enables teredo support on windows

This commit is contained in:
Arvid Norberg 2009-01-21 01:39:13 +00:00
parent 8d6c1527ae
commit 9a9f08f70f
2 changed files with 24 additions and 1 deletions

View File

@ -213,6 +213,22 @@ namespace libtorrent
int m_value; int m_value;
}; };
#ifdef TORRENT_WINDOWS
struct v6_protection_level
{
v6_protection_level(int level): m_value(level) {}
template<class Protocol>
int level(Protocol const&) const { return IPPROTO_IPV6; }
template<class Protocol>
int name(Protocol const&) const { return IPV6_PROTECTION_LEVEL; }
template<class Protocol>
int const* data(Protocol const&) const { return &m_value; }
template<class Protocol>
size_t size(Protocol const&) const { return sizeof(m_value); }
int m_value;
};
#endif
struct type_of_service struct type_of_service
{ {
type_of_service(char val): m_value(val) {} type_of_service(char val): m_value(val) {}

View File

@ -632,7 +632,14 @@ namespace aux {
s.sock.reset(new socket_acceptor(m_io_service)); s.sock.reset(new socket_acceptor(m_io_service));
s.sock->open(ep.protocol(), ec); s.sock->open(ep.protocol(), ec);
s.sock->set_option(socket_acceptor::reuse_address(true), ec); s.sock->set_option(socket_acceptor::reuse_address(true), ec);
if (ep.protocol() == tcp::v6()) s.sock->set_option(v6only(v6_only), ec); if (ep.protocol() == tcp::v6())
{
s.sock->set_option(v6only(v6_only), ec);
#ifdef TORRENT_WINDOWS
// enable Teredo on windows
s.sock->set_option(v6_protection_level(PROTECTION_LEVEL_UNRESTRICTED), ec);
#endif
}
s.sock->bind(ep, ec); s.sock->bind(ep, ec);
while (ec && retries > 0) while (ec && retries > 0)
{ {