[PATCH 2/3] Send received EAPOL ip addr received in PeerJoined.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Description: This patch sends EAPOL ip addr in PeerJoined event.
It is similar to ip_addr sent in AP_STA_CONNECTED event over CTRL_IFACE.

Signed-off-by: Nishant Chaprana <n.chaprana@xxxxxxxxxxx>
---
 src/ap/hostapd.h               |  3 ++-
 src/ap/sta_info.c              | 11 ++++++-----
 wpa_supplicant/ap.c            |  5 +++--
 wpa_supplicant/dbus/dbus_new.c | 13 +++++++++----
 wpa_supplicant/dbus/dbus_new.h |  2 +-
 wpa_supplicant/notify.c        |  9 +++++----
 wpa_supplicant/notify.h        |  2 +-
 7 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index fd5aaed..d3cf650 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -222,7 +222,8 @@ struct hostapd_data {
 	void *wps_event_cb_ctx;
 
 	void (*sta_authorized_cb)(void *ctx, const u8 *mac_addr,
-				  int authorized, const u8 *p2p_dev_addr);
+				  int authorized, const u8 *p2p_dev_addr,
+				  const u8 *ip);
 	void *sta_authorized_cb_ctx;
 
 	void (*setup_complete_cb)(void *ctx);
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index f12d408..4095768 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -1124,8 +1124,8 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
 	char buf[100];
 #ifdef CONFIG_P2P
 	u8 addr[ETH_ALEN];
-	u8 ip_addr_buf[4];
 #endif /* CONFIG_P2P */
+	u8 ip_addr_buf[4] = {0, };
 
 	if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED))
 		return;
@@ -1150,10 +1150,6 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
 #endif /* CONFIG_P2P */
 		os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
 
-	if (hapd->sta_authorized_cb)
-		hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
-					sta->addr, authorized, dev_addr);
-
 	if (authorized) {
 		char ip_addr[100];
 		ip_addr[0] = '\0';
@@ -1183,6 +1179,11 @@ void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
 					  AP_STA_DISCONNECTED "%s", buf);
 	}
 
+	if (hapd->sta_authorized_cb)
+		hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
+					sta->addr, authorized, dev_addr,
+					ip_addr_buf);
+
 #ifdef CONFIG_FST
 	if (hapd->iface->fst) {
 		if (authorized)
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 5afb772..600903f 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -521,9 +521,10 @@ static void ap_wps_event_cb(void *ctx, enum wps_event event,
 
 
 static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr,
-				 int authorized, const u8 *p2p_dev_addr)
+				 int authorized, const u8 *p2p_dev_addr,
+				 const u8 *ip)
 {
-	wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr);
+	wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr, ip);
 }
 
 
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 27b3012..95f4980 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -1482,11 +1482,11 @@ void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
  * @peer_addr: P2P Device Address of the peer joining the group
  */
 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
-				      const u8 *peer_addr)
+				      const u8 *peer_addr, const u8 *ip)
 {
 	struct wpas_dbus_priv *iface;
 	DBusMessage *msg;
-	DBusMessageIter iter;
+	DBusMessageIter iter, dict_iter;
 	char peer_obj_path[WPAS_DBUS_OBJECT_PATH_MAX], *path;
 	struct wpa_supplicant *parent;
 
@@ -1518,8 +1518,12 @@ void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
 
 	dbus_message_iter_init_append(msg, &iter);
 	path = peer_obj_path;
-	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
-					    &path)) {
+	if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &path)
+	    || (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
+		(ip && !wpa_dbus_dict_append_byte_array(&dict_iter, "IpAddr",
+							(const char *) ip, 4)) ||
+		!wpa_dbus_dict_close_write(&iter, &dict_iter))
+	   ) {
 		wpa_printf(MSG_ERROR, "dbus: Failed to construct signal");
 	} else {
 		dbus_connection_send(iface->con, msg, NULL);
@@ -4106,6 +4110,7 @@ static const struct wpa_dbus_signal_desc wpas_dbus_p2p_group_signals[] = {
 	{ "PeerJoined", WPAS_DBUS_NEW_IFACE_P2P_GROUP,
 	  {
 		  { "peer", "o", ARG_OUT },
+		  { "ip_address", "a{sv}", ARG_OUT },
 		  END_ARGS
 	  }
 	},
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index d64fcee..c2eea13 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -215,7 +215,7 @@ void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
 				      const u8 *sa, u16 update_indic,
 				      const u8 *tlvs, size_t tlvs_len);
 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
-				const u8 *member);
+				      const u8 *member, const u8 *ip);
 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
 				     struct wps_event_fail *fail);
 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 67e36ae..435c0a1 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -707,7 +707,8 @@ void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
 
 static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
 					  const u8 *sta,
-					  const u8 *p2p_dev_addr)
+					  const u8 *p2p_dev_addr,
+					  const u8 *ip)
 {
 #ifdef CONFIG_P2P
 	wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
@@ -717,7 +718,7 @@ static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
 	 * check P2P itself.
 	 */
 	if (p2p_dev_addr)
-		wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
+		wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr, ip);
 #endif /* CONFIG_P2P */
 
 	/* Notify listeners a new station has been authorized */
@@ -745,10 +746,10 @@ static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
 
 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
 				const u8 *mac_addr, int authorized,
-				const u8 *p2p_dev_addr)
+				const u8 *p2p_dev_addr, const u8 *ip)
 {
 	if (authorized)
-		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
+		wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr, ip);
 	else
 		wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
 }
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 8cce0f3..59aa126 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -85,7 +85,7 @@ void wpas_notify_resume(struct wpa_global *global);
 
 void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
 				const u8 *mac_addr, int authorized,
-				const u8 *p2p_dev_addr);
+				const u8 *p2p_dev_addr, const u8 *ip);
 void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s);
 void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
 				  const u8 *dev_addr, int new_device);
-- 
1.9.1


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux