hostapd: Set LCI and Location Civic information in configuration
[mech_eap.git] / hostapd / config_file.c
index e91c86c..9e17388 100644 (file)
@@ -97,6 +97,8 @@ static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
                }
 
                vlan->vlan_id = vlan_id;
+               vlan->vlan_desc.untagged = vlan_id;
+               vlan->vlan_desc.notempty = !!vlan_id;
                os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
                vlan->next = bss->vlan;
                bss->vlan = vlan;
@@ -197,7 +199,10 @@ static int hostapd_config_read_maclist(const char *fname,
 
                *acl = newacl;
                os_memcpy((*acl)[*num].addr, addr, ETH_ALEN);
-               (*acl)[*num].vlan_id = vlan_id;
+               os_memset(&(*acl)[*num].vlan_id, 0,
+                         sizeof((*acl)[*num].vlan_id));
+               (*acl)[*num].vlan_id.untagged = vlan_id;
+               (*acl)[*num].vlan_id.notempty = !!vlan_id;
                (*num)++;
        }
 
@@ -1519,6 +1524,54 @@ fail:
 }
 
 
+static int parse_anqp_elem(struct hostapd_bss_config *bss, char *buf, int line)
+{
+       char *delim;
+       u16 infoid;
+       size_t len;
+       struct wpabuf *payload;
+       struct anqp_element *elem;
+
+       delim = os_strchr(buf, ':');
+       if (!delim)
+               return -1;
+       delim++;
+       infoid = atoi(buf);
+       len = os_strlen(delim);
+       if (len & 1)
+               return -1;
+       len /= 2;
+       payload = wpabuf_alloc(len);
+       if (!payload)
+               return -1;
+       if (hexstr2bin(delim, wpabuf_put(payload, len), len) < 0) {
+               wpabuf_free(payload);
+               return -1;
+       }
+
+       dl_list_for_each(elem, &bss->anqp_elem, struct anqp_element, list) {
+               if (elem->infoid == infoid) {
+                       /* Update existing entry */
+                       wpabuf_free(elem->payload);
+                       elem->payload = payload;
+                       return 0;
+               }
+       }
+
+       /* Add a new entry */
+       elem = os_zalloc(sizeof(*elem));
+       if (!elem) {
+               wpabuf_free(payload);
+               return -1;
+       }
+       elem->infoid = infoid;
+       elem->payload = payload;
+       dl_list_add(&bss->anqp_elem, &elem->list);
+
+       return 0;
+}
+
+
 static int parse_qos_map_set(struct hostapd_bss_config *bss,
                             char *buf, int line)
 {
@@ -1867,7 +1920,6 @@ static int hs20_parse_osu_service_desc(struct hostapd_bss_config *bss,
 #endif /* CONFIG_HS20 */
 
 
-#ifdef CONFIG_WPS_NFC
 static struct wpabuf * hostapd_parse_bin(const char *buf)
 {
        size_t len;
@@ -1889,7 +1941,6 @@ static struct wpabuf * hostapd_parse_bin(const char *buf)
 
        return ret;
 }
-#endif /* CONFIG_WPS_NFC */
 
 
 #ifdef CONFIG_ACS
@@ -2084,6 +2135,9 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        } else if (os_strcmp(buf, "ocsp_stapling_response") == 0) {
                os_free(bss->ocsp_stapling_response);
                bss->ocsp_stapling_response = os_strdup(pos);
+       } else if (os_strcmp(buf, "ocsp_stapling_response_multi") == 0) {
+               os_free(bss->ocsp_stapling_response_multi);
+               bss->ocsp_stapling_response_multi = os_strdup(pos);
        } else if (os_strcmp(buf, "dh_file") == 0) {
                os_free(bss->dh_file);
                bss->dh_file = os_strdup(pos);
@@ -2139,6 +2193,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        } else if (os_strcmp(buf, "eap_sim_db") == 0) {
                os_free(bss->eap_sim_db);
                bss->eap_sim_db = os_strdup(pos);
+       } else if (os_strcmp(buf, "eap_sim_db_timeout") == 0) {
+               bss->eap_sim_db_timeout = atoi(pos);
        } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
                bss->eap_sim_aka_result_ind = atoi(pos);
 #endif /* EAP_SERVER_SIM */
@@ -2644,7 +2700,7 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                }
        } else if (os_strcmp(buf, "rts_threshold") == 0) {
                conf->rts_threshold = atoi(pos);
-               if (conf->rts_threshold < 0 || conf->rts_threshold > 2347) {
+               if (conf->rts_threshold < -1 || conf->rts_threshold > 65535) {
                        wpa_printf(MSG_ERROR,
                                   "Line %d: invalid rts_threshold %d",
                                   line, conf->rts_threshold);
@@ -2652,8 +2708,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                }
        } else if (os_strcmp(buf, "fragm_threshold") == 0) {
                conf->fragm_threshold = atoi(pos);
-               if (conf->fragm_threshold < 256 ||
-                   conf->fragm_threshold > 2346) {
+               if (conf->fragm_threshold == -1) {
+                       /* allow a value of -1 */
+               } else if (conf->fragm_threshold < 256 ||
+                          conf->fragm_threshold > 2346) {
                        wpa_printf(MSG_ERROR,
                                   "Line %d: invalid fragm_threshold %d",
                                   line, conf->fragm_threshold);
@@ -2686,6 +2744,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                        conf->preamble = LONG_PREAMBLE;
        } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
                bss->ignore_broadcast_ssid = atoi(pos);
+       } else if (os_strcmp(buf, "no_probe_resp_if_max_sta") == 0) {
+               bss->no_probe_resp_if_max_sta = atoi(pos);
        } else if (os_strcmp(buf, "wep_default_key") == 0) {
                bss->ssid.wep.idx = atoi(pos);
                if (bss->ssid.wep.idx > 3) {
@@ -2707,6 +2767,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 #ifndef CONFIG_NO_VLAN
        } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
                bss->ssid.dynamic_vlan = atoi(pos);
+       } else if (os_strcmp(buf, "per_sta_vif") == 0) {
+               bss->ssid.per_sta_vif = atoi(pos);
        } else if (os_strcmp(buf, "vlan_file") == 0) {
                if (hostapd_config_read_vlan_file(bss, pos)) {
                        wpa_printf(MSG_ERROR, "Line %d: failed to read VLAN file '%s'",
@@ -2762,6 +2824,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                                   line);
                        return 1;
                }
+       } else if (os_strcmp(buf, "use_driver_iface_addr") == 0) {
+               conf->use_driver_iface_addr = atoi(pos);
 #ifdef CONFIG_IEEE80211W
        } else if (os_strcmp(buf, "ieee80211w") == 0) {
                bss->ieee80211w = atoi(pos);
@@ -3136,6 +3200,9 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        } else if (os_strcmp(buf, "nai_realm") == 0) {
                if (parse_nai_realm(bss, pos, line) < 0)
                        return 1;
+       } else if (os_strcmp(buf, "anqp_elem") == 0) {
+               if (parse_anqp_elem(bss, pos, line) < 0)
+                       return 1;
        } else if (os_strcmp(buf, "gas_frag_limit") == 0) {
                bss->gas_frag_limit = atoi(pos);
        } else if (os_strcmp(buf, "gas_comeback_delay") == 0) {
@@ -3149,13 +3216,15 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                os_free(bss->dump_msk_file);
                bss->dump_msk_file = os_strdup(pos);
 #endif /* CONFIG_RADIUS_TEST */
+#ifdef CONFIG_PROXYARP
+       } else if (os_strcmp(buf, "proxy_arp") == 0) {
+               bss->proxy_arp = atoi(pos);
+#endif /* CONFIG_PROXYARP */
 #ifdef CONFIG_HS20
        } else if (os_strcmp(buf, "hs20") == 0) {
                bss->hs20 = atoi(pos);
        } else if (os_strcmp(buf, "disable_dgaf") == 0) {
                bss->disable_dgaf = atoi(pos);
-       } else if (os_strcmp(buf, "proxy_arp") == 0) {
-               bss->proxy_arp = atoi(pos);
        } else if (os_strcmp(buf, "na_mcast_to_ucast") == 0) {
                bss->na_mcast_to_ucast = atoi(pos);
        } else if (os_strcmp(buf, "osen") == 0) {
@@ -3231,6 +3300,10 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        } else if (os_strcmp(buf, "subscr_remediation_method") == 0) {
                bss->subscr_remediation_method = atoi(pos);
 #endif /* CONFIG_HS20 */
+#ifdef CONFIG_MBO
+       } else if (os_strcmp(buf, "mbo") == 0) {
+               bss->mbo_enabled = atoi(pos);
+#endif /* CONFIG_MBO */
 #ifdef CONFIG_TESTING_OPTIONS
 #define PARSE_TEST_PROBABILITY(_val)                           \
        } else if (os_strcmp(buf, #_val) == 0) {                \
@@ -3249,6 +3322,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        PARSE_TEST_PROBABILITY(ignore_assoc_probability)
        PARSE_TEST_PROBABILITY(ignore_reassoc_probability)
        PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability)
+       } else if (os_strcmp(buf, "ecsa_ie_only") == 0) {
+               conf->ecsa_ie_only = atoi(pos);
        } else if (os_strcmp(buf, "bss_load_test") == 0) {
                WPA_PUT_LE16(bss->bss_load_test, atoi(pos));
                pos = os_strchr(pos, ':');
@@ -3391,7 +3466,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                        return -1;
                }
                val = strtol(pos, &endp, 0);
-               if (*endp || val < 1 || val > FST_MAX_LLT_MS) {
+               if (*endp || val < 1 ||
+                   (unsigned long int) val > FST_MAX_LLT_MS) {
                        wpa_printf(MSG_ERROR,
                                   "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
                                   line, val, pos, FST_MAX_LLT_MS);
@@ -3399,6 +3475,22 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                }
                conf->fst_cfg.llt = (u32) val;
 #endif /* CONFIG_FST */
+       } else if (os_strcmp(buf, "track_sta_max_num") == 0) {
+               conf->track_sta_max_num = atoi(pos);
+       } else if (os_strcmp(buf, "track_sta_max_age") == 0) {
+               conf->track_sta_max_age = atoi(pos);
+       } else if (os_strcmp(buf, "no_probe_resp_if_seen_on") == 0) {
+               os_free(bss->no_probe_resp_if_seen_on);
+               bss->no_probe_resp_if_seen_on = os_strdup(pos);
+       } else if (os_strcmp(buf, "no_auth_if_seen_on") == 0) {
+               os_free(bss->no_auth_if_seen_on);
+               bss->no_auth_if_seen_on = os_strdup(pos);
+       } else if (os_strcmp(buf, "lci") == 0) {
+               wpabuf_free(conf->lci);
+               conf->lci = hostapd_parse_bin(pos);
+       } else if (os_strcmp(buf, "civic") == 0) {
+               wpabuf_free(conf->civic);
+               conf->civic = hostapd_parse_bin(pos);
        } else {
                wpa_printf(MSG_ERROR,
                           "Line %d: unknown configuration item '%s'",
@@ -3419,7 +3511,7 @@ struct hostapd_config * hostapd_config_read(const char *fname)
 {
        struct hostapd_config *conf;
        FILE *f;
-       char buf[512], *pos;
+       char buf[4096], *pos;
        int line = 0;
        int errors = 0;
        size_t i;