OSX compile fix

This commit is contained in:
Aleksandar Fabijanic
2012-08-17 03:23:47 +00:00
parent 08a788a41c
commit 84ca64e283

View File

@@ -784,13 +784,12 @@ NetworkInterface NetworkInterface::forAddress(const IPAddress& addr)
throw InterfaceNotFoundException(addr.toString()); throw InterfaceNotFoundException(addr.toString());
} }
NetworkInterface NetworkInterface::forIndex(unsigned i) NetworkInterface NetworkInterface::forIndex(unsigned i)
{ {
if (i != NetworkInterface::NO_INDEX) if (i != NetworkInterface::NO_INDEX)
{ {
Map map = NetworkInterface::map(); Map map = NetworkInterface::map();
Map::const_iterator it = map.find(i); Map::const_iterator it = map.find(i);
if (it != map.end()) if (it != map.end())
return it->second; return it->second;
@@ -1100,7 +1099,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
#elif defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_SOLARIS) #elif defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_QNX) || (POCO_OS == POCO_OS_SOLARIS)
// //
// BSD variants, QNX and Solaris // BSD variants, QNX(?) and Solaris
// //
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
@@ -1108,7 +1107,7 @@ NetworkInterface::NetworkInterfaceList NetworkInterface::list()
#include <net/if.h> #include <net/if.h>
#include <net/if_dl.h> #include <net/if_dl.h>
#include <net/if_types.h> #include <net/if_types.h>
#include <iostream>
namespace Poco { namespace Poco {
namespace Net { namespace Net {
@@ -1144,7 +1143,7 @@ void setInterfaceParams(struct ifaddrs* iface, NetworkInterfaceImpl& impl)
impl.setType(fromNative(sdl->sdl_type)); impl.setType(fromNative(sdl->sdl_type));
} }
} } // namespace
NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly) NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
@@ -1173,6 +1172,8 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
{ {
#if defined(POCO_OS_FAMILY_BSD) #if defined(POCO_OS_FAMILY_BSD)
case AF_LINK: case AF_LINK:
{
struct sockaddr_dl* sdl = (struct sockaddr_dl*) currIface->ifa_addr;
ifIndex = sdl->sdl_index; ifIndex = sdl->sdl_index;
if ((result.find(ifIndex) == result.end()) && ((upOnly && intf.isUp()) || !upOnly)) if ((result.find(ifIndex) == result.end()) && ((upOnly && intf.isUp()) || !upOnly))
{ {
@@ -1181,6 +1182,7 @@ NetworkInterface::Map NetworkInterface::map(bool ipOnly, bool upOnly)
ifIt = result.insert(Map::value_type(ifIndex, intf)).first; ifIt = result.insert(Map::value_type(ifIndex, intf)).first;
} }
break; break;
}
#endif #endif
case AF_INET: case AF_INET:
ifIndex = if_nametoindex(currIface->ifa_name); ifIndex = if_nametoindex(currIface->ifa_name);