Utils/Console: Console UDPServer
[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
44       */
45     class UDPServer
46         : public boost::noncopyable
47     {
48         SENF_LOG_CLASS_AREA();
49         SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE);
50     public:
51         ///////////////////////////////////////////////////////////////////////////
52         // Types
53
54         typedef senf::ClientSocketHandle<
55             senf::MakeSocketPolicy<senf::UDPv4SocketProtocol::Policy,
56                                    senf::BSDAddressingPolicy>::policy > Handle;
57
58         ///////////////////////////////////////////////////////////////////////////
59         ///\name Structors and default members
60         ///@{
61
62         explicit UDPServer(senf::INet4SocketAddress const & address);
63         explicit UDPServer(senf::INet6SocketAddress const & address);
64         
65         ///@}
66         ///////////////////////////////////////////////////////////////////////////
67
68         UDPServer & replies(bool enable);
69         UDPServer & replies(senf::INet4SocketAddress const & address);
70         UDPServer & replies(senf::INet6SocketAddress const & address);
71
72         DirectoryNode & root() const;   ///< Get root node
73
74         UDPServer & root(DirectoryNode & root); ///< Set root node
75                                         /**< \a node will be the root node for all clients launched
76                                              from this server. */
77
78     protected:
79
80     private:
81         void handleInput(int events);
82
83         bool replies_;
84         senf::GenericBSDSocketAddress target_;
85
86         Handle handle_;
87         senf::scheduler::FdEvent readevent_;
88         CommandParser parser_;
89         Executor executor_;
90     };
91
92
93 }}
94
95 ///////////////////////////////hh.e////////////////////////////////////////
96 //#include "UDPServer.cci"
97 //#include "UDPServer.ct"
98 //#include "UDPServer.cti"
99 #endif
100
101 \f
102 // Local Variables:
103 // mode: c++
104 // fill-column: 100
105 // comment-column: 40
106 // c-file-style: "senf"
107 // indent-tabs-mode: nil
108 // ispell-local-dictionary: "american"
109 // compile-command: "scons -u test"
110 // End: