From c3f42784454e413dcec09c8fd8c77cbe68186ed7 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 6 Dec 2011 21:57:17 +0200 Subject: [PATCH] P2P: Add group ifname to P2P-PROV-DISC-* events If Provision Discovery Request is sent for GO role (i.e., P2P Group ID attribute is included), add the group interface name to the control interface event on the GO. This makes it easier to figure out which ctrl_iface needs to be used for wps_pbc/wps_pin command to authorize the joining P2P client. Signed-hostap: Jouni Malinen --- src/drivers/driver_test.c | 3 ++- src/p2p/p2p.h | 5 ++++- src/p2p/p2p_pd.c | 4 ++-- wpa_supplicant/events.c | 3 ++- wpa_supplicant/p2p_supplicant.c | 25 +++++++++++++++++++++---- wpa_supplicant/p2p_supplicant.h | 3 ++- 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/drivers/driver_test.c b/src/drivers/driver_test.c index 3faa85d87..f8e314b17 100644 --- a/src/drivers/driver_test.c +++ b/src/drivers/driver_test.c @@ -3196,7 +3196,8 @@ static void test_sd_response(void *ctx, const u8 *sa, u16 update_indic, static void test_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods, const u8 *dev_addr, const u8 *pri_dev_type, const char *dev_name, u16 supp_config_methods, - u8 dev_capab, u8 group_capab) + u8 dev_capab, u8 group_capab, + const u8 *group_id, size_t group_id_len) { wpa_printf(MSG_DEBUG, "%s(peer=" MACSTR " config_methods=0x%x)", __func__, MAC2STR(peer), config_methods); diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 4735acee6..1159121ca 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -594,6 +594,8 @@ struct p2p_config { * @supp_config_methods: Supported configuration Methods * @dev_capab: Device Capabilities * @group_capab: Group Capabilities + * @group_id: P2P Group ID (or %NULL if not included) + * @group_id_len: Length of P2P Group ID * * This callback is used to indicate reception of a Provision Discovery * Request frame that the P2P module accepted. @@ -601,7 +603,8 @@ struct p2p_config { void (*prov_disc_req)(void *ctx, const u8 *peer, u16 config_methods, const u8 *dev_addr, const u8 *pri_dev_type, const char *dev_name, u16 supp_config_methods, - u8 dev_capab, u8 group_capab); + u8 dev_capab, u8 group_capab, + const u8 *group_id, size_t group_id_len); /** * prov_disc_resp - Callback on Provisiong Discovery Response diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c index ac086b9bd..903c9ee56 100644 --- a/src/p2p/p2p_pd.c +++ b/src/p2p/p2p_pd.c @@ -191,8 +191,8 @@ out: msg.device_name, msg.config_methods, msg.capability ? msg.capability[0] : 0, msg.capability ? msg.capability[1] : - 0); - + 0, + msg.group_id, msg.group_id_len); } p2p_parse_free(&msg); } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 9823501ba..c38991715 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -2375,7 +2375,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->p2p_prov_disc_req.dev_name, data->p2p_prov_disc_req.supp_config_methods, data->p2p_prov_disc_req.dev_capab, - data->p2p_prov_disc_req.group_capab); + data->p2p_prov_disc_req.group_capab, + NULL, 0); break; case EVENT_P2P_PROV_DISC_RESPONSE: wpas_prov_disc_resp(wpa_s, data->p2p_prov_disc_resp.peer, diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index e76656b4b..4ce04321a 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -1688,13 +1688,28 @@ static void wpas_prov_disc_local_keypad(struct wpa_supplicant *wpa_s, void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods, const u8 *dev_addr, const u8 *pri_dev_type, const char *dev_name, u16 supp_config_methods, - u8 dev_capab, u8 group_capab) + u8 dev_capab, u8 group_capab, const u8 *group_id, + size_t group_id_len) { struct wpa_supplicant *wpa_s = ctx; char devtype[WPS_DEV_TYPE_BUFSIZE]; - char params[200]; + char params[300]; u8 empty_dev_type[8]; unsigned int generated_pin = 0; + struct wpa_supplicant *group = NULL; + + if (group_id) { + for (group = wpa_s->global->ifaces; group; group = group->next) + { + struct wpa_ssid *s = group->current_ssid; + if (s != NULL && + s->mode == WPAS_MODE_P2P_GO && + group_id_len - ETH_ALEN == s->ssid_len && + os_memcmp(group_id + ETH_ALEN, s->ssid, + s->ssid_len) == 0) + break; + } + } if (pri_dev_type == NULL) { os_memset(empty_dev_type, 0, sizeof(empty_dev_type)); @@ -1702,11 +1717,13 @@ void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods, } os_snprintf(params, sizeof(params), " p2p_dev_addr=" MACSTR " pri_dev_type=%s name='%s' config_methods=0x%x " - "dev_capab=0x%x group_capab=0x%x", + "dev_capab=0x%x group_capab=0x%x%s%s", MAC2STR(dev_addr), wps_dev_type_bin2str(pri_dev_type, devtype, sizeof(devtype)), - dev_name, supp_config_methods, dev_capab, group_capab); + dev_name, supp_config_methods, dev_capab, group_capab, + group ? " group=" : "", + group ? group->ifname : ""); params[sizeof(params) - 1] = '\0'; if (config_methods & WPS_CONFIG_DISPLAY) { diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 33b22db17..6afc4bb06 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -73,7 +73,8 @@ void wpas_go_neg_req_rx(void *ctx, const u8 *src, u16 dev_passwd_id); void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods, const u8 *dev_addr, const u8 *pri_dev_type, const char *dev_name, u16 supp_config_methods, - u8 dev_capab, u8 group_capab); + u8 dev_capab, u8 group_capab, const u8 *group_id, + size_t group_id_len); void wpas_prov_disc_resp(void *ctx, const u8 *peer, u16 config_methods); void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token, u16 update_indic, const u8 *tlvs, size_t tlvs_len);