1 // $Id: ConnectedRawINetSocketHandle.hh 597 2008-01-15 09:16:20Z g0dil $
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // David Wagner <dw6@berlios.de>
28 #ifndef CONNECTEDHH_SENF_Socket_Protocols_INet_RawINetSocketHandle_
29 #define CONNECTEDHH_SENF_Socket_Protocols_INet_RawINetSocketHandle_
32 #include "INetAddressing.hh"
33 #include "RawINetSocketProtocol.hh"
34 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
35 #include <senf/Socket/Protocols/DatagramSocketProtocol.hh>
36 #include <senf/Socket/FramingPolicy.hh>
37 #include <senf/Socket/CommunicationPolicy.hh>
38 #include <senf/Socket/ReadWritePolicy.hh>
39 #include <senf/Socket/ProtocolClientSocketHandle.hh>
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 /// \addtogroup concrete_protocol_group
49 typedef MakeSocketPolicy<
50 INet4AddressingPolicy,
51 DatagramFramingPolicy,
52 ConnectedCommunicationPolicy,
55 >::policy ConnectedRawV4Socket_Policy; ///< Socket Policy of the Connected RawV4 Protocol
57 /** \brief IPv4 RAW Socket Protocol, connected
59 \par Socket Handle typedefs:
60 \ref ConnectedRawV4ClientSocketHandle (ProtocolClientSocketHandle)
62 \par Policy Interface:
63 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
64 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
69 ConnectedRawV4SocketProtocol provides an Internet protocol raw socket based on IPv4
70 addressing. This socket will put data written to it onto the IPv4 layer: if you call
71 writeto don't include the header!
73 On the other hand `read` will return the packet data including the IP header.
74 This behaviour is strange and differs from the behaviour of IPv6 RAW sockets and should be
75 changed in the future.
77 This class is utilized as the protocol class of the ProtocolClientSocketHandle
78 via the Socket Handle typedefs above.
80 \attention If socket handle with ConnectedRawV4SocketProtocol is connected via
81 INet4SocketAddress, the port number is interpreted as protocol number for IPv4
82 layer. Please refer manpage: "man 7 raw".
84 \see ConnectedRawV6SocketProtocol
85 \see RawV4SocketProtocol
86 \see RawV6SocketProtocol
88 class ConnectedRawV4SocketProtocol
89 : public ConcreteSocketProtocol<ConnectedRawV4Socket_Policy, ConnectedRawV4SocketProtocol>,
90 public RawINetSocketProtocol,
91 public BSDSocketProtocol,
92 public DatagramSocketProtocol,
93 public AddressableBSDSocketProtocol
96 //-////////////////////////////////////////////////////////////////////////
102 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
103 /**< \note This member is implicitly called from the
104 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
106 void init_client(int const & protocol) const;
107 ///< Create unconnected client socket for protocol
109 void init_client(int const & protocol, INet4SocketAddress const & address) const;
110 ///< Create client socket and connect
111 /**< Creates a new client socket for the given protocol and
112 connects to the given address.
113 \param[in] protocol Layer 4 protocol to filter for / to
115 \param[in] address local address to connect to */
120 typedef ProtocolClientSocketHandle<ConnectedRawV4SocketProtocol>
121 ConnectedRawV4ClientSocketHandle;
126 //-/////////////////////////////////////////////////////////////////////////////////////////////////
127 typedef MakeSocketPolicy<
128 INet6AddressingPolicy,
129 DatagramFramingPolicy,
130 ConnectedCommunicationPolicy,
133 >::policy ConnectedRawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
135 /** \brief IPv6 RAW Socket Protocol, connected
137 \par Socket Handle typedefs:
138 \ref ConnectedRawV6ClientSocketHandle (ProtocolClientSocketHandle)
140 \par Policy Interface:
141 ClientSocketHandle::read(), ClientSocketHandle::write(), ClientSocketHandle::bind(),
142 ClientSocketHandle::local(), ClientSocketHandle::connect(), ClientSocketHandle::peer()
147 ConnectedRawV6SocketProtocol provides an internet protocol raw socket based on IPv6
148 addressing which is connected to certain peer. This socket will put data written to it onto
149 the IPv6 layer: if you call writeto don't include the header! On the other hand `read` will
150 return the packet data on top of the IPv6 layer, excluding the IP header. Note: This
151 behaviour is differs from the behaviour of IPv4 RAW sockets.
153 This class is utilized as the protocol class of the ProtocolClientSocketHandle
154 via the Socket Handle typedefs above.
156 \attention If socket handle with ConnectedRawV6SocketProtocol is connected via
157 INet6SocketAddress, the port number is interpreted as protocol number for IPv6
158 layer. Please refer manpage: "man 7 ipv6".
160 \see ConnectedRawV4SocketProtocol
161 \see RawV4SocketProtocol
162 \see RawV6SocketProtocol
164 class ConnectedRawV6SocketProtocol
165 : public ConcreteSocketProtocol<ConnectedRawV6Socket_Policy, ConnectedRawV6SocketProtocol>,
166 public RawINetSocketProtocol,
167 public BSDSocketProtocol,
168 public DatagramSocketProtocol,
169 public AddressableBSDSocketProtocol
172 //-////////////////////////////////////////////////////////////////////////
173 // internal interface
175 ///\name Constructors
178 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
179 /**< \note This member is implicitly called from the
180 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
183 void init_client(int const & protocol) const;
184 ///< Create unconnected client socket for protocol
186 void init_client(int const & protocol, INet6SocketAddress const & address) const;
187 ///< Create client socket and connect
188 /**< Creates a new client socket for the given protocol and
189 connects to the given address.
190 \param[in] protocol Layer 4 protocol to filter for / to
192 \param[in] address local address to connect to
193 \note This member is implicitly called from the //
194 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
200 typedef ProtocolClientSocketHandle<ConnectedRawV6SocketProtocol>
201 ConnectedRawV6ClientSocketHandle;
207 #endif /*CONNECTEDHH_SENF_Socket_Protocols_INet_RawINetSocketHandle_*/
213 // c-file-style: "senf"
214 // indent-tabs-mode: nil
215 // ispell-local-dictionary: "american"
216 // compile-command: "scons -u test"
217 // comment-column: 40