1 #ifndef _ADDRCONF_H
2 #define _ADDRCONF_H
3
4 #define RETRANS_TIMER HZ
5
6 #define MAX_RTR_SOLICITATIONS 3
7 #define RTR_SOLICITATION_INTERVAL (4*HZ)
8
9 #define ADDR_CHECK_FREQUENCY (120*HZ)
10
11 struct prefix_info {
12 __u8 type;
13 __u8 length;
14 __u8 prefix_len;
15
16 #if defined(__BIG_ENDIAN_BITFIELD)
17 __u8 onlink : 1,
18 autoconf : 1,
19 reserved : 6;
20 #elif defined(__LITTLE_ENDIAN_BITFIELD)
21 __u8 reserved : 6,
22 autoconf : 1,
23 onlink : 1;
24 #else
25 #error "Please fix <asm/byteorder.h>"
26 #endif
27 __u32 valid;
28 __u32 prefered;
29 __u32 reserved2;
30
31 struct in6_addr prefix;
32 };
33
34
35 #ifdef __KERNEL__
36
37 #include <linux/in6.h>
38 #include <linux/netdevice.h>
39 #include <net/if_inet6.h>
40
41 #define IN6_ADDR_HSIZE 16
42
43 extern void addrconf_init(void);
44 extern void addrconf_cleanup(void);
45
46 extern int addrconf_notify(struct notifier_block *this,
47 unsigned long event,
48 void * data);
49
50 extern int addrconf_add_ifaddr(void *arg);
51 extern int addrconf_del_ifaddr(void *arg);
52 extern int addrconf_set_dstaddr(void *arg);
53
54 extern int ipv6_chk_addr(struct in6_addr *addr,
55 struct net_device *dev);
56 extern struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr,
57 struct net_device *dev);
58 extern int ipv6_get_saddr(struct dst_entry *dst,
59 struct in6_addr *daddr,
60 struct in6_addr *saddr);
61 extern int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *);
62
63 /*
64 * multicast prototypes (mcast.c)
65 */
66 extern int ipv6_sock_mc_join(struct sock *sk,
67 int ifindex,
68 struct in6_addr *addr);
69 extern int ipv6_sock_mc_drop(struct sock *sk,
70 int ifindex,
71 struct in6_addr *addr);
72 extern void ipv6_sock_mc_close(struct sock *sk);
73 extern int inet6_mc_check(struct sock *sk, struct in6_addr *addr);
74
75 extern int ipv6_dev_mc_inc(struct net_device *dev,
76 struct in6_addr *addr);
77 extern int ipv6_dev_mc_dec(struct net_device *dev,
78 struct in6_addr *addr);
79 extern void ipv6_mc_up(struct inet6_dev *idev);
80 extern void ipv6_mc_down(struct inet6_dev *idev);
81 extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
82 extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
83
84 extern int ipv6_chk_mcast_addr(struct net_device *dev,
85 struct in6_addr *addr);
86
87 extern void addrconf_prefix_rcv(struct net_device *dev,
88 u8 *opt, int len);
89
90 static inline struct inet6_dev *
91 __in6_dev_get(struct net_device *dev)
92 {
93 return (struct inet6_dev *)dev->ip6_ptr;
94 }
95
96 extern rwlock_t addrconf_lock;
97
98 static inline struct inet6_dev *
99 in6_dev_get(struct net_device *dev)
100 {
101 struct inet6_dev *idev = NULL;
102 read_lock(&addrconf_lock);
103 idev = dev->ip6_ptr;
104 if (idev)
105 atomic_inc(&idev->refcnt);
106 read_unlock(&addrconf_lock);
107 return idev;
108 }
109
110 extern void in6_dev_finish_destroy(struct inet6_dev *idev);
111
112 static inline void
113 in6_dev_put(struct inet6_dev *idev)
114 {
115 if (atomic_dec_and_test(&idev->refcnt))
116 in6_dev_finish_destroy(idev);
117 }
118
119 #define __in6_dev_put(idev) atomic_dec(&(idev)->refcnt)
120 #define in6_dev_hold(idev) atomic_inc(&(idev)->refcnt)
121
122
123 extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
124
125 static inline void in6_ifa_put(struct inet6_ifaddr *ifp)
126 {
127 if (atomic_dec_and_test(&ifp->refcnt))
128 inet6_ifa_finish_destroy(ifp);
129 }
130
131 #define __in6_ifa_put(idev) atomic_dec(&(idev)->refcnt)
132 #define in6_ifa_hold(idev) atomic_inc(&(idev)->refcnt)
133
134
135 extern void addrconf_forwarding_on(void);
136 /*
137 * Hash function taken from net_alias.c
138 */
139
140 static __inline__ u8 ipv6_addr_hash(struct in6_addr *addr)
141 {
142 __u32 word;
143
144 /*
145 * We perform the hash function over the last 64 bits of the address
146 * This will include the IEEE address token on links that support it.
147 */
148
149 word = addr->s6_addr[2] ^ addr->s6_addr32[3];
150 word ^= (word>>16);
151 word ^= (word >> 8);
152
153 return ((word ^ (word >> 4)) & 0x0f);
154 }
155
156 /*
157 * compute link-local solicited-node multicast address
158 */
159
160 static inline void addrconf_addr_solict_mult_old(struct in6_addr *addr,
161 struct in6_addr *solicited)
162 {
163 ipv6_addr_set(solicited,
164 __constant_htonl(0xFF020000), 0,
165 __constant_htonl(0x1), addr->s6_addr32[3]);
166 }
167
168 static inline void addrconf_addr_solict_mult_new(struct in6_addr *addr,
169 struct in6_addr *solicited)
170 {
171 ipv6_addr_set(solicited,
172 __constant_htonl(0xFF020000), 0,
173 __constant_htonl(0x1),
174 __constant_htonl(0xFF000000) | addr->s6_addr32[3]);
175 }
176
177
178 static inline void ipv6_addr_all_nodes(struct in6_addr *addr)
179 {
180 ipv6_addr_set(addr,
181 __constant_htonl(0xFF020000), 0, 0,
182 __constant_htonl(0x1));
183 }
184
185 static inline void ipv6_addr_all_routers(struct in6_addr *addr)
186 {
187 ipv6_addr_set(addr,
188 __constant_htonl(0xFF020000), 0, 0,
189 __constant_htonl(0x2));
190 }
191
192 static inline int ipv6_addr_is_multicast(struct in6_addr *addr)
193 {
194 return (addr->s6_addr32[0] & __constant_htonl(0xFF000000)) == __constant_htonl(0xFF000000);
195 }
196
197 #endif
198 #endif
199
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.