4 #define RETRANS_TIMER HZ
6 #define MAX_RTR_SOLICITATIONS 3
7 #define RTR_SOLICITATION_INTERVAL (4*HZ)
9 #define ADDR_CHECK_FREQUENCY (120*HZ)
16 #if defined(__BIG_ENDIAN_BITFIELD)
20 #elif defined(__LITTLE_ENDIAN_BITFIELD)
25 #error "Please fix <asm/byteorder.h>"
31 struct in6_addr prefix;
37 #include <linux/in6.h>
38 #include <linux/netdevice.h>
39 #include <net/if_inet6.h>
41 #define IN6_ADDR_HSIZE 16
43 extern void addrconf_init(void);
44 extern void addrconf_cleanup(void);
46 extern int addrconf_notify(struct notifier_block *this,
50 extern int addrconf_add_ifaddr(void *arg);
51 extern int addrconf_del_ifaddr(void *arg);
52 extern int addrconf_set_dstaddr(void *arg);
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 *);
64 * multicast prototypes (mcast.c)
66 extern int ipv6_sock_mc_join(struct sock *sk,
68 struct in6_addr *addr);
69 extern int ipv6_sock_mc_drop(struct sock *sk,
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);
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_init_dev(struct inet6_dev *idev);
82 extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
83 extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);
85 extern int ipv6_chk_mcast_addr(struct net_device *dev,
86 struct in6_addr *addr);
88 extern void addrconf_prefix_rcv(struct net_device *dev,
92 extern int register_inet6addr_notifier(struct notifier_block *nb);
93 extern int unregister_inet6addr_notifier(struct notifier_block *nb);
95 static inline struct inet6_dev *
96 __in6_dev_get(struct net_device *dev)
98 return (struct inet6_dev *)dev->ip6_ptr;
101 extern rwlock_t addrconf_lock;
103 static inline struct inet6_dev *
104 in6_dev_get(struct net_device *dev)
106 struct inet6_dev *idev = NULL;
107 read_lock(&addrconf_lock);
110 atomic_inc(&idev->refcnt);
111 read_unlock(&addrconf_lock);
115 extern void in6_dev_finish_destroy(struct inet6_dev *idev);
118 in6_dev_put(struct inet6_dev *idev)
120 if (atomic_dec_and_test(&idev->refcnt))
121 in6_dev_finish_destroy(idev);
124 #define __in6_dev_put(idev) atomic_dec(&(idev)->refcnt)
125 #define in6_dev_hold(idev) atomic_inc(&(idev)->refcnt)
128 extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
130 static inline void in6_ifa_put(struct inet6_ifaddr *ifp)
132 if (atomic_dec_and_test(&ifp->refcnt))
133 inet6_ifa_finish_destroy(ifp);
136 #define __in6_ifa_put(idev) atomic_dec(&(idev)->refcnt)
137 #define in6_ifa_hold(idev) atomic_inc(&(idev)->refcnt)
140 extern void addrconf_forwarding_on(void);
142 * Hash function taken from net_alias.c
145 static __inline__ u8 ipv6_addr_hash(struct in6_addr *addr)
150 * We perform the hash function over the last 64 bits of the address
151 * This will include the IEEE address token on links that support it.
154 word = addr->s6_addr[2] ^ addr->s6_addr32[3];
158 return ((word ^ (word >> 4)) & 0x0f);
162 * compute link-local solicited-node multicast address
165 static inline void addrconf_addr_solict_mult(struct in6_addr *addr,
166 struct in6_addr *solicited)
168 ipv6_addr_set(solicited,
169 __constant_htonl(0xFF020000), 0,
170 __constant_htonl(0x1),
171 __constant_htonl(0xFF000000) | addr->s6_addr32[3]);
175 static inline void ipv6_addr_all_nodes(struct in6_addr *addr)
178 __constant_htonl(0xFF020000), 0, 0,
179 __constant_htonl(0x1));
182 static inline void ipv6_addr_all_routers(struct in6_addr *addr)
185 __constant_htonl(0xFF020000), 0, 0,
186 __constant_htonl(0x2));
189 static inline int ipv6_addr_is_multicast(struct in6_addr *addr)
191 return (addr->s6_addr32[0] & __constant_htonl(0xFF000000)) == __constant_htonl(0xFF000000);
194 static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr)
196 return (addr->s6_addr32[0] == htonl(0xff020000) &&
197 addr->s6_addr32[1] == 0 &&
198 addr->s6_addr32[2] == 0 &&
199 addr->s6_addr32[3] == htonl(0x00000001));
202 static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
204 return (addr->s6_addr32[0] == htonl(0xff020000) &&
205 addr->s6_addr32[1] == 0 &&
206 addr->s6_addr32[2] == 0 &&
207 addr->s6_addr32[3] == htonl(0x00000002));