5 #include <netlink/genl/genl.h>
6 #include <netlink/genl/family.h>
7 #include <netlink/genl/ctrl.h>
8 #include <netlink/msg.h>
9 #include <netlink/attr.h>
16 static int print_mpp_handler(struct nl_msg
*msg
, void *arg
)
18 struct nlattr
*tb
[NL80211_ATTR_MAX
+ 1];
19 struct genlmsghdr
*gnlh
= nlmsg_data(nlmsg_hdr(msg
));
20 char dst
[20], next_hop
[20], dev
[20];
22 nla_parse(tb
, NL80211_ATTR_MAX
, genlmsg_attrdata(gnlh
, 0),
23 genlmsg_attrlen(gnlh
, 0), NULL
);
26 * TODO: validate the interface and mac address!
27 * Otherwise, there's a race condition as soon as
28 * the kernel starts sending mpath notifications.
31 mac_addr_n2a(dst
, nla_data(tb
[NL80211_ATTR_MAC
]));
32 mac_addr_n2a(next_hop
, nla_data(tb
[NL80211_ATTR_MPATH_NEXT_HOP
]));
33 if_indextoname(nla_get_u32(tb
[NL80211_ATTR_IFINDEX
]), dev
);
34 printf("%s %s %s\n", dst
, next_hop
, dev
);
39 static int handle_mpp_get(struct nl80211_state
*state
,
42 int argc
, char **argv
,
45 unsigned char dst
[ETH_ALEN
];
50 if (mac_addr_a2n(dst
, argv
[0])) {
51 fprintf(stderr
, "invalid mac address\n");
60 NLA_PUT(msg
, NL80211_ATTR_MAC
, ETH_ALEN
, dst
);
62 nl_cb_set(cb
, NL_CB_VALID
, NL_CB_CUSTOM
, print_mpp_handler
, NULL
);
68 COMMAND(mpp
, get
, "<MAC address>",
69 NL80211_CMD_GET_MPP
, 0, CIB_NETDEV
, handle_mpp_get
,
70 "Get information on mesh proxy path to the given node.");
72 static int handle_mpp_dump(struct nl80211_state
*state
,
75 int argc
, char **argv
,
78 printf("DEST ADDR PROXY NODE IFACE\n");
79 nl_cb_set(cb
, NL_CB_VALID
, NL_CB_CUSTOM
, print_mpp_handler
, NULL
);
82 COMMAND(mpp
, dump
, NULL
,
83 NL80211_CMD_GET_MPP
, NLM_F_DUMP
, CIB_NETDEV
, handle_mpp_dump
,
84 "List known mesh proxy paths.");