char *value;
int res;
- if (ssid->mac_addr != 3)
+ if (ssid->mac_addr != WPAS_MAC_ADDR_STYLE_DEDICATED_PER_ESS)
return NULL;
value = os_malloc(size);
#ifdef CONFIG_MACSEC
ssid->mka_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
#endif /* CONFIG_MACSEC */
- ssid->mac_addr = -1;
+ ssid->mac_addr = WPAS_MAC_ADDR_STYLE_NOT_SET;
ssid->max_oper_chwidth = DEFAULT_MAX_OPER_CHWIDTH;
}
{ STR(osu_dir), 0 },
{ STR(wowlan_triggers), CFG_CHANGED_WOWLAN_TRIGGERS },
{ INT(p2p_search_delay), 0},
- { INT(mac_addr), 0 },
+ { INT_RANGE(mac_addr, 0, 2), 0 },
{ INT(rand_addr_lifetime), 0 },
- { INT(preassoc_mac_addr), 0 },
+ { INT_RANGE(preassoc_mac_addr, 0, 2), 0 },
{ INT(key_mgmt_offload), 0},
{ INT(passive_scan), 0 },
{ INT(reassoc_same_bss_optim), 0 },
* the per-network mac_addr parameter. Global mac_addr=1 can be used to
* change this default behavior.
*/
- int mac_addr;
+ enum wpas_mac_addr_style mac_addr;
/**
* rand_addr_lifetime - Lifetime of random MAC address in seconds
* 1 = use random MAC address
* 2 = like 1, but maintain OUI (with local admin bit set)
*/
- int preassoc_mac_addr;
+ enum wpas_mac_addr_style preassoc_mac_addr;
/**
* key_mgmt_offload - Use key management offload
* 1 = use random MAC address
* 2 = like 1, but maintain OUI (with local admin bit set)
*/
- int gas_rand_mac_addr;
+ enum wpas_mac_addr_style gas_rand_mac_addr;
/**
* dpp_config_processing - How to process DPP configuration
SAE_PK_MODE_DISABLED = 2,
};
+enum wpas_mac_addr_style {
+ WPAS_MAC_ADDR_STYLE_NOT_SET = -1,
+ WPAS_MAC_ADDR_STYLE_PERMANENT = 0,
+ WPAS_MAC_ADDR_STYLE_RANDOM = 1,
+ WPAS_MAC_ADDR_STYLE_RANDOM_SAME_OUI = 2,
+ WPAS_MAC_ADDR_STYLE_DEDICATED_PER_ESS = 3,
+};
+
/**
* struct wpa_ssid - Network configuration data
*
* was not specified in the configuration (i.e., default behavior is
* followed).
*/
- int mac_addr;
+ enum wpas_mac_addr_style mac_addr;
/**
* mac_value - Specific MAC address to be used
}
-int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style,
+int wpas_update_random_addr(struct wpa_supplicant *wpa_s,
+ enum wpas_mac_addr_style style,
struct wpa_ssid *ssid)
{
struct os_reltime now;
/* Random addresses are valid within a given ESS so check
* expiration/value only when continuing to use the same ESS. */
if (wpa_s->last_mac_addr_style == style && wpa_s->reassoc_same_ess) {
- if (style == 3) {
+ if (style == WPAS_MAC_ADDR_STYLE_DEDICATED_PER_ESS) {
/* Pregenerated addresses do not expire but their value
* might have changed, so let's check that. */
if (os_memcmp(wpa_s->own_addr, ssid->mac_value,
}
switch (style) {
- case 1:
+ case WPAS_MAC_ADDR_STYLE_RANDOM:
if (random_mac_addr(addr) < 0)
return -1;
break;
- case 2:
+ case WPAS_MAC_ADDR_STYLE_RANDOM_SAME_OUI:
os_memcpy(addr, wpa_s->perm_addr, ETH_ALEN);
if (random_mac_addr_keep_oui(addr) < 0)
return -1;
break;
- case 3:
+ case WPAS_MAC_ADDR_STYLE_DEDICATED_PER_ESS:
if (!ssid) {
wpa_msg(wpa_s, MSG_INFO,
"Invalid 'ssid' for address policy 3");
struct wpa_bss *bss, struct wpa_ssid *ssid)
{
struct wpa_connect_work *cwork;
- int rand_style;
+ enum wpas_mac_addr_style rand_style;
wpa_s->own_disconnect_req = 0;
wpa_s->own_reconnect_req = 0;
wpabuf_free(wpa_s->pending_eapol_rx);
wpa_s->pending_eapol_rx = NULL;
- if (ssid->mac_addr == -1)
+ if (ssid->mac_addr == WPAS_MAC_ADDR_STYLE_NOT_SET)
rand_style = wpa_s->conf->mac_addr;
else
rand_style = ssid->mac_addr;
wpa_s_setup_sae_pt(wpa_s->conf, ssid);
#endif /* CONFIG_SAE */
- if (rand_style > 0) {
+ if (rand_style > WPAS_MAC_ADDR_STYLE_PERMANENT) {
int status = wpas_update_random_addr(wpa_s, rand_style, ssid);
if (status < 0)
return;
if (status > 0) /* MAC changed */
wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
- } else if (rand_style == 0 && wpa_s->mac_addr_changed) {
+ } else if (rand_style == WPAS_MAC_ADDR_STYLE_PERMANENT &&
+ wpa_s->mac_addr_changed) {
if (wpas_restore_permanent_mac_addr(wpa_s) < 0)
return;
}
unsigned int disable_mbo_oce:1;
struct os_reltime last_mac_addr_change;
- int last_mac_addr_style;
+ enum wpas_mac_addr_style last_mac_addr_style;
struct ibss_rsn *ibss_rsn;