summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstsp <stsp@openbsd.org>2017-01-09 12:40:00 +0000
committerstsp <stsp@openbsd.org>2017-01-09 12:40:00 +0000
commita2ee12ec5312f000b562600de0b9d10b25d6f59d (patch)
tree26833d9821fb8d224fbcfd82f803ae66f0d16e9a
parentProvide TLS_INT for consistency with libssl/libcrypto. (diff)
downloadwireguard-openbsd-a2ee12ec5312f000b562600de0b9d10b25d6f59d.tar.xz
wireguard-openbsd-a2ee12ec5312f000b562600de0b9d10b25d6f59d.zip
Manage the HT protection setting if acting as hostap with 11n enabled.
For now we flip-flop only between non-member protection and non-HT protection. Running a HT network without protection would require monitoring environmental conditions (e.g. foreign beacons) which make HT protection necessary. The ic_update_htprot driver function becomes optional because it won't be needed by all drivers. Only call it if the driver has set a function pointer. ok tb@
-rw-r--r--sys/net80211/ieee80211_input.c5
-rw-r--r--sys/net80211/ieee80211_node.c32
-rw-r--r--sys/net80211/ieee80211_var.h5
3 files changed, 37 insertions, 5 deletions
diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c
index f57cdbdbc4c..746f8d8dd21 100644
--- a/sys/net80211/ieee80211_input.c
+++ b/sys/net80211/ieee80211_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_input.c,v 1.180 2016/09/21 12:21:27 stsp Exp $ */
+/* $OpenBSD: ieee80211_input.c,v 1.181 2017/01/09 12:40:00 stsp Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
@@ -1612,7 +1612,8 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m,
htprot_last, htprot));
ic->ic_stats.is_ht_prot_change++;
ic->ic_bss->ni_htop1 = ni->ni_htop1;
- ic->ic_update_htprot(ic, ic->ic_bss);
+ if (ic->ic_update_htprot)
+ ic->ic_update_htprot(ic, ic->ic_bss);
}
}
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index f9c2d55c55c..f255e0d1a2a 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.c,v 1.108 2017/01/09 09:31:18 stsp Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.109 2017/01/09 12:40:00 stsp Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
@@ -353,6 +353,16 @@ ieee80211_create_ibss(struct ieee80211com* ic, struct ieee80211_channel *chan)
ni->ni_capinfo = IEEE80211_CAPINFO_IBSS;
if (ic->ic_flags & IEEE80211_F_WEPON)
ni->ni_capinfo |= IEEE80211_CAPINFO_PRIVACY;
+ if (ic->ic_flags & IEEE80211_F_HTON) {
+ /*
+ * Default to non-member HT protection until we have a way
+ * of picking up information from the environment (such as
+ * beacons from other networks) which proves that only HT
+ * STAs are on the air.
+ */
+ ni->ni_htop1 = IEEE80211_HTPROT_NONMEMBER;
+ ic->ic_protmode = IEEE80211_PROT_RTSCTS;
+ }
if (ic->ic_flags & IEEE80211_F_RSNON) {
struct ieee80211_key *k;
@@ -1423,7 +1433,15 @@ ieee80211_needs_auth(struct ieee80211com *ic, struct ieee80211_node *ni)
void
ieee80211_node_join_ht(struct ieee80211com *ic, struct ieee80211_node *ni)
{
- /* TBD */
+ enum ieee80211_htprot;
+
+ /* Update HT protection setting. */
+ if ((ni->ni_flags & IEEE80211_NODE_HT) == 0) {
+ ic->ic_nonhtsta++;
+ ic->ic_bss->ni_htop1 = IEEE80211_HTPROT_NONHT_MIXED;
+ if (ic->ic_update_htprot)
+ ic->ic_update_htprot(ic, ic->ic_bss);
+ }
}
/*
@@ -1712,6 +1730,16 @@ ieee80211_node_leave(struct ieee80211com *ic, struct ieee80211_node *ni)
if (ni->ni_flags & IEEE80211_NODE_HT)
ieee80211_node_leave_ht(ic, ni);
+ else if (ic->ic_flags & IEEE80211_F_HTON) {
+ if (ic->ic_nonhtsta == 0)
+ panic("bogus non-HT station count %d", ic->ic_nonhtsta);
+ if (--ic->ic_nonhtsta == 0) {
+ /* All associated stations now support HT. */
+ ic->ic_bss->ni_htop1 = IEEE80211_HTPROT_NONMEMBER;
+ if (ic->ic_update_htprot)
+ ic->ic_update_htprot(ic, ic->ic_bss);
+ }
+ }
if (ic->ic_node_leave != NULL)
(*ic->ic_node_leave)(ic, ni);
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 08024e7c27c..a43979fd53c 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_var.h,v 1.73 2016/12/17 18:35:54 stsp Exp $ */
+/* $OpenBSD: ieee80211_var.h,v 1.74 2017/01/09 12:40:00 stsp Exp $ */
/* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */
/*-
@@ -310,6 +310,9 @@ struct ieee80211com {
u_int ic_dtim_period;
u_int ic_dtim_count;
+#ifndef IEEE80211_STA_ONLY
+ u_int16_t ic_nonhtsta; /* # non-HT stations */
+#endif
u_int32_t ic_txbfcaps;
u_int16_t ic_htcaps;
u_int8_t ic_ampdu_params;