Date: Wed, 24 Nov 2004 05:35:38 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 65764 for review Message-ID: <200411240535.iAO5ZcBW005307@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=65764 Change 65764 by sam@sam_ebb on 2004/11/24 05:34:45 consolidate printing of information elements Affected files ... .. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#18 edit Differences ... ==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#18 (text+ko) ==== @@ -665,7 +665,55 @@ return maxlen; } +/* unalligned little endian access */ +#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))) + +static int __inline +iswpaoui(const u_int8_t *frm) +{ + return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); +} + +static int __inline +iswmeoui(const u_int8_t *frm) +{ + return frm[1] > 3 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI); +} + +static int __inline +isatherosoui(const u_int8_t *frm) +{ + return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI); +} + static void +printies(const u_int8_t *vp, int ielen, int maxcols) +{ + for (; ielen > 0; ielen -= 2+vp[1]) + switch (vp[0]) { + case IEEE80211_ELEMID_VENDOR: + if (iswpaoui(vp)) + printie(" WPA", vp, 2+vp[1], maxcols); + else if (iswmeoui(vp)) + printie(" WME", 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); + break; + default: + printie(" ???", vp, 2+vp[1], maxcols); + break; + } +} + +static void list_scan(int s) { uint8_t buf[24*1024]; @@ -711,21 +759,7 @@ , sr->isr_intval , getcaps(sr->isr_capinfo) ); - - if (sr->isr_ie_len > 0) { - vp += sr->isr_ssid_len; - switch (vp[0]) { - case IEEE80211_ELEMID_VENDOR: - if (vp[1] < 2 + 4 || - memcmp(&vp[2], "\x00\x50\xf2\x01", 4) != 0) - break; - printie("WPA", vp, 2+vp[1], 24); - break; - case IEEE80211_ELEMID_RSN: - printie("RSN", vp, 2+vp[1], 24); - break; - } - } + printies(vp + sr->isr_ssid_len, sr->isr_ie_len, 24);; printf("\n"); cp += sr->isr_len, len -= sr->isr_len; } while (len >= sizeof(struct ieee80211req_scan_result)); @@ -775,32 +809,6 @@ list_scan(s); } -/* unalligned little endian access */ -#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))) - -static int __inline -iswpaoui(const u_int8_t *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); -} - -static int __inline -iswmeoui(const u_int8_t *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((WME_OUI_TYPE<<24)|WME_OUI); -} - -static int __inline -isatherosoui(const u_int8_t *frm) -{ - return frm[1] > 3 && LE_READ_4(frm+2) == ((ATH_OUI_TYPE<<24)|ATH_OUI); -} - static void list_stations(int s) { @@ -836,7 +844,6 @@ do { struct ieee80211req_sta_info *si; uint8_t *vp; - int ielen; si = (struct ieee80211req_sta_info *) cp; vp = (u_int8_t *)(si+1); @@ -852,24 +859,7 @@ , getcaps(si->isi_capinfo) , si->isi_erp ); - - for (ielen = si->isi_ie_len; ielen > 0; ielen -= 2+vp[1]) - switch (vp[0]) { - case IEEE80211_ELEMID_VENDOR: - if (iswpaoui(vp)) - printie(" WPA", vp, 2+vp[1], 24); - else if (iswmeoui(vp)) - printie(" WME", vp, 2+vp[1], 24); - else - printie(" VEN", vp, 2+vp[1], 24); - break; - case IEEE80211_ELEMID_RSN: - printie(" RSN", vp, 2+vp[1], 24); - break; - default: - printie(" ???", vp, 2+vp[1], 24); - break; - } + printies(vp, si->isi_ie_len, 24); printf("\n"); cp += si->isi_len, len -= si->isi_len; } while (len >= sizeof(struct ieee80211req_sta_info));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411240535.iAO5ZcBW005307>