diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index b093f2805..9306a3332 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -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 " diff --git a/src/wps/wps.h b/src/wps/wps.h index d61db68e1..7d78a5350 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -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 { diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c index 99f6eb9ad..9273d3749 100644 --- a/src/wps/wps_common.c +++ b/src/wps/wps_common.c @@ -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); +} diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c index 18967cd37..a63a578c3 100644 --- a/src/wps/wps_enrollee.c +++ b/src/wps/wps_enrollee.c @@ -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; } diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h index 3ae53b8ea..35130b1a6 100644 --- a/src/wps/wps_i.h +++ b/src/wps/wps_i.h @@ -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); diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index cd53c74de..4d5e0c34d 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -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; } diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp index dc555ab83..e6bdf52cf 100644 --- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp +++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp @@ -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"); } } diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index 1babe86ef..1ceabc963 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -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; } }