P2P: Replace p2p_get_peer_info with p2p_peer_known when applicable
p2p_get_peer_info() was used in multiple places just to check whether a specific peer is known. This was not the designed use for the function, so introduce a simpler function for that purpose to make it obvious that the p2p_get_peer_info() function is actually used only in ctrl_iface.c. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
a601f71bc7
commit
b3bcc0f519
4 changed files with 21 additions and 8 deletions
|
@ -3216,6 +3216,12 @@ int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
|||
}
|
||||
|
||||
|
||||
int p2p_peer_known(struct p2p_data *p2p, const u8 *addr)
|
||||
{
|
||||
return p2p_get_device(p2p, addr) != NULL;
|
||||
}
|
||||
|
||||
|
||||
void p2p_set_client_discoverability(struct p2p_data *p2p, int enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
|
|
|
@ -1427,6 +1427,14 @@ const u8 * p2p_get_go_dev_addr(const struct wpabuf *p2p_ie);
|
|||
int p2p_get_peer_info(struct p2p_data *p2p, const u8 *addr, int next,
|
||||
char *buf, size_t buflen);
|
||||
|
||||
/**
|
||||
* p2p_peer_known - Check whether P2P peer is known
|
||||
* @p2p: P2P module context from p2p_init()
|
||||
* @addr: P2P Device Address of the peer
|
||||
* Returns: 1 if the specified device is in the P2P peer table or 0 if not
|
||||
*/
|
||||
int p2p_peer_known(struct p2p_data *p2p, const u8 *addr);
|
||||
|
||||
/**
|
||||
* p2p_set_client_discoverability - Set client discoverability capability
|
||||
* @p2p: P2P module context from p2p_init()
|
||||
|
|
|
@ -867,7 +867,7 @@ void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (p2p_get_peer_info(wpa_s->global->p2p, dev_addr, 0, NULL, 0) < 0)
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, dev_addr))
|
||||
goto error;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
|
@ -1357,7 +1357,7 @@ void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (p2p_get_peer_info(wpa_s->global->p2p, sa, 0, NULL, 0) < 0)
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, sa))
|
||||
goto error;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
|
@ -1426,7 +1426,7 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
|
|||
return;
|
||||
|
||||
/* Check if this is a known peer */
|
||||
if (p2p_get_peer_info(wpa_s->global->p2p, sa, 0, NULL, 0) < 0)
|
||||
if (!p2p_peer_known(wpa_s->global->p2p, sa))
|
||||
goto error;
|
||||
|
||||
os_snprintf(peer_obj_path, WPAS_DBUS_OBJECT_PATH_MAX,
|
||||
|
|
|
@ -497,7 +497,7 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
|
|||
|
||||
if (!peer_object_path || (wps_method == WPS_NOT_READY) ||
|
||||
(parse_peer_object_path(peer_object_path, addr) < 0) ||
|
||||
(p2p_get_peer_info(wpa_s->global->p2p, addr, 0, NULL, 0) < 0))
|
||||
!p2p_peer_known(wpa_s->global->p2p, addr))
|
||||
goto inv_args;
|
||||
|
||||
/*
|
||||
|
@ -603,8 +603,7 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
|
|||
|
||||
if (!peer_object_path ||
|
||||
(parse_peer_object_path(peer_object_path, peer_addr) < 0) ||
|
||||
(p2p_get_peer_info(wpa_s->global->p2p,
|
||||
peer_addr, 0, NULL, 0) < 0)) {
|
||||
!p2p_peer_known(wpa_s->global->p2p, peer_addr)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -2013,7 +2012,7 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_req(
|
|||
|
||||
if (!peer_object_path ||
|
||||
(parse_peer_object_path(peer_object_path, addr) < 0) ||
|
||||
(p2p_get_peer_info(wpa_s->global->p2p, addr, 0, NULL, 0) < 0))
|
||||
!p2p_peer_known(wpa_s->global->p2p, addr))
|
||||
goto error;
|
||||
|
||||
if (upnp == 1) {
|
||||
|
@ -2094,7 +2093,7 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_res(
|
|||
}
|
||||
if (!peer_object_path ||
|
||||
(parse_peer_object_path(peer_object_path, addr) < 0) ||
|
||||
(p2p_get_peer_info(wpa_s->global->p2p, addr, 0, NULL, 0) < 0))
|
||||
!p2p_peer_known(wpa_s->global->p2p, addr))
|
||||
goto error;
|
||||
|
||||
if (tlv == NULL)
|
||||
|
|
Loading…
Reference in a new issue