PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/standard - dns.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 99 495 20.0 %
Date: 2014-09-21 Functions: 9 12 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2014 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: The typical suspects                                        |
      16             :    |          Pollita <pollita@php.net>                                   |
      17             :    |          Marcus Boerger <helly@php.net>                              |
      18             :    +----------------------------------------------------------------------+
      19             :  */
      20             : 
      21             : /* $Id$ */
      22             : 
      23             : /* {{{ includes */
      24             : #include "php.h"
      25             : #include "php_network.h"
      26             : 
      27             : #if HAVE_SYS_SOCKET_H
      28             : #include <sys/socket.h>
      29             : #endif
      30             : 
      31             : #ifdef PHP_WIN32
      32             : # include "win32/inet.h"
      33             : # include <winsock2.h>
      34             : # include <windows.h>
      35             : # include <Ws2tcpip.h>
      36             : #else   /* This holds good for NetWare too, both for Winsock and Berkeley sockets */
      37             : #include <netinet/in.h>
      38             : #if HAVE_ARPA_INET_H
      39             : #include <arpa/inet.h>
      40             : #endif
      41             : #include <netdb.h>
      42             : #ifdef _OSD_POSIX
      43             : #undef STATUS
      44             : #undef T_UNSPEC
      45             : #endif
      46             : #if HAVE_ARPA_NAMESER_H
      47             : #ifdef DARWIN
      48             : # define BIND_8_COMPAT 1
      49             : #endif
      50             : #include <arpa/nameser.h>
      51             : #endif
      52             : #if HAVE_RESOLV_H
      53             : #include <resolv.h>
      54             : #endif
      55             : #ifdef HAVE_DNS_H
      56             : #include <dns.h>
      57             : #endif
      58             : #endif
      59             : 
      60             : /* Borrowed from SYS/SOCKET.H */
      61             : #if defined(NETWARE) && defined(USE_WINSOCK)
      62             : #define AF_INET 2   /* internetwork: UDP, TCP, etc. */
      63             : #endif
      64             : 
      65             : #ifndef MAXHOSTNAMELEN
      66             : #define MAXHOSTNAMELEN 255
      67             : #endif
      68             : 
      69             : /* For the local hostname obtained via gethostname which is different from the
      70             :    dns-related MAXHOSTNAMELEN constant above */
      71             : #ifndef HOST_NAME_MAX
      72             : #define HOST_NAME_MAX 255
      73             : #endif
      74             : 
      75             : #include "php_dns.h"
      76             : 
      77             : /* type compat */
      78             : #ifndef DNS_T_A
      79             : #define DNS_T_A         1
      80             : #endif
      81             : #ifndef DNS_T_NS
      82             : #define DNS_T_NS        2
      83             : #endif
      84             : #ifndef DNS_T_CNAME
      85             : #define DNS_T_CNAME     5
      86             : #endif
      87             : #ifndef DNS_T_SOA
      88             : #define DNS_T_SOA       6
      89             : #endif
      90             : #ifndef DNS_T_PTR
      91             : #define DNS_T_PTR       12
      92             : #endif
      93             : #ifndef DNS_T_HINFO
      94             : #define DNS_T_HINFO     13
      95             : #endif
      96             : #ifndef DNS_T_MINFO
      97             : #define DNS_T_MINFO     14
      98             : #endif
      99             : #ifndef DNS_T_MX
     100             : #define DNS_T_MX        15
     101             : #endif
     102             : #ifndef DNS_T_TXT
     103             : #define DNS_T_TXT       16
     104             : #endif
     105             : #ifndef DNS_T_AAAA
     106             : #define DNS_T_AAAA      28
     107             : #endif
     108             : #ifndef DNS_T_SRV
     109             : #define DNS_T_SRV       33
     110             : #endif
     111             : #ifndef DNS_T_NAPTR
     112             : #define DNS_T_NAPTR     35
     113             : #endif
     114             : #ifndef DNS_T_A6
     115             : #define DNS_T_A6        38
     116             : #endif
     117             : 
     118             : #ifndef DNS_T_ANY
     119             : #define DNS_T_ANY       255
     120             : #endif
     121             : /* }}} */
     122             : 
     123             : static char *php_gethostbyaddr(char *ip);
     124             : static char *php_gethostbyname(char *name);
     125             : 
     126             : #ifdef HAVE_GETHOSTNAME
     127             : /* {{{ proto string gethostname()
     128             :    Get the host name of the current machine */
     129           0 : PHP_FUNCTION(gethostname)
     130             : {
     131             :         char buf[HOST_NAME_MAX];
     132             : 
     133           0 :         if (zend_parse_parameters_none() == FAILURE) {
     134           0 :                 return;
     135             :         }
     136             : 
     137           0 :         if (gethostname(buf, sizeof(buf) - 1)) {
     138           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to fetch host [%d]: %s", errno, strerror(errno));
     139           0 :                 RETURN_FALSE;
     140             :         }
     141             : 
     142           0 :         RETURN_STRING(buf, 1);
     143             : }
     144             : /* }}} */
     145             : #endif
     146             : 
     147             : /* TODO: Reimplement the gethostby* functions using the new winxp+ API, in dns_win32.c, then
     148             :  we can have a dns.c, dns_unix.c and dns_win32.c instead of a messy dns.c full of #ifdef
     149             : */
     150             : 
     151             : /* {{{ proto string gethostbyaddr(string ip_address)
     152             :    Get the Internet host name corresponding to a given IP address */
     153           6 : PHP_FUNCTION(gethostbyaddr)
     154             : {
     155             :         char *addr;
     156             :         int addr_len;
     157             :         char *hostname;
     158             : 
     159           6 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == FAILURE) {
     160           2 :                 return;
     161             :         }
     162             : 
     163           4 :         hostname = php_gethostbyaddr(addr);
     164             : 
     165           4 :         if (hostname == NULL) {
     166             : #if HAVE_IPV6 && HAVE_INET_PTON
     167           3 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not a valid IPv4 or IPv6 address");
     168             : #else
     169             :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Address is not in a.b.c.d form");
     170             : #endif
     171           3 :                 RETVAL_FALSE;
     172             :         } else {
     173           1 :                 RETVAL_STRING(hostname, 0);
     174             :         }
     175             : }
     176             : /* }}} */
     177             : 
     178             : /* {{{ php_gethostbyaddr */
     179           4 : static char *php_gethostbyaddr(char *ip)
     180             : {
     181             : #if HAVE_IPV6 && HAVE_INET_PTON
     182             :         struct in6_addr addr6;
     183             : #endif
     184             :         struct in_addr addr;
     185             :         struct hostent *hp;
     186             : 
     187             : #if HAVE_IPV6 && HAVE_INET_PTON
     188           4 :         if (inet_pton(AF_INET6, ip, &addr6)) {
     189           0 :                 hp = gethostbyaddr((char *) &addr6, sizeof(addr6), AF_INET6);
     190           4 :         } else if (inet_pton(AF_INET, ip, &addr)) {
     191           1 :                 hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
     192             :         } else {
     193           3 :                 return NULL;
     194             :         }
     195             : #else
     196             :         addr.s_addr = inet_addr(ip);
     197             : 
     198             :         if (addr.s_addr == -1) {
     199             :                 return NULL;
     200             :         }
     201             : 
     202             :         hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
     203             : #endif
     204             : 
     205           1 :         if (!hp || hp->h_name == NULL || hp->h_name[0] == '\0') {
     206           0 :                 return estrdup(ip);
     207             :         }
     208             : 
     209           1 :         return estrdup(hp->h_name);
     210             : }
     211             : /* }}} */
     212             : 
     213             : /* {{{ proto string gethostbyname(string hostname)
     214             :    Get the IP address corresponding to a given Internet host name */
     215          12 : PHP_FUNCTION(gethostbyname)
     216             : {
     217             :         char *hostname;
     218             :         int hostname_len;
     219             :         char *addr;
     220             : 
     221          12 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) {
     222           1 :                 return;
     223             :         }
     224             : 
     225          11 :         addr = php_gethostbyname(hostname);
     226             : 
     227          11 :         RETVAL_STRING(addr, 0);
     228             : }
     229             : /* }}} */
     230             : 
     231             : /* {{{ proto array gethostbynamel(string hostname)
     232             :    Return a list of IP addresses that a given hostname resolves to. */
     233           3 : PHP_FUNCTION(gethostbynamel)
     234             : {
     235             :         char *hostname;
     236             :         int hostname_len;
     237             :         struct hostent *hp;
     238             :         struct in_addr in;
     239             :         int i;
     240             : 
     241           3 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &hostname_len) == FAILURE) {
     242           2 :                 return;
     243             :         }
     244             : 
     245           1 :         hp = gethostbyname(hostname);
     246           1 :         if (hp == NULL || hp->h_addr_list == NULL) {
     247           0 :                 RETURN_FALSE;
     248             :         }
     249             : 
     250           1 :         array_init(return_value);
     251             : 
     252           3 :         for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) {
     253           2 :                 in = *(struct in_addr *) hp->h_addr_list[i];
     254           2 :                 add_next_index_string(return_value, inet_ntoa(in), 1);
     255             :         }
     256             : }
     257             : /* }}} */
     258             : 
     259             : /* {{{ php_gethostbyname */
     260          11 : static char *php_gethostbyname(char *name)
     261             : {
     262             :         struct hostent *hp;
     263             :         struct in_addr in;
     264             : 
     265          11 :         hp = gethostbyname(name);
     266             : 
     267          11 :         if (!hp || !*(hp->h_addr_list)) {
     268           5 :                 return estrdup(name);
     269             :         }
     270             : 
     271           6 :         memcpy(&in.s_addr, *(hp->h_addr_list), sizeof(in.s_addr));
     272             : 
     273           6 :         return estrdup(inet_ntoa(in));
     274             : }
     275             : /* }}} */
     276             : 
     277             : #if HAVE_FULL_DNS_FUNCS || defined(PHP_WIN32)
     278             : # define PHP_DNS_NUM_TYPES      12      /* Number of DNS Types Supported by PHP currently */
     279             : 
     280             : # define PHP_DNS_A      0x00000001
     281             : # define PHP_DNS_NS     0x00000002
     282             : # define PHP_DNS_CNAME  0x00000010
     283             : # define PHP_DNS_SOA    0x00000020
     284             : # define PHP_DNS_PTR    0x00000800
     285             : # define PHP_DNS_HINFO  0x00001000
     286             : # define PHP_DNS_MX     0x00004000
     287             : # define PHP_DNS_TXT    0x00008000
     288             : # define PHP_DNS_A6     0x01000000
     289             : # define PHP_DNS_SRV    0x02000000
     290             : # define PHP_DNS_NAPTR  0x04000000
     291             : # define PHP_DNS_AAAA   0x08000000
     292             : # define PHP_DNS_ANY    0x10000000
     293             : # 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)
     294             : #endif /* HAVE_FULL_DNS_FUNCS || defined(PHP_WIN32) */
     295             : 
     296             : /* Note: These functions are defined in ext/standard/dns_win32.c for Windows! */
     297             : #if !defined(PHP_WIN32) && (HAVE_DNS_SEARCH_FUNC && !(defined(__BEOS__) || defined(NETWARE)))
     298             :   
     299             : #ifndef HFIXEDSZ
     300             : #define HFIXEDSZ        12      /* fixed data in header <arpa/nameser.h> */
     301             : #endif /* HFIXEDSZ */
     302             : 
     303             : #ifndef QFIXEDSZ
     304             : #define QFIXEDSZ        4       /* fixed data in query <arpa/nameser.h> */
     305             : #endif /* QFIXEDSZ */
     306             : 
     307             : #undef MAXHOSTNAMELEN
     308             : #define MAXHOSTNAMELEN  1024
     309             : 
     310             : #ifndef MAXRESOURCERECORDS
     311             : #define MAXRESOURCERECORDS      64
     312             : #endif /* MAXRESOURCERECORDS */
     313             : 
     314             : typedef union {
     315             :         HEADER qb1;
     316             :         u_char qb2[65536];
     317             : } querybuf;
     318             : 
     319             : /* just a hack to free resources allocated by glibc in __res_nsend()
     320             :  * See also:
     321             :  *   res_thread_freeres() in glibc/resolv/res_init.c
     322             :  *   __libc_res_nsend()   in resolv/res_send.c
     323             :  * */
     324             : 
     325             : #if defined(__GLIBC__) && !defined(HAVE_DEPRECATED_DNS_FUNCS)
     326             : #define php_dns_free_res(__res__) _php_dns_free_res(__res__)
     327           2 : static void _php_dns_free_res(struct __res_state res) { /* {{{ */
     328             :         int ns;
     329           8 :         for (ns = 0; ns < MAXNS; ns++) {
     330           6 :                 if (res._u._ext.nsaddrs[ns] != NULL) {
     331           0 :                         free (res._u._ext.nsaddrs[ns]);
     332           0 :                         res._u._ext.nsaddrs[ns] = NULL;
     333             :                 }
     334             :         }
     335           2 : } /* }}} */
     336             : #else
     337             : #define php_dns_free_res(__res__)
     338             : #endif
     339             : 
     340             : /* {{{ proto bool dns_check_record(string host [, string type])
     341             :    Check DNS records corresponding to a given Internet host name or IP address */
     342           1 : PHP_FUNCTION(dns_check_record)
     343             : {
     344             : #ifndef MAXPACKET
     345             : #define MAXPACKET  8192 /* max packet size used internally by BIND */
     346             : #endif
     347             :         u_char ans[MAXPACKET];
     348           1 :         char *hostname, *rectype = NULL;
     349           1 :         int hostname_len, rectype_len = 0;
     350           1 :         int type = T_MX, i;
     351             : #if defined(HAVE_DNS_SEARCH)
     352             :         struct sockaddr_storage from;
     353             :         uint32_t fromsize = sizeof(from);
     354             :         dns_handle_t handle;
     355             : #elif defined(HAVE_RES_NSEARCH)
     356             :         struct __res_state state;
     357           1 :         struct __res_state *handle = &state;
     358             : #endif
     359             : 
     360           1 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &hostname, &hostname_len, &rectype, &rectype_len) == FAILURE) {
     361           0 :                 return;
     362             :         }
     363             : 
     364           1 :         if (hostname_len == 0) {
     365           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host cannot be empty");
     366           1 :                 RETURN_FALSE;
     367             :         }
     368             : 
     369           0 :         if (rectype) {
     370           0 :                 if (!strcasecmp("A",     rectype)) type = T_A;
     371           0 :                 else if (!strcasecmp("NS",    rectype)) type = DNS_T_NS;
     372           0 :                 else if (!strcasecmp("MX",    rectype)) type = DNS_T_MX;
     373           0 :                 else if (!strcasecmp("PTR",   rectype)) type = DNS_T_PTR;
     374           0 :                 else if (!strcasecmp("ANY",   rectype)) type = DNS_T_ANY;
     375           0 :                 else if (!strcasecmp("SOA",   rectype)) type = DNS_T_SOA;
     376           0 :                 else if (!strcasecmp("TXT",   rectype)) type = DNS_T_TXT;
     377           0 :                 else if (!strcasecmp("CNAME", rectype)) type = DNS_T_CNAME;
     378           0 :                 else if (!strcasecmp("AAAA",  rectype)) type = DNS_T_AAAA;
     379           0 :                 else if (!strcasecmp("SRV",   rectype)) type = DNS_T_SRV;
     380           0 :                 else if (!strcasecmp("NAPTR", rectype)) type = DNS_T_NAPTR;
     381           0 :                 else if (!strcasecmp("A6",    rectype)) type = DNS_T_A6;
     382             :                 else {
     383           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%s' not supported", rectype);
     384           0 :                         RETURN_FALSE;
     385             :                 }
     386             :         }
     387             : 
     388             : #if defined(HAVE_DNS_SEARCH)
     389             :         handle = dns_open(NULL);
     390             :         if (handle == NULL) {
     391             :                 RETURN_FALSE;
     392             :         }
     393             : #elif defined(HAVE_RES_NSEARCH)
     394           0 :     memset(&state, 0, sizeof(state));
     395           0 :     if (res_ninit(handle)) {
     396           0 :                         RETURN_FALSE;
     397             :         }
     398             : #else
     399             :         res_init();
     400             : #endif
     401             : 
     402           0 :         RETVAL_TRUE;
     403           0 :         i = php_dns_search(handle, hostname, C_IN, type, ans, sizeof(ans));
     404             : 
     405           0 :         if (i < 0) {
     406           0 :                 RETVAL_FALSE;
     407             :         }
     408             : 
     409           0 :         php_dns_free_handle(handle);
     410             : }
     411             : /* }}} */
     412             : 
     413             : #if HAVE_FULL_DNS_FUNCS
     414             : 
     415             : #define CHECKCP(n) do { \
     416             :         if (cp + n > end) { \
     417             :                 return NULL; \
     418             :         } \
     419             : } while (0)
     420             : 
     421             : /* {{{ php_parserr */
     422           0 : static u_char *php_parserr(u_char *cp, u_char *end, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray)
     423             : {
     424             :         u_short type, class, dlen;
     425             :         u_long ttl;
     426             :         long n, i;
     427             :         u_short s;
     428             :         u_char *tp, *p;
     429             :         char name[MAXHOSTNAMELEN];
     430           0 :         int have_v6_break = 0, in_v6_break = 0;
     431             : 
     432           0 :         *subarray = NULL;
     433             : 
     434           0 :         n = dn_expand(answer->qb2, end, cp, name, sizeof(name) - 2);
     435           0 :         if (n < 0) {
     436           0 :                 return NULL;
     437             :         }
     438           0 :         cp += n;
     439             : 
     440           0 :         CHECKCP(10);
     441           0 :         GETSHORT(type, cp);
     442           0 :         GETSHORT(class, cp);
     443           0 :         GETLONG(ttl, cp);
     444           0 :         GETSHORT(dlen, cp);
     445           0 :         CHECKCP(dlen);
     446           0 :         if (type_to_fetch != T_ANY && type != type_to_fetch) {
     447           0 :                 cp += dlen;
     448           0 :                 return cp;
     449             :         }
     450             : 
     451           0 :         if (!store) {
     452           0 :                 cp += dlen;
     453           0 :                 return cp;
     454             :         }
     455             : 
     456           0 :         ALLOC_INIT_ZVAL(*subarray);
     457           0 :         array_init(*subarray);
     458             : 
     459           0 :         add_assoc_string(*subarray, "host", name, 1);
     460           0 :         add_assoc_string(*subarray, "class", "IN", 1);
     461           0 :         add_assoc_long(*subarray, "ttl", ttl);
     462             : 
     463           0 :         if (raw) {
     464           0 :                 add_assoc_long(*subarray, "type", type);
     465           0 :                 add_assoc_stringl(*subarray, "data", (char*) cp, (uint) dlen, 1);
     466           0 :                 cp += dlen;
     467           0 :                 return cp;
     468             :         }
     469             : 
     470           0 :         switch (type) {
     471             :                 case DNS_T_A:
     472           0 :                         CHECKCP(4);
     473           0 :                         add_assoc_string(*subarray, "type", "A", 1);
     474           0 :                         snprintf(name, sizeof(name), "%d.%d.%d.%d", cp[0], cp[1], cp[2], cp[3]);
     475           0 :                         add_assoc_string(*subarray, "ip", name, 1);
     476           0 :                         cp += dlen;
     477           0 :                         break;
     478             :                 case DNS_T_MX:
     479           0 :                         CHECKCP(2);
     480           0 :                         add_assoc_string(*subarray, "type", "MX", 1);
     481           0 :                         GETSHORT(n, cp);
     482           0 :                         add_assoc_long(*subarray, "pri", n);
     483             :                         /* no break; */
     484             :                 case DNS_T_CNAME:
     485           0 :                         if (type == DNS_T_CNAME) {
     486           0 :                                 add_assoc_string(*subarray, "type", "CNAME", 1);
     487             :                         }
     488             :                         /* no break; */
     489             :                 case DNS_T_NS:
     490           0 :                         if (type == DNS_T_NS) {
     491           0 :                                 add_assoc_string(*subarray, "type", "NS", 1);
     492             :                         }
     493             :                         /* no break; */
     494             :                 case DNS_T_PTR:
     495           0 :                         if (type == DNS_T_PTR) {
     496           0 :                                 add_assoc_string(*subarray, "type", "PTR", 1);
     497             :                         }
     498           0 :                         n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
     499           0 :                         if (n < 0) {
     500           0 :                                 return NULL;
     501             :                         }
     502           0 :                         cp += n;
     503           0 :                         add_assoc_string(*subarray, "target", name, 1);
     504           0 :                         break;
     505             :                 case DNS_T_HINFO:
     506             :                         /* See RFC 1010 for values */
     507           0 :                         add_assoc_string(*subarray, "type", "HINFO", 1);
     508           0 :                         CHECKCP(1);
     509           0 :                         n = *cp & 0xFF;
     510           0 :                         cp++;
     511           0 :                         CHECKCP(n);
     512           0 :                         add_assoc_stringl(*subarray, "cpu", (char*)cp, n, 1);
     513           0 :                         cp += n;
     514           0 :                         CHECKCP(1);
     515           0 :                         n = *cp & 0xFF;
     516           0 :                         cp++;
     517           0 :                         CHECKCP(n);
     518           0 :                         add_assoc_stringl(*subarray, "os", (char*)cp, n, 1);
     519           0 :                         cp += n;
     520           0 :                         break;
     521             :                 case DNS_T_TXT:
     522             :                         {
     523           0 :                                 int l1 = 0, l2 = 0;
     524           0 :                                 zval *entries = NULL;
     525             : 
     526           0 :                                 add_assoc_string(*subarray, "type", "TXT", 1);
     527           0 :                                 tp = emalloc(dlen + 1);
     528             :                                 
     529           0 :                                 MAKE_STD_ZVAL(entries);
     530           0 :                                 array_init(entries);
     531             :                                 
     532           0 :                                 while (l1 < dlen) {
     533           0 :                                         n = cp[l1];
     534           0 :                                         if ((l1 + n) >= dlen) {
     535             :                                                 // Invalid chunk length, truncate
     536           0 :                                                 n = dlen - (l1 + 1);
     537             :                                         }
     538           0 :                                         if (n) {
     539           0 :                                                 memcpy(tp + l2 , cp + l1 + 1, n);
     540           0 :                                                 add_next_index_stringl(entries, cp + l1 + 1, n, 1);
     541             :                                         }
     542           0 :                                         l1 = l1 + n + 1;
     543           0 :                                         l2 = l2 + n;
     544             :                                 }
     545           0 :                                 tp[l2] = '\0';
     546           0 :                                 cp += dlen;
     547             : 
     548           0 :                                 add_assoc_stringl(*subarray, "txt", tp, l2, 0);
     549           0 :                                 add_assoc_zval(*subarray, "entries", entries);
     550             :                         }
     551           0 :                         break;
     552             :                 case DNS_T_SOA:
     553           0 :                         add_assoc_string(*subarray, "type", "SOA", 1);
     554           0 :                         n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2);
     555           0 :                         if (n < 0) {
     556           0 :                                 return NULL;
     557             :                         }
     558           0 :                         cp += n;
     559           0 :                         add_assoc_string(*subarray, "mname", name, 1);
     560           0 :                         n = dn_expand(answer->qb2, end, cp, name, (sizeof name) -2);
     561           0 :                         if (n < 0) {
     562           0 :                                 return NULL;
     563             :                         }
     564           0 :                         cp += n;
     565           0 :                         add_assoc_string(*subarray, "rname", name, 1);
     566           0 :                         CHECKCP(5*4);
     567           0 :                         GETLONG(n, cp);
     568           0 :                         add_assoc_long(*subarray, "serial", n);
     569           0 :                         GETLONG(n, cp);
     570           0 :                         add_assoc_long(*subarray, "refresh", n);
     571           0 :                         GETLONG(n, cp);
     572           0 :                         add_assoc_long(*subarray, "retry", n);
     573           0 :                         GETLONG(n, cp);
     574           0 :                         add_assoc_long(*subarray, "expire", n);
     575           0 :                         GETLONG(n, cp);
     576           0 :                         add_assoc_long(*subarray, "minimum-ttl", n);
     577           0 :                         break;
     578             :                 case DNS_T_AAAA:
     579           0 :                         tp = (u_char*)name;
     580           0 :                         CHECKCP(8*2);
     581           0 :                         for(i=0; i < 8; i++) {
     582           0 :                                 GETSHORT(s, cp);
     583           0 :                                 if (s != 0) {
     584           0 :                                         if (tp > (u_char *)name) {
     585           0 :                                                 in_v6_break = 0;
     586           0 :                                                 tp[0] = ':';
     587           0 :                                                 tp++;
     588             :                                         }
     589           0 :                                         tp += sprintf((char*)tp,"%x",s);
     590             :                                 } else {
     591           0 :                                         if (!have_v6_break) {
     592           0 :                                                 have_v6_break = 1;
     593           0 :                                                 in_v6_break = 1;
     594           0 :                                                 tp[0] = ':';
     595           0 :                                                 tp++;
     596           0 :                                         } else if (!in_v6_break) {
     597           0 :                                                 tp[0] = ':';
     598           0 :                                                 tp++;
     599           0 :                                                 tp[0] = '0';
     600           0 :                                                 tp++;
     601             :                                         }
     602             :                                 }
     603             :                         }
     604           0 :                         if (have_v6_break && in_v6_break) {
     605           0 :                                 tp[0] = ':';
     606           0 :                                 tp++;
     607             :                         }
     608           0 :                         tp[0] = '\0';
     609           0 :                         add_assoc_string(*subarray, "type", "AAAA", 1);
     610           0 :                         add_assoc_string(*subarray, "ipv6", name, 1);
     611           0 :                         break;
     612             :                 case DNS_T_A6:
     613           0 :                         p = cp;
     614           0 :                         add_assoc_string(*subarray, "type", "A6", 1);
     615           0 :                         CHECKCP(1);
     616           0 :                         n = ((int)cp[0]) & 0xFF;
     617           0 :                         cp++;
     618           0 :                         add_assoc_long(*subarray, "masklen", n);
     619           0 :                         tp = (u_char*)name;
     620           0 :                         if (n > 15) {
     621           0 :                                 have_v6_break = 1;
     622           0 :                                 in_v6_break = 1;
     623           0 :                                 tp[0] = ':';
     624           0 :                                 tp++;
     625             :                         }
     626           0 :                         if (n % 16 > 8) {
     627             :                                 /* Partial short */
     628           0 :                                 if (cp[0] != 0) {
     629           0 :                                         if (tp > (u_char *)name) {
     630           0 :                                                 in_v6_break = 0;
     631           0 :                                                 tp[0] = ':';
     632           0 :                                                 tp++;
     633             :                                         }
     634           0 :                                         sprintf((char*)tp, "%x", cp[0] & 0xFF);
     635             :                                 } else {
     636           0 :                                         if (!have_v6_break) {
     637           0 :                                                 have_v6_break = 1;
     638           0 :                                                 in_v6_break = 1;
     639           0 :                                                 tp[0] = ':';
     640           0 :                                                 tp++;
     641           0 :                                         } else if (!in_v6_break) {
     642           0 :                                                 tp[0] = ':';
     643           0 :                                                 tp++;
     644           0 :                                                 tp[0] = '0';
     645           0 :                                                 tp++;
     646             :                                         }
     647             :                                 }
     648           0 :                                 cp++;
     649             :                         }
     650           0 :                         for (i = (n + 8) / 16; i < 8; i++) {
     651           0 :                                 CHECKCP(2);
     652           0 :                                 GETSHORT(s, cp);
     653           0 :                                 if (s != 0) {
     654           0 :                                         if (tp > (u_char *)name) {
     655           0 :                                                 in_v6_break = 0;
     656           0 :                                                 tp[0] = ':';
     657           0 :                                                 tp++;
     658             :                                         }
     659           0 :                                         tp += sprintf((char*)tp,"%x",s);
     660             :                                 } else {
     661           0 :                                         if (!have_v6_break) {
     662           0 :                                                 have_v6_break = 1;
     663           0 :                                                 in_v6_break = 1;
     664           0 :                                                 tp[0] = ':';
     665           0 :                                                 tp++;
     666           0 :                                         } else if (!in_v6_break) {
     667           0 :                                                 tp[0] = ':';
     668           0 :                                                 tp++;
     669           0 :                                                 tp[0] = '0';
     670           0 :                                                 tp++;
     671             :                                         }
     672             :                                 }
     673             :                         }
     674           0 :                         if (have_v6_break && in_v6_break) {
     675           0 :                                 tp[0] = ':';
     676           0 :                                 tp++;
     677             :                         }
     678           0 :                         tp[0] = '\0';
     679           0 :                         add_assoc_string(*subarray, "ipv6", name, 1);
     680           0 :                         if (cp < p + dlen) {
     681           0 :                                 n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
     682           0 :                                 if (n < 0) {
     683           0 :                                         return NULL;
     684             :                                 }
     685           0 :                                 cp += n;
     686           0 :                                 add_assoc_string(*subarray, "chain", name, 1);
     687             :                         }
     688           0 :                         break;
     689             :                 case DNS_T_SRV:
     690           0 :                         CHECKCP(3*2);
     691           0 :                         add_assoc_string(*subarray, "type", "SRV", 1);
     692           0 :                         GETSHORT(n, cp);
     693           0 :                         add_assoc_long(*subarray, "pri", n);
     694           0 :                         GETSHORT(n, cp);
     695           0 :                         add_assoc_long(*subarray, "weight", n);
     696           0 :                         GETSHORT(n, cp);
     697           0 :                         add_assoc_long(*subarray, "port", n);
     698           0 :                         n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
     699           0 :                         if (n < 0) {
     700           0 :                                 return NULL;
     701             :                         }
     702           0 :                         cp += n;
     703           0 :                         add_assoc_string(*subarray, "target", name, 1);
     704           0 :                         break;
     705             :                 case DNS_T_NAPTR:
     706           0 :                         CHECKCP(2*2);
     707           0 :                         add_assoc_string(*subarray, "type", "NAPTR", 1);
     708           0 :                         GETSHORT(n, cp);
     709           0 :                         add_assoc_long(*subarray, "order", n);
     710           0 :                         GETSHORT(n, cp);
     711           0 :                         add_assoc_long(*subarray, "pref", n);
     712             : 
     713           0 :                         CHECKCP(1);
     714           0 :                         n = (cp[0] & 0xFF);
     715           0 :                         cp++;
     716           0 :                         CHECKCP(n);
     717           0 :                         add_assoc_stringl(*subarray, "flags", (char*)cp, n, 1);
     718           0 :                         cp += n;
     719             : 
     720           0 :                         CHECKCP(1);
     721           0 :                         n = (cp[0] & 0xFF);
     722           0 :                         cp++;
     723           0 :                         CHECKCP(n);
     724           0 :                         add_assoc_stringl(*subarray, "services", (char*)cp, n, 1);
     725           0 :                         cp += n;
     726             : 
     727           0 :                         CHECKCP(1);
     728           0 :                         n = (cp[0] & 0xFF);
     729           0 :                         cp++;
     730           0 :                         CHECKCP(n);
     731           0 :                         add_assoc_stringl(*subarray, "regex", (char*)cp, n, 1);
     732           0 :                         cp += n;
     733             : 
     734           0 :                         n = dn_expand(answer->qb2, end, cp, name, (sizeof name) - 2);
     735           0 :                         if (n < 0) {
     736           0 :                                 return NULL;
     737             :                         }
     738           0 :                         cp += n;
     739           0 :                         add_assoc_string(*subarray, "replacement", name, 1);
     740           0 :                         break;
     741             :                 default:
     742           0 :                         zval_ptr_dtor(subarray);
     743           0 :                         *subarray = NULL;
     744           0 :                         cp += dlen;
     745             :                         break;
     746             :         }
     747             : 
     748           0 :         return cp;
     749             : }
     750             : /* }}} */
     751             : 
     752             : /* {{{ proto array|false dns_get_record(string hostname [, int type[, array authns, array addtl]])
     753             :    Get any Resource Record corresponding to a given Internet host name */
     754           0 : PHP_FUNCTION(dns_get_record)
     755             : {
     756             :         char *hostname;
     757             :         int hostname_len;
     758           0 :         long type_param = PHP_DNS_ANY;
     759           0 :         zval *authns = NULL, *addtl = NULL;
     760             :         int type_to_fetch;
     761             : #if defined(HAVE_DNS_SEARCH)
     762             :         struct sockaddr_storage from;
     763             :         uint32_t fromsize = sizeof(from);
     764             :         dns_handle_t handle;
     765             : #elif defined(HAVE_RES_NSEARCH)
     766             :         struct __res_state state;
     767           0 :         struct __res_state *handle = &state;
     768             : #endif
     769             :         HEADER *hp;
     770             :         querybuf answer;
     771           0 :         u_char *cp = NULL, *end = NULL;
     772           0 :         int n, qd, an, ns = 0, ar = 0;
     773           0 :         int type, first_query = 1, store_results = 1;
     774           0 :         zend_bool raw = 0;
     775             : 
     776           0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz!z!b",
     777             :                         &hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) {
     778           0 :                 return;
     779             :         }
     780             : 
     781           0 :         if (authns) {
     782           0 :                 zval_dtor(authns);
     783           0 :                 array_init(authns);
     784             :         }
     785           0 :         if (addtl) {
     786           0 :                 zval_dtor(addtl);
     787           0 :                 array_init(addtl);
     788             :         }
     789             : 
     790           0 :         if (!raw) {
     791           0 :                 if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) {
     792           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param);
     793           0 :                         RETURN_FALSE;
     794             :                 }
     795             :         } else {
     796           0 :                 if ((type_param < 1) || (type_param > 0xFFFF)) {
     797           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING,
     798             :                                 "Numeric DNS record type must be between 1 and 65535, '%ld' given", type_param);
     799           0 :                         RETURN_FALSE;
     800             :                 }
     801             :         }
     802             : 
     803             :         /* Initialize the return array */
     804           0 :         array_init(return_value);
     805             : 
     806             :         /* - We emulate an or'ed type mask by querying type by type. (Steps 0 - NUMTYPES-1 )
     807             :          *   If additional info is wanted we check again with DNS_T_ANY (step NUMTYPES / NUMTYPES+1 )
     808             :          *   store_results is used to skip storing the results retrieved in step
     809             :          *   NUMTYPES+1 when results were already fetched.
     810             :          * - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step NUMTYPES+1 )
     811             :          * - In case of raw mode, we query only the requestd type instead of looping type by type
     812             :          *   before going with the additional info stuff.
     813             :          */
     814             : 
     815           0 :         if (raw) {
     816           0 :                 type = -1;
     817           0 :         } else if (type_param == PHP_DNS_ANY) {
     818           0 :                 type = PHP_DNS_NUM_TYPES + 1;
     819             :         } else {
     820           0 :                 type = 0;
     821             :         }
     822             : 
     823           0 :         for ( ;
     824           0 :                 type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query;
     825             :                 type++
     826           0 :         ) {
     827           0 :                 first_query = 0;
     828           0 :                 switch (type) {
     829             :                         case -1: /* raw */
     830           0 :                                 type_to_fetch = type_param;
     831             :                                 /* skip over the rest and go directly to additional records */
     832           0 :                                 type = PHP_DNS_NUM_TYPES - 1;
     833           0 :                                 break;
     834             :                         case 0:
     835           0 :                                 type_to_fetch = type_param&PHP_DNS_A     ? DNS_T_A     : 0;
     836           0 :                                 break;
     837             :                         case 1:
     838           0 :                                 type_to_fetch = type_param&PHP_DNS_NS    ? DNS_T_NS    : 0;
     839           0 :                                 break;
     840             :                         case 2:
     841           0 :                                 type_to_fetch = type_param&PHP_DNS_CNAME ? DNS_T_CNAME : 0;
     842           0 :                                 break;
     843             :                         case 3:
     844           0 :                                 type_to_fetch = type_param&PHP_DNS_SOA   ? DNS_T_SOA   : 0;
     845           0 :                                 break;
     846             :                         case 4:
     847           0 :                                 type_to_fetch = type_param&PHP_DNS_PTR   ? DNS_T_PTR   : 0;
     848           0 :                                 break;
     849             :                         case 5:
     850           0 :                                 type_to_fetch = type_param&PHP_DNS_HINFO ? DNS_T_HINFO : 0;
     851           0 :                                 break;
     852             :                         case 6:
     853           0 :                                 type_to_fetch = type_param&PHP_DNS_MX    ? DNS_T_MX    : 0;
     854           0 :                                 break;
     855             :                         case 7:
     856           0 :                                 type_to_fetch = type_param&PHP_DNS_TXT   ? DNS_T_TXT   : 0;
     857           0 :                                 break;
     858             :                         case 8:
     859           0 :                                 type_to_fetch = type_param&PHP_DNS_AAAA      ? DNS_T_AAAA  : 0;
     860           0 :                                 break;
     861             :                         case 9:
     862           0 :                                 type_to_fetch = type_param&PHP_DNS_SRV   ? DNS_T_SRV   : 0;
     863           0 :                                 break;
     864             :                         case 10:
     865           0 :                                 type_to_fetch = type_param&PHP_DNS_NAPTR ? DNS_T_NAPTR : 0;
     866           0 :                                 break;
     867             :                         case 11:
     868           0 :                                 type_to_fetch = type_param&PHP_DNS_A6        ? DNS_T_A6 : 0;
     869           0 :                                 break;
     870             :                         case PHP_DNS_NUM_TYPES:
     871           0 :                                 store_results = 0;
     872           0 :                                 continue;
     873             :                         default:
     874             :                         case (PHP_DNS_NUM_TYPES + 1):
     875           0 :                                 type_to_fetch = DNS_T_ANY;
     876             :                                 break;
     877             :                 }
     878             : 
     879           0 :                 if (type_to_fetch) {
     880             : #if defined(HAVE_DNS_SEARCH)
     881             :                         handle = dns_open(NULL);
     882             :                         if (handle == NULL) {
     883             :                                 zval_dtor(return_value);
     884             :                                 RETURN_FALSE;
     885             :                         }
     886             : #elif defined(HAVE_RES_NSEARCH)
     887           0 :                     memset(&state, 0, sizeof(state));
     888           0 :                     if (res_ninit(handle)) {
     889             :                         zval_dtor(return_value);
     890           0 :                                 RETURN_FALSE;
     891             :                         }
     892             : #else
     893             :                         res_init();
     894             : #endif
     895             : 
     896           0 :                         n = php_dns_search(handle, hostname, C_IN, type_to_fetch, answer.qb2, sizeof answer);
     897             : 
     898           0 :                         if (n < 0) {
     899           0 :                                 php_dns_free_handle(handle);
     900           0 :                                 continue;
     901             :                         }
     902             : 
     903           0 :                         cp = answer.qb2 + HFIXEDSZ;
     904           0 :                         end = answer.qb2 + n;
     905           0 :                         hp = (HEADER *)&answer;
     906           0 :                         qd = ntohs(hp->qdcount);
     907           0 :                         an = ntohs(hp->ancount);
     908           0 :                         ns = ntohs(hp->nscount);
     909           0 :                         ar = ntohs(hp->arcount);
     910             : 
     911             :                         /* Skip QD entries, they're only used by dn_expand later on */
     912           0 :                         while (qd-- > 0) {
     913           0 :                                 n = dn_skipname(cp, end);
     914           0 :                                 if (n < 0) {
     915           0 :                                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to parse DNS data received");
     916             :                                         zval_dtor(return_value);
     917           0 :                                         php_dns_free_handle(handle);
     918           0 :                                         RETURN_FALSE;
     919             :                                 }
     920           0 :                                 cp += n + QFIXEDSZ;
     921             :                         }
     922             : 
     923             :                         /* YAY! Our real answers! */
     924           0 :                         while (an-- && cp && cp < end) {
     925             :                                 zval *retval;
     926             : 
     927           0 :                                 cp = php_parserr(cp, end, &answer, type_to_fetch, store_results, raw, &retval);
     928           0 :                                 if (retval != NULL && store_results) {
     929           0 :                                         add_next_index_zval(return_value, retval);
     930             :                                 }
     931             :                         }
     932             : 
     933           0 :                         if (authns || addtl) {
     934             :                                 /* List of Authoritative Name Servers
     935             :                                  * Process when only requesting addtl so that we can skip through the section
     936             :                                  */
     937           0 :                                 while (ns-- > 0 && cp && cp < end) {
     938           0 :                                         zval *retval = NULL;
     939             : 
     940           0 :                                         cp = php_parserr(cp, end, &answer, DNS_T_ANY, authns != NULL, raw, &retval);
     941           0 :                                         if (retval != NULL) {
     942           0 :                                                 add_next_index_zval(authns, retval);
     943             :                                         }
     944             :                                 }
     945             :                         }
     946             : 
     947           0 :                         if (addtl) {
     948             :                                 /* Additional records associated with authoritative name servers */
     949           0 :                                 while (ar-- > 0 && cp && cp < end) {
     950           0 :                                         zval *retval = NULL;
     951             : 
     952           0 :                                         cp = php_parserr(cp, end, &answer, DNS_T_ANY, 1, raw, &retval);
     953           0 :                                         if (retval != NULL) {
     954           0 :                                                 add_next_index_zval(addtl, retval);
     955             :                                         }
     956             :                                 }
     957             :                         }
     958           0 :                         php_dns_free_handle(handle);
     959             :                 }
     960             :         }
     961             : }
     962             : /* }}} */
     963             : 
     964             : /* {{{ proto bool dns_get_mx(string hostname, array mxhosts [, array weight])
     965             :    Get MX records corresponding to a given Internet host name */
     966           2 : PHP_FUNCTION(dns_get_mx)
     967             : {
     968             :         char *hostname;
     969             :         int hostname_len;
     970           2 :         zval *mx_list, *weight_list = NULL;
     971             :         int count, qdc;
     972             :         u_short type, weight;
     973             :         u_char ans[MAXPACKET];
     974             :         char buf[MAXHOSTNAMELEN];
     975             :         HEADER *hp;
     976             :         u_char *cp, *end;
     977             :         int i;
     978             : #if defined(HAVE_DNS_SEARCH)
     979             :         struct sockaddr_storage from;
     980             :         uint32_t fromsize = sizeof(from);
     981             :         dns_handle_t handle;
     982             : #elif defined(HAVE_RES_NSEARCH)
     983             :         struct __res_state state;
     984           2 :         struct __res_state *handle = &state;
     985             : #endif
     986             : 
     987           2 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
     988           0 :                 return;
     989             :         }
     990             : 
     991           2 :         zval_dtor(mx_list);
     992           2 :         array_init(mx_list);
     993             : 
     994           2 :         if (weight_list) {
     995           2 :                 zval_dtor(weight_list);
     996           2 :                 array_init(weight_list);
     997             :         }
     998             : 
     999             : #if defined(HAVE_DNS_SEARCH)
    1000             :         handle = dns_open(NULL);
    1001             :         if (handle == NULL) {
    1002             :                 RETURN_FALSE;
    1003             :         }
    1004             : #elif defined(HAVE_RES_NSEARCH)
    1005           2 :     memset(&state, 0, sizeof(state));
    1006           2 :     if (res_ninit(handle)) {
    1007           0 :                         RETURN_FALSE;
    1008             :         }
    1009             : #else
    1010             :         res_init();
    1011             : #endif
    1012             : 
    1013           2 :         i = php_dns_search(handle, hostname, C_IN, DNS_T_MX, (u_char *)&ans, sizeof(ans));
    1014           2 :         if (i < 0) {
    1015           0 :                 RETURN_FALSE;
    1016             :         }
    1017           2 :         if (i > (int)sizeof(ans)) {
    1018           0 :                 i = sizeof(ans);
    1019             :         }
    1020           2 :         hp = (HEADER *)&ans;
    1021           2 :         cp = (u_char *)&ans + HFIXEDSZ;
    1022           2 :         end = (u_char *)&ans +i;
    1023           4 :         for (qdc = ntohs((unsigned short)hp->qdcount); qdc--; cp += i + QFIXEDSZ) {
    1024           2 :                 if ((i = dn_skipname(cp, end)) < 0 ) {
    1025           0 :                         php_dns_free_handle(handle);
    1026           0 :                         RETURN_FALSE;
    1027             :                 }
    1028             :         }
    1029           2 :         count = ntohs((unsigned short)hp->ancount);
    1030           7 :         while (--count >= 0 && cp < end) {
    1031           3 :                 if ((i = dn_skipname(cp, end)) < 0 ) {
    1032           0 :                         php_dns_free_handle(handle);
    1033           0 :                         RETURN_FALSE;
    1034             :                 }
    1035           3 :                 cp += i;
    1036           3 :                 GETSHORT(type, cp);
    1037           3 :                 cp += INT16SZ + INT32SZ;
    1038           3 :                 GETSHORT(i, cp);
    1039           3 :                 if (type != DNS_T_MX) {
    1040           0 :                         cp += i;
    1041           0 :                         continue;
    1042             :                 }
    1043           3 :                 GETSHORT(weight, cp);
    1044           3 :                 if ((i = dn_expand(ans, end, cp, buf, sizeof(buf)-1)) < 0) {
    1045           0 :                         php_dns_free_handle(handle);
    1046           0 :                         RETURN_FALSE;
    1047             :                 }
    1048           3 :                 cp += i;
    1049           3 :                 add_next_index_string(mx_list, buf, 1);
    1050           3 :                 if (weight_list) {
    1051           3 :                         add_next_index_long(weight_list, weight);
    1052             :                 }
    1053             :         }
    1054           2 :         php_dns_free_handle(handle);
    1055           2 :         RETURN_TRUE;
    1056             : }
    1057             : /* }}} */
    1058             : #endif /* HAVE_FULL_DNS_FUNCS */
    1059             : #endif /* !defined(PHP_WIN32) && (HAVE_DNS_SEARCH_FUNC && !(defined(__BEOS__) || defined(NETWARE))) */
    1060             : 
    1061             : #if HAVE_FULL_DNS_FUNCS || defined(PHP_WIN32)
    1062       20225 : PHP_MINIT_FUNCTION(dns) {
    1063       20225 :         REGISTER_LONG_CONSTANT("DNS_A",     PHP_DNS_A,     CONST_CS | CONST_PERSISTENT);
    1064       20225 :         REGISTER_LONG_CONSTANT("DNS_NS",    PHP_DNS_NS,    CONST_CS | CONST_PERSISTENT);
    1065       20225 :         REGISTER_LONG_CONSTANT("DNS_CNAME", PHP_DNS_CNAME, CONST_CS | CONST_PERSISTENT);
    1066       20225 :         REGISTER_LONG_CONSTANT("DNS_SOA",   PHP_DNS_SOA,   CONST_CS | CONST_PERSISTENT);
    1067       20225 :         REGISTER_LONG_CONSTANT("DNS_PTR",   PHP_DNS_PTR,   CONST_CS | CONST_PERSISTENT);
    1068       20225 :         REGISTER_LONG_CONSTANT("DNS_HINFO", PHP_DNS_HINFO, CONST_CS | CONST_PERSISTENT);
    1069       20225 :         REGISTER_LONG_CONSTANT("DNS_MX",    PHP_DNS_MX,    CONST_CS | CONST_PERSISTENT);
    1070       20225 :         REGISTER_LONG_CONSTANT("DNS_TXT",   PHP_DNS_TXT,   CONST_CS | CONST_PERSISTENT);
    1071       20225 :         REGISTER_LONG_CONSTANT("DNS_SRV",   PHP_DNS_SRV,   CONST_CS | CONST_PERSISTENT);
    1072       20225 :         REGISTER_LONG_CONSTANT("DNS_NAPTR", PHP_DNS_NAPTR, CONST_CS | CONST_PERSISTENT);
    1073       20225 :         REGISTER_LONG_CONSTANT("DNS_AAAA",  PHP_DNS_AAAA,  CONST_CS | CONST_PERSISTENT);
    1074       20225 :         REGISTER_LONG_CONSTANT("DNS_A6",    PHP_DNS_A6,    CONST_CS | CONST_PERSISTENT);
    1075       20225 :         REGISTER_LONG_CONSTANT("DNS_ANY",   PHP_DNS_ANY,   CONST_CS | CONST_PERSISTENT);
    1076       20225 :         REGISTER_LONG_CONSTANT("DNS_ALL",   PHP_DNS_ALL,   CONST_CS | CONST_PERSISTENT);
    1077       20225 :         return SUCCESS;
    1078             : }
    1079             : #endif /* HAVE_FULL_DNS_FUNCS */
    1080             : 
    1081             : /*
    1082             :  * Local variables:
    1083             :  * tab-width: 4
    1084             :  * c-basic-offset: 4
    1085             :  * End:
    1086             :  * vim600: sw=4 ts=4 fdm=marker
    1087             :  * vim<600: sw=4 ts=4
    1088             :  */

Generated by: LCOV version 1.10

Generated at Sun, 21 Sep 2014 15:27:45 +0000 (38 hours ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.