mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Removed unused getLocalInterfaces_ipv4
This commit is contained in:
parent
77bcc99030
commit
5a541e7feb
4 changed files with 0 additions and 238 deletions
|
@ -256,80 +256,6 @@ std::string socket_errorType(int err)
|
|||
return std::string("----WINDOWS OPERATING SYSTEM FAILURE----");
|
||||
}
|
||||
|
||||
#include <iphlpapi.h>
|
||||
//#include <iprtrmib.h>
|
||||
|
||||
// A function to determine the interfaces on your computer....
|
||||
// No idea of how to do this in windows....
|
||||
// see if it compiles.
|
||||
bool getLocalInterfaces_ipv4(struct in_addr &routeAddr, std::list<struct in_addr> &addrs)
|
||||
{
|
||||
// Get the best interface for transport to routeAddr
|
||||
// This interface should be first in list!
|
||||
DWORD bestInterface;
|
||||
if (GetBestInterface((IPAddr) routeAddr.s_addr, &bestInterface) != NO_ERROR)
|
||||
{
|
||||
bestInterface = 0;
|
||||
}
|
||||
|
||||
/* USE MIB IPADDR Interface */
|
||||
PMIB_IPADDRTABLE iptable = NULL;
|
||||
DWORD dwSize = 0;
|
||||
|
||||
if (GetIpAddrTable(iptable, &dwSize, 0) != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
pqioutput(PQL_ALERT, pqinetzone, "Cannot Find Windoze Interfaces!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
iptable = (MIB_IPADDRTABLE *) malloc(dwSize);
|
||||
GetIpAddrTable(iptable, &dwSize, 0);
|
||||
|
||||
struct in_addr addr;
|
||||
|
||||
for (unsigned int i = 0; i < iptable -> dwNumEntries; i++)
|
||||
{
|
||||
MIB_IPADDRROW &ipaddr = iptable->table[i];
|
||||
|
||||
std::string out;
|
||||
|
||||
addr.s_addr = ipaddr.dwAddr;
|
||||
rs_sprintf(out, "Iface(%ld) => %s\n", ipaddr.dwIndex, rs_inet_ntoa(addr).c_str());
|
||||
|
||||
#if __MINGW_MAJOR_VERSION <= 3 && !defined(__MINGW64_VERSION_MAJOR)
|
||||
unsigned short wType = ipaddr.unused2; // should be wType
|
||||
#else
|
||||
unsigned short wType = ipaddr.wType;
|
||||
#endif
|
||||
if (wType & MIB_IPADDR_DISCONNECTED)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqinetzone, "Interface disconnected, " + out);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wType & MIB_IPADDR_DELETED)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqinetzone, "Interface deleted, " + out);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ipaddr.dwIndex == bestInterface)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqinetzone, "Best address, " + out);
|
||||
addrs.push_front(addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqinetzone, out);
|
||||
addrs.push_back(addr);
|
||||
}
|
||||
}
|
||||
|
||||
free (iptable);
|
||||
|
||||
return (addrs.size() > 0);
|
||||
}
|
||||
|
||||
// implement the improved unix inet address fn.
|
||||
// using old one.
|
||||
int inet_aton(const char *name, struct in_addr *addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue