mirror of
https://github.com/pocoproject/poco.git
synced 2025-06-01 08:31:27 +02:00
Poco::Net::NetworkInterface::list does not list inactive interfaces even when explicitly being asked for it #2044
This commit is contained in:
parent
56a483bcf9
commit
2b125e1c4e
@ -875,14 +875,16 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
|
|||||||
|
|
||||||
typedef NetworkInterface::AddressList List;
|
typedef NetworkInterface::AddressList List;
|
||||||
const List& ipList = it->second.addressList();
|
const List& ipList = it->second.addressList();
|
||||||
|
if (ipList.size() > 0)
|
||||||
|
{
|
||||||
List::const_iterator ipIt = ipList.begin();
|
List::const_iterator ipIt = ipList.begin();
|
||||||
List::const_iterator ipEnd = ipList.end();
|
List::const_iterator ipEnd = ipList.end();
|
||||||
for (; ipIt != ipEnd; ++ipIt)
|
for(; ipIt != ipEnd; ++ipIt)
|
||||||
{
|
{
|
||||||
IPAddress addr = ipIt->get<NetworkInterface::IP_ADDRESS>();
|
IPAddress addr = ipIt->get<NetworkInterface::IP_ADDRESS>();
|
||||||
IPAddress mask = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
IPAddress mask = ipIt->get<NetworkInterface::SUBNET_MASK>();
|
||||||
NetworkInterface ni;
|
NetworkInterface ni;
|
||||||
if (mask.isWildcard())
|
if(mask.isWildcard())
|
||||||
{
|
{
|
||||||
ni = NetworkInterface(name, displayName, adapterName, addr, index, &mac);
|
ni = NetworkInterface(name, displayName, adapterName, addr, index, &mac);
|
||||||
}
|
}
|
||||||
@ -904,6 +906,11 @@ NetworkInterface::List NetworkInterface::list(bool ipOnly, bool upOnly)
|
|||||||
list.push_back(ni);
|
list.push_back(ni);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.push_back(NetworkInterface(name, displayName, adapterName, index, &mac));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ void NetworkInterfaceTest::testList()
|
|||||||
{
|
{
|
||||||
NetworkInterface::List list = NetworkInterface::list(false, false);
|
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::List::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << std::endl << "==============" << std::endl;
|
std::cout << std::endl << "==============" << std::endl;
|
||||||
|
|
||||||
@ -92,10 +92,10 @@ void NetworkInterfaceTest::testList()
|
|||||||
if (!mac.empty() && (it->type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
if (!mac.empty() && (it->type() != NetworkInterface::NI_TYPE_SOFTWARE_LOOPBACK))
|
||||||
std::cout << "MAC Address: (" << it->type() << ") " << mac << std::endl;
|
std::cout << "MAC Address: (" << it->type() << ") " << mac << std::endl;
|
||||||
|
|
||||||
typedef NetworkInterface::AddressList List;
|
typedef NetworkInterface::AddressList AddrList;
|
||||||
const List& ipList = it->addressList();
|
const AddrList& ipList = it->addressList();
|
||||||
List::const_iterator ipIt = ipList.begin();
|
AddrList::const_iterator ipIt = ipList.begin();
|
||||||
List::const_iterator ipEnd = ipList.end();
|
AddrList::const_iterator ipEnd = ipList.end();
|
||||||
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
for (int counter = 0; ipIt != ipEnd; ++ipIt, ++counter)
|
||||||
{
|
{
|
||||||
std::cout << "IP Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
|
std::cout << "IP Address: " << ipIt->get<NetworkInterface::IP_ADDRESS>() << std::endl;
|
||||||
@ -213,13 +213,20 @@ void NetworkInterfaceTest::testListMapConformance()
|
|||||||
|
|
||||||
typedef NetworkInterface::AddressList List;
|
typedef NetworkInterface::AddressList List;
|
||||||
const List& ipList = mapIt->second.addressList();
|
const List& ipList = mapIt->second.addressList();
|
||||||
|
if (ipList.size() > 0)
|
||||||
|
{
|
||||||
List::const_iterator ipIt = ipList.begin();
|
List::const_iterator ipIt = ipList.begin();
|
||||||
List::const_iterator ipEnd = ipList.end();
|
List::const_iterator ipEnd = ipList.end();
|
||||||
for (; ipIt != ipEnd; ++ipIt, ++counter, ++listIt)
|
for(; ipIt != ipEnd; ++ipIt, ++counter, ++listIt)
|
||||||
{
|
{
|
||||||
NetworkInterface::MACAddress lmac = listIt->macAddress();
|
NetworkInterface::MACAddress lmac = listIt->macAddress();
|
||||||
assert (lmac == mac);
|
assert (lmac == mac);
|
||||||
if (listIt == l.end()) fail ("wrong number of list items");
|
if(listIt == l.end()) fail("wrong number of list items");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user