From 6e6963ea866b748e84bc18f09baca348cf5d9489 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 28 Jun 2010 20:44:01 -0700 Subject: [PATCH] P2P: Add test mode for SD to force fragmented response --- wpa_supplicant/ctrl_iface.c | 6 ++++++ wpa_supplicant/p2p_supplicant.c | 10 ++++++++++ wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 17 insertions(+) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 3d604f34b..e330ed62e 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/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) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index b5a7ab83f..60e3bafc1 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/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); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index f272a60a0..534ce942e 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/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;