2 * Definitions for IPv6 packet disassembly
4 * $Id: packet-ipv6.h,v 1.17 2000/12/14 08:35:07 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #ifndef __PACKET_IPV6_H_DEFINED__
27 #define __PACKET_IPV6_H_DEFINED__
29 void dissect_ipv6(const u_char *, int, frame_data *, proto_tree *);
36 } u6_addr; /* 128 bit IP6 address */
55 #define s6_addr32 u6_addr.u6_addr32
56 #define s6_addr16 u6_addr.u6_addr16
57 #define s6_addr8 u6_addr.u6_addr8
58 #define s6_addr u6_addr.u6_addr8
60 #define INET6_ADDRSTRLEN 46
63 * Definition for internet protocol version 6.
69 guint32 ip6_un1_flow; /* 20 bits of flow-ID */
70 guint16 ip6_un1_plen; /* payload length */
71 guint8 ip6_un1_nxt; /* next header */
72 guint8 ip6_un1_hlim; /* hop limit */
74 guint8 ip6_un2_vfc; /* 4 bits version, 4 bits class */
76 struct e_in6_addr ip6_src; /* source address */
77 struct e_in6_addr ip6_dst; /* destination address */
80 #define ip6_vfc ip6_ctlun.ip6_un2_vfc
81 #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
82 #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
83 #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
84 #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
85 #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
87 /* Offsets of fields within an IPv6 header. */
89 #define IP6H_CTL_FLOW 0
90 #define IP6H_CTL_PLEN 4
91 #define IP6H_CTL_NXT 6
92 #define IP6H_CTL_HLIM 7
93 #define IP6H_CTL_VFC 0
97 #define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */
98 #define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */
109 /* Hop-by-Hop options header */
110 /* XXX should we pad it to force alignment on an 8-byte boundary? */
112 guint8 ip6h_nxt; /* next header */
113 guint8 ip6h_len; /* length in units of 8 octets */
114 /* followed by options */
117 /* Destination options header */
118 /* XXX should we pad it to force alignment on an 8-byte boundary? */
120 guint8 ip6d_nxt; /* next header */
121 guint8 ip6d_len; /* length in units of 8 octets */
122 /* followed by options */
125 /* Option types and related macros */
126 #define IP6OPT_PAD1 0x00 /* 00 0 00000 */
127 #define IP6OPT_PADN 0x01 /* 00 0 00001 */
128 #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
129 #define IP6OPT_JUMBO_LEN 6
130 #define IP6OPT_RTALERT 0x05 /* 00 0 00101 */
131 #define IP6OPT_RTALERT_LEN 4
132 #define IP6OPT_RTALERT_MLD 0 /* Datagram contains MLD message */
133 #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains RSVP message */
134 #define IP6OPT_MINLEN 2
136 #define IP6OPT_TYPE(o) ((o) & 0xC0)
137 #define IP6OPT_TYPE_SKIP 0x00
138 #define IP6OPT_TYPE_DISCARD 0x40
139 #define IP6OPT_TYPE_FORCEICMP 0x80
140 #define IP6OPT_TYPE_ICMP 0xC0
142 #define IP6OPT_MUTABLE 0x20
146 guint8 ip6r_nxt; /* next header */
147 guint8 ip6r_len; /* length in units of 8 octets */
148 guint8 ip6r_type; /* routing type */
149 guint8 ip6r_segleft; /* segments left */
150 /* followed by routing type specific data */
153 /* Type 0 Routing header */
155 guint8 ip6r0_nxt; /* next header */
156 guint8 ip6r0_len; /* length in units of 8 octets */
157 guint8 ip6r0_type; /* always zero */
158 guint8 ip6r0_segleft; /* segments left */
159 guint8 ip6r0_reserved; /* reserved field */
160 guint8 ip6r0_slmap[3]; /* strict/loose bit map */
161 struct e_in6_addr ip6r0_addr[1]; /* up to 23 addresses */
164 /* Fragment header */
166 guint8 ip6f_nxt; /* next header */
167 guint8 ip6f_reserved; /* reserved field */
168 guint16 ip6f_offlg; /* offset, reserved, and flag */
169 guint32 ip6f_ident; /* identification */
172 #define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
173 #define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
174 #define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
179 #define IP6OPT_BINDING_UPDATE 0xC6 /* 11 0 00110 */
180 #define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
181 #define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
182 #define IP6OPT_HOME_ADDRESS 0xC9 /* 11 0 01001 */
183 #define IP6OPT_EID 0x8A /* 10 0 01010 */
184 #define IP6SUBOPT_UNIQUE_ID 0x02 /* Unique Id */
185 #define IP6SUBOPT_ALTERNATE_COA 0x04 /* Alternate CoA */
187 /* Binding Update Option */
188 struct ip6_opt_binding_update {
192 #define IP6_BU_ACK 0x80 /* Request a binding ack */
193 #define IP6_BU_HOME 0x40 /* Home Registration */
194 #define IP6_BU_COA 0x20 /* Care-of-address present in option */
195 #define IP6_BU_ROUTER 0x10 /* Sending mobile node is a router */
196 guint8 ip6bu_prefixlen;
198 guint32 ip6bu_lifetime;
199 /* followed by sub-options */
202 /* Binding Ack Option */
203 struct ip6_opt_binding_ack {
207 #define IP6_BINDING_ACK_OK 0 /* Binding Update accepted */
208 #define IP6_BINDING_ACK_EUNKNOWN 128 /* Reason unspecified */
209 #define IP6_BINDING_ACK_EPERM 130 /* Administratively prohib. */
210 #define IP6_BINDING_ACK_EAGAIN 131 /* Insufficient resources */
211 #define IP6_BINDING_ACK_EHOMENOSUPPORT 132 /* Home registration */
212 #define IP6_BINDING_ACK_ENOTHOMESUBNET 133 /* Not home subnet */
213 #define IP6_BINDING_ACK_EBADIFLEN 136 /* Incorrect interface id len */
214 #define IP6_BINDING_ACK_ENOTHOME 137 /* Not home agent for this MN */
216 guint32 ip6ba_lifetime;
217 guint32 ip6ba_refresh;
218 /* followed by sub-options */
221 /* Binding Request Option */
222 struct ip6_opt_binding_request {
225 /* followed by sub-options */
228 /* Home Address Option */
229 struct ip6_opt_home_address {
232 struct e_in6_addr ip6ha_ha; /* Home Address */
233 /* followed by sub-options */
236 /* Unique Identifier sub-option */
237 struct ip6_subopt_unique_id {
240 guint16 ip6ui_id; /* Unique Identifier */
243 /* Alternate CoA sub-option */
244 struct ip6_subopt_alternate_coa {
247 struct e_in6_addr coa; /* Alternate CoA */
252 * Definition for ICMPv6.
256 #define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
257 - sizeof(struct icmp6_hdr) */
260 guint8 icmp6_type; /* type field */
261 guint8 icmp6_code; /* code field */
262 guint16 icmp6_cksum; /* checksum field */
264 guint32 icmp6_un_data32[1]; /* type-specific field */
265 guint16 icmp6_un_data16[2]; /* type-specific field */
266 guint8 icmp6_un_data8[4]; /* type-specific field */
270 #define icmp6_data32 icmp6_dataun.icmp6_un_data32
271 #define icmp6_data16 icmp6_dataun.icmp6_un_data16
272 #define icmp6_data8 icmp6_dataun.icmp6_un_data8
273 #define icmp6_pptr icmp6_data32[0] /* parameter prob */
274 #define icmp6_mtu icmp6_data32[0] /* packet too big */
275 #define icmp6_id icmp6_data16[0] /* echo request/reply */
276 #define icmp6_seq icmp6_data16[1] /* echo request/reply */
277 #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
279 #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
280 #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
281 #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
282 #define ICMP6_PARAM_PROB 4 /* ip6 header bad */
284 #define ICMP6_ECHO_REQUEST 128 /* echo service */
285 #define ICMP6_ECHO_REPLY 129 /* echo reply */
286 #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
287 #define MLD6_LISTENER_QUERY 130 /* multicast listener query */
288 #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
289 #define MLD6_LISTENER_REPORT 131 /* multicast listener report */
290 #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
291 #define MLD6_LISTENER_DONE 132 /* multicast listener done */
293 #define ND_ROUTER_SOLICIT 133 /* router solicitation */
294 #define ND_ROUTER_ADVERT 134 /* router advertisment */
295 #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
296 #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisment */
297 #define ND_REDIRECT 137 /* redirect */
299 #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
301 #define ICMP6_WRUREQUEST 139 /* who are you request */
302 #define ICMP6_WRUREPLY 140 /* who are you reply */
303 #define ICMP6_FQDN_QUERY 139 /* FQDN query */
304 #define ICMP6_FQDN_REPLY 140 /* FQDN reply */
305 #define ICMP6_NI_QUERY 139 /* node information request */
306 #define ICMP6_NI_REPLY 140 /* node information reply */
308 /* The definitions below are experimental. TBA */
309 #define MLD6_MTRACE_RESP 141 /* mtrace response(to sender) */
310 #define MLD6_MTRACE 142 /* mtrace messages */
312 #define ICMP6_MAXTYPE 142
314 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
315 #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
316 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
317 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
318 #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
319 #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
321 #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
322 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
324 #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
325 #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
326 #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
328 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
330 #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
331 #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
332 #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
334 #define ICMP6_NI_SUCCESS 0 /* node information successful reply */
335 #define ICMP6_NI_REFUSED 1 /* node information request is refused */
336 #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
338 #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
339 #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
340 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
343 * Multicast Listener Discovery
346 struct icmp6_hdr mld6_hdr;
347 struct e_in6_addr mld6_addr; /* multicast address */
350 #define mld6_type mld6_hdr.icmp6_type
351 #define mld6_code mld6_hdr.icmp6_code
352 #define mld6_cksum mld6_hdr.icmp6_cksum
353 #define mld6_maxdelay mld6_hdr.icmp6_data16[0]
354 #define mld6_reserved mld6_hdr.icmp6_data16[1]
360 struct nd_router_solicit { /* router solicitation */
361 struct icmp6_hdr nd_rs_hdr;
362 /* could be followed by options */
365 #define nd_rs_type nd_rs_hdr.icmp6_type
366 #define nd_rs_code nd_rs_hdr.icmp6_code
367 #define nd_rs_cksum nd_rs_hdr.icmp6_cksum
368 #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
370 struct nd_router_advert { /* router advertisement */
371 struct icmp6_hdr nd_ra_hdr;
372 guint32 nd_ra_reachable; /* reachable time */
373 guint32 nd_ra_retransmit; /* retransmit timer */
374 /* could be followed by options */
377 #define nd_ra_type nd_ra_hdr.icmp6_type
378 #define nd_ra_code nd_ra_hdr.icmp6_code
379 #define nd_ra_cksum nd_ra_hdr.icmp6_cksum
380 #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
381 #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
382 #define ND_RA_FLAG_MANAGED 0x80
383 #define ND_RA_FLAG_OTHER 0x40
384 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
386 struct nd_neighbor_solicit { /* neighbor solicitation */
387 struct icmp6_hdr nd_ns_hdr;
388 struct e_in6_addr nd_ns_target; /*target address */
389 /* could be followed by options */
392 #define nd_ns_type nd_ns_hdr.icmp6_type
393 #define nd_ns_code nd_ns_hdr.icmp6_code
394 #define nd_ns_cksum nd_ns_hdr.icmp6_cksum
395 #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
397 struct nd_neighbor_advert { /* neighbor advertisement */
398 struct icmp6_hdr nd_na_hdr;
399 struct e_in6_addr nd_na_target; /* target address */
400 /* could be followed by options */
403 #define nd_na_type nd_na_hdr.icmp6_type
404 #define nd_na_code nd_na_hdr.icmp6_code
405 #define nd_na_cksum nd_na_hdr.icmp6_cksum
406 #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
407 #define ND_NA_FLAG_ROUTER 0x80000000
408 #define ND_NA_FLAG_SOLICITED 0x40000000
409 #define ND_NA_FLAG_OVERRIDE 0x20000000
411 struct nd_redirect { /* redirect */
412 struct icmp6_hdr nd_rd_hdr;
413 struct e_in6_addr nd_rd_target; /* target address */
414 struct e_in6_addr nd_rd_dst; /* destination address */
415 /* could be followed by options */
418 #define nd_rd_type nd_rd_hdr.icmp6_type
419 #define nd_rd_code nd_rd_hdr.icmp6_code
420 #define nd_rd_cksum nd_rd_hdr.icmp6_cksum
421 #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
423 struct nd_opt_hdr { /* Neighbor discovery option header */
426 /* followed by option specific data*/
429 #define ND_OPT_SOURCE_LINKADDR 1
430 #define ND_OPT_TARGET_LINKADDR 2
431 #define ND_OPT_PREFIX_INFORMATION 3
432 #define ND_OPT_REDIRECTED_HEADER 4
435 struct nd_opt_prefix_info { /* prefix information */
436 guint8 nd_opt_pi_type;
437 guint8 nd_opt_pi_len;
438 guint8 nd_opt_pi_prefix_len;
439 guint8 nd_opt_pi_flags_reserved;
440 guint32 nd_opt_pi_valid_time;
441 guint32 nd_opt_pi_preferred_time;
442 guint32 nd_opt_pi_reserved2;
443 struct e_in6_addr nd_opt_pi_prefix;
446 #define ND_OPT_PI_FLAG_ONLINK 0x80
447 #define ND_OPT_PI_FLAG_AUTO 0x40
449 struct nd_opt_rd_hdr { /* redirected header */
450 guint8 nd_opt_rh_type;
451 guint8 nd_opt_rh_len;
452 guint16 nd_opt_rh_reserved1;
453 guint32 nd_opt_rh_reserved2;
454 /* followed by IP header and data */
457 struct nd_opt_mtu { /* MTU option */
458 guint8 nd_opt_mtu_type;
459 guint8 nd_opt_mtu_len;
460 guint16 nd_opt_mtu_reserved;
461 guint32 nd_opt_mtu_mtu;
465 * icmp6 node information
467 struct icmp6_nodeinfo {
468 struct icmp6_hdr icmp6_ni_hdr;
469 guint8 icmp6_ni_nonce[8];
470 /* could be followed by reply data */
473 #define ni_type icmp6_ni_hdr.icmp6_type
474 #define ni_code icmp6_ni_hdr.icmp6_code
475 #define ni_cksum icmp6_ni_hdr.icmp6_cksum
476 #define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
477 #define ni_flags icmp6_ni_hdr.icmp6_data16[1]
479 #define NI_QTYPE_NOOP 0 /* NOOP */
480 #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
481 #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
482 #define NI_QTYPE_DNSNAME 2 /* DNS Name */
483 #define NI_QTYPE_NODEADDR 3 /* Node Addresses */
484 #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
486 #define NI_SUPTYPE_FLAG_COMPRESS 0x1
487 #define NI_FQDN_FLAG_VALIDTTL 0x1
489 #define NI_NODEADDR_FLAG_TRUNCATE 0x1
490 #define NI_NODEADDR_FLAG_ALL 0x2
491 #define NI_NODEADDR_FLAG_COMPAT 0x4
492 #define NI_NODEADDR_FLAG_LINKLOCAL 0x8
493 #define NI_NODEADDR_FLAG_SITELOCAL 0x10
494 #define NI_NODEADDR_FLAG_GLOBAL 0x20
495 #define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
497 struct ni_reply_fqdn {
498 guint32 ni_fqdn_ttl; /* TTL */
499 guint8 ni_fqdn_namelen; /* length in octets of the FQDN */
500 guint8 ni_fqdn_name[3]; /* XXX: alignment */
504 * Router Renumbering. as router-renum-05.txt
506 struct icmp6_router_renum { /* router renumbering header */
507 struct icmp6_hdr rr_hdr;
514 #define rr_type rr_hdr.icmp6_type
515 #define rr_code rr_hdr.icmp6_code
516 #define rr_cksum rr_hdr.icmp6_cksum
517 #define rr_seqnum rr_hdr.icmp6_data32[0]
519 struct rr_pco_match { /* match prefix part */
526 guint16 rpm_reserved;
527 struct e_in6_addr rpm_prefix;
530 #define RPM_PCO_ADD 1
531 #define RPM_PCO_CHANGE 2
532 #define RPM_PCO_SETGLOBAL 3
533 #define RPM_PCO_MAX 4
535 struct rr_pco_use { /* use prefix part */
543 struct e_in6_addr rpu_prefix;
546 #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
547 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
550 #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
551 #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
553 struct rr_result { /* router renumbering result message */
556 guint8 rrr_matchedlen;
558 struct e_in6_addr rrr_prefix;
562 #define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
563 #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
565 #endif /* __PACKET_IPV6_H_DEFINED__ */