mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
WPS ER: Show SetSelectedRegistrar events as ctrl_iface events
This makes it easier to figure out if something goes wrong in preparing the AP for enrolling a station.
This commit is contained in:
parent
c973f3868a
commit
3e7533b399
@ -571,6 +571,8 @@ static void hostapd_wps_event_cb(void *ctx, enum wps_event event,
|
||||
break;
|
||||
case WPS_EV_ER_AP_SETTINGS:
|
||||
break;
|
||||
case WPS_EV_ER_SET_SELECTED_REGISTRAR:
|
||||
break;
|
||||
}
|
||||
if (hapd->wps_event_cb)
|
||||
hapd->wps_event_cb(hapd->wps_event_cb_ctx, event, data);
|
||||
|
@ -89,6 +89,7 @@ extern "C" {
|
||||
#define WPS_EVENT_ER_ENROLLEE_ADD "WPS-ER-ENROLLEE-ADD "
|
||||
#define WPS_EVENT_ER_ENROLLEE_REMOVE "WPS-ER-ENROLLEE-REMOVE "
|
||||
#define WPS_EVENT_ER_AP_SETTINGS "WPS-ER-AP-SETTINGS "
|
||||
#define WPS_EVENT_ER_SET_SEL_REG "WPS-ER-AP-SET-SEL-REG "
|
||||
|
||||
/** P2P device found */
|
||||
#define P2P_EVENT_DEVICE_FOUND "P2P-DEVICE-FOUND "
|
||||
|
@ -417,7 +417,12 @@ enum wps_event {
|
||||
/**
|
||||
* WPS_EV_ER_AP_SETTINGS - ER: AP Settings learned
|
||||
*/
|
||||
WPS_EV_ER_AP_SETTINGS
|
||||
WPS_EV_ER_AP_SETTINGS,
|
||||
|
||||
/**
|
||||
* WPS_EV_ER_SET_SELECTED_REGISTRAR - ER: SetSelectedRegistrar event
|
||||
*/
|
||||
WPS_EV_ER_SET_SELECTED_REGISTRAR
|
||||
};
|
||||
|
||||
/**
|
||||
@ -492,6 +497,18 @@ union wps_event_data {
|
||||
const u8 *uuid;
|
||||
const struct wps_credential *cred;
|
||||
} ap_settings;
|
||||
|
||||
struct wps_event_er_set_selected_registrar {
|
||||
const u8 *uuid;
|
||||
int sel_reg;
|
||||
u16 dev_passwd_id;
|
||||
u16 sel_reg_config_methods;
|
||||
enum {
|
||||
WPS_ER_SET_SEL_REG_START,
|
||||
WPS_ER_SET_SEL_REG_DONE,
|
||||
WPS_ER_SET_SEL_REG_FAILED
|
||||
} state;
|
||||
} set_sel_reg;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1269,19 +1269,30 @@ static void wps_er_http_set_sel_reg_cb(void *ctx, struct http_client *c,
|
||||
enum http_client_event event)
|
||||
{
|
||||
struct wps_er_ap *ap = ctx;
|
||||
union wps_event_data data;
|
||||
|
||||
os_memset(&data, 0, sizeof(data));
|
||||
|
||||
switch (event) {
|
||||
case HTTP_CLIENT_OK:
|
||||
wpa_printf(MSG_DEBUG, "WPS ER: SetSelectedRegistrar OK");
|
||||
data.set_sel_reg.state = WPS_ER_SET_SEL_REG_DONE;
|
||||
data.set_sel_reg.uuid = ap->uuid;
|
||||
break;
|
||||
case HTTP_CLIENT_FAILED:
|
||||
case HTTP_CLIENT_INVALID_REPLY:
|
||||
case HTTP_CLIENT_TIMEOUT:
|
||||
wpa_printf(MSG_DEBUG, "WPS ER: SetSelectedRegistrar failed");
|
||||
data.set_sel_reg.state = WPS_ER_SET_SEL_REG_FAILED;
|
||||
data.set_sel_reg.uuid = ap->uuid;
|
||||
break;
|
||||
}
|
||||
http_client_free(ap->http);
|
||||
ap->http = NULL;
|
||||
|
||||
if (data.set_sel_reg.uuid)
|
||||
ap->er->wps->event_cb(ap->er->wps->cb_ctx,
|
||||
WPS_EV_ER_SET_SELECTED_REGISTRAR, &data);
|
||||
}
|
||||
|
||||
|
||||
@ -1377,6 +1388,7 @@ void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
|
||||
struct wps_registrar *reg = er->wps->registrar;
|
||||
const u8 *auth_macs;
|
||||
size_t count;
|
||||
union wps_event_data data;
|
||||
|
||||
if (er->skip_set_sel_reg) {
|
||||
wpa_printf(MSG_DEBUG, "WPS ER: Skip SetSelectedRegistrar");
|
||||
@ -1399,8 +1411,18 @@ void wps_er_set_sel_reg(struct wps_er *er, int sel_reg, u16 dev_passwd_id,
|
||||
return;
|
||||
}
|
||||
|
||||
dl_list_for_each(ap, &er->ap, struct wps_er_ap, list)
|
||||
os_memset(&data, 0, sizeof(data));
|
||||
data.set_sel_reg.sel_reg = sel_reg;
|
||||
data.set_sel_reg.dev_passwd_id = dev_passwd_id;
|
||||
data.set_sel_reg.sel_reg_config_methods = sel_reg_config_methods;
|
||||
data.set_sel_reg.state = WPS_ER_SET_SEL_REG_START;
|
||||
|
||||
dl_list_for_each(ap, &er->ap, struct wps_er_ap, list) {
|
||||
data.set_sel_reg.uuid = ap->uuid;
|
||||
er->wps->event_cb(er->wps->cb_ctx,
|
||||
WPS_EV_ER_SET_SELECTED_REGISTRAR, &data);
|
||||
wps_er_send_set_sel_reg(ap, msg);
|
||||
}
|
||||
|
||||
wpabuf_free(msg);
|
||||
}
|
||||
|
@ -509,6 +509,33 @@ static void wpa_supplicant_wps_event_er_ap_settings(
|
||||
}
|
||||
|
||||
|
||||
static void wpa_supplicant_wps_event_er_set_sel_reg(
|
||||
struct wpa_supplicant *wpa_s,
|
||||
struct wps_event_er_set_selected_registrar *ev)
|
||||
{
|
||||
char uuid_str[100];
|
||||
|
||||
uuid_bin2str(ev->uuid, uuid_str, sizeof(uuid_str));
|
||||
switch (ev->state) {
|
||||
case WPS_ER_SET_SEL_REG_START:
|
||||
wpa_msg(wpa_s, MSG_DEBUG, WPS_EVENT_ER_SET_SEL_REG
|
||||
"uuid=%s state=START sel_reg=%d dev_passwd_id=%u "
|
||||
"sel_reg_config_methods=0x%x",
|
||||
uuid_str, ev->sel_reg, ev->dev_passwd_id,
|
||||
ev->sel_reg_config_methods);
|
||||
break;
|
||||
case WPS_ER_SET_SEL_REG_DONE:
|
||||
wpa_msg(wpa_s, MSG_DEBUG, WPS_EVENT_ER_SET_SEL_REG
|
||||
"uuid=%s state=DONE", uuid_str);
|
||||
break;
|
||||
case WPS_ER_SET_SEL_REG_FAILED:
|
||||
wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_SET_SEL_REG
|
||||
"uuid=%s state=FAILED", uuid_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
|
||||
union wps_event_data *data)
|
||||
{
|
||||
@ -547,6 +574,10 @@ static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
|
||||
wpa_supplicant_wps_event_er_ap_settings(wpa_s,
|
||||
&data->ap_settings);
|
||||
break;
|
||||
case WPS_EV_ER_SET_SELECTED_REGISTRAR:
|
||||
wpa_supplicant_wps_event_er_set_sel_reg(wpa_s,
|
||||
&data->set_sel_reg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user