From patchwork Fri Aug 9 19:20:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Taavi_Eom=C3=A4e?= X-Patchwork-Id: 818375 Received: from aegrel.ee (mail.aegrel.ee [51.195.117.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D75E156228 for ; Fri, 9 Aug 2024 19:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.195.117.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231258; cv=none; b=mux9s2Lj3BuB21JaQBHr8y8k4/tg+sVb0MKtaAfPAw77YLmKhWj7iQ2sewfawFazdF36Ot1/CIlOpaTBywhZ7Nd9B2VBT7LTw4lCb8MzCDUga9RaLd7CepvdDfRC29tnXoVJu37e0YnOZyyl5SqUsdWAXrZbDMaii2xgbKoPERE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231258; c=relaxed/simple; bh=iDDdqHqmIeQdQTZ1k14UHO58t1Xk1mbnit4grBLKdlU=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=SjoozH7AcayxZueUwefCgM0j1ACtTm6iuKDdKRDKAET2cx2fAnqRxS5UC3QXj9ChrILfHSg2HdCAguaBlGwdm7YYQLH+KYyCIrzjp3iPvdABIZE2t7mYDc7d5N98hWFwJlwapTA25UAaeZxuAg1olpFJW7XuOUGqH2nQ7iR0psw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aegrel.ee; spf=pass smtp.mailfrom=aegrel.ee; dkim=permerror (0-bit key) header.d=aegrel.ee header.i=@aegrel.ee header.b=KBztrJJE; arc=none smtp.client-ip=51.195.117.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aegrel.ee Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aegrel.ee Authentication-Results: smtp.subspace.kernel.org; dkim=permerror (0-bit key) header.d=aegrel.ee header.i=@aegrel.ee header.b="KBztrJJE" DKIM-Signature: v=1; a=ed25519-sha256; s=default; d=aegrel.ee; c=relaxed/relaxed; r=y; h=Content-Type:Subject:From:To:Content-Language:User-Agent:MIME-Version :Date:Message-ID:Sender:Expires:Content-Type; t=1723231252; x=1725823252; bh=i DDdqHqmIeQdQTZ1k14UHO58t1Xk1mbnit4grBLKdlU=; b=KBztrJJE/swILXeCn8idVs7s2SjG bOG0TJ9r96dDPipIrfjh0uyNrcSHYUoeBzL6I1sTLkZJ6pyBO90HASJJAg==; Message-ID: <1670e04b-9d61-4778-9d7d-e0d1c2ebb5f8@aegrel.ee> Date: Fri, 9 Aug 2024 22:20:52 +0300 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Johannes Berg Cc: linux-wireless From: =?utf-8?q?Taavi_Eom=C3=A4e?= Subject: [PATCH] iw: scan: Improved handling of Country String environment values 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 ---  scan.c | 18 ++++++++++++++++--  1 file changed, 16 insertions(+), 2 deletions(-)      data += 3;      len -= 3; 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]);