From 582ec6a160fda52817d8c4ddeb0cd430eaa5db8e Mon Sep 17 00:00:00 2001 From: saleemuddin shaik Date: Tue, 7 Mar 2023 16:54:31 +0530 Subject: [PATCH] hostapd: Add UNII band into sta_info from hostapd whitespace cleanup and tab alignment made proper. Signed-off-by: saleemuddin shaik --- src/ap/ctrl_iface_ap.c | 128 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c index 1579ce4..f713c77 100644 --- a/src/ap/ctrl_iface_ap.c +++ b/src/ap/ctrl_iface_ap.c @@ -28,6 +28,19 @@ #ifdef CONFIG_CTRL_IFACE_MIB +typedef enum { + BAND_UNII_1 = 1, + BAND_UNII_2A, + BAND_UNII_2C, + BAND_UNII_3, + BAND_UNII_4, + BAND_UNII_ALL_5G, + BAND_UNII_ALL_6G, + BAND_UNII_5, +} band_info_t; + +static unsigned int uniibands[8] = {0}; + static size_t hostapd_write_ht_mcs_bitmask(char *buf, size_t buflen, size_t curr_len, const u8 *mcs_set) { @@ -232,6 +245,45 @@ static const char * hw_mode_str(enum hostapd_hw_mode mode) return "unknown"; } +unsigned int operclass_to_uniimask(unsigned int operclass) +{ + if ((operclass >= 115) && (operclass <= 117)) { + return BAND_UNII_1; + } else if ((operclass >= 118) && (operclass <= 120)) { + return BAND_UNII_2A; + } else if ((operclass >= 121) && (operclass <= 123)) { + return BAND_UNII_2C; + } else if (operclass == 124) { + return BAND_UNII_3; + } else if ((operclass >= 125) && (operclass <= 127)) { + return BAND_UNII_4; + } else if ((operclass >= 128) && (operclass <= 130)) { + return BAND_UNII_ALL_5G; + } else if ((operclass >= 131) && (operclass <= 135)) { + return BAND_UNII_ALL_6G; + } else if (operclass == 136) { + return BAND_UNII_5; + } + + return 0; +} + +void check_and_add_uniibands(band_info_t uniiband) +{ + uint8_t i = 0; + + while (i < 8) { + if (uniibands[i] == uniiband) { + return; + } + else if (uniibands[i] == 0) { + uniibands[i] = uniiband; + return; + } + i++; + } +} + static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd, struct sta_info *sta, @@ -360,6 +412,81 @@ static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd, sta->supp_op_classes + 1, sta->supp_op_classes[0]); len += os_snprintf(buf + len, buflen - len, "\n"); + + u8 *op_classes = sta->supp_op_classes + 1; + + while (*op_classes != 0) { + uint8_t uniiband = operclass_to_uniimask(*op_classes); + switch(uniiband) { + case BAND_UNII_1: + case BAND_UNII_2A: + case BAND_UNII_2C: + case BAND_UNII_3: + case BAND_UNII_4: + case BAND_UNII_ALL_5G: + case BAND_UNII_ALL_6G: + case BAND_UNII_5: + check_and_add_uniibands(uniiband); + default: + break; + } + op_classes++; + } + + len += os_snprintf(buf + len, buflen - len, "uniibands supported: \n"); + for (int i=0; (i < 8) && (uniibands[i] != 0); i++) { + switch(uniibands[i]) { + case BAND_UNII_1: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_1\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_2A: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_2A\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_2C: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_2C\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_3: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_3\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_4: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_4\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_ALL_5G: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_1 UNII_2A " + "UNII_2C UNII_3 UNII_4\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_ALL_6G: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_5 UNII_6 UNII_7 UNII_8\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + case BAND_UNII_5: + ret = os_snprintf(buf + len, buflen - len, "\tUNII_5\n"); + if (os_snprintf_error(buflen - len, ret)) + return len; + len += ret; + break; + } + } } if (sta->power_capab) {