Blame view

include/linux/ipv6.h 7.23 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  #ifndef _IPV6_H
  #define _IPV6_H
607ca46e9   David Howells   UAPI: (Scripted) ...
3
  #include <uapi/linux/ipv6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
  #define ipv6_optlen(p)  (((p)->hdrlen+1) << 3)
1431fb31e   Paul Durrant   xen-netback: fix ...
6
  #define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  /*
   * This structure contains configuration options per IPv6 link.
   */
  struct ipv6_devconf {
  	__s32		forwarding;
  	__s32		hop_limit;
  	__s32		mtu6;
  	__s32		accept_ra;
  	__s32		accept_redirects;
  	__s32		autoconf;
  	__s32		dad_transmits;
  	__s32		rtr_solicits;
  	__s32		rtr_solicit_interval;
  	__s32		rtr_solicit_delay;
  	__s32		force_mld_version;
fc4eba58b   Hannes Frederic Sowa   ipv6: make unsoli...
22
23
  	__s32		mldv1_unsolicited_report_interval;
  	__s32		mldv2_unsolicited_report_interval;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
26
27
28
  	__s32		use_tempaddr;
  	__s32		temp_valid_lft;
  	__s32		temp_prefered_lft;
  	__s32		regen_max_retry;
  	__s32		max_desync_factor;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
29
  	__s32		max_addresses;
65f5c7c11   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
30
  	__s32		accept_ra_defrtr;
c4fd30eb1   YOSHIFUJI Hideaki   [IPV6]: ADDRCONF:...
31
  	__s32		accept_ra_pinfo;
930d6ff2e   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
32
33
  #ifdef CONFIG_IPV6_ROUTER_PREF
  	__s32		accept_ra_rtr_pref;
52e163563   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
34
  	__s32		rtr_probe_interval;
09c884d4c   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
35
36
37
  #ifdef CONFIG_IPV6_ROUTE_INFO
  	__s32		accept_ra_rt_info_max_plen;
  #endif
930d6ff2e   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
38
  #endif
fbea49e1e   YOSHIFUJI Hideaki   [IPV6] NDISC: Add...
39
  	__s32		proxy_ndp;
0bcbc9262   YOSHIFUJI Hideaki   [IPV6]: Disallow ...
40
  	__s32		accept_source_route;
d93331965   Ben Greear   ipv6: Allow accep...
41
  	__s32		accept_ra_from_local;
95c385b4d   Neil Horman   [IPV6] ADDRCONF: ...
42
43
  #ifdef CONFIG_IPV6_OPTIMISTIC_DAD
  	__s32		optimistic_dad;
7fd2561e4   Erik Kline   net: ipv6: Add a ...
44
  	__s32		use_optimistic;
95c385b4d   Neil Horman   [IPV6] ADDRCONF: ...
45
  #endif
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
46
47
48
  #ifdef CONFIG_IPV6_MROUTE
  	__s32		mc_forwarding;
  #endif
778d80be5   YOSHIFUJI Hideaki   ipv6: Add disable...
49
  	__s32		disable_ipv6;
1b34be74c   YOSHIFUJI Hideaki   ipv6 addrconf: ad...
50
  	__s32		accept_dad;
f7734fdf6   Octavian Purdila   make TLLAO option...
51
  	__s32		force_tllao;
5cb04436e   Hannes Frederic Sowa   ipv6: add knob to...
52
  	__s32           ndisc_notify;
b800c3b96   Hannes Frederic Sowa   ipv6: drop fragme...
53
  	__s32		suppress_frag_ndisc;
c2943f145   Harout Hedeshian   net: ipv6: Add sy...
54
  	__s32		accept_ra_mtu;
3d1bec993   Hannes Frederic Sowa   ipv6: introduce s...
55
56
57
58
  	struct ipv6_stable_secret {
  		bool initialized;
  		struct in6_addr secret;
  	} stable_secret;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
  	void		*sysctl;
  };
56d417b12   Brian Haley   IPv6: Add 'autoco...
61
62
63
64
65
66
  
  struct ipv6_params {
  	__s32 disable_ipv6;
  	__s32 autoconf;
  };
  extern struct ipv6_params ipv6_defaults;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
  #include <linux/icmpv6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
  #include <linux/tcp.h>
  #include <linux/udp.h>
14c850212   Arnaldo Carvalho de Melo   [INET_SOCK]: Move...
70
  #include <net/inet_sock.h>
0660e03f6   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
71
72
73
74
  static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
  {
  	return (struct ipv6hdr *)skb_network_header(skb);
  }
6a674e9c7   Joseph Gasparakis   net: Add support ...
75
76
77
78
  static inline struct ipv6hdr *inner_ipv6_hdr(const struct sk_buff *skb)
  {
  	return (struct ipv6hdr *)skb_inner_network_header(skb);
  }
39b89160d   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
79
80
  static inline struct ipv6hdr *ipipv6_hdr(const struct sk_buff *skb)
  {
9c70220b7   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
81
  	return (struct ipv6hdr *)skb_transport_header(skb);
39b89160d   Arnaldo Carvalho de Melo   [SK_BUFF]: Introd...
82
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
83
84
85
86
87
88
89
  /* 
     This structure contains results of exthdrs parsing
     as offsets from skb->nh.
   */
  
  struct inet6_skb_parm {
  	int			iif;
dd3332bfc   YOSHIFUJI Hideaki / 吉藤英明   ipv6: Store Route...
90
  	__be16			ra;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
93
94
  	__u16			hop;
  	__u16			dst0;
  	__u16			srcrt;
  	__u16			dst1;
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
95
  	__u16			lastopt;
e7c38157c   David S. Miller   ipv6: Make IP6CB(...
96
  	__u16			nhoff;
3e3850e98   Patrick McHardy   [NETFILTER]: Fix ...
97
  	__u16			flags;
59fbb3a61   Masahide NAKAMURA   [IPV6] MIP6: Load...
98
  #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
8dd7368dd   David S. Miller   [IPV6]: Put dstha...
99
100
  	__u16			dsthao;
  #endif
4cdd34084   Patrick McHardy   netfilter: nf_con...
101
  	__u16			frag_max_size;
3e3850e98   Patrick McHardy   [NETFILTER]: Fix ...
102
103
  
  #define IP6SKB_XFRM_TRANSFORMED	1
7bc570c8b   YOSHIFUJI Hideaki   [IPV6] MROUTE: Su...
104
  #define IP6SKB_FORWARDED	2
9c6eb28ac   Jan Engelhardt   netfilter: ipv6: ...
105
  #define IP6SKB_REROUTED		4
dd3332bfc   YOSHIFUJI Hideaki / 吉藤英明   ipv6: Store Route...
106
  #define IP6SKB_ROUTERALERT	8
f46078cfc   Hannes Frederic Sowa   ipv6: drop packet...
107
  #define IP6SKB_FRAGMENTED      16
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
109
110
  };
  
  #define IP6CB(skb)	((struct inet6_skb_parm*)((skb)->cb))
4b340ae20   Brian Haley   IPv6: Complete IP...
111
  #define IP6CBMTU(skb)	((struct ip6_mtuinfo *)((skb)->cb))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112

505cbfc57   Arnaldo Carvalho de Melo   [IPV6]: Generalis...
113
114
115
116
  static inline int inet6_iif(const struct sk_buff *skb)
  {
  	return IP6CB(skb)->iif;
  }
ca304b610   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
117
118
  struct tcp6_request_sock {
  	struct tcp_request_sock	  tcp6rsk_tcp;
ca304b610   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
119
  };
2e6599cb8   Arnaldo Carvalho de Melo   [NET] Generalise ...
120

20283d84c   Herbert Xu   [IPV6]: Remove ci...
121
122
123
  struct ipv6_mc_socklist;
  struct ipv6_ac_socklist;
  struct ipv6_fl_socklist;
366e41d97   Vlad Yasevich   ipv6: pull cork i...
124
125
126
127
128
  struct inet6_cork {
  	struct ipv6_txoptions *opt;
  	u8 hop_limit;
  	u8 tclass;
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
129
130
131
132
133
134
135
136
137
138
  /**
   * struct ipv6_pinfo - ipv6 private area
   *
   * In the struct sock hierarchy (tcp6_sock, upd6_sock, etc)
   * this _must_ be the last member, so that inet6_sk_generic
   * is able to calculate its offset from the base struct sock
   * by using the struct proto->slab_obj_size member. -acme
   */
  struct ipv6_pinfo {
  	struct in6_addr 	saddr;
b24a2516d   Yang Hongyang   ipv6: Add IPV6_PK...
139
  	struct in6_pktinfo	sticky_pktinfo;
d3818c92a   Eric Dumazet   ipv6: fix inet6_c...
140
  	const struct in6_addr		*daddr_cache;
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
141
  #ifdef CONFIG_IPV6_SUBTREES
d3818c92a   Eric Dumazet   ipv6: fix inet6_c...
142
  	const struct in6_addr		*saddr_cache;
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
143
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144

90bcaf7b4   Al Viro   [IPV6]: flowlabel...
145
  	__be32			flow_label;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
146
  	__u32			frag_size;
1d5d236d3   YOSHIFUJI Hideaki   [IPV6]: Use bitfi...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  
  	/*
  	 * Packed in 16bits.
  	 * Omit one shift by by putting the signed field at MSB.
  	 */
  #if defined(__BIG_ENDIAN_BITFIELD)
  	__s16			hop_limit:9;
  	__u16			__unused_1:7;
  #else
  	__u16			__unused_1:7;
  	__s16			hop_limit:9;
  #endif
  
  #if defined(__BIG_ENDIAN_BITFIELD)
  	/* Packed in 16bits. */
  	__s16			mcast_hops:9;
  	__u16			__unused_2:6,
  				mc_loop:1;
  #else
  	__u16			mc_loop:1,
  				__unused_2:6;
  	__s16			mcast_hops:9;
  #endif
c4062dfc4   Erich E. Hoover   ipv6: Implement I...
170
  	int			ucast_oif;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
171
172
173
174
175
  	int			mcast_oif;
  
  	/* pktoption flags */
  	union {
  		struct {
4c752098f   YOSHIFUJI Hideaki   [IPV6]: Make IPV6...
176
177
  			__u16	srcrt:1,
  				osrcrt:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
178
  			        rxinfo:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
179
  			        rxoinfo:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
180
  				rxhlim:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
181
  				rxohlim:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
182
  				hopopts:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
183
  				ohopopts:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
  				dstopts:1,
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
185
  				odstopts:1,
41a1f8ea4   YOSHIFUJI Hideaki   [IPV6]: Support I...
186
                                  rxflow:1,
793b14731   Brian Haley   IPv6: data struct...
187
  				rxtclass:1,
6c4686228   Balazs Scheidler   tproxy: added tpr...
188
189
190
  				rxpmtu:1,
  				rxorigdstaddr:1;
  				/* 2 bits hole */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
191
  		} bits;
333fad536   YOSHIFUJI Hideaki   [IPV6]: Support s...
192
  		__u16		all;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
193
194
195
  	} rxopt;
  
  	/* sockopt flags */
793b14731   Brian Haley   IPv6: data struct...
196
  	__u16			recverr:1,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
197
  	                        sndflow:1,
df3687ffc   Florent Fourcot   ipv6: add the IPV...
198
  				repflow:1,
93b36cf34   Hannes Frederic Sowa   ipv6: support IPV...
199
  				pmtudisc:3,
9fe516ba3   Eric Dumazet   inet: move ipv6on...
200
  				padding:1,	/* 1 bit hole */
793b14731   Brian Haley   IPv6: data struct...
201
  				srcprefs:3,	/* 001: prefer temporary address
7cbca67c0   YOSHIFUJI Hideaki   [IPV6]: Support S...
202
203
204
  						 * 010: prefer public address
  						 * 100: prefer care-of address
  						 */
cb1ce2ef3   Tom Herbert   ipv6: Implement a...
205
206
  				dontfrag:1,
  				autoflowlabel:1;
e802af9ca   Stephen Hemminger   IPv6: Generic TTL...
207
  	__u8			min_hopcount;
41a1f8ea4   YOSHIFUJI Hideaki   [IPV6]: Support I...
208
  	__u8			tclass;
1397ed35f   Florent Fourcot   ipv6: add flowinf...
209
  	__be32			rcv_flowinfo;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
210
211
  
  	__u32			dst_cookie;
5d299f3d3   Eric Dumazet   net: ipv6: fix TC...
212
  	__u32			rx_dst_cookie;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213

456b61bca   Eric Dumazet   ipv6: mcast: RCU ...
214
  	struct ipv6_mc_socklist	__rcu *ipv6_mc_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
215
  	struct ipv6_ac_socklist	*ipv6_ac_list;
18367681a   YOSHIFUJI Hideaki / 吉藤英明   ipv6 flowlabel: C...
216
  	struct ipv6_fl_socklist __rcu *ipv6_fl_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
217
218
219
  
  	struct ipv6_txoptions	*opt;
  	struct sk_buff		*pktoptions;
4b340ae20   Brian Haley   IPv6: Complete IP...
220
  	struct sk_buff		*rxpmtu;
366e41d97   Vlad Yasevich   ipv6: pull cork i...
221
  	struct inet6_cork	cork;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
222
223
224
225
226
227
228
229
230
  };
  
  /* WARNING: don't change the layout of the members in {raw,udp,tcp}6_sock! */
  struct raw6_sock {
  	/* inet_sock has to be the first member of raw6_sock */
  	struct inet_sock	inet;
  	__u32			checksum;	/* perform checksum */
  	__u32			offset;		/* checksum offset  */
  	struct icmp6_filter	filter;
d1db275dd   Patrick McHardy   ipv6: ip6mr: supp...
231
  	__u32			ip6mr_table;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
  	/* ipv6_pinfo has to be the last member of raw6_sock, see inet6_sk_generic */
  	struct ipv6_pinfo	inet6;
  };
  
  struct udp6_sock {
  	struct udp_sock	  udp;
  	/* ipv6_pinfo has to be the last member of udp6_sock, see inet6_sk_generic */
  	struct ipv6_pinfo inet6;
  };
  
  struct tcp6_sock {
  	struct tcp_sock	  tcp;
  	/* ipv6_pinfo has to be the last member of tcp6_sock, see inet6_sk_generic */
  	struct ipv6_pinfo inet6;
  };
b9750ce13   Arnaldo Carvalho de Melo   [IPV6]: Generalis...
247
  extern int inet6_sk_rebuild_header(struct sock *sk);
48ee3569f   David S. Miller   ipv6: Move ipv6 t...
248
249
  struct tcp6_timewait_sock {
  	struct tcp_timewait_sock   tcp6tw_tcp;
48ee3569f   David S. Miller   ipv6: Move ipv6 t...
250
  };
dfd56b8b3   Eric Dumazet   net: use IS_ENABL...
251
  #if IS_ENABLED(CONFIG_IPV6)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
  static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
  {
  	return inet_sk(__sk)->pinet6;
  }
  
  static inline struct raw6_sock *raw6_sk(const struct sock *sk)
  {
  	return (struct raw6_sock *)sk;
  }
  
  static inline void inet_sk_copy_descendant(struct sock *sk_to,
  					   const struct sock *sk_from)
  {
  	int ancestor_size = sizeof(struct inet_sock);
  
  	if (sk_from->sk_family == PF_INET6)
  		ancestor_size += sizeof(struct ipv6_pinfo);
  
  	__inet_sk_copy_descendant(sk_to, sk_from, ancestor_size);
  }
9fe516ba3   Eric Dumazet   inet: move ipv6on...
272
273
  #define __ipv6_only_sock(sk)	(sk->sk_ipv6only)
  #define ipv6_only_sock(sk)	(__ipv6_only_sock(sk))
4b261c75a   Hannes Frederic Sowa   ipv6: make IPV6_R...
274
275
  #define ipv6_sk_rxinfo(sk)	((sk)->sk_family == PF_INET6 && \
  				 inet6_sk(sk)->rxopt.bits.rxinfo)
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
276

efe4208f4   Eric Dumazet   ipv6: make lookup...
277
  static inline const struct in6_addr *inet6_rcv_saddr(const struct sock *sk)
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
278
  {
efe4208f4   Eric Dumazet   ipv6: make lookup...
279
280
281
  	if (sk->sk_family == AF_INET6)
  		return &sk->sk_v6_rcv_saddr;
  	return NULL;
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
282
  }
463c84b97   Arnaldo Carvalho de Melo   [NET]: Introduce ...
283
  static inline int inet_v6_ipv6only(const struct sock *sk)
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
284
  {
9fe516ba3   Eric Dumazet   inet: move ipv6on...
285
286
  	/* ipv6only field is at same position for timewait and other sockets */
  	return ipv6_only_sock(sk);
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
287
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
288
289
290
  #else
  #define __ipv6_only_sock(sk)	0
  #define ipv6_only_sock(sk)	0
4b261c75a   Hannes Frederic Sowa   ipv6: make IPV6_R...
291
  #define ipv6_sk_rxinfo(sk)	0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
292
293
294
295
296
  
  static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk)
  {
  	return NULL;
  }
ca304b610   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
297
298
299
300
301
  static inline struct inet6_request_sock *
  			inet6_rsk(const struct request_sock *rsk)
  {
  	return NULL;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
302
303
304
305
  static inline struct raw6_sock *raw6_sk(const struct sock *sk)
  {
  	return NULL;
  }
0fa1a53e1   Arnaldo Carvalho de Melo   [IPV6]: Introduce...
306
  #define inet6_rcv_saddr(__sk)	NULL
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
307
  #define tcp_twsk_ipv6only(__sk)		0
463c84b97   Arnaldo Carvalho de Melo   [NET]: Introduce ...
308
  #define inet_v6_ipv6only(__sk)		0
dfd56b8b3   Eric Dumazet   net: use IS_ENABL...
309
  #endif /* IS_ENABLED(CONFIG_IPV6) */
8feaf0c0a   Arnaldo Carvalho de Melo   [INET]: Generalis...
310
  #endif /* _IPV6_H */