26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <sys/ksynch.h>
29 #include <sys/kmem.h>
30 #include <sys/errno.h>
31 #include <sys/systm.h>
32 #include <sys/sysmacros.h>
33 #include <sys/cmn_err.h>
34 #include <sys/strsun.h>
35 #include <sys/zone.h>
36 #include <netinet/in.h>
37 #include <inet/common.h>
38 #include <inet/ip.h>
39 #include <inet/ip6.h>
40 #include <inet/ip6_asp.h>
41 #include <inet/ip_ire.h>
42 #include <inet/ip_if.h>
43 #include <inet/ipclassifier.h>
44
45 #define IN6ADDR_MASK128_INIT \
46 { 0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU }
47 #define IN6ADDR_MASK96_INIT { 0xffffffffU, 0xffffffffU, 0xffffffffU, 0 }
48 #ifdef _BIG_ENDIAN
49 #define IN6ADDR_MASK16_INIT { 0xffff0000U, 0, 0, 0 }
50 #else
51 #define IN6ADDR_MASK16_INIT { 0x0000ffffU, 0, 0, 0 }
52 #endif
53
54
55 /*
56 * This table is ordered such that longest prefix matches are hit first
57 * (longer prefix lengths first). The last entry must be the "default"
58 * entry (::0/0).
59 */
60 static ip6_asp_t default_ip6_asp_table[] = {
61 { IN6ADDR_LOOPBACK_INIT, IN6ADDR_MASK128_INIT,
62 "Loopback", 50 },
63 { IN6ADDR_ANY_INIT, IN6ADDR_MASK96_INIT,
64 "IPv4_Compatible", 20 },
65 #ifdef _BIG_ENDIAN
66 { { 0, 0, 0x0000ffffU, 0 }, IN6ADDR_MASK96_INIT,
67 "IPv4", 10 },
68 { { 0x20020000U, 0, 0, 0 }, IN6ADDR_MASK16_INIT,
69 "6to4", 30 },
70 #else
71 { { 0, 0, 0xffff0000U, 0 }, IN6ADDR_MASK96_INIT,
72 "IPv4", 10 },
73 { { 0x00000220U, 0, 0, 0 }, IN6ADDR_MASK16_INIT,
74 "6to4", 30 },
75 #endif
76 { IN6ADDR_ANY_INIT, IN6ADDR_ANY_INIT,
77 "Default", 40 }
78 };
79
80 /*
81 * The IPv6 Default Address Selection policy table.
82 * Until someone up above reconfigures the policy table, use the global
83 * default. The table needs no lock since the only way to alter it is
84 * through the SIOCSIP6ADDRPOLICY which is exclusive in ip.
85 */
86 static void ip6_asp_copy(ip6_asp_t *, ip6_asp_t *, uint_t);
87 static void ip6_asp_check_for_updates(ip_stack_t *);
88
89 void
90 ip6_asp_init(ip_stack_t *ipst)
91 {
92 /* Initialize the table lock */
93 mutex_init(&ipst->ips_ip6_asp_lock, NULL, MUTEX_DEFAULT, NULL);
94
95 ipst->ips_ip6_asp_table = default_ip6_asp_table;
96
97 ipst->ips_ip6_asp_table_count =
|
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <sys/ksynch.h>
29 #include <sys/kmem.h>
30 #include <sys/errno.h>
31 #include <sys/systm.h>
32 #include <sys/sysmacros.h>
33 #include <sys/cmn_err.h>
34 #include <sys/strsun.h>
35 #include <sys/zone.h>
36 #include <netinet/in.h>
37 #include <inet/common.h>
38 #include <inet/ip.h>
39 #include <inet/ip6.h>
40 #include <inet/ip6_asp.h>
41 #include <inet/ip_ire.h>
42 #include <inet/ip_if.h>
43 #include <inet/ipclassifier.h>
44
45 #define IN6ADDR_MASK128_INIT \
46 {{{ 0xffffffffU, 0xffffffffU, 0xffffffffU, 0xffffffffU }}}
47 #define IN6ADDR_MASK96_INIT {{{ 0xffffffffU, 0xffffffffU, 0xffffffffU, 0 }}}
48 #ifdef _BIG_ENDIAN
49 #define IN6ADDR_MASK16_INIT {{{ 0xffff0000U, 0, 0, 0 }}}
50 #else
51 #define IN6ADDR_MASK16_INIT {{{ 0x0000ffffU, 0, 0, 0 }}}
52 #endif
53
54
55 /*
56 * This table is ordered such that longest prefix matches are hit first
57 * (longer prefix lengths first). The last entry must be the "default"
58 * entry (::0/0).
59 */
60 static ip6_asp_t default_ip6_asp_table[] = {
61 { IN6ADDR_LOOPBACK_INIT, IN6ADDR_MASK128_INIT,
62 {"Loopback"}, 50 },
63 { IN6ADDR_ANY_INIT, IN6ADDR_MASK96_INIT,
64 {"IPv4_Compatible"}, 20 },
65 #ifdef _BIG_ENDIAN
66 { {{{ 0, 0, 0x0000ffffU, 0 }}}, IN6ADDR_MASK96_INIT,
67 {"IPv4"}, 10 },
68 { {{{ 0x20020000U, 0, 0, 0 }}}, IN6ADDR_MASK16_INIT,
69 {"6to4"}, 30 },
70 #else
71 { {{{ 0, 0, 0xffff0000U, 0 }}}, IN6ADDR_MASK96_INIT,
72 {"IPv4"}, 10 },
73 { {{{ 0x00000220U, 0, 0, 0 }}}, IN6ADDR_MASK16_INIT,
74 {"6to4"}, 30 },
75 #endif
76 { IN6ADDR_ANY_INIT, IN6ADDR_ANY_INIT,
77 {"Default"}, 40 }
78 };
79
80 /*
81 * The IPv6 Default Address Selection policy table.
82 * Until someone up above reconfigures the policy table, use the global
83 * default. The table needs no lock since the only way to alter it is
84 * through the SIOCSIP6ADDRPOLICY which is exclusive in ip.
85 */
86 static void ip6_asp_copy(ip6_asp_t *, ip6_asp_t *, uint_t);
87 static void ip6_asp_check_for_updates(ip_stack_t *);
88
89 void
90 ip6_asp_init(ip_stack_t *ipst)
91 {
92 /* Initialize the table lock */
93 mutex_init(&ipst->ips_ip6_asp_lock, NULL, MUTEX_DEFAULT, NULL);
94
95 ipst->ips_ip6_asp_table = default_ip6_asp_table;
96
97 ipst->ips_ip6_asp_table_count =
|