summaryrefslogtreecommitdiffstats
path: root/sys/net80211
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2007-03-11 06:36:10 +0000
committersam <sam@FreeBSD.org>2007-03-11 06:36:10 +0000
commitb04c5bd38256cacaf01d5e5de001265ee280c21f (patch)
treec8836cf18bb680aa720bd7556c512bad8fb3cca7 /sys/net80211
parent679daf849749d409c8c49c8cc5e58093b228968f (diff)
downloadFreeBSD-src-b04c5bd38256cacaf01d5e5de001265ee280c21f.zip
FreeBSD-src-b04c5bd38256cacaf01d5e5de001265ee280c21f.tar.gz
add IEEE80211_KEY_UNDEFINED and use it instead of local defs
Obtained from: netbsd
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211_crypto.c4
-rw-r--r--sys/net80211/ieee80211_crypto.h3
-rw-r--r--sys/net80211/ieee80211_output.c10
3 files changed, 10 insertions, 7 deletions
diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c
index e9ce135..4f60133 100644
--- a/sys/net80211/ieee80211_crypto.c
+++ b/sys/net80211/ieee80211_crypto.c
@@ -521,7 +521,7 @@ ieee80211_crypto_encap(struct ieee80211com *ic,
*/
wh = mtod(m, struct ieee80211_frame *);
if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
- ni->ni_ucastkey.wk_cipher == &ieee80211_cipher_none) {
+ IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)) {
if (ic->ic_def_txkey == IEEE80211_KEYIX_NONE) {
IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
"[%s] no default transmit key (%s) deftxkey %u\n",
@@ -577,7 +577,7 @@ ieee80211_crypto_decap(struct ieee80211com *ic,
ivp = mtod(m, const u_int8_t *) + hdrlen; /* XXX contig */
keyid = ivp[IEEE80211_WEP_IVLEN];
if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
- ni->ni_ucastkey.wk_cipher == &ieee80211_cipher_none)
+ IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey))
k = &ic->ic_nw_keys[keyid >> 6];
else
k = &ni->ni_ucastkey;
diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h
index f006a7a..3df3e07 100644
--- a/sys/net80211/ieee80211_crypto.h
+++ b/sys/net80211/ieee80211_crypto.h
@@ -169,6 +169,9 @@ struct ieee80211_cipher {
};
extern const struct ieee80211_cipher ieee80211_cipher_none;
+#define IEEE80211_KEY_UNDEFINED(k) \
+ ((k)->wk_cipher == &ieee80211_cipher_none)
+
void ieee80211_crypto_register(const struct ieee80211_cipher *);
void ieee80211_crypto_unregister(const struct ieee80211_cipher *);
int ieee80211_crypto_available(u_int cipher);
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index e58bbb6..5dd4aec 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -573,7 +573,6 @@ ieee80211_mbuf_adjust(struct ieee80211com *ic, int hdrsize,
#undef TO_BE_RECLAIMED
}
-#define KEY_UNDEFINED(k) ((k).wk_cipher == &ieee80211_cipher_none)
/*
* Return the transmit key to use in sending a unicast frame.
* If a unicast key is set we use that. When no unicast key is set
@@ -582,9 +581,9 @@ ieee80211_mbuf_adjust(struct ieee80211com *ic, int hdrsize,
static __inline struct ieee80211_key *
ieee80211_crypto_getucastkey(struct ieee80211com *ic, struct ieee80211_node *ni)
{
- if (KEY_UNDEFINED(ni->ni_ucastkey)) {
+ if (IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)) {
if (ic->ic_def_txkey == IEEE80211_KEYIX_NONE ||
- KEY_UNDEFINED(ic->ic_nw_keys[ic->ic_def_txkey]))
+ IEEE80211_KEY_UNDEFINED(&ic->ic_nw_keys[ic->ic_def_txkey]))
return NULL;
return &ic->ic_nw_keys[ic->ic_def_txkey];
} else {
@@ -601,7 +600,7 @@ static __inline struct ieee80211_key *
ieee80211_crypto_getmcastkey(struct ieee80211com *ic, struct ieee80211_node *ni)
{
if (ic->ic_def_txkey == IEEE80211_KEYIX_NONE ||
- KEY_UNDEFINED(ic->ic_nw_keys[ic->ic_def_txkey]))
+ IEEE80211_KEY_UNDEFINED(&ic->ic_nw_keys[ic->ic_def_txkey]))
return NULL;
return &ic->ic_nw_keys[ic->ic_def_txkey];
}
@@ -752,7 +751,8 @@ ieee80211_encap(struct ieee80211com *ic, struct mbuf *m,
if (eh.ether_type != htons(ETHERTYPE_PAE) ||
((ic->ic_flags & IEEE80211_F_WPA) &&
(ic->ic_opmode == IEEE80211_M_STA ?
- !KEY_UNDEFINED(*key) : !KEY_UNDEFINED(ni->ni_ucastkey)))) {
+ !IEEE80211_KEY_UNDEFINED(key) :
+ !IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)))) {
wh->i_fc[1] |= IEEE80211_FC1_WEP;
/* XXX do fragmentation */
if (!ieee80211_crypto_enmic(ic, key, m, 0)) {
OpenPOWER on IntegriCloud