Browse Source

P2P: Add test mode for SD to force fragmented response

Jouni Malinen 14 years ago
parent
commit
6e6963ea86
3 changed files with 17 additions and 0 deletions
  1. 6 0
      wpa_supplicant/ctrl_iface.c
  2. 10 0
      wpa_supplicant/p2p_supplicant.c
  3. 1 0
      wpa_supplicant/wpa_supplicant_i.h

+ 6 - 0
wpa_supplicant/ctrl_iface.c

@@ -2457,6 +2457,11 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd)
 		return 0;
 	}
 
+	if (os_strcmp(cmd, "force_long_sd") == 0) {
+		wpa_s->force_long_sd = atoi(param);
+		return 0;
+	}
+
 	wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown P2P_SET field value '%s'",
 		   cmd);
 
@@ -2718,6 +2723,7 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
 			reply_len = -1;
 	} else if (os_strcmp(buf, "P2P_FLUSH") == 0) {
 		os_memset(wpa_s->p2p_auth_invite, 0, ETH_ALEN);
+		wpa_s->force_long_sd = 0;
 		p2p_flush(wpa_s->global->p2p);
 	} else if (os_strncmp(buf, "P2P_PRESENCE_REQ ", 17) == 0) {
 		if (p2p_ctrl_presence_req(wpa_s, buf + 17) < 0)

+ 10 - 0
wpa_supplicant/p2p_supplicant.c

@@ -1359,6 +1359,15 @@ void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
 		wpa_hexdump(MSG_MSGDUMP, "P2P: Query Data",
 			    pos, tlv_end - pos);
 
+
+		if (wpa_s->force_long_sd) {
+			wpa_printf(MSG_DEBUG, "P2P: SD test - force long "
+				   "response");
+			wpas_sd_all_bonjour(wpa_s, resp, srv_trans_id);
+			wpas_sd_all_upnp(wpa_s, resp, srv_trans_id);
+			goto done;
+		}
+
 		switch (srv_proto) {
 		case P2P_SERV_ALL_SERVICES:
 			wpa_printf(MSG_DEBUG, "P2P: Service Discovery Request "
@@ -1394,6 +1403,7 @@ void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
 		pos = tlv_end;
 	}
 
+done:
 	wpas_p2p_sd_response(wpa_s, freq, sa, dialog_token, resp);
 
 	wpabuf_free(resp);

+ 1 - 0
wpa_supplicant/wpa_supplicant_i.h

@@ -485,6 +485,7 @@ struct wpa_supplicant {
 	u8 pending_join_dev_addr[ETH_ALEN];
 	int pending_join_wps_method;
 	unsigned int roc_waiting_drv_freq;
+	int force_long_sd;
 #endif /* CONFIG_P2P */
 
 	struct wpa_ssid *bgscan_ssid;