PERFORCE change 139691 for review
Sam Leffler
sam at FreeBSD.org
Wed Apr 9 23:29:31 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=139691
Change 139691 by sam at sam_ebb on 2008/04/09 23:28:45
show last auth failure, deauth, and disassoc reasons
Affected files ...
.. //depot/projects/vap/tools/tools/net80211/wlanstats/wlanstats.c#7 edit
Differences ...
==== //depot/projects/vap/tools/tools/net80211/wlanstats/wlanstats.c#7 (text+ko) ====
@@ -113,7 +113,10 @@
"rx w/ unsupported auth alg" },
#define S_RX_AUTH_FAIL AFTER(S_RX_AUTH_UNSUPPORTED)
{ 5, "rx_auth_fail", "auth_fail", "rx sta auth failure" },
-#define S_RX_AUTH_COUNTERMEASURES AFTER(S_RX_AUTH_FAIL)
+#define S_RX_AUTH_FAIL_CODE AFTER(S_RX_AUTH_FAIL)
+ { 5, "rx_auth_fail_code","auth_fail_code",
+ "last rx auth failure reason" },
+#define S_RX_AUTH_COUNTERMEASURES AFTER(S_RX_AUTH_FAIL_CODE)
{ 5, "rx_auth_countermeasures", "auth_countermeasures",
"rx sta auth failure 'cuz of TKIP countermeasures" },
#define S_RX_ASSOC_BSS AFTER(S_RX_AUTH_COUNTERMEASURES)
@@ -130,9 +133,14 @@
"rx assoc w/ bad WPA IE" },
#define S_RX_DEAUTH AFTER(S_RX_ASSOC_BADWPAIE)
{ 5, "rx_deauth", "deauth", "rx deauthentication" },
-#define S_RX_DISASSOC AFTER(S_RX_DEAUTH)
+#define S_RX_DEAUTH_CODE AFTER(S_RX_DEAUTH)
+ { 5, "rx_deauth_code","deauth_code", "last rx deauth reason" },
+#define S_RX_DISASSOC AFTER(S_RX_DEAUTH_CODE)
{ 5, "rx_disassoc", "disassoc", "rx disassociation" },
-#define S_RX_BADSUBTYPE AFTER(S_RX_DISASSOC)
+#define S_RX_DISASSOC_CODE AFTER(S_RX_DISASSOC)
+ { 5, "rx_disassoc_code","disassoc_code",
+ "last rx disassoc reason" },
+#define S_RX_BADSUBTYPE AFTER(S_RX_DISASSOC_CODE)
{ 5, "rx_badsubtype", "badsubtype", "rx frame w/ unknown subtype" },
#define S_RX_NOBUF AFTER(S_RX_BADSUBTYPE)
{ 5, "rx_nobuf", "nobuf", "rx failed for lack of mbuf" },
@@ -448,14 +456,14 @@
wf->ireq.i_data = (caddr_t) &wf->u_info;
wf->ireq.i_len = sizeof(wf->u_info);
if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0)
- err(1, "%s (IEEE80211_IOC_STA_INFO)", wf->ireq.i_name);
+ warn("%s (IEEE80211_IOC_STA_INFO)", wf->ireq.i_name);
IEEE80211_ADDR_COPY(nstats->is_u.macaddr, wf->mac);
wf->ireq.i_type = IEEE80211_IOC_STA_STATS;
wf->ireq.i_data = (caddr_t) nstats;
wf->ireq.i_len = sizeof(*nstats);
if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0)
- err(1, "%s (IEEE80211_IOC_STA_STATS)", wf->ireq.i_name);
+ warn("%s (IEEE80211_IOC_STA_STATS)", wf->ireq.i_name);
wf->ifr.ifr_data = (caddr_t) stats;
if (ioctl(wf->s, SIOCG80211STATS, &wf->ifr) < 0)
@@ -487,6 +495,81 @@
wf->ntotal = wf->ncur;
}
+void
+setreason(char b[], size_t bs, int v)
+{
+#define N(a) (sizeof(a)/sizeof(a[0]))
+ static const char *reasons[] = {
+ [IEEE80211_REASON_UNSPECIFIED] = "unspecified",
+ [IEEE80211_REASON_AUTH_EXPIRE] = "auth expire",
+ [IEEE80211_REASON_AUTH_LEAVE] = "auth leave",
+ [IEEE80211_REASON_ASSOC_EXPIRE] = "assoc expire",
+ [IEEE80211_REASON_ASSOC_TOOMANY] = "assoc toomany",
+ [IEEE80211_REASON_NOT_AUTHED] = "not authed",
+ [IEEE80211_REASON_NOT_ASSOCED] = "not assoced",
+ [IEEE80211_REASON_ASSOC_LEAVE] = "assoc leave",
+ [IEEE80211_REASON_ASSOC_NOT_AUTHED] = "assoc not authed",
+ [IEEE80211_REASON_DISASSOC_PWRCAP_BAD] = "disassoc pwrcap bad",
+ [IEEE80211_REASON_DISASSOC_SUPCHAN_BAD] = "disassoc supchan bad",
+ [IEEE80211_REASON_IE_INVALID] = "ie invalid",
+ [IEEE80211_REASON_MIC_FAILURE] = "mic failure",
+ [IEEE80211_REASON_4WAY_HANDSHAKE_TIMEOUT]= "4-way handshake timeout",
+ [IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT] = "group key update timeout",
+ [IEEE80211_REASON_IE_IN_4WAY_DIFFERS] = "ie in 4-way differs",
+ [IEEE80211_REASON_GROUP_CIPHER_INVALID] = "group cipher invalid",
+ [IEEE80211_REASON_PAIRWISE_CIPHER_INVALID]= "pairwise cipher invalid",
+ [IEEE80211_REASON_AKMP_INVALID] = "akmp invalid",
+ [IEEE80211_REASON_UNSUPP_RSN_IE_VERSION]= "unsupported rsn ie version",
+ [IEEE80211_REASON_INVALID_RSN_IE_CAP] = "invalid rsn ie cap",
+ [IEEE80211_REASON_802_1X_AUTH_FAILED] = "802.1x auth failed",
+ [IEEE80211_REASON_CIPHER_SUITE_REJECTED]= "cipher suite rejected",
+ };
+ if (v < N(reasons) && reasons[v] != NULL)
+ snprintf(b, bs, "%s (%u)", reasons[v], v);
+ else
+ snprintf(b, bs, "%u", v);
+#undef N
+}
+
+void
+setstatus(char b[], size_t bs, int v)
+{
+#define N(a) (sizeof(a)/sizeof(a[0]))
+ static const char *status[] = {
+ [IEEE80211_STATUS_SUCCESS] = "success",
+ [IEEE80211_STATUS_UNSPECIFIED] = "unspecified",
+ [IEEE80211_STATUS_CAPINFO] = "capinfo",
+ [IEEE80211_STATUS_NOT_ASSOCED] = "not assoced",
+ [IEEE80211_STATUS_OTHER] = "other",
+ [IEEE80211_STATUS_ALG] = "algorithm",
+ [IEEE80211_STATUS_SEQUENCE] = "sequence",
+ [IEEE80211_STATUS_CHALLENGE] = "challenge",
+ [IEEE80211_STATUS_TIMEOUT] = "timeout",
+ [IEEE80211_STATUS_TOOMANY] = "toomany",
+ [IEEE80211_STATUS_BASIC_RATE] = "basic rate",
+ [IEEE80211_STATUS_SP_REQUIRED] = "sp required",
+ [IEEE80211_STATUS_PBCC_REQUIRED] = "pbcc required",
+ [IEEE80211_STATUS_CA_REQUIRED] = "ca required",
+ [IEEE80211_STATUS_SPECMGMT_REQUIRED] = "specmgmt required",
+ [IEEE80211_STATUS_PWRCAP_REQUIRED] = "pwrcap required",
+ [IEEE80211_STATUS_SUPCHAN_REQUIRED] = "supchan required",
+ [IEEE80211_STATUS_SHORTSLOT_REQUIRED] = "shortslot required",
+ [IEEE80211_STATUS_DSSSOFDM_REQUIRED] = "dsssofdm required",
+ [IEEE80211_STATUS_INVALID_IE] = "invalid ie",
+ [IEEE80211_STATUS_GROUP_CIPHER_INVALID] = "group cipher invalid",
+ [IEEE80211_STATUS_PAIRWISE_CIPHER_INVALID]= "pairwise cipher invalid",
+ [IEEE80211_STATUS_AKMP_INVALID] = "akmp invalid",
+ [IEEE80211_STATUS_UNSUPP_RSN_IE_VERSION]= "unsupported rsn ie version",
+ [IEEE80211_STATUS_INVALID_RSN_IE_CAP] = "invalid rsn ie cap",
+ [IEEE80211_STATUS_CIPHER_SUITE_REJECTED]= "cipher suite rejected",
+ };
+ if (v < N(status) && status[v] != NULL)
+ snprintf(b, bs, "%s (%u)", status[v], v);
+ else
+ snprintf(b, bs, "%u", v);
+#undef N
+}
+
static int
wlan_getinfo(struct wlanstatfoo_p *wf, int s, char b[], size_t bs)
{
@@ -505,6 +588,21 @@
case S_SIGNAL:
snprintf(b, bs, "%d", si->isi_rssi + si->isi_noise);
return 1;
+ case S_RX_AUTH_FAIL_CODE:
+ if (wf->cur.is_rx_authfail_code == 0)
+ break;
+ setstatus(b, bs, wf->cur.is_rx_authfail_code);
+ return 1;
+ case S_RX_DEAUTH_CODE:
+ if (wf->cur.is_rx_deauth_code == 0)
+ break;
+ setreason(b, bs, wf->cur.is_rx_deauth_code);
+ return 1;
+ case S_RX_DISASSOC_CODE:
+ if (wf->cur.is_rx_disassoc_code == 0)
+ break;
+ setreason(b, bs, wf->cur.is_rx_disassoc_code);
+ return 1;
}
b[0] = '\0';
return 0;
More information about the p4-projects
mailing list