Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Socket / Protocols / Raw / TunTapSocketHandle.hh
1 // $Id:PacketSocketHandle.hh 218 2007-03-20 14:39:32Z tho $
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@berlios.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 PacketSocketProtocol and PacketSocketHandle public header
25  */
26
27 #ifndef HH_SENF_Socket_Protocols_Raw_TunTapSocketHandle_
28 #define HH_SENF_Socket_Protocols_Raw_TunTapSocketHandle_ 1
29
30 // Custom includes
31 #include <senf/Socket/SocketPolicy.hh>
32 #include <senf/Socket/SocketProtocol.hh>
33 #include <senf/Socket/ProtocolClientSocketHandle.hh>
34 #include <senf/Socket/FramingPolicy.hh>
35 #include <senf/Socket/CommunicationPolicy.hh>
36 #include <senf/Socket/ReadWritePolicy.hh>
37 #include <senf/Socket/Protocols/BSDSocketProtocol.hh>
38
39 //#include "TunTapSocketHandle.mpp"
40 //#include "TunTapSocketHandle.ih"
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42
43 namespace senf {
44
45     /// \addtogroup concrete_protocol_group
46     //\{
47
48     typedef MakeSocketPolicy<
49         NoAddressingPolicy,
50         DatagramFramingPolicy,
51         ConnectedCommunicationPolicy,
52         ReadablePolicy,
53         WriteablePolicy
54         >::policy Tap_Policy;        ///< Policy for TapSocketProtocol
55
56     /** \brief SocketProcol for the tap pseudo-device.
57
58         \par Socket Handle typedefs:
59             \ref TapSocketHandle
60
61         \par Policy Interface:
62             ClientSocketHandle::read() ...
63
64         The TapSocketProtocol provides access to the Linux tap device.
65
66         The tap device is a virtual ethernet network device. The tap driver was designed as low
67         level kernel support for ethernet tunneling. Userland application can write Ethernet
68         frames to the socket and kernel will receive this frames from the tap interface.
69         In the same time every frame that kernel writes to the tap interface can be read by
70         userland application from the socket.
71
72         This class is utilized as the protocol class of the ProtocolClientSocketHandle via the
73         Socket Handle typedef above.
74
75         \see <a href="http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/tuntap.txt">Kernel documentation for the TUN/TAP device driver.</a>
76      */
77     class TapSocketProtocol
78         : public ConcreteSocketProtocol<Tap_Policy,TapSocketProtocol>,
79           public BSDSocketProtocol
80     {
81     public:
82         ///\name Constructors
83         //\{
84         void init_client() const;       ///< Open tap socket and create new tap interface
85                                         /**< Opens the tun/tap socket and create a new tap interface
86                                              Use \ref ifaceName() to get the actual name of the newly
87                                              created interface.
88
89                                              The new interface is down and has to be set up separately.
90                                              After closing the socket, the tap interface and all
91                                              corresponding routes will be deleted automatically. */
92                                         /**< \note This member is implicitly called from the
93                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
94                                              constructor */
95         void init_client(std::string const & interface_name, bool NO_PI=true) const;
96                                         ///< Open tap socket and create new tap interface
97                                         /**< Opens the tun/tap socket and create a new tap interface
98                                              with the given name. Note that the created interface can
99                                              have a different name as specified. Use \ref ifaceName()
100                                              to get the actual name.
101
102                                              The new interface is down and has to be set up separately.
103                                              After closing the socket, the tap interface and all
104                                              corresponding routes will be deleted automatically.
105                                              \param[in] interface_name name of the new tap interface.
106                                              \param[in] NO_PI if set to \c false each packet has a
107                                                  additional 4 bytes header (flags, proto) */
108                                         /**< \note This member is implicitly called from the
109                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
110                                              constructor */
111
112         //\}
113
114         ///\name Abstract Interface Implementation
115         //\{
116
117         unsigned available() const;
118         bool eof() const;               ///< returns always false.
119         unsigned int ifaceIndex() const;///< returns the index of the correspondent tap interface
120         std::string ifaceName() const;  ///< returns the actual name of the correspondent tap interface
121
122     private:
123         mutable unsigned int ifaceIndex_;
124         //\}
125     };
126
127     typedef ProtocolClientSocketHandle<TapSocketProtocol> TapSocketHandle;
128                                         ///< SocketHandle of TapSocketProtocol
129                                         /**< \related TapSocketProtocol */
130
131     //\}
132 }
133
134 //-/////////////////////////////////////////////////////////////////////////////////////////////////
135 //#include "TunTapSocketHandle.cci"
136 //#include "TunTapSocketHandle.ct"
137 //#include "TunTapSocketHandle.cti"
138 //#include "TunTapSocketHandle.mpp"
139 #endif
140
141 \f
142 // Local Variables:
143 // mode: c++
144 // fill-column: 100
145 // c-file-style: "senf"
146 // indent-tabs-mode: nil
147 // ispell-local-dictionary: "american"
148 // compile-command: "scons -u test"
149 // comment-column: 40
150 // End: