]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - wpa_supplicant/ctrl_iface.c
The master branch is now used for v2.10 development
[thirdparty/hostap.git] / wpa_supplicant / ctrl_iface.c
index c1664d043673e7b502ebc4ef149ff2114ce3a10b..8efc08d4d906161cb41af106808581b402147471 100644 (file)
@@ -8,10 +8,10 @@
 
 #include "utils/includes.h"
 #ifdef CONFIG_TESTING_OPTIONS
-#include <net/ethernet.h>
 #include <netinet/ip.h>
 #endif /* CONFIG_TESTING_OPTIONS */
 
+#include <net/ethernet.h>
 #include "utils/common.h"
 #include "utils/eloop.h"
 #include "utils/uuid.h"
@@ -3129,6 +3129,49 @@ static int wpa_supplicant_ctrl_iface_mesh_peer_add(
        return wpas_mesh_peer_add(wpa_s, addr, duration);
 }
 
+
+static int wpa_supplicant_ctrl_iface_mesh_link_probe(
+       struct wpa_supplicant *wpa_s, char *cmd)
+{
+       struct ether_header *eth;
+       u8 addr[ETH_ALEN];
+       u8 *buf;
+       char *pos;
+       size_t payload_len = 0, len;
+       int ret = -1;
+
+       if (hwaddr_aton(cmd, addr))
+               return -1;
+
+       pos = os_strstr(cmd, " payload=");
+       if (pos) {
+               pos = pos + 9;
+               payload_len = os_strlen(pos);
+               if (payload_len & 1)
+                       return -1;
+
+               payload_len /= 2;
+       }
+
+       len = ETH_HLEN + payload_len;
+       buf = os_malloc(len);
+       if (!buf)
+               return -1;
+
+       eth = (struct ether_header *) buf;
+       os_memcpy(eth->ether_dhost, addr, ETH_ALEN);
+       os_memcpy(eth->ether_shost, wpa_s->own_addr, ETH_ALEN);
+       eth->ether_type = htons(ETH_P_802_3);
+
+       if (payload_len && hexstr2bin(pos, buf + ETH_HLEN, payload_len) < 0)
+               goto fail;
+
+       ret = wpa_drv_mesh_link_probe(wpa_s, addr, buf, len);
+fail:
+       os_free(buf);
+       return -ret;
+}
+
 #endif /* CONFIG_MESH */
 
 
@@ -5548,17 +5591,17 @@ static int parse_freq(int chwidth, int freq2)
        if (freq2 < 0)
                return -1;
        if (freq2)
-               return VHT_CHANWIDTH_80P80MHZ;
+               return CHANWIDTH_80P80MHZ;
 
        switch (chwidth) {
        case 0:
        case 20:
        case 40:
-               return VHT_CHANWIDTH_USE_HT;
+               return CHANWIDTH_USE_HT;
        case 80:
-               return VHT_CHANWIDTH_80MHZ;
+               return CHANWIDTH_80MHZ;
        case 160:
-               return VHT_CHANWIDTH_160MHZ;
+               return CHANWIDTH_160MHZ;
        default:
                wpa_printf(MSG_DEBUG, "Unknown max oper bandwidth: %d",
                           chwidth);
@@ -9583,59 +9626,10 @@ static int wpas_ctrl_iface_mac_rand_scan(struct wpa_supplicant *wpa_s,
                return -1;
        }
 
-       if (!enable) {
-               wpas_mac_addr_rand_scan_clear(wpa_s, type);
-               if (wpa_s->pno) {
-                       if (type & MAC_ADDR_RAND_PNO) {
-                               wpas_stop_pno(wpa_s);
-                               wpas_start_pno(wpa_s);
-                       }
-               } else if (wpa_s->sched_scanning &&
-                          (type & MAC_ADDR_RAND_SCHED_SCAN)) {
-                       wpas_scan_restart_sched_scan(wpa_s);
-               }
-               return 0;
-       }
-
-       if ((addr && !mask) || (!addr && mask)) {
-               wpa_printf(MSG_INFO,
-                          "CTRL: MAC_RAND_SCAN invalid addr/mask combination");
-               return -1;
-       }
-
-       if (addr && mask && (!(mask[0] & 0x01) || (addr[0] & 0x01))) {
-               wpa_printf(MSG_INFO,
-                          "CTRL: MAC_RAND_SCAN cannot allow multicast address");
-               return -1;
-       }
-
-       if (type & MAC_ADDR_RAND_SCAN) {
-               if (wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_SCAN,
-                                           addr, mask))
-                       return -1;
-       }
-
-       if (type & MAC_ADDR_RAND_SCHED_SCAN) {
-               if (wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_SCHED_SCAN,
-                                           addr, mask))
-                       return -1;
-
-               if (wpa_s->sched_scanning && !wpa_s->pno)
-                       wpas_scan_restart_sched_scan(wpa_s);
-       }
-
-       if (type & MAC_ADDR_RAND_PNO) {
-               if (wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_PNO,
-                                           addr, mask))
-                       return -1;
+       if (!enable)
+               return wpas_disable_mac_addr_randomization(wpa_s, type);
 
-               if (wpa_s->pno) {
-                       wpas_stop_pno(wpa_s);
-                       wpas_start_pno(wpa_s);
-               }
-       }
-
-       return 0;
+       return wpas_enable_mac_addr_randomization(wpa_s, type, addr, mask);
 }
 
 
@@ -10171,6 +10165,9 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
        } else if (os_strncmp(buf, "MESH_PEER_ADD ", 14) == 0) {
                if (wpa_supplicant_ctrl_iface_mesh_peer_add(wpa_s, buf + 14))
                        reply_len = -1;
+       } else if (os_strncmp(buf, "MESH_LINK_PROBE ", 16) == 0) {
+               if (wpa_supplicant_ctrl_iface_mesh_link_probe(wpa_s, buf + 16))
+                       reply_len = -1;
 #endif /* CONFIG_MESH */
 #ifdef CONFIG_P2P
        } else if (os_strncmp(buf, "P2P_FIND ", 9) == 0) {