#if USE_IPV6
/* under IPv6 there is the possibility IPv6 is present but disabled. */
/* try again as IPv4-native if possible */
- if ( sock < 0 && addr.IsIPv6() && addr.SetIPv4() ) {
+ if ( new_socket < 0 && addr.IsIPv6() && addr.SetIPv4() ) {
/* attempt to open this IPv4-only. */
addr.FreeAddrInfo(AI);
/* Setup the socket addrinfo details for use */
AI->ai_socktype = sock_type;
AI->ai_protocol = proto;
debugs(50, 3, "comm_openex: Attempt fallback open socket for: " << addr );
- new_socket = comm_openex(sock_type, proto, addr, flags, 0, note);
+ new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol);
debugs(50, 2, HERE << "attempt open " << note << " socket on: " << addr);
}
#endif
p1[i] &= p2[i];
}
- /* we have found a situation where mask forms or destroys a IPv4 map. */
- check4Mapped();
-
return changes;
}
const struct in6_addr IpAddress::v4_anyaddr = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}
};
+const struct in6_addr IpAddress::v4_noaddr = {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}
+};
const struct in6_addr IpAddress::v6_noaddr = {{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}
};
operator=(*res);
SetPort(port);
- /* free the memory xgetaddrinfo() dynamically allocated. */
- xfreeaddrinfo(res);
-
res = NULL;
return true;
memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in));
#endif
- /* maintain stored family values properly */
- check4Mapped();
-
return *this;
};
return *this;
};
-void IpAddress::check4Mapped()
-{
- // obsolete.
- // TODO use this NOW to set the sin6_family properly on exporting. not on import.
-}
-
#if USE_IPV6
IpAddress::IpAddress(struct sockaddr_in6 const &s)
{
{
memcpy(&m_SocketAddr, &s, sizeof(struct sockaddr_in6));
- /* maintain address family properly */
- check4Mapped();
return *this;
};
memcpy(&m_SocketAddr.sin_addr, &s, sizeof(struct in_addr));
#endif
-
- /* maintain stored family type properly */
- check4Mapped();
-
return *this;
};
memcpy(&m_SocketAddr.sin6_addr, &s, sizeof(struct in6_addr));
m_SocketAddr.sin6_family = AF_INET6;
- /* maintain address family type properly */
- check4Mapped();
-
return *this;
};
if ( in.s_addr == 0x00000000) {
/* ANYADDR */
- memset(&out, 0, sizeof(struct in6_addr));
+ out = v4_anyaddr;
} else if ( in.s_addr == 0xFFFFFFFF) {
/* NOADDR */
- memset(&out, 255, sizeof(struct in6_addr));
+ out = v4_noaddr;
} else {
/* general */
- memset(&out, 0, sizeof(struct in6_addr));
- out.s6_addr[10] = 0xFF;
- out.s6_addr[11] = 0xFF;
+ out = v4_anyaddr;
out.s6_addr[12] = ((uint8_t *)&in.s_addr)[0];
out.s6_addr[13] = ((uint8_t *)&in.s_addr)[1];
out.s6_addr[14] = ((uint8_t *)&in.s_addr)[2];