Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/ifieee80211.c
Show First 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Given the channel at index i with attributes from, | * Given the channel at index i with attributes from, | ||||
* check if there is a channel with attributes to in | * check if there is a channel with attributes to in | ||||
* the channel table. With suitable attributes this | * the channel table. With suitable attributes this | ||||
* allows the caller to look for promotion; e.g. from | * allows the caller to look for promotion; e.g. from | ||||
* 11b > 11g. | * 11b > 11g. | ||||
*/ | */ | ||||
static int | static int | ||||
canpromote(int i, int from, int to) | canpromote(unsigned int i, uint32_t from, uint32_t to) | ||||
{ | { | ||||
const struct ieee80211_channel *fc = &chaninfo->ic_chans[i]; | const struct ieee80211_channel *fc = &chaninfo->ic_chans[i]; | ||||
u_int j; | u_int j; | ||||
if ((fc->ic_flags & from) != from) | if ((fc->ic_flags & from) != from) | ||||
return i; | return i; | ||||
/* NB: quick check exploiting ordering of chans w/ same frequency */ | /* NB: quick check exploiting ordering of chans w/ same frequency */ | ||||
if (i+1 < chaninfo->ic_nchans && | if (i+1 < chaninfo->ic_nchans && | ||||
Show All 20 Lines | |||||
* command line with a media request that constrains the available | * command line with a media request that constrains the available | ||||
* channe list (e.g. mode 11a); we want to honor that to avoid | * channe list (e.g. mode 11a); we want to honor that to avoid | ||||
* confusing behaviour. | * confusing behaviour. | ||||
*/ | */ | ||||
/* | /* | ||||
* XXX VHT | * XXX VHT | ||||
*/ | */ | ||||
static int | static int | ||||
promote(int i) | promote(unsigned int i) | ||||
{ | { | ||||
/* | /* | ||||
* Query the current mode of the interface in case it's | * Query the current mode of the interface in case it's | ||||
* constrained (e.g. to 11a). We must do this carefully | * constrained (e.g. to 11a). We must do this carefully | ||||
* as there may be a pending ifmedia request in which case | * as there may be a pending ifmedia request in which case | ||||
* asking the kernel will give us the wrong answer. This | * asking the kernel will give us the wrong answer. This | ||||
* is an unfortunate side-effect of the way ifconfig is | * is an unfortunate side-effect of the way ifconfig is | ||||
* structure for modularity (yech). | * structure for modularity (yech). | ||||
Show All 29 Lines | if (htconf & 2) { | ||||
i = canpromote(i, IEEE80211_CHAN_A, | i = canpromote(i, IEEE80211_CHAN_A, | ||||
IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U); | IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U); | ||||
} | } | ||||
} | } | ||||
return i; | return i; | ||||
} | } | ||||
static void | static void | ||||
mapfreq(struct ieee80211_channel *chan, int freq, int flags) | mapfreq(struct ieee80211_channel *chan, uint16_t freq, unsigned int flags) | ||||
{ | { | ||||
u_int i; | u_int i; | ||||
for (i = 0; i < chaninfo->ic_nchans; i++) { | for (i = 0; i < chaninfo->ic_nchans; i++) { | ||||
const struct ieee80211_channel *c = &chaninfo->ic_chans[i]; | const struct ieee80211_channel *c = &chaninfo->ic_chans[i]; | ||||
if (c->ic_freq == freq && (c->ic_flags & flags) == flags) { | if (c->ic_freq == freq && (c->ic_flags & flags) == flags) { | ||||
if (flags == 0) { | if (flags == 0) { | ||||
/* when ambiguous promote to ``best'' */ | /* when ambiguous promote to ``best'' */ | ||||
c = &chaninfo->ic_chans[promote(i)]; | c = &chaninfo->ic_chans[promote(i)]; | ||||
} | } | ||||
*chan = *c; | *chan = *c; | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
errx(1, "unknown/undefined frequency %u/0x%x", freq, flags); | errx(1, "unknown/undefined frequency %u/0x%x", freq, flags); | ||||
} | } | ||||
static void | static void | ||||
mapchan(struct ieee80211_channel *chan, int ieee, int flags) | mapchan(struct ieee80211_channel *chan, uint8_t ieee, unsigned int flags) | ||||
{ | { | ||||
u_int i; | u_int i; | ||||
for (i = 0; i < chaninfo->ic_nchans; i++) { | for (i = 0; i < chaninfo->ic_nchans; i++) { | ||||
const struct ieee80211_channel *c = &chaninfo->ic_chans[i]; | const struct ieee80211_channel *c = &chaninfo->ic_chans[i]; | ||||
if (c->ic_ieee == ieee && (c->ic_flags & flags) == flags) { | if (c->ic_ieee == ieee && (c->ic_flags & flags) == flags) { | ||||
if (flags == 0) { | if (flags == 0) { | ||||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | |||||
* freq:mode channel mode (a,b,g,h,n,t,s,d) | * freq:mode channel mode (a,b,g,h,n,t,s,d) | ||||
* | * | ||||
* These can be combined in either order; e.g. 2437:ng/40. | * These can be combined in either order; e.g. 2437:ng/40. | ||||
* Modes are case insensitive. | * Modes are case insensitive. | ||||
* | * | ||||
* The result is not validated here; it's assumed to be | * The result is not validated here; it's assumed to be | ||||
* checked against the channel table fetched from the kernel. | * checked against the channel table fetched from the kernel. | ||||
*/ | */ | ||||
static int | static unsigned int | ||||
getchannelflags(const char *val, int freq) | getchannelflags(const char *val, int freq) | ||||
{ | { | ||||
#define _CHAN_HT 0x80000000 | #define _CHAN_HT 0x80000000 | ||||
const char *cp; | const char *cp; | ||||
int flags; | int flags; | ||||
int is_vht = 0; | int is_vht = 0; | ||||
flags = 0; | flags = 0; | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | #define _CHAN_HT 0x80000000 | ||||
} | } | ||||
return flags; | return flags; | ||||
#undef _CHAN_HT | #undef _CHAN_HT | ||||
} | } | ||||
static void | static void | ||||
getchannel(int s, struct ieee80211_channel *chan, const char *val) | getchannel(int s, struct ieee80211_channel *chan, const char *val) | ||||
{ | { | ||||
int v, flags; | unsigned int v, flags; | ||||
char *eptr; | char *eptr; | ||||
memset(chan, 0, sizeof(*chan)); | memset(chan, 0, sizeof(*chan)); | ||||
if (isanyarg(val)) { | if (isanyarg(val)) { | ||||
chan->ic_freq = IEEE80211_CHAN_ANY; | chan->ic_freq = IEEE80211_CHAN_ANY; | ||||
return; | return; | ||||
} | } | ||||
getchaninfo(s); | getchaninfo(s); | ||||
▲ Show 20 Lines • Show All 1,259 Lines • ▼ Show 20 Lines | for (i = 0; i < nchans; i++) { | ||||
if (c->ic_freq == freq && | if (c->ic_freq == freq && | ||||
(c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) | (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) | ||||
return c; | return c; | ||||
} | } | ||||
return NULL; | return NULL; | ||||
} | } | ||||
static int | static int | ||||
chanfind(const struct ieee80211_channel chans[], int nchans, int flags) | chanfind(const struct ieee80211_channel chans[], int nchans, unsigned int flags) | ||||
{ | { | ||||
int i; | for (int i = 0; i < nchans; i++) { | ||||
for (i = 0; i < nchans; i++) { | |||||
const struct ieee80211_channel *c = &chans[i]; | const struct ieee80211_channel *c = &chans[i]; | ||||
if ((c->ic_flags & flags) == flags) | if ((c->ic_flags & flags) == flags) | ||||
return 1; | return 1; | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 594 Lines • ▼ Show 20 Lines | if (flags & IEEE80211_NODE_UAPSD) | ||||
*cp++ = 'U'; | *cp++ = 'U'; | ||||
if (flags & IEEE80211_NODE_LDPC) | if (flags & IEEE80211_NODE_LDPC) | ||||
*cp++ = 'L'; | *cp++ = 'L'; | ||||
*cp = '\0'; | *cp = '\0'; | ||||
return flagstring; | return flagstring; | ||||
} | } | ||||
static void | static void | ||||
printie(const char* tag, const uint8_t *ie, size_t ielen, int maxlen) | printie(const char* tag, const uint8_t *ie, size_t ielen, unsigned int maxlen) | ||||
{ | { | ||||
printf("%s", tag); | printf("%s", tag); | ||||
if (verbose) { | if (verbose) { | ||||
maxlen -= strlen(tag)+2; | maxlen -= strlen(tag)+2; | ||||
if (2*ielen > maxlen) | if (2*ielen > maxlen) | ||||
maxlen--; | maxlen--; | ||||
printf("<"); | printf("<"); | ||||
for (; ielen > 0; ie++, ielen--) { | for (; ielen > 0; ie++, ielen--) { | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | static const char *txpwrmap[] = { | ||||
"20", | "20", | ||||
"40", | "40", | ||||
"80", | "80", | ||||
"160", | "160", | ||||
}; | }; | ||||
if (verbose) { | if (verbose) { | ||||
const struct ieee80211_ie_vht_txpwrenv *vhtpwr = | const struct ieee80211_ie_vht_txpwrenv *vhtpwr = | ||||
(const struct ieee80211_ie_vht_txpwrenv *) ie; | (const struct ieee80211_ie_vht_txpwrenv *) ie; | ||||
int i, n; | size_t i, n; | ||||
const char *sep = ""; | const char *sep = ""; | ||||
/* Get count; trim at ielen */ | /* Get count; trim at ielen */ | ||||
n = (vhtpwr->tx_info & | n = (vhtpwr->tx_info & | ||||
IEEE80211_VHT_TXPWRENV_INFO_COUNT_MASK) + 1; | IEEE80211_VHT_TXPWRENV_INFO_COUNT_MASK) + 1; | ||||
/* Trim at ielen */ | /* Trim at ielen */ | ||||
if (n > ielen - 3) | if (n + 3 > ielen) | ||||
n = ielen - 3; | n = ielen - 3; | ||||
printf("<tx_info 0x%02x pwr:[", vhtpwr->tx_info); | printf("<tx_info 0x%02x pwr:[", vhtpwr->tx_info); | ||||
for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
printf("%s%s:%.2f", sep, txpwrmap[i], | printf("%s%s:%.2f", sep, txpwrmap[i], | ||||
((float) ((int8_t) ie[i+3])) / 2.0); | ((float) ((int8_t) ie[i+3])) / 2.0); | ||||
sep = " "; | sep = " "; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
printapchanrep(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) | printapchanrep(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) | ||||
{ | { | ||||
printf("%s", tag); | printf("%s", tag); | ||||
if (verbose) { | if (verbose) { | ||||
const struct ieee80211_ap_chan_report_ie *ap = | const struct ieee80211_ap_chan_report_ie *ap = | ||||
(const struct ieee80211_ap_chan_report_ie *) ie; | (const struct ieee80211_ap_chan_report_ie *) ie; | ||||
const char *sep = ""; | const char *sep = ""; | ||||
int i; | |||||
printf("<class %u, chan:[", ap->i_class); | printf("<class %u, chan:[", ap->i_class); | ||||
for (i = 3; i < ielen; i++) { | for (size_t i = 3; i < ielen; i++) { | ||||
printf("%s%u", sep, ie[i]); | printf("%s%u", sep, ie[i]); | ||||
sep = ","; | sep = ","; | ||||
} | } | ||||
printf("]>"); | printf("]>"); | ||||
} | } | ||||
} | } | ||||
static const char * | static const char * | ||||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | while (len) { | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case IEEE80211_WPS_ATTR_DEV_NAME: | case IEEE80211_WPS_ATTR_DEV_NAME: | ||||
printf(" device_name:<%.*s>", tlv_len, ie); | printf(" device_name:<%.*s>", tlv_len, ie); | ||||
break; | break; | ||||
case IEEE80211_WPS_ATTR_DEV_PASSWORD_ID: | case IEEE80211_WPS_ATTR_DEV_PASSWORD_ID: | ||||
n = LE_READ_2(ie); | n = LE_READ_2(ie); | ||||
if (n < nitems(dev_pass_id)) | if (n < (int)nitems(dev_pass_id)) | ||||
printf(" dpi:%s", dev_pass_id[n]); | printf(" dpi:%s", dev_pass_id[n]); | ||||
break; | break; | ||||
case IEEE80211_WPS_ATTR_MANUFACTURER: | case IEEE80211_WPS_ATTR_MANUFACTURER: | ||||
printf(" manufacturer:<%.*s>", tlv_len, ie); | printf(" manufacturer:<%.*s>", tlv_len, ie); | ||||
break; | break; | ||||
case IEEE80211_WPS_ATTR_MODEL_NAME: | case IEEE80211_WPS_ATTR_MODEL_NAME: | ||||
printf(" model_name:<%.*s>", tlv_len, ie); | printf(" model_name:<%.*s>", tlv_len, ie); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | printssid(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) | ||||
printf("%s<%.*s>", tag, copy_essid(ssid, maxlen, ie+2, ie[1]), ssid); | printf("%s<%.*s>", tag, copy_essid(ssid, maxlen, ie+2, ie[1]), ssid); | ||||
} | } | ||||
static void | static void | ||||
printrates(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) | printrates(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) | ||||
{ | { | ||||
const char *sep; | const char *sep; | ||||
int i; | |||||
printf("%s", tag); | printf("%s", tag); | ||||
sep = "<"; | sep = "<"; | ||||
for (i = 2; i < ielen; i++) { | for (size_t i = 2; i < ielen; i++) { | ||||
printf("%s%s%d", sep, | printf("%s%s%d", sep, | ||||
ie[i] & IEEE80211_RATE_BASIC ? "B" : "", | ie[i] & IEEE80211_RATE_BASIC ? "B" : "", | ||||
ie[i] & IEEE80211_RATE_VAL); | ie[i] & IEEE80211_RATE_VAL); | ||||
sep = ","; | sep = ","; | ||||
} | } | ||||
printf(">"); | printf(">"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | iename(int elemid) | ||||
case IEEE80211_ELEMID_EXTCAP: return " EXTCAP"; | case IEEE80211_ELEMID_EXTCAP: return " EXTCAP"; | ||||
} | } | ||||
snprintf(iename_buf, sizeof(iename_buf), " UNKNOWN_ELEMID_%d", | snprintf(iename_buf, sizeof(iename_buf), " UNKNOWN_ELEMID_%d", | ||||
elemid); | elemid); | ||||
return (const char *) iename_buf; | return (const char *) iename_buf; | ||||
} | } | ||||
static void | static void | ||||
printies(const u_int8_t *vp, int ielen, int maxcols) | printies(const u_int8_t *vp, int ielen, unsigned int maxcols) | ||||
{ | { | ||||
while (ielen > 0) { | while (ielen > 0) { | ||||
switch (vp[0]) { | switch (vp[0]) { | ||||
case IEEE80211_ELEMID_SSID: | case IEEE80211_ELEMID_SSID: | ||||
if (verbose) | if (verbose) | ||||
printssid(" SSID", vp, 2+vp[1], maxcols); | printssid(" SSID", vp, 2+vp[1], maxcols); | ||||
break; | break; | ||||
case IEEE80211_ELEMID_RATES: | case IEEE80211_ELEMID_RATES: | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
uint8_t buf[24*1024]; | uint8_t buf[24*1024]; | ||||
char ssid[IEEE80211_NWID_LEN+1]; | char ssid[IEEE80211_NWID_LEN+1]; | ||||
const uint8_t *cp; | const uint8_t *cp; | ||||
int len, idlen; | int len, idlen; | ||||
if (get80211len(s, IEEE80211_IOC_SCAN_RESULTS, buf, sizeof(buf), &len) < 0) | if (get80211len(s, IEEE80211_IOC_SCAN_RESULTS, buf, sizeof(buf), &len) < 0) | ||||
errx(1, "unable to get scan results"); | errx(1, "unable to get scan results"); | ||||
if (len < sizeof(struct ieee80211req_scan_result)) | if (len < (int)sizeof(struct ieee80211req_scan_result)) | ||||
return; | return; | ||||
getchaninfo(s); | getchaninfo(s); | ||||
printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n" | printf("%-*.*s %-17.17s %4s %4s %-7s %3s %4s\n" | ||||
, IEEE80211_NWID_LEN, IEEE80211_NWID_LEN, "SSID/MESH ID" | , IEEE80211_NWID_LEN, IEEE80211_NWID_LEN, "SSID/MESH ID" | ||||
, "BSSID" | , "BSSID" | ||||
, "CHAN" | , "CHAN" | ||||
, "RATE" | , "RATE" | ||||
, " S:N" | , " S:N" | ||||
, "INT" | , "INT" | ||||
, "CAPS" | , "CAPS" | ||||
); | ); | ||||
cp = buf; | cp = buf; | ||||
do { | do { | ||||
const struct ieee80211req_scan_result *sr; | const struct ieee80211req_scan_result *sr; | ||||
const uint8_t *vp, *idp; | const uint8_t *vp, *idp; | ||||
sr = (const struct ieee80211req_scan_result *) cp; | sr = (const struct ieee80211req_scan_result *)(const void *) cp; | ||||
vp = cp + sr->isr_ie_off; | vp = cp + sr->isr_ie_off; | ||||
if (sr->isr_meshid_len) { | if (sr->isr_meshid_len) { | ||||
idp = vp + sr->isr_ssid_len; | idp = vp + sr->isr_ssid_len; | ||||
idlen = sr->isr_meshid_len; | idlen = sr->isr_meshid_len; | ||||
} else { | } else { | ||||
idp = vp; | idp = vp; | ||||
idlen = sr->isr_ssid_len; | idlen = sr->isr_ssid_len; | ||||
} | } | ||||
printf("%-*.*s %s %3d %3dM %4d:%-4d %4d %-4.4s" | printf("%-*.*s %s %3d %3dM %4d:%-4d %4d %-4.4s" | ||||
, IEEE80211_NWID_LEN | , IEEE80211_NWID_LEN | ||||
, copy_essid(ssid, IEEE80211_NWID_LEN, idp, idlen) | , copy_essid(ssid, IEEE80211_NWID_LEN, idp, idlen) | ||||
, ssid | , ssid | ||||
, ether_ntoa((const struct ether_addr *) sr->isr_bssid) | , ether_ntoa((const struct ether_addr *) sr->isr_bssid) | ||||
, ieee80211_mhz2ieee(sr->isr_freq, sr->isr_flags) | , ieee80211_mhz2ieee(sr->isr_freq, sr->isr_flags) | ||||
, getmaxrate(sr->isr_rates, sr->isr_nrates) | , getmaxrate(sr->isr_rates, sr->isr_nrates) | ||||
, (sr->isr_rssi/2)+sr->isr_noise, sr->isr_noise | , (sr->isr_rssi/2)+sr->isr_noise, sr->isr_noise | ||||
, sr->isr_intval | , sr->isr_intval | ||||
, getcaps(sr->isr_capinfo) | , getcaps(sr->isr_capinfo) | ||||
); | ); | ||||
printies(vp + sr->isr_ssid_len + sr->isr_meshid_len, | printies(vp + sr->isr_ssid_len + sr->isr_meshid_len, | ||||
sr->isr_ie_len, 24); | sr->isr_ie_len, 24); | ||||
printbssidname((const struct ether_addr *)sr->isr_bssid); | printbssidname((const struct ether_addr *)sr->isr_bssid); | ||||
printf("\n"); | printf("\n"); | ||||
cp += sr->isr_len, len -= sr->isr_len; | cp += sr->isr_len, len -= sr->isr_len; | ||||
} while (len >= sizeof(struct ieee80211req_scan_result)); | } while (len >= (int)sizeof(struct ieee80211req_scan_result)); | ||||
} | } | ||||
static void | static void | ||||
scan_and_wait(int s) | scan_and_wait(int s) | ||||
{ | { | ||||
struct ieee80211_scan_req sr; | struct ieee80211_scan_req sr; | ||||
struct ieee80211req ireq; | struct ieee80211req ireq; | ||||
int sroute; | int sroute; | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | for (i = 0; i < IEEE80211_TID_SIZE; i++) | ||||
if (si->isi_txseqs[i] > txseq) | if (si->isi_txseqs[i] > txseq) | ||||
txseq = si->isi_txseqs[i]; | txseq = si->isi_txseqs[i]; | ||||
return txseq; | return txseq; | ||||
} | } | ||||
static int | static int | ||||
getrxseq(const struct ieee80211req_sta_info *si) | getrxseq(const struct ieee80211req_sta_info *si) | ||||
{ | { | ||||
int i, rxseq; | int rxseq; | ||||
if ((si->isi_state & IEEE80211_NODE_QOS) == 0) | if ((si->isi_state & IEEE80211_NODE_QOS) == 0) | ||||
return si->isi_rxseqs[0]; | return si->isi_rxseqs[0]; | ||||
/* XXX not right but usually what folks want */ | /* XXX not right but usually what folks want */ | ||||
rxseq = 0; | rxseq = 0; | ||||
for (i = 0; i < IEEE80211_TID_SIZE; i++) | for (unsigned int i = 0; i < IEEE80211_TID_SIZE; i++) | ||||
if (si->isi_rxseqs[i] > rxseq) | if (si->isi_rxseqs[i] > rxseq) | ||||
rxseq = si->isi_rxseqs[i]; | rxseq = si->isi_rxseqs[i]; | ||||
return rxseq; | return rxseq; | ||||
} | } | ||||
static void | static void | ||||
list_stations(int s) | list_stations(int s) | ||||
{ | { | ||||
Show All 11 Lines | if (opmode == IEEE80211_M_STA) { | ||||
/* | /* | ||||
* Get information about the associated AP. | * Get information about the associated AP. | ||||
*/ | */ | ||||
(void) get80211(s, IEEE80211_IOC_BSSID, | (void) get80211(s, IEEE80211_IOC_BSSID, | ||||
u.req.is_u.macaddr, IEEE80211_ADDR_LEN); | u.req.is_u.macaddr, IEEE80211_ADDR_LEN); | ||||
} | } | ||||
if (get80211len(s, IEEE80211_IOC_STA_INFO, &u, sizeof(u), &len) < 0) | if (get80211len(s, IEEE80211_IOC_STA_INFO, &u, sizeof(u), &len) < 0) | ||||
errx(1, "unable to get station information"); | errx(1, "unable to get station information"); | ||||
if (len < sizeof(struct ieee80211req_sta_info)) | if (len < (int)sizeof(struct ieee80211req_sta_info)) | ||||
return; | return; | ||||
getchaninfo(s); | getchaninfo(s); | ||||
if (opmode == IEEE80211_M_MBSS) | if (opmode == IEEE80211_M_MBSS) | ||||
printf("%-17.17s %4s %5s %5s %7s %4s %4s %4s %6s %6s\n" | printf("%-17.17s %4s %5s %5s %7s %4s %4s %4s %6s %6s\n" | ||||
, "ADDR" | , "ADDR" | ||||
, "CHAN" | , "CHAN" | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | else | ||||
, getrxseq(si) | , getrxseq(si) | ||||
, getcaps(si->isi_capinfo) | , getcaps(si->isi_capinfo) | ||||
, getflags(si->isi_state) | , getflags(si->isi_state) | ||||
); | ); | ||||
printies(cp + si->isi_ie_off, si->isi_ie_len, 24); | printies(cp + si->isi_ie_off, si->isi_ie_len, 24); | ||||
printmimo(&si->isi_mimo); | printmimo(&si->isi_mimo); | ||||
printf("\n"); | printf("\n"); | ||||
cp += si->isi_len, len -= si->isi_len; | cp += si->isi_len, len -= si->isi_len; | ||||
} while (len >= sizeof(struct ieee80211req_sta_info)); | } while (len >= (int)sizeof(struct ieee80211req_sta_info)); | ||||
} | } | ||||
static const char * | static const char * | ||||
mesh_linkstate_string(uint8_t state) | mesh_linkstate_string(uint8_t state) | ||||
{ | { | ||||
static const char *state_names[] = { | static const char *state_names[] = { | ||||
[0] = "IDLE", | [0] = "IDLE", | ||||
[1] = "OPEN-TX", | [1] = "OPEN-TX", | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
print_channels(int s, const struct ieee80211req_chaninfo *chans, | print_channels(int s, const struct ieee80211req_chaninfo *chans, | ||||
int allchans, int verb) | int allchans, int verb) | ||||
{ | { | ||||
struct ieee80211req_chaninfo *achans; | struct ieee80211req_chaninfo *achans; | ||||
uint8_t reported[IEEE80211_CHAN_BYTES]; | uint8_t reported[IEEE80211_CHAN_BYTES]; | ||||
const struct ieee80211_channel *c; | const struct ieee80211_channel *c; | ||||
int i, half; | unsigned int i, half; | ||||
achans = malloc(IEEE80211_CHANINFO_SPACE(chans)); | achans = malloc(IEEE80211_CHANINFO_SPACE(chans)); | ||||
if (achans == NULL) | if (achans == NULL) | ||||
errx(1, "no space for active channel list"); | errx(1, "no space for active channel list"); | ||||
achans->ic_nchans = 0; | achans->ic_nchans = 0; | ||||
memset(reported, 0, sizeof(reported)); | memset(reported, 0, sizeof(reported)); | ||||
if (!allchans) { | if (!allchans) { | ||||
struct ieee80211req_chanlist active; | struct ieee80211req_chanlist active; | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
list_txpow(int s) | list_txpow(int s) | ||||
{ | { | ||||
struct ieee80211req_chaninfo *achans; | struct ieee80211req_chaninfo *achans; | ||||
uint8_t reported[IEEE80211_CHAN_BYTES]; | uint8_t reported[IEEE80211_CHAN_BYTES]; | ||||
struct ieee80211_channel *c, *prev; | struct ieee80211_channel *c, *prev; | ||||
int i, half; | unsigned int i, half; | ||||
getchaninfo(s); | getchaninfo(s); | ||||
achans = malloc(IEEE80211_CHANINFO_SPACE(chaninfo)); | achans = malloc(IEEE80211_CHANINFO_SPACE(chaninfo)); | ||||
if (achans == NULL) | if (achans == NULL) | ||||
errx(1, "no space for active channel list"); | errx(1, "no space for active channel list"); | ||||
achans->ic_nchans = 0; | achans->ic_nchans = 0; | ||||
memset(reported, 0, sizeof(reported)); | memset(reported, 0, sizeof(reported)); | ||||
for (i = 0; i < chaninfo->ic_nchans; i++) { | for (i = 0; i < chaninfo->ic_nchans; i++) { | ||||
▲ Show 20 Lines • Show All 404 Lines • ▼ Show 20 Lines | printf("%-17.17s %-17.17s %4s %4s %4s %6s %s\n" | ||||
, "DEST" | , "DEST" | ||||
, "NEXT HOP" | , "NEXT HOP" | ||||
, "HOPS" | , "HOPS" | ||||
, "METRIC" | , "METRIC" | ||||
, "LIFETIME" | , "LIFETIME" | ||||
, "MSEQ" | , "MSEQ" | ||||
, "FLAGS"); | , "FLAGS"); | ||||
for (rt = &routes[0]; rt - &routes[0] < ireq.i_len / sizeof(*rt); rt++){ | for (unsigned int i = 0; i < ireq.i_len / sizeof(*rt); i++) { | ||||
rt = &routes[i]; | |||||
printf("%s ", | printf("%s ", | ||||
ether_ntoa((const struct ether_addr *)rt->imr_dest)); | ether_ntoa((const struct ether_addr *)rt->imr_dest)); | ||||
printf("%s %4u %4u %6u %6u %c%c\n", | printf("%s %4u %4u %6u %6u %c%c\n", | ||||
ether_ntoa((const struct ether_addr *)rt->imr_nexthop), | ether_ntoa((const struct ether_addr *)rt->imr_nexthop), | ||||
rt->imr_nhops, rt->imr_metric, rt->imr_lifetime, | rt->imr_nhops, rt->imr_metric, rt->imr_lifetime, | ||||
rt->imr_lastmseq, | rt->imr_lastmseq, | ||||
(rt->imr_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) ? | (rt->imr_flags & IEEE80211_MESHRT_FLAGS_DISCOVER) ? | ||||
'D' : | 'D' : | ||||
▲ Show 20 Lines • Show All 1,439 Lines • ▼ Show 20 Lines | static struct afswtch af_ieee80211 = { | ||||
.af_name = "af_ieee80211", | .af_name = "af_ieee80211", | ||||
.af_af = AF_UNSPEC, | .af_af = AF_UNSPEC, | ||||
.af_other_status = ieee80211_status, | .af_other_status = ieee80211_status, | ||||
}; | }; | ||||
static __constructor void | static __constructor void | ||||
ieee80211_ctor(void) | ieee80211_ctor(void) | ||||
{ | { | ||||
int i; | for (size_t i = 0; i < nitems(ieee80211_cmds); i++) | ||||
for (i = 0; i < nitems(ieee80211_cmds); i++) | |||||
cmd_register(&ieee80211_cmds[i]); | cmd_register(&ieee80211_cmds[i]); | ||||
af_register(&af_ieee80211); | af_register(&af_ieee80211); | ||||
clone_setdefcallback_prefix("wlan", wlan_create); | clone_setdefcallback_prefix("wlan", wlan_create); | ||||
} | } |