2 #include <netinet/in.h>
11 #include <libmnl/libmnl.h>
12 #include <linux/if_link.h>
13 #include <linux/rtnetlink.h>
15 static int test(
int family)
18 char buf[MNL_SOCKET_BUFFER_SIZE*4];
21 uint32_t prefix, seq, portid;
24 nlh = mnl_nlmsg_put_header(buf);
26 nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK;
27 nlh->nlmsg_seq = seq = time(NULL);
28 nlh->nlmsg_len +=
sizeof(buf) -
sizeof(
struct nlmsghdr) - 100;
30 nl = mnl_socket_open(family);
32 perror(
"mnl_socket_open");
36 if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) {
37 perror(
"mnl_socket_bind");
40 portid = mnl_socket_get_portid(nl);
43 if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
44 perror(
"mnl_socket_send");
48 ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL);
58 int main(
int argc,
char *argv[])
62 for (i=0; i<20; i++) {
63 printf(
"testing %d\n", i);