2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
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 Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef PDNS_DYNLISTENER
23 #define PDNS_DYNLISTENER
28 #include <sys/types.h>
33 #include <boost/utility.hpp>
37 #include <sys/socket.h>
38 #include <netinet/in.h>
40 #include "namespaces.hh"
42 class DynListener : public boost::noncopyable
45 explicit DynListener(const string &pname="");
46 explicit DynListener(const ComboAddress& addr);
50 static void *theListenerHelper(void *p);
52 typedef string g_funk_t(const vector<string> &parts, Utility::pid_t ppid); // guido!
53 typedef struct { g_funk_t *func; string args; string usage; } g_funkwithusage_t;
54 typedef map<string,g_funkwithusage_t> g_funkdb_t;
56 static void registerFunc(const string &name, g_funk_t *gf, const string &usage="", const string &args="");
57 static void registerRestFunc(g_funk_t *gf);
58 static g_funk_t* getFunc(const string& fname) { return s_funcdb[fname].func; }
60 void sendlines(const string &lines);
64 void listenOnUnixDomain(const std::string& fname);
65 void listenOnTCP(const ComboAddress&);
66 void createSocketAndBind(int family, struct sockaddr*local, size_t len);
68 NetmaskGroup d_tcprange;
77 ComboAddress d_socketaddress;
78 static g_funkdb_t s_funcdb;
79 static g_funk_t* s_restfunc;
80 bool testLive(const string& fname);
82 #endif /* PDNS_DYNLISTENER */