summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2007-07-03 19:44:55 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2007-07-03 19:44:55 +0000
commitf0ec217509a6f9cc784437cfcefa6844b07ad8e4 (patch)
treef826239e0ce7a74e5fd6626e7260e5fadf936342
parentecaf2e2a78105db3b11e502933a39c404975f739 (diff)
add a function that builds an RSN IE (ieee80211_add_rsn).
-rw-r--r--sys/net80211/ieee80211_node.h10
-rw-r--r--sys/net80211/ieee80211_output.c81
-rw-r--r--sys/net80211/ieee80211_proto.h4
3 files changed, 91 insertions, 4 deletions
diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h
index b2aba6a609f..57c9177681f 100644
--- a/sys/net80211/ieee80211_node.h
+++ b/sys/net80211/ieee80211_node.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.h,v 1.15 2007/06/17 09:05:44 damien Exp $ */
+/* $OpenBSD: ieee80211_node.h,v 1.16 2007/07/03 19:44:54 damien Exp $ */
/* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */
/*-
@@ -109,10 +109,15 @@ struct ieee80211_node {
#endif
/* power saving mode */
-
u_int8_t ni_pwrsave;
struct ifqueue ni_savedq; /* packets queued for pspoll */
+ /* RSN */
+ u_int ni_group_cipher;
+ u_int ni_pairwise_cipherset;
+ u_int ni_akmset;
+ u_int16_t ni_rsncaps;
+
/* others */
u_int16_t ni_associd; /* assoc response */
u_int16_t ni_txseq; /* seq to be transmitted */
@@ -124,6 +129,7 @@ struct ieee80211_node {
int ni_txrate; /* index to ni_rates[] */
int ni_state;
u_int32_t *ni_challenge; /* shared-key challenge */
+
u_int8_t ni_flags; /* special-purpose state */
#define IEEE80211_NODE_ERP 0x01
#define IEEE80211_NODE_QOS 0x02
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index c96b245e971..953b44f94fc 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_output.c,v 1.37 2007/07/03 16:43:41 damien Exp $ */
+/* $OpenBSD: ieee80211_output.c,v 1.38 2007/07/03 19:44:54 damien Exp $ */
/* $NetBSD: ieee80211_output.c,v 1.13 2004/05/31 11:02:55 dyoung Exp $ */
/*-
@@ -809,6 +809,85 @@ ieee80211_add_qos_capability(u_int8_t *frm, struct ieee80211com *ic)
}
/*
+ * Add an RSN element to a frame (see 7.3.2.25).
+ */
+u_int8_t *
+ieee80211_add_rsn(u_int8_t *frm, struct ieee80211com *ic,
+ const struct ieee80211_node *ni)
+{
+ u_int8_t *plen, *pcount;
+ u_int16_t count;
+
+ *frm++ = IEEE80211_ELEMID_RSN;
+ plen = frm++; /* length filled in later */
+
+ /* write Version field */
+ LE_WRITE_2(frm, 1); frm += 2;
+
+ /* write Group Cipher Suite field (see Table 20da) */
+ memcpy(frm, IEEE80211_OUI, 3); frm += 3;
+ switch (ni->ni_group_cipher) {
+ case IEEE80211_CIPHER_WEP40:
+ *frm++ = 1;
+ break;
+ case IEEE80211_CIPHER_TKIP:
+ *frm++ = 2;
+ break;
+ case IEEE80211_CIPHER_CCMP:
+ *frm++ = 3;
+ break;
+ case IEEE80211_CIPHER_WEP104:
+ *frm++ = 5;
+ break;
+ case IEEE80211_CIPHER_USEGROUP:
+ /* can't get there */
+ panic("invalid group cipher!");
+ break;
+ }
+
+ pcount = frm; frm += 2;
+ count = 0;
+ /* write Pairwise Cipher Suite List */
+ if (ni->ni_pairwise_cipherset & IEEE80211_CIPHER_TKIP) {
+ memcpy(frm, IEEE80211_OUI, 3); frm += 3;
+ *frm++ = 2;
+ count++;
+ }
+ if (ni->ni_pairwise_cipherset & IEEE80211_CIPHER_CCMP) {
+ memcpy(frm, IEEE80211_OUI, 3); frm += 3;
+ *frm++ = 3;
+ count++;
+ }
+ /* write Pairwise Cipher Suite Count field */
+ LE_WRITE_2(pcount, count);
+
+ pcount = frm; frm += 2;
+ count = 0;
+ /* write AKM Suite List (see Table 20dc) */
+ if (ni->ni_akmset & IEEE80211_AKM_IEEE8021X) {
+ memcpy(frm, IEEE80211_OUI, 3); frm += 3;
+ *frm++ = 1;
+ count++;
+ }
+ if (ni->ni_akmset & IEEE80211_AKM_PSK) {
+ memcpy(frm, IEEE80211_OUI, 3); frm += 3;
+ *frm++ = 2;
+ count++;
+ }
+ /* write AKM Suite List Count field */
+ LE_WRITE_2(pcount, count);
+
+ /* write RSN Capabilities field */
+ LE_WRITE_2(frm, ni->ni_rsncaps); frm += 2;
+
+ /* no PMKID List for now */
+
+ /* write length field */
+ *plen = frm - plen + 1;
+ return frm;
+}
+
+/*
* Add an extended supported rates element to a frame (see 7.3.2.14).
*/
u_int8_t *
diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h
index b509106b352..5cf24aa3016 100644
--- a/sys/net80211/ieee80211_proto.h
+++ b/sys/net80211/ieee80211_proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_proto.h,v 1.17 2007/07/03 16:43:41 damien Exp $ */
+/* $OpenBSD: ieee80211_proto.h,v 1.18 2007/07/03 19:44:54 damien Exp $ */
/* $NetBSD: ieee80211_proto.h,v 1.3 2003/10/13 04:23:56 dyoung Exp $ */
/*-
@@ -95,6 +95,8 @@ extern u_int8_t *ieee80211_add_challenge(u_int8_t *, const u_int8_t *, u_int);
extern u_int8_t *ieee80211_add_erp(u_int8_t *, struct ieee80211com *);
extern u_int8_t *ieee80211_add_qos_capability(u_int8_t *,
struct ieee80211com *);
+extern u_int8_t *ieee80211_add_rsn(u_int8_t *, struct ieee80211com *,
+ const struct ieee80211_node *);
extern u_int8_t *ieee80211_add_xrates(u_int8_t *,
const struct ieee80211_rateset *);
extern void ieee80211_print_essid(const u_int8_t *, int);