1 // $Id: ConnectedRawINetSocketHandle.hh 597 2008-01-15 09:16:20Z g0dil $
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 CONNECTEDHH_SENF_Socket_Protocols_INet_RawINetSocketHandle_
24 #define CONNECTEDHH_SENF_Socket_Protocols_INet_RawINetSocketHandle_
27 #include "INetAddressing.hh"
28 #include "RawINetSocketProtocol.hh"
29 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
30 #include <senf/Socket/Protocols/DatagramSocketProtocol.hh>
31 #include <senf/Socket/FramingPolicy.hh>
32 #include <senf/Socket/CommunicationPolicy.hh>
33 #include <senf/Socket/ReadWritePolicy.hh>
34 #include <senf/Socket/ProtocolClientSocketHandle.hh>
37 ///////////////////////////////hh.p////////////////////////////////////////
41 /// \addtogroup concrete_protocol_group
44 typedef MakeSocketPolicy<
45 INet4AddressingPolicy,
46 DatagramFramingPolicy,
47 ConnectedCommunicationPolicy,
50 >::policy ConnectedRawV4Socket_Policy; ///< Socket Policy of the Connected RawV4 Protocol
52 /** \brief IPv4 RAW Socket Protocol, connected
54 \par Socket Handle typedefs:
55 \ref ConnectedRawV4ClientSocketHandle (ProtocolClientSocketHandle)
57 \par Policy Interface:
58 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
59 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
64 ConnectedRawV4SocketProtocol provides an Internet protocol raw socket based on IPv4 addressing.
65 This socket will put data written to it onto the IPv4 layer: if you call writeto don't include
67 On the other hand `read` will return the packet data including the IP header.
68 This behaviour is strange and differs from the behaviour of IPv6 RAW sockets and should be
69 changed in the future.
71 This class is utilized as the protocol class of the ProtocolClientSocketHandle
72 via the Socket Handle typedefs above.
75 If socket handle with ConnectedRawV4SocketProtocol is connected via INet4SocketAddress, the port number
76 is interpreted as protocol number for IPv4 layer. Please refer manpage: "man 7 raw".
78 \see ConnectedRawV6SocketProtocol
79 \see RawV4SocketProtocol
80 \see RawV6SocketProtocol
82 class ConnectedRawV4SocketProtocol
83 : public ConcreteSocketProtocol<ConnectedRawV4Socket_Policy, ConnectedRawV4SocketProtocol>,
84 public RawINetSocketProtocol,
85 public BSDSocketProtocol,
86 public DatagramSocketProtocol,
87 public AddressableBSDSocketProtocol
90 ///////////////////////////////////////////////////////////////////////////
96 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
97 /**< \note This member is implicitly called from the
98 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
100 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
102 void init_client(int const & protocol, INet4SocketAddress const & address) const;
103 ///< Create client socket and connect
104 /**< Creates a new client socket for the given protocol and connects to the given
106 \param[in] protocol Layer 4 protocol to filter for / to send
107 \param[in] address local address to connect to */
112 typedef ProtocolClientSocketHandle<ConnectedRawV4SocketProtocol> ConnectedRawV4ClientSocketHandle;
117 //////////////////////////////////////////////////////////////////// Raw IPv6 Socket //////////////////////////////////////
118 typedef MakeSocketPolicy<
119 INet6AddressingPolicy,
120 DatagramFramingPolicy,
121 ConnectedCommunicationPolicy,
124 >::policy ConnectedRawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
126 /** \brief IPv6 RAW Socket Protocol, connected
128 \par Socket Handle typedefs:
129 \ref ConnectedRawV6ClientSocketHandle (ProtocolClientSocketHandle)
131 \par Policy Interface:
132 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
133 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
138 ConnectedRawV6SocketProtocol provides an internet protocol raw socket based on IPv6 addressing which is connected to certain peer.
139 This socket will put data written to it onto the IPv6 layer: if you call writeto don't inlude the header!
140 On the other hand `read` will return the packet data on top of the IPv6 layer, excluding the IP header.
141 Note: This behaviour is differs from the behaviour of IPv4 RAW sockets.
143 This class is utilized as the protocol class of the ProtocolClientSocketHandle
144 via the Socket Handle typedefs above.
147 If socket handle with ConnectedRawV6SocketProtocol is connected via INet6SocketAddress, the port number
148 is interpreted as protocol number for IPv6 layer. Please refer manpage: "man 7 ipv6".
150 \see ConnectedRawV4SocketProtocol
151 \see RawV4SocketProtocol
152 \see RawV6SocketProtocol
154 class ConnectedRawV6SocketProtocol
155 : public ConcreteSocketProtocol<ConnectedRawV6Socket_Policy, ConnectedRawV6SocketProtocol>,
156 public RawINetSocketProtocol,
157 public BSDSocketProtocol,
158 public DatagramSocketProtocol,
159 public AddressableBSDSocketProtocol
162 ///////////////////////////////////////////////////////////////////////////
163 // internal interface
165 ///\name Constructors
168 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
169 /**< \note This member is implicitly called from the
170 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
173 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
175 void init_client(int const & protocol, INet6SocketAddress const & address) const;
176 ///< Create client socket and connect
177 /**< Creates a new client socket for the given protocol and connects to the given
179 \param[in] protocol Layer 4 protocol to filter for / to send
180 \param[in] address local address to connect to */
181 /**< \note This member is implicitly called from the
182 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
188 typedef ProtocolClientSocketHandle<ConnectedRawV6SocketProtocol> ConnectedRawV6ClientSocketHandle;
194 #endif /*CONNECTEDHH_SENF_Socket_Protocols_INet_RawINetSocketHandle_*/