low level network primitives should not be exported. Moved enum_if into tests (since it uses internal functions)

This commit is contained in:
Arvid Norberg 2013-07-20 01:02:15 +00:00
parent 6e28e33b32
commit bbe62564ad
8 changed files with 41 additions and 34 deletions

View File

@ -21,7 +21,6 @@ exe client_test : client_test.cpp ;
exe simple_client : simple_client.cpp ;
exe dump_torrent : dump_torrent.cpp ;
exe make_torrent : make_torrent.cpp ;
exe enum_if : enum_if.cpp ;
exe connection_tester : connection_tester.cpp ;
exe fragmentation_test : fragmentation_test.cpp ;
exe rss_reader : rss_reader.cpp ;

View File

@ -59,7 +59,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/magnet_uri.hpp"
#include "libtorrent/bitfield.hpp"
#include "libtorrent/peer_info.hpp"
#include "libtorrent/socket_io.hpp" // print_address
#include "libtorrent/time.hpp"
#include "libtorrent/create_torrent.hpp"
@ -264,6 +263,21 @@ bool is_hex(char const *in, int len)
return true;
}
std::string print_endpoint(libtorrent::tcp::endpoint const& ep)
{
using namespace libtorrent;
error_code ec;
char buf[200];
address const& addr = ep.address();
#if TORRENT_USE_IPV6
if (addr.is_v6())
snprintf(buf, sizeof(buf), "[%s]:%d", addr.to_string(ec).c_str(), ep.port());
else
#endif
snprintf(buf, sizeof(buf), "%s:%d", addr.to_string(ec).c_str(), ep.port());
return buf;
}
enum {
torrents_all,
torrents_downloading,
@ -571,9 +585,9 @@ void print_peer_info(std::string& out, std::vector<libtorrent::peer_info> const&
if (print_ip)
{
snprintf(str, sizeof(str), "%-30s %-22s", (print_endpoint(i->ip) +
snprintf(str, sizeof(str), "%-30s %-22s", (::print_endpoint(i->ip) +
(i->connection_type == peer_info::bittorrent_utp ? " [uTP]" : "")).c_str()
, print_endpoint(i->local_endpoint).c_str());
, ::print_endpoint(i->local_endpoint).c_str());
out += str;
}

View File

@ -45,20 +45,20 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
TORRENT_EXPORT bool is_local(address const& a);
TORRENT_EXPORT bool is_loopback(address const& addr);
TORRENT_EXPORT bool is_multicast(address const& addr);
TORRENT_EXPORT bool is_any(address const& addr);
TORRENT_EXPORT bool is_teredo(address const& addr);
TORRENT_EXTRA_EXPORT bool is_local(address const& a);
TORRENT_EXTRA_EXPORT bool is_loopback(address const& addr);
TORRENT_EXTRA_EXPORT bool is_multicast(address const& addr);
TORRENT_EXTRA_EXPORT bool is_any(address const& addr);
TORRENT_EXTRA_EXPORT bool is_teredo(address const& addr);
TORRENT_EXTRA_EXPORT int cidr_distance(address const& a1, address const& a2);
// determines if the operating system supports IPv6
TORRENT_EXPORT bool supports_ipv6();
TORRENT_EXTRA_EXPORT bool supports_ipv6();
TORRENT_EXTRA_EXPORT int common_bits(unsigned char const* b1
, unsigned char const* b2, int n);
TORRENT_EXPORT address guess_local_address(io_service&);
TORRENT_EXTRA_EXPORT address guess_local_address(io_service&);
typedef boost::function<void(udp::endpoint const& from
, char* buffer, int size)> receive_handler_t;

View File

@ -62,20 +62,20 @@ namespace libtorrent
// returns a list of the configured IP interfaces
// on the machine
TORRENT_EXPORT std::vector<ip_interface> enum_net_interfaces(io_service& ios
TORRENT_EXTRA_EXPORT std::vector<ip_interface> enum_net_interfaces(io_service& ios
, error_code& ec);
TORRENT_EXPORT std::vector<ip_route> enum_routes(io_service& ios, error_code& ec);
TORRENT_EXTRA_EXPORT std::vector<ip_route> enum_routes(io_service& ios, error_code& ec);
// return (a1 & mask) == (a2 & mask)
TORRENT_EXPORT bool match_addr_mask(address const& a1, address const& a2, address const& mask);
TORRENT_EXTRA_EXPORT bool match_addr_mask(address const& a1, address const& a2, address const& mask);
// returns true if the specified address is on the same
// local network as us
TORRENT_EXPORT bool in_local_network(io_service& ios, address const& addr
TORRENT_EXTRA_EXPORT bool in_local_network(io_service& ios, address const& addr
, error_code& ec);
TORRENT_EXPORT address get_default_gateway(io_service& ios
TORRENT_EXTRA_EXPORT address get_default_gateway(io_service& ios
, error_code& ec);
}

View File

@ -43,10 +43,10 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
TORRENT_EXPORT std::string print_address(address const& addr);
TORRENT_EXPORT std::string print_endpoint(tcp::endpoint const& ep);
TORRENT_EXPORT std::string print_endpoint(udp::endpoint const& ep);
TORRENT_EXPORT std::string address_to_bytes(address const& a);
TORRENT_EXTRA_EXPORT std::string print_address(address const& addr);
TORRENT_EXTRA_EXPORT std::string print_endpoint(tcp::endpoint const& ep);
TORRENT_EXTRA_EXPORT std::string print_endpoint(udp::endpoint const& ep);
TORRENT_EXTRA_EXPORT std::string address_to_bytes(address const& a);
TORRENT_EXTRA_EXPORT void hash_address(address const& ip, sha1_hash& h);
namespace detail

View File

@ -67,25 +67,15 @@ namespace libtorrent
std::string print_endpoint(tcp::endpoint const& ep)
{
error_code ec;
std::string ret;
char buf[200];
address const& addr = ep.address();
#if TORRENT_USE_IPV6
if (addr.is_v6())
{
ret += '[';
ret += addr.to_string(ec);
ret += ']';
ret += ':';
ret += to_string(ep.port()).elems;
}
snprintf(buf, sizeof(buf), "[%s]:%d", addr.to_string(ec).c_str(), ep.port());
else
#endif
{
ret += addr.to_string(ec);
ret += ':';
ret += to_string(ep.port()).elems;
}
return ret;
snprintf(buf, sizeof(buf), "%s:%d", addr.to_string(ec).c_str(), ep.port());
return buf;
}
std::string print_endpoint(udp::endpoint const& ep)

View File

@ -5,7 +5,11 @@ use-project /torrent : .. ;
exe test_natpmp : test_natpmp.cpp /torrent//torrent
: <threading>multi <debug-iterators>on <invariant-checks>full ;
exe enum_if : enum_if.cpp /torrent//torrent
: <threading>multi <debug-iterators>on <invariant-checks>full ;
explicit test_natpmp ;
explicit enum_if ;
lib libtorrent_test
: # sources