Add 'unflatten' to doxygen/dot processing
[senf.git] / Utils / Console / UDPServer.hh
1 // $Id$
2 //
3 // Copyright (C) 2009 
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 UDPServer public header */
25
26 #ifndef HH_SENF_Utils_Console_UDPServer_
27 #define HH_SENF_Utils_Console_UDPServer_ 1
28
29 // Custom includes
30 #include <boost/utility.hpp>
31 #include "../../Socket/Protocols/INet/UDPSocketHandle.hh"
32 #include "../Logger/SenfLog.hh"
33 #include "../../Scheduler/Scheduler.hh"
34 #include "Parse.hh"
35 #include "Executor.hh"
36
37 //#include "UDPServer.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
39
40 namespace senf {
41 namespace console {
42
43     /** \brief UDP Console server
44
45         This class provides UDP access to the console to allow remote scripting. The UDP console
46         does support multicast operation.
47
48         Every UDP packet will be executed in a clean context: No directory groups are open/closed,
49         and the current directory is always the root directory. 
50
51         By default, the server will send command replies via UDP to the sender of the corresponding
52         incoming command. Replies may however either be completely disabled or be sent to a fixed
53         address (which may be a multicast address).
54
55         \ingroup console_access
56       */
57     class UDPServer
58         : public boost::noncopyable
59     {
60         SENF_LOG_CLASS_AREA();
61         SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE);
62     public:
63         ///////////////////////////////////////////////////////////////////////////
64         // Types
65
66         typedef senf::ClientSocketHandle<
67             senf::MakeSocketPolicy<senf::UDPv4SocketProtocol::Policy,
68                                    senf::BSDAddressingPolicy>::policy > Handle;
69
70         ///////////////////////////////////////////////////////////////////////////
71         ///\name Structors and default members
72         ///@{
73
74         explicit UDPServer(senf::INet4SocketAddress const & address);
75                                         ///< Open UDP server on \a address
76         explicit UDPServer(senf::INet6SocketAddress const & address);
77                                         ///< Open UDP server on \a address
78         
79         ///@}
80         ///////////////////////////////////////////////////////////////////////////
81
82         UDPServer & replies(bool enable); ///< Enable or disable reply packets
83         UDPServer & replies(senf::INet4SocketAddress const & address);
84                                         ///< Send replies to \a address
85         UDPServer & replies(senf::INet6SocketAddress const & address);
86                                         ///< Send replies to \a address
87
88         UDPServer & emptyReplies(bool enable); ///< Enable or disable empty reply packets
89
90         DirectoryNode & root() const;   ///< Get root node
91
92         UDPServer & root(DirectoryNode & root); ///< Set root node
93                                         /**< \a node will be the root node for all clients launched
94                                              from this server. */
95
96     protected:
97
98     private:
99         void handleInput(int events);
100
101         bool replies_;
102         bool emptyReplies_;
103         senf::GenericBSDSocketAddress target_;
104
105         Handle handle_;
106         senf::scheduler::FdEvent readevent_;
107         CommandParser parser_;
108         Executor executor_;
109     };
110
111
112 }}
113
114 ///////////////////////////////hh.e////////////////////////////////////////
115 //#include "UDPServer.cci"
116 //#include "UDPServer.ct"
117 //#include "UDPServer.cti"
118 #endif
119
120 \f
121 // Local Variables:
122 // mode: c++
123 // fill-column: 100
124 // comment-column: 40
125 // c-file-style: "senf"
126 // indent-tabs-mode: nil
127 // ispell-local-dictionary: "american"
128 // compile-command: "scons -u test"
129 // End: