]>
Commit | Line | Data |
---|---|---|
12c86877 | 1 | /* |
12471842 PL |
2 | * This file is part of PowerDNS or dnsdist. |
3 | * Copyright -- PowerDNS.COM B.V. and its contributors | |
4 | * | |
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. | |
8 | * | |
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. | |
12 | * | |
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. | |
17 | * | |
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. | |
21 | */ | |
12c86877 BH |
22 | #ifndef PDNS_TCPRECEIVER_HH |
23 | #define PDNS_TCPRECEIVER_HH | |
24 | ||
25 | #include "dns.hh" | |
9f1d5826 | 26 | #include "iputils.hh" |
12c86877 BH |
27 | #include "dnsbackend.hh" |
28 | #include "packethandler.hh" | |
092f210a | 29 | #include <vector> |
dd7da6cd | 30 | |
8edfedf1 | 31 | #include <poll.h> |
76473b92 KM |
32 | #include <sys/select.h> |
33 | #include <sys/socket.h> | |
34 | #include <netinet/in.h> | |
35 | #include <arpa/inet.h> | |
36 | #include <sys/stat.h> | |
37 | #include <unistd.h> | |
38 | #include <netdb.h> | |
39 | #include <sys/uio.h> | |
40 | #include <sys/select.h> | |
12c86877 | 41 | |
10f4eea8 | 42 | #include "namespaces.hh" |
12c86877 BH |
43 | |
44 | class TCPNameserver | |
45 | { | |
46 | public: | |
092f210a | 47 | TCPNameserver(); |
12c86877 BH |
48 | ~TCPNameserver(); |
49 | void go(); | |
50 | private: | |
51 | ||
dd7da6cd | 52 | static void sendPacket(std::shared_ptr<DNSPacket> p, int outsock); |
809fe23f BH |
53 | static int readLength(int fd, ComboAddress *remote); |
54 | static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote); | |
7abbc40f | 55 | static int doAXFR(const DNSName &target, std::shared_ptr<DNSPacket> q, int outsock); |
dd7da6cd | 56 | static int doIXFR(std::shared_ptr<DNSPacket> q, int outsock); |
57 | static bool canDoAXFR(std::shared_ptr<DNSPacket> q); | |
12c86877 BH |
58 | static void *doConnection(void *data); |
59 | static void *launcher(void *data); | |
60 | void thread(void); | |
61 | static pthread_mutex_t s_plock; | |
62 | static PacketHandler *s_P; | |
63 | pthread_t d_tid; | |
64 | static Semaphore *d_connectionroom_sem; | |
9f1d5826 | 65 | static NetmaskGroup d_ng; |
12c86877 BH |
66 | |
67 | vector<int>d_sockets; | |
8edfedf1 | 68 | vector<struct pollfd> d_prfds; |
12c86877 BH |
69 | }; |
70 | ||
71 | #endif /* PDNS_TCPRECEIVER_HH */ |