1 /* 2 * Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 3 * Copyright (C) 2009-2013 Sourcefire, Inc. 4 * 5 * Authors: aCaB <acab@clamav.net> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef __RESOLV_H 23 #define __RESOLV_H 24 25 #if HAVE_CONFIG_H 26 #include "clamav-config.h" 27 #endif 28 29 #include <Windns.h> 30 #include "clamav-types.h" 31 32 #define C_IN 1 33 34 #define T_A DNS_TYPE_A 35 #define T_NS DNS_TYPE_NS 36 #define T_MD DNS_TYPE_MD 37 #define T_MF DNS_TYPE_MF 38 #define T_CNAME DNS_TYPE_CNAME 39 #define T_SOA DNS_TYPE_SOA 0 40 #define T_MB DNS_TYPE_MB 41 #define T_MG DNS_TYPE_MG 42 #define T_MR DNS_TYPE_MR 43 #define T_NULL DNS_TYPE_NULL 44 #define T_WKS DNS_TYPE_WKS 45 #define T_PTR DNS_TYPE_PTR 46 #define T_HINFO DNS_TYPE_HINFO 47 #define T_MINFO DNS_TYPE_MINFO 48 #define T_MX DNS_TYPE_MX 49 #define T_TXT DNS_TYPE_TEXT 50 #define T_RP DNS_TYPE_RP 51 #define T_AFSDB DNS_TYPE_AFSDB 52 #define T_X25 DNS_TYPE_X25 53 #define T_ISDN DNS_TYPE_ISDN 54 #define T_RT DNS_TYPE_RT 55 #define T_NSAP DNS_TYPE_NSAP 56 #define T_NSAP_PTR DNS_TYPE_NSAPPTR 57 #define T_SIG DNS_TYPE_SIG 58 #define T_KEY DNS_TYPE_KEY 59 #define T_PX DNS_TYPE_PX 60 #define T_GPOS DNS_TYPE_GPOS 61 #define T_AAAA DNS_TYPE_AAAA 62 #define T_LOC DNS_TYPE_LOC 63 #define T_NXT DNS_TYPE_NXT 64 #define T_EID DNS_TYPE_EID 65 #define T_NIMLOC DNS_TYPE_NIMLOC 66 #define T_SRV DNS_TYPE_SRV 67 #define T_ATMA DNS_TYPE_ATMA 68 #define T_NAPTR DNS_TYPE_NAPTR 69 #define T_KX DNS_TYPE_KX 70 #define T_CERT DNS_TYPE_CERT 71 #define T_A6 DNS_TYPE_A6 72 #define T_DNAME DNS_TYPE_DNAME 73 #define T_SINK DNS_TYPE_SINK 74 #define T_OPT DNS_TYPE_OPT 75 #define T_DS DNS_TYPE_DS 76 #define T_RRSIG DNS_TYPE_RRSIG 77 #define T_NSEC DNS_TYPE_NSEC 78 #define T_DNSKEY DNS_TYPE_DNSKEY 79 #define T_DHCID DNS_TYPE_DHCID 80 #define T_UINFO DNS_TYPE_UINFO 81 #define T_UID DNS_TYPE_UID 82 #define T_GID DNS_TYPE_GID 83 #define T_UNSPEC DNS_TYPE_UNSPEC 84 #define T_ADDRS DNS_TYPE_ADDRS 85 #define T_TKEY DNS_TYPE_TKEY 86 #define T_TSIG DNS_TYPE_TSIG 87 #define T_IXFR DNS_TYPE_IXFR 88 #define T_AXFR DNS_TYPE_AXFR 89 #define T_MAILB DNS_TYPE_MAILB 90 #define T_MAILA DNS_TYPE_MAILA 91 #define T_ALL DNS_TYPE_ALL 92 #define T_ANY DNS_TYPE_ANY 93 #define T_WINS DNS_TYPE_WINS 94 #define T_WINSR DNS_TYPE_WINSR 95 #define T_NBSTAT DNS_TYPE_NBSTAT 96 97 #ifndef DNS_QUERY_NO_HOSTS_FILE 98 #define DNS_QUERY_NO_HOSTS_FILE 0 99 #endif 100 101 typedef struct { 102 unsigned short id; /* fake stuff */ 103 } HEADER; 104 105 #define INT16SZ 2 106 107 #define GETSHORT(var, ptr) \ 108 do { \ 109 var = ((uint16_t)(*(uint8_t *)ptr++)) << 8; \ 110 var |= *(uint8_t *)ptr++; \ 111 } while (0) 112 113 #define GETLONG(var, ptr) \ 114 do { \ 115 var = ((uint32_t)(*(uint8_t *)ptr++)) << 24; \ 116 var = ((uint32_t)(*(uint8_t *)ptr++)) << 16; \ 117 var = ((uint32_t)(*(uint8_t *)ptr++)) << 8; \ 118 var |= *(uint8_t *)ptr++; \ 119 } while (0) 120 121 int res_init(void); 122 int res_query(const char *dname, int class, int type, unsigned char *answer, int anslen); 123 int dn_expand(unsigned char *msg, unsigned char *eomorig, unsigned char *comp_dn, char *exp_dn, int length); 124 125 #endif 126