4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Kompetenzzentrum NETwork research (NET)
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 RAWINETSOCKETHANDLE_HH_
24 #define RAWINETSOCKETHANDLE_HH_
28 #include "INetProtocol.hh"
29 #include "RawInetProtocol.hh"
30 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
31 #include "../../../Socket/FramingPolicy.hh"
32 #include "../../../Socket/CommunicationPolicy.hh"
33 #include "../../../Socket/ReadWritePolicy.hh"
34 #include "../../../Socket/BufferingPolicy.hh"
35 #include "../../../Socket/ProtocolClientSocketHandle.hh"
38 ///////////////////////////////hh.p////////////////////////////////////////
42 /// \addtogroup concrete_protocol_group
45 typedef MakeSocketPolicy<
46 INet4AddressingPolicy,
47 DatagramFramingPolicy,
48 UnconnectedCommunicationPolicy,
52 >::policy RawV4Socket_Policy; ///< Socket Policy of the RawV4 Protocol
54 /** \brief IPv4 RAW Socket Protocol
56 \par Socket Handle typedefs:
57 \ref RawV4ClientSocketHandle (ProtocolClientSocketHandle)
59 \par Policy Interface:
60 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
61 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
62 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
67 RawV4SocketProtocol provides an internet protocol raw socket based on IPv4 addressing.
68 This socket will put data written to it onto the IPv4 layer: if you call writeto don't inlude the header!
69 On the other hand `read` will return the packet data including the IP header.
70 This behaviour is strange and differs from the behaviour of IPv6 RAW sockets and should be changed in the future.
72 This class is utilized as the protocol class of the ProtocolClientSocketHandle
73 via the Socket Handle typedefs above.
75 \see RawV6SocketProtocol
77 class RawV4SocketProtocol
78 : public ConcreteSocketProtocol<RawV4Socket_Policy>,
80 public RawInetProtocol,
81 public BSDSocketProtocol,
82 public AddressableBSDSocketProtocol//,
83 // public senf::pool_alloc_mixin<RawV4Socket_Policy>
86 ///////////////////////////////////////////////////////////////////////////
92 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
93 /**< \note This member is implicitly called from the
94 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
96 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
98 void init_client(int const & protocol, INet4SocketAddress const & address) const;
99 ///< Create client socket and bind
100 /**< Creates a new client socket for the given protocol and binds to the given
102 \param[in] protocol Layer 4 protocol to filter for / to send
103 \param[in] address local address to bind to */
106 ///\name Abstract Interface Implementation
108 std::auto_ptr<SocketProtocol> clone() const;
113 typedef ProtocolClientSocketHandle<RawV4SocketProtocol> RawV4ClientSocketHandle;
118 //////////////////////////////////////////////////////////////////// Raw IPv6 Socket //////////////////////////////////////
119 typedef MakeSocketPolicy<
120 INet6AddressingPolicy,
121 DatagramFramingPolicy,
122 UnconnectedCommunicationPolicy,
125 SocketBufferingPolicy
126 >::policy RawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
128 /** \brief IPv6 RAW Socket Protocol
130 \par Socket Handle typedefs:
131 \ref RawV6ClientSocketHandle (ProtocolClientSocketHandle)
133 \par Policy Interface:
134 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
135 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
136 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
141 RawV6SocketProtocol provides an internet protocol raw socket based on IPv6 addressing.
142 This socket will put data written to it onto the IPv6 layer: if you call writeto don't inlude the header!
143 On the other hand `read` will return the packet data on top of the IPv6 layer, excluding the IP header.
144 Note: This behaviour is differs from the behaviour of IPv4 RAW sockets.
146 This class is utilized as the protocol class of the ProtocolClientSocketHandle
147 via the Socket Handle typedefs above.
149 \see RawV4SocketProtocol
151 class RawV6SocketProtocol
152 : public ConcreteSocketProtocol<RawV6Socket_Policy>,
154 public RawInetProtocol,
155 public BSDSocketProtocol,
156 public AddressableBSDSocketProtocol//,
157 // public senf::pool_alloc_mixin<RawV6SocketProtocol>
160 ///////////////////////////////////////////////////////////////////////////
161 // internal interface
163 ///\name Constructors
166 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
167 /**< \note This member is implicitly called from the
168 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
171 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
173 void init_client(int const & protocol, INet6SocketAddress const & address) const;
174 ///< Create client socket and bind
175 /**< Creates a new client socket for the given protocol and binds to the given
177 \param[in] protocol Layer 4 protocol to filter for / to send
178 \param[in] address local address to bind to */
179 /**< \note This member is implicitly called from the
180 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
184 ///\name Abstract Interface Implementation
186 std::auto_ptr<SocketProtocol> clone() const;
191 typedef ProtocolClientSocketHandle<RawV6SocketProtocol> RawV6ClientSocketHandle;
197 #endif /*RAWINETSOCKETHANDLE_HH_*/