WPS: Added event callback for successfully completed registration
This commit is contained in:
parent
469fc3a41f
commit
ad5302a1ca
8 changed files with 34 additions and 2 deletions
|
@ -64,6 +64,8 @@ extern "C" {
|
||||||
#define WPS_EVENT_M2D "WPS-M2D "
|
#define WPS_EVENT_M2D "WPS-M2D "
|
||||||
/** WPS registration failed after M2/M2D */
|
/** WPS registration failed after M2/M2D */
|
||||||
#define WPS_EVENT_FAIL "WPS-FAIL "
|
#define WPS_EVENT_FAIL "WPS-FAIL "
|
||||||
|
/** WPS registration completed successfully */
|
||||||
|
#define WPS_EVENT_SUCCESS "WPS-SUCCESS "
|
||||||
|
|
||||||
/* hostapd control interface - fixed message prefixes */
|
/* hostapd control interface - fixed message prefixes */
|
||||||
#define WPS_EVENT_PIN_NEEDED "WPS-PIN-NEEDED "
|
#define WPS_EVENT_PIN_NEEDED "WPS-PIN-NEEDED "
|
||||||
|
|
|
@ -97,7 +97,8 @@ struct wps_registrar_config {
|
||||||
|
|
||||||
enum wps_event {
|
enum wps_event {
|
||||||
WPS_EV_M2D,
|
WPS_EV_M2D,
|
||||||
WPS_EV_FAIL
|
WPS_EV_FAIL,
|
||||||
|
WPS_EV_SUCCESS
|
||||||
};
|
};
|
||||||
|
|
||||||
union wps_event_data {
|
union wps_event_data {
|
||||||
|
|
|
@ -311,3 +311,12 @@ void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg)
|
||||||
data.fail.msg = msg;
|
data.fail.msg = msg;
|
||||||
wps->event_cb(wps->cb_ctx, WPS_EV_FAIL, &data);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -326,7 +326,12 @@ static struct wpabuf * wps_build_wsc_done(struct wps_data *wps)
|
||||||
return NULL;
|
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;
|
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) {
|
if (wps->state == RECV_ACK && wps->authenticator) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS: External Registrar registration "
|
wpa_printf(MSG_DEBUG, "WPS: External Registrar registration "
|
||||||
"completed successfully");
|
"completed successfully");
|
||||||
|
wps_success_event(wps->wps);
|
||||||
wps->state = WPS_FINISHED;
|
wps->state = WPS_FINISHED;
|
||||||
return WPS_DONE;
|
return WPS_DONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
struct wpabuf * wps_decrypt_encr_settings(struct wps_data *wps, const u8 *encr,
|
||||||
size_t encr_len);
|
size_t encr_len);
|
||||||
void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg);
|
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 */
|
/* wps_attr_parse.c */
|
||||||
int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
|
int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
|
||||||
|
|
|
@ -2077,6 +2077,8 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
|
||||||
wps_registrar_pbc_completed(wps->registrar);
|
wps_registrar_pbc_completed(wps->registrar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wps_success_event(wps->wps);
|
||||||
|
|
||||||
return WPS_DONE;
|
return WPS_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -806,6 +806,8 @@ void WpaGui::processMsg(char *msg)
|
||||||
wpsStatusText->setText("Registrar does not yet know PIN");
|
wpsStatusText->setText("Registrar does not yet know PIN");
|
||||||
} else if (str_match(pos, WPS_EVENT_FAIL)) {
|
} else if (str_match(pos, WPS_EVENT_FAIL)) {
|
||||||
wpsStatusText->setText("Registration failed");
|
wpsStatusText->setText("Registration failed");
|
||||||
|
} else if (str_match(pos, WPS_EVENT_SUCCESS)) {
|
||||||
|
wpsStatusText->setText("Registration succeeded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
|
||||||
union wps_event_data *data)
|
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:
|
case WPS_EV_FAIL:
|
||||||
wpa_supplicant_wps_event_fail(wpa_s, &data->fail);
|
wpa_supplicant_wps_event_fail(wpa_s, &data->fail);
|
||||||
break;
|
break;
|
||||||
|
case WPS_EV_SUCCESS:
|
||||||
|
wpa_supplicant_wps_event_success(wpa_s);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue