summaryrefslogtreecommitdiff
path: root/sys/net80211
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2017-03-12 03:13:51 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2017-03-12 03:13:51 +0000
commit6342e05f19d8d19befc6bbb0252382351687c735 (patch)
treeac2424f26fe1a10e04bc0054e2594888b662e487 /sys/net80211
parent2bb7a6a466ffd9e59436b6b68233e51962ad8d65 (diff)
Introduce separate fields for supported WPA protocols and AKMs in struct
ieee80211_node. Pass these fields to 'ifconfig scan' instead of giving it currently configured/enabled settings. Fixes display of AP WPA capabilities in 'ifconfig scan' while the wifi interface is not configured to use WPA (my previous commit attempted to fix the same problem but didn't make it work in all cases). ok tb@
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211_input.c75
-rw-r--r--sys/net80211/ieee80211_ioctl.c16
-rw-r--r--sys/net80211/ieee80211_node.h4
3 files changed, 65 insertions, 30 deletions
diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c
index 4dff49f2d41..748db65fa92 100644
--- a/sys/net80211/ieee80211_input.c
+++ b/sys/net80211/ieee80211_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_input.c,v 1.187 2017/03/01 19:28:48 stsp Exp $ */
+/* $OpenBSD: ieee80211_input.c,v 1.188 2017/03/12 03:13:50 stsp Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
@@ -1654,35 +1654,57 @@ ieee80211_recv_probe_resp(struct ieee80211com *ic, struct mbuf *m,
&& ic->ic_opmode != IEEE80211_M_HOSTAP
#endif
) {
- struct ieee80211_rsnparams rsn;
- const u_int8_t *saveie = NULL;
+ struct ieee80211_rsnparams rsn, wpa;
+
+ ni->ni_rsnprotos = IEEE80211_PROTO_NONE;
+ ni->ni_supported_rsnprotos = IEEE80211_PROTO_NONE;
+ ni->ni_rsnakms = 0;
+ ni->ni_supported_rsnakms = 0;
+ ni->ni_rsnciphers = 0;
+ ni->ni_rsngroupcipher = 0;
+ ni->ni_rsngroupmgmtcipher = 0;
+ ni->ni_rsncaps = 0;
+
+ if (rsnie != NULL &&
+ ieee80211_parse_rsn(ic, rsnie, &rsn) == 0) {
+ ni->ni_supported_rsnprotos |= IEEE80211_PROTO_RSN;
+ ni->ni_supported_rsnakms |= rsn.rsn_akms;
+ }
+ if (wpaie != NULL &&
+ ieee80211_parse_wpa(ic, wpaie, &wpa) == 0) {
+ ni->ni_supported_rsnprotos |= IEEE80211_PROTO_WPA;
+ ni->ni_supported_rsnakms |= wpa.rsn_akms;
+ }
+
/*
- * If the AP advertises both RSN and WPA IEs (WPA1+WPA2),
- * we only store the parameters of the highest protocol
- * version we support.
+ * If the AP advertises both WPA and RSN IEs (WPA1+WPA2),
+ * we only use the highest protocol version we support.
*/
if (rsnie != NULL &&
+ (ni->ni_supported_rsnprotos & IEEE80211_PROTO_RSN) &&
(ic->ic_rsnprotos & IEEE80211_PROTO_RSN)) {
- if (ieee80211_parse_rsn(ic, rsnie, &rsn) == 0) {
+ if (ieee80211_save_ie(rsnie, &ni->ni_rsnie) == 0) {
ni->ni_rsnprotos = IEEE80211_PROTO_RSN;
- saveie = rsnie;
+ ni->ni_rsnakms = rsn.rsn_akms;
+ ni->ni_rsnciphers = rsn.rsn_ciphers;
+ ni->ni_rsngroupcipher = rsn.rsn_groupcipher;
+ ni->ni_rsngroupmgmtcipher =
+ rsn.rsn_groupmgmtcipher;
+ ni->ni_rsncaps = rsn.rsn_caps;
}
} else if (wpaie != NULL &&
+ (ni->ni_supported_rsnprotos & IEEE80211_PROTO_WPA) &&
(ic->ic_rsnprotos & IEEE80211_PROTO_WPA)) {
- if (ieee80211_parse_wpa(ic, wpaie, &rsn) == 0) {
+ if (ieee80211_save_ie(wpaie, &ni->ni_rsnie) == 0) {
ni->ni_rsnprotos = IEEE80211_PROTO_WPA;
- saveie = wpaie;
+ ni->ni_rsnakms = wpa.rsn_akms;
+ ni->ni_rsnciphers = wpa.rsn_ciphers;
+ ni->ni_rsngroupcipher = wpa.rsn_groupcipher;
+ ni->ni_rsngroupmgmtcipher =
+ wpa.rsn_groupmgmtcipher;
+ ni->ni_rsncaps = wpa.rsn_caps;
}
}
- if (saveie != NULL &&
- ieee80211_save_ie(saveie, &ni->ni_rsnie) == 0) {
- ni->ni_rsnakms = rsn.rsn_akms;
- ni->ni_rsnciphers = rsn.rsn_ciphers;
- ni->ni_rsngroupcipher = rsn.rsn_groupcipher;
- ni->ni_rsngroupmgmtcipher = rsn.rsn_groupmgmtcipher;
- ni->ni_rsncaps = rsn.rsn_caps;
- } else
- ni->ni_rsnprotos = IEEE80211_PROTO_NONE;
}
if (ssid[1] != 0 && ni->ni_esslen == 0) {
@@ -2018,6 +2040,15 @@ ieee80211_recv_assoc_req(struct ieee80211com *ic, struct mbuf *m,
goto end;
}
+ ni->ni_rsnprotos = IEEE80211_PROTO_NONE;
+ ni->ni_supported_rsnprotos = IEEE80211_PROTO_NONE;
+ ni->ni_rsnakms = 0;
+ ni->ni_supported_rsnakms = 0;
+ ni->ni_rsnciphers = 0;
+ ni->ni_rsngroupcipher = 0;
+ ni->ni_rsngroupmgmtcipher = 0;
+ ni->ni_rsncaps = 0;
+
if (ic->ic_flags & IEEE80211_F_RSNON) {
const u_int8_t *saveie;
/*
@@ -2032,6 +2063,7 @@ ieee80211_recv_assoc_req(struct ieee80211com *ic, struct mbuf *m,
if (status != 0)
goto end;
ni->ni_rsnprotos = IEEE80211_PROTO_RSN;
+ ni->ni_supported_rsnprotos = IEEE80211_PROTO_RSN;
saveie = rsnie;
} else if (wpaie != NULL &&
(ic->ic_rsnprotos & IEEE80211_PROTO_WPA)) {
@@ -2039,6 +2071,7 @@ ieee80211_recv_assoc_req(struct ieee80211com *ic, struct mbuf *m,
if (status != 0)
goto end;
ni->ni_rsnprotos = IEEE80211_PROTO_WPA;
+ ni->ni_supported_rsnprotos = IEEE80211_PROTO_WPA;
saveie = wpaie;
} else {
/*
@@ -2112,6 +2145,7 @@ ieee80211_recv_assoc_req(struct ieee80211com *ic, struct mbuf *m,
goto end;
}
ni->ni_rsnakms = rsn.rsn_akms;
+ ni->ni_supported_rsnakms = rsn.rsn_akms;
ni->ni_rsnciphers = rsn.rsn_ciphers;
ni->ni_rsngroupcipher = ic->ic_bss->ni_rsngroupcipher;
ni->ni_rsngroupmgmtcipher = ic->ic_bss->ni_rsngroupmgmtcipher;
@@ -2138,8 +2172,7 @@ ieee80211_recv_assoc_req(struct ieee80211com *ic, struct mbuf *m,
ni->ni_flags |= IEEE80211_NODE_PMK;
}
}
- } else
- ni->ni_rsnprotos = IEEE80211_PROTO_NONE;
+ }
ni->ni_rssi = rxi->rxi_rssi;
ni->ni_rstamp = rxi->rxi_tstamp;
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index 08ba495e096..dfd415a22b9 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_ioctl.c,v 1.49 2017/03/11 13:22:36 stsp Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.50 2017/03/12 03:13:50 stsp Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
@@ -108,17 +108,17 @@ ieee80211_node2req(struct ieee80211com *ic, const struct ieee80211_node *ni,
nr->nr_rsnciphers = ni->ni_rsnciphers;
nr->nr_rsnakms = 0;
nr->nr_rsnprotos = 0;
- if (ni->ni_rsnprotos & IEEE80211_PROTO_WPA)
- nr->nr_rsnprotos |= IEEE80211_WPA_PROTO_WPA1;
- if (ni->ni_rsnprotos & IEEE80211_PROTO_RSN)
+ if (ni->ni_supported_rsnprotos & IEEE80211_PROTO_RSN)
nr->nr_rsnprotos |= IEEE80211_WPA_PROTO_WPA2;
- if (ni->ni_rsnakms & IEEE80211_AKM_8021X)
+ if (ni->ni_supported_rsnprotos & IEEE80211_PROTO_WPA)
+ nr->nr_rsnprotos |= IEEE80211_WPA_PROTO_WPA1;
+ if (ni->ni_supported_rsnakms & IEEE80211_AKM_8021X)
nr->nr_rsnakms |= IEEE80211_WPA_AKM_8021X;
- if (ni->ni_rsnakms & IEEE80211_AKM_PSK)
+ if (ni->ni_supported_rsnakms & IEEE80211_AKM_PSK)
nr->nr_rsnakms |= IEEE80211_WPA_AKM_PSK;
- if (ni->ni_rsnakms & IEEE80211_AKM_SHA256_8021X)
+ if (ni->ni_supported_rsnakms & IEEE80211_AKM_SHA256_8021X)
nr->nr_rsnakms |= IEEE80211_WPA_AKM_SHA256_8021X;
- if (ni->ni_rsnakms & IEEE80211_AKM_SHA256_PSK)
+ if (ni->ni_supported_rsnakms & IEEE80211_AKM_SHA256_PSK)
nr->nr_rsnakms |= IEEE80211_WPA_AKM_SHA256_PSK;
/* Node flags */
diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h
index 281c868ef03..82f79306570 100644
--- a/sys/net80211/ieee80211_node.h
+++ b/sys/net80211/ieee80211_node.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.h,v 1.67 2017/03/04 12:44:27 stsp Exp $ */
+/* $OpenBSD: ieee80211_node.h,v 1.68 2017/03/12 03:13:50 stsp Exp $ */
/* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */
/*-
@@ -219,7 +219,9 @@ struct ieee80211_node {
u_int ni_rsn_supp_state;
u_int ni_rsn_gstate;
u_int ni_rsn_retries;
+ u_int ni_supported_rsnprotos;
u_int ni_rsnprotos;
+ u_int ni_supported_rsnakms;
u_int ni_rsnakms;
u_int ni_rsnciphers;
enum ieee80211_cipher ni_rsngroupcipher;