2007-09-20 18:25:07 +02:00
|
|
|
#include <libtorrent/enum_net.hpp>
|
|
|
|
#include <libtorrent/socket.hpp>
|
|
|
|
#include <libtorrent/broadcast_socket.hpp>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace libtorrent;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
io_service ios;
|
|
|
|
asio::error_code ec;
|
2008-01-11 07:49:37 +01:00
|
|
|
std::vector<ip_interface> const& net = enum_net_interfaces(ios, ec);
|
2007-09-20 18:25:07 +02:00
|
|
|
|
2008-01-11 07:49:37 +01:00
|
|
|
for (std::vector<ip_interface>::const_iterator i = net.begin()
|
2007-09-20 18:25:07 +02:00
|
|
|
, end(net.end()); i != end; ++i)
|
|
|
|
{
|
2008-01-11 07:49:37 +01:00
|
|
|
std::cout << "address: " << i->interface_address << std::endl
|
|
|
|
<< " mask: " << i->netmask << std::endl
|
|
|
|
<< " flags: ";
|
|
|
|
if (is_multicast(i->interface_address)) std::cout << "multicast ";
|
|
|
|
if (is_local(i->interface_address)) std::cout << "local ";
|
|
|
|
if (is_loopback(i->interface_address)) std::cout << "loopback ";
|
|
|
|
std::cout << std::endl;
|
2007-09-20 18:25:07 +02:00
|
|
|
}
|
2007-10-01 19:21:19 +02:00
|
|
|
|
|
|
|
address local = guess_local_address(ios);
|
|
|
|
std::cout << "Local address: " << local << std::endl;
|
2008-01-11 10:58:40 +01:00
|
|
|
|
|
|
|
address gateway = get_default_gateway(ios, local, ec);
|
|
|
|
std::cout << "Default gateway: " << gateway << std::endl;
|
2007-09-20 18:25:07 +02:00
|
|
|
}
|
|
|
|
|