2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>
4 * Subject to the GPL, version 2.
6 * ICMPv6 described in RFC4443, RFC2710, RFC4861, RFC2894,
7 * RFC4620, RFC3122, RFC3810, RFC3775, RFC3971, RFC4065
11 #ifndef PROTO_ICMPV6_H
12 #define PROTO_ICMPV6_H
16 #include <netinet/in.h>
17 #include <arpa/inet.h>
20 #include "proto_struct.h"
21 #include "dissector_eth.h"
31 static char *icmpv6_type_1_strings
[] = {
32 "No route to destination",
33 "Communication with destination administratively prohibited",
34 "Beyond scope of source address",
35 "Address unreachable",
37 "Source address failed ingress/egress policy",
38 "Reject route to destination",
39 "Error in Source Routing Header",
42 #define icmpv6_code_range_valid(code, sarr) ((code) < array_size((sarr)))
44 static inline void icmpv6_process(struct icmpv6hdr
*icmp
, char **type
,
45 char **code
, char **optional
)
47 *type
= "Unknown Type";
48 *code
= "Unknown Code";
50 switch (icmp
->h_type
) {
52 *type
= "Destination Unreachable";
53 if (icmpv6_code_range_valid(icmp
->h_code
, icmpv6_type_1_strings
))
54 *code
= icmpv6_type_1_strings
[icmp
->h_code
];
57 *type
= "Packet Too Big";
60 *type
= "Time Exceeded";
63 *type
= "Parameter Problem";
66 *type
= "Private experimation";
69 *type
= "Private experimation";
72 *type
= "Reserved for expansion of ICMPv6 error messages";
75 *type
= "Echo Request";
81 *type
= "Multicast Listener Query";
84 *type
= "Multicast Listener Report";
87 *type
= "Multicast Listener Done";
90 *type
= "Router Solicitation";
93 *type
= "Router Advertisement";
96 *type
= "Neighbor Solicitation";
99 *type
= "Neighbor Advertisement";
102 *type
= "Redirect Message";
105 *type
= "Router Renumbering";
108 *type
= "ICMP Node Information Query";
111 *type
= "ICMP Node Information Response";
114 *type
= "Inverse Neighbor Discovery Solicitation Message";
117 *type
= "Inverse Neighbor Discovery Advertisement Message";
120 *type
= "Multicast Listener Report v2";
123 *type
= "Home Agent Address Discovery Request Message";
126 *type
= "Home Agent Address Discovery Reply Message";
129 *type
= "Mobile Prefix Solicitation";
132 *type
= "Mobile Prefix Advertisement";
135 *type
= "Certification Path Solicitation";
138 *type
= "Certification Path Advertisement";
141 *type
= "ICMP messages utilized by experimental mobility "
142 "protocols such as Seamoby";
145 *type
= "Multicast Router Advertisement";
148 *type
= "Multicast Router Solicitation";
151 *type
= "Multicast Router Termination";
154 *type
= "RPL Control Message";
157 *type
= "Private experimation";
160 *type
= "Private experimation";
163 *type
= "Reserved for expansion of ICMPv6 error messages";
168 static inline void icmpv6(struct pkt_buff
*pkt
)
170 char *type
= NULL
, *code
= NULL
, *optional
= NULL
;
171 struct icmpv6hdr
*icmp
=
172 (struct icmpv6hdr
*) pkt_pull(pkt
, sizeof(*icmp
));
177 icmpv6_process(icmp
, &type
, &code
, &optional
);
179 tprintf(" [ ICMPv6 ");
180 tprintf("%s (%u), ", type
, icmp
->h_type
);
181 tprintf("%s (%u), ", code
, icmp
->h_code
);
182 tprintf("Chks (0x%x)", ntohs(icmp
->h_chksum
));
184 tprintf(" %s", optional
);
188 static inline void icmpv6_less(struct pkt_buff
*pkt
)
190 struct icmpv6hdr
*icmp
=
191 (struct icmpv6hdr
*) pkt_pull(pkt
, sizeof(*icmp
));
196 tprintf(" ICMPv6 Type (%u) Code (%u)", icmp
->h_type
, icmp
->h_code
);
199 struct protocol icmpv6_ops
= {
201 .print_full
= icmpv6
,
202 .print_less
= icmpv6_less
,
205 #endif /* PROTO_ICMPV6_H */