Browse Source

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 <jouni@qca.qualcomm.com>
Jouni Malinen 9 years ago
parent
commit
2a098e3668
2 changed files with 6 additions and 12 deletions
  1. 4 10
      src/p2p/p2p_pd.c
  2. 2 2
      wpa_supplicant/p2p_supplicant.c

+ 4 - 10
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);

+ 2 - 2
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;
 			}