| 1 | /* |
|---|
| 2 | PowerDNS Versatile Database Driven Nameserver |
|---|
| 3 | Copyright (C) 2002 - 2005 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 as published by |
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | (at your option) any later version. |
|---|
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #ifndef PDNS_LWRES_HH |
|---|
| 21 | #define PDNS_LWRES_HH |
|---|
| 22 | #include <string> |
|---|
| 23 | #include <vector> |
|---|
| 24 | #include <sys/types.h> |
|---|
| 25 | |
|---|
| 26 | #ifndef WIN32 |
|---|
| 27 | |
|---|
| 28 | # include <arpa/nameser.h> |
|---|
| 29 | # include <resolv.h> |
|---|
| 30 | # include <netdb.h> |
|---|
| 31 | # include <unistd.h> |
|---|
| 32 | # include <sys/time.h> |
|---|
| 33 | # include <sys/uio.h> |
|---|
| 34 | # include <fcntl.h> |
|---|
| 35 | # include <sys/socket.h> |
|---|
| 36 | # include <netinet/in.h> |
|---|
| 37 | # include <arpa/inet.h> |
|---|
| 38 | # undef res_mkquery |
|---|
| 39 | #endif // WIN32 |
|---|
| 40 | |
|---|
| 41 | #include "ahuexception.hh" |
|---|
| 42 | #include "dns.hh" |
|---|
| 43 | using namespace std; |
|---|
| 44 | |
|---|
| 45 | int asendto(const char *data, int len, int flags, struct sockaddr *toaddr, int addrlen, int id); |
|---|
| 46 | int arecvfrom(char *data, int len, int flags, struct sockaddr *toaddr, Utility::socklen_t *addrlen, int *d_len, int id); |
|---|
| 47 | |
|---|
| 48 | class LWResException : public AhuException |
|---|
| 49 | { |
|---|
| 50 | public: |
|---|
| 51 | LWResException(const string &reason) : AhuException(reason){} |
|---|
| 52 | }; |
|---|
| 53 | |
|---|
| 54 | //! LWRes class |
|---|
| 55 | class LWRes |
|---|
| 56 | { |
|---|
| 57 | public: |
|---|
| 58 | LWRes(); |
|---|
| 59 | ~LWRes(); |
|---|
| 60 | string i; |
|---|
| 61 | |
|---|
| 62 | typedef vector<DNSResourceRecord> res_t; |
|---|
| 63 | |
|---|
| 64 | int asyncresolve(uint32_t ip, const char *domain, int type, bool doTCP, struct timeval* now); |
|---|
| 65 | vector<DNSResourceRecord> result(); |
|---|
| 66 | int d_rcode; |
|---|
| 67 | bool d_aabit, d_tcbit; |
|---|
| 68 | uint32_t d_usec; |
|---|
| 69 | private: |
|---|
| 70 | int d_sock; |
|---|
| 71 | unsigned char *d_buf; |
|---|
| 72 | int getLength(); |
|---|
| 73 | int d_len; |
|---|
| 74 | int d_soacount; |
|---|
| 75 | string d_domain; |
|---|
| 76 | int d_type; |
|---|
| 77 | int d_timeout; |
|---|
| 78 | uint32_t d_ip; |
|---|
| 79 | bool d_inaxfr; |
|---|
| 80 | int d_bufsize; |
|---|
| 81 | }; |
|---|
| 82 | |
|---|
| 83 | #endif // PDNS_LWRES_HH |
|---|