summaryrefslogtreecommitdiff
path: root/netsniff-ng.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 /netsniff-ng.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 'netsniff-ng.c')
-rw-r--r--netsniff-ng.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c
index 2b9732e..f447864 100644
--- a/netsniff-ng.c
+++ b/netsniff-ng.c
@@ -314,7 +314,8 @@ static void pcap_to_xmit(struct ctx *ctx)
ctx->link_type, hdr, ctx->print_mode);
dissector_entry_point(out, hdr->tp_h.tp_snaplen,
- ctx->link_type, ctx->print_mode);
+ ctx->link_type, ctx->print_mode,
+ hdr->s_ll.sll_protocol);
kernel_may_pull_from_tx(&hdr->tp_h);
@@ -463,7 +464,8 @@ static void receive_to_xmit(struct ctx *ctx)
ctx->link_type, hdr_in, ctx->print_mode);
dissector_entry_point(in, hdr_in->tp_h.tp_snaplen,
- ctx->link_type, ctx->print_mode);
+ ctx->link_type, ctx->print_mode,
+ hdr_in->s_ll.sll_protocol);
if (frame_count_max != 0) {
if (frame_count >= frame_count_max) {
@@ -646,7 +648,8 @@ static void read_pcap(struct ctx *ctx)
ctx->print_mode);
dissector_entry_point(out, fm.tp_h.tp_snaplen,
- ctx->link_type, ctx->print_mode);
+ ctx->link_type, ctx->print_mode,
+ fm.s_ll.sll_protocol);
if (is_out_pcap) {
size_t pcap_len = pcap_get_length(&phdr, ctx->magic);
@@ -913,7 +916,7 @@ static void walk_t3_block(struct block_desc *pbd, struct ctx *ctx,
hdr, ctx->print_mode, true);
dissector_entry_point(packet, hdr->tp_snaplen, ctx->link_type,
- ctx->print_mode);
+ ctx->print_mode, sll->sll_protocol);
next:
hdr = (void *) ((uint8_t *) hdr + hdr->tp_next_offset);
sll = (void *) ((uint8_t *) hdr + TPACKET_ALIGN(sizeof(*hdr)));
@@ -1047,7 +1050,8 @@ static void recv_only_or_dump(struct ctx *ctx)
ctx->link_type, hdr, ctx->print_mode);
dissector_entry_point(packet, hdr->tp_h.tp_snaplen,
- ctx->link_type, ctx->print_mode);
+ ctx->link_type, ctx->print_mode,
+ hdr->s_ll.sll_protocol);
if (frame_count_max != 0) {
if (unlikely(frame_count >= frame_count_max)) {