4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // David Wagner <dw6@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #ifndef CONNECTEDRAWINETSOCKETHANDLE_HH_
24 #define CONNECTEDRAWINETSOCKETHANDLE_HH_
27 #include "INetProtocol.hh"
28 #include "RawInetProtocol.hh"
29 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
30 #include "../../../Socket/FramingPolicy.hh"
31 #include "../../../Socket/CommunicationPolicy.hh"
32 #include "../../../Socket/ReadWritePolicy.hh"
33 #include "../../../Socket/BufferingPolicy.hh"
34 #include "../../../Socket/ProtocolClientSocketHandle.hh"
37 ///////////////////////////////hh.p////////////////////////////////////////
41 /// \addtogroup concrete_protocol_group
44 typedef MakeSocketPolicy<
45 INet4AddressingPolicy,
46 DatagramFramingPolicy,
47 ConnectedCommunicationPolicy,
51 >::policy ConnectedRawV4Socket_Policy; ///< Socket Policy of the Connected RawV4 Protocol
53 /** \brief IPv4 RAW Socket Protocol, connected
55 \par Socket Handle typedefs:
56 \ref ConnectedRawV4ClientSocketHandle (ProtocolClientSocketHandle)
58 \par Policy Interface:
59 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
60 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
61 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
66 ConnectedRawV4SocketProtocol provides an internet protocol raw socket based on IPv4 addressing.
67 This socket will put data written to it onto the IPv4 layer: if you call writeto don't inlude the header!
68 On the other hand `read` will return the packet data including the IP header.
69 This behaviour is strange and differs from the behaviour of IPv6 RAW sockets and should be changed in the future.
71 This class is utilized as the protocol class of the ProtocolClientSocketHandle
72 via the Socket Handle typedefs above.
74 \see ConnectedRawV6SocketProtocol
75 \see RawV4SocketProtocol
76 \see RawV6SocketProtocol
78 class ConnectedRawV4SocketProtocol
79 : public ConcreteSocketProtocol<ConnectedRawV4Socket_Policy>,
81 public RawInetProtocol,
82 public BSDSocketProtocol,
83 public AddressableBSDSocketProtocol//,
84 // public senf::pool_alloc_mixin<RawV4Socket_Policy>
87 ///////////////////////////////////////////////////////////////////////////
93 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
94 /**< \note This member is implicitly called from the
95 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
97 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
99 void init_client(int const & protocol, INet4SocketAddress const & address) const;
100 ///< Create client socket and connect
101 /**< Creates a new client socket for the given protocol and connects to the given
103 \param[in] protocol Layer 4 protocol to filter for / to send
104 \param[in] address local address to connect to */
107 ///\name Abstract Interface Implementation
109 std::auto_ptr<SocketProtocol> clone() const;
114 typedef ProtocolClientSocketHandle<ConnectedRawV4SocketProtocol> ConnectedRawV4ClientSocketHandle;
119 //////////////////////////////////////////////////////////////////// Raw IPv6 Socket //////////////////////////////////////
120 typedef MakeSocketPolicy<
121 INet6AddressingPolicy,
122 DatagramFramingPolicy,
123 ConnectedCommunicationPolicy,
126 SocketBufferingPolicy
127 >::policy ConnectedRawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
129 /** \brief IPv6 RAW Socket Protocol, connected
131 \par Socket Handle typedefs:
132 \ref ConnectedRawV6ClientSocketHandle (ProtocolClientSocketHandle)
134 \par Policy Interface:
135 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
136 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer(),
137 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
142 ConnectedRawV6SocketProtocol provides an internet protocol raw socket based on IPv6 addressing which is connected to certain peer.
143 This socket will put data written to it onto the IPv6 layer: if you call writeto don't inlude the header!
144 On the other hand `read` will return the packet data on top of the IPv6 layer, excluding the IP header.
145 Note: This behaviour is differs from the behaviour of IPv4 RAW sockets.
147 This class is utilized as the protocol class of the ProtocolClientSocketHandle
148 via the Socket Handle typedefs above.
150 \see ConnectedRawV4SocketProtocol
151 \see RawV4SocketProtocol
152 \see RawV6SocketProtocol
154 class ConnectedRawV6SocketProtocol
155 : public ConcreteSocketProtocol<ConnectedRawV6Socket_Policy>,
157 public RawInetProtocol,
158 public BSDSocketProtocol,
159 public AddressableBSDSocketProtocol//,
160 // public senf::pool_alloc_mixin<RawV6SocketProtocol>
163 ///////////////////////////////////////////////////////////////////////////
164 // internal interface
166 ///\name Constructors
169 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
170 /**< \note This member is implicitly called from the
171 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
174 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
176 void init_client(int const & protocol, INet6SocketAddress const & address) const;
177 ///< Create client socket and connect
178 /**< Creates a new client socket for the given protocol and connects to the given
180 \param[in] protocol Layer 4 protocol to filter for / to send
181 \param[in] address local address to connect to */
182 /**< \note This member is implicitly called from the
183 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
187 ///\name Abstract Interface Implementation
189 std::auto_ptr<SocketProtocol> clone() const;
194 typedef ProtocolClientSocketHandle<ConnectedRawV6SocketProtocol> ConnectedRawV6ClientSocketHandle;
200 #endif /*CONNECTEDRAWINETSOCKETHANDLE_HH_*/