]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
TDLS: Allow TDLS to be disabled at runtime for testing purposes
authorJouni Malinen <jouni.malinen@atheros.com>
Thu, 24 Mar 2011 18:44:17 +0000 (20:44 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Mar 2011 18:44:17 +0000 (20:44 +0200)
Control interface command 'SET tdls_disabled <1/0>' can now be used
to disable/enable TDLS at runtime. This is mainly for testing
purposes.

src/drivers/driver.h
src/rsn_supp/tdls.c
src/rsn_supp/wpa.h
src/rsn_supp/wpa_i.h
wpa_supplicant/ctrl_iface.c

index a3012012396ea5e7ed7dc6d2a986f10385c1d1bf..40f1d0e3f6ed334e9e4fd8ff12cefaf8b7adc9e5 100644 (file)
@@ -699,7 +699,9 @@ enum tdls_oper {
        TDLS_SETUP,
        TDLS_TEARDOWN,
        TDLS_ENABLE_LINK,
-       TDLS_DISABLE_LINK
+       TDLS_DISABLE_LINK,
+       TDLS_ENABLE,
+       TDLS_DISABLE
 };
 
 /**
index 4ee363951fccebf6ced7b1e7db39e921900f62ec..14c2b7b8000216eb30896cd56d12faa13458ed71 100644 (file)
@@ -625,6 +625,9 @@ int wpa_tdls_recv_teardown_notify(struct wpa_sm *sm, const u8 *addr,
        u8 *rbuf, *pos;
        int ielen;
 
+       if (sm->tdls_disabled)
+               return -1;
+
        /* Find the node and free from the list */
        for (peer = sm->tdls; peer; peer = peer->next) {
                if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
@@ -1825,6 +1828,9 @@ int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr)
        struct wpa_tdls_peer *peer;
        int tdls_prohibited = sm->tdls_prohibited;
 
+       if (sm->tdls_disabled)
+               return -1;
+
 #ifdef CONFIG_TDLS_TESTING
        if ((tdls_testing & TDLS_TESTING_IGNORE_AP_PROHIBIT) &&
            tdls_prohibited) {
@@ -1869,6 +1875,9 @@ int wpa_tdls_reneg(struct wpa_sm *sm, const u8 *addr)
 {
        struct wpa_tdls_peer *peer;
 
+       if (sm->tdls_disabled)
+               return -1;
+
        for (peer = sm->tdls; peer; peer = peer->next) {
                if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0)
                        break;
@@ -1895,6 +1904,11 @@ static void wpa_supplicant_rx_tdls(void *ctx, const u8 *src_addr,
        wpa_hexdump(MSG_DEBUG, "TDLS: Received Data frame encapsulation",
                    buf, len);
 
+       if (sm->tdls_disabled) {
+               wpa_printf(MSG_DEBUG, "TDLS: Discard message - TDLS disabled");
+               return;
+       }
+
        if (os_memcmp(src_addr, sm->own_addr, ETH_ALEN) == 0) {
                wpa_printf(MSG_DEBUG, "TDLS: Discard copy of own message");
                return;
@@ -2051,3 +2065,10 @@ void wpa_tdls_assoc_resp_ies(struct wpa_sm *sm, const u8 *ies, size_t len)
                sm->tdls_prohibited = 1;
        }
 }
+
+
+void wpa_tdls_enable(struct wpa_sm *sm, int enabled)
+{
+       wpa_printf(MSG_DEBUG, "TDLS: %s", enabled ? "enabled" : "disabled");
+       sm->tdls_disabled = !enabled;
+}
index 41bafee6317804abf3c3b799976852b4359280c4..111597ca4a760836b51566cf999f2e4bc6a83b70 100644 (file)
@@ -346,5 +346,6 @@ int wpa_tdls_recv_teardown_notify(struct wpa_sm *sm, const u8 *addr,
                                  u16 reason_code);
 int wpa_tdls_init(struct wpa_sm *sm);
 void wpa_tdls_deinit(struct wpa_sm *sm);
+void wpa_tdls_enable(struct wpa_sm *sm, int enabled);
 
 #endif /* WPA_H */
index 590dea149125601b43ddd1ed1148b4f4e8a6fd28..09a2e4ff5a508707127ae544b7cbbb3c3e960b24 100644 (file)
@@ -97,6 +97,7 @@ struct wpa_sm {
 #ifdef CONFIG_TDLS
        struct wpa_tdls_peer *tdls;
        int tdls_prohibited;
+       int tdls_disabled;
 #endif /* CONFIG_TDLS */
 
 #ifdef CONFIG_IEEE80211R
index cb813ba79715b98613636a42aade9e5e48657887..5488ea4479b28beca1ac9e2afff78a0ccd91dd6f 100644 (file)
@@ -114,6 +114,17 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                tdls_testing = strtol(value, NULL, 0);
                wpa_printf(MSG_DEBUG, "TDLS: tdls_testing=0x%x", tdls_testing);
 #endif /* CONFIG_TDLS_TESTING */
+#ifdef CONFIG_TDLS
+       } else if (os_strcasecmp(cmd, "tdls_disabled") == 0) {
+               int disabled = atoi(value);
+               wpa_printf(MSG_DEBUG, "TDLS: tdls_disabled=%d", disabled);
+               if (disabled) {
+                       if (wpa_drv_tdls_oper(wpa_s, TDLS_DISABLE, NULL) < 0)
+                               ret = -1;
+               } else if (wpa_drv_tdls_oper(wpa_s, TDLS_ENABLE, NULL) < 0)
+                       ret = -1;
+               wpa_tdls_enable(wpa_s->wpa, !disabled);
+#endif /* CONFIG_TDLS */
        } else {
                value[-1] = '=';
                ret = wpa_config_process_global(wpa_s->conf, cmd, -1);