diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2007-02-21 12:25:42 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-02-26 14:42:52 -0500 |
commit | 8c14b7ce22a7ddd9fe1b1c852c4015633ec3efec (patch) | |
tree | acdf622ee0691c93242f37863c91169657637fa2 | |
parent | f4b9479dc5a1b0e1ca8666053f0d932baddc619d (diff) |
[IPV6] ADDRCONF: Statically link __ipv6_addr_type() for sunrpc subsystem.
Link __ipv6_addr_type() statically for sunrpc code even if IPv6 is
built as module.
Signed-off-by: YOSHIFUJI Hidaki <yoshfuji@linux-ipv6.org>
-rw-r--r-- | net/ipv6/Makefile | 2 | ||||
-rw-r--r-- | net/ipv6/addrconf.c | 68 | ||||
-rw-r--r-- | net/ipv6/addrconf_core.c | 75 |
3 files changed, 76 insertions, 69 deletions
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile index 8bacda109b7f..d460017bb353 100644 --- a/net/ipv6/Makefile +++ b/net/ipv6/Makefile | |||
@@ -32,6 +32,6 @@ obj-$(CONFIG_NETFILTER) += netfilter/ | |||
32 | obj-$(CONFIG_IPV6_SIT) += sit.o | 32 | obj-$(CONFIG_IPV6_SIT) += sit.o |
33 | obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o | 33 | obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o |
34 | 34 | ||
35 | obj-y += exthdrs_core.o | 35 | obj-y += addrconf_core.o exthdrs_core.o |
36 | 36 | ||
37 | obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o | 37 | obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 569a37d698f7..524bffe62499 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -211,74 +211,6 @@ const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; | |||
211 | #endif | 211 | #endif |
212 | const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; | 212 | const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; |
213 | 213 | ||
214 | #define IPV6_ADDR_SCOPE_TYPE(scope) ((scope) << 16) | ||
215 | |||
216 | static inline unsigned ipv6_addr_scope2type(unsigned scope) | ||
217 | { | ||
218 | switch(scope) { | ||
219 | case IPV6_ADDR_SCOPE_NODELOCAL: | ||
220 | return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_NODELOCAL) | | ||
221 | IPV6_ADDR_LOOPBACK); | ||
222 | case IPV6_ADDR_SCOPE_LINKLOCAL: | ||
223 | return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL) | | ||
224 | IPV6_ADDR_LINKLOCAL); | ||
225 | case IPV6_ADDR_SCOPE_SITELOCAL: | ||
226 | return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL) | | ||
227 | IPV6_ADDR_SITELOCAL); | ||
228 | } | ||
229 | return IPV6_ADDR_SCOPE_TYPE(scope); | ||
230 | } | ||
231 | |||
232 | int __ipv6_addr_type(const struct in6_addr *addr) | ||
233 | { | ||
234 | __be32 st; | ||
235 | |||
236 | st = addr->s6_addr32[0]; | ||
237 | |||
238 | /* Consider all addresses with the first three bits different of | ||
239 | 000 and 111 as unicasts. | ||
240 | */ | ||
241 | if ((st & htonl(0xE0000000)) != htonl(0x00000000) && | ||
242 | (st & htonl(0xE0000000)) != htonl(0xE0000000)) | ||
243 | return (IPV6_ADDR_UNICAST | | ||
244 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); | ||
245 | |||
246 | if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) { | ||
247 | /* multicast */ | ||
248 | /* addr-select 3.1 */ | ||
249 | return (IPV6_ADDR_MULTICAST | | ||
250 | ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr))); | ||
251 | } | ||
252 | |||
253 | if ((st & htonl(0xFFC00000)) == htonl(0xFE800000)) | ||
254 | return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST | | ||
255 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.1 */ | ||
256 | if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000)) | ||
257 | return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST | | ||
258 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL)); /* addr-select 3.1 */ | ||
259 | |||
260 | if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) { | ||
261 | if (addr->s6_addr32[2] == 0) { | ||
262 | if (addr->s6_addr32[3] == 0) | ||
263 | return IPV6_ADDR_ANY; | ||
264 | |||
265 | if (addr->s6_addr32[3] == htonl(0x00000001)) | ||
266 | return (IPV6_ADDR_LOOPBACK | IPV6_ADDR_UNICAST | | ||
267 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.4 */ | ||
268 | |||
269 | return (IPV6_ADDR_COMPATv4 | IPV6_ADDR_UNICAST | | ||
270 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */ | ||
271 | } | ||
272 | |||
273 | if (addr->s6_addr32[2] == htonl(0x0000ffff)) | ||
274 | return (IPV6_ADDR_MAPPED | | ||
275 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */ | ||
276 | } | ||
277 | |||
278 | return (IPV6_ADDR_RESERVED | | ||
279 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.4 */ | ||
280 | } | ||
281 | |||
282 | static void addrconf_del_timer(struct inet6_ifaddr *ifp) | 214 | static void addrconf_del_timer(struct inet6_ifaddr *ifp) |
283 | { | 215 | { |
284 | if (del_timer(&ifp->timer)) | 216 | if (del_timer(&ifp->timer)) |
diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c new file mode 100644 index 000000000000..644e0c742f99 --- /dev/null +++ b/net/ipv6/addrconf_core.c | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * IPv6 library code, needed by static components when full IPv6 support is | ||
3 | * not configured or static. | ||
4 | */ | ||
5 | |||
6 | #include <net/ipv6.h> | ||
7 | |||
8 | #define IPV6_ADDR_SCOPE_TYPE(scope) ((scope) << 16) | ||
9 | |||
10 | static inline unsigned ipv6_addr_scope2type(unsigned scope) | ||
11 | { | ||
12 | switch(scope) { | ||
13 | case IPV6_ADDR_SCOPE_NODELOCAL: | ||
14 | return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_NODELOCAL) | | ||
15 | IPV6_ADDR_LOOPBACK); | ||
16 | case IPV6_ADDR_SCOPE_LINKLOCAL: | ||
17 | return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL) | | ||
18 | IPV6_ADDR_LINKLOCAL); | ||
19 | case IPV6_ADDR_SCOPE_SITELOCAL: | ||
20 | return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL) | | ||
21 | IPV6_ADDR_SITELOCAL); | ||
22 | } | ||
23 | return IPV6_ADDR_SCOPE_TYPE(scope); | ||
24 | } | ||
25 | |||
26 | int __ipv6_addr_type(const struct in6_addr *addr) | ||
27 | { | ||
28 | __be32 st; | ||
29 | |||
30 | st = addr->s6_addr32[0]; | ||
31 | |||
32 | /* Consider all addresses with the first three bits different of | ||
33 | 000 and 111 as unicasts. | ||
34 | */ | ||
35 | if ((st & htonl(0xE0000000)) != htonl(0x00000000) && | ||
36 | (st & htonl(0xE0000000)) != htonl(0xE0000000)) | ||
37 | return (IPV6_ADDR_UNICAST | | ||
38 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); | ||
39 | |||
40 | if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) { | ||
41 | /* multicast */ | ||
42 | /* addr-select 3.1 */ | ||
43 | return (IPV6_ADDR_MULTICAST | | ||
44 | ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr))); | ||
45 | } | ||
46 | |||
47 | if ((st & htonl(0xFFC00000)) == htonl(0xFE800000)) | ||
48 | return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST | | ||
49 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.1 */ | ||
50 | if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000)) | ||
51 | return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST | | ||
52 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL)); /* addr-select 3.1 */ | ||
53 | |||
54 | if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) { | ||
55 | if (addr->s6_addr32[2] == 0) { | ||
56 | if (addr->s6_addr32[3] == 0) | ||
57 | return IPV6_ADDR_ANY; | ||
58 | |||
59 | if (addr->s6_addr32[3] == htonl(0x00000001)) | ||
60 | return (IPV6_ADDR_LOOPBACK | IPV6_ADDR_UNICAST | | ||
61 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL)); /* addr-select 3.4 */ | ||
62 | |||
63 | return (IPV6_ADDR_COMPATv4 | IPV6_ADDR_UNICAST | | ||
64 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */ | ||
65 | } | ||
66 | |||
67 | if (addr->s6_addr32[2] == htonl(0x0000ffff)) | ||
68 | return (IPV6_ADDR_MAPPED | | ||
69 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.3 */ | ||
70 | } | ||
71 | |||
72 | return (IPV6_ADDR_RESERVED | | ||
73 | IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* addr-select 3.4 */ | ||
74 | } | ||
75 | |||