OS/2 (eCS) support

This commit is contained in:
Arvid Norberg
2012-09-24 16:13:57 +00:00
parent 852502ef2c
commit b8149ead5c
7 changed files with 58 additions and 11 deletions

View File

@@ -88,6 +88,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <ifaddrs.h>
#endif
#if defined(TORRENT_OS2) and !defined(IF_NAMESIZE)
#define IF_NAMESIZE IFNAMSIZ
#endif
namespace libtorrent { namespace
{
@@ -222,6 +226,9 @@ namespace libtorrent { namespace
#endif
#if TORRENT_USE_SYSCTL
#ifdef TORRENT_OS2
int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
#endif
bool parse_route(int s, rt_msghdr* rtm, ip_route* rt_info)
{
@@ -493,7 +500,11 @@ namespace libtorrent
close(s);
return ret;
}
#ifndef TORRENT_OS2
iface.mtu = req.ifr_mtu;
#else
iface.mtu = req.ifr_metric; // according to tcp/ip reference
#endif
memset(&req, 0, sizeof(req));
strncpy(req.ifr_name, item.ifr_name, IF_NAMESIZE - 1);
@@ -762,7 +773,11 @@ namespace libtorrent
int mib[6] = { CTL_NET, PF_ROUTE, 0, AF_UNSPEC, NET_RT_DUMP, 0};
size_t needed = 0;
#ifdef TORRENT_OS2
if (__libsocket_sysctl(mib, 6, 0, &needed, 0, 0) < 0)
#else
if (sysctl(mib, 6, 0, &needed, 0, 0) < 0)
#endif
{
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();
@@ -780,7 +795,11 @@ namespace libtorrent
return std::vector<ip_route>();
}
#ifdef TORRENT_OS2
if (__libsocket_sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
#else
if (sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
#endif
{
ec = error_code(errno, asio::error::system_category);
return std::vector<ip_route>();