From 71bbd1b31530e4ef84e3562425d78450da289d8c Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 26 Sep 2020 18:54:32 -0400 Subject: [PATCH] server.c: re-locate definitions to appropriate scope --- src/server.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server.c b/src/server.c index 7639fdd..a896e6a 100644 --- a/src/server.c +++ b/src/server.c @@ -46,22 +46,22 @@ server_init(struct gmnisrv_server *server, struct gmnisrv_config *conf) static const int t = 1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &t, sizeof(t)); + struct sockaddr_in in = {0}; + struct sockaddr_in6 in6 = {0}; struct sockaddr *addr; size_t addrsz; if (b->family == AF_INET) { - struct sockaddr_in in = {0}; in.sin_family = AF_INET; in.sin_port = htons(b->port); memcpy(&in.sin_addr, b->addr, sizeof(struct in_addr)); addr = (struct sockaddr *)∈ addrsz = sizeof(in); } else if (b->family == AF_INET6) { - struct sockaddr_in6 in = {0}; - in.sin6_family = AF_INET6; - in.sin6_port = htons(b->port); - memcpy(&in.sin6_addr, b->addr, sizeof(struct in6_addr)); - addr = (struct sockaddr *)∈ - addrsz = sizeof(in); + in6.sin6_family = AF_INET6; + in6.sin6_port = htons(b->port); + memcpy(&in6.sin6_addr, b->addr, sizeof(struct in6_addr)); + addr = (struct sockaddr *)&in6; + addrsz = sizeof(in6); #ifdef IPV6_V6ONLY setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &t, sizeof(t));