]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/tcpreceiver.hh
further cleanups of TCP
[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
29 #ifndef WIN32
30 # include <sys/select.h>
31 # include <sys/socket.h>
32 # include <netinet/in.h>
33 # include <arpa/inet.h>
34 # include <sys/stat.h>
35 # include <unistd.h>
36 # include <netdb.h>
37 # include <sys/uio.h>
38 # include <sys/select.h>
39 #endif // WIN32
40
41 using namespace std;
42
43 class TCPNameserver
44 {
45 public:
46 TCPNameserver();
47 ~TCPNameserver();
48 void go();
49 private:
50
51 static void sendPacket(boost::shared_ptr<DNSPacket> p, int outsock);
52 static int readLength(int fd, ComboAddress *remote);
53 static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote);
54 static int doAXFR(const string &target, boost::shared_ptr<DNSPacket> q, int outsock);
55 static bool canDoAXFR(boost::shared_ptr<DNSPacket> q);
56 static void *doConnection(void *data);
57 static void *launcher(void *data);
58 void thread(void);
59 static pthread_mutex_t s_plock;
60 static PacketHandler *s_P;
61 pthread_t d_tid;
62 static Semaphore *d_connectionroom_sem;
63 static NetmaskGroup d_ng;
64
65 vector<int>d_sockets;
66 int d_highfd;
67 fd_set d_rfds;
68 static int s_timeout;
69 };
70
71 #endif /* PDNS_TCPRECEIVER_HH */