From 9654ac02d11acfc4170d9e933e9794b97a756221 Mon Sep 17 00:00:00 2001 From: damien Date: Tue, 12 Aug 2008 19:05:39 +0000 Subject: [PATCH] add IEEE80211_RSNIE_MAXLEN and IEEE80211_WPAIE_MAXLEN definitions instead of hard-coding values. for RSN IE, request space for Group Integrity Cipher Suite. --- sys/net80211/ieee80211_output.c | 20 +++++++++++++------- sys/net80211/ieee80211_pae_output.c | 11 +++++------ sys/net80211/ieee80211_priv.h | 23 ++++++++++++++++++++++- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c index f6333c44194..9fb019879f1 100644 --- a/sys/net80211/ieee80211_output.c +++ b/sys/net80211/ieee80211_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_output.c,v 1.66 2008/08/02 08:35:48 damien Exp $ */ +/* $OpenBSD: ieee80211_output.c,v 1.67 2008/08/12 19:05:39 damien Exp $ */ /* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */ /*- @@ -1028,10 +1028,12 @@ ieee80211_get_probe_resp(struct ieee80211com *ic, struct ieee80211_node *ni) ((rs->rs_nrates > IEEE80211_RATE_SIZE) ? 2 + rs->rs_nrates - IEEE80211_RATE_SIZE : 0) + (((ic->ic_flags & IEEE80211_F_RSNON) && - (ic->ic_bss->ni_rsnprotos & IEEE80211_PROTO_RSN)) ? 2 + 44 : 0) + + (ic->ic_bss->ni_rsnprotos & IEEE80211_PROTO_RSN)) ? + 2 + IEEE80211_RSNIE_MAXLEN : 0) + ((ic->ic_flags & IEEE80211_F_QOS) ? 2 + 18 : 0) + (((ic->ic_flags & IEEE80211_F_RSNON) && - (ic->ic_bss->ni_rsnprotos & IEEE80211_PROTO_WPA)) ? 2 + 48 : 0)); + (ic->ic_bss->ni_rsnprotos & IEEE80211_PROTO_WPA)) ? + 2 + IEEE80211_WPAIE_MAXLEN : 0)); if (m == NULL) return NULL; @@ -1143,10 +1145,12 @@ ieee80211_get_assoc_req(struct ieee80211com *ic, struct ieee80211_node *ni, ((rs->rs_nrates > IEEE80211_RATE_SIZE) ? 2 + rs->rs_nrates - IEEE80211_RATE_SIZE : 0) + (((ic->ic_flags & IEEE80211_F_RSNON) && - (ni->ni_rsnprotos & IEEE80211_PROTO_RSN)) ? 2 + 44 : 0) + + (ni->ni_rsnprotos & IEEE80211_PROTO_RSN)) ? + 2 + IEEE80211_RSNIE_MAXLEN : 0) + ((ic->ic_flags & IEEE80211_F_QOS) ? 2 + 1 : 0) + (((ic->ic_flags & IEEE80211_F_RSNON) && - (ni->ni_rsnprotos & IEEE80211_PROTO_WPA)) ? 2 + 48 : 0)); + (ni->ni_rsnprotos & IEEE80211_PROTO_WPA)) ? + 2 + IEEE80211_WPAIE_MAXLEN : 0)); if (m == NULL) return NULL; @@ -1436,10 +1440,12 @@ ieee80211_beacon_alloc(struct ieee80211com *ic, struct ieee80211_node *ni) ((rs->rs_nrates > IEEE80211_RATE_SIZE) ? 2 + rs->rs_nrates - IEEE80211_RATE_SIZE : 0) + (((ic->ic_flags & IEEE80211_F_RSNON) && - (ni->ni_rsnprotos & IEEE80211_PROTO_RSN)) ? 2 + 44 : 0) + + (ni->ni_rsnprotos & IEEE80211_PROTO_RSN)) ? + 2 + IEEE80211_RSNIE_MAXLEN : 0) + ((ic->ic_flags & IEEE80211_F_QOS) ? 2 + 18 : 0) + (((ic->ic_flags & IEEE80211_F_RSNON) && - (ni->ni_rsnprotos & IEEE80211_PROTO_WPA)) ? 2 + 48 : 0)); + (ni->ni_rsnprotos & IEEE80211_PROTO_WPA)) ? + 2 + IEEE80211_WPAIE_MAXLEN : 0)); if (m == NULL) return NULL; diff --git a/sys/net80211/ieee80211_pae_output.c b/sys/net80211/ieee80211_pae_output.c index 2e8a341e708..cef1942aa0a 100644 --- a/sys/net80211/ieee80211_pae_output.c +++ b/sys/net80211/ieee80211_pae_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_pae_output.c,v 1.7 2008/08/12 18:25:40 damien Exp $ */ +/* $OpenBSD: ieee80211_pae_output.c,v 1.8 2008/08/12 19:05:39 damien Exp $ */ /*- * Copyright (c) 2007,2008 Damien Bergamini @@ -375,11 +375,10 @@ ieee80211_send_4way_msg3(struct ieee80211com *ic, struct ieee80211_node *ni) k = &ic->ic_nw_keys[ic->ic_def_txkey]; m = ieee80211_get_eapol_key(M_DONTWAIT, MT_DATA, - 2 + 48 + - ((ni->ni_rsnprotos == IEEE80211_PROTO_RSN) ? - 2 + 6 + k->k_len : 0) + - ((ni->ni_flags & IEEE80211_NODE_MFP) ? 2 + 28 : 0) + - 15); + ((ni->ni_rsnprotos == IEEE80211_PROTO_WPA) ? + 2 + IEEE80211_WPAIE_MAXLEN : + 2 + IEEE80211_RSNIE_MAXLEN + 2 + 6 + k->k_len + 15) + + ((ni->ni_flags & IEEE80211_NODE_MFP) ? 2 + 28 : 0)); if (m == NULL) return ENOMEM; key = mtod(m, struct ieee80211_eapol_key *); diff --git a/sys/net80211/ieee80211_priv.h b/sys/net80211/ieee80211_priv.h index 7a8c6de5ba1..29e1072faa2 100644 --- a/sys/net80211/ieee80211_priv.h +++ b/sys/net80211/ieee80211_priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_priv.h,v 1.2 2008/07/27 14:21:15 damien Exp $ */ +/* $OpenBSD: ieee80211_priv.h,v 1.3 2008/08/12 19:05:39 damien Exp $ */ /*- * Copyright (c) 2008 Damien Bergamini @@ -38,6 +38,27 @@ extern int ieee80211_debug; #define IEEE80211_AID_ISSET(b, w) \ ((w)[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32))) +#define IEEE80211_RSNIE_MAXLEN \ + (2 + /* Version */ \ + 4 + /* Group Data Cipher Suite */ \ + 2 + /* Pairwise Cipher Suite Count */ \ + 4 * 2 + /* Pairwise Cipher Suite List (max 2) */ \ + 2 + /* AKM Suite List Count */ \ + 4 * 4 + /* AKM Suite List (max 4) */ \ + 2 + /* RSN Capabilities */ \ + 2 + /* PMKID Count */ \ + 16 * 1 + /* PMKID List (max 1) */ \ + 4) /* 11w: Group Integrity Cipher Suite */ + +#define IEEE80211_WPAIE_MAXLEN \ + (4 + /* MICROSOFT_OUI */ \ + 2 + /* Version */ \ + 4 + /* Group Cipher Suite */ \ + 2 + /* Pairwise Cipher Suite Count */ \ + 4 * 2 + /* Pairwise Cipher Suite List (max 2) */ \ + 2 + /* AKM Suite List Count */ \ + 4 * 2) /* AKM Suite List (max 2) */ + /* unaligned big endian access */ #define BE_READ_2(p) \ ((u_int16_t) \ -- 2.20.1