]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
HS 2.0: Add advertising of Operating Class Indication
authorJay Katabathuni <jkatabat@qca.qualcomm.com>
Sat, 25 Aug 2012 13:17:21 +0000 (16:17 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 25 Aug 2012 15:26:32 +0000 (18:26 +0300)
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.c
src/ap/ap_config.h
src/ap/gas_serv.c
src/ap/gas_serv.h

index fceb33f25742e3fa76d2d8e822759b4a76da4e53..549bba9c4f0e418df1ecb54acd7aa365ca52bc63 100644 (file)
@@ -2573,6 +2573,34 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                        bss->hs20 = atoi(pos);
                } else if (os_strcmp(buf, "disable_dgaf") == 0) {
                        bss->disable_dgaf = atoi(pos);
+               } else if (os_strcmp(buf, "hs20_operating_class") == 0) {
+                       u8 *oper_class;
+                       size_t oper_class_len;
+                       oper_class_len = os_strlen(pos);
+                       if (oper_class_len < 2 || (oper_class_len & 0x01)) {
+                               wpa_printf(MSG_ERROR, "Line %d: Invalid "
+                                          "hs20_operating_class '%s'",
+                                          line, pos);
+                               errors++;
+                               return errors;
+                       }
+                       oper_class_len /= 2;
+                       oper_class = os_malloc(oper_class_len);
+                       if (oper_class == NULL) {
+                               errors++;
+                               return errors;
+                       }
+                       if (hexstr2bin(pos, oper_class, oper_class_len)) {
+                               wpa_printf(MSG_ERROR, "Line %d: Invalid "
+                                          "hs20_operating_class '%s'",
+                                          line, pos);
+                               os_free(oper_class);
+                               errors++;
+                               return errors;
+                       }
+                       os_free(bss->hs20_operating_class);
+                       bss->hs20_operating_class = oper_class;
+                       bss->hs20_operating_class_len = oper_class_len;
 #endif /* CONFIG_HS20 */
                } else {
                        wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
index f02c3cd8a7c86f40d6ff84e606380e05f8a69af1..04474ba9350a62071930117a4a865800ea37c49d 100644 (file)
@@ -1400,6 +1400,15 @@ own_ip_addr=127.0.0.1
 # forging such frames to other stations in the BSS.
 #disable_dgaf=1
 
+# Operating Class Indication
+# List of operating classes the BSSes in this ESS use. The Global operating
+# classes in Table E-4 of IEEE Std 802.11-2012 Annex E define the values that
+# can be used in this.
+# format: hexdump of operating class octets
+# for example, operating classes 81 (2.4 GHz channels 1-13) and 115 (5 GHz
+# channels 36-48):
+#hs20_operating_class=5173
+
 ##### Multiple BSSID support ##################################################
 #
 # Above configuration is using the default interface (wlan#, or multi-SSID VLAN
index c804ec58639517ca743d71d60425cd110c7be587..8f6a6e844e8a1590a64758b0d2b5e9a7920f8c2a 100644 (file)
@@ -505,6 +505,10 @@ static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 #ifdef CONFIG_RADIUS_TEST
        os_free(conf->dump_msk_file);
 #endif /* CONFIG_RADIUS_TEST */
+
+#ifdef CONFIG_HS20
+       os_free(conf->hs20_operating_class);
+#endif /* CONFIG_HS20 */
 }
 
 
index 80f65c54d2d2cd3f3cd7669d9063c16782a42464..221ebe2dfaf2f045709edfc1276101c0d9b44ef4 100644 (file)
@@ -410,6 +410,8 @@ struct hostapd_bss_config {
 #ifdef CONFIG_HS20
        int hs20;
        int disable_dgaf;
+       u8 *hs20_operating_class;
+       u8 hs20_operating_class_len;
 #endif /* CONFIG_HS20 */
 
        u8 wps_rf_bands; /* RF bands for WPS (WPS_RF_*) */
index dfbed39ac4c4496236b7ca4cf23fbc42db8d3182..c8bfa111fce53702eafaaf948fb46c44c51f54e8 100644 (file)
@@ -139,6 +139,8 @@ static void anqp_add_hs_capab_list(struct hostapd_data *hapd,
        wpabuf_put_u8(buf, HS20_STYPE_CAPABILITY_LIST);
        wpabuf_put_u8(buf, 0); /* Reserved */
        wpabuf_put_u8(buf, HS20_STYPE_CAPABILITY_LIST);
+       if (hapd->conf->hs20_operating_class)
+               wpabuf_put_u8(buf, HS20_STYPE_OPERATING_CLASS);
        gas_anqp_set_element_len(buf, len);
 }
 
@@ -251,6 +253,22 @@ static void anqp_add_domain_name(struct hostapd_data *hapd, struct wpabuf *buf)
 }
 
 
+static void anqp_add_operating_class(struct hostapd_data *hapd,
+                                    struct wpabuf *buf)
+{
+       if (hapd->conf->hs20_operating_class) {
+               u8 *len = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC);
+               wpabuf_put_be24(buf, OUI_WFA);
+               wpabuf_put_u8(buf, HS20_ANQP_OUI_TYPE);
+               wpabuf_put_u8(buf, HS20_STYPE_OPERATING_CLASS);
+               wpabuf_put_u8(buf, 0); /* Reserved */
+               wpabuf_put_data(buf, hapd->conf->hs20_operating_class,
+                               hapd->conf->hs20_operating_class_len);
+               gas_anqp_set_element_len(buf, len);
+       }
+}
+
+
 static struct wpabuf *
 gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
                                unsigned int request,
@@ -279,6 +297,8 @@ gas_serv_build_gas_resp_payload(struct hostapd_data *hapd,
 
        if (request & ANQP_REQ_HS_CAPABILITY_LIST)
                anqp_add_hs_capab_list(hapd, buf);
+       if (request & ANQP_REQ_OPERATING_CLASS)
+               anqp_add_operating_class(hapd, buf);
 
        return buf;
 }
@@ -390,6 +410,11 @@ static void rx_anqp_hs_query_list(struct hostapd_data *hapd, u8 subtype,
                set_anqp_req(ANQP_REQ_HS_CAPABILITY_LIST, "HS Capability List",
                             1, 0, 0, qi);
                break;
+       case HS20_STYPE_OPERATING_CLASS:
+               set_anqp_req(ANQP_REQ_OPERATING_CLASS, "Operating Class",
+                            hapd->conf->hs20_operating_class != NULL,
+                            0, 0, qi);
+               break;
        default:
                wpa_printf(MSG_DEBUG, "ANQP: Unsupported HS 2.0 subtype %u",
                           subtype);
index dc4bf05bd6138a8b34f30a54faec9c3f35e0f52b..369daad48e123e0c36c731fd1e7c647479e83b46 100644 (file)
@@ -25,6 +25,8 @@
        (1 << (ANQP_DOMAIN_NAME - ANQP_QUERY_LIST))
 #define ANQP_REQ_HS_CAPABILITY_LIST \
        (0x10000 << HS20_STYPE_CAPABILITY_LIST)
+#define ANQP_REQ_OPERATING_CLASS \
+       (0x10000 << HS20_STYPE_OPERATING_CLASS)
 
 /* To account for latencies between hostapd and external ANQP processor */
 #define GAS_SERV_COMEBACK_DELAY_FUDGE 10