FST: Remove the IE header len/size macros
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 17 Jul 2015 15:36:03 +0000 (18:36 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 17 Jul 2015 16:06:48 +0000 (19:06 +0300)
These are confusing when the style used with the couple of FST IE checks
differs from the rest of hostapd/wpa_supplicant implementation.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/common/ieee802_11_common.c
src/fst/fst_group.c
src/fst/fst_internal.h

index 884ae8d..d55e296 100644 (file)
@@ -960,17 +960,14 @@ const char * fc2str(u16 fc)
 }
 
 
-#define IE_HEADER_SIZE               ((u8) (2 * sizeof(u8)))
-#define IE_BUFFER_LENGTH(ie_len_val) ((ie_len_val) + IE_HEADER_SIZE)
-
 int mb_ies_info_by_ies(struct mb_ies_info *info, const u8 *ies_buf,
                       size_t ies_len)
 {
        os_memset(info, 0, sizeof(*info));
 
-       while (ies_buf && ies_len >= IE_HEADER_SIZE &&
+       while (ies_buf && ies_len >= 2 &&
               info->nof_ies < MAX_NOF_MB_IES_SUPPORTED) {
-               size_t len = IE_BUFFER_LENGTH(ies_buf[1]);
+               size_t len = 2 + ies_buf[1];
 
                if (len > ies_len) {
                        wpa_hexdump(MSG_DEBUG, "Truncated IEs",
@@ -980,7 +977,7 @@ int mb_ies_info_by_ies(struct mb_ies_info *info, const u8 *ies_buf,
 
                if (ies_buf[0] == WLAN_EID_MULTI_BAND) {
                        wpa_printf(MSG_DEBUG, "MB IE of %zu bytes found", len);
-                       info->ies[info->nof_ies].ie = ies_buf + IE_HEADER_SIZE;
+                       info->ies[info->nof_ies].ie = ies_buf + 2;
                        info->ies[info->nof_ies].ie_len = ies_buf[1];
                        info->nof_ies++;
                }
@@ -1004,7 +1001,7 @@ struct wpabuf * mb_ies_by_info(struct mb_ies_info *info)
                size_t mb_ies_size = 0;
 
                for (i = 0; i < info->nof_ies; i++)
-                       mb_ies_size += IE_BUFFER_LENGTH(info->ies[i].ie_len);
+                       mb_ies_size += 2 + info->ies[i].ie_len;
 
                mb_ies = wpabuf_alloc(mb_ies_size);
                if (mb_ies) {
index e362aa2..9718e4e 100644 (file)
@@ -41,11 +41,11 @@ static void fst_dump_mb_ies(const char *group_id, const char *ifname,
        const u8 *p = wpabuf_head(mbies);
        size_t s = wpabuf_len(mbies);
 
-       while (s >= offsetof(struct multi_band_ie, mb_ctrl)) {
+       while (s >= 2) {
                const struct multi_band_ie *mbie =
                        (const struct multi_band_ie *) p;
                WPA_ASSERT(mbie->eid == WLAN_EID_MULTI_BAND);
-               WPA_ASSERT(IE_BUFFER_LENGTH(mbie->len) >= sizeof(*mbie));
+               WPA_ASSERT(2 + mbie->len >= sizeof(*mbie));
 
                fst_printf(MSG_WARNING,
                           "%s: %s: mb_ctrl=%u band_id=%u op_class=%u chan=%u bssid="
@@ -61,8 +61,8 @@ static void fst_dump_mb_ies(const char *group_id, const char *ifname,
                           mbie->mb_connection_capability,
                           mbie->fst_session_tmout);
 
-               p += IE_BUFFER_LENGTH(mbie->len);
-               s -= IE_BUFFER_LENGTH(mbie->len);
+               p += 2 + mbie->len;
+               s -= 2 + mbie->len;
        }
 }
 
@@ -81,7 +81,7 @@ static void fst_fill_mb_ie(struct wpabuf *buf, const u8 *bssid,
        os_memset(mbie, 0, len);
 
        mbie->eid = WLAN_EID_MULTI_BAND;
-       mbie->len = len - IE_HEADER_SIZE;
+       mbie->len = len - 2;
 #ifdef HOSTAPD
        mbie->mb_ctrl = MB_STA_ROLE_AP;
        mbie->mb_connection_capability = MB_CONNECTION_CAPABILITY_AP;
@@ -211,7 +211,7 @@ static const u8 * fst_mbie_get_peer_addr(const struct multi_band_ie *mbie)
                break;
        case MB_STA_ROLE_NON_PCP_NON_AP:
                if (mbie->mb_ctrl & MB_CTRL_STA_MAC_PRESENT &&
-                   IE_BUFFER_LENGTH(mbie->len) >= sizeof(*mbie) + ETH_ALEN)
+                   (size_t) 2 + mbie->len >= sizeof(*mbie) + ETH_ALEN)
                        peer_addr = (const u8 *) &mbie[1];
                break;
        default:
@@ -229,12 +229,12 @@ fst_group_get_new_iface_by_mbie_and_band_id(struct fst_group *g,
                                            u8 band_id,
                                            u8 *iface_peer_addr)
 {
-       while (mb_ies_size >= offsetof(struct multi_band_ie, mb_ctrl)) {
+       while (mb_ies_size >= 2) {
                const struct multi_band_ie *mbie =
                        (const struct multi_band_ie *) mb_ies_buff;
 
                if (mbie->eid != WLAN_EID_MULTI_BAND ||
-                   IE_BUFFER_LENGTH(mbie->len) < sizeof(*mbie))
+                   (size_t) 2 + mbie->len < sizeof(*mbie))
                        break;
 
                if (mbie->band_id == band_id) {
@@ -255,8 +255,8 @@ fst_group_get_new_iface_by_mbie_and_band_id(struct fst_group *g,
                        break;
                }
 
-               mb_ies_buff += IE_BUFFER_LENGTH(mbie->len);
-               mb_ies_size -= IE_BUFFER_LENGTH(mbie->len);
+               mb_ies_buff += 2 + mbie->len;
+               mb_ies_size -= 2 + mbie->len;
        }
 
        return NULL;
index 8f7b1a7..d5a875f 100644 (file)
@@ -45,9 +45,6 @@ fst_hw_mode_to_band(enum hostapd_hw_mode mode)
        }
 }
 
-#define IE_HEADER_SIZE               ((u8) (2 * sizeof(u8)))
-#define IE_BUFFER_LENGTH(ie_len_val) ((size_t) ((ie_len_val) + IE_HEADER_SIZE))
-
 struct fst_ctrl_handle {
        struct fst_ctrl ctrl;
        struct dl_list global_ctrls_lentry;