Wireshark  4.3.0
The Wireshark network protocol analyzer
inet_ipv6.h
Go to the documentation of this file.
1 
10 #ifndef __INET_IPV6_H__
11 #define __INET_IPV6_H__
12 
13 #include <inttypes.h>
14 #include <stdbool.h>
15 
16 #define IPv6_ADDR_SIZE 16
17 
18 #define IPv6_HDR_SIZE 40
19 #define IPv6_FRAGMENT_HDR_SIZE 8
20 
21 typedef struct e_in6_addr {
22  uint8_t bytes[16]; /* 128 bit IPv6 address */
23 } ws_in6_addr;
24 
25 /*
26  * Definition for internet protocol version 6.
27  * RFC 2460
28  */
29 struct ws_ip6_hdr {
30  uint32_t ip6h_vc_flow; /* version, class, flow */
31  uint16_t ip6h_plen; /* payload length */
32  uint8_t ip6h_nxt; /* next header */
33  uint8_t ip6h_hlim; /* hop limit */
34  ws_in6_addr ip6h_src; /* source address */
35  ws_in6_addr ip6h_dst; /* destination address */
36 };
37 
38 /*
39  * Extension Headers
40  */
41 
42 struct ip6_ext {
43  unsigned char ip6e_nxt;
44  unsigned char ip6e_len;
45 };
46 
47 /* Routing header */
48 struct ip6_rthdr {
49  uint8_t ip6r_nxt; /* next header */
50  uint8_t ip6r_len; /* length in units of 8 octets */
51  uint8_t ip6r_type; /* routing type */
52  uint8_t ip6r_segleft; /* segments left */
53  /* followed by routing type specific data */
54 };
55 
56 /* Type 0 Routing header */
57 struct ip6_rthdr0 {
58  uint8_t ip6r0_nxt; /* next header */
59  uint8_t ip6r0_len; /* length in units of 8 octets */
60  uint8_t ip6r0_type; /* always zero */
61  uint8_t ip6r0_segleft; /* segments left */
62  uint8_t ip6r0_reserved; /* reserved field */
63  uint8_t ip6r0_slmap[3]; /* strict/loose bit map */
64  /* followed by up to 127 addresses */
65  ws_in6_addr ip6r0_addr[1];
66 };
67 
68 /* Fragment header */
69 struct ip6_frag {
70  uint8_t ip6f_nxt; /* next header */
71  uint8_t ip6f_reserved; /* reserved field */
72  uint16_t ip6f_offlg; /* offset, reserved, and flag */
73  uint32_t ip6f_ident; /* identification */
74 };
75 
76 #define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
77 #define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
78 #define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
79 
80 
85 static inline bool in6_addr_is_linklocal(const ws_in6_addr *a)
86 {
87  return (a->bytes[0] == 0xfe) && ((a->bytes[1] & 0xc0) == 0x80);
88 }
89 
90 static inline bool in6_addr_is_sitelocal(const ws_in6_addr *a)
91 {
92  return (a->bytes[0] == 0xfe) && ((a->bytes[1] & 0xc0) == 0xc0);
93 }
94 
98 static inline bool in6_addr_is_multicast(const ws_in6_addr *a)
99 {
100  return a->bytes[0] == 0xff;
101 }
102 
103 #endif
Definition: inet_ipv6.h:21
Definition: inet_ipv6.h:42
Definition: inet_ipv6.h:69
Definition: inet_ipv6.h:57
Definition: inet_ipv6.h:48
Definition: inet_ipv6.h:29