land libtorrent_aio branch in trunk
This commit is contained in:
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "libtorrent/broadcast_socket.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/socket_type.hpp"
|
||||
#if BOOST_VERSION < 103500
|
||||
#include <asio/ip/host_name.hpp>
|
||||
#else
|
||||
@@ -343,7 +344,12 @@ namespace libtorrent
|
||||
{
|
||||
std::vector<ip_interface> net = enum_net_interfaces(ios, ec);
|
||||
if (ec) return false;
|
||||
for (std::vector<ip_interface>::iterator i = net.begin()
|
||||
return in_local_network(net, addr);
|
||||
}
|
||||
|
||||
bool in_local_network(std::vector<ip_interface> const& net, address const& addr)
|
||||
{
|
||||
for (std::vector<ip_interface>::const_iterator i = net.begin()
|
||||
, end(net.end()); i != end; ++i)
|
||||
{
|
||||
if (match_addr_mask(addr, i->interface_address, i->netmask))
|
||||
@@ -1055,6 +1061,28 @@ namespace libtorrent
|
||||
return ret;
|
||||
}
|
||||
|
||||
// returns true if the given device exists
|
||||
bool has_interface(char const* name, io_service& ios, error_code& ec)
|
||||
{
|
||||
std::vector<ip_interface> ifs = enum_net_interfaces(ios, ec);
|
||||
if (ec) return false;
|
||||
|
||||
for (int i = 0; i < int(ifs.size()); ++i)
|
||||
if (ifs[i].name == name) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns the device name whose local address is ``addr``. If
|
||||
// no such device is found, an empty string is returned.
|
||||
std::string device_for_address(address addr, io_service& ios, error_code& ec)
|
||||
{
|
||||
std::vector<ip_interface> ifs = enum_net_interfaces(ios, ec);
|
||||
if (ec) return std::string();
|
||||
|
||||
for (int i = 0; i < int(ifs.size()); ++i)
|
||||
if (ifs[i].interface_address == addr) return ifs[i].name;
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user