|
@ -1532,18 +1532,10 @@ static struct io_plan *connection_in(struct io_conn *conn, struct daemon *daemon |
|
|
|
|
|
|
|
|
if (s.ss_family == AF_INET6) { |
|
|
if (s.ss_family == AF_INET6) { |
|
|
struct sockaddr_in6 *s6 = (void *)&s; |
|
|
struct sockaddr_in6 *s6 = (void *)&s; |
|
|
addr.type = ADDR_TYPE_IPV6; |
|
|
wireaddr_from_ipv6(&addr, &s6->sin6_addr, ntohs(s6->sin6_port)); |
|
|
addr.addrlen = sizeof(s6->sin6_addr); |
|
|
|
|
|
BUILD_ASSERT(sizeof(s6->sin6_addr) <= sizeof(addr.addr)); |
|
|
|
|
|
memcpy(addr.addr, &s6->sin6_addr, addr.addrlen); |
|
|
|
|
|
addr.port = ntohs(s6->sin6_port); |
|
|
|
|
|
} else if (s.ss_family == AF_INET) { |
|
|
} else if (s.ss_family == AF_INET) { |
|
|
struct sockaddr_in *s4 = (void *)&s; |
|
|
struct sockaddr_in *s4 = (void *)&s; |
|
|
addr.type = ADDR_TYPE_IPV4; |
|
|
wireaddr_from_ipv4(&addr, &s4->sin_addr, ntohs(s4->sin_port)); |
|
|
addr.addrlen = sizeof(s4->sin_addr); |
|
|
|
|
|
BUILD_ASSERT(sizeof(s4->sin_addr) <= sizeof(addr.addr)); |
|
|
|
|
|
memcpy(addr.addr, &s4->sin_addr, addr.addrlen); |
|
|
|
|
|
addr.port = ntohs(s4->sin_port); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
status_broken("Unknown socket type %i for incoming conn", |
|
|
status_broken("Unknown socket type %i for incoming conn", |
|
|
s.ss_family); |
|
|
s.ss_family); |
|
@ -1568,13 +1560,7 @@ static void setup_listeners(struct daemon *daemon) |
|
|
|
|
|
|
|
|
switch (daemon->wireaddrs[i].type) { |
|
|
switch (daemon->wireaddrs[i].type) { |
|
|
case ADDR_TYPE_IPV4: |
|
|
case ADDR_TYPE_IPV4: |
|
|
addr.sin_family = AF_INET; |
|
|
wireaddr_to_ipv4(&daemon->wireaddrs[i], &addr); |
|
|
addr.sin_port = htons(daemon->wireaddrs[i].port); |
|
|
|
|
|
assert(daemon->wireaddrs[i].addrlen |
|
|
|
|
|
== sizeof(addr.sin_addr)); |
|
|
|
|
|
memcpy(&addr.sin_addr, |
|
|
|
|
|
daemon->wireaddrs[i].addr, |
|
|
|
|
|
sizeof(addr.sin_addr)); |
|
|
|
|
|
/* We might fail if IPv6 bound to port first */ |
|
|
/* We might fail if IPv6 bound to port first */ |
|
|
fd = make_listen_fd(AF_INET, &addr, sizeof(addr), |
|
|
fd = make_listen_fd(AF_INET, &addr, sizeof(addr), |
|
|
!had_ipv6_wildcard); |
|
|
!had_ipv6_wildcard); |
|
@ -1586,13 +1572,7 @@ static void setup_listeners(struct daemon *daemon) |
|
|
} |
|
|
} |
|
|
continue; |
|
|
continue; |
|
|
case ADDR_TYPE_IPV6: |
|
|
case ADDR_TYPE_IPV6: |
|
|
memset(&addr6, 0, sizeof(addr6)); |
|
|
wireaddr_to_ipv6(&daemon->wireaddrs[i], &addr6); |
|
|
addr6.sin6_family = AF_INET6; |
|
|
|
|
|
addr6.sin6_port = htons(daemon->wireaddrs[i].port); |
|
|
|
|
|
assert(daemon->wireaddrs[i].addrlen |
|
|
|
|
|
== sizeof(addr6.sin6_addr)); |
|
|
|
|
|
memcpy(&addr6.sin6_addr, daemon->wireaddrs[i].addr, |
|
|
|
|
|
sizeof(addr6.sin6_addr)); |
|
|
|
|
|
if (memeqzero(&addr6.sin6_addr, sizeof(addr6.sin6_addr))) |
|
|
if (memeqzero(&addr6.sin6_addr, sizeof(addr6.sin6_addr))) |
|
|
had_ipv6_wildcard = true; |
|
|
had_ipv6_wildcard = true; |
|
|
fd = make_listen_fd(AF_INET6, &addr6, sizeof(addr6), |
|
|
fd = make_listen_fd(AF_INET6, &addr6, sizeof(addr6), |
|
@ -1771,19 +1751,14 @@ static struct io_plan *conn_init(struct io_conn *conn, struct reaching *reach) |
|
|
|
|
|
|
|
|
switch (reach->addr.type) { |
|
|
switch (reach->addr.type) { |
|
|
case ADDR_TYPE_IPV4: |
|
|
case ADDR_TYPE_IPV4: |
|
|
ai.ai_family = AF_INET; |
|
|
wireaddr_to_ipv4(&reach->addr, &sin); |
|
|
sin.sin_family = AF_INET; |
|
|
ai.ai_family = sin.sin_family; |
|
|
sin.sin_port = htons(reach->addr.port); |
|
|
|
|
|
memcpy(&sin.sin_addr, reach->addr.addr, sizeof(sin.sin_addr)); |
|
|
|
|
|
ai.ai_addrlen = sizeof(sin); |
|
|
ai.ai_addrlen = sizeof(sin); |
|
|
ai.ai_addr = (struct sockaddr *)&sin; |
|
|
ai.ai_addr = (struct sockaddr *)&sin; |
|
|
break; |
|
|
break; |
|
|
case ADDR_TYPE_IPV6: |
|
|
case ADDR_TYPE_IPV6: |
|
|
ai.ai_family = AF_INET6; |
|
|
wireaddr_to_ipv6(&reach->addr, &sin6); |
|
|
memset(&sin6, 0, sizeof(sin6)); |
|
|
ai.ai_family = sin6.sin6_family; |
|
|
sin6.sin6_family = AF_INET6; |
|
|
|
|
|
sin6.sin6_port = htons(reach->addr.port); |
|
|
|
|
|
memcpy(&sin6.sin6_addr, reach->addr.addr, sizeof(sin6.sin6_addr)); |
|
|
|
|
|
ai.ai_addrlen = sizeof(sin6); |
|
|
ai.ai_addrlen = sizeof(sin6); |
|
|
ai.ai_addr = (struct sockaddr *)&sin6; |
|
|
ai.ai_addr = (struct sockaddr *)&sin6; |
|
|
break; |
|
|
break; |
|
|