4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief UDPServer public header */
26 #ifndef HH_SENF_Utils_Console_UDPServer_
27 #define HH_SENF_Utils_Console_UDPServer_ 1
30 #include <boost/utility.hpp>
31 #include <senf/Socket/Protocols/INet/UDPSocketHandle.hh>
32 #include <senf/Utils/Logger/SenfLog.hh>
33 #include <senf/Scheduler/Scheduler.hh>
35 #include "Executor.hh"
37 //#include "UDPServer.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
43 /** \brief UDP Console server
45 This class provides UDP access to the console to allow remote scripting. The UDP console
46 does support multicast operation.
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.
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).
55 \ingroup console_access
58 : public boost::noncopyable
60 SENF_LOG_CLASS_AREA();
61 SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE);
63 ///////////////////////////////////////////////////////////////////////////
66 typedef senf::ClientSocketHandle<
67 senf::MakeSocketPolicy<senf::UDPv4SocketProtocol::Policy,
68 senf::BSDAddressingPolicy>::policy > Handle;
70 ///////////////////////////////////////////////////////////////////////////
71 ///\name Structors and default members
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
80 ///////////////////////////////////////////////////////////////////////////
82 UDPServer & replies(bool enable); ///< Enable or disable reply packets
83 /** \e Default: enabled */
84 UDPServer & replies(senf::INet4SocketAddress const & address);
85 ///< Send replies to \a address
86 /**< \e Default: no address set (send replies to sender) */
87 UDPServer & replies(senf::INet6SocketAddress const & address);
88 ///< Send replies to \a address
89 /**< \e Default: no address set (send replies to sender) */
91 UDPServer & emptyReplies(bool enable); ///< Enable or disable empty reply packets
92 /**< \e Default: enabled */
94 DirectoryNode & root() const; ///< Get root node
96 UDPServer & root(DirectoryNode & root); ///< Set root node
97 /**< \a node will be the root node for all clients launched
103 void handleInput(int events);
107 senf::GenericBSDSocketAddress target_;
110 senf::scheduler::FdEvent readevent_;
111 CommandParser parser_;
118 ///////////////////////////////hh.e////////////////////////////////////////
119 //#include "UDPServer.cci"
120 //#include "UDPServer.ct"
121 //#include "UDPServer.cti"
128 // comment-column: 40
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"