]>
Commit | Line | Data |
---|---|---|
12c86877 BH |
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 | |
22dc646a BH |
6 | it under the terms of the GNU General Public License version 2 |
7 | as published by the Free Software Foundation | |
8 | ||
12c86877 BH |
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 | |
06bd9ccf | 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
12c86877 BH |
18 | */ |
19 | #ifndef PDNS_TCPRECEIVER_HH | |
20 | #define PDNS_TCPRECEIVER_HH | |
21 | ||
22 | #include "dns.hh" | |
9f1d5826 | 23 | #include "iputils.hh" |
12c86877 BH |
24 | #include "dnsbackend.hh" |
25 | #include "packethandler.hh" | |
092f210a | 26 | #include <vector> |
ff76e8b4 | 27 | #include <boost/shared_ptr.hpp> |
092f210a | 28 | |
12c86877 | 29 | #ifndef WIN32 |
092f210a BH |
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> | |
12c86877 BH |
39 | #endif // WIN32 |
40 | ||
41 | using namespace std; | |
42 | ||
43 | class TCPNameserver | |
44 | { | |
45 | public: | |
092f210a | 46 | TCPNameserver(); |
12c86877 BH |
47 | ~TCPNameserver(); |
48 | void go(); | |
49 | private: | |
50 | ||
6a3e5d1a | 51 | static void sendPacket(boost::shared_ptr<DNSPacket> p, int outsock); |
809fe23f BH |
52 | static int readLength(int fd, ComboAddress *remote); |
53 | static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote); | |
ff76e8b4 BH |
54 | static int doAXFR(const string &target, boost::shared_ptr<DNSPacket> q, int outsock); |
55 | static bool canDoAXFR(boost::shared_ptr<DNSPacket> q); | |
12c86877 BH |
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; | |
9f1d5826 | 63 | static NetmaskGroup d_ng; |
12c86877 BH |
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 */ |