5 #include <netinet/in.h>
7 #include <libmnl/libmnl.h>
11 static void udp_echo(
const struct mnl_socket *nl,
12 const char *pre,
const char *post)
14 uint8_t proto = IPPROTO_UDP;
17 timeout.tv_sec = INIT_TIMEOUT;
18 handle_qacb(nl,
true, cb_udp_new, &proto);
19 handle_qacb(nl,
true, cb_udp_update, &proto);
20 handle_qacb(nl,
true, cb_udp_destroy, &proto);
21 handle_qacb(nl,
false, NULL, NULL);
25 static void icmp_echo(
const struct mnl_socket *nl,
26 const char *pre,
const char *post)
28 uint8_t proto = IPPROTO_ICMP;
31 timeout.tv_sec = INIT_TIMEOUT;
32 handle_qacb(nl,
true, cb_icmp_new, &proto);
33 handle_qacb(nl,
true, cb_icmp_update, &proto);
34 handle_qacb(nl,
true, cb_icmp_destroy, &proto);
35 handle_qacb(nl,
false, NULL, NULL);
39 int main(
int argc,
char *argv[])
41 struct mnl_socket *nl;
45 fprintf(stderr,
"usage: %s <netns> <pre_fifo> <post_fifo>\n", argv[0]);
51 nl = mnl_event_nssocket(argv[1]);
53 perror(
"init_mnl_socket");
57 tcp_echo(nl, pre, post);
58 udp_echo(nl, pre, post);
59 icmp_echo(nl, pre, post);
61 return fini_nssocket();