[reSIProcate] IPv6 support bug (win32)

Livio Torrero ltownmail at hotmail.it
Mon Mar 21 15:17:35 CST 2005


I found a bug in TransportSelector.cxx that makes the code fail when it is 
compiled under Windows enabling the IPv6 support. On line 491 of 
TransportSelector.cxx      the "WinCompat::determineSourceInterface" is 
invoked. This function calls the "GetBestRoute" which only returns IPv4 
addresses. It is possible to fix the bug by simply replacing the 
"WinCompat::determineSourceInterface" invocation with this code:


#ifdef USE_IPV6
	Data localAddress = SipStack::getHostAddress();				Tuple 
tempTuple(localAddress, target.getPort(), target.getType());			source = 
tempTuple;
#else
               // will not work on ipv6
               source = WinCompat::determineSourceInterface(target);
#endif

To make everything work I've also rewritten the SipStack::getHostAddress() 
method:

Data
SipStack::getHostAddress()
{
      char hostName[1024], addrA[1024];
      int err =  gethostname( hostName, sizeof(hostName) );
      struct addrinfo hints, *results;
      memset(&hints, 0 , sizeof(struct addrinfo));
#ifdef USE_IPV6
      hints.ai_family = AF_INET6;
#else
      hints.ai_family = AF_INET;
#endif
      getaddrinfo(hostName, NULL, &hints, &results);
      getnameinfo(results->ai_addr, results->ai_addrlen, addrA, 
sizeof(addrA), NULL, NI_MAXSERV, NI_NUMERICHOST);
      freeaddrinfo(results);
      Data ret(addrA);
      return ret;
}

I've also noticed that you often use inet_ntop and inet_pton instead of 
getaddrinfo and getnameinfo. Is there any particular reason for such a 
choice? (I've replaced inet_ntop with  getnameinfo everywhere I found it in 
the Resiprocate code).


Livio Torrero

_________________________________________________________________
Ricerche online più semplici e veloci con MSN Toolbar! 
http://toolbar.msn.it/




More information about the resiprocate-devel mailing list