1#ifndef _NETINET_IP6_H
2#define _NETINET_IP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10#include <endian.h>
11
12struct ip6_hdr {
13	union {
14		struct ip6_hdrctl {
15			uint32_t ip6_un1_flow;
16			uint16_t ip6_un1_plen;
17			uint8_t  ip6_un1_nxt;
18			uint8_t  ip6_un1_hlim;
19		} ip6_un1;
20		uint8_t ip6_un2_vfc;
21	} ip6_ctlun;
22	struct in6_addr ip6_src;
23	struct in6_addr ip6_dst;
24};
25
26#define ip6_vfc   ip6_ctlun.ip6_un2_vfc
27#define ip6_flow  ip6_ctlun.ip6_un1.ip6_un1_flow
28#define ip6_plen  ip6_ctlun.ip6_un1.ip6_un1_plen
29#define ip6_nxt   ip6_ctlun.ip6_un1.ip6_un1_nxt
30#define ip6_hlim  ip6_ctlun.ip6_un1.ip6_un1_hlim
31#define ip6_hops  ip6_ctlun.ip6_un1.ip6_un1_hlim
32
33struct ip6_ext {
34	uint8_t  ip6e_nxt;
35	uint8_t  ip6e_len;
36};
37
38struct ip6_hbh {
39	uint8_t  ip6h_nxt;
40	uint8_t  ip6h_len;
41};
42
43struct ip6_dest {
44	uint8_t  ip6d_nxt;
45	uint8_t  ip6d_len;
46};
47
48struct ip6_rthdr {
49	uint8_t  ip6r_nxt;
50	uint8_t  ip6r_len;
51	uint8_t  ip6r_type;
52	uint8_t  ip6r_segleft;
53};
54
55struct ip6_rthdr0 {
56	uint8_t  ip6r0_nxt;
57	uint8_t  ip6r0_len;
58	uint8_t  ip6r0_type;
59	uint8_t  ip6r0_segleft;
60	uint8_t  ip6r0_reserved;
61	uint8_t  ip6r0_slmap[3];
62	struct in6_addr ip6r0_addr[];
63};
64
65struct ip6_frag {
66	uint8_t   ip6f_nxt;
67	uint8_t   ip6f_reserved;
68	uint16_t  ip6f_offlg;
69	uint32_t  ip6f_ident;
70};
71
72#if __BYTE_ORDER == __BIG_ENDIAN
73#define IP6F_OFF_MASK       0xfff8
74#define IP6F_RESERVED_MASK  0x0006
75#define IP6F_MORE_FRAG      0x0001
76#else
77#define IP6F_OFF_MASK       0xf8ff
78#define IP6F_RESERVED_MASK  0x0600
79#define IP6F_MORE_FRAG      0x0100
80#endif
81
82struct ip6_opt {
83	uint8_t  ip6o_type;
84	uint8_t  ip6o_len;
85};
86
87#define IP6OPT_TYPE(o)		((o) & 0xc0)
88#define IP6OPT_TYPE_SKIP	0x00
89#define IP6OPT_TYPE_DISCARD	0x40
90#define IP6OPT_TYPE_FORCEICMP	0x80
91#define IP6OPT_TYPE_ICMP	0xc0
92#define IP6OPT_TYPE_MUTABLE	0x20
93
94#define IP6OPT_PAD1	0
95#define IP6OPT_PADN	1
96
97#define IP6OPT_JUMBO		0xc2
98#define IP6OPT_NSAP_ADDR	0xc3
99#define IP6OPT_TUNNEL_LIMIT	0x04
100#define IP6OPT_ROUTER_ALERT	0x05
101
102struct ip6_opt_jumbo {
103	uint8_t  ip6oj_type;
104	uint8_t  ip6oj_len;
105	uint8_t  ip6oj_jumbo_len[4];
106};
107#define IP6OPT_JUMBO_LEN	6
108
109struct ip6_opt_nsap {
110	uint8_t  ip6on_type;
111	uint8_t  ip6on_len;
112	uint8_t  ip6on_src_nsap_len;
113	uint8_t  ip6on_dst_nsap_len;
114};
115
116struct ip6_opt_tunnel {
117	uint8_t  ip6ot_type;
118	uint8_t  ip6ot_len;
119	uint8_t  ip6ot_encap_limit;
120};
121
122struct ip6_opt_router {
123	uint8_t  ip6or_type;
124	uint8_t  ip6or_len;
125	uint8_t  ip6or_value[2];
126};
127
128#if __BYTE_ORDER == __BIG_ENDIAN
129#define IP6_ALERT_MLD	0x0000
130#define IP6_ALERT_RSVP	0x0001
131#define IP6_ALERT_AN	0x0002
132#else
133#define IP6_ALERT_MLD	0x0000
134#define IP6_ALERT_RSVP	0x0100
135#define IP6_ALERT_AN	0x0200
136#endif
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif
143