Advertisement
cooperlees

Adding v6 ToS

Aug 21st, 2014
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.83 KB | None | 0 0
  1. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp
  2. index 058a18b..229e3e5 100644
  3. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp
  4. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/include/libtorrent/socket.hpp
  5. @@ -64,7 +64,7 @@ POSSIBILITY OF SUCH DAMAGE.
  6.  #include <boost/asio/read.hpp>
  7.  #endif
  8.  
  9. -#ifdef __OBJC__
  10. +#ifdef __OBJC__
  11.  #undef Protocol
  12.  #endif
  13.  
  14. @@ -114,7 +114,7 @@ namespace libtorrent
  15.         };
  16.  #endif
  17.  #endif
  18. -
  19. +
  20.  #ifdef TORRENT_WINDOWS
  21.  
  22.  #ifndef IPV6_PROTECTION_LEVEL
  23. @@ -135,6 +135,20 @@ namespace libtorrent
  24.         };
  25.  #endif
  26.  
  27. +    struct traffic_class
  28. +    {
  29. +        traffic_class(char val): m_value(val) {}
  30. +        template<class Protocol>
  31. +        int level(Protocol const&) const { return IPPROTO_IPV6; }
  32. +        template<class Protocol>
  33. +        int name(Protocol const&) const { return IPV6_TCLASS; }
  34. +        template<class Protocol>
  35. +        int const* data(Protocol const&) const { return &m_value; }
  36. +        template<class Protocol>
  37. +        size_t size(Protocol const&) const { return sizeof(m_value); }
  38. +        int m_value;
  39. +    };
  40. +
  41.         struct type_of_service
  42.         {
  43.  #ifdef WIN32
  44. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp
  45. index 2a94e51..ab80ee9 100644
  46. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp
  47. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/peer_connection.cpp
  48. @@ -638,6 +638,10 @@ namespace libtorrent
  49.                                 peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_ses.settings().peer_tos, ec.message().c_str());
  50.  #endif
  51.                         }
  52. +            else if (m_remote.address().is_v6())
  53. +            {
  54. +                m_socket->set_option(traffic_class(m_ses.settings().peer_tos), ec);
  55. +            }
  56.                 }
  57.  
  58.                 if (t && t->ready_for_connections())
  59. @@ -5700,12 +5704,16 @@ namespace libtorrent
  60.                         peer_log(">>> SET_TOS[ tos: %d e: %s ]", m_ses.settings().peer_tos, ec.message().c_str());
  61.  #endif
  62.                 }
  63. +        else if (m_remote.address().is_v6())
  64. +        {
  65. +            m_socket->set_option(traffic_class(m_ses.settings().peer_tos), ec);
  66. +        }
  67.  
  68.                 on_connected();
  69.                 setup_send();
  70.                 setup_receive();
  71.         }
  72. -
  73. +
  74.         // --------------------------
  75.         // SEND DATA
  76.         // --------------------------
  77. diff --git a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp
  78. index 79cc500..6ec84ce 100644
  79. --- a/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp
  80. +++ b/0.16.16/src/libtorrent-rasterbar-0.16.16/src/session_impl.cpp
  81. @@ -2052,7 +2052,10 @@ namespace aux {
  82.                 if (m_settings.peer_tos != s.peer_tos)
  83.                 {
  84.                         error_code ec;
  85. -                       m_udp_socket.set_option(type_of_service(s.peer_tos), ec);
  86. +            if (m_udp_socket.local_endpoint(ec).address().is_v6())
  87. +                m_udp_socket.set_option(traffic_class(s.peer_tos), ec);
  88. +            else
  89. +                           m_udp_socket.set_option(type_of_service(s.peer_tos), ec);
  90. @@ -2408,7 +2411,11 @@ retry:
  91.                         maybe_update_udp_mapping(1, m_listen_interface.port(), m_listen_interface.port());
  92.                 }
  93.  
  94. -               m_udp_socket.set_option(type_of_service(m_settings.peer_tos), ec);
  95. +
  96. +        if (m_udp_socket.local_endpoint(ec).address().is_v6())
  97. +            m_udp_socket.set_option(traffic_class(m_settings.peer_tos), ec);
  98. +        else
  99. +                   m_udp_socket.set_option(type_of_service(m_settings.peer_tos), ec);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement