Commit 73cc93df authored by venaas's avatar venaas Committed by venaas
Browse files

fixing bugs in new addserver binding code

git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@190 e88ac4ed-0b26-0410-9574-a7f39faa03bf
parent 4f87524a
......@@ -373,27 +373,31 @@ void addserver(struct clsrvconf *conf) {
if (udp_client4_sock < 0) {
struct sockaddr_in sa;
memset(&sa, 0, sizeof(sa));
udp_client4_sock = socket(AF_INET, conf->addrinfo->ai_socktype, conf->addrinfo->ai_protocol);
sa.sin_family = AF_INET;
udp_client4_sock = socket(PF_INET, conf->addrinfo->ai_socktype, conf->addrinfo->ai_protocol);
if (udp_client4_sock < 0)
debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->host);
if (!bind(udp_client4_sock, (struct sockaddr *)&sa, sizeof(sa)))
if (bind(udp_client4_sock, (struct sockaddr *)&sa, sizeof(sa)))
debugx(1, DBG_ERR, "addserver: failed to bind client socket for server %s", conf->host);
}
conf->servers->sock = udp_client4_sock;
break;
case AF_INET6:
if (udp_client6_sock < 0) {
struct sockaddr_in6 sa;
memset(&sa, 0, sizeof(sa));
udp_client6_sock = socket(AF_INET6, conf->addrinfo->ai_socktype, conf->addrinfo->ai_protocol);
sa.sin6_family = AF_INET6;
udp_client6_sock = socket(PF_INET6, conf->addrinfo->ai_socktype, conf->addrinfo->ai_protocol);
if (udp_client6_sock < 0)
debugx(1, DBG_ERR, "addserver: failed to create client socket for server %s", conf->host);
#ifdef IPV6_V6ONLY
setsockopt(udp_client6_sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on, sizeof(on));
#endif
if (!bind(udp_client6_sock, (struct sockaddr *)&sa, sizeof(sa)))
if (bind(udp_client6_sock, (struct sockaddr *)&sa, sizeof(sa)))
debugx(1, DBG_ERR, "addserver: failed to bind client socket for server %s", conf->host);
}
conf->servers->sock = udp_client6_sock;
break;
default:
debugx(1, DBG_ERR, "addserver: unsupported address family");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment