Repository : ssh://git@diktynna/batctl
On branch : master
commit ffce54add033bb1b34806a97771ac63d4a1c7bef Author: Alexander Sarmanow asarmanow@gmail.com Date: Thu May 13 16:28:10 2021 +0200
batctl: Add neighbors_json command
Signed-off-by: Alexander Sarmanow asarmanow@gmail.com [sven@narfation.org: Reimplement with shared json query helpers] Signed-off-by: Sven Eckelmann sven@narfation.org
ffce54add033bb1b34806a97771ac63d4a1c7bef Makefile | 1 + README.rst | 28 ++++++++++++++++++++++++++++ man/batctl.8 | 3 +++ gateways_json.c => neighbors_json.c | 10 +++++----- 4 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile index 478e767..97790ce 100755 --- a/Makefile +++ b/Makefile @@ -67,6 +67,7 @@ $(eval $(call add_command,multicast_fanout,y)) $(eval $(call add_command,multicast_forceflood,y)) $(eval $(call add_command,multicast_mode,y)) $(eval $(call add_command,neighbors,y)) +$(eval $(call add_command,neighbors_json,y)) $(eval $(call add_command,network_coding,y)) $(eval $(call add_command,orig_interval,y)) $(eval $(call add_command,originators,y)) diff --git a/README.rst b/README.rst index 674c574..ce22087 100644 --- a/README.rst +++ b/README.rst @@ -1038,6 +1038,34 @@ Example:: }
+batctl neighbors_json +--------------------- + +Query batman-adv for the entries in the (direct) neighbors table. + +Usage:: + + batctl meshif <netdev> neighbors_json|nj + +Example:: + + $ batctl meshif bat0 neighbors_json + [ + { + "hard_ifindex": 3, + "hard_ifname": "enp0s1", + "last_seen_msecs": 708, + "neigh_address": "16:7b:3c:c2:bf:b8" + }, + { + "hard_ifindex": 3, + "hard_ifname": "enp0s1", + "last_seen_msecs": 1872, + "neigh_address": "ae:1b:bf:52:25:58" + } + ] + + Advanced Analytics ==================
diff --git a/man/batctl.8 b/man/batctl.8 index 915bde0..826d21c 100644 --- a/man/batctl.8 +++ b/man/batctl.8 @@ -329,6 +329,9 @@ List of available JSON queries: .RS 10 - mesh_json|mj .RE +.RS 10 +- neighbors_json|nj +.RE .RE .br .IP "[\fBmeshif <netdev>\fP] \fBtranslate\fP|\fBt\fP \fBMAC_address\fP|\fBbat-host_name\fP|\fBhost_name\fP|\fBIP_address\fP" diff --git a/gateways_json.c b/neighbors_json.c similarity index 52% copy from gateways_json.c copy to neighbors_json.c index 3ab75da..6c9bdc3 100644 --- a/gateways_json.c +++ b/neighbors_json.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (C) B.A.T.M.A.N. contributors: * - * Sven Eckelmann <sven@narfation.org + * Alexander Sarmanow asarmanow@gmail.com * * License-Filename: LICENSES/preferred/GPL-2.0 */ @@ -10,11 +10,11 @@
#include "genl_json.h"
-static struct json_query_data batctl_json_query_gateways = { +static struct json_query_data batctl_json_query_neighbors = { .nlm_flags = NLM_F_DUMP, - .cmd = BATADV_CMD_GET_GATEWAYS, + .cmd = BATADV_CMD_GET_NEIGHBORS, };
-COMMAND_NAMED(JSON_MIF, gateways_json, "gwj", handle_json_query, +COMMAND_NAMED(JSON_MIF, neighbors_json, "nj", handle_json_query, COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK, - &batctl_json_query_gateways, ""); + &batctl_json_query_neighbors, "");