From 54670f26d097cb7999dc4bdc5a058b51ae5c97bf Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Sat, 9 Jul 2011 23:33:29 -0300 Subject: [PATCH] Bring aboard a aternative version of Boost's TCP protocol - This version allows low level socket manipulation of TCP segments, whereas the SOCK_STREAM doesn't allow. --- .../boost/asio/ip/tcp_raw_protocol.hpp | 123 ++++++++++++++++++++ 1 files changed, 123 insertions(+), 0 deletions(-) create mode 100644 lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp diff --git a/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp b/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp new file mode 100644 index 0000000..68fc07c --- /dev/null +++ b/lib/boost-custom/boost/asio/ip/tcp_raw_protocol.hpp @@ -0,0 +1,123 @@ +// +// tcp_raw_protocol.hpp +// ~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Modified by Guilherme M. Ferreira +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef TCP_RAW_PROTOCOL +#define TCP_RAW_PROTOCOL + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace boost { +namespace asio { +namespace ip { + +class tcp_raw_protocol +{ +public: + /// The type of a TCP endpoint. + typedef basic_endpoint< tcp_raw_protocol > endpoint; + + /// (Deprecated: use resolver::query.) The type of a resolver query. + typedef basic_resolver_query< tcp_raw_protocol > resolver_query; + + /// (Deprecated: use resolver::iterator.) The type of a resolver iterator. + typedef basic_resolver_iterator< tcp_raw_protocol > resolver_iterator; + + /// Construct to represent the IPv4 TCP protocol. + static tcp_raw_protocol v4() + { + return tcp_raw_protocol( PF_INET ); + } + + /// Construct to represent the IPv6 TCP protocol. + static tcp_raw_protocol v6() + { + return tcp_raw_protocol( PF_INET6 ); + } + + /// Obtain an identifier for the type of the protocol. + /// Instead of returning the TCP's SOCK_STREAM, it returns the SOCK_RAW, + /// thus allowing a low level TCP management. + int type() const + { + return SOCK_RAW; + } + + /// Obtain an identifier for the protocol. + int protocol() const + { + return IPPROTO_TCP; + } + + /// Obtain an identifier for the protocol family. + int family() const + { + return family_; + } + + /// The TCP socket type. + typedef basic_stream_socket< tcp_raw_protocol > socket; + + /// The TCP acceptor type. + typedef basic_socket_acceptor< tcp_raw_protocol > acceptor; + + /// The TCP resolver type. + typedef basic_resolver< tcp_raw_protocol > resolver; + +#if !defined(BOOST_NO_IOSTREAM) + /// The TCP iostream type. + typedef basic_socket_iostream< tcp_raw_protocol > iostream; +#endif // !defined(BOOST_NO_IOSTREAM) + /// Socket option for disabling the Nagle algorithm. +#if defined(GENERATING_DOCUMENTATION) + typedef implementation_defined no_delay; +#else + typedef boost::asio::detail::socket_option::boolean< IPPROTO_TCP, + TCP_NODELAY > no_delay; +#endif + + /// Compare two protocols for equality. + friend bool operator==( const tcp_raw_protocol& p1, const tcp_raw_protocol& p2 ) + { + return p1.family_ == p2.family_; + } + + /// Compare two protocols for inequality. + friend bool operator!=( const tcp_raw_protocol& p1, const tcp_raw_protocol& p2 ) + { + return p1.family_ != p2.family_; + } + +private: + // Construct with a specific family. + explicit tcp_raw_protocol( int family ) : + family_( family ) + { + } + + int family_; +}; + +} // namespace ip +} // namespace asio +} // namespace boost + +#endif /* TCP_RAW_PROTOCOL */ -- 1.7.1