mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 10:18:21 -05:00
P2P: support random interface address
To enhance privacy, generate a random interface for each group. There are two configurations are introduced: * p2p_interface_random_mac_addr enable interface random MAC address feature, default disable. Signed-off-by: Jimmy Chen <jimmycmchen@google.com>
This commit is contained in:
parent
9359cc8483
commit
a95906f938
@ -4787,6 +4787,7 @@ static const struct global_parse_data global_fields[] = {
|
||||
{ INT_RANGE(p2p_cli_probe, 0, 1), 0 },
|
||||
{ INT(p2p_device_random_mac_addr), 0 },
|
||||
{ FUNC(p2p_device_persistent_mac_addr), 0 },
|
||||
{ INT(p2p_interface_random_mac_addr), 0 },
|
||||
#endif /* CONFIG_P2P */
|
||||
{ FUNC(country), CFG_CHANGED_COUNTRY },
|
||||
{ INT(bss_max_count), 0 },
|
||||
|
@ -1507,6 +1507,16 @@ struct wpa_config {
|
||||
* random MAC address, and need to restore to last used MAC address.
|
||||
*/
|
||||
u8 p2p_device_persistent_mac_addr[ETH_ALEN];
|
||||
|
||||
/**
|
||||
* p2p_interface_random_mac_addr - P2P Interface MAC address policy default
|
||||
*
|
||||
* 0 = use permanent MAC address
|
||||
* 1 = use random MAC address on creating the interface.
|
||||
*
|
||||
* By default, permanent MAC address is used.
|
||||
*/
|
||||
int p2p_interface_random_mac_addr;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1535,6 +1535,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
|
||||
if (!is_zero_ether_addr(config->p2p_device_persistent_mac_addr))
|
||||
fprintf(f, "p2p_device_persistent_mac_addr=" MACSTR "\n",
|
||||
MAC2STR(config->p2p_device_persistent_mac_addr));
|
||||
if (config->p2p_interface_random_mac_addr)
|
||||
fprintf(f, "p2p_interface_random_mac_addr=%d\n",
|
||||
config->p2p_interface_random_mac_addr);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NO_CONFIG_WRITE */
|
||||
|
@ -2076,6 +2076,13 @@ static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (wpa_s->conf->p2p_interface_random_mac_addr) {
|
||||
random_mac_addr(wpa_s->pending_interface_addr);
|
||||
wpa_printf(MSG_DEBUG, "P2P: Generate random MAC address " MACSTR
|
||||
" for the group",
|
||||
MAC2STR(wpa_s->pending_interface_addr));
|
||||
}
|
||||
|
||||
if (force_ifname[0]) {
|
||||
wpa_printf(MSG_DEBUG, "P2P: Driver forced interface name %s",
|
||||
force_ifname);
|
||||
@ -2154,6 +2161,29 @@ wpas_p2p_init_group_interface(struct wpa_supplicant *wpa_s, int go)
|
||||
|
||||
wpas_p2p_clone_config(group_wpa_s, wpa_s);
|
||||
|
||||
if (wpa_s->conf->p2p_interface_random_mac_addr) {
|
||||
if (wpa_drv_set_mac_addr(group_wpa_s,
|
||||
wpa_s->pending_interface_addr) < 0) {
|
||||
wpa_msg(group_wpa_s, MSG_INFO,
|
||||
"Failed to set random MAC address");
|
||||
wpa_supplicant_remove_iface(wpa_s->global, group_wpa_s,
|
||||
0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (wpa_supplicant_update_mac_addr(group_wpa_s) < 0) {
|
||||
wpa_msg(group_wpa_s, MSG_INFO,
|
||||
"Could not update MAC address information");
|
||||
wpa_supplicant_remove_iface(wpa_s->global, group_wpa_s,
|
||||
0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wpa_printf(MSG_DEBUG, "P2P: Using random MAC address " MACSTR
|
||||
" for the group",
|
||||
MAC2STR(wpa_s->pending_interface_addr));
|
||||
}
|
||||
|
||||
return group_wpa_s;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user