From 58d95b5164ca5f26fb8d16e85d6e91b191cbad2b Mon Sep 17 00:00:00 2001 From: Jeremy Visser Date: Thu, 14 Aug 2014 23:44:46 +0200 Subject: [PATCH] Allows connecting to IPv6 hosts if an AAAA record is present and /etc/gai.conf is not configured to prefer IPv4 hosts. The current logic handling the output of getaddrinfo() is flawed in that it only ever attempts to connect() to the first address returned. This is a problem for both round-robin and dual-stack hosts. Furthermore, rtl_tcp_source_c::rtl_tcp_source_c() assumes a colon in the device string is a port number. This prevents the use of raw IPv6 addresses. The function will need to be taught how to handle IPv6 addresses contained within square brackets, e.g. "rtl_tcp=[2001:db8::1]:1234". Therefore further work is required to improve the handling of multiple addresses, and also device strings containing raw IPv6 addresses. Signed-off-by: Jeremy Visser --- lib/rtl_tcp/rtl_tcp_source_f.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rtl_tcp/rtl_tcp_source_f.cc b/lib/rtl_tcp/rtl_tcp_source_f.cc index 389c4f4..a17594c 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.cc +++ b/lib/rtl_tcp/rtl_tcp_source_f.cc @@ -113,7 +113,7 @@ rtl_tcp_source_f::rtl_tcp_source_f(size_t itemsize, struct addrinfo *ip_src; // store the source IP address to use struct addrinfo hints; memset( (void*)&hints, 0, sizeof(hints) ); - hints.ai_family = AF_INET; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_PASSIVE;