2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
9 #include <netinet/in.h> /* for ntohs() */
14 #include "dissector_eth.h"
35 static void icmp(struct pkt_buff
*pkt
)
37 struct icmphdr
*icmp
= (struct icmphdr
*) pkt_pull(pkt
, sizeof(*icmp
));
43 csum
= calc_csum(icmp
, pkt_len(pkt
) + sizeof(*icmp
), 0);
46 tprintf("Type (%u), ", icmp
->type
);
47 tprintf("Code (%u), ", icmp
->code
);
48 tprintf("CSum (0x%.4x) is %s", ntohs(icmp
->checksum
),
49 csum
? colorize_start_full(black
, red
) "bogus (!)"
50 colorize_end() : "ok");
54 static void icmp_less(struct pkt_buff
*pkt
)
56 struct icmphdr
*icmp
= (struct icmphdr
*) pkt_pull(pkt
, sizeof(*icmp
));
61 tprintf(" Type %u Code %u", icmp
->type
, icmp
->code
);
64 struct protocol icmpv4_ops
= {
67 .print_less
= icmp_less
,