From 9af88412449b1fb2275409308667779b7030760e Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 6 Jun 2015 13:49:18 -0400 Subject: [PATCH] remove some unnecessary asio typedefs in the libtorrent namespace, just pull ip::tcp and ip::udp --- examples/connection_tester.cpp | 2 +- include/libtorrent/aux_/session_impl.hpp | 6 ++-- include/libtorrent/broadcast_socket.hpp | 6 ++-- include/libtorrent/kademlia/dht_tracker.hpp | 2 +- include/libtorrent/natpmp.hpp | 2 +- include/libtorrent/proxy_base.hpp | 10 +++--- include/libtorrent/resolver.hpp | 1 + include/libtorrent/settings_pack.hpp | 2 +- include/libtorrent/socket.hpp | 4 --- include/libtorrent/socket_type.hpp | 28 +++++++-------- include/libtorrent/udp_socket.hpp | 6 ++-- include/libtorrent/utp_stream.hpp | 4 +-- src/broadcast_socket.cpp | 6 ++-- src/instantiate_connection.cpp | 4 +-- src/session_impl.cpp | 36 +++++++++---------- src/socket_type.cpp | 27 +++++++------- src/torrent.cpp | 4 +-- src/utp_socket_manager.cpp | 6 ++-- test/test_fast_extension.cpp | 40 ++++++++++----------- test/test_ssl.cpp | 2 +- 20 files changed, 98 insertions(+), 100 deletions(-) diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index 11b4e9239..15280cd1f 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -203,7 +203,7 @@ struct peer_conn s.async_connect(endpoint, boost::bind(&peer_conn::on_connect, this, _1)); } - stream_socket s; + tcp::socket s; char write_buf_proto[100]; boost::uint32_t write_buffer[17*1024/4]; boost::uint32_t buffer[17*1024/4]; diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index fa2432179..6347c055a 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -141,7 +141,7 @@ namespace libtorrent bool ssl; // the actual socket - boost::shared_ptr sock; + boost::shared_ptr sock; }; namespace aux @@ -234,9 +234,9 @@ namespace libtorrent tcp::endpoint get_ipv6_interface() const; tcp::endpoint get_ipv4_interface() const; - void async_accept(boost::shared_ptr const& listener, bool ssl); + void async_accept(boost::shared_ptr const& listener, bool ssl); void on_accept_connection(boost::shared_ptr const& s - , boost::weak_ptr listener, error_code const& e, bool ssl); + , boost::weak_ptr listener, error_code const& e, bool ssl); void on_socks_accept(boost::shared_ptr const& s , error_code const& e); diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index 42a00778b..35bd81c18 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -86,11 +86,11 @@ namespace libtorrent struct socket_entry { - socket_entry(boost::shared_ptr const& s) + socket_entry(boost::shared_ptr const& s) : socket(s), broadcast(false) {} - socket_entry(boost::shared_ptr const& s + socket_entry(boost::shared_ptr const& s , address_v4 const& mask): socket(s), netmask(mask), broadcast(false) {} - boost::shared_ptr socket; + boost::shared_ptr socket; char buffer[1500]; udp::endpoint remote; address_v4 netmask; diff --git a/include/libtorrent/kademlia/dht_tracker.hpp b/include/libtorrent/kademlia/dht_tracker.hpp index 56d4335b6..2acf33d31 100644 --- a/include/libtorrent/kademlia/dht_tracker.hpp +++ b/include/libtorrent/kademlia/dht_tracker.hpp @@ -116,7 +116,7 @@ namespace libtorrent { namespace dht , udp::endpoint const&, char const* buf, int size); private: - + boost::shared_ptr self() { return shared_from_this(); } diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index e8cbb588b..8f636c692 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -156,7 +156,7 @@ private: // the udp socket used to communicate // with the NAT router - datagram_socket m_socket; + udp::socket m_socket; // used to resend udp packets in case // they time out diff --git a/include/libtorrent/proxy_base.hpp b/include/libtorrent/proxy_base.hpp index 7725134ca..214c9126d 100644 --- a/include/libtorrent/proxy_base.hpp +++ b/include/libtorrent/proxy_base.hpp @@ -51,10 +51,10 @@ public: typedef boost::function handler_type; - typedef stream_socket next_layer_type; - typedef stream_socket::lowest_layer_type lowest_layer_type; - typedef stream_socket::endpoint_type endpoint_type; - typedef stream_socket::protocol_type protocol_type; + typedef tcp::socket next_layer_type; + typedef tcp::socket::lowest_layer_type lowest_layer_type; + typedef tcp::socket::endpoint_type endpoint_type; + typedef tcp::socket::protocol_type protocol_type; explicit proxy_base(io_service& io_service); ~proxy_base(); @@ -250,7 +250,7 @@ protected: bool handle_error(error_code const& e, boost::shared_ptr const& h); - stream_socket m_sock; + tcp::socket m_sock; std::string m_hostname; int m_port; diff --git a/include/libtorrent/resolver.hpp b/include/libtorrent/resolver.hpp index 8a387124f..65702d0d4 100644 --- a/include/libtorrent/resolver.hpp +++ b/include/libtorrent/resolver.hpp @@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/io_service.hpp" +#include "libtorrent/socket.hpp" #include "libtorrent/resolver_interface.hpp" #include "libtorrent/address.hpp" #include "libtorrent/time.hpp" diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 36a379c10..410b94577 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -1583,7 +1583,7 @@ namespace libtorrent { // use only plaintext encryption pe_plaintext = 1, - // use only rc4 encryption + // use only rc4 encryption pe_rc4 = 2, // allow both pe_both = 3 diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index ec14abdbd..b9559355b 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -69,10 +69,6 @@ namespace libtorrent using boost::asio::async_write; using boost::asio::async_read; - typedef boost::asio::ip::tcp::socket stream_socket; - typedef boost::asio::ip::udp::socket datagram_socket; - typedef boost::asio::ip::tcp::acceptor socket_acceptor; - #if TORRENT_USE_IPV6 #ifdef IPV6_V6ONLY struct v6only diff --git a/include/libtorrent/socket_type.hpp b/include/libtorrent/socket_type.hpp index c4881cd77..fd8a424e7 100644 --- a/include/libtorrent/socket_type.hpp +++ b/include/libtorrent/socket_type.hpp @@ -75,8 +75,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef TORRENT_USE_OPENSSL #define TORRENT_SOCKTYPE_SSL_FORWARD(x) \ - case socket_type_int_impl >::value: \ - get >()->x; break; \ + case socket_type_int_impl >::value: \ + get >()->x; break; \ case socket_type_int_impl >::value: \ get >()->x; break; \ case socket_type_int_impl >::value: \ @@ -85,8 +85,8 @@ POSSIBILITY OF SUCH DAMAGE. get >()->x; break; #define TORRENT_SOCKTYPE_SSL_FORWARD_RET(x, def) \ - case socket_type_int_impl >::value: \ - return get >()->x; \ + case socket_type_int_impl >::value: \ + return get >()->x; \ case socket_type_int_impl >::value: \ return get >()->x; \ case socket_type_int_impl >::value: \ @@ -103,8 +103,8 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_SOCKTYPE_FORWARD(x) \ switch (m_type) { \ - case socket_type_int_impl::value: \ - get()->x; break; \ + case socket_type_int_impl::value: \ + get()->x; break; \ case socket_type_int_impl::value: \ get()->x; break; \ case socket_type_int_impl::value: \ @@ -118,8 +118,8 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_SOCKTYPE_FORWARD_RET(x, def) \ switch (m_type) { \ - case socket_type_int_impl::value: \ - return get()->x; \ + case socket_type_int_impl::value: \ + return get()->x; \ case socket_type_int_impl::value: \ return get()->x; \ case socket_type_int_impl::value: \ @@ -139,7 +139,7 @@ namespace libtorrent { enum { value = 0 }; }; template <> - struct socket_type_int_impl + struct socket_type_int_impl { enum { value = 1 }; }; template <> @@ -162,7 +162,7 @@ namespace libtorrent #ifdef TORRENT_USE_OPENSSL template <> - struct socket_type_int_impl > + struct socket_type_int_impl > { enum { value = 6 }; }; template <> @@ -180,8 +180,8 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT socket_type { - typedef stream_socket::endpoint_type endpoint_type; - typedef stream_socket::protocol_type protocol_type; + typedef tcp::socket::endpoint_type endpoint_type; + typedef tcp::socket::protocol_type protocol_type; explicit socket_type(io_service& ios): m_io_service(ios), m_type(0) {} ~socket_type(); @@ -298,7 +298,7 @@ namespace libtorrent io_service& m_io_service; int m_type; enum { storage_size = max9< - sizeof(stream_socket) + sizeof(tcp::socket) , sizeof(socks5_stream) , sizeof(http_stream) , sizeof(utp_stream) @@ -308,7 +308,7 @@ namespace libtorrent , 0 #endif #ifdef TORRENT_USE_OPENSSL - , sizeof(ssl_stream) + , sizeof(ssl_stream) , sizeof(ssl_stream) , sizeof(ssl_stream) , sizeof(ssl_stream) diff --git a/include/libtorrent/udp_socket.hpp b/include/libtorrent/udp_socket.hpp index bc1dd55b8..f969161b5 100644 --- a/include/libtorrent/udp_socket.hpp +++ b/include/libtorrent/udp_socket.hpp @@ -210,7 +210,7 @@ namespace libtorrent void wrap(char const* hostname, int port, char const* p, int len, error_code& ec); void unwrap(error_code const& e, char const* buf, int size); - datagram_socket m_ipv4_sock; + udp::socket m_ipv4_sock; deadline_timer m_timer; int m_buf_size; @@ -223,7 +223,7 @@ namespace libtorrent char* m_buf; #if TORRENT_USE_IPV6 - datagram_socket m_ipv6_sock; + udp::socket m_ipv6_sock; #endif boost::uint16_t m_bind_port; @@ -232,7 +232,7 @@ namespace libtorrent boost::uint8_t m_v6_outstanding; #endif - stream_socket m_socks5_sock; + tcp::socket m_socks5_sock; proxy_settings m_proxy_settings; tcp::resolver m_resolver; char m_tmp_buf[270]; diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index a79d609c9..be0f36280 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -176,8 +176,8 @@ class TORRENT_EXTRA_EXPORT utp_stream public: typedef utp_stream lowest_layer_type; - typedef stream_socket::endpoint_type endpoint_type; - typedef stream_socket::protocol_type protocol_type; + typedef tcp::socket::endpoint_type endpoint_type; + typedef tcp::socket::protocol_type protocol_type; explicit utp_stream(io_service& io_service); ~utp_stream(); diff --git a/src/broadcast_socket.cpp b/src/broadcast_socket.cpp index 3d9a52d56..5daaa0b42 100644 --- a/src/broadcast_socket.cpp +++ b/src/broadcast_socket.cpp @@ -268,10 +268,10 @@ namespace libtorrent { using namespace boost::asio::ip::multicast; - boost::shared_ptr s(new datagram_socket(ios)); + boost::shared_ptr s(new udp::socket(ios)); s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec); if (ec) return; - s->set_option(datagram_socket::reuse_address(true), ec); + s->set_option(udp::socket::reuse_address(true), ec); if (ec) return; s->bind(udp::endpoint(addr, m_multicast_endpoint.port()), ec); if (ec) return; @@ -296,7 +296,7 @@ namespace libtorrent { using namespace boost::asio::ip::multicast; error_code ec; - boost::shared_ptr s(new datagram_socket(ios)); + boost::shared_ptr s(new udp::socket(ios)); s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec); if (ec) return; s->bind(udp::endpoint(addr, 0), ec); diff --git a/src/instantiate_connection.cpp b/src/instantiate_connection.cpp index 799ca69df..07180f002 100644 --- a/src/instantiate_connection.cpp +++ b/src/instantiate_connection.cpp @@ -82,12 +82,12 @@ namespace libtorrent #ifdef TORRENT_USE_OPENSSL if (ssl_context) { - s.instantiate >(ios, ssl_context); + s.instantiate >(ios, ssl_context); } else #endif { - s.instantiate(ios); + s.instantiate(ios); } } else if (ps.type == settings_pack::http diff --git a/src/session_impl.cpp b/src/session_impl.cpp index cd796ad6b..8f35ec301 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1144,11 +1144,11 @@ namespace aux { int snd_size = sett.get_int(settings_pack::send_socket_buffer_size); if (snd_size) { - stream_socket::send_buffer_size prev_option; + tcp::socket::send_buffer_size prev_option; s.get_option(prev_option, ec); if (!ec && prev_option.value() != snd_size) { - stream_socket::send_buffer_size option(snd_size); + tcp::socket::send_buffer_size option(snd_size); s.set_option(option, ec); if (ec) { @@ -1161,11 +1161,11 @@ namespace aux { int recv_size = sett.get_int(settings_pack::recv_socket_buffer_size); if (recv_size) { - stream_socket::receive_buffer_size prev_option; + tcp::socket::receive_buffer_size prev_option; s.get_option(prev_option, ec); if (!ec && prev_option.value() != recv_size) { - stream_socket::receive_buffer_size option(recv_size); + tcp::socket::receive_buffer_size option(recv_size); s.set_option(option, ec); if (ec) { @@ -1588,7 +1588,7 @@ namespace aux { int last_op = 0; listen_failed_alert::socket_type_t sock_type = (flags & open_ssl_socket) ? listen_failed_alert::tcp_ssl : listen_failed_alert::tcp; - ret.sock.reset(new socket_acceptor(m_io_service)); + ret.sock.reset(new tcp::acceptor(m_io_service)); ret.sock->open(ipv4 ? tcp::v4() : tcp::v6(), ec); last_op = listen_failed_alert::open; if (ec) @@ -1609,7 +1609,7 @@ namespace aux { // application. Don't do it! #ifndef TORRENT_WINDOWS error_code err; // ignore errors here - ret.sock->set_option(socket_acceptor::reuse_address(true), err); + ret.sock->set_option(tcp::acceptor::reuse_address(true), err); #endif #if TORRENT_USE_IPV6 @@ -2198,11 +2198,11 @@ retry: return false; } - void session_impl::async_accept(boost::shared_ptr const& listener, bool ssl) + void session_impl::async_accept(boost::shared_ptr const& listener, bool ssl) { TORRENT_ASSERT(!m_abort); shared_ptr c(new socket_type(m_io_service)); - stream_socket* str = 0; + tcp::socket* str = 0; #ifdef TORRENT_USE_OPENSSL if (ssl) @@ -2211,14 +2211,14 @@ retry: // use the generic m_ssl_ctx context. However, since it has // the servername callback set on it, we will switch away from // this context into a specific torrent once we start handshaking - c->instantiate >(m_io_service, &m_ssl_ctx); - str = &c->get >()->next_layer(); + c->instantiate >(m_io_service, &m_ssl_ctx); + str = &c->get >()->next_layer(); } else #endif { - c->instantiate(m_io_service); - str = c->get(); + c->instantiate(m_io_service); + str = c->get(); } #if defined TORRENT_ASIO_DEBUGGING @@ -2231,18 +2231,18 @@ retry: listener->async_accept(*str , boost::bind(&session_impl::on_accept_connection, this, c - , boost::weak_ptr(listener), _1, ssl)); + , boost::weak_ptr(listener), _1, ssl)); } void session_impl::on_accept_connection(shared_ptr const& s - , weak_ptr listen_socket, error_code const& e, bool ssl) + , weak_ptr listen_socket, error_code const& e, bool ssl) { #if defined TORRENT_ASIO_DEBUGGING complete_async("session_impl::on_accept_connection"); #endif m_stats_counters.inc_stats_counter(counters::on_accept_counter); TORRENT_ASSERT(is_single_thread()); - boost::shared_ptr listener = listen_socket.lock(); + boost::shared_ptr listener = listen_socket.lock(); if (!listener) return; if (e == boost::asio::error::operation_aborted) return; @@ -2322,7 +2322,7 @@ retry: #if defined TORRENT_ASIO_DEBUGGING add_outstanding_async("session_impl::ssl_handshake"); #endif - s->get >()->async_accept_handshake( + s->get >()->async_accept_handshake( boost::bind(&session_impl::ssl_handshake, this, _1, s)); m_incoming_sockets.insert(s); } @@ -2439,7 +2439,7 @@ retry: } if (!m_settings.get_bool(settings_pack::enable_incoming_tcp) - && s->get()) + && s->get()) { #ifndef TORRENT_DISABLE_LOGGING session_log(" rejected TCP connection"); @@ -4695,7 +4695,7 @@ retry: tcp::endpoint bind_ep(address_v4(), 0); if (m_settings.get_int(settings_pack::outgoing_port) > 0) { - s.set_option(socket_acceptor::reuse_address(true), ec); + s.set_option(tcp::acceptor::reuse_address(true), ec); // ignore errors because the underlying socket may not // be opened yet. This happens when we're routing through // a proxy. In that case, we don't yet know the address of diff --git a/src/socket_type.cpp b/src/socket_type.cpp index 1cbb95f34..edcd7bc6f 100644 --- a/src/socket_type.cpp +++ b/src/socket_type.cpp @@ -55,7 +55,7 @@ namespace libtorrent #define CASE(t) case socket_type_int_impl >::value: switch (s.type()) { - CASE(stream_socket) + CASE(tcp::socket) CASE(socks5_stream) CASE(http_stream) CASE(utp_stream) @@ -104,7 +104,7 @@ namespace libtorrent switch(s.type()) { - CASE(stream_socket) + CASE(tcp::socket) CASE(socks5_stream) CASE(http_stream) CASE(utp_stream) @@ -161,7 +161,7 @@ namespace libtorrent switch (s.type()) { - CASE(stream_socket) + CASE(tcp::socket) CASE(socks5_stream) CASE(http_stream) CASE(utp_stream) @@ -176,11 +176,12 @@ namespace libtorrent void socket_type::destruct() { + typedef tcp::socket tcp_socket; switch (m_type) { case 0: break; - case socket_type_int_impl::value: - get()->~stream_socket(); + case socket_type_int_impl::value: + get()->~tcp_socket(); break; case socket_type_int_impl::value: get()->~socks5_stream(); @@ -189,16 +190,16 @@ namespace libtorrent get()->~http_stream(); break; case socket_type_int_impl::value: - get()->~utp_stream(); - break; + get()->~utp_stream(); + break; #if TORRENT_USE_I2P case socket_type_int_impl::value: get()->~i2p_stream(); break; #endif #ifdef TORRENT_USE_OPENSSL - case socket_type_int_impl >::value: - get >()->~ssl_stream(); + case socket_type_int_impl >::value: + get >()->~ssl_stream(); break; case socket_type_int_impl >::value: get >()->~ssl_stream(); @@ -221,8 +222,8 @@ namespace libtorrent switch (type) { case 0: break; - case socket_type_int_impl::value: - new ((stream_socket*)m_data) stream_socket(m_io_service); + case socket_type_int_impl::value: + new ((tcp::socket*)m_data) tcp::socket(m_io_service); break; case socket_type_int_impl::value: new ((socks5_stream*)m_data) socks5_stream(m_io_service); @@ -239,9 +240,9 @@ namespace libtorrent break; #endif #ifdef TORRENT_USE_OPENSSL - case socket_type_int_impl >::value: + case socket_type_int_impl >::value: TORRENT_ASSERT(userdata); - new ((ssl_stream*)m_data) ssl_stream(m_io_service + new ((ssl_stream*)m_data) ssl_stream(m_io_service , *((boost::asio::ssl::context*)userdata)); break; case socket_type_int_impl >::value: diff --git a/src/torrent.cpp b/src/torrent.cpp index 45c6de032..f24789688 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -7420,7 +7420,7 @@ namespace libtorrent switch (s->type()) { - CASE(stream_socket) + CASE(tcp::socket) CASE(socks5_stream) CASE(http_stream) CASE(utp_stream) @@ -7625,7 +7625,7 @@ namespace libtorrent switch (s->type()) { - case SSL(stream_socket) + case SSL(tcp::socket) case SSL(socks5_stream) case SSL(http_stream) case SSL(utp_stream) diff --git a/src/utp_socket_manager.cpp b/src/utp_socket_manager.cpp index 39b009a50..65e114341 100644 --- a/src/utp_socket_manager.cpp +++ b/src/utp_socket_manager.cpp @@ -423,12 +423,12 @@ namespace libtorrent // only update the buffer size if it's bigger than // what we already have - datagram_socket::receive_buffer_size recv_buf_size_opt; + udp::socket::receive_buffer_size recv_buf_size_opt; m_sock.get_option(recv_buf_size_opt, ec); if (recv_buf_size_opt.value() < size * 10) { - m_sock.set_option(datagram_socket::receive_buffer_size(size * 10), ec); - m_sock.set_option(datagram_socket::send_buffer_size(size * 3), ec); + m_sock.set_option(udp::socket::receive_buffer_size(size * 10), ec); + m_sock.set_option(udp::socket::send_buffer_size(size * 3), ec); } m_sock_buf_size = size; } diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index dd440e07b..b04342a4f 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -73,7 +73,7 @@ void print_session_log(lt::session& ses) print_alerts(ses, "ses", true, true); } -int read_message(stream_socket& s, char* buffer, int max_size) +int read_message(tcp::socket& s, char* buffer, int max_size) { using namespace libtorrent::detail; error_code ec; @@ -151,7 +151,7 @@ void print_message(char const* buffer, int len) log("<== %s %s", message, extra); } -void send_allow_fast(stream_socket& s, int piece) +void send_allow_fast(tcp::socket& s, int piece) { log("==> allow fast: %d", piece); using namespace libtorrent::detail; @@ -164,7 +164,7 @@ void send_allow_fast(stream_socket& s, int piece) if (ec) TEST_ERROR(ec.message()); } -void send_suggest_piece(stream_socket& s, int piece) +void send_suggest_piece(tcp::socket& s, int piece) { log("==> suggest piece: %d", piece); using namespace libtorrent::detail; @@ -177,7 +177,7 @@ void send_suggest_piece(stream_socket& s, int piece) if (ec) TEST_ERROR(ec.message()); } -void send_keepalive(stream_socket& s) +void send_keepalive(tcp::socket& s) { log("==> keepalive"); char msg[] = "\0\0\0\0"; @@ -187,7 +187,7 @@ void send_keepalive(stream_socket& s) if (ec) TEST_ERROR(ec.message()); } -void send_unchoke(stream_socket& s) +void send_unchoke(tcp::socket& s) { log("==> unchoke"); char msg[] = "\0\0\0\x01\x01"; @@ -197,7 +197,7 @@ void send_unchoke(stream_socket& s) if (ec) TEST_ERROR(ec.message()); } -void send_have_all(stream_socket& s) +void send_have_all(tcp::socket& s) { log("==> have_all"); char msg[] = "\0\0\0\x01\x0e"; // have_all @@ -207,7 +207,7 @@ void send_have_all(stream_socket& s) if (ec) TEST_ERROR(ec.message()); } -void send_have_none(stream_socket& s) +void send_have_none(tcp::socket& s) { log("==> have_none"); char msg[] = "\0\0\0\x01\x0f"; // have_none @@ -217,7 +217,7 @@ void send_have_none(stream_socket& s) if (ec) TEST_ERROR(ec.message()); } -void send_bitfield(stream_socket& s, char const* bits) +void send_bitfield(tcp::socket& s, char const* bits) { using namespace libtorrent::detail; @@ -239,7 +239,7 @@ void send_bitfield(stream_socket& s, char const* bits) if (ec) TEST_ERROR(ec.message()); } -void do_handshake(stream_socket& s, sha1_hash const& ih, char* buffer) +void do_handshake(tcp::socket& s, sha1_hash const& ih, char* buffer) { char handshake[] = "\x13" "BitTorrent protocol\0\0\0\0\0\x10\0\x04" " " // space for info-hash @@ -285,7 +285,7 @@ void do_handshake(stream_socket& s, sha1_hash const& ih, char* buffer) TEST_CHECK(std::memcmp(buffer + 28, ih.begin(), 20) == 0); } -void send_extension_handshake(stream_socket& s, entry const& e) +void send_extension_handshake(tcp::socket& s, entry const& e) { std::vector buf; @@ -310,7 +310,7 @@ void send_extension_handshake(stream_socket& s, entry const& e) if (ec) TEST_ERROR(ec.message()); } -entry read_extension_handshake(stream_socket& s, char* recv_buffer, int size) +entry read_extension_handshake(tcp::socket& s, char* recv_buffer, int size) { for (;;) { @@ -332,7 +332,7 @@ entry read_extension_handshake(stream_socket& s, char* recv_buffer, int size) } } -void send_ut_metadata_msg(stream_socket& s, int ut_metadata_msg, int type, int piece) +void send_ut_metadata_msg(tcp::socket& s, int ut_metadata_msg, int type, int piece) { std::vector buf; @@ -362,7 +362,7 @@ void send_ut_metadata_msg(stream_socket& s, int ut_metadata_msg, int type, int p if (ec) TEST_ERROR(ec.message()); } -entry read_ut_metadata_msg(stream_socket& s, char* recv_buffer, int size) +entry read_ut_metadata_msg(tcp::socket& s, char* recv_buffer, int size) { for (;;) { @@ -384,7 +384,7 @@ entry read_ut_metadata_msg(stream_socket& s, char* recv_buffer, int size) } } -boost::shared_ptr setup_peer(stream_socket& s, sha1_hash& ih +boost::shared_ptr setup_peer(tcp::socket& s, sha1_hash& ih , boost::shared_ptr& ses, torrent_handle* th = NULL) { boost::shared_ptr t = ::create_torrent(); @@ -427,7 +427,7 @@ void test_reject_fast() sha1_hash ih; boost::shared_ptr ses; io_service ios; - stream_socket s(ios); + tcp::socket s(ios); setup_peer(s, ih, ses); char recv_buffer[1000]; @@ -495,7 +495,7 @@ void test_respect_suggest() sha1_hash ih; boost::shared_ptr ses; io_service ios; - stream_socket s(ios); + tcp::socket s(ios); setup_peer(s, ih, ses); char recv_buffer[1000]; @@ -573,7 +573,7 @@ void test_multiple_bitfields() sha1_hash ih; boost::shared_ptr ses; io_service ios; - stream_socket s(ios); + tcp::socket s(ios); boost::shared_ptr ti = setup_peer(s, ih, ses); print_session_log(*ses); @@ -607,7 +607,7 @@ void test_multiple_have_all() sha1_hash ih; boost::shared_ptr ses; io_service ios; - stream_socket s(ios); + tcp::socket s(ios); boost::shared_ptr ti = setup_peer(s, ih, ses); char recv_buffer[1000]; @@ -641,7 +641,7 @@ void test_dont_have() torrent_handle th; boost::shared_ptr ses; io_service ios; - stream_socket s(ios); + tcp::socket s(ios); boost::shared_ptr ti = setup_peer(s, ih, ses, &th); char recv_buffer[1000]; @@ -742,7 +742,7 @@ void test_invalid_metadata_requests() sha1_hash ih; boost::shared_ptr ses; io_service ios; - stream_socket s(ios); + tcp::socket s(ios); boost::shared_ptr ti = setup_peer(s, ih, ses); char recv_buffer[1000]; diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index 25a87f59a..50adfbde6 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -417,7 +417,7 @@ bool try_connect(libtorrent::session& ses1, int port } } - boost::asio::ssl::stream ssl_sock(ios, ctx); + boost::asio::ssl::stream ssl_sock(ios, ctx); fprintf(stderr, "connecting 127.0.0.1:%d\n", port); ssl_sock.lowest_layer().connect(tcp::endpoint(