forked from premiere/premiere-libtorrent
factored out OS detection code and added kfreebsd support
This commit is contained in:
parent
0c51e822f5
commit
799dd70c4e
|
@ -67,5 +67,21 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_DEPRECATED
|
#define TORRENT_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// set up defines for target environments
|
||||||
|
#if (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \
|
||||||
|
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__ \
|
||||||
|
|| defined __FreeBSD_kernel__
|
||||||
|
#define TORRENT_BSD
|
||||||
|
#elif defined __linux__
|
||||||
|
#define TORRENT_LINUX
|
||||||
|
#elif defined WIN32
|
||||||
|
#define TORRENT_WINDOWS
|
||||||
|
#else
|
||||||
|
#warning unkown OS, assuming BSD
|
||||||
|
#define TORRENT_BSD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // TORRENT_CONFIG_HPP_INCLUDED
|
#endif // TORRENT_CONFIG_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined __linux__ || (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \
|
#include "libtorrent/config.hpp"
|
||||||
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__
|
|
||||||
|
#if defined TORRENT_BSD || defined TORRENT_LINUX
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
#elif defined WIN32
|
#elif defined TORRENT_WINDOWS
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,9 +72,7 @@ namespace libtorrent
|
||||||
return address();
|
return address();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \
|
#ifdef TORRENT_BSD
|
||||||
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__
|
|
||||||
|
|
||||||
bool verify_sockaddr(sockaddr_in* sin)
|
bool verify_sockaddr(sockaddr_in* sin)
|
||||||
{
|
{
|
||||||
return (sin->sin_len == sizeof(sockaddr_in)
|
return (sin->sin_len == sizeof(sockaddr_in)
|
||||||
|
@ -114,8 +113,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
std::vector<ip_interface> ret;
|
std::vector<ip_interface> ret;
|
||||||
// covers linux, MacOS X and BSD distributions
|
// covers linux, MacOS X and BSD distributions
|
||||||
#if defined __linux__ || (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \
|
#if defined TORRENT_LINUX || defined TORRENT_BSD
|
||||||
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__
|
|
||||||
int s = socket(AF_INET, SOCK_DGRAM, 0);
|
int s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
{
|
{
|
||||||
|
@ -168,10 +166,9 @@ namespace libtorrent
|
||||||
ret.push_back(iface);
|
ret.push_back(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \
|
#if defined TORRENT_BSD
|
||||||
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__
|
|
||||||
int current_size = item.ifr_addr.sa_len + IFNAMSIZ;
|
int current_size = item.ifr_addr.sa_len + IFNAMSIZ;
|
||||||
#elif defined __linux__
|
#elif defined TORRENT_LINUX
|
||||||
int current_size = sizeof(ifreq);
|
int current_size = sizeof(ifreq);
|
||||||
#endif
|
#endif
|
||||||
ifr += current_size;
|
ifr += current_size;
|
||||||
|
@ -179,7 +176,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
close(s);
|
close(s);
|
||||||
|
|
||||||
#elif defined WIN32
|
#elif defined TORRENT_WINDOWS
|
||||||
|
|
||||||
SOCKET s = socket(AF_INET, SOCK_DGRAM, 0);
|
SOCKET s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (s == SOCKET_ERROR)
|
if (s == SOCKET_ERROR)
|
||||||
|
@ -232,8 +229,7 @@ namespace libtorrent
|
||||||
address get_default_gateway(asio::io_service& ios, address const& interface, asio::error_code& ec)
|
address get_default_gateway(asio::io_service& ios, address const& interface, asio::error_code& ec)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if (defined __APPLE__ && __MACH__) || defined __FreeBSD__ || defined __NetBSD__ \
|
#if defined TORRENT_BSD
|
||||||
|| defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__
|
|
||||||
|
|
||||||
struct rt_msg
|
struct rt_msg
|
||||||
{
|
{
|
||||||
|
@ -333,7 +329,7 @@ namespace libtorrent
|
||||||
|
|
||||||
return sockaddr_to_address((sockaddr*)sin);
|
return sockaddr_to_address((sockaddr*)sin);
|
||||||
|
|
||||||
#elif defined WIN32
|
#elif defined TORRENT_WINDOWS
|
||||||
|
|
||||||
// Load Iphlpapi library
|
// Load Iphlpapi library
|
||||||
HMODULE iphlp = LoadLibraryA("Iphlpapi.dll");
|
HMODULE iphlp = LoadLibraryA("Iphlpapi.dll");
|
||||||
|
@ -398,7 +394,7 @@ namespace libtorrent
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
//#elif defined __linux__
|
//#elif defined TORRENT_LINUX
|
||||||
// No linux implementation yet
|
// No linux implementation yet
|
||||||
#else
|
#else
|
||||||
if (!interface.is_v4())
|
if (!interface.is_v4())
|
||||||
|
|
Loading…
Reference in New Issue