4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief UDPServer public header */
31 #ifndef HH_SENF_Utils_Console_UDPServer_
32 #define HH_SENF_Utils_Console_UDPServer_ 1
35 #include <boost/utility.hpp>
36 #include <senf/Socket/Protocols/INet/UDPSocketHandle.hh>
37 #include <senf/Utils/Logger/SenfLog.hh>
38 #include <senf/Scheduler/FdEvent.hh>
40 #include "Executor.hh"
42 //#include "UDPServer.mpp"
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 /** \brief UDP Console server
50 This class provides UDP access to the console to allow remote scripting. The UDP console
51 does support multicast operation.
53 Every UDP packet will be executed in a clean context: No directory groups are open/closed,
54 and the current directory is always the root directory.
56 By default, the server will send command replies via UDP to the sender of the corresponding
57 incoming command. Replies may however either be completely disabled or be sent to a fixed
58 address (which may be a multicast address).
60 \ingroup console_access
63 : public boost::noncopyable
65 SENF_LOG_CLASS_AREA();
66 SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE);
68 //-////////////////////////////////////////////////////////////////////////
71 typedef senf::ClientSocketHandle<
72 senf::MakeSocketPolicy<senf::UDPv4SocketProtocol::Policy,
73 senf::BSDAddressingPolicy>::policy > Handle;
75 //-////////////////////////////////////////////////////////////////////////
76 ///\name Structors and default members
79 explicit UDPServer(senf::INet4SocketAddress const & address);
80 ///< Open UDP server on \a address
81 explicit UDPServer(senf::INet6SocketAddress const & address);
82 ///< Open UDP server on \a address
85 //-////////////////////////////////////////////////////////////////////////
87 UDPServer & replies(bool enable); ///< Enable or disable reply packets
88 /** \e Default: enabled */
89 UDPServer & replies(senf::INet4SocketAddress const & address);
90 ///< Send replies to \a address
91 /**< \e Default: no address set (send replies to sender) */
92 UDPServer & replies(senf::INet6SocketAddress const & address);
93 ///< Send replies to \a address
94 /**< \e Default: no address set (send replies to sender) */
96 UDPServer & emptyReplies(bool enable); ///< Enable or disable empty reply packets
97 /**< \e Default: enabled */
99 DirectoryNode & root() const; ///< Get root node
101 UDPServer & root(DirectoryNode & root); ///< Set root node
102 /**< \a node will be the root node for all clients launched
108 void handleInput(int events);
112 senf::GenericBSDSocketAddress target_;
115 senf::scheduler::FdEvent readevent_;
116 CommandParser parser_;
123 //-/////////////////////////////////////////////////////////////////////////////////////////////////
124 //#include "UDPServer.cci"
125 //#include "UDPServer.ct"
126 //#include "UDPServer.cti"
133 // comment-column: 40
134 // c-file-style: "senf"
135 // indent-tabs-mode: nil
136 // ispell-local-dictionary: "american"
137 // compile-command: "scons -u test"