From d312a25879d5826ff1ca638410bbd36ba2619d93 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Fri, 24 Apr 2015 19:14:35 +0300 Subject: 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 [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 --- pkt_buff.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'pkt_buff.h') diff --git a/pkt_buff.h b/pkt_buff.h index 1350388..58b0506 100644 --- a/pkt_buff.h +++ b/pkt_buff.h @@ -19,8 +19,9 @@ struct pkt_buff { uint8_t *tail; unsigned int size; - struct protocol *proto; + struct protocol *handler; int link_type; + uint16_t proto; }; static inline struct pkt_buff *pkt_alloc(uint8_t *packet, unsigned int len) @@ -31,7 +32,7 @@ static inline struct pkt_buff *pkt_alloc(uint8_t *packet, unsigned int len) pkt->data = packet; pkt->tail = packet + len; pkt->size = len; - pkt->proto = NULL; + pkt->handler = NULL; return pkt; } @@ -105,9 +106,9 @@ static inline void pkt_set_proto(struct pkt_buff *pkt, struct hash_table *table, { bug_on(!pkt || !table); - pkt->proto = lookup_hash(key, table); - while (pkt->proto && key != pkt->proto->key) - pkt->proto = pkt->proto->next; + pkt->handler = lookup_hash(key, table); + while (pkt->handler && key != pkt->handler->key) + pkt->handler = pkt->handler->next; } #endif /* PKT_BUFF_H */ -- cgit v1.2.3-54-g00ecf