]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Append P2P Device Address to AP-STA-CONNECTED event
authorJithu Jance <jithu@broadcom.com>
Mon, 24 Oct 2011 21:13:03 +0000 (00:13 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 24 Oct 2011 21:13:03 +0000 (00:13 +0300)
For P2P, the p2p_connect takes in device address argument to make a
connection. However the connected event AP-STA-CONNECTED comes with
interface address. The application listening on events would find it
difficult to map interface address to the p2p device address which is
provided for connection.

Append P2P Device Address to AP-STA-CONNECTED event for P2P Client
connection. This will help applications to easily map the P2P Interface
Address to P2P Device Address on CONNECTED event. For non-P2P case, it
will just print the usual STA MAC address alone.

Signed-off-by: Jithu Jance <jithu@broadcom.com>
src/ap/ieee802_1x.c
src/p2p/p2p.h
src/p2p/p2p_group.c

index 63598e9212c517804ae1afb3f33bb62b5e4e4dea..f6e9f0866420d5b8787f1c1339088f15f96549dd 100644 (file)
@@ -27,6 +27,7 @@
 #include "eap_common/eap_wsc_common.h"
 #include "eapol_auth/eapol_auth_sm.h"
 #include "eapol_auth/eapol_auth_sm_i.h"
+#include "p2p/p2p.h"
 #include "hostapd.h"
 #include "accounting.h"
 #include "sta_info.h"
@@ -89,9 +90,23 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
                return;
 
        if (authorized) {
-               if (!ap_sta_is_authorized(sta))
-                       wpa_msg(hapd->msg_ctx, MSG_INFO,
-                               AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
+               if (!ap_sta_is_authorized(sta)) {
+                       const u8 *dev_addr = NULL;
+#ifdef CONFIG_P2P
+                       dev_addr = p2p_group_get_dev_addr(hapd->p2p_group,
+                                                         sta->addr);
+#endif /* CONFIG_P2P */
+
+                       if (dev_addr)
+                               wpa_msg(hapd->msg_ctx, MSG_INFO,
+                                       AP_STA_CONNECTED MACSTR
+                                       " dev_addr=" MACSTR,
+                                       MAC2STR(sta->addr), MAC2STR(dev_addr));
+                       else
+                               wpa_msg(hapd->msg_ctx, MSG_INFO,
+                                       AP_STA_CONNECTED MACSTR,
+                                       MAC2STR(sta->addr));
+               }
                ap_sta_set_authorized(hapd, sta, 1);
                res = hostapd_set_authorized(hapd, sta, 1);
                hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
index 3d97136f9c6ba83d24743760afcb4ea743f1e9e1..aa7889b060dec8d22ec53a7f46c99fde453584ae 100644 (file)
@@ -1487,6 +1487,15 @@ unsigned int p2p_get_group_num_members(struct p2p_group *group);
  */
 const u8 * p2p_iterate_group_members(struct p2p_group *group, void **next);
 
+/**
+ * p2p_group_get_dev_addr - Get a P2P Device Address of a client in a group
+ * @group: P2P group context from p2p_group_init()
+ * @addr: P2P Interface Address of the client
+ * Returns: P2P Device Address of the client if found or %NULL if no match
+ * found
+ */
+const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
+
 /**
  * p2p_get_peer_found - Get P2P peer info structure of a found peer
  * @p2p: P2P module context from p2p_init()
index e0f0c5604bc0dbf5696017c69257c06aca878c72..58b24c5b039e32c32d7733f7eff77bf27157019c 100644 (file)
@@ -546,6 +546,19 @@ static struct p2p_group_member * p2p_group_get_client_iface(
 }
 
 
+const u8 * p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr)
+{
+       struct p2p_group_member *m;
+
+       if (group == NULL)
+               return NULL;
+       m = p2p_group_get_client_iface(group, addr);
+       if (m && !is_zero_ether_addr(m->dev_addr))
+               return m->dev_addr;
+       return NULL;
+}
+
+
 static struct wpabuf * p2p_build_go_disc_req(void)
 {
        struct wpabuf *buf;