P2P: Add test command for filtering which peers are discovered
"wpa_cli p2p_set peer_filter <MAC address>" can now be used to only allow a single P2P Device (based on P2P Device Address) to be discovered for testing. Setting the address to 00:00:00:00:00:00 disables the filter.
This commit is contained in:
parent
6e6963ea86
commit
80c9582a5f
4 changed files with 32 additions and 0 deletions
|
@ -448,6 +448,14 @@ static int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_zero_ether_addr(p2p->peer_filter) &&
|
||||||
|
os_memcmp(p2p_dev_addr, p2p->peer_filter, ETH_ALEN) != 0) {
|
||||||
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Do not add peer "
|
||||||
|
"filter for " MACSTR " due to peer filter",
|
||||||
|
MAC2STR(p2p_dev_addr));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
dev = p2p_create_device(p2p, p2p_dev_addr);
|
dev = p2p_create_device(p2p, p2p_dev_addr);
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
p2p_parse_free(&msg);
|
p2p_parse_free(&msg);
|
||||||
|
@ -2912,3 +2920,15 @@ int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
|
||||||
os_memcpy(iface_addr, dev->interface_addr, ETH_ALEN);
|
os_memcpy(iface_addr, dev->interface_addr, ETH_ALEN);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr)
|
||||||
|
{
|
||||||
|
os_memcpy(p2p->peer_filter, addr, ETH_ALEN);
|
||||||
|
if (is_zero_ether_addr(p2p->peer_filter))
|
||||||
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Disable peer "
|
||||||
|
"filter");
|
||||||
|
else
|
||||||
|
wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Enable peer "
|
||||||
|
"filter for " MACSTR, MAC2STR(p2p->peer_filter));
|
||||||
|
}
|
||||||
|
|
|
@ -1213,4 +1213,6 @@ int p2p_set_ssid_postfix(struct p2p_data *p2p, const u8 *postfix, size_t len);
|
||||||
int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
|
int p2p_get_interface_addr(struct p2p_data *p2p, const u8 *dev_addr,
|
||||||
u8 *iface_addr);
|
u8 *iface_addr);
|
||||||
|
|
||||||
|
void p2p_set_peer_filter(struct p2p_data *p2p, const u8 *addr);
|
||||||
|
|
||||||
#endif /* P2P_H */
|
#endif /* P2P_H */
|
||||||
|
|
|
@ -362,6 +362,8 @@ struct p2p_data {
|
||||||
unsigned int ext_listen_interval;
|
unsigned int ext_listen_interval;
|
||||||
unsigned int ext_listen_interval_sec;
|
unsigned int ext_listen_interval_sec;
|
||||||
unsigned int ext_listen_interval_usec;
|
unsigned int ext_listen_interval_usec;
|
||||||
|
|
||||||
|
u8 peer_filter[ETH_ALEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2462,6 +2462,14 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (os_strcmp(cmd, "peer_filter") == 0) {
|
||||||
|
u8 addr[ETH_ALEN];
|
||||||
|
if (hwaddr_aton(param, addr))
|
||||||
|
return -1;
|
||||||
|
p2p_set_peer_filter(wpa_s->global->p2p, addr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown P2P_SET field value '%s'",
|
wpa_printf(MSG_DEBUG, "CTRL_IFACE: Unknown P2P_SET field value '%s'",
|
||||||
cmd);
|
cmd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue