WPS ER: Add ctrl_iface event for learned AP settings
This commit is contained in:
parent
0848668513
commit
15dbf1291a
4 changed files with 49 additions and 2 deletions
|
@ -86,6 +86,7 @@ extern "C" {
|
||||||
#define WPS_EVENT_ER_AP_REMOVE "WPS-ER-AP-REMOVE "
|
#define WPS_EVENT_ER_AP_REMOVE "WPS-ER-AP-REMOVE "
|
||||||
#define WPS_EVENT_ER_ENROLLEE_ADD "WPS-ER-ENROLLEE-ADD "
|
#define WPS_EVENT_ER_ENROLLEE_ADD "WPS-ER-ENROLLEE-ADD "
|
||||||
#define WPS_EVENT_ER_ENROLLEE_REMOVE "WPS-ER-ENROLLEE-REMOVE "
|
#define WPS_EVENT_ER_ENROLLEE_REMOVE "WPS-ER-ENROLLEE-REMOVE "
|
||||||
|
#define WPS_EVENT_ER_AP_SETTINGS "WPS-ER-AP-SETTINGS "
|
||||||
|
|
||||||
/* 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 "
|
||||||
|
|
|
@ -395,7 +395,12 @@ enum wps_event {
|
||||||
/**
|
/**
|
||||||
* WPS_EV_ER_ENROLLEE_REMOVE - ER: Enrollee removed
|
* WPS_EV_ER_ENROLLEE_REMOVE - ER: Enrollee removed
|
||||||
*/
|
*/
|
||||||
WPS_EV_ER_ENROLLEE_REMOVE
|
WPS_EV_ER_ENROLLEE_REMOVE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WPS_EV_ER_AP_SETTINGS - ER: AP Settings learned
|
||||||
|
*/
|
||||||
|
WPS_EV_ER_AP_SETTINGS
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -464,6 +469,11 @@ union wps_event_data {
|
||||||
const char *model_number;
|
const char *model_number;
|
||||||
const char *serial_number;
|
const char *serial_number;
|
||||||
} enrollee;
|
} enrollee;
|
||||||
|
|
||||||
|
struct wps_event_er_ap_settings {
|
||||||
|
const u8 *uuid;
|
||||||
|
const struct wps_credential *cred;
|
||||||
|
} ap_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1393,6 +1393,8 @@ int wps_er_pbc(struct wps_er *er, const u8 *uuid)
|
||||||
static void wps_er_ap_settings_cb(void *ctx, const struct wps_credential *cred)
|
static void wps_er_ap_settings_cb(void *ctx, const struct wps_credential *cred)
|
||||||
{
|
{
|
||||||
struct wps_er_ap *ap = ctx;
|
struct wps_er_ap *ap = ctx;
|
||||||
|
union wps_event_data data;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "WPS ER: AP Settings received");
|
wpa_printf(MSG_DEBUG, "WPS ER: AP Settings received");
|
||||||
os_free(ap->ap_settings);
|
os_free(ap->ap_settings);
|
||||||
ap->ap_settings = os_malloc(sizeof(*cred));
|
ap->ap_settings = os_malloc(sizeof(*cred));
|
||||||
|
@ -1401,7 +1403,11 @@ static void wps_er_ap_settings_cb(void *ctx, const struct wps_credential *cred)
|
||||||
ap->ap_settings->cred_attr = NULL;
|
ap->ap_settings->cred_attr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: send info through ctrl_iface */
|
os_memset(&data, 0, sizeof(data));
|
||||||
|
data.ap_settings.uuid = ap->uuid;
|
||||||
|
data.ap_settings.cred = cred;
|
||||||
|
ap->er->wps->event_cb(ap->er->wps->cb_ctx, WPS_EV_ER_AP_SETTINGS,
|
||||||
|
&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -468,6 +468,32 @@ static void wpa_supplicant_wps_event_er_enrollee_remove(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void wpa_supplicant_wps_event_er_ap_settings(
|
||||||
|
struct wpa_supplicant *wpa_s,
|
||||||
|
struct wps_event_er_ap_settings *ap_settings)
|
||||||
|
{
|
||||||
|
char uuid_str[100];
|
||||||
|
char key_str[65];
|
||||||
|
const struct wps_credential *cred = ap_settings->cred;
|
||||||
|
|
||||||
|
key_str[0] = '\0';
|
||||||
|
if (cred->auth_type & (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK)) {
|
||||||
|
if (cred->key_len >= 8 && cred->key_len <= 64) {
|
||||||
|
os_memcpy(key_str, cred->key, cred->key_len);
|
||||||
|
key_str[cred->key_len] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uuid_bin2str(ap_settings->uuid, uuid_str, sizeof(uuid_str));
|
||||||
|
/* Use wpa_msg_ctrl to avoid showing the key in debug log */
|
||||||
|
wpa_msg_ctrl(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_SETTINGS
|
||||||
|
"uuid=%s ssid=%s auth_type=0x%04x encr_type=0x%04x "
|
||||||
|
"key=%s",
|
||||||
|
uuid_str, wpa_ssid_txt(cred->ssid, cred->ssid_len),
|
||||||
|
cred->auth_type, cred->encr_type, key_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -502,6 +528,10 @@ static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
|
||||||
wpa_supplicant_wps_event_er_enrollee_remove(wpa_s,
|
wpa_supplicant_wps_event_er_enrollee_remove(wpa_s,
|
||||||
&data->enrollee);
|
&data->enrollee);
|
||||||
break;
|
break;
|
||||||
|
case WPS_EV_ER_AP_SETTINGS:
|
||||||
|
wpa_supplicant_wps_event_er_ap_settings(wpa_s,
|
||||||
|
&data->ap_settings);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue