iw: Scan: Add EHT beacon info support
PATCH v2 1/1 iw: Scan: Add EHT beacon info support
From: "Dylan E." <[email protected]>
Update and add to the old EHT beacon info implementation to print EHT PHY and MAC capabilities as well as MCS/NSS information for WiFi-7 beacons.
---
v2: Fix subject
info.c | 2 +- iw.h | 3 +- scan.c | 37 ++++++++++++++--- util.c | 127 +++++++++++++++++++++++++++++++++++---------------------- 4 files changed, 114 insertions(+), 55 deletions(-)
info.c +1 -1
@@ -390,7 +390,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg) tb_band[NL80211_BAND_ATTR_IFTYPE_DATA], rem_band) {print_he_info (nl_iftype); -print_eht_info (nl_iftype, last_band); +print_eht_info (nl_iftype); } }if (tb_band[NL80211_BAND_ATTR_FREQS ]) {
iw.h +2 -1
@@ -223,7 +223,8 @@ void print_ht_capability(__u16 cap);void print_vht_info (__u32 capa,const __u8 *mcs);void print_he_capability (const uint8_t *ie,int len);void print_he_info (struct nlattr *nl_iftype); -void print_eht_info (struct nlattr *nl_iftype,int band); +void print_eht_capability (const uint8_t *ie,int len,const __u16 *he_phy_cap); +void print_eht_info (struct nlattr *nl_iftype);void print_s1g_capability (const uint8_t *caps);char *channel_width_name (enum nl80211_chan_width width);
scan.c +32 -5
@@ -2384,12 +2384,40 @@ static void print_he_capa(const uint8_t type, uint8_t len, const uint8_t *data,print_he_capability (data, len); } +static void print_eht_capa (const uint8_t type,uint8_t len,const uint8_t *data, +const struct print_ies_data *ie_buffer) +{ +bool is_he = false; +const __u16 he_phy_cap[6 ] = {0 }; +unsigned char *ie = ie_buffer->ie; +int ielen = ie_buffer->ielen; + +while (ielen >=2 && ielen >= ie[1 ]) { +if (ie[0 ] ==255 && ie[2 ] ==35 ) { + is_he = true; +break ; + } + ielen -= ie[1 ] +2 ; + ie += ie[1 ] +2 ; + } + +if (is_he) { +memcpy (&((__u8 *)he_phy_cap)[0 ], + ie +9 ,12 ); + } + +printf ("\n" ); +print_eht_capability (data, len, he_phy_cap); +} +static const struct ie_print ext_printers[] = { [35 ] = {"HE capabilities" , print_he_capa,21 ,54 ,BIT (PRINT_SCAN ), }, + [108 ] = {"EHT capabilties" , print_eht_capa,13 ,30 ,BIT (PRINT_SCAN ), }, };static void print_extension (unsigned char len,unsigned char *ie, -bool unknown,enum print_ie_type ptype) +bool unknown,enum print_ie_type ptype, +const struct print_ies_data *ie_buffer) {unsigned char tag;
@@ -2401,7 +2429,7 @@ static void print_extension(unsigned char len, unsigned char *ie, tag = ie[0 ];if (tag <ARRAY_SIZE (ext_printers) && ext_printers[tag].name && ext_printers[tag].flags &BIT (ptype)) { -print_ie (&ext_printers[tag], tag, len -1 , ie +1 ,NULL ); +print_ie (&ext_printers[tag], tag, len -1 , ie +1 , ie_buffer);return ; }
@@ -2435,7 +2463,7 @@ void print_ies(unsigned char *ie, int ielen, bool unknown, }else if (ie[0 ] ==221 /* vendor */ ) {print_vendor (ie[1 ], ie +2 , unknown, ptype); }else if (ie[0 ] ==255 /* extension */ ) { -print_extension (ie[1 ], ie +2 , unknown, ptype); +print_extension (ie[1 ], ie +2 , unknown, ptype, &ie_buffer); }else if (unknown) {int i;
@@ -2639,8 +2667,7 @@ static int print_bss_handler(struct nl_msg *msg, void *arg) nla_len(ies)))))printf ("\tInformation elements from Probe Response " "frame:\n" ); -print_ies (nla_data (ies),nla_len (ies), - params->unknown, params->type); +print_ies (nla_data (ies),nla_len (ies), params->unknown, params->type); }if (bss[NL80211_BSS_BEACON_IES ] && show--) {printf ("\tInformation elements from Beacon frame:\n" );
util.c +79 -48
202 lines not on this page · raw message
Signature · 1 line
2.44.0
Hi,
Sorry this took forever to bubble up on my list again ...
Quoted 11 lines
scan.c +11
-0+static void print_eht_capa (const uint8_t type,uint8_t len,const uint8_t *data, +const struct print_ies_data *ie_buffer) +{ +bool is_he = false; +const __u16 he_phy_cap[6 ] = {0 }; +unsigned char *ie = ie_buffer->ie; +int ielen = ie_buffer->ielen; + +while (ielen >=2 && ielen >= ie[1 ]) { +if (ie[0 ] ==255 && ie[2 ] ==35 ) { + is_he = true;
scan.c static void print_he_capa(const uint8_t type, uint8_t len, const uint8_t *data, · line 2407
Quoted 10 lines
scan.c +10
-0+break ; + } + ielen -= ie[1 ] +2 ; + ie += ie[1 ] +2 ; + } + +if (is_he) { +memcpy (&((__u8 *)he_phy_cap)[0 ], + ie +9 ,12 ); + }
Hm, at the very least, that could be a helper; at first I was wondering what you even did there :)
Also, even if I see that this exists in print_capabilities(), I'm really not convinced this is a good idea. In the print_capabilities() case it should probably just print max A-MSDU anyway (or "(reserved for non- VHT)" with it perhaps). Either way, we end up double-parsing this which isn't great...
Also, you go to great lengths to get it, and then comment out the usage of it below?
Not really sure what we should do instead - perhaps more 'elems' style parsing like mac80211 does, and then print that way. Clearly we can't simply iterate any more.
scan.c static int print_bss_handler(struct nl_msg *msg, void *arg) · line 2670
Quoted 7 lines
scan.c +1
-2@@ -2639,8 +2667,7 @@ static int print_bss_handler(struct nl_msg *msg, void *arg) nla_len(ies)))))printf ("\tInformation elements from Probe Response " "frame:\n" ); -print_ies (nla_data (ies),nla_len (ies), - params->unknown, params->type); +print_ies (nla_data (ies),nla_len (ies), params->unknown, params->type);
why?
util.c static void __print_eht_capa(int band, · line 1614
Quoted 2 lines
util.c +1
-1-if (!(he_phy_cap[0 ] & ((BIT (2 ) |BIT (3 ) |BIT (4 )) <<8 ))){ +/*if (!(he_phy_cap[0] & ((BIT(2) | BIT(3) | BIT(4)) << 8))){
Don't leave commented out stuff.
johannes