From 9a9f08f70f31172ebe96e807cc7c531c26aea6b1 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 21 Jan 2009 01:39:13 +0000 Subject: [PATCH] enables teredo support on windows --- include/libtorrent/socket.hpp | 16 ++++++++++++++++ src/session_impl.cpp | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index d4cc9bdb0..98f5d8151 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -213,6 +213,22 @@ namespace libtorrent int m_value; }; +#ifdef TORRENT_WINDOWS + struct v6_protection_level + { + v6_protection_level(int level): m_value(level) {} + template + int level(Protocol const&) const { return IPPROTO_IPV6; } + template + int name(Protocol const&) const { return IPV6_PROTECTION_LEVEL; } + template + int const* data(Protocol const&) const { return &m_value; } + template + size_t size(Protocol const&) const { return sizeof(m_value); } + int m_value; + }; +#endif + struct type_of_service { type_of_service(char val): m_value(val) {} diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f3d97885f..4e33a61a3 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -632,7 +632,14 @@ namespace aux { s.sock.reset(new socket_acceptor(m_io_service)); s.sock->open(ep.protocol(), 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); while (ec && retries > 0) {