1
0
forked from aniani/gmnisrv

server.c: re-locate definitions to appropriate scope

This commit is contained in:
Drew DeVault 2020-09-26 18:54:32 -04:00
parent f3075e4bbd
commit 71bbd1b315

View File

@ -46,22 +46,22 @@ server_init(struct gmnisrv_server *server, struct gmnisrv_config *conf)
static const int t = 1; static const int t = 1;
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(t)); setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(t));
struct sockaddr_in in = {0};
struct sockaddr_in6 in6 = {0};
struct sockaddr *addr; struct sockaddr *addr;
size_t addrsz; size_t addrsz;
if (b->family == AF_INET) { if (b->family == AF_INET) {
struct sockaddr_in in = {0};
in.sin_family = AF_INET; in.sin_family = AF_INET;
in.sin_port = htons(b->port); in.sin_port = htons(b->port);
memcpy(&in.sin_addr, b->addr, sizeof(struct in_addr)); memcpy(&in.sin_addr, b->addr, sizeof(struct in_addr));
addr = (struct sockaddr *)∈ addr = (struct sockaddr *)∈
addrsz = sizeof(in); addrsz = sizeof(in);
} else if (b->family == AF_INET6) { } else if (b->family == AF_INET6) {
struct sockaddr_in6 in = {0}; in6.sin6_family = AF_INET6;
in.sin6_family = AF_INET6; in6.sin6_port = htons(b->port);
in.sin6_port = htons(b->port); memcpy(&in6.sin6_addr, b->addr, sizeof(struct in6_addr));
memcpy(&in.sin6_addr, b->addr, sizeof(struct in6_addr)); addr = (struct sockaddr *)&in6;
addr = (struct sockaddr *)∈ addrsz = sizeof(in6);
addrsz = sizeof(in);
#ifdef IPV6_V6ONLY #ifdef IPV6_V6ONLY
setsockopt(sockfd, IPPROTO_IPV6, setsockopt(sockfd, IPPROTO_IPV6,
IPV6_V6ONLY, &t, sizeof(t)); IPV6_V6ONLY, &t, sizeof(t));