From ba091c06c53702ff76bdb17a59e6ab4fdb2aef30 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 13 Dec 2009 23:11:11 +0200 Subject: [PATCH] Mark ieee802_11_parse_elems() input and parsed elems const In addition, re-order IE pointers and u8 length so that the shorter length fields are together to allow compiler to optimize structure size. --- hostapd/ieee802_11.c | 2 +- src/common/ieee802_11_common.c | 8 +++--- src/common/ieee802_11_common.h | 51 +++++++++++++++++----------------- wpa_supplicant/mlme.c | 8 +++--- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c index a3bffc77c..bf50abbce 100644 --- a/hostapd/ieee802_11.c +++ b/hostapd/ieee802_11.c @@ -639,7 +639,7 @@ static u16 check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta, { struct ieee802_11_elems elems; u16 resp; - u8 *wpa_ie; + const u8 *wpa_ie; size_t wpa_ie_len; if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) { diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 79a9325ed..96ef5b65a 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -1,6 +1,6 @@ /* * IEEE 802.11 Common routines - * Copyright (c) 2002-2008, Jouni Malinen + * Copyright (c) 2002-2009, Jouni Malinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -19,7 +19,7 @@ #include "ieee802_11_common.h" -static int ieee802_11_parse_vendor_specific(u8 *pos, size_t elen, +static int ieee802_11_parse_vendor_specific(const u8 *pos, size_t elen, struct ieee802_11_elems *elems, int show_errors) { @@ -131,12 +131,12 @@ static int ieee802_11_parse_vendor_specific(u8 *pos, size_t elen, * @show_errors: Whether to show parsing errors in debug log * Returns: Parsing result */ -ParseRes ieee802_11_parse_elems(u8 *start, size_t len, +ParseRes ieee802_11_parse_elems(const u8 *start, size_t len, struct ieee802_11_elems *elems, int show_errors) { size_t left = len; - u8 *pos = start; + const u8 *pos = start; int unknown = 0; os_memset(elems, 0, sizeof(*elems)); diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index 4a48046ff..4a4f5a742 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -1,6 +1,6 @@ /* * IEEE 802.11 Common routines - * Copyright (c) 2002-2008, Jouni Malinen + * Copyright (c) 2002-2009, Jouni Malinen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -17,57 +17,58 @@ /* Parsed Information Elements */ struct ieee802_11_elems { - u8 *ssid; + const u8 *ssid; + const u8 *supp_rates; + const u8 *fh_params; + const u8 *ds_params; + const u8 *cf_params; + const u8 *tim; + const u8 *ibss_params; + const u8 *challenge; + const u8 *erp_info; + const u8 *ext_supp_rates; + const u8 *wpa_ie; + const u8 *rsn_ie; + const u8 *wmm; /* WMM Information or Parameter Element */ + const u8 *wmm_tspec; + const u8 *wps_ie; + const u8 *power_cap; + const u8 *supp_channels; + const u8 *mdie; + const u8 *ftie; + const u8 *timeout_int; + const u8 *ht_capabilities; + const u8 *ht_operation; + const u8 *vendor_ht_cap; + u8 ssid_len; - u8 *supp_rates; u8 supp_rates_len; - u8 *fh_params; u8 fh_params_len; - u8 *ds_params; u8 ds_params_len; - u8 *cf_params; u8 cf_params_len; - u8 *tim; u8 tim_len; - u8 *ibss_params; u8 ibss_params_len; - u8 *challenge; u8 challenge_len; - u8 *erp_info; u8 erp_info_len; - u8 *ext_supp_rates; u8 ext_supp_rates_len; - u8 *wpa_ie; u8 wpa_ie_len; - u8 *rsn_ie; u8 rsn_ie_len; - u8 *wmm; /* WMM Information or Parameter Element */ u8 wmm_len; /* 7 = WMM Information; 24 = WMM Parameter */ - u8 *wmm_tspec; u8 wmm_tspec_len; - u8 *wps_ie; u8 wps_ie_len; - u8 *power_cap; u8 power_cap_len; - u8 *supp_channels; u8 supp_channels_len; - u8 *mdie; u8 mdie_len; - u8 *ftie; u8 ftie_len; - u8 *timeout_int; u8 timeout_int_len; - u8 *ht_capabilities; u8 ht_capabilities_len; - u8 *ht_operation; u8 ht_operation_len; - u8 *vendor_ht_cap; u8 vendor_ht_cap_len; }; typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; -ParseRes ieee802_11_parse_elems(u8 *start, size_t len, +ParseRes ieee802_11_parse_elems(const u8 *start, size_t len, struct ieee802_11_elems *elems, int show_errors); int ieee802_11_ie_count(const u8 *ies, size_t ies_len); diff --git a/wpa_supplicant/mlme.c b/wpa_supplicant/mlme.c index c71cdd317..cb2dffebe 100644 --- a/wpa_supplicant/mlme.c +++ b/wpa_supplicant/mlme.c @@ -130,11 +130,11 @@ static int ecw2cw(int ecw) static void ieee80211_sta_wmm_params(struct wpa_supplicant *wpa_s, - u8 *wmm_param, size_t wmm_param_len) + const u8 *wmm_param, size_t wmm_param_len) { size_t left; int count; - u8 *pos; + const u8 *pos; u8 wmm_acm; if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) @@ -218,8 +218,8 @@ static int ieee80211_sta_tx(struct wpa_supplicant *wpa_s, const u8 *buf, static void ieee80211_send_auth(struct wpa_supplicant *wpa_s, - int transaction, u8 *extra, size_t extra_len, - int encrypt) + int transaction, const u8 *extra, + size_t extra_len, int encrypt) { u8 *buf; size_t len;