summaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2019-09-02 12:54:22 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2019-09-02 12:54:22 +0000
commit38b1bfefb2ef4d31513e7e75acaf6503a5312c1c (patch)
tree47989b06053aa3ae00d0ebea90f9806ad4a9db4d /sbin/ifconfig
parentfbe59ca116c64eb924e71fe936b301dabd78c0a9 (diff)
Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if the failure is applicable to an already selected AP (e.g. wrong WPA key). This will hopefully reduce the amount of help requests for what often turn out to be trivial misconfiguration issues that were previously hard to diagnose without debug mode. ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in sync with the kernel. A full 'make build' will do the right thing! Very helpful input by mpi@ and deraadt@
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifconfig.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 85785d39420..961a54ab4db 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.411 2019/08/30 03:52:20 deraadt Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.412 2019/09/02 12:54:21 stsp Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -2348,10 +2348,25 @@ print_cipherset(u_int32_t cipherset)
}
void
+print_assoc_failures(uint32_t assoc_fail)
+{
+ /* Filter out the most obvious failure cases. */
+ assoc_fail &= ~IEEE80211_NODEREQ_ASSOCFAIL_ESSID;
+ if (assoc_fail & IEEE80211_NODEREQ_ASSOCFAIL_PRIVACY)
+ assoc_fail &= ~IEEE80211_NODEREQ_ASSOCFAIL_WPA_PROTO;
+ assoc_fail &= ~IEEE80211_NODEREQ_ASSOCFAIL_PRIVACY;
+
+ if (assoc_fail == 0)
+ return;
+
+ printb_status(assoc_fail, IEEE80211_NODEREQ_ASSOCFAIL_BITS);
+}
+
+void
ieee80211_status(void)
{
int len, inwid, ijoin, inwkey, ipsk, ichan, ipwr;
- int ibssid, iwpa;
+ int ibssid, iwpa, assocfail = 0;
struct ieee80211_nwid nwid;
struct ieee80211_join join;
struct ieee80211_nwkey nwkey;
@@ -2431,11 +2446,15 @@ ieee80211_status(void)
bzero(&nr, sizeof(nr));
bcopy(bssid.i_bssid, &nr.nr_macaddr, sizeof(nr.nr_macaddr));
strlcpy(nr.nr_ifname, name, sizeof(nr.nr_ifname));
- if (ioctl(s, SIOCG80211NODE, &nr) == 0 && nr.nr_rssi) {
- if (nr.nr_max_rssi)
- printf(" %u%%", IEEE80211_NODEREQ_RSSI(&nr));
- else
- printf(" %ddBm", nr.nr_rssi);
+ if (ioctl(s, SIOCG80211NODE, &nr) == 0) {
+ if (nr.nr_rssi) {
+ if (nr.nr_max_rssi)
+ printf(" %u%%",
+ IEEE80211_NODEREQ_RSSI(&nr));
+ else
+ printf(" %ddBm", nr.nr_rssi);
+ }
+ assocfail = nr.nr_assoc_fail;
}
}
@@ -2478,6 +2497,11 @@ ieee80211_status(void)
putchar(' ');
printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
}
+
+ if (assocfail) {
+ putchar(' ');
+ print_assoc_failures(assocfail);
+ }
putchar('\n');
if (show_join)
join_status();
@@ -2751,6 +2775,8 @@ ieee80211_printnode(struct ieee80211_nodereq *nr)
if ((nr->nr_flags & IEEE80211_NODEREQ_AP) == 0)
printb_status(IEEE80211_NODEREQ_STATE(nr->nr_state),
IEEE80211_NODEREQ_STATE_BITS);
+ else if (nr->nr_assoc_fail)
+ print_assoc_failures(nr->nr_assoc_fail);
}
void