diff options
author | sam <sam@FreeBSD.org> | 2008-05-28 23:32:00 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2008-05-28 23:32:00 +0000 |
commit | 7aa0974e2beebe0274ddf6e9c4c6663f0153b9fb (patch) | |
tree | 11f1e7429f40b4646c19d38f606412f9c2290a86 /sys/net80211 | |
parent | 6be5c5b31dc02a4f03bf8981291eaf6adfce5882 (diff) | |
download | FreeBSD-src-7aa0974e2beebe0274ddf6e9c4c6663f0153b9fb.zip FreeBSD-src-7aa0974e2beebe0274ddf6e9c4c6663f0153b9fb.tar.gz |
Add a mac address to the key definition as otherwise we lose the
address specified in the ioctl and for drivers that need the address
to locate a key (e.g. for delete).
Note this changes net80211-private api's but not the driver callback;
may want to change that in the future.
Reviewed by: sephe, thompsa
Diffstat (limited to 'sys/net80211')
-rw-r--r-- | sys/net80211/ieee80211_crypto.c | 12 | ||||
-rw-r--r-- | sys/net80211/ieee80211_crypto.h | 5 | ||||
-rw-r--r-- | sys/net80211/ieee80211_ioctl.c | 8 |
3 files changed, 12 insertions, 13 deletions
diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index d644d0c..1329bd4 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -130,10 +130,9 @@ dev_key_delete(struct ieee80211vap *vap, } static __inline int -dev_key_set(struct ieee80211vap *vap, const struct ieee80211_key *key, - const uint8_t mac[IEEE80211_ADDR_LEN]) +dev_key_set(struct ieee80211vap *vap, const struct ieee80211_key *key) { - return vap->iv_key_set(vap, key, mac); + return vap->iv_key_set(vap, key, key->wk_macaddr); } /* @@ -480,8 +479,7 @@ ieee80211_crypto_delglobalkeys(struct ieee80211vap *vap) * ieee80211_key_update_end(vap); */ int -ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key, - const uint8_t macaddr[IEEE80211_ADDR_LEN]) +ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key) { const struct ieee80211_cipher *cip = key->wk_cipher; @@ -490,7 +488,7 @@ ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key, IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO, "%s: %s keyix %u flags 0x%x mac %s rsc %ju tsc %ju len %u\n", __func__, cip->ic_name, key->wk_keyix, - key->wk_flags, ether_sprintf(macaddr), + key->wk_flags, ether_sprintf(key->wk_macaddr), key->wk_keyrsc[IEEE80211_NONQOS_TID], key->wk_keytsc, key->wk_keylen); @@ -513,7 +511,7 @@ ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key, vap->iv_stats.is_crypto_setkey_nokey++; return 0; } - return dev_key_set(vap, key, macaddr); + return dev_key_set(vap, key); } /* diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h index c0ae068..f6f666c 100644 --- a/sys/net80211/ieee80211_crypto.h +++ b/sys/net80211/ieee80211_crypto.h @@ -92,6 +92,7 @@ struct ieee80211_key { uint64_t wk_keytsc; /* key transmit sequence counter */ const struct ieee80211_cipher *wk_cipher; void *wk_private; /* private cipher state */ + uint8_t wk_macaddr[IEEE80211_ADDR_LEN]; }; #define IEEE80211_KEY_COMMON /* common flags passed in by apps */\ (IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV | IEEE80211_KEY_GROUP) @@ -144,9 +145,7 @@ int ieee80211_crypto_newkey(struct ieee80211vap *, int cipher, int flags, struct ieee80211_key *); int ieee80211_crypto_delkey(struct ieee80211vap *, struct ieee80211_key *); -int ieee80211_crypto_setkey(struct ieee80211vap *, - struct ieee80211_key *, - const uint8_t macaddr[IEEE80211_ADDR_LEN]); +int ieee80211_crypto_setkey(struct ieee80211vap *, struct ieee80211_key *); void ieee80211_crypto_delglobalkeys(struct ieee80211vap *); /* diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index d9c1857..786c815 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1135,8 +1135,9 @@ ieee80211_ioctl_setkey(struct ieee80211vap *vap, struct ieee80211req *ireq) wk->wk_keytsc = 0; /* new key, reset */ memset(wk->wk_key, 0, sizeof(wk->wk_key)); memcpy(wk->wk_key, ik.ik_keydata, ik.ik_keylen); - if (!ieee80211_crypto_setkey(vap, wk, - ni != NULL ? ni->ni_macaddr : ik.ik_macaddr)) + IEEE80211_ADDR_COPY(wk->wk_macaddr, + ni != NULL ? ni->ni_macaddr : ik.ik_macaddr); + if (!ieee80211_crypto_setkey(vap, wk)) error = EIO; else if ((ik.ik_flags & IEEE80211_KEY_DEFAULT)) vap->iv_def_txkey = kid; @@ -2502,7 +2503,8 @@ ieee80211_ioctl_set80211(struct ieee80211vap *vap, u_long cmd, struct ieee80211r IEEE80211_KEY_XMIT | IEEE80211_KEY_RECV, k)) { k->wk_keylen = ireq->i_len; memcpy(k->wk_key, tmpkey, sizeof(tmpkey)); - if (!ieee80211_crypto_setkey(vap, k, vap->iv_myaddr)) + IEEE80211_ADDR_COPY(k->wk_macaddr, vap->iv_myaddr); + if (!ieee80211_crypto_setkey(vap, k)) error = EINVAL; } else error = EINVAL; |