]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Move MAC address randomization enable/disable to helper functions
authorEric Caruso <ejcaruso@chromium.org>
Thu, 30 May 2019 18:10:46 +0000 (11:10 -0700)
committerJouni Malinen <j@w1.fi>
Wed, 26 Jun 2019 17:56:01 +0000 (20:56 +0300)
This makes it easier to share this for D-Bus implementation.

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 10f1908f8d3409354cf927e211013fb821da78bb..8efc08d4d906161cb41af106808581b402147471 100644 (file)
@@ -9626,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 (!enable)
+               return wpas_disable_mac_addr_randomization(wpa_s, type);
 
-       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 (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);
 }
 
 
index be45f2e38fdb1202edfff81669e72e2ec1a728d8..78eef388dfa37d78e166929daed15e3c08a1978c 100644 (file)
@@ -7486,3 +7486,66 @@ int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s,
 
        return 1;
 }
+
+
+int wpas_enable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
+                                      unsigned int type, const u8 *addr,
+                                      const u8 *mask)
+{
+       if ((addr && !mask) || (!addr && mask)) {
+               wpa_printf(MSG_INFO,
+                          "MAC_ADDR_RAND_SCAN invalid addr/mask combination");
+               return -1;
+       }
+
+       if (addr && mask && (!(mask[0] & 0x01) || (addr[0] & 0x01))) {
+               wpa_printf(MSG_INFO,
+                          "MAC_ADDR_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 (wpa_s->pno) {
+                       wpas_stop_pno(wpa_s);
+                       wpas_start_pno(wpa_s);
+               }
+       }
+
+       return 0;
+}
+
+
+int wpas_disable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
+                                       unsigned int type)
+{
+       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;
+}
index 204cf60f311611f16615b8e29cb5b0dc2857a162..8a4bdf8cbc334e60df0271ff2c5b5efbe9e654b3 100644 (file)
@@ -1418,6 +1418,12 @@ size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,
                             struct wpa_ssid *ssid,
                             int freq, u8 *pos, size_t len);
 
+int wpas_enable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
+                                      unsigned int type, const u8 *addr,
+                                      const u8 *mask);
+int wpas_disable_mac_addr_randomization(struct wpa_supplicant *wpa_s,
+                                       unsigned int type);
+
 /**
  * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response
  * @wpa_s: Pointer to wpa_supplicant data