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

[reSIProcate] WinCompat::determineSourceInterfaceWithoutIPv6(const GenericIPAddress& 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/