Date: Sun, 10 Jun 2007 00:24:28 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 121312 for review Message-ID: <200706100024.l5A0OSFe071951@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=121312 Change 121312 by sam@sam_laptop on 2007/06/10 00:23:48 change get sta info and get scan results ioctl's to include the offset to the variable length data in each record so user applications no longer are wed to structure sizes; this permits us to grow these data structures while still maintain backwards compatibility Affected files ... .. //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#68 edit .. //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#80 edit .. //depot/projects/wifi/sys/net80211/ieee80211_ioctl.h#41 edit .. //depot/projects/wifi/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c#7 edit Differences ... ==== //depot/projects/wifi/sbin/ifconfig/ifieee80211.c#68 (text+ko) ==== @@ -1018,7 +1018,7 @@ } static int -getmaxrate(uint8_t rates[15], uint8_t nrates) +getmaxrate(const uint8_t rates[15], uint8_t nrates) { int i, maxrate = -1; @@ -1488,11 +1488,11 @@ ); cp = buf; do { - struct ieee80211req_scan_result *sr; - uint8_t *vp; + const struct ieee80211req_scan_result *sr; + const uint8_t *vp; - sr = (struct ieee80211req_scan_result *) cp; - vp = (u_int8_t *)(sr+1); + sr = (const struct ieee80211req_scan_result *) cp; + vp = ((const u_int8_t *)sr) + sr->isr_ie_off; printf("%-*.*s %s %3d %3dM %3d:%-3d %3d %-4.4s" , ssidmax , copy_essid(ssid, ssidmax, vp, sr->isr_ssid_len) @@ -1504,7 +1504,7 @@ , 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_ie_len, 24); printf("\n"); cp += sr->isr_len, len -= sr->isr_len; } while (len >= sizeof(struct ieee80211req_scan_result)); @@ -1565,7 +1565,7 @@ } u; enum ieee80211_opmode opmode = get80211opmode(s); struct ieee80211req ireq; - uint8_t *cp; + const uint8_t *cp; int len; (void) memset(&ireq, 0, sizeof(ireq)); @@ -1604,15 +1604,13 @@ , "CAPS" , "FLAG" ); - cp = (uint8_t *) u.req.info; + cp = (const uint8_t *) u.req.info; do { - struct ieee80211req_sta_info *si; - uint8_t *vp; + const struct ieee80211req_sta_info *si; - si = (struct ieee80211req_sta_info *) cp; + si = (const struct ieee80211req_sta_info *) cp; if (si->isi_len < sizeof(*si)) break; - vp = (u_int8_t *)(si+1); printf("%s %4u %4d %3dM %3.1f %4d %6d %6d %-4.4s %-4.4s" , ether_ntoa((const struct ether_addr*) si->isi_macaddr) , IEEE80211_AID(si->isi_associd) @@ -1625,7 +1623,7 @@ , getcaps(si->isi_capinfo) , getflags(si->isi_state) ); - printies(vp, si->isi_ie_len, 24); + printies(cp + si->isi_ie_off, si->isi_ie_len, 24); printf("\n"); cp += si->isi_len, len -= si->isi_len; } while (len >= sizeof(struct ieee80211req_sta_info)); ==== //depot/projects/wifi/sys/net80211/ieee80211_ioctl.c#80 (text+ko) ==== @@ -430,7 +430,7 @@ sr = req->sr; KASSERT(len <= 65535 && ielen <= 65535, ("len %u ssid %u ie %u", len, se->se_ssid[1], ielen)); - sr->isr_ssid_len = se->se_ssid[1]; + sr->isr_ie_off = sizeof(struct ieee80211req_scan_result); sr->isr_ie_len = ielen; sr->isr_len = len; sr->isr_freq = se->se_chan->ic_freq; @@ -447,10 +447,12 @@ memcpy(sr->isr_rates+nr, se->se_xrates+2, nxr); sr->isr_nrates = nr + nxr; - cp = (uint8_t *)(sr+1); + 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); - cp += sr->isr_ssid_len; - if (sr->isr_ie_len) { + + if (ielen) { + cp += sr->isr_ssid_len; cp = copyie(cp, se->se_wpa_ie); cp = copyie(cp, se->se_rsn_ie); cp = copyie(cp, se->se_wme_ie); @@ -550,6 +552,7 @@ return; si = req->si; si->isi_len = len; + si->isi_ie_off = sizeof(struct ieee80211req_sta_info); si->isi_ie_len = ielen; si->isi_freq = ni->ni_chan->ic_freq; si->isi_flags = ni->ni_chan->ic_flags; @@ -585,11 +588,13 @@ si->isi_inact = ic->ic_inact_init; si->isi_inact = (si->isi_inact - ni->ni_inact) * IEEE80211_INACT_WAIT; - cp = (uint8_t *)(si+1); - cp = copyie(cp, ni->ni_wpa_ie); - cp = copyie(cp, ni->ni_rsn_ie); - cp = copyie(cp, ni->ni_wme_ie); - cp = copyie(cp, ni->ni_ath_ie); + if (ielen) { + cp = ((uint8_t *)si) + si->isi_ie_off; + cp = copyie(cp, ni->ni_wpa_ie); + cp = copyie(cp, ni->ni_rsn_ie); + cp = copyie(cp, ni->ni_wme_ie); + cp = copyie(cp, ni->ni_ath_ie); + } req->si = (struct ieee80211req_sta_info *)(((uint8_t *)si) + len); req->space -= len; ==== //depot/projects/wifi/sys/net80211/ieee80211_ioctl.h#41 (text+ko) ==== @@ -318,6 +318,8 @@ */ struct ieee80211req_sta_info { uint16_t isi_len; /* length (mult of 4) */ + uint16_t isi_ie_off; /* offset to IE data */ + uint16_t isi_ie_len; /* IE length */ uint16_t isi_freq; /* MHz */ uint16_t isi_flags; /* channel flags */ uint16_t isi_state; /* state flags */ @@ -331,7 +333,6 @@ /* negotiated rates */ uint8_t isi_rates[IEEE80211_RATE_MAXSIZE]; uint8_t isi_txrate; /* index to isi_rates[] */ - uint16_t isi_ie_len; /* IE length */ uint16_t isi_associd; /* assoc response */ uint16_t isi_txpower; /* current tx power */ uint16_t isi_vlan; /* vlan tag */ @@ -501,6 +502,7 @@ */ struct ieee80211req_scan_result { uint16_t isr_len; /* length (mult of 4) */ + uint16_t isr_ie_off; /* offset to IE data */ uint16_t isr_ie_len; /* IE length */ uint16_t isr_freq; /* MHz */ uint16_t isr_flags; /* channel flags */ @@ -513,7 +515,6 @@ uint8_t isr_nrates; uint8_t isr_rates[IEEE80211_RATE_MAXSIZE]; uint8_t isr_ssid_len; /* SSID length */ - uint8_t isr_pad[8]; /* variable length SSID followed by IE data */ }; ==== //depot/projects/wifi/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c#7 (text+ko) ==== @@ -587,7 +587,7 @@ } static int -getmaxrate(uint8_t rates[15], uint8_t nrates) +getmaxrate(const uint8_t rates[15], uint8_t nrates) { int i, maxrate = -1; @@ -621,8 +621,8 @@ #define min(a,b) ((a)>(b)?(b):(a)) struct wpa_driver_bsd_data *drv = priv; uint8_t buf[24*1024]; - uint8_t *cp, *vp; - struct ieee80211req_scan_result *sr; + const uint8_t *cp, *vp; + const struct ieee80211req_scan_result *sr; struct wpa_scan_result *wsr; int len, ielen; @@ -634,7 +634,7 @@ cp = buf; wsr = results; while (len >= sizeof(struct ieee80211req_scan_result)) { - sr = (struct ieee80211req_scan_result *) cp; + sr = (const struct ieee80211req_scan_result *) cp; memcpy(wsr->bssid, sr->isr_bssid, IEEE80211_ADDR_LEN); wsr->ssid_len = sr->isr_ssid_len; wsr->freq = sr->isr_freq; @@ -643,7 +643,7 @@ wsr->level = 0; /* XXX? */ wsr->caps = sr->isr_capinfo; wsr->maxrate = getmaxrate(sr->isr_rates, sr->isr_nrates); - vp = (u_int8_t *)(sr+1); + vp = ((u_int8_t *)sr) + sr->isr_ie_off; memcpy(wsr->ssid, vp, sr->isr_ssid_len); if (sr->isr_ie_len > 0) { vp += sr->isr_ssid_len;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706100024.l5A0OSFe071951>