]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
FILS: Move HLP request handling into a separate file
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 31 Jan 2017 12:00:12 +0000 (14:00 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 31 Jan 2017 15:46:13 +0000 (17:46 +0200)
This is independent functionality from the core IEEE 802.11 management
handling and will increase significantly in size, so it is cleaner to
maintain this in a separate source code file.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/Android.mk
hostapd/Makefile
src/ap/fils_hlp.c [new file with mode: 0644]
src/ap/fils_hlp.h [new file with mode: 0644]
src/ap/ieee802_11.c
wpa_supplicant/Android.mk
wpa_supplicant/Makefile

index ec2d55a9fae2d02f96828211637489456a3ea459..8664cfa767f93878c4510d485d2774b7cbab3589 100644 (file)
@@ -263,6 +263,7 @@ endif
 
 ifdef CONFIG_FILS
 L_CFLAGS += -DCONFIG_FILS
+OBJS += src/ap/fils_hlp.c
 NEED_CRC32=y
 NEED_SHA384=y
 NEED_AES_SIV=y
index d9bb72a0a8c45db4c6d879a2d07ab9a5f1cc227f..dfa7b969bc94ad41beb5dec0b279270e0fcb2261 100644 (file)
@@ -307,6 +307,7 @@ endif
 
 ifdef CONFIG_FILS
 CFLAGS += -DCONFIG_FILS
+OBJS += ../src/ap/fils_hlp.o
 NEED_CRC32=y
 NEED_SHA384=y
 NEED_AES_SIV=y
diff --git a/src/ap/fils_hlp.c b/src/ap/fils_hlp.c
new file mode 100644 (file)
index 0000000..3fde71e
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * FILS HLP request processing
+ * Copyright (c) 2017, Qualcomm Atheros, Inc.
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "utils/includes.h"
+
+#include "utils/common.h"
+#include "sta_info.h"
+#include "fils_hlp.h"
+
+
+static void fils_process_hlp_req(struct hostapd_data *hapd,
+                                struct sta_info *sta,
+                                const u8 *pos, size_t len)
+{
+       const u8 *pkt, *end;
+
+       wpa_printf(MSG_DEBUG, "FILS: HLP request from " MACSTR " (dst=" MACSTR
+                  " src=" MACSTR " len=%u)",
+                  MAC2STR(sta->addr), MAC2STR(pos), MAC2STR(pos + ETH_ALEN),
+                  (unsigned int) len);
+       if (os_memcmp(sta->addr, pos + ETH_ALEN, ETH_ALEN) != 0) {
+               wpa_printf(MSG_DEBUG,
+                          "FILS: Ignore HLP request with unexpected source address"
+                          MACSTR, MAC2STR(pos + ETH_ALEN));
+               return;
+       }
+
+       end = pos + len;
+       pkt = pos + 2 * ETH_ALEN;
+       if (end - pkt >= 6 &&
+           os_memcmp(pkt, "\xaa\xaa\x03\x00\x00\x00", 6) == 0)
+               pkt += 6; /* Remove SNAP/LLC header */
+       wpa_hexdump(MSG_MSGDUMP, "FILS: HLP request packet", pkt, end - pkt);
+}
+
+
+void fils_process_hlp(struct hostapd_data *hapd, struct sta_info *sta,
+                     const u8 *pos, int left)
+{
+       const u8 *end = pos + left;
+       u8 *tmp, *tmp_pos;
+
+       /* Check if there are any FILS HLP Container elements */
+       while (end - pos >= 2) {
+               if (2 + pos[1] > end - pos)
+                       return;
+               if (pos[0] == WLAN_EID_EXTENSION &&
+                   pos[1] >= 1 + 2 * ETH_ALEN &&
+                   pos[2] == WLAN_EID_EXT_FILS_HLP_CONTAINER)
+                       break;
+               pos += 2 + pos[1];
+       }
+       if (end - pos < 2)
+               return; /* No FILS HLP Container elements */
+
+       tmp = os_malloc(end - pos);
+       if (!tmp)
+               return;
+
+       while (end - pos >= 2) {
+               if (2 + pos[1] > end - pos ||
+                   pos[0] != WLAN_EID_EXTENSION ||
+                   pos[1] < 1 + 2 * ETH_ALEN ||
+                   pos[2] != WLAN_EID_EXT_FILS_HLP_CONTAINER)
+                       break;
+               tmp_pos = tmp;
+               os_memcpy(tmp_pos, pos + 3, pos[1] - 1);
+               tmp_pos += pos[1] - 1;
+               pos += 2 + pos[1];
+
+               /* Add possible fragments */
+               while (end - pos >= 2 && pos[0] == WLAN_EID_FRAGMENT &&
+                      2 + pos[1] <= end - pos) {
+                       os_memcpy(tmp_pos, pos + 2, pos[1]);
+                       tmp_pos += pos[1];
+                       pos += 2 + pos[1];
+               }
+
+               fils_process_hlp_req(hapd, sta, tmp, tmp_pos - tmp);
+       }
+
+       os_free(tmp);
+}
diff --git a/src/ap/fils_hlp.h b/src/ap/fils_hlp.h
new file mode 100644 (file)
index 0000000..98cc319
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * FILS HLP request processing
+ * Copyright (c) 2017, Qualcomm Atheros, Inc.
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#ifndef FILS_HLP_H
+#define FILS_HLP_H
+
+void fils_process_hlp(struct hostapd_data *hapd, struct sta_info *sta,
+                     const u8 *pos, int left);
+
+#endif /* FILS_HLP_H */
index 64d1800797a3592a9b60d6913ac5e67a06df95ec..129cc158d73abe949fcbae93f039fc5178472694 100644 (file)
@@ -45,6 +45,7 @@
 #include "mbo_ap.h"
 #include "rrm.h"
 #include "taxonomy.h"
+#include "fils_hlp.h"
 
 
 u8 * hostapd_eid_supp_rates(struct hostapd_data *hapd, u8 *eid)
@@ -2447,85 +2448,6 @@ static u16 send_assoc_resp(struct hostapd_data *hapd, struct sta_info *sta,
 }
 
 
-#ifdef CONFIG_FILS
-
-static void fils_process_hlp_req(struct hostapd_data *hapd,
-                                struct sta_info *sta,
-                                const u8 *pos, size_t len)
-{
-       const u8 *pkt, *end;
-
-       wpa_printf(MSG_DEBUG, "FILS: HLP request from " MACSTR " (dst=" MACSTR
-                  " src=" MACSTR " len=%u)",
-                  MAC2STR(sta->addr), MAC2STR(pos), MAC2STR(pos + ETH_ALEN),
-                  (unsigned int) len);
-       if (os_memcmp(sta->addr, pos + ETH_ALEN, ETH_ALEN) != 0) {
-               wpa_printf(MSG_DEBUG,
-                          "FILS: Ignore HLP request with unexpected source address"
-                          MACSTR, MAC2STR(pos + ETH_ALEN));
-               return;
-       }
-
-       end = pos + len;
-       pkt = pos + 2 * ETH_ALEN;
-       if (end - pkt >= 6 &&
-           os_memcmp(pkt, "\xaa\xaa\x03\x00\x00\x00", 6) == 0)
-               pkt += 6; /* Remove SNAP/LLC header */
-       wpa_hexdump(MSG_MSGDUMP, "FILS: HLP request packet", pkt, end - pkt);
-}
-
-
-static void fils_process_hlp(struct hostapd_data *hapd, struct sta_info *sta,
-                            const u8 *pos, int left)
-{
-       const u8 *end = pos + left;
-       u8 *tmp, *tmp_pos;
-
-       /* Check if there are any FILS HLP Container elements */
-       while (end - pos >= 2) {
-               if (2 + pos[1] > end - pos)
-                       return;
-               if (pos[0] == WLAN_EID_EXTENSION &&
-                   pos[1] >= 1 + 2 * ETH_ALEN &&
-                   pos[2] == WLAN_EID_EXT_FILS_HLP_CONTAINER)
-                       break;
-               pos += 2 + pos[1];
-       }
-       if (end - pos < 2)
-               return; /* No FILS HLP Container elements */
-
-       tmp = os_malloc(end - pos);
-       if (!tmp)
-               return;
-
-       while (end - pos >= 2) {
-               if (2 + pos[1] > end - pos ||
-                   pos[0] != WLAN_EID_EXTENSION ||
-                   pos[1] < 1 + 2 * ETH_ALEN ||
-                   pos[2] != WLAN_EID_EXT_FILS_HLP_CONTAINER)
-                       break;
-               tmp_pos = tmp;
-               os_memcpy(tmp_pos, pos + 3, pos[1] - 1);
-               tmp_pos += pos[1] - 1;
-               pos += 2 + pos[1];
-
-               /* Add possible fragments */
-               while (end - pos >= 2 && pos[0] == WLAN_EID_FRAGMENT &&
-                      2 + pos[1] <= end - pos) {
-                       os_memcpy(tmp_pos, pos + 2, pos[1]);
-                       tmp_pos += pos[1];
-                       pos += 2 + pos[1];
-               }
-
-               fils_process_hlp_req(hapd, sta, tmp, tmp_pos - tmp);
-       }
-
-       os_free(tmp);
-}
-
-#endif /* CONFIG_FILS */
-
-
 static void handle_assoc(struct hostapd_data *hapd,
                         const struct ieee80211_mgmt *mgmt, size_t len,
                         int reassoc)
index 3c877f0903b5e77c0836186f255bd4810594eee1..0f56f1d6a0468f36b6a9d480acfb01743e2378e6 100644 (file)
@@ -835,6 +835,9 @@ endif
 ifdef CONFIG_MBO
 OBJS += src/ap/mbo_ap.c
 endif
+ifdef CONFIG_FILS
+OBJS += src/ap/fils_hlp.c
+endif
 ifdef CONFIG_CTRL_IFACE
 OBJS += src/ap/ctrl_iface_ap.c
 endif
index dae691105e69a532822fd869d547901a6c3dd096..460441c15931b2da3640c32c616b4e8f685689a7 100644 (file)
@@ -876,6 +876,9 @@ endif
 ifdef CONFIG_MBO
 OBJS += ../src/ap/mbo_ap.o
 endif
+ifdef CONFIG_FILS
+OBJS += ../src/ap/fils_hlp.o
+endif
 ifdef CONFIG_CTRL_IFACE
 OBJS += ../src/ap/ctrl_iface_ap.o
 endif