Socket: Move protocol into the socket body (as private base class) and allow non...
[senf.git] / Socket / Protocols / Raw / TunTapSocketHandle.hh
1 // $Id:PacketSocketHandle.hh 218 2007-03-20 14:39:32Z tho $
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY 
6 //     Stefan Bund <g0dil@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 PacketProtocol and PacketSocketHandle public header
25
26     \todo Implement global promisc() helper based on ioctl() interface.
27  */
28
29 #ifndef HH_TunTapSocketHandle_
30 #define HH_TunTapSocketHandle_ 1
31
32 // Custom includes
33 #include "../../../Socket/SocketPolicy.hh"
34 #include "../../../Socket/SocketProtocol.hh"
35 #include "../../../Socket/ProtocolClientSocketHandle.hh"
36 #include "../../../Socket/FramingPolicy.hh"
37 #include "../../../Socket/CommunicationPolicy.hh"
38 #include "../../../Socket/ReadWritePolicy.hh"
39 #include "../../../Socket/Protocols/BSDSocketProtocol.hh"
40 #include "LLAddressing.hh"
41
42 //#include "TunTapSocketHandle.mpp"
43 //#include "TunTapSocketHandle.ih"
44 ///////////////////////////////hh.p////////////////////////////////////////
45
46 namespace senf {
47
48     /// \addtogroup concrete_protocol_group
49     /// @{
50
51     typedef MakeSocketPolicy<
52         NoAddressingPolicy,
53         DatagramFramingPolicy,
54         ConnectedCommunicationPolicy,
55         ReadablePolicy,
56         WriteablePolicy
57         >::policy Tap_Policy;        ///< Policy for TAP
58
59     /** \brief TAP
60
61         \todo document me
62
63         \par Socket Handle typedefs:
64
65
66         \par Policy Interface:
67
68
69         \par Address Type:
70
71
72         This class is utilized as the protocol class of the ProtocolClientSocketHandle via the
73         Socket Handle typedefs above.
74      */
75     class TapProtocol
76         : public ConcreteSocketProtocol<Tap_Policy,TapProtocol>,
77           public BSDSocketProtocol
78     {
79     public:
80         ///\name Constructors
81         ///@{
82         void init_client() const;
83                                         ///< Create TAP socket
84                                         /**< \todo document me */
85                                         /**< \note This member is implicitly called from the
86                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
87                                              constructor */
88         void init_client(std::string const & interface_name, bool const NO_PI=true) const;
89                                         ///< Create TAP socket
90                                         /**< \todo document me
91                                              \param[in] address remote address to connect to */
92                                         /**< \note This member is implicitly called from the
93                                              ProtocolClientSocketHandle::ProtocolClientSocketHandle()
94                                              constructor */
95         
96         ///@}
97
98         ///\name Abstract Interface Implementation
99         ///@{
100
101         unsigned available() const;
102         bool eof() const;
103
104         ///@}
105     };
106
107     typedef ProtocolClientSocketHandle<TapProtocol> TapSocketHandle;
108                                         ///< SocketHandle of TapProtocol
109                                         /**< \related TapPrototol */
110
111     /// @}
112 }
113
114 ///////////////////////////////hh.e////////////////////////////////////////
115 //#include "TunTapSocketHandle.cci"
116 //#include "TunTapSocketHandle.ct"
117 //#include "TunTapSocketHandle.cti"
118 //#include "TunTapSocketHandle.mpp"
119 #endif
120
121 \f
122 // Local Variables:
123 // mode: c++
124 // fill-column: 100
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"
129 // comment-column: 40
130 // End: