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_TCPRECEIVER_HH
23 #define PDNS_TCPRECEIVER_HH
27 #include "dnsbackend.hh"
28 #include "packethandler.hh"
32 #include <sys/select.h>
33 #include <sys/socket.h>
34 #include <netinet/in.h>
35 #include <arpa/inet.h>
40 #include <sys/select.h>
42 #include "namespaces.hh"
52 static void sendPacket(std::shared_ptr<DNSPacket> p, int outsock);
53 static int readLength(int fd, ComboAddress *remote);
54 static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote, unsigned int totalTime);
55 static int doAXFR(const DNSName &target, std::shared_ptr<DNSPacket> q, int outsock);
56 static int doIXFR(std::shared_ptr<DNSPacket> q, int outsock);
57 static bool canDoAXFR(std::shared_ptr<DNSPacket> q);
58 static void *doConnection(void *data);
59 static void *launcher(void *data);
60 static void decrementClientCount(const ComboAddress& remote);
62 static pthread_mutex_t s_plock;
63 static std::mutex s_clientsCountMutex;
64 static std::map<ComboAddress,size_t,ComboAddress::addressOnlyLessThan> s_clientsCount;
65 static PacketHandler *s_P;
67 static Semaphore *d_connectionroom_sem;
68 static NetmaskGroup d_ng;
69 static size_t d_maxTransactionsPerConn;
70 static size_t d_maxConnectionsPerClient;
71 static unsigned int d_idleTimeout;
72 static unsigned int d_maxConnectionDuration;
75 vector<struct pollfd> d_prfds;
78 #endif /* PDNS_TCPRECEIVER_HH */