1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-05 09:14:03 +00:00

Support per socket based IPv4 mapped IPv6 addr enable/disable control.

Submitted by: ume
This commit is contained in:
Yoshinobu Inoue 2000-04-01 22:35:47 +00:00
parent 1f0118b915
commit fdaf052eb3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58907
6 changed files with 17 additions and 13 deletions

View File

@ -153,6 +153,10 @@ in_pcballoc(so, pcbinfo, p)
inp->inp_gencnt = ++pcbinfo->ipi_gencnt;
inp->inp_pcbinfo = pcbinfo;
inp->inp_socket = so;
if (ip6_mapped_addr_on)
inp->inp_flags &= ~IN6P_BINDV6ONLY;
else
inp->inp_flags |= IN6P_BINDV6ONLY;
LIST_INSERT_HEAD(pcbinfo->listhead, inp, inp_list);
pcbinfo->ipi_count++;
so->so_pcb = (caddr_t)inp;
@ -231,7 +235,8 @@ in_pcbbind(inp, nam, p)
(so->so_cred->cr_uid !=
t->inp_socket->so_cred->cr_uid)) {
#if defined(INET6)
if (ip6_mapped_addr_on == 0 ||
if ((inp->inp_flags &
IN6P_BINDV6ONLY) != 0 ||
ntohl(sin->sin_addr.s_addr) !=
INADDR_ANY ||
ntohl(t->inp_laddr.s_addr) !=
@ -247,7 +252,7 @@ in_pcbbind(inp, nam, p)
if (t &&
(reuseport & t->inp_socket->so_options) == 0) {
#if defined(INET6)
if (ip6_mapped_addr_on == 0 ||
if ((inp->inp_flags & IN6P_BINDV6ONLY) != 0 ||
ntohl(sin->sin_addr.s_addr) !=
INADDR_ANY ||
ntohl(t->inp_laddr.s_addr) !=

View File

@ -740,7 +740,7 @@ tcp_input(m, off0, proto)
if (isipv6)
inp->in6p_laddr = ip6->ip6_dst;
else {
if (ip6_mapped_addr_on) {
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
inp->inp_vflag &= ~INP_IPV6;
inp->inp_vflag |= INP_IPV4;
}

View File

@ -740,7 +740,7 @@ tcp_input(m, off0, proto)
if (isipv6)
inp->in6p_laddr = ip6->ip6_dst;
else {
if (ip6_mapped_addr_on) {
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
inp->inp_vflag &= ~INP_IPV6;
inp->inp_vflag |= INP_IPV4;
}

View File

@ -238,7 +238,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
}
inp->inp_vflag &= ~INP_IPV4;
inp->inp_vflag |= INP_IPV6;
if (ip6_mapped_addr_on && (inp->inp_flags & IN6P_BINDV6ONLY) == NULL) {
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
if (IN6_IS_ADDR_UNSPECIFIED(&sin6p->sin6_addr))
inp->inp_vflag |= INP_IPV4;
@ -290,8 +290,7 @@ tcp6_usr_listen(struct socket *so, struct proc *p)
COMMON_START();
if (inp->inp_lport == 0) {
inp->inp_vflag &= ~INP_IPV4;
if (ip6_mapped_addr_on &&
(inp->inp_flags & IN6P_BINDV6ONLY) == NULL)
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0)
inp->inp_vflag |= INP_IPV4;
error = in6_pcbbind(inp, (struct sockaddr *)0, p);
}
@ -359,7 +358,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
goto out;
}
if (ip6_mapped_addr_on &&
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0 &&
IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
struct sockaddr_in sin;

View File

@ -224,7 +224,7 @@ in6_pcbbind(inp, nam, p)
(so->so_cred->cr_uid !=
t->inp_socket->so_cred->cr_uid))
return (EADDRINUSE);
if (ip6_mapped_addr_on != 0 &&
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0 &&
IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
struct sockaddr_in sin;
@ -246,7 +246,7 @@ in6_pcbbind(inp, nam, p)
lport, wild);
if (t && (reuseport & t->inp_socket->so_options) == 0)
return(EADDRINUSE);
if (ip6_mapped_addr_on != 0 &&
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0 &&
IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
struct sockaddr_in sin;

View File

@ -670,7 +670,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
inp->inp_vflag &= ~INP_IPV4;
inp->inp_vflag |= INP_IPV6;
if (ip6_mapped_addr_on && (inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
struct sockaddr_in6 *sin6_p;
sin6_p = (struct sockaddr_in6 *)nam;
@ -705,7 +705,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
inp = sotoinpcb(so);
if (inp == 0)
return EINVAL;
if (ip6_mapped_addr_on) {
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
struct sockaddr_in6 *sin6_p;
sin6_p = (struct sockaddr_in6 *)nam;
@ -794,7 +794,7 @@ udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
return EINVAL;
}
if (ip6_mapped_addr_on) {
if ((inp->inp_flags & IN6P_BINDV6ONLY) == 0) {
int hasv4addr;
struct sockaddr_in6 *sin6 = 0;