2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2014 Tobias Klauser.
4 * Subject to the GPL, version 2.
9 #include <libnl3/netlink/msg.h>
15 static void nlmsg(struct pkt_buff
*pkt
)
17 struct nlmsghdr
*hdr
= (struct nlmsghdr
*) pkt_pull(pkt
, sizeof(*hdr
));
25 /* Look up the process name if message is not coming from the kernel */
26 if (hdr
->nlmsg_pid
!= 0) {
30 snprintf(path
, sizeof(path
), "/proc/%u/exe", hdr
->nlmsg_pid
);
31 ret
= readlink(path
, procname
, sizeof(procname
) - 1);
35 snprintf(procname
, sizeof(procname
), "kernel");
38 tprintf("Len %u, ", hdr
->nlmsg_len
);
39 tprintf("Type 0x%.4x (%s%s%s), ", hdr
->nlmsg_type
,
41 nl_nlmsgtype2str(hdr
->nlmsg_type
, type
, sizeof(type
)),
43 tprintf("Flags 0x%.4x (%s%s%s), ", hdr
->nlmsg_flags
,
45 nl_nlmsg_flags2str(hdr
->nlmsg_flags
, flags
, sizeof(flags
)),
47 tprintf("Seq-Nr %u, ", hdr
->nlmsg_seq
);
48 tprintf("PID %u", hdr
->nlmsg_pid
);
50 tprintf(" (%s%s%s)", colorize_start(bold
), basename(procname
),
55 static void nlmsg_less(struct pkt_buff
*pkt
)
57 struct nlmsghdr
*hdr
= (struct nlmsghdr
*) pkt_pull(pkt
, sizeof(*hdr
));
63 tprintf(" NLMSG %u (%s%s%s)", hdr
->nlmsg_type
, colorize_start(bold
),
64 nl_nlmsgtype2str(hdr
->nlmsg_type
, type
, sizeof(type
)),
68 struct protocol nlmsg_ops
= {
70 .print_less
= nlmsg_less
,