103-iw-scan-add-enum-for-element-IDs.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. From 966c590bc4dcbd9a69fdf8fe9f41cec00e72e376 Mon Sep 17 00:00:00 2001
  2. From: Dylan Eskew <[email protected]>
  3. Date: Mon, 30 Sep 2024 11:11:43 -0700
  4. Subject: [PATCH] iw: scan: add enum for element IDs
  5. Formerly, element IDs were hardcoded. Improve readability by using
  6. element ID names.
  7. Signed-off-by: Dylan Eskew <[email protected]>
  8. Link: https://patch.msgid.link/[email protected]
  9. Signed-off-by: Johannes Berg <[email protected]>
  10. ---
  11. ieee80211.h | 43 +++++++++++++++++++++++++++
  12. scan.c | 86 +++++++++++++++++++++++++++++++----------------------
  13. 2 files changed, 93 insertions(+), 36 deletions(-)
  14. --- a/ieee80211.h
  15. +++ b/ieee80211.h
  16. @@ -58,6 +58,49 @@ struct ieee80211_vht_cap {
  17. struct ieee80211_vht_mcs_info mcs;
  18. } __attribute__ ((packed));
  19. +enum elem_id {
  20. + EID_SSID = 0,
  21. + EID_SUPP_RATES = 1,
  22. + EID_DS_PARAMS = 3,
  23. + EID_TIM = 5,
  24. + EID_IBSS_TIM_PARAMS = 6,
  25. + EID_COUNTRY = 7,
  26. + EID_BSS_LOAD = 11,
  27. + EID_POWER_CONSTRAINT = 32,
  28. + EID_TPC_REPORT = 35,
  29. + EID_ERP_INFO = 42,
  30. + EID_HT_CAPABILITY = 45,
  31. + EID_ERP_D4_0 = 47,
  32. + EID_RSN = 48,
  33. + EID_EXT_SUPP_RATES = 50,
  34. + EID_AP_CHAN_REPORT = 51,
  35. + EID_SUPP_OP_CLASSES = 59,
  36. + EID_HT_OPERATION = 61,
  37. + EID_SECONDARY_CH_OFFSET = 62,
  38. + EID_MEASUREMENT_PILOT_TX = 66,
  39. + EID_RM_ENABLED_CAPABILITIES = 70,
  40. + EID_OVERLAP_BSS_SCAN_PARAM = 74,
  41. + EID_INTERWORKING = 107,
  42. + EID_ADVERTISEMENT = 108,
  43. + EID_ROAMING_CONSORTIUM = 111,
  44. + EID_MESH_CONFIG = 113,
  45. + EID_MESH_ID = 114,
  46. + EID_EXT_CAPABILITY = 127,
  47. + EID_VHT_CAPABILITY = 191,
  48. + EID_VHT_OPERATION = 192,
  49. + EID_TRANSMIT_POWER_ENVELOPE = 195,
  50. + EID_SHORT_BEACON_INTERVAL = 214,
  51. + EID_S1G_CAPABILITY = 217,
  52. + EID_VENDOR = 221,
  53. + EID_S1G_OPERATION = 232,
  54. + EID_EXTENSION = 255,
  55. +};
  56. +
  57. +enum elem_id_ext {
  58. + EID_EXT_HE_CAPABILITY = 35,
  59. + EID_EXT_HE_OPERATION = 36,
  60. +};
  61. +
  62. #define SUITE(oui, id) (((oui) << 8) | (id))
  63. /* cipher suite selectors */
  64. --- a/scan.c
  65. +++ b/scan.c
  66. @@ -1816,40 +1816,54 @@ static void print_ie(const struct ie_pri
  67. }
  68. static const struct ie_print ieprinters[] = {
  69. - [0] = { "SSID", print_ssid, 0, 32,
  70. - BIT(PRINT_SCAN) | BIT(PRINT_LINK) | BIT(PRINT_LINK_MLO_MLD), },
  71. - [1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
  72. - [3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
  73. - [5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
  74. - [6] = { "IBSS ATIM window", print_ibssatim, 2, 2, BIT(PRINT_SCAN), },
  75. - [7] = { "Country", print_country, 3, 255, BIT(PRINT_SCAN), },
  76. - [11] = { "BSS Load", print_bss_load, 5, 5, BIT(PRINT_SCAN), },
  77. - [32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
  78. - [35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
  79. - [42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
  80. - [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
  81. - [47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
  82. - [51] = { "AP Channel Report", print_ap_channel_report, 1, 255, BIT(PRINT_SCAN), },
  83. - [59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
  84. - [66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
  85. - [74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
  86. - [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
  87. - [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
  88. - [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
  89. - [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
  90. - [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
  91. - [50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
  92. - [70] = { "RM enabled capabilities", print_rm_enabled_capabilities, 5, 5, BIT(PRINT_SCAN), },
  93. - [113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
  94. - [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
  95. - [127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
  96. - [107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
  97. - [108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
  98. - [111] = { "802.11u Roaming Consortium", print_11u_rcon, 2, 255, BIT(PRINT_SCAN), },
  99. - [195] = { "Transmit Power Envelope", print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), },
  100. - [214] = { "Short beacon interval", print_short_beacon_int, 2, 2, BIT(PRINT_SCAN), },
  101. - [217] = { "S1G capabilities", print_s1g_capa, 15, 15, BIT(PRINT_SCAN), },
  102. - [232] = { "S1G operation", print_s1g_oper, 6, 6, BIT(PRINT_SCAN), },
  103. + [EID_SSID] = { "SSID", print_ssid, 0, 32,
  104. + BIT(PRINT_SCAN) | BIT(PRINT_LINK) | BIT(PRINT_LINK_MLO_MLD), },
  105. + [EID_SUPP_RATES] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
  106. + [EID_DS_PARAMS] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
  107. + [EID_TIM] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
  108. + [EID_IBSS_TIM_PARAMS] = { "IBSS ATIM window", print_ibssatim, 2, 2, BIT(PRINT_SCAN), },
  109. + [EID_COUNTRY] = { "Country", print_country, 3, 255, BIT(PRINT_SCAN), },
  110. + [EID_BSS_LOAD] = { "BSS Load", print_bss_load, 5, 5, BIT(PRINT_SCAN), },
  111. + [EID_POWER_CONSTRAINT] = { "Power constraint", print_powerconstraint,
  112. + 1, 1, BIT(PRINT_SCAN), },
  113. + [EID_TPC_REPORT] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
  114. + [EID_ERP_INFO] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
  115. + [EID_HT_CAPABILITY] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
  116. + [EID_ERP_D4_0] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
  117. + [EID_AP_CHAN_REPORT] = { "AP Channel Report", print_ap_channel_report,
  118. + 1, 255, BIT(PRINT_SCAN), },
  119. + [EID_SUPP_OP_CLASSES] = { "Supported operating classes",
  120. + print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
  121. + [EID_MEASUREMENT_PILOT_TX] = { "Measurement Pilot Transmission",
  122. + print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
  123. + [EID_OVERLAP_BSS_SCAN_PARAM] = { "Overlapping BSS scan params",
  124. + print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
  125. + [EID_HT_OPERATION] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
  126. + [EID_SECONDARY_CH_OFFSET] = { "Secondary Channel Offset",
  127. + print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
  128. + [EID_VHT_CAPABILITY] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
  129. + [EID_VHT_OPERATION] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
  130. + [EID_RSN] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
  131. + [EID_EXT_SUPP_RATES] = { "Extended supported rates", print_supprates,
  132. + 0, 255, BIT(PRINT_SCAN), },
  133. + [EID_RM_ENABLED_CAPABILITIES] = { "RM enabled capabilities",
  134. + print_rm_enabled_capabilities, 5, 5, BIT(PRINT_SCAN), },
  135. + [EID_MESH_CONFIG] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
  136. + [EID_MESH_ID] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
  137. + [EID_EXT_CAPABILITY] = { "Extended capabilities", print_capabilities,
  138. + 0, 255, BIT(PRINT_SCAN), },
  139. + [EID_INTERWORKING] = { "802.11u Interworking", print_interworking,
  140. + 0, 255, BIT(PRINT_SCAN), },
  141. + [EID_ADVERTISEMENT] = { "802.11u Advertisement", print_11u_advert,
  142. + 0, 255, BIT(PRINT_SCAN), },
  143. + [EID_ROAMING_CONSORTIUM] = { "802.11u Roaming Consortium",
  144. + print_11u_rcon, 2, 255, BIT(PRINT_SCAN), },
  145. + [EID_TRANSMIT_POWER_ENVELOPE] = { "Transmit Power Envelope",
  146. + print_tx_power_envelope, 2, 5, BIT(PRINT_SCAN), },
  147. + [EID_SHORT_BEACON_INTERVAL] = { "Short beacon interval",
  148. + print_short_beacon_int, 2, 2, BIT(PRINT_SCAN), },
  149. + [EID_S1G_CAPABILITY] = { "S1G capabilities", print_s1g_capa, 15, 15, BIT(PRINT_SCAN), },
  150. + [EID_S1G_OPERATION] = { "S1G operation", print_s1g_oper, 6, 6, BIT(PRINT_SCAN), },
  151. };
  152. static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
  153. @@ -2392,8 +2406,8 @@ static void print_he_oper(const uint8_t
  154. }
  155. static const struct ie_print ext_printers[] = {
  156. - [35] = { "HE capabilities", print_he_capa, 21, 54, BIT(PRINT_SCAN), },
  157. - [36] = { "HE Operation", print_he_oper, 6, 15, BIT(PRINT_SCAN), },
  158. + [EID_EXT_HE_CAPABILITY] = { "HE capabilities", print_he_capa, 21, 54, BIT(PRINT_SCAN), },
  159. + [EID_EXT_HE_OPERATION] = { "HE Operation", print_he_oper, 6, 15, BIT(PRINT_SCAN), },
  160. };
  161. static void print_extension(unsigned char len, unsigned char *ie,