1 // $Id: RawINetSocketHandle.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 RAWINETSOCKETHANDLE_HH_
24 #define RAWINETSOCKETHANDLE_HH_
28 #include "INetProtocol.hh"
29 #include "RawINetProtocol.hh"
30 #include "MulticastProtocol.hh"
31 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
32 #include "../../../Socket/FramingPolicy.hh"
33 #include "../../../Socket/CommunicationPolicy.hh"
34 #include "../../../Socket/ReadWritePolicy.hh"
35 #include "../../../Socket/ProtocolClientSocketHandle.hh"
38 ///////////////////////////////hh.p////////////////////////////////////////
42 /// \addtogroup concrete_protocol_group
45 typedef MakeSocketPolicy<
46 INet4AddressingPolicy,
47 DatagramFramingPolicy,
48 UnconnectedCommunicationPolicy,
51 >::policy RawV4Socket_Policy; ///< Socket Policy of the RawV4 Protocol
53 /** \brief IPv4 RAW Socket Protocol
55 \par Socket Handle typedefs:
56 \ref RawV4ClientSocketHandle (ProtocolClientSocketHandle)
58 \par Policy Interface:
59 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
60 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
61 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
66 RawV4SocketProtocol provides an internet protocol raw socket based on IPv4 addressing.
67 This socket will put data written to it onto the IPv4 layer: if you call writeto don't inlude the header!
68 On the other hand `read` will return the packet data including the IP header.
69 This behaviour is strange and differs from the behaviour of IPv6 RAW sockets and should be changed in the future.
71 This class is utilized as the protocol class of the ProtocolClientSocketHandle
72 via the Socket Handle typedefs above.
74 \see RawV6SocketProtocol
76 class RawV4SocketProtocol
77 : public ConcreteSocketProtocol<RawV4Socket_Policy, RawV4SocketProtocol>,
78 public RawINetProtocol,
79 public BSDSocketProtocol,
80 public AddressableBSDSocketProtocol,
81 public MulticastProtocol,
82 public INet4MulticastProtocol
85 ///////////////////////////////////////////////////////////////////////////
91 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
92 /**< \note This member is implicitly called from the
93 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
95 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
97 void init_client(int const & protocol, INet4SocketAddress const & address) const;
98 ///< Create client socket and bind
99 /**< Creates a new client socket for the given protocol and binds to the given
101 \param[in] protocol Layer 4 protocol to filter for / to send
102 \param[in] address local address to bind to */
107 typedef ProtocolClientSocketHandle<RawV4SocketProtocol> RawV4ClientSocketHandle;
112 //////////////////////////////////////////////////////////////////// Raw IPv6 Socket //////////////////////////////////////
113 typedef MakeSocketPolicy<
114 INet6AddressingPolicy,
115 DatagramFramingPolicy,
116 UnconnectedCommunicationPolicy,
119 >::policy RawV6Socket_Policy; ///< Socket Policy of the RawV6 Protocol
121 /** \brief IPv6 RAW Socket Protocol
123 \par Socket Handle typedefs:
124 \ref RawV6ClientSocketHandle (ProtocolClientSocketHandle)
126 \par Policy Interface:
127 ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
128 ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
129 ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
134 RawV6SocketProtocol provides an internet protocol raw socket based on IPv6 addressing.
135 This socket will put data written to it onto the IPv6 layer: if you call writeto don't inlude the header!
136 On the other hand `read` will return the packet data on top of the IPv6 layer, excluding the IP header.
137 Note: This behaviour is differs from the behaviour of IPv4 RAW sockets.
139 This class is utilized as the protocol class of the ProtocolClientSocketHandle
140 via the Socket Handle typedefs above.
142 \see RawV4SocketProtocol
144 class RawV6SocketProtocol
145 : public ConcreteSocketProtocol<RawV6Socket_Policy,RawV6SocketProtocol>,
146 public RawINetProtocol,
147 public BSDSocketProtocol,
148 public AddressableBSDSocketProtocol,
149 public MulticastProtocol,
150 public INet4MulticastProtocol
153 ///////////////////////////////////////////////////////////////////////////
154 // internal interface
156 ///\name Constructors
159 void init_client() const; ///< Create unconnected client socket for IPPROTO_RAW
160 /**< \note This member is implicitly called from the
161 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
164 void init_client(int const & protocol) const; ///< Create unconnected client socket for protocol
166 void init_client(int const & protocol, INet6SocketAddress const & address) const;
167 ///< Create client socket and bind
168 /**< Creates a new client socket for the given protocol and binds to the given
170 \param[in] protocol Layer 4 protocol to filter for / to send
171 \param[in] address local address to bind to */
172 /**< \note This member is implicitly called from the
173 ProtocolClientSocketHandle::ProtocolClientSocketHandle()
179 typedef ProtocolClientSocketHandle<RawV6SocketProtocol> RawV6ClientSocketHandle;
185 #endif /*RAWINETSOCKETHANDLE_HH_*/