xref: /php-src/ext/standard/php_dns.h (revision 6f2f228e)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: The typical suspects                                        |
14    |          Marcus Boerger <helly@php.net>                              |
15    |          Pollita <pollita@php.net>                                   |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef PHP_DNS_H
20 #define PHP_DNS_H
21 
22 #if defined(HAVE_DNS_SEARCH)
23 #define php_dns_search(res, dname, class, type, answer, anslen) \
24     	((int)dns_search(res, dname, class, type, (char *) answer, anslen, (struct sockaddr *)&from, &fromsize))
25 #define php_dns_free_handle(res) \
26 		dns_free(res)
27 #define php_dns_errno(handle) h_errno
28 
29 #elif defined(HAVE_RES_NSEARCH)
30 #define php_dns_search(res, dname, class, type, answer, anslen) \
31 			res_nsearch(res, dname, class, type, answer, anslen);
32 #ifdef HAVE_RES_NDESTROY
33 #define php_dns_free_handle(res) \
34 			res_ndestroy(res); \
35 			php_dns_free_res(res)
36 #else
37 #define php_dns_free_handle(res) \
38 			res_nclose(res); \
39 			php_dns_free_res(res)
40 #endif
41 #define php_dns_errno(handle) handle->res_h_errno
42 
43 #elif defined(HAVE_RES_SEARCH)
44 #define php_dns_search(res, dname, class, type, answer, anslen) \
45 			res_search(dname, class, type, answer, anslen)
46 #define php_dns_free_handle(res) /* noop */
47 #define php_dns_errno(handle) h_errno
48 
49 #endif
50 
51 #if defined(HAVE_DNS_SEARCH) || defined(HAVE_RES_NSEARCH) || defined(HAVE_RES_SEARCH)
52 #define HAVE_DNS_SEARCH_FUNC 1
53 #endif
54 
55 #if defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_DN_EXPAND) && defined(HAVE_DN_SKIPNAME)
56 #define HAVE_FULL_DNS_FUNCS 1
57 #endif
58 
59 #if defined(PHP_WIN32) || (defined(HAVE_DNS_SEARCH_FUNC) && defined(HAVE_FULL_DNS_FUNCS))
60 #define PHP_DNS_A      0x00000001
61 #define PHP_DNS_NS     0x00000002
62 #define PHP_DNS_CNAME  0x00000010
63 #define PHP_DNS_SOA    0x00000020
64 #define PHP_DNS_PTR    0x00000800
65 #define PHP_DNS_HINFO  0x00001000
66 #if !defined(PHP_WIN32)
67 # define PHP_DNS_CAA    0x00002000
68 #endif
69 #define PHP_DNS_MX     0x00004000
70 #define PHP_DNS_TXT    0x00008000
71 #define PHP_DNS_A6     0x01000000
72 #define PHP_DNS_SRV    0x02000000
73 #define PHP_DNS_NAPTR  0x04000000
74 #define PHP_DNS_AAAA   0x08000000
75 #define PHP_DNS_ANY    0x10000000
76 
77 #if defined(PHP_WIN32)
78 # define PHP_DNS_NUM_TYPES	12	/* Number of DNS Types Supported by PHP currently */
79 # define PHP_DNS_ALL    (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA)
80 #else
81 # define PHP_DNS_NUM_TYPES	13	/* Number of DNS Types Supported by PHP currently */
82 # define PHP_DNS_ALL   (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_CAA|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA)
83 #endif
84 #endif
85 
86 #ifndef INT16SZ
87 #define INT16SZ		2
88 #endif
89 
90 #ifndef INT32SZ
91 #define INT32SZ		4
92 #endif
93 
94 #endif /* PHP_DNS_H */
95