mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 08:31:43 +02:00
fixes for linux compile/tests
This commit is contained in:
@@ -1308,7 +1308,7 @@ static NetworkInterface::Type fromNative(unsigned arphrd)
|
|||||||
|
|
||||||
void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
|
void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
|
||||||
{
|
{
|
||||||
struct sockaddr_dl* sdl = (struct sockaddr_dl*) iface->ifa_addr;
|
struct sockaddr_ll* sdl = (struct sockaddr_ll*) iface->ifa_addr;
|
||||||
impl.setName(iface->ifa_name);
|
impl.setName(iface->ifa_name);
|
||||||
impl.setDisplayName(iface->ifa_name);
|
impl.setDisplayName(iface->ifa_name);
|
||||||
impl.setPhyParams();
|
impl.setPhyParams();
|
||||||
@@ -1358,7 +1358,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
|||||||
}
|
}
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
ifIndex = if_nametoindex(iface->ifa_name);
|
ifIndex = if_nametoindex(iface->ifa_name);
|
||||||
|
ifIt = result.find(ifIndex);
|
||||||
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
||||||
{
|
{
|
||||||
intf = NetworkInterface(ifIndex);
|
intf = NetworkInterface(ifIndex);
|
||||||
@@ -1380,11 +1380,12 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
|||||||
#if defined(POCO_HAVE_IPv6)
|
#if defined(POCO_HAVE_IPv6)
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
ifIndex = if_nametoindex(iface->ifa_name);
|
ifIndex = if_nametoindex(iface->ifa_name);
|
||||||
|
ifIt = result.find(ifIndex);
|
||||||
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
if ((ifIt == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
|
||||||
{
|
{
|
||||||
intf = NetworkInterface(ifIndex);
|
intf = NetworkInterface(ifIndex);
|
||||||
setInterfaceParams(iface, intf.impl());
|
setInterfaceParams(iface, intf.impl());
|
||||||
ifIt = result.insert(Map::value_type(ifIndex, intf)).first;
|
result.insert(Map::value_type(ifIndex, intf)).first;
|
||||||
}
|
}
|
||||||
address = IPAddress(&reinterpret_cast<const struct sockaddr_in6*>(iface->ifa_addr)->sin6_addr, sizeof(struct in6_addr), ifIndex);
|
address = IPAddress(&reinterpret_cast<const struct sockaddr_in6*>(iface->ifa_addr)->sin6_addr, sizeof(struct in6_addr), ifIndex);
|
||||||
subnetMask = IPAddress(*(iface->ifa_netmask));
|
subnetMask = IPAddress(*(iface->ifa_netmask));
|
||||||
@@ -1394,6 +1395,20 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
|
|||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (family == AF_INET
|
||||||
|
#ifdef POCO_HAVE_IPv6
|
||||||
|
|| family == AF_INET6
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
intf = NetworkInterface(std::string(iface->ifa_name), address, subnetMask, broadcastAddress, ifIndex);
|
||||||
|
if ((upOnly && intf.isUp()) || !upOnly)
|
||||||
|
{
|
||||||
|
if ((ifIt = result.find(ifIndex)) != result.end())
|
||||||
|
ifIt->second.addAddress(address, subnetMask, broadcastAddress);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // for interface
|
} // for interface
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
@@ -94,7 +94,7 @@ void NetworkInterfaceTest::testMap()
|
|||||||
|
|
||||||
void NetworkInterfaceTest::testList()
|
void NetworkInterfaceTest::testList()
|
||||||
{
|
{
|
||||||
NetworkInterface::List list = NetworkInterface::list();
|
NetworkInterface::List list = NetworkInterface::list(false, false);
|
||||||
assert (!list.empty());
|
assert (!list.empty());
|
||||||
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user