< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] GenericIPAddress and ipv6


If you create a GenericIPAddress from a sockaddr that contains an ipv6
address, then the ipv6 address will not be fully copied. I've made a
patch for this:

*** GenericIPAddress.hxx.orig   Thu May  8 16:14:01 2014
--- GenericIPAddress.hxx        Thu May  8 16:14:52 2014
*************** struct GenericIPAddress
*** 26,33 ****
        {
        }
        
!       GenericIPAddress(const sockaddr& addr) : address(addr) 
        {
        }
  
        GenericIPAddress(const sockaddr_in& v4) : v4Address(v4)
--- 26,43 ----
        {
        }
        
!       GenericIPAddress(const sockaddr& addr)
        {
+ #ifdef IPPROTO_IPV6
+          if (addr.sa_family == AF_INET6)
+          {
+             v6Address = reinterpret_cast<const sockaddr_in6&>(addr);
+          }
+          else
+ #endif
+          {
+             v4Address = reinterpret_cast<const sockaddr_in&>(addr);
+          }
        }
  
        GenericIPAddress(const sockaddr_in& v4) : v4Address(v4)


Best Regards,
Björn