aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Chen <jimmycmchen@google.com>2018-11-29 08:46:43 (GMT)
committerJouni Malinen <j@w1.fi>2019-01-12 15:58:30 (GMT)
commita95906f9381ee8aa4ccb66e1c99952658d8e3369 (patch)
tree92e523e361885382de8bb6d3832fbbc39334708c
parent9359cc8483eb84fbbb0a75cf64dcffd213fb412e (diff)
downloadhostap-a95906f9381ee8aa4ccb66e1c99952658d8e3369.zip
hostap-a95906f9381ee8aa4ccb66e1c99952658d8e3369.tar.gz
hostap-a95906f9381ee8aa4ccb66e1c99952658d8e3369.tar.bz2
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>
-rw-r--r--wpa_supplicant/config.c1
-rw-r--r--wpa_supplicant/config.h10
-rw-r--r--wpa_supplicant/config_file.c3
-rw-r--r--wpa_supplicant/p2p_supplicant.c30
4 files changed, 44 insertions, 0 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index d4570d6..b4e9952 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -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 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 0d02827..15d8c48 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -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;
};
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 57d8afc..85a3937 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -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 */
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 6df4f76..848299d 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -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;
}