--- /dev/null
+/*
+ * Proxmity Ranging
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "includes.h"
+
+#include "utils/common.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");
+}
--- /dev/null
+/*
+ * Proxmity Ranging
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * 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"
+
+/**
+ * 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 */
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
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
--- /dev/null
+/*
+ * Proxmity Ranging
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#include "includes.h"
+
+#include "utils/common.h"
+#include "common/proximity_ranging.h"
+#include "wpa_supplicant_i.h"
+#include "config.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;
+ }
+}
--- /dev/null
+/*
+ * Proxmity Ranging
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ *
+ * 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
+
+#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 */
#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"
wpas_p2p_deinit(wpa_s);
+ wpas_pr_deinit(wpa_s);
+
#ifdef CONFIG_OFFCHANNEL
offchannel_deinit(wpa_s);
#endif /* CONFIG_OFFCHANNEL */
return -1;
}
+ if (wpas_pr_init(wpa_s->global, wpa_s) < 0)
+ return -1;
+
if (wpa_bss_init(wpa_s) < 0)
return -1;
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 */