| @@ -55,88 +55,72 @@ | | | @@ -55,88 +55,72 @@ |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
62 | * SUCH DAMAGE. | | 62 | * SUCH DAMAGE. |
63 | * | | 63 | * |
64 | * @(#)in_pcb.c 8.2 (Berkeley) 1/4/94 | | 64 | * @(#)in_pcb.c 8.2 (Berkeley) 1/4/94 |
65 | */ | | 65 | */ |
66 | | | 66 | |
67 | #include <sys/cdefs.h> | | 67 | #include <sys/cdefs.h> |
68 | __KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.48 2009/05/12 22:22:46 elad Exp $"); | | 68 | __KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.49 2009/05/25 22:49:23 pooka Exp $"); |
69 | | | 69 | |
70 | #include "opt_inet.h" | | 70 | #include "opt_inet.h" |
71 | | | 71 | |
72 | #include <sys/param.h> | | 72 | #include <sys/param.h> |
73 | #include <sys/systm.h> | | 73 | #include <sys/systm.h> |
74 | #include <sys/malloc.h> | | 74 | #include <sys/malloc.h> |
75 | #include <sys/mbuf.h> | | 75 | #include <sys/mbuf.h> |
76 | #include <sys/protosw.h> | | 76 | #include <sys/protosw.h> |
77 | #include <sys/socket.h> | | 77 | #include <sys/socket.h> |
78 | #include <sys/socketvar.h> | | 78 | #include <sys/socketvar.h> |
79 | #ifndef __FreeBSD__ | | | |
80 | #include <sys/ioctl.h> | | 79 | #include <sys/ioctl.h> |
81 | #else | | | |
82 | #include <sys/sockio.h> | | | |
83 | #endif | | | |
84 | #ifdef __FreeBSD__ | | | |
85 | #include <sys/sysctl.h> | | | |
86 | #endif | | | |
87 | #include <sys/errno.h> | | 80 | #include <sys/errno.h> |
88 | #include <sys/time.h> | | 81 | #include <sys/time.h> |
89 | #include <sys/kernel.h> | | 82 | #include <sys/kernel.h> |
90 | #include <sys/proc.h> | | 83 | #include <sys/proc.h> |
91 | #include <sys/kauth.h> | | 84 | #include <sys/kauth.h> |
92 | | | 85 | |
93 | #include <net/if.h> | | 86 | #include <net/if.h> |
94 | #include <net/if_types.h> | | 87 | #include <net/if_types.h> |
95 | #include <net/route.h> | | 88 | #include <net/route.h> |
96 | | | 89 | |
97 | #include <netinet/in.h> | | 90 | #include <netinet/in.h> |
98 | #include <netinet/in_var.h> | | 91 | #include <netinet/in_var.h> |
99 | #include <netinet/in_systm.h> | | 92 | #include <netinet/in_systm.h> |
100 | #include <netinet/ip.h> | | 93 | #include <netinet/ip.h> |
101 | #include <netinet/in_pcb.h> | | 94 | #include <netinet/in_pcb.h> |
102 | #include <netinet6/in6_var.h> | | 95 | #include <netinet6/in6_var.h> |
103 | #include <netinet/ip6.h> | | 96 | #include <netinet/ip6.h> |
104 | #ifndef __OpenBSD__ | | | |
105 | #include <netinet6/in6_pcb.h> | | 97 | #include <netinet6/in6_pcb.h> |
106 | #endif | | | |
107 | #include <netinet6/ip6_var.h> | | 98 | #include <netinet6/ip6_var.h> |
108 | #include <netinet6/ip6_private.h> | | 99 | #include <netinet6/ip6_private.h> |
109 | #include <netinet6/nd6.h> | | 100 | #include <netinet6/nd6.h> |
110 | #include <netinet6/scope6_var.h> | | 101 | #include <netinet6/scope6_var.h> |
111 | | | 102 | |
112 | #include <net/net_osdep.h> | | 103 | #include <net/net_osdep.h> |
113 | | | 104 | |
114 | #ifdef MIP6 | | 105 | #ifdef MIP6 |
115 | #include <netinet6/mip6.h> | | 106 | #include <netinet6/mip6.h> |
116 | #include <netinet6/mip6_var.h> | | 107 | #include <netinet6/mip6_var.h> |
117 | #include "mip.h" | | 108 | #include "mip.h" |
118 | #if NMIP > 0 | | 109 | #if NMIP > 0 |
119 | #include <net/if_mip.h> | | 110 | #include <net/if_mip.h> |
120 | #endif /* NMIP > 0 */ | | 111 | #endif /* NMIP > 0 */ |
121 | #endif /* MIP6 */ | | 112 | #endif /* MIP6 */ |
122 | | | 113 | |
123 | #ifndef __OpenBSD__ | | | |
124 | #include "loop.h" | | | |
125 | #endif | | | |
126 | #ifdef __NetBSD__ | | | |
127 | extern struct ifnet loif[NLOOP]; | | | |
128 | #endif | | | |
129 | | | | |
130 | #define ADDR_LABEL_NOTAPP (-1) | | 114 | #define ADDR_LABEL_NOTAPP (-1) |
131 | struct in6_addrpolicy defaultaddrpolicy; | | 115 | struct in6_addrpolicy defaultaddrpolicy; |
132 | | | 116 | |
133 | #ifdef notyet /* until introducing ND extensions and address selection */ | | 117 | #ifdef notyet /* until introducing ND extensions and address selection */ |
134 | int ip6_prefer_tempaddr = 0; | | 118 | int ip6_prefer_tempaddr = 0; |
135 | #endif | | 119 | #endif |
136 | | | 120 | |
137 | static int selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, | | 121 | static int selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, |
138 | struct ip6_moptions *, struct route *, struct ifnet **, | | 122 | struct ip6_moptions *, struct route *, struct ifnet **, |
139 | struct rtentry **, int, int); | | 123 | struct rtentry **, int, int); |
140 | static int in6_selectif(struct sockaddr_in6 *, struct ip6_pktopts *, | | 124 | static int in6_selectif(struct sockaddr_in6 *, struct ip6_pktopts *, |
141 | struct ip6_moptions *, struct route *, struct ifnet **); | | 125 | struct ip6_moptions *, struct route *, struct ifnet **); |
142 | | | 126 | |
| @@ -593,31 +577,27 @@ selectroute(struct sockaddr_in6 *dstsock | | | @@ -593,31 +577,27 @@ selectroute(struct sockaddr_in6 *dstsock |
593 | !IN6_IS_ADDR_LOOPBACK(&dstsock->sin6_addr)) { | | 577 | !IN6_IS_ADDR_LOOPBACK(&dstsock->sin6_addr)) { |
594 | printf("in6_selectroute: strange destination %s\n", | | 578 | printf("in6_selectroute: strange destination %s\n", |
595 | ip6_sprintf(&dstsock->sin6_addr)); | | 579 | ip6_sprintf(&dstsock->sin6_addr)); |
596 | } else { | | 580 | } else { |
597 | printf("in6_selectroute: destination = %s%%%d\n", | | 581 | printf("in6_selectroute: destination = %s%%%d\n", |
598 | ip6_sprintf(&dstsock->sin6_addr), | | 582 | ip6_sprintf(&dstsock->sin6_addr), |
599 | dstsock->sin6_scope_id); /* for debug */ | | 583 | dstsock->sin6_scope_id); /* for debug */ |
600 | } | | 584 | } |
601 | #endif | | 585 | #endif |
602 | | | 586 | |
603 | /* If the caller specify the outgoing interface explicitly, use it. */ | | 587 | /* If the caller specify the outgoing interface explicitly, use it. */ |
604 | if (opts && (pi = opts->ip6po_pktinfo) != NULL && pi->ipi6_ifindex) { | | 588 | if (opts && (pi = opts->ip6po_pktinfo) != NULL && pi->ipi6_ifindex) { |
605 | /* XXX boundary check is assumed to be already done. */ | | 589 | /* XXX boundary check is assumed to be already done. */ |
606 | #ifdef __FreeBSD__ | | | |
607 | ifp = ifnet_byindex(pi->ipi6_ifindex); | | | |
608 | #else | | | |
609 | ifp = ifindex2ifnet[pi->ipi6_ifindex]; | | 590 | ifp = ifindex2ifnet[pi->ipi6_ifindex]; |
610 | #endif | | | |
611 | if (ifp != NULL && | | 591 | if (ifp != NULL && |
612 | (norouteok || retrt == NULL || | | 592 | (norouteok || retrt == NULL || |
613 | IN6_IS_ADDR_MULTICAST(dst))) { | | 593 | IN6_IS_ADDR_MULTICAST(dst))) { |
614 | /* | | 594 | /* |
615 | * we do not have to check or get the route for | | 595 | * we do not have to check or get the route for |
616 | * multicast. | | 596 | * multicast. |
617 | */ | | 597 | */ |
618 | goto done; | | 598 | goto done; |
619 | } else | | 599 | } else |
620 | goto getroute; | | 600 | goto getroute; |
621 | } | | 601 | } |
622 | | | 602 | |
623 | /* | | 603 | /* |