aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-12-15 20:36:42 (GMT)
committerJouni Malinen <j@w1.fi>2008-12-15 20:36:42 (GMT)
commit3d799c0b2cb79f4980b14eea6de80d11ddb75c45 (patch)
tree369682ddc8b7aab657e969c2d7b67f49c1f6a4a1 /wpa_supplicant
parentff8a53a8d7ebe5ff9dd48a4bb764d3b825dac525 (diff)
downloadhostap-06-3d799c0b2cb79f4980b14eea6de80d11ddb75c45.zip
hostap-06-3d799c0b2cb79f4980b14eea6de80d11ddb75c45.tar.gz
hostap-06-3d799c0b2cb79f4980b14eea6de80d11ddb75c45.tar.bz2
WPS: Added WPS support into wpa_gui-qt4
Currently, only Enrollee operations (both PBC and PIN) are supported.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.cpp134
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.h6
-rw-r--r--wpa_supplicant/wpa_gui-qt4/wpagui.ui108
3 files changed, 248 insertions, 0 deletions
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
index cd700a1..bd1c507 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp
@@ -48,6 +48,7 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
SLOT(eventHistory()));
connect(fileSaveConfigAction, SIGNAL(triggered()), this,
SLOT(saveConfig()));
+ connect(actionWPS, SIGNAL(triggered()), this, SLOT(wpsDialog()));
connect(fileExitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(networkAddAction, SIGNAL(triggered()), this,
SLOT(addNetwork()));
@@ -86,6 +87,10 @@ WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
connect(scanNetworkButton, SIGNAL(clicked()), this, SLOT(scan()));
connect(networkList, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
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;
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;
}
@@ -599,6 +614,14 @@ void WpaGui::disconnect()
char reply[10];
size_t reply_len = sizeof(reply);
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,
"Connection to network established.");
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 ");
ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
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();
}
+
+
+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;
+}
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.h b/wpa_supplicant/wpa_gui-qt4/wpagui.h
index 45e878a..c805962 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.h
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.h
@@ -71,6 +71,10 @@ public slots:
virtual void showTrayMessage(QSystemTrayIcon::MessageIcon type,
int sec, const QString &msg);
virtual void showTrayStatus();
+ virtual void wpsDialog();
+ virtual void tabChanged(int index);
+ virtual void wpsPbc();
+ virtual void wpsGeneratePin();
protected slots:
virtual void languageChange();
@@ -105,6 +109,8 @@ private:
bool startInTray;
int openCtrlConnection(const char *ifname);
+
+ bool wpsRunning;
};
#endif /* WPAGUI_H */
diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.ui b/wpa_supplicant/wpa_gui-qt4/wpagui.ui
index 0758ce6..71e62a9 100644
--- a/wpa_supplicant/wpa_gui-qt4/wpagui.ui
+++ b/wpa_supplicant/wpa_gui-qt4/wpagui.ui
@@ -289,6 +289,105 @@
</item>
</layout>
</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>
</item>
</layout>
@@ -308,6 +407,7 @@
</property>
<addaction name="fileEventHistoryAction" />
<addaction name="fileSaveConfigAction" />
+ <addaction name="actionWPS" />
<addaction name="separator" />
<addaction name="fileExitAction" />
</widget>
@@ -408,6 +508,14 @@
<string>&amp;About</string>
</property>
</action>
+ <action name="actionWPS" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="text" >
+ <string>&amp;Wi-Fi Protected Setup</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>