1 // $Id: RawINetSocketHandle.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>
29 #ifndef HH_SENF_Socket_Protocols_INet_RawINetSocketHandle_
30 #define HH_SENF_Socket_Protocols_INet_RawINetSocketHandle_
34 #include "INetAddressing.hh"
35 #include "RawINetSocketProtocol.hh"
36 #include "MulticastSocketProtocol.hh"
37 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
38 #include <senf/Socket/Protocols/DatagramSocketProtocol.hh>
39 #include <senf/Socket/FramingPolicy.hh>
40 #include <senf/Socket/CommunicationPolicy.hh>
41 #include <senf/Socket/ReadWritePolicy.hh>
42 #include <senf/Socket/ProtocolClientSocketHandle.hh>
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
49 /// \addtogroup concrete_protocol_group
52 typedef MakeSocketPolicy<
53 INet4AddressingPolicy,
54 DatagramFramingPolicy,
55 UnconnectedCommunicationPolicy,
58 >::policy RawV4Socket_Policy; ///< Socket Policy of the RawV4 Protocol
60 /** \brief IPv4 RAW Socket Protocol
62 \par Socket Handle typedefs:
63 \ref RawV4ClientSocketHandle (ProtocolClientSocketHandle)
65 \par Policy Interface:
66 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
67 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local()
72 RawV4SocketProtocol provides an internet protocol raw socket based on IPv4 addressing.
73 This socket will put data written to it onto the IPv4 layer: if you call writeto don't include the header!
74 On the other hand `read` will return the packet data including the IP header.
75 This behaviour is strange and differs from the behaviour of IPv6 RAW sockets and should be changed in the future.
77 This class is utilized as the protocol class of the ProtocolClientSocketHandle
78 via the Socket Handle typedefs above.
81 If socket handle with RawV4SocketProtocol is connected via INet4SocketAddress, the port number
82 is interpreted as protocol number for IPv4 layer. Please refer manpage: "man 7 raw".
84 \see RawV6SocketProtocol
86 class RawV4SocketProtocol
87 : public ConcreteSocketProtocol<RawV4Socket_Policy, RawV4SocketProtocol>,
88 public RawINetSocketProtocol,
89 public BSDSocketProtocol,
90 public AddressableBSDSocketProtocol,
91 public DatagramSocketProtocol,
92 public INet4MulticastSocketProtocol
95 //-////////////////////////////////////////////////////////////////////////
101 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
102 /**< \note This member is implicitly called from the
103 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
105 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
107 void init_client(int const & protocol, INet4SocketAddress const & address) const;
108 ///< Create client socket and bind
109 /**< Creates a new client socket for the given protocol and binds to the given
111 \param[in] protocol Layer 4 protocol to filter for / to send
112 \param[in] address local address to bind to */
117 typedef ProtocolClientSocketHandle<RawV4SocketProtocol> RawV4ClientSocketHandle;
122 //-/////////////////////////////////////////////////////////////////////////////////////////////////
123 typedef MakeSocketPolicy<
124 INet6AddressingPolicy,
125 DatagramFramingPolicy,
126 UnconnectedCommunicationPolicy,
129 >::policy RawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
131 /** \brief IPv6 RAW Socket Protocol
133 \par Socket Handle typedefs:
134 \ref RawV6ClientSocketHandle (ProtocolClientSocketHandle)
136 \par Policy Interface:
137 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
138 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local()
143 RawV6SocketProtocol provides an internet protocol raw socket based on IPv6 addressing.
144 This socket will put data written to it onto the IPv6 layer: if you call writeto don't include the header!
145 On the other hand `read` will return the packet data on top of the IPv6 layer, excluding the IP header.
146 Note: This behaviour is differs from the behaviour of IPv4 RAW sockets.
148 This class is utilized as the protocol class of the ProtocolClientSocketHandle
149 via the Socket Handle typedefs above.
152 If socket handle with ConnectedRawV6SocketProtocol is connected via INet6SocketAddress, the port number
153 is interpreted as protocol number for IPv6 layer. Please refer manpage: "man 7 ipv6".
155 \see RawV4SocketProtocol
157 class RawV6SocketProtocol
158 : public ConcreteSocketProtocol<RawV6Socket_Policy,RawV6SocketProtocol>,
159 public RawINetSocketProtocol,
160 public BSDSocketProtocol,
161 public AddressableBSDSocketProtocol,
162 public DatagramSocketProtocol,
163 public INet6MulticastSocketProtocol
166 //-////////////////////////////////////////////////////////////////////////
167 // internal interface
169 ///\name Constructors
172 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
173 /**< \note This member is implicitly called from the
174 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
177 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
179 void init_client(int const & protocol, INet6SocketAddress const & address) const;
180 ///< Create client socket and bind
181 /**< Creates a new client socket for the given protocol and binds to the given
183 \param[in] protocol Layer 4 protocol to filter for / to send
184 \param[in] address local address to bind to */
185 /**< \note This member is implicitly called from the
186 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
192 typedef ProtocolClientSocketHandle<RawV6SocketProtocol> RawV6ClientSocketHandle;
198 #endif /*HH_SENF_Socket_Protocols_INet_RawINetSocketHandle_*/