]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/tcpreceiver.hh
70df64e983c932283fdd80b468cd76e0c7ec69ab
[thirdparty/pdns.git] / pdns / tcpreceiver.hh
1 /*
2 PowerDNS Versatile Database Driven Nameserver
3 Copyright (C) 2002 PowerDNS.COM BV
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2
7 as published by the Free Software Foundation
8
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 #ifndef PDNS_TCPRECEIVER_HH
20 #define PDNS_TCPRECEIVER_HH
21
22 #include "dns.hh"
23 #include "iputils.hh"
24 #include "dnsbackend.hh"
25 #include "packethandler.hh"
26 #include <vector>
27 #include <boost/shared_ptr.hpp>
28 #include <poll.h>
29 #include <sys/select.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
32 #include <arpa/inet.h>
33 #include <sys/stat.h>
34 #include <unistd.h>
35 #include <netdb.h>
36 #include <sys/uio.h>
37 #include <sys/select.h>
38
39 #include "namespaces.hh"
40
41 class TCPNameserver
42 {
43 public:
44 TCPNameserver();
45 ~TCPNameserver();
46 void go();
47 private:
48
49 static void sendPacket(boost::shared_ptr<DNSPacket> p, int outsock);
50 static int readLength(int fd, ComboAddress *remote);
51 static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote);
52 static int doAXFR(const string &target, boost::shared_ptr<DNSPacket> q, int outsock);
53 static bool canDoAXFR(boost::shared_ptr<DNSPacket> q);
54 static void *doConnection(void *data);
55 static void *launcher(void *data);
56 void thread(void);
57 static pthread_mutex_t s_plock;
58 static PacketHandler *s_P;
59 pthread_t d_tid;
60 static Semaphore *d_connectionroom_sem;
61 static NetmaskGroup d_ng;
62
63 vector<int>d_sockets;
64 vector<struct pollfd> d_prfds;
65 static int s_timeout;
66 };
67
68 #endif /* PDNS_TCPRECEIVER_HH */