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.
This commit is contained in:
Jouni Malinen 2009-12-13 23:11:11 +02:00
parent f8b1f69561
commit ba091c06c5
4 changed files with 35 additions and 34 deletions

View file

@ -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) {

View file

@ -1,6 +1,6 @@
/*
* IEEE 802.11 Common routines
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
*
* 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));

View file

@ -1,6 +1,6 @@
/*
* IEEE 802.11 Common routines
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
*
* 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);

View file

@ -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;