Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Dec 2016 04:02:41 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r309664 - head/sys/net80211
Message-ID:  <201612070402.uB742fZH047704@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed Dec  7 04:02:41 2016
New Revision: 309664
URL: https://svnweb.freebsd.org/changeset/base/309664

Log:
  [net80211] start refactoring out the "am I a wep / group key!" code.
  
  This is a bunch of pointer arithmetic that is copypasta'ed everywhere.
  Let's undo that copypasta.

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	Wed Dec  7 01:15:10 2016	(r309663)
+++ head/sys/net80211/ieee80211_crypto.c	Wed Dec  7 04:02:41 2016	(r309664)
@@ -520,6 +520,26 @@ ieee80211_crypto_setkey(struct ieee80211
 	return dev_key_set(vap, key);
 }
 
+/*
+ * Return index if the key is a WEP key (0..3); -1 otherwise.
+ *
+ * This is different to "get_keyid" which defaults to returning
+ * 0 for unicast keys; it assumes that it won't be used for WEP.
+ */
+int
+ieee80211_crypto_get_key_wepidx(const struct ieee80211vap *vap,
+    const struct ieee80211_key *k)
+{
+
+	if (k >= &vap->iv_nw_keys[0] &&
+	    k <  &vap->iv_nw_keys[IEEE80211_WEP_NKID])
+		return (k - vap->iv_nw_keys);
+	return (-1):
+}
+
+/*
+ * Note: only supports a single unicast key (0).
+ */
 uint8_t
 ieee80211_crypto_get_keyid(struct ieee80211vap *vap, struct ieee80211_key *k)
 {

Modified: head/sys/net80211/ieee80211_crypto.h
==============================================================================
--- head/sys/net80211/ieee80211_crypto.h	Wed Dec  7 01:15:10 2016	(r309663)
+++ head/sys/net80211/ieee80211_crypto.h	Wed Dec  7 04:02:41 2016	(r309664)
@@ -202,6 +202,8 @@ void	ieee80211_crypto_register(const str
 void	ieee80211_crypto_unregister(const struct ieee80211_cipher *);
 int	ieee80211_crypto_available(u_int cipher);
 
+int	ieee80211_crypto_get_key_wepidx(const struct ieee80211vap *,
+	    const struct ieee80211_key *k);
 uint8_t	ieee80211_crypto_get_keyid(struct ieee80211vap *vap,
 		struct ieee80211_key *k);
 struct ieee80211_key *ieee80211_crypto_get_txkey(struct ieee80211_node *,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612070402.uB742fZH047704>