From owner-p4-projects@FreeBSD.ORG Tue Nov 29 06:07:08 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B27E716A422; Tue, 29 Nov 2005 06:07:07 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8C2E316A41F for ; Tue, 29 Nov 2005 06:07:07 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A74C43D60 for ; Tue, 29 Nov 2005 06:06:57 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id jAT66v6V060567 for ; Tue, 29 Nov 2005 06:06:57 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id jAT66v66060564 for perforce@freebsd.org; Tue, 29 Nov 2005 06:06:57 GMT (envelope-from sam@freebsd.org) Date: Tue, 29 Nov 2005 06:06:57 GMT Message-Id: <200511290606.jAT66v66060564@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 87416 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Nov 2005 06:07:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=87416 Change 87416 by sam@sam_ebb on 2005/11/29 06:06:02 print decoded wme, wpa, rsn, and ath ie's with -v Affected files ... .. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#53 edit Differences ... ==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#53 (text+ko) ==== @@ -812,6 +812,252 @@ } } +#define LE_READ_2(p) \ + ((u_int16_t) \ + ((((const u_int8_t *)(p))[0] ) | \ + (((const u_int8_t *)(p))[1] << 8))) +#define LE_READ_4(p) \ + ((u_int32_t) \ + ((((const u_int8_t *)(p))[0] ) | \ + (((const u_int8_t *)(p))[1] << 8) | \ + (((const u_int8_t *)(p))[2] << 16) | \ + (((const u_int8_t *)(p))[3] << 24))) + +/* + * NB: The decoding routines assume a properly formatted ie + * which should be safe as the kernel only retains them + * if they parse ok. + */ + +static void +printwmeie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ +#define MS(_v, _f) (((_v) & _f) >> _f##_S) + static const char *acnames[] = { "BE", "BK", "VO", "VI" }; + int i; + + printf("%s", tag); + if (verbose) { + printf(""); + } +#undef MS +} + +static void +printathie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ + + printf("%s", tag); + if (verbose) { + const struct ieee80211_ath_ie *ath = + (const struct ieee80211_ath_ie *)ie; + + printf("<"); + if (ath->ath_capability & ATHEROS_CAP_TURBO_PRIME) + printf("DTURBO,"); + if (ath->ath_capability & ATHEROS_CAP_COMPRESSION) + printf("COMP,"); + if (ath->ath_capability & ATHEROS_CAP_FAST_FRAME) + printf("FF,"); + if (ath->ath_capability & ATHEROS_CAP_XR) + printf("XR,"); + if (ath->ath_capability & ATHEROS_CAP_AR) + printf("AR,"); + if (ath->ath_capability & ATHEROS_CAP_BURST) + printf("BURST,"); + if (ath->ath_capability & ATHEROS_CAP_WME) + printf("WME,"); + if (ath->ath_capability & ATHEROS_CAP_BOOST) + printf("BOOST,"); + printf("0x%x>", LE_READ_2(ath->ath_defkeyix)); + } +} + +static const char * +wpa_cipher(const u_int8_t *sel) +{ +#define WPA_SEL(x) (((x)<<24)|WPA_OUI) + u_int32_t w = LE_READ_4(sel); + + switch (w) { + case WPA_SEL(WPA_CSE_NULL): + return "NONE"; + case WPA_SEL(WPA_CSE_WEP40): + return "WEP40"; + case WPA_SEL(WPA_CSE_WEP104): + return "WEP104"; + case WPA_SEL(WPA_CSE_TKIP): + return "TKIP"; + case WPA_SEL(WPA_CSE_CCMP): + return "AES-CCMP"; + } + return "?"; /* NB: so 1<< is discarded */ +#undef WPA_SEL +} + +static const char * +wpa_keymgmt(const u_int8_t *sel) +{ +#define WPA_SEL(x) (((x)<<24)|WPA_OUI) + u_int32_t w = LE_READ_4(sel); + + switch (w) { + case WPA_SEL(WPA_ASE_8021X_UNSPEC): + return "8021X-UNSPEC"; + case WPA_SEL(WPA_ASE_8021X_PSK): + return "8021X-PSK"; + case WPA_SEL(WPA_ASE_NONE): + return "NONE"; + } + return "?"; +#undef WPA_SEL +} + +static void +printwpaie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ + u_int8_t len = ie[1]; + + printf("%s", tag); + if (verbose) { + const char *sep; + int n; + + ie += 6, len -= 4; /* NB: len is payload only */ + + printf(" 0; n--) { + printf("%s%s", sep, wpa_cipher(ie)); + ie += 4, len -= 4; + sep = "+"; + } + + /* key management algorithms */ + n = LE_READ_2(ie); + ie += 2, len -= 2; + sep = " km:"; + for (; n > 0; n--) { + printf("%s%s", sep, wpa_keymgmt(ie)); + ie += 4, len -= 4; + sep = "+"; + } + + if (len > 2) /* optional capabilities */ + printf(", caps 0x%x", LE_READ_2(ie)); + printf(">"); + } +} + +static const char * +rsn_cipher(const u_int8_t *sel) +{ +#define RSN_SEL(x) (((x)<<24)|RSN_OUI) + u_int32_t w = LE_READ_4(sel); + + switch (w) { + case RSN_SEL(RSN_CSE_NULL): + return "NONE"; + case RSN_SEL(RSN_CSE_WEP40): + return "WEP40"; + case RSN_SEL(RSN_CSE_WEP104): + return "WEP104"; + case RSN_SEL(RSN_CSE_TKIP): + return "TKIP"; + case RSN_SEL(RSN_CSE_CCMP): + return "AES-CCMP"; + case RSN_SEL(RSN_CSE_WRAP): + return "AES-OCB"; + } + return "?"; +#undef WPA_SEL +} + +static const char * +rsn_keymgmt(const u_int8_t *sel) +{ +#define RSN_SEL(x) (((x)<<24)|RSN_OUI) + u_int32_t w = LE_READ_4(sel); + + switch (w) { + case RSN_SEL(RSN_ASE_8021X_UNSPEC): + return "8021X-UNSPEC"; + case RSN_SEL(RSN_ASE_8021X_PSK): + return "8021X-PSK"; + case RSN_SEL(RSN_ASE_NONE): + return "NONE"; + } + return "?"; +#undef RSN_SEL +} + +static void +printrsnie(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ + u_int8_t len = ie[1]; + + printf("%s", tag); + if (verbose) { + const char *sep; + int n; + + ie += 6, len -= 4; /* NB: len is payload only */ + + printf(" 0; n--) { + printf("%s%s", sep, rsn_cipher(ie)); + ie += 4, len -= 4; + sep = "+"; + } + + /* key management algorithms */ + n = LE_READ_2(ie); + ie += 2, len -= 2; + sep = " km:"; + for (; n > 0; n--) { + printf("%s%s", sep, rsn_keymgmt(ie)); + ie += 4, len -= 4; + sep = "+"; + } + + if (len > 2) /* optional capabilities */ + printf(", caps 0x%x", LE_READ_2(ie)); + /* XXXPMKID */ + printf(">"); + } +} + /* * Copy the ssid string contents into buf, truncating to fit. If the * ssid is entirely printable then just copy intact. Otherwise convert @@ -887,16 +1133,16 @@ switch (vp[0]) { case IEEE80211_ELEMID_VENDOR: if (iswpaoui(vp)) - printie(" WPA", vp, 2+vp[1], maxcols); + printwpaie(" WPA", vp, 2+vp[1], maxcols); else if (iswmeoui(vp)) - printie(" WME", vp, 2+vp[1], maxcols); + printwmeie(" WME", vp, 2+vp[1], maxcols); else if (isatherosoui(vp)) - printie(" ATH", vp, 2+vp[1], maxcols); + printathie(" ATH", vp, 2+vp[1], maxcols); else printie(" VEN", vp, 2+vp[1], maxcols); break; case IEEE80211_ELEMID_RSN: - printie(" RSN", vp, 2+vp[1], maxcols); + printrsnie(" RSN", vp, 2+vp[1], maxcols); break; default: printie(" ???", vp, 2+vp[1], maxcols);