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() */
34 static void icmp(struct pkt_buff
*pkt
)
36 struct icmphdr
*icmp
= (struct icmphdr
*) pkt_pull(pkt
, sizeof(*icmp
));
42 csum
= calc_csum(icmp
, pkt_len(pkt
) + sizeof(*icmp
));
45 tprintf("Type (%u), ", icmp
->type
);
46 tprintf("Code (%u), ", icmp
->code
);
47 tprintf("CSum (0x%.4x) is %s", ntohs(icmp
->checksum
),
48 csum
? colorize_start_full(black
, red
) "bogus (!)"
49 colorize_end() : "ok");
53 static void icmp_less(struct pkt_buff
*pkt
)
55 struct icmphdr
*icmp
= (struct icmphdr
*) pkt_pull(pkt
, sizeof(*icmp
));
60 tprintf(" Type %u Code %u", icmp
->type
, icmp
->code
);
63 struct protocol icmpv4_ops
= {
66 .print_less
= icmp_less
,