diff mbox series

iw: scan: Improved handling of Country String environment values

Message ID 1670e04b-9d61-4778-9d7d-e0d1c2ebb5f8@aegrel.ee
State New
Headers show
Series iw: scan: Improved handling of Country String environment values | expand

Commit Message

Taavi Eomäe Aug. 9, 2024, 7:20 p.m. UTC
The third octet in Country String (dot11CountryString) can be a reference
to one of the tables defined in IEEE 802.11 Annex E. The hexadecimal value
directly corresponds to a table with the same number.

Also added handling for non-country entity and hexadecimal printout of all
values for enhanced clarity.

Signed-off-by: Taavi Eomäe <taaviw@aegrel.ee>

---
  scan.c | 18 ++++++++++++++++--
  1 file changed, 16 insertions(+), 2 deletions(-)

      data += 3;
      len -= 3;

Comments

Johannes Berg Aug. 28, 2024, 11:28 a.m. UTC | #1
Hi,

Couple of comments:

On Fri, 2024-08-09 at 22:20 +0300, Taavi Eomäe wrote:
> The third octet in Country String (dot11CountryString) can be a reference
> to one of the tables defined in IEEE 802.11 Annex E. The hexadecimal value
> directly corresponds to a table with the same number.
> 
> Also added handling for non-country entity and hexadecimal printout of all
> values for enhanced clarity.

First off, the subject and commit message should be written in
imperative voice, "improve handling", "add handling", etc.



> 
> Signed-off-by: Taavi Eomäe <taaviw@aegrel.ee>
> 
> ---
>   scan.c | 18 ++++++++++++++++--
>   1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/scan.c b/scan.c
> index faf406d..85798b8 100644
> --- a/scan.c
> +++ b/scan.c
> @@ -661,10 +661,24 @@ static const char *country_env_str(char environment)
>           return "Indoor only";
>       case 'O':
>           return "Outdoor only";
> +    case 'X':
> +        return "Non-country";

Please follow existing coding style with tabs. Or maybe your email
client just mangled it?

> 
> @@ -673,7 +687,7 @@ static void print_country(const uint8_t type, 
> uint8_t len, const uint8_t *data,
>   {
>       printf(" %.*s", 2, data);
> 
> -    printf("\tEnvironment: %s\n", country_env_str(data[2]));
> +    printf("\tEnvironment: %s (%#.2x)\n", country_env_str(data[2]), 
> data[2]);
> 

This also got line-broken so I can't apply it.

johannes
diff mbox series

Patch

diff --git a/scan.c b/scan.c
index faf406d..85798b8 100644
--- a/scan.c
+++ b/scan.c
@@ -661,10 +661,24 @@  static const char *country_env_str(char environment)
          return "Indoor only";
      case 'O':
          return "Outdoor only";
+    case 'X':
+        return "Non-country";
      case ' ':
          return "Indoor/Outdoor";
+    case 0x01:
+        return "Operating classes table E-1 (United States)";
+    case 0x02:
+        return "Operating classes table E-2 (Europe)";
+    case 0x03:
+        return "Operating classes table E-3 (Japan)";
+    case 0x04:
+        return "Operating classes table E-4 (Global)";
+    case 0x05:
+        return "Operating classes table E-5 (S1G)";
+    case 0x06:
+        return "Operating classes table E-6 (China)";
      default:
-        return "bogus";
+        return "Bogus";
      }
  }

@@ -673,7 +687,7 @@  static void print_country(const uint8_t type, 
uint8_t len, const uint8_t *data,
  {
      printf(" %.*s", 2, data);

-    printf("\tEnvironment: %s\n", country_env_str(data[2]));
+    printf("\tEnvironment: %s (%#.2x)\n", country_env_str(data[2]), 
data[2]);