]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Replace p2p_get_peer_info with p2p_peer_known when applicable
authorJouni Malinen <j@w1.fi>
Thu, 22 Dec 2011 19:04:41 +0000 (21:04 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 22 Dec 2011 19:04:41 +0000 (21:04 +0200)
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>

src/p2p/p2p.c
src/p2p/p2p.h
wpa_supplicant/dbus/dbus_new.c
wpa_supplicant/dbus/dbus_new_handlers_p2p.c

index 9fcc6ca39d538a653738022479d9590b3584c431..a9d5998b2077ce5d14f121d7a0c0f173b51d0457 100644 (file)
@@ -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) {
index 3db0ac581486398d2b90e00fdb586a6f3c8f634c..99934bdc745055c858c1bc013e6a8cb2f9454fa3 100644 (file)
@@ -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()
index f88d3546e4158e5ca57189152c10af623b8af720..2bf9be8a6401ea3092d863402239e8bcda404eb8 100644 (file)
@@ -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,
index de0caad6c7f697d003b6e03e579ecb89af4f0308..671d0e5ef9b06fb67c66f73eedc9de494c59efaf 100644 (file)
@@ -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)