WPS: Added WPS support into wpa_gui-qt4
Currently, only Enrollee operations (both PBC and PIN) are supported.
This commit is contained in:
parent
ff8a53a8d7
commit
3d799c0b2c
3 changed files with 248 additions and 0 deletions
|
@ -48,6 +48,7 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
|
||||||
SLOT(eventHistory()));
|
SLOT(eventHistory()));
|
||||||
connect(fileSaveConfigAction, SIGNAL(triggered()), this,
|
connect(fileSaveConfigAction, SIGNAL(triggered()), this,
|
||||||
SLOT(saveConfig()));
|
SLOT(saveConfig()));
|
||||||
|
connect(actionWPS, SIGNAL(triggered()), this, SLOT(wpsDialog()));
|
||||||
connect(fileExitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
|
connect(fileExitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
|
||||||
connect(networkAddAction, SIGNAL(triggered()), this,
|
connect(networkAddAction, SIGNAL(triggered()), this,
|
||||||
SLOT(addNetwork()));
|
SLOT(addNetwork()));
|
||||||
|
@ -86,6 +87,10 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
|
||||||
connect(scanNetworkButton, SIGNAL(clicked()), this, SLOT(scan()));
|
connect(scanNetworkButton, SIGNAL(clicked()), this, SLOT(scan()));
|
||||||
connect(networkList, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
connect(networkList, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
||||||
this, SLOT(editListedNetwork()));
|
this, SLOT(editListedNetwork()));
|
||||||
|
connect(wpaguiTab, SIGNAL(currentChanged(int)), this,
|
||||||
|
SLOT(tabChanged(int)));
|
||||||
|
connect(wpsPbcButton, SIGNAL(clicked()), this, SLOT(wpsPbc()));
|
||||||
|
connect(wpsPinButton, SIGNAL(clicked()), this, SLOT(wpsGeneratePin()));
|
||||||
|
|
||||||
eh = NULL;
|
eh = NULL;
|
||||||
scanres = NULL;
|
scanres = NULL;
|
||||||
|
@ -340,6 +345,16 @@ int WpaGui::openCtrlConnection(const char *ifname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len = sizeof(buf) - 1;
|
||||||
|
if (wpa_ctrl_request(ctrl_conn, "GET_CAPABILITY eap", 18, buf, &len,
|
||||||
|
NULL) >= 0) {
|
||||||
|
buf[len] = '\0';
|
||||||
|
|
||||||
|
QString res(buf);
|
||||||
|
QStringList types = res.split(QChar(' '));
|
||||||
|
actionWPS->setEnabled(types.contains("WSC"));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,6 +614,14 @@ void WpaGui::disconnect()
|
||||||
char reply[10];
|
char reply[10];
|
||||||
size_t reply_len = sizeof(reply);
|
size_t reply_len = sizeof(reply);
|
||||||
ctrlRequest("DISCONNECT", reply, &reply_len);
|
ctrlRequest("DISCONNECT", reply, &reply_len);
|
||||||
|
|
||||||
|
if (wpsRunning)
|
||||||
|
wpsStatusText->setText("Stopped");
|
||||||
|
else
|
||||||
|
wpsStatusText->setText("");
|
||||||
|
wpsPinEdit->setEnabled(false);
|
||||||
|
wpsInstructions->setText("");
|
||||||
|
wpsRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -738,6 +761,48 @@ void WpaGui::processMsg(char *msg)
|
||||||
showTrayMessage(QSystemTrayIcon::Information, 3,
|
showTrayMessage(QSystemTrayIcon::Information, 3,
|
||||||
"Connection to network established.");
|
"Connection to network established.");
|
||||||
QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
|
QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
|
||||||
|
if (wpsRunning) {
|
||||||
|
wpsStatusText->setText("Connected to the network");
|
||||||
|
wpsPinEdit->setEnabled(false);
|
||||||
|
wpsInstructions->setText("");
|
||||||
|
wpsRunning = false;
|
||||||
|
}
|
||||||
|
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PBC)) {
|
||||||
|
showTrayMessage(QSystemTrayIcon::Information, 3,
|
||||||
|
"Wi-Fi Protected Setup (WPS) AP\n"
|
||||||
|
"in active PBC mode found.");
|
||||||
|
wpsStatusText->setText("WPS AP in active PBC mode found");
|
||||||
|
wpaguiTab->setCurrentWidget(wpsTab);
|
||||||
|
wpsInstructions->setText("Press the PBC button on the screen "
|
||||||
|
"to start registration");
|
||||||
|
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PIN)) {
|
||||||
|
showTrayMessage(QSystemTrayIcon::Information, 3,
|
||||||
|
"Wi-Fi Protected Setup (WPS) AP\n"
|
||||||
|
" in active PIN mode found.");
|
||||||
|
wpsStatusText->setText("WPS AP with recently selected "
|
||||||
|
"registrar");
|
||||||
|
wpaguiTab->setCurrentWidget(wpsTab);
|
||||||
|
} else if (str_match(pos, WPS_EVENT_AP_AVAILABLE)) {
|
||||||
|
showTrayMessage(QSystemTrayIcon::Information, 3,
|
||||||
|
"Wi-Fi Protected Setup (WPS)\n"
|
||||||
|
"AP detected.");
|
||||||
|
wpsStatusText->setText("WPS AP detected");
|
||||||
|
wpaguiTab->setCurrentWidget(wpsTab);
|
||||||
|
} else if (str_match(pos, WPS_EVENT_OVERLAP)) {
|
||||||
|
showTrayMessage(QSystemTrayIcon::Information, 3,
|
||||||
|
"Wi-Fi Protected Setup (WPS)\n"
|
||||||
|
"PBC mode overlap detected.");
|
||||||
|
wpsStatusText->setText("PBC mode overlap detected");
|
||||||
|
wpsInstructions->setText("More than one AP is currently in "
|
||||||
|
"active WPS PBC mode. Wait couple of "
|
||||||
|
"minutes and try again");
|
||||||
|
wpaguiTab->setCurrentWidget(wpsTab);
|
||||||
|
} else if (str_match(pos, WPS_EVENT_CRED_RECEIVED)) {
|
||||||
|
wpsStatusText->setText("Network configuration received");
|
||||||
|
wpaguiTab->setCurrentWidget(wpsTab);
|
||||||
|
} else if (str_match(pos, WPA_EVENT_EAP_METHOD)) {
|
||||||
|
if (strstr(pos, "(WSC)"))
|
||||||
|
wpsStatusText->setText("Registration started");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,6 +869,14 @@ void WpaGui::selectNetwork( const QString &sel )
|
||||||
cmd.prepend("SELECT_NETWORK ");
|
cmd.prepend("SELECT_NETWORK ");
|
||||||
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
|
||||||
triggerUpdate();
|
triggerUpdate();
|
||||||
|
|
||||||
|
if (wpsRunning)
|
||||||
|
wpsStatusText->setText("Stopped");
|
||||||
|
else
|
||||||
|
wpsStatusText->setText("");
|
||||||
|
wpsPinEdit->setEnabled(false);
|
||||||
|
wpsInstructions->setText("");
|
||||||
|
wpsRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1275,3 +1348,64 @@ void WpaGui::closeEvent(QCloseEvent *event)
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WpaGui::wpsDialog()
|
||||||
|
{
|
||||||
|
wpaguiTab->setCurrentWidget(wpsTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WpaGui::tabChanged(int index)
|
||||||
|
{
|
||||||
|
if (index != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (wpsRunning)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* TODO: Update WPS status based on latest scan results and
|
||||||
|
* availability of WPS APs */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WpaGui::wpsPbc()
|
||||||
|
{
|
||||||
|
char reply[20];
|
||||||
|
size_t reply_len = sizeof(reply);
|
||||||
|
|
||||||
|
if (ctrlRequest("WPS_PBC", reply, &reply_len) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wpsPinEdit->setEnabled(false);
|
||||||
|
if (wpsStatusText->text().compare("WPS AP in active PBC mode found")) {
|
||||||
|
wpsInstructions->setText("Press the push button on the AP to "
|
||||||
|
"start the PBC mode.");
|
||||||
|
} else {
|
||||||
|
wpsInstructions->setText("If you have not yet done so, press "
|
||||||
|
"the push button on the AP to start "
|
||||||
|
"the PBC mode.");
|
||||||
|
}
|
||||||
|
wpsStatusText->setText("Waiting for Registrar");
|
||||||
|
wpsRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WpaGui::wpsGeneratePin()
|
||||||
|
{
|
||||||
|
char reply[20];
|
||||||
|
size_t reply_len = sizeof(reply) - 1;
|
||||||
|
|
||||||
|
if (ctrlRequest("WPS_PIN any", reply, &reply_len) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
reply[reply_len] = '\0';
|
||||||
|
|
||||||
|
wpsPinEdit->setText(reply);
|
||||||
|
wpsPinEdit->setEnabled(true);
|
||||||
|
wpsInstructions->setText("Enter the generated PIN into the Registrar "
|
||||||
|
"(either the internal one in the AP or an "
|
||||||
|
"external one).");
|
||||||
|
wpsStatusText->setText("Waiting for Registrar");
|
||||||
|
wpsRunning = true;
|
||||||
|
}
|
||||||
|
|
|
@ -71,6 +71,10 @@ public slots:
|
||||||
virtual void showTrayMessage(QSystemTrayIcon::MessageIcon type,
|
virtual void showTrayMessage(QSystemTrayIcon::MessageIcon type,
|
||||||
int sec, const QString &msg);
|
int sec, const QString &msg);
|
||||||
virtual void showTrayStatus();
|
virtual void showTrayStatus();
|
||||||
|
virtual void wpsDialog();
|
||||||
|
virtual void tabChanged(int index);
|
||||||
|
virtual void wpsPbc();
|
||||||
|
virtual void wpsGeneratePin();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void languageChange();
|
virtual void languageChange();
|
||||||
|
@ -105,6 +109,8 @@ private:
|
||||||
bool startInTray;
|
bool startInTray;
|
||||||
|
|
||||||
int openCtrlConnection(const char *ifname);
|
int openCtrlConnection(const char *ifname);
|
||||||
|
|
||||||
|
bool wpsRunning;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WPAGUI_H */
|
#endif /* WPAGUI_H */
|
||||||
|
|
|
@ -289,6 +289,105 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="wpsTab" >
|
||||||
|
<attribute name="title" >
|
||||||
|
<string>WPS</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QPushButton" name="wpsPbcButton" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>141</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>PBC - push button</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="wpsPinButton" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>90</y>
|
||||||
|
<width>141</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Generate PIN</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>160</x>
|
||||||
|
<y>100</y>
|
||||||
|
<width>21</width>
|
||||||
|
<height>18</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>PIN</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="wpsPinEdit" >
|
||||||
|
<property name="enabled" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>190</x>
|
||||||
|
<y>90</y>
|
||||||
|
<width>113</width>
|
||||||
|
<height>28</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>41</width>
|
||||||
|
<height>18</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Status:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="wpsStatusText" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>70</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>231</width>
|
||||||
|
<height>18</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" name="wpsInstructions" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>130</y>
|
||||||
|
<width>301</width>
|
||||||
|
<height>91</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly" >
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -308,6 +407,7 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="fileEventHistoryAction" />
|
<addaction name="fileEventHistoryAction" />
|
||||||
<addaction name="fileSaveConfigAction" />
|
<addaction name="fileSaveConfigAction" />
|
||||||
|
<addaction name="actionWPS" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="fileExitAction" />
|
<addaction name="fileExitAction" />
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -408,6 +508,14 @@
|
||||||
<string>&About</string>
|
<string>&About</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionWPS" >
|
||||||
|
<property name="enabled" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Wi-Fi Protected Setup</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11" />
|
<layoutdefault spacing="6" margin="11" />
|
||||||
<pixmapfunction></pixmapfunction>
|
<pixmapfunction></pixmapfunction>
|
||||||
|
|
Loading…
Reference in a new issue