1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* netsniff-ng - the packet sniffing beast
* Copyright 2014 Tobias Klauser.
* Subject to the GPL, version 2.
*/
#include <libnl3/netlink/msg.h>
#include "pkt_buff.h"
#include "proto.h"
static void nlmsg(struct pkt_buff *pkt)
{
struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr));
char type[32];
char flags[128];
if (hdr == NULL)
return;
tprintf(" [ NLMSG ");
tprintf("Len %u, ", hdr->nlmsg_len);
tprintf("Type 0x%.4x (%s%s%s), ", hdr->nlmsg_type,
colorize_start(bold),
nl_nlmsgtype2str(hdr->nlmsg_type, type, sizeof(type)),
colorize_end());
tprintf("Flags 0x%.4x (%s%s%s), ", hdr->nlmsg_flags,
colorize_start(bold),
nl_nlmsg_flags2str(hdr->nlmsg_flags, flags, sizeof(flags)),
colorize_end());
tprintf("Seq-Nr %u, ", hdr->nlmsg_seq);
tprintf("PID %u", hdr->nlmsg_pid);
tprintf(" ]\n");
}
static void nlmsg_less(struct pkt_buff *pkt)
{
struct nlmsghdr *hdr = (struct nlmsghdr *) pkt_pull(pkt, sizeof(*hdr));
char type[32];
if (hdr == NULL)
return;
tprintf(" NLMSG %u (%s%s%s)", hdr->nlmsg_type, colorize_start(bold),
nl_nlmsgtype2str(hdr->nlmsg_type, type, sizeof(type)),
colorize_end());
}
struct protocol nlmsg_ops = {
.print_full = nlmsg,
.print_less = nlmsg_less,
};
|