summaryrefslogtreecommitdiffstats
path: root/sys/net80211
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2015-10-03 00:57:33 +0000
committeradrian <adrian@FreeBSD.org>2015-10-03 00:57:33 +0000
commit792bb43e5b8131ff6d91d493d0042d75c58db5c0 (patch)
tree3575612756cc899daacf91fdbc673765fae243c8 /sys/net80211
parent49776fea0a8200d6d6a1085e7d4b0a6f04870612 (diff)
downloadFreeBSD-src-792bb43e5b8131ff6d91d493d0042d75c58db5c0.zip
FreeBSD-src-792bb43e5b8131ff6d91d493d0042d75c58db5c0.tar.gz
net80211: add a possibility to retrieve current TX key without encapsulation.
Submitted by: <s3erios@gmail.com> Differential Revision: https://reviews.freebsd.org/D3639
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211_crypto.c32
-rw-r--r--sys/net80211/ieee80211_crypto.h2
2 files changed, 23 insertions, 11 deletions
diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c
index 5864d282..db54e76 100644
--- a/sys/net80211/ieee80211_crypto.c
+++ b/sys/net80211/ieee80211_crypto.c
@@ -531,16 +531,11 @@ ieee80211_crypto_get_keyid(struct ieee80211vap *vap, struct ieee80211_key *k)
return (0);
}
-/*
- * Add privacy headers appropriate for the specified key.
- */
struct ieee80211_key *
-ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
+ieee80211_crypto_get_txkey(struct ieee80211_node *ni, struct mbuf *m)
{
struct ieee80211vap *vap = ni->ni_vap;
- struct ieee80211_key *k;
struct ieee80211_frame *wh;
- const struct ieee80211_cipher *cip;
/*
* Multicast traffic always uses the multicast key.
@@ -559,12 +554,27 @@ ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
vap->iv_stats.is_tx_nodefkey++;
return NULL;
}
- k = &vap->iv_nw_keys[vap->iv_def_txkey];
- } else
- k = &ni->ni_ucastkey;
+ return &vap->iv_nw_keys[vap->iv_def_txkey];
+ }
- cip = k->wk_cipher;
- return (cip->ic_encap(k, m) ? k : NULL);
+ return &ni->ni_ucastkey;
+}
+
+/*
+ * Add privacy headers appropriate for the specified key.
+ */
+struct ieee80211_key *
+ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
+{
+ struct ieee80211_key *k;
+ const struct ieee80211_cipher *cip;
+
+ if ((k = ieee80211_crypto_get_txkey(ni, m)) != NULL) {
+ cip = k->wk_cipher;
+ return (cip->ic_encap(k, m) ? k : NULL);
+ }
+
+ return NULL;
}
/*
diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h
index 2b6375e..cca166d 100644
--- a/sys/net80211/ieee80211_crypto.h
+++ b/sys/net80211/ieee80211_crypto.h
@@ -195,6 +195,8 @@ int ieee80211_crypto_available(u_int cipher);
uint8_t ieee80211_crypto_get_keyid(struct ieee80211vap *vap,
struct ieee80211_key *k);
+struct ieee80211_key *ieee80211_crypto_get_txkey(struct ieee80211_node *,
+ struct mbuf *);
struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_node *,
struct mbuf *);
struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *,
OpenPOWER on IntegriCloud