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

RE: [reSIProcate] WinCompat::determineSourceInterfaceWithoutIPv6(constGenericIPAddress& destination)


The Windows determine source interface stuff is already painfully slow
(especially the IPV6 call).   I don't think we should be adding a query
to GetIpAddeTable with every call to determineSourceInterface.

A better solution for most of this stuff will be to cache what we can.
Ie.  Cache results fo GetIpAddrTable in WinCompat and just check it with
each call to determineSourceInterface.

Scott

> -----Original Message-----
> From: resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx
[mailto:resiprocate-
> devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Dmytro Bogovych
> Sent: Monday, October 31, 2005 11:41 AM
> To: resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> Subject: [reSIProcate]
> WinCompat::determineSourceInterfaceWithoutIPv6(constGenericIPAddress&
> destination)
> 
> Greetings.
> 
> I tried to run simple user agent on the local interface 192.168.0.1
(MS
> Loopback adapter)
> I have running asteriskwin32 on the same interface but another port.
> User agent uses one UDP transport bound to 192.168.0.1 interface.
> 
> When resip uses determineSourceInterfaceWithoutIPv6 - IPhlp's
GetBestRoute
> returns index of 127.0.0.1 interface. But there is no transport bound
to
> this IP.
> 
> I did small workaround - check if destination interface is local
before
> calling GetBestRoute. May this code be included to resiprocate?
> 
> bool WinCompat::IsLocalIf(const GenericIPAddress& addr)
> {
>    PMIB_IPADDRTABLE  pIpAddrTable = NULL;
>    ULONG addrSize = 0;
> 
>    if (ERROR_INSUFFICIENT_BUFFER == GetIpAddrTable(NULL, &addrSize,
> FALSE))
>      pIpAddrTable = (PMIB_IPADDRTABLE) new char [addrSize];
>    else
>      throw Exception("Can't load interface table", __FILE__,__LINE__);
> 
>    if (NO_ERROR == GetIpAddrTable(pIpAddrTable, &addrSize, FALSE))
>    {
>      // try to find a match
>      DWORD i = 0;
>      while (i<pIpAddrTable->dwNumEntries &&
>        pIpAddrTable->table[i].dwAddr !=
> addr.v4Address.sin_addr.S_un.S_addr)
>        i++;
>      bool res = i < pIpAddrTable->dwNumEntries;
> 
>      delete [] (char *) pIpAddrTable;
>      return res;
>    }
>    return false;
> 
> }
> 
> GenericIPAddress
> WinCompat::determineSourceInterfaceWithoutIPv6(const GenericIPAddress&
> destination)
> {
>     // check if destination is local address?
>     if (IsLocalIf(destination))
>       return destination;
> 
>     [skipped]
> }
> 
> 
> 
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel