From 800d58721c8a5721d1ddb1271093350ab769ade0 Mon Sep 17 00:00:00 2001 From: Sunil Dutt Date: Wed, 13 Nov 2013 17:05:44 +0530 Subject: [PATCH] TDLS: Provide external control to specify the peers for setup There are use cases requesting the host driver to initiate the TDLS setup with the peer only when configured by the external applications. Thus, enable this control by tdls_external_control=1 and pass the requisite information for the specific TDLS operation to the driver on the request from such use cases. This operation mode expects the driver to initiate TDLS link automatically based on signal strength and traffic to a peer and tear down links whenever they are not used or suitable due to signal strength etc. The list of peers with which such operations are to be performed are provided with the TDLS driver operations. Signed-hostap: Jouni Malinen --- wpa_supplicant/config.c | 1 + wpa_supplicant/config.h | 10 ++++++++++ wpa_supplicant/config_file.c | 4 ++++ wpa_supplicant/ctrl_iface.c | 8 ++++++++ 4 files changed, 23 insertions(+) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 180827367..9ceaaf85c 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -3358,6 +3358,7 @@ static const struct global_parse_data global_fields[] = { { FUNC(freq_list), 0 }, { INT(scan_cur_freq), 0 }, { INT(sched_scan_interval), 0 }, + { INT(tdls_external_control), 0}, }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index 55a2d62ed..068679e56 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -933,6 +933,16 @@ struct wpa_config { * sched_scan_interval - schedule scan interval */ unsigned int sched_scan_interval; + + /** + * tdls_external_control - External control for TDLS setup requests + * + * Enable TDLS mode where external programs are given the control + * to specify the TDLS link to get established to the driver. The + * driver requests the TDLS setup to the supplicant only for the + * specified TDLS peers. + */ + int tdls_external_control; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index ed5cdfffc..7d328673c 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -1079,6 +1079,10 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) if (config->external_sim) fprintf(f, "external_sim=%d\n", config->external_sim); + + if (config->tdls_external_control) + fprintf(f, "tdls_external_control=%d\n", + config->tdls_external_control); } #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index ebe08b37a..615a972bf 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -571,6 +571,10 @@ static int wpa_supplicant_ctrl_iface_tdls_setup( wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_SETUP " MACSTR, MAC2STR(peer)); + if ((wpa_s->conf->tdls_external_control) && + wpa_tdls_is_external_setup(wpa_s->wpa)) + return wpa_drv_tdls_oper(wpa_s, TDLS_SETUP, peer); + wpa_tdls_remove(wpa_s->wpa, peer); if (wpa_tdls_is_external_setup(wpa_s->wpa)) @@ -597,6 +601,10 @@ static int wpa_supplicant_ctrl_iface_tdls_teardown( wpa_printf(MSG_DEBUG, "CTRL_IFACE TDLS_TEARDOWN " MACSTR, MAC2STR(peer)); + if ((wpa_s->conf->tdls_external_control) && + wpa_tdls_is_external_setup(wpa_s->wpa)) + return wpa_drv_tdls_oper(wpa_s, TDLS_TEARDOWN, peer); + if (wpa_tdls_is_external_setup(wpa_s->wpa)) ret = wpa_tdls_teardown_link( wpa_s->wpa, peer,