exclude NetworkInterface where not supported

Exclude NetworkInterface and MulticastSocket on platforms where we do
not have network interface detection implemented
This commit is contained in:
aleks-f 2012-12-23 16:05:16 -06:00
parent ba70e7f734
commit 007659a107
13 changed files with 96 additions and 8 deletions

View File

@ -102,6 +102,12 @@
#elif defined(__QNX__)
#define POCO_OS_FAMILY_UNIX 1
#define POCO_OS POCO_OS_QNX
#elif defined(__CYGWIN__)
#define POCO_OS_FAMILY_UNIX 1
#define POCO_OS POCO_OS_CYGWIN
#elif defined(POCO_VXWORKS)
#define POCO_OS_FAMILY_UNIX 1
#define POCO_OS POCO_OS_VXWORKS
#elif defined(unix) || defined(__unix) || defined(__unix__)
#define POCO_OS_FAMILY_UNIX 1
#define POCO_OS POCO_OS_UNKNOWN_UNIX
@ -111,15 +117,9 @@
#elif defined(_WIN32) || defined(_WIN64)
#define POCO_OS_FAMILY_WINDOWS 1
#define POCO_OS POCO_OS_WINDOWS_NT
#elif defined(__CYGWIN__)
#define POCO_OS_FAMILY_UNIX 1
#define POCO_OS POCO_OS_CYGWIN
#elif defined(__VMS)
#define POCO_OS_FAMILY_VMS 1
#define POCO_OS POCO_OS_VMS
#elif defined(POCO_VXWORKS)
#define POCO_OS_FAMILY_UNIX 1
#define POCO_OS POCO_OS_VXWORKS
#endif

View File

@ -41,6 +41,11 @@
#include "Poco/Net/Net.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "Poco/Net/DatagramSocket.h"
#include "Poco/Net/NetworkInterface.h"
@ -135,4 +140,7 @@ public:
} } // namespace Poco::Net
#endif // POCO_NET_HAS_INTERFACE
#endif // Net_MulticastSocket_INCLUDED

View File

@ -134,4 +134,12 @@ inline void Net_API uninitializeNetwork();
#endif // POCO_NET_NO_WINDOWS_INIT
//
// Define POCO_NET_HAS_INTERFACE for platforms that have network interface detection implemented.
//
#if defined(POCO_OS_FAMILY_WINDOWS) || (POCO_OS == POCO_OS_LINUX) || defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_QNX)
#define POCO_NET_HAS_INTERFACE
#endif
#endif // Net_Net_INCLUDED

View File

@ -41,6 +41,11 @@
#include "Poco/Net/Net.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "Poco/Net/IPAddress.h"
#include "Poco/Mutex.h"
#include "Poco/Tuple.h"
@ -330,4 +335,7 @@ inline bool NetworkInterface::operator == (const NetworkInterface& other) const
Net_API std::ostream& operator<<(std::ostream& os, const Poco::Net::NetworkInterface::MACAddress& mac);
#endif // POCO_NET_HAS_INTERFACE
#endif // Net_NetworkInterface_INCLUDED

View File

@ -35,6 +35,11 @@
#include "Poco/Net/MulticastSocket.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "Poco/Net/NetException.h"
#include <cstring>
@ -263,3 +268,6 @@ void MulticastSocket::leaveGroup(const IPAddress& groupAddress, const NetworkInt
} } // namespace Poco::Net
#endif // POCO_NET_HAS_INTERFACE

View File

@ -35,6 +35,11 @@
#include "Poco/Net/NetworkInterface.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "Poco/Net/DatagramSocket.h"
#include "Poco/Net/NetException.h"
#include "Poco/NumberFormatter.h"
@ -949,7 +954,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
pAddress = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(memory.begin()); // leave in the loop, begin may change after resize
poco_assert (memory.capacity() >= outBufLen);
if (ERROR_BUFFER_OVERFLOW == (dwRetVal = GetAdaptersAddresses(family, flags, 0, pAddress, &outBufLen)))
memory.resize(outBufLen); // adjust size and try again
memory.resize(outBufLen, false); // adjust size and try again
else if (ERROR_NO_DATA == dwRetVal) // no network interfaces found
return result;
else if (NO_ERROR != dwRetVal) // error occurred
@ -1540,3 +1545,6 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
#endif
#endif // POCO_NET_HAS_INTERFACE

View File

@ -31,6 +31,11 @@
#include "MulticastEchoServer.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "Poco/Timespan.h"
#include <iostream>
@ -120,3 +125,5 @@ Poco::Net::NetworkInterface MulticastEchoServer::findInterface()
}
return NetworkInterface();
}
#endif // POCO_NET_HAS_INTERFACE

View File

@ -37,6 +37,11 @@
#include "Poco/Net/Net.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "Poco/Net/MulticastSocket.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Net/NetworkInterface.h"
@ -82,4 +87,7 @@ private:
};
#endif // POCO_NET_HAS_INTERFACE
#endif // MulticastEchoServer_INCLUDED

View File

@ -31,6 +31,11 @@
#include "MulticastSocketTest.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "MulticastEchoServer.h"
@ -94,3 +99,6 @@ CppUnit::Test* MulticastSocketTest::suite()
return pSuite;
}
#endif // POCO_NET_HAS_INTERFACE

View File

@ -37,6 +37,11 @@
#include "Poco/Net/Net.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "CppUnit/TestCase.h"
@ -57,4 +62,7 @@ private:
};
#endif // POCO_NET_HAS_INTERFACE
#endif // MulticastSocketTest_INCLUDED

View File

@ -44,7 +44,8 @@ CppUnit::Test* NetCoreTestSuite::suite()
pSuite->addTest(IPAddressTest::suite());
pSuite->addTest(SocketAddressTest::suite());
pSuite->addTest(DNSTest::suite());
#ifdef POCO_NET_HAS_INTERFACE
pSuite->addTest(NetworkInterfaceTest::suite());
#endif // POCO_NET_HAS_INTERFACE
return pSuite;
}

View File

@ -31,6 +31,11 @@
#include "NetworkInterfaceTest.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/Net/NetworkInterface.h"
@ -231,3 +236,6 @@ CppUnit::Test* NetworkInterfaceTest::suite()
return pSuite;
}
#endif // POCO_NET_HAS_INTERFACE

View File

@ -37,6 +37,11 @@
#include "Poco/Net/Net.h"
#ifdef POCO_NET_HAS_INTERFACE
#include "CppUnit/TestCase.h"
@ -63,4 +68,7 @@ private:
};
#endif // POCO_NET_HAS_INTERFACE
#endif // NetworkInterfaceTest_INCLUDED