Blame view

include/net/if_inet6.h 7 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  /*
   *	inet6 interface/address list definitions
   *	Linux INET6 implementation 
   *
   *	Authors:
   *	Pedro Roque		<roque@di.fc.ul.pt>	
   *
   *
   *	This program is free software; you can redistribute it and/or
   *      modify it under the terms of the GNU General Public License
   *      as published by the Free Software Foundation; either version
   *      2 of the License, or (at your option) any later version.
   */
  
  #ifndef _NET_IF_INET6_H
  #define _NET_IF_INET6_H
  
  #include <net/snmp.h>
  #include <linux/ipv6.h>
  
  /* inet6_dev.if_flags */
  
  #define IF_RA_OTHERCONF	0x80
  #define IF_RA_MANAGED	0x40
  #define IF_RA_RCVD	0x20
  #define IF_RS_SENT	0x10
3c21edbd1   YOSHIFUJI Hideaki   [IPV6]: Defer IPv...
27
  #define IF_READY	0x80000000
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
30
31
  
  /* prefix flags */
  #define IF_PREFIX_ONLINK	0x01
  #define IF_PREFIX_AUTOCONF	0x02
e9d3e0849   Herbert Xu   ipv6: Replace ine...
32
33
34
35
36
37
  enum {
  	INET6_IFADDR_STATE_DAD,
  	INET6_IFADDR_STATE_POSTDAD,
  	INET6_IFADDR_STATE_UP,
  	INET6_IFADDR_STATE_DEAD,
  };
fd2c3ef76   Eric Dumazet   net: cleanup incl...
38
  struct inet6_ifaddr {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
39
40
41
  	struct in6_addr		addr;
  	__u32			prefix_len;
  	
76f793e3a   Lorenzo Colitti   ipv6: updates to ...
42
  	/* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43
44
  	__u32			valid_lft;
  	__u32			prefered_lft;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
  	atomic_t		refcnt;
  	spinlock_t		lock;
e9d3e0849   Herbert Xu   ipv6: Replace ine...
47
48
49
  	spinlock_t		state_lock;
  
  	int			state;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
52
53
54
  
  	__u8			probes;
  	__u8			flags;
  
  	__u16			scope;
04ec5cfcf   Richard Kennedy   ipv6: reorder str...
55
56
  	unsigned long		cstamp;	/* created timestamp */
  	unsigned long		tstamp; /* updated timestamp */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
59
60
  	struct timer_list	timer;
  
  	struct inet6_dev	*idev;
  	struct rt6_info		*rt;
c2e21293c   stephen hemminger   ipv6: convert add...
61
  	struct hlist_node	addr_lst;
502a2ffd7   stephen hemminger   ipv6: convert ide...
62
  	struct list_head	if_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
64
  
  #ifdef CONFIG_IPV6_PRIVACY
372e6c8f1   stephen hemminger   ipv6: convert tem...
65
  	struct list_head	tmp_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
67
68
  	struct inet6_ifaddr	*ifpub;
  	int			regen_count;
  #endif
5c578aedc   stephen hemminger   IPv6: convert add...
69
  	struct rcu_head		rcu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
  };
fd2c3ef76   Eric Dumazet   net: cleanup incl...
71
  struct ip6_sf_socklist {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
75
76
77
78
79
80
  	unsigned int		sl_max;
  	unsigned int		sl_count;
  	struct in6_addr		sl_addr[0];
  };
  
  #define IP6_SFLSIZE(count)	(sizeof(struct ip6_sf_socklist) + \
  	(count) * sizeof(struct in6_addr))
  
  #define IP6_SFBLOCK	10	/* allocate this many at once */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
81
  struct ipv6_mc_socklist {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
  	struct in6_addr		addr;
  	int			ifindex;
456b61bca   Eric Dumazet   ipv6: mcast: RCU ...
84
  	struct ipv6_mc_socklist __rcu *next;
5ab4a6c81   David L Stevens   [IPV6] mcast: Fix...
85
  	rwlock_t		sflock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
  	unsigned int		sfmode;		/* MCAST_{INCLUDE,EXCLUDE} */
  	struct ip6_sf_socklist	*sflist;
456b61bca   Eric Dumazet   ipv6: mcast: RCU ...
88
  	struct rcu_head		rcu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
89
  };
fd2c3ef76   Eric Dumazet   net: cleanup incl...
90
  struct ip6_sf_list {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
93
94
95
96
97
98
99
100
101
102
103
  	struct ip6_sf_list	*sf_next;
  	struct in6_addr		sf_addr;
  	unsigned long		sf_count[2];	/* include/exclude counts */
  	unsigned char		sf_gsresp;	/* include in g & s response? */
  	unsigned char		sf_oldin;	/* change state */
  	unsigned char		sf_crcount;	/* retrans. left to send */
  };
  
  #define MAF_TIMER_RUNNING	0x01
  #define MAF_LAST_REPORTER	0x02
  #define MAF_LOADED		0x04
  #define MAF_NOREPORT		0x08
  #define MAF_GSQUERY		0x10
fd2c3ef76   Eric Dumazet   net: cleanup incl...
104
  struct ifmcaddr6 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
105
106
107
108
109
110
  	struct in6_addr		mca_addr;
  	struct inet6_dev	*idev;
  	struct ifmcaddr6	*next;
  	struct ip6_sf_list	*mca_sources;
  	struct ip6_sf_list	*mca_tomb;
  	unsigned int		mca_sfmode;
246f19d19   Arnaldo Carvalho de Melo   [IPV6]: Reorg str...
111
  	unsigned char		mca_crcount;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
113
114
115
116
117
  	unsigned long		mca_sfcount[2];
  	struct timer_list	mca_timer;
  	unsigned		mca_flags;
  	int			mca_users;
  	atomic_t		mca_refcnt;
  	spinlock_t		mca_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
119
120
121
122
  	unsigned long		mca_cstamp;
  	unsigned long		mca_tstamp;
  };
  
  /* Anycast stuff */
fd2c3ef76   Eric Dumazet   net: cleanup incl...
123
  struct ipv6_ac_socklist {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
125
126
127
  	struct in6_addr		acl_addr;
  	int			acl_ifindex;
  	struct ipv6_ac_socklist *acl_next;
  };
fd2c3ef76   Eric Dumazet   net: cleanup incl...
128
  struct ifacaddr6 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  	struct in6_addr		aca_addr;
  	struct inet6_dev	*aca_idev;
  	struct rt6_info		*aca_rt;
  	struct ifacaddr6	*aca_next;
  	int			aca_users;
  	atomic_t		aca_refcnt;
  	spinlock_t		aca_lock;
  	unsigned long		aca_cstamp;
  	unsigned long		aca_tstamp;
  };
  
  #define	IFA_HOST	IPV6_ADDR_LOOPBACK
  #define	IFA_LINK	IPV6_ADDR_LINKLOCAL
  #define	IFA_SITE	IPV6_ADDR_SITELOCAL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
143
144
145
  
  struct ipv6_devstat {
  	struct proc_dir_entry	*proc_dir_entry;
a11d206d0   YOSHIFUJI Hideaki   [IPV6]: Per-inter...
146
  	DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
be281e554   Eric Dumazet   ipv6: reduce per ...
147
148
  	DEFINE_SNMP_STAT_ATOMIC(struct icmpv6_mib_device, icmpv6dev);
  	DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib_device, icmpv6msgdev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
  };
fd2c3ef76   Eric Dumazet   net: cleanup incl...
150
  struct inet6_dev {
502a2ffd7   stephen hemminger   ipv6: convert ide...
151
  	struct net_device	*dev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
152

502a2ffd7   stephen hemminger   ipv6: convert ide...
153
  	struct list_head	addr_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
155
156
  
  	struct ifmcaddr6	*mc_list;
  	struct ifmcaddr6	*mc_tomb;
6457d26bd   Stephen Hemminger   IPv6: convert mc_...
157
  	spinlock_t		mc_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
158
159
160
  	unsigned char		mc_qrv;
  	unsigned char		mc_gq_running;
  	unsigned char		mc_ifc_count;
4e7e5cfe3   Arnaldo Carvalho de Melo   [INET6]: Reorgani...
161
162
  	unsigned long		mc_v1_seen;
  	unsigned long		mc_maxdelay;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
163
164
165
166
167
168
169
170
171
172
173
  	struct timer_list	mc_gq_timer;	/* general query timer */
  	struct timer_list	mc_ifc_timer;	/* interface change timer */
  
  	struct ifacaddr6	*ac_list;
  	rwlock_t		lock;
  	atomic_t		refcnt;
  	__u32			if_flags;
  	int			dead;
  
  #ifdef CONFIG_IPV6_PRIVACY
  	u8			rndid[8];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
174
  	struct timer_list	regen_timer;
372e6c8f1   stephen hemminger   ipv6: convert tem...
175
  	struct list_head	tempaddr_list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176
177
178
179
180
181
182
  #endif
  
  	struct neigh_parms	*nd_parms;
  	struct inet6_dev	*next;
  	struct ipv6_devconf	cnf;
  	struct ipv6_devstat	stats;
  	unsigned long		tstamp; /* ipv6InterfaceTable update timestamp */
8814c4b53   YOSHIFUJI Hideaki   [IPV6] ADDRCONF: ...
183
  	struct rcu_head		rcu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
  };
b71d1d426   Eric Dumazet   inet: constify ip...
185
  static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
186
187
188
189
190
191
192
193
194
195
196
197
  {
  	/*
  	 *	+-------+-------+-------+-------+-------+-------+
  	 *      |   33  |   33  | DST13 | DST14 | DST15 | DST16 |
  	 *      +-------+-------+-------+-------+-------+-------+
  	 */
  
  	buf[0]= 0x33;
  	buf[1]= 0x33;
  
  	memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
  }
b71d1d426   Eric Dumazet   inet: constify ip...
198
  static inline void ipv6_tr_mc_map(const struct in6_addr *addr, char *buf)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
  {
  	/* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */
  
  	if (((addr->s6_addr[0] == 0xFF) &&
  	    ((addr->s6_addr[1] == 0x01) || (addr->s6_addr[1] == 0x02)) &&
  	     (addr->s6_addr16[1] == 0) &&
  	     (addr->s6_addr32[1] == 0) &&
  	     (addr->s6_addr32[2] == 0) &&
  	     (addr->s6_addr16[6] == 0) &&
  	     (addr->s6_addr[15] == 1)) ||
  	    ((addr->s6_addr[0] == 0xFF) &&
  	     (addr->s6_addr[1] == 0x02) &&
  	     (addr->s6_addr16[1] == 0) &&
  	     (addr->s6_addr32[1] == 0) &&
  	     (addr->s6_addr16[4] == 0) &&
  	     (addr->s6_addr[10] == 0) &&
  	     (addr->s6_addr[11] == 1) &&
  	     (addr->s6_addr[12] == 0xff)))
  	{
  		buf[0]=0xC0;
  		buf[1]=0x00;
  		buf[2]=0x01;
  		buf[3]=0x00;
  		buf[4]=0x00;
  		buf[5]=0x00;
  	/* All routers FF0x::2 */
  	} else if ((addr->s6_addr[0] ==0xff) &&
  		((addr->s6_addr[1] & 0xF0) == 0) &&
  		(addr->s6_addr16[1] == 0) &&
  		(addr->s6_addr32[1] == 0) &&
  		(addr->s6_addr32[2] == 0) &&
  		(addr->s6_addr16[6] == 0) &&
  		(addr->s6_addr[15] == 2))
  	{
  		buf[0]=0xC0;
  		buf[1]=0x00;
  		buf[2]=0x02;
  		buf[3]=0x00;
  		buf[4]=0x00;
  		buf[5]=0x00;
  	} else {
  		unsigned char i ; 
  		
  		i = addr->s6_addr[15] & 7 ; 
  		buf[0]=0xC0;
  		buf[1]=0x00;
  		buf[2]=0x00;
  		buf[3]=0x01 << i ; 
  		buf[4]=0x00;
  		buf[5]=0x00;
  	}
  }
  
  static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf)
  {
  	buf[0] = 0x00;
  }
a9e527e3f   Rolf Manderscheid   IPoIB: improve IP...
256
257
  static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
  				  const unsigned char *broadcast, char *buf)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
258
  {
a9e527e3f   Rolf Manderscheid   IPoIB: improve IP...
259
  	unsigned char scope = broadcast[5] & 0xF;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
260
261
262
263
264
  	buf[0]  = 0;		/* Reserved */
  	buf[1]  = 0xff;		/* Multicast QPN */
  	buf[2]  = 0xff;
  	buf[3]  = 0xff;
  	buf[4]  = 0xff;
a9e527e3f   Rolf Manderscheid   IPoIB: improve IP...
265
  	buf[5]  = 0x10 | scope;	/* scope from broadcast address */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
266
267
  	buf[6]  = 0x60;		/* IPv6 signature */
  	buf[7]  = 0x1b;
a9e527e3f   Rolf Manderscheid   IPoIB: improve IP...
268
269
  	buf[8]  = broadcast[8];	/* P_Key */
  	buf[9]  = broadcast[9];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
270
271
  	memcpy(buf + 10, addr->s6_addr + 6, 10);
  }
93ca3bb5d   Timo Teräs   net: gre: provide...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
  
  static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
  				    const unsigned char *broadcast, char *buf)
  {
  	if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) {
  		memcpy(buf, broadcast, 4);
  	} else {
  		/* v4mapped? */
  		if ((addr->s6_addr32[0] | addr->s6_addr32[1] |
  		     (addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0)
  			return -EINVAL;
  		memcpy(buf, &addr->s6_addr32[3], 4);
  	}
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
287
  #endif