Skip to content

Commit

Permalink
fixup! information: add batman-adv statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Mar 19, 2024
1 parent c5ba358 commit 4b54a4c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/batadv.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ struct neigh_netlink_opts {
struct gluon_diagnostic_batadv_neighbor_stats *stats;
};

static const enum batadv_nl_attrs parse_orig_list_mandatory[] = {
BATADV_ATTR_ORIG_ADDRESS,
BATADV_ATTR_NEIGH_ADDRESS,
BATADV_ATTR_TQ,
BATADV_ATTR_HARD_IFINDEX,
BATADV_ATTR_LAST_SEEN_MSECS,
};

static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
{
Expand All @@ -29,6 +36,7 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
struct batadv_nlquery_opts *query_opts = arg;
struct genlmsghdr *ghdr;
struct neigh_netlink_opts *opts;
char ifname[IF_NAMESIZE];
uint32_t hardif;
uint8_t tq;

Expand All @@ -53,9 +61,12 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)

hardif = nla_get_u32(attrs[BATADV_ATTR_HARD_IFINDEX]);

if (if_indextoname(hardif, ifname) == NULL)
return NL_OK;

opts->stats->neighbor_count++;
opts->stats->vpn.tq = nla_get_u8(attrs[BATADV_ATTR_TQ]);
opts->stats->vpn.connected = !!strcmp(if_indextoname(hardif), "mesh-vpn");
opts->stats->vpn.connected = !!strncmp(ifname, "mesh-vpn", strlen(ifname));

return NL_OK;
}
Expand Down

0 comments on commit 4b54a4c

Please sign in to comment.