dissector_fuzz: removed printing opts to make for usage with diff
[netsniff-ng.git] / src / proto_icmpv6.h
blob614fd8872faf5b95350cd486714b8c4722535e78
1 /*
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
8 * RFC4286
9 * Look also for an good overview:
10 * http://www.iana.org/assignments/icmpv6-parameters
13 #ifndef PROTO_ICMPV6_H
14 #define PROTO_ICMPV6_H
16 #include <stdio.h>
17 #include <stdint.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
20 #include <asm/byteorder.h>
22 #include "built_in.h"
23 #include "proto_struct.h"
24 #include "dissector_eth.h"
25 #include "pkt_buff.h"
26 #include "built_in.h"
28 #define icmpv6_code_range_valid(code, sarr) ((code) < array_size((sarr)))
30 struct icmpv6_general_hdr {
31 uint8_t h_type;
32 uint8_t h_code;
33 uint16_t h_chksum;
34 } __packed;
36 /* for type 0x01 and 0x03 */
37 struct icmpv6_type_1_3 {
38 uint32_t unused;
39 uint8_t invoking_pkt[0];
40 } __packed;
42 struct icmpv6_type_2 {
43 uint32_t MTU;
44 uint8_t invoking_pkt[0];
45 } __packed;
47 struct icmpv6_type_4 {
48 uint32_t pointer;
49 uint8_t invoking_pkt[0];
50 } __packed;
52 struct icmpv6_type_128_129 {
53 uint16_t id;
54 uint16_t sn;
55 uint8_t data[0];
56 } __packed;
58 /* MLDv1 msg */
59 struct icmpv6_type_130_131_132 {
60 uint16_t maxrespdel;
61 uint16_t res;
62 struct in6_addr ipv6_addr;
63 } __packed;
64 /* end MLDv1 msg */
66 struct icmpv6_type_130_mldv2 {
67 uint8_t resv_S_QRV;
68 uint8_t QQIC;
69 uint16_t nr_src;
70 struct in6_addr ipv6_addr[0];
71 } __packed;
73 /* Neighbor Discovery msg */
74 struct icmpv6_type_133_141_142 {
75 uint32_t res;
76 uint8_t ops[0];
77 } __packed;
79 struct icmpv6_type_134 {
80 uint8_t cur_hop_limit;
81 uint8_t m_o_res;
82 uint16_t router_lifetime;
83 uint32_t reachable_time;
84 uint32_t retrans_timer;
85 uint8_t ops[0];
86 } __packed;
88 struct icmpv6_type_135 {
89 uint32_t res;
90 struct in6_addr ipv6_addr;
91 uint8_t ops[0];
92 } __packed;
94 struct icmpv6_type_136 {
95 uint32_t r_s_o_res;
96 struct in6_addr ipv6_addr;
97 uint8_t ops[0];
98 } __packed;
100 struct icmpv6_type_137 {
101 uint32_t res;
102 struct in6_addr ipv6_targ_addr;
103 struct in6_addr ipv6_dest_addr;
104 uint8_t ops[0];
105 } __packed;
107 struct icmpv6_neighb_disc_ops_general {
108 uint8_t type;
109 uint8_t len;
110 uint8_t ops[0];
111 } __packed;
113 struct icmpv6_neighb_disc_ops_type_1_2 {
114 uint8_t link_lay_addr[0];
115 } __packed;
117 struct icmpv6_neighb_disc_ops_type_3 {
118 uint8_t prefix_len;
119 uint8_t l_a_res1;
120 uint32_t valid_lifetime;
121 uint32_t preferred_lifetime;
122 uint32_t res2;
123 struct in6_addr prefix;
124 } __packed;
126 struct icmpv6_neighb_disc_ops_type_4 {
127 uint16_t res1;
128 uint32_t res2;
129 uint8_t ip_hdr_data[0];
130 } __packed;
132 struct icmpv6_neighb_disc_ops_type_5 {
133 uint16_t res1;
134 uint32_t MTU;
135 } __packed;
137 struct icmpv6_neighb_disc_ops_type_9_10 {
138 uint16_t res1;
139 uint32_t res2;
140 uint8_t ip_hdr_data[0];
141 } __packed;
143 struct icmpv6_neighb_disc_ops_type_15 {
144 uint8_t name_type;
145 size_t pad_len;
146 char name[0];
147 uint8_t pad[0];
148 } __packed;
150 struct icmpv6_neighb_disc_ops_type_16 {
151 uint8_t cert_type;
152 uint8_t res;
153 uint8_t cert[0];
154 uint8_t pad[0];
155 } __packed;
157 struct icmpv6_neighb_disc_ops_type_17 {
158 uint8_t opt_code;
159 uint8_t prefix_len;
160 uint8_t data[0];
161 } __packed;
163 struct icmpv6_neighb_disc_ops_type_17_1 {
164 uint32_t res;
165 struct in6_addr ipv6_addr;
166 } __packed;
168 struct icmpv6_neighb_disc_ops_type_17_2 {
169 struct in6_addr ipv6_addr;
170 } __packed;
172 struct icmpv6_neighb_disc_ops_type_19 {
173 uint8_t opt_code;
174 uint8_t lla[0];
175 } __packed;
176 /* end Neighbor Discovery msg */
178 struct icmpv6_type_138 {
179 uint32_t seq_nr;
180 uint8_t seg_nr;
181 uint8_t flags;
182 uint16_t maxdelay;
183 uint32_t res;
184 } __packed;
186 /* Node Information Queries */
187 struct icmpv6_type_139_140 {
188 uint16_t qtype;
189 uint16_t flags;
190 uint64_t nonce;
191 uint8_t data[0];
192 } __packed;
193 /* end Node Information Queries */
195 /* MLDv2 report */
196 struct icmpv6_type_143 {
197 uint16_t res;
198 uint16_t nr_rec;
199 uint8_t addr_rec[0];
200 } __packed;
202 struct icmpv6_mldv2_addr_rec {
203 uint8_t rec_type;
204 uint8_t aux_data_len;
205 uint16_t nr_src;
206 struct in6_addr multic_addr;
207 struct in6_addr src_addr[0];
208 } __packed;
209 /* end MLDv2 report */
211 /* ICMP Mobility Support */
212 struct icmpv6_type_144_146 {
213 uint16_t id;
214 uint16_t res;
215 } __packed;
217 struct icmpv6_type_145 {
218 uint16_t id;
219 uint16_t res;
220 struct in6_addr home_agent_addr[0];
221 } __packed;
223 struct icmpv6_type_147 {
224 uint16_t id;
225 uint16_t m_o_res;
226 uint8_t ops[0];
227 } __packed;
228 /* end ICMP Mobility Support */
230 /* SEcure Neighbor Discovery */
231 struct icmpv6_type_148 {
232 uint16_t id;
233 uint16_t comp;
234 uint8_t ops[0];
235 } __packed;
237 struct icmpv6_type_149 {
238 uint16_t id;
239 uint16_t all_comp;
240 uint16_t comp;
241 uint16_t res;
242 uint8_t ops[0];
243 } __packed;
244 /* end SEcure Neighbor Discovery */
246 struct icmpv6_type_150 {
247 union {
248 uint32_t subtype_res;
249 struct {
250 #if defined(__LITTLE_ENDIAN_BITFIELD)
251 uint32_t res :24,
252 subtype :8;
253 #elif defined(__BIG_ENDIAN_BITFIELD)
254 uint32_t subtype :8,
255 res :24;
256 #else
257 # error "Please fix <asm/byteorder.h>"
258 #endif
261 uint8_t ops[0];
262 } __packed;
264 /* Multicast Router Discovery */
265 struct icmpv6_type_151 {
266 uint16_t query_intv;
267 uint16_t rob_var;
268 } __packed;
270 struct icmpv6_type_152 {
271 uint8_t null[0];
272 } __packed;
274 struct icmpv6_type_153 {
275 uint8_t null[0];
276 } __packed;
277 /* end Multicast Router Discovery */
279 struct icmpv6_type_154 {
280 uint8_t subtype;
281 uint8_t res;
282 uint16_t id;
283 uint8_t ops[0];
284 } __packed;
286 static inline void print_ipv6_addr_list(struct pkt_buff *pkt, uint8_t nr_addr)
288 char address[INET6_ADDRSTRLEN];
289 struct in6_addr *addr;
291 while (nr_addr--) {
292 addr = (struct in6_addr *) pkt_pull(pkt, sizeof(*addr));
293 if (addr == NULL)
294 return;
296 tprintf("\n\t Address: %s",
297 inet_ntop(AF_INET6, addr, address,
298 sizeof(address)));
302 static char *icmpv6_mcast_rec_types[] = {
303 "MODE_IS_INCLUDE",
304 "MODE_IS_EXCLUDE",
305 "CHANGE_TO_INCLUDE_MODE",
306 "CHANGE_TO_EXCLUDE_MODE",
307 "ALLOW_NEW_SOURCES",
308 "BLOCK_OLD_SOURCES",
311 static inline void dissect_icmpv6_mcast_rec(struct pkt_buff *pkt,
312 uint16_t nr_rec)
314 size_t aux_data_len_bytes;
315 uint16_t nr_src;
316 struct icmpv6_mldv2_addr_rec *addr_rec;
318 while (nr_rec--) {
319 addr_rec = (struct icmpv6_mldv2_addr_rec *)
320 pkt_pull(pkt,sizeof(*addr_rec));
321 if (addr_rec == NULL)
322 return;
323 aux_data_len_bytes = addr_rec->aux_data_len * 4;
324 nr_src = ntohs(addr_rec->nr_src);
326 tprintf(", Rec Type %s (%u)",
327 icmpv6_code_range_valid(addr_rec->rec_type - 1,
328 icmpv6_mcast_rec_types) ?
329 icmpv6_mcast_rec_types[addr_rec->rec_type - 1]
330 : "Unknown", addr_rec->rec_type);
331 tprintf(", Aux Data Len (%u, %u bytes)",addr_rec->aux_data_len,
332 aux_data_len_bytes);
333 tprintf(", Nr. of Sources (%u)",nr_src);
335 print_ipv6_addr_list(pkt, nr_src);
337 tprintf(", Aux Data: ");
338 while (aux_data_len_bytes--) {
339 tprintf("%x", *pkt_pull(pkt,1));
344 static inline void dissect_neighb_disc_ops_1(struct pkt_buff *pkt, size_t len)
346 struct icmpv6_neighb_disc_ops_type_1_2 *icmp_neighb_disc_1;
348 icmp_neighb_disc_1 = (struct icmpv6_neighb_disc_ops_type_1_2 *)
349 pkt_pull(pkt,sizeof(*icmp_neighb_disc_1));
350 if (icmp_neighb_disc_1 == NULL)
351 return;
352 len -= sizeof(*icmp_neighb_disc_1);
354 tprintf("Address 0x");
356 while(len--){
357 tprintf("%x", *pkt_pull(pkt,1));
361 static inline void dissect_neighb_disc_ops_2(struct pkt_buff *pkt, size_t len)
363 dissect_neighb_disc_ops_1(pkt, len);
366 static inline void dissect_neighb_disc_ops_3(struct pkt_buff *pkt, size_t len)
368 char address[INET6_ADDRSTRLEN];
369 struct icmpv6_neighb_disc_ops_type_3 *icmp_neighb_disc_3;
371 icmp_neighb_disc_3 = (struct icmpv6_neighb_disc_ops_type_3 *)
372 pkt_pull(pkt,sizeof(*icmp_neighb_disc_3));
373 if (icmp_neighb_disc_3 == NULL)
374 return;
375 len -= sizeof(*icmp_neighb_disc_3);
377 tprintf("Prefix Len (%u) ",icmp_neighb_disc_3->prefix_len);
378 tprintf("L (%u) A (%u) Res1 (0x%x) ",icmp_neighb_disc_3->l_a_res1 >> 7,
379 (icmp_neighb_disc_3->l_a_res1 >> 7) & 0x1,
380 icmp_neighb_disc_3->l_a_res1 & 0x3F);
381 tprintf("Valid Lifetime (%us) ",
382 ntohl(icmp_neighb_disc_3->valid_lifetime));
383 tprintf("Preferred Lifetime (%us) ",
384 ntohl(icmp_neighb_disc_3->preferred_lifetime));
385 tprintf("Reserved2 (0x%x) ",
386 ntohl(icmp_neighb_disc_3->res2));
387 tprintf("Prefix: %s ",
388 inet_ntop(AF_INET6,&icmp_neighb_disc_3->prefix,
389 address, sizeof(address)));
392 static inline void dissect_neighb_disc_ops_4(struct pkt_buff *pkt, size_t len)
394 struct icmpv6_neighb_disc_ops_type_4 *icmp_neighb_disc_4;
396 icmp_neighb_disc_4 = (struct icmpv6_neighb_disc_ops_type_4 *)
397 pkt_pull(pkt,sizeof(*icmp_neighb_disc_4));
398 if (icmp_neighb_disc_4 == NULL)
399 return;
400 len -= sizeof(*icmp_neighb_disc_4);
402 tprintf("Reserved 1 (0x%x) ", ntohs(icmp_neighb_disc_4->res1));
403 tprintf("Reserved 2 (0x%x) ", ntohl(icmp_neighb_disc_4->res2));
404 tprintf("IP header + data ");
406 while (len--) {
407 tprintf("%x", *pkt_pull(pkt,1));
411 static inline void dissect_neighb_disc_ops_5(struct pkt_buff *pkt, size_t len)
413 struct icmpv6_neighb_disc_ops_type_5 *icmp_neighb_disc_5;
415 icmp_neighb_disc_5 = (struct icmpv6_neighb_disc_ops_type_5 *)
416 pkt_pull(pkt,sizeof(*icmp_neighb_disc_5));
417 if (icmp_neighb_disc_5 == NULL)
418 return;
419 len -= sizeof(*icmp_neighb_disc_5);
421 tprintf("Reserved (0x%x) ", ntohs(icmp_neighb_disc_5->res1));
422 tprintf("MTU (%u)", ntohl(icmp_neighb_disc_5->MTU));
425 static inline void dissect_neighb_disc_ops_9(struct pkt_buff *pkt, size_t len)
427 struct icmpv6_neighb_disc_ops_type_9_10 *icmp_neighb_disc_9;
429 icmp_neighb_disc_9 = (struct icmpv6_neighb_disc_ops_type_9_10 *)
430 pkt_pull(pkt,sizeof(*icmp_neighb_disc_9));
431 if (icmp_neighb_disc_9 == NULL)
432 return;
433 len -= sizeof(*icmp_neighb_disc_9);
435 tprintf("Reserved 1 (0x%x) ", ntohs(icmp_neighb_disc_9->res1));
436 tprintf("Reserved 2 (0x%x) ", ntohl(icmp_neighb_disc_9->res2));
438 print_ipv6_addr_list(pkt, len / sizeof(struct in6_addr));
441 static inline void dissect_neighb_disc_ops_10(struct pkt_buff *pkt, size_t len)
443 dissect_neighb_disc_ops_9(pkt, len);
446 static char *icmpv6_neighb_disc_ops_15_name[] = {
447 "DER Encoded X.501 Name",
448 "FQDN",
451 static inline void dissect_neighb_disc_ops_15(struct pkt_buff *pkt, size_t len)
453 uint8_t name_len, pad_len;
454 struct icmpv6_neighb_disc_ops_type_15 *icmp_neighb_disc_15;
456 icmp_neighb_disc_15 = (struct icmpv6_neighb_disc_ops_type_15 *)
457 pkt_pull(pkt,sizeof(*icmp_neighb_disc_15));
458 if (icmp_neighb_disc_15 == NULL)
459 return;
460 len -= sizeof(*icmp_neighb_disc_15);
461 pad_len = icmp_neighb_disc_15->pad_len;
462 name_len = len - pad_len;
464 tprintf("Name Type %s (%u) ",
465 icmpv6_code_range_valid(icmp_neighb_disc_15->name_type - 1,
466 icmpv6_neighb_disc_ops_15_name) ?
467 icmpv6_neighb_disc_ops_15_name[
468 icmp_neighb_disc_15->name_type - 1] : "Unknown",
469 icmp_neighb_disc_15->name_type);
470 tprintf("Pad Len (0x%x) ", icmp_neighb_disc_15->pad_len);
472 tprintf("Name (");
473 while (name_len--) {
474 tprintf("%c", *pkt_pull(pkt,1));
476 tprintf(") ");
478 tprintf("Padding (");
480 while (pad_len--) {
481 tprintf("%x", *pkt_pull(pkt,1));
483 tprintf(")");
486 static char *icmpv6_neighb_disc_ops_16_cert[] = {
487 "X.509v3 Certificate",
490 static inline void dissect_neighb_disc_ops_16(struct pkt_buff *pkt, size_t len)
492 struct icmpv6_neighb_disc_ops_type_16 *icmp_neighb_disc_16;
494 icmp_neighb_disc_16 = (struct icmpv6_neighb_disc_ops_type_16 *)
495 pkt_pull(pkt,sizeof(*icmp_neighb_disc_16));
496 if (icmp_neighb_disc_16 == NULL)
497 return;
498 len -= sizeof(*icmp_neighb_disc_16);
500 tprintf("Cert Type %s (%u) ",
501 icmpv6_code_range_valid(icmp_neighb_disc_16->cert_type - 1,
502 icmpv6_neighb_disc_ops_16_cert) ?
503 icmpv6_neighb_disc_ops_16_cert[
504 icmp_neighb_disc_16->cert_type - 1] : "Unknown",
505 icmp_neighb_disc_16->cert_type);
506 tprintf("Res (0x%x) ", icmp_neighb_disc_16->res);
508 tprintf("Certificate + Padding (");
509 while (len--) {
510 tprintf("%x", *pkt_pull(pkt,1));
512 tprintf(") ");
515 static char *icmpv6_neighb_disc_ops_17_codes[] = {
516 "Old Care-of Address",
517 "New Care-of Address",
518 "NAR's IP address",
519 "NAR's Prefix",
522 static inline void dissect_neighb_disc_ops_17(struct pkt_buff *pkt, size_t len)
524 char address[INET6_ADDRSTRLEN];
525 struct icmpv6_neighb_disc_ops_type_17 *icmp_neighb_disc_17;
527 icmp_neighb_disc_17 = (struct icmpv6_neighb_disc_ops_type_17 *)
528 pkt_pull(pkt,sizeof(*icmp_neighb_disc_17));
529 if (icmp_neighb_disc_17 == NULL)
530 return;
531 len -= sizeof(*icmp_neighb_disc_17);
533 tprintf("Opt Code %s (%u) ",
534 icmpv6_code_range_valid(icmp_neighb_disc_17->opt_code - 1,
535 icmpv6_neighb_disc_ops_17_codes) ?
536 icmpv6_neighb_disc_ops_17_codes[
537 icmp_neighb_disc_17->opt_code - 1] : "Unknown",
538 icmp_neighb_disc_17->opt_code);
539 tprintf("Prefix Len (%u) ", icmp_neighb_disc_17->prefix_len);
541 if (len == sizeof(struct icmpv6_neighb_disc_ops_type_17_1)) {
542 struct icmpv6_neighb_disc_ops_type_17_1
543 *icmp_neighb_disc_17_1;
545 icmp_neighb_disc_17_1 =
546 (struct icmpv6_neighb_disc_ops_type_17_1 *)
547 pkt_pull(pkt,sizeof(*icmp_neighb_disc_17_1));
548 if (icmp_neighb_disc_17_1 == NULL)
549 return;
550 len -= sizeof(*icmp_neighb_disc_17_1);
552 tprintf("Res (0x%x) ",icmp_neighb_disc_17_1->res);
553 tprintf("Addr: %s ",
554 inet_ntop(AF_INET6,&icmp_neighb_disc_17_1->ipv6_addr,
555 address, sizeof(address)));
557 else if (len == sizeof(struct icmpv6_neighb_disc_ops_type_17_1)) {
558 struct icmpv6_neighb_disc_ops_type_17_2
559 *icmp_neighb_disc_17_2;
561 icmp_neighb_disc_17_2 =
562 (struct icmpv6_neighb_disc_ops_type_17_2 *)
563 pkt_pull(pkt,sizeof(*icmp_neighb_disc_17_2));
564 if (icmp_neighb_disc_17_2 == NULL)
565 return;
566 len -= sizeof(*icmp_neighb_disc_17_2);
568 tprintf("Addr: %s ",
569 inet_ntop(AF_INET6,&icmp_neighb_disc_17_2->ipv6_addr,
570 address, sizeof(address)));
573 tprintf("Error Wrong Params (");
574 while (len--) {
575 tprintf("%x", *pkt_pull(pkt,1));
577 tprintf(") ");
580 static char *icmpv6_neighb_disc_ops_19_codes[] = {
581 "Wildcard requesting resolution for all nearby access points",
582 "Link-Layer Address of the New Access Point",
583 "Link-Layer Address of the MN",
584 "Link-Layer Address of the NAR",
585 "Link-Layer Address of the source of RtSolPr or PrRtAdv \
586 message",
587 "The access point identified by the LLA belongs to the \
588 current interface of the router",
589 "No prefix information available for the access point \
590 identified by the LLA",
591 "No fast handover support available for the access point \
592 identified by the LLA",
595 static inline void dissect_neighb_disc_ops_19(struct pkt_buff *pkt, size_t len)
597 struct icmpv6_neighb_disc_ops_type_19 *icmp_neighb_disc_19;
599 icmp_neighb_disc_19 = (struct icmpv6_neighb_disc_ops_type_19 *)
600 pkt_pull(pkt,sizeof(*icmp_neighb_disc_19));
601 if (icmp_neighb_disc_19 == NULL)
602 return;
603 len -= sizeof(*icmp_neighb_disc_19);
605 tprintf("Opt Code %s (%u) ",
606 icmpv6_code_range_valid(icmp_neighb_disc_19->opt_code,
607 icmpv6_neighb_disc_ops_19_codes) ?
608 icmpv6_neighb_disc_ops_19_codes[
609 icmp_neighb_disc_19->opt_code] : "Unknown",
610 icmp_neighb_disc_19->opt_code);
612 tprintf("LLA (");
613 while(len--){
614 tprintf("%x", *pkt_pull(pkt,1));
616 tprintf(") ");
619 static inline char *icmpv6_neighb_disc_ops(uint8_t code) {
620 switch (code) {
621 case 1:
622 return "Source Link-Layer Address";
623 case 2:
624 return "Target Link-Layer Address";
625 case 3:
626 return "Prefix Information";
627 case 4:
628 return "Redirected Header";
629 case 5:
630 return "MTU";
631 case 6:
632 return "NBMA Shortcut Limit Option";
633 case 7:
634 return "Advertisement Interval Option";
635 case 8:
636 return "Home Agent Information Option";
637 case 9:
638 return "Source Address List";
639 case 10:
640 return "Target Address List";
641 case 11:
642 return "CGA option";
643 case 12:
644 return "RSA Signature option";
645 case 13:
646 return "Timestamp option";
647 case 14:
648 return "Nonce option";
649 case 15:
650 return "Trust Anchor option";
651 case 16:
652 return "Certificate option";
653 case 17:
654 return "IP Address/Prefix Option";
655 case 18:
656 return "New Router Prefix Information Option";
657 case 19:
658 return "Link-layer Address Option";
659 case 20:
660 return "Neighbor Advertisement Acknowledgment Option";
662 case 23:
663 return "Prefix Information";
664 case 24:
665 return "Redirected Header";
666 case 25:
667 return "MTU";
668 case 26:
669 return "NBMA Shortcut Limit Option";
670 case 27:
671 return "Advertisement Interval Option";
672 case 28:
673 return "Home Agent Information Option";
674 case 29:
675 return "Source Address List";
676 case 30:
677 return "Target Address List";
678 case 31:
679 return "DNS Search List Option";
680 case 32:
681 return "Proxy Signature (PS)";
683 case 138:
684 return "CARD Request option";
685 case 139:
686 return "CARD Reply option";
688 case 253:
689 return "RFC3692-style Experiment 1";
690 case 254:
691 return "RFC3692-style Experiment 2";
694 return NULL;
697 static inline void dissect_neighb_disc_ops(struct pkt_buff *pkt)
699 size_t ops_total_len, ops_payl_len, pad_bytes;
700 struct icmpv6_neighb_disc_ops_general *icmp_neighb_disc;
702 while(pkt_len(pkt)) {
703 icmp_neighb_disc = (struct icmpv6_neighb_disc_ops_general *)
704 pkt_pull(pkt,sizeof(*icmp_neighb_disc));
705 if (icmp_neighb_disc == NULL)
706 return;
708 ops_total_len = icmp_neighb_disc->len * 8;
709 pad_bytes = ops_total_len % 8;
710 ops_payl_len = ops_total_len - sizeof(*icmp_neighb_disc) -
711 pad_bytes;
713 tprintf("\n\tOption %s (%u) ",
714 icmpv6_neighb_disc_ops(icmp_neighb_disc->type) ?
715 icmpv6_neighb_disc_ops(icmp_neighb_disc->type)
716 : "Type Unknown", icmp_neighb_disc->type);
717 tprintf("Length (%u, %u bytes) ", icmp_neighb_disc->len,
718 ops_total_len);
720 switch (icmp_neighb_disc->type) {
721 case 1:
722 dissect_neighb_disc_ops_1(pkt, ops_payl_len);
723 break;
724 case 2:
725 dissect_neighb_disc_ops_2(pkt, ops_payl_len);
726 break;
727 case 3:
728 dissect_neighb_disc_ops_3(pkt, ops_payl_len);
729 break;
730 case 4:
731 dissect_neighb_disc_ops_4(pkt, ops_payl_len);
732 break;
733 case 5:
734 dissect_neighb_disc_ops_5(pkt, ops_payl_len);
735 break;
736 /* Type 9 and 10 defined in
737 * http://tools.ietf.org/html/rfc3122#section-3.1
739 case 9:
740 dissect_neighb_disc_ops_9(pkt, ops_payl_len);
741 break;
742 case 10:
743 dissect_neighb_disc_ops_10(pkt, ops_payl_len);
744 break;
745 /* Type 15 and 16 defined in
746 * http://tools.ietf.org/html/rfc3971#section-6.4.3
747 * http://tools.ietf.org/html/rfc3971#section-6.4.4
749 case 15:
750 dissect_neighb_disc_ops_15(pkt, ops_payl_len);
751 break;
752 case 16:
753 dissect_neighb_disc_ops_16(pkt, ops_payl_len);
754 break;
755 /* Type 17 and 19 defined in
756 * http://tools.ietf.org/html/rfc5568#section-6.4
758 case 17:
759 dissect_neighb_disc_ops_17(pkt, ops_payl_len);
760 break;
761 case 19:
762 dissect_neighb_disc_ops_19(pkt, ops_payl_len);
763 break;
764 default:
765 pkt_pull(pkt, ops_payl_len);
768 /* Skip Padding Bytes */
769 pkt_pull(pkt, pad_bytes);
773 static char *icmpv6_type_1_codes[] = {
774 "No route to destination",
775 "Communication with destination administratively prohibited",
776 "Beyond scope of source address",
777 "Address unreachable",
778 "Port unreachable",
779 "Source address failed ingress/egress policy",
780 "Reject route to destination",
781 "Error in Source Routing Header",
784 static inline void dissect_icmpv6_type1(struct pkt_buff *pkt)
786 struct icmpv6_type_1_3 *icmp_1;
788 icmp_1 = (struct icmpv6_type_1_3 *) pkt_pull(pkt,sizeof(*icmp_1));
789 if (icmp_1 == NULL)
790 return;
792 tprintf(", Unused (0x%x)",ntohl(icmp_1->unused));
793 tprintf(" Payload include as much of invoking packet");
796 static inline void dissect_icmpv6_type2(struct pkt_buff *pkt)
798 struct icmpv6_type_2 *icmp_2;
800 icmp_2 = (struct icmpv6_type_2 *) pkt_pull(pkt,sizeof(*icmp_2));
801 if (icmp_2 == NULL)
802 return;
804 tprintf(", MTU (0x%x)",ntohl(icmp_2->MTU));
805 tprintf(" Payload include as much of invoking packet");
808 static char *icmpv6_type_3_codes[] = {
809 "Hop limit exceeded in transit",
810 "Fragment reassembly time exceeded",
813 static inline void dissect_icmpv6_type3(struct pkt_buff *pkt)
815 struct icmpv6_type_1_3 *icmp_3;
817 icmp_3 = (struct icmpv6_type_1_3 *) pkt_pull(pkt,sizeof(*icmp_3));
818 if (icmp_3 == NULL)
819 return;
821 tprintf(", Unused (0x%x)",ntohl(icmp_3->unused));
822 tprintf(" Payload include as much of invoking packet");
825 static char *icmpv6_type_4_codes[] = {
826 "Erroneous header field encountered",
827 "Unrecognized Next Header type encountered",
828 "Unrecognized IPv6 option encountered",
831 static inline void dissect_icmpv6_type4(struct pkt_buff *pkt)
833 struct icmpv6_type_4 *icmp_4;
835 icmp_4 = (struct icmpv6_type_4 *) pkt_pull(pkt,sizeof(*icmp_4));
836 if (icmp_4 == NULL)
837 return;
839 tprintf(", Pointer (0x%x)",ntohl(icmp_4->pointer));
840 tprintf(" Payload include as much of invoking packet");
843 static inline void dissect_icmpv6_type128(struct pkt_buff *pkt)
845 struct icmpv6_type_128_129 *icmp_128;
847 icmp_128 = (struct icmpv6_type_128_129 *)
848 pkt_pull(pkt,sizeof(*icmp_128));
849 if (icmp_128 == NULL)
850 return;
852 tprintf(", ID (0x%x)",ntohs(icmp_128->id));
853 tprintf(", Seq. Nr. (%u)",ntohs(icmp_128->sn));
854 tprintf(" Payload include Data");
857 static inline void dissect_icmpv6_type129(struct pkt_buff *pkt)
859 struct icmpv6_type_128_129 *icmp_129;
861 icmp_129 = (struct icmpv6_type_128_129 *)
862 pkt_pull(pkt,sizeof(*icmp_129));
863 if (icmp_129 == NULL)
864 return;
866 tprintf(", ID (0x%x)",ntohs(icmp_129->id));
867 tprintf(", Seq. Nr. (%u)",ntohs(icmp_129->sn));
868 tprintf(" Payload include Data");
871 static inline void dissect_icmpv6_type130(struct pkt_buff *pkt)
873 char address[INET6_ADDRSTRLEN];
874 uint16_t nr_src, maxrespdel;
875 uint8_t switch_mldv2 = 0;
876 struct icmpv6_type_130_131_132 *icmp_130;
878 icmp_130 = (struct icmpv6_type_130_131_132 *)
879 pkt_pull(pkt,sizeof(*icmp_130));
880 if (icmp_130 == NULL)
881 return;
882 maxrespdel = ntohs(icmp_130->maxrespdel);
884 if(pkt_len(pkt) >= sizeof(struct icmpv6_type_130_mldv2))
885 switch_mldv2 = 1;
887 if(switch_mldv2)
888 tprintf(", MLDv2, Max Resp Delay (%ums)", maxrespdel >> 15 ?
889 (((maxrespdel & 0xFFF) | 0x1000) <<
890 (((maxrespdel >> 12) & 0x3) + 3)) : maxrespdel);
891 else
892 tprintf(", Max Resp Delay (%ums)",maxrespdel);
893 tprintf(", Res (0x%x)",ntohs(icmp_130->res));
894 tprintf(", Address: %s",
895 inet_ntop(AF_INET6, &icmp_130->ipv6_addr,
896 address, sizeof(address)));
898 if(switch_mldv2) {
899 struct icmpv6_type_130_mldv2 *icmp_130_mldv2;
901 icmp_130_mldv2 = (struct icmpv6_type_130_mldv2 *)
902 pkt_pull(pkt,sizeof(*icmp_130_mldv2));
903 if (icmp_130_mldv2 == NULL)
904 return;
906 nr_src = ntohs(icmp_130_mldv2->nr_src);
908 tprintf(", Resv (0x%x)",icmp_130_mldv2->resv_S_QRV >> 4);
909 tprintf(", S (%u)",(icmp_130_mldv2->resv_S_QRV >> 3) & 0x1);
910 tprintf(", QRV (0x%x)",icmp_130_mldv2->resv_S_QRV & 0x3);
911 tprintf(", QQIC (%u)",icmp_130_mldv2->QQIC);
912 tprintf(", Nr Src (0x%x)",nr_src);
914 print_ipv6_addr_list(pkt, nr_src);
918 static inline void dissect_icmpv6_type131(struct pkt_buff *pkt)
920 char address[INET6_ADDRSTRLEN];
921 struct icmpv6_type_130_131_132 *icmp_131;
923 icmp_131 = (struct icmpv6_type_130_131_132 *)
924 pkt_pull(pkt,sizeof(*icmp_131));
925 if (icmp_131 == NULL)
926 return;
928 tprintf(", Max Resp Delay (%ums)",ntohs(icmp_131->maxrespdel));
929 tprintf(", Res (0x%x)",ntohs(icmp_131->res));
930 tprintf(", Address: %s",
931 inet_ntop(AF_INET6, &icmp_131->ipv6_addr,
932 address, sizeof(address)));
935 static inline void dissect_icmpv6_type132(struct pkt_buff *pkt)
937 dissect_icmpv6_type131(pkt);
940 static inline void dissect_icmpv6_type133(struct pkt_buff *pkt)
942 struct icmpv6_type_133_141_142 *icmp_133;
944 icmp_133 = (struct icmpv6_type_133_141_142 *)
945 pkt_pull(pkt,sizeof(*icmp_133));
946 if (icmp_133 == NULL)
947 return;
949 tprintf(", Reserved (0x%x)",ntohl(icmp_133->res));
951 dissect_neighb_disc_ops(pkt);
954 static inline void dissect_icmpv6_type134(struct pkt_buff *pkt)
956 struct icmpv6_type_134 *icmp_134;
958 icmp_134 = (struct icmpv6_type_134 *)
959 pkt_pull(pkt,sizeof(*icmp_134));
960 if (icmp_134 == NULL)
961 return;
963 tprintf(", Cur Hop Limit (%u)",icmp_134->cur_hop_limit);
964 tprintf(", M (%u) O (%u)",icmp_134->m_o_res >> 7,
965 (icmp_134->m_o_res >> 6) & 0x1);
966 tprintf(", Router Lifetime (%us)",ntohs(icmp_134->router_lifetime));
967 tprintf(", Reachable Time (%ums)",ntohl(icmp_134->reachable_time));
968 tprintf(", Retrans Timer (%ums)",ntohl(icmp_134->retrans_timer));
970 dissect_neighb_disc_ops(pkt);
973 static inline void dissect_icmpv6_type135(struct pkt_buff *pkt)
975 char address[INET6_ADDRSTRLEN];
976 struct icmpv6_type_135 *icmp_135;
978 icmp_135 = (struct icmpv6_type_135 *)
979 pkt_pull(pkt,sizeof(*icmp_135));
980 if (icmp_135 == NULL)
981 return;
983 tprintf(", Reserved (0x%x)",ntohl(icmp_135->res));
984 tprintf(", Target Address: %s",
985 inet_ntop(AF_INET6, &icmp_135->ipv6_addr,
986 address, sizeof(address)));
988 dissect_neighb_disc_ops(pkt);
991 static inline void dissect_icmpv6_type136(struct pkt_buff *pkt)
993 char address[INET6_ADDRSTRLEN];
994 uint32_t r_s_o_res;
995 struct icmpv6_type_136 *icmp_136;
997 icmp_136 = (struct icmpv6_type_136 *)
998 pkt_pull(pkt,sizeof(*icmp_136));
999 if (icmp_136 == NULL)
1000 return;
1001 r_s_o_res = ntohl(icmp_136->r_s_o_res);
1003 tprintf(", R (%u) S (%u) O (%u) Reserved (0x%x)", r_s_o_res >> 31,
1004 (r_s_o_res >> 30) & 0x1, (r_s_o_res >> 29) & 0x1,
1005 r_s_o_res & 0x1FFFFFFF);
1006 tprintf(", Target Address: %s",
1007 inet_ntop(AF_INET6, &icmp_136->ipv6_addr,
1008 address, sizeof(address)));
1010 dissect_neighb_disc_ops(pkt);
1013 static inline void dissect_icmpv6_type137(struct pkt_buff *pkt)
1015 char address[INET6_ADDRSTRLEN];
1016 struct icmpv6_type_137 *icmp_137;
1018 icmp_137 = (struct icmpv6_type_137 *)
1019 pkt_pull(pkt,sizeof(*icmp_137));
1020 if (icmp_137 == NULL)
1021 return;
1023 tprintf(", Reserved (0x%x)",icmp_137->res);
1024 tprintf(", Target Address: %s",
1025 inet_ntop(AF_INET6, &icmp_137->ipv6_targ_addr,
1026 address, sizeof(address)));
1027 tprintf(", Dest Address: %s",
1028 inet_ntop(AF_INET6, &icmp_137->ipv6_dest_addr,
1029 address, sizeof(address)));
1031 dissect_neighb_disc_ops(pkt);
1034 static inline void dissect_icmpv6_rr_body(struct pkt_buff *pkt)
1037 * Upgrade Dissector for Message Body
1038 * from http://tools.ietf.org/html/rfc2894#section-3.2
1040 if(pkt_len(pkt))
1041 tprintf(" Message Body recognized");
1044 static inline char *icmpv6_type_138_codes(uint8_t code) {
1045 switch (code) {
1046 case 1:
1047 return "Router Renumbering Command";
1048 case 2:
1049 return "Router Renumbering Result";
1050 case 255:
1051 return "Sequence Number Reset";
1054 return NULL;
1057 static inline void dissect_icmpv6_type138(struct pkt_buff *pkt)
1059 struct icmpv6_type_138 *icmp_138;
1061 icmp_138 = (struct icmpv6_type_138 *)
1062 pkt_pull(pkt,sizeof(*icmp_138));
1063 if (icmp_138 == NULL)
1064 return;
1066 tprintf(", Sequence Nr. (%u)",ntohl(icmp_138->seq_nr));
1067 tprintf(", Segment Nr. (%u)",icmp_138->seg_nr);
1068 tprintf(", T (%u) R (%u) A (%u) S (%u) P (%u) Res \
1069 (0x%x) ",icmp_138->flags >> 7, (icmp_138->flags >> 6) & 1,
1070 (icmp_138->flags >> 5) & 1, (icmp_138->flags >> 4) & 1,
1071 (icmp_138->flags >> 3) & 1, icmp_138->flags & 7);
1072 tprintf(", Max Delay (%ums)", ntohs(icmp_138->maxdelay));
1073 tprintf(", Res (0x%x)", ntohl(icmp_138->res));
1075 dissect_icmpv6_rr_body(pkt);
1078 static inline void dissect_icmpv6_node_inf_data(struct pkt_buff *pkt)
1081 * Upgrade Dissector for Data field
1082 * http://tools.ietf.org/html/rfc4620#section-4
1084 if(pkt_len(pkt))
1085 tprintf(" Data recognized");
1088 static char *icmpv6_node_inf_qtypes[] = {
1089 "NOOP",
1090 "unused",
1091 "Node Name",
1092 "Node Addresses",
1093 "IPv4 Addresses ",
1096 static char *icmpv6_type_139_codes[] = {
1097 "Data contains IPv6 Address",
1098 "Data contains Name or nothing",
1099 "Data contains IPv4 Address",
1102 static inline void dissect_icmpv6_type139(struct pkt_buff *pkt)
1104 char *qtype_name = "Unknown";
1105 uint16_t qtype_nr;
1106 struct icmpv6_type_139_140 *icmp_139;
1108 icmp_139 = (struct icmpv6_type_139_140 *)
1109 pkt_pull(pkt,sizeof(*icmp_139));
1110 if (icmp_139 == NULL)
1111 return;
1113 qtype_nr = ntohs(icmp_139->qtype);
1114 if (icmpv6_code_range_valid(qtype_nr, icmpv6_node_inf_qtypes))
1115 qtype_name = icmpv6_node_inf_qtypes[qtype_nr];
1117 tprintf(", Qtype %s (%u)",qtype_name, qtype_nr);
1118 tprintf(", Flags (0x%x)",ntohs(icmp_139->flags));
1119 tprintf(", Nonce (0x%x)",ntohll(icmp_139->nonce));
1121 dissect_icmpv6_node_inf_data(pkt);
1124 static char *icmpv6_type_140_codes[] = {
1125 "Successfull reply",
1126 "Responder refuses answer",
1127 "Qtype is unknown to the Responder",
1130 static inline void dissect_icmpv6_type140(struct pkt_buff *pkt)
1132 dissect_icmpv6_type139(pkt);
1135 static inline void dissect_icmpv6_type141(struct pkt_buff *pkt)
1137 dissect_icmpv6_type133(pkt);
1140 static inline void dissect_icmpv6_type142(struct pkt_buff *pkt)
1142 dissect_icmpv6_type133(pkt);
1145 static inline void dissect_icmpv6_type143(struct pkt_buff *pkt)
1147 uint16_t nr_rec;
1148 struct icmpv6_type_143 *icmp_143;
1150 icmp_143 = (struct icmpv6_type_143 *)
1151 pkt_pull(pkt,sizeof(*icmp_143));
1152 if (icmp_143 == NULL)
1153 return;
1154 nr_rec = ntohs(icmp_143->nr_rec);
1156 tprintf(", Res (0x%x)",ntohs(icmp_143->res));
1157 tprintf(", Nr. Mcast Addr Records (%u)",nr_rec);
1159 dissect_icmpv6_mcast_rec(pkt, nr_rec);
1162 static inline void dissect_icmpv6_type144(struct pkt_buff *pkt)
1164 struct icmpv6_type_144_146 *icmp_144;
1166 icmp_144 = (struct icmpv6_type_144_146 *)
1167 pkt_pull(pkt,sizeof(*icmp_144));
1168 if (icmp_144 == NULL)
1169 return;
1171 tprintf(", ID (%u)",ntohs(icmp_144->id));
1172 tprintf(", Res (0x%x)",ntohs(icmp_144->res));
1175 static inline void dissect_icmpv6_type145(struct pkt_buff *pkt)
1177 struct icmpv6_type_145 *icmp_145;
1179 icmp_145 = (struct icmpv6_type_145 *)
1180 pkt_pull(pkt,sizeof(*icmp_145));
1181 if (icmp_145 == NULL)
1182 return;
1184 tprintf(", ID (%u)",ntohs(icmp_145->id));
1185 tprintf(", Res (0x%x)",ntohs(icmp_145->res));
1187 print_ipv6_addr_list(pkt, pkt_len(pkt) / sizeof(struct in6_addr));
1190 static inline void dissect_icmpv6_type146(struct pkt_buff *pkt)
1192 dissect_icmpv6_type144(pkt);
1195 static inline void dissect_icmpv6_type147(struct pkt_buff *pkt)
1197 uint16_t m_o_res;
1198 struct icmpv6_type_147 *icmp_147;
1200 icmp_147 = (struct icmpv6_type_147 *)
1201 pkt_pull(pkt,sizeof(*icmp_147));
1202 if (icmp_147 == NULL)
1203 return;
1204 m_o_res = ntohs(icmp_147->m_o_res);
1206 tprintf(", ID (%u)",ntohs(icmp_147->id));
1207 tprintf(", M (%u) O (%u) Res (0x%x)",m_o_res >> 15,
1208 (m_o_res >> 14) & 1, m_o_res & 0x3FFF);
1210 dissect_neighb_disc_ops(pkt);
1213 static inline void dissect_icmpv6_type148(struct pkt_buff *pkt)
1215 struct icmpv6_type_148 *icmp_148;
1217 icmp_148 = (struct icmpv6_type_148 *)
1218 pkt_pull(pkt,sizeof(*icmp_148));
1219 if (icmp_148 == NULL)
1220 return;
1222 tprintf(", ID (%u)",ntohs(icmp_148->id));
1223 tprintf(", Component (%u)",ntohs(icmp_148->comp));
1225 dissect_neighb_disc_ops(pkt);
1228 static inline void dissect_icmpv6_type149(struct pkt_buff *pkt)
1230 struct icmpv6_type_149 *icmp_149;
1232 icmp_149 = (struct icmpv6_type_149 *)
1233 pkt_pull(pkt,sizeof(*icmp_149));
1234 if (icmp_149 == NULL)
1235 return;
1237 tprintf(", ID (%u)",ntohs(icmp_149->id));
1238 tprintf(", All Components (%u)",ntohs(icmp_149->all_comp));
1239 tprintf(", Component (%u)",ntohs(icmp_149->comp));
1240 tprintf(", Res (0x%x)",ntohs(icmp_149->res));
1242 dissect_neighb_disc_ops(pkt);
1245 static inline void dissect_icmpv6_type150(struct pkt_buff *pkt)
1247 struct icmpv6_type_150 *icmp_150;
1249 icmp_150 = (struct icmpv6_type_150 *)
1250 pkt_pull(pkt,sizeof(*icmp_150));
1251 if (icmp_150 == NULL)
1252 return;
1254 tprintf(", Subtype (%u)",icmp_150->subtype);
1255 tprintf(", Res (0x%x)",icmp_150->res);
1256 tprintf(", Options in Payload");
1259 static inline void dissect_icmpv6_type151(struct pkt_buff *pkt)
1261 struct icmpv6_type_151 *icmp_151;
1263 icmp_151 = (struct icmpv6_type_151 *)
1264 pkt_pull(pkt,sizeof(*icmp_151));
1265 if (icmp_151 == NULL)
1266 return;
1268 tprintf(", Query Interval (%us)",ntohs(icmp_151->query_intv));
1269 tprintf(", Robustness Variable (%u)",ntohs(icmp_151->rob_var));
1272 static inline void dissect_icmpv6_type152(struct pkt_buff *pkt)
1274 struct icmpv6_type_152 *icmp_152;
1276 icmp_152 = (struct icmpv6_type_152 *)
1277 pkt_pull(pkt,sizeof(*icmp_152));
1278 if (icmp_152 == NULL)
1279 return;
1282 static inline void dissect_icmpv6_type153(struct pkt_buff *pkt)
1284 struct icmpv6_type_153 *icmp_153;
1286 icmp_153 = (struct icmpv6_type_153 *)
1287 pkt_pull(pkt,sizeof(*icmp_153));
1288 if (icmp_153 == NULL)
1289 return;
1292 static inline void dissect_icmpv6_type154(struct pkt_buff *pkt)
1294 struct icmpv6_type_154 *icmp_154;
1296 icmp_154 = (struct icmpv6_type_154 *)
1297 pkt_pull(pkt,sizeof(*icmp_154));
1298 if (icmp_154 == NULL)
1299 return;
1301 tprintf(", Subtype (%u)",icmp_154->subtype);
1302 tprintf(", Res (0x%x)",icmp_154->res);
1303 tprintf(", ID (%u)",ntohs(icmp_154->id));
1305 dissect_neighb_disc_ops(pkt);
1308 static inline char *icmpv6_type_155_codes(uint8_t code) {
1309 switch (code) {
1310 case 0x00:
1311 return "DODAG Information Solicitation";
1312 case 0x01:
1313 return "DODAG Information Object";
1314 case 0x02:
1315 return "Destination Advertisement Object";
1316 case 0x03:
1317 return "Destination Advertisement Object Acknowledgment";
1318 case 0x80:
1319 return "Secure DODAG Information Solicitation";
1320 case 0x81:
1321 return "Secure DODAG Information Object";
1322 case 0x82:
1323 return "Secure Destination Advertisement Object";
1324 case 0x83:
1325 return "Secure Destination Advertisement Object Acknowledgment";
1326 case 0x8A:
1327 return "Consistency Check";
1330 return NULL;
1333 static inline void icmpv6_process(struct icmpv6_general_hdr *icmp, char **type,
1334 char **code,
1335 void (**optional)(struct pkt_buff *pkt))
1337 *type = "Unknown Type";
1338 *code = "Unknown Code";
1340 switch (icmp->h_type) {
1341 case 1:
1342 *type = "Destination Unreachable";
1343 if (icmpv6_code_range_valid(icmp->h_code, icmpv6_type_1_codes))
1344 *code = icmpv6_type_1_codes[icmp->h_code];
1345 *optional = dissect_icmpv6_type1;
1346 return;
1347 case 2:
1348 *type = "Packet Too Big";
1349 *optional = dissect_icmpv6_type2;
1350 return;
1351 case 3:
1352 *type = "Time Exceeded";
1353 if (icmpv6_code_range_valid(icmp->h_code, icmpv6_type_3_codes))
1354 *code = icmpv6_type_3_codes[icmp->h_code];
1355 *optional = dissect_icmpv6_type3;
1356 return;
1357 case 4:
1358 *type = "Parameter Problem";
1359 if (icmpv6_code_range_valid(icmp->h_code, icmpv6_type_4_codes))
1360 *code = icmpv6_type_4_codes[icmp->h_code];
1361 *optional = dissect_icmpv6_type4;
1362 return;
1363 case 100:
1364 *type = "Private experimation";
1365 return;
1366 case 101:
1367 *type = "Private experimation";
1368 return;
1369 case 127:
1370 *type = "Reserved for expansion of ICMPv6 error messages";
1371 return;
1372 case 128:
1373 *type = "Echo Request";
1374 *optional = dissect_icmpv6_type128;
1375 return;
1376 case 129:
1377 *type = "Echo Reply";
1378 *optional = dissect_icmpv6_type129;
1379 return;
1380 case 130:
1381 *type = "Multicast Listener Query";
1382 *optional = dissect_icmpv6_type130;
1383 return;
1384 case 131:
1385 *type = "Multicast Listener Report";
1386 *optional = dissect_icmpv6_type131;
1387 return;
1388 case 132:
1389 *type = "Multicast Listener Done";
1390 *optional = dissect_icmpv6_type132;
1391 return;
1392 case 133:
1393 *type = "Router Solicitation";
1394 *optional = dissect_icmpv6_type133;
1395 return;
1396 case 134:
1397 *type = "Router Advertisement";
1398 *optional = dissect_icmpv6_type134;
1399 return;
1400 case 135:
1401 *type = "Neighbor Solicitation";
1402 *optional = dissect_icmpv6_type135;
1403 return;
1404 case 136:
1405 *type = "Neighbor Advertisement";
1406 *optional = dissect_icmpv6_type136;
1407 return;
1408 case 137:
1409 *type = "Redirect Message";
1410 *optional = dissect_icmpv6_type137;
1411 return;
1412 case 138:
1413 *type = "Router Renumbering";
1414 if(icmpv6_type_138_codes(icmp->h_code))
1415 *code = icmpv6_type_138_codes(icmp->h_code);
1416 *optional = dissect_icmpv6_type138;
1417 return;
1418 case 139:
1419 *type = "ICMP Node Information Query";
1420 if (icmpv6_code_range_valid(icmp->h_code,
1421 icmpv6_type_139_codes))
1422 *code = icmpv6_type_139_codes[icmp->h_code];
1423 *optional = dissect_icmpv6_type139;
1424 return;
1425 case 140:
1426 *type = "ICMP Node Information Response";
1427 if (icmpv6_code_range_valid(icmp->h_code,
1428 icmpv6_type_140_codes))
1429 *code = icmpv6_type_140_codes[icmp->h_code];
1430 *optional = dissect_icmpv6_type140;
1431 return;
1432 case 141:
1433 *type = "Inverse Neighbor Discovery Solicitation Message";
1434 *optional = dissect_icmpv6_type141;
1435 return;
1436 case 142:
1437 *type = "Inverse Neighbor Discovery Advertisement Message";
1438 *optional = dissect_icmpv6_type142;
1439 return;
1440 case 143:
1441 *type = "Multicast Listener Report v2";
1442 *optional = dissect_icmpv6_type143;
1443 return;
1444 case 144:
1445 *type = "Home Agent Address Discovery Request Message";
1446 *optional = dissect_icmpv6_type144;
1447 return;
1448 case 145:
1449 *type = "Home Agent Address Discovery Reply Message";
1450 *optional = dissect_icmpv6_type145;
1451 return;
1452 case 146:
1453 *type = "Mobile Prefix Solicitation";
1454 *optional = dissect_icmpv6_type146;
1455 return;
1456 case 147:
1457 *type = "Mobile Prefix Advertisement";
1458 *optional = dissect_icmpv6_type147;
1459 return;
1460 case 148:
1461 *type = "Certification Path Solicitation";
1462 *optional = dissect_icmpv6_type148;
1463 return;
1464 case 149:
1465 *type = "Certification Path Advertisement";
1466 *optional = dissect_icmpv6_type149;
1467 return;
1468 case 150:
1469 *type = "ICMP messages utilized by experimental mobility "
1470 "protocols such as Seamoby";
1471 *optional = dissect_icmpv6_type150;
1472 return;
1473 case 151:
1474 *type = "Multicast Router Advertisement";
1475 *code = "Ad. Interval";
1476 *optional = dissect_icmpv6_type151;
1477 return;
1478 case 152:
1479 *type = "Multicast Router Solicitation";
1480 *code = "Reserved";
1481 *optional = dissect_icmpv6_type152;
1482 return;
1483 case 153:
1484 *type = "Multicast Router Termination";
1485 *code = "Reserved";
1486 *optional = dissect_icmpv6_type153;
1487 return;
1488 case 154:
1489 *type = "FMIPv6 Messages";
1490 *optional = dissect_icmpv6_type154;
1491 return;
1492 case 155:
1493 *type = "RPL Control Message";
1494 if(icmpv6_type_155_codes(icmp->h_code))
1495 *code = icmpv6_type_155_codes(icmp->h_code);
1496 return;
1497 case 200:
1498 *type = "Private experimation";
1499 return;
1500 case 201:
1501 *type = "Private experimation";
1502 return;
1503 case 255:
1504 *type = "Reserved for expansion of ICMPv6 error messages";
1505 return;
1509 static inline void icmpv6(struct pkt_buff *pkt)
1511 char *type = NULL, *code = NULL;
1512 void (*optional)(struct pkt_buff *pkt) = NULL;
1513 struct icmpv6_general_hdr *icmp =
1514 (struct icmpv6_general_hdr *) pkt_pull(pkt, sizeof(*icmp));
1516 if (icmp == NULL)
1517 return;
1519 icmpv6_process(icmp, &type, &code, &optional);
1521 tprintf(" [ ICMPv6 ");
1522 tprintf("%s (%u), ", type, icmp->h_type);
1523 tprintf("%s (%u), ", code, icmp->h_code);
1524 tprintf("Chks (0x%x)", ntohs(icmp->h_chksum));
1525 if (optional)
1526 (*optional) (pkt);
1527 tprintf(" ]\n\n");
1530 static inline void icmpv6_less(struct pkt_buff *pkt)
1532 struct icmpv6_general_hdr *icmp =
1533 (struct icmpv6_general_hdr *) pkt_pull(pkt, sizeof(*icmp));
1535 if (icmp == NULL)
1536 return;
1538 tprintf(" ICMPv6 Type (%u) Code (%u)", icmp->h_type, icmp->h_code);
1541 struct protocol icmpv6_ops = {
1542 .key = 0x3A,
1543 .print_full = icmpv6,
1544 .print_less = icmpv6_less,
1547 #endif /* PROTO_ICMPV6_H */