Signed-off-by: Peddolla Harshavardhan Reddy <peddolla@xxxxxxxxxxxxxxxx> --- src/common/proximity_ranging.c | 53 +++++++++++++++++++++++++ src/common/proximity_ranging.h | 65 +++++++++++++++++++++++++++++++ wpa_supplicant/Android.mk | 6 +++ wpa_supplicant/Makefile | 6 +++ wpa_supplicant/pr_supplicant.c | 52 +++++++++++++++++++++++++ wpa_supplicant/pr_supplicant.h | 31 +++++++++++++++ wpa_supplicant/wpa_supplicant.c | 7 +++- wpa_supplicant/wpa_supplicant_i.h | 2 + 8 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 src/common/proximity_ranging.c create mode 100644 src/common/proximity_ranging.h create mode 100644 wpa_supplicant/pr_supplicant.c create mode 100644 wpa_supplicant/pr_supplicant.h diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c new file mode 100644 index 000000000..287bff2f7 --- /dev/null +++ b/src/common/proximity_ranging.c @@ -0,0 +1,53 @@ +/* + * Proxmity Ranging + * Copyright (c) 2025, Qualcomm Innovation Center, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#include "includes.h" + +#include "common.h" +#include "common/ieee802_11_defs.h" +#include "common/ieee802_11_common.h" +#include "common/qca-vendor.h" +#include "wps/wps_i.h" +#include "proximity_ranging.h" + +struct pr_data * pr_init(const struct pr_config *cfg) +{ + struct pr_data *pr; + + pr = os_zalloc(sizeof(*pr) + sizeof(*cfg)); + if (!pr) + return NULL; + + pr->cfg = (struct pr_config *) (pr + 1); + os_memcpy(pr->cfg, cfg, sizeof(*cfg)); + if (cfg->dev_name) + pr->cfg->dev_name = os_strdup(cfg->dev_name); + else + pr->cfg->dev_name = NULL; + + dl_list_init(&pr->devices); + + return pr; +} + + +void pr_deinit(struct pr_data *pr) +{ + struct pr_device *dev, *prev; + + if (!pr) + return; + + os_free(pr->cfg->dev_name); + + dl_list_for_each_safe(dev, prev, &pr->devices, struct pr_device, list) + dl_list_del(&dev->list); + + os_free(pr); + wpa_printf(MSG_DEBUG, "PR: Deinit done"); +} diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h new file mode 100644 index 000000000..33a67469b --- /dev/null +++ b/src/common/proximity_ranging.h @@ -0,0 +1,65 @@ +/* + * Proxmity Ranging + * Copyright (c) 2025, Qualcomm Innovation Center, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef PROXIMITY_RANGING_H +#define PROXIMITY_RANGING_H + + +#include "utils/list.h" +#include "drivers/driver.h" + + +/** + * PR_MAX_PEER - Maximum number of Proximity Ranging peers that device can store + */ +#define PR_MAX_PEER 100 + +/** + * struct pr_device_info - Proximity ranging peer information + */ +struct pr_device { + struct dl_list list; + struct os_reltime last_seen; + + /** + * pr_device_addr - PR Device Address of the peer + */ + u8 pr_device_addr[ETH_ALEN]; +}; + + +struct pr_config { + u8 dev_addr[ETH_ALEN]; + + /** + * dev_name - Device Name + */ + char *dev_name; + + /** + * cb_ctx - Context to use with callback functions + */ + void *cb_ctx; +}; + +struct pr_data { + /** + * cfg - PR module configuration + * + * This is included in the same memory allocation with the + * struct pr_data and as such, must not be freed separately. + */ + struct pr_config *cfg; + + struct dl_list devices; +}; + +struct pr_data * pr_init(const struct pr_config *cfg); +void pr_deinit(struct pr_data *pr); + +#endif /* PROXIMITY_RANGING_H */ diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk index cb07e7364..e09768a9d 100644 --- a/wpa_supplicant/Android.mk +++ b/wpa_supplicant/Android.mk @@ -290,6 +290,12 @@ NEED_OFFCHANNEL=y L_CFLAGS += -DCONFIG_NAN_USD endif +ifdef CONFIG_PR +OBJS += src/common/proximity_ranging.c +OBJS += pr_supplicant.c +L_CFLAGS += -DCONFIG_PR +endif + ifdef CONFIG_OWE L_CFLAGS += -DCONFIG_OWE NEED_ECC=y diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index fd7d7a0bd..f420e7130 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -324,6 +324,12 @@ NEED_OFFCHANNEL=y CFLAGS += -DCONFIG_NAN_USD endif +ifdef CONFIG_PR +OBJS += ../src/common/proximity_ranging.o +OBJS += pr_supplicant.o +CFLAGS += -DCONFIG_PR +endif + ifdef CONFIG_OWE CFLAGS += -DCONFIG_OWE NEED_ECC=y diff --git a/wpa_supplicant/pr_supplicant.c b/wpa_supplicant/pr_supplicant.c new file mode 100644 index 000000000..f35077218 --- /dev/null +++ b/wpa_supplicant/pr_supplicant.c @@ -0,0 +1,52 @@ +/* + * Proxmity Ranging + * Copyright (c) 2025, Qualcomm Innovation Center, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#include "includes.h" + +#include "common.h" +#include "eloop.h" +#include "wpa_supplicant_i.h" +#include "config.h" +#include "notify.h" +#include "driver_i.h" +#include "common/ieee802_11_common.h" +#include "common/proximity_ranging.h" +#include "pr_supplicant.h" + +int wpas_pr_init(struct wpa_global *global, struct wpa_supplicant *wpa_s) +{ + struct pr_config pr; + + if (global->pr) + return 0; + + os_memset(&pr, 0, sizeof(pr)); + + os_memcpy(pr.dev_addr, wpa_s->own_addr, ETH_ALEN); + pr.cb_ctx = wpa_s; + pr.dev_name = wpa_s->conf->device_name; + + global->pr = pr_init(&pr); + if (!global->pr) { + wpa_printf(MSG_DEBUG, "PR: Failed to init PR"); + return -1; + } + global->pr_init_wpa_s = wpa_s; + + return 0; +} + + +void wpas_pr_deinit(struct wpa_supplicant *wpa_s) +{ + if (wpa_s == wpa_s->global->pr_init_wpa_s) { + pr_deinit(wpa_s->global->pr); + wpa_s->global->pr = NULL; + wpa_s->global->pr_init_wpa_s = NULL; + } +} diff --git a/wpa_supplicant/pr_supplicant.h b/wpa_supplicant/pr_supplicant.h new file mode 100644 index 000000000..fc8019dda --- /dev/null +++ b/wpa_supplicant/pr_supplicant.h @@ -0,0 +1,31 @@ +/* + * Proxmity Ranging + * Copyright (c) 2025, Qualcomm Innovation Center, Inc. + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef PR_SUPPLICANT_H +#define PR_SUPPLICANT_H + +#include "common/proximity_ranging.h" + +#ifdef CONFIG_PR + +int wpas_pr_init(struct wpa_global *global, struct wpa_supplicant *wpa_s); +void wpas_pr_deinit(struct wpa_supplicant *wpa_s); +#else /* CONFIG_PR */ +static inline int wpas_pr_init(struct wpa_global *global, + struct wpa_supplicant *wpa_s) +{ + return -1; +} + +static inline void wpas_pr_deinit(struct wpa_supplicant *wpa_s) +{ +} + +#endif /* CONFIG_PR */ + +#endif /*PR_SUPPLICANT_H */ diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index da7ff00c9..fb0da3d67 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -66,6 +66,7 @@ #include "mesh.h" #include "dpp_supplicant.h" #include "nan_usd.h" +#include "pr_supplicant.h" #ifdef CONFIG_MESH #include "ap/ap_config.h" #include "ap/hostapd.h" @@ -738,6 +739,8 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) wpas_p2p_deinit(wpa_s); + wpas_pr_deinit(wpa_s); + #ifdef CONFIG_OFFCHANNEL offchannel_deinit(wpa_s); #endif /* CONFIG_OFFCHANNEL */ @@ -7871,7 +7874,6 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, if (wpas_nan_usd_init(wpa_s) < 0) return -1; #endif /* CONFIG_NAN_USD */ - if (wpa_supplicant_init_eapol(wpa_s) < 0) return -1; wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol); @@ -7903,6 +7905,9 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, return -1; } + if (wpas_pr_init(wpa_s->global, wpa_s) < 0) + return -1; + if (wpa_bss_init(wpa_s) < 0) return -1; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 1a7e2148e..078b17759 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -288,9 +288,11 @@ struct wpa_global { size_t drv_count; struct os_time suspend_time; struct p2p_data *p2p; + struct pr_data *pr; struct wpa_supplicant *p2p_init_wpa_s; struct wpa_supplicant *p2p_group_formation; struct wpa_supplicant *p2p_invite_group; + struct wpa_supplicant *pr_init_wpa_s; u8 p2p_dev_addr[ETH_ALEN]; struct os_reltime p2p_go_wait_client; struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */ -- 2.34.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap