0bc21b4e19ebc872b69ed15b2e7386e92c111a22
[linux-flexiantxendom0-3.2.10.git] / include / linux / ipv6.h
1 #ifndef _IPV6_H
2 #define _IPV6_H
3
4 #include <linux/config.h>
5 #include <linux/in6.h>
6 #include <asm/byteorder.h>
7
8 /* The latest drafts declared increase in minimal mtu up to 1280. */
9
10 #define IPV6_MIN_MTU    1280
11
12 /*
13  *      Advanced API
14  *      source interface/address selection, source routing, etc...
15  *      *under construction*
16  */
17
18
19 struct in6_pktinfo {
20         struct in6_addr ipi6_addr;
21         int             ipi6_ifindex;
22 };
23
24
25 struct in6_ifreq {
26         struct in6_addr ifr6_addr;
27         __u32           ifr6_prefixlen;
28         int             ifr6_ifindex; 
29 };
30
31 #define IPV6_SRCRT_STRICT       0x01    /* this hop must be a neighbor  */
32 #define IPV6_SRCRT_TYPE_0       0       /* IPv6 type 0 Routing Header   */
33
34 /*
35  *      routing header
36  */
37 struct ipv6_rt_hdr {
38         __u8            nexthdr;
39         __u8            hdrlen;
40         __u8            type;
41         __u8            segments_left;
42
43         /*
44          *      type specific data
45          *      variable length field
46          */
47 };
48
49
50 struct ipv6_opt_hdr {
51         __u8            nexthdr;
52         __u8            hdrlen;
53         /* 
54          * TLV encoded option data follows.
55          */
56 };
57
58 #define ipv6_destopt_hdr ipv6_opt_hdr
59 #define ipv6_hopopt_hdr  ipv6_opt_hdr
60
61 #ifdef __KERNEL__
62 #define ipv6_optlen(p)  (((p)->hdrlen+1) << 3)
63 #endif
64
65 /*
66  *      routing header type 0 (used in cmsghdr struct)
67  */
68
69 struct rt0_hdr {
70         struct ipv6_rt_hdr      rt_hdr;
71         __u32                   bitmap;         /* strict/loose bit map */
72         struct in6_addr         addr[0];
73
74 #define rt0_type                rt_hdr.type;
75 };
76
77 struct ipv6_auth_hdr {
78         __u8  nexthdr;
79         __u8  hdrlen;           /* This one is measured in 32 bit units! */
80         __u16 reserved;
81         __u32 spi;
82         __u32 seq_no;           /* Sequence number */
83         __u8  auth_data[0];     /* Length variable but >=4. Mind the 64 bit alignment! */
84 };
85
86 struct ipv6_esp_hdr {
87         __u32 spi;
88         __u32 seq_no;           /* Sequence number */
89         __u8  enc_data[0];      /* Length variable but >=8. Mind the 64 bit alignment! */
90 };
91
92 struct ipv6_comp_hdr {
93         __u8 nexthdr;
94         __u8 flags;
95         __u16 cpi;
96 };
97
98 /*
99  *      IPv6 fixed header
100  *
101  *      BEWARE, it is incorrect. The first 4 bits of flow_lbl
102  *      are glued to priority now, forming "class".
103  */
104
105 struct ipv6hdr {
106 #if defined(__LITTLE_ENDIAN_BITFIELD)
107         __u8                    priority:4,
108                                 version:4;
109 #elif defined(__BIG_ENDIAN_BITFIELD)
110         __u8                    version:4,
111                                 priority:4;
112 #else
113 #error  "Please fix <asm/byteorder.h>"
114 #endif
115         __u8                    flow_lbl[3];
116
117         __u16                   payload_len;
118         __u8                    nexthdr;
119         __u8                    hop_limit;
120
121         struct  in6_addr        saddr;
122         struct  in6_addr        daddr;
123 };
124
125 #ifdef __KERNEL__
126 #include <linux/in6.h>          /* struct sockaddr_in6 */
127 #include <linux/icmpv6.h>
128 #include <net/if_inet6.h>       /* struct ipv6_mc_socklist */
129 #include <linux/tcp.h>
130 #include <linux/udp.h>
131
132 /* 
133    This structure contains results of exthdrs parsing
134    as offsets from skb->nh.
135  */
136
137 struct inet6_skb_parm
138 {
139         int                     iif;
140         __u16                   ra;
141         __u16                   hop;
142         __u16                   auth;
143         __u16                   dst0;
144         __u16                   srcrt;
145         __u16                   dst1;
146 };
147
148 struct ipv6_pinfo {
149         struct in6_addr         saddr;
150         struct in6_addr         rcv_saddr;
151         struct in6_addr         daddr;
152         struct in6_addr         *daddr_cache;
153
154         __u32                   flow_label;
155         __u32                   frag_size;
156         int                     hop_limit;
157         int                     mcast_hops;
158         int                     mcast_oif;
159
160         /* pktoption flags */
161         union {
162                 struct {
163                         __u8    srcrt:2,
164                                 rxinfo:1,
165                                 rxhlim:1,
166                                 hopopts:1,
167                                 dstopts:1,
168                                 authhdr:1,
169                                 rxflow:1;
170                 } bits;
171                 __u8            all;
172         } rxopt;
173
174         /* sockopt flags */
175         __u8                    mc_loop:1,
176                                 recverr:1,
177                                 sndflow:1,
178                                 pmtudisc:2,
179                                 ipv6only:1;
180
181         struct ipv6_mc_socklist *ipv6_mc_list;
182         struct ipv6_ac_socklist *ipv6_ac_list;
183         struct ipv6_fl_socklist *ipv6_fl_list;
184         __u32                   dst_cookie;
185
186         struct ipv6_txoptions   *opt;
187         struct sk_buff          *pktoptions;
188         struct {
189                 struct ipv6_txoptions *opt;
190                 struct rt6_info *rt;
191                 struct flowi *fl;
192         } cork;
193 };
194
195 struct raw6_opt {
196         __u32                   checksum;       /* perform checksum */
197         __u32                   offset;         /* checksum offset  */
198
199         struct icmp6_filter     filter;
200 };
201
202 /* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
203 struct raw6_sock {
204         struct sock       sk;
205         struct ipv6_pinfo *pinet6;
206         struct inet_opt   inet;
207         struct raw6_opt   raw6;
208         struct ipv6_pinfo inet6;
209 };
210
211 struct udp6_sock {
212         struct sock       sk;
213         struct ipv6_pinfo *pinet6;
214         struct inet_opt   inet;
215         struct udp_opt    udp;
216         struct ipv6_pinfo inet6;
217 };
218
219 struct tcp6_sock {
220         struct sock       sk;
221         struct ipv6_pinfo *pinet6;
222         struct inet_opt   inet;
223         struct tcp_opt    tcp;
224         struct ipv6_pinfo inet6;
225 };
226
227 #define inet6_sk(__sk) ((struct raw6_sock *)__sk)->pinet6
228 #define raw6_sk(__sk) (&((struct raw6_sock *)__sk)->raw6)
229
230 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
231 #define __ipv6_only_sock(sk)    (inet6_sk(sk)->ipv6only)
232 #define ipv6_only_sock(sk)      ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk))
233 #else
234 #define __ipv6_only_sock(sk)    0
235 #define ipv6_only_sock(sk)      0
236 #endif
237
238 #endif
239
240 #endif