Using address::is_multicast instead util function (#686)

This commit is contained in:
Alden Torres 2016-05-01 18:15:25 -04:00 committed by Arvid Norberg
parent c8241f4eac
commit b85b501d92
5 changed files with 5 additions and 23 deletions

View File

@ -391,7 +391,7 @@ namespace libtorrent
boost::int64_t total_uploaded; boost::int64_t total_uploaded;
boost::int64_t total_downloaded; boost::int64_t total_downloaded;
// the numeber of seconds this torrent has spent in started, finished and // the number of seconds this torrent has spent in started, finished and
// seeding state so far, respectively. // seeding state so far, respectively.
int active_time; int active_time;
int finished_time; int finished_time;
@ -415,7 +415,7 @@ namespace libtorrent
// swarm, as returned by the tracker (either when announcing to it or by // swarm, as returned by the tracker (either when announcing to it or by
// sending a specific scrape request). ``num_complete`` is the number of // sending a specific scrape request). ``num_complete`` is the number of
// peers in the swarm that are seeds, or have every piece in the torrent. // peers in the swarm that are seeds, or have every piece in the torrent.
// ``num_inomplete`` is the number of peers in the swarm that do not have // ``num_incomplete`` is the number of peers in the swarm that do not have
// every piece. ``num_downloaded`` is the number of times the torrent has // every piece. ``num_downloaded`` is the number of times the torrent has
// been downloaded (not initiated, but the number of times a download has // been downloaded (not initiated, but the number of times a download has
// completed). // completed).

View File

@ -52,7 +52,6 @@ namespace libtorrent
TORRENT_EXTRA_EXPORT bool is_local(address const& a); TORRENT_EXTRA_EXPORT bool is_local(address const& a);
TORRENT_EXTRA_EXPORT bool is_loopback(address const& addr); 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_any(address const& addr);
TORRENT_EXTRA_EXPORT bool is_teredo(address const& addr); TORRENT_EXTRA_EXPORT bool is_teredo(address const& addr);
TORRENT_EXTRA_EXPORT int cidr_distance(address const& a1, address const& a2); TORRENT_EXTRA_EXPORT int cidr_distance(address const& a1, address const& a2);

View File

@ -1503,7 +1503,7 @@ namespace libtorrent
// to peer protocol encryption. // to peer protocol encryption.
struct TORRENT_EXPORT pe_settings struct TORRENT_EXPORT pe_settings
{ {
// initializes the encryption settings with the default vaues // initializes the encryption settings with the default values
pe_settings() pe_settings()
: out_enc_policy(enabled) : out_enc_policy(enabled)
, in_enc_policy(enabled) , in_enc_policy(enabled)

View File

@ -97,20 +97,6 @@ namespace libtorrent
#endif #endif
} }
bool is_multicast(address const& addr)
{
#if TORRENT_USE_IPV6
TORRENT_TRY {
if (addr.is_v4())
return addr.to_v4().is_multicast();
else
return addr.to_v6().is_multicast();
} TORRENT_CATCH(std::exception&) { return false; }
#else
return addr.to_v4().is_multicast();
#endif
}
bool is_any(address const& addr) bool is_any(address const& addr)
{ {
TORRENT_TRY { TORRENT_TRY {
@ -212,9 +198,7 @@ namespace libtorrent
, m_outstanding_operations(0) , m_outstanding_operations(0)
, m_abort(false) , m_abort(false)
{ {
TORRENT_ASSERT(is_multicast(m_multicast_endpoint.address())); TORRENT_ASSERT(m_multicast_endpoint.address().is_multicast());
using namespace boost::asio::ip::multicast;
} }
void broadcast_socket::open(receive_handler_t const& handler void broadcast_socket::open(receive_handler_t const& handler
@ -302,7 +286,6 @@ namespace libtorrent
void broadcast_socket::open_unicast_socket(io_service& ios, address const& addr void broadcast_socket::open_unicast_socket(io_service& ios, address const& addr
, address_v4 const& mask) , address_v4 const& mask)
{ {
using namespace boost::asio::ip::multicast;
error_code ec; error_code ec;
boost::shared_ptr<udp::socket> s(new udp::socket(ios)); boost::shared_ptr<udp::socket> s(new udp::socket(ios));
s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec); s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec);

View File

@ -91,7 +91,7 @@ int main()
, i->netmask.to_string(ec).c_str() , i->netmask.to_string(ec).c_str()
, i->name , i->name
, i->mtu , i->mtu
, (is_multicast(i->interface_address)?"multicast ":"") , (i->interface_address.is_multicast()?"multicast ":"")
, (is_local(i->interface_address)?"local ":"") , (is_local(i->interface_address)?"local ":"")
, (is_loopback(i->interface_address)?"loopback ":"") , (is_loopback(i->interface_address)?"loopback ":"")
); );