summaryrefslogtreecommitdiff
path: root/dissector.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-04-24 19:14:35 +0300
committerTobias Klauser <tklauser@distanz.ch>2015-04-27 11:52:48 +0200
commitd312a25879d5826ff1ca638410bbd36ba2619d93 (patch)
tree301de11dfc9dd5de7be1531f048806e336ed4541 /dissector.c
parent7abd76e387c10d9f105af348d2f7bd16e3f671b8 (diff)
netsniff-ng nlmsg: Print netlink protocol name
nlmsg proto handler can't identify Netlink protocol from nlmsghdr, so sockaddr_ll can be used to get it. Also renamed [proto -> handler] member in pkt_buff struct, which is more understandable. Example: >U nlmon0 4756 1429891435s.14505747ns [ NLMSG Proto 0 (RTNETLINK), Len 1160, Type 0x0010 (0x10), Flags 0x0002 (MULTI), Seq-Nr 1429891436, PID 31613 ] Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tklauser: Handle usage of NETLINK_SOCK_DIAG with pre 3.10 kernel headers, fix nl_proto2str() return value, formatting changes] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'dissector.c')
-rw-r--r--dissector.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/dissector.c b/dissector.c
index 7c8ba39..ca98386 100644
--- a/dissector.c
+++ b/dissector.c
@@ -42,25 +42,26 @@ int dissector_set_print_type(void *ptr, int type)
static void dissector_main(struct pkt_buff *pkt, struct protocol *start,
struct protocol *end)
{
- struct protocol *proto;
+ struct protocol *handler;
if (!start)
return;
- for (pkt->proto = start; pkt->proto; ) {
- if (unlikely(!pkt->proto->process))
+ for (pkt->handler = start; pkt->handler; ) {
+ if (unlikely(!pkt->handler->process))
break;
- proto = pkt->proto;
- pkt->proto = NULL;
- proto->process(pkt);
+ handler = pkt->handler;
+ pkt->handler = NULL;
+ handler->process(pkt);
}
if (end && likely(end->process))
end->process(pkt);
}
-void dissector_entry_point(uint8_t *packet, size_t len, int linktype, int mode)
+void dissector_entry_point(uint8_t *packet, size_t len, int linktype, int mode,
+ uint16_t proto)
{
struct protocol *proto_start, *proto_end;
struct pkt_buff *pkt;
@@ -70,6 +71,7 @@ void dissector_entry_point(uint8_t *packet, size_t len, int linktype, int mode)
pkt = pkt_alloc(packet, len);
pkt->link_type = linktype;
+ pkt->proto = proto;
switch (linktype) {
case LINKTYPE_EN10MB: