Allow parallel listen to IPv4 and v6 addresses (#6816)

* Allow parallel listen to IPv4 and v6 addresses

* Reformatted last changes

Co-authored-by: Marcel <marcel+it+gitkraken@linux-ng.de>
Co-authored-by: akallabeth <akallabeth@posteo.net>
This commit is contained in:
Marcel Ritter 2021-02-15 11:19:58 +01:00 committed by GitHub
parent 8852d8631f
commit a60413a1a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,13 +90,19 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a
continue;
}
option_value = 1;
if (ai->ai_family == AF_INET)
sin_addr = &(((struct sockaddr_in*)ai->ai_addr)->sin_addr);
else
{
sin_addr = &(((struct sockaddr_in6*)ai->ai_addr)->sin6_addr);
if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&option_value,
sizeof(option_value)) == -1)
WLog_ERR(TAG, "setsockopt");
}
inet_ntop(ai->ai_family, sin_addr, addr, sizeof(addr));
option_value = 1;
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&option_value,
sizeof(option_value)) == -1)