saddr4->sin_port = 0xffff;
}
#ifdef HAVE_IPV6
- else {
+ else if (af == AF_INET6) {
saddr6->sin6_port = 0xffff;
}
#endif
port = saddr4->sin_port;
}
#ifdef HAVE_IPV6
- else {
+ else if (saddr->sa_family == AF_INET6) {
port = saddr6->sin6_port;
}
#endif
- return port;
+ return port;
}
void IPADDR::set_port_net(unsigned short port)
saddr4->sin_port = port;
}
#ifdef HAVE_IPV6
- else {
+ else if (saddr->sa_family == AF_INET6) {
saddr6->sin6_port = port;
}
#endif
const char *IPADDR::build_address_str(char *buf, int blen)
{
char tmp[1024];
+ *buf = 0;
if (get_family() == AF_INET) {
bsnprintf(buf, blen, "%s:%hu ",
get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
- } else {
+ } else if (get_family() == AF_INET6) {
bsnprintf(buf, blen, "[%s]:%hu ",
get_address(tmp, sizeof(tmp) - 1), get_port_host_order());
}
return ((struct sockaddr_in *)client_addr)->sin_port;
}
#ifdef HAVE_IPV6
- else {
+ else if (client_addr->sa_family == AF_INET6) {
return ((struct sockaddr_in6 *)client_addr)->sin6_port;
}
#endif
return ntohs(((struct sockaddr_in *)client_addr)->sin_port);
}
#ifdef HAVE_IPV6
- else {
+ else if (client_addr->sa_family == AF_INET6) {
return ntohs(((struct sockaddr_in6 *)client_addr)->sin6_port);
}
#endif
IPADDR *addr = New(IPADDR(hp->h_addrtype));
addr->set_type(IPADDR::R_MULTIPLE);
if (addr->get_family() == AF_INET) {
- addr->set_addr4((struct in_addr*)*p);
+ addr->set_addr4((struct in_addr*)*p);
+ addr_list->append(addr);
}
#ifdef HAVE_IPV6
- else {
- addr->set_addr6((struct in6_addr*)*p);
+ else if (addr->get_family() == AF_INET6) {
+ addr->set_addr6((struct in6_addr*)*p);
+ addr_list->append(addr);
}
#endif
- addr_list->append(addr);
}
V(ip_mutex);
}