1e5b75505Sopenharmony_ci/* 2e5b75505Sopenharmony_ci * hostapd / Configuration file parser 3e5b75505Sopenharmony_ci * Copyright (c) 2003-2018, Jouni Malinen <j@w1.fi> 4e5b75505Sopenharmony_ci * 5e5b75505Sopenharmony_ci * This software may be distributed under the terms of the BSD license. 6e5b75505Sopenharmony_ci * See README for more details. 7e5b75505Sopenharmony_ci */ 8e5b75505Sopenharmony_ci 9e5b75505Sopenharmony_ci#include "utils/includes.h" 10e5b75505Sopenharmony_ci#ifndef CONFIG_NATIVE_WINDOWS 11e5b75505Sopenharmony_ci#include <grp.h> 12e5b75505Sopenharmony_ci#endif /* CONFIG_NATIVE_WINDOWS */ 13e5b75505Sopenharmony_ci 14e5b75505Sopenharmony_ci#include "utils/common.h" 15e5b75505Sopenharmony_ci#include "utils/uuid.h" 16e5b75505Sopenharmony_ci#include "common/ieee802_11_defs.h" 17e5b75505Sopenharmony_ci#include "crypto/sha256.h" 18e5b75505Sopenharmony_ci#include "crypto/tls.h" 19e5b75505Sopenharmony_ci#include "drivers/driver.h" 20e5b75505Sopenharmony_ci#include "eap_server/eap.h" 21e5b75505Sopenharmony_ci#include "radius/radius_client.h" 22e5b75505Sopenharmony_ci#include "ap/wpa_auth.h" 23e5b75505Sopenharmony_ci#include "ap/ap_config.h" 24e5b75505Sopenharmony_ci#include "config_file.h" 25e5b75505Sopenharmony_ci 26e5b75505Sopenharmony_ci 27e5b75505Sopenharmony_ci#ifndef CONFIG_NO_VLAN 28e5b75505Sopenharmony_cistatic int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss, 29e5b75505Sopenharmony_ci const char *fname) 30e5b75505Sopenharmony_ci{ 31e5b75505Sopenharmony_ci FILE *f; 32e5b75505Sopenharmony_ci char buf[128], *pos, *pos2, *pos3; 33e5b75505Sopenharmony_ci int line = 0, vlan_id; 34e5b75505Sopenharmony_ci struct hostapd_vlan *vlan; 35e5b75505Sopenharmony_ci 36e5b75505Sopenharmony_ci f = fopen(fname, "r"); 37e5b75505Sopenharmony_ci if (!f) { 38e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "VLAN file '%s' not readable.", fname); 39e5b75505Sopenharmony_ci return -1; 40e5b75505Sopenharmony_ci } 41e5b75505Sopenharmony_ci 42e5b75505Sopenharmony_ci while (fgets(buf, sizeof(buf), f)) { 43e5b75505Sopenharmony_ci line++; 44e5b75505Sopenharmony_ci 45e5b75505Sopenharmony_ci if (buf[0] == '#') 46e5b75505Sopenharmony_ci continue; 47e5b75505Sopenharmony_ci pos = buf; 48e5b75505Sopenharmony_ci while (*pos != '\0') { 49e5b75505Sopenharmony_ci if (*pos == '\n') { 50e5b75505Sopenharmony_ci *pos = '\0'; 51e5b75505Sopenharmony_ci break; 52e5b75505Sopenharmony_ci } 53e5b75505Sopenharmony_ci pos++; 54e5b75505Sopenharmony_ci } 55e5b75505Sopenharmony_ci if (buf[0] == '\0') 56e5b75505Sopenharmony_ci continue; 57e5b75505Sopenharmony_ci 58e5b75505Sopenharmony_ci if (buf[0] == '*') { 59e5b75505Sopenharmony_ci vlan_id = VLAN_ID_WILDCARD; 60e5b75505Sopenharmony_ci pos = buf + 1; 61e5b75505Sopenharmony_ci } else { 62e5b75505Sopenharmony_ci vlan_id = strtol(buf, &pos, 10); 63e5b75505Sopenharmony_ci if (buf == pos || vlan_id < 1 || 64e5b75505Sopenharmony_ci vlan_id > MAX_VLAN_ID) { 65e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid VLAN ID at " 66e5b75505Sopenharmony_ci "line %d in '%s'", line, fname); 67e5b75505Sopenharmony_ci fclose(f); 68e5b75505Sopenharmony_ci return -1; 69e5b75505Sopenharmony_ci } 70e5b75505Sopenharmony_ci } 71e5b75505Sopenharmony_ci 72e5b75505Sopenharmony_ci while (*pos == ' ' || *pos == '\t') 73e5b75505Sopenharmony_ci pos++; 74e5b75505Sopenharmony_ci pos2 = pos; 75e5b75505Sopenharmony_ci while (*pos2 != ' ' && *pos2 != '\t' && *pos2 != '\0') 76e5b75505Sopenharmony_ci pos2++; 77e5b75505Sopenharmony_ci 78e5b75505Sopenharmony_ci if (*pos2 != '\0') 79e5b75505Sopenharmony_ci *(pos2++) = '\0'; 80e5b75505Sopenharmony_ci 81e5b75505Sopenharmony_ci if (*pos == '\0' || os_strlen(pos) > IFNAMSIZ) { 82e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid VLAN ifname at line %d " 83e5b75505Sopenharmony_ci "in '%s'", line, fname); 84e5b75505Sopenharmony_ci fclose(f); 85e5b75505Sopenharmony_ci return -1; 86e5b75505Sopenharmony_ci } 87e5b75505Sopenharmony_ci 88e5b75505Sopenharmony_ci while (*pos2 == ' ' || *pos2 == '\t') 89e5b75505Sopenharmony_ci pos2++; 90e5b75505Sopenharmony_ci pos3 = pos2; 91e5b75505Sopenharmony_ci while (*pos3 != ' ' && *pos3 != '\t' && *pos3 != '\0') 92e5b75505Sopenharmony_ci pos3++; 93e5b75505Sopenharmony_ci *pos3 = '\0'; 94e5b75505Sopenharmony_ci 95e5b75505Sopenharmony_ci vlan = os_zalloc(sizeof(*vlan)); 96e5b75505Sopenharmony_ci if (vlan == NULL) { 97e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Out of memory while reading " 98e5b75505Sopenharmony_ci "VLAN interfaces from '%s'", fname); 99e5b75505Sopenharmony_ci fclose(f); 100e5b75505Sopenharmony_ci return -1; 101e5b75505Sopenharmony_ci } 102e5b75505Sopenharmony_ci 103e5b75505Sopenharmony_ci vlan->vlan_id = vlan_id; 104e5b75505Sopenharmony_ci vlan->vlan_desc.untagged = vlan_id; 105e5b75505Sopenharmony_ci vlan->vlan_desc.notempty = !!vlan_id; 106e5b75505Sopenharmony_ci os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname)); 107e5b75505Sopenharmony_ci os_strlcpy(vlan->bridge, pos2, sizeof(vlan->bridge)); 108e5b75505Sopenharmony_ci vlan->next = bss->vlan; 109e5b75505Sopenharmony_ci bss->vlan = vlan; 110e5b75505Sopenharmony_ci } 111e5b75505Sopenharmony_ci 112e5b75505Sopenharmony_ci fclose(f); 113e5b75505Sopenharmony_ci 114e5b75505Sopenharmony_ci return 0; 115e5b75505Sopenharmony_ci} 116e5b75505Sopenharmony_ci#endif /* CONFIG_NO_VLAN */ 117e5b75505Sopenharmony_ci 118e5b75505Sopenharmony_ci 119e5b75505Sopenharmony_ciint hostapd_acl_comp(const void *a, const void *b) 120e5b75505Sopenharmony_ci{ 121e5b75505Sopenharmony_ci const struct mac_acl_entry *aa = a; 122e5b75505Sopenharmony_ci const struct mac_acl_entry *bb = b; 123e5b75505Sopenharmony_ci return os_memcmp(aa->addr, bb->addr, sizeof(macaddr)); 124e5b75505Sopenharmony_ci} 125e5b75505Sopenharmony_ci 126e5b75505Sopenharmony_ci 127e5b75505Sopenharmony_ciint hostapd_add_acl_maclist(struct mac_acl_entry **acl, int *num, 128e5b75505Sopenharmony_ci int vlan_id, const u8 *addr) 129e5b75505Sopenharmony_ci{ 130e5b75505Sopenharmony_ci struct mac_acl_entry *newacl; 131e5b75505Sopenharmony_ci 132e5b75505Sopenharmony_ci newacl = os_realloc_array(*acl, *num + 1, sizeof(**acl)); 133e5b75505Sopenharmony_ci if (!newacl) { 134e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "MAC list reallocation failed"); 135e5b75505Sopenharmony_ci return -1; 136e5b75505Sopenharmony_ci } 137e5b75505Sopenharmony_ci 138e5b75505Sopenharmony_ci *acl = newacl; 139e5b75505Sopenharmony_ci os_memcpy((*acl)[*num].addr, addr, ETH_ALEN); 140e5b75505Sopenharmony_ci os_memset(&(*acl)[*num].vlan_id, 0, sizeof((*acl)[*num].vlan_id)); 141e5b75505Sopenharmony_ci (*acl)[*num].vlan_id.untagged = vlan_id; 142e5b75505Sopenharmony_ci (*acl)[*num].vlan_id.notempty = !!vlan_id; 143e5b75505Sopenharmony_ci (*num)++; 144e5b75505Sopenharmony_ci 145e5b75505Sopenharmony_ci return 0; 146e5b75505Sopenharmony_ci} 147e5b75505Sopenharmony_ci 148e5b75505Sopenharmony_ci 149e5b75505Sopenharmony_civoid hostapd_remove_acl_mac(struct mac_acl_entry **acl, int *num, 150e5b75505Sopenharmony_ci const u8 *addr) 151e5b75505Sopenharmony_ci{ 152e5b75505Sopenharmony_ci int i = 0; 153e5b75505Sopenharmony_ci 154e5b75505Sopenharmony_ci while (i < *num) { 155e5b75505Sopenharmony_ci if (os_memcmp((*acl)[i].addr, addr, ETH_ALEN) == 0) { 156e5b75505Sopenharmony_ci os_remove_in_array(*acl, *num, sizeof(**acl), i); 157e5b75505Sopenharmony_ci (*num)--; 158e5b75505Sopenharmony_ci } else { 159e5b75505Sopenharmony_ci i++; 160e5b75505Sopenharmony_ci } 161e5b75505Sopenharmony_ci } 162e5b75505Sopenharmony_ci} 163e5b75505Sopenharmony_ci 164e5b75505Sopenharmony_ci 165e5b75505Sopenharmony_cistatic int hostapd_config_read_maclist(const char *fname, 166e5b75505Sopenharmony_ci struct mac_acl_entry **acl, int *num) 167e5b75505Sopenharmony_ci{ 168e5b75505Sopenharmony_ci FILE *f; 169e5b75505Sopenharmony_ci char buf[128], *pos; 170e5b75505Sopenharmony_ci int line = 0; 171e5b75505Sopenharmony_ci u8 addr[ETH_ALEN]; 172e5b75505Sopenharmony_ci int vlan_id; 173e5b75505Sopenharmony_ci 174e5b75505Sopenharmony_ci f = fopen(fname, "r"); 175e5b75505Sopenharmony_ci if (!f) { 176e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "MAC list file '%s' not found.", fname); 177e5b75505Sopenharmony_ci return -1; 178e5b75505Sopenharmony_ci } 179e5b75505Sopenharmony_ci 180e5b75505Sopenharmony_ci while (fgets(buf, sizeof(buf), f)) { 181e5b75505Sopenharmony_ci int rem = 0; 182e5b75505Sopenharmony_ci 183e5b75505Sopenharmony_ci line++; 184e5b75505Sopenharmony_ci 185e5b75505Sopenharmony_ci if (buf[0] == '#') 186e5b75505Sopenharmony_ci continue; 187e5b75505Sopenharmony_ci pos = buf; 188e5b75505Sopenharmony_ci while (*pos != '\0') { 189e5b75505Sopenharmony_ci if (*pos == '\n') { 190e5b75505Sopenharmony_ci *pos = '\0'; 191e5b75505Sopenharmony_ci break; 192e5b75505Sopenharmony_ci } 193e5b75505Sopenharmony_ci pos++; 194e5b75505Sopenharmony_ci } 195e5b75505Sopenharmony_ci if (buf[0] == '\0') 196e5b75505Sopenharmony_ci continue; 197e5b75505Sopenharmony_ci pos = buf; 198e5b75505Sopenharmony_ci if (buf[0] == '-') { 199e5b75505Sopenharmony_ci rem = 1; 200e5b75505Sopenharmony_ci pos++; 201e5b75505Sopenharmony_ci } 202e5b75505Sopenharmony_ci 203e5b75505Sopenharmony_ci if (hwaddr_aton(pos, addr)) { 204e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid MAC address '%s' at " 205e5b75505Sopenharmony_ci "line %d in '%s'", pos, line, fname); 206e5b75505Sopenharmony_ci fclose(f); 207e5b75505Sopenharmony_ci return -1; 208e5b75505Sopenharmony_ci } 209e5b75505Sopenharmony_ci 210e5b75505Sopenharmony_ci if (rem) { 211e5b75505Sopenharmony_ci hostapd_remove_acl_mac(acl, num, addr); 212e5b75505Sopenharmony_ci continue; 213e5b75505Sopenharmony_ci } 214e5b75505Sopenharmony_ci vlan_id = 0; 215e5b75505Sopenharmony_ci pos = buf; 216e5b75505Sopenharmony_ci while (*pos != '\0' && *pos != ' ' && *pos != '\t') 217e5b75505Sopenharmony_ci pos++; 218e5b75505Sopenharmony_ci while (*pos == ' ' || *pos == '\t') 219e5b75505Sopenharmony_ci pos++; 220e5b75505Sopenharmony_ci if (*pos != '\0') 221e5b75505Sopenharmony_ci vlan_id = atoi(pos); 222e5b75505Sopenharmony_ci 223e5b75505Sopenharmony_ci if (hostapd_add_acl_maclist(acl, num, vlan_id, addr) < 0) { 224e5b75505Sopenharmony_ci fclose(f); 225e5b75505Sopenharmony_ci return -1; 226e5b75505Sopenharmony_ci } 227e5b75505Sopenharmony_ci } 228e5b75505Sopenharmony_ci 229e5b75505Sopenharmony_ci fclose(f); 230e5b75505Sopenharmony_ci 231e5b75505Sopenharmony_ci if (*acl) 232e5b75505Sopenharmony_ci qsort(*acl, *num, sizeof(**acl), hostapd_acl_comp); 233e5b75505Sopenharmony_ci 234e5b75505Sopenharmony_ci return 0; 235e5b75505Sopenharmony_ci} 236e5b75505Sopenharmony_ci 237e5b75505Sopenharmony_ci 238e5b75505Sopenharmony_ci#ifdef EAP_SERVER 239e5b75505Sopenharmony_ci 240e5b75505Sopenharmony_cistatic int hostapd_config_eap_user_salted(struct hostapd_eap_user *user, 241e5b75505Sopenharmony_ci const char *hash, size_t len, 242e5b75505Sopenharmony_ci char **pos, int line, 243e5b75505Sopenharmony_ci const char *fname) 244e5b75505Sopenharmony_ci{ 245e5b75505Sopenharmony_ci char *pos2 = *pos; 246e5b75505Sopenharmony_ci 247e5b75505Sopenharmony_ci while (*pos2 != '\0' && *pos2 != ' ' && *pos2 != '\t' && *pos2 != '#') 248e5b75505Sopenharmony_ci pos2++; 249e5b75505Sopenharmony_ci 250e5b75505Sopenharmony_ci if (pos2 - *pos < (int) (2 * (len + 1))) { /* at least 1 byte of salt */ 251e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 252e5b75505Sopenharmony_ci "Invalid salted %s hash on line %d in '%s'", 253e5b75505Sopenharmony_ci hash, line, fname); 254e5b75505Sopenharmony_ci return -1; 255e5b75505Sopenharmony_ci } 256e5b75505Sopenharmony_ci 257e5b75505Sopenharmony_ci user->password = os_malloc(len); 258e5b75505Sopenharmony_ci if (!user->password) { 259e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 260e5b75505Sopenharmony_ci "Failed to allocate memory for salted %s hash", 261e5b75505Sopenharmony_ci hash); 262e5b75505Sopenharmony_ci return -1; 263e5b75505Sopenharmony_ci } 264e5b75505Sopenharmony_ci 265e5b75505Sopenharmony_ci if (hexstr2bin(*pos, user->password, len) < 0) { 266e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 267e5b75505Sopenharmony_ci "Invalid salted password on line %d in '%s'", 268e5b75505Sopenharmony_ci line, fname); 269e5b75505Sopenharmony_ci return -1; 270e5b75505Sopenharmony_ci } 271e5b75505Sopenharmony_ci user->password_len = len; 272e5b75505Sopenharmony_ci *pos += 2 * len; 273e5b75505Sopenharmony_ci 274e5b75505Sopenharmony_ci user->salt_len = (pos2 - *pos) / 2; 275e5b75505Sopenharmony_ci user->salt = os_malloc(user->salt_len); 276e5b75505Sopenharmony_ci if (!user->salt) { 277e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 278e5b75505Sopenharmony_ci "Failed to allocate memory for salted %s hash", 279e5b75505Sopenharmony_ci hash); 280e5b75505Sopenharmony_ci return -1; 281e5b75505Sopenharmony_ci } 282e5b75505Sopenharmony_ci 283e5b75505Sopenharmony_ci if (hexstr2bin(*pos, user->salt, user->salt_len) < 0) { 284e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 285e5b75505Sopenharmony_ci "Invalid salt for password on line %d in '%s'", 286e5b75505Sopenharmony_ci line, fname); 287e5b75505Sopenharmony_ci return -1; 288e5b75505Sopenharmony_ci } 289e5b75505Sopenharmony_ci 290e5b75505Sopenharmony_ci *pos = pos2; 291e5b75505Sopenharmony_ci return 0; 292e5b75505Sopenharmony_ci} 293e5b75505Sopenharmony_ci 294e5b75505Sopenharmony_ci 295e5b75505Sopenharmony_cistatic int hostapd_config_read_eap_user(const char *fname, 296e5b75505Sopenharmony_ci struct hostapd_bss_config *conf) 297e5b75505Sopenharmony_ci{ 298e5b75505Sopenharmony_ci FILE *f; 299e5b75505Sopenharmony_ci char buf[512], *pos, *start, *pos2; 300e5b75505Sopenharmony_ci int line = 0, ret = 0, num_methods; 301e5b75505Sopenharmony_ci struct hostapd_eap_user *user = NULL, *tail = NULL, *new_user = NULL; 302e5b75505Sopenharmony_ci 303e5b75505Sopenharmony_ci if (os_strncmp(fname, "sqlite:", 7) == 0) { 304e5b75505Sopenharmony_ci#ifdef CONFIG_SQLITE 305e5b75505Sopenharmony_ci os_free(conf->eap_user_sqlite); 306e5b75505Sopenharmony_ci conf->eap_user_sqlite = os_strdup(fname + 7); 307e5b75505Sopenharmony_ci return 0; 308e5b75505Sopenharmony_ci#else /* CONFIG_SQLITE */ 309e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 310e5b75505Sopenharmony_ci "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build."); 311e5b75505Sopenharmony_ci return -1; 312e5b75505Sopenharmony_ci#endif /* CONFIG_SQLITE */ 313e5b75505Sopenharmony_ci } 314e5b75505Sopenharmony_ci 315e5b75505Sopenharmony_ci f = fopen(fname, "r"); 316e5b75505Sopenharmony_ci if (!f) { 317e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "EAP user file '%s' not found.", fname); 318e5b75505Sopenharmony_ci return -1; 319e5b75505Sopenharmony_ci } 320e5b75505Sopenharmony_ci 321e5b75505Sopenharmony_ci /* Lines: "user" METHOD,METHOD2 "password" (password optional) */ 322e5b75505Sopenharmony_ci while (fgets(buf, sizeof(buf), f)) { 323e5b75505Sopenharmony_ci line++; 324e5b75505Sopenharmony_ci 325e5b75505Sopenharmony_ci if (buf[0] == '#') 326e5b75505Sopenharmony_ci continue; 327e5b75505Sopenharmony_ci pos = buf; 328e5b75505Sopenharmony_ci while (*pos != '\0') { 329e5b75505Sopenharmony_ci if (*pos == '\n') { 330e5b75505Sopenharmony_ci *pos = '\0'; 331e5b75505Sopenharmony_ci break; 332e5b75505Sopenharmony_ci } 333e5b75505Sopenharmony_ci pos++; 334e5b75505Sopenharmony_ci } 335e5b75505Sopenharmony_ci if (buf[0] == '\0') 336e5b75505Sopenharmony_ci continue; 337e5b75505Sopenharmony_ci 338e5b75505Sopenharmony_ci#ifndef CONFIG_NO_RADIUS 339e5b75505Sopenharmony_ci if (user && os_strncmp(buf, "radius_accept_attr=", 19) == 0) { 340e5b75505Sopenharmony_ci struct hostapd_radius_attr *attr, *a; 341e5b75505Sopenharmony_ci attr = hostapd_parse_radius_attr(buf + 19); 342e5b75505Sopenharmony_ci if (attr == NULL) { 343e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid radius_auth_req_attr: %s", 344e5b75505Sopenharmony_ci buf + 19); 345e5b75505Sopenharmony_ci user = NULL; /* already in the BSS list */ 346e5b75505Sopenharmony_ci goto failed; 347e5b75505Sopenharmony_ci } 348e5b75505Sopenharmony_ci if (user->accept_attr == NULL) { 349e5b75505Sopenharmony_ci user->accept_attr = attr; 350e5b75505Sopenharmony_ci } else { 351e5b75505Sopenharmony_ci a = user->accept_attr; 352e5b75505Sopenharmony_ci while (a->next) 353e5b75505Sopenharmony_ci a = a->next; 354e5b75505Sopenharmony_ci a->next = attr; 355e5b75505Sopenharmony_ci } 356e5b75505Sopenharmony_ci continue; 357e5b75505Sopenharmony_ci } 358e5b75505Sopenharmony_ci#endif /* CONFIG_NO_RADIUS */ 359e5b75505Sopenharmony_ci 360e5b75505Sopenharmony_ci user = NULL; 361e5b75505Sopenharmony_ci 362e5b75505Sopenharmony_ci if (buf[0] != '"' && buf[0] != '*') { 363e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid EAP identity (no \" in " 364e5b75505Sopenharmony_ci "start) on line %d in '%s'", line, fname); 365e5b75505Sopenharmony_ci goto failed; 366e5b75505Sopenharmony_ci } 367e5b75505Sopenharmony_ci 368e5b75505Sopenharmony_ci user = os_zalloc(sizeof(*user)); 369e5b75505Sopenharmony_ci if (user == NULL) { 370e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "EAP user allocation failed"); 371e5b75505Sopenharmony_ci goto failed; 372e5b75505Sopenharmony_ci } 373e5b75505Sopenharmony_ci user->force_version = -1; 374e5b75505Sopenharmony_ci 375e5b75505Sopenharmony_ci if (buf[0] == '*') { 376e5b75505Sopenharmony_ci pos = buf; 377e5b75505Sopenharmony_ci } else { 378e5b75505Sopenharmony_ci pos = buf + 1; 379e5b75505Sopenharmony_ci start = pos; 380e5b75505Sopenharmony_ci while (*pos != '"' && *pos != '\0') 381e5b75505Sopenharmony_ci pos++; 382e5b75505Sopenharmony_ci if (*pos == '\0') { 383e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid EAP identity " 384e5b75505Sopenharmony_ci "(no \" in end) on line %d in '%s'", 385e5b75505Sopenharmony_ci line, fname); 386e5b75505Sopenharmony_ci goto failed; 387e5b75505Sopenharmony_ci } 388e5b75505Sopenharmony_ci 389e5b75505Sopenharmony_ci user->identity = os_memdup(start, pos - start); 390e5b75505Sopenharmony_ci if (user->identity == NULL) { 391e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Failed to allocate " 392e5b75505Sopenharmony_ci "memory for EAP identity"); 393e5b75505Sopenharmony_ci goto failed; 394e5b75505Sopenharmony_ci } 395e5b75505Sopenharmony_ci user->identity_len = pos - start; 396e5b75505Sopenharmony_ci 397e5b75505Sopenharmony_ci if (pos[0] == '"' && pos[1] == '*') { 398e5b75505Sopenharmony_ci user->wildcard_prefix = 1; 399e5b75505Sopenharmony_ci pos++; 400e5b75505Sopenharmony_ci } 401e5b75505Sopenharmony_ci } 402e5b75505Sopenharmony_ci pos++; 403e5b75505Sopenharmony_ci while (*pos == ' ' || *pos == '\t') 404e5b75505Sopenharmony_ci pos++; 405e5b75505Sopenharmony_ci 406e5b75505Sopenharmony_ci if (*pos == '\0') { 407e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "No EAP method on line %d in " 408e5b75505Sopenharmony_ci "'%s'", line, fname); 409e5b75505Sopenharmony_ci goto failed; 410e5b75505Sopenharmony_ci } 411e5b75505Sopenharmony_ci 412e5b75505Sopenharmony_ci start = pos; 413e5b75505Sopenharmony_ci while (*pos != ' ' && *pos != '\t' && *pos != '\0') 414e5b75505Sopenharmony_ci pos++; 415e5b75505Sopenharmony_ci if (*pos == '\0') { 416e5b75505Sopenharmony_ci pos = NULL; 417e5b75505Sopenharmony_ci } else { 418e5b75505Sopenharmony_ci *pos = '\0'; 419e5b75505Sopenharmony_ci pos++; 420e5b75505Sopenharmony_ci } 421e5b75505Sopenharmony_ci num_methods = 0; 422e5b75505Sopenharmony_ci while (*start) { 423e5b75505Sopenharmony_ci char *pos3 = os_strchr(start, ','); 424e5b75505Sopenharmony_ci if (pos3) { 425e5b75505Sopenharmony_ci *pos3++ = '\0'; 426e5b75505Sopenharmony_ci } 427e5b75505Sopenharmony_ci user->methods[num_methods].method = 428e5b75505Sopenharmony_ci eap_server_get_type( 429e5b75505Sopenharmony_ci start, 430e5b75505Sopenharmony_ci &user->methods[num_methods].vendor); 431e5b75505Sopenharmony_ci if (user->methods[num_methods].vendor == 432e5b75505Sopenharmony_ci EAP_VENDOR_IETF && 433e5b75505Sopenharmony_ci user->methods[num_methods].method == EAP_TYPE_NONE) 434e5b75505Sopenharmony_ci { 435e5b75505Sopenharmony_ci if (os_strcmp(start, "TTLS-PAP") == 0) { 436e5b75505Sopenharmony_ci user->ttls_auth |= EAP_TTLS_AUTH_PAP; 437e5b75505Sopenharmony_ci goto skip_eap; 438e5b75505Sopenharmony_ci } 439e5b75505Sopenharmony_ci if (os_strcmp(start, "TTLS-CHAP") == 0) { 440e5b75505Sopenharmony_ci user->ttls_auth |= EAP_TTLS_AUTH_CHAP; 441e5b75505Sopenharmony_ci goto skip_eap; 442e5b75505Sopenharmony_ci } 443e5b75505Sopenharmony_ci if (os_strcmp(start, "TTLS-MSCHAP") == 0) { 444e5b75505Sopenharmony_ci user->ttls_auth |= 445e5b75505Sopenharmony_ci EAP_TTLS_AUTH_MSCHAP; 446e5b75505Sopenharmony_ci goto skip_eap; 447e5b75505Sopenharmony_ci } 448e5b75505Sopenharmony_ci if (os_strcmp(start, "TTLS-MSCHAPV2") == 0) { 449e5b75505Sopenharmony_ci user->ttls_auth |= 450e5b75505Sopenharmony_ci EAP_TTLS_AUTH_MSCHAPV2; 451e5b75505Sopenharmony_ci goto skip_eap; 452e5b75505Sopenharmony_ci } 453e5b75505Sopenharmony_ci if (os_strcmp(start, "MACACL") == 0) { 454e5b75505Sopenharmony_ci user->macacl = 1; 455e5b75505Sopenharmony_ci goto skip_eap; 456e5b75505Sopenharmony_ci } 457e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Unsupported EAP type " 458e5b75505Sopenharmony_ci "'%s' on line %d in '%s'", 459e5b75505Sopenharmony_ci start, line, fname); 460e5b75505Sopenharmony_ci goto failed; 461e5b75505Sopenharmony_ci } 462e5b75505Sopenharmony_ci 463e5b75505Sopenharmony_ci num_methods++; 464e5b75505Sopenharmony_ci if (num_methods >= EAP_MAX_METHODS) 465e5b75505Sopenharmony_ci break; 466e5b75505Sopenharmony_ci skip_eap: 467e5b75505Sopenharmony_ci if (pos3 == NULL) 468e5b75505Sopenharmony_ci break; 469e5b75505Sopenharmony_ci start = pos3; 470e5b75505Sopenharmony_ci } 471e5b75505Sopenharmony_ci if (num_methods == 0 && user->ttls_auth == 0 && !user->macacl) { 472e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "No EAP types configured on " 473e5b75505Sopenharmony_ci "line %d in '%s'", line, fname); 474e5b75505Sopenharmony_ci goto failed; 475e5b75505Sopenharmony_ci } 476e5b75505Sopenharmony_ci 477e5b75505Sopenharmony_ci if (pos == NULL) 478e5b75505Sopenharmony_ci goto done; 479e5b75505Sopenharmony_ci 480e5b75505Sopenharmony_ci while (*pos == ' ' || *pos == '\t') 481e5b75505Sopenharmony_ci pos++; 482e5b75505Sopenharmony_ci if (*pos == '\0') 483e5b75505Sopenharmony_ci goto done; 484e5b75505Sopenharmony_ci 485e5b75505Sopenharmony_ci if (os_strncmp(pos, "[ver=0]", 7) == 0) { 486e5b75505Sopenharmony_ci user->force_version = 0; 487e5b75505Sopenharmony_ci goto done; 488e5b75505Sopenharmony_ci } 489e5b75505Sopenharmony_ci 490e5b75505Sopenharmony_ci if (os_strncmp(pos, "[ver=1]", 7) == 0) { 491e5b75505Sopenharmony_ci user->force_version = 1; 492e5b75505Sopenharmony_ci goto done; 493e5b75505Sopenharmony_ci } 494e5b75505Sopenharmony_ci 495e5b75505Sopenharmony_ci if (os_strncmp(pos, "[2]", 3) == 0) { 496e5b75505Sopenharmony_ci user->phase2 = 1; 497e5b75505Sopenharmony_ci goto done; 498e5b75505Sopenharmony_ci } 499e5b75505Sopenharmony_ci 500e5b75505Sopenharmony_ci if (*pos == '"') { 501e5b75505Sopenharmony_ci pos++; 502e5b75505Sopenharmony_ci start = pos; 503e5b75505Sopenharmony_ci while (*pos != '"' && *pos != '\0') 504e5b75505Sopenharmony_ci pos++; 505e5b75505Sopenharmony_ci if (*pos == '\0') { 506e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid EAP password " 507e5b75505Sopenharmony_ci "(no \" in end) on line %d in '%s'", 508e5b75505Sopenharmony_ci line, fname); 509e5b75505Sopenharmony_ci goto failed; 510e5b75505Sopenharmony_ci } 511e5b75505Sopenharmony_ci 512e5b75505Sopenharmony_ci user->password = os_memdup(start, pos - start); 513e5b75505Sopenharmony_ci if (user->password == NULL) { 514e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Failed to allocate " 515e5b75505Sopenharmony_ci "memory for EAP password"); 516e5b75505Sopenharmony_ci goto failed; 517e5b75505Sopenharmony_ci } 518e5b75505Sopenharmony_ci user->password_len = pos - start; 519e5b75505Sopenharmony_ci 520e5b75505Sopenharmony_ci pos++; 521e5b75505Sopenharmony_ci } else if (os_strncmp(pos, "hash:", 5) == 0) { 522e5b75505Sopenharmony_ci pos += 5; 523e5b75505Sopenharmony_ci pos2 = pos; 524e5b75505Sopenharmony_ci while (*pos2 != '\0' && *pos2 != ' ' && 525e5b75505Sopenharmony_ci *pos2 != '\t' && *pos2 != '#') 526e5b75505Sopenharmony_ci pos2++; 527e5b75505Sopenharmony_ci if (pos2 - pos != 32) { 528e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid password hash " 529e5b75505Sopenharmony_ci "on line %d in '%s'", line, fname); 530e5b75505Sopenharmony_ci goto failed; 531e5b75505Sopenharmony_ci } 532e5b75505Sopenharmony_ci user->password = os_malloc(16); 533e5b75505Sopenharmony_ci if (user->password == NULL) { 534e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Failed to allocate " 535e5b75505Sopenharmony_ci "memory for EAP password hash"); 536e5b75505Sopenharmony_ci goto failed; 537e5b75505Sopenharmony_ci } 538e5b75505Sopenharmony_ci if (hexstr2bin(pos, user->password, 16) < 0) { 539e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid hash password " 540e5b75505Sopenharmony_ci "on line %d in '%s'", line, fname); 541e5b75505Sopenharmony_ci goto failed; 542e5b75505Sopenharmony_ci } 543e5b75505Sopenharmony_ci user->password_len = 16; 544e5b75505Sopenharmony_ci user->password_hash = 1; 545e5b75505Sopenharmony_ci pos = pos2; 546e5b75505Sopenharmony_ci } else if (os_strncmp(pos, "ssha1:", 6) == 0) { 547e5b75505Sopenharmony_ci pos += 6; 548e5b75505Sopenharmony_ci if (hostapd_config_eap_user_salted(user, "sha1", 20, 549e5b75505Sopenharmony_ci &pos, 550e5b75505Sopenharmony_ci line, fname) < 0) 551e5b75505Sopenharmony_ci goto failed; 552e5b75505Sopenharmony_ci } else if (os_strncmp(pos, "ssha256:", 8) == 0) { 553e5b75505Sopenharmony_ci pos += 8; 554e5b75505Sopenharmony_ci if (hostapd_config_eap_user_salted(user, "sha256", 32, 555e5b75505Sopenharmony_ci &pos, 556e5b75505Sopenharmony_ci line, fname) < 0) 557e5b75505Sopenharmony_ci goto failed; 558e5b75505Sopenharmony_ci } else if (os_strncmp(pos, "ssha512:", 8) == 0) { 559e5b75505Sopenharmony_ci pos += 8; 560e5b75505Sopenharmony_ci if (hostapd_config_eap_user_salted(user, "sha512", 64, 561e5b75505Sopenharmony_ci &pos, 562e5b75505Sopenharmony_ci line, fname) < 0) 563e5b75505Sopenharmony_ci goto failed; 564e5b75505Sopenharmony_ci } else { 565e5b75505Sopenharmony_ci pos2 = pos; 566e5b75505Sopenharmony_ci while (*pos2 != '\0' && *pos2 != ' ' && 567e5b75505Sopenharmony_ci *pos2 != '\t' && *pos2 != '#') 568e5b75505Sopenharmony_ci pos2++; 569e5b75505Sopenharmony_ci if ((pos2 - pos) & 1) { 570e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid hex password " 571e5b75505Sopenharmony_ci "on line %d in '%s'", line, fname); 572e5b75505Sopenharmony_ci goto failed; 573e5b75505Sopenharmony_ci } 574e5b75505Sopenharmony_ci user->password = os_malloc((pos2 - pos) / 2); 575e5b75505Sopenharmony_ci if (user->password == NULL) { 576e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Failed to allocate " 577e5b75505Sopenharmony_ci "memory for EAP password"); 578e5b75505Sopenharmony_ci goto failed; 579e5b75505Sopenharmony_ci } 580e5b75505Sopenharmony_ci if (hexstr2bin(pos, user->password, 581e5b75505Sopenharmony_ci (pos2 - pos) / 2) < 0) { 582e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid hex password " 583e5b75505Sopenharmony_ci "on line %d in '%s'", line, fname); 584e5b75505Sopenharmony_ci goto failed; 585e5b75505Sopenharmony_ci } 586e5b75505Sopenharmony_ci user->password_len = (pos2 - pos) / 2; 587e5b75505Sopenharmony_ci pos = pos2; 588e5b75505Sopenharmony_ci } 589e5b75505Sopenharmony_ci 590e5b75505Sopenharmony_ci while (*pos == ' ' || *pos == '\t') 591e5b75505Sopenharmony_ci pos++; 592e5b75505Sopenharmony_ci if (os_strncmp(pos, "[2]", 3) == 0) { 593e5b75505Sopenharmony_ci user->phase2 = 1; 594e5b75505Sopenharmony_ci } 595e5b75505Sopenharmony_ci 596e5b75505Sopenharmony_ci done: 597e5b75505Sopenharmony_ci if (tail == NULL) { 598e5b75505Sopenharmony_ci tail = new_user = user; 599e5b75505Sopenharmony_ci } else { 600e5b75505Sopenharmony_ci tail->next = user; 601e5b75505Sopenharmony_ci tail = user; 602e5b75505Sopenharmony_ci } 603e5b75505Sopenharmony_ci continue; 604e5b75505Sopenharmony_ci 605e5b75505Sopenharmony_ci failed: 606e5b75505Sopenharmony_ci if (user) 607e5b75505Sopenharmony_ci hostapd_config_free_eap_user(user); 608e5b75505Sopenharmony_ci ret = -1; 609e5b75505Sopenharmony_ci break; 610e5b75505Sopenharmony_ci } 611e5b75505Sopenharmony_ci 612e5b75505Sopenharmony_ci fclose(f); 613e5b75505Sopenharmony_ci 614e5b75505Sopenharmony_ci if (ret == 0) { 615e5b75505Sopenharmony_ci hostapd_config_free_eap_users(conf->eap_user); 616e5b75505Sopenharmony_ci conf->eap_user = new_user; 617e5b75505Sopenharmony_ci } else { 618e5b75505Sopenharmony_ci hostapd_config_free_eap_users(new_user); 619e5b75505Sopenharmony_ci } 620e5b75505Sopenharmony_ci 621e5b75505Sopenharmony_ci return ret; 622e5b75505Sopenharmony_ci} 623e5b75505Sopenharmony_ci 624e5b75505Sopenharmony_ci#endif /* EAP_SERVER */ 625e5b75505Sopenharmony_ci 626e5b75505Sopenharmony_ci 627e5b75505Sopenharmony_ci#ifndef CONFIG_NO_RADIUS 628e5b75505Sopenharmony_cistatic int 629e5b75505Sopenharmony_cihostapd_config_read_radius_addr(struct hostapd_radius_server **server, 630e5b75505Sopenharmony_ci int *num_server, const char *val, int def_port, 631e5b75505Sopenharmony_ci struct hostapd_radius_server **curr_serv) 632e5b75505Sopenharmony_ci{ 633e5b75505Sopenharmony_ci struct hostapd_radius_server *nserv; 634e5b75505Sopenharmony_ci int ret; 635e5b75505Sopenharmony_ci static int server_index = 1; 636e5b75505Sopenharmony_ci 637e5b75505Sopenharmony_ci nserv = os_realloc_array(*server, *num_server + 1, sizeof(*nserv)); 638e5b75505Sopenharmony_ci if (nserv == NULL) 639e5b75505Sopenharmony_ci return -1; 640e5b75505Sopenharmony_ci 641e5b75505Sopenharmony_ci *server = nserv; 642e5b75505Sopenharmony_ci nserv = &nserv[*num_server]; 643e5b75505Sopenharmony_ci (*num_server)++; 644e5b75505Sopenharmony_ci (*curr_serv) = nserv; 645e5b75505Sopenharmony_ci 646e5b75505Sopenharmony_ci os_memset(nserv, 0, sizeof(*nserv)); 647e5b75505Sopenharmony_ci nserv->port = def_port; 648e5b75505Sopenharmony_ci ret = hostapd_parse_ip_addr(val, &nserv->addr); 649e5b75505Sopenharmony_ci nserv->index = server_index++; 650e5b75505Sopenharmony_ci 651e5b75505Sopenharmony_ci return ret; 652e5b75505Sopenharmony_ci} 653e5b75505Sopenharmony_ci 654e5b75505Sopenharmony_ci 655e5b75505Sopenharmony_ci 656e5b75505Sopenharmony_cistatic int hostapd_parse_das_client(struct hostapd_bss_config *bss, char *val) 657e5b75505Sopenharmony_ci{ 658e5b75505Sopenharmony_ci char *secret; 659e5b75505Sopenharmony_ci 660e5b75505Sopenharmony_ci secret = os_strchr(val, ' '); 661e5b75505Sopenharmony_ci if (secret == NULL) 662e5b75505Sopenharmony_ci return -1; 663e5b75505Sopenharmony_ci 664e5b75505Sopenharmony_ci *secret++ = '\0'; 665e5b75505Sopenharmony_ci 666e5b75505Sopenharmony_ci if (hostapd_parse_ip_addr(val, &bss->radius_das_client_addr)) 667e5b75505Sopenharmony_ci return -1; 668e5b75505Sopenharmony_ci 669e5b75505Sopenharmony_ci os_free(bss->radius_das_shared_secret); 670e5b75505Sopenharmony_ci bss->radius_das_shared_secret = (u8 *) os_strdup(secret); 671e5b75505Sopenharmony_ci if (bss->radius_das_shared_secret == NULL) 672e5b75505Sopenharmony_ci return -1; 673e5b75505Sopenharmony_ci bss->radius_das_shared_secret_len = os_strlen(secret); 674e5b75505Sopenharmony_ci 675e5b75505Sopenharmony_ci return 0; 676e5b75505Sopenharmony_ci} 677e5b75505Sopenharmony_ci#endif /* CONFIG_NO_RADIUS */ 678e5b75505Sopenharmony_ci 679e5b75505Sopenharmony_ci 680e5b75505Sopenharmony_cistatic int hostapd_config_parse_key_mgmt(int line, const char *value) 681e5b75505Sopenharmony_ci{ 682e5b75505Sopenharmony_ci int val = 0, last; 683e5b75505Sopenharmony_ci char *start, *end, *buf; 684e5b75505Sopenharmony_ci 685e5b75505Sopenharmony_ci buf = os_strdup(value); 686e5b75505Sopenharmony_ci if (buf == NULL) 687e5b75505Sopenharmony_ci return -1; 688e5b75505Sopenharmony_ci start = buf; 689e5b75505Sopenharmony_ci 690e5b75505Sopenharmony_ci while (*start != '\0') { 691e5b75505Sopenharmony_ci while (*start == ' ' || *start == '\t') 692e5b75505Sopenharmony_ci start++; 693e5b75505Sopenharmony_ci if (*start == '\0') 694e5b75505Sopenharmony_ci break; 695e5b75505Sopenharmony_ci end = start; 696e5b75505Sopenharmony_ci while (*end != ' ' && *end != '\t' && *end != '\0') 697e5b75505Sopenharmony_ci end++; 698e5b75505Sopenharmony_ci last = *end == '\0'; 699e5b75505Sopenharmony_ci *end = '\0'; 700e5b75505Sopenharmony_ci if (os_strcmp(start, "WPA-PSK") == 0) 701e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_PSK; 702e5b75505Sopenharmony_ci else if (os_strcmp(start, "WPA-EAP") == 0) 703e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_IEEE8021X; 704e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211R_AP 705e5b75505Sopenharmony_ci else if (os_strcmp(start, "FT-PSK") == 0) 706e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FT_PSK; 707e5b75505Sopenharmony_ci else if (os_strcmp(start, "FT-EAP") == 0) 708e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FT_IEEE8021X; 709e5b75505Sopenharmony_ci#ifdef CONFIG_SHA384 710e5b75505Sopenharmony_ci else if (os_strcmp(start, "FT-EAP-SHA384") == 0) 711e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FT_IEEE8021X_SHA384; 712e5b75505Sopenharmony_ci#endif /* CONFIG_SHA384 */ 713e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211R_AP */ 714e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211W 715e5b75505Sopenharmony_ci else if (os_strcmp(start, "WPA-PSK-SHA256") == 0) 716e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_PSK_SHA256; 717e5b75505Sopenharmony_ci else if (os_strcmp(start, "WPA-EAP-SHA256") == 0) 718e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_IEEE8021X_SHA256; 719e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211W */ 720e5b75505Sopenharmony_ci#ifdef CONFIG_SAE 721e5b75505Sopenharmony_ci else if (os_strcmp(start, "SAE") == 0) 722e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_SAE; 723e5b75505Sopenharmony_ci else if (os_strcmp(start, "FT-SAE") == 0) 724e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FT_SAE; 725e5b75505Sopenharmony_ci#endif /* CONFIG_SAE */ 726e5b75505Sopenharmony_ci#ifdef CONFIG_SUITEB 727e5b75505Sopenharmony_ci else if (os_strcmp(start, "WPA-EAP-SUITE-B") == 0) 728e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_IEEE8021X_SUITE_B; 729e5b75505Sopenharmony_ci#endif /* CONFIG_SUITEB */ 730e5b75505Sopenharmony_ci#ifdef CONFIG_SUITEB192 731e5b75505Sopenharmony_ci else if (os_strcmp(start, "WPA-EAP-SUITE-B-192") == 0) 732e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192; 733e5b75505Sopenharmony_ci#endif /* CONFIG_SUITEB192 */ 734e5b75505Sopenharmony_ci#ifdef CONFIG_FILS 735e5b75505Sopenharmony_ci else if (os_strcmp(start, "FILS-SHA256") == 0) 736e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FILS_SHA256; 737e5b75505Sopenharmony_ci else if (os_strcmp(start, "FILS-SHA384") == 0) 738e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FILS_SHA384; 739e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211R_AP 740e5b75505Sopenharmony_ci else if (os_strcmp(start, "FT-FILS-SHA256") == 0) 741e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FT_FILS_SHA256; 742e5b75505Sopenharmony_ci else if (os_strcmp(start, "FT-FILS-SHA384") == 0) 743e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_FT_FILS_SHA384; 744e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211R_AP */ 745e5b75505Sopenharmony_ci#endif /* CONFIG_FILS */ 746e5b75505Sopenharmony_ci#ifdef CONFIG_OWE 747e5b75505Sopenharmony_ci else if (os_strcmp(start, "OWE") == 0) 748e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_OWE; 749e5b75505Sopenharmony_ci#endif /* CONFIG_OWE */ 750e5b75505Sopenharmony_ci#ifdef CONFIG_DPP 751e5b75505Sopenharmony_ci else if (os_strcmp(start, "DPP") == 0) 752e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_DPP; 753e5b75505Sopenharmony_ci#endif /* CONFIG_DPP */ 754e5b75505Sopenharmony_ci#ifdef CONFIG_HS20 755e5b75505Sopenharmony_ci else if (os_strcmp(start, "OSEN") == 0) 756e5b75505Sopenharmony_ci val |= WPA_KEY_MGMT_OSEN; 757e5b75505Sopenharmony_ci#endif /* CONFIG_HS20 */ 758e5b75505Sopenharmony_ci else { 759e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid key_mgmt '%s'", 760e5b75505Sopenharmony_ci line, start); 761e5b75505Sopenharmony_ci os_free(buf); 762e5b75505Sopenharmony_ci return -1; 763e5b75505Sopenharmony_ci } 764e5b75505Sopenharmony_ci 765e5b75505Sopenharmony_ci if (last) 766e5b75505Sopenharmony_ci break; 767e5b75505Sopenharmony_ci start = end + 1; 768e5b75505Sopenharmony_ci } 769e5b75505Sopenharmony_ci 770e5b75505Sopenharmony_ci os_free(buf); 771e5b75505Sopenharmony_ci if (val == 0) { 772e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: no key_mgmt values " 773e5b75505Sopenharmony_ci "configured.", line); 774e5b75505Sopenharmony_ci return -1; 775e5b75505Sopenharmony_ci } 776e5b75505Sopenharmony_ci 777e5b75505Sopenharmony_ci return val; 778e5b75505Sopenharmony_ci} 779e5b75505Sopenharmony_ci 780e5b75505Sopenharmony_ci 781e5b75505Sopenharmony_cistatic int hostapd_config_parse_cipher(int line, const char *value) 782e5b75505Sopenharmony_ci{ 783e5b75505Sopenharmony_ci int val = wpa_parse_cipher(value); 784e5b75505Sopenharmony_ci if (val < 0) { 785e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid cipher '%s'.", 786e5b75505Sopenharmony_ci line, value); 787e5b75505Sopenharmony_ci return -1; 788e5b75505Sopenharmony_ci } 789e5b75505Sopenharmony_ci if (val == 0) { 790e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: no cipher values configured.", 791e5b75505Sopenharmony_ci line); 792e5b75505Sopenharmony_ci return -1; 793e5b75505Sopenharmony_ci } 794e5b75505Sopenharmony_ci return val; 795e5b75505Sopenharmony_ci} 796e5b75505Sopenharmony_ci 797e5b75505Sopenharmony_ci 798e5b75505Sopenharmony_cistatic int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx, 799e5b75505Sopenharmony_ci char *val) 800e5b75505Sopenharmony_ci{ 801e5b75505Sopenharmony_ci size_t len = os_strlen(val); 802e5b75505Sopenharmony_ci 803e5b75505Sopenharmony_ci if (keyidx < 0 || keyidx > 3) 804e5b75505Sopenharmony_ci return -1; 805e5b75505Sopenharmony_ci 806e5b75505Sopenharmony_ci if (len == 0) { 807e5b75505Sopenharmony_ci int i, set = 0; 808e5b75505Sopenharmony_ci 809e5b75505Sopenharmony_ci bin_clear_free(wep->key[keyidx], wep->len[keyidx]); 810e5b75505Sopenharmony_ci wep->key[keyidx] = NULL; 811e5b75505Sopenharmony_ci wep->len[keyidx] = 0; 812e5b75505Sopenharmony_ci for (i = 0; i < NUM_WEP_KEYS; i++) { 813e5b75505Sopenharmony_ci if (wep->key[i]) 814e5b75505Sopenharmony_ci set++; 815e5b75505Sopenharmony_ci } 816e5b75505Sopenharmony_ci if (!set) 817e5b75505Sopenharmony_ci wep->keys_set = 0; 818e5b75505Sopenharmony_ci return 0; 819e5b75505Sopenharmony_ci } 820e5b75505Sopenharmony_ci 821e5b75505Sopenharmony_ci if (wep->key[keyidx] != NULL) 822e5b75505Sopenharmony_ci return -1; 823e5b75505Sopenharmony_ci 824e5b75505Sopenharmony_ci if (val[0] == '"') { 825e5b75505Sopenharmony_ci if (len < 2 || val[len - 1] != '"') 826e5b75505Sopenharmony_ci return -1; 827e5b75505Sopenharmony_ci len -= 2; 828e5b75505Sopenharmony_ci wep->key[keyidx] = os_memdup(val + 1, len); 829e5b75505Sopenharmony_ci if (wep->key[keyidx] == NULL) 830e5b75505Sopenharmony_ci return -1; 831e5b75505Sopenharmony_ci wep->len[keyidx] = len; 832e5b75505Sopenharmony_ci } else { 833e5b75505Sopenharmony_ci if (len & 1) 834e5b75505Sopenharmony_ci return -1; 835e5b75505Sopenharmony_ci len /= 2; 836e5b75505Sopenharmony_ci wep->key[keyidx] = os_malloc(len); 837e5b75505Sopenharmony_ci if (wep->key[keyidx] == NULL) 838e5b75505Sopenharmony_ci return -1; 839e5b75505Sopenharmony_ci wep->len[keyidx] = len; 840e5b75505Sopenharmony_ci if (hexstr2bin(val, wep->key[keyidx], len) < 0) 841e5b75505Sopenharmony_ci return -1; 842e5b75505Sopenharmony_ci } 843e5b75505Sopenharmony_ci 844e5b75505Sopenharmony_ci wep->keys_set++; 845e5b75505Sopenharmony_ci 846e5b75505Sopenharmony_ci return 0; 847e5b75505Sopenharmony_ci} 848e5b75505Sopenharmony_ci 849e5b75505Sopenharmony_ci 850e5b75505Sopenharmony_cistatic int hostapd_parse_chanlist(struct hostapd_config *conf, char *val) 851e5b75505Sopenharmony_ci{ 852e5b75505Sopenharmony_ci char *pos; 853e5b75505Sopenharmony_ci 854e5b75505Sopenharmony_ci /* for backwards compatibility, translate ' ' in conf str to ',' */ 855e5b75505Sopenharmony_ci pos = val; 856e5b75505Sopenharmony_ci while (pos) { 857e5b75505Sopenharmony_ci pos = os_strchr(pos, ' '); 858e5b75505Sopenharmony_ci if (pos) 859e5b75505Sopenharmony_ci *pos++ = ','; 860e5b75505Sopenharmony_ci } 861e5b75505Sopenharmony_ci if (freq_range_list_parse(&conf->acs_ch_list, val)) 862e5b75505Sopenharmony_ci return -1; 863e5b75505Sopenharmony_ci 864e5b75505Sopenharmony_ci return 0; 865e5b75505Sopenharmony_ci} 866e5b75505Sopenharmony_ci 867e5b75505Sopenharmony_ci 868e5b75505Sopenharmony_cistatic int hostapd_parse_intlist(int **int_list, char *val) 869e5b75505Sopenharmony_ci{ 870e5b75505Sopenharmony_ci int *list; 871e5b75505Sopenharmony_ci int count; 872e5b75505Sopenharmony_ci char *pos, *end; 873e5b75505Sopenharmony_ci 874e5b75505Sopenharmony_ci os_free(*int_list); 875e5b75505Sopenharmony_ci *int_list = NULL; 876e5b75505Sopenharmony_ci 877e5b75505Sopenharmony_ci pos = val; 878e5b75505Sopenharmony_ci count = 0; 879e5b75505Sopenharmony_ci while (*pos != '\0') { 880e5b75505Sopenharmony_ci if (*pos == ' ') 881e5b75505Sopenharmony_ci count++; 882e5b75505Sopenharmony_ci pos++; 883e5b75505Sopenharmony_ci } 884e5b75505Sopenharmony_ci 885e5b75505Sopenharmony_ci list = os_malloc(sizeof(int) * (count + 2)); 886e5b75505Sopenharmony_ci if (list == NULL) 887e5b75505Sopenharmony_ci return -1; 888e5b75505Sopenharmony_ci pos = val; 889e5b75505Sopenharmony_ci count = 0; 890e5b75505Sopenharmony_ci while (*pos != '\0') { 891e5b75505Sopenharmony_ci end = os_strchr(pos, ' '); 892e5b75505Sopenharmony_ci if (end) 893e5b75505Sopenharmony_ci *end = '\0'; 894e5b75505Sopenharmony_ci 895e5b75505Sopenharmony_ci list[count++] = atoi(pos); 896e5b75505Sopenharmony_ci if (!end) 897e5b75505Sopenharmony_ci break; 898e5b75505Sopenharmony_ci pos = end + 1; 899e5b75505Sopenharmony_ci } 900e5b75505Sopenharmony_ci list[count] = -1; 901e5b75505Sopenharmony_ci 902e5b75505Sopenharmony_ci *int_list = list; 903e5b75505Sopenharmony_ci return 0; 904e5b75505Sopenharmony_ci} 905e5b75505Sopenharmony_ci 906e5b75505Sopenharmony_ci 907e5b75505Sopenharmony_cistatic int hostapd_config_bss(struct hostapd_config *conf, const char *ifname) 908e5b75505Sopenharmony_ci{ 909e5b75505Sopenharmony_ci struct hostapd_bss_config **all, *bss; 910e5b75505Sopenharmony_ci 911e5b75505Sopenharmony_ci if (*ifname == '\0') 912e5b75505Sopenharmony_ci return -1; 913e5b75505Sopenharmony_ci 914e5b75505Sopenharmony_ci all = os_realloc_array(conf->bss, conf->num_bss + 1, 915e5b75505Sopenharmony_ci sizeof(struct hostapd_bss_config *)); 916e5b75505Sopenharmony_ci if (all == NULL) { 917e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Failed to allocate memory for " 918e5b75505Sopenharmony_ci "multi-BSS entry"); 919e5b75505Sopenharmony_ci return -1; 920e5b75505Sopenharmony_ci } 921e5b75505Sopenharmony_ci conf->bss = all; 922e5b75505Sopenharmony_ci 923e5b75505Sopenharmony_ci bss = os_zalloc(sizeof(*bss)); 924e5b75505Sopenharmony_ci if (bss == NULL) 925e5b75505Sopenharmony_ci return -1; 926e5b75505Sopenharmony_ci bss->radius = os_zalloc(sizeof(*bss->radius)); 927e5b75505Sopenharmony_ci if (bss->radius == NULL) { 928e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Failed to allocate memory for " 929e5b75505Sopenharmony_ci "multi-BSS RADIUS data"); 930e5b75505Sopenharmony_ci os_free(bss); 931e5b75505Sopenharmony_ci return -1; 932e5b75505Sopenharmony_ci } 933e5b75505Sopenharmony_ci 934e5b75505Sopenharmony_ci conf->bss[conf->num_bss++] = bss; 935e5b75505Sopenharmony_ci conf->last_bss = bss; 936e5b75505Sopenharmony_ci 937e5b75505Sopenharmony_ci hostapd_config_defaults_bss(bss); 938e5b75505Sopenharmony_ci os_strlcpy(bss->iface, ifname, sizeof(bss->iface)); 939e5b75505Sopenharmony_ci os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1); 940e5b75505Sopenharmony_ci 941e5b75505Sopenharmony_ci return 0; 942e5b75505Sopenharmony_ci} 943e5b75505Sopenharmony_ci 944e5b75505Sopenharmony_ci 945e5b75505Sopenharmony_ci/* convert floats with one decimal place to value*10 int, i.e., 946e5b75505Sopenharmony_ci * "1.5" will return 15 */ 947e5b75505Sopenharmony_cistatic int hostapd_config_read_int10(const char *value) 948e5b75505Sopenharmony_ci{ 949e5b75505Sopenharmony_ci int i, d; 950e5b75505Sopenharmony_ci char *pos; 951e5b75505Sopenharmony_ci 952e5b75505Sopenharmony_ci i = atoi(value); 953e5b75505Sopenharmony_ci pos = os_strchr(value, '.'); 954e5b75505Sopenharmony_ci d = 0; 955e5b75505Sopenharmony_ci if (pos) { 956e5b75505Sopenharmony_ci pos++; 957e5b75505Sopenharmony_ci if (*pos >= '0' && *pos <= '9') 958e5b75505Sopenharmony_ci d = *pos - '0'; 959e5b75505Sopenharmony_ci } 960e5b75505Sopenharmony_ci 961e5b75505Sopenharmony_ci return i * 10 + d; 962e5b75505Sopenharmony_ci} 963e5b75505Sopenharmony_ci 964e5b75505Sopenharmony_ci 965e5b75505Sopenharmony_cistatic int valid_cw(int cw) 966e5b75505Sopenharmony_ci{ 967e5b75505Sopenharmony_ci return (cw == 1 || cw == 3 || cw == 7 || cw == 15 || cw == 31 || 968e5b75505Sopenharmony_ci cw == 63 || cw == 127 || cw == 255 || cw == 511 || cw == 1023 || 969e5b75505Sopenharmony_ci cw == 2047 || cw == 4095 || cw == 8191 || cw == 16383 || 970e5b75505Sopenharmony_ci cw == 32767); 971e5b75505Sopenharmony_ci} 972e5b75505Sopenharmony_ci 973e5b75505Sopenharmony_ci 974e5b75505Sopenharmony_cienum { 975e5b75505Sopenharmony_ci IEEE80211_TX_QUEUE_DATA0 = 0, /* used for EDCA AC_VO data */ 976e5b75505Sopenharmony_ci IEEE80211_TX_QUEUE_DATA1 = 1, /* used for EDCA AC_VI data */ 977e5b75505Sopenharmony_ci IEEE80211_TX_QUEUE_DATA2 = 2, /* used for EDCA AC_BE data */ 978e5b75505Sopenharmony_ci IEEE80211_TX_QUEUE_DATA3 = 3 /* used for EDCA AC_BK data */ 979e5b75505Sopenharmony_ci}; 980e5b75505Sopenharmony_ci 981e5b75505Sopenharmony_cistatic int hostapd_config_tx_queue(struct hostapd_config *conf, 982e5b75505Sopenharmony_ci const char *name, const char *val) 983e5b75505Sopenharmony_ci{ 984e5b75505Sopenharmony_ci int num; 985e5b75505Sopenharmony_ci const char *pos; 986e5b75505Sopenharmony_ci struct hostapd_tx_queue_params *queue; 987e5b75505Sopenharmony_ci 988e5b75505Sopenharmony_ci /* skip 'tx_queue_' prefix */ 989e5b75505Sopenharmony_ci pos = name + 9; 990e5b75505Sopenharmony_ci if (os_strncmp(pos, "data", 4) == 0 && 991e5b75505Sopenharmony_ci pos[4] >= '0' && pos[4] <= '9' && pos[5] == '_') { 992e5b75505Sopenharmony_ci num = pos[4] - '0'; 993e5b75505Sopenharmony_ci pos += 6; 994e5b75505Sopenharmony_ci } else if (os_strncmp(pos, "after_beacon_", 13) == 0 || 995e5b75505Sopenharmony_ci os_strncmp(pos, "beacon_", 7) == 0) { 996e5b75505Sopenharmony_ci wpa_printf(MSG_INFO, "DEPRECATED: '%s' not used", name); 997e5b75505Sopenharmony_ci return 0; 998e5b75505Sopenharmony_ci } else { 999e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Unknown tx_queue name '%s'", pos); 1000e5b75505Sopenharmony_ci return -1; 1001e5b75505Sopenharmony_ci } 1002e5b75505Sopenharmony_ci 1003e5b75505Sopenharmony_ci if (num >= NUM_TX_QUEUES) { 1004e5b75505Sopenharmony_ci /* for backwards compatibility, do not trigger failure */ 1005e5b75505Sopenharmony_ci wpa_printf(MSG_INFO, "DEPRECATED: '%s' not used", name); 1006e5b75505Sopenharmony_ci return 0; 1007e5b75505Sopenharmony_ci } 1008e5b75505Sopenharmony_ci 1009e5b75505Sopenharmony_ci queue = &conf->tx_queue[num]; 1010e5b75505Sopenharmony_ci 1011e5b75505Sopenharmony_ci if (os_strcmp(pos, "aifs") == 0) { 1012e5b75505Sopenharmony_ci queue->aifs = atoi(val); 1013e5b75505Sopenharmony_ci if (queue->aifs < 0 || queue->aifs > 255) { 1014e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid AIFS value %d", 1015e5b75505Sopenharmony_ci queue->aifs); 1016e5b75505Sopenharmony_ci return -1; 1017e5b75505Sopenharmony_ci } 1018e5b75505Sopenharmony_ci } else if (os_strcmp(pos, "cwmin") == 0) { 1019e5b75505Sopenharmony_ci queue->cwmin = atoi(val); 1020e5b75505Sopenharmony_ci if (!valid_cw(queue->cwmin)) { 1021e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid cwMin value %d", 1022e5b75505Sopenharmony_ci queue->cwmin); 1023e5b75505Sopenharmony_ci return -1; 1024e5b75505Sopenharmony_ci } 1025e5b75505Sopenharmony_ci } else if (os_strcmp(pos, "cwmax") == 0) { 1026e5b75505Sopenharmony_ci queue->cwmax = atoi(val); 1027e5b75505Sopenharmony_ci if (!valid_cw(queue->cwmax)) { 1028e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid cwMax value %d", 1029e5b75505Sopenharmony_ci queue->cwmax); 1030e5b75505Sopenharmony_ci return -1; 1031e5b75505Sopenharmony_ci } 1032e5b75505Sopenharmony_ci } else if (os_strcmp(pos, "burst") == 0) { 1033e5b75505Sopenharmony_ci queue->burst = hostapd_config_read_int10(val); 1034e5b75505Sopenharmony_ci } else { 1035e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Unknown tx_queue field '%s'", pos); 1036e5b75505Sopenharmony_ci return -1; 1037e5b75505Sopenharmony_ci } 1038e5b75505Sopenharmony_ci 1039e5b75505Sopenharmony_ci return 0; 1040e5b75505Sopenharmony_ci} 1041e5b75505Sopenharmony_ci 1042e5b75505Sopenharmony_ci 1043e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211R_AP 1044e5b75505Sopenharmony_ci 1045e5b75505Sopenharmony_cistatic int rkh_derive_key(const char *pos, u8 *key, size_t key_len) 1046e5b75505Sopenharmony_ci{ 1047e5b75505Sopenharmony_ci u8 oldkey[16]; 1048e5b75505Sopenharmony_ci int ret; 1049e5b75505Sopenharmony_ci 1050e5b75505Sopenharmony_ci if (!hexstr2bin(pos, key, key_len)) 1051e5b75505Sopenharmony_ci return 0; 1052e5b75505Sopenharmony_ci 1053e5b75505Sopenharmony_ci /* Try to use old short key for backwards compatibility */ 1054e5b75505Sopenharmony_ci if (hexstr2bin(pos, oldkey, sizeof(oldkey))) 1055e5b75505Sopenharmony_ci return -1; 1056e5b75505Sopenharmony_ci 1057e5b75505Sopenharmony_ci ret = hmac_sha256_kdf(oldkey, sizeof(oldkey), "FT OLDKEY", NULL, 0, 1058e5b75505Sopenharmony_ci key, key_len); 1059e5b75505Sopenharmony_ci os_memset(oldkey, 0, sizeof(oldkey)); 1060e5b75505Sopenharmony_ci return ret; 1061e5b75505Sopenharmony_ci} 1062e5b75505Sopenharmony_ci 1063e5b75505Sopenharmony_ci 1064e5b75505Sopenharmony_cistatic int add_r0kh(struct hostapd_bss_config *bss, char *value) 1065e5b75505Sopenharmony_ci{ 1066e5b75505Sopenharmony_ci struct ft_remote_r0kh *r0kh; 1067e5b75505Sopenharmony_ci char *pos, *next; 1068e5b75505Sopenharmony_ci 1069e5b75505Sopenharmony_ci r0kh = os_zalloc(sizeof(*r0kh)); 1070e5b75505Sopenharmony_ci if (r0kh == NULL) 1071e5b75505Sopenharmony_ci return -1; 1072e5b75505Sopenharmony_ci 1073e5b75505Sopenharmony_ci /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */ 1074e5b75505Sopenharmony_ci pos = value; 1075e5b75505Sopenharmony_ci next = os_strchr(pos, ' '); 1076e5b75505Sopenharmony_ci if (next) 1077e5b75505Sopenharmony_ci *next++ = '\0'; 1078e5b75505Sopenharmony_ci if (next == NULL || hwaddr_aton(pos, r0kh->addr)) { 1079e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid R0KH MAC address: '%s'", pos); 1080e5b75505Sopenharmony_ci os_free(r0kh); 1081e5b75505Sopenharmony_ci return -1; 1082e5b75505Sopenharmony_ci } 1083e5b75505Sopenharmony_ci 1084e5b75505Sopenharmony_ci pos = next; 1085e5b75505Sopenharmony_ci next = os_strchr(pos, ' '); 1086e5b75505Sopenharmony_ci if (next) 1087e5b75505Sopenharmony_ci *next++ = '\0'; 1088e5b75505Sopenharmony_ci if (next == NULL || next - pos > FT_R0KH_ID_MAX_LEN) { 1089e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid R0KH-ID: '%s'", pos); 1090e5b75505Sopenharmony_ci os_free(r0kh); 1091e5b75505Sopenharmony_ci return -1; 1092e5b75505Sopenharmony_ci } 1093e5b75505Sopenharmony_ci r0kh->id_len = next - pos - 1; 1094e5b75505Sopenharmony_ci os_memcpy(r0kh->id, pos, r0kh->id_len); 1095e5b75505Sopenharmony_ci 1096e5b75505Sopenharmony_ci pos = next; 1097e5b75505Sopenharmony_ci if (rkh_derive_key(pos, r0kh->key, sizeof(r0kh->key)) < 0) { 1098e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid R0KH key: '%s'", pos); 1099e5b75505Sopenharmony_ci os_free(r0kh); 1100e5b75505Sopenharmony_ci return -1; 1101e5b75505Sopenharmony_ci } 1102e5b75505Sopenharmony_ci 1103e5b75505Sopenharmony_ci r0kh->next = bss->r0kh_list; 1104e5b75505Sopenharmony_ci bss->r0kh_list = r0kh; 1105e5b75505Sopenharmony_ci 1106e5b75505Sopenharmony_ci return 0; 1107e5b75505Sopenharmony_ci} 1108e5b75505Sopenharmony_ci 1109e5b75505Sopenharmony_ci 1110e5b75505Sopenharmony_cistatic int add_r1kh(struct hostapd_bss_config *bss, char *value) 1111e5b75505Sopenharmony_ci{ 1112e5b75505Sopenharmony_ci struct ft_remote_r1kh *r1kh; 1113e5b75505Sopenharmony_ci char *pos, *next; 1114e5b75505Sopenharmony_ci 1115e5b75505Sopenharmony_ci r1kh = os_zalloc(sizeof(*r1kh)); 1116e5b75505Sopenharmony_ci if (r1kh == NULL) 1117e5b75505Sopenharmony_ci return -1; 1118e5b75505Sopenharmony_ci 1119e5b75505Sopenharmony_ci /* 02:01:02:03:04:05 02:01:02:03:04:05 1120e5b75505Sopenharmony_ci * 000102030405060708090a0b0c0d0e0f */ 1121e5b75505Sopenharmony_ci pos = value; 1122e5b75505Sopenharmony_ci next = os_strchr(pos, ' '); 1123e5b75505Sopenharmony_ci if (next) 1124e5b75505Sopenharmony_ci *next++ = '\0'; 1125e5b75505Sopenharmony_ci if (next == NULL || hwaddr_aton(pos, r1kh->addr)) { 1126e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid R1KH MAC address: '%s'", pos); 1127e5b75505Sopenharmony_ci os_free(r1kh); 1128e5b75505Sopenharmony_ci return -1; 1129e5b75505Sopenharmony_ci } 1130e5b75505Sopenharmony_ci 1131e5b75505Sopenharmony_ci pos = next; 1132e5b75505Sopenharmony_ci next = os_strchr(pos, ' '); 1133e5b75505Sopenharmony_ci if (next) 1134e5b75505Sopenharmony_ci *next++ = '\0'; 1135e5b75505Sopenharmony_ci if (next == NULL || hwaddr_aton(pos, r1kh->id)) { 1136e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid R1KH-ID: '%s'", pos); 1137e5b75505Sopenharmony_ci os_free(r1kh); 1138e5b75505Sopenharmony_ci return -1; 1139e5b75505Sopenharmony_ci } 1140e5b75505Sopenharmony_ci 1141e5b75505Sopenharmony_ci pos = next; 1142e5b75505Sopenharmony_ci if (rkh_derive_key(pos, r1kh->key, sizeof(r1kh->key)) < 0) { 1143e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid R1KH key: '%s'", pos); 1144e5b75505Sopenharmony_ci os_free(r1kh); 1145e5b75505Sopenharmony_ci return -1; 1146e5b75505Sopenharmony_ci } 1147e5b75505Sopenharmony_ci 1148e5b75505Sopenharmony_ci r1kh->next = bss->r1kh_list; 1149e5b75505Sopenharmony_ci bss->r1kh_list = r1kh; 1150e5b75505Sopenharmony_ci 1151e5b75505Sopenharmony_ci return 0; 1152e5b75505Sopenharmony_ci} 1153e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211R_AP */ 1154e5b75505Sopenharmony_ci 1155e5b75505Sopenharmony_ci 1156e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211N 1157e5b75505Sopenharmony_cistatic int hostapd_config_ht_capab(struct hostapd_config *conf, 1158e5b75505Sopenharmony_ci const char *capab) 1159e5b75505Sopenharmony_ci{ 1160e5b75505Sopenharmony_ci if (os_strstr(capab, "[LDPC]")) 1161e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP; 1162e5b75505Sopenharmony_ci if (os_strstr(capab, "[HT40-]")) { 1163e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; 1164e5b75505Sopenharmony_ci conf->secondary_channel = -1; 1165e5b75505Sopenharmony_ci } 1166e5b75505Sopenharmony_ci if (os_strstr(capab, "[HT40+]")) { 1167e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; 1168e5b75505Sopenharmony_ci conf->secondary_channel = 1; 1169e5b75505Sopenharmony_ci } 1170e5b75505Sopenharmony_ci if (os_strstr(capab, "[HT40+]") && os_strstr(capab, "[HT40-]")) { 1171e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; 1172e5b75505Sopenharmony_ci conf->ht40_plus_minus_allowed = 1; 1173e5b75505Sopenharmony_ci } 1174e5b75505Sopenharmony_ci if (!os_strstr(capab, "[HT40+]") && !os_strstr(capab, "[HT40-]")) 1175e5b75505Sopenharmony_ci conf->secondary_channel = 0; 1176e5b75505Sopenharmony_ci if (os_strstr(capab, "[SMPS-STATIC]")) { 1177e5b75505Sopenharmony_ci conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK; 1178e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC; 1179e5b75505Sopenharmony_ci } 1180e5b75505Sopenharmony_ci if (os_strstr(capab, "[SMPS-DYNAMIC]")) { 1181e5b75505Sopenharmony_ci conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK; 1182e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SMPS_DYNAMIC; 1183e5b75505Sopenharmony_ci } 1184e5b75505Sopenharmony_ci if (os_strstr(capab, "[GF]")) 1185e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_GREEN_FIELD; 1186e5b75505Sopenharmony_ci if (os_strstr(capab, "[SHORT-GI-20]")) 1187e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ; 1188e5b75505Sopenharmony_ci if (os_strstr(capab, "[SHORT-GI-40]")) 1189e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ; 1190e5b75505Sopenharmony_ci if (os_strstr(capab, "[TX-STBC]")) 1191e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_TX_STBC; 1192e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC1]")) { 1193e5b75505Sopenharmony_ci conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK; 1194e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_RX_STBC_1; 1195e5b75505Sopenharmony_ci } 1196e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC12]")) { 1197e5b75505Sopenharmony_ci conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK; 1198e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_RX_STBC_12; 1199e5b75505Sopenharmony_ci } 1200e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC123]")) { 1201e5b75505Sopenharmony_ci conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK; 1202e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_RX_STBC_123; 1203e5b75505Sopenharmony_ci } 1204e5b75505Sopenharmony_ci if (os_strstr(capab, "[DELAYED-BA]")) 1205e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_DELAYED_BA; 1206e5b75505Sopenharmony_ci if (os_strstr(capab, "[MAX-AMSDU-7935]")) 1207e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE; 1208e5b75505Sopenharmony_ci if (os_strstr(capab, "[DSSS_CCK-40]")) 1209e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_DSSS_CCK40MHZ; 1210e5b75505Sopenharmony_ci if (os_strstr(capab, "[40-INTOLERANT]")) 1211e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_40MHZ_INTOLERANT; 1212e5b75505Sopenharmony_ci if (os_strstr(capab, "[LSIG-TXOP-PROT]")) 1213e5b75505Sopenharmony_ci conf->ht_capab |= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT; 1214e5b75505Sopenharmony_ci 1215e5b75505Sopenharmony_ci return 0; 1216e5b75505Sopenharmony_ci} 1217e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211N */ 1218e5b75505Sopenharmony_ci 1219e5b75505Sopenharmony_ci 1220e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211AC 1221e5b75505Sopenharmony_cistatic int hostapd_config_vht_capab(struct hostapd_config *conf, 1222e5b75505Sopenharmony_ci const char *capab) 1223e5b75505Sopenharmony_ci{ 1224e5b75505Sopenharmony_ci if (os_strstr(capab, "[MAX-MPDU-7991]")) 1225e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_7991; 1226e5b75505Sopenharmony_ci if (os_strstr(capab, "[MAX-MPDU-11454]")) 1227e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_11454; 1228e5b75505Sopenharmony_ci if (os_strstr(capab, "[VHT160]")) 1229e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; 1230e5b75505Sopenharmony_ci if (os_strstr(capab, "[VHT160-80PLUS80]")) 1231e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; 1232e5b75505Sopenharmony_ci if (os_strstr(capab, "[RXLDPC]")) 1233e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_RXLDPC; 1234e5b75505Sopenharmony_ci if (os_strstr(capab, "[SHORT-GI-80]")) 1235e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_SHORT_GI_80; 1236e5b75505Sopenharmony_ci if (os_strstr(capab, "[SHORT-GI-160]")) 1237e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_SHORT_GI_160; 1238e5b75505Sopenharmony_ci if (os_strstr(capab, "[TX-STBC-2BY1]")) 1239e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_TXSTBC; 1240e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC-1]")) 1241e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_RXSTBC_1; 1242e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC-12]")) 1243e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_RXSTBC_2; 1244e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC-123]")) 1245e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_RXSTBC_3; 1246e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-STBC-1234]")) 1247e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_RXSTBC_4; 1248e5b75505Sopenharmony_ci if (os_strstr(capab, "[SU-BEAMFORMER]")) 1249e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_SU_BEAMFORMER_CAPABLE; 1250e5b75505Sopenharmony_ci if (os_strstr(capab, "[SU-BEAMFORMEE]")) 1251e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_SU_BEAMFORMEE_CAPABLE; 1252e5b75505Sopenharmony_ci if (os_strstr(capab, "[BF-ANTENNA-2]") && 1253e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE)) 1254e5b75505Sopenharmony_ci conf->vht_capab |= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET); 1255e5b75505Sopenharmony_ci if (os_strstr(capab, "[BF-ANTENNA-3]") && 1256e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE)) 1257e5b75505Sopenharmony_ci conf->vht_capab |= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET); 1258e5b75505Sopenharmony_ci if (os_strstr(capab, "[BF-ANTENNA-4]") && 1259e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE)) 1260e5b75505Sopenharmony_ci conf->vht_capab |= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET); 1261e5b75505Sopenharmony_ci if (os_strstr(capab, "[SOUNDING-DIMENSION-2]") && 1262e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE)) 1263e5b75505Sopenharmony_ci conf->vht_capab |= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET); 1264e5b75505Sopenharmony_ci if (os_strstr(capab, "[SOUNDING-DIMENSION-3]") && 1265e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE)) 1266e5b75505Sopenharmony_ci conf->vht_capab |= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET); 1267e5b75505Sopenharmony_ci if (os_strstr(capab, "[SOUNDING-DIMENSION-4]") && 1268e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE)) 1269e5b75505Sopenharmony_ci conf->vht_capab |= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET); 1270e5b75505Sopenharmony_ci if (os_strstr(capab, "[MU-BEAMFORMER]")) 1271e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MU_BEAMFORMER_CAPABLE; 1272e5b75505Sopenharmony_ci if (os_strstr(capab, "[VHT-TXOP-PS]")) 1273e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_VHT_TXOP_PS; 1274e5b75505Sopenharmony_ci if (os_strstr(capab, "[HTC-VHT]")) 1275e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_HTC_VHT; 1276e5b75505Sopenharmony_ci if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP7]")) 1277e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX; 1278e5b75505Sopenharmony_ci else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP6]")) 1279e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6; 1280e5b75505Sopenharmony_ci else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP5]")) 1281e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5; 1282e5b75505Sopenharmony_ci else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP4]")) 1283e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4; 1284e5b75505Sopenharmony_ci else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP3]")) 1285e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3; 1286e5b75505Sopenharmony_ci else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP2]")) 1287e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2; 1288e5b75505Sopenharmony_ci else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP1]")) 1289e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1; 1290e5b75505Sopenharmony_ci if (os_strstr(capab, "[VHT-LINK-ADAPT2]") && 1291e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_HTC_VHT)) 1292e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB; 1293e5b75505Sopenharmony_ci if (os_strstr(capab, "[VHT-LINK-ADAPT3]") && 1294e5b75505Sopenharmony_ci (conf->vht_capab & VHT_CAP_HTC_VHT)) 1295e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB; 1296e5b75505Sopenharmony_ci if (os_strstr(capab, "[RX-ANTENNA-PATTERN]")) 1297e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_RX_ANTENNA_PATTERN; 1298e5b75505Sopenharmony_ci if (os_strstr(capab, "[TX-ANTENNA-PATTERN]")) 1299e5b75505Sopenharmony_ci conf->vht_capab |= VHT_CAP_TX_ANTENNA_PATTERN; 1300e5b75505Sopenharmony_ci return 0; 1301e5b75505Sopenharmony_ci} 1302e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211AC */ 1303e5b75505Sopenharmony_ci 1304e5b75505Sopenharmony_ci 1305e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211AX 1306e5b75505Sopenharmony_ci 1307e5b75505Sopenharmony_cistatic u8 find_bit_offset(u8 val) 1308e5b75505Sopenharmony_ci{ 1309e5b75505Sopenharmony_ci u8 res = 0; 1310e5b75505Sopenharmony_ci 1311e5b75505Sopenharmony_ci for (; val; val >>= 1) { 1312e5b75505Sopenharmony_ci if (val & 1) 1313e5b75505Sopenharmony_ci break; 1314e5b75505Sopenharmony_ci res++; 1315e5b75505Sopenharmony_ci } 1316e5b75505Sopenharmony_ci 1317e5b75505Sopenharmony_ci return res; 1318e5b75505Sopenharmony_ci} 1319e5b75505Sopenharmony_ci 1320e5b75505Sopenharmony_ci 1321e5b75505Sopenharmony_cistatic u8 set_he_cap(int val, u8 mask) 1322e5b75505Sopenharmony_ci{ 1323e5b75505Sopenharmony_ci return (u8) (mask & (val << find_bit_offset(mask))); 1324e5b75505Sopenharmony_ci} 1325e5b75505Sopenharmony_ci 1326e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211AX */ 1327e5b75505Sopenharmony_ci 1328e5b75505Sopenharmony_ci 1329e5b75505Sopenharmony_ci#ifdef CONFIG_INTERWORKING 1330e5b75505Sopenharmony_cistatic int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos, 1331e5b75505Sopenharmony_ci int line) 1332e5b75505Sopenharmony_ci{ 1333e5b75505Sopenharmony_ci size_t len = os_strlen(pos); 1334e5b75505Sopenharmony_ci u8 oi[MAX_ROAMING_CONSORTIUM_LEN]; 1335e5b75505Sopenharmony_ci 1336e5b75505Sopenharmony_ci struct hostapd_roaming_consortium *rc; 1337e5b75505Sopenharmony_ci 1338e5b75505Sopenharmony_ci if ((len & 1) || len < 2 * 3 || len / 2 > MAX_ROAMING_CONSORTIUM_LEN || 1339e5b75505Sopenharmony_ci hexstr2bin(pos, oi, len / 2)) { 1340e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid roaming_consortium " 1341e5b75505Sopenharmony_ci "'%s'", line, pos); 1342e5b75505Sopenharmony_ci return -1; 1343e5b75505Sopenharmony_ci } 1344e5b75505Sopenharmony_ci len /= 2; 1345e5b75505Sopenharmony_ci 1346e5b75505Sopenharmony_ci rc = os_realloc_array(bss->roaming_consortium, 1347e5b75505Sopenharmony_ci bss->roaming_consortium_count + 1, 1348e5b75505Sopenharmony_ci sizeof(struct hostapd_roaming_consortium)); 1349e5b75505Sopenharmony_ci if (rc == NULL) 1350e5b75505Sopenharmony_ci return -1; 1351e5b75505Sopenharmony_ci 1352e5b75505Sopenharmony_ci os_memcpy(rc[bss->roaming_consortium_count].oi, oi, len); 1353e5b75505Sopenharmony_ci rc[bss->roaming_consortium_count].len = len; 1354e5b75505Sopenharmony_ci 1355e5b75505Sopenharmony_ci bss->roaming_consortium = rc; 1356e5b75505Sopenharmony_ci bss->roaming_consortium_count++; 1357e5b75505Sopenharmony_ci 1358e5b75505Sopenharmony_ci return 0; 1359e5b75505Sopenharmony_ci} 1360e5b75505Sopenharmony_ci 1361e5b75505Sopenharmony_ci 1362e5b75505Sopenharmony_cistatic int parse_lang_string(struct hostapd_lang_string **array, 1363e5b75505Sopenharmony_ci unsigned int *count, char *pos) 1364e5b75505Sopenharmony_ci{ 1365e5b75505Sopenharmony_ci char *sep, *str = NULL; 1366e5b75505Sopenharmony_ci size_t clen, nlen, slen; 1367e5b75505Sopenharmony_ci struct hostapd_lang_string *ls; 1368e5b75505Sopenharmony_ci int ret = -1; 1369e5b75505Sopenharmony_ci 1370e5b75505Sopenharmony_ci if (*pos == '"' || (*pos == 'P' && pos[1] == '"')) { 1371e5b75505Sopenharmony_ci str = wpa_config_parse_string(pos, &slen); 1372e5b75505Sopenharmony_ci if (!str) 1373e5b75505Sopenharmony_ci return -1; 1374e5b75505Sopenharmony_ci pos = str; 1375e5b75505Sopenharmony_ci } 1376e5b75505Sopenharmony_ci 1377e5b75505Sopenharmony_ci sep = os_strchr(pos, ':'); 1378e5b75505Sopenharmony_ci if (sep == NULL) 1379e5b75505Sopenharmony_ci goto fail; 1380e5b75505Sopenharmony_ci *sep++ = '\0'; 1381e5b75505Sopenharmony_ci 1382e5b75505Sopenharmony_ci clen = os_strlen(pos); 1383e5b75505Sopenharmony_ci if (clen < 2 || clen > sizeof(ls->lang)) 1384e5b75505Sopenharmony_ci goto fail; 1385e5b75505Sopenharmony_ci nlen = os_strlen(sep); 1386e5b75505Sopenharmony_ci if (nlen > 252) 1387e5b75505Sopenharmony_ci goto fail; 1388e5b75505Sopenharmony_ci 1389e5b75505Sopenharmony_ci ls = os_realloc_array(*array, *count + 1, 1390e5b75505Sopenharmony_ci sizeof(struct hostapd_lang_string)); 1391e5b75505Sopenharmony_ci if (ls == NULL) 1392e5b75505Sopenharmony_ci goto fail; 1393e5b75505Sopenharmony_ci 1394e5b75505Sopenharmony_ci *array = ls; 1395e5b75505Sopenharmony_ci ls = &(*array)[*count]; 1396e5b75505Sopenharmony_ci (*count)++; 1397e5b75505Sopenharmony_ci 1398e5b75505Sopenharmony_ci os_memset(ls->lang, 0, sizeof(ls->lang)); 1399e5b75505Sopenharmony_ci os_memcpy(ls->lang, pos, clen); 1400e5b75505Sopenharmony_ci ls->name_len = nlen; 1401e5b75505Sopenharmony_ci os_memcpy(ls->name, sep, nlen); 1402e5b75505Sopenharmony_ci 1403e5b75505Sopenharmony_ci ret = 0; 1404e5b75505Sopenharmony_cifail: 1405e5b75505Sopenharmony_ci os_free(str); 1406e5b75505Sopenharmony_ci return ret; 1407e5b75505Sopenharmony_ci} 1408e5b75505Sopenharmony_ci 1409e5b75505Sopenharmony_ci 1410e5b75505Sopenharmony_cistatic int parse_venue_name(struct hostapd_bss_config *bss, char *pos, 1411e5b75505Sopenharmony_ci int line) 1412e5b75505Sopenharmony_ci{ 1413e5b75505Sopenharmony_ci if (parse_lang_string(&bss->venue_name, &bss->venue_name_count, pos)) { 1414e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'", 1415e5b75505Sopenharmony_ci line, pos); 1416e5b75505Sopenharmony_ci return -1; 1417e5b75505Sopenharmony_ci } 1418e5b75505Sopenharmony_ci return 0; 1419e5b75505Sopenharmony_ci} 1420e5b75505Sopenharmony_ci 1421e5b75505Sopenharmony_ci 1422e5b75505Sopenharmony_cistatic int parse_venue_url(struct hostapd_bss_config *bss, char *pos, 1423e5b75505Sopenharmony_ci int line) 1424e5b75505Sopenharmony_ci{ 1425e5b75505Sopenharmony_ci char *sep; 1426e5b75505Sopenharmony_ci size_t nlen; 1427e5b75505Sopenharmony_ci struct hostapd_venue_url *url; 1428e5b75505Sopenharmony_ci int ret = -1; 1429e5b75505Sopenharmony_ci 1430e5b75505Sopenharmony_ci sep = os_strchr(pos, ':'); 1431e5b75505Sopenharmony_ci if (!sep) 1432e5b75505Sopenharmony_ci goto fail; 1433e5b75505Sopenharmony_ci *sep++ = '\0'; 1434e5b75505Sopenharmony_ci 1435e5b75505Sopenharmony_ci nlen = os_strlen(sep); 1436e5b75505Sopenharmony_ci if (nlen > 254) 1437e5b75505Sopenharmony_ci goto fail; 1438e5b75505Sopenharmony_ci 1439e5b75505Sopenharmony_ci url = os_realloc_array(bss->venue_url, bss->venue_url_count + 1, 1440e5b75505Sopenharmony_ci sizeof(struct hostapd_venue_url)); 1441e5b75505Sopenharmony_ci if (!url) 1442e5b75505Sopenharmony_ci goto fail; 1443e5b75505Sopenharmony_ci 1444e5b75505Sopenharmony_ci bss->venue_url = url; 1445e5b75505Sopenharmony_ci url = &bss->venue_url[bss->venue_url_count++]; 1446e5b75505Sopenharmony_ci 1447e5b75505Sopenharmony_ci url->venue_number = atoi(pos); 1448e5b75505Sopenharmony_ci url->url_len = nlen; 1449e5b75505Sopenharmony_ci os_memcpy(url->url, sep, nlen); 1450e5b75505Sopenharmony_ci 1451e5b75505Sopenharmony_ci ret = 0; 1452e5b75505Sopenharmony_cifail: 1453e5b75505Sopenharmony_ci if (ret) 1454e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid venue_url '%s'", 1455e5b75505Sopenharmony_ci line, pos); 1456e5b75505Sopenharmony_ci return ret; 1457e5b75505Sopenharmony_ci} 1458e5b75505Sopenharmony_ci 1459e5b75505Sopenharmony_ci 1460e5b75505Sopenharmony_cistatic int parse_3gpp_cell_net(struct hostapd_bss_config *bss, char *buf, 1461e5b75505Sopenharmony_ci int line) 1462e5b75505Sopenharmony_ci{ 1463e5b75505Sopenharmony_ci size_t count; 1464e5b75505Sopenharmony_ci char *pos; 1465e5b75505Sopenharmony_ci u8 *info = NULL, *ipos; 1466e5b75505Sopenharmony_ci 1467e5b75505Sopenharmony_ci /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */ 1468e5b75505Sopenharmony_ci 1469e5b75505Sopenharmony_ci count = 1; 1470e5b75505Sopenharmony_ci for (pos = buf; *pos; pos++) { 1471e5b75505Sopenharmony_ci if ((*pos < '0' || *pos > '9') && *pos != ';' && *pos != ',') 1472e5b75505Sopenharmony_ci goto fail; 1473e5b75505Sopenharmony_ci if (*pos == ';') 1474e5b75505Sopenharmony_ci count++; 1475e5b75505Sopenharmony_ci } 1476e5b75505Sopenharmony_ci if (1 + count * 3 > 0x7f) 1477e5b75505Sopenharmony_ci goto fail; 1478e5b75505Sopenharmony_ci 1479e5b75505Sopenharmony_ci info = os_zalloc(2 + 3 + count * 3); 1480e5b75505Sopenharmony_ci if (info == NULL) 1481e5b75505Sopenharmony_ci return -1; 1482e5b75505Sopenharmony_ci 1483e5b75505Sopenharmony_ci ipos = info; 1484e5b75505Sopenharmony_ci *ipos++ = 0; /* GUD - Version 1 */ 1485e5b75505Sopenharmony_ci *ipos++ = 3 + count * 3; /* User Data Header Length (UDHL) */ 1486e5b75505Sopenharmony_ci *ipos++ = 0; /* PLMN List IEI */ 1487e5b75505Sopenharmony_ci /* ext(b8) | Length of PLMN List value contents(b7..1) */ 1488e5b75505Sopenharmony_ci *ipos++ = 1 + count * 3; 1489e5b75505Sopenharmony_ci *ipos++ = count; /* Number of PLMNs */ 1490e5b75505Sopenharmony_ci 1491e5b75505Sopenharmony_ci pos = buf; 1492e5b75505Sopenharmony_ci while (pos && *pos) { 1493e5b75505Sopenharmony_ci char *mcc, *mnc; 1494e5b75505Sopenharmony_ci size_t mnc_len; 1495e5b75505Sopenharmony_ci 1496e5b75505Sopenharmony_ci mcc = pos; 1497e5b75505Sopenharmony_ci mnc = os_strchr(pos, ','); 1498e5b75505Sopenharmony_ci if (mnc == NULL) 1499e5b75505Sopenharmony_ci goto fail; 1500e5b75505Sopenharmony_ci *mnc++ = '\0'; 1501e5b75505Sopenharmony_ci pos = os_strchr(mnc, ';'); 1502e5b75505Sopenharmony_ci if (pos) 1503e5b75505Sopenharmony_ci *pos++ = '\0'; 1504e5b75505Sopenharmony_ci 1505e5b75505Sopenharmony_ci mnc_len = os_strlen(mnc); 1506e5b75505Sopenharmony_ci if (os_strlen(mcc) != 3 || (mnc_len != 2 && mnc_len != 3)) 1507e5b75505Sopenharmony_ci goto fail; 1508e5b75505Sopenharmony_ci 1509e5b75505Sopenharmony_ci /* BC coded MCC,MNC */ 1510e5b75505Sopenharmony_ci /* MCC digit 2 | MCC digit 1 */ 1511e5b75505Sopenharmony_ci *ipos++ = ((mcc[1] - '0') << 4) | (mcc[0] - '0'); 1512e5b75505Sopenharmony_ci /* MNC digit 3 | MCC digit 3 */ 1513e5b75505Sopenharmony_ci *ipos++ = (((mnc_len == 2) ? 0xf0 : ((mnc[2] - '0') << 4))) | 1514e5b75505Sopenharmony_ci (mcc[2] - '0'); 1515e5b75505Sopenharmony_ci /* MNC digit 2 | MNC digit 1 */ 1516e5b75505Sopenharmony_ci *ipos++ = ((mnc[1] - '0') << 4) | (mnc[0] - '0'); 1517e5b75505Sopenharmony_ci } 1518e5b75505Sopenharmony_ci 1519e5b75505Sopenharmony_ci os_free(bss->anqp_3gpp_cell_net); 1520e5b75505Sopenharmony_ci bss->anqp_3gpp_cell_net = info; 1521e5b75505Sopenharmony_ci bss->anqp_3gpp_cell_net_len = 2 + 3 + 3 * count; 1522e5b75505Sopenharmony_ci wpa_hexdump(MSG_MSGDUMP, "3GPP Cellular Network information", 1523e5b75505Sopenharmony_ci bss->anqp_3gpp_cell_net, bss->anqp_3gpp_cell_net_len); 1524e5b75505Sopenharmony_ci 1525e5b75505Sopenharmony_ci return 0; 1526e5b75505Sopenharmony_ci 1527e5b75505Sopenharmony_cifail: 1528e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid anqp_3gpp_cell_net: %s", 1529e5b75505Sopenharmony_ci line, buf); 1530e5b75505Sopenharmony_ci os_free(info); 1531e5b75505Sopenharmony_ci return -1; 1532e5b75505Sopenharmony_ci} 1533e5b75505Sopenharmony_ci 1534e5b75505Sopenharmony_ci 1535e5b75505Sopenharmony_cistatic int parse_nai_realm(struct hostapd_bss_config *bss, char *buf, int line) 1536e5b75505Sopenharmony_ci{ 1537e5b75505Sopenharmony_ci struct hostapd_nai_realm_data *realm; 1538e5b75505Sopenharmony_ci size_t i, j, len; 1539e5b75505Sopenharmony_ci int *offsets; 1540e5b75505Sopenharmony_ci char *pos, *end, *rpos; 1541e5b75505Sopenharmony_ci 1542e5b75505Sopenharmony_ci offsets = os_calloc(bss->nai_realm_count * MAX_NAI_REALMS, 1543e5b75505Sopenharmony_ci sizeof(int)); 1544e5b75505Sopenharmony_ci if (offsets == NULL) 1545e5b75505Sopenharmony_ci return -1; 1546e5b75505Sopenharmony_ci 1547e5b75505Sopenharmony_ci for (i = 0; i < bss->nai_realm_count; i++) { 1548e5b75505Sopenharmony_ci realm = &bss->nai_realm_data[i]; 1549e5b75505Sopenharmony_ci for (j = 0; j < MAX_NAI_REALMS; j++) { 1550e5b75505Sopenharmony_ci offsets[i * MAX_NAI_REALMS + j] = 1551e5b75505Sopenharmony_ci realm->realm[j] ? 1552e5b75505Sopenharmony_ci realm->realm[j] - realm->realm_buf : -1; 1553e5b75505Sopenharmony_ci } 1554e5b75505Sopenharmony_ci } 1555e5b75505Sopenharmony_ci 1556e5b75505Sopenharmony_ci realm = os_realloc_array(bss->nai_realm_data, bss->nai_realm_count + 1, 1557e5b75505Sopenharmony_ci sizeof(struct hostapd_nai_realm_data)); 1558e5b75505Sopenharmony_ci if (realm == NULL) { 1559e5b75505Sopenharmony_ci os_free(offsets); 1560e5b75505Sopenharmony_ci return -1; 1561e5b75505Sopenharmony_ci } 1562e5b75505Sopenharmony_ci bss->nai_realm_data = realm; 1563e5b75505Sopenharmony_ci 1564e5b75505Sopenharmony_ci /* patch the pointers after realloc */ 1565e5b75505Sopenharmony_ci for (i = 0; i < bss->nai_realm_count; i++) { 1566e5b75505Sopenharmony_ci realm = &bss->nai_realm_data[i]; 1567e5b75505Sopenharmony_ci for (j = 0; j < MAX_NAI_REALMS; j++) { 1568e5b75505Sopenharmony_ci int offs = offsets[i * MAX_NAI_REALMS + j]; 1569e5b75505Sopenharmony_ci if (offs >= 0) 1570e5b75505Sopenharmony_ci realm->realm[j] = realm->realm_buf + offs; 1571e5b75505Sopenharmony_ci else 1572e5b75505Sopenharmony_ci realm->realm[j] = NULL; 1573e5b75505Sopenharmony_ci } 1574e5b75505Sopenharmony_ci } 1575e5b75505Sopenharmony_ci os_free(offsets); 1576e5b75505Sopenharmony_ci 1577e5b75505Sopenharmony_ci realm = &bss->nai_realm_data[bss->nai_realm_count]; 1578e5b75505Sopenharmony_ci os_memset(realm, 0, sizeof(*realm)); 1579e5b75505Sopenharmony_ci 1580e5b75505Sopenharmony_ci pos = buf; 1581e5b75505Sopenharmony_ci realm->encoding = atoi(pos); 1582e5b75505Sopenharmony_ci pos = os_strchr(pos, ','); 1583e5b75505Sopenharmony_ci if (pos == NULL) 1584e5b75505Sopenharmony_ci goto fail; 1585e5b75505Sopenharmony_ci pos++; 1586e5b75505Sopenharmony_ci 1587e5b75505Sopenharmony_ci end = os_strchr(pos, ','); 1588e5b75505Sopenharmony_ci if (end) { 1589e5b75505Sopenharmony_ci len = end - pos; 1590e5b75505Sopenharmony_ci *end = '\0'; 1591e5b75505Sopenharmony_ci } else { 1592e5b75505Sopenharmony_ci len = os_strlen(pos); 1593e5b75505Sopenharmony_ci } 1594e5b75505Sopenharmony_ci 1595e5b75505Sopenharmony_ci if (len > MAX_NAI_REALMLEN) { 1596e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Too long a realm string (%d > max %d " 1597e5b75505Sopenharmony_ci "characters)", (int) len, MAX_NAI_REALMLEN); 1598e5b75505Sopenharmony_ci goto fail; 1599e5b75505Sopenharmony_ci } 1600e5b75505Sopenharmony_ci os_memcpy(realm->realm_buf, pos, len); 1601e5b75505Sopenharmony_ci 1602e5b75505Sopenharmony_ci if (end) 1603e5b75505Sopenharmony_ci pos = end + 1; 1604e5b75505Sopenharmony_ci else 1605e5b75505Sopenharmony_ci pos = NULL; 1606e5b75505Sopenharmony_ci 1607e5b75505Sopenharmony_ci while (pos && *pos) { 1608e5b75505Sopenharmony_ci struct hostapd_nai_realm_eap *eap; 1609e5b75505Sopenharmony_ci 1610e5b75505Sopenharmony_ci if (realm->eap_method_count >= MAX_NAI_EAP_METHODS) { 1611e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Too many EAP methods"); 1612e5b75505Sopenharmony_ci goto fail; 1613e5b75505Sopenharmony_ci } 1614e5b75505Sopenharmony_ci 1615e5b75505Sopenharmony_ci eap = &realm->eap_method[realm->eap_method_count]; 1616e5b75505Sopenharmony_ci realm->eap_method_count++; 1617e5b75505Sopenharmony_ci 1618e5b75505Sopenharmony_ci end = os_strchr(pos, ','); 1619e5b75505Sopenharmony_ci if (end == NULL) 1620e5b75505Sopenharmony_ci end = pos + os_strlen(pos); 1621e5b75505Sopenharmony_ci 1622e5b75505Sopenharmony_ci eap->eap_method = atoi(pos); 1623e5b75505Sopenharmony_ci for (;;) { 1624e5b75505Sopenharmony_ci pos = os_strchr(pos, '['); 1625e5b75505Sopenharmony_ci if (pos == NULL || pos > end) 1626e5b75505Sopenharmony_ci break; 1627e5b75505Sopenharmony_ci pos++; 1628e5b75505Sopenharmony_ci if (eap->num_auths >= MAX_NAI_AUTH_TYPES) { 1629e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Too many auth params"); 1630e5b75505Sopenharmony_ci goto fail; 1631e5b75505Sopenharmony_ci } 1632e5b75505Sopenharmony_ci eap->auth_id[eap->num_auths] = atoi(pos); 1633e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1634e5b75505Sopenharmony_ci if (pos == NULL || pos > end) 1635e5b75505Sopenharmony_ci goto fail; 1636e5b75505Sopenharmony_ci pos++; 1637e5b75505Sopenharmony_ci eap->auth_val[eap->num_auths] = atoi(pos); 1638e5b75505Sopenharmony_ci pos = os_strchr(pos, ']'); 1639e5b75505Sopenharmony_ci if (pos == NULL || pos > end) 1640e5b75505Sopenharmony_ci goto fail; 1641e5b75505Sopenharmony_ci pos++; 1642e5b75505Sopenharmony_ci eap->num_auths++; 1643e5b75505Sopenharmony_ci } 1644e5b75505Sopenharmony_ci 1645e5b75505Sopenharmony_ci if (*end != ',') 1646e5b75505Sopenharmony_ci break; 1647e5b75505Sopenharmony_ci 1648e5b75505Sopenharmony_ci pos = end + 1; 1649e5b75505Sopenharmony_ci } 1650e5b75505Sopenharmony_ci 1651e5b75505Sopenharmony_ci /* Split realm list into null terminated realms */ 1652e5b75505Sopenharmony_ci rpos = realm->realm_buf; 1653e5b75505Sopenharmony_ci i = 0; 1654e5b75505Sopenharmony_ci while (*rpos) { 1655e5b75505Sopenharmony_ci if (i >= MAX_NAI_REALMS) { 1656e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Too many realms"); 1657e5b75505Sopenharmony_ci goto fail; 1658e5b75505Sopenharmony_ci } 1659e5b75505Sopenharmony_ci realm->realm[i++] = rpos; 1660e5b75505Sopenharmony_ci rpos = os_strchr(rpos, ';'); 1661e5b75505Sopenharmony_ci if (rpos == NULL) 1662e5b75505Sopenharmony_ci break; 1663e5b75505Sopenharmony_ci *rpos++ = '\0'; 1664e5b75505Sopenharmony_ci } 1665e5b75505Sopenharmony_ci 1666e5b75505Sopenharmony_ci bss->nai_realm_count++; 1667e5b75505Sopenharmony_ci 1668e5b75505Sopenharmony_ci return 0; 1669e5b75505Sopenharmony_ci 1670e5b75505Sopenharmony_cifail: 1671e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid nai_realm '%s'", line, buf); 1672e5b75505Sopenharmony_ci return -1; 1673e5b75505Sopenharmony_ci} 1674e5b75505Sopenharmony_ci 1675e5b75505Sopenharmony_ci 1676e5b75505Sopenharmony_cistatic int parse_anqp_elem(struct hostapd_bss_config *bss, char *buf, int line) 1677e5b75505Sopenharmony_ci{ 1678e5b75505Sopenharmony_ci char *delim; 1679e5b75505Sopenharmony_ci u16 infoid; 1680e5b75505Sopenharmony_ci size_t len; 1681e5b75505Sopenharmony_ci struct wpabuf *payload; 1682e5b75505Sopenharmony_ci struct anqp_element *elem; 1683e5b75505Sopenharmony_ci 1684e5b75505Sopenharmony_ci delim = os_strchr(buf, ':'); 1685e5b75505Sopenharmony_ci if (!delim) 1686e5b75505Sopenharmony_ci return -1; 1687e5b75505Sopenharmony_ci delim++; 1688e5b75505Sopenharmony_ci infoid = atoi(buf); 1689e5b75505Sopenharmony_ci len = os_strlen(delim); 1690e5b75505Sopenharmony_ci if (len & 1) 1691e5b75505Sopenharmony_ci return -1; 1692e5b75505Sopenharmony_ci len /= 2; 1693e5b75505Sopenharmony_ci payload = wpabuf_alloc(len); 1694e5b75505Sopenharmony_ci if (!payload) 1695e5b75505Sopenharmony_ci return -1; 1696e5b75505Sopenharmony_ci if (hexstr2bin(delim, wpabuf_put(payload, len), len) < 0) { 1697e5b75505Sopenharmony_ci wpabuf_free(payload); 1698e5b75505Sopenharmony_ci return -1; 1699e5b75505Sopenharmony_ci } 1700e5b75505Sopenharmony_ci 1701e5b75505Sopenharmony_ci dl_list_for_each(elem, &bss->anqp_elem, struct anqp_element, list) { 1702e5b75505Sopenharmony_ci if (elem->infoid == infoid) { 1703e5b75505Sopenharmony_ci /* Update existing entry */ 1704e5b75505Sopenharmony_ci wpabuf_free(elem->payload); 1705e5b75505Sopenharmony_ci elem->payload = payload; 1706e5b75505Sopenharmony_ci return 0; 1707e5b75505Sopenharmony_ci } 1708e5b75505Sopenharmony_ci } 1709e5b75505Sopenharmony_ci 1710e5b75505Sopenharmony_ci /* Add a new entry */ 1711e5b75505Sopenharmony_ci elem = os_zalloc(sizeof(*elem)); 1712e5b75505Sopenharmony_ci if (!elem) { 1713e5b75505Sopenharmony_ci wpabuf_free(payload); 1714e5b75505Sopenharmony_ci return -1; 1715e5b75505Sopenharmony_ci } 1716e5b75505Sopenharmony_ci elem->infoid = infoid; 1717e5b75505Sopenharmony_ci elem->payload = payload; 1718e5b75505Sopenharmony_ci dl_list_add(&bss->anqp_elem, &elem->list); 1719e5b75505Sopenharmony_ci 1720e5b75505Sopenharmony_ci return 0; 1721e5b75505Sopenharmony_ci} 1722e5b75505Sopenharmony_ci 1723e5b75505Sopenharmony_ci 1724e5b75505Sopenharmony_cistatic int parse_qos_map_set(struct hostapd_bss_config *bss, 1725e5b75505Sopenharmony_ci char *buf, int line) 1726e5b75505Sopenharmony_ci{ 1727e5b75505Sopenharmony_ci u8 qos_map_set[16 + 2 * 21], count = 0; 1728e5b75505Sopenharmony_ci char *pos = buf; 1729e5b75505Sopenharmony_ci int val; 1730e5b75505Sopenharmony_ci 1731e5b75505Sopenharmony_ci for (;;) { 1732e5b75505Sopenharmony_ci if (count == sizeof(qos_map_set)) { 1733e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Too many qos_map_set " 1734e5b75505Sopenharmony_ci "parameters '%s'", line, buf); 1735e5b75505Sopenharmony_ci return -1; 1736e5b75505Sopenharmony_ci } 1737e5b75505Sopenharmony_ci 1738e5b75505Sopenharmony_ci val = atoi(pos); 1739e5b75505Sopenharmony_ci if (val > 255 || val < 0) { 1740e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid qos_map_set " 1741e5b75505Sopenharmony_ci "'%s'", line, buf); 1742e5b75505Sopenharmony_ci return -1; 1743e5b75505Sopenharmony_ci } 1744e5b75505Sopenharmony_ci 1745e5b75505Sopenharmony_ci qos_map_set[count++] = val; 1746e5b75505Sopenharmony_ci pos = os_strchr(pos, ','); 1747e5b75505Sopenharmony_ci if (!pos) 1748e5b75505Sopenharmony_ci break; 1749e5b75505Sopenharmony_ci pos++; 1750e5b75505Sopenharmony_ci } 1751e5b75505Sopenharmony_ci 1752e5b75505Sopenharmony_ci if (count < 16 || count & 1) { 1753e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid qos_map_set '%s'", 1754e5b75505Sopenharmony_ci line, buf); 1755e5b75505Sopenharmony_ci return -1; 1756e5b75505Sopenharmony_ci } 1757e5b75505Sopenharmony_ci 1758e5b75505Sopenharmony_ci os_memcpy(bss->qos_map_set, qos_map_set, count); 1759e5b75505Sopenharmony_ci bss->qos_map_set_len = count; 1760e5b75505Sopenharmony_ci 1761e5b75505Sopenharmony_ci return 0; 1762e5b75505Sopenharmony_ci} 1763e5b75505Sopenharmony_ci 1764e5b75505Sopenharmony_ci#endif /* CONFIG_INTERWORKING */ 1765e5b75505Sopenharmony_ci 1766e5b75505Sopenharmony_ci 1767e5b75505Sopenharmony_ci#ifdef CONFIG_HS20 1768e5b75505Sopenharmony_cistatic int hs20_parse_conn_capab(struct hostapd_bss_config *bss, char *buf, 1769e5b75505Sopenharmony_ci int line) 1770e5b75505Sopenharmony_ci{ 1771e5b75505Sopenharmony_ci u8 *conn_cap; 1772e5b75505Sopenharmony_ci char *pos; 1773e5b75505Sopenharmony_ci 1774e5b75505Sopenharmony_ci if (bss->hs20_connection_capability_len >= 0xfff0) 1775e5b75505Sopenharmony_ci return -1; 1776e5b75505Sopenharmony_ci 1777e5b75505Sopenharmony_ci conn_cap = os_realloc(bss->hs20_connection_capability, 1778e5b75505Sopenharmony_ci bss->hs20_connection_capability_len + 4); 1779e5b75505Sopenharmony_ci if (conn_cap == NULL) 1780e5b75505Sopenharmony_ci return -1; 1781e5b75505Sopenharmony_ci 1782e5b75505Sopenharmony_ci bss->hs20_connection_capability = conn_cap; 1783e5b75505Sopenharmony_ci conn_cap += bss->hs20_connection_capability_len; 1784e5b75505Sopenharmony_ci pos = buf; 1785e5b75505Sopenharmony_ci conn_cap[0] = atoi(pos); 1786e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1787e5b75505Sopenharmony_ci if (pos == NULL) 1788e5b75505Sopenharmony_ci return -1; 1789e5b75505Sopenharmony_ci pos++; 1790e5b75505Sopenharmony_ci WPA_PUT_LE16(conn_cap + 1, atoi(pos)); 1791e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1792e5b75505Sopenharmony_ci if (pos == NULL) 1793e5b75505Sopenharmony_ci return -1; 1794e5b75505Sopenharmony_ci pos++; 1795e5b75505Sopenharmony_ci conn_cap[3] = atoi(pos); 1796e5b75505Sopenharmony_ci bss->hs20_connection_capability_len += 4; 1797e5b75505Sopenharmony_ci 1798e5b75505Sopenharmony_ci return 0; 1799e5b75505Sopenharmony_ci} 1800e5b75505Sopenharmony_ci 1801e5b75505Sopenharmony_ci 1802e5b75505Sopenharmony_cistatic int hs20_parse_wan_metrics(struct hostapd_bss_config *bss, char *buf, 1803e5b75505Sopenharmony_ci int line) 1804e5b75505Sopenharmony_ci{ 1805e5b75505Sopenharmony_ci u8 *wan_metrics; 1806e5b75505Sopenharmony_ci char *pos; 1807e5b75505Sopenharmony_ci 1808e5b75505Sopenharmony_ci /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */ 1809e5b75505Sopenharmony_ci 1810e5b75505Sopenharmony_ci wan_metrics = os_zalloc(13); 1811e5b75505Sopenharmony_ci if (wan_metrics == NULL) 1812e5b75505Sopenharmony_ci return -1; 1813e5b75505Sopenharmony_ci 1814e5b75505Sopenharmony_ci pos = buf; 1815e5b75505Sopenharmony_ci /* WAN Info */ 1816e5b75505Sopenharmony_ci if (hexstr2bin(pos, wan_metrics, 1) < 0) 1817e5b75505Sopenharmony_ci goto fail; 1818e5b75505Sopenharmony_ci pos += 2; 1819e5b75505Sopenharmony_ci if (*pos != ':') 1820e5b75505Sopenharmony_ci goto fail; 1821e5b75505Sopenharmony_ci pos++; 1822e5b75505Sopenharmony_ci 1823e5b75505Sopenharmony_ci /* Downlink Speed */ 1824e5b75505Sopenharmony_ci WPA_PUT_LE32(wan_metrics + 1, atoi(pos)); 1825e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1826e5b75505Sopenharmony_ci if (pos == NULL) 1827e5b75505Sopenharmony_ci goto fail; 1828e5b75505Sopenharmony_ci pos++; 1829e5b75505Sopenharmony_ci 1830e5b75505Sopenharmony_ci /* Uplink Speed */ 1831e5b75505Sopenharmony_ci WPA_PUT_LE32(wan_metrics + 5, atoi(pos)); 1832e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1833e5b75505Sopenharmony_ci if (pos == NULL) 1834e5b75505Sopenharmony_ci goto fail; 1835e5b75505Sopenharmony_ci pos++; 1836e5b75505Sopenharmony_ci 1837e5b75505Sopenharmony_ci /* Downlink Load */ 1838e5b75505Sopenharmony_ci wan_metrics[9] = atoi(pos); 1839e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1840e5b75505Sopenharmony_ci if (pos == NULL) 1841e5b75505Sopenharmony_ci goto fail; 1842e5b75505Sopenharmony_ci pos++; 1843e5b75505Sopenharmony_ci 1844e5b75505Sopenharmony_ci /* Uplink Load */ 1845e5b75505Sopenharmony_ci wan_metrics[10] = atoi(pos); 1846e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1847e5b75505Sopenharmony_ci if (pos == NULL) 1848e5b75505Sopenharmony_ci goto fail; 1849e5b75505Sopenharmony_ci pos++; 1850e5b75505Sopenharmony_ci 1851e5b75505Sopenharmony_ci /* LMD */ 1852e5b75505Sopenharmony_ci WPA_PUT_LE16(wan_metrics + 11, atoi(pos)); 1853e5b75505Sopenharmony_ci 1854e5b75505Sopenharmony_ci os_free(bss->hs20_wan_metrics); 1855e5b75505Sopenharmony_ci bss->hs20_wan_metrics = wan_metrics; 1856e5b75505Sopenharmony_ci 1857e5b75505Sopenharmony_ci return 0; 1858e5b75505Sopenharmony_ci 1859e5b75505Sopenharmony_cifail: 1860e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid hs20_wan_metrics '%s'", 1861e5b75505Sopenharmony_ci line, buf); 1862e5b75505Sopenharmony_ci os_free(wan_metrics); 1863e5b75505Sopenharmony_ci return -1; 1864e5b75505Sopenharmony_ci} 1865e5b75505Sopenharmony_ci 1866e5b75505Sopenharmony_ci 1867e5b75505Sopenharmony_cistatic int hs20_parse_oper_friendly_name(struct hostapd_bss_config *bss, 1868e5b75505Sopenharmony_ci char *pos, int line) 1869e5b75505Sopenharmony_ci{ 1870e5b75505Sopenharmony_ci if (parse_lang_string(&bss->hs20_oper_friendly_name, 1871e5b75505Sopenharmony_ci &bss->hs20_oper_friendly_name_count, pos)) { 1872e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid " 1873e5b75505Sopenharmony_ci "hs20_oper_friendly_name '%s'", line, pos); 1874e5b75505Sopenharmony_ci return -1; 1875e5b75505Sopenharmony_ci } 1876e5b75505Sopenharmony_ci return 0; 1877e5b75505Sopenharmony_ci} 1878e5b75505Sopenharmony_ci 1879e5b75505Sopenharmony_ci 1880e5b75505Sopenharmony_cistatic int hs20_parse_icon(struct hostapd_bss_config *bss, char *pos) 1881e5b75505Sopenharmony_ci{ 1882e5b75505Sopenharmony_ci struct hs20_icon *icon; 1883e5b75505Sopenharmony_ci char *end; 1884e5b75505Sopenharmony_ci 1885e5b75505Sopenharmony_ci icon = os_realloc_array(bss->hs20_icons, bss->hs20_icons_count + 1, 1886e5b75505Sopenharmony_ci sizeof(struct hs20_icon)); 1887e5b75505Sopenharmony_ci if (icon == NULL) 1888e5b75505Sopenharmony_ci return -1; 1889e5b75505Sopenharmony_ci bss->hs20_icons = icon; 1890e5b75505Sopenharmony_ci icon = &bss->hs20_icons[bss->hs20_icons_count]; 1891e5b75505Sopenharmony_ci os_memset(icon, 0, sizeof(*icon)); 1892e5b75505Sopenharmony_ci 1893e5b75505Sopenharmony_ci icon->width = atoi(pos); 1894e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1895e5b75505Sopenharmony_ci if (pos == NULL) 1896e5b75505Sopenharmony_ci return -1; 1897e5b75505Sopenharmony_ci pos++; 1898e5b75505Sopenharmony_ci 1899e5b75505Sopenharmony_ci icon->height = atoi(pos); 1900e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 1901e5b75505Sopenharmony_ci if (pos == NULL) 1902e5b75505Sopenharmony_ci return -1; 1903e5b75505Sopenharmony_ci pos++; 1904e5b75505Sopenharmony_ci 1905e5b75505Sopenharmony_ci end = os_strchr(pos, ':'); 1906e5b75505Sopenharmony_ci if (end == NULL || end - pos > 3) 1907e5b75505Sopenharmony_ci return -1; 1908e5b75505Sopenharmony_ci os_memcpy(icon->language, pos, end - pos); 1909e5b75505Sopenharmony_ci pos = end + 1; 1910e5b75505Sopenharmony_ci 1911e5b75505Sopenharmony_ci end = os_strchr(pos, ':'); 1912e5b75505Sopenharmony_ci if (end == NULL || end - pos > 255) 1913e5b75505Sopenharmony_ci return -1; 1914e5b75505Sopenharmony_ci os_memcpy(icon->type, pos, end - pos); 1915e5b75505Sopenharmony_ci pos = end + 1; 1916e5b75505Sopenharmony_ci 1917e5b75505Sopenharmony_ci end = os_strchr(pos, ':'); 1918e5b75505Sopenharmony_ci if (end == NULL || end - pos > 255) 1919e5b75505Sopenharmony_ci return -1; 1920e5b75505Sopenharmony_ci os_memcpy(icon->name, pos, end - pos); 1921e5b75505Sopenharmony_ci pos = end + 1; 1922e5b75505Sopenharmony_ci 1923e5b75505Sopenharmony_ci if (os_strlen(pos) > 255) 1924e5b75505Sopenharmony_ci return -1; 1925e5b75505Sopenharmony_ci os_memcpy(icon->file, pos, os_strlen(pos)); 1926e5b75505Sopenharmony_ci 1927e5b75505Sopenharmony_ci bss->hs20_icons_count++; 1928e5b75505Sopenharmony_ci 1929e5b75505Sopenharmony_ci return 0; 1930e5b75505Sopenharmony_ci} 1931e5b75505Sopenharmony_ci 1932e5b75505Sopenharmony_ci 1933e5b75505Sopenharmony_cistatic int hs20_parse_osu_ssid(struct hostapd_bss_config *bss, 1934e5b75505Sopenharmony_ci char *pos, int line) 1935e5b75505Sopenharmony_ci{ 1936e5b75505Sopenharmony_ci size_t slen; 1937e5b75505Sopenharmony_ci char *str; 1938e5b75505Sopenharmony_ci 1939e5b75505Sopenharmony_ci str = wpa_config_parse_string(pos, &slen); 1940e5b75505Sopenharmony_ci if (str == NULL || slen < 1 || slen > SSID_MAX_LEN) { 1941e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid SSID '%s'", line, pos); 1942e5b75505Sopenharmony_ci os_free(str); 1943e5b75505Sopenharmony_ci return -1; 1944e5b75505Sopenharmony_ci } 1945e5b75505Sopenharmony_ci 1946e5b75505Sopenharmony_ci os_memcpy(bss->osu_ssid, str, slen); 1947e5b75505Sopenharmony_ci bss->osu_ssid_len = slen; 1948e5b75505Sopenharmony_ci os_free(str); 1949e5b75505Sopenharmony_ci 1950e5b75505Sopenharmony_ci return 0; 1951e5b75505Sopenharmony_ci} 1952e5b75505Sopenharmony_ci 1953e5b75505Sopenharmony_ci 1954e5b75505Sopenharmony_cistatic int hs20_parse_osu_server_uri(struct hostapd_bss_config *bss, 1955e5b75505Sopenharmony_ci char *pos, int line) 1956e5b75505Sopenharmony_ci{ 1957e5b75505Sopenharmony_ci struct hs20_osu_provider *p; 1958e5b75505Sopenharmony_ci 1959e5b75505Sopenharmony_ci p = os_realloc_array(bss->hs20_osu_providers, 1960e5b75505Sopenharmony_ci bss->hs20_osu_providers_count + 1, sizeof(*p)); 1961e5b75505Sopenharmony_ci if (p == NULL) 1962e5b75505Sopenharmony_ci return -1; 1963e5b75505Sopenharmony_ci 1964e5b75505Sopenharmony_ci bss->hs20_osu_providers = p; 1965e5b75505Sopenharmony_ci bss->last_osu = &bss->hs20_osu_providers[bss->hs20_osu_providers_count]; 1966e5b75505Sopenharmony_ci bss->hs20_osu_providers_count++; 1967e5b75505Sopenharmony_ci os_memset(bss->last_osu, 0, sizeof(*p)); 1968e5b75505Sopenharmony_ci bss->last_osu->server_uri = os_strdup(pos); 1969e5b75505Sopenharmony_ci 1970e5b75505Sopenharmony_ci return 0; 1971e5b75505Sopenharmony_ci} 1972e5b75505Sopenharmony_ci 1973e5b75505Sopenharmony_ci 1974e5b75505Sopenharmony_cistatic int hs20_parse_osu_friendly_name(struct hostapd_bss_config *bss, 1975e5b75505Sopenharmony_ci char *pos, int line) 1976e5b75505Sopenharmony_ci{ 1977e5b75505Sopenharmony_ci if (bss->last_osu == NULL) { 1978e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line); 1979e5b75505Sopenharmony_ci return -1; 1980e5b75505Sopenharmony_ci } 1981e5b75505Sopenharmony_ci 1982e5b75505Sopenharmony_ci if (parse_lang_string(&bss->last_osu->friendly_name, 1983e5b75505Sopenharmony_ci &bss->last_osu->friendly_name_count, pos)) { 1984e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid osu_friendly_name '%s'", 1985e5b75505Sopenharmony_ci line, pos); 1986e5b75505Sopenharmony_ci return -1; 1987e5b75505Sopenharmony_ci } 1988e5b75505Sopenharmony_ci 1989e5b75505Sopenharmony_ci return 0; 1990e5b75505Sopenharmony_ci} 1991e5b75505Sopenharmony_ci 1992e5b75505Sopenharmony_ci 1993e5b75505Sopenharmony_cistatic int hs20_parse_osu_nai(struct hostapd_bss_config *bss, 1994e5b75505Sopenharmony_ci char *pos, int line) 1995e5b75505Sopenharmony_ci{ 1996e5b75505Sopenharmony_ci if (bss->last_osu == NULL) { 1997e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line); 1998e5b75505Sopenharmony_ci return -1; 1999e5b75505Sopenharmony_ci } 2000e5b75505Sopenharmony_ci 2001e5b75505Sopenharmony_ci os_free(bss->last_osu->osu_nai); 2002e5b75505Sopenharmony_ci bss->last_osu->osu_nai = os_strdup(pos); 2003e5b75505Sopenharmony_ci if (bss->last_osu->osu_nai == NULL) 2004e5b75505Sopenharmony_ci return -1; 2005e5b75505Sopenharmony_ci 2006e5b75505Sopenharmony_ci return 0; 2007e5b75505Sopenharmony_ci} 2008e5b75505Sopenharmony_ci 2009e5b75505Sopenharmony_ci 2010e5b75505Sopenharmony_cistatic int hs20_parse_osu_nai2(struct hostapd_bss_config *bss, 2011e5b75505Sopenharmony_ci char *pos, int line) 2012e5b75505Sopenharmony_ci{ 2013e5b75505Sopenharmony_ci if (bss->last_osu == NULL) { 2014e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line); 2015e5b75505Sopenharmony_ci return -1; 2016e5b75505Sopenharmony_ci } 2017e5b75505Sopenharmony_ci 2018e5b75505Sopenharmony_ci os_free(bss->last_osu->osu_nai2); 2019e5b75505Sopenharmony_ci bss->last_osu->osu_nai2 = os_strdup(pos); 2020e5b75505Sopenharmony_ci if (bss->last_osu->osu_nai2 == NULL) 2021e5b75505Sopenharmony_ci return -1; 2022e5b75505Sopenharmony_ci bss->hs20_osu_providers_nai_count++; 2023e5b75505Sopenharmony_ci 2024e5b75505Sopenharmony_ci return 0; 2025e5b75505Sopenharmony_ci} 2026e5b75505Sopenharmony_ci 2027e5b75505Sopenharmony_ci 2028e5b75505Sopenharmony_cistatic int hs20_parse_osu_method_list(struct hostapd_bss_config *bss, char *pos, 2029e5b75505Sopenharmony_ci int line) 2030e5b75505Sopenharmony_ci{ 2031e5b75505Sopenharmony_ci if (bss->last_osu == NULL) { 2032e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line); 2033e5b75505Sopenharmony_ci return -1; 2034e5b75505Sopenharmony_ci } 2035e5b75505Sopenharmony_ci 2036e5b75505Sopenharmony_ci if (hostapd_parse_intlist(&bss->last_osu->method_list, pos)) { 2037e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid osu_method_list", line); 2038e5b75505Sopenharmony_ci return -1; 2039e5b75505Sopenharmony_ci } 2040e5b75505Sopenharmony_ci 2041e5b75505Sopenharmony_ci return 0; 2042e5b75505Sopenharmony_ci} 2043e5b75505Sopenharmony_ci 2044e5b75505Sopenharmony_ci 2045e5b75505Sopenharmony_cistatic int hs20_parse_osu_icon(struct hostapd_bss_config *bss, char *pos, 2046e5b75505Sopenharmony_ci int line) 2047e5b75505Sopenharmony_ci{ 2048e5b75505Sopenharmony_ci char **n; 2049e5b75505Sopenharmony_ci struct hs20_osu_provider *p = bss->last_osu; 2050e5b75505Sopenharmony_ci 2051e5b75505Sopenharmony_ci if (p == NULL) { 2052e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line); 2053e5b75505Sopenharmony_ci return -1; 2054e5b75505Sopenharmony_ci } 2055e5b75505Sopenharmony_ci 2056e5b75505Sopenharmony_ci n = os_realloc_array(p->icons, p->icons_count + 1, sizeof(char *)); 2057e5b75505Sopenharmony_ci if (n == NULL) 2058e5b75505Sopenharmony_ci return -1; 2059e5b75505Sopenharmony_ci p->icons = n; 2060e5b75505Sopenharmony_ci p->icons[p->icons_count] = os_strdup(pos); 2061e5b75505Sopenharmony_ci if (p->icons[p->icons_count] == NULL) 2062e5b75505Sopenharmony_ci return -1; 2063e5b75505Sopenharmony_ci p->icons_count++; 2064e5b75505Sopenharmony_ci 2065e5b75505Sopenharmony_ci return 0; 2066e5b75505Sopenharmony_ci} 2067e5b75505Sopenharmony_ci 2068e5b75505Sopenharmony_ci 2069e5b75505Sopenharmony_cistatic int hs20_parse_osu_service_desc(struct hostapd_bss_config *bss, 2070e5b75505Sopenharmony_ci char *pos, int line) 2071e5b75505Sopenharmony_ci{ 2072e5b75505Sopenharmony_ci if (bss->last_osu == NULL) { 2073e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line); 2074e5b75505Sopenharmony_ci return -1; 2075e5b75505Sopenharmony_ci } 2076e5b75505Sopenharmony_ci 2077e5b75505Sopenharmony_ci if (parse_lang_string(&bss->last_osu->service_desc, 2078e5b75505Sopenharmony_ci &bss->last_osu->service_desc_count, pos)) { 2079e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid osu_service_desc '%s'", 2080e5b75505Sopenharmony_ci line, pos); 2081e5b75505Sopenharmony_ci return -1; 2082e5b75505Sopenharmony_ci } 2083e5b75505Sopenharmony_ci 2084e5b75505Sopenharmony_ci return 0; 2085e5b75505Sopenharmony_ci} 2086e5b75505Sopenharmony_ci 2087e5b75505Sopenharmony_ci 2088e5b75505Sopenharmony_cistatic int hs20_parse_operator_icon(struct hostapd_bss_config *bss, char *pos, 2089e5b75505Sopenharmony_ci int line) 2090e5b75505Sopenharmony_ci{ 2091e5b75505Sopenharmony_ci char **n; 2092e5b75505Sopenharmony_ci 2093e5b75505Sopenharmony_ci n = os_realloc_array(bss->hs20_operator_icon, 2094e5b75505Sopenharmony_ci bss->hs20_operator_icon_count + 1, sizeof(char *)); 2095e5b75505Sopenharmony_ci if (!n) 2096e5b75505Sopenharmony_ci return -1; 2097e5b75505Sopenharmony_ci bss->hs20_operator_icon = n; 2098e5b75505Sopenharmony_ci bss->hs20_operator_icon[bss->hs20_operator_icon_count] = os_strdup(pos); 2099e5b75505Sopenharmony_ci if (!bss->hs20_operator_icon[bss->hs20_operator_icon_count]) 2100e5b75505Sopenharmony_ci return -1; 2101e5b75505Sopenharmony_ci bss->hs20_operator_icon_count++; 2102e5b75505Sopenharmony_ci 2103e5b75505Sopenharmony_ci return 0; 2104e5b75505Sopenharmony_ci} 2105e5b75505Sopenharmony_ci 2106e5b75505Sopenharmony_ci#endif /* CONFIG_HS20 */ 2107e5b75505Sopenharmony_ci 2108e5b75505Sopenharmony_ci 2109e5b75505Sopenharmony_ci#ifdef CONFIG_ACS 2110e5b75505Sopenharmony_cistatic int hostapd_config_parse_acs_chan_bias(struct hostapd_config *conf, 2111e5b75505Sopenharmony_ci char *pos) 2112e5b75505Sopenharmony_ci{ 2113e5b75505Sopenharmony_ci struct acs_bias *bias = NULL, *tmp; 2114e5b75505Sopenharmony_ci unsigned int num = 0; 2115e5b75505Sopenharmony_ci char *end; 2116e5b75505Sopenharmony_ci 2117e5b75505Sopenharmony_ci while (*pos) { 2118e5b75505Sopenharmony_ci tmp = os_realloc_array(bias, num + 1, sizeof(*bias)); 2119e5b75505Sopenharmony_ci if (!tmp) 2120e5b75505Sopenharmony_ci goto fail; 2121e5b75505Sopenharmony_ci bias = tmp; 2122e5b75505Sopenharmony_ci 2123e5b75505Sopenharmony_ci bias[num].channel = atoi(pos); 2124e5b75505Sopenharmony_ci if (bias[num].channel <= 0) 2125e5b75505Sopenharmony_ci goto fail; 2126e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 2127e5b75505Sopenharmony_ci if (!pos) 2128e5b75505Sopenharmony_ci goto fail; 2129e5b75505Sopenharmony_ci pos++; 2130e5b75505Sopenharmony_ci bias[num].bias = strtod(pos, &end); 2131e5b75505Sopenharmony_ci if (end == pos || bias[num].bias < 0.0) 2132e5b75505Sopenharmony_ci goto fail; 2133e5b75505Sopenharmony_ci pos = end; 2134e5b75505Sopenharmony_ci if (*pos != ' ' && *pos != '\0') 2135e5b75505Sopenharmony_ci goto fail; 2136e5b75505Sopenharmony_ci num++; 2137e5b75505Sopenharmony_ci } 2138e5b75505Sopenharmony_ci 2139e5b75505Sopenharmony_ci os_free(conf->acs_chan_bias); 2140e5b75505Sopenharmony_ci conf->acs_chan_bias = bias; 2141e5b75505Sopenharmony_ci conf->num_acs_chan_bias = num; 2142e5b75505Sopenharmony_ci 2143e5b75505Sopenharmony_ci return 0; 2144e5b75505Sopenharmony_cifail: 2145e5b75505Sopenharmony_ci os_free(bias); 2146e5b75505Sopenharmony_ci return -1; 2147e5b75505Sopenharmony_ci} 2148e5b75505Sopenharmony_ci#endif /* CONFIG_ACS */ 2149e5b75505Sopenharmony_ci 2150e5b75505Sopenharmony_ci 2151e5b75505Sopenharmony_cistatic int parse_wpabuf_hex(int line, const char *name, struct wpabuf **buf, 2152e5b75505Sopenharmony_ci const char *val) 2153e5b75505Sopenharmony_ci{ 2154e5b75505Sopenharmony_ci struct wpabuf *elems; 2155e5b75505Sopenharmony_ci 2156e5b75505Sopenharmony_ci if (val[0] == '\0') { 2157e5b75505Sopenharmony_ci wpabuf_free(*buf); 2158e5b75505Sopenharmony_ci *buf = NULL; 2159e5b75505Sopenharmony_ci return 0; 2160e5b75505Sopenharmony_ci } 2161e5b75505Sopenharmony_ci 2162e5b75505Sopenharmony_ci elems = wpabuf_parse_bin(val); 2163e5b75505Sopenharmony_ci if (!elems) { 2164e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid %s '%s'", 2165e5b75505Sopenharmony_ci line, name, val); 2166e5b75505Sopenharmony_ci return -1; 2167e5b75505Sopenharmony_ci } 2168e5b75505Sopenharmony_ci 2169e5b75505Sopenharmony_ci wpabuf_free(*buf); 2170e5b75505Sopenharmony_ci *buf = elems; 2171e5b75505Sopenharmony_ci 2172e5b75505Sopenharmony_ci return 0; 2173e5b75505Sopenharmony_ci} 2174e5b75505Sopenharmony_ci 2175e5b75505Sopenharmony_ci 2176e5b75505Sopenharmony_ci#ifdef CONFIG_FILS 2177e5b75505Sopenharmony_cistatic int parse_fils_realm(struct hostapd_bss_config *bss, const char *val) 2178e5b75505Sopenharmony_ci{ 2179e5b75505Sopenharmony_ci struct fils_realm *realm; 2180e5b75505Sopenharmony_ci size_t len; 2181e5b75505Sopenharmony_ci 2182e5b75505Sopenharmony_ci len = os_strlen(val); 2183e5b75505Sopenharmony_ci realm = os_zalloc(sizeof(*realm) + len + 1); 2184e5b75505Sopenharmony_ci if (!realm) 2185e5b75505Sopenharmony_ci return -1; 2186e5b75505Sopenharmony_ci 2187e5b75505Sopenharmony_ci os_memcpy(realm->realm, val, len); 2188e5b75505Sopenharmony_ci if (fils_domain_name_hash(val, realm->hash) < 0) { 2189e5b75505Sopenharmony_ci os_free(realm); 2190e5b75505Sopenharmony_ci return -1; 2191e5b75505Sopenharmony_ci } 2192e5b75505Sopenharmony_ci dl_list_add_tail(&bss->fils_realms, &realm->list); 2193e5b75505Sopenharmony_ci 2194e5b75505Sopenharmony_ci return 0; 2195e5b75505Sopenharmony_ci} 2196e5b75505Sopenharmony_ci#endif /* CONFIG_FILS */ 2197e5b75505Sopenharmony_ci 2198e5b75505Sopenharmony_ci 2199e5b75505Sopenharmony_ci#ifdef EAP_SERVER 2200e5b75505Sopenharmony_cistatic unsigned int parse_tls_flags(const char *val) 2201e5b75505Sopenharmony_ci{ 2202e5b75505Sopenharmony_ci unsigned int flags = 0; 2203e5b75505Sopenharmony_ci 2204e5b75505Sopenharmony_ci /* Disable TLS v1.3 by default for now to avoid interoperability issue. 2205e5b75505Sopenharmony_ci * This can be enabled by default once the implementation has been fully 2206e5b75505Sopenharmony_ci * completed and tested with other implementations. */ 2207e5b75505Sopenharmony_ci flags |= TLS_CONN_DISABLE_TLSv1_3; 2208e5b75505Sopenharmony_ci 2209e5b75505Sopenharmony_ci if (os_strstr(val, "[ALLOW-SIGN-RSA-MD5]")) 2210e5b75505Sopenharmony_ci flags |= TLS_CONN_ALLOW_SIGN_RSA_MD5; 2211e5b75505Sopenharmony_ci if (os_strstr(val, "[DISABLE-TIME-CHECKS]")) 2212e5b75505Sopenharmony_ci flags |= TLS_CONN_DISABLE_TIME_CHECKS; 2213e5b75505Sopenharmony_ci if (os_strstr(val, "[DISABLE-TLSv1.0]")) 2214e5b75505Sopenharmony_ci flags |= TLS_CONN_DISABLE_TLSv1_0; 2215e5b75505Sopenharmony_ci if (os_strstr(val, "[ENABLE-TLSv1.0]")) 2216e5b75505Sopenharmony_ci flags |= TLS_CONN_ENABLE_TLSv1_0; 2217e5b75505Sopenharmony_ci if (os_strstr(val, "[DISABLE-TLSv1.1]")) 2218e5b75505Sopenharmony_ci flags |= TLS_CONN_DISABLE_TLSv1_1; 2219e5b75505Sopenharmony_ci if (os_strstr(val, "[ENABLE-TLSv1.1]")) 2220e5b75505Sopenharmony_ci flags |= TLS_CONN_ENABLE_TLSv1_1; 2221e5b75505Sopenharmony_ci if (os_strstr(val, "[DISABLE-TLSv1.2]")) 2222e5b75505Sopenharmony_ci flags |= TLS_CONN_DISABLE_TLSv1_2; 2223e5b75505Sopenharmony_ci if (os_strstr(val, "[ENABLE-TLSv1.2]")) 2224e5b75505Sopenharmony_ci flags |= TLS_CONN_ENABLE_TLSv1_2; 2225e5b75505Sopenharmony_ci if (os_strstr(val, "[DISABLE-TLSv1.3]")) 2226e5b75505Sopenharmony_ci flags |= TLS_CONN_DISABLE_TLSv1_3; 2227e5b75505Sopenharmony_ci if (os_strstr(val, "[ENABLE-TLSv1.3]")) 2228e5b75505Sopenharmony_ci flags &= ~TLS_CONN_DISABLE_TLSv1_3; 2229e5b75505Sopenharmony_ci if (os_strstr(val, "[SUITEB]")) 2230e5b75505Sopenharmony_ci flags |= TLS_CONN_SUITEB; 2231e5b75505Sopenharmony_ci if (os_strstr(val, "[SUITEB-NO-ECDH]")) 2232e5b75505Sopenharmony_ci flags |= TLS_CONN_SUITEB_NO_ECDH | TLS_CONN_SUITEB; 2233e5b75505Sopenharmony_ci 2234e5b75505Sopenharmony_ci return flags; 2235e5b75505Sopenharmony_ci} 2236e5b75505Sopenharmony_ci#endif /* EAP_SERVER */ 2237e5b75505Sopenharmony_ci 2238e5b75505Sopenharmony_ci 2239e5b75505Sopenharmony_ci#ifdef CONFIG_AIRTIME_POLICY 2240e5b75505Sopenharmony_cistatic int add_airtime_weight(struct hostapd_bss_config *bss, char *value) 2241e5b75505Sopenharmony_ci{ 2242e5b75505Sopenharmony_ci struct airtime_sta_weight *wt; 2243e5b75505Sopenharmony_ci char *pos, *next; 2244e5b75505Sopenharmony_ci 2245e5b75505Sopenharmony_ci wt = os_zalloc(sizeof(*wt)); 2246e5b75505Sopenharmony_ci if (!wt) 2247e5b75505Sopenharmony_ci return -1; 2248e5b75505Sopenharmony_ci 2249e5b75505Sopenharmony_ci /* 02:01:02:03:04:05 10 */ 2250e5b75505Sopenharmony_ci pos = value; 2251e5b75505Sopenharmony_ci next = os_strchr(pos, ' '); 2252e5b75505Sopenharmony_ci if (next) 2253e5b75505Sopenharmony_ci *next++ = '\0'; 2254e5b75505Sopenharmony_ci if (!next || hwaddr_aton(pos, wt->addr)) { 2255e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid station address: '%s'", pos); 2256e5b75505Sopenharmony_ci os_free(wt); 2257e5b75505Sopenharmony_ci return -1; 2258e5b75505Sopenharmony_ci } 2259e5b75505Sopenharmony_ci 2260e5b75505Sopenharmony_ci pos = next; 2261e5b75505Sopenharmony_ci wt->weight = atoi(pos); 2262e5b75505Sopenharmony_ci if (!wt->weight) { 2263e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Invalid weight: '%s'", pos); 2264e5b75505Sopenharmony_ci os_free(wt); 2265e5b75505Sopenharmony_ci return -1; 2266e5b75505Sopenharmony_ci } 2267e5b75505Sopenharmony_ci 2268e5b75505Sopenharmony_ci wt->next = bss->airtime_weight_list; 2269e5b75505Sopenharmony_ci bss->airtime_weight_list = wt; 2270e5b75505Sopenharmony_ci return 0; 2271e5b75505Sopenharmony_ci} 2272e5b75505Sopenharmony_ci#endif /* CONFIG_AIRTIME_POLICY */ 2273e5b75505Sopenharmony_ci 2274e5b75505Sopenharmony_ci 2275e5b75505Sopenharmony_ci#ifdef CONFIG_SAE 2276e5b75505Sopenharmony_cistatic int parse_sae_password(struct hostapd_bss_config *bss, const char *val) 2277e5b75505Sopenharmony_ci{ 2278e5b75505Sopenharmony_ci struct sae_password_entry *pw; 2279e5b75505Sopenharmony_ci const char *pos = val, *pos2, *end = NULL; 2280e5b75505Sopenharmony_ci 2281e5b75505Sopenharmony_ci pw = os_zalloc(sizeof(*pw)); 2282e5b75505Sopenharmony_ci if (!pw) 2283e5b75505Sopenharmony_ci return -1; 2284e5b75505Sopenharmony_ci os_memset(pw->peer_addr, 0xff, ETH_ALEN); /* default to wildcard */ 2285e5b75505Sopenharmony_ci 2286e5b75505Sopenharmony_ci pos2 = os_strstr(pos, "|mac="); 2287e5b75505Sopenharmony_ci if (pos2) { 2288e5b75505Sopenharmony_ci end = pos2; 2289e5b75505Sopenharmony_ci pos2 += 5; 2290e5b75505Sopenharmony_ci if (hwaddr_aton(pos2, pw->peer_addr) < 0) 2291e5b75505Sopenharmony_ci goto fail; 2292e5b75505Sopenharmony_ci pos = pos2 + ETH_ALEN * 3 - 1; 2293e5b75505Sopenharmony_ci } 2294e5b75505Sopenharmony_ci 2295e5b75505Sopenharmony_ci pos2 = os_strstr(pos, "|vlanid="); 2296e5b75505Sopenharmony_ci if (pos2) { 2297e5b75505Sopenharmony_ci if (!end) 2298e5b75505Sopenharmony_ci end = pos2; 2299e5b75505Sopenharmony_ci pos2 += 8; 2300e5b75505Sopenharmony_ci pw->vlan_id = atoi(pos2); 2301e5b75505Sopenharmony_ci } 2302e5b75505Sopenharmony_ci 2303e5b75505Sopenharmony_ci pos2 = os_strstr(pos, "|id="); 2304e5b75505Sopenharmony_ci if (pos2) { 2305e5b75505Sopenharmony_ci if (!end) 2306e5b75505Sopenharmony_ci end = pos2; 2307e5b75505Sopenharmony_ci pos2 += 4; 2308e5b75505Sopenharmony_ci pw->identifier = os_strdup(pos2); 2309e5b75505Sopenharmony_ci if (!pw->identifier) 2310e5b75505Sopenharmony_ci goto fail; 2311e5b75505Sopenharmony_ci } 2312e5b75505Sopenharmony_ci 2313e5b75505Sopenharmony_ci if (!end) { 2314e5b75505Sopenharmony_ci pw->password = os_strdup(val); 2315e5b75505Sopenharmony_ci if (!pw->password) 2316e5b75505Sopenharmony_ci goto fail; 2317e5b75505Sopenharmony_ci } else { 2318e5b75505Sopenharmony_ci pw->password = os_malloc(end - val + 1); 2319e5b75505Sopenharmony_ci if (!pw->password) 2320e5b75505Sopenharmony_ci goto fail; 2321e5b75505Sopenharmony_ci os_memcpy(pw->password, val, end - val); 2322e5b75505Sopenharmony_ci pw->password[end - val] = '\0'; 2323e5b75505Sopenharmony_ci } 2324e5b75505Sopenharmony_ci 2325e5b75505Sopenharmony_ci pw->next = bss->sae_passwords; 2326e5b75505Sopenharmony_ci bss->sae_passwords = pw; 2327e5b75505Sopenharmony_ci 2328e5b75505Sopenharmony_ci return 0; 2329e5b75505Sopenharmony_cifail: 2330e5b75505Sopenharmony_ci str_clear_free(pw->password); 2331e5b75505Sopenharmony_ci os_free(pw->identifier); 2332e5b75505Sopenharmony_ci os_free(pw); 2333e5b75505Sopenharmony_ci return -1; 2334e5b75505Sopenharmony_ci} 2335e5b75505Sopenharmony_ci#endif /* CONFIG_SAE */ 2336e5b75505Sopenharmony_ci 2337e5b75505Sopenharmony_ci 2338e5b75505Sopenharmony_ci#ifdef CONFIG_DPP2 2339e5b75505Sopenharmony_cistatic int hostapd_dpp_controller_parse(struct hostapd_bss_config *bss, 2340e5b75505Sopenharmony_ci const char *pos) 2341e5b75505Sopenharmony_ci{ 2342e5b75505Sopenharmony_ci struct dpp_controller_conf *conf; 2343e5b75505Sopenharmony_ci char *val; 2344e5b75505Sopenharmony_ci 2345e5b75505Sopenharmony_ci conf = os_zalloc(sizeof(*conf)); 2346e5b75505Sopenharmony_ci if (!conf) 2347e5b75505Sopenharmony_ci return -1; 2348e5b75505Sopenharmony_ci val = get_param(pos, "ipaddr="); 2349e5b75505Sopenharmony_ci if (!val || hostapd_parse_ip_addr(val, &conf->ipaddr)) 2350e5b75505Sopenharmony_ci goto fail; 2351e5b75505Sopenharmony_ci os_free(val); 2352e5b75505Sopenharmony_ci val = get_param(pos, "pkhash="); 2353e5b75505Sopenharmony_ci if (!val || os_strlen(val) != 2 * SHA256_MAC_LEN || 2354e5b75505Sopenharmony_ci hexstr2bin(val, conf->pkhash, SHA256_MAC_LEN) < 0) 2355e5b75505Sopenharmony_ci goto fail; 2356e5b75505Sopenharmony_ci os_free(val); 2357e5b75505Sopenharmony_ci conf->next = bss->dpp_controller; 2358e5b75505Sopenharmony_ci bss->dpp_controller = conf; 2359e5b75505Sopenharmony_ci return 0; 2360e5b75505Sopenharmony_cifail: 2361e5b75505Sopenharmony_ci os_free(val); 2362e5b75505Sopenharmony_ci os_free(conf); 2363e5b75505Sopenharmony_ci return -1; 2364e5b75505Sopenharmony_ci} 2365e5b75505Sopenharmony_ci#endif /* CONFIG_DPP2 */ 2366e5b75505Sopenharmony_ci 2367e5b75505Sopenharmony_ci 2368e5b75505Sopenharmony_cistatic int hostapd_config_fill(struct hostapd_config *conf, 2369e5b75505Sopenharmony_ci struct hostapd_bss_config *bss, 2370e5b75505Sopenharmony_ci const char *buf, char *pos, int line) 2371e5b75505Sopenharmony_ci{ 2372e5b75505Sopenharmony_ci if (os_strcmp(buf, "interface") == 0) { 2373e5b75505Sopenharmony_ci os_strlcpy(conf->bss[0]->iface, pos, 2374e5b75505Sopenharmony_ci sizeof(conf->bss[0]->iface)); 2375e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "bridge") == 0) { 2376e5b75505Sopenharmony_ci os_strlcpy(bss->bridge, pos, sizeof(bss->bridge)); 2377e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vlan_bridge") == 0) { 2378e5b75505Sopenharmony_ci os_strlcpy(bss->vlan_bridge, pos, sizeof(bss->vlan_bridge)); 2379e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wds_bridge") == 0) { 2380e5b75505Sopenharmony_ci os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge)); 2381e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "driver") == 0) { 2382e5b75505Sopenharmony_ci int j; 2383e5b75505Sopenharmony_ci const struct wpa_driver_ops *driver = NULL; 2384e5b75505Sopenharmony_ci 2385e5b75505Sopenharmony_ci for (j = 0; wpa_drivers[j]; j++) { 2386e5b75505Sopenharmony_ci if (os_strcmp(pos, wpa_drivers[j]->name) == 0) { 2387e5b75505Sopenharmony_ci driver = wpa_drivers[j]; 2388e5b75505Sopenharmony_ci break; 2389e5b75505Sopenharmony_ci } 2390e5b75505Sopenharmony_ci } 2391e5b75505Sopenharmony_ci if (!driver) { 2392e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2393e5b75505Sopenharmony_ci "Line %d: invalid/unknown driver '%s'", 2394e5b75505Sopenharmony_ci line, pos); 2395e5b75505Sopenharmony_ci return 1; 2396e5b75505Sopenharmony_ci } 2397e5b75505Sopenharmony_ci conf->driver = driver; 2398e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "driver_params") == 0) { 2399e5b75505Sopenharmony_ci os_free(conf->driver_params); 2400e5b75505Sopenharmony_ci conf->driver_params = os_strdup(pos); 2401e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "debug") == 0) { 2402e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore", 2403e5b75505Sopenharmony_ci line); 2404e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "logger_syslog_level") == 0) { 2405e5b75505Sopenharmony_ci bss->logger_syslog_level = atoi(pos); 2406e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "logger_stdout_level") == 0) { 2407e5b75505Sopenharmony_ci bss->logger_stdout_level = atoi(pos); 2408e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "logger_syslog") == 0) { 2409e5b75505Sopenharmony_ci bss->logger_syslog = atoi(pos); 2410e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "logger_stdout") == 0) { 2411e5b75505Sopenharmony_ci bss->logger_stdout = atoi(pos); 2412e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dump_file") == 0) { 2413e5b75505Sopenharmony_ci wpa_printf(MSG_INFO, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore", 2414e5b75505Sopenharmony_ci line); 2415e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ssid") == 0) { 2416e5b75505Sopenharmony_ci bss->ssid.ssid_len = os_strlen(pos); 2417e5b75505Sopenharmony_ci if (bss->ssid.ssid_len > SSID_MAX_LEN || 2418e5b75505Sopenharmony_ci bss->ssid.ssid_len < 1) { 2419e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'", 2420e5b75505Sopenharmony_ci line, pos); 2421e5b75505Sopenharmony_ci return 1; 2422e5b75505Sopenharmony_ci } 2423e5b75505Sopenharmony_ci os_memcpy(bss->ssid.ssid, pos, bss->ssid.ssid_len); 2424e5b75505Sopenharmony_ci bss->ssid.ssid_set = 1; 2425e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ssid2") == 0) { 2426e5b75505Sopenharmony_ci size_t slen; 2427e5b75505Sopenharmony_ci char *str = wpa_config_parse_string(pos, &slen); 2428e5b75505Sopenharmony_ci if (str == NULL || slen < 1 || slen > SSID_MAX_LEN) { 2429e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'", 2430e5b75505Sopenharmony_ci line, pos); 2431e5b75505Sopenharmony_ci os_free(str); 2432e5b75505Sopenharmony_ci return 1; 2433e5b75505Sopenharmony_ci } 2434e5b75505Sopenharmony_ci os_memcpy(bss->ssid.ssid, str, slen); 2435e5b75505Sopenharmony_ci bss->ssid.ssid_len = slen; 2436e5b75505Sopenharmony_ci bss->ssid.ssid_set = 1; 2437e5b75505Sopenharmony_ci os_free(str); 2438e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "utf8_ssid") == 0) { 2439e5b75505Sopenharmony_ci bss->ssid.utf8_ssid = atoi(pos) > 0; 2440e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "macaddr_acl") == 0) { 2441e5b75505Sopenharmony_ci enum macaddr_acl acl = atoi(pos); 2442e5b75505Sopenharmony_ci 2443e5b75505Sopenharmony_ci if (acl != ACCEPT_UNLESS_DENIED && 2444e5b75505Sopenharmony_ci acl != DENY_UNLESS_ACCEPTED && 2445e5b75505Sopenharmony_ci acl != USE_EXTERNAL_RADIUS_AUTH) { 2446e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: unknown macaddr_acl %d", 2447e5b75505Sopenharmony_ci line, acl); 2448e5b75505Sopenharmony_ci return 1; 2449e5b75505Sopenharmony_ci } 2450e5b75505Sopenharmony_ci bss->macaddr_acl = acl; 2451e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "accept_mac_file") == 0) { 2452e5b75505Sopenharmony_ci if (hostapd_config_read_maclist(pos, &bss->accept_mac, 2453e5b75505Sopenharmony_ci &bss->num_accept_mac)) { 2454e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Failed to read accept_mac_file '%s'", 2455e5b75505Sopenharmony_ci line, pos); 2456e5b75505Sopenharmony_ci return 1; 2457e5b75505Sopenharmony_ci } 2458e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "deny_mac_file") == 0) { 2459e5b75505Sopenharmony_ci if (hostapd_config_read_maclist(pos, &bss->deny_mac, 2460e5b75505Sopenharmony_ci &bss->num_deny_mac)) { 2461e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Failed to read deny_mac_file '%s'", 2462e5b75505Sopenharmony_ci line, pos); 2463e5b75505Sopenharmony_ci return 1; 2464e5b75505Sopenharmony_ci } 2465e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wds_sta") == 0) { 2466e5b75505Sopenharmony_ci bss->wds_sta = atoi(pos); 2467e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "start_disabled") == 0) { 2468e5b75505Sopenharmony_ci bss->start_disabled = atoi(pos); 2469e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_isolate") == 0) { 2470e5b75505Sopenharmony_ci bss->isolate = atoi(pos); 2471e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_max_inactivity") == 0) { 2472e5b75505Sopenharmony_ci bss->ap_max_inactivity = atoi(pos); 2473e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) { 2474e5b75505Sopenharmony_ci bss->skip_inactivity_poll = atoi(pos); 2475e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "country_code") == 0) { 2476e5b75505Sopenharmony_ci os_memcpy(conf->country, pos, 2); 2477e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "country3") == 0) { 2478e5b75505Sopenharmony_ci conf->country[2] = strtol(pos, NULL, 16); 2479e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee80211d") == 0) { 2480e5b75505Sopenharmony_ci conf->ieee80211d = atoi(pos); 2481e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee80211h") == 0) { 2482e5b75505Sopenharmony_ci conf->ieee80211h = atoi(pos); 2483e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee8021x") == 0) { 2484e5b75505Sopenharmony_ci bss->ieee802_1x = atoi(pos); 2485e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eapol_version") == 0) { 2486e5b75505Sopenharmony_ci int eapol_version = atoi(pos); 2487e5b75505Sopenharmony_ci 2488e5b75505Sopenharmony_ci#ifdef CONFIG_MACSEC 2489e5b75505Sopenharmony_ci if (eapol_version < 1 || eapol_version > 3) { 2490e5b75505Sopenharmony_ci#else /* CONFIG_MACSEC */ 2491e5b75505Sopenharmony_ci if (eapol_version < 1 || eapol_version > 2) { 2492e5b75505Sopenharmony_ci#endif /* CONFIG_MACSEC */ 2493e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2494e5b75505Sopenharmony_ci "Line %d: invalid EAPOL version (%d): '%s'.", 2495e5b75505Sopenharmony_ci line, eapol_version, pos); 2496e5b75505Sopenharmony_ci return 1; 2497e5b75505Sopenharmony_ci } 2498e5b75505Sopenharmony_ci bss->eapol_version = eapol_version; 2499e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "eapol_version=%d", bss->eapol_version); 2500e5b75505Sopenharmony_ci#ifdef EAP_SERVER 2501e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_authenticator") == 0) { 2502e5b75505Sopenharmony_ci bss->eap_server = atoi(pos); 2503e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line); 2504e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_server") == 0) { 2505e5b75505Sopenharmony_ci bss->eap_server = atoi(pos); 2506e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_user_file") == 0) { 2507e5b75505Sopenharmony_ci if (hostapd_config_read_eap_user(pos, bss)) 2508e5b75505Sopenharmony_ci return 1; 2509e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ca_cert") == 0) { 2510e5b75505Sopenharmony_ci os_free(bss->ca_cert); 2511e5b75505Sopenharmony_ci bss->ca_cert = os_strdup(pos); 2512e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "server_cert") == 0) { 2513e5b75505Sopenharmony_ci os_free(bss->server_cert); 2514e5b75505Sopenharmony_ci bss->server_cert = os_strdup(pos); 2515e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "server_cert2") == 0) { 2516e5b75505Sopenharmony_ci os_free(bss->server_cert2); 2517e5b75505Sopenharmony_ci bss->server_cert2 = os_strdup(pos); 2518e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "private_key") == 0) { 2519e5b75505Sopenharmony_ci os_free(bss->private_key); 2520e5b75505Sopenharmony_ci bss->private_key = os_strdup(pos); 2521e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "private_key2") == 0) { 2522e5b75505Sopenharmony_ci os_free(bss->private_key2); 2523e5b75505Sopenharmony_ci bss->private_key2 = os_strdup(pos); 2524e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "private_key_passwd") == 0) { 2525e5b75505Sopenharmony_ci os_free(bss->private_key_passwd); 2526e5b75505Sopenharmony_ci bss->private_key_passwd = os_strdup(pos); 2527e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "private_key_passwd2") == 0) { 2528e5b75505Sopenharmony_ci os_free(bss->private_key_passwd2); 2529e5b75505Sopenharmony_ci bss->private_key_passwd2 = os_strdup(pos); 2530e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "check_cert_subject") == 0) { 2531e5b75505Sopenharmony_ci if (!pos[0]) { 2532e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: unknown check_cert_subject '%s'", 2533e5b75505Sopenharmony_ci line, pos); 2534e5b75505Sopenharmony_ci return 1; 2535e5b75505Sopenharmony_ci } 2536e5b75505Sopenharmony_ci os_free(bss->check_cert_subject); 2537e5b75505Sopenharmony_ci bss->check_cert_subject = os_strdup(pos); 2538e5b75505Sopenharmony_ci if (!bss->check_cert_subject) 2539e5b75505Sopenharmony_ci return 1; 2540e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "check_crl") == 0) { 2541e5b75505Sopenharmony_ci bss->check_crl = atoi(pos); 2542e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "check_crl_strict") == 0) { 2543e5b75505Sopenharmony_ci bss->check_crl_strict = atoi(pos); 2544e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "crl_reload_interval") == 0) { 2545e5b75505Sopenharmony_ci bss->crl_reload_interval = atoi(pos); 2546e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "tls_session_lifetime") == 0) { 2547e5b75505Sopenharmony_ci bss->tls_session_lifetime = atoi(pos); 2548e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "tls_flags") == 0) { 2549e5b75505Sopenharmony_ci bss->tls_flags = parse_tls_flags(pos); 2550e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ocsp_stapling_response") == 0) { 2551e5b75505Sopenharmony_ci os_free(bss->ocsp_stapling_response); 2552e5b75505Sopenharmony_ci bss->ocsp_stapling_response = os_strdup(pos); 2553e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ocsp_stapling_response_multi") == 0) { 2554e5b75505Sopenharmony_ci os_free(bss->ocsp_stapling_response_multi); 2555e5b75505Sopenharmony_ci bss->ocsp_stapling_response_multi = os_strdup(pos); 2556e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dh_file") == 0) { 2557e5b75505Sopenharmony_ci os_free(bss->dh_file); 2558e5b75505Sopenharmony_ci bss->dh_file = os_strdup(pos); 2559e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "openssl_ciphers") == 0) { 2560e5b75505Sopenharmony_ci os_free(bss->openssl_ciphers); 2561e5b75505Sopenharmony_ci bss->openssl_ciphers = os_strdup(pos); 2562e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "openssl_ecdh_curves") == 0) { 2563e5b75505Sopenharmony_ci os_free(bss->openssl_ecdh_curves); 2564e5b75505Sopenharmony_ci bss->openssl_ecdh_curves = os_strdup(pos); 2565e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fragment_size") == 0) { 2566e5b75505Sopenharmony_ci bss->fragment_size = atoi(pos); 2567e5b75505Sopenharmony_ci#ifdef EAP_SERVER_FAST 2568e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) { 2569e5b75505Sopenharmony_ci os_free(bss->pac_opaque_encr_key); 2570e5b75505Sopenharmony_ci bss->pac_opaque_encr_key = os_malloc(16); 2571e5b75505Sopenharmony_ci if (bss->pac_opaque_encr_key == NULL) { 2572e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2573e5b75505Sopenharmony_ci "Line %d: No memory for pac_opaque_encr_key", 2574e5b75505Sopenharmony_ci line); 2575e5b75505Sopenharmony_ci return 1; 2576e5b75505Sopenharmony_ci } else if (hexstr2bin(pos, bss->pac_opaque_encr_key, 16)) { 2577e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid pac_opaque_encr_key", 2578e5b75505Sopenharmony_ci line); 2579e5b75505Sopenharmony_ci return 1; 2580e5b75505Sopenharmony_ci } 2581e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_fast_a_id") == 0) { 2582e5b75505Sopenharmony_ci size_t idlen = os_strlen(pos); 2583e5b75505Sopenharmony_ci if (idlen & 1) { 2584e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid eap_fast_a_id", 2585e5b75505Sopenharmony_ci line); 2586e5b75505Sopenharmony_ci return 1; 2587e5b75505Sopenharmony_ci } 2588e5b75505Sopenharmony_ci os_free(bss->eap_fast_a_id); 2589e5b75505Sopenharmony_ci bss->eap_fast_a_id = os_malloc(idlen / 2); 2590e5b75505Sopenharmony_ci if (bss->eap_fast_a_id == NULL || 2591e5b75505Sopenharmony_ci hexstr2bin(pos, bss->eap_fast_a_id, idlen / 2)) { 2592e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Failed to parse eap_fast_a_id", 2593e5b75505Sopenharmony_ci line); 2594e5b75505Sopenharmony_ci os_free(bss->eap_fast_a_id); 2595e5b75505Sopenharmony_ci bss->eap_fast_a_id = NULL; 2596e5b75505Sopenharmony_ci return 1; 2597e5b75505Sopenharmony_ci } else { 2598e5b75505Sopenharmony_ci bss->eap_fast_a_id_len = idlen / 2; 2599e5b75505Sopenharmony_ci } 2600e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_fast_a_id_info") == 0) { 2601e5b75505Sopenharmony_ci os_free(bss->eap_fast_a_id_info); 2602e5b75505Sopenharmony_ci bss->eap_fast_a_id_info = os_strdup(pos); 2603e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_fast_prov") == 0) { 2604e5b75505Sopenharmony_ci bss->eap_fast_prov = atoi(pos); 2605e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pac_key_lifetime") == 0) { 2606e5b75505Sopenharmony_ci bss->pac_key_lifetime = atoi(pos); 2607e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) { 2608e5b75505Sopenharmony_ci bss->pac_key_refresh_time = atoi(pos); 2609e5b75505Sopenharmony_ci#endif /* EAP_SERVER_FAST */ 2610e5b75505Sopenharmony_ci#ifdef EAP_SERVER_TEAP 2611e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_teap_auth") == 0) { 2612e5b75505Sopenharmony_ci int val = atoi(pos); 2613e5b75505Sopenharmony_ci 2614e5b75505Sopenharmony_ci if (val < 0 || val > 1) { 2615e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2616e5b75505Sopenharmony_ci "Line %d: Invalid eap_teap_auth value", 2617e5b75505Sopenharmony_ci line); 2618e5b75505Sopenharmony_ci return 1; 2619e5b75505Sopenharmony_ci } 2620e5b75505Sopenharmony_ci bss->eap_teap_auth = val; 2621e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_teap_pac_no_inner") == 0) { 2622e5b75505Sopenharmony_ci bss->eap_teap_pac_no_inner = atoi(pos); 2623e5b75505Sopenharmony_ci#endif /* EAP_SERVER_TEAP */ 2624e5b75505Sopenharmony_ci#ifdef EAP_SERVER_SIM 2625e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_sim_db") == 0) { 2626e5b75505Sopenharmony_ci os_free(bss->eap_sim_db); 2627e5b75505Sopenharmony_ci bss->eap_sim_db = os_strdup(pos); 2628e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_sim_db_timeout") == 0) { 2629e5b75505Sopenharmony_ci bss->eap_sim_db_timeout = atoi(pos); 2630e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) { 2631e5b75505Sopenharmony_ci bss->eap_sim_aka_result_ind = atoi(pos); 2632e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_sim_id") == 0) { 2633e5b75505Sopenharmony_ci bss->eap_sim_id = atoi(pos); 2634e5b75505Sopenharmony_ci#endif /* EAP_SERVER_SIM */ 2635e5b75505Sopenharmony_ci#ifdef EAP_SERVER_TNC 2636e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "tnc") == 0) { 2637e5b75505Sopenharmony_ci bss->tnc = atoi(pos); 2638e5b75505Sopenharmony_ci#endif /* EAP_SERVER_TNC */ 2639e5b75505Sopenharmony_ci#ifdef EAP_SERVER_PWD 2640e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pwd_group") == 0) { 2641e5b75505Sopenharmony_ci bss->pwd_group = atoi(pos); 2642e5b75505Sopenharmony_ci#endif /* EAP_SERVER_PWD */ 2643e5b75505Sopenharmony_ci#ifdef CONFIG_ERP 2644e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_server_erp") == 0) { 2645e5b75505Sopenharmony_ci bss->eap_server_erp = atoi(pos); 2646e5b75505Sopenharmony_ci#endif /* CONFIG_ERP */ 2647e5b75505Sopenharmony_ci#endif /* EAP_SERVER */ 2648e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_message") == 0) { 2649e5b75505Sopenharmony_ci char *term; 2650e5b75505Sopenharmony_ci os_free(bss->eap_req_id_text); 2651e5b75505Sopenharmony_ci bss->eap_req_id_text = os_strdup(pos); 2652e5b75505Sopenharmony_ci if (bss->eap_req_id_text == NULL) { 2653e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Failed to allocate memory for eap_req_id_text", 2654e5b75505Sopenharmony_ci line); 2655e5b75505Sopenharmony_ci return 1; 2656e5b75505Sopenharmony_ci } 2657e5b75505Sopenharmony_ci bss->eap_req_id_text_len = os_strlen(bss->eap_req_id_text); 2658e5b75505Sopenharmony_ci term = os_strstr(bss->eap_req_id_text, "\\0"); 2659e5b75505Sopenharmony_ci if (term) { 2660e5b75505Sopenharmony_ci *term++ = '\0'; 2661e5b75505Sopenharmony_ci os_memmove(term, term + 1, 2662e5b75505Sopenharmony_ci bss->eap_req_id_text_len - 2663e5b75505Sopenharmony_ci (term - bss->eap_req_id_text) - 1); 2664e5b75505Sopenharmony_ci bss->eap_req_id_text_len--; 2665e5b75505Sopenharmony_ci } 2666e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "erp_send_reauth_start") == 0) { 2667e5b75505Sopenharmony_ci bss->erp_send_reauth_start = atoi(pos); 2668e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "erp_domain") == 0) { 2669e5b75505Sopenharmony_ci os_free(bss->erp_domain); 2670e5b75505Sopenharmony_ci bss->erp_domain = os_strdup(pos); 2671e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) { 2672e5b75505Sopenharmony_ci int val = atoi(pos); 2673e5b75505Sopenharmony_ci 2674e5b75505Sopenharmony_ci if (val < 0 || val > 13) { 2675e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2676e5b75505Sopenharmony_ci "Line %d: invalid WEP key len %d (= %d bits)", 2677e5b75505Sopenharmony_ci line, val, val * 8); 2678e5b75505Sopenharmony_ci return 1; 2679e5b75505Sopenharmony_ci } 2680e5b75505Sopenharmony_ci bss->default_wep_key_len = val; 2681e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) { 2682e5b75505Sopenharmony_ci int val = atoi(pos); 2683e5b75505Sopenharmony_ci 2684e5b75505Sopenharmony_ci if (val < 0 || val > 13) { 2685e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2686e5b75505Sopenharmony_ci "Line %d: invalid WEP key len %d (= %d bits)", 2687e5b75505Sopenharmony_ci line, val, val * 8); 2688e5b75505Sopenharmony_ci return 1; 2689e5b75505Sopenharmony_ci } 2690e5b75505Sopenharmony_ci bss->individual_wep_key_len = val; 2691e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wep_rekey_period") == 0) { 2692e5b75505Sopenharmony_ci bss->wep_rekeying_period = atoi(pos); 2693e5b75505Sopenharmony_ci if (bss->wep_rekeying_period < 0) { 2694e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid period %d", 2695e5b75505Sopenharmony_ci line, bss->wep_rekeying_period); 2696e5b75505Sopenharmony_ci return 1; 2697e5b75505Sopenharmony_ci } 2698e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eap_reauth_period") == 0) { 2699e5b75505Sopenharmony_ci bss->eap_reauth_period = atoi(pos); 2700e5b75505Sopenharmony_ci if (bss->eap_reauth_period < 0) { 2701e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid period %d", 2702e5b75505Sopenharmony_ci line, bss->eap_reauth_period); 2703e5b75505Sopenharmony_ci return 1; 2704e5b75505Sopenharmony_ci } 2705e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) { 2706e5b75505Sopenharmony_ci bss->eapol_key_index_workaround = atoi(pos); 2707e5b75505Sopenharmony_ci#ifdef CONFIG_IAPP 2708e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "iapp_interface") == 0) { 2709e5b75505Sopenharmony_ci bss->ieee802_11f = 1; 2710e5b75505Sopenharmony_ci os_strlcpy(bss->iapp_iface, pos, sizeof(bss->iapp_iface)); 2711e5b75505Sopenharmony_ci#endif /* CONFIG_IAPP */ 2712e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "own_ip_addr") == 0) { 2713e5b75505Sopenharmony_ci if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) { 2714e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2715e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 2716e5b75505Sopenharmony_ci line, pos); 2717e5b75505Sopenharmony_ci return 1; 2718e5b75505Sopenharmony_ci } 2719e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "nas_identifier") == 0) { 2720e5b75505Sopenharmony_ci os_free(bss->nas_identifier); 2721e5b75505Sopenharmony_ci bss->nas_identifier = os_strdup(pos); 2722e5b75505Sopenharmony_ci#ifndef CONFIG_NO_RADIUS 2723e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_client_addr") == 0) { 2724e5b75505Sopenharmony_ci if (hostapd_parse_ip_addr(pos, &bss->radius->client_addr)) { 2725e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2726e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 2727e5b75505Sopenharmony_ci line, pos); 2728e5b75505Sopenharmony_ci return 1; 2729e5b75505Sopenharmony_ci } 2730e5b75505Sopenharmony_ci bss->radius->force_client_addr = 1; 2731e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "auth_server_addr") == 0) { 2732e5b75505Sopenharmony_ci if (hostapd_config_read_radius_addr( 2733e5b75505Sopenharmony_ci &bss->radius->auth_servers, 2734e5b75505Sopenharmony_ci &bss->radius->num_auth_servers, pos, 1812, 2735e5b75505Sopenharmony_ci &bss->radius->auth_server)) { 2736e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2737e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 2738e5b75505Sopenharmony_ci line, pos); 2739e5b75505Sopenharmony_ci return 1; 2740e5b75505Sopenharmony_ci } 2741e5b75505Sopenharmony_ci } else if (bss->radius->auth_server && 2742e5b75505Sopenharmony_ci os_strcmp(buf, "auth_server_addr_replace") == 0) { 2743e5b75505Sopenharmony_ci if (hostapd_parse_ip_addr(pos, 2744e5b75505Sopenharmony_ci &bss->radius->auth_server->addr)) { 2745e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2746e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 2747e5b75505Sopenharmony_ci line, pos); 2748e5b75505Sopenharmony_ci return 1; 2749e5b75505Sopenharmony_ci } 2750e5b75505Sopenharmony_ci } else if (bss->radius->auth_server && 2751e5b75505Sopenharmony_ci os_strcmp(buf, "auth_server_port") == 0) { 2752e5b75505Sopenharmony_ci bss->radius->auth_server->port = atoi(pos); 2753e5b75505Sopenharmony_ci } else if (bss->radius->auth_server && 2754e5b75505Sopenharmony_ci os_strcmp(buf, "auth_server_shared_secret") == 0) { 2755e5b75505Sopenharmony_ci int len = os_strlen(pos); 2756e5b75505Sopenharmony_ci if (len == 0) { 2757e5b75505Sopenharmony_ci /* RFC 2865, Ch. 3 */ 2758e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: empty shared secret is not allowed", 2759e5b75505Sopenharmony_ci line); 2760e5b75505Sopenharmony_ci return 1; 2761e5b75505Sopenharmony_ci } 2762e5b75505Sopenharmony_ci os_free(bss->radius->auth_server->shared_secret); 2763e5b75505Sopenharmony_ci bss->radius->auth_server->shared_secret = (u8 *) os_strdup(pos); 2764e5b75505Sopenharmony_ci bss->radius->auth_server->shared_secret_len = len; 2765e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "acct_server_addr") == 0) { 2766e5b75505Sopenharmony_ci if (hostapd_config_read_radius_addr( 2767e5b75505Sopenharmony_ci &bss->radius->acct_servers, 2768e5b75505Sopenharmony_ci &bss->radius->num_acct_servers, pos, 1813, 2769e5b75505Sopenharmony_ci &bss->radius->acct_server)) { 2770e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2771e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 2772e5b75505Sopenharmony_ci line, pos); 2773e5b75505Sopenharmony_ci return 1; 2774e5b75505Sopenharmony_ci } 2775e5b75505Sopenharmony_ci } else if (bss->radius->acct_server && 2776e5b75505Sopenharmony_ci os_strcmp(buf, "acct_server_addr_replace") == 0) { 2777e5b75505Sopenharmony_ci if (hostapd_parse_ip_addr(pos, 2778e5b75505Sopenharmony_ci &bss->radius->acct_server->addr)) { 2779e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2780e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 2781e5b75505Sopenharmony_ci line, pos); 2782e5b75505Sopenharmony_ci return 1; 2783e5b75505Sopenharmony_ci } 2784e5b75505Sopenharmony_ci } else if (bss->radius->acct_server && 2785e5b75505Sopenharmony_ci os_strcmp(buf, "acct_server_port") == 0) { 2786e5b75505Sopenharmony_ci bss->radius->acct_server->port = atoi(pos); 2787e5b75505Sopenharmony_ci } else if (bss->radius->acct_server && 2788e5b75505Sopenharmony_ci os_strcmp(buf, "acct_server_shared_secret") == 0) { 2789e5b75505Sopenharmony_ci int len = os_strlen(pos); 2790e5b75505Sopenharmony_ci if (len == 0) { 2791e5b75505Sopenharmony_ci /* RFC 2865, Ch. 3 */ 2792e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: empty shared secret is not allowed", 2793e5b75505Sopenharmony_ci line); 2794e5b75505Sopenharmony_ci return 1; 2795e5b75505Sopenharmony_ci } 2796e5b75505Sopenharmony_ci os_free(bss->radius->acct_server->shared_secret); 2797e5b75505Sopenharmony_ci bss->radius->acct_server->shared_secret = (u8 *) os_strdup(pos); 2798e5b75505Sopenharmony_ci bss->radius->acct_server->shared_secret_len = len; 2799e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_retry_primary_interval") == 0) { 2800e5b75505Sopenharmony_ci bss->radius->retry_primary_interval = atoi(pos); 2801e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0) { 2802e5b75505Sopenharmony_ci bss->acct_interim_interval = atoi(pos); 2803e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_request_cui") == 0) { 2804e5b75505Sopenharmony_ci bss->radius_request_cui = atoi(pos); 2805e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_auth_req_attr") == 0) { 2806e5b75505Sopenharmony_ci struct hostapd_radius_attr *attr, *a; 2807e5b75505Sopenharmony_ci attr = hostapd_parse_radius_attr(pos); 2808e5b75505Sopenharmony_ci if (attr == NULL) { 2809e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2810e5b75505Sopenharmony_ci "Line %d: invalid radius_auth_req_attr", 2811e5b75505Sopenharmony_ci line); 2812e5b75505Sopenharmony_ci return 1; 2813e5b75505Sopenharmony_ci } else if (bss->radius_auth_req_attr == NULL) { 2814e5b75505Sopenharmony_ci bss->radius_auth_req_attr = attr; 2815e5b75505Sopenharmony_ci } else { 2816e5b75505Sopenharmony_ci a = bss->radius_auth_req_attr; 2817e5b75505Sopenharmony_ci while (a->next) 2818e5b75505Sopenharmony_ci a = a->next; 2819e5b75505Sopenharmony_ci a->next = attr; 2820e5b75505Sopenharmony_ci } 2821e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_acct_req_attr") == 0) { 2822e5b75505Sopenharmony_ci struct hostapd_radius_attr *attr, *a; 2823e5b75505Sopenharmony_ci attr = hostapd_parse_radius_attr(pos); 2824e5b75505Sopenharmony_ci if (attr == NULL) { 2825e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2826e5b75505Sopenharmony_ci "Line %d: invalid radius_acct_req_attr", 2827e5b75505Sopenharmony_ci line); 2828e5b75505Sopenharmony_ci return 1; 2829e5b75505Sopenharmony_ci } else if (bss->radius_acct_req_attr == NULL) { 2830e5b75505Sopenharmony_ci bss->radius_acct_req_attr = attr; 2831e5b75505Sopenharmony_ci } else { 2832e5b75505Sopenharmony_ci a = bss->radius_acct_req_attr; 2833e5b75505Sopenharmony_ci while (a->next) 2834e5b75505Sopenharmony_ci a = a->next; 2835e5b75505Sopenharmony_ci a->next = attr; 2836e5b75505Sopenharmony_ci } 2837e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_req_attr_sqlite") == 0) { 2838e5b75505Sopenharmony_ci os_free(bss->radius_req_attr_sqlite); 2839e5b75505Sopenharmony_ci bss->radius_req_attr_sqlite = os_strdup(pos); 2840e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_das_port") == 0) { 2841e5b75505Sopenharmony_ci bss->radius_das_port = atoi(pos); 2842e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_das_client") == 0) { 2843e5b75505Sopenharmony_ci if (hostapd_parse_das_client(bss, pos) < 0) { 2844e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid DAS client", 2845e5b75505Sopenharmony_ci line); 2846e5b75505Sopenharmony_ci return 1; 2847e5b75505Sopenharmony_ci } 2848e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_das_time_window") == 0) { 2849e5b75505Sopenharmony_ci bss->radius_das_time_window = atoi(pos); 2850e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_das_require_event_timestamp") == 0) { 2851e5b75505Sopenharmony_ci bss->radius_das_require_event_timestamp = atoi(pos); 2852e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_das_require_message_authenticator") == 2853e5b75505Sopenharmony_ci 0) { 2854e5b75505Sopenharmony_ci bss->radius_das_require_message_authenticator = atoi(pos); 2855e5b75505Sopenharmony_ci#endif /* CONFIG_NO_RADIUS */ 2856e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "auth_algs") == 0) { 2857e5b75505Sopenharmony_ci bss->auth_algs = atoi(pos); 2858e5b75505Sopenharmony_ci if (bss->auth_algs == 0) { 2859e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: no authentication algorithms allowed", 2860e5b75505Sopenharmony_ci line); 2861e5b75505Sopenharmony_ci return 1; 2862e5b75505Sopenharmony_ci } 2863e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "max_num_sta") == 0) { 2864e5b75505Sopenharmony_ci bss->max_num_sta = atoi(pos); 2865e5b75505Sopenharmony_ci if (bss->max_num_sta < 0 || 2866e5b75505Sopenharmony_ci bss->max_num_sta > MAX_STA_COUNT) { 2867e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d", 2868e5b75505Sopenharmony_ci line, bss->max_num_sta, MAX_STA_COUNT); 2869e5b75505Sopenharmony_ci return 1; 2870e5b75505Sopenharmony_ci } 2871e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa") == 0) { 2872e5b75505Sopenharmony_ci bss->wpa = atoi(pos); 2873e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_group_rekey") == 0) { 2874e5b75505Sopenharmony_ci bss->wpa_group_rekey = atoi(pos); 2875e5b75505Sopenharmony_ci bss->wpa_group_rekey_set = 1; 2876e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) { 2877e5b75505Sopenharmony_ci bss->wpa_strict_rekey = atoi(pos); 2878e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) { 2879e5b75505Sopenharmony_ci bss->wpa_gmk_rekey = atoi(pos); 2880e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_ptk_rekey") == 0) { 2881e5b75505Sopenharmony_ci bss->wpa_ptk_rekey = atoi(pos); 2882e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_group_update_count") == 0) { 2883e5b75505Sopenharmony_ci char *endp; 2884e5b75505Sopenharmony_ci unsigned long val = strtoul(pos, &endp, 0); 2885e5b75505Sopenharmony_ci 2886e5b75505Sopenharmony_ci if (*endp || val < 1 || val > (u32) -1) { 2887e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2888e5b75505Sopenharmony_ci "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295", 2889e5b75505Sopenharmony_ci line, val); 2890e5b75505Sopenharmony_ci return 1; 2891e5b75505Sopenharmony_ci } 2892e5b75505Sopenharmony_ci bss->wpa_group_update_count = (u32) val; 2893e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_pairwise_update_count") == 0) { 2894e5b75505Sopenharmony_ci char *endp; 2895e5b75505Sopenharmony_ci unsigned long val = strtoul(pos, &endp, 0); 2896e5b75505Sopenharmony_ci 2897e5b75505Sopenharmony_ci if (*endp || val < 1 || val > (u32) -1) { 2898e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2899e5b75505Sopenharmony_ci "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295", 2900e5b75505Sopenharmony_ci line, val); 2901e5b75505Sopenharmony_ci return 1; 2902e5b75505Sopenharmony_ci } 2903e5b75505Sopenharmony_ci bss->wpa_pairwise_update_count = (u32) val; 2904e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_disable_eapol_key_retries") == 0) { 2905e5b75505Sopenharmony_ci bss->wpa_disable_eapol_key_retries = atoi(pos); 2906e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_passphrase") == 0) { 2907e5b75505Sopenharmony_ci int len = os_strlen(pos); 2908e5b75505Sopenharmony_ci if (len < 8 || len > 63) { 2909e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid WPA passphrase length %d (expected 8..63)", 2910e5b75505Sopenharmony_ci line, len); 2911e5b75505Sopenharmony_ci return 1; 2912e5b75505Sopenharmony_ci } 2913e5b75505Sopenharmony_ci os_free(bss->ssid.wpa_passphrase); 2914e5b75505Sopenharmony_ci bss->ssid.wpa_passphrase = os_strdup(pos); 2915e5b75505Sopenharmony_ci if (bss->ssid.wpa_passphrase) { 2916e5b75505Sopenharmony_ci hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk); 2917e5b75505Sopenharmony_ci bss->ssid.wpa_passphrase_set = 1; 2918e5b75505Sopenharmony_ci } 2919e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_psk") == 0) { 2920e5b75505Sopenharmony_ci hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk); 2921e5b75505Sopenharmony_ci bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk)); 2922e5b75505Sopenharmony_ci if (bss->ssid.wpa_psk == NULL) 2923e5b75505Sopenharmony_ci return 1; 2924e5b75505Sopenharmony_ci if (hexstr2bin(pos, bss->ssid.wpa_psk->psk, PMK_LEN) || 2925e5b75505Sopenharmony_ci pos[PMK_LEN * 2] != '\0') { 2926e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid PSK '%s'.", 2927e5b75505Sopenharmony_ci line, pos); 2928e5b75505Sopenharmony_ci hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk); 2929e5b75505Sopenharmony_ci return 1; 2930e5b75505Sopenharmony_ci } 2931e5b75505Sopenharmony_ci bss->ssid.wpa_psk->group = 1; 2932e5b75505Sopenharmony_ci os_free(bss->ssid.wpa_passphrase); 2933e5b75505Sopenharmony_ci bss->ssid.wpa_passphrase = NULL; 2934e5b75505Sopenharmony_ci bss->ssid.wpa_psk_set = 1; 2935e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_psk_file") == 0) { 2936e5b75505Sopenharmony_ci os_free(bss->ssid.wpa_psk_file); 2937e5b75505Sopenharmony_ci bss->ssid.wpa_psk_file = os_strdup(pos); 2938e5b75505Sopenharmony_ci if (!bss->ssid.wpa_psk_file) { 2939e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: allocation failed", 2940e5b75505Sopenharmony_ci line); 2941e5b75505Sopenharmony_ci return 1; 2942e5b75505Sopenharmony_ci } 2943e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) { 2944e5b75505Sopenharmony_ci bss->wpa_key_mgmt = hostapd_config_parse_key_mgmt(line, pos); 2945e5b75505Sopenharmony_ci if (bss->wpa_key_mgmt == -1) 2946e5b75505Sopenharmony_ci return 1; 2947e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_psk_radius") == 0) { 2948e5b75505Sopenharmony_ci bss->wpa_psk_radius = atoi(pos); 2949e5b75505Sopenharmony_ci if (bss->wpa_psk_radius != PSK_RADIUS_IGNORED && 2950e5b75505Sopenharmony_ci bss->wpa_psk_radius != PSK_RADIUS_ACCEPTED && 2951e5b75505Sopenharmony_ci bss->wpa_psk_radius != PSK_RADIUS_REQUIRED) { 2952e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2953e5b75505Sopenharmony_ci "Line %d: unknown wpa_psk_radius %d", 2954e5b75505Sopenharmony_ci line, bss->wpa_psk_radius); 2955e5b75505Sopenharmony_ci return 1; 2956e5b75505Sopenharmony_ci } 2957e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wpa_pairwise") == 0) { 2958e5b75505Sopenharmony_ci bss->wpa_pairwise = hostapd_config_parse_cipher(line, pos); 2959e5b75505Sopenharmony_ci if (bss->wpa_pairwise == -1 || bss->wpa_pairwise == 0) 2960e5b75505Sopenharmony_ci return 1; 2961e5b75505Sopenharmony_ci if (bss->wpa_pairwise & 2962e5b75505Sopenharmony_ci (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)) { 2963e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: unsupported pairwise cipher suite '%s'", 2964e5b75505Sopenharmony_ci line, pos); 2965e5b75505Sopenharmony_ci return 1; 2966e5b75505Sopenharmony_ci } 2967e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rsn_pairwise") == 0) { 2968e5b75505Sopenharmony_ci bss->rsn_pairwise = hostapd_config_parse_cipher(line, pos); 2969e5b75505Sopenharmony_ci if (bss->rsn_pairwise == -1 || bss->rsn_pairwise == 0) 2970e5b75505Sopenharmony_ci return 1; 2971e5b75505Sopenharmony_ci if (bss->rsn_pairwise & 2972e5b75505Sopenharmony_ci (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)) { 2973e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: unsupported pairwise cipher suite '%s'", 2974e5b75505Sopenharmony_ci line, pos); 2975e5b75505Sopenharmony_ci return 1; 2976e5b75505Sopenharmony_ci } 2977e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "group_cipher") == 0) { 2978e5b75505Sopenharmony_ci bss->group_cipher = hostapd_config_parse_cipher(line, pos); 2979e5b75505Sopenharmony_ci if (bss->group_cipher == -1 || bss->group_cipher == 0) 2980e5b75505Sopenharmony_ci return 1; 2981e5b75505Sopenharmony_ci if (bss->group_cipher != WPA_CIPHER_TKIP && 2982e5b75505Sopenharmony_ci bss->group_cipher != WPA_CIPHER_CCMP && 2983e5b75505Sopenharmony_ci bss->group_cipher != WPA_CIPHER_GCMP && 2984e5b75505Sopenharmony_ci bss->group_cipher != WPA_CIPHER_GCMP_256 && 2985e5b75505Sopenharmony_ci bss->group_cipher != WPA_CIPHER_CCMP_256) { 2986e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 2987e5b75505Sopenharmony_ci "Line %d: unsupported group cipher suite '%s'", 2988e5b75505Sopenharmony_ci line, pos); 2989e5b75505Sopenharmony_ci return 1; 2990e5b75505Sopenharmony_ci } 2991e5b75505Sopenharmony_ci#ifdef CONFIG_RSN_PREAUTH 2992e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rsn_preauth") == 0) { 2993e5b75505Sopenharmony_ci bss->rsn_preauth = atoi(pos); 2994e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) { 2995e5b75505Sopenharmony_ci os_free(bss->rsn_preauth_interfaces); 2996e5b75505Sopenharmony_ci bss->rsn_preauth_interfaces = os_strdup(pos); 2997e5b75505Sopenharmony_ci#endif /* CONFIG_RSN_PREAUTH */ 2998e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "peerkey") == 0) { 2999e5b75505Sopenharmony_ci wpa_printf(MSG_INFO, 3000e5b75505Sopenharmony_ci "Line %d: Obsolete peerkey parameter ignored", line); 3001e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211R_AP 3002e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "mobility_domain") == 0) { 3003e5b75505Sopenharmony_ci if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN || 3004e5b75505Sopenharmony_ci hexstr2bin(pos, bss->mobility_domain, 3005e5b75505Sopenharmony_ci MOBILITY_DOMAIN_ID_LEN) != 0) { 3006e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3007e5b75505Sopenharmony_ci "Line %d: Invalid mobility_domain '%s'", 3008e5b75505Sopenharmony_ci line, pos); 3009e5b75505Sopenharmony_ci return 1; 3010e5b75505Sopenharmony_ci } 3011e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "r1_key_holder") == 0) { 3012e5b75505Sopenharmony_ci if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN || 3013e5b75505Sopenharmony_ci hexstr2bin(pos, bss->r1_key_holder, FT_R1KH_ID_LEN) != 0) { 3014e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3015e5b75505Sopenharmony_ci "Line %d: Invalid r1_key_holder '%s'", 3016e5b75505Sopenharmony_ci line, pos); 3017e5b75505Sopenharmony_ci return 1; 3018e5b75505Sopenharmony_ci } 3019e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "r0_key_lifetime") == 0) { 3020e5b75505Sopenharmony_ci /* DEPRECATED: Use ft_r0_key_lifetime instead. */ 3021e5b75505Sopenharmony_ci bss->r0_key_lifetime = atoi(pos) * 60; 3022e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ft_r0_key_lifetime") == 0) { 3023e5b75505Sopenharmony_ci bss->r0_key_lifetime = atoi(pos); 3024e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "r1_max_key_lifetime") == 0) { 3025e5b75505Sopenharmony_ci bss->r1_max_key_lifetime = atoi(pos); 3026e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "reassociation_deadline") == 0) { 3027e5b75505Sopenharmony_ci bss->reassociation_deadline = atoi(pos); 3028e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rkh_pos_timeout") == 0) { 3029e5b75505Sopenharmony_ci bss->rkh_pos_timeout = atoi(pos); 3030e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rkh_neg_timeout") == 0) { 3031e5b75505Sopenharmony_ci bss->rkh_neg_timeout = atoi(pos); 3032e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rkh_pull_timeout") == 0) { 3033e5b75505Sopenharmony_ci bss->rkh_pull_timeout = atoi(pos); 3034e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rkh_pull_retries") == 0) { 3035e5b75505Sopenharmony_ci bss->rkh_pull_retries = atoi(pos); 3036e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "r0kh") == 0) { 3037e5b75505Sopenharmony_ci if (add_r0kh(bss, pos) < 0) { 3038e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "Line %d: Invalid r0kh '%s'", 3039e5b75505Sopenharmony_ci line, pos); 3040e5b75505Sopenharmony_ci return 1; 3041e5b75505Sopenharmony_ci } 3042e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "r1kh") == 0) { 3043e5b75505Sopenharmony_ci if (add_r1kh(bss, pos) < 0) { 3044e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "Line %d: Invalid r1kh '%s'", 3045e5b75505Sopenharmony_ci line, pos); 3046e5b75505Sopenharmony_ci return 1; 3047e5b75505Sopenharmony_ci } 3048e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pmk_r1_push") == 0) { 3049e5b75505Sopenharmony_ci bss->pmk_r1_push = atoi(pos); 3050e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ft_over_ds") == 0) { 3051e5b75505Sopenharmony_ci bss->ft_over_ds = atoi(pos); 3052e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ft_psk_generate_local") == 0) { 3053e5b75505Sopenharmony_ci bss->ft_psk_generate_local = atoi(pos); 3054e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211R_AP */ 3055e5b75505Sopenharmony_ci#ifndef CONFIG_NO_CTRL_IFACE 3056e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ctrl_interface") == 0) { 3057e5b75505Sopenharmony_ci os_free(bss->ctrl_interface); 3058e5b75505Sopenharmony_ci bss->ctrl_interface = os_strdup(pos); 3059e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ctrl_interface_group") == 0) { 3060e5b75505Sopenharmony_ci#ifndef CONFIG_NATIVE_WINDOWS 3061e5b75505Sopenharmony_ci struct group *grp; 3062e5b75505Sopenharmony_ci char *endp; 3063e5b75505Sopenharmony_ci const char *group = pos; 3064e5b75505Sopenharmony_ci 3065e5b75505Sopenharmony_ci grp = getgrnam(group); 3066e5b75505Sopenharmony_ci if (grp) { 3067e5b75505Sopenharmony_ci bss->ctrl_interface_gid = grp->gr_gid; 3068e5b75505Sopenharmony_ci bss->ctrl_interface_gid_set = 1; 3069e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d (from group name '%s')", 3070e5b75505Sopenharmony_ci bss->ctrl_interface_gid, group); 3071e5b75505Sopenharmony_ci return 0; 3072e5b75505Sopenharmony_ci } 3073e5b75505Sopenharmony_ci 3074e5b75505Sopenharmony_ci /* Group name not found - try to parse this as gid */ 3075e5b75505Sopenharmony_ci bss->ctrl_interface_gid = strtol(group, &endp, 10); 3076e5b75505Sopenharmony_ci if (*group == '\0' || *endp != '\0') { 3077e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "Line %d: Invalid group '%s'", 3078e5b75505Sopenharmony_ci line, group); 3079e5b75505Sopenharmony_ci return 1; 3080e5b75505Sopenharmony_ci } 3081e5b75505Sopenharmony_ci bss->ctrl_interface_gid_set = 1; 3082e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d", 3083e5b75505Sopenharmony_ci bss->ctrl_interface_gid); 3084e5b75505Sopenharmony_ci#endif /* CONFIG_NATIVE_WINDOWS */ 3085e5b75505Sopenharmony_ci#endif /* CONFIG_NO_CTRL_IFACE */ 3086e5b75505Sopenharmony_ci#ifdef RADIUS_SERVER 3087e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_server_clients") == 0) { 3088e5b75505Sopenharmony_ci os_free(bss->radius_server_clients); 3089e5b75505Sopenharmony_ci bss->radius_server_clients = os_strdup(pos); 3090e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_server_auth_port") == 0) { 3091e5b75505Sopenharmony_ci bss->radius_server_auth_port = atoi(pos); 3092e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_server_acct_port") == 0) { 3093e5b75505Sopenharmony_ci bss->radius_server_acct_port = atoi(pos); 3094e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radius_server_ipv6") == 0) { 3095e5b75505Sopenharmony_ci bss->radius_server_ipv6 = atoi(pos); 3096e5b75505Sopenharmony_ci#endif /* RADIUS_SERVER */ 3097e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "use_pae_group_addr") == 0) { 3098e5b75505Sopenharmony_ci bss->use_pae_group_addr = atoi(pos); 3099e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hw_mode") == 0) { 3100e5b75505Sopenharmony_ci if (os_strcmp(pos, "a") == 0) 3101e5b75505Sopenharmony_ci conf->hw_mode = HOSTAPD_MODE_IEEE80211A; 3102e5b75505Sopenharmony_ci else if (os_strcmp(pos, "b") == 0) 3103e5b75505Sopenharmony_ci conf->hw_mode = HOSTAPD_MODE_IEEE80211B; 3104e5b75505Sopenharmony_ci else if (os_strcmp(pos, "g") == 0) 3105e5b75505Sopenharmony_ci conf->hw_mode = HOSTAPD_MODE_IEEE80211G; 3106e5b75505Sopenharmony_ci else if (os_strcmp(pos, "ad") == 0) 3107e5b75505Sopenharmony_ci conf->hw_mode = HOSTAPD_MODE_IEEE80211AD; 3108e5b75505Sopenharmony_ci else if (os_strcmp(pos, "any") == 0) 3109e5b75505Sopenharmony_ci conf->hw_mode = HOSTAPD_MODE_IEEE80211ANY; 3110e5b75505Sopenharmony_ci else { 3111e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: unknown hw_mode '%s'", 3112e5b75505Sopenharmony_ci line, pos); 3113e5b75505Sopenharmony_ci return 1; 3114e5b75505Sopenharmony_ci } 3115e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_rf_bands") == 0) { 3116e5b75505Sopenharmony_ci if (os_strcmp(pos, "ad") == 0) 3117e5b75505Sopenharmony_ci bss->wps_rf_bands = WPS_RF_60GHZ; 3118e5b75505Sopenharmony_ci else if (os_strcmp(pos, "a") == 0) 3119e5b75505Sopenharmony_ci bss->wps_rf_bands = WPS_RF_50GHZ; 3120e5b75505Sopenharmony_ci else if (os_strcmp(pos, "g") == 0 || 3121e5b75505Sopenharmony_ci os_strcmp(pos, "b") == 0) 3122e5b75505Sopenharmony_ci bss->wps_rf_bands = WPS_RF_24GHZ; 3123e5b75505Sopenharmony_ci else if (os_strcmp(pos, "ag") == 0 || 3124e5b75505Sopenharmony_ci os_strcmp(pos, "ga") == 0) 3125e5b75505Sopenharmony_ci bss->wps_rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; 3126e5b75505Sopenharmony_ci else { 3127e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3128e5b75505Sopenharmony_ci "Line %d: unknown wps_rf_band '%s'", 3129e5b75505Sopenharmony_ci line, pos); 3130e5b75505Sopenharmony_ci return 1; 3131e5b75505Sopenharmony_ci } 3132e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "acs_exclude_dfs") == 0) { 3133e5b75505Sopenharmony_ci conf->acs_exclude_dfs = atoi(pos); 3134e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "channel") == 0) { 3135e5b75505Sopenharmony_ci if (os_strcmp(pos, "acs_survey") == 0) { 3136e5b75505Sopenharmony_ci#ifndef CONFIG_ACS 3137e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: tries to enable ACS but CONFIG_ACS disabled", 3138e5b75505Sopenharmony_ci line); 3139e5b75505Sopenharmony_ci return 1; 3140e5b75505Sopenharmony_ci#else /* CONFIG_ACS */ 3141e5b75505Sopenharmony_ci conf->acs = 1; 3142e5b75505Sopenharmony_ci conf->channel = 0; 3143e5b75505Sopenharmony_ci#endif /* CONFIG_ACS */ 3144e5b75505Sopenharmony_ci } else { 3145e5b75505Sopenharmony_ci conf->channel = atoi(pos); 3146e5b75505Sopenharmony_ci conf->acs = conf->channel == 0; 3147e5b75505Sopenharmony_ci } 3148e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "chanlist") == 0) { 3149e5b75505Sopenharmony_ci if (hostapd_parse_chanlist(conf, pos)) { 3150e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid channel list", 3151e5b75505Sopenharmony_ci line); 3152e5b75505Sopenharmony_ci return 1; 3153e5b75505Sopenharmony_ci } 3154e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "beacon_int") == 0) { 3155e5b75505Sopenharmony_ci int val = atoi(pos); 3156e5b75505Sopenharmony_ci /* MIB defines range as 1..65535, but very small values 3157e5b75505Sopenharmony_ci * cause problems with the current implementation. 3158e5b75505Sopenharmony_ci * Since it is unlikely that this small numbers are 3159e5b75505Sopenharmony_ci * useful in real life scenarios, do not allow beacon 3160e5b75505Sopenharmony_ci * period to be set below 10 TU. */ 3161e5b75505Sopenharmony_ci if (val < 10 || val > 65535) { 3162e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3163e5b75505Sopenharmony_ci "Line %d: invalid beacon_int %d (expected 10..65535)", 3164e5b75505Sopenharmony_ci line, val); 3165e5b75505Sopenharmony_ci return 1; 3166e5b75505Sopenharmony_ci } 3167e5b75505Sopenharmony_ci conf->beacon_int = val; 3168e5b75505Sopenharmony_ci#ifdef CONFIG_ACS 3169e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "acs_num_scans") == 0) { 3170e5b75505Sopenharmony_ci int val = atoi(pos); 3171e5b75505Sopenharmony_ci if (val <= 0 || val > 100) { 3172e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid acs_num_scans %d (expected 1..100)", 3173e5b75505Sopenharmony_ci line, val); 3174e5b75505Sopenharmony_ci return 1; 3175e5b75505Sopenharmony_ci } 3176e5b75505Sopenharmony_ci conf->acs_num_scans = val; 3177e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "acs_chan_bias") == 0) { 3178e5b75505Sopenharmony_ci if (hostapd_config_parse_acs_chan_bias(conf, pos)) { 3179e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid acs_chan_bias", 3180e5b75505Sopenharmony_ci line); 3181e5b75505Sopenharmony_ci return -1; 3182e5b75505Sopenharmony_ci } 3183e5b75505Sopenharmony_ci#endif /* CONFIG_ACS */ 3184e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dtim_period") == 0) { 3185e5b75505Sopenharmony_ci int val = atoi(pos); 3186e5b75505Sopenharmony_ci 3187e5b75505Sopenharmony_ci if (val < 1 || val > 255) { 3188e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid dtim_period %d", 3189e5b75505Sopenharmony_ci line, val); 3190e5b75505Sopenharmony_ci return 1; 3191e5b75505Sopenharmony_ci } 3192e5b75505Sopenharmony_ci bss->dtim_period = val; 3193e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "bss_load_update_period") == 0) { 3194e5b75505Sopenharmony_ci int val = atoi(pos); 3195e5b75505Sopenharmony_ci 3196e5b75505Sopenharmony_ci if (val < 0 || val > 100) { 3197e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3198e5b75505Sopenharmony_ci "Line %d: invalid bss_load_update_period %d", 3199e5b75505Sopenharmony_ci line, val); 3200e5b75505Sopenharmony_ci return 1; 3201e5b75505Sopenharmony_ci } 3202e5b75505Sopenharmony_ci bss->bss_load_update_period = val; 3203e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "chan_util_avg_period") == 0) { 3204e5b75505Sopenharmony_ci int val = atoi(pos); 3205e5b75505Sopenharmony_ci 3206e5b75505Sopenharmony_ci if (val < 0) { 3207e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3208e5b75505Sopenharmony_ci "Line %d: invalid chan_util_avg_period", 3209e5b75505Sopenharmony_ci line); 3210e5b75505Sopenharmony_ci return 1; 3211e5b75505Sopenharmony_ci } 3212e5b75505Sopenharmony_ci bss->chan_util_avg_period = val; 3213e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rts_threshold") == 0) { 3214e5b75505Sopenharmony_ci conf->rts_threshold = atoi(pos); 3215e5b75505Sopenharmony_ci if (conf->rts_threshold < -1 || conf->rts_threshold > 65535) { 3216e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3217e5b75505Sopenharmony_ci "Line %d: invalid rts_threshold %d", 3218e5b75505Sopenharmony_ci line, conf->rts_threshold); 3219e5b75505Sopenharmony_ci return 1; 3220e5b75505Sopenharmony_ci } 3221e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fragm_threshold") == 0) { 3222e5b75505Sopenharmony_ci conf->fragm_threshold = atoi(pos); 3223e5b75505Sopenharmony_ci if (conf->fragm_threshold == -1) { 3224e5b75505Sopenharmony_ci /* allow a value of -1 */ 3225e5b75505Sopenharmony_ci } else if (conf->fragm_threshold < 256 || 3226e5b75505Sopenharmony_ci conf->fragm_threshold > 2346) { 3227e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3228e5b75505Sopenharmony_ci "Line %d: invalid fragm_threshold %d", 3229e5b75505Sopenharmony_ci line, conf->fragm_threshold); 3230e5b75505Sopenharmony_ci return 1; 3231e5b75505Sopenharmony_ci } 3232e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "send_probe_response") == 0) { 3233e5b75505Sopenharmony_ci int val = atoi(pos); 3234e5b75505Sopenharmony_ci if (val != 0 && val != 1) { 3235e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid send_probe_response %d (expected 0 or 1)", 3236e5b75505Sopenharmony_ci line, val); 3237e5b75505Sopenharmony_ci return 1; 3238e5b75505Sopenharmony_ci } 3239e5b75505Sopenharmony_ci bss->send_probe_response = val; 3240e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "supported_rates") == 0) { 3241e5b75505Sopenharmony_ci if (hostapd_parse_intlist(&conf->supported_rates, pos)) { 3242e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid rate list", 3243e5b75505Sopenharmony_ci line); 3244e5b75505Sopenharmony_ci return 1; 3245e5b75505Sopenharmony_ci } 3246e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "basic_rates") == 0) { 3247e5b75505Sopenharmony_ci if (hostapd_parse_intlist(&conf->basic_rates, pos)) { 3248e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid rate list", 3249e5b75505Sopenharmony_ci line); 3250e5b75505Sopenharmony_ci return 1; 3251e5b75505Sopenharmony_ci } 3252e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "beacon_rate") == 0) { 3253e5b75505Sopenharmony_ci int val; 3254e5b75505Sopenharmony_ci 3255e5b75505Sopenharmony_ci if (os_strncmp(pos, "ht:", 3) == 0) { 3256e5b75505Sopenharmony_ci val = atoi(pos + 3); 3257e5b75505Sopenharmony_ci if (val < 0 || val > 31) { 3258e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3259e5b75505Sopenharmony_ci "Line %d: invalid beacon_rate HT-MCS %d", 3260e5b75505Sopenharmony_ci line, val); 3261e5b75505Sopenharmony_ci return 1; 3262e5b75505Sopenharmony_ci } 3263e5b75505Sopenharmony_ci conf->rate_type = BEACON_RATE_HT; 3264e5b75505Sopenharmony_ci conf->beacon_rate = val; 3265e5b75505Sopenharmony_ci } else if (os_strncmp(pos, "vht:", 4) == 0) { 3266e5b75505Sopenharmony_ci val = atoi(pos + 4); 3267e5b75505Sopenharmony_ci if (val < 0 || val > 9) { 3268e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3269e5b75505Sopenharmony_ci "Line %d: invalid beacon_rate VHT-MCS %d", 3270e5b75505Sopenharmony_ci line, val); 3271e5b75505Sopenharmony_ci return 1; 3272e5b75505Sopenharmony_ci } 3273e5b75505Sopenharmony_ci conf->rate_type = BEACON_RATE_VHT; 3274e5b75505Sopenharmony_ci conf->beacon_rate = val; 3275e5b75505Sopenharmony_ci } else { 3276e5b75505Sopenharmony_ci val = atoi(pos); 3277e5b75505Sopenharmony_ci if (val < 10 || val > 10000) { 3278e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3279e5b75505Sopenharmony_ci "Line %d: invalid legacy beacon_rate %d", 3280e5b75505Sopenharmony_ci line, val); 3281e5b75505Sopenharmony_ci return 1; 3282e5b75505Sopenharmony_ci } 3283e5b75505Sopenharmony_ci conf->rate_type = BEACON_RATE_LEGACY; 3284e5b75505Sopenharmony_ci conf->beacon_rate = val; 3285e5b75505Sopenharmony_ci } 3286e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "preamble") == 0) { 3287e5b75505Sopenharmony_ci if (atoi(pos)) 3288e5b75505Sopenharmony_ci conf->preamble = SHORT_PREAMBLE; 3289e5b75505Sopenharmony_ci else 3290e5b75505Sopenharmony_ci conf->preamble = LONG_PREAMBLE; 3291e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) { 3292e5b75505Sopenharmony_ci bss->ignore_broadcast_ssid = atoi(pos); 3293e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "no_probe_resp_if_max_sta") == 0) { 3294e5b75505Sopenharmony_ci bss->no_probe_resp_if_max_sta = atoi(pos); 3295e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wep_default_key") == 0) { 3296e5b75505Sopenharmony_ci bss->ssid.wep.idx = atoi(pos); 3297e5b75505Sopenharmony_ci if (bss->ssid.wep.idx > 3) { 3298e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3299e5b75505Sopenharmony_ci "Invalid wep_default_key index %d", 3300e5b75505Sopenharmony_ci bss->ssid.wep.idx); 3301e5b75505Sopenharmony_ci return 1; 3302e5b75505Sopenharmony_ci } 3303e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wep_key0") == 0 || 3304e5b75505Sopenharmony_ci os_strcmp(buf, "wep_key1") == 0 || 3305e5b75505Sopenharmony_ci os_strcmp(buf, "wep_key2") == 0 || 3306e5b75505Sopenharmony_ci os_strcmp(buf, "wep_key3") == 0) { 3307e5b75505Sopenharmony_ci if (hostapd_config_read_wep(&bss->ssid.wep, 3308e5b75505Sopenharmony_ci buf[7] - '0', pos)) { 3309e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid WEP key '%s'", 3310e5b75505Sopenharmony_ci line, buf); 3311e5b75505Sopenharmony_ci return 1; 3312e5b75505Sopenharmony_ci } 3313e5b75505Sopenharmony_ci#ifndef CONFIG_NO_VLAN 3314e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dynamic_vlan") == 0) { 3315e5b75505Sopenharmony_ci bss->ssid.dynamic_vlan = atoi(pos); 3316e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "per_sta_vif") == 0) { 3317e5b75505Sopenharmony_ci bss->ssid.per_sta_vif = atoi(pos); 3318e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vlan_file") == 0) { 3319e5b75505Sopenharmony_ci if (hostapd_config_read_vlan_file(bss, pos)) { 3320e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: failed to read VLAN file '%s'", 3321e5b75505Sopenharmony_ci line, pos); 3322e5b75505Sopenharmony_ci return 1; 3323e5b75505Sopenharmony_ci } 3324e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vlan_naming") == 0) { 3325e5b75505Sopenharmony_ci bss->ssid.vlan_naming = atoi(pos); 3326e5b75505Sopenharmony_ci if (bss->ssid.vlan_naming >= DYNAMIC_VLAN_NAMING_END || 3327e5b75505Sopenharmony_ci bss->ssid.vlan_naming < 0) { 3328e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3329e5b75505Sopenharmony_ci "Line %d: invalid naming scheme %d", 3330e5b75505Sopenharmony_ci line, bss->ssid.vlan_naming); 3331e5b75505Sopenharmony_ci return 1; 3332e5b75505Sopenharmony_ci } 3333e5b75505Sopenharmony_ci#ifdef CONFIG_FULL_DYNAMIC_VLAN 3334e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) { 3335e5b75505Sopenharmony_ci os_free(bss->ssid.vlan_tagged_interface); 3336e5b75505Sopenharmony_ci bss->ssid.vlan_tagged_interface = os_strdup(pos); 3337e5b75505Sopenharmony_ci#endif /* CONFIG_FULL_DYNAMIC_VLAN */ 3338e5b75505Sopenharmony_ci#endif /* CONFIG_NO_VLAN */ 3339e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_table_max_size") == 0) { 3340e5b75505Sopenharmony_ci conf->ap_table_max_size = atoi(pos); 3341e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) { 3342e5b75505Sopenharmony_ci conf->ap_table_expiration_time = atoi(pos); 3343e5b75505Sopenharmony_ci } else if (os_strncmp(buf, "tx_queue_", 9) == 0) { 3344e5b75505Sopenharmony_ci if (hostapd_config_tx_queue(conf, buf, pos)) { 3345e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid TX queue item", 3346e5b75505Sopenharmony_ci line); 3347e5b75505Sopenharmony_ci return 1; 3348e5b75505Sopenharmony_ci } 3349e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wme_enabled") == 0 || 3350e5b75505Sopenharmony_ci os_strcmp(buf, "wmm_enabled") == 0) { 3351e5b75505Sopenharmony_ci bss->wmm_enabled = atoi(pos); 3352e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "uapsd_advertisement_enabled") == 0) { 3353e5b75505Sopenharmony_ci bss->wmm_uapsd = atoi(pos); 3354e5b75505Sopenharmony_ci } else if (os_strncmp(buf, "wme_ac_", 7) == 0 || 3355e5b75505Sopenharmony_ci os_strncmp(buf, "wmm_ac_", 7) == 0) { 3356e5b75505Sopenharmony_ci if (hostapd_config_wmm_ac(conf->wmm_ac_params, buf, pos)) { 3357e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid WMM ac item", 3358e5b75505Sopenharmony_ci line); 3359e5b75505Sopenharmony_ci return 1; 3360e5b75505Sopenharmony_ci } 3361e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "bss") == 0) { 3362e5b75505Sopenharmony_ci if (hostapd_config_bss(conf, pos)) { 3363e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid bss item", 3364e5b75505Sopenharmony_ci line); 3365e5b75505Sopenharmony_ci return 1; 3366e5b75505Sopenharmony_ci } 3367e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "bssid") == 0) { 3368e5b75505Sopenharmony_ci if (hwaddr_aton(pos, bss->bssid)) { 3369e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid bssid item", 3370e5b75505Sopenharmony_ci line); 3371e5b75505Sopenharmony_ci return 1; 3372e5b75505Sopenharmony_ci } 3373e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "use_driver_iface_addr") == 0) { 3374e5b75505Sopenharmony_ci conf->use_driver_iface_addr = atoi(pos); 3375e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211W 3376e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee80211w") == 0) { 3377e5b75505Sopenharmony_ci bss->ieee80211w = atoi(pos); 3378e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "group_mgmt_cipher") == 0) { 3379e5b75505Sopenharmony_ci if (os_strcmp(pos, "AES-128-CMAC") == 0) { 3380e5b75505Sopenharmony_ci bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC; 3381e5b75505Sopenharmony_ci } else if (os_strcmp(pos, "BIP-GMAC-128") == 0) { 3382e5b75505Sopenharmony_ci bss->group_mgmt_cipher = WPA_CIPHER_BIP_GMAC_128; 3383e5b75505Sopenharmony_ci } else if (os_strcmp(pos, "BIP-GMAC-256") == 0) { 3384e5b75505Sopenharmony_ci bss->group_mgmt_cipher = WPA_CIPHER_BIP_GMAC_256; 3385e5b75505Sopenharmony_ci } else if (os_strcmp(pos, "BIP-CMAC-256") == 0) { 3386e5b75505Sopenharmony_ci bss->group_mgmt_cipher = WPA_CIPHER_BIP_CMAC_256; 3387e5b75505Sopenharmony_ci } else { 3388e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid group_mgmt_cipher: %s", 3389e5b75505Sopenharmony_ci line, pos); 3390e5b75505Sopenharmony_ci return 1; 3391e5b75505Sopenharmony_ci } 3392e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) { 3393e5b75505Sopenharmony_ci bss->assoc_sa_query_max_timeout = atoi(pos); 3394e5b75505Sopenharmony_ci if (bss->assoc_sa_query_max_timeout == 0) { 3395e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid assoc_sa_query_max_timeout", 3396e5b75505Sopenharmony_ci line); 3397e5b75505Sopenharmony_ci return 1; 3398e5b75505Sopenharmony_ci } 3399e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0) { 3400e5b75505Sopenharmony_ci bss->assoc_sa_query_retry_timeout = atoi(pos); 3401e5b75505Sopenharmony_ci if (bss->assoc_sa_query_retry_timeout == 0) { 3402e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid assoc_sa_query_retry_timeout", 3403e5b75505Sopenharmony_ci line); 3404e5b75505Sopenharmony_ci return 1; 3405e5b75505Sopenharmony_ci } 3406e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211W */ 3407e5b75505Sopenharmony_ci#ifdef CONFIG_OCV 3408e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ocv") == 0) { 3409e5b75505Sopenharmony_ci bss->ocv = atoi(pos); 3410e5b75505Sopenharmony_ci if (bss->ocv && !bss->ieee80211w) 3411e5b75505Sopenharmony_ci bss->ieee80211w = 1; 3412e5b75505Sopenharmony_ci#endif /* CONFIG_OCV */ 3413e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211N 3414e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee80211n") == 0) { 3415e5b75505Sopenharmony_ci conf->ieee80211n = atoi(pos); 3416e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ht_capab") == 0) { 3417e5b75505Sopenharmony_ci if (hostapd_config_ht_capab(conf, pos) < 0) { 3418e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid ht_capab", 3419e5b75505Sopenharmony_ci line); 3420e5b75505Sopenharmony_ci return 1; 3421e5b75505Sopenharmony_ci } 3422e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "require_ht") == 0) { 3423e5b75505Sopenharmony_ci conf->require_ht = atoi(pos); 3424e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "obss_interval") == 0) { 3425e5b75505Sopenharmony_ci conf->obss_interval = atoi(pos); 3426e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211N */ 3427e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211AC 3428e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee80211ac") == 0) { 3429e5b75505Sopenharmony_ci conf->ieee80211ac = atoi(pos); 3430e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vht_capab") == 0) { 3431e5b75505Sopenharmony_ci if (hostapd_config_vht_capab(conf, pos) < 0) { 3432e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid vht_capab", 3433e5b75505Sopenharmony_ci line); 3434e5b75505Sopenharmony_ci return 1; 3435e5b75505Sopenharmony_ci } 3436e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "require_vht") == 0) { 3437e5b75505Sopenharmony_ci conf->require_vht = atoi(pos); 3438e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vht_oper_chwidth") == 0) { 3439e5b75505Sopenharmony_ci conf->vht_oper_chwidth = atoi(pos); 3440e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vht_oper_centr_freq_seg0_idx") == 0) { 3441e5b75505Sopenharmony_ci conf->vht_oper_centr_freq_seg0_idx = atoi(pos); 3442e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vht_oper_centr_freq_seg1_idx") == 0) { 3443e5b75505Sopenharmony_ci conf->vht_oper_centr_freq_seg1_idx = atoi(pos); 3444e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vendor_vht") == 0) { 3445e5b75505Sopenharmony_ci bss->vendor_vht = atoi(pos); 3446e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "use_sta_nsts") == 0) { 3447e5b75505Sopenharmony_ci bss->use_sta_nsts = atoi(pos); 3448e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211AC */ 3449e5b75505Sopenharmony_ci#ifdef CONFIG_IEEE80211AX 3450e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ieee80211ax") == 0) { 3451e5b75505Sopenharmony_ci conf->ieee80211ax = atoi(pos); 3452e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_su_beamformer") == 0) { 3453e5b75505Sopenharmony_ci conf->he_phy_capab.he_su_beamformer = atoi(pos); 3454e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_su_beamformee") == 0) { 3455e5b75505Sopenharmony_ci conf->he_phy_capab.he_su_beamformee = atoi(pos); 3456e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_beamformer") == 0) { 3457e5b75505Sopenharmony_ci conf->he_phy_capab.he_mu_beamformer = atoi(pos); 3458e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_bss_color") == 0) { 3459e5b75505Sopenharmony_ci conf->he_op.he_bss_color = atoi(pos); 3460e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_default_pe_duration") == 0) { 3461e5b75505Sopenharmony_ci conf->he_op.he_default_pe_duration = atoi(pos); 3462e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_twt_required") == 0) { 3463e5b75505Sopenharmony_ci conf->he_op.he_twt_required = atoi(pos); 3464e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_rts_threshold") == 0) { 3465e5b75505Sopenharmony_ci conf->he_op.he_rts_threshold = atoi(pos); 3466e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_basic_mcs_nss_set") == 0) { 3467e5b75505Sopenharmony_ci conf->he_op.he_basic_mcs_nss_set = atoi(pos); 3468e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_qos_info_param_count") == 0) { 3469e5b75505Sopenharmony_ci conf->he_mu_edca.he_qos_info |= 3470e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_QOS_INFO_EDCA_PARAM_SET_COUNT); 3471e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_qos_info_q_ack") == 0) { 3472e5b75505Sopenharmony_ci conf->he_mu_edca.he_qos_info |= 3473e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_QOS_INFO_Q_ACK); 3474e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_qos_info_queue_request") == 0) { 3475e5b75505Sopenharmony_ci conf->he_mu_edca.he_qos_info |= 3476e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_QOS_INFO_QUEUE_REQUEST); 3477e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_qos_info_txop_request") == 0) { 3478e5b75505Sopenharmony_ci conf->he_mu_edca.he_qos_info |= 3479e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_QOS_INFO_TXOP_REQUEST); 3480e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_be_aifsn") == 0) { 3481e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ACI_IDX] |= 3482e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN); 3483e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_be_acm") == 0) { 3484e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ACI_IDX] |= 3485e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM); 3486e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_be_aci") == 0) { 3487e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ACI_IDX] |= 3488e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI); 3489e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_be_ecwmin") == 0) { 3490e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ECW_IDX] |= 3491e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN); 3492e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_be_ecwmax") == 0) { 3493e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ECW_IDX] |= 3494e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX); 3495e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_be_timer") == 0) { 3496e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_TIMER_IDX] = 3497e5b75505Sopenharmony_ci atoi(pos) & 0xff; 3498e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_bk_aifsn") == 0) { 3499e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ACI_IDX] |= 3500e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN); 3501e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_bk_acm") == 0) { 3502e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ACI_IDX] |= 3503e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM); 3504e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_bk_aci") == 0) { 3505e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ACI_IDX] |= 3506e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI); 3507e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_bk_ecwmin") == 0) { 3508e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ECW_IDX] |= 3509e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN); 3510e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_bk_ecwmax") == 0) { 3511e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ECW_IDX] |= 3512e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX); 3513e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_bk_timer") == 0) { 3514e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_TIMER_IDX] = 3515e5b75505Sopenharmony_ci atoi(pos) & 0xff; 3516e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vi_aifsn") == 0) { 3517e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ACI_IDX] |= 3518e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN); 3519e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vi_acm") == 0) { 3520e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ACI_IDX] |= 3521e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM); 3522e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vi_aci") == 0) { 3523e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ACI_IDX] |= 3524e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI); 3525e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vi_ecwmin") == 0) { 3526e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ECW_IDX] |= 3527e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN); 3528e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vi_ecwmax") == 0) { 3529e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ECW_IDX] |= 3530e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX); 3531e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vi_timer") == 0) { 3532e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_TIMER_IDX] = 3533e5b75505Sopenharmony_ci atoi(pos) & 0xff; 3534e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vo_aifsn") == 0) { 3535e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ACI_IDX] |= 3536e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN); 3537e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vo_acm") == 0) { 3538e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ACI_IDX] |= 3539e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM); 3540e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vo_aci") == 0) { 3541e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ACI_IDX] |= 3542e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI); 3543e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vo_ecwmin") == 0) { 3544e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ECW_IDX] |= 3545e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN); 3546e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vo_ecwmax") == 0) { 3547e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ECW_IDX] |= 3548e5b75505Sopenharmony_ci set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX); 3549e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_mu_edca_ac_vo_timer") == 0) { 3550e5b75505Sopenharmony_ci conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_TIMER_IDX] = 3551e5b75505Sopenharmony_ci atoi(pos) & 0xff; 3552e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_spr_sr_control") == 0) { 3553e5b75505Sopenharmony_ci conf->spr.sr_control = atoi(pos) & 0xff; 3554e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_spr_non_srg_obss_pd_max_offset") == 0) { 3555e5b75505Sopenharmony_ci conf->spr.non_srg_obss_pd_max_offset = atoi(pos); 3556e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_spr_srg_obss_pd_min_offset") == 0) { 3557e5b75505Sopenharmony_ci conf->spr.srg_obss_pd_min_offset = atoi(pos); 3558e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_spr_srg_obss_pd_max_offset") == 0) { 3559e5b75505Sopenharmony_ci conf->spr.srg_obss_pd_max_offset = atoi(pos); 3560e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_oper_chwidth") == 0) { 3561e5b75505Sopenharmony_ci conf->he_oper_chwidth = atoi(pos); 3562e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_oper_centr_freq_seg0_idx") == 0) { 3563e5b75505Sopenharmony_ci conf->he_oper_centr_freq_seg0_idx = atoi(pos); 3564e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "he_oper_centr_freq_seg1_idx") == 0) { 3565e5b75505Sopenharmony_ci conf->he_oper_centr_freq_seg1_idx = atoi(pos); 3566e5b75505Sopenharmony_ci#endif /* CONFIG_IEEE80211AX */ 3567e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "max_listen_interval") == 0) { 3568e5b75505Sopenharmony_ci bss->max_listen_interval = atoi(pos); 3569e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "disable_pmksa_caching") == 0) { 3570e5b75505Sopenharmony_ci bss->disable_pmksa_caching = atoi(pos); 3571e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "okc") == 0) { 3572e5b75505Sopenharmony_ci bss->okc = atoi(pos); 3573e5b75505Sopenharmony_ci#ifdef CONFIG_WPS 3574e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_state") == 0) { 3575e5b75505Sopenharmony_ci bss->wps_state = atoi(pos); 3576e5b75505Sopenharmony_ci if (bss->wps_state < 0 || bss->wps_state > 2) { 3577e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid wps_state", 3578e5b75505Sopenharmony_ci line); 3579e5b75505Sopenharmony_ci return 1; 3580e5b75505Sopenharmony_ci } 3581e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_independent") == 0) { 3582e5b75505Sopenharmony_ci bss->wps_independent = atoi(pos); 3583e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_setup_locked") == 0) { 3584e5b75505Sopenharmony_ci bss->ap_setup_locked = atoi(pos); 3585e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "uuid") == 0) { 3586e5b75505Sopenharmony_ci if (uuid_str2bin(pos, bss->uuid)) { 3587e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid UUID", line); 3588e5b75505Sopenharmony_ci return 1; 3589e5b75505Sopenharmony_ci } 3590e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_pin_requests") == 0) { 3591e5b75505Sopenharmony_ci os_free(bss->wps_pin_requests); 3592e5b75505Sopenharmony_ci bss->wps_pin_requests = os_strdup(pos); 3593e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "device_name") == 0) { 3594e5b75505Sopenharmony_ci if (os_strlen(pos) > WPS_DEV_NAME_MAX_LEN) { 3595e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Too long " 3596e5b75505Sopenharmony_ci "device_name", line); 3597e5b75505Sopenharmony_ci return 1; 3598e5b75505Sopenharmony_ci } 3599e5b75505Sopenharmony_ci os_free(bss->device_name); 3600e5b75505Sopenharmony_ci bss->device_name = os_strdup(pos); 3601e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "manufacturer") == 0) { 3602e5b75505Sopenharmony_ci if (os_strlen(pos) > 64) { 3603e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Too long manufacturer", 3604e5b75505Sopenharmony_ci line); 3605e5b75505Sopenharmony_ci return 1; 3606e5b75505Sopenharmony_ci } 3607e5b75505Sopenharmony_ci os_free(bss->manufacturer); 3608e5b75505Sopenharmony_ci bss->manufacturer = os_strdup(pos); 3609e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "model_name") == 0) { 3610e5b75505Sopenharmony_ci if (os_strlen(pos) > 32) { 3611e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Too long model_name", 3612e5b75505Sopenharmony_ci line); 3613e5b75505Sopenharmony_ci return 1; 3614e5b75505Sopenharmony_ci } 3615e5b75505Sopenharmony_ci os_free(bss->model_name); 3616e5b75505Sopenharmony_ci bss->model_name = os_strdup(pos); 3617e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "model_number") == 0) { 3618e5b75505Sopenharmony_ci if (os_strlen(pos) > 32) { 3619e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Too long model_number", 3620e5b75505Sopenharmony_ci line); 3621e5b75505Sopenharmony_ci return 1; 3622e5b75505Sopenharmony_ci } 3623e5b75505Sopenharmony_ci os_free(bss->model_number); 3624e5b75505Sopenharmony_ci bss->model_number = os_strdup(pos); 3625e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "serial_number") == 0) { 3626e5b75505Sopenharmony_ci if (os_strlen(pos) > 32) { 3627e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Too long serial_number", 3628e5b75505Sopenharmony_ci line); 3629e5b75505Sopenharmony_ci return 1; 3630e5b75505Sopenharmony_ci } 3631e5b75505Sopenharmony_ci os_free(bss->serial_number); 3632e5b75505Sopenharmony_ci bss->serial_number = os_strdup(pos); 3633e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "device_type") == 0) { 3634e5b75505Sopenharmony_ci if (wps_dev_type_str2bin(pos, bss->device_type)) 3635e5b75505Sopenharmony_ci return 1; 3636e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "config_methods") == 0) { 3637e5b75505Sopenharmony_ci os_free(bss->config_methods); 3638e5b75505Sopenharmony_ci bss->config_methods = os_strdup(pos); 3639e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "os_version") == 0) { 3640e5b75505Sopenharmony_ci if (hexstr2bin(pos, bss->os_version, 4)) { 3641e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid os_version", 3642e5b75505Sopenharmony_ci line); 3643e5b75505Sopenharmony_ci return 1; 3644e5b75505Sopenharmony_ci } 3645e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_pin") == 0) { 3646e5b75505Sopenharmony_ci os_free(bss->ap_pin); 3647e5b75505Sopenharmony_ci if (*pos == '\0') 3648e5b75505Sopenharmony_ci bss->ap_pin = NULL; 3649e5b75505Sopenharmony_ci else 3650e5b75505Sopenharmony_ci bss->ap_pin = os_strdup(pos); 3651e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "skip_cred_build") == 0) { 3652e5b75505Sopenharmony_ci bss->skip_cred_build = atoi(pos); 3653e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "extra_cred") == 0) { 3654e5b75505Sopenharmony_ci os_free(bss->extra_cred); 3655e5b75505Sopenharmony_ci bss->extra_cred = (u8 *) os_readfile(pos, &bss->extra_cred_len); 3656e5b75505Sopenharmony_ci if (bss->extra_cred == NULL) { 3657e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: could not read Credentials from '%s'", 3658e5b75505Sopenharmony_ci line, pos); 3659e5b75505Sopenharmony_ci return 1; 3660e5b75505Sopenharmony_ci } 3661e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_cred_processing") == 0) { 3662e5b75505Sopenharmony_ci bss->wps_cred_processing = atoi(pos); 3663e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_cred_add_sae") == 0) { 3664e5b75505Sopenharmony_ci bss->wps_cred_add_sae = atoi(pos); 3665e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ap_settings") == 0) { 3666e5b75505Sopenharmony_ci os_free(bss->ap_settings); 3667e5b75505Sopenharmony_ci bss->ap_settings = 3668e5b75505Sopenharmony_ci (u8 *) os_readfile(pos, &bss->ap_settings_len); 3669e5b75505Sopenharmony_ci if (bss->ap_settings == NULL) { 3670e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: could not read AP Settings from '%s'", 3671e5b75505Sopenharmony_ci line, pos); 3672e5b75505Sopenharmony_ci return 1; 3673e5b75505Sopenharmony_ci } 3674e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "multi_ap_backhaul_ssid") == 0) { 3675e5b75505Sopenharmony_ci size_t slen; 3676e5b75505Sopenharmony_ci char *str = wpa_config_parse_string(pos, &slen); 3677e5b75505Sopenharmony_ci 3678e5b75505Sopenharmony_ci if (!str || slen < 1 || slen > SSID_MAX_LEN) { 3679e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'", 3680e5b75505Sopenharmony_ci line, pos); 3681e5b75505Sopenharmony_ci os_free(str); 3682e5b75505Sopenharmony_ci return 1; 3683e5b75505Sopenharmony_ci } 3684e5b75505Sopenharmony_ci os_memcpy(bss->multi_ap_backhaul_ssid.ssid, str, slen); 3685e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.ssid_len = slen; 3686e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.ssid_set = 1; 3687e5b75505Sopenharmony_ci os_free(str); 3688e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "multi_ap_backhaul_wpa_passphrase") == 0) { 3689e5b75505Sopenharmony_ci int len = os_strlen(pos); 3690e5b75505Sopenharmony_ci 3691e5b75505Sopenharmony_ci if (len < 8 || len > 63) { 3692e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3693e5b75505Sopenharmony_ci "Line %d: invalid WPA passphrase length %d (expected 8..63)", 3694e5b75505Sopenharmony_ci line, len); 3695e5b75505Sopenharmony_ci return 1; 3696e5b75505Sopenharmony_ci } 3697e5b75505Sopenharmony_ci os_free(bss->multi_ap_backhaul_ssid.wpa_passphrase); 3698e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.wpa_passphrase = os_strdup(pos); 3699e5b75505Sopenharmony_ci if (bss->multi_ap_backhaul_ssid.wpa_passphrase) { 3700e5b75505Sopenharmony_ci hostapd_config_clear_wpa_psk( 3701e5b75505Sopenharmony_ci &bss->multi_ap_backhaul_ssid.wpa_psk); 3702e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.wpa_passphrase_set = 1; 3703e5b75505Sopenharmony_ci } 3704e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "multi_ap_backhaul_wpa_psk") == 0) { 3705e5b75505Sopenharmony_ci hostapd_config_clear_wpa_psk( 3706e5b75505Sopenharmony_ci &bss->multi_ap_backhaul_ssid.wpa_psk); 3707e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.wpa_psk = 3708e5b75505Sopenharmony_ci os_zalloc(sizeof(struct hostapd_wpa_psk)); 3709e5b75505Sopenharmony_ci if (!bss->multi_ap_backhaul_ssid.wpa_psk) 3710e5b75505Sopenharmony_ci return 1; 3711e5b75505Sopenharmony_ci if (hexstr2bin(pos, bss->multi_ap_backhaul_ssid.wpa_psk->psk, 3712e5b75505Sopenharmony_ci PMK_LEN) || 3713e5b75505Sopenharmony_ci pos[PMK_LEN * 2] != '\0') { 3714e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid PSK '%s'.", 3715e5b75505Sopenharmony_ci line, pos); 3716e5b75505Sopenharmony_ci hostapd_config_clear_wpa_psk( 3717e5b75505Sopenharmony_ci &bss->multi_ap_backhaul_ssid.wpa_psk); 3718e5b75505Sopenharmony_ci return 1; 3719e5b75505Sopenharmony_ci } 3720e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.wpa_psk->group = 1; 3721e5b75505Sopenharmony_ci os_free(bss->multi_ap_backhaul_ssid.wpa_passphrase); 3722e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.wpa_passphrase = NULL; 3723e5b75505Sopenharmony_ci bss->multi_ap_backhaul_ssid.wpa_psk_set = 1; 3724e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "upnp_iface") == 0) { 3725e5b75505Sopenharmony_ci os_free(bss->upnp_iface); 3726e5b75505Sopenharmony_ci bss->upnp_iface = os_strdup(pos); 3727e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "friendly_name") == 0) { 3728e5b75505Sopenharmony_ci os_free(bss->friendly_name); 3729e5b75505Sopenharmony_ci bss->friendly_name = os_strdup(pos); 3730e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "manufacturer_url") == 0) { 3731e5b75505Sopenharmony_ci os_free(bss->manufacturer_url); 3732e5b75505Sopenharmony_ci bss->manufacturer_url = os_strdup(pos); 3733e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "model_description") == 0) { 3734e5b75505Sopenharmony_ci os_free(bss->model_description); 3735e5b75505Sopenharmony_ci bss->model_description = os_strdup(pos); 3736e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "model_url") == 0) { 3737e5b75505Sopenharmony_ci os_free(bss->model_url); 3738e5b75505Sopenharmony_ci bss->model_url = os_strdup(pos); 3739e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "upc") == 0) { 3740e5b75505Sopenharmony_ci os_free(bss->upc); 3741e5b75505Sopenharmony_ci bss->upc = os_strdup(pos); 3742e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pbc_in_m1") == 0) { 3743e5b75505Sopenharmony_ci bss->pbc_in_m1 = atoi(pos); 3744e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "server_id") == 0) { 3745e5b75505Sopenharmony_ci os_free(bss->server_id); 3746e5b75505Sopenharmony_ci bss->server_id = os_strdup(pos); 3747e5b75505Sopenharmony_ci#ifdef CONFIG_WPS_NFC 3748e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_nfc_dev_pw_id") == 0) { 3749e5b75505Sopenharmony_ci bss->wps_nfc_dev_pw_id = atoi(pos); 3750e5b75505Sopenharmony_ci if (bss->wps_nfc_dev_pw_id < 0x10 || 3751e5b75505Sopenharmony_ci bss->wps_nfc_dev_pw_id > 0xffff) { 3752e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid wps_nfc_dev_pw_id value", 3753e5b75505Sopenharmony_ci line); 3754e5b75505Sopenharmony_ci return 1; 3755e5b75505Sopenharmony_ci } 3756e5b75505Sopenharmony_ci bss->wps_nfc_pw_from_config = 1; 3757e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_nfc_dh_pubkey") == 0) { 3758e5b75505Sopenharmony_ci wpabuf_free(bss->wps_nfc_dh_pubkey); 3759e5b75505Sopenharmony_ci bss->wps_nfc_dh_pubkey = wpabuf_parse_bin(pos); 3760e5b75505Sopenharmony_ci bss->wps_nfc_pw_from_config = 1; 3761e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_nfc_dh_privkey") == 0) { 3762e5b75505Sopenharmony_ci wpabuf_free(bss->wps_nfc_dh_privkey); 3763e5b75505Sopenharmony_ci bss->wps_nfc_dh_privkey = wpabuf_parse_bin(pos); 3764e5b75505Sopenharmony_ci bss->wps_nfc_pw_from_config = 1; 3765e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wps_nfc_dev_pw") == 0) { 3766e5b75505Sopenharmony_ci wpabuf_free(bss->wps_nfc_dev_pw); 3767e5b75505Sopenharmony_ci bss->wps_nfc_dev_pw = wpabuf_parse_bin(pos); 3768e5b75505Sopenharmony_ci bss->wps_nfc_pw_from_config = 1; 3769e5b75505Sopenharmony_ci#endif /* CONFIG_WPS_NFC */ 3770e5b75505Sopenharmony_ci#endif /* CONFIG_WPS */ 3771e5b75505Sopenharmony_ci#ifdef CONFIG_P2P_MANAGER 3772e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "manage_p2p") == 0) { 3773e5b75505Sopenharmony_ci if (atoi(pos)) 3774e5b75505Sopenharmony_ci bss->p2p |= P2P_MANAGE; 3775e5b75505Sopenharmony_ci else 3776e5b75505Sopenharmony_ci bss->p2p &= ~P2P_MANAGE; 3777e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "allow_cross_connection") == 0) { 3778e5b75505Sopenharmony_ci if (atoi(pos)) 3779e5b75505Sopenharmony_ci bss->p2p |= P2P_ALLOW_CROSS_CONNECTION; 3780e5b75505Sopenharmony_ci else 3781e5b75505Sopenharmony_ci bss->p2p &= ~P2P_ALLOW_CROSS_CONNECTION; 3782e5b75505Sopenharmony_ci#endif /* CONFIG_P2P_MANAGER */ 3783e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "disassoc_low_ack") == 0) { 3784e5b75505Sopenharmony_ci bss->disassoc_low_ack = atoi(pos); 3785e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "tdls_prohibit") == 0) { 3786e5b75505Sopenharmony_ci if (atoi(pos)) 3787e5b75505Sopenharmony_ci bss->tdls |= TDLS_PROHIBIT; 3788e5b75505Sopenharmony_ci else 3789e5b75505Sopenharmony_ci bss->tdls &= ~TDLS_PROHIBIT; 3790e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "tdls_prohibit_chan_switch") == 0) { 3791e5b75505Sopenharmony_ci if (atoi(pos)) 3792e5b75505Sopenharmony_ci bss->tdls |= TDLS_PROHIBIT_CHAN_SWITCH; 3793e5b75505Sopenharmony_ci else 3794e5b75505Sopenharmony_ci bss->tdls &= ~TDLS_PROHIBIT_CHAN_SWITCH; 3795e5b75505Sopenharmony_ci#ifdef CONFIG_RSN_TESTING 3796e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rsn_testing") == 0) { 3797e5b75505Sopenharmony_ci extern int rsn_testing; 3798e5b75505Sopenharmony_ci rsn_testing = atoi(pos); 3799e5b75505Sopenharmony_ci#endif /* CONFIG_RSN_TESTING */ 3800e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "time_advertisement") == 0) { 3801e5b75505Sopenharmony_ci bss->time_advertisement = atoi(pos); 3802e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "time_zone") == 0) { 3803e5b75505Sopenharmony_ci size_t tz_len = os_strlen(pos); 3804e5b75505Sopenharmony_ci if (tz_len < 4 || tz_len > 255) { 3805e5b75505Sopenharmony_ci wpa_printf(MSG_DEBUG, "Line %d: invalid time_zone", 3806e5b75505Sopenharmony_ci line); 3807e5b75505Sopenharmony_ci return 1; 3808e5b75505Sopenharmony_ci } 3809e5b75505Sopenharmony_ci os_free(bss->time_zone); 3810e5b75505Sopenharmony_ci bss->time_zone = os_strdup(pos); 3811e5b75505Sopenharmony_ci if (bss->time_zone == NULL) 3812e5b75505Sopenharmony_ci return 1; 3813e5b75505Sopenharmony_ci#ifdef CONFIG_WNM_AP 3814e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wnm_sleep_mode") == 0) { 3815e5b75505Sopenharmony_ci bss->wnm_sleep_mode = atoi(pos); 3816e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wnm_sleep_mode_no_keys") == 0) { 3817e5b75505Sopenharmony_ci bss->wnm_sleep_mode_no_keys = atoi(pos); 3818e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "bss_transition") == 0) { 3819e5b75505Sopenharmony_ci bss->bss_transition = atoi(pos); 3820e5b75505Sopenharmony_ci#endif /* CONFIG_WNM_AP */ 3821e5b75505Sopenharmony_ci#ifdef CONFIG_INTERWORKING 3822e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "interworking") == 0) { 3823e5b75505Sopenharmony_ci bss->interworking = atoi(pos); 3824e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "access_network_type") == 0) { 3825e5b75505Sopenharmony_ci bss->access_network_type = atoi(pos); 3826e5b75505Sopenharmony_ci if (bss->access_network_type < 0 || 3827e5b75505Sopenharmony_ci bss->access_network_type > 15) { 3828e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3829e5b75505Sopenharmony_ci "Line %d: invalid access_network_type", 3830e5b75505Sopenharmony_ci line); 3831e5b75505Sopenharmony_ci return 1; 3832e5b75505Sopenharmony_ci } 3833e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "internet") == 0) { 3834e5b75505Sopenharmony_ci bss->internet = atoi(pos); 3835e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "asra") == 0) { 3836e5b75505Sopenharmony_ci bss->asra = atoi(pos); 3837e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "esr") == 0) { 3838e5b75505Sopenharmony_ci bss->esr = atoi(pos); 3839e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "uesa") == 0) { 3840e5b75505Sopenharmony_ci bss->uesa = atoi(pos); 3841e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "venue_group") == 0) { 3842e5b75505Sopenharmony_ci bss->venue_group = atoi(pos); 3843e5b75505Sopenharmony_ci bss->venue_info_set = 1; 3844e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "venue_type") == 0) { 3845e5b75505Sopenharmony_ci bss->venue_type = atoi(pos); 3846e5b75505Sopenharmony_ci bss->venue_info_set = 1; 3847e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hessid") == 0) { 3848e5b75505Sopenharmony_ci if (hwaddr_aton(pos, bss->hessid)) { 3849e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid hessid", line); 3850e5b75505Sopenharmony_ci return 1; 3851e5b75505Sopenharmony_ci } 3852e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "roaming_consortium") == 0) { 3853e5b75505Sopenharmony_ci if (parse_roaming_consortium(bss, pos, line) < 0) 3854e5b75505Sopenharmony_ci return 1; 3855e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "venue_name") == 0) { 3856e5b75505Sopenharmony_ci if (parse_venue_name(bss, pos, line) < 0) 3857e5b75505Sopenharmony_ci return 1; 3858e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "venue_url") == 0) { 3859e5b75505Sopenharmony_ci if (parse_venue_url(bss, pos, line) < 0) 3860e5b75505Sopenharmony_ci return 1; 3861e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "network_auth_type") == 0) { 3862e5b75505Sopenharmony_ci u8 auth_type; 3863e5b75505Sopenharmony_ci u16 redirect_url_len; 3864e5b75505Sopenharmony_ci if (hexstr2bin(pos, &auth_type, 1)) { 3865e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3866e5b75505Sopenharmony_ci "Line %d: Invalid network_auth_type '%s'", 3867e5b75505Sopenharmony_ci line, pos); 3868e5b75505Sopenharmony_ci return 1; 3869e5b75505Sopenharmony_ci } 3870e5b75505Sopenharmony_ci if (auth_type == 0 || auth_type == 2) 3871e5b75505Sopenharmony_ci redirect_url_len = os_strlen(pos + 2); 3872e5b75505Sopenharmony_ci else 3873e5b75505Sopenharmony_ci redirect_url_len = 0; 3874e5b75505Sopenharmony_ci os_free(bss->network_auth_type); 3875e5b75505Sopenharmony_ci bss->network_auth_type = os_malloc(redirect_url_len + 3 + 1); 3876e5b75505Sopenharmony_ci if (bss->network_auth_type == NULL) 3877e5b75505Sopenharmony_ci return 1; 3878e5b75505Sopenharmony_ci *bss->network_auth_type = auth_type; 3879e5b75505Sopenharmony_ci WPA_PUT_LE16(bss->network_auth_type + 1, redirect_url_len); 3880e5b75505Sopenharmony_ci if (redirect_url_len) 3881e5b75505Sopenharmony_ci os_memcpy(bss->network_auth_type + 3, pos + 2, 3882e5b75505Sopenharmony_ci redirect_url_len); 3883e5b75505Sopenharmony_ci bss->network_auth_type_len = 3 + redirect_url_len; 3884e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ipaddr_type_availability") == 0) { 3885e5b75505Sopenharmony_ci if (hexstr2bin(pos, &bss->ipaddr_type_availability, 1)) { 3886e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid ipaddr_type_availability '%s'", 3887e5b75505Sopenharmony_ci line, pos); 3888e5b75505Sopenharmony_ci bss->ipaddr_type_configured = 0; 3889e5b75505Sopenharmony_ci return 1; 3890e5b75505Sopenharmony_ci } 3891e5b75505Sopenharmony_ci bss->ipaddr_type_configured = 1; 3892e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "domain_name") == 0) { 3893e5b75505Sopenharmony_ci int j, num_domains, domain_len, domain_list_len = 0; 3894e5b75505Sopenharmony_ci char *tok_start, *tok_prev; 3895e5b75505Sopenharmony_ci u8 *domain_list, *domain_ptr; 3896e5b75505Sopenharmony_ci 3897e5b75505Sopenharmony_ci domain_list_len = os_strlen(pos) + 1; 3898e5b75505Sopenharmony_ci domain_list = os_malloc(domain_list_len); 3899e5b75505Sopenharmony_ci if (domain_list == NULL) 3900e5b75505Sopenharmony_ci return 1; 3901e5b75505Sopenharmony_ci 3902e5b75505Sopenharmony_ci domain_ptr = domain_list; 3903e5b75505Sopenharmony_ci tok_prev = pos; 3904e5b75505Sopenharmony_ci num_domains = 1; 3905e5b75505Sopenharmony_ci while ((tok_prev = os_strchr(tok_prev, ','))) { 3906e5b75505Sopenharmony_ci num_domains++; 3907e5b75505Sopenharmony_ci tok_prev++; 3908e5b75505Sopenharmony_ci } 3909e5b75505Sopenharmony_ci tok_prev = pos; 3910e5b75505Sopenharmony_ci for (j = 0; j < num_domains; j++) { 3911e5b75505Sopenharmony_ci tok_start = os_strchr(tok_prev, ','); 3912e5b75505Sopenharmony_ci if (tok_start) { 3913e5b75505Sopenharmony_ci domain_len = tok_start - tok_prev; 3914e5b75505Sopenharmony_ci *domain_ptr = domain_len; 3915e5b75505Sopenharmony_ci os_memcpy(domain_ptr + 1, tok_prev, domain_len); 3916e5b75505Sopenharmony_ci domain_ptr += domain_len + 1; 3917e5b75505Sopenharmony_ci tok_prev = ++tok_start; 3918e5b75505Sopenharmony_ci } else { 3919e5b75505Sopenharmony_ci domain_len = os_strlen(tok_prev); 3920e5b75505Sopenharmony_ci *domain_ptr = domain_len; 3921e5b75505Sopenharmony_ci os_memcpy(domain_ptr + 1, tok_prev, domain_len); 3922e5b75505Sopenharmony_ci domain_ptr += domain_len + 1; 3923e5b75505Sopenharmony_ci } 3924e5b75505Sopenharmony_ci } 3925e5b75505Sopenharmony_ci 3926e5b75505Sopenharmony_ci os_free(bss->domain_name); 3927e5b75505Sopenharmony_ci bss->domain_name = domain_list; 3928e5b75505Sopenharmony_ci bss->domain_name_len = domain_list_len; 3929e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "anqp_3gpp_cell_net") == 0) { 3930e5b75505Sopenharmony_ci if (parse_3gpp_cell_net(bss, pos, line) < 0) 3931e5b75505Sopenharmony_ci return 1; 3932e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "nai_realm") == 0) { 3933e5b75505Sopenharmony_ci if (parse_nai_realm(bss, pos, line) < 0) 3934e5b75505Sopenharmony_ci return 1; 3935e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "anqp_elem") == 0) { 3936e5b75505Sopenharmony_ci if (parse_anqp_elem(bss, pos, line) < 0) 3937e5b75505Sopenharmony_ci return 1; 3938e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "gas_frag_limit") == 0) { 3939e5b75505Sopenharmony_ci int val = atoi(pos); 3940e5b75505Sopenharmony_ci 3941e5b75505Sopenharmony_ci if (val <= 0) { 3942e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3943e5b75505Sopenharmony_ci "Line %d: Invalid gas_frag_limit '%s'", 3944e5b75505Sopenharmony_ci line, pos); 3945e5b75505Sopenharmony_ci return 1; 3946e5b75505Sopenharmony_ci } 3947e5b75505Sopenharmony_ci bss->gas_frag_limit = val; 3948e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "gas_comeback_delay") == 0) { 3949e5b75505Sopenharmony_ci bss->gas_comeback_delay = atoi(pos); 3950e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "qos_map_set") == 0) { 3951e5b75505Sopenharmony_ci if (parse_qos_map_set(bss, pos, line) < 0) 3952e5b75505Sopenharmony_ci return 1; 3953e5b75505Sopenharmony_ci#endif /* CONFIG_INTERWORKING */ 3954e5b75505Sopenharmony_ci#ifdef CONFIG_RADIUS_TEST 3955e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dump_msk_file") == 0) { 3956e5b75505Sopenharmony_ci os_free(bss->dump_msk_file); 3957e5b75505Sopenharmony_ci bss->dump_msk_file = os_strdup(pos); 3958e5b75505Sopenharmony_ci#endif /* CONFIG_RADIUS_TEST */ 3959e5b75505Sopenharmony_ci#ifdef CONFIG_PROXYARP 3960e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "proxy_arp") == 0) { 3961e5b75505Sopenharmony_ci bss->proxy_arp = atoi(pos); 3962e5b75505Sopenharmony_ci#endif /* CONFIG_PROXYARP */ 3963e5b75505Sopenharmony_ci#ifdef CONFIG_HS20 3964e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20") == 0) { 3965e5b75505Sopenharmony_ci bss->hs20 = atoi(pos); 3966e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_release") == 0) { 3967e5b75505Sopenharmony_ci int val = atoi(pos); 3968e5b75505Sopenharmony_ci 3969e5b75505Sopenharmony_ci if (val < 1 || val > (HS20_VERSION >> 4) + 1) { 3970e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 3971e5b75505Sopenharmony_ci "Line %d: Unsupported hs20_release: %s", 3972e5b75505Sopenharmony_ci line, pos); 3973e5b75505Sopenharmony_ci return 1; 3974e5b75505Sopenharmony_ci } 3975e5b75505Sopenharmony_ci bss->hs20_release = val; 3976e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "disable_dgaf") == 0) { 3977e5b75505Sopenharmony_ci bss->disable_dgaf = atoi(pos); 3978e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "na_mcast_to_ucast") == 0) { 3979e5b75505Sopenharmony_ci bss->na_mcast_to_ucast = atoi(pos); 3980e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osen") == 0) { 3981e5b75505Sopenharmony_ci bss->osen = atoi(pos); 3982e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "anqp_domain_id") == 0) { 3983e5b75505Sopenharmony_ci bss->anqp_domain_id = atoi(pos); 3984e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_deauth_req_timeout") == 0) { 3985e5b75505Sopenharmony_ci bss->hs20_deauth_req_timeout = atoi(pos); 3986e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_oper_friendly_name") == 0) { 3987e5b75505Sopenharmony_ci if (hs20_parse_oper_friendly_name(bss, pos, line) < 0) 3988e5b75505Sopenharmony_ci return 1; 3989e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_wan_metrics") == 0) { 3990e5b75505Sopenharmony_ci if (hs20_parse_wan_metrics(bss, pos, line) < 0) 3991e5b75505Sopenharmony_ci return 1; 3992e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_conn_capab") == 0) { 3993e5b75505Sopenharmony_ci if (hs20_parse_conn_capab(bss, pos, line) < 0) { 3994e5b75505Sopenharmony_ci return 1; 3995e5b75505Sopenharmony_ci } 3996e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_operating_class") == 0) { 3997e5b75505Sopenharmony_ci u8 *oper_class; 3998e5b75505Sopenharmony_ci size_t oper_class_len; 3999e5b75505Sopenharmony_ci oper_class_len = os_strlen(pos); 4000e5b75505Sopenharmony_ci if (oper_class_len < 2 || (oper_class_len & 0x01)) { 4001e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4002e5b75505Sopenharmony_ci "Line %d: Invalid hs20_operating_class '%s'", 4003e5b75505Sopenharmony_ci line, pos); 4004e5b75505Sopenharmony_ci return 1; 4005e5b75505Sopenharmony_ci } 4006e5b75505Sopenharmony_ci oper_class_len /= 2; 4007e5b75505Sopenharmony_ci oper_class = os_malloc(oper_class_len); 4008e5b75505Sopenharmony_ci if (oper_class == NULL) 4009e5b75505Sopenharmony_ci return 1; 4010e5b75505Sopenharmony_ci if (hexstr2bin(pos, oper_class, oper_class_len)) { 4011e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4012e5b75505Sopenharmony_ci "Line %d: Invalid hs20_operating_class '%s'", 4013e5b75505Sopenharmony_ci line, pos); 4014e5b75505Sopenharmony_ci os_free(oper_class); 4015e5b75505Sopenharmony_ci return 1; 4016e5b75505Sopenharmony_ci } 4017e5b75505Sopenharmony_ci os_free(bss->hs20_operating_class); 4018e5b75505Sopenharmony_ci bss->hs20_operating_class = oper_class; 4019e5b75505Sopenharmony_ci bss->hs20_operating_class_len = oper_class_len; 4020e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_icon") == 0) { 4021e5b75505Sopenharmony_ci if (hs20_parse_icon(bss, pos) < 0) { 4022e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid hs20_icon '%s'", 4023e5b75505Sopenharmony_ci line, pos); 4024e5b75505Sopenharmony_ci return 1; 4025e5b75505Sopenharmony_ci } 4026e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_ssid") == 0) { 4027e5b75505Sopenharmony_ci if (hs20_parse_osu_ssid(bss, pos, line) < 0) 4028e5b75505Sopenharmony_ci return 1; 4029e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_server_uri") == 0) { 4030e5b75505Sopenharmony_ci if (hs20_parse_osu_server_uri(bss, pos, line) < 0) 4031e5b75505Sopenharmony_ci return 1; 4032e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_friendly_name") == 0) { 4033e5b75505Sopenharmony_ci if (hs20_parse_osu_friendly_name(bss, pos, line) < 0) 4034e5b75505Sopenharmony_ci return 1; 4035e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_nai") == 0) { 4036e5b75505Sopenharmony_ci if (hs20_parse_osu_nai(bss, pos, line) < 0) 4037e5b75505Sopenharmony_ci return 1; 4038e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_nai2") == 0) { 4039e5b75505Sopenharmony_ci if (hs20_parse_osu_nai2(bss, pos, line) < 0) 4040e5b75505Sopenharmony_ci return 1; 4041e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_method_list") == 0) { 4042e5b75505Sopenharmony_ci if (hs20_parse_osu_method_list(bss, pos, line) < 0) 4043e5b75505Sopenharmony_ci return 1; 4044e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_icon") == 0) { 4045e5b75505Sopenharmony_ci if (hs20_parse_osu_icon(bss, pos, line) < 0) 4046e5b75505Sopenharmony_ci return 1; 4047e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "osu_service_desc") == 0) { 4048e5b75505Sopenharmony_ci if (hs20_parse_osu_service_desc(bss, pos, line) < 0) 4049e5b75505Sopenharmony_ci return 1; 4050e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "operator_icon") == 0) { 4051e5b75505Sopenharmony_ci if (hs20_parse_operator_icon(bss, pos, line) < 0) 4052e5b75505Sopenharmony_ci return 1; 4053e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "subscr_remediation_url") == 0) { 4054e5b75505Sopenharmony_ci os_free(bss->subscr_remediation_url); 4055e5b75505Sopenharmony_ci bss->subscr_remediation_url = os_strdup(pos); 4056e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "subscr_remediation_method") == 0) { 4057e5b75505Sopenharmony_ci bss->subscr_remediation_method = atoi(pos); 4058e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_t_c_filename") == 0) { 4059e5b75505Sopenharmony_ci os_free(bss->t_c_filename); 4060e5b75505Sopenharmony_ci bss->t_c_filename = os_strdup(pos); 4061e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_t_c_timestamp") == 0) { 4062e5b75505Sopenharmony_ci bss->t_c_timestamp = strtol(pos, NULL, 0); 4063e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_t_c_server_url") == 0) { 4064e5b75505Sopenharmony_ci os_free(bss->t_c_server_url); 4065e5b75505Sopenharmony_ci bss->t_c_server_url = os_strdup(pos); 4066e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "hs20_sim_provisioning_url") == 0) { 4067e5b75505Sopenharmony_ci os_free(bss->hs20_sim_provisioning_url); 4068e5b75505Sopenharmony_ci bss->hs20_sim_provisioning_url = os_strdup(pos); 4069e5b75505Sopenharmony_ci#endif /* CONFIG_HS20 */ 4070e5b75505Sopenharmony_ci#ifdef CONFIG_MBO 4071e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "mbo") == 0) { 4072e5b75505Sopenharmony_ci bss->mbo_enabled = atoi(pos); 4073e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "mbo_cell_data_conn_pref") == 0) { 4074e5b75505Sopenharmony_ci bss->mbo_cell_data_conn_pref = atoi(pos); 4075e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "oce") == 0) { 4076e5b75505Sopenharmony_ci bss->oce = atoi(pos); 4077e5b75505Sopenharmony_ci#endif /* CONFIG_MBO */ 4078e5b75505Sopenharmony_ci#ifdef CONFIG_TESTING_OPTIONS 4079e5b75505Sopenharmony_ci#define PARSE_TEST_PROBABILITY(_val) \ 4080e5b75505Sopenharmony_ci } else if (os_strcmp(buf, #_val) == 0) { \ 4081e5b75505Sopenharmony_ci char *end; \ 4082e5b75505Sopenharmony_ci \ 4083e5b75505Sopenharmony_ci conf->_val = strtod(pos, &end); \ 4084e5b75505Sopenharmony_ci if (*end || conf->_val < 0.0 || \ 4085e5b75505Sopenharmony_ci conf->_val > 1.0) { \ 4086e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, \ 4087e5b75505Sopenharmony_ci "Line %d: Invalid value '%s'", \ 4088e5b75505Sopenharmony_ci line, pos); \ 4089e5b75505Sopenharmony_ci return 1; \ 4090e5b75505Sopenharmony_ci } 4091e5b75505Sopenharmony_ci PARSE_TEST_PROBABILITY(ignore_probe_probability) 4092e5b75505Sopenharmony_ci PARSE_TEST_PROBABILITY(ignore_auth_probability) 4093e5b75505Sopenharmony_ci PARSE_TEST_PROBABILITY(ignore_assoc_probability) 4094e5b75505Sopenharmony_ci PARSE_TEST_PROBABILITY(ignore_reassoc_probability) 4095e5b75505Sopenharmony_ci PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability) 4096e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ecsa_ie_only") == 0) { 4097e5b75505Sopenharmony_ci conf->ecsa_ie_only = atoi(pos); 4098e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "bss_load_test") == 0) { 4099e5b75505Sopenharmony_ci WPA_PUT_LE16(bss->bss_load_test, atoi(pos)); 4100e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 4101e5b75505Sopenharmony_ci if (pos == NULL) { 4102e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid bss_load_test", 4103e5b75505Sopenharmony_ci line); 4104e5b75505Sopenharmony_ci return 1; 4105e5b75505Sopenharmony_ci } 4106e5b75505Sopenharmony_ci pos++; 4107e5b75505Sopenharmony_ci bss->bss_load_test[2] = atoi(pos); 4108e5b75505Sopenharmony_ci pos = os_strchr(pos, ':'); 4109e5b75505Sopenharmony_ci if (pos == NULL) { 4110e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid bss_load_test", 4111e5b75505Sopenharmony_ci line); 4112e5b75505Sopenharmony_ci return 1; 4113e5b75505Sopenharmony_ci } 4114e5b75505Sopenharmony_ci pos++; 4115e5b75505Sopenharmony_ci WPA_PUT_LE16(&bss->bss_load_test[3], atoi(pos)); 4116e5b75505Sopenharmony_ci bss->bss_load_test_set = 1; 4117e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "radio_measurements") == 0) { 4118e5b75505Sopenharmony_ci /* 4119e5b75505Sopenharmony_ci * DEPRECATED: This parameter will be removed in the future. 4120e5b75505Sopenharmony_ci * Use rrm_neighbor_report instead. 4121e5b75505Sopenharmony_ci */ 4122e5b75505Sopenharmony_ci int val = atoi(pos); 4123e5b75505Sopenharmony_ci 4124e5b75505Sopenharmony_ci if (val & BIT(0)) 4125e5b75505Sopenharmony_ci bss->radio_measurements[0] |= 4126e5b75505Sopenharmony_ci WLAN_RRM_CAPS_NEIGHBOR_REPORT; 4127e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "own_ie_override") == 0) { 4128e5b75505Sopenharmony_ci struct wpabuf *tmp; 4129e5b75505Sopenharmony_ci size_t len = os_strlen(pos) / 2; 4130e5b75505Sopenharmony_ci 4131e5b75505Sopenharmony_ci tmp = wpabuf_alloc(len); 4132e5b75505Sopenharmony_ci if (!tmp) 4133e5b75505Sopenharmony_ci return 1; 4134e5b75505Sopenharmony_ci 4135e5b75505Sopenharmony_ci if (hexstr2bin(pos, wpabuf_put(tmp, len), len)) { 4136e5b75505Sopenharmony_ci wpabuf_free(tmp); 4137e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4138e5b75505Sopenharmony_ci "Line %d: Invalid own_ie_override '%s'", 4139e5b75505Sopenharmony_ci line, pos); 4140e5b75505Sopenharmony_ci return 1; 4141e5b75505Sopenharmony_ci } 4142e5b75505Sopenharmony_ci 4143e5b75505Sopenharmony_ci wpabuf_free(bss->own_ie_override); 4144e5b75505Sopenharmony_ci bss->own_ie_override = tmp; 4145e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_reflection_attack") == 0) { 4146e5b75505Sopenharmony_ci bss->sae_reflection_attack = atoi(pos); 4147e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_commit_override") == 0) { 4148e5b75505Sopenharmony_ci wpabuf_free(bss->sae_commit_override); 4149e5b75505Sopenharmony_ci bss->sae_commit_override = wpabuf_parse_bin(pos); 4150e5b75505Sopenharmony_ci#endif /* CONFIG_TESTING_OPTIONS */ 4151e5b75505Sopenharmony_ci#ifdef CONFIG_SAE 4152e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_password") == 0) { 4153e5b75505Sopenharmony_ci if (parse_sae_password(bss, pos) < 0) { 4154e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid sae_password", 4155e5b75505Sopenharmony_ci line); 4156e5b75505Sopenharmony_ci return 1; 4157e5b75505Sopenharmony_ci } 4158e5b75505Sopenharmony_ci#endif /* CONFIG_SAE */ 4159e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "vendor_elements") == 0) { 4160e5b75505Sopenharmony_ci if (parse_wpabuf_hex(line, buf, &bss->vendor_elements, pos)) 4161e5b75505Sopenharmony_ci return 1; 4162e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "assocresp_elements") == 0) { 4163e5b75505Sopenharmony_ci if (parse_wpabuf_hex(line, buf, &bss->assocresp_elements, pos)) 4164e5b75505Sopenharmony_ci return 1; 4165e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_anti_clogging_threshold") == 0) { 4166e5b75505Sopenharmony_ci bss->sae_anti_clogging_threshold = atoi(pos); 4167e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_sync") == 0) { 4168e5b75505Sopenharmony_ci bss->sae_sync = atoi(pos); 4169e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_groups") == 0) { 4170e5b75505Sopenharmony_ci if (hostapd_parse_intlist(&bss->sae_groups, pos)) { 4171e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4172e5b75505Sopenharmony_ci "Line %d: Invalid sae_groups value '%s'", 4173e5b75505Sopenharmony_ci line, pos); 4174e5b75505Sopenharmony_ci return 1; 4175e5b75505Sopenharmony_ci } 4176e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "sae_require_mfp") == 0) { 4177e5b75505Sopenharmony_ci bss->sae_require_mfp = atoi(pos); 4178e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "local_pwr_constraint") == 0) { 4179e5b75505Sopenharmony_ci int val = atoi(pos); 4180e5b75505Sopenharmony_ci if (val < 0 || val > 255) { 4181e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)", 4182e5b75505Sopenharmony_ci line, val); 4183e5b75505Sopenharmony_ci return 1; 4184e5b75505Sopenharmony_ci } 4185e5b75505Sopenharmony_ci conf->local_pwr_constraint = val; 4186e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "spectrum_mgmt_required") == 0) { 4187e5b75505Sopenharmony_ci conf->spectrum_mgmt_required = atoi(pos); 4188e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "wowlan_triggers") == 0) { 4189e5b75505Sopenharmony_ci os_free(bss->wowlan_triggers); 4190e5b75505Sopenharmony_ci bss->wowlan_triggers = os_strdup(pos); 4191e5b75505Sopenharmony_ci#ifdef CONFIG_FST 4192e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fst_group_id") == 0) { 4193e5b75505Sopenharmony_ci size_t len = os_strlen(pos); 4194e5b75505Sopenharmony_ci 4195e5b75505Sopenharmony_ci if (!len || len >= sizeof(conf->fst_cfg.group_id)) { 4196e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4197e5b75505Sopenharmony_ci "Line %d: Invalid fst_group_id value '%s'", 4198e5b75505Sopenharmony_ci line, pos); 4199e5b75505Sopenharmony_ci return 1; 4200e5b75505Sopenharmony_ci } 4201e5b75505Sopenharmony_ci 4202e5b75505Sopenharmony_ci if (conf->fst_cfg.group_id[0]) { 4203e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4204e5b75505Sopenharmony_ci "Line %d: Duplicate fst_group value '%s'", 4205e5b75505Sopenharmony_ci line, pos); 4206e5b75505Sopenharmony_ci return 1; 4207e5b75505Sopenharmony_ci } 4208e5b75505Sopenharmony_ci 4209e5b75505Sopenharmony_ci os_strlcpy(conf->fst_cfg.group_id, pos, 4210e5b75505Sopenharmony_ci sizeof(conf->fst_cfg.group_id)); 4211e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fst_priority") == 0) { 4212e5b75505Sopenharmony_ci char *endp; 4213e5b75505Sopenharmony_ci long int val; 4214e5b75505Sopenharmony_ci 4215e5b75505Sopenharmony_ci if (!*pos) { 4216e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4217e5b75505Sopenharmony_ci "Line %d: fst_priority value not supplied (expected 1..%u)", 4218e5b75505Sopenharmony_ci line, FST_MAX_PRIO_VALUE); 4219e5b75505Sopenharmony_ci return -1; 4220e5b75505Sopenharmony_ci } 4221e5b75505Sopenharmony_ci 4222e5b75505Sopenharmony_ci val = strtol(pos, &endp, 0); 4223e5b75505Sopenharmony_ci if (*endp || val < 1 || val > FST_MAX_PRIO_VALUE) { 4224e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4225e5b75505Sopenharmony_ci "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)", 4226e5b75505Sopenharmony_ci line, val, pos, FST_MAX_PRIO_VALUE); 4227e5b75505Sopenharmony_ci return 1; 4228e5b75505Sopenharmony_ci } 4229e5b75505Sopenharmony_ci conf->fst_cfg.priority = (u8) val; 4230e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fst_llt") == 0) { 4231e5b75505Sopenharmony_ci char *endp; 4232e5b75505Sopenharmony_ci long int val; 4233e5b75505Sopenharmony_ci 4234e5b75505Sopenharmony_ci if (!*pos) { 4235e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4236e5b75505Sopenharmony_ci "Line %d: fst_llt value not supplied (expected 1..%u)", 4237e5b75505Sopenharmony_ci line, FST_MAX_LLT_MS); 4238e5b75505Sopenharmony_ci return -1; 4239e5b75505Sopenharmony_ci } 4240e5b75505Sopenharmony_ci val = strtol(pos, &endp, 0); 4241e5b75505Sopenharmony_ci if (*endp || val < 1 || 4242e5b75505Sopenharmony_ci (unsigned long int) val > FST_MAX_LLT_MS) { 4243e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4244e5b75505Sopenharmony_ci "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)", 4245e5b75505Sopenharmony_ci line, val, pos, FST_MAX_LLT_MS); 4246e5b75505Sopenharmony_ci return 1; 4247e5b75505Sopenharmony_ci } 4248e5b75505Sopenharmony_ci conf->fst_cfg.llt = (u32) val; 4249e5b75505Sopenharmony_ci#endif /* CONFIG_FST */ 4250e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "track_sta_max_num") == 0) { 4251e5b75505Sopenharmony_ci conf->track_sta_max_num = atoi(pos); 4252e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "track_sta_max_age") == 0) { 4253e5b75505Sopenharmony_ci conf->track_sta_max_age = atoi(pos); 4254e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "no_probe_resp_if_seen_on") == 0) { 4255e5b75505Sopenharmony_ci os_free(bss->no_probe_resp_if_seen_on); 4256e5b75505Sopenharmony_ci bss->no_probe_resp_if_seen_on = os_strdup(pos); 4257e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "no_auth_if_seen_on") == 0) { 4258e5b75505Sopenharmony_ci os_free(bss->no_auth_if_seen_on); 4259e5b75505Sopenharmony_ci bss->no_auth_if_seen_on = os_strdup(pos); 4260e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "lci") == 0) { 4261e5b75505Sopenharmony_ci wpabuf_free(conf->lci); 4262e5b75505Sopenharmony_ci conf->lci = wpabuf_parse_bin(pos); 4263e5b75505Sopenharmony_ci if (conf->lci && wpabuf_len(conf->lci) == 0) { 4264e5b75505Sopenharmony_ci wpabuf_free(conf->lci); 4265e5b75505Sopenharmony_ci conf->lci = NULL; 4266e5b75505Sopenharmony_ci } 4267e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "civic") == 0) { 4268e5b75505Sopenharmony_ci wpabuf_free(conf->civic); 4269e5b75505Sopenharmony_ci conf->civic = wpabuf_parse_bin(pos); 4270e5b75505Sopenharmony_ci if (conf->civic && wpabuf_len(conf->civic) == 0) { 4271e5b75505Sopenharmony_ci wpabuf_free(conf->civic); 4272e5b75505Sopenharmony_ci conf->civic = NULL; 4273e5b75505Sopenharmony_ci } 4274e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rrm_neighbor_report") == 0) { 4275e5b75505Sopenharmony_ci if (atoi(pos)) 4276e5b75505Sopenharmony_ci bss->radio_measurements[0] |= 4277e5b75505Sopenharmony_ci WLAN_RRM_CAPS_NEIGHBOR_REPORT; 4278e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rrm_beacon_report") == 0) { 4279e5b75505Sopenharmony_ci if (atoi(pos)) 4280e5b75505Sopenharmony_ci bss->radio_measurements[0] |= 4281e5b75505Sopenharmony_ci WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE | 4282e5b75505Sopenharmony_ci WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE | 4283e5b75505Sopenharmony_ci WLAN_RRM_CAPS_BEACON_REPORT_TABLE; 4284e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "gas_address3") == 0) { 4285e5b75505Sopenharmony_ci bss->gas_address3 = atoi(pos); 4286e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "stationary_ap") == 0) { 4287e5b75505Sopenharmony_ci conf->stationary_ap = atoi(pos); 4288e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ftm_responder") == 0) { 4289e5b75505Sopenharmony_ci bss->ftm_responder = atoi(pos); 4290e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "ftm_initiator") == 0) { 4291e5b75505Sopenharmony_ci bss->ftm_initiator = atoi(pos); 4292e5b75505Sopenharmony_ci#ifdef CONFIG_FILS 4293e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fils_cache_id") == 0) { 4294e5b75505Sopenharmony_ci if (hexstr2bin(pos, bss->fils_cache_id, FILS_CACHE_ID_LEN)) { 4295e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4296e5b75505Sopenharmony_ci "Line %d: Invalid fils_cache_id '%s'", 4297e5b75505Sopenharmony_ci line, pos); 4298e5b75505Sopenharmony_ci return 1; 4299e5b75505Sopenharmony_ci } 4300e5b75505Sopenharmony_ci bss->fils_cache_id_set = 1; 4301e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fils_realm") == 0) { 4302e5b75505Sopenharmony_ci if (parse_fils_realm(bss, pos) < 0) 4303e5b75505Sopenharmony_ci return 1; 4304e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fils_dh_group") == 0) { 4305e5b75505Sopenharmony_ci bss->fils_dh_group = atoi(pos); 4306e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dhcp_server") == 0) { 4307e5b75505Sopenharmony_ci if (hostapd_parse_ip_addr(pos, &bss->dhcp_server)) { 4308e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4309e5b75505Sopenharmony_ci "Line %d: invalid IP address '%s'", 4310e5b75505Sopenharmony_ci line, pos); 4311e5b75505Sopenharmony_ci return 1; 4312e5b75505Sopenharmony_ci } 4313e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dhcp_rapid_commit_proxy") == 0) { 4314e5b75505Sopenharmony_ci bss->dhcp_rapid_commit_proxy = atoi(pos); 4315e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "fils_hlp_wait_time") == 0) { 4316e5b75505Sopenharmony_ci bss->fils_hlp_wait_time = atoi(pos); 4317e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dhcp_server_port") == 0) { 4318e5b75505Sopenharmony_ci bss->dhcp_server_port = atoi(pos); 4319e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dhcp_relay_port") == 0) { 4320e5b75505Sopenharmony_ci bss->dhcp_relay_port = atoi(pos); 4321e5b75505Sopenharmony_ci#endif /* CONFIG_FILS */ 4322e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "multicast_to_unicast") == 0) { 4323e5b75505Sopenharmony_ci bss->multicast_to_unicast = atoi(pos); 4324e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "broadcast_deauth") == 0) { 4325e5b75505Sopenharmony_ci bss->broadcast_deauth = atoi(pos); 4326e5b75505Sopenharmony_ci#ifdef CONFIG_DPP 4327e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dpp_connector") == 0) { 4328e5b75505Sopenharmony_ci os_free(bss->dpp_connector); 4329e5b75505Sopenharmony_ci bss->dpp_connector = os_strdup(pos); 4330e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dpp_netaccesskey") == 0) { 4331e5b75505Sopenharmony_ci if (parse_wpabuf_hex(line, buf, &bss->dpp_netaccesskey, pos)) 4332e5b75505Sopenharmony_ci return 1; 4333e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dpp_netaccesskey_expiry") == 0) { 4334e5b75505Sopenharmony_ci bss->dpp_netaccesskey_expiry = strtol(pos, NULL, 0); 4335e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dpp_csign") == 0) { 4336e5b75505Sopenharmony_ci if (parse_wpabuf_hex(line, buf, &bss->dpp_csign, pos)) 4337e5b75505Sopenharmony_ci return 1; 4338e5b75505Sopenharmony_ci#ifdef CONFIG_DPP2 4339e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "dpp_controller") == 0) { 4340e5b75505Sopenharmony_ci if (hostapd_dpp_controller_parse(bss, pos)) 4341e5b75505Sopenharmony_ci return 1; 4342e5b75505Sopenharmony_ci#endif /* CONFIG_DPP2 */ 4343e5b75505Sopenharmony_ci#endif /* CONFIG_DPP */ 4344e5b75505Sopenharmony_ci#ifdef CONFIG_OWE 4345e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "owe_transition_bssid") == 0) { 4346e5b75505Sopenharmony_ci if (hwaddr_aton(pos, bss->owe_transition_bssid)) { 4347e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4348e5b75505Sopenharmony_ci "Line %d: invalid owe_transition_bssid", 4349e5b75505Sopenharmony_ci line); 4350e5b75505Sopenharmony_ci return 1; 4351e5b75505Sopenharmony_ci } 4352e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "owe_transition_ssid") == 0) { 4353e5b75505Sopenharmony_ci size_t slen; 4354e5b75505Sopenharmony_ci char *str = wpa_config_parse_string(pos, &slen); 4355e5b75505Sopenharmony_ci 4356e5b75505Sopenharmony_ci if (!str || slen < 1 || slen > SSID_MAX_LEN) { 4357e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'", 4358e5b75505Sopenharmony_ci line, pos); 4359e5b75505Sopenharmony_ci os_free(str); 4360e5b75505Sopenharmony_ci return 1; 4361e5b75505Sopenharmony_ci } 4362e5b75505Sopenharmony_ci os_memcpy(bss->owe_transition_ssid, str, slen); 4363e5b75505Sopenharmony_ci bss->owe_transition_ssid_len = slen; 4364e5b75505Sopenharmony_ci os_free(str); 4365e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "owe_transition_ifname") == 0) { 4366e5b75505Sopenharmony_ci os_strlcpy(bss->owe_transition_ifname, pos, 4367e5b75505Sopenharmony_ci sizeof(bss->owe_transition_ifname)); 4368e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "owe_groups") == 0) { 4369e5b75505Sopenharmony_ci if (hostapd_parse_intlist(&bss->owe_groups, pos)) { 4370e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4371e5b75505Sopenharmony_ci "Line %d: Invalid owe_groups value '%s'", 4372e5b75505Sopenharmony_ci line, pos); 4373e5b75505Sopenharmony_ci return 1; 4374e5b75505Sopenharmony_ci } 4375e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "coloc_intf_reporting") == 0) { 4376e5b75505Sopenharmony_ci bss->coloc_intf_reporting = atoi(pos); 4377e5b75505Sopenharmony_ci#endif /* CONFIG_OWE */ 4378e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "multi_ap") == 0) { 4379e5b75505Sopenharmony_ci int val = atoi(pos); 4380e5b75505Sopenharmony_ci 4381e5b75505Sopenharmony_ci if (val < 0 || val > 3) { 4382e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid multi_ap '%s'", 4383e5b75505Sopenharmony_ci line, buf); 4384e5b75505Sopenharmony_ci return -1; 4385e5b75505Sopenharmony_ci } 4386e5b75505Sopenharmony_ci 4387e5b75505Sopenharmony_ci bss->multi_ap = val; 4388e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rssi_reject_assoc_rssi") == 0) { 4389e5b75505Sopenharmony_ci conf->rssi_reject_assoc_rssi = atoi(pos); 4390e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "rssi_reject_assoc_timeout") == 0) { 4391e5b75505Sopenharmony_ci conf->rssi_reject_assoc_timeout = atoi(pos); 4392e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "pbss") == 0) { 4393e5b75505Sopenharmony_ci bss->pbss = atoi(pos); 4394e5b75505Sopenharmony_ci#ifdef CONFIG_AIRTIME_POLICY 4395e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "airtime_mode") == 0) { 4396e5b75505Sopenharmony_ci int val = atoi(pos); 4397e5b75505Sopenharmony_ci 4398e5b75505Sopenharmony_ci if (val < 0 || val > AIRTIME_MODE_MAX) { 4399e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Unknown airtime_mode", 4400e5b75505Sopenharmony_ci line); 4401e5b75505Sopenharmony_ci return 1; 4402e5b75505Sopenharmony_ci } 4403e5b75505Sopenharmony_ci conf->airtime_mode = val; 4404e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "airtime_update_interval") == 0) { 4405e5b75505Sopenharmony_ci conf->airtime_update_interval = atoi(pos); 4406e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "airtime_bss_weight") == 0) { 4407e5b75505Sopenharmony_ci bss->airtime_weight = atoi(pos); 4408e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "airtime_bss_limit") == 0) { 4409e5b75505Sopenharmony_ci int val = atoi(pos); 4410e5b75505Sopenharmony_ci 4411e5b75505Sopenharmony_ci if (val < 0 || val > 1) { 4412e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4413e5b75505Sopenharmony_ci "Line %d: Invalid airtime_bss_limit (must be 0 or 1)", 4414e5b75505Sopenharmony_ci line); 4415e5b75505Sopenharmony_ci return 1; 4416e5b75505Sopenharmony_ci } 4417e5b75505Sopenharmony_ci bss->airtime_limit = val; 4418e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "airtime_sta_weight") == 0) { 4419e5b75505Sopenharmony_ci if (add_airtime_weight(bss, pos) < 0) { 4420e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4421e5b75505Sopenharmony_ci "Line %d: Invalid airtime weight '%s'", 4422e5b75505Sopenharmony_ci line, pos); 4423e5b75505Sopenharmony_ci return 1; 4424e5b75505Sopenharmony_ci } 4425e5b75505Sopenharmony_ci#endif /* CONFIG_AIRTIME_POLICY */ 4426e5b75505Sopenharmony_ci#ifdef CONFIG_MACSEC 4427e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "macsec_policy") == 0) { 4428e5b75505Sopenharmony_ci int macsec_policy = atoi(pos); 4429e5b75505Sopenharmony_ci 4430e5b75505Sopenharmony_ci if (macsec_policy < 0 || macsec_policy > 1) { 4431e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4432e5b75505Sopenharmony_ci "Line %d: invalid macsec_policy (%d): '%s'.", 4433e5b75505Sopenharmony_ci line, macsec_policy, pos); 4434e5b75505Sopenharmony_ci return 1; 4435e5b75505Sopenharmony_ci } 4436e5b75505Sopenharmony_ci bss->macsec_policy = macsec_policy; 4437e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "macsec_integ_only") == 0) { 4438e5b75505Sopenharmony_ci int macsec_integ_only = atoi(pos); 4439e5b75505Sopenharmony_ci 4440e5b75505Sopenharmony_ci if (macsec_integ_only < 0 || macsec_integ_only > 1) { 4441e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4442e5b75505Sopenharmony_ci "Line %d: invalid macsec_integ_only (%d): '%s'.", 4443e5b75505Sopenharmony_ci line, macsec_integ_only, pos); 4444e5b75505Sopenharmony_ci return 1; 4445e5b75505Sopenharmony_ci } 4446e5b75505Sopenharmony_ci bss->macsec_integ_only = macsec_integ_only; 4447e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "macsec_replay_protect") == 0) { 4448e5b75505Sopenharmony_ci int macsec_replay_protect = atoi(pos); 4449e5b75505Sopenharmony_ci 4450e5b75505Sopenharmony_ci if (macsec_replay_protect < 0 || macsec_replay_protect > 1) { 4451e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4452e5b75505Sopenharmony_ci "Line %d: invalid macsec_replay_protect (%d): '%s'.", 4453e5b75505Sopenharmony_ci line, macsec_replay_protect, pos); 4454e5b75505Sopenharmony_ci return 1; 4455e5b75505Sopenharmony_ci } 4456e5b75505Sopenharmony_ci bss->macsec_replay_protect = macsec_replay_protect; 4457e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "macsec_replay_window") == 0) { 4458e5b75505Sopenharmony_ci bss->macsec_replay_window = atoi(pos); 4459e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "macsec_port") == 0) { 4460e5b75505Sopenharmony_ci int macsec_port = atoi(pos); 4461e5b75505Sopenharmony_ci 4462e5b75505Sopenharmony_ci if (macsec_port < 1 || macsec_port > 65534) { 4463e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4464e5b75505Sopenharmony_ci "Line %d: invalid macsec_port (%d): '%s'.", 4465e5b75505Sopenharmony_ci line, macsec_port, pos); 4466e5b75505Sopenharmony_ci return 1; 4467e5b75505Sopenharmony_ci } 4468e5b75505Sopenharmony_ci bss->macsec_port = macsec_port; 4469e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "mka_priority") == 0) { 4470e5b75505Sopenharmony_ci int mka_priority = atoi(pos); 4471e5b75505Sopenharmony_ci 4472e5b75505Sopenharmony_ci if (mka_priority < 0 || mka_priority > 255) { 4473e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4474e5b75505Sopenharmony_ci "Line %d: invalid mka_priority (%d): '%s'.", 4475e5b75505Sopenharmony_ci line, mka_priority, pos); 4476e5b75505Sopenharmony_ci return 1; 4477e5b75505Sopenharmony_ci } 4478e5b75505Sopenharmony_ci bss->mka_priority = mka_priority; 4479e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "mka_cak") == 0) { 4480e5b75505Sopenharmony_ci size_t len = os_strlen(pos); 4481e5b75505Sopenharmony_ci 4482e5b75505Sopenharmony_ci if (len > 2 * MACSEC_CAK_MAX_LEN || 4483e5b75505Sopenharmony_ci (len != 2 * 16 && len != 2 * 32) || 4484e5b75505Sopenharmony_ci hexstr2bin(pos, bss->mka_cak, len / 2)) { 4485e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CAK '%s'.", 4486e5b75505Sopenharmony_ci line, pos); 4487e5b75505Sopenharmony_ci return 1; 4488e5b75505Sopenharmony_ci } 4489e5b75505Sopenharmony_ci bss->mka_cak_len = len / 2; 4490e5b75505Sopenharmony_ci bss->mka_psk_set |= MKA_PSK_SET_CAK; 4491e5b75505Sopenharmony_ci } else if (os_strcmp(buf, "mka_ckn") == 0) { 4492e5b75505Sopenharmony_ci size_t len = os_strlen(pos); 4493e5b75505Sopenharmony_ci 4494e5b75505Sopenharmony_ci if (len > 2 * MACSEC_CKN_MAX_LEN || /* too long */ 4495e5b75505Sopenharmony_ci len < 2 || /* too short */ 4496e5b75505Sopenharmony_ci len % 2 != 0 /* not an integral number of bytes */) { 4497e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.", 4498e5b75505Sopenharmony_ci line, pos); 4499e5b75505Sopenharmony_ci return 1; 4500e5b75505Sopenharmony_ci } 4501e5b75505Sopenharmony_ci bss->mka_ckn_len = len / 2; 4502e5b75505Sopenharmony_ci if (hexstr2bin(pos, bss->mka_ckn, bss->mka_ckn_len)) { 4503e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.", 4504e5b75505Sopenharmony_ci line, pos); 4505e5b75505Sopenharmony_ci return -1; 4506e5b75505Sopenharmony_ci } 4507e5b75505Sopenharmony_ci bss->mka_psk_set |= MKA_PSK_SET_CKN; 4508e5b75505Sopenharmony_ci#endif /* CONFIG_MACSEC */ 4509e5b75505Sopenharmony_ci } else { 4510e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, 4511e5b75505Sopenharmony_ci "Line %d: unknown configuration item '%s'", 4512e5b75505Sopenharmony_ci line, buf); 4513e5b75505Sopenharmony_ci return 1; 4514e5b75505Sopenharmony_ci } 4515e5b75505Sopenharmony_ci 4516e5b75505Sopenharmony_ci return 0; 4517e5b75505Sopenharmony_ci} 4518e5b75505Sopenharmony_ci 4519e5b75505Sopenharmony_ci 4520e5b75505Sopenharmony_ci/** 4521e5b75505Sopenharmony_ci * hostapd_config_read - Read and parse a configuration file 4522e5b75505Sopenharmony_ci * @fname: Configuration file name (including path, if needed) 4523e5b75505Sopenharmony_ci * Returns: Allocated configuration data structure 4524e5b75505Sopenharmony_ci */ 4525e5b75505Sopenharmony_cistruct hostapd_config * hostapd_config_read(const char *fname) 4526e5b75505Sopenharmony_ci{ 4527e5b75505Sopenharmony_ci struct hostapd_config *conf; 4528e5b75505Sopenharmony_ci FILE *f; 4529e5b75505Sopenharmony_ci char buf[4096], *pos; 4530e5b75505Sopenharmony_ci int line = 0; 4531e5b75505Sopenharmony_ci int errors = 0; 4532e5b75505Sopenharmony_ci size_t i; 4533e5b75505Sopenharmony_ci 4534e5b75505Sopenharmony_ci f = fopen(fname, "r"); 4535e5b75505Sopenharmony_ci if (f == NULL) { 4536e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Could not open configuration file '%s' " 4537e5b75505Sopenharmony_ci "for reading.", fname); 4538e5b75505Sopenharmony_ci return NULL; 4539e5b75505Sopenharmony_ci } 4540e5b75505Sopenharmony_ci 4541e5b75505Sopenharmony_ci conf = hostapd_config_defaults(); 4542e5b75505Sopenharmony_ci if (conf == NULL) { 4543e5b75505Sopenharmony_ci fclose(f); 4544e5b75505Sopenharmony_ci return NULL; 4545e5b75505Sopenharmony_ci } 4546e5b75505Sopenharmony_ci 4547e5b75505Sopenharmony_ci /* set default driver based on configuration */ 4548e5b75505Sopenharmony_ci conf->driver = wpa_drivers[0]; 4549e5b75505Sopenharmony_ci if (conf->driver == NULL) { 4550e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "No driver wrappers registered!"); 4551e5b75505Sopenharmony_ci hostapd_config_free(conf); 4552e5b75505Sopenharmony_ci fclose(f); 4553e5b75505Sopenharmony_ci return NULL; 4554e5b75505Sopenharmony_ci } 4555e5b75505Sopenharmony_ci 4556e5b75505Sopenharmony_ci conf->last_bss = conf->bss[0]; 4557e5b75505Sopenharmony_ci 4558e5b75505Sopenharmony_ci while (fgets(buf, sizeof(buf), f)) { 4559e5b75505Sopenharmony_ci struct hostapd_bss_config *bss; 4560e5b75505Sopenharmony_ci 4561e5b75505Sopenharmony_ci bss = conf->last_bss; 4562e5b75505Sopenharmony_ci line++; 4563e5b75505Sopenharmony_ci 4564e5b75505Sopenharmony_ci if (buf[0] == '#') 4565e5b75505Sopenharmony_ci continue; 4566e5b75505Sopenharmony_ci pos = buf; 4567e5b75505Sopenharmony_ci while (*pos != '\0') { 4568e5b75505Sopenharmony_ci if (*pos == '\n') { 4569e5b75505Sopenharmony_ci *pos = '\0'; 4570e5b75505Sopenharmony_ci break; 4571e5b75505Sopenharmony_ci } 4572e5b75505Sopenharmony_ci pos++; 4573e5b75505Sopenharmony_ci } 4574e5b75505Sopenharmony_ci if (buf[0] == '\0') 4575e5b75505Sopenharmony_ci continue; 4576e5b75505Sopenharmony_ci 4577e5b75505Sopenharmony_ci pos = os_strchr(buf, '='); 4578e5b75505Sopenharmony_ci if (pos == NULL) { 4579e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'", 4580e5b75505Sopenharmony_ci line, buf); 4581e5b75505Sopenharmony_ci errors++; 4582e5b75505Sopenharmony_ci continue; 4583e5b75505Sopenharmony_ci } 4584e5b75505Sopenharmony_ci *pos = '\0'; 4585e5b75505Sopenharmony_ci pos++; 4586e5b75505Sopenharmony_ci errors += hostapd_config_fill(conf, bss, buf, pos, line); 4587e5b75505Sopenharmony_ci } 4588e5b75505Sopenharmony_ci 4589e5b75505Sopenharmony_ci fclose(f); 4590e5b75505Sopenharmony_ci 4591e5b75505Sopenharmony_ci for (i = 0; i < conf->num_bss; i++) 4592e5b75505Sopenharmony_ci hostapd_set_security_params(conf->bss[i], 1); 4593e5b75505Sopenharmony_ci 4594e5b75505Sopenharmony_ci if (hostapd_config_check(conf, 1)) 4595e5b75505Sopenharmony_ci errors++; 4596e5b75505Sopenharmony_ci 4597e5b75505Sopenharmony_ci#ifndef WPA_IGNORE_CONFIG_ERRORS 4598e5b75505Sopenharmony_ci if (errors) { 4599e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "%d errors found in configuration file " 4600e5b75505Sopenharmony_ci "'%s'", errors, fname); 4601e5b75505Sopenharmony_ci hostapd_config_free(conf); 4602e5b75505Sopenharmony_ci conf = NULL; 4603e5b75505Sopenharmony_ci } 4604e5b75505Sopenharmony_ci#endif /* WPA_IGNORE_CONFIG_ERRORS */ 4605e5b75505Sopenharmony_ci 4606e5b75505Sopenharmony_ci return conf; 4607e5b75505Sopenharmony_ci} 4608e5b75505Sopenharmony_ci 4609e5b75505Sopenharmony_ci 4610e5b75505Sopenharmony_ciint hostapd_set_iface(struct hostapd_config *conf, 4611e5b75505Sopenharmony_ci struct hostapd_bss_config *bss, const char *field, 4612e5b75505Sopenharmony_ci char *value) 4613e5b75505Sopenharmony_ci{ 4614e5b75505Sopenharmony_ci int errors; 4615e5b75505Sopenharmony_ci size_t i; 4616e5b75505Sopenharmony_ci 4617e5b75505Sopenharmony_ci errors = hostapd_config_fill(conf, bss, field, value, 0); 4618e5b75505Sopenharmony_ci if (errors) { 4619e5b75505Sopenharmony_ci wpa_printf(MSG_INFO, "Failed to set configuration field '%s' " 4620e5b75505Sopenharmony_ci "to value '%s'", field, value); 4621e5b75505Sopenharmony_ci return -1; 4622e5b75505Sopenharmony_ci } 4623e5b75505Sopenharmony_ci 4624e5b75505Sopenharmony_ci for (i = 0; i < conf->num_bss; i++) 4625e5b75505Sopenharmony_ci hostapd_set_security_params(conf->bss[i], 0); 4626e5b75505Sopenharmony_ci 4627e5b75505Sopenharmony_ci if (hostapd_config_check(conf, 0)) { 4628e5b75505Sopenharmony_ci wpa_printf(MSG_ERROR, "Configuration check failed"); 4629e5b75505Sopenharmony_ci return -1; 4630e5b75505Sopenharmony_ci } 4631e5b75505Sopenharmony_ci 4632e5b75505Sopenharmony_ci return 0; 4633e5b75505Sopenharmony_ci} 4634