WPS: Added event callback for successfully completed registration
authorJouni Malinen <j@w1.fi>
Fri, 19 Dec 2008 20:34:18 +0000 (22:34 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 19 Dec 2008 20:34:18 +0000 (22:34 +0200)
src/common/wpa_ctrl.h
src/wps/wps.h
src/wps/wps_common.c
src/wps/wps_enrollee.c
src/wps/wps_i.h
src/wps/wps_registrar.c
wpa_supplicant/wpa_gui-qt4/wpagui.cpp
wpa_supplicant/wps_supplicant.c

index b093f28..9306a33 100644 (file)
@@ -64,6 +64,8 @@ extern "C" {
 #define WPS_EVENT_M2D "WPS-M2D "
 /** WPS registration failed after M2/M2D */
 #define WPS_EVENT_FAIL "WPS-FAIL "
+/** WPS registration completed successfully */
+#define WPS_EVENT_SUCCESS "WPS-SUCCESS "
 
 /* hostapd control interface - fixed message prefixes */
 #define WPS_EVENT_PIN_NEEDED "WPS-PIN-NEEDED "
index d61db68..7d78a53 100644 (file)
@@ -97,7 +97,8 @@ struct wps_registrar_config {
 
 enum wps_event {
        WPS_EV_M2D,
-       WPS_EV_FAIL
+       WPS_EV_FAIL,
+       WPS_EV_SUCCESS
 };
 
 union wps_event_data {
index 99f6eb9..9273d37 100644 (file)
@@ -311,3 +311,12 @@ void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg)
        data.fail.msg = msg;
        wps->event_cb(wps->cb_ctx, WPS_EV_FAIL, &data);
 }
+
+
+void wps_success_event(struct wps_context *wps)
+{
+       if (wps->event_cb == NULL)
+               return;
+
+       wps->event_cb(wps->cb_ctx, WPS_EV_SUCCESS, NULL);
+}
index 18967cd..a63a578 100644 (file)
@@ -326,7 +326,12 @@ static struct wpabuf * wps_build_wsc_done(struct wps_data *wps)
                return NULL;
        }
 
-       wps->state = wps->authenticator ? RECV_ACK : WPS_FINISHED;
+       if (wps->authenticator)
+               wps->state = RECV_ACK;
+       else {
+               wps_success_event(wps->wps);
+               wps->state = WPS_FINISHED;
+       }
        return msg;
 }
 
@@ -1020,6 +1025,7 @@ static enum wps_process_res wps_process_wsc_ack(struct wps_data *wps,
        if (wps->state == RECV_ACK && wps->authenticator) {
                wpa_printf(MSG_DEBUG, "WPS: External Registrar registration "
                           "completed successfully");
+               wps_success_event(wps->wps);
                wps->state = WPS_FINISHED;
                return WPS_DONE;
        }
index 3ae53b8..35130b1 100644 (file)
@@ -166,6 +166,7 @@ void wps_derive_psk(struct wps_data *wps, const u8 *dev_passwd,
 struct wpabuf * wps_decrypt_encr_settings(struct wps_data *wps, const u8 *encr,
                                          size_t encr_len);
 void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg);
+void wps_success_event(struct wps_context *wps);
 
 /* wps_attr_parse.c */
 int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
index cd53c74..4d5e0c3 100644 (file)
@@ -2077,6 +2077,8 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
                wps_registrar_pbc_completed(wps->registrar);
        }
 
+       wps_success_event(wps->wps);
+
        return WPS_DONE;
 }
 
index dc555ab..e6bdf52 100644 (file)
@@ -806,6 +806,8 @@ void WpaGui::processMsg(char *msg)
                wpsStatusText->setText("Registrar does not yet know PIN");
        } else if (str_match(pos, WPS_EVENT_FAIL)) {
                wpsStatusText->setText("Registration failed");
+       } else if (str_match(pos, WPS_EVENT_SUCCESS)) {
+               wpsStatusText->setText("Registration succeeded");
        }
 }
 
index 1babe86..1ceabc9 100644 (file)
@@ -198,6 +198,12 @@ static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
 }
 
 
+static void wpa_supplicant_wps_event_success(struct wpa_supplicant *wpa_s)
+{
+       wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
+}
+
+
 static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
                                     union wps_event_data *data)
 {
@@ -209,6 +215,9 @@ static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
        case WPS_EV_FAIL:
                wpa_supplicant_wps_event_fail(wpa_s, &data->fail);
                break;
+       case WPS_EV_SUCCESS:
+               wpa_supplicant_wps_event_success(wpa_s);
+               break;
        }
 }