Move include files in debian packge into 'senf' subdirectory
[senf.git] / Socket / Protocols / INet / UDPSocketHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief UDPv4SocketHandle and UDPv6SocketHandle public header
25
26     \todo Implement possibly non-blocking connect and SO_ERROR in the
27     protocol interface
28  */
29
30 #ifndef HH_UDPSocketHandle_
31 #define HH_UDPSocketHandle_ 1
32
33 // Custom includes
34 #include "INetProtocol.hh"
35 #include "UDPProtocol.hh"
36 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
37 #include "../../../Socket/FramingPolicy.hh"
38 #include "../../../Socket/CommunicationPolicy.hh"
39 #include "../../../Socket/ReadWritePolicy.hh"
40 #include "../../../Socket/BufferingPolicy.hh"
41 #include "../../../Socket/ProtocolClientSocketHandle.hh"
42
43 //#include "UDPSocketHandle.mpp"
44 ///////////////////////////////hh.p////////////////////////////////////////
45
46 namespace senf {
47
48     /// \addtogroup concrete_protocol_group
49     /// @{
50
51     typedef MakeSocketPolicy<
52         INet4AddressingPolicy,
53         DatagramFramingPolicy,
54         UnconnectedCommunicationPolicy,
55         ReadablePolicy,
56         WriteablePolicy,
57         SocketBufferingPolicy
58         >::policy UDPv4Socket_Policy;   ///< Socket Policy of the UDPv4 Protocol
59
60     /** \brief IPv4 UDP Socket Protocol
61
62         \par Socket Handle typedefs:
63             \ref UDPv4ClientSocketHandle (ProtocolClientSocketHandle)
64
65         \par Policy Interface:
66             ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
67             ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
68             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
69
70         \par Address Type:
71             INet4Address
72
73         UDPv4SocketProtocol provides an internet protocol stream socket based on the UDP protocol
74         and IPv4 addressing.
75
76         This class is utilized as the protocol class of the ProtocolClientSocketHandle
77         via the Socket Handle typedefs above.
78
79         \see UDPv6SocketProtocol
80      */
81     class UDPv4SocketProtocol
82         : public ConcreteSocketProtocol<UDPv4Socket_Policy>,
83           public IPv4Protocol,
84           public UDPProtocol,
85           public BSDSocketProtocol,
86           public AddressableBSDSocketProtocol,
87           public senf::pool_alloc_mixin<UDPv4SocketProtocol>
88     {
89     public:
90         ///////////////////////////////////////////////////////////////////////////
91         // internal interface
92
93         ///\name Constructors
94         ///@{
95
96         void init_client() const;       ///< Create unconnected client socket
97                                         /**< \note This member is implicitly called from the
98                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
99                                              constructor */
100         void init_client(INet4SocketAddress const & address) const;
101                                         ///< Create client socket and connect
102                                         /**< Creates a new client socket and connects to the given
103                                              address.
104
105                                              \param[in] address remote address to connect to */
106                                         /**< \note This member is implicitly called from the
107                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
108                                              constructor */
109
110         ///@}
111         ///\name Abstract Interface Implementation
112
113         std::auto_ptr<SocketProtocol> clone() const;
114
115         ///@}
116     };
117
118     typedef ProtocolClientSocketHandle<UDPv4SocketProtocol> UDPv4ClientSocketHandle;
119
120     typedef MakeSocketPolicy<
121         UDPv4Socket_Policy,
122         INet6AddressingPolicy
123         >::policy UDPv6Socket_Policy;
124
125     /** \brief IPv6 UDP Socket Protocol
126
127         \par Socket Handle typedefs:
128         \ref UDPv6ClientSocketHandle (ProtocolClientSocketHandle)
129
130         \par Policy Interface: 
131             ClientSocketHandle::read(), ClientSocketHandle::readfrom(),
132             ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local(),
133             ClientSocketHandle::rcvbuf(), ClientSocketHandle::sndbuf()
134
135         \par Address Type:
136             INet6Address
137
138         UDPv6SocketProtocol provides an internet protocol stream socket based on the UDP protocol
139         and IPv6 addressing.
140
141         This class is utilized as the protocol class of the ProtocolClientSocketHandle
142         via the Socket Handle typedefs above.
143
144         \see UDPv4SocketProtocol
145      */
146     class UDPv6SocketProtocol
147         : public ConcreteSocketProtocol<UDPv6Socket_Policy>,
148           public IPv6Protocol,
149           public UDPProtocol,
150           public BSDSocketProtocol,
151           public AddressableBSDSocketProtocol,
152           public senf::pool_alloc_mixin<UDPv6SocketProtocol>
153     {
154     public:
155         ///////////////////////////////////////////////////////////////////////////
156         // internal interface
157
158         ///\name Constructors
159         ///@{
160
161         void init_client() const;       ///< Create unconnected client socket
162                                         /**< \note This member is implicitly called from the
163                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
164                                              constructor */
165         void init_client(INet6SocketAddress const & address) const;
166                                         ///< Create client socket and connect
167                                         /**< Creates a new client socket and connects to the given
168                                              address.
169
170                                              \param[in] address remote address to connect to */
171                                         /**< \note This member is implicitly called from the
172                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
173                                              constructor */
174
175         ///@}
176         ///\name Abstract Interface Implementation
177
178         std::auto_ptr<SocketProtocol> clone() const;
179
180         ///@}
181     };
182
183     typedef ProtocolClientSocketHandle<UDPv6SocketProtocol> UDPv6ClientSocketHandle;
184
185     /// @}
186
187 }
188
189 ///////////////////////////////hh.e////////////////////////////////////////
190 //#include "UDPSocketHandle.cci"
191 //#include "UDPSocketHandle.ct"
192 //#include "UDPSocketHandle.cti"
193 #endif
194
195 \f
196 // Local Variables:
197 // mode: c++
198 // fill-column: 100
199 // c-file-style: "senf"
200 // indent-tabs-mode: nil
201 // ispell-local-dictionary: "american"
202 // compile-command: "scons -u test"
203 // comment-column: 40
204 // End: