[PATCH] Append P2P device address to AP-STA-CONNECTED event for P2P

Jithu Jance jithu
Fri Oct 21 21:41:36 PDT 2011



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.

This patch appends 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. 

Please see whether the patch is okay.


Signed-off-by: Jithu Jance <jithu at broadcom.com>

---
 src/ap/ieee802_1x.c |   16 +++++++++++++---
 src/p2p/p2p_group.c |   11 +++++++++++
 src/p2p/p2p_i.h     |    1 +
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index d163ce6..97587f4 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -36,6 +36,7 @@
 #include "ap_config.h"
 #include "ap_drv_ops.h"
 #include "ieee802_1x.h"
+#include "p2p/p2p_i.h"
 
 
 static void ieee802_1x_finished(struct hostapd_data *hapd,
@@ -84,14 +85,23 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
 				   struct sta_info *sta, int authorized)
 {
 	int res;
+	const u8 *dev_addr = NULL;
 
 	if (sta->flags & WLAN_STA_PREAUTH)
 		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)) {
+#if defined(CONFIG_P2P)
+			if((dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr)))
+				wpa_msg(hapd->msg_ctx, MSG_INFO,
+					AP_STA_CONNECTED MACSTR " dev_addr="MACSTR, MAC2STR(sta->addr), MAC2STR(dev_addr));
+			else
+#endif /* CONFIG_P2P */
+				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,
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index cc2542d..1735cb2 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -542,6 +542,17 @@ static struct p2p_group_member * p2p_group_get_client_iface(
 	return NULL;
 }
 
+const u8* p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr)
+{
+	struct p2p_group_member *m;
+
+	m = p2p_group_get_client_iface(group, addr);
+
+    if(m)
+		return m->dev_addr;
+	else
+		return NULL;
+}
 
 static struct wpabuf * p2p_build_go_disc_req(void)
 {
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 0e73136..3c13c3c 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -537,6 +537,7 @@ struct p2p_noa_desc {
 
 /* p2p_group.c */
 const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
+const u8* p2p_group_get_dev_addr(struct p2p_group *group, const u8 *addr);
 u8 p2p_group_presence_req(struct p2p_group *group,
 			  const u8 *client_interface_addr,
 			  const u8 *noa, size_t noa_len);
-- 
1.7.4.1



- Jithu Jance.



More information about the Hostap mailing list