From owner-svn-src-head@freebsd.org Sat Oct 3 00:57:35 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F41B1A0EF61; Sat, 3 Oct 2015 00:57:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C89F211D7; Sat, 3 Oct 2015 00:57:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t930vYok095568; Sat, 3 Oct 2015 00:57:34 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t930vYjn095566; Sat, 3 Oct 2015 00:57:34 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201510030057.t930vYjn095566@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 3 Oct 2015 00:57:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288527 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Oct 2015 00:57:35 -0000 Author: adrian Date: Sat Oct 3 00:57:33 2015 New Revision: 288527 URL: https://svnweb.freebsd.org/changeset/base/288527 Log: net80211: add a possibility to retrieve current TX key without encapsulation. Submitted by: Differential Revision: https://reviews.freebsd.org/D3639 Modified: head/sys/net80211/ieee80211_crypto.c head/sys/net80211/ieee80211_crypto.h Modified: head/sys/net80211/ieee80211_crypto.c ============================================================================== --- head/sys/net80211/ieee80211_crypto.c Sat Oct 3 00:50:13 2015 (r288526) +++ head/sys/net80211/ieee80211_crypto.c Sat Oct 3 00:57:33 2015 (r288527) @@ -531,16 +531,11 @@ ieee80211_crypto_get_keyid(struct ieee80 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_ 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; } /* Modified: head/sys/net80211/ieee80211_crypto.h ============================================================================== --- head/sys/net80211/ieee80211_crypto.h Sat Oct 3 00:50:13 2015 (r288526) +++ head/sys/net80211/ieee80211_crypto.h Sat Oct 3 00:57:33 2015 (r288527) @@ -195,6 +195,8 @@ int ieee80211_crypto_available(u_int cip 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 *,