2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
10 #include <netinet/in.h> /* for ntohs() */
15 #include "dissector_eth.h"
36 static void icmp(struct pkt_buff
*pkt
)
38 struct icmphdr
*icmp
= (struct icmphdr
*) pkt_pull(pkt
, sizeof(*icmp
));
44 csum
= calc_csum(icmp
, pkt_len(pkt
) + sizeof(*icmp
), 0);
47 tprintf("Type (%u), ", icmp
->type
);
48 tprintf("Code (%u), ", icmp
->code
);
49 tprintf("CSum (0x%.4x) is %s", ntohs(icmp
->checksum
),
50 csum
? colorize_start_full(black
, red
) "bogus (!)"
51 colorize_end() : "ok");
55 static void icmp_less(struct pkt_buff
*pkt
)
57 struct icmphdr
*icmp
= (struct icmphdr
*) pkt_pull(pkt
, sizeof(*icmp
));
62 tprintf(" Type %u Code %u", icmp
->type
, icmp
->code
);
65 struct protocol icmpv4_ops
= {
68 .print_less
= icmp_less
,