[PATCH 1/1] Add p2p_group_get_member_connection_info
장원준
wonjun2.jang at samsung.com
Mon Nov 3 16:06:55 PST 2025
>From 2bddf384abff11e54678d2a51f0f03ab602c8449 Mon Sep 17 00:00:00 2001
From: Wonjun Jang <wonjun2.jang at samsung.com>
Date: Tue, 4 Nov 2025 08:14:50 +0900
Subject: [PATCH 1/1] Add p2p_group_get_member_connection_info
Implement event handling for P2P group association to record IEEE standard, and bandwidth.
Add p2p_group_get_member_connection_info function to retrive connection capabilities of group clients.
Signed-off-by: Wonjun Jang <wonjun2.jang at samsung.com>
---
src/ap/drv_callbacks.c | 40 +++++++++++++++++++++++++-
src/ap/ieee802_11.c | 2 +-
src/p2p/p2p.h | 5 ++--
src/p2p/p2p_group.c | 65 ++++++++++++++++++++++++++++++++++++------
src/p2p/p2p_i.h | 10 +++++++
5 files changed, 110 insertions(+), 12 deletions(-)
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index 16a15076c..536e19f9e 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -997,7 +997,45 @@ skip_wpa_check:
#ifdef CONFIG_P2P
if (req_ies) {
- p2p_group_notif_assoc(hapd->p2p_group, sta->addr,
+ if (elems.ht_capabilities) {
+ if (!sta->ht_capabilities) {
+ sta->ht_capabilities = os_zalloc(sizeof(struct ieee80211_ht_capabilities));
+ if (!sta->ht_capabilities) {
+ wpa_printf(MSG_ERROR, "Failed to allocate memory for HT capabilities");
+ return 0;
+ }
+ }
+ os_memcpy(sta->ht_capabilities,
+ (const struct ieee80211_ht_capabilities *) elems.ht_capabilities,
+ sizeof(struct ieee80211_ht_capabilities));
+ }
+
+ if (elems.vht_capabilities) {
+ if (!sta->vht_capabilities) {
+ sta->vht_capabilities = os_zalloc(sizeof(struct ieee80211_vht_capabilities));
+ if (!sta->vht_capabilities) {
+ wpa_printf(MSG_ERROR, "Failed to allocate memory for VHT capabilities");
+ return 0;
+ }
+ }
+ os_memcpy(sta->vht_capabilities,
+ (const struct ieee80211_vht_capabilities *) elems.vht_capabilities,
+ sizeof(struct ieee80211_vht_capabilities));
+ }
+
+ if (elems.he_capabilities) {
+ if (!sta->he_capab) {
+ sta->he_capab = os_zalloc(sizeof(struct ieee80211_he_capabilities));
+ if (!sta->he_capab) {
+ wpa_printf(MSG_ERROR, "Failed to allocate memory for HE capabilities");
+ return 0;
+ }
+ }
+ os_memcpy(sta->he_capab,
+ (const struct ieee80211_he_capabilities *) elems.he_capabilities,
+ sizeof(struct ieee80211_he_capabilities));
+ }
+ p2p_group_notif_assoc(hapd->p2p_group, sta,
req_ies, req_ies_len);
}
#endif /* CONFIG_P2P */
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index dc3b397c5..811ecfdf4 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -4779,7 +4779,7 @@ skip_wpa_ies:
#ifdef CONFIG_P2P
if (ies && ies_len)
- p2p_group_notif_assoc(hapd->p2p_group, sta->addr, ies, ies_len);
+ p2p_group_notif_assoc(hapd->p2p_group, sta, ies, ies_len);
#endif /* CONFIG_P2P */
#ifdef CONFIG_HS20
diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h
index 933c76ec5..84ca41262 100644
--- a/src/p2p/p2p.h
+++ b/src/p2p/p2p.h
@@ -9,6 +9,7 @@
#ifndef P2P_H
#define P2P_H
+#include "ap/sta_info.h"
#include "common/ieee802_11_defs.h"
#include "wps/wps.h"
#include "common/wpa_common.h"
@@ -2123,12 +2124,12 @@ void p2p_group_deinit(struct p2p_group *group);
/**
* p2p_group_notif_assoc - Notification of P2P client association with GO
* @group: P2P group context from p2p_group_init()
- * @addr: Interface address of the P2P client
+ * @sta: Pointer to sta info from P2P client
* @ie: IEs from the (Re)association Request frame
* @len: Length of the ie buffer in octets
* Returns: 0 on success, -1 on failure
*/
-int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
+int p2p_group_notif_assoc(struct p2p_group *group, struct sta_info *sta,
const u8 *ie, size_t len);
/**
diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c
index 2659787f3..fb53562a8 100644
--- a/src/p2p/p2p_group.c
+++ b/src/p2p/p2p_group.c
@@ -26,6 +26,11 @@ struct p2p_group_member {
struct wpabuf *wfd_ie;
struct wpabuf *client_info;
u8 dev_capab;
+ unsigned int connection_ht:1;
+ unsigned int connection_vht:1;
+ unsigned int connection_he:1;
+ unsigned int connection_eht:1;
+ unsigned int connection_channel_bandwidth:5;
};
/**
@@ -637,7 +642,7 @@ static int p2p_group_remove_member(struct p2p_group *group, const u8 *addr)
}
-int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
+int p2p_group_notif_assoc(struct p2p_group *group, struct sta_info *sta,
const u8 *ie, size_t len)
{
struct p2p_group_member *m;
@@ -645,15 +650,35 @@ int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
if (group == NULL)
return -1;
- p2p_add_device(group->p2p, addr, 0, NULL, 0, ie, len, 0);
+ int ht = !!sta->ht_capabilities;
+ int vht = !!sta->vht_capabilities;
+ int he = !!sta->he_capab;
+ int bw = CHAN_WIDTH_20;
+
+ if (ht && (sta->ht_capabilities->ht_capabilities_info & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) {
+ bw = CHAN_WIDTH_40;
+ }
+#ifdef CONFIG_IEEE80211AC
+ if (vht) {
+ bw = CHAN_WIDTH_80;
+ }
+#endif
+
+#ifdef CONFIG_IEEE80211AX
+ if (he) {
+ bw = CHAN_WIDTH_80;
+ }
+#endif
+
+ p2p_add_device(group->p2p, sta->addr, 0, NULL, 0, ie, len, 0);
m = os_zalloc(sizeof(*m));
if (m == NULL)
return -1;
- os_memcpy(m->addr, addr, ETH_ALEN);
+ os_memcpy(m->addr, sta->addr, ETH_ALEN);
m->p2p_ie = ieee802_11_vendor_ie_concat(ie, len, P2P_IE_VENDOR_TYPE);
if (m->p2p_ie) {
- m->client_info = p2p_build_client_info(addr, m->p2p_ie,
+ m->client_info = p2p_build_client_info(sta->addr, m->p2p_ie,
&m->dev_capab,
m->dev_addr);
}
@@ -661,16 +686,21 @@ int p2p_group_notif_assoc(struct p2p_group *group, const u8 *addr,
m->wfd_ie = ieee802_11_vendor_ie_concat(ie, len, WFD_IE_VENDOR_TYPE);
#endif /* CONFIG_WIFI_DISPLAY */
- p2p_group_remove_member(group, addr);
+ p2p_group_remove_member(group, sta->addr);
+ m->connection_ht = ht;
+ m->connection_vht = vht;
+ m->connection_he = he;
+ m->connection_channel_bandwidth = bw;
m->next = group->members;
group->members = m;
group->num_members++;
p2p_dbg(group->p2p, "Add client " MACSTR
- " to group (p2p=%d wfd=%d client_info=%d); num_members=%u/%u",
- MAC2STR(addr), m->p2p_ie ? 1 : 0, m->wfd_ie ? 1 : 0,
+ " to group (p2p=%d wfd=%d client_info=%d); num_members=%u/%u ht=%d vht=%d he=%d bandwidth=%d",
+ MAC2STR(sta->addr), m->p2p_ie ? 1 : 0, m->wfd_ie ? 1 : 0,
m->client_info ? 1 : 0,
- group->num_members, group->cfg->max_clients);
+ group->num_members, group->cfg->max_clients,
+ m->connection_ht, m->connection_vht, m->connection_he, m->connection_channel_bandwidth);
if (group->num_members == group->cfg->max_clients)
group->beacon_update = 1;
p2p_group_update_ies(group);
@@ -1179,3 +1209,22 @@ int p2p_group_get_common_freqs(struct p2p_group *group, int *common_freqs,
return 0;
}
+
+int p2p_group_get_member_connection_info(struct p2p_group *group, const u8 *member_addr,
+ struct p2p_member_connection_info *out_info)
+{
+ struct p2p_group_member *member;
+
+ member = p2p_group_get_client_iface(group, member_addr);
+ if (!member) {
+ return -1;
+ }
+
+ out_info->connection_ht = member->connection_ht;
+ out_info->connection_vht = member->connection_vht;
+ out_info->connection_he = member->connection_he;
+ out_info->connection_eht = member->connection_eht;
+ out_info->connection_channel_bandwidth = member->connection_channel_bandwidth;
+
+ return 0;
+}
\ No newline at end of file
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index a2b763b9f..62ba7eb61 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -886,6 +886,14 @@ struct p2p_noa_desc {
};
/* p2p_group.c */
+struct p2p_member_connection_info {
+ unsigned int connection_ht:1;
+ unsigned int connection_vht:1;
+ unsigned int connection_he:1;
+ unsigned int connection_eht:1;
+ unsigned int connection_channel_bandwidth:5;
+};
+
const u8 * p2p_group_get_interface_addr(struct p2p_group *group);
u8 p2p_group_presence_req(struct p2p_group *group,
const u8 *client_interface_addr,
@@ -899,6 +907,8 @@ void p2p_buf_add_group_info(struct p2p_group *group, struct wpabuf *buf,
int max_clients);
void p2p_group_buf_add_id(struct p2p_group *group, struct wpabuf *buf);
int p2p_group_get_freq(struct p2p_group *group);
+int p2p_group_get_member_connection_info(struct p2p_group *group, const u8 *member_addr,
+ struct p2p_member_connection_info *out_info);
void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token);
--
2.25.1
More information about the Hostap
mailing list