added option to control TOS byte in peer traffic
This commit is contained in:
@@ -101,6 +101,20 @@ public:
|
||||
m_sock.async_write_some(buffers, handler);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
template <class SettableSocketOption>
|
||||
void set_option(SettableSocketOption const& opt)
|
||||
{
|
||||
m_sock.set_option(opt);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class SettableSocketOption>
|
||||
asio::error_code set_option(SettableSocketOption const& opt, asio::error_code& ec)
|
||||
{
|
||||
return m_sock.set_option(opt, ec);
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
void bind(endpoint_type const& endpoint)
|
||||
{
|
||||
|
@@ -127,6 +127,7 @@ namespace libtorrent
|
||||
, cache_size(512)
|
||||
, cache_expiry(60)
|
||||
, outgoing_ports(0,0)
|
||||
, peer_tos(0)
|
||||
{}
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
@@ -339,6 +340,13 @@ namespace libtorrent
|
||||
// is useful for users that have routers that
|
||||
// allow QoS settings based on local port.
|
||||
std::pair<int, int> outgoing_ports;
|
||||
|
||||
// the TOS byte of all peer traffic (including
|
||||
// web seeds) is set to this value. The default
|
||||
// is the QBSS scavenger service
|
||||
// http://qbone.internet2.edu/qbss/
|
||||
// For unmarked packets, set to 0
|
||||
char peer_tos;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
@@ -185,6 +185,19 @@ namespace libtorrent
|
||||
int m_value;
|
||||
};
|
||||
|
||||
struct type_of_service
|
||||
{
|
||||
type_of_service(char val): m_value(val) {}
|
||||
template<class Protocol>
|
||||
int level(Protocol const&) const { return IPPROTO_IP; }
|
||||
template<class Protocol>
|
||||
int name(Protocol const&) const { return IP_TOS; }
|
||||
template<class Protocol>
|
||||
char const* data(Protocol const&) const { return &m_value; }
|
||||
template<class Protocol>
|
||||
size_t size(Protocol const&) const { return sizeof(m_value); }
|
||||
char m_value;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TORRENT_SOCKET_HPP_INCLUDED
|
||||
|
@@ -256,6 +256,45 @@ namespace aux
|
||||
{ return EndpointType(); }
|
||||
};
|
||||
|
||||
// -------------- set_option -----------
|
||||
|
||||
template <class SettableSocketOption>
|
||||
struct set_option_visitor
|
||||
: boost::static_visitor<>
|
||||
{
|
||||
set_option_visitor(SettableSocketOption const& opt)
|
||||
: opt_(opt)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
void operator()(T* p) const
|
||||
{ p->set_option(opt_); }
|
||||
|
||||
std::size_t operator()(boost::blank) const {}
|
||||
|
||||
SettableSocketOption const& opt_;
|
||||
};
|
||||
|
||||
template <class SettableSocketOption>
|
||||
struct set_option_visitor_ec
|
||||
: boost::static_visitor<asio::error_code>
|
||||
{
|
||||
set_option_visitor_ec(SettableSocketOption const& opt, asio::error_code& ec)
|
||||
: opt_(opt)
|
||||
, ec_(ec)
|
||||
{}
|
||||
|
||||
template <class T>
|
||||
asio::error_code operator()(T* p) const
|
||||
{ return p->set_option(opt_, ec_); }
|
||||
|
||||
asio::error_code operator()(boost::blank) const
|
||||
{ return ec_; }
|
||||
|
||||
SettableSocketOption const& opt_;
|
||||
asio::error_code& ec_;
|
||||
};
|
||||
|
||||
// -------------- local_endpoint -----------
|
||||
|
||||
template <class EndpointType>
|
||||
@@ -657,6 +696,22 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
template <class SettableSocketOption>
|
||||
void set_option(SettableSocketOption const& opt)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
boost::apply_visitor(aux::set_option_visitor<SettableSocketOption>(opt)
|
||||
, m_variant);
|
||||
}
|
||||
|
||||
template <class SettableSocketOption>
|
||||
asio::error_code set_option(SettableSocketOption const& opt, asio::error_code& ec)
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
return boost::apply_visitor(aux::set_option_visitor_ec<SettableSocketOption>(opt, ec)
|
||||
, m_variant);
|
||||
}
|
||||
|
||||
endpoint_type local_endpoint() const
|
||||
{
|
||||
TORRENT_ASSERT(instantiated());
|
||||
|
Reference in New Issue
Block a user