diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index 28e037dc1..87bbd3763 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -186,11 +186,26 @@ static void hostapd_wps_pin_needed_cb(void *ctx, const u8 *uuid_e, } +struct wps_stop_reg_data { + struct hostapd_data *current_hapd; + const u8 *uuid_e; +}; + +static int wps_stop_registrar(struct hostapd_data *hapd, void *ctx) +{ + struct wps_stop_reg_data *data = ctx; + if (hapd != data->current_hapd && hapd->wps != NULL) + wps_registrar_complete(hapd->wps->registrar, data->uuid_e); + return 0; +} + + static void hostapd_wps_reg_success_cb(void *ctx, const u8 *mac_addr, const u8 *uuid_e) { struct hostapd_data *hapd = ctx; char uuid[40]; + struct wps_stop_reg_data data; if (uuid_bin2str(uuid_e, uuid, sizeof(uuid))) return; wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_REG_SUCCESS MACSTR " %s", @@ -198,6 +213,9 @@ static void hostapd_wps_reg_success_cb(void *ctx, const u8 *mac_addr, if (hapd->wps_reg_success_cb) hapd->wps_reg_success_cb(hapd->wps_reg_success_cb_ctx, mac_addr, uuid_e); + data.current_hapd = hapd; + data.uuid_e = uuid_e; + hostapd_wps_for_each(hapd, wps_stop_registrar, &data); } diff --git a/src/wps/wps.h b/src/wps/wps.h index cdafc2709..4986881b0 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -784,6 +784,7 @@ int wps_registrar_wps_cancel(struct wps_registrar *reg); int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid); int wps_registrar_button_pushed(struct wps_registrar *reg, const u8 *p2p_dev_addr); +void wps_registrar_complete(struct wps_registrar *registrar, const u8 *uuid_e); void wps_registrar_probe_req_rx(struct wps_registrar *reg, const u8 *addr, const struct wpabuf *wps_data, int p2p_wildcard); diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index 66ed41086..e59edb87a 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -941,6 +941,18 @@ static void wps_registrar_pin_completed(struct wps_registrar *reg) } +void wps_registrar_complete(struct wps_registrar *registrar, const u8 *uuid_e) +{ + if (registrar->pbc) { + wps_registrar_remove_pbc_session(registrar, + uuid_e); + wps_registrar_pbc_completed(registrar); + } else { + wps_registrar_pin_completed(registrar); + } +} + + int wps_registrar_wps_cancel(struct wps_registrar *reg) { if (reg->pbc) {