...
 
Commits (2)
From a61f14930a4d1e618bf3571203431a2f1e07fa15 Mon Sep 17 00:00:00 2001
From: Anjan Chanda <anjan.chanda@iopsys.eu>
Date: Tue, 8 Oct 2019 15:58:26 +0200
Subject: [PATCH] add list_neighbor_per_vap to dump 11k neighbor list
---
hostapd/ctrl_iface.c | 9 +++++++++
hostapd/hostapd_cli.c | 8 ++++++++
src/ap/neighbor_db.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/ap/neighbor_db.h | 2 ++
4 files changed, 60 insertions(+)
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 56c1641..ecb4491 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -5853,6 +5853,12 @@ static int hostapd_ctrl_iface_remove_neighbor_per_vap(struct hostapd_data *hapd,
return hostapd_neighbor_remove(hapd, bssid, &ssid);
}
+static int hostapd_ctrl_iface_list_neighbor_per_vap(struct hostapd_data *hapd,
+ char *reply, size_t len)
+{
+ return hostapd_neighbor_list(hapd, reply, len);
+}
+
static int
hostapd_is_chandef_valid (struct hostapd_iface *iface, unsigned int center_freq, unsigned int bandwidth)
{
@@ -7037,6 +7043,9 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd,
} else if (os_strncmp(buf, "REMOVE_NEIGHBOR_PER_VAP ", 24) == 0) {
if (hostapd_ctrl_iface_remove_neighbor_per_vap(hapd, buf + 24))
reply_len = -1;
+ } else if (os_strncmp(buf, "LIST_NEIGHBOR_PER_VAP", 21) == 0) {
+ reply_len = hostapd_ctrl_iface_list_neighbor_per_vap(hapd,
+ reply, reply_size);
} else if (os_strncmp(buf, "REQ_LCI ", 8) == 0) {
if (hostapd_ctrl_iface_req_lci(hapd, buf + 8))
reply_len = -1;
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index ce92618..0909ccb 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -1363,6 +1363,12 @@ static int hostapd_cli_cmd_remove_neighbor_per_vap(struct wpa_ctrl *ctrl, int ar
return wpa_ctrl_command(ctrl, cmd);
}
+static int hostapd_cli_cmd_list_neighbor_per_vap(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "LIST_NEIGHBOR_PER_VAP");
+}
+
static int hostapd_cli_cmd_req_lci(struct wpa_ctrl *ctrl, int argc,
char *argv[])
{
@@ -2257,6 +2263,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "set_neighbor_per_vap", hostapd_cli_cmd_set_neighbor_per_vap, NULL, NULL },
{ "remove_neighbor", hostapd_cli_cmd_remove_neighbor, NULL, NULL },
{ "remove_neighbor_per_vap", hostapd_cli_cmd_remove_neighbor_per_vap, NULL, NULL },
+ { "list_neighbor_per_vap", hostapd_cli_cmd_list_neighbor_per_vap, NULL,
+ "= list neighbor APs"},
{ "req_lci", hostapd_cli_cmd_req_lci, NULL, NULL },
{ "req_range", hostapd_cli_cmd_req_range, NULL, NULL },
{ "req_beacon", hostapd_cli_cmd_req_beacon, NULL, NULL },
diff --git a/src/ap/neighbor_db.c b/src/ap/neighbor_db.c
index f65afff..b19b693 100644
--- a/src/ap/neighbor_db.c
+++ b/src/ap/neighbor_db.c
@@ -131,3 +131,44 @@ void hostpad_free_neighbor_db(struct hostapd_data *hapd)
os_free(nr);
}
}
+
+int hostapd_neighbor_list(struct hostapd_data *hapd, char *rbuf, size_t rlen)
+{
+ struct hostapd_neighbor_entry *n;
+ struct nbr {
+ u8 bssid[ETH_ALEN];
+ u32 bssid_info;
+ u8 reg;
+ u8 channel;
+ u8 phy;
+ } __attribute__((packed)) *nbr;
+ unsigned char obuf[256] = {0};
+ int len = 0, ret = 0;
+ int i;
+
+ dl_list_for_each(n, &hapd->nr_db, struct hostapd_neighbor_entry, list) {
+ if (len + sizeof(struct nbr) > rlen)
+ break;
+
+ if (!os_memcmp(n->bssid, hapd->own_addr, ETH_ALEN))
+ continue;
+
+ nbr = (struct nbr *)&obuf[len];
+ if (n->nr) {
+ os_memcpy(nbr, wpabuf_head(n->nr), wpabuf_len(n->nr));
+ len += sizeof(struct nbr);
+ }
+ }
+
+ if (len > 0) {
+ rbuf[0] = '\0';
+ /* convert to hexbyte-stream */
+ for (i = 0; i < len; i++)
+ sprintf(rbuf + strlen(rbuf), "%02x", obuf[i] & 0xff);
+
+ rbuf[2 * len] = '\0';
+ ret = 2 * len + 1;
+ }
+
+ return ret;
+}
diff --git a/src/ap/neighbor_db.h b/src/ap/neighbor_db.h
index c22e043..eda7227 100644
--- a/src/ap/neighbor_db.h
+++ b/src/ap/neighbor_db.h
@@ -21,4 +21,6 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
const struct wpa_ssid_value *ssid);
void hostpad_free_neighbor_db(struct hostapd_data *hapd);
+int hostapd_neighbor_list(struct hostapd_data *hapd, char *rbuf, size_t rlen);
+
#endif /* NEIGHBOR_DB_H */
--
2.7.4
......@@ -56,6 +56,7 @@ drv_intel_init_iface_config() {
config_add_int dtim_period
config_add_int start_disabled
config_add_int disabled
config_add_int rrm wnm
}
intel_add_capabilities() {
......@@ -328,6 +329,9 @@ intel_hostapd_setup_bss() {
[ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
[ "$rrm" -gt 0 ] && append hostapd_cfg "rrm_neighbor_report=1" "$N"
[ "$wnm" -eq 0 ] || append hostapd_cfg "bss_transition=1" "$N"
cat >> /var/run/hostapd-$phy.conf <<EOF
$hostapd_cfg
bssid=$bssaddr
......@@ -529,6 +533,7 @@ intel_prepare_vif() {
json_get_vars network:0
json_get_vars isolate
json_get_vars hidden:0
json_get_vars rrm:255 wnm:1
local radio_macaddr=$1
......