From 2a098e3668fc5a3e2807e3b35f2583a6e3b94833 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 6 Aug 2015 20:43:25 +0300 Subject: [PATCH] P2PS: Clean up intended interface address passing to p2ps_prov_complete Use NULL to indicate if the address is not available instead of fixed 00:00:00:00:00:00. wpas_p2ps_prov_complete() already had code for converting NULL to that all zeros address for event messages. Signed-off-by: Jouni Malinen --- src/p2p/p2p_pd.c | 14 ++++---------- wpa_supplicant/p2p_supplicant.c | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c index b3881c47f..890094551 100644 --- a/src/p2p/p2p_pd.c +++ b/src/p2p/p2p_pd.c @@ -442,7 +442,7 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa, u32 session_id = 0; u8 session_mac[ETH_ALEN]; u8 adv_mac[ETH_ALEN]; - u8 group_mac[ETH_ALEN]; + const u8 *group_mac; int passwd_id = DEV_PW_DEFAULT; u16 config_methods; u16 allowed_config_methods = WPS_CONFIG_DISPLAY | WPS_CONFIG_KEYPAD; @@ -455,6 +455,7 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa, p2p_dbg(p2p, "Received Provision Discovery Request from " MACSTR " with config methods 0x%x (freq=%d)", MAC2STR(sa), msg.wps_config_methods, rx_freq); + group_mac = msg.intended_addr; dev = p2p_get_device(p2p, sa); if (dev == NULL || (dev->flags & P2P_DEV_PROBE_REQ_ONLY)) { @@ -534,7 +535,6 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa, os_memset(session_mac, 0, ETH_ALEN); os_memset(adv_mac, 0, ETH_ALEN); - os_memset(group_mac, 0, ETH_ALEN); /* Note 1: A feature capability attribute structure can be changed * in the future. The assumption is that such modifications are @@ -553,9 +553,6 @@ void p2p_process_prov_disc_req(struct p2p_data *p2p, const u8 *sa, req_fcap = (struct p2ps_feature_capab *) msg.feature_cap; - if (msg.intended_addr) - os_memcpy(group_mac, msg.intended_addr, ETH_ALEN); - os_memcpy(session_mac, msg.session_mac, ETH_ALEN); os_memcpy(adv_mac, msg.adv_mac, ETH_ALEN); @@ -1037,7 +1034,7 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa, u32 adv_id = 0; u8 conncap = P2PS_SETUP_NEW; u8 adv_mac[ETH_ALEN]; - u8 group_mac[ETH_ALEN]; + const u8 *group_mac; int passwd_id = DEV_PW_DEFAULT; int p2ps_seeker; @@ -1053,10 +1050,7 @@ void p2p_process_prov_disc_resp(struct p2p_data *p2p, const u8 *sa, if (msg.status) status = *msg.status; - if (msg.intended_addr) - os_memcpy(group_mac, msg.intended_addr, ETH_ALEN); - else - os_memset(group_mac, 0, ETH_ALEN); + group_mac = msg.intended_addr; if (msg.adv_mac) os_memcpy(adv_mac, msg.adv_mac, ETH_ALEN); diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index e849b91bf..8a6a89dee 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3811,7 +3811,7 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, persist_ssid_size); if (persist_ssid && s && s->mode != WPAS_MODE_P2P_GO && - os_memcmp(grp_mac, mac, ETH_ALEN) == 0) { + is_zero_ether_addr(grp_mac)) { wpa_dbg(wpa_s, MSG_ERROR, "P2P: Peer device is a GO in a persistent group, but it did not provide the intended MAC address"); return; @@ -3903,7 +3903,7 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, wpas_p2ps_prov_complete( wpa_s, P2P_SC_FAIL_UNKNOWN_GROUP, dev, adv_mac, ses_mac, - NULL, adv_id, ses_id, 0, 0, + grp_mac, adv_id, ses_id, 0, 0, NULL, 0, 0, 0, NULL, NULL, 0); return; }