6 #include <libmnl/libmnl.h>
8 #include <linux/if_link.h>
9 #include <linux/rtnetlink.h>
11 static int data_attr_cb(
const struct nlattr *attr,
void *data)
13 const struct nlattr **tb = data;
23 perror(
"mnl_attr_validate");
29 perror(
"mnl_attr_validate2");
38 static int data_cb(
const struct nlmsghdr *nlh,
void *data)
40 struct nlattr *tb[IFLA_MAX+1] = {};
43 printf(
"index=%d type=%d flags=%d family=%d ",
44 ifm->ifi_index, ifm->ifi_type,
45 ifm->ifi_flags, ifm->ifi_family);
47 if (ifm->ifi_flags & IFF_RUNNING)
50 printf(
"[NOT RUNNING] ");
56 if (tb[IFLA_IFNAME]) {
66 char buf[MNL_SOCKET_BUFFER_SIZE];
71 perror(
"mnl_socket_open");
76 perror(
"mnl_socket_bind");
82 ret =
mnl_cb_run(buf, ret, 0, 0, data_cb, NULL);