forked from premiere/premiere-libtorrent
fixed building with no IPv6 support
This commit is contained in:
parent
9fd7a58370
commit
ddceb1487d
3
Jamfile
3
Jamfile
|
@ -218,6 +218,9 @@ feature.compose <timer>absolute : <define>TORRENT_USE_ABSOLUTE_TIME=1 ;
|
||||||
feature.compose <timer>performance : <define>TORRENT_USE_PERFORMANCE_TIMER=1 ;
|
feature.compose <timer>performance : <define>TORRENT_USE_PERFORMANCE_TIMER=1 ;
|
||||||
feature.compose <timer>clock : <define>TORRENT_USE_CLOCK_GETTIME=1 ;
|
feature.compose <timer>clock : <define>TORRENT_USE_CLOCK_GETTIME=1 ;
|
||||||
|
|
||||||
|
feature ipv6 : on off : composite propagated link-incompatible ;
|
||||||
|
feature.compose <ipv6>off : <define>TORRENT_USE_IPV6=0 ;
|
||||||
|
|
||||||
feature need-librt : no yes : composite propagated link-incompatible ;
|
feature need-librt : no yes : composite propagated link-incompatible ;
|
||||||
|
|
||||||
feature pool-allocators : on off : composite propagated link-incompatible ;
|
feature pool-allocators : on off : composite propagated link-incompatible ;
|
||||||
|
|
|
@ -60,12 +60,16 @@ namespace libtorrent
|
||||||
#if BOOST_VERSION < 103500
|
#if BOOST_VERSION < 103500
|
||||||
typedef ::asio::ip::address address;
|
typedef ::asio::ip::address address;
|
||||||
typedef ::asio::ip::address_v4 address_v4;
|
typedef ::asio::ip::address_v4 address_v4;
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
typedef ::asio::ip::address_v6 address_v6;
|
typedef ::asio::ip::address_v6 address_v6;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
typedef boost::asio::ip::address address;
|
typedef boost::asio::ip::address address;
|
||||||
typedef boost::asio::ip::address_v4 address_v4;
|
typedef boost::asio::ip::address_v4 address_v4;
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
typedef boost::asio::ip::address_v6 address_v6;
|
typedef boost::asio::ip::address_v6 address_v6;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -137,7 +137,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_BSD
|
#define TORRENT_BSD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_USE_IPV6
|
||||||
#define TORRENT_USE_IPV6 1
|
#define TORRENT_USE_IPV6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TORRENT_USE_MLOCK 1
|
#define TORRENT_USE_MLOCK 1
|
||||||
#define TORRENT_USE_READV 1
|
#define TORRENT_USE_READV 1
|
||||||
#define TORRENT_USE_WRITEV 1
|
#define TORRENT_USE_WRITEV 1
|
||||||
|
|
|
@ -276,8 +276,12 @@ public:
|
||||||
void add_rule(address first, address last, int flags);
|
void add_rule(address first, address last, int flags);
|
||||||
int access(address const& addr) const;
|
int access(address const& addr) const;
|
||||||
|
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
typedef boost::tuple<std::vector<ip_range<address_v4> >
|
typedef boost::tuple<std::vector<ip_range<address_v4> >
|
||||||
, std::vector<ip_range<address_v6> > > filter_tuple_t;
|
, std::vector<ip_range<address_v6> > > filter_tuple_t;
|
||||||
|
#else
|
||||||
|
typedef std::vector<ip_range<address_v4> > filter_tuple_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
filter_tuple_t export_filter() const;
|
filter_tuple_t export_filter() const;
|
||||||
|
|
||||||
|
|
|
@ -80,12 +80,14 @@ struct traversal_algorithm : boost::noncopyable
|
||||||
result(node_id const& id, udp::endpoint ep, unsigned char f = 0)
|
result(node_id const& id, udp::endpoint ep, unsigned char f = 0)
|
||||||
: id(id), flags(f)
|
: id(id), flags(f)
|
||||||
{
|
{
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
if (ep.address().is_v6())
|
if (ep.address().is_v6())
|
||||||
{
|
{
|
||||||
flags |= ipv6_address;
|
flags |= ipv6_address;
|
||||||
addr.v6 = ep.address().to_v6().to_bytes();
|
addr.v6 = ep.address().to_v6().to_bytes();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
flags &= ~ipv6_address;
|
flags &= ~ipv6_address;
|
||||||
addr.v4 = ep.address().to_v4().to_bytes();
|
addr.v4 = ep.address().to_v4().to_bytes();
|
||||||
|
@ -95,9 +97,11 @@ struct traversal_algorithm : boost::noncopyable
|
||||||
|
|
||||||
udp::endpoint endpoint() const
|
udp::endpoint endpoint() const
|
||||||
{
|
{
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
if (flags & ipv6_address)
|
if (flags & ipv6_address)
|
||||||
return udp::endpoint(address_v6(addr.v6), port);
|
return udp::endpoint(address_v6(addr.v6), port);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
return udp::endpoint(address_v4(addr.v4), port);
|
return udp::endpoint(address_v4(addr.v4), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +110,9 @@ struct traversal_algorithm : boost::noncopyable
|
||||||
union addr_t
|
union addr_t
|
||||||
{
|
{
|
||||||
address_v4::bytes_type v4;
|
address_v4::bytes_type v4;
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
address_v6::bytes_type v6;
|
address_v6::bytes_type v6;
|
||||||
|
#endif
|
||||||
} addr;
|
} addr;
|
||||||
|
|
||||||
boost::uint16_t port;
|
boost::uint16_t port;
|
||||||
|
|
|
@ -314,7 +314,9 @@ namespace libtorrent
|
||||||
union addr_t
|
union addr_t
|
||||||
{
|
{
|
||||||
address_v4::bytes_type v4;
|
address_v4::bytes_type v4;
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
address_v6::bytes_type v6;
|
address_v6::bytes_type v6;
|
||||||
|
#endif
|
||||||
} addr;
|
} addr;
|
||||||
|
|
||||||
boost::uint16_t port;
|
boost::uint16_t port;
|
||||||
|
@ -322,19 +324,23 @@ namespace libtorrent
|
||||||
|
|
||||||
void set_peer(tcp::endpoint const& ep)
|
void set_peer(tcp::endpoint const& ep)
|
||||||
{
|
{
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
is_v6_addr = ep.address().is_v6();
|
is_v6_addr = ep.address().is_v6();
|
||||||
if (is_v6_addr)
|
if (is_v6_addr)
|
||||||
addr.v6 = ep.address().to_v6().to_bytes();
|
addr.v6 = ep.address().to_v6().to_bytes();
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
addr.v4 = ep.address().to_v4().to_bytes();
|
addr.v4 = ep.address().to_v4().to_bytes();
|
||||||
port = ep.port();
|
port = ep.port();
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp::endpoint peer() const
|
tcp::endpoint peer() const
|
||||||
{
|
{
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
if (is_v6_addr)
|
if (is_v6_addr)
|
||||||
return tcp::endpoint(address_v6(addr.v6), port);
|
return tcp::endpoint(address_v6(addr.v6), port);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
return tcp::endpoint(address_v4(addr.v4), port);
|
return tcp::endpoint(address_v4(addr.v4), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1527,6 +1527,7 @@ namespace libtorrent
|
||||||
std::copy(myip.begin(), myip.end(), bytes.begin());
|
std::copy(myip.begin(), myip.end(), bytes.begin());
|
||||||
m_ses.set_external_address(address_v4(bytes));
|
m_ses.set_external_address(address_v4(bytes));
|
||||||
}
|
}
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
else if (myip.size() == address_v6::bytes_type::static_size)
|
else if (myip.size() == address_v6::bytes_type::static_size)
|
||||||
{
|
{
|
||||||
address_v6::bytes_type bytes;
|
address_v6::bytes_type bytes;
|
||||||
|
@ -1537,6 +1538,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
m_ses.set_external_address(ipv6_address);
|
m_ses.set_external_address(ipv6_address);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're finished and this peer is uploading only
|
// if we're finished and this peer is uploading only
|
||||||
|
|
|
@ -298,12 +298,14 @@ namespace libtorrent
|
||||||
ifreq netmask = item;
|
ifreq netmask = item;
|
||||||
if (ioctl(s, SIOCGIFNETMASK, &netmask) < 0)
|
if (ioctl(s, SIOCGIFNETMASK, &netmask) < 0)
|
||||||
{
|
{
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
if (iface.interface_address.is_v6())
|
if (iface.interface_address.is_v6())
|
||||||
{
|
{
|
||||||
// this is expected to fail (at least on MacOS X)
|
// this is expected to fail (at least on MacOS X)
|
||||||
iface.netmask = address_v6::any();
|
iface.netmask = address_v6::any();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ec = error_code(errno, asio::error::system_category);
|
ec = error_code(errno, asio::error::system_category);
|
||||||
close(s);
|
close(s);
|
||||||
|
|
|
@ -74,8 +74,7 @@ namespace libtorrent
|
||||||
return boost::make_tuple(m_filter4.export_filter<address_v4>()
|
return boost::make_tuple(m_filter4.export_filter<address_v4>()
|
||||||
, m_filter6.export_filter<address_v6>());
|
, m_filter6.export_filter<address_v6>());
|
||||||
#else
|
#else
|
||||||
return boost::make_tuple(m_filter4.export_filter<address_v4>()
|
return m_filter4.export_filter<address_v4>();
|
||||||
, std::vector<ip_range<address_v6> >());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -511,11 +511,13 @@ namespace libtorrent
|
||||||
address_v4::bytes_type bytes = addr.to_v4().to_bytes();
|
address_v4::bytes_type bytes = addr.to_v4().to_bytes();
|
||||||
x.assign((char*)&bytes[0], bytes.size());
|
x.assign((char*)&bytes[0], bytes.size());
|
||||||
}
|
}
|
||||||
|
#if TORRENT_USE_IPV6
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
address_v6::bytes_type bytes = addr.to_v6().to_bytes();
|
address_v6::bytes_type bytes = addr.to_v6().to_bytes();
|
||||||
x.assign((char*)&bytes[0], bytes.size());
|
x.assign((char*)&bytes[0], bytes.size());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
x.append((char*)&t->torrent_file().info_hash()[0], 20);
|
x.append((char*)&t->torrent_file().info_hash()[0], 20);
|
||||||
|
|
||||||
sha1_hash hash = hasher(&x[0], x.size()).final();
|
sha1_hash hash = hasher(&x[0], x.size()).final();
|
||||||
|
@ -4534,10 +4536,12 @@ namespace libtorrent
|
||||||
// to the same protocol family as the target endpoint
|
// to the same protocol family as the target endpoint
|
||||||
if (is_any(bind_interface.address()))
|
if (is_any(bind_interface.address()))
|
||||||
{
|
{
|
||||||
if (m_remote.address().is_v4())
|
#if TORRENT_USE_IPV6
|
||||||
bind_interface.address(address_v4::any());
|
if (m_remote.address().is_v6())
|
||||||
else
|
|
||||||
bind_interface.address(address_v6::any());
|
bind_interface.address(address_v6::any());
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
bind_interface.address(address_v4::any());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_socket->bind(bind_interface, ec);
|
m_socket->bind(bind_interface, ec);
|
||||||
|
|
Loading…
Reference in New Issue