@@ -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_addr);
void *sta_authorized_cb_ctx;
void (*setup_complete_cb)(void *ctx);
@@ -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, 0, 0, 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)
@@ -5018,6 +5018,25 @@ p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next)
}
+void p2p_set_peer_ip_addr(struct p2p_data *p2p, const u8 *dev_addr,
+ const u8 *ip_addr)
+{
+ struct p2p_device *dev;
+
+ if (!p2p || !dev_addr)
+ return;
+
+ dev = p2p_get_device(p2p, dev_addr);
+ if (!dev)
+ return;
+
+ if (ip_addr)
+ os_memcpy(dev->info.ip_addr, ip_addr, 4);
+ else
+ os_memset(dev->info.ip_addr, 0, 4);
+}
+
+
int p2p_in_progress(struct p2p_data *p2p)
{
if (p2p == NULL)
@@ -402,6 +402,11 @@ struct p2p_peer_info {
* p2ps_instance - P2PS Application Service Info
*/
struct wpabuf *p2ps_instance;
+
+ /**
+ * ip_addr - IP address assigned during 4-way handshake
+ */
+ u8 ip_addr[4];
};
enum p2p_prov_disc_status {
@@ -2191,6 +2196,15 @@ const struct p2p_peer_info *
p2p_get_peer_found(struct p2p_data *p2p, const u8 *addr, int next);
/**
+ * p2p_set_peer_ip_addr - Set P2P peer IP address in info structure
+ * @p2p: P2P module context from p2p_init()
+ * @dev_addr: P2P Device Address of the peer
+ * @ip_addr: IP address of the peer
+ */
+void p2p_set_peer_ip_addr(struct p2p_data *p2p, const u8 *dev_addr,
+ const u8 *ip_addr);
+
+/**
* p2p_remove_wps_vendor_extensions - Remove WPS vendor extensions
* @p2p: P2P module context from p2p_init()
*/
@@ -521,9 +521,11 @@ 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_addr)
{
- wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr);
+ wpas_notify_sta_authorized(ctx, mac_addr, authorized, p2p_dev_addr,
+ ip_addr);
}
@@ -3800,6 +3800,11 @@ static const struct wpa_dbus_property_desc wpas_dbus_p2p_peer_properties[] = {
NULL,
NULL
},
+ { "IpAddress", WPAS_DBUS_NEW_IFACE_P2P_PEER, "ay",
+ wpas_dbus_getter_p2p_peer_ip_address,
+ NULL,
+ NULL
+ },
{ NULL, NULL, NULL, NULL, NULL, NULL }
};
@@ -1903,6 +1903,26 @@ out:
}
+dbus_bool_t wpas_dbus_getter_p2p_peer_ip_address(
+ const struct wpa_dbus_property_desc *property_desc,
+ DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+ struct peer_handler_args *peer_args = user_data;
+ const struct p2p_peer_info *info;
+
+ info = p2p_get_peer_found(peer_args->wpa_s->global->p2p,
+ peer_args->p2p_device_addr, 0);
+ if (!info) {
+ dbus_set_error(error, DBUS_ERROR_FAILED,
+ "failed to find peer");
+ return FALSE;
+ }
+
+ return wpas_dbus_simple_array_property_getter(
+ iter, DBUS_TYPE_BYTE, (char *) info->ip_addr, 4, error);
+}
+
+
/**
* wpas_dbus_getter_persistent_groups - Get array of persistent group objects
* @iter: Pointer to incoming dbus message iter
@@ -114,6 +114,7 @@ DECLARE_ACCESSOR(wpas_dbus_getter_p2p_peer_vendor_extension);
DECLARE_ACCESSOR(wpas_dbus_getter_p2p_peer_ies);
DECLARE_ACCESSOR(wpas_dbus_getter_p2p_peer_device_address);
DECLARE_ACCESSOR(wpas_dbus_getter_p2p_peer_groups);
+DECLARE_ACCESSOR(wpas_dbus_getter_p2p_peer_ip_address);
/*
* P2P Group properties
@@ -707,10 +707,11 @@ 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_addr)
{
#ifdef CONFIG_P2P
- wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
+ wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr, ip_addr);
/*
* Create 'peer-joined' signal on group object -- will also
@@ -734,8 +735,10 @@ static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
* Create 'peer-disconnected' signal on group object if this
* is a P2P group.
*/
- if (p2p_dev_addr)
+ if (p2p_dev_addr) {
+ p2p_set_peer_ip_addr(wpa_s->global->p2p, p2p_dev_addr, NULL);
wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
+ }
#endif /* CONFIG_P2P */
/* Notify listeners a station has been deauthorized */
@@ -745,10 +748,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_addr)
{
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_addr);
else
wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
}
@@ -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_addr);
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);
@@ -7761,8 +7761,11 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
- const u8 *addr)
+ const u8 *addr, const u8 *ip_addr)
{
+ if (ip_addr)
+ p2p_set_peer_ip_addr(wpa_s->global->p2p, addr, ip_addr);
+
if (eloop_cancel_timeout(wpas_p2p_group_formation_timeout,
wpa_s->p2pdev, NULL) > 0) {
/*
@@ -140,7 +140,7 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
const u8 *addr, const u8 *ssid,
size_t ssid_len);
void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
- const u8 *addr);
+ const u8 *addr, const u8 *ip_addr);
int wpas_p2p_scan_no_go_seen(struct wpa_supplicant *wpa_s);
int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s,
struct hostapd_hw_modes *mode, u8 channel);