diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h index 5450ee42c..4032db895 100644 --- a/src/common/wpa_ctrl.h +++ b/src/common/wpa_ctrl.h @@ -60,6 +60,8 @@ extern "C" { #define WPS_EVENT_AP_AVAILABLE "WPS-AP-AVAILABLE " /** A new credential received */ #define WPS_EVENT_CRED_RECEIVED "WPS-CRED-RECEIVED " +/** M2D received */ +#define WPS_EVENT_M2D "WPS-M2D " /* 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 c1e8eb78f..e1026b6fa 100644 --- a/src/wps/wps.h +++ b/src/wps/wps.h @@ -95,6 +95,29 @@ struct wps_registrar_config { }; +enum wps_event { + WPS_EV_M2D +}; + +union wps_event_data { + struct wps_event_m2d { + u16 config_methods; + const u8 *manufacturer; + size_t manufacturer_len; + const u8 *model_name; + size_t model_name_len; + const u8 *model_number; + size_t model_number_len; + const u8 *serial_number; + size_t serial_number_len; + const u8 *dev_name; + size_t dev_name_len; + const u8 *primary_dev_type; /* 8 octets */ + u16 config_error; + u16 dev_password_id; + } m2d; +}; + /** * struct wps_context - Long term WPS context data * @@ -117,6 +140,8 @@ struct wps_context { size_t network_key_len; int (*cred_cb)(void *ctx, const struct wps_credential *cred); + void (*event_cb)(void *ctx, enum wps_event event, + union wps_event_data *data); void *cb_ctx; }; diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c index 92e57a869..7fd1b35f7 100644 --- a/src/wps/wps_enrollee.c +++ b/src/wps/wps_enrollee.c @@ -733,10 +733,32 @@ static enum wps_process_res wps_process_m2d(struct wps_data *wps, wpa_hexdump_ascii(MSG_DEBUG, "WPS: Device Name", attr->dev_name, attr->dev_name_len); - /* - * TODO: notify monitor programs (cli/gui/etc.) of the M2D and provide - * user information about the registrar properties. - */ + if (wps->wps->event_cb) { + union wps_event_data data; + struct wps_event_m2d *m2d = &data.m2d; + os_memset(&data, 0, sizeof(data)); + if (attr->config_methods) + m2d->config_methods = + WPA_GET_BE16(attr->config_methods); + m2d->manufacturer = attr->manufacturer; + m2d->manufacturer_len = attr->manufacturer_len; + m2d->model_name = attr->model_name; + m2d->model_name_len = attr->model_name_len; + m2d->model_number = attr->model_number; + m2d->model_number_len = attr->model_number_len; + m2d->serial_number = attr->serial_number; + m2d->serial_number_len = attr->serial_number_len; + m2d->dev_name = attr->dev_name; + m2d->dev_name_len = attr->dev_name_len; + m2d->primary_dev_type = attr->primary_dev_type; + if (attr->config_error) + m2d->config_error = + WPA_GET_BE16(attr->config_error); + if (attr->dev_password_id) + m2d->dev_password_id = + WPA_GET_BE16(attr->dev_password_id); + wps->wps->event_cb(wps->wps->cb_ctx, WPS_EV_M2D, &data); + } wps->state = RECEIVED_M2D; return WPS_CONTINUE; diff --git a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp index 829e3c1c9..edf88ea0a 100644 --- a/wpa_supplicant/wpa_gui-qt4/wpagui.cpp +++ b/wpa_supplicant/wpa_gui-qt4/wpagui.cpp @@ -802,6 +802,8 @@ void WpaGui::processMsg(char *msg) } else if (str_match(pos, WPA_EVENT_EAP_METHOD)) { if (strstr(pos, "(WSC)")) wpsStatusText->setText("Registration started"); + } else if (str_match(pos, WPS_EVENT_M2D)) { + wpsStatusText->setText("Registrar does not yet know PIN"); } } diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c index dcd072473..5f3b29d5b 100644 --- a/wpa_supplicant/wps_supplicant.c +++ b/wpa_supplicant/wps_supplicant.c @@ -180,6 +180,27 @@ static int wpa_supplicant_wps_cred(void *ctx, } +static void wpa_supplicant_wps_event_m2d(struct wpa_supplicant *wpa_s, + struct wps_event_m2d *m2d) +{ + wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_M2D + "dev_password_id=%d config_error=%d", + m2d->dev_password_id, m2d->config_error); +} + + +static void wpa_supplicant_wps_event(void *ctx, enum wps_event event, + union wps_event_data *data) +{ + struct wpa_supplicant *wpa_s = ctx; + switch (event) { + case WPS_EV_M2D: + wpa_supplicant_wps_event_m2d(wpa_s, &data->m2d); + break; + } +} + + u8 wpas_wps_get_req_type(struct wpa_ssid *ssid) { if (eap_is_wps_pbc_enrollee(&ssid->eap) || @@ -361,6 +382,7 @@ int wpas_wps_init(struct wpa_supplicant *wpa_s) return -1; wps->cred_cb = wpa_supplicant_wps_cred; + wps->event_cb = wpa_supplicant_wps_event; wps->cb_ctx = wpa_s; wps->dev.device_name = wpa_s->conf->device_name;