From 2ec535fd376cf0f08c55d709024e3e1d045a266f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 18 Dec 2012 16:57:52 +0200 Subject: [PATCH] WNM: Add option to disable keep-alive frames for testing purposes "wpa_cli set no_keep_alive 1/0" can now be used to disable/enable keep alive frames to enable testing. Signed-hostap: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 2 ++ wpa_supplicant/events.c | 16 ++++++++++------ wpa_supplicant/wpa_supplicant_i.h | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index c5e5fd295..880fe010c 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -415,6 +415,8 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s, ret = set_bssid_filter(wpa_s, value); } else if (os_strcasecmp(cmd, "disallow_aps") == 0) { ret = set_disallow_aps(wpa_s, value); + } else if (os_strcasecmp(cmd, "no_keep_alive") == 0) { + wpa_s->no_keep_alive = !!atoi(value); } else { value[-1] = '='; ret = wpa_config_process_global(wpa_s->conf, cmd, -1); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index d9ed7a243..68b407b9a 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1316,12 +1316,16 @@ static void wnm_bss_keep_alive(void *eloop_ctx, void *sock_ctx) if (wpa_s->wpa_state < WPA_ASSOCIATED) return; - wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR, - MAC2STR(wpa_s->bssid)); - /* TODO: could skip this if normal data traffic has been sent */ - /* TODO: Consider using some more appropriate data frame for this */ - if (wpa_s->l2) - l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800, (u8 *) "", 0); + if (!wpa_s->no_keep_alive) { + wpa_printf(MSG_DEBUG, "WNM: Send keep-alive to AP " MACSTR, + MAC2STR(wpa_s->bssid)); + /* TODO: could skip this if normal data traffic has been sent */ + /* TODO: Consider using some more appropriate data frame for + * this */ + if (wpa_s->l2) + l2_packet_send(wpa_s->l2, wpa_s->bssid, 0x0800, + (u8 *) "", 0); + } #ifdef CONFIG_SME if (wpa_s->sme.bss_max_idle_period) { diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index a92d0c1f4..3a56064b0 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -668,6 +668,8 @@ struct wpa_supplicant { struct wpabuf *last_gas_resp; u8 last_gas_addr[ETH_ALEN]; u8 last_gas_dialog_token; + + unsigned int no_keep_alive:1; };