]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Notify the IP address of the connected P2P Client
authorSunil Ravi <sunilravi@google.com>
Thu, 29 Feb 2024 01:36:40 +0000 (01:36 +0000)
committerJouni Malinen <j@w1.fi>
Fri, 1 Mar 2024 18:36:41 +0000 (20:36 +0200)
When wpa_supplicant assigns the IP address (WFA EAPOL IP address
allocation feature), the assigned IP address of the P2P Client on the GO
side is notified in the AP-STA-CONNECTED event. So to obtain the IP info
to external programs, modify the STA authorized event to include the the
assigned IP address of the P2P Client.

Test: Establish P2P connection and verified from the logs that
      the P2P Client IP address is notified.
Signed-off-by: Sunil Ravi <sunilravi@google.com>
src/ap/hostapd.h
src/ap/sta_info.c
wpa_supplicant/ap.c
wpa_supplicant/notify.c
wpa_supplicant/notify.h

index 3339554865e3ef875971106cd984ca4374b8242b..22540bb371c19583a4d809159b9d0b44512eb4ce 100644 (file)
@@ -293,7 +293,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);
index 9de5b0a1c65abeb0400f24a9deffa568defff957..dc5e3b4190349e677c797cb96ad2e7e62194b981 100644 (file)
@@ -1433,6 +1433,7 @@ void ap_sta_set_authorized_event(struct hostapd_data *hapd,
        u8 addr[ETH_ALEN];
        u8 ip_addr_buf[4];
 #endif /* CONFIG_P2P */
+       const u8 *ip_ptr = NULL;
 
 #ifdef CONFIG_P2P
        if (hapd->p2p_group == NULL) {
@@ -1449,10 +1450,6 @@ void ap_sta_set_authorized_event(struct hostapd_data *hapd,
 #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) {
                const u8 *dpp_pkhash;
                const char *keyid;
@@ -1469,6 +1466,7 @@ void ap_sta_set_authorized_event(struct hostapd_data *hapd,
                                    " ip_addr=%u.%u.%u.%u",
                                    ip_addr_buf[0], ip_addr_buf[1],
                                    ip_addr_buf[2], ip_addr_buf[3]);
+                       ip_ptr = ip_addr_buf;
                }
 #endif /* CONFIG_P2P */
 
@@ -1508,6 +1506,11 @@ void ap_sta_set_authorized_event(struct hostapd_data *hapd,
                                          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_ptr);
+
 #ifdef CONFIG_FST
        if (hapd->iface->fst) {
                if (authorized)
index ffe98fa8ddb1c994dd8a7c84ac277df7988650e5..11bf53900816d32d0bbfb00709b693ded7bd9dd1 100644 (file)
@@ -868,9 +868,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);
 }
 
 
index 745234dda530d4745b025cbd89e55b1d7d4e31f1..85150a01017b46d91ce837827d66db97b7e436d9 100644 (file)
@@ -776,7 +776,7 @@ 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);
@@ -820,10 +820,11 @@ 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);
 }
index 2a0cf097aa917a91d38ddfe3477c180f05f510d2..5c8057836c1c1950c28091e3bcf1615dd40846d9 100644 (file)
@@ -94,7 +94,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);