2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum NETwork research (NET)
4 // David Wagner <david.wagner@fokus.fraunhofer.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef RAWINETSOCKETHANDLE_HH_
22 #define RAWINETSOCKETHANDLE_HH_
26 #include "INetProtocol.hh"
27 #include "RawInetProtocol.hh"
28 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
29 #include "../../../Socket/FramingPolicy.hh"
30 #include "../../../Socket/CommunicationPolicy.hh"
31 #include "../../../Socket/ReadWritePolicy.hh"
32 #include "../../../Socket/BufferingPolicy.hh"
33 #include "../../../Socket/ProtocolClientSocketHandle.hh"
36 ///////////////////////////////hh.p////////////////////////////////////////
40 /// \addtogroup concrete_protocol_group
43 typedef MakeSocketPolicy<
44 INet4AddressingPolicy,
45 DatagramFramingPolicy,
46 UnconnectedCommunicationPolicy,
50 >::policy RawV4Socket_Policy; ///< Socket Policy of the RawV4 Protocol
52 /** \brief IPv4 RAW Socket Protocol
54 \par Socket Handle typedefs:
55 \ref RawV4ClientSocketHandle (ProtocolClientSocketHandle)
57 \par Policy Interface:
58 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
59 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
60 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
65 RawV4SocketProtocol provides an internet protocol raw socket based on IPv4 addressing.
66 This socket will put data written to it onto the IPv4 layer: if you call writeto don't inlude the header!
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 changed in the future.
70 This class is utilized as the protocol class of the ProtocolClientSocketHandle
71 via the Socket Handle typedefs above.
73 \see RawV6SocketProtocol
75 class RawV4SocketProtocol
76 : public ConcreteSocketProtocol<RawV4Socket_Policy>,
78 public RawInetProtocol,
79 public BSDSocketProtocol,
80 public AddressableBSDSocketProtocol//,
81 // public senf::pool_alloc_mixin<RawV4Socket_Policy>
84 ///////////////////////////////////////////////////////////////////////////
90 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
91 /**< \note This member is implicitly called from the
92 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
94 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
96 void init_client(int const & protocol, INet4SocketAddress const & address) const;
97 ///< Create client socket and bind
98 /**< Creates a new client socket for the given protocol and binds to the given
100 \param[in] protocol Layer 4 protocol to filter for / to send
101 \param[in] address local address to bind to */
104 ///\name Abstract Interface Implementation
106 std::auto_ptr<SocketProtocol> clone() const;
111 typedef ProtocolClientSocketHandle<RawV4SocketProtocol> RawV4ClientSocketHandle;
116 //////////////////////////////////////////////////////////////////// Raw IPv6 Socket //////////////////////////////////////
117 typedef MakeSocketPolicy<
118 INet6AddressingPolicy,
119 DatagramFramingPolicy,
120 UnconnectedCommunicationPolicy,
123 SocketBufferingPolicy
124 >::policy RawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
126 /** \brief IPv6 RAW Socket Protocol
128 \par Socket Handle typedefs:
129 \ref RawV6ClientSocketHandle (ProtocolClientSocketHandle)
131 \par Policy Interface:
132 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
133 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
134 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
139 RawV6SocketProtocol provides an internet protocol raw socket based on IPv6 addressing.
140 This socket will put data written to it onto the IPv6 layer: if you call writeto don't inlude the header!
141 On the other hand `read` will return the packet data on top of the IPv6 layer, excluding the IP header.
142 Note: This behaviour is differs from the behaviour of IPv4 RAW sockets.
144 This class is utilized as the protocol class of the ProtocolClientSocketHandle
145 via the Socket Handle typedefs above.
147 \see RawV4SocketProtocol
149 class RawV6SocketProtocol
150 : public ConcreteSocketProtocol<RawV6Socket_Policy>,
152 public RawInetProtocol,
153 public BSDSocketProtocol,
154 public AddressableBSDSocketProtocol//,
155 // public senf::pool_alloc_mixin<RawV6SocketProtocol>
158 ///////////////////////////////////////////////////////////////////////////
159 // internal interface
161 ///\name Constructors
164 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
165 /**< \note This member is implicitly called from the
166 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
169 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
171 void init_client(int const & protocol, INet6SocketAddress const & address) const;
172 ///< Create client socket and bind
173 /**< Creates a new client socket for the given protocol and binds to the given
175 \param[in] protocol Layer 4 protocol to filter for / to send
176 \param[in] address local address to bind to */
177 /**< \note This member is implicitly called from the
178 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
182 ///\name Abstract Interface Implementation
184 std::auto_ptr<SocketProtocol> clone() const;
189 typedef ProtocolClientSocketHandle<RawV6SocketProtocol> RawV6ClientSocketHandle;
195 #endif /*RAWINETSOCKETHANDLE_HH_*/