Date: Thu, 16 Apr 2009 21:50:17 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r191150 - in projects/mesh11s: sbin/ifconfig sys/net80211 Message-ID: <200904162150.n3GLoH6b092699@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Thu Apr 16 21:50:17 2009 New Revision: 191150 URL: http://svn.freebsd.org/changeset/base/191150 Log: Implement MBSS (Mesh) scanning in net80211 and ifconfig. Sponsored by: The FreeBSD Foundation Modified: projects/mesh11s/sbin/ifconfig/ifieee80211.c projects/mesh11s/sys/net80211/ieee80211_input.c projects/mesh11s/sys/net80211/ieee80211_ioctl.c projects/mesh11s/sys/net80211/ieee80211_ioctl.h projects/mesh11s/sys/net80211/ieee80211_scan.h projects/mesh11s/sys/net80211/ieee80211_scan_sta.c Modified: projects/mesh11s/sbin/ifconfig/ifieee80211.c ============================================================================== --- projects/mesh11s/sbin/ifconfig/ifieee80211.c Thu Apr 16 21:20:24 2009 (r191149) +++ projects/mesh11s/sbin/ifconfig/ifieee80211.c Thu Apr 16 21:50:17 2009 (r191150) @@ -77,6 +77,8 @@ #include <net/if_media.h> #include <net/route.h> +#include <arpa/inet.h> + #include <net80211/ieee80211_ioctl.h> #include <net80211/ieee80211_freebsd.h> #include <net80211/ieee80211_superg.h> @@ -2482,6 +2484,40 @@ printathie(const char *tag, const u_int8 } } + +static void +printmeshconf(const char *tag, const uint8_t *ie, size_t ielen, int maxlen) +{ +#define MATCHOUI(bitfield, oui, value, string) \ +do { \ + if (((htonl(bitfield)) >> 8) == oui && \ + ((htonl(bitfield)) & 0xff) == value) \ + printf("%s", string); \ +} while (0) + + printf("%s", tag); + if (verbose) { + const struct ieee80211_meshconf_ie *mconf = + (const struct ieee80211_meshconf_ie *)ie; + printf("<v%d APSPI:", mconf->conf_ver); + MATCHOUI(mconf->conf_apspi, IEEE80211_MESHCONF_APSPI_HWMP_OUI, + IEEE80211_MESHCONF_APSPI_HWMP_VALUE, "HWMP"); + printf(" APSMI:"); + MATCHOUI(mconf->conf_apsmi, + IEEE80211_MESHCONF_APSMI_AIRTIME_OUI, + IEEE80211_MESHCONF_APSMI_AIRTIME_VALUE, "AIRTIME"); + printf(" CCMI:"); + MATCHOUI(mconf->conf_ccmi, IEEE80211_MESHCONF_CCMI_DEFAULT_OUI, + IEEE80211_MESHCONF_CCMI_DEFAULT_VALUE, "DEFAULT"); + MATCHOUI(mconf->conf_ccmi, IEEE80211_MESHCONF_CCMI_NULL_OUI, + IEEE80211_MESHCONF_CCMI_NULL_VALUE, "NULL"); + printf(" FORM:0x%x CAPS:0x%x", mconf->conf_finfo, + mconf->conf_cap); + printf(">"); + } +#undef MATCHOUI +} + static const char * wpa_cipher(const u_int8_t *sel) { @@ -2952,6 +2988,15 @@ printies(const u_int8_t *vp, int ielen, if (verbose) printhtinfo(" HTINFO", vp, 2+vp[1], maxcols); break; + case IEEE80211_ELEMID_MESHID: + if (verbose) + printssid(" MESHID", vp, 2+vp[1], maxcols); + break; + case IEEE80211_ELEMID_MESHCONF: + if (verbose) + printmeshconf(" MESHCONF", vp, 2+vp[1], + maxcols); + break; default: if (verbose) printie(iename(vp[0]), vp, 2+vp[1], maxcols); @@ -2980,7 +3025,7 @@ list_scan(int s) uint8_t buf[24*1024]; char ssid[IEEE80211_NWID_LEN+1]; const uint8_t *cp; - int len, ssidmax; + int len, ssidmax, idlen; if (get80211len(s, IEEE80211_IOC_SCAN_RESULTS, buf, sizeof(buf), &len) < 0) errx(1, "unable to get scan results"); @@ -2989,9 +3034,9 @@ list_scan(int s) getchaninfo(s); - ssidmax = verbose ? IEEE80211_NWID_LEN : 14; + ssidmax = verbose ? IEEE80211_NWID_LEN - 1 : 14; printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n" - , ssidmax, ssidmax, "SSID" + , ssidmax, ssidmax, "SSID/MESH ID" , "BSSID" , "CHAN" , "RATE" @@ -3002,13 +3047,20 @@ list_scan(int s) cp = buf; do { const struct ieee80211req_scan_result *sr; - const uint8_t *vp; + const uint8_t *vp, *idp; sr = (const struct ieee80211req_scan_result *) cp; vp = cp + sr->isr_ie_off; + if (sr->isr_meshid_len) { + idp = vp + sr->isr_ssid_len; + idlen = sr->isr_meshid_len; + } else { + idp = vp; + idlen = sr->isr_ssid_len; + } printf("%-*.*s %s %3d %3dM %3d:%-3d %3d %-4.4s" , ssidmax - , copy_essid(ssid, ssidmax, vp, sr->isr_ssid_len) + , copy_essid(ssid, ssidmax, idp, idlen) , ssid , ether_ntoa((const struct ether_addr *) sr->isr_bssid) , ieee80211_mhz2ieee(sr->isr_freq, sr->isr_flags) @@ -3017,7 +3069,8 @@ list_scan(int s) , sr->isr_intval , getcaps(sr->isr_capinfo) ); - printies(vp + sr->isr_ssid_len, sr->isr_ie_len, 24); + printies(vp + sr->isr_ssid_len + sr->isr_meshid_len, + sr->isr_ie_len, 24); printf("\n"); cp += sr->isr_len, len -= sr->isr_len; } while (len >= sizeof(struct ieee80211req_scan_result)); Modified: projects/mesh11s/sys/net80211/ieee80211_input.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_input.c Thu Apr 16 21:20:24 2009 (r191149) +++ projects/mesh11s/sys/net80211/ieee80211_input.c Thu Apr 16 21:50:17 2009 (r191150) @@ -479,6 +479,9 @@ ieee80211_parse_beacon(struct ieee80211_ * [tlv] HT capabilities * [tlv] HT information * [tlv] Atheros capabilities + * [tlv] Mesh ID + * [tlv] Mesh Configuration + * [tlv] Mesh TIM */ IEEE80211_VERIFY_LENGTH(efrm - frm, 12, return (scan->status = IEEE80211_BPARSE_BADIELEN)); @@ -551,6 +554,15 @@ ieee80211_parse_beacon(struct ieee80211_ case IEEE80211_ELEMID_HTINFO: scan->htinfo = frm; break; + case IEEE80211_ELEMID_MESHID: + scan->meshid = frm; + break; + case IEEE80211_ELEMID_MESHCONF: + scan->meshconf = frm; + break; + case IEEE80211_ELEMID_MESHTIM: + /* XXXRP TBD */ + break; case IEEE80211_ELEMID_VENDOR: if (iswpaoui(frm)) scan->wpa = frm; Modified: projects/mesh11s/sys/net80211/ieee80211_ioctl.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_ioctl.c Thu Apr 16 21:20:24 2009 (r191149) +++ projects/mesh11s/sys/net80211/ieee80211_ioctl.c Thu Apr 16 21:50:17 2009 (r191150) @@ -242,7 +242,8 @@ scan_space(const struct ieee80211_scan_e * packet is <3Kbytes so we are sure this doesn't overflow * 16-bits; if this is a concern we can drop the ie's. */ - len = sizeof(struct ieee80211req_scan_result) + se->se_ssid[1] + *ielen; + len = sizeof(struct ieee80211req_scan_result) + se->se_ssid[1] + + se->se_meshid[1] + *ielen; return roundup(len, sizeof(uint32_t)); } @@ -287,14 +288,19 @@ get_scan_result(void *arg, const struct memcpy(sr->isr_rates+nr, se->se_xrates+2, nxr); sr->isr_nrates = nr + nxr; + /* copy SSID */ sr->isr_ssid_len = se->se_ssid[1]; cp = ((uint8_t *)sr) + sr->isr_ie_off; memcpy(cp, se->se_ssid+2, sr->isr_ssid_len); - if (ielen) { - cp += sr->isr_ssid_len; + /* copy mesh id */ + cp += sr->isr_ssid_len; + sr->isr_meshid_len = se->se_meshid[1]; + memcpy(cp, se->se_meshid+2, sr->isr_meshid_len); + cp += sr->isr_meshid_len; + + if (ielen) memcpy(cp, se->se_ies.data, ielen); - } req->space -= len; req->sr = (struct ieee80211req_scan_result *)(((uint8_t *)sr) + len); Modified: projects/mesh11s/sys/net80211/ieee80211_ioctl.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_ioctl.h Thu Apr 16 21:20:24 2009 (r191149) +++ projects/mesh11s/sys/net80211/ieee80211_ioctl.h Thu Apr 16 21:50:17 2009 (r191150) @@ -716,7 +716,9 @@ struct ieee80211req_scan_result { uint8_t isr_nrates; uint8_t isr_rates[IEEE80211_RATE_MAXSIZE]; uint8_t isr_ssid_len; /* SSID length */ - /* variable length SSID followed by IE data */ + uint8_t isr_meshid_len; /* MESH ID length */ + /* variable length SSID, followed by variable length MESH ID, + followed by IE data */ }; /* Modified: projects/mesh11s/sys/net80211/ieee80211_scan.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_scan.h Thu Apr 16 21:20:24 2009 (r191149) +++ projects/mesh11s/sys/net80211/ieee80211_scan.h Thu Apr 16 21:50:17 2009 (r191150) @@ -210,6 +210,9 @@ struct ieee80211_scanparams { uint8_t *htinfo; uint8_t *ath; uint8_t *tdma; + uint8_t *meshid; + uint8_t *meshconf; + uint8_t *meshtim; }; /* @@ -239,6 +242,7 @@ struct ieee80211_scan_entry { int8_t se_rssi; /* avg'd recv ssi */ int8_t se_noise; /* noise floor */ uint8_t se_cc[2]; /* captured country code */ + uint8_t se_meshid[2+IEEE80211_NWID_LEN]; struct ieee80211_ies se_ies; /* captured ie's */ u_int se_age; /* age of entry (0 on create) */ }; Modified: projects/mesh11s/sys/net80211/ieee80211_scan_sta.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_scan_sta.c Thu Apr 16 21:20:24 2009 (r191149) +++ projects/mesh11s/sys/net80211/ieee80211_scan_sta.c Thu Apr 16 21:50:17 2009 (r191150) @@ -282,6 +282,8 @@ found: memcpy(ise->se_tstamp.data, sp->tstamp, sizeof(ise->se_tstamp)); ise->se_intval = sp->bintval; ise->se_capinfo = sp->capinfo; + if (sp->meshid != NULL && sp->meshid[1] != 0) + memcpy(ise->se_meshid, sp->meshid, 2+sp->meshid[1]); /* * Beware of overriding se_chan for frames seen * off-channel; this can cause us to attempt an
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904162150.n3GLoH6b092699>