From aa33c1cc86a8bd32c93cc88f706b51a697c63a7c Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 9 Jul 2005 23:15:30 +0000 Subject: Change default key allocation method to do the right thing for legacy parts (i.e. those that have 4 global key slots). We blindly assign unicast keys to key slot 0. Devices that need alternate allocation logic must override this method. Reviewed by: avatar Approved by: re (scottl) --- sys/net80211/ieee80211_crypto.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index d68ca47..c20a81f 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -61,7 +61,24 @@ static int _ieee80211_crypto_delkey(struct ieee80211com *, static int null_key_alloc(struct ieee80211com *ic, const struct ieee80211_key *k) { - return IEEE80211_KEYIX_NONE; + if (!(&ic->ic_nw_keys[0] <= k && + k < &ic->ic_nw_keys[IEEE80211_WEP_NKID])) { + /* + * Not in the global key table, the driver should handle this + * by allocating a slot in the h/w key table/cache. In + * lieu of that return key slot 0 for any unicast key + * request. We disallow the request if this is a group key. + * This default policy does the right thing for legacy hardware + * with a 4 key table. It also handles devices that pass + * packets through untouched when marked with the WEP bit + * and key index 0. + */ + if ((k->wk_flags & IEEE80211_KEY_GROUP) == 0) + return 0; /* NB: use key index 0 for ucast key */ + else + return IEEE80211_KEYIX_NONE; + } + return k - ic->ic_nw_keys; } static int null_key_delete(struct ieee80211com *ic, const struct ieee80211_key *k) -- cgit v1.1