ldns-1.9.2/0000775000175000017500000000000015212267540012035 5ustar willemwillemldns-1.9.2/README0000664000175000017500000000671015212267520012717 0ustar willemwillemDEVELOPMENT VISION Note: ldns has been in maintenance mode since 2020, with no plans for major features. We welcome PRs from contributors who want to add new functionality. We also actively fix bugs, so users can continue to rely on ldns if its current features meet their needs. We will continue to make occasional use of ldns in an experimental setting, such as during an IETF Hackathon to build a proof of concept for an Internet Draft. The natural successor to the ldns library is the domain library for Rust: https://github.com/NLnetLabs/domain We offer drop-in replacements for commonly used ldns example tools in dnst: https://github.com/NLnetLabs/dnst --- Contents: REQUIREMENTS INSTALLATION libdns examples drill INFORMATION FOR SPECIFIC OPERATING SYSTEMS Mac OS X Solaris KNOWN ISSUES pyldns Project page: http://www.nlnetlabs.nl/ldns/ On that page you can also subscribe to the ldns mailing list. * Development ldns is mainly developed on Linux and FreeBSD. It is regularly tested to compile on other systems like Solaris and Mac OS X. REQUIREMENTS - OpenSSL (Optional, but needed for features like DNSSEC) - OpenSSL >= 0.9.7f for DANE support - OpenSSL >= 1.0.0 for ECDSA and GOST support - libpcap (Optional, but needed for examples/ldns-dpa) - (GNU) libtool (in OSX, that's glibtool, not libtool) - GNU make INSTALLATION 1. Unpack the tarball 2. cd ldns- 3. ./configure --with-examples --with-drill (optionally compile python bindings too with: --with-pyldns) 4. make 5. make install * Building from repository If you are building from the repository you will need to have (gnu) autotools like libtool and autoreconf installed. A list of all the commands needed to build everything can be found in README.git. Note that the actual commands may be a little bit different on your machine. Most notably, you'll need to run libtoolize (or glibtoolize). If you skip this step, you'll get an error about missing config.sub. * Developers ldns is developed by the ldns team at NLnet Labs. This team currently consists of: o Willem Toorop o Wouter Wijngaards Former main developers: o Jelte Jansen o Miek Gieben o Matthijs Mekking * Credits We have received patches from the following people, thanks! o Bedrich Kosata o Erik Rozendaal o Håkan Olsson o Jakob Schlyter o Paul Wouters o Simon Vallet o Ondřej Surý o Karel Slany o Havard Eidnes o Leo Baltus o Dag-Erling Smørgrav o Felipe Gasper INFORMATION FOR SPECIFIC OPERATING SYSTEMS MAC OS X For MACOSX 10.4 and later, it seems that you have to set the MACOSX_DEPLOYMENT_TARGET environment variable to 10.4 before running make. Apparently it defaults to 10.1. This appears to be a known problem in 10.2 to 10.4, see: http://developer.apple.com/qa/qa2001/qa1233.html for more information. SOLARIS In Solaris multi-architecture systems (which have both 32-bit and 64-bit support), it can be a bit taxing to convince the system to compile in 64-bit mode. Jakob Schlyter has kindly contributed a build script that sets the right build and link options. You can find it in contrib/build-solaris.sh KNOWN ISSUES A complete list of currently known open issues can be found here: https://github.com/NLnetLabs/ldns/issues * pyldns Compiling pyldns produces many ``unused parameter'' warnings. Those are harmless and may safely be ignored. Also, when building with SWIG older than 2.0.4, compiling pyldns produces many ``missing initializer'' warnings. Those are harmless too. ldns-1.9.2/compat/0000775000175000017500000000000015212267520013316 5ustar willemwillemldns-1.9.2/compat/ctime_r.c0000664000175000017500000000040615212267520015104 0ustar willemwillem#ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_TIME_H #include #endif char *ctime_r(const time_t *timep, char *buf) { /* no thread safety. */ char* result = ctime(timep); if(buf && result) strcpy(buf, result); return result; } ldns-1.9.2/compat/timegm.c0000664000175000017500000000063615212267520014751 0ustar willemwillem#ifdef HAVE_CONFIG_H #include #endif #include #ifdef HAVE_STDLIB_H #include #endif #include time_t timegm (struct tm *tm) { time_t ret; char *tz; tz = getenv("TZ"); putenv((char*)"TZ="); tzset(); ret = mktime(tm); if (tz) { char buf[256]; snprintf(buf, sizeof(buf), "TZ=%s", tz); putenv(tz); } else putenv((char*)"TZ"); tzset(); return ret; } ldns-1.9.2/compat/malloc.c0000664000175000017500000000061515212267520014733 0ustar willemwillem/* Just a replacement, if the original malloc is not GNU-compliant. See autoconf documentation. */ #if HAVE_CONFIG_H #include #endif #undef malloc #include void *malloc (size_t n); /* Allocate an N-byte block of memory from the heap. If N is zero, allocate a 1-byte block. */ void * rpl_malloc (size_t n) { if (n == 0) n = 1; return malloc (n); } ldns-1.9.2/compat/inet_ntop.c0000664000175000017500000001276015212267520015467 0ustar willemwillem/* From openssh 4.3p2 compat/inet_ntop.c */ /* Copyright (c) 1996 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* OPENBSD ORIGINAL: lib/libc/net/inet_ntop.c */ #include #ifndef HAVE_INET_NTOP #include #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #include #include #include #ifndef IN6ADDRSZ #define IN6ADDRSZ 16 /* IPv6 T_AAAA */ #endif #ifndef INT16SZ #define INT16SZ 2 /* for systems without 16-bit ints */ #endif /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static const char *inet_ntop4(const u_char *src, char *dst, size_t size); static const char *inet_ntop6(const u_char *src, char *dst, size_t size); /* char * * inet_ntop(af, src, dst, size) * convert a network format address to presentation format. * return: * pointer to presentation format address (`dst'), or NULL (see errno). * author: * Paul Vixie, 1996. */ const char * inet_ntop(int af, const void *src, char *dst, size_t size) { switch (af) { case AF_INET: return (inet_ntop4(src, dst, size)); case AF_INET6: return (inet_ntop6(src, dst, size)); default: #ifdef EAFNOSUPPORT errno = EAFNOSUPPORT; #else errno = ENOSYS; #endif return (NULL); } /* NOTREACHED */ } /* const char * * inet_ntop4(src, dst, size) * format an IPv4 address, more or less like inet_ntoa() * return: * `dst' (as a const) * notes: * (1) uses no statics * (2) takes a u_char* not an in_addr as input * author: * Paul Vixie, 1996. */ static const char * inet_ntop4(const u_char *src, char *dst, size_t size) { static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; int l; l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]); if (l <= 0 || l >= (int)size) { errno = ENOSPC; return (NULL); } strlcpy(dst, tmp, size); return (dst); } /* const char * * inet_ntop6(src, dst, size) * convert IPv6 binary address into presentation (printable) format * author: * Paul Vixie, 1996. */ static const char * inet_ntop6(const u_char *src, char *dst, size_t size) { /* * Note that int32_t and int16_t need only be "at least" large enough * to contain a value of the specified size. On some systems, like * Crays, there is no such thing as an integer variable with 16 bits. * Keep this in mind if you think this function should have been coded * to use pointer overlays. All the world's not a VAX. */ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; char *tp, *ep; struct { int base, len; } best, cur; u_int words[IN6ADDRSZ / INT16SZ]; int i; int advance; /* * Preprocess: * Copy the input (bytewise) array into a wordwise array. * Find the longest run of 0x00's in src[] for :: shorthanding. */ memset(words, '\0', sizeof words); for (i = 0; i < IN6ADDRSZ; i++) words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); best.base = -1; best.len = 0; cur.base = -1; cur.len = 0; for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { if (words[i] == 0) { if (cur.base == -1) cur.base = i, cur.len = 1; else cur.len++; } else { if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; cur.base = -1; } } } if (cur.base != -1) { if (best.base == -1 || cur.len > best.len) best = cur; } if (best.base != -1 && best.len < 2) best.base = -1; /* * Format the result. */ tp = tmp; ep = tmp + sizeof(tmp); for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) { /* Are we inside the best run of 0x00's? */ if (best.base != -1 && i >= best.base && i < (best.base + best.len)) { if (i == best.base) { if (tp + 1 >= ep) return (NULL); *tp++ = ':'; } continue; } /* Are we following an initial run of 0x00s or any real hex? */ if (i != 0) { if (tp + 1 >= ep) return (NULL); *tp++ = ':'; } /* Is this address an encapsulated IPv4? */ if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { if (!inet_ntop4(src+12, tp, (size_t)(ep - tp))) return (NULL); tp += strlen(tp); break; } advance = snprintf(tp, ep - tp, "%x", words[i]); if (advance <= 0 || advance >= ep - tp) return (NULL); tp += advance; } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) { if (tp + 1 >= ep) return (NULL); *tp++ = ':'; } if (tp + 1 >= ep) return (NULL); *tp++ = '\0'; /* * Check for overflow, copy, and we're done. */ if ((size_t)(tp - tmp) > size) { errno = ENOSPC; return (NULL); } strlcpy(dst, tmp, size); return (dst); } #endif /* !HAVE_INET_NTOP */ ldns-1.9.2/compat/fake-rfc2553.h0000664000175000017500000001241115212267520015463 0ustar willemwillem/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */ /* * Copyright (C) 2000-2003 Damien Miller. All rights reserved. * Copyright (C) 1999 WIDE Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Pseudo-implementation of RFC2553 name / address resolution functions * * But these functions are not implemented correctly. The minimum subset * is implemented for ssh use only. For example, this routine assumes * that ai_family is AF_INET. Don't use it for another purpose. */ #ifndef _FAKE_RFC2553_H #define _FAKE_RFC2553_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* * First, socket and INET6 related definitions */ #ifndef HAVE_STRUCT_SOCKADDR_STORAGE #ifndef _SS_MAXSIZE # define _SS_MAXSIZE 128 /* Implementation specific max size */ # define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) struct sockaddr_storage { struct sockaddr ss_sa; char __ss_pad2[_SS_PADSIZE]; }; # define ss_family ss_sa.sa_family #endif /* _SS_MAXSIZE */ #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ #ifndef IN6_IS_ADDR_LOOPBACK # define IN6_IS_ADDR_LOOPBACK(a) \ (((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \ ((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1)) #endif /* !IN6_IS_ADDR_LOOPBACK */ #ifndef HAVE_STRUCT_IN6_ADDR struct in6_addr { uint8_t s6_addr[16]; }; #endif /* !HAVE_STRUCT_IN6_ADDR */ #ifndef HAVE_STRUCT_SOCKADDR_IN6 struct sockaddr_in6 { unsigned short sin6_family; uint16_t sin6_port; uint32_t sin6_flowinfo; struct in6_addr sin6_addr; }; #endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ #ifndef AF_INET6 /* Define it to something that should never appear */ #define AF_INET6 AF_MAX #endif /* * Next, RFC2553 name / address resolution API */ #ifndef NI_NUMERICHOST # define NI_NUMERICHOST (1) #endif #ifndef NI_NAMEREQD # define NI_NAMEREQD (1<<1) #endif #ifndef NI_NUMERICSERV # define NI_NUMERICSERV (1<<2) #endif #ifndef AI_PASSIVE # define AI_PASSIVE (1) #endif #ifndef AI_CANONNAME # define AI_CANONNAME (1<<1) #endif #ifndef AI_NUMERICHOST # define AI_NUMERICHOST (1<<2) #endif #ifndef NI_MAXSERV # define NI_MAXSERV 32 #endif /* !NI_MAXSERV */ #ifndef NI_MAXHOST # define NI_MAXHOST 1025 #endif /* !NI_MAXHOST */ #ifndef INT_MAX #define INT_MAX 0xffffffff #endif #ifndef EAI_NODATA # define EAI_NODATA (INT_MAX - 1) #endif #ifndef EAI_MEMORY # define EAI_MEMORY (INT_MAX - 2) #endif #ifndef EAI_NONAME # define EAI_NONAME (INT_MAX - 3) #endif #ifndef EAI_SYSTEM # define EAI_SYSTEM (INT_MAX - 4) #endif #ifndef HAVE_STRUCT_ADDRINFO struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ int ai_family; /* PF_xxx */ int ai_socktype; /* SOCK_xxx */ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ size_t ai_addrlen; /* length of ai_addr */ char *ai_canonname; /* canonical name for hostname */ struct sockaddr *ai_addr; /* binary address */ struct addrinfo *ai_next; /* next structure in linked list */ }; #endif /* !HAVE_STRUCT_ADDRINFO */ #ifndef HAVE_GETADDRINFO #ifdef getaddrinfo # undef getaddrinfo #endif #define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d)) int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **); #endif /* !HAVE_GETADDRINFO */ #if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO) #define gai_strerror(a) (ssh_gai_strerror(a)) char *gai_strerror(int); #endif /* !HAVE_GAI_STRERROR */ #ifndef HAVE_FREEADDRINFO #define freeaddrinfo(a) (ssh_freeaddrinfo(a)) void freeaddrinfo(struct addrinfo *); #endif /* !HAVE_FREEADDRINFO */ #ifndef HAVE_GETNAMEINFO #define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g)) int getnameinfo(const struct sockaddr *, size_t, char *, size_t, char *, size_t, int); #endif /* !HAVE_GETNAMEINFO */ #ifdef __cplusplus } #endif #endif /* !_FAKE_RFC2553_H */ ldns-1.9.2/compat/strlcpy.c0000664000175000017500000000321215212267520015160 0ustar willemwillem/* from openssh 4.3p2 compat/strlcpy.c */ /* * Copyright (c) 1998 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */ #include #ifndef HAVE_STRLCPY #include #include /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */ } #endif /* !HAVE_STRLCPY */ ldns-1.9.2/compat/asctime_r.c0000664000175000017500000000040715212267520015431 0ustar willemwillem#ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_TIME_H #include #endif char *asctime_r(const struct tm *tm, char *buf) { /* no thread safety. */ char* result = asctime(tm); if(buf && result) strcpy(buf, result); return result; } ldns-1.9.2/compat/isblank.c0000664000175000017500000000037715212267520015114 0ustar willemwillem/* Just a replacement, if the original isblank is not present */ #if HAVE_CONFIG_H #include #endif int isblank(int c); /* true if character is a blank (space or tab). C99. */ int isblank(int c) { return (c == ' ') || (c == '\t'); } ldns-1.9.2/compat/isascii.c0000664000175000017500000000034115212267520015104 0ustar willemwillem/* Just a replacement, if the original isascii is not present */ #if HAVE_CONFIG_H #include #endif int isascii(int c); /* true if character is ascii. */ int isascii(int c) { return c >= 0 && c < 128; } ldns-1.9.2/compat/b64_ntop.c0000664000175000017500000001637615212267520015132 0ustar willemwillem/* * Copyright (c) 1996, 1998 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* * Portions Copyright (c) 1995 by International Business Machines, Inc. * * International Business Machines, Inc. (hereinafter called IBM) grants * permission under its copyrights to use, copy, modify, and distribute this * Software with or without fee, provided that the above copyright notice and * all paragraphs of this notice appear in all copies, and that the name of IBM * not be used in connection with the marketing of any product incorporating * the Software or modifications thereof, without specific, written prior * permission. * * To the extent it has a right to do so, IBM grants an immunity from suit * under its patents, if any, for the use, sale or manufacture of products to * the extent that such products are used for performing Domain Name System * dynamic updates in TCP/IP networks by means of the Software. No immunity is * granted for any product per se or for any other function of any product. * * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ #include #include #include #include static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; /* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) The following encoding technique is taken from RFC 1521 by Borenstein and Freed. It is reproduced here in a slightly edited form for convenience. A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character. (The extra 65th character, "=", is used to signify a special processing function.) The encoding process represents 24-bit groups of input bits as output strings of 4 encoded characters. Proceeding from left to right, a 24-bit input group is formed by concatenating 3 8-bit input groups. These 24 bits are then treated as 4 concatenated 6-bit groups, each of which is translated into a single digit in the base64 alphabet. Each 6-bit group is used as an index into an array of 64 printable characters. The character referenced by the index is placed in the output string. Table 1: The Base64 Alphabet Value Encoding Value Encoding Value Encoding Value Encoding 0 A 17 R 34 i 51 z 1 B 18 S 35 j 52 0 2 C 19 T 36 k 53 1 3 D 20 U 37 l 54 2 4 E 21 V 38 m 55 3 5 F 22 W 39 n 56 4 6 G 23 X 40 o 57 5 7 H 24 Y 41 p 58 6 8 I 25 Z 42 q 59 7 9 J 26 a 43 r 60 8 10 K 27 b 44 s 61 9 11 L 28 c 45 t 62 + 12 M 29 d 46 u 63 / 13 N 30 e 47 v 14 O 31 f 48 w (pad) = 15 P 32 g 49 x 16 Q 33 h 50 y Special processing is performed if fewer than 24 bits are available at the end of the data being encoded. A full encoding quantum is always completed at the end of a quantity. When fewer than 24 input bits are available in an input group, zero bits are added (on the right) to form an integral number of 6-bit groups. Padding at the end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the ------------------------------------------------- following cases can arise: (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding, (2) the final quantum of encoding input is exactly 8 bits; here, the final unit of encoded output will be two characters followed by two "=" padding characters, or (3) the final quantum of encoding input is exactly 16 bits; here, the final unit of encoded output will be three characters followed by one "=" padding character. */ int ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) { size_t datalength = 0; uint8_t input[3]; uint8_t output[4]; size_t i; if (srclength == 0) { if (targsize > 0) { target[0] = '\0'; return 0; } else { return -1; } } while (2 < srclength) { input[0] = *src++; input[1] = *src++; input[2] = *src++; srclength -= 3; output[0] = input[0] >> 2; output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); output[3] = input[2] & 0x3f; assert(output[0] < 64); assert(output[1] < 64); assert(output[2] < 64); assert(output[3] < 64); if (datalength + 4 > targsize) { return (-1); } target[datalength++] = Base64[output[0]]; target[datalength++] = Base64[output[1]]; target[datalength++] = Base64[output[2]]; target[datalength++] = Base64[output[3]]; } /* Now we worry about padding. */ if (0 != srclength) { /* Get what's left. */ input[0] = input[1] = input[2] = (uint8_t) '\0'; for (i = 0; i < srclength; i++) input[i] = *src++; output[0] = input[0] >> 2; output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); assert(output[0] < 64); assert(output[1] < 64); assert(output[2] < 64); if (datalength + 4 > targsize) { return (-2); } target[datalength++] = Base64[output[0]]; target[datalength++] = Base64[output[1]]; if (srclength == 1) { target[datalength++] = Pad64; } else { target[datalength++] = Base64[output[2]]; } target[datalength++] = Pad64; } if (datalength >= targsize) { return (-3); } target[datalength] = '\0'; /* Returned value doesn't count \0. */ return (int) (datalength); } ldns-1.9.2/compat/gmtime_r.c0000664000175000017500000000034715212267520015271 0ustar willemwillem#ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_TIME_H #include #endif struct tm *gmtime_r(const time_t *timep, struct tm *result) { /* no thread safety. */ *result = *gmtime(timep); return result; } ldns-1.9.2/compat/inet_aton.c0000664000175000017500000001252415212267520015446 0ustar willemwillem/* From openssh4.3p2 compat/inet_aton.c */ /* * Copyright (c) 1983, 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ /* OPENBSD ORIGINAL: lib/libc/net/inet_addr.c */ #include #if !defined(HAVE_INET_ATON) #include #include #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #include #if 0 /* * Ascii internet address interpretation routine. * The value returned is in network order. */ in_addr_t inet_addr(const char *cp) { struct in_addr val; if (inet_aton(cp, &val)) return (val.s_addr); return (INADDR_NONE); } #endif /* * Check whether "cp" is a valid ascii representation * of an Internet address and convert to a binary address. * Returns 1 if the address is valid, 0 if not. * This replaces inet_addr, the return value from which * cannot distinguish between failure and a local broadcast address. */ int inet_aton(const char *cp, struct in_addr *addr) { uint32_t val; int base, n; char c; unsigned int parts[4]; unsigned int *pp = parts; c = *cp; for (;;) { /* * Collect number up to ``.''. * Values are specified as for C: * 0x=hex, 0=octal, isdigit=decimal. */ if (!isdigit((int) c)) return (0); val = 0; base = 10; if (c == '0') { c = *++cp; if (c == 'x' || c == 'X') base = 16, c = *++cp; else base = 8; } for (;;) { if (isascii((int) c) && isdigit((int) c)) { val = (val * base) + (c - '0'); c = *++cp; } else if (base == 16 && isascii((int) c) && isxdigit((int) c)) { val = (val << 4) | (c + 10 - (islower((int) c) ? 'a' : 'A')); c = *++cp; } else break; } if (c == '.') { /* * Internet format: * a.b.c.d * a.b.c (with c treated as 16 bits) * a.b (with b treated as 24 bits) */ if (pp >= parts + 3) return (0); *pp++ = val; c = *++cp; } else break; } /* * Check for trailing characters. */ if (c != '\0' && (!isascii((int) c) || !isspace((int) c))) return (0); /* * Concoct the address according to * the number of parts specified. */ n = pp - parts + 1; switch (n) { case 0: return (0); /* initial nondigit */ case 1: /* a -- 32 bits */ break; case 2: /* a.b -- 8.24 bits */ if ((val > 0xffffff) || (parts[0] > 0xff)) return (0); val |= parts[0] << 24; break; case 3: /* a.b.c -- 8.8.16 bits */ if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff)) return (0); val |= (parts[0] << 24) | (parts[1] << 16); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff)) return (0); val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); break; } if (addr) addr->s_addr = htonl(val); return (1); } #endif /* !defined(HAVE_INET_ATON) */ ldns-1.9.2/compat/fake-rfc2553.c0000664000175000017500000001411115212267520015455 0ustar willemwillem/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */ /* * Copyright (C) 2000-2003 Damien Miller. All rights reserved. * Copyright (C) 1999 WIDE Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * Pseudo-implementation of RFC2553 name / address resolution functions * * But these functions are not implemented correctly. The minimum subset * is implemented for ssh use only. For example, this routine assumes * that ai_family is AF_INET. Don't use it for another purpose. */ #include #include #include #include #include #include #include "compat/fake-rfc2553.h" #ifndef HAVE_GETNAMEINFO int getnameinfo(const struct sockaddr *sa, size_t ATTR_UNUSED(salen), char *host, size_t hostlen, char *serv, size_t servlen, int flags) { struct sockaddr_in *sin = (struct sockaddr_in *)sa; struct hostent *hp; char tmpserv[16]; if (serv != NULL) { snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); if (strlcpy(serv, tmpserv, servlen) >= servlen) return (EAI_MEMORY); } if (host != NULL) { if (flags & NI_NUMERICHOST) { if (strlcpy(host, inet_ntoa(sin->sin_addr), hostlen) >= hostlen) return (EAI_MEMORY); else return (0); } else { hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); if (hp == NULL) return (EAI_NODATA); if (strlcpy(host, hp->h_name, hostlen) >= hostlen) return (EAI_MEMORY); else return (0); } } return (0); } #endif /* !HAVE_GETNAMEINFO */ #ifndef HAVE_GAI_STRERROR #ifdef HAVE_CONST_GAI_STRERROR_PROTO const char * #else char * #endif gai_strerror(int err) { switch (err) { case EAI_NODATA: return ("no address associated with name"); case EAI_MEMORY: return ("memory allocation failure."); case EAI_NONAME: return ("nodename nor servname provided, or not known"); default: return ("unknown/invalid error."); } } #endif /* !HAVE_GAI_STRERROR */ #ifndef HAVE_FREEADDRINFO void freeaddrinfo(struct addrinfo *ai) { struct addrinfo *next; for(; ai != NULL;) { next = ai->ai_next; free(ai); ai = next; } } #endif /* !HAVE_FREEADDRINFO */ #ifndef HAVE_GETADDRINFO static struct addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) { struct addrinfo *ai; ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in)); if (ai == NULL) return (NULL); memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); ai->ai_addr = (struct sockaddr *)(ai + 1); /* XXX -- ssh doesn't use sa_len */ ai->ai_addrlen = sizeof(struct sockaddr_in); ai->ai_addr->sa_family = ai->ai_family = AF_INET; ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; /* XXX: the following is not generally correct, but does what we want */ if (hints->ai_socktype) ai->ai_socktype = hints->ai_socktype; else ai->ai_socktype = SOCK_STREAM; if (hints->ai_protocol) ai->ai_protocol = hints->ai_protocol; return (ai); } int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { struct hostent *hp; struct servent *sp; struct in_addr in; int i; long int port; u_long addr; port = 0; if (servname != NULL) { char *cp; port = strtol(servname, &cp, 10); if (port > 0 && port <= 65535 && *cp == '\0') port = htons(port); else if ((sp = getservbyname(servname, NULL)) != NULL) port = sp->s_port; else port = 0; } if (hints && hints->ai_flags & AI_PASSIVE) { addr = htonl(0x00000000); if (hostname && inet_aton(hostname, &in) != 0) addr = in.s_addr; *res = malloc_ai(port, addr, hints); if (*res == NULL) return (EAI_MEMORY); return (0); } if (!hostname) { *res = malloc_ai(port, htonl(0x7f000001), hints); if (*res == NULL) return (EAI_MEMORY); return (0); } if (inet_aton(hostname, &in)) { *res = malloc_ai(port, in.s_addr, hints); if (*res == NULL) return (EAI_MEMORY); return (0); } /* Don't try DNS if AI_NUMERICHOST is set */ if (hints && hints->ai_flags & AI_NUMERICHOST) return (EAI_NONAME); hp = gethostbyname(hostname); if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { struct addrinfo *cur, *prev; cur = prev = *res = NULL; for (i = 0; hp->h_addr_list[i]; i++) { struct in_addr *in = (struct in_addr *)hp->h_addr_list[i]; cur = malloc_ai(port, in->s_addr, hints); if (cur == NULL) { if (*res != NULL) freeaddrinfo(*res); return (EAI_MEMORY); } if (prev) prev->ai_next = cur; else *res = cur; prev = cur; } return (0); } return (EAI_NODATA); } #endif /* !HAVE_GETADDRINFO */ ldns-1.9.2/compat/inet_pton.c0000664000175000017500000001223215212267520015461 0ustar willemwillem/* $KAME: inet_pton.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */ /* Copyright (c) 1996 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #include #include #include /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ static int inet_pton4 (const char *src, uint8_t *dst); static int inet_pton6 (const char *src, uint8_t *dst); /* * * The definitions we might miss. * */ #ifndef NS_INT16SZ #define NS_INT16SZ 2 #endif #ifndef NS_IN6ADDRSZ #define NS_IN6ADDRSZ 16 #endif #ifndef NS_INADDRSZ #define NS_INADDRSZ 4 #endif /* int * inet_pton(af, src, dst) * convert from presentation format (which usually means ASCII printable) * to network format (which is usually some kind of binary format). * return: * 1 if the address was valid for the specified address family * 0 if the address wasn't valid (`dst' is untouched in this case) * -1 if some other error occurred (`dst' is untouched in this case, too) * author: * Paul Vixie, 1996. */ int inet_pton(af, src, dst) int af; const char *src; void *dst; { switch (af) { case AF_INET: return (inet_pton4(src, dst)); case AF_INET6: return (inet_pton6(src, dst)); default: #ifdef EAFNOSUPPORT errno = EAFNOSUPPORT; #else errno = ENOSYS; #endif return (-1); } /* NOTREACHED */ } /* int * inet_pton4(src, dst) * like inet_aton() but without all the hexadecimal and shorthand. * return: * 1 if `src' is a valid dotted quad, else 0. * notice: * does not touch `dst' unless it's returning 1. * author: * Paul Vixie, 1996. */ static int inet_pton4(src, dst) const char *src; uint8_t *dst; { static const char digits[] = "0123456789"; int saw_digit, octets, ch; uint8_t tmp[NS_INADDRSZ], *tp; saw_digit = 0; octets = 0; *(tp = tmp) = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr(digits, ch)) != NULL) { uint32_t new = *tp * 10 + (pch - digits); if (new > 255) return (0); *tp = new; if (! saw_digit) { if (++octets > 4) return (0); saw_digit = 1; } } else if (ch == '.' && saw_digit) { if (octets == 4) return (0); *++tp = 0; saw_digit = 0; } else return (0); } if (octets < 4) return (0); memcpy(dst, tmp, NS_INADDRSZ); return (1); } /* int * inet_pton6(src, dst) * convert presentation level address to network order binary form. * return: * 1 if `src' is a valid [RFC1884 2.2] address, else 0. * notice: * (1) does not touch `dst' unless it's returning 1. * (2) :: in a full address is silently ignored. * credit: * inspired by Mark Andrews. * author: * Paul Vixie, 1996. */ static int inet_pton6(src, dst) const char *src; uint8_t *dst; { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; uint8_t tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; uint32_t val; memset((tp = tmp), '\0', NS_IN6ADDRSZ); endp = tp + NS_IN6ADDRSZ; colonp = NULL; /* Leading :: requires some special handling. */ if (*src == ':') if (*++src != ':') return (0); curtok = src; saw_xdigit = 0; val = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) pch = strchr((xdigits = xdigits_u), ch); if (pch != NULL) { val <<= 4; val |= (pch - xdigits); if (val > 0xffff) return (0); saw_xdigit = 1; continue; } if (ch == ':') { curtok = src; if (!saw_xdigit) { if (colonp) return (0); colonp = tp; continue; } if (tp + NS_INT16SZ > endp) return (0); *tp++ = (uint8_t) (val >> 8) & 0xff; *tp++ = (uint8_t) val & 0xff; saw_xdigit = 0; val = 0; continue; } if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) { tp += NS_INADDRSZ; saw_xdigit = 0; break; /* '\0' was seen by inet_pton4(). */ } return (0); } if (saw_xdigit) { if (tp + NS_INT16SZ > endp) return (0); *tp++ = (uint8_t) (val >> 8) & 0xff; *tp++ = (uint8_t) val & 0xff; } if (colonp != NULL) { /* * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ const int n = tp - colonp; int i; for (i = 1; i <= n; i++) { endp[- i] = colonp[n - i]; colonp[n - i] = 0; } tp = endp; } if (tp != endp) return (0); memcpy(dst, tmp, NS_IN6ADDRSZ); return (1); } ldns-1.9.2/compat/snprintf.c0000664000175000017500000007124615212267520015337 0ustar willemwillem/* snprintf - compatibility implementation of snprintf, vsnprintf * * Copyright (c) 2013, NLnet Labs. All rights reserved. * * This software is open source. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #ifdef HAVE_STDINT_H #include #endif /* for test */ /* #define SNPRINTF_TEST 1 */ #ifdef SNPRINTF_TEST #define snprintf my_snprintf #define vsnprintf my_vsnprintf #endif /* SNPRINTF_TEST */ int snprintf(char* str, size_t size, const char* format, ...); int vsnprintf(char* str, size_t size, const char* format, va_list arg); /** * Very portable snprintf implementation, limited in functionality, * esp. for %[capital] %[nonportable] and so on. Reduced float functionality, * mostly in formatting and range (e+-16), for %f and %g. * * %s, %d, %u, %i, %x, %c, %n and %% are fully supported. * This includes width, precision, flags 0- +, and *(arg for wid,prec). * %f, %g, %m, %p have reduced support, support for wid,prec,flags,*, but * less floating point range, no %e formatting for %g. */ int snprintf(char* str, size_t size, const char* format, ...) { int r; va_list args; va_start(args, format); r = vsnprintf(str, size, format, args); va_end(args); return r; } /** add padding to string */ static void print_pad(char** at, size_t* left, int* ret, char p, int num) { while(num--) { if(*left > 1) { *(*at)++ = p; (*left)--; } (*ret)++; } } /** get negative symbol, 0 if none */ static char get_negsign(int negative, int plus, int space) { if(negative) return '-'; if(plus) return '+'; if(space) return ' '; return 0; } #define PRINT_DEC_BUFSZ 32 /* 20 is enough for 64 bit decimals */ /** print decimal into buffer, returns length */ static int print_dec(char* buf, int max, unsigned int value) { int i = 0; if(value == 0) { if(max > 0) { buf[0] = '0'; i = 1; } } else while(value && i < max) { buf[i++] = '0' + value % 10; value /= 10; } return i; } /** print long decimal into buffer, returns length */ static int print_dec_l(char* buf, int max, unsigned long value) { int i = 0; if(value == 0) { if(max > 0) { buf[0] = '0'; i = 1; } } else while(value && i < max) { buf[i++] = '0' + value % 10; value /= 10; } return i; } /** print long decimal into buffer, returns length */ static int print_dec_ll(char* buf, int max, unsigned long long value) { int i = 0; if(value == 0) { if(max > 0) { buf[0] = '0'; i = 1; } } else while(value && i < max) { buf[i++] = '0' + value % 10; value /= 10; } return i; } /** print hex into buffer, returns length */ static int print_hex(char* buf, int max, unsigned int value) { const char* h = "0123456789abcdef"; int i = 0; if(value == 0) { if(max > 0) { buf[0] = '0'; i = 1; } } else while(value && i < max) { buf[i++] = h[value & 0x0f]; value >>= 4; } return i; } /** print long hex into buffer, returns length */ static int print_hex_l(char* buf, int max, unsigned long value) { const char* h = "0123456789abcdef"; int i = 0; if(value == 0) { if(max > 0) { buf[0] = '0'; i = 1; } } else while(value && i < max) { buf[i++] = h[value & 0x0f]; value >>= 4; } return i; } /** print long long hex into buffer, returns length */ static int print_hex_ll(char* buf, int max, unsigned long long value) { const char* h = "0123456789abcdef"; int i = 0; if(value == 0) { if(max > 0) { buf[0] = '0'; i = 1; } } else while(value && i < max) { buf[i++] = h[value & 0x0f]; value >>= 4; } return i; } /** copy string into result, reversed */ static void spool_str_rev(char** at, size_t* left, int* ret, const char* buf, int len) { int i = len; while(i) { if(*left > 1) { *(*at)++ = buf[--i]; (*left)--; } else --i; (*ret)++; } } /** copy string into result */ static void spool_str(char** at, size_t* left, int* ret, const char* buf, int len) { int i; for(i=0; i 1) { *(*at)++ = buf[i]; (*left)--; } (*ret)++; } } /** print number formatted */ static void print_num(char** at, size_t* left, int* ret, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space, int zero, int negative, char* buf, int len) { int w = len; /* excludes minus sign */ char s = get_negsign(negative, plus, space); if(minus) { /* left adjust the number into the field, space padding */ /* calc numw = [sign][zeroes][number] */ int numw = w; if(precision == 0 && zero) numw = 0; if(numw < precision) numw = precision; if(s) numw++; /* sign */ if(s) print_pad(at, left, ret, s, 1); /* number */ if(precision == 0 && zero) { /* "" for the number */ } else { if(w < precision) print_pad(at, left, ret, '0', precision - w); spool_str_rev(at, left, ret, buf, len); } /* spaces */ if(numw < minw) print_pad(at, left, ret, ' ', minw - numw); } else { /* pad on the left of the number */ /* calculate numw has width of [sign][zeroes][number] */ int numw = w; if(precision == 0 && zero) numw = 0; if(numw < precision) numw = precision; if(!prgiven && zeropad && numw < minw) numw = minw; else if(s) numw++; /* pad with spaces */ if(numw < minw) print_pad(at, left, ret, ' ', minw - numw); /* print sign (and one less zeropad if so) */ if(s) { print_pad(at, left, ret, s, 1); numw--; } /* pad with zeroes */ if(w < numw) print_pad(at, left, ret, '0', numw - w); if(precision == 0 && zero) return; /* print the characters for the value */ spool_str_rev(at, left, ret, buf, len); } } /** print %d and %i */ static void print_num_d(char** at, size_t* left, int* ret, int value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = (value < 0); int zero = (value == 0); int len = print_dec(buf, (int)sizeof(buf), (unsigned int)(negative?-value:value)); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %ld and %li */ static void print_num_ld(char** at, size_t* left, int* ret, long value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = (value < 0); int zero = (value == 0); int len = print_dec_l(buf, (int)sizeof(buf), (unsigned long)(negative?-value:value)); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %lld and %lli */ static void print_num_lld(char** at, size_t* left, int* ret, long long value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = (value < 0); int zero = (value == 0); int len = print_dec_ll(buf, (int)sizeof(buf), (unsigned long long)(negative?-value:value)); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %u */ static void print_num_u(char** at, size_t* left, int* ret, unsigned int value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); int len = print_dec(buf, (int)sizeof(buf), value); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %lu */ static void print_num_lu(char** at, size_t* left, int* ret, unsigned long value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); int len = print_dec_l(buf, (int)sizeof(buf), value); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %llu */ static void print_num_llu(char** at, size_t* left, int* ret, unsigned long long value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); int len = print_dec_ll(buf, (int)sizeof(buf), value); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %x */ static void print_num_x(char** at, size_t* left, int* ret, unsigned int value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); int len = print_hex(buf, (int)sizeof(buf), value); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %lx */ static void print_num_lx(char** at, size_t* left, int* ret, unsigned long value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); int len = print_hex_l(buf, (int)sizeof(buf), value); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %llx */ static void print_num_llx(char** at, size_t* left, int* ret, unsigned long long value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); int len = print_hex_ll(buf, (int)sizeof(buf), value); print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } /** print %llp */ static void print_num_llp(char** at, size_t* left, int* ret, void* value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_DEC_BUFSZ]; int negative = 0; int zero = (value == 0); #if defined(UINTPTR_MAX) && defined(UINT32_MAX) && (UINTPTR_MAX == UINT32_MAX) /* avoid warning about upcast on 32bit systems */ unsigned long long llvalue = (unsigned long)value; #else unsigned long long llvalue = (unsigned long long)value; #endif int len = print_hex_ll(buf, (int)sizeof(buf), llvalue); if(zero) { buf[0]=')'; buf[1]='l'; buf[2]='i'; buf[3]='n'; buf[4]='('; len = 5; } else { /* put '0x' in front of the (reversed) buffer result */ if(len < PRINT_DEC_BUFSZ) buf[len++] = 'x'; if(len < PRINT_DEC_BUFSZ) buf[len++] = '0'; } print_num(at, left, ret, minw, precision, prgiven, zeropad, minus, plus, space, zero, negative, buf, len); } #define PRINT_FLOAT_BUFSZ 64 /* xx.yy with 20.20 about the max */ /** spool remainder after the decimal point to buffer, in reverse */ static int print_remainder(char* buf, int max, double r, int prec) { unsigned long long cap = 1; unsigned long long value; int len, i; if(prec > 19) prec = 19; /* max we can do */ if(max < prec) return 0; for(i=0; i= 5) { value++; /* that might carry to numbers before the comma, if so, * just ignore that rounding. failure because 64bitprintout */ if(value >= cap) value = cap-1; } len = print_dec_ll(buf, max, value); while(len < prec) { /* pad with zeroes, e.g. if 0.0012 */ buf[len++] = '0'; } if(len < max) buf[len++] = '.'; return len; } /** spool floating point to buffer */ static int print_float(char* buf, int max, double value, int prec) { /* as xxx.xxx if prec==0, no '.', with prec decimals after . */ /* no conversion for NAN and INF, because we do not want to require linking with -lm. */ /* Thus, the conversions use 64bit integers to convert the numbers, * which makes 19 digits before and after the decimal point the max */ unsigned long long whole = (unsigned long long)value; double remain = value - (double)whole; int len = 0; if(prec != 0) len = print_remainder(buf, max, remain, prec); len += print_dec_ll(buf+len, max-len, whole); return len; } /** print %f */ static void print_num_f(char** at, size_t* left, int* ret, double value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_FLOAT_BUFSZ]; int negative = (value < 0); int zero = 0; int len; if(!prgiven) precision = 6; len = print_float(buf, (int)sizeof(buf), negative?-value:value, precision); print_num(at, left, ret, minw, 1, 0, zeropad, minus, plus, space, zero, negative, buf, len); } /* rudimentary %g support */ static int print_float_g(char* buf, int max, double value, int prec) { unsigned long long whole = (unsigned long long)value; double remain = value - (double)whole; int before = 0; int len = 0; /* number of digits before the decimal point */ while(whole > 0) { before++; whole /= 10; } whole = (unsigned long long)value; if(prec > before && remain != 0.0) { /* see if the last decimals are zero, if so, skip them */ len = print_remainder(buf, max, remain, prec-before); while(len > 0 && buf[0]=='0') { memmove(buf, buf+1, --len); } } len += print_dec_ll(buf+len, max-len, whole); return len; } /** print %g */ static void print_num_g(char** at, size_t* left, int* ret, double value, int minw, int precision, int prgiven, int zeropad, int minus, int plus, int space) { char buf[PRINT_FLOAT_BUFSZ]; int negative = (value < 0); int zero = 0; int len; if(!prgiven) precision = 6; if(precision == 0) precision = 1; len = print_float_g(buf, (int)sizeof(buf), negative?-value:value, precision); print_num(at, left, ret, minw, 1, 0, zeropad, minus, plus, space, zero, negative, buf, len); } /** strnlen (compat implementation) */ static int my_strnlen(const char* s, int max) { int i; for(i=0; i 1) { *at++ = *fmt++; left--; } else fmt++; ret++; } /* see if we are at end */ if(!*fmt) break; /* fetch next argument % designation from format string */ fmt++; /* skip the '%' */ /********************************/ /* get the argument designation */ /********************************/ /* we must do this vararg stuff inside this function for * portability. Hence, get_designation, and print_designation * are not their own functions. */ /* printout designation: * conversion specifier: x, d, u, s, c, n, m, p * flags: # not supported * 0 zeropad (on the left) * - left adjust (right by default) * ' ' printspace for positive number (in - position). * + alwayssign * fieldwidth: [1-9][0-9]* minimum field width. * if this is * then type int next argument specifies the minwidth. * if this is negative, the - flag is set (with positive width). * precision: period[digits]*, %.2x. * if this is * then type int next argument specifies the precision. * just '.' or negative value means precision=0. * this is mindigits to print for d, i, u, x * this is aftercomma digits for f * this is max number significant digits for g * maxnumber characters to be printed for s * length: 0-none (int), 1-l (long), 2-ll (long long) * notsupported: hh (char), h (short), L (long double), q, j, z, t * Does not support %m$ and *m$ argument designation as array indices. * Does not support %#x * */ minw = 0; precision = 1; prgiven = 0; zeropad = 0; minus = 0; plus = 0; space = 0; length = 0; /* get flags in any order */ for(;;) { if(*fmt == '0') zeropad = 1; else if(*fmt == '-') minus = 1; else if(*fmt == '+') plus = 1; else if(*fmt == ' ') space = 1; else break; fmt++; } /* field width */ if(*fmt == '*') { fmt++; /* skip char */ minw = va_arg(arg, int); if(minw < 0) { minus = 1; minw = -minw; } } else while(*fmt >= '0' && *fmt <= '9') { minw = minw*10 + (*fmt++)-'0'; } /* precision */ if(*fmt == '.') { fmt++; /* skip period */ prgiven = 1; precision = 0; if(*fmt == '*') { fmt++; /* skip char */ precision = va_arg(arg, int); if(precision < 0) precision = 0; } else while(*fmt >= '0' && *fmt <= '9') { precision = precision*10 + (*fmt++)-'0'; } } /* length */ if(*fmt == 'l') { fmt++; /* skip char */ length = 1; if(*fmt == 'l') { fmt++; /* skip char */ length = 2; } } /* get the conversion */ if(!*fmt) conv = 0; else conv = *fmt++; /***********************************/ /* print that argument designation */ /***********************************/ switch(conv) { case 'i': case 'd': if(length == 0) print_num_d(&at, &left, &ret, va_arg(arg, int), minw, precision, prgiven, zeropad, minus, plus, space); else if(length == 1) print_num_ld(&at, &left, &ret, va_arg(arg, long), minw, precision, prgiven, zeropad, minus, plus, space); else if(length == 2) print_num_lld(&at, &left, &ret, va_arg(arg, long long), minw, precision, prgiven, zeropad, minus, plus, space); break; case 'u': if(length == 0) print_num_u(&at, &left, &ret, va_arg(arg, unsigned int), minw, precision, prgiven, zeropad, minus, plus, space); else if(length == 1) print_num_lu(&at, &left, &ret, va_arg(arg, unsigned long), minw, precision, prgiven, zeropad, minus, plus, space); else if(length == 2) print_num_llu(&at, &left, &ret, va_arg(arg, unsigned long long), minw, precision, prgiven, zeropad, minus, plus, space); break; case 'x': if(length == 0) print_num_x(&at, &left, &ret, va_arg(arg, unsigned int), minw, precision, prgiven, zeropad, minus, plus, space); else if(length == 1) print_num_lx(&at, &left, &ret, va_arg(arg, unsigned long), minw, precision, prgiven, zeropad, minus, plus, space); else if(length == 2) print_num_llx(&at, &left, &ret, va_arg(arg, unsigned long long), minw, precision, prgiven, zeropad, minus, plus, space); break; case 's': print_str(&at, &left, &ret, va_arg(arg, char*), minw, precision, prgiven, minus); break; case 'c': print_char(&at, &left, &ret, va_arg(arg, int), minw, minus); break; case 'n': *va_arg(arg, int*) = ret; break; case 'm': print_str(&at, &left, &ret, strerror(errno), minw, precision, prgiven, minus); break; case 'p': print_num_llp(&at, &left, &ret, va_arg(arg, void*), minw, precision, prgiven, zeropad, minus, plus, space); break; case '%': print_pad(&at, &left, &ret, '%', 1); break; case 'f': print_num_f(&at, &left, &ret, va_arg(arg, double), minw, precision, prgiven, zeropad, minus, plus, space); break; case 'g': print_num_g(&at, &left, &ret, va_arg(arg, double), minw, precision, prgiven, zeropad, minus, plus, space); break; /* unknown */ default: case 0: break; } } /* zero terminate */ if(left > 0) *at = 0; return ret; } #ifdef SNPRINTF_TEST /** do tests */ #undef snprintf #define DOTEST(bufsz, result, retval, ...) do { \ char buf[bufsz]; \ printf("now test %s\n", #__VA_ARGS__); \ int r=my_snprintf(buf, sizeof(buf), __VA_ARGS__); \ if(r != retval || strcmp(buf, result) != 0) { \ printf("error test(%s) was \"%s\":%d\n", \ ""#bufsz", "#result", "#retval", "#__VA_ARGS__, \ buf, r); \ exit(1); \ } \ r=snprintf(buf, sizeof(buf), __VA_ARGS__); \ if(r != retval || strcmp(buf, result) != 0) { \ printf("error test(%s) differs with system, \"%s\":%d\n", \ ""#bufsz", "#result", "#retval", "#__VA_ARGS__, \ buf, r); \ exit(1); \ } \ printf("test(\"%s\":%d) passed\n", buf, r); \ } while(0); /** test program */ int main(void) { int x = 0; /* bufsize, expectedstring, expectedretval, snprintf arguments */ DOTEST(1024, "hello", 5, "hello"); DOTEST(1024, "h", 1, "h"); /* warning from gcc for format string, but it does work * DOTEST(1024, "", 0, ""); */ DOTEST(3, "he", 5, "hello"); DOTEST(1, "", 7, "%d", 7823089); /* test positive numbers */ DOTEST(1024, "0", 1, "%d", 0); DOTEST(1024, "1", 1, "%d", 1); DOTEST(1024, "9", 1, "%d", 9); DOTEST(1024, "15", 2, "%d", 15); DOTEST(1024, "ab15cd", 6, "ab%dcd", 15); DOTEST(1024, "167", 3, "%d", 167); DOTEST(1024, "7823089", 7, "%d", 7823089); DOTEST(1024, " 12", 3, "%3d", 12); DOTEST(1024, "012", 3, "%.3d", 12); DOTEST(1024, "012", 3, "%3.3d", 12); DOTEST(1024, "012", 3, "%03d", 12); DOTEST(1024, " 012", 4, "%4.3d", 12); DOTEST(1024, "", 0, "%.0d", 0); /* test negative numbers */ DOTEST(1024, "-1", 2, "%d", -1); DOTEST(1024, "-12", 3, "%3d", -12); DOTEST(1024, " -2", 3, "%3d", -2); DOTEST(1024, "-012", 4, "%.3d", -12); DOTEST(1024, "-012", 4, "%3.3d", -12); DOTEST(1024, "-012", 4, "%4.3d", -12); DOTEST(1024, " -012", 5, "%5.3d", -12); DOTEST(1024, "-12", 3, "%03d", -12); DOTEST(1024, "-02", 3, "%03d", -2); DOTEST(1024, "-15", 3, "%d", -15); DOTEST(1024, "-7307", 5, "%d", -7307); DOTEST(1024, "-12 ", 5, "%-5d", -12); DOTEST(1024, "-00012", 6, "%-.5d", -12); /* test + and space flags */ DOTEST(1024, "+12", 3, "%+d", 12); DOTEST(1024, " 12", 3, "% d", 12); /* test %u */ DOTEST(1024, "12", 2, "%u", 12); DOTEST(1024, "0", 1, "%u", 0); DOTEST(1024, "4294967295", 10, "%u", 0xffffffff); /* test %x */ DOTEST(1024, "0", 1, "%x", 0); DOTEST(1024, "c", 1, "%x", 12); DOTEST(1024, "12ab34cd", 8, "%x", 0x12ab34cd); /* test %llu, %lld */ DOTEST(1024, "18446744073709551615", 20, "%llu", (long long)0xffffffffffffffff); DOTEST(1024, "-9223372036854775808", 20, "%lld", (long long)0x8000000000000000); DOTEST(1024, "9223372036854775808", 19, "%llu", (long long)0x8000000000000000); /* test %s */ DOTEST(1024, "hello", 5, "%s", "hello"); DOTEST(1024, " hello", 10, "%10s", "hello"); DOTEST(1024, "hello ", 10, "%-10s", "hello"); DOTEST(1024, "he", 2, "%.2s", "hello"); DOTEST(1024, " he", 4, "%4.2s", "hello"); DOTEST(1024, " h", 4, "%4.2s", "h"); /* test %c */ DOTEST(1024, "a", 1, "%c", 'a'); /* warning from gcc for format string, but it does work DOTEST(1024, " a", 5, "%5c", 'a'); DOTEST(1024, "a", 1, "%.0c", 'a'); */ /* test %n */ DOTEST(1024, "hello", 5, "hello%n", &x); if(x != 5) { printf("the %%n failed\n"); exit(1); } /* test %m */ errno = 0; DOTEST(1024, "Success", 7, "%m"); /* test %p */ DOTEST(1024, "0x10", 4, "%p", (void*)0x10); DOTEST(1024, "(nil)", 5, "%p", (void*)0x0); /* test %% */ DOTEST(1024, "%", 1, "%%"); /* test %f */ DOTEST(1024, "0.000000", 8, "%f", 0.0); DOTEST(1024, "0.00", 4, "%.2f", 0.0); /* differs, "-0.00" DOTEST(1024, "0.00", 4, "%.2f", -0.0); */ DOTEST(1024, "234.00", 6, "%.2f", 234.005); DOTEST(1024, "8973497.1246", 12, "%.4f", 8973497.12456); DOTEST(1024, "-12.000000", 10, "%f", -12.0); DOTEST(1024, "6", 1, "%.0f", 6.0); DOTEST(1024, "6", 1, "%g", 6.0); DOTEST(1024, "6.1", 3, "%g", 6.1); DOTEST(1024, "6.15", 4, "%g", 6.15); /* These format strings are from the code of NSD, Unbound, ldns */ DOTEST(1024, "abcdef", 6, "%s", "abcdef"); DOTEST(1024, "005", 3, "%03u", 5); DOTEST(1024, "12345", 5, "%03u", 12345); DOTEST(1024, "5", 1, "%d", 5); DOTEST(1024, "(nil)", 5, "%p", NULL); DOTEST(1024, "12345", 5, "%ld", (long)12345); DOTEST(1024, "12345", 5, "%lu", (long)12345); DOTEST(1024, " 12345", 12, "%12u", (unsigned)12345); DOTEST(1024, "12345", 5, "%u", (unsigned)12345); DOTEST(1024, "12345", 5, "%llu", (unsigned long long)12345); DOTEST(1024, "12345", 5, "%x", 0x12345); DOTEST(1024, "12345", 5, "%llx", (long long)0x12345); DOTEST(1024, "012345", 6, "%6.6d", 12345); DOTEST(1024, "012345", 6, "%6.6u", 12345); DOTEST(1024, "1234.54", 7, "%g", 1234.54); DOTEST(1024, "123456789.54", 12, "%.12g", 123456789.54); DOTEST(1024, "3456789123456.54", 16, "%.16g", 3456789123456.54); /* %24g does not work with 24 digits, not enough accuracy, * the first 16 digits are correct */ DOTEST(1024, "12345", 5, "%3.3d", 12345); DOTEST(1024, "000", 3, "%3.3d", 0); DOTEST(1024, "001", 3, "%3.3d", 1); DOTEST(1024, "012", 3, "%3.3d", 12); DOTEST(1024, "-012", 4, "%3.3d", -12); DOTEST(1024, "he", 2, "%.2s", "hello"); DOTEST(1024, "helloworld", 10, "%s%s", "hello", "world"); DOTEST(1024, "he", 2, "%.*s", 2, "hello"); DOTEST(1024, " hello", 7, "%*s", 7, "hello"); DOTEST(1024, "hello ", 7, "%*s", -7, "hello"); DOTEST(1024, "0", 1, "%c", '0'); DOTEST(1024, "A", 1, "%c", 'A'); DOTEST(1024, "", 1, "%c", 0); DOTEST(1024, "\010", 1, "%c", 8); DOTEST(1024, "%", 1, "%%"); DOTEST(1024, "0a", 2, "%02x", 0x0a); DOTEST(1024, "bd", 2, "%02x", 0xbd); DOTEST(1024, "12", 2, "%02ld", (long)12); DOTEST(1024, "02", 2, "%02ld", (long)2); DOTEST(1024, "02", 2, "%02u", (unsigned)2); DOTEST(1024, "765432", 6, "%05u", (unsigned)765432); DOTEST(1024, "10.234", 6, "%0.3f", 10.23421); DOTEST(1024, "123456.234", 10, "%0.3f", 123456.23421); DOTEST(1024, "123456789.234", 13, "%0.3f", 123456789.23421); DOTEST(1024, "123456.23", 9, "%.2f", 123456.23421); DOTEST(1024, "123456", 6, "%.0f", 123456.23421); DOTEST(1024, "0123", 4, "%.4x", 0x0123); DOTEST(1024, "00000123", 8, "%.8x", 0x0123); DOTEST(1024, "ffeb0cde", 8, "%.8x", 0xffeb0cde); DOTEST(1024, " 987654321", 10, "%10lu", (unsigned long)987654321); DOTEST(1024, " 987654321", 12, "%12lu", (unsigned long)987654321); DOTEST(1024, "987654321", 9, "%i", 987654321); DOTEST(1024, "-87654321", 9, "%i", -87654321); DOTEST(1024, "hello ", 16, "%-16s", "hello"); DOTEST(1024, " ", 16, "%-16s", ""); DOTEST(1024, "a ", 16, "%-16s", "a"); DOTEST(1024, "foobarfoobar ", 16, "%-16s", "foobarfoobar"); DOTEST(1024, "foobarfoobarfoobar", 18, "%-16s", "foobarfoobarfoobar"); /* combined expressions */ DOTEST(1024, "foo 1.0 size 512 edns", 21, "foo %s size %d %s%s", "1.0", 512, "", "edns"); DOTEST(15, "foo 1.0 size 5", 21, "foo %s size %d %s%s", "1.0", 512, "", "edns"); DOTEST(1024, "packet 1203ceff id", 18, "packet %2.2x%2.2x%2.2x%2.2x id", 0x12, 0x03, 0xce, 0xff); DOTEST(1024, "/tmp/testbound_123abcd.tmp", 26, "/tmp/testbound_%u%s%s.tmp", 123, "ab", "cd"); return 0; } #endif /* SNPRINTF_TEST */ ldns-1.9.2/compat/realloc.c0000664000175000017500000000106715212267520015107 0ustar willemwillem/* Just a replacement, if the original malloc is not GNU-compliant. Based on malloc.c */ #if HAVE_CONFIG_H #include #endif #undef realloc #include void *realloc (void*, size_t); void *malloc (size_t); /* Changes allocation to new sizes, copies over old data. * if oldptr is NULL, does a malloc. * if size is zero, allocate 1-byte block.... * (does not return NULL and free block) */ void * rpl_realloc (void* ptr, size_t n) { if (n == 0) n = 1; if(ptr == 0) { return malloc(n); } return realloc(ptr, n); } ldns-1.9.2/compat/memmove.c0000664000175000017500000000167115212267520015134 0ustar willemwillem/* * memmove.c: memmove compat implementation. * * Copyright (c) 2001-2008, NLnet Labs. All rights reserved. * * See LICENSE for the license. */ #include #include void *memmove(void *dest, const void *src, size_t n); void *memmove(void *dest, const void *src, size_t n) { uint8_t* from = (uint8_t*) src; uint8_t* to = (uint8_t*) dest; if (from == to || n == 0) return dest; if (to > from && to-from < (int)n) { /* to overlaps with from */ /* */ /* */ /* copy in reverse, to avoid overwriting from */ int i; for(i=n-1; i>=0; i--) to[i] = from[i]; return dest; } if (from > to && from-to < (int)n) { /* to overlaps with from */ /* */ /* */ /* copy forwards, to avoid overwriting from */ size_t i; for(i=0; i #endif #ifdef HAVE_TIME_H #include #endif struct tm *localtime_r(const time_t *timep, struct tm *result) { /* no thread safety. */ *result = *localtime(timep); return result; } ldns-1.9.2/compat/calloc.c0000664000175000017500000000063715212267520014725 0ustar willemwillem/* Just a replacement, if the original malloc is not GNU-compliant. See autoconf documentation. */ #if HAVE_CONFIG_H #include #endif void *calloc(); #if !HAVE_BZERO && HAVE_MEMSET # define bzero(buf, bytes) ((void) memset (buf, 0, bytes)) #endif void * calloc(size_t num, size_t size) { void *new = malloc(num * size); if (!new) { return NULL; } bzero(new, num * size); return new; } ldns-1.9.2/compat/b64_pton.c0000664000175000017500000002074515212267520015125 0ustar willemwillem/* * Copyright (c) 1996, 1998 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* * Portions Copyright (c) 1995 by International Business Machines, Inc. * * International Business Machines, Inc. (hereinafter called IBM) grants * permission under its copyrights to use, copy, modify, and distribute this * Software with or without fee, provided that the above copyright notice and * all paragraphs of this notice appear in all copies, and that the name of IBM * not be used in connection with the marketing of any product incorporating * the Software or modifications thereof, without specific, written prior * permission. * * To the extent it has a right to do so, IBM grants an immunity from suit * under its patents, if any, for the use, sale or manufacture of products to * the extent that such products are used for performing Domain Name System * dynamic updates in TCP/IP networks by means of the Software. No immunity is * granted for any product per se or for any other function of any product. * * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ #include #include #include #include static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; /* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) The following encoding technique is taken from RFC 1521 by Borenstein and Freed. It is reproduced here in a slightly edited form for convenience. A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character. (The extra 65th character, "=", is used to signify a special processing function.) The encoding process represents 24-bit groups of input bits as output strings of 4 encoded characters. Proceeding from left to right, a 24-bit input group is formed by concatenating 3 8-bit input groups. These 24 bits are then treated as 4 concatenated 6-bit groups, each of which is translated into a single digit in the base64 alphabet. Each 6-bit group is used as an index into an array of 64 printable characters. The character referenced by the index is placed in the output string. Table 1: The Base64 Alphabet Value Encoding Value Encoding Value Encoding Value Encoding 0 A 17 R 34 i 51 z 1 B 18 S 35 j 52 0 2 C 19 T 36 k 53 1 3 D 20 U 37 l 54 2 4 E 21 V 38 m 55 3 5 F 22 W 39 n 56 4 6 G 23 X 40 o 57 5 7 H 24 Y 41 p 58 6 8 I 25 Z 42 q 59 7 9 J 26 a 43 r 60 8 10 K 27 b 44 s 61 9 11 L 28 c 45 t 62 + 12 M 29 d 46 u 63 / 13 N 30 e 47 v 14 O 31 f 48 w (pad) = 15 P 32 g 49 x 16 Q 33 h 50 y Special processing is performed if fewer than 24 bits are available at the end of the data being encoded. A full encoding quantum is always completed at the end of a quantity. When fewer than 24 input bits are available in an input group, zero bits are added (on the right) to form an integral number of 6-bit groups. Padding at the end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the ------------------------------------------------- following cases can arise: (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding, (2) the final quantum of encoding input is exactly 8 bits; here, the final unit of encoded output will be two characters followed by two "=" padding characters, or (3) the final quantum of encoding input is exactly 16 bits; here, the final unit of encoded output will be three characters followed by one "=" padding character. */ /* skips all whitespace anywhere. converts characters, four at a time, starting at (or after) src from base - 64 numbers into three 8 bit bytes in the target area. it returns the number of data bytes stored at the target, or -1 on error. */ int ldns_b64_pton(char const *origsrc, uint8_t *target, size_t targsize) { unsigned char const* src = (unsigned char*)origsrc; int tarindex, state, ch; char *pos; state = 0; tarindex = 0; if (strlen(origsrc) == 0) { return 0; } while ((ch = *src++) != '\0') { if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */ continue; if (ch == Pad64) break; pos = strchr(Base64, ch); if (pos == 0) { /* A non-base64 character. */ return (-1); } switch (state) { case 0: if (target) { if ((size_t)tarindex >= targsize) return (-1); target[tarindex] = (pos - Base64) << 2; } state = 1; break; case 1: if (target) { if ((size_t)tarindex + 1 >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 4; target[tarindex+1] = ((pos - Base64) & 0x0f) << 4 ; } tarindex++; state = 2; break; case 2: if (target) { if ((size_t)tarindex + 1 >= targsize) return (-1); target[tarindex] |= (pos - Base64) >> 2; target[tarindex+1] = ((pos - Base64) & 0x03) << 6; } tarindex++; state = 3; break; case 3: if (target) { if ((size_t)tarindex >= targsize) return (-1); target[tarindex] |= (pos - Base64); } tarindex++; state = 0; break; default: abort(); } } /* * We are done decoding Base-64 chars. Let's see if we ended * on a byte boundary, and/or with erroneous trailing characters. */ if (ch == Pad64) { /* We got a pad char. */ ch = *src++; /* Skip it, get next. */ switch (state) { case 0: /* Invalid = in first position */ case 1: /* Invalid = in second position */ return (-1); case 2: /* Valid, means one byte of info */ /* Skip any number of spaces. */ for ((void)NULL; ch != '\0'; ch = *src++) if (!isspace((unsigned char)ch)) break; /* Make sure there is another trailing = sign. */ if (ch != Pad64) return (-1); ch = *src++; /* Skip the = */ /* Fall through to "single trailing =" case. */ /* FALLTHROUGH */ case 3: /* Valid, means two bytes of info */ /* * We know this char is an =. Is there anything but * whitespace after it? */ for ((void)NULL; ch != '\0'; ch = *src++) if (!isspace((unsigned char)ch)) return (-1); /* * Now make sure for cases 2 and 3 that the "extra" * bits that slopped past the last full byte were * zeros. If we don't check them, they become a * subliminal channel. */ if (target && target[tarindex] != 0) return (-1); } } else { /* * We ended by seeing the end of the string. Make sure we * have no partial bytes lying around. */ if (state != 0) return (-1); } return (tarindex); } ldns-1.9.2/config.guess0000775000175000017500000014342415212050264014356 0ustar willemwillem#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2026 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale timestamp='2026-05-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to . # The "shellcheck disable" line above the timestamp inhibits complaints # about features and limitations of the classic Bourne shell that were # superseded or lifted in POSIX. However, this script identifies a wide # variety of pre-POSIX systems that do not have POSIX shells at all, and # even some reasonably current systems (Solaris 10 as case-in-point) still # have a pre-POSIX /bin/sh. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2026 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi # Just in case it came from the environment. GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still # use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. tmp= # shellcheck disable=SC2172 trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" # shellcheck disable=SC2039,SC3028 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" for driver in cc gcc c17 c99 c89 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD=$driver break fi done if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac } # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case $UNAME_SYSTEM in Ironclad|Linux|GNU|GNU/*) LIBC=unknown set_cc_for_build cat <<-EOF > "$dummy.c" #if defined(__ANDROID__) LIBC=android #else #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu #elif defined(__LLVM_LIBC__) LIBC=llvm #elif defined(__mlibc__) LIBC=mlibc #else #include /* First heuristic to detect musl libc. */ #ifdef __DEFINED_va_list LIBC=musl #endif #endif #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" # Second heuristic to detect musl libc. if [ "$LIBC" = unknown ] && command -v ldd >/dev/null && ldd --version 2>&1 | grep -q ^musl; then LIBC=musl fi # If the system lacks a compiler, then just pick glibc. # We could probably try harder. if [ "$LIBC" = unknown ]; then LIBC=gnu fi ;; esac # Note: order is significant - the case branches are not exclusive. case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` case $UNAME_MACHINE_ARCH in aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case $UNAME_VERSION in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. GUESS=$machine-${os}${release}${abi-} ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE ;; *:SecBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE ;; *:MidnightBSD:*:*) GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE ;; *:ekkoBSD:*:*) GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE ;; *:SolidBSD:*:*) GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE ;; *:OS108:*:*) GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE ;; macppc:MirBSD:*:*) GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE ;; *:MirBSD:*:*) GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE ;; *:Sortix:*:*) GUESS=$UNAME_MACHINE-unknown-sortix ;; *:Twizzler:*:*) GUESS=$UNAME_MACHINE-unknown-twizzler ;; *:Redox:*:*) GUESS=$UNAME_MACHINE-unknown-redox ;; mips:OSF1:*.*) GUESS=mips-dec-osf1 ;; alpha:OSF1:*:*) # Reset EXIT trap before exiting to avoid spurious non-zero exit code. trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` GUESS=$UNAME_MACHINE-dec-osf$OSF_REL ;; Amiga*:UNIX_System_V:4.0:*) GUESS=m68k-unknown-sysv4 ;; *:[Aa]miga[Oo][Ss]:*:*) GUESS=$UNAME_MACHINE-unknown-amigaos ;; *:[Mm]orph[Oo][Ss]:*:*) GUESS=$UNAME_MACHINE-unknown-morphos ;; *:OS/390:*:*) GUESS=i370-ibm-openedition ;; *:z/VM:*:*) GUESS=s390-ibm-zvmoe ;; *:OS400:*:*) GUESS=powerpc-ibm-os400 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) GUESS=arm-acorn-riscix$UNAME_RELEASE ;; arm*:riscos:*:*|arm*:RISCOS:*:*) GUESS=arm-unknown-riscos ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) GUESS=hppa1.1-hitachi-hiuxmpp ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. case `(/bin/universe) 2>/dev/null` in att) GUESS=pyramid-pyramid-sysv3 ;; *) GUESS=pyramid-pyramid-bsd ;; esac ;; NILE*:*:*:dcosx) GUESS=pyramid-pyramid-svr4 ;; DRS?6000:unix:4.0:6*) GUESS=sparc-icl-nx6 ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) GUESS=sparc-icl-nx7 ;; esac ;; s390x:SunOS:*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL ;; sun4H:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-hal-solaris2$SUN_REL ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-sun-solaris2$SUN_REL ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) GUESS=i386-pc-auroraux$UNAME_RELEASE ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=$SUN_ARCH-pc-solaris2$SUN_REL ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=sparc-sun-solaris3$SUN_REL ;; sun4*:SunOS:*:*) case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; sun3*:SunOS:*:*) GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case `/bin/arch` in sun3) GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac ;; aushp:SunOS:*:*) GUESS=sparc-auspex-sunos$UNAME_RELEASE ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) GUESS=m68k-atari-mint$UNAME_RELEASE ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) GUESS=m68k-milan-mint$UNAME_RELEASE ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) GUESS=m68k-hades-mint$UNAME_RELEASE ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) GUESS=m68k-unknown-mint$UNAME_RELEASE ;; m68k:machten:*:*) GUESS=m68k-apple-machten$UNAME_RELEASE ;; powerpc:machten:*:*) GUESS=powerpc-apple-machten$UNAME_RELEASE ;; RISC*:Mach:*:*) GUESS=mips-dec-mach_bsd4.3 ;; RISC*:ULTRIX:*:*) GUESS=mips-dec-ultrix$UNAME_RELEASE ;; VAX*:ULTRIX*:*:*) GUESS=vax-dec-ultrix$UNAME_RELEASE ;; 2020:CLIX:*:* | 2430:CLIX:*:*) GUESS=clipper-intergraph-clix$UNAME_RELEASE ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } GUESS=mips-mips-riscos$UNAME_RELEASE ;; Motorola:PowerMAX_OS:*:*) GUESS=powerpc-motorola-powermax ;; Motorola:*:4.3:PL8-*) GUESS=powerpc-harris-powermax ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) GUESS=powerpc-harris-powermax ;; Night_Hawk:Power_UNIX:*:*) GUESS=powerpc-harris-powerunix ;; m88k:CX/UX:7*:*) GUESS=m88k-harris-cxux7 ;; m88k:*:4*:R4*) GUESS=m88k-motorola-sysv4 ;; m88k:*:3*:R3*) GUESS=m88k-motorola-sysv3 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ test "$TARGET_BINARY_INTERFACE"x = x then GUESS=m88k-dg-dgux$UNAME_RELEASE else GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else GUESS=i586-dg-dgux$UNAME_RELEASE fi ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) GUESS=m88k-dolphin-sysv3 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 GUESS=m88k-motorola-sysv3 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) GUESS=m88k-tektronix-sysv3 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) GUESS=m68k-tektronix-bsd ;; *:IRIX*:*:*) IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` GUESS=mips-sgi-irix$IRIX_REL ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) GUESS=i386-ibm-aix ;; ia64:AIX:*:*) if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include int main () { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then GUESS=$SYSTEM_NAME else GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then GUESS=rs6000-ibm-aix3.2.4 else GUESS=rs6000-ibm-aix3.2 fi ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if test -x /usr/bin/lslpp ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi GUESS=$IBM_ARCH-ibm-aix$IBM_REV ;; *:AIX:*:*) GUESS=rs6000-ibm-aix ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) GUESS=romp-ibm-bsd4.4 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) GUESS=rs6000-bull-bosx ;; DPX/2?00:B.O.S.:*:*) GUESS=m68k-bull-sysv3 ;; 9000/[34]??:4.3bsd:1.*:*) GUESS=m68k-hp-bsd ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) GUESS=m68k-hp-bsd4.4 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` case $UNAME_MACHINE in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if test "$HP_ARCH" = hppa2.0w then set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi GUESS=$HP_ARCH-hp-hpux$HPUX_REV ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` GUESS=ia64-hp-hpux$HPUX_REV ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } GUESS=unknown-hitachi-hiuxwe2 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) GUESS=hppa1.1-hp-bsd ;; 9000/8??:4.3bsd:*:*) GUESS=hppa1.0-hp-bsd ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) GUESS=hppa1.0-hp-mpeix ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) GUESS=hppa1.1-hp-osf ;; hp8??:OSF1:*:*) GUESS=hppa1.0-hp-osf ;; i*86:OSF1:*:*) if test -x /usr/sbin/sysversion ; then GUESS=$UNAME_MACHINE-unknown-osf1mk else GUESS=$UNAME_MACHINE-unknown-osf1 fi ;; parisc*:Lites*:*:*) GUESS=hppa1.1-hp-lites ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) GUESS=c1-convex-bsd ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) GUESS=c34-convex-bsd ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) GUESS=c38-convex-bsd ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) GUESS=c4-convex-bsd ;; CRAY*Y-MP:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=ymp-cray-unicos$CRAY_REL ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=t90-cray-unicos$CRAY_REL ;; CRAY*T3E:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=alphaev5-cray-unicosmk$CRAY_REL ;; CRAY*SV1:*:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=sv1-cray-unicos$CRAY_REL ;; *:UNICOS/mp:*:*) CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` GUESS=craynv-cray-unicosmp$CRAY_REL ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE ;; sparc*:BSD/OS:*:*) GUESS=sparc-unknown-bsdi$UNAME_RELEASE ;; *:BSD/OS:*:*) GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE ;; arm:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` set_cc_for_build if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi else FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf fi ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL ;; i*:CYGWIN*:*) GUESS=$UNAME_MACHINE-pc-cygwin ;; *:MINGW64*:*) GUESS=$UNAME_MACHINE-pc-mingw64 ;; *:MINGW*:*) GUESS=$UNAME_MACHINE-pc-mingw32 ;; *:MSYS*:*) GUESS=$UNAME_MACHINE-pc-msys ;; i*:PW*:*) GUESS=$UNAME_MACHINE-pc-pw32 ;; *:SerenityOS:*:*) GUESS=$UNAME_MACHINE-pc-serenity ;; *:Interix*:*) case $UNAME_MACHINE in x86) GUESS=i586-pc-interix$UNAME_RELEASE ;; authenticamd | genuineintel | EM64T) GUESS=x86_64-unknown-interix$UNAME_RELEASE ;; IA64) GUESS=ia64-unknown-interix$UNAME_RELEASE ;; esac ;; i*:UWIN*:*) GUESS=$UNAME_MACHINE-pc-uwin ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) GUESS=x86_64-pc-cygwin ;; prep*:SunOS:5.*:*) SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` GUESS=powerpcle-unknown-solaris2$SUN_REL ;; *:GNU:*:*) # the GNU system GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL ;; *:GNU/*:*:*) # other systems with GNU libc and userland GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC ;; x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) GUESS="$UNAME_MACHINE-pc-managarm-mlibc" ;; *:[Mm]anagarm:*:*) GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" ;; *:Minix:*:*) GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) set_cc_for_build CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then ABI=64 sed 's/^ //' << EOF > "$dummy.c" #ifdef __ARM_EABI__ #ifdef __ARM_PCS_VFP ABI=eabihf #else ABI=eabi #endif #endif EOF cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` eval "$cc_set_abi" case $ABI in eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; esac fi GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi ;; avr32*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; cris:Linux:*:*) GUESS=$UNAME_MACHINE-axis-linux-$LIBC ;; crisv32:Linux:*:*) GUESS=$UNAME_MACHINE-axis-linux-$LIBC ;; e2k:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; frv:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; hexagon:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; i*86:Linux:*:*) GUESS=$UNAME_MACHINE-pc-linux-$LIBC ;; ia64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; kvx:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; kvx:cos:*:*) GUESS=$UNAME_MACHINE-unknown-cos ;; kvx:mbr:*:*) GUESS=$UNAME_MACHINE-unknown-mbr ;; loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m32r*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m68*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef mips #undef mipsel #undef mips64 #undef mips64el #if ${IS_GLIBC} && defined(_ABI64) LIBCABI=gnuabi64 #else #if ${IS_GLIBC} && defined(_ABIN32) LIBCABI=gnuabin32 #else LIBCABI=${LIBC} #endif #endif #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa64r6 #else #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 CPU=mipsisa32r6 #else #if defined(__mips64) CPU=mips64 #else CPU=mips #endif #endif #endif #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) MIPS_ENDIAN= #else MIPS_ENDIAN= #endif #endif EOF cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` eval "$cc_set_vars" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; openrisc*:Linux:*:*) GUESS=or1k-unknown-linux-$LIBC ;; or32:Linux:*:* | or1k*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; padre:Linux:*:*) GUESS=sparc-unknown-linux-$LIBC ;; parisc64:Linux:*:* | hppa64:Linux:*:*) GUESS=hppa64-unknown-linux-$LIBC ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; *) GUESS=hppa-unknown-linux-$LIBC ;; esac ;; ppc64:Linux:*:*) GUESS=powerpc64-unknown-linux-$LIBC ;; ppc:Linux:*:*) GUESS=powerpc-unknown-linux-$LIBC ;; ppc64le:Linux:*:*) GUESS=powerpc64le-unknown-linux-$LIBC ;; ppcle:Linux:*:*) GUESS=powerpcle-unknown-linux-$LIBC ;; riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; s390:Linux:*:* | s390x:Linux:*:*) GUESS=$UNAME_MACHINE-ibm-linux-$LIBC ;; sh64*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sh*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sparc:Linux:*:* | sparc64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; sw_64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; tile*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; vax:Linux:*:*) GUESS=$UNAME_MACHINE-dec-linux-$LIBC ;; x86_64:Linux:*:*) set_cc_for_build CPU=$UNAME_MACHINE LIBCABI=$LIBC if test "$CC_FOR_BUILD" != no_compiler_found; then ABI=64 sed 's/^ //' << EOF > "$dummy.c" #ifdef __i386__ ABI=x86 #else #ifdef __ILP32__ ABI=x32 #endif #endif EOF cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` eval "$cc_set_abi" case $ABI in x86) CPU=i686 ;; x32) LIBCABI=${LIBC}x32 ;; esac fi GUESS=$CPU-pc-linux-$LIBCABI ;; xtensa*:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. GUESS=i386-sequent-sysv4 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; i*86:XTS-300:*:STOP) GUESS=$UNAME_MACHINE-unknown-stop ;; i*86:atheos:*:*) GUESS=$UNAME_MACHINE-unknown-atheos ;; i*86:syllable:*:*) GUESS=$UNAME_MACHINE-pc-syllable ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) GUESS=i386-unknown-lynxos$UNAME_RELEASE ;; i*86:*DOS:*:*) GUESS=$UNAME_MACHINE-pc-msdosdjgpp ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else GUESS=$UNAME_MACHINE-pc-sysv32 fi ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. GUESS=i586-pc-msdosdjgpp ;; Intel:Mach:3*:*) GUESS=i386-pc-mach3 ;; paragon:*:*:*) GUESS=i860-intel-osf1 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi ;; mini*:CTIX:SYS*5:*) # "miniframe" GUESS=m68010-convergent-sysv ;; mc68k:UNIX:SYSTEM5:3.51m) GUESS=m68k-convergent-sysv ;; M680?0:D-NIX:5.3:*) GUESS=m68k-diab-dnix ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) GUESS=m68k-unknown-lynxos$UNAME_RELEASE ;; mc68030:UNIX_System_V:4.*:*) GUESS=m68k-atari-sysv4 ;; TSUNAMI:LynxOS:2.*:*) GUESS=sparc-unknown-lynxos$UNAME_RELEASE ;; rs6000:LynxOS:2.*:*) GUESS=rs6000-unknown-lynxos$UNAME_RELEASE ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) GUESS=powerpc-unknown-lynxos$UNAME_RELEASE ;; SM[BE]S:UNIX_SV:*:*) GUESS=mips-dde-sysv$UNAME_RELEASE ;; RM*:ReliantUNIX-*:*:*) GUESS=mips-sni-sysv4 ;; RM*:SINIX-*:*:*) GUESS=mips-sni-sysv4 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` GUESS=$UNAME_MACHINE-sni-sysv4 else GUESS=ns32k-sni-sysv fi ;; PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says GUESS=i586-unisys-sysv4 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm GUESS=hppa1.1-stratus-sysv4 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. GUESS=i860-stratus-sysv4 ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. GUESS=$UNAME_MACHINE-stratus-vos ;; *:VOS:*:*) # From Paul.Green@stratus.com. GUESS=hppa1.1-stratus-vos ;; mc68*:A/UX:*:*) GUESS=m68k-apple-aux$UNAME_RELEASE ;; news*:NEWS-OS:6*:*) GUESS=mips-sony-newsos6 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if test -d /usr/nec; then GUESS=mips-nec-sysv$UNAME_RELEASE else GUESS=mips-unknown-sysv$UNAME_RELEASE fi ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. GUESS=powerpc-be-beos ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. GUESS=powerpc-apple-beos ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. GUESS=i586-pc-beos ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. GUESS=i586-pc-haiku ;; ppc:Haiku:*:*) # Haiku running on Apple PowerPC GUESS=powerpc-apple-haiku ;; *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) GUESS=$UNAME_MACHINE-unknown-haiku ;; SX-4:SUPER-UX:*:*) GUESS=sx4-nec-superux$UNAME_RELEASE ;; SX-5:SUPER-UX:*:*) GUESS=sx5-nec-superux$UNAME_RELEASE ;; SX-6:SUPER-UX:*:*) GUESS=sx6-nec-superux$UNAME_RELEASE ;; SX-7:SUPER-UX:*:*) GUESS=sx7-nec-superux$UNAME_RELEASE ;; SX-8:SUPER-UX:*:*) GUESS=sx8-nec-superux$UNAME_RELEASE ;; SX-8R:SUPER-UX:*:*) GUESS=sx8r-nec-superux$UNAME_RELEASE ;; SX-ACE:SUPER-UX:*:*) GUESS=sxace-nec-superux$UNAME_RELEASE ;; Power*:Rhapsody:*:*) GUESS=powerpc-apple-rhapsody$UNAME_RELEASE ;; *:Rhapsody:*:*) GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE ;; arm64:Darwin:*:*) GUESS=aarch64-apple-darwin$UNAME_RELEASE ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac if command -v xcode-select > /dev/null 2> /dev/null && \ ! xcode-select --print-path > /dev/null 2> /dev/null ; then # Avoid executing cc if there is no toolchain installed as # cc will be a stub that puts up a graphical alert # prompting the user to install developer tools. CC_FOR_BUILD=no_compiler_found else set_cc_for_build fi if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE ;; *:QNX:*:4*) GUESS=i386-pc-qnx ;; NEO-*:NONSTOP_KERNEL:*:*) GUESS=neo-tandem-nsk$UNAME_RELEASE ;; NSE-*:NONSTOP_KERNEL:*:*) GUESS=nse-tandem-nsk$UNAME_RELEASE ;; NSR-*:NONSTOP_KERNEL:*:*) GUESS=nsr-tandem-nsk$UNAME_RELEASE ;; NSV-*:NONSTOP_KERNEL:*:*) GUESS=nsv-tandem-nsk$UNAME_RELEASE ;; NSX-*:NONSTOP_KERNEL:*:*) GUESS=nsx-tandem-nsk$UNAME_RELEASE ;; *:NonStop-UX:*:*) GUESS=mips-compaq-nonstopux ;; BS2000:POSIX*:*:*) GUESS=bs2000-siemens-sysv ;; DS/*:UNIX_System_V:*:*) GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "${cputype-}" = 386; then UNAME_MACHINE=i386 elif test "x${cputype-}" != x; then UNAME_MACHINE=$cputype fi GUESS=$UNAME_MACHINE-unknown-plan9 ;; *:TOPS-10:*:*) GUESS=pdp10-unknown-tops10 ;; *:TENEX:*:*) GUESS=pdp10-unknown-tenex ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) GUESS=pdp10-dec-tops20 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) GUESS=pdp10-xkl-tops20 ;; *:TOPS-20:*:*) GUESS=pdp10-unknown-tops20 ;; *:ITS:*:*) GUESS=pdp10-unknown-its ;; SEI:*:*:SEIUX) GUESS=mips-sei-seiux$UNAME_RELEASE ;; *:DragonFly:*:*) DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case $UNAME_MACHINE in A*) GUESS=alpha-dec-vms ;; I*) GUESS=ia64-dec-vms ;; V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) GUESS=i386-pc-xenix ;; i*86:skyos:*:*) SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL ;; i*86:rdos:*:*) GUESS=$UNAME_MACHINE-pc-rdos ;; i*86:Fiwix:*:*) GUESS=$UNAME_MACHINE-pc-fiwix ;; *:AROS:*:*) GUESS=$UNAME_MACHINE-unknown-aros ;; x86_64:VMkernel:*:*) GUESS=$UNAME_MACHINE-unknown-esx ;; amd64:Isilon\ OneFS:*:*) GUESS=x86_64-unknown-onefs ;; *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; x86_64:[Ii]ronclad:*:*|i?86:[Ii]ronclad:*:*) GUESS=$UNAME_MACHINE-pc-ironclad-$LIBC ;; *:[Ii]ronclad:*:*) GUESS=$UNAME_MACHINE-unknown-ironclad-$LIBC ;; esac # Do we have a guess based on uname results? if test "x$GUESS" != x; then echo "$GUESS" exit fi # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" < #include #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #include #if defined(_SIZE_T_) || defined(SIGLOST) #include #endif #endif #endif int main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) #include #if defined (BSD) #if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); #else #if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); #else printf ("vax-dec-bsd\n"); exit (0); #endif #endif #else printf ("vax-dec-bsd\n"); exit (0); #endif #else #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname un; uname (&un); printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) #if defined(_SIZE_T_) || defined(SIGLOST) struct utsname *un; uname (&un); printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else printf ("mips-dec-ultrix\n"); exit (0); #endif #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 case $UNAME_MACHINE:$UNAME_SYSTEM in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF fi exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp nil t) # time-stamp-start: "timestamp='" # time-stamp-format: "%Y-%02m-%02d" # time-stamp-end: "'" # End: ldns-1.9.2/parse.c0000664000175000017500000002555315212267520013323 0ustar willemwillem/* * a generic (simple) parser. Use to parse rr's, private key * information and /etc/resolv.conf files * * a Net::DNS like library for C * LibDNS Team @ NLnet Labs * (c) NLnet Labs, 2005-2006 * See the file LICENSE for the license */ #include #include #include #include ldns_lookup_table ldns_directive_types[] = { { LDNS_DIR_TTL, "$TTL" }, { LDNS_DIR_ORIGIN, "$ORIGIN" }, { LDNS_DIR_INCLUDE, "$INCLUDE" }, { 0, NULL } }; /* add max_limit here? */ ssize_t ldns_fget_token(FILE *f, char *token, const char *delim, size_t limit) { return ldns_fget_token_l(f, token, delim, limit, NULL); } enum file_type2parse { zone_file_type, resolv_conf_file_type }; static ldns_status ldns_fget_token_l_st_file_type(FILE *f, char **token, size_t *limit, bool fixed, const char *delim, int *line_nr, enum file_type2parse file_type) { int c, prev_c; int p; /* 0 -> no parentheses seen, >0 nr of ( seen */ int com, quoted; char *t, *old_token; size_t i; const char *d; const char *del; /* standard delimiters */ if (!delim) { /* from isspace(3) */ del = LDNS_PARSE_NORMAL; } else { del = delim; } if (!token || !limit) return LDNS_STATUS_NULL; if (fixed) { if (*token == NULL || *limit == 0) return LDNS_STATUS_NULL; } else if (*token == NULL) { *limit = LDNS_MAX_LINELEN; if (!(*token = LDNS_XMALLOC(char, *limit + 1))) return LDNS_STATUS_MEM_ERR; } else if (*limit == 0) return LDNS_STATUS_ERR; p = 0; i = 0; com = 0; quoted = 0; prev_c = 0; t = *token; if (del[0] == '"') { quoted = 1; } while ((c = getc(f)) != EOF) { if (c == '\r') /* carriage return */ c = ' '; if (c == '(' && prev_c != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { p++; } prev_c = c; continue; } if (c == ')' && prev_c != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { p--; } prev_c = c; continue; } if (p < 0) { /* more ) then ( - close off the string */ *t = '\0'; return i == 0 ? LDNS_STATUS_SYNTAX_EMPTY : LDNS_STATUS_OK; } /* do something with comments ; */ if ((c == ';' || (c == '#' && file_type == resolv_conf_file_type)) && quoted == 0) { if (prev_c != '\\') { com = 1; } } if (c == '\"' && com == 0 && prev_c != '\\') { quoted = 1 - quoted; } if (c == '\n' && com != 0) { /* comments */ com = 0; *t = ' '; if (line_nr) { *line_nr = *line_nr + 1; } if (p == 0 && i > 0) { goto tokenread; } else { prev_c = c; continue; } } if (com == 1) { *t = ' '; prev_c = c; continue; } if (c == '\n' && p != 0 && t > *token) { /* in parentheses */ if (line_nr) { *line_nr = *line_nr + 1; } if (*limit > 0 && (i >= *limit || (size_t)(t - *token) >= *limit)) { if (fixed) { *t = '\0'; return LDNS_STATUS_SYNTAX_ERR; } old_token = *token; *limit *= 2; *token = LDNS_XREALLOC(*token, char, *limit + 1); if (*token == NULL) { *token = old_token; *t = '\0'; return LDNS_STATUS_MEM_ERR; } if (*token != old_token) t = *token + (t - old_token); } *t++ = ' '; prev_c = c; continue; } /* check if we hit the delim */ for (d = del; *d; d++) { if (c == *d && i > 0 && prev_c != '\\' && p == 0) { if (c == '\n' && line_nr) { *line_nr = *line_nr + 1; } goto tokenread; } } if (c != '\0' && c != '\n') { i++; } if (*limit > 0 && (i >= *limit || (size_t)(t - *token) >= *limit)) { if (fixed) { *t = '\0'; return LDNS_STATUS_SYNTAX_ERR; } old_token = *token; *limit *= 2; *token = LDNS_XREALLOC(*token, char, *limit + 1); if (*token == NULL) { *token = old_token; *t = '\0'; return LDNS_STATUS_MEM_ERR; } if (*token != old_token) t = *token + (t - old_token); } if (c != '\0' && c != '\n') { *t++ = c; } if (c == '\n' && line_nr) { *line_nr = *line_nr + 1; } if (c == '\\' && prev_c == '\\') prev_c = 0; else prev_c = c; } *t = '\0'; if (c == EOF) { return i == 0 ? LDNS_STATUS_SYNTAX_EMPTY : LDNS_STATUS_OK; } if (p != 0) { return LDNS_STATUS_SYNTAX_ERR; } return i == 0 ? LDNS_STATUS_SYNTAX_EMPTY : LDNS_STATUS_OK; tokenread: if(*del == '"') /* do not skip over quotes, they are significant */ ldns_fskipcs_l(f, del+1, line_nr); else ldns_fskipcs_l(f, del, line_nr); *t = '\0'; if (p != 0) { return LDNS_STATUS_SYNTAX_ERR; } return i == 0 ? LDNS_STATUS_SYNTAX_EMPTY : LDNS_STATUS_OK; } ldns_status ldns_fget_token_l_st(FILE *f, char **token, size_t *limit, bool fixed , const char *delim, int *line_nr) { return ldns_fget_token_l_st_file_type( f, token, limit, fixed, delim, line_nr, zone_file_type); } ssize_t ldns_fget_token_l_resolv_conf(FILE *f, char *token, const char *delim, size_t limit, int *line_nr) { if (limit == 0) limit = LDNS_MAX_LINELEN; if (ldns_fget_token_l_st_file_type(f, &token, &limit, true, delim, line_nr, resolv_conf_file_type)) return -1; else return (ssize_t)strlen(token); } ssize_t ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr) { if (limit == 0) limit = LDNS_MAX_LINELEN; if (ldns_fget_token_l_st(f, &token, &limit, true, delim, line_nr)) return -1; else return (ssize_t)strlen(token); } ssize_t ldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) { return ldns_fget_keyword_data_l(f, keyword, k_del, data, d_del, data_limit, NULL); } ssize_t ldns_fget_keyword_data_l(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit, int *line_nr) { /* we assume: keyword|sep|data */ char *fkeyword; ssize_t i; if(strlen(keyword) >= LDNS_MAX_KEYWORDLEN) return -1; fkeyword = LDNS_XMALLOC(char, LDNS_MAX_KEYWORDLEN); if(!fkeyword) return -1; i = ldns_fget_token(f, fkeyword, k_del, LDNS_MAX_KEYWORDLEN); if(i==0 || i==-1) { LDNS_FREE(fkeyword); return -1; } /* case??? i instead of strlen? */ if (strncmp(fkeyword, keyword, LDNS_MAX_KEYWORDLEN - 1) == 0) { /* whee! */ /* printf("%s\n%s\n", "Matching keyword", fkeyword); */ i = ldns_fget_token_l(f, data, d_del, data_limit, line_nr); LDNS_FREE(fkeyword); return i; } else { /*printf("no match for %s (read: %s)\n", keyword, fkeyword);*/ LDNS_FREE(fkeyword); return -1; } } ssize_t ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit) { int c, lc; int p; /* 0 -> no parentheses seen, >0 nr of ( seen */ int com, quoted; char *t; size_t i; const char *d; const char *del; /* standard delimiters */ if (!delim) { /* from isspace(3) */ del = LDNS_PARSE_NORMAL; } else { del = delim; } p = 0; i = 0; com = 0; quoted = 0; t = token; lc = 0; if (del[0] == '"') { quoted = 1; } while ((c = ldns_bgetc(b)) != EOF) { if (c == '\r') /* carriage return */ c = ' '; if (c == '(' && lc != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { p++; } lc = c; continue; } if (c == ')' && lc != '\\' && !quoted) { /* this only counts for non-comments */ if (com == 0) { p--; } lc = c; continue; } if (p < 0) { /* more ) then ( */ *t = '\0'; return 0; } /* do something with comments ; */ if (c == ';' && quoted == 0) { if (lc != '\\') { com = 1; } } if (c == '"' && com == 0 && lc != '\\') { quoted = 1 - quoted; } if (c == '\n' && com != 0) { /* comments */ com = 0; *t = ' '; lc = c; continue; } if (com == 1) { *t = ' '; lc = c; continue; } if (c == '\n' && p != 0) { /* in parentheses */ *t++ = ' '; lc = c; continue; } /* check if we hit the delim */ for (d = del; *d; d++) { if (c == *d && lc != '\\' && p == 0) { goto tokenread; } } i++; if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { *t = '\0'; return -1; } *t++ = c; if (c == '\\' && lc == '\\') { lc = 0; } else { lc = c; } } *t = '\0'; if (i == 0) { /* nothing read */ return -1; } if (p != 0) { return -1; } return (ssize_t)i; tokenread: if(*del == '"') /* do not skip over quotes, they are significant */ ldns_bskipcs(b, del+1); else ldns_bskipcs(b, del); *t = '\0'; if (p != 0) { return -1; } return (ssize_t)i; } void ldns_bskipcs(ldns_buffer *buffer, const char *s) { bool found; char c; const char *d; while(ldns_buffer_available_at(buffer, buffer->_position, sizeof(char))) { c = (char) ldns_buffer_read_u8_at(buffer, buffer->_position); found = false; for (d = s; *d; d++) { if (*d == c) { found = true; } } if (found && buffer->_limit > buffer->_position) { buffer->_position += sizeof(char); } else { return; } } } void ldns_fskipcs(FILE *fp, const char *s) { ldns_fskipcs_l(fp, s, NULL); } void ldns_fskipcs_l(FILE *fp, const char *s, int *line_nr) { bool found; int c; const char *d; while ((c = fgetc(fp)) != EOF) { if (line_nr && c == '\n') { *line_nr = *line_nr + 1; } found = false; for (d = s; *d; d++) { if (*d == c) { found = true; } } if (!found) { /* with getc, we've read too far */ ungetc(c, fp); return; } } } ssize_t ldns_bget_keyword_data(ldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) { /* we assume: keyword|sep|data */ char *fkeyword; ssize_t i; if(strlen(keyword) >= LDNS_MAX_KEYWORDLEN) return -1; fkeyword = LDNS_XMALLOC(char, LDNS_MAX_KEYWORDLEN); if(!fkeyword) return -1; /* out of memory */ i = ldns_bget_token(b, fkeyword, k_del, data_limit); if(i==0 || i==-1) { LDNS_FREE(fkeyword); return -1; /* nothing read */ } /* case??? */ if (strncmp(fkeyword, keyword, strlen(keyword)) == 0) { LDNS_FREE(fkeyword); /* whee, the match! */ /* retrieve it's data */ i = ldns_bget_token(b, data, d_del, 0); return i; } else { LDNS_FREE(fkeyword); return -1; } } ldns-1.9.2/tsig.c0000664000175000017500000003040315212267520013145 0ustar willemwillem/* * tsig.c * * contains the functions needed for TSIG [RFC2845] * * (c) 2005-2006 NLnet Labs * See the file LICENSE for the license */ #include #include #include #ifdef HAVE_SSL #include #include #endif /* HAVE_SSL */ const char * ldns_tsig_algorithm(const ldns_tsig_credentials *tc) { return tc->algorithm; } const char * ldns_tsig_keyname(const ldns_tsig_credentials *tc) { return tc->keyname; } const char * ldns_tsig_keydata(const ldns_tsig_credentials *tc) { return tc->keydata; } char * ldns_tsig_keyname_clone(const ldns_tsig_credentials *tc) { return strdup(tc->keyname); } char * ldns_tsig_keydata_clone(const ldns_tsig_credentials *tc) { return strdup(tc->keydata); } /* * Makes an exact copy of the wire, but with the tsig rr removed */ static uint8_t * ldns_tsig_prepare_pkt_wire(const uint8_t *wire, size_t wire_len, size_t *result_len) { uint8_t *wire2 = NULL; uint16_t qd_count; uint16_t an_count; uint16_t ns_count; uint16_t ar_count; ldns_rr *rr; size_t pos; uint16_t i; ldns_status status; if(wire_len < LDNS_HEADER_SIZE) { return NULL; } /* fake parse the wire */ qd_count = LDNS_QDCOUNT(wire); an_count = LDNS_ANCOUNT(wire); ns_count = LDNS_NSCOUNT(wire); ar_count = LDNS_ARCOUNT(wire); if (ar_count > 0) { ar_count--; } else { return NULL; } pos = LDNS_HEADER_SIZE; for (i = 0; i < qd_count; i++) { status = ldns_wire2rr(&rr, wire, wire_len, &pos, LDNS_SECTION_QUESTION); if (status != LDNS_STATUS_OK) { return NULL; } ldns_rr_free(rr); } for (i = 0; i < an_count; i++) { status = ldns_wire2rr(&rr, wire, wire_len, &pos, LDNS_SECTION_ANSWER); if (status != LDNS_STATUS_OK) { return NULL; } ldns_rr_free(rr); } for (i = 0; i < ns_count; i++) { status = ldns_wire2rr(&rr, wire, wire_len, &pos, LDNS_SECTION_AUTHORITY); if (status != LDNS_STATUS_OK) { return NULL; } ldns_rr_free(rr); } for (i = 0; i < ar_count; i++) { status = ldns_wire2rr(&rr, wire, wire_len, &pos, LDNS_SECTION_ADDITIONAL); if (status != LDNS_STATUS_OK) { return NULL; } ldns_rr_free(rr); } *result_len = pos; wire2 = LDNS_XMALLOC(uint8_t, *result_len); if(!wire2) { return NULL; } memcpy(wire2, wire, *result_len); ldns_write_uint16(wire2 + LDNS_ARCOUNT_OFF, ar_count); return wire2; } #ifdef HAVE_SSL static const EVP_MD * ldns_digest_function(char *name) { /* these are the mandatory algorithms from RFC4635 */ /* The optional algorithms are not yet implemented */ if (strcasecmp(name, "hmac-sha512.") == 0) { #ifdef HAVE_EVP_SHA512 return EVP_sha512(); #else return NULL; #endif } else if (strcasecmp(name, "hmac-shac384.") == 0) { #ifdef HAVE_EVP_SHA384 return EVP_sha384(); #else return NULL; #endif } else if (strcasecmp(name, "hmac-sha256.") == 0) { #ifdef HAVE_EVP_SHA256 return EVP_sha256(); #else return NULL; #endif } else if (strcasecmp(name, "hmac-sha1.") == 0) { return EVP_sha1(); } else if (strcasecmp(name, "hmac-md5.sig-alg.reg.int.") == 0) { return EVP_md5(); } else { return NULL; } } #endif #ifdef HAVE_SSL static ldns_status ldns_tsig_mac_new(ldns_rdf **tsig_mac, const uint8_t *pkt_wire, size_t pkt_wire_size, const char *key_data, const ldns_rdf *key_name_rdf, const ldns_rdf *fudge_rdf, const ldns_rdf *algorithm_rdf, const ldns_rdf *time_signed_rdf, const ldns_rdf *error_rdf, const ldns_rdf *other_data_rdf, const ldns_rdf *orig_mac_rdf, int tsig_timers_only) { ldns_status status; char *wireformat; int wiresize; unsigned char *mac_bytes = NULL; unsigned char *key_bytes = NULL; int key_size; const EVP_MD *digester; char *algorithm_name = NULL; unsigned int md_len = EVP_MAX_MD_SIZE; ldns_rdf *result = NULL; ldns_buffer *data_buffer = NULL; ldns_rdf *canonical_key_name_rdf = NULL; ldns_rdf *canonical_algorithm_rdf = NULL; if (key_name_rdf == NULL || algorithm_rdf == NULL) { return LDNS_STATUS_NULL; } canonical_key_name_rdf = ldns_rdf_clone(key_name_rdf); if (canonical_key_name_rdf == NULL) { return LDNS_STATUS_MEM_ERR; } canonical_algorithm_rdf = ldns_rdf_clone(algorithm_rdf); if (canonical_algorithm_rdf == NULL) { ldns_rdf_deep_free(canonical_key_name_rdf); return LDNS_STATUS_MEM_ERR; } /* * prepare the digestible information */ data_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN); if (!data_buffer) { status = LDNS_STATUS_MEM_ERR; goto clean; } /* if orig_mac is not NULL, add it too */ if (orig_mac_rdf) { (void) ldns_rdf2buffer_wire(data_buffer, orig_mac_rdf); } ldns_buffer_write(data_buffer, pkt_wire, pkt_wire_size); if (!tsig_timers_only) { ldns_dname2canonical(canonical_key_name_rdf); (void)ldns_rdf2buffer_wire(data_buffer, canonical_key_name_rdf); ldns_buffer_write_u16(data_buffer, LDNS_RR_CLASS_ANY); ldns_buffer_write_u32(data_buffer, 0); ldns_dname2canonical(canonical_algorithm_rdf); (void)ldns_rdf2buffer_wire(data_buffer, canonical_algorithm_rdf); } (void)ldns_rdf2buffer_wire(data_buffer, time_signed_rdf); (void)ldns_rdf2buffer_wire(data_buffer, fudge_rdf); if (!tsig_timers_only) { (void)ldns_rdf2buffer_wire(data_buffer, error_rdf); (void)ldns_rdf2buffer_wire(data_buffer, other_data_rdf); } wireformat = (char *) data_buffer->_data; wiresize = (int) ldns_buffer_position(data_buffer); algorithm_name = ldns_rdf2str(algorithm_rdf); if(!algorithm_name) { status = LDNS_STATUS_MEM_ERR; goto clean; } /* prepare the key */ key_bytes = LDNS_XMALLOC(unsigned char, ldns_b64_pton_calculate_size(strlen(key_data))); if(!key_bytes) { status = LDNS_STATUS_MEM_ERR; goto clean; } key_size = ldns_b64_pton(key_data, key_bytes, ldns_b64_pton_calculate_size(strlen(key_data))); if (key_size < 0) { status = LDNS_STATUS_INVALID_B64; goto clean; } /* hmac it */ /* 2 spare bytes for the length */ mac_bytes = LDNS_XMALLOC(unsigned char, md_len+2); if(!mac_bytes) { status = LDNS_STATUS_MEM_ERR; goto clean; } memset(mac_bytes, 0, md_len+2); digester = ldns_digest_function(algorithm_name); if (digester) { (void) HMAC(digester, key_bytes, key_size, (void *)wireformat, (size_t) wiresize, mac_bytes + 2, &md_len); ldns_write_uint16(mac_bytes, md_len); result = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_INT16_DATA, md_len + 2, mac_bytes); } else { status = LDNS_STATUS_CRYPTO_UNKNOWN_ALGO; goto clean; } *tsig_mac = result; status = LDNS_STATUS_OK; clean: LDNS_FREE(mac_bytes); LDNS_FREE(key_bytes); LDNS_FREE(algorithm_name); ldns_buffer_free(data_buffer); ldns_rdf_deep_free(canonical_algorithm_rdf); ldns_rdf_deep_free(canonical_key_name_rdf); return status; } #endif /* HAVE_SSL */ #ifdef HAVE_SSL bool ldns_pkt_tsig_verify(ldns_pkt *pkt, const uint8_t *wire, size_t wirelen, const char *key_name, const char *key_data, const ldns_rdf *orig_mac_rdf) { return ldns_pkt_tsig_verify_next(pkt, wire, wirelen, key_name, key_data, orig_mac_rdf, 0); } bool ldns_pkt_tsig_verify_next(ldns_pkt *pkt, const uint8_t *wire, size_t wirelen, const char* key_name, const char *key_data, const ldns_rdf *orig_mac_rdf, int tsig_timers_only) { ldns_rdf *fudge_rdf; ldns_rdf *algorithm_rdf; ldns_rdf *time_signed_rdf; ldns_rdf *orig_id_rdf; ldns_rdf *error_rdf; ldns_rdf *other_data_rdf; ldns_rdf *pkt_mac_rdf; ldns_rdf *my_mac_rdf; ldns_rdf *key_name_rdf = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, key_name); uint16_t pkt_id, orig_pkt_id; ldns_status status; uint8_t *prepared_wire = NULL; size_t prepared_wire_size = 0; ldns_rr *orig_tsig = ldns_pkt_tsig(pkt); if (!orig_tsig || ldns_rr_rd_count(orig_tsig) <= 6) { ldns_rdf_deep_free(key_name_rdf); return false; } algorithm_rdf = ldns_rr_rdf(orig_tsig, 0); time_signed_rdf = ldns_rr_rdf(orig_tsig, 1); fudge_rdf = ldns_rr_rdf(orig_tsig, 2); pkt_mac_rdf = ldns_rr_rdf(orig_tsig, 3); orig_id_rdf = ldns_rr_rdf(orig_tsig, 4); error_rdf = ldns_rr_rdf(orig_tsig, 5); other_data_rdf = ldns_rr_rdf(orig_tsig, 6); /* remove temporarily */ ldns_pkt_set_tsig(pkt, NULL); /* temporarily change the id to the original id */ pkt_id = ldns_pkt_id(pkt); orig_pkt_id = ldns_rdf2native_int16(orig_id_rdf); ldns_pkt_set_id(pkt, orig_pkt_id); prepared_wire = ldns_tsig_prepare_pkt_wire(wire, wirelen, &prepared_wire_size); status = ldns_tsig_mac_new(&my_mac_rdf, prepared_wire, prepared_wire_size, key_data, key_name_rdf, fudge_rdf, algorithm_rdf, time_signed_rdf, error_rdf, other_data_rdf, orig_mac_rdf, tsig_timers_only); LDNS_FREE(prepared_wire); if (status != LDNS_STATUS_OK) { ldns_rdf_deep_free(key_name_rdf); return false; } /* Put back the values */ ldns_pkt_set_tsig(pkt, orig_tsig); ldns_pkt_set_id(pkt, pkt_id); ldns_rdf_deep_free(key_name_rdf); if( ldns_rdf_size(pkt_mac_rdf) != ldns_rdf_size(my_mac_rdf)) { ldns_rdf_deep_free(my_mac_rdf); return false; } /* use time insensitive memory compare */ if( #ifdef HAVE_CRYPTO_MEMCMP CRYPTO_memcmp #else memcmp #endif (ldns_rdf_data(pkt_mac_rdf), ldns_rdf_data(my_mac_rdf), ldns_rdf_size(my_mac_rdf)) == 0) { ldns_rdf_deep_free(my_mac_rdf); return true; } else { ldns_rdf_deep_free(my_mac_rdf); return false; } } #endif /* HAVE_SSL */ #ifdef HAVE_SSL ldns_status ldns_pkt_tsig_sign(ldns_pkt *pkt, const char *key_name, const char *key_data, uint16_t fudge, const char *algorithm_name, const ldns_rdf *query_mac) { return ldns_pkt_tsig_sign_next(pkt, key_name, key_data, fudge, algorithm_name, query_mac, 0); } ldns_status ldns_pkt_tsig_sign_next(ldns_pkt *pkt, const char *key_name, const char *key_data, uint16_t fudge, const char *algorithm_name, const ldns_rdf *query_mac, int tsig_timers_only) { ldns_rr *tsig_rr; ldns_rdf *key_name_rdf = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, key_name); ldns_rdf *fudge_rdf = NULL; ldns_rdf *orig_id_rdf = NULL; ldns_rdf *algorithm_rdf; ldns_rdf *error_rdf = NULL; ldns_rdf *mac_rdf = NULL; ldns_rdf *other_data_rdf = NULL; ldns_status status = LDNS_STATUS_OK; uint8_t *pkt_wire = NULL; size_t pkt_wire_len; struct timeval tv_time_signed; uint8_t *time_signed = NULL; ldns_rdf *time_signed_rdf = NULL; algorithm_rdf = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, algorithm_name); if(!key_name_rdf || !algorithm_rdf) { status = LDNS_STATUS_MEM_ERR; goto clean; } /* eww don't have create tsigtime rdf yet :( */ /* bleh :p */ if (gettimeofday(&tv_time_signed, NULL) == 0) { time_signed = LDNS_XMALLOC(uint8_t, 6); if(!time_signed) { status = LDNS_STATUS_MEM_ERR; goto clean; } ldns_write_uint64_as_uint48(time_signed, (uint64_t)tv_time_signed.tv_sec); } else { status = LDNS_STATUS_INTERNAL_ERR; goto clean; } time_signed_rdf = ldns_rdf_new(LDNS_RDF_TYPE_TSIGTIME, 6, time_signed); if(!time_signed_rdf) { LDNS_FREE(time_signed); status = LDNS_STATUS_MEM_ERR; goto clean; } fudge_rdf = ldns_native2rdf_int16(LDNS_RDF_TYPE_INT16, fudge); orig_id_rdf = ldns_native2rdf_int16(LDNS_RDF_TYPE_INT16, ldns_pkt_id(pkt)); error_rdf = ldns_native2rdf_int16(LDNS_RDF_TYPE_INT16, 0); other_data_rdf = ldns_native2rdf_int16_data(0, NULL); if(!fudge_rdf || !orig_id_rdf || !error_rdf || !other_data_rdf) { status = LDNS_STATUS_MEM_ERR; goto clean; } if (ldns_pkt2wire(&pkt_wire, pkt, &pkt_wire_len) != LDNS_STATUS_OK) { status = LDNS_STATUS_ERR; goto clean; } status = ldns_tsig_mac_new(&mac_rdf, pkt_wire, pkt_wire_len, key_data, key_name_rdf, fudge_rdf, algorithm_rdf, time_signed_rdf, error_rdf, other_data_rdf, query_mac, tsig_timers_only); if (!mac_rdf) { goto clean; } LDNS_FREE(pkt_wire); /* Create the TSIG RR */ tsig_rr = ldns_rr_new(); if(!tsig_rr) { status = LDNS_STATUS_MEM_ERR; goto clean; } ldns_rr_set_owner(tsig_rr, key_name_rdf); ldns_rr_set_class(tsig_rr, LDNS_RR_CLASS_ANY); ldns_rr_set_type(tsig_rr, LDNS_RR_TYPE_TSIG); ldns_rr_set_ttl(tsig_rr, 0); ldns_rr_push_rdf(tsig_rr, algorithm_rdf); ldns_rr_push_rdf(tsig_rr, time_signed_rdf); ldns_rr_push_rdf(tsig_rr, fudge_rdf); ldns_rr_push_rdf(tsig_rr, mac_rdf); ldns_rr_push_rdf(tsig_rr, orig_id_rdf); ldns_rr_push_rdf(tsig_rr, error_rdf); ldns_rr_push_rdf(tsig_rr, other_data_rdf); ldns_pkt_set_tsig(pkt, tsig_rr); return status; clean: LDNS_FREE(pkt_wire); ldns_rdf_free(key_name_rdf); ldns_rdf_free(algorithm_rdf); ldns_rdf_free(time_signed_rdf); ldns_rdf_free(fudge_rdf); ldns_rdf_free(orig_id_rdf); ldns_rdf_free(error_rdf); ldns_rdf_free(other_data_rdf); return status; } #endif /* HAVE_SSL */ ldns-1.9.2/resolver.c0000664000175000017500000010471615212267520014051 0ustar willemwillem/* * resolver.c * * resolver implementation * * a Net::DNS like library for C * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ #include #include #include /* Access function for reading * and setting the different Resolver * options */ /* read */ uint16_t ldns_resolver_port(const ldns_resolver *r) { return r->_port; } ldns_rdf * ldns_resolver_source(const ldns_resolver *r) { return r->_source; } uint16_t ldns_resolver_edns_udp_size(const ldns_resolver *r) { return r->_edns_udp_size; } uint8_t ldns_resolver_retry(const ldns_resolver *r) { return r->_retry; } uint8_t ldns_resolver_retrans(const ldns_resolver *r) { return r->_retrans; } bool ldns_resolver_fallback(const ldns_resolver *r) { return r->_fallback; } uint8_t ldns_resolver_ip6(const ldns_resolver *r) { return r->_ip6; } bool ldns_resolver_recursive(const ldns_resolver *r) { return r->_recursive; } bool ldns_resolver_debug(const ldns_resolver *r) { return r->_debug; } bool ldns_resolver_dnsrch(const ldns_resolver *r) { return r->_dnsrch; } bool ldns_resolver_fail(const ldns_resolver *r) { return r->_fail; } bool ldns_resolver_defnames(const ldns_resolver *r) { return r->_defnames; } ldns_rdf * ldns_resolver_domain(const ldns_resolver *r) { return r->_domain; } ldns_rdf ** ldns_resolver_searchlist(const ldns_resolver *r) { return r->_searchlist; } ldns_rdf ** ldns_resolver_nameservers(const ldns_resolver *r) { return r->_nameservers; } size_t ldns_resolver_nameserver_count(const ldns_resolver *r) { return r->_nameserver_count; } bool ldns_resolver_dnssec(const ldns_resolver *r) { return r->_dnssec; } bool ldns_resolver_dnssec_cd(const ldns_resolver *r) { return r->_dnssec_cd; } ldns_rr_list * ldns_resolver_dnssec_anchors(const ldns_resolver *r) { return r->_dnssec_anchors; } bool ldns_resolver_trusted_key(const ldns_resolver *r, ldns_rr_list * keys, ldns_rr_list * trusted_keys) { size_t i; bool result = false; ldns_rr_list * trust_anchors; ldns_rr * cur_rr; if (!r || !keys) { return false; } trust_anchors = ldns_resolver_dnssec_anchors(r); if (!trust_anchors) { return false; } for (i = 0; i < ldns_rr_list_rr_count(keys); i++) { cur_rr = ldns_rr_list_rr(keys, i); if (ldns_rr_list_contains_rr(trust_anchors, cur_rr)) { if (trusted_keys) { ldns_rr_list_push_rr(trusted_keys, cur_rr); } result = true; } } return result; } bool ldns_resolver_igntc(const ldns_resolver *r) { return r->_igntc; } bool ldns_resolver_usevc(const ldns_resolver *r) { return r->_usevc; } size_t * ldns_resolver_rtt(const ldns_resolver *r) { return r->_rtt; } size_t ldns_resolver_nameserver_rtt(const ldns_resolver *r, size_t pos) { size_t *rtt; assert(r != NULL); rtt = ldns_resolver_rtt(r); if (pos >= ldns_resolver_nameserver_count(r)) { /* error ?*/ return 0; } else { return rtt[pos]; } } struct timeval ldns_resolver_timeout(const ldns_resolver *r) { return r->_timeout; } const char * ldns_resolver_tsig_keyname(const ldns_resolver *r) { return r->_tsig_keyname; } const char * ldns_resolver_tsig_algorithm(const ldns_resolver *r) { return r->_tsig_algorithm; } const char * ldns_resolver_tsig_keydata(const ldns_resolver *r) { return r->_tsig_keydata; } bool ldns_resolver_random(const ldns_resolver *r) { return r->_random; } size_t ldns_resolver_searchlist_count(const ldns_resolver *r) { return r->_searchlist_count; } /* write */ void ldns_resolver_set_port(ldns_resolver *r, uint16_t p) { r->_port = p; } void ldns_resolver_set_source(ldns_resolver *r, ldns_rdf *s) { r->_source = s; } ldns_rdf * ldns_resolver_pop_nameserver(ldns_resolver *r) { ldns_rdf **nameservers; ldns_rdf *pop; size_t ns_count; size_t *rtt; assert(r != NULL); ns_count = ldns_resolver_nameserver_count(r); nameservers = ldns_resolver_nameservers(r); rtt = ldns_resolver_rtt(r); if (ns_count == 0 || !nameservers) { return NULL; } pop = nameservers[ns_count - 1]; if (ns_count == 1) { LDNS_FREE(nameservers); LDNS_FREE(rtt); ldns_resolver_set_nameservers(r, NULL); ldns_resolver_set_rtt(r, NULL); } else { nameservers = LDNS_XREALLOC(nameservers, ldns_rdf *, (ns_count - 1)); rtt = LDNS_XREALLOC(rtt, size_t, (ns_count - 1)); ldns_resolver_set_nameservers(r, nameservers); ldns_resolver_set_rtt(r, rtt); } /* decr the count */ ldns_resolver_dec_nameserver_count(r); return pop; } ldns_status ldns_resolver_push_nameserver(ldns_resolver *r, const ldns_rdf *n) { ldns_rdf **nameservers; size_t ns_count; size_t *rtt; if (ldns_rdf_get_type(n) != LDNS_RDF_TYPE_A && ldns_rdf_get_type(n) != LDNS_RDF_TYPE_AAAA) { return LDNS_STATUS_ERR; } ns_count = ldns_resolver_nameserver_count(r); nameservers = ldns_resolver_nameservers(r); rtt = ldns_resolver_rtt(r); /* make room for the next one */ if (ns_count == 0) { nameservers = LDNS_XMALLOC(ldns_rdf *, 1); } else { nameservers = LDNS_XREALLOC(nameservers, ldns_rdf *, (ns_count + 1)); } if(!nameservers) return LDNS_STATUS_MEM_ERR; /* set the new value in the resolver */ ldns_resolver_set_nameservers(r, nameservers); /* don't forget the rtt */ if (ns_count == 0) { rtt = LDNS_XMALLOC(size_t, 1); } else { rtt = LDNS_XREALLOC(rtt, size_t, (ns_count + 1)); } if(!rtt) return LDNS_STATUS_MEM_ERR; /* slide n in its slot. */ /* we clone it here, because then we can free the original * rr's where it stood */ nameservers[ns_count] = ldns_rdf_clone(n); rtt[ns_count] = LDNS_RESOLV_RTT_MIN; ldns_resolver_incr_nameserver_count(r); ldns_resolver_set_rtt(r, rtt); return LDNS_STATUS_OK; } ldns_status ldns_resolver_push_nameserver_rr(ldns_resolver *r, const ldns_rr *rr) { ldns_rdf *address; if ((!rr) || (ldns_rr_get_type(rr) != LDNS_RR_TYPE_A && ldns_rr_get_type(rr) != LDNS_RR_TYPE_AAAA)) { return LDNS_STATUS_ERR; } address = ldns_rr_rdf(rr, 0); /* extract the ip number */ if (address) { return ldns_resolver_push_nameserver(r, address); } else { return LDNS_STATUS_ERR; } } ldns_status ldns_resolver_push_nameserver_rr_list(ldns_resolver *r, const ldns_rr_list *rrlist) { ldns_rr *rr; ldns_status stat; size_t i; stat = LDNS_STATUS_OK; if (rrlist) { for(i = 0; i < ldns_rr_list_rr_count(rrlist); i++) { rr = ldns_rr_list_rr(rrlist, i); if (ldns_resolver_push_nameserver_rr(r, rr) != LDNS_STATUS_OK) { stat = LDNS_STATUS_ERR; break; } } return stat; } else { return LDNS_STATUS_ERR; } } void ldns_resolver_set_edns_udp_size(ldns_resolver *r, uint16_t s) { r->_edns_udp_size = s; } void ldns_resolver_set_recursive(ldns_resolver *r, bool re) { r->_recursive = re; } void ldns_resolver_set_dnssec(ldns_resolver *r, bool d) { r->_dnssec = d; } void ldns_resolver_set_dnssec_cd(ldns_resolver *r, bool d) { r->_dnssec_cd = d; } void ldns_resolver_set_dnssec_anchors(ldns_resolver *r, ldns_rr_list * l) { r->_dnssec_anchors = l; } ldns_status ldns_resolver_push_dnssec_anchor(ldns_resolver *r, ldns_rr *rr) { ldns_rr_list * trust_anchors; if ((!rr) || (ldns_rr_get_type(rr) != LDNS_RR_TYPE_DNSKEY && ldns_rr_get_type(rr) != LDNS_RR_TYPE_DS)) { return LDNS_STATUS_ERR; } if (!(trust_anchors = ldns_resolver_dnssec_anchors(r))) { /* Initialize */ trust_anchors = ldns_rr_list_new(); ldns_resolver_set_dnssec_anchors(r, trust_anchors); } return (ldns_rr_list_push_rr(trust_anchors, ldns_rr_clone(rr))) ? LDNS_STATUS_OK : LDNS_STATUS_ERR; } void ldns_resolver_set_igntc(ldns_resolver *r, bool i) { r->_igntc = i; } void ldns_resolver_set_usevc(ldns_resolver *r, bool vc) { r->_usevc = vc; } void ldns_resolver_set_debug(ldns_resolver *r, bool d) { r->_debug = d; } void ldns_resolver_set_ip6(ldns_resolver *r, uint8_t ip6) { r->_ip6 = ip6; } void ldns_resolver_set_fail(ldns_resolver *r, bool f) { r->_fail =f; } static void ldns_resolver_set_searchlist_count(ldns_resolver *r, size_t c) { r->_searchlist_count = c; } void ldns_resolver_set_nameserver_count(ldns_resolver *r, size_t c) { r->_nameserver_count = c; } void ldns_resolver_set_dnsrch(ldns_resolver *r, bool d) { r->_dnsrch = d; } void ldns_resolver_set_retry(ldns_resolver *r, uint8_t retry) { r->_retry = retry; } void ldns_resolver_set_retrans(ldns_resolver *r, uint8_t retrans) { r->_retrans = retrans; } void ldns_resolver_set_fallback(ldns_resolver *r, bool fallback) { r->_fallback = fallback; } void ldns_resolver_set_nameservers(ldns_resolver *r, ldns_rdf **n) { r->_nameservers = n; } void ldns_resolver_set_defnames(ldns_resolver *r, bool d) { r->_defnames = d; } void ldns_resolver_set_rtt(ldns_resolver *r, size_t *rtt) { r->_rtt = rtt; } void ldns_resolver_set_nameserver_rtt(ldns_resolver *r, size_t pos, size_t value) { size_t *rtt; assert(r != NULL); rtt = ldns_resolver_rtt(r); if (pos >= ldns_resolver_nameserver_count(r)) { /* error ?*/ } else { rtt[pos] = value; } } void ldns_resolver_incr_nameserver_count(ldns_resolver *r) { size_t c; c = ldns_resolver_nameserver_count(r); ldns_resolver_set_nameserver_count(r, ++c); } void ldns_resolver_dec_nameserver_count(ldns_resolver *r) { size_t c; c = ldns_resolver_nameserver_count(r); if (c == 0) { return; } else { ldns_resolver_set_nameserver_count(r, --c); } } void ldns_resolver_set_domain(ldns_resolver *r, ldns_rdf *d) { r->_domain = d; } void ldns_resolver_set_timeout(ldns_resolver *r, struct timeval timeout) { r->_timeout.tv_sec = timeout.tv_sec; r->_timeout.tv_usec = timeout.tv_usec; } void ldns_resolver_push_searchlist(ldns_resolver *r, ldns_rdf *d) { ldns_rdf **searchlist; size_t list_count; if (ldns_rdf_get_type(d) != LDNS_RDF_TYPE_DNAME) { return; } list_count = ldns_resolver_searchlist_count(r); searchlist = ldns_resolver_searchlist(r); searchlist = LDNS_XREALLOC(searchlist, ldns_rdf *, (list_count + 1)); if (searchlist) { r->_searchlist = searchlist; searchlist[list_count] = ldns_rdf_clone(d); ldns_resolver_set_searchlist_count(r, list_count + 1); } /* no way to report mem err */ } void ldns_resolver_set_tsig_keyname(ldns_resolver *r, const char *tsig_keyname) { LDNS_FREE(r->_tsig_keyname); r->_tsig_keyname = strdup(tsig_keyname); } void ldns_resolver_set_tsig_algorithm(ldns_resolver *r, const char *tsig_algorithm) { LDNS_FREE(r->_tsig_algorithm); r->_tsig_algorithm = strdup(tsig_algorithm); } void ldns_resolver_set_tsig_keydata(ldns_resolver *r, const char *tsig_keydata) { LDNS_FREE(r->_tsig_keydata); r->_tsig_keydata = strdup(tsig_keydata); } void ldns_resolver_set_random(ldns_resolver *r, bool b) { r->_random = b; } /* more sophisticated functions */ ldns_resolver * ldns_resolver_new(void) { ldns_resolver *r; r = LDNS_MALLOC(ldns_resolver); if (!r) { return NULL; } r->_searchlist = NULL; r->_nameservers = NULL; r->_rtt = NULL; /* defaults are filled out */ ldns_resolver_set_searchlist_count(r, 0); ldns_resolver_set_nameserver_count(r, 0); ldns_resolver_set_usevc(r, 0); ldns_resolver_set_port(r, LDNS_PORT); ldns_resolver_set_domain(r, NULL); ldns_resolver_set_defnames(r, false); ldns_resolver_set_retry(r, 3); ldns_resolver_set_retrans(r, 2); ldns_resolver_set_fallback(r, true); ldns_resolver_set_fail(r, false); ldns_resolver_set_edns_udp_size(r, 0); ldns_resolver_set_dnssec(r, false); ldns_resolver_set_dnssec_cd(r, false); ldns_resolver_set_dnssec_anchors(r, NULL); ldns_resolver_set_ip6(r, LDNS_RESOLV_INETANY); ldns_resolver_set_igntc(r, false); ldns_resolver_set_recursive(r, false); ldns_resolver_set_dnsrch(r, true); ldns_resolver_set_source(r, NULL); ldns_resolver_set_ixfr_serial(r, 0); /* randomize the nameserver to be queried * when there are multiple */ ldns_resolver_set_random(r, true); ldns_resolver_set_debug(r, 0); r->_timeout.tv_sec = LDNS_DEFAULT_TIMEOUT_SEC; r->_timeout.tv_usec = LDNS_DEFAULT_TIMEOUT_USEC; r->_socket = -1; r->_axfr_soa_count = 0; r->_axfr_i = 0; r->_cur_axfr_pkt = NULL; r->_tsig_keyname = NULL; r->_tsig_keydata = NULL; r->_tsig_algorithm = NULL; return r; } ldns_resolver * ldns_resolver_clone(ldns_resolver *src) { ldns_resolver *dst; size_t i; assert(src != NULL); if (!(dst = LDNS_MALLOC(ldns_resolver))) return NULL; (void) memcpy(dst, src, sizeof(ldns_resolver)); if (dst->_searchlist_count == 0) dst->_searchlist = NULL; else { if (!(dst->_searchlist = LDNS_XMALLOC(ldns_rdf *, dst->_searchlist_count))) goto error; for (i = 0; i < dst->_searchlist_count; i++) if (!(dst->_searchlist[i] = ldns_rdf_clone(src->_searchlist[i]))) { dst->_searchlist_count = i; goto error_searchlist; } } if (dst->_nameserver_count == 0) { dst->_nameservers = NULL; dst->_rtt = NULL; } else { if (!(dst->_nameservers = LDNS_XMALLOC(ldns_rdf *, dst->_nameserver_count))) goto error_searchlist; for (i = 0; i < dst->_nameserver_count; i++) if (!(dst->_nameservers[i] = ldns_rdf_clone(src->_nameservers[i]))) { dst->_nameserver_count = i; goto error_nameservers; } if (!(dst->_rtt = LDNS_XMALLOC(size_t, dst->_nameserver_count))) goto error_nameservers; (void) memcpy(dst->_rtt, src->_rtt, sizeof(size_t) * dst->_nameserver_count); } if (dst->_domain && (!(dst->_domain = ldns_rdf_clone(src->_domain)))) goto error_rtt; if (dst->_tsig_keyname && (!(dst->_tsig_keyname = strdup(src->_tsig_keyname)))) goto error_domain; if (dst->_tsig_keydata && (!(dst->_tsig_keydata = strdup(src->_tsig_keydata)))) goto error_tsig_keyname; if (dst->_tsig_algorithm && (!(dst->_tsig_algorithm = strdup(src->_tsig_algorithm)))) goto error_tsig_keydata; if (dst->_cur_axfr_pkt && (!(dst->_cur_axfr_pkt = ldns_pkt_clone(src->_cur_axfr_pkt)))) goto error_tsig_algorithm; if (dst->_dnssec_anchors && (!(dst->_dnssec_anchors=ldns_rr_list_clone(src->_dnssec_anchors)))) goto error_cur_axfr_pkt; return dst; error_cur_axfr_pkt: ldns_pkt_free(dst->_cur_axfr_pkt); error_tsig_algorithm: LDNS_FREE(dst->_tsig_algorithm); error_tsig_keydata: LDNS_FREE(dst->_tsig_keydata); error_tsig_keyname: LDNS_FREE(dst->_tsig_keyname); error_domain: ldns_rdf_deep_free(dst->_domain); error_rtt: LDNS_FREE(dst->_rtt); error_nameservers: for (i = 0; i < dst->_nameserver_count; i++) ldns_rdf_deep_free(dst->_nameservers[i]); LDNS_FREE(dst->_nameservers); error_searchlist: for (i = 0; i < dst->_searchlist_count; i++) ldns_rdf_deep_free(dst->_searchlist[i]); LDNS_FREE(dst->_searchlist); error: LDNS_FREE(dst); return NULL; } ldns_status ldns_resolver_new_frm_fp(ldns_resolver **res, FILE *fp) { return ldns_resolver_new_frm_fp_l(res, fp, NULL); } ldns_status ldns_resolver_new_frm_fp_l(ldns_resolver **res, FILE *fp, int *line_nr) { ldns_resolver *r = NULL; const char *keyword[LDNS_RESOLV_KEYWORDS]; char word[LDNS_MAX_LINELEN + 1]; int8_t expect; uint8_t i; ldns_rdf *tmp; #ifdef HAVE_SSL ldns_rr *tmp_rr; #endif ssize_t gtr, bgtr; ldns_buffer *b; int lnr = 0; FILE* myfp = fp; if(!line_nr) line_nr = &lnr; if(!fp) { myfp = fopen(LDNS_RESOLV_CONF, "r"); if(!myfp) return LDNS_STATUS_FILE_ERR; } /* do this better * expect = * 0: keyword * 1: default domain dname * 2: NS aaaa or a record */ /* recognized keywords */ keyword[LDNS_RESOLV_NAMESERVER] = "nameserver"; keyword[LDNS_RESOLV_DEFDOMAIN] = "domain"; keyword[LDNS_RESOLV_SEARCH] = "search"; /* these two are read but not used atm TODO */ keyword[LDNS_RESOLV_SORTLIST] = "sortlist"; keyword[LDNS_RESOLV_OPTIONS] = "options"; keyword[LDNS_RESOLV_ANCHOR] = "anchor"; r = ldns_resolver_new(); if (!r) { if(!fp) fclose(myfp); return LDNS_STATUS_MEM_ERR; } gtr = 1; word[0] = 0; expect = LDNS_RESOLV_KEYWORD; while (gtr > 0) { switch(expect) { case LDNS_RESOLV_KEYWORD: /* keyword */ gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_NORMAL, 0, line_nr); if (gtr != 0) { for(i = 0; i < LDNS_RESOLV_KEYWORDS; i++) { if (strcasecmp(keyword[i], word) == 0) { /* chosen the keyword and * expect values carefully */ expect = i; break; } } /* no keyword recognized */ if (expect == LDNS_RESOLV_KEYWORD) { /* skip line */ /* ldns_resolver_deep_free(r); if(!fp) fclose(myfp); return LDNS_STATUS_SYNTAX_KEYWORD_ERR; */ } } break; case LDNS_RESOLV_DEFDOMAIN: /* default domain dname */ gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_NORMAL, 0, line_nr); if (gtr == 0) { if(!fp) fclose(myfp); ldns_resolver_deep_free(r); return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR; } tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, word); if (!tmp) { if(!fp) fclose(myfp); ldns_resolver_deep_free(r); return LDNS_STATUS_SYNTAX_DNAME_ERR; } /* DOn't free, because we copy the pointer */ ldns_resolver_set_domain(r, tmp); expect = LDNS_RESOLV_KEYWORD; break; case LDNS_RESOLV_NAMESERVER: /* NS aaaa or a record */ gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_NORMAL, 0, line_nr); if (gtr == 0) { if(!fp) fclose(myfp); ldns_resolver_deep_free(r); return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR; } if(strchr(word, '%')) { /* snip off interface labels, * fe80::222:19ff:fe31:4222%eth0 */ strchr(word, '%')[0]=0; } tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_AAAA, word); if (!tmp) { /* try ip4 */ tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_A, word); } /* could not parse it, exit */ if (!tmp) { ldns_resolver_deep_free(r); if(!fp) fclose(myfp); return LDNS_STATUS_SYNTAX_ERR; } (void)ldns_resolver_push_nameserver(r, tmp); ldns_rdf_deep_free(tmp); expect = LDNS_RESOLV_KEYWORD; break; case LDNS_RESOLV_SEARCH: /* search list domain dname */ gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_SKIP_SPACE, 0, line_nr); b = LDNS_MALLOC(ldns_buffer); if(!b) { ldns_resolver_deep_free(r); if(!fp) fclose(myfp); return LDNS_STATUS_MEM_ERR; } ldns_buffer_new_frm_data(b, word, (size_t) gtr); if(ldns_buffer_status(b) != LDNS_STATUS_OK) { LDNS_FREE(b); ldns_resolver_deep_free(r); if(!fp) fclose(myfp); return LDNS_STATUS_MEM_ERR; } bgtr = ldns_bget_token(b, word, LDNS_PARSE_NORMAL, (size_t) gtr + 1); while (bgtr > 0) { gtr -= bgtr; tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, word); if (!tmp) { ldns_resolver_deep_free(r); ldns_buffer_free(b); if(!fp) fclose(myfp); return LDNS_STATUS_SYNTAX_DNAME_ERR; } ldns_resolver_push_searchlist(r, tmp); ldns_rdf_deep_free(tmp); bgtr = ldns_bget_token(b, word, LDNS_PARSE_NORMAL, (size_t) gtr + 1); } ldns_buffer_free(b); if (expect != LDNS_RESOLV_KEYWORD) { gtr = 1; expect = LDNS_RESOLV_KEYWORD; } break; case LDNS_RESOLV_SORTLIST: gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_SKIP_SPACE, 0, line_nr); /* sortlist not implemented atm */ expect = LDNS_RESOLV_KEYWORD; break; case LDNS_RESOLV_OPTIONS: gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_SKIP_SPACE, 0, line_nr); /* options not implemented atm */ expect = LDNS_RESOLV_KEYWORD; break; case LDNS_RESOLV_ANCHOR: /* a file containing a DNSSEC trust anchor */ gtr = ldns_fget_token_l_resolv_conf(myfp, word, LDNS_PARSE_NORMAL, 0, line_nr); if (gtr == 0) { ldns_resolver_deep_free(r); if(!fp) fclose(myfp); return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR; } #ifdef HAVE_SSL tmp_rr = ldns_read_anchor_file(word); (void) ldns_resolver_push_dnssec_anchor(r, tmp_rr); ldns_rr_free(tmp_rr); #endif expect = LDNS_RESOLV_KEYWORD; break; } } if(!fp) fclose(myfp); if (res) { *res = r; return LDNS_STATUS_OK; } else { ldns_resolver_deep_free(r); return LDNS_STATUS_NULL; } } ldns_status ldns_resolver_new_frm_file(ldns_resolver **res, const char *filename) { ldns_resolver *r; FILE *fp; ldns_status s; if (!filename) { fp = fopen(LDNS_RESOLV_CONF, "r"); } else { fp = fopen(filename, "r"); } if (!fp) { return LDNS_STATUS_FILE_ERR; } s = ldns_resolver_new_frm_fp(&r, fp); fclose(fp); if (s == LDNS_STATUS_OK) { if (res) { *res = r; return LDNS_STATUS_OK; } else { ldns_resolver_free(r); return LDNS_STATUS_NULL; } } return s; } void ldns_resolver_free(ldns_resolver *res) { LDNS_FREE(res); } void ldns_resolver_deep_free(ldns_resolver *res) { size_t i; if (res) { close_socket(res->_socket); if (res->_searchlist) { for (i = 0; i < ldns_resolver_searchlist_count(res); i++) { ldns_rdf_deep_free(res->_searchlist[i]); } LDNS_FREE(res->_searchlist); } if (res->_nameservers) { for (i = 0; i < res->_nameserver_count; i++) { ldns_rdf_deep_free(res->_nameservers[i]); } LDNS_FREE(res->_nameservers); } if (ldns_resolver_domain(res)) { ldns_rdf_deep_free(ldns_resolver_domain(res)); } if (res->_tsig_keyname) { LDNS_FREE(res->_tsig_keyname); } if (res->_tsig_keydata) { LDNS_FREE(res->_tsig_keydata); } if (res->_tsig_algorithm) { LDNS_FREE(res->_tsig_algorithm); } if (res->_cur_axfr_pkt) { ldns_pkt_free(res->_cur_axfr_pkt); } if (res->_rtt) { LDNS_FREE(res->_rtt); } if (res->_dnssec_anchors) { ldns_rr_list_deep_free(res->_dnssec_anchors); } LDNS_FREE(res); } } ldns_status ldns_resolver_search_status(ldns_pkt** pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags) { ldns_rdf *new_name; ldns_rdf **search_list; size_t i; ldns_status s = LDNS_STATUS_OK; ldns_rdf root_dname = { 1, LDNS_RDF_TYPE_DNAME, (void *)"" }; if (ldns_dname_absolute(name)) { /* query as-is */ return ldns_resolver_query_status(pkt, r, name, t, c, flags); } else if (ldns_resolver_dnsrch(r)) { ldns_pkt *return_pkt = NULL; search_list = ldns_resolver_searchlist(r); for (i = 0; i <= ldns_resolver_searchlist_count(r); i++) { if (i == ldns_resolver_searchlist_count(r)) { new_name = ldns_dname_cat_clone(name, &root_dname); } else { new_name = ldns_dname_cat_clone(name, search_list[i]); } s = ldns_resolver_query_status(&return_pkt, r, new_name, t, c, flags); ldns_rdf_deep_free(new_name); if (return_pkt) { if (s == LDNS_STATUS_OK && ldns_pkt_get_rcode(return_pkt) == LDNS_RCODE_NOERROR) { return LDNS_STATUS_OK; } else if (i < ldns_resolver_searchlist_count(r)) { ldns_pkt_free(return_pkt); return_pkt = NULL; } } } if (pkt && return_pkt) { *pkt = return_pkt; } } return s; } ldns_pkt * ldns_resolver_search(const ldns_resolver *r,const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags) { ldns_pkt* pkt = NULL; if (ldns_resolver_search_status(&pkt, (ldns_resolver *)r, name, t, c, flags) != LDNS_STATUS_OK) { ldns_pkt_free(pkt); return NULL; } return pkt; } ldns_status ldns_resolver_query_status(ldns_pkt** pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags) { ldns_rdf *newname; ldns_status status; if (!ldns_resolver_defnames(r) || !ldns_resolver_domain(r)) { return ldns_resolver_send(pkt, r, name, t, c, flags); } newname = ldns_dname_cat_clone(name, ldns_resolver_domain(r)); if (!newname) { return LDNS_STATUS_MEM_ERR; } status = ldns_resolver_send(pkt, r, newname, t, c, flags); ldns_rdf_free(newname); return status; } ldns_pkt * ldns_resolver_query(const ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags) { ldns_pkt* pkt = NULL; if (ldns_resolver_query_status(&pkt, (ldns_resolver *)r, name, t, c, flags) != LDNS_STATUS_OK) { ldns_pkt_free(pkt); return NULL; } return pkt; } static size_t * ldns_resolver_backup_rtt(ldns_resolver *r) { size_t *new_rtt; size_t *old_rtt = ldns_resolver_rtt(r); if (old_rtt && ldns_resolver_nameserver_count(r)) { new_rtt = LDNS_XMALLOC(size_t , ldns_resolver_nameserver_count(r)); if (!new_rtt) return NULL; memcpy(new_rtt, old_rtt, sizeof(size_t) * ldns_resolver_nameserver_count(r)); ldns_resolver_set_rtt(r, new_rtt); return old_rtt; } return NULL; } static void ldns_resolver_restore_rtt(ldns_resolver *r, size_t *old_rtt) { size_t *cur_rtt = ldns_resolver_rtt(r); if (cur_rtt) { LDNS_FREE(cur_rtt); } ldns_resolver_set_rtt(r, old_rtt); } ldns_status ldns_resolver_send_pkt(ldns_pkt **answer, ldns_resolver *r, ldns_pkt *query_pkt) { ldns_pkt *answer_pkt = NULL; ldns_status stat = LDNS_STATUS_OK; size_t *rtt; stat = ldns_send(&answer_pkt, (ldns_resolver *)r, query_pkt); if (stat != LDNS_STATUS_OK) { if(answer_pkt) { ldns_pkt_free(answer_pkt); answer_pkt = NULL; } } else { /* if tc=1 fall back to EDNS and/or TCP */ /* check for tcp first (otherwise we don't care about tc=1) */ if (!ldns_resolver_usevc(r) && ldns_resolver_fallback(r)) { if (ldns_pkt_tc(answer_pkt)) { /* was EDNS0 set? */ if (ldns_pkt_edns_udp_size(query_pkt) == 0) { ldns_pkt_set_edns_udp_size(query_pkt , 4096); ldns_pkt_free(answer_pkt); answer_pkt = NULL; /* Nameservers should not become * unreachable because fragments are * dropped (network error). We might * still have success with TCP. * Therefore maintain reachability * statuses of the nameservers by * backup and restore the rtt list. */ rtt = ldns_resolver_backup_rtt(r); stat = ldns_send(&answer_pkt, r , query_pkt); ldns_resolver_restore_rtt(r, rtt); } /* either way, if it is still truncated, use TCP */ if (stat != LDNS_STATUS_OK || ldns_pkt_tc(answer_pkt)) { ldns_resolver_set_usevc(r, true); ldns_pkt_free(answer_pkt); answer_pkt = NULL; stat = ldns_send(&answer_pkt, r, query_pkt); ldns_resolver_set_usevc(r, false); } } } } if (answer && answer_pkt) { *answer = answer_pkt; } return stat; } ldns_status ldns_resolver_prepare_query_pkt(ldns_pkt **query_pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags) { struct timeval now; ldns_rr* soa = NULL; /* prepare a question pkt from the parameters * and then send this */ if (t == LDNS_RR_TYPE_IXFR) { ldns_rdf *owner_rdf; ldns_rdf *mname_rdf; ldns_rdf *rname_rdf; ldns_rdf *serial_rdf; ldns_rdf *refresh_rdf; ldns_rdf *retry_rdf; ldns_rdf *expire_rdf; ldns_rdf *minimum_rdf; soa = ldns_rr_new(); if (!soa) { return LDNS_STATUS_ERR; } owner_rdf = ldns_rdf_clone(name); if (!owner_rdf) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } ldns_rr_set_owner(soa, owner_rdf); ldns_rr_set_type(soa, LDNS_RR_TYPE_SOA); ldns_rr_set_class(soa, c); ldns_rr_set_question(soa, false); if (ldns_str2rdf_dname(&mname_rdf, ".") != LDNS_STATUS_OK) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, mname_rdf); if (ldns_str2rdf_dname(&rname_rdf, ".") != LDNS_STATUS_OK) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, rname_rdf); serial_rdf = ldns_native2rdf_int32(LDNS_RDF_TYPE_INT32, ldns_resolver_get_ixfr_serial(r)); if (!serial_rdf) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, serial_rdf); refresh_rdf = ldns_native2rdf_int32(LDNS_RDF_TYPE_INT32, 0); if (!refresh_rdf) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, refresh_rdf); retry_rdf = ldns_native2rdf_int32(LDNS_RDF_TYPE_INT32, 0); if (!retry_rdf) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, retry_rdf); expire_rdf = ldns_native2rdf_int32(LDNS_RDF_TYPE_INT32, 0); if (!expire_rdf) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, expire_rdf); minimum_rdf = ldns_native2rdf_int32(LDNS_RDF_TYPE_INT32, 0); if (!minimum_rdf) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } else ldns_rr_push_rdf(soa, minimum_rdf); *query_pkt = ldns_pkt_ixfr_request_new(ldns_rdf_clone(name), c, flags, soa); } else { *query_pkt = ldns_pkt_query_new(ldns_rdf_clone(name), t, c, flags); } if (!*query_pkt) { ldns_rr_free(soa); return LDNS_STATUS_ERR; } /* set DO bit if necessary */ if (ldns_resolver_dnssec(r)) { if (ldns_resolver_edns_udp_size(r) == 0) { ldns_resolver_set_edns_udp_size(r, 4096); } ldns_pkt_set_edns_do(*query_pkt, true); if (ldns_resolver_dnssec_cd(r) || (flags & LDNS_CD)) { ldns_pkt_set_cd(*query_pkt, true); } } /* transfer the udp_edns_size from the resolver to the packet */ if (ldns_resolver_edns_udp_size(r) != 0) { ldns_pkt_set_edns_udp_size(*query_pkt, ldns_resolver_edns_udp_size(r)); } /* set the timestamp */ now.tv_sec = time(NULL); now.tv_usec = 0; ldns_pkt_set_timestamp(*query_pkt, now); if (ldns_resolver_debug(r)) { ldns_pkt_print(stdout, *query_pkt); } /* only set the id if it is not set yet */ if (ldns_pkt_id(*query_pkt) == 0) { ldns_pkt_set_random_id(*query_pkt); } return LDNS_STATUS_OK; } ldns_status ldns_resolver_send(ldns_pkt **answer, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags) { ldns_pkt *query_pkt; ldns_pkt *answer_pkt; ldns_status status; assert(r != NULL); assert(name != NULL); answer_pkt = NULL; /* do all the preprocessing here, then fire of an query to * the network */ if (0 == t) { t= LDNS_RR_TYPE_A; } if (0 == c) { c= LDNS_RR_CLASS_IN; } if (0 == ldns_resolver_nameserver_count(r)) { return LDNS_STATUS_RES_NO_NS; } if (ldns_rdf_get_type(name) != LDNS_RDF_TYPE_DNAME) { return LDNS_STATUS_RES_QUERY; } status = ldns_resolver_prepare_query_pkt(&query_pkt, r, name, t, c, flags); if (status != LDNS_STATUS_OK) { return status; } /* if tsig values are set, tsign it */ /* TODO: make last 3 arguments optional too? maybe make complete rr instead of separate values in resolver (and packet) Jelte should this go in pkt_prepare? */ if (ldns_resolver_tsig_keyname(r) && ldns_resolver_tsig_keydata(r)) { #ifdef HAVE_SSL status = ldns_pkt_tsig_sign(query_pkt, ldns_resolver_tsig_keyname(r), ldns_resolver_tsig_keydata(r), 300, ldns_resolver_tsig_algorithm(r), NULL); if (status != LDNS_STATUS_OK) { ldns_pkt_free(query_pkt); return LDNS_STATUS_CRYPTO_TSIG_ERR; } #else ldns_pkt_free(query_pkt); return LDNS_STATUS_CRYPTO_TSIG_ERR; #endif /* HAVE_SSL */ } status = ldns_resolver_send_pkt(&answer_pkt, r, query_pkt); ldns_pkt_free(query_pkt); /* allows answer to be NULL when not interested in return value */ if (answer) { *answer = answer_pkt; } return status; } ldns_rr * ldns_axfr_next(ldns_resolver *resolver) { ldns_rr *cur_rr; uint8_t *packet_wire; size_t packet_wire_size; ldns_status status; /* check if start() has been called */ if (!resolver || resolver->_socket == -1) { return NULL; } if (resolver->_cur_axfr_pkt) { if (resolver->_axfr_i == ldns_pkt_ancount(resolver->_cur_axfr_pkt)) { ldns_pkt_free(resolver->_cur_axfr_pkt); resolver->_cur_axfr_pkt = NULL; return ldns_axfr_next(resolver); } cur_rr = ldns_rr_clone(ldns_rr_list_rr( ldns_pkt_answer(resolver->_cur_axfr_pkt), resolver->_axfr_i)); resolver->_axfr_i++; if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_SOA) { resolver->_axfr_soa_count++; if (resolver->_axfr_soa_count >= 2) { close_socket(resolver->_socket); ldns_pkt_free(resolver->_cur_axfr_pkt); resolver->_cur_axfr_pkt = NULL; } } return cur_rr; } else { packet_wire = ldns_tcp_read_wire_timeout(resolver->_socket, &packet_wire_size, resolver->_timeout); if(!packet_wire) return NULL; status = ldns_wire2pkt(&resolver->_cur_axfr_pkt, packet_wire, packet_wire_size); LDNS_FREE(packet_wire); resolver->_axfr_i = 0; if (status != LDNS_STATUS_OK) { /* TODO: make status return type of this function (...api change) */ #ifdef STDERR_MSGS fprintf(stderr, "Error parsing rr during AXFR: %s\n", ldns_get_errorstr_by_id(status)); #endif /* we must now also close the socket, otherwise subsequent uses of the same resolver structure will fail because the link is still open or in an undefined state */ close_socket(resolver->_socket); return NULL; } else if (ldns_pkt_get_rcode(resolver->_cur_axfr_pkt) != 0) { #ifdef STDERR_MSGS ldns_lookup_table *rcode = ldns_lookup_by_id( ldns_rcodes,(int) ldns_pkt_get_rcode( resolver->_cur_axfr_pkt)); if (rcode) { fprintf(stderr, "Error in AXFR: %s\n", rcode->name); } else { fprintf(stderr, "Error in AXFR: %d\n", (int) ldns_pkt_get_rcode( resolver->_cur_axfr_pkt)); } #endif /* we must now also close the socket, otherwise subsequent uses of the same resolver structure will fail because the link is still open or in an undefined state */ close_socket(resolver->_socket); return NULL; } else { return ldns_axfr_next(resolver); } } } /* this function is needed to abort a transfer that is in progress; * without it an aborted transfer will lead to the AXFR code in the * library staying in an indetermined state because the socket for the * AXFR is never closed */ void ldns_axfr_abort(ldns_resolver *resolver) { /* Only abort if an actual AXFR is in progress */ if (resolver->_socket != -1) { #ifndef USE_WINSOCK close(resolver->_socket); #else closesocket(resolver->_socket); #endif resolver->_socket = -1; } } bool ldns_axfr_complete(const ldns_resolver *res) { /* complete when soa count is 2? */ return res->_axfr_soa_count == 2; } ldns_pkt * ldns_axfr_last_pkt(const ldns_resolver *res) { return res->_cur_axfr_pkt; } void ldns_resolver_set_ixfr_serial(ldns_resolver *r, uint32_t serial) { r->_serial = serial; } uint32_t ldns_resolver_get_ixfr_serial(const ldns_resolver *res) { return res->_serial; } /* random isn't really that good */ void ldns_resolver_nameservers_randomize(ldns_resolver *r) { uint16_t i, j; ldns_rdf **ns, *tmpns; size_t *rtt, tmprtt; /* should I check for ldns_resolver_random?? */ assert(r != NULL); ns = ldns_resolver_nameservers(r); rtt = ldns_resolver_rtt(r); for (i = 0; i < ldns_resolver_nameserver_count(r); i++) { j = ldns_get_random() % ldns_resolver_nameserver_count(r); tmpns = ns[i]; ns[i] = ns[j]; ns[j] = tmpns; tmprtt = rtt[i]; rtt[i] = rtt[j]; rtt[j] = tmprtt; } ldns_resolver_set_nameservers(r, ns); } ldns-1.9.2/dnssec_zone.c0000664000175000017500000014360015212267520014515 0ustar willemwillem/* * special zone file structures and functions for better dnssec handling */ #include #include ldns_dnssec_rrs * ldns_dnssec_rrs_new(void) { ldns_dnssec_rrs *new_rrs; new_rrs = LDNS_MALLOC(ldns_dnssec_rrs); if(!new_rrs) return NULL; new_rrs->rr = NULL; new_rrs->next = NULL; return new_rrs; } INLINE void ldns_dnssec_rrs_free_internal(ldns_dnssec_rrs *rrs, int deep) { ldns_dnssec_rrs *next; while (rrs) { next = rrs->next; if (deep) { ldns_rr_free(rrs->rr); } LDNS_FREE(rrs); rrs = next; } } void ldns_dnssec_rrs_free(ldns_dnssec_rrs *rrs) { ldns_dnssec_rrs_free_internal(rrs, 0); } void ldns_dnssec_rrs_deep_free(ldns_dnssec_rrs *rrs) { ldns_dnssec_rrs_free_internal(rrs, 1); } ldns_status ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr) { int cmp; ldns_dnssec_rrs *new_rrs; if (!rrs || !rr) { return LDNS_STATUS_ERR; } /* this could be done more efficiently; name and type should already be equal */ cmp = ldns_rr_compare(rrs->rr, rr); if (cmp < 0) { if (rrs->next) { return ldns_dnssec_rrs_add_rr(rrs->next, rr); } else { new_rrs = ldns_dnssec_rrs_new(); new_rrs->rr = rr; rrs->next = new_rrs; } } else if (cmp > 0) { /* put the current old rr in the new next, put the new rr in the current container */ new_rrs = ldns_dnssec_rrs_new(); new_rrs->rr = rrs->rr; new_rrs->next = rrs->next; rrs->rr = rr; rrs->next = new_rrs; } else return LDNS_STATUS_EQUAL_RR; return LDNS_STATUS_OK; } void ldns_dnssec_rrs_print_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_rrs *rrs) { if (!rrs) { if ((fmt->flags & LDNS_COMMENT_LAYOUT)) fprintf(out, "; "); } else { if (rrs->rr) { ldns_rr_print_fmt(out, fmt, rrs->rr); } if (rrs->next) { ldns_dnssec_rrs_print_fmt(out, fmt, rrs->next); } } } void ldns_dnssec_rrs_print(FILE *out, const ldns_dnssec_rrs *rrs) { ldns_dnssec_rrs_print_fmt(out, ldns_output_format_default, rrs); } ldns_dnssec_rrsets * ldns_dnssec_rrsets_new(void) { ldns_dnssec_rrsets *new_rrsets; new_rrsets = LDNS_MALLOC(ldns_dnssec_rrsets); if(!new_rrsets) return NULL; new_rrsets->rrs = NULL; new_rrsets->type = 0; new_rrsets->signatures = NULL; new_rrsets->next = NULL; return new_rrsets; } INLINE void ldns_dnssec_rrsets_free_internal(ldns_dnssec_rrsets *rrsets, int deep) { if (rrsets) { if (rrsets->rrs) { ldns_dnssec_rrs_free_internal(rrsets->rrs, deep); } if (rrsets->next) { ldns_dnssec_rrsets_free_internal(rrsets->next, deep); } if (rrsets->signatures) { ldns_dnssec_rrs_free_internal(rrsets->signatures, deep); } LDNS_FREE(rrsets); } } void ldns_dnssec_rrsets_free(ldns_dnssec_rrsets *rrsets) { ldns_dnssec_rrsets_free_internal(rrsets, 0); } void ldns_dnssec_rrsets_deep_free(ldns_dnssec_rrsets *rrsets) { ldns_dnssec_rrsets_free_internal(rrsets, 1); } ldns_rr_type ldns_dnssec_rrsets_type(const ldns_dnssec_rrsets *rrsets) { if (rrsets) { return rrsets->type; } else { return 0; } } ldns_status ldns_dnssec_rrsets_set_type(ldns_dnssec_rrsets *rrsets, ldns_rr_type type) { if (rrsets) { rrsets->type = type; return LDNS_STATUS_OK; } return LDNS_STATUS_ERR; } static ldns_dnssec_rrsets * ldns_dnssec_rrsets_new_frm_rr(ldns_rr *rr) { ldns_dnssec_rrsets *new_rrsets; ldns_rr_type rr_type; bool rrsig; new_rrsets = ldns_dnssec_rrsets_new(); rr_type = ldns_rr_get_type(rr); if (rr_type == LDNS_RR_TYPE_RRSIG) { rrsig = true; rr_type = ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr)); } else { rrsig = false; } if (!rrsig) { new_rrsets->rrs = ldns_dnssec_rrs_new(); new_rrsets->rrs->rr = rr; } else { new_rrsets->signatures = ldns_dnssec_rrs_new(); new_rrsets->signatures->rr = rr; } new_rrsets->type = rr_type; return new_rrsets; } ldns_status ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr) { ldns_dnssec_rrsets *new_rrsets; ldns_rr_type rr_type; bool rrsig = false; ldns_status result = LDNS_STATUS_OK; if (!rrsets || !rr) { return LDNS_STATUS_ERR; } rr_type = ldns_rr_get_type(rr); if (rr_type == LDNS_RR_TYPE_RRSIG) { rrsig = true; rr_type = ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr)); } if (!rrsets->rrs && rrsets->type == 0 && !rrsets->signatures) { if (!rrsig) { rrsets->rrs = ldns_dnssec_rrs_new(); rrsets->rrs->rr = rr; rrsets->type = rr_type; } else { rrsets->signatures = ldns_dnssec_rrs_new(); rrsets->signatures->rr = rr; rrsets->type = rr_type; } return LDNS_STATUS_OK; } if (rr_type > ldns_dnssec_rrsets_type(rrsets)) { if (rrsets->next) { result = ldns_dnssec_rrsets_add_rr(rrsets->next, rr); } else { new_rrsets = ldns_dnssec_rrsets_new_frm_rr(rr); rrsets->next = new_rrsets; } } else if (rr_type < ldns_dnssec_rrsets_type(rrsets)) { /* move the current one into the new next, replace field of current with data from new rr */ new_rrsets = ldns_dnssec_rrsets_new(); new_rrsets->rrs = rrsets->rrs; new_rrsets->type = rrsets->type; new_rrsets->signatures = rrsets->signatures; new_rrsets->next = rrsets->next; if (!rrsig) { rrsets->rrs = ldns_dnssec_rrs_new(); rrsets->rrs->rr = rr; rrsets->signatures = NULL; } else { rrsets->rrs = NULL; rrsets->signatures = ldns_dnssec_rrs_new(); rrsets->signatures->rr = rr; } rrsets->type = rr_type; rrsets->next = new_rrsets; } else { /* equal, add to current rrsets */ if (rrsig) { if (rrsets->signatures) { result = ldns_dnssec_rrs_add_rr(rrsets->signatures, rr); } else { rrsets->signatures = ldns_dnssec_rrs_new(); rrsets->signatures->rr = rr; } } else { if (rrsets->rrs) { result = ldns_dnssec_rrs_add_rr(rrsets->rrs, rr); } else { rrsets->rrs = ldns_dnssec_rrs_new(); rrsets->rrs->rr = rr; } } } return result; } static void ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_rrsets *rrsets, bool follow, bool show_soa) { if (!rrsets) { if ((fmt->flags & LDNS_COMMENT_LAYOUT)) fprintf(out, "; \n"); } else { if (rrsets->rrs && (show_soa || ldns_rr_get_type(rrsets->rrs->rr) != LDNS_RR_TYPE_SOA ) ) { ldns_dnssec_rrs_print_fmt(out, fmt, rrsets->rrs); if (rrsets->signatures) { ldns_dnssec_rrs_print_fmt(out, fmt, rrsets->signatures); } } if (follow && rrsets->next) { ldns_dnssec_rrsets_print_soa_fmt(out, fmt, rrsets->next, follow, show_soa); } } } void ldns_dnssec_rrsets_print_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_rrsets *rrsets, bool follow) { ldns_dnssec_rrsets_print_soa_fmt(out, fmt, rrsets, follow, true); } void ldns_dnssec_rrsets_print(FILE *out, const ldns_dnssec_rrsets *rrsets, bool follow) { ldns_dnssec_rrsets_print_fmt(out, ldns_output_format_default, rrsets, follow); } ldns_dnssec_name * ldns_dnssec_name_new(void) { ldns_dnssec_name *new_name; new_name = LDNS_CALLOC(ldns_dnssec_name, 1); if (!new_name) { return NULL; } /* * not needed anymore because CALLOC initializes everything to zero. new_name->name = NULL; new_name->rrsets = NULL; new_name->name_alloced = false; new_name->nsec = NULL; new_name->nsec_signatures = NULL; new_name->is_glue = false; new_name->hashed_name = NULL; */ return new_name; } ldns_dnssec_name * ldns_dnssec_name_new_frm_rr(ldns_rr *rr) { ldns_dnssec_name *new_name = ldns_dnssec_name_new(); new_name->name = ldns_rr_owner(rr); if(ldns_dnssec_name_add_rr(new_name, rr) != LDNS_STATUS_OK) { ldns_dnssec_name_free(new_name); return NULL; } return new_name; } INLINE void ldns_dnssec_name_free_internal(ldns_dnssec_name *name, int deep) { if (name) { if (name->name_alloced) { ldns_rdf_deep_free(name->name); } if (name->rrsets) { ldns_dnssec_rrsets_free_internal(name->rrsets, deep); } if (name->nsec && deep) { ldns_rr_free(name->nsec); } if (name->nsec_signatures) { ldns_dnssec_rrs_free_internal(name->nsec_signatures, deep); } if (name->hashed_name) { /* Hashed name is always allocated when signing, * so always deep free */ ldns_rdf_deep_free(name->hashed_name); } LDNS_FREE(name); } } void ldns_dnssec_name_free(ldns_dnssec_name *name) { ldns_dnssec_name_free_internal(name, 0); } void ldns_dnssec_name_deep_free(ldns_dnssec_name *name) { ldns_dnssec_name_free_internal(name, 1); } ldns_rdf * ldns_dnssec_name_name(const ldns_dnssec_name *name) { if (name) { return name->name; } return NULL; } bool ldns_dnssec_name_is_glue(const ldns_dnssec_name *name) { if (name) { return name->is_glue; } return false; } void ldns_dnssec_name_set_name(ldns_dnssec_name *rrset, ldns_rdf *dname) { if (rrset && dname) { rrset->name = dname; } } void ldns_dnssec_name_set_nsec(ldns_dnssec_name *rrset, ldns_rr *nsec) { if (rrset && nsec) { rrset->nsec = nsec; } } int ldns_dnssec_name_cmp(const void *a, const void *b) { ldns_dnssec_name *na = (ldns_dnssec_name *) a; ldns_dnssec_name *nb = (ldns_dnssec_name *) b; if (na && nb) { return ldns_dname_compare(ldns_dnssec_name_name(na), ldns_dnssec_name_name(nb)); } else if (na) { return 1; } else if (nb) { return -1; } else { return 0; } } ldns_status ldns_dnssec_name_add_rr(ldns_dnssec_name *name, ldns_rr *rr) { ldns_status result = LDNS_STATUS_OK; ldns_rr_type rr_type; ldns_rr_type typecovered = 0; /* special handling for NSEC3 and NSECX covering RRSIGS */ if (!name || !rr) { return LDNS_STATUS_ERR; } rr_type = ldns_rr_get_type(rr); if (rr_type == LDNS_RR_TYPE_RRSIG) { typecovered = ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr)); } if (rr_type == LDNS_RR_TYPE_NSEC || rr_type == LDNS_RR_TYPE_NSEC3) { /* XX check if is already set (and error?) */ name->nsec = rr; } else if (typecovered == LDNS_RR_TYPE_NSEC || typecovered == LDNS_RR_TYPE_NSEC3) { if (name->nsec_signatures) { result = ldns_dnssec_rrs_add_rr(name->nsec_signatures, rr); } else { name->nsec_signatures = ldns_dnssec_rrs_new(); name->nsec_signatures->rr = rr; } } else { /* it's a 'normal' RR, add it to the right rrset */ if (name->rrsets) { result = ldns_dnssec_rrsets_add_rr(name->rrsets, rr); } else { name->rrsets = ldns_dnssec_rrsets_new(); result = ldns_dnssec_rrsets_add_rr(name->rrsets, rr); } } return result; } ldns_dnssec_rrsets * ldns_dnssec_name_find_rrset(const ldns_dnssec_name *name, ldns_rr_type type) { ldns_dnssec_rrsets *result; result = name->rrsets; while (result) { if (result->type == type) { return result; } else { result = result->next; } } return NULL; } ldns_dnssec_rrsets * ldns_dnssec_zone_find_rrset(const ldns_dnssec_zone *zone, const ldns_rdf *dname, ldns_rr_type type) { ldns_rbnode_t *node; if (!zone || !dname || !zone->names) { return NULL; } node = ldns_rbtree_search(zone->names, dname); if (node) { return ldns_dnssec_name_find_rrset((ldns_dnssec_name *)node->data, type); } else { return NULL; } } static void ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_name *name, bool show_soa) { if (name) { if(name->rrsets) { ldns_dnssec_rrsets_print_soa_fmt(out, fmt, name->rrsets, true, show_soa); } else if ((fmt->flags & LDNS_COMMENT_LAYOUT)) { fprintf(out, ";; Empty nonterminal: "); ldns_rdf_print(out, name->name); fprintf(out, "\n"); } if(name->nsec) { ldns_rr_print_fmt(out, fmt, name->nsec); } if (name->nsec_signatures) { ldns_dnssec_rrs_print_fmt(out, fmt, name->nsec_signatures); } } else if ((fmt->flags & LDNS_COMMENT_LAYOUT)) { fprintf(out, "; \n"); } } void ldns_dnssec_name_print_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_name *name) { ldns_dnssec_name_print_soa_fmt(out, fmt, name, true); } void ldns_dnssec_name_print(FILE *out, const ldns_dnssec_name *name) { ldns_dnssec_name_print_fmt(out, ldns_output_format_default, name); } ldns_dnssec_zone * ldns_dnssec_zone_new(void) { ldns_dnssec_zone *zone = LDNS_MALLOC(ldns_dnssec_zone); if(!zone) return NULL; zone->soa = NULL; zone->names = NULL; zone->hashed_names = NULL; zone->_nsec3params = NULL; return zone; } static bool rr_is_rrsig_covering(ldns_rr* rr, ldns_rr_type t) { return ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG && ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr)) == t; } /* When the zone is first read into an list and then inserted into an * ldns_dnssec_zone (rbtree) the nodes of the rbtree are allocated close (next) * to each other. Because ldns-verify-zone (the only program that uses this * function) uses the rbtree mostly for sequential walking, this results * in a speed increase (of 15% on linux) because we have less CPU-cache misses. */ #define FASTER_DNSSEC_ZONE_NEW_FRM_FP 1 /* Because of L2 cache efficiency */ static ldns_status ldns_dnssec_zone_add_empty_nonterminals_nsec3( ldns_dnssec_zone *zone, ldns_rbtree_t *nsec3s); static void ldns_todo_nsec3_ents_node_free(ldns_rbnode_t *node, void *arg) { (void) arg; ldns_rdf_deep_free((ldns_rdf *)node->key); LDNS_FREE(node); } ldns_status ldns_dnssec_zone_new_frm_fp_l(ldns_dnssec_zone** z, FILE* fp, const ldns_rdf* origin, uint32_t default_ttl, ldns_rr_class ATTR_UNUSED(c), int* line_nr) { ldns_rr* cur_rr; size_t i; ldns_rdf *my_origin = NULL; ldns_rdf *my_prev = NULL; ldns_dnssec_zone *newzone = ldns_dnssec_zone_new(); /* NSEC3s may occur before the names they refer to. We must remember them and add them to the name later on, after the name is read. We track not yet matching NSEC3s*n the todo_nsec3s list */ ldns_rr_list* todo_nsec3s = ldns_rr_list_new(); /* when reading NSEC3s, there is a chance that we encounter nsecs for empty nonterminals, whose nonterminals we cannot derive yet because the needed information is to be read later. nsec3_ents (where ent is e.n.t.; i.e. empty non terminal) will hold the NSEC3s that still didn't have a matching name in the zone tree, even after all names were read. They can only match after the zone is equipped with all the empty non terminals. */ ldns_rbtree_t todo_nsec3_ents; ldns_rbnode_t *new_node; ldns_rr_list* todo_nsec3_rrsigs = ldns_rr_list_new(); ldns_status status; #ifdef FASTER_DNSSEC_ZONE_NEW_FRM_FP ldns_zone* zone = NULL; #else ldns_rr *prev_rr = NULL; uint32_t my_ttl = default_ttl; /* RFC 1035 Section 5.1, says 'Omitted class and TTL values are default * to the last explicitly stated values.' */ bool ttl_from_TTL = false; bool explicit_ttl = false; #endif ldns_rbtree_init(&todo_nsec3_ents, ldns_dname_compare_v); #ifdef FASTER_DNSSEC_ZONE_NEW_FRM_FP status = ldns_zone_new_frm_fp_l(&zone, fp, origin, default_ttl, c, line_nr); if (status != LDNS_STATUS_OK) goto error; #endif if (!newzone || !todo_nsec3s || !todo_nsec3_rrsigs ) { status = LDNS_STATUS_MEM_ERR; goto error; } if (origin) { if (!(my_origin = ldns_rdf_clone(origin))) { status = LDNS_STATUS_MEM_ERR; goto error; } if (!(my_prev = ldns_rdf_clone(origin))) { status = LDNS_STATUS_MEM_ERR; goto error; } } #ifdef FASTER_DNSSEC_ZONE_NEW_FRM_FP if (ldns_zone_soa(zone)) { status = ldns_dnssec_zone_add_rr(newzone, ldns_zone_soa(zone)); if (status != LDNS_STATUS_OK) goto error; } for (i = 0; i < ldns_rr_list_rr_count(ldns_zone_rrs(zone)); i++) { cur_rr = ldns_rr_list_rr(ldns_zone_rrs(zone), i); status = LDNS_STATUS_OK; #else while (!feof(fp)) { /* If ttl came from $TTL line, then it should be the default. * (RFC 2308 Section 4) * Otherwise it "defaults to the last explicitly stated value" * (RFC 1035 Section 5.1) */ if (ttl_from_TTL) my_ttl = default_ttl; status = ldns_rr_new_frm_fp_l(&cur_rr, fp, &my_ttl, &my_origin, &my_prev, line_nr, &explicit_ttl); #endif switch (status) { case LDNS_STATUS_OK: #ifndef FASTER_DNSSEC_ZONE_NEW_FRM_FP if (explicit_ttl) { if (!ttl_from_TTL) { /* No $TTL, so ttl "defaults to the * last explicitly stated value" * (RFC 1035 Section 5.1) */ my_ttl = ldns_rr_ttl(cur_rr); } /* When ttl is implicit, try to adhere to the rules as * much as possible. (also for compatibility with bind) * This was changed when fixing an issue with ZONEMD * which hashes the TTL too. */ } else if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_SIG || ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_RRSIG) { if (ldns_rr_rd_count(cur_rr) >= 4 && ldns_rdf_get_type(ldns_rr_rdf(cur_rr, 3)) == LDNS_RDF_TYPE_INT32) /* SIG without explicit ttl get ttl * from the original_ttl field * (RFC 2535 Section 7.2) * * Similarly for RRSIG, but stated less * specifically in the spec. * (RFC 4034 Section 3) */ ldns_rr_set_ttl(cur_rr, ldns_rdf2native_int32( ldns_rr_rdf(rr, 3))); } else if (prev_rr && ldns_rr_get_type(prev_rr) == ldns_rr_get_type(cur_rr) && ldns_dname_compare( ldns_rr_owner(prev_rr) , ldns_rr_owner(cur_rr)) == 0) /* "TTLs of all RRs in an RRSet must be the same" * (RFC 2881 Section 5.2) */ ldns_rr_set_ttl(cur_rr, ldns_rr_ttl(prev_rr)); #endif status = ldns_dnssec_zone_add_rr(newzone, cur_rr); switch(status) { case LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND: if (rr_is_rrsig_covering(cur_rr, LDNS_RR_TYPE_NSEC3)){ ldns_rr_list_push_rr(todo_nsec3_rrsigs, cur_rr); } else { ldns_rr_list_push_rr(todo_nsec3s, cur_rr); } status = LDNS_STATUS_OK; break; case LDNS_STATUS_EQUAL_RR: ldns_rr_free(cur_rr); #ifndef FASTER_DNSSEC_ZONE_NEW_FRM_FP cur_rr = prev_rr; #else cur_rr = NULL; #endif status = LDNS_STATUS_OK; break; case LDNS_STATUS_OK: break; default: goto error; } #ifndef FASTER_DNSSEC_ZONE_NEW_FRM_FP prev_rr = cur_rr; #endif break; case LDNS_STATUS_SYNTAX_TTL: /* the ttl was set*/ #ifndef FASTER_DNSSEC_ZONE_NEW_FRM_FP default_ttl = my_ttl; ttl_from_TTL = true; #endif status = LDNS_STATUS_OK; break; case LDNS_STATUS_SYNTAX_EMPTY: /* empty line was seen */ case LDNS_STATUS_SYNTAX_ORIGIN: /* the origin was set*/ status = LDNS_STATUS_OK; break; case LDNS_STATUS_SYNTAX_INCLUDE:/* $include not implemented */ status = LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL; break; default: goto error; } } for (i = 0; status == LDNS_STATUS_OK && i < ldns_rr_list_rr_count(todo_nsec3s); i++) { cur_rr = ldns_rr_list_rr(todo_nsec3s, i); status = ldns_dnssec_zone_add_rr(newzone, cur_rr); if (status == LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND) { if (!(new_node = LDNS_MALLOC(ldns_rbnode_t))) { status = LDNS_STATUS_MEM_ERR; break; } new_node->key = ldns_dname_label(ldns_rr_owner(cur_rr), 0); new_node->data = cur_rr; if (!ldns_rbtree_insert(&todo_nsec3_ents, new_node)) { LDNS_FREE(new_node); status = LDNS_STATUS_MEM_ERR; break; } status = LDNS_STATUS_OK; } } if (todo_nsec3_ents.count > 0) (void) ldns_dnssec_zone_add_empty_nonterminals_nsec3( newzone, &todo_nsec3_ents); for (i = 0; status == LDNS_STATUS_OK && i < ldns_rr_list_rr_count(todo_nsec3_rrsigs); i++) { cur_rr = ldns_rr_list_rr(todo_nsec3_rrsigs, i); status = ldns_dnssec_zone_add_rr(newzone, cur_rr); } if (z) { *z = newzone; newzone = NULL; } else { ldns_dnssec_zone_free(newzone); newzone = NULL; } error: #ifdef FASTER_DNSSEC_ZONE_NEW_FRM_FP if (zone) { ldns_zone_free(zone); } #endif ldns_rr_list_free(todo_nsec3_rrsigs); ldns_traverse_postorder(&todo_nsec3_ents, ldns_todo_nsec3_ents_node_free, NULL); ldns_rr_list_free(todo_nsec3s); if (my_origin) { ldns_rdf_deep_free(my_origin); } if (my_prev) { ldns_rdf_deep_free(my_prev); } if (newzone) { ldns_dnssec_zone_free(newzone); } return status; } ldns_status ldns_dnssec_zone_new_frm_fp(ldns_dnssec_zone** z, FILE* fp, const ldns_rdf* origin, uint32_t ttl, ldns_rr_class ATTR_UNUSED(c)) { return ldns_dnssec_zone_new_frm_fp_l(z, fp, origin, ttl, c, NULL); } static void ldns_dnssec_name_node_free(ldns_rbnode_t *node, void *arg) { (void) arg; ldns_dnssec_name_free((ldns_dnssec_name *)node->data); LDNS_FREE(node); } static void ldns_dnssec_name_node_deep_free(ldns_rbnode_t *node, void *arg) { (void) arg; ldns_dnssec_name_deep_free((ldns_dnssec_name *)node->data); LDNS_FREE(node); } static void ldns_hashed_names_node_free(ldns_rbnode_t *node, void *arg) { (void) arg; LDNS_FREE(node); } void ldns_dnssec_zone_free(ldns_dnssec_zone *zone) { if (zone) { if (zone->hashed_names) { ldns_traverse_postorder(zone->hashed_names, ldns_hashed_names_node_free, NULL); LDNS_FREE(zone->hashed_names); } if (zone->names) { /* destroy all name structures within the tree */ ldns_traverse_postorder(zone->names, ldns_dnssec_name_node_free, NULL); LDNS_FREE(zone->names); } LDNS_FREE(zone); } } void ldns_dnssec_zone_deep_free(ldns_dnssec_zone *zone) { if (zone) { if (zone->hashed_names) { ldns_traverse_postorder(zone->hashed_names, ldns_hashed_names_node_free, NULL); LDNS_FREE(zone->hashed_names); } if (zone->names) { /* destroy all name structures within the tree */ ldns_traverse_postorder(zone->names, ldns_dnssec_name_node_deep_free, NULL); LDNS_FREE(zone->names); } LDNS_FREE(zone); } } /* use for dname comparison in tree */ int ldns_dname_compare_v(const void *a, const void *b) { return ldns_dname_compare((ldns_rdf *)a, (ldns_rdf *)b); } static void ldns_dnssec_name_make_hashed_name(ldns_dnssec_zone *zone, ldns_dnssec_name* name, ldns_rr* nsec3rr); static void ldns_dnssec_zone_hashed_names_from_nsec3( ldns_dnssec_zone* zone, ldns_rr* nsec3rr) { ldns_rbnode_t* current_node; ldns_dnssec_name* current_name; assert(zone != NULL); assert(nsec3rr != NULL); if (zone->hashed_names) { ldns_traverse_postorder(zone->hashed_names, ldns_hashed_names_node_free, NULL); LDNS_FREE(zone->hashed_names); } zone->_nsec3params = nsec3rr; /* So this is a NSEC3 zone. * Calculate hashes for all names already in the zone */ zone->hashed_names = ldns_rbtree_create(ldns_dname_compare_v); if (zone->hashed_names == NULL) { return; } for ( current_node = ldns_rbtree_first(zone->names) ; current_node != LDNS_RBTREE_NULL ; current_node = ldns_rbtree_next(current_node) ) { current_name = (ldns_dnssec_name *) current_node->data; ldns_dnssec_name_make_hashed_name(zone, current_name, nsec3rr); } } static void ldns_dnssec_name_make_hashed_name(ldns_dnssec_zone *zone, ldns_dnssec_name* name, ldns_rr* nsec3rr) { ldns_rbnode_t* new_node; assert(name != NULL); if (! zone->_nsec3params) { if (! nsec3rr) { return; } ldns_dnssec_zone_hashed_names_from_nsec3(zone, nsec3rr); } else if (! nsec3rr) { nsec3rr = zone->_nsec3params; } name->hashed_name = ldns_nsec3_hash_name_frm_nsec3(nsec3rr, name->name); /* Also store in zone->hashed_names */ if ((new_node = LDNS_MALLOC(ldns_rbnode_t))) { new_node->key = name->hashed_name; new_node->data = name; if (ldns_rbtree_insert(zone->hashed_names, new_node) == NULL) { LDNS_FREE(new_node); } } } static ldns_rbnode_t * ldns_dnssec_zone_find_nsec3_original(ldns_dnssec_zone *zone, ldns_rr *rr) { ldns_rdf *hashed_name; ldns_rbnode_t *to_return; if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_NSEC3 && ! zone->_nsec3params){ ldns_dnssec_zone_hashed_names_from_nsec3(zone, rr); } if (zone->hashed_names == NULL) { return NULL; } hashed_name = ldns_dname_label(ldns_rr_owner(rr), 0); if (hashed_name == NULL) { return NULL; } to_return = ldns_rbtree_search(zone->hashed_names, hashed_name); ldns_rdf_deep_free(hashed_name); return to_return; } ldns_status ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr) { ldns_status result = LDNS_STATUS_OK; ldns_dnssec_name *cur_name; ldns_rbnode_t *cur_node; ldns_rr_type type_covered = 0; if (!zone || !rr) { return LDNS_STATUS_ERR; } if (!zone->names) { zone->names = ldns_rbtree_create(ldns_dname_compare_v); if(!zone->names) return LDNS_STATUS_MEM_ERR; } /* we need the original of the hashed name if this is an NSEC3, or an RRSIG that covers an NSEC3 */ if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG) { type_covered = ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr)); } if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_NSEC3 || type_covered == LDNS_RR_TYPE_NSEC3) { cur_node = ldns_dnssec_zone_find_nsec3_original(zone, rr); if (!cur_node) { return LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND; } } else { cur_node = ldns_rbtree_search(zone->names, ldns_rr_owner(rr)); } if (!cur_node) { /* add */ cur_name = ldns_dnssec_name_new_frm_rr(rr); if(!cur_name) return LDNS_STATUS_MEM_ERR; cur_node = LDNS_MALLOC(ldns_rbnode_t); if(!cur_node) { ldns_dnssec_name_free(cur_name); return LDNS_STATUS_MEM_ERR; } cur_node->key = ldns_rr_owner(rr); cur_node->data = cur_name; (void)ldns_rbtree_insert(zone->names, cur_node); ldns_dnssec_name_make_hashed_name(zone, cur_name, NULL); } else { cur_name = (ldns_dnssec_name *) cur_node->data; result = ldns_dnssec_name_add_rr(cur_name, rr); } if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) { zone->soa = cur_name; } return result; } void ldns_dnssec_zone_names_print_fmt(FILE *out, const ldns_output_format *fmt, const ldns_rbtree_t *tree, bool print_soa) { ldns_rbnode_t *node; ldns_dnssec_name *name; node = ldns_rbtree_first(tree); while (node != LDNS_RBTREE_NULL) { name = (ldns_dnssec_name *) node->data; ldns_dnssec_name_print_soa_fmt(out, fmt, name, print_soa); if ((fmt->flags & LDNS_COMMENT_LAYOUT)) fprintf(out, ";\n"); node = ldns_rbtree_next(node); } } void ldns_dnssec_zone_names_print(FILE *out, const ldns_rbtree_t *tree, bool print_soa) { ldns_dnssec_zone_names_print_fmt(out, ldns_output_format_default, tree, print_soa); } void ldns_dnssec_zone_print_fmt(FILE *out, const ldns_output_format *fmt, const ldns_dnssec_zone *zone) { if (zone) { if (zone->soa) { if ((fmt->flags & LDNS_COMMENT_LAYOUT)) { fprintf(out, ";; Zone: "); ldns_rdf_print(out, ldns_dnssec_name_name( zone->soa)); fprintf(out, "\n;\n"); } ldns_dnssec_rrsets_print_fmt(out, fmt, ldns_dnssec_name_find_rrset( zone->soa, LDNS_RR_TYPE_SOA), false); if ((fmt->flags & LDNS_COMMENT_LAYOUT)) fprintf(out, ";\n"); } if (zone->names) { ldns_dnssec_zone_names_print_fmt(out, fmt, zone->names, false); } } } void ldns_dnssec_zone_print(FILE *out, const ldns_dnssec_zone *zone) { ldns_dnssec_zone_print_fmt(out, ldns_output_format_default, zone); } static ldns_status ldns_dnssec_zone_add_empty_nonterminals_nsec3( ldns_dnssec_zone *zone, ldns_rbtree_t *nsec3s) { ldns_dnssec_name *new_name; ldns_rdf *cur_name; ldns_rdf *next_name; ldns_rbnode_t *cur_node, *next_node, *new_node; /* for the detection */ uint16_t i, cur_label_count, next_label_count; uint16_t soa_label_count = 0; ldns_rdf *l1, *l2; int lpos; if (!zone) { return LDNS_STATUS_ERR; } if (zone->soa && zone->soa->name) { soa_label_count = ldns_dname_label_count(zone->soa->name); } cur_node = ldns_rbtree_first(zone->names); while (cur_node != LDNS_RBTREE_NULL) { next_node = ldns_rbtree_next(cur_node); /* skip glue */ while (next_node != LDNS_RBTREE_NULL && next_node->data && ((ldns_dnssec_name *)next_node->data)->is_glue ) { next_node = ldns_rbtree_next(next_node); } if (next_node == LDNS_RBTREE_NULL) { next_node = ldns_rbtree_first(zone->names); } if (! cur_node->data || ! next_node->data) { return LDNS_STATUS_ERR; } cur_name = ((ldns_dnssec_name *)cur_node->data)->name; next_name = ((ldns_dnssec_name *)next_node->data)->name; cur_label_count = ldns_dname_label_count(cur_name); next_label_count = ldns_dname_label_count(next_name); /* Since the names are in canonical order, we can * recognize empty non-terminals by their labels; * every label after the first one on the next owner * name is a non-terminal if it either does not exist * in the current name or is different from the same * label in the current name (counting from the end) */ for (i = 1; i < next_label_count - soa_label_count; i++) { lpos = (int)cur_label_count - (int)next_label_count + (int)i; if (lpos >= 0) { l1 = ldns_dname_clone_from(cur_name, (uint8_t)lpos); } else { l1 = NULL; } l2 = ldns_dname_clone_from(next_name, i); if (!l1 || ldns_dname_compare(l1, l2) != 0) { /* We have an empty nonterminal, add it to the * tree */ ldns_rbnode_t *node = NULL; ldns_rdf *ent_name; if (!(ent_name = ldns_dname_clone_from( next_name, i))) { ldns_rdf_deep_free(l1); ldns_rdf_deep_free(l2); return LDNS_STATUS_MEM_ERR; } if (nsec3s && zone->_nsec3params) { ldns_rdf *ent_hashed_name; if (!(ent_hashed_name = ldns_nsec3_hash_name_frm_nsec3( zone->_nsec3params, ent_name))) { ldns_rdf_deep_free(l1); ldns_rdf_deep_free(l2); ldns_rdf_deep_free(ent_name); return LDNS_STATUS_MEM_ERR; } node = ldns_rbtree_search(nsec3s, ent_hashed_name); ldns_rdf_deep_free(ent_hashed_name); if (!node) { ldns_rdf_deep_free(l1); ldns_rdf_deep_free(l2); ldns_rdf_deep_free(ent_name); continue; } } new_name = ldns_dnssec_name_new(); if (!new_name) { ldns_rdf_deep_free(l1); ldns_rdf_deep_free(l2); ldns_rdf_deep_free(ent_name); return LDNS_STATUS_MEM_ERR; } new_name->name = ent_name; new_name->name_alloced = true; new_node = LDNS_MALLOC(ldns_rbnode_t); if (!new_node) { ldns_rdf_deep_free(l1); ldns_rdf_deep_free(l2); ldns_dnssec_name_free(new_name); return LDNS_STATUS_MEM_ERR; } new_node->key = new_name->name; new_node->data = new_name; (void)ldns_rbtree_insert(zone->names, new_node); ldns_dnssec_name_make_hashed_name( zone, new_name, NULL); if (node) (void) ldns_dnssec_zone_add_rr(zone, (ldns_rr *)node->data); } ldns_rdf_deep_free(l1); ldns_rdf_deep_free(l2); } /* we might have inserted a new node after * the current one so we can't just use next() */ if (next_node != ldns_rbtree_first(zone->names)) { cur_node = next_node; } else { cur_node = LDNS_RBTREE_NULL; } } return LDNS_STATUS_OK; } ldns_status ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone) { return ldns_dnssec_zone_add_empty_nonterminals_nsec3(zone, NULL); } bool ldns_dnssec_zone_is_nsec3_optout(const ldns_dnssec_zone* zone) { ldns_rr* nsec3; ldns_rbnode_t* node; if (ldns_dnssec_name_find_rrset(zone->soa, LDNS_RR_TYPE_NSEC3PARAM)) { node = ldns_rbtree_first(zone->names); while (node != LDNS_RBTREE_NULL) { nsec3 = ((ldns_dnssec_name*)node->data)->nsec; if (nsec3 &&ldns_rr_get_type(nsec3) == LDNS_RR_TYPE_NSEC3 && ldns_nsec3_optout(nsec3)) { return true; } node = ldns_rbtree_next(node); } } return false; } /* * Stuff for calculating and verifying zone digests */ typedef enum dnssec_zone_rr_iter_state { DNSSEC_ZONE_RR_ITER_LT_RRSIG , DNSSEC_ZONE_RR_ITER_RRSIGs_NO_NSEC , DNSSEC_ZONE_RR_ITER_REST , DNSSEC_ZONE_RR_ITER_RRSIGs_NSEC , DNSSEC_ZONE_RR_ITER_RRSIGs_NSEC_REST , DNSSEC_ZONE_RR_ITER_NSEC3 , DNSSEC_ZONE_RR_ITER_FINI } dnssec_zone_rr_iter_state; typedef struct dnssec_zone_rr_iter { ldns_dnssec_zone *zone; ldns_rbnode_t *node; ldns_dnssec_name *name; ldns_dnssec_rrsets *rrsets; ldns_dnssec_rrs *rrs; ldns_dnssec_rrsets *rrsets4rrsigs; ldns_rbnode_t *nsec3_node; ldns_dnssec_name *nsec3_name; dnssec_zone_rr_iter_state state; ldns_rdf *apex_name; uint8_t apex_labs; } dnssec_zone_rr_iter; INLINE void dnssec_zone_rr_iter_set_state_for_next_name(dnssec_zone_rr_iter *i) { /* Make sure the i->name is "in zone" (i.e. below the apex) */ if (i->apex_name) { ldns_rdf *name = (ldns_rdf *)i->node->key; while (i->name && name != i->apex_name /* not apex */ && ( ldns_dname_label_count(name) != i->apex_labs || ldns_dname_compare(name, i->apex_name)) /* not apex */ && !ldns_dname_is_subdomain(name, i->apex_name) /* no sub */) { /* next name */ i->node = ldns_rbtree_next(i->node); if (i->node == LDNS_RBTREE_NULL) i->name = NULL; else { i->name = (ldns_dnssec_name *)i->node->data; name = (ldns_rdf *)i->node->key; } } } /* determine state */ if (!i->name) { if (!i->nsec3_name) i->state = DNSSEC_ZONE_RR_ITER_FINI; else { i->rrs = i->nsec3_name->nsec_signatures; i->state = DNSSEC_ZONE_RR_ITER_NSEC3; } } else if (!i->nsec3_name) { i->rrsets = i->name->rrsets; i->state = DNSSEC_ZONE_RR_ITER_LT_RRSIG; } else if (ldns_dname_compare( ldns_rr_owner(i->nsec3_name->nsec) , (ldns_rdf *)i->node->key) < 0) { i->rrs = i->nsec3_name->nsec_signatures; i->state = DNSSEC_ZONE_RR_ITER_NSEC3; } else { i->rrsets = i->name->rrsets; i->state = DNSSEC_ZONE_RR_ITER_LT_RRSIG; } } /** * Iterate over the RR's in the ldns_dnssec_zone in canonical order. * There are three possible paths through the RR's in a ldns_dnssec_name. * * 1. There is no NSEC: * * 1.1. All the RRs in the name->rrsets with type < RRSIG, * state: DNSSEC_ZONE_RR_ITER_LT_RRSIG * * 1.2. Then all the RRSIGs from name->rrsets (likely none) * state: DNSSEC_ZONE_RR_ITER_RRSIGs_NO_NSEC * * 1.3. Finally the remaining RRs in name->rrsets (type > RRSIG) * state: DNSSEC_ZONE_RR_ITER_REST * * * 2. There is a NSEC of type NSEC with this name: * * 2.1. All the RRs in the name->rrsets with type < RRSIG, * state: DNSSEC_ZONE_RR_ITER_LT_RRSIG * * 2.2. Then all the RRSIGs from name->rrsets with type < NSEC * state: DNSSEC_ZONE_RR_ITER_RRSIGs_NO_NSEC * * 2.3. Then the signatures of the NSEC RR, followed by * the signatures of the remaining name->rrsets (type > NSEC), * followed by the NSEC rr. * state: DNSSEC_ZONE_RR_ITER_RRSIGs_NO_NSEC * * 2.4. Finally the remaining RRs in name->rrsets (type > RRSIG) * state: DNSSEC_ZONE_RR_ITER_REST * * * 3. There is a NSEC of type NSEC3 for this name: * * 3.1. If the NSEC3 name is before the name for other RRsets in the zone, * Then all signatures of the NSEC3 RR, followed by the NSEC3 * state: DNSSEC_ZONE_RR_ITER_NSEC3 * * otherwise follow path for "no NSEC" for the name for other RRsets */ static ldns_rr * dnssec_zone_rr_iter_next(dnssec_zone_rr_iter *i) { ldns_rr *nsec3; for (;;) { if (i->rrs) { ldns_rr *rr = i->rrs->rr; i->rrs = i->rrs->next; return rr; } switch (i->state) { case DNSSEC_ZONE_RR_ITER_LT_RRSIG: if (i->rrsets && i->rrsets->type < LDNS_RR_TYPE_RRSIG) { i->rrs = i->rrsets->rrs; i->rrsets = i->rrsets->next; break; } i->rrsets4rrsigs = i->name->rrsets; if (i->name->nsec && ldns_rr_get_type(i->name->nsec) == LDNS_RR_TYPE_NSEC) { i->state = DNSSEC_ZONE_RR_ITER_RRSIGs_NSEC; break; } i->state = DNSSEC_ZONE_RR_ITER_RRSIGs_NO_NSEC; /* fallthrough */ case DNSSEC_ZONE_RR_ITER_RRSIGs_NO_NSEC: if (i->rrsets4rrsigs) { i->rrs = i->rrsets4rrsigs->signatures; i->rrsets4rrsigs = i->rrsets4rrsigs->next; break; } i->state = DNSSEC_ZONE_RR_ITER_REST; /* fallthrough */ case DNSSEC_ZONE_RR_ITER_REST: if (i->rrsets) { i->rrs = i->rrsets->rrs; i->rrsets = i->rrsets->next; break; } /* next name */ i->node = ldns_rbtree_next(i->node); i->name = i->node == LDNS_RBTREE_NULL ? NULL : (ldns_dnssec_name *)i->node->data; dnssec_zone_rr_iter_set_state_for_next_name(i); break; case DNSSEC_ZONE_RR_ITER_RRSIGs_NSEC: if (i->rrsets4rrsigs && i->rrsets4rrsigs->type < LDNS_RR_TYPE_NSEC) { i->rrs = i->rrsets4rrsigs->signatures; i->rrsets4rrsigs = i->rrsets4rrsigs->next; break; } i->state = DNSSEC_ZONE_RR_ITER_RRSIGs_NSEC_REST; i->rrs = i->name->nsec_signatures; break; case DNSSEC_ZONE_RR_ITER_RRSIGs_NSEC_REST: if (i->rrsets4rrsigs) { i->rrs = i->rrsets4rrsigs->signatures; i->rrsets4rrsigs = i->rrsets4rrsigs->next; break; } i->state = DNSSEC_ZONE_RR_ITER_REST; return i->name->nsec; case DNSSEC_ZONE_RR_ITER_NSEC3: nsec3 = i->nsec3_name->nsec; /* next nsec3 */ do { i->nsec3_node = ldns_rbtree_next(i->nsec3_node); i->nsec3_name = i->nsec3_node == LDNS_RBTREE_NULL ? NULL : (ldns_dnssec_name*)i->nsec3_node->data; /* names for glue can be in the hashed_names * tree, but will not have a NSEC3 */ } while (i->nsec3_name && !i->nsec3_name->nsec); dnssec_zone_rr_iter_set_state_for_next_name(i); return nsec3; case DNSSEC_ZONE_RR_ITER_FINI: return NULL; } } } static ldns_rr * dnssec_zone_rr_iter_first(dnssec_zone_rr_iter *i, ldns_dnssec_zone *zone) { if (!i || !zone) return NULL; memset(i, 0, sizeof(*i)); i->zone = zone; if (zone->soa && zone->soa->name) { i->apex_name = zone->soa->name; i->apex_labs = ldns_dname_label_count(i->apex_name); } else i->apex_name = NULL; i->node = ldns_rbtree_first(zone->names); i->name = i->node == LDNS_RBTREE_NULL ? NULL : (ldns_dnssec_name *)i->node->data; if (zone->hashed_names) { i->nsec3_node = ldns_rbtree_first(zone->hashed_names); i->nsec3_name = i->nsec3_node == LDNS_RBTREE_NULL ? NULL : (ldns_dnssec_name*)i->nsec3_node->data; /* While there is no NSEC3 RR present at this hashed name, * skip to the next hashed name. */ while (i->nsec3_name && !i->nsec3_name->nsec) { /* next nsec3 */ i->nsec3_node = ldns_rbtree_next(i->nsec3_node); i->nsec3_name = i->nsec3_node == LDNS_RBTREE_NULL ? NULL : (ldns_dnssec_name*)i->nsec3_node->data; } } dnssec_zone_rr_iter_set_state_for_next_name(i); return dnssec_zone_rr_iter_next(i); } enum enum_zonemd_scheme { ZONEMD_SCHEME_FIRST = 1, ZONEMD_SCHEME_SIMPLE = 1, ZONEMD_SCHEME_LAST = 1 }; typedef enum enum_zonemd_scheme zonemd_scheme; enum enum_zonemd_hash { ZONEMD_HASH_FIRST = 1, ZONEMD_HASH_SHA384 = 1, ZONEMD_HASH_SHA512 = 2, ZONEMD_HASH_LAST = 2 }; typedef enum enum_zonemd_hash zonemd_hash; struct struct_zone_digester { ldns_sha384_CTX sha384_CTX; ldns_sha512_CTX sha512_CTX; unsigned simple_sha384 : 1; unsigned simple_sha512 : 1; unsigned double_sha384 : 1; unsigned double_sha512 : 1; }; typedef struct struct_zone_digester zone_digester; INLINE bool zone_digester_set(zone_digester *zd) { return zd && (zd->simple_sha384 || zd->simple_sha512); } INLINE void zone_digester_init(zone_digester *zd) { memset(zd, 0, sizeof(*zd)); } static ldns_status zone_digester_add(zone_digester *zd, zonemd_scheme scheme, zonemd_hash hash) { if (!zd) return LDNS_STATUS_NULL; switch (scheme) { case ZONEMD_SCHEME_SIMPLE: switch (hash) { case ZONEMD_HASH_SHA384: if (zd->double_sha384) return LDNS_STATUS_ZONEMD_DOUBLE_OCCURRENCE; else if (zd->simple_sha384) { zd->simple_sha384 = 0; zd->double_sha384 = 1; return LDNS_STATUS_ZONEMD_DOUBLE_OCCURRENCE; } ldns_sha384_init(&zd->sha384_CTX); zd->simple_sha384 = 1; break; case ZONEMD_HASH_SHA512: if (zd->double_sha512) return LDNS_STATUS_ZONEMD_DOUBLE_OCCURRENCE; else if (zd->simple_sha512) { zd->simple_sha512 = 0; zd->double_sha512 = 1; return LDNS_STATUS_ZONEMD_DOUBLE_OCCURRENCE; } ldns_sha512_init(&zd->sha512_CTX); zd->simple_sha512 = 1; break; default: return LDNS_STATUS_ZONEMD_UNKNOWN_HASH; } break; default: return LDNS_STATUS_ZONEMD_UNKNOWN_SCHEME; } return LDNS_STATUS_OK; } static ldns_status zone_digester_update(zone_digester *zd, ldns_rr *rr) { uint8_t data[65536]; ldns_buffer buf; ldns_status st; buf._data = data; buf._position = 0; buf._limit = sizeof(data); buf._capacity = sizeof(data); buf._fixed = 1; buf._status = LDNS_STATUS_OK; if ((st = ldns_rr2buffer_wire_canonical(&buf, rr, LDNS_SECTION_ANSWER))) return st; if (zd->simple_sha384) ldns_sha384_update(&zd->sha384_CTX, data, buf._position); if (zd->simple_sha512) ldns_sha512_update(&zd->sha512_CTX, data, buf._position); return LDNS_STATUS_OK; } INLINE ldns_rr * new_zonemd(ldns_rr *soa, zonemd_hash hash) { ldns_rr *rr = NULL; uint8_t *data = NULL; ldns_rdf *rdf; size_t md_len = hash == ZONEMD_HASH_SHA384 ? LDNS_SHA384_DIGEST_LENGTH : LDNS_SHA512_DIGEST_LENGTH; if (!(rr = ldns_rr_new_frm_type(LDNS_RR_TYPE_ZONEMD))) return NULL; if (!(rdf = ldns_rdf_clone(ldns_rr_owner(soa)))) goto error; ldns_rr_set_owner(rr, rdf); ldns_rr_set_class(rr, ldns_rr_get_class(soa)); ldns_rr_set_ttl(rr, ldns_rr_ttl(soa)); if (!(rdf = ldns_rdf_clone(ldns_rr_rdf(soa, 2)))) goto error; ldns_rr_set_rdf(rr, rdf, 0); if (!(rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, 1))) goto error; ldns_rr_set_rdf(rr, rdf, 1); if (!(rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, hash))) goto error; ldns_rr_set_rdf(rr, rdf, 2); if (!(data = LDNS_XMALLOC(uint8_t, md_len))) goto error; if (!(rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, md_len, data))) goto error; ldns_rr_set_rdf(rr, rdf, 3); return rr; error: if (data) LDNS_FREE(data); ldns_rr_free(rr); return NULL; } static ldns_rr_list * zone_digester_export( zone_digester *zd, ldns_rr *soa, ldns_status *ret_st) { ldns_status st = LDNS_STATUS_OK; ldns_rr_list *rr_list = NULL; ldns_rr *sha384 = NULL; ldns_rr *sha512 = NULL; if (!zd || !soa) st = LDNS_STATUS_NULL; else if (ldns_rr_get_type(soa) != LDNS_RR_TYPE_SOA || ldns_rr_rd_count(soa) < 3) st = LDNS_STATUS_ZONEMD_INVALID_SOA; else if (!(rr_list = ldns_rr_list_new())) st = LDNS_STATUS_MEM_ERR; else if (zd->simple_sha384 && !(sha384 = new_zonemd(soa, ZONEMD_HASH_SHA384))) st = LDNS_STATUS_MEM_ERR; else if (zd->simple_sha512 && !(sha512 = new_zonemd(soa, ZONEMD_HASH_SHA512))) st = LDNS_STATUS_MEM_ERR; else if (zd->simple_sha384 && !ldns_rr_list_push_rr(rr_list, sha384)) st = LDNS_STATUS_MEM_ERR; else if (zd->simple_sha512 && !ldns_rr_list_push_rr(rr_list, sha512)) { if (zd->simple_sha384) sha384 = NULL; /* deleted by ldns_rr_list_deep_free */ st = LDNS_STATUS_MEM_ERR; } else { if (sha384) ldns_sha384_final( ldns_rdf_data(ldns_rr_rdf(sha384,3)) , &zd->sha384_CTX); if (sha512) ldns_sha512_final( ldns_rdf_data(ldns_rr_rdf(sha512,3)) , &zd->sha512_CTX); return rr_list; } if (ret_st) *ret_st = st; if (sha384) ldns_rr_free(sha384); if (sha512) ldns_rr_free(sha512); if (rr_list) ldns_rr_list_deep_free(rr_list); return NULL; } static ldns_status ldns_digest_zone(ldns_dnssec_zone *zone, zone_digester *zd) { ldns_status st = LDNS_STATUS_OK; dnssec_zone_rr_iter rr_iter; ldns_rr *rr; ldns_rdf *apex_name; /* name of zone apex */ if (!zone || !zd || !zone->soa || !zone->soa->name) return LDNS_STATUS_NULL; apex_name = zone->soa->name; for ( rr = dnssec_zone_rr_iter_first(&rr_iter, zone) ; rr && !st ; rr = dnssec_zone_rr_iter_next(&rr_iter)) { /* Skip apex ZONEMD RRs */ if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_ZONEMD && !ldns_dname_compare(ldns_rr_owner(rr), apex_name)) continue; /* Skip RRSIGs for apex ZONEMD RRs */ if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG && LDNS_RR_TYPE_ZONEMD == ldns_rdf2rr_type( ldns_rr_rrsig_typecovered(rr)) && !ldns_dname_compare(ldns_rr_owner(rr), apex_name)) continue; st = zone_digester_update(zd, rr); } return st; } ldns_status ldns_dnssec_zone_verify_zonemd(ldns_dnssec_zone *zone) { ldns_dnssec_rrsets *zonemd, *soa; zone_digester zd; ldns_dnssec_rrs *rrs; ldns_rr *soa_rr; ldns_status st; uint8_t simple_sha384[LDNS_SHA384_DIGEST_LENGTH]; uint8_t simple_sha512[LDNS_SHA512_DIGEST_LENGTH]; size_t valid_zonemds; if (!zone) return LDNS_STATUS_NULL; zonemd = ldns_dnssec_zone_find_rrset( zone, zone->soa->name, LDNS_RR_TYPE_ZONEMD); if (!zonemd) { ldns_rbnode_t *nsec3_node; /* we need proof of non-existence for ZONEMD at the apex */ if (zone->soa->nsec) { if (ldns_nsec_bitmap_covers_type(ldns_nsec_get_bitmap( zone->soa->nsec), LDNS_RR_TYPE_ZONEMD)) return LDNS_STATUS_NO_ZONEMD; } else if (!zone->soa->hashed_name || !zone->hashed_names) return LDNS_STATUS_NO_ZONEMD; else if (LDNS_RBTREE_NULL == (nsec3_node = ldns_rbtree_search( zone->hashed_names , zone->soa->hashed_name))) return LDNS_STATUS_NO_ZONEMD; else { ldns_dnssec_name *nsec3 = (ldns_dnssec_name *)nsec3_node->data; if (ldns_nsec_bitmap_covers_type(ldns_nsec_get_bitmap( nsec3->nsec), LDNS_RR_TYPE_ZONEMD)) return LDNS_STATUS_NO_ZONEMD; } /* ZONEMD at apex does really not exist */ return LDNS_STATUS_OK; } soa = ldns_dnssec_zone_find_rrset( zone, zone->soa->name, LDNS_RR_TYPE_SOA); if (!soa || !soa->rrs || !soa->rrs->rr) return LDNS_STATUS_ZONEMD_INVALID_SOA; soa_rr = soa->rrs->rr; if (ldns_rr_get_type(soa_rr) != LDNS_RR_TYPE_SOA || ldns_rr_rd_count(soa_rr) < 3) return LDNS_STATUS_ZONEMD_INVALID_SOA; zone_digester_init(&zd); for (rrs = zonemd->rrs; rrs; rrs = rrs->next) { if (!rrs->rr || ldns_rr_get_type(rrs->rr) != LDNS_RR_TYPE_ZONEMD || ldns_rr_rd_count(rrs->rr) < 4) continue; /* serial should match SOA's serial */ if (ldns_rdf2native_int32(ldns_rr_rdf(soa_rr, 2)) != ldns_rdf2native_int32(ldns_rr_rdf(rrs->rr, 0))) continue; /* Add (scheme, hash) to digester */ zone_digester_add(&zd, ldns_rdf2native_int8(ldns_rr_rdf(rrs->rr, 1)), ldns_rdf2native_int8(ldns_rr_rdf(rrs->rr, 2))); } if (!zone_digester_set(&zd)) return LDNS_STATUS_NO_VALID_ZONEMD; if ((st = ldns_digest_zone(zone, &zd))) return st; if (zd.simple_sha384) ldns_sha384_final(simple_sha384, &zd.sha384_CTX); if (zd.simple_sha512) ldns_sha512_final(simple_sha512, &zd.sha512_CTX); valid_zonemds = 0; for (rrs = zonemd->rrs; rrs; rrs = rrs->next) { if (!rrs->rr || ldns_rr_get_type(rrs->rr) != LDNS_RR_TYPE_ZONEMD || ldns_rr_rd_count(rrs->rr) < 4) continue; /* serial should match SOA's serial */ if (ldns_rdf2native_int32(ldns_rr_rdf(soa_rr, 2)) != ldns_rdf2native_int32(ldns_rr_rdf(rrs->rr, 0))) continue; if (ZONEMD_SCHEME_SIMPLE != ldns_rdf2native_int8(ldns_rr_rdf(rrs->rr, 1))) continue; if (ZONEMD_HASH_SHA384 == ldns_rdf2native_int8(ldns_rr_rdf(rrs->rr,2)) && LDNS_SHA384_DIGEST_LENGTH == ldns_rdf_size(ldns_rr_rdf(rrs->rr, 3)) && memcmp( simple_sha384 , ldns_rdf_data(ldns_rr_rdf(rrs->rr, 3)) , LDNS_SHA384_DIGEST_LENGTH) == 0) valid_zonemds += 1; if (ZONEMD_HASH_SHA512 == ldns_rdf2native_int8(ldns_rr_rdf(rrs->rr,2)) && LDNS_SHA512_DIGEST_LENGTH == ldns_rdf_size(ldns_rr_rdf(rrs->rr, 3)) && memcmp( simple_sha512 , ldns_rdf_data(ldns_rr_rdf(rrs->rr, 3)) , LDNS_SHA512_DIGEST_LENGTH) == 0) valid_zonemds += 1; } return valid_zonemds ? LDNS_STATUS_OK : LDNS_STATUS_NO_VALID_ZONEMD; } #ifdef HAVE_SSL static ldns_status rr_list2dnssec_rrs(ldns_rr_list *rr_list, ldns_dnssec_rrs **rrs, ldns_rr_list *new_rrs) { ldns_rr *rr = NULL; if (!rr_list || !rrs) return LDNS_STATUS_NULL; if (ldns_rr_list_rr_count(rr_list) == 0) return LDNS_STATUS_OK; if (!*rrs) { if (!(*rrs = ldns_dnssec_rrs_new())) return LDNS_STATUS_MEM_ERR; (*rrs)->rr = ldns_rr_list_pop_rr(rr_list); if (new_rrs) ldns_rr_list_push_rr(new_rrs, (*rrs)->rr); } while ((rr = ldns_rr_list_pop_rr(rr_list))) { ldns_status st; if ((st = ldns_dnssec_rrs_add_rr(*rrs, rr))) { ldns_rr_list_push_rr(rr_list, rr); return st; } else if (new_rrs) ldns_rr_list_push_rr(new_rrs, rr); } return LDNS_STATUS_OK; } ldns_status dnssec_zone_equip_zonemd(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int signflags); ldns_status dnssec_zone_equip_zonemd(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int signflags) { ldns_status st = LDNS_STATUS_OK; zone_digester zd; ldns_rr_list *zonemd_rr_list = NULL; ldns_rr_list *zonemd_rrsigs = NULL; ldns_dnssec_rrsets *soa_rrset; ldns_rr *soa_rr = NULL; ldns_dnssec_rrsets **rrset_ref; ldns_dnssec_rrsets *zonemd_rrset; zone_digester_init(&zd); if (signflags & LDNS_SIGN_WITH_ZONEMD_SIMPLE_SHA384) zone_digester_add(&zd, ZONEMD_SCHEME_SIMPLE , ZONEMD_HASH_SHA384); if (signflags & LDNS_SIGN_WITH_ZONEMD_SIMPLE_SHA512) zone_digester_add(&zd, ZONEMD_SCHEME_SIMPLE , ZONEMD_HASH_SHA512); if ((st = ldns_digest_zone(zone, &zd))) return st; soa_rrset = ldns_dnssec_zone_find_rrset( zone, zone->soa->name, LDNS_RR_TYPE_SOA); if (!soa_rrset || !soa_rrset->rrs || !soa_rrset->rrs->rr) return LDNS_STATUS_ZONEMD_INVALID_SOA; soa_rr = soa_rrset->rrs->rr; if (!(zonemd_rr_list = zone_digester_export(&zd, soa_rr, &st))) return st; /* - replace or add ZONEMD rrset */ rrset_ref = &zone->soa->rrsets; /* scan rrsets at apex */ while (*rrset_ref && (*rrset_ref)->type < LDNS_RR_TYPE_ZONEMD) rrset_ref = &(*rrset_ref)->next; if (*rrset_ref && (*rrset_ref)->type == LDNS_RR_TYPE_ZONEMD) { /* reuse zonemd rrset */ zonemd_rrset = *rrset_ref; ldns_dnssec_rrs_free(zonemd_rrset->rrs); zonemd_rrset->rrs = NULL; ldns_dnssec_rrs_free(zonemd_rrset->signatures); zonemd_rrset->signatures = NULL; } else { /* insert zonemd rrset */ zonemd_rrset = ldns_dnssec_rrsets_new(); if (!zonemd_rrset) { ldns_rr_list_deep_free(zonemd_rr_list); return LDNS_STATUS_MEM_ERR; } zonemd_rrset->type = LDNS_RR_TYPE_ZONEMD; zonemd_rrset->next = *rrset_ref; *rrset_ref = zonemd_rrset; } if ((zonemd_rrsigs = ldns_sign_public(zonemd_rr_list, key_list))) st = rr_list2dnssec_rrs( zonemd_rrsigs , &zonemd_rrset->signatures, new_rrs); if (!st) st = rr_list2dnssec_rrs( zonemd_rr_list , &zonemd_rrset->rrs, new_rrs); ldns_rr_list_deep_free(zonemd_rr_list); ldns_rr_list_deep_free(zonemd_rrsigs); return st; } #endif /* HAVE_SSL */ ldns-1.9.2/rbtree.c0000664000175000017500000004247415212267520013475 0ustar willemwillem/* * rbtree.c -- generic red black tree * * Taken from Unbound, modified for ldns * * Copyright (c) 2001-2008, NLnet Labs. All rights reserved. * * This software is open source. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * \file * Implementation of a redblack tree. */ #include #include #include #include /** Node colour black */ #define BLACK 0 /** Node colour red */ #define RED 1 /** the NULL node, global alloc */ ldns_rbnode_t ldns_rbtree_null_node = { LDNS_RBTREE_NULL, /* Parent. */ LDNS_RBTREE_NULL, /* Left. */ LDNS_RBTREE_NULL, /* Right. */ NULL, /* Key. */ NULL, /* Data. */ BLACK /* Color. */ }; /** rotate subtree left (to preserve redblack property) */ static void ldns_rbtree_rotate_left(ldns_rbtree_t *rbtree, ldns_rbnode_t *node); /** rotate subtree right (to preserve redblack property) */ static void ldns_rbtree_rotate_right(ldns_rbtree_t *rbtree, ldns_rbnode_t *node); /** Fixup node colours when insert happened */ static void ldns_rbtree_insert_fixup(ldns_rbtree_t *rbtree, ldns_rbnode_t *node); /** Fixup node colours when delete happened */ static void ldns_rbtree_delete_fixup(ldns_rbtree_t* rbtree, ldns_rbnode_t* child, ldns_rbnode_t* child_parent); /* * Creates a new red black tree, initializes and returns a pointer to it. * * Return NULL on failure. * */ ldns_rbtree_t * ldns_rbtree_create (int (*cmpf)(const void *, const void *)) { ldns_rbtree_t *rbtree; /* Allocate memory for it */ rbtree = (ldns_rbtree_t *) LDNS_MALLOC(ldns_rbtree_t); if (!rbtree) { return NULL; } /* Initialize it */ ldns_rbtree_init(rbtree, cmpf); return rbtree; } void ldns_rbtree_init(ldns_rbtree_t *rbtree, int (*cmpf)(const void *, const void *)) { /* Initialize it */ rbtree->root = LDNS_RBTREE_NULL; rbtree->count = 0; rbtree->cmp = cmpf; } void ldns_rbtree_free(ldns_rbtree_t *rbtree) { LDNS_FREE(rbtree); } /* * Rotates the node to the left. * */ static void ldns_rbtree_rotate_left(ldns_rbtree_t *rbtree, ldns_rbnode_t *node) { ldns_rbnode_t *right = node->right; node->right = right->left; if (right->left != LDNS_RBTREE_NULL) right->left->parent = node; right->parent = node->parent; if (node->parent != LDNS_RBTREE_NULL) { if (node == node->parent->left) { node->parent->left = right; } else { node->parent->right = right; } } else { rbtree->root = right; } right->left = node; node->parent = right; } /* * Rotates the node to the right. * */ static void ldns_rbtree_rotate_right(ldns_rbtree_t *rbtree, ldns_rbnode_t *node) { ldns_rbnode_t *left = node->left; node->left = left->right; if (left->right != LDNS_RBTREE_NULL) left->right->parent = node; left->parent = node->parent; if (node->parent != LDNS_RBTREE_NULL) { if (node == node->parent->right) { node->parent->right = left; } else { node->parent->left = left; } } else { rbtree->root = left; } left->right = node; node->parent = left; } static void ldns_rbtree_insert_fixup(ldns_rbtree_t *rbtree, ldns_rbnode_t *node) { ldns_rbnode_t *uncle; /* While not at the root and need fixing... */ while (node != rbtree->root && node->parent->color == RED) { /* If our parent is left child of our grandparent... */ if (node->parent == node->parent->parent->left) { uncle = node->parent->parent->right; /* If our uncle is red... */ if (uncle->color == RED) { /* Paint the parent and the uncle black... */ node->parent->color = BLACK; uncle->color = BLACK; /* And the grandparent red... */ node->parent->parent->color = RED; /* And continue fixing the grandparent */ node = node->parent->parent; } else { /* Our uncle is black... */ /* Are we the right child? */ if (node == node->parent->right) { node = node->parent; ldns_rbtree_rotate_left(rbtree, node); } /* Now we're the left child, repaint and rotate... */ node->parent->color = BLACK; node->parent->parent->color = RED; ldns_rbtree_rotate_right(rbtree, node->parent->parent); } } else { uncle = node->parent->parent->left; /* If our uncle is red... */ if (uncle->color == RED) { /* Paint the parent and the uncle black... */ node->parent->color = BLACK; uncle->color = BLACK; /* And the grandparent red... */ node->parent->parent->color = RED; /* And continue fixing the grandparent */ node = node->parent->parent; } else { /* Our uncle is black... */ /* Are we the right child? */ if (node == node->parent->left) { node = node->parent; ldns_rbtree_rotate_right(rbtree, node); } /* Now we're the right child, repaint and rotate... */ node->parent->color = BLACK; node->parent->parent->color = RED; ldns_rbtree_rotate_left(rbtree, node->parent->parent); } } } rbtree->root->color = BLACK; } void ldns_rbtree_insert_vref(ldns_rbnode_t *data, void *rbtree) { (void) ldns_rbtree_insert((ldns_rbtree_t *) rbtree, data); } /* * Inserts a node into a red black tree. * * Returns NULL on failure or the pointer to the newly added node * otherwise. */ ldns_rbnode_t * ldns_rbtree_insert (ldns_rbtree_t *rbtree, ldns_rbnode_t *data) { /* XXX Not necessary, but keeps compiler quiet... */ int r = 0; /* We start at the root of the tree */ ldns_rbnode_t *node = rbtree->root; ldns_rbnode_t *parent = LDNS_RBTREE_NULL; /* Lets find the new parent... */ while (node != LDNS_RBTREE_NULL) { /* Compare two keys, do we have a duplicate? */ if ((r = rbtree->cmp(data->key, node->key)) == 0) { return NULL; } parent = node; if (r < 0) { node = node->left; } else { node = node->right; } } /* Initialize the new node */ data->parent = parent; data->left = data->right = LDNS_RBTREE_NULL; data->color = RED; rbtree->count++; /* Insert it into the tree... */ if (parent != LDNS_RBTREE_NULL) { if (r < 0) { parent->left = data; } else { parent->right = data; } } else { rbtree->root = data; } /* Fix up the red-black properties... */ ldns_rbtree_insert_fixup(rbtree, data); return data; } /* * Searches the red black tree, returns the data if key is found or NULL otherwise. * */ ldns_rbnode_t * ldns_rbtree_search (ldns_rbtree_t *rbtree, const void *key) { ldns_rbnode_t *node; if (ldns_rbtree_find_less_equal(rbtree, key, &node)) { return node; } else { return NULL; } } /** helpers for delete: swap node colours */ static void swap_int8(uint8_t* x, uint8_t* y) { uint8_t t = *x; *x = *y; *y = t; } /** helpers for delete: swap node pointers */ static void swap_np(ldns_rbnode_t** x, ldns_rbnode_t** y) { ldns_rbnode_t* t = *x; *x = *y; *y = t; } /** Update parent pointers of child trees of 'parent' */ static void change_parent_ptr(ldns_rbtree_t* rbtree, ldns_rbnode_t* parent, ldns_rbnode_t* old, ldns_rbnode_t* new) { if(parent == LDNS_RBTREE_NULL) { if(rbtree->root == old) rbtree->root = new; return; } if(parent->left == old) parent->left = new; if(parent->right == old) parent->right = new; } /** Update parent pointer of a node 'child' */ static void change_child_ptr(ldns_rbnode_t* child, ldns_rbnode_t* old, ldns_rbnode_t* new) { if(child == LDNS_RBTREE_NULL) return; if(child->parent == old) child->parent = new; } ldns_rbnode_t* ldns_rbtree_delete(ldns_rbtree_t *rbtree, const void *key) { ldns_rbnode_t *to_delete; ldns_rbnode_t *child; if((to_delete = ldns_rbtree_search(rbtree, key)) == 0) return 0; rbtree->count--; /* make sure we have at most one non-leaf child */ if(to_delete->left != LDNS_RBTREE_NULL && to_delete->right != LDNS_RBTREE_NULL) { /* swap with smallest from right subtree (or largest from left) */ ldns_rbnode_t *smright = to_delete->right; while(smright->left != LDNS_RBTREE_NULL) smright = smright->left; /* swap the smright and to_delete elements in the tree, * but the ldns_rbnode_t is first part of user data struct * so cannot just swap the keys and data pointers. Instead * readjust the pointers left,right,parent */ /* swap colors - colors are tied to the position in the tree */ swap_int8(&to_delete->color, &smright->color); /* swap child pointers in parents of smright/to_delete */ change_parent_ptr(rbtree, to_delete->parent, to_delete, smright); if(to_delete->right != smright) change_parent_ptr(rbtree, smright->parent, smright, to_delete); /* swap parent pointers in children of smright/to_delete */ change_child_ptr(smright->left, smright, to_delete); change_child_ptr(smright->left, smright, to_delete); change_child_ptr(smright->right, smright, to_delete); change_child_ptr(smright->right, smright, to_delete); change_child_ptr(to_delete->left, to_delete, smright); if(to_delete->right != smright) change_child_ptr(to_delete->right, to_delete, smright); if(to_delete->right == smright) { /* set up so after swap they work */ to_delete->right = to_delete; smright->parent = smright; } /* swap pointers in to_delete/smright nodes */ swap_np(&to_delete->parent, &smright->parent); swap_np(&to_delete->left, &smright->left); swap_np(&to_delete->right, &smright->right); /* now delete to_delete (which is at the location where the smright previously was) */ } if(to_delete->left != LDNS_RBTREE_NULL) child = to_delete->left; else child = to_delete->right; /* unlink to_delete from the tree, replace to_delete with child */ change_parent_ptr(rbtree, to_delete->parent, to_delete, child); change_child_ptr(child, to_delete, to_delete->parent); if(to_delete->color == RED) { /* if node is red then the child (black) can be swapped in */ } else if(child->color == RED) { /* change child to BLACK, removing a RED node is no problem */ if(child!=LDNS_RBTREE_NULL) child->color = BLACK; } else ldns_rbtree_delete_fixup(rbtree, child, to_delete->parent); /* unlink completely */ to_delete->parent = LDNS_RBTREE_NULL; to_delete->left = LDNS_RBTREE_NULL; to_delete->right = LDNS_RBTREE_NULL; to_delete->color = BLACK; return to_delete; } static void ldns_rbtree_delete_fixup(ldns_rbtree_t* rbtree, ldns_rbnode_t* child, ldns_rbnode_t* child_parent) { ldns_rbnode_t* sibling; int go_up = 1; /* determine sibling to the node that is one-black short */ if(child_parent->right == child) sibling = child_parent->left; else sibling = child_parent->right; while(go_up) { if(child_parent == LDNS_RBTREE_NULL) { /* removed parent==black from root, every path, so ok */ return; } if(sibling->color == RED) { /* rotate to get a black sibling */ child_parent->color = RED; sibling->color = BLACK; if(child_parent->right == child) ldns_rbtree_rotate_right(rbtree, child_parent); else ldns_rbtree_rotate_left(rbtree, child_parent); /* new sibling after rotation */ if(child_parent->right == child) sibling = child_parent->left; else sibling = child_parent->right; } if(child_parent->color == BLACK && sibling->color == BLACK && sibling->left->color == BLACK && sibling->right->color == BLACK) { /* fixup local with recolor of sibling */ if(sibling != LDNS_RBTREE_NULL) sibling->color = RED; child = child_parent; child_parent = child_parent->parent; /* prepare to go up, new sibling */ if(child_parent->right == child) sibling = child_parent->left; else sibling = child_parent->right; } else go_up = 0; } if(child_parent->color == RED && sibling->color == BLACK && sibling->left->color == BLACK && sibling->right->color == BLACK) { /* move red to sibling to rebalance */ if(sibling != LDNS_RBTREE_NULL) sibling->color = RED; child_parent->color = BLACK; return; } /* get a new sibling, by rotating at sibling. See which child of sibling is red */ if(child_parent->right == child && sibling->color == BLACK && sibling->right->color == RED && sibling->left->color == BLACK) { sibling->color = RED; sibling->right->color = BLACK; ldns_rbtree_rotate_left(rbtree, sibling); /* new sibling after rotation */ if(child_parent->right == child) sibling = child_parent->left; else sibling = child_parent->right; } else if(child_parent->left == child && sibling->color == BLACK && sibling->left->color == RED && sibling->right->color == BLACK) { sibling->color = RED; sibling->left->color = BLACK; ldns_rbtree_rotate_right(rbtree, sibling); /* new sibling after rotation */ if(child_parent->right == child) sibling = child_parent->left; else sibling = child_parent->right; } /* now we have a black sibling with a red child. rotate and exchange colors. */ sibling->color = child_parent->color; child_parent->color = BLACK; if(child_parent->right == child) { sibling->left->color = BLACK; ldns_rbtree_rotate_right(rbtree, child_parent); } else { sibling->right->color = BLACK; ldns_rbtree_rotate_left(rbtree, child_parent); } } int ldns_rbtree_find_less_equal(ldns_rbtree_t *rbtree, const void *key, ldns_rbnode_t **result) { int r; ldns_rbnode_t *node; /* We start at root... */ node = rbtree->root; *result = NULL; /* While there are children... */ while (node != LDNS_RBTREE_NULL) { r = rbtree->cmp(key, node->key); if (r == 0) { /* Exact match */ *result = node; return 1; } if (r < 0) { node = node->left; } else { /* Temporary match */ *result = node; node = node->right; } } return 0; } /* * Finds the first element in the red black tree * */ ldns_rbnode_t * ldns_rbtree_first(const ldns_rbtree_t *rbtree) { ldns_rbnode_t *node = rbtree->root; if (rbtree->root != LDNS_RBTREE_NULL) { for (node = rbtree->root; node->left != LDNS_RBTREE_NULL; node = node->left); } return node; } ldns_rbnode_t * ldns_rbtree_last(const ldns_rbtree_t *rbtree) { ldns_rbnode_t *node = rbtree->root; if (rbtree->root != LDNS_RBTREE_NULL) { for (node = rbtree->root; node->right != LDNS_RBTREE_NULL; node = node->right); } return node; } /* * Returns the next node... * */ ldns_rbnode_t * ldns_rbtree_next(ldns_rbnode_t *node) { ldns_rbnode_t *parent; if (node->right != LDNS_RBTREE_NULL) { /* One right, then keep on going left... */ for (node = node->right; node->left != LDNS_RBTREE_NULL; node = node->left); } else { parent = node->parent; while (parent != LDNS_RBTREE_NULL && node == parent->right) { node = parent; parent = parent->parent; } node = parent; } return node; } ldns_rbnode_t * ldns_rbtree_previous(ldns_rbnode_t *node) { ldns_rbnode_t *parent; if (node->left != LDNS_RBTREE_NULL) { /* One left, then keep on going right... */ for (node = node->left; node->right != LDNS_RBTREE_NULL; node = node->right); } else { parent = node->parent; while (parent != LDNS_RBTREE_NULL && node == parent->left) { node = parent; parent = parent->parent; } node = parent; } return node; } /** * split off elements number of elements from the start * of the name tree and return a new tree */ ldns_rbtree_t * ldns_rbtree_split(ldns_rbtree_t *tree, size_t elements) { ldns_rbtree_t *new_tree; ldns_rbnode_t *cur_node; ldns_rbnode_t *move_node; size_t count = 0; new_tree = ldns_rbtree_create(tree->cmp); cur_node = ldns_rbtree_first(tree); while (count < elements && cur_node != LDNS_RBTREE_NULL) { move_node = ldns_rbtree_delete(tree, cur_node->key); (void)ldns_rbtree_insert(new_tree, move_node); cur_node = ldns_rbtree_first(tree); count++; } return new_tree; } /* * add all node from the second tree to the first (removing them from the * second), and fix up nsec(3)s if present */ void ldns_rbtree_join(ldns_rbtree_t *tree1, ldns_rbtree_t *tree2) { ldns_traverse_postorder(tree2, ldns_rbtree_insert_vref, tree1); } /** recursive descent traverse */ static void traverse_post(void (*func)(ldns_rbnode_t*, void*), void* arg, ldns_rbnode_t* node) { if(!node || node == LDNS_RBTREE_NULL) return; /* recurse */ traverse_post(func, arg, node->left); traverse_post(func, arg, node->right); /* call user func */ (*func)(node, arg); } void ldns_traverse_postorder(ldns_rbtree_t* tree, void (*func)(ldns_rbnode_t*, void*), void* arg) { traverse_post(func, arg, tree->root); } ldns-1.9.2/ax_python_devel.m40000664000175000017500000003361515212267520015475 0ustar willemwillem# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_python_devel.html # =========================================================================== # # SYNOPSIS # # AX_PYTHON_DEVEL([version]) # # DESCRIPTION # # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it # in your configure.ac. # # This macro checks for Python and tries to get the include path to # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output # variables. It also exports $(PYTHON_EXTRA_LIBS) and # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. # # You can search for some particular version of Python by passing a # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please # note that you *have* to pass also an operator along with the version to # match, and pay special attention to the single quotes surrounding the # version number. Don't use "PYTHON_VERSION" for this: that environment # variable is declared as precious and thus reserved for the end-user. # # This macro should work for all versions of Python >= 2.1.0. As an end # user, you can disable the check for the python version by setting the # PYTHON_NOVERSIONCHECK environment variable to something else than the # empty string. # # If you need to use this macro for an older Python version, please # contact the authors. We're always open for feedback. # # LICENSE # # Copyright (c) 2009 Sebastian Huber # Copyright (c) 2009 Alan W. Irwin # Copyright (c) 2009 Rafael Laboissiere # Copyright (c) 2009 Andrew Collier # Copyright (c) 2009 Matteo Settenvini # Copyright (c) 2009 Horst Knorr # Copyright (c) 2013 Daniel Mullner # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 32 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) AC_DEFUN([AX_PYTHON_DEVEL],[ # # Allow the use of a (user set) custom python version # AC_ARG_VAR([PYTHON_VERSION],[The installed Python version to use, for example '2.3'. This string will be appended to the Python interpreter canonical name.]) AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) if test -z "$PYTHON"; then AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) PYTHON_VERSION="" fi # # Check for a version of Python >= 2.1.0 # AC_MSG_CHECKING([for a version of Python >= '2.1.0']) ac_supports_python_ver=`$PYTHON -c "import sys; \ ver = sys.version.split ()[[0]]; \ print (ver >= '2.1.0')"` if test "$ac_supports_python_ver" != "True"; then if test -z "$PYTHON_NOVERSIONCHECK"; then AC_MSG_RESULT([no]) AC_MSG_FAILURE([ This version of the AC@&t@_PYTHON_DEVEL macro doesn't work properly with versions of Python before 2.1.0. You may need to re-run configure, setting the variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG, PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. Moreover, to disable this check, set PYTHON_NOVERSIONCHECK to something else than an empty string. ]) else AC_MSG_RESULT([skip at user request]) fi else AC_MSG_RESULT([yes]) fi # # If the macro parameter ``version'' is set, honour it. # A Python shim class, VPy, is used to implement correct version comparisons via # string expressions, since e.g. a naive textual ">= 2.7.3" won't work for # Python 2.7.10 (the ".1" being evaluated as less than ".3"). # if test -n "$1"; then AC_MSG_CHECKING([for a version of Python $1]) cat << EOF > ax_python_devel_vpy.py class VPy: def vtup(self, s): return tuple(map(int, s.strip().replace("rc", ".").split("."))) def __init__(self): import sys self.vpy = tuple(sys.version_info) def __eq__(self, s): return self.vpy == self.vtup(s) def __ne__(self, s): return self.vpy != self.vtup(s) def __lt__(self, s): return self.vpy < self.vtup(s) def __gt__(self, s): return self.vpy > self.vtup(s) def __le__(self, s): return self.vpy <= self.vtup(s) def __ge__(self, s): return self.vpy >= self.vtup(s) EOF ac_supports_python_ver=`$PYTHON -c "import ax_python_devel_vpy; \ ver = ax_python_devel_vpy.VPy(); \ print (ver $1)"` rm -rf ax_python_devel_vpy*.py* __pycache__/ax_python_devel_vpy*.py* if test "$ac_supports_python_ver" = "True"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) AC_MSG_ERROR([this package requires Python $1. If you have it installed, but it isn't the default Python interpreter in your system path, please pass the PYTHON_VERSION variable to configure. See ``configure --help'' for reference. ]) PYTHON_VERSION="" fi fi # # Check if you have distutils, else fail # AC_MSG_CHECKING([for the sysconfig Python package]) ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1` if test $? -eq 0; then AC_MSG_RESULT([yes]) IMPORT_SYSCONFIG="import sysconfig" else AC_MSG_RESULT([no]) AC_MSG_CHECKING([for the distutils Python package]) ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1` if test $? -eq 0; then AC_MSG_RESULT([yes]) IMPORT_SYSCONFIG="from distutils import sysconfig" else AC_MSG_ERROR([cannot import Python module "distutils". Please check your Python installation. The error was: $ac_sysconfig_result]) PYTHON_VERSION="" fi fi # # Check for Python include path # AC_MSG_CHECKING([for Python include path]) if test -z "$PYTHON_CPPFLAGS"; then if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then # sysconfig module has different functions python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_path ('include'));"` plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_path ('platinclude'));"` else # old distutils way python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_python_inc ());"` plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_python_inc (plat_specific=1));"` fi if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" else python_path="-I$python_path" fi fi PYTHON_CPPFLAGS=$python_path fi AC_MSG_RESULT([$PYTHON_CPPFLAGS]) AC_SUBST([PYTHON_CPPFLAGS]) # # Check for Python library path # AC_MSG_CHECKING([for Python library path]) if test -z "$PYTHON_LIBS"; then # (makes two attempts to ensure we've got a version number # from the interpreter) ac_python_version=`cat<]], [[Py_Initialize();]]) ],[pythonexists=yes],[pythonexists=no]) AC_LANG_POP([C]) # turn back to default flags CPPFLAGS="$ac_save_CPPFLAGS" LIBS="$ac_save_LIBS" LDFLAGS="$ac_save_LDFLAGS" AC_MSG_RESULT([$pythonexists]) if test ! "x$pythonexists" = "xyes"; then AC_MSG_FAILURE([ Could not link test program to Python. Maybe the main Python library has been installed in some non-standard library path. If so, pass it to configure, via the LIBS environment variable. Example: ./configure LIBS="-L/usr/non-standard-path/python/lib" ============================================================================ ERROR! You probably have to install the development version of the Python package for your distribution. The exact name of this package varies among them. ============================================================================ ]) PYTHON_VERSION="" fi # # all done! # ]) ldns-1.9.2/LICENSE0000664000175000017500000000274615212267520013051 0ustar willemwillemCopyright (c) 2005,2006, NLnetLabs All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of NLnetLabs nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ldns-1.9.2/acx_nlnetlabs.m40000664000175000017500000013216315212267520015120 0ustar willemwillem# acx_nlnetlabs.m4 - common macros for configure checks # Copyright 2009, Wouter Wijngaards, NLnet Labs. # BSD licensed. # # Version 48 # 2024-01-16 fix to add -l:libssp.a to -lcrypto link check. # and check for getaddrinfo with only header. # 2024-01-15 fix to add crypt32 to -lcrypto link check when checking for gdi32. # 2023-05-04 fix to remove unused whitespace. # 2023-01-26 fix -Wstrict-prototypes. # 2022-09-01 fix checking if nonblocking sockets work on OpenBSD. # 2021-08-17 fix sed script in ssldir split handling. # 2021-08-17 fix for openssl to detect split version, with ssldir_include # and ssldir_lib output directories. # 2021-07-30 fix for openssl use of lib64 directory. # 2021-06-14 fix nonblocking test to use host instead of target for mingw test. # 2021-05-17 fix nonblocking socket test from grep on mingw32 to mingw for # 64bit compatibility. # 2021-03-24 fix ACX_FUNC_DEPRECATED to use CPPFLAGS and CFLAGS. # 2021-01-05 fix defun for aclocal # 2021-01-05 autoconf 2.70 autoupdate and fixes, no AC_TRY_COMPILE # 2020-08-24 Use EVP_sha256 instead of HMAC_Update (for openssl-3.0.0). # 2016-03-21 Check -ldl -pthread for libcrypto for ldns and openssl 1.1.0. # 2016-03-21 Use HMAC_Update instead of HMAC_CTX_Init (for openssl-1.1.0). # 2016-01-04 -D_DEFAULT_SOURCE defined with -D_BSD_SOURCE for Linux glibc 2.20 # 2015-12-11 FLTO check for new OSX, clang. # 2015-11-18 spelling check fix. # 2015-11-05 ACX_SSL_CHECKS no longer adds -ldl needlessly. # 2015-08-28 ACX_CHECK_PIE and ACX_CHECK_RELRO_NOW added. # 2015-03-17 AHX_CONFIG_REALLOCARRAY added # 2013-09-19 FLTO help text improved. # 2013-07-18 Enable ACX_CHECK_COMPILER_FLAG to test for -Wstrict-prototypes # 2013-06-25 FLTO has --disable-flto option. # 2013-05-03 Update W32_SLEEP for newer mingw that links but not defines it. # 2013-03-22 Fix ACX_RSRC_VERSION for long version numbers. # 2012-02-09 Fix AHX_MEMCMP_BROKEN with undef in compat/memcmp.h. # 2012-01-20 Fix COMPILER_FLAGS_UNBOUND for gcc 4.6.2 assigned-not-used-warns. # 2011-12-05 Fix getaddrinfowithincludes on windows with fedora16 mingw32-gcc. # Fix ACX_MALLOC for redefined malloc error. # Fix GETADDRINFO_WITH_INCLUDES to add -lws2_32 # 2011-11-10 Fix FLTO test to not drop a.out in current directory. # 2011-11-01 Fix FLTO test for llvm on Lion. # 2011-08-01 Fix nonblock test (broken at v13). # 2011-08-01 Fix autoconf 2.68 warnings # 2011-06-23 Add ACX_CHECK_FLTO to check -flto. # 2010-08-16 Fix FLAG_OMITTED for AS_TR_CPP changes in autoconf-2.66. # 2010-07-02 Add check for ss_family (for minix). # 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS. # 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end. # 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS separate, -ldl # 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN # 2010-01-20 added AHX_COONFIG_STRLCAT # 2009-07-14 U_CHAR detection improved for windows crosscompile. # added ACX_FUNC_MALLOC # fixup some #if to #ifdef # NONBLOCKING test for mingw crosscompile. # 2009-07-13 added ACX_WITH_SSL_OPTIONAL # 2009-07-03 fixup LDFLAGS for empty ssl dir. # # Automates some of the checking constructs. Aims at portability for POSIX. # Documentation for functions is below. # # the following macro's are provided in this file: # (see below for details on each macro). # # ACX_ESCAPE_BACKSLASH - escape backslashes in var for C-preproc. # ACX_RSRC_VERSION - create windows resource version number. # ACX_CHECK_COMPILER_FLAG - see if cc supports a flag. # ACX_CHECK_ERROR_FLAGS - see which flag is -werror (used below). # ACX_CHECK_COMPILER_FLAG_NEEDED - see if flags make the code compile cleanly. # ACX_DEPFLAG - find cc dependency flags. # ACX_DETERMINE_EXT_FLAGS_UNBOUND - find out which flags enable BSD and POSIX. # ACX_CHECK_FORMAT_ATTRIBUTE - find cc printf format syntax. # ACX_CHECK_UNUSED_ATTRIBUTE - find cc variable unused syntax. # ACX_CHECK_FLTO - see if cc supports -flto and use it if so. # ACX_LIBTOOL_C_ONLY - create libtool for C only, improved. # ACX_TYPE_U_CHAR - u_char type. # ACX_TYPE_RLIM_T - rlim_t type. # ACX_TYPE_SOCKLEN_T - socklen_t type. # ACX_TYPE_IN_ADDR_T - in_addr_t type. # ACX_TYPE_IN_PORT_T - in_port_t type. # ACX_ARG_RPATH - add --disable-rpath option. # ACX_WITH_SSL - add --with-ssl option, link -lcrypto. # ACX_WITH_SSL_OPTIONAL - add --with-ssl option, link -lcrypto, # where --without-ssl is also accepted # ACX_LIB_SSL - setup to link -lssl. # ACX_SYS_LARGEFILE - improved sys_largefile, fseeko, >2G files. # ACX_CHECK_GETADDRINFO_WITH_INCLUDES - find getaddrinfo, portably. # ACX_FUNC_DEPRECATED - see if func is deprecated. # ACX_CHECK_NONBLOCKING_BROKEN - see if nonblocking sockets really work. # ACX_MKDIR_ONE_ARG - determine mkdir(2) number of arguments. # ACX_FUNC_IOCTLSOCKET - find ioctlsocket, portably. # ACX_FUNC_MALLOC - check malloc, define replacement . # AHX_CONFIG_FORMAT_ATTRIBUTE - config.h text for format. # AHX_CONFIG_UNUSED_ATTRIBUTE - config.h text for unused. # AHX_CONFIG_FSEEKO - define fseeko, ftello fallback. # AHX_CONFIG_RAND_MAX - define RAND_MAX if needed. # AHX_CONFIG_MAXHOSTNAMELEN - define MAXHOSTNAMELEN if needed. # AHX_CONFIG_IPV6_MIN_MTU - define IPV6_MIN_MTU if needed. # AHX_CONFIG_SNPRINTF - snprintf compat prototype # AHX_CONFIG_INET_PTON - inet_pton compat prototype # AHX_CONFIG_INET_NTOP - inet_ntop compat prototype # AHX_CONFIG_INET_ATON - inet_aton compat prototype # AHX_CONFIG_MEMMOVE - memmove compat prototype # AHX_CONFIG_STRLCAT - strlcat compat prototype # AHX_CONFIG_STRLCPY - strlcpy compat prototype # AHX_CONFIG_GMTIME_R - gmtime_r compat prototype # AHX_CONFIG_W32_SLEEP - w32 compat for sleep # AHX_CONFIG_W32_USLEEP - w32 compat for usleep # AHX_CONFIG_W32_RANDOM - w32 compat for random # AHX_CONFIG_W32_SRANDOM - w32 compat for srandom # AHX_CONFIG_W32_FD_SET_T - w32 detection of FD_SET_T. # ACX_CFLAGS_STRIP - strip one flag from CFLAGS # ACX_STRIP_EXT_FLAGS - strip extension flags from CFLAGS # AHX_CONFIG_FLAG_OMITTED - define omitted flag # AHX_CONFIG_FLAG_EXT - define omitted extension flag # AHX_CONFIG_EXT_FLAGS - define the stripped extension flags # ACX_CHECK_MEMCMP_SIGNED - check if memcmp uses signed characters. # AHX_MEMCMP_BROKEN - replace memcmp func for CHECK_MEMCMP_SIGNED. # ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family # ACX_CHECK_PIE - add --enable-pie option and check if works # ACX_CHECK_RELRO_NOW - add --enable-relro-now option and check it # dnl Escape backslashes as \\, for C:\ paths, for the C preprocessor defines. dnl for example, ACX_ESCAPE_BACKSLASH($from_var, to_var) dnl $1: the text to change. dnl $2: the result. AC_DEFUN([ACX_ESCAPE_BACKSLASH], [$2="`echo $1 | sed -e 's/\\\\/\\\\\\\\/g'`" ]) dnl Calculate comma separated windows-resource numbers from package version. dnl Picks the first three(,0) or four numbers out of the name. dnl $1: variable for the result AC_DEFUN([ACX_RSRC_VERSION], [$1=[`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9]*$/\1,\2,\3,0/' `] ]) dnl Routine to help check for compiler flags. dnl Checks if the compiler will accept the flag. dnl $1: the flag without a - in front, so g to check -g. dnl $2: executed if yes dnl $3: executed if no AC_DEFUN([ACX_CHECK_COMPILER_FLAG], [ AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING(whether $CC supports -$1) cache=`echo $1 | sed 'y%.=/+-%___p_%'` AC_CACHE_VAL(cv_prog_cc_flag_$cache, [ echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -$1 -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c ]) if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then AC_MSG_RESULT(yes) : $2 else AC_MSG_RESULT(no) : $3 fi ]) dnl setup flags for ACX_CHECK_COMPILER_FLAG_NEEDED dnl ERRFLAG: result, compiler flag to turn warnings into errors AC_DEFUN([ACX_CHECK_ERROR_FLAGS], [ ACX_CHECK_COMPILER_FLAG(Werror, [ERRFLAG="-Werror"], [ERRFLAG="-errwarn"]) ACX_CHECK_COMPILER_FLAG(Wall, [ERRFLAG="$ERRFLAG -Wall"], [ERRFLAG="$ERRFLAG -errfmt"]) ]) dnl Routine to help check for needed compiler flags. dnl $1: flags for CC dnl $2: the includes and code dnl $3: if the given code only compiles with the flag, execute argument 3 dnl $4: if the given code compiles without the flag, execute argument 4 dnl $5: with and without flag the compile fails, execute argument 5. AC_DEFUN([ACX_CHECK_COMPILER_FLAG_NEEDED], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([ACX_CHECK_ERROR_FLAGS]) AC_MSG_CHECKING(whether we need $1 as a flag for $CC) cache=AS_TR_SH($1) dnl cache=`echo $1 | sed 'y%.=/+- %___p__%'` AC_CACHE_VAL(cv_prog_cc_flag_needed_$cache, [ echo '$2' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else [ if test -z "`$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1` #exit 1 fi ] fi rm -f conftest conftest.c conftest.o ]) if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then AC_MSG_RESULT(yes) : $3 else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then AC_MSG_RESULT(no) #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $1 $ERRFLAG -c conftest.c 2>&1` #exit 1 : $4 else AC_MSG_RESULT(failed) : $5 fi fi ]) dnl Check for CC dependency flag dnl DEPFLAG: set to flag that generates dependencies. AC_DEFUN([ACX_DEPFLAG], [ AC_MSG_CHECKING([$CC dependency flag]) echo 'void f(void){}' >conftest.c if test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then DEPFLAG="-MM" else if test "`$CC -xM1 conftest.c 2>&1`" = "conftest.o: conftest.c"; then DEPFLAG="-xM1" else DEPFLAG="-MM" # dunno do something fi fi AC_MSG_RESULT($DEPFLAG) rm -f conftest.c AC_SUBST(DEPFLAG) ]) dnl Determine flags that gives POSIX and BSD functionality. dnl CFLAGS is modified for the result. AC_DEFUN([ACX_DETERMINE_EXT_FLAGS_UNBOUND], [ ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"]) ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"]) AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT]) ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE, [ #include "confdefs.h" #include #include #include #ifdef HAVE_TIME_H #include #endif #include #include #ifdef HAVE_GETOPT_H #include #endif int test(void) { int a; char **opts = NULL; struct timeval tv; char *t; time_t time = 0; char *buf = NULL; const char* str = NULL; struct msghdr msg; msg.msg_control = 0; t = ctime_r(&time, buf); tv.tv_usec = 10; srandom(32); a = getopt(2, opts, "a"); a = isascii(32); str = gai_strerror(0); if(str && t && tv.tv_usec && msg.msg_control) a = 0; return a; } ], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE"]) ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE, [ #include "confdefs.h" #include #include #include #ifdef HAVE_TIME_H #include #endif #include #include #ifdef HAVE_GETOPT_H #include #endif int test(void) { int a; char **opts = NULL; struct timeval tv; char *t; time_t time = 0; char *buf = NULL; const char* str = NULL; struct msghdr msg; msg.msg_control = 0; t = ctime_r(&time, buf); tv.tv_usec = 10; srandom(32); a = getopt(2, opts, "a"); a = isascii(32); str = gai_strerror(0); if(str && t && tv.tv_usec && msg.msg_control) a = 0; return a; } ], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE"]) ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG, [ #include #include int test(void) { int a = 0; return a; } ], [CFLAGS="$CFLAGS $C99FLAG"]) ACX_CHECK_COMPILER_FLAG_NEEDED(-D_BSD_SOURCE -D_DEFAULT_SOURCE, [ #include int test(void) { int a; a = isascii(32); return a; } ], [CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE"]) ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE, [ #include int test(void) { struct in6_pktinfo inf; int a = (int)sizeof(inf); return a; } ], [CFLAGS="$CFLAGS -D_GNU_SOURCE"]) # check again for GNU_SOURCE for setresgid. May fail if setresgid # is not available at all. -D_FRSRESGID is to make this check unique. # otherwise we would get the previous cached result. ACX_CHECK_COMPILER_FLAG_NEEDED(-D_GNU_SOURCE -D_FRSRESGID, [ #include int test(void) { int a = setresgid(0,0,0); a = setresuid(0,0,0); return a; } ], [CFLAGS="$CFLAGS -D_GNU_SOURCE"]) ACX_CHECK_COMPILER_FLAG_NEEDED(-D_POSIX_C_SOURCE=200112, [ #include "confdefs.h" #ifdef HAVE_TIME_H #include #endif #include int test(void) { int a = 0; char *t; time_t time = 0; char *buf = NULL; const char* str = NULL; t = ctime_r(&time, buf); str = gai_strerror(0); if(t && str) a = 0; return a; } ], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"]) ACX_CHECK_COMPILER_FLAG_NEEDED(-D__EXTENSIONS__, [ #include "confdefs.h" #include #include #include #ifdef HAVE_TIME_H #include #endif #include #ifdef HAVE_GETOPT_H #include #endif int test(void) { int a; char **opts = NULL; struct timeval tv; tv.tv_usec = 10; srandom(32); a = getopt(2, opts, "a"); a = isascii(32); if(tv.tv_usec) a = 0; return a; } ], [CFLAGS="$CFLAGS -D__EXTENSIONS__"]) ])dnl End of ACX_DETERMINE_EXT_FLAGS_UNBOUND dnl Check if CC supports -flto. dnl in a way that supports clang and suncc (that flag does something else, dnl but fails to link). It sets it in CFLAGS if it works. AC_DEFUN([ACX_CHECK_FLTO], [ AC_ARG_ENABLE([flto], AS_HELP_STRING([--disable-flto], [Disable link-time optimization (gcc specific option)])) AS_IF([test "x$enable_flto" != "xno"], [ AC_MSG_CHECKING([if $CC supports -flto]) BAKCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -flto" AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ if $CC $CFLAGS -o conftest conftest.c 2>&1 | $GREP -e "warning: no debug symbols in executable" -e "warning: object" >/dev/null; then CFLAGS="$BAKCFLAGS" AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi rm -f conftest conftest.c conftest.o ], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)]) ]) ]) dnl Check the printf-format attribute (if any) dnl result in HAVE_ATTR_FORMAT. dnl Make sure you also include the AHX_CONFIG_FORMAT_ATTRIBUTE. AC_DEFUN([ACX_CHECK_FORMAT_ATTRIBUTE], [AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute) AC_CACHE_VAL(ac_cv_c_format_attribute, [ac_cv_c_format_attribute=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include void f (char *format, ...) __attribute__ ((format (printf, 1, 2))); void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); ]], [[ f ("%s", "str"); ]])],[ac_cv_c_format_attribute="yes"],[ac_cv_c_format_attribute="no"]) ]) AC_MSG_RESULT($ac_cv_c_format_attribute) if test $ac_cv_c_format_attribute = yes; then AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute]) fi ])dnl End of ACX_CHECK_FORMAT_ATTRIBUTE dnl Setup ATTR_FORMAT config.h parts. dnl make sure you call ACX_CHECK_FORMAT_ATTRIBUTE also. AC_DEFUN([AHX_CONFIG_FORMAT_ATTRIBUTE], [ #ifdef HAVE_ATTR_FORMAT # define ATTR_FORMAT(archetype, string_index, first_to_check) \ __attribute__ ((format (archetype, string_index, first_to_check))) #else /* !HAVE_ATTR_FORMAT */ # define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ #endif /* !HAVE_ATTR_FORMAT */ ]) dnl Check how to mark function arguments as unused. dnl result in HAVE_ATTR_UNUSED. dnl Make sure you include AHX_CONFIG_UNUSED_ATTRIBUTE also. AC_DEFUN([ACX_CHECK_UNUSED_ATTRIBUTE], [AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute) AC_CACHE_VAL(ac_cv_c_unused_attribute, [ac_cv_c_unused_attribute=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include void f (char *u __attribute__((unused))); ]], [[ f ("x"); ]])],[ac_cv_c_unused_attribute="yes"],[ac_cv_c_unused_attribute="no"]) ]) dnl Setup ATTR_UNUSED config.h parts. dnl make sure you call ACX_CHECK_UNUSED_ATTRIBUTE also. AC_DEFUN([AHX_CONFIG_UNUSED_ATTRIBUTE], [ #if defined(DOXYGEN) # define ATTR_UNUSED(x) x #elif defined(__cplusplus) # define ATTR_UNUSED(x) #elif defined(HAVE_ATTR_UNUSED) # define ATTR_UNUSED(x) x __attribute__((unused)) #else /* !HAVE_ATTR_UNUSED */ # define ATTR_UNUSED(x) x #endif /* !HAVE_ATTR_UNUSED */ ]) AC_MSG_RESULT($ac_cv_c_unused_attribute) if test $ac_cv_c_unused_attribute = yes; then AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) fi ])dnl dnl Pre-fun for ACX_LIBTOOL_C_ONLY AC_DEFUN([ACX_LIBTOOL_C_PRE], [ # skip these tests, we do not need them. AC_DEFUN([AC_PROG_F77], [:]) AC_DEFUN([AC_PROG_FC], [:]) AC_DEFUN([AC_PROG_CXX], [:]) AC_DEFUN([AC_PROG_CXXCPP], [:]) AC_DEFUN([AC_PROG_OBJC], [:]) AC_DEFUN([AC_PROG_OBJCCPP], [:]) AC_DEFUN([AC_LIBTOOL_CXX], [:]) AC_DEFUN([AC_LIBTOOL_F77], [:]) # always use ./libtool unless override from commandline (libtool=mylibtool) if test -z "$libtool"; then libtool="./libtool" fi AC_SUBST(libtool) # avoid libtool max commandline length test on systems that fork slowly. AC_CANONICAL_HOST if echo "$host_os" | grep "sunos4" >/dev/null; then lt_cv_sys_max_cmd_len=32750; fi AC_PATH_TOOL(AR, ar, [false]) if test $AR = false; then AC_MSG_ERROR([Cannot find 'ar', please extend PATH to include it]) fi ]) dnl Perform libtool check, portably, only for C AC_DEFUN([ACX_LIBTOOL_C_ONLY], [ dnl as a requirement so that is gets called before LIBTOOL dnl because libtools 'AC_REQUIRE' names are right after this one, before dnl this function contents. AC_REQUIRE([ACX_LIBTOOL_C_PRE]) LT_INIT ]) dnl Detect if u_char type is defined, otherwise define it. AC_DEFUN([ACX_TYPE_U_CHAR], [AC_CHECK_TYPE([u_char], , [AC_DEFINE([u_char], [unsigned char], [Define to 'unsigned char if not defined])], [ AC_INCLUDES_DEFAULT #ifdef HAVE_WINSOCK2_H # include #endif ]) ]) dnl Detect if rlim_t type is defined, otherwise define it. AC_DEFUN([ACX_TYPE_RLIM_T], [AC_CHECK_TYPE(rlim_t, , [AC_DEFINE([rlim_t], [unsigned long], [Define to 'int' if not defined])], [ AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_RESOURCE_H # include #endif ]) ]) dnl Detect if socklen_t type is defined, otherwise define it. AC_DEFUN([ACX_TYPE_SOCKLEN_T], [ AC_CHECK_TYPE(socklen_t, , [AC_DEFINE([socklen_t], [int], [Define to 'int' if not defined])], [ AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_SOCKET_H # include #endif #ifdef HAVE_WS2TCPIP_H # include #endif ]) ]) dnl Detect if in_addr_t type is defined, otherwise define it. AC_DEFUN([ACX_TYPE_IN_ADDR_T], [ AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [ AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_NETINET_IN_H # include #endif ]) ]) dnl Detect if in_port_t type is defined, otherwise define it. AC_DEFUN([ACX_TYPE_IN_PORT_T], [ AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [ AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_NETINET_IN_H # include #endif ]) ]) dnl Add option to disable the evil rpath. Check whether to use rpath or not. dnl Adds the --disable-rpath option. Uses trick to edit the ./libtool. AC_DEFUN([ACX_ARG_RPATH], [ AC_ARG_ENABLE(rpath, [ --disable-rpath disable hardcoded rpath (default=enabled)], enable_rpath=$enableval, enable_rpath=yes) if test "x$enable_rpath" = xno; then dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.]) AC_CONFIG_COMMANDS([disable-rpath], [ sed < libtool > libtool-2 \ 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/' mv libtool-2 libtool chmod 755 libtool libtool="./libtool" ]) fi ]) dnl Add a -R to the RUNTIME_PATH. Only if rpath is enabled and it is dnl an absolute path. dnl $1: the pathname to add. AC_DEFUN([ACX_RUNTIME_PATH_ADD], [ if test "x$enable_rpath" = xyes; then if echo "$1" | grep "^/" >/dev/null; then RUNTIME_PATH="$RUNTIME_PATH -R$1" fi fi ]) dnl Common code for both ACX_WITH_SSL and ACX_WITH_SSL_OPTIONAL dnl Takes one argument; the withval checked in those 2 functions dnl sets up the environment for the given openssl path AC_DEFUN([ACX_SSL_CHECKS], [ withval=$1 if test x_$withval != x_no; then AC_MSG_CHECKING(for SSL) if test -n "$withval"; then dnl look for openssl install with different version, eg. dnl in /usr/include/openssl11/openssl/ssl.h dnl and /usr/lib64/openssl11/libssl.so dnl with the --with-ssl=/usr/include/openssl11 if test ! -f "$withval/include/openssl/ssl.h" -a -f "$withval/openssl/ssl.h"; then ssldir="$withval" found_ssl="yes" withval="" ssldir_include="$ssldir" dnl find the libdir ssldir_lib=`echo $ssldir | sed -e 's/include/lib/'` if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then : # found here else ssldir_lib=`echo $ssldir | sed -e 's/include/lib64/'` if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then : # found here else AC_MSG_ERROR([Could not find openssl lib file, $ssldir_lib/libssl.[so,a], pass like "/usr/local" or "/usr/include/openssl11"]) fi fi fi fi if test x_$withval = x_ -o x_$withval = x_yes; then withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr" fi for dir in $withval; do ssldir="$dir" if test -f "$dir/include/openssl/ssl.h"; then found_ssl="yes" ssldir_include="$ssldir/include" if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then ssldir_lib="$ssldir/lib64" else ssldir_lib="$ssldir/lib" fi break; fi done if test x_$found_ssl != x_yes; then AC_MSG_ERROR(Cannot find the SSL libraries in $withval) else AC_MSG_RESULT(found in $ssldir) AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.]) HAVE_SSL=yes dnl assume /usr is already in the include, lib and dynlib paths. if test "$ssldir" != "/usr"; then CPPFLAGS="$CPPFLAGS -I$ssldir_include" LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir_include" LDFLAGS="$LDFLAGS -L$ssldir_lib" LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir_lib" ACX_RUNTIME_PATH_ADD([$ssldir_lib]) fi AC_MSG_CHECKING([for EVP_sha256 in -lcrypto]) LIBS="$LIBS -lcrypto" LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto" AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int EVP_sha256(void); (void)EVP_sha256(); ]])],[ AC_MSG_RESULT(yes) AC_DEFINE([HAVE_EVP_SHA256], 1, [If you have EVP_sha256]) ],[ AC_MSG_RESULT(no) # check if -lwsock32 or -lgdi32 are needed. BAKLIBS="$LIBS" BAKSSLLIBS="$LIBSSL_LIBS" LIBS="$LIBS -lgdi32 -lws2_32" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32" AC_MSG_CHECKING([if -lcrypto needs -lgdi32]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int EVP_sha256(void); (void)EVP_sha256(); ]])],[ AC_DEFINE([HAVE_EVP_SHA256], 1, [If you have EVP_sha256]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32" AC_MSG_CHECKING([if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int EVP_sha256(void); (void)EVP_sha256(); ]])],[ AC_DEFINE([HAVE_EVP_SHA256], 1, [If you have EVP_sha256]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a" AC_MSG_CHECKING([if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int EVP_sha256(void); (void)EVP_sha256(); ]])],[ AC_DEFINE([HAVE_EVP_SHA256], 1, [If you have EVP_sha256]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -ldl" LIBSSL_LIBS="$LIBSSL_LIBS -ldl" AC_MSG_CHECKING([if -lcrypto needs -ldl]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int EVP_sha256(void); (void)EVP_sha256(); ]])],[ AC_DEFINE([HAVE_EVP_SHA256], 1, [If you have EVP_sha256]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -ldl -pthread" LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread" AC_MSG_CHECKING([if -lcrypto needs -ldl -pthread]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int EVP_sha256(void); (void)EVP_sha256(); ]])],[ AC_DEFINE([HAVE_EVP_SHA256], 1, [If you have EVP_sha256]) AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no) AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) ]) ]) ]) ]) ]) ]) fi AC_SUBST(HAVE_SSL) AC_SUBST(RUNTIME_PATH) fi AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT]) AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT]) AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT]) ])dnl End of ACX_SSL_CHECKS dnl Check for SSL, where SSL is mandatory dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS. dnl Checks main header files of SSL. dnl AC_DEFUN([ACX_WITH_SSL], [ AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl=pathname],[enable SSL (will check /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr or specify like /usr/include/openssl11)]),[ ],[ withval="yes" ]) if test x_$withval = x_no; then AC_MSG_ERROR([Need SSL library to do digital signature cryptography]) fi ACX_SSL_CHECKS($withval) ])dnl End of ACX_WITH_SSL dnl Check for SSL, where ssl is optional (--without-ssl is allowed) dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS. dnl Checks main header files of SSL. dnl AC_DEFUN([ACX_WITH_SSL_OPTIONAL], [ AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl=pathname],[enable SSL (will check /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr or specify like /usr/include/openssl11)]),[ ],[ withval="yes" ]) ACX_SSL_CHECKS($withval) ])dnl End of ACX_WITH_SSL_OPTIONAL dnl Setup to use -lssl dnl To use -lcrypto, use the ACX_WITH_SSL setup (before this one). AC_DEFUN([ACX_LIB_SSL], [ # check if libssl needs libdl BAKLIBS="$LIBS" LIBS="-lssl $LIBS" AC_MSG_CHECKING([if libssl needs libdl]) AC_TRY_LINK_FUNC([SSL_CTX_new], [ AC_MSG_RESULT([no]) LIBS="$BAKLIBS" ] , [ AC_MSG_RESULT([yes]) LIBS="$BAKLIBS" AC_SEARCH_LIBS([dlopen], [dl]) ]) ])dnl End of ACX_LIB_SSL dnl Setup to use very large files (>2Gb). dnl setups fseeko and its own AC_DEFUN([ACX_SYS_LARGEFILE], [ AC_SYS_LARGEFILE dnl try to see if an additional _LARGEFILE_SOURCE 1 is needed to get fseeko ACX_CHECK_COMPILER_FLAG_NEEDED(-D_LARGEFILE_SOURCE=1, [ #include int test(void) { int a = fseeko(stdin, 0, 0); return a; } ], [CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE=1"]) ]) dnl Check getaddrinfo. dnl Works on linux, solaris, bsd and windows(links winsock). dnl defines HAVE_GETADDRINFO, USE_WINSOCK. AC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES], [AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING(for getaddrinfo) ac_cv_func_getaddrinfo=no AC_LINK_IFELSE( [AC_LANG_SOURCE([[ #ifdef __cplusplus extern "C" { #endif char* getaddrinfo(); char* (*f) () = getaddrinfo; #ifdef __cplusplus } #endif int main(void) { ; return 0; } ]])], dnl this case on linux, solaris, bsd [ac_cv_func_getaddrinfo="yes" dnl see if on windows if test "$ac_cv_header_windows_h" = "yes"; then AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used]) USE_WINSOCK="1" if echo "$LIBS" | grep 'lws2_32' >/dev/null; then : else LIBS="$LIBS -lws2_32" fi fi ], dnl no quick getaddrinfo, try mingw32 and winsock2 library. dnl perhaps getaddrinfo needs only the include AC_LINK_IFELSE( [AC_LANG_PROGRAM( [ #ifdef HAVE_WS2TCPIP_H #include #endif ], [ (void)getaddrinfo(NULL, NULL, NULL, NULL); ] )], [ ac_cv_func_getaddrinfo="yes" AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used]) USE_WINSOCK="1" ], ORIGLIBS="$LIBS" LIBS="$LIBS -lws2_32" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [ #ifdef HAVE_WS2TCPIP_H #include #endif ], [ (void)getaddrinfo(NULL, NULL, NULL, NULL); ] )], [ ac_cv_func_getaddrinfo="yes" dnl already: LIBS="$LIBS -lws2_32" AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used]) USE_WINSOCK="1" ], [ ac_cv_func_getaddrinfo="no" LIBS="$ORIGLIBS" ]) ) ) AC_MSG_RESULT($ac_cv_func_getaddrinfo) if test $ac_cv_func_getaddrinfo = yes; then AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available]) fi ])dnl Endof AC_CHECK_GETADDRINFO_WITH_INCLUDES dnl check if a function is deprecated. defines DEPRECATED_func in config.h. dnl $1: function name dnl $2: C-statement that calls the function. dnl $3: includes for the program. dnl $4: executes if yes dnl $5: executes if no AC_DEFUN([ACX_FUNC_DEPRECATED], [ AC_REQUIRE([AC_PROG_CC]) AC_MSG_CHECKING(if $1 is deprecated) cache=`echo $1 | sed 'y%.=/+-%___p_%'` AC_CACHE_VAL(cv_cc_deprecated_$cache, [ echo '$3' >conftest.c echo 'void f(void){ $2 }' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -c conftest.c 2>&1 | grep -e deprecated -e unavailable`"; then eval "cv_cc_deprecated_$cache=no" else eval "cv_cc_deprecated_$cache=yes" fi rm -f conftest conftest.o conftest.c ]) if eval "test \"`echo '$cv_cc_deprecated_'$cache`\" = yes"; then AC_MSG_RESULT(yes) AC_DEFINE_UNQUOTED(AS_TR_CPP([DEPRECATED_$1]), 1, [Whether $1 is deprecated]) : $4 else AC_MSG_RESULT(no) : $5 fi ])dnl end of ACX_FUNC_DEPRECATED dnl check if select and nonblocking sockets actually work. dnl Needs fork(2) and select(2). dnl defines NONBLOCKING_IS_BROKEN, and if that is true multiple reads from dnl a nonblocking socket do not work, a new call to select is necessary. AC_DEFUN([ACX_CHECK_NONBLOCKING_BROKEN], [ AC_MSG_CHECKING([if nonblocking sockets work]) if echo $host | grep mingw >/dev/null; then AC_MSG_RESULT([no (windows)]) AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).]) else AC_RUN_IFELSE([ AC_LANG_SOURCE([[ #include #include #include #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_TIME_H #include #endif int main(void) { int port; int sfd, cfd; int num = 10; int i, p; struct sockaddr_in a; /* test if select and nonblocking reads work well together */ /* open port. fork child to send 10 messages. select to read. then try to nonblocking read the 10 messages then, nonblocking read must give EAGAIN */ port = 12345 + (time(0)%32); sfd = socket(PF_INET, SOCK_DGRAM, 0); if(sfd == -1) { perror("socket"); return 1; } memset(&a, 0, sizeof(a)); a.sin_family = AF_INET; a.sin_port = htons(port); a.sin_addr.s_addr = inet_addr("127.0.0.1"); if(bind(sfd, (struct sockaddr*)&a, sizeof(a)) < 0) { perror("bind"); return 1; } if(fcntl(sfd, F_SETFL, O_NONBLOCK) == -1) { perror("fcntl"); return 1; } cfd = socket(PF_INET, SOCK_DGRAM, 0); if(cfd == -1) { perror("client socket"); return 1; } a.sin_port = 0; if(bind(cfd, (struct sockaddr*)&a, sizeof(a)) < 0) { perror("client bind"); return 1; } a.sin_port = htons(port); /* no handler, causes exit in 10 seconds */ alarm(10); /* send and receive on the socket */ if((p=fork()) == 0) { for(i=0; i #include #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif ]], [[ (void)mkdir("directory"); ]])],[AC_MSG_RESULT(yes) AC_DEFINE(MKDIR_HAS_ONE_ARG, 1, [Define if mkdir has one argument.]) ],[AC_MSG_RESULT(no) ]) ])dnl end of ACX_MKDIR_ONE_ARG dnl Check for ioctlsocket function. works on mingw32 too. AC_DEFUN([ACX_FUNC_IOCTLSOCKET], [ # check ioctlsocket AC_MSG_CHECKING(for ioctlsocket) AC_LINK_IFELSE([AC_LANG_PROGRAM([ #ifdef HAVE_WINSOCK2_H #include #endif ], [ (void)ioctlsocket(0, 0, NULL); ])], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available]) ],[AC_MSG_RESULT(no)]) ])dnl end of ACX_FUNC_IOCTLSOCKET dnl detect malloc and provide malloc compat prototype. dnl $1: unique name for compat code AC_DEFUN([ACX_FUNC_MALLOC], [ AC_MSG_CHECKING([for GNU libc compatible malloc]) AC_RUN_IFELSE([AC_LANG_PROGRAM( [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H #include #else char *malloc (); #endif ]], [ if(malloc(0) != 0) return 1;]) ], [AC_MSG_RESULT([no]) AC_LIBOBJ(malloc) AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] , [AC_MSG_RESULT([yes]) AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])], [AC_MSG_RESULT([no (crosscompile)]) AC_LIBOBJ(malloc) AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] ) ]) dnl Define fallback for fseeko and ftello if needed. AC_DEFUN([AHX_CONFIG_FSEEKO], [ #ifndef HAVE_FSEEKO #define fseeko fseek #define ftello ftell #endif /* HAVE_FSEEKO */ ]) dnl Define RAND_MAX if not defined AC_DEFUN([AHX_CONFIG_RAND_MAX], [ #ifndef RAND_MAX #define RAND_MAX 2147483647 #endif ]) dnl Define MAXHOSTNAMELEN if not defined AC_DEFUN([AHX_CONFIG_MAXHOSTNAMELEN], [ #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 #endif ]) dnl Define IPV6_MIN_MTU if not defined AC_DEFUN([AHX_CONFIG_IPV6_MIN_MTU], [ #ifndef IPV6_MIN_MTU #define IPV6_MIN_MTU 1280 #endif /* IPV6_MIN_MTU */ ]) dnl provide snprintf, vsnprintf compat prototype dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_SNPRINTF], [ #ifndef HAVE_SNPRINTF #define snprintf snprintf_$1 #define vsnprintf vsnprintf_$1 #include int snprintf (char *str, size_t count, const char *fmt, ...); int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); #endif /* HAVE_SNPRINTF */ ]) dnl provide inet_pton compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_INET_PTON], [ #ifndef HAVE_INET_PTON #define inet_pton inet_pton_$1 int inet_pton(int af, const char* src, void* dst); #endif /* HAVE_INET_PTON */ ]) dnl provide inet_ntop compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_INET_NTOP], [ #ifndef HAVE_INET_NTOP #define inet_ntop inet_ntop_$1 const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif ]) dnl provide inet_aton compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_INET_ATON], [ #ifndef HAVE_INET_ATON #define inet_aton inet_aton_$1 int inet_aton(const char *cp, struct in_addr *addr); #endif ]) dnl provide memmove compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_MEMMOVE], [ #ifndef HAVE_MEMMOVE #define memmove memmove_$1 void *memmove(void *dest, const void *src, size_t n); #endif ]) dnl provide strlcat compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_STRLCAT], [ #ifndef HAVE_STRLCAT #define strlcat strlcat_$1 size_t strlcat(char *dst, const char *src, size_t siz); #endif ]) dnl provide strlcpy compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_STRLCPY], [ #ifndef HAVE_STRLCPY #define strlcpy strlcpy_$1 size_t strlcpy(char *dst, const char *src, size_t siz); #endif ]) dnl provide gmtime_r compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_GMTIME_R], [ #ifndef HAVE_GMTIME_R #define gmtime_r gmtime_r_$1 struct tm *gmtime_r(const time_t *timep, struct tm *result); #endif ]) dnl provide reallocarray compat prototype. dnl $1: unique name for compat code AC_DEFUN([AHX_CONFIG_REALLOCARRAY], [ #ifndef HAVE_REALLOCARRAY #define reallocarray reallocarray$1 void* reallocarray(void *ptr, size_t nmemb, size_t size); #endif ]) dnl provide w32 compat definition for sleep AC_DEFUN([AHX_CONFIG_W32_SLEEP], [ #if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H) #define sleep(x) Sleep((x)*1000) /* on win32 */ #endif /* HAVE_SLEEP */ ]) dnl provide w32 compat definition for usleep AC_DEFUN([AHX_CONFIG_W32_USLEEP], [ #ifndef HAVE_USLEEP #define usleep(x) Sleep((x)/1000 + 1) /* on win32 */ #endif /* HAVE_USLEEP */ ]) dnl provide w32 compat definition for random AC_DEFUN([AHX_CONFIG_W32_RANDOM], [ #ifndef HAVE_RANDOM #define random rand /* on win32, for tests only (bad random) */ #endif /* HAVE_RANDOM */ ]) dnl provide w32 compat definition for srandom AC_DEFUN([AHX_CONFIG_W32_SRANDOM], [ #ifndef HAVE_SRANDOM #define srandom(x) srand(x) /* on win32, for tests only (bad random) */ #endif /* HAVE_SRANDOM */ ]) dnl provide w32 compat definition for FD_SET_T AC_DEFUN([AHX_CONFIG_W32_FD_SET_T], [ /* detect if we need to cast to unsigned int for FD_SET to avoid warnings */ #ifdef HAVE_WINSOCK2_H #define FD_SET_T (u_int) #else #define FD_SET_T #endif ]) dnl Remove an extension flag from CFLAGS, define replacement to be made. dnl Used by ACX_STRIP_EXT_FLAGS. dnl $1: the name of the flag, for example -D_GNU_SOURCE. AC_DEFUN([ACX_CFLAGS_STRIP], [ if echo $CFLAGS | grep " $1" >/dev/null 2>&1; then CFLAGS="`echo $CFLAGS | sed -e 's/ $1//g'`" AC_DEFINE(m4_bpatsubst(OMITTED_$1,[[-=]],_), 1, Put $1 define in config.h) fi ]) dnl Remove EXT flags from the CFLAGS and set them to be defined in config.h dnl use with ACX_DETERMINE_EXT_FLAGS. AC_DEFUN([ACX_STRIP_EXT_FLAGS], [ AC_MSG_NOTICE([Stripping extension flags...]) ACX_CFLAGS_STRIP(-D_GNU_SOURCE) ACX_CFLAGS_STRIP(-D_BSD_SOURCE) ACX_CFLAGS_STRIP(-D_DEFAULT_SOURCE) ACX_CFLAGS_STRIP(-D__EXTENSIONS__) ACX_CFLAGS_STRIP(-D_POSIX_C_SOURCE=200112) ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE=600) ACX_CFLAGS_STRIP(-D_XOPEN_SOURCE_EXTENDED=1) ACX_CFLAGS_STRIP(-D_ALL_SOURCE) ACX_CFLAGS_STRIP(-D_LARGEFILE_SOURCE=1) ]) dnl End of ACX_STRIP_EXT_FLAGS dnl define one omitted flag for config.h dnl $1: flag name. -D_GNU_SOURCE dnl $2: replacement define. _GNU_SOURCE dnl $3: define value, 1 AC_DEFUN([AHX_CONFIG_FLAG_OMITTED], [#if defined($1) && !defined($2) #define $2 $3 [#]endif]) dnl Wrapper for AHX_CONFIG_FLAG_OMITTED for -D style flags dnl $1: the -DNAME or -DNAME=value string. AC_DEFUN([AHX_CONFIG_FLAG_EXT], [AHX_CONFIG_FLAG_OMITTED(m4_bpatsubst(OMITTED_$1,[[-=]],_),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,))) ]) dnl config.h part to define omitted cflags, use with ACX_STRIP_EXT_FLAGS. AC_DEFUN([AHX_CONFIG_EXT_FLAGS], [AHX_CONFIG_FLAG_EXT(-D_GNU_SOURCE) AHX_CONFIG_FLAG_EXT(-D_BSD_SOURCE) AHX_CONFIG_FLAG_EXT(-D_DEFAULT_SOURCE) AHX_CONFIG_FLAG_EXT(-D__EXTENSIONS__) AHX_CONFIG_FLAG_EXT(-D_POSIX_C_SOURCE=200112) AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE=600) AHX_CONFIG_FLAG_EXT(-D_XOPEN_SOURCE_EXTENDED=1) AHX_CONFIG_FLAG_EXT(-D_ALL_SOURCE) AHX_CONFIG_FLAG_EXT(-D_LARGEFILE_SOURCE=1) ]) dnl check if memcmp is using signed characters and replace if so. AC_DEFUN([ACX_CHECK_MEMCMP_SIGNED], [AC_MSG_CHECKING([if memcmp compares unsigned]) AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include int main(void) { char a = 255, b = 0; if(memcmp(&a, &b, 1) < 0) return 1; return 0; } ]])], [AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes]) AC_LIBOBJ([memcmp]) ], [ AC_MSG_RESULT([cross-compile no]) AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes]) AC_LIBOBJ([memcmp]) ]) ]) dnl define memcmp to its replacement, pass unique id for program as arg AC_DEFUN([AHX_MEMCMP_BROKEN], [ #ifdef MEMCMP_IS_BROKEN #include "compat/memcmp.h" #define memcmp memcmp_$1 int memcmp(const void *x, const void *y, size_t n); #endif ]) dnl ACX_CHECK_SS_FAMILY - check for sockaddr_storage.ss_family AC_DEFUN([ACX_CHECK_SS_FAMILY], [AC_CHECK_MEMBER([struct sockaddr_storage.ss_family], [], [ AC_CHECK_MEMBER([struct sockaddr_storage.__ss_family], [ AC_DEFINE([ss_family], [__ss_family], [Fallback member name for socket family in struct sockaddr_storage]) ],, [AC_INCLUDES_DEFAULT #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif ]) ], [AC_INCLUDES_DEFAULT #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif ]) ]) dnl Check if CC and linker support -fPIE and -pie. dnl If so, sets them in CFLAGS / LDFLAGS. AC_DEFUN([ACX_CHECK_PIE], [ AC_ARG_ENABLE([pie], AS_HELP_STRING([--enable-pie], [Enable Position-Independent Executable (eg. to fully benefit from ASLR, small performance penalty)])) AS_IF([test "x$enable_pie" = "xyes"], [ AC_MSG_CHECKING([if $CC supports PIE]) BAKLDFLAGS="$LDFLAGS" BAKCFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS -pie" CFLAGS="$CFLAGS -fPIE" AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ if $CC $CFLAGS $LDFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then LDFLAGS="$BAKLDFLAGS" AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi rm -f conftest conftest.c conftest.o ], [LDFLAGS="$BAKLDFLAGS" ; CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)]) ]) ]) dnl Check if linker supports -Wl,-z,relro,-z,now. dnl If so, adds it to LDFLAGS. AC_DEFUN([ACX_CHECK_RELRO_NOW], [ AC_ARG_ENABLE([relro_now], AS_HELP_STRING([--enable-relro-now], [Enable full relocation binding at load-time (RELRO NOW, to protect GOT and .dtor areas)])) AS_IF([test "x$enable_relro_now" = "xyes"], [ AC_MSG_CHECKING([if $CC supports -Wl,-z,relro,-z,now]) BAKLDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now" AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ if $CC $CFLAGS $LDFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then LDFLAGS="$BAKLDFLAGS" AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) fi rm -f conftest conftest.c conftest.o ], [LDFLAGS="$BAKLDFLAGS" ; AC_MSG_RESULT(no)]) ]) ]) dnl End of file ldns-1.9.2/ax_pkg_swig.m40000664000175000017500000001516015212267520014602 0ustar willemwillem# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html # =========================================================================== # # SYNOPSIS # # AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) # # DESCRIPTION # # This macro searches for a SWIG installation on your system. If found, # then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is # found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. # # You can use the optional first argument to check if the version of the # available SWIG is greater than or equal to the value of the argument. It # should have the format: N[.N[.N]] (N is a number between 0 and 999. Only # the first N is mandatory.) If the version argument is given (e.g. # 1.3.17), AX_PKG_SWIG checks that the swig package is this version number # or higher. # # As usual, action-if-found is executed if SWIG is found, otherwise # action-if-not-found is executed. # # In configure.in, use as: # # AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) # AX_SWIG_ENABLE_CXX # AX_SWIG_MULTI_MODULE_SUPPORT # AX_SWIG_PYTHON # # LICENSE # # Copyright (c) 2008 Sebastian Huber # Copyright (c) 2008 Alan W. Irwin # Copyright (c) 2008 Rafael Laboissiere # Copyright (c) 2008 Andrew Collier # Copyright (c) 2011 Murray Cumming # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 13 AC_DEFUN([AX_PKG_SWIG],[ # Find path to the "swig" executable. AC_PATH_PROGS([SWIG],[swig swig3.0 swig2.0]) if test -z "$SWIG" ; then m4_ifval([$3],[$3],[:]) elif test -n "$1" ; then AC_MSG_CHECKING([SWIG version]) [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] AC_MSG_RESULT([$swig_version]) if test -n "$swig_version" ; then # Calculate the required version number components [required=$1] [required_major=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_major" ; then [required_major=0] fi [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] [required_minor=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_minor" ; then [required_minor=0] fi [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] [required_patch=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_patch" ; then [required_patch=0] fi # Calculate the available version number components [available=$swig_version] [available_major=`echo $available | sed 's/[^0-9].*//'`] if test -z "$available_major" ; then [available_major=0] fi [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] [available_minor=`echo $available | sed 's/[^0-9].*//'`] if test -z "$available_minor" ; then [available_minor=0] fi [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] [available_patch=`echo $available | sed 's/[^0-9].*//'`] if test -z "$available_patch" ; then [available_patch=0] fi # Convert the version tuple into a single number for easier comparison. # Using base 100 should be safe since SWIG internally uses BCD values # to encode its version number. required_swig_vernum=`expr $required_major \* 10000 \ \+ $required_minor \* 100 \+ $required_patch` available_swig_vernum=`expr $available_major \* 10000 \ \+ $available_minor \* 100 \+ $available_patch` if test $available_swig_vernum -lt $required_swig_vernum; then AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version.]) SWIG='' m4_ifval([$3],[$3],[]) else AC_MSG_CHECKING([for SWIG library]) SWIG_LIB=`$SWIG -swiglib` AC_MSG_RESULT([$SWIG_LIB]) m4_ifval([$2],[$2],[]) fi else AC_MSG_WARN([cannot determine SWIG version]) SWIG='' m4_ifval([$3],[$3],[]) fi fi AC_SUBST([SWIG_LIB]) ]) ldns-1.9.2/contrib/0000775000175000017500000000000015212267527013502 5ustar willemwillemldns-1.9.2/contrib/build-solaris.sh0000664000175000017500000000173015212267520016601 0ustar willemwillem#!/bin/ksh # # $Id$ PREFIX=/opt/ldns OPENSSL=/usr/sfw SUDO=sudo MAKE_PROGRAM=gmake MAKE_ARGS="-j 4" OBJ32=obj32 OBJ64=obj64 SRCDIR=`pwd` test -d $OBJ32 && $SUDO rm -fr $OBJ32 mkdir $OBJ32 export CFLAGS="" export LDFLAGS="-L${OPENSSL}/lib -R${OPENSSL}/lib" (cd $OBJ32; \ ${SRCDIR}/configure --with-ssl=${OPENSSL} --prefix=${PREFIX} --libdir=${PREFIX}/lib; \ $MAKE_PROGRAM $MAKE_ARGS) if [ `isainfo -k` = amd64 ]; then test -d $OBJ64 && $SUDO rm -fr $OBJ64 mkdir $OBJ64 export CFLAGS="-m64" export LDFLAGS="-L${OPENSSL}/lib/amd64 -R${OPENSSL}/lib/amd64" (cd $OBJ64; \ ${SRCDIR}/configure --with-ssl=${OPENSSL} --prefix=${PREFIX} --libdir=${PREFIX}/lib/amd64; \ $MAKE_PROGRAM $MAKE_ARGS) fi # optionally install # if [ x$1 = xinstall ]; then (cd $OBJ32; $SUDO $MAKE_PROGRAM install-h) (cd $OBJ32; $SUDO $MAKE_PROGRAM install-doc) (cd $OBJ32; $SUDO $MAKE_PROGRAM install-lib) if [ `isainfo -k` = amd64 ]; then (cd $OBJ64; $SUDO $MAKE_PROGRAM install-lib) fi fi ldns-1.9.2/contrib/ldnsx/0000775000175000017500000000000015212267520014623 5ustar willemwillemldns-1.9.2/contrib/ldnsx/source/0000775000175000017500000000000015212267520016123 5ustar willemwillemldns-1.9.2/contrib/ldnsx/source/examples/0000775000175000017500000000000015212267520017741 5ustar willemwillemldns-1.9.2/contrib/ldnsx/source/examples/ldnsx-mx1.rst0000664000175000017500000000012715212267520022326 0ustar willemwillemMX1 === .. literalinclude:: ../../examples/ldnsx-mx1.py :language: python :linenos: ldns-1.9.2/contrib/ldnsx/source/examples/ldnsx-axfr.rst0000664000175000017500000000015215212267520022557 0ustar willemwillemAXFR Example ============ .. literalinclude:: ../../examples/ldnsx-axfr.py :language: python :linenos: ldns-1.9.2/contrib/ldnsx/source/examples/ldnsx-walk.rst0000664000175000017500000000015015212267520022553 0ustar willemwillemNSEC Walker =========== .. literalinclude:: ../../examples/ldnsx-walk.py :language: python :linenos: ldns-1.9.2/contrib/ldnsx/source/examples/ldnsx-dnssec.rst0000664000175000017500000000016015212267520023075 0ustar willemwillemDNSSEC Example ============== .. literalinclude:: ../../examples/ldnsx-dnssec.py :language: python :linenos: ldns-1.9.2/contrib/ldnsx/source/examples/ldnsx-mx2.rst0000664000175000017500000000012715212267520022327 0ustar willemwillemMX2 === .. literalinclude:: ../../examples/ldnsx-mx2.py :language: python :linenos: ldns-1.9.2/contrib/ldnsx/source/index.rst0000664000175000017500000000203415212267520017763 0ustar willemwillemWelcome to ldnsx's documentation! ================================= LDNSX: Easy DNS (including DNSSEC) via ldns. ldns is a great library. It is a powerful tool for working with DNS. python-ldns it is a straight up clone of the C interface, however that is not a very good interface for python. Its documentation is incomplete and some functions don't work as described. And some objects don't have a full python API. ldnsx aims to fix this. It wraps around the ldns python bindings, working around its limitations and providing a well-documented, more pythonistic interface. Reference ========= .. toctree:: :maxdepth: 1 api/ldnsx .. toctree:: :maxdepth: 2 api/resolver api/packet api/resource_record Examples ======== Examples translated from ldns examples: .. toctree:: :maxdepth: 1 examples/ldnsx-axfr examples/ldnsx-dnssec examples/ldnsx-mx1 examples/ldnsx-mx2 Others: .. toctree:: :maxdepth: 1 examples/ldnsx-walk Indices and tables ================== * :ref:`genindex` * :ref:`search` ldns-1.9.2/contrib/ldnsx/source/conf.py0000664000175000017500000001431115212267520017422 0ustar willemwillem# -*- coding: utf-8 -*- # # ldnsx documentation build configuration file, created by # sphinx-quickstart on Mon May 30 16:56:19 2011. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append(os.path.abspath('..')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']#, 'sphinx.ext.jsmath'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' # General information about the project. project = u'ldnsx' copyright = u'2011, Christopher Olah' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.0' # The full version, including alpha/beta/rc tags. release = '-1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'ldnsxdoc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'ldnsx.tex', u'ldnsx Documentation', u'Christopher Olah', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True ldns-1.9.2/contrib/ldnsx/source/api/0000775000175000017500000000000015212267520016674 5ustar willemwillemldns-1.9.2/contrib/ldnsx/source/api/packet.rst0000664000175000017500000000012515212267520020673 0ustar willemwillemClass packet ============== .. autoclass:: ldnsx.packet :members: :undoc-members: ldns-1.9.2/contrib/ldnsx/source/api/resource_record.rst0000664000175000017500000000015615212267520022615 0ustar willemwillemClass resource_record ===================== .. autoclass:: ldnsx.resource_record :members: :undoc-members: ldns-1.9.2/contrib/ldnsx/source/api/ldnsx.rst0000664000175000017500000000027715212267520020564 0ustar willemwillemLDNSX API Reference =================== .. automodule:: ldnsx :members: query, get_rrs, secure_query Classes ------- .. toctree:: :maxdepth: 1 :glob: resolver packet resource_record ldns-1.9.2/contrib/ldnsx/source/api/resolver.rst0000664000175000017500000000013215212267520021263 0ustar willemwillemClass resolver =============== .. autoclass:: ldnsx.resolver :members: :undoc-members: ldns-1.9.2/contrib/ldnsx/examples/0000775000175000017500000000000015212267520016441 5ustar willemwillemldns-1.9.2/contrib/ldnsx/examples/ldnsx-axfr.py0000664000175000017500000000174415212267520021107 0ustar willemwillem#!/usr/bin/python # vim:fileencoding=utf-8 # # AXFR client with IDN (Internationalized Domain Names) support # import ldns import encodings.idna def utf2name(name): return '.'.join([encodings.idna.ToASCII(a) for a in name.split('.')]) def name2utf(name): return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')]) resolver = ldnsx.resolver("zone.nic.cz") #Print results for rr in resolver.AXFR(utf2name(u"háčkyčárky.cz")): # rdf = rr.owner() # if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): # print "RDF owner: type=",rr.type(),"data=",name2utf(rr.owner()) # else: # print "RDF owner: type=",rdf.get_type_str(),"data=",str(rdf) # print " RR type=", rr.get_type_str()," ttl=",rr.ttl() # for rdf in rr.rdfs(): # if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): # print " RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf)) # else: # print " RDF: type=",rdf.get_type_str(),"data=",str(rdf) ldns-1.9.2/contrib/ldnsx/examples/ldnsx-walk.py0000775000175000017500000000135715212267520021110 0ustar willemwillem#!/usr/bin/python # vim:fileencoding=utf-8 # # Walk a domain that's using NSEC and print in zonefile format. import sys import ldnsx def walk(domain): res = ldnsx.resolver("193.110.157.136", dnssec=True) pkt = res.query(domain, 666) try: nsec_rr = pkt.authority(rr_type="NSEC")[0] except: print "no NSEC found, domain is not signed or using NSEC3" sys.exit() for rr_type in nsec_rr[5].split(' ')[:-1]: for rr in ldnsx.get_rrs(domain, rr_type): print str(rr)[:-1] next_rec = nsec_rr[4] if (next_rec != domain) and (next_rec[-len(domain):] == domain): walk(next_rec) walk("xelerance.com") ldns-1.9.2/contrib/ldnsx/examples/ldnsx-mx1.py0000664000175000017500000000023715212267520020650 0ustar willemwillemimport ldnsx resolver = ldnsx.resolver() pkt = resolver.query("nic.cz", "MX") if (pkt): mx = pkt.answer() if (mx): mx.sort() print mx ldns-1.9.2/contrib/ldnsx/examples/ldnsx-mx2.py0000664000175000017500000000064615212267520020655 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldnsx resolver = ldnsx.resolver() pkt = resolver.query("nic.cz", "MX") if pkt: for rr in pkt.answer(rr_type = "MX"): rdf = rr.owner() print rr #Could also do: #print rr[0], rr[1], rr[2], rr[3], " ".join(rr[4:]) #print rr.owner(), rr.ttl(), rr.rr_clas(), rr.rr_type(), " ".join(rr[4:]) ldns-1.9.2/contrib/ldnsx/examples/ldnsx-dnssec.py0000664000175000017500000000153615212267520021425 0ustar willemwillem#!/usr/bin/python # -*- coding: utf-8 -*- import ldnsx import sys debug = True if len(sys.argv) < 2: print "Usage:", sys.argv[0], "domain [resolver_addr]" sys.exit(1) name = sys.argv[1] # Create resolver resolver = ldnsx.resolver(dnssec=True) # Custom resolver if len(sys.argv) > 2: # Clear previous nameservers resolver.set_nameservers(sys.argv[2:]) # Resolve DNS name pkt = resolver.query(name, "A") if pkt and pkt.answer(): # Debug if debug: print "NS returned:", pkt.rcode(), "(AA: %d AD: %d)" % ( "AA" in pkt.flags(), "AD" in pkt.flags() ) # SERVFAIL indicated bogus name if pkt.rcode() == "SERVFAIL": print name, "failed to resolve" # Check AD (Authenticated) bit if pkt.rcode() == "NOERROR": if "AD" in pkt.flags(): print name, "is secure" else: print name, "is insecure" ldns-1.9.2/contrib/ldnsx/LICENSE0000664000175000017500000000302115212267520015624 0ustar willemwillemCopyright (c) 2011, Xelerance Author: Christopher Olah All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Xelerance nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ldns-1.9.2/contrib/ldnsx/README0000664000175000017500000000203315212267520015501 0ustar willemwillemLDNSX: Easy DNS (including DNSSEC) via ldns. ldns is a great library. It is a powerful tool for working with DNS. python-ldns it is a straight up clone of the C interface, however that is not a very good interface for python. Its documentation is incomplete and some functions don't work as described. And some objects don't have a full python API. ldnsx aims to fix this. It wraps around the ldns python bindings, working around its limitations and providing a well-documented, more pythonistic interface. Written by Christopher Olah Examples ======== Query the default resolver for google.com's A records. Print the response packet. >>> import ldnsx >>> resolver = ldnsx.resolver() >>> print resolver.query("google.com","A") Print the NS records for com. from f.root-servers.net if we get a response, else an error message. >>> import ldnsx >>> pkt = ldnsx.resolver("f.root-servers.net").query("com.","NS") >>> if pkt: >>> for rr in pkt.answer(): >>> print rr >>> else: >>> print "response not received" ldns-1.9.2/contrib/ldnsx/ldnsx.py0000664000175000017500000007320515212267520016334 0ustar willemwillem# Copyright (C) Xelerance Corp. . # Author: Christopher Olah # License: BSD """ Easy DNS (including DNSSEC) via ldns. ldns is a great library. It is a powerful tool for working with DNS. python-ldns it is a straight up clone of the C interface, however that is not a very good interface for python. Its documentation is incomplete and some functions don't work as described. And some objects don't have a full python API. ldnsx aims to fix this. It wraps around the ldns python bindings, working around its limitations and providing a well-documented, more pythonistic interface. **WARNING:** **API subject to change.** No backwards compatibility guarantee. Write software using this version at your own risk! Examples -------- Query the default resolver for google.com's A records. Print the response packet. >>> import ldnsx >>> resolver = ldnsx.resolver() >>> print resolver.query("google.com","A") Print the root NS records from f.root-servers.net; if we get a response, else an error message. >>> import ldnsx >>> pkt = ldnsx.resolver("f.root-servers.net").query(".", "NS") >>> if pkt: >>> for rr in pkt.answer(): >>> print rr >>> else: >>> print "response not received" """ import time, sys, calendar, warnings, socket try: import ldns except ImportError: print >> sys.stderr, "ldnsx requires the ldns-python sub-package from http://www.nlnetlabs.nl/projects/ldns/" print >> sys.stderr, "Fedora/CentOS: yum install ldns-python" print >> sys.stderr, "Debian/Ubuntu: apt-get install python-ldns" print >> sys.stderr, "openSUSE: zypper in python-ldns" sys.exit(1) __version__ = "0.1" def isValidIP(ipaddr): try: v4 = socket.inet_pton(socket.AF_INET,ipaddr) return 4 except: try: v6 = socket.inet_pton(socket.AF_INET6,ipaddr) return 6 except: return 0 def query(name, rr_type, rr_class="IN", flags=["RD"], tries = 3, res=None): """Convenience function. Creates a resolver and then queries it. Refer to resolver.query() * name -- domain to query for * rr_type -- rr_type to query for * flags -- flags for query (list of strings) * tries -- number of times to retry the query on failure * res -- configurations for the resolver as a dict -- see resolver() """ if isinstance(res, list) or isinstance(res, tuple): res = resolver(*res) elif isinstance(res, dict): res = resolver(**res) else: res = resolver(res) return res.query(name, rr_type, rr_class, flags, tries) def get_rrs(name, rr_type, rr_class="IN", tries = 3, strict = False, res=None, **kwds): """Convenience function. Gets RRs for name of type rr_type trying tries times. If strict, it raises and exception on failure, otherwise it returns []. * name -- domain to query for * rr_type -- rr_type to query for * flags -- flags for query (list of strings) * tries -- number of times to retry the query on failure * strict -- if the query fails, do we return [] or raise an exception? * res -- configurations for the resolver as a dict -- see resolver() * kwds -- query filters, refer to packet.answer() """ if isinstance(res, list) or isinstance(res, tuple): res = resolver(*res) elif isinstance(res, dict): res = resolver(**res) else: res = resolver(res) if "|" in rr_type: pkt = res.query(name, "ANY", rr_class=rr_class, tries=tries) else: pkt = res.query(name, rr_type, rr_class=rr_class, tries=tries) if pkt: if rr_type in ["", "ANY", "*"]: return pkt.answer( **kwds) else: return pkt.answer(rr_type=rr_type, **kwds) else: if strict: raise Exception("LDNS couldn't complete query") else: return [] def secure_query(name, rr_type, rr_class="IN", flags=["RD"], tries = 1, flex=False, res=None): """Convenience function. Creates a resolver and then does a DNSSEC query. Refer to resolver.query() * name -- domain to query for * rr_type -- rr_type to query for * flags -- flags for query (list of strings) * tries -- number of times to retry the query on failure * flex -- if we can't verify data, exception or warning? * res -- configurations for the resolver as a dict -- see resolver()""" if isinstance(res, list) or isinstance(res, tuple): res = resolver(*res) elif isinstance(res, dict): res = resolver(**res) else: res = resolver(res) pkt = res.query(name, rr_type, rr_class, flags, tries) if pkt.rcode() == "SERVFAIL": raise Exception("%s lookup failed (server error or dnssec validation failed)" % name) if pkt.rcode() == "NXDOMAIN": if "AD" in pkt.flags(): raise Exception("%s lookup failed (non-existence proven by DNSSEC)" % name ) else: raise Exception("%s lookup failed" % name ) if pkt.rcode() == "NOERROR": if "AD" not in pkt.flags(): if not flex: raise Exception("DNS lookup was insecure") else: warnings.warn("DNS lookup was insecure") return pkt else: raise Exception("unknown ldns error, %s" % pkt.rcode()) class resolver: """ A wrapper around ldns.ldns_resolver. **Examples** Making resolvers is easy! >>> from ldnsx import resolver >>> resolver() # from /etc/resolv.conf >>> resolver("") # resolver with no nameservers >>> resolver("193.110.157.135") #resolver pointing to ip addr >>> resolver("f.root-servers.net") # resolver pointing ip address(es) resolved from name >>> resolver("193.110.157.135, 193.110.157.136") >>> # resolver pointing to multiple ip addr, first takes precedence. So is playing around with their nameservers! >>> import ldnsx >>> res = ldnsx.resolver("192.168.1.1") >>> res.add_nameserver("192.168.1.2") >>> res.add_nameserver("192.168.1.3") >>> res.nameservers_ip() ["192.168.1.1","192.168.1.2","192.168.1.3"] And querying! >>> from ldnsx import resolver >>> res= resolver() >>> res.query("cow.com","A") ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 7663 ;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;; cow.com. IN A ;; ANSWER SECTION: cow.com. 300 IN A 208.87.34.18 ;; AUTHORITY SECTION: ;; ADDITIONAL SECTION: ;; Query time: 313 msec ;; SERVER: 192.168.111.9 ;; WHEN: Fri Jun 3 11:01:02 2011 ;; MSG SIZE rcvd: 41 """ def __init__(self, ns = None, dnssec = False, tcp = False, port = 53): """resolver constructor * ns -- the nameserver/comma delimited nameserver list defaults to settings from /etc/resolv.conf * dnssec -- should the resolver try and use dnssec or not? * tcp -- should the resolver use TCP 'auto' is a deprecated work around for old ldns problems * port -- the port to use, must be the same for all nameservers """ # We construct based on a file and dump the nameservers rather than using # ldns_resolver_new() to avoid environment/configuration/magic specific # bugs. self._ldns_resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") if ns != None: self.drop_nameservers() nm_list = ns.split(',') nm_list = map(lambda s: s.strip(), nm_list) nm_list = list(filter(lambda s: s != "", nm_list)) nm_list.reverse() for nm in nm_list: self.add_nameserver(nm) # Configure DNSSEC, tcp and port self.set_dnssec(dnssec) if tcp == 'auto': self.autotcp = True self._ldns_resolver.set_usevc(False) else: self.autotcp = False self._ldns_resolver.set_usevc(tcp) self._ldns_resolver.set_port(port) def query(self, name, rr_type, rr_class="IN", flags=["RD"], tries = 3): """Run a query on the resolver. * name -- name to query for * rr_type -- the record type to query for * rr_class -- the class to query for, defaults to IN (Internet) * flags -- the flags to send the query with * tries -- the number of times to attempt to achieve query in case of packet loss, etc **Examples** Let's get some A records! >>> google_a_records = resolver.query("google.com","A").answer() Using DNSSEC is easy :) >>> dnssec_pkt = ldnsx.resolver(dnssec=True).query("xelerance.com") We let you use strings to make things easy, but if you prefer stay close to DNS... >>> AAAA = 28 >>> resolver.query("ipv6.google.com", AAAA) **More about rr_type** rr_type must be a supported resource record type. There are a large number of RR types: =========== =================================== ================== TYPE Value and meaning Reference =========== =================================== ================== A 1 a host address [RFC1035] NS 2 an authoritative name server [RFC1035] ... AAAA 28 IP6 Address [RFC3596] ... DS 43 Delegation Signer [RFC4034][RFC3658] ... DNSKEY 48 DNSKEY [RFC4034][RFC3755] ... Unassigned 32770-65279 Private use 65280-65534 Reserved 65535 =========== =================================== ================== (From http://www.iana.org/assignments/dns-parameters) RR types are given as a string (eg. "A"). In the case of Unassigned/Private use/Reserved ones, they are given as "TYPEXXXXX" where XXXXX is the number. ie. RR type 65280 is "TYPE65280". You may also pass the integer, but you always be given the string. If the version of ldnsx you are using is old, it is possible that there could be new rr_types that we don't recognise mnemonic for. You can still use the number XXX or the string "TYPEXXX". To determine what rr_type mnemonics we support, please refer to resolver.supported_rr_types() """ # Determine rr_type int if rr_type in _rr_types.keys(): _rr_type = _rr_types[rr_type] elif isinstance(rr_type,int): _rr_type = rr_type elif isinstance(rr_type,str) and rr_type[0:4] == "TYPE": try: _rr_type = int(rr_type[4:]) except: raise Exception("%s is a bad RR type. TYPEXXXX: XXXX must be a number") else: raise Exception("ldnsx (version %s) does not support the RR type %s." % (__version__, str(rr_type)) ) # Determine rr_class int if rr_class == "IN": _rr_class = ldns.LDNS_RR_CLASS_IN elif rr_class == "CH": _rr_class = ldns.LDNS_RR_CLASS_CH elif rr_class == "HS": _rr_class = ldns.LDNS_RR_CLASS_HS else: raise Exception("ldnsx (version %s) does not support the RR class %s." % (__version__, str(rr_class)) ) # Determine flags int _flags = 0 if "QR" in flags: _flags |= ldns.LDNS_QR if "AA" in flags: _flags |= ldns.LDNS_AA if "TC" in flags: _flags |= ldns.LDNS_TC if "RD" in flags: _flags |= ldns.LDNS_RD if "CD" in flags: _flags |= ldns.LDNS_CD if "RA" in flags: _flags |= ldns.LDNS_RA if "AD" in flags: _flags |= ldns.LDNS_AD # Query if tries == 0: return None try: pkt = self._ldns_resolver.query(name, _rr_type, _rr_class, _flags) except KeyboardInterrupt: #Since so much time is spent waiting on ldns, this is very common place for Ctr-C to fall raise except: #Since the ldns exception is not very descriptive... raise Exception("ldns backend ran into problems. Likely, the name you were querying for, %s, was invalid." % name) #Deal with failed queries if not pkt: if tries <= 1: return None else: # One of the major causes of none-packets is truncation of packets # When autotcp is set, we are in a flexible enough position to try and use tcp # to get around this. # Either way, we want to replace the resolver, since resolvers will sometimes # just freeze up. if self.autotcp: self = resolver( ",".join(self.nameservers_ip()),tcp=True, dnssec = self._ldns_resolver.dnssec()) self.autotcp = True pkt = self.query(name, rr_type, rr_class=rr_class, flags=flags, tries = tries-1) self._ldns_resolver.set_usevc(False) return pkt else: self = resolver( ",".join(self.nameservers_ip()), tcp = self._ldns_resolver.usevc(), dnssec = self._ldns_resolver.dnssec() ) time.sleep(1) # It could be that things are failing because of a brief outage return self.query(name, rr_type, rr_class=rr_class, flags=flags, tries = tries-1) elif self.autotcp: pkt = packet(pkt) if "TC" in pkt.flags(): self._ldns_resolver.set_usevc(True) pkt2 = self.query(name, rr_type, rr_class=rr_class, flags=flags, tries = tries-1) self._ldns_resolver.set_usevc(False) if pkt2: return packet(pkt2) return pkt return packet(pkt) #ret = [] #for rr in pkt.answer().rrs(): # ret.append([str(rr.owner()),rr.ttl(),rr.get_class_str(),rr.get_type_str()]+[str(rdf) for rdf in rr.rdfs()]) #return ret def suported_rr_types(self): """ Returns the supported DNS resource record types. Refer to resolver.query() for thorough documentation of resource record types or refer to: http://www.iana.org/assignments/dns-parameters """ return _rr_types.keys() def AXFR(self,name): """AXFR for name * name -- name to AXFR for This function is a generator. As it AXFRs it will yield you the records. **Example** Let's get a list of the tlds (gotta catch em all!): >>> tlds = [] >>> for rr in resolver("f.root-servers.net").AXFR("."): >>> if rr.rr_type() == "NS": >>> tlds.append(rr.owner()) """ #Dname seems to be unnecessary on some computers, but it is on others. Avoid bugs. if self._ldns_resolver.axfr_start(ldns.ldns_dname(name), ldns.LDNS_RR_CLASS_IN) != ldns.LDNS_STATUS_OK: raise Exception("Starting AXFR failed. Error: %s" % ldns.ldns_get_errorstr_by_id(status)) pres = self._ldns_resolver.axfr_next() while pres: yield resource_record(pres) pres = self._ldns_resolver.axfr_next() def nameservers_ip(self): """ returns a list of the resolvers nameservers (as IP addr) """ nm_stack2 =[] nm_str_stack2=[] nm = self._ldns_resolver.pop_nameserver() while nm: nm_stack2.append(nm) nm_str_stack2.append(str(nm)) nm = self._ldns_resolver.pop_nameserver() for nm in nm_stack2: self._ldns_resolver.push_nameserver(nm) nm_str_stack2.reverse() return nm_str_stack2 def add_nameserver(self,ns): """ Add a nameserver, IPv4/IPv6/name. """ if isValidIP(ns) == 4: address = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A,ns) self._ldns_resolver.push_nameserver(address) elif isValidIP(ns) == 6: address = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_AAAA,ns) self._ldns_resolver.push_nameserver(address) else: resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") #address = resolver.get_addr_by_name(ns) address = resolver.get_addr_by_name(ldns.ldns_dname(ns)) if not address: address = resolver.get_addr_by_name(ldns.ldns_dname(ns)) if not address: raise Exception("Failed to resolve address for %s" % ns) for rr in address.rrs(): self._ldns_resolver.push_nameserver_rr(rr) def drop_nameservers(self): """Drops all nameservers. This function causes the resolver to forget all nameservers. """ while self._ldns_resolver.pop_nameserver(): pass def set_nameservers(self, nm_list): """Takes a list of nameservers and sets the resolver to use them """ self.drop_nameservers() for nm in nm_list: self.add_nameserver(nm) def __repr__(self): return "" % ", ".join(self.nameservers_ip()) __str__ = __repr__ def set_dnssec(self,new_dnssec_status): """Set whether the resolver uses DNSSEC. """ self._ldns_resolver.set_dnssec(new_dnssec_status) class packet: def _construct_rr_filter(self, **kwds): def match(pattern, target): if pattern[0] in ["<",">","!"]: rel = pattern[0] pattern=pattern[1:] elif pattern[0:2] in ["<=","=>"]: rel = pattern[0:2] pattern=pattern[2:] else: rel = "=" for val in pattern.split("|"): if {"<" : target < val, ">" : target > val, "!" : target != val, "=" : target == val, ">=": target >= val, "<=": target <= val}[rel]: return True return False def f(rr): for key in kwds.keys(): if ( ( isinstance(kwds[key], list) and str(rr[key]) not in map(str,kwds[key]) ) or ( not isinstance(kwds[key], list) and not match(str(kwds[key]), str(rr[key])))): return False return True return f def __init__(self, pkt): self._ldns_pkt = pkt def __repr__(self): return str(self._ldns_pkt) __str__ = __repr__ def rcode(self): """Returns the rcode. Example returned value: "NOERROR" possible rcodes (via ldns): "FORMERR", "MASK", "NOERROR", "NOTAUTH", "NOTIMPL", "NOTZONE", "NXDOMAIN", "NXRSET", "REFUSED", "SERVFAIL", "SHIFT", "YXDOMAIN", "YXRRSET" Refer to http://www.iana.org/assignments/dns-parameters section: DNS RCODEs """ return self._ldns_pkt.rcode2str() def opcode(self): """Returns the rcode. Example returned value: "QUERY" """ return self._ldns_pkt.opcode2str() def flags(self): """Return packet flags (as list of strings). Example returned value: ['QR', 'RA', 'RD'] **What are the flags?** ======== ==== ===================== ========= Bit Flag Description Reference ======== ==== ===================== ========= bit 5 AA Authoritative Answer [RFC1035] bit 6 TC Truncated Response [RFC1035] bit 7 RD Recursion Desired [RFC1035] bit 8 RA Recursion Allowed [RFC1035] bit 9 Reserved bit 10 AD Authentic Data [RFC4035] bit 11 CD Checking Disabled [RFC4035] ======== ==== ===================== ========= (from http://www.iana.org/assignments/dns-parameters) There is also QR. It is mentioned in other sources, though not the above page. It being false means that the packet is a query, it being true means that it is a response. """ ret = [] if self._ldns_pkt.aa(): ret += ["AA"] if self._ldns_pkt.ad(): ret += ["AD"] if self._ldns_pkt.cd(): ret += ["CD"] if self._ldns_pkt.qr(): ret += ["QR"] if self._ldns_pkt.ra(): ret += ["RA"] if self._ldns_pkt.rd(): ret += ["RD"] if self._ldns_pkt.tc(): ret += ["TC"] return ret def answer(self, **filters): """Returns the answer section. * filters -- a filtering mechanism Since a very common desire is to filter the resource records in a packet section, we provide a special tool for doing this: filters. They are a lot like regular python filters, but more convenient. If you set a field equal to some value, you will only receive resource records for which it holds true. **Examples** >>> res = ldnsx.resolver() >>> pkt = res.query("google.ca","A") >>> pkt.answer() [google.ca. 28 IN A 74.125.91.99 , google.ca. 28 IN A 74.125.91.105 , google.ca. 28 IN A 74.125.91.147 , google.ca. 28 IN A 74.125.91.103 , google.ca. 28 IN A 74.125.91.104 , google.ca. 28 IN A 74.125.91.106 ] To understand filters, consider the following: >>> pkt = ldnsx.query("cow.com","ANY") >>> pkt.answer() [cow.com. 276 IN A 208.87.32.75 , cow.com. 3576 IN NS sell.internettraffic.com. , cow.com. 3576 IN NS buy.internettraffic.com. , cow.com. 3576 IN SOA buy.internettraffic.com. hostmaster.hostingnet.com. 1308785320 10800 3600 604800 3600 ] >>> pkt.answer(rr_type="A") [cow.com. 276 IN A 208.87.32.75 ] >>> pkt.answer(rr_type="A|NS") [cow.com. 276 IN A 208.87.32.75 , cow.com. 3576 IN NS sell.internettraffic.com. , cow.com. 3576 IN NS buy.internettraffic.com. ] >>> pkt.answer(rr_type="!NS") [cow.com. 276 IN A 208.87.32.75 , cow.com. 3576 IN SOA buy.internettraffic.com. hostmaster.hostingnet.com. 1308785320 10800 3600 604800 3600 ] fields are the same as when indexing a resource record. note: ordering is alphabetical. """ ret = [resource_record(rr) for rr in self._ldns_pkt.answer().rrs()] return filter(self._construct_rr_filter(**filters), ret) def authority(self, **filters): """Returns the authority section. * filters -- a filtering mechanism Since a very common desire is to filter the resource records in a packet section, we provide a special tool for doing this: filters. They are a lot like regular python filters, but more convenient. If you set a field equal to some value, you will only receive resource records for which it holds true. See answer() for details. **Examples** >>> res = ldnsx.resolver() >>> pkt = res.query("google.ca","A") >>> pkt.authority() [google.ca. 251090 IN NS ns3.google.com. , google.ca. 251090 IN NS ns1.google.com. , google.ca. 251090 IN NS ns2.google.com. , google.ca. 251090 IN NS ns4.google.com. ] """ ret = [resource_record(rr) for rr in self._ldns_pkt.authority().rrs()] return filter(self._construct_rr_filter(**filters), ret) def additional(self, **filters): """Returns the additional section. * filters -- a filtering mechanism Since a very common desire is to filter the resource records in a packet section, we provide a special tool for doing this: filters. They are a lot like regular python filters, but more convenient. If you set a field equal to some value, you will only receive resource records for which it holds true. See answer() for details. **Examples** >>> res = ldnsx.resolver() >>> pkt = res.query("google.ca","A") >>> pkt.additional() [ns3.google.com. 268778 IN A 216.239.36.10 , ns1.google.com. 262925 IN A 216.239.32.10 , ns2.google.com. 255659 IN A 216.239.34.10 , ns4.google.com. 264489 IN A 216.239.38.10 ] """ ret = [resource_record(rr) for rr in self._ldns_pkt.additional().rrs()] return filter(self._construct_rr_filter(**filters), ret) def question(self, **filters): """Returns the question section. * filters -- a filtering mechanism Since a very common desire is to filter the resource records in a packet section, we provide a special tool for doing this: filters. They are a lot like regular python filters, but more convenient. If you set a field equal to some value, you will only receive resource records for which it holds true. See answer() for details. """ ret = [resource_record(rr) for rr in self._ldns_pkt.question().rrs()] return filter(self._construct_rr_filter(**filters), ret) class resource_record: _rdfs = None _iter_pos = None def __init__(self, rr): self._ldns_rr = rr self._rdfs = [str(rr.owner()),rr.ttl(),rr.get_class_str(),rr.get_type_str()]+[str(rdf) for rdf in rr.rdfs()] def __repr__(self): return str(self._ldns_rr) __str__ = __repr__ def __iter__(self): self._iter_pos = 0 return self def next(self): if self._iter_pos < len(self._rdfs): self._iter_pos += 1 return self._rdfs[self._iter_pos-1] else: raise StopIteration def __len__(self): try: return len(self._rdfs) except: return 0 def __getitem__(self, n): if isinstance(n, int): return self._rdfs[n] elif isinstance(n, str): n = n.lower() if n in ["owner"]: return self.owner() elif n in ["rr_type", "rr type", "type"]: return self.rr_type() elif n in ["rr_class", "rr class", "class"]: return self.rr_class() elif n in ["covered_type", "covered type", "type2"]: return self.covered_type() elif n in ["ttl"]: return self.ttl() elif n in ["ip"]: return self.ip() elif n in ["alg", "algorithm"]: return self.alg() elif n in ["protocol"]: return self.protocol() elif n in ["flags"]: return self.flags() else: raise Exception("ldnsx (version %s) does not recognize the rr field %s" % (__version__,n) ) else: raise TypeError("bad type %s for index resource record" % type(n) ) #def rdfs(self): # return self._rdfs.clone() def owner(self): """Get the RR's owner""" return str(self._ldns_rr.owner()) def rr_type(self): """Get a RR's type """ return self._ldns_rr.get_type_str() def covered_type(self): """Get an RRSIG RR's covered type""" if self.rr_type() == "RRSIG": return self[4] else: return "" def rr_class(self): """Get the RR's collapse""" return self._ldns_rr.get_class_str() def ttl(self): """Get the RR's TTL""" return self._ldns_rr.ttl() def inception(self, out_format="UTC"): """returns the inception time in format out_format, defaulting to a UTC string. options for out_format are: UTC -- a UTC string eg. 20110712192610 (2011/07/12 19:26:10) unix -- number of seconds since the epoch, Jan 1, 1970 struct_time -- the format used by python's time library """ # Something very strange is going on with inception/expiration dates in DNS. # According to RFC 4034 section 3.1.5 (http://tools.ietf.org/html/rfc4034#page-9) # the inception/expiration fields should be in seconds since Jan 1, 1970, the Unix # epoch (as is standard in unix). Yet all the packets I've seen provide UTC encoded # as a string instead, eg. "20110712192610" which is 2011/07/12 19:26:10. # # It turns out that this is a standard thing that ldns is doing before the data gets # to us. if self.rr_type() == "RRSIG": if out_format.lower() in ["utc", "utc str", "utc_str"]: return self[9] elif out_format.lower() in ["unix", "posix", "ctime"]: return calendar.timegm(time.strptime(self[9], "%Y%m%d%H%M%S")) elif out_format.lower() in ["relative"]: return calendar.timegm(time.strptime(self[9], "%Y%m%d%H%M%S")) - time.time() elif out_format.lower() in ["struct_time", "time.struct_time"]: return time.strptime(self[9], "%Y%m%d%H%M%S") else: raise Exception("unrecognized time format") else: return "" def expiration(self, out_format="UTC"): """get expiration time. see inception() for more information""" if self.rr_type() == "RRSIG": if out_format.lower() in ["utc", "utc str", "utc_str"]: return self[8] elif out_format.lower() in ["unix", "posix", "ctime"]: return calendar.timegm(time.strptime(self[8], "%Y%m%d%H%M%S")) elif out_format.lower() in ["relative"]: return calendar.timegm(time.strptime(self[8], "%Y%m%d%H%M%S")) - time.time() elif out_format.lower() in ["struct_time", "time.struct_time"]: return time.strptime(self[8], "%Y%m%d%H%M%S") else: raise Exception("unrecognized time format") else: return "" def ip(self): """ IP address form A/AAAA record""" if self.rr_type() in ["A", "AAAA"]: return self[4] else: raise Exception("ldnsx does not support ip for records other than A/AAAA") def alg(self): """Returns algorithm of RRSIG/DNSKEY/DS""" t = self.rr_type() if t == "RRSIG": return int(self[5]) elif t == "DNSKEY": return int(self[6]) elif t == "DS": return int(self[5]) else: return -1 def protocol(self): """ Returns protocol of the DNSKEY""" t = self.rr_type() if t == "DNSKEY": return int(self[5]) else: return -1 def flags(self): """Return RR flags for DNSKEY """ t = self.rr_type() if t == "DNSKEY": ret = [] n = int(self[4]) for m in range(1): if 2**(15-m) & n: if m == 7: ret.append("ZONE") elif m == 8: ret.append("REVOKE") elif m ==15: ret.append("SEP") else: ret.append(m) return ret else: return [] _rr_types={ "A" : ldns.LDNS_RR_TYPE_A, "A6" : ldns.LDNS_RR_TYPE_A6, "AAAA" : ldns.LDNS_RR_TYPE_AAAA, "AFSDB": ldns.LDNS_RR_TYPE_AFSDB, "ANY" : ldns.LDNS_RR_TYPE_ANY, "APL" : ldns.LDNS_RR_TYPE_APL, "ATMA" : ldns.LDNS_RR_TYPE_ATMA, "AXFR" : ldns.LDNS_RR_TYPE_AXFR, "CDNSKEY" : ldns.LDNS_RR_TYPE_CDNSKEY, "CDS" : ldns.LDNS_RR_TYPE_CDS, "CERT" : ldns.LDNS_RR_TYPE_CERT, "CNAME": ldns.LDNS_RR_TYPE_CNAME, "COUNT": ldns.LDNS_RR_TYPE_COUNT, "DHCID": ldns.LDNS_RR_TYPE_DHCID, "DLV" : ldns.LDNS_RR_TYPE_DLV, "DNAME": ldns.LDNS_RR_TYPE_DNAME, "DNSKEY": ldns.LDNS_RR_TYPE_DNSKEY, "DS" : ldns.LDNS_RR_TYPE_DS, "EID" : ldns.LDNS_RR_TYPE_EID, "FIRST": ldns.LDNS_RR_TYPE_FIRST, "GID" : ldns.LDNS_RR_TYPE_GID, "GPOS" : ldns.LDNS_RR_TYPE_GPOS, "HINFO": ldns.LDNS_RR_TYPE_HINFO, "IPSECKEY": ldns.LDNS_RR_TYPE_IPSECKEY, "ISDN" : ldns.LDNS_RR_TYPE_ISDN, "IXFR" : ldns.LDNS_RR_TYPE_IXFR, "KEY" : ldns.LDNS_RR_TYPE_KEY, "KX" : ldns.LDNS_RR_TYPE_KX, "LAST" : ldns.LDNS_RR_TYPE_LAST, "LOC" : ldns.LDNS_RR_TYPE_LOC, "MAILA": ldns.LDNS_RR_TYPE_MAILA, "MAILB": ldns.LDNS_RR_TYPE_MAILB, "MB" : ldns.LDNS_RR_TYPE_MB, "MD" : ldns.LDNS_RR_TYPE_MD, "MF" : ldns.LDNS_RR_TYPE_MF, "MG" : ldns.LDNS_RR_TYPE_MG, "MINFO": ldns.LDNS_RR_TYPE_MINFO, "MR" : ldns.LDNS_RR_TYPE_MR, "MX" : ldns.LDNS_RR_TYPE_MX, "NAPTR": ldns.LDNS_RR_TYPE_NAPTR, "NIMLOC": ldns.LDNS_RR_TYPE_NIMLOC, "NS" : ldns.LDNS_RR_TYPE_NS, "NSAP" : ldns.LDNS_RR_TYPE_NSAP, "NSAP_PTR" : ldns.LDNS_RR_TYPE_NSAP_PTR, "NSEC" : ldns.LDNS_RR_TYPE_NSEC, "NSEC3": ldns.LDNS_RR_TYPE_NSEC3, "NSEC3PARAM" : ldns.LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAMS" : ldns.LDNS_RR_TYPE_NSEC3PARAMS, "NULL" : ldns.LDNS_RR_TYPE_NULL, "NXT" : ldns.LDNS_RR_TYPE_NXT, "OPENPGPKEY" : ldns.LDNS_RR_TYPE_OPENPGPKEY, "OPT" : ldns.LDNS_RR_TYPE_OPT, "PTR" : ldns.LDNS_RR_TYPE_PTR, "PX" : ldns.LDNS_RR_TYPE_PX, "RP" : ldns.LDNS_RR_TYPE_RP, "RRSIG": ldns.LDNS_RR_TYPE_RRSIG, "RT" : ldns.LDNS_RR_TYPE_RT, "SIG" : ldns.LDNS_RR_TYPE_SIG, "SINK" : ldns.LDNS_RR_TYPE_SINK, "SOA" : ldns.LDNS_RR_TYPE_SOA, "SRV" : ldns.LDNS_RR_TYPE_SRV, "SSHFP": ldns.LDNS_RR_TYPE_SSHFP, "TLSA" : ldns.LDNS_RR_TYPE_TLSA, "TSIG" : ldns.LDNS_RR_TYPE_TSIG, "TXT" : ldns.LDNS_RR_TYPE_TXT, "UID" : ldns.LDNS_RR_TYPE_UID, "UINFO": ldns.LDNS_RR_TYPE_UINFO, "UNSPEC": ldns.LDNS_RR_TYPE_UNSPEC, "WKS" : ldns.LDNS_RR_TYPE_WKS, "X25" : ldns.LDNS_RR_TYPE_X25 } ldns-1.9.2/contrib/ldnsx/Makefile0000664000175000017500000000607015212267520016266 0ustar willemwillem# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ldnsx.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ldnsx.qhc" latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." ldns-1.9.2/contrib/python/0000775000175000017500000000000015212267520015014 5ustar willemwillemldns-1.9.2/contrib/python/examples/0000775000175000017500000000000015212267520016632 5ustar willemwillemldns-1.9.2/contrib/python/examples/ldns-buf.py0000775000175000017500000000014215212267520020716 0ustar willemwillem#!/usr/bin/python import ldns buf = ldns.ldns_buffer(1024) buf.printf("Test buffer") print buf ldns-1.9.2/contrib/python/examples/ldns-keygen.py0000775000175000017500000000176415212267520021437 0ustar willemwillem#!/usr/bin/python # # This example shows how to generate public/private key pair # import ldns algorithm = ldns.LDNS_SIGN_DSA bits = 512 ldns.ldns_init_random(open("/dev/urandom","rb"), (bits+7)//8) domain = ldns.ldns_dname("example.") #generate a new key key = ldns.ldns_key.new_frm_algorithm(algorithm, bits); print key #set owner key.set_pubkey_owner(domain) #create the public from the ldns_key pubkey = key.key_to_rr() #previous command is equivalent to # pubkey = ldns.ldns_key2rr(key) print pubkey #calculate and set the keytag key.set_keytag(ldns.ldns_calc_keytag(pubkey)) #build the DS record ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1) print ds owner, tag = pubkey.owner(), key.keytag() #write public key to .key file fw = open("key-%s-%d.key" % (owner,tag), "wb") pubkey.print_to_file(fw) #write private key to .priv file fw = open("key-%s-%d.private" % (owner,tag), "wb") key.print_to_file(fw) #write DS to .ds file fw = open("key-%s-%d.ds" % (owner,tag), "wb") ds.print_to_file(fw) ldns-1.9.2/contrib/python/examples/test_resolver.py0000775000175000017500000013031515212267520022112 0ustar willemwillem#!/usr/bin/env python # # ldns_resolver testing script. # # Do not use constructs that differ between Python 2 and 3. # Use write on stdout or stderr. # import ldns import sys import os import inspect class_name = "ldns_resolver" method_name = None error_detected = False temp_fname = "tmp_resolver.txt" def set_error(): """ Writes an error message and sets error flag. """ global class_name global method_name global error_detected error_detected = True sys.stderr.write("(line %d): malfunctioning method %s.\n" % \ (inspect.currentframe().f_back.f_lineno, method_name)) #if not error_detected: if True: method_name = class_name + ".axfr_complete()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".axfr_last_pkt()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".axfr_next()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".axfr_start()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".debug()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_debug(False) try: ret = resolver.debug() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_debug(True) try: ret = resolver.debug() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dec_nameserver_count()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") cnt = resolver.nameserver_count() try: resolver.dec_nameserver_count() except: set_error() if cnt != (resolver.nameserver_count() + 1): set_error() #if not error_detected: if True: method_name = class_name + ".defnames()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_defnames(False) try: ret = resolver.defnames() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_defnames(True) try: ret = resolver.defnames() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnsrch()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnsrch(False) try: ret = resolver.dnsrch() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_dnsrch(True) try: ret = resolver.dnsrch() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnssec()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(False) try: ret = resolver.dnssec() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_dnssec(True) try: ret = resolver.dnssec() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnssec_anchors()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") rrl = ldns.ldns_rr_list.new() try: ret = resolver.dnssec_anchors() if ret != None: set_error() except: set_error() resolver.set_dnssec_anchors(rrl) try: ret = resolver.dnssec_anchors() if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnssec_cd()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec_cd(False) try: ret = resolver.dnssec_cd() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_dnssec_cd(True) try: ret = resolver.dnssec_cd() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".domain()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_domain(None) try: ret = resolver.domain() if ret != None: set_error() except: set_error() dname = ldns.ldns_dname("example.com.") resolver.set_domain(dname) try: ret = resolver.domain() if not isinstance(ret, ldns.ldns_dname): set_error() if ret != dname: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".edns_udp_size()" try: resolver = ldns.ldns_resolver.new() if not isinstance(resolver, ldns.ldns_resolver): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".edns_udp_size()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_edns_udp_size(4096) try: ret = resolver.edns_udp_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 4096: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".fail()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_fail(False) try: ret = resolver.fail() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_fail(True) try: ret = resolver.fail() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".fallback()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_fallback(False) try: ret = resolver.fallback() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_fallback(True) try: ret = resolver.fallback() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_addr_by_name()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = resolver.get_addr_by_name(1, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.get_addr_by_name("www.google.com", "bad argument", ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".get_name_by_addr()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: addr = resolver.get_name_by_addr("8.8.8.8", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) if not isinstance(addr, ldns.ldns_rr_list): set_error() except: set_error() try: addr = resolver.get_name_by_addr(1, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: addr = resolver.get_name_by_addr("8.8.8.8", "bad argument", ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: addr = resolver.get_name_by_addr("8.8.8.8", ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".igntc()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_igntc(False) try: ret = resolver.igntc() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_igntc(True) try: ret = resolver.igntc() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".incr_nameserver_count()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") cnt = resolver.nameserver_count() try: resolver.incr_nameserver_count() except: set_error() if (cnt + 1) != resolver.nameserver_count(): set_error() #if not error_detected: if True: method_name = class_name + ".ip6()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_ip6(0) try: ret = resolver.ip6() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".nameserver_count()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_nameserver_count(1) try: ret = resolver.nameserver_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".nameserver_rtt()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") num = resolver.nameserver_count() for i in range(0, num): resolver.set_nameserver_rtt(i, i + 1) try: for i in range(0, num): ret = resolver.nameserver_rtt(i) if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if (i + 1) != ret: set_error() except: set_error() try: ret = resolver.nameserver_rtt("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".nameservers()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".nameservers_randomize()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.nameservers_randomize() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_file()" try: ret = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf", raiseException=True) if not isinstance(ret, ldns.ldns_resolver): set_error() except: set_error() try: ret = ldns.ldns_resolver.new_frm_file(1, raiseException=True) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_fp()" fi = open("/etc/resolv.conf") try: ret = ldns.ldns_resolver.new_frm_fp(fi, raiseException=True) if not isinstance(ret, ldns.ldns_resolver): set_error() except: set_error() fi.close() try: ret = ldns.ldns_resolver.new_frm_fp(1, raiseException=True) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_fp_l()" fi = open("/etc/resolv.conf") try: ret, line = ldns.ldns_resolver.new_frm_fp_l(fi, raiseException=True) if not isinstance(ret, ldns.ldns_resolver): set_error() if (not isinstance(line, int)) and (not isinstance(line, long)): set_error() except: set_error() fi.close() try: ret, line = ldns.ldns_resolver.new_frm_fp_l(1, raiseException=True) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".pop_nameserver()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") cnt = resolver.nameserver_count() try: for i in range(0, cnt): ret = resolver.pop_nameserver() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() try: ret = resolver.pop_nameserver() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".port()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_port(12345) try: ret = resolver.port() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 12345: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".prepare_query_pkt()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.prepare_query_pkt("example.com.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD, raiseException=True) if not isinstance(ret, ldns.ldns_pkt): set_error() except: set_error() try: ret = resolver.prepare_query_pkt(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD, raiseException=True) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.prepare_query_pkt("example.com.", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD, raiseException=True) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.prepare_query_pkt("example.com.", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD, raiseException=True) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.prepare_query_pkt("example.com.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument", raiseException=True) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_dnssec_anchor()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") key = ldns.ldns_key.new_frm_algorithm(ldns.LDNS_SIGN_DSA, 512) domain = ldns.ldns_dname("example.") key.set_pubkey_owner(domain) pubkey = key.key_to_rr() ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1) try: ret = resolver.push_dnssec_anchor(ds) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") try: ret = resolver.push_dnssec_anchor(rr) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = resolver.push_dnssec_anchor("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_nameserver()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") rdf = ldns.ldns_rdf.new_frm_str("127.0.0.1", ldns.LDNS_RDF_TYPE_A) try: ret = resolver.push_nameserver(rdf) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rdf = ldns.ldns_rdf.new_frm_str("::1", ldns.LDNS_RDF_TYPE_AAAA) try: ret = resolver.push_nameserver(rdf) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rdf = ldns.ldns_rdf.new_frm_str("example.com.", ldns.LDNS_RDF_TYPE_DNAME) try: ret = resolver.push_nameserver(rdf) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = resolver.push_nameserver("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_nameserver_rr()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") rr = ldns.ldns_rr.new_frm_str("test 600 IN A 127.0.0.1") try: ret = resolver.push_nameserver_rr(rr) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN AAAA ::1") try: ret = resolver.push_nameserver_rr(rr) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN NS 8.8.8.8") try: ret = resolver.push_nameserver_rr(rr) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = resolver.push_nameserver_rr("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_nameserver_rr_list()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 127.0.0.1") rrl.push_rr(rr) try: ret = resolver.push_nameserver_rr_list(rrl) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test 600 IN AAAA ::1") rrl.push_rr(rr) try: ret = resolver.push_nameserver_rr_list(rrl) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test 600 IN NS 8.8.8.8") rrl.push_rr(rr) try: ret = resolver.push_nameserver_rr_list(rrl) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = resolver.push_nameserver_rr_list("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_searchlist()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.push_searchlist("example.com.") try: resolver.push_searchlist("example.com.") except: set_error() try: resolver.push_searchlist(1) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".query()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) if not isinstance(ret, ldns.ldns_pkt): set_error() except: set_error() try: ret = resolver.query(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.query("www.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".random()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_random(False) try: ret = resolver.random() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_random(True) try: ret = resolver.random() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".recursive()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_recursive(False) try: ret = resolver.recursive() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_recursive(True) try: ret = resolver.recursive() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".retrans()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_retrans(127) try: ret = resolver.retrans() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 127: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".retry()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_retry(4) try: ret = resolver.retry() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 4: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rtt()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".search()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.search("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) if not isinstance(ret, ldns.ldns_pkt): set_error() except: set_error() try: ret = resolver.search(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.search("www.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.search("www.nic.cz", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.search("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".searchlist()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".searchlist_count()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.searchlist_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".send()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.send("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) if not isinstance(ret, ldns.ldns_pkt): set_error() except: set_error() try: ret = resolver.send(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.send("www.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.send("www.nic.cz", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.send("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".send_pkt()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: status, ret = resolver.send_pkt(pkt) if status != ldns.LDNS_STATUS_OK: ste_error() if not isinstance(ret, ldns.ldns_pkt): set_error() except: set_error() try: status, ret = resolver.send_pkt("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_debug()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_debug(False) ret = resolver.debug() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_debug(True) ret = resolver.debug() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_defnames()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_defnames(False) ret = resolver.defnames() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_defnames(True) ret = resolver.defnames() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_dnsrch()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_dnsrch(False) ret = resolver.dnsrch() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_dnsrch(True) ret = resolver.dnsrch() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_dnssec()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_dnssec(False) ret = resolver.dnssec() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_dnssec(True) ret = resolver.dnssec() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_dnssec_anchors()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") rrl = ldns.ldns_rr_list.new() try: resolver.set_dnssec_anchors(rrl) ret = resolver.dnssec_anchors() if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: resolver.set_dnssec_anchors("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_dnssec_cd()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_dnssec_cd(False) ret = resolver.dnssec_cd() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_dnssec_cd(True) ret = resolver.dnssec_cd() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_domain()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_domain(None) ret = resolver.domain() if ret != None: set_error() except: set_error() dname = ldns.ldns_dname("example.com.") try: resolver.set_domain(dname) ret = resolver.domain() if not isinstance(ret, ldns.ldns_dname): set_error() if ret != dname: set_error() except: set_error() rdf = ldns.ldns_rdf.new_frm_str("example.com.", ldns.LDNS_RDF_TYPE_DNAME) try: resolver.set_domain(rdf) ret = resolver.domain() if not isinstance(ret, ldns.ldns_rdf): set_error() if ret != dname: set_error() except: set_error() resolver.set_domain("example.com.") try: resolver.set_domain("example.com.") ret = resolver.domain() if not isinstance(ret, ldns.ldns_dname): set_error() if ret != dname: set_error() except: set_error() rdf = ldns.ldns_rdf.new_frm_str("127.0.0.1", ldns.LDNS_RDF_TYPE_A) try: resolver.set_domain(rdf) set_error() except Exception as e: pass except: set_error() try: resolver.set_domain(1) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_udp_size()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_edns_udp_size(4096) ret = resolver.edns_udp_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 4096: set_error() except: set_error() try: resolver.set_edns_udp_size("bad argument") set_error() except TypeError as e: pass except: ste_error() #if not error_detected: if True: method_name = class_name + ".set_fail()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_fail(False) ret = resolver.fail() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_fail(True) ret = resolver.fail() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_fallback()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_fallback(False) ret = resolver.fallback() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_fallback(True) ret = resolver.fallback() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_igntc()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_igntc(False) ret = resolver.igntc() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_igntc(True) ret = resolver.igntc() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_ip6()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_ip6(1) ret = resolver.ip6() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() try: resolver.set_ip6("bad argument") set_error() except TypeError as e: pass except: ste_error() #if not error_detected: if True: method_name = class_name + ".set_nameserver_count()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_nameserver_count(2) ret = resolver.nameserver_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 2: set_error() except: set_error() try: resolver.set_nameserver_count("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_nameserver_rtt()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") num = resolver.nameserver_count() try: for i in range(0, num): resolver.set_nameserver_rtt(i, i + 1) ret = resolver.nameserver_rtt(i) if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if (i + 1) != ret: set_error() except: set_error() try: ret = resolver.set_nameserver_rtt("bad argument", 0) set_error() except TypeError as e: pass except: set_error() try: ret = resolver.set_nameserver_rtt(0, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_nameservers()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".set_port()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_port(12345) ret = resolver.port() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 12345: set_error() except: set_error() try: resolver.set_port("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_random()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_random(False) ret = resolver.random() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_random(True) ret = resolver.random() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_recursive()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_recursive(False) ret = resolver.recursive() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_recursive(True) ret = resolver.recursive() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_retrans()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_retrans(127) ret = resolver.retrans() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 127: set_error() except: set_error() try: resolver.set_retrans("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_retry()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_retry(4) ret = resolver.retry() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 4: set_error() except: set_error() try: resolver.set_retry("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rtt()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".set_timeout()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".set_tsig_algorithm()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") tsigstr = "hmac-md5.sig-alg.reg.int." try: resolver.set_tsig_algorithm(tsigstr) ret = resolver.tsig_algorithm() if not isinstance(ret, str): set_error() if ret != tsigstr: set_error() except: set_error() try: resolver.set_tsig_algorithm(1) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_tsig_keydata()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") tkdstr = "Humpty Dumpty sat on a wall, Humpty Dumpty had a great fall, All the King's horses and all the King's men, Couldn't put Humpty together again." try: resolver.set_tsig_keydata(tkdstr) ret = resolver.tsig_keydata() if not isinstance(ret, str): set_error() if ret != tkdstr: set_error() except: set_error() try: resolver.set_tsig_keydata(1) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_tsig_keyname()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") tknstr = "key 1" try: resolver.set_tsig_keyname(tknstr) ret = resolver.tsig_keyname() if not isinstance(ret, str): set_error() if ret != tknstr: set_error() except: set_error() try: resolver.set_tsig_keyname(1) set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_usevc()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: resolver.set_usevc(False) ret = resolver.usevc() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: resolver.set_usevc(True) ret = resolver.usevc() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".timeout()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".trusted_key()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") key = ldns.ldns_key.new_frm_algorithm(ldns.LDNS_SIGN_DSA, 512) domain = ldns.ldns_dname("example.") key.set_pubkey_owner(domain) pubkey = key.key_to_rr() ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1) resolver.push_dnssec_anchor(ds) rrl = ldns.ldns_rr_list.new() try: ret = resolver.trusted_key(rrl) if ret != None: set_error() except: set_error() rrl.push_rr(ds) ret = resolver.trusted_key(rrl) try: ret = resolver.trusted_key(rrl) if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 1: set_error() except: set_error() try: ret = resolver.trusted_key("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".tsig_algorithm()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.tsig_algorithm() if ret != None: set_error() except: set_error() tsigstr = "hmac-md5.sig-alg.reg.int." resolver.set_tsig_algorithm(tsigstr) try: ret = resolver.tsig_algorithm() if not isinstance(ret, str): set_error() if ret != tsigstr: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".tsig_keydata()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.tsig_keydata() if ret != None: set_error() except: set_error() tkdstr = "Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe." resolver.set_tsig_keydata(tkdstr) try: ret = resolver.tsig_keydata() if not isinstance(ret, str): set_error() if ret != tkdstr: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".tsig_keyname()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = resolver.tsig_keyname() if ret != None: set_error() except: set_error() tknstr = "key 2" resolver.set_tsig_keyname(tknstr) try: ret = resolver.tsig_keyname() if not isinstance(ret, str): set_error() if ret != tknstr: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".usevc()" resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_usevc(False) try: ret = resolver.usevc() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver.set_usevc(True) try: ret = resolver.usevc() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() if not error_detected: sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__))) else: sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__))) sys.exit(1) ldns-1.9.2/contrib/python/examples/zone.txt0000664000175000017500000000104115212267520020342 0ustar willemwillem$ORIGIN example. $TTL 600 example. IN SOA example. admin.example. ( 2008022501 ; serial 28800 ; refresh (8 hours) 7200 ; retry (2 hours) 604800 ; expire (1 week) 18000 ; minimum (5 hours) ) @ IN MX 10 mail.example. @ IN NS ns1 @ IN NS ns2 @ IN A 192.168.1.1 ldns-1.9.2/contrib/python/examples/test_buffer.py0000775000175000017500000004015315212267520021522 0ustar willemwillem#!/usr/bin/env python # # ldns_buffer testing script. # # Do not use constructs that differ between Python 2 and 3. # Use write on stdout or stderr. # import ldns import sys import os import inspect class_name = "ldns_buffer" method_name = None error_detected = False def set_error(): """ Writes an error message and sets error flag. """ global class_name global method_name global error_detected error_detected = True sys.stderr.write("(line %d): malfunctioning method %s.\n" % \ (inspect.currentframe().f_back.f_lineno, method_name)) # Buffer creation. capacity = 1024 #if not error_detected: if True: method_name = "ldns_buffer.__init__()" try: buf = ldns.ldns_buffer(1024) except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.__str__()" buf.printf("abcedf") try: string = buf.__str__() except: set_error() if not isinstance(string, str): # Should be string. set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.at()" try: ret = buf.at(512) except: set_error() try: # Must raise TypeError. ret = buf.at("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.available()" try: ret = buf.available(capacity) except: set_error() if not isinstance(ret, bool): # Should be bool. set_error() if not buf.available(capacity): # Should return True. set_error() if buf.available(capacity + 1): # Should return False. set_error() try: # Must raise TypeError. ret = buf.available("") set_error() except TypeError: pass except: set_error() # try: # # Must raise ValueError. # ret = buf.available("") # set_error() # except ValueError: # pass # except: # set_error() #if not error_detected: if True: method_name = "ldns_buffer.available_at()" try: ret = buf.available_at(512, capacity - 512) except: set_error() if not isinstance(ret, bool): # Should be bool. set_error() if not buf.available_at(512, capacity - 512): # Should return True. set_error() if buf.available_at(512, capacity - 512 + 1): # Should return False. set_error() try: # Must raise TypeError. ret = buf.available_at("", 1) set_error() except TypeError: pass except: set_error() try: # Must raise TypeError. ret = buf.available_at(1, "") set_error() except TypeError: pass except: set_error() # try: # # Must raise ValueError. # ret = buf.available_at(-1, 512) # set_error() # except ValueError: # pass # except: # set_error() # try: # # Must raise ValueError. # ret = buf.available_at(512, -1) # set_error() # except ValueError: # pass # except: # set_error() #if not error_detected: if True: method_name = "ldns_buffer.begin()" try: ret = buf.begin() except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.capacity()" try: ret = buf.capacity() except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): # Should be int. set_error() #if not error_detected: if True: method_name = "ldns_buffer.clear()" try: buf.clear() except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.copy()" sys.stderr.write("%s not tested.\n" % (method_name)) # buf2 = ldns.ldns_buffer(10) # buf2.printf("abcdef") # try: # buf.copy(buf2) # print buf.capacity() # print buf2.capacity() # except: # set_error() # buf.printf("2") # print buf #if not error_detected: if True: method_name = "ldns_buffer.current()" try: ret = buf.current() except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.end()" try: ret = buf.end() except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.export()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_buffer.flip()" buf.printf("abcdef") try: buf.flip() except: set_error() # if buf.remaining() != capacity: # # Should be at beginning. # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.getc()" buf.printf("a") buf.rewind() try: ret = buf.getc() except: set_error() if ret != ord("a"): set_error() # Test return value for -1 buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.invariant()" try: buf.invariant() except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.limit()" try: ret = buf.limit() except: set_error() if ret != capacity: set_error() #if not error_detected: if True: method_name = "ldns_buffer.position()" try: ret = buf.position() except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() #if not error_detected: if True: method_name = "ldns_buffer.printf()" try: ret = buf.printf("abcdef") except: set_error() if not isinstance(ret, int): set_error() try: ret = buf.printf(10) set_error() except TypeError: pass except: set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.read()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_buffer.read_at()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_buffer.read_u16()" buf.printf("aac") buf.rewind() try: ret = buf.read_u16() except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != (ord("a") * 0x0101): set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.read_u16_at()" buf.printf("abbc") try: ret = buf.read_u16_at(1) except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != (ord("b") * 0x0101): set_error() try: ret = buf.read_u16_at("") set_error() except TypeError: pass except: set_error() # try: # ret = buf.read_u16_at(-1) # set_error() # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.read_u32()" buf.printf("aaaac") buf.rewind() try: ret = buf.read_u32() except: set_error() if not isinstance(ret, int): set_error() if ret != (ord("a") * 0x01010101): set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.read_u32_at()" buf.printf("abbbbc") try: ret = buf.read_u32_at(1) except: set_error() if not isinstance(ret, int): set_error() if ret != (ord("b") * 0x01010101): set_error() try: ret = buf.read_u32_at("") set_error() except TypeError: pass except: set_error() # try: # ret = buf.read_u32_at(-1) # set_error() # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.read_u8()" buf.printf("ac") buf.rewind() try: ret = buf.read_u8() except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != ord("a"): set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.read_u8_at()" buf.printf("abc") try: ret = buf.read_u8_at(1) except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != ord("b"): set_error() try: ret = buf.read_u8_at("") set_error() except TypeError: pass except: set_error() # try: # ret = buf.read_u8_at(-1) # set_error() # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.remaining()" buf.printf("abcdef") try: ret = buf.remaining() except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != (capacity - 6): set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.remaining_at()" buf.printf("abcdef") try: ret = buf.remaining_at(1) except: set_error() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != (capacity - 1): set_error() try: ret = buf.remaining_at("") set_error() except TypeError: pass except: set_error() # try: # ret = buf.remaining_at(-1) # set_error() # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.reserve()" buf2 = ldns.ldns_buffer(512) try: ret = buf2.reserve(1024) except: set_error() if not isinstance(ret, bool): set_error() try: ret = buf2.reserve("") set_error() except TypeError: pass except: set_error() # try: # ret = buf2.reserve(-1) # set_error() # except ValueError: # pass # except: # set_error() #if not error_detected: if True: method_name = "ldns_buffer.rewind()" buf.printf("abcdef") try: buf.rewind() except: set_error() if buf.position() != 0: set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.set_capacity()" try: ret = buf.set_capacity(capacity) except: set_error() if not isinstance(ret, bool): set_error() try: ret = buf.set_capacity("") set_error() except TypeError: pass except: set_error() # try: # ret = buf.set_capacity(-1) # set_error() # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.set_limit()" try: buf.set_limit(0) except: set_error() try: buf.set_limit("") set_error() except TypeError: pass except: set_error() # try: # buf.set_limit(-1) # set_error() # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.set_position()" try: buf.set_position(0) except: set_error() try: buf.set_position("") except TypeError: pass except: set_error() # try: # buf.set_position(-1) # except ValueError: # pass # except: # set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.skip()" try: buf.skip(10) except: set_error() try: buf.skip(-1) except: set_error() try: buf.skip("") set_error() except TypeError: pass except: set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.status()" try: ret = buf.status() except: set_error() # Returned status is an integer. if not isinstance(ret, int): set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.status_ok()" try: ret = buf.status_ok() except: set_error() if not isinstance(ret, bool): set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.write()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_buffer.write_at()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_buffer.write_string()" try: buf.write_string("abcdef") except: set_error() # try: # buf.write_sring(-1) # set_error() # except TypeError: # pass # except: # set_error() sys.stderr.write("%s not tested for parameter correctness.\n" % \ (method_name)) buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.write_string_at()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_buffer.write_u16()" try: buf.write_u16(ord("b") * 0x0101) except: set_error() try: buf.write_u16("") set_error() except TypeError: pass except: set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.write_u16_at()" buf.printf("a") try: buf.write_u16_at(1, ord("b") * 0x0101) except: set_error() try: buf.write_u16_at("", ord("b") * 0x0101) set_error() except TypeError: pass except: set_error() # try: # buf.write_u16_at(-1, ord("b") * 0x0101) # set_error() # except ValueError: # pass # except: # set_error() try: buf.write_u16_at(1, "") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.write_u32()" try: buf.write_u32(ord("b") * 0x01010101) except: set_error() try: buf.write_u32("") set_error() except TypeError: pass except: set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.write_u32_at()" buf.printf("a") try: buf.write_u32_at(1, ord("b") * 0x01010101) except: set_error() try: buf.write_u32_at("", ord("b") * 0x01010101) set_error() except TypeError: pass except: set_error() # try: # buf.write_u32_at(-1, ord("b") * 0x01010101) # set_error() # except ValueError: # pass # except: # set_error() try: buf.write_u32_at(1, "") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_buffer.write_u8()" try: buf.write_u8(ord("b")) except: set_error() try: buf.write_u8("") set_error() except TypeError: pass except: set_error() buf.clear() #if not error_detected: if True: method_name = "ldns_buffer.write_u8_at()" buf.printf("a") try: buf.write_u8_at(1, ord("b")) except: set_error() try: buf.write_u8_at("", ord("b")) set_error() except TypeError: pass except: set_error() # try: # buf.write_u8_at(-1, ord("b")) # set_error() # except ValueError: # pass # except: # set_error() try: buf.write_u8_at(1, "") set_error() except TypeError: pass except: set_error() if not error_detected: sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__))) else: sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__))) sys.exit(1) ldns-1.9.2/contrib/python/examples/python3/0000775000175000017500000000000015212267520020236 5ustar willemwillemldns-1.9.2/contrib/python/examples/python3/ldns-signzone.py0000775000175000017500000000312315212267520023404 0ustar willemwillem#!/usr/bin/python # This example shows how to sign a given zone file with private key import ldns import sys, os, time #private key TAG which identifies the private key #use ldns-keygen.py in order to obtain private key keytag = 30761 # Read zone file #------------------------------------------------------------- zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) soa = zone.soa() origin = soa.owner() # Prepare keys #------------------------------------------------------------- #Read private key from file keyfile = open("key-%s-%d.private" % (origin, keytag), "r"); key = ldns.ldns_key.new_frm_fp(keyfile) #Read public key from file pubfname = "key-%s-%d.key" % (origin, keytag) pubkey = None if os.path.isfile(pubfname): pubkeyfile = open(pubfname, "r"); pubkey,_,_,_ = ldns.ldns_rr.new_frm_fp(pubkeyfile) if not pubkey: #Create new public key pubkey = key.key_to_rr() #Set key expiration key.set_expiration(int(time.time()) + 365*60*60*24) #365 days #Set key owner (important step) key.set_pubkey_owner(origin) #Insert DNSKEY RR zone.push_rr(pubkey) # Sign zone #------------------------------------------------------------- #Create keylist and push private key keys = ldns.ldns_key_list() keys.push_key(key) #Add SOA signed_zone = ldns.ldns_dnssec_zone() signed_zone.add_rr(soa) #Add RRs for rr in zone.rrs().rrs(): print("RR:", str(rr), end=" ") signed_zone.add_rr(rr) added_rrs = ldns.ldns_rr_list() status = signed_zone.sign(added_rrs, keys) if (status == ldns.LDNS_STATUS_OK): signed_zone.print_to_file(open("zone_signed.txt","w")) ldns-1.9.2/contrib/python/examples/python3/ldns-higher.py0000775000175000017500000000175315212267520023025 0ustar willemwillem#!/usr/bin/python import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") dnn = ldns.ldns_dname("www.google.com") print(dnn.get_type_str(), dnn) dna = ldns.ldns_rdf.new_frm_str("74.125.43.99",ldns.LDNS_RDF_TYPE_A) print(dna.get_type_str(), dna) name = resolver.get_name_by_addr(dna) if (not name): raise Exception("Can't retrieve server name") for rr in name.rrs(): print(rr) name = resolver.get_name_by_addr("74.125.43.99") if (not name): raise Exception("Can't retrieve server name") for rr in name.rrs(): print(rr) addr = resolver.get_addr_by_name(dnn) if (not addr): raise Exception("Can't retrieve server address") for rr in addr.rrs(): print(rr) addr = resolver.get_addr_by_name("www.google.com") if (not addr): raise Exception("Can't retrieve server address") for rr in addr.rrs(): print(rr) hosts = ldns.ldns_rr_list.new_frm_file("/etc/hosts") if (not hosts): raise Exception("Can't retrieve the content of file") for rr in hosts.rrs(): print(rr) ldns-1.9.2/contrib/python/examples/python3/ldns_rr_iter_frm_fp_l.demo.py0000664000175000017500000000031715212267520026066 0ustar willemwillemimport ldns import sys if len(sys.argv) <= 1: print("Usage: %s zone_file" % sys.argv[0]) sys.exit() inp = open(sys.argv[1],"r"); for rr in ldns.ldns_rr_iter_frm_fp_l(inp): print(rr) inp.close() ldns-1.9.2/contrib/python/examples/python3/ldns-dnssec.py0000775000175000017500000000215715212267520023035 0ustar willemwillem#!/usr/bin/python # -*- coding: utf-8 -*- import ldns import sys debug = True # Check args argc = len(sys.argv) name = "www.nic.cz" if argc < 2: print("Usage:", sys.argv[0], "domain [resolver_addr]") sys.exit(1) else: name = sys.argv[1] # Create resolver resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) # Custom resolver if argc > 2: # Clear previous nameservers ns = resolver.pop_nameserver() while ns != None: ns = resolver.pop_nameserver() ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) resolver.push_nameserver(ip) # Resolve DNS name pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) if pkt and pkt.answer(): # Debug if debug: print("NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() )) # SERVFAIL indicated bogus name if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL: print(name, "is bogus") # Check AD (Authenticated) bit if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR: if pkt.ad(): print(name, "is secure") else: print(name, "is insecure") ldns-1.9.2/contrib/python/examples/python3/ldns-buf.py0000775000175000017500000000014315212267520022323 0ustar willemwillem#!/usr/bin/python import ldns buf = ldns.ldns_buffer(1024) buf.printf("Test buffer") print(buf) ldns-1.9.2/contrib/python/examples/python3/ldns-zone.py0000775000175000017500000000041215212267520022521 0ustar willemwillem#!/usr/bin/python import ldns #Read zone from file zone = ldns.ldns_zone.new_frm_fp(open("../zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) print(zone) print("SOA:", zone.soa()) for r in zone.rrs().rrs(): print("RR:", r) zone = ldns.ldns_zone() #print zone ldns-1.9.2/contrib/python/examples/python3/ldns_rr_new_frm_fp_l.demo.py0000664000175000017500000000231015212267520025707 0ustar willemwillemimport ldns import sys if len(sys.argv) <= 1: print("Usage: %s zone_file" % sys.argv[0]) sys.exit() inp = open(sys.argv[1],"r"); # variables that preserve the parsers state my_ttl = 3600; my_origin = None my_prev = None # additional state variables last_pos = 0 line_nr = 0 while True: ret = ldns.ldns_rr_new_frm_fp_l_(inp, my_ttl, my_origin, my_prev) s, rr, line_inc, new_ttl, new_origin, new_prev = ret # unpack the result line_nr += line_inc # increase number of parsed lines my_prev = new_prev # update ref to previous owner if s == ldns.LDNS_STATUS_SYNTAX_TTL: my_ttl = new_ttl # update default TTL print("$TTL:", my_ttl) elif s == ldns.LDNS_STATUS_SYNTAX_ORIGIN: my_origin = new_origin # update reference to origin print("$ORIGIN:", my_origin) elif s == ldns.LDNS_STATUS_SYNTAX_EMPTY: if last_pos == inp.tell(): break # no advance since last read - EOF last_pos = inp.tell() elif s != ldns.LDNS_STATUS_OK: print("! parse error in line", line_nr) else: # we are sure to have LDNS_STATUS_OK print(rr) inp.close() print("--------------------") print("Read %d lines" % line_nr) ldns-1.9.2/contrib/python/examples/python3/ldns-mx.py0000775000175000017500000000060415212267520022175 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) if (pkt): mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) if (mx): mx.sort() print(mx) ldns-1.9.2/contrib/python/examples/python3/ldns-axfr.py0000775000175000017500000000332415212267520022513 0ustar willemwillem#!/usr/bin/python # vim:fileencoding=utf-8 # # AXFR client with IDN (Internationalized Domain Names) support # import ldns import encodings.idna def utf2name(name): return '.'.join([encodings.idna.ToASCII(a).decode("utf-8") for a in name.split('.')]) def name2utf(name): return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')]) resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") #addr = ldns.ldns_get_rr_list_addr_by_name(resolver, "zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); addr = resolver.get_addr_by_name("zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); if (not addr): raise Exception("Can't retrieve server address") print("Addr_by_name:",str(addr).replace("\n","; ")) #remove all nameservers while resolver.pop_nameserver(): pass #insert server addr for rr in addr.rrs(): resolver.push_nameserver_rr(rr) #AXFR transfer status = resolver.axfr_start(utf2name("háčkyčárky.cz"), ldns.LDNS_RR_CLASS_IN) if status != ldns.LDNS_STATUS_OK: raise Exception("Can't start AXFR. Error: %s" % ldns.ldns_get_errorstr_by_id(status)) #Print results while True: rr = resolver.axfr_next() if not rr: break rdf = rr.owner() if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): print("RDF owner: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))) else: print("RDF owner: type=",rdf.get_type_str(),"data=",str(rdf)) print(" RR type=", rr.get_type_str()," ttl=",rr.ttl()) for rdf in rr.rdfs(): if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): print(" RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))) else: print(" RDF: type=",rdf.get_type_str(),"data=",str(rdf)) print() ldns-1.9.2/contrib/python/examples/python3/ldns-mx1.py0000775000175000017500000000066115212267520022261 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns dname = ldns.ldns_dname("nic.cz") print(dname) resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) if (pkt): mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) if (mx): mx.sort() print(mx) ldns-1.9.2/contrib/python/examples/python3/ldns-mx2.py0000775000175000017500000000106215212267520022256 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) if (pkt) and (pkt.answer()): for rr in pkt.answer().rrs(): if (rr.get_type() != ldns.LDNS_RR_TYPE_MX): continue rdf = rr.owner() print(rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ", end=" ") print(" ".join(str(rdf) for rdf in rr.rdfs())) ldns-1.9.2/contrib/python/examples/python3/ldns-newpkt.py0000775000175000017500000000073415212267520023065 0ustar willemwillem#!/usr/bin/python import ldns pkt = ldns.ldns_pkt.new_query_frm_str("www.google.com",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) rra = ldns.ldns_rr.new_frm_str("www.google.com. IN A 192.168.1.1",300) rrb = ldns.ldns_rr.new_frm_str("www.google.com. IN TXT Some\ Description",300) list = ldns.ldns_rr_list() if (rra): list.push_rr(rra) if (rrb): list.push_rr(rrb) pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, list) print("Packet:") print(pkt) ldns-1.9.2/contrib/python/examples/python3/ldns-keygen.py0000775000175000017500000000176615212267520023045 0ustar willemwillem#!/usr/bin/python # # This example shows how to generate public/private key pair # import ldns algorithm = ldns.LDNS_SIGN_DSA bits = 512 ldns.ldns_init_random(open("/dev/random","rb"), (bits+7)//8) domain = ldns.ldns_dname("example.") #generate a new key key = ldns.ldns_key.new_frm_algorithm(algorithm, bits); print(key) #set owner key.set_pubkey_owner(domain) #create the public from the ldns_key pubkey = key.key_to_rr() #previous command is equivalent to # pubkey = ldns.ldns_key2rr(key) print(pubkey) #calculate and set the keytag key.set_keytag(ldns.ldns_calc_keytag(pubkey)) #build the DS record ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1) print(ds) owner, tag = pubkey.owner(), key.keytag() #write public key to .key file fw = open("key-%s-%d.key" % (owner,tag), "wb") pubkey.print_to_file(fw) #write private key to .priv file fw = open("key-%s-%d.private" % (owner,tag), "wb") key.print_to_file(fw) #write DS to .ds file fw = open("key-%s-%d.ds" % (owner,tag), "wb") ds.print_to_file(fw) ldns-1.9.2/contrib/python/examples/test_dname.py0000775000175000017500000002560315212267520021340 0ustar willemwillem#!/usr/bin/env python # # ldns_dname testing script. # # Do not use constructs that differ between Python 2 and 3. # Use write on stdout or stderr. # import ldns import sys import os import inspect class_name = "ldns_dname" method_name = None error_detected = False temp_fname = "tmp_dname.txt" def set_error(): """ Writes an error message and sets error flag. """ global class_name global method_name global error_detected error_detected = True sys.stderr.write("(line %d): malfunctioning method %s.\n" % \ (inspect.currentframe().f_back.f_lineno, method_name)) #if not error_detected: if True: method_name = class_name + ".__init__()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test.nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "217.31.205.50") try: dname = ldns.ldns_dname("www.nic.cz.") if not isinstance(dname, ldns.ldns_dname): set_error() except: set_error() # # Error when printing a dname which was created from an empty string. # Must find out why. # try: dname = ldns.ldns_dname(rdf1) if not isinstance(dname, ldns.ldns_dname): set_error() except: set_error() # Test whether rdf1 and dname independent. dname.cat(dname) if dname.__str__() == rdf1.__str__(): set_error() # Test whether rdf1 and dname are dependent. dname = ldns.ldns_dname(rdf1, clone=False) dname.cat(dname) if dname.__str__() != rdf1.__str__(): set_error() # Test whether constructs from non-dname rdfs. try: dname = ldns.ldns_dname(rdf2) set_error() except TypeError: pass except: set_error() try: dname = ldns.ldns_dname(1) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".[comparison operators]" dn1 = ldns.ldns_dname("a.test") dn2 = ldns.ldns_dname("b.test") try: ret = dn1 < dn2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = dn2 < dn1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = dn1 <= dn2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = dn2 <= dn1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = dn1 == dn2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = dn1 == dn1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = dn1 != dn2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = dn1 != dn1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = dn1 > dn2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = dn2 > dn1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = dn1 >= dn2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = dn2 >= dn1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".absolute()" dname = ldns.ldns_dname("www.nic.cz.") try: ret = dname.absolute() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".cat()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test.nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "217.31.205.50") dname = ldns.ldns_dname("www.nic.cz.") try: ret = dname.cat(dname) if ret != ldns.LDNS_STATUS_OK: set_error() if dname.__str__() != "www.nic.cz.www.nic.cz.": set_error() except: set_error() try: ret = dname.cat(rdf1) if ret != ldns.LDNS_STATUS_OK: set_error() if dname.__str__() != "www.nic.cz.www.nic.cz.test.nic.cz.": set_error() except: set_error() try: ret = dname.cat(rdf2) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = dname.cat("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".cat_clone()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test.nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "217.31.205.50") dname = ldns.ldns_dname("www.nic.cz.") try: ret = dname.cat_clone(dname) if not isinstance(ret, ldns.ldns_dname): set_error() if ret.__str__() != "www.nic.cz.www.nic.cz.": set_error() except: set_error() try: ret = dname.cat_clone(rdf1) if not isinstance(ret, ldns.ldns_dname): set_error() if ret.__str__() != "www.nic.cz.test.nic.cz.": set_error() except: set_error() try: ret = dname.cat_clone(rdf2) if ret != None: set_error() except: set_error() try: ret = dname.cat_clone("") except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".interval()" dn1 = ldns.ldns_dname("a.ns.nic.cz.") dn2 = ldns.ldns_dname("b.ns.nic.cz.") dn3 = ldns.ldns_dname("c.ns.nic.cz.") try: ret = dn1.interval(dn2, dn3) if ret != -1: set_error() except: set_error() try: ret = dn2.interval(dn1, dn3) if ret != 1: set_error() except: set_error() rdf4 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "d.ns.nic.cz.") rdf5 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "194.0.12.1") try: ret = dn1.interval(dn2, rdf4) if ret != -1: set_error() except: set_error() try: ret = dn2.interval(dn1, rdf4) if ret != 1: set_error() except: set_error() try: ret = dn1.interval(dn2, rdf5) set_error() except Exception: pass except: set_error() try: ret = dn1.interval(dn2, "") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".is_subdomain()" dn1 = ldns.ldns_dname("nic.cz.") dn2 = ldns.ldns_dname("www.nic.cz.") rdf3 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = dn1.is_subdomain(dn2) if not isinstance(ret, bool): set_error() if ret == True: set_error() ret = dn2.is_subdomain(dn1) if ret != True: set_error() except: set_error() try: ret = dn1.is_subdomain(rdf3) if not isinstance(ret, bool): set_error() if ret == True: set_error() except: set_error() rdf4 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "194.0.12.1") try: ret = dn1.is_subdomain(rdf4) if ret != False: set_error() except: set_error() try: ret = dn1.is_subdomain("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".label()" dn = ldns.ldns_dname("nic.cz.") try: ret = dn.label(0) if not isinstance(ret, ldns.ldns_dname): set_error() except: set_error() try: ret = dn.label(10) if ret != None: set_error() except: set_error() try: ret = dn.label("") except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".label_count()" dn = ldns.ldns_dname("www.nic.cz.") try: ret = dn.label_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 3: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".left_chop()" dn = ldns.ldns_dname("www.nic.cz.") try: ret = dn.left_chop() if not isinstance(ret, ldns.ldns_dname): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".make_canonical()" dn = ldns.ldns_dname("WWW.NIC.CZ.") try: dn.make_canonical() if dn.__str__() != "www.nic.cz.": set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_rdf()" # Tested via constructor call. #if not error_detected: if True: method_name = class_name + ".new_frm_str()" # Tested via constructor call. #if not error_detected: if True: method_name = class_name + ".reverse()" dn = ldns.ldns_dname("www.nic.cz.") try: ret = dn.reverse() if not isinstance(ret, ldns.ldns_dname): set_error() if ret.__str__() != "cz.nic.www.": set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".write_to_buffer()" dn = ldns.ldns_dname("www.nic.cz.") buf = ldns.ldns_buffer(1024) try: ret = dn.write_to_buffer(buf) if ret != ldns.LDNS_STATUS_OK: set_error() if buf.position() != 12: set_error() except: set_error() try: ret = dn.write_to_buffer("") except TypeError: pass except: set_error() if not error_detected: sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__))) else: sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__))) sys.exit(1) ldns-1.9.2/contrib/python/examples/test_rr.py0000775000175000017500000017524015212267520020702 0ustar willemwillem#!/usr/bin/env python # # ldns_rr and ldns_rr_list testing script. # # Do not use constructs that differ between Python 2 and 3. # Use write on stdout or stderr. # import ldns import sys import os import inspect class_name = "ldns_rr" method_name = None error_detected = False temp_fname = "tmp_rr.txt" def set_error(): """ Writes an error message and sets error flag. """ global class_name global method_name global error_detected error_detected = True sys.stderr.write("(line %d): malfunctioning method %s.\n" % \ (inspect.currentframe().f_back.f_lineno, method_name)) #if not error_detected: if True: method_name = class_name + ".[comparison operators]" rr1 = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rr2 = ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1") try: ret = rr1 < rr2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr2 < rr1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rr1 <= rr2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr2 <= rr1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rr1 == rr2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rr1 == rr1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr1 != rr2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr1 != rr1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rr1 > rr2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rr2 > rr1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr1 >= rr2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rr2 >= rr1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + "__init__()" try: rr = ldns.ldns_rr() set_error() except Exception: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".a_address()" rr = ldns.ldns_rr.new_frm_str("www.nic.cz 600 IN A 217.31.205.50") try: address = rr.a_address() if not isinstance(address, ldns.ldns_rdf): set_error() if address == None: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("www.nic.cz 600 IN AAAA 2002:d91f:cd32::1") try: address = rr.a_address() if not isinstance(address, ldns.ldns_rdf): set_error() if address == None: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("www.nic.cz 600 IN TXT text") try: address = rr.a_address() if isinstance(address, ldns.ldns_rdf): set_error() if address != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".a_set_address()" rdf = ldns.ldns_rdf.new_frm_str("127.0.0.1", ldns.LDNS_RDF_TYPE_A) rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.a_set_address(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() rdf = ldns.ldns_rdf.new_frm_str("::1", ldns.LDNS_RDF_TYPE_AAAA) rr = ldns.ldns_rr.new_frm_str("test 600 IN AAAA ::") try: ret = rr.a_set_address(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr.a_set_address("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".class_by_name()" try: ret = ldns.ldns_rr.class_by_name("IN") if not isinstance(ret, int): set_error() if ret != ldns.LDNS_RR_CLASS_IN: set_error() except: set_error() method_name = class_name + ".class_by_name()" try: ret = ldns.ldns_rr.class_by_name("AA") if not isinstance(ret, int): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".clone()" rr = ldns.ldns_rr.new_frm_str("test 600 IN TXT text") try: ret = rr.clone() if not isinstance(ret, ldns.ldns_rr): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".compare_ds()" pubkey1 = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") pubkey2 = ldns.ldns_rr.new_frm_str("example2. 3600 IN DNSKEY 256 3 3 ALBoD2+1xYpzrE7gjU5EwwBHG2HNiD1977LDZGh+8VNifMGjixMpgUN6xRhFjvRSsC/seMVXmUGq+msUDF2pHnUHbW/dbQbBxVMAqx2jT0LTvAx5wUPGltHHsa92K8VdzD8ynTFwPvjmk7g3hqRRzt4UTQIeK7DYgrOOgvDv+DYWVQctLwYP0ktm85b4cMtIUNRIf/N+K25pfK6BM/tHN8HOm4ECvm2U9zqHHfnxJFdiNK2PydkNeJZZGUOubSFVvaOMhZoEeAgkm3q5QcwXHsLAhacZ ;{id = 30944 (zsk), size = 512b}") ds1 = ldns.ldns_key_rr2ds(pubkey1, ldns.LDNS_SHA1) ds2 = ldns.ldns_key_rr2ds(pubkey2, ldns.LDNS_SHA1) try: ret = pubkey1.compare_ds(pubkey1) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pubkey1.compare_ds(pubkey2) if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = pubkey1.compare_ds(ds1) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pubkey1.compare_ds(ds2) if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: pubkey1.compare_ds("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".compare_no_rdata()" rr1 = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") rr2 = ldns.ldns_rr.new_frm_str("test 600 IN AAAA ::") try: ret = rr1.compare_no_rdata(rr2) if not isinstance(ret, int): set_error() if ret != -27: set_error() except: set_error() try: rr1.compare_no_rdata("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_algorithm()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") try: ret = pubkey.dnskey_algorithm() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.dnskey_algorithm() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_flags()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") try: ret = pubkey.dnskey_flags() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.dnskey_flags() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_errror() #if not error_detected: if True: method_name = class_name + ".dnskey_key()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") try: ret = pubkey.dnskey_key() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.dnskey_key() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_errror() #if not error_detected: if True: method_name = class_name + ".dnskey_key_size()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") try: ret = pubkey.dnskey_key_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 512: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.dnskey_key_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_key_size_raw()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".dnskey_protocol()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") try: ret = pubkey.dnskey_protocol() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.dnskey_protocol() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_set_algorithm()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") rdf = ldns.ldns_rdf.new_frm_str("3", ldns.LDNS_RDF_TYPE_ALG) try: ret = pubkey.dnskey_set_algorithm(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = pubkey.dnskey_set_algorithm(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = pubkey.dnskey_set_algorithm("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_set_flags()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") rdf = ldns.ldns_rdf.new_frm_str("256", ldns.LDNS_RDF_TYPE_INT16) try: ret = pubkey.dnskey_set_flags(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = pubkey.dnskey_set_flags(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = pubkey.dnskey_set_flags("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_set_key()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") rdf = ldns.ldns_rdf.new_frm_str("AMLdYflByPu1GEPCnu9qPTqbnC8n5mftFmFVTFQI10aefiDqp5DLpjBdTxdmz/GACMZh1+YG/iLj0QYX7qRVIl0rR00iREozqj44YwUILHo3cASSRSeAzyidvlGT8QSMKOlOsD33ygtETpzW0XDmzWhyU3bv0O7lnGpbtqdzP/nsZDbdtf5XI0YBdi91HftqtQpIlMtCg+zIzATO4+QWGt0oDX/+jdB7Y/vBahxnz13stNYeGYslGBSZNgpB7HBKlTwB70sprZ8XmNGhj/NixqB6Bzae", ldns.LDNS_RDF_TYPE_B64) try: ret = pubkey.dnskey_set_key(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = pubkey.dnskey_set_key(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = pubkey.dnskey_set_key("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".dnskey_set_protocol()" pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}") rdf = ldns.ldns_rdf.new_frm_str("3", ldns.LDNS_RDF_TYPE_INT8) try: ret = pubkey.dnskey_set_protocol(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = pubkey.dnskey_set_protocol(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = pubkey.dnskey_set_protocol("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".get_class()" rr = ldns.ldns_rr.new_frm_str("test IN A 0.0.0.0", 600) try: ret = rr.get_class() if not isinstance(ret, int): set_error() if ret != ldns.LDNS_RR_CLASS_IN: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_class_str()" rr = ldns.ldns_rr.new_frm_str("test CH A 0.0.0.0", 600) try: ret = rr.get_class_str() if not isinstance(ret, str): set_error() if ret != "CH": set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_type()" rr = ldns.ldns_rr.new_frm_str("test IN A 0.0.0.0", 600) try: ret = rr.get_type() if not isinstance(ret, int): set_error() if ret != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_type_str()" rr = ldns.ldns_rr.new_frm_str("test IN A 0.0.0.0", 600) try: ret = rr.get_type_str() if not isinstance(ret, str): set_error() if ret != "A": set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".is_question()" rr = ldns.ldns_rr.new_frm_str("test IN A 0.0.0.0", 600) try: ret = rr.is_question() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() rr.set_question(True) try: ret = rr.is_question() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".label_count()" rr = ldns.ldns_rr.new_frm_str("test.dom. IN A 0.0.0.0", 600) try: ret = rr.label_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 2: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str(". IN A 0.0.0.0", 600) try: ret = rr.label_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error(string) if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".mx_exchange()" rr = ldns.ldns_rr.new_frm_str("nic.cz. IN MX 15 mail4.nic.cz.", 600) try: ret = rr.mx_exchange() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.mx_exchange() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".mx_preference()" rr = ldns.ldns_rr.new_frm_str("nic.cz. IN MX 15 mail4.nic.cz.", 600) try: ret = rr.mx_preference() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.mx_preference() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_fp()" f = open(temp_fname, "w") f.write("test 600 IN A 0.0.0.0") f.close() f = open(temp_fname, "r") rr, ttl, origin, prev = ldns.ldns_rr.new_frm_fp(f, origin=ldns.ldns_dname("nic.cz")) try: # Reading past file end. ret = ldns.ldns_rr.new_frm_fp(f, raiseException=False) if ret != None: set_error() except: set_error() try: # Reading past file end. rr, ttl, origin, prev = ldns.ldns_rr.new_frm_fp(f) set_error() except Exception: pass except: set_error() f.close() os.remove(temp_fname) #if not error_detected: if True: method_name = class_name + ".new_frm_fp_l()" f = open(temp_fname, "w") f.write("test 600 IN A 0.0.0.0") f.close() f = open(temp_fname, "r") rr, line, ttl, origin, prev = ldns.ldns_rr.new_frm_fp_l(f, origin=ldns.ldns_dname("nic.cz")) try: # Reading past file end. ret = ldns.ldns_rr.new_frm_fp_l(f, raiseException=False) if ret != None: set_error() except: set_error() try: # Reading past file end. rr, ttl, origin, prev = ldns.ldns_rr.new_frm_fp_l(f) set_error() except Exception: pass except: set_error() f.close() os.remove(temp_fname) #if not error_detected: if True: method_name = class_name + ".new_frm_str()" try: rr = ldns.ldns_rr.new_frm_str("test IN A 0.0.0.0", 600, origin=ldns.ldns_dname("nic.cz")) if not isinstance(rr, ldns.ldns_rr): set_error() except: set_error() try: rr = ldns.ldns_rr.new_frm_str(10) set_error() except TypeError: pass except: set_error() try: rr = ldns.ldns_rr.new_frm_str("") set_error() except Exception: pass except: set_error() try: rr = ldns.ldns_rr.new_frm_str("", raiseException=False) if rr != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_str_prev()" try: rr, prev = ldns.ldns_rr.new_frm_str_prev("test IN A 0.0.0.0", 600, origin=ldns.ldns_dname("nic.cz")) if not isinstance(rr, ldns.ldns_rr): set_error() # if prev != None: # set_error() except: set_error() try: rr = ldns.ldns_rr.new_frm_str_prev(10) set_error() except TypeError: pass except: set_error() try: rr = ldns.ldns_rr.new_frm_str_prev("") set_error() except Exception: pass except: set_error() try: rr = ldns.ldns_rr.new_frm_str_prev("", raiseException=False) if rr != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_question_frm_str()" try: rr = ldns.ldns_rr.new_question_frm_str("test IN A", 600, origin=ldns.ldns_dname("nic.cz")) if not isinstance(rr, ldns.ldns_rr): set_error() except: set_error() try: rr = ldns.ldns_rr.new_question_frm_str(10) set_error() except TypeError: pass except: set_error() try: rr = ldns.ldns_rr.new_question_frm_str("") set_error() except Exception: pass except: set_error() try: rr = ldns.ldns_rr.new_question_frm_str("", raiseException=False) if rr != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".ns_nsdname()" rr = ldns.ldns_rr.new_frm_str("nic.cz. 1800 IN NS a.ns.nic.cz.") try: ret = rr.ns_nsdname() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.ns_nsdname() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".owner()" rr = ldns.ldns_rr.new_frm_str("nic.cz. 1800 IN NS a.ns.nic.cz.") try: ret = rr.owner() if not isinstance(ret, ldns.ldns_dname): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".pop_rdf()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.pop_rdf() if not isinstance(ret, ldns.ldns_rdf): set_error() if ret.get_type() != ldns.LDNS_RDF_TYPE_A: set_error() except: set_error() try: ret = rr.pop_rdf() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".print_to_file()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") f = open(temp_fname, "w") try: rr.print_to_file(f) except: set_error() f.close() f = open(temp_fname, "r") if not f.readline(): set_error() f.close() os.remove(temp_fname) #if not error_detected: if True: method_name = class_name + ".push_rdf()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") rdf = ldns.ldns_rdf.new_frm_str("1.1.1.1", ldns.LDNS_RDF_TYPE_A) try: ret = rr.push_rdf(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rr.push_rdf("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rd_count()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rd_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rdf()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rdf(0) if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() try: ret = rr.rdf(1) if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rdfs()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rdfs() if len(list(ret)) != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_algorithm()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_algorithm() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_algorithm() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_expiration()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_expiration() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_expiration() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_inception()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_inception() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_inception() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_keytag()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_keytag() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_keytag() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_labels()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_labels() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_labels() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_origttl()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_origttl() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_origttl() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_algorithm()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("3", ldns.LDNS_RDF_TYPE_ALG) try: ret = rr.rrsig_set_algorithm(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_algorithm(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_algorithm("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_expiration()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("20130928153754", ldns.LDNS_RDF_TYPE_TIME) try: ret = rr.rrsig_set_expiration(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_expiration(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_expiration("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_inception()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("20120728153754", ldns.LDNS_RDF_TYPE_TIME) try: ret = rr.rrsig_set_inception(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_inception(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_inception("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_keytag()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("19032", ldns.LDNS_RDF_TYPE_INT16) try: ret = rr.rrsig_set_keytag(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_keytag(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_keytag("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_labels()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("1", ldns.LDNS_RDF_TYPE_INT8) try: ret = rr.rrsig_set_labels(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_labels(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_labels("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_origttl()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("1", ldns.LDNS_RDF_TYPE_INT8) try: ret = rr.rrsig_set_origttl(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_origttl(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_origttl("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_sig()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=", ldns.LDNS_RDF_TYPE_B64) try: ret = rr.rrsig_set_sig(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_sig(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_sig("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_signame()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("example.", ldns.LDNS_RDF_TYPE_DNAME) try: ret = rr.rrsig_set_signame(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_signame(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_signame("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_set_typecovered()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") rdf = ldns.ldns_rdf.new_frm_str("SOA", ldns.LDNS_RDF_TYPE_TYPE) try: ret = rr.rrsig_set_typecovered(rdf) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() # rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) # try: # ret = rr.rrsig_set_typecovered(rdf) # if not isinstance(ret, bool): # set_error() # if ret != False: # set_error() # except: # set_error() try: ret = rr.rrsig_set_typecovered("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_sig()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_sig() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_sig() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_signame()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_signame() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_signame() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrsig_typecovered()" rr = ldns.ldns_rr.new_frm_str("example. 600 IN RRSIG SOA 3 1 600 20130828153754 20120828153754 19031 example. AIoCFhwZJxIgYOBEyo3cxxWFZEsUPqkxnt38xEl1cFAHHC9iQN9mlEg=") try: ret = rr.rrsig_typecovered() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.rrsig_typecovered() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_class()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: rr.set_class(ldns.LDNS_RR_CLASS_CH) except: set_error() try: rr.set_class("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_owner()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") rdf = ldns.ldns_dname("test2") try: rr.set_owner(rdf) except: set_error() try: rr.set_owner("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_question()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: rr.set_question(True) except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rd_count()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: rr.set_rd_count(1) except: set_error() try: rr.set_rd_count("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rdf()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") rdf = ldns.ldns_rdf.new_frm_str("1.1.1.1", ldns.LDNS_RDF_TYPE_A) rr.push_rdf(rdf) try: ret = rr.set_rdf(rdf, 0) if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() try: ret = rr.set_rdf(rdf, 2) if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() try: rr.set_rdf("", 1) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_ttl()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: rr.set_ttl(1) except: set_error() try: rr.set_ttl("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_type()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: rr.set_type(ldns.LDNS_RR_TYPE_A) except: set_error() try: rr.set_type("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".to_canonical()" rr = ldns.ldns_rr.new_frm_str("TEST 600 IN A 0.0.0.0") try: rr.to_canonical() except: set_error() #if not error_detected: if True: method_name = class_name + ".ttl()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.ttl() if not isinstance(ret, int): set_error() if ret != 600: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".type_by_name()" try: ret = ldns.ldns_rr.type_by_name("A") if not isinstance(ret, int): set_error() if ret != ldns.LDNS_RR_TYPE_A: set_error() except: set_error() try: ret = ldns.ldns_rr.type_by_name("AA") if not isinstance(ret, int): set_error() if ret != 0: set_error() except: set_error() try: ret = ldns.ldns_rr.type_by_name(1) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".uncompressed_size()" rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0") try: ret = rr.uncompressed_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 20: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".write_data_to_buffer()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".write_rrsig_to_buffer()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".write_to_buffer()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".write_to_buffer_canonical()" sys.stderr.write("%s not tested.\n" % (method_name)) ############################################################################### ############################################################################### class_name = "ldns_rr_descriptor" method_name = None error_detected = False temp_fname = "tmp_rr_descriptor.txt" #if not error_detected: if True: method_name = class_name + ".field_type()" desc_a = ldns.ldns_rr_descriptor.ldns_rr_descriptor(ldns.LDNS_RR_TYPE_A) try: ret = desc_a.field_type(0) if not isinstance(ret, int): set_error() if ret != ldns.LDNS_RDF_TYPE_A: set_error() except: set_error() try: ret = desc_a.field_type("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".ldns_rr_descriptor()" try: ret = ldns.ldns_rr_descriptor.ldns_rr_descriptor(ldns.LDNS_RR_TYPE_A) if not isinstance(ret, ldns.ldns_rr_descriptor): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".maximum()" desc_a = ldns.ldns_rr_descriptor.ldns_rr_descriptor(ldns.LDNS_RR_TYPE_A) try: ret = desc_a.maximum() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".minimum()" desc_a = ldns.ldns_rr_descriptor.ldns_rr_descriptor(ldns.LDNS_RR_TYPE_A) try: ret = desc_a.minimum() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() ############################################################################### ############################################################################### class_name = "ldns_rr_list" method_name = None error_detected = False temp_fname = "tmp_rr_list.txt" #if not error_detected: if True: method_name = class_name + ".[comparison operators]" rrl1 = ldns.ldns_rr_list.new() rrl1.push_rr(ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")) rrl2 = ldns.ldns_rr_list.new() rrl2.push_rr(ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1")) try: ret = rrl1 < rrl2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl2 < rrl1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl1 <= rrl2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl2 <= rrl1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl1 == rrl2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl1 == rrl1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl1 != rrl2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl1 != rrl1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl1 > rrl2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl2 > rrl1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl1 >= rrl2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl2 >= rrl1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".cat()" rrl1 = ldns.ldns_rr_list.new() rrl2 = ldns.ldns_rr_list.new() rrl1.push_rr(ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")) rrl2.push_rr(ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1")) try: ret = rrl1.cat(rrl2) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl2.cat("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".cat_clone()" rrl1 = ldns.ldns_rr_list.new() rrl2 = ldns.ldns_rr_list.new() rrl1.push_rr(ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")) rrl2.push_rr(ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1")) try: ret = rrl1.cat_clone(rrl2) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = rrl2.cat_clone("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".clone()" rrl = ldns.ldns_rr_list.new() rrl.push_rr(ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")) try: ret = rrl.clone() if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".contains_rr()" rrl = ldns.ldns_rr_list.new() rr1 = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rr2 = ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1") rrl.push_rr(rr1) try: ret = rrl.contains_rr(rr1) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl.contains_rr(rr2) if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rrl.contains_rr("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".is_rrset()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = rrl.is_rrset() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new()" try: ret = ldns.ldns_rr_list.new() if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_frm_file()" try: ret = ldns.ldns_rr_list.new_frm_file() if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = ldns.ldns_rr_list.new_frm_file("test") set_error() except Exception: pass except: set_error() try: ret = ldns.ldns_rr_list.new_frm_file("test", raiseException=False) if isinstance(ret, ldns.ldns_rr_list): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".owner()" rrl = ldns.ldns_rr_list.new() try: ret = rrl.owner() if isinstance(ret, ldns.ldns_rdf): set_error() if ret != None: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = rrl.owner() if not isinstance(ret, ldns.ldns_dname): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".pop_rr()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = rrl.pop_rr() if not isinstance(ret, ldns.ldns_rr): set_error() except: set_error() try: ret = rrl.pop_rr() if isinstance(ret, ldns.ldns_rr): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".pop_rr_list()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rrl.push_rr(rr) rrl.push_rr(rr) try: ret = rrl.pop_rr_list(2) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = rrl.pop_rr_list(2) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = rrl.pop_rr_list(2) if isinstance(ret, ldns.ldns_rr_list): set_error() if ret != None: set_error() except: set_error() try: ret = rrl.pop_rr_list("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".pop_rrset()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rrl.push_rr(rr) rrl.push_rr(rr) try: ret = rrl.pop_rrset() if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = rrl.pop_rrset() if isinstance(ret, ldns.ldns_rr_list): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".print_to_file()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rrl.push_rr(rr) rrl.push_rr(rr) f = open(temp_fname, "w") try: rrl.print_to_file(f) except: set_error() f.close() f = open(temp_fname, "r") if len(f.readlines()) != 3: set_error() f.close() os.remove(temp_fname) #if not error_detected: if True: method_name = class_name + ".push_rr()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") try: ret = rrl.push_rr(rr) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl.push_rr("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_rr_list()" rrl1 = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl1.push_rr(rr) rrl2 = rrl1.new() try: ret = rrl1.push_rr_list(rrl2) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rrl.push_rr_list("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rr()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = rrl.rr(0) if not isinstance(ret, ldns.ldns_rr): set_error() except: set_error() try: ret = rrl.rr(1) if isinstance(ret, ldns.ldns_rr): set_error() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rr_count()" rrl = ldns.ldns_rr_list.new() try: ret = rrl.rr_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = rrl.rr_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rrs()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rrl.push_rr(rr) try: ret = list(rrl.rrs()) if not isinstance(ret, list): set_error() if len(ret) != 2: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rr()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rr = ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1") ret = rrl.set_rr(rr, 0) try: ret = rrl.set_rr(rr, 0) if not isinstance(ret, ldns.ldns_rr): set_error() except: set_error() try: ret = rrl.set_rr(rr, 1) if isinstance(ret, ldns.ldns_rr): set_error() if ret != None: set_error() except: set_error() try: ret = rrl.set_rr("", 1) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rr_count()" rrl = ldns.ldns_rr_list.new() try: rrl.set_rr_count(0) except: set_error() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: rrl.set_rr_count("") except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".sort()" rrl = ldns.ldns_rr_list.new() try: rrl.sort() except: set_error() #if not error_detected: if True: method_name = class_name + ".subtype_by_rdf()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rr = ldns.ldns_rr.new_frm_str("test2 600 IN A 1.1.1.1") rrl.push_rr(rr) rr = ldns.ldns_rr.new_frm_str("test3 600 IN A 0.0.0.0") rrl.push_rr(rr) rdf = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) try: ret = rrl.subtype_by_rdf(rdf, 0) if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 2: set_error() except: set_error() rdf = ldns.ldns_rdf.new_frm_str("::", ldns.LDNS_RDF_TYPE_AAAA) try: ret = rrl.subtype_by_rdf(rdf, 0) if isinstance(ret, ldns.ldns_rr_list): set_error() if ret != None: set_error() except: set_error() try: ret = rrl.subtype_by_rdf("", 0) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".to_canonical()" rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("TEST1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: rrl.to_canonical() except: set_error() #if not error_detected: if True: method_name = class_name + ".type()" rrl = ldns.ldns_rr_list.new() try: ret = rrl.type() if not isinstance(ret, int): set_error() if ret != 0: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("TEST1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = rrl.type() if not isinstance(ret, int): set_error() if ret != ldns.LDNS_RR_TYPE_A: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".write_to_buffer()" sys.stderr.write("%s not tested.\n" % (method_name)) if not error_detected: sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__))) else: sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__))) sys.exit(1) ldns-1.9.2/contrib/python/examples/ldns-axfr.py0000775000175000017500000000327515212267520021114 0ustar willemwillem#!/usr/bin/python # vim:fileencoding=utf-8 # # AXFR client with IDN (Internationalized Domain Names) support # import ldns import encodings.idna def utf2name(name): return '.'.join([encodings.idna.ToASCII(a) for a in name.split('.')]) def name2utf(name): return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')]) resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") #addr = ldns.ldns_get_rr_list_addr_by_name(resolver, "zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); addr = resolver.get_addr_by_name("zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD); if (not addr): raise Exception("Can't retrieve server address") print "Addr_by_name:",str(addr).replace("\n","; ") #remove all nameservers while resolver.pop_nameserver(): pass #insert server addr for rr in addr.rrs(): resolver.push_nameserver_rr(rr) #AXFR transfer status = resolver.axfr_start(utf2name(u"háčkyčárky.cz"), ldns.LDNS_RR_CLASS_IN) if status != ldns.LDNS_STATUS_OK: raise Exception("Can't start AXFR. Error: %s" % ldns.ldns_get_errorstr_by_id(status)) #Print results while True: rr = resolver.axfr_next() if not rr: break rdf = rr.owner() if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): print "RDF owner: type=",rdf.get_type_str(),"data=",name2utf(str(rdf)) else: print "RDF owner: type=",rdf.get_type_str(),"data=",str(rdf) print " RR type=", rr.get_type_str()," ttl=",rr.ttl() for rdf in rr.rdfs(): if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME): print " RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf)) else: print " RDF: type=",rdf.get_type_str(),"data=",str(rdf) print ldns-1.9.2/contrib/python/examples/ldns-newpkt.py0000775000175000017500000000073215212267520021457 0ustar willemwillem#!/usr/bin/python import ldns pkt = ldns.ldns_pkt.new_query_frm_str("www.google.com",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) rra = ldns.ldns_rr.new_frm_str("www.google.com. IN A 192.168.1.1",300) rrb = ldns.ldns_rr.new_frm_str("www.google.com. IN TXT Some\ Description",300) list = ldns.ldns_rr_list() if (rra): list.push_rr(rra) if (rrb): list.push_rr(rrb) pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, list) print "Packet:" print pkt ldns-1.9.2/contrib/python/examples/test_rdf.py0000775000175000017500000004714415212267520021033 0ustar willemwillem#!/usr/bin/env python # # ldns_rdf testing script. # # Do not use constructs that differ between Python 2 and 3. # Use write on stdout or stderr. # import ldns import sys import os import inspect class_name = "ldns_rdf" method_name = None error_detected = False temp_fname = "tmp_rdf.txt" def set_error(): """ Writes an error message and sets error flag. """ global class_name global method_name global error_detected error_detected = True sys.stderr.write("(line %d): malfunctioning method %s.\n" % \ (inspect.currentframe().f_back.f_lineno, method_name)) #if not error_detected: if True: method_name = class_name + ".__init__()" try: # Should raise an Exception rdf = ldns.ldns_rdf() set_error() except Exception as e: pass #if not error_detected: if True: method_name = class_name + ".[comparison operators]" rdf1 = ldns.ldns_rdf.new_frm_str("0.0.0.0", ldns.LDNS_RDF_TYPE_A) rdf2 = ldns.ldns_rdf.new_frm_str("1.1.1.1", ldns.LDNS_RDF_TYPE_A) try: ret = rdf1 < rdf2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rdf2 < rdf1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rdf1 <= rdf2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rdf2 <= rdf1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rdf1 == rdf2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rdf1 == rdf1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rdf1 != rdf2 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rdf1 != rdf1 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rdf1 > rdf2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rdf2 > rdf1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = rdf1 >= rdf2 if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = rdf2 >= rdf1 if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf_new()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_rdf_new_frm_data()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_rdf_new_frm_str()" try: rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz") except: set_error() try: rdf = ldns.ldns_rdf_new_frm_str("", "www.nic.cz") et_error() except TypeError: pass except: set_error() try: rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, 1) except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf_new_frm_fp()" f = open(temp_fname, "w") f.write("217.31.205.50") f.close() f = open(temp_fname, "r") try: status, rdf = ldns.ldns_rdf_new_frm_fp(ldns.LDNS_RDF_TYPE_A, f) if status != ldns.LDNS_STATUS_OK: set_error() if rdf == None: set_error() except: set_error() try: # Reading past file end. status, rdf = ldns.ldns_rdf_new_frm_fp(ldns.LDNS_RDF_TYPE_AAAA, f) if status == ldns.LDNS_STATUS_OK: set_error() if rdf != None: set_error() except: set_error() f.close() f = open(temp_fname, "r") try: status, rdf = ldns.ldns_rdf_new_frm_fp(ldns.LDNS_RDF_TYPE_AAAA, f) if status != ldns.LDNS_STATUS_OK: set_error() if rdf != None: set_error() except: set_error() f.close() os.remove(temp_fname) try: status, rdf = ldns.ldns_rdf_new_frm_fp("", f) except TypeError: pass except: set_error() try: status, rdf = ldns.ldns_rdf_new_frm_fp(ldns.LDNS_RDF_TYPE_AAAA, "") except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf_new_frm_fp_l()" f = open(temp_fname, "w") f.write("217.31.205.50\n194.0.12.1") f.close() f = open(temp_fname, "r") try: status, rdf, line = ldns.ldns_rdf_new_frm_fp_l(ldns.LDNS_RDF_TYPE_A, f) if status != ldns.LDNS_STATUS_OK: set_error() if rdf == None: set_error() except: set_error() try: status, rdf, line = ldns.ldns_rdf_new_frm_fp_l(ldns.LDNS_RDF_TYPE_A, f) if status != ldns.LDNS_STATUS_OK: set_error() if rdf == None: set_error() except: set_error() try: # Reading past file end. status, rdf, line = ldns.ldns_rdf_new_frm_fp_l(ldns.LDNS_RDF_TYPE_A, f) if status == ldns.LDNS_STATUS_OK: set_error() if rdf != None: set_error() except: set_error() f.close() os.remove(temp_fname) try: status, rdf = ldns.ldns_rdf_new_frm_fp_l("", f) except TypeError: pass except: set_error() try: status, rdf = ldns.ldns_rdf_new_frm_fp_l(ldns.LDNS_RDF_TYPE_AAAA, "") except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_drf.absolute()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.absolute() if not isinstance(ret, bool): set_error() if not ret: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.address_reverse()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "194.0.12.1") try: ret = rdf.address_reverse() if ret == None: set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_AAAA, "::1") try: ret = rdf.address_reverse() if ret == None: set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.address_reverse() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.cat()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "cz.") try: ret = rdf1.cat(rdf2) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf1.cat(rdf2) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = rdf2.cat(rdf1) if ret == ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = rdf2.cat("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.cat_clone()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "cz.") try: ret = rdf1.cat_clone(rdf2) if ret == None: set_error() except: set_error() rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf1.cat_clone(rdf2) if ret != None: set_error() except: set_error() try: ret = rdf2.cat_clone(rdf1) if ret != None: set_error() except: set_error() try: ret = rdf2.cat_clone("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.clone()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.clone() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.data()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.data() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.data_as_bytearray()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.data_as_bytearray() if not isinstance(ret, bytearray): set_error() if len(ret) != 12: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.dname_compare()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "nic.cz.") try: ret = rdf1.dname_compare(rdf2) if ret != 1: set_error() except: set_error() try: ret = rdf2.dname_compare(rdf1) if ret != -1: set_error() except: set_error() try: ret = rdf1.dname_compare(rdf1) if ret != 0: set_error() except: set_error() rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf1.dname_compare(rdf2) set_error() except Exception: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.dname_new_frm_str()" try: rdf = ldns.ldns_rdf.dname_new_frm_str("www.nic.cz.") if rdf == None: set_error() except: set_error() try: rdf = ldns.ldns_rdf.dname_new_frm_str("") if rdf != None: set_error() except: set_error() try: rdf = ldns.ldns_rdf.dname_new_frm_str(1) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.get_type()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.get_type() if not isinstance(ret, int): set_error() if ret != ldns.LDNS_RDF_TYPE_DNAME: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.get_type_str()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.get_type_str() if not isinstance(ret, str): set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.interval()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "a.ns.nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "b.ns.nic.cz.") rdf3 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "c.ns.nic.cz.") try: ret = rdf1.interval(rdf2, rdf3) if ret != -1: set_error() except: set_error() try: ret = rdf2.interval(rdf1, rdf3) if ret != 1: set_error() except: set_error() rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "194.0.12.1") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "b.ns.nic.cz.") rdf3 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "c.ns.nic.cz.") try: ret = rdf1.interval(rdf2, rdf3) set_error() except Exception: pass except: set_error() try: ret = rdf2.interval("", rdf3) set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.is_subdomain()" rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "nic.cz.") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf1.is_subdomain(rdf2) if not isinstance(ret, bool): set_error() if ret == True: set_error() ret = rdf2.is_subdomain(rdf1) if ret != True: set_error() except: set_error() rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "194.0.12.1") rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf1.is_subdomain(rdf2) if ret != False: set_error() except: set_error() try: ret = rdf2.is_subdomain(rdf1) if ret != False: set_error() except: set_error() try: ret = rdf2.is_subdomain("") set_error() except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.label()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.label(0) if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() try: ret = rdf.label(10) if ret != None: set_error() except: set_error() try: ret = rdf.label("") except TypeError: pass except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf.label(0) if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.label_count()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.label_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 3: set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf.label_count() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.left_chop()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.left_chop() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf.left_chop() if ret != None: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.make_canonical()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "WWW.NIC.CZ.") try: rdf.make_canonical() if rdf.__str__() != "www.nic.cz.": set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: rdf.make_canonical() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.new_frm_str()" try: rdf = ldns.ldns_rdf.new_frm_str("www.nic.cz.", ldns.LDNS_RDF_TYPE_DNAME) except: set_error() try: rdf = ldns.ldns_rdf.new_frm_str("www.nic.cz.", ldns.LDNS_RDF_TYPE_AAAA) set_error() except Exception: pass except: set_error() try: rdf = ldns.ldns_rdf.new_frm_str("www.nic.cz.", ldns.LDNS_RDF_TYPE_AAAA, raiseException = False) if rdf != None: set_error() except: set_error() try: rdf = ldns.ldns_rdf.new_frm_str("", "www.nic.cz") et_error() except TypeError: pass except: set_error() try: rdf = ldns.ldns_rdf.new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, 1) except TypeError: pass except: set_error() #if not error_detected: if True: rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") f = open(temp_fname, "w") try: rdf.print_to_file(f) except: set_error() f.close() f = open(temp_fname, "r") if f.read() != "127.0.0.1": set_error() f.close() os.remove(temp_fname) #if not error_detected: if True: rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.reverse() if not isinstance(ret, ldns.ldns_rdf): set_error() if ret.__str__() != "cz.nic.www.": set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: ret = rdf.reverse() set_error() except Exception: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.set_data()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_rdf.set_size()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_rdf.set_type()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = "ldns_rdf.size()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") try: ret = rdf.size() if ret != 12: set_error() except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.write_to_buffer()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.") buf = ldns.ldns_buffer(1024) try: ret = rdf.write_to_buffer(buf) if ret != ldns.LDNS_STATUS_OK: set_error() if buf.position() != 12: set_error() except: set_error() try: ret = rdf.write_to_buffer("") except TypeError: pass except: set_error() #if not error_detected: if True: method_name = "ldns_rdf.write_to_buffer_canonical()" rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "WWW.NIC.CZ.") buf = ldns.ldns_buffer(1024) try: ret = rdf.write_to_buffer_canonical(buf) if ret != ldns.LDNS_STATUS_OK: set_error() if buf.position() != 12: set_error() except: set_error() try: ret = rdf.write_to_buffer_canonical("") except TypeError: pass except: set_error() if not error_detected: sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__))) else: sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__))) sys.exit(1) ldns-1.9.2/contrib/python/examples/ldns-signzone.py0000775000175000017500000000311115212267520021775 0ustar willemwillem#!/usr/bin/python # This example shows how to sign a given zone file with private key import ldns import sys, os, time #private key TAG which identifies the private key #use ldns-keygen.py in order to obtain private key keytag = 30761 # Read zone file #------------------------------------------------------------- zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) soa = zone.soa() origin = soa.owner() # Prepare keys #------------------------------------------------------------- #Read private key from file keyfile = open("key-%s-%d.private" % (origin, keytag), "r"); key = ldns.ldns_key.new_frm_fp(keyfile) #Read public key from file pubfname = "key-%s-%d.key" % (origin, keytag) pubkey = None if os.path.isfile(pubfname): pubkeyfile = open(pubfname, "r"); pubkey,_,_,_ = ldns.ldns_rr.new_frm_fp(pubkeyfile) if not pubkey: #Create new public key pubkey = key.key_to_rr() #Set key expiration key.set_expiration(int(time.time()) + 365*60*60*24) #365 days #Set key owner (important step) key.set_pubkey_owner(origin) #Insert DNSKEY RR zone.push_rr(pubkey) # Sign zone #------------------------------------------------------------- #Create keylist and push private key keys = ldns.ldns_key_list() keys.push_key(key) #Add SOA signed_zone = ldns.ldns_dnssec_zone() signed_zone.add_rr(soa) #Add RRs for rr in zone.rrs().rrs(): print "RR:",str(rr), signed_zone.add_rr(rr) added_rrs = ldns.ldns_rr_list() status = signed_zone.sign(added_rrs, keys) if (status == ldns.LDNS_STATUS_OK): signed_zone.print_to_file(open("zone_signed.txt","w")) ldns-1.9.2/contrib/python/examples/ldns_rr_new_frm_fp_l.demo.py0000664000175000017500000000227215212267520024312 0ustar willemwillemimport ldns import sys if len(sys.argv) <= 1: print "Usage: %s zone_file" % sys.argv[0] sys.exit() inp = open(sys.argv[1],"r"); # variables that preserve the parsers state my_ttl = 3600; my_origin = None my_prev = None # additional state variables last_pos = 0 line_nr = 0 while True: ret = ldns.ldns_rr_new_frm_fp_l_(inp, my_ttl, my_origin, my_prev) s, rr, line_inc, new_ttl, new_origin, new_prev = ret # unpack the result line_nr += line_inc # increase number of parsed lines my_prev = new_prev # update ref to previous owner if s == ldns.LDNS_STATUS_SYNTAX_TTL: my_ttl = new_ttl # update default TTL print "$TTL:", my_ttl elif s == ldns.LDNS_STATUS_SYNTAX_ORIGIN: my_origin = new_origin # update reference to origin print "$ORIGIN:", my_origin elif s == ldns.LDNS_STATUS_SYNTAX_EMPTY: if last_pos == inp.tell(): break # no advance since last read - EOF last_pos = inp.tell() elif s != ldns.LDNS_STATUS_OK: print "! parse error in line", line_nr else: # we are sure to have LDNS_STATUS_OK print rr inp.close() print "--------------------" print "Read %d lines" % line_nr ldns-1.9.2/contrib/python/examples/test_pkt.py0000775000175000017500000014166415212267520021060 0ustar willemwillem#!/usr/bin/env python # # ldns_pkt testing script. # # Do not use constructs that differ between Python 2 and 3. # Use write on stdout or stderr. # import ldns import sys import os import inspect class_name = "ldns_pkt" method_name = None error_detected = False temp_fname = "tmp_pkt.txt" def set_error(): """ Writes an error message and sets error flag. """ global class_name global method_name global error_detected error_detected = True sys.stderr.write("(line %d): malfunctioning method %s.\n" % \ (inspect.currentframe().f_back.f_lineno, method_name)) #if not error_detected: if True: method_name = class_name + ".aa()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) try: ret = pkt.aa() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR) try: ret = pkt.aa() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".ad()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.ad() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR) try: ret = pkt.ad() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".additional()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.additional() if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".algorithm2str()" try: ret = ldns.ldns_pkt.algorithm2str(ldns.LDNS_DSA) if not isinstance(ret, str): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".all()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.all() if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".all_noquestion()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.all_noquestion() if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".ancount()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.ancount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".answer()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.answer() if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".answerfrom()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.answerfrom() if ret != None: set_error() except: set_error() resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) try: ret = pkt.answerfrom() if not isinstance(ret, ldns.ldns_rdf): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".arcount()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.arcount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".authority()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.authority() if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".cd()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_CD) try: ret = pkt.cd() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR) try: ret = pkt.cd() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".cert_algorithm2str()" try: ret = ldns.ldns_pkt.cert_algorithm2str(ldns.LDNS_CERT_PGP) if not isinstance(ret, str): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".clone()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.clone() if not isinstance(ret, ldns.ldns_pkt): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".ends()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) try: ret = pkt.edns() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".ends_data()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns_data() if ret != None: set_error() except: set_error() #resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") #resolver.set_dnssec(True) #pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) #try: # ret = pkt.edns_data() # print ret # if not isinstance(ret, ldns.ldns_rdf): # set_error() # if ret != True: # set_error() #except: # set_error() #if not error_detected: if True: method_name = class_name + ".edns_do()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns_do() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".edns_extended_rcode()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns_extended_rcode() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") #resolver.set_dnssec(True) #pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) #try: # ret = pkt.edns_extended_rcode() # if (not isinstance(ret, int)) and (not isinstance(ret, long)): # set_error() # if ret != 0: # set_error() #except: # set_error() #if not error_detected: if True: method_name = class_name + ".edns_udp_size()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns_udp_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) try: ret = pkt.edns_udp_size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret == 0: # Don't know the actual size, but must be greater than 0. set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".edns_version()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns_version() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") #resolver.set_dnssec(True) #pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) #try: # ret = pkt.edns_version() # if (not isinstance(ret, int)) and (not isinstance(ret, long)): # set_error() # if ret != 0: # set_error() #except: # set_error() #if not error_detected: if True: method_name = class_name + ".edns_z()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.edns_z() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".empty()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.empty() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_opcode()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.get_opcode() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != ldns.LDNS_PACKET_QUERY: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_rcode()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.get_rcode() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != ldns.LDNS_RCODE_NOERROR: set_error() except: set_error() resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) pkt = resolver.query("nonexistent_domain.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) try: ret = pkt.get_rcode() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != ldns.LDNS_RCODE_NXDOMAIN: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".get_section_clone()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.get_section_clone(ldns.LDNS_SECTION_ANY) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = pkt.get_section_clone(ldns.LDNS_SECTION_ANSWER) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = pkt.get_section_clone("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".id()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.id() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new()" try: pkt = ldns.ldns_pkt.new() if not isinstance(pkt, ldns.ldns_pkt): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".new_query()" dname = ldns.ldns_dname("test.nic.cz.") try: pkt = ldns.ldns_pkt.new_query(dname, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) if not isinstance(pkt, ldns.ldns_pkt): set_error() except: set_error() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test.nic.cz.") try: pkt = ldns.ldns_pkt.new_query(rdf, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) if not isinstance(pkt, ldns.ldns_pkt): set_error() except: set_error() try: pkt = ldns.ldns_pkt.new_query("bad argument", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: pkt = ldns.ldns_pkt.new_query(dname, "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: pkt = ldns.ldns_pkt.new_query(dname, ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_QR | ldns.LDNS_RD) set_error() except TypeError as e: pass except: set_error() try: pkt = ldns.ldns_pkt.new_query(dname, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".new_query_frm_str()" try: pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) except: set_error() try: pkt = ldns.ldns_pkt.new_query_frm_str(pkt, ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) set_error() except TypeError as e: pass except: set_error() try: pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) set_error() except TypeError as e: pass except: set_error() try: pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_ANY, "bad argument", ldns.LDNS_QR | ldns.LDNS_AA) set_error() except TypeError as e: pass except: set_error() try: pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".nscount()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.nscount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".opcode2str()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) try: ret = pkt.opcode2str() if not isinstance(ret, str): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".print_to_file()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) f = open(temp_fname, "w") try: pkt.print_to_file(f) except: set_error() f.close() f = open(temp_fname, "r") if len(f.readlines()) != 14: set_error() f.close() os.remove(temp_fname) #if not error_detected: if True: method_name = class_name + ".push_rr()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") try: ret = pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pkt.push_rr("bad argument", rr) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.push_rr(ldns.LDNS_SECTION_ANSWER, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".push_rr_list()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD) rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) rrl.push_rr(rr) try: ret = pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, rrl) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pkt.push_rr_list("bad argument", rrl) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".qdcount()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.qdcount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".qr()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) try: ret = pkt.qr() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_AA) try: ret = pkt.qr() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".querytime()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.querytime() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".question()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD) try: ret = pkt.question() if not isinstance(ret, ldns.ldns_rr_list): set_error() if ret.rr_count() != 1: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".ra()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RA) try: ret = pkt.ra() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR) try: ret = pkt.ra() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rcode2str()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RA) try: ret = pkt.rcode2str() if not isinstance(ret, str): set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rd()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) try: ret = pkt.rd() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR) try: ret = pkt.rd() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".reply_type()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) try: ret = pkt.reply_type() if ret != ldns.LDNS_PACKET_ANSWER: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".rr()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr) try: ret = pkt.rr(ldns.LDNS_SECTION_ANSWER, rr) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pkt.rr(ldns.LDNS_SECTION_QUESTION, rr) if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = pkt.rr("bad argument", rr) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.rr(ldns.LDNS_SECTION_QUESTION, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rr_list_by_name()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr) rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test1") try: ret = pkt.rr_list_by_name(rdf, ldns.LDNS_SECTION_ANSWER) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = pkt.rr_list_by_name(rdf, ldns.LDNS_SECTION_QUESTION) if ret != None: set_error() except: set_error() try: ret = pkt.rr_list_by_name("bad argument", ldns.LDNS_SECTION_ANSWER) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.rr_list_by_name(rdf, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rr_list_by_name_and_type()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr) rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test1") try: ret = pkt.rr_list_by_name_and_type(rdf, ldns.LDNS_RR_TYPE_A, ldns.LDNS_SECTION_ANSWER) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = pkt.rr_list_by_name_and_type(rdf, ldns.LDNS_RR_TYPE_AAAA, ldns.LDNS_SECTION_ANSWER) if ret != None: set_error() except: set_error() #try: # ret = pkt.rr_list_by_name_and_type("bad argument", ldns.LDNS_RR_TYPE_A, ldns.LDNS_SECTION_ANSWER) # set_error() #except TypeError as e: # pass #except: # set_error() try: ret = pkt.rr_list_by_name_and_type(rdf, "bad argument", ldns.LDNS_SECTION_ANSWER) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.rr_list_by_name_and_type(rdf, ldns.LDNS_RR_TYPE_A, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".rr_list_by_type()" pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD) rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr) try: ret = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_A, ldns.LDNS_SECTION_ANSWER) if not isinstance(ret, ldns.ldns_rr_list): set_error() except: set_error() try: ret = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_AAAA, ldns.LDNS_SECTION_ANSWER) if ret != None: set_error() except: set_error() try: ret = pkt.rr_list_by_type("bad argument", ldns.LDNS_SECTION_ANSWER) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_A, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".safe_push_rr()" pkt = ldns.ldns_pkt.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") try: ret = pkt.safe_push_rr(ldns.LDNS_SECTION_ANSWER, rr) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pkt.safe_push_rr(ldns.LDNS_SECTION_ANSWER, rr) if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = pkt.safe_push_rr("bad argument", rr) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.safe_push_rr(ldns.LDNS_SECTION_ANSWER, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".safe_push_rr_list()" pkt = ldns.ldns_pkt.new() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: ret = pkt.safe_push_rr_list(ldns.LDNS_SECTION_ANSWER, rrl) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: ret = pkt.safe_push_rr_list(ldns.LDNS_SECTION_ANSWER, rrl) if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() try: ret = pkt.safe_push_rr_list("bad argument", rrl) set_error() except TypeError as e: pass except: set_error() try: ret = pkt.safe_push_rr_list(ldns.LDNS_SECTION_ANSWER, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_aa()" pkt = ldns.ldns_pkt.new() try: pkt.set_aa(True) if pkt.aa() != True: set_error() except: set_error() try: pkt.set_aa(False) if pkt.aa() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_ad()" pkt = ldns.ldns_pkt.new() try: pkt.set_ad(True) if pkt.ad() != True: set_error() except: set_error() try: pkt.set_ad(False) if pkt.ad() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_additional()" pkt = ldns.ldns_pkt.new() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: pkt.set_additional(rrl) if not isinstance(pkt.additional() , ldns.ldns_rr_list): set_error() if pkt.additional() != rrl: set_error() except: set_error() try: pkt.set_additional("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_ancount()" pkt = ldns.ldns_pkt.new() try: pkt.set_ancount(1) ret = pkt.ancount() if ret != 1: set_error() except: set_error() try: pkt.set_ancount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_answer()" pkt = ldns.ldns_pkt.new() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: pkt.set_answer(rrl) if not isinstance(pkt.additional() , ldns.ldns_rr_list): set_error() if pkt.answer() != rrl: set_error() except: set_error() try: pkt.set_answer("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_answerfrom()" pkt = ldns.ldns_pkt.new() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: pkt.set_answerfrom(rdf) ret = pkt.answerfrom() if ret != rdf: set_error() except: set_error() try: pkt.set_answerfrom("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_arcount()" pkt = ldns.ldns_pkt.new() try: pkt.set_arcount(1) ret = pkt.arcount() if ret != 1: set_error() except: set_error() try: pkt.set_arcount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_authority()" pkt = ldns.ldns_pkt.new() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: pkt.set_authority(rrl) if not isinstance(pkt.additional() , ldns.ldns_rr_list): set_error() if pkt.authority() != rrl: set_error() except: set_error() try: pkt.set_authority("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_cd()" pkt = ldns.ldns_pkt.new() try: pkt.set_cd(True) if pkt.cd() != True: set_error() except: set_error() try: pkt.set_cd(False) if pkt.cd() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_data()" pkt = ldns.ldns_pkt.new() rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1") try: pkt.set_edns_data(rdf) ret = pkt.edns_data() if ret != rdf: set_error() except: set_error() try: pkt.set_edns_data("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_do()" pkt = ldns.ldns_pkt.new() try: pkt.set_edns_do(True) if pkt.edns_do() != True: set_error() except: set_error() try: pkt.set_edns_do(False) if pkt.edns_do() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_extended_rcode()" pkt = ldns.ldns_pkt.new() try: pkt.set_edns_extended_rcode(8) ret = pkt.edns_extended_rcode() if ret != 8: set_error() except: set_error() try: pkt.set_edns_extended_rcode("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_udp_size()" pkt = ldns.ldns_pkt.new() try: pkt.set_edns_udp_size(4096) ret = pkt.edns_udp_size() if ret != 4096: set_error() except: set_error() try: pkt.set_edns_udp_size("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_version()" pkt = ldns.ldns_pkt.new() try: pkt.set_edns_version(8) ret = pkt.edns_version() if ret != 8: set_error() except: set_error() try: pkt.set_edns_version("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_edns_z()" pkt = ldns.ldns_pkt.new() try: pkt.set_edns_z(4096) ret = pkt.edns_z() if ret != 4096: set_error() except: set_error() try: pkt.set_edns_z("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_flags()" pkt = ldns.ldns_pkt.new() try: ret = pkt.set_flags(ldns.LDNS_AA | ldns.LDNS_AD) if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() try: pkt.set_flags("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_id()" pkt = ldns.ldns_pkt.new() try: pkt.set_id(4096) ret = pkt.id() if ret != 4096: set_error() except: set_error() try: pkt.set_id("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_nscount()" pkt = ldns.ldns_pkt.new() try: pkt.set_nscount(1) ret = pkt.nscount() if ret != 1: set_error() except: set_error() try: pkt.set_nscount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_opcode()" pkt = ldns.ldns_pkt.new() try: pkt.set_opcode(ldns.LDNS_PACKET_QUERY) ret = pkt.get_opcode() if ret != ldns.LDNS_PACKET_QUERY: set_error() except: set_error() try: pkt.set_opcode("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_qdcount()" pkt = ldns.ldns_pkt.new() try: pkt.set_qdcount(10) ret = pkt.qdcount() if ret != 10: set_error() except: set_error() try: pkt.set_qdcount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_qr()" pkt = ldns.ldns_pkt.new() try: pkt.set_qr(True) if pkt.qr() != True: set_error() except: set_error() try: pkt.set_qr(False) if pkt.qr() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_querytime()" pkt = ldns.ldns_pkt.new() try: pkt.set_querytime(65536) ret = pkt.querytime() if ret != 65536: set_error() except: set_error() try: pkt.set_querytime("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_question()" pkt = ldns.ldns_pkt.new() rrl = ldns.ldns_rr_list.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") rrl.push_rr(rr) try: pkt.set_question(rrl) if not isinstance(pkt.additional() , ldns.ldns_rr_list): set_error() if pkt.question() != rrl: set_error() except: set_error() try: pkt.set_question("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_ra()" pkt = ldns.ldns_pkt.new() try: pkt.set_ra(True) if pkt.ra() != True: set_error() except: set_error() try: pkt.set_ra(False) if pkt.ra() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_random_id()" pkt = ldns.ldns_pkt.new() try: pkt.set_random_id() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rcode()" pkt = ldns.ldns_pkt.new() try: pkt.set_rcode(127) ret = pkt.get_rcode() if ret != 127: set_error() except: set_error() try: pkt.set_rcode("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_rd()" pkt = ldns.ldns_pkt.new() try: pkt.set_rd(True) if pkt.rd() != True: set_error() except: set_error() try: pkt.set_rd(False) if pkt.rd() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_section_count()" pkt = ldns.ldns_pkt.new() try: pkt.set_section_count(ldns.LDNS_PACKET_QUESTION, 4096) ret = pkt.qdcount() if ret != 4096: set_error() except: set_error() try: pkt.set_section_count("bad argument", 4096) set_error() except TypeError as e: pass except: set_error() try: pkt.set_section_count(ldns.LDNS_PACKET_QUESTION, "bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_size()" pkt = ldns.ldns_pkt.new() try: pkt.set_size(512) ret = pkt.size() if ret != 512: set_error() except: set_error() try: pkt.set_size("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".set_tc()" pkt = ldns.ldns_pkt.new() try: pkt.set_tc(True) if pkt.tc() != True: set_error() except: set_error() try: pkt.set_tc(False) if pkt.tc() != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".set_timestamp()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".set_tsig()" pkt = ldns.ldns_pkt.new() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") try: pkt.set_tsig(rr) ret = pkt.tsig() if ret != rr: set_error() except: set_error() try: pkt.set_tsig("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".size()" pkt = ldns.ldns_pkt.new() pkt.set_size(512) try: ret = pkt.size() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 512: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".tc()" pkt = ldns.ldns_pkt.new() pkt.set_tc(True) try: ret = pkt.tc() if not isinstance(ret, bool): set_error() if ret != True: set_error() except: set_error() pkt.set_tc(False) try: ret = pkt.tc() if not isinstance(ret, bool): set_error() if ret != False: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".timestamp()" sys.stderr.write("%s not tested.\n" % (method_name)) #if not error_detected: if True: method_name = class_name + ".tsig()" pkt = ldns.ldns_pkt.new() try: ret = pkt.tsig() if ret != None: set_error() except: set_error() rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0") pkt.set_tsig(rr) try: ret = pkt.tsig() if not isinstance(ret, ldns.ldns_rr): set_error() if ret != rr: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".update_pkt_tsig_add()" pkt = ldns.ldns_pkt.new() resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") try: ret = pkt.update_pkt_tsig_add(resolver) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() try: ret = pkt.update_pkt_tsig_add("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".update_prcount()" pkt = ldns.ldns_pkt.new() try: ret = pkt.update_prcount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() pkt.update_set_prcount(127) try: ret = pkt.update_prcount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 127: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".update_set_adcount()" pkt = ldns.ldns_pkt.new() try: pkt.update_set_adcount(4096) ret = pkt.update_ad() if ret != 4096: set_error() except: set_error() try: pkt.update_set_adcount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".update_set_prcount()" pkt = ldns.ldns_pkt.new() try: pkt.update_set_prcount(4096) ret = pkt.update_prcount() if ret != 4096: set_error() except: set_error() try: pkt.update_set_prcount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".update_set_upcount()" pkt = ldns.ldns_pkt.new() try: pkt.update_set_upcount(4096) ret = pkt.update_upcount() if ret != 4096: set_error() except: set_error() try: pkt.update_set_upcount("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".update_set_zo()" pkt = ldns.ldns_pkt.new() try: pkt.update_set_zo(4096) ret = pkt.update_zocount() if ret != 4096: set_error() except: set_error() try: pkt.update_set_zo("bad argument") set_error() except TypeError as e: pass except: set_error() #if not error_detected: if True: method_name = class_name + ".update_upcount()" pkt = ldns.ldns_pkt.new() try: ret = pkt.update_upcount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() pkt.update_set_upcount(127) try: ret = pkt.update_upcount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 127: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".update_zocount()" pkt = ldns.ldns_pkt.new() try: ret = pkt.update_zocount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 0: set_error() except: set_error() pkt.update_set_zo(127) try: ret = pkt.update_zocount() if (not isinstance(ret, int)) and (not isinstance(ret, long)): set_error() if ret != 127: set_error() except: set_error() #if not error_detected: if True: method_name = class_name + ".write_to_buffer()" pkt = pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) buf = buf = ldns.ldns_buffer(4096) try: ret = pkt.write_to_buffer(buf) if ret != ldns.LDNS_STATUS_OK: set_error() except: set_error() if not error_detected: sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__))) else: sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__))) sys.exit(1) ldns-1.9.2/contrib/python/examples/ldns_rr_iter_frm_fp_l.demo.py0000664000175000017500000000032415212267520024460 0ustar willemwillemimport ldns import sys if len(sys.argv) <= 1: print "Usage: %s zone_file" % sys.argv[0] sys.exit() inp = open(sys.argv[1],"r"); for rr in ldns.ldns_rr_iter_frm_fp_l(inp): print rr inp.close() ldns-1.9.2/contrib/python/examples/ldns-zone.py0000775000175000017500000000040415212267520021116 0ustar willemwillem#!/usr/bin/python import ldns #Read zone from file zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN) print zone print "SOA:", zone.soa() for r in zone.rrs().rrs(): print "RR:", r zone = ldns.ldns_zone() #print zone ldns-1.9.2/contrib/python/examples/ldns-mx2.py0000775000175000017500000000105015212267520020647 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) if (pkt) and (pkt.answer()): for rr in pkt.answer().rrs(): if (rr.get_type() != ldns.LDNS_RR_TYPE_MX): continue rdf = rr.owner() print rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ", print " ".join(str(rdf) for rdf in rr.rdfs()) ldns-1.9.2/contrib/python/examples/ldns-higher.py0000775000175000017500000000174415212267520021421 0ustar willemwillem#!/usr/bin/python import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") dnn = ldns.ldns_dname("www.google.com") print dnn.get_type_str(), dnn dna = ldns.ldns_rdf.new_frm_str("74.125.43.99",ldns.LDNS_RDF_TYPE_A) print dna.get_type_str(), dna name = resolver.get_name_by_addr(dna) if (not name): raise Exception("Can't retrieve server name") for rr in name.rrs(): print rr name = resolver.get_name_by_addr("74.125.43.99") if (not name): raise Exception("Can't retrieve server name") for rr in name.rrs(): print rr addr = resolver.get_addr_by_name(dnn) if (not addr): raise Exception("Can't retrieve server address") for rr in addr.rrs(): print rr addr = resolver.get_addr_by_name("www.google.com") if (not addr): raise Exception("Can't retrieve server address") for rr in addr.rrs(): print rr hosts = ldns.ldns_rr_list.new_frm_file("/etc/hosts") if (not hosts): raise Exception("Can't retrieve the content of file") for rr in hosts.rrs(): print rr ldns-1.9.2/contrib/python/examples/ldns-mx1.py0000775000175000017500000000065715212267520020662 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns dname = ldns.ldns_dname("nic.cz") print dname resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) if (pkt): mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) if (mx): mx.sort() print mx ldns-1.9.2/contrib/python/examples/ldns-dnssec.py0000775000175000017500000000215215212267520021424 0ustar willemwillem#!/usr/bin/python # -*- coding: utf-8 -*- import ldns import sys debug = True # Check args argc = len(sys.argv) name = "www.nic.cz" if argc < 2: print "Usage:", sys.argv[0], "domain [resolver_addr]" sys.exit(1) else: name = sys.argv[1] # Create resolver resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) # Custom resolver if argc > 2: # Clear previous nameservers ns = resolver.pop_nameserver() while ns != None: ns = resolver.pop_nameserver() ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) resolver.push_nameserver(ip) # Resolve DNS name pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) if pkt and pkt.answer(): # Debug if debug: print "NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() ) # SERVFAIL indicated bogus name if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL: print name, "is bogus" # Check AD (Authenticated) bit if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR: if pkt.ad(): print name, "is secure" else: print name, "is insecure" ldns-1.9.2/contrib/python/examples/ldns-mx.py0000775000175000017500000000060315212267520020570 0ustar willemwillem#!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN) if (pkt): mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) if (mx): mx.sort() print mx ldns-1.9.2/contrib/python/ldns_key.i0000664000175000017500000004436215212267520017007 0ustar willemwillem/****************************************************************************** * ldns_key.i: LDNS key class * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ %typemap(in,numinputs=0,noblock=1) (ldns_key **) { ldns_key *$1_key; $1 = &$1_key; } /* result generation */ %typemap(argout,noblock=1) (ldns_key **) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_key), SWIGTYPE_p_ldns_struct_key, SWIG_POINTER_OWN | 0 )); } %typemap(argout) ldns_rdf *r "Py_INCREF($input);" %nodefaultctor ldns_struct_key; //no default constructor & destructor %nodefaultdtor ldns_struct_key; %delobject ldns_key_free; %delobject ldns_key_deep_free; %newobject ldns_key_list_pop_key; %newobject ldns_key2rr; %newobject ldns_key_new_frm_algorithm; %newobject ldns_key_new_frm_fp; %newobject ldns_key_new_frm_fp_l; %newobject ldns_key_new_frm_engine; %rename(ldns_key) ldns_struct_key; #ifdef LDNS_DEBUG %rename(__ldns_key_free) ldns_key_free; %inline %{ void _ldns_key_free (ldns_key* k) { printf("******** LDNS_KEY free 0x%lX ************\n", (long unsigned int)k); ldns_key_deep_free(k); } %} #else %rename(_ldns_key_free) ldns_key_deep_free; %rename(__ldns_key_free) ldns_key_free; #endif %feature("docstring") ldns_struct_key "Key class This class can contains all types of keys that are used in DNSSEC. Mostly used to store private keys, since public keys can also be stored in a ldns_rr with type LDNS_RR_TYPE_DNSKEY. This class can also store some variables that influence the signatures generated by signing with this key, for instance the inception date. **Usage** >>> import ldns >>> ldns.ldns_init_random(open(\"/dev/random\",\"rb\"), 512/8) >>> key = ldns.ldns_key.new_frm_algorithm(ldns.LDNS_SIGN_DSA, 512) #generate new DSA key >>> print key Private-key-format: v1.2 Algorithm: 3 (DSA) Prime(p): XXXXXXXXHRQBGRflHZQriSAoLI2g+LGvZz8BlEesO+ZQg65wrFGs9IC441y/mn3nFnXfCdtX6zbN5bQuabPdlQ== Subprime(q): XXXXXdnWs/cWsGDglhEyZRLEVA8= Base(g): XXXXXXXqrd+dm2bcxDBdCsZRzkXQ22FxCk2ycnjgevr+s2HfA57BPk3xwqCrHUwuOBVg3Fvq4bpldrCe0sT6Og== Private_value(x): XXXXXcVubZF33pj04z4ZoETsQW1Y= Public_value(y): XXXXXX8t6zfOxJHoy57qteIw9sOZ/Zu0yFiPO083sPm11NlFx3b4m7TJ2k41gYicHXHLUQK1p0xXFToeZEkPGQ== >>> fw = open(\"key.priv\", \"wb\") >>> key.print_to_file(fw) #write priv key to file " %extend ldns_struct_key { %pythoncode %{ def __init__(self): self.this = _ldns.ldns_key_new() if not self.this: raise Exception("Can't create instance of this class") __swig_destroy__ = _ldns._ldns_key_free def __str__(self): """converts the data to presentation format""" return _ldns.ldns_key2str(self) def key_to_rr(self): """converts a ldns_key to a public key rr :returns: (ldns_rr \*) ldns_rr representation of the key """ return _ldns.ldns_key2rr(self) #parameters: const ldns_key *, #retvals: ldns_rr * def print_to_file(self, file): """print a private key to the file output :param file: output file pointer """ _ldns.ldns_key_print(file, self) #parameters: FILE *, const ldns_key *, #retvals: #LDNS_KEY_CONSTRUCTORS_# @staticmethod def new_frm_fp(file, raiseException=True): """Creates a new priv key based on the contents of the file pointed by fp. :param file: a file object :param raiseException: if True, an exception occurs in case a key instance can't be created :returns: key instance or None. If the object can't be created and raiseException is True, an exception occurs. """ status, key = _ldns.ldns_key_new_frm_fp(file) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create key, error: %s (%d)" % (_ldns.ldns_get_errorstr_by_id(status),status)) return None return key @staticmethod def new_frm_fp_l(file, raiseException=True): """Creates a new private key based on the contents of the file pointed by fp. :param file: a file object :param raiseException: if True, an exception occurs in case a key instance can't be created :returns: * key - key instance or None. If an instance can't be created and raiseException is True, an exception occurs. * line - the line number (for debugging) """ status, key, line = _ldns.ldns_key_new_frm_fp_l(file) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create key, error: %d" % status) return None return key, line @staticmethod def new_frm_algorithm(algorithm, size, raiseException=True): """Creates a new key based on the algorithm. :param algorithm: the algorithm to use :param size: the number of bytes for the keysize :param raiseException: if True, an exception occurs in case a key instance can't be created :returns: key instance or None. If the object can't be created and raiseException is True, an exception occurs. **Algorithms** LDNS_SIGN_RSAMD5, LDNS_SIGN_RSASHA1, LDNS_SIGN_DSA, LDNS_SIGN_RSASHA1_NSEC3, LDNS_SIGN_RSASHA256, LDNS_SIGN_RSASHA256_NSEC3, LDNS_SIGN_RSASHA512, LDNS_SIGN_RSASHA512_NSEC3, LDNS_SIGN_DSA_NSEC3, LDNS_SIGN_HMACMD5, LDNS_SIGN_HMACSHA1, LDNS_SIGN_HMACSHA256 """ key = _ldns.ldns_key_new_frm_algorithm(algorithm, size) if (not key) and (raiseException): raise Exception("Can't create key, error: %d" % status) return key #_LDNS_KEY_CONSTRUCTORS# #LDNS_KEY_METHODS_# def algorithm(self): """return the signing alg of the key :returns: (ldns_signing_algorithm) the algorithm """ return _ldns.ldns_key_algorithm(self) #parameters: const ldns_key *, #retvals: ldns_signing_algorithm def dsa_key(self): """returns the (openssl) DSA struct contained in the key :returns: (DSA \*) """ return _ldns.ldns_key_dsa_key(self) #parameters: const ldns_key *, #retvals: DSA * def evp_key(self): """returns the (openssl) EVP struct contained in the key :returns: (EVP_PKEY \*) the RSA * structure in the key """ return _ldns.ldns_key_evp_key(self) #parameters: const ldns_key *, #retvals: EVP_PKEY * def expiration(self): """return the key's expiration date :returns: (uint32_t) the expiration date """ return _ldns.ldns_key_expiration(self) #parameters: const ldns_key *, #retvals: uint32_t def flags(self): """return the flag of the key :returns: (uint16_t) the flag """ return _ldns.ldns_key_flags(self) #parameters: const ldns_key *, #retvals: uint16_t def hmac_key(self): """return the hmac key data :returns: (unsigned char \*) the hmac key data """ return _ldns.ldns_key_hmac_key(self) #parameters: const ldns_key *, #retvals: unsigned char * def hmac_size(self): """return the hmac key size :returns: (size_t) the hmac key size """ return _ldns.ldns_key_hmac_size(self) #parameters: const ldns_key *, #retvals: size_t def inception(self): """return the key's inception date :returns: (uint32_t) the inception date """ return _ldns.ldns_key_inception(self) #parameters: const ldns_key *, #retvals: uint32_t def keytag(self): """return the keytag :returns: (uint16_t) the keytag """ return _ldns.ldns_key_keytag(self) #parameters: const ldns_key *, #retvals: uint16_t def origttl(self): """return the original ttl of the key :returns: (uint32_t) the original ttl """ return _ldns.ldns_key_origttl(self) #parameters: const ldns_key *, #retvals: uint32_t def pubkey_owner(self): """return the public key's owner :returns: (ldns_rdf \*) the owner """ return _ldns.ldns_key_pubkey_owner(self) #parameters: const ldns_key *, #retvals: ldns_rdf * def rsa_key(self): """returns the (openssl) RSA struct contained in the key :returns: (RSA \*) the RSA * structure in the key """ return _ldns.ldns_key_rsa_key(self) #parameters: const ldns_key *, #retvals: RSA * def set_algorithm(self,l): """Set the key's algorithm. :param l: the algorithm """ _ldns.ldns_key_set_algorithm(self,l) #parameters: ldns_key *,ldns_signing_algorithm, #retvals: def set_dsa_key(self,d): """Set the key's dsa data. :param d: the dsa data """ _ldns.ldns_key_set_dsa_key(self,d) #parameters: ldns_key *,DSA *, #retvals: def set_evp_key(self,e): """Set the key's evp key. :param e: the evp key """ _ldns.ldns_key_set_evp_key(self,e) #parameters: ldns_key *,EVP_PKEY *, #retvals: def set_expiration(self,e): """Set the key's expiration date (seconds after epoch). :param e: the expiration """ _ldns.ldns_key_set_expiration(self,e) #parameters: ldns_key *,uint32_t, #retvals: def set_flags(self,flags): """Set the key's flags. :param flags: the flags """ _ldns.ldns_key_set_flags(self,flags) #parameters: ldns_key *,uint16_t, #retvals: def set_hmac_key(self,hmac): """Set the key's hmac data. :param hmac: the raw key data """ _ldns.ldns_key_set_hmac_key(self,hmac) #parameters: ldns_key *,unsigned char *, #retvals: def set_hmac_size(self,hmac_size): """Set the key's hmac size. :param hmac_size: the size of the hmac data """ _ldns.ldns_key_set_hmac_size(self,hmac_size) #parameters: ldns_key *,size_t, #retvals: def set_inception(self,i): """Set the key's inception date (seconds after epoch). :param i: the inception """ _ldns.ldns_key_set_inception(self,i) #parameters: ldns_key *,uint32_t, #retvals: def set_keytag(self,tag): """Set the key's key tag. :param tag: the keytag """ _ldns.ldns_key_set_keytag(self,tag) #parameters: ldns_key *,uint16_t, #retvals: def set_origttl(self,t): """Set the key's original ttl. :param t: the ttl """ _ldns.ldns_key_set_origttl(self,t) #parameters: ldns_key *,uint32_t, #retvals: def set_pubkey_owner(self,r): """Set the key's pubkey owner. :param r: the owner """ _ldns.ldns_key_set_pubkey_owner(self,r) #parameters: ldns_key *,ldns_rdf *, #retvals: def set_rsa_key(self,r): """Set the key's rsa data. :param r: the rsa data """ _ldns.ldns_key_set_rsa_key(self,r) #parameters: ldns_key *,RSA *, #retvals: def set_use(self,v): """set the use flag :param v: the boolean value to set the _use field to """ _ldns.ldns_key_set_use(self,v) #parameters: ldns_key *,bool, #retvals: def use(self): """return the use flag :returns: (bool) the boolean value of the _use field """ return _ldns.ldns_key_use(self) #parameters: const ldns_key *, #retvals: bool #_LDNS_KEY_METHODS# %} } %nodefaultctor ldns_struct_key_list; //no default constructor & destructor %nodefaultdtor ldns_struct_key_list; %newobject ldns_key_list_new; %newobject ldns_key_list_pop_key; %delobject ldns_key_list_free; %delobject ldns_key_list_push_key; %rename(ldns_key_list) ldns_struct_key_list; #ifdef LDNS_DEBUG %rename(__ldns_key_list_free) ldns_key_list_free; %inline %{ void _ldns_key_list_free (ldns_key_list* k) { printf("******** LDNS_KEY_LIST free 0x%lX ************\n", (long unsigned int)k); ldns_key_list_free(k); } %} #else %rename(_ldns_key_list_free) ldns_key_list_free; #endif %extend ldns_struct_key_list { %pythoncode %{ def __init__(self): self.this = _ldns.ldns_key_list_new() if not self.this: raise Exception("Can't create class") __swig_destroy__ = _ldns._ldns_key_list_free def keys(self): """Key list iterator""" for i in range(0, self.key_count()): yield self.key(i) def __str__(self): i = 0 s = "" for k in self.keys(): i += 1 s += "key %d:\n %s\n" % (i, str(k).replace("\n","\n ")) return s #LDNS_KEY_LIST_METHODS_# def key(self,nr): """returns a pointer to the key in the list at the given position :param nr: the position in the list :returns: (ldns_key \*) the key """ return _ldns.ldns_key_list_key(self,nr) #parameters: const ldns_key_list *,size_t, #retvals: ldns_key * def key_count(self): """returns the number of keys in the key list :returns: (size_t) the numbers of keys in the list """ return _ldns.ldns_key_list_key_count(self) #parameters: const ldns_key_list *, #retvals: size_t def pop_key(self): """pops the last rr from a keylist :returns: (ldns_key \*) NULL if nothing to pop. Otherwise the popped RR """ return _ldns.ldns_key_list_pop_key(self) #parameters: ldns_key_list *, #retvals: ldns_key * def push_key(self,key): """pushes a key to a keylist :param key: the key to push :returns: (bool) false on error, otherwise true """ return _ldns.ldns_key_list_push_key(self,key) #parameters: ldns_key_list *,ldns_key *, #retvals: bool def set_key_count(self,count): """Set the keylist's key count to count. :param count: the count """ _ldns.ldns_key_list_set_key_count(self,count) #parameters: ldns_key_list *,size_t, #retvals: def set_use(self,v): """Set the 'use' flag for all keys in the list. :param v: The value to set the use flags to """ _ldns.ldns_key_list_set_use(self,v) #parameters: ldns_key_list *,bool, #retvals: #_LDNS_KEY_LIST_METHODS# %} } ldns-1.9.2/contrib/python/ldns_dnssec.i0000664000175000017500000004454715212267520017503 0ustar willemwillem/****************************************************************************** * ldns_dnssec.i: DNSSEC zone, name, rrs * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ %nodefaultctor ldns_dnssec_rrs; //no default constructor & destructor %nodefaultdtor ldns_dnssec_rrs; %newobject ldns_dnssec_rrs_new; %delobject ldns_dnssec_rrs_free; %extend ldns_dnssec_rrs { %pythoncode %{ def __init__(self): """Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs. :returns: (ldns_dnssec_rrs) the allocated data """ self.this = _ldns.ldns_dnssec_rrs_new() if not self.this: raise Exception("Can't create rrs instance") __swig_destroy__ = _ldns.ldns_dnssec_rrs_free #LDNS_DNSSEC_RRS_METHODS_# def add_rr(self,rr): """Adds an RR to the list of RRs. The list will remain ordered :param rr: the RR to add :returns: (ldns_status) LDNS_STATUS_OK on success """ return _ldns.ldns_dnssec_rrs_add_rr(self,rr) #parameters: ldns_dnssec_rrs *,ldns_rr *, #retvals: ldns_status #_LDNS_DNSSEC_RRS_METHODS# %} } // ================================================================================ // DNNSEC RRS // ================================================================================ %nodefaultctor ldns_dnssec_rrsets; //no default constructor & destructor %nodefaultdtor ldns_dnssec_rrsets; %newobject ldns_dnssec_rrsets_new; %delobject ldns_dnssec_rrsets_free; %extend ldns_dnssec_rrsets { %pythoncode %{ def __init__(self): """Creates a new list (entry) of RRsets. :returns: (ldns_dnssec_rrsets \*) instance """ self.this = _ldns.ldns_dnssec_rrsets_new() if not self.this: raise Exception("Can't create rrsets instance") __swig_destroy__ = _ldns.ldns_dnssec_rrsets_free def print_to_file(self, file, follow): """Print the given list of rrsets to the given file descriptor. :param file: file pointer :param follow: if set to false, only print the first RRset """ _ldns.ldns_dnssec_rrsets_print(file,self,follow) #parameters: FILE *,ldns_dnssec_rrsets *,bool, #retvals: #LDNS_DNSSEC_RRSETS_METHODS_# def add_rr(self,rr): """Add an ldns_rr to the corresponding RRset in the given list of RRsets. If it is not present, add it as a new RRset with 1 record. :param rr: the rr to add to the list of rrsets :returns: (ldns_status) LDNS_STATUS_OK on success """ return _ldns.ldns_dnssec_rrsets_add_rr(self,rr) #parameters: ldns_dnssec_rrsets *,ldns_rr *, #retvals: ldns_status def set_type(self,atype): """Sets the RR type of the rrset (that is head of the given list). :param atype: :returns: (ldns_status) LDNS_STATUS_OK on success """ return _ldns.ldns_dnssec_rrsets_set_type(self,atype) #parameters: ldns_dnssec_rrsets *,ldns_rr_type, #retvals: ldns_status def type(self): """Returns the rr type of the rrset (that is head of the given list). :returns: (ldns_rr_type) the rr type """ return _ldns.ldns_dnssec_rrsets_type(self) #parameters: ldns_dnssec_rrsets *, #retvals: ldns_rr_type #_LDNS_DNSSEC_RRSETS_METHODS# %} } // ================================================================================ // DNNSEC NAME // ================================================================================ %nodefaultctor ldns_dnssec_name; //no default constructor & destructor %nodefaultdtor ldns_dnssec_name; %newobject ldns_dnssec_name_new; %delobject ldns_dnssec_name_free; %extend ldns_dnssec_name { %pythoncode %{ def __init__(self): """Create a new instance of dnssec name.""" self.this = _ldns.ldns_dnssec_name_new() if not self.this: raise Exception("Can't create dnssec name instance") __swig_destroy__ = _ldns.ldns_dnssec_name_free def print_to_file(self,file): """Prints the RRs in the dnssec name structure to the given file descriptor. :param file: file pointer """ _ldns.ldns_dnssec_name_print(file, self) #parameters: FILE *,ldns_dnssec_name *, @staticmethod def new_frm_rr(raiseException=True): """Create a new instance of dnssec name for the given RR. :returns: (ldns_dnssec_name) instance """ name = _ldns.ldns_dnssec_name_new_frm_rr(self) if (not name) and (raiseException): raise Exception("Can't create dnssec name") return name #LDNS_DNSSEC_NAME_METHODS_# def add_rr(self,rr): """Inserts the given rr at the right place in the current dnssec_name No checking is done whether the name matches. :param rr: The RR to add :returns: (ldns_status) LDNS_STATUS_OK on success, error code otherwise """ return _ldns.ldns_dnssec_name_add_rr(self,rr) #parameters: ldns_dnssec_name *,ldns_rr *, #retvals: ldns_status def find_rrset(self,atype): """Find the RRset with the given type in within this name structure. :param atype: :returns: (ldns_dnssec_rrsets \*) the RRset, or NULL if not present """ return _ldns.ldns_dnssec_name_find_rrset(self,atype) #parameters: ldns_dnssec_name *,ldns_rr_type, #retvals: ldns_dnssec_rrsets * def name(self): """Returns the domain name of the given dnssec_name structure. :returns: (ldns_rdf \*) the domain name """ return _ldns.ldns_dnssec_name_name(self) #parameters: ldns_dnssec_name *, #retvals: ldns_rdf * def set_name(self,dname): """Sets the domain name of the given dnssec_name structure. :param dname: the domain name to set it to. This data is *not* copied. """ _ldns.ldns_dnssec_name_set_name(self,dname) #parameters: ldns_dnssec_name *,ldns_rdf *, #retvals: def set_nsec(self,nsec): """Sets the NSEC(3) RR of the given dnssec_name structure. :param nsec: the nsec rr to set it to. This data is *not* copied. """ _ldns.ldns_dnssec_name_set_nsec(self,nsec) #parameters: ldns_dnssec_name *,ldns_rr *, #retvals: #_LDNS_DNSSEC_NAME_METHODS# %} } // ================================================================================ // DNNSEC ZONE // ================================================================================ %nodefaultctor ldns_dnssec_zone; //no default constructor & destructor %nodefaultdtor ldns_dnssec_zone; %newobject ldns_dnssec_zone_new; %delobject ldns_dnssec_zone_free; %inline %{ ldns_status ldns_dnssec_zone_sign_defcb(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int cbtype) { if (cbtype == 0) return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_add_to_signatures, NULL); if (cbtype == 1) return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_leave_signatures, NULL); if (cbtype == 2) return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_delete_signatures, NULL); return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_replace_signatures, NULL); } ldns_status ldns_dnssec_zone_add_rr_(ldns_dnssec_zone *zone, ldns_rr *rr) { ldns_rr *new_rr; ldns_status status; new_rr = ldns_rr_clone(rr); /* * A clone of the RR is created to be stored in the DNSSEC zone. * The Python engine frees a RR object as soon it's reference count * reaches zero. The code must avoid double freeing or accessing of freed * memory. */ status = ldns_dnssec_zone_add_rr(zone, new_rr); if (status != LDNS_STATUS_OK) { ldns_rr_free(new_rr); } return status; } %} %extend ldns_dnssec_zone { %pythoncode %{ def __init__(self): """Creates a new dnssec_zone instance""" self.this = _ldns.ldns_dnssec_zone_new() if not self.this: raise Exception("Can't create dnssec zone instance") __swig_destroy__ = _ldns.ldns_dnssec_zone_free def print_to_file(self,file): """Prints the complete zone to the given file descriptor. :param file: file pointer """ _ldns.ldns_dnssec_zone_print(file, self) #parameters: FILE *, ldns_dnssec_zone *, #retvals: def create_nsec3s(self,new_rrs,algorithm,flags,iterations,salt_length,salt): """Adds NSEC3 records to the zone. :param new_rrs: :param algorithm: :param flags: :param iterations: :param salt_length: :param salt: :returns: (ldns_status) """ return _ldns.ldns_dnssec_zone_create_nsec3s(self,new_rrs,algorithm,flags,iterations,salt_length,salt) #parameters: ldns_dnssec_zone *,ldns_rr_list *,uint8_t,uint8_t,uint16_t,uint8_t,uint8_t *, #retvals: ldns_status def create_nsecs(self,new_rrs): """Adds NSEC records to the given dnssec_zone. :param new_rrs: ldns_rr's created by this function are added to this rr list, so the caller can free them later :returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise """ return _ldns.ldns_dnssec_zone_create_nsecs(self,new_rrs) #parameters: ldns_dnssec_zone *,ldns_rr_list *, #retvals: ldns_status def create_rrsigs(self,new_rrs,key_list,func,arg): """Adds signatures to the zone. :param new_rrs: the RRSIG RRs that are created are also added to this list, so the caller can free them later :param key_list: list of keys to sign with. :param func: Callback function to decide what keys to use and what to do with old signatures :param arg: Optional argument for the callback function :returns: (ldns_status) LDNS_STATUS_OK on success, error otherwise """ return _ldns.ldns_dnssec_zone_create_rrsigs(self,new_rrs,key_list,func,arg) #parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,int(*)(ldns_rr *, void *),void *, #retvals: ldns_status def sign_cb(self,new_rrs,key_list,func,arg): """signs the given zone with the given keys (with callback function) :param new_rrs: newly created resource records are added to this list, to free them later :param key_list: the list of keys to sign the zone with :param func: callback function that decides what to do with old signatures. This function takes an ldns_rr and an optional arg argument, and returns one of four values: * LDNS_SIGNATURE_LEAVE_ADD_NEW - leave the signature and add a new one for the corresponding key * LDNS_SIGNATURE_REMOVE_ADD_NEW - remove the signature and replace is with a new one from the same key * LDNS_SIGNATURE_LEAVE_NO_ADD - leave the signature and do not add a new one with the corresponding key * LDNS_SIGNATURE_REMOVE_NO_ADD - remove the signature and do not replace :param arg: optional argument for the callback function :returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise """ return _ldns.ldns_dnssec_zone_sign(self,new_rrs,key_list,func,arg) #parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,int(*)(ldns_rr *, void *),void *, #retvals: ldns_status def sign(self,new_rrs,key_list, cbtype=3): """signs the given zone with the given keys :param new_rrs: newly created resource records are added to this list, to free them later :param key_list: the list of keys to sign the zone with :param cb_type: specifies how to deal with old signatures, possible values: * 0 - ldns_dnssec_default_add_to_signatures, * 1 - ldns_dnssec_default_leave_signatures, * 2 - ldns_dnssec_default_delete_signatures, * 3 - ldns_dnssec_default_replace_signatures :returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise """ return _ldns.ldns_dnssec_zone_sign_defcb(self,new_rrs,key_list, cbtype) #parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *, #retvals: ldns_status def sign_nsec3(self,new_rrs,key_list,func,arg,algorithm,flags,iterations,salt_length,salt): """signs the given zone with the given new zone, with NSEC3 :param new_rrs: newly created resource records are added to this list, to free them later :param key_list: the list of keys to sign the zone with :param func: callback function that decides what to do with old signatures :param arg: optional argument for the callback function :param algorithm: the NSEC3 hashing algorithm to use :param flags: NSEC3 flags :param iterations: the number of NSEC3 hash iterations to use :param salt_length: the length (in octets) of the NSEC3 salt :param salt: the NSEC3 salt data :returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise """ return _ldns.ldns_dnssec_zone_sign_nsec3(self,new_rrs,key_list,func,arg,algorithm,flags,iterations,salt_length,salt) #parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,int(*)(ldns_rr *, void *),void *,uint8_t,uint8_t,uint16_t,uint8_t,uint8_t *, #retvals: ldns_status #LDNS_DNSSEC_ZONE_METHODS_# def add_empty_nonterminals(self): """Adds explicit dnssec_name structures for the empty nonterminals in this zone. (this is needed for NSEC3 generation) :returns: (ldns_status) """ return _ldns.ldns_dnssec_zone_add_empty_nonterminals(self) #parameters: ldns_dnssec_zone *, #retvals: ldns_status def add_rr(self,rr): """Adds the given RR to the zone. It find whether there is a dnssec_name with that name present. If so, add it to that, if not create a new one. Special handling of NSEC and RRSIG provided. :param rr: The RR to add :returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise """ return _ldns.ldns_dnssec_zone_add_rr_(self,rr) #parameters: ldns_dnssec_zone *,ldns_rr *, #retvals: ldns_status def find_rrset(self,dname,atype): """Find the RRset with the given name and type in the zone. :param dname: the domain name of the RRset to find :param atype: :returns: (ldns_dnssec_rrsets \*) the RRset, or NULL if not present """ return _ldns.ldns_dnssec_zone_find_rrset(self,dname,atype) #parameters: ldns_dnssec_zone *,ldns_rdf *,ldns_rr_type, #retvals: ldns_dnssec_rrsets * #_LDNS_DNSSEC_ZONE_METHODS# %} } ldns-1.9.2/contrib/python/docs/0000775000175000017500000000000015212267520015744 5ustar willemwillemldns-1.9.2/contrib/python/docs/Makefile0000664000175000017500000000460515212267520017411 0ustar willemwillem# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html web pickle htmlhelp latex changes linkcheck help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " pickle to make pickle files (usable by e.g. sphinx-web)" @echo " htmlhelp to make HTML files and a HTML help project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview over all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf build/* html: mkdir -p build/html build/doctrees LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html @echo @echo "Build finished. The HTML pages are in build/html." pickle: mkdir -p build/pickle build/doctrees LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle @echo @echo "Build finished; now you can process the pickle files or run" @echo " sphinx-web build/pickle" @echo "to start the sphinx-web server." web: pickle htmlhelp: mkdir -p build/htmlhelp build/doctrees LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in build/htmlhelp." latex: mkdir -p build/latex build/doctrees LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex @echo @echo "Build finished; the LaTeX files are in build/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: mkdir -p build/changes build/doctrees LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes @echo @echo "The overview file is in build/changes." linkcheck: mkdir -p build/linkcheck build/doctrees LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." ldns-1.9.2/contrib/python/docs/source/0000775000175000017500000000000015212267520017244 5ustar willemwillemldns-1.9.2/contrib/python/docs/source/install.rst0000664000175000017500000000422715212267520021451 0ustar willemwillemInstallation =================================== **Prerequisites** SWIG 1.3 and GNU make are required to build modules for Python 2.4 and higher (but lower than 3). In order to build modules for Python 3.2 or higher, SWIG in version 2.0.4 or higher is required. Note that Python 3.0 and 3.1 are not supported. In order to build this documentation the Sphinx Python documentation generator is required. **Download** The latest source codes can be downloaded from `here`_. .. _here: http://nlnetlabs.nl/projects/ldns/ **Compiling** After downloading the source code archive (this example uses ldns-1.6.13.tar.gz), pyLDNS can be enabled and compiled by typing:: > tar -xzf ldns-1.6.13.tar.gz > cd ldns-1.6.13 > ./configure --with-pyldns > make You need GNU make to compile pyLDNS; SWIG and Python development libraries to compile the extension module. **Selecting Target Python Interpreter** By default, the pyLDNS module builds for the default Python interpreter (i.e., the Python interpreter which can be accessed by just typing ``python`` in the command line). If you desire to build the pyLDNS module for a different Python version then you must specify the desired Python version by setting the ``PYTHON_VERSION`` variable during the configure phase:: > PYTHON_VERSION=3.2 ./configure --with-pyldns > make By default the pyLDNS compiles from sources for a single Python interpreter. Remember to execute scripts requiring pyLDNS in those Python interpreters which have pyLDNS installed. **Testing** If the compilation is successful, you can test the python LDNS extension module by executing the commands:: > cd contrib/python > make testenv > ./ldns-mx.py Again, remember to use the Python interpreter version which the pyLDNS module has been compiled with. The commands will start a new shell, in which several symbolic links will be set-up. When you exit the shell, then symbolic links will be deleted. In ``contrib/python/examples`` several simple Python scripts utilising pyLDNS can be found. These scripts demonstrate the capabilities of the LDNS library. **Installation** To install the libraries and it's extensions type:: > cd ldns-1.6.13 > make install ldns-1.9.2/contrib/python/docs/source/examples/0000775000175000017500000000000015212267520021062 5ustar willemwillemldns-1.9.2/contrib/python/docs/source/examples/example2.py0000775000175000017500000000215715212267520023161 0ustar willemwillem#!/usr/bin/python # -*- coding: utf-8 -*- import ldns import sys debug = True # Check args argc = len(sys.argv) name = "www.nic.cz" if argc < 2: print("Usage:", sys.argv[0], "domain [resolver_addr]") sys.exit(1) else: name = sys.argv[1] # Create resolver resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) # Custom resolver if argc > 2: # Clear previous nameservers ns = resolver.pop_nameserver() while ns != None: ns = resolver.pop_nameserver() ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) resolver.push_nameserver(ip) # Resolve DNS name pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) if pkt and pkt.answer(): # Debug if debug: print("NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() )) # SERVFAIL indicated bogus name if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL: print(name, "is bogus") # Check AD (Authenticated) bit if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR: if pkt.ad(): print(name, "is secure") else: print(name, "is insecure") ldns-1.9.2/contrib/python/docs/source/examples/example5.rst0000664000175000017500000000054415212267520023337 0ustar willemwillemExamine the results =============================== This example shows how to go through the obtained results .. literalinclude:: ../../../examples/ldns-mx2.py :language: python This snippet of code prints:: nic.cz. 1761 IN MX 20 mx.cznic.org. nic.cz. 1761 IN MX 10 mail.nic.cz. nic.cz. 1761 IN MX 15 mail4.nic.cz. ldns-1.9.2/contrib/python/docs/source/examples/example2.rst0000664000175000017500000000511215212267520023330 0ustar willemwillem.. _ex_dnssec: Querying DNS-SEC validators =========================== This basic example shows how to query validating resolver and evaluate answer. Resolving step by step ------------------------ For DNS queries, we need to initialize ldns resolver (covered in previous example). :: # Create resolver resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") resolver.set_dnssec(True) # Custom resolver if argc > 2: # Clear previous nameservers ns = resolver.pop_nameserver() while ns != None: ns = resolver.pop_nameserver() ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A) resolver.push_nameserver(ip) Note the second line :meth:`resolver.set_dnssec`, which enables DNSSEC OK bit in queries in order to get meaningful results. As we have resolver initialized, we can start querying for domain names : :: # Resolve DNS name pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN) if pkt and pkt.answer(): Now we evaluate result, where two flags are crucial : * Return code * AD flag (authenticated) When return code is `SERVFAIL`, it means that validating resolver marked requested name as **bogus** (or bad configuration). **AD** flag is set if domain name is authenticated **(secure)** or false if it's insecure. Complete source code -------------------- .. literalinclude:: ../../../examples/ldns-dnssec.py :language: python Testing ------- In order to get meaningful results, you have to enter IP address of validating resolver or setup your own (see howto). Execute `./example2.py` with options `domain name` and `resolver IP`, example: :: user@localhost# ./example2.py www.dnssec.cz 127.0.0.1 # Secure (Configured Unbound running on localhost) user@localhost# ./example2.py www.rhybar.cz 127.0.0.1 # Bogus Howto setup Unbound as validating resolver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Install Unbound according to instructions. Modify following options in `unbound.conf` (located in `/etc` or `/usr/local/etc`)/ Uncomment `module-config` and set `validator` before iterator. :: module-config: "validator iterator" Download DLV keys and update path in `unbound.conf`:: # DLV keys # Download from http://ftp.isc.org/www/dlv/dlv.isc.org.key dlv-anchor-file: "/usr/local/etc/unbound/dlv.isc.org.key" Update trusted keys (`.cz` for example):: # Trusted keys # For current key, see www.dnssec.cz trusted-keys-file: "/usr/local/etc/unbound/trusted.key" Now you should have well configured Unbound, so run it:: user@localhost# unbound -dv ldns-1.9.2/contrib/python/docs/source/examples/example3.rst0000664000175000017500000000027615212267520023337 0ustar willemwillemHigh-level functions =========================== This basic example shows how to get name by addr and vice versa. .. literalinclude:: ../../../examples/ldns-higher.py :language: python ldns-1.9.2/contrib/python/docs/source/examples/example4.rst0000664000175000017500000000035715212267520023340 0ustar willemwillemAXFR client with IDN support =============================== This example shows how to get AXFR working and how to get involved Internationalized Domain Names (IDN) .. literalinclude:: ../../../examples/ldns-axfr.py :language: python ldns-1.9.2/contrib/python/docs/source/examples/example7.rst0000664000175000017500000000037215212267520023340 0ustar willemwillemGenerate public/private key pair ======================================= This example shows how generate keys for DNSSEC (i.e. for signing a zone file according DNSSECbis). .. literalinclude:: ../../../examples/ldns-keygen.py :language: python ldns-1.9.2/contrib/python/docs/source/examples/index.rst0000664000175000017500000000031515212267520022722 0ustar willemwillemTutorials ============================== Here you can find a set of simple applications which utilizes the ldns library in Python environment. `Tutorials` .. toctree:: :maxdepth: 1 :glob: example* ldns-1.9.2/contrib/python/docs/source/examples/example8.rst0000664000175000017500000000153315212267520023341 0ustar willemwillemSigning of a zone file =============================== This example shows how to sign the content of the given zone file .. literalinclude:: ../../../examples/ldns-signzone.py :language: python In order to be able sign a zone file, you have to generate a key-pair using ``ldns-keygen.py``. Don't forget to modify tag number. Signing consists of three steps 1. In the first step, the content of a zone file is read and parsed. This can be done using :class:`ldns.ldns_zone` class. 2. In the second step, the private and public key is read and public key is inserted into zone (as DNSKEY). 3. In the last step, the DNSSEC zone instance is created and all the RRs from zone file are copied here. Then, all the records are signed using :meth:`ldns.ldns_zone.sign` method. If the signing was successful, the content of DNSSEC zone is written to a file. ldns-1.9.2/contrib/python/docs/source/examples/example1.rst0000664000175000017500000000406315212267520023333 0ustar willemwillemResolving the MX records ============================== This basic example shows how to create a resolver which asks for MX records which contain the information about mail servers. :: #!/usr/bin/python # # MX is a small program that prints out the mx records for a particular domain # import ldns resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") dname = ldns.ldns_dname("nic.cz") pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) if (pkt): mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) if (mx): mx.sort() print mx Resolving step by step ------------------------ First of all we import :mod:`ldns` extension module which make LDNS functions and classes accessible:: import ldns If importing fails, it means that Python cannot find the module or ldns library. Then we create the resolver by :meth:`ldns.ldns_resolver.new_frm_file` constructor :: resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf") and domain name variable dname:: dname = ldns.ldns_dname("nic.cz") To create a resolver you may also use:: resolver = ldns.ldns_resolver.new_frm_file(None) which behaves in the same manner as the command above. In the third step we tell the resolver to query for our domain, type MX, of class IN:: pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) The function should return a packet if everything goes well and this packet will contain resource records we asked for. Note that there exists a simpler way. Instead of using a dname variable, we can use a string which will be automatically converted. :: pkt = resolver.query("fit.vutbr.cz", ldns.LDNS_RR_TYPE_MX, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) Now, we test whether the resolver returns a packet and then get all RRs of type MX from the answer packet and store them in list mx:: if (pkt): mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER) If this list is not empty, we sort and print the content to stdout:: if (mx): mx.sort() print mx ldns-1.9.2/contrib/python/docs/source/examples/example6.rst0000664000175000017500000000037515212267520023342 0ustar willemwillemRead zone file =============================== This example shows how to read the content of a zone file .. literalinclude:: ../../../examples/ldns-zone.py :language: python Zone file ``zone.txt``: .. literalinclude:: ../../../examples/zone.txt ldns-1.9.2/contrib/python/docs/source/modules/0000775000175000017500000000000015212267520020714 5ustar willemwillemldns-1.9.2/contrib/python/docs/source/modules/ldns_buffer.rst0000664000175000017500000000026315212267520023740 0ustar willemwillemClass ldns_buffer ================================ .. automodule:: ldns Class ldns_buffer ------------------------------ .. autoclass:: ldns_buffer :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_key.rst0000664000175000017500000000025215212267520023255 0ustar willemwillemClass ldns_key ================================ .. automodule:: ldns Class ldns_key ------------------------------ .. autoclass:: ldns_key :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_func.rst0000664000175000017500000001553615212267520023433 0ustar willemwillemVarious functions ================================ Here you can find list of functions that are not assigned to the classes. These functions have the same parameters as LDNS functions of the same name. You are encouraged to read the LDNS documentation. **List of functions** * ldns_algorithm2buffer_str * ldns_bget_keyword_data * ldns_bget_token * ldns_bgetc * ldns_bskipcs * ldns_bubblebabble * ldns_buffer2pkt_wire * ldns_buffer2str * ldns_calc_keytag * ldns_calc_keytag_raw * ldns_cert_algorithm2buffer_str * ldns_convert_dsa_rrsig_asn12rdf * ldns_convert_dsa_rrsig_rdf2asn1 * ldns_create_nsec * ldns_create_nsec3 * ldns_dname2buffer_wire * ldns_dname2canonical * ldns_dnssec_build_data_chain * ldns_dnssec_chain_nsec3_list * ldns_dnssec_create_nsec * ldns_dnssec_create_nsec3 * ldns_dnssec_create_nsec_bitmap * ldns_dnssec_data_chain_deep_free * ldns_dnssec_data_chain_free * ldns_dnssec_data_chain_new * ldns_dnssec_data_chain_print * ldns_dnssec_default_add_to_signatures * ldns_dnssec_default_delete_signatures * ldns_dnssec_default_leave_signatures * ldns_dnssec_default_replace_signatures * ldns_dnssec_derive_trust_tree * ldns_dnssec_derive_trust_tree_dnskey_rrset * ldns_dnssec_derive_trust_tree_ds_rrset * ldns_dnssec_derive_trust_tree_no_sig * ldns_dnssec_derive_trust_tree_normal_rrset * ldns_dnssec_get_dnskey_for_rrsig * ldns_dnssec_get_rrsig_for_name_and_type * ldns_dnssec_nsec3_closest_encloser * ldns_dnssec_pkt_get_rrsigs_for_name_and_type * ldns_dnssec_pkt_get_rrsigs_for_type * ldns_dnssec_pkt_has_rrsigs * ldns_dnssec_remove_signatures * ldns_dnssec_trust_tree_add_parent * ldns_dnssec_trust_tree_contains_keys * ldns_dnssec_trust_tree_depth * ldns_dnssec_trust_tree_free * ldns_dnssec_trust_tree_new * ldns_dnssec_trust_tree_print * ldns_dnssec_verify_denial * ldns_dnssec_verify_denial_nsec3 * ldns_fetch_valid_domain_keys * ldns_fget_keyword_data * ldns_fget_keyword_data_l * ldns_fget_token * ldns_fget_token_l * ldns_fskipcs * ldns_fskipcs_l * ldns_get_bit * ldns_get_bit_r * ldns_get_errorstr_by_id * ldns_get_rr_class_by_name * ldns_get_rr_list_addr_by_name * ldns_get_rr_list_hosts_frm_file * ldns_get_rr_list_hosts_frm_fp * ldns_get_rr_list_hosts_frm_fp_l * ldns_get_rr_list_name_by_addr * ldns_get_rr_type_by_name * ldns_getaddrinfo * ldns_hexdigit_to_int * ldns_hexstring_to_data * ldns_init_random * ldns_int_to_hexdigit * ldns_is_rrset * ldns_key2buffer_str * ldns_key2rr * ldns_key2str * ldns_lookup_by_id * ldns_lookup_by_name * ldns_native2rdf_int16 * ldns_native2rdf_int16_data * ldns_native2rdf_int32 * ldns_native2rdf_int8 * ldns_nsec3_add_param_rdfs * ldns_nsec3_algorithm * ldns_nsec3_bitmap * ldns_nsec3_flags * ldns_nsec3_hash_name * ldns_nsec3_hash_name_frm_nsec3 * ldns_nsec3_iterations * ldns_nsec3_next_owner * ldns_nsec3_optout * ldns_nsec3_salt * ldns_nsec3_salt_data * ldns_nsec3_salt_length * ldns_nsec_bitmap_covers_type * ldns_nsec_covers_name * ldns_nsec_get_bitmap * ldns_nsec_type_check * ldns_octet * ldns_pkt2buffer_str * ldns_pkt2buffer_wire * ldns_pkt2str * ldns_pkt2wire * ldns_pktheader2buffer_str * ldns_power * ldns_print_rr_rdf * ldns_rbtree_create * ldns_rbtree_delete * ldns_rbtree_find_less_equal * ldns_rbtree_first * ldns_rbtree_free * ldns_rbtree_init * ldns_rbtree_insert * ldns_rbtree_insert_vref * ldns_rbtree_last * ldns_rbtree_next * ldns_rbtree_previous * ldns_rbtree_search * ldns_rdf2buffer_str * ldns_rdf2buffer_str_a * ldns_rdf2buffer_str_aaaa * ldns_rdf2buffer_str_alg * ldns_rdf2buffer_str_apl * ldns_rdf2buffer_str_b64 * ldns_rdf2buffer_str_cert_alg * ldns_rdf2buffer_str_class * ldns_rdf2buffer_str_dname * ldns_rdf2buffer_str_hex * ldns_rdf2buffer_str_int16 * ldns_rdf2buffer_str_int16_data * ldns_rdf2buffer_str_ipseckey * ldns_rdf2buffer_str_loc * ldns_rdf2buffer_str_nsap * ldns_rdf2buffer_str_nsec * ldns_rdf2buffer_str_period * ldns_rdf2buffer_str_str * ldns_rdf2buffer_str_tsig * ldns_rdf2buffer_str_tsigtime * ldns_rdf2buffer_str_type * ldns_rdf2buffer_str_unknown * ldns_rdf2buffer_str_wks * ldns_rdf2buffer_wire * ldns_rdf2buffer_wire_canonical * ldns_rdf2native_int16 * ldns_rdf2native_int32 * ldns_rdf2native_int8 * ldns_rdf2native_sockaddr_storage * ldns_rdf2native_time_t * ldns_rdf2rr_type * ldns_rdf2str * ldns_rdf2wire * ldns_read_anchor_file * ldns_read_uint16 * ldns_read_uint32 * ldns_rr2buffer_str * ldns_rr2buffer_wire * ldns_rr2buffer_wire_canonical * ldns_rr2canonical * ldns_rr2str * ldns_rr2wire * ldns_rrsig2buffer_wire * ldns_send * ldns_send_buffer * ldns_set_bit * ldns_sign_public * ldns_sockaddr_storage2rdf * ldns_str2period * ldns_str2rdf_a * ldns_str2rdf_aaaa * ldns_str2rdf_alg * ldns_str2rdf_apl * ldns_str2rdf_b32_ext * ldns_str2rdf_b64 * ldns_str2rdf_cert_alg * ldns_str2rdf_class * ldns_str2rdf_dname * ldns_str2rdf_hex * ldns_str2rdf_int16 * ldns_str2rdf_int32 * ldns_str2rdf_int8 * ldns_str2rdf_loc * ldns_str2rdf_nsap * ldns_str2rdf_nsec * ldns_str2rdf_nsec3_salt * ldns_str2rdf_period * ldns_str2rdf_service * ldns_str2rdf_str * ldns_str2rdf_time * ldns_str2rdf_tsig * ldns_str2rdf_type * ldns_str2rdf_unknown * ldns_str2rdf_wks * ldns_tcp_bgsend * ldns_tcp_connect * ldns_tcp_read_wire * ldns_tcp_send * ldns_tcp_send_query * ldns_traverse_postorder * ldns_tsig_algorithm * ldns_tsig_keydata * ldns_tsig_keydata_clone * ldns_tsig_keyname * ldns_tsig_keyname_clone * ldns_udp_bgsend * ldns_udp_connect * ldns_udp_read_wire * ldns_udp_send * ldns_udp_send_query * ldns_update_pkt_new * ldns_update_pkt_tsig_add * ldns_update_prcount * ldns_update_set_adcount * ldns_update_set_prcount * ldns_update_set_upcount * ldns_update_soa_mname * ldns_update_soa_zone_mname * ldns_update_upcount * ldns_update_zocount * ldns_validate_domain_dnskey * ldns_validate_domain_ds * ldns_verify * ldns_verify_rrsig * ldns_verify_rrsig_buffers * ldns_verify_rrsig_buffers_raw * ldns_verify_rrsig_dsa * ldns_verify_rrsig_dsa_raw * ldns_verify_rrsig_keylist * ldns_verify_rrsig_rsamd5 * ldns_verify_rrsig_rsamd5_raw * ldns_verify_rrsig_rsasha1 * ldns_verify_rrsig_rsasha1_raw * ldns_verify_rrsig_rsasha256_raw * ldns_verify_rrsig_rsasha512_raw * ldns_verify_trusted * ldns_version * ldns_wire2dname * ldns_wire2pkt * ldns_wire2rdf * ldns_wire2rr * ldns_write_uint16 * ldns_write_uint32 * ldns_write_uint64_as_uint48 * mktime_from_utc * qsort_rr_compare_nsec3 ldns-1.9.2/contrib/python/docs/source/modules/ldns_dnssec.rst0000664000175000017500000000103415212267520023743 0ustar willemwillemClass ldns_dnssec_zone ================================ .. automodule:: ldns Class ldns_dnssec_zone ------------------------------ .. autoclass:: ldns_dnssec_zone :members: :undoc-members: Class ldns_dnssec_name ------------------------------ .. autoclass:: ldns_dnssec_name :members: :undoc-members: Class ldns_dnssec_rrsets ------------------------------ .. autoclass:: ldns_dnssec_rrsets :members: :undoc-members: Class ldns_dnssec_rrs ------------------------------ .. autoclass:: ldns_dnssec_rrs :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_pkt.rst0000664000175000017500000000025215212267520023263 0ustar willemwillemClass ldns_pkt ================================ .. automodule:: ldns Class ldns_pkt ------------------------------ .. autoclass:: ldns_pkt :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns.rst0000664000175000017500000000206115212267520022405 0ustar willemwillemLDNS module documentation ================================ Here you can find the documentation of pyLDNS extension module. This module consists of several classes and a couple of functions. .. toctree:: :maxdepth: 1 :glob: ldns_resolver ldns_pkt ldns_rr ldns_rdf ldns_dname ldns_rr_list ldns_zone ldns_key ldns_key_list ldns_buffer ldns_dnssec ldns_func **Differences against libLDNS** * You don't need to use ldns-compare functions, instances can be compared using standard operators <, >, = :: if (some_rr.owner() == another_rr.rdf(1)): pass * Classes contain static methods that create new instances, the name of these methods starts with the new\_ prefix (e.g. :meth:`ldns.ldns_pkt.new_frm_file`). * Is it possible to print the content of an object using ``print objinst`` (see :meth:`ldns.ldns_resolver.get_addr_by_name`). * Classes contain write_to_buffer method that writes the content into buffer. * All the methods that consume parameter of (const ldns_rdf) type allows to use string instead (see :meth:`ldns.ldns_resolver.query`). ldns-1.9.2/contrib/python/docs/source/modules/ldns_zone.rst0000664000175000017500000000025515212267520023443 0ustar willemwillemClass ldns_zone ================================ .. automodule:: ldns Class ldns_zone ------------------------------ .. autoclass:: ldns_zone :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_dname.rst0000664000175000017500000000026015212267520023550 0ustar willemwillemClass ldns_dname ================================ .. automodule:: ldns Class ldns_dname ------------------------------ .. autoclass:: ldns_dname :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_rdf.rst0000664000175000017500000000171215212267520023242 0ustar willemwillemClass ldns_rdf ================================ .. automodule:: ldns Class ldns_rdf ------------------------------ .. autoclass:: ldns_rdf :members: :undoc-members: Predefined constants ------------------------------ **RDF TYPE** * LDNS_RDF_TYPE_NONE, * LDNS_RDF_TYPE_DNAME, * LDNS_RDF_TYPE_INT8, * LDNS_RDF_TYPE_INT16, * LDNS_RDF_TYPE_INT32, * LDNS_RDF_TYPE_A, * LDNS_RDF_TYPE_AAAA, * LDNS_RDF_TYPE_STR, * LDNS_RDF_TYPE_APL, * LDNS_RDF_TYPE_B32_EXT, * LDNS_RDF_TYPE_B64, * LDNS_RDF_TYPE_HEX, * LDNS_RDF_TYPE_NSEC, * LDNS_RDF_TYPE_TYPE, * LDNS_RDF_TYPE_CLASS, * LDNS_RDF_TYPE_CERT_ALG, * LDNS_RDF_TYPE_ALG, * LDNS_RDF_TYPE_UNKNOWN, * LDNS_RDF_TYPE_TIME, * LDNS_RDF_TYPE_PERIOD, * LDNS_RDF_TYPE_TSIGTIME, * LDNS_RDF_TYPE_HIP, * LDNS_RDF_TYPE_INT16_DATA, * LDNS_RDF_TYPE_SERVICE, * LDNS_RDF_TYPE_LOC, * LDNS_RDF_TYPE_WKS, * LDNS_RDF_TYPE_NSAP, * LDNS_RDF_TYPE_IPSECKEY, * LDNS_RDF_TYPE_NSEC3_SALT, * LDNS_RDF_TYPE_NSEC3_NEXT_OWNER ldns-1.9.2/contrib/python/docs/source/modules/ldns_rr.rst0000664000175000017500000000043715212267520023115 0ustar willemwillemClass ldns_rr ================================ .. automodule:: ldns Class ldns_rr ------------------------------ .. autoclass:: ldns_rr :members: :undoc-members: Class ldns_rr_descriptor ------------------------------ .. autoclass:: ldns_rr_descriptor :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_rr_list.rst0000664000175000017500000000026615212267520024150 0ustar willemwillemClass ldns_rr_list ================================ .. automodule:: ldns Class ldns_rr_list ------------------------------ .. autoclass:: ldns_rr_list :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_key_list.rst0000664000175000017500000000027115212267520024311 0ustar willemwillemClass ldns_key_list ================================ .. automodule:: ldns Class ldns_key_list ------------------------------ .. autoclass:: ldns_key_list :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/modules/ldns_resolver.rst0000664000175000017500000000027315212267520024331 0ustar willemwillemClass ldns_resolver ================================ .. automodule:: ldns Class ldns_resolver ------------------------------ .. autoclass:: ldns_resolver :members: :undoc-members: ldns-1.9.2/contrib/python/docs/source/index.rst0000664000175000017500000000151415212267520021106 0ustar willemwillemPyLDNS documentation ======================================= PyLDNS provides an `LDNS`_ wrapper (Python extension module) - the thinnest layer over the library possible. Everything you can do from the C API, you can do from Python, but with less effort. The purpose of porting LDNS library to Python is to simplify DNS programming and usage of LDNS, however, still preserve the performance of this library as the speed represents the main benefit of LDNS. The proposed object approach allows the users to be concentrated at the essential part of application only and don't bother with deallocation of objects and so on. .. _LDNS: http://www.nlnetlabs.nl/projects/ldns/ Contents ---------- .. toctree:: :maxdepth: 2 install.rst examples/index.rst modules/ldns Indices and tables ------------------- * :ref:`genindex` * :ref:`search` ldns-1.9.2/contrib/python/docs/source/conf.py0000664000175000017500000001322415212267520020545 0ustar willemwillem# -*- coding: utf-8 -*- # # Unbound documentation build configuration file, created by # sphinx-quickstart on Fri Jan 2 19:14:13 2009. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),'../../'))) #print sys.path # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = 'pyLDNS' copyright = '2009-2013, Karel Slany, Zdenek Vasicek' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. # # The short X.Y version. version = '1.6' # The full version, including alpha/beta/rc tags. release = '1.6.17' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directories, that shouldn't be searched # for source files. #exclude_dirs = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'default.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (within the static path) to place at the top of # the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. html_use_modindex = False # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. html_copy_source = False # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'ldnsdoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'ldns-doc.tex', 'LDNS Documentation', 'Karel Slany, Zdenek Vasicek', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True ldns-1.9.2/contrib/python/file_py3.i0000664000175000017500000000774615212267520016716 0ustar willemwillem/* * file_py3.i: Typemaps for FILE* for Python 3 * * Copyright (c) 2011, Karel Slany (karel.slany AT nic.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ %{ #include #include %} %types(FILE *); /* converts basic file descriptor flags onto a string */ %fragment("fdfl_to_str", "header") { const char * fdfl_to_str(int fdfl) { static const char * const file_mode[] = {"w+", "w", "r"}; if (fdfl & O_RDWR) { return file_mode[0]; } else if (fdfl & O_WRONLY) { return file_mode[1]; } else { return file_mode[2]; } } } %fragment("obj_to_file","header", fragment="fdfl_to_str") { FILE * obj_to_file(PyObject *obj) { %#if PY_VERSION_HEX >= 0x03000000 int fd, fdfl; FILE *fp; if (!PyLong_Check(obj) && /* is not an integer */ PyObject_HasAttrString(obj, "fileno") && /* has fileno method */ (PyObject_CallMethod(obj, "flush", NULL) != NULL) && /* flush() succeeded */ ((fd = PyObject_AsFileDescriptor(obj)) != -1) && /* got file descriptor */ ((fdfl = fcntl(fd, F_GETFL)) != -1) /* got descriptor flags */ ) { fp = fdopen(dup(fd), fdfl_to_str(fdfl)); /* the FILE* must be flushed and closed after being used */ #ifdef SWIG_FILE3_DEBUG fprintf(stderr, "opening fd %d (fl %d \"%s\") as FILE %p\n", fd, fdfl, fdfl_to_str(fdfl), (void *)fp); #endif return fp; } %#endif return NULL; } } /* returns -1 if error occurred */ %fragment("dispose_file", "header") { int dispose_file(FILE **fp) { #ifdef SWIG_FILE3_DEBUG fprintf(stderr, "flushing FILE %p\n", (void *)fp); #endif if (*fp == NULL) { return 0; } if ((fflush(*fp) == 0) && /* flush file */ (fclose(*fp) == 0)) { /* close file */ *fp = NULL; return 0; } return -1; } } %typemap(arginit, noblock = 1) FILE* { $1 = NULL; } %typemap(check, noblock = 1) FILE* { if ($1 == NULL) { /* The generated wrapper function raises TypeError on mismatching types. */ SWIG_exception_fail(SWIG_TypeError, "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'"); } } %typemap(in, noblock = 1, fragment = "obj_to_file") FILE* { $1 = obj_to_file($input); } %typemap(freearg, noblock = 1, fragment = "dispose_file") FILE* { if (dispose_file(&$1) == -1) { SWIG_exception_fail(SWIG_IOError, "closing file in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'"); } } ldns-1.9.2/contrib/python/Changelog0000664000175000017500000001165615212267520016637 0ustar willemwillem1.6.17 2014-01-10 * Added ldns_rdf.data_as_bytearray(). The method returns a bytearray object containing rdf data. * Changed the behaviour of ldns_resolver.trusted_key() in order to prevent memory corruption and leaks. * Fixed memory leaks when destroying ldns_resolver. * Removed ldns_pkt.section_count(), ldns_resolver.set_searchlist_count() because it is marked static in the library. * Added ldns_pkt.new(), ldns_resolver.new(). * Marked as returning new object ldns_pkt.get_section_clone(), ldns_resolver.get_addr_by_name(), ldns_resolver.get_name_by_addr(), ldns_resolver.search(). * Added push cloning for ldns_pkt.safe_push_rr(), ldns_pkt.safe_push_rr_list(), ldns_pkt.set_additional(), ldns_pkt.set_answer(), ldns_pkt.set_answerfrom(), ldns_pkt.set_authority(), ldns_pkt.set_edns_data(), ldns_pkt.set_question(), ldns_pkt.set_tsig(), ldns_resolver.set_dnssec_anchors(), ldns_resolver.set_domain(). * Added pull cloning for ldns_pkt.answerfrom(), ldns_pkt.edns_data(), ldns_pkt.tsig(), ldns_resolver.axfr_last_pkt(), ldns_resolver.dnssec_anchors(), ldns_resolver.domain(), ldns_resolver.tsig_algorithm(), ldns_resolver.tsig_keydata(), ldns_resolver.tsig_keyname(). * Method ldns_rdf.reverse() now throws an exception when not applied on dname rdfs. This is to prevent assertion fails in ldns' C code. 1.6.16 2012-11-13 * Fix typo in ldns_struct_pkt.opcode2str 1.6.14 2012-10-23 * Added rich comparison methods for ldns_dname, ldns_rdf, ldns_rr and ldns_rr_list classes. * Added deprecation warnings into ldns_rr.new_frm_fp() and ldns_rr.new_frm_fp_l() and others. * Fixed ldns_rr.set_rdf(), which may cause memory leaks, because it returns new objects (in the scope of Python). Also it leaked memory, when the call was not successful. * Fixed ldns_get_rr_list_hosts_frm_file, marked as newobject. * Fixed ldns_rr_list.cat() to return bool as mentioned in documentation. * Fixed ldns_rr_list_cat_clone, marked as newobject. * Fixed ldns_rr_list.new_frm_file(). Exception argument was invalid. * Fixed ldns_rr_list.push_rr() to return bool as mentioned in documentation. * Fixed ldns_rr_list.push_rr_list() to return bool as mentioned in documentation. * Fixed ldns_rr_list.set_rr(), which caused memory corruption, double free problems and memory leaks. (The wrapper used original function instead of its push cloned variant which was missing.) * Fixed ldns_rr_list.set_rr_count(), added python exception raise in order to avoid assertion failure. * Fixed ldns_rr_list.subtype_by_rdf(), marked as newobject. * Added ldns_rr.to_canonical(), ldns_rr.is_question(), ldns_rr.type_by_name(), ldns_rr.class_by_name(), ldns_rr_list.new(), ldns_rr.set_question(). * Modified ldns_rr_list.owner() and ldns_rr.owner(), now returns ldns_dname. * Fixed assertion failures for several methods when receiving incorrect but syntactically valid arguments (i.e., ldns_rr.a_address(), ldns_rr.dnskey_algorithm(), ldns_rr.dnskey_flags(), ldns_rr.dnskey_key(), ldns_rr.dnskey_protocol(), ldns_rr.mx_exchange(), ldns_rr.mx_preference(), ldns_rr.ns_nsdname(), ldns_rr.owner(), ldns_rr.rdf(), ldns_rr.rrsig_algorithm(), ldns_rr.rrsig_expiration(), ldns_rr.rrsig_inception(), ldns_rr.rrsig_keytag(), ldns_rr.rrsig_labels(), ldns_rr.rrsig_origttl(), ldns_rr.rrsig_sig(), ldns_rr.rrsig_signame(), ldns_rr.rrsig_typecovered(), ldns_rr_list.owner(), ldns_rr_list.rr()) * Fixed ldns_rr.a_address(), which was asserting when called on non A or AAAA type rr. Now returns None when fails. * Added scripts for testing the basic functionality of the ldns_rr, ldns_rr_descriptor and ldns_rr_list class code. * Improved documentation of ldns_rr, ldns_rr_descriptor and ldns_rr_list. * Fixed automatic conversion from Python string to ldns_rdf and ldns_dname. Caused memory corruption when using Python 3. * The Python 3 wrapper code now raises TypeError instead of ValueError when receiving a non FILE * argument when it should be a FILE *. * Fixed wrong handling of _ldns_rr_list_free() and _ldns_rr_list_deep_free() when compiling with LDNS_DEBUG directive. * Fixed malfunctioning ldns.ldns_rdf_new_frm_fp_l(). * Fixed malfunctioning ldns_drf.absolute() and ldns_dname.absolute(). * Marked several functions related to ldns_rdf and ldns_buffer as returning new objects. * Method operating on ldns_dnames and returning dname ldns_rdfs now return ldns_dname instances. * Improved documentation of ldns_buffer, ldns_rdf and ldns_dname classes. * Methods ldns_buffer.available() and ldns_buffer.available_at() now return bool types as described in the documentation. * Added scripts for testing the basic functionality of the ldns_buffer, ldns_rdf, ldns_dname class code. * Added deprecation warnings to ldns_rdf methods operating on dname rdfs. The user is encouraged to converts dname ldns_rdfs to ldns_dnames. * Extended ldns_dname constructor to accept ldns_rdfs containing dnames. ldns-1.9.2/contrib/python/ldns.i0000664000175000017500000003427115212267520016135 0ustar willemwillem/* * ldns.i: LDNS interface file * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ %module ldns #pragma SWIG nowarn=454 %{ #include "ldns.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include %} //#define LDNS_DEBUG //#define SWIG_FILE3_DEBUG %include "stdint.i" // uint_16_t is known type now #ifdef PY3 %include "file_py3.i" // python 3 FILE * #else %include "file.i" // FILE * #endif %include "typemaps.i" /* ========================================================================= */ /* Preliminary Python code. */ /* ========================================================================= */ %pythoncode %{ # # Use and don't ignore DeprecationWarning and # PendingDeprecationWarning. # import warnings warnings.filterwarnings("module", category=DeprecationWarning) warnings.filterwarnings("module", category=PendingDeprecationWarning) %} /* Tell SWIG how to handle ssize_t as input parameter. */ %typemap(in, noblock=1) (ssize_t) { int $1_res = 0; long val; $1_res = SWIG_AsVal_long($input, &val); if (!SWIG_IsOK($1_res)) { SWIG_exception_fail(SWIG_ArgError($1_res), "in method '" "$symname" "', argument " "$argnum" " of type '" "$type""'"); } $1 = val; } %inline %{ struct timeval* ldns_make_timeval(uint32_t sec, uint32_t usec) { struct timeval* res = (struct timeval*)malloc(sizeof(*res)); res->tv_sec = sec; res->tv_usec = usec; return res; } uint32_t ldns_read_timeval_sec(struct timeval* t) { return (uint32_t)t->tv_sec; } uint32_t ldns_read_timeval_usec(struct timeval* t) { return (uint32_t)t->tv_usec; } %} %immutable ldns_struct_lookup_table::name; %immutable ldns_struct_rr_descriptor::_name; %immutable ldns_error_str; %immutable ldns_signing_algorithms; %immutable ldns_tsig_credentials_struct::algorithm; %immutable ldns_tsig_credentials_struct::keyname; %immutable ldns_tsig_credentials_struct::keydata; //*_new_frm_fp_l %apply int *OUTPUT { (int *line_nr) }; %apply uint32_t *OUTPUT { uint32_t *default_ttl}; // wire2pkt %apply (char *STRING, int LENGTH) { (const char *str, int len) }; %include "ldns_packet.i" %include "ldns_resolver.i" %include "ldns_rr.i" %include %inline %{ int Python_str_Check(PyObject *o) { #if PY_VERSION_HEX>=0x03000000 return PyUnicode_Check(o); #else return PyString_Check(o); #endif } %} %include "ldns_rdf.i" %include "ldns_zone.i" %include "ldns_key.i" %include "ldns_buffer.i" %include "ldns_dnssec.i" %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include %include typedef struct ldns_dnssec_name { }; typedef struct ldns_dnssec_rrs { }; typedef struct ldns_dnssec_rrsets { }; typedef struct ldns_dnssec_zone { }; // ================================================================================ %include "ldns_dname.i" %inline %{ PyObject* ldns_rr_new_frm_str_(const char *str, uint32_t default_ttl, ldns_rdf* origin, ldns_rdf* prev) //returns tuple (status, ldns_rr, prev) { PyObject* tuple; /* origin and prev have to be cloned in order to decouple the data * from the python wrapper */ if (origin != NULL) origin = ldns_rdf_clone(origin); if (prev != NULL) prev = ldns_rdf_clone(prev); ldns_rdf *p_prev = prev; ldns_rdf **pp_prev = &p_prev; if (p_prev == 0) pp_prev = 0; ldns_rr *p_rr = 0; ldns_rr **pp_rr = &p_rr; ldns_status st = ldns_rr_new_frm_str(pp_rr, str, default_ttl, origin, pp_prev); tuple = PyTuple_New(3); PyTuple_SetItem(tuple, 0, SWIG_From_int(st)); PyTuple_SetItem(tuple, 1, (st == LDNS_STATUS_OK) ? SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); PyTuple_SetItem(tuple, 2, (p_prev != prev) ? SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); return tuple; } PyObject* ldns_rr_new_frm_fp_(FILE *fp, uint32_t default_ttl, ldns_rdf* origin, ldns_rdf* prev) //returns tuple (status, ldns_rr, ttl, origin, prev) { uint32_t defttl = default_ttl; uint32_t *p_defttl = &defttl; if (defttl == 0) p_defttl = 0; /* origin and prev have to be cloned in order to decouple the data * from the python wrapper */ if (origin != NULL) origin = ldns_rdf_clone(origin); if (prev != NULL) prev = ldns_rdf_clone(prev); ldns_rdf *p_origin = origin; ldns_rdf **pp_origin = &p_origin; //if (p_origin == 0) pp_origin = 0; ldns_rdf *p_prev = prev; ldns_rdf **pp_prev = &p_prev; //if (p_prev == 0) pp_prev = 0; ldns_rr *p_rr = 0; ldns_rr **pp_rr = &p_rr; ldns_status st = ldns_rr_new_frm_fp(pp_rr, fp, p_defttl, pp_origin, pp_prev); PyObject* tuple; tuple = PyTuple_New(5); int idx = 0; PyTuple_SetItem(tuple, idx, SWIG_From_int(st)); idx++; PyTuple_SetItem(tuple, idx, (st == LDNS_STATUS_OK) ? SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); idx++; PyTuple_SetItem(tuple, idx, SWIG_From_int(defttl)); idx++; PyTuple_SetItem(tuple, idx, SWIG_NewPointerObj(SWIG_as_voidptr(p_origin), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 )); idx++; PyTuple_SetItem(tuple, idx, SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 )); return tuple; } PyObject* ldns_rr_new_frm_fp_l_(FILE *fp, uint32_t default_ttl, ldns_rdf* origin, ldns_rdf* prev) //returns tuple (status, ldns_rr, line, ttl, origin, prev) { int linenr = 0; int *p_linenr = &linenr; uint32_t defttl = default_ttl; uint32_t *p_defttl = &defttl; if (defttl == 0) p_defttl = 0; /* origin and prev have to be cloned in order to decouple the data * from the python wrapper */ if (origin != NULL) origin = ldns_rdf_clone(origin); if (prev != NULL) prev = ldns_rdf_clone(prev); ldns_rdf *p_origin = origin; ldns_rdf **pp_origin = &p_origin; //if (p_origin == 0) pp_origin = 0; ldns_rdf *p_prev = prev; ldns_rdf **pp_prev = &p_prev; //if (p_prev == 0) pp_prev = 0; ldns_rr *p_rr = 0; ldns_rr **pp_rr = &p_rr; ldns_status st = ldns_rr_new_frm_fp_l(pp_rr, fp, p_defttl, pp_origin, pp_prev, p_linenr); PyObject* tuple; tuple = PyTuple_New(6); int idx = 0; PyTuple_SetItem(tuple, idx, SWIG_From_int(st)); idx++; PyTuple_SetItem(tuple, idx, (st == LDNS_STATUS_OK) ? SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); idx++; PyTuple_SetItem(tuple, idx, SWIG_From_int(linenr)); idx++; PyTuple_SetItem(tuple, idx, SWIG_From_int(defttl)); idx++; PyTuple_SetItem(tuple, idx, SWIG_NewPointerObj(SWIG_as_voidptr(p_origin), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 )); idx++; PyTuple_SetItem(tuple, idx, SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 )); return tuple; } PyObject* ldns_rr_new_question_frm_str_(const char *str, ldns_rdf* origin, ldns_rdf* prev) //returns tuple (status, ldns_rr, prev) { PyObject* tuple; /* origin and prev have to be cloned in order to decouple the data * from the python wrapper */ if (origin != NULL) origin = ldns_rdf_clone(origin); if (prev != NULL) prev = ldns_rdf_clone(prev); ldns_rdf *p_prev = prev; ldns_rdf **pp_prev = &p_prev; if (p_prev == 0) pp_prev = 0; ldns_rr *p_rr = 0; ldns_rr **pp_rr = &p_rr; ldns_status st = ldns_rr_new_question_frm_str(pp_rr, str, origin, pp_prev); tuple = PyTuple_New(3); PyTuple_SetItem(tuple, 0, SWIG_From_int(st)); PyTuple_SetItem(tuple, 1, (st == LDNS_STATUS_OK) ? SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); PyTuple_SetItem(tuple, 2, (p_prev != prev) ? SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); return tuple; } PyObject* ldns_fetch_valid_domain_keys_(const ldns_resolver * res, const ldns_rdf * domain, const ldns_rr_list * keys) //returns tuple (status, result) { PyObject* tuple; ldns_rr_list *rrl = 0; ldns_status st = 0; rrl = ldns_fetch_valid_domain_keys(res, domain, keys, &st); tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, SWIG_From_int(st)); PyTuple_SetItem(tuple, 1, (st == LDNS_STATUS_OK) ? SWIG_NewPointerObj(SWIG_as_voidptr(rrl), SWIGTYPE_p_ldns_struct_rr_list, SWIG_POINTER_OWN | 0 ) : (Py_INCREF(Py_None), Py_None)); return tuple; } PyObject* ldns_wire2pkt_(const char *str, int len) //returns tuple (status, result) { PyObject *resultobj = 0; ldns_pkt *arg1 = NULL; uint8_t *arg2 = (uint8_t *) str; size_t arg3 = (size_t) len; ldns_status result; PyObject* tuple; result = (ldns_status)ldns_wire2pkt(&arg1,arg2,arg3); tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, SWIG_From_int(result)); if (result == LDNS_STATUS_OK) PyTuple_SetItem(tuple, 1, SWIG_NewPointerObj(SWIG_as_voidptr(arg1), SWIGTYPE_p_ldns_struct_pkt, SWIG_POINTER_OWN | 0 )); else { Py_INCREF(Py_None); PyTuple_SetItem(tuple, 1, Py_None); } return tuple; } PyObject* ldns_pkt2wire_(const ldns_pkt *pkt) //returns tuple (status, result) { PyObject *resultobj = 0; uint8_t *arg1 = NULL; size_t arg3; ldns_status result; PyObject* tuple; result = (ldns_status)ldns_pkt2wire(&arg1,pkt,&arg3); tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, SWIG_From_int(result)); if (result == LDNS_STATUS_OK) PyTuple_SetItem(tuple, 1, SWIG_FromCharPtrAndSize((char *)arg1, arg3)); else { Py_INCREF(Py_None); PyTuple_SetItem(tuple, 1, Py_None); } LDNS_FREE(arg1); return tuple; } %} %pythoncode %{ def ldns_fetch_valid_domain_keys(res, domain, keys): return _ldns.ldns_fetch_valid_domain_keys_(res, domain, keys) def ldns_wire2pkt(data): return _ldns.ldns_wire2pkt_(data) def ldns_pkt2wire(data): return _ldns.ldns_pkt2wire_(data) def ldns_rr_iter_frm_fp_l(input_file): """Creates an iterator (generator) that returns individual parsed RRs from an open zone file.""" # variables that preserve the parsers state my_ttl = 0; my_origin = None my_prev = None # additional state variables last_pos = 0 line_nr = 0 while True: ret = _ldns.ldns_rr_new_frm_fp_l_(input_file, my_ttl, my_origin, my_prev) s, rr, line_inc, new_ttl, new_origin, new_prev = ret # unpack the result line_nr += line_inc # increase number of parsed lines my_prev = new_prev # update ref to previous owner if s == _ldns.LDNS_STATUS_SYNTAX_TTL: my_ttl = new_ttl # update default TTL elif s == _ldns.LDNS_STATUS_SYNTAX_ORIGIN: my_origin = new_origin # update reference to origin elif s == _ldns.LDNS_STATUS_SYNTAX_EMPTY: if last_pos == input_file.tell(): break # no advance since last read - EOF last_pos = input_file.tell() elif s != _ldns.LDNS_STATUS_OK: raise ValueError("Parse error in line %d" % line_nr) else: # we are sure to have LDNS_STATUS_OK yield rr %} ldns-1.9.2/contrib/python/ldns_packet.i0000664000175000017500000014311515212267520017462 0ustar willemwillem/****************************************************************************** * ldns_packet.i: LDNS packet class * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ /* Creates a temporary instance of (ldns_pkt *). */ %typemap(in,numinputs=0,noblock=1) (ldns_pkt **) { ldns_pkt *$1_pkt; $1 = &$1_pkt; } /* Result generation, appends (ldns_pkt *) after the result. */ %typemap(argout,noblock=1) (ldns_pkt **) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_pkt), SWIGTYPE_p_ldns_struct_pkt, SWIG_POINTER_OWN | 0 )); } %newobject ldns_pkt_new; %newobject ldns_pkt_clone; %newobject ldns_pkt_rr_list_by_type; %newobject ldns_pkt_rr_list_by_name_and_type; %newobject ldns_pkt_rr_list_by_name; %newobject ldns_update_pkt_new; %nodefaultctor ldns_struct_pkt; /* No default constructor. */ %nodefaultdtor ldns_struct_pkt; /* No default destructor. */ %rename(ldns_pkt) ldns_struct_pkt; %newobject ldns_pkt2str; %newobject ldns_pkt_opcode2str; %newobject ldns_pkt_rcode2str; %newobject ldns_pkt_algorithm2str; %newobject ldns_pkt_cert_algorithm2str; %newobject ldns_pkt_get_section_clone; /* Clone data on pull. */ %newobject _ldns_pkt_additional; %rename(__ldns_pkt_additional) ldns_pkt_additional; %inline %{ ldns_rr_list * _ldns_pkt_additional(ldns_pkt *p) { return ldns_rr_list_clone(ldns_pkt_additional(p)); } %} %newobject _ldns_pkt_answer; %rename(__ldns_pkt_answer) ldns_pkt_answer; %inline %{ ldns_rr_list * _ldns_pkt_answer(ldns_pkt *p) { return ldns_rr_list_clone(ldns_pkt_answer(p)); } %} %newobject _ldns_pkt_answerfrom; %rename(__ldns_pkt_answerfrom) ldns_pkt_answerfrom; %inline %{ ldns_rdf * _ldns_pkt_answerfrom(ldns_pkt *p) { ldns_rdf *rdf; rdf = ldns_pkt_answerfrom(p); if (rdf != NULL) { rdf = ldns_rdf_clone(rdf); } return rdf; } %} %newobject _ldns_pkt_authority; %rename(__ldns_pkt_authority) ldns_pkt_authority; %inline %{ ldns_rr_list * _ldns_pkt_authority(ldns_pkt *p) { return ldns_rr_list_clone(ldns_pkt_authority(p)); } %} %newobject _ldns_pkt_edns_data; %rename(__ldns_pkt_edns_data) ldns_pkt_edns_data; %inline %{ ldns_rdf * _ldns_pkt_edns_data(ldns_pkt *p) { ldns_rdf *rdf; rdf = ldns_pkt_edns_data(p); if (rdf != NULL) { rdf = ldns_rdf_clone(rdf); } return rdf; } %} %newobject _ldns_pkt_tsig; %rename(__ldns_pkt_tsig) ldns_pkt_tsig; %inline %{ ldns_rr * _ldns_pkt_tsig(const ldns_pkt *pkt) { return ldns_rr_clone(ldns_pkt_tsig(pkt)); } %} %newobject _ldns_pkt_question; %rename(__ldns_pkt_question) ldns_pkt_question; %inline %{ ldns_rr_list * _ldns_pkt_question(ldns_pkt *p) { return ldns_rr_list_clone(ldns_pkt_question(p)); } %} /* End of pull cloning. */ /* Clone data on push. */ %newobject _ldns_pkt_query_new; %rename(__ldns_pkt_query_new) ldns_pkt_query_new; %inline %{ ldns_pkt * _ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class, uint16_t flags) { return ldns_pkt_query_new(ldns_rdf_clone(rr_name), rr_type, rr_class, flags); } %} %rename(__ldns_pkt_push_rr) ldns_pkt_push_rr; %inline %{ bool _ldns_pkt_push_rr(ldns_pkt *p, ldns_pkt_section sec, ldns_rr *rr) { return ldns_pkt_push_rr(p, sec, ldns_rr_clone(rr)); } %} %rename(__ldns_pkt_safe_push_rr) ldns_pkt_safe_push_rr; %inline %{ bool _ldns_pkt_safe_push_rr(ldns_pkt *pkt, ldns_pkt_section sec, ldns_rr *rr) { /* Prevents memory leaks when fails. */ ldns_rr *rr_clone = NULL; bool ret; if (rr != NULL) { rr_clone = ldns_rr_clone(rr); } ret = ldns_pkt_safe_push_rr(pkt, sec, rr_clone); if (!ret) { ldns_rr_free(rr_clone); } return ret; } %} %rename(__ldns_pkt_push_rr_list) ldns_pkt_push_rr_list; %inline %{ bool _ldns_pkt_push_rr_list(ldns_pkt *p, ldns_pkt_section sec, ldns_rr_list *rrl) { return ldns_pkt_push_rr_list(p, sec, ldns_rr_list_clone(rrl)); } %} %rename(__ldns_pkt_safe_push_rr_list) ldns_pkt_safe_push_rr_list; %inline %{ bool _ldns_pkt_safe_push_rr_list(ldns_pkt *p, ldns_pkt_section s, ldns_rr_list *rrl) { /* Prevents memory leaks when fails. */ ldns_rr_list *rrl_clone = NULL; bool ret; if (rrl != NULL) { rrl_clone = ldns_rr_list_clone(rrl); } ret = ldns_pkt_safe_push_rr_list(p, s, rrl_clone); if (!ret) { ldns_rr_list_free(rrl_clone); } return ret; } %} %rename(__ldns_pkt_set_additional) ldns_pkt_set_additional; %inline %{ void _ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rrl) { ldns_rr_list *rrl_clone = NULL; if (rrl != NULL) { rrl_clone = ldns_rr_list_clone(rrl); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_additional(p, rrl_clone); } %} %rename(__ldns_pkt_set_answer) ldns_pkt_set_answer; %inline %{ void _ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rrl) { ldns_rr_list *rrl_clone = NULL; if (rrl != NULL) { rrl_clone = ldns_rr_list_clone(rrl); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_answer(p, rrl_clone); } %} %rename (__ldns_pkt_set_answerfrom) ldns_pkt_set_answerfrom; %inline %{ void _ldns_pkt_set_answerfrom(ldns_pkt *packet, ldns_rdf *rdf) { ldns_rdf *rdf_clone = NULL; if (rdf != NULL) { rdf_clone = ldns_rdf_clone(rdf); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_answerfrom(packet, rdf_clone); } %} %rename(__ldns_pkt_set_authority) ldns_pkt_set_authority; %inline %{ void _ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rrl) { ldns_rr_list *rrl_clone = NULL; if (rrl != NULL) { rrl_clone = ldns_rr_list_clone(rrl); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_authority(p, rrl_clone); } %} %rename(__ldns_pkt_set_edns_data) ldns_pkt_set_edns_data; %inline %{ void _ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *rdf) { ldns_rdf *rdf_clone = NULL; if (rdf != NULL) { rdf_clone = ldns_rdf_clone(rdf); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_edns_data(packet, rdf_clone); } %} %rename(__ldns_pkt_set_question) ldns_pkt_set_question; %inline %{ void _ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rrl) { ldns_rr_list *rrl_clone = NULL; if (rrl != NULL) { rrl_clone = ldns_rr_list_clone(rrl); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_question(p, rrl_clone); } %} %rename(__ldns_pkt_set_tsig) ldns_pkt_set_tsig; %inline %{ void _ldns_pkt_set_tsig(ldns_pkt *pkt, ldns_rr *rr) { ldns_rr *rr_clone = NULL; if (rr != NULL) { rr_clone = ldns_rr_clone(rr); } /* May leak memory, when overwriting pointer value. */ ldns_pkt_set_tsig(pkt, rr_clone); } %} /* End of push cloning. */ /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ #ifdef LDNS_DEBUG %rename(__ldns_pkt_free) ldns_pkt_free; %inline %{ /*! * @brief Prints information about deallocated pkt and deallocates. */ void _ldns_pkt_free (ldns_pkt* p) { printf("******** LDNS_PKT free 0x%lX ************\n", (long unsigned int) p); ldns_pkt_free(p); } %} #else /* !LDNS_DEBUG */ %rename(_ldns_pkt_free) ldns_pkt_free; #endif /* LDNS_DEBUG */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ /* None. */ /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") ldns_struct_pkt "LDNS packet object. The :class:`ldns_pkt` object contains DNS packed (either a query or an answer). It is the complete representation of what you actually send to a name server, and what you get back (see :class:`ldns.ldns_resolver`). **Usage** >>> import ldns >>> resolver = ldns.ldns_resolver.new_frm_file(\"/etc/resolv.conf\") >>> pkt = resolver.query(\"nic.cz\", ldns.LDNS_RR_TYPE_NS,ldns.LDNS_RR_CLASS_IN) >>> print pkt ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 63004 ;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;; nic.cz. IN NS ;; ANSWER SECTION: nic.cz. 758 IN NS a.ns.nic.cz. nic.cz. 758 IN NS c.ns.nic.cz. nic.cz. 758 IN NS e.ns.nic.cz. ;; AUTHORITY SECTION: ;; ADDITIONAL SECTION: ;; Query time: 8 msec ;; SERVER: 82.100.38.2 ;; WHEN: Thu Jan 11 12:54:33 2009 ;; MSG SIZE rcvd: 75 This simple example instances a resolver in order to resolve NS for nic.cz." %extend ldns_struct_pkt { %pythoncode %{ def __init__(self): """ Cannot be created directly from Python. """ raise Exception("This class can't be created directly. " + "Please use: ldns_pkt_new, ldns_pkt_query_new " + "or ldns_pkt_query_new_frm_str") __swig_destroy__ = _ldns._ldns_pkt_free # # LDNS_PKT_CONSTRUCTORS_ # @staticmethod def new(): """ Creates new empty packet structure. :return: (:class:`ldns_pkt` ) New empty packet. """ return _ldns.ldns_pkt_new() @staticmethod def new_query(rr_name, rr_type, rr_class, flags): """ Creates a packet with a query in it for the given name, type and class. :param rr_name: The name to query for. :type rr_name: :class:`ldns_dname` :param rr_type: The type to query for. :type rr_type: ldns_rr_type :param rr_class: The class to query for. :type rr_class: ldns_rr_class :param flags: Packet flags. :type flags: uint16_t :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_pkt`) New object. .. note:: The type checking of parameter `rr_name` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(rr_name, ldns_dname)) and \ isinstance(rr_name, ldns_rdf) and \ rr_name.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_pkt.new_query() method will" + " drop the possibility to accept ldns_rdf." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(rr_name, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (rr_name.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns._ldns_pkt_query_new(rr_name, rr_type, rr_class, flags) @staticmethod def new_query_frm_str(rr_name, rr_type, rr_class, flags, raiseException = True): """ Creates a query packet for the given name, type, class. :param rr_name: The name to query for. :type rr_name: str :param rr_type: The type to query for. :type rr_type: ldns_rr_type :param rr_class: The class to query for. :type rr_class: ldns_rr_class :param flags: Packet flags. :type flags: uint16_t :param raiseException: If True, an exception occurs in case a packet object can't be created. :throws TypeError: When arguments of inappropriate types. :throws Exception: When raiseException set and packet couldn't be created. :return: (:class:`ldns_pkt`) Query packet object or None. If the object can't be created and raiseException is True, an exception occurs. **Usage** >>> pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA) >>> rra = ldns.ldns_rr.new_frm_str("test.nic.cz. IN A 192.168.1.1",300) >>> list = ldns.ldns_rr_list() >>> if (rra): list.push_rr(rra) >>> pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, list) >>> print pkt ;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 0 ;; flags: qr aa ; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;; test.nic.cz. IN ANY ;; ANSWER SECTION: test.nic.cz. 300 IN A 192.168.1.1 ;; AUTHORITY SECTION: ;; ADDITIONAL SECTION: ;; Query time: 0 msec ;; WHEN: Thu Jan 1 01:00:00 1970 ;; MSG SIZE rcvd: 0 """ status, pkt = _ldns.ldns_pkt_query_new_frm_str(rr_name, rr_type, rr_class, flags) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create query packet, error: %d" % status) return None return pkt # # _LDNS_PKT_CONSTRUCTORS # def __str__(self): """ Converts the data in the DNS packet to presentation format. :return: (str) """ return _ldns.ldns_pkt2str(self) def opcode2str(self): """ Converts a packet opcode to its mnemonic and returns that as an allocated null-terminated string. :return: (str) """ return _ldns.ldns_pkt_opcode2str(self.get_opcode()) def rcode2str(self): """ Converts a packet rcode to its mnemonic and returns that as an allocated null-terminated string. :return: (str) """ return _ldns.ldns_pkt_rcode2str(self.get_rcode()) def print_to_file(self, output): """ Prints the data in the DNS packet to the given file stream (in presentation format). :param output: Opened file to write to. :type output: file :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_print(output, self) #parameters: FILE *,const ldns_pkt *, def write_to_buffer(self, buffer): """ Copies the packet data to the buffer in wire format. :param buffer: Buffer to append the result to. :type buffer: :class:`ldns_buffer` :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) ldns_status """ return _ldns.ldns_pkt2buffer_wire(buffer, self) #parameters: ldns_buffer *,const ldns_pkt *, #retvals: ldns_status @staticmethod def algorithm2str(alg): """ Converts a signing algorithms to its mnemonic and returns that as an allocated null-terminated string. :param alg: The algorithm to convert to text. :type alg: ldns_algorithm :return: (str) """ return _ldns.ldns_pkt_algorithm2str(alg) #parameters: ldns_algorithm, @staticmethod def cert_algorithm2str(alg): """ Converts a cert algorithm to its mnemonic and returns that as an allocated null-terminated string. :param alg: Cert algorithm to convert to text. :type alg: ldns_cert_algorithm :return: (str) """ return _ldns.ldns_pkt_cert_algorithm2str(alg) #parameters: ldns_algorithm, # # LDNS_PKT_METHODS_ # def aa(self): """ Read the packet's aa bit. :return: (bool) Value of the bit. """ return _ldns.ldns_pkt_aa(self) #parameters: const ldns_pkt *, #retvals: bool def ad(self): """ Read the packet's ad bit. :return: (bool) Value of the bit. """ return _ldns.ldns_pkt_ad(self) #parameters: const ldns_pkt *, #retvals: bool def additional(self): """ Return the packet's additional section. :return: (:class:`ldns_rr_list`) The additional section. """ return _ldns._ldns_pkt_additional(self) #parameters: const ldns_pkt *, #retvals: ldns_rr_list * def all(self): """ Return the packet's question, answer, authority and additional sections concatenated. :return: (:class:`ldns_rr_list`) Concatenated sections. """ return _ldns.ldns_pkt_all(self) #parameters: const ldns_pkt *, #retvals: ldns_rr_list * def all_noquestion(self): """ Return the packet's answer, authority and additional sections concatenated. Like :meth:`all` but without the questions. :return: (:class:`ldns_rr_list`) Concatenated sections except questions. """ return _ldns.ldns_pkt_all_noquestion(self) #parameters: const ldns_pkt *, #retvals: ldns_rr_list * def ancount(self): """ Return the packet's an count. :return: (int) The an count. """ return _ldns.ldns_pkt_ancount(self) #parameters: const ldns_pkt *, #retvals: uint16_t def answer(self): """ Return the packet's answer section. :return: (:class:`ldns_rr_list`) The answer section. """ return _ldns._ldns_pkt_answer(self) #parameters: const ldns_pkt *, #retvals: ldns_rr_list * def answerfrom(self): """ Return the packet's answerfrom. :return: (:class:`ldns_rdf`) The name of the server. """ return _ldns._ldns_pkt_answerfrom(self) #parameters: const ldns_pkt *, #retvals: ldns_rdf * def arcount(self): """ Return the packet's ar count. :return: (int) The ar count. """ return _ldns.ldns_pkt_arcount(self) #parameters: const ldns_pkt *, #retvals: uint16_t def authority(self): """ Return the packet's authority section. :return: (:class:`ldns_rr_list`) The authority section. """ return _ldns._ldns_pkt_authority(self) #parameters: const ldns_pkt *, #retvals: ldns_rr_list * def cd(self): """ Read the packet's cd bit. :return: (bool) Value of the bit. """ return _ldns.ldns_pkt_cd(self) #parameters: const ldns_pkt *, #retvals: bool def clone(self): """ Clones the packet, creating a fully allocated copy. :return: (:class:`ldns_pkt`) New packet clone. """ return _ldns.ldns_pkt_clone(self) #parameters: ldns_pkt *, #retvals: ldns_pkt * def edns(self): """ Returns True if this packet needs and EDNS rr to be sent. At the moment the only reason is an expected packet size larger than 512 bytes, but for instance DNSSEC would be a good reason too. :return: (bool) True if packet needs EDNS rr. """ return _ldns.ldns_pkt_edns(self) #parameters: const ldns_pkt *, #retvals: bool def edns_data(self): """ Return the packet's edns data. :return: (:class:`ldns_rdf`) The edns data. """ return _ldns._ldns_pkt_edns_data(self) #parameters: const ldns_pkt *, #retvals: ldns_rdf * def edns_do(self): """ Return the packet's edns do bit :return: (bool) The bit's value. """ return _ldns.ldns_pkt_edns_do(self) #parameters: const ldns_pkt *, #retvals: bool def edns_extended_rcode(self): """ Return the packet's edns extended rcode. :return: (uint8_t) The rcode. """ return _ldns.ldns_pkt_edns_extended_rcode(self) #parameters: const ldns_pkt *, #retvals: uint8_t def edns_udp_size(self): """ Return the packet's edns udp size. :return: (uint16_t) The udp size. """ return _ldns.ldns_pkt_edns_udp_size(self) #parameters: const ldns_pkt *, #retvals: uint16_t def edns_version(self): """ Return the packet's edns version. :return: (uint8_t) The edns version. """ return _ldns.ldns_pkt_edns_version(self) #parameters: const ldns_pkt *, #retvals: uint8_t def edns_z(self): """ Return the packet's edns z value. :return: (uint16_t) The z value. """ return _ldns.ldns_pkt_edns_z(self) #parameters: const ldns_pkt *, #retvals: uint16_t def empty(self): """ Check if a packet is empty. :return: (bool) True: empty, False: not empty """ return _ldns.ldns_pkt_empty(self) #parameters: ldns_pkt *, #retvals: bool def get_opcode(self): """ Read the packet's code. :return: (ldns_pkt_opcode) the opcode """ return _ldns.ldns_pkt_get_opcode(self) #parameters: const ldns_pkt *, #retvals: ldns_pkt_opcode def get_rcode(self): """ Return the packet's response code. :return: (ldns_pkt_rcode) The response code. """ return _ldns.ldns_pkt_get_rcode(self) #parameters: const ldns_pkt *, #retvals: ldns_pkt_rcode def get_section_clone(self, s): """ Return the selected rr_list's in the packet. :param s: What section(s) to return. :type s: ldns_pkt_section :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) RR list with the rr's or None if none were found. """ return _ldns.ldns_pkt_get_section_clone(self, s) #parameters: const ldns_pkt *,ldns_pkt_section, #retvals: ldns_rr_list * def id(self): """ Read the packet id. :return: (uint16_t) The packet id. """ return _ldns.ldns_pkt_id(self) #parameters: const ldns_pkt *, #retvals: uint16_t def nscount(self): """ Return the packet's ns count. :return: (uint16_t) The ns count. """ return _ldns.ldns_pkt_nscount(self) #parameters: const ldns_pkt *, #retvals: uint16_t def push_rr(self, section, rr): """ Push an rr on a packet. :param section: Where to put it. :type section: ldns_pkt_section :param rr: RR to push. :type rr: :class:`ldns_rr` :throws TypeError: When arguments of inappropriate types. :return: (bool) A boolean which is True when the rr was added. """ return _ldns._ldns_pkt_push_rr(self,section,rr) #parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *, #retvals: bool def push_rr_list(self, section, list): """ Push a rr_list on a packet. :param section: Where to put it. :type section: ldns_pkt_section :param list: The rr_list to push. :type list: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. :return: (bool) A boolean which is True when the rr was added. """ return _ldns._ldns_pkt_push_rr_list(self,section,list) #parameters: ldns_pkt *,ldns_pkt_section,ldns_rr_list *, #retvals: bool def qdcount(self): """ Return the packet's qd count. :return: (uint16_t) The qd count. """ return _ldns.ldns_pkt_qdcount(self) #parameters: const ldns_pkt *, #retvals: uint16_t def qr(self): """ Read the packet's qr bit. :return: (bool) value of the bit """ return _ldns.ldns_pkt_qr(self) #parameters: const ldns_pkt *, #retvals: bool def querytime(self): """ Return the packet's query time. :return: (uint32_t) The query time. """ return _ldns.ldns_pkt_querytime(self) #parameters: const ldns_pkt *, #retvals: uint32_t def question(self): """ Return the packet's question section. :return: (:class:`ldns_rr_list`) The question section. """ return _ldns._ldns_pkt_question(self) #parameters: const ldns_pkt *, #retvals: ldns_rr_list * def ra(self): """ Read the packet's ra bit. :return: (bool) Value of the bit. """ return _ldns.ldns_pkt_ra(self) #parameters: const ldns_pkt *, #retvals: bool def rd(self): """ Read the packet's rd bit. :return: (bool) Value of the bit. """ return _ldns.ldns_pkt_rd(self) #parameters: const ldns_pkt *, #retvals: bool def reply_type(self): """ Looks inside the packet to determine what kind of packet it is, AUTH, NXDOMAIN, REFERRAL, etc. :return: (ldns_pkt_type) The type of packet. """ return _ldns.ldns_pkt_reply_type(self) #parameters: ldns_pkt *, #retvals: ldns_pkt_type def rr(self, sec, rr): """ Check to see if an rr exist in the packet. :param sec: In which section to look. :type sec: ldns_pkt_section :param rr: The rr to look for. :type rr: :class:`ldns_rr` :throws TypeError: When arguments of inappropriate types. :return: (bool) Return True is exists. """ return _ldns.ldns_pkt_rr(self, sec, rr) #parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *, #retvals: bool def rr_list_by_name(self, r, s): """ Return all the rr with a specific name from a packet. :param r: The name. :type r: :class:`ldns_rdf` :param s: The packet's section. :type s: ldns_pkt_section :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) A list with the rr's or None if none were found. """ return _ldns.ldns_pkt_rr_list_by_name(self,r,s) #parameters: ldns_pkt *,ldns_rdf *,ldns_pkt_section, #retvals: ldns_rr_list * def rr_list_by_name_and_type(self, ownername, atype, sec): """ Return all the rr with a specific type and type from a packet. :param ownername: The name. :type ownername: :class:`ldns_rdf` :param atype: The type. :type atype: ldns_rr_type :param sec: The packet's section. :type sec: ldns_pkt_section :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) A list with the rr's or None if none were found. """ return _ldns.ldns_pkt_rr_list_by_name_and_type(self, ownername, atype, sec) #parameters: const ldns_pkt *,const ldns_rdf *,ldns_rr_type,ldns_pkt_section, #retvals: ldns_rr_list * def rr_list_by_type(self, t, s): """ Return all the rr with a specific type from a packet. :param t: The type. :type t: ldns_rr_type :param s: The packet's section. :type s: ldns_pkt_section :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) A list with the rr's or None if none were found. """ return _ldns.ldns_pkt_rr_list_by_type(self, t, s) #parameters: const ldns_pkt *,ldns_rr_type,ldns_pkt_section, #retvals: ldns_rr_list * def safe_push_rr(self, sec, rr): """ Push an rr on a packet, provided the RR is not there. :param sec: Where to put it. :type sec: ldns_pkt_section :param rr: RR to push. :type rr: :class:`ldns_rr` :throws TypeError: When arguments of inappropriate types. :return: (bool) A boolean which is True when the rr was added. """ return _ldns._ldns_pkt_safe_push_rr(self,sec,rr) #parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *, #retvals: bool def safe_push_rr_list(self, sec, list): """ Push an rr_list to a packet, provided the RRs are not already there. :param sec: Where to put it. :type sec: ldns_pkt_section :param list: The rr_list to push. :type list: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. :return: (bool) A boolean which is True when the list was added. """ return _ldns._ldns_pkt_safe_push_rr_list(self, sec, list) #parameters: ldns_pkt *,ldns_pkt_section,ldns_rr_list *, #retvals: bool def set_aa(self, b): """ Set the packet's aa bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_aa(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_ad(self, b): """ Set the packet's ad bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_ad(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_additional(self, rr): """ Directly set the additional section. :param rr: The rr list to set. :type rr: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_additional(self, rr) #parameters: ldns_pkt *,ldns_rr_list *, #retvals: def set_ancount(self, c): """ Set the packet's an count. :param c: The count. :type c: int :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_ancount(self, c) #parameters: ldns_pkt *,uint16_t, #retvals: def set_answer(self, rr): """ Directly set the answer section. :param rr: The rr list to set. :type rr: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_answer(self, rr) #parameters: ldns_pkt *,ldns_rr_list *, #retvals: def set_answerfrom(self, r): """ Set the packet's answering server. :param r: The address. :type r: :class:`ldns_rdf` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_answerfrom(self, r) #parameters: ldns_pkt *,ldns_rdf *, #retvals: def set_arcount(self, c): """ Set the packet's arcount. :param c: The count. :type c: int :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_arcount(self,c) #parameters: ldns_pkt *,uint16_t, #retvals: def set_authority(self, rr): """ Directly set the authority section. :param rr: The rr list to set. :type rr: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_authority(self, rr) #parameters: ldns_pkt *,ldns_rr_list *, #retvals: def set_cd(self, b): """ Set the packet's cd bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_cd(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_edns_data(self, data): """ Set the packet's edns data. :param data: The data. :type data: :class:`ldns_rdf` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_edns_data(self, data) #parameters: ldns_pkt *,ldns_rdf *, #retvals: def set_edns_do(self, value): """ Set the packet's edns do bit. :param value: The bit's new value. :type value: bool """ _ldns.ldns_pkt_set_edns_do(self, value) #parameters: ldns_pkt *,bool, #retvals: def set_edns_extended_rcode(self, c): """ Set the packet's edns extended rcode. :param c: The code. :type c: uint8_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_edns_extended_rcode(self, c) #parameters: ldns_pkt *,uint8_t, #retvals: def set_edns_udp_size(self, s): """ Set the packet's edns udp size. :param s: The size. :type s: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_edns_udp_size(self, s) #parameters: ldns_pkt *,uint16_t, #retvals: def set_edns_version(self, v): """ Set the packet's edns version. :param v: The version. :type v: uint8_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_edns_version(self, v) #parameters: ldns_pkt *,uint8_t, #retvals: def set_edns_z(self, z): """ Set the packet's edns z value. :param z: The value. :type z: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_edns_z(self, z) #parameters: ldns_pkt *,uint16_t, #retvals: def set_flags(self, flags): """ Sets the flags in a packet. :param flags: ORed values: LDNS_QR| LDNS_AR for instance. :type flags: int :throws TypeError: When arguments of inappropriate types. :return: (bool) True on success, False otherwise. """ return _ldns.ldns_pkt_set_flags(self, flags) #parameters: ldns_pkt *,uint16_t, #retvals: bool def set_id(self, id): """ Set the packet's id. :param id: The id to set. :type id: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_id(self, id) #parameters: ldns_pkt *,uint16_t, #retvals: def set_nscount(self, c): """ Set the packet's ns count. :param c: The count. :type c: int :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_nscount(self, c) #parameters: ldns_pkt *,uint16_t, #retvals: def set_opcode(self, c): """ Set the packet's opcode. :param c: The opcode. :type c: ldns_pkt_opcode :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_opcode(self, c) #parameters: ldns_pkt *,ldns_pkt_opcode, #retvals: def set_qdcount(self, c): """ Set the packet's qd count. :param c: The count. :type c: int :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_qdcount(self, c) #parameters: ldns_pkt *,uint16_t, #retvals: def set_qr(self, b): """ Set the packet's qr bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_qr(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_querytime(self, t): """ Set the packet's query time. :param t: The query time in msec. :type t: uint32_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_querytime(self, t) #parameters: ldns_pkt *,uint32_t, #retvals: def set_question(self, rr): """ Directly set the question section. :param rr: The rr list to set. :type rr: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_question(self, rr) #parameters: ldns_pkt *,ldns_rr_list *, #retvals: def set_ra(self, b): """ Set the packet's ra bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_ra(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_random_id(self): """ Set the packet's id to a random value. """ _ldns.ldns_pkt_set_random_id(self) #parameters: ldns_pkt *, #retvals: def set_rcode(self, c): """ Set the packet's response code. :param c: The rcode. :type c: uint8_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_rcode(self, c) #parameters: ldns_pkt *,uint8_t, #retvals: def set_rd(self, b): """ Set the packet's rd bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_rd(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_section_count(self, s, x): """ Set a packet's section count to x. :param s: The section. :type s: ldns_pkt_section :param x: The section count. :type x: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_section_count(self, s, x) #parameters: ldns_pkt *,ldns_pkt_section,uint16_t, #retvals: def set_size(self, s): """ Set the packet's size. :param s: The size. :type s: int :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_size(self,s) #parameters: ldns_pkt *,size_t, #retvals: def set_tc(self, b): """ Set the packet's tc bit. :param b: The value to set. :type b: bool """ _ldns.ldns_pkt_set_tc(self, b) #parameters: ldns_pkt *,bool, #retvals: def set_timestamp(self, timeval): """ Set the packet's time stamp. :param timestamp: The time stamp. :type timestamp: struct timeval :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_pkt_set_timestamp(self, timeval) #parameters: ldns_pkt *,struct timeval, #retvals: def set_tsig(self, t): """ Set the packet's tsig rr. :param t: The tsig rr. :type t: :class:`ldns_rr` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_pkt_set_tsig(self, t) #parameters: ldns_pkt *,ldns_rr *, #retvals: def size(self): """ Return the packet's size in bytes. :return: (size_t) The size. """ return _ldns.ldns_pkt_size(self) #parameters: const ldns_pkt *, #retvals: size_t def tc(self): """ Read the packet's tc bit. :return: (bool) Value of the bit. """ return _ldns.ldns_pkt_tc(self) #parameters: const ldns_pkt *, #retvals: bool def timestamp(self): """ Return the packet's time stamp. :return: (struct timeval) The time stamp. """ return _ldns.ldns_pkt_timestamp(self) #parameters: const ldns_pkt *, #retvals: struct timeval def tsig(self): """ Return the packet's tsig pseudo rr's. :return: (:class:`ldns_rr`) The tsig rr. """ return _ldns._ldns_pkt_tsig(self) #parameters: const ldns_pkt *, #retvals: ldns_rr * # # _LDNS_PKT_METHODS# # # # LDNS update methods # # # LDNS_METHODS_ # def update_ad(self): """ Get the ad count. :return: (uint16_t) The ad count. """ return _ldns.ldns_update_ad(self) #parameters: ldns_pkt * #retvals: uint16_t def update_pkt_tsig_add(self, r): """ Add tsig credentials to a packet from a resolver. :param r: Resolver to copy from. :type r: :class:`ldns_resolver` :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) Status whether successful or not. """ return _ldns.ldns_update_pkt_tsig_add(self, r) #parameters: ldns_pkt *,ldns_resolver *, #retvals: ldns_status def update_prcount(self): """ Get the pr count. :return: (uint16_t) The pr count. """ return _ldns.ldns_update_prcount(self) #parameters: const ldns_pkt *, #retvals: uint16_t def update_set_adcount(self, c): """ Set the ad count. :param c: The ad count to set. :type c: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_update_set_adcount(self, c) #parameters: ldns_pkt *,uint16_t, #retvals: def update_set_prcount(self, c): """ Set the pr count. :param c: The pr count to set. :type c: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_update_set_prcount(self, c) #parameters: ldns_pkt *,uint16_t, #retvals: def update_set_upcount(self, c): """ Set the up count. :param c: The up count to set. :type c: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_update_set_upcount(self,c) #parameters: ldns_pkt *,uint16_t, #retvals: def update_set_zo(self, c): """ Set the zo count. :param c: The zo count to set. :type c: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_update_set_zo(self, c) #parameters: ldns_pkt *,uint16_t, #retvals: def update_upcount(self): """ Get the up count. :return: (uint16_t) The up count. """ return _ldns.ldns_update_upcount(self) #parameters: const ldns_pkt *, #retvals: uint16_t def update_zocount(self): """ Get the zo count. :return: (uint16_t) The zo count. """ return _ldns.ldns_update_zocount(self) #parameters: const ldns_pkt *, #retvals: uint16_t # # _LDNS_METHODS # %} } ldns-1.9.2/contrib/python/LICENSE0000664000175000017500000000310215212267520016015 0ustar willemwillemCopyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) Karel Slany (slany AT fit.vutbr.cz) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ldns-1.9.2/contrib/python/ldns_zone.i0000664000175000017500000002701015212267520017161 0ustar willemwillem/****************************************************************************** * ldns_zone.i: LDNS zone class * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ %typemap(in,numinputs=0,noblock=1) (ldns_zone **) { ldns_zone *$1_zone; $1 = &$1_zone; } /* result generation */ %typemap(argout,noblock=1) (ldns_zone **) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_zone), SWIGTYPE_p_ldns_struct_zone, SWIG_POINTER_OWN | 0 )); } %nodefaultctor ldns_struct_zone; //no default constructor & destructor %nodefaultdtor ldns_struct_zone; %newobject ldns_zone_new_frm_fp; %newobject ldns_zone_new_frm_fp_l; %newobject ldns_zone_new; %delobject ldns_zone_free; %delobject ldns_zone_deep_free; %delobject ldns_zone_push_rr; %delobject ldns_zone_push_rr_list; %ignore ldns_struct_zone::_soa; %ignore ldns_struct_zone::_rrs; %rename(ldns_zone) ldns_struct_zone; #ifdef LDNS_DEBUG %rename(__ldns_zone_free) ldns_zone_free; %rename(__ldns_zone_deep_free) ldns_zone_deep_free; %inline %{ void _ldns_zone_free (ldns_zone* z) { printf("******** LDNS_ZONE free 0x%lX ************\n", (long unsigned int)z); ldns_zone_deep_free(z); } %} #else %rename(__ldns_zone_free) ldns_zone_free; %rename(_ldns_zone_free) ldns_zone_deep_free; #endif %feature("docstring") ldns_struct_zone "Zone definitions **Usage** This class is able to read and parse the content of zone file by doing: >>> import ldns >>> zone = ldns.ldns_zone.new_frm_fp(open(\"zone.txt\",\"r\"), None, 0, ldns.LDNS_RR_CLASS_IN) >>> print zone.soa() example. 600 IN SOA example. admin.example. 2008022501 28800 7200 604800 18000 >>> print zone.rrs() example. 600 IN MX 10 mail.example. example. 600 IN NS ns1.example. example. 600 IN NS ns2.example. example. 600 IN A 192.168.1.1 The ``zone.txt`` file contains the following records:: $ORIGIN example. $TTL 600 example. IN SOA example. admin.example. ( 2008022501 ; serial 28800 ; refresh (8 hours) 7200 ; retry (2 hours) 604800 ; expire (1 week) 18000 ; minimum (5 hours) ) @ IN MX 10 mail.example. @ IN NS ns1 @ IN NS ns2 @ IN A 192.168.1.1 " %extend ldns_struct_zone { %pythoncode %{ def __init__(self): self.this = _ldns.ldns_zone_new() if not self.this: raise Exception("Can't create zone.") __swig_destroy__ = _ldns._ldns_zone_free def __str__(self): return str(self.soa()) + "\n" + str(self.rrs()) def print_to_file(self,output): """Prints the data in the zone to the given file stream (in presentation format).""" _ldns.ldns_zone_print(output,self) #parameters: FILE *,const ldns_zone *, #LDNS_ZONE_CONSTRUCTORS_# @staticmethod def new_frm_fp(file, origin, ttl, rr_class=_ldns.LDNS_RR_CLASS_IN, raiseException=True): """Creates a new zone object from given file pointer :param file: a file object :param origin: (ldns_rdf) the zones' origin :param ttl: default ttl to use :param rr_class: Default class to use (IN) :param raiseException: if True, an exception occurs in case a zone instance can't be created :returns: zone instance or None. If an instance can't be created and raiseException is True, an exception occurs. """ status, zone = _ldns.ldns_zone_new_frm_fp(file, origin, ttl, rr_class) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create zone, error: %s (%d)" % (_ldns.ldns_get_errorstr_by_id(status),status)) return None return zone @staticmethod def new_frm_fp_l(file, origin, ttl, rr_class, raiseException=True): """Create a new zone from a file, keep track of the line numbering :param file: a file object :param origin: (ldns_rdf) the zones' origin :param ttl: default ttl to use :param rr_class: Default class to use (IN) :param raiseException: if True, an exception occurs in case a zone instance can't be created :returns: * zone - zone instance or None. If an instance can't be created and raiseException is True, an exception occurs. * line - used for error msg, to get to the line number """ status, zone = _ldns.ldns_zone_new_frm_fp_l(file, line) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create zone, error: %d" % status) return None return zone #_LDNS_ZONE_CONSTRUCTORS# def sign(self,key_list): """Signs the zone, and returns a newly allocated signed zone. :param key_list: list of keys to sign with :returns: (ldns_zone \*) signed zone """ return _ldns.ldns_zone_sign(self,key_list) #parameters: const ldns_zone *,ldns_key_list *, #retvals: ldns_zone * def sign_nsec3(self,key_list,algorithm,flags,iterations,salt_length,salt): """Signs the zone with NSEC3, and returns a newly allocated signed zone. :param key_list: list of keys to sign with :param algorithm: the NSEC3 hashing algorithm to use :param flags: NSEC3 flags :param iterations: the number of NSEC3 hash iterations to use :param salt_length: the length (in octets) of the NSEC3 salt :param salt: the NSEC3 salt data :returns: (ldns_zone \*) signed zone """ return _ldns.ldns_zone_sign_nsec3(self,key_list,algorithm,flags,iterations,salt_length,salt) #parameters: ldns_zone *,ldns_key_list *,uint8_t,uint8_t,uint16_t,uint8_t,uint8_t *, #retvals: ldns_zone * #LDNS_ZONE_METHODS_# def glue_rr_list(self): """Retrieve all resource records from the zone that are glue records. The resulting list does are pointer references to the zone's data. Due to the current zone implementation (as a list of rr's), this function is extremely slow. Another (probably better) way to do this is to use an ldns_dnssec_zone structure and the mark_glue function :returns: (ldns_rr_list \*) the rr_list with the glue """ return _ldns.ldns_zone_glue_rr_list(self) #parameters: const ldns_zone *, #retvals: ldns_rr_list * def push_rr(self,rr): """push an single rr to a zone structure. This function use pointer copying, so the rr_list structure inside z is modified! :param rr: the rr to add :returns: (bool) a true on success otherwise falsed """ return _ldns.ldns_zone_push_rr(self,rr) #parameters: ldns_zone *,ldns_rr *, #retvals: bool def push_rr_list(self,list): """push an rrlist to a zone structure. This function use pointer copying, so the rr_list structure inside z is modified! :param list: the list to add :returns: (bool) a true on success otherwise falsed """ return _ldns.ldns_zone_push_rr_list(self,list) #parameters: ldns_zone *,ldns_rr_list *, #retvals: bool def rr_count(self): """Returns the number of resource records in the zone, NOT counting the SOA record. :returns: (size_t) the number of rr's in the zone """ return _ldns.ldns_zone_rr_count(self) #parameters: const ldns_zone *, #retvals: size_t def rrs(self): """Get a list of a zone's content. Note that the SOA isn't included in this list. You need to get the with ldns_zone_soa. :returns: (ldns_rr_list \*) the rrs from this zone """ return _ldns.ldns_zone_rrs(self) #parameters: const ldns_zone *, #retvals: ldns_rr_list * def set_rrs(self,rrlist): """Set the zone's contents. :param rrlist: the rrlist to use """ _ldns.ldns_zone_set_rrs(self,rrlist) #parameters: ldns_zone *,ldns_rr_list *, #retvals: def set_soa(self,soa): """Set the zone's soa record. :param soa: the soa to set """ _ldns.ldns_zone_set_soa(self,soa) #parameters: ldns_zone *,ldns_rr *, #retvals: def soa(self): """Return the soa record of a zone. :returns: (ldns_rr \*) the soa record in the zone """ return _ldns.ldns_zone_soa(self) #parameters: const ldns_zone *, #retvals: ldns_rr * def sort(self): """Sort the rrs in a zone, with the current impl. this is slow """ _ldns.ldns_zone_sort(self) #parameters: ldns_zone *, #retvals: #_LDNS_ZONE_METHODS# %} } ldns-1.9.2/contrib/python/Makefile0000664000175000017500000001132015212267520016451 0ustar willemwillem# Makefile: compilation of sources and documentation, test environment # # Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) # Karel Slany (slany AT fit.vutbr.cz) # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the organization nor the names of its # contributors may be used to endorse or promote products derived from this # software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. .PHONY: help clean testenv test doc te bw bw3 sw sw3 help: @echo "Please use \`make ' where is one of" @echo " testenv to make test environment and run bash " @echo " useful in case you don't want to install ldns but want to test examples" @echo " doc to make documentation" @echo " clean clean all" ../../Makefile: ../../configure cd ../.. && ./configure --with-python _ldns.so: ../../Makefile $(MAKE) -C ../.. ../../.libs/libldns.so.1: ../../Makefile $(MAKE) -C ../.. clean: rm -rf examples/ldns rm -f _ldns.so ldns_wrapper.o $(MAKE) -C ../.. clean testenv: ../../.libs/libldns.so.1 _ldns.so rm -rf examples/ldns cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1 && ls -la @echo "Run a script by typing ./script_name.py" cd examples && LD_LIBRARY_PATH=ldns bash rm -rf examples/ldns test: ../../.libs/libldns.so.1 _ldns.so examples/test_buffer.py examples/test_rdf.py examples/test_dname.py examples/test_rr.py examples/test_pkt.py examples/test_resolver.py @rm -rf examples/ldns @cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1 @cd examples && LD_LIBRARY_PATH=ldns ./test_buffer.py 2>/dev/null @cd examples && LD_LIBRARY_PATH=ldns ./test_rdf.py 2>/dev/null @cd examples && LD_LIBRARY_PATH=ldns ./test_dname.py 2>/dev/null @cd examples && LD_LIBRARY_PATH=ldns ./test_rr.py 2>/dev/null @cd examples && LD_LIBRARY_PATH=ldns ./test_pkt.py 2>/dev/null @cd examples && LD_LIBRARY_PATH=ldns ./test_resolver.py 2>/dev/null @rm -rf examples/ldns doc: ../../.libs/libldns.so.1 _ldns.so echo @VERSION_MAJOR@ rm -f _ldns.so ln -s ../../.libs/_ldns.so $(MAKE) -C docs html rm -f _ldns.so # For development only: # Test environment, does not build the wrapper from dependencies. te: rm -rf examples/ldns cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1 && ls -la @echo "Run a script by typing ./script_name.py" cd examples && LD_LIBRARY_PATH=ldns bash rm -rf examples/ldns # Builds Python 2 wrapper from present wrapper C code. bw: gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python2.7 -I. -o ldns_wrapper.o mkdir -p ../../.libs ld -shared ldns_wrapper.o -L../../.libs -lldns -o ../../.libs/_ldns.so # Builds Python 3 wrapper from present wrapper C code. bw3: gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python3.2 -I. -o ldns_wrapper.o mkdir -p ../../.libs ld -shared ldns_wrapper.o -L../../.libs -ldns -o ../../.libs/_ldns.so # Builds Python 2 wrapper from interface file. sw: ldns.i swig -python -o ldns_wrapper.c -I../.. ldns.i $(MAKE) bw # Builds Python 3 wrapper from interface file. sw3: ldns.i swig -python -py3 -DPY3 -o ldns_wrapper.c -I../.. ldns.i $(MAKE) bw3 ldns-1.9.2/contrib/python/ldns_rdf.i0000664000175000017500000010501015212267520016756 0ustar willemwillem/****************************************************************************** * ldns_rdf.i: LDNS record data * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ /* Creates a temporary instance of (ldns_rdf *). */ %typemap(in, numinputs=0, noblock=1) (ldns_rdf **) { ldns_rdf *$1_rdf = NULL; $1 = &$1_rdf; } /* Result generation, appends (ldns_rdf *) after the result. */ %typemap(argout, noblock=1) (ldns_rdf **) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_rdf), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0)); } #if SWIG_VERSION < 0x040200 /* * Automatic conversion of const (ldns_rdf *) parameter from string. * Argument default value. */ %typemap(arginit, noblock=1) const ldns_rdf * { #if SWIG_VERSION >= 0x040200 PyObject *$1_bytes = NULL; #else char *$1_str = NULL; #endif } /* * Automatic conversion of const (ldns_rdf *) parameter from string. * Preparation of arguments. */ %typemap(in, noblock=1) const ldns_rdf * (void* argp, $1_ltype tmp = 0, int res) { if (Python_str_Check($input)) { const char *argstr; #if SWIG_VERSION >= 0x040200 argstr = SWIG_PyUnicode_AsUTF8AndSize($input, NULL, &$1_bytes); #else $1_str = SWIG_Python_str_AsChar($input); argstr = $1_str; #endif if (argstr == NULL) { %argument_fail(SWIG_TypeError, "char *", $symname, $argnum); } tmp = ldns_dname_new_frm_str(argstr); if (tmp == NULL) { %argument_fail(SWIG_TypeError, "char *", $symname, $argnum); } $1 = ($1_ltype) tmp; } else { res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_ldns_struct_rdf, 0 | 0); if (!SWIG_IsOK(res)) { %argument_fail(res, "ldns_rdf const *", $symname, $argnum); } $1 = ($1_ltype) argp; } } /* * Automatic conversion of const (ldns_rdf *) parameter from string. * Freeing of allocated memory (in Python 3 when daling with strings). */ %typemap(freearg, noblock=1) const ldns_rdf * { #if SWIG_VERSION >= 0x040200 if ($1_bytes != NULL) { /* Is not NULL only when a conversion form string occurred. */ Py_XDECREF($1_bytes); } #else if ($1_str != NULL) { /* Is not NULL only when a conversion form string occurred. */ SWIG_Python_str_DelForPy3($1_str); /* Is a empty macro for Python < 3. */ } #endif } #else /* * Automatic conversion of const (ldns_rdf *) parameter from string. * Argument default value. */ %typemap(arginit, noblock=1) const ldns_rdf * { PyObject *$1_bytes = NULL; } /* * Automatic conversion of const (ldns_rdf *) parameter from string. * Preparation of arguments. */ %typemap(in, noblock=1) const ldns_rdf * (void* argp, $1_ltype tmp = 0, int res) { if (Python_str_Check($input)) { const char *$1_str = SWIG_PyUnicode_AsUTF8AndSize($input, NULL, &$1_bytes); if ($1_str == NULL) { %argument_fail(SWIG_TypeError, "char *", $symname, $argnum); } tmp = ldns_dname_new_frm_str($1_str); if (tmp == NULL) { %argument_fail(SWIG_TypeError, "char *", $symname, $argnum); } $1 = ($1_ltype) tmp; } else { res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_ldns_struct_rdf, 0 | 0); if (!SWIG_IsOK(res)) { %argument_fail(res, "ldns_rdf const *", $symname, $argnum); } $1 = ($1_ltype) argp; } } /* * Automatic conversion of const (ldns_rdf *) parameter from string. * Freeing of allocated memory (it's a no op unless compiling for some older versions of the Python stable ABI). */ %typemap(freearg, noblock=1) const ldns_rdf * { Py_XDECREF($1_bytes); } #endif %nodefaultctor ldns_struct_rdf; /* No default constructor. */ %nodefaultdtor ldns_struct_rdf; /* No default destructor. */ /* * This file must contain all %newobject and %delobject tags also for * ldns_dname. This is because the ldns_dname is a derived class from ldns_rdf. */ %newobject ldns_rdf_new; %newobject ldns_rdf_new_frm_str; %newobject ldns_rdf_new_frm_data; %newobject ldns_rdf_address_reverse; %newobject ldns_rdf_clone; %newobject ldns_rdf2str; %newobject ldns_dname_new; %newobject ldns_dname_new_frm_str; %newobject ldns_dname_new_frm_data; %newobject ldns_dname_cat_clone; %newobject ldns_dname_label; %newobject ldns_dname_left_chop; %newobject ldns_dname_reverse; %delobject ldns_rdf_deep_free; %delobject ldns_rdf_free; /* * Should the ldns_rdf_new() also be marked as deleting its data parameter? */ %delobject ldns_rdf_set_data; /* Because data are directly coupled into rdf. */ %rename(ldns_rdf) ldns_struct_rdf; /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ #ifdef LDNS_DEBUG %rename(__ldns_rdf_deep_free) ldns_rdf_deep_free; %rename(__ldns_rdf_free) ldns_rdf_free; %inline %{ /*! * @brief Prints information about deallocated rdf and deallocates. */ void _ldns_rdf_deep_free (ldns_rdf *r) { printf("******** LDNS_RDF deep free 0x%lX ************\n", (long unsigned int) r); ldns_rdf_deep_free(r); } /*! * @brief Prints information about deallocated rdf and deallocates. */ void _ldns_rdf_free (ldns_rdf* r) { printf("******** LDNS_RDF free 0x%lX ************\n", (long unsigned int) r); ldns_rdf_free(r); } %} #else /* !LDNS_DEBUG */ %rename(_ldns_rdf_deep_free) ldns_rdf_deep_free; %rename(_ldns_rdf_free) ldns_rdf_free; #endif /* LDNS_DEBUG */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ %inline %{ /*! * @brief returns a human readable string containing rdf type. */ const char *ldns_rdf_type2str(const ldns_rdf *rdf) { if (rdf) { switch(ldns_rdf_get_type(rdf)) { case LDNS_RDF_TYPE_NONE: return 0; case LDNS_RDF_TYPE_DNAME: return "DNAME"; case LDNS_RDF_TYPE_INT8: return "INT8"; case LDNS_RDF_TYPE_INT16: return "INT16"; case LDNS_RDF_TYPE_INT32: return "INT32"; case LDNS_RDF_TYPE_A: return "A"; case LDNS_RDF_TYPE_AAAA: return "AAAA"; case LDNS_RDF_TYPE_STR: return "STR"; case LDNS_RDF_TYPE_APL: return "APL"; case LDNS_RDF_TYPE_B32_EXT: return "B32_EXT"; case LDNS_RDF_TYPE_B64: return "B64"; case LDNS_RDF_TYPE_HEX: return "HEX"; case LDNS_RDF_TYPE_NSEC: return "NSEC"; case LDNS_RDF_TYPE_TYPE: return "TYPE"; case LDNS_RDF_TYPE_CLASS: return "CLASS"; case LDNS_RDF_TYPE_CERT_ALG: return "CER_ALG"; case LDNS_RDF_TYPE_ALG: return "ALG"; case LDNS_RDF_TYPE_UNKNOWN: return "UNKNOWN"; case LDNS_RDF_TYPE_TIME: return "TIME"; case LDNS_RDF_TYPE_PERIOD: return "PERIOD"; case LDNS_RDF_TYPE_TSIGTIME: return "TSIGTIME"; case LDNS_RDF_TYPE_HIP: return "HIP"; case LDNS_RDF_TYPE_INT16_DATA: return "INT16_DATA"; case LDNS_RDF_TYPE_SERVICE: return "SERVICE"; case LDNS_RDF_TYPE_LOC: return "LOC"; case LDNS_RDF_TYPE_WKS: return "WKS"; case LDNS_RDF_TYPE_NSAP: return "NSAP"; case LDNS_RDF_TYPE_ATMA: return "ATMA"; case LDNS_RDF_TYPE_IPSECKEY: return "IPSECKEY"; case LDNS_RDF_TYPE_NSEC3_SALT: return "NSEC3_SALT"; case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER: return "NSEC3_NEXT_OWNER"; case LDNS_RDF_TYPE_ILNP64: return "ILNP64"; case LDNS_RDF_TYPE_EUI48: return "EUI48"; case LDNS_RDF_TYPE_EUI64: return "EUI64"; case LDNS_RDF_TYPE_TAG: return "TAG"; case LDNS_RDF_TYPE_LONG_STR: return "LONG_STR"; case LDNS_RDF_TYPE_AMTRELAY: return "AMTRELAY"; case LDNS_RDF_TYPE_SVCPARAMS: return "SVCPARAMS"; case LDNS_RDF_TYPE_CERTIFICATE_USAGE: return "CERTIFICATE_USAGE"; case LDNS_RDF_TYPE_SELECTOR: return "SELECTOR"; case LDNS_RDF_TYPE_MATCHING_TYPE: return "MATCHING_TYPE"; } } return 0; } %} %inline %{ /*! * @brief Returns the rdf data organised into a list of bytes. */ PyObject * ldns_rdf_data_as_bytearray(const ldns_rdf *rdf) { Py_ssize_t len; uint8_t *data; assert(rdf != NULL); len = ldns_rdf_size(rdf); data = ldns_rdf_data(rdf); return PyByteArray_FromStringAndSize((char *) data, len); } %} /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") ldns_struct_rdf "Resource record data field. The data is a network ordered array of bytes, which size is specified by the (16-bit) size field. To correctly parse it, use the type specified in the (16-bit) type field with a value from ldns_rdf_type." %extend ldns_struct_rdf { %pythoncode %{ def __init__(self): """ Cannot be created directly from Python. """ raise Exception("This class can't be created directly. " + "Please use: ldns_rdf_new, ldns_rdf_new_frm_data, " + "ldns_rdf_new_frm_str, ldns_rdf_new_frm_fp, " + "ldns_rdf_new_frm_fp_l") __swig_destroy__ = _ldns._ldns_rdf_deep_free # # LDNS_RDF_CONSTRUCTORS_ # @staticmethod def new_frm_str(string, rr_type, raiseException = True): """ Creates a new rdf from a string of a given type. :param string: string to use :type string: string :param rr_type: The type of the rdf. See predefined `RDF_TYPE_` constants. :type rr_type: integer :param raiseException: If True, an exception occurs in case a RDF object can't be created. :type raiseException: bool :throws TypeError: When parameters of mismatching types. :throws Exception: When raiseException set and rdf couldn't be created. :return: :class:`ldns_rdf` object or None. If the object can't be created and `raiseException` is True, an exception occurs. **Usage** >>> rdf = ldns.ldns_rdf.new_frm_str("74.125.43.99", ldns.LDNS_RDF_TYPE_A) >>> print rdf, rdf.get_type_str() A 74.125.43.99 >>> name = ldns.ldns_resolver.new_frm_file().get_name_by_addr(rdf) >>> if (name): print name 99.43.125.74.in-addr.arpa. 85277 IN PTR bw-in-f99.google.com. """ rr = _ldns.ldns_rdf_new_frm_str(rr_type, string) if (not rr) and raiseException: raise Exception("Can't create query packet") return rr # # _LDNS_RDF_CONSTRUCTORS # def __str__(self): """ Converts the rdata field to presentation format. """ return _ldns.ldns_rdf2str(self) def __cmp__(self, other): """ Compares two rdfs on their wire formats. (To order dnames according to rfc4034, use ldns_dname_compare.) :param other: The second one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (int) -1, 0 or 1 if self comes before other, is equal or self comes after other respectively. """ return _ldns.ldns_rdf_compare(self, other) def __lt__(self, other): """ Compares two rdfs on their formats. :param other: The socond one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (bool) True when `self` is less than 'other'. """ return _ldns.ldns_rdf_compare(self, other) == -1 def __le__(self, other): """ Compares two rdfs on their formats. :param other: The socond one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (bool) True when `self` is less than or equal to 'other'. """ return _ldns.ldns_rdf_compare(self, other) != 1 def __eq__(self, other): """ Compares two rdfs on their formats. :param other: The socond one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (bool) True when `self` is equal to 'other'. """ return _ldns.ldns_rdf_compare(self, other) == 0 def __ne__(self, other): """ Compares two rdfs on their formats. :param other: The socond one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (bool) True when `self` is not equal to 'other'. """ return _ldns.ldns_rdf_compare(self, other) != 0 def __gt__(self, other): """ Compares two rdfs on their formats. :param other: The socond one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (bool) True when `self` is greater than 'other'. """ return _ldns.ldns_rdf_compare(self, other) == 1 def __ge__(self, other): """ Compares two rdfs on their formats. :param other: The socond one RDF. :type other: :class:`ldns_rdf` :throws TypeError: When `other` of non-:class:`ldns_rdf` type. :return: (bool) True when `self` is greater than or equal to 'other'. """ return _ldns.ldns_rdf_compare(self, other) != -1 def print_to_file(self, output): """ Prints the data in the rdata field to the given `output` file stream (in presentation format). """ _ldns.ldns_rdf_print(output, self) def get_type_str(self): """ Returns the type of the rdf as a human readable string. :return: String containing rdf type. """ return ldns_rdf_type2str(self) def write_to_buffer(self, buffer): """ Copies the rdata data to the buffer in wire format. :param buffer: Buffer to append the rdf to. :type param: :class:`ldns_buffer` :throws TypeError: When `buffer` of non-:class:`ldns_buffer` type. :return: (ldns_status) ldns_status """ return _ldns.ldns_rdf2buffer_wire(buffer, self) #parameters: ldns_buffer *, const ldns_rdf *, #retvals: ldns_status def write_to_buffer_canonical(self, buffer): """ Copies the rdata data to the buffer in wire format. If the rdata is a dname, the letters will be converted to lower case during the conversion. :param buffer: LDNS buffer. :type buffer: :class:`ldns_buffer` :throws TypeError: When `buffer` of non-:class:`ldns_buffer` type. :return: (ldns_status) ldns_status """ return _ldns.ldns_rdf2buffer_wire_canonical(buffer, self) #parameters: ldns_buffer *, const ldns_rdf *, #retvals: ldns_status # # LDNS_RDF_METHODS_ # def address_reverse(self): """ Reverses an rdf, only actually useful for AAAA and A records. The returned rdf has the type LDNS_RDF_TYPE_DNAME! :return: (:class:`ldns_rdf`) The reversed rdf (a newly created rdf). """ return _ldns.ldns_rdf_address_reverse(self) #parameters: ldns_rdf *, #retvals: ldns_rdf * def clone(self): """ Clones a rdf structure. The data are copied. :return: (:class:`ldns_rdf`) A new rdf structure. """ return _ldns.ldns_rdf_clone(self) #parameters: const ldns_rdf *, #retvals: ldns_rdf * def data(self): """ Returns the data of the rdf. :return: (uint8_t \*) uint8_t* pointer to the rdf's data. """ return _ldns.ldns_rdf_data(self) #parameters: const ldns_rdf *, #retvals: uint8_t * def data_as_bytearray(self): """ Returns the data of the rdf as a bytearray. :return: (bytearray) Bytearray containing the rdf data. """ return _ldns.ldns_rdf_data_as_bytearray(self) #parameters: const ldns_rdf *, #retvals: bytearray def get_type(self): """ Returns the type of the rdf. We need to prepend the prefix get_ here to prevent conflict with the rdf_type TYPE. :return: (ldns_rdf_type) Identifier of the type. """ return _ldns.ldns_rdf_get_type(self) #parameters: const ldns_rdf *, #retvals: ldns_rdf_type def set_data(self, data): """ Sets the data portion of the rdf. The data are not copied, but are assigned to the rdf, `data` are decoupled from the Python engine. :param data: Data to be set. :type data: void \* """ _ldns.ldns_rdf_set_data(self, data) #parameters: ldns_rdf *, void *, #retvals: def set_size(self, size): """ Sets the size of the rdf. :param size: The new size. :type size: integer :throws TypeError: When size of non-integer type. """ _ldns.ldns_rdf_set_size(self,size) #parameters: ldns_rdf *,size_t, #retvals: def set_type(self, atype): """ Sets the type of the rdf. :param atype: rdf type :type atype: integer :throws TypeError: When atype of non-integer type. """ _ldns.ldns_rdf_set_type(self, atype) #parameters: ldns_rdf *, ldns_rdf_type, #retvals: def size(self): """ Returns the size of the rdf. :return: (size_t) uint16_t with the size. """ return _ldns.ldns_rdf_size(self) #parameters: const ldns_rdf *, #retvals: size_t @staticmethod def dname_new_frm_str(string): """ Creates a new dname rdf instance from a given string. This static method is equivalent to using of default :class:`ldns_rdf` constructor. :parameter string: String to use. :type string: string :throws TypeError: When not a string used. :return: :class:`ldns_rdf` or None if error. .. warning:: It is scheduled to be deprecated and removed. Use :class:`ldns_dname` constructor instead. """ warnings.warn("The ldns_rdf.dname_new_frm_str() method is" + " scheduled to be deprecated in future releases." + " Use ldns_dname constructor instead.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_new_frm_str(string) def absolute(self): """ Checks whether the given dname string is absolute (i.e., ends with a '.'). :return: (bool) True or False .. note:: This method was malfunctioning in ldns-1.3.16 and also possibly earlier. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname` to use the method. """ warnings.warn("The ldns_rdf.absolute() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) if self.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: string = self.__str__() return _ldns.ldns_dname_str_absolute(string) != 0 else: return False def make_canonical(self): """ Put a dname into canonical format (i.e., convert to lower case). Performs no action if not a dname. .. warning:: This method is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname` to use the method. """ warnings.warn("The ldns_rdf.make_canonical() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) _ldns.ldns_dname2canonical(self) def dname_compare(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_rdf` :throws TypeError: When not a :class:`ldns_rdf` used. :throws Exception: When not dnames compared. :return: (int) -1, 0 or 1 if `self` comes before `other`, `self` is equal or `self` comes after `other` respectively. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.dname_compare() method is" + " scheduled to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \ (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Both operands must be dname rdfs.") return _ldns.ldns_dname_compare(self, other) def cat(self, rd2): """ Concatenates `rd2` after `this` dname (`rd2` is copied, `this` dname is modified). :param rd2: The right-hand side. :type rd2: :class:`ldns_rdf` :throws TypeError: When `rd2` of non-:class:`ldns_rdf` or non-:class:`ldns_dname` type. :return: (ldns_status) LDNS_STATUS_OK on success. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.cat() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_cat(self, rd2) #parameters: ldns_rdf *, ldns_rdf *, #retvals: ldns_status def cat_clone(self, rd2): """ Concatenates two dnames together. :param rd2: The right-hand side. :type rd2: :class:`ldns_rdf` :throws TypeError: When `rd2` of non-:class:`ldns_rdf` or non-:class:`ldns_dname` type. :return: (:class:`ldns_rdf`) A new rdf with left-hand side + right-hand side content None when error. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.cat_clone() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_cat_clone(self, rd2) #parameters: const ldns_rdf *, const ldns_rdf *, #retvals: ldns_rdf * def interval(self, middle, next): """ Check whether the `middle` lays in the interval defined by `this` and `next` (`this` <= `middle` < `next`). This method is useful for nsec checking :param middle: The dname to check. :type middle: :class:`ldns_rdf` :param next: The boundary. :type next: :class:`ldns_rdf` :throws TypeError: When `middle` or `next` of non-:class:`ldns_rdf` type. :throws Exception: When non-dname rdfs compared. :return: (int) 0 on error or unknown, -1 when middle is in the interval, 1 when not. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.interval() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(middle, ldns_rdf)) or \ (not isinstance(next, ldns_rdf)): raise TypeError("Parameters must be derived from ldns_rdf.") if (self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \ (middle.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \ (next.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("All operands must be dname rdfs.") return _ldns.ldns_dname_interval(self, middle, next) #parameters: const ldns_rdf *, const ldns_rdf *, const ldns_rdf *, #retvals: int def is_subdomain(self, parent): """ Tests whether the name of the given instance falls under `parent` (i.e., is a sub-domain of `parent`). This function will return False if the given dnames are equal. :param parent: The parent's name. :type parent: :class:`ldns_rdf` :throws TypeError: When `parent` of non-:class:`ldns_rdf` type. :return: (bool) True if `this` falls under `parent`, otherwise False. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.is_subdomain() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_is_subdomain(self, parent) #parameters: const ldns_rdf *, const ldns_rdf *, #retvals: bool def label(self, labelpos): """ Look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label. The labels are numbered starting from 0 (left most). :param labelpos: Index of the label. (Labels are numbered 0, which is the left most.) :type labelpos: integer :throws TypeError: When `labelpos` of non-integer type. :return: (:class:`ldns_rdf`) A new rdf with the label as name or None on error. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.label() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_label(self, labelpos) #parameters: const ldns_rdf *, uint8_t, #retvals: ldns_rdf * def label_count(self): """ Count the number of labels inside a LDNS_RDF_DNAME type rdf. :return: (uint8_t) The number of labels. Will return 0 if not a dname. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.label_count() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_label_count(self) #parameters: const ldns_rdf *, #retvals: uint8_t def left_chop(self): """ Chop one label off the left side of a dname. (e.g., wwww.nlnetlabs.nl, becomes nlnetlabs.nl) :return: (:class:`ldns_rdf`) The remaining dname or None when error. .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.left_chop() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_left_chop(self) #parameters: const ldns_rdf *, #retvals: ldns_rdf * def reverse(self): """ Returns a clone of the given dname with the labels reversed. When reversing non-dnames a "." (root name) dname is returned. :throws Exception: When used on non-dname rdfs. :return: (:class:`ldns_rdf`) Clone of the dname with the labels reversed or ".". .. warning:: It is scheduled to be deprecated and removed. Convert :class:`ldns_rdf` to :class:`ldns_dname`. """ warnings.warn("The ldns_rdf.reverse() method is scheduled" + " to be deprecated in future releases." + " Convert the ldns_rdf to ldns_dname and the use its" + " methods.", PendingDeprecationWarning, stacklevel=2) if self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME: raise Exception("Operand must be a dname rdf.") return _ldns.ldns_dname_reverse(self) #parameters: const ldns_rdf *, #retvals: ldns_rdf * # # _LDNS_RDF_METHODS # %} } ldns-1.9.2/contrib/python/ldns_resolver.i0000664000175000017500000015044615212267520020061 0ustar willemwillem/****************************************************************************** * ldns_resolver.i: LDNS resolver class * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ /* Creates temporary instance of (ldns_resolver *). */ %typemap(in,numinputs=0,noblock=1) (ldns_resolver **r) { ldns_resolver *$1_res; $1 = &$1_res; } /* Result generation, appends (ldns_resolver *) after the result. */ %typemap(argout,noblock=1) (ldns_resolver **r) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_res), SWIGTYPE_p_ldns_struct_resolver, SWIG_POINTER_OWN | 0 )); } %newobject ldns_resolver_new; %newobject ldns_resolver_pop_nameserver; %newobject ldns_resolver_query; %newobject ldns_resolver_search; %newobject ldns_axfr_next; %newobject ldns_get_rr_list_addr_by_name; %newobject ldns_get_rr_list_name_by_addr; %delobject ldns_resolver_deep_free; %delobject ldns_resolver_free; %nodefaultctor ldns_struct_resolver; /* No default constructor. */ %nodefaultdtor ldns_struct_resolver; /* No default destructor. */ %ignore ldns_struct_resolver::_searchlist; %ignore ldns_struct_resolver::_nameservers; %ignore ldns_resolver_set_nameservers; %rename(ldns_resolver) ldns_struct_resolver; /* Clone data on pull. */ %newobject _ldns_axfr_last_pkt; %rename(__ldns_axfr_last_pkt) ldns_axfr_last_pkt; %inline %{ ldns_pkt * _ldns_axfr_last_pkt(const ldns_resolver *res) { return ldns_pkt_clone(ldns_axfr_last_pkt(res)); } %} %newobject _ldns_resolver_dnssec_anchors; %rename(__ldns_resolver_dnssec_anchors) ldns_resolver_dnssec_anchors; %inline %{ ldns_rr_list * _ldns_resolver_dnssec_anchors(const ldns_resolver *res) { return ldns_rr_list_clone(ldns_resolver_dnssec_anchors(res)); } %} %newobject _ldns_resolver_domain; %rename(__ldns_resolver_domain) ldns_resolver_domain; %inline %{ ldns_rdf * _ldns_resolver_domain(const ldns_resolver *res) { /* Prevents assertion failures. */ ldns_rdf *rdf; rdf = ldns_resolver_domain(res); if (rdf != NULL) { rdf = ldns_rdf_clone(rdf); } return rdf; } %} %newobject _ldns_resolver_tsig_algorithm; %rename(__ldns_resolver_tsig_algorithm) ldns_resolver_tsig_algorithm; %inline %{ const char * _ldns_resolver_tsig_algorithm(const ldns_resolver *res) { const char *str; str = ldns_resolver_tsig_algorithm(res); if (str != NULL) { str = strdup(str); } return str; } %} %newobject _ldns_resolver_tsig_keydata; %rename(__ldns_resolver_tsig_keydata) ldns_resolver_tsig_keydata; %inline %{ const char * _ldns_resolver_tsig_keydata(const ldns_resolver *res) { const char *str; str = ldns_resolver_tsig_keydata(res); if (str != NULL) { str = strdup(str); } return str; } %} %newobject _ldns_resolver_tsig_keyname; %rename(__ldns_resolver_tsig_keyname) ldns_resolver_tsig_keyname; %inline %{ const char * _ldns_resolver_tsig_keyname(const ldns_resolver *res) { const char *str; str = ldns_resolver_tsig_keyname(res); if (str != NULL) { str = strdup(str); } return str; } %} /* End of pull cloning. */ /* Clone data on push. */ %rename(__ldns_resolver_set_dnssec_anchors) ldns_resolver_set_dnssec_anchors; %inline %{ void _ldns_resolver_set_dnssec_anchors(ldns_resolver *res, ldns_rr_list * rrl) { ldns_rr_list *rrl_clone = NULL; if (rrl != NULL) { rrl_clone = ldns_rr_list_clone(rrl); } /* May leak memory, when overwriting pointer value. */ ldns_resolver_set_dnssec_anchors(res, rrl_clone); } %} %rename(__ldns_resolver_set_domain) ldns_resolver_set_domain; %inline %{ void _ldns_resolver_set_domain(ldns_resolver *res, ldns_rdf *rdf) { ldns_rdf *rdf_clone = NULL; if (rdf != NULL) { rdf_clone = ldns_rdf_clone(rdf); } /* May leak memory, when overwriting pointer value. */ ldns_resolver_set_domain(res, rdf_clone); } %} /* End of push cloning. */ /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ #ifdef LDNS_DEBUG %rename(__ldns_resolver_deep_free) ldns_resolver_deep_free; %rename(__ldns_resolver_free) ldns_resolver_free; %inline %{ /*! * @brief Prints information about deallocated resolver and deallocates. */ void _ldns_resolver_deep_free(ldns_resolver *r) { printf("******** LDNS_RESOLVER deep free 0x%lX ************\n", (long unsigned int) r); ldns_resolver_deep_free(r); } /*! * @brief Prints information about deallocated resolver and deallocates. * * @note There should be no need to use this function in the wrapper code, as * it is likely to leak memory. */ void _ldns_resolver_free(ldns_resolver *r) { printf("******** LDNS_RESOLVER free 0x%lX ************\n", (long unsigned int) r); ldns_resolver_free(r); } %} #else /* !LDNS_DEBUG */ %rename(_ldns_resolver_deep_free) ldns_resolver_deep_free; %rename(_ldns_resolver_free) ldns_resolver_free; #endif /* LDNS_DEBUG */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ %newobject _replacement_ldns_resolver_trusted_key; %inline %{ /*! * @brief Replaces the rrs in the list with their clones. * * Prevents memory corruption when automatically deallocating list content. */ void _rr_list_replace_content_with_clones(ldns_rr_list *rrl) { size_t count; unsigned int i; if (rrl == NULL) { return; } count = ldns_rr_list_rr_count(rrl); for (i = 0; i < count; ++i) { ldns_rr_list_set_rr(rrl, ldns_rr_clone(ldns_rr_list_rr(rrl, i)), i); } } /* * @brief Behaves similarly to ldns_resolver_trusted_key(). * * Prevents memory leakage by controlling the usage of content cloning. * * @return Newly allocated list of trusted key clones if any found, * NULL else. */ ldns_rr_list * _replacement_ldns_resolver_trusted_key( const ldns_resolver *res, ldns_rr_list *keys) { ldns_rr_list *trusted_keys = ldns_rr_list_new(); if (ldns_resolver_trusted_key(res, keys, trusted_keys)) { _rr_list_replace_content_with_clones(trusted_keys); } else { ldns_rr_list_deep_free(trusted_keys); trusted_keys = NULL; } return trusted_keys; } %} /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") ldns_struct_resolver "LDNS resolver object. The :class:`ldns_resolver` object keeps a list of name servers and can perform queries. **Usage** >>> import ldns >>> resolver = ldns.ldns_resolver.new_frm_file(\"/etc/resolv.conf\") >>> pkt = resolver.query(\"www.nic.cz\", ldns.LDNS_RR_TYPE_A,ldns.LDNS_RR_CLASS_IN) >>> if (pkt) and (pkt.answer()): >>> print pkt.answer() www.nic.cz. 1757 IN A 217.31.205.50 This simple example instances a resolver in order to resolve www.nic.cz A type record." %extend ldns_struct_resolver { %pythoncode %{ def __init__(self): """ Cannot be created directly from Python. """ raise Exception("This class can't be created directly. " + "Please use: new_frm_file(filename), new_frm_fp(file) " + "or new_frm_fp_l(file, line)") __swig_destroy__ = _ldns._ldns_resolver_deep_free # # LDNS_RESOLVER_CONSTRUCTORS_ # @staticmethod def new(): """ Creates a new resolver object. :return: (:class:`ldns_resolver`) New resolver object or None. .. note:: The returned resolver object is unusable unless some name servers are added. **Usage** >>> resolver = ldns.ldns_resolver.new() >>> ns_addr = ldns.ldns_rdf.new_frm_str("8.8.8.8", ldns.LDNS_RDF_TYPE_A) >>> if not ns_addr: raise Exception("Can't create resolver address.") >>> status = resolver.push_nameserver(ns_addr) >>> if status != ldns.LDNS_STATUS_OK: raise Exception("Can't push resolver address.") >>> pkt = resolver.query("www.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) >>> if (pkt) and (pkt.answer()): >>> print pkt.answer() www.nic.cz. 1265 IN A 217.31.205.50 """ return _ldns.ldns_resolver_new() @staticmethod def new_frm_file(filename = "/etc/resolv.conf", raiseException=True): """ Creates a resolver object from given file name :param filename: Name of file which contains resolver information (usually /etc/resolv.conf). :type filename: str :param raiseException: If True, an exception occurs in case a resolver object can't be created. :type raiseException: bool :throws TypeError: When arguments of inappropriate types. :throws Exception: When `raiseException` set and resolver couldn't be created. :return: (:class:`ldns_resolver`) Resolver object or None. An exception occurs if the object can't be created and 'raiseException' is True. """ status, resolver = _ldns.ldns_resolver_new_frm_file(filename) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create resolver, error: %d" % status) return None return resolver @staticmethod def new_frm_fp(file, raiseException=True): """ Creates a resolver object from file :param file: A file object. :type file: file :param raiseException: If True, an exception occurs in case a resolver object can't be created. :type raiseException: bool :throws TypeError: When arguments of inappropriate types. :throws Exception: When `raiseException` set and resolver couldn't be created. :return: (:class:`ldns_resolver`) Resolver object or None. An exception occurs if the object can't be created and `raiseException` is True. """ status, resolver = _ldns.ldns_resolver_new_frm_fp(file) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create resolver, error: %d" % status) return None return resolver @staticmethod def new_frm_fp_l(file, raiseException=True): """ Creates a resolver object from file :param file: A file object. :type file: file :param raiseException: If True, an exception occurs in case a resolver instance can't be created. :type raiseException: bool :throws TypeError: When arguments of inappropriate types. :throws Exception: When `raiseException` set and resolver couldn't be created. :return: * (:class:`ldns_resolver`) Resolver instance or None. An exception occurs if an instance can't be created and `raiseException` is True. * (int) - The line number. (e.g., for debugging) """ status, resolver, line = _ldns.ldns_resolver_new_frm_fp_l(file) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create resolver, error: %d" % status) return None return resolver, line # # _LDNS_RESOLVER_CONSTRUCTORS # # High level functions def get_addr_by_name(self, name, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD): """ Ask the resolver about name and return all address records. :param name: The name to look for. String is automatically converted to dname. :type name: :class:`ldns_dname` or str :param aclass: The class to use. :type aclass: ldns_rr_class :param flags: Give some optional flags to the query. :type flags: uint16_t :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) RR List object or None. **Usage** >>> addr = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) >>> if (not addr): raise Exception("Can't retrieve server address") >>> for rr in addr.rrs(): >>> print rr www.l.google.com. 300 IN A 74.125.43.99 www.l.google.com. 300 IN A 74.125.43.103 www.l.google.com. 300 IN A 74.125.43.104 www.l.google.com. 300 IN A 74.125.43.147 """ rdf = name if isinstance(name, str): rdf = _ldns.ldns_dname_new_frm_str(name) return _ldns.ldns_get_rr_list_addr_by_name(self, rdf, aclass, flags) def get_name_by_addr(self, addr, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD): """ Ask the resolver about the address and return the name. :param name: (ldns_rdf of A or AAAA type) the addr to look for. If a string is given, A or AAAA type is identified automatically. :type name: :class:`ldns_rdf` of A or AAAA type :param aclass: The class to use. :type aclass: ldns_rr_class :param flags: Give some optional flags to the query. :type flags: uint16_t :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) RR List object or None. **Usage** >>> addr = resolver.get_name_by_addr("74.125.43.99", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD) >>> if (not addr): raise Exception("Can't retrieve server address") >>> for rr in addr.rrs(): >>> print rr 99.43.125.74.in-addr.arpa. 85641 IN PTR bw-in-f99.google.com. """ rdf = addr if isinstance(addr, str): if (addr.find("::") >= 0): #IPv6 rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_AAAA, addr) else: rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_A, addr) return _ldns.ldns_get_rr_list_name_by_addr(self, rdf, aclass, flags) def print_to_file(self,output): """Print a resolver (in so far that is possible) state to output.""" _ldns.ldns_resolver_print(output,self) def axfr_complete(self): """ Returns True if the axfr transfer has completed (i.e., 2 SOA RRs and no errors were encountered). :return: (bool) """ return _ldns.ldns_axfr_complete(self) #parameters: const ldns_resolver *, #retvals: bool def axfr_last_pkt(self): """ Returns a last packet that was sent by the server in the AXFR transfer (usable for instance to get the error code on failure). :return: (:class:`ldns_pkt`) Last packet of the AXFR transfer. """ return _ldns._ldns_axfr_last_pkt(self) #parameters: const ldns_resolver *, #retvals: ldns_pkt * def axfr_next(self): """ Get the next stream of RRs in a AXFR. :return: (:class:`ldns_rr`) The next RR from the AXFR stream. """ return _ldns.ldns_axfr_next(self) #parameters: ldns_resolver *, #retvals: ldns_rr * def axfr_start(self, domain, aclass): """ Prepares the resolver for an axfr query. The query is sent and the answers can be read with :meth:`axfr_next`. :param domain: Domain to axfr. :type domain: :class:`dlsn_dname` :param aclass: The class to use. :type aclass: ldns_rr_class :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) The status of the transfer. .. note:: The type checking of parameter `domain` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. **Usage** :: status = resolver.axfr_start("nic.cz", ldns.LDNS_RR_CLASS_IN) if (status != ldns.LDNS_STATUS_OK): raise Exception("Can't start AXFR, error: %s" % ldns.ldns_get_errorstr_by_id(status)) #Print the results while True: rr = resolver.axfr_next() if not rr: break print rr """ # TODO -- Add checking for ldns_rdf and ldns_dname. rdf = domain if isinstance(domain, str): rdf = _ldns.ldns_dname_new_frm_str(domain) return _ldns.ldns_axfr_start(self, rdf, aclass) #parameters: ldns_resolver *resolver, ldns_rdf *domain, ldns_rr_class c #retvals: int # # LDNS_RESOLVER_METHODS_ # def debug(self): """ Get the debug status of the resolver. :return: (bool) True if so, otherwise False. """ return _ldns.ldns_resolver_debug(self) #parameters: const ldns_resolver *, #retvals: bool def dec_nameserver_count(self): """ Decrement the resolver's name server count. """ _ldns.ldns_resolver_dec_nameserver_count(self) #parameters: ldns_resolver *, #retvals: def defnames(self): """ Does the resolver apply default domain name. :return: (bool) """ return _ldns.ldns_resolver_defnames(self) #parameters: const ldns_resolver *, #retvals: bool def dnsrch(self): """ Does the resolver apply search list. :return: (bool) """ return _ldns.ldns_resolver_dnsrch(self) #parameters: const ldns_resolver *, #retvals: bool def dnssec(self): """ Does the resolver do DNSSEC. :return: (bool) True: yes, False: no. """ return _ldns.ldns_resolver_dnssec(self) #parameters: const ldns_resolver *, #retvals: bool def dnssec_anchors(self): """ Get the resolver's DNSSEC anchors. :return: (:class:`ldns_rr_list`) An rr list containing trusted DNSSEC anchors. """ return _ldns._ldns_resolver_dnssec_anchors(self) #parameters: const ldns_resolver *, #retvals: ldns_rr_list * def dnssec_cd(self): """ Does the resolver set the CD bit. :return: (bool) True: yes, False: no. """ return _ldns.ldns_resolver_dnssec_cd(self) #parameters: const ldns_resolver *, #retvals: bool def domain(self): """ What is the default dname to add to relative queries. :return: (:class:`ldns_dname`) The dname which is added. """ dname = _ldns._ldns_resolver_domain(self) if dname != None: return ldns_dname(_ldns._ldns_resolver_domain(self), clone=False) else: return dname #parameters: const ldns_resolver *, #retvals: ldns_rdf * def edns_udp_size(self): """ Get the resolver's udp size. :return: (uint16_t) The udp mesg size. """ return _ldns.ldns_resolver_edns_udp_size(self) #parameters: const ldns_resolver *, #retvals: uint16_t def fail(self): """ Does the resolver only try the first name server. :return: (bool) True: yes, fail, False: no, try the others. """ return _ldns.ldns_resolver_fail(self) #parameters: const ldns_resolver *, #retvals: bool def fallback(self): """ Get the truncation fall-back status. :return: (bool) Whether the truncation fall*back mechanism is used. """ return _ldns.ldns_resolver_fallback(self) #parameters: const ldns_resolver *, #retvals: bool def igntc(self): """ Does the resolver ignore the TC bit (truncated). :return: (bool) True: yes, False: no. """ return _ldns.ldns_resolver_igntc(self) #parameters: const ldns_resolver *, #retvals: bool def incr_nameserver_count(self): """ Increment the resolver's name server count. """ _ldns.ldns_resolver_incr_nameserver_count(self) #parameters: ldns_resolver *, #retvals: def ip6(self): """ Does the resolver use ip6 or ip4. :return: (uint8_t) 0: both, 1: ip4, 2:ip6 """ return _ldns.ldns_resolver_ip6(self) #parameters: const ldns_resolver *, #retvals: uint8_t def nameserver_count(self): """ How many name server are configured in the resolver. :return: (size_t) Number of name servers. """ return _ldns.ldns_resolver_nameserver_count(self) #parameters: const ldns_resolver *, #retvals: size_t def nameserver_rtt(self, pos): """ Return the used round trip time for a specific name server. :param pos: The index to the name server. :type pos: size_t :throws TypeError: When arguments of inappropriate types. :return: (size_t) The rrt, 0: infinite, >0: undefined (as of * yet). """ return _ldns.ldns_resolver_nameserver_rtt(self, pos) #parameters: const ldns_resolver *,size_t, #retvals: size_t def nameservers(self): """ Return the configured name server ip address. :return: (ldns_rdf \*\*) A ldns_rdf pointer to a list of the addresses. """ # TODO -- Convert to list of ldns_rdf. return _ldns.ldns_resolver_nameservers(self) #parameters: const ldns_resolver *, #retvals: ldns_rdf ** def nameservers_randomize(self): """ Randomize the name server list in the resolver. """ _ldns.ldns_resolver_nameservers_randomize(self) #parameters: ldns_resolver *, #retvals: def pop_nameserver(self): """ Pop the last name server from the resolver. :return: (:class:`ldns_rdf`) The popped address or None if empty. """ return _ldns.ldns_resolver_pop_nameserver(self) #parameters: ldns_resolver *, #retvals: ldns_rdf * def port(self): """ Get the port the resolver should use. :return: (uint16_t) The port number. """ return _ldns.ldns_resolver_port(self) #parameters: const ldns_resolver *, #retvals: uint16_t def prepare_query_pkt(self, name, t, c, f, raiseException=True): """ Form a query packet from a resolver and name/type/class combo. :param name: Query for this name. :type name: :class:`ldns_dname` or str :param t: Query for this type (may be 0, defaults to A). :type t: ldns_rr_type :param c: Query for this class (may be 0, default to IN). :type c: ldns_rr_class :param f: The query flags. :type f: uint16_t :throws TypeError: When arguments of inappropriate types. :throws Exception: When `raiseException` set and answer couldn't be resolved. :return: (:class:`ldns_pkt`) Query packet or None. An exception occurs if the object can't be created and 'raiseException' is True. """ rdf = name if isinstance(name, str): rdf = _ldns.ldns_dname_new_frm_str(name) status, pkt = _ldns.ldns_resolver_prepare_query_pkt(self, rdf, t, c, f) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create resolver, error: %d" % status) return None return pkt #parameters: ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t, #retvals: ldns_status,ldns_pkt ** def push_dnssec_anchor(self, rr): """ Push a new trust anchor to the resolver. It must be a DS or DNSKEY rr. :param rr: The RR to add as a trust anchor. :type rr: DS of DNSKEY :class:`ldns_rr` :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) A status. """ return _ldns.ldns_resolver_push_dnssec_anchor(self, rr) #parameters: ldns_resolver *,ldns_rr *, #retvals: ldns_status def push_nameserver(self, n): """ Push a new name server to the resolver. It must be an IP address v4 or v6. :param n: The ip address. :type n: :class:`ldns_rdf` of A or AAAA type. :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) A status. """ return _ldns.ldns_resolver_push_nameserver(self, n) #parameters: ldns_resolver *,ldns_rdf *, #retvals: ldns_status def push_nameserver_rr(self, rr): """ Push a new name server to the resolver. It must be an A or AAAA RR record type. :param rr: The resource record. :type rr: :class:`ldns_rr` of A or AAAA type. :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) A status. """ return _ldns.ldns_resolver_push_nameserver_rr(self, rr) #parameters: ldns_resolver *,ldns_rr *, #retvals: ldns_status def push_nameserver_rr_list(self, rrlist): """ Push a new name server rr_list to the resolver. :param rrlist: The rr list to push. :type rrlist: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. :return: (ldns_status) A status. """ return _ldns.ldns_resolver_push_nameserver_rr_list(self, rrlist) #parameters: ldns_resolver *,ldns_rr_list *, #retvals: ldns_status def push_searchlist(self, rd): """ Push a new rd to the resolver's search-list. :param rd: To push. :param rd: :class:`ldns_dname` or str :throws TypeError: When arguments of inappropriate types. .. note: The function does not return any return status, so the caller must ensure the correctness of the passed values. """ rdf = rd if isinstance(rd, str): rdf = _ldns.ldns_dname_new_frm_str(rd) _ldns.ldns_resolver_push_searchlist(self, rdf) #parameters: ldns_resolver *,ldns_rdf *, #retvals: def query(self,name,atype=_ldns.LDNS_RR_TYPE_A,aclass=_ldns.LDNS_RR_CLASS_IN,flags=_ldns.LDNS_RD): """ Send a query to a name server. :param name: The name to look for. :type name: :class:`ldns_dname` or str :param atype: The RR type to use. :type atype: ldns_rr_type :param aclass: The RR class to use. :type aclass: ldns_rr_class :param flags: Give some optional flags to the query. :type flags: uint16_t :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_pkt`) A packet with the reply from the name server if _defnames is true the default domain will be added. """ # Explicit conversion from string to ldns_rdf prevents memory leaks. # TODO -- Find out why. dname = name if isinstance(name, str): dname = _ldns.ldns_dname_new_frm_str(name) return _ldns.ldns_resolver_query(self, dname, atype, aclass, flags) #parameters: const ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t, #retvals: ldns_pkt * def random(self): """ Does the resolver randomize the name server before usage? :return: (bool) True: yes, False: no. """ return _ldns.ldns_resolver_random(self) #parameters: const ldns_resolver *, #retvals: bool def recursive(self): """ Is the resolver set to recurse? :return: (bool) True if so, otherwise False. """ return _ldns.ldns_resolver_recursive(self) #parameters: const ldns_resolver *, #retvals: bool def retrans(self): """ Get the retransmit interval. :return: (uint8_t) The retransmit interval. """ return _ldns.ldns_resolver_retrans(self) #parameters: const ldns_resolver *, #retvals: uint8_t def retry(self): """ Get the number of retries. :return: (uint8_t) The number of retries. """ return _ldns.ldns_resolver_retry(self) #parameters: const ldns_resolver *, #retvals: uint8_t def rtt(self): """ Return the used round trip times for the name servers. :return: (size_t \*) a size_t* pointer to the list. yet) """ return _ldns.ldns_resolver_rtt(self) #parameters: const ldns_resolver *, #retvals: size_t * def search(self, name, atype=_ldns.LDNS_RR_TYPE_A, aclass=_ldns.LDNS_RR_CLASS_IN, flags=_ldns.LDNS_RD): """ Send the query for using the resolver and take the search list into account The search algorithm is as follows: If the name is absolute, try it as-is, otherwise apply the search list. :param name: The name to look for. :type name: :class:`ldns_dname` or str :param atype: The RR type to use. :type atype: ldns_rr_type :param aclass: The RR class to use. :type aclass: ldns_rr_class :param flags: Give some optional flags to the query. :type flags: uint16_t :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_pkt`) A packet with the reply from the name server. """ # Explicit conversion from string to ldns_rdf prevents memory leaks. # TODO -- Find out why. dname = name if isinstance(name, str): dname = _ldns.ldns_dname_new_frm_str(name) return _ldns.ldns_resolver_search(self, dname, atype, aclass, flags) #parameters: const ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t, #retvals: ldns_pkt * def searchlist(self): """ What is the search-list as used by the resolver. :return: (ldns_rdf \*\*) A ldns_rdf pointer to a list of the addresses. """ return _ldns.ldns_resolver_searchlist(self) #parameters: const ldns_resolver *, #retvals: ldns_rdf \*\* def searchlist_count(self): """ Return the resolver's search-list count. :return: (size_t) The search-list count. """ return _ldns.ldns_resolver_searchlist_count(self) #parameters: const ldns_resolver *, #retvals: size_t def send(self, name, atype, aclass, flags, raiseException=True): """ Send the query for name as-is. :param name: The name to look for. :type name: :class:`ldns_dname` or str :param atype: The RR type to use. :type atype: ldns_rr_type :param aclass: The RR class to use. :type aclass: ldns_rr_class :param flags: Give some optional flags to the query. :type flags: uint16_t :throws TypeError: When arguments of inappropriate types. :throws Exception: When `raiseException` set and answer couldn't be resolved. :return: (:class:`ldns_pkt`) A packet with the reply from the name server. """ # Explicit conversion from string to ldns_rdf prevents memory leaks. # TODO -- Find out why. dname = name if isinstance(name, str): dname = _ldns.ldns_dname_new_frm_str(name) status, pkt = _ldns.ldns_resolver_send(self, dname, atype, aclass, flags) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create resolver, error: %d" % status) return None return pkt #parameters: ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t, #retvals: ldns_status,ldns_pkt ** def send_pkt(self, query_pkt): """ Send the given packet to a name server. :param query_pkt: Query packet. :type query_pkt: :class:`ldns_pkt` :throws TypeError: When arguments of inappropriate types. :return: * (ldns_status) Return status. * (:class:`ldns_pkt`) Response packet if returns status ok. """ status, answer = _ldns.ldns_resolver_send_pkt(self, query_pkt) return _ldns.ldns_resolver_send_pkt(self,query_pkt) #parameters: ldns_resolver *,ldns_pkt *, #retvals: ldns_status,ldns_pkt ** def set_debug(self, b): """ Set the resolver debugging. :param b: True: debug on, False: debug off. :type b: bool """ _ldns.ldns_resolver_set_debug(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_defnames(self, b): """ Whether the resolver uses the name set with _set_domain. :param b: True: use the defaults, False: don't use them. :type b: bool """ _ldns.ldns_resolver_set_defnames(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_dnsrch(self, b): """ Whether the resolver uses the search list. :param b: True: use the list, False: don't use the list. :type b: bool """ _ldns.ldns_resolver_set_dnsrch(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_dnssec(self, b): """ Whether the resolver uses DNSSEC. :param b: True: use DNSSEC, False: don't use DNSSEC. :type b: bool """ _ldns.ldns_resolver_set_dnssec(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_dnssec_anchors(self, l): """ Set the resolver's DNSSEC anchor list directly. RRs should be of type DS or DNSKEY. :param l: The list of RRs to use as trust anchors. :type l: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. """ _ldns._ldns_resolver_set_dnssec_anchors(self, l) #parameters: ldns_resolver *,ldns_rr_list *, #retvals: def set_dnssec_cd(self, b): """ Whether the resolver uses the checking disable bit. :param b: True: enable, False: disable. :type b: bool """ _ldns.ldns_resolver_set_dnssec_cd(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_domain(self, rd): """ Set the resolver's default domain. This gets appended when no absolute name is given. :param rd: The name to append. :type rd: :class:`ldns_dname` or str :throws TypeError: When arguments of inappropriate types. :throws Exception: When `rd` a non dname rdf. .. note:: The type checking of parameter `rd` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # Also has to be able to pass None or dame string. if isinstance(rd, str): dname = _ldns.ldns_dname_new_frm_str(rd) elif (not isinstance(rd, ldns_dname)) and \ isinstance(rd, ldns_rdf) and \ rd.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_resolver.set_domain() method" + " will drop the possibility to accept ldns_rdf." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) dname = rd else: dname = rd if (not isinstance(dname, ldns_rdf)) and (dname != None): raise TypeError("Parameter must be derived from ldns_rdf.") if (isinstance(dname, ldns_rdf)) and \ (dname.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") _ldns._ldns_resolver_set_domain(self, dname) #parameters: ldns_resolver *,ldns_rdf *, #retvals: def set_edns_udp_size(self, s): """ Set maximum udp size. :param s: The udp max size. :type s: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_edns_udp_size(self,s) #parameters: ldns_resolver *,uint16_t, #retvals: def set_fail(self, b): """ Whether or not to fail after one failed query. :param b: True: yes fail, False: continue with next name server. :type b: bool """ _ldns.ldns_resolver_set_fail(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_fallback(self, fallback): """ Set whether the resolvers truncation fall-back mechanism is used when :meth:`query` is called. :param fallback: Whether to use the fall-back mechanism. :type fallback: bool """ _ldns.ldns_resolver_set_fallback(self, fallback) #parameters: ldns_resolver *,bool, #retvals: def set_igntc(self, b): """ Whether or not to ignore the TC bit. :param b: True: yes ignore, False: don't ignore. :type b: bool """ _ldns.ldns_resolver_set_igntc(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_ip6(self, i): """ Whether the resolver uses ip6. :param i: 0: no pref, 1: ip4, 2: ip6 :type i: uint8_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_ip6(self, i) #parameters: ldns_resolver *,uint8_t, #retvals: def set_nameserver_count(self, c): """ Set the resolver's name server count directly. :param c: The name server count. :type c: size_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_nameserver_count(self, c) #parameters: ldns_resolver *,size_t, #retvals: def set_nameserver_rtt(self, pos, value): """ Set round trip time for a specific name server. Note this currently differentiates between: unreachable and reachable. :param pos: The name server position. :type pos: size_t :param value: The rtt. :type value: size_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_nameserver_rtt(self, pos, value) #parameters: ldns_resolver *,size_t,size_t, #retvals: def set_nameservers(self, rd): """ Set the resolver's name server count directly by using an rdf list. :param rd: The resolver addresses. :type rd: ldns_rdf \*\* :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_nameservers(self, rd) #parameters: ldns_resolver *,ldns_rdf **, #retvals: def set_port(self, p): """ Set the port the resolver should use. :param p: The port number. :type p: uint16_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_port(self, p) #parameters: ldns_resolver *,uint16_t, #retvals: def set_random(self, b): """ Should the name server list be randomized before each use. :param b: True: randomize, False: don't. :type b: bool """ _ldns.ldns_resolver_set_random(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_recursive(self, b): """ Set the resolver recursion. :param b: True: set to recurse, False: unset. :type b: bool """ _ldns.ldns_resolver_set_recursive(self, b) #parameters: ldns_resolver *,bool, #retvals: def set_retrans(self, re): """ Set the resolver retrans time-out (in seconds). :param re: The retransmission interval in seconds. :type re: uint8_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_retrans(self, re) #parameters: ldns_resolver *,uint8_t, #retvals: def set_retry(self, re): """ Set the resolver retry interval (in seconds). :param re: The retry interval. :type re: uint8_t :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_retry(self,re) #parameters: ldns_resolver *,uint8_t, #retvals: def set_rtt(self, rtt): """ Set round trip time for all name servers. Note this currently differentiates between: unreachable and reachable. :param rtt: A list with the times. :type rtt: size \* :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_rtt(self, rtt) #parameters: ldns_resolver *,size_t *, #retvals: def set_timeout(self, timeout): """ Set the resolver's socket time out when talking to remote hosts. :param timeout: The time-out to use. :param timeout: struct timeval :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_timeout(self,timeout) #parameters: ldns_resolver *,struct timeval, #retvals: def set_tsig_algorithm(self, tsig_algorithm): """ Set the tsig algorithm. :param tsig_algorithm: The tsig algorithm. :param tsig_algorithm: str :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_tsig_algorithm(self, tsig_algorithm) #parameters: ldns_resolver *,char *, #retvals: def set_tsig_keydata(self, tsig_keydata): """ Set the tsig key data. :param tsig_keydata: The key data. :type tsig_keydata: str :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_tsig_keydata(self, tsig_keydata) #parameters: ldns_resolver *,char *, #retvals: def set_tsig_keyname(self, tsig_keyname): """ Set the tsig key name. :param tsig_keyname: The tsig key name. :type tsig_keyname: str :throws TypeError: When arguments of inappropriate types. """ _ldns.ldns_resolver_set_tsig_keyname(self, tsig_keyname) #parameters: ldns_resolver *,char *, #retvals: def set_usevc(self, b): """ Whether the resolver uses a virtual circuit (TCP). :param b: True: use TCP, False: don't use TCP. :type b: bool """ _ldns.ldns_resolver_set_usevc(self, b) #parameters: ldns_resolver *,bool, #retvals: def timeout(self): """ What is the time-out on socket connections. :return: (struct timeval) The time-out. """ return _ldns.ldns_resolver_timeout(self) #parameters: const ldns_resolver *, #retvals: struct timeval def trusted_key(self, keys): """ Returns true if at least one of the provided keys is a trust anchor. :param keys: The key set to check. :type keys: :class:`ldns_rr_list` :throws TypeError: When arguments of inappropriate types. :return: (:class:`ldns_rr_list`) List of trusted keys if at least one of the provided keys is a configured trust anchor, None else. """ return _ldns._replacement_ldns_resolver_trusted_key(self, keys) #parameters: const ldns_resolver *,ldns_rr_list *,ldns_rr_list *, #retvals: bool def tsig_algorithm(self): """ Return the tsig algorithm as used by the name server. :return: (str) The algorithm used. """ return _ldns._ldns_resolver_tsig_algorithm(self) #parameters: const ldns_resolver *, #retvals: char * def tsig_keydata(self): """ Return the tsig key data as used by the name server. :return: (str) The key data used. """ return _ldns._ldns_resolver_tsig_keydata(self) #parameters: const ldns_resolver *, #retvals: char * def tsig_keyname(self): """ Return the tsig key name as used by the name server. :return: (str) The name used. """ return _ldns._ldns_resolver_tsig_keyname(self) #parameters: const ldns_resolver *, #retvals: char * def usevc(self): """ Does the resolver use tcp or udp. :return: (bool) True: tcp, False: udp. """ return _ldns.ldns_resolver_usevc(self) #parameters: const ldns_resolver *, #retvals: bool # # _LDNS_RESOLVER_METHODS # %} } ldns-1.9.2/contrib/python/ldns_dname.i0000664000175000017500000006573015212267520017305 0ustar willemwillem/****************************************************************************** * ldns_dname.i: LDNS domain name class * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ /* * Not here (with the exception of functions defined in this C code section), * must be set in ldns_rdf.i. */ /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ /* * Not here (with the exception of functions defined in this C code section), * must be set in ldns_rdf.i. */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ /* None */ /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %pythoncode %{ class ldns_dname(ldns_rdf): """ Domain name. This class contains methods to read and manipulate domain name drfs. Domain names are stored in :class:`ldns_rdf` structures, with the type LDNS_RDF_TYPE_DNAME. This class encapsulates such rdfs. **Usage** >>> import ldns >>> dn1 = ldns.ldns_dname("test.nic.cz") >>> print dn1 test.nic.cz. >>> dn2 = ldns.ldns_dname("nic.cz") >>> if dn2.is_subdomain(dn1): print dn2, "is sub-domain of", dn1 >>> if dn1.is_subdomain(dn2): print dn1, "is sub-domain of", dn2 test.nic.cz. is sub-domain of nic.cz. The following two examples show the creation of :class:`ldns_dname` from :class:`ldns_rdf`. The first shows the creation of :class:`ldns_dname` instance which is independent of the original `rdf`. >>> import ldns >>> rdf = ldns.ldns_rdf.new_frm_str("a.ns.nic.cz", ldns.LDNS_RDF_TYPE_DNAME) >>> dn = ldns.ldns_dname(rdf) >>> print dn a.ns.nic.cz. The latter shows the wrapping of a :class:`ldns_rdf` onto a :class:`ldns_dname` without the creation of a copy. >>> import ldns >>> dn = ldns.ldns_dname(ldns.ldns_rdf.new_frm_str("a.ns.nic.cz", ldns.LDNS_RDF_TYPE_DNAME), clone=False) >>> print dn a.ns.nic.cz. """ def __init__(self, initialiser, clone=True): """ Creates a new dname rdf from a string or :class:`ldns_rdf`. :param initialiser: string or :class:`ldns_rdf` :type initialiser: string or :class:`ldns_rdf` containing a dname :param clone: Whether to clone or directly grab the parameter. :type clone: bool :throws TypeError: When `initialiser` of invalid type. """ if isinstance(initialiser, ldns_rdf) and \ (initialiser.get_type() == _ldns.LDNS_RDF_TYPE_DNAME): if clone == True: self.this = _ldns.ldns_rdf_clone(initialiser) else: self.this = initialiser else: self.this = _ldns.ldns_dname_new_frm_str(initialiser) # # LDNS_DNAME_CONSTRUCTORS_ # @staticmethod def new_frm_str(string): """ Creates a new dname rdf instance from a string. This static method is equivalent to using default :class:`ldns_dname` constructor. :param string: String to use. :type string: string :throws TypeError: When `string` not a string. :return: (:class:`ldns_dname`) dname rdf. """ return ldns_dname(string) @staticmethod def new_frm_rdf(rdf, clone=True): """ Creates a new dname rdf instance from a dname :class:`ldns_rdf`. This static method is equivalent to using the default :class:`ldns_dname` constructor. :param rdf: A dname :class:`ldns_rdf`. :type rdf: :class:`ldns_rdf` :throws TypeError: When `rdf` of inappropriate type. :param clone: Whether to create a clone or to wrap present instance. :type clone: bool :return: (:class:`ldns_dname`) dname rdf. """ return ldns_dname(rdf, clone=clone) # # _LDNS_DNAME_CONSTRUCTORS # def write_to_buffer(self, buffer): """ Copies the dname data to the buffer in wire format. :param buffer: Buffer to append the result to. :type param: :class:`ldns_buffer` :throws TypeError: When `buffer` of non-:class:`ldns_buffer` type. :return: (ldns_status) ldns_status """ return _ldns.ldns_dname2buffer_wire(buffer, self) #parameters: ldns_buffer *, const ldns_rdf *, #retvals: ldns_status # # LDNS_DNAME_METHODS_ # def absolute(self): """ Checks whether the given dname string is absolute (i.e., ends with a '.'). :return: (bool) True or False """ string = self.__str__() return _ldns.ldns_dname_str_absolute(string) != 0 def make_canonical(self): """ Put a dname into canonical format (i.e., convert to lower case). """ _ldns.ldns_dname2canonical(self) def __cmp__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (int) -1, 0 or 1 if self comes before other, self is equal or self comes after other respectively. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__cmp__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) def __lt__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (bool) True when `self` is less than 'other'. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__lt__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) == -1 def __le__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (bool) True when `self` is less than or equal to 'other'. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__le__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) != 1 def __eq__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (bool) True when `self` is equal to 'other'. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__eq__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) == 0 def __ne__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (bool) True when `self` is not equal to 'other'. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__ne__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) != 0 def __gt__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (bool) True when `self` is greater than 'other'. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__gt__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) == 1 def __ge__(self, other): """ Compares two dname rdf according to the algorithm for ordering in RFC4034 Section 6. :param other: The second dname rdf to compare. :type other: :class:`ldns_dname` :throws TypeError: When `other` of invalid type. :return: (bool) True when `self` is greater than or equal to 'other'. .. note:: The type checking of parameter `other` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(other, ldns_dname)) and \ isinstance(other, ldns_rdf) and \ other.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.__ge__() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) if not isinstance(other, ldns_rdf): raise TypeError("Parameter must be derived from ldns_rdf.") if (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("Operands must be ldns_dname.") return _ldns.ldns_dname_compare(self, other) != -1 def cat(self, rd2): """ Concatenates rd2 after this dname (`rd2` is copied, `this` dname is modified). :param rd2: The right-hand side. :type rd2: :class:`ldns_dname` :throws TypeError: When `rd2` of invalid type. :return: (ldns_status) LDNS_STATUS_OK on success .. note:: The type checking of parameter `rd2` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(rd2, ldns_dname)) and \ isinstance(rd2, ldns_rdf) and \ rd2.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.cat() method will" + " drop the support of ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_cat(self, rd2) #parameters: ldns_rdf *, ldns_rdf *, #retvals: ldns_status def cat_clone(self, rd2): """ Concatenates two dnames together. :param rd2: The right-hand side. :type rd2: :class:`ldns_dname` :throws TypeError: When `rd2` of invalid type. :return: (:class:`ldns_dname`) A new rdf with left-hand side + right-hand side content None when error. .. note:: The type checking of parameter `rd2` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(rd2, ldns_dname)) and \ isinstance(rd2, ldns_rdf) and \ rd2.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.cat_clone() method will" + " drop the support of ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) ret = _ldns.ldns_dname_cat_clone(self, rd2) if ret != None: ret = ldns_dname(ret, clone=False) return ret #parameters: const ldns_rdf *, const ldns_rdf *, #retvals: ldns_rdf * def interval(self, middle, next): """ Check whether `middle` lays in the interval defined by `this` and `next` (`this` <= `middle` < `next`). This method is useful for nsec checking. :param middle: The dname to check. :type middle: :class:`ldns_dname` :param next: The boundary. :type next: :class:`ldns_dname` :throws TypeError: When `middle` or `next` of non-:class:`ldns_rdf` type. :throws Exception: When non-dname rdfs compared. :return: (int) 0 on error or unknown, -1 when middle is in the interval, 1 when not. .. note:: The type checking of parameters is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ # # The wrapped function generates asserts instead of setting # error status. They cannot be caught from Python so a check # is necessary. # if (not isinstance(middle, ldns_rdf)) or \ (not isinstance(next, ldns_rdf)): raise TypeError("Parameters must be derived from ldns_dname.") if (self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \ (middle.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \ (next.get_type() != _ldns.LDNS_RDF_TYPE_DNAME): raise Exception("All operands must be dname rdfs.") if (not isinstance(middle, ldns_dname)) or \ (not isinstance(next, ldns_dname)): warnings.warn("The ldns_dname.interval() method will" + " drop the possibility to compare ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_interval(self, middle, next) #parameters: const ldns_rdf *, const ldns_rdf *, const ldns_rdf *, #retvals: int def is_subdomain(self, parent): """ Tests whether the name of the instance falls under `parent` (i.e., is a sub-domain of `parent`). This function will return false if the given dnames are equal. :param parent: The parent's name. :type parent: :class:`ldns_dname` :throws TypeError: When `parent` of non-:class:`ldns_rdf` or derived type. :return: (bool) True if `this` falls under `parent`, otherwise False. .. note:: The type checking of parameters is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(parent, ldns_dname)) and \ isinstance(parent, ldns_rdf) and \ parent.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_dname.is_subdomain() method will" + " drop the support of ldns_rdf." + " Convert arguments to ldns_dname.", PendingDeprecationWarning, stacklevel=2) return _ldns.ldns_dname_is_subdomain(self, parent) #parameters: const ldns_rdf *, const ldns_rdf *, #retvals: bool def label(self, labelpos): """ Look inside the rdf and retrieve a specific label. The labels are numbered starting from 0 (left most). :param labelpos: Index of the label. (Labels are numbered 0, which is the left most.) :type labelpos: integer :throws TypeError: When `labelpos` of non-integer type. :return: (:class:`ldns_dname`) A new rdf with the label as name or None on error. """ ret = _ldns.ldns_dname_label(self, labelpos) if ret != None: ret = ldns_dname(ret, clone=False) return ret #parameters: const ldns_rdf *, uint8_t, #retvals: ldns_rdf * def label_count(self): """ Counts the number of labels. :return: (uint8_t) the number of labels. Will return 0 if not a dname. """ return _ldns.ldns_dname_label_count(self) #parameters: const ldns_rdf *, #retvals: uint8_t def left_chop(self): """ Chop one label off the left side of a dname. (e.g., wwww.nlnetlabs.nl, becomes nlnetlabs.nl) :return: (:class:`ldns_dname`) The remaining dname or None when error. """ return ldns_dname(_ldns.ldns_dname_left_chop(self), clone=False) #parameters: const ldns_rdf *, #retvals: ldns_rdf * def reverse(self): """ Returns a clone of the given dname with the labels reversed. :return: (:class:`ldns_dname`) A clone of the dname with the labels reversed. """ return ldns_dname(_ldns.ldns_dname_reverse(self), clone=False) #parameters: const ldns_rdf *, #retvals: ldns_rdf * # # _LDNS_DNAME_METHODS # %} ldns-1.9.2/contrib/python/ldns_buffer.i0000664000175000017500000006265615212267520017476 0ustar willemwillem/****************************************************************************** * ldns_buffer.i: LDNS buffer class * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ /* Creates a temporary instance of (ldns_buffer *). */ %typemap(in, numinputs=0, noblock=1) (ldns_buffer **) { ldns_buffer *$1_buf; $1 = &$1_buf; } /* Result generation, appends (ldns_buffer *) after the result. */ %typemap(argout, noblock=1) (ldns_buffer **) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_buf), SWIGTYPE_p_ldns_struct_buffer, SWIG_POINTER_OWN | 0)); } /* * Limit the number of arguments to 2 and deal with variable * number of arguments in the Python way. */ %varargs(2, char *arg = NULL) ldns_buffer_printf; %nodefaultctor ldns_struct_buffer; /* No default constructor. */ %nodefaultdtor ldns_struct_buffer; /* No default destructor. */ %newobject ldns_buffer_new; %newobject ldns_dname_new_frm_data; %delobject ldns_buffer_free; %rename(ldns_buffer) ldns_struct_buffer; %ignore ldns_struct_buffer::_position; %ignore ldns_struct_buffer::_limit; %ignore ldns_struct_buffer::_capacity; %ignore ldns_struct_buffer::_data; %ignore ldns_struct_buffer::_fixed; %ignore ldns_struct_buffer::_status; %ignore ldns_buffer_new_frm_data; /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ #ifdef LDNS_DEBUG %rename(__ldns_buffer_free) ldns_buffer_free; %inline %{ /*! * @brief Frees the buffer and print a message. */ void _ldns_buffer_free (ldns_buffer* b) { printf("******** LDNS_BUFFER free 0x%lX ************\n", (long unsigned int) b); ldns_buffer_free(b); } %} #else /* !LDNS_DEBUG */ %rename(_ldns_buffer_free) ldns_buffer_free; #endif /* LDNS_DEBUG */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ /* None. */ /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") "LDNS buffer." %extend ldns_struct_buffer { %pythoncode %{ def __init__(self, capacity): """ Creates a new buffer with the specified capacity. :param capacity: Number of bytes to allocate for the buffer. :type capacity: integer :throws TypeError: When `capacity` of non-integer type. :return: (:class:`ldns_buffer`) """ self.this = _ldns.ldns_buffer_new(capacity) __swig_destroy__ = _ldns._ldns_buffer_free def __str__(self): """ Returns the data in the buffer as a string. Buffer data must be char * type. :return: string """ return _ldns.ldns_buffer2str(self) def getc(self): """ Returns the next character from a buffer. Advances the position pointer with 1. When end of buffer is reached returns EOF. This is the buffer's equivalent for getc(). :return: (integer) EOF on failure otherwise return the character. """ return _ldns.ldns_bgetc(self) # # LDNS_BUFFER_METHODS_ # def at(self, at): """ Returns a pointer to the data at the indicated position. :param at: position :type at: positive integer :throws TypeError: When `at` of non-integer type. :return: (uint8_t \*) The pointer to the data. """ return _ldns.ldns_buffer_at(self, at) #parameters: const ldns_buffer *, size_t, #retvals: uint8_t * def available(self, count): """ Checks whether the buffer has count bytes available at the current position. :param count: How much is available. :type count: integer :throws TypeError: When `count` of non-integer type. :return: (bool) True or False. """ return _ldns.ldns_buffer_available(self, count) != 0 #parameters: ldns_buffer *, size_t, #retvals: int def available_at(self, at, count): """ Checks if the buffer has at least `count` more bytes available. Before reading or writing the caller needs to ensure that enough space is available! :param at: Indicated position. :type at: positive integer :param count: How much is available. :type count: positive integer :throws TypeError: When `at` or `count` of non-integer type. :return: (bool) True or False. """ return _ldns.ldns_buffer_available_at(self, at, count) != 0 #parameters: ldns_buffer *,size_t,size_t, #retvals: int def begin(self): """ Returns a pointer to the beginning of the buffer (the data at position 0). :return: (uint8_t \*) Pointer. """ return _ldns.ldns_buffer_begin(self) #parameters: const ldns_buffer *, #retvals: uint8_t * def capacity(self): """ Returns the number of bytes the buffer can hold. :return: (size_t) The number of bytes. """ return _ldns.ldns_buffer_capacity(self) #parameters: ldns_buffer *, #retvals: size_t def clear(self): """ Clears the buffer and make it ready for writing. The buffer's limit is set to the capacity and the position is set to 0. """ _ldns.ldns_buffer_clear(self) #parameters: ldns_buffer *, #retvals: def copy(self, bfrom): """ Copy contents of the other buffer to this buffer. Silently truncated if this buffer is too small. :param bfrom: Source buffer. :type bfrom: :class:`ldns_buffer` :throws TypeError: When `bfrom` of non-:class:`ldns_buffer` type. """ _ldns.ldns_buffer_copy(self, bfrom) #parameters: ldns_buffer *, ldns_buffer *, #retvals: def current(self): """ Returns a pointer to the data at the buffer's current position. :return: (uint8_t \*) A pointer. """ return _ldns.ldns_buffer_current(self) #parameters: ldns_buffer *, #retvals: uint8_t * def end(self): """ Returns a pointer to the end of the buffer (the data at the buffer's limit). :return: (uint8_t \*) Pointer. """ return _ldns.ldns_buffer_end(self) #parameters: ldns_buffer *, #retvals: uint8_t * def export(self): """ Makes the buffer fixed and returns a pointer to the data. The caller is responsible for freeing the result. :return: (void \*) Void pointer. """ return _ldns.ldns_buffer_export(self) #parameters: ldns_buffer *, #retvals: void * def flip(self): """ Makes the buffer ready for reading the data that has been written to the buffer. The buffer's limit is set to the current position and the position is set to 0. """ _ldns.ldns_buffer_flip(self) #parameters: ldns_buffer *, def invariant(self): """ Performs no action. In debugging mode this method performs a buffer settings check. It asserts if something is wrong. """ _ldns.ldns_buffer_invariant(self) #parameters: ldns_buffer *, def limit(self): """ Returns the maximum size of the buffer. :return: (size_t) The size. """ return _ldns.ldns_buffer_limit(self) #parameters: ldns_buffer *, #retvals: size_t def position(self): """ Returns the current position in the buffer (as a number of bytes). :return: (size_t) The current position. """ return _ldns.ldns_buffer_position(self) #parameters: ldns_buffer *, #retvals: size_t def printf(self, string, *args): """ Prints to the buffer, increasing the capacity if required using buffer_reserve(). The buffer's position is set to the terminating '\0'. Returns the number of characters written (not including the terminating '\0') or -1 on failure. :param string: A string to be written. :type string: string :throws: TypeError when `string` not a string. :return: (int) Number of written characters or -1 on failure. """ data = string % args return _ldns.ldns_buffer_printf(self, data) #parameters: ldns_buffer *, const char *, ... #retvals: int def read(self, data, count): """ Copies count bytes of data at the current position to the given `data`-array :param data: Target buffer to copy to. :type data: void \* :param count: The length of the data to copy. :type count: size_t """ _ldns.ldns_buffer_read(self,data,count) #parameters: ldns_buffer *, void *, size_t, #retvals: def read_at(self, at, data, count): """ Copies count bytes of data at the given position to the given `data`-array. :param at: The position in the buffer to start reading. :type at: size_t :param data: Target buffer to copy to. :type data: void \* :param count: The length of the data to copy. :type count: size_t """ _ldns.ldns_buffer_read_at(self,at,data,count) #parameters: ldns_buffer *, size_t, void *, size_t, #retvals: def read_u16(self): """ Returns the 2-byte integer value at the current position from the buffer. :return: (uint16_t) Word. """ return _ldns.ldns_buffer_read_u16(self) #parameters: ldns_buffer *, #retvals: uint16_t def read_u16_at(self, at): """ Returns the 2-byte integer value at the given position from the buffer. :param at: Position in the buffer. :type at: positive integer :throws TypeError: When `at` of non-integer type. :return: (uint16_t) Word. """ return _ldns.ldns_buffer_read_u16_at(self, at) #parameters: ldns_buffer *, size_t, #retvals: uint16_t def read_u32(self): """ Returns the 4-byte integer value at the current position from the buffer. :return: (uint32_t) Double-word. """ return _ldns.ldns_buffer_read_u32(self) #parameters: ldns_buffer *, #retvals: uint32_t def read_u32_at(self, at): """ Returns the 4-byte integer value at the given position from the buffer. :param at: Position in the buffer. :type at: positive integer :throws TypeError: When `at` of non-integer type. :return: (uint32_t) Double-word. """ return _ldns.ldns_buffer_read_u32_at(self, at) #parameters: ldns_buffer *, size_t, #retvals: uint32_t def read_u8(self): """ Returns the byte value at the current position from the buffer. :return: (uint8_t) A byte (not a character). """ return _ldns.ldns_buffer_read_u8(self) #parameters: ldns_buffer *, #retvals: uint8_t def read_u8_at(self, at): """ Returns the byte value at the given position from the buffer. :param at: The position in the buffer. :type at: positive integer :throws TypeError: When `at` of non-integer type. :return: (uint8_t) Byte value. """ return _ldns.ldns_buffer_read_u8_at(self, at) #parameters: ldns_buffer *, size_t, #retvals: uint8_t def remaining(self): """ Returns the number of bytes remaining between the buffer's position and limit. :return: (size_t) The number of bytes. """ return _ldns.ldns_buffer_remaining(self) #parameters: ldns_buffer *, #retvals: size_t def remaining_at(self, at): """ Returns the number of bytes remaining between the indicated position and the limit. :param at: Indicated position. :type at: positive integer :throws TypeError: When `at` of non-integer type. :return: (size_t) number of bytes """ return _ldns.ldns_buffer_remaining_at(self, at) #parameters: ldns_buffer *,size_t, #retvals: size_t def reserve(self, amount): """ Ensures that the buffer can contain at least `amount` more bytes. The buffer's capacity is increased if necessary using buffer_set_capacity(). The buffer's limit is always set to the (possibly increased) capacity. :param amount: Amount to use. :type amount: positive integer :throws TypeError: When `amount` of non-integer type. :return: (bool) Whether this failed or succeeded. """ return _ldns.ldns_buffer_reserve(self, amount) #parameters: ldns_buffer *, size_t, #retvals: bool def rewind(self): """ Make the buffer ready for re-reading the data. The buffer's position is reset to 0. """ _ldns.ldns_buffer_rewind(self) #parameters: ldns_buffer *, #retvals: def set_capacity(self, capacity): """ Changes the buffer's capacity. The data is reallocated so any pointers to the data may become invalid. The buffer's limit is set to the buffer's new capacity. :param capacity: The capacity to use. :type capacity: positive integer :throws TypeError: When `capacity` of non-integer type. :return: (bool) whether this failed or succeeded """ return _ldns.ldns_buffer_set_capacity(self, capacity) #parameters: ldns_buffer *, size_t, #retvals: bool def set_limit(self, limit): """ Changes the buffer's limit. If the buffer's position is greater than the new limit then the position is set to the limit. :param limit: The new limit. :type limit: positive integer :throws TypeError: When `limit` of non-integer type. """ _ldns.ldns_buffer_set_limit(self, limit) #parameters: ldns_buffer *, size_t, #retvals: def set_position(self,mark): """ Sets the buffer's position to `mark`. The position must be less than or equal to the buffer's limit. :param mark: The mark to use. :type mark: positive integer :throws TypeError: When `mark` of non-integer type. """ _ldns.ldns_buffer_set_position(self,mark) #parameters: ldns_buffer *,size_t, #retvals: def skip(self, count): """ Changes the buffer's position by `count` bytes. The position must not be moved behind the buffer's limit or before the beginning of the buffer. :param count: The count to use. :type count: integer :throws TypeError: When `count` of non-integer type. """ _ldns.ldns_buffer_skip(self, count) #parameters: ldns_buffer *, ssize_t, #retvals: def status(self): """ Returns the status of the buffer. :return: (ldns_status) The status. """ return _ldns.ldns_buffer_status(self) #parameters: ldns_buffer *, #retvals: ldns_status def status_ok(self): """ Returns True if the status of the buffer is LDNS_STATUS_OK, False otherwise. :return: (bool) True or False. """ return _ldns.ldns_buffer_status_ok(self) #parameters: ldns_buffer *, #retvals: bool def write(self, data, count): """ Writes count bytes of data to the current position of the buffer. :param data: The data to write. :type data: void \* :param count: The length of the data to write. :type count: size_t """ _ldns.ldns_buffer_write(self, data, count) #parameters: ldns_buffer *, const void *, size_t, #retvals: def write_at(self, at, data, count): """ Writes the given data to the buffer at the specified position by `at`. :param at: The position (in number of bytes) to write the data at. :param data: Pointer to the data to write to the buffer. :param count: The number of bytes of data to write. """ _ldns.ldns_buffer_write_at(self, at, data, count) #parameters: ldns_buffer *, size_t, const void *, size_t, #retvals: def write_string(self, string): """ Copies the given (null-delimited) string to the current position into the buffer. :param string: The string to write. :type string: string :throws TypeError: When `string` not a string. """ _ldns.ldns_buffer_write_string(self,string) #parameters: ldns_buffer *,const char *, #retvals: def write_string_at(self, at, string): """ Copies the given (null-delimited) string to the specified position `at` into the buffer. :param at: The position in the buffer. :type at: positive integer :param string: The string to write. :type string: string :throws TypeError: When types mismatch. """ _ldns.ldns_buffer_write_string_at(self, at, string) #parameters: ldns_buffer *, size_t, const char *, #retvals: def write_u16(self, data): """Writes the given 2 byte integer at the current position in the buffer. :param data: The word to write. :type data: uint16_t :throws TypeError: When `data` of non-integer type. """ _ldns.ldns_buffer_write_u16(self, data) #parameters: ldns_buffer *, uint16_t, #retvals: def write_u16_at(self, at, data): """ Writes the given 2 byte integer at the given position in the buffer. :param at: The position in the buffer. :type at: positive integer :param data: The word to write. :type data: uint16_t :throws TypeError: When `at` or `data` of non-integer type. """ _ldns.ldns_buffer_write_u16_at(self,at,data) #parameters: ldns_buffer *,size_t,uint16_t, #retvals: def write_u32(self, data): """ Writes the given 4 byte integer at the current position in the buffer. :param data: The double-word to write. :type data: uint32_t :throws TypeError: When `data` of non-integer type. """ _ldns.ldns_buffer_write_u32(self, data) #parameters: ldns_buffer *, uint32_t, #retvals: def write_u32_at(self, at, data): """ Writes the given 4 byte integer at the given position in the buffer. :param at: The position in the buffer. :type at: positive integer :param data: The double-word to write. :type data: uint32_t :throws TypeError: When `at` or `data` of non-integer type. """ _ldns.ldns_buffer_write_u32_at(self, at, data) #parameters: ldns_buffer *,size_t,uint32_t, #retvals: def write_u8(self, data): """ Writes the given byte of data at the current position in the buffer. :param data: The byte to write. :type data: uint8_t :throws TypeError: When `data` of non-integer type. """ _ldns.ldns_buffer_write_u8(self, data) #parameters: ldns_buffer *, uint8_t, #retvals: def write_u8_at(self,at,data): """ Writes the given byte of data at the given position in the buffer. :param at: The position in the buffer. :type at: positive integer :param data: The byte to write. :type data: uint8_t :throws TypeError: When `at` or `data` of non-integer type. """ _ldns.ldns_buffer_write_u8_at(self,at,data) #parameters: ldns_buffer *,size_t,uint8_t, #retvals: # # _LDNS_BUFFER_METHODS # %} } ldns-1.9.2/contrib/python/ldns_rr.i0000664000175000017500000025264515212267520016647 0ustar willemwillem/****************************************************************************** * ldns_rr.i: LDNS resource records (RR), RR list * * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz) * Karel Slany (slany AT fit.vutbr.cz) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the organization nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ /* Creates a temporary instance of (ldns_rr *). */ %typemap(in, numinputs=0, noblock=1) (ldns_rr **) { ldns_rr *$1_rr; $1 = &$1_rr; } /* Result generation, appends (ldns_rr *) after the result. */ %typemap(argout, noblock=1) (ldns_rr **) { $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 )); } %nodefaultctor ldns_struct_rr; /* No default constructor. */ %nodefaultdtor ldns_struct_rr; /* No default destructor. */ %ignore ldns_struct_rr::_rdata_fields; %newobject ldns_rr_clone; %newobject ldns_rr_new; %newobject ldns_rr_new_frm_type; %newobject ldns_rr_pop_rdf; %delobject ldns_rr_free; %rename(ldns_rr) ldns_struct_rr; %newobject ldns_rr2str; %newobject ldns_rr_type2str; %newobject ldns_rr_class2str; %newobject ldns_read_anchor_file; /* Clone rdf data on pull. */ /* Clone will fail with NULL argument. */ %newobject _ldns_rr_rdf; %rename(__ldns_rr_rdf) ldns_rr_rdf; %inline %{ ldns_rdf * _ldns_rr_rdf(ldns_rr *rr, size_t i) { ldns_rdf *rdf; rdf = ldns_rr_rdf(rr, i); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_algorithm; %rename(__ldns_rr_rrsig_algorithm) ldns_rr_rrsig_algorithm; %inline %{ ldns_rdf * _ldns_rr_rrsig_algorithm(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_algorithm(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_dnskey_algorithm; %rename(__ldns_rr_dnskey_algorithm) ldns_rr_dnskey_algorithm; %inline %{ ldns_rdf * _ldns_rr_dnskey_algorithm(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_dnskey_algorithm(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_dnskey_flags; %rename(__ldns_rr_dnskey_flags) ldns_rr_dnskey_flags; %inline %{ ldns_rdf * _ldns_rr_dnskey_flags(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_dnskey_flags(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_dnskey_key; %rename(__ldns_rr_dnskey_key) ldns_rr_dnskey_key; %inline %{ ldns_rdf * _ldns_rr_dnskey_key(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_dnskey_key(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_dnskey_protocol; %rename(__ldns_rr_dnskey_protocol) ldns_rr_dnskey_protocol; %inline %{ ldns_rdf * _ldns_rr_dnskey_protocol(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_dnskey_protocol(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_owner; %rename(__ldns_rr_owner) ldns_rr_owner; %inline %{ ldns_rdf * _ldns_rr_owner(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_owner(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_a_address; %rename(__ldns_rr_a_address) ldns_rr_a_address; %inline %{ ldns_rdf * _ldns_rr_a_address(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_a_address(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_mx_exchange; %rename(__ldns_rr_mx_exchange) ldns_rr_mx_exchange; %inline %{ ldns_rdf * _ldns_rr_mx_exchange(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_mx_exchange(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_mx_preference; %rename(__ldns_rr_mx_preference) ldns_rr_mx_preference; %inline %{ ldns_rdf * _ldns_rr_mx_preference(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_mx_preference(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_ns_nsdname; %rename(__ldns_rr_ns_nsdname) ldns_rr_ns_nsdname; %inline %{ ldns_rdf * _ldns_rr_ns_nsdname(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_ns_nsdname(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_expiration; %rename(__ldns_rr_rrsig_expiration) ldns_rr_rrsig_expiration; %inline %{ ldns_rdf * _ldns_rr_rrsig_expiration(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_expiration(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_inception; %rename(__ldns_rr_rrsig_inception) ldns_rr_rrsig_inception; %inline %{ ldns_rdf * _ldns_rr_rrsig_inception(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_inception(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_keytag; %rename(__ldns_rr_rrsig_keytag) ldns_rr_rrsig_keytag; %inline %{ ldns_rdf * _ldns_rr_rrsig_keytag(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_keytag(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_labels; %rename(__ldns_rr_rrsig_labels) ldns_rr_rrsig_labels; %inline %{ ldns_rdf * _ldns_rr_rrsig_labels(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_labels(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_origttl; %rename(__ldns_rr_rrsig_origttl) ldns_rr_rrsig_origttl; %inline %{ ldns_rdf * _ldns_rr_rrsig_origttl(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_origttl(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_sig; %rename(__ldns_rr_rrsig_sig) ldns_rr_rrsig_sig; %inline %{ ldns_rdf * _ldns_rr_rrsig_sig(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_sig(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_signame; %rename(__ldns_rr_rrsig_signame) ldns_rr_rrsig_signame; %inline %{ ldns_rdf * _ldns_rr_rrsig_signame(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_signame(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} %newobject _ldns_rr_rrsig_typecovered; %rename(__ldns_rr_rrsig_typecovered) ldns_rr_rrsig_typecovered; %inline %{ ldns_rdf * _ldns_rr_rrsig_typecovered(ldns_rr *rr) { ldns_rdf *rdf; rdf = ldns_rr_rrsig_typecovered(rr); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} /* End of pull cloning. */ /* Clone rdf data on push. */ %rename(__ldns_rr_a_set_address) ldns_rr_a_set_address; %inline %{ bool _ldns_rr_a_set_address(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_a_set_address(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_dnskey_set_algorithm) ldns_rr_dnskey_set_algorithm; %inline %{ bool _ldns_rr_dnskey_set_algorithm(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_dnskey_set_algorithm(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_dnskey_set_flags) ldns_rr_dnskey_set_flags; %inline %{ bool _ldns_rr_dnskey_set_flags(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_dnskey_set_flags(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_dnskey_set_key) ldns_rr_dnskey_set_key; %inline %{ bool _ldns_rr_dnskey_set_key(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_dnskey_set_key(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_dnskey_set_protocol) ldns_rr_dnskey_set_protocol; %inline %{ bool _ldns_rr_dnskey_set_protocol(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_dnskey_set_protocol(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_push_rdf) ldns_rr_push_rdf; %inline %{ bool _ldns_rr_push_rdf(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_push_rdf(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_algorithm) ldns_rr_rrsig_set_algorithm; %inline %{ bool _ldns_rr_rrsig_set_algorithm(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_algorithm(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_expiration) ldns_rr_rrsig_set_expiration; %inline %{ bool _ldns_rr_rrsig_set_expiration(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_expiration(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_inception) ldns_rr_rrsig_set_inception; %inline %{ bool _ldns_rr_rrsig_set_inception(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_inception(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_keytag) ldns_rr_rrsig_set_keytag; %inline %{ bool _ldns_rr_rrsig_set_keytag(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_keytag(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_labels) ldns_rr_rrsig_set_labels; %inline %{ bool _ldns_rr_rrsig_set_labels(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_labels(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_origttl) ldns_rr_rrsig_set_origttl; %inline %{ bool _ldns_rr_rrsig_set_origttl(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_origttl(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_sig) ldns_rr_rrsig_set_sig; %inline %{ bool _ldns_rr_rrsig_set_sig(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_sig(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_signame) ldns_rr_rrsig_set_signame; %inline %{ bool _ldns_rr_rrsig_set_signame(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_signame(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_rrsig_set_typecovered) ldns_rr_rrsig_set_typecovered; %inline %{ bool _ldns_rr_rrsig_set_typecovered(ldns_rr *rr, ldns_rdf *rdf) { return ldns_rr_rrsig_set_typecovered(rr, ldns_rdf_clone(rdf)); } %} %rename(__ldns_rr_set_owner) ldns_rr_set_owner; %inline %{ void _ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *rdf) { ldns_rr_set_owner(rr, ldns_rdf_clone(rdf)); } %} %newobject _ldns_rr_set_rdf; %rename(__ldns_rr_set_rdf) ldns_rr_set_rdf; %inline %{ ldns_rdf * _ldns_rr_set_rdf(ldns_rr *rr, ldns_rdf *rdf, size_t pos) { /* May leak memory on unsuccessful calls. */ ldns_rdf *new, *ret; new = ldns_rdf_clone(rdf); if ((ret = ldns_rr_set_rdf(rr, new, pos)) == NULL) { ldns_rdf_deep_free(new); } return ret; } %} /* End of push cloning. */ %rename(_ldns_rr_new_frm_str) ldns_rr_new_frm_str; %rename(_ldns_rr_new_frm_fp_l) ldns_rr_new_frm_fp_l; %rename(_ldns_rr_new_frm_fp) ldns_rr_new_frm_fp; /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ #ifdef LDNS_DEBUG %rename(__ldns_rr_free) ldns_rr_free; %inline %{ void _ldns_rr_free (ldns_rr *r) { printf("******** LDNS_RR free 0x%lX ************\n", (long unsigned int)r); ldns_rr_free(r); } %} #else /* !LDNS_DEBUG */ %rename(_ldns_rr_free) ldns_rr_free; #endif /* LDNS_DEBUG */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ /* None. */ /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") ldns_struct_rr "Resource Record (RR). The RR is the basic DNS element that contains actual data. This class allows to create RR and manipulate with the content. Use :meth:`ldns_rr_new`, :meth:`ldns_rr_new_frm_type`, :meth:`new_frm_fp`, :meth:`new_frm_fp_l`, :meth:`new_frm_str` or :meth:`new_question_frm_str` to create :class:`ldns_rr` instances. " %extend ldns_struct_rr { %pythoncode %{ def __init__(self): raise Exception("This class can't be created directly. " + "Please use: ldns_rr_new(), ldns_rr_new_frm_type(), " + "new_frm_fp(), new_frm_fp_l(), new_frm_str() or " + "new_question_frm_str()") __swig_destroy__ = _ldns._ldns_rr_free # # LDNS_RR_CONSTRUCTORS_ # @staticmethod def new_frm_str(string, default_ttl=0, origin=None, prev=None, raiseException=True): """ Creates an rr object from a string. The string should be a fully filled-in rr, like "owner_name [space] TTL [space] CLASS [space] TYPE [space] RDATA." :param string: The string to convert. :type string: str :param default_ttl: Default ttl value for the rr. If 0 DEF_TTL will be used. :type default_ttl: int :param origin: When the owner is relative add this. :type origin: :class:`ldns_dname` :param prev: The previous owner name. :type prev: :class:`ldns_rdf` :param raiseException: If True, an exception occurs in case a rr instance can't be created. :throws Exception: If `raiseException` is set and fails. :throws TypeError: When parameters of incorrect types. :return: (:class:`ldns_rr`) RR instance or None. .. note:: The type checking of `origin` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. **Usage** >>> import ldns >>> rr = ldns.ldns_rr.new_frm_str("www.nic.cz. IN A 192.168.1.1", 300) >>> print rr www.nic.cz. 300 IN A 192.168.1.1 >>> rr = ldns.ldns_rr.new_frm_str("test.nic.cz. 600 IN A 192.168.1.2") >>> print rr test.nic.cz. 600 IN A 192.168.1.2 """ if (not isinstance(origin, ldns_dname)) and \ isinstance(origin, ldns_rdf) and \ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_rr.new_frm_str() method will" + " drop the possibility to accept ldns_rdf as origin." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) status, rr, prev = _ldns.ldns_rr_new_frm_str_(string, default_ttl, origin, prev) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create RR, error: %d" % status) return None return rr @staticmethod def new_question_frm_str(string, default_ttl=0, origin=None, prev=None, raiseException=True): """ Creates an rr object from a string. The string is like :meth:`new_frm_str` but without rdata. :param string: The string to convert. :type string: str :param origin: When the owner is relative add this. :type origin: :class:`ldns_dname` :param prev: The previous owner name. :type prev: :class:`ldns_rdf` :param raiseException: If True, an exception occurs in case a rr instance can't be created. :throws Exception: If `raiseException` is set and fails. :throws TypeError: When parameters of incorrect types. :return: (:class:`ldns_rr`) RR instance or None. If the object can't be created and `raiseException` is True, an exception occurs. .. note:: The type checking of `origin` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(origin, ldns_dname)) and \ isinstance(origin, ldns_rdf) and \ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_rr.new_question_frm_str() method will" + " drop the possibility to accept ldns_rdf as origin." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) status, rr, prev = _ldns.ldns_rr_new_question_frm_str_(string, origin, prev) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create RR, error: %d" % status) return None return rr @staticmethod def new_frm_str_prev(string, default_ttl=0, origin=None, prev=None, raiseException=True): """ Creates an rr object from a string. The string should be a fully filled-in rr, like "owner_name [space] TTL [space] CLASS [space] TYPE [space] RDATA". :param string: The string to convert. :type string: str :param default_ttl: Default ttl value for the rr. If 0 DEF_TTL will be used. :type default_ttl: int :param origin: When the owner is relative add this. :type origin: :class:`ldns_dname` :param prev: The previous owner name. :type prev: :class:`ldns_rdf` :param raiseException: If True, an exception occurs in case when a rr instance can't be created. :throws Exception: If `raiseException` is set and fails. :throws TypeError: When parameters of incorrect types. :return: None when fails, otherwise a tuple containing: * rr - (:class:`ldns_rr`) RR instance or None. If the object can't be created and `raiseException` is True, an exception occurs. * prev - (:class:`ldns_rdf`) Owner name found in this string or None. .. note:: The type checking of `origin` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(origin, ldns_dname)) and \ isinstance(origin, ldns_rdf) and \ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_rr.new_frm_str_prev() method will" + " drop the possibility to accept ldns_rdf as origin." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) status, rr, prev = _ldns.ldns_rr_new_frm_str_(string, default_ttl, origin, prev) if status != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create RR, error: %d" % status) return None return rr, prev @staticmethod def new_frm_fp(file, default_ttl=0, origin=None, prev=None, raiseException=True): """ Creates a new rr from a file containing a string. :param file: Opened file. :param default_ttl: If 0 DEF_TTL will be used. :type default_ttl: int :param origin: When the owner is relative add this. :type origin: :class:`ldns_dname` :param prev: When the owner is white spaces use this. :type prev: :class:`ldns_rdf` :param raiseException: If True, an exception occurs in case a resolver object can't be created. :throws Exception: If `raiseException` is set and the input cannot be read. :throws TypeError: When parameters of incorrect types. :return: None when fails, otherwise a tuple containing: * rr - (:class:`ldns_rr`) RR object or None. If the object can't be created and `raiseException` is True, an exception occurs. * ttl - (int) None or TTL if the file contains a TTL directive. * origin - (:class:`ldns_rdf`) None or dname rdf if the file contains a ORIGIN directive. * prev - (:class:`ldns_rdf`) None or updated value of prev parameter. .. note:: The type checking of `origin` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(origin, ldns_dname)) and \ isinstance(origin, ldns_rdf) and \ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_rr.new_frm_fp() method will" + " drop the possibility to accept ldns_rdf as origin." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) res = _ldns.ldns_rr_new_frm_fp_(file, default_ttl, origin, prev) if res[0] != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create RR, error: %d" % res[0]) return None return res[1:] @staticmethod def new_frm_fp_l(file, default_ttl=0, origin=None, prev=None, raiseException=True): """ Creates a new rr from a file containing a string. :param file: Opened file. :param default_ttl: If 0 DEF_TTL will be used. :type default_ttl: int :param origin: When the owner is relative add this. :type origin: :class:`ldns_dname` :param prev: When the owner is white spaces use this. :type prev: :class:`ldns_rdf` :param raiseException: If True, an exception occurs in case a resolver object can't be created. :throws Exception: If `raiseException` is set and the input cannot be read. :throws TypeError: When parameters of incorrect types. :return: None when fails, otherwise a tuple containing: * rr - (:class:`ldns_rr`) RR object or None. If the object can't be created and `raiseException` is True, an exception occurs. * line - (int) line number (for debugging). * ttl - (int) None or TTL if the file contains a TTL directive . * origin - (:class:`ldns_rdf`) None or dname rdf if the file contains a ORIGIN directive. * prev - (:class:`ldns_rdf`) None or updated value of prev parameter. .. note:: The type checking of `origin` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(origin, ldns_dname)) and \ isinstance(origin, ldns_rdf) and \ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_rr.new_frm_fp_l() method will" + " drop the possibility to accept ldns_rdf as origin." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) res = _ldns.ldns_rr_new_frm_fp_l_(file, default_ttl, origin, prev) if res[0] != LDNS_STATUS_OK: if (raiseException): raise Exception("Can't create RR, error: %d" % res[0]) return None return res[1:] # # _LDNS_RR_CONSTRUCTORS # def __str__(self): """ Converts the data in the resource record to presentation format. :return: (str) """ return _ldns.ldns_rr2str(self) def __cmp__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (int) 0 if equal, -1 if `self` comes before `other`, 1 if `other` RR comes before `self`. """ return _ldns.ldns_rr_compare(self, other) def __lt__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (bool) True when `self` is less than 'other'. """ return _ldns.ldns_rr_compare(self, other) == -1 def __le__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (bool) True when `self` is less than or equal to 'other'. """ return _ldns.ldns_rr_compare(self, other) != 1 def __eq__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (bool) True when `self` is equal to 'other'. """ return _ldns.ldns_rr_compare(self, other) == 0 def __ne__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (bool) True when `self` is not equal to 'other'. """ return _ldns.ldns_rr_compare(self, other) != 0 def __gt__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (bool) True when `self` is greater than 'other'. """ return _ldns.ldns_rr_compare(self, other) == 1 def __ge__(self, other): """ Compares two rrs. The TTL is not looked at. :param other: The second RR one. :type other: :class:`ldns_rr` :throws TypeError: When `other` of non-:class:`ldns_rr` type. :return: (bool) True when `self` is greater than or equal to 'other'. """ return _ldns.ldns_rr_compare(self, other) != -1 @staticmethod def class_by_name(string): """ Retrieves a class identifier value by looking up its name. :param string: Class name. :type string: str :throws TypeError: when `string` of inappropriate type. :return: (int) Class identifier value, or 0 if not valid class name given. """ return _ldns.ldns_get_rr_class_by_name(string) def rdfs(self): """ Returns a generator object of rdata records. :return: Generator of :class:`ldns_rdf`. """ for i in range(0, self.rd_count()): yield self.rdf(i) def print_to_file(self, output): """ Prints the data in the resource record to the given file stream (in presentation format). :param output: Opened file stream. :throws TypeError: When `output` not a file. """ _ldns.ldns_rr_print(output, self) #parameters: FILE *, const ldns_rr *, def get_type_str(self): """ Converts an RR type value to its string representation, and returns that string. :return: (str) containing type identification. """ return _ldns.ldns_rr_type2str(self.get_type()) #parameters: const ldns_rr_type, def get_class_str(self): """ Converts an RR class value to its string representation, and returns that string. :return: (str) containing class identification. """ return _ldns.ldns_rr_class2str(self.get_class()) #parameters: const ldns_rr_class, @staticmethod def dnskey_key_size_raw(keydata, len, alg): """ Get the length of the keydata in bits. :param keydata: Key raw data. :type keydata: unsigned char \* :param len: Number of bytes of `keydata`. :type len: size_t :param alg: Algorithm identifier. :type alg: ldns_algorithm :return: (size_t) The length of key data in bits. """ return _ldns.ldns_rr_dnskey_key_size_raw(keydata, len, alg) #parameters: const unsigned char *,const size_t,const ldns_algorithm, #retvals: size_t def write_to_buffer(self,buffer,section): """ Copies the rr data to the buffer in wire format. :param buffer: Buffer to append the result to. :type buffer: :class:`ldns_buffer` :param section: The section in the packet this rr is supposed to be in (to determine whether to add rdata or not). :type section: int :throws TypeError: when arguments of mismatching types passed. :return: (ldns_status) ldns_status """ return _ldns.ldns_rr2buffer_wire(buffer, self, section) #parameters: ldns_buffer *,const ldns_rr *,int, #retvals: ldns_status def write_to_buffer_canonical(self,buffer,section): """ Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dname in rdata fields of RR's mentioned in that RFC will be converted to lower-case). :param buffer: Buffer to append the result to. :type buffer: :class:`ldns_buffer` :param section: The section in the packet this rr is supposed to be in (to determine whether to add rdata or not). :type section: int :throws TypeError: when arguments of mismatching types passed. :return: (ldns_status) ldns_status """ return _ldns.ldns_rr2buffer_wire_canonical(buffer,self,section) #parameters: ldns_buffer *,const ldns_rr *,int, #retvals: ldns_status def write_data_to_buffer(self, buffer): """ Converts an rr's rdata to wire format, while excluding the owner name and all the stuff before the rdata. This is needed in DNSSEC key-tag calculation, the ds calculation from the key and maybe elsewhere. :param buffer: Buffer to append the result to. :type buffer: :class:`ldns_buffer` :throws TypeError: when `buffer` of non-:class:`ldns_buffer` type. :return: (ldns_status) ldns_status """ return _ldns.ldns_rr_rdata2buffer_wire(buffer,self) #parameters: ldns_buffer *, const ldns_rr *, #retvals: ldns_status def write_rrsig_to_buffer(self, buffer): """ Converts a rrsig to wire format BUT EXCLUDE the rrsig rdata. This is needed in DNSSEC verification. :param buffer: Buffer to append the result to. :type buffer: :class:`ldns_buffer` :throws TypeError: when `buffer` of non-:class:`ldns_buffer` type. :return: (ldns_status) ldns_status """ return _ldns.ldns_rrsig2buffer_wire(buffer,self) #parameters: ldns_buffer *,const ldns_rr *, #retvals: ldns_status # # LDNS_RR_METHODS_ # def a_address(self): """ Returns the address rdf of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA rr. :return: (:class:`ldns_rdf`) with the address or None on failure. """ return _ldns._ldns_rr_a_address(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def a_set_address(self, f): """ Sets the address of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA rr. :param f: The address to be set. :type f: :class:`ldns_rdf` :throws TypeError: When `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_a_set_address(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def clone(self): """ Clones a rr and all its data. :return: (:class:`ldns_rr`) The new rr or None on failure. """ return _ldns.ldns_rr_clone(self) #parameters: const ldns_rr *, #retvals: ldns_rr * def compare_ds(self, rr2): """ Returns True if the given rr's are equal. Also returns True if one record is a DS that represents the same DNSKEY record as the other record. :param rr2: The second rr. :type rr2: :class:`ldns_rr` :throws TypeError: When `rr2` of non-:class:`ldns_rr` type. :return: (bool) True if equal otherwise False. """ return _ldns.ldns_rr_compare_ds(self, rr2) #parameters: const ldns_rr *, const ldns_rr *, #retvals: bool def compare_no_rdata(self, rr2): """ Compares two rrs, up to the rdata. :param rr2: Rhe second rr. :type rr2: :class:`ldns_rr` :throws TypeError: When `rr2` of non-:class:`ldns_rr` type. :return: (int) 0 if equal, negative integer if `self` comes before `rr2`, positive integer if `rr2` comes before `self`. """ return _ldns.ldns_rr_compare_no_rdata(self, rr2) #parameters: const ldns_rr *, const ldns_rr *, #retvals: int def dnskey_algorithm(self): """ Returns the algorithm of a LDNS_RR_TYPE_DNSKEY rr. :return: (:class:`ldns_rdf`) with the algorithm or None on failure. """ return _ldns._ldns_rr_dnskey_algorithm(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def dnskey_flags(self): """ Returns the flags of a LDNS_RR_TYPE_DNSKEY rr. :return: (:class:`ldns_rdf`) with the flags or None on failure. """ return _ldns._ldns_rr_dnskey_flags(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def dnskey_key(self): """ Returns the key data of a LDNS_RR_TYPE_DNSKEY rr. :return: (:class:`ldns_rdf`) with the key data or None on failure. """ return _ldns._ldns_rr_dnskey_key(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def dnskey_key_size(self): """ Get the length of the keydata in bits. :return: (size_t) the keysize in bits. """ return _ldns.ldns_rr_dnskey_key_size(self) #parameters: const ldns_rr *, #retvals: size_t def dnskey_protocol(self): """ Returns the protocol of a LDNS_RR_TYPE_DNSKEY rr. :return: (:class:`ldns_rdf`) with the protocol or None on failure. """ return _ldns._ldns_rr_dnskey_protocol(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def dnskey_set_algorithm(self, f): """ Sets the algorithm of a LDNS_RR_TYPE_DNSKEY rr :param f: The algorithm to set. :type f: :class:`ldns_rdf` :throws TypeError: When `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_dnskey_set_algorithm(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def dnskey_set_flags(self, f): """ Sets the flags of a LDNS_RR_TYPE_DNSKEY rr. :param f: The flags to be set. :type f: :class:`ldns_rdf` :throws TypeError: When `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_dnskey_set_flags(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def dnskey_set_key(self, f): """ Sets the key data of a LDNS_RR_TYPE_DNSKEY rr. :param f: The key data to set. :type f: :class:`ldns_rdf` :throws TypeError: When `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_dnskey_set_key(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def dnskey_set_protocol(self,f): """ Sets the protocol of a LDNS_RR_TYPE_DNSKEY rr. :param f: The protocol to set. :type f: :class:`ldns_rdf` :throws TypeError: When `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_dnskey_set_protocol(self,f) #parameters: ldns_rr *,ldns_rdf *, #retvals: bool def get_class(self): """ Returns the class of the rr. :return: (int) The class identifier of the rr. """ return _ldns.ldns_rr_get_class(self) #parameters: const ldns_rr *, #retvals: ldns_rr_class def get_type(self): """ Returns the type of the rr. :return: (int) The type identifier of the rr. """ return _ldns.ldns_rr_get_type(self) #parameters: const ldns_rr *, #retvals: ldns_rr_type def is_question(self): """ Returns the question flag of a rr structure. :return: (bool) True if question flag is set. """ return _ldns.ldns_rr_is_question(self) def label_count(self): """ Counts the number of labels of the owner name. :return: (int) The number of labels. """ return _ldns.ldns_rr_label_count(self) #parameters: ldns_rr *, #retvals: uint8_t def mx_exchange(self): """ Returns the mx host of a LDNS_RR_TYPE_MX rr. :return: (:class:`ldns_rdf`) with the name of the MX host or None on failure. """ return _ldns._ldns_rr_mx_exchange(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def mx_preference(self): """ Returns the mx preference of a LDNS_RR_TYPE_MX rr. :return: (:class:`ldns_rdf`) with the preference or None on failure. """ return _ldns._ldns_rr_mx_preference(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def ns_nsdname(self): """ Returns the name of a LDNS_RR_TYPE_NS rr. :return: (:class:`ldns_rdf`) A dname rdf with the name or None on failure. """ return _ldns._ldns_rr_ns_nsdname(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def owner(self): """ Returns the owner name of an rr structure. :return: (:class:`ldns_dname`) Owner name or None on failure. """ rdf = _ldns._ldns_rr_owner(self) if rdf: rdf = ldns_dname(rdf, clone=False) return rdf #parameters: const ldns_rr *, #retvals: ldns_rdf * def pop_rdf(self): """ Removes a rd_field member, it will be popped from the last position. :return: (:class:`ldns_rdf`) rdf which was popped, None if nothing. """ return _ldns.ldns_rr_pop_rdf(self) #parameters: ldns_rr *, #retvals: ldns_rdf * def push_rdf(self,f): """ Sets rd_field member, it will be placed in the next available spot. :param f: The rdf to be appended. :type f: :class:`ldns_rdf` :throws TypeError: When `f` of non-:class:`ldns_rdf` type. :return: (bool) Returns True if success, False otherwise. """ return _ldns._ldns_rr_push_rdf(self, f) #parameters: ldns_rr *, const ldns_rdf *, #retvals: bool def rd_count(self): """ Returns the rd_count of an rr structure. :return: (size_t) the rd count of the rr. """ return _ldns.ldns_rr_rd_count(self) #parameters: const ldns_rr *, #retvals: size_t def rdf(self, nr): """ Returns the rdata field with the given index. :param nr: The index of the rdf to return. :type nr: positive int :throws TypeError: When `nr` not a positive integer. :return: (:class:`ldns_rdf`) The given rdf or None if fails. """ return _ldns._ldns_rr_rdf(self, nr) #parameters: const ldns_rr *, size_t, #retvals: ldns_rdf * def rrsig_algorithm(self): """ Returns the algorithm identifier of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the algorithm or None on failure. """ return _ldns._ldns_rr_rrsig_algorithm(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_expiration(self): """ Returns the expiration time of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the expiration time or None on failure. """ return _ldns._ldns_rr_rrsig_expiration(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_inception(self): """ Returns the inception time of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the inception time or None on failure. """ return _ldns._ldns_rr_rrsig_inception(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_keytag(self): """ Returns the keytag of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the keytag or None on failure. """ return _ldns._ldns_rr_rrsig_keytag(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_labels(self): """ Returns the number of labels of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the number of labels or None on failure. """ return _ldns._ldns_rr_rrsig_labels(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_origttl(self): """ Returns the original TTL of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the original TTL or None on failure. """ return _ldns._ldns_rr_rrsig_origttl(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_set_algorithm(self, f): """ Sets the algorithm of a LDNS_RR_TYPE_RRSIG rr. :param f: The algorithm to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_algorithm(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_expiration(self, f): """ Sets the expiration date of a LDNS_RR_TYPE_RRSIG rr. :param f: The expiration date to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_expiration(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_inception(self, f): """ Sets the inception date of a LDNS_RR_TYPE_RRSIG rr. :param f: The inception date to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_inception(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_keytag(self, f): """ Sets the keytag of a LDNS_RR_TYPE_RRSIG rr. :param f: The keytag to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_keytag(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_labels(self, f): """ Sets the number of labels of a LDNS_RR_TYPE_RRSIG rr. :param f: The number of labels to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_labels(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_origttl(self, f): """ Sets the original TTL of a LDNS_RR_TYPE_RRSIG rr. :param f: The original TTL to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_origttl(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_sig(self, f): """ Sets the signature data of a LDNS_RR_TYPE_RRSIG rr. :param f: The signature data to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_sig(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_signame(self, f): """ Sets the signers name of a LDNS_RR_TYPE_RRSIG rr. :param f: The signers name to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_signame(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_set_typecovered(self, f): """ Sets the typecovered of a LDNS_RR_TYPE_RRSIG rr. :param f: The type covered to set. :type f: :class:`ldns_rdf` :throws TypeError: when `f` of non-:class:`ldns_rdf` type. :return: (bool) True on success, False otherwise. """ return _ldns._ldns_rr_rrsig_set_typecovered(self, f) #parameters: ldns_rr *, ldns_rdf *, #retvals: bool def rrsig_sig(self): """ Returns the signature data of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the signature data or None on failure. """ return _ldns._ldns_rr_rrsig_sig(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_signame(self): """ Returns the signers name of a LDNS_RR_TYPE_RRSIG RR. :return: (:class:`ldns_rdf`) with the signers name or None on failure. """ return _ldns._ldns_rr_rrsig_signame(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def rrsig_typecovered(self): """ Returns the type covered of a LDNS_RR_TYPE_RRSIG rr. :return: (:class:`ldns_rdf`) with the type covered or None on failure. """ return _ldns._ldns_rr_rrsig_typecovered(self) #parameters: const ldns_rr *, #retvals: ldns_rdf * def set_class(self, rr_class): """ Sets the class in the rr. :param rr_class: Set to this class. :type rr_class: int :throws TypeError: when `rr_class` of non-integer type. """ _ldns.ldns_rr_set_class(self, rr_class) #parameters: ldns_rr *, ldns_rr_class, #retvals: def set_owner(self, owner): """ Sets the owner in the rr structure. :param owner: Owner name. :type owner: :class:`ldns_dname` :throws TypeError: when `owner` of non-:class:`ldns_dname` type. .. note:: The type checking of `owner` is benevolent. It allows also to pass a dname :class:`ldns_rdf` object. This will probably change in future. """ if (not isinstance(owner, ldns_dname)) and \ isinstance(owner, ldns_rdf) and \ owner.get_type() == _ldns.LDNS_RDF_TYPE_DNAME: warnings.warn("The ldns_rr.new_frm_str() method will" + " drop the possibility to accept ldns_rdf as owner." + " Convert argument to ldns_dname.", PendingDeprecationWarning, stacklevel=2) _ldns._ldns_rr_set_owner(self, owner) #parameters: ldns_rr *, ldns_rdf *, #retvals: def set_question(self, question): """ Sets the question flag in the rr structure. :param question: Question flag. :type question: bool """ _ldns.ldns_rr_set_question(self, question) #parameters: ldns_rr *, bool, #retvals: def set_rd_count(self, count): """ Sets the rd_count in the rr. :param count: Set to this count. :type count: positive int :throws TypeError: when `count` of non-integer type. """ _ldns.ldns_rr_set_rd_count(self, count) #parameters: ldns_rr *, size_t, #retvals: def set_rdf(self, f, position): """ Sets a rdf member, it will be set on the position given. The old value is returned, like pop. :param f: The rdf to be set. :type f: :class:`ldns_rdf` :param position: The position the set the rdf. :type position: positive int :throws TypeError: when mismatching types passed. :return: (:class:`ldns_rdf`) the old value in the rr, None on failure. """ return _ldns._ldns_rr_set_rdf(self, f, position) #parameters: ldns_rr *, const ldns_rdf *, size_t, #retvals: ldns_rdf * def set_ttl(self, ttl): """ Sets the ttl in the rr structure. :param ttl: Set to this ttl. :type ttl: positive int :throws TypeError: when `ttl` of non-integer type. """ _ldns.ldns_rr_set_ttl(self, ttl) #parameters: ldns_rr *, uint32_t, #retvals: def set_type(self, rr_type): """ Sets the type in the rr. :param rr_type: Set to this type. :type rr_type: integer :throws TypeError: when `rr_type` of non-integer type. """ _ldns.ldns_rr_set_type(self, rr_type) #parameters: ldns_rr *, ldns_rr_type, #retvals: def to_canonical(self): """ Converts each dname in a rr to its canonical form. """ _ldns.ldns_rr2canonical(self) def ttl(self): """ Returns the ttl of an rr structure. :return: (int) the ttl of the rr. """ return _ldns.ldns_rr_ttl(self) #parameters: const ldns_rr *, #retvals: uint32_t @staticmethod def type_by_name(string): """ Retrieves a rr type identifier value by looking up its name. Returns 0 if invalid name passed. :param string: RR type name. :type string: str :throws TypeError: when `string` of inappropriate type. :return: (int) RR type identifier, or 0 if no matching value to identifier found. """ return _ldns.ldns_get_rr_type_by_name(string) def uncompressed_size(self): """ Calculates the uncompressed size of an RR. :return: (integer) size of the rr. """ return _ldns.ldns_rr_uncompressed_size(self) #parameters: const ldns_rr *, #retvals: size_t # # _LDNS_RR_METHODS # %} } /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ %nodefaultctor ldns_struct_rr_list; /* No default constructor. */ %nodefaultdtor ldns_struct_rr_list; /* No default destructor. */ %ignore ldns_struct_rr_list::_rrs; %newobject ldns_rr_list_cat_clone; %newobject ldns_rr_list_clone; %newobject ldns_rr_list_pop_rr; %newobject ldns_rr_list_pop_rr_list; %newobject ldns_rr_list_pop_rrset; %newobject ldns_rr_list_rr; %newobject ldns_rr_list_new; %newobject ldns_get_rr_list_hosts_frm_file; %newobject ldns_rr_list_subtype_by_rdf; %newobject ldns_rr_list2str; %delobject ldns_rr_list_deep_free; %delobject ldns_rr_list_free; /* Clone data on push. */ %rename(__ldns_rr_list_push_rr) ldns_rr_list_push_rr; %inline %{ bool _ldns_rr_list_push_rr(ldns_rr_list* r, ldns_rr *rr) { bool ret; ldns_rr *new; new = ldns_rr_clone(rr); if (!(ret = ldns_rr_list_push_rr(r, new))) { ldns_rr_free(new); } return ret; } %} %rename(__ldns_rr_list_push_rr_list) ldns_rr_list_push_rr_list; %inline %{ bool _ldns_rr_list_push_rr_list(ldns_rr_list* r, ldns_rr_list *r2) { bool ret; ldns_rr_list *new; new = ldns_rr_list_clone(r2); if (!(ret = ldns_rr_list_push_rr_list(r, new))) { ldns_rr_list_deep_free(new); } return ret; } %} %newobject _ldns_rr_list_set_rr; %rename(__ldns_rr_list_set_rr) ldns_rr_list_set_rr; %inline %{ ldns_rr * _ldns_rr_list_set_rr(ldns_rr_list * rrl, ldns_rr *rr, size_t idx) { ldns_rr *ret; ldns_rr *new; new = ldns_rr_clone(rr); if ((ret = ldns_rr_list_set_rr(rrl, new, idx)) == NULL) { ldns_rr_free(new); } return ret; } %} %rename(__ldns_rr_list_cat) ldns_rr_list_cat; %inline %{ bool _ldns_rr_list_cat(ldns_rr_list *r, ldns_rr_list *r2) { return ldns_rr_list_cat(r, ldns_rr_list_clone(r2)); } %} /* End clone data on push. */ /* Clone data on pull. */ %newobject _ldns_rr_list_rr; %rename(__ldns_rr_list_rr) ldns_rr_list_rr; %inline %{ ldns_rr * _ldns_rr_list_rr(ldns_rr_list *r, int i) { ldns_rr *rr; rr = ldns_rr_list_rr(r, i); return (rr != NULL) ? ldns_rr_clone(rr) : NULL; } %} %newobject _ldns_rr_list_owner; %rename(__ldns_rr_list_owner) ldns_rr_list_owner; %inline %{ ldns_rdf * _ldns_rr_list_owner(ldns_rr_list *r) { ldns_rdf *rdf; rdf = ldns_rr_list_owner(r); return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL; } %} /* End clone data on pull. */ /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ %rename(ldns_rr_list) ldns_struct_rr_list; #ifdef LDNS_DEBUG %rename(__ldns_rr_list_deep_free) ldns_rr_list_deep_free; %rename(__ldns_rr_list_free) ldns_rr_list_free; %inline %{ void _ldns_rr_list_deep_free(ldns_rr_list *r) { printf("******** LDNS_RR_LIST deep free 0x%lX ************\n", (long unsigned int) r); ldns_rr_list_deep_free(r); } void _ldns_rr_list_free(ldns_rr_list *r) { printf("******** LDNS_RR_LIST deep free 0x%lX ************\n", (long unsigned int) r); ldns_rr_list_free(r); } %} #else %rename(_ldns_rr_list_deep_free) ldns_rr_list_deep_free; %rename(_ldns_rr_list_free) ldns_rr_list_free; #endif /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ /* None. */ /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") ldns_struct_rr_list "List of Resource Records. This class contains a list of RR's (see :class:`ldns.ldns_rr`). " %extend ldns_struct_rr_list { %pythoncode %{ def __init__(self): self.this = _ldns.ldns_rr_list_new() if not self.this: raise Exception("Can't create new RR_LIST") __swig_destroy__ = _ldns._ldns_rr_list_deep_free # # LDNS_RR_LIST_CONSTRUCTORS_ # @staticmethod def new(raiseException=True): """ Creates an empty RR List object. :param raiseException: Set to True if an exception should signal an error. :type raiseException: bool :throws Exception: when `raiseException` is True and error occurs. :return: :class:`ldns_rr_list` Empty RR list. """ rrl = _ldns.ldns_rr_list_new() if (not rrl) and raiseException: raise Exception("Can't create RR List.") return rrl @staticmethod def new_frm_file(filename="/etc/hosts", raiseException=True): """ Creates an RR List object from file content. Goes through a file and returns a rr list containing all the defined hosts in there. :param filename: The filename to use. :type filename: str :param raiseException: Set to True if an exception should signal an error. :type raiseException: bool :throws TypeError: when `filename` of inappropriate type. :throws Exception: when `raiseException` is True and error occurs. :return: RR List object or None. If the object can't be created and `raiseException` is True, an exception occurs. **Usage** >>> alist = ldns.ldns_rr_list.new_frm_file() >>> print alist localhost. 3600 IN A 127.0.0.1 ... """ rr = _ldns.ldns_get_rr_list_hosts_frm_file(filename) if (not rr) and (raiseException): raise Exception("Can't create RR List.") return rr # # _LDNS_RR_LIST_CONSTRUCTORS # def __str__(self): """ Converts a list of resource records to presentation format. :return: (str) Presentation format. """ return _ldns.ldns_rr_list2str(self) def print_to_file(self, output): """ Print a rr_list to output. :param output: Opened file to print to. :throws TypeError: when `output` of inappropriate type. """ _ldns.ldns_rr_list_print(output, self) def to_canonical(self): """ Converts each dname in each rr in a rr_list to its canonical form. """ _ldns.ldns_rr_list2canonical(self) #parameters: ldns_rr_list *, #retvals: def rrs(self): """ Returns a generator object of a list of rr records. :return: (generator) generator object. """ for i in range(0, self.rr_count()): yield self.rr(i) def is_rrset(self): """ Checks if the rr list is a rr set. :return: (bool) True if rr list is a rr set. """ return _ldns.ldns_is_rrset(self) def __cmp__(self, rrl2): """ Compares two rr lists. :param rrl2: The second one. :type rrl2: :class:`ldns_rr_list` :throws TypeError: when `rrl2` of non-:class:`ldns_rr_list` type. :return: (int) 0 if equal, -1 if this list comes before `rrl2`, 1 if `rrl2` comes before this list. """ return _ldns.ldns_rr_list_compare(self, rrl2) def __lt__(self, other): """ Compares two rr lists. :param other: The second one. :type other: :class:`ldns_rr_list` :throws TypeError: when `other` of non-:class:`ldns_rr_list` type. :return: (bool) True when `self` is less than 'other'. """ return _ldns.ldns_rr_list_compare(self, other) == -1 def __le__(self, other): """ Compares two rr lists. :param other: The second one. :type other: :class:`ldns_rr_list` :throws TypeError: when `other` of non-:class:`ldns_rr_list` type. :return: (bool) True when `self` is less than or equal to 'other'. """ return _ldns.ldns_rr_list_compare(self, other) != 1 def __eq__(self, other): """ Compares two rr lists. :param other: The second one. :type other: :class:`ldns_rr_list` :throws TypeError: when `other` of non-:class:`ldns_rr_list` type. :return: (bool) True when `self` is equal to 'other'. """ return _ldns.ldns_rr_list_compare(self, other) == 0 def __ne__(self, other): """ Compares two rr lists. :param other: The second one. :type other: :class:`ldns_rr_list` :throws TypeError: when `other` of non-:class:`ldns_rr_list` type. :return: (bool) True when `self` is not equal to 'other'. """ return _ldns.ldns_rr_list_compare(self, other) != 0 def __gt__(self, other): """ Compares two rr lists. :param other: The second one. :type other: :class:`ldns_rr_list` :throws TypeError: when `other` of non-:class:`ldns_rr_list` type. :return: (bool) True when `self` is greater than 'other'. """ return _ldns.ldns_rr_list_compare(self, other) == 1 def __ge__(self, other): """ Compares two rr lists. :param other: The second one. :type other: :class:`ldns_rr_list` :throws TypeError: when `other` of non-:class:`ldns_rr_list` type. :return: (bool) True when `self` is greater than or equal to 'other'. """ return _ldns.ldns_rr_list_compare(self, other) != -1 def write_to_buffer(self, buffer): """ Copies the rr_list data to the buffer in wire format. :param buffer: Output buffer to append the result to. :type buffer: :class:`ldns_buffer` :throws TypeError: when `buffer` of non-:class:`ldns_buffer` type. :return: (ldns_status) ldns_status """ return _ldns.ldns_rr_list2buffer_wire(buffer, self) # # LDNS_RR_LIST_METHODS_ # def cat(self, right): """ Concatenates two ldns_rr_lists together. This modifies rr list (to extend it and adds RRs from right). :param right: The right-hand side. :type right: :class:`ldns_rr_list` :throws TypeError: when `right` of non-:class:`ldns_rr_list` type. :return: (bool) True if success. """ return _ldns._ldns_rr_list_cat(self, right) #parameters: ldns_rr_list *, ldns_rr_list *, #retvals: bool def cat_clone(self, right): """ Concatenates two ldns_rr_lists together, creates a new list of the rr's (instead of appending the content to an existing list). :param right: The right-hand side. :type right: :class:`ldns_rr_list` :throws TypeError: when `right` of non-:class:`ldns_rr_list` type. :return: (:class:`ldns_rr_list`) rr list with left-hand side + right-hand side concatenated, on None on error. """ return _ldns.ldns_rr_list_cat_clone(self, right) #parameters: ldns_rr_list *, ldns_rr_list *, #retvals: ldns_rr_list * def clone(self): """ Clones an rrlist. :return: (:class:`ldns_rr_list`) the cloned rr list, or None on error. """ return _ldns.ldns_rr_list_clone(self) #parameters: const ldns_rr_list *, #retvals: ldns_rr_list * def contains_rr(self, rr): """ Returns True if the given rr is one of the rrs in the list, or if it is equal to one. :param rr: The rr to check. :type rr: :class:`ldns_rr` :throws TypeError: when `rr` of non-:class:`ldns_rr` type. :return: (bool) True if rr_list contains `rr`, False otherwise. """ return _ldns.ldns_rr_list_contains_rr(self, rr) #parameters: const ldns_rr_list *, ldns_rr *, #retvals: bool def owner(self): """ Returns the owner domain name rdf of the first element of the RR. If there are no elements present, None is returned. :return: (:class:`ldns_dname`) dname of the first element, or None if the list is empty. """ rdf = _ldns._ldns_rr_list_owner(self) if rdf: rdf = ldns_dname(rdf, clone=False) return rdf #parameters: const ldns_rr_list *, #retvals: ldns_rdf * def pop_rr(self): """ Pops the last rr from an rrlist. :return: (:class:`ldns_rr`) None if nothing to pop. Otherwise the popped RR. """ rr = _ldns.ldns_rr_list_pop_rr(self) return rr #parameters: ldns_rr_list *, #retvals: ldns_rr * def pop_rr_list(self, size): """ Pops an rr_list of size s from an rrlist. :param size: The number of rr's to pop. :type size: positive int :throws TypeError: when `size` of inappropriate type. :return: (:class:`ldns_rr_list`) None if nothing to pop. Otherwise the popped rr list. """ return _ldns.ldns_rr_list_pop_rr_list(self, size) #parameters: ldns_rr_list *, size_t, #retvals: ldns_rr_list * def pop_rrset(self): """ Pops the first rrset from the list, the list must be sorted, so that all rr's from each rrset are next to each other. :return: (:class:`ldns_rr_list`) the first rrset, or None when empty. """ return _ldns.ldns_rr_list_pop_rrset(self) #parameters: ldns_rr_list *, #retvals: ldns_rr_list * def push_rr(self, rr): """ Pushes an rr to an rrlist. :param rr: The rr to push. :type rr: :class:`ldns_rr` :throws TypeError: when `rr` of non-:class:`ldns_rr` type. :return: (bool) False on error, otherwise True. """ return _ldns._ldns_rr_list_push_rr(self, rr) #parameters: ldns_rr_list *, const ldns_rr *, #retvals: bool def push_rr_list(self, push_list): """ Pushes an rr list to an rr list. :param push_list: The rr_list to push. :type push_list: :class:`ldns_rr_list` :throws TypeError: when `push_list` of non-:class:`ldns_rr_list` type. :returns: (bool) False on error, otherwise True. """ return _ldns._ldns_rr_list_push_rr_list(self, push_list) #parameters: ldns_rr_list *, const ldns_rr_list *, #retvals: bool def rr(self, nr): """ Returns a specific rr of an rrlist. :param nr: Index of the desired rr. :type nr: positive int :throws TypeError: when `nr` of inappropriate type. :return: (:class:`ldns_rr`) The rr at position `nr`, or None if failed. """ return _ldns._ldns_rr_list_rr(self, nr) #parameters: const ldns_rr_list *, size_t, #retvals: ldns_rr * def rr_count(self): """ Returns the number of rr's in an rr_list. :return: (int) The number of rr's. """ return _ldns.ldns_rr_list_rr_count(self) #parameters: const ldns_rr_list *, #retvals: size_t def set_rr(self, r, idx): """ Set a rr on a specific index in a ldns_rr_list. :param r: The rr to set. :type r: :class:`ldns_rr` :param idx: Index into the rr_list. :type idx: positive int :throws TypeError: when parameters of inappropriate types. :return: (:class:`ldns_rr`) the old rr which was stored in the rr_list, or None if the index was too large to set a specific rr. """ return _ldns._ldns_rr_list_set_rr(self, r, idx) #parameters: ldns_rr_list *, const ldns_rr *, size_t, #retvals: ldns_rr * def set_rr_count(self, count): """ Sets the number of rr's in an rr_list. :param count: The number of rr in this list. :type count: positive int :throws TypeError: when `count` of non-integer type. :throws Exception: when `count` out of acceptable range. .. warning:: Don't use this method unless you really know what you are doing. """ # The function C has a tendency to generate an assertion fail when # the count exceeds the list's capacity -- therefore the checking # code. if isinstance(count, int) and \ ((count < 0) or (count > self._rr_capacity)): raise Exception("Given count %d is out of range " % (count) + "of the rr list's capacity %d." % (self._rr_capacity)) _ldns.ldns_rr_list_set_rr_count(self, count) #parameters: ldns_rr_list *, size_t, #retvals: def sort(self): """ Sorts an rr_list (canonical wire format). """ _ldns.ldns_rr_list_sort(self) #parameters: ldns_rr_list *, #retvals: def subtype_by_rdf(self, r, pos): """ Return the rr_list which matches the rdf at position field. Think type-covered stuff for RRSIG. :param r: The rdf to use for the comparison. :type r: :class:`ldns_rdf` :param pos: At which position we can find the rdf. :type pos: positive int :throws TypeError: when parameters of inappropriate types. :return: (:class:`ldns_rr_list`) a new rr list with only the RRs that match, or None when nothing matches. """ return _ldns.ldns_rr_list_subtype_by_rdf(self, r, pos) #parameters: ldns_rr_list *, ldns_rdf *, size_t, #retvals: ldns_rr_list * def type(self): """ Returns the type of the first element of the RR. If there are no elements present, 0 is returned. :return: (int) rr_type of the first element, or 0 if the list is empty. """ return _ldns.ldns_rr_list_type(self) #parameters: const ldns_rr_list *, #retvals: ldns_rr_type # # _LDNS_RR_LIST_METHODS # %} } /* ========================================================================= */ /* SWIG setting and definitions. */ /* ========================================================================= */ %newobject ldns_rr_descript; %nodefaultctor ldns_struct_rr_descriptor; /* No default constructor. */ %nodefaultdtor ldns_struct_rr_descriptor; /* No default destructor.*/ %rename(ldns_rr_descriptor) ldns_struct_rr_descriptor; /* ========================================================================= */ /* Debugging related code. */ /* ========================================================================= */ /* None. */ /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ %inline %{ /* * Does nothing, but keeps the SWIG wrapper quiet about absent destructor. */ void ldns_rr_descriptor_dummy_free(const ldns_rr_descriptor *rd) { (void) rd; } %} /* ========================================================================= */ /* Encapsulating Python code. */ /* ========================================================================= */ %feature("docstring") ldns_struct_rr_descriptor "Resource Record descriptor. This structure contains, for all rr types, the rdata fields that are defined. In order to create a class instance use :meth:`ldns_rr_descriptor`. " %extend ldns_struct_rr_descriptor { %pythoncode %{ def __init__(self, rr_type): """ Returns the resource record descriptor for the given type. :param rr_type: RR type. :type rr_type: int :throws TypeError: when `rr_type` of inappropriate type. :return: (:class:`ldns_rr_descriptor`) RR descriptor class. """ self.this = self.ldns_rr_descriptor(rr_type) def __str__(self): raise Exception("The content of this class cannot be printed.") __swig_destroy__ = _ldns.ldns_rr_descriptor_dummy_free # # LDNS_RR_DESCRIPTOR_CONSTRUCTORS_ # @staticmethod def ldns_rr_descriptor(rr_type): """ Returns the resource record descriptor for the given type. :param rr_type: RR type. :type rr_type: int :throws TypeError: when `rr_type` of inappropriate type. :return: (:class:`ldns_rr_descriptor`) RR descriptor class. """ return _ldns.ldns_rr_descript(rr_type) #parameters: uint16_t #retvals: const ldns_rr_descriptor * # # _LDNS_RR_DESCRIPTOR_CONSTRUCTORS # # # LDNS_RR_DESCRIPTOR_METHODS_ # def field_type(self, field): """ Returns the rdf type for the given rdata field number of the rr type for the given descriptor. :param field: The field number. :type field: positive int :throws TypeError: when `field` of non-integer type. :return: (int) the rdf type for the field. """ return _ldns.ldns_rr_descriptor_field_type(self, field) #parameters: const ldns_rr_descriptor *, size_t, #retvals: ldns_rdf_type def maximum(self): """ Returns the maximum number of rdata fields of the rr type this descriptor describes. :return: (int) the maximum number of rdata fields. """ return _ldns.ldns_rr_descriptor_maximum(self) #parameters: const ldns_rr_descriptor *, #retvals: size_t def minimum(self): """ Returns the minimum number of rdata fields of the rr type this descriptor describes. :return: (int) the minimum number of rdata fields. """ return _ldns.ldns_rr_descriptor_minimum(self) #parameters: const ldns_rr_descriptor *, #retvals: size_t # # _LDNS_RR_DESCRIPTOR_METHODS # %} } /* ========================================================================= */ /* Added C code. */ /* ========================================================================= */ /* * rrsig checking wrappers * * Copying of rr pointers into the good_keys list leads to double free * problems, therefore we provide two options - either ignore the keys * or get list of indexes of the keys. The latter allows fetching of the * keys later on from the original key set. */ %rename(__ldns_verify_rrsig_keylist) ldns_verify_rrsig_keylist; %inline %{ ldns_status ldns_verify_rrsig_keylist_status_only(ldns_rr_list *rrset, ldns_rr *rrsig, const ldns_rr_list *keys) { ldns_rr_list *good_keys = ldns_rr_list_new(); ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys, good_keys); ldns_rr_list_free(good_keys); return status; } %} %rename(__ldns_verify_rrsig_keylist) ldns_verify_rrsig_keylist; %inline %{ PyObject* ldns_verify_rrsig_keylist_(ldns_rr_list *rrset, ldns_rr *rrsig, const ldns_rr_list *keys) { PyObject* tuple; PyObject* keylist; ldns_rr_list *good_keys = ldns_rr_list_new(); ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys, good_keys); tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, SWIG_From_int(status)); keylist = PyList_New(0); if (status == LDNS_STATUS_OK) { unsigned int i; for (i = 0; i < ldns_rr_list_rr_count(keys); i++) { if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i))) { PyList_Append(keylist, SWIG_From_int(i)); } } } PyTuple_SetItem(tuple, 1, keylist); ldns_rr_list_free(good_keys); return tuple; } %} %rename(__ldns_verify_rrsig_keylist_notime) ldns_verify_rrsig_keylist_notime; %inline %{ ldns_status ldns_verify_rrsig_keylist_notime_status_only(ldns_rr_list *rrset, ldns_rr *rrsig, const ldns_rr_list *keys) { ldns_rr_list *good_keys = ldns_rr_list_new(); ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys, good_keys); ldns_rr_list_free(good_keys); return status; } %} %rename(__ldns_verify_rrsig_keylist_notime) ldns_verify_rrsig_keylist_notime; %inline %{ PyObject* ldns_verify_rrsig_keylist_notime_(ldns_rr_list *rrset, ldns_rr *rrsig, const ldns_rr_list *keys) { PyObject* tuple; PyObject* keylist; ldns_rr_list *good_keys = ldns_rr_list_new(); ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys, good_keys); tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, SWIG_From_int(status)); keylist = PyList_New(0); if (status == LDNS_STATUS_OK) { unsigned int i; for (i = 0; i < ldns_rr_list_rr_count(keys); i++) { if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i))) { PyList_Append(keylist, SWIG_From_int(i)); } } } PyTuple_SetItem(tuple, 1, keylist); ldns_rr_list_free(good_keys); return tuple; } %} /* End of rrsig checking wrappers. */ ldns-1.9.2/contrib/NETLDNS.tar.gz0000664000175000017500000015246215212267520015743 0ustar willemwillemm2L `\Iq0+om ?8:7kaϐ18x{bx_ .x_];w޳ qx5»|׌!x{=IxGn'{/yx7} x'ᝂwsYxw~x}" .{?}}W{^_x_ux}"xW-{2x}^5x"um߀1xq/ jx_Dc1 7<0.$[o0|2XOCmR@&ng"`>v mpI9/OJHCoP zz%YXPr.ŭs;!~ho6"@OϤϑtiLt?8Ojyք>&_r02Gs~# t i(i4?ҁ) 3PkGߦ8}#=`qHxoGڈ4 g( _@_w}o7-̽.ͯ0 {q, S?sR$!v q'0|f' |RN"YXZ[nnL{ngFk*5^ Uрmo]EN@ %.6RGm9xǡ Ih˟?_sʳO|/VΗͽs_HW_?qZVBs>ُ{8ZDWŊ4Ne"nkp_ 3WR/_Hp-ԏ2/{eG6尕&y9HS0um NԢф^9-on_'~lll>% *X?DPJGE܆(JB/pu*8EKSLa+G)~k| QeE)i|? =UHuQJnrg o3EG#1[VsК#RSbE*Roԏ2DKn9:Fy' ى˷󭴴yg\ϋP?/< . ck~8?oc{ZEZpyXܥ_|S=6A"h P@bjOɷ(rqmIaqn0 n0QJ2 KQEi0|*HuI(J~ߛYws;*`^=_bx#x/s[¿ڸ(F0,xg/h'?tꩥ͌;(˴ߜSjy~VwQR! c+ZyJ)i~ҽCYCQJ+ƘX/#,]ǀ^܄?~W s_iw-csj'p+a ] Aa=ϝ0gM0{1}?I?>}7_=^z(]~Ka x%Zt!)Bեh B=Cü=iw` X ) </O( ;P˜S@,Ǹ־ [0" ?/'Ua\?QcH5lǰ0!ó=㕦:Lp㼫 5_Eao)'5Q uSP}~xP;~}n>2_HㇰS<70 կExb=;!20PTWK)J8A$)'P7NR0^a{)l°I {eB͜(l°m(bB) 5;$ʖ0[KLaU}yBدHH;៝ߚ` d}S#?!ۙd /LHƄxw#oN&Ju ~>?HhÏ<|^4? ? ?O3,?Ge|~_߿ LgJ(}߀ ?Ķ `X[S؟e _k; G@i >+|?x+| š(_CnK푲Дۤ9k}Q:3O+uGt_:'ob>HyaRwK9R(n G󃄟RP0M2ov:U:q#zgEA= GQ0|CRçSa e ,Õq.m4cHBh+.3 )6!_$MS97:a4j3Kߘgn%g"{1U ֟ cQy1z>3aǨ>d;h~kǡsCמ;m80 pom3n?:n!81eC03j]Z:IGc`|€{ W>M5-k+ߗh^6zË[wVqsbcD&Wg+& OFF] q59X~ Rۥ)ϧkxI\ OH#v#䎽#Q^^.^ʏ_~W~r]N|жP\\x>{o=oBJi}# ?s0go8ޞhsE7]QWR7C߆黼9)ƾVq@y21+Zg=s͘?Nߢq&U_&PgЩάa)}OU32,7>rcם˹}DuR(zDř(\n gqw3},&FrIE-'g$\v<[l?8K:|7(xL0^~mfT{[v1d~^ڕ]x-j!_H;ʦ~ 3{Awba:PQݻh9E vx"x;`} |~)o x7yf 7}~ _ &oO]2 >7Nxd o=*Nxtҟ_=~/0MiЦC>u|K'(? \I T> +)xӨ[ o?PC{GZ?~޿yҽy|=?;(gOx >?qJgyj?qwgu"e'H(B[&',[ a|:{MPuO-Ү~{Rsf{w2^29s ڟPo=j =稂n'ܷ筪$}3{ު<[ Jn壟ȍ{N/Bm(>gG5&FM~Ws-pkv>}Vvv[=o_Vei`s9k s{.ʅJ` j[4^X7%I.>ݲ={w {7.'Ҙjh'-=_!ﴠQ@Ds9q^1/Fu1>jڷ$vC҃^@KEtS?`Tfl\3ub̈ \~R <0OaF@J;Hki{͑oʜ'`/7p3d@HJmwzx`YKbٮ+{%Zئ\$k?wB1Cbt^lmPK>ڻ̫tr썃xKZI%bX@ r1!_]_eO:qG1F7h>I ߣu?!m58[ю>&֟vUv?hg_8xghDpd+ތE+K')SZp #Tz {^Gaz ;|#C\wSP=&.컖P=۠0L( :e4>}u+Ö$Q0@N8%-R YE{L (R{FU*㱄noQ<0 ax ~" Z?xv*[P0xQ?]0;ˎPV<^EZyC™x°/vm@;asx?ӈqވgug{Bh^?zg&$ǭpOn~$ioea 2ݍ>?UGYi{?>]:VZz勵M8a\eql9gR؋t/v/Z05CuN< wCڸz>0pCݽ} |;x + oҮY ]!y7D^>7C/?޶/>ؕӽ>skczՓofX鞣?"ē?୓-|C`k^,C׭3cA1ϟ-ĭ>{=?zBC?أ1J?1H(K9>~y)ˋ(.--0JaߵoǾE9XyM_Os]x_63,'ۭ]?䟹Dk?b}6o=C{ٙWhݼ\|' O0s1BiL(=WSXpSfBɾzeޟ?SGS^/Wvu}foO"HL7zv'ww]㝿e-2bVl`L?VYpM#9/(BV!@K}82ٟ8 3qyvkvJIRXp. S]nWz~ި֯^O&×לB^.-eW ?όKu:~&~+Fg/L4_@Yٿ\y GZ\ ٙ|E"^~[sba Cެ♔=3ޤQфy^OTCoG:fƔ{vH'EqX ߧjބ(DB{ k{| 4JS"1W\ӂAw=z;CFY^o~GoðB9JD}8ހevԃw>= 3[ZdަR]o<(uH})|$khÂd^谭8Wی-E߉G?q/qOi{ voL ]//8jۢϢtY{{t&jF6#Na|pa3)S PXCt/,` 3e͖6IHʉ2r2ߕp1/qOSX&M(=Ga,{CI0gEn@ɐV!%%:L(/RB5ap>ءdŃ :=Bi¾CCaѡ%n Tt(Fi C ) C?Ey¾'!=XQ_vөX$(yrfJ'K(ցe?i -DP;(851L#Xb\-%Ԙ=HavBq78'ޟ^X9/PyAⵞg68hQL-N:S˻|sҔLjob^2/N$ޤy E6/0\٣ RWSb՛)Z?>@ a>D~0p##ZA}—OPyL(JjZyi IaPO}FKZX˧X/ 93@aՄ_Ba_PUZo cB;o/ii{m+Dh?r gQi?X}ۡs[Ue7emMH(Mϳ4jl c |Y ~`Z3ka̗0sR#e} dOpmӱj-Khao>Vʗ9om_ AgvqU`Vͮ˿x_sͼΖe(pQ!ukCmJkOLq6JaW | _Daj\%bkܑa#-D❿*xG˿?G^ O֏wƒwHouցVGnx½˖oJH?(^C.}#AYxG2S;[7_% -~䮄ܮ뎄ٰtww$6.PkKv}lhLw¼ WiSZyL _/}1-WQo' %ڥ}_}*CLUZ@eW'_}dnO!<^k?9=ۛ{]+Y.;/  p{n ~83{+f(Gj 1t5 C٣ƚȃŸ C: cY !d˛) җkaHŎ~{?2G0>?s_T&ĘVN:fC;dbC e P~ ^~ !O/ d+MFtۨ%~x?!N¾G)8l%) (Dʐ-??| W?iD_ńSGt*1'|v°|Zk¾,֕/I(k) KF {'sy`6)RRΟ|lL ߿k-"Y/ PYOsc:Da[d) Wbs%̕ r}oC })AO U]i0=C1'h)H? ZOkz^(#G:8λuhKs#͖px=>ڷj$)0k$%ԮXzfZOS?7Yvjw èC{ҭф#ټx/\ ꏧ*Q+'h!05 xڏowM_G{Uْ8z#V, ߏ^n/?>CpnHT럮V^~~~[B78=ͻ+ߙyGK}7@K~o)c,;f:g[:- ֞|eKEJ/$* c)ZI'Џ'2kpKR;yEkrg|COGPBgU/,QrBIV(n> ~ѵbw0s %u0D~u&sw%7߸"B?A?[Z؟RO"Q'ǿZ:HNoSAkRyM(HVxT=CӟMnPP< {CaA *;n.b2ҡ)ZZ;v7SƿV/P/lMr¾Fk3ZD5ҽpzo:> ~Ka0. Hۃ|4!i Q <wG>x_ o^w9x/CʦfԻ3+~ƻi\?(7}go '1o>1nMq_h{w&$e56o@BI-C n*y~5VS |BR=^RH(c+y?DaPmfo ttUQϣ0EޥQn ;Q^ Ki6Ha(9:F: Q3*_Sލ%NaOh%q{i6CFF OzQ CO(=-T{L#=Pa)jBфUHgNK(zs %Nj/$b$Ba# E31Z,DmQG{˾MQ[3T^BR^.!i%*\5 ϥ0_!'/C#_H阖T6I _' w(&;,OK7K4Ϸ<_f0 cx~VNa(Faν"Y* *{?K7I%Ug4Prܵ=!:{8s4 cXp7q/V?p9nځ>qoCRr ջ=!]k[~[8?V6=%H)-fj̶ٞ+2:庂Pr%= C CNSQC~ָ?џ/uiOo? ,!?Er]1qU(廊k~y`%b /:) em!7}3աM֋\nMkXҜM%z~LqX{J-(uq:ƒl3{ pQ7/"ܹy.߀Aoܧ<{m;Jr'x#i~Sݦ÷Q:c&-1k,aYcm 5㾃] 5X~@{Kxh&guc=vuhҮ]lW@ܳίtsui?h^s, CңED#0L4fOyO''{>aRu|od!$,hO\x89JxOnCG_+;= Cwu㐞 b< ;ԇOA}$Ƹm>3`7'!@ AWc|v BL%mk랷G1jэ~[B8`mR,aU?kɍtĩ_(~q>Ujԗk%K qk;c=?EЖ"L}}H?~ 1a2dzy&6$eGY#Z :6{m:|+iw3UӟSn/Lj?tk'YHwʕP3 &t85[1q8N^CWa٣[+-#)&$wcS{С("^{nHw7OxSG>+e,eA6&U&1Xk o(L_!!\Wަ09vەP|W8ey,AKmtf|dL_HxÏQ/ 6Can}ѫbQ[q!-˒f ʿ0%!NhA8Z8&Rhyttle=hѵyxr*3_T/S!JǧHݷ$f|c?|>%-D] L+2'כ2HqPWIk0 kt,4x2em+@aPt)5 pm$zNր;/sxN̺S㪇)Oqܥ8sc ηDWpEz4d6m`Z6@EmTzLT5LcX_XO+ koϯp?Aa {V5 ڭ Ur) y)[_Cyߦ}=}'=}Zy,0ҫKlt#lZ2r W'1'M_HKKTk#}c sT|P'V߬j: G)'`O'Z5K(n(ݿSz.?) {_Z wCq{zJ9ʽ5((Ѯ]ʝ96Op,\ɴx3) l}[kQD̓ձŒc e-pQZW.Ve2>JwpS[;g,l{uqf{Dz>P.ƞ@Gl%]}oDwR^~o?Fu|4xtFo)"7οNy†;[;>9aѡnbXc'$*z Tǧ(^x5üуyotw gJ8_%Б8$n>_[Ot|(}ǰRt-8~H)ri%Z[,JץCjR;P[>/MyzSU$!s6ɰs hit֏ ;wi_Ea(02OW:@մzkVȃO—/7Rk)MZ)zCC$,x! 0C!5Cj~3N` xH_ J+hOSj~aE#~Êv~ =` /V4͙ߦ;SiaLa5>PNIg >My尢MN־RXՖCxv3uQ;z#jzپP}ǰQ4#ǎ~vDۏ9jK( y^Dͅ{1?{DY {%^răG7{Dy?1wAV Z7p|o>"[) OLN ýf CP?EaxVA6 3u{)l:;( eԏh}u5?ORSThuc?;(5 7 VNu|FÃ$a,>F9soRs)6V:&Տ#" C Dӑ+ 0i3ћ_2vG&t97)QثnR|S2\,PE-)snVJۉu(|c!2!qw>˯ඳԘvf<KOW܏ 3k^dO;Go~Ԥ8x_?[?j3x/Di4$TwVNTKv/X>4sr'XvA؋rg΅QyqπZm~>Pok[?__biě_?-d3#el =R|oq7vK8?X܉e'710 \IxI95>IRTvp0tP&a5nó4uJlTv=<]'mJ޿uy]T:NgC@R`*a5 S|_VZe\+3SW篜;veT؞P/U muGKWkSl Q:vcG;kKRCrq,Q5bNu^B^DzZaXXZgLnzlnfk G1jh]!Gѱ{z>j_I#'@MI'7cw?h~̻q(R`F"ODf@T^x`PBcF$CKӹ Z =k# ,3 ornJS `<r7/ SrNjUBW ::ju xvThGM#q 5wfI9x|U|+=*Ox{T.irMU}V`q}㙢mWh'ř?vc/?!2ÃCɴ̤?w <\rYqjK N^ U) j$%LUR7Y^wv)Q+-NZ GK%3-"2j `d|Bf2 %Ju9ۯl744KvQ?j"cm_oOًϋD1MaD~,?|xhAu00n-jq7x`'numn! =K (?tdj}6Ṳlr ӓB(~nnɘ;w]-nmuʌ~XF}oH֠K ̭;<{G&8eS~vl) "Ӆ mewftӆ-BT@SsrY^ONr&^(ꮏ).ӜVqQcw flrp(3_6=xc;=ZkzDl˜jl3>qV LF+SԚi\1X]m!5yZqx5 vx;^]w"A7&Wh#P׽^EYM$J`Vs^o5Ĉ0LA՞՚N0L>d#a>mXX_Kx |@\,0nP[btv~8a֠t?H%X t YKY{ IW&̤?ʣ$ GR(Q`'d0~^!]w2L*2D>oD5WkԵyITI@nFrnivrb>+e.O۔޳ׅHJ3@X%딥o:~Pamxڭ}gp`d|nleMKJzk]0TGVF`!lk5X⠇uTOj\4scTܐexֲ~HDJQE G㝝svv

]8] xAܫƵ){:< QBdUnyz2dϨ50V}!U.ka¬iV54v姝 b[KՁ]kչ:"T{Z ==> QN*pv"ǫ+]],@>NSќJ>wSZ踗@+6= :=hT700[EjɱEׁw1ismAd`kutC 5`(:Wv+`~!6z5 ώ3s05ԟ;q~҆kTay$ڥ ; PA@KMO'[@(ϼ902&ֺ91y*v}N:s4*P-ws"i/qm%JJMM}>lLjXG߆ c.pI.)37UT iH=RafŻU5R { sCe 2i,@4Y!kkv.YɝFp1ؽDqhQy*z4~Y:*Im}5xB%4"yf4,!͡tB- t`q-˱A6|PuKӼ xUy/ @.WJ IZIm~զɍ$Ic7w©L޷Q:v5<\.eQ^l[Ş]7{tF12v,b$09Tޜ^a< 5+߀}:QZfyySFā|+;#&毣Ź.k"vO7 '!l=vYVXL!MD<ƣ8W #($Ne3n<?_X=ʗ׿(|36%"34aeQL%/c69щ=52jp j|4Z8֌Ϧ^?u{wkTWrC us R Ͳ2 xw_XX81=we~2717{+ Ό͝_e҇.V pKΪ}Dž#>QtUwiTuPx;pzMۭ֒]>mWbDaǎ͞;;iEk/+ky!^Wn;ҌNͺ?v@iJ`L?wNAdq ɳӳr'eF0mrv32+/_./WJD'[۶CNKQ밉­;yN耆T " @^G3aW6;$ f]y?:2?k:f>ex?l6s{SL6;%FB ::vZdq-RS E }#ڛޔo}伕56A-4eӜC` 9}QjmM'hH|$o_`st(IQ32snpKGT: [SNaLeS9FOP +jcvzm @zeJq)YMY,ӶTgB_:tYW1a-呻\VtWBC\0 tOz  /%u=Dq8W0~yLAgqF Sˆs>pxY\"Bݓsmֈx>1-d%kfep*3j${$>ڡo M&N {Gn9t}0m %NpI3Sq~ښ$+0G;Oh7/u՝NF*2n"k5mztu}/aiHp[~Rd ](Ëz"8,yP5ZA̳Ң،6]r%i]3Gf;~3Ɖ^5%OuH_7%YaAd cHY a eϗ0@&tX"S~RM `N-R)Ųp*>ҹw()AkGM0֏)yigy`2G[y(+x[[j\KWƵZeZjw7z]n/aI`QHm񃚠!Ap"\I(5`D &#ٌx&LɣrP+ |"/hpm8,4dt+UUb5c6\m Z%@p2bXT~_H%~F} Y+b5zؗM2numuzvDOfxЫ3<<8ٍ #Ლ*3cR]3bR-`{(t&K 4bYGZ8dӔAB"=y*I}TԇMsg?1Fx?Õ?Ksg>5OJ0pUPJ@syvUQOD=IE~L̎(Et2ITǂ-zHBOxo@) &xcܩu.pJٹs30cJ^jK!& fnO=4c5q4M5SCaX4ixh&Ze.)+=m'D怛)ySc4Dnd7.**sZT= FI4b,ˍ2 i xb*ԗ5~j7 =lGHtUW1jcM?ʤ*Ǵ@ٱ1Gכ5f :4ך6W֘0j.-LYu]0U(M؊.jOI-ȶ!9؂~l7x΄+ztccƺīb;(mQ+8k׈US;P6Z6JVvɧ GVfmJV`*ml,tT#ȺW])_Ud3ԇB6DgрiXV(׿r$MVV2c‰b}&i1XP2ɊpD}ܑJ͵$<ڂ.C2+9ySO; vS}`X6˪ u b9xز ŊZn#݀CvnM!1 "PC NCLE G?rYc^\@.#%NM4]5 FN]`!S.ɕ6)L:T7z)UBTZZKĺ^DVlI꥕ՆKq$/rq+#\앐Vfzp%.IxnO$愐v[IkHHNp̭T]Vd@-LqlJ6} .iM %" vF%r(#-+t 7:ꁡKK{,lm 3Tu/BWSvj́T4]555UᵥA wpE+vAb7C¨YrK%L !f # -{Er*n>}{[%M 5C^&"^#N% &G$!Y̶מlRI!zK'yxuvbxR yxLÖܲvOZ71vqm~Au uJ;޽‹8*+bZWz ZUv 34 s0$Ⱥ v隭Ԫ/LVPr=V0E5Crmݗ^&xa"CJHd/u$*_WdQ*~(9P㬯AĀLb3nt7i [ .7|qO9+dtC!@bbu' 38݅*##>Jep7MZ922ąΛ^BڨexH/;e:' }.DJAByۋrN3֪:+E# {Y~\T qN!RRT2+M^zHoV-K>PE-V? Sj+,r?4t4Rr#@2tn(ܔ,vSo+ʲjvZ`\CzC)%.JT3t0̅] WԋfB!hiri).l 4l;t2qTNj $z+PLZmI(`X|06dJnX饶,(h-ć–Z,49t8"Vs<:l+Bۂ*'P3c43͌m7|ĶCDAf*>dmv@f)dƇ-ACv@lSȴDvfJvfvlٙEvCi~K vopBR|\d.m;d.md.5l|ngvKs;6v"@ t\n>-CLK@lJrSfi LJ$ ߶C-= q10R B $% ȶåDbn6U0|ϥ0G Ye=3S= EO=W_C}BSW=vd=FjT-j1+44SFMU;s(N]xx:E.ڎt;/HoBuB7CLX+VOLMhx9?5'ǝ0e|,=Y)qJ\dL&Q76.ɅC:ufjT7x MfhN ] w>JxTR>.yIJdG5wq| u5.VS_z Gt%8 lF4hy$#=Pum}=3PոUvýH6rN*bcGaD0KPAE;-jMf@*2V\G :'n=8Z]^uKjNMYm=ԛľ[]w!x0#lGw $jL,3֝wj1Eg560 .ǿb2bz! .e҅ռfPU}]w-[ 2+[^ x}: x݄1xf;w ځs9}7tҼ5t.Ӌ[6b  au.HhmCy\kм>PRxo[I9a9ceF):$yrX4Q&%# IQ,[$OԙjS6MSeYl`A>, J22,hX+h0| +) VKɓQmFUvPv8ZJZq7'D`rIzsy"1ҦZHn!mvÔVE%WƫdEdLY`ɇDģln,Che{Onz[0U-0)vP9ƴ {hEH{J%Y-R?U&)AK&Z!ErI!%x fh'vBI!:vkҼҦ)"+45l`exwihlj2DY?q7`l(rF^;BZ"ƭsenN&CF\ݰ"CYStAs巓9.H5322~ZkǦ{:j=J(_`*Q33>ߕGiMFRG&,8NI\̯eH##Bːr.9ī *{:jL!Ο^<7sYkTskno 2]CxB?Ҋ잻MVlG 苊hV([Zi- Rr;"k1]j5́ f$UR0ܖG3R8-z%?AūR9##SHwɑK}]KhFNCnn(LSgF?`/KGFp],{!euy{>5"Ph69cڛV h6(/$ji&]ϗJ%Z^DTŝL8ML~l==qZlDN/{hUMJe( BLMEt-2&h]9'nN/4|ЈnTNVcݛDzb%5]N9|$R 6RE5oRm ]:%u^ 7'L)Bۈ򞲊.LD)DW4sh6zPBb|V 1#|Eiw` gќF?V{jEmu]%{6S97fSg 4||T2.RXJôNU{4C&3lv(L22=+ȺN ODػҌPKr|T[UO"MOHFEԎ^ޑ3ؼG*@hEkWXW+ᕫU݊]hW$eά/> 0A33w%GPTs\#1Z414xbb%1M1&M:V i﹤C:UMM\%SĴ" 1dkM hN!g/whFfv uf۩ʤOM~ģcvFЄK zCG)OD\PBW#"Lŀeg|S/zB#dzzlKY4FCq(@Xz~q@T$}ȃV!նpdg'JG H%- imj*ai?<8|cͷpYM`1~.78?={P[ h1Nr^<gmC1ĘPۖ fR'=wV\y~[T9"bO^N &mBܰH1R[{D ʶE1.ZsBE9y"alzgbXe۪vIZ.?QnsFzZÄ_Q.-vCfgwEv<1 b ip$Rdif'o1y[:^sa(>s|+}]x~ !*hl倜iY ؄z:V3<uT:q O/>,"]GYd} N^ U +Dڭ:"ü lސFŷkAaֈG-ދaԁ]yKcMIaV9G c|#u371![ 27A\bjDM >g"m^p+%8lX%!ySKcA84{wC!}tXz>!fmiKw8;pp,žñ3w8w8phTc\{U0հ#OB^}6{j8p&%?sktW?eintn8}`3ǎ bzP.Pedk.\$ K<{qztS`n/&'NN OeNdN89>4qfV !TU}І]3J~.c؍:dAS?nR'RL0=I^xΣ;5|iǡPEbdEyc\@^I~޾fUwӕe5J]<7> xw4Z-#Zu$# ܄FZ&chi-XH&0)KI-}3I/5]XwVQ+{-B;n3bf<%WkZтF}fu6j9Vؗ?5z1oU9&}h: ~r}Jt^[|b-^9)+B'v &ue=$g5;;7Qh|/:C>3>:JSmz0Dr"/;uY] nac-f'A靂Nct-fvԝ-Z[V7 +1:cIz/fK%o-; im/Aæӳ1&{iehqH䚡z}w.د)Fmxrcు ,5d\+[.cIMl$"S]΍RąVJH?:n+goZ+{Xkj9?vɳ٪ڢ屩lȤjoK M|܆  @V ݊ʹiy+6VWڣ^G3!eS!y<~Oa>߽µuHp"4  LfVR!"-52w |,Lo5P*D\ve}LʤJZeJ뜞:O[^N25K!S79`ݫE{b=ʺf [7иuQٹIDTsM생bWejz~a%E."448sgСcWV՚:LZuVX۪ٖT+_U-] \~ HY@HhY,\ԭ"h VܒS->kݱK K#μ\oȣEd8Rl'aʥ]@Aq-_*KN x Q7)Bhubeݓ.LOL.λ-þήԫ5k^[f< O2c]띇'쨜x|I=dž 9V#꥚aR:UK8)ElWJC%e(J4::0:YfV˾³z&Ґa_o#YONd(~FE&R'R\Jbɰ酉Yk`)3z89616d'W䰤5X6!As< %DM>(Q]:5ͽ@O{9JS sh-ծ y q/@0={ڨ]pb՚H͙Iݹz)`68 }Elf5 9>{Ӛ"bk.©zk XSj ;z/q9MUKyc7 /9PQrd&΍ Ξ$gpL3r`R-\u$g8)s]egم Ed/:/M 4(6P9laNELl]$Dp^ UH23ﮓ(eʳ+r ı yXDE6fuo3'nҹŁ#?އuZwJ@h yA C'U1>n\Y4,5`9pRn vs1|j ӖdV*=wVq/ e[K3,¹+g0p.\b'3L izpȓ4%LinadL`J9R?xaq`@F,,B%{r|%ZP'ZԐKf~WFEVuip8_>@~7(-@vfz-NNVs@lUkmy|#l|`8"Ց;7Pu:{;=pɑD>D+0OlSI,KhT"'8z9$~J!B/7}ӕà pB+!eA- [eZZW $V%^թAB X`)U+_h'3g ~z]RNhά|n`d|rۅ822xѭz!.5tf9@R };Z bfbJ֡q}4C_}&C%B]ʛ/;U{'ܵ*ZH,bc sjHzpJS&Tc3\9z)TvKbU,Jq3Qfd84l&0t ~`3QNjU N[iɯ #X x&,!..aҦ%O.e,ό|Fwy"3)qNy LJ7"#suk5Dt@ٚJ̋%kYe<.:[&}8/'̰C ]U+f&Z3,Q`^'su^2P[Z~"vfC)H,!;#Ъ t@dUš&L@Alݷ0#(GPyIs``q;F&X}Tg3WƯ j5s^ i<_4v\@zcP-oYǫ%|79])]0_!(WڴT =.$+e"hٍ*myU NAI0 E%qa[P Iۨn@mQ" 39MpD\C音^`DEؾZHZ4Ej`9`|_Tvm^:c}7h`!WQ݋RbNVGQ fSCxc0=+ǫ.N.,N^97 H{Z M$¯"#o4k5X X`RY}̻Gv̪h0Jrʉ$$hiU&Eh]H9"4z>hEpH2Epa! " &u y*=^_9O2,f'=>_8T|746?v / Fqk/bY+zznO J66'jMmoN6:ٜԫhVJg`@#ŎCw^6lǓGZ0E=4PxPRA.@C+;bIIɮ %oltAD+2zU*QɞܵȾl'ʦj_yעp=ϜhPJh"AOE`mGU(YZRsƑn2ʗn78-] bv*w5daKvqxC>??}lIgaKYͿ%dOEy+5l6OGݛZj-=4p*;_vtL.ddѾ?n75eE3Ʈ/k%-i;3 K._Ǻ'6LVUU-' *"8=UL;Ry ?nS K(*lV\XGob([Т](ׂ;،۵2BUtZq-Ƨ-4GOBka}!rpkLFKNͫ1v8N\cTL8ߍ*LpCfD- PH iםU.`JgEuw 5sTD|V."e 2G.iAjڣXWbͥz FD1Ԍq;%h8aFKݕg FМ[%>s uSIQ*񭨱GG.j;t$jTH?1I#?$aowƪ0INFcf^uH6?1:$MՃrJ5ňB^X^ڴv^XFAd=_*wK;9Y(G6BHqQxʕhm%H-@&/B#}WDH(رaUtW)i>X*a*ˀxIq=rmt0i.b LHl^ɴkWdarݢl鮱2) 7G[fvbiH3%b{9Mc]t{'!1V7{F??lҺV|Kc8)Tvxjf.Ϯw@yc*r\j[[8!E10ކe{76R0=ϧ58o@t NC;NSM#xgdS`d:e]dWb8'l'3 KҨ ng}Ʌ!a`(Af\;s+hharj8'W!T_aIƸ(H[TNa`O9dFV\~0ɗ:jVv1yAF~H"AxK]1yGn $nb7)o'fXmUV\IPu[~Zڭ2trVZB&bQY5Ⱥ4GԌ)X.[HƧX@Rw. Gtu(7d ]DQq kݷ"<{hr!eK!mRi\+ ZA|C=p=?5.,KAGQPIP( yY_#vI} j ڙ[W5! cX+v)O\/1d_:&nP6M*sQ$=@Q-1 -IP1)-mZkUG+-|DjC$ꁁB()r6AG{-)!0i^,S4> (9֯됄 6,p4}}<N g 4ObeAz)LLsxQ)f$t $٩ j,ORTR^mMsLY{/byŖSc*d8glKn亝O*昰m썅R`{aYN1)k*] .UKhNU}Du)eD<{v^&%(y˅s*EKQ¦U: &phpM'f UCx5Nl / K%ehC7Cb&aKkkZ_x0ܽ?jó3Ggo?wnt#`# Uї`=!:}K^[)8pmdW,̊¾nZCʡnH ETnG,&Li+Xo{o,}䶙\bHM~Zri&XSTqgF ?V[ @S :pQz4?Vի˗|TN[pS:skeF[tJ`a̱/9BcX^*X`]h׋]25~8>ٟW@Vrs:<S O {i} hb&-o䝧D8y7^][W U(iTn%WJq#rF5Qъ]P()o{rZzk,w~mݹFv^v_o^u^V-ƈ'+Jj[6cWv\zZ?U_<3+&P?Xdx(8sb%jQbVKkMLhC`~rDwi.y>@j |xv< ht{%HV:) QOFJVCbqԆHnۂ>9v;-8Rku_<*r}zh5>+ZϽ̑:|԰cX=S+"-YA:Vymg([؂0G+f?Z14h͇*It(ktѸq\s^yb ף|FXlygǂKQ8֏0XD!uVVc-["Y3$IWad\i,VgXݮ9=VmWUMBcM HKT|y&+kAԝxYF0 뢵sOG32锦'C>ګKMxi ^s3<;]09;19;>=pㆸҥ)}˥-%ZBrVi}4/窽{&_٬``+7 !WJ+x{Ů/- fQ]kFCҭ{dmB7,$CjZһ+7wGT f=F4; cvI-yFŴE鷬eZ*U˥"שh'tGd0F8w%w+itݍ0[_Z]g %goH}5ۤn5aP > trmӶ4gz}\ v PZcnuSj{wۛ&u6l{-mxj`SJ0T87172bM*%gUZ6òregH#>f׫-s<^޴J k[^7'Ϲ2u5(ٍҀrA[K''5;$ THkѦBSXECF1B螐Ё()tRN(&V@WW O$F?n=׫Q=Zou%]7c)a`TJ+&`H"p `ЫiP$λTÚy\{݋ܼFo=ocyʪ,-hб+:~/c2ʮ.#Y33Kn/f&=*p2A'5<:JB]G XZ Lœou߉RzQ_ON-rs/gX96l@{(3g^t?(]-˥JBd8 jY%†\UnGx5@` 6J%-4"c{diU0߰KNl7l҃ATϴPH0!F:3Īb1Dn( 0J8*%,*BF5ǘJ.%( #kW N :_BfÀgT/}K?Cg#$4I86)rd1,kp[ZY_[^6̾^F@ \N`ʢ _41T1,c"]] T>nblwhR&@,mPxǠغY[DE*5XfsԭOyw,"u"O"È+=8(":Ȅ&d ),VQů@KzS2mGˮL(&IHA |S]g,X: zCH<]A7-,'VTk=M?4: -z1ZeUld,jaICkһ*THk{ג^]\,7k4z"?8 ZsM ?4e*}ehmHnb9ԣa<0s@x +VnMv,\ŧ[Id*pnVLI(9X odd;OLK*h7ҟ;:g`Iȯc]ntӦR Pv 9k5y.kr]amѶAR7h7eM-S;.Zj}s2%|@  a+-&ư2xAlUrdLs؈&?rޚz]“%8S2WOHج,2U,mhyP7{ǾH)_B CߚKwX5FkNj[G *P k>\AѭÂ`I"K]čJuj"vbO, j] ba2 4!.IHL :H3FAZHK& SVn`[IX;!RK#`z`1eg;4TڝOg&rg'W-r NBgFtB'Zwq)i6~T5$BeݒY3m5+y1SV$ 6SbՈXX :>ؽ'uzHP fM b(Hao]+`"r*p~H9?/V]_z62x: 뎏٠^XkD<#5Y<,؏Xa׍*2F`X¼d;Vs Znk+6Yʺ8qAo:a mW : rMg}HSא29OEbzV7bYaq0(O[vo-}`uWŭ4.9B3o jmif..*g [UOҮ7jY#QoUƺQ֧6Zk>u`i:έx+3kتNO'mǹeَ#%Xf|2+TG"M}مfMka1~1JށqYi28}mal\ s.i]'5rTb s&/i4Ue/:RlI] r iAK8Ms9$JߛRw _|Оs l?ln`f̪ Fm+8&/+{@V4ٺ"ޖnfp|cjXS0z0l?Cb.E^ϰzAs2#]aTX%!6݈E7T\U\rDz;x'__G3d:-p*az?Zh@<rGdPj\--Y Hű j5U;noW#q$=OGF1|}'Ϥ<5bI1.opע-cqu## F\lWՠ%mDbZP4?|#Mc_Ad1HOǧ?A$J _6{4LWK1~jgEseVZP 6֬+Tjox|(' 2;'h7y%CV$wFͼ+ KZ7jӮ.E,~Lqd֙d%O _ZD3념B@KO)U{ʋ9Pzh۝rwԵzTagtR)bL9A@T~OlwBԠWΦ X%m"uĬ٭_Ex#3OˏDP*f2_~ J$XlX٠@B6e6jp*~2T{!-56Pk}MK Һt ܟ{ QL2%hg%_;S,%TiW*] _fl.i CDf[2m,nb;w鰯T#G:ߩ[b#}K8<_ #!k$~#RpwۭbS-MQ]:.T du.5n&/Uc߹ LyaOK"z3ק{mBMf7uz&/}csݝ,lK^=8~E鱥tg iZbi^hj `g94s]έ9NזW3ң@ M㹠X{V<|kwn_e2hg}v^!JK즼\]F R.-Y|p–HR B xjo`bMa.khsXEYwnlȂ6JDVDn1+JFW\khQ6@e-!!n;' +M-s` |'@%+1YO 1E1quϠSDt`+oP$T:N/{B01 @<>IAS\TΚ>~''+}alaE jZRf5WvWJ.Z@.W @v _ xF 4֚X 'ldns/ldns.h', lib => 'ldns', ); use 5.014002; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Perl extension for the ldns library", "AUTHOR" => "Erik Ostlyngen ", "CONFIGURE_REQUIRES" => { "Devel::CheckLib" => "0.9", "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "DNS-LDNS", "LICENSE" => "restrictive", "MIN_PERL_VERSION" => "5.014002", "NAME" => "DNS::LDNS", "PREREQ_PM" => { "AutoLoader" => 0, "Carp" => 0, "Exporter" => 0, "XSLoader" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "FindBin" => 0, "Test::Exception" => 0, "Test::More" => 0 }, "VERSION" => "0.61", "test" => { "TESTS" => "t/*.t" } ); %WriteMakefileArgs = ( %WriteMakefileArgs, LIBS => ['-lldns'], ); my %FallbackPrereqs = ( "AutoLoader" => 0, "Carp" => 0, "Exporter" => 0, "FindBin" => 0, "Test::Exception" => 0, "Test::More" => 0, "XSLoader" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); use ExtUtils::Constant; # If you edit these definitions to change the constants used by this module, # you will need to use the generated const-c.inc and const-xs.inc # files to replace their "fallback" counterparts before distributing your # changes. my @names = (qw(LDNS_AA LDNS_AD LDNS_CD LDNS_DEFAULT_EXP_TIME LDNS_DEFAULT_TTL LDNS_DNSSEC_KEYPROTO LDNS_IP4ADDRLEN LDNS_IP6ADDRLEN LDNS_KEY_REVOKE_KEY LDNS_KEY_SEP_KEY LDNS_KEY_ZONE_KEY LDNS_MAX_DOMAINLEN LDNS_MAX_KEYLEN LDNS_MAX_LABELLEN LDNS_MAX_PACKETLEN LDNS_MAX_POINTERS LDNS_MAX_RDFLEN LDNS_NSEC3_MAX_ITERATIONS LDNS_NSEC3_VARS_OPTOUT_MASK LDNS_PORT LDNS_QR LDNS_RA LDNS_RD LDNS_RDATA_FIELD_DESCRIPTORS_COMMON LDNS_RDF_SIZE_16BYTES LDNS_RDF_SIZE_6BYTES LDNS_RDF_SIZE_BYTE LDNS_RDF_SIZE_DOUBLEWORD LDNS_RDF_SIZE_WORD LDNS_RESOLV_ANCHOR LDNS_RESOLV_DEFDOMAIN LDNS_RESOLV_INET LDNS_RESOLV_INET6 LDNS_RESOLV_INETANY LDNS_RESOLV_KEYWORD LDNS_RESOLV_KEYWORDS LDNS_RESOLV_NAMESERVER LDNS_RESOLV_OPTIONS LDNS_RESOLV_RTT_INF LDNS_RESOLV_RTT_MIN LDNS_RESOLV_SEARCH LDNS_RESOLV_SORTLIST LDNS_RR_OVERHEAD LDNS_SIGNATURE_LEAVE_ADD_NEW LDNS_SIGNATURE_LEAVE_NO_ADD LDNS_SIGNATURE_REMOVE_ADD_NEW LDNS_SIGNATURE_REMOVE_NO_ADD LDNS_TC), {name=>"LDNS_CERT_ACPKIX", macro=>"1"}, {name=>"LDNS_CERT_IACPKIX", macro=>"1"}, {name=>"LDNS_CERT_IPGP", macro=>"1"}, {name=>"LDNS_CERT_IPKIX", macro=>"1"}, {name=>"LDNS_CERT_ISPKI", macro=>"1"}, {name=>"LDNS_CERT_OID", macro=>"1"}, {name=>"LDNS_CERT_PGP", macro=>"1"}, {name=>"LDNS_CERT_PKIX", macro=>"1"}, {name=>"LDNS_CERT_SPKI", macro=>"1"}, {name=>"LDNS_CERT_URI", macro=>"1"}, {name=>"LDNS_DH", macro=>"1"}, {name=>"LDNS_DSA", macro=>"1"}, {name=>"LDNS_DSA_NSEC3", macro=>"1"}, {name=>"LDNS_ECC", macro=>"1"}, {name=>"LDNS_ECC_GOST", macro=>"1"}, {name=>"LDNS_HASH_GOST", macro=>"1"}, {name=>"LDNS_PACKET_ANSWER", macro=>"1"}, {name=>"LDNS_PACKET_IQUERY", macro=>"1"}, {name=>"LDNS_PACKET_NODATA", macro=>"1"}, {name=>"LDNS_PACKET_NOTIFY", macro=>"1"}, {name=>"LDNS_PACKET_NXDOMAIN", macro=>"1"}, {name=>"LDNS_PACKET_QUERY", macro=>"1"}, {name=>"LDNS_PACKET_QUESTION", macro=>"1"}, {name=>"LDNS_PACKET_REFERRAL", macro=>"1"}, {name=>"LDNS_PACKET_STATUS", macro=>"1"}, {name=>"LDNS_PACKET_UNKNOWN", macro=>"1"}, {name=>"LDNS_PACKET_UPDATE", macro=>"1"}, {name=>"LDNS_PRIVATEDNS", macro=>"1"}, {name=>"LDNS_PRIVATEOID", macro=>"1"}, {name=>"LDNS_RCODE_FORMERR", macro=>"1"}, {name=>"LDNS_RCODE_NOERROR", macro=>"1"}, {name=>"LDNS_RCODE_NOTAUTH", macro=>"1"}, {name=>"LDNS_RCODE_NOTIMPL", macro=>"1"}, {name=>"LDNS_RCODE_NOTZONE", macro=>"1"}, {name=>"LDNS_RCODE_NXDOMAIN", macro=>"1"}, {name=>"LDNS_RCODE_NXRRSET", macro=>"1"}, {name=>"LDNS_RCODE_REFUSED", macro=>"1"}, {name=>"LDNS_RCODE_SERVFAIL", macro=>"1"}, {name=>"LDNS_RCODE_YXDOMAIN", macro=>"1"}, {name=>"LDNS_RCODE_YXRRSET", macro=>"1"}, {name=>"LDNS_RDF_TYPE_A", macro=>"1"}, {name=>"LDNS_RDF_TYPE_AAAA", macro=>"1"}, {name=>"LDNS_RDF_TYPE_ALG", macro=>"1"}, {name=>"LDNS_RDF_TYPE_APL", macro=>"1"}, {name=>"LDNS_RDF_TYPE_ATMA", macro=>"1"}, {name=>"LDNS_RDF_TYPE_B32_EXT", macro=>"1"}, {name=>"LDNS_RDF_TYPE_B64", macro=>"1"}, {name=>"LDNS_RDF_TYPE_CERT_ALG", macro=>"1"}, {name=>"LDNS_RDF_TYPE_CLASS", macro=>"1"}, {name=>"LDNS_RDF_TYPE_DNAME", macro=>"1"}, {name=>"LDNS_RDF_TYPE_HEX", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT16", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT16_DATA", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT32", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT8", macro=>"1"}, {name=>"LDNS_RDF_TYPE_IPSECKEY", macro=>"1"}, {name=>"LDNS_RDF_TYPE_LOC", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NONE", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSAP", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSEC", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSEC3_NEXT_OWNER", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSEC3_SALT", macro=>"1"}, {name=>"LDNS_RDF_TYPE_PERIOD", macro=>"1"}, {name=>"LDNS_RDF_TYPE_SERVICE", macro=>"1"}, {name=>"LDNS_RDF_TYPE_STR", macro=>"1"}, {name=>"LDNS_RDF_TYPE_TIME", macro=>"1"}, {name=>"LDNS_RDF_TYPE_HIP", macro=>"1"}, {name=>"LDNS_RDF_TYPE_TSIGTIME", macro=>"1"}, {name=>"LDNS_RDF_TYPE_TYPE", macro=>"1"}, {name=>"LDNS_RDF_TYPE_UNKNOWN", macro=>"1"}, {name=>"LDNS_RDF_TYPE_WKS", macro=>"1"}, {name=>"LDNS_RR_CLASS_ANY", macro=>"1"}, {name=>"LDNS_RR_CLASS_CH", macro=>"1"}, {name=>"LDNS_RR_CLASS_COUNT", macro=>"1"}, {name=>"LDNS_RR_CLASS_FIRST", macro=>"1"}, {name=>"LDNS_RR_CLASS_HS", macro=>"1"}, {name=>"LDNS_RR_CLASS_IN", macro=>"1"}, {name=>"LDNS_RR_CLASS_LAST", macro=>"1"}, {name=>"LDNS_RR_CLASS_NONE", macro=>"1"}, {name=>"LDNS_RR_COMPRESS", macro=>"1"}, {name=>"LDNS_RR_NO_COMPRESS", macro=>"1"}, {name=>"LDNS_RR_TYPE_A", macro=>"1"}, {name=>"LDNS_RR_TYPE_A6", macro=>"1"}, {name=>"LDNS_RR_TYPE_AAAA", macro=>"1"}, {name=>"LDNS_RR_TYPE_AFSDB", macro=>"1"}, {name=>"LDNS_RR_TYPE_ANY", macro=>"1"}, {name=>"LDNS_RR_TYPE_APL", macro=>"1"}, {name=>"LDNS_RR_TYPE_ATMA", macro=>"1"}, {name=>"LDNS_RR_TYPE_AXFR", macro=>"1"}, {name=>"LDNS_RR_TYPE_CERT", macro=>"1"}, {name=>"LDNS_RR_TYPE_CNAME", macro=>"1"}, {name=>"LDNS_RR_TYPE_COUNT", macro=>"1"}, {name=>"LDNS_RR_TYPE_DHCID", macro=>"1"}, {name=>"LDNS_RR_TYPE_DLV", macro=>"1"}, {name=>"LDNS_RR_TYPE_DNAME", macro=>"1"}, {name=>"LDNS_RR_TYPE_DNSKEY", macro=>"1"}, {name=>"LDNS_RR_TYPE_DS", macro=>"1"}, {name=>"LDNS_RR_TYPE_EID", macro=>"1"}, {name=>"LDNS_RR_TYPE_FIRST", macro=>"1"}, {name=>"LDNS_RR_TYPE_GID", macro=>"1"}, {name=>"LDNS_RR_TYPE_GPOS", macro=>"1"}, {name=>"LDNS_RR_TYPE_HINFO", macro=>"1"}, {name=>"LDNS_RR_TYPE_IPSECKEY", macro=>"1"}, {name=>"LDNS_RR_TYPE_ISDN", macro=>"1"}, {name=>"LDNS_RR_TYPE_IXFR", macro=>"1"}, {name=>"LDNS_RR_TYPE_KEY", macro=>"1"}, {name=>"LDNS_RR_TYPE_KX", macro=>"1"}, {name=>"LDNS_RR_TYPE_LAST", macro=>"1"}, {name=>"LDNS_RR_TYPE_LOC", macro=>"1"}, {name=>"LDNS_RR_TYPE_MAILA", macro=>"1"}, {name=>"LDNS_RR_TYPE_MAILB", macro=>"1"}, {name=>"LDNS_RR_TYPE_MB", macro=>"1"}, {name=>"LDNS_RR_TYPE_MD", macro=>"1"}, {name=>"LDNS_RR_TYPE_MF", macro=>"1"}, {name=>"LDNS_RR_TYPE_MG", macro=>"1"}, {name=>"LDNS_RR_TYPE_MINFO", macro=>"1"}, {name=>"LDNS_RR_TYPE_MR", macro=>"1"}, {name=>"LDNS_RR_TYPE_MX", macro=>"1"}, {name=>"LDNS_RR_TYPE_NAPTR", macro=>"1"}, {name=>"LDNS_RR_TYPE_NIMLOC", macro=>"1"}, {name=>"LDNS_RR_TYPE_NS", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSAP", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSAP_PTR", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC3", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC3PARAM", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC3PARAMS", macro=>"1"}, {name=>"LDNS_RR_TYPE_NULL", macro=>"1"}, {name=>"LDNS_RR_TYPE_NXT", macro=>"1"}, {name=>"LDNS_RR_TYPE_OPT", macro=>"1"}, {name=>"LDNS_RR_TYPE_PTR", macro=>"1"}, {name=>"LDNS_RR_TYPE_PX", macro=>"1"}, {name=>"LDNS_RR_TYPE_RP", macro=>"1"}, {name=>"LDNS_RR_TYPE_RRSIG", macro=>"1"}, {name=>"LDNS_RR_TYPE_RT", macro=>"1"}, {name=>"LDNS_RR_TYPE_SIG", macro=>"1"}, {name=>"LDNS_RR_TYPE_SINK", macro=>"1"}, {name=>"LDNS_RR_TYPE_SOA", macro=>"1"}, {name=>"LDNS_RR_TYPE_SPF", macro=>"1"}, {name=>"LDNS_RR_TYPE_SRV", macro=>"1"}, {name=>"LDNS_RR_TYPE_SSHFP", macro=>"1"}, {name=>"LDNS_RR_TYPE_TALINK", macro=>"1"}, {name=>"LDNS_RR_TYPE_TSIG", macro=>"1"}, {name=>"LDNS_RR_TYPE_TXT", macro=>"1"}, {name=>"LDNS_RR_TYPE_UID", macro=>"1"}, {name=>"LDNS_RR_TYPE_UINFO", macro=>"1"}, {name=>"LDNS_RR_TYPE_UNSPEC", macro=>"1"}, {name=>"LDNS_RR_TYPE_WKS", macro=>"1"}, {name=>"LDNS_RR_TYPE_X25", macro=>"1"}, {name=>"LDNS_RSAMD5", macro=>"1"}, {name=>"LDNS_RSASHA1", macro=>"1"}, {name=>"LDNS_RSASHA1_NSEC3", macro=>"1"}, {name=>"LDNS_RSASHA256", macro=>"1"}, {name=>"LDNS_RSASHA512", macro=>"1"}, {name=>"LDNS_SECTION_ADDITIONAL", macro=>"1"}, {name=>"LDNS_SECTION_ANSWER", macro=>"1"}, {name=>"LDNS_SECTION_ANY", macro=>"1"}, {name=>"LDNS_SECTION_ANY_NOQUESTION", macro=>"1"}, {name=>"LDNS_SECTION_AUTHORITY", macro=>"1"}, {name=>"LDNS_SECTION_QUESTION", macro=>"1"}, {name=>"LDNS_SHA1", macro=>"1"}, {name=>"LDNS_SHA256", macro=>"1"}, {name=>"LDNS_SIGN_DSA", macro=>"1"}, {name=>"LDNS_SIGN_DSA_NSEC3", macro=>"1"}, {name=>"LDNS_SIGN_ECC_GOST", macro=>"1"}, {name=>"LDNS_SIGN_HMACSHA1", macro=>"1"}, {name=>"LDNS_SIGN_HMACSHA256", macro=>"1"}, {name=>"LDNS_SIGN_RSAMD5", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA1", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA1_NSEC3", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA256", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA512", macro=>"1"}, {name=>"LDNS_STATUS_ADDRESS_ERR", macro=>"1"}, {name=>"LDNS_STATUS_CERT_BAD_ALGORITHM", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_BOGUS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_DNSKEY", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_DS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_RRSIG", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_TRUSTED_DS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_SIG_EXPIRED", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_TSIG_BOGUS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_TSIG_ERR", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_UNKNOWN_ALGO", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_VALIDATED", macro=>"1"}, {name=>"LDNS_STATUS_DDD_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_EXISTENCE_DENIED", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED", macro=>"1"}, {name=>"LDNS_STATUS_DOMAINNAME_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_DOMAINNAME_UNDERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_EMPTY_LABEL", macro=>"1"}, {name=>"LDNS_STATUS_ENGINE_KEY_NOT_LOADED", macro=>"1"}, {name=>"LDNS_STATUS_ERR", macro=>"1"}, {name=>"LDNS_STATUS_FILE_ERR", macro=>"1"}, {name=>"LDNS_STATUS_INTERNAL_ERR", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_B32_EXT", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_B64", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_HEX", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_INT", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_IP4", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_IP6", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_POINTER", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_STR", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_TIME", macro=>"1"}, {name=>"LDNS_STATUS_LABEL_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_MEM_ERR", macro=>"1"}, {name=>"LDNS_STATUS_MISSING_RDATA_FIELDS_KEY", macro=>"1"}, {name=>"LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG", macro=>"1"}, {name=>"LDNS_STATUS_NETWORK_ERR", macro=>"1"}, {name=>"LDNS_STATUS_NOT_IMPL", macro=>"1"}, {name=>"LDNS_STATUS_NO_DATA", macro=>"1"}, {name=>"LDNS_STATUS_NSEC3_ERR", macro=>"1"}, {name=>"LDNS_STATUS_NULL", macro=>"1"}, {name=>"LDNS_STATUS_OK", macro=>"1"}, {name=>"LDNS_STATUS_PACKET_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_RES_NO_NS", macro=>"1"}, {name=>"LDNS_STATUS_RES_QUERY", macro=>"1"}, {name=>"LDNS_STATUS_SOCKET_ERROR", macro=>"1"}, {name=>"LDNS_STATUS_SSL_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ALG_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_BAD_ESCAPE", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_CLASS_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_DNAME_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_EMPTY", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_INCLUDE", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_KEYWORD_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ORIGIN", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_RDATA_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_TTL", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_TTL_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_TYPE_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_VERSION_ERR", macro=>"1"}, {name=>"LDNS_STATUS_UNKNOWN_INET", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_ANSWER", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_HEADER", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_QUESTION", macro=>"1"}); ExtUtils::Constant::WriteConstants( NAME => 'LDNS', NAMES => \@names, DEFAULT_TYPE => 'IV', C_FILE => 'const-c.inc', XS_FILE => 'const-xs.inc', ); ldns-1.9.2/contrib/DNS-LDNS/META.yml0000644000175000017500000000125715212267527016140 0ustar willemwillem--- abstract: 'Perl extension for the ldns library' author: - 'Erik Ostlyngen ' build_requires: FindBin: '0' Test::Exception: '0' Test::More: '0' configure_requires: Devel::CheckLib: '0.9' ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010' license: restrictive meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DNS-LDNS requires: AutoLoader: '0' Carp: '0' Exporter: '0' XSLoader: '0' perl: '5.014002' strict: '0' warnings: '0' version: '0.61' x_generated_by_perl: v5.38.2 x_serialization_backend: 'YAML::Tiny version 1.74' ldns-1.9.2/contrib/DNS-LDNS/README0000644000175000017500000000152015212267527015540 0ustar willemwillemDNS::LDNS version 0.61 ====================== DESCRIPTION DNS::LDNS is a perl OO-wrapper for the ldns library. For a detailed description on how this library works, you are advised to read the ldns documentation. For a functional description of the wrapper classes, please read the perldoc for DNS::LDNS and subclasses. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: ldns AUTHOR Erik Pihl Ostlyngen, erik.ostlyngen@uninett.no COPYRIGHT AND LICENCE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. ldns-1.9.2/contrib/DNS-LDNS/t/0000775000175000017500000000000015212267527015127 5ustar willemwillemldns-1.9.2/contrib/DNS-LDNS/t/rdata.t0000644000175000017500000000357415212267527016416 0ustar willemwillemuse Test::More tests => 18; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; # Integer data my $i = new DNS::LDNS::RData(LDNS_RDF_TYPE_INT32, '1237654'); is($i->to_string, '1237654', 'Integer value rdata'); my $ii = new DNS::LDNS::RData(LDNS_RDF_TYPE_INT32, '1237654X'); is($ii, undef, '1237654X is invalid'); # Period data my $p1 = new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '3h3m3s'); is($p1->to_string, sprintf("%d", 3600*3 + 60*3 + 3), 'Normalizing period'); my $pi = new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '3h3X3s'); is($pi, undef, 'Invalid period value 3h3X3s'); # DNames my $dn1 = new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'azone.org'); my $dn2 = new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'other.org'); my $dn3 = new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'sub.other.org'); my $dn4 = new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'adder.org'); $dn1->cat($dn2); is($dn1->to_string, 'azone.org.other.org.', 'Concatenating two domain names'); my $chopped = $dn1->left_chop; is($chopped->to_string, 'org.other.org.', 'Chop off left domain name label'); ok($dn3->is_subdomain($dn2), 'sub.other.org is subdomain of other.org'); ok(!$dn2->is_subdomain($dn3), 'other.org is not subdomain of sub.other.org'); is($dn3->label_count, 3, 'sub.other.org has 3 labels'); is($dn3->label(1)->to_string, 'other.', 'label 1 of sub.other.org is other.'); my $dni = new DNS::LDNS::RData( LDNS_RDF_TYPE_DNAME, 'not..valid.org'); is($dni, undef, 'Invalid dname not_valid.org'); my $wc = new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, '*.other.org'); ok($wc->is_wildcard, '*.other.org is a wildcard'); ok(!$dn3->is_wildcard, 'sub.other.org is not a wildcard'); ok($dn3->matches_wildcard($wc), 'sub.other.org matches *.other.org'); ok(!$dn4->matches_wildcard($wc), 'adder.org does not match *.other.org'); is($dn3->compare($dn4), 1, 'sub.other.org > adder.org'); is($dn4->compare($dn3), -1, 'adder.org < sub.other.org'); ldns-1.9.2/contrib/DNS-LDNS/t/resolver.t0000644000175000017500000000102415212267527017150 0ustar willemwillemuse Test::More tests => 3; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; my $r = new DNS::LDNS::Resolver(filename => "/etc/resolv.conf"); $r->set_random(0); my $p = $r->query( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'org'), LDNS_RR_TYPE_SOA, LDNS_RR_CLASS_IN, LDNS_RD); isa_ok($p, 'DNS::LDNS::Packet', 'Make a simple query'); my $r2 = new DNS::LDNS::Resolver(filename => "$Bin/testdata/resolv.conf"); $r2->set_rtt(2, 3); my @rtt = $r2->rtt; is_deeply(\@rtt, [2, 3], "set_rtt and rtt"); ldns-1.9.2/contrib/DNS-LDNS/t/dnssec_datachain.t0000644000175000017500000000332515212267527020570 0ustar willemwillemuse Test::More tests => 10; use Test::Exception; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; # Note: This test makes queries on real internet dns data, and assumes # that the iis.se domain is signed. my $r = new DNS::LDNS::Resolver(filename => "/etc/resolv.conf"); $r->set_dnssec(1); $r->set_random(0); my $p = $r->query( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'iis.se.'), LDNS_RR_TYPE_SOA, LDNS_RR_CLASS_IN, LDNS_RD); SKIP: { skip "Resolver is not dnssec able. Skip this test.", 9 unless ($p->ad); isa_ok($p, 'DNS::LDNS::Packet'); my $rrset = $p->rr_list_by_type(LDNS_RR_TYPE_SOA, LDNS_SECTION_ANSWER); ok($rrset->rr_count > 0, 'Got an answer with some content'); my $chain = $r->build_data_chain(LDNS_RD, $rrset, $p, undef); isa_ok($chain, 'DNS::LDNS::DNSSecDataChain'); isa_ok($chain->parent, 'DNS::LDNS::DNSSecDataChain'); dies_ok { my $new_rr = new DNS::LDNS::RR(str => 'test.test. 1234 IN A 10.0.0.1'); my $t = $chain->derive_trust_tree($new_rr); } 'Making a trust tree with foreign rr fails.'; my $rr = $chain->rrset->rr(0); my $tree = $chain->derive_trust_tree($rr); isa_ok($tree, 'DNS::LDNS::DNSSecTrustTree'); # Get root keys. my $root_keys_pk = $r->query( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, '.'), LDNS_RR_TYPE_DNSKEY, LDNS_RR_CLASS_IN, LDNS_RD); my $root_keys = $root_keys_pk->rr_list_by_type( LDNS_RR_TYPE_DNSKEY, LDNS_SECTION_ANSWER); is($tree->contains_keys($root_keys), LDNS_STATUS_OK, 'Root key found in trust chain'); ok($tree->depth > 1, 'The trust tree is more than one node.'); isa_ok($tree->parent(0), 'DNS::LDNS::DNSSecTrustTree'); } ldns-1.9.2/contrib/DNS-LDNS/t/rr.t0000644000175000017500000000554715212267527015750 0ustar willemwillemuse Test::More tests => 19; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; my $rr1 = new DNS::LDNS::RR; isa_ok($rr1, 'DNS::LDNS::RR', 'Create empty rr'); $rr1 = new DNS::LDNS::RR( type => LDNS_RR_TYPE_SOA, class => LDNS_RR_CLASS_CH, ttl => 1234, owner => 'myzone.org', rdata => [ new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'hostmaster.myzone.org'), new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'master.myzone.org'), new DNS::LDNS::RData(LDNS_RDF_TYPE_INT32, '2012113030'), new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '12345'), new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '1827'), new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '2345678'), new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '87654') ], ); isa_ok($rr1, 'DNS::LDNS::RR', 'Create SOA rr with rdata'); like($rr1->to_string, qr/^myzone\.org\.\s+1234\s+CH\s+SOA\s+hostmaster\.myzone\.org\.\s+master\.myzone\.org\.\s+2012113030\s+12345\s+1827\s+2345678\s+87654$/, 'Format SOA rr as string'); is($rr1->pop_rdata->to_string, '87654', 'pop rdata'); $rr1->push_rdata(new DNS::LDNS::RData(LDNS_RDF_TYPE_PERIOD, '55667')); is($rr1->rdata(6)->to_string, '55667', 'push_rdata and access rdata by index'); my $rr2 = new DNS::LDNS::RR(str => 'myzone.org. 1234 IN SOA hostmaster.myzone.org. master.myzone.org. 2012 12345 1827 2345678 87654'); isa_ok($rr2, 'DNS::LDNS::RR', 'Create SOA rr from string'); like($rr2->to_string, qr/^myzone\.org\.\s+1234\s+IN\s+SOA\s+hostmaster\.myzone\.org\.\s+master\.myzone\.org\.\s+2012\s+12345\s+1827\s+2345678\s+87654$/, 'Format it back to string'); ok($rr1->compare($rr2) > 0, 'Compare rr, greater than'); ok($rr2->compare($rr1) < 0, 'Compare rr, less than'); is($rr1->compare($rr1), 0, 'Compare rr, equal'); my $rr3 = new DNS::LDNS::RR(str => 'ozone.org. 1234 IN SOA hostmaster.ozone.org. master.ozone.org. 2012 12345 1827 2345678 87654'); ok($rr3->compare_dname($rr1) > 0, 'Compare dname, greater than'); ok($rr1->compare_dname($rr3) < 0, 'Compare dname, less than'); is($rr1->compare_dname($rr2), 0, 'Compare dname, equal'); # Read records from a zonefile my $origin = new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, '.'); my $prev = $origin->clone; my $ttl = 0; my $count = 0; open(ZONE, "$Bin/testdata/myzone.org"); my $rr4 = new DNS::LDNS::RR(file => \*ZONE, default_ttl => \$ttl, origin => \$origin, prev => \$prev); is($DNS::LDNS::last_status, LDNS_STATUS_SYNTAX_TTL, "Read ttl statement."); is($ttl, 4500, "TTL is 4500"); $rr4 = new DNS::LDNS::RR(file => \*ZONE, default_ttl => \$ttl, origin => \$origin, prev => \$prev); is($DNS::LDNS::last_status, LDNS_STATUS_SYNTAX_ORIGIN, "Read origin statement."); is($origin->to_string, "myzone.org.", "Origin is myzone.org."); while (!eof(\*ZONE)) { $rr4 = new DNS::LDNS::RR(file => \*ZONE, default_ttl => \$ttl, origin => \$origin, prev => \$prev); last unless ($rr4); $count++; } is($count, 6); ldns-1.9.2/contrib/DNS-LDNS/t/DNS-LDNS.t0000644000175000017500000001552515212267527016504 0ustar willemwillem# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl DNS-LDNS.t' ######################### # change 'tests => 2' to 'tests => last_test_to_print'; use strict; use warnings; use Test::More tests => 2; BEGIN { use_ok('DNS::LDNS') }; my $fail = 0; foreach my $constname (qw( LDNS_AA LDNS_AD LDNS_CD LDNS_CERT_ACPKIX LDNS_CERT_IACPKIX LDNS_CERT_IPGP LDNS_CERT_IPKIX LDNS_CERT_ISPKI LDNS_CERT_OID LDNS_CERT_PGP LDNS_CERT_PKIX LDNS_CERT_SPKI LDNS_CERT_URI LDNS_DEFAULT_TTL LDNS_DH LDNS_DSA LDNS_DSA_NSEC3 LDNS_ECC LDNS_ECC_GOST LDNS_HASH_GOST LDNS_IP4ADDRLEN LDNS_IP6ADDRLEN LDNS_KEY_REVOKE_KEY LDNS_KEY_SEP_KEY LDNS_KEY_ZONE_KEY LDNS_MAX_DOMAINLEN LDNS_MAX_LABELLEN LDNS_MAX_PACKETLEN LDNS_MAX_POINTERS LDNS_MAX_RDFLEN LDNS_NSEC3_VARS_OPTOUT_MASK LDNS_PACKET_ANSWER LDNS_PACKET_IQUERY LDNS_PACKET_NODATA LDNS_PACKET_NOTIFY LDNS_PACKET_NXDOMAIN LDNS_PACKET_QUERY LDNS_PACKET_QUESTION LDNS_PACKET_REFERRAL LDNS_PACKET_STATUS LDNS_PACKET_UNKNOWN LDNS_PACKET_UPDATE LDNS_PORT LDNS_PRIVATEDNS LDNS_PRIVATEOID LDNS_QR LDNS_RA LDNS_RCODE_FORMERR LDNS_RCODE_NOERROR LDNS_RCODE_NOTAUTH LDNS_RCODE_NOTIMPL LDNS_RCODE_NOTZONE LDNS_RCODE_NXDOMAIN LDNS_RCODE_NXRRSET LDNS_RCODE_REFUSED LDNS_RCODE_SERVFAIL LDNS_RCODE_YXDOMAIN LDNS_RCODE_YXRRSET LDNS_RD LDNS_RDATA_FIELD_DESCRIPTORS_COMMON LDNS_RDF_SIZE_16BYTES LDNS_RDF_SIZE_6BYTES LDNS_RDF_SIZE_BYTE LDNS_RDF_SIZE_DOUBLEWORD LDNS_RDF_SIZE_WORD LDNS_RDF_TYPE_A LDNS_RDF_TYPE_AAAA LDNS_RDF_TYPE_ALG LDNS_RDF_TYPE_APL LDNS_RDF_TYPE_ATMA LDNS_RDF_TYPE_B32_EXT LDNS_RDF_TYPE_B64 LDNS_RDF_TYPE_CERT_ALG LDNS_RDF_TYPE_CLASS LDNS_RDF_TYPE_DNAME LDNS_RDF_TYPE_HEX LDNS_RDF_TYPE_INT16 LDNS_RDF_TYPE_INT16_DATA LDNS_RDF_TYPE_INT32 LDNS_RDF_TYPE_INT8 LDNS_RDF_TYPE_IPSECKEY LDNS_RDF_TYPE_LOC LDNS_RDF_TYPE_NONE LDNS_RDF_TYPE_NSAP LDNS_RDF_TYPE_NSEC LDNS_RDF_TYPE_NSEC3_NEXT_OWNER LDNS_RDF_TYPE_NSEC3_SALT LDNS_RDF_TYPE_PERIOD LDNS_RDF_TYPE_SERVICE LDNS_RDF_TYPE_STR LDNS_RDF_TYPE_TIME LDNS_RDF_TYPE_HIP LDNS_RDF_TYPE_TSIGTIME LDNS_RDF_TYPE_TYPE LDNS_RDF_TYPE_UNKNOWN LDNS_RDF_TYPE_WKS LDNS_RESOLV_ANCHOR LDNS_RESOLV_DEFDOMAIN LDNS_RESOLV_INET LDNS_RESOLV_INET6 LDNS_RESOLV_INETANY LDNS_RESOLV_KEYWORD LDNS_RESOLV_KEYWORDS LDNS_RESOLV_NAMESERVER LDNS_RESOLV_OPTIONS LDNS_RESOLV_RTT_INF LDNS_RESOLV_RTT_MIN LDNS_RESOLV_SEARCH LDNS_RESOLV_SORTLIST LDNS_RR_CLASS_ANY LDNS_RR_CLASS_CH LDNS_RR_CLASS_COUNT LDNS_RR_CLASS_FIRST LDNS_RR_CLASS_HS LDNS_RR_CLASS_IN LDNS_RR_CLASS_LAST LDNS_RR_CLASS_NONE LDNS_RR_COMPRESS LDNS_RR_NO_COMPRESS LDNS_RR_OVERHEAD LDNS_RR_TYPE_A LDNS_RR_TYPE_A6 LDNS_RR_TYPE_AAAA LDNS_RR_TYPE_AFSDB LDNS_RR_TYPE_ANY LDNS_RR_TYPE_APL LDNS_RR_TYPE_ATMA LDNS_RR_TYPE_AXFR LDNS_RR_TYPE_CERT LDNS_RR_TYPE_CNAME LDNS_RR_TYPE_COUNT LDNS_RR_TYPE_DHCID LDNS_RR_TYPE_DLV LDNS_RR_TYPE_DNAME LDNS_RR_TYPE_DNSKEY LDNS_RR_TYPE_DS LDNS_RR_TYPE_EID LDNS_RR_TYPE_FIRST LDNS_RR_TYPE_GID LDNS_RR_TYPE_GPOS LDNS_RR_TYPE_HINFO LDNS_RR_TYPE_IPSECKEY LDNS_RR_TYPE_ISDN LDNS_RR_TYPE_IXFR LDNS_RR_TYPE_KEY LDNS_RR_TYPE_KX LDNS_RR_TYPE_LAST LDNS_RR_TYPE_LOC LDNS_RR_TYPE_MAILA LDNS_RR_TYPE_MAILB LDNS_RR_TYPE_MB LDNS_RR_TYPE_MD LDNS_RR_TYPE_MF LDNS_RR_TYPE_MG LDNS_RR_TYPE_MINFO LDNS_RR_TYPE_MR LDNS_RR_TYPE_MX LDNS_RR_TYPE_NAPTR LDNS_RR_TYPE_NIMLOC LDNS_RR_TYPE_NS LDNS_RR_TYPE_NSAP LDNS_RR_TYPE_NSAP_PTR LDNS_RR_TYPE_NSEC LDNS_RR_TYPE_NSEC3 LDNS_RR_TYPE_NSEC3PARAM LDNS_RR_TYPE_NSEC3PARAMS LDNS_RR_TYPE_NULL LDNS_RR_TYPE_NXT LDNS_RR_TYPE_OPT LDNS_RR_TYPE_PTR LDNS_RR_TYPE_PX LDNS_RR_TYPE_RP LDNS_RR_TYPE_RRSIG LDNS_RR_TYPE_RT LDNS_RR_TYPE_SIG LDNS_RR_TYPE_SINK LDNS_RR_TYPE_SOA LDNS_RR_TYPE_SPF LDNS_RR_TYPE_SRV LDNS_RR_TYPE_SSHFP LDNS_RR_TYPE_TALINK LDNS_RR_TYPE_TSIG LDNS_RR_TYPE_TXT LDNS_RR_TYPE_UID LDNS_RR_TYPE_UINFO LDNS_RR_TYPE_UNSPEC LDNS_RR_TYPE_WKS LDNS_RR_TYPE_X25 LDNS_RSAMD5 LDNS_RSASHA1 LDNS_RSASHA1_NSEC3 LDNS_RSASHA256 LDNS_RSASHA512 LDNS_SECTION_ADDITIONAL LDNS_SECTION_ANSWER LDNS_SECTION_ANY LDNS_SECTION_ANY_NOQUESTION LDNS_SECTION_AUTHORITY LDNS_SECTION_QUESTION LDNS_SHA1 LDNS_SHA256 LDNS_SIGN_DSA LDNS_SIGN_DSA_NSEC3 LDNS_SIGN_ECC_GOST LDNS_SIGN_HMACSHA1 LDNS_SIGN_HMACSHA256 LDNS_SIGN_RSAMD5 LDNS_SIGN_RSASHA1 LDNS_SIGN_RSASHA1_NSEC3 LDNS_SIGN_RSASHA256 LDNS_SIGN_RSASHA512 LDNS_STATUS_ADDRESS_ERR LDNS_STATUS_CERT_BAD_ALGORITHM LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL LDNS_STATUS_CRYPTO_BOGUS LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION LDNS_STATUS_CRYPTO_NO_DNSKEY LDNS_STATUS_CRYPTO_NO_DS LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY LDNS_STATUS_CRYPTO_NO_RRSIG LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY LDNS_STATUS_CRYPTO_NO_TRUSTED_DS LDNS_STATUS_CRYPTO_SIG_EXPIRED LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED LDNS_STATUS_CRYPTO_TSIG_BOGUS LDNS_STATUS_CRYPTO_TSIG_ERR LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR LDNS_STATUS_CRYPTO_UNKNOWN_ALGO LDNS_STATUS_CRYPTO_VALIDATED LDNS_STATUS_DDD_OVERFLOW LDNS_STATUS_DNSSEC_EXISTENCE_DENIED LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED LDNS_STATUS_DOMAINNAME_OVERFLOW LDNS_STATUS_DOMAINNAME_UNDERFLOW LDNS_STATUS_EMPTY_LABEL LDNS_STATUS_ENGINE_KEY_NOT_LOADED LDNS_STATUS_ERR LDNS_STATUS_FILE_ERR LDNS_STATUS_INTERNAL_ERR LDNS_STATUS_INVALID_B32_EXT LDNS_STATUS_INVALID_B64 LDNS_STATUS_INVALID_HEX LDNS_STATUS_INVALID_INT LDNS_STATUS_INVALID_IP4 LDNS_STATUS_INVALID_IP6 LDNS_STATUS_INVALID_POINTER LDNS_STATUS_INVALID_STR LDNS_STATUS_INVALID_TIME LDNS_STATUS_LABEL_OVERFLOW LDNS_STATUS_MEM_ERR LDNS_STATUS_MISSING_RDATA_FIELDS_KEY LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG LDNS_STATUS_NETWORK_ERR LDNS_STATUS_NOT_IMPL LDNS_STATUS_NO_DATA LDNS_STATUS_NSEC3_ERR LDNS_STATUS_NULL LDNS_STATUS_OK LDNS_STATUS_PACKET_OVERFLOW LDNS_STATUS_RES_NO_NS LDNS_STATUS_RES_QUERY LDNS_STATUS_SOCKET_ERROR LDNS_STATUS_SSL_ERR LDNS_STATUS_SYNTAX_ALG_ERR LDNS_STATUS_SYNTAX_BAD_ESCAPE LDNS_STATUS_SYNTAX_CLASS_ERR LDNS_STATUS_SYNTAX_DNAME_ERR LDNS_STATUS_SYNTAX_EMPTY LDNS_STATUS_SYNTAX_ERR LDNS_STATUS_SYNTAX_INCLUDE LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW LDNS_STATUS_SYNTAX_KEYWORD_ERR LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR LDNS_STATUS_SYNTAX_ORIGIN LDNS_STATUS_SYNTAX_RDATA_ERR LDNS_STATUS_SYNTAX_TTL LDNS_STATUS_SYNTAX_TTL_ERR LDNS_STATUS_SYNTAX_TYPE_ERR LDNS_STATUS_SYNTAX_VERSION_ERR LDNS_STATUS_UNKNOWN_INET LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL LDNS_STATUS_WIRE_INCOMPLETE_ANSWER LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY LDNS_STATUS_WIRE_INCOMPLETE_HEADER LDNS_STATUS_WIRE_INCOMPLETE_QUESTION LDNS_TC)) { next if (eval "my \$a = $constname; 1"); if ($@ =~ /^Your vendor has not defined LDNS macro $constname/) { print "# pass: $@"; } else { print "# fail: $@"; $fail = 1; } } ok( $fail == 0 , 'Constants' ); ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. ldns-1.9.2/contrib/DNS-LDNS/t/dnssec_zone.t0000644000175000017500000000215115212267527017623 0ustar willemwillemuse Test::More tests => 7; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; # Create a new dnssec zone my $z = new DNS::LDNS::DNSSecZone; isa_ok($z, 'DNS::LDNS::DNSSecZone', 'Create an empty zone'); # Read a zone from file and create a dnssec zone from it my $z2 = new DNS::LDNS::Zone( filename => "$Bin/testdata/myzone.org"); $z->create_from_zone($z2); my $rrset = $z->find_rrset( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'ns1.myzone.org.'), LDNS_RR_TYPE_A); is($rrset->rrs->rr->type, LDNS_RR_TYPE_A, 'Found an A record'); is($rrset->rrs->rr->dname, 'ns1.myzone.org.', 'Dname is ns1.myzone.org.'); is($z->add_empty_nonterminals, LDNS_STATUS_OK, 'Add empty non-terminals'); my $klist = new DNS::LDNS::KeyList; $klist->push(new DNS::LDNS::Key(filename => "$Bin/testdata/key.private")); $klist->key(0)->set_pubkey_owner( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone.org')); is($z->sign($klist, LDNS_SIGNATURE_REMOVE_ADD_NEW, 0), LDNS_STATUS_OK, 'Sign'); is($z->sign_nsec3($klist, LDNS_SIGNATURE_REMOVE_ADD_NEW, 1, 0, 10, 'ABBA', 0), LDNS_STATUS_OK, 'Sign nsec3'); ldns-1.9.2/contrib/DNS-LDNS/t/rrlist.t0000644000175000017500000001042415212267527016632 0ustar willemwillemuse Test::More tests => 24; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; # Create list my $list = new DNS::LDNS::RRList; isa_ok($list, 'DNS::LDNS::RRList', 'Create an empty rr list'); # Push/pop/count rr $list->push(new DNS::LDNS::RR(str => 'ns.myzone.org 3600 IN AAAA ::1')); is($list->rr_count, 1, 'Added one rr'); like($list->rr(0)->to_string, qr/^ns\.myzone\.org\.\s+3600\s+IN\s+AAAA\s+::1$/, 'Added rr is at position 0'); $list->push(new DNS::LDNS::RR(str => 'ns.myzone.org 7200 IN A 192.168.100.2')); is($list->rr_count, 2, 'Added another rr'); like($list->rr(1)->to_string, qr/^ns\.myzone\.org\.\s+7200\s+IN\s+A\s+192\.168\.100\.2$/, 'Last added rr is at position 1'); like($list->pop->to_string, qr/^ns\.myzone\.org\.\s+7200\s+IN\s+A\s+192\.168\.100\.2$/, 'pop the last element'); is($list->rr_count, 1, '1 element left in the list'); # Push/pop list my $l2 = new DNS::LDNS::RRList; $l2->push(new DNS::LDNS::RR(str => 'ns2.myzone.org 3600 IN A 192.168.100.0')); $l2->push(new DNS::LDNS::RR(str => 'ns2.myzone.org 3600 IN A 192.168.100.1')); $list->push_list($l2); is($list->rr_count, 3, 'Pushed two elements. List count is now 3.'); $list->push_list($l2); $list->push_list($l2); my $l3 = $list->pop_list(1); is($list->rr_count, 6, 'Pushed 4 elements, popped 1, count is now 6'); is($l3->rr_count, 1, 'Popped list contains 1 elements'); $l3 = $list->pop_list(3); is($list->rr_count, 3, 'Popped 3 elements, count is now 3'); is($l3->rr_count, 3, 'Popped list contains 3 elements'); # RRSets ok($l2->is_rrset, 'List is rrset'); ok(!$list->is_rrset, 'List is no longer an rrset'); my $rrset = $list->pop_rrset; ok($rrset->is_rrset, 'Popped list is rrset'); is($rrset->rr_count, 2, 'Popped rrset has two elements.'); # Compare, contains, subtype my $rr = new DNS::LDNS::RR(str => 'ns2.myzone.org 3600 IN A 192.168.100.0'); ok($rrset->contains_rr($rr), 'RRSet contains rr '.$rr->to_string); is($list->compare($l2), -1, '$list < $l2'); is($l2->compare($list), 1, '$l2 > $list'); $list->push(new DNS::LDNS::RR(str => 'ns3.myzone.org 3600 IN A 192.168.100.0'), new DNS::LDNS::RR(str => 'ns3.myzone.org 3600 IN A 192.168.100.1'), new DNS::LDNS::RR(str => 'ns4.myzone.org 3600 IN A 192.168.100.1')); my $subtype = $list->subtype_by_rdata( new DNS::LDNS::RData(LDNS_RDF_TYPE_A, '192.168.100.1'), 0); is($subtype->to_string, "ns3.myzone.org.\t3600\tIN\tA\t192.168.100.1\nns4.myzone.org.\t3600\tIN\tA\t192.168.100.1\n", 'Filter rrs by rdata'); # DNSSec signature verification my $keylist = new DNS::LDNS::RRList; $keylist->push( new DNS::LDNS::RR(str => 'trondheim.no. 3600 IN DNSKEY 256 3 8 AwEAAZIDdRI8I+F/J6OT8xX7CbGQYRr8rWH9dvloUlRJXcEVE2pRAez6 pJC5Odg+i2WvDUeE4tUO1gwwjU83TIinZxxsDnqr7FzvqpHeJbVd2N3d S4zaJcbjSnwMqdebmTEXSrflp8DeIAH0GQGNQjhOPubbb/nADYP2RS1i CoOADa8P'), new DNS::LDNS::RR(str => 'trondheim.no. 3600 IN DNSKEY 257 3 8 AwEAAax9EgKyRsMpU2B0E2dZ+nkWnmZHjlBO3uXBI+2x33dG8bk+XSqr kyWTelhhsqLqIxsaYSwYgzLtn+/qzlFjKwcaU95p+Tp95MOVXYqUtRyC VyLGkzA7ZDbx7TFCi3PyLDM/Arx+DvOx6nNvA/erqIU5gYEo9Nm1KXEy rhfSn3xc96p1AOhmTuSo6EfYlPY4gxHDgJdHFv7Fi9zV6VFmJ29h0rsG 5g3pV1lvCcGcxfRLJ1u7JRw2BWMo9lgHzGuypEVV7iLnvbfDlXhF+jAS owR2JxlESC3dOgNiNWvc4pbyVXBXpP6h/5JpcxkzF7BNJMZiLN14qvam G1+LuZM8qfc=') ); my $soalist = new DNS::LDNS::RRList; $soalist->push( new DNS::LDNS::RR(str => 'trondheim.no. 3600 IN SOA charm.norid.no. hostmaster.norid.no. 2013021137 14400 1800 2419200 3600') ); my $siglist = new DNS::LDNS::RRList; $siglist->push( new DNS::LDNS::RR(str => 'trondheim.no. 3600 IN RRSIG SOA 8 2 3600 20130227105101 20130213090318 36381 trondheim.no. NbeN8E4pvQSDk3Dn0i8B4e2A3KAY8JrX+zcJazPTgHbT6wjzCncn3ANn 6rs+HdcCLtptyX1QbzlZD/lOY8kjJw5TEUoFX2Q/2sBYdt1aT6qgt/+H o71iUz3bk1V73zjSG/OpqG0oXmjCWSBZgzK6UI+zGlgG0Kvrc7H1pw5S ZBA=') ); my ($status, $goodkeys) = $soalist->verify_notime($siglist, $keylist); is ($status, LDNS_STATUS_OK, 'Verification returned status ok.'); is ($goodkeys->rr_count, 1, 'One key matched the signature.'); my $klist = new DNS::LDNS::KeyList; $klist->push(new DNS::LDNS::Key(filename => "$Bin/testdata/key.private")); $klist->key(0)->set_pubkey_owner( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone.org')); my $sigs = $l2->sign_public($klist); is($sigs->rr_count, 1, 'Sign public, got 1 rrsig'); ldns-1.9.2/contrib/DNS-LDNS/t/key.t0000644000175000017500000000162015212267527016101 0ustar willemwillemuse Test::More tests => 8; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; my $key = new DNS::LDNS::Key(filename => "$Bin/testdata/key.private"); ok($key, 'Created new key object from file'); is($key->algorithm, 7, 'Algorithm is NSEC3RSASHA1'); my $now = time; $key->set_inception($now); $key->set_expiration($now + 10000); is($key->inception, $now, 'Inception time'); is($key->expiration, $now + 10000, 'Expiration time'); like($key->to_rr->to_string, qr|3600\s+IN\s+DNSKEY\s+256\s+3\s+7\s+AwEAAfg/ghOkk|, 'Got rr representation of key'); my $klist = new DNS::LDNS::KeyList; $klist->push($key); is($klist->count, 1, 'Keylist has one key'); is($$key, ${$klist->key(0)}, 'Key in keylist is the one we pushed'); # FIXME: pop is buggy in ldns 1.6.12, uncomment when this starts working # is($klist->pop(), $$key, 'Pop key from list'); # is($klist->count, 0, 'No keys left in list'); ldns-1.9.2/contrib/DNS-LDNS/t/zone.t0000644000175000017500000000531715212267527016273 0ustar willemwillemuse Test::More tests => 16; use FindBin qw/$Bin/; use DNS::LDNS ':all'; BEGIN { use_ok('DNS::LDNS') }; # Create a new zone my $z = new DNS::LDNS::Zone; isa_ok($z, 'DNS::LDNS::Zone', 'Create an empty zone'); # Fill inn a soa and some rrs $z->set_soa(new DNS::LDNS::RR(str => join(' ', qw/myzone.org 1000 IN SOA hostmaster.myzone.org. master.myzone.org. 2012113030 12345 1827 2345678 87654/))); is($z->soa->dname, 'myzone.org.', 'Found soa record'); my $rrs = new DNS::LDNS::RRList; $rrs->push(new DNS::LDNS::RR(str => 'ns2.myzone.org 3600 IN A 192.168.100.2'), new DNS::LDNS::RR(str => 'ns2.myzone.org 3600 IN A 192.168.100.9'), new DNS::LDNS::RR(str => 'ns3.myzone.org 3600 IN A 192.168.100.2'), new DNS::LDNS::RR(str => 'ns1.myzone.org 3600 IN A 192.168.100.7')); $z->set_rrs($rrs); is($z->rrs->rr(0)->to_string, "ns2.myzone.org.\t3600\tIN\tA\t192.168.100.2\n", 'Check first rr'); is($z->rrs->rr(3)->to_string, "ns1.myzone.org.\t3600\tIN\tA\t192.168.100.7\n", 'Check last rr'); $z->sort; is($z->rrs->rr(0)->to_string, "ns1.myzone.org.\t3600\tIN\tA\t192.168.100.7\n", 'Check first rr after sorting'); is($z->rrs->rr(3)->to_string, "ns3.myzone.org.\t3600\tIN\tA\t192.168.100.2\n", 'Check last rr after sorting'); # Read a zone from file my $z2 = new DNS::LDNS::Zone( filename => "$Bin/testdata/myzone.org", ttl => 100); $z2->canonicalize; like($z2->to_string, qr/\nns.ldns.myzone.org.\s+/, 'Canonicalize'); like($z2->to_string, qr/^myzone.org.\s+1000\s+IN\s+SOA\s+ldns.myzone.org.\s+ns.ldns.myzone.org.\s+2012113030\s+12345\s+1827\s+2345678\s+87654\s+/, 'Found soa rec'); like($z2->to_string, qr/ns.ldns.myzone.org.\s+4500\s+IN\s+A\s+192.168.100.2/, 'Found ns rec'); like($z2->to_string, qr/ns2.myzone.org.\s+5600\s+IN\s+AAAA\s+2001:dead:dead::2/, 'Found yet another ns rec'); is($z2->rrs->rr_count, 5, 'Zone has 5 rrs'); my $klist = new DNS::LDNS::KeyList; $klist->push(new DNS::LDNS::Key(filename => "$Bin/testdata/key.private")); $klist->key(0)->set_pubkey_owner( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone.org')); my $z3 = $z2->sign($klist); my $sigc = grep { $z3->rrs->rr($_)->type == LDNS_RR_TYPE_RRSIG } (0 .. $z3->rrs->rr_count - 1); is($sigc, 10, 'Signed zone has 10 signatures'); my $nsecc = grep { $z3->rrs->rr($_)->type == LDNS_RR_TYPE_NSEC } (0 .. $z3->rrs->rr_count - 1); is($nsecc, 4, 'Signed zone has 3 nsec recs'); my $z4 = $z2->sign_nsec3($klist, 1, 0, 2, 'ABC'); my $sigc3 = grep { $z4->rrs->rr($_)->type == LDNS_RR_TYPE_RRSIG } (0 .. $z4->rrs->rr_count - 1); is($sigc3, 12, 'NSEC3-signed zone has 12 signatures'); my $nsecc3 = grep { $z4->rrs->rr($_)->type == LDNS_RR_TYPE_NSEC3 } (0 .. $z4->rrs->rr_count - 1); is($nsecc3, 5, 'NSEC3-signed zone has 5 nsec recs'); ldns-1.9.2/contrib/DNS-LDNS/t/testdata/0000775000175000017500000000000015212267527016740 5ustar willemwillemldns-1.9.2/contrib/DNS-LDNS/t/testdata/myzone.org0000644000175000017500000000051515212267527020771 0ustar willemwillem$TTL 4500 $ORIGIN myzone.org. myzone.org. 1000 IN SOA ( ldns.myzone.org. ns.ldns.myzone.org. 2012113030 12345 1827 2345678 87654 ) ns.ldns A 192.168.100.2 ns2 5600 IN AAAA 2001:dead:dead::2 ns2 6600 IN A 192.168.100.7 ns1 3600 IN A 192.168.100.2 ns1 4600 IN AAAA 2001:dead:dead::1 ldns-1.9.2/contrib/DNS-LDNS/t/testdata/resolv.conf0000644000175000017500000000010115212267527021107 0ustar willemwillemnameserver 127.0.0.1 nameserver 192.168.100.1 search foo.bar.org ldns-1.9.2/contrib/DNS-LDNS/t/testdata/key.private0000644000175000017500000000336315212267527021127 0ustar willemwillemPrivate-key-format: v1.2 Algorithm: 7 (NSEC3RSASHA1) Modulus: +D+CE6ST+vFtbnXLdNESSprWSpbpRqEyri20vOx/JIViYdflGQyT0SDWSAE0JqtRlq73qSTDNuR3KWG/57oQQQ5P/wdQaF4TXA/nGjQJPEnhwKVUPVl5WRvqJLpW3C5xSSkhUkwjCp8y6z4NkbX0x7kum9ZTyTai6hkAhjyXu56yXAHX80DWadGK7RmX4JNlJalp2O33hJmakw8BVpgM9yaN4TixVsmZyHLi4hLjMAsjkEEJnfV8WoMEyyjs4kdKDHQAIa854loRcOluT1FiBKgecVAjDu/mkxnqYedN68Yx/wi7D+eClGf/gZjsmuoKKxCxnvDkRCKxrdMJtrsduw== PublicExponent: AQAB PrivateExponent: A8m0SmhweZvFd7IEcLvf85N5QZob5SAAjffUki1poz0Fy0hoDoHKn55IpsCd8xkaHZp93O7aq7PAvbjoHLkSFmwJfHK4H1+QHA+CDzxMB8d40l+zcVw0Jc/vOrA9Mw7iW6NtBrxyrG7RcBV6T4bfPUzuESKsFJ3oznmjMGksR4iUrnYAoUgi1pCQlxhSkPM74YhNWbUxYr4gRlL2xGGcJ2qMM8KG06or/Ok+d4bxnxiDBo41THik8ptfu/DL3HrJLOJ1CrvZGy9Q3uFiCvfD9Sk+eOZz1XPkJrUDKGYGoUvZc8enStXSM+TKd3EQy5owjJt+j2h0JdYJM8pxF2EWwQ== Prime1: /5r4e+6kJS/+UJ0DMenJGm0vxfgFHvk5yLfz+1sKd6C9qQJN5da1m6kWuPdtBG7XGhZb8cJPOfK//g9hVS9GYEDyYmhYZsPTL+1vkiecDpeEQkrf4RCtU7NXLNT/AVNe01iEnIGuKbva6z19P1hjNO23d7LXHil1oULM1W8O1Z8= Prime2: +KGhJOe+dB5Ud9cFlspMIIpZKHvoDc8VUb2avnhicDX5YC8dVS3nBoyc1cBNgxi4nSvBSl8/fwNT1cHJsPj7Xp2FOAsIBITRnmQt2P5JDpTEuMkEjMT8h/gJ8WnJ0+/VQhLG6rfsSAXdXvVhP4VYttPdiQ0fAe8b5v2MH1VzamU= Exponent1: UWCEVeifR9ukywOCHeUBirFScWPKNZdBR18RhWfxyC5b07ARHuihvyIxQsg7ZBrpzrtpoGmtkZRwfbFl2poHfOOQh7YS1vzngq3ERLLpo1en2vc9mckWdbx2N6bEXSau3Pikl7NNwKm3RAe6lW1NgG9iZvCAPnESqzm6PwVxop8= Exponent2: FMsnt/dttTZoKBGilQbcMQiBBmK+eJEuHkT2MSHOUcYh0gp+sIYDQUf3QeUwVlt17ScgpkCrBctYcpMfdB6On04bOyGpDP+yrEWClBhIMeD9RtsA92juGc0Dv93yFDiFpF3/pte0+h0Lc4qgFHjpf3jemTywsC+4LKxd0K0L1wU= Coefficient: klnXksRr0Z8HPLASytPt4EeBK3Md7MM+Ihm6DIM5PA/KO9k0s8231hspcxBDj37HYwJ7eD77svUJFzdUOqIT8gChc6uq9VI9NFggs8rn4EndoEe+zU477NpL4U09LMfbAN+NATkhDWabVIQBeGqpIAR0fxFIqGhDtkiLyNqhq3c= Created: 20120614100023 Publish: 20120614100023 Activate: 20120614100023 ldns-1.9.2/contrib/DNS-LDNS/dist.ini0000644000175000017500000000052515212267527016330 0ustar willemwillemname = DNS-LDNS author = Erik Ostlyngen copyright_holder = UNINETT Norid AS copyright_year = 2013 license = None version = 0.61 [AutoPrereqs] [GatherDir] [MetaYAML] [MakeMaker::Awesome] WriteMakefile_arg = LIBS => ['-lldns'] footer_file = constants.PL [CheckLib] lib = ldns header = ldns/ldns.h [License] [PruneCruft] ldns-1.9.2/contrib/DNS-LDNS/Changes0000644000175000017500000000427415212267527016164 0ustar willemwillemRevision history for Perl extension DNS::LDNS. 0.01 Thu Nov 22 12:48:29 2012 - original version; created by h2xs 1.23 with options -A -n LDNS 0.02 Fri Jan 18 09:47:57 2013 - Support for DNSSec and Resolver. Added some more constants from the header files; created by h2xs 1.23 with options -n LDNS /usr/include/ldns/ldns.h /usr/include/ldns/error.h /usr/include/ldns/rr.h /usr/include/ldns/keys.h /usr/include/ldns/packet.h /usr/include/ldns/resolver.h /usr/include/ldns/rdata.h /usr/include/ldns/dnssec.h 0.03 Fri Apr 19 13:40:57 2013 - Renamed module to Net::LDNS 0.04 Fri Dec 13 14:15:26 2013 - Renamed module to DNS::LDNS 0.05 Mon Dec 30 10:14:00 2013 - Corrected versioning variable in all classes. - Cleaned up the base class documentation. 0.06 Tue Dec 31 12:17:00 2013 - Corrected pod syntax 0.50 Sun Mar 30 11:05:23 2014 - Added prev parameter to the DNS::LDNS::RR::new(str) constructor. - Corrected DNS::LDNS::RR::new(file/filename) constructor. Added prev parameter, changed the default_ttl and origin parameters to references so they can return data back to the caller as intended. Using the 'built-in' default values for ttl and origin, rather than my own values. - Corrected the DNS::LDNS::Zone::new() constructor. Corrected file option for reading zone from stream. Using the 'built-in' default values for ttl and origin, rather than my own values. - Removed the $DNS::LDNS::DEFAULT_* variables, they proved to be less useful after modifying the Zone and RR constructors. - More robust Makefile.PL. Check for existence of ldns library and perl modules required for the test suite. 0.51 Wed Apr 2 09:12:00 2014 - Added META.yml, and added some more package dependencies. - Compatibility with ldns < 1.6.12. 0.52 Tue May 5 09:13:00 2015 - Fixed typo in META.yml 0.60 Thu Dec 29 11:15:00 2016 - Compatibility with ldns 1.7 - Dist::zilla build management 0.61 Fri Dec 30 14:32:00 2016 - Bugfixes for ldns 1.7 compatibility - Compatibility with perl 5.25 ldns-1.9.2/contrib/DNS-LDNS/constants.PL0000644000175000017500000003375515212267527017150 0ustar willemwillemuse ExtUtils::Constant; # If you edit these definitions to change the constants used by this module, # you will need to use the generated const-c.inc and const-xs.inc # files to replace their "fallback" counterparts before distributing your # changes. my @names = (qw(LDNS_AA LDNS_AD LDNS_CD LDNS_DEFAULT_EXP_TIME LDNS_DEFAULT_TTL LDNS_DNSSEC_KEYPROTO LDNS_IP4ADDRLEN LDNS_IP6ADDRLEN LDNS_KEY_REVOKE_KEY LDNS_KEY_SEP_KEY LDNS_KEY_ZONE_KEY LDNS_MAX_DOMAINLEN LDNS_MAX_KEYLEN LDNS_MAX_LABELLEN LDNS_MAX_PACKETLEN LDNS_MAX_POINTERS LDNS_MAX_RDFLEN LDNS_NSEC3_MAX_ITERATIONS LDNS_NSEC3_VARS_OPTOUT_MASK LDNS_PORT LDNS_QR LDNS_RA LDNS_RD LDNS_RDATA_FIELD_DESCRIPTORS_COMMON LDNS_RDF_SIZE_16BYTES LDNS_RDF_SIZE_6BYTES LDNS_RDF_SIZE_BYTE LDNS_RDF_SIZE_DOUBLEWORD LDNS_RDF_SIZE_WORD LDNS_RESOLV_ANCHOR LDNS_RESOLV_DEFDOMAIN LDNS_RESOLV_INET LDNS_RESOLV_INET6 LDNS_RESOLV_INETANY LDNS_RESOLV_KEYWORD LDNS_RESOLV_KEYWORDS LDNS_RESOLV_NAMESERVER LDNS_RESOLV_OPTIONS LDNS_RESOLV_RTT_INF LDNS_RESOLV_RTT_MIN LDNS_RESOLV_SEARCH LDNS_RESOLV_SORTLIST LDNS_RR_OVERHEAD LDNS_SIGNATURE_LEAVE_ADD_NEW LDNS_SIGNATURE_LEAVE_NO_ADD LDNS_SIGNATURE_REMOVE_ADD_NEW LDNS_SIGNATURE_REMOVE_NO_ADD LDNS_TC), {name=>"LDNS_CERT_ACPKIX", macro=>"1"}, {name=>"LDNS_CERT_IACPKIX", macro=>"1"}, {name=>"LDNS_CERT_IPGP", macro=>"1"}, {name=>"LDNS_CERT_IPKIX", macro=>"1"}, {name=>"LDNS_CERT_ISPKI", macro=>"1"}, {name=>"LDNS_CERT_OID", macro=>"1"}, {name=>"LDNS_CERT_PGP", macro=>"1"}, {name=>"LDNS_CERT_PKIX", macro=>"1"}, {name=>"LDNS_CERT_SPKI", macro=>"1"}, {name=>"LDNS_CERT_URI", macro=>"1"}, {name=>"LDNS_DH", macro=>"1"}, {name=>"LDNS_DSA", macro=>"1"}, {name=>"LDNS_DSA_NSEC3", macro=>"1"}, {name=>"LDNS_ECC", macro=>"1"}, {name=>"LDNS_ECC_GOST", macro=>"1"}, {name=>"LDNS_HASH_GOST", macro=>"1"}, {name=>"LDNS_PACKET_ANSWER", macro=>"1"}, {name=>"LDNS_PACKET_IQUERY", macro=>"1"}, {name=>"LDNS_PACKET_NODATA", macro=>"1"}, {name=>"LDNS_PACKET_NOTIFY", macro=>"1"}, {name=>"LDNS_PACKET_NXDOMAIN", macro=>"1"}, {name=>"LDNS_PACKET_QUERY", macro=>"1"}, {name=>"LDNS_PACKET_QUESTION", macro=>"1"}, {name=>"LDNS_PACKET_REFERRAL", macro=>"1"}, {name=>"LDNS_PACKET_STATUS", macro=>"1"}, {name=>"LDNS_PACKET_UNKNOWN", macro=>"1"}, {name=>"LDNS_PACKET_UPDATE", macro=>"1"}, {name=>"LDNS_PRIVATEDNS", macro=>"1"}, {name=>"LDNS_PRIVATEOID", macro=>"1"}, {name=>"LDNS_RCODE_FORMERR", macro=>"1"}, {name=>"LDNS_RCODE_NOERROR", macro=>"1"}, {name=>"LDNS_RCODE_NOTAUTH", macro=>"1"}, {name=>"LDNS_RCODE_NOTIMPL", macro=>"1"}, {name=>"LDNS_RCODE_NOTZONE", macro=>"1"}, {name=>"LDNS_RCODE_NXDOMAIN", macro=>"1"}, {name=>"LDNS_RCODE_NXRRSET", macro=>"1"}, {name=>"LDNS_RCODE_REFUSED", macro=>"1"}, {name=>"LDNS_RCODE_SERVFAIL", macro=>"1"}, {name=>"LDNS_RCODE_YXDOMAIN", macro=>"1"}, {name=>"LDNS_RCODE_YXRRSET", macro=>"1"}, {name=>"LDNS_RDF_TYPE_A", macro=>"1"}, {name=>"LDNS_RDF_TYPE_AAAA", macro=>"1"}, {name=>"LDNS_RDF_TYPE_ALG", macro=>"1"}, {name=>"LDNS_RDF_TYPE_APL", macro=>"1"}, {name=>"LDNS_RDF_TYPE_ATMA", macro=>"1"}, {name=>"LDNS_RDF_TYPE_B32_EXT", macro=>"1"}, {name=>"LDNS_RDF_TYPE_B64", macro=>"1"}, {name=>"LDNS_RDF_TYPE_CERT_ALG", macro=>"1"}, {name=>"LDNS_RDF_TYPE_CLASS", macro=>"1"}, {name=>"LDNS_RDF_TYPE_DNAME", macro=>"1"}, {name=>"LDNS_RDF_TYPE_HEX", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT16", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT16_DATA", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT32", macro=>"1"}, {name=>"LDNS_RDF_TYPE_INT8", macro=>"1"}, {name=>"LDNS_RDF_TYPE_IPSECKEY", macro=>"1"}, {name=>"LDNS_RDF_TYPE_LOC", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NONE", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSAP", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSEC", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSEC3_NEXT_OWNER", macro=>"1"}, {name=>"LDNS_RDF_TYPE_NSEC3_SALT", macro=>"1"}, {name=>"LDNS_RDF_TYPE_PERIOD", macro=>"1"}, {name=>"LDNS_RDF_TYPE_SERVICE", macro=>"1"}, {name=>"LDNS_RDF_TYPE_STR", macro=>"1"}, {name=>"LDNS_RDF_TYPE_TIME", macro=>"1"}, {name=>"LDNS_RDF_TYPE_HIP", macro=>"1"}, {name=>"LDNS_RDF_TYPE_TSIGTIME", macro=>"1"}, {name=>"LDNS_RDF_TYPE_TYPE", macro=>"1"}, {name=>"LDNS_RDF_TYPE_UNKNOWN", macro=>"1"}, {name=>"LDNS_RDF_TYPE_WKS", macro=>"1"}, {name=>"LDNS_RR_CLASS_ANY", macro=>"1"}, {name=>"LDNS_RR_CLASS_CH", macro=>"1"}, {name=>"LDNS_RR_CLASS_COUNT", macro=>"1"}, {name=>"LDNS_RR_CLASS_FIRST", macro=>"1"}, {name=>"LDNS_RR_CLASS_HS", macro=>"1"}, {name=>"LDNS_RR_CLASS_IN", macro=>"1"}, {name=>"LDNS_RR_CLASS_LAST", macro=>"1"}, {name=>"LDNS_RR_CLASS_NONE", macro=>"1"}, {name=>"LDNS_RR_COMPRESS", macro=>"1"}, {name=>"LDNS_RR_NO_COMPRESS", macro=>"1"}, {name=>"LDNS_RR_TYPE_A", macro=>"1"}, {name=>"LDNS_RR_TYPE_A6", macro=>"1"}, {name=>"LDNS_RR_TYPE_AAAA", macro=>"1"}, {name=>"LDNS_RR_TYPE_AFSDB", macro=>"1"}, {name=>"LDNS_RR_TYPE_ANY", macro=>"1"}, {name=>"LDNS_RR_TYPE_APL", macro=>"1"}, {name=>"LDNS_RR_TYPE_ATMA", macro=>"1"}, {name=>"LDNS_RR_TYPE_AXFR", macro=>"1"}, {name=>"LDNS_RR_TYPE_CERT", macro=>"1"}, {name=>"LDNS_RR_TYPE_CNAME", macro=>"1"}, {name=>"LDNS_RR_TYPE_COUNT", macro=>"1"}, {name=>"LDNS_RR_TYPE_DHCID", macro=>"1"}, {name=>"LDNS_RR_TYPE_DLV", macro=>"1"}, {name=>"LDNS_RR_TYPE_DNAME", macro=>"1"}, {name=>"LDNS_RR_TYPE_DNSKEY", macro=>"1"}, {name=>"LDNS_RR_TYPE_DS", macro=>"1"}, {name=>"LDNS_RR_TYPE_EID", macro=>"1"}, {name=>"LDNS_RR_TYPE_FIRST", macro=>"1"}, {name=>"LDNS_RR_TYPE_GID", macro=>"1"}, {name=>"LDNS_RR_TYPE_GPOS", macro=>"1"}, {name=>"LDNS_RR_TYPE_HINFO", macro=>"1"}, {name=>"LDNS_RR_TYPE_IPSECKEY", macro=>"1"}, {name=>"LDNS_RR_TYPE_ISDN", macro=>"1"}, {name=>"LDNS_RR_TYPE_IXFR", macro=>"1"}, {name=>"LDNS_RR_TYPE_KEY", macro=>"1"}, {name=>"LDNS_RR_TYPE_KX", macro=>"1"}, {name=>"LDNS_RR_TYPE_LAST", macro=>"1"}, {name=>"LDNS_RR_TYPE_LOC", macro=>"1"}, {name=>"LDNS_RR_TYPE_MAILA", macro=>"1"}, {name=>"LDNS_RR_TYPE_MAILB", macro=>"1"}, {name=>"LDNS_RR_TYPE_MB", macro=>"1"}, {name=>"LDNS_RR_TYPE_MD", macro=>"1"}, {name=>"LDNS_RR_TYPE_MF", macro=>"1"}, {name=>"LDNS_RR_TYPE_MG", macro=>"1"}, {name=>"LDNS_RR_TYPE_MINFO", macro=>"1"}, {name=>"LDNS_RR_TYPE_MR", macro=>"1"}, {name=>"LDNS_RR_TYPE_MX", macro=>"1"}, {name=>"LDNS_RR_TYPE_NAPTR", macro=>"1"}, {name=>"LDNS_RR_TYPE_NIMLOC", macro=>"1"}, {name=>"LDNS_RR_TYPE_NS", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSAP", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSAP_PTR", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC3", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC3PARAM", macro=>"1"}, {name=>"LDNS_RR_TYPE_NSEC3PARAMS", macro=>"1"}, {name=>"LDNS_RR_TYPE_NULL", macro=>"1"}, {name=>"LDNS_RR_TYPE_NXT", macro=>"1"}, {name=>"LDNS_RR_TYPE_OPT", macro=>"1"}, {name=>"LDNS_RR_TYPE_PTR", macro=>"1"}, {name=>"LDNS_RR_TYPE_PX", macro=>"1"}, {name=>"LDNS_RR_TYPE_RP", macro=>"1"}, {name=>"LDNS_RR_TYPE_RRSIG", macro=>"1"}, {name=>"LDNS_RR_TYPE_RT", macro=>"1"}, {name=>"LDNS_RR_TYPE_SIG", macro=>"1"}, {name=>"LDNS_RR_TYPE_SINK", macro=>"1"}, {name=>"LDNS_RR_TYPE_SOA", macro=>"1"}, {name=>"LDNS_RR_TYPE_SPF", macro=>"1"}, {name=>"LDNS_RR_TYPE_SRV", macro=>"1"}, {name=>"LDNS_RR_TYPE_SSHFP", macro=>"1"}, {name=>"LDNS_RR_TYPE_TALINK", macro=>"1"}, {name=>"LDNS_RR_TYPE_TSIG", macro=>"1"}, {name=>"LDNS_RR_TYPE_TXT", macro=>"1"}, {name=>"LDNS_RR_TYPE_UID", macro=>"1"}, {name=>"LDNS_RR_TYPE_UINFO", macro=>"1"}, {name=>"LDNS_RR_TYPE_UNSPEC", macro=>"1"}, {name=>"LDNS_RR_TYPE_WKS", macro=>"1"}, {name=>"LDNS_RR_TYPE_X25", macro=>"1"}, {name=>"LDNS_RSAMD5", macro=>"1"}, {name=>"LDNS_RSASHA1", macro=>"1"}, {name=>"LDNS_RSASHA1_NSEC3", macro=>"1"}, {name=>"LDNS_RSASHA256", macro=>"1"}, {name=>"LDNS_RSASHA512", macro=>"1"}, {name=>"LDNS_SECTION_ADDITIONAL", macro=>"1"}, {name=>"LDNS_SECTION_ANSWER", macro=>"1"}, {name=>"LDNS_SECTION_ANY", macro=>"1"}, {name=>"LDNS_SECTION_ANY_NOQUESTION", macro=>"1"}, {name=>"LDNS_SECTION_AUTHORITY", macro=>"1"}, {name=>"LDNS_SECTION_QUESTION", macro=>"1"}, {name=>"LDNS_SHA1", macro=>"1"}, {name=>"LDNS_SHA256", macro=>"1"}, {name=>"LDNS_SIGN_DSA", macro=>"1"}, {name=>"LDNS_SIGN_DSA_NSEC3", macro=>"1"}, {name=>"LDNS_SIGN_ECC_GOST", macro=>"1"}, {name=>"LDNS_SIGN_HMACSHA1", macro=>"1"}, {name=>"LDNS_SIGN_HMACSHA256", macro=>"1"}, {name=>"LDNS_SIGN_RSAMD5", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA1", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA1_NSEC3", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA256", macro=>"1"}, {name=>"LDNS_SIGN_RSASHA512", macro=>"1"}, {name=>"LDNS_STATUS_ADDRESS_ERR", macro=>"1"}, {name=>"LDNS_STATUS_CERT_BAD_ALGORITHM", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_BOGUS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_DNSKEY", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_DS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_RRSIG", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_NO_TRUSTED_DS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_SIG_EXPIRED", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_TSIG_BOGUS", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_TSIG_ERR", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_UNKNOWN_ALGO", macro=>"1"}, {name=>"LDNS_STATUS_CRYPTO_VALIDATED", macro=>"1"}, {name=>"LDNS_STATUS_DDD_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_EXISTENCE_DENIED", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED", macro=>"1"}, {name=>"LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED", macro=>"1"}, {name=>"LDNS_STATUS_DOMAINNAME_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_DOMAINNAME_UNDERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_EMPTY_LABEL", macro=>"1"}, {name=>"LDNS_STATUS_ENGINE_KEY_NOT_LOADED", macro=>"1"}, {name=>"LDNS_STATUS_ERR", macro=>"1"}, {name=>"LDNS_STATUS_FILE_ERR", macro=>"1"}, {name=>"LDNS_STATUS_INTERNAL_ERR", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_B32_EXT", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_B64", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_HEX", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_INT", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_IP4", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_IP6", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_POINTER", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_STR", macro=>"1"}, {name=>"LDNS_STATUS_INVALID_TIME", macro=>"1"}, {name=>"LDNS_STATUS_LABEL_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_MEM_ERR", macro=>"1"}, {name=>"LDNS_STATUS_MISSING_RDATA_FIELDS_KEY", macro=>"1"}, {name=>"LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG", macro=>"1"}, {name=>"LDNS_STATUS_NETWORK_ERR", macro=>"1"}, {name=>"LDNS_STATUS_NOT_IMPL", macro=>"1"}, {name=>"LDNS_STATUS_NO_DATA", macro=>"1"}, {name=>"LDNS_STATUS_NSEC3_ERR", macro=>"1"}, {name=>"LDNS_STATUS_NULL", macro=>"1"}, {name=>"LDNS_STATUS_OK", macro=>"1"}, {name=>"LDNS_STATUS_PACKET_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_RES_NO_NS", macro=>"1"}, {name=>"LDNS_STATUS_RES_QUERY", macro=>"1"}, {name=>"LDNS_STATUS_SOCKET_ERROR", macro=>"1"}, {name=>"LDNS_STATUS_SSL_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ALG_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_BAD_ESCAPE", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_CLASS_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_DNAME_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_EMPTY", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_INCLUDE", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_KEYWORD_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_ORIGIN", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_RDATA_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_TTL", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_TTL_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_TYPE_ERR", macro=>"1"}, {name=>"LDNS_STATUS_SYNTAX_VERSION_ERR", macro=>"1"}, {name=>"LDNS_STATUS_UNKNOWN_INET", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_ANSWER", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_HEADER", macro=>"1"}, {name=>"LDNS_STATUS_WIRE_INCOMPLETE_QUESTION", macro=>"1"}); ExtUtils::Constant::WriteConstants( NAME => 'LDNS', NAMES => \@names, DEFAULT_TYPE => 'IV', C_FILE => 'const-c.inc', XS_FILE => 'const-xs.inc', ); ldns-1.9.2/contrib/DNS-LDNS/ppport.h0000644000175000017500000052540615212267527016373 0ustar willemwillem#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.19 Automatically created by Devel::PPPort running under perl 5.014002. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.19 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.10.0. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2009, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.19; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.011000||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.011000| HeVAL||5.004000| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LVRET||| MARK||| MULTICALL||5.011000| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.011000||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.011000||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.011000||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.011000| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.011000||p PL_bufptr|5.011000||p PL_compiling|5.004050||p PL_copline|5.011000||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.011000||p PL_expect|5.011000||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.011000||p PL_in_my|5.011000||p PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.011000||p PL_lex_stuff|5.011000||p PL_linestr|5.011000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_parser|5.009005||p PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rsfp_filters|5.004050||p PL_rsfp|5.004050||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.011000||p POP_MULTICALL||5.011000| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.011000| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.011000||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _pMY_CXT|5.007003||p aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.011000||p aTHXR|5.011000||p aTHX_|5.006000||p aTHX|5.006000||p add_data|||n addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_i_ncmp||| amagic_ncmp||| any_dup||| ao||| append_elem||| append_list||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_anoncode||| ck_bitop||| ck_concat||| ck_defined||| ck_delete||| ck_die||| ck_each||| ck_eof||| ck_eval||| ck_exec||| ck_exists||| ck_exit||| ck_ftst||| ck_fun||| ck_glob||| ck_grep||| ck_index||| ck_join||| ck_lfun||| ck_listiob||| ck_match||| ck_method||| ck_null||| ck_open||| ck_readline||| ck_repeat||| ck_require||| ck_return||| ck_rfun||| ck_rvconst||| ck_sassign||| ck_select||| ck_shift||| ck_sort||| ck_spair||| ck_split||| ck_subr||| ck_substr||| ck_svconst||| ck_trunc||| ck_unpack||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init_zero|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| closest_cop||| convert||| cop_free||| cr_textfilter||| create_eval_scope||| croak_nocontext|||vn croak_xs_usage||5.011000| croak|||v csighandler||5.009003|n curmad||| custom_op_desc||5.007003| custom_op_name||5.007003| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_undef||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.011000||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000| deprecate_old||| deprecate||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_where||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_chop||| do_close||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_kv||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs||5.006000| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_script||| find_uninit_var||| first_symbol|||n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_arena||| get_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags||5.009005| get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_isa_hash||| get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv||5.009002| gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||5.011000| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr||| intro_my||| intuit_method||| intuit_more||| invert||| io_close||| isALNUMC|5.006000||p isALNUM||| isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isXDIGIT|5.006000||p is_an_int||| is_gv_magical_sv||| is_handle_constructor|||n is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnumc_lc||5.006000| is_uni_alnumc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_alnumc||5.006000| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000| is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003| is_utf8_string_loc||5.008001| is_utf8_string||5.006001| is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword||| leave_scope||| lex_end||| lex_start||| linklist||| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.011000||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.011000||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall||| magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQ|5.004000||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_find||| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_get_from_name||5.011000| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.011000| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_register||5.011000| mro_set_mro||5.011000| mro_set_private_data||5.011000| mul128||| mulexp10|||n my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat||| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat||| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.011000||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.011000||p newSVpvn|5.004050||p newSVpvs_flags|5.011000||p newSVpvs_share||5.009003| newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.009003| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr||| no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n offer_nice_chunk||| oopsAV||| oopsHV||| op_clear||| op_const_sv||| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_null||5.007002| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_xmldump||| open_script||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package||| packlist||5.008001| pad_add_anon||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||5.011000| pad_swipe||| pad_tidy||| pad_undef||| parse_body||| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmflag||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_elem||| prepend_madprops||| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch||| refcounted_he_free||| refcounted_he_new_common||| refcounted_he_new||| refcounted_he_value||| refkids||| refto||| ref||5.011000| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly|||n regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy||| report_evil_fh||| report_uninit||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||| save_padsv_and_mortalize||5.011000| save_pptr||| save_pushi32ptr||| save_pushptri32ptr||| save_pushptrptr||| save_pushptr||5.011000| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpv||5.007003| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| scope||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.011000| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv||| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_mg|5.004050||p sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_inc_multiple||| sv_dup||| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc||| sv_insert_flags||5.011000| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.011000|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swap_match_buff||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vdie_common||| vdie_croak_common||| vdie||| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| write_no_mem||| write_to_stderr||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs||| xmldump_sub||| xmldump_vindent||| yyerror||| yylex||| yyparse||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <

$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ ldns-1.9.2/contrib/DNS-LDNS/typemap0000644000175000017500000000426115212267527016267 0ustar willemwillemTYPEMAP DNS__LDNS__Zone LDNS_GENERIC_STRUCT DNS__LDNS__RRList LDNS_GENERIC_STRUCT DNS__LDNS__RR LDNS_GENERIC_STRUCT DNS__LDNS__RData LDNS_GENERIC_STRUCT DNS__LDNS__DNSSecZone LDNS_GENERIC_STRUCT DNS__LDNS__DNSSecRRSets LDNS_GENERIC_STRUCT DNS__LDNS__DNSSecRRs LDNS_GENERIC_STRUCT DNS__LDNS__DNSSecName LDNS_GENERIC_STRUCT DNS__LDNS__RBTree LDNS_GENERIC_STRUCT DNS__LDNS__RBNode LDNS_GENERIC_STRUCT DNS__LDNS__Resolver LDNS_GENERIC_STRUCT DNS__LDNS__Packet LDNS_GENERIC_STRUCT DNS__LDNS__Key LDNS_GENERIC_STRUCT DNS__LDNS__KeyList LDNS_GENERIC_STRUCT DNS__LDNS__DNSSecDataChain LDNS_GENERIC_STRUCT DNS__LDNS__DNSSecTrustTree LDNS_GENERIC_STRUCT Mortal_PV Mortal_PV DNS__LDNS__RR__Opt LDNS_GENERIC_STRUCT_OPT DNS__LDNS__RData__Opt LDNS_GENERIC_STRUCT_OPT LDNS_Pkt_Opcode T_ENUM LDNS_Pkt_Rcode T_ENUM LDNS_Pkt_Section T_ENUM LDNS_Pkt_Type T_ENUM LDNS_RR_Type T_ENUM LDNS_RR_Class T_ENUM LDNS_RDF_Type T_ENUM LDNS_Hash T_ENUM LDNS_Status T_ENUM LDNS_Signing_Algorithm T_ENUM uint32_t T_UV uint16_t T_UV uint8_t T_UV signed char T_UV INPUT LDNS_GENERIC_STRUCT_OPT if (!SvOK($arg)) { $var = NULL; } else if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/__/::/g;$ntt=~s/::Opt$//;\$ntt}\")){ IV tmp = SvIV((SV*)SvRV($arg)); $var = INT2PTR($type, tmp); } else croak(\"$var is not of type ${(my $ntt=$ntype)=~s/__/::/g;$ntt=~s/::Opt$//;\$ntt}\") INPUT LDNS_GENERIC_STRUCT if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\")){ IV tmp = SvIV((SV*)SvRV($arg)); $var = INT2PTR($type, tmp); } else croak(\"$var is not of type ${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\") OUTPUT LDNS_GENERIC_STRUCT sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/__/::/g;\$ntt}\", (void*)$var); OUTPUT LDNS_GENERIC_STRUCT_OPT sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/__/::/g;$ntt=~s/::Opt$//;\$ntt}\", (void*)$var); OUTPUT Mortal_PV sv_setsv($arg, sv_2mortal(newSVpv($var, 0))); free((void *)$var); ldns-1.9.2/contrib/DNS-LDNS/LDNS.xs0000644000175000017500000017454115212267527016012 0ustar willemwillem#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "ldns/ldns.h" #include "ldns/error.h" #include "ldns/rr.h" #include "ldns/keys.h" #include "ldns/dname.h" #include "ldns/host2str.h" #include "ldns/rdata.h" #include "ldns/rbtree.h" #include "ldns/resolver.h" #include "ldns/packet.h" #include "ldns/dnssec.h" #include "ldns/dnssec_zone.h" #include "ldns/dnssec_verify.h" #include "ldns/dnssec_sign.h" #include "ldns/rr_functions.h" #if LDNS_REVISION < ((1<<16)|(6<<8)|(17)) #define LDNS_RDF_TYPE_HIP LDNS_RDF_TYPE_TSIG #endif #include "const-c.inc" typedef ldns_zone * DNS__LDNS__Zone; typedef ldns_rr_list * DNS__LDNS__RRList; typedef ldns_rr * DNS__LDNS__RR; typedef ldns_rr * DNS__LDNS__RR__Opt; typedef ldns_rdf * DNS__LDNS__RData; typedef ldns_rdf * DNS__LDNS__RData__Opt; typedef ldns_dnssec_zone * DNS__LDNS__DNSSecZone; typedef ldns_dnssec_rrsets * DNS__LDNS__DNSSecRRSets; typedef ldns_dnssec_rrs * DNS__LDNS__DNSSecRRs; typedef ldns_dnssec_name * DNS__LDNS__DNSSecName; typedef ldns_rbtree_t * DNS__LDNS__RBTree; typedef ldns_rbnode_t * DNS__LDNS__RBNode; typedef ldns_resolver * DNS__LDNS__Resolver; typedef ldns_pkt * DNS__LDNS__Packet; typedef ldns_key * DNS__LDNS__Key; typedef ldns_key_list * DNS__LDNS__KeyList; typedef ldns_dnssec_data_chain * DNS__LDNS__DNSSecDataChain; typedef ldns_dnssec_trust_tree * DNS__LDNS__DNSSecTrustTree; typedef const char * Mortal_PV; typedef ldns_pkt_opcode LDNS_Pkt_Opcode; typedef ldns_pkt_rcode LDNS_Pkt_Rcode; typedef ldns_pkt_section LDNS_Pkt_Section; typedef ldns_pkt_type LDNS_Pkt_Type; typedef ldns_rr_type LDNS_RR_Type; typedef ldns_rr_class LDNS_RR_Class; typedef ldns_rdf_type LDNS_RDF_Type; typedef ldns_hash LDNS_Hash; typedef ldns_status LDNS_Status; typedef ldns_signing_algorithm LDNS_Signing_Algorithm; /* callback function used by the signing methods */ int sign_policy(ldns_rr *sig, void *n) { return *(uint16_t*)n; } /* utility methods */ void add_cloned_rrs_to_list(ldns_rr_list * list, ldns_rr_list * add) { size_t count; size_t i; count = ldns_rr_list_rr_count(add); for(i = 0; i < count; i++) { ldns_rr_list_push_rr(list, ldns_rr_clone(ldns_rr_list_rr(add, i))); } } #if LDNS_REVISION < ((1<<16)|(6<<8)|(12)) ldns_dnssec_trust_tree *ldns_dnssec_derive_trust_tree_time( ldns_dnssec_data_chain *data_chain, ldns_rr *rr, time_t check_time); ldns_rr_list *ldns_fetch_valid_domain_keys_time(const ldns_resolver * res, const ldns_rdf * domain, const ldns_rr_list * keys, time_t check_time, ldns_status *status); ldns_rr_list *ldns_validate_domain_dnskey_time( const ldns_resolver *res, const ldns_rdf *domain, const ldns_rr_list *keys, time_t check_time); ldns_rr_list *ldns_validate_domain_ds_time( const ldns_resolver *res, const ldns_rdf *domain, const ldns_rr_list * keys, time_t check_time); ldns_status ldns_verify_rrsig_keylist_time( ldns_rr_list *rrset, ldns_rr *rrsig, const ldns_rr_list *keys, time_t check_time, ldns_rr_list *good_keys); ldns_status ldns_verify_trusted_time( ldns_resolver *res, ldns_rr_list *rrset, ldns_rr_list *rrsigs, time_t check_time, ldns_rr_list *validating_keys); ldns_status ldns_verify_rrsig_time( ldns_rr_list *rrset, ldns_rr *rrsig, ldns_rr *key, time_t check_time); ldns_status ldns_verify_time(ldns_rr_list *rrset, ldns_rr_list *rrsig, const ldns_rr_list *keys, time_t check_time, ldns_rr_list *good_keys); ldns_dnssec_trust_tree *ldns_dnssec_derive_trust_tree_time( ldns_dnssec_data_chain *data_chain, ldns_rr *rr, time_t check_time) { Perl_croak(aTHX_ "function ldns_dnssec_derive_trust_tree_time is not implemented in this version of ldns"); } ldns_rr_list *ldns_fetch_valid_domain_keys_time(const ldns_resolver * res, const ldns_rdf * domain, const ldns_rr_list * keys, time_t check_time, ldns_status *status) { Perl_croak(aTHX_ "function ldns_fetch_valid_domain_keys_time is not implemented in this version of ldns"); } ldns_rr_list *ldns_validate_domain_dnskey_time( const ldns_resolver *res, const ldns_rdf *domain, const ldns_rr_list *keys, time_t check_time) { Perl_croak(aTHX_ "function ldns_validate_domain_dnskey_time is not implemented in this version of ldns"); } ldns_rr_list *ldns_validate_domain_ds_time( const ldns_resolver *res, const ldns_rdf *domain, const ldns_rr_list * keys, time_t check_time) { Perl_croak(aTHX_ "function ldns_validate_domain_ds_time is not implemented in this version of ldns"); } ldns_status ldns_verify_rrsig_keylist_time( ldns_rr_list *rrset, ldns_rr *rrsig, const ldns_rr_list *keys, time_t check_time, ldns_rr_list *good_keys) { Perl_croak(aTHX_ "function ldns_verify_rrsig_keylist_time is not implemented in this version of ldns"); } ldns_status ldns_verify_trusted_time( ldns_resolver *res, ldns_rr_list *rrset, ldns_rr_list *rrsigs, time_t check_time, ldns_rr_list *validating_keys) { Perl_croak(aTHX_ "function ldns_verify_trusted_time is not implemented in this version of ldns"); } ldns_status ldns_verify_rrsig_time( ldns_rr_list *rrset, ldns_rr *rrsig, ldns_rr *key, time_t check_time) { Perl_croak(aTHX_ "function ldns_verify_rrsig_time is not implemented in this version of ldns"); } ldns_status ldns_verify_time(ldns_rr_list *rrset, ldns_rr_list *rrsig, const ldns_rr_list *keys, time_t check_time, ldns_rr_list *good_keys) { Perl_croak(aTHX_ "function ldns_verify_time is not implemented in this version of ldns"); } #endif MODULE = DNS::LDNS PACKAGE = DNS::LDNS INCLUDE: const-xs.inc const char * ldns_get_errorstr_by_id(s) LDNS_Status s ALIAS: errorstr_by_id = 1 Mortal_PV ldns_rr_type2str(type) LDNS_RR_Type type; ALIAS: rr_type2str = 1 Mortal_PV ldns_rr_class2str(class) LDNS_RR_Class class; ALIAS: rr_class2str = 1 Mortal_PV ldns_pkt_opcode2str(opcode) LDNS_Pkt_Opcode opcode; ALIAS: pkt_opcode2str = 1 Mortal_PV ldns_pkt_rcode2str(rcode) LDNS_Pkt_Rcode rcode; ALIAS: pkt_rcode2str = 1 LDNS_RR_Type ldns_get_rr_type_by_name(name) char * name; ALIAS: rr_type_by_name = 1 LDNS_RR_Class ldns_get_rr_class_by_name(name) char * name; ALIAS: rr_class_by_name = 1 DNS__LDNS__RR ldns_dnssec_create_nsec(from, to, nsec_type) DNS__LDNS__DNSSecName from; DNS__LDNS__DNSSecName to; LDNS_RR_Type nsec_type; ALIAS: dnssec_create_nsec = 1 DNS__LDNS__RR dnssec_create_nsec3(from, to, zone_name, algorithm, flags, iterations, salt) DNS__LDNS__DNSSecName from; DNS__LDNS__DNSSecName to; DNS__LDNS__RData zone_name; uint8_t algorithm; uint8_t flags; uint16_t iterations; char * salt; CODE: RETVAL = ldns_dnssec_create_nsec3(from, to, zone_name, algorithm, flags, iterations, strlen(salt), (uint8_t*)salt); OUTPUT: RETVAL DNS__LDNS__RR ldns_create_nsec(current, next, rrs) DNS__LDNS__RData current; DNS__LDNS__RData next; DNS__LDNS__RRList rrs; ALIAS: create_nsec = 1 DNS__LDNS__RR create_nsec3(cur_owner, cur_zone, rrs, algorithm, flags, iterations, salt, emptynonterminal) DNS__LDNS__RData cur_owner; DNS__LDNS__RData cur_zone; DNS__LDNS__RRList rrs; uint8_t algorithm; uint8_t flags; uint16_t iterations; char * salt; bool emptynonterminal; CODE: RETVAL = ldns_create_nsec3(cur_owner, cur_zone, rrs, algorithm, flags, iterations, strlen(salt), (uint8_t*)salt, emptynonterminal); OUTPUT: RETVAL LDNS_Signing_Algorithm ldns_get_signing_algorithm_by_name(name) const char * name; ALIAS: signing_algorithm_by_name = 1 int ldns_key_algo_supported(algorithm) int algorithm; ALIAS: key_algorithm_supported = 1 DNS__LDNS__RR ldns_read_anchor_file(filename) char * filename; ALIAS: read_anchor_file = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::GC void ldns_zone_deep_free(zone) DNS__LDNS__Zone zone; ALIAS: _zone_deep_free = 1 void ldns_rr_list_deep_free(list) DNS__LDNS__RRList list; ALIAS: _rrlist_deep_free = 1 void ldns_rr_free(rr) DNS__LDNS__RR rr; ALIAS: _rr_free = 1 void ldns_rdf_deep_free(rdf) DNS__LDNS__RData rdf; ALIAS: _rdata_deep_free = 1 void ldns_dnssec_zone_deep_free(zone) DNS__LDNS__DNSSecZone zone; ALIAS: _dnssec_zone_deep_free = 1 void ldns_dnssec_name_deep_free(name) DNS__LDNS__DNSSecName name; ALIAS: _dnssec_name_deep_free = 1 void ldns_resolver_deep_free(resolver) DNS__LDNS__Resolver resolver; ALIAS: _resolver_deep_free = 1 void ldns_pkt_free(pkt) DNS__LDNS__Packet pkt; ALIAS: _packet_free = 1 void ldns_key_deep_free(key) DNS__LDNS__Key key; ALIAS: _key_deep_free = 1 void ldns_key_list_free(keylist) DNS__LDNS__KeyList keylist; ALIAS: _keylist_free = 1 void ldns_dnssec_data_chain_deep_free(chain) DNS__LDNS__DNSSecDataChain chain; ALIAS: _dnssec_datachain_deep_free = 1 void ldns_dnssec_trust_tree_free(tree) DNS__LDNS__DNSSecTrustTree tree; ALIAS: _dnssec_trusttree_free = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::Zone PROTOTYPES: ENABLE DNS__LDNS__Zone ldns_zone_new() ALIAS: _new = 1 DNS__LDNS__Zone _new_from_file(fp, origin, ttl, c, s, line_nr) FILE* fp; DNS__LDNS__RData__Opt origin; uint32_t ttl; LDNS_RR_Class c; LDNS_Status s; int line_nr; PREINIT: ldns_zone *z; CODE: if (ttl == 0) { ttl = 0; } RETVAL = NULL; s = ldns_zone_new_frm_fp_l(&z, fp, origin, ttl, c, &line_nr); if (s == LDNS_STATUS_OK) { RETVAL = z; } OUTPUT: RETVAL s line_nr void print(zone, fp) DNS__LDNS__Zone zone; FILE* fp; CODE: ldns_zone_print(fp, zone); void canonicalize(zone) DNS__LDNS__Zone zone; PREINIT: ldns_rr_list *list; size_t count; size_t i; CODE: list = ldns_zone_rrs(zone); count = ldns_rr_list_rr_count(list); ldns_rr2canonical(ldns_zone_soa(zone)); for (i = 0; i < ldns_rr_list_rr_count(ldns_zone_rrs(zone)); i++) { ldns_rr2canonical(ldns_rr_list_rr(ldns_zone_rrs(zone), i)); } void ldns_zone_sort(zone) DNS__LDNS__Zone zone; ALIAS: sort = 1 DNS__LDNS__RR ldns_zone_soa(zone) DNS__LDNS__Zone zone; ALIAS: _soa = 1 void ldns_zone_set_soa(zone, soa) DNS__LDNS__Zone zone; DNS__LDNS__RR soa; ALIAS: _set_soa = 1 DNS__LDNS__RRList ldns_zone_rrs(zone) DNS__LDNS__Zone zone; ALIAS: _rrs = 1 void ldns_zone_set_rrs(zone, list) DNS__LDNS__Zone zone; DNS__LDNS__RRList list; ALIAS: _set_rrs = 1 DNS__LDNS__Zone ldns_zone_sign(zone, keylist) DNS__LDNS__Zone zone; DNS__LDNS__KeyList keylist; ALIAS: sign = 1 DNS__LDNS__Zone sign_nsec3(zone, keylist, algorithm, flags, iterations, salt) DNS__LDNS__Zone zone; DNS__LDNS__KeyList keylist; uint8_t algorithm; uint8_t flags; uint16_t iterations; unsigned char * salt; CODE: RETVAL = ldns_zone_sign_nsec3(zone, keylist, algorithm, flags, iterations, strlen(salt), (uint8_t*)salt); OUTPUT: RETVAL MODULE = DNS::LDNS PACKAGE = DNS::LDNS::RRList PROTOTYPES: ENABLE DNS__LDNS__RRList ldns_rr_list_new() ALIAS: _new = 1 DNS__LDNS__RRList _new_hosts_from_file(fp, line_nr) FILE * fp; int line_nr; CODE: RETVAL = ldns_get_rr_list_hosts_frm_fp_l(fp, &line_nr); OUTPUT: RETVAL DNS__LDNS__RRList ldns_rr_list_clone(list) DNS__LDNS__RRList list; ALIAS: clone = 1 void print(list, fp) DNS__LDNS__RRList list; FILE* fp; CODE: ldns_rr_list_print(fp, list); Mortal_PV ldns_rr_list2str(list) DNS__LDNS__RRList list; ALIAS: to_string = 1 DNS__LDNS__RR ldns_rr_list_rr(list, i) DNS__LDNS__RRList list; size_t i; ALIAS: _rr = 1 DNS__LDNS__RR ldns_rr_list_pop_rr(list) DNS__LDNS__RRList list; ALIAS: pop = 1 bool ldns_rr_list_push_rr(list, rr) DNS__LDNS__RRList list; DNS__LDNS__RR rr; ALIAS: _push = 1 size_t ldns_rr_list_rr_count(list) DNS__LDNS__RRList list; ALIAS: rr_count = 1 int ldns_rr_list_compare(list, otherlist) DNS__LDNS__RRList list; DNS__LDNS__RRList otherlist; ALIAS: compare = 1 DNS__LDNS__RRList ldns_rr_list_subtype_by_rdf(list, rdf, pos) DNS__LDNS__RRList list; DNS__LDNS__RData rdf; size_t pos; ALIAS: subtype_by_rdata = 1 DNS__LDNS__RRList ldns_rr_list_pop_rrset(list) DNS__LDNS__RRList list; ALIAS: pop_rrset = 1 bool ldns_is_rrset(list) DNS__LDNS__RRList list; ALIAS: is_rrset = 1 bool ldns_rr_list_contains_rr(list, rr) DNS__LDNS__RRList list; DNS__LDNS__RR rr; ALIAS: contains_rr = 1 DNS__LDNS__RRList ldns_rr_list_pop_rr_list(list, count) DNS__LDNS__RRList list; size_t count; ALIAS: pop_list = 1 bool _push_list(list, otherlist) DNS__LDNS__RRList list; DNS__LDNS__RRList otherlist; PREINIT: bool ret; CODE: ret = ldns_rr_list_push_rr_list(list, otherlist); if (ret) { ldns_rr_list_free(otherlist); } OUTPUT: RETVAL LDNS_Status _verify_rrsig_keylist(rrset, rrsig, keys, good_keys) DNS__LDNS__RRList rrset; DNS__LDNS__RR rrsig; DNS__LDNS__RRList keys; DNS__LDNS__RRList good_keys; PREINIT: DNS__LDNS__RRList gk; CODE: gk = ldns_rr_list_new(); RETVAL = ldns_verify_rrsig_keylist(rrset, rrsig, keys, good_keys); add_cloned_rrs_to_list(good_keys, gk); ldns_rr_list_free(gk); OUTPUT: RETVAL LDNS_Status _verify_rrsig_keylist_time(rrset, rrsig, keys, check_time, good_keys) DNS__LDNS__RRList rrset; DNS__LDNS__RR rrsig; DNS__LDNS__RRList keys; time_t check_time; DNS__LDNS__RRList good_keys; PREINIT: DNS__LDNS__RRList gk; CODE: gk = ldns_rr_list_new(); RETVAL = ldns_verify_rrsig_keylist_time( rrset, rrsig, keys, check_time, good_keys); add_cloned_rrs_to_list(good_keys, gk); ldns_rr_list_free(gk); OUTPUT: RETVAL LDNS_Status _verify_rrsig_keylist_notime(rrset, rrsig, keys, good_keys) DNS__LDNS__RRList rrset; DNS__LDNS__RR rrsig; DNS__LDNS__RRList keys; DNS__LDNS__RRList good_keys; PREINIT: DNS__LDNS__RRList gk; CODE: gk = ldns_rr_list_new(); RETVAL = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys, NULL); add_cloned_rrs_to_list(good_keys, gk); ldns_rr_list_free(gk); OUTPUT: RETVAL LDNS_Status ldns_verify_rrsig(rrset, rrsig, key) DNS__LDNS__RRList rrset; DNS__LDNS__RR rrsig; DNS__LDNS__RR key; ALIAS: _verify_rrsig = 1 LDNS_Status ldns_verify_rrsig_time(rrset, rrsig, key, check_time) DNS__LDNS__RRList rrset; DNS__LDNS__RR rrsig; DNS__LDNS__RR key; time_t check_time; ALIAS: _verify_rrsig_time = 1 LDNS_Status _verify(rrset, rrsig, keys, good_keys) DNS__LDNS__RRList rrset; DNS__LDNS__RRList rrsig; DNS__LDNS__RRList keys; DNS__LDNS__RRList good_keys; PREINIT: DNS__LDNS__RRList gk; CODE: gk = ldns_rr_list_new(); RETVAL = ldns_verify(rrset, rrsig, keys, gk); add_cloned_rrs_to_list(good_keys, gk); ldns_rr_list_free(gk); OUTPUT: RETVAL LDNS_Status _verify_time(rrset, rrsig, keys, check_time, good_keys) DNS__LDNS__RRList rrset; DNS__LDNS__RRList rrsig; DNS__LDNS__RRList keys; time_t check_time; DNS__LDNS__RRList good_keys; PREINIT: DNS__LDNS__RRList gk; CODE: gk = ldns_rr_list_new(); RETVAL = ldns_verify_time(rrset, rrsig, keys, check_time, gk); add_cloned_rrs_to_list(good_keys, gk); ldns_rr_list_free(gk); OUTPUT: RETVAL LDNS_Status _verify_notime(rrset, rrsig, keys, good_keys) DNS__LDNS__RRList rrset; DNS__LDNS__RRList rrsig; DNS__LDNS__RRList keys; DNS__LDNS__RRList good_keys; PREINIT: DNS__LDNS__RRList gk; CODE: gk = ldns_rr_list_new(); RETVAL = ldns_verify_notime(rrset, rrsig, keys, gk); add_cloned_rrs_to_list(good_keys, gk); ldns_rr_list_free(gk); OUTPUT: RETVAL DNS__LDNS__RR ldns_create_empty_rrsig(rrset, current_key) DNS__LDNS__RRList rrset; DNS__LDNS__Key current_key; ALIAS: create_empty_rrsig = 1 DNS__LDNS__RRList ldns_sign_public(rrset, keys) DNS__LDNS__RRList rrset; DNS__LDNS__KeyList keys; ALIAS: sign_public = 1 void ldns_rr_list_sort(list) DNS__LDNS__RRList list; ALIAS: sort = 1 void ldns_rr_list_sort_nsec3(list) DNS__LDNS__RRList list; ALIAS: sort_nsec3 = 1 void ldns_rr_list2canonical(list) DNS__LDNS__RRList list; ALIAS: canonicalize = 1 DNS__LDNS__RR ldns_dnssec_get_dnskey_for_rrsig(rr, rrlist) DNS__LDNS__RR rr; DNS__LDNS__RRList rrlist; ALIAS: _get_dnskey_for_rrsig = 1 DNS__LDNS__RR ldns_dnssec_get_rrsig_for_name_and_type(name, type, rrsigs) DNS__LDNS__RData name; LDNS_RR_Type type; DNS__LDNS__RRList rrsigs; ALIAS: _get_rrsig_for_name_and_type = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::RR PROTOTYPES: ENABLE DNS__LDNS__RR ldns_rr_new() ALIAS: _new = 1 DNS__LDNS__RR ldns_rr_new_frm_type(t) LDNS_RR_Type t; ALIAS: _new_from_type = 1 DNS__LDNS__RR _new_from_str(str, default_ttl, origin, prev, s) const char* str; uint32_t default_ttl; DNS__LDNS__RData__Opt origin; DNS__LDNS__RData__Opt prev; LDNS_Status s; PREINIT: DNS__LDNS__RR rr = NULL; ldns_rdf *pclone = NULL; CODE: if (prev != NULL) { pclone = ldns_rdf_clone(prev); } s = ldns_rr_new_frm_str(&rr, str, default_ttl, origin, &prev); if (prev != NULL) { prev = pclone; } if (s == LDNS_STATUS_OK) { RETVAL = rr; } OUTPUT: RETVAL s prev DNS__LDNS__RR _new_from_file(fp, default_ttl, origin, prev, s, line_nr) FILE* fp; uint32_t default_ttl; DNS__LDNS__RData__Opt origin; DNS__LDNS__RData__Opt prev; LDNS_Status s; int line_nr; PREINIT: ldns_rr *rr; ldns_rdf *oclone = NULL; ldns_rdf *pclone = NULL; CODE: /* Must clone origin and prev because new_frm_fp_l may change them and may not (we do not know for certain). The perl layer will take care of freeing the old structs. */ if (origin != NULL) { oclone = ldns_rdf_clone(origin); } if (prev != NULL) { pclone = ldns_rdf_clone(prev); } RETVAL = NULL; s = ldns_rr_new_frm_fp_l(&rr, fp, &default_ttl, &oclone, &pclone, &line_nr); /* Replace the input origin with our new clone. The perl layer will take care of freeing it later. */ if (origin != NULL) { origin = oclone; } if (prev != NULL) { prev = pclone; } if (s == LDNS_STATUS_OK) { RETVAL = rr; } OUTPUT: RETVAL s line_nr default_ttl origin prev DNS__LDNS__RR ldns_rr_clone(rr) DNS__LDNS__RR rr; ALIAS: clone = 1 void ldns_rr_set_owner(rr, owner) DNS__LDNS__RR rr; DNS__LDNS__RData owner; ALIAS: _set_owner = 1 void ldns_rr_set_ttl(rr, ttl) DNS__LDNS__RR rr; uint32_t ttl; ALIAS: set_ttl = 1 void ldns_rr_set_type(rr, type) DNS__LDNS__RR rr; LDNS_RR_Type type; ALIAS: set_type = 1 void ldns_rr_set_class(rr, class) DNS__LDNS__RR rr; LDNS_RR_Class class; ALIAS: set_class = 1 void print(rr, fp) DNS__LDNS__RR rr; FILE* fp; CODE: ldns_rr_print(fp, rr); Mortal_PV ldns_rr2str(rr) DNS__LDNS__RR rr; ALIAS: to_string = 1 int ldns_rr_compare(rr, otherrr) DNS__LDNS__RR rr; DNS__LDNS__RR otherrr; ALIAS: compare = 1 int ldns_rr_compare_no_rdata(rr, otherrr) DNS__LDNS__RR rr; DNS__LDNS__RR otherrr; ALIAS: compare_no_rdata = 1 int ldns_rr_compare_ds(rr, otherrr) DNS__LDNS__RR rr; DNS__LDNS__RR otherrr; ALIAS: compare_ds = 1 int compare_dname(rr, otherrr) DNS__LDNS__RR rr; DNS__LDNS__RR otherrr; CODE: RETVAL = ldns_dname_compare( ldns_rr_owner(rr), ldns_rr_owner(otherrr)); OUTPUT: RETVAL DNS__LDNS__RData ldns_rr_owner(rr) DNS__LDNS__RR rr; ALIAS: _owner = 1 size_t ldns_rr_rd_count(rr); DNS__LDNS__RR rr; ALIAS: rd_count = 1 DNS__LDNS__RData ldns_rr_rdf(rr, i) DNS__LDNS__RR rr; size_t i; ALIAS: _rdata = 1 DNS__LDNS__RData ldns_rr_set_rdf(rr, rdf, i) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; size_t i; ALIAS: _set_rdata = 1 uint32_t ldns_rr_ttl(rr) DNS__LDNS__RR rr; ALIAS: ttl = 1 LDNS_RR_Class ldns_rr_get_class(rr) DNS__LDNS__RR rr; ALIAS: class = 1 LDNS_RR_Type ldns_rr_get_type(rr) DNS__LDNS__RR rr; ALIAS: type = 1 DNS__LDNS__RData ldns_rr_pop_rdf(rr) DNS__LDNS__RR rr; ALIAS: pop_rdata = 1 bool ldns_rr_push_rdf(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _push_rdata = 1 DNS__LDNS__RData ldns_rr_rrsig_typecovered(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_typecovered = 1 bool ldns_rr_rrsig_set_typecovered(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_typecovered = 1 DNS__LDNS__RData ldns_rr_rrsig_algorithm(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_algorithm = 1 bool ldns_rr_rrsig_set_algorithm(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_algorithm = 1 DNS__LDNS__RData ldns_rr_rrsig_expiration(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_expiration = 1 bool ldns_rr_rrsig_set_expiration(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_expiration = 1 DNS__LDNS__RData ldns_rr_rrsig_inception(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_inception = 1 bool ldns_rr_rrsig_set_inception(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_inception = 1 DNS__LDNS__RData ldns_rr_rrsig_keytag(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_keytag = 1 bool ldns_rr_rrsig_set_keytag(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_keytag = 1 DNS__LDNS__RData ldns_rr_rrsig_sig(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_sig = 1 bool ldns_rr_rrsig_set_sig(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_sig = 1 DNS__LDNS__RData ldns_rr_rrsig_labels(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_labels = 1 bool ldns_rr_rrsig_set_labels(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_labels = 1 DNS__LDNS__RData ldns_rr_rrsig_origttl(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_origttl = 1 bool ldns_rr_rrsig_set_origttl(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_origttl = 1 DNS__LDNS__RData ldns_rr_rrsig_signame(rr) DNS__LDNS__RR rr; ALIAS: _rrsig_signame = 1 bool ldns_rr_rrsig_set_signame(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _rrsig_set_signame = 1 DNS__LDNS__RData ldns_rr_dnskey_algorithm(rr) DNS__LDNS__RR rr; ALIAS: _dnskey_algorithm = 1 bool ldns_rr_dnskey_set_algorithm(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _dnskey_set_algorithm = 1 DNS__LDNS__RData ldns_rr_dnskey_flags(rr) DNS__LDNS__RR rr; ALIAS: _dnskey_flags = 1 bool ldns_rr_dnskey_set_flags(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _dnskey_set_flags = 1 DNS__LDNS__RData ldns_rr_dnskey_protocol(rr) DNS__LDNS__RR rr; ALIAS: _dnskey_protocol = 1 bool ldns_rr_dnskey_set_protocol(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _dnskey_set_protocol = 1 DNS__LDNS__RData ldns_rr_dnskey_key(rr) DNS__LDNS__RR rr; ALIAS: _dnskey_key = 1 bool ldns_rr_dnskey_set_key(rr, rdf) DNS__LDNS__RR rr; DNS__LDNS__RData rdf; ALIAS: _dnskey_set_key = 1 size_t ldns_rr_dnskey_key_size(rr) DNS__LDNS__RR rr; ALIAS: dnskey_key_size = 1 uint16_t ldns_calc_keytag(key) DNS__LDNS__RR key; ALIAS: calc_keytag = 1 DNS__LDNS__RData ldns_nsec3_hash_name_frm_nsec3(rr, name) DNS__LDNS__RR rr; DNS__LDNS__RData name; ALIAS: _hash_name_from_nsec3 = 1 DNS__LDNS__RData _nsec3_hash_name(name, algorithm, iterations, salt) DNS__LDNS__RData name; uint8_t algorithm; uint16_t iterations; char * salt; CODE: RETVAL = ldns_nsec3_hash_name(name, algorithm, iterations, strlen(salt), (uint8_t *)salt); OUTPUT: RETVAL LDNS_Status ldns_dnssec_verify_denial(rr, nsecs, rrsigs) DNS__LDNS__RR rr; DNS__LDNS__RRList nsecs; DNS__LDNS__RRList rrsigs; ALIAS: _verify_denial = 1 LDNS_Status ldns_dnssec_verify_denial_nsec3(rr, nsecs, rrsigs, packet_rcode, packet_qtype, packet_nodata) DNS__LDNS__RR rr; DNS__LDNS__RRList nsecs; DNS__LDNS__RRList rrsigs; LDNS_Pkt_Rcode packet_rcode; LDNS_RR_Type packet_qtype; signed char packet_nodata; ALIAS: _verify_denial_nsec3 = 1 DNS__LDNS__RR _verify_denial_nsec3_match(rr, nsecs, rrsigs, packet_rcode, packet_qtype, packet_nodata, status) DNS__LDNS__RR rr; DNS__LDNS__RRList nsecs; DNS__LDNS__RRList rrsigs; LDNS_Pkt_Rcode packet_rcode; LDNS_RR_Type packet_qtype; signed char packet_nodata; LDNS_Status status; PREINIT: ldns_rr ** match; CODE: RETVAL = NULL; status = ldns_dnssec_verify_denial_nsec3_match(rr, nsecs, rrsigs, packet_rcode, packet_qtype, packet_nodata, match); if (status == LDNS_STATUS_OK) { RETVAL = *match; } OUTPUT: status RETVAL void nsec3_add_param_rdfs(rr, algorithm, flags, iterations, salt) DNS__LDNS__RR rr; uint8_t algorithm; uint8_t flags; uint16_t iterations; char * salt; CODE: ldns_nsec3_add_param_rdfs(rr, algorithm, flags, iterations, strlen(salt), (uint8_t*)salt); uint8_t ldns_nsec3_algorithm(nsec3) DNS__LDNS__RR nsec3; ALIAS: nsec3_algorithm = 1 uint8_t ldns_nsec3_flags(nsec3) DNS__LDNS__RR nsec3; ALIAS: nsec3_flags = 1 bool ldns_nsec3_optout(nsec3) DNS__LDNS__RR nsec3; ALIAS: nsec3_optout = 1 uint16_t ldns_nsec3_iterations(nsec3) DNS__LDNS__RR nsec3; ALIAS: nsec3_iterations = 1 DNS__LDNS__RData ldns_nsec3_next_owner(nsec3) DNS__LDNS__RR nsec3; ALIAS: _nsec3_next_owner = 1 DNS__LDNS__RData ldns_nsec3_bitmap(nsec3) DNS__LDNS__RR nsec3; ALIAS: _nsec3_bitmap = 1 DNS__LDNS__RData ldns_nsec3_salt(nsec3) DNS__LDNS__RR nsec3; ALIAS: _nsec3_salt = 1 DNS__LDNS__RR ldns_key_rr2ds(key, hash) DNS__LDNS__RR key; LDNS_Hash hash; ALIAS: key_to_ds = 1 bool ldns_rr_is_question(rr) DNS__LDNS__RR rr; ALIAS: is_question = 1 uint8_t ldns_rr_label_count(rr) DNS__LDNS__RR rr; ALIAS: label_count = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::RData PROTOTYPES: ENABLE DNS__LDNS__RData ldns_rdf_new_frm_str(type, str) LDNS_RDF_Type type; const char *str; ALIAS: _new = 1 DNS__LDNS__RData ldns_rdf_clone(rdf) DNS__LDNS__RData rdf; ALIAS: clone = 1 Mortal_PV ldns_rdf2str(rdf) DNS__LDNS__RData rdf; ALIAS: to_string = 1 void print(rdf, fp) DNS__LDNS__RData rdf; FILE* fp; CODE: ldns_rdf_print(fp, rdf); LDNS_RDF_Type ldns_rdf_get_type(rdf) DNS__LDNS__RData rdf; ALIAS: type = 1 void ldns_rdf_set_type(rdf, type) DNS__LDNS__RData rdf; LDNS_RDF_Type type ALIAS: set_type = 1 int ldns_rdf_compare(rd1, rd2) DNS__LDNS__RData rd1; DNS__LDNS__RData rd2; ALIAS: compare = 1 DNS__LDNS__RData ldns_rdf_address_reverse(rdf) DNS__LDNS__RData rdf; ALIAS: address_reverse = 1 uint8_t ldns_dname_label_count(rdf) DNS__LDNS__RData rdf; ALIAS: label_count = 1 DNS__LDNS__RData ldns_dname_label(rdf, labelpos) DNS__LDNS__RData rdf; uint8_t labelpos; ALIAS: label = 1 int ldns_dname_is_wildcard(rdf) DNS__LDNS__RData rdf; ALIAS: is_wildcard = 1 int ldns_dname_match_wildcard(rdf, wildcard) DNS__LDNS__RData rdf; DNS__LDNS__RData wildcard; ALIAS: matches_wildcard = 1 signed char ldns_dname_is_subdomain(rdf, parent) DNS__LDNS__RData rdf; DNS__LDNS__RData parent; ALIAS: is_subdomain = 1 DNS__LDNS__RData ldns_dname_left_chop(rdf) DNS__LDNS__RData rdf ALIAS: left_chop = 1 LDNS_Status ldns_dname_cat(rdata, otherrd) DNS__LDNS__RData rdata; DNS__LDNS__RData otherrd; ALIAS: _cat = 1 int ldns_dname_compare(dname, otherdname) DNS__LDNS__RData dname; DNS__LDNS__RData otherdname; ALIAS: compare = 1 LDNS_RR_Type ldns_rdf2rr_type(rdf) DNS__LDNS__RData rdf; ALIAS: to_rr_type = 1 DNS__LDNS__RData ldns_dname_reverse(rdf) DNS__LDNS__RData rdf; ALIAS: dname_reverse = 1 void ldns_dname2canonical(rdf) DNS__LDNS__RData rdf; ALIAS: dname2canonical = 1 time_t ldns_rdf2native_time_t(rdf) DNS__LDNS__RData rdf; ALIAS: to_unix_time = 1 2native_time_t = 2 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::DNSSecZone PROTOTYPES: ENABLE DNS__LDNS__DNSSecZone ldns_dnssec_zone_new() ALIAS: _new = 1 DNS__LDNS__DNSSecZone _new_from_file(fp, origin, ttl, c, s, line_nr) FILE* fp; DNS__LDNS__RData__Opt origin; uint32_t ttl; LDNS_RR_Class c; LDNS_Status s; int line_nr; PREINIT: ldns_dnssec_zone *z; CODE: RETVAL = NULL; #if LDNS_REVISION < ((1<<16)|(6<<8)|(13)) Perl_croak(aTHX_ "function ldns_dnssec_zone_new_frm_fp_l is not implemented in this version of ldns"); #else s = ldns_dnssec_zone_new_frm_fp_l(&z, fp, origin, ttl, c, &line_nr); #endif if (s == LDNS_STATUS_OK) { RETVAL = z; } OUTPUT: RETVAL s line_nr LDNS_Status create_from_zone(dnssec_zone, zone) DNS__LDNS__DNSSecZone dnssec_zone; DNS__LDNS__Zone zone; PREINIT: size_t i; ldns_rr *cur_rr; ldns_status status; ldns_rr_list *failed_nsec3s; ldns_rr_list *failed_nsec3_rrsigs; ldns_status result = LDNS_STATUS_OK; CODE: failed_nsec3s = ldns_rr_list_new(); failed_nsec3_rrsigs = ldns_rr_list_new(); status = ldns_dnssec_zone_add_rr(dnssec_zone, ldns_rr_clone(ldns_zone_soa(zone))); if (result == LDNS_STATUS_OK) { result = status; } for (i = 0; i < ldns_rr_list_rr_count(ldns_zone_rrs(zone)); i++) { cur_rr = ldns_rr_list_rr(ldns_zone_rrs(zone), i); status = ldns_dnssec_zone_add_rr(dnssec_zone, ldns_rr_clone(cur_rr)); if (status != LDNS_STATUS_OK) { if (LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND == status) { if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_RRSIG && ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(cur_rr)) == LDNS_RR_TYPE_NSEC3) { ldns_rr_list_push_rr(failed_nsec3_rrsigs, cur_rr); } else { ldns_rr_list_push_rr(failed_nsec3s, cur_rr); } } if (result == LDNS_STATUS_OK) { result = status; } } } if (ldns_rr_list_rr_count(failed_nsec3s) > 0) { (void) ldns_dnssec_zone_add_empty_nonterminals(dnssec_zone); for (i = 0; i < ldns_rr_list_rr_count(failed_nsec3s); i++) { cur_rr = ldns_rr_list_rr(failed_nsec3s, i); status = ldns_dnssec_zone_add_rr(dnssec_zone, ldns_rr_clone(cur_rr)); if (result == LDNS_STATUS_OK) { result = status; } } for (i = 0; i < ldns_rr_list_rr_count(failed_nsec3_rrsigs); i++) { cur_rr = ldns_rr_list_rr(failed_nsec3_rrsigs, i); status = ldns_dnssec_zone_add_rr(dnssec_zone, ldns_rr_clone(cur_rr)); if (result == LDNS_STATUS_OK) { result = status; } } } ldns_rr_list_free(failed_nsec3_rrsigs); ldns_rr_list_free(failed_nsec3s); RETVAL = result; OUTPUT: RETVAL void print(zone, fp) DNS__LDNS__DNSSecZone zone; FILE* fp; CODE: ldns_dnssec_zone_print(fp, zone); LDNS_Status ldns_dnssec_zone_add_rr(zone, rr) DNS__LDNS__DNSSecZone zone; DNS__LDNS__RR rr; ALIAS: _add_rr = 1 LDNS_Status ldns_dnssec_zone_add_empty_nonterminals(zone) DNS__LDNS__DNSSecZone zone; ALIAS: _add_empty_nonterminals = 1 LDNS_Status ldns_dnssec_zone_mark_glue(zone) DNS__LDNS__DNSSecZone zone; ALIAS: _mark_glue = 1 DNS__LDNS__DNSSecName _soa(zone) DNS__LDNS__DNSSecZone zone; CODE: RETVAL = zone->soa; OUTPUT: RETVAL DNS__LDNS__RBTree _names(zone) DNS__LDNS__DNSSecZone zone; CODE: RETVAL = zone->names; OUTPUT: RETVAL DNS__LDNS__DNSSecRRSets ldns_dnssec_zone_find_rrset(zone, rdf, type) DNS__LDNS__DNSSecZone zone; DNS__LDNS__RData rdf; LDNS_RR_Type type; ALIAS: _find_rrset = 1 LDNS_Status _sign(zone, key_list, policy, flags) DNS__LDNS__DNSSecZone zone; DNS__LDNS__KeyList key_list; uint16_t policy; int flags; PREINIT: ldns_rr_list * new_rrs; CODE: new_rrs = ldns_rr_list_new(); RETVAL = ldns_dnssec_zone_sign_flg(zone, new_rrs, key_list, sign_policy, (void*)&policy, flags); ldns_rr_list_free(new_rrs); OUTPUT: RETVAL LDNS_Status _sign_nsec3(zone, key_list, policy, algorithm, flags, iterations, salt, signflags) DNS__LDNS__DNSSecZone zone; DNS__LDNS__KeyList key_list; uint16_t policy; uint8_t algorithm; uint8_t flags; uint16_t iterations; char * salt; int signflags; PREINIT: ldns_rr_list * new_rrs; CODE: new_rrs = ldns_rr_list_new(); RETVAL = ldns_dnssec_zone_sign_nsec3_flg(zone, new_rrs, key_list, sign_policy, (void*)&policy, algorithm, flags, iterations, strlen(salt), (uint8_t*)salt, signflags); ldns_rr_list_free(new_rrs); OUTPUT: RETVAL LDNS_Status create_nsecs(zone) DNS__LDNS__DNSSecZone zone; PREINIT: ldns_rr_list * new_rrs; CODE: new_rrs = ldns_rr_list_new(); RETVAL = ldns_dnssec_zone_create_nsecs(zone, new_rrs); ldns_rr_list_free(new_rrs); OUTPUT: RETVAL LDNS_Status create_nsec3s(zone, algorithm, flags, iterations, salt) DNS__LDNS__DNSSecZone zone; uint8_t algorithm; uint8_t flags; uint8_t iterations; char * salt; PREINIT: ldns_rr_list * new_rrs; CODE: new_rrs = ldns_rr_list_new(); RETVAL = ldns_dnssec_zone_create_nsec3s(zone, new_rrs, algorithm, flags, iterations, strlen(salt), (uint8_t*)salt); ldns_rr_list_free(new_rrs); OUTPUT: RETVAL LDNS_Status create_rrsigs(zone, key_list, policy, flags) DNS__LDNS__DNSSecZone zone; DNS__LDNS__KeyList key_list; uint16_t policy; int flags; PREINIT: ldns_rr_list * new_rrs; CODE: new_rrs = ldns_rr_list_new(); RETVAL = ldns_dnssec_zone_create_rrsigs_flg(zone, new_rrs, key_list, sign_policy, (void*)&policy, flags); ldns_rr_list_free(new_rrs); OUTPUT: RETVAL MODULE = DNS::LDNS PACKAGE = DNS::LDNS::DNSSecRRSets DNS__LDNS__DNSSecRRs _rrs(rrsets) DNS__LDNS__DNSSecRRSets rrsets; CODE: RETVAL = rrsets->rrs; OUTPUT: RETVAL DNS__LDNS__DNSSecRRs _signatures(rrsets) DNS__LDNS__DNSSecRRSets rrsets; CODE: RETVAL = rrsets->signatures; OUTPUT: RETVAL bool ldns_dnssec_rrsets_contains_type(rrsets, type) DNS__LDNS__DNSSecRRSets rrsets; LDNS_RR_Type type; ALIAS: contains_type = 1 LDNS_RR_Type ldns_dnssec_rrsets_type(rrsets) DNS__LDNS__DNSSecRRSets rrsets; ALIAS: type = 1 LDNS_Status ldns_dnssec_rrsets_set_type(rrsets, type) DNS__LDNS__DNSSecRRSets rrsets; LDNS_RR_Type type; ALIAS: _set_type = 1 DNS__LDNS__DNSSecRRSets _next(rrsets) DNS__LDNS__DNSSecRRSets rrsets; CODE: RETVAL = rrsets->next; OUTPUT: RETVAL LDNS_Status ldns_dnssec_rrsets_add_rr(rrsets, rr) DNS__LDNS__DNSSecRRSets rrsets; DNS__LDNS__RR rr; ALIAS: _add_rr = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::DNSSecRRs DNS__LDNS__DNSSecRRs ldns_dnssec_rrs_new() ALIAS: _new = 1 DNS__LDNS__RR _rr(rrs) DNS__LDNS__DNSSecRRs rrs; CODE: RETVAL = rrs->rr; OUTPUT: RETVAL DNS__LDNS__DNSSecRRs _next(rrs) DNS__LDNS__DNSSecRRs rrs; CODE: RETVAL = rrs->next; OUTPUT: RETVAL LDNS_Status ldns_dnssec_rrs_add_rr(rrs, rr) DNS__LDNS__DNSSecRRs rrs; DNS__LDNS__RR rr; ALIAS: _add_rr = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::DNSSecName DNS__LDNS__DNSSecName ldns_dnssec_name_new() ALIAS: _new = 1 DNS__LDNS__RData ldns_dnssec_name_name(name) DNS__LDNS__DNSSecName name; ALIAS: _name = 1 bool ldns_dnssec_name_is_glue(name) DNS__LDNS__DNSSecName name; ALIAS: is_glue = 1 DNS__LDNS__DNSSecRRSets _rrsets(name) DNS__LDNS__DNSSecName name; CODE: RETVAL = name->rrsets; OUTPUT: RETVAL DNS__LDNS__RR _nsec(name) DNS__LDNS__DNSSecName name; CODE: RETVAL = name->nsec; OUTPUT: RETVAL DNS__LDNS__RData _hashed_name(name) DNS__LDNS__DNSSecName name; CODE: RETVAL = name->hashed_name; OUTPUT: RETVAL DNS__LDNS__DNSSecRRs _nsec_signatures(name) DNS__LDNS__DNSSecName name; CODE: RETVAL = name->nsec_signatures; OUTPUT: RETVAL void ldns_dnssec_name_set_name(name, dname) DNS__LDNS__DNSSecName name; DNS__LDNS__RData dname; ALIAS: _set_name = 1 void ldns_dnssec_name_set_nsec(name, nsec) DNS__LDNS__DNSSecName name; DNS__LDNS__RR nsec; ALIAS: _set_nsec = 1 int ldns_dnssec_name_cmp(a, b) DNS__LDNS__DNSSecName a; DNS__LDNS__DNSSecName b; ALIAS: compare = 1 LDNS_Status ldns_dnssec_name_add_rr(name, rr) DNS__LDNS__DNSSecName name; DNS__LDNS__RR rr; ALIAS: _add_rr = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::RBTree DNS__LDNS__RBNode ldns_rbtree_first(tree) DNS__LDNS__RBTree tree; ALIAS: _first = 1 DNS__LDNS__RBNode ldns_rbtree_last(tree) DNS__LDNS__RBTree tree; ALIAS: _last = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::RBNode DNS__LDNS__RBNode ldns_rbtree_next(node) DNS__LDNS__RBNode node; ALIAS: _next = 1 DNS__LDNS__RBNode ldns_rbtree_previous(node) DNS__LDNS__RBNode node; ALIAS: _previous = 1 DNS__LDNS__RBNode ldns_dnssec_name_node_next_nonglue(node) DNS__LDNS__RBNode node; ALIAS: _next_nonglue = 1 bool is_null(node) DNS__LDNS__RBNode node; CODE: RETVAL = (node == LDNS_RBTREE_NULL); OUTPUT: RETVAL DNS__LDNS__DNSSecName _name(node) DNS__LDNS__RBNode node; CODE: RETVAL = (ldns_dnssec_name*)node->data; OUTPUT: RETVAL MODULE = DNS::LDNS PACKAGE = DNS::LDNS::Resolver DNS__LDNS__Resolver _new_from_file(fp, s) FILE* fp; LDNS_Status s; PREINIT: ldns_resolver *r; CODE: RETVAL = NULL; s = ldns_resolver_new_frm_fp(&r, fp); if (s == LDNS_STATUS_OK) { RETVAL = r; } OUTPUT: RETVAL s DNS__LDNS__Resolver ldns_resolver_new() ALIAS: _new = 1 bool ldns_resolver_dnssec(resolver) DNS__LDNS__Resolver resolver; ALIAS: dnssec = 1 void ldns_resolver_set_dnssec(resolver, d) DNS__LDNS__Resolver resolver; bool d; ALIAS: set_dnssec = 1 bool ldns_resolver_dnssec_cd(resolver) DNS__LDNS__Resolver resolver; ALIAS: dnssec_cd = 1 void ldns_resolver_set_dnssec_cd(resolver, d) DNS__LDNS__Resolver resolver; bool d; ALIAS: set_dnssec_cd = 1 uint16_t ldns_resolver_port(resolver) DNS__LDNS__Resolver resolver; ALIAS: port = 1 void ldns_resolver_set_port(resolver, port) DNS__LDNS__Resolver resolver; uint16_t port; ALIAS: set_port = 1 bool ldns_resolver_recursive(resolver) DNS__LDNS__Resolver resolver; ALIAS: recursive = 1 void ldns_resolver_set_recursive(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_recursive = 1 bool ldns_resolver_debug(resolver) DNS__LDNS__Resolver resolver; ALIAS: debug = 1 void ldns_resolver_set_debug(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_debug = 1 uint8_t ldns_resolver_retry(resolver) DNS__LDNS__Resolver resolver; ALIAS: retry = 1 void ldns_resolver_set_retry(resolver, re) DNS__LDNS__Resolver resolver; uint8_t re; ALIAS: set_retry = 1 uint8_t ldns_resolver_retrans(resolver) DNS__LDNS__Resolver resolver; ALIAS: retrans = 1 void ldns_resolver_set_retrans(resolver, re) DNS__LDNS__Resolver resolver; uint8_t re; ALIAS: set_retrans = 1 bool ldns_resolver_fallback(resolver) DNS__LDNS__Resolver resolver; ALIAS: fallback = 1 void ldns_resolver_set_fallback(resolver, f) DNS__LDNS__Resolver resolver; bool f; ALIAS: set_fallback = 1 uint8_t ldns_resolver_ip6(resolver) DNS__LDNS__Resolver resolver; ALIAS: ip6 = 1 void ldns_resolver_set_ip6(resolver, i) DNS__LDNS__Resolver resolver; uint8_t i; ALIAS: set_ip6 = 1 uint16_t ldns_resolver_edns_udp_size(resolver) DNS__LDNS__Resolver resolver; ALIAS: edns_udp_size = 1 void ldns_resolver_set_edns_udp_size(resolver, s) DNS__LDNS__Resolver resolver; uint16_t s; ALIAS: set_edns_udp_size = 1 bool ldns_resolver_usevc(resolver) DNS__LDNS__Resolver resolver; ALIAS: usevc = 1 void ldns_resolver_set_usevc(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_usevc = 1 bool ldns_resolver_fail(resolver) DNS__LDNS__Resolver resolver; ALIAS: fail = 1 void ldns_resolver_set_fail(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_fail = 1 bool ldns_resolver_defnames(resolver) DNS__LDNS__Resolver resolver; ALIAS: defnames = 1 void ldns_resolver_set_defnames(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_defnames = 1 bool ldns_resolver_dnsrch(resolver) DNS__LDNS__Resolver resolver; ALIAS: dnsrch = 1 void ldns_resolver_set_dnsrch(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_dnsrch = 1 bool ldns_resolver_igntc(resolver) DNS__LDNS__Resolver resolver; ALIAS: igntc = 1 void ldns_resolver_set_igntc(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_igntc = 1 bool ldns_resolver_random(resolver) DNS__LDNS__Resolver resolver; ALIAS: random = 1 void ldns_resolver_set_random(resolver, b) DNS__LDNS__Resolver resolver; bool b; ALIAS: set_random = 1 bool ldns_resolver_trusted_key(resolver, keys, trusted_key) DNS__LDNS__Resolver resolver; DNS__LDNS__RRList keys; DNS__LDNS__RRList trusted_key; ALIAS: trusted_key = 1 DNS__LDNS__RRList ldns_resolver_dnssec_anchors(resolver) DNS__LDNS__Resolver resolver; ALIAS: _dnssec_anchors = 1 void ldns_resolver_set_dnssec_anchors(resolver, list) DNS__LDNS__Resolver resolver; DNS__LDNS__RRList list; ALIAS: _set_dnssec_anchors = 1 void ldns_resolver_push_dnssec_anchor(resolver, rr) DNS__LDNS__Resolver resolver; DNS__LDNS__RR rr; ALIAS: _push_dnssec_anchor = 1 DNS__LDNS__RData ldns_resolver_domain(resolver) DNS__LDNS__Resolver resolver; ALIAS: _domain = 1 void ldns_resolver_set_domain(resolver, rd) DNS__LDNS__Resolver resolver; DNS__LDNS__RData rd; ALIAS: _set_domain = 1 AV * _nameservers(resolver) DNS__LDNS__Resolver resolver; PREINIT: ldns_rdf** list; AV * result; int i; SV * elem; CODE: result = (AV *)sv_2mortal((SV *)newAV()); list = ldns_resolver_nameservers(resolver); /* FIXME: Make a typemap for this ? */ for (i = 0; i < ldns_resolver_nameserver_count(resolver); i++) { elem = newSVpv(0, 0); sv_setref_pv(elem, "LDNS::RData", list[i]); av_push(result, elem); } RETVAL = result; OUTPUT: RETVAL size_t ldns_resolver_nameserver_count(resolver) DNS__LDNS__Resolver resolver; ALIAS: nameserver_count = 1 LDNS_Status ldns_resolver_push_nameserver(resolver, n) DNS__LDNS__Resolver resolver; DNS__LDNS__RData n; ALIAS: _push_nameserver = 1 DNS__LDNS__RData ldns_resolver_pop_nameserver(resolver) DNS__LDNS__Resolver resolver; ALIAS: _pop_nameserver = 1 void ldns_resolver_nameservers_randomize(resolver) DNS__LDNS__Resolver resolver; ALIAS: nameservers_randomize = 1 const char* ldns_resolver_tsig_keyname(resolver) DNS__LDNS__Resolver resolver; ALIAS: tsig_keyname = 1 void ldns_resolver_set_tsig_keyname(resolver, tsig_keyname) DNS__LDNS__Resolver resolver; char* tsig_keyname; ALIAS: set_tsig_keyname = 1 const char* ldns_resolver_tsig_algorithm(resolver) DNS__LDNS__Resolver resolver; ALIAS: tsig_algorithm = 1 void ldns_resolver_set_tsig_algorithm(resolver, tsig_algorithm) DNS__LDNS__Resolver resolver; char* tsig_algorithm; ALIAS: set_tsig_algorithm = 1 const char* ldns_resolver_tsig_keydata(resolver) DNS__LDNS__Resolver resolver; ALIAS: tsig_keydata = 1 void ldns_resolver_set_tsig_keydata(resolver, tsig_keydata) DNS__LDNS__Resolver resolver; char* tsig_keydata; ALIAS: set_tsig_keydata = 1 size_t ldns_resolver_searchlist_count(resolver) DNS__LDNS__Resolver resolver; ALIAS: searchlist_count = 1 void ldns_resolver_push_searchlist(resolver, rd) DNS__LDNS__Resolver resolver; DNS__LDNS__RData rd; ALIAS: _push_searchlist = 1 AV * _searchlist(resolver) DNS__LDNS__Resolver resolver; PREINIT: ldns_rdf** list; AV * result; int i; SV * elem; CODE: result = (AV *)sv_2mortal((SV *)newAV()); list = ldns_resolver_searchlist(resolver); /* FIXME: Make a typemap for this ? */ for (i = 0; i < ldns_resolver_searchlist_count(resolver); i++) { elem = newSVpv(0, 0); sv_setref_pv(elem, "LDNS::RData", list[i]); av_push(result, elem); } RETVAL = result; OUTPUT: RETVAL size_t ldns_resolver_nameserver_rtt(resolver, pos) DNS__LDNS__Resolver resolver; size_t pos; ALIAS: nameserver_rtt = 1 void ldns_resolver_set_nameserver_rtt(resolver, pos, val) DNS__LDNS__Resolver resolver; size_t pos; size_t val; ALIAS: set_nameserver_rtt = 1 AV * _timeout(resolver) DNS__LDNS__Resolver resolver; PREINIT: struct timeval t; AV * result; CODE: t = ldns_resolver_timeout(resolver); result = (AV *)sv_2mortal((SV *)newAV()); av_push(result, newSVuv(t.tv_sec)); av_push(result, newSVuv(t.tv_usec)); RETVAL = result; OUTPUT: RETVAL void set_timeout(resolver, sec, usec) DNS__LDNS__Resolver resolver; uint32_t sec; uint32_t usec; PREINIT: struct timeval t; CODE: t.tv_sec = sec; t.tv_usec = usec; ldns_resolver_set_timeout(resolver, t); void _set_rtt(resolver, rtt) DNS__LDNS__Resolver resolver; AV * rtt; PREINIT: size_t *buff; int i; SV** elem; CODE: buff = malloc(sizeof(size_t)*(av_len(rtt)+1)); for (i = 0; i <= av_len(rtt); i++) { elem = av_fetch(rtt, i, 0); buff[i] = SvUV(*elem); } ldns_resolver_set_rtt(resolver, buff); AV * _rtt(resolver) DNS__LDNS__Resolver resolver; PREINIT: int i; size_t *rtt; AV * result; CODE: result = (AV *)sv_2mortal((SV *)newAV()); rtt = ldns_resolver_rtt(resolver); for (i = 0; i < ldns_resolver_nameserver_count(resolver); i++) { av_push(result, newSVuv(rtt[i])); } RETVAL = result; OUTPUT: RETVAL DNS__LDNS__RRList ldns_validate_domain_ds(resolver, domain, keys) DNS__LDNS__Resolver resolver; DNS__LDNS__RData domain; DNS__LDNS__RRList keys; ALIAS: validate_domain_ds = 1 DNS__LDNS__RRList ldns_validate_domain_ds_time(resolver, domain, keys, check_time) DNS__LDNS__Resolver resolver; DNS__LDNS__RData domain; DNS__LDNS__RRList keys; time_t check_time; ALIAS: validate_domain_ds_time = 1 DNS__LDNS__RRList ldns_validate_domain_dnskey(resolver, domain, keys) DNS__LDNS__Resolver resolver; DNS__LDNS__RData domain; DNS__LDNS__RRList keys; ALIAS: validate_domain_dnskey = 1 DNS__LDNS__RRList ldns_validate_domain_dnskey_time(resolver, domain, keys, check_time) DNS__LDNS__Resolver resolver; DNS__LDNS__RData domain; DNS__LDNS__RRList keys; time_t check_time; ALIAS: validate_domain_dnskey_time = 1 LDNS_Status ldns_verify_trusted(resolver, rrset, rrsigs, validating_keys) DNS__LDNS__Resolver resolver; DNS__LDNS__RRList rrset; DNS__LDNS__RRList rrsigs; DNS__LDNS__RRList validating_keys; ALIAS: _verify_trusted = 1 LDNS_Status ldns_verify_trusted_time(resolver, rrset, rrsigs, check_time, validating_keys) DNS__LDNS__Resolver resolver; DNS__LDNS__RRList rrset; DNS__LDNS__RRList rrsigs; time_t check_time; DNS__LDNS__RRList validating_keys; ALIAS: _verify_trusted_time = 1 DNS__LDNS__RRList _fetch_valid_domain_keys(resolver, domain, keys, s) DNS__LDNS__Resolver resolver; DNS__LDNS__RData domain; DNS__LDNS__RRList keys; LDNS_Status s; PREINIT: DNS__LDNS__RRList trusted; DNS__LDNS__RRList ret; size_t i; CODE: RETVAL = NULL; trusted = ldns_fetch_valid_domain_keys(resolver, domain, keys, &s); if (s == LDNS_STATUS_OK) { RETVAL = ldns_rr_list_clone(trusted); ldns_rr_list_free(trusted); } OUTPUT: RETVAL s DNS__LDNS__RRList _fetch_valid_domain_keys_time(resolver, domain, keys, check_time, s) DNS__LDNS__Resolver resolver; DNS__LDNS__RData domain; DNS__LDNS__RRList keys; time_t check_time; LDNS_Status s; PREINIT: DNS__LDNS__RRList trusted; DNS__LDNS__RRList ret; size_t i; CODE: RETVAL = NULL; trusted = ldns_fetch_valid_domain_keys_time( resolver, domain, keys, check_time, &s); if (s == LDNS_STATUS_OK) { RETVAL = ldns_rr_list_clone(trusted); ldns_rr_list_free(trusted); } OUTPUT: RETVAL s DNS__LDNS__Packet ldns_resolver_query(resolver, name, type, class, flags) DNS__LDNS__Resolver resolver; DNS__LDNS__RData name; LDNS_RR_Type type; LDNS_RR_Class class; uint16_t flags; ALIAS: query = 1 DNS__LDNS__Packet _send(resolver, name, type, class, flags, s) DNS__LDNS__Resolver resolver; DNS__LDNS__RData name; LDNS_RR_Type type; LDNS_RR_Class class; uint16_t flags; LDNS_Status s; PREINIT: DNS__LDNS__Packet packet; CODE: s = ldns_resolver_send(&packet, resolver, name, type, class, flags); if (s == LDNS_STATUS_OK) { RETVAL = packet; } OUTPUT: RETVAL s DNS__LDNS__Packet _send_pkt(resolver, packet, s) DNS__LDNS__Resolver resolver; DNS__LDNS__Packet packet; LDNS_Status s; PREINIT: DNS__LDNS__Packet answer; CODE: s = ldns_resolver_send_pkt(&answer, resolver, packet); if (s == LDNS_STATUS_OK) { RETVAL = answer; } OUTPUT: RETVAL s DNS__LDNS__Packet _prepare_query_pkt(resolver, name, type, class, flags, s) DNS__LDNS__Resolver resolver; DNS__LDNS__RData name; LDNS_RR_Type type; LDNS_RR_Class class; uint16_t flags; LDNS_Status s; PREINIT: DNS__LDNS__Packet packet; CODE: s = ldns_resolver_prepare_query_pkt(&packet, resolver, name, type, class, flags); if (s == LDNS_STATUS_OK) { RETVAL = packet; } OUTPUT: RETVAL s DNS__LDNS__Packet ldns_resolver_search(resolver, name, type, class, flags) DNS__LDNS__Resolver resolver; DNS__LDNS__RData name; LDNS_RR_Type type; LDNS_RR_Class class; uint16_t flags; ALIAS: search = 1 DNS__LDNS__DNSSecDataChain build_data_chain(res, qflags, data_set, pkt, orig_rr) DNS__LDNS__Resolver res; uint16_t qflags; DNS__LDNS__RRList data_set; DNS__LDNS__Packet pkt; DNS__LDNS__RR__Opt orig_rr; CODE: RETVAL = ldns_dnssec_build_data_chain(res, qflags, data_set, pkt, orig_rr); OUTPUT: RETVAL DNS__LDNS__RRList ldns_get_rr_list_addr_by_name(res, name, class, flags) DNS__LDNS__Resolver res; DNS__LDNS__RData name; LDNS_RR_Class class; uint16_t flags; ALIAS: get_rr_list_addr_by_name = 1 DNS__LDNS__RRList ldns_get_rr_list_name_by_addr(res, addr, class, flags) DNS__LDNS__Resolver res; DNS__LDNS__RData addr; LDNS_RR_Class class; uint16_t flags; ALIAS: get_rr_list_addr_by_addr = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::Packet Mortal_PV ldns_pkt2str(pkt) DNS__LDNS__Packet pkt; ALIAS: to_string = 1 DNS__LDNS__RRList ldns_pkt_question(pkt) DNS__LDNS__Packet pkt; ALIAS: _question = 1 void ldns_pkt_set_question(pkt, l) DNS__LDNS__Packet pkt; DNS__LDNS__RRList l; ALIAS: _set_question = 1 DNS__LDNS__RRList ldns_pkt_answer(pkt) DNS__LDNS__Packet pkt; ALIAS: _answer = 1 void ldns_pkt_set_answer(pkt, l) DNS__LDNS__Packet pkt; DNS__LDNS__RRList l; ALIAS: _set_answer = 1 DNS__LDNS__RRList ldns_pkt_authority(pkt) DNS__LDNS__Packet pkt; ALIAS: _authority = 1 void ldns_pkt_set_authority(pkt, l) DNS__LDNS__Packet pkt; DNS__LDNS__RRList l; ALIAS: _set_authority = 1 DNS__LDNS__RRList ldns_pkt_additional(pkt) DNS__LDNS__Packet pkt; ALIAS: _additional = 1 void ldns_pkt_set_additional(pkt, l) DNS__LDNS__Packet pkt; DNS__LDNS__RRList l; ALIAS: _set_additional = 1 DNS__LDNS__RRList ldns_pkt_all(pkt) DNS__LDNS__Packet pkt; ALIAS: all = 1 DNS__LDNS__RRList ldns_pkt_all_noquestion(pkt) DNS__LDNS__Packet pkt; ALIAS: all_noquestion = 1 signed char ldns_pkt_qr(pkt) DNS__LDNS__Packet pkt; ALIAS: qr = 1 void ldns_pkt_set_qr(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_qr = 1 signed char ldns_pkt_aa(pkt) DNS__LDNS__Packet pkt; ALIAS: aa = 1 void ldns_pkt_set_aa(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_aa = 1 signed char ldns_pkt_tc(pkt) DNS__LDNS__Packet pkt; ALIAS: tc = 1 void ldns_pkt_set_tc(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_tc = 1 signed char ldns_pkt_rd(pkt) DNS__LDNS__Packet pkt; ALIAS: rd = 1 void ldns_pkt_set_rd(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_rd = 1 bool ldns_pkt_cd(pkt) DNS__LDNS__Packet pkt; ALIAS: cd = 1 void ldns_pkt_set_cd(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_cd = 1 signed char ldns_pkt_ra(pkt) DNS__LDNS__Packet pkt; ALIAS: ra = 1 void ldns_pkt_set_ra(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_ra = 1 signed char ldns_pkt_ad(pkt) DNS__LDNS__Packet pkt; ALIAS: ad = 1 void ldns_pkt_set_ad(pkt, b) DNS__LDNS__Packet pkt; signed char b; ALIAS: set_ad = 1 uint16_t ldns_pkt_id(pkt) DNS__LDNS__Packet pkt; ALIAS: id = 1 void ldns_pkt_set_id(pkt, id) DNS__LDNS__Packet pkt; uint16_t id; ALIAS: set_id = 1 void ldns_pkt_set_random_id(pkt) DNS__LDNS__Packet pkt; ALIAS: set_random_id = 1 uint16_t ldns_pkt_qdcount(pkt) DNS__LDNS__Packet pkt; ALIAS: qdcount = 1 uint16_t ldns_pkt_ancount(pkt) DNS__LDNS__Packet pkt; ALIAS: ancount = 1 uint16_t ldns_pkt_nscount(pkt) DNS__LDNS__Packet pkt; ALIAS: nscount = 1 uint16_t ldns_pkt_arcount(pkt) DNS__LDNS__Packet pkt; ALIAS: arcount = 1 LDNS_Pkt_Opcode ldns_pkt_get_opcode(pkt) DNS__LDNS__Packet pkt; ALIAS: opcode = 1 void ldns_pkt_set_opcode(pkt, c) DNS__LDNS__Packet pkt; LDNS_Pkt_Opcode c; ALIAS: set_opcode = 1 uint8_t ldns_pkt_get_rcode(pkt) DNS__LDNS__Packet pkt; ALIAS: rcode = 1 void ldns_pkt_set_rcode(pkt, r) DNS__LDNS__Packet pkt; uint8_t r; ALIAS: set_rcode = 1 size_t ldns_pkt_size(pkt) DNS__LDNS__Packet pkt; ALIAS: size = 1 uint32_t ldns_pkt_querytime(pkt) DNS__LDNS__Packet pkt; ALIAS: querytime = 1 void ldns_pkt_set_querytime(pkt, t) DNS__LDNS__Packet pkt; uint32_t t; ALIAS: set_querytime = 1 DNS__LDNS__RData ldns_pkt_answerfrom(pkt) DNS__LDNS__Packet pkt; ALIAS: _answerfrom = 1 AV * _timestamp(pkt) DNS__LDNS__Packet pkt; PREINIT: struct timeval t; AV * result; CODE: t = ldns_pkt_timestamp(pkt); result = (AV *)sv_2mortal((SV *)newAV()); av_push(result, newSVuv(t.tv_sec)); av_push(result, newSVuv(t.tv_usec)); RETVAL = result; OUTPUT: RETVAL void set_timestamp(pkt, sec, usec) DNS__LDNS__Packet pkt; uint32_t sec; uint32_t usec; PREINIT: struct timeval t; CODE: t.tv_sec = sec; t.tv_usec = usec; ldns_pkt_set_timestamp(pkt, t); void ldns_pkt_set_answerfrom(pkt, a) DNS__LDNS__Packet pkt; DNS__LDNS__RData a; ALIAS: _set_answerfrom = 1 bool ldns_pkt_set_flags(pkt, f) DNS__LDNS__Packet pkt; uint16_t f; ALIAS: set_flags = 1 DNS__LDNS__RRList ldns_pkt_rr_list_by_name(pkt, name, sec) DNS__LDNS__Packet pkt; DNS__LDNS__RData name; LDNS_Pkt_Section sec; ALIAS: rr_list_by_name = 1 DNS__LDNS__RRList ldns_pkt_rr_list_by_type(pkt, type, sec) DNS__LDNS__Packet pkt; LDNS_RR_Type type; LDNS_Pkt_Section sec; ALIAS: rr_list_by_type = 1 DNS__LDNS__RRList ldns_pkt_rr_list_by_name_and_type(pkt, name, type, sec) DNS__LDNS__Packet pkt; DNS__LDNS__RData name; LDNS_RR_Type type; LDNS_Pkt_Section sec; ALIAS: rr_list_by_name_and_type = 1 bool ldns_pkt_rr(pkt, sec, rr) DNS__LDNS__Packet pkt; LDNS_Pkt_Section sec; DNS__LDNS__RR rr; ALIAS: rr = 1 bool ldns_pkt_push_rr(pkt, sec, rr) DNS__LDNS__Packet pkt; LDNS_Pkt_Section sec; DNS__LDNS__RR rr; ALIAS: _push_rr = 1 bool ldns_pkt_safe_push_rr(pkt, sec, rr) DNS__LDNS__Packet pkt; LDNS_Pkt_Section sec; DNS__LDNS__RR rr; ALIAS: _safe_push_rr = 1 uint16_t ldns_pkt_section_count(pkt, sec) DNS__LDNS__Packet pkt; LDNS_Pkt_Section sec; ALIAS: section_count = 1 signed char ldns_pkt_empty(pkt) DNS__LDNS__Packet pkt; ALIAS: empty = 1 DNS__LDNS__RR ldns_pkt_tsig(pkt) DNS__LDNS__Packet pkt; ALIAS: _tsig = 1 void ldns_pkt_set_tsig(pkt, rr) DNS__LDNS__Packet pkt; DNS__LDNS__RR rr; ALIAS: _set_tsig = 1 DNS__LDNS__Packet ldns_pkt_clone(pkt) DNS__LDNS__Packet pkt; ALIAS: clone = 1 LDNS_Pkt_Type ldns_pkt_reply_type(pkt) DNS__LDNS__Packet pkt; ALIAS: reply_type = 1 DNS__LDNS__Packet ldns_pkt_new() ALIAS: _new = 1 DNS__LDNS__Packet ldns_pkt_query_new(name, type, class, flags) DNS__LDNS__RData name; LDNS_RR_Type type; LDNS_RR_Class class; uint16_t flags; ALIAS: _query_new = 1 DNS__LDNS__RRList ldns_dnssec_pkt_get_rrsigs_for_name_and_type(pkt, name, type) DNS__LDNS__Packet pkt; DNS__LDNS__RData name; LDNS_RR_Type type; ALIAS: get_rrsigs_for_name_and_type = 1 DNS__LDNS__RRList ldns_dnssec_pkt_get_rrsigs_for_type(pkt, type) DNS__LDNS__Packet pkt; LDNS_RR_Type type; ALIAS: get_rrsigs_for_type = 1 uint16_t ldns_pkt_edns_udp_size(pkt) DNS__LDNS__Packet pkt; ALIAS: edns_udp_size = 1 void ldns_pkt_set_edns_udp_size(pkt, s) DNS__LDNS__Packet pkt; uint16_t s; ALIAS: set_edns_udp_size = 1 uint8_t ldns_pkt_edns_extended_rcode(pkt) DNS__LDNS__Packet pkt; ALIAS: edns_extended_rcode = 1 void ldns_pkt_set_edns_extended_rcode(pkt, c) DNS__LDNS__Packet pkt; uint8_t c; ALIAS: set_edns_extended_rcode = 1 uint8_t ldns_pkt_edns_version(pkt) DNS__LDNS__Packet pkt; ALIAS: edns_version = 1 void ldns_pkt_set_edns_version(pkt, v) DNS__LDNS__Packet pkt; uint8_t v; ALIAS: set_edns_version = 1 uint16_t ldns_pkt_edns_z(pkt) DNS__LDNS__Packet pkt; ALIAS: edns_z = 1 void ldns_pkt_set_edns_z(pkt, z) DNS__LDNS__Packet pkt; uint16_t z; ALIAS: set_edns_z = 1 signed char ldns_pkt_edns_do(pkt) DNS__LDNS__Packet pkt; ALIAS: edns_do = 1 DNS__LDNS__RData ldns_pkt_edns_data(pkt) DNS__LDNS__Packet pkt; ALIAS: _edns_data = 1 void ldns_pkt_set_edns_data(pkt, data) DNS__LDNS__Packet pkt; DNS__LDNS__RData data; ALIAS: _set_edns_data = 1 void ldns_pkt_set_edns_do(pkt, val) DNS__LDNS__Packet pkt; signed char val; ALIAS: set_edns_do = 1 bool ldns_pkt_edns(pkt) DNS__LDNS__Packet pkt; ALIAS: edns = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::Key DNS__LDNS__Key _new_from_file(fp, line_nr, s) FILE* fp; int line_nr; LDNS_Status s; PREINIT: ldns_key *key; CODE: RETVAL = NULL; s = ldns_key_new_frm_fp_l(&key, fp, &line_nr); if (s == LDNS_STATUS_OK) { RETVAL = key; } OUTPUT: RETVAL s line_nr DNS__LDNS__Key ldns_key_new() ALIAS: _new = 1 void print(key, fp) DNS__LDNS__Key key; FILE* fp; CODE: ldns_key_print(fp, key); Mortal_PV ldns_key2str(key) DNS__LDNS__Key key; ALIAS: to_string = 1 void ldns_key_set_algorithm(key, algorithm) DNS__LDNS__Key key; LDNS_Signing_Algorithm algorithm; ALIAS: set_algorithm = 1 LDNS_Signing_Algorithm ldns_key_algorithm(key) DNS__LDNS__Key key; ALIAS: algorithm = 1 void ldns_key_set_flags(key, flags) DNS__LDNS__Key key; uint16_t flags; ALIAS: set_flags = 1 uint16_t ldns_key_flags(key) DNS__LDNS__Key key; ALIAS: flags = 1 void ldns_key_set_hmac_key(key, hmac) DNS__LDNS__Key key; unsigned char* hmac; ALIAS: set_hmac_key = 1 unsigned char * ldns_key_hmac_key(key) DNS__LDNS__Key key; ALIAS: hmac_key = 1 void ldns_key_set_hmac_size(key, size) DNS__LDNS__Key key; size_t size; ALIAS: set_hmac_size = 1 size_t ldns_key_hmac_size(key) DNS__LDNS__Key key; ALIAS: hmac_size = 1 void ldns_key_set_origttl(key, t) DNS__LDNS__Key key; uint32_t t; ALIAS: set_origttl = 1 uint32_t ldns_key_origttl(key) DNS__LDNS__Key key; ALIAS: origttl = 1 void ldns_key_set_inception(key, i) DNS__LDNS__Key key; uint32_t i; ALIAS: set_inception = 1 uint32_t ldns_key_inception(key) DNS__LDNS__Key key; ALIAS: inception = 1 void ldns_key_set_expiration(key, e) DNS__LDNS__Key key; uint32_t e; ALIAS: set_expiration = 1 uint32_t ldns_key_expiration(key) DNS__LDNS__Key key; ALIAS: expiration = 1 void ldns_key_set_pubkey_owner(key, r) DNS__LDNS__Key key; DNS__LDNS__RData r; ALIAS: _set_pubkey_owner = 1 DNS__LDNS__RData ldns_key_pubkey_owner(key) DNS__LDNS__Key key; ALIAS: _pubkey_owner = 1 void ldns_key_set_keytag(key, tag) DNS__LDNS__Key key; uint16_t tag; ALIAS: set_keytag = 1 uint16_t ldns_key_keytag(key) DNS__LDNS__Key key; ALIAS: keytag = 1 void ldns_key_set_use(key, v) DNS__LDNS__Key key; signed char v; ALIAS: set_use = 1 signed char ldns_key_use(key) DNS__LDNS__Key key; ALIAS: use = 1 char * ldns_key_get_file_base_name(key) DNS__LDNS__Key key; ALIAS: get_file_base_name = 1 DNS__LDNS__RR ldns_key2rr(key) DNS__LDNS__Key key; ALIAS: to_rr = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::KeyList DNS__LDNS__KeyList ldns_key_list_new() ALIAS: _new = 1 void ldns_key_list_set_use(keys, v) DNS__LDNS__KeyList keys; bool v; ALIAS: set_use = 1 DNS__LDNS__Key ldns_key_list_pop_key(keylist) DNS__LDNS__KeyList keylist; ALIAS: pop = 1 void ldns_key_list_push_key(keylist, key) DNS__LDNS__KeyList keylist; DNS__LDNS__Key key; ALIAS: _push = 1 size_t ldns_key_list_key_count(keylist) DNS__LDNS__KeyList keylist; ALIAS: count = 1 DNS__LDNS__Key ldns_key_list_key(keylist, nr) DNS__LDNS__KeyList keylist; size_t nr; ALIAS: _key = 1 MODULE = DNS::LDNS PACKAGE = DNS::LDNS::DNSSecDataChain DNS__LDNS__DNSSecDataChain ldns_dnssec_data_chain_new() ALIAS: _new = 1 void print(chain, fp) DNS__LDNS__DNSSecDataChain chain; FILE* fp; CODE: ldns_dnssec_data_chain_print(fp, chain); DNS__LDNS__DNSSecTrustTree ldns_dnssec_derive_trust_tree(chain, rr) DNS__LDNS__DNSSecDataChain chain; DNS__LDNS__RR rr; ALIAS: _derive_trust_tree = 1 DNS__LDNS__DNSSecTrustTree ldns_dnssec_derive_trust_tree_time(chain, rr, check_time) DNS__LDNS__DNSSecDataChain chain; DNS__LDNS__RR rr; time_t check_time; ALIAS: _derive_trust_tree_time = 1 DNS__LDNS__RRList _rrset(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->rrset; OUTPUT: RETVAL DNS__LDNS__RRList _signatures(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->signatures; OUTPUT: RETVAL LDNS_RR_Type parent_type(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->parent_type; OUTPUT: RETVAL DNS__LDNS__DNSSecDataChain _parent(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->parent; OUTPUT: RETVAL LDNS_Pkt_Rcode packet_rcode(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->packet_rcode; OUTPUT: RETVAL LDNS_RR_Type packet_qtype(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->packet_qtype; OUTPUT: RETVAL signed char packet_nodata(chain) DNS__LDNS__DNSSecDataChain chain; CODE: RETVAL = chain->packet_nodata; OUTPUT: RETVAL MODULE = DNS::LDNS PACKAGE = DNS::LDNS::DNSSecTrustTree DNS__LDNS__DNSSecTrustTree ldns_dnssec_trust_tree_new() ALIAS: _new = 1 void print(tree, fp, tabs, extended) DNS__LDNS__DNSSecTrustTree tree; FILE* fp; size_t tabs; bool extended; CODE: ldns_dnssec_trust_tree_print(fp, tree, tabs, extended); size_t ldns_dnssec_trust_tree_depth(tree) DNS__LDNS__DNSSecTrustTree tree; ALIAS: depth = 1 LDNS_Status ldns_dnssec_trust_tree_add_parent(tree, parent, signature, parent_status) DNS__LDNS__DNSSecTrustTree tree; DNS__LDNS__DNSSecTrustTree parent; DNS__LDNS__RR signature; LDNS_Status parent_status; ALIAS: _add_parent = 1 LDNS_Status ldns_dnssec_trust_tree_contains_keys(tree, trusted_keys) DNS__LDNS__DNSSecTrustTree tree; DNS__LDNS__RRList trusted_keys; ALIAS: _contains_keys = 1 DNS__LDNS__RR _rr(tree) DNS__LDNS__DNSSecTrustTree tree; CODE: RETVAL = tree->rr; OUTPUT: RETVAL DNS__LDNS__RRList _rrset(tree) DNS__LDNS__DNSSecTrustTree tree; CODE: RETVAL = tree->rrset; OUTPUT: RETVAL DNS__LDNS__DNSSecTrustTree _parent(tree, i) DNS__LDNS__DNSSecTrustTree tree; size_t i; CODE: RETVAL = tree->parents[i]; OUTPUT: RETVAL LDNS_Status _parent_status(tree, i) DNS__LDNS__DNSSecTrustTree tree; size_t i; CODE: RETVAL = tree->parent_status[i]; OUTPUT: RETVAL DNS__LDNS__RR _parent_signature(tree, i) DNS__LDNS__DNSSecTrustTree tree; size_t i; CODE: RETVAL = tree->parent_signature[i]; OUTPUT: RETVAL size_t parent_count(tree) DNS__LDNS__DNSSecTrustTree tree; CODE: RETVAL = tree->parent_count; OUTPUT: RETVAL ldns-1.9.2/contrib/DNS-LDNS/MANIFEST0000644000175000017500000000124615212267527016016 0ustar willemwillemChanges constants.PL dist.ini LDNS.xs lib/DNS/LDNS.pm lib/DNS/LDNS/DNSSecDataChain.pm lib/DNS/LDNS/DNSSecName.pm lib/DNS/LDNS/DNSSecRRs.pm lib/DNS/LDNS/DNSSecRRSets.pm lib/DNS/LDNS/DNSSecTrustTree.pm lib/DNS/LDNS/DNSSecZone.pm lib/DNS/LDNS/GC.pm lib/DNS/LDNS/Key.pm lib/DNS/LDNS/KeyList.pm lib/DNS/LDNS/Packet.pm lib/DNS/LDNS/RBNode.pm lib/DNS/LDNS/RBTree.pm lib/DNS/LDNS/RData.pm lib/DNS/LDNS/Resolver.pm lib/DNS/LDNS/RR.pm lib/DNS/LDNS/RRList.pm lib/DNS/LDNS/Zone.pm MANIFEST ppport.h README t/dnssec_datachain.t t/dnssec_zone.t t/key.t t/DNS-LDNS.t t/rdata.t t/resolver.t t/rr.t t/rrlist.t t/testdata/key.private t/testdata/myzone.org t/testdata/resolv.conf t/zone.t typemap ldns-1.9.2/contrib/DNS-LDNS/LICENSE0000644000175000017500000000017115212267527015666 0ustar willemwillemThis software is copyright (c) 2013 by UNINETT Norid AS. No license is granted to other entities. All rights reserved. ldns-1.9.2/contrib/DNS-LDNS/lib/0000775000175000017500000000000015212267527015432 5ustar willemwillemldns-1.9.2/contrib/DNS-LDNS/lib/DNS/0000775000175000017500000000000015212267527016056 5ustar willemwillemldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS.pm0000644000175000017500000007213115212267527017156 0ustar willemwillempackage DNS::LDNS; use 5.014002; use strict; use warnings; use Carp; require Exporter; use AutoLoader; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. our %EXPORT_TAGS = ( 'all' => [ qw( LDNS_AA LDNS_AD LDNS_CD LDNS_CERT_ACPKIX LDNS_CERT_IACPKIX LDNS_CERT_IPGP LDNS_CERT_IPKIX LDNS_CERT_ISPKI LDNS_CERT_OID LDNS_CERT_PGP LDNS_CERT_PKIX LDNS_CERT_SPKI LDNS_CERT_URI LDNS_DEFAULT_EXP_TIME LDNS_DEFAULT_TTL LDNS_DH LDNS_DNSSEC_KEYPROTO LDNS_DSA LDNS_DSA_NSEC3 LDNS_ECC LDNS_ECC_GOST LDNS_HASH_GOST LDNS_IP4ADDRLEN LDNS_IP6ADDRLEN LDNS_KEY_REVOKE_KEY LDNS_KEY_SEP_KEY LDNS_KEY_ZONE_KEY LDNS_MAX_DOMAINLEN LDNS_MAX_KEYLEN LDNS_MAX_LABELLEN LDNS_MAX_PACKETLEN LDNS_MAX_POINTERS LDNS_MAX_RDFLEN LDNS_NSEC3_MAX_ITERATIONS LDNS_NSEC3_VARS_OPTOUT_MASK LDNS_PACKET_ANSWER LDNS_PACKET_IQUERY LDNS_PACKET_NODATA LDNS_PACKET_NOTIFY LDNS_PACKET_NXDOMAIN LDNS_PACKET_QUERY LDNS_PACKET_QUESTION LDNS_PACKET_REFERRAL LDNS_PACKET_STATUS LDNS_PACKET_UNKNOWN LDNS_PACKET_UPDATE LDNS_PORT LDNS_PRIVATEDNS LDNS_PRIVATEOID LDNS_QR LDNS_RA LDNS_RCODE_FORMERR LDNS_RCODE_NOERROR LDNS_RCODE_NOTAUTH LDNS_RCODE_NOTIMPL LDNS_RCODE_NOTZONE LDNS_RCODE_NXDOMAIN LDNS_RCODE_NXRRSET LDNS_RCODE_REFUSED LDNS_RCODE_SERVFAIL LDNS_RCODE_YXDOMAIN LDNS_RCODE_YXRRSET LDNS_RD LDNS_RDATA_FIELD_DESCRIPTORS_COMMON LDNS_RDF_SIZE_16BYTES LDNS_RDF_SIZE_6BYTES LDNS_RDF_SIZE_BYTE LDNS_RDF_SIZE_DOUBLEWORD LDNS_RDF_SIZE_WORD LDNS_RDF_TYPE_A LDNS_RDF_TYPE_AAAA LDNS_RDF_TYPE_ALG LDNS_RDF_TYPE_APL LDNS_RDF_TYPE_ATMA LDNS_RDF_TYPE_B32_EXT LDNS_RDF_TYPE_B64 LDNS_RDF_TYPE_CERT_ALG LDNS_RDF_TYPE_CLASS LDNS_RDF_TYPE_DNAME LDNS_RDF_TYPE_HEX LDNS_RDF_TYPE_INT16 LDNS_RDF_TYPE_INT16_DATA LDNS_RDF_TYPE_INT32 LDNS_RDF_TYPE_INT8 LDNS_RDF_TYPE_IPSECKEY LDNS_RDF_TYPE_LOC LDNS_RDF_TYPE_NONE LDNS_RDF_TYPE_NSAP LDNS_RDF_TYPE_NSEC LDNS_RDF_TYPE_NSEC3_NEXT_OWNER LDNS_RDF_TYPE_NSEC3_SALT LDNS_RDF_TYPE_PERIOD LDNS_RDF_TYPE_SERVICE LDNS_RDF_TYPE_STR LDNS_RDF_TYPE_TIME LDNS_RDF_TYPE_HIP LDNS_RDF_TYPE_TSIGTIME LDNS_RDF_TYPE_TYPE LDNS_RDF_TYPE_UNKNOWN LDNS_RDF_TYPE_WKS LDNS_RESOLV_ANCHOR LDNS_RESOLV_DEFDOMAIN LDNS_RESOLV_INET LDNS_RESOLV_INET6 LDNS_RESOLV_INETANY LDNS_RESOLV_KEYWORD LDNS_RESOLV_KEYWORDS LDNS_RESOLV_NAMESERVER LDNS_RESOLV_OPTIONS LDNS_RESOLV_RTT_INF LDNS_RESOLV_RTT_MIN LDNS_RESOLV_SEARCH LDNS_RESOLV_SORTLIST LDNS_RR_CLASS_ANY LDNS_RR_CLASS_CH LDNS_RR_CLASS_COUNT LDNS_RR_CLASS_FIRST LDNS_RR_CLASS_HS LDNS_RR_CLASS_IN LDNS_RR_CLASS_LAST LDNS_RR_CLASS_NONE LDNS_RR_COMPRESS LDNS_RR_NO_COMPRESS LDNS_RR_OVERHEAD LDNS_RR_TYPE_A LDNS_RR_TYPE_A6 LDNS_RR_TYPE_AAAA LDNS_RR_TYPE_AFSDB LDNS_RR_TYPE_ANY LDNS_RR_TYPE_APL LDNS_RR_TYPE_ATMA LDNS_RR_TYPE_AXFR LDNS_RR_TYPE_CERT LDNS_RR_TYPE_CNAME LDNS_RR_TYPE_COUNT LDNS_RR_TYPE_DHCID LDNS_RR_TYPE_DLV LDNS_RR_TYPE_DNAME LDNS_RR_TYPE_DNSKEY LDNS_RR_TYPE_DS LDNS_RR_TYPE_EID LDNS_RR_TYPE_FIRST LDNS_RR_TYPE_GID LDNS_RR_TYPE_GPOS LDNS_RR_TYPE_HINFO LDNS_RR_TYPE_IPSECKEY LDNS_RR_TYPE_ISDN LDNS_RR_TYPE_IXFR LDNS_RR_TYPE_KEY LDNS_RR_TYPE_KX LDNS_RR_TYPE_LAST LDNS_RR_TYPE_LOC LDNS_RR_TYPE_MAILA LDNS_RR_TYPE_MAILB LDNS_RR_TYPE_MB LDNS_RR_TYPE_MD LDNS_RR_TYPE_MF LDNS_RR_TYPE_MG LDNS_RR_TYPE_MINFO LDNS_RR_TYPE_MR LDNS_RR_TYPE_MX LDNS_RR_TYPE_NAPTR LDNS_RR_TYPE_NIMLOC LDNS_RR_TYPE_NS LDNS_RR_TYPE_NSAP LDNS_RR_TYPE_NSAP_PTR LDNS_RR_TYPE_NSEC LDNS_RR_TYPE_NSEC3 LDNS_RR_TYPE_NSEC3PARAM LDNS_RR_TYPE_NSEC3PARAMS LDNS_RR_TYPE_NULL LDNS_RR_TYPE_NXT LDNS_RR_TYPE_OPT LDNS_RR_TYPE_PTR LDNS_RR_TYPE_PX LDNS_RR_TYPE_RP LDNS_RR_TYPE_RRSIG LDNS_RR_TYPE_RT LDNS_RR_TYPE_SIG LDNS_RR_TYPE_SINK LDNS_RR_TYPE_SOA LDNS_RR_TYPE_SPF LDNS_RR_TYPE_SRV LDNS_RR_TYPE_SSHFP LDNS_RR_TYPE_TALINK LDNS_RR_TYPE_TSIG LDNS_RR_TYPE_TXT LDNS_RR_TYPE_UID LDNS_RR_TYPE_UINFO LDNS_RR_TYPE_UNSPEC LDNS_RR_TYPE_WKS LDNS_RR_TYPE_X25 LDNS_RSAMD5 LDNS_RSASHA1 LDNS_RSASHA1_NSEC3 LDNS_RSASHA256 LDNS_RSASHA512 LDNS_SECTION_ADDITIONAL LDNS_SECTION_ANSWER LDNS_SECTION_ANY LDNS_SECTION_ANY_NOQUESTION LDNS_SECTION_AUTHORITY LDNS_SECTION_QUESTION LDNS_SHA1 LDNS_SHA256 LDNS_SIGNATURE_LEAVE_ADD_NEW LDNS_SIGNATURE_LEAVE_NO_ADD LDNS_SIGNATURE_REMOVE_ADD_NEW LDNS_SIGNATURE_REMOVE_NO_ADD LDNS_SIGN_DSA LDNS_SIGN_DSA_NSEC3 LDNS_SIGN_ECC_GOST LDNS_SIGN_HMACSHA1 LDNS_SIGN_HMACSHA256 LDNS_SIGN_RSAMD5 LDNS_SIGN_RSASHA1 LDNS_SIGN_RSASHA1_NSEC3 LDNS_SIGN_RSASHA256 LDNS_SIGN_RSASHA512 LDNS_STATUS_ADDRESS_ERR LDNS_STATUS_CERT_BAD_ALGORITHM LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL LDNS_STATUS_CRYPTO_BOGUS LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION LDNS_STATUS_CRYPTO_NO_DNSKEY LDNS_STATUS_CRYPTO_NO_DS LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY LDNS_STATUS_CRYPTO_NO_RRSIG LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY LDNS_STATUS_CRYPTO_NO_TRUSTED_DS LDNS_STATUS_CRYPTO_SIG_EXPIRED LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED LDNS_STATUS_CRYPTO_TSIG_BOGUS LDNS_STATUS_CRYPTO_TSIG_ERR LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR LDNS_STATUS_CRYPTO_UNKNOWN_ALGO LDNS_STATUS_CRYPTO_VALIDATED LDNS_STATUS_DDD_OVERFLOW LDNS_STATUS_DNSSEC_EXISTENCE_DENIED LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED LDNS_STATUS_DOMAINNAME_OVERFLOW LDNS_STATUS_DOMAINNAME_UNDERFLOW LDNS_STATUS_EMPTY_LABEL LDNS_STATUS_ENGINE_KEY_NOT_LOADED LDNS_STATUS_ERR LDNS_STATUS_FILE_ERR LDNS_STATUS_INTERNAL_ERR LDNS_STATUS_INVALID_B32_EXT LDNS_STATUS_INVALID_B64 LDNS_STATUS_INVALID_HEX LDNS_STATUS_INVALID_INT LDNS_STATUS_INVALID_IP4 LDNS_STATUS_INVALID_IP6 LDNS_STATUS_INVALID_POINTER LDNS_STATUS_INVALID_STR LDNS_STATUS_INVALID_TIME LDNS_STATUS_LABEL_OVERFLOW LDNS_STATUS_MEM_ERR LDNS_STATUS_MISSING_RDATA_FIELDS_KEY LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG LDNS_STATUS_NETWORK_ERR LDNS_STATUS_NOT_IMPL LDNS_STATUS_NO_DATA LDNS_STATUS_NSEC3_ERR LDNS_STATUS_NULL LDNS_STATUS_OK LDNS_STATUS_PACKET_OVERFLOW LDNS_STATUS_RES_NO_NS LDNS_STATUS_RES_QUERY LDNS_STATUS_SOCKET_ERROR LDNS_STATUS_SSL_ERR LDNS_STATUS_SYNTAX_ALG_ERR LDNS_STATUS_SYNTAX_BAD_ESCAPE LDNS_STATUS_SYNTAX_CLASS_ERR LDNS_STATUS_SYNTAX_DNAME_ERR LDNS_STATUS_SYNTAX_EMPTY LDNS_STATUS_SYNTAX_ERR LDNS_STATUS_SYNTAX_INCLUDE LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW LDNS_STATUS_SYNTAX_KEYWORD_ERR LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR LDNS_STATUS_SYNTAX_ORIGIN LDNS_STATUS_SYNTAX_RDATA_ERR LDNS_STATUS_SYNTAX_TTL LDNS_STATUS_SYNTAX_TTL_ERR LDNS_STATUS_SYNTAX_TYPE_ERR LDNS_STATUS_SYNTAX_VERSION_ERR LDNS_STATUS_UNKNOWN_INET LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL LDNS_STATUS_WIRE_INCOMPLETE_ANSWER LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY LDNS_STATUS_WIRE_INCOMPLETE_HEADER LDNS_STATUS_WIRE_INCOMPLETE_QUESTION LDNS_TC dnssec_create_nsec dnssec_create_nsec3 create_nsec create_nsec3 rr_type2str rr_class2str rr_type_by_name rr_class_by_name pkt_opcode2str pkt_rcode2str errorstr_by_id signing_algorithm_by_name key_algorithm_supported read_anchor_file ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( LDNS_AA LDNS_AD LDNS_CD LDNS_CERT_ACPKIX LDNS_CERT_IACPKIX LDNS_CERT_IPGP LDNS_CERT_IPKIX LDNS_CERT_ISPKI LDNS_CERT_OID LDNS_CERT_PGP LDNS_CERT_PKIX LDNS_CERT_SPKI LDNS_CERT_URI LDNS_DEFAULT_EXP_TIME LDNS_DEFAULT_TTL LDNS_DH LDNS_DNSSEC_KEYPROTO LDNS_DSA LDNS_DSA_NSEC3 LDNS_ECC LDNS_ECC_GOST LDNS_HASH_GOST LDNS_IP4ADDRLEN LDNS_IP6ADDRLEN LDNS_KEY_REVOKE_KEY LDNS_KEY_SEP_KEY LDNS_KEY_ZONE_KEY LDNS_MAX_DOMAINLEN LDNS_MAX_KEYLEN LDNS_MAX_LABELLEN LDNS_MAX_PACKETLEN LDNS_MAX_POINTERS LDNS_MAX_RDFLEN LDNS_NSEC3_MAX_ITERATIONS LDNS_NSEC3_VARS_OPTOUT_MASK LDNS_PACKET_ANSWER LDNS_PACKET_IQUERY LDNS_PACKET_NODATA LDNS_PACKET_NOTIFY LDNS_PACKET_NXDOMAIN LDNS_PACKET_QUERY LDNS_PACKET_QUESTION LDNS_PACKET_REFERRAL LDNS_PACKET_STATUS LDNS_PACKET_UNKNOWN LDNS_PACKET_UPDATE LDNS_PORT LDNS_PRIVATEDNS LDNS_PRIVATEOID LDNS_QR LDNS_RA LDNS_RCODE_FORMERR LDNS_RCODE_NOERROR LDNS_RCODE_NOTAUTH LDNS_RCODE_NOTIMPL LDNS_RCODE_NOTZONE LDNS_RCODE_NXDOMAIN LDNS_RCODE_NXRRSET LDNS_RCODE_REFUSED LDNS_RCODE_SERVFAIL LDNS_RCODE_YXDOMAIN LDNS_RCODE_YXRRSET LDNS_RD LDNS_RDATA_FIELD_DESCRIPTORS_COMMON LDNS_RDF_SIZE_16BYTES LDNS_RDF_SIZE_6BYTES LDNS_RDF_SIZE_BYTE LDNS_RDF_SIZE_DOUBLEWORD LDNS_RDF_SIZE_WORD LDNS_RDF_TYPE_A LDNS_RDF_TYPE_AAAA LDNS_RDF_TYPE_ALG LDNS_RDF_TYPE_APL LDNS_RDF_TYPE_ATMA LDNS_RDF_TYPE_B32_EXT LDNS_RDF_TYPE_B64 LDNS_RDF_TYPE_CERT_ALG LDNS_RDF_TYPE_CLASS LDNS_RDF_TYPE_DNAME LDNS_RDF_TYPE_HEX LDNS_RDF_TYPE_INT16 LDNS_RDF_TYPE_INT16_DATA LDNS_RDF_TYPE_INT32 LDNS_RDF_TYPE_INT8 LDNS_RDF_TYPE_IPSECKEY LDNS_RDF_TYPE_LOC LDNS_RDF_TYPE_NONE LDNS_RDF_TYPE_NSAP LDNS_RDF_TYPE_NSEC LDNS_RDF_TYPE_NSEC3_NEXT_OWNER LDNS_RDF_TYPE_NSEC3_SALT LDNS_RDF_TYPE_PERIOD LDNS_RDF_TYPE_SERVICE LDNS_RDF_TYPE_STR LDNS_RDF_TYPE_TIME LDNS_RDF_TYPE_HIP LDNS_RDF_TYPE_TSIGTIME LDNS_RDF_TYPE_TYPE LDNS_RDF_TYPE_UNKNOWN LDNS_RDF_TYPE_WKS LDNS_RESOLV_ANCHOR LDNS_RESOLV_DEFDOMAIN LDNS_RESOLV_INET LDNS_RESOLV_INET6 LDNS_RESOLV_INETANY LDNS_RESOLV_KEYWORD LDNS_RESOLV_KEYWORDS LDNS_RESOLV_NAMESERVER LDNS_RESOLV_OPTIONS LDNS_RESOLV_RTT_INF LDNS_RESOLV_RTT_MIN LDNS_RESOLV_SEARCH LDNS_RESOLV_SORTLIST LDNS_RR_CLASS_ANY LDNS_RR_CLASS_CH LDNS_RR_CLASS_COUNT LDNS_RR_CLASS_FIRST LDNS_RR_CLASS_HS LDNS_RR_CLASS_IN LDNS_RR_CLASS_LAST LDNS_RR_CLASS_NONE LDNS_RR_COMPRESS LDNS_RR_NO_COMPRESS LDNS_RR_OVERHEAD LDNS_RR_TYPE_A LDNS_RR_TYPE_A6 LDNS_RR_TYPE_AAAA LDNS_RR_TYPE_AFSDB LDNS_RR_TYPE_ANY LDNS_RR_TYPE_APL LDNS_RR_TYPE_ATMA LDNS_RR_TYPE_AXFR LDNS_RR_TYPE_CERT LDNS_RR_TYPE_CNAME LDNS_RR_TYPE_COUNT LDNS_RR_TYPE_DHCID LDNS_RR_TYPE_DLV LDNS_RR_TYPE_DNAME LDNS_RR_TYPE_DNSKEY LDNS_RR_TYPE_DS LDNS_RR_TYPE_EID LDNS_RR_TYPE_FIRST LDNS_RR_TYPE_GID LDNS_RR_TYPE_GPOS LDNS_RR_TYPE_HINFO LDNS_RR_TYPE_IPSECKEY LDNS_RR_TYPE_ISDN LDNS_RR_TYPE_IXFR LDNS_RR_TYPE_KEY LDNS_RR_TYPE_KX LDNS_RR_TYPE_LAST LDNS_RR_TYPE_LOC LDNS_RR_TYPE_MAILA LDNS_RR_TYPE_MAILB LDNS_RR_TYPE_MB LDNS_RR_TYPE_MD LDNS_RR_TYPE_MF LDNS_RR_TYPE_MG LDNS_RR_TYPE_MINFO LDNS_RR_TYPE_MR LDNS_RR_TYPE_MX LDNS_RR_TYPE_NAPTR LDNS_RR_TYPE_NIMLOC LDNS_RR_TYPE_NS LDNS_RR_TYPE_NSAP LDNS_RR_TYPE_NSAP_PTR LDNS_RR_TYPE_NSEC LDNS_RR_TYPE_NSEC3 LDNS_RR_TYPE_NSEC3PARAM LDNS_RR_TYPE_NSEC3PARAMS LDNS_RR_TYPE_NULL LDNS_RR_TYPE_NXT LDNS_RR_TYPE_OPT LDNS_RR_TYPE_PTR LDNS_RR_TYPE_PX LDNS_RR_TYPE_RP LDNS_RR_TYPE_RRSIG LDNS_RR_TYPE_RT LDNS_RR_TYPE_SIG LDNS_RR_TYPE_SINK LDNS_RR_TYPE_SOA LDNS_RR_TYPE_SPF LDNS_RR_TYPE_SRV LDNS_RR_TYPE_SSHFP LDNS_RR_TYPE_TALINK LDNS_RR_TYPE_TSIG LDNS_RR_TYPE_TXT LDNS_RR_TYPE_UID LDNS_RR_TYPE_UINFO LDNS_RR_TYPE_UNSPEC LDNS_RR_TYPE_WKS LDNS_RR_TYPE_X25 LDNS_RSAMD5 LDNS_RSASHA1 LDNS_RSASHA1_NSEC3 LDNS_RSASHA256 LDNS_RSASHA512 LDNS_SECTION_ADDITIONAL LDNS_SECTION_ANSWER LDNS_SECTION_ANY LDNS_SECTION_ANY_NOQUESTION LDNS_SECTION_AUTHORITY LDNS_SECTION_QUESTION LDNS_SHA1 LDNS_SHA256 LDNS_SIGNATURE_LEAVE_ADD_NEW LDNS_SIGNATURE_LEAVE_NO_ADD LDNS_SIGNATURE_REMOVE_ADD_NEW LDNS_SIGNATURE_REMOVE_NO_ADD LDNS_SIGN_DSA LDNS_SIGN_DSA_NSEC3 LDNS_SIGN_ECC_GOST LDNS_SIGN_HMACSHA1 LDNS_SIGN_HMACSHA256 LDNS_SIGN_RSAMD5 LDNS_SIGN_RSASHA1 LDNS_SIGN_RSASHA1_NSEC3 LDNS_SIGN_RSASHA256 LDNS_SIGN_RSASHA512 LDNS_STATUS_ADDRESS_ERR LDNS_STATUS_CERT_BAD_ALGORITHM LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL LDNS_STATUS_CRYPTO_BOGUS LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION LDNS_STATUS_CRYPTO_NO_DNSKEY LDNS_STATUS_CRYPTO_NO_DS LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY LDNS_STATUS_CRYPTO_NO_RRSIG LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY LDNS_STATUS_CRYPTO_NO_TRUSTED_DS LDNS_STATUS_CRYPTO_SIG_EXPIRED LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED LDNS_STATUS_CRYPTO_TSIG_BOGUS LDNS_STATUS_CRYPTO_TSIG_ERR LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR LDNS_STATUS_CRYPTO_UNKNOWN_ALGO LDNS_STATUS_CRYPTO_VALIDATED LDNS_STATUS_DDD_OVERFLOW LDNS_STATUS_DNSSEC_EXISTENCE_DENIED LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED LDNS_STATUS_DOMAINNAME_OVERFLOW LDNS_STATUS_DOMAINNAME_UNDERFLOW LDNS_STATUS_EMPTY_LABEL LDNS_STATUS_ENGINE_KEY_NOT_LOADED LDNS_STATUS_ERR LDNS_STATUS_FILE_ERR LDNS_STATUS_INTERNAL_ERR LDNS_STATUS_INVALID_B32_EXT LDNS_STATUS_INVALID_B64 LDNS_STATUS_INVALID_HEX LDNS_STATUS_INVALID_INT LDNS_STATUS_INVALID_IP4 LDNS_STATUS_INVALID_IP6 LDNS_STATUS_INVALID_POINTER LDNS_STATUS_INVALID_STR LDNS_STATUS_INVALID_TIME LDNS_STATUS_LABEL_OVERFLOW LDNS_STATUS_MEM_ERR LDNS_STATUS_MISSING_RDATA_FIELDS_KEY LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG LDNS_STATUS_NETWORK_ERR LDNS_STATUS_NOT_IMPL LDNS_STATUS_NO_DATA LDNS_STATUS_NSEC3_ERR LDNS_STATUS_NULL LDNS_STATUS_OK LDNS_STATUS_PACKET_OVERFLOW LDNS_STATUS_RES_NO_NS LDNS_STATUS_RES_QUERY LDNS_STATUS_SOCKET_ERROR LDNS_STATUS_SSL_ERR LDNS_STATUS_SYNTAX_ALG_ERR LDNS_STATUS_SYNTAX_BAD_ESCAPE LDNS_STATUS_SYNTAX_CLASS_ERR LDNS_STATUS_SYNTAX_DNAME_ERR LDNS_STATUS_SYNTAX_EMPTY LDNS_STATUS_SYNTAX_ERR LDNS_STATUS_SYNTAX_INCLUDE LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW LDNS_STATUS_SYNTAX_KEYWORD_ERR LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR LDNS_STATUS_SYNTAX_ORIGIN LDNS_STATUS_SYNTAX_RDATA_ERR LDNS_STATUS_SYNTAX_TTL LDNS_STATUS_SYNTAX_TTL_ERR LDNS_STATUS_SYNTAX_TYPE_ERR LDNS_STATUS_SYNTAX_VERSION_ERR LDNS_STATUS_UNKNOWN_INET LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL LDNS_STATUS_WIRE_INCOMPLETE_ANSWER LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY LDNS_STATUS_WIRE_INCOMPLETE_HEADER LDNS_STATUS_WIRE_INCOMPLETE_QUESTION LDNS_TC dnssec_create_nsec dnssec_create_nsec3 create_nsec create_nsec3 rr_type2str rr_class2str pkt_opcode2str pkt_rcode2str rr_type_by_name rr_class_by_name errorstr_by_id signing_algorithm_by_name key_algorithm_supported read_anchor_file ); our $VERSION = '0.61'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. my $constname; our $AUTOLOAD; ($constname = $AUTOLOAD) =~ s/.*:://; croak "&DNS::LDNS::constant not defined" if $constname eq 'constant'; my ($error, $val) = constant($constname); if ($error) { croak $error; } { no strict 'refs'; # Fixed between 5.005_53 and 5.005_61 #XXX if ($] >= 5.00561) { #XXX *$AUTOLOAD = sub () { $val }; #XXX } #XXX else { *$AUTOLOAD = sub { $val }; #XXX } } goto &$AUTOLOAD; } require XSLoader; XSLoader::load('DNS::LDNS', $VERSION); # Preloaded methods go here. our $last_status; our $line_nr; sub last_error { return errorstr_by_id($DNS::LDNS::last_status); } require DNS::LDNS::RR; require DNS::LDNS::GC; require DNS::LDNS::RData; require DNS::LDNS::Zone; require DNS::LDNS::RRList; require DNS::LDNS::DNSSecZone; require DNS::LDNS::DNSSecRRSets; require DNS::LDNS::DNSSecRRs; require DNS::LDNS::DNSSecName; require DNS::LDNS::RBTree; require DNS::LDNS::RBNode; require DNS::LDNS::Resolver; require DNS::LDNS::Packet; require DNS::LDNS::Key; require DNS::LDNS::KeyList; require DNS::LDNS::DNSSecDataChain; require DNS::LDNS::DNSSecTrustTree; # Autoload methods go after =cut, and are processed by the autosplit program. 1; __END__ =head1 NAME DNS::LDNS - Perl extension for the ldns library =head1 SYNOPSIS use DNS::LDNS ':all' =head1 DESCRIPTION DNS::LDNS is a perl OO-wrapper for the ldns library. A complete list of object methods is found in the perldoc for each of the individual classes. You may also read the documentation of the ldns library (http://www.nlnetlabs.nl/projects/ldns). =head2 Brief examples of usage use DNS::LDNS ':all'; my $z = new DNS::LDNS::Zone(filename => '/path/to/myzone'); print DNS::LDNS::last_error; my $rr = new DNS::LDNS::RR('mylabel 3600 IN A 168.10.10.10'); print $z->soa->to_string; my $rrlist = $z->rrs->push($rr); print $z->to_string; my $kl = new DNS::LDNS::KeyList; $kl->push(new DNS::LDNS::Key(filename => 'key'); $kl->key(0)->set_pubkey_owner( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone.org')); my $signedz = $z->sign($kl); print $signedz->to_string; my $r = new DNS::LDNS::Resolver(filename => '/my/resolv.conf'); my $p = $r->send( new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'www.google.com'), LDNS_RR_TYPE_A, LDNS_RR_CLASS_IN, LDNS_RD); print $p->answer->to_string; print $p->authority->to_string; =head2 Classes A description of the classes included and how they map to the ldns library structures: =over 20 =item B Base class with static functions and constants =item B Represents a parsed zonefile (maps to the ldns_zone struct) =item B Represents a list of RRs. This class is also used to represent an RRSet if all the dnames and types are equal, (maps to the the ldns_rr_list struct) =item B Represents a resource record (RR), (maps to the ldns_rr struct) =item B Represents an rdata field or a dname in an RR (maps to the ldns_rdf struct) =item B Represents a DNS resolver (maps to the ldns_resolver struct) =item B Represents a DNS package (maps to the ldns_pkt struct) =item B Represents a DNSSec private key (maps to the ldns_key struct) =item B Represents a linked list of keys (maps to the ldns_key_list struct) =item B Represents a zone with dnssec data (maps to the ldns_dnssec_zone struct) =item B Represents a tree of DNSSecName nodes (maps to the ldns_rbtree struct) =item B Represents a node in the RBTree (maps to the ldns_rbnode struct) =item B Represents a dname in a DNSSecZone and holds a DNSSecRRSets list for this dname, possibly with signatures (maps to the ldns_dnssec_name struct) =item B Represents a linked list of DNSSec RR sets, possibly with signatures (maps to the ldns_dnssec_rrsets struct) =item B Represents a linked list of RRs (maps to the ldns_dnssec_rrs struct) =item B Represents a chain of RR, DNSKEY, and DS data used for building a dnssec trust tree (maps to the ldns_dnssec_data_chain struct) =item B Represents a tree of chained trust relationships from a signed RR to a set of trust anchors (maps to the ldns_dnssec_trust_tree struct). =item B Garbage collector. Handles ownership dependencies and freeing data used by the other classes. Used internally only. =back One thing to note is that some of the classes have a seemingly overlapping functionality. The Zone and RRList are used to represent a generic zone. It may contain dnssec data but treats it like any other dns data and does not have any knowledge of its structure. The DNSSec* and RB* classes are building blocks for representing a signed zone in a more structured way. =head2 Static functions str = rr_type2str(type) str = rr_class2str(class) type = rr_type_by_name(str) class = rr_class_by_name(str) str = pkt_opcode2str(opcode) str = pkt_rcode2str(rcode) error = errorstr_by_id(status) str = DNS::LDNS::last_error status = DNS::LDNS::last_status rr = dnssec_create_nsec(from, to, type) rr = dnssec_create_nsec3(from, to, algorithm, flags, iterations, salt) rr = create_nsec(current, next, rrs) rr = create_nsec3(cur_owner, cur_zone, algorithm, flags, iterations, salt, empty_nonterminals) algo = signing_algorithm_by_name(name) bool = key_algorithm_supported(algorithm) rr = read_anchor_file(filename) =head2 Object references and cloning Since some of the objects are found as sub objects within other objects, it is important to know how the wrapper classes handle object references, dependencies and cloning. The general rule is that accessor methods just return a reference to the object while methods inserting data inserts inserts a clone of the object. Most classes have a clone method which can be used if a cloned object is what you really want. =head3 Examples DNS::LDNS::Zone::rrs returns a reference to the DNS::LDNS::RRList within the zone, so if you make changes to the RRList you also changes the Zone object. DNS::LDNS::RRList::push(rr) clones the rr, then pushes the cloned rr to the list. Changing the rr afterwards will not change the list. An exception is the Key class which does not have a clone mechanism. In this case we allow a free Key to be added to only one KeyList. Adding it to multiple lists will provoke an error. The wrapper keeps track of allocated data structures and references. Whenever data is no longer referred to by a perl object, it will be freed. =head2 ERROR HANDLING The purpose for writing this wrapper class has been to be able to process zone file data with good time performance. Data checking and error handling is a bit sparse. Most constructors will update the DNS::LDNS::last_status variable if they fail (return undef). Wrapper methods to ldns functions which would return a status will update the static DNS::LDNS::last_status variable. Most methods do not return a status and will not reset this variable even though they succeeds. =head2 EXPORT None by default. =head2 Exportable constants =head3 Status LDNS_STATUS_ADDRESS_ERR LDNS_STATUS_CERT_BAD_ALGORITHM LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL LDNS_STATUS_CRYPTO_BOGUS LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION LDNS_STATUS_CRYPTO_NO_DNSKEY LDNS_STATUS_CRYPTO_NO_DS LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY LDNS_STATUS_CRYPTO_NO_RRSIG LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY LDNS_STATUS_CRYPTO_NO_TRUSTED_DS LDNS_STATUS_CRYPTO_SIG_EXPIRED LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED LDNS_STATUS_CRYPTO_TSIG_BOGUS LDNS_STATUS_CRYPTO_TSIG_ERR LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR LDNS_STATUS_CRYPTO_UNKNOWN_ALGO LDNS_STATUS_CRYPTO_VALIDATED LDNS_STATUS_DDD_OVERFLOW LDNS_STATUS_DNSSEC_EXISTENCE_DENIED LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED LDNS_STATUS_DOMAINNAME_OVERFLOW LDNS_STATUS_DOMAINNAME_UNDERFLOW LDNS_STATUS_EMPTY_LABEL LDNS_STATUS_ENGINE_KEY_NOT_LOADED LDNS_STATUS_ERR LDNS_STATUS_FILE_ERR LDNS_STATUS_INTERNAL_ERR LDNS_STATUS_INVALID_B32_EXT LDNS_STATUS_INVALID_B64 LDNS_STATUS_INVALID_HEX LDNS_STATUS_INVALID_INT LDNS_STATUS_INVALID_IP4 LDNS_STATUS_INVALID_IP6 LDNS_STATUS_INVALID_POINTER LDNS_STATUS_INVALID_STR LDNS_STATUS_INVALID_TIME LDNS_STATUS_LABEL_OVERFLOW LDNS_STATUS_MEM_ERR LDNS_STATUS_MISSING_RDATA_FIELDS_KEY LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG LDNS_STATUS_NETWORK_ERR LDNS_STATUS_NOT_IMPL LDNS_STATUS_NO_DATA LDNS_STATUS_NSEC3_ERR LDNS_STATUS_NULL LDNS_STATUS_OK LDNS_STATUS_PACKET_OVERFLOW LDNS_STATUS_RES_NO_NS LDNS_STATUS_RES_QUERY LDNS_STATUS_SOCKET_ERROR LDNS_STATUS_SSL_ERR LDNS_STATUS_SYNTAX_ALG_ERR LDNS_STATUS_SYNTAX_BAD_ESCAPE LDNS_STATUS_SYNTAX_CLASS_ERR LDNS_STATUS_SYNTAX_DNAME_ERR LDNS_STATUS_SYNTAX_EMPTY LDNS_STATUS_SYNTAX_ERR LDNS_STATUS_SYNTAX_INCLUDE LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW LDNS_STATUS_SYNTAX_KEYWORD_ERR LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR LDNS_STATUS_SYNTAX_ORIGIN LDNS_STATUS_SYNTAX_RDATA_ERR LDNS_STATUS_SYNTAX_TTL LDNS_STATUS_SYNTAX_TTL_ERR LDNS_STATUS_SYNTAX_TYPE_ERR LDNS_STATUS_SYNTAX_VERSION_ERR LDNS_STATUS_UNKNOWN_INET LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL LDNS_STATUS_WIRE_INCOMPLETE_ANSWER LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY LDNS_STATUS_WIRE_INCOMPLETE_HEADER LDNS_STATUS_WIRE_INCOMPLETE_QUESTION =head3 Resolver flags and constants LDNS_RESOLV_ANCHOR LDNS_RESOLV_DEFDOMAIN LDNS_RESOLV_INET LDNS_RESOLV_INET6 LDNS_RESOLV_INETANY LDNS_RESOLV_KEYWORD LDNS_RESOLV_KEYWORDS LDNS_RESOLV_NAMESERVER LDNS_RESOLV_OPTIONS LDNS_RESOLV_RTT_INF LDNS_RESOLV_RTT_MIN LDNS_RESOLV_SEARCH LDNS_RESOLV_SORTLIST =head3 Resolver query flags LDNS_AA LDNS_AD LDNS_CD LDNS_QR LDNS_RA LDNS_RD LDNS_TC =head3 Resolver rcodes LDNS_RCODE_FORMERR LDNS_RCODE_NOERROR LDNS_RCODE_NOTAUTH LDNS_RCODE_NOTIMPL LDNS_RCODE_NOTZONE LDNS_RCODE_NXDOMAIN LDNS_RCODE_NXRRSET LDNS_RCODE_REFUSED LDNS_RCODE_SERVFAIL LDNS_RCODE_YXDOMAIN LDNS_RCODE_YXRRSET =head3 Packet types LDNS_PACKET_ANSWER LDNS_PACKET_NODATA LDNS_PACKET_NXDOMAIN LDNS_PACKET_QUESTION LDNS_PACKET_REFERRAL LDNS_PACKET_UNKNOWN =head3 Packet opcodes LDNS_PACKET_IQUERY LDNS_PACKET_NOTIFY LDNS_PACKET_QUERY LDNS_PACKET_STATUS LDNS_PACKET_UPDATE =head3 Packet sections LDNS_SECTION_ADDITIONAL LDNS_SECTION_ANSWER LDNS_SECTION_ANY LDNS_SECTION_ANY_NOQUESTION LDNS_SECTION_AUTHORITY LDNS_SECTION_QUESTION =head3 DNSSec constants LDNS_DEFAULT_EXP_TIME LDNS_MAX_KEYLEN LDNS_DNSSEC_KEYPROTO =head3 DNSSec sign policies LDNS_SIGNATURE_LEAVE_ADD_NEW LDNS_SIGNATURE_LEAVE_NO_ADD LDNS_SIGNATURE_REMOVE_ADD_NEW LDNS_SIGNATURE_REMOVE_NO_ADD LDNS_NSEC3_MAX_ITERATIONS =head3 Key flags LDNS_KEY_REVOKE_KEY LDNS_KEY_SEP_KEY LDNS_KEY_ZONE_KEY =head3 Key algorithms LDNS_DH LDNS_DSA LDNS_DSA_NSEC3 LDNS_ECC LDNS_RSAMD5 LDNS_RSASHA1 LDNS_RSASHA1_NSEC3 LDNS_RSASHA256 LDNS_RSASHA512 LDNS_ECC_GOST LDNS_PRIVATEDNS LDNS_PRIVATEOID =head3 Signing algorithms LDNS_SIGN_DSA LDNS_SIGN_DSA_NSEC3 LDNS_SIGN_ECC_GOST LDNS_SIGN_HMACSHA1 LDNS_SIGN_HMACSHA256 LDNS_SIGN_RSAMD5 LDNS_SIGN_RSASHA1 LDNS_SIGN_RSASHA1_NSEC3 LDNS_SIGN_RSASHA256 LDNS_SIGN_RSASHA512 =head3 Hashing algorithm LDNS_SHA1 LDNS_SHA256 LDNS_HASH_GOST =head3 Rdata constants LDNS_MAX_RDFLEN LDNS_NSEC3_VARS_OPTOUT_MASK LDNS_RDF_SIZE_16BYTES LDNS_RDF_SIZE_6BYTES LDNS_RDF_SIZE_BYTE LDNS_RDF_SIZE_DOUBLEWORD LDNS_RDF_SIZE_WORD =head3 Rdata types LDNS_RDF_TYPE_A LDNS_RDF_TYPE_AAAA LDNS_RDF_TYPE_ALG LDNS_RDF_TYPE_APL LDNS_RDF_TYPE_ATMA LDNS_RDF_TYPE_B32_EXT LDNS_RDF_TYPE_B64 LDNS_RDF_TYPE_CERT_ALG LDNS_RDF_TYPE_CLASS LDNS_RDF_TYPE_DNAME LDNS_RDF_TYPE_HEX LDNS_RDF_TYPE_INT16 LDNS_RDF_TYPE_INT16_DATA LDNS_RDF_TYPE_INT32 LDNS_RDF_TYPE_INT8 LDNS_RDF_TYPE_IPSECKEY LDNS_RDF_TYPE_LOC LDNS_RDF_TYPE_NONE LDNS_RDF_TYPE_NSAP LDNS_RDF_TYPE_NSEC LDNS_RDF_TYPE_NSEC3_NEXT_OWNER LDNS_RDF_TYPE_NSEC3_SALT LDNS_RDF_TYPE_PERIOD LDNS_RDF_TYPE_SERVICE LDNS_RDF_TYPE_STR LDNS_RDF_TYPE_TIME LDNS_RDF_TYPE_HIP LDNS_RDF_TYPE_TSIGTIME LDNS_RDF_TYPE_TYPE LDNS_RDF_TYPE_UNKNOWN LDNS_RDF_TYPE_WKS =head3 Algorithms used in CERT RRs. LDNS_CERT_ACPKIX LDNS_CERT_IACPKIX LDNS_CERT_IPGP LDNS_CERT_IPKIX LDNS_CERT_ISPKI LDNS_CERT_OID LDNS_CERT_PGP LDNS_CERT_PKIX LDNS_CERT_SPKI LDNS_CERT_URI =head3 RR compress flag LDNS_RR_COMPRESS LDNS_RR_NO_COMPRESS =head3 RR classes LDNS_RR_CLASS_ANY LDNS_RR_CLASS_CH LDNS_RR_CLASS_COUNT LDNS_RR_CLASS_FIRST LDNS_RR_CLASS_HS LDNS_RR_CLASS_IN LDNS_RR_CLASS_LAST LDNS_RR_CLASS_NONE =head3 RR types LDNS_RR_TYPE_A LDNS_RR_TYPE_A6 LDNS_RR_TYPE_AAAA LDNS_RR_TYPE_AFSDB LDNS_RR_TYPE_ANY LDNS_RR_TYPE_APL LDNS_RR_TYPE_ATMA LDNS_RR_TYPE_AXFR LDNS_RR_TYPE_CERT LDNS_RR_TYPE_CNAME LDNS_RR_TYPE_COUNT LDNS_RR_TYPE_DHCID LDNS_RR_TYPE_DLV LDNS_RR_TYPE_DNAME LDNS_RR_TYPE_DNSKEY LDNS_RR_TYPE_DS LDNS_RR_TYPE_EID LDNS_RR_TYPE_FIRST LDNS_RR_TYPE_GID LDNS_RR_TYPE_GPOS LDNS_RR_TYPE_HINFO LDNS_RR_TYPE_IPSECKEY LDNS_RR_TYPE_ISDN LDNS_RR_TYPE_IXFR LDNS_RR_TYPE_KEY LDNS_RR_TYPE_KX LDNS_RR_TYPE_LAST LDNS_RR_TYPE_LOC LDNS_RR_TYPE_MAILA LDNS_RR_TYPE_MAILB LDNS_RR_TYPE_MB LDNS_RR_TYPE_MD LDNS_RR_TYPE_MF LDNS_RR_TYPE_MG LDNS_RR_TYPE_MINFO LDNS_RR_TYPE_MR LDNS_RR_TYPE_MX LDNS_RR_TYPE_NAPTR LDNS_RR_TYPE_NIMLOC LDNS_RR_TYPE_NS LDNS_RR_TYPE_NSAP LDNS_RR_TYPE_NSAP_PTR LDNS_RR_TYPE_NSEC LDNS_RR_TYPE_NSEC3 LDNS_RR_TYPE_NSEC3PARAM LDNS_RR_TYPE_NSEC3PARAMS LDNS_RR_TYPE_NULL LDNS_RR_TYPE_NXT LDNS_RR_TYPE_OPT LDNS_RR_TYPE_PTR LDNS_RR_TYPE_PX LDNS_RR_TYPE_RP LDNS_RR_TYPE_RRSIG LDNS_RR_TYPE_RT LDNS_RR_TYPE_SIG LDNS_RR_TYPE_SINK LDNS_RR_TYPE_SOA LDNS_RR_TYPE_SPF LDNS_RR_TYPE_SRV LDNS_RR_TYPE_SSHFP LDNS_RR_TYPE_TALINK LDNS_RR_TYPE_TSIG LDNS_RR_TYPE_TXT LDNS_RR_TYPE_UID LDNS_RR_TYPE_UINFO LDNS_RR_TYPE_UNSPEC LDNS_RR_TYPE_WKS LDNS_RR_TYPE_X25 =head3 Various defaults and other constants LDNS_DEFAULT_TTL LDNS_PORT LDNS_IP4ADDRLEN LDNS_IP6ADDRLEN LDNS_MAX_DOMAINLEN LDNS_MAX_LABELLEN LDNS_MAX_PACKETLEN LDNS_MAX_POINTERS LDNS_RR_OVERHEAD LDNS_RDATA_FIELD_DESCRIPTORS_COMMON =head1 BUGS This package is still in the beta stage of development. There no known bugs, although parts of the code has not yet been very well tested. Bugreports will be greatly appreciated. =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/0000775000175000017500000000000015212267527016616 5ustar willemwillemldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/RData.pm0000644000175000017500000000315415212267527020150 0ustar willemwillempackage DNS::LDNS::RData; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; sub new { my ($class, $type, $str) = @_; return _new($type, $str); } sub cat { my ($self, $other) = @_; my $s = _cat($self, $other); $DNS::LDNS::last_status = $s; return $s; } sub nsec3_hash_name { my ($self, $algorithm, $iterations, $salt) = @_; return DNS::LDNS::GC::own( $self->_nsec3_hash_name($algorithm, $iterations, $salt), $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::RData - Rdata field or a dname in an rr =head1 SYNOPSIS use DNS::LDNS ':all' my rd = new DNS::LDNS::RData(rdf_type, str) rd2 = rd->clone rdf_type = rd->type rd->set_type(rdf_type) rd->print(\*FILE) str = rd->to_string count = rd->label_count rd2 = rd->label(pos) bool = rd->is_wildcard bool = rd->matches_wildcard(wildcard) bool = rd->is_subdomain(parent) rd2 = rd->left_chop status = rd->cat(rd2) rd->compare(rd2) rd2 = rd->address_reverse rd2 = rd->dname_reverse rd2 = rd->nsec3_hash_name(name, algorithm, iterations, salt) epoch = rd->to_unix_time ( epoch = rd->2native_time_t ) rr_type = rd->to_rr_type =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/GC.pm0000644000175000017500000000511615212267527017446 0ustar willemwillempackage DNS::LDNS::GC; use strict; use warnings; our $VERSION = '0.61'; my %ref_count; my %owned_by; sub own { my ($obj, $owner) = @_; # print STDERR "Owning $obj -> $owner\n"; return unless (defined $obj); if ($owned_by{$$owner}) { # If the owner is an owned object, let obj be owned by # the owners owner. We want to avoid recursive ownerships. $owner = $owned_by{$$owner}; } if (exists $owned_by{$$obj}) { $ref_count{$$obj}++; } else { $ref_count{$$obj} = 1; $owned_by{$$obj} = $owner; } return $obj; } # Return true if the object is owned by someone sub is_owned { return (exists $owned_by{${$_[0]}}); } sub owner { return $owned_by{${$_[0]}}; } sub disown { return unless (defined $_[0]); delete $owned_by{${$_[0]}}; } my %free_method = ( 'DNS::LDNS::Zone' => '_zone_deep_free', 'DNS::LDNS::RRList' => '_rrlist_deep_free', 'DNS::LDNS::RR' => '_rr_free', 'DNS::LDNS::RData' => '_rdata_deep_free', 'DNS::LDNS::DNSSecZone' => '_dnssec_zone_deep_free', 'DNS::LDNS::DNSSecName' => '_dnssec_name_deep_free', 'DNS::LDNS::Resolver' => '_resolver_deep_free', 'DNS::LDNS::Packet' => '_packet_free', 'DNS::LDNS::Key' => '_key_deep_free', 'DNS::LDNS::KeyList' => '_keylist_free', 'DNS::LDNS::DNSSecDataChain' => '_dnssec_datachain', ); my %not_deleted_by_owner = ( 'DNS::LDNS::DNSSecTrustChain' => 1, ); sub free { my $obj = shift; # print STDERR "Freeing $obj\n"; if (exists $ref_count{$$obj}) { # print STDERR "Derefing $obj\n"; $ref_count{$$obj}--; return if ($ref_count{$$obj} > 0); } # print STDERR "Deleting $obj\n"; delete $ref_count{$$obj}; if (exists $owned_by{$$obj}) { delete $owned_by{$$obj}; return unless ($not_deleted_by_owner{ref $obj}); } my $class = ref $obj; my $free = $free_method{ref $obj}; die "Internal error: No freeing method for $obj (".ref $obj.")" unless ($free); no strict; &$free($obj); } 1; __END__ =head1 NAME DNS::LDNS::GC - Garbage collector, used internally by the DNS::LDNS modules =head1 SYNOPSIS Garbage collector class for DNS::LDNS objects. =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/Key.pm0000644000175000017500000000442115212267527017703 0ustar willemwillempackage DNS::LDNS::Key; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my ($class, %args) = @_; my $key; if ($args{filename} or $args{file}) { my $status = &LDNS_STATUS_OK; my $line_nr = 0; my $file = $args{file}; if ($args{filename}) { unless (open FILE, $args{filename}) { $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR; return; } $file = \*FILE; } $key = _new_from_file($file, $line_nr, $status); if ($args{filename}) { close $file; } $DNS::LDNS::last_status = $status; $DNS::LDNS::line_nr = $line_nr; if (!defined $key) { return; } } else { $key = _new(); } return $key; } sub set_pubkey_owner { my ($self, $owner) = @_; my $oldowner = $self->pubkey_owner; DNS::LDNS::GC::disown(my $old = $self->pubkey_owner); $self->_set_pubkey_owner($owner); return DNS::LDNS::GC::own($owner, $self); } sub pubkey_owner { my $self = shift; return DNS::LDNS::GC::own($self->_pubkey_owner, $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::Key - DNSSec private key =head1 SYNOPSIS use DNS::LDNS ':all' key = new DNS::LDNS::Key key = new DNS::LDNS::Key(file => \*FILE) key = new DNS::LDNS::Key(filename => 'keyfile') str = key->to_string key->print(\*OUTPUT) key->set_algorithm(alg) alg = key->algorithm key->set_flags(flags) flags = key->flags key->set_hmac_key(hmac) hmac = key->hmac_key key->set_hmac_size(size) size = key->hmac_size key->set_origttl(ttl) ttl = key->origttl key->set_inception(epoch) epoch = key->inception key->set_expiration(epoch) epoch = key->expiration key->set_pubkey_owner(rdata) rdata = key->pubkey_owner key->set_keytag(tag) tag = key->keytag key->set_use(bool) bool = key->use str = key->get_file_base_name rr = key->to_rr =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/RRList.pm0000644000175000017500000001030315212267527020326 0ustar willemwillempackage DNS::LDNS::RRList; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; sub new { my ($class, %args) = @_; if ($args{hosts_filename} or $args{hosts_file}) { my $file = $args{hosts_file}; if ($args{hosts_filename}) { unless (open FILE, $args{hosts_filename}) { $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR; $DNS::LDNS::line_nr = 0; return; } $file = \*FILE; } my $list = _new_hosts_from_file($file, $DNS::LDNS::line_nr); if ($args{hosts_filename}) { close $file; } return $list; } return _new(); } sub rr { my ($self, $index) = @_; return DNS::LDNS::GC::own($self->_rr($index), $self); } sub push { my ($self, @rrs) = @_; for my $rr (@rrs) { # Push a copy of the rr in case it is already owned $self->_push(my $copy = $rr->clone); DNS::LDNS::GC::own($copy, $self); } } sub push_list { my ($self, $list) = @_; $self->_push_list(my $copy = $list->clone); DNS::LDNS::GC::own($copy, $self); } sub verify { my ($self, $sig, $keys) = @_; my $goodkeys = new DNS::LDNS::RRList; my $s = _verify($self, $sig, $keys, $goodkeys); $DNS::LDNS::last_status = $s; return wantarray ? ($s, $goodkeys) : $s; } sub verify_time { my ($self, $sig, $keys, $checktime) = @_; my $goodkeys = new DNS::LDNS::RRList; my $s = _verify_time($self, $sig, $keys, $checktime, $goodkeys); $DNS::LDNS::last_status = $s; return wantarray ? ($s, $goodkeys) : $s; } sub verify_notime { my ($self, $sig, $keys) = @_; my $goodkeys = new DNS::LDNS::RRList; my $s = _verify_notime($self, $sig, $keys, $goodkeys); $DNS::LDNS::last_status = $s; return wantarray ? ($s, $goodkeys) : $s; } sub verify_rrsig_keylist { my ($self, $sig, $keys) = @_; my $goodkeys = new DNS::LDNS::RRList; my $s = _verify_rrsig_keylist($self, $sig, $keys, $goodkeys); $DNS::LDNS::last_status = $s; return wantarray ? ($s, $goodkeys) : $s; } sub verify_rrsig_keylist_notime { my ($self, $sig, $keys, $check_time) = @_; my $goodkeys = new DNS::LDNS::RRList; my $s = _verify_rrsig_keylist_notime($self, $sig, $keys, $goodkeys); $DNS::LDNS::last_status = $s; return wantarray ? ($s, $goodkeys) : $s; } sub get_dnskey_for_rrsig { my ($self, $rrsig) = @_; return DNS::LDNS::GC::own(_get_dnskey_for_rrsig($rrsig, $self), $self); } sub get_rrsig_for_name_and_type { my ($self, $name, $type) = @_; return DNS::LDNS::GC::own( _get_dnskey_for_name_and_type($name, $type, $self), $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::RRList - List of rrs =head1 SYNOPSIS use DNS::LDNS ':all' my l = new DNS::LDNS::RRList my l = new DNS::LDNS::RRList(hosts_file => \*FILE) my l = new DNS::LDNS::RRList(hosts_filename => fname) my l2 = l->clone l->to_string l->print(\*FILE) count = l->rr_count rr = l->rr(index) l->push(@rr) rr = l->pop l->push_list(l2) l2 = l->pop_list(count) l2 = l->pop_rrset l->compare(l2) l2 = l->subtype_by_rdata(rdata, pos) bool = l->is_rrset bool = l->contains_rr(rr) (status, goodkeys) = l->verify(sig, keys) (status, goodkeys) = l->verify_time(sig, keys, checktime) (status, goodkeys) = l->verify_notime(sig, keys) (status, goodkeys) = l->verify_rrsig_keylist(sig, keys) (status, goodkeys) = l->verify_rrsig_keylist_time(sig, keys, checktime) (status, goodkeys) = l->verify_rrsig_keylist_notime(sig, keys) status = l->verify_rrsig(sig, keys) status = l->verify_rrsig_time(sig, keys, checktime) rr = l->create_empty_rrsig(key) rrlist = l->sign_public(keylist) rrlist->canonicalize rrlist->sort rrlist->sort_nsec3 # the list must contain only nsec3 rrs rr = keylist->get_dnskey_for_rrsig(rrsig) rr = keylist->get_rrsig_for_name_and_type(name, type) =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecName.pm0000644000175000017500000000375515212267527021044 0ustar willemwillempackage DNS::LDNS::DNSSecName; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my $class = shift; return _new; } sub name { my $self = shift; return DNS::LDNS::GC::own($self->_name, $self); } sub set_name { my ($self, $name) = @_; DNS::LDNS::GC::disown(my $old = $self->name); _set_name($self, my $copy = $name->clone); DNS::LDNS::GC::own($copy, $self); } sub rrsets { my $self = shift; return DNS::LDNS::GC::own($self->_rrsets, $self); } sub add_rr { my ($self, $rr) = @_; my $s = _add_rr($self, my $copy = $rr->clone); DNS::LDNS::GC::own($copy, $self); $DNS::LDNS::last_status = $s; return $s; } sub nsec { my $self = shift; return DNS::LDNS::GC::own($self->_nsec, $self); } sub set_nsec { my ($self, $nsec) = @_; DNS::LDNS::GC::disown(my $old = $self->nsec); _set_nsec($self, my $copy = $nsec->clone); DNS::LDNS::GC::own($copy, $self); } sub hashed_name { my $self = shift; return DNS::LDNS::GC::own($self->_hashed_name, $self); } sub nsec_signatures { my $self = shift; return DNS::LDNS::GC::own($self->_nsec_signatures, $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::DNSSecName - Dname with rrsets in a dnssec zone =head1 SYNOPSIS use LDNS ':all' my name = new DNS::LDNS::DNSSecName rdata = name->name name->set_name(rdata) bool = name->is_glue rrsets = name->rrsets name->add_rr(rr) rr = name->nsec name->set_nsec(rr) hash = name->hashed_name rrs = name->nsec_signatures =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/RR.pm0000644000175000017500000003015215212267527017476 0ustar willemwillempackage DNS::LDNS::RR; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my $class = shift; my $rr; my $status = &LDNS_STATUS_OK; if (scalar(@_) == 0) { $rr = _new; } elsif (scalar(@_) == 1) { $rr = _new_from_str($_[0], 0, undef, undef, $status); } else { my %args = @_; # Perl 5.25 does not allow us to pass read-only undef into a # parameter changing function. So we must send it with a variable. my $undef = undef; if ($args{str}) { $rr = _new_from_str($args{str}, $args{default_ttl} || 0, $args{origin}, $args{prev} ? ${$args{prev}} : $undef, $status); } elsif ($args{filename} or $args{file}) { my $line_nr = 0; my $file = $args{file}; if ($args{filename}) { unless (open FILE, $args{filename}) { $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR; $DNS::LDNS::line_nr = 0; return; } $file = \*FILE; } my $ttl = 0; $rr = _new_from_file($file, $args{default_ttl} ? ${$args{default_ttl}} : $ttl, $args{origin} ? ${$args{origin}} : $undef, $args{prev} ? ${$args{prev}} : $undef, $status, $line_nr); if ($args{filename}) { close $file; } $DNS::LDNS::line_nr = $line_nr; } elsif ($args{type}) { $rr = _new_from_type($args{type}); if ($args{owner}) { $rr->set_owner(ref $args{owner} ? $args{owner} : new DNS::LDNS::RData(&LDNS_RDF_TYPE_DNAME, $args{owner})); } $rr->set_ttl($args{ttl}) if ($args{ttl}); $rr->set_class($args{class}) if ($args{class}); if ($args{rdata}) { if (!$rr->set_rdata(@{$args{rdata}})) { $DNS::LDNS::last_status = &LDNS_STATUS_SYNTAX_RDATA_ERR; return; } } } } if (!defined $rr) { $DNS::LDNS::last_status = $status; return; } return $rr; } sub owner { my $self = shift; return DNS::LDNS::GC::own($self->_owner, $self); } sub set_owner { my ($self, $owner) = @_; DNS::LDNS::GC::disown(my $old = $self->owner); $self->_set_owner($owner); return DNS::LDNS::GC::own($owner, $self); } sub dname { return $_[0]->owner->to_string; } sub rdata { my ($self, $index) = @_; return DNS::LDNS::GC::own($self->_rdata($index), $self); } # replace all existing rdata with new ones. Requires the # input array to be exactly same length as rd_count sub set_rdata { my ($self, @rdata) = @_; if (scalar @rdata != $self->rd_count) { # Hopefully this is a proper error to return here... $DNS::LDNS::last_status = LDNS_STATUS_SYNTAX_RDATA_ERR; return; } my $i = 0; for (@rdata) { my $oldrd = _set_rdata($self, my $copy = $_->clone, $i); DNS::LDNS::GC::disown(my $old = $oldrd); DNS::LDNS::GC::own($copy, $self); $i++; } return 1; } sub push_rdata { my ($self, @rdata) = @_; for (@rdata) { # Push a copy in case the input rdata are already owned $self->_push_rdata(my $copy = $_->clone); DNS::LDNS::GC::own($copy, $self); } } sub rrsig_typecovered { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_typecovered, $self); } sub rrsig_set_typecovered { my ($self, $type) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_typecovered); my $result = $self->_rrsig_set_typecovered(my $copy = $type->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_algorithm { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_algorithm, $self); } sub rrsig_set_algorithm { my ($self, $algo) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_algorithm); my $result = $self->_rrsig_set_algorithm(my $copy = $algo->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_expiration { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_expiration, $self); } sub rrsig_set_expiration { my ($self, $date) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_expiration); my $result = $self->_rrsig_set_expiration(my $copy = $date->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_inception { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_inception, $self); } sub rrsig_set_inception { my ($self, $date) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_inception); my $result = $self->_rrsig_set_inception(my $copy = $date->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_keytag { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_keytag, $self); } sub rrsig_set_keytag { my ($self, $tag) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_keytag); my $result = $self->_rrsig_set_keytag(my $copy = $tag->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_sig { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_sig, $self); } sub rrsig_set_sig { my ($self, $sig) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_sig); my $result = $self->_rrsig_set_sig(my $copy = $sig->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_labels { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_labels, $self); } sub rrsig_set_labels { my ($self, $lab) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_labels); my $result = $self->_rrsig_set_labels(my $copy = $lab->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_origttl { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_origttl, $self); } sub rrsig_set_origttl { my ($self, $ttl) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_origttl); my $result = $self->_rrsig_set_origttl(my $copy = $ttl->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub rrsig_signame { my $self = shift; return DNS::LDNS::GC::own($self->_rrsig_signame, $self); } sub rrsig_set_signame { my ($self, $name) = shift; DNS::LDNS::GC::disown(my $old = $self->rrsig_signame); my $result = $self->_rrsig_set_signame(my $copy = $name->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub dnskey_algorithm { my $self = shift; return DNS::LDNS::GC::own($self->_dnskey_algorithm, $self); } sub dnskey_set_algorithm { my ($self, $algo) = shift; DNS::LDNS::GC::disown(my $old = $self->dnskey_algorithm); my $result = $self->_dnskey_set_algorithm(my $copy = $algo->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub dnskey_flags { my $self = shift; return DNS::LDNS::GC::own($self->_dnskey_flags, $self); } sub dnskey_set_flags { my ($self, $flags) = shift; DNS::LDNS::GC::disown(my $old = $self->flags); my $result = $self->_dnskey_set_flags(my $copy = $flags->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub dnskey_protocol { my $self = shift; return DNS::LDNS::GC::own($self->_dnskey_protocol, $self); } sub dnskey_set_protocol { my ($self, $proto) = shift; DNS::LDNS::GC::disown(my $old = $self->dnskey_protocol); my $result = $self->_dnskey_set_protocol(my $copy = $proto->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub dnskey_key { my $self = shift; return DNS::LDNS::GC::own($self->_dnskey_key, $self); } sub dnskey_set_key { my ($self, $key) = shift; DNS::LDNS::GC::disown(my $old = $self->dnskey_key); my $result = $self->_dnskey_set_key(my $copy = $key->clone); DNS::LDNS::GC::own($copy, $self); return $result; } sub nsec3_next_owner { my $self = shift; return DNS::LDNS::GC::own($self->_nsec3_next_owner, $self); } sub nsec3_bitmap { my $self = shift; return DNS::LDNS::GC::own($self->_nsec3_bitmap, $self); } sub nsec3_salt { my $self = shift; return DNS::LDNS::GC::own($self->_nsec3_salt, $self); } sub hash_name_from_nsec3 { my ($self, $name) = @_; my $hash = $self->_hash_name_from_nsec3($name); return DNS::LDNS::GC::own($self->_hash_name_from_nsec3($name), $self); } sub verify_denial { my ($self, $nsecs, $rrsigs) = @_; my $s = _verify_denial($self, $nsecs, $rrsigs); $DNS::LDNS::last_status = $s; return $s; } sub verify_denial_nsec3 { my ($self, $nsecs, $rrsigs, $packet_rcode, $packet_qtype, $packet_nodata) = @_; my $s = _verify_denial_nsec3($self, $nsecs, $rrsigs, $packet_rcode, $packet_qtype, $packet_nodata); $DNS::LDNS::last_status = $s; return $s; } sub verify_denial_nsec3_match { my ($self, $nsecs, $rrsigs, $packet_rcode, $packet_qtype, $packet_nodata) = @_; my $status; my $match = _verify_denial_nsec3_match($self, $nsecs, $rrsigs, $packet_rcode, $packet_qtype, $packet_nodata, $status); $DNS::LDNS::last_status = $status; if ($status != &LDNS_STATUS_OK) { return; } # $match is an RR owned by the $nsecs list. return DNS::LDNS::GC::own($match, $nsecs); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::RR - Resource record =head1 SYNOPSIS use DNS::LDNS ':all' my rr = new DNS::LDNS::RR('mylabel 3600 IN A 168.10.10.10') my rr = new DNS::LDNS::RR( str => 'mylabel 3600 IN A 168.10.10.10', default_ttl => 3600, # optional origin => $origin_rdata, # optional prev => \$prev_rdata, # optional ) my rr = new DNS::LDNS::RR( filename => '/path/to/rr', default_ttl => \$ttl, # optional origin => \$origin_rdata, # optional prev => \$prev_rdata) # optional my rr = new DNS::LDNS::RR( file => \*FILE, default_ttl => \$ttl, # optional origin => \$origin_rdata, # optional prev => \$prev_rdata) # optional my rr = new DNS::LDNS::RR( type => LDNS_RR_TYPE_A, rdata => [new DNS::LDNS::RData(...), new DNS::LDNS::RData(...), ...], class => LDNS_RR_CLASS_IN, # optional ttl => 3600, # optional owner => new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'mylabel'), # optional) my rr = new DNS::LDNS::RR rr2 = rr->clone rr->print(\*FILE) rr->to_string ttl = rr->ttl rr->set_ttl(ttl) type = rr->type rr->set_type(type) class = rr->class rr->set_class(class) rdata = rr->owner rr->set_owner(rdata) str = rr->dname count = rr->rd_count rdata = rr->rdata(index) rr->set_rdata(rd1, rd2, rd3, ...) rr->push_rdata(rd1, rd2, rd3, ...) rdata = rr->pop_rdata rr->compare(rr2) rr->compare_dname(rr2) rr->compare_no_rdata(rr2) rr->compare_ds(rr2) hash = rr->hash_name_from_nsec3(dname) status = rr->verify_denial(nsecs, rrsigs) status = rr->verify_denial_nsec3(nsecs, rrsigs, packet_rcode, packet_qtype, packet_nodata) match = rr->verify_denial_nsec3_match(nsecs, rrsigs, packet_rcode, packet_qtype, packet_nodata) rr->nsec3_add_param_rdfs(algorithm, flags, iterations, salt) a = rr->nsec3_algorithm f = rr->nsec3_flags o = rr->nsec3_optout i = rr->nsec3_iterations rdata = rr->nsec3_next_owner rdata = rr->nsec3_bitmap rdata = rr->nsec3_salt rdata = rr->rrsig_keytag bool = rr->rrsig_set_keytag(rdata) rdata = rr->rrsig_signame bool = rr->rrsig_set_signame(rdata) rdata = rr->rrsig_sig bool = rr->rrsig_set_sig(rdata) rdata = rr->rrsig_algorithm bool = rr->rrsig_set_algorithm(rdata) rdata = rr->rrsig_inception bool = rr->rrsig_set_inception(rdata) rdata = rr->rrsig_expiration bool = rr->rrsig_set_expiration(rdata) rdata = rr->rrsig_labels bool = rr->rrsig_set_labels(rdata) rdata = rr->rrsig_origttl bool = rr->rrsig_set_origttl(rdata) key = rr->get_dnskey_for_rrsig(rrlist) rdata = rr->dnskey_algorithm bool = rr->dnskey_set_algorithm(rdata) rdata = rr->dnskey_flags bool = rr->dnskey_set_flags(rdata) rdata = rr->dnskey_protocol bool = rr->dnskey_set_protocol(rdata) rdata = rr->dnskey_key bool = rr->dnskey_set_key(rdata) bits = rr->dnskey_key_size tag = rr->calc_keytag ds = rr->key_to_ds(hash) rr->is_question =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecZone.pm0000644000175000017500000000666715212267527021104 0ustar willemwillempackage DNS::LDNS::DNSSecZone; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my ($class, %args) = @_; my $line_nr; my $status = &LDNS_STATUS_OK; my $zone; my $file; if ($args{filename}) { unless (open FILE, $args{filename}) { $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR; $DNS::LDNS::line_nr = 0; return; } $file = \*FILE; } elsif ($args{file}) { $file = $args{file}; } if ($file) { $zone = _new_from_file($file, $args{origin}, $args{ttl} || 0, $args{class} || 0, $status, $line_nr); } else { $zone = _new(); } if ($args{filename}) { close $file; } $DNS::LDNS::last_status = $status; $DNS::LDNS::line_nr = $line_nr; if (!defined $zone) { return; } return $zone; } sub soa { my $self = shift; return DNS::LDNS::GC::own($self->_soa, $self); } sub names { my $self = shift; return DNS::LDNS::GC::own($self->_names, $self); } sub find_rrset { my ($self, $name, $type) = @_; return DNS::LDNS::GC::own($self->_find_rrset($name, $type), $self); } sub add_rr { my ($self, $rr) = @_; # Set a copy of the rr in case it is already owned my $s = _add_rr($self, my $copy = $rr->clone); $DNS::LDNS::last_status = $s; DNS::LDNS::GC::own($copy, $self); return $s; } sub add_empty_nonterminals { my $self = shift; my $s = _add_empty_nonterminals($self); $DNS::LDNS::last_status = $s; return $s; } sub mark_glue { my $self = shift; my $s = _mark_glue($self); $DNS::LDNS::last_status = $s; return $s; } sub sign { my ($self, $keylist, $policy, $flags) = @_; my $s = _sign($self, $keylist, $policy, $flags); $DNS::LDNS::last_status = $s; return $s; } sub sign_nsec3 { my ($self, $keylist, $policy, $algorithm, $flags, $iterations, $salt, $signflags) = @_; my $s = _sign_nsec3($self, $keylist, $policy, $algorithm, $flags, $iterations, $salt, $signflags); $DNS::LDNS::last_status = $s; return $s; } sub to_string { return "DNS::LDNS::DNSSecZone::to_string is not yet implemented"; } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::DNSSecZone - Zone with dnssec data =head1 SYNOPSIS use DNS::LDNS ':all' my z = new DNS::LDNS::DNSSecZone( filename => '/path/to/myzone', origin => new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone'), #optional ttl => 3600, #optional class => LDNS_RR_CLASS_, #optional ) my z = new DNS::LDNS::DNSSecZone( file => \*FILE, origin => ..., ttl => ..., class => ... ) my z = new DNS::LDNS::DNSSecZone rr = z->soa rbtree = z->names rrsets = z->find_rrset z->add_rr(rr) z->create_from_zone(zone) z->add_empty_nonterminals z->sign(keylist, policy) z->sign_nsec3(keylist, policy, algorithm, flags, iterations, salt) z->create_nsecs z->create_nsec3s(algorithm, flags, iterations, salt) z->create_rrsigs(key_list, policy, flags) =head1 TODO z->to_string =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecDataChain.pm0000644000175000017500000000350115212267527021765 0ustar willemwillempackage DNS::LDNS::DNSSecDataChain; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; sub rrset { my $self = shift; return DNS::LDNS::GC::own($self->_rrset, $self); } sub signatures { my $self = shift; return DNS::LDNS::GC::own($self->_signatures, $self); } sub parent { my $self = shift; return DNS::LDNS::GC::own($self->_parent, $self); } sub derive_trust_tree { my ($self, $rr) = @_; if (!DNS::LDNS::GC::is_owned($rr) or DNS::LDNS::GC::owner($rr) ne $self) { die "The rr ($rr) must be in the data chain ($self)"; } return DNS::LDNS::GC::own($self->_derive_trust_tree($rr), $self); } sub derive_trust_tree_time { my ($self, $rr, $checktime) = @_; if (!DNS::LDNS::GC::is_owned($rr) or DNS::LDNS::GC::owner($rr) ne $self) { die "The rr ($rr) must be in the data chain ($self)"; } return DNS::LDNS::GC::own( $self->_derive_trust_tree_time($rr, $checktime), $self); } 1; __END__ =head1 NAME DNS::LDNS::DNSSecDataChain - DNSSec data chain element =head1 SYNOPSIS use DNS::LDNS ':all' chain = new DNS::LDNS::DNSSecDataChain chain->print(fp) chain->derive_trust_tree(rr) chain->derive_trust_tree_time(rr, checktime) # Node attributes rrset = chain->rrset rrset = chain->signatures rrtype = chain->parent_type pchain = chain->parent rcode = chain->packet_rcode rrtype = chain->packet_qtype bool = chain->packet_nodata =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/Zone.pm0000644000175000017500000000516215212267527020071 0ustar willemwillempackage DNS::LDNS::Zone; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my ($class, %args) = @_; my $line_nr = 0; my $status = &LDNS_STATUS_OK; my $zone; my $file; if ($args{filename}) { unless (open FILE, $args{filename}) { $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR; $DNS::LDNS::line_nr = 0; return; } $file = \*FILE; } elsif ($args{file}) { $file = $args{file}; } if ($file) { $zone = _new_from_file($file, $args{origin}, $args{default_ttl} || 0, $args{class} || 0, $status, $line_nr); } else { $zone = _new(); } if ($args{filename}) { close $file; } $DNS::LDNS::last_status = $status; $DNS::LDNS::line_nr = $line_nr; if (!defined $zone) { return; } return $zone; } sub to_string { my $self = shift; return join('', map { $self->$_ ? $self->$_->to_string : '' } qw/soa rrs/); } sub soa { my $self = shift; return DNS::LDNS::GC::own($self->_soa, $self); } sub set_soa { my ($self, $soa) = @_; DNS::LDNS::GC::disown(my $old = $self->soa); $self->_set_soa(my $copy = $soa->clone); return DNS::LDNS::GC::own($copy, $self); } sub rrs { my $self = shift; return DNS::LDNS::GC::own($self->_rrs, $self); } sub set_rrs { my ($self, $list) = @_; DNS::LDNS::GC::disown(my $old = $self->rrs); $self->_set_rrs(my $copy = $list->clone); return DNS::LDNS::GC::own($copy, $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::Zone - Parsed zonefile =head1 SYNOPSIS use DNS::LDNS ':all' my z = new DNS::LDNS::Zone( filename => '/path/to/myzone', origin => new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone'), #optional default_ttl => 3600, #optional class => LDNS_RR_CLASS_IN, #optional ) my z = new DNS::LDNS::Zone( file => \*FILE, origin => ..., default_ttl => ..., class => ... ) my z = new DNS::LDNS::Zone z->to_string z->print(\*FILE) z->canonicalize z->sort rr = z->soa z->set_soa(rr) rrlist = z->rrs z->set_rrs(rrlist) z->sign(keylist) z->sign_nsec3(keylist, algorithm, flags, iterations, salt) =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/Packet.pm0000644000175000017500000001175615212267527020373 0ustar willemwillempackage DNS::LDNS::Packet; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; sub new { my ($class, %args) = @_; if ($args{name}) { return _query_new( $args{name}, $args{type}, $args{class}, $args{flags}); } else { return _new; } } sub question { my $self = shift; return DNS::LDNS::GC::own($self->_question, $self); } sub set_question { my ($self, $l) = @_; DNS::LDNS::GC::disown(my $old = $self->question); $self->_set_question($l); return DNS::LDNS::GC::own($l, $self); } sub answer { my $self = shift; return DNS::LDNS::GC::own($self->_answer, $self); } sub set_answer { my ($self, $l) = @_; DNS::LDNS::GC::disown(my $old = $self->answer); $self->_set_answer($l); return DNS::LDNS::GC::own($l, $self); } sub authority { my $self = shift; return DNS::LDNS::GC::own($self->_authority, $self); } sub set_authority { my ($self, $l) = @_; DNS::LDNS::GC::disown(my $old = $self->authority); $self->_set_authority($l); return DNS::LDNS::GC::own($l, $self); } sub additional { my $self = shift; return DNS::LDNS::GC::own($self->_additional, $self); } sub set_additional { my ($self, $l) = @_; DNS::LDNS::GC::disown(my $old = $self->additional); $self->_set_additional($l); return DNS::LDNS::GC::own($l, $self); } sub answerfrom { my $self = shift; return DNS::LDNS::GC::own($self->_answerfrom, $self); } sub set_answerfrom { my ($self, $a) = @_; DNS::LDNS::GC::disown(my $old = $self->answerfrom); $self->_set_answerfrom($a); return DNS::LDNS::GC::own($a, $self); } sub timestamp { my $self = shift; my $t = _timestamp($self); return wantarray ? @$t : $t; } sub edns_data { my $self = shift; return DNS::LDNS::GC::own($self->_edns_data, $self); } sub set_edns_data { my ($self, $data) = @_; DNS::LDNS::GC::disown(my $old = $self->edns_data); $self->_set_edns_data($data); return DNS::LDNS::GC::own($data, $self); } sub push_rr { my ($self, $sec, $rr) = @_; my $ret = $self->_push_rr($sec, my $copy = $_->clone); DNS::LDNS::GC::own($copy, $self); return $ret; } sub safe_push_rr { my ($self, $sec, $rr) = @_; my $ret = $self->_safe_push_rr($sec, my $copy = $_->clone); if ($ret) { DNS::LDNS::GC::own($copy, $self); } return $ret; } sub tsig { my $self = shift; return DNS::LDNS::GC::own($self->_tsig, $self); } sub set_tsig { my ($self, $rr) = @_; DNS::LDNS::GC::disown(my $old = $self->tsig); $self->_set_tsig($rr); return DNS::LDNS::GC::own($rr, $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::Packet - DNS packet =head1 SYNOPSIS use DNS::LDNS ':all' my pkt = new DNS::LDNS::Packet(name => rdata, type => LDNS_RR_TYPE_..., class => LDNS_RR_CLASS_..., flags => ...) my pkt = new DNS::LDNS::Packet pkt2 = pkt->clone pkt->to_string rrlist = pkt->question pkt->set_question(rrlist) ' rrlist = pkt->answer pkt->set_answer(rrlist) rrlist = pkt->authority pkt->set_authority(rrlist) rrlist = pkt->additional pkt->set_additional(rrlist) rrlist = pkt->all rrlist = pkt->all_noquestion for (qw/qr aa tc rd cd ra ad/) { bool = pkt->$_ pkt->set_$_(bool) } id = pkt->id pkt->set_id(id) pkt->set_random_id count = pkt->qdcount count = pkt->ancount count = pkt->nscount count = pkt->arcount opcode = pkt->opcode pkt->set_opcode(opcode) rcode = pkt->rcode # Response code pkt->set_rcode(rcode) size = pkt->size epoch = pkt->querytime pkt->set_querytime(epoch) rdata = pkt->answerfrom pkt->set_answerfrom(rdata) (sec, usec) = pkt->timestamp pkt->set_timestamp(sec, usec) bool = pkt->edns size = pkt->edns_udp_size pkt->set_edns_udp_size(size) rcode = pkt->edns_extended_rcode pkt->set_edns_extended_rcode(rcode) v = pkt->edns_version pkt->set_edns_version(v) z = pkt->edns_z pkt->set_edns_z(z) do = pkt->edns_do pkt->set_edns_do(do) rdata = pkt->edns_data pkt->set_edns_data(rdata) pkt->set_flags(flags) rrlist = pkt->rr_list_by_name(rdata, section) rrlist = pkt->rr_list_by_type(type, section) rrlist = pkt->rr_list_by_name_and_type(rdata, type, section) bool = pkt->rr(section, rr) # Check if rr exists pkt->push_rr(section, rr) pkt->safe_push_rr(section, rr) count = pkt->section_count(section) bool = pkt->empty rr = pkt->tsig pkt->set_tsig(rr) type = pkt->reply_type rrlist = pkt->get_rrsigs_for_name_and_type(rdata, rrtype) rrlist = pkt->get_rrsigs_for_type(rrtype) =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/Resolver.pm0000644000175000017500000001700015212267527020751 0ustar willemwillempackage DNS::LDNS::Resolver; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my ($class, %args) = @_; my $file; my $status = &LDNS_STATUS_OK; if ($args{filename}) { unless (open FILE, $args{filename}) { $DNS::LDNS::last_status = &LDNS_STATUS_FILE_ERR; $DNS::LDNS::line_nr = 0; return; } $file = \*FILE; } elsif ($args{file}) { $file = $args{file}; } my $resolver; if ($file) { $resolver = _new_from_file($file, $status); } else { $resolver = _new(); } if ($args{filename}) { close $file; } $DNS::LDNS::last_status = $status; if (!defined $resolver) { return; } return $resolver; } sub dnssec_anchors { my $self = shift; return DNS::LDNS::GC::own($self->_dnssec_anchors, $self); } sub push_dnssec_anchor { my ($self, $rr) = @_; _push_dnssec_anchor($self, my $copy = $rr->clone); DNS::LDNS::GC::own($copy, $self); } sub set_dnssec_anchors { my ($self, $l) = @_; DNS::LDNS::GC::disown(my $old = $self->dnssec_anchors); $self->_set_dnssec_anchors($l); DNS::LDNS::GC::own($l, $self); return $l; } sub domain { my $self = shift; return DNS::LDNS::GC::own($self->_domain, $self); } sub set_domain { my ($self, $dom) = @_; DNS::LDNS::GC::disown(my $old = $self->domain); _set_domain($self, my $copy = $dom->clone); DNS::LDNS::GC::own($copy, $self); } sub nameservers { my $self = shift; my $list = _nameservers($self); for my $r (@$list) { DNS::LDNS::GC::own($r, $self); } return wantarray ? @$list : $list; } sub push_nameserver { my ($self, $n) = @_; my $s = _push_nameserver($self, my $copy = $n->clone); DNS::LDNS::GC::own($copy, $self); $DNS::LDNS::last_status = $s; return $s; } sub pop_nameserver { my $self = shift; return DNS::LDNS::GC::own($self->_pop_nameserver); } sub push_searchlist { my ($self, $rd) = @_; _push_searchlist($self, my $copy = $rd->clone); DNS::LDNS::GC::own($copy, $self); } sub searchlist { my $self = shift; my $list = _searchlist($self); for my $r (@$list) { DNS::LDNS::GC::own($r, $self); } return wantarray ? @$list : $list; } sub timeout { my $self = shift; my $t = _timeout($self); return wantarray ? @$t : $t; } sub rtt { my $self = shift; my $list = _rtt($self); return wantarray ? @$list : $list; } sub set_rtt { my ($self, @rtt) = @_; # FIXME: Validate @rtt, existence, size _set_rtt($self, \@rtt); } sub fetch_valid_domain_keys { my ($self, $domain, $keys) = @_; my $status; my $trusted = _fetch_valid_domain_keys($self, $domain, $keys, $status); $DNS::LDNS::last_status = $status; if (!$trusted) { return; } return DNS::LDNS::GC::own($trusted, $self); } sub fetch_valid_domain_keys_time { my ($self, $domain, $keys, $checktime) = @_; my $status; my $trusted = _fetch_valid_domain_keys_time( $self, $domain, $keys, $checktime, $status); $DNS::LDNS::last_status = $status; if (!$trusted) { return; } return DNS::LDNS::GC::own($trusted, $self); } sub prepare_query_pkt { my ($self, $rdata, $type, $class, $flags) = @_; my $s = &LDNS_STATUS_OK; my $qry = _prepare_query_pkt($self, $rdata, $type, $class, $flags, $s); $DNS::LDNS::last_status = $s; if ($s != LDNS_STATUS_OK) { return; } return $qry; } sub send { my ($self, $rdata, $type, $class, $flags) = @_; my $s = &LDNS_STATUS_OK; my $ans = _send($self, $rdata, $type, $class, $flags, $s); $DNS::LDNS::last_status = $s; if ($s != LDNS_STATUS_OK) { return; } return $ans; } sub send_pkt { my ($self, $qry) = @_; my $s = &LDNS_STATUS_OK; my $ans = _send_pkt($self, $qry, $s); $DNS::LDNS::last_status = $s; if ($s != LDNS_STATUS_OK) { return; } return $ans; } sub verify_trusted { my ($self, $rrset, $rrsigs, $validating_keys) = @_; my $s = _verify_trusted($self, $rrset, $rrsigs, $validating_keys); $DNS::LDNS::last_status = $s; return $s; } sub verify_trusted_time { my ($self, $rrset, $rrsigs, $check_time, $validating_keys) = @_; my $s = _verify_trusted_time($self, $rrset, $rrsigs, $check_time, $validating_keys); $DNS::LDNS::last_status = $s; return $s; } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::Resolver - DNS resolver =head1 SYNOPSIS use DNS::LDNS ':all' my r = new DNS::LDNS::Resolver(filename => '/my/resolv.conf') my r = new DNS::LDNS::Resolver(file => \*FILE) my r = new DNS::LDNS::Resolver bool = r->dnssec r->set_dnssec(bool) bool = r->dnssec_cd # Resolver sets the CD bit r->set_dnssec_cd(bool) port = r->port r->set_port(port) bool = r->recursive r->set_recursive(bool) bool = r->debug r->set_debug(bool) count = r->retry r->set_retry(count) count = r->retrans r->set_retrans(count) bool = r->fallback # Resolver truncation fallback mechanism r->set_fallback(bool) bool = r->ip6 r->set_ip6(bool) size = r->edns_udp_size r->set_edns_udp_size(size) bool = r->usevc # Use virtual circuit (TCP) r->set_usevc(bool) r->fail r->set_fail r->defnames r->set_defnames r->dnsrch r->set_dnsrch r->igntc r->set_igntc bool = r->random # randomize nameserver before usage r->set_random(bool) rrlist = r->dnssec_anchors # list of trusted DNSSEC anchors r->push_dnssec_anchor(rr) r->set_dnssec_anchors(rrlist) rdata = r->domain # Domain to add to relative queries r->set_domain(rdata) @rdata = r->nameservers count = r->nameserver_count r->push_nameserver(rdata) rdata = r->pop_nameserver r->nameservers_randomize str = r->tsig_keyname r->set_tsig_keyname(str) str = r->tsig_algorithm r->set_tsig_algorithm(str) str = r->tsig_keydata r->set_tsig_keydata(str) count = r->searchlist_count r->push_searchlist(rdata) @rdata = r->searchlist @times = r->rtt # Round trip times r->set_rtt(@rtt) time = r->nameserver_rtt(pos) r->set_nameserver_rtt(pos, time) (sec, usec) = r->timeout r->set_timeout(sec, usec) # DNSSec validation rrlist = r->fetch_valid_domain_keys(domain, keys) rrlist = r->fetch_valid_domain_keys_time(domain, keys, checktime) rrlist = r->validate_domain_ds(domain, keys) rrlist = r->validate_domain_ds_time(domain, keys, checktime) rrlist = r->validate_domain_dnskey(domain, keys) rrlist = r->validate_domain_dnskey_time(domain, keys, checktime) status = r->verify_trusted(rrset, rrsigs, validation_keys) status = r->verify_trusted_time(rrset, rrsigs, checktime, validation_keys) bool = r->trusted_key(keys, trusted_keys) chain = r->build_data_chain(qflags, dataset, pkt, orig_rr) # Query pkt = r->query(rdata, type, class, flags) pkt = r->search(rdata, type, class, flags) query = r->prepare_query_pkt(rdata, type, class, flags) answer = r->send(rdata, type, class, flags) answer = r->send_pkt(query) rrlist = r->get_rr_list_addr_by_name(name, class, flags) rrlist = r->get_rr_list_name_by_addr(addr, class, flags) =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecRRSets.pm0000644000175000017500000000325215212267527021336 0ustar willemwillempackage DNS::LDNS::DNSSecRRSets; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; # Note: Since this class does not have a constructor, we can let its child # objects be owned by the parent. This reduces the recursion depth on # DESTROY. sub rrs { my $self = shift; return DNS::LDNS::GC::own($self->_rrs, DNS::LDNS::GC::owner($self)); } sub signatures { my $self = shift; return DNS::LDNS::GC::own($self->_signatures, DNS::LDNS::GC::owner($self)); } sub next { my $self = shift; return DNS::LDNS::GC::own($self->_next, DNS::LDNS::GC::owner($self)); } sub set_type { my ($self, $type) = @_; my $s = _set_type($self, $type); $DNS::LDNS::last_status = $s; return $s; } sub add_rr { my ($self, $rr) = @_; my $s = _add_rr($self, my $copy = $rr->clone); $DNS::LDNS::last_status = $s; DNS::LDNS::GC::own($copy, $self); return $s; } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::DNSSecRRSets - Linked list of rrsets in a dnssec zone =head1 SYNOPSIS use DNS::LDNS ':all' rrs = rrsets->rrs rrs = rrsets->signatures rrsets2 = rrsets->next rrsets->add_rr(rr) bool = rrsets->contains_type(rr_type) rr_type = rrsets->type rrsets->set_type(rr_type) =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/KeyList.pm0000644000175000017500000000224415212267527020540 0ustar willemwillempackage DNS::LDNS::KeyList; use 5.008008; use strict; use warnings; use DNS::LDNS ':all'; our $VERSION = '0.61'; sub new { my $class = shift; return _new(); } sub push { my ($self, @keys) = @_; for my $k (@keys) { if (DNS::LDNS::GC::is_owned($k)) { die "Cannot push a key on multiple lists."; } $self->_push($k); DNS::LDNS::GC::own($k, $self); } } sub key { my ($self, $index) = @_; return DNS::LDNS::GC::own($self->_key($index), $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::KeyList - Linked list of dnssec keys =head1 SYNOPSIS use DNS::LDNS ':all' my l = new DNS::LDNS::KeyList l->set_use(bool) l->push(@keys) key = l->pop c = l->count key = l->key(index) =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/RBNode.pm0000644000175000017500000000250215212267527020262 0ustar willemwillempackage DNS::LDNS::RBNode; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; # Note: This class does not have a constructor. Thus, it can not be created # as an individual object. The data structure of the object will always be # owned and freed by its parent object. sub next { my $self = shift; return DNS::LDNS::GC::own($self->_next, $self); } sub previous { my $self = shift; return DNS::LDNS::GC::own($self->_previous, $self); } sub next_nonglue { my $self = shift; return DNS::LDNS::GC::own($self->_next_nonglue, $self); } sub name { my ($self) = @_; return DNS::LDNS::GC::own($self->_name, $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::RBNode - Node in the RBTree =head1 SYNOPSIS use DNS::LDNS ':all' node2 = node->next node2 = node->next_nonglue bool = node->is_null dnssec_name = node->name =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/RBTree.pm0000644000175000017500000000205415212267527020276 0ustar willemwillempackage DNS::LDNS::RBTree; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; # Note: Since this class does not have a constructor, we can let its child # objects be owned by the parent. This reduces the recursion depth on # DESTROY. sub first { my $self = shift; return DNS::LDNS::GC::own($self->_first, $self); } sub last { my $self = shift; return DNS::LDNS::GC::own($self->_last, $self); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::RBTree - Tree of DNSSecName nodes =head1 SYNOPSIS use DNS::LDNS ':all' rbnode = rbtree->first rbnode = rbtree->last =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecRRs.pm0000644000175000017500000000307615212267527020666 0ustar willemwillempackage DNS::LDNS::DNSSecRRs; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; # Note: This class does not have a constructor. Thus, it can not be created # as an individual object. The data structure of the node is owned # and freed by the owner of the parent rather than the parent node. This # is to prevent deep recursion on DESTROY. sub to_string { my $self = shift; my $ret = ''; while ($self and $self->rr) { $ret .= $self->rr->to_string; $self = $self->next; } return $ret; } sub add_rr { my ($self, $rr) = @_; my $s = _add_rr($self, my $copy = $rr->clone); DNS::LDNS::GC::own($self, $copy); $DNS::LDNS::last_status = $s; return $s; } sub rr { my $self = shift; return DNS::LDNS::GC::own($self->_rr, DNS::LDNS::GC::owner($self)); } sub next { my $self = shift; return DNS::LDNS::GC::own($self->_next, DNS::LDNS::GC::owner($self)); } sub DESTROY { DNS::LDNS::GC::free($_[0]); } 1; __END__ =head1 NAME DNS::LDNS::DNSSecRRs - Linked list of rrs in a dnssec zone =head1 SYNOPSIS use DNS::LDNS ':all' rrs->to_string rrs->add_rr(rr) rr = rrs->rr rrs2 = rrs->next =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/contrib/DNS-LDNS/lib/DNS/LDNS/DNSSecTrustTree.pm0000644000175000017500000000375715212267527022127 0ustar willemwillempackage DNS::LDNS::DNSSecTrustTree; use 5.008008; use strict; use warnings; use DNS::LDNS; our $VERSION = '0.61'; sub add_parent { my ($self, $parent, $sig, $parent_status) = @_; if (DNS::LDNS::GC::is_owned($parent)) { die "Cannot add to multiple trees."; } my $s = _add_parent($self, $parent, $sig, $parent_status); DNS::LDNS::GC::own($parent, $self); $DNS::LDNS::last_status = $s; return $s; } sub contains_keys { my ($self, $trusted_keys) = @_; my $s = _contains_keys($self, $trusted_keys); $DNS::LDNS::last_status = $s; return $s; } sub rr { my $self = shift; return DNS::LDNS::GC::own($self->_rr, $self); } sub rrset { my $self = shift; return DNS::LDNS::GC::own($self->_rrset, $self); } sub parent { my ($self, $i) = @_; return DNS::LDNS::GC::own($self->_parent($i), $self); } sub parent_status { my ($self, $i) = @_; my $s = _parent_status($self, $i); $DNS::LDNS::last_status = $s; return $s; } sub parent_signature { my ($self, $i) = @_; return DNS::LDNS::GC::own($self->_parent_signature($i), $self); } 1; __END__ =head1 NAME DNS::LDNS::DNSSecTrustTree - Trust tree from signed RR to trust anchors =head1 SYNOPSIS use DNS::LDNS ':all' tree = new DNS::LDNS::DNSSecTrustTree tree->print(fp) d = tree->depth status = tree->add_parent(parent, sig, parent_status) status = tree->contains_keys(trusted_keys) # Node attributes rr = tree->rr; rrset = tree->rrset ptree = tree->parent(i) pstatus = tree->parent_status(i) rr = tree->parent_signature(i) count = tree->parent_count =head1 SEE ALSO http://www.nlnetlabs.nl/projects/ldns =head1 AUTHOR Erik Pihl Ostlyngen, Eerik.ostlyngen@uninett.noE =head1 COPYRIGHT AND LICENSE Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut ldns-1.9.2/sha2.c0000664000175000017500000007456215212267520013052 0ustar willemwillem/* * FILE: sha2.c * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ * * Copyright (c) 2000-2001, Aaron D. Gifford * All rights reserved. * * Modified by Jelte Jansen to fit in ldns, and not clash with any * system-defined SHA code. * Changes: * - Renamed (external) functions and constants to fit ldns style * - Removed _End and _Data functions * - Added ldns_shaX(data, len, digest) convenience functions * - Removed prototypes of _Transform functions and made those static * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holder nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ */ #include #include /* memcpy()/memset() or bcopy()/bzero() */ #include /* assert() */ #include /* * ASSERT NOTE: * Some sanity checking code is included using assert(). On my FreeBSD * system, this additional code can be removed by compiling with NDEBUG * defined. Check your own systems manpage on assert() to see how to * compile WITHOUT the sanity checking code on your system. * * UNROLLED TRANSFORM LOOP NOTE: * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform * loop version for the hash transform rounds (defined using macros * later in this file). Either define on the command line, for example: * * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c * * or define below: * * #define SHA2_UNROLL_TRANSFORM * */ /*** SHA-256/384/512 Machine Architecture Definitions *****************/ /* * BYTE_ORDER NOTE: * * Please make sure that your system defines BYTE_ORDER. If your * architecture is little-endian, make sure it also defines * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are * equivalent. * * If your system does not define the above, then you can do so by * hand like this: * * #define LITTLE_ENDIAN 1234 * #define BIG_ENDIAN 4321 * * And for little-endian machines, add: * * #define BYTE_ORDER LITTLE_ENDIAN * * Or for big-endian machines: * * #define BYTE_ORDER BIG_ENDIAN * * The FreeBSD machine this was written on defines BYTE_ORDER * appropriately by including (which in turn includes * where the appropriate definitions are actually * made). */ #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN #endif typedef uint8_t sha2_byte; /* Exactly 1 byte */ typedef uint32_t sha2_word32; /* Exactly 4 bytes */ #ifdef S_SPLINT_S typedef unsigned long long sha2_word64; /* lint 8 bytes */ #else typedef uint64_t sha2_word64; /* Exactly 8 bytes */ #endif /*** SHA-256/384/512 Various Length Definitions ***********************/ /* NOTE: Most of these are in sha2.h */ #define ldns_sha256_SHORT_BLOCK_LENGTH (LDNS_SHA256_BLOCK_LENGTH - 8) #define ldns_sha384_SHORT_BLOCK_LENGTH (LDNS_SHA384_BLOCK_LENGTH - 16) #define ldns_sha512_SHORT_BLOCK_LENGTH (LDNS_SHA512_BLOCK_LENGTH - 16) /*** ENDIAN REVERSAL MACROS *******************************************/ #if BYTE_ORDER == LITTLE_ENDIAN #define REVERSE32(w,x) { \ sha2_word32 tmp = (w); \ tmp = (tmp >> 16) | (tmp << 16); \ (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ } #ifndef S_SPLINT_S #define REVERSE64(w,x) { \ sha2_word64 tmp = (w); \ tmp = (tmp >> 32) | (tmp << 32); \ tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ ((tmp & 0x0000ffff0000ffffULL) << 16); \ } #else /* splint */ #define REVERSE64(w,x) /* splint */ #endif /* splint */ #endif /* BYTE_ORDER == LITTLE_ENDIAN */ /* * Macro for incrementally adding the unsigned 64-bit integer n to the * unsigned 128-bit integer (represented using a two-element array of * 64-bit words): */ #define ADDINC128(w,n) { \ (w)[0] += (sha2_word64)(n); \ if ((w)[0] < (n)) { \ (w)[1]++; \ } \ } #ifdef S_SPLINT_S #undef ADDINC128 #define ADDINC128(w,n) /* splint */ #endif /* * Macros for copying blocks of memory and for zeroing out ranges * of memory. Using these macros makes it easy to switch from * using memset()/memcpy() and using bzero()/bcopy(). * * Please define either SHA2_USE_MEMSET_MEMCPY or define * SHA2_USE_BZERO_BCOPY depending on which function set you * choose to use: */ #if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY) /* Default to memset()/memcpy() if no option is specified */ #define SHA2_USE_MEMSET_MEMCPY 1 #endif #if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY) /* Abort with an error if BOTH options are defined */ #error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both! #endif #ifdef SHA2_USE_MEMSET_MEMCPY #define MEMSET_BZERO(p,l) memset((p), 0, (l)) #define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) #endif #ifdef SHA2_USE_BZERO_BCOPY #define MEMSET_BZERO(p,l) bzero((p), (l)) #define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l)) #endif /*** THE SIX LOGICAL FUNCTIONS ****************************************/ /* * Bit shifting and rotation (used by the six SHA-XYZ logical functions: * * NOTE: The naming of R and S appears backwards here (R is a SHIFT and * S is a ROTATION) because the SHA-256/384/512 description document * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this * same "backwards" definition. */ /* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ #define R(b,x) ((x) >> (b)) /* 32-bit Rotate-right (used in SHA-256): */ #define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) /* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ #define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) /* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ #define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) #define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) /* Four of six logical functions used in SHA-256: */ #define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) #define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) #define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) #define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) /* Four of six logical functions used in SHA-384 and SHA-512: */ #define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) #define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) #define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) #define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) /*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ /* Hash constant words K for SHA-256: */ static const sha2_word32 K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; /* initial hash value H for SHA-256: */ static const sha2_word32 ldns_sha256_initial_hash_value[8] = { 0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL, 0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL }; /* Hash constant words K for SHA-384 and SHA-512: */ static const sha2_word64 K512[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL }; /* initial hash value H for SHA-384 */ static const sha2_word64 sha384_initial_hash_value[8] = { 0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL, 0x152fecd8f70e5939ULL, 0x67332667ffc00b31ULL, 0x8eb44a8768581511ULL, 0xdb0c2e0d64f98fa7ULL, 0x47b5481dbefa4fa4ULL }; /* initial hash value H for SHA-512 */ static const sha2_word64 sha512_initial_hash_value[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL }; /*** SHA-256: *********************************************************/ void ldns_sha256_init(ldns_sha256_CTX* context) { if (context == (ldns_sha256_CTX*)0) { return; } MEMCPY_BCOPY(context->state, ldns_sha256_initial_hash_value, LDNS_SHA256_DIGEST_LENGTH); MEMSET_BZERO(context->buffer, LDNS_SHA256_BLOCK_LENGTH); context->bitcount = 0; } #ifdef SHA2_UNROLL_TRANSFORM /* Unrolled SHA-256 round macros: */ #if BYTE_ORDER == LITTLE_ENDIAN #define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ REVERSE32(*data++, W256[j]); \ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ K256[j] + W256[j]; \ (d) += T1; \ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ #else /* BYTE_ORDER == LITTLE_ENDIAN */ #define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ K256[j] + (W256[j] = *data++); \ (d) += T1; \ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ #endif /* BYTE_ORDER == LITTLE_ENDIAN */ #define ROUND256(a,b,c,d,e,f,g,h) \ s0 = W256[(j+1)&0x0f]; \ s0 = sigma0_256(s0); \ s1 = W256[(j+14)&0x0f]; \ s1 = sigma1_256(s1); \ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ (d) += T1; \ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ j++ static void ldns_sha256_Transform(ldns_sha256_CTX* context, const sha2_word32* data) { sha2_word32 a, b, c, d, e, f, g, h, s0, s1; sha2_word32 T1, *W256; int j; W256 = (sha2_word32*)context->buffer; /* initialize registers with the prev. intermediate value */ a = context->state[0]; b = context->state[1]; c = context->state[2]; d = context->state[3]; e = context->state[4]; f = context->state[5]; g = context->state[6]; h = context->state[7]; j = 0; do { /* Rounds 0 to 15 (unrolled): */ ROUND256_0_TO_15(a,b,c,d,e,f,g,h); ROUND256_0_TO_15(h,a,b,c,d,e,f,g); ROUND256_0_TO_15(g,h,a,b,c,d,e,f); ROUND256_0_TO_15(f,g,h,a,b,c,d,e); ROUND256_0_TO_15(e,f,g,h,a,b,c,d); ROUND256_0_TO_15(d,e,f,g,h,a,b,c); ROUND256_0_TO_15(c,d,e,f,g,h,a,b); ROUND256_0_TO_15(b,c,d,e,f,g,h,a); } while (j < 16); /* Now for the remaining rounds to 64: */ do { ROUND256(a,b,c,d,e,f,g,h); ROUND256(h,a,b,c,d,e,f,g); ROUND256(g,h,a,b,c,d,e,f); ROUND256(f,g,h,a,b,c,d,e); ROUND256(e,f,g,h,a,b,c,d); ROUND256(d,e,f,g,h,a,b,c); ROUND256(c,d,e,f,g,h,a,b); ROUND256(b,c,d,e,f,g,h,a); } while (j < 64); /* Compute the current intermediate hash value */ context->state[0] += a; context->state[1] += b; context->state[2] += c; context->state[3] += d; context->state[4] += e; context->state[5] += f; context->state[6] += g; context->state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; } #else /* SHA2_UNROLL_TRANSFORM */ static void ldns_sha256_Transform(ldns_sha256_CTX* context, const sha2_word32* data) { sha2_word32 a, b, c, d, e, f, g, h, s0, s1; sha2_word32 T1, T2, *W256; int j; W256 = (sha2_word32*)context->buffer; /* initialize registers with the prev. intermediate value */ a = context->state[0]; b = context->state[1]; c = context->state[2]; d = context->state[3]; e = context->state[4]; f = context->state[5]; g = context->state[6]; h = context->state[7]; j = 0; do { #if BYTE_ORDER == LITTLE_ENDIAN /* Copy data while converting to host byte order */ REVERSE32(*data++,W256[j]); /* Apply the SHA-256 compression function to update a..h */ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; #else /* BYTE_ORDER == LITTLE_ENDIAN */ /* Apply the SHA-256 compression function to update a..h with copy */ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); #endif /* BYTE_ORDER == LITTLE_ENDIAN */ T2 = Sigma0_256(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; j++; } while (j < 16); do { /* Part of the message block expansion: */ s0 = W256[(j+1)&0x0f]; s0 = sigma0_256(s0); s1 = W256[(j+14)&0x0f]; s1 = sigma1_256(s1); /* Apply the SHA-256 compression function to update a..h */ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); T2 = Sigma0_256(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; j++; } while (j < 64); /* Compute the current intermediate hash value */ context->state[0] += a; context->state[1] += b; context->state[2] += c; context->state[3] += d; context->state[4] += e; context->state[5] += f; context->state[6] += g; context->state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; (void)a; (void)b; (void)c; (void)d; (void)e; (void)f; (void)g; (void)h; (void)T1; (void)T2; } #endif /* SHA2_UNROLL_TRANSFORM */ void ldns_sha256_update(ldns_sha256_CTX* context, const sha2_byte *data, size_t len) { size_t freespace, usedspace; if (len == 0) { /* Calling with no data is valid - we do nothing */ return; } /* Sanity check: */ assert(context != (ldns_sha256_CTX*)0 && data != (sha2_byte*)0); usedspace = (context->bitcount >> 3) % LDNS_SHA256_BLOCK_LENGTH; if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = LDNS_SHA256_BLOCK_LENGTH - usedspace; if (len >= freespace) { /* Fill the buffer completely and process it */ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); context->bitcount += freespace << 3; len -= freespace; data += freespace; ldns_sha256_Transform(context, (sha2_word32*)context->buffer); } else { /* The buffer is not yet full */ MEMCPY_BCOPY(&context->buffer[usedspace], data, len); context->bitcount += len << 3; /* Clean up: */ usedspace = freespace = 0; (void)usedspace; (void)freespace; return; } } while (len >= LDNS_SHA256_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ ldns_sha256_Transform(context, (sha2_word32*)data); context->bitcount += LDNS_SHA256_BLOCK_LENGTH << 3; len -= LDNS_SHA256_BLOCK_LENGTH; data += LDNS_SHA256_BLOCK_LENGTH; } if (len > 0) { /* There's left-overs, so save 'em */ MEMCPY_BCOPY(context->buffer, data, len); context->bitcount += len << 3; } /* Clean up: */ usedspace = freespace = 0; (void)usedspace; (void)freespace; } typedef union _ldns_sha2_buffer_union { uint8_t* theChars; uint64_t* theLongs; } ldns_sha2_buffer_union; void ldns_sha256_final(sha2_byte digest[LDNS_SHA256_DIGEST_LENGTH], ldns_sha256_CTX* context) { sha2_word32 *d = (sha2_word32*)digest; size_t usedspace; ldns_sha2_buffer_union cast_var; /* Sanity check: */ assert(context != (ldns_sha256_CTX*)0); /* If no digest buffer is passed, we don't bother doing this: */ if (digest != (sha2_byte*)0) { usedspace = (context->bitcount >> 3) % LDNS_SHA256_BLOCK_LENGTH; #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->bitcount,context->bitcount); #endif if (usedspace > 0) { /* Begin padding with a 1 bit: */ context->buffer[usedspace++] = 0x80; if (usedspace <= ldns_sha256_SHORT_BLOCK_LENGTH) { /* Set-up for the last transform: */ MEMSET_BZERO(&context->buffer[usedspace], ldns_sha256_SHORT_BLOCK_LENGTH - usedspace); } else { if (usedspace < LDNS_SHA256_BLOCK_LENGTH) { MEMSET_BZERO(&context->buffer[usedspace], LDNS_SHA256_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ ldns_sha256_Transform(context, (sha2_word32*)context->buffer); /* And set-up for the last transform: */ MEMSET_BZERO(context->buffer, ldns_sha256_SHORT_BLOCK_LENGTH); } } else { /* Set-up for the last transform: */ MEMSET_BZERO(context->buffer, ldns_sha256_SHORT_BLOCK_LENGTH); /* Begin padding with a 1 bit: */ *context->buffer = 0x80; } /* Set the bit count: */ cast_var.theChars = context->buffer; cast_var.theLongs[ldns_sha256_SHORT_BLOCK_LENGTH / 8] = context->bitcount; /* final transform: */ ldns_sha256_Transform(context, (sha2_word32*)context->buffer); #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; for (j = 0; j < 8; j++) { REVERSE32(context->state[j],context->state[j]); *d++ = context->state[j]; } } #else MEMCPY_BCOPY(d, context->state, LDNS_SHA256_DIGEST_LENGTH); #endif } /* Clean up state data: */ MEMSET_BZERO(context, sizeof(ldns_sha256_CTX)); usedspace = 0; (void)usedspace; } unsigned char * ldns_sha256(const unsigned char *data, unsigned int data_len, unsigned char *digest) { ldns_sha256_CTX ctx; ldns_sha256_init(&ctx); ldns_sha256_update(&ctx, data, data_len); ldns_sha256_final(digest, &ctx); return digest; } /*** SHA-512: *********************************************************/ void ldns_sha512_init(ldns_sha512_CTX* context) { if (context == (ldns_sha512_CTX*)0) { return; } MEMCPY_BCOPY(context->state, sha512_initial_hash_value, LDNS_SHA512_DIGEST_LENGTH); MEMSET_BZERO(context->buffer, LDNS_SHA512_BLOCK_LENGTH); context->bitcount[0] = context->bitcount[1] = 0; } #ifdef SHA2_UNROLL_TRANSFORM /* Unrolled SHA-512 round macros: */ #if BYTE_ORDER == LITTLE_ENDIAN #define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ REVERSE64(*data++, W512[j]); \ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ K512[j] + W512[j]; \ (d) += T1, \ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \ j++ #else /* BYTE_ORDER == LITTLE_ENDIAN */ #define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ K512[j] + (W512[j] = *data++); \ (d) += T1; \ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ j++ #endif /* BYTE_ORDER == LITTLE_ENDIAN */ #define ROUND512(a,b,c,d,e,f,g,h) \ s0 = W512[(j+1)&0x0f]; \ s0 = sigma0_512(s0); \ s1 = W512[(j+14)&0x0f]; \ s1 = sigma1_512(s1); \ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ (d) += T1; \ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ j++ static void ldns_sha512_Transform(ldns_sha512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; int j; /* initialize registers with the prev. intermediate value */ a = context->state[0]; b = context->state[1]; c = context->state[2]; d = context->state[3]; e = context->state[4]; f = context->state[5]; g = context->state[6]; h = context->state[7]; j = 0; do { ROUND512_0_TO_15(a,b,c,d,e,f,g,h); ROUND512_0_TO_15(h,a,b,c,d,e,f,g); ROUND512_0_TO_15(g,h,a,b,c,d,e,f); ROUND512_0_TO_15(f,g,h,a,b,c,d,e); ROUND512_0_TO_15(e,f,g,h,a,b,c,d); ROUND512_0_TO_15(d,e,f,g,h,a,b,c); ROUND512_0_TO_15(c,d,e,f,g,h,a,b); ROUND512_0_TO_15(b,c,d,e,f,g,h,a); } while (j < 16); /* Now for the remaining rounds up to 79: */ do { ROUND512(a,b,c,d,e,f,g,h); ROUND512(h,a,b,c,d,e,f,g); ROUND512(g,h,a,b,c,d,e,f); ROUND512(f,g,h,a,b,c,d,e); ROUND512(e,f,g,h,a,b,c,d); ROUND512(d,e,f,g,h,a,b,c); ROUND512(c,d,e,f,g,h,a,b); ROUND512(b,c,d,e,f,g,h,a); } while (j < 80); /* Compute the current intermediate hash value */ context->state[0] += a; context->state[1] += b; context->state[2] += c; context->state[3] += d; context->state[4] += e; context->state[5] += f; context->state[6] += g; context->state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; } #else /* SHA2_UNROLL_TRANSFORM */ static void ldns_sha512_Transform(ldns_sha512_CTX* context, const sha2_word64* data) { sha2_word64 a, b, c, d, e, f, g, h, s0, s1; sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; int j; sha2_word64 aligned; /* initialize registers with the prev. intermediate value */ a = context->state[0]; b = context->state[1]; c = context->state[2]; d = context->state[3]; e = context->state[4]; f = context->state[5]; g = context->state[6]; h = context->state[7]; j = 0; do { #if BYTE_ORDER == LITTLE_ENDIAN /* Convert TO host byte order */ memcpy(&aligned, data++, sizeof(aligned)); REVERSE64(aligned, W512[j]); /* Apply the SHA-512 compression function to update a..h */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; #else /* BYTE_ORDER == LITTLE_ENDIAN */ /* Apply the SHA-512 compression function to update a..h with copy */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); #endif /* BYTE_ORDER == LITTLE_ENDIAN */ T2 = Sigma0_512(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; j++; } while (j < 16); do { /* Part of the message block expansion: */ s0 = W512[(j+1)&0x0f]; s0 = sigma0_512(s0); s1 = W512[(j+14)&0x0f]; s1 = sigma1_512(s1); /* Apply the SHA-512 compression function to update a..h */ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); T2 = Sigma0_512(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2; j++; } while (j < 80); /* Compute the current intermediate hash value */ context->state[0] += a; context->state[1] += b; context->state[2] += c; context->state[3] += d; context->state[4] += e; context->state[5] += f; context->state[6] += g; context->state[7] += h; /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; (void)a; (void)b; (void)c; (void)d; (void)e; (void)f; (void)g; (void)h; (void)T1; (void)T2; } #endif /* SHA2_UNROLL_TRANSFORM */ void ldns_sha512_update(ldns_sha512_CTX* context, const sha2_byte *data, size_t len) { size_t freespace, usedspace; if (len == 0) { /* Calling with no data is valid - we do nothing */ return; } /* Sanity check: */ assert(context != (ldns_sha512_CTX*)0 && data != (sha2_byte*)0); usedspace = (context->bitcount[0] >> 3) % LDNS_SHA512_BLOCK_LENGTH; if (usedspace > 0) { /* Calculate how much free space is available in the buffer */ freespace = LDNS_SHA512_BLOCK_LENGTH - usedspace; if (len >= freespace) { /* Fill the buffer completely and process it */ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); ADDINC128(context->bitcount, freespace << 3); len -= freespace; data += freespace; ldns_sha512_Transform(context, (sha2_word64*)context->buffer); } else { /* The buffer is not yet full */ MEMCPY_BCOPY(&context->buffer[usedspace], data, len); ADDINC128(context->bitcount, len << 3); /* Clean up: */ usedspace = freespace = 0; (void)usedspace; (void)freespace; return; } } while (len >= LDNS_SHA512_BLOCK_LENGTH) { /* Process as many complete blocks as we can */ ldns_sha512_Transform(context, (sha2_word64*)data); ADDINC128(context->bitcount, LDNS_SHA512_BLOCK_LENGTH << 3); len -= LDNS_SHA512_BLOCK_LENGTH; data += LDNS_SHA512_BLOCK_LENGTH; } if (len > 0) { /* There's left-overs, so save 'em */ MEMCPY_BCOPY(context->buffer, data, len); ADDINC128(context->bitcount, len << 3); } /* Clean up: */ usedspace = freespace = 0; (void)usedspace; (void)freespace; } static void ldns_sha512_Last(ldns_sha512_CTX* context) { size_t usedspace; ldns_sha2_buffer_union cast_var; usedspace = (context->bitcount[0] >> 3) % LDNS_SHA512_BLOCK_LENGTH; #if BYTE_ORDER == LITTLE_ENDIAN /* Convert FROM host byte order */ REVERSE64(context->bitcount[0],context->bitcount[0]); REVERSE64(context->bitcount[1],context->bitcount[1]); #endif if (usedspace > 0) { /* Begin padding with a 1 bit: */ context->buffer[usedspace++] = 0x80; if (usedspace <= ldns_sha512_SHORT_BLOCK_LENGTH) { /* Set-up for the last transform: */ MEMSET_BZERO(&context->buffer[usedspace], ldns_sha512_SHORT_BLOCK_LENGTH - usedspace); } else { if (usedspace < LDNS_SHA512_BLOCK_LENGTH) { MEMSET_BZERO(&context->buffer[usedspace], LDNS_SHA512_BLOCK_LENGTH - usedspace); } /* Do second-to-last transform: */ ldns_sha512_Transform(context, (sha2_word64*)context->buffer); /* And set-up for the last transform: */ MEMSET_BZERO(context->buffer, LDNS_SHA512_BLOCK_LENGTH - 2); } } else { /* Prepare for final transform: */ MEMSET_BZERO(context->buffer, ldns_sha512_SHORT_BLOCK_LENGTH); /* Begin padding with a 1 bit: */ *context->buffer = 0x80; } /* Store the length of input data (in bits): */ cast_var.theChars = context->buffer; cast_var.theLongs[ldns_sha512_SHORT_BLOCK_LENGTH / 8] = context->bitcount[1]; cast_var.theLongs[ldns_sha512_SHORT_BLOCK_LENGTH / 8 + 1] = context->bitcount[0]; /* final transform: */ ldns_sha512_Transform(context, (sha2_word64*)context->buffer); } void ldns_sha512_final(sha2_byte digest[LDNS_SHA512_DIGEST_LENGTH], ldns_sha512_CTX* context) { sha2_word64 *d = (sha2_word64*)digest; /* Sanity check: */ assert(context != (ldns_sha512_CTX*)0); /* If no digest buffer is passed, we don't bother doing this: */ if (digest != (sha2_byte*)0) { ldns_sha512_Last(context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; for (j = 0; j < 8; j++) { REVERSE64(context->state[j],context->state[j]); *d++ = context->state[j]; } } #else MEMCPY_BCOPY(d, context->state, LDNS_SHA512_DIGEST_LENGTH); #endif } /* Zero out state data */ MEMSET_BZERO(context, sizeof(ldns_sha512_CTX)); } unsigned char * ldns_sha512(const unsigned char *data, unsigned int data_len, unsigned char *digest) { ldns_sha512_CTX ctx; ldns_sha512_init(&ctx); ldns_sha512_update(&ctx, data, data_len); ldns_sha512_final(digest, &ctx); return digest; } /*** SHA-384: *********************************************************/ void ldns_sha384_init(ldns_sha384_CTX* context) { if (context == (ldns_sha384_CTX*)0) { return; } MEMCPY_BCOPY(context->state, sha384_initial_hash_value, LDNS_SHA512_DIGEST_LENGTH); MEMSET_BZERO(context->buffer, LDNS_SHA384_BLOCK_LENGTH); context->bitcount[0] = context->bitcount[1] = 0; } void ldns_sha384_update(ldns_sha384_CTX* context, const sha2_byte* data, size_t len) { ldns_sha512_update((ldns_sha512_CTX*)context, data, len); } void ldns_sha384_final(sha2_byte digest[LDNS_SHA384_DIGEST_LENGTH], ldns_sha384_CTX* context) { sha2_word64 *d = (sha2_word64*)digest; /* Sanity check: */ assert(context != (ldns_sha384_CTX*)0); /* If no digest buffer is passed, we don't bother doing this: */ if (digest != (sha2_byte*)0) { ldns_sha512_Last((ldns_sha512_CTX*)context); /* Save the hash data for output: */ #if BYTE_ORDER == LITTLE_ENDIAN { /* Convert TO host byte order */ int j; for (j = 0; j < 6; j++) { REVERSE64(context->state[j],context->state[j]); *d++ = context->state[j]; } } #else MEMCPY_BCOPY(d, context->state, LDNS_SHA384_DIGEST_LENGTH); #endif } /* Zero out state data */ MEMSET_BZERO(context, sizeof(ldns_sha384_CTX)); } unsigned char * ldns_sha384(const unsigned char *data, unsigned int data_len, unsigned char *digest) { ldns_sha384_CTX ctx; ldns_sha384_init(&ctx); ldns_sha384_update(&ctx, data, data_len); ldns_sha384_final(digest, &ctx); return digest; } ldns-1.9.2/dname.c0000664000175000017500000003217315212267520013271 0ustar willemwillem/* * dname.c * * dname specific rdata implementations * A dname is a rdf structure with type LDNS_RDF_TYPE_DNAME * It is not a /real/ type! All function must therefore check * for LDNS_RDF_TYPE_DNAME. * * a Net::DNS like library for C * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ #include #include #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif /* Returns whether the last label in the name is a root label (a empty label). * Note that it is not enough to just test the last character to be 0, * because it may be part of the last label itself. */ static bool ldns_dname_last_label_is_root_label(const ldns_rdf* dname) { size_t src_pos; size_t len = 0; for (src_pos = 0; src_pos < ldns_rdf_size(dname); src_pos += len + 1) { len = ldns_rdf_data(dname)[src_pos]; } assert(src_pos == ldns_rdf_size(dname)); return src_pos > 0 && len == 0; } ldns_rdf * ldns_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2) { ldns_rdf *new; uint16_t new_size; uint8_t *buf; uint16_t left_size; if (ldns_rdf_get_type(rd1) != LDNS_RDF_TYPE_DNAME || ldns_rdf_get_type(rd2) != LDNS_RDF_TYPE_DNAME) { return NULL; } /* remove root label if it is present at the end of the left * rd, by reducing the size with 1 */ left_size = ldns_rdf_size(rd1); if (ldns_dname_last_label_is_root_label(rd1)) { left_size--; } /* we overwrite the nullbyte of rd1 */ new_size = left_size + ldns_rdf_size(rd2); buf = LDNS_XMALLOC(uint8_t, new_size); if (!buf) { return NULL; } /* put the two dname's after each other */ memcpy(buf, ldns_rdf_data(rd1), left_size); memcpy(buf + left_size, ldns_rdf_data(rd2), ldns_rdf_size(rd2)); new = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME, new_size, buf); LDNS_FREE(buf); return new; } ldns_status ldns_dname_cat(ldns_rdf *rd1, const ldns_rdf *rd2) { uint16_t left_size; uint16_t size; uint8_t* newd; if (ldns_rdf_get_type(rd1) != LDNS_RDF_TYPE_DNAME || ldns_rdf_get_type(rd2) != LDNS_RDF_TYPE_DNAME) { return LDNS_STATUS_ERR; } /* remove root label if it is present at the end of the left * rd, by reducing the size with 1 */ left_size = ldns_rdf_size(rd1); if (ldns_dname_last_label_is_root_label(rd1)) { left_size--; } size = left_size + ldns_rdf_size(rd2); newd = LDNS_XREALLOC(ldns_rdf_data(rd1), uint8_t, size); if(!newd) { return LDNS_STATUS_MEM_ERR; } ldns_rdf_set_data(rd1, newd); memcpy(ldns_rdf_data(rd1) + left_size, ldns_rdf_data(rd2), ldns_rdf_size(rd2)); ldns_rdf_set_size(rd1, size); return LDNS_STATUS_OK; } ldns_rdf* ldns_dname_reverse(const ldns_rdf *dname) { size_t rd_size; uint8_t* buf; ldns_rdf* new; size_t src_pos; size_t len ; assert(ldns_rdf_get_type(dname) == LDNS_RDF_TYPE_DNAME); rd_size = ldns_rdf_size(dname); buf = LDNS_XMALLOC(uint8_t, rd_size); if (! buf) { return NULL; } new = ldns_rdf_new(LDNS_RDF_TYPE_DNAME, rd_size, buf); if (! new) { LDNS_FREE(buf); return NULL; } /* If dname ends in a root label, the reverse should too. */ if (ldns_dname_last_label_is_root_label(dname)) { buf[rd_size - 1] = 0; rd_size -= 1; } for (src_pos = 0; src_pos < rd_size; src_pos += len + 1) { len = ldns_rdf_data(dname)[src_pos]; memcpy(&buf[rd_size - src_pos - len - 1], &ldns_rdf_data(dname)[src_pos], len + 1); } return new; } ldns_rdf * ldns_dname_clone_from(const ldns_rdf *d, uint16_t n) { uint8_t *data; uint8_t label_size; size_t data_size; if (!d || ldns_rdf_get_type(d) != LDNS_RDF_TYPE_DNAME || ldns_dname_label_count(d) < n) { return NULL; } data = ldns_rdf_data(d); data_size = ldns_rdf_size(d); while (n > 0) { label_size = data[0] + 1; data += label_size; if (data_size < label_size) { /* this label is very broken */ return NULL; } data_size -= label_size; n--; } return ldns_dname_new_frm_data(data_size, data); } ldns_rdf * ldns_dname_left_chop(const ldns_rdf *d) { uint8_t label_pos; ldns_rdf *chop; if (!d) { return NULL; } if (ldns_rdf_get_type(d) != LDNS_RDF_TYPE_DNAME) { return NULL; } if (ldns_dname_label_count(d) == 0) { /* root label */ return NULL; } /* 05blaat02nl00 */ label_pos = ldns_rdf_data(d)[0]; chop = ldns_dname_new_frm_data(ldns_rdf_size(d) - label_pos - 1, ldns_rdf_data(d) + label_pos + 1); return chop; } uint8_t ldns_dname_label_count(const ldns_rdf *r) { uint16_t src_pos; uint16_t len; uint8_t i; size_t r_size; if (!r) { return 0; } i = 0; src_pos = 0; r_size = ldns_rdf_size(r); if (ldns_rdf_get_type(r) != LDNS_RDF_TYPE_DNAME) { return 0; } else { len = ldns_rdf_data(r)[src_pos]; /* start of the label */ /* single root label */ if (1 == r_size) { return 0; } else { while ((len > 0) && src_pos < r_size) { src_pos++; src_pos += len; len = ldns_rdf_data(r)[src_pos]; i++; } } } return i; } ldns_rdf * ldns_dname_new(uint16_t s, void *d) { ldns_rdf *rd; if (!s || !d) { return NULL; } rd = LDNS_MALLOC(ldns_rdf); if (!rd) { return NULL; } ldns_rdf_set_size(rd, s); ldns_rdf_set_type(rd, LDNS_RDF_TYPE_DNAME); ldns_rdf_set_data(rd, d); return rd; } ldns_rdf * ldns_dname_new_frm_str(const char *str) { return ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, str); } ldns_rdf * ldns_dname_new_frm_data(uint16_t size, const void *data) { return ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME, size, data); } void ldns_dname2canonical(const ldns_rdf *rd) { uint8_t *rdd; uint16_t i; if (ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_DNAME) { return; } rdd = (uint8_t*)ldns_rdf_data(rd); for (i = 0; i < ldns_rdf_size(rd); i++, rdd++) { *rdd = (uint8_t)LDNS_DNAME_NORMALIZE((int)*rdd); } } bool ldns_dname_is_subdomain(const ldns_rdf *sub, const ldns_rdf *parent) { uint8_t sub_lab; uint8_t par_lab; int8_t i, j; ldns_rdf *tmp_sub = NULL; ldns_rdf *tmp_par = NULL; ldns_rdf *sub_clone; ldns_rdf *parent_clone; bool result = true; if (ldns_rdf_get_type(sub) != LDNS_RDF_TYPE_DNAME || ldns_rdf_get_type(parent) != LDNS_RDF_TYPE_DNAME || ldns_rdf_compare(sub, parent) == 0) { return false; } /* would be nicer if we do not have to clone... */ sub_clone = ldns_dname_clone_from(sub, 0); parent_clone = ldns_dname_clone_from(parent, 0); ldns_dname2canonical(sub_clone); ldns_dname2canonical(parent_clone); sub_lab = ldns_dname_label_count(sub_clone); par_lab = ldns_dname_label_count(parent_clone); /* if sub sits above parent, it cannot be a child/sub domain */ if (sub_lab < par_lab) { result = false; } else { /* check all labels the from the parent labels, from right to left. * When they /all/ match we have found a subdomain */ j = sub_lab - 1; /* we count from zero, thank you */ for (i = par_lab -1; i >= 0; i--) { tmp_sub = ldns_dname_label(sub_clone, j); tmp_par = ldns_dname_label(parent_clone, i); if (!tmp_sub || !tmp_par) { /* deep free does null check */ ldns_rdf_deep_free(tmp_sub); ldns_rdf_deep_free(tmp_par); result = false; break; } if (ldns_rdf_compare(tmp_sub, tmp_par) != 0) { /* they are not equal */ ldns_rdf_deep_free(tmp_sub); ldns_rdf_deep_free(tmp_par); result = false; break; } ldns_rdf_deep_free(tmp_sub); ldns_rdf_deep_free(tmp_par); j--; } } ldns_rdf_deep_free(sub_clone); ldns_rdf_deep_free(parent_clone); return result; } int ldns_dname_compare(const ldns_rdf *dname1, const ldns_rdf *dname2) { size_t lc1, lc2, lc1f, lc2f; size_t i; int result = 0; uint8_t *lp1, *lp2; /* see RFC4034 for this algorithm */ /* this algorithm assumes the names are normalized to case */ /* only when both are not NULL we can say anything about them */ if (!dname1 && !dname2) { return 0; } if (!dname1 || !dname2) { return -1; } /* asserts must happen later as we are looking in the * dname, which could be NULL. But this case is handled * above */ assert(ldns_rdf_get_type(dname1) == LDNS_RDF_TYPE_DNAME); assert(ldns_rdf_get_type(dname2) == LDNS_RDF_TYPE_DNAME); lc1 = ldns_dname_label_count(dname1); lc2 = ldns_dname_label_count(dname2); if (lc1 == 0 && lc2 == 0) { return 0; } if (lc1 == 0) { return -1; } if (lc2 == 0) { return 1; } lc1--; lc2--; /* we start at the last label */ while (true) { /* find the label first */ lc1f = lc1; lp1 = ldns_rdf_data(dname1); while (lc1f > 0) { lp1 += *lp1 + 1; lc1f--; } /* and find the other one */ lc2f = lc2; lp2 = ldns_rdf_data(dname2); while (lc2f > 0) { lp2 += *lp2 + 1; lc2f--; } /* now check the label character for character. */ for (i = 1; i < (size_t)(*lp1 + 1); i++) { if (i > *lp2) { /* apparently label 1 is larger */ result = 1; goto done; } if (LDNS_DNAME_NORMALIZE((int) *(lp1 + i)) < LDNS_DNAME_NORMALIZE((int) *(lp2 + i))) { result = -1; goto done; } else if (LDNS_DNAME_NORMALIZE((int) *(lp1 + i)) > LDNS_DNAME_NORMALIZE((int) *(lp2 + i))) { result = 1; goto done; } } if (*lp1 < *lp2) { /* apparently label 2 is larger */ result = -1; goto done; } if (lc1 == 0 && lc2 > 0) { result = -1; goto done; } else if (lc1 > 0 && lc2 == 0) { result = 1; goto done; } else if (lc1 == 0 && lc2 == 0) { result = 0; goto done; } lc1--; lc2--; } done: return result; } int ldns_dname_is_wildcard(const ldns_rdf* dname) { return ( ldns_dname_label_count(dname) > 0 && ldns_rdf_data(dname)[0] == 1 && ldns_rdf_data(dname)[1] == '*'); } int ldns_dname_match_wildcard(const ldns_rdf *dname, const ldns_rdf *wildcard) { ldns_rdf *wc_chopped; int result; /* check whether it really is a wildcard */ if (ldns_dname_is_wildcard(wildcard)) { /* ok, so the dname needs to be a subdomain of the wildcard * without the * */ wc_chopped = ldns_dname_left_chop(wildcard); result = (int) ldns_dname_is_subdomain(dname, wc_chopped); ldns_rdf_deep_free(wc_chopped); } else { result = (ldns_dname_compare(dname, wildcard) == 0); } return result; } /* nsec test: does prev <= middle < next * -1 = yes * 0 = error/can't tell * 1 = no */ int ldns_dname_interval(const ldns_rdf *prev, const ldns_rdf *middle, const ldns_rdf *next) { int prev_check, next_check; assert(ldns_rdf_get_type(prev) == LDNS_RDF_TYPE_DNAME); assert(ldns_rdf_get_type(middle) == LDNS_RDF_TYPE_DNAME); assert(ldns_rdf_get_type(next) == LDNS_RDF_TYPE_DNAME); prev_check = ldns_dname_compare(prev, middle); next_check = ldns_dname_compare(middle, next); /* <= next. This cannot be the case for nsec, because then we would * have gotten the nsec of next... */ if (next_check == 0) { return 0; } /* <= */ if ((prev_check == -1 || prev_check == 0) && /* < */ next_check == -1) { return -1; } else { return 1; } } bool ldns_dname_str_absolute(const char *dname_str) { const char* s; if(dname_str && strcmp(dname_str, ".") == 0) return 1; if(!dname_str || strlen(dname_str) < 2) return 0; if(dname_str[strlen(dname_str) - 1] != '.') return 0; if(dname_str[strlen(dname_str) - 2] != '\\') return 1; /* ends in . and no \ before it */ /* so we have the case of ends in . and there is \ before it */ for(s=dname_str; *s; s++) { if(*s == '\\') { if(s[1] && s[2] && s[3] /* check length */ && isdigit((unsigned char)s[1]) && isdigit((unsigned char)s[2]) && isdigit((unsigned char)s[3])) s += 3; else if(!s[1] || isdigit((unsigned char)s[1])) /* escape of nul,0-9 */ return 0; /* parse error */ else s++; /* another character escaped */ } else if(!*(s+1) && *s == '.') return 1; /* trailing dot, unescaped */ } return 0; } bool ldns_dname_absolute(const ldns_rdf *rdf) { char *str = ldns_rdf2str(rdf); if (str) { bool r = ldns_dname_str_absolute(str); LDNS_FREE(str); return r; } return false; } ldns_rdf * ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos) { uint8_t labelcnt; uint16_t src_pos; uint16_t len; ldns_rdf *tmpnew; size_t s; uint8_t *data; if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_DNAME) { return NULL; } labelcnt = 0; src_pos = 0; s = ldns_rdf_size(rdf); len = ldns_rdf_data(rdf)[src_pos]; /* label start */ while ((len > 0) && src_pos < s) { if (labelcnt == labelpos) { /* found our label */ data = LDNS_XMALLOC(uint8_t, len + 2); if (!data) { return NULL; } memcpy(data, ldns_rdf_data(rdf) + src_pos, len + 1); data[len + 2 - 1] = 0; tmpnew = ldns_rdf_new( LDNS_RDF_TYPE_DNAME , len + 2, data); if (!tmpnew) { LDNS_FREE(data); return NULL; } return tmpnew; } src_pos++; src_pos += len; len = ldns_rdf_data(rdf)[src_pos]; labelcnt++; } return NULL; } ldns-1.9.2/update.c0000664000175000017500000001705615212267520013472 0ustar willemwillem/* update.c * * Functions for RFC 2136 Dynamic Update * * Copyright (c) 2005-2008, NLnet Labs. All rights reserved. * * See LICENSE for the license. */ #include #include #include #include #include /* * RFC 2136 sections mapped to RFC 1035: * zone/ZO -- QD/question * prerequisites/PR -- AN/answers * updates/UP -- NS/authority records * additional data/AD -- AR/additional records */ ldns_pkt * ldns_update_pkt_new(ldns_rdf *zone_rdf, ldns_rr_class c, const ldns_rr_list *pr_rrlist, const ldns_rr_list *up_rrlist, const ldns_rr_list *ad_rrlist) { ldns_pkt *p; if (!zone_rdf || !up_rrlist) { return NULL; } if (c == 0) { c = LDNS_RR_CLASS_IN; } /* Create packet, fill in Zone Section. */ p = ldns_pkt_query_new(zone_rdf, LDNS_RR_TYPE_SOA, c, LDNS_RD); if (!p) { return NULL; } zone_rdf = NULL; /* No longer safe to use. */ ldns_pkt_set_opcode(p, LDNS_PACKET_UPDATE); ldns_rr_list_deep_free(p->_authority); ldns_pkt_set_authority(p, ldns_rr_list_clone(up_rrlist)); ldns_update_set_upcount(p, ldns_rr_list_rr_count(up_rrlist)); if (pr_rrlist) { ldns_rr_list_deep_free(p->_answer); /*XXX access function */ ldns_pkt_set_answer(p, ldns_rr_list_clone(pr_rrlist)); ldns_update_set_prcount(p, ldns_rr_list_rr_count(pr_rrlist)); } if (ad_rrlist) { ldns_rr_list_deep_free(p->_additional); ldns_pkt_set_additional(p, ldns_rr_list_clone(ad_rrlist)); ldns_update_set_adcount(p, ldns_rr_list_rr_count(ad_rrlist)); } return p; } ldns_status ldns_update_pkt_tsig_add(ldns_pkt *p, const ldns_resolver *r) { #ifdef HAVE_SSL uint16_t fudge = 300; /* Recommended fudge. [RFC2845 6.4] */ if (ldns_resolver_tsig_keyname(r) && ldns_resolver_tsig_keydata(r)) return ldns_pkt_tsig_sign(p, ldns_resolver_tsig_keyname(r), ldns_resolver_tsig_keydata(r), fudge, ldns_resolver_tsig_algorithm(r), NULL); #else /* do nothing */ (void)p; (void)r; #endif /* HAVE_SSL */ /* No TSIG to do. */ return LDNS_STATUS_OK; } /* Move to higher.c or similar? */ /* XXX doc */ ldns_status ldns_update_soa_mname(ldns_rdf *zone, ldns_resolver *r, ldns_rr_class c, ldns_rdf **mname) { ldns_rr *soa_rr; ldns_pkt *query, *resp; /* Nondestructive, so clone 'zone' here */ query = ldns_pkt_query_new(ldns_rdf_clone(zone), LDNS_RR_TYPE_SOA, c, LDNS_RD); if (!query) { return LDNS_STATUS_ERR; } ldns_pkt_set_random_id(query); if (ldns_resolver_send_pkt(&resp, r, query) != LDNS_STATUS_OK) { ldns_pkt_free(query); return LDNS_STATUS_ERR; } ldns_pkt_free(query); if (!resp) { return LDNS_STATUS_ERR; } /* Expect a SOA answer. */ *mname = NULL; while ((soa_rr = ldns_rr_list_pop_rr(ldns_pkt_answer(resp)))) { if (ldns_rr_get_type(soa_rr) != LDNS_RR_TYPE_SOA || ldns_rr_rdf(soa_rr, 0) == NULL) continue; /* [RFC1035 3.3.13] */ *mname = ldns_rdf_clone(ldns_rr_rdf(soa_rr, 0)); break; } ldns_pkt_free(resp); return *mname ? LDNS_STATUS_OK : LDNS_STATUS_ERR; } /* Try to get zone and MNAME from SOA queries. */ ldns_status ldns_update_soa_zone_mname(const char *fqdn, ldns_resolver *r, ldns_rr_class c, ldns_rdf **zone_rdf, ldns_rdf **mname_rdf) { ldns_rr *soa_rr, *rr; ldns_rdf *soa_zone = NULL, *soa_mname = NULL; ldns_rdf *ipaddr, *fqdn_rdf, *tmp; ldns_rdf **nslist; ldns_pkt *query, *resp; ldns_resolver *tmp_r; size_t i; /* * XXX Ok, this cannot be the best way to find this...? * XXX (I run into weird cache-related stuff here) */ /* Step 1 - first find a nameserver that should know *something* */ fqdn_rdf = ldns_dname_new_frm_str(fqdn); query = ldns_pkt_query_new(fqdn_rdf, LDNS_RR_TYPE_SOA, c, LDNS_RD); if (!query) { return LDNS_STATUS_ERR; } fqdn_rdf = NULL; ldns_pkt_set_random_id(query); if (ldns_resolver_send_pkt(&resp, r, query) != LDNS_STATUS_OK) { ldns_pkt_free(query); return LDNS_STATUS_ERR; } ldns_pkt_free(query); if (!resp) { return LDNS_STATUS_ERR; } /* XXX Is it safe to only look in authority section here? */ while ((soa_rr = ldns_rr_list_pop_rr(ldns_pkt_authority(resp)))) { if (ldns_rr_get_type(soa_rr) != LDNS_RR_TYPE_SOA || ldns_rr_rdf(soa_rr, 0) == NULL) continue; /* [RFC1035 3.3.13] */ soa_mname = ldns_rdf_clone(ldns_rr_rdf(soa_rr, 0)); break; } ldns_pkt_free(resp); if (!soa_rr) { return LDNS_STATUS_ERR; } /* Step 2 - find SOA MNAME IP address, add to resolver */ query = ldns_pkt_query_new(soa_mname, LDNS_RR_TYPE_A, c, LDNS_RD); if (!query) { return LDNS_STATUS_ERR; } soa_mname = NULL; ldns_pkt_set_random_id(query); if (ldns_resolver_send_pkt(&resp, r, query) != LDNS_STATUS_OK) { ldns_pkt_free(query); return LDNS_STATUS_ERR; } ldns_pkt_free(query); if (!resp) { return LDNS_STATUS_ERR; } if (ldns_pkt_ancount(resp) == 0) { ldns_pkt_free(resp); return LDNS_STATUS_ERR; } /* XXX There may be more than one answer RR here. */ rr = ldns_rr_list_pop_rr(ldns_pkt_answer(resp)); ipaddr = ldns_rr_rdf(rr, 0); /* Put the SOA mname IP first in the nameserver list. */ if (!(tmp_r = ldns_resolver_clone(r))) { return LDNS_STATUS_MEM_ERR; } nslist = ldns_resolver_nameservers(tmp_r); for (i = 0; i < ldns_resolver_nameserver_count(tmp_r); i++) { if (ldns_rdf_compare(ipaddr, nslist[i]) == 0) { if (i) { tmp = nslist[0]; nslist[0] = nslist[i]; nslist[i] = tmp; } break; } } if (i >= ldns_resolver_nameserver_count(tmp_r)) { /* SOA mname was not part of the resolver so add it first. */ (void) ldns_resolver_push_nameserver(tmp_r, ipaddr); nslist = ldns_resolver_nameservers(tmp_r); i = ldns_resolver_nameserver_count(tmp_r) - 1; tmp = nslist[0]; nslist[0] = nslist[i]; nslist[i] = tmp; } ldns_pkt_free(resp); /* Make sure to ask the first in the list, i.e SOA mname */ ldns_resolver_set_random(tmp_r, false); /* Step 3 - Redo SOA query, sending to SOA MNAME directly. */ fqdn_rdf = ldns_dname_new_frm_str(fqdn); query = ldns_pkt_query_new(fqdn_rdf, LDNS_RR_TYPE_SOA, c, LDNS_RD); if (!query) { ldns_resolver_free(tmp_r); return LDNS_STATUS_ERR; } fqdn_rdf = NULL; ldns_pkt_set_random_id(query); if (ldns_resolver_send_pkt(&resp, tmp_r, query) != LDNS_STATUS_OK) { ldns_pkt_free(query); ldns_resolver_free(tmp_r); return LDNS_STATUS_ERR; } ldns_resolver_free(tmp_r); ldns_pkt_free(query); if (!resp) { return LDNS_STATUS_ERR; } /* XXX Is it safe to only look in authority section here, too? */ while ((soa_rr = ldns_rr_list_pop_rr(ldns_pkt_authority(resp)))) { if (ldns_rr_get_type(soa_rr) != LDNS_RR_TYPE_SOA || ldns_rr_rdf(soa_rr, 0) == NULL) continue; /* [RFC1035 3.3.13] */ soa_mname = ldns_rdf_clone(ldns_rr_rdf(soa_rr, 0)); soa_zone = ldns_rdf_clone(ldns_rr_owner(soa_rr)); break; } ldns_pkt_free(resp); if (!soa_rr) { return LDNS_STATUS_ERR; } /* That seems to have worked, pass results to caller. */ *zone_rdf = soa_zone; *mname_rdf = soa_mname; return LDNS_STATUS_OK; } /* * ldns_update_{get,set}_{zo,pr,up,ad}count */ uint16_t ldns_update_zocount(const ldns_pkt *p) { return ldns_pkt_qdcount(p); } uint16_t ldns_update_prcount(const ldns_pkt *p) { return ldns_pkt_ancount(p); } uint16_t ldns_update_upcount(const ldns_pkt *p) { return ldns_pkt_nscount(p); } uint16_t ldns_update_ad(const ldns_pkt *p) { return ldns_pkt_arcount(p); } void ldns_update_set_zo(ldns_pkt *p, uint16_t v) { ldns_pkt_set_qdcount(p, v); } void ldns_update_set_prcount(ldns_pkt *p, uint16_t v) { ldns_pkt_set_ancount(p, v); } void ldns_update_set_upcount(ldns_pkt *p, uint16_t v) { ldns_pkt_set_nscount(p, v); } void ldns_update_set_adcount(ldns_pkt *p, uint16_t v) { ldns_pkt_set_arcount(p, v); } ldns-1.9.2/higher.c0000664000175000017500000001707515212267520013457 0ustar willemwillem/* * higher.c * * Specify some higher level functions that would * be useful to would be developers * * a Net::DNS like library for C * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ #include #include #ifdef HAVE_SSL #include #include #endif /* HAVE_SSL */ ldns_rr_list * ldns_get_rr_list_addr_by_name(ldns_resolver *res, const ldns_rdf *name, ldns_rr_class c, uint16_t flags) { ldns_pkt *pkt; ldns_rr_list *aaaa; ldns_rr_list *a; ldns_rr_list *result = NULL; ldns_rr_list *hostsfilenames; size_t i; uint8_t ip6; a = NULL; aaaa = NULL; result = NULL; if (!res) { return NULL; } if (ldns_rdf_get_type(name) != LDNS_RDF_TYPE_DNAME) { return NULL; } ip6 = ldns_resolver_ip6(res); /* we use INET_ANY here, save what was there */ ldns_resolver_set_ip6(res, LDNS_RESOLV_INETANY); hostsfilenames = ldns_get_rr_list_hosts_frm_file(NULL); for (i = 0; i < ldns_rr_list_rr_count(hostsfilenames); i++) { if (ldns_rdf_compare(name, ldns_rr_owner(ldns_rr_list_rr(hostsfilenames, i))) == 0) { if (!result) { result = ldns_rr_list_new(); } ldns_rr_list_push_rr(result, ldns_rr_clone(ldns_rr_list_rr(hostsfilenames, i))); } } ldns_rr_list_deep_free(hostsfilenames); if (result) { return result; } /* add the RD flags, because we want an answer */ pkt = ldns_resolver_query(res, name, LDNS_RR_TYPE_AAAA, c, flags | LDNS_RD); if (pkt) { /* extract the data we need */ aaaa = ldns_pkt_rr_list_by_type(pkt, LDNS_RR_TYPE_AAAA, LDNS_SECTION_ANSWER); ldns_pkt_free(pkt); } pkt = ldns_resolver_query(res, name, LDNS_RR_TYPE_A, c, flags | LDNS_RD); if (pkt) { /* extract the data we need */ a = ldns_pkt_rr_list_by_type(pkt, LDNS_RR_TYPE_A, LDNS_SECTION_ANSWER); ldns_pkt_free(pkt); } ldns_resolver_set_ip6(res, ip6); if (aaaa && a) { result = ldns_rr_list_cat_clone(aaaa, a); ldns_rr_list_deep_free(aaaa); ldns_rr_list_deep_free(a); return result; } if (aaaa) { result = ldns_rr_list_clone(aaaa); } if (a) { result = ldns_rr_list_clone(a); } ldns_rr_list_deep_free(aaaa); ldns_rr_list_deep_free(a); return result; } ldns_rr_list * ldns_get_rr_list_name_by_addr(ldns_resolver *res, const ldns_rdf *addr, ldns_rr_class c, uint16_t flags) { ldns_pkt *pkt; ldns_rr_list *names; ldns_rdf *name; names = NULL; if (!res || !addr) { return NULL; } if (ldns_rdf_get_type(addr) != LDNS_RDF_TYPE_A && ldns_rdf_get_type(addr) != LDNS_RDF_TYPE_AAAA) { return NULL; } name = ldns_rdf_address_reverse(addr); /* add the RD flags, because we want an answer */ pkt = ldns_resolver_query(res, name, LDNS_RR_TYPE_PTR, c, flags | LDNS_RD); ldns_rdf_deep_free(name); if (pkt) { /* extract the data we need */ names = ldns_pkt_rr_list_by_type(pkt, LDNS_RR_TYPE_PTR, LDNS_SECTION_ANSWER); ldns_pkt_free(pkt); } return names; } /* read a line, put it in a buffer, parse the buffer */ ldns_rr_list * ldns_get_rr_list_hosts_frm_fp(FILE *fp) { return ldns_get_rr_list_hosts_frm_fp_l(fp, NULL); } ldns_rr_list * ldns_get_rr_list_hosts_frm_fp_l(FILE *fp, int *line_nr) { ssize_t i, j; size_t cnt; char *line; char *word; char *addr; char *rr_str; ldns_buffer *linebuf; ldns_rr *rr; ldns_rr_list *list; ldns_rdf *tmp; bool ip6; ldns_status parse_result; line = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1); word = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1); addr = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1); rr_str = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1); ip6 = false; list = ldns_rr_list_new(); rr = NULL; if(!line || !word || !addr || !rr_str || !list) { LDNS_FREE(line); LDNS_FREE(word); LDNS_FREE(addr); LDNS_FREE(rr_str); ldns_rr_list_free(list); return NULL; } for(i = ldns_fget_token_l(fp, line, "\n", LDNS_MAX_LINELEN, line_nr); i > 0; i = ldns_fget_token_l(fp, line, "\n", LDNS_MAX_LINELEN, line_nr)) { /* # is comment */ if (line[0] == '#') { continue; } /* put it in a buffer for further processing */ linebuf = LDNS_MALLOC(ldns_buffer); if(!linebuf) { LDNS_FREE(line); LDNS_FREE(word); LDNS_FREE(addr); LDNS_FREE(rr_str); ldns_rr_list_deep_free(list); return NULL; } ldns_buffer_new_frm_data(linebuf, line, (size_t) i); for(cnt = 0, j = ldns_bget_token(linebuf, word, LDNS_PARSE_NO_NL, LDNS_MAX_LINELEN); j > 0; j = ldns_bget_token(linebuf, word, LDNS_PARSE_NO_NL, LDNS_MAX_LINELEN), cnt++) { if (cnt == 0) { /* the address */ if ((tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_AAAA, word))) { /* ip6 */ ldns_rdf_deep_free(tmp); ip6 = true; } else { if ((tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_A, word))) { /* ip4 */ ldns_rdf_deep_free(tmp); ip6 = false; } else { /* kaput */ break; } } (void)strlcpy(addr, word, LDNS_MAX_LINELEN+1); } else { /* Stop parsing line when a comment begins. */ if (word[0] == '#') break; /* la al la la */ if (ip6) { snprintf(rr_str, LDNS_MAX_LINELEN, "%s IN AAAA %s", word, addr); } else { snprintf(rr_str, LDNS_MAX_LINELEN, "%s IN A %s", word, addr); } parse_result = ldns_rr_new_frm_str(&rr, rr_str, 0, NULL, NULL); if (parse_result == LDNS_STATUS_OK && ldns_rr_owner(rr) && ldns_rr_rd_count(rr) > 0) { ldns_rr_list_push_rr(list, ldns_rr_clone(rr)); ldns_rr_free(rr); } } } ldns_buffer_free(linebuf); } LDNS_FREE(line); LDNS_FREE(word); LDNS_FREE(addr); LDNS_FREE(rr_str); return list; } ldns_rr_list * ldns_get_rr_list_hosts_frm_file(char *filename) { ldns_rr_list *names; FILE *fp; if (!filename) { fp = fopen(LDNS_RESOLV_HOSTS, "r"); } else { fp = fopen(filename, "r"); } if (!fp) { return NULL; } names = ldns_get_rr_list_hosts_frm_fp(fp); fclose(fp); return names; } uint16_t ldns_getaddrinfo(ldns_resolver *res, const ldns_rdf *node, ldns_rr_class c, ldns_rr_list **ret) { ldns_rdf_type t; uint16_t names_found; ldns_resolver *r; ldns_status s; t = ldns_rdf_get_type(node); names_found = 0; r = res; if (res == NULL) { /* prepare a new resolver, using /etc/resolv.conf as a guide */ s = ldns_resolver_new_frm_file(&r, NULL); if (s != LDNS_STATUS_OK) { return 0; } } if (t == LDNS_RDF_TYPE_DNAME) { /* we're asked to query for a name */ *ret = ldns_get_rr_list_addr_by_name(r, node, c, 0); names_found = ldns_rr_list_rr_count(*ret); } if (t == LDNS_RDF_TYPE_A || t == LDNS_RDF_TYPE_AAAA) { /* an address */ *ret = ldns_get_rr_list_name_by_addr(r, node, c, 0); names_found = ldns_rr_list_rr_count(*ret); } if (res == NULL) { ldns_resolver_deep_free(r); } return names_found; } bool ldns_nsec_type_check(const ldns_rr *nsec, ldns_rr_type t) { switch (ldns_rr_get_type(nsec)) { case LDNS_RR_TYPE_NSEC : if (ldns_rr_rd_count(nsec) < 2) { return false; } return ldns_nsec_bitmap_covers_type( ldns_rr_rdf(nsec, 1), t); case LDNS_RR_TYPE_NSEC3 : if (ldns_rr_rd_count(nsec) < 6) { return false; } return ldns_nsec_bitmap_covers_type( ldns_rr_rdf(nsec, 5), t); default : return false; } } void ldns_print_rr_rdf(FILE *fp, ldns_rr *r, int rdfnum, ...) { int16_t rdf; ldns_rdf *rd; va_list va_rdf; va_start(va_rdf, rdfnum); for (rdf = (int16_t)rdfnum; rdf != -1; rdf = (int16_t)va_arg(va_rdf, int)) { rd = ldns_rr_rdf(r, rdf); if (!rd) { continue; } else { ldns_rdf_print(fp, rd); fprintf(fp, " "); /* not sure if we want to do this */ } } va_end(va_rdf); } ldns-1.9.2/util.c0000664000175000017500000004465215212267520013167 0ustar willemwillem/* * util.c * * some general memory functions * * a Net::DNS like library for C * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_SSL #include #endif ldns_lookup_table * ldns_lookup_by_name(ldns_lookup_table *table, const char *name) { while (table->name != NULL) { if (strcasecmp(name, table->name) == 0) return table; table++; } return NULL; } ldns_lookup_table * ldns_lookup_by_id(ldns_lookup_table *table, int id) { while (table->name != NULL) { if (table->id == id) return table; table++; } return NULL; } int ldns_get_bit(uint8_t bits[], size_t index) { /* * The bits are counted from left to right, so bit #0 is the * left most bit. */ return (int) (bits[index / 8] & (1 << (7 - index % 8))); } int ldns_get_bit_r(uint8_t bits[], size_t index) { /* * The bits are counted from right to left, so bit #0 is the * right most bit. */ return (int) bits[index / 8] & (1 << (index % 8)); } void ldns_set_bit(uint8_t *byte, int bit_nr, bool value) { /* * The bits are counted from right to left, so bit #0 is the * right most bit. */ if (bit_nr >= 0 && bit_nr < 8) { if (value) { *byte = *byte | (0x01 << bit_nr); } else { *byte = *byte & ~(0x01 << bit_nr); } } } int ldns_hexdigit_to_int(char ch) { switch (ch) { case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4; case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9; case 'a': case 'A': return 10; case 'b': case 'B': return 11; case 'c': case 'C': return 12; case 'd': case 'D': return 13; case 'e': case 'E': return 14; case 'f': case 'F': return 15; default: return -1; } } char ldns_int_to_hexdigit(int i) { switch (i) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; case 10: return 'a'; case 11: return 'b'; case 12: return 'c'; case 13: return 'd'; case 14: return 'e'; case 15: return 'f'; default: abort(); } } int ldns_hexstring_to_data(uint8_t *data, const char *str) { size_t i; if (!str || !data) { return -1; } if (strlen(str) % 2 != 0) { return -2; } for (i = 0; i < strlen(str) / 2; i++) { data[i] = 16 * (uint8_t) ldns_hexdigit_to_int(str[i*2]) + (uint8_t) ldns_hexdigit_to_int(str[i*2 + 1]); } return (int) i; } const char * ldns_version(void) { return (char*)LDNS_VERSION; } /* Number of days per month (except for February in leap years). */ static const int mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; #define LDNS_MOD(x,y) (((x) % (y) < 0) ? ((x) % (y) + (y)) : ((x) % (y))) #define LDNS_DIV(x,y) (((x) % (y) < 0) ? ((x) / (y) - 1 ) : ((x) / (y))) static int is_leap_year(int year) { return LDNS_MOD(year, 4) == 0 && (LDNS_MOD(year, 100) != 0 || LDNS_MOD(year, 400) == 0); } static int leap_days(int y1, int y2) { --y1; --y2; return (LDNS_DIV(y2, 4) - LDNS_DIV(y1, 4)) - (LDNS_DIV(y2, 100) - LDNS_DIV(y1, 100)) + (LDNS_DIV(y2, 400) - LDNS_DIV(y1, 400)); } /* * Code adapted from Python 2.4.1 sources (Lib/calendar.py). */ time_t ldns_mktime_from_utc(const struct tm *tm) { int year = 1900 + tm->tm_year; time_t days = 365 * ((time_t) year - 1970) + leap_days(1970, year); time_t hours; time_t minutes; time_t seconds; int i; for (i = 0; i < tm->tm_mon; ++i) { days += mdays[i]; } if (tm->tm_mon > 1 && is_leap_year(year)) { ++days; } days += tm->tm_mday - 1; hours = days * 24 + tm->tm_hour; minutes = hours * 60 + tm->tm_min; seconds = minutes * 60 + tm->tm_sec; return seconds; } time_t mktime_from_utc(const struct tm *tm) { return ldns_mktime_from_utc(tm); } #if SIZEOF_TIME_T <= 4 static void ldns_year_and_yday_from_days_since_epoch(int64_t days, struct tm *result) { int year = 1970; int new_year; while (days < 0 || days >= (int64_t) (is_leap_year(year) ? 366 : 365)) { new_year = year + (int) LDNS_DIV(days, 365); days -= (new_year - year) * 365; days -= leap_days(year, new_year); year = new_year; } result->tm_year = year; result->tm_yday = (int) days; } /* Number of days per month in a leap year. */ static const int leap_year_mdays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static void ldns_mon_and_mday_from_year_and_yday(struct tm *result) { int idays = result->tm_yday; const int *mon_lengths = is_leap_year(result->tm_year) ? leap_year_mdays : mdays; result->tm_mon = 0; while (idays >= mon_lengths[result->tm_mon]) { idays -= mon_lengths[result->tm_mon++]; } result->tm_mday = idays + 1; } static void ldns_wday_from_year_and_yday(struct tm *result) { result->tm_wday = 4 /* 1-1-1970 was a thursday */ + LDNS_MOD((result->tm_year - 1970), 7) * LDNS_MOD(365, 7) + leap_days(1970, result->tm_year) + result->tm_yday; result->tm_wday = LDNS_MOD(result->tm_wday, 7); if (result->tm_wday < 0) { result->tm_wday += 7; } } static struct tm * ldns_gmtime64_r(int64_t clock, struct tm *result) { result->tm_isdst = 0; result->tm_sec = (int) LDNS_MOD(clock, 60); clock = LDNS_DIV(clock, 60); result->tm_min = (int) LDNS_MOD(clock, 60); clock = LDNS_DIV(clock, 60); result->tm_hour = (int) LDNS_MOD(clock, 24); clock = LDNS_DIV(clock, 24); ldns_year_and_yday_from_days_since_epoch(clock, result); ldns_mon_and_mday_from_year_and_yday(result); ldns_wday_from_year_and_yday(result); result->tm_year -= 1900; return result; } #endif /* SIZEOF_TIME_T <= 4 */ static int64_t ldns_serial_arithmetics_time(int32_t time, time_t now) { /* Casting due to https://github.com/NLnetLabs/ldns/issues/71 */ int32_t offset = (int32_t) ((uint32_t) time - (uint32_t) now); return (int64_t) now + offset; } struct tm * ldns_serial_arithmetics_gmtime_r(int32_t time, time_t now, struct tm *result) { #if SIZEOF_TIME_T <= 4 int64_t secs_since_epoch = ldns_serial_arithmetics_time(time, now); return ldns_gmtime64_r(secs_since_epoch, result); #else time_t secs_since_epoch = ldns_serial_arithmetics_time(time, now); return gmtime_r(&secs_since_epoch, result); #endif } #ifdef ldns_serial_arithmitics_gmtime_r #undef ldns_serial_arithmitics_gmtime_r #endif /* alias function because of previously used wrong spelling */ struct tm * ldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result); struct tm * ldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result) { return ldns_serial_arithmetics_gmtime_r(time, now, result); } /** * Init the random source * applications should call this if they need entropy data within ldns * If openSSL is available, it is automatically seeded from /dev/urandom * or /dev/random * * If you need more entropy, or have no openssl available, this function * MUST be called at the start of the program * * If openssl *is* available, this function just adds more entropy **/ int ldns_init_random(FILE *fd, unsigned int size) { /* if fp is given, seed srandom with data from file otherwise use /dev/urandom */ FILE *rand_f; uint8_t *seed; size_t read = 0; unsigned int seed_i; struct timeval tv; #ifdef HAVE_SSL if(RAND_status() == 1) /* already seeded */ return 0; #endif /* we'll need at least sizeof(unsigned int) bytes for the standard prng seed */ if (size < (unsigned int) sizeof(seed_i)){ size = (unsigned int) sizeof(seed_i); } seed = LDNS_XMALLOC(uint8_t, size); if(!seed) { return 1; } if (!fd) { if ((rand_f = fopen("/dev/urandom", "r")) == NULL) { /* no readable /dev/urandom, try /dev/random */ if ((rand_f = fopen("/dev/random", "r")) == NULL) { /* no readable /dev/random either, and no entropy source given. we'll have to improvise */ for (read = 0; read < size; read++) { gettimeofday(&tv, NULL); seed[read] = (uint8_t) (tv.tv_usec % 256); } } else { read = fread(seed, 1, size, rand_f); } } else { read = fread(seed, 1, size, rand_f); } } else { rand_f = fd; read = fread(seed, 1, size, rand_f); } if (read < size) { LDNS_FREE(seed); if (!fd) fclose(rand_f); return 1; } else { #ifdef HAVE_SSL /* Seed the OpenSSL prng (most systems have it seeded automatically, in that case this call just adds entropy */ RAND_seed(seed, (int) size); #else /* Seed the standard prng, only uses the first * unsigned sizeof(unsigned int) bytes found in the entropy pool */ memcpy(&seed_i, seed, sizeof(seed_i)); srandom(seed_i); #endif LDNS_FREE(seed); } if (!fd) { if (rand_f) fclose(rand_f); } return 0; } /** * Get random number. * */ uint16_t ldns_get_random(void) { uint16_t rid = 0; #ifdef HAVE_SSL if (RAND_bytes((unsigned char*)&rid, 2) != 1) { rid = (uint16_t) random(); } #else rid = (uint16_t) random(); #endif return rid; } /* * BubbleBabble code taken from OpenSSH * Copyright (c) 2001 Carsten Raskgaard. All rights reserved. */ char * ldns_bubblebabble(uint8_t *data, size_t len) { char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; char consonants[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'z', 'x' }; size_t i, j = 0, rounds, seed = 1; char *retval; rounds = (len / 2) + 1; retval = LDNS_XMALLOC(char, rounds * 6); if(!retval) return NULL; retval[j++] = 'x'; for (i = 0; i < rounds; i++) { size_t idx0, idx1, idx2, idx3, idx4; if ((i + 1 < rounds) || (len % 2 != 0)) { idx0 = (((((size_t)(data[2 * i])) >> 6) & 3) + seed) % 6; idx1 = (((size_t)(data[2 * i])) >> 2) & 15; idx2 = ((((size_t)(data[2 * i])) & 3) + (seed / 6)) % 6; retval[j++] = vowels[idx0]; retval[j++] = consonants[idx1]; retval[j++] = vowels[idx2]; if ((i + 1) < rounds) { idx3 = (((size_t)(data[(2 * i) + 1])) >> 4) & 15; idx4 = (((size_t)(data[(2 * i) + 1]))) & 15; retval[j++] = consonants[idx3]; retval[j++] = '-'; retval[j++] = consonants[idx4]; seed = ((seed * 5) + ((((size_t)(data[2 * i])) * 7) + ((size_t)(data[(2 * i) + 1])))) % 36; } } else { idx0 = seed % 6; idx1 = 16; idx2 = seed / 6; retval[j++] = vowels[idx0]; retval[j++] = consonants[idx1]; retval[j++] = vowels[idx2]; } } retval[j++] = 'x'; retval[j++] = '\0'; return retval; } /* * For backwards compatibility, because we have always exported this symbol. */ #ifdef HAVE_B64_NTOP int ldns_b64_ntop(const uint8_t* src, size_t srclength, char *target, size_t targsize); { return b64_ntop(src, srclength, target, targsize); } #endif /* * For backwards compatibility, because we have always exported this symbol. */ #ifdef HAVE_B64_PTON int ldns_b64_pton(const char* src, uint8_t *target, size_t targsize) { return b64_pton(src, target, targsize); } #endif static int ldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz, bool extended_hex, bool add_padding) { size_t ret_sz; const char* b32 = extended_hex ? "0123456789abcdefghijklmnopqrstuv" : "abcdefghijklmnopqrstuvwxyz234567"; size_t c = 0; /* c is used to carry partial base32 character over * byte boundaries for sizes with a remainder. * (i.e. src_sz % 5 != 0) */ ret_sz = add_padding ? ldns_b32_ntop_calculate_size(src_sz) : ldns_b32_ntop_calculate_size_no_padding(src_sz); /* Do we have enough space? */ if (dst_sz < ret_sz + 1) return -1; /* We know the size; terminate the string */ dst[ret_sz] = '\0'; /* First process all chunks of five */ while (src_sz >= 5) { /* 00000... ........ ........ ........ ........ */ dst[0] = b32[(src[0] ) >> 3]; /* .....111 11...... ........ ........ ........ */ dst[1] = b32[(src[0] & 0x07) << 2 | src[1] >> 6]; /* ........ ..22222. ........ ........ ........ */ dst[2] = b32[(src[1] & 0x3e) >> 1]; /* ........ .......3 3333.... ........ ........ */ dst[3] = b32[(src[1] & 0x01) << 4 | src[2] >> 4]; /* ........ ........ ....4444 4....... ........ */ dst[4] = b32[(src[2] & 0x0f) << 1 | src[3] >> 7]; /* ........ ........ ........ .55555.. ........ */ dst[5] = b32[(src[3] & 0x7c) >> 2]; /* ........ ........ ........ ......66 666..... */ dst[6] = b32[(src[3] & 0x03) << 3 | src[4] >> 5]; /* ........ ........ ........ ........ ...77777 */ dst[7] = b32[(src[4] & 0x1f) ]; src_sz -= 5; src += 5; dst += 8; } /* Process what remains */ switch (src_sz) { case 4: /* ........ ........ ........ ......66 666..... */ dst[6] = b32[(src[3] & 0x03) << 3]; /* ........ ........ ........ .55555.. ........ */ dst[5] = b32[(src[3] & 0x7c) >> 2]; /* ........ ........ ....4444 4....... ........ */ c = src[3] >> 7 ; /* fallthrough */ case 3: dst[4] = b32[(src[2] & 0x0f) << 1 | c]; /* ........ .......3 3333.... ........ ........ */ c = src[2] >> 4 ; /* fallthrough */ case 2: dst[3] = b32[(src[1] & 0x01) << 4 | c]; /* ........ ..22222. ........ ........ ........ */ dst[2] = b32[(src[1] & 0x3e) >> 1]; /* .....111 11...... ........ ........ ........ */ c = src[1] >> 6 ; /* fallthrough */ case 1: dst[1] = b32[(src[0] & 0x07) << 2 | c]; /* 00000... ........ ........ ........ ........ */ dst[0] = b32[ src[0] >> 3]; } /* Add padding */ if (add_padding) { switch (src_sz) { case 1: dst[2] = '='; dst[3] = '='; /* fallthrough */ case 2: dst[4] = '='; /* fallthrough */ case 3: dst[5] = '='; dst[6] = '='; /* fallthrough */ case 4: dst[7] = '='; } } return (int)ret_sz; } int ldns_b32_ntop(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return ldns_b32_ntop_base(src, src_sz, dst, dst_sz, false, true); } int ldns_b32_ntop_extended_hex(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return ldns_b32_ntop_base(src, src_sz, dst, dst_sz, true, true); } #ifndef HAVE_B32_NTOP int b32_ntop(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return ldns_b32_ntop_base(src, src_sz, dst, dst_sz, false, true); } int b32_ntop_extended_hex(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz) { return ldns_b32_ntop_base(src, src_sz, dst, dst_sz, true, true); } #endif /* ! HAVE_B32_NTOP */ static int ldns_b32_pton_base(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz, bool extended_hex, bool check_padding) { size_t i = 0; char ch = '\0'; uint8_t buf[8]; uint8_t* start = dst; while (src_sz) { /* Collect 8 characters in buf (if possible) */ for (i = 0; i < 8; i++) { do { ch = *src++; --src_sz; } while (isspace((unsigned char)ch) && src_sz > 0); if (ch == '=' || ch == '\0') break; else if (extended_hex) if (ch >= '0' && ch <= '9') buf[i] = (uint8_t)ch - '0'; else if (ch >= 'a' && ch <= 'v') buf[i] = (uint8_t)ch - 'a' + 10; else if (ch >= 'A' && ch <= 'V') buf[i] = (uint8_t)ch - 'A' + 10; else return -1; else if (ch >= 'a' && ch <= 'z') buf[i] = (uint8_t)ch - 'a'; else if (ch >= 'A' && ch <= 'Z') buf[i] = (uint8_t)ch - 'A'; else if (ch >= '2' && ch <= '7') buf[i] = (uint8_t)ch - '2' + 26; else return -1; } /* Less that 8 characters. We're done. */ if (i < 8) break; /* Enough space available at the destination? */ if (dst_sz < 5) return -1; /* 00000... ........ ........ ........ ........ */ /* .....111 11...... ........ ........ ........ */ dst[0] = buf[0] << 3 | buf[1] >> 2; /* .....111 11...... ........ ........ ........ */ /* ........ ..22222. ........ ........ ........ */ /* ........ .......3 3333.... ........ ........ */ dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4; /* ........ .......3 3333.... ........ ........ */ /* ........ ........ ....4444 4....... ........ */ dst[2] = buf[3] << 4 | buf[4] >> 1; /* ........ ........ ....4444 4....... ........ */ /* ........ ........ ........ .55555.. ........ */ /* ........ ........ ........ ......66 666..... */ dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3; /* ........ ........ ........ ......66 666..... */ /* ........ ........ ........ ........ ...77777 */ dst[4] = buf[6] << 5 | buf[7]; dst += 5; dst_sz -= 5; } /* Not ending on a eight byte boundary? */ if (i > 0 && i < 8) { /* Enough space available at the destination? */ if (dst_sz < (i + 1) / 2) return -1; switch (i) { case 7: /* ........ ........ ........ ......66 666..... */ /* ........ ........ ........ .55555.. ........ */ /* ........ ........ ....4444 4....... ........ */ dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3; /* fallthrough */ case 5: /* ........ ........ ....4444 4....... ........ */ /* ........ .......3 3333.... ........ ........ */ dst[2] = buf[3] << 4 | buf[4] >> 1; /* fallthrough */ case 4: /* ........ .......3 3333.... ........ ........ */ /* ........ ..22222. ........ ........ ........ */ /* .....111 11...... ........ ........ ........ */ dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4; /* fallthrough */ case 2: /* .....111 11...... ........ ........ ........ */ /* 00000... ........ ........ ........ ........ */ dst[0] = buf[0] << 3 | buf[1] >> 2; break; default: return -1; } dst += (i + 1) / 2; if (check_padding) { /* Check remaining padding characters */ if (ch != '=') return -1; /* One down, 8 - i - 1 more to come... */ for (i = 8 - i - 1; i > 0; i--) { do { if (src_sz == 0) return -1; ch = *src++; src_sz--; } while (isspace((unsigned char)ch)); if (ch != '=') return -1; } } } return dst - start; } int ldns_b32_pton(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return ldns_b32_pton_base(src, src_sz, dst, dst_sz, false, true); } int ldns_b32_pton_extended_hex(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return ldns_b32_pton_base(src, src_sz, dst, dst_sz, true, true); } #ifndef HAVE_B32_PTON int b32_pton(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return ldns_b32_pton_base(src, src_sz, dst, dst_sz, false, true); } int b32_pton_extended_hex(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz) { return ldns_b32_pton_base(src, src_sz, dst, dst_sz, true, true); } #endif /* ! HAVE_B32_PTON */ ldns-1.9.2/aclocal.m40000664000175000017500000000156515212267525013707 0ustar willemwillem# generated automatically by aclocal 1.16.5 -*- Autoconf -*- # Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_include([m4/ax_config_feature.m4]) m4_include([m4/ax_have_poll.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) ldns-1.9.2/radix.c0000664000175000017500000011114215212267520013306 0ustar willemwillem/* * radix.c -- generic radix tree * * Taken from NSD4, modified for ldns * * Copyright (c) 2012, NLnet Labs. All rights reserved. * * This software is open source. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the NLNET LABS nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** * \file * Implementation of a radix tree. */ #include #include #include #include /** Helper functions */ static ldns_radix_node_t* ldns_radix_new_node(void* data, uint8_t* key, radix_strlen_t len); static int ldns_radix_find_prefix(ldns_radix_t* tree, uint8_t* key, radix_strlen_t len, ldns_radix_node_t** result, radix_strlen_t* pos); static int ldns_radix_array_space(ldns_radix_node_t* node, uint8_t byte); static int ldns_radix_array_grow(ldns_radix_node_t* node, unsigned need); static int ldns_radix_str_create(ldns_radix_array_t* array, uint8_t* key, radix_strlen_t pos, radix_strlen_t len); static int ldns_radix_prefix_remainder(radix_strlen_t prefix_len, uint8_t* longer_str, radix_strlen_t longer_len, uint8_t** split_str, radix_strlen_t* split_len); static int ldns_radix_array_split(ldns_radix_array_t* array, uint8_t* key, radix_strlen_t pos, radix_strlen_t len, ldns_radix_node_t* add); static int ldns_radix_str_is_prefix(uint8_t* str1, radix_strlen_t len1, uint8_t* str2, radix_strlen_t len2); static radix_strlen_t ldns_radix_str_common(uint8_t* str1, radix_strlen_t len1, uint8_t* str2, radix_strlen_t len2); static ldns_radix_node_t* ldns_radix_next_in_subtree(ldns_radix_node_t* node); static ldns_radix_node_t* ldns_radix_prev_from_index(ldns_radix_node_t* node, uint8_t index); static ldns_radix_node_t* ldns_radix_last_in_subtree_incl_self( ldns_radix_node_t* node); static ldns_radix_node_t* ldns_radix_last_in_subtree(ldns_radix_node_t* node); static void ldns_radix_del_fix(ldns_radix_t* tree, ldns_radix_node_t* node); static void ldns_radix_cleanup_onechild(ldns_radix_node_t* node); static void ldns_radix_cleanup_leaf(ldns_radix_node_t* node); static void ldns_radix_node_free(ldns_radix_node_t* node, void* arg); static void ldns_radix_node_array_free(ldns_radix_node_t* node); static void ldns_radix_node_array_free_front(ldns_radix_node_t* node); static void ldns_radix_node_array_free_end(ldns_radix_node_t* node); static void ldns_radix_array_reduce(ldns_radix_node_t* node); static void ldns_radix_self_or_prev(ldns_radix_node_t* node, ldns_radix_node_t** result); /** * Create a new radix node. * */ static ldns_radix_node_t* ldns_radix_new_node(void* data, uint8_t* key, radix_strlen_t len) { ldns_radix_node_t* node = LDNS_MALLOC(ldns_radix_node_t); if (!node) { return NULL; } node->data = data; node->key = key; node->klen = len; node->parent = NULL; node->parent_index = 0; node->len = 0; node->offset = 0; node->capacity = 0; node->array = NULL; return node; } /** * Create a new radix tree. * */ ldns_radix_t * ldns_radix_create(void) { ldns_radix_t* tree; /** Allocate memory for it */ tree = (ldns_radix_t *) LDNS_MALLOC(ldns_radix_t); if (!tree) { return NULL; } /** Initialize it */ ldns_radix_init(tree); return tree; } /** * Initialize radix tree. * */ void ldns_radix_init(ldns_radix_t* tree) { /** Initialize it */ if (tree) { tree->root = NULL; tree->count = 0; } return; } /** * Free radix tree. * */ void ldns_radix_free(ldns_radix_t* tree) { if (tree) { if (tree->root) { ldns_radix_traverse_postorder(tree->root, ldns_radix_node_free, NULL); } LDNS_FREE(tree); } return; } /** * Insert data into the tree. * */ ldns_status ldns_radix_insert(ldns_radix_t* tree, uint8_t* key, radix_strlen_t len, void* data) { radix_strlen_t pos = 0; ldns_radix_node_t* add = NULL; ldns_radix_node_t* prefix = NULL; if (!tree || !key || !data) { return LDNS_STATUS_NULL; } add = ldns_radix_new_node(data, key, len); if (!add) { return LDNS_STATUS_MEM_ERR; } /** Search the trie until we can make no further process. */ if (!ldns_radix_find_prefix(tree, key, len, &prefix, &pos)) { /** No prefix found */ assert(tree->root == NULL); if (len == 0) { /** * Example 1: The root: * | [0] **/ tree->root = add; } else { /** Example 2: 'dns': * | [0] * --| [d+ns] dns **/ prefix = ldns_radix_new_node(NULL, (uint8_t*)"", 0); if (!prefix) { LDNS_FREE(add); return LDNS_STATUS_MEM_ERR; } /** Find some space in the array for the first byte */ if (!ldns_radix_array_space(prefix, key[0])) { LDNS_FREE(add); LDNS_FREE(prefix->array); LDNS_FREE(prefix); return LDNS_STATUS_MEM_ERR; } /** Set relational pointers */ add->parent = prefix; add->parent_index = 0; prefix->array[0].edge = add; if (len > 1) { /** Store the remainder of the prefix */ if (!ldns_radix_prefix_remainder(1, key, len, &prefix->array[0].str, &prefix->array[0].len)) { LDNS_FREE(add); LDNS_FREE(prefix->array); LDNS_FREE(prefix); return LDNS_STATUS_MEM_ERR; } } tree->root = prefix; } } else if (pos == len) { /** Exact match found */ LDNS_FREE(add); if (prefix->data) { /* Element already exists */ return LDNS_STATUS_EXISTS_ERR; } prefix->data = data; prefix->key = key; prefix->klen = len; /* redundant */ } else { /** Prefix found */ uint8_t byte = key[pos]; assert(pos < len); if (byte < prefix->offset || (byte - prefix->offset) >= prefix->len) { /** Find some space in the array for the byte. */ /** * Example 3: 'ldns' * | [0] * --| [d+ns] dns * --| [l+dns] ldns **/ if (!ldns_radix_array_space(prefix, byte)) { LDNS_FREE(add); return LDNS_STATUS_MEM_ERR; } assert(byte >= prefix->offset); assert((byte - prefix->offset) <= prefix->len); byte -= prefix->offset; if (pos+1 < len) { /** Create remainder of the string. */ if (!ldns_radix_str_create( &prefix->array[byte], key, pos+1, len)) { LDNS_FREE(add); return LDNS_STATUS_MEM_ERR; } } /** Add new node. */ add->parent = prefix; add->parent_index = byte; prefix->array[byte].edge = add; } else if (prefix->array[byte-prefix->offset].edge == NULL) { /** Use existing element. */ /** * Example 4: 'edns' * | [0] * --| [d+ns] dns * --| [e+dns] edns * --| [l+dns] ldns **/ byte -= prefix->offset; if (pos+1 < len) { /** Create remainder of the string. */ if (!ldns_radix_str_create( &prefix->array[byte], key, pos+1, len)) { LDNS_FREE(add); return LDNS_STATUS_MEM_ERR; } } /** Add new node. */ add->parent = prefix; add->parent_index = byte; prefix->array[byte].edge = add; } else { /** * Use existing element, but it has a shared prefix, * we need a split. */ if (!ldns_radix_array_split(&prefix->array[byte-(prefix->offset)], key, pos+1, len, add)) { LDNS_FREE(add); return LDNS_STATUS_MEM_ERR; } } } tree->count ++; return LDNS_STATUS_OK; } /** * Delete data from the tree. * */ void* ldns_radix_delete(ldns_radix_t* tree, const uint8_t* key, radix_strlen_t len) { ldns_radix_node_t* del = ldns_radix_search(tree, key, len); void* data = NULL; if (del) { tree->count--; data = del->data; del->data = NULL; ldns_radix_del_fix(tree, del); return data; } return NULL; } /** * Search data in the tree. * */ ldns_radix_node_t* ldns_radix_search(ldns_radix_t* tree, const uint8_t* key, radix_strlen_t len) { ldns_radix_node_t* node = NULL; radix_strlen_t pos = 0; uint8_t byte = 0; if (!tree || !key) { return NULL; } node = tree->root; while (node) { if (pos == len) { return node->data?node:NULL; } byte = key[pos]; if (byte < node->offset) { return NULL; } byte -= node->offset; if (byte >= node->len) { return NULL; } pos++; if (node->array[byte].len > 0) { /** Must match additional string. */ if (pos + node->array[byte].len > len) { return NULL; } if (memcmp(&key[pos], node->array[byte].str, node->array[byte].len) != 0) { return NULL; } pos += node->array[byte].len; } node = node->array[byte].edge; } return NULL; } /** * Search data in the tree, and if not found, find the closest smaller * element in the tree. * */ int ldns_radix_find_less_equal(ldns_radix_t* tree, const uint8_t* key, radix_strlen_t len, ldns_radix_node_t** result) { ldns_radix_node_t* node = NULL; radix_strlen_t pos = 0; uint8_t byte; int memcmp_res = 0; if (!tree || !tree->root || !key) { *result = NULL; return 0; } node = tree->root; while (pos < len) { byte = key[pos]; if (byte < node->offset) { /** * No exact match. The lesser is in this or the * previous node. */ ldns_radix_self_or_prev(node, result); return 0; } byte -= node->offset; if (byte >= node->len) { /** * No exact match. The lesser is in this node or the * last of this array, or something before this node. */ *result = ldns_radix_last_in_subtree_incl_self(node); if (*result == NULL) { *result = ldns_radix_prev(node); } return 0; } pos++; if (!node->array[byte].edge) { /** * No exact match. Find the previous in the array * from this index. */ *result = ldns_radix_prev_from_index(node, byte); if (*result == NULL) { ldns_radix_self_or_prev(node, result); } return 0; } if (node->array[byte].len != 0) { /** Must match additional string. */ if (pos + node->array[byte].len > len) { /** Additional string is longer than key. */ if (memcmp(&key[pos], node->array[byte].str, len-pos) <= 0) { /** Key is before this node. */ *result = ldns_radix_prev( node->array[byte].edge); } else { /** Key is after additional string. */ *result = ldns_radix_last_in_subtree_incl_self(node->array[byte].edge); if (*result == NULL) { *result = ldns_radix_prev(node->array[byte].edge); } } return 0; } memcmp_res = memcmp(&key[pos], node->array[byte].str, node->array[byte].len); if (memcmp_res < 0) { *result = ldns_radix_prev( node->array[byte].edge); return 0; } else if (memcmp_res > 0) { *result = ldns_radix_last_in_subtree_incl_self(node->array[byte].edge); if (*result == NULL) { *result = ldns_radix_prev(node->array[byte].edge); } return 0; } pos += node->array[byte].len; } node = node->array[byte].edge; } if (node->data) { /** Exact match. */ *result = node; return 1; } /** There is a node which is an exact match, but has no element. */ *result = ldns_radix_prev(node); return 0; } /** * Get the first element in the tree. * */ ldns_radix_node_t* ldns_radix_first(const ldns_radix_t* tree) { ldns_radix_node_t* first = NULL; if (!tree || !tree->root) { return NULL; } first = tree->root; if (first->data) { return first; } return ldns_radix_next(first); } /** * Get the last element in the tree. * */ ldns_radix_node_t* ldns_radix_last(const ldns_radix_t* tree) { if (!tree || !tree->root) { return NULL; } return ldns_radix_last_in_subtree_incl_self(tree->root); } /** * Next element. * */ ldns_radix_node_t* ldns_radix_next(ldns_radix_node_t* node) { if (!node) { return NULL; } if (node->len) { /** Go down: most-left child is the next. */ ldns_radix_node_t* next = ldns_radix_next_in_subtree(node); if (next) { return next; } } /** No elements in subtree, get to parent and go down next branch. */ while (node->parent) { uint8_t index = node->parent_index; node = node->parent; index++; for (; index < node->len; index++) { if (node->array[index].edge) { ldns_radix_node_t* next; /** Node itself. */ if (node->array[index].edge->data) { return node->array[index].edge; } /** Dive into subtree. */ next = ldns_radix_next_in_subtree(node); if (next) { return next; } } } } return NULL; } /** * Previous element. * */ ldns_radix_node_t* ldns_radix_prev(ldns_radix_node_t* node) { if (!node) { return NULL; } /** Get to parent and go down previous branch. */ while (node->parent) { uint8_t index = node->parent_index; ldns_radix_node_t* prev; node = node->parent; assert(node->len > 0); prev = ldns_radix_prev_from_index(node, index); if (prev) { return prev; } if (node->data) { return node; } } return NULL; } /** * Print node. * */ static void ldns_radix_node_print(FILE* fd, ldns_radix_node_t* node, uint8_t i, uint8_t* str, radix_strlen_t len, unsigned d) { uint8_t j; if (!node) { return; } for (j = 0; j < d; j++) { fprintf(fd, "--"); } if (str) { radix_strlen_t l; fprintf(fd, "| [%u+", (unsigned) i); for (l=0; l < len; l++) { fprintf(fd, "%c", (char) str[l]); } fprintf(fd, "]%u", (unsigned) len); } else { fprintf(fd, "| [%u]", (unsigned) i); } if (node->data) { fprintf(fd, " %s", (char*) node->data); } fprintf(fd, "\n"); for (j = 0; j < node->len; j++) { if (node->array[j].edge) { ldns_radix_node_print(fd, node->array[j].edge, j, node->array[j].str, node->array[j].len, d+1); } } return; } /** * Print radix tree. * */ void ldns_radix_printf(FILE* fd, const ldns_radix_t* tree) { if (!fd || !tree) { return; } if (!tree->root) { fprintf(fd, "; empty radix tree\n"); return; } ldns_radix_node_print(fd, tree->root, 0, NULL, 0, 0); return; } /** * Join two radix trees. * */ ldns_status ldns_radix_join(ldns_radix_t* tree1, ldns_radix_t* tree2) { ldns_radix_node_t* cur_node, *next_node; ldns_status status; if (!tree2 || !tree2->root) { return LDNS_STATUS_OK; } /** Add all elements from tree2 into tree1. */ cur_node = ldns_radix_first(tree2); while (cur_node) { status = LDNS_STATUS_NO_DATA; /** Insert current node into tree1 */ if (cur_node->data) { status = ldns_radix_insert(tree1, cur_node->key, cur_node->klen, cur_node->data); /** Exist errors may occur */ if (status != LDNS_STATUS_OK && status != LDNS_STATUS_EXISTS_ERR) { return status; } } next_node = ldns_radix_next(cur_node); if (status == LDNS_STATUS_OK) { (void) ldns_radix_delete(tree2, cur_node->key, cur_node->klen); } cur_node = next_node; } return LDNS_STATUS_OK; } /** * Split a radix tree intwo. * */ ldns_status ldns_radix_split(ldns_radix_t* tree1, size_t num, ldns_radix_t** tree2) { size_t count = 0; ldns_radix_node_t* cur_node; ldns_status status = LDNS_STATUS_OK; if (!tree1 || !tree1->root || num == 0) { return LDNS_STATUS_OK; } if (!tree2) { return LDNS_STATUS_NULL; } if (!*tree2) { *tree2 = ldns_radix_create(); if (!*tree2) { return LDNS_STATUS_MEM_ERR; } } cur_node = ldns_radix_first(tree1); while (count < num && cur_node) { if (cur_node->data) { /** Delete current node from tree1. */ uint8_t* cur_key = cur_node->key; radix_strlen_t cur_len = cur_node->klen; void* cur_data = ldns_radix_delete(tree1, cur_key, cur_len); /** Insert current node into tree2/ */ if (!cur_data) { return LDNS_STATUS_NO_DATA; } status = ldns_radix_insert(*tree2, cur_key, cur_len, cur_data); if (status != LDNS_STATUS_OK && status != LDNS_STATUS_EXISTS_ERR) { return status; } /* if (status == LDNS_STATUS_OK) { cur_node->key = NULL; cur_node->klen = 0; } */ /** Update count; get first element from tree1 again. */ count++; cur_node = ldns_radix_first(tree1); } else { cur_node = ldns_radix_next(cur_node); } } return LDNS_STATUS_OK; } /** * Call function for all nodes in the tree, such that leaf nodes are * called before parent nodes. * */ void ldns_radix_traverse_postorder(ldns_radix_node_t* node, void (*func)(ldns_radix_node_t*, void*), void* arg) { uint8_t i; if (!node) { return; } for (i=0; i < node->len; i++) { ldns_radix_traverse_postorder(node->array[i].edge, func, arg); } /** Call user function */ (*func)(node, arg); return; } /** Static helper functions */ /** * Find a prefix of the key. * @param tree: tree. * @param key: key. * @param len: length of key. * @param result: the longest prefix, the entry itself if *pos==len, * otherwise an array entry. * @param pos: position in string where next unmatched byte is. * If *pos==len, an exact match is found. * If *pos== 0, a "" match was found. * @return 0 (false) if no prefix found. * */ static int ldns_radix_find_prefix(ldns_radix_t* tree, uint8_t* key, radix_strlen_t len, ldns_radix_node_t** result, radix_strlen_t* respos) { /** Start searching at the root node */ ldns_radix_node_t* n = tree->root; radix_strlen_t pos = 0; uint8_t byte; *respos = 0; *result = n; if (!n) { /** No root, no prefix found */ return 0; } /** For each node, look if we can make further progress */ while (n) { if (pos == len) { /** Exact match */ return 1; } byte = key[pos]; if (byte < n->offset) { /** key < node */ return 1; } byte -= n->offset; if (byte >= n->len) { /** key > node */ return 1; } /** So far, the trie matches */ pos++; if (n->array[byte].len != 0) { /** Must match additional string */ if (pos + n->array[byte].len > len) { return 1; /* no match at child node */ } if (memcmp(&key[pos], n->array[byte].str, n->array[byte].len) != 0) { return 1; /* no match at child node */ } pos += n->array[byte].len; } /** Continue searching prefix at this child node */ n = n->array[byte].edge; if (!n) { return 1; } /** Update the prefix node */ *respos = pos; *result = n; } /** Done */ return 1; } /** * Make space in the node's array for another byte. * @param node: node. * @param byte: byte. * @return 1 if successful, 0 otherwise. * */ static int ldns_radix_array_space(ldns_radix_node_t* node, uint8_t byte) { /** Is there an array? */ if (!node->array) { assert(node->capacity == 0); /** No array, create new array */ node->array = LDNS_MALLOC(ldns_radix_array_t); if (!node->array) { return 0; } memset(&node->array[0], 0, sizeof(ldns_radix_array_t)); node->len = 1; node->capacity = 1; node->offset = byte; return 1; } /** Array exist */ assert(node->array != NULL); assert(node->capacity > 0); if (node->len == 0) { /** Unused array */ node->len = 1; node->offset = byte; } else if (byte < node->offset) { /** Byte is below the offset */ uint8_t index; uint16_t need = node->offset - byte; /** Is there enough capacity? */ if (node->len + need > node->capacity) { /** Not enough capacity, grow array */ if (!ldns_radix_array_grow(node, (unsigned) (node->len + need))) { return 0; /* failed to grow array */ } } /** Move items to the end */ memmove(&node->array[need], &node->array[0], node->len*sizeof(ldns_radix_array_t)); /** Fix parent index */ for (index = 0; index < node->len; index++) { if (node->array[index+need].edge) { node->array[index+need].edge->parent_index = index + need; } } /** Zero the first */ memset(&node->array[0], 0, need*sizeof(ldns_radix_array_t)); node->len += need; node->offset = byte; } else if (byte - node->offset >= node->len) { /** Byte does not fit in array */ uint16_t need = (byte - node->offset) - node->len + 1; /** Is there enough capacity? */ if (node->len + need > node->capacity) { /** Not enough capacity, grow array */ if (!ldns_radix_array_grow(node, (unsigned) (node->len + need))) { return 0; /* failed to grow array */ } } /** Zero the added items */ memset(&node->array[node->len], 0, need*sizeof(ldns_radix_array_t)); node->len += need; } return 1; } /** * Grow the array. * @param node: node. * @param need: number of elements the array at least need to grow. * Can't be bigger than 256. * @return: 0 if failed, 1 if was successful. * */ static int ldns_radix_array_grow(ldns_radix_node_t* node, unsigned need) { unsigned size = ((unsigned)node->capacity)*2; ldns_radix_array_t* a = NULL; if (need > size) { size = need; } if (size > 256) { size = 256; } a = LDNS_XMALLOC(ldns_radix_array_t, size); if (!a) { return 0; } assert(node->len <= node->capacity); assert(node->capacity < size); memcpy(&a[0], &node->array[0], node->len*sizeof(ldns_radix_array_t)); LDNS_FREE(node->array); node->array = a; node->capacity = size; return 1; } /** * Create a prefix in the array string. * @param array: array. * @param key: key. * @param pos: start position in key. * @param len: length of key. * @return 0 if failed, 1 if was successful. * */ static int ldns_radix_str_create(ldns_radix_array_t* array, uint8_t* key, radix_strlen_t pos, radix_strlen_t len) { array->str = LDNS_XMALLOC(uint8_t, (len-pos)); if (!array->str) { return 0; } memmove(array->str, key+pos, len-pos); array->len = (len-pos); return 1; } /** * Allocate remainder from prefixes for a split. * @param prefixlen: length of prefix. * @param longer_str: the longer string. * @param longer_len: the longer string length. * @param split_str: the split string. * @param split_len: the split string length. * @return 0 if failed, 1 if successful. * */ static int ldns_radix_prefix_remainder(radix_strlen_t prefix_len, uint8_t* longer_str, radix_strlen_t longer_len, uint8_t** split_str, radix_strlen_t* split_len) { *split_len = longer_len - prefix_len; *split_str = LDNS_XMALLOC(uint8_t, (*split_len)); if (!*split_str) { return 0; } memmove(*split_str, longer_str+prefix_len, longer_len-prefix_len); return 1; } /** * Create a split when two nodes have a shared prefix. * @param array: array. * @param key: key. * @param pos: start position in key. * @param len: length of the key. * @param add: node to be added. * @return 0 if failed, 1 if was successful. * */ static int ldns_radix_array_split(ldns_radix_array_t* array, uint8_t* key, radix_strlen_t pos, radix_strlen_t len, ldns_radix_node_t* add) { uint8_t* str_to_add = key + pos; radix_strlen_t strlen_to_add = len - pos; if (ldns_radix_str_is_prefix(str_to_add, strlen_to_add, array->str, array->len)) { /** The string to add is a prefix of the existing string */ uint8_t* split_str = NULL, *dup_str = NULL; radix_strlen_t split_len = 0; /** * Example 5: 'ld' * | [0] * --| [d+ns] dns * --| [e+dns] edns * --| [l+d] ld * ----| [n+s] ldns **/ assert(strlen_to_add < array->len); /** Store the remainder in the split string */ if (array->len - strlen_to_add > 1) { if (!ldns_radix_prefix_remainder(strlen_to_add+1, array->str, array->len, &split_str, &split_len)) { return 0; } } /** Duplicate the string to add */ if (strlen_to_add != 0) { dup_str = LDNS_XMALLOC(uint8_t, strlen_to_add); if (!dup_str) { LDNS_FREE(split_str); return 0; } memcpy(dup_str, str_to_add, strlen_to_add); } /** Make space in array for the new node */ if (!ldns_radix_array_space(add, array->str[strlen_to_add])) { LDNS_FREE(split_str); LDNS_FREE(dup_str); return 0; } /** * The added node should go direct under the existing parent. * The existing node should go under the added node. */ add->parent = array->edge->parent; add->parent_index = array->edge->parent_index; add->array[0].edge = array->edge; add->array[0].str = split_str; add->array[0].len = split_len; array->edge->parent = add; array->edge->parent_index = 0; LDNS_FREE(array->str); array->edge = add; array->str = dup_str; array->len = strlen_to_add; } else if (ldns_radix_str_is_prefix(array->str, array->len, str_to_add, strlen_to_add)) { /** The existing string is a prefix of the string to add */ /** * Example 6: 'dns-ng' * | [0] * --| [d+ns] dns * ----| [-+ng] dns-ng * --| [e+dns] edns * --| [l+d] ld * ----| [n+s] ldns **/ uint8_t* split_str = NULL; radix_strlen_t split_len = 0; assert(array->len < strlen_to_add); if (strlen_to_add - array->len > 1) { if (!ldns_radix_prefix_remainder(array->len+1, str_to_add, strlen_to_add, &split_str, &split_len)) { return 0; } } /** Make space in array for the new node */ if (!ldns_radix_array_space(array->edge, str_to_add[array->len])) { LDNS_FREE(split_str); return 0; } /** * The added node should go direct under the existing node. */ add->parent = array->edge; add->parent_index = str_to_add[array->len] - array->edge->offset; array->edge->array[add->parent_index].edge = add; array->edge->array[add->parent_index].str = split_str; array->edge->array[add->parent_index].len = split_len; } else { /** Create a new split node. */ /** * Example 7: 'dndns' * | [0] * --| [d+n] * ----| [d+ns] dndns * ----| [s] dns * ------| [-+ng] dns-ng * --| [e+dns] edns * --| [l+d] ld * ----| [n+s] ldns **/ ldns_radix_node_t* common = NULL; uint8_t* common_str = NULL, *s1 = NULL, *s2 = NULL; radix_strlen_t common_len = 0, l1 = 0, l2 = 0; common_len = ldns_radix_str_common(array->str, array->len, str_to_add, strlen_to_add); assert(common_len < array->len); assert(common_len < strlen_to_add); /** Create the new common node. */ common = ldns_radix_new_node(NULL, (uint8_t*)"", 0); if (!common) { return 0; } if (array->len - common_len > 1) { if (!ldns_radix_prefix_remainder(common_len+1, array->str, array->len, &s1, &l1)) { LDNS_FREE(common); return 0; } } if (strlen_to_add - common_len > 1) { if (!ldns_radix_prefix_remainder(common_len+1, str_to_add, strlen_to_add, &s2, &l2)) { LDNS_FREE(common); LDNS_FREE(s1); return 0; } } /** Create the shared prefix. */ if (common_len > 0) { common_str = LDNS_XMALLOC(uint8_t, common_len); if (!common_str) { LDNS_FREE(common); LDNS_FREE(s1); LDNS_FREE(s2); return 0; } memcpy(common_str, str_to_add, common_len); } /** Make space in the common node array. */ if (!ldns_radix_array_space(common, array->str[common_len]) || !ldns_radix_array_space(common, str_to_add[common_len])) { LDNS_FREE(common->array); LDNS_FREE(common); LDNS_FREE(common_str); LDNS_FREE(s1); LDNS_FREE(s2); return 0; } /** * The common node should go direct under the parent node. * The added and existing nodes go under the common node. */ common->parent = array->edge->parent; common->parent_index = array->edge->parent_index; array->edge->parent = common; array->edge->parent_index = array->str[common_len] - common->offset; add->parent = common; add->parent_index = str_to_add[common_len] - common->offset; common->array[array->edge->parent_index].edge = array->edge; common->array[array->edge->parent_index].str = s1; common->array[array->edge->parent_index].len = l1; common->array[add->parent_index].edge = add; common->array[add->parent_index].str = s2; common->array[add->parent_index].len = l2; LDNS_FREE(array->str); array->edge = common; array->str = common_str; array->len = common_len; } return 1; } /** * Check if one string prefix of other string. * @param str1: one string. * @param len1: one string length. * @param str2: other string. * @param len2: other string length. * @return 1 if prefix, 0 otherwise. * */ static int ldns_radix_str_is_prefix(uint8_t* str1, radix_strlen_t len1, uint8_t* str2, radix_strlen_t len2) { if (len1 == 0) { return 1; /* empty prefix is also a prefix */ } if (len1 > len2) { return 0; /* len1 is longer so str1 cannot be a prefix */ } return (memcmp(str1, str2, len1) == 0); } /** * Return the number of bytes in common for the two strings. * @param str1: one string. * @param len1: one string length. * @param str2: other string. * @param len2: other string length. * @return length of substring that the two strings have in common. * */ static radix_strlen_t ldns_radix_str_common(uint8_t* str1, radix_strlen_t len1, uint8_t* str2, radix_strlen_t len2) { radix_strlen_t i, max = (len1len; i++) { if (node->array[i].edge) { /** Node itself. */ if (node->array[i].edge->data) { return node->array[i].edge; } /** Dive into subtree. */ next = ldns_radix_next_in_subtree(node->array[i].edge); if (next) { return next; } } } return NULL; } /** * Find the previous element in the array of this node, from index. * @param node: node. * @param index: index. * @return previous node from index. * */ static ldns_radix_node_t* ldns_radix_prev_from_index(ldns_radix_node_t* node, uint8_t index) { uint8_t i = index; while (i > 0) { i--; if (node->array[i].edge) { ldns_radix_node_t* prev = ldns_radix_last_in_subtree_incl_self(node); if (prev) { return prev; } } } return NULL; } /** * Find last node in subtree, or this node (if have data). * @param node: node. * @return last node in subtree, or this node, or NULL. * */ static ldns_radix_node_t* ldns_radix_last_in_subtree_incl_self(ldns_radix_node_t* node) { ldns_radix_node_t* last = ldns_radix_last_in_subtree(node); if (last) { return last; } else if (node->data) { return node; } return NULL; } /** * Find last node in subtree. * @param node: node. * @return last node in subtree. * */ static ldns_radix_node_t* ldns_radix_last_in_subtree(ldns_radix_node_t* node) { int i; /** Look for the most right leaf node. */ for (i=(int)(node->len)-1; i >= 0; i--) { if (node->array[i].edge) { /** Keep looking for the most right leaf node. */ if (node->array[i].edge->len > 0) { ldns_radix_node_t* last = ldns_radix_last_in_subtree( node->array[i].edge); if (last) { return last; } } /** Could this be the most right leaf node? */ if (node->array[i].edge->data) { return node->array[i].edge; } } } return NULL; } /** * Fix tree after deleting element. * @param tree: tree. * @param node: node with deleted element. * */ static void ldns_radix_del_fix(ldns_radix_t* tree, ldns_radix_node_t* node) { while (node) { if (node->data) { /** Thou should not delete nodes with data attached. */ return; } else if (node->len == 1 && node->parent) { /** Node with one child is fold back into. */ ldns_radix_cleanup_onechild(node); return; } else if (node->len == 0) { /** Leaf node. */ ldns_radix_node_t* parent = node->parent; if (!parent) { /** The root is a leaf node. */ ldns_radix_node_free(node, NULL); tree->root = NULL; return; } /** Cleanup leaf node and continue with parent. */ ldns_radix_cleanup_leaf(node); node = parent; } else { /** * Node cannot be deleted, because it has edge nodes * and no parent to fix up to. */ return; } } /** Not reached. */ return; } /** * Clean up a node with one child. * @param node: node with one child. * */ static void ldns_radix_cleanup_onechild(ldns_radix_node_t* node) { uint8_t* join_str; radix_strlen_t join_len; uint8_t parent_index = node->parent_index; ldns_radix_node_t* child = node->array[0].edge; ldns_radix_node_t* parent = node->parent; /** Node has one child, merge the child node into the parent node. */ assert(parent_index < parent->len); join_len = parent->array[parent_index].len + node->array[0].len + 1; join_str = LDNS_XMALLOC(uint8_t, join_len); if (!join_str) { /** * Cleanup failed due to out of memory. * This tree is now inefficient, with the empty node still * existing, but it is still valid. */ return; } memcpy(join_str, parent->array[parent_index].str, parent->array[parent_index].len); join_str[parent->array[parent_index].len] = child->parent_index + node->offset; memmove(join_str + parent->array[parent_index].len+1, node->array[0].str, node->array[0].len); LDNS_FREE(parent->array[parent_index].str); parent->array[parent_index].str = join_str; parent->array[parent_index].len = join_len; parent->array[parent_index].edge = child; child->parent = parent; child->parent_index = parent_index; ldns_radix_node_free(node, NULL); return; } /** * Clean up a leaf node. * @param node: leaf node. * */ static void ldns_radix_cleanup_leaf(ldns_radix_node_t* node) { uint8_t parent_index = node->parent_index; ldns_radix_node_t* parent = node->parent; /** Delete lead node and fix parent array. */ assert(parent_index < parent->len); ldns_radix_node_free(node, NULL); LDNS_FREE(parent->array[parent_index].str); parent->array[parent_index].str = NULL; parent->array[parent_index].len = 0; parent->array[parent_index].edge = NULL; /** Fix array in parent. */ if (parent->len == 1) { ldns_radix_node_array_free(parent); } else if (parent_index == 0) { ldns_radix_node_array_free_front(parent); } else { ldns_radix_node_array_free_end(parent); } return; } /** * Free a radix node. * @param node: node. * @param arg: user argument. * */ static void ldns_radix_node_free(ldns_radix_node_t* node, void* arg) { uint16_t i; (void) arg; if (!node) { return; } for (i=0; i < node->len; i++) { LDNS_FREE(node->array[i].str); } node->key = NULL; node->klen = 0; LDNS_FREE(node->array); LDNS_FREE(node); return; } /** * Free select edge array. * @param node: node. * */ static void ldns_radix_node_array_free(ldns_radix_node_t* node) { node->offset = 0; node->len = 0; LDNS_FREE(node->array); node->array = NULL; node->capacity = 0; return; } /** * Free front of select edge array. * @param node: node. * */ static void ldns_radix_node_array_free_front(ldns_radix_node_t* node) { uint16_t i, n = 0; /** Remove until a non NULL entry. */ while (n < node->len && node->array[n].edge == NULL) { n++; } if (n == 0) { return; } if (n == node->len) { ldns_radix_node_array_free(node); return; } assert(n < node->len); assert((int) n <= (255 - (int) node->offset)); memmove(&node->array[0], &node->array[n], (node->len - n)*sizeof(ldns_radix_array_t)); node->offset += n; node->len -= n; for (i=0; i < node->len; i++) { if (node->array[i].edge) { node->array[i].edge->parent_index = i; } } ldns_radix_array_reduce(node); return; } /** * Free front of select edge array. * @param node: node. * */ static void ldns_radix_node_array_free_end(ldns_radix_node_t* node) { uint16_t n = 0; /** Shorten array. */ while (n < node->len && node->array[node->len-1-n].edge == NULL) { n++; } if (n == 0) { return; } if (n == node->len) { ldns_radix_node_array_free(node); return; } assert(n < node->len); node->len -= n; ldns_radix_array_reduce(node); return; } /** * Reduce the capacity of the array if needed. * @param node: node. * */ static void ldns_radix_array_reduce(ldns_radix_node_t* node) { if (node->len <= node->capacity/2 && node->len != node->capacity) { ldns_radix_array_t* a = LDNS_XMALLOC(ldns_radix_array_t, node->len); if (!a) { return; } memcpy(a, node->array, sizeof(ldns_radix_array_t)*node->len); LDNS_FREE(node->array); node->array = a; node->capacity = node->len; } return; } /** * Return this element if it exists, the previous otherwise. * @param node: from this node. * @param result: result node. * */ static void ldns_radix_self_or_prev(ldns_radix_node_t* node, ldns_radix_node_t** result) { if (node->data) { *result = node; } else { *result = ldns_radix_prev(node); } return; } ldns-1.9.2/keys.c0000664000175000017500000014745015212267520013165 0ustar willemwillem/* * keys.c handle private keys for use in DNSSEC * * This module should hide some of the openSSL complexities * and give a general interface for private keys and hmac * handling * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ #include #include #ifdef HAVE_SSL #include #include #include #include #include #ifdef USE_DSA #include #endif #if defined(HAVE_OPENSSL_ENGINE_H) && !defined(OPENSSL_NO_ENGINE) #include #else # ifndef OPENSSL_NO_ENGINE # define OPENSSL_NO_ENGINE # endif #endif #endif /* HAVE_SSL */ ldns_lookup_table ldns_signing_algorithms[] = { { LDNS_SIGN_RSAMD5, "RSAMD5" }, { LDNS_SIGN_RSASHA1, "RSASHA1" }, { LDNS_SIGN_RSASHA1_NSEC3, "RSASHA1-NSEC3-SHA1" }, #ifdef USE_SHA2 { LDNS_SIGN_RSASHA256, "RSASHA256" }, { LDNS_SIGN_RSASHA512, "RSASHA512" }, #endif #ifdef USE_GOST { LDNS_SIGN_ECC_GOST, "ECC-GOST" }, #endif #ifdef USE_ECDSA { LDNS_SIGN_ECDSAP256SHA256, "ECDSAP256SHA256" }, { LDNS_SIGN_ECDSAP384SHA384, "ECDSAP384SHA384" }, #endif #ifdef USE_ED25519 { LDNS_SIGN_ED25519, "ED25519" }, #endif #ifdef USE_ED448 { LDNS_SIGN_ED448, "ED448" }, #endif #ifdef USE_DSA { LDNS_SIGN_DSA, "DSA" }, { LDNS_SIGN_DSA_NSEC3, "DSA-NSEC3-SHA1" }, #endif { LDNS_SIGN_HMACMD5, "hmac-md5.sig-alg.reg.int" }, { LDNS_SIGN_HMACSHA1, "hmac-sha1" }, { LDNS_SIGN_HMACSHA256, "hmac-sha256" }, { LDNS_SIGN_HMACSHA224, "hmac-sha224" }, { LDNS_SIGN_HMACSHA384, "hmac-sha384" }, { LDNS_SIGN_HMACSHA512, "hmac-sha512" }, { 0, NULL } }; ldns_key_list * ldns_key_list_new(void) { ldns_key_list *key_list = LDNS_MALLOC(ldns_key_list); if (!key_list) { return NULL; } else { key_list->_key_count = 0; key_list->_keys = NULL; return key_list; } } ldns_key * ldns_key_new(void) { ldns_key *newkey; newkey = LDNS_MALLOC(ldns_key); if (!newkey) { return NULL; } else { /* some defaults - not sure whether to do this */ ldns_key_set_use(newkey, true); ldns_key_set_flags(newkey, LDNS_KEY_ZONE_KEY); ldns_key_set_origttl(newkey, 0); ldns_key_set_keytag(newkey, 0); ldns_key_set_inception(newkey, 0); ldns_key_set_expiration(newkey, 0); ldns_key_set_pubkey_owner(newkey, NULL); #ifdef HAVE_SSL ldns_key_set_evp_key(newkey, NULL); #endif /* HAVE_SSL */ ldns_key_set_hmac_key(newkey, NULL); ldns_key_set_external_key(newkey, NULL); return newkey; } } ldns_status ldns_key_new_frm_fp(ldns_key **k, FILE *fp) { return ldns_key_new_frm_fp_l(k, fp, NULL); } #if defined(HAVE_SSL) && !defined(OPENSSL_NO_ENGINE) ldns_status ldns_key_new_frm_engine(ldns_key **key, ENGINE *e, char *key_id, ldns_algorithm alg) { ldns_key *k; k = ldns_key_new(); if(!k) return LDNS_STATUS_MEM_ERR; #ifndef S_SPLINT_S ldns_key_set_algorithm(k, (ldns_signing_algorithm) alg); k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL); if (!k->_key.key) { ldns_key_free(k); return LDNS_STATUS_ENGINE_KEY_NOT_LOADED; } #endif /* splint */ *key = k; return LDNS_STATUS_OK; } #endif #if defined(USE_GOST) && !defined(OPENSSL_NO_ENGINE) /** store GOST engine reference loaded into OpenSSL library */ ENGINE* ldns_gost_engine = NULL; int ldns_key_EVP_load_gost_id(void) { static int gost_id = 0; const EVP_PKEY_ASN1_METHOD* meth; ENGINE* e; if(gost_id) return gost_id; /* see if configuration loaded gost implementation from other engine*/ meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); if(meth) { EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } /* see if engine can be loaded already */ e = ENGINE_by_id("gost"); if(!e) { /* load it ourself, in case statically linked */ ENGINE_load_builtin_engines(); ENGINE_load_dynamic(); e = ENGINE_by_id("gost"); } if(!e) { /* no gost engine in openssl */ return 0; } if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { ENGINE_finish(e); ENGINE_free(e); return 0; } meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); if(!meth) { /* algo not found */ ENGINE_finish(e); ENGINE_free(e); return 0; } /* Note: do not ENGINE_finish and ENGINE_free the acquired engine * on some platforms this frees up the meth and unloads gost stuff */ ldns_gost_engine = e; EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } void ldns_key_EVP_unload_gost(void) { if(ldns_gost_engine) { ENGINE_finish(ldns_gost_engine); ENGINE_free(ldns_gost_engine); ldns_gost_engine = NULL; } } /** read GOST private key */ static EVP_PKEY* ldns_key_new_frm_fp_gost_l(FILE* fp, int* line_nr) { char token[16384]; const unsigned char* pp; int gost_id; EVP_PKEY* pkey; ldns_rdf* b64rdf = NULL; gost_id = ldns_key_EVP_load_gost_id(); if(!gost_id) return NULL; if (ldns_fget_keyword_data_l(fp, "GostAsn1", ": ", token, "\n", sizeof(token), line_nr) == -1) return NULL; while(strlen(token) < 96) { /* read more b64 from the file, b64 split on multiple lines */ if(ldns_fget_token_l(fp, token+strlen(token), "\n", sizeof(token)-strlen(token), line_nr) == -1) return NULL; } if(ldns_str2rdf_b64(&b64rdf, token) != LDNS_STATUS_OK) return NULL; pp = (unsigned char*)ldns_rdf_data(b64rdf); pkey = d2i_PrivateKey(gost_id, NULL, &pp, (int)ldns_rdf_size(b64rdf)); ldns_rdf_deep_free(b64rdf); return pkey; } #endif #ifdef USE_ECDSA /** calculate public key from private key */ static int ldns_EC_KEY_calc_public(EC_KEY* ec) { EC_POINT* pub_key; const EC_GROUP* group; group = EC_KEY_get0_group(ec); pub_key = EC_POINT_new(group); if(!pub_key) return 0; if(!EC_POINT_copy(pub_key, EC_GROUP_get0_generator(group))) { EC_POINT_free(pub_key); return 0; } if(!EC_POINT_mul(group, pub_key, EC_KEY_get0_private_key(ec), NULL, NULL, NULL)) { EC_POINT_free(pub_key); return 0; } if(EC_KEY_set_public_key(ec, pub_key) == 0) { EC_POINT_free(pub_key); return 0; } EC_POINT_free(pub_key); return 1; } /** read ECDSA private key */ static EVP_PKEY* ldns_key_new_frm_fp_ecdsa_l(FILE* fp, ldns_algorithm alg, int* line_nr) { char token[16384]; ldns_rdf* b64rdf = NULL; unsigned char* pp; BIGNUM* bn; EVP_PKEY* evp_key; EC_KEY* ec; if (ldns_fget_keyword_data_l(fp, "PrivateKey", ": ", token, "\n", sizeof(token), line_nr) == -1) return NULL; if(ldns_str2rdf_b64(&b64rdf, token) != LDNS_STATUS_OK) return NULL; pp = (unsigned char*)ldns_rdf_data(b64rdf); if(alg == LDNS_ECDSAP256SHA256) ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); else if(alg == LDNS_ECDSAP384SHA384) ec = EC_KEY_new_by_curve_name(NID_secp384r1); else ec = NULL; if(!ec) { ldns_rdf_deep_free(b64rdf); return NULL; } bn = BN_bin2bn(pp, (int)ldns_rdf_size(b64rdf), NULL); ldns_rdf_deep_free(b64rdf); if(!bn) { EC_KEY_free(ec); return NULL; } EC_KEY_set_private_key(ec, bn); BN_free(bn); if(!ldns_EC_KEY_calc_public(ec)) { EC_KEY_free(ec); return NULL; } evp_key = EVP_PKEY_new(); if(!evp_key) { EC_KEY_free(ec); return NULL; } if (!EVP_PKEY_assign_EC_KEY(evp_key, ec)) { EVP_PKEY_free(evp_key); EC_KEY_free(ec); return NULL; } return evp_key; } #endif #ifdef USE_ED25519 /** turn private key buffer into EC_KEY structure */ static EVP_PKEY* ldns_ed25519_priv_raw(uint8_t* pkey, int plen) { const unsigned char* pp; uint8_t buf[256]; int buflen = 0; uint8_t pre[] = {0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x04, 0x22, 0x04, 0x20}; int pre_len = 16; /* ASN looks like this for ED25519 public key * 302a300506032b6570032100 <32byteskey> * for ED25519 private key * 302e020100300506032b657004220420 <32bytes> * * for X25519 this was * 30320201010420 <32byteskey> * andparameters a00b06092b06010401da470f01 * (noparameters, preamble is 30250201010420). * the key is reversed (little endian). */ buflen = pre_len + plen; if((size_t)buflen > sizeof(buf)) return NULL; memmove(buf, pre, pre_len); memmove(buf+pre_len, pkey, plen); /* reverse the pkey into the buf - key is not reversed it seems */ /* for(i=0; i * the key is reversed (little endian). */ buflen = pre_len + plen; if((size_t)buflen > sizeof(buf)) return NULL; memmove(buf, pre, pre_len); memmove(buf+pre_len, pkey, plen); /* reverse the pkey into the buf - key is not reversed it seems */ /* for(i=0; i_key.key) { ldns_key_free(k); return LDNS_STATUS_ERR; } #endif /* splint */ #endif break; #ifdef USE_ECDSA case LDNS_SIGN_ECDSAP256SHA256: case LDNS_SIGN_ECDSAP384SHA384: ldns_key_set_algorithm(k, alg); ldns_key_set_evp_key(k, ldns_key_new_frm_fp_ecdsa_l(fp, (ldns_algorithm)alg, line_nr)); #ifndef S_SPLINT_S if(!k->_key.key) { ldns_key_free(k); return LDNS_STATUS_ERR; } #endif /* splint */ break; #endif #ifdef USE_ED25519 case LDNS_SIGN_ED25519: ldns_key_set_algorithm(k, alg); ldns_key_set_evp_key(k, ldns_key_new_frm_fp_ed25519_l(fp, line_nr)); #ifndef S_SPLINT_S if(!k->_key.key) { ldns_key_free(k); return LDNS_STATUS_ERR; } #endif /* splint */ break; #endif #ifdef USE_ED448 case LDNS_SIGN_ED448: ldns_key_set_algorithm(k, alg); ldns_key_set_evp_key(k, ldns_key_new_frm_fp_ed448_l(fp, line_nr)); #ifndef S_SPLINT_S if(!k->_key.key) { ldns_key_free(k); return LDNS_STATUS_ERR; } #endif /* splint */ break; #endif default: ldns_key_free(k); return LDNS_STATUS_SYNTAX_ALG_ERR; } key_rr = ldns_key2rr(k); ldns_key_set_keytag(k, ldns_calc_keytag(key_rr)); ldns_rr_free(key_rr); if (key) { *key = k; return LDNS_STATUS_OK; } ldns_key_free(k); return LDNS_STATUS_ERR; } #ifdef HAVE_SSL RSA * ldns_key_new_frm_fp_rsa(FILE *f) { return ldns_key_new_frm_fp_rsa_l(f, NULL); } RSA * ldns_key_new_frm_fp_rsa_l(FILE *f, int *line_nr) { /* we parse * Modulus: * PublicExponent: * PrivateExponent: * Prime1: * Prime2: * Exponent1: * Exponent2: * Coefficient: * * man 3 RSA: * * struct * { * BIGNUM *n; // public modulus * BIGNUM *e; // public exponent * BIGNUM *d; // private exponent * BIGNUM *p; // secret prime factor * BIGNUM *q; // secret prime factor * BIGNUM *dmp1; // d mod (p-1) * BIGNUM *dmq1; // d mod (q-1) * BIGNUM *iqmp; // q^-1 mod p * // ... * */ char *b; RSA *rsa; uint8_t *buf; int i; BIGNUM *n=NULL, *e=NULL, *d=NULL, *p=NULL, *q=NULL, *dmp1=NULL, *dmq1=NULL, *iqmp=NULL; b = LDNS_XMALLOC(char, LDNS_MAX_LINELEN); buf = LDNS_XMALLOC(uint8_t, LDNS_MAX_LINELEN); rsa = RSA_new(); if (!b || !rsa || !buf) { goto error; } /* I could use functions again, but that seems an overkill, * although this also looks tedious */ /* Modules, rsa->n */ if (ldns_fget_keyword_data_l(f, "Modulus", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); #ifndef S_SPLINT_S n = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!n) { goto error; } /* PublicExponent, rsa->e */ if (ldns_fget_keyword_data_l(f, "PublicExponent", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); e = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!e) { goto error; } /* PrivateExponent, rsa->d */ if (ldns_fget_keyword_data_l(f, "PrivateExponent", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); d = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!d) { goto error; } /* Prime1, rsa->p */ if (ldns_fget_keyword_data_l(f, "Prime1", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); p = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!p) { goto error; } /* Prime2, rsa->q */ if (ldns_fget_keyword_data_l(f, "Prime2", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); q = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!q) { goto error; } /* Exponent1, rsa->dmp1 */ if (ldns_fget_keyword_data_l(f, "Exponent1", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); dmp1 = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!dmp1) { goto error; } /* Exponent2, rsa->dmq1 */ if (ldns_fget_keyword_data_l(f, "Exponent2", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); dmq1 = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!dmq1) { goto error; } /* Coefficient, rsa->iqmp */ if (ldns_fget_keyword_data_l(f, "Coefficient", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)b, buf, ldns_b64_ntop_calculate_size(strlen(b))); iqmp = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!iqmp) { goto error; } #endif /* splint */ #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000) # ifndef S_SPLINT_S rsa->n = n; rsa->e = e; rsa->d = d; rsa->p = p; rsa->q = q; rsa->dmp1 = dmp1; rsa->dmq1 = dmq1; rsa->iqmp = iqmp; # endif #else if(!RSA_set0_key(rsa, n, e, d)) goto error; n = NULL; e = NULL; d = NULL; if(!RSA_set0_factors(rsa, p, q)) goto error; p = NULL; q = NULL; if(!RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp)) goto error; #endif LDNS_FREE(buf); LDNS_FREE(b); return rsa; error: RSA_free(rsa); LDNS_FREE(b); LDNS_FREE(buf); BN_free(n); BN_free(e); BN_free(d); BN_free(p); BN_free(q); BN_free(dmp1); BN_free(dmq1); BN_free(iqmp); return NULL; } #ifdef USE_DSA DSA * ldns_key_new_frm_fp_dsa(FILE *f) { return ldns_key_new_frm_fp_dsa_l(f, NULL); } DSA * ldns_key_new_frm_fp_dsa_l(FILE *f, ATTR_UNUSED(int *line_nr)) { int i; char *d; DSA *dsa; uint8_t *buf; BIGNUM *p=NULL, *q=NULL, *g=NULL, *priv_key=NULL, *pub_key=NULL; d = LDNS_XMALLOC(char, LDNS_MAX_LINELEN); buf = LDNS_XMALLOC(uint8_t, LDNS_MAX_LINELEN); dsa = DSA_new(); if (!d || !dsa || !buf) { goto error; } /* the line parser removes the () from the input... */ /* Prime, dsa->p */ if (ldns_fget_keyword_data_l(f, "Primep", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d))); #ifndef S_SPLINT_S p = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!p) { goto error; } /* Subprime, dsa->q */ if (ldns_fget_keyword_data_l(f, "Subprimeq", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d))); q = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!q) { goto error; } /* Base, dsa->g */ if (ldns_fget_keyword_data_l(f, "Baseg", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d))); g = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!g) { goto error; } /* Private key, dsa->priv_key */ if (ldns_fget_keyword_data_l(f, "Private_valuex", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d))); priv_key = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!priv_key) { goto error; } /* Public key, dsa->priv_key */ if (ldns_fget_keyword_data_l(f, "Public_valuey", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { goto error; } i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d))); pub_key = BN_bin2bn((const char unsigned*)buf, i, NULL); if (!pub_key) { goto error; } #endif /* splint */ #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000) # ifndef S_SPLINT_S dsa->p = p; dsa->q = q; dsa->g = g; dsa->priv_key = priv_key; dsa->pub_key = pub_key; # endif #else if(!DSA_set0_pqg(dsa, p, q, g)) goto error; p = NULL; q = NULL; g = NULL; if(!DSA_set0_key(dsa, pub_key, priv_key)) goto error; #endif LDNS_FREE(buf); LDNS_FREE(d); return dsa; error: LDNS_FREE(d); LDNS_FREE(buf); DSA_free(dsa); BN_free(p); BN_free(q); BN_free(g); BN_free(priv_key); BN_free(pub_key); return NULL; } #endif /* USE_DSA */ unsigned char * ldns_key_new_frm_fp_hmac(FILE *f, size_t *hmac_size) { return ldns_key_new_frm_fp_hmac_l(f, NULL, hmac_size); } unsigned char * ldns_key_new_frm_fp_hmac_l( FILE *f , ATTR_UNUSED(int *line_nr) , size_t *hmac_size ) { size_t bufsz; char d[LDNS_MAX_LINELEN]; unsigned char *buf = NULL; *hmac_size = ldns_fget_keyword_data_l(f, "Key", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1 ? 0 : (buf = LDNS_XMALLOC( unsigned char, (bufsz = ldns_b64_ntop_calculate_size(strlen(d))))) == NULL ? 0 : (size_t) ldns_b64_pton((const char*)d, buf, bufsz); return buf; } #endif /* HAVE_SSL */ #ifdef USE_GOST static EVP_PKEY* ldns_gen_gost_key(void) { EVP_PKEY_CTX* ctx; EVP_PKEY* p = NULL; int gost_id = ldns_key_EVP_load_gost_id(); if(!gost_id) return NULL; ctx = EVP_PKEY_CTX_new_id(gost_id, NULL); if(!ctx) { /* the id should be available now */ return NULL; } if(EVP_PKEY_CTX_ctrl_str(ctx, "paramset", "A") <= 0) { /* cannot set paramset */ EVP_PKEY_CTX_free(ctx); return NULL; } if(EVP_PKEY_keygen_init(ctx) <= 0) { EVP_PKEY_CTX_free(ctx); return NULL; } if(EVP_PKEY_keygen(ctx, &p) <= 0) { EVP_PKEY_free(p); EVP_PKEY_CTX_free(ctx); return NULL; } EVP_PKEY_CTX_free(ctx); return p; } #endif ldns_key * ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size) { ldns_key *k; #ifdef HAVE_SSL #ifdef USE_DSA DSA *d; #endif /* USE_DSA */ # ifdef USE_ECDSA EC_KEY *ec = NULL; # endif # ifdef HAVE_EVP_PKEY_KEYGEN EVP_PKEY_CTX *ctx; # else RSA *r; # endif #else int i; uint16_t offset = 0; #endif unsigned char *hmac; k = ldns_key_new(); if (!k) { return NULL; } switch(alg) { case LDNS_SIGN_RSAMD5: case LDNS_SIGN_RSASHA1: case LDNS_SIGN_RSASHA1_NSEC3: case LDNS_SIGN_RSASHA256: case LDNS_SIGN_RSASHA512: #ifdef HAVE_SSL #ifdef HAVE_EVP_PKEY_KEYGEN ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); if(!ctx) { ldns_key_free(k); return NULL; } if(EVP_PKEY_keygen_init(ctx) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } if (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, size) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } #ifndef S_SPLINT_S if (EVP_PKEY_keygen(ctx, &k->_key.key) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } #endif EVP_PKEY_CTX_free(ctx); #else /* HAVE_EVP_PKEY_KEYGEN */ r = RSA_generate_key((int)size, RSA_F4, NULL, NULL); if(!r) { ldns_key_free(k); return NULL; } if (RSA_check_key(r) != 1) { ldns_key_free(k); return NULL; } ldns_key_set_rsa_key(k, r); RSA_free(r); #endif /* HAVE_EVP_PKEY_KEYGEN */ #endif /* HAVE_SSL */ break; #ifdef USE_DSA case LDNS_SIGN_DSA: case LDNS_SIGN_DSA_NSEC3: #ifdef HAVE_SSL # if OPENSSL_VERSION_NUMBER < 0x00908000L d = DSA_generate_parameters((int)size, NULL, 0, NULL, NULL, NULL, NULL); if (!d) { ldns_key_free(k); return NULL; } # else if (! (d = DSA_new())) { ldns_key_free(k); return NULL; } if (! DSA_generate_parameters_ex(d, (int)size, NULL, 0, NULL, NULL, NULL)) { DSA_free(d); ldns_key_free(k); return NULL; } # endif if (DSA_generate_key(d) != 1) { ldns_key_free(k); return NULL; } ldns_key_set_dsa_key(k, d); DSA_free(d); #endif /* HAVE_SSL */ #endif /* USE_DSA */ break; case LDNS_SIGN_HMACMD5: case LDNS_SIGN_HMACSHA1: case LDNS_SIGN_HMACSHA224: case LDNS_SIGN_HMACSHA256: case LDNS_SIGN_HMACSHA384: case LDNS_SIGN_HMACSHA512: #ifdef HAVE_SSL #ifndef S_SPLINT_S k->_key.key = NULL; #endif /* splint */ #endif /* HAVE_SSL */ size = size / 8; ldns_key_set_hmac_size(k, size); hmac = LDNS_XMALLOC(unsigned char, size); if(!hmac) { ldns_key_free(k); return NULL; } #ifdef HAVE_SSL if (RAND_bytes(hmac, (int) size) != 1) { LDNS_FREE(hmac); ldns_key_free(k); return NULL; } #else while (offset + sizeof(i) < size) { i = random(); memcpy(&hmac[offset], &i, sizeof(i)); offset += sizeof(i); } if (offset < size) { i = random(); memcpy(&hmac[offset], &i, size - offset); } #endif /* HAVE_SSL */ ldns_key_set_hmac_key(k, hmac); ldns_key_set_flags(k, 0); break; case LDNS_SIGN_ECC_GOST: #if defined(HAVE_SSL) && defined(USE_GOST) ldns_key_set_evp_key(k, ldns_gen_gost_key()); #ifndef S_SPLINT_S if(!k->_key.key) { ldns_key_free(k); return NULL; } #endif /* splint */ #else ldns_key_free(k); return NULL; #endif /* HAVE_SSL and USE_GOST */ break; case LDNS_SIGN_ECDSAP256SHA256: case LDNS_SIGN_ECDSAP384SHA384: #ifdef USE_ECDSA if(alg == LDNS_SIGN_ECDSAP256SHA256) ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); else if(alg == LDNS_SIGN_ECDSAP384SHA384) ec = EC_KEY_new_by_curve_name(NID_secp384r1); if(!ec) { ldns_key_free(k); return NULL; } if(!EC_KEY_generate_key(ec)) { ldns_key_free(k); EC_KEY_free(ec); return NULL; } #ifndef S_SPLINT_S k->_key.key = EVP_PKEY_new(); if(!k->_key.key) { ldns_key_free(k); EC_KEY_free(ec); return NULL; } if (!EVP_PKEY_assign_EC_KEY(k->_key.key, ec)) { ldns_key_free(k); EC_KEY_free(ec); return NULL; } #endif /* splint */ #else ldns_key_free(k); return NULL; #endif /* ECDSA */ break; #ifdef USE_ED25519 case LDNS_SIGN_ED25519: #ifdef HAVE_EVP_PKEY_KEYGEN ctx = EVP_PKEY_CTX_new_id(NID_ED25519, NULL); if(!ctx) { ldns_key_free(k); return NULL; } if(EVP_PKEY_keygen_init(ctx) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } if (EVP_PKEY_keygen(ctx, &k->_key.key) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } EVP_PKEY_CTX_free(ctx); #endif break; #endif /* ED25519 */ #ifdef USE_ED448 case LDNS_SIGN_ED448: #ifdef HAVE_EVP_PKEY_KEYGEN ctx = EVP_PKEY_CTX_new_id(NID_ED448, NULL); if(!ctx) { ldns_key_free(k); return NULL; } if(EVP_PKEY_keygen_init(ctx) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } if (EVP_PKEY_keygen(ctx, &k->_key.key) <= 0) { ldns_key_free(k); EVP_PKEY_CTX_free(ctx); return NULL; } EVP_PKEY_CTX_free(ctx); #endif break; #endif /* ED448 */ } ldns_key_set_algorithm(k, alg); return k; } void ldns_key_print(FILE *output, const ldns_key *k) { char *str = ldns_key2str(k); if (str) { fprintf(output, "%s", str); } else { fprintf(output, "Unable to convert private key to string\n"); } LDNS_FREE(str); } void ldns_key_set_algorithm(ldns_key *k, ldns_signing_algorithm l) { k->_alg = l; } void ldns_key_set_flags(ldns_key *k, uint16_t f) { k->_extra.dnssec.flags = f; } #ifdef HAVE_SSL #ifndef S_SPLINT_S void ldns_key_set_evp_key(ldns_key *k, EVP_PKEY *e) { k->_key.key = e; } void ldns_key_set_rsa_key(ldns_key *k, RSA *r) { EVP_PKEY *key = EVP_PKEY_new(); EVP_PKEY_set1_RSA(key, r); k->_key.key = key; } void ldns_key_set_dsa_key(ldns_key *k, DSA *d) { #ifdef USE_DSA EVP_PKEY *key = EVP_PKEY_new(); EVP_PKEY_set1_DSA(key, d); k->_key.key = key; #else (void)k; (void)d; #endif } void ldns_key_assign_rsa_key(ldns_key *k, RSA *r) { EVP_PKEY *key = EVP_PKEY_new(); EVP_PKEY_assign_RSA(key, r); k->_key.key = key; } void ldns_key_assign_dsa_key(ldns_key *k, DSA *d) { #ifdef USE_DSA EVP_PKEY *key = EVP_PKEY_new(); EVP_PKEY_assign_DSA(key, d); k->_key.key = key; #else (void)k; (void)d; #endif } #endif /* splint */ #endif /* HAVE_SSL */ void ldns_key_set_hmac_key(ldns_key *k, unsigned char *hmac) { k->_key.hmac.key = hmac; } void ldns_key_set_hmac_size(ldns_key *k, size_t hmac_size) { k->_key.hmac.size = hmac_size; } void ldns_key_set_external_key(ldns_key *k, void *external_key) { k->_key.external_key = external_key; } void ldns_key_set_origttl(ldns_key *k, uint32_t t) { k->_extra.dnssec.orig_ttl = t; } void ldns_key_set_inception(ldns_key *k, uint32_t i) { k->_extra.dnssec.inception = i; } void ldns_key_set_expiration(ldns_key *k, uint32_t e) { k->_extra.dnssec.expiration = e; } void ldns_key_set_pubkey_owner(ldns_key *k, ldns_rdf *r) { k->_pubkey_owner = r; } void ldns_key_set_keytag(ldns_key *k, uint16_t tag) { k->_extra.dnssec.keytag = tag; } /* read */ size_t ldns_key_list_key_count(const ldns_key_list *key_list) { return key_list ? key_list->_key_count : 0; } ldns_key * ldns_key_list_key(const ldns_key_list *key, size_t nr) { if (nr < ldns_key_list_key_count(key)) { return key->_keys[nr]; } else { return NULL; } } ldns_signing_algorithm ldns_key_algorithm(const ldns_key *k) { return k->_alg; } void ldns_key_set_use(ldns_key *k, bool v) { if (k) { k->_use = v; } } bool ldns_key_use(const ldns_key *k) { if (k) { return k->_use; } return false; } #ifdef HAVE_SSL #ifndef S_SPLINT_S EVP_PKEY * ldns_key_evp_key(const ldns_key *k) { return k->_key.key; } RSA * ldns_key_rsa_key(const ldns_key *k) { if (k->_key.key) { return EVP_PKEY_get1_RSA(k->_key.key); } else { return NULL; } } DSA * ldns_key_dsa_key(const ldns_key *k) { #ifdef USE_DSA if (k->_key.key) { return EVP_PKEY_get1_DSA(k->_key.key); } else { return NULL; } #else (void)k; return NULL; #endif } #endif /* splint */ #endif /* HAVE_SSL */ unsigned char * ldns_key_hmac_key(const ldns_key *k) { if (k->_key.hmac.key) { return k->_key.hmac.key; } else { return NULL; } } size_t ldns_key_hmac_size(const ldns_key *k) { #ifndef __clang_analyzer__ if (k->_key.hmac.size) { return k->_key.hmac.size; } else { return 0; } #endif } void * ldns_key_external_key(const ldns_key *k) { return k->_key.external_key; } uint32_t ldns_key_origttl(const ldns_key *k) { return k->_extra.dnssec.orig_ttl; } uint16_t ldns_key_flags(const ldns_key *k) { return k->_extra.dnssec.flags; } uint32_t ldns_key_inception(const ldns_key *k) { return k->_extra.dnssec.inception; } uint32_t ldns_key_expiration(const ldns_key *k) { return k->_extra.dnssec.expiration; } uint16_t ldns_key_keytag(const ldns_key *k) { return k->_extra.dnssec.keytag; } ldns_rdf * ldns_key_pubkey_owner(const ldns_key *k) { return k->_pubkey_owner; } /* write */ void ldns_key_list_set_use(ldns_key_list *keys, bool v) { size_t i; for (i = 0; i < ldns_key_list_key_count(keys); i++) { ldns_key_set_use(ldns_key_list_key(keys, i), v); } } void ldns_key_list_set_key_count(ldns_key_list *key, size_t count) { key->_key_count = count; } bool ldns_key_list_push_key(ldns_key_list *key_list, ldns_key *key) { size_t key_count; ldns_key **keys; key_count = ldns_key_list_key_count(key_list); /* grow the array */ keys = LDNS_XREALLOC( key_list->_keys, ldns_key *, key_count + 1); if (!keys) { return false; } /* add the new member */ key_list->_keys = keys; key_list->_keys[key_count] = key; ldns_key_list_set_key_count(key_list, key_count + 1); return true; } ldns_key * ldns_key_list_pop_key(ldns_key_list *key_list) { size_t key_count; ldns_key** a; ldns_key *pop; if (!key_list) { return NULL; } key_count = ldns_key_list_key_count(key_list); if (key_count == 0) { return NULL; } pop = ldns_key_list_key(key_list, key_count); /* shrink the array */ a = LDNS_XREALLOC(key_list->_keys, ldns_key *, key_count - 1); if(a) { key_list->_keys = a; } ldns_key_list_set_key_count(key_list, key_count - 1); return pop; } #ifdef HAVE_SSL #ifndef S_SPLINT_S /* data pointer must be large enough (LDNS_MAX_KEYLEN) */ static bool ldns_key_rsa2bin(unsigned char *data, RSA *k, uint16_t *size) { int i,j; const BIGNUM *n=NULL, *e=NULL; if (!k) { return false; } #if OPENSSL_VERSION_NUMBER < 0x10100000 || (defined(HAVE_LIBRESSL) && LIBRESSL_VERSION_NUMBER < 0x20700000) n = k->n; e = k->e; #else RSA_get0_key(k, &n, &e, NULL); #endif if (BN_num_bytes(e) <= 256) { /* normally only this path is executed (small factors are * more common */ data[0] = (unsigned char) BN_num_bytes(e); i = BN_bn2bin(e, data + 1); j = BN_bn2bin(n, data + i + 1); *size = (uint16_t) i + j; } else if (BN_num_bytes(e) <= 65536) { data[0] = 0; /* BN_bn2bin does bigendian, _uint16 also */ ldns_write_uint16(data + 1, (uint16_t) BN_num_bytes(e)); BN_bn2bin(e, data + 3); BN_bn2bin(n, data + 4 + BN_num_bytes(e)); *size = (uint16_t) BN_num_bytes(n) + 6; } else { return false; } return true; } #ifdef USE_DSA /* data pointer must be large enough (LDNS_MAX_KEYLEN) */ static bool ldns_key_dsa2bin(unsigned char *data, DSA *k, uint16_t *size) { uint8_t T; const BIGNUM *p, *q, *g; const BIGNUM *pub_key, *priv_key; if (!k) { return false; } /* See RFC2536 */ # ifdef HAVE_DSA_GET0_PQG DSA_get0_pqg(k, &p, &q, &g); # else p = k->p; q = k->q; g = k->g; # endif # ifdef HAVE_DSA_GET0_KEY DSA_get0_key(k, &pub_key, &priv_key); # else pub_key = k->pub_key; priv_key = k->priv_key; # endif (void)priv_key; *size = (uint16_t)BN_num_bytes(p); T = (*size - 64) / 8; if (T > 8) { #ifdef STDERR_MSGS fprintf(stderr, "DSA key with T > 8 (ie. > 1024 bits)"); fprintf(stderr, " not implemented\n"); #endif return false; } /* size = 64 + (T * 8); */ memset(data, 0, 21 + *size * 3); data[0] = (unsigned char)T; BN_bn2bin(q, data + 1 ); /* 20 octects */ BN_bn2bin(p, data + 21 ); /* offset octects */ BN_bn2bin(g, data + 21 + *size * 2 - BN_num_bytes(g)); BN_bn2bin(pub_key,data + 21 + *size * 3 - BN_num_bytes(pub_key)); *size = 21 + *size * 3; return true; } #endif /* USE_DSA */ #ifdef USE_GOST static bool ldns_key_gost2bin(unsigned char* data, EVP_PKEY* k, uint16_t* size) { int i; unsigned char* pp = NULL; if(i2d_PUBKEY(k, &pp) != 37 + 64) { /* expect 37 byte(ASN header) and 64 byte(X and Y) */ free(pp); return false; } /* omit ASN header */ for(i=0; i<64; i++) data[i] = pp[i+37]; free(pp); *size = 64; return true; } #endif /* USE_GOST */ #ifdef USE_ED25519 static bool ldns_key_ed255192bin(unsigned char* data, EVP_PKEY* k, uint16_t* size) { int i; unsigned char* pp = NULL; if(i2d_PUBKEY(k, &pp) != 12 + 32) { /* expect 12 byte(ASN header) and 32 byte(pubkey) */ free(pp); return false; } /* omit ASN header */ for(i=0; i<32; i++) data[i] = pp[i+12]; free(pp); *size = 32; return true; } #endif /* USE_ED25519 */ #ifdef USE_ED448 static bool ldns_key_ed4482bin(unsigned char* data, EVP_PKEY* k, uint16_t* size) { int i; unsigned char* pp = NULL; if(i2d_PUBKEY(k, &pp) != 12 + 57) { /* expect 12 byte(ASN header) and 57 byte(pubkey) */ free(pp); return false; } /* omit ASN header */ for(i=0; i<57; i++) data[i] = pp[i+12]; free(pp); *size = 57; return true; } #endif /* USE_ED448 */ #endif /* splint */ #endif /* HAVE_SSL */ ldns_rr * ldns_key2rr(const ldns_key *k) { /* this function will convert a the keydata contained in * rsa/dsa pointers to a DNSKEY rr. It will fill in as * much as it can, but it does not know about key-flags * for instance */ ldns_rr *pubkey; ldns_rdf *keybin; unsigned char *bin = NULL; uint16_t size = 0; #ifdef HAVE_SSL RSA *rsa = NULL; #ifdef USE_DSA DSA *dsa = NULL; #endif /* USE_DSA */ #endif /* HAVE_SSL */ #ifdef USE_ECDSA EC_KEY* ec; #endif int internal_data = 0; if (!k) { return NULL; } pubkey = ldns_rr_new(); switch (ldns_key_algorithm(k)) { case LDNS_SIGN_HMACMD5: case LDNS_SIGN_HMACSHA1: case LDNS_SIGN_HMACSHA224: case LDNS_SIGN_HMACSHA256: case LDNS_SIGN_HMACSHA384: case LDNS_SIGN_HMACSHA512: ldns_rr_set_type(pubkey, LDNS_RR_TYPE_KEY); break; default: ldns_rr_set_type(pubkey, LDNS_RR_TYPE_DNSKEY); break; } /* zero-th rdf - flags */ ldns_rr_push_rdf(pubkey, ldns_native2rdf_int16(LDNS_RDF_TYPE_INT16, ldns_key_flags(k))); /* first - proto */ ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, LDNS_DNSSEC_KEYPROTO)); if (ldns_key_pubkey_owner(k)) { ldns_rr_set_owner(pubkey, ldns_rdf_clone(ldns_key_pubkey_owner(k))); } /* third - da algorithm */ switch(ldns_key_algorithm(k)) { case LDNS_SIGN_RSAMD5: case LDNS_SIGN_RSASHA1: case LDNS_SIGN_RSASHA1_NSEC3: case LDNS_SIGN_RSASHA256: case LDNS_SIGN_RSASHA512: ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); #ifdef HAVE_SSL rsa = ldns_key_rsa_key(k); if (rsa) { bin = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN); if (!bin) { ldns_rr_free(pubkey); return NULL; } if (!ldns_key_rsa2bin(bin, rsa, &size)) { LDNS_FREE(bin); ldns_rr_free(pubkey); return NULL; } RSA_free(rsa); internal_data = 1; } #endif size++; break; #ifdef USE_DSA case LDNS_SIGN_DSA: ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_DSA)); #ifdef HAVE_SSL dsa = ldns_key_dsa_key(k); if (dsa) { bin = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN); if (!bin) { ldns_rr_free(pubkey); return NULL; } if (!ldns_key_dsa2bin(bin, dsa, &size)) { LDNS_FREE(bin); ldns_rr_free(pubkey); return NULL; } DSA_free(dsa); internal_data = 1; } #endif /* HAVE_SSL */ #endif /* USE_DSA */ break; #ifdef USE_DSA case LDNS_SIGN_DSA_NSEC3: ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_DSA_NSEC3)); #ifdef HAVE_SSL dsa = ldns_key_dsa_key(k); if (dsa) { bin = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN); if (!bin) { ldns_rr_free(pubkey); return NULL; } if (!ldns_key_dsa2bin(bin, dsa, &size)) { LDNS_FREE(bin); ldns_rr_free(pubkey); return NULL; } DSA_free(dsa); internal_data = 1; } #endif /* HAVE_SSL */ #endif /* USE_DSA */ break; case LDNS_SIGN_ECC_GOST: ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8( LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); #if defined(HAVE_SSL) && defined(USE_GOST) bin = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN); if (!bin) { ldns_rr_free(pubkey); return NULL; } #ifndef S_SPLINT_S if (!ldns_key_gost2bin(bin, k->_key.key, &size)) { LDNS_FREE(bin); ldns_rr_free(pubkey); return NULL; } #endif /* splint */ internal_data = 1; #else ldns_rr_free(pubkey); return NULL; #endif /* HAVE_SSL and USE_GOST */ break; case LDNS_SIGN_ECDSAP256SHA256: case LDNS_SIGN_ECDSAP384SHA384: #ifdef USE_ECDSA ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8( LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); bin = NULL; #ifndef S_SPLINT_S ec = EVP_PKEY_get1_EC_KEY(k->_key.key); #endif EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED); size = (uint16_t)i2o_ECPublicKey(ec, NULL); if(!i2o_ECPublicKey(ec, &bin)) { EC_KEY_free(ec); ldns_rr_free(pubkey); return NULL; } if(size > 1) { /* move back one byte to shave off the 0x02 * 'uncompressed' indicator that openssl made * Actually its 0x04 (from implementation). */ assert(bin[0] == POINT_CONVERSION_UNCOMPRESSED); size -= 1; memmove(bin, bin+1, size); } /* down the reference count for ec, its still assigned * to the pkey */ EC_KEY_free(ec); internal_data = 1; #else ldns_rr_free(pubkey); return NULL; #endif /* ECDSA */ break; #ifdef USE_ED25519 case LDNS_SIGN_ED25519: ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8( LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); bin = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN); if (!bin) { ldns_rr_free(pubkey); return NULL; } if (!ldns_key_ed255192bin(bin, k->_key.key, &size)) { LDNS_FREE(bin); ldns_rr_free(pubkey); return NULL; } internal_data = 1; break; #endif #ifdef USE_ED448 case LDNS_SIGN_ED448: ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8( LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); bin = LDNS_XMALLOC(unsigned char, LDNS_MAX_KEYLEN); if (!bin) { ldns_rr_free(pubkey); return NULL; } if (!ldns_key_ed4482bin(bin, k->_key.key, &size)) { LDNS_FREE(bin); ldns_rr_free(pubkey); return NULL; } internal_data = 1; break; #endif case LDNS_SIGN_HMACMD5: case LDNS_SIGN_HMACSHA1: case LDNS_SIGN_HMACSHA224: case LDNS_SIGN_HMACSHA256: case LDNS_SIGN_HMACSHA384: case LDNS_SIGN_HMACSHA512: bin = LDNS_XMALLOC(unsigned char, ldns_key_hmac_size(k)); if (!bin) { ldns_rr_free(pubkey); return NULL; } ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); size = ldns_key_hmac_size(k); memcpy(bin, ldns_key_hmac_key(k), size); internal_data = 1; break; } /* fourth the key bin material */ if (internal_data) { keybin = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, size, bin); LDNS_FREE(bin); ldns_rr_push_rdf(pubkey, keybin); } return pubkey; } void ldns_key_free(ldns_key *key) { LDNS_FREE(key); } void ldns_key_deep_free(ldns_key *key) { unsigned char* hmac; if (ldns_key_pubkey_owner(key)) { ldns_rdf_deep_free(ldns_key_pubkey_owner(key)); } #ifdef HAVE_SSL if (ldns_key_evp_key(key)) { EVP_PKEY_free(ldns_key_evp_key(key)); } #endif /* HAVE_SSL */ if (ldns_key_hmac_key(key)) { hmac = ldns_key_hmac_key(key); LDNS_FREE(hmac); } LDNS_FREE(key); } void ldns_key_list_free(ldns_key_list *key_list) { size_t i; for (i = 0; i < ldns_key_list_key_count(key_list); i++) { ldns_key_deep_free(ldns_key_list_key(key_list, i)); } LDNS_FREE(key_list->_keys); LDNS_FREE(key_list); } ldns_rr * ldns_read_anchor_file(const char *filename) { FILE *fp; /*char line[LDNS_MAX_PACKETLEN];*/ char *line = LDNS_XMALLOC(char, LDNS_MAX_PACKETLEN); int c; size_t i = 0; ldns_rr *r; ldns_status status; if(!line) { return NULL; } fp = fopen(filename, "r"); if (!fp) { #ifdef STDERR_MSGS fprintf(stderr, "Unable to open %s: %s\n", filename, strerror(errno)); #endif LDNS_FREE(line); return NULL; } while ((c = fgetc(fp)) && i+1 < LDNS_MAX_PACKETLEN && c != EOF) { line[i] = c; i++; } line[i] = '\0'; fclose(fp); if (i <= 0) { #ifdef STDERR_MSGS fprintf(stderr, "nothing read from %s", filename); #endif LDNS_FREE(line); return NULL; } else { status = ldns_rr_new_frm_str(&r, line, 0, NULL, NULL); if (status == LDNS_STATUS_OK && (ldns_rr_get_type(r) == LDNS_RR_TYPE_DNSKEY || ldns_rr_get_type(r) == LDNS_RR_TYPE_DS)) { LDNS_FREE(line); return r; } else { #ifdef STDERR_MSGS fprintf(stderr, "Error creating DNSKEY or DS rr from %s: %s\n", filename, ldns_get_errorstr_by_id(status)); #endif LDNS_FREE(line); return NULL; } } } char * ldns_key_get_file_base_name(const ldns_key *key) { ldns_buffer *buffer; char *file_base_name; buffer = ldns_buffer_new(255); ldns_buffer_printf(buffer, "K"); (void)ldns_rdf2buffer_str_dname(buffer, ldns_key_pubkey_owner(key)); ldns_buffer_printf(buffer, "+%03u+%05u", ldns_key_algorithm(key), ldns_key_keytag(key)); file_base_name = ldns_buffer_export(buffer); ldns_buffer_free(buffer); return file_base_name; } int ldns_key_algo_supported(int algo) { ldns_lookup_table *lt = ldns_signing_algorithms; while(lt->name) { if(lt->id == algo) return 1; lt++; } return 0; } ldns_signing_algorithm ldns_get_signing_algorithm_by_name(const char* name) { /* list of (signing algorithm id, alias_name) */ ldns_lookup_table aliases[] = { /* from bind dnssec-keygen */ {LDNS_SIGN_HMACMD5, "HMAC-MD5"}, #ifdef USE_DSA {LDNS_SIGN_DSA_NSEC3, "NSEC3DSA"}, #endif /* USE_DSA */ {LDNS_SIGN_RSASHA1_NSEC3, "NSEC3RSASHA1"}, /* old ldns usage, now RFC names */ #ifdef USE_DSA {LDNS_SIGN_DSA_NSEC3, "DSA_NSEC3" }, #endif {LDNS_SIGN_RSASHA1_NSEC3, "RSASHA1_NSEC3" }, #ifdef USE_GOST {LDNS_SIGN_ECC_GOST, "GOST"}, #endif /* compat with possible output */ {LDNS_DH, "DH"}, {LDNS_ECC, "ECC"}, {LDNS_INDIRECT, "INDIRECT"}, {LDNS_PRIVATEDNS, "PRIVATEDNS"}, {LDNS_PRIVATEOID, "PRIVATEOID"}, {0, NULL}}; ldns_lookup_table* lt = ldns_signing_algorithms; ldns_signing_algorithm a; char *endptr; while(lt->name) { if(strcasecmp(lt->name, name) == 0) return lt->id; lt++; } lt = aliases; while(lt->name) { if(strcasecmp(lt->name, name) == 0) return lt->id; lt++; } a = strtol(name, &endptr, 10); if (*name && !*endptr) return a; return 0; } ldns-1.9.2/install-sh0000755000175000017500000003577615212267521014060 0ustar willemwillem#!/bin/sh # install - install a program, script, or datafile scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 # Create dirs (including intermediate dirs) using mode 755. # This is like GNU 'install' as of coreutils 8.32 (2020). mkdir_umask=22 backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -p pass -p to $cpprog. -s $stripprog installed files. -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG By default, rm is invoked with -f; when overridden with RMPROG, it's up to you to specify -f if you want it. If -S is not specified, no backups are attempted. Email bug reports to bug-automake@gnu.org. Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; -S) backupsuffix="$2" shift;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? # Don't chown directories that already exist. if test $dstdir_status = 0; then chowncmd="" fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false # The $RANDOM variable is not portable (e.g., dash). Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap ' ret=$? rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null exit $ret ' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p'. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && { test -z "$stripcmd" || { # Create $dsttmp read-write so that cp doesn't create it read-only, # which would cause strip to fail. if test -z "$doit"; then : >"$dsttmp" # No need to fork-exec 'touch'. else $doit touch "$dsttmp" fi } } && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # If $backupsuffix is set, and the file being installed # already exists, attempt a backup. Don't worry if it fails, # e.g., if mv doesn't support -f. if test -n "$backupsuffix" && test -f "$dst"; then $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null fi # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: ldns-1.9.2/packaging/0000775000175000017500000000000015212267520013757 5ustar willemwillemldns-1.9.2/packaging/ldns-config.10000664000175000017500000000200615212267520016242 0ustar willemwillem.TH ldns-config 1 "22 Sep 2011" .SH NAME ldns-config \- show compiler and linker flags for ldns usage. .SH SYNOPSIS .B ldns-config [ .IR OPTIONS ] .SH DESCRIPTION When writing programs using ldns, you have to tell the compiler where to look for include files and what libraries from which location to link to. \fBldns-config\fR can be used to find out what flags to use with the C compiler and the linker. .SH OPTIONS .TP \fB--cflags\fR Show the C compiler flags needed to compile with ldns .TP \fB--libs\fR Show the flags to be used to link with ldns .TP \fB--version\fR Shows the ldns version of the installed ldns library .TP \fB--libversion\fR Shows version of the binary api of the installed ldns library .TP \fB--help\fR Show \fBldns-config\fR usage description .SH AUTHOR Written by the ldns team. .SH REPORTING BUGS Report bugs to . .SH COPYRIGHT Copyright (C) 2011 NLnet Labs. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ldns-1.9.2/packaging/fedora/0000775000175000017500000000000015212267520015217 5ustar willemwillemldns-1.9.2/packaging/fedora/ldns.spec0000664000175000017500000001475415212267520017046 0ustar willemwillem%{?!with_python: %global with_python 1} %if %{with_python} %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} %endif Summary: Lowlevel DNS(SEC) library with API Name: ldns Version: 1.6.13 Release: 1%{?dist} License: BSD Url: http://www.nlnetlabs.nl/%{name}/ Source: http://www.nlnetlabs.nl/downloads/%{%name}/%{name}-%{version}.tar.gz Group: System Environment/Libraries BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: perl, libpcap-devel, openssl-devel , gcc-c++, doxygen, # Only needed for builds from svn snapshot # BuildRequires: libtool, autoconf, automake %if %{with_python} BuildRequires: python-devel, swig %endif %description ldns is a library with the aim to simplify DNS programming in C. All lowlevel DNS/DNSSEC operations are supported. We also define a higher level API which allows a programmer to (for instance) create or sign packets. %package devel Summary: Development package that includes the ldns header files Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel The devel package contains the ldns library and the include files %if %{with_python} %package python Summary: Python extensions for ldns Group: Applications/System Requires: %{name} = %{version}-%{release} %description python Python extensions for ldns %endif %prep %setup -q # To built svn snapshots # rm config.guess config.sub ltmain.sh # aclocal # libtoolize -c # autoreconf %build %configure --disable-rpath --disable-static --with-sha2 --disable-gost \ %if %{with_python} --with-pyldns %endif (cd drill ; %configure --disable-rpath --disable-static --with-sha2 --disable-gost --with-ldns=%{buildroot}/lib/ ) (cd examples ; %configure --disable-rpath --disable-static --with-sha2 --disable-gost --with-ldns=%{buildroot}/lib/ ) make %{?_smp_mflags} ( cd drill ; make %{?_smp_mflags} ) ( cd examples ; make %{?_smp_mflags} ) make %{?_smp_mflags} doc %install rm -rf %{buildroot} make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-doc # don't install another set of man pages from doc/ rm -rf doc/man/ # don't package building script for install-doc in doc section rm doc/doxyparse.pl # remove .la files rm -rf %{buildroot}%{_libdir}/*.la %{buildroot}%{python_sitearch}/*.la (cd drill ; make DESTDIR=%{buildroot} install) (cd examples; make DESTDIR=%{buildroot} install) %clean rm -rf %{buildroot} %files %defattr(-,root,root) %{_libdir}/libldns*so.* %{_bindir}/drill %{_bindir}/ldnsd %{_bindir}/ldns-chaos %{_bindir}/ldns-compare-zones %{_bindir}/ldns-[d-z]* %doc README LICENSE %{_mandir}/*/* %files devel %defattr(-,root,root,-) %{_libdir}/libldns*so %{_bindir}/ldns-config %dir %{_includedir}/ldns %{_includedir}/ldns/*.h %doc doc Changelog README %if %{with_python} %files python %defattr(-,root,root) %{python_sitearch}/* %endif %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %changelog * Thu Sep 22 2011 Paul Wouters - 1.6.11-1 - Updated to 1.6.11 - Cleanup spec for - Python goes into sitearch, not sitelib * Wed Jun 08 2011 Paul Wouters - 1.6.10-1 - Updated to 1.6.10 - commented out build dependencies for svn snapshots * Sun Mar 27 2011 Paul Wouters - 1.6.9-1 - Updated to 1.6.9 * Mon Jan 24 2011 Paul Wouters - 1.6.8-1 - Updated to 1.6.8 * Thu Aug 26 2010 Paul Wouters - 1.6.6-1 - Upgraded to 1.6.6 * Mon Apr 26 2010 Paul Wouters - 1.6.4-4 - Disable a debug line that was added to find the LOC issue that causes unexpected output for automated tools using ldns-read-zone * Thu Feb 11 2010 Paul Wouters - 1.6.4-3 - Applied fix svn 3186 for LOC record parsing * Fri Jan 22 2010 Paul Wouters - 1.6.4-2 - libtool on EL-5 does not take --install as argument * Fri Jan 22 2010 Paul Wouters - 1.6.4-1 - Upgraded to 1.6.4 - Added ldns-python sub package - Patch for installing ldns-python files - Patch for rpath in ldns-python * Sun Aug 16 2009 Paul Wouters - 1.6.1-2 - Bump version, sources file was not updated. * Sun Aug 16 2009 Paul Wouters - 1.6.1-1 -Updated to 1.6.1 * Sat Jul 11 2009 Paul Wouters - 1.6.0-1 - Updated to 1.6.0 * Thu Apr 16 2009 Paul Wouters - 1.5.1-2 - Memory management bug when generating a sha256 key, see: https://bugzilla.redhat.com/show_bug.cgi?id=493953 * Fri Feb 13 2009 Paul Wouters - 1.5.1-1 - Upgrade to 1.5.1 (1.5.0 was a dud release) * Sun Nov 9 2008 Paul Wouters - 1.4.0-2 - libldns.so was missing in files section. * Sun Nov 9 2008 Paul Wouters - 1.4.0-1 - Updated to 1.4.0 - enable SHA2 functionality * Mon Jun 30 2008 Paul Wouters - 1.3.0-1 - Updated to latest release * Thu Nov 29 2007 Paul Wouters - 1.2.2-1 - Upgraded to 1.2.2. * Mon Sep 11 2006 Paul Wouters 1.0.1-4 - Commented out 1.1.0 make targets, put make 1.0.1 targets. * Mon Sep 11 2006 Paul Wouters 1.0.1-3 - Fixed changelog typo in date - Rebuild requested for PT_GNU_HASH support from gcc - Did not upgrade to 1.1.0 due to compile issues on x86_64 * Fri Jan 6 2006 Paul Wouters 1.0.1-1 - Upgraded to 1.0.1. Removed temporary clean hack from spec file. * Sun Dec 18 2005 Paul Wouters 1.0.0-8 - Cannot use make clean because there are no Makefiles. Use hardcoded rm. * Sun Dec 18 2005 Paul Wouters 1.0.0-7 - Patched 'make clean' target to get rid of object files shipped with 1.0.0 * Sun Dec 13 2005 Paul Wouters 1.0.0-6 - added a make clean for 2.3.3 since .o files were left behind upstream, causing failure on ppc platform * Sun Dec 11 2005 Tom "spot" Callaway 1.0.0-5 - minor cleanups * Wed Oct 5 2005 Paul Wouters 0.70_1205 - reworked for svn version * Sun Sep 25 2005 Paul Wouters - 0.70 - Initial version ldns-1.9.2/packaging/ldns-config.in0000775000175000017500000000206015212267520016513 0ustar willemwillem#!/bin/sh prefix="@prefix@" exec_prefix="@exec_prefix@" VERSION="@PACKAGE_VERSION@" CFLAGS="@CFLAGS@" CPPFLAGS="@CPPFLAGS@ @LIBSSL_CPPFLAGS@" LDFLAGS="@LDFLAGS@ @LIBSSL_LDFLAGS@" PYTHON_CPPFLAGS="@PYTHON_CPPFLAGS@" PYTHON_LDFLAGS="@PYTHON_LDFLAGS@" LIBS="@LIBS@ @LIBSSL_LIBS@" LIBDIR="@libdir@" INCLUDEDIR="@includedir@" LIBVERSION="@VERSION_INFO@" for arg in $@ do if [ $arg = "--cflags" ] then echo "-I${INCLUDEDIR}" fi if [ $arg = "--python-cflags" ] then echo "${PYTHON_CPPFLAGS} -I${INCLUDEDIR}" fi if [ $arg = "--libs" ] then echo "${LDFLAGS} -L${LIBDIR} ${LIBS} -lldns" fi if [ $arg = "--python-libs" ] then echo "${LDFLAGS} ${PYTHON_LDFLAGS} -L${LIBDIR} ${LIBS} -lldns" fi if [ $arg = "-h" ] || [ $arg = "--help" ] then echo "Usage: $0 [--cflags] [--python-cflags] [--libs] [--python-libs] [--version]" fi if [ $arg = "--version" ] then echo "${VERSION}" fi if [ $arg = "--libversion" ] then echo "${LIBVERSION}" fi done ldns-1.9.2/packaging/libldns.pc.in0000664000175000017500000000044215212267520016337 0ustar willemwillemprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: ldns Description: Library for DNS programming URL: http://www.nlnetlabs.nl/projects/ldns Version: @PACKAGE_VERSION@ Requires: Libs: -L${libdir} -lldns Libs.private: @LDFLAGS@ Cflags: -I${includedir} ldns-1.9.2/dane.c0000664000175000017500000006104115212267520013110 0ustar willemwillem/* * Verify or create TLS authentication with DANE (RFC6698) * * (c) NLnetLabs 2012-2020 * * See the file LICENSE for the license. * */ #include #ifdef USE_DANE #include #include #include #include #include #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_SSL #include #include #include #endif /* OpenSSL context options. At the moment, disable SSLv2, SSLv3 * and Compression, if available. TLSv1.0 is allowed at the moment. * TLSv1.1 is the first to provide elliptic curves, so it is usually * allowed in a TLS stack. TLSv1.2 is the first to provide authentication * modes of operation, like GCM. The defines below are a moving * target based on OpenSSL library version. Grep is useful to find * the defines: grep -IR SSL_OP_NO_ /usr/include/openssl. */ #ifdef HAVE_SSL # ifdef SSL_OP_NO_SSLv2 const long NoOpenSSLv2 = SSL_OP_NO_SSLv2; # else const long NoOpenSSLv2 = 0L; # endif # ifdef SSL_OP_NO_SSLv3 const long NoOpenSSLv3 = SSL_OP_NO_SSLv3; # else const long NoOpenSSLv3 = 0L; # endif # ifdef SSL_OP_NO_TLSv1 const long NoOpenTLSv1 = SSL_OP_NO_TLSv1; # else const long NoOpenTLSv1 = 0L; # endif # ifdef SSL_OP_NO_DTLSv1 const long NoOpenDTLSv1 = SSL_OP_NO_DTLSv1; # else const long NoOpenDTLSv1 = 0L; # endif # ifdef SSL_OP_NO_COMPRESSION const long NoOpenSSLCompression = SSL_OP_NO_COMPRESSION; # else const long NoOpenSSLCompression = 0L; # endif #endif #if defined(USE_DANE_VERIFY) && defined(USE_DANE_TA_USAGE) static SSL_CTX* ldns_dane_new_ssl_context(void) { SSL_CTX* ssl_ctx; ssl_ctx = SSL_CTX_new(TLS_client_method()); if (ssl_ctx != NULL) { /* ldns allows TLS and DTLS v1.0 at the moment. Some may disagree. * Sometime in the future they may be disabled, too. Maybe * --disable-tlsv1 and --disable-dtlsv1 should be configure options. */ long flags = NoOpenSSLv2 | NoOpenSSLv3 | NoOpenSSLCompression; SSL_CTX_set_options(ssl_ctx, flags); } return ssl_ctx; } #endif ldns_status ldns_dane_create_tlsa_owner(ldns_rdf** tlsa_owner, const ldns_rdf* name, uint16_t port, ldns_dane_transport transport) { char buf[LDNS_MAX_DOMAINLEN]; size_t s; assert(tlsa_owner != NULL); assert(name != NULL); assert(ldns_rdf_get_type(name) == LDNS_RDF_TYPE_DNAME); s = (size_t)snprintf(buf, LDNS_MAX_DOMAINLEN, "X_%d", (int)port); buf[0] = (char)(s - 1); switch(transport) { case LDNS_DANE_TRANSPORT_TCP: s += snprintf(buf + s, LDNS_MAX_DOMAINLEN - s, "\004_tcp"); break; case LDNS_DANE_TRANSPORT_UDP: s += snprintf(buf + s, LDNS_MAX_DOMAINLEN - s, "\004_udp"); break; case LDNS_DANE_TRANSPORT_SCTP: s += snprintf(buf + s, LDNS_MAX_DOMAINLEN - s, "\005_sctp"); break; default: return LDNS_STATUS_DANE_UNKNOWN_TRANSPORT; } if (s + ldns_rdf_size(name) > LDNS_MAX_DOMAINLEN) { return LDNS_STATUS_DOMAINNAME_OVERFLOW; } memcpy(buf + s, ldns_rdf_data(name), ldns_rdf_size(name)); *tlsa_owner = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME, s + ldns_rdf_size(name), buf); if (*tlsa_owner == NULL) { return LDNS_STATUS_MEM_ERR; } return LDNS_STATUS_OK; } #ifdef HAVE_SSL ldns_status ldns_dane_cert2rdf(ldns_rdf** rdf, X509* cert, ldns_tlsa_selector selector, ldns_tlsa_matching_type matching_type) { unsigned char* buf = NULL; size_t len; X509_PUBKEY* xpubkey; EVP_PKEY* epubkey; unsigned char* digest; assert(rdf != NULL); assert(cert != NULL); switch(selector) { case LDNS_TLSA_SELECTOR_FULL_CERTIFICATE: len = (size_t)i2d_X509(cert, &buf); break; case LDNS_TLSA_SELECTOR_SUBJECTPUBLICKEYINFO: #ifndef S_SPLINT_S xpubkey = X509_get_X509_PUBKEY(cert); #endif if (! xpubkey) { return LDNS_STATUS_SSL_ERR; } epubkey = X509_PUBKEY_get(xpubkey); if (! epubkey) { return LDNS_STATUS_SSL_ERR; } len = (size_t)i2d_PUBKEY(epubkey, &buf); break; default: return LDNS_STATUS_DANE_UNKNOWN_SELECTOR; } switch(matching_type) { case LDNS_TLSA_MATCHING_TYPE_NO_HASH_USED: *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, len, buf); return *rdf ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR; break; case LDNS_TLSA_MATCHING_TYPE_SHA256: digest = LDNS_XMALLOC(unsigned char, LDNS_SHA256_DIGEST_LENGTH); if (digest == NULL) { LDNS_FREE(buf); return LDNS_STATUS_MEM_ERR; } (void) ldns_sha256(buf, (unsigned int)len, digest); *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, LDNS_SHA256_DIGEST_LENGTH, digest); LDNS_FREE(buf); return *rdf ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR; break; case LDNS_TLSA_MATCHING_TYPE_SHA512: digest = LDNS_XMALLOC(unsigned char, LDNS_SHA512_DIGEST_LENGTH); if (digest == NULL) { LDNS_FREE(buf); return LDNS_STATUS_MEM_ERR; } (void) ldns_sha512(buf, (unsigned int)len, digest); *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, LDNS_SHA512_DIGEST_LENGTH, digest); LDNS_FREE(buf); return *rdf ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR; break; default: LDNS_FREE(buf); return LDNS_STATUS_DANE_UNKNOWN_MATCHING_TYPE; } } /* Ordinary PKIX validation of cert (with extra_certs to help) * against the CA's in store */ static ldns_status ldns_dane_pkix_validate(X509* cert, STACK_OF(X509)* extra_certs, X509_STORE* store) { X509_STORE_CTX* vrfy_ctx; ldns_status s; if (! store) { return LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE; } vrfy_ctx = X509_STORE_CTX_new(); if (! vrfy_ctx) { return LDNS_STATUS_SSL_ERR; } else if (X509_STORE_CTX_init(vrfy_ctx, store, cert, extra_certs) != 1) { s = LDNS_STATUS_SSL_ERR; } else if (X509_verify_cert(vrfy_ctx) == 1) { s = LDNS_STATUS_OK; } else { s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE; } X509_STORE_CTX_free(vrfy_ctx); return s; } /* Ordinary PKIX validation of cert (with extra_certs to help) * against the CA's in store, but also return the validation chain. */ static ldns_status ldns_dane_pkix_validate_and_get_chain(STACK_OF(X509)** chain, X509* cert, STACK_OF(X509)* extra_certs, X509_STORE* store) { ldns_status s; X509_STORE* empty_store = NULL; X509_STORE_CTX* vrfy_ctx; assert(chain != NULL); if (! store) { store = empty_store = X509_STORE_new(); } s = LDNS_STATUS_SSL_ERR; vrfy_ctx = X509_STORE_CTX_new(); if (! vrfy_ctx) { goto exit_free_empty_store; } else if (X509_STORE_CTX_init(vrfy_ctx, store, cert, extra_certs) != 1) { goto exit_free_vrfy_ctx; } else if (X509_verify_cert(vrfy_ctx) == 1) { s = LDNS_STATUS_OK; } else { s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE; } *chain = X509_STORE_CTX_get1_chain(vrfy_ctx); if (! *chain) { s = LDNS_STATUS_SSL_ERR; } exit_free_vrfy_ctx: X509_STORE_CTX_free(vrfy_ctx); exit_free_empty_store: if (empty_store) { X509_STORE_free(empty_store); } return s; } /* Return the validation chain that can be build out of cert, with extra_certs. */ static ldns_status ldns_dane_pkix_get_chain(STACK_OF(X509)** chain, X509* cert, STACK_OF(X509)* extra_certs) { ldns_status s; X509_STORE* empty_store = NULL; X509_STORE_CTX* vrfy_ctx; assert(chain != NULL); empty_store = X509_STORE_new(); s = LDNS_STATUS_SSL_ERR; vrfy_ctx = X509_STORE_CTX_new(); if (! vrfy_ctx) { goto exit_free_empty_store; } else if (X509_STORE_CTX_init(vrfy_ctx, empty_store, cert, extra_certs) != 1) { goto exit_free_vrfy_ctx; } (void) X509_verify_cert(vrfy_ctx); *chain = X509_STORE_CTX_get1_chain(vrfy_ctx); if (! *chain) { s = LDNS_STATUS_SSL_ERR; } else { s = LDNS_STATUS_OK; } exit_free_vrfy_ctx: X509_STORE_CTX_free(vrfy_ctx); exit_free_empty_store: X509_STORE_free(empty_store); return s; } /* Pop n+1 certs and return the last popped. */ static ldns_status ldns_dane_get_nth_cert_from_validation_chain( X509** cert, STACK_OF(X509)* chain, int n, bool ca) { if (n >= sk_X509_num(chain) || n < 0) { return LDNS_STATUS_DANE_OFFSET_OUT_OF_RANGE; } *cert = sk_X509_pop(chain); while (n-- > 0) { X509_free(*cert); *cert = sk_X509_pop(chain); } if (ca && ! X509_check_ca(*cert)) { return LDNS_STATUS_DANE_NON_CA_CERTIFICATE; } return LDNS_STATUS_OK; } /* Create validation chain with cert and extra_certs and returns the last * self-signed (if present). */ static ldns_status ldns_dane_pkix_get_last_self_signed(X509** out_cert, X509* cert, STACK_OF(X509)* extra_certs) { ldns_status s; X509_STORE* empty_store = NULL; X509_STORE_CTX* vrfy_ctx; assert(out_cert != NULL); empty_store = X509_STORE_new(); s = LDNS_STATUS_SSL_ERR; vrfy_ctx = X509_STORE_CTX_new(); if (! vrfy_ctx) { goto exit_free_empty_store; } else if (X509_STORE_CTX_init(vrfy_ctx, empty_store, cert, extra_certs) != 1) { goto exit_free_vrfy_ctx; } (void) X509_verify_cert(vrfy_ctx); if (X509_STORE_CTX_get_error(vrfy_ctx) == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN || X509_STORE_CTX_get_error(vrfy_ctx) == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT){ *out_cert = X509_STORE_CTX_get_current_cert( vrfy_ctx); s = LDNS_STATUS_OK; } else { s = LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR; } exit_free_vrfy_ctx: X509_STORE_CTX_free(vrfy_ctx); exit_free_empty_store: X509_STORE_free(empty_store); return s; } ldns_status ldns_dane_select_certificate(X509** selected_cert, X509* cert, STACK_OF(X509)* extra_certs, X509_STORE* pkix_validation_store, ldns_tlsa_certificate_usage cert_usage, int offset) { ldns_status s; STACK_OF(X509)* pkix_validation_chain = NULL; assert(selected_cert != NULL); assert(cert != NULL); /* With PKIX validation explicitly turned off (pkix_validation_store * == NULL), treat the "CA constraint" and "Service certificate * constraint" the same as "Trust anchor assertion" and "Domain issued * certificate" respectively. */ if (pkix_validation_store == NULL) { switch (cert_usage) { case LDNS_TLSA_USAGE_CA_CONSTRAINT: cert_usage = LDNS_TLSA_USAGE_TRUST_ANCHOR_ASSERTION; break; case LDNS_TLSA_USAGE_SERVICE_CERTIFICATE_CONSTRAINT: cert_usage = LDNS_TLSA_USAGE_DOMAIN_ISSUED_CERTIFICATE; break; default: break; } } /* Now what to do with each Certificate usage... */ switch (cert_usage) { case LDNS_TLSA_USAGE_CA_CONSTRAINT: s = ldns_dane_pkix_validate_and_get_chain( &pkix_validation_chain, cert, extra_certs, pkix_validation_store); if (! pkix_validation_chain) { return s; } if (s == LDNS_STATUS_OK) { if (offset == -1) { offset = 0; } s = ldns_dane_get_nth_cert_from_validation_chain( selected_cert, pkix_validation_chain, offset, true); } sk_X509_pop_free(pkix_validation_chain, X509_free); return s; break; case LDNS_TLSA_USAGE_SERVICE_CERTIFICATE_CONSTRAINT: *selected_cert = cert; return ldns_dane_pkix_validate(cert, extra_certs, pkix_validation_store); break; case LDNS_TLSA_USAGE_TRUST_ANCHOR_ASSERTION: if (offset == -1) { s = ldns_dane_pkix_get_last_self_signed( selected_cert, cert, extra_certs); return s; } else { s = ldns_dane_pkix_get_chain( &pkix_validation_chain, cert, extra_certs); if (s == LDNS_STATUS_OK) { s = ldns_dane_get_nth_cert_from_validation_chain( selected_cert, pkix_validation_chain, offset, false); } else if (! pkix_validation_chain) { return s; } sk_X509_pop_free(pkix_validation_chain, X509_free); return s; } break; case LDNS_TLSA_USAGE_DOMAIN_ISSUED_CERTIFICATE: *selected_cert = cert; return LDNS_STATUS_OK; break; default: return LDNS_STATUS_DANE_UNKNOWN_CERTIFICATE_USAGE; break; } } ldns_status ldns_dane_create_tlsa_rr(ldns_rr** tlsa, ldns_tlsa_certificate_usage certificate_usage, ldns_tlsa_selector selector, ldns_tlsa_matching_type matching_type, X509* cert) { ldns_rdf* rdf; ldns_status s; assert(tlsa != NULL); assert(cert != NULL); /* create rr */ *tlsa = ldns_rr_new_frm_type(LDNS_RR_TYPE_TLSA); if (*tlsa == NULL) { return LDNS_STATUS_MEM_ERR; } rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, (uint8_t)certificate_usage); if (rdf == NULL) { goto memerror; } (void) ldns_rr_set_rdf(*tlsa, rdf, 0); rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, (uint8_t)selector); if (rdf == NULL) { goto memerror; } (void) ldns_rr_set_rdf(*tlsa, rdf, 1); rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, (uint8_t)matching_type); if (rdf == NULL) { goto memerror; } (void) ldns_rr_set_rdf(*tlsa, rdf, 2); s = ldns_dane_cert2rdf(&rdf, cert, selector, matching_type); if (s == LDNS_STATUS_OK) { (void) ldns_rr_set_rdf(*tlsa, rdf, 3); return LDNS_STATUS_OK; } ldns_rr_free(*tlsa); *tlsa = NULL; return s; memerror: ldns_rr_free(*tlsa); *tlsa = NULL; return LDNS_STATUS_MEM_ERR; } #ifdef USE_DANE_VERIFY /* Return tlsas that actually are TLSA resource records with known values * for the Certificate usage, Selector and Matching type rdata fields. */ static ldns_rr_list* ldns_dane_filter_unusable_records(const ldns_rr_list* tlsas) { size_t i; ldns_rr_list* r = ldns_rr_list_new(); ldns_rr* tlsa_rr; if (! r) { return NULL; } for (i = 0; i < ldns_rr_list_rr_count(tlsas); i++) { tlsa_rr = ldns_rr_list_rr(tlsas, i); if (ldns_rr_get_type(tlsa_rr) == LDNS_RR_TYPE_TLSA && ldns_rr_rd_count(tlsa_rr) == 4 && ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 0)) <= 3 && ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 1)) <= 1 && ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 2)) <= 2) { if (! ldns_rr_list_push_rr(r, tlsa_rr)) { ldns_rr_list_free(r); return NULL; } } } return r; } #if !defined(USE_DANE_TA_USAGE) /* Return whether cert/selector/matching_type matches data. */ static ldns_status ldns_dane_match_cert_with_data(X509* cert, ldns_tlsa_selector selector, ldns_tlsa_matching_type matching_type, ldns_rdf* data) { ldns_status s; ldns_rdf* match_data; s = ldns_dane_cert2rdf(&match_data, cert, selector, matching_type); if (s == LDNS_STATUS_OK) { if (ldns_rdf_compare(data, match_data) != 0) { s = LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH; } ldns_rdf_free(match_data); } return s; } /* Return whether any certificate from the chain with selector/matching_type * matches data. * ca should be true if the certificate has to be a CA certificate too. */ static ldns_status ldns_dane_match_any_cert_with_data(STACK_OF(X509)* chain, ldns_tlsa_selector selector, ldns_tlsa_matching_type matching_type, ldns_rdf* data, bool ca) { ldns_status s = LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH; int n, i; X509* cert; n = sk_X509_num(chain); for (i = 0; i < n; i++) { cert = sk_X509_pop(chain); if (! cert) { s = LDNS_STATUS_SSL_ERR; break; } s = ldns_dane_match_cert_with_data(cert, selector, matching_type, data); if (ca && s == LDNS_STATUS_OK && ! X509_check_ca(cert)) { s = LDNS_STATUS_DANE_NON_CA_CERTIFICATE; } X509_free(cert); if (s != LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH) { break; } /* when s == LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH, * try to match the next certificate */ } return s; } #endif /* !defined(USE_DANE_TA_USAGE) */ #endif /* USE_DANE_VERIFY */ #ifdef USE_DANE_VERIFY ldns_status ldns_dane_verify_rr(const ldns_rr* tlsa_rr, X509* cert, STACK_OF(X509)* extra_certs, X509_STORE* pkix_validation_store) { #if defined(USE_DANE_TA_USAGE) SSL_CTX *ssl_ctx = NULL; SSL *ssl = NULL; X509_STORE_CTX *store_ctx = NULL; #else STACK_OF(X509)* pkix_validation_chain = NULL; #endif ldns_status s = LDNS_STATUS_OK; ldns_tlsa_certificate_usage usage; ldns_tlsa_selector selector; ldns_tlsa_matching_type mtype; ldns_rdf* data; if (! tlsa_rr || ldns_rr_get_type(tlsa_rr) != LDNS_RR_TYPE_TLSA || ldns_rr_rd_count(tlsa_rr) != 4 || ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 0)) > 3 || ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 1)) > 1 || ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 2)) > 2 ) { /* No (usable) TLSA, so regular PKIX validation */ return ldns_dane_pkix_validate(cert, extra_certs, pkix_validation_store); } usage = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 0)); selector = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 1)); mtype = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 2)); data = ldns_rr_rdf(tlsa_rr, 3) ; #if defined(USE_DANE_TA_USAGE) /* Rely on OpenSSL dane functions. * * OpenSSL does not provide offline dane verification. The dane unit * tests within openssl use the undocumented SSL_get0_dane() and * X509_STORE_CTX_set0_dane() to convey dane parameters set on SSL and * SSL_CTX to a X509_STORE_CTX that can be used to do offline * verification. We use these undocumented means with the ldns * dane function prototypes which did only offline dane verification. */ if (!(ssl_ctx = ldns_dane_new_ssl_context())) s = LDNS_STATUS_MEM_ERR; else if (SSL_CTX_dane_enable(ssl_ctx) <= 0) s = LDNS_STATUS_SSL_ERR; else if (SSL_CTX_dane_set_flags( ssl_ctx, DANE_FLAG_NO_DANE_EE_NAMECHECKS), !(ssl = SSL_new(ssl_ctx))) s = LDNS_STATUS_MEM_ERR; else if (SSL_set_connect_state(ssl), (SSL_dane_enable(ssl, NULL) <= 0)) s = LDNS_STATUS_SSL_ERR; else if (SSL_dane_tlsa_add(ssl, usage, selector, mtype, ldns_rdf_data(data), ldns_rdf_size(data)) <= 0) s = LDNS_STATUS_SSL_ERR; else if (!(store_ctx = X509_STORE_CTX_new())) s = LDNS_STATUS_MEM_ERR; else if (!X509_STORE_CTX_init(store_ctx, pkix_validation_store, cert, extra_certs)) s = LDNS_STATUS_SSL_ERR; else { int ret; X509_STORE_CTX_set_default(store_ctx, SSL_is_server(ssl) ? "ssl_client" : "ssl_server"); X509_VERIFY_PARAM_set1(X509_STORE_CTX_get0_param(store_ctx), SSL_get0_param(ssl)); X509_STORE_CTX_set0_dane(store_ctx, SSL_get0_dane(ssl)); if (SSL_get_verify_callback(ssl)) X509_STORE_CTX_set_verify_cb(store_ctx, SSL_get_verify_callback(ssl)); ret = X509_verify_cert(store_ctx); if (!ret) { if (X509_STORE_CTX_get_error(store_ctx) == X509_V_ERR_DANE_NO_MATCH) s = LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH; else s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE; } X509_STORE_CTX_cleanup(store_ctx); } if (store_ctx) X509_STORE_CTX_free(store_ctx); if (ssl) SSL_free(ssl); if (ssl_ctx) SSL_CTX_free(ssl_ctx); return s; #else switch (usage) { case LDNS_TLSA_USAGE_CA_CONSTRAINT: s = ldns_dane_pkix_validate_and_get_chain( &pkix_validation_chain, cert, extra_certs, pkix_validation_store); if (! pkix_validation_chain) { return s; } if (s == LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE) { /* * NO PKIX validation. We still try to match *any* * certificate from the chain, so we return * TLSA errors over PKIX errors. * * i.e. When the TLSA matches no certificate, we return * TLSA_DID_NOT_MATCH and not PKIX_DID_NOT_VALIDATE */ s = ldns_dane_match_any_cert_with_data( pkix_validation_chain, selector, mtype, data, true); if (s == LDNS_STATUS_OK) { /* A TLSA record did match a cert from the * chain, thus the error is failed PKIX * validation. */ s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE; } } else if (s == LDNS_STATUS_OK) { /* PKIX validated, does the TLSA match too? */ s = ldns_dane_match_any_cert_with_data( pkix_validation_chain, selector, mtype, data, true); } sk_X509_pop_free(pkix_validation_chain, X509_free); return s; break; case LDNS_TLSA_USAGE_SERVICE_CERTIFICATE_CONSTRAINT: s = ldns_dane_match_cert_with_data(cert, selector, mtype, data); if (s == LDNS_STATUS_OK) { return ldns_dane_pkix_validate(cert, extra_certs, pkix_validation_store); } return s; break; case LDNS_TLSA_USAGE_TRUST_ANCHOR_ASSERTION: #if 0 s = ldns_dane_pkix_get_chain(&pkix_validation_chain, cert, extra_certs); if (s == LDNS_STATUS_OK) { s = ldns_dane_match_any_cert_with_data( pkix_validation_chain, selector, mtype, data, false); } else if (! pkix_validation_chain) { return s; } sk_X509_pop_free(pkix_validation_chain, X509_free); return s; #else return LDNS_STATUS_DANE_NEED_OPENSSL_GE_1_1_FOR_DANE_TA; #endif break; case LDNS_TLSA_USAGE_DOMAIN_ISSUED_CERTIFICATE: return ldns_dane_match_cert_with_data(cert, selector, mtype, data); break; default: break; } #endif return LDNS_STATUS_DANE_UNKNOWN_CERTIFICATE_USAGE; } ldns_status ldns_dane_verify(const ldns_rr_list* tlsas, X509* cert, STACK_OF(X509)* extra_certs, X509_STORE* pkix_validation_store) { #if defined(USE_DANE_TA_USAGE) SSL_CTX *ssl_ctx = NULL; ldns_rdf *basename_rdf = NULL; char *basename = NULL; SSL *ssl = NULL; X509_STORE_CTX *store_ctx = NULL; #else ldns_status ps; #endif size_t i; ldns_rr* tlsa_rr; ldns_rr_list *usable_tlsas; ldns_status s = LDNS_STATUS_OK; assert(cert != NULL); if (! tlsas || ldns_rr_list_rr_count(tlsas) == 0) /* No TLSA's, so regular PKIX validation */ return ldns_dane_pkix_validate(cert, extra_certs, pkix_validation_store); /* To enable name checks (which we don't) */ #if defined(USE_DANE_TA_USAGE) && 0 else if (!(basename_rdf = ldns_dname_clone_from( ldns_rr_list_owner(tlsas), 2))) /* Could nog get DANE base name */ s = LDNS_STATUS_ERR; else if (!(basename = ldns_rdf2str(basename_rdf))) s = LDNS_STATUS_MEM_ERR; else if (strlen(basename) && (basename[strlen(basename)-1] = 0)) s = LDNS_STATUS_ERR; /* Intended to be unreachable */ #endif else if (!(usable_tlsas = ldns_dane_filter_unusable_records(tlsas))) return LDNS_STATUS_MEM_ERR; else if (ldns_rr_list_rr_count(usable_tlsas) == 0) { /* No TLSA's, so regular PKIX validation */ ldns_rr_list_free(usable_tlsas); return ldns_dane_pkix_validate(cert, extra_certs, pkix_validation_store); } #if defined(USE_DANE_TA_USAGE) /* Rely on OpenSSL dane functions. * * OpenSSL does not provide offline dane verification. The dane unit * tests within openssl use the undocumented SSL_get0_dane() and * X509_STORE_CTX_set0_dane() to convey dane parameters set on SSL and * SSL_CTX to a X509_STORE_CTX that can be used to do offline * verification. We use these undocumented means with the ldns * dane function prototypes which did only offline dane verification. */ if (!(ssl_ctx = ldns_dane_new_ssl_context())) s = LDNS_STATUS_MEM_ERR; else if (SSL_CTX_dane_enable(ssl_ctx) <= 0) s = LDNS_STATUS_SSL_ERR; else if (SSL_CTX_dane_set_flags( ssl_ctx, DANE_FLAG_NO_DANE_EE_NAMECHECKS), !(ssl = SSL_new(ssl_ctx))) s = LDNS_STATUS_MEM_ERR; else if (SSL_set_connect_state(ssl), (SSL_dane_enable(ssl, basename) <= 0)) s = LDNS_STATUS_SSL_ERR; else for (i = 0; i < ldns_rr_list_rr_count(usable_tlsas); i++) { ldns_tlsa_certificate_usage usage; ldns_tlsa_selector selector; ldns_tlsa_matching_type mtype; ldns_rdf* data; tlsa_rr = ldns_rr_list_rr(usable_tlsas, i); usage = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr,0)); selector= ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr,1)); mtype = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr,2)); data = ldns_rr_rdf(tlsa_rr,3) ; if (SSL_dane_tlsa_add(ssl, usage, selector, mtype, ldns_rdf_data(data), ldns_rdf_size(data)) <= 0) { s = LDNS_STATUS_SSL_ERR; break; } } if (!s && !(store_ctx = X509_STORE_CTX_new())) s = LDNS_STATUS_MEM_ERR; else if (!X509_STORE_CTX_init(store_ctx, pkix_validation_store, cert, extra_certs)) s = LDNS_STATUS_SSL_ERR; else { int ret; X509_STORE_CTX_set_default(store_ctx, SSL_is_server(ssl) ? "ssl_client" : "ssl_server"); X509_VERIFY_PARAM_set1(X509_STORE_CTX_get0_param(store_ctx), SSL_get0_param(ssl)); X509_STORE_CTX_set0_dane(store_ctx, SSL_get0_dane(ssl)); if (SSL_get_verify_callback(ssl)) X509_STORE_CTX_set_verify_cb(store_ctx, SSL_get_verify_callback(ssl)); ret = X509_verify_cert(store_ctx); if (!ret) { if (X509_STORE_CTX_get_error(store_ctx) == X509_V_ERR_DANE_NO_MATCH) s = LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH; else s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE; } X509_STORE_CTX_cleanup(store_ctx); } if (store_ctx) X509_STORE_CTX_free(store_ctx); if (ssl) SSL_free(ssl); if (ssl_ctx) SSL_CTX_free(ssl_ctx); if (basename) free(basename); ldns_rdf_deep_free(basename_rdf); #else for (i = 0; i < ldns_rr_list_rr_count(usable_tlsas); i++) { tlsa_rr = ldns_rr_list_rr(usable_tlsas, i); ps = s; s = ldns_dane_verify_rr(tlsa_rr, cert, extra_certs, pkix_validation_store); if (s != LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH && s != LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE && s != LDNS_STATUS_DANE_NEED_OPENSSL_GE_1_1_FOR_DANE_TA) { /* which would be LDNS_STATUS_OK (match) * or some fatal error preventing use from * trying the next TLSA record. */ break; } s = (s > ps ? s : ps); /* pref NEED_OPENSSL_GE_1_1_FOR_DANE_TA * over PKIX_DID_NOT_VALIDATE * over TLSA_DID_NOT_MATCH */ } #endif ldns_rr_list_free(usable_tlsas); return s; } #endif /* USE_DANE_VERIFY */ #endif /* HAVE_SSL */ #endif /* USE_DANE */ ldns-1.9.2/Changelog0000664000175000017500000015361315212267520013656 0ustar willemwillem1.9.2 2026-06-10 * Fix to set VERSION_INFO to create .so.3 instead of .so.11 which will be reserved for a future 1.10.0 release 1.9.1 2026-06-10 * Bugfix: Insufficient verification that responses belong to a query (CVE-2026-10846). Thanks Pablo Ruiz from 'codecome.ai' 1.9.0 2025-12-04 * PR #246: Make ldns_calc_keytag() available for CDNSKEY RR Thanks tgreenx and pnax * PR #247: Make ldns_key_rr2ds() available for CDNSKEY RR Thanks tgreenx * PR #248: Make ldns_rr_compare_{ds,ds_dnskey}() available for CDS and CDNSKEY RRs. Thanks tgreenx * PR #245: Make drill trace use IPv6 when used with -6 Thanks Paul Radford * Fix #254: Unquoted "value" rdata for CAA records fail to validate. Follows the long string unquoted syntax from RFC8659, section 4.1.1. * Fix #266: ldns-read-zone -u fails if a type is the only type in a window and the type modulo 256 is equal to zero. * Fix #271: Intermittent build failure with multi-job builds (make -j). * Add ldns-verify-zone -s option. It checks all signature results, instead of passing by when one RRSIG validates. That prints output for spurious RRSIGs, the failures for them. * Fix RR types NSAP-PTR, GPOS and RESINFO to print unquoted strings. * Fix memory leak when trying to read zones that have equal RRs. the ldns_dnssec_*_add_rr() functions now return LDNS_STATUS_EQUAL_RR when an already existing RR is tried to be added. This is a API change, hence this also bumps the version to 1.9.0 * PR #282: ensure returning pkt with LDNS_STATUS_OK. Thanks grobian. * PR #286: Fix RR Type AMTRELAY type nogateway, to print relay '.', and memory leaks in parsing it. * DSYNC is no longer a draft RR type and compiled by default * RFC 9824 support: Compact Denial of Existence in DNSSEC * The HHIT and BRID draft RR types * PR #249: If RNG is already seeded, return early. Thanks crrodriguez * PR #221: Improve error messages. Thanks jschauma * PR #256: Use SWIG_AppendOutput to support swig 4.3 Thanks pemensik * PR #188: Homogenize paths for source files during compilation Thanks duthils * Fix #283: ldns-walk fails after update from 1.8.3 to 1.8.4 Thanks jschauma * PR #200: Allow compiled tests to link to ldns statically via environment variable. Thanks FGasper and pemensik * PR #220: Optionally exclude ZONEMD RRs in ldns-compare-zone Thanks gjherbiet * Fix #285: A WALLET RR breaks TXT signing. Thanks bortzmeyer * Fix #287: ldns-verify-zone hangs with missing NSEC3 RRs. Thanks Roy Arends 1.8.4 2024-07-19 * Fix building documentation in build directory. Thanks Michael Tokarev * Updated the configure script for split openssl directories. * Fix for windows compile; asctime_r compat, search for inet_ntop in ws2_32, avoid double decl of inet_ntop, check for symlink call, include config.h in edns.c, have socket compare use correct signedness, add -u repo option to makewin.sh, fix quoting in makewin.sh and check return value of bind and connect in net.c for failure instead of a socket type. And fix to install .exe files. * Fix to compile with OpenSSL 3.2. Update acx_nlnetlabs.m4 to 48. * Fix to compile DLLs, and pick out of the lib64 dir, and include libssp-0.dll and ldns-config. * bugfix #237: Resolver uses nameserver commented out in /etc/resolv.conf. Thanks grembo. * Added RESINFO rrtype. * Added WALLET rrtype. * PR #241: Fix coverity cited problems. Thanks Enji Cooper. * PR #233: Several Python SWIG issues. Thanks Florian Weimer. * PR #231: const ldns_rdf * typemap fixes to support swig-4.2.0 Thanks William S Fulton * PR #227: keys.c: fix build with libressl >= 3.8.1 Thanks Fabrice Fontaine * PR #224: Portable executable progs don't underlink to libldns Thanks Ørjan Malde * PR #216: Update declaration for function with no argument Thanks Ed Maste * PR #214: fix the build in FreeBSD's base system Thanks Pierre Pronchery and Dag-Erling Smørgrav * PR #206: improve 'next-label' algorithm in ldns-walk Thanks Jelte Jansen * PR #205: Add functions to extract RFC 8914 extended errors Thanks Roland van Rijswijk-Deij * PR #203: Expand CI: Cygwin, BSDs, musl libc, 32-bit, and big-endian Thanks Felipe Gasper * PR #191: 16-unit-tests-edns: Fix leak & warnings Thanks Felipe Gasper * Added NXNAME rrtype. * PR #242: Openssl no engine improved support #242 Thanks Petr Menšík 1.8.3 2022-08-15 * bugfix #183: Assertion failure with OPT record without rdata. This caused packet creation with only a DO bit (for DNSSEC OK) to crash. Thanks Anand Buddhdev and others for reporting this so quickly. * Fix for syntax error in pyldns 1.8.2 2022-08-12 * bugfix #147: Allow for tabs in whitespace before quoted rdata fields. Thanks Felipe Gasper * bugfix #149: Add some missing [out] annotations to doxygen parameters. Thanks aldot. * Fix build error on Solaris 10 with inet_ntop redeclaration error. * Fix -U flag with ldns-signzone. Thanks Ulrich and Jonathan * Enable compile of SVCB and HTTPS support by default. * bugfix #179: Free line memory even if zone file parsing fails Thanks Claudius Zingerli * bugfix #166: Grow buffer when writing chars and fixed size strings when converting to presentation format, preventing potential assersion errors. * bugfix #46: Print network errors when secure tracing. Thanks reedjc * EDNS0 Option handling and conversion into presentation format. * bugfix #145: ldns-verify-zone should not call occluded records glue. Thanks Habbie 1.8.1 2021-12-03 * bugfix #146: ldns-1.7.1 had soname 3.0, so ldns-1.8.x soname needs to larger. Thanks Leah Neukirchen & Felipe Gasper * Undo PR#123 fix ldns.pc installation when building out-of-source Thanks Axel Xu 1.8.0 2021-11-26 * bugfix #38: Print "line" before line number when printing zone parse errors. Thanks Petr Špaček. * bugfix: Revert unused variables in ldns-config removal patch. * bugfix #50: heap Out-of-bound Read vulnerability in rr_frm_str_internal reported by pokerfacett. * bugfix #51: Heap Out-of-bound Read vulnerability in ldns_nsec3_salt_data reported by pokerfacett. * Fix memory leak in examples/ldns-testns handle_tcp routine. * Detect fixed time memory compare for openssl 0.9.8. * Fix compile warning by variable initialisation for older gcc. * Fix #92: ldns-testns.c:429:15: error: 'fork' is unavailable: not available on tvOS. * Fix for #93: fix packaging/libldns.pc Makefile rule. * ZONEMD support in ldns-signzone and ldns-verify-zone * ldns-testns can answer several queries over one tcp connection, if they arrive within 100msec of each other. * Fix so that ldns-testns does not leak sockets if the read fails. * SVCB and HTTPS draft rrtypes. Enable with --enable-rrtype-svcb-https. * bugfix #117: Assertion failure with DNSSEC validating of non existence of RR types at the root. Thanks ZjYwMj * Set NSEC(3) ttls to the minimum of the MINIMUM field of the SOA record and the TTL of the SOA itself. draft-ietf-dnsop-nsec-ttl * bugfix #119: Let example tools read longer RR's than LDNS_MAX_LINELEN * Add SVCPARAMS to python ldns_rdf_type2str function. * PR #134 Miscellaneous spelling fixes. Thanks jsoref! * Fix that ldns-read-zone and ldns_zone_new_frm_fp_l properly return the $INCLUDE not implemented error. * Fix that ldns-read-zone and ldns_zone_new_frm_fp_l count the line number for an empty line after a comment. * Fix #135: Fix compile with OpenSSL-3.0.0-beta2. * PR #107: Added ldns_pkt2buffer_wire_compress() to make dname compression optional when converting packets to wire format. Thanks Eli Lindsey * Option to ldns-keygen to create symlinks with known names (i.e. without the key id) to the created files. Thanks Andreas Schulze * Fix #121: Correct handling of centimetres by LOC parser. Thanks Felipe Gasper * PR #126: Link with libldns.la in Makefile.in. Thanks orbea * PR #127: Added option -Q to drill to give short answer. Thanks niknah * PR #133: Update m4 files for python modules. Thanks Petr Menšík * Bufix CAA value fields may be empty: Thanks Robert Mortimer * PR #108: Fix for ldns-compare-zones net detecting when first zone has a RRset that shrinks from two to one RRs, or grows from one to two RRs. Thanks Emilio Caballero * Fix #131: Drill sig chasing breaks with gcc-11 and strict-aliasing. Thanks Stanislav Levin * Fix #130: Unless $TLL is defined, ttl defaults to the last explicitly stated value. Thanks Benno * Fix #48: Missing UNSIGNED legend with drill. Thanks reedjc * Fix #143: EVP_PKEY_base_id became a macro with OpenSSL > 3.0 Thanks Daniel J. Luke * Let ldns-signzone warn for high NSEC3 iteration counts. Thanks Andreas Schulze 1.7.1 2019-07-26 * bugfix: Manage verification paths for OpenSSL >= 1.1.0 Thanks Marco Davids * bugfix #4106: find the SDK on MacOS X <= 10.6 Thanks Bill Cole * bugfix #4155: ldns-config contains never used variables Thanks Petr Menšík * bugfix #4221: drill -x crashes with malformed IPv4 address Thanks Oleksandr Tymoshenko * bugfix #3437: CDS & CDNSKEY RRsets should be signed with the KSK Thanks Tony Finch * bugfix #1566, #1568, #1569, #1570: Potential NULL Dereferences Thanks Bill Parker * bugfix #1260: Anticipate strchr returning NULL on unfound char Thanks Stephan Zeisberg * bugfix #1257: Free after reallocing to 0 size (CVE-2017-1000232) Thanks Stephan Zeisberg * bugfix #1256: Check parse limit before t increment (CVE-2017-1000231) Thanks Stephan Zeisberg * bugfix #1245: Only one signature per RRset needs to be valid with ldns-verify-zone. Thanks Emil Natan. * ldns-notify can use all supported hash algorithms with -y. * bugfix #1209: make install ldns.pc file Thanks Oleksandr Natalenko * bugfix #1218: Only chase DS if signer is parent of owner. Thanks Emil Natan * bugfix #617: Retry WKS service and protocol names lower case. Thanks Siali Yan * Spelling errors in binaries and man pages Thanks Andreas Schulze * removed duplicate condition in ldns_udp_send_query. * ldns_wire2pkt: fix null pointer dereference if pkt allocation fails and fix memory leak with more EDNS sections Thanks Jan Vcelak * bugfix #1399: ldns_pkt2wire() Python binding is broken. Thanks James Raftery * ED25519 and ED448 support. Default is to autodetect support in OpenSSL. Disable with --disable-ed25519 and --disable-ed448. * ldns-notify: can have IPv6 address as argument. * Fix time sensitive TSIG compare vulnerability. * Fix that ldns-testns ignores sigpipe. * Fix that ldns-notify sets the query RR as question RR, this removes the wrong TTL and 0 rdata from the packet printout. * Allow -T flag to be used together with drill -x * Python bindings compile with swig 4.0 Thanks Jitka Plesníková * bugfix #4248: drill -DT fails for CNAME domain Thanks Thom Wiggers * bugfix #4214: Various fixes and leaks found by coverity. Thanks Petr Menšík * Feature #3394: An -I option to ldns-notify to specify a source IP address to send to notify from. Thanks Geert Hendrickx * Bugfix #279: New API functions ldns_udp_connect2, ldns_tcp_connect2, ldns_udp_bgsend2 and ldns_tcp_bgsend2, that return -1 on failure and allow socket number 0 to be returned too. Thanks Joerg Sonnenberger * Bugfix #1447: More verbose reporting of chasing problems with ldns-verify-zone. Thanks Stephane Guedon * OpenSSL engine support with ldns-signzone. See also https://penzin.net/ldns-signzone/ Many thanks Vadim Penzin. * Various improvements found with shellcheck. Thanks Jeffrey Walton * PR #36 Update manpage of ldns-notify to mention algorithm support with TSIG. Thanks Anand Buddhdev * Compile warnings with signed char input to to_lower() and is_digit() with NetBSD. Thanks Håvard Eidnes * Missing Makefile.PL in DNS-LDNS perl module contribution. Thanks Jaap Akkerhuis 1.7.0 2016-12-20 * Fix lookup of relative names in ldns_resolver_search. * bugfix #548: Double free for answers > 4096 in ldns_resolver_send_pkt * Follow CNAME's when tracing with drill (TODO dnssec trace) * Fix #551 change Regent to Copyright holder in BSD license in some of the headings of the file, to match the opensource.org BSD license. * -e option makes ldns-compare-zones exit with status code 2 on difference * Filter out specified RR types with ldns-read-zone -e and -E options * bugfix #563: Correct DNSKEY from DSA private key. Thanks Peter Koch. * bugfix #562: ldns-keygen match DSA key maximum size with library. And check keysizes with all algorithms. Thanks Peter Koch. * ldns-verify-zone accepts only one single zonefile as argument. * bugfix #573: ldns-keygen write private keys with mode 0600. Thanks Leon Weber * Fix configure to make ldns compile with LibreSSL 2.0 * drill now also accepts dig style -y option (-y <[algo:]name:key> i.s.o. -y ) * OPENPGPKEY draft rr types. Enable with: --enable-rrtype-openpgpkey * bugfix #608: Correct comment about escaped characters * CDS and CDNSKEY rr type from RFC 7344. --enable-rrtype-cds configure option removed * fix: Memory leak in ldns_pkt_rr_list_by_name() Thanks Johannes Naab * fix: Memory leak in ldns_dname2buffer_wire_compress() Thanks Max Liebkies * bugfix #613: Allow tab as whitespace too in last rdata field of types of variable length. Thanks Xiali Yan * bugfix: strip trailing whitespace from $ORIGIN lines in zone files * Let ldns-keygen output .ds files only for KSK keys * Parse RFC7218 TLSA mnemonics, but do not output them * Let ldns-dane use SPKI as the default selector i.s.o. Cert * bugfix: Fit left over NSEC3s once more before adding empty non terminals. Thanks Stuart Browne * bugfix #605: Determine default trust anchor location at compile time Thanks Peter Koch * bugfix #697: Double free with ldns-dane create Thanks Carsten Strotmann * bugfix #623: Do not redefine bool type and boolean values Thanks Jakob Petsovits * bugfix #570: Add TLSA, CDS, CDNSKEY and OPENPGPKEY RR types to ldnsx Thanks Shussain * bugfix #575: ldns_pkt_clone() does not copy timestamp field Thanks Calle Dybedahl * bugfix #584: ldns-update fixes. Send update to port 53, bring manpage in sync with the usage text, and don't alter the ldns_resolver passed to ldns_update_soa_zone_mname(). Created a ldns_resolver_clone() function in the process. Thanks Nicholas Riley. * bugfix #633: ldns_pkt_clone() parameter isn't const. Thanks Jakop Petsovits * bugfix: ldns-dane manpage correction Thanks Erwin Lansing * Spelling fixes. Thanks Andreas Schulze * Hyphen used as minus in manpages. Thanks Andreas Schulze. * RFC7553 RR Type URI is supported by default. * Fix ECDSA signature generation, do not omit leading zeroes. * bugfix: Get rid of superfluous newline in ldns-keyfetcher Thanks Jan-Piet Mens * bugfix: -U option to ldns-signzone to sign with every algorithm Thanks Guido Kroon * const function parameters whenever possible. Thanks Ray Bellis * bugfix #725: allow RR-types on the type bitmap window border Thanks Pieter Lexis * bugfix #726: 2 typos in drill manpage. Thanks Hugo Lombard * Add type CSYNC support, RFC 7477. * Prepare for ED25519, ED448 support: todo convert* routines in dnssec.h, once openssl has support for signing with these algorithms. The dns algorithm number is not yet allocated. These features are not fully implemented yet, openssl (1.1) does not support the algorithms enough to generate keys and sign and verify with them. * Fix _answerfrom comment in ldns_struct_pkt. * Fix drill axfr ipv4/ipv6 queries. * Fix comment referring to mk_query in packet.h to pkt_query_new. * Fix description of QR flag in packet.h. * Fix for openssl 1.1.0 API changes. * Remove commented out macro. Thanks Thiago Farina * bugfix #641: Include install-sh in .gitignore * bugfix #825: Module import breaks with newer SWIG versions. Thanks Christoph Egger * bugfix #796 - #792: Fix miscellaneous compiler warning issues. Thanks Ngie Cooper * bugfix #769: Add support for :: in an IPv6 address Thanks Hajimu UMEMOTO * bugfix #760: Detect superfluous text in presentation format Thanks Xiali Yan * bugfix #708: warnings and errors with xcode 6.1/7.0 * bugfix #754: Memory leak in ldns_str2rdf_ipseckey Thanks Xiali Yan * bugfix #661: Fail NSEC3 signing when NSEC domainname length would overflow. Thanks Jan-Piet Mens. * bugfix #771: hmac-sha224, hmac-sha384 and hmac-sha512 keys. Thanks Harald Jenny * bugfix #680: ldns fails to reject invalidly formatted RFC 7553 URI RRs. Thanks Robert Edmonds * bugfix #678: Use poll i.s.o. select to support > 1024 fds Thanks William King * Use OpenSSL DANE functions for verification (unless explicitly disabled with --disable-dane-ta-usage). * Bump .so version * Include OPENPGPKEY RR type by default * rdata processing for SMIMEA RR type * Fix crash in displaying TLSA RR's. Thanks Andreas Schulze * Update ldns-key2ds man page to mention GOST and SHA384 hash functions. Thanks Harald Jenny * Add sha384 and sha512 tsig algorithm. Thanks Michael Weiser * Clarify data ownership with consts for tsig parameters. Thanks Michael Weiser * bugfix: Fix detection of DSA support with OpenSSL >= 1.1.0 * bugfix #1160: Provide sha256 for release tarballs * --enable-gost-anyway compiles GOST support with OpenSSL >= 1.1.0 even when the GOST engine is not available. 1.6.17 2014-01-10 * Fix ldns_dnssec_zone_new_frm_fp_l to allow the last parsed line of a zone to be an NSEC3 (or its RRSIG) covering an empty non terminal. * Add --disable-dane option to configure and check availability of the for dane needed X509_check_ca function in openssl. * bugfix #490: Get rid of type-punned pointer warnings. Thanks Adam Tkac. * Make sure executables are linked against libcrypto with the LIBSSL_LDFLAGS. Thanks Leo Baltus. * Miscellaneous prototype fixes. Thanks Dag-Erling Smørgrav. * README now shows preferred way to configure for examples and drill. * Bind to source address for resolvers. drill binds to source with -I. Thanks Bryan Duff. * -T option for ldns-dane that has specific exit status for PKIX validated connections without (secure) TLSA records. * Fix b{32,64}_{ntop,pton} detection and handling. * New RR type TKEY, but without operational practice. * New RR types HIP, NINFO, RKEY, CDS, EUI48, EUI64, URI, CAA and TA. * New output format flag (and accompanying functions) to print certain RR's as unknown type * -u and -U parameter for ldns-read-zone to mark/unmark a RR type for printing as unknown type * bugfix #504: GPOS RR has three rdata fields. Thanks Jelte Jansen. * bugfix #497: Properly test for EOF when reading key files with drill. * New functions: ldns_pkt_ixfr_request_new and ldns_pkt_ixfr_request_new_frm_str. * Use SNI with ldns-dane * bugfix #507: ldnsx Fix use of non-existent variables and not properly referring to instance variable. Patch from shussain. * bugfix #508: ldnsx Adding NSEC3PARAM to known/allowable RR type dictionary. Patch from shussain. * bugfix #517: ldns_resolver_new_frm_fp error when invoked using a NULL file pointer. * Fix memory leak in contrib/python: ldns_pkt.new_query. * Fix buffer overflow in fget_token and bget_token. * ldns-verify-zone NSEC3 checking from quadratic to linear performance. Thanks NIC MX (nicmexico.mx) * ldns-dane setup new ssl session for each new connect to prevent hangs * bugfix #521: drill trace continue on empty non-terminals with NSEC3 * bugfix #525: Fix documentation of ldns_resolver_set_retry * Remove unused LDNS_RDF_TYPE_TSIG and associated functions. * Fix ldns_nsec_covers_name for zones with an apex only. Thanks Miek. * Configure option to build perl bindings: --with-p5-dns-ldns (DNS::LDNS is a contribution from Erik Ostlyngen) * bugfix #527: Move -lssl before -lcrypto when linking * Optimize TSIG digest function name comparison (Thanks Marc Buijsman) * Compare names case insensitive with ldns_pkt_rr_list_by_name and ldns_pkt_rr_list_by_name_and_type (thanks Johannes Naab) * A separate --enable for each draft RR type: --enable-rrtype-ninfo, --enable-rrtype-rkey, --enable-rrtype-cds, --enable-rrtype-uri and --enable-rrtype-ta * bugfix #530: Don't sign and verify duplicate RRs (Thanks Jelte Jansen) * bugfix #505: Manpage and usage output fixes (Thanks Tomas Hozza) * Adjust ldns_sha1() so that the input data is not modified (Thanks Marc Buijsman) * Messages to stderr are now off by default and can be re-enabled with the --enable-stderr-msgs configure option. 1.6.16 2012-11-13 * Fix Makefile to build pyldns with BSD make * Fix typo in exporting b32_* symbols to make pyldns load again * Allow leaving the RR owner name empty in ldns-testns datafiles. * Fix fail to create NSEC3 bitmap for empty non-terminal (bug introduced in 1.6.14). 1.6.15 2012-10-25 * Remove LDNS_STATUS_EXISTS_ERR from ldns/error.h to make ldns binary compatible with earlier releases again. 1.6.14 2012-10-23 * DANE support (RFC6698), including ldns-dane example tool. * Configurable default CA certificate repository for ldns-dane with --with-ca-file=CAFILE and --with-ca-path=CAPATH * Configurable default trust anchor with --with-trust-anchor=FILE for drill, ldns-verify-zone and ldns-dane * bugfix #474: Define socklen_t when undefined (like in Win32) * bugfix #473: Dead code removal and resource leak fix in drill * bugfix #471: Let ldns_resolver_push_dnssec_anchor accept DS RR's too. * Various bugfixes from code reviews from CZ.NIC and Paul Wouters * ldns-notify TSIG option argument checking * Let ldns_resolver_nameservers_randomize keep nameservers and rtt's in sync. * Let ldns_pkt_push_rr now return false on (memory) errors. * Make buffer_export comply to documentation and fix buffer2str * Various improvements and fixes of pyldns from Karel Slany now documented in their own Changelog. * bugfix: Make ldns_resolver_pop_nameserver clear the array when there was only one. * bugfix #459: Remove ldns_symbols and export symbols based on regex * bugfix #458: Track all newly created signatures when signing. * bugfix #454: Only set -g and -O2 CFLAGS when no CFLAGS was given. * bugfix #457: Memory leak fix for ldns_key_new_frm_algorithm. * pyldns memory handling fixes and the python3/ldns-signzone.py examples script contribution from Karel Slany. * bugfix #450: Base # bytes for P, G and Y (T) on the guaranteed to be bigger (or equal) P in ldns_key_dsa2bin. * bugfix #449: Deep free cloned rdf's in ldns_tsig_mac_new. * bugfix #448: Copy nameserver value (in stead of reference) of the answering nameserver to the answer packet in ldns_send_buffer, so the original value may be deep freed with the ldns_resolver struct. * New -0 option for ldns-read-zone to replace inception, expiration and signature rdata fields with (null). Thanks Paul Wouters. * New -p option for ldns-read-zone to prepend-pad SOA serial to take up ten characters. * Return error if printing RR fails due to unknown/null RDATA. 1.6.13 2012-05-21 * New -S option for ldns-verify-zone to chase signatures online. * New -k option for ldns-verify-zone to validate using a trusted key. * New inception and expiration margin options (-i and -e) to ldns-verify-zone. * New ldns_dnssec_zone_new_frm_fp and ldns_dnssec_zone_new_frm_fp_l functions. * New ldns_duration* functions (copied from OpenDNSSEC source) * fix ldns-verify-zone to allow NSEC3 signatures to come before the NSEC3 RR in all cases. Thanks Wolfgang Nagele. * Zero the correct flag (opt-out) when creating NSEC3PARAMS. Thanks Peter van Dijk. * Canonicalize RRSIG's Signer's name too when validating, because bind and unbound do that too. Thanks Peter van Dijk. * bugfix #433: Allocate rdf using ldns_rdf_new in ldns_dname_label * bugfix #432: Use LDNS_MALLOC & LDNS_FREE i.s.o. malloc & free * bugfix #431: Added error message for LDNS_STATUS_INVALID_B32_EXT * bugfix #427: Explicitly link ssl with the programs that use it. * Fix reading \DDD: Error on values that are outside range (>255). * bugfix #429: fix doxyparse.pl fails on NetBSD because specified path to perl. * New ECDSA support (RFC 6605), use --disable-ecdsa for older openssl. * fix verifying denial of existence for DS's in NSEC3 Opt-Out zones. Thanks John Barnitz 1.6.12 2012-01-11 * bugfix #413: Fix manpage source for srcdir != builddir * Canonicalize the signers name rdata field in RRSIGs when signing * Ignore minor version of Private-key-format (so v1.3 may be used) * Allow a check_time to be given in stead of always checking against the current time. With ldns-verify-zone the check_time can be set with the -t option. * Added functions for updating and manipulating SOA serial numbers. ldns-read-zone has an option -S for updating and manipulating the serial numbers. * The library Makefile is now GNU and BSD make compatible. * bugfix #419: NSEC3 validation of a name covered by a wildcard with no data. * Two new options (--with-drill and --with-examples) to the main configure script (in the root of the source tree) to build drill and examples too. * Fix days_since_epoch to year_yday calculation on 32bits systems. 1.6.11 2011-09-29 * bugfix #394: Fix socket leak on errors * bugfix #392: Apex only and percentage checks for ldns-verify-zone (thanks Miek Gieben) * bugfix #398: Allow NSEC RRSIGs before the NSEC3 in ldns-verify-zone * Fix python site package path from sitelib to sitearch for pyldns. * Fix python api to support python2 and python3 (thanks Karel Slany). * bugfix #401: Correction of date/time functions algorithm and prevention of an infinite loop therein * bugfix #402: Correct the minimum and maximum number of rdata fields in TSIG. (thanks David Keeler) * bugfix #403: Fix heap overflow (thanks David Keeler) * bugfix #404: Make parsing APL strings more robust (thanks David Keeler) * bugfix #391: Complete library assessment to prevent assertion errors through ldns_rdf_size usage. * Slightly more specific error messaging on wrong number of rdata fields with the LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG and LDNS_STATUS_MISSING_RDATA_FIELDS_KEY result codes. * bugfix #406: More rigorous openssl result code handling to prevent future crashes within openssl. * Fix ldns_fetch_valid_domain_keys to search deeper than just one level for a DNSKEY that signed a DS RR. (this function was used in the check_dnssec_trace nagios module) * bugfix #407: Canonicalize TSIG dnames and algorithm fields * A new output specifier to accommodate configuration of what to show in comment texts when converting host and/or wire-format data to string. All conversion to string and printing functions have a new version that have such a format specifier as an extra argument. The default is changed so that only DNSKEY RR's are annotated with an comment show the Key Tag of the DNSKEY. * Fixed the ldns resolver to not mark a nameserver unreachable when edns0 is tried unsuccessfully with size 4096 (no return packet came), but to still try TCP. A big UDP packet might have been corrupted by fragments dropping firewalls. * Update of libdns.vim (thanks Miek Gieben) * Added the ldnsx Python module to our contrib section, which adds even more pythonisticism to the usage of ldns with Python. (Many thanks to Christopher Olah and Paul Wouters) The ldnsx module is automatically installed when --with-pyldns is used with configuring, but may explicitly be excluded with the --without-pyldnsx option to configure. * bugfix #410: Fix clearing out temporary data on stack in sha2.c * bugfix #411: Don't let empty non-terminal NSEC3s cause assertion failure. 1.6.10 2011-05-31 * New example tool added: ldns-gen-zone. * bugfix #359: Serial-arithmetic for the inception and expiration fields of a RRSIG and correctly converting them to broken-out time information. * bugfix #364: Slight performance increase of ldns-verifyzone. * bugfix #367: Fix to allow glue records with the same name as the delegation. * Fix ldns-verifyzone to allow NSEC3-less records for NS rrsets *and* glue when the zone is opt-out. * bugfix #376: Adapt ldns_nsec3_salt, ldns_nsec3_iterations, ldns_nsec3_flags and ldns_nsec3_algorithm to work for NSEC3PARAMS too. * pyldns memory leaks fixed by Bedrich Kosata (at the cost of a bit performance) * Better handling of reference variables in ldns_rr_new_frm_fp_l from pyldns, with a very nice generator function by Bedrich Kosata. * Decoupling of the rdfs in rrs in the python wrappers to enable the python garbage collector by Bedrich Kosata. * bugfix #380: Minimizing effect of discrepancies in sizeof(bool) at build time and when used. * bugfix #383: Fix detection of empty nonterminals of multiple labels. * Fixed the omission of rrsets in nsec(3)s and rrsigs to all occluded names (in stead of just the ones that contain glue only) and all occluded records on the delegation points (in stead of just the glue). * Clarify the operation of ldns_dnssec_mark_glue and the usage of ldns_dnssec_node_next_nonglue functions in the documentation. * Added function ldns_dnssec_mark_and_get_glue as an real fast alternative for ldns_zone_glue_rr_list. * Fix parse buffer overflow for max length domain names. * Fix Makefile for U in environment, since wrong U is more common than deansification necessity. 1.6.9 2011-03-16 * Fix creating NSEC(3) bitmaps: make array size 65536, don't add doubles. * Fix printout of escaped binary in TXT records. * Parsing TXT records: don't skip starting whitespace that is quoted. * bugfix #358: Check if memory was successfully allocated in ldns_rdf2str(). * Added more memory allocation checks in host2str.c * python wrapper for ldns_fetch_valid_domain_keys by Bedrich Kosata. * fix to compile python wrapper with swig 2.0.2. * Don't fallback to SHA-1 when creating NSEC3 hash with another algorithm identifier, fail instead (no other algorithm identifiers are assigned yet). 1.6.8 2011-01-24 * Fix ldns zone, so that $TTL definition match RFC 2308. * Fix lots of missing checks on allocation failures and parse of NSEC with many types and max parse length in hosts_frm_fp routine and off by one in read_anchor_file routine (thanks Dan Kaminsky and Justin Ferguson). * bugfix #335: Drill: Print both SHA-1 and SHA-256 corresponding DS records. * Print correct WHEN in query packet (is not always 1-1-1970) * ldns-test-edns: new example tool that detects EDNS support. * fix ldns_resolver_send without openssl. * bugfix #342: patch for support for more CERT key types (RFC4398). * bugfix #351: fix udp_send hang if UDP checksum error. * fix set_bit (from NSEC3 sign) patch from Jan Komissar. 1.6.7 2010-11-08 * EXPERIMENTAL ecdsa implementation, please do not enable on real servers. * GOST code enabled by default (RFC 5933). * bugfix #326: ignore whitespace between directives and their values. * Header comment to advertise ldns_axfr_complete to check for successfully completed zone transfers. * read resolv.conf skips interface labels, e.g. %eth0. * Fix drill verify NSEC3 denials. * Use closesocket() on windows. * Add ldns_get_signing_algorithm_by_name that understand aliases, names changed to RFC names and aliases for compatibility added. * bugfix: don't print final dot if the domain is relative. * bugfix: resolver search continue when packet rcode != NOERROR. * bugfix: resolver push all domains in search directive to list. * bugfix: resolver search by default includes the root domain. * bugfix: tcp read could fail on single octet recv. * bugfix: read of RR in unknown syntax with missing fields. * added ldns_pkt_tsig_sign_next() and ldns_pkt_tsig_verify_next() to sign and verify TSIG RRs on subsequent messages (section 4.4, RFC 2845, thanks to Michael Sheldon). * bugfix: signer sigs nsecs with zsks only. * bugfix #333: fix ldns_dname_absolute for name ending with backslash. 1.6.6 2010-08-09 * Fix ldns_rr_clone to copy question rrs properly. * Fix ldns_sign_zone(_nsec3) to clone the soa for the new zone. * Fix ldns_wire2dname size check from reading 1 byte beyond buffer end. * Fix ldns_wire2dname from reading 1 byte beyond end for pointer. * Fix crash using GOST for particular platform configurations. * extern C declarations used in the header file. * Removed debug fprintf from resolver.c. * ldns-signzone checks if public key file is for the right zone. * NETLDNS, .NET port of ldns functionality, by Alex Nicoll, in contrib. * Fix handling of comments in resolv.conf parse. * GOST code enabled if SSL recent, RFC 5933. * bugfix #317: segfault util.c ldns_init_random() fixed. * Fix ldns_tsig_mac_new: allocate enough memory for the hash, fix use of b64_pton_calculate_size. * Fix ldns_dname_cat: size calculation and handling of realloc(). * Fix ldns_rr_pop_rdf: fix handling of realloc(). * Fix ldns-signzone for single type key scheme: sign whole zone if there are only KSKs. * Fix ldns_resolver: also close socket if AXFR failed (if you don't, it would block subsequent transfers (thanks Roland van Rijswijk). * Fix drill: allow for a secure trace if you use DS records as trust anchors (thanks Jan Komissar). 1.6.5 2010-06-15 * Catch \X where X is a digit as an error. * Fix segfault when ip6 ldns resolver only has ip4 servers. * Fix NSEC record after DNSKEY at zone apex not properly signed. * Fix syntax error if last label too long and no dot at end of domain. * Fix parse of \# syntax with space for type LOC. * Fix ldns_dname_absolute for escape sequences, fixes some parse errs. * bugfix #297: linking ssl, bug due to patch submitted as #296. * bugfix #299: added missing declarations to host2str.h * ldns-compare-zones -s to not exclude SOA record from comparison. * --disable-rpath fix * fix ldns_pkt_empty(), reported by Alex Nicoll. * fix ldns_resolver_new_frm_fp not ignore lines after a comment. * python code for ldns_rr.new_question_frm_str() * Fix ldns_dnssec_verify_denial: the signature selection routine. * Type TALINK parsed (draft-ietf-dnsop-trust-history). * bugfix #304: fixed dead loop in ldns_tcp_read_wire() and ldns_tcp_read_wire_timeout(). * GOST support with correct algorithm numbers. The plan is to make it enabled if openssl support is detected, but it is disabled by default in this release because the RFC is not ready. * Fixed comment in rbtree.h about being first member and data ptr. * Fixed possibly leak in case of out of memory in ldns_native2rdf... * ldns_dname_is_wildcard added. * Fixed: signatures over wildcards had the wrong labelcount. * Fixed ldns_verify() inconsistent return values. * Fixed ldns_resolver to copy and free tsig name, data and algorithm. * Fixed ldns_resolver to push search onto searchlist. * A ldns resolver now defaults to a non-recursive resolver that handles the TC bit. * ldns_resolver_print() prints more details. * Fixed ldns_rdf2buffer_str_time(), which did not print timestamps on 64bit systems. * Make ldns_resolver_nameservers_randomize() more random. * bugfix #310: POSIX specifies NULL second argument of gettimeofday. * fix compiler warnings from llvm clang compiler. * bugfix #309: ldns_pkt_clone did not clone the tsig_rr. * Fix gentoo ebuild for drill, 'no m4 directory'. * bugfix #313: drill trace on an empty nonterminal continuation. 1.6.4 2010-01-20 * Imported pyldns contribution by Zdenek Vasicek and Karel Slany. Changed its configure and Makefile to fit into ldns. Added its dname_* methods to the rdf_* class (as is the ldns API). Changed swig destroy of ldns_buffer class to ldns_buffer_free. Declared ldns_pkt_all and ldns_pkt_all_noquestion so swig sees them. * Bugfix: parse PTR target of .tomhendrikx.nl with error not crash. * Bugfix: handle escaped characters in TXT rdata. * bug292: no longer crash on malformed domain names where a label is on position 255, which was a buffer overflow by one. * Fix ldns_get_rr_list_hosts_frm_fp_l (strncpy to strlcpy change), which fixes resolv.conf reading badly terminated string buffers. * Fix ldns_pkt_set_random_id to be more random, and a little faster, it did not do value 0 statistically correctly. * Fix ldns_rdf2native_sockaddr_storage to set sockaddr type to zeroes, for portability. * bug295: nsec3-hash routine no longer case sensitive. * bug298: drill failed nsec3 denial of existence proof. 1.6.3 2009-12-04 * Bugfix: allow for unknown resource records in zonefile with rdlen=0. * Bugfix: also mark an RR as question if it comes from the wire * Bugfix: NSEC3 bitmap contained NSEC * Bugfix: Inherit class when creating signatures 1.6.2 2009-11-12 * Fix Makefile patch from Havard Eidnes, better install.sh usage. * Fix parse error on SOA serial of 2910532839. Fix print of ';' and readback of '\;' in names, also for '\\'. Fix parse of '\(' and '\)' in names. Also for file read. Also '\.' * Fix signature creation when TTLs are different for RRs in RRset. * bug273: fix so EDNS rdata is included in pkt to wire conversion. * bug274: fix use of c++ keyword 'class' for RR class in the code. * bug275: fix memory leak of packet edns rdata. * Fix timeout procedure for TCP and AXFR on Solaris. * Fix occasional NSEC bitmap bogus * Fix rr comparing (was in reversed order since 1.6.0) * bug278: fix parsing HINFO rdata (and other cases). * Fix previous owner name: also pick up if owner name is @. * RFC5702: enabled sha2 functions by default. This requires OpenSSL 0.9.8 or higher. Reason for this default is the root to be signed with RSASHA256. * Fix various LDNS RR parsing issues: IPSECKEY, WKS, NSAP, very long lines * Fix: Make ldns_dname_is_subdomain case insensitive. * Fix ldns-verify-zone so that address records at zone NS set are not considered glue (Or glue records fall below delegation) * Fix LOC RR altitude printing. * Feature: Added period (e.g. '3m6d') support at explicit TTLs. * Feature: DNSKEY rrset by default signed with minimal signatures but -A option for ldns-signzone to sign it with all keys. This makes the DNSKEY responses smaller for signed domains. 1.6.1 2009-09-14 * --enable-gost : use the GOST algorithm (experimental). * Added some missing options to drill manpage * Some fixes to --without-ssl option * Fixed quote parsing within strings * Bitmask fix in EDNS handling * Fixed non-fqdn domain name completion for rdata field domain names of length 1 * Fixed chain validation with SHA256 DS records 1.6.0 Additions: * Addition of an ldns-config script which gives cflags and libs values, for use in configure scripts for applications that use use ldns. Can be disabled with ./configure --disable-ldns-config * Added direct sha1, sha256, and sha512 support in ldns. With these functions, all NSEC3 functionality can still be used, even if ldns is built without OpenSSL. Thanks to OpenBSD, Steve Reid, and Aaron D. Gifford for the code. * Added reading/writing support for the SPF Resource Record * Base32 functions are now exported Bugfixes: * ldns_is_rrset did not go through the complete rrset, but only compared the first two records. Thanks to Olafur Gudmundsson for report and patch * Fixed a small memory bug in ldns_rr_list_subtype_by_rdf(), thanks to Marius Rieder for finding an patching this. * --without-ssl should now work. Make sure that examples/ and drill also get the --without-ssl flag on their configure, if this is used. * Some malloc() return value checks have been added * NSEC3 creation has been improved wrt to empty nonterminals, and opt-out. * Fixed a bug in the parser when reading large NSEC3 salt values. * Made the allowed length for domain names on wire and presentation format the same. Example tools: * ldns-key2ds can now also generate DS records for keys without the SEP flag * ldns-signzone now equalizes the TTL of the DNSKEY RRset (to the first non-default DNSKEY TTL value it sees) 1.5.1 Example tools: * ldns-signzone was broken in 1.5.0 for multiple keys, this has been repaired Build system: * Removed a small erroneous output warning in examples/configure and drill/configure 1.5.0 Bug fixes: * fixed a possible memory overflow in the RR parser * build flag fix for Sun Studio * fixed a building race condition in the copying of header files * EDNS0 extended rcode; the correct assembled code number is now printed (still in the EDNS0 field, though) * ldns_pkt_rr no longer leaks memory (in fact, it no longer copies anything all) API addition: * ldns_key now has support for 'external' data, in which case the OpenSSL EVP structures are not used; ldns_key_set_external_key() and ldns_key_external_key() * added ldns_key_get_file_base_name() which creates a 'default' filename base string for key storage, of the form "K++" * the ldns_dnssec_* family of structures now have deep_free() functions, which also free the ldns_rr's contained in them * there is now an ldns_match_wildcard() function, which checks whether a domain name matches a wildcard name * ldns_sign_public has been split up; this resulted in the addition of ldns_create_empty_rrsig() and ldns_sign_public_buffer() Examples: * ldns-signzone can now automatically add DNSKEY records when using an OpenSSL engine, as it already did when using key files * added new example tool: ldns-nsec3-hash * ldns-dpa can now filter on specific query name and types * ldnsd has fixes for the zone name, a fix for the return value of recvfrom(), and an memory initialization fix (Thanks to Colm MacCárthaigh for the patch) * Fixed memory leaks in ldnsd 1.4.1 Bug fixes: * fixed a build issue where ldns lib existence was done too early * removed unnecessary check for pcap.h * NSEC3 optout flag now correctly printed in string output * inttypes.h moved to configured inclusion * fixed NSEC3 type bitmaps for empty nonterminals and unsigned delegations API addition: * for that last fix, we added a new function ldns_dname_add_from() that can clone parts of a dname 1.4.0 Bug fixes: * sig chase return code fix (patch from Rafael Justo, bug id 189) * rdata.c memory leaks on error and allocation checks fixed (patch from Shane Kerr, bug id 188) * zone.c memory leaks on error and allocation checks fixed (patch from Shane Kerr, bug id 189) * ldns-zsplit output and error messages fixed (patch from Shane Kerr, bug id 190) * Fixed potential buffer overflow in ldns_str2rdf_dname * Signing code no longer signs delegation NS rrsets * Some minor configure/makefile updates * Fixed a bug in the randomness initialization * Fixed a bug in the reading of resolv.conf * Fixed a bug concerning whitespace in zone data (with patch from Ondrej Sury, bug 213) * Fixed a small fallback problem in axfr client code API CHANGES: * added 2str convenience functions: - ldns_rr_type2str - ldns_rr_class2str - ldns_rr_type2buffer_str - ldns_rr_class2buffer_str * buffer2str() is now called ldns_buffer2str * base32 and base64 function names are now also prepended with ldns_ * ldns_rr_new_frm_str() now returns an error on missing RDATA fields. Since you cannot read QUESTION section RRs with this anymore, there is now a function called ldns_rr_new_question_frm_str() LIBRARY FEATURES: * DS RRs string representation now add bubblebabble in a comment (patch from Jakob Schlyter) * DLV RR type added * TCP fallback system has been improved * HMAC-SHA256 TSIG support has been added. * TTLS are now correctly set in NSEC(3) records when signing zones EXAMPLE TOOLS: * New example: ldns-revoke to revoke DNSKEYs according to RFC5011 * ldns-testpkts has been fixed and updated * ldns-signzone now has the option to not add the DNSKEY * ldns-signzone now has an (full zone only) opt-out option for NSEC3 * ldns-keygen can create HMAC-SHA1 and HMAC-SHA256 symmetric keys * ldns-walk output has been fixed * ldns-compare-zones has been fixed, and now has an option to show all differences (-a) * ldns-read-zone now has an option to print DNSSEC records only 1.3 Base library: * Added a new family of functions based around ldns_dnssec_zone, which is a new structure that keeps a zone sorted through an rbtree and links signatures and NSEC(3) records directly to their RRset. These functions all start with ldns_dnssec_ * ldns_zone_sign and ldns_zone_sign_nsec3 are now deprecated, but have been changed to internally use the new ldns_dnssec_zone_sign(_nsec3) * Moved some ldns_buffer functions inline, so a clean rebuild of applications relying on those is needed (otherwise you'll get linker errors) * ldns_dname_label now returns one extra (zero) byte, so it can be seen as an fqdn. * NSEC3 type code update for signing algorithms. * DSA key generation of DNSKEY RRs fixed (one byte too small). * Added support for RSA/SHA256 and RSA/SHA512, as specified in draft-ietf-dnsext-dnssec-rsasha256-04. The typecodes are not final, and this feature is not enabled by default. It can be enabled at compilation time with the flag --with-sha2 * Added 2wire_canonical family of functions that lowercase dnames in rdata fields in resource records of the types in the list in rfc3597 * Added base32 conversion functions. * Fixed DSA RRSIG conversion when calling OpenSSL Drill: * Chase output is completely different, it shows, in ascii, the relations in the trust hierarchy. Examples: * Added ldns-verify-zone, that can verify the internal DNSSEC records of a signed BIND-style zone file * ldns-keygen now takes an -a argument specifying the algorithm, instead of -R or -D. -a list show a list of supported algorithms * ldns-keygen now defaults to the exponent RSA_F4 instead of RSA_3 for RSA key generation * ldns-signzone now has support for HSMs * ldns-signzone uses the new ldns_dnssec_ structures and functions which improves its speed, and output; RRSIGS are now placed directly after their RRset, NSEC(3) records directly after the name they handle Contrib: * new contrib/ dir with user contributions * added compilation script for solaris (thanks to Jakob Schlyter) 28 Nov 2007 1.2.2: * Added support for HMAC-MD5 keys in generator * Added a new example tool (written by Ondrej Sury): ldns-compare-zones * ldns-keygen now checks key sizes for rfc conformance * ldns-signzone outputs SSL error if present * Fixed manpages (thanks to Ondrej Sury) * Fixed Makefile for -j * Fixed a $ORIGIN error when reading zones * Fixed another off-by-one error 03 Oct 2007 1.2.1: * Fixed an offset error in rr comparison * Fixed ldns-read-zone exit code * Added check for availability of SHA256 hashing algorithm * Fixed ldns-key2ds -2 argument * Fixed $ORIGIN bug in .key files * Output algorithms as an integer instead of their mnemonic * Fixed a memory leak in dnssec code when SHA256 is not available * Updated fedora .spec file 11 Apr 2007 1.2.0: * canonicalization of rdata in DNSSEC functions now adheres to the rr type list in rfc3597, not rfc4035, which will be updated (see http://www.ops.ietf.org/lists/namedroppers/namedroppers.2007/msg00183.html) * ldns-walk now support dnames with maximum label length * ldnsd now takes an extra argument containing the address to listen on * signing no longer signs every rrset with KSK's, but only the DNSKEY rrset * ported to Solaris 10 * added ldns_send_buffer() function * added ldns-testpkts fake packet server * added ldns-notify to send NOTIFY packets * ldns-dpa can now accurately calculate the number of matches per second * libtool is now used for compilation too (still gcc, but not directly) * Bugfixes: - TSIG signing buffer size - resolv.conf reading (comments) - dname comparison off by one error - typo in keyfetchers output file name fixed (a . too much) - fixed zone file parser when comments contain ( or ) - fixed LOC RR type - fixed CERT RR type Drill: * drill prints error on failed axfr. * drill now accepts mangled packets with -f * old -c option (use tcp) changed to -t * -c option to specify alternative resolv.conf file added * feedback of signature chase improved * chaser now stops at root when no trusted keys are found instead of looping forever trying to find the DS for . * Fixed bugs: - wildcard on multiple labels signature verification - error in -f packet writing for malformed packets - made KSK check more resilient 7 Jul 2006: 1.1.0: ldns-team * Added tutorials and an introduction to the documentation * Added include/ and lib/ dirs so that you can compile against ldns without installing ldns on your system * Makefile updates * Starting usage of assert throughout the library to catch illegal calls * Solaris 9 testing was carried out. Ldns now compiles on that platform; some gnuism were identified and fixed. * The ldns_zone structure was stress tested. The current setup (ie. just a list of rrs) can scale to zone file in order of megabytes. Sorting such zone is still difficult. * Reading multiline b64 encoded rdata works. * OpenSSL was made optional, configure --without-ssl. Ofcourse all dnssec/tsig related functions are disabled * Building of examples and drill now happens with the same defines as the building of ldns itself. * Preliminary sha-256 support was added. Currently is your OpenSSL supports it, it is supported in the DS creation. * ldns_resolver_search was implemented * Fixed a lot of bugs Drill: * -r was killed in favor of -o
which allows for a header bits setting (and maybe more in the future) * DNSSEC is never automatically set, even when you query for DNSKEY/RRSIG or DS. * Implement a crude RTT check, it now distinguishes between reachable and unreachable. * A form of secure tracing was added * Secure Chasing has been improved * -x does a reverse lookup for the given IP address Examples: * ldns-dpa was added to the examples - this is the Dns Packet Analyzer tool. * ldnsd - as very, very simple nameserver impl. * ldns-zsplit - split zones for parallel signing * ldns-zcat - cat split zones back together * ldns-keyfetcher - Fetches DNSKEY records with a few (non-strong, non-DNSSEC) anti-spoofing techniques. * ldns-walk - 'Walks' a DNSSEC signed zone * Added an all-static target to the makefile so you can use examples without installing the library * When building in the source tree or in a direct subdirectory of the build dir, configure does not need --with-ldns=../ anymore Code: * All networking code was moved to net.c * rdata.c: added asserts to the rdf set/get functions * const keyword was added to pointer arguments that aren't changed API: Changed: * renamed ldns/dns.h to ldns/ldns.h * ldns_rr_new_frm_str() is extended with an extra variable which in common use may be NULL. This trickles through to: o ldns_rr_new_frm_fp o ldns_rr_new_frm_fp_l Which also get an extra variable Also the function has been changed to return a status message. The compiled RR is returned in the first argument. * ldns_zone_new_frm_fp_l() and ldns_zone_new_frm_fp() are changed to return a status msg. * ldns_key_new_frm_fp is changed to return ldns_status and the actual key list in the first argument * ldns_rdata_new_frm_fp[_l]() are changed to return a status. the rdf is return in the first argument * ldns_resolver_new_frm_fp: same treatment: return status and the new resolver in the first argument * ldns_pkt_query_new_frm_str(): same: return status and the packet in the first arg * tsig.h: internal used functions are now static: ldns_digest_name and ldns_tsig_mac_new * ldns_key_rr2ds has an extra argument to specify the hash to use. * ldns_pkt_rcode() is renamed to ldns_pkt_get_rcode, ldns_pkt_rcode is now the rcode type, like ldns_pkt_opcode New: * ldns_resolver_searchlist_count: return the searchlist counter * ldns_zone_sort: Sort a zone * ldns_bgsend(): background send, returns a socket. * ldns_pkt_empty(): check is a packet is empty * ldns_rr_list_pop_rr_list(): pop multiple rr's from another rr_list * ldns_rr_list_push_rr_list(): push multiple rr's to an rr_list * ldns_rr_list_compare(): compare 2 ldns_rr_lists * ldns_pkt_push_rr_list: rr_list equiv for rr * ldns_pkt_safe_push_rr_list: rr_list equiv for rr Removed: * ldns_resolver_bgsend(): was not used in 1.0.0 and is not used now * ldns_udp_server_connect(): was faulty and isn't really part of the core ldns idea any how. * ldns_rr_list_insert_rr(): obsoleted, because not used. * char *_when was removed from the ldns_pkt structure 18 Oct 2005: 1.0.0: ldns-team * Committed a patch from Håkan Olsson * Added UPDATE support (Jakob Schlyter and Håkan Olsson) * License change: ldns is now BSD licensed * ldns now depends on SSL * Networking code cleanup, added (some) server udp/tcp support * A zone type is introduced. Currently this is a list of RRs, so it will not scale well. * [beta] Zonefile parsing was added * [tools] Drill was added to ldns - see drill/ * [tools] experimental signer was added * [building] better check for ssl * [building] major revision of build system * [building] added rpm .spec in packaging/ (thanks to Paul Wouters) * [building] A lot of cleanup in the build scripts (thanks to Jakob Schlyter and Paul Wouters) 28 Jul 2005: 0.70: ldns-team * [func] ldns_pkt_get_section now returns copies from the rrlists in the packet. This can be freed by the user program * [code] added ldns_ prefixes to function from util.h * [inst] removed documentation from default make install * Usual fixes in documentation and code 20 Jun 2005: 0.66: ldns-team Rel. Focus: drill-pre2 uses some functions which are not in 0.65 * dnssec_cd bit function was added * Zone infrastructure was added * Usual fixes in documentation and code 13 Jun 2005: 0.65: ldns-team * Repository is online at: http://www.nlnetlabs.nl/ldns/svn/ * Apply reference copying throughout ldns, except in 2 places in the ldns_resolver structure (._domain and ._nameservers) * Usual array of bugfixes * Documentation added * keygen.c added as an example for DNSSEC programming 23 May 2005: 0.60: ldns-team * Removed config.h from the header installed files (you're not supposed to include that in a library) * Further tweaking - DNSSEC signing/verification works - Assorted bug fixes and tweaks (memory management) May 2005: 0.50: ldns-team * First usable release * Basic DNS functionality works * DNSSEC validation works ldns-1.9.2/sha1.c0000664000175000017500000001421215212267520013033 0ustar willemwillem/* * modified for ldns by Jelte Jansen, original taken from OpenBSD: * * SHA-1 in C * By Steve Reid * 100% Public Domain * * Test Vectors (from FIPS PUB 180-1) * "abc" * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 * A million repetitions of "a" * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F */ /* #define LITTLE_ENDIAN * This should be #define'd already, if true. */ #include #include #include #define SHA1HANDSOFF 1 /* Copies data before messing with it. */ #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) /* blk0() and blk() perform the initial expand. */ /* I got the idea of expanding during the round function from SSLeay */ #if BYTE_ORDER == LITTLE_ENDIAN #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ |(rol(block->l[i],8)&0x00FF00FF)) #else #define blk0(i) block->l[i] #endif #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ ^block->l[(i+2)&15]^block->l[i&15],1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); /* Hash a single 512-bit block. This is the core of the algorithm. */ void ldns_sha1_transform(uint32_t state[5], const unsigned char buffer[LDNS_SHA1_BLOCK_LENGTH]) { uint32_t a, b, c, d, e; typedef union { unsigned char c[64]; unsigned int l[16]; } CHAR64LONG16; CHAR64LONG16* block; #ifdef SHA1HANDSOFF unsigned char workspace[LDNS_SHA1_BLOCK_LENGTH]; block = (CHAR64LONG16 *)workspace; memmove(block, buffer, LDNS_SHA1_BLOCK_LENGTH); #else block = (CHAR64LONG16 *)buffer; #endif /* Copy context->state[] to working vars */ a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; /* 4 rounds of 20 operations each. Loop unrolled. */ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); /* Add the working vars back into context.state[] */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; state[4] += e; /* Wipe variables */ a = b = c = d = e = 0; (void)a; (void)b; (void)c; (void)d; (void)e; } /* SHA1Init - Initialize new context */ void ldns_sha1_init(ldns_sha1_ctx *context) { /* SHA1 initialization constants */ context->count = 0; context->state[0] = 0x67452301; context->state[1] = 0xEFCDAB89; context->state[2] = 0x98BADCFE; context->state[3] = 0x10325476; context->state[4] = 0xC3D2E1F0; } /* Run your data through this. */ void ldns_sha1_update(ldns_sha1_ctx *context, const unsigned char *data, unsigned int len) { unsigned int i; unsigned int j; j = (unsigned)(uint32_t)((context->count >> 3) & 63); context->count += (len << 3); if ((j + len) > 63) { memmove(&context->buffer[j], data, (i = 64 - j)); ldns_sha1_transform(context->state, context->buffer); for ( ; i + 63 < len; i += 64) { ldns_sha1_transform(context->state, &data[i]); } j = 0; } else i = 0; memmove(&context->buffer[j], &data[i], len - i); } /* Add padding and return the message digest. */ void ldns_sha1_final(unsigned char digest[LDNS_SHA1_DIGEST_LENGTH], ldns_sha1_ctx *context) { unsigned int i; unsigned char finalcount[8]; for (i = 0; i < 8; i++) { finalcount[i] = (unsigned char)((context->count >> ((7 - (i & 7)) * 8)) & 255); /* Endian independent */ } ldns_sha1_update(context, (unsigned char *)"\200", 1); while ((context->count & 504) != 448) { ldns_sha1_update(context, (unsigned char *)"\0", 1); } ldns_sha1_update(context, finalcount, 8); /* Should cause a SHA1Transform() */ if (digest != NULL) for (i = 0; i < LDNS_SHA1_DIGEST_LENGTH; i++) { digest[i] = (unsigned char)((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); } #ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */ ldns_sha1_transform(context->state, context->buffer); #endif } unsigned char * ldns_sha1(const unsigned char *data, unsigned int data_len, unsigned char *digest) { ldns_sha1_ctx ctx; ldns_sha1_init(&ctx); ldns_sha1_update(&ctx, data, data_len); ldns_sha1_final(digest, &ctx); return digest; } ldns-1.9.2/configure0000775000175000017500000231604415212267525013761 0ustar willemwillem#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.71 for ldns 1.9.2. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, # Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="as_nop=: if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes else $as_nop as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$as_shell as_have_required=yes if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null then : break 2 fi fi done;; esac as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes fi fi if test "x$CONFIG_SHELL" != x then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno then : printf "%s\n" "$0: This script requires a shell more modern than all" printf "%s\n" "$0: the shells that I found on your system." if test ${ZSH_VERSION+y} ; then printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and $0: dns-team@nlnetlabs.nl about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ldns' PACKAGE_TARNAME='libdns' PACKAGE_VERSION='1.9.2' PACKAGE_STRING='ldns 1.9.2' PACKAGE_BUGREPORT='dns-team@nlnetlabs.nl' PACKAGE_URL='' ac_unique_file="packet.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_STDIO_H # include #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_c_list= ac_func_c_list= ac_subst_vars='LTLIBOBJS CONFIG_FILES ldns_build_config_have_attr_unused ldns_build_config_have_attr_format ldns_build_config_have_ssl DEFAULT_CAPATH DEFAULT_CAFILE LDNS_TRUST_ANCHOR_FILE WINDRES ldns_build_config_have_b32_pton ldns_build_config_have_b32_ntop LIBOBJS ldns_build_config_have_socklen_t LIBPCAP_LIBS include_unistd_h include_systypes_h include_inttypes_h ldns_build_config_have_inttypes_h include_sys_socket_h LIBSSL_SSL_LIBS LIBSSL_LIBS LIBSSL_LDFLAGS LIBSSL_CPPFLAGS ldns_build_config_use_dane_ta_usage ldns_build_config_use_dane_verify ldns_build_config_use_dane ldns_build_config_use_ed448 ldns_build_config_use_ed25519 ldns_build_config_use_dsa RUNTIME_PATH HAVE_SSL libtool CLEAN_P5_DNS_LDNS UNINSTALL_P5_DNS_LDNS INSTALL_P5_DNS_LDNS TEST_P5_DNS_LDNS P5_DNS_LDNS PERL PYLDNSXUNINST PYLDNSXINST PYLDNSUNINST PYLDNSINST PYLDNSX PYTHON_X_CFLAGS swig PYLDNS SWIG_LIB SWIG SWIGPY3 PYTHON_EXTRA_LDFLAGS PYTHON_EXTRA_LIBS PYTHON_PLATFORM_SITE_PKG PYTHON_SITE_PKG PYTHON_LIBS PYTHON_CPPFLAGS PYTHON PYTHON_VERSION UNINSTALL_CONFIG_MANPAGE UNINSTALL_CONFIG INSTALL_CONFIG_MANPAGE INSTALL_CONFIG LINT_EXAMPLES CLEAN_EXAMPLES UNINSTALL_EXAMPLES INSTALL_EXAMPLES EXAMPLES LINT_DRILL CLEAN_DRILL UNINSTALL_DRILL INSTALL_DRILL DRILL doxygen LINTFLAGS SET_MAKE DEPFLAG LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL AWK RANLIB STRIP ac_ct_AR AR DLLTOOL OBJDUMP FILECMD LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC VERSION_INFO LDNS_VERSION_MICRO LDNS_VERSION_MINOR LDNS_VERSION_MAJOR target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_shared enable_static with_pic enable_fast_install with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock with_drill with_examples enable_ldns_config enable_stderr_msgs enable_poll with_pyldns with_pyldnsx with_p5_dns_ldns with_ssl enable_sha2 enable_gost enable_gost_anyway enable_ecdsa enable_dsa enable_ed25519 enable_ed448 enable_dane enable_dane_verify enable_dane_ta_usage enable_full_dane enable_no_dane_ta_usage enable_no_dane_verify enable_draft_rrtypes enable_rrtype_ninfo enable_rrtype_rkey enable_rrtype_openpgpkey enable_rrtype_ta enable_rrtype_avc enable_rrtype_doa enable_rrtype_amtrelay enable_rrtype_svcb_https enable_rrtype_resinfo enable_rrtype_dsync enable_rrtypes_cla_ipn enable_rrtypes_hhit_brid enable_rpath with_xcode_sdk with_trust_anchor with_ca_file with_ca_path ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS LT_SYS_LIBRARY_PATH PYTHON_VERSION' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures ldns 1.9.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libdns] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of ldns 1.9.2:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-ldns-config disable installation of ldns-config (default=enabled) --enable-stderr-msgs Enable printing to stderr (default=disabled) --enable-poll This platform supports poll(7) --disable-sha2 Disable SHA256 and SHA512 RRSIG support --disable-gost Disable GOST support --enable-gost-anyway Enable GOST even without a GOST engine installed --disable-ecdsa Disable ECDSA support --disable-dsa Disable DSA support --disable-ed25519 Disable (experimental) ED25519 support. Default is detect --disable-ed448 Disable (experimental) ED448 support. Default is detect --disable-dane Disable DANE support --disable-dane-verify Disable DANE verify support --disable-dane-ta-usage Disable DANE-TA usage type support --enable-draft-rrtypes Enable all draft RR types. --enable-rrtype-ninfo Enable draft RR type ninfo. --enable-rrtype-rkey Enable draft RR type rkey. --disable-rrtype-openpgpkey Disable openpgpkey RR type. --enable-rrtype-ta Enable draft RR type ta. --enable-rrtype-avc Enable draft RR type avc. --enable-rrtype-doa Enable draft RR type DOA. --disable-rrtype-amtrelay Disable RR type AMTRELAY. --disable-rrtype-svcb-https Disable RR types SVCB and HTTPS. --disable-rrtype-resinfo Disable RR type RESINFO. --disable-rrtype-dsync Disable RR type DSYNC. --enable-rrtypes-cla-ipn Enable draft RR types CLA and IPN. --enable-rrtypes-hhit-brid Enable draft RR types HHIT and BRID. --disable-rpath disable hardcoded rpath (default=enabled) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-drill Also build drill. --with-examples Also build examples. --with-pyldns generate python library, or --without-pyldns to disable Python support. --without-pyldnsx Do not install the ldnsx python module, or --with-pyldnsx to install it. --with-p5-dns-ldns generate DNS::LDNS perl bindings --with-ssl=pathname enable SSL (will check /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr or specify like /usr/include/openssl11) --with-xcode-sdk Set xcode SDK version. Default is autodetect --with-trust-anchor=KEYFILE Default location of the trust anchor file for drill and ldns-dane. [default=SYSCONFDIR/unbound/root.key] --with-ca-file=CAFILE File containing CA certificates for ldns-dane --with-ca-path=CAPATH Directory containing CA certificate files for ldns-dane Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory LT_SYS_LIBRARY_PATH User-defined run-time library search path. PYTHON_VERSION The installed Python version to use, for example '2.3'. This string will be appended to the Python interpreter canonical name. Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for configure.gnu first; this name is used for a wrapper for # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ldns configure 1.9.2 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. */ #include #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main (void) { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR # ------------------------------------------------------------------ # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR. ac_fn_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 printf %s "checking whether $as_decl_name is declared... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` eval ac_save_FLAGS=\$$6 as_fn_append $6 " $5" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext eval $6=\$ac_save_FLAGS fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_check_decl # ac_fn_c_try_run LINENO # ---------------------- # Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that # executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: program exited with status $ac_status" >&5 printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=$ac_mid; break else $as_nop as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_lo=$ac_mid; break else $as_nop as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done else $as_nop ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_hi=$ac_mid else $as_nop as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval (void) { return $2; } static unsigned long int ulongval (void) { return $2; } #include #include int main (void) { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : echo >>conftest.val; read $3 &5 printf %s "checking for $2.$3... " >&6; } if eval test \${$4+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" else $as_nop eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$4 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member ac_configure_args_raw= for ac_arg do case $ac_arg in *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_configure_args_raw " '$ac_arg'" done case $ac_configure_args_raw in *$as_nl*) ac_safe_unquote= ;; *) ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. ac_unsafe_a="$ac_unsafe_z#~" ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; esac cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ldns $as_me 1.9.2, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && printf "%s\n" "$as_me: caught signal $ac_signal" printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi for ac_site_file in $ac_site_files do case $ac_site_file in #( */*) : ;; #( *) : ac_site_file=./$ac_site_file ;; esac if test -f "$ac_site_file" && test -r "$ac_site_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" # Test code for whether the C compiler supports C89 (global declarations) ac_c_conftest_c89_globals=' /* Does the compiler advertise C89 conformance? Do not test the value of __STDC__, because some compilers set it to 0 while being otherwise adequately conformant. */ #if !defined __STDC__ # error "Compiler does not advertise C89 conformance" #endif #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ struct buf { int x; }; struct buf * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not \xHH hex character constants. These do not provoke an error unfortunately, instead are silently treated as an "x". The following induces an error, until -std is added to get proper ANSI mode. Curiously \x00 != x always comes out true, for an array size at least. It is necessary to write \x00 == 0 to get something that is true only with -std. */ int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) '\''x'\'' int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), int, int);' # Test code for whether the C compiler supports C89 (body of main). ac_c_conftest_c89_main=' ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); ' # Test code for whether the C compiler supports C99 (global declarations) ac_c_conftest_c99_globals=' // Does the compiler advertise C99 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L # error "Compiler does not advertise C99 conformance" #endif #include extern int puts (const char *); extern int printf (const char *, ...); extern int dprintf (int, const char *, ...); extern void *malloc (size_t); // Check varargs macros. These examples are taken from C99 6.10.3.5. // dprintf is used instead of fprintf to avoid needing to declare // FILE and stderr. #define debug(...) dprintf (2, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK #error "your preprocessor is broken" #endif #if BIG_OK #else #error "your preprocessor is broken" #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case '\''s'\'': // string str = va_arg (args_copy, const char *); break; case '\''d'\'': // int number = va_arg (args_copy, int); break; case '\''f'\'': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } ' # Test code for whether the C compiler supports C99 (body of main). ac_c_conftest_c99_main=' // Check bool. _Bool success = false; success |= (argc != 0); // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[0] = argv[0][0]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' || dynamic_array[ni.number - 1] != 543); ' # Test code for whether the C compiler supports C11 (global declarations) ac_c_conftest_c11_globals=' // Does the compiler advertise C11 conformance? #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L # error "Compiler does not advertise C11 conformance" #endif // Check _Alignas. char _Alignas (double) aligned_as_double; char _Alignas (0) no_special_alignment; extern char aligned_as_int; char _Alignas (0) _Alignas (int) aligned_as_int; // Check _Alignof. enum { int_alignment = _Alignof (int), int_array_alignment = _Alignof (int[100]), char_alignment = _Alignof (char) }; _Static_assert (0 < -_Alignof (int), "_Alignof is signed"); // Check _Noreturn. int _Noreturn does_not_return (void) { for (;;) continue; } // Check _Static_assert. struct test_static_assert { int x; _Static_assert (sizeof (int) <= sizeof (long int), "_Static_assert does not work in struct"); long int y; }; // Check UTF-8 literals. #define u8 syntax error! char const utf8_literal[] = u8"happens to be ASCII" "another string"; // Check duplicate typedefs. typedef long *long_ptr; typedef long int *long_ptr; typedef long_ptr long_ptr; // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. struct anonymous { union { struct { int i; int j; }; struct { int k; long int l; } w; }; int m; } v1; ' # Test code for whether the C compiler supports C11 (body of main). ac_c_conftest_c11_main=' _Static_assert ((offsetof (struct anonymous, i) == offsetof (struct anonymous, w.k)), "Anonymous union alignment botch"); v1.i = 2; v1.w.k = 5; ok |= v1.i != 5; ' # Test code for whether the C compiler supports C11 (complete). ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} ${ac_c_conftest_c11_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} ${ac_c_conftest_c11_main} return ok; } " # Test code for whether the C compiler supports C99 (complete). ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} ${ac_c_conftest_c99_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} ${ac_c_conftest_c99_main} return ok; } " # Test code for whether the C compiler supports C89 (complete). ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} int main (int argc, char **argv) { int ok = 0; ${ac_c_conftest_c89_main} return ok; } " as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H" as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H" as_fn_append ac_header_c_list " vfork.h vfork_h HAVE_VFORK_H" as_fn_append ac_func_c_list " fork HAVE_FORK" as_fn_append ac_func_c_list " vfork HAVE_VFORK" # Auxiliary files required by this configure script. ac_aux_files="config.guess config.sub ltmain.sh" # Locations in which to look for auxiliary files. ac_aux_dir_candidates="${srcdir}${PATH_SEPARATOR}${srcdir}/..${PATH_SEPARATOR}${srcdir}/../.." # Search for a directory containing all of the required auxiliary files, # $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. # If we don't find one directory that contains all the files we need, # we report the set of missing files from the *first* directory in # $ac_aux_dir_candidates and give up. ac_missing_aux_files="" ac_first_candidate=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in $ac_aux_dir_candidates do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 ac_aux_dir_found=yes ac_install_sh= for ac_aux in $ac_aux_files do # As a special case, if "install-sh" is required, that requirement # can be satisfied by any of "install-sh", "install.sh", or "shtool", # and $ac_install_sh is set appropriately for whichever one is found. if test x"$ac_aux" = x"install-sh" then if test -f "${as_dir}install-sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 ac_install_sh="${as_dir}install-sh -c" elif test -f "${as_dir}install.sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 ac_install_sh="${as_dir}install.sh -c" elif test -f "${as_dir}shtool"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 ac_install_sh="${as_dir}shtool install -c" else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} install-sh" else break fi fi else if test -f "${as_dir}${ac_aux}"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" else break fi fi fi done if test "$ac_aux_dir_found" = yes; then ac_aux_dir="$as_dir" break fi ac_first_candidate=false as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. if test -f "${ac_aux_dir}config.guess"; then ac_config_guess="$SHELL ${ac_aux_dir}config.guess" fi if test -f "${ac_aux_dir}config.sub"; then ac_config_sub="$SHELL ${ac_aux_dir}config.sub" fi if test -f "$ac_aux_dir/configure"; then ac_configure="$SHELL ${ac_aux_dir}configure" fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # needed to build correct soname LDNS_VERSION_MAJOR=1 LDNS_VERSION_MINOR=9 LDNS_VERSION_MICRO=2 # Library version # --------------- # current:revision:age # (binary-api-number):(which-binary-api-version):(how-many-nrs-backwardscompat) # if source code changes increment revision # if any interfaces have been added/removed/changed since last update then # increment current and set revision to 0 # if any interfaces have been added since the last public release then increment age # if any interfaces have been removed or changed since the last public release then # set age to 0 # # ldns-1.6.17 and before had a .so with version same as VERSION_INFO # ldns-1.7.0 had libversion 2:0:0 # ldns-1.7.1 had libversion 3:0:0 (though it should have had 3:0:1) # ldns-1.8.0 had libversion 4:0:2 (though it should have had 4:0:1) # ldns-1.8.1 had libversion 5:0:2 # ldns-1.8.1 had libversion 6:0:3 # ldns-1.8.2 had libversion 7:0:4 # ldns-1.8.3 had libversion 8:0:5 # ldns-1.8.4 had libversion 9:0:6 # ldns-1.9.0 had libversion 9:0:6 (though it should have had 10:0:0) # ldns-1.9.1 had libversion 11:0:0 (but should have had 10:0:7 with 11:0:0 reserved for the ldns-1.10.0 release) # ldns-1.9.2 has libversion 12:0:9 # VERSION_INFO=12:0:9 ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. set dummy ${ac_tool_prefix}clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "clang", so it can be a program name with args. set dummy clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi fi test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 printf %s "checking whether the C compiler works... " >&6; } ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else $as_nop ac_file='' fi if test -z "$ac_file" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 printf %s "checking for C compiler default output file name... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi ac_prog_cc_stdc=no if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c11_program _ACEOF for ac_arg in '' -std=gnu11 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } CC="$CC $ac_cv_prog_cc_c11" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 ac_prog_cc_stdc=c11 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c99_program _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c99" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c99" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } CC="$CC $ac_cv_prog_cc_c99" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 ac_prog_cc_stdc=c99 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c89_program _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c89" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c89" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } CC="$CC $ac_cv_prog_cc_c89" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 ac_prog_cc_stdc=c89 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_header= ac_cache= for ac_item in $ac_header_c_list do if test $ac_cache; then ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then printf "%s\n" "#define $ac_item 1" >> confdefs.h fi ac_header= ac_cache= elif test $ac_header; then ac_cache=$ac_item else ac_header=$ac_item fi done if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes then : printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 printf %s "checking whether it is safe to define __EXTENSIONS__... " >&6; } if test ${ac_cv_safe_to_define___extensions__+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_safe_to_define___extensions__=yes else $as_nop ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 printf "%s\n" "$ac_cv_safe_to_define___extensions__" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5 printf %s "checking whether _XOPEN_SOURCE should be defined... " >&6; } if test ${ac_cv_should_define__xopen_source+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_should_define__xopen_source=no if test $ac_cv_header_wchar_h = yes then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include mbstate_t x; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _XOPEN_SOURCE 500 #include mbstate_t x; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_should_define__xopen_source=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5 printf "%s\n" "$ac_cv_should_define__xopen_source" >&6; } printf "%s\n" "#define _ALL_SOURCE 1" >>confdefs.h printf "%s\n" "#define _DARWIN_C_SOURCE 1" >>confdefs.h printf "%s\n" "#define _GNU_SOURCE 1" >>confdefs.h printf "%s\n" "#define _HPUX_ALT_XOPEN_SOCKET_API 1" >>confdefs.h printf "%s\n" "#define _NETBSD_SOURCE 1" >>confdefs.h printf "%s\n" "#define _OPENBSD_SOURCE 1" >>confdefs.h printf "%s\n" "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_IEC_60559_BFP_EXT__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_IEC_60559_DFP_EXT__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_LIB_EXT2__ 1" >>confdefs.h printf "%s\n" "#define __STDC_WANT_MATH_SPEC_FUNCS__ 1" >>confdefs.h printf "%s\n" "#define _TANDEM_SOURCE 1" >>confdefs.h if test $ac_cv_header_minix_config_h = yes then : MINIX=yes printf "%s\n" "#define _MINIX 1" >>confdefs.h printf "%s\n" "#define _POSIX_SOURCE 1" >>confdefs.h printf "%s\n" "#define _POSIX_1_SOURCE 2" >>confdefs.h else $as_nop MINIX= fi if test $ac_cv_safe_to_define___extensions__ = yes then : printf "%s\n" "#define __EXTENSIONS__ 1" >>confdefs.h fi if test $ac_cv_should_define__xopen_source = yes then : printf "%s\n" "#define _XOPEN_SOURCE 500" >>confdefs.h fi if test "$ac_cv_header_minix_config_h" = "yes"; then printf "%s\n" "#define _NETBSD_SOURCE 1" >>confdefs.h fi case `pwd` in *\ * | *\ *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.7' macro_revision='2.4.7' ltmain=$ac_aux_dir/ltmain.sh # Make sure we can run config.sub. $SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 printf %s "checking build system type... " >&6; } if test ${ac_cv_build+y} then : printf %s "(cached) " >&6 else $as_nop ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 printf "%s\n" "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 printf %s "checking host system type... " >&6; } if test ${ac_cv_host+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 printf "%s\n" "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 printf %s "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5 printf "%s\n" "printf" >&6; } ;; print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 printf "%s\n" "print -r" >&6; } ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5 printf "%s\n" "cat" >&6; } ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 printf %s "checking for a sed that does not truncate output... " >&6; } if test ${ac_cv_path_SED+y} then : printf %s "(cached) " >&6 else $as_nop ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in sed gsed do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 printf "%s\n" "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 printf %s "checking for grep that handles long lines and -e... " >&6; } if test ${ac_cv_path_GREP+y} then : printf %s "(cached) " >&6 else $as_nop if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in grep ggrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 printf "%s\n" "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 printf %s "checking for egrep... " >&6; } if test ${ac_cv_path_EGREP+y} then : printf %s "(cached) " >&6 else $as_nop if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in egrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 printf "%s\n" "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 printf %s "checking for fgrep... " >&6; } if test ${ac_cv_path_FGREP+y} then : printf %s "(cached) " >&6 else $as_nop if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in fgrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 printf "%s\n" "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test ${with_gnu_ld+y} then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else $as_nop with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 printf %s "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 printf %s "checking for GNU ld... " >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 printf %s "checking for non-GNU ld... " >&6; } fi if test ${lt_cv_path_LD+y} then : printf %s "(cached) " >&6 else $as_nop if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 printf "%s\n" "$LD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 printf %s "checking if the linker ($LD) is GNU ld... " >&6; } if test ${lt_cv_prog_gnu_ld+y} then : printf %s "(cached) " >&6 else $as_nop # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if test ${lt_cv_path_NM+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 printf "%s\n" "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DUMPBIN+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 printf "%s\n" "$DUMPBIN" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DUMPBIN+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 printf "%s\n" "$ac_ct_DUMPBIN" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 printf %s "checking the name lister ($NM) interface... " >&6; } if test ${lt_cv_nm_interface+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 printf "%s\n" "$lt_cv_nm_interface" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 printf %s "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 printf "%s\n" "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 printf %s "checking the maximum length of command line arguments... " >&6; } if test ${lt_cv_sys_max_cmd_len+y} then : printf %s "(cached) " >&6 else $as_nop i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 printf "%s\n" "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 printf %s "checking how to convert $build file names to $host format... " >&6; } if test ${lt_cv_to_host_file_cmd+y} then : printf %s "(cached) " >&6 else $as_nop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 printf %s "checking how to convert $build file names to toolchain format... " >&6; } if test ${lt_cv_to_tool_file_cmd+y} then : printf %s "(cached) " >&6 else $as_nop #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 printf %s "checking for $LD option to reload object files... " >&6; } if test ${lt_cv_ld_reload_flag+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ld_reload_flag='-r' fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 printf "%s\n" "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args. set dummy ${ac_tool_prefix}file; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_FILECMD+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$FILECMD"; then ac_cv_prog_FILECMD="$FILECMD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_FILECMD="${ac_tool_prefix}file" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi FILECMD=$ac_cv_prog_FILECMD if test -n "$FILECMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FILECMD" >&5 printf "%s\n" "$FILECMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_FILECMD"; then ac_ct_FILECMD=$FILECMD # Extract the first word of "file", so it can be a program name with args. set dummy file; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_FILECMD+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_FILECMD"; then ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_FILECMD="file" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD if test -n "$ac_ct_FILECMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5 printf "%s\n" "$ac_ct_FILECMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_FILECMD" = x; then FILECMD=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac FILECMD=$ac_ct_FILECMD fi else FILECMD="$ac_cv_prog_FILECMD" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OBJDUMP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 printf "%s\n" "$OBJDUMP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OBJDUMP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 printf "%s\n" "$ac_ct_OBJDUMP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 printf %s "checking how to recognize dependent libraries... " >&6; } if test ${lt_cv_deplibs_check_method+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='$FILECMD -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly* | midnightbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=$FILECMD case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 printf "%s\n" "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DLLTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 printf "%s\n" "$DLLTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DLLTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 printf "%s\n" "$ac_ct_DLLTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 printf %s "checking how to associate runtime and link libraries... " >&6; } if test ${lt_cv_sharedlib_from_linklib_cmd+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AR+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 printf "%s\n" "$AR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_AR+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 printf "%s\n" "$ac_ct_AR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} # Use ARFLAGS variable as AR's operation code to sync the variable naming with # Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have # higher priority because thats what people were doing historically (setting # ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS # variable obsoleted/removed. test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} lt_ar_flags=$AR_FLAGS # Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override # by AR_FLAGS because that was never working and AR_FLAGS is about to die. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 printf %s "checking for archiver @FILE support... " >&6; } if test ${lt_cv_ar_at_file+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 printf "%s\n" "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_STRIP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 printf "%s\n" "$STRIP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_STRIP+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 printf "%s\n" "$ac_ct_STRIP" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_RANLIB+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 printf "%s\n" "$RANLIB" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_RANLIB+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 printf "%s\n" "$ac_ct_RANLIB" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_AWK+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 printf "%s\n" "$AWK" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$AWK" && break done # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 printf %s "checking command to parse $NM output from $compiler object... " >&6; } if test ${lt_cv_sys_global_symbol_pipe+y} then : printf %s "(cached) " >&6 else $as_nop # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++ or ICC, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 printf "%s\n" "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 printf %s "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test ${with_sysroot+y} then : withval=$with_sysroot; else $as_nop with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 printf "%s\n" "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 printf "%s\n" "${lt_sysroot:-no}" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 printf %s "checking for a working dd... " >&6; } if test ${ac_cv_path_lt_DD+y} then : printf %s "(cached) " >&6 else $as_nop printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} if test -z "$lt_DD"; then ac_path_lt_DD_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in dd do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi $ac_path_lt_DD_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_lt_DD"; then : fi else ac_cv_path_lt_DD=$lt_DD fi rm -f conftest.i conftest2.i conftest.out fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 printf "%s\n" "$ac_cv_path_lt_DD" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 printf %s "checking how to truncate binary pipes... " >&6; } if test ${lt_cv_truncate_bin+y} then : printf %s "(cached) " >&6 else $as_nop printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 printf "%s\n" "$lt_cv_truncate_bin" >&6; } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # Check whether --enable-libtool-lock was given. if test ${enable_libtool_lock+y} then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `$FILECMD conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `$FILECMD conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `$FILECMD conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `$FILECMD conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `$FILECMD conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `$FILECMD conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 printf %s "checking whether the C compiler needs -belf... " >&6; } if test ${lt_cv_cc_needs_belf+y} then : printf %s "(cached) " >&6 else $as_nop ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_cv_cc_needs_belf=yes else $as_nop lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `$FILECMD conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_MANIFEST_TOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 printf "%s\n" "$MANIFEST_TOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if test ${lt_cv_path_mainfest_tool+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_DSYMUTIL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 printf "%s\n" "$DSYMUTIL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_DSYMUTIL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 printf "%s\n" "$ac_ct_DSYMUTIL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_NMEDIT+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 printf "%s\n" "$NMEDIT" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_NMEDIT+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 printf "%s\n" "$ac_ct_NMEDIT" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_LIPO+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 printf "%s\n" "$LIPO" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_LIPO+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 printf "%s\n" "$ac_ct_LIPO" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 printf "%s\n" "$OTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OTOOL+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 printf "%s\n" "$ac_ct_OTOOL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_OTOOL64+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 printf "%s\n" "$OTOOL64" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_OTOOL64+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 printf "%s\n" "$ac_ct_OTOOL64" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 printf %s "checking for -single_module linker flag... " >&6; } if test ${lt_cv_apple_cc_single_mod+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 printf %s "checking for -exported_symbols_list linker flag... " >&6; } if test ${lt_cv_ld_exported_symbols_list+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_cv_ld_exported_symbols_list=yes else $as_nop lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 printf %s "checking for -force_load linker flag... " >&6; } if test ${lt_cv_ld_force_load+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5 $AR $AR_FLAGS libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 printf "%s\n" "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) case $MACOSX_DEPLOYMENT_TARGET,$host in 10.[012],*|,*powerpc*-darwin[5-8]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; *) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes then : printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h fi # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test ${enable_shared+y} then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop enable_shared=yes fi # Check whether --enable-static was given. if test ${enable_static+y} then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop enable_static=yes fi # Check whether --with-pic was given. if test ${with_pic+y} then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop pic_mode=default fi # Check whether --enable-fast-install was given. if test ${enable_fast_install+y} then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else $as_nop enable_fast_install=yes fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 printf %s "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. if test ${with_aix_soname+y} then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; *) as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 ;; esac lt_cv_with_aix_soname=$with_aix_soname else $as_nop if test ${lt_cv_with_aix_soname+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 printf "%s\n" "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 printf %s "checking for objdir... " >&6; } if test ${lt_cv_objdir+y} then : printf %s "(cached) " >&6 else $as_nop rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 printf "%s\n" "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC and # ICC, which need '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o func_cc_basename $compiler cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 printf %s "checking for ${ac_tool_prefix}file... " >&6; } if test ${lt_cv_path_MAGIC_CMD+y} then : printf %s "(cached) " >&6 else $as_nop case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 printf "%s\n" "$MAGIC_CMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5 printf %s "checking for file... " >&6; } if test ${lt_cv_path_MAGIC_CMD+y} then : printf %s "(cached) " >&6 else $as_nop case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 printf "%s\n" "$MAGIC_CMD" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if test ${lt_cv_prog_compiler_rtti_exceptions+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # flang / f18. f95 an alias for gfortran or flang on Debian flang* | f18* | f95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | $SED 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 printf %s "checking for $compiler option to produce PIC... " >&6; } if test ${lt_cv_prog_compiler_pic+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if test ${lt_cv_prog_compiler_pic_works+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if test ${lt_cv_prog_compiler_static_works+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test ${lt_cv_prog_compiler_c_o+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if test ${lt_cv_prog_compiler_c_o+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 printf %s "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 printf "%s\n" "$hard_links" >&6; } if test no = "$hard_links"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes file_list_spec='@' ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct=no hardcode_direct_absolute=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if test ${lt_cv_aix_libpath_+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if test ${lt_cv_aix_libpath_+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl* | icl*) # Native MSVC or ICC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC and ICC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly* | midnightbsd*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 printf %s "checking if $CC understands -b... " >&6; } if test ${lt_cv_prog_compiler__b+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 printf "%s\n" "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if test ${lt_cv_irix_exported_symbol+y} then : printf %s "(cached) " >&6 else $as_nop save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : lt_cv_irix_exported_symbol=yes else $as_nop lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi link_all_deplibs=no else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes file_list_spec='@' ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 printf "%s\n" "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 printf %s "checking whether -lc should be explicitly linked in... " >&6; } if test ${lt_cv_archive_cmds_need_lc+y} then : printf %s "(cached) " >&6 else $as_nop $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 printf %s "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl* | *,icl*) # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly* | midnightbsd*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if test ${lt_cv_shlibpath_overrides_runpath+y} then : printf %s "(cached) " >&6 else $as_nop lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 printf "%s\n" "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 printf %s "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 printf "%s\n" "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 printf %s "checking for dlopen in -ldl... " >&6; } if test ${ac_cv_lib_dl_dlopen+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char dlopen (); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dl_dlopen=yes else $as_nop ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else $as_nop lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes then : lt_cv_dlopen=shl_load else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 printf %s "checking for shl_load in -ldld... " >&6; } if test ${ac_cv_lib_dld_shl_load+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char shl_load (); int main (void) { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dld_shl_load=yes else $as_nop ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else $as_nop ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes then : lt_cv_dlopen=dlopen else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 printf %s "checking for dlopen in -ldl... " >&6; } if test ${ac_cv_lib_dl_dlopen+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char dlopen (); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dl_dlopen=yes else $as_nop ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 printf %s "checking for dlopen in -lsvld... " >&6; } if test ${ac_cv_lib_svld_dlopen+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char dlopen (); int main (void) { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_svld_dlopen=yes else $as_nop ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 printf %s "checking for dld_link in -ldld... " >&6; } if test ${ac_cv_lib_dld_dld_link+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char dld_link (); int main (void) { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dld_dld_link=yes else $as_nop ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 printf %s "checking whether a program can dlopen itself... " >&6; } if test ${lt_cv_dlopen_self+y} then : printf %s "(cached) " >&6 else $as_nop if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 printf "%s\n" "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 printf %s "checking whether a statically linked program can dlopen itself... " >&6; } if test ${lt_cv_dlopen_self_static+y} then : printf %s "(cached) " >&6 else $as_nop if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 printf "%s\n" "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 printf %s "checking whether stripping libraries is possible... " >&6; } if test -z "$STRIP"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } else if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then old_striplib="$STRIP --strip-debug" striplib="$STRIP --strip-unneeded" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else case $host_os in darwin*) # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } ;; freebsd*) if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then old_striplib="$STRIP --strip-debug" striplib="$STRIP --strip-unneeded" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi ;; *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } ;; esac fi fi # Report what library types will actually be built { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 printf %s "checking if libtool supports shared libraries... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 printf "%s\n" "$can_build_shared" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 printf %s "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 printf "%s\n" "$enable_shared" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 printf %s "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 printf "%s\n" "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC ac_config_commands="$ac_config_commands libtool" # Only expand once: OURCPPFLAGS='' CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}} CFLAGS="$CFLAGS" # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. set dummy ${ac_tool_prefix}clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "clang", so it can be a program name with args. set dummy clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi fi test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi ac_prog_cc_stdc=no if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c11_program _ACEOF for ac_arg in '' -std=gnu11 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c11" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c11" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } CC="$CC $ac_cv_prog_cc_c11" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 ac_prog_cc_stdc=c11 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c99_program _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c99" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c99" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } CC="$CC $ac_cv_prog_cc_c99" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 ac_prog_cc_stdc=c99 fi fi if test x$ac_prog_cc_stdc = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_c_conftest_c89_program _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi if test "x$ac_cv_prog_cc_c89" = xno then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } else $as_nop if test "x$ac_cv_prog_cc_c89" = x then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } CC="$CC $ac_cv_prog_cc_c89" fi ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 ac_prog_cc_stdc=c89 fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking $CC dependency flag" >&5 printf %s "checking $CC dependency flag... " >&6; } echo 'void f(void){}' >conftest.c if test "`$CC -MM conftest.c 2>&1`" = "conftest.o: conftest.c"; then DEPFLAG="-MM" else if test "`$CC -xM1 conftest.c 2>&1`" = "conftest.o: conftest.c"; then DEPFLAG="-xM1" else DEPFLAG="-MM" # dunno do something fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DEPFLAG" >&5 printf "%s\n" "$DEPFLAG" >&6; } rm -f conftest.c { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval test \${ac_cv_prog_make_${ac_make}_set+y} then : printf %s "(cached) " >&6 else $as_nop cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } SET_MAKE= else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi # Extra (sp)lint flags for NetBSD case "$host_os" in netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS" ;; *) LINTFLAGS="$LINTFLAGS" ;; esac printf "%s\n" "#define WINVER 0x0502" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -std=c99" >&5 printf %s "checking whether $CC supports -std=c99... " >&6; } cache=`echo std=c99 | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -std=c99 -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : C99FLAG="-std=c99" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -xc99" >&5 printf %s "checking whether $CC supports -xc99... " >&6; } cache=`echo xc99 | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -xc99 -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : C99FLAG="-xc99" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi # routine to copy files # argument 1 is a list of files (relative to the source dir) # argument 2 is a destination directory (relative to the current # working directory # copy all .h files in the dir at argument 1 # (relative to source) to the dir at argument 2 # (relative to current dir) # Checks for typedefs, structures, and compiler characteristics. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 printf %s "checking for an ANSI C-conforming const... " >&6; } if test ${ac_cv_c_const+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* IBM XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_const=yes else $as_nop ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 printf "%s\n" "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then printf "%s\n" "#define const /**/" >>confdefs.h fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "x$CFLAGS" = "x" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -g" >&5 printf %s "checking whether $CC supports -g... " >&6; } cache=`echo g | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -g -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-g" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -O2" >&5 printf %s "checking whether $CC supports -O2... " >&6; } cache=`echo O2 | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -O2 -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-O2 $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wall" >&5 printf %s "checking whether $CC supports -Wall... " >&6; } cache=`echo Wall | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wall -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-Wall $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -W" >&5 printf %s "checking whether $CC supports -W... " >&6; } cache=`echo W | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -W -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-W $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wwrite-strings" >&5 printf %s "checking whether $CC supports -Wwrite-strings... " >&6; } cache=`echo Wwrite-strings | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wwrite-strings -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-Wwrite-strings $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wstrict-prototypes" >&5 printf %s "checking whether $CC supports -Wstrict-prototypes... " >&6; } cache=`echo Wstrict-prototypes | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wstrict-prototypes -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-Wstrict-prototypes $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi #ACX_CHECK_COMPILER_FLAG(Wshadow, [CFLAGS="-Wshadow $CFLAGS"]) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wunused-function" >&5 printf %s "checking whether $CC supports -Wunused-function... " >&6; } cache=`echo Wunused-function | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wunused-function -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-Wunused-function $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wmissing-prototypes" >&5 printf %s "checking whether $CC supports -Wmissing-prototypes... " >&6; } cache=`echo Wmissing-prototypes | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wmissing-prototypes -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-Wmissing-prototypes $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fno-strict-aliasing" >&5 printf %s "checking whether $CC supports -fno-strict-aliasing... " >&6; } cache=`echo fno-strict-aliasing | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -fno-strict-aliasing -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="-fno-strict-aliasing $CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi ac_fn_c_check_header_compile "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default " if test "x$ac_cv_header_getopt_h" = xyes then : printf "%s\n" "#define HAVE_GETOPT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default " if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi # MinGW32 tests ac_fn_c_check_header_compile "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default " if test "x$ac_cv_header_winsock2_h" = xyes then : printf "%s\n" "#define HAVE_WINSOCK2_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "ws2tcpip.h" "ac_cv_header_ws2tcpip_h" "$ac_includes_default " if test "x$ac_cv_header_ws2tcpip_h" = xyes then : printf "%s\n" "#define HAVE_WS2TCPIP_H 1" >>confdefs.h fi # end mingw32 tests # Check for Apple header. This uncovers TARGET_OS_IPHONE, TARGET_OS_TV or TARGET_OS_WATCH ac_fn_c_check_header_compile "$LINENO" "TargetConditionals.h" "ac_cv_header_TargetConditionals_h" "$ac_includes_default" if test "x$ac_cv_header_TargetConditionals_h" = xyes then : printf "%s\n" "#define HAVE_TARGETCONDITIONALS_H 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Werror" >&5 printf %s "checking whether $CC supports -Werror... " >&6; } cache=`echo Werror | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Werror -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : ERRFLAG="-Werror" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : ERRFLAG="-errwarn" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wall" >&5 printf %s "checking whether $CC supports -Wall... " >&6; } cache=`echo Wall | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wall -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : ERRFLAG="$ERRFLAG -Wall" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : ERRFLAG="$ERRFLAG -errfmt" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -std=c99" >&5 printf %s "checking whether $CC supports -std=c99... " >&6; } cache=`echo std=c99 | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -std=c99 -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : C99FLAG="-std=c99" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -xc99" >&5 printf %s "checking whether $CC supports -xc99... " >&6; } cache=`echo xc99 | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -xc99 -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : C99FLAG="-xc99" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi ac_fn_c_check_header_compile "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default " if test "x$ac_cv_header_getopt_h" = xyes then : printf "%s\n" "#define HAVE_GETOPT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default " if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE as a flag for $CC" >&5 printf %s "checking whether we need $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE as a flag for $CC... " >&6; } cache=`printf "%s\n" "$C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE" | $as_tr_sh` if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include "confdefs.h" #include #include #include #ifdef HAVE_TIME_H #include #endif #include #include #ifdef HAVE_GETOPT_H #include #endif int test(void) { int a; char **opts = NULL; struct timeval tv; char *t; time_t time = 0; char *buf = NULL; const char* str = NULL; struct msghdr msg; msg.msg_control = 0; t = ctime_r(&time, buf); tv.tv_usec = 10; srandom(32); a = getopt(2, opts, "a"); a = isascii(32); str = gai_strerror(0); if(str && t && tv.tv_usec && msg.msg_control) a = 0; return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE as a flag for $CC" >&5 printf %s "checking whether we need $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE as a flag for $CC... " >&6; } cache=`printf "%s\n" "$C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE" | $as_tr_sh` if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include "confdefs.h" #include #include #include #ifdef HAVE_TIME_H #include #endif #include #include #ifdef HAVE_GETOPT_H #include #endif int test(void) { int a; char **opts = NULL; struct timeval tv; char *t; time_t time = 0; char *buf = NULL; const char* str = NULL; struct msghdr msg; msg.msg_control = 0; t = ctime_r(&time, buf); tv.tv_usec = 10; srandom(32); a = getopt(2, opts, "a"); a = isascii(32); str = gai_strerror(0); if(str && t && tv.tv_usec && msg.msg_control) a = 0; return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need $C99FLAG as a flag for $CC" >&5 printf %s "checking whether we need $C99FLAG as a flag for $CC... " >&6; } cache=`printf "%s\n" "$C99FLAG" | $as_tr_sh` if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include #include int test(void) { int a = 0; return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS $C99FLAG $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $C99FLAG $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $C99FLAG $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS $C99FLAG" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS $C99FLAG $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS $C99FLAG $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need -D_BSD_SOURCE -D_DEFAULT_SOURCE as a flag for $CC" >&5 printf %s "checking whether we need -D_BSD_SOURCE -D_DEFAULT_SOURCE as a flag for $CC... " >&6; } cache=_D_BSD_SOURCE__D_DEFAULT_SOURCE if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include int test(void) { int a; a = isascii(32); return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need -D_GNU_SOURCE as a flag for $CC" >&5 printf %s "checking whether we need -D_GNU_SOURCE as a flag for $CC... " >&6; } cache=_D_GNU_SOURCE if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include int test(void) { struct in6_pktinfo inf; int a = (int)sizeof(inf); return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS -D_GNU_SOURCE" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi # check again for GNU_SOURCE for setresgid. May fail if setresgid # is not available at all. -D_FRSRESGID is to make this check unique. # otherwise we would get the previous cached result. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need -D_GNU_SOURCE -D_FRSRESGID as a flag for $CC" >&5 printf %s "checking whether we need -D_GNU_SOURCE -D_FRSRESGID as a flag for $CC... " >&6; } cache=_D_GNU_SOURCE__D_FRSRESGID if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include int test(void) { int a = setresgid(0,0,0); a = setresuid(0,0,0); return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE -D_FRSRESGID $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE -D_FRSRESGID $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE -D_FRSRESGID $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS -D_GNU_SOURCE" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE -D_FRSRESGID $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_GNU_SOURCE -D_FRSRESGID $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need -D_POSIX_C_SOURCE=200112 as a flag for $CC" >&5 printf %s "checking whether we need -D_POSIX_C_SOURCE=200112 as a flag for $CC... " >&6; } cache=_D_POSIX_C_SOURCE_200112 if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include "confdefs.h" #ifdef HAVE_TIME_H #include #endif #include int test(void) { int a = 0; char *t; time_t time = 0; char *buf = NULL; const char* str = NULL; t = ctime_r(&time, buf); str = gai_strerror(0); if(t && str) a = 0; return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS -D_POSIX_C_SOURCE=200112 $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_POSIX_C_SOURCE=200112 $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_POSIX_C_SOURCE=200112 $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D_POSIX_C_SOURCE=200112 $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D_POSIX_C_SOURCE=200112 $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we need -D__EXTENSIONS__ as a flag for $CC" >&5 printf %s "checking whether we need -D__EXTENSIONS__ as a flag for $CC... " >&6; } cache=_D__EXTENSIONS__ if eval test \${cv_prog_cc_flag_needed_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo ' #include "confdefs.h" #include #include #include #ifdef HAVE_TIME_H #include #endif #include #ifdef HAVE_GETOPT_H #include #endif int test(void) { int a; char **opts = NULL; struct timeval tv; tv.tv_usec = 10; srandom(32); a = getopt(2, opts, "a"); a = isascii(32); if(tv.tv_usec) a = 0; return a; } ' > conftest.c echo 'void f(void){}' >>conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=no" else if test -z "`$CC $CPPFLAGS $CFLAGS -D__EXTENSIONS__ $ERRFLAG -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_needed_$cache=yes" else eval "cv_prog_cc_flag_needed_$cache=fail" #echo 'Test with flag fails too!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D__EXTENSIONS__ $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D__EXTENSIONS__ $ERRFLAG -c conftest.c 2>&1` #exit 1 fi fi rm -f conftest conftest.c conftest.o fi if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : CFLAGS="$CFLAGS -D__EXTENSIONS__" else if eval "test \"`echo '$cv_prog_cc_flag_needed_'$cache`\" = no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } #echo 'Test with flag is no!' #cat conftest.c #echo "$CC $CPPFLAGS $CFLAGS -D__EXTENSIONS__ $ERRFLAG -c conftest.c 2>&1" #echo `$CC $CPPFLAGS $CFLAGS -D__EXTENSIONS__ $ERRFLAG -c conftest.c 2>&1` #exit 1 : else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } : fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 printf %s "checking for inline... " >&6; } if test ${ac_cv_c_inline+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo (void) {return 0; } $ac_kw foo_t foo (void) {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 printf "%s\n" "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default" if test "x$ac_cv_type_int8_t" = xyes then : else $as_nop printf "%s\n" "#define int8_t char" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default" if test "x$ac_cv_type_int16_t" = xyes then : else $as_nop printf "%s\n" "#define int16_t short" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default" if test "x$ac_cv_type_int32_t" = xyes then : else $as_nop printf "%s\n" "#define int32_t int" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_default" if test "x$ac_cv_type_int64_t" = xyes then : else $as_nop printf "%s\n" "#define int64_t long long" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default" if test "x$ac_cv_type_uint8_t" = xyes then : else $as_nop printf "%s\n" "#define uint8_t unsigned char" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default" if test "x$ac_cv_type_uint16_t" = xyes then : else $as_nop printf "%s\n" "#define uint16_t unsigned short" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default" if test "x$ac_cv_type_uint32_t" = xyes then : else $as_nop printf "%s\n" "#define uint32_t unsigned int" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "$ac_includes_default" if test "x$ac_cv_type_uint64_t" = xyes then : else $as_nop printf "%s\n" "#define uint64_t unsigned long long" >>confdefs.h fi # my own checks # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_doxygen+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$doxygen"; then ac_cv_prog_doxygen="$doxygen" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_doxygen="doxygen" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi doxygen=$ac_cv_prog_doxygen if test -n "$doxygen"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $doxygen" >&5 printf "%s\n" "$doxygen" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi # check to see if libraries are needed for these functions. ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket" if test "x$ac_cv_func_socket" = xyes then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 printf %s "checking for library containing socket... " >&6; } if test ${ac_cv_search_socket+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char socket (); int main (void) { return socket (); ; return 0; } _ACEOF for ac_lib in '' socket do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_socket=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_socket+y} then : break fi done if test ${ac_cv_search_socket+y} then : else $as_nop ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 printf "%s\n" "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi # modern Linux provides inet_ntop in -lsocket. # modern OS X provides inet_ntop in -lc. # modern Solaris provides inet_ntop in -lsocket -lnsl. # older Solaris provides inet_ntop in -lresolv. # Windows provides inet_ntop in -lws2_32. ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" if test "x$ac_cv_func_inet_ntop" = xyes then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing inet_ntop" >&5 printf %s "checking for library containing inet_ntop... " >&6; } if test ${ac_cv_search_inet_ntop+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char inet_ntop (); int main (void) { return inet_ntop (); ; return 0; } _ACEOF for ac_lib in '' socket c nsl resolv ws2_32 do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_inet_ntop=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_inet_ntop+y} then : break fi done if test ${ac_cv_search_inet_ntop+y} then : else $as_nop ac_cv_search_inet_ntop=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_ntop" >&5 printf "%s\n" "$ac_cv_search_inet_ntop" >&6; } ac_res=$ac_cv_search_inet_ntop if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ac_cv_func_inet_ntop=yes fi fi # modern Linux provides inet_pton in -lsocket. # modern OS X provides inet_pton in -lc. # modern Solaris provides inet_pton in -lsocket -lnsl. # older Solaris provides inet_pton in -lresolv. # Windows provides inet_pton in -lws2_32. ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes then : else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing inet_pton" >&5 printf %s "checking for library containing inet_pton... " >&6; } if test ${ac_cv_search_inet_pton+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char inet_pton (); int main (void) { return inet_pton (); ; return 0; } _ACEOF for ac_lib in '' socket c nsl resolv ws2_32 do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_inet_pton=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_inet_pton+y} then : break fi done if test ${ac_cv_search_inet_pton+y} then : else $as_nop ac_cv_search_inet_pton=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_pton" >&5 printf "%s\n" "$ac_cv_search_inet_pton" >&6; } ac_res=$ac_cv_search_inet_pton if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" ac_cv_func_inet_pton=yes fi fi # Check whether --with-drill was given. if test ${with_drill+y} then : withval=$with_drill; else $as_nop with_drill="no" fi if test x_$with_drill != x_no ; then DRILL=drill INSTALL_DRILL=install-drill UNINSTALL_DRILL=uninstall-drill CLEAN_DRILL=clean-drill LINT_DRILL=lint-drill if test -e $srcdir/drill/config.h -o -e drill/config.h ; then as_fn_error $? " A config.h was detected in the drill subdirectory. This does not work with the --with-drill option. Please remove the config.h from the drill subdirectory or do not use the --with-drill option." "$LINENO" 5 fi else DRILL="" INSTALL_DRILL="" UNINSTALL_DRILL="" CLEAN_DRILL="" LINT_DRILL="" fi # Check whether --with-examples was given. if test ${with_examples+y} then : withval=$with_examples; else $as_nop with_examples="no" fi if test x_$with_examples != x_no ; then EXAMPLES=examples INSTALL_EXAMPLES=install-examples UNINSTALL_EXAMPLES=uninstall-examples CLEAN_EXAMPLES=clean-examples LINT_EXAMPLES=lint-examples if test -e $srcdir/examples/config.h -o -e examples/config.h ; then as_fn_error $? " A config.h was detected in the examples subdirectory. This does not work with the --with-examples option. Please remove the config.h from the examples subdirectory or do not use the --with-examples option." "$LINENO" 5 fi else EXAMPLES="" INSTALL_EXAMPLES="" UNINSTALL_EXAMPLES="" CLEAN_EXAMPLES="" LINT_EXAMPLES="" fi # add option to disable installation of ldns-config script # Check whether --enable-ldns-config was given. if test ${enable_ldns_config+y} then : enableval=$enable_ldns_config; enable_ldns_config=$enableval else $as_nop enable_ldns_config=yes fi if test "x$enable_ldns_config" = xyes; then INSTALL_CONFIG=install-config INSTALL_CONFIG_MANPAGE=install-config-manpage UNINSTALL_CONFIG=uninstall-config UNINSTALL_CONFIG_MANPAGE=uninstall-config-manpage else INSTALL_CONFIG="" INSTALL_CONFIG_MANPAGE="" UNINSTALL_CONFIG="" UNINSTALL_CONFIG_MANPAGE="" fi # add option to disable library printing to stderr # Check whether --enable-stderr-msgs was given. if test ${enable_stderr_msgs+y} then : enableval=$enable_stderr_msgs; enable_stderr_msgs=$enableval else $as_nop enable_stderr_msgs=no fi case "$enable_stderr_msgs" in no) ;; *) printf "%s\n" "#define STDERR_MSGS 1" >>confdefs.h ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for poll(2)" >&5 printf %s "checking for poll(2)... " >&6; } if test ${ax_cv_have_poll+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { int rc; rc = poll((struct pollfd *)(0), 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ax_cv_have_poll=yes else $as_nop ax_cv_have_poll=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi if test "${ax_cv_have_poll}" = "yes" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } ax_config_feature_poll=yes else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } ax_config_feature_poll=no fi # Check whether --enable-poll was given. if test ${enable_poll+y} then : enableval=$enable_poll; case "${enableval}" in yes) ax_config_feature_poll="yes" ;; no) ax_config_feature_poll="no" ;; *) as_fn_error $? "bad value ${enableval} for feature --poll" "$LINENO" 5 ;; esac fi if test "$ax_config_feature_poll" = yes then : printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h if test "$ax_config_feature_verbose" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Feature poll is enabled" >&5 printf "%s\n" "$as_me: Feature poll is enabled" >&6;} fi else $as_nop if test "$ax_config_feature_verbose" = yes then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Feature poll is disabled" >&5 printf "%s\n" "$as_me: Feature poll is disabled" >&6;} fi fi # check for python PYTHON_X_CFLAGS="" ldns_with_pyldns=no ldns_with_pyldnsx=no # Check whether --with-pyldns was given. if test ${with_pyldns+y} then : withval=$with_pyldns; else $as_nop withval="no" fi ldns_have_python=no if test x_$withval != x_no; then # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_python_devel.html # =========================================================================== # # SYNOPSIS # # AX_PYTHON_DEVEL([version]) # # DESCRIPTION # # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it # in your configure.ac. # # This macro checks for Python and tries to get the include path to # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output # variables. It also exports $(PYTHON_EXTRA_LIBS) and # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. # # You can search for some particular version of Python by passing a # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please # note that you *have* to pass also an operator along with the version to # match, and pay special attention to the single quotes surrounding the # version number. Don't use "PYTHON_VERSION" for this: that environment # variable is declared as precious and thus reserved for the end-user. # # This macro should work for all versions of Python >= 2.1.0. As an end # user, you can disable the check for the python version by setting the # PYTHON_NOVERSIONCHECK environment variable to something else than the # empty string. # # If you need to use this macro for an older Python version, please # contact the authors. We're always open for feedback. # # LICENSE # # Copyright (c) 2009 Sebastian Huber # Copyright (c) 2009 Alan W. Irwin # Copyright (c) 2009 Rafael Laboissiere # Copyright (c) 2009 Andrew Collier # Copyright (c) 2009 Matteo Settenvini # Copyright (c) 2009 Horst Knorr # Copyright (c) 2013 Daniel Mullner # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 32 # This is what autoupdate's m4 run will expand. It fires the warning # (with _au_warn_XXX), outputs it into the updated configure.ac (with # m4_warn), and then outputs the replacement expansion. We need extra # quotation around the m4_warn and dnl so they will be written # unexpanded into the updated configure.ac. # This is an auxiliary macro that is also run when # autoupdate runs m4. It simply calls m4_warning, but # we need a wrapper so that each warning is emitted only # once. We break the quoting in m4_warning's argument in # order to expand this macro's arguments, not AU_DEFUN's. # Finally, this is the expansion that is picked up by # autoconf, causing NAME to expand to NEW-CODE, plus # (if SILENT is not "silent") a m4_warning telling the # maintainer to run autoupdate. We don't issue MESSAGE # from autoconf, because that's instructions for what # to do *after* running autoupdate. ac_save_LIBS="$LIBS" # # Allow the use of a (user set) custom python version # # Extract the first word of "python[$PYTHON_VERSION]", so it can be a program name with args. set dummy python$PYTHON_VERSION; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_PYTHON+y} then : printf %s "(cached) " >&6 else $as_nop case $PYTHON in [\\/]* | ?:[\\/]*) ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_PYTHON="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PYTHON=$ac_cv_path_PYTHON if test -n "$PYTHON"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 printf "%s\n" "$PYTHON" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test -z "$PYTHON"; then as_fn_error $? "Cannot find python$PYTHON_VERSION in your system path" "$LINENO" 5 PYTHON_VERSION="" fi # # Check for a version of Python >= 2.1.0 # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a version of Python >= '2.1.0'" >&5 printf %s "checking for a version of Python >= '2.1.0'... " >&6; } ac_supports_python_ver=`$PYTHON -c "import sys; \ ver = sys.version.split ()[0]; \ print (ver >= '2.1.0')"` if test "$ac_supports_python_ver" != "True"; then if test -z "$PYTHON_NOVERSIONCHECK"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? " This version of the AC_PYTHON_DEVEL macro doesn't work properly with versions of Python before 2.1.0. You may need to re-run configure, setting the variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG, PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. Moreover, to disable this check, set PYTHON_NOVERSIONCHECK to something else than an empty string. See \`config.log' for more details" "$LINENO" 5; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: skip at user request" >&5 printf "%s\n" "skip at user request" >&6; } fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi # # If the macro parameter ``version'' is set, honour it. # A Python shim class, VPy, is used to implement correct version comparisons via # string expressions, since e.g. a naive textual ">= 2.7.3" won't work for # Python 2.7.10 (the ".1" being evaluated as less than ".3"). # if test -n ">= '2.4.0'"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a version of Python >= '2.4.0'" >&5 printf %s "checking for a version of Python >= '2.4.0'... " >&6; } cat << EOF > ax_python_devel_vpy.py class VPy: def vtup(self, s): return tuple(map(int, s.strip().replace("rc", ".").split("."))) def __init__(self): import sys self.vpy = tuple(sys.version_info) def __eq__(self, s): return self.vpy == self.vtup(s) def __ne__(self, s): return self.vpy != self.vtup(s) def __lt__(self, s): return self.vpy < self.vtup(s) def __gt__(self, s): return self.vpy > self.vtup(s) def __le__(self, s): return self.vpy <= self.vtup(s) def __ge__(self, s): return self.vpy >= self.vtup(s) EOF ac_supports_python_ver=`$PYTHON -c "import ax_python_devel_vpy; \ ver = ax_python_devel_vpy.VPy(); \ print (ver >= '2.4.0')"` rm -rf ax_python_devel_vpy*.py* __pycache__/ax_python_devel_vpy*.py* if test "$ac_supports_python_ver" = "True"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "this package requires Python >= '2.4.0'. If you have it installed, but it isn't the default Python interpreter in your system path, please pass the PYTHON_VERSION variable to configure. See \`\`configure --help'' for reference. " "$LINENO" 5 PYTHON_VERSION="" fi fi # # Check if you have distutils, else fail # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the sysconfig Python package" >&5 printf %s "checking for the sysconfig Python package... " >&6; } ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1` if test $? -eq 0; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } IMPORT_SYSCONFIG="import sysconfig" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the distutils Python package" >&5 printf %s "checking for the distutils Python package... " >&6; } ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1` if test $? -eq 0; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } IMPORT_SYSCONFIG="from distutils import sysconfig" else as_fn_error $? "cannot import Python module \"distutils\". Please check your Python installation. The error was: $ac_sysconfig_result" "$LINENO" 5 PYTHON_VERSION="" fi fi # # Check for Python include path # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python include path" >&5 printf %s "checking for Python include path... " >&6; } if test -z "$PYTHON_CPPFLAGS"; then if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then # sysconfig module has different functions python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_path ('include'));"` plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_path ('platinclude'));"` else # old distutils way python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_python_inc ());"` plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_python_inc (plat_specific=1));"` fi if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" else python_path="-I$python_path" fi fi PYTHON_CPPFLAGS=$python_path fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CPPFLAGS" >&5 printf "%s\n" "$PYTHON_CPPFLAGS" >&6; } # # Check for Python library path # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python library path" >&5 printf %s "checking for Python library path... " >&6; } if test -z "$PYTHON_LIBS"; then # (makes two attempts to ensure we've got a version number # from the interpreter) ac_python_version=`cat<>confdefs.h # First, the library directory: ac_python_libdir=`cat<&5 printf "%s\n" "$PYTHON_LIBS" >&6; } # # Check for site packages # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python site-packages path" >&5 printf %s "checking for Python site-packages path... " >&6; } if test -z "$PYTHON_SITE_PKG"; then if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then PYTHON_SITE_PKG=`$PYTHON -c " $IMPORT_SYSCONFIG; if hasattr(sysconfig, 'get_default_scheme'): scheme = sysconfig.get_default_scheme() else: scheme = sysconfig._get_default_scheme() if scheme == 'posix_local': # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/ scheme = 'posix_prefix' prefix = '$prefix' if prefix == 'NONE': prefix = '$ac_default_prefix' sitedir = sysconfig.get_path('purelib', scheme, vars={'base': prefix}) print(sitedir)"` else # distutils.sysconfig way PYTHON_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_python_lib(0,0));"` fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_SITE_PKG" >&5 printf "%s\n" "$PYTHON_SITE_PKG" >&6; } # # Check for platform-specific site packages # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Python platform specific site-packages path" >&5 printf %s "checking for Python platform specific site-packages path... " >&6; } if test -z "$PYTHON_PLATFORM_SITE_PKG"; then if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c " $IMPORT_SYSCONFIG; if hasattr(sysconfig, 'get_default_scheme'): scheme = sysconfig.get_default_scheme() else: scheme = sysconfig._get_default_scheme() if scheme == 'posix_local': # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/ scheme = 'posix_prefix' prefix = '$prefix' if prefix == 'NONE': prefix = '$ac_default_prefix' sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase': prefix}) print(sitedir)"` else # distutils.sysconfig way PYTHON_PLATFORM_SITE_PKG=`$PYTHON -c "$IMPORT_SYSCONFIG; \ print (sysconfig.get_python_lib(1,0));"` fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_PLATFORM_SITE_PKG" >&5 printf "%s\n" "$PYTHON_PLATFORM_SITE_PKG" >&6; } # # libraries which must be linked in when embedding # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking python extra libraries" >&5 printf %s "checking python extra libraries... " >&6; } if test -z "$PYTHON_EXTRA_LIBS"; then PYTHON_EXTRA_LIBS=`$PYTHON -c "$IMPORT_SYSCONFIG; \ conf = sysconfig.get_config_var; \ print (conf('LIBS') + ' ' + conf('SYSLIBS'))"` fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LIBS" >&5 printf "%s\n" "$PYTHON_EXTRA_LIBS" >&6; } # # linking flags needed when embedding # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking python extra linking flags" >&5 printf %s "checking python extra linking flags... " >&6; } if test -z "$PYTHON_EXTRA_LDFLAGS"; then PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "$IMPORT_SYSCONFIG; \ conf = sysconfig.get_config_var; \ print (conf('LINKFORSHARED'))"` fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LDFLAGS" >&5 printf "%s\n" "$PYTHON_EXTRA_LDFLAGS" >&6; } # # final check to see if everything compiles alright # { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking consistency of all components of python development environment" >&5 printf %s "checking consistency of all components of python development environment... " >&6; } # save current global flags ac_save_LIBS="$LIBS" ac_save_LDFLAGS="$LDFLAGS" ac_save_CPPFLAGS="$CPPFLAGS" LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS" LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS" CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { Py_Initialize(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : pythonexists=yes else $as_nop pythonexists=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # turn back to default flags CPPFLAGS="$ac_save_CPPFLAGS" LIBS="$ac_save_LIBS" LDFLAGS="$ac_save_LDFLAGS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $pythonexists" >&5 printf "%s\n" "$pythonexists" >&6; } if test ! "x$pythonexists" = "xyes"; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? " Could not link test program to Python. Maybe the main Python library has been installed in some non-standard library path. If so, pass it to configure, via the LIBS environment variable. Example: ./configure LIBS=\"-L/usr/non-standard-path/python/lib\" ============================================================================ ERROR! You probably have to install the development version of the Python package for your distribution. The exact name of this package varies among them. ============================================================================ See \`config.log' for more details" "$LINENO" 5; } PYTHON_VERSION="" fi # # all done! # if test ! -z "$ac_python_version"; then ldns_have_python=yes fi # pass additional Python 3 option to SWIG if test `$PYTHON -c "import sys; \ ver = sys.version.split()[0]; \ print(ver >= '3')"` = "True"; then SWIGPY3="-py3 -DPY3" fi # check for SWIG if test x_$ldns_have_python != x_no; then # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html # =========================================================================== # # SYNOPSIS # # AX_PKG_SWIG([major.minor.micro], [action-if-found], [action-if-not-found]) # # DESCRIPTION # # This macro searches for a SWIG installation on your system. If found, # then SWIG is AC_SUBST'd; if not found, then $SWIG is empty. If SWIG is # found, then SWIG_LIB is set to the SWIG library path, and AC_SUBST'd. # # You can use the optional first argument to check if the version of the # available SWIG is greater than or equal to the value of the argument. It # should have the format: N[.N[.N]] (N is a number between 0 and 999. Only # the first N is mandatory.) If the version argument is given (e.g. # 1.3.17), AX_PKG_SWIG checks that the swig package is this version number # or higher. # # As usual, action-if-found is executed if SWIG is found, otherwise # action-if-not-found is executed. # # In configure.in, use as: # # AX_PKG_SWIG(1.3.17, [], [ AC_MSG_ERROR([SWIG is required to build..]) ]) # AX_SWIG_ENABLE_CXX # AX_SWIG_MULTI_MODULE_SUPPORT # AX_SWIG_PYTHON # # LICENSE # # Copyright (c) 2008 Sebastian Huber # Copyright (c) 2008 Alan W. Irwin # Copyright (c) 2008 Rafael Laboissiere # Copyright (c) 2008 Andrew Collier # Copyright (c) 2011 Murray Cumming # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 13 # check for >=SWIG-2.0.4 if Python 3.2 used if test `$PYTHON -c "import sys; \ ver = sys.version.split()[0]; \ print(ver >= '3.2')"` = "True"; then # Find path to the "swig" executable. for ac_prog in swig swig3.0 swig2.0 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_SWIG+y} then : printf %s "(cached) " >&6 else $as_nop case $SWIG in [\\/]* | ?:[\\/]*) ac_cv_path_SWIG="$SWIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_SWIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi SWIG=$ac_cv_path_SWIG if test -n "$SWIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SWIG" >&5 printf "%s\n" "$SWIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$SWIG" && break done if test -z "$SWIG" ; then as_fn_error $? "SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater." "$LINENO" 5 elif test -n "2.0.4" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking SWIG version" >&5 printf %s "checking SWIG version... " >&6; } swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $swig_version" >&5 printf "%s\n" "$swig_version" >&6; } if test -n "$swig_version" ; then # Calculate the required version number components required=2.0.4 required_major=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_major" ; then required_major=0 fi required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_minor=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_minor" ; then required_minor=0 fi required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_patch=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_patch" ; then required_patch=0 fi # Calculate the available version number components available=$swig_version available_major=`echo $available | sed 's/[^0-9].*//'` if test -z "$available_major" ; then available_major=0 fi available=`echo $available | sed 's/[0-9]*[^0-9]//'` available_minor=`echo $available | sed 's/[^0-9].*//'` if test -z "$available_minor" ; then available_minor=0 fi available=`echo $available | sed 's/[0-9]*[^0-9]//'` available_patch=`echo $available | sed 's/[^0-9].*//'` if test -z "$available_patch" ; then available_patch=0 fi # Convert the version tuple into a single number for easier comparison. # Using base 100 should be safe since SWIG internally uses BCD values # to encode its version number. required_swig_vernum=`expr $required_major \* 10000 \ \+ $required_minor \* 100 \+ $required_patch` available_swig_vernum=`expr $available_major \* 10000 \ \+ $available_minor \* 100 \+ $available_patch` if test $available_swig_vernum -lt $required_swig_vernum; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: SWIG version >= 2.0.4 is required. You have $swig_version." >&5 printf "%s\n" "$as_me: WARNING: SWIG version >= 2.0.4 is required. You have $swig_version." >&2;} SWIG='' as_fn_error $? "SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater." "$LINENO" 5 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SWIG library" >&5 printf %s "checking for SWIG library... " >&6; } SWIG_LIB=`$SWIG -swiglib` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SWIG_LIB" >&5 printf "%s\n" "$SWIG_LIB" >&6; } fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine SWIG version" >&5 printf "%s\n" "$as_me: WARNING: cannot determine SWIG version" >&2;} SWIG='' as_fn_error $? "SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater." "$LINENO" 5 fi fi else # Find path to the "swig" executable. for ac_prog in swig swig3.0 swig2.0 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_SWIG+y} then : printf %s "(cached) " >&6 else $as_nop case $SWIG in [\\/]* | ?:[\\/]*) ac_cv_path_SWIG="$SWIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_SWIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi SWIG=$ac_cv_path_SWIG if test -n "$SWIG"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SWIG" >&5 printf "%s\n" "$SWIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$SWIG" && break done if test -z "$SWIG" ; then : elif test -n "" ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking SWIG version" >&5 printf %s "checking SWIG version... " >&6; } swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $swig_version" >&5 printf "%s\n" "$swig_version" >&6; } if test -n "$swig_version" ; then # Calculate the required version number components required= required_major=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_major" ; then required_major=0 fi required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_minor=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_minor" ; then required_minor=0 fi required=`echo $required | sed 's/[0-9]*[^0-9]//'` required_patch=`echo $required | sed 's/[^0-9].*//'` if test -z "$required_patch" ; then required_patch=0 fi # Calculate the available version number components available=$swig_version available_major=`echo $available | sed 's/[^0-9].*//'` if test -z "$available_major" ; then available_major=0 fi available=`echo $available | sed 's/[0-9]*[^0-9]//'` available_minor=`echo $available | sed 's/[^0-9].*//'` if test -z "$available_minor" ; then available_minor=0 fi available=`echo $available | sed 's/[0-9]*[^0-9]//'` available_patch=`echo $available | sed 's/[^0-9].*//'` if test -z "$available_patch" ; then available_patch=0 fi # Convert the version tuple into a single number for easier comparison. # Using base 100 should be safe since SWIG internally uses BCD values # to encode its version number. required_swig_vernum=`expr $required_major \* 10000 \ \+ $required_minor \* 100 \+ $required_patch` available_swig_vernum=`expr $available_major \* 10000 \ \+ $available_minor \* 100 \+ $available_patch` if test $available_swig_vernum -lt $required_swig_vernum; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: SWIG version >= is required. You have $swig_version." >&5 printf "%s\n" "$as_me: WARNING: SWIG version >= is required. You have $swig_version." >&2;} SWIG='' else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SWIG library" >&5 printf %s "checking for SWIG library... " >&6; } SWIG_LIB=`$SWIG -swiglib` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SWIG_LIB" >&5 printf "%s\n" "$SWIG_LIB" >&6; } fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine SWIG version" >&5 printf "%s\n" "$as_me: WARNING: cannot determine SWIG version" >&2;} SWIG='' fi fi fi if test ! -x "$SWIG"; then as_fn_error $? "failed to find SWIG tool, install it, or do not build pyldns" "$LINENO" 5 else printf "%s\n" "#define HAVE_SWIG 1" >>confdefs.h PYLDNS="pyldns" swig="$SWIG" ldns_with_pyldns=yes fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: *** don't have Python, skipping SWIG, no pyldns ***" >&5 printf "%s\n" "*** don't have Python, skipping SWIG, no pyldns ***" >&6; } # ' fi # xtra cflags for pyldns if test x_$ldns_have_python != x_no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fno-strict-aliasing" >&5 printf %s "checking whether $CC supports -fno-strict-aliasing... " >&6; } cache=`echo fno-strict-aliasing | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -fno-strict-aliasing -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : PYTHON_X_CFLAGS="-fno-strict-aliasing" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-missing-field-initializers" >&5 printf %s "checking whether $CC supports -Wno-missing-field-initializers... " >&6; } cache=`echo Wno-missing-field-initializers | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wno-missing-field-initializers -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : PYTHON_X_CFLAGS="-Wno-missing-field-initializers $PYTHON_X_CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-unused-parameter" >&5 printf %s "checking whether $CC supports -Wno-unused-parameter... " >&6; } cache=`echo Wno-unused-parameter | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wno-unused-parameter -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : PYTHON_X_CFLAGS="-Wno-unused-parameter $PYTHON_X_CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wno-unused-variable" >&5 printf %s "checking whether $CC supports -Wno-unused-variable... " >&6; } cache=`echo Wno-unused-variable | sed 'y%.=/+-%___p_%'` if eval test \${cv_prog_cc_flag_$cache+y} then : printf %s "(cached) " >&6 else $as_nop echo 'void f(void){}' >conftest.c if test -z "`$CC $CPPFLAGS $CFLAGS -Wno-unused-variable -c conftest.c 2>&1`"; then eval "cv_prog_cc_flag_$cache=yes" else eval "cv_prog_cc_flag_$cache=no" fi rm -f conftest conftest.o conftest.c fi if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } : PYTHON_X_CFLAGS="-Wno-unused-variable $PYTHON_X_CFLAGS" else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } : fi fi fi # Check for pyldnsx # Check whether --with-pyldnsx was given. if test ${with_pyldnsx+y} then : withval=$with_pyldnsx; else $as_nop withval="with_pyldns" fi if test x_$withval != x_no; then if test x_$ldns_with_pyldns != x_no; then PYLDNSX="pyldnsx" ldns_with_pyldnsx=yes else if test x_$withval != x_with_pyldns; then as_fn_error $? "--with-pyldns is needed for the ldnsx python module" "$LINENO" 5 fi fi fi if test x_$ldns_with_pyldns != x_no; then PYLDNSINST="install-pyldns" PYLDNSUNINST="uninstall-pyldns" else PYLDNSINST="" PYLDNSUNINST="" fi if test x_$ldns_with_pyldnsx != x_no; then PYLDNSXINST="install-pyldnsx" PYLDNSXUNINST="uninstall-pyldnsx" else PYLDNSXINST="" PYLDNSXUNINST="" fi # check for perl ldns_with_p5_dns_ldns=no # Check whether --with-p5-dns-ldns was given. if test ${with_p5_dns_ldns+y} then : withval=$with_p5_dns_ldns; else $as_nop withval="no" fi ldns_have_perl=no if test x_$withval != x_no; then # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_PERL+y} then : printf %s "(cached) " >&6 else $as_nop case $PERL in [\\/]* | ?:[\\/]*) ac_cv_path_PERL="$PERL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_PERL="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PERL=$ac_cv_path_PERL if test -n "$PERL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 printf "%s\n" "$PERL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test -z "$PERL"; then as_fn_error $? "Cannot find perl in your system path" "$LINENO" 5 fi P5_DNS_LDNS="p5-dns-ldns" TEST_P5_DNS_LDNS="test-p5-dns-ldns" INSTALL_P5_DNS_LDNS="install-p5-dns-ldns" UNINSTALL_P5_DNS_LDNS="uninstall-p5-dns-ldns" CLEAN_P5_DNS_LDNS="clean-p5-dns-ldns" else P5_DNS_LDNS="" TEST_P5_DNS_LDNS="" INSTALL_P5_DNS_LDNS="" UNINSTALL_P5_DNS_LDNS="" CLEAN_P5_DNS_LDNS="" fi # Use libtool # skip these tests, we do not need them. # always use ./libtool unless override from commandline (libtool=mylibtool) if test -z "$libtool"; then libtool="./libtool" fi # avoid libtool max commandline length test on systems that fork slowly. if echo "$host_os" | grep "sunos4" >/dev/null; then lt_cv_sys_max_cmd_len=32750; fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_AR+y} then : printf %s "(cached) " >&6 else $as_nop case $AR in [\\/]* | ?:[\\/]*) ac_cv_path_AR="$AR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_AR="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi AR=$ac_cv_path_AR if test -n "$AR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 printf "%s\n" "$AR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_path_AR"; then ac_pt_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_path_ac_pt_AR+y} then : printf %s "(cached) " >&6 else $as_nop case $ac_pt_AR in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_AR="$ac_pt_AR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_AR="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_AR=$ac_cv_path_ac_pt_AR if test -n "$ac_pt_AR"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_AR" >&5 printf "%s\n" "$ac_pt_AR" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_pt_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_pt_AR fi else AR="$ac_cv_path_AR" fi if test $AR = false; then as_fn_error $? "Cannot find 'ar', please extend PATH to include it" "$LINENO" 5 fi tmp_CPPFLAGS=$CPPFLAGS tmp_LDFLAGS=$LDFLAGS tmp_LIBS=$LIBS # Check whether --with-ssl was given. if test ${with_ssl+y} then : withval=$with_ssl; else $as_nop withval="yes" fi withval=$withval if test x_$withval != x_no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SSL" >&5 printf %s "checking for SSL... " >&6; } if test -n "$withval"; then if test ! -f "$withval/include/openssl/ssl.h" -a -f "$withval/openssl/ssl.h"; then ssldir="$withval" found_ssl="yes" withval="" ssldir_include="$ssldir" ssldir_lib=`echo $ssldir | sed -e 's/include/lib/'` if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then : # found here else ssldir_lib=`echo $ssldir | sed -e 's/include/lib64/'` if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then : # found here else as_fn_error $? "Could not find openssl lib file, $ssldir_lib/libssl.so,a, pass like \"/usr/local\" or \"/usr/include/openssl11\"" "$LINENO" 5 fi fi fi fi if test x_$withval = x_ -o x_$withval = x_yes; then withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr" fi for dir in $withval; do ssldir="$dir" if test -f "$dir/include/openssl/ssl.h"; then found_ssl="yes" ssldir_include="$ssldir/include" if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then ssldir_lib="$ssldir/lib64" else ssldir_lib="$ssldir/lib" fi break; fi done if test x_$found_ssl != x_yes; then as_fn_error $? "Cannot find the SSL libraries in $withval" "$LINENO" 5 else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: found in $ssldir" >&5 printf "%s\n" "found in $ssldir" >&6; } printf "%s\n" "#define HAVE_SSL /**/" >>confdefs.h HAVE_SSL=yes if test "$ssldir" != "/usr"; then CPPFLAGS="$CPPFLAGS -I$ssldir_include" LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir_include" LDFLAGS="$LDFLAGS -L$ssldir_lib" LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir_lib" if test "x$enable_rpath" = xyes; then if echo "$ssldir_lib" | grep "^/" >/dev/null; then RUNTIME_PATH="$RUNTIME_PATH -R$ssldir_lib" fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for EVP_sha256 in -lcrypto" >&5 printf %s "checking for EVP_sha256 in -lcrypto... " >&6; } LIBS="$LIBS -lcrypto" LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int EVP_sha256(void); (void)EVP_sha256(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } # check if -lwsock32 or -lgdi32 are needed. BAKLIBS="$LIBS" BAKSSLLIBS="$LIBSSL_LIBS" LIBS="$LIBS -lgdi32 -lws2_32" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -lgdi32" >&5 printf %s "checking if -lcrypto needs -lgdi32... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int EVP_sha256(void); (void)EVP_sha256(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32" >&5 printf %s "checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int EVP_sha256(void); (void)EVP_sha256(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a" LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a" >&5 printf %s "checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32 -l:libssp.a... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int EVP_sha256(void); (void)EVP_sha256(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -ldl" LIBSSL_LIBS="$LIBSSL_LIBS -ldl" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl" >&5 printf %s "checking if -lcrypto needs -ldl... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int EVP_sha256(void); (void)EVP_sha256(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } LIBS="$BAKLIBS" LIBSSL_LIBS="$BAKSSLLIBS" LIBS="$LIBS -ldl -pthread" LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl -pthread" >&5 printf %s "checking if -lcrypto needs -ldl -pthread... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { int EVP_sha256(void); (void)EVP_sha256(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } as_fn_error $? "OpenSSL found in $ssldir, but version 0.9.7 or higher is required" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi fi ac_fn_c_check_header_compile "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_ssl_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_SSL_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "openssl/err.h" "ac_cv_header_openssl_err_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_err_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_ERR_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "openssl/rand.h" "ac_cv_header_openssl_rand_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_rand_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_RAND_H 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for LibreSSL" >&5 printf %s "checking for LibreSSL... " >&6; } if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_LIBRESSL 1" >>confdefs.h else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi ac_fn_c_check_header_compile "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_ssl_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_SSL_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_evp_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_EVP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "openssl/engine.h" "ac_cv_header_openssl_engine_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_engine_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_ENGINE_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "openssl/conf.h" "ac_cv_header_openssl_conf_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_conf_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_CONF_H 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_sha256" "ac_cv_func_EVP_sha256" if test "x$ac_cv_func_EVP_sha256" = xyes then : printf "%s\n" "#define HAVE_EVP_SHA256 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_sha384" "ac_cv_func_EVP_sha384" if test "x$ac_cv_func_EVP_sha384" = xyes then : printf "%s\n" "#define HAVE_EVP_SHA384 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_sha512" "ac_cv_func_EVP_sha512" if test "x$ac_cv_func_EVP_sha512" = xyes then : printf "%s\n" "#define HAVE_EVP_SHA512 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_PKEY_keygen" "ac_cv_func_EVP_PKEY_keygen" if test "x$ac_cv_func_EVP_PKEY_keygen" = xyes then : printf "%s\n" "#define HAVE_EVP_PKEY_KEYGEN 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "ECDSA_SIG_get0" "ac_cv_func_ECDSA_SIG_get0" if test "x$ac_cv_func_ECDSA_SIG_get0" = xyes then : printf "%s\n" "#define HAVE_ECDSA_SIG_GET0 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_MD_CTX_new" "ac_cv_func_EVP_MD_CTX_new" if test "x$ac_cv_func_EVP_MD_CTX_new" = xyes then : printf "%s\n" "#define HAVE_EVP_MD_CTX_NEW 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "DSA_SIG_set0" "ac_cv_func_DSA_SIG_set0" if test "x$ac_cv_func_DSA_SIG_set0" = xyes then : printf "%s\n" "#define HAVE_DSA_SIG_SET0 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "DSA_SIG_get0" "ac_cv_func_DSA_SIG_get0" if test "x$ac_cv_func_DSA_SIG_get0" = xyes then : printf "%s\n" "#define HAVE_DSA_SIG_GET0 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_dss1" "ac_cv_func_EVP_dss1" if test "x$ac_cv_func_EVP_dss1" = xyes then : printf "%s\n" "#define HAVE_EVP_DSS1 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "DSA_get0_pqg" "ac_cv_func_DSA_get0_pqg" if test "x$ac_cv_func_DSA_get0_pqg" = xyes then : printf "%s\n" "#define HAVE_DSA_GET0_PQG 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "DSA_get0_key" "ac_cv_func_DSA_get0_key" if test "x$ac_cv_func_DSA_get0_key" = xyes then : printf "%s\n" "#define HAVE_DSA_GET0_KEY 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_cleanup" "ac_cv_func_EVP_cleanup" if test "x$ac_cv_func_EVP_cleanup" = xyes then : printf "%s\n" "#define HAVE_EVP_CLEANUP 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "ENGINE_cleanup" "ac_cv_func_ENGINE_cleanup" if test "x$ac_cv_func_ENGINE_cleanup" = xyes then : printf "%s\n" "#define HAVE_ENGINE_CLEANUP 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "ENGINE_free" "ac_cv_func_ENGINE_free" if test "x$ac_cv_func_ENGINE_free" = xyes then : printf "%s\n" "#define HAVE_ENGINE_FREE 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "CRYPTO_cleanup_all_ex_data" "ac_cv_func_CRYPTO_cleanup_all_ex_data" if test "x$ac_cv_func_CRYPTO_cleanup_all_ex_data" = xyes then : printf "%s\n" "#define HAVE_CRYPTO_CLEANUP_ALL_EX_DATA 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "ERR_free_strings" "ac_cv_func_ERR_free_strings" if test "x$ac_cv_func_ERR_free_strings" = xyes then : printf "%s\n" "#define HAVE_ERR_FREE_STRINGS 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "CONF_modules_unload" "ac_cv_func_CONF_modules_unload" if test "x$ac_cv_func_CONF_modules_unload" = xyes then : printf "%s\n" "#define HAVE_CONF_MODULES_UNLOAD 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "OPENSSL_init_ssl" "ac_cv_func_OPENSSL_init_ssl" if test "x$ac_cv_func_OPENSSL_init_ssl" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_INIT_SSL 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "OPENSSL_init_crypto" "ac_cv_func_OPENSSL_init_crypto" if test "x$ac_cv_func_OPENSSL_init_crypto" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_INIT_CRYPTO 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "ERR_load_crypto_strings" "ac_cv_func_ERR_load_crypto_strings" if test "x$ac_cv_func_ERR_load_crypto_strings" = xyes then : printf "%s\n" "#define HAVE_ERR_LOAD_CRYPTO_STRINGS 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "CRYPTO_memcmp" "ac_cv_func_CRYPTO_memcmp" if test "x$ac_cv_func_CRYPTO_memcmp" = xyes then : printf "%s\n" "#define HAVE_CRYPTO_MEMCMP 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "EVP_PKEY_get_base_id" "ac_cv_func_EVP_PKEY_get_base_id" if test "x$ac_cv_func_EVP_PKEY_get_base_id" = xyes then : printf "%s\n" "#define HAVE_EVP_PKEY_GET_BASE_ID 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } if test ${ac_cv_c_undeclared_builtin_options+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_CFLAGS=$CFLAGS ac_cv_c_undeclared_builtin_options='cannot detect' for ac_arg in '' -fno-builtin; do CFLAGS="$ac_save_CFLAGS $ac_arg" # This test program should *not* compile successfully. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { (void) strchr; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop # This test program should compile successfully. # No library function is consistently available on # freestanding implementations, so test against a dummy # declaration. Include always-available headers on the # off chance that they somehow elicit warnings. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include extern void ac_decl (int, char *); int main (void) { (void) ac_decl (0, (char *) 0); (void) ac_decl; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : if test x"$ac_arg" = x then : ac_cv_c_undeclared_builtin_options='none needed' else $as_nop ac_cv_c_undeclared_builtin_options=$ac_arg fi break fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done CFLAGS=$ac_save_CFLAGS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5 printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; } case $ac_cv_c_undeclared_builtin_options in #( 'cannot detect') : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot make $CC report undeclared builtins See \`config.log' for more details" "$LINENO" 5; } ;; #( 'none needed') : ac_c_undeclared_builtin_options='' ;; #( *) : ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;; esac ac_fn_check_decl "$LINENO" "EVP_PKEY_base_id" "ac_cv_have_decl_EVP_PKEY_base_id" "$ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_EVP_PKEY_base_id" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_EVP_PKEY_BASE_ID $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 then : printf "%s\n" "#define HAVE_EVP_PKEY_BASE_ID 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking Checking for OpenSSL >= 3.0.0" >&5 printf %s "checking Checking for OpenSSL >= 3.0.0... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if OPENSSL_VERSION_MAJOR >= 3 #define SOMETHING #else This fails compiling. So either no OpenSSL at all (the include already failed), or the version < 3.0.0 #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } CFLAGS="-DOPENSSL_API_COMPAT=10100 $CFLAGS" else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # for macosx, see if glibtool exists and use that # BSD's need to know the version... #AC_CHECK_PROG(glibtool, glibtool, [glibtool], ) #AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool]) # Check whether --enable-sha2 was given. if test ${enable_sha2+y} then : enableval=$enable_sha2; fi case "$enable_sha2" in no) ;; yes|*) if test "x$HAVE_SSL" != "xyes"; then as_fn_error $? "SHA2 enabled, but no SSL support" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SHA256 and SHA512" >&5 printf %s "checking for SHA256 and SHA512... " >&6; } ac_fn_c_check_func "$LINENO" "SHA256_Init" "ac_cv_func_SHA256_Init" if test "x$ac_cv_func_SHA256_Init" = xyes then : else $as_nop as_fn_error $? "No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2" "$LINENO" 5 fi printf "%s\n" "#define USE_SHA2 1" >>confdefs.h ;; esac # check whether gost also works # Check whether --enable-gost was given. if test ${enable_gost+y} then : enableval=$enable_gost; fi case "$enable_gost" in no) ;; *) if test "x$HAVE_SSL" != "xyes"; then as_fn_error $? "GOST enabled, but no SSL support" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GOST" >&5 printf %s "checking for GOST... " >&6; } ac_fn_c_check_func "$LINENO" "EVP_PKEY_set_type_str" "ac_cv_func_EVP_PKEY_set_type_str" if test "x$ac_cv_func_EVP_PKEY_set_type_str" = xyes then : else $as_nop as_fn_error $? "OpenSSL >= 1.0.0 is needed for GOST support or rerun with --disable-gost" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "EC_KEY_new" "ac_cv_func_EC_KEY_new" if test "x$ac_cv_func_EC_KEY_new" = xyes then : else $as_nop as_fn_error $? "No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if GOST works" >&5 printf %s "checking if GOST works... " >&6; } if test c${cross_compiling} = cno; then BAKCFLAGS="$CFLAGS" if test -n "$ssldir"; then if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib64" else CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib" fi fi if test "$cross_compiling" = yes then : { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_OPENSSL_SSL_H #include #endif #ifdef HAVE_OPENSSL_EVP_H #include #endif #ifdef HAVE_OPENSSL_ENGINE_H #include #endif #ifdef HAVE_OPENSSL_CONF_H #include #endif /* routine to load gost (from sldns) */ int load_gost_id(void) { static int gost_id = 0; const EVP_PKEY_ASN1_METHOD* meth; ENGINE* e; if(gost_id) return gost_id; /* see if configuration loaded gost implementation from other engine*/ meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); if(meth) { EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } /* see if engine can be loaded already */ e = ENGINE_by_id("gost"); if(!e) { /* load it ourself, in case statically linked */ ENGINE_load_builtin_engines(); ENGINE_load_dynamic(); e = ENGINE_by_id("gost"); } if(!e) { /* no gost engine in openssl */ return 0; } if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { ENGINE_finish(e); ENGINE_free(e); return 0; } meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); if(!meth) { /* algo not found */ ENGINE_finish(e); ENGINE_free(e); return 0; } EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); return gost_id; } int main(void) { EVP_MD_CTX* ctx; const EVP_MD* md; unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */ const char* str = "Hello world"; const unsigned char check[] = { 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 , 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 , 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d , 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d }; OPENSSL_config(NULL); (void)load_gost_id(); md = EVP_get_digestbyname("md_gost94"); if(!md) return 1; memset(digest, 0, sizeof(digest)); ctx = EVP_MD_CTX_create(); if(!ctx) return 2; if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3; if(!EVP_DigestUpdate(ctx, str, 10)) return 4; if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5; /* uncomment to see the hash calculated. {int i; for(i=0; i<32; i++) printf(" %2.2x", (int)digest[i]); printf("\n");} */ if(memcmp(digest, check, sizeof(check)) != 0) return 6; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : eval "ac_cv_c_gost_works=yes" else $as_nop eval "ac_cv_c_gost_works=no" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi CFLAGS="$BAKCFLAGS" else eval "ac_cv_c_gost_works=maybe" fi # Check whether --enable-gost-anyway was given. if test ${enable_gost_anyway+y} then : enableval=$enable_gost_anyway; fi if test "$ac_cv_c_gost_works" != "no" -o "$enable_gost_anyway" = "yes"; then if test "$ac_cv_c_gost_works" = "no"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, but compiling with GOST support anyway" >&5 printf "%s\n" "no, but compiling with GOST support anyway" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi use_gost="yes" printf "%s\n" "#define USE_GOST 1" >>confdefs.h else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Gost support does not work because the engine is missing." >&5 printf "%s\n" "$as_me: WARNING: Gost support does not work because the engine is missing." >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Install gost-engine first or use the --enable-gost-anyway to compile with GOST support anyway" >&5 printf "%s\n" "$as_me: WARNING: Install gost-engine first or use the --enable-gost-anyway to compile with GOST support anyway" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: See also https://github.com/gost-engine/engine/wiki for information about gost-engine" >&5 printf "%s\n" "$as_me: WARNING: See also https://github.com/gost-engine/engine/wiki for information about gost-engine" >&2;} fi ;; esac # Check whether --enable-ecdsa was given. if test ${enable_ecdsa+y} then : enableval=$enable_ecdsa; fi case "$enable_ecdsa" in no) ;; *) if test "x$HAVE_SSL" != "xyes"; then as_fn_error $? "ECDSA enabled, but no SSL support" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "ECDSA_sign" "ac_cv_func_ECDSA_sign" if test "x$ac_cv_func_ECDSA_sign" = xyes then : else $as_nop as_fn_error $? "OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "SHA384_Init" "ac_cv_func_SHA384_Init" if test "x$ac_cv_func_SHA384_Init" = xyes then : else $as_nop as_fn_error $? "OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa" "$LINENO" 5 fi ac_fn_check_decl "$LINENO" "NID_X9_62_prime256v1" "ac_cv_have_decl_NID_X9_62_prime256v1" "$ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_NID_X9_62_prime256v1" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_NID_X9_62_PRIME256V1 $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 then : else $as_nop as_fn_error $? "OpenSSL does not support the ECDSA curves: please upgrade OpenSSL or rerun with --disable-ecdsa" "$LINENO" 5 fi ac_fn_check_decl "$LINENO" "NID_secp384r1" "ac_cv_have_decl_NID_secp384r1" "$ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_NID_secp384r1" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_NID_SECP384R1 $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 then : else $as_nop as_fn_error $? "OpenSSL does not support the ECDSA curves: please upgrade OpenSSL or rerun with --disable-ecdsa" "$LINENO" 5 fi # we now know we have ECDSA and the required curves. printf "%s\n" "#define USE_ECDSA 1" >>confdefs.h ;; esac # Check whether --enable-dsa was given. if test ${enable_dsa+y} then : enableval=$enable_dsa; fi case "$enable_dsa" in no) ldns_build_config_use_dsa=0 ;; *) # detect if DSA is supported, and turn it off if not. ac_fn_c_check_func "$LINENO" "DSA_SIG_new" "ac_cv_func_DSA_SIG_new" if test "x$ac_cv_func_DSA_SIG_new" = xyes then : printf "%s\n" "#define USE_DSA 1" >>confdefs.h ldns_build_config_use_dsa=1 else $as_nop if test "x$enable_dsa" = "xyes"; then as_fn_error $? "OpenSSL does not support DSA and you used --enable-dsa." "$LINENO" 5 fi ldns_build_config_use_dsa=0 fi ;; esac # Check whether --enable-ed25519 was given. if test ${enable_ed25519+y} then : enableval=$enable_ed25519; fi case "$enable_ed25519" in no) ldns_build_config_use_ed25519=0 ;; *) ac_fn_check_decl "$LINENO" "NID_ED25519" "ac_cv_have_decl_NID_ED25519" "$ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_NID_ED25519" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_NID_ED25519 $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 then : printf "%s\n" "#define USE_ED25519 1" >>confdefs.h ldns_build_config_use_ed25519=1 else $as_nop if test "x$enable_ed25519" = "xyes"; then as_fn_error $? "OpenSSL does not support ED25519 and you used --enable-ed25519." "$LINENO" 5 fi ldns_build_config_use_ed25519=0 fi ;; esac # Check whether --enable-ed448 was given. if test ${enable_ed448+y} then : enableval=$enable_ed448; fi case "$enable_ed448" in no) ldns_build_config_use_ed448=0 ;; *) ac_fn_check_decl "$LINENO" "NID_ED448" "ac_cv_have_decl_NID_ED448" "$ac_includes_default #include " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_NID_ED448" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_NID_ED448 $ac_have_decl" >>confdefs.h if test $ac_have_decl = 1 then : printf "%s\n" "#define USE_ED448 1" >>confdefs.h ldns_build_config_use_ed448=1 else $as_nop if test "x$enable_ed448" = "xyes"; then as_fn_error $? "OpenSSL does not support ED448 and you used --enable-ed448." "$LINENO" 5 fi ldns_build_config_use_ed448=0 fi ;; esac # Check whether --enable-dane was given. if test ${enable_dane+y} then : enableval=$enable_dane; fi # Check whether --enable-dane-verify was given. if test ${enable_dane_verify+y} then : enableval=$enable_dane_verify; fi # Check whether --enable-dane-ta-usage was given. if test ${enable_dane_ta_usage+y} then : enableval=$enable_dane_ta_usage; fi # Check whether --enable-full-dane was given. if test ${enable_full_dane+y} then : enableval=$enable_full_dane; enable_dane_ta_usage=yes enable_dane_verify=yes enable_dane=yes fi # Check whether --enable-no-dane-ta-usage was given. if test ${enable_no_dane_ta_usage+y} then : enableval=$enable_no_dane_ta_usage; enable_dane_ta_usage=no enable_dane_verify=yes enable_dane=yes fi # Check whether --enable-no-dane-verify was given. if test ${enable_no_dane_verify+y} then : enableval=$enable_no_dane_verify; enable_dane_ta_usage=no enable_dane_verify=no enable_dane=yes fi case "$enable_dane" in no) ldns_build_config_use_dane=0 ldns_build_config_use_dane_verify=0 ldns_build_config_use_dane_ta_usage=0 ;; *) if test "x$HAVE_SSL" != "xyes"; then as_fn_error $? "DANE enabled, but no SSL support" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "X509_check_ca" "ac_cv_func_X509_check_ca" if test "x$ac_cv_func_X509_check_ca" = xyes then : else $as_nop as_fn_error $? "OpenSSL does not support DANE: please upgrade OpenSSL or rerun with --disable-dane" "$LINENO" 5 fi ldns_build_config_use_dane=1 printf "%s\n" "#define USE_DANE 1" >>confdefs.h case "$enable_dane_verify" in no) ldns_build_config_use_dane_verify=0 ldns_build_config_use_dane_ta_usage=0 ;; *) ldns_build_config_use_dane_verify=1 printf "%s\n" "#define USE_DANE_VERIFY 1" >>confdefs.h case "$enable_dane_ta_usage" in no) ldns_build_config_use_dane_ta_usage=0 ;; *) danetmpLIBS="$LIBS" LIBS="-lssl -lcrypto $LIBS" ac_fn_c_check_func "$LINENO" "SSL_get0_dane" "ac_cv_func_SSL_get0_dane" if test "x$ac_cv_func_SSL_get0_dane" = xyes then : else $as_nop as_fn_error $? "OpenSSL does not support offline DANE verification (Needed for the DANE-TA usage type). Please upgrade OpenSSL to version >= 1.1.0 or rerun with --disable-dane-verify or --disable-dane-ta-usage" "$LINENO" 5 fi LIBSSL_LIBS="-lssl $LIBSSL_LIBS" LIBS="$danetmpLIBS" ldns_build_config_use_dane_ta_usage=1 printf "%s\n" "#define USE_DANE_TA_USAGE 1" >>confdefs.h ;; esac esac ;; esac # Check whether --enable-draft-rrtypes was given. if test ${enable_draft_rrtypes+y} then : enableval=$enable_draft_rrtypes; fi # Check whether --enable-rrtype-ninfo was given. if test ${enable_rrtype_ninfo+y} then : enableval=$enable_rrtype_ninfo; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_ninfo="yes"; fi case "$enable_rrtype_ninfo" in yes) printf "%s\n" "#define RRTYPE_NINFO /**/" >>confdefs.h ;; no|*) ;; esac # Check whether --enable-rrtype-rkey was given. if test ${enable_rrtype_rkey+y} then : enableval=$enable_rrtype_rkey; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_rkey="yes"; fi case "$enable_rrtype_rkey" in yes) printf "%s\n" "#define RRTYPE_RKEY /**/" >>confdefs.h ;; no|*) ;; esac # Check whether --enable-rrtype-openpgpkey was given. if test ${enable_rrtype_openpgpkey+y} then : enableval=$enable_rrtype_openpgpkey; fi case "$enable_rrtype_openpgpkey" in no) ;; yes|*) printf "%s\n" "#define RRTYPE_OPENPGPKEY /**/" >>confdefs.h ;; esac # Check whether --enable-rrtype-ta was given. if test ${enable_rrtype_ta+y} then : enableval=$enable_rrtype_ta; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_ta="yes"; fi case "$enable_rrtype_ta" in yes) printf "%s\n" "#define RRTYPE_TA /**/" >>confdefs.h ;; no|*) ;; esac # Check whether --enable-rrtype-avc was given. if test ${enable_rrtype_avc+y} then : enableval=$enable_rrtype_avc; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_avc="yes"; fi case "$enable_rrtype_avc" in yes) printf "%s\n" "#define RRTYPE_AVC /**/" >>confdefs.h ;; no|*) ;; esac # Check whether --enable-rrtype-doa was given. if test ${enable_rrtype_doa+y} then : enableval=$enable_rrtype_doa; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_doa="yes"; fi case "$enable_rrtype_doa" in yes) printf "%s\n" "#define RRTYPE_DOA /**/" >>confdefs.h ;; no|*) ;; esac # Check whether --enable-rrtype-amtrelay was given. if test ${enable_rrtype_amtrelay+y} then : enableval=$enable_rrtype_amtrelay; fi case "$enable_rrtype_amtrelay" in no) ;; yes|*) printf "%s\n" "#define RRTYPE_AMTRELAY /**/" >>confdefs.h ;; esac # Check whether --enable-rrtype-svcb-https was given. if test ${enable_rrtype_svcb_https+y} then : enableval=$enable_rrtype_svcb_https; fi case "$enable_rrtype_svcb_https" in no) ;; yes|*) printf "%s\n" "#define RRTYPE_SVCB_HTTPS /**/" >>confdefs.h ;; esac # Check whether --enable-rrtype-resinfo was given. if test ${enable_rrtype_resinfo+y} then : enableval=$enable_rrtype_resinfo; fi case "$enable_rrtype_resinfo" in no) ;; yes|*) printf "%s\n" "#define RRTYPE_RESINFO /**/" >>confdefs.h ;; esac # Check whether --enable-rrtype-dsync was given. if test ${enable_rrtype_dsync+y} then : enableval=$enable_rrtype_dsync; fi case "$enable_rrtype_dsync" in no) ;; yes|*) printf "%s\n" "#define RRTYPE_DSYNC /**/" >>confdefs.h ;; esac # Check whether --enable-rrtypes-cla-ipn was given. if test ${enable_rrtypes_cla_ipn+y} then : enableval=$enable_rrtypes_cla_ipn; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtypes_cla_ipn="yes"; fi case "$enable_rrtypes_cla_ipn" in yes) printf "%s\n" "#define RRTYPE_CLA_IPN /**/" >>confdefs.h ;; no|*) ;; esac # Check whether --enable-rrtypes-hhit-brid was given. if test ${enable_rrtypes_hhit_brid+y} then : enableval=$enable_rrtypes_hhit_brid; fi if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtypes_hhit_brid="yes"; fi case "$enable_rrtypes_hhit_brid" in yes) printf "%s\n" "#define RRTYPE_HHIT_BRID /**/" >>confdefs.h ;; no|*) ;; esac if echo "$tmp_LIBS" | grep "ws2_32" >/dev/null; then if echo "$LIBSSL_LIBS" | grep "ws2_32" >/dev/null; then # only need it once. LIBSSL_LIBS=`echo "$LIBSSL_LIBS" | sed -e 's/ -lws2_32//' -e 's/^-lws2_32//'` fi fi if test "x$HAVE_SSL" = "xyes"; then if echo "$LIBSSL_LIBS" | grep -- "-lssl" >/dev/null 2>&1; then LIBSSL_SSL_LIBS="$LIBSSL_LIBS" else LIBSSL_SSL_LIBS="-lssl $LIBSSL_LIBS" fi LIBSSL_SSL_LIBS="$LIBSSL_SSL_LIBS" fi CPPFLAGS=$tmp_CPPFLAGS LDFLAGS=$tmp_LDFLAGS LIBS=$tmp_LIBS # add option to disable the evil rpath # Check whether --enable-rpath was given. if test ${enable_rpath+y} then : enableval=$enable_rpath; enable_rpath=$enableval else $as_nop enable_rpath=yes fi if test "x$enable_rpath" = xno; then ac_config_commands="$ac_config_commands disable-rpath" fi #AC_RUN_IFELSE([AC_LANG_SOURCE( #[ #int main() #{ #short one = 1; #char *cp = (char*)&one; #if ( *cp == 0 ) #return(0); #else #return(1); #} #])], [],[ #AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian]) #],[]) # should define WORDS_BIGENDIAN if the system is big-endian { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 printf %s "checking whether byte ordering is bigendian... " >&6; } if test ${ac_cv_c_bigendian+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO" then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes else $as_nop ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes else $as_nop ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ unsigned short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; unsigned short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } unsigned short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; unsigned short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main (void) { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main (void) { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_c_bigendian=no else $as_nop ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 printf "%s\n" "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) printf "%s\n" "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac # Checks for header files. # Autoupdate added the next two lines to ensure that your configure # script's behavior did not change. They are probably safe to remove. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 printf %s "checking for egrep... " >&6; } if test ${ac_cv_path_EGREP+y} then : printf %s "(cached) " >&6 else $as_nop if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_prog in egrep do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" printf "%s\n" 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 printf "%s\n" "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes then : printf "%s\n" "#define HAVE__BOOL 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 printf %s "checking for stdbool.h that conforms to C99... " >&6; } if test ${ac_cv_header_stdbool_h+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef __bool_true_false_are_defined #error "__bool_true_false_are_defined is not defined" #endif char a[__bool_true_false_are_defined == 1 ? 1 : -1]; /* Regardless of whether this is C++ or "_Bool" is a valid type name, "true" and "false" should be usable in #if expressions and integer constant expressions, and "bool" should be a valid type name. */ #if !true #error "'true' is not true" #endif #if true != 1 #error "'true' is not equal to 1" #endif char b[true == 1 ? 1 : -1]; char c[true]; #if false #error "'false' is not false" #endif #if false != 0 #error "'false' is not equal to 0" #endif char d[false == 0 ? 1 : -1]; enum { e = false, f = true, g = false * true, h = true * 256 }; char i[(bool) 0.5 == true ? 1 : -1]; char j[(bool) 0.0 == false ? 1 : -1]; char k[sizeof (bool) > 0 ? 1 : -1]; struct sb { bool s: 1; bool t; } s; char l[sizeof s.t > 0 ? 1 : -1]; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ bool m[h]; char n[sizeof m == h * sizeof m[0] ? 1 : -1]; char o[-1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html https://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ bool p = true; bool *pp = &p; /* C 1999 specifies that bool, true, and false are to be macros, but C++ 2011 and later overrule this. */ #if __cplusplus < 201103 #ifndef bool #error "bool is not defined" #endif #ifndef false #error "false is not defined" #endif #ifndef true #error "true is not defined" #endif #endif /* If _Bool is available, repeat with it all the tests above that used bool. */ #ifdef HAVE__BOOL struct sB { _Bool s: 1; _Bool t; } t; char q[(_Bool) 0.5 == true ? 1 : -1]; char r[(_Bool) 0.0 == false ? 1 : -1]; char u[sizeof (_Bool) > 0 ? 1 : -1]; char v[sizeof t.t > 0 ? 1 : -1]; _Bool w[h]; char x[sizeof m == h * sizeof m[0] ? 1 : -1]; char y[-1 - (_Bool) 0 < 0 ? 1 : -1]; _Bool z = true; _Bool *pz = &p; #endif int main (void) { bool ps = &s; *pp |= p; *pp |= ! p; #ifdef HAVE__BOOL _Bool pt = &t; *pz |= z; *pz |= ! z; #endif /* Refer to every declared value, so they cannot be discarded as unused. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + !l + !m + !n + !o + !p + !pp + !ps #ifdef HAVE__BOOL + !q + !r + !u + !v + !w + !x + !y + !z + !pt #endif ); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_header_stdbool_h=yes else $as_nop ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 printf "%s\n" "$ac_cv_header_stdbool_h" >&6; } if test $ac_cv_header_stdbool_h = yes; then printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h fi #AC_HEADER_SYS_WAIT #AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h]) # do the very minimum - we can always extend this ac_fn_c_check_header_compile "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default " if test "x$ac_cv_header_getopt_h" = xyes then : printf "%s\n" "#define HAVE_GETOPT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default " if test "x$ac_cv_header_stdarg_h" = xyes then : printf "%s\n" "#define HAVE_STDARG_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default " if test "x$ac_cv_header_openssl_ssl_h" = xyes then : printf "%s\n" "#define HAVE_OPENSSL_SSL_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default " if test "x$ac_cv_header_netinet_in_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IN_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "time.h" "ac_cv_header_time_h" "$ac_includes_default " if test "x$ac_cv_header_time_h" = xyes then : printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "arpa/inet.h" "ac_cv_header_arpa_inet_h" "$ac_includes_default " if test "x$ac_cv_header_arpa_inet_h" = xyes then : printf "%s\n" "#define HAVE_ARPA_INET_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netdb.h" "ac_cv_header_netdb_h" "$ac_includes_default " if test "x$ac_cv_header_netdb_h" = xyes then : printf "%s\n" "#define HAVE_NETDB_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default #if HAVE_SYS_PARAM_H # include #endif " if test "x$ac_cv_header_sys_param_h" = xyes then : printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/mount.h" "ac_cv_header_sys_mount_h" "$ac_includes_default #if HAVE_SYS_PARAM_H # include #endif " if test "x$ac_cv_header_sys_mount_h" = xyes then : printf "%s\n" "#define HAVE_SYS_MOUNT_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default #if HAVE_SYS_PARAM_H # include #endif " if test "x$ac_cv_header_sys_socket_h" = xyes then : include_sys_socket_h='#include ' printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h else $as_nop include_sys_socket_h='' fi ac_fn_c_check_header_compile "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default " if test "x$ac_cv_header_inttypes_h" = xyes then : include_inttypes_h='#include ' printf "%s\n" "#define HAVE_INTTYPES_H 1" >>confdefs.h ldns_build_config_have_inttypes_h=1 else $as_nop include_inttypes_h='' ldns_build_config_have_inttypes_h=0 fi ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default " if test "x$ac_cv_header_sys_types_h" = xyes then : include_systypes_h='#include ' printf "%s\n" "#define HAVE_SYS_TYPES_H 1" >>confdefs.h else $as_nop include_systypes_h='' fi ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default " if test "x$ac_cv_header_unistd_h" = xyes then : include_unistd_h='#include ' printf "%s\n" "#define HAVE_UNISTD_H 1" >>confdefs.h else $as_nop include_unistd_h='' fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 printf %s "checking size of time_t... " >&6; } if test ${ac_cv_sizeof_time_t+y} then : printf %s "(cached) " >&6 else $as_nop if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" " $ac_includes_default #ifdef TIME_WITH_SYS_TIME # include # include #else # ifdef HAVE_SYS_TIME_H # include # else # include # endif #endif " then : else $as_nop if test "$ac_cv_type_time_t" = yes; then { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (time_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_time_t=0 fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5 printf "%s\n" "$ac_cv_sizeof_time_t" >&6; } printf "%s\n" "#define SIZEOF_TIME_T $ac_cv_sizeof_time_t" >>confdefs.h if test x_$with_examples != x_no; then ac_fn_c_check_header_compile "$LINENO" "pcap.h" "ac_cv_header_pcap_h" "$ac_includes_default " if test "x$ac_cv_header_pcap_h" = xyes then : printf "%s\n" "#define HAVE_PCAP_H 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pcap_open_offline in -lpcap" >&5 printf %s "checking for pcap_open_offline in -lpcap... " >&6; } if test ${ac_cv_lib_pcap_pcap_open_offline+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char pcap_open_offline (); int main (void) { return pcap_open_offline (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_pcap_pcap_open_offline=yes else $as_nop ac_cv_lib_pcap_pcap_open_offline=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_open_offline" >&5 printf "%s\n" "$ac_cv_lib_pcap_pcap_open_offline" >&6; } if test "x$ac_cv_lib_pcap_pcap_open_offline" = xyes then : printf "%s\n" "#define HAVE_LIBPCAP 1" >>confdefs.h LIBPCAP_LIBS=-lpcap else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Can't find pcap library (needed for ldns-dpa, will not build dpa now.)" >&5 printf "%s\n" "$as_me: WARNING: Can't find pcap library (needed for ldns-dpa, will not build dpa now.)" >&2;} fi ac_fn_c_check_header_compile "$LINENO" "netinet/in_systm.h" "ac_cv_header_netinet_in_systm_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_in_systm_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IN_SYSTM_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_net_if_h" = xyes then : printf "%s\n" "#define HAVE_NET_IF_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/ip.h" "ac_cv_header_netinet_ip_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_ip_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/udp.h" "ac_cv_header_netinet_udp_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_udp_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_UDP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/igmp.h" "ac_cv_header_netinet_igmp_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_igmp_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IGMP_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_if_ether_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IF_ETHER_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/ip6.h" "ac_cv_header_netinet_ip6_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_ip6_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IP6_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "net/ethernet.h" "ac_cv_header_net_ethernet_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_net_ethernet_h" = xyes then : printf "%s\n" "#define HAVE_NET_ETHERNET_H 1" >>confdefs.h fi ac_fn_c_check_header_compile "$LINENO" "netinet/ip_compat.h" "ac_cv_header_netinet_ip_compat_h" " $ac_includes_default #ifdef HAVE_NETINET_IN_SYSTM_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NET_IF_H #include #endif " if test "x$ac_cv_header_netinet_ip_compat_h" = xyes then : printf "%s\n" "#define HAVE_NETINET_IP_COMPAT_H 1" >>confdefs.h fi fi ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" " $ac_includes_default #ifdef HAVE_SYS_SOCKET_H # include #endif #ifdef HAVE_WS2TCPIP_H # include #endif " if test "x$ac_cv_type_socklen_t" = xyes then : else $as_nop printf "%s\n" "#define socklen_t int" >>confdefs.h fi if test "x$ac_cv_type_socklen_t" = xyes; then ldns_build_config_have_socklen_t=1 else ldns_build_config_have_socklen_t=0 fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes then : else $as_nop printf "%s\n" "#define size_t unsigned int" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes then : else $as_nop printf "%s\n" "#define ssize_t int" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default" if test "x$ac_cv_type_intptr_t" = xyes then : else $as_nop printf "%s\n" "#define intptr_t size_t" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "in_addr_t" "ac_cv_type_in_addr_t" " #if HAVE_SYS_TYPES_H # include #endif #if HAVE_NETINET_IN_H # include #endif " if test "x$ac_cv_type_in_addr_t" = xyes then : else $as_nop printf "%s\n" "#define in_addr_t uint32_t" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "in_port_t" "ac_cv_type_in_port_t" " #if HAVE_SYS_TYPES_H # include #endif #if HAVE_NETINET_IN_H # include #endif " if test "x$ac_cv_type_in_port_t" = xyes then : else $as_nop printf "%s\n" "#define in_port_t uint16_t" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct sockaddr_storage" "ss_family" "ac_cv_member_struct_sockaddr_storage_ss_family" "$ac_includes_default #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_storage_ss_family" = xyes then : else $as_nop ac_fn_c_check_member "$LINENO" "struct sockaddr_storage" "__ss_family" "ac_cv_member_struct_sockaddr_storage___ss_family" "$ac_includes_default #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif " if test "x$ac_cv_member_struct_sockaddr_storage___ss_family" = xyes then : printf "%s\n" "#define ss_family __ss_family" >>confdefs.h fi fi ac_fn_check_decl "$LINENO" "inet_pton" "ac_cv_have_decl_inet_pton" " $ac_includes_default #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_inet_pton" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_INET_PTON $ac_have_decl" >>confdefs.h ac_fn_check_decl "$LINENO" "inet_ntop" "ac_cv_have_decl_inet_ntop" " $ac_includes_default #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_NETINET_TCP_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_WS2TCPIP_H #include #endif " "$ac_c_undeclared_builtin_options" "CFLAGS" if test "x$ac_cv_have_decl_inet_ntop" = xyes then : ac_have_decl=1 else $as_nop ac_have_decl=0 fi printf "%s\n" "#define HAVE_DECL_INET_NTOP $ac_have_decl" >>confdefs.h # AC_FUNC_MALLOC suffers false failures and causes Asan failures. # AC_FUNC_MALLOC # AC_FUNC_REALLOC ac_fn_c_check_func "$LINENO" "b64_pton" "ac_cv_func_b64_pton" if test "x$ac_cv_func_b64_pton" = xyes then : printf "%s\n" "#define HAVE_B64_PTON 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" b64_pton.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS b64_pton.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "b64_ntop" "ac_cv_func_b64_ntop" if test "x$ac_cv_func_b64_ntop" = xyes then : printf "%s\n" "#define HAVE_B64_NTOP 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" b64_ntop.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS b64_ntop.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "calloc" "ac_cv_func_calloc" if test "x$ac_cv_func_calloc" = xyes then : printf "%s\n" "#define HAVE_CALLOC 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" calloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS calloc.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "timegm" "ac_cv_func_timegm" if test "x$ac_cv_func_timegm" = xyes then : printf "%s\n" "#define HAVE_TIMEGM 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" timegm.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS timegm.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "gmtime_r" "ac_cv_func_gmtime_r" if test "x$ac_cv_func_gmtime_r" = xyes then : printf "%s\n" "#define HAVE_GMTIME_R 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" gmtime_r.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS gmtime_r.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "asctime_r" "ac_cv_func_asctime_r" if test "x$ac_cv_func_asctime_r" = xyes then : printf "%s\n" "#define HAVE_ASCTIME_R 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" asctime_r.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS asctime_r.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "ctime_r" "ac_cv_func_ctime_r" if test "x$ac_cv_func_ctime_r" = xyes then : printf "%s\n" "#define HAVE_CTIME_R 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" ctime_r.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS ctime_r.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "localtime_r" "ac_cv_func_localtime_r" if test "x$ac_cv_func_localtime_r" = xyes then : printf "%s\n" "#define HAVE_LOCALTIME_R 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" localtime_r.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS localtime_r.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "isblank" "ac_cv_func_isblank" if test "x$ac_cv_func_isblank" = xyes then : printf "%s\n" "#define HAVE_ISBLANK 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" isblank.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS isblank.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "isascii" "ac_cv_func_isascii" if test "x$ac_cv_func_isascii" = xyes then : printf "%s\n" "#define HAVE_ISASCII 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" isascii.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS isascii.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "inet_aton" "ac_cv_func_inet_aton" if test "x$ac_cv_func_inet_aton" = xyes then : printf "%s\n" "#define HAVE_INET_ATON 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" inet_aton.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_aton.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes then : printf "%s\n" "#define HAVE_INET_PTON 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" inet_pton.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" if test "x$ac_cv_func_inet_ntop" = xyes then : printf "%s\n" "#define HAVE_INET_NTOP 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" inet_ntop.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" if test "x$ac_cv_func_snprintf" = xyes then : printf "%s\n" "#define HAVE_SNPRINTF 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" snprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes then : printf "%s\n" "#define HAVE_STRLCPY 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "memmove" "ac_cv_func_memmove" if test "x$ac_cv_func_memmove" = xyes then : printf "%s\n" "#define HAVE_MEMMOVE 1" >>confdefs.h else $as_nop case " $LIBOBJS " in *" memmove.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memmove.$ac_objext" ;; esac fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default " if test "x$ac_cv_type_pid_t" = xyes then : else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined _WIN64 && !defined __CYGWIN__ LLP64 #endif int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_pid_type='int' else $as_nop ac_pid_type='__int64' fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext printf "%s\n" "#define pid_t $ac_pid_type" >>confdefs.h fi ac_func= for ac_item in $ac_func_c_list do if test $ac_func; then ac_fn_c_check_func "$LINENO" $ac_func ac_cv_func_$ac_func if eval test \"x\$ac_cv_func_$ac_func\" = xyes; then echo "#define $ac_item 1" >> confdefs.h fi ac_func= else ac_func=$ac_item fi done if test "x$ac_cv_func_fork" = xyes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 printf %s "checking for working fork... " >&6; } if test ${ac_cv_func_fork_works+y} then : printf %s "(cached) " >&6 else $as_nop if test "$cross_compiling" = yes then : ac_cv_func_fork_works=cross else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main (void) { /* By Ruediger Kuhlmann. */ return fork () < 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_fork_works=yes else $as_nop ac_cv_func_fork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 printf "%s\n" "$ac_cv_func_fork_works" >&6; } else ac_cv_func_fork_works=$ac_cv_func_fork fi if test "x$ac_cv_func_fork_works" = xcross; then case $host in *-*-amigaos* | *-*-msdosdjgpp*) # Override, as these systems have only a dummy fork() stub ac_cv_func_fork_works=no ;; *) ac_cv_func_fork_works=yes ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 printf "%s\n" "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} fi ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 printf %s "checking for working vfork... " >&6; } if test ${ac_cv_func_vfork_works+y} then : printf %s "(cached) " >&6 else $as_nop if test "$cross_compiling" = yes then : ac_cv_func_vfork_works=cross else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Thanks to Paul Eggert for this test. */ $ac_includes_default #include #include #ifdef HAVE_VFORK_H # include #endif static void do_nothing (int sig) { (void) sig; } /* On some sparc systems, changes by the child to local and incoming argument registers are propagated back to the parent. The compiler is told about this with #include , but some compilers (e.g. gcc -O) don't grok . Test for this by using a static variable whose address is put into a register that is clobbered by the vfork. */ static void sparc_address_test (int arg) { static pid_t child; if (!child) { child = vfork (); if (child < 0) { perror ("vfork"); _exit(2); } if (!child) { arg = getpid(); write(-1, "", 0); _exit (arg); } } } int main (void) { pid_t parent = getpid (); pid_t child; sparc_address_test (0); /* On Solaris 2.4, changes by the child to the signal handler also munge signal handlers in the parent. To detect this, start by putting the parent's handler in a known state. */ signal (SIGTERM, SIG_DFL); child = vfork (); if (child == 0) { /* Here is another test for sparc vfork register problems. This test uses lots of local variables, at least as many local variables as main has allocated so far including compiler temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should reuse the register of parent for one of the local variables, since it will think that parent can't possibly be used any more in this routine. Assigning to the local variable will thus munge parent in the parent process. */ pid_t p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); /* Convince the compiler that p..p7 are live; otherwise, it might use the same hardware register for all 8 local variables. */ if (p != p1 || p != p2 || p != p3 || p != p4 || p != p5 || p != p6 || p != p7) _exit(1); /* Alter the child's signal handler. */ if (signal (SIGTERM, do_nothing) != SIG_DFL) _exit(1); /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent from child file descriptors. If the child closes a descriptor before it execs or exits, this munges the parent's descriptor as well. Test for this by closing stdout in the child. */ _exit(close(fileno(stdout)) != 0); } else { int status; struct stat st; while (wait(&status) != child) ; return ( /* Was there some problem with vforking? */ child < 0 /* Did the child munge the parent's signal handler? */ || signal (SIGTERM, SIG_DFL) != SIG_DFL /* Did the child fail? (This shouldn't happen.) */ || status /* Did the vfork/compiler bug occur? */ || parent != getpid() /* Did the file descriptor bug occur? */ || fstat(fileno(stdout), &st) != 0 ); } } _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_func_vfork_works=yes else $as_nop ac_cv_func_vfork_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 printf "%s\n" "$ac_cv_func_vfork_works" >&6; } fi; if test "x$ac_cv_func_fork_works" = xcross; then ac_cv_func_vfork_works=$ac_cv_func_vfork { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 printf "%s\n" "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} fi if test "x$ac_cv_func_vfork_works" = xyes; then printf "%s\n" "#define HAVE_WORKING_VFORK 1" >>confdefs.h else printf "%s\n" "#define vfork fork" >>confdefs.h fi if test "x$ac_cv_func_fork_works" = xyes; then printf "%s\n" "#define HAVE_WORKING_FORK 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking compile of fork" >&5 printf %s "checking compile of fork... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { (void)fork(); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_FORK_AVAILABLE 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_fn_c_check_func "$LINENO" "endprotoent" "ac_cv_func_endprotoent" if test "x$ac_cv_func_endprotoent" = xyes then : printf "%s\n" "#define HAVE_ENDPROTOENT 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "endservent" "ac_cv_func_endservent" if test "x$ac_cv_func_endservent" = xyes then : printf "%s\n" "#define HAVE_ENDSERVENT 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "sleep" "ac_cv_func_sleep" if test "x$ac_cv_func_sleep" = xyes then : printf "%s\n" "#define HAVE_SLEEP 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "random" "ac_cv_func_random" if test "x$ac_cv_func_random" = xyes then : printf "%s\n" "#define HAVE_RANDOM 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "fcntl" "ac_cv_func_fcntl" if test "x$ac_cv_func_fcntl" = xyes then : printf "%s\n" "#define HAVE_FCNTL 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" if test "x$ac_cv_func_strtoul" = xyes then : printf "%s\n" "#define HAVE_STRTOUL 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "bzero" "ac_cv_func_bzero" if test "x$ac_cv_func_bzero" = xyes then : printf "%s\n" "#define HAVE_BZERO 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" if test "x$ac_cv_func_memset" = xyes then : printf "%s\n" "#define HAVE_MEMSET 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "b32_ntop" "ac_cv_func_b32_ntop" if test "x$ac_cv_func_b32_ntop" = xyes then : printf "%s\n" "#define HAVE_B32_NTOP 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "b32_pton" "ac_cv_func_b32_pton" if test "x$ac_cv_func_b32_pton" = xyes then : printf "%s\n" "#define HAVE_B32_PTON 1" >>confdefs.h fi ac_fn_c_check_func "$LINENO" "symlink" "ac_cv_func_symlink" if test "x$ac_cv_func_symlink" = xyes then : printf "%s\n" "#define HAVE_SYMLINK 1" >>confdefs.h fi if test "x$HAVE_B32_NTOP" = "xyes"; then ldns_build_config_have_b32_ntop=1 else ldns_build_config_have_b32_ntop=0 fi if test "x$HAVE_B32_PTON" = "xyes"; then ldns_build_config_have_b32_pton=1 else ldns_build_config_have_b32_pton=0 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo" >&5 printf %s "checking for getaddrinfo... " >&6; } ac_cv_func_getaddrinfo=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __cplusplus extern "C" { #endif char* getaddrinfo(); char* (*f) () = getaddrinfo; #ifdef __cplusplus } #endif int main(void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_getaddrinfo="yes" if test "$ac_cv_header_windows_h" = "yes"; then printf "%s\n" "#define USE_WINSOCK 1" >>confdefs.h USE_WINSOCK="1" if echo "$LIBS" | grep 'lws2_32' >/dev/null; then : else LIBS="$LIBS -lws2_32" fi fi else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_WS2TCPIP_H #include #endif int main (void) { (void)getaddrinfo(NULL, NULL, NULL, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_getaddrinfo="yes" printf "%s\n" "#define USE_WINSOCK 1" >>confdefs.h USE_WINSOCK="1" else $as_nop ORIGLIBS="$LIBS" LIBS="$LIBS -lws2_32" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_WS2TCPIP_H #include #endif int main (void) { (void)getaddrinfo(NULL, NULL, NULL, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_func_getaddrinfo="yes" printf "%s\n" "#define USE_WINSOCK 1" >>confdefs.h USE_WINSOCK="1" else $as_nop ac_cv_func_getaddrinfo="no" LIBS="$ORIGLIBS" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getaddrinfo" >&5 printf "%s\n" "$ac_cv_func_getaddrinfo" >&6; } if test $ac_cv_func_getaddrinfo = yes; then printf "%s\n" "#define HAVE_GETADDRINFO 1" >>confdefs.h fi if test $ac_cv_func_getaddrinfo = no; then case " $LIBOBJS " in *" fake-rfc2553.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS fake-rfc2553.$ac_objext" ;; esac fi if test "$USE_WINSOCK" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. set dummy ${ac_tool_prefix}windres; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_WINDRES+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$WINDRES"; then ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_WINDRES="${ac_tool_prefix}windres" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi WINDRES=$ac_cv_prog_WINDRES if test -n "$WINDRES"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $WINDRES" >&5 printf "%s\n" "$WINDRES" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_WINDRES"; then ac_ct_WINDRES=$WINDRES # Extract the first word of "windres", so it can be a program name with args. set dummy windres; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_WINDRES+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_WINDRES"; then ac_cv_prog_ac_ct_WINDRES="$ac_ct_WINDRES" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_WINDRES="windres" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_WINDRES=$ac_cv_prog_ac_ct_WINDRES if test -n "$ac_ct_WINDRES"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_WINDRES" >&5 printf "%s\n" "$ac_ct_WINDRES" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_WINDRES" = x; then WINDRES="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac WINDRES=$ac_ct_WINDRES fi else WINDRES="$ac_cv_prog_WINDRES" fi fi # check ioctlsocket { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ioctlsocket" >&5 printf %s "checking for ioctlsocket... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_WINSOCK2_H #include #endif int main (void) { (void)ioctlsocket(0, 0, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_IOCTLSOCKET 1" >>confdefs.h else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext #AC_SEARCH_LIBS(RSA_new, [crypto]) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler (${CC-cc}) accepts the \"format\" attribute" >&5 printf %s "checking whether the C compiler (${CC-cc}) accepts the \"format\" attribute... " >&6; } if test ${ac_cv_c_format_attribute+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_c_format_attribute=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include void f (char *format, ...) __attribute__ ((format (printf, 1, 2))); void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); int main (void) { f ("%s", "str"); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_format_attribute="yes" else $as_nop ac_cv_c_format_attribute="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_format_attribute" >&5 printf "%s\n" "$ac_cv_c_format_attribute" >&6; } if test $ac_cv_c_format_attribute = yes; then printf "%s\n" "#define HAVE_ATTR_FORMAT 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler (${CC-cc}) accepts the \"unused\" attribute" >&5 printf %s "checking whether the C compiler (${CC-cc}) accepts the \"unused\" attribute... " >&6; } if test ${ac_cv_c_unused_attribute+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_c_unused_attribute=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include void f (char *u __attribute__((unused))); int main (void) { f ("x"); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_unused_attribute="yes" else $as_nop ac_cv_c_unused_attribute="no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_unused_attribute" >&5 printf "%s\n" "$ac_cv_c_unused_attribute" >&6; } if test $ac_cv_c_unused_attribute = yes; then printf "%s\n" "#define HAVE_ATTR_UNUSED 1" >>confdefs.h fi # Check whether --with-xcode-sdk was given. if test ${with_xcode_sdk+y} then : withval=$with_xcode_sdk; else $as_nop with_xcode_sdk="yes" fi if test "x_$with_xcode_sdk" != "x_no" ; then # check OSX deployment target, if needed if echo $target_os | grep darwin > /dev/null; then sdk_p=`xcode-select -print-path`; if test "x_$with_xcode_sdk" = "x_yes" ; then sdk_v="$( /usr/bin/xcrun --show-sdk-version 2>/dev/null )" else sdk_v="$with_xcode_sdk" fi # xcrun only got that option in 10.7 if test -z "$sdk_v" ; then sdk_c="10.6" sdk_v="10.6" fi SYSROOT="$( find ${sdk_p} -name MacOSX${sdk_v}.sdk )" case $sdk_v in 10.9|10.8) sdk_c="10.7";; 10.11|10.10|*) sdk_c="10.10";; esac export MACOSX_DEPLOYMENT_TARGET="${sdk_c}"; export CFLAGS="$CFLAGS -mmacosx-version-min=${sdk_c} -isysroot ${SYSROOT}" fi fi printf "%s\n" "#define SYSCONFDIR sysconfdir" >>confdefs.h # Check whether --with-trust-anchor was given. if test ${with_trust_anchor+y} then : withval=$with_trust_anchor; LDNS_TRUST_ANCHOR_FILE="$withval" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Default trust anchor: $withval" >&5 printf "%s\n" "$as_me: Default trust anchor: $withval" >&6;} else $as_nop LDNS_TRUST_ANCHOR_FILE="\$(sysconfdir)/unbound/root.key" fi # Check whether --with-ca-file was given. if test ${with_ca_file+y} then : withval=$with_ca_file; printf "%s\n" "#define HAVE_DANE_CA_FILE 1" >>confdefs.h printf "%s\n" "#define LDNS_DANE_CA_FILE \"$withval\"" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using CAfile: $withval" >&5 printf "%s\n" "$as_me: Using CAfile: $withval" >&6;} DEFAULT_CAFILE="Default is $withval" else $as_nop printf "%s\n" "#define HAVE_DANE_CA_FILE 0" >>confdefs.h fi # Check whether --with-ca-path was given. if test ${with_ca_path+y} then : withval=$with_ca_path; printf "%s\n" "#define HAVE_DANE_CA_PATH 1" >>confdefs.h printf "%s\n" "#define LDNS_DANE_CA_PATH \"$withval\"" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using CApath: $withval" >&5 printf "%s\n" "$as_me: Using CApath: $withval" >&6;} DEFAULT_CAPATH="Default is $withval" else $as_nop printf "%s\n" "#define HAVE_DANE_CA_PATH 0" >>confdefs.h fi if test "x$HAVE_SSL" = "xyes"; then ldns_build_config_have_ssl=1 else ldns_build_config_have_ssl=0 fi if test "x$ac_cv_c_format_attribute" = "xyes"; then ldns_build_config_have_attr_format=1 else ldns_build_config_have_attr_format=0 fi if test "x$ac_cv_c_unused_attribute" = "xyes"; then ldns_build_config_have_attr_unused=1 else ldns_build_config_have_attr_unused=0 fi CONFIG_FILES="Makefile libdns.doxygen ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config" ac_config_files="$ac_config_files $CONFIG_FILES" ac_config_headers="$ac_config_headers ldns/config.h" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by ldns $as_me 1.9.2, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ ldns config.status 1.9.2 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" Copyright (C) 2021 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' FILECMD='`$ECHO "$FILECMD" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ FILECMD \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ configure_time_dlsearch_path \ configure_time_lt_sys_library_path; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "disable-rpath") CONFIG_COMMANDS="$CONFIG_COMMANDS disable-rpath" ;; "$CONFIG_FILES") CONFIG_FILES="$CONFIG_FILES $CONFIG_FILES" ;; "ldns/config.h") CONFIG_HEADERS="$CONFIG_HEADERS ldns/config.h" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 printf "%s\n" "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # The names of the tagged configurations supported by this script. available_tags='' # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shared archive member basename,for filename based shared library versioning on AIX. shared_archive_member_spec=$shared_archive_member_spec # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # A file(cmd) program that detects file types. FILECMD=$lt_FILECMD # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive (by configure). lt_ar_flags=$lt_ar_flags # Flags to create an archive. AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"} # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # Command to truncate a binary pipe. lt_truncate_bin=$lt_lt_cv_truncate_bin # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Detected run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? $SED '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; "disable-rpath":C) sed < libtool > libtool-2 \ 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/' mv libtool-2 libtool chmod 755 libtool libtool="./libtool" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi echo "copying header files" for file in $srcdir/ldns//*.h; do sh $srcdir/install-sh -m 644 $file ldns/ done ldns-1.9.2/README.git0000664000175000017500000000153215212267520013476 0ustar willemwillem# The ldns git repository can found at: # git.nlnetlabs.nl/ldns/ # small list of commands to build all on a linux system # libtoolize is needed for most other targets # on Solaris, and other systems that may not have # the default 'automake' and 'aclocal' script aliases, # the correct versions may need to be set. On those # systems, the 'autoreconf' line should be changed to: # AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf # older versions of libtoolize do not support --install # so you might need to remove that (with newer versions # it is needed) git submodule update --init libtoolize -ci autoreconf -fi ./configure --with-examples --with-drill # --with-pyldns --with-p5-dns-ldns make make doc # needs doxygen for the html pages (cd pcat && autoreconf && ./configure && make) (cd examples/nsd-test && autoreconf && ./configure && make) ldns-1.9.2/host2wire.c0000664000175000017500000003377715212267520014146 0ustar willemwillem/* * host2wire.c * * conversion routines from the host to the wire format. * This will usually just a re-ordering of the * data (as we store it in network format) * * a Net::DNS like library for C * * (c) NLnet Labs, 2004-2006 * * See the file LICENSE for the license */ #include #include ldns_status ldns_dname2buffer_wire(ldns_buffer *buffer, const ldns_rdf *name) { return ldns_dname2buffer_wire_compress(buffer, name, NULL); } ldns_status ldns_dname2buffer_wire_compress(ldns_buffer *buffer, const ldns_rdf *name, ldns_rbtree_t *compression_data) { ldns_rbnode_t *node; uint8_t *data; size_t size; ldns_rdf *label; ldns_rdf *rest; ldns_status s; /* If no tree, just add the data */ if(!compression_data) { if (ldns_buffer_reserve(buffer, ldns_rdf_size(name))) { ldns_buffer_write(buffer, ldns_rdf_data(name), ldns_rdf_size(name)); } return ldns_buffer_status(buffer); } /* No labels left, write final zero */ if(ldns_dname_label_count(name)==0) { if(ldns_buffer_reserve(buffer,1)) { ldns_buffer_write_u8(buffer, 0); } return ldns_buffer_status(buffer); } /* Can we find the name in the tree? */ if((node = ldns_rbtree_search(compression_data, name)) != NULL) { /* Found */ uint16_t position = (uint16_t) (intptr_t) node->data | 0xC000; if (ldns_buffer_reserve(buffer, 2)) { ldns_buffer_write_u16(buffer, position); } return ldns_buffer_status(buffer); } else { /* Not found. Write cache entry, take off first label, write it, */ /* try again with the rest of the name. */ if (ldns_buffer_position(buffer) < 16384) { ldns_rdf *key; node = LDNS_MALLOC(ldns_rbnode_t); if(!node) { return LDNS_STATUS_MEM_ERR; } key = ldns_rdf_clone(name); if (!key) { LDNS_FREE(node); return LDNS_STATUS_MEM_ERR; } node->key = key; node->data = (void *) (intptr_t) ldns_buffer_position(buffer); if(!ldns_rbtree_insert(compression_data,node)) { /* fprintf(stderr,"Name not found but now it's there?\n"); */ ldns_rdf_deep_free(key); LDNS_FREE(node); } } label = ldns_dname_label(name, 0); rest = ldns_dname_left_chop(name); size = ldns_rdf_size(label) - 1; /* Don't want the final zero */ data = ldns_rdf_data(label); if(ldns_buffer_reserve(buffer, size)) { ldns_buffer_write(buffer, data, size); } ldns_rdf_deep_free(label); s = ldns_dname2buffer_wire_compress(buffer, rest, compression_data); ldns_rdf_deep_free(rest); return s; } } ldns_status ldns_rdf2buffer_wire(ldns_buffer *buffer, const ldns_rdf *rdf) { return ldns_rdf2buffer_wire_compress(buffer, rdf, NULL); } ldns_status ldns_rdf2buffer_wire_compress(ldns_buffer *buffer, const ldns_rdf *rdf, ldns_rbtree_t *compression_data) { /* If it's a DNAME, call that function to get compression */ if(compression_data && ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_DNAME) { return ldns_dname2buffer_wire_compress(buffer,rdf,compression_data); } if (ldns_buffer_reserve(buffer, ldns_rdf_size(rdf))) { ldns_buffer_write(buffer, ldns_rdf_data(rdf), ldns_rdf_size(rdf)); } return ldns_buffer_status(buffer); } ldns_status ldns_rdf2buffer_wire_canonical(ldns_buffer *buffer, const ldns_rdf *rdf) { size_t i; uint8_t *rdf_data; if (ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_DNAME) { if (ldns_buffer_reserve(buffer, ldns_rdf_size(rdf))) { rdf_data = ldns_rdf_data(rdf); for (i = 0; i < ldns_rdf_size(rdf); i++) { ldns_buffer_write_u8(buffer, (uint8_t) LDNS_DNAME_NORMALIZE((int)rdf_data[i])); } } } else { /* direct copy for all other types */ if (ldns_buffer_reserve(buffer, ldns_rdf_size(rdf))) { ldns_buffer_write(buffer, ldns_rdf_data(rdf), ldns_rdf_size(rdf)); } } return ldns_buffer_status(buffer); } /* convert a rr list to wireformat */ ldns_status ldns_rr_list2buffer_wire(ldns_buffer *buffer,const ldns_rr_list *rr_list) { uint16_t rr_count; uint16_t i; rr_count = ldns_rr_list_rr_count(rr_list); for(i = 0; i < rr_count; i++) { (void)ldns_rr2buffer_wire(buffer, ldns_rr_list_rr(rr_list, i), LDNS_SECTION_ANY); } return ldns_buffer_status(buffer); } ldns_status ldns_rr2buffer_wire_canonical(ldns_buffer *buffer, const ldns_rr *rr, int section) { uint16_t i; uint16_t rdl_pos = 0; bool pre_rfc3597 = false; switch (ldns_rr_get_type(rr)) { case LDNS_RR_TYPE_NS: case LDNS_RR_TYPE_MD: case LDNS_RR_TYPE_MF: case LDNS_RR_TYPE_CNAME: case LDNS_RR_TYPE_SOA: case LDNS_RR_TYPE_MB: case LDNS_RR_TYPE_MG: case LDNS_RR_TYPE_MR: case LDNS_RR_TYPE_PTR: case LDNS_RR_TYPE_HINFO: case LDNS_RR_TYPE_MINFO: case LDNS_RR_TYPE_MX: case LDNS_RR_TYPE_RP: case LDNS_RR_TYPE_AFSDB: case LDNS_RR_TYPE_RT: case LDNS_RR_TYPE_SIG: case LDNS_RR_TYPE_PX: case LDNS_RR_TYPE_NXT: case LDNS_RR_TYPE_NAPTR: case LDNS_RR_TYPE_KX: case LDNS_RR_TYPE_SRV: case LDNS_RR_TYPE_DNAME: case LDNS_RR_TYPE_A6: case LDNS_RR_TYPE_RRSIG: pre_rfc3597 = true; break; default: break; } if (ldns_rr_owner(rr)) { (void) ldns_rdf2buffer_wire_canonical(buffer, ldns_rr_owner(rr)); } if (ldns_buffer_reserve(buffer, 4)) { (void) ldns_buffer_write_u16(buffer, ldns_rr_get_type(rr)); (void) ldns_buffer_write_u16(buffer, ldns_rr_get_class(rr)); } if (section != LDNS_SECTION_QUESTION) { if (ldns_buffer_reserve(buffer, 6)) { ldns_buffer_write_u32(buffer, ldns_rr_ttl(rr)); /* remember pos for later */ rdl_pos = ldns_buffer_position(buffer); ldns_buffer_write_u16(buffer, 0); } for (i = 0; i < ldns_rr_rd_count(rr); i++) { if (pre_rfc3597) { (void) ldns_rdf2buffer_wire_canonical( buffer, ldns_rr_rdf(rr, i)); } else { (void) ldns_rdf2buffer_wire( buffer, ldns_rr_rdf(rr, i)); } } if (rdl_pos != 0) { ldns_buffer_write_u16_at(buffer, rdl_pos, ldns_buffer_position(buffer) - rdl_pos - 2); } } return ldns_buffer_status(buffer); } ldns_status ldns_rr2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr, int section) { return ldns_rr2buffer_wire_compress(buffer,rr,section,NULL); } ldns_status ldns_rr2buffer_wire_compress(ldns_buffer *buffer, const ldns_rr *rr, int section, ldns_rbtree_t *compression_data) { uint16_t i; uint16_t rdl_pos = 0; if (ldns_rr_owner(rr)) { (void) ldns_dname2buffer_wire_compress(buffer, ldns_rr_owner(rr), compression_data); } if (ldns_buffer_reserve(buffer, 4)) { (void) ldns_buffer_write_u16(buffer, ldns_rr_get_type(rr)); (void) ldns_buffer_write_u16(buffer, ldns_rr_get_class(rr)); } if (section != LDNS_SECTION_QUESTION) { if (ldns_buffer_reserve(buffer, 6)) { ldns_buffer_write_u32(buffer, ldns_rr_ttl(rr)); /* remember pos for later */ rdl_pos = ldns_buffer_position(buffer); ldns_buffer_write_u16(buffer, 0); } if (LDNS_RR_COMPRESS == ldns_rr_descript(ldns_rr_get_type(rr))->_compress) { for (i = 0; i < ldns_rr_rd_count(rr); i++) { (void) ldns_rdf2buffer_wire_compress(buffer, ldns_rr_rdf(rr, i), compression_data); } } else { for (i = 0; i < ldns_rr_rd_count(rr); i++) { (void) ldns_rdf2buffer_wire( buffer, ldns_rr_rdf(rr, i)); } } if (rdl_pos != 0) { ldns_buffer_write_u16_at(buffer, rdl_pos, ldns_buffer_position(buffer) - rdl_pos - 2); } } return ldns_buffer_status(buffer); } ldns_status ldns_rrsig2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr) { uint16_t i; /* it must be a sig RR */ if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) { return LDNS_STATUS_ERR; } /* Convert all the rdfs, except the actual signature data * rdf number 8 - the last, hence: -1 */ for (i = 0; i < ldns_rr_rd_count(rr) - 1; i++) { (void) ldns_rdf2buffer_wire_canonical(buffer, ldns_rr_rdf(rr, i)); } return ldns_buffer_status(buffer); } ldns_status ldns_rr_rdata2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr) { uint16_t i; /* convert all the rdf's */ for (i = 0; i < ldns_rr_rd_count(rr); i++) { (void) ldns_rdf2buffer_wire(buffer, ldns_rr_rdf(rr,i)); } return ldns_buffer_status(buffer); } /* * Copies the packet header data to the buffer in wire format */ static ldns_status ldns_hdr2buffer_wire(ldns_buffer *buffer, const ldns_pkt *packet) { uint8_t flags; uint16_t arcount; if (ldns_buffer_reserve(buffer, 12)) { ldns_buffer_write_u16(buffer, ldns_pkt_id(packet)); flags = ldns_pkt_qr(packet) << 7 | ldns_pkt_get_opcode(packet) << 3 | ldns_pkt_aa(packet) << 2 | ldns_pkt_tc(packet) << 1 | ldns_pkt_rd(packet); ldns_buffer_write_u8(buffer, flags); flags = ldns_pkt_ra(packet) << 7 /*| ldns_pkt_z(packet) << 6*/ | ldns_pkt_ad(packet) << 5 | ldns_pkt_cd(packet) << 4 | ldns_pkt_get_rcode(packet); ldns_buffer_write_u8(buffer, flags); ldns_buffer_write_u16(buffer, ldns_pkt_qdcount(packet)); ldns_buffer_write_u16(buffer, ldns_pkt_ancount(packet)); ldns_buffer_write_u16(buffer, ldns_pkt_nscount(packet)); /* add EDNS0 and TSIG to additional if they are there */ arcount = ldns_pkt_arcount(packet); if (ldns_pkt_tsig(packet)) { arcount++; } if (ldns_pkt_edns(packet)) { arcount++; } ldns_buffer_write_u16(buffer, arcount); } return ldns_buffer_status(buffer); } static void compression_node_free(ldns_rbnode_t *node, void *arg) { (void)arg; /* Yes, dear compiler, it is used */ ldns_rdf_deep_free((ldns_rdf *)node->key); LDNS_FREE(node); } ldns_status ldns_pkt2buffer_wire(ldns_buffer *buffer, const ldns_pkt *packet) { ldns_status status; ldns_rbtree_t *compression_data = ldns_rbtree_create(ldns_dname_compare_v); status = ldns_pkt2buffer_wire_compress(buffer, packet, compression_data); ldns_traverse_postorder(compression_data,compression_node_free,NULL); ldns_rbtree_free(compression_data); return status; } ldns_status ldns_pkt2buffer_wire_compress(ldns_buffer *buffer, const ldns_pkt *packet, ldns_rbtree_t *compression_data) { ldns_rr_list *rr_list; uint16_t i; /* edns tmp vars */ ldns_rr *edns_rr; uint8_t edata[4]; ldns_buffer *edns_buf = NULL; ldns_rdf *edns_rdf = NULL; (void) ldns_hdr2buffer_wire(buffer, packet); rr_list = ldns_pkt_question(packet); if (rr_list) { for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { (void) ldns_rr2buffer_wire_compress(buffer, ldns_rr_list_rr(rr_list, i), LDNS_SECTION_QUESTION, compression_data); } } rr_list = ldns_pkt_answer(packet); if (rr_list) { for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { (void) ldns_rr2buffer_wire_compress(buffer, ldns_rr_list_rr(rr_list, i), LDNS_SECTION_ANSWER, compression_data); } } rr_list = ldns_pkt_authority(packet); if (rr_list) { for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { (void) ldns_rr2buffer_wire_compress(buffer, ldns_rr_list_rr(rr_list, i), LDNS_SECTION_AUTHORITY, compression_data); } } rr_list = ldns_pkt_additional(packet); if (rr_list) { for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { (void) ldns_rr2buffer_wire_compress(buffer, ldns_rr_list_rr(rr_list, i), LDNS_SECTION_ADDITIONAL, compression_data); } } /* add EDNS to additional if it is needed */ if (ldns_pkt_edns(packet)) { edns_rr = ldns_rr_new(); if(!edns_rr) return LDNS_STATUS_MEM_ERR; ldns_rr_set_owner(edns_rr, ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, ".")); ldns_rr_set_type(edns_rr, LDNS_RR_TYPE_OPT); ldns_rr_set_class(edns_rr, ldns_pkt_edns_udp_size(packet)); edata[0] = ldns_pkt_edns_extended_rcode(packet); edata[1] = ldns_pkt_edns_version(packet); ldns_write_uint16(&edata[2], ldns_pkt_edns_z(packet)); ldns_rr_set_ttl(edns_rr, ldns_read_uint32(edata)); /* don't forget to add the edns rdata (if any) */ if ((edns_buf = ldns_edns_option_list2wireformat_buffer(packet->_edns_list))) { edns_rdf = ldns_rdf_new( LDNS_RDF_TYPE_UNKNOWN , ldns_buffer_limit(edns_buf) , ldns_buffer_export(edns_buf)); ldns_buffer_free(edns_buf); } if (edns_rdf) ldns_rr_push_rdf(edns_rr, edns_rdf); else if (packet->_edns_data) ldns_rr_push_rdf(edns_rr, packet->_edns_data); (void)ldns_rr2buffer_wire_compress(buffer, edns_rr, LDNS_SECTION_ADDITIONAL, compression_data); /* if the rdata of the OPT came from packet->_edns_data * we need to take it back out of the edns_rr before we free it * so packet->_edns_data doesn't get freed */ if (!edns_rdf && packet->_edns_data) (void)ldns_rr_pop_rdf (edns_rr); ldns_rr_free(edns_rr); } /* add TSIG to additional if it is there */ if (ldns_pkt_tsig(packet)) { (void) ldns_rr2buffer_wire_compress(buffer, ldns_pkt_tsig(packet), LDNS_SECTION_ADDITIONAL, compression_data); } return LDNS_STATUS_OK; } ldns_status ldns_rdf2wire(uint8_t **dest, const ldns_rdf *rdf, size_t *result_size) { ldns_buffer *buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN); ldns_status status; *result_size = 0; *dest = NULL; if(!buffer) return LDNS_STATUS_MEM_ERR; status = ldns_rdf2buffer_wire(buffer, rdf); if (status == LDNS_STATUS_OK) { *result_size = ldns_buffer_position(buffer); *dest = (uint8_t *) ldns_buffer_export(buffer); } ldns_buffer_free(buffer); return status; } ldns_status ldns_rr2wire(uint8_t **dest, const ldns_rr *rr, int section, size_t *result_size) { ldns_buffer *buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN); ldns_status status; *result_size = 0; *dest = NULL; if(!buffer) return LDNS_STATUS_MEM_ERR; status = ldns_rr2buffer_wire(buffer, rr, section); if (status == LDNS_STATUS_OK) { *result_size = ldns_buffer_position(buffer); *dest = (uint8_t *) ldns_buffer_export(buffer); } ldns_buffer_free(buffer); return status; } ldns_status ldns_pkt2wire(uint8_t **dest, const ldns_pkt *packet, size_t *result_size) { ldns_buffer *buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN); ldns_status status; *result_size = 0; *dest = NULL; if(!buffer) return LDNS_STATUS_MEM_ERR; status = ldns_pkt2buffer_wire(buffer, packet); if (status == LDNS_STATUS_OK) { *result_size = ldns_buffer_position(buffer); *dest = (uint8_t *) ldns_buffer_export(buffer); } ldns_buffer_free(buffer); return status; } ldns-1.9.2/error.c0000664000175000017500000002670115212267520013336 0ustar willemwillem/* * a error2str function to make sense of all the * error codes we have laying around * * a Net::DNS like library for C * LibDNS Team @ NLnet Labs * (c) NLnet Labs, 2005-2006 * See the file LICENSE for the license */ #include #include ldns_lookup_table ldns_error_str[] = { { LDNS_STATUS_OK, "All OK" }, { LDNS_STATUS_EMPTY_LABEL, "Empty label" }, { LDNS_STATUS_LABEL_OVERFLOW, "Label length overflow" }, { LDNS_STATUS_DOMAINNAME_OVERFLOW, "Domainname length overflow" }, { LDNS_STATUS_DOMAINNAME_UNDERFLOW, "Domainname length underflow (zero length)" }, { LDNS_STATUS_DDD_OVERFLOW, "\\DDD sequence overflow (>255)" }, { LDNS_STATUS_PACKET_OVERFLOW, "Packet size overflow" }, { LDNS_STATUS_INVALID_POINTER, "Invalid compression pointer" }, { LDNS_STATUS_MEM_ERR, "General memory error" }, { LDNS_STATUS_INTERNAL_ERR, "Internal error, this should not happen" }, { LDNS_STATUS_SSL_ERR, "Error in SSL library" }, { LDNS_STATUS_ERR, "General LDNS error" }, { LDNS_STATUS_INVALID_INT, "Conversion error, integer expected" }, { LDNS_STATUS_INVALID_IP4, "Conversion error, ip4 addr expected" }, { LDNS_STATUS_INVALID_IP6, "Conversion error, ip6 addr expected" }, { LDNS_STATUS_INVALID_STR, "Conversion error, string expected" }, { LDNS_STATUS_INVALID_B32_EXT, "Conversion error, b32 ext encoding expected" }, { LDNS_STATUS_INVALID_B64, "Conversion error, b64 encoding expected" }, { LDNS_STATUS_INVALID_HEX, "Conversion error, hex encoding expected" }, { LDNS_STATUS_INVALID_TIME, "Conversion error, time encoding expected" }, { LDNS_STATUS_NETWORK_ERR, "Could not send or receive, because of network error" }, { LDNS_STATUS_ADDRESS_ERR, "Could not start AXFR, because of address error" }, { LDNS_STATUS_FILE_ERR, "Could not open the files" }, { LDNS_STATUS_UNKNOWN_INET, "Unknown address family" }, { LDNS_STATUS_NOT_IMPL, "This function is not implemented (yet), please notify the developers - or not..." }, { LDNS_STATUS_NULL, "Supplied value pointer null" }, { LDNS_STATUS_CRYPTO_UNKNOWN_ALGO, "Unknown cryptographic algorithm" }, { LDNS_STATUS_CRYPTO_ALGO_NOT_IMPL, "Cryptographic algorithm not implemented" }, { LDNS_STATUS_CRYPTO_NO_RRSIG, "No DNSSEC signature(s)" }, { LDNS_STATUS_CRYPTO_NO_DNSKEY, "No DNSSEC public key(s)" }, { LDNS_STATUS_CRYPTO_TYPE_COVERED_ERR, "The signature does not cover this RRset" }, { LDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEY, "No signatures found for trusted DNSSEC public key(s)" }, { LDNS_STATUS_CRYPTO_NO_DS, "No DS record(s)" }, { LDNS_STATUS_CRYPTO_NO_TRUSTED_DS, "Could not validate DS record(s)" }, { LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY, "No keys with the keytag and algorithm from the RRSIG found" }, { LDNS_STATUS_CRYPTO_VALIDATED, "Valid DNSSEC signature" }, { LDNS_STATUS_CRYPTO_BOGUS, "Bogus DNSSEC signature" }, { LDNS_STATUS_CRYPTO_SIG_EXPIRED, "DNSSEC signature has expired" }, { LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED, "DNSSEC signature not incepted yet" }, { LDNS_STATUS_CRYPTO_TSIG_BOGUS, "Bogus TSIG signature" }, { LDNS_STATUS_CRYPTO_TSIG_ERR, "Could not create TSIG signature" }, { LDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTION, "DNSSEC signature has expiration date earlier than inception date" }, { LDNS_STATUS_ENGINE_KEY_NOT_LOADED, "Unable to load private key from engine" }, { LDNS_STATUS_NSEC3_ERR, "Error in NSEC3 denial of existence proof" }, { LDNS_STATUS_RES_NO_NS, "No (valid) nameservers defined in the resolver" }, { LDNS_STATUS_RES_QUERY, "No correct query given to resolver" }, { LDNS_STATUS_WIRE_INCOMPLETE_HEADER, "header section incomplete" }, { LDNS_STATUS_WIRE_INCOMPLETE_QUESTION, "question section incomplete" }, { LDNS_STATUS_WIRE_INCOMPLETE_ANSWER, "answer section incomplete" }, { LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY, "authority section incomplete" }, { LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL, "additional section incomplete" }, { LDNS_STATUS_NO_DATA, "No data" }, { LDNS_STATUS_EXISTS_ERR, "Element already exists" }, { LDNS_STATUS_CERT_BAD_ALGORITHM, "Bad algorithm type for CERT record" }, { LDNS_STATUS_SYNTAX_TYPE_ERR, "Syntax error, could not parse the RR's type" }, { LDNS_STATUS_SYNTAX_CLASS_ERR, "Syntax error, could not parse the RR's class" }, { LDNS_STATUS_SYNTAX_TTL_ERR, "Syntax error, could not parse the RR's TTL" }, { LDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPL, "Syntax error, $INCLUDE not implemented" }, { LDNS_STATUS_SYNTAX_RDATA_ERR, "Syntax error, could not parse the RR's rdata" }, { LDNS_STATUS_SYNTAX_DNAME_ERR, "Syntax error, could not parse the RR's dname(s)" }, { LDNS_STATUS_SYNTAX_VERSION_ERR, "Syntax error, version mismatch" }, { LDNS_STATUS_SYNTAX_ALG_ERR, "Syntax error, algorithm unknown or non parseable" }, { LDNS_STATUS_SYNTAX_KEYWORD_ERR, "Syntax error, unknown keyword in input" }, { LDNS_STATUS_SYNTAX_ERR, "Syntax error, could not parse the RR" }, { LDNS_STATUS_SYNTAX_EMPTY, "Empty line was returned" }, { LDNS_STATUS_SYNTAX_TTL, "$TTL directive was seen in the zone" }, { LDNS_STATUS_SYNTAX_ORIGIN, "$ORIGIN directive was seen in the zone" }, { LDNS_STATUS_SYNTAX_INCLUDE, "$INCLUDE directive was seen in the zone" }, { LDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOW, "Iterations count for NSEC3 record higher than maximum" }, { LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR, "Syntax error, value expected" }, { LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW, "Syntax error, integer value too large" }, { LDNS_STATUS_SYNTAX_BAD_ESCAPE, "Syntax error, bad escape sequence" }, { LDNS_STATUS_SOCKET_ERROR, "Error creating socket" }, { LDNS_STATUS_DNSSEC_EXISTENCE_DENIED, "Existence denied by NSEC" }, { LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED, "RR not covered by the given NSEC RRs" }, { LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED, "wildcard not covered by the given NSEC RRs" }, { LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND, "original of NSEC3 hashed name could not be found" }, { LDNS_STATUS_MISSING_RDATA_FIELDS_RRSIG, "The RRSIG has to few rdata fields" }, { LDNS_STATUS_MISSING_RDATA_FIELDS_KEY, "The DNSKEY has to few rdata fields" }, { LDNS_STATUS_CRYPTO_SIG_EXPIRED_WITHIN_MARGIN, "DNSSEC signature will expire too soon" }, { LDNS_STATUS_CRYPTO_SIG_NOT_INCEPTED_WITHIN_MARGIN, "DNSSEC signature not incepted long enough" }, { LDNS_STATUS_DANE_UNKNOWN_CERTIFICATE_USAGE, "Unknown TLSA Certificate Usage" }, { LDNS_STATUS_DANE_UNKNOWN_SELECTOR, "Unknown TLSA Selector" }, { LDNS_STATUS_DANE_UNKNOWN_MATCHING_TYPE, "Unknown TLSA Matching Type" }, { LDNS_STATUS_DANE_UNKNOWN_PROTOCOL, "Unknown protocol. Only IPv4 and IPv6 are understood" }, { LDNS_STATUS_DANE_UNKNOWN_TRANSPORT, "Unknown transport. Should be one of {tcp, udp, sctp}" }, { LDNS_STATUS_DANE_MISSING_EXTRA_CERTS, /* Trust anchor assertion */ "More than one certificate should be provided" }, { LDNS_STATUS_DANE_EXTRA_CERTS_NOT_USED, /* Trust anchor assertion */ "Non of the extra certificates is used to sign the first" }, { LDNS_STATUS_DANE_OFFSET_OUT_OF_RANGE, /* Trust anchor assertion */ "The offset was out of range" }, { LDNS_STATUS_DANE_INSECURE, /* Unused by library */ "The queried resource records were insecure" }, { LDNS_STATUS_DANE_BOGUS, /* Unused by library */ "The queried resource records were bogus" }, { LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH, "The TLSA record(s) " "did not match with the server certificate (chain)" }, { LDNS_STATUS_DANE_NON_CA_CERTIFICATE, "The certificate was not a CA certificate" }, { LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE, "Could not PKIX validate" }, { LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR, "The validation path " "did not end in a self-signed certificate" }, { LDNS_STATUS_INVALID_ILNP64, "Conversion error, 4 colon separated hex numbers expected" }, { LDNS_STATUS_INVALID_EUI48, "Conversion error, 6 two character hex numbers " "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx" }, { LDNS_STATUS_INVALID_EUI64, "Conversion error, 8 two character hex numbers " "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx-xx-xx" }, { LDNS_STATUS_WIRE_RDATA_ERR, "invalid rdata in wire format" }, { LDNS_STATUS_INVALID_TAG, "Conversion error, a non-zero sequence of US-ASCII letters " "and numbers in lower case expected" }, { LDNS_STATUS_TYPE_NOT_IN_BITMAP, "The RR type bitmap rdata field did not have " "a bit reserved for the specific RR type" }, { LDNS_STATUS_INVALID_RDF_TYPE, "The rdata field was not of the expected type" }, { LDNS_STATUS_RDATA_OVERFLOW, "Rdata size overflow" }, { LDNS_STATUS_SYNTAX_SUPERFLUOUS_TEXT_ERR, "Syntax error, superfluous text present" }, { LDNS_STATUS_NSEC3_DOMAINNAME_OVERFLOW, "The NSEC3 domainname length overflow" }, #if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL) { LDNS_STATUS_DANE_NEED_OPENSSL_GE_1_1_FOR_DANE_TA, "ldns needs to be linked with OpenSSL >= 1.1.0 to be able " "to verify the DANE-TA usage type." }, #else { LDNS_STATUS_DANE_NEED_OPENSSL_GE_1_1_FOR_DANE_TA, "ldns depends on the availability of the SSL_get0_dane() and " "X509_STORE_CTX_set0_dane() functions within OpenSSL >= 1.1.0 " "to be able to verify the DANE-TA usage type." }, #endif { LDNS_STATUS_ZONEMD_DOUBLE_OCCURRENCE, "A ZONEMD with the same " " and hash algorithm occurred more than once." }, { LDNS_STATUS_ZONEMD_UNKNOWN_SCHEME, "Unknown ZONEMD " }, { LDNS_STATUS_ZONEMD_UNKNOWN_HASH, "Unknown ZONEMD hash algorithm" }, { LDNS_STATUS_ZONEMD_INVALID_SOA, "Missing or invalid SOA to associate with ZONEMD RR" }, { LDNS_STATUS_NO_ZONEMD, "NSEC(3) RRs indicate that a ZONEMD exists, " "but it is not found in the zone" }, { LDNS_STATUS_NO_VALID_ZONEMD, "No ZONEMD matching the zone data was found" }, { LDNS_STATUS_SYNTAX_SVCPARAM_KEY_ERR, "Syntax error in a key in " "the ServiceParam rdata field of SVCB or HTTPS RR" }, { LDNS_STATUS_SYNTAX_SVCPARAM_VALUE_ERR, "Syntax error in a value in " "the ServiceParam rdata field of SVCB or HTTPS RR" }, { LDNS_STATUS_RESERVED_SVCPARAM_KEY, "key65535 is reserved and MUST NOT be used " "in the ServiceParam rdata field of SVCB or HTTPS RR" }, { LDNS_STATUS_NO_SVCPARAM_VALUE_EXPECTED, "A value was found for a key that SHOULD not have a value " "in the ServiceParam rdata field of SVCB or HTTPS RR" }, { LDNS_STATUS_SVCPARAM_KEY_MORE_THAN_ONCE, "A key was found more than once " "in the ServiceParam rdata field of SVCB or HTTPS RR" }, { LDNS_STATUS_INVALID_SVCPARAM_VALUE, "Invalid wireformat of a value " "in the ServiceParam rdata field of SVCB or HTTPS RR" }, { LDNS_STATUS_NOT_EDE, "The EDNS option is not an extended error code" }, { LDNS_STATUS_EDE_OPTION_MALFORMED, "The extended error code option is malformed, expected " "at least 2 bytes of option data" }, { LDNS_STATUS_EQUAL_RR, "An identical RR already existed in the zone" }, { LDNS_STATUS_ID_DID_NOT_MATCH, "Response ID did not match the query ID" }, { LDNS_STATUS_QDCOUNT_MUST_BE_ONE, "The query section MUST contain exactly one question" }, { LDNS_STATUS_QUERY_DID_NOT_MATCH, "The question in the response did not match the query" }, { 0, NULL } }; const char * ldns_get_errorstr_by_id(ldns_status err) { ldns_lookup_table *lt; lt = ldns_lookup_by_id(ldns_error_str, err); if (lt) { return lt->name; } return NULL; } ldns-1.9.2/buffer.c0000664000175000017500000000736515212267520013463 0ustar willemwillem/* * buffer.c -- generic memory buffer . * * Copyright (c) 2001-2008, NLnet Labs. All rights reserved. * * See LICENSE for the license. * */ #include #include #include ldns_buffer * ldns_buffer_new(size_t capacity) { ldns_buffer *buffer = LDNS_MALLOC(ldns_buffer); if (!buffer) { return NULL; } buffer->_data = (uint8_t *) LDNS_XMALLOC(uint8_t, capacity); if (!buffer->_data) { LDNS_FREE(buffer); return NULL; } buffer->_position = 0; buffer->_limit = buffer->_capacity = capacity; buffer->_fixed = 0; buffer->_status = LDNS_STATUS_OK; ldns_buffer_invariant(buffer); return buffer; } void ldns_buffer_new_frm_data(ldns_buffer *buffer, const void *data, size_t size) { assert(data != NULL); buffer->_position = 0; buffer->_limit = buffer->_capacity = size; buffer->_fixed = 0; buffer->_data = LDNS_XMALLOC(uint8_t, size); if(!buffer->_data) { buffer->_status = LDNS_STATUS_MEM_ERR; return; } memcpy(buffer->_data, data, size); buffer->_status = LDNS_STATUS_OK; ldns_buffer_invariant(buffer); } bool ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity) { void *data; ldns_buffer_invariant(buffer); assert(buffer->_position <= capacity); assert(!buffer->_fixed); data = (uint8_t *) LDNS_XREALLOC(buffer->_data, uint8_t, capacity); if (!data) { buffer->_status = LDNS_STATUS_MEM_ERR; return false; } else { buffer->_data = data; buffer->_limit = buffer->_capacity = capacity; return true; } } bool ldns_buffer_reserve(ldns_buffer *buffer, size_t amount) { ldns_buffer_invariant(buffer); if (buffer->_capacity < buffer->_position + amount) { size_t new_capacity = buffer->_capacity * 3 / 2; if (new_capacity < buffer->_position + amount) { new_capacity = buffer->_position + amount; } if (!ldns_buffer_set_capacity(buffer, new_capacity)) { buffer->_status = LDNS_STATUS_MEM_ERR; return false; } } buffer->_limit = buffer->_capacity; return true; } int ldns_buffer_printf(ldns_buffer *buffer, const char *format, ...) { va_list args; int written = 0; size_t remaining; if (ldns_buffer_status_ok(buffer)) { ldns_buffer_invariant(buffer); assert(buffer->_limit == buffer->_capacity); remaining = ldns_buffer_remaining(buffer); va_start(args, format); written = vsnprintf((char *) ldns_buffer_current(buffer), remaining, format, args); va_end(args); if (written == -1) { buffer->_status = LDNS_STATUS_INTERNAL_ERR; return -1; } else if ((size_t) written >= remaining) { if (!ldns_buffer_reserve(buffer, (size_t) written + 1)) { buffer->_status = LDNS_STATUS_MEM_ERR; return -1; } va_start(args, format); written = vsnprintf((char *) ldns_buffer_current(buffer), ldns_buffer_remaining(buffer), format, args); va_end(args); if (written == -1) { buffer->_status = LDNS_STATUS_INTERNAL_ERR; return -1; } } buffer->_position += written; } return written; } void ldns_buffer_free(ldns_buffer *buffer) { if (!buffer) { return; } if (!buffer->_fixed) LDNS_FREE(buffer->_data); LDNS_FREE(buffer); } void * ldns_buffer_export(ldns_buffer *buffer) { buffer->_fixed = 1; return buffer->_data; } int ldns_bgetc(ldns_buffer *buffer) { if (!ldns_buffer_available_at(buffer, buffer->_position, sizeof(uint8_t))) { ldns_buffer_set_position(buffer, ldns_buffer_limit(buffer)); /* ldns_buffer_rewind(buffer);*/ return EOF; } return (int)ldns_buffer_read_u8(buffer); } void ldns_buffer_copy(ldns_buffer* result, const ldns_buffer* from) { size_t tocopy = ldns_buffer_limit(from); if(tocopy > ldns_buffer_capacity(result)) tocopy = ldns_buffer_capacity(result); ldns_buffer_clear(result); ldns_buffer_write(result, ldns_buffer_begin(from), tocopy); ldns_buffer_flip(result); } ldns-1.9.2/rr.c0000664000175000017500000026226215212267520012634 0ustar willemwillem/* rr.c * * access functions for ldns_rr - * a Net::DNS like library for C * LibDNS Team @ NLnet Labs * * (c) NLnet Labs, 2004-2006 * See the file LICENSE for the license */ #include #include #include #include #include #define LDNS_SYNTAX_DATALEN 16 #define LDNS_TTL_DATALEN 21 #define LDNS_RRLIST_INIT 8 #define _IS_WHITESPACE(chr) \ ( NULL != strchr( LDNS_PARSE_NO_NL, chr) ) #define _BUFFER_IS_AT_WHITESPACE(rd_buf) \ _IS_WHITESPACE(*(ldns_buffer_current(rd_buf))) ldns_rr * ldns_rr_new(void) { ldns_rr *rr; rr = LDNS_MALLOC(ldns_rr); if (!rr) { return NULL; } ldns_rr_set_owner(rr, NULL); ldns_rr_set_question(rr, false); ldns_rr_set_rd_count(rr, 0); rr->_rdata_fields = NULL; ldns_rr_set_class(rr, LDNS_RR_CLASS_IN); ldns_rr_set_ttl(rr, LDNS_DEFAULT_TTL); return rr; } ldns_rr * ldns_rr_new_frm_type(ldns_rr_type t) { ldns_rr *rr; const ldns_rr_descriptor *desc; size_t i; rr = LDNS_MALLOC(ldns_rr); if (!rr) { return NULL; } desc = ldns_rr_descript(t); rr->_rdata_fields = LDNS_XMALLOC(ldns_rdf *, ldns_rr_descriptor_minimum(desc)); if(!rr->_rdata_fields) { LDNS_FREE(rr); return NULL; } for (i = 0; i < ldns_rr_descriptor_minimum(desc); i++) { rr->_rdata_fields[i] = NULL; } ldns_rr_set_owner(rr, NULL); ldns_rr_set_question(rr, false); /* set the count to minimum */ ldns_rr_set_rd_count(rr, ldns_rr_descriptor_minimum(desc)); ldns_rr_set_class(rr, LDNS_RR_CLASS_IN); ldns_rr_set_ttl(rr, LDNS_DEFAULT_TTL); ldns_rr_set_type(rr, t); return rr; } void ldns_rr_free(ldns_rr *rr) { size_t i; if (rr) { if (ldns_rr_owner(rr)) { ldns_rdf_deep_free(ldns_rr_owner(rr)); } for (i = 0; i < ldns_rr_rd_count(rr); i++) { ldns_rdf_deep_free(ldns_rr_rdf(rr, i)); } LDNS_FREE(rr->_rdata_fields); LDNS_FREE(rr); } } /* Syntactic sugar for ldns_rr_new_frm_str_internal */ INLINE bool ldns_rdf_type_maybe_quoted(ldns_rdf_type rdf_type) { return rdf_type == LDNS_RDF_TYPE_STR || rdf_type == LDNS_RDF_TYPE_LONG_STR; } /* * trailing spaces are allowed * leading spaces are not allowed * allow ttl to be optional * class is optional too * if ttl is missing, and default_ttl is 0, use DEF_TTL * allow ttl to be written as 1d3h * So the RR should look like. e.g. * miek.nl. 3600 IN MX 10 elektron.atoom.net * or * miek.nl. 1h IN MX 10 elektron.atoom.net * or * miek.nl. IN MX 10 elektron.atoom.net */ static ldns_status ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str, uint32_t default_ttl, const ldns_rdf *origin, ldns_rdf **prev, bool question, bool *explicit_ttl) { ldns_rr *new; const ldns_rr_descriptor *desc; ldns_rr_type rr_type; ldns_buffer *rr_buf = NULL; ldns_buffer *rd_buf = NULL; uint32_t ttl_val; char *owner = NULL; char *ttl = NULL; ldns_rr_class clas_val; char *clas = NULL; char *type = NULL; size_t type_sz; char *rdata = NULL; char *rd = NULL; char *xtok = NULL; /* For RDF types with spaces (i.e. extra tokens) */ size_t rd_strlen; const char *delimiters; ssize_t c; ldns_rdf *owner_dname; const char* endptr; int was_unknown_rr_format = 0; ldns_status status = LDNS_STATUS_OK; /* used for types with unknown number of rdatas */ bool done; bool quoted; ldns_rdf *r = NULL; uint16_t r_cnt; uint16_t r_min; uint16_t r_max; size_t pre_data_pos; uint16_t hex_data_size; char *hex_data_str = NULL; uint16_t cur_hex_data_size; size_t hex_pos = 0; uint8_t *hex_data = NULL; new = ldns_rr_new(); owner = LDNS_XMALLOC(char, LDNS_MAX_DOMAINLEN + 1); ttl = LDNS_XMALLOC(char, LDNS_TTL_DATALEN); clas = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN); rdata = LDNS_XMALLOC(char, LDNS_MAX_PACKETLEN + 1); rr_buf = LDNS_MALLOC(ldns_buffer); rd_buf = LDNS_MALLOC(ldns_buffer); rd = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN); xtok = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN); if (rr_buf) { rr_buf->_data = NULL; } if (rd_buf) { rd_buf->_data = NULL; } if (!new || !owner || !ttl || !clas || !rdata || !rr_buf || !rd_buf || !rd || !xtok) { goto memerror; } ldns_buffer_new_frm_data(rr_buf, (char*)str, strlen(str)); /* split the rr in its parts -1 signals trouble */ if (ldns_bget_token(rr_buf, owner, "\t\n ", LDNS_MAX_DOMAINLEN) == -1){ status = LDNS_STATUS_SYNTAX_ERR; goto error; } if (ldns_bget_token(rr_buf, ttl, "\t\n ", LDNS_TTL_DATALEN) == -1) { status = LDNS_STATUS_SYNTAX_TTL_ERR; goto error; } ttl_val = (uint32_t) ldns_str2period(ttl, &endptr); if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) { /* ah, it's not there or something */ if (default_ttl == 0) { ttl_val = LDNS_DEFAULT_TTL; } else { ttl_val = default_ttl; } if (explicit_ttl) *explicit_ttl = false; /* we not ASSUMING the TTL is missing and that * the rest of the RR is still there. That is * CLASS TYPE RDATA * so ttl value we read is actually the class */ clas_val = ldns_get_rr_class_by_name(ttl); /* class can be left out too, assume IN, current * token must be type */ if (clas_val == 0) { clas_val = LDNS_RR_CLASS_IN; type_sz = strlen(ttl) + 1; type = LDNS_XMALLOC(char, type_sz); if (!type) { goto memerror; } strlcpy(type, ttl, type_sz); } } else { if (explicit_ttl) *explicit_ttl = true; if (-1 == ldns_bget_token( rr_buf, clas, "\t\n ", LDNS_SYNTAX_DATALEN)) { status = LDNS_STATUS_SYNTAX_CLASS_ERR; goto error; } clas_val = ldns_get_rr_class_by_name(clas); /* class can be left out too, assume IN, current * token must be type */ if (clas_val == 0) { clas_val = LDNS_RR_CLASS_IN; type_sz = strlen(clas) + 1; type = LDNS_XMALLOC(char, type_sz); if (!type) { goto memerror; } strlcpy(type, clas, type_sz); } } /* the rest should still be waiting for us */ if (!type) { type = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN); if (!type) { goto memerror; } if (-1 == ldns_bget_token( rr_buf, type, "\t\n ", LDNS_SYNTAX_DATALEN)) { status = LDNS_STATUS_SYNTAX_TYPE_ERR; goto error; } } if (ldns_bget_token(rr_buf, rdata, "\0", LDNS_MAX_PACKETLEN) == -1) { /* apparently we are done, and it's only a question RR * so do not set status and go to ldnserror here */ } ldns_buffer_new_frm_data(rd_buf, rdata, strlen(rdata)); if (strncmp(owner, "@", 1) == 0) { if (origin) { ldns_rr_set_owner(new, ldns_rdf_clone(origin)); } else if (prev && *prev) { ldns_rr_set_owner(new, ldns_rdf_clone(*prev)); } else { /* default to root */ ldns_rr_set_owner(new, ldns_dname_new_frm_str(".")); } /* @ also overrides prev */ if (prev) { ldns_rdf_deep_free(*prev); *prev = ldns_rdf_clone(ldns_rr_owner(new)); if (!*prev) { goto memerror; } } } else { if (strlen(owner) == 0) { /* no ownername was given, try prev, if that fails * origin, else default to root */ if (prev && *prev) { ldns_rr_set_owner(new, ldns_rdf_clone(*prev)); } else if (origin) { ldns_rr_set_owner(new, ldns_rdf_clone(origin)); } else { ldns_rr_set_owner(new, ldns_dname_new_frm_str(".")); } if(!ldns_rr_owner(new)) { goto memerror; } } else { owner_dname = ldns_dname_new_frm_str(owner); if (!owner_dname) { status = LDNS_STATUS_SYNTAX_ERR; goto error; } ldns_rr_set_owner(new, owner_dname); if (!ldns_dname_str_absolute(owner) && origin) { if(ldns_dname_cat(ldns_rr_owner(new), origin) != LDNS_STATUS_OK) { status = LDNS_STATUS_SYNTAX_ERR; goto error; } } if (prev) { ldns_rdf_deep_free(*prev); *prev = ldns_rdf_clone(ldns_rr_owner(new)); if (!*prev) { goto error; } } } } LDNS_FREE(owner); ldns_rr_set_question(new, question); ldns_rr_set_ttl(new, ttl_val); LDNS_FREE(ttl); ldns_rr_set_class(new, clas_val); LDNS_FREE(clas); rr_type = ldns_get_rr_type_by_name(type); LDNS_FREE(type); desc = ldns_rr_descript((uint16_t)rr_type); ldns_rr_set_type(new, rr_type); if (desc) { /* only the rdata remains */ r_max = ldns_rr_descriptor_maximum(desc); r_min = ldns_rr_descriptor_minimum(desc); } else { r_min = 0; r_max = 1; } for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) { quoted = false; switch (ldns_rr_descriptor_field_type(desc, r_cnt)) { case LDNS_RDF_TYPE_B64 : case LDNS_RDF_TYPE_HEX : /* These rdf types may con- */ case LDNS_RDF_TYPE_NSEC : /* tain whitespace, only if */ case LDNS_RDF_TYPE_LOC : /* it is the last rd field. */ case LDNS_RDF_TYPE_WKS : case LDNS_RDF_TYPE_IPSECKEY : case LDNS_RDF_TYPE_AMTRELAY : case LDNS_RDF_TYPE_SVCPARAMS : if (r_cnt == r_max - 1) { delimiters = "\n"; break; } /* fallthrough */ default : delimiters = "\n\t "; } if (ldns_rdf_type_maybe_quoted( ldns_rr_descriptor_field_type( desc, r_cnt)) && ldns_buffer_remaining(rd_buf) > 0){ /* skip whitespace */ while (ldns_buffer_remaining(rd_buf) > 0 && _BUFFER_IS_AT_WHITESPACE(rd_buf)) { ldns_buffer_skip(rd_buf, 1); } if (ldns_buffer_remaining(rd_buf) > 0 && *(ldns_buffer_current(rd_buf)) == '\"') { delimiters = "\"\0"; ldns_buffer_skip(rd_buf, 1); quoted = true; } } /* because number of fields can be variable, we can't rely on * _maximum() only */ /* skip whitespace */ while (ldns_buffer_position(rd_buf) < ldns_buffer_limit(rd_buf) && _BUFFER_IS_AT_WHITESPACE(rd_buf) && !quoted) { ldns_buffer_skip(rd_buf, 1); } pre_data_pos = ldns_buffer_position(rd_buf); if (-1 == ldns_bget_token( rd_buf, rd, delimiters, LDNS_MAX_RDFLEN)) { done = true; (void)done; /* we're breaking, so done not read anymore */ break; } /* hmmz, rfc3597 specifies that any type can be represented * with \# method, which can contain spaces... * it does specify size though... */ rd_strlen = strlen(rd); /* unknown RR data */ if (strncmp(rd, "\\#", 2) == 0 && !quoted && (rd_strlen == 2 || _IS_WHITESPACE(rd[2]))) { was_unknown_rr_format = 1; /* go back to before \# * and skip it while setting delimiters better */ ldns_buffer_set_position(rd_buf, pre_data_pos); delimiters = "\n\t "; (void)ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN); /* read rdata octet length */ c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN); if (c == -1) { /* something goes very wrong here */ status = LDNS_STATUS_SYNTAX_RDATA_ERR; goto error; } hex_data_size = (uint16_t) atoi(rd); /* copy hex chars into hex str (2 chars per byte) */ hex_data_str = LDNS_XMALLOC(char, 2*hex_data_size + 1); if (!hex_data_str) { /* malloc error */ goto memerror; } cur_hex_data_size = 0; while(cur_hex_data_size < 2 * hex_data_size) { c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN); if (c == -1) { status = LDNS_STATUS_SYNTAX_RDATA_ERR; goto error; } rd_strlen = strlen(rd); if ((size_t)cur_hex_data_size + rd_strlen > 2 * (size_t)hex_data_size) { status = LDNS_STATUS_SYNTAX_RDATA_ERR; goto error; } strlcpy(hex_data_str + cur_hex_data_size, rd, rd_strlen + 1); cur_hex_data_size += rd_strlen; } hex_data_str[cur_hex_data_size] = '\0'; /* correct the rdf type */ /* if *we* know the type, interpret it as wireformat */ if (desc) { hex_pos = 0; hex_data = LDNS_XMALLOC(uint8_t, hex_data_size+2); if (!hex_data) { goto memerror; } ldns_write_uint16(hex_data, hex_data_size); ldns_hexstring_to_data( hex_data + 2, hex_data_str); status = ldns_wire2rdf(new, hex_data, hex_data_size + 2, &hex_pos); if (status != LDNS_STATUS_OK) { goto error; } LDNS_FREE(hex_data); } else { r = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX, hex_data_str); if (!r) { goto memerror; } ldns_rdf_set_type(r, LDNS_RDF_TYPE_UNKNOWN); if (!ldns_rr_push_rdf(new, r)) { goto memerror; } } LDNS_FREE(hex_data_str); } else if(rd_strlen > 0 || quoted) { /* Normal RR */ switch(ldns_rr_descriptor_field_type(desc, r_cnt)) { case LDNS_RDF_TYPE_HEX: case LDNS_RDF_TYPE_B64: /* When this is the last rdata field, then the * rest should be read in (cause then these * rdf types may contain spaces). */ if (r_cnt == r_max - 1) { c = ldns_bget_token(rd_buf, xtok, "\n", LDNS_MAX_RDFLEN); if (c != -1) { (void) strncat(rd, xtok, LDNS_MAX_RDFLEN - strlen(rd) - 1); } } r = ldns_rdf_new_frm_str( ldns_rr_descriptor_field_type( desc, r_cnt), rd); break; case LDNS_RDF_TYPE_HIP: /* * In presentation format this RDATA type has * three tokens: An algorithm byte, then a * variable length HIT (in hexbytes) and then * a variable length Public Key (in base64). * * We have just read the algorithm, so we need * two more tokens: HIT and Public Key. */ do { /* Read and append HIT */ if (ldns_bget_token(rd_buf, xtok, delimiters, LDNS_MAX_RDFLEN) == -1) break; (void) strncat(rd, " ", LDNS_MAX_RDFLEN - strlen(rd) - 1); (void) strncat(rd, xtok, LDNS_MAX_RDFLEN - strlen(rd) - 1); /* Read and append Public Key*/ if (ldns_bget_token(rd_buf, xtok, delimiters, LDNS_MAX_RDFLEN) == -1) break; (void) strncat(rd, " ", LDNS_MAX_RDFLEN - strlen(rd) - 1); (void) strncat(rd, xtok, LDNS_MAX_RDFLEN - strlen(rd) - 1); } while (false); r = ldns_rdf_new_frm_str( ldns_rr_descriptor_field_type( desc, r_cnt), rd); break; case LDNS_RDF_TYPE_DNAME: r = ldns_rdf_new_frm_str( ldns_rr_descriptor_field_type( desc, r_cnt), rd); /* check if the origin should be used * or concatenated */ if (r && ldns_rdf_size(r) > 1 && ldns_rdf_data(r)[0] == 1 && ldns_rdf_data(r)[1] == '@') { ldns_rdf_deep_free(r); r = origin ? ldns_rdf_clone(origin) : ( rr_type == LDNS_RR_TYPE_SOA ? ldns_rdf_clone( ldns_rr_owner(new)) : ldns_rdf_new_frm_str( LDNS_RDF_TYPE_DNAME, ".") ); } else if (r && rd_strlen >= 1 && (origin || rr_type == LDNS_RR_TYPE_SOA) && !ldns_dname_str_absolute(rd)) { status = ldns_dname_cat(r, origin ? origin : ldns_rr_owner(new)); if (status != LDNS_STATUS_OK) { goto error; } } break; default: r = ldns_rdf_new_frm_str( ldns_rr_descriptor_field_type( desc, r_cnt), rd); break; } if (!r) { status = LDNS_STATUS_SYNTAX_RDATA_ERR; goto error; } ldns_rr_push_rdf(new, r); } } /* for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) */ LDNS_FREE(rd); LDNS_FREE(xtok); ldns_buffer_free(rr_buf); LDNS_FREE(rdata); if (ldns_buffer_remaining(rd_buf) > 0) { ldns_buffer_free(rd_buf); ldns_rr_free(new); return LDNS_STATUS_SYNTAX_SUPERFLUOUS_TEXT_ERR; } ldns_buffer_free(rd_buf); if (!question && desc && !was_unknown_rr_format && ldns_rr_rd_count(new) < r_min) { ldns_rr_free(new); return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR; } if (newrr) { *newrr = new; } else { /* Maybe the caller just wanted to see if it would parse? */ ldns_rr_free(new); } return LDNS_STATUS_OK; memerror: status = LDNS_STATUS_MEM_ERR; error: if (rd_buf && rd_buf->_data) { ldns_buffer_free(rd_buf); } else { LDNS_FREE(rd_buf); } if (rr_buf && rr_buf->_data) { ldns_buffer_free(rr_buf); } else { LDNS_FREE(rr_buf); } LDNS_FREE(type); LDNS_FREE(owner); LDNS_FREE(ttl); LDNS_FREE(clas); LDNS_FREE(hex_data); LDNS_FREE(hex_data_str); LDNS_FREE(xtok); LDNS_FREE(rd); LDNS_FREE(rdata); ldns_rr_free(new); return status; } ldns_status ldns_rr_new_frm_str(ldns_rr **newrr, const char *str, uint32_t default_ttl, const ldns_rdf *origin, ldns_rdf **prev) { return ldns_rr_new_frm_str_internal(newrr, str, default_ttl, origin, prev, false, NULL); } ldns_status ldns_rr_new_question_frm_str(ldns_rr **newrr, const char *str, const ldns_rdf *origin, ldns_rdf **prev) { return ldns_rr_new_frm_str_internal(newrr, str, 0, origin, prev, true, NULL); } /* Strip whitespace from the start and the end of . */ static char * ldns_strip_ws(char *line) { char *s = line, *e; for (s = line; *s && isspace((unsigned char)*s); s++) ; for (e = strchr(s, 0); e > s+2 && isspace((unsigned char)e[-1]) && e[-2] != '\\'; e--) ; *e = 0; return s; } ldns_status ldns_rr_new_frm_fp(ldns_rr **newrr, FILE *fp, uint32_t *ttl, ldns_rdf **origin, ldns_rdf **prev) { return ldns_rr_new_frm_fp_l(newrr, fp, ttl, origin, prev, NULL); } ldns_status _ldns_rr_new_frm_fp_l_internal(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr, bool *explicit_ttl); ldns_status _ldns_rr_new_frm_fp_l_internal(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr, bool *explicit_ttl) { char *line = NULL; size_t limit = 0; const char *endptr; /* unused */ ldns_rr *rr; uint32_t ttl; ldns_rdf *tmp; ldns_status s; if (default_ttl) { ttl = *default_ttl; } else { ttl = 0; } /* read an entire line in from the file */ if ((s = ldns_fget_token_l_st( fp, &line, &limit, false , LDNS_PARSE_SKIP_SPACE, line_nr))) { LDNS_FREE(line); return s; } if (strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) { if (*origin) { ldns_rdf_deep_free(*origin); *origin = NULL; } tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, ldns_strip_ws(line + 8)); if (!tmp) { /* could not parse what next to $ORIGIN */ LDNS_FREE(line); return LDNS_STATUS_SYNTAX_DNAME_ERR; } *origin = tmp; s = LDNS_STATUS_SYNTAX_ORIGIN; } else if (strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) { if (default_ttl) { *default_ttl = ldns_str2period( ldns_strip_ws(line + 5), &endptr); } s = LDNS_STATUS_SYNTAX_TTL; } else if (strncmp(line, "$INCLUDE", 8) == 0) { s = LDNS_STATUS_SYNTAX_INCLUDE; } else if (!*ldns_strip_ws(line)) { LDNS_FREE(line); return LDNS_STATUS_SYNTAX_EMPTY; } else { if (origin && *origin) { s = ldns_rr_new_frm_str_internal(&rr, (const char*)line, ttl, *origin, prev, false, explicit_ttl); } else { s = ldns_rr_new_frm_str_internal(&rr, (const char*)line, ttl, NULL, prev, false, explicit_ttl); } } LDNS_FREE(line); if (s == LDNS_STATUS_OK) { if (newrr) { *newrr = rr; } else { /* Just testing if it would parse? */ ldns_rr_free(rr); } } return s; } ldns_status ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr) { return _ldns_rr_new_frm_fp_l_internal(newrr, fp, default_ttl, origin, prev, line_nr, NULL); } void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner) { rr->_owner = owner; } void ldns_rr_set_question(ldns_rr *rr, bool question) { rr->_rr_question = question; } void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl) { rr->_ttl = ttl; } void ldns_rr_set_rd_count(ldns_rr *rr, size_t count) { rr->_rd_count = count; } void ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type) { rr->_rr_type = rr_type; } void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class) { rr->_rr_class = rr_class; } ldns_rdf * ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position) { size_t rd_count; ldns_rdf *pop; rd_count = ldns_rr_rd_count(rr); if (position < rd_count) { /* discard the old one */ pop = rr->_rdata_fields[position]; rr->_rdata_fields[position] = (ldns_rdf*)f; return pop; } else { return NULL; } } bool ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f) { size_t rd_count; ldns_rdf **rdata_fields; rd_count = ldns_rr_rd_count(rr); /* grow the array */ rdata_fields = LDNS_XREALLOC( rr->_rdata_fields, ldns_rdf *, rd_count + 1); if (!rdata_fields) { return false; } /* add the new member */ rr->_rdata_fields = rdata_fields; rr->_rdata_fields[rd_count] = (ldns_rdf*)f; ldns_rr_set_rd_count(rr, rd_count + 1); return true; } ldns_rdf * ldns_rr_pop_rdf(ldns_rr *rr) { size_t rd_count; ldns_rdf *pop; ldns_rdf** newrd; rd_count = ldns_rr_rd_count(rr); if (rd_count == 0) { return NULL; } pop = rr->_rdata_fields[rd_count - 1]; /* try to shrink the array */ if(rd_count > 1) { newrd = LDNS_XREALLOC( rr->_rdata_fields, ldns_rdf *, rd_count - 1); if(newrd) rr->_rdata_fields = newrd; } else { LDNS_FREE(rr->_rdata_fields); } ldns_rr_set_rd_count(rr, rd_count - 1); return pop; } ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr) { if (rr && nr < ldns_rr_rd_count(rr)) { return rr->_rdata_fields[nr]; } else { return NULL; } } ldns_rdf * ldns_rr_owner(const ldns_rr *rr) { return rr->_owner; } bool ldns_rr_is_question(const ldns_rr *rr) { return rr->_rr_question; } uint32_t ldns_rr_ttl(const ldns_rr *rr) { return rr->_ttl; } size_t ldns_rr_rd_count(const ldns_rr *rr) { return rr->_rd_count; } ldns_rr_type ldns_rr_get_type(const ldns_rr *rr) { return rr->_rr_type; } ldns_rr_class ldns_rr_get_class(const ldns_rr *rr) { return rr->_rr_class; } /* rr_lists */ size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list) { if (rr_list) { return rr_list->_rr_count; } else { return 0; } } ldns_rr * ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count) { ldns_rr *old; if (count > ldns_rr_list_rr_count(rr_list)) { return NULL; } old = ldns_rr_list_rr(rr_list, count); /* overwrite old's pointer */ rr_list->_rrs[count] = (ldns_rr*)r; return old; } void ldns_rr_list_set_rr_count(ldns_rr_list *rr_list, size_t count) { assert(count <= rr_list->_rr_capacity); rr_list->_rr_count = count; } ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr) { if (nr < ldns_rr_list_rr_count(rr_list)) { return rr_list->_rrs[nr]; } else { return NULL; } } ldns_rr_list * ldns_rr_list_new(void) { ldns_rr_list *rr_list = LDNS_MALLOC(ldns_rr_list); if(!rr_list) return NULL; rr_list->_rr_count = 0; rr_list->_rr_capacity = 0; rr_list->_rrs = NULL; return rr_list; } void ldns_rr_list_free(ldns_rr_list *rr_list) { if (rr_list) { LDNS_FREE(rr_list->_rrs); LDNS_FREE(rr_list); } } void ldns_rr_list_deep_free(ldns_rr_list *rr_list) { size_t i; if (rr_list) { for (i=0; i < ldns_rr_list_rr_count(rr_list); i++) { ldns_rr_free(ldns_rr_list_rr(rr_list, i)); } LDNS_FREE(rr_list->_rrs); LDNS_FREE(rr_list); } } /* add right to left. So we modify *left! */ bool ldns_rr_list_cat(ldns_rr_list *left, const ldns_rr_list *right) { size_t r_rr_count; size_t i; if (!left) { return false; } if (right) { r_rr_count = ldns_rr_list_rr_count(right); } else { r_rr_count = 0; } /* push right to left */ for(i = 0; i < r_rr_count; i++) { ldns_rr_list_push_rr(left, ldns_rr_list_rr(right, i)); } return true; } ldns_rr_list * ldns_rr_list_cat_clone(const ldns_rr_list *left, const ldns_rr_list *right) { size_t l_rr_count; size_t r_rr_count; size_t i; ldns_rr_list *cat; if (left) { l_rr_count = ldns_rr_list_rr_count(left); } else { return ldns_rr_list_clone(right); } if (right) { r_rr_count = ldns_rr_list_rr_count(right); } else { r_rr_count = 0; } cat = ldns_rr_list_new(); if (!cat) { return NULL; } /* left */ for(i = 0; i < l_rr_count; i++) { ldns_rr_list_push_rr(cat, ldns_rr_clone(ldns_rr_list_rr(left, i))); } /* right */ for(i = 0; i < r_rr_count; i++) { ldns_rr_list_push_rr(cat, ldns_rr_clone(ldns_rr_list_rr(right, i))); } return cat; } ldns_rr_list * ldns_rr_list_subtype_by_rdf(const ldns_rr_list *l, const ldns_rdf *r, size_t pos) { size_t i; ldns_rr_list *subtyped; ldns_rdf *list_rdf; subtyped = ldns_rr_list_new(); for(i = 0; i < ldns_rr_list_rr_count(l); i++) { list_rdf = ldns_rr_rdf( ldns_rr_list_rr(l, i), pos); if (!list_rdf) { /* pos is too large or any other error */ ldns_rr_list_deep_free(subtyped); return NULL; } if (ldns_rdf_compare(list_rdf, r) == 0) { /* a match */ ldns_rr_list_push_rr(subtyped, ldns_rr_clone(ldns_rr_list_rr(l, i))); } } if (ldns_rr_list_rr_count(subtyped) > 0) { return subtyped; } else { ldns_rr_list_free(subtyped); return NULL; } } bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr) { size_t rr_count; size_t cap; rr_count = ldns_rr_list_rr_count(rr_list); cap = rr_list->_rr_capacity; /* grow the array */ if(rr_count+1 > cap) { ldns_rr **rrs; if(cap == 0) cap = LDNS_RRLIST_INIT; /* initial list size */ else cap *= 2; rrs = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap); if (!rrs) { return false; } rr_list->_rrs = rrs; rr_list->_rr_capacity = cap; } /* add the new member */ rr_list->_rrs[rr_count] = (ldns_rr*)rr; ldns_rr_list_set_rr_count(rr_list, rr_count + 1); return true; } bool ldns_rr_list_push_rr_list(ldns_rr_list *rr_list, const ldns_rr_list *push_list) { size_t i; for(i = 0; i < ldns_rr_list_rr_count(push_list); i++) { if (!ldns_rr_list_push_rr(rr_list, ldns_rr_list_rr(push_list, i))) { return false; } } return true; } ldns_rr * ldns_rr_list_pop_rr(ldns_rr_list *rr_list) { size_t rr_count; size_t cap; ldns_rr *pop; rr_count = ldns_rr_list_rr_count(rr_list); if (rr_count == 0) { return NULL; } cap = rr_list->_rr_capacity; pop = ldns_rr_list_rr(rr_list, rr_count - 1); /* shrink the array */ if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) { ldns_rr** a; cap /= 2; a = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap); if(a) { rr_list->_rrs = a; rr_list->_rr_capacity = cap; } /* if the realloc fails, the capacity for the list remains unchanged */ } ldns_rr_list_set_rr_count(rr_list, rr_count - 1); return pop; } ldns_rr_list * ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany) { /* pop a number of rr's and put them in a rr_list */ ldns_rr_list *popped; ldns_rr *p; size_t i = howmany; popped = ldns_rr_list_new(); if (!popped) { return NULL; } while(i > 0 && (p = ldns_rr_list_pop_rr(rr_list)) != NULL) { ldns_rr_list_push_rr(popped, p); i--; } if (i == howmany) { /* so i <= 0 */ ldns_rr_list_free(popped); return NULL; } else { return popped; } } bool ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, const ldns_rr *rr) { size_t i; if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) { return false; } for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { if (rr == ldns_rr_list_rr(rr_list, i)) { return true; } else if (ldns_rr_compare(rr, ldns_rr_list_rr(rr_list, i)) == 0) { return true; } } return false; } bool ldns_is_rrset(const ldns_rr_list *rr_list) { ldns_rr_type t; ldns_rr_class c; ldns_rdf *o; ldns_rr *tmp; size_t i; if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) { return false; } tmp = ldns_rr_list_rr(rr_list, 0); t = ldns_rr_get_type(tmp); c = ldns_rr_get_class(tmp); o = ldns_rr_owner(tmp); /* compare these with the rest of the rr_list, start with 1 */ for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) { tmp = ldns_rr_list_rr(rr_list, i); if (t != ldns_rr_get_type(tmp)) { return false; } if (c != ldns_rr_get_class(tmp)) { return false; } if (ldns_dname_compare(o, ldns_rr_owner(tmp)) != 0) { return false; } } return true; } bool ldns_is_rrset_strict(const ldns_rr_list *rr_list) { ldns_rr_type t; ldns_rr_class c; uint32_t l; ldns_rdf *o; ldns_rr *tmp; size_t i; if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) { return false; } tmp = ldns_rr_list_rr(rr_list, 0); t = ldns_rr_get_type(tmp); c = ldns_rr_get_class(tmp); l = ldns_rr_ttl(tmp); o = ldns_rr_owner(tmp); /* compare these with the rest of the rr_list, start with 1 */ for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) { tmp = ldns_rr_list_rr(rr_list, i); if (t != ldns_rr_get_type(tmp)) { return false; } if (c != ldns_rr_get_class(tmp)) { return false; } if (l != ldns_rr_ttl(tmp)) { return false; } if (ldns_dname_compare(o, ldns_rr_owner(tmp)) != 0) { return false; } } return true; } bool ldns_rr_set_push_rr(ldns_rr_list *rr_list, ldns_rr *rr) { size_t rr_count; size_t i; ldns_rr *last; assert(rr != NULL); rr_count = ldns_rr_list_rr_count(rr_list); if (rr_count == 0) { /* nothing there, so checking it is * not needed */ return ldns_rr_list_push_rr(rr_list, rr); } else { /* check with the final rr in the rr_list */ last = ldns_rr_list_rr(rr_list, rr_count - 1); if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) { return false; } if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) { return false; } /* only check if not equal to RRSIG */ if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) { if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) { return false; } } if (ldns_rdf_compare(ldns_rr_owner(last), ldns_rr_owner(rr)) != 0) { return false; } /* ok, still alive - check if the rr already * exists - if so, don't add it */ for(i = 0; i < rr_count; i++) { if(ldns_rr_compare( ldns_rr_list_rr(rr_list, i), rr) == 0) { return false; } } /* it's safe, push it */ return ldns_rr_list_push_rr(rr_list, rr); } } ldns_rr * ldns_rr_set_pop_rr(ldns_rr_list *rr_list) { return ldns_rr_list_pop_rr(rr_list); } ldns_rr_list * ldns_rr_list_pop_rrset(ldns_rr_list *rr_list) { ldns_rr_list *rrset; ldns_rr *last_rr = NULL; ldns_rr *next_rr; if (!rr_list) { return NULL; } rrset = ldns_rr_list_new(); if (!last_rr) { last_rr = ldns_rr_list_pop_rr(rr_list); if (!last_rr) { ldns_rr_list_free(rrset); return NULL; } else { ldns_rr_list_push_rr(rrset, last_rr); } } if (ldns_rr_list_rr_count(rr_list) > 0) { next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1); } else { next_rr = NULL; } while (next_rr) { if ( ldns_rdf_compare(ldns_rr_owner(next_rr), ldns_rr_owner(last_rr)) == 0 && ldns_rr_get_type(next_rr) == ldns_rr_get_type(last_rr) && ldns_rr_get_class(next_rr) == ldns_rr_get_class(last_rr) ) { ldns_rr_list_push_rr(rrset, ldns_rr_list_pop_rr(rr_list)); if (ldns_rr_list_rr_count(rr_list) > 0) { last_rr = next_rr; next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1); } else { next_rr = NULL; } } else { next_rr = NULL; } } return rrset; } ldns_rr * ldns_rr_clone(const ldns_rr *rr) { size_t i; ldns_rr *new_rr; if (!rr) { return NULL; } new_rr = ldns_rr_new(); if (!new_rr) { return NULL; } if (ldns_rr_owner(rr)) { ldns_rr_set_owner(new_rr, ldns_rdf_clone(ldns_rr_owner(rr))); } ldns_rr_set_ttl(new_rr, ldns_rr_ttl(rr)); ldns_rr_set_type(new_rr, ldns_rr_get_type(rr)); ldns_rr_set_class(new_rr, ldns_rr_get_class(rr)); ldns_rr_set_question(new_rr, ldns_rr_is_question(rr)); for (i = 0; i < ldns_rr_rd_count(rr); i++) { if (ldns_rr_rdf(rr,i)) { ldns_rr_push_rdf(new_rr, ldns_rdf_clone(ldns_rr_rdf(rr, i))); } } return new_rr; } ldns_rr_list * ldns_rr_list_clone(const ldns_rr_list *rrlist) { size_t i; ldns_rr_list *new_list; ldns_rr *r; if (!rrlist) { return NULL; } new_list = ldns_rr_list_new(); if (!new_list) { return NULL; } for (i = 0; i < ldns_rr_list_rr_count(rrlist); i++) { r = ldns_rr_clone( ldns_rr_list_rr(rrlist, i) ); if (!r) { /* huh, failure in cloning */ ldns_rr_list_deep_free(new_list); return NULL; } ldns_rr_list_push_rr(new_list, r); } return new_list; } static int qsort_schwartz_rr_compare(const void *a, const void *b) { int result = 0; ldns_rr *rr1, *rr2; ldns_buffer *rr1_buf, *rr2_buf; struct ldns_schwartzian_compare_struct *sa = *(struct ldns_schwartzian_compare_struct **) a; struct ldns_schwartzian_compare_struct *sb = *(struct ldns_schwartzian_compare_struct **) b; /* if we are doing 2wire, we need to do lowercasing on the dname (and maybe on the rdata) * this must be done for comparison only, so we need to have a temp var for both buffers, * which is only used when the transformed object value isn't there yet */ ldns_rr *canonical_a, *canonical_b; rr1 = (ldns_rr *) sa->original_object; rr2 = (ldns_rr *) sb->original_object; result = ldns_rr_compare_no_rdata(rr1, rr2); if (result == 0) { if (!sa->transformed_object) { canonical_a = ldns_rr_clone(sa->original_object); ldns_rr2canonical(canonical_a); sa->transformed_object = ldns_buffer_new(ldns_rr_uncompressed_size(canonical_a)); if (ldns_rr2buffer_wire(sa->transformed_object, canonical_a, LDNS_SECTION_ANY) != LDNS_STATUS_OK) { ldns_buffer_free((ldns_buffer *)sa->transformed_object); sa->transformed_object = NULL; ldns_rr_free(canonical_a); return 0; } ldns_rr_free(canonical_a); } if (!sb->transformed_object) { canonical_b = ldns_rr_clone(sb->original_object); ldns_rr2canonical(canonical_b); sb->transformed_object = ldns_buffer_new(ldns_rr_uncompressed_size(canonical_b)); if (ldns_rr2buffer_wire(sb->transformed_object, canonical_b, LDNS_SECTION_ANY) != LDNS_STATUS_OK) { ldns_buffer_free((ldns_buffer *)sa->transformed_object); ldns_buffer_free((ldns_buffer *)sb->transformed_object); sa->transformed_object = NULL; sb->transformed_object = NULL; ldns_rr_free(canonical_b); return 0; } ldns_rr_free(canonical_b); } rr1_buf = (ldns_buffer *) sa->transformed_object; rr2_buf = (ldns_buffer *) sb->transformed_object; result = ldns_rr_compare_wire(rr1_buf, rr2_buf); } return result; } void ldns_rr_list_sort(ldns_rr_list *unsorted) { struct ldns_schwartzian_compare_struct **sortables; size_t item_count; size_t i; if (unsorted) { item_count = ldns_rr_list_rr_count(unsorted); sortables = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct *, item_count); if(!sortables) return; /* no way to return error */ for (i = 0; i < item_count; i++) { sortables[i] = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct, 1); if(!sortables[i]) { /* free the allocated parts */ while(i>0) { i--; LDNS_FREE(sortables[i]); } /* no way to return error */ LDNS_FREE(sortables); return; } sortables[i]->original_object = ldns_rr_list_rr(unsorted, i); sortables[i]->transformed_object = NULL; } qsort(sortables, item_count, sizeof(struct ldns_schwartzian_compare_struct *), qsort_schwartz_rr_compare); for (i = 0; i < item_count; i++) { unsorted->_rrs[i] = sortables[i]->original_object; if (sortables[i]->transformed_object) { ldns_buffer_free(sortables[i]->transformed_object); } LDNS_FREE(sortables[i]); } LDNS_FREE(sortables); } } int ldns_rr_compare_no_rdata(const ldns_rr *rr1, const ldns_rr *rr2) { size_t rr1_len; size_t rr2_len; size_t offset; assert(rr1 != NULL); assert(rr2 != NULL); rr1_len = ldns_rr_uncompressed_size(rr1); rr2_len = ldns_rr_uncompressed_size(rr2); if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) { return -1; } else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) { return 1; } /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */ if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) { return ldns_rr_get_class(rr1) - ldns_rr_get_class(rr2); } /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */ if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) { return ldns_rr_get_type(rr1) - ldns_rr_get_type(rr2); } /* offset is the owername length + ttl + type + class + rdlen == start of wire format rdata */ offset = ldns_rdf_size(ldns_rr_owner(rr1)) + 4 + 2 + 2 + 2; /* if either record doesn't have any RDATA... */ if (offset > rr1_len || offset > rr2_len) { if (rr1_len == rr2_len) { return 0; } return ((int) rr2_len - (int) rr1_len); } return 0; } int ldns_rr_compare_wire(const ldns_buffer *rr1_buf, const ldns_buffer *rr2_buf) { size_t rr1_len, rr2_len, min_len, i, offset; rr1_len = ldns_buffer_capacity(rr1_buf); rr2_len = ldns_buffer_capacity(rr2_buf); /* jump past dname (checked in earlier part) * and especially past TTL */ offset = 0; while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) { offset += *ldns_buffer_at(rr1_buf, offset) + 1; } /* jump to rdata section (PAST the rdata length field, otherwise rrs with different lengths might be sorted erroneously */ offset += 11; min_len = (rr1_len < rr2_len) ? rr1_len : rr2_len; /* Compare RRs RDATA byte for byte. */ for(i = offset; i < min_len; i++) { if (*ldns_buffer_at(rr1_buf,i) < *ldns_buffer_at(rr2_buf,i)) { return -1; } else if (*ldns_buffer_at(rr1_buf,i) > *ldns_buffer_at(rr2_buf,i)) { return +1; } } /* If both RDATAs are the same up to min_len, then the shorter one sorts first. */ if (rr1_len < rr2_len) { return -1; } else if (rr1_len > rr2_len) { return +1; } /* The RDATAs are equal. */ return 0; } int ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2) { int result; size_t rr1_len, rr2_len; ldns_buffer *rr1_buf; ldns_buffer *rr2_buf; result = ldns_rr_compare_no_rdata(rr1, rr2); if (result == 0) { rr1_len = ldns_rr_uncompressed_size(rr1); rr2_len = ldns_rr_uncompressed_size(rr2); rr1_buf = ldns_buffer_new(rr1_len); rr2_buf = ldns_buffer_new(rr2_len); if (ldns_rr2buffer_wire_canonical(rr1_buf, rr1, LDNS_SECTION_ANY) != LDNS_STATUS_OK) { ldns_buffer_free(rr1_buf); ldns_buffer_free(rr2_buf); return 0; } if (ldns_rr2buffer_wire_canonical(rr2_buf, rr2, LDNS_SECTION_ANY) != LDNS_STATUS_OK) { ldns_buffer_free(rr1_buf); ldns_buffer_free(rr2_buf); return 0; } result = ldns_rr_compare_wire(rr1_buf, rr2_buf); ldns_buffer_free(rr1_buf); ldns_buffer_free(rr2_buf); } return result; } /* convert (c)dnskey to a (c)ds with the given algorithm, * then compare the result with the given (c)ds */ static int ldns_rr_compare_ds_dnskey(ldns_rr *ds, ldns_rr *dnskey) { ldns_rr *ds_gen; bool result = false; ldns_hash algo; if (!dnskey || !ds || (ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS && ldns_rr_get_type(ds) != LDNS_RR_TYPE_CDS) || (ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_DNSKEY && ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_CDNSKEY)) { return false; } if (ldns_rr_rdf(ds, 2) == NULL) { return false; } algo = ldns_rdf2native_int8(ldns_rr_rdf(ds, 2)); ds_gen = ldns_key_rr2ds(dnskey, algo); if (ds_gen) { result = ldns_rr_compare(ds, ds_gen) == 0; ldns_rr_free(ds_gen); } return result; } bool ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2) { bool result; ldns_rr *rr1 = ldns_rr_clone(orr1); ldns_rr *rr2 = ldns_rr_clone(orr2); /* set ttls to zero */ ldns_rr_set_ttl(rr1, 0); ldns_rr_set_ttl(rr2, 0); if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS && ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DNSKEY) { result = ldns_rr_compare_ds_dnskey(rr1, rr2); } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY && ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DS) { result = ldns_rr_compare_ds_dnskey(rr2, rr1); } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_CDS && ldns_rr_get_type(rr2) == LDNS_RR_TYPE_CDNSKEY) { result = ldns_rr_compare_ds_dnskey(rr1, rr2); } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_CDNSKEY && ldns_rr_get_type(rr2) == LDNS_RR_TYPE_CDS) { result = ldns_rr_compare_ds_dnskey(rr2, rr1); } else { result = (ldns_rr_compare(rr1, rr2) == 0); } ldns_rr_free(rr1); ldns_rr_free(rr2); return result; } int ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2) { size_t i = 0; int rr_cmp; assert(rrl1 != NULL); assert(rrl2 != NULL); for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) { rr_cmp = ldns_rr_compare(ldns_rr_list_rr(rrl1, i), ldns_rr_list_rr(rrl2, i)); if (rr_cmp != 0) { return rr_cmp; } } if (i == ldns_rr_list_rr_count(rrl1) && i != ldns_rr_list_rr_count(rrl2)) { return 1; } else if (i == ldns_rr_list_rr_count(rrl2) && i != ldns_rr_list_rr_count(rrl1)) { return -1; } else { return 0; } } size_t ldns_rr_uncompressed_size(const ldns_rr *r) { size_t rrsize; size_t i; rrsize = 0; /* add all the rdf sizes */ for(i = 0; i < ldns_rr_rd_count(r); i++) { rrsize += ldns_rdf_size(ldns_rr_rdf(r, i)); } /* ownername */ rrsize += ldns_rdf_size(ldns_rr_owner(r)); rrsize += LDNS_RR_OVERHEAD; return rrsize; } void ldns_rr2canonical(ldns_rr *rr) { uint16_t i; if (!rr) { return; } ldns_dname2canonical(ldns_rr_owner(rr)); /* * lowercase the rdata dnames if the rr type is one * of the list in chapter 7 of RFC3597 * Also added RRSIG, because a "Signer's Name" should be canonicalized * too. See dnssec-bis-updates-16. We can add it to this list because * the "Signer's Name" is the only dname type rdata field in a RRSIG. */ switch(ldns_rr_get_type(rr)) { case LDNS_RR_TYPE_NS: case LDNS_RR_TYPE_MD: case LDNS_RR_TYPE_MF: case LDNS_RR_TYPE_CNAME: case LDNS_RR_TYPE_SOA: case LDNS_RR_TYPE_MB: case LDNS_RR_TYPE_MG: case LDNS_RR_TYPE_MR: case LDNS_RR_TYPE_PTR: case LDNS_RR_TYPE_MINFO: case LDNS_RR_TYPE_MX: case LDNS_RR_TYPE_RP: case LDNS_RR_TYPE_AFSDB: case LDNS_RR_TYPE_RT: case LDNS_RR_TYPE_SIG: case LDNS_RR_TYPE_PX: case LDNS_RR_TYPE_NXT: case LDNS_RR_TYPE_NAPTR: case LDNS_RR_TYPE_KX: case LDNS_RR_TYPE_SRV: case LDNS_RR_TYPE_DNAME: case LDNS_RR_TYPE_A6: case LDNS_RR_TYPE_RRSIG: for (i = 0; i < ldns_rr_rd_count(rr); i++) { ldns_dname2canonical(ldns_rr_rdf(rr, i)); } return; default: /* do nothing */ return; } } void ldns_rr_list2canonical(const ldns_rr_list *rr_list) { size_t i; for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { ldns_rr2canonical(ldns_rr_list_rr(rr_list, i)); } } uint8_t ldns_rr_label_count(const ldns_rr *rr) { if (!rr) { return 0; } return ldns_dname_label_count( ldns_rr_owner(rr)); } /** \cond */ static const ldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN }; static const ldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A }; static const ldns_rdf_type type_ns_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_soa_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD }; static const ldns_rdf_type type_mb_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_mg_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_mr_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_wks_wireformat[] = { LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_WKS }; static const ldns_rdf_type type_ptr_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_hinfo_wireformat[] = { LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR }; static const ldns_rdf_type type_minfo_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_mx_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_rp_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_afsdb_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_x25_wireformat[] = { LDNS_RDF_TYPE_STR }; static const ldns_rdf_type type_isdn_wireformat[] = { LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR }; static const ldns_rdf_type type_rt_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_nsap_wireformat[] = { LDNS_RDF_TYPE_NSAP }; static const ldns_rdf_type type_nsap_ptr_wireformat[] = { LDNS_RDF_TYPE_UNQUOTED }; static const ldns_rdf_type type_sig_wireformat[] = { LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_key_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_px_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_gpos_wireformat[] = { LDNS_RDF_TYPE_UNQUOTED, LDNS_RDF_TYPE_UNQUOTED, LDNS_RDF_TYPE_UNQUOTED }; static const ldns_rdf_type type_aaaa_wireformat[] = { LDNS_RDF_TYPE_AAAA }; static const ldns_rdf_type type_loc_wireformat[] = { LDNS_RDF_TYPE_LOC }; static const ldns_rdf_type type_nxt_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_UNKNOWN }; static const ldns_rdf_type type_eid_wireformat[] = { LDNS_RDF_TYPE_HEX }; static const ldns_rdf_type type_nimloc_wireformat[] = { LDNS_RDF_TYPE_HEX }; static const ldns_rdf_type type_srv_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_atma_wireformat[] = { LDNS_RDF_TYPE_ATMA }; static const ldns_rdf_type type_naptr_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_kx_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_cert_wireformat[] = { LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN }; static const ldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_sink_wireformat[] = { LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_apl_wireformat[] = { LDNS_RDF_TYPE_APL }; static const ldns_rdf_type type_ds_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX }; static const ldns_rdf_type type_sshfp_wireformat[] = { LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX }; static const ldns_rdf_type type_ipseckey_wireformat[] = { LDNS_RDF_TYPE_IPSECKEY }; static const ldns_rdf_type type_rrsig_wireformat[] = { LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_nsec_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_NSEC }; static const ldns_rdf_type type_dhcid_wireformat[] = { LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_talink_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME }; #ifdef RRTYPE_OPENPGPKEY static const ldns_rdf_type type_openpgpkey_wireformat[] = { LDNS_RDF_TYPE_B64 }; #endif static const ldns_rdf_type type_csync_wireformat[] = { LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_NSEC }; static const ldns_rdf_type type_zonemd_wireformat[] = { LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX }; #ifdef RRTYPE_SVCB_HTTPS static const ldns_rdf_type type_svcb_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_SVCPARAMS }; #endif #ifdef RRTYPE_DSYNC static const ldns_rdf_type type_dsync_wireformat[] = { LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; #endif #ifdef RRTYPE_HHIT_BRID static const ldns_rdf_type type_hhit_wireformat[] = { LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_brid_wireformat[] = { LDNS_RDF_TYPE_B64 }; #endif /* nsec3 is some vars, followed by same type of data of nsec */ static const ldns_rdf_type type_nsec3_wireformat[] = { /* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/ LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_NSEC3_SALT, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC }; static const ldns_rdf_type type_nsec3param_wireformat[] = { /* LDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/ LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_NSEC3_SALT }; static const ldns_rdf_type type_dnskey_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64 }; static const ldns_rdf_type type_tkey_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16_DATA, LDNS_RDF_TYPE_INT16_DATA, }; static const ldns_rdf_type type_tsig_wireformat[] = { LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_TSIGTIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16_DATA, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16_DATA }; static const ldns_rdf_type type_tlsa_wireformat[] = { LDNS_RDF_TYPE_CERTIFICATE_USAGE, LDNS_RDF_TYPE_SELECTOR, LDNS_RDF_TYPE_MATCHING_TYPE, LDNS_RDF_TYPE_HEX }; static const ldns_rdf_type type_hip_wireformat[] = { LDNS_RDF_TYPE_HIP }; static const ldns_rdf_type type_nid_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ILNP64 }; static const ldns_rdf_type type_l32_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_A }; static const ldns_rdf_type type_l64_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ILNP64 }; static const ldns_rdf_type type_lp_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME }; static const ldns_rdf_type type_eui48_wireformat[] = { LDNS_RDF_TYPE_EUI48 }; static const ldns_rdf_type type_eui64_wireformat[] = { LDNS_RDF_TYPE_EUI64 }; static const ldns_rdf_type type_uri_wireformat[] = { LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_LONG_STR }; static const ldns_rdf_type type_caa_wireformat[] = { LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_TAG, LDNS_RDF_TYPE_LONG_STR }; #ifdef RRTYPE_DOA static const ldns_rdf_type type_doa_wireformat[] = { LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_INT32, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_B64 }; #endif #ifdef RRTYPE_AMTRELAY static const ldns_rdf_type type_amtrelay_wireformat[] = { LDNS_RDF_TYPE_AMTRELAY }; #endif #ifdef RRTYPE_CLA_IPN static const ldns_rdf_type type_ipn_wireformat[] = { LDNS_RDF_TYPE_IPN }; #endif /** \endcond */ /** \cond */ /* All RR's defined in 1035 are well known and can thus * be compressed. See RFC3597. These RR's are: * CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT */ static ldns_rr_descriptor rdata_field_descriptors[] = { /* 0 */ { 0, NULL, 0, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 1 */ {LDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 2 */ {LDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 3 */ {LDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 4 */ {LDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 5 */ {LDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 6 */ {LDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 }, /* 7 */ {LDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 8 */ {LDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 9 */ {LDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 10 */ {LDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 11 */ {LDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 12 */ {LDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 13 */ {LDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 14 */ {LDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 }, /* 15 */ {LDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 }, /* 16 */ {LDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 }, /* 17 */ {LDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 }, /* 18 */ {LDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 19 */ {LDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 20 */ {LDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 21 */ {LDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 22 */ {LDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 23 */ {LDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 24 */ {LDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 25 */ {LDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 26 */ {LDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 }, /* 27 */ {LDNS_RR_TYPE_GPOS, "GPOS", 3, 3, type_gpos_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 28 */ {LDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 29 */ {LDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 30 */ {LDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 31 */ {LDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 32 */ {LDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 33 */ {LDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 34 */ {LDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 35 */ {LDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 36 */ {LDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 37 */ {LDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 38 */ {LDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 39 */ {LDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 40 */ {LDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 41 */ {LDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 42 */ {LDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, LDNS_RDF_TYPE_APL, LDNS_RR_NO_COMPRESS, 0 }, /* 43 */ {LDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 44 */ {LDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 45 */ {LDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 46 */ {LDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 47 */ {LDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 48 */ {LDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 49 */ {LDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 50 */ {LDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 51 */ {LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 52 */ {LDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_SMIMEA, "SMIMEA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 55 * Hip ends with 0 or more Rendezvous Servers represented as dname's. * Hence the LDNS_RDF_TYPE_DNAME _variable field and the _maximum field * set to 0. */ {LDNS_RR_TYPE_HIP, "HIP", 1, 1, type_hip_wireformat, LDNS_RDF_TYPE_DNAME, LDNS_RR_NO_COMPRESS, 0 }, #ifdef RRTYPE_NINFO /* 56 */ {LDNS_RR_TYPE_NINFO, "NINFO", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif #ifdef RRTYPE_RKEY /* 57 */ {LDNS_RR_TYPE_RKEY, "RKEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif /* 58 */ {LDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 }, /* 59 */ {LDNS_RR_TYPE_CDS, "CDS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 60 */ {LDNS_RR_TYPE_CDNSKEY, "CDNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #ifdef RRTYPE_OPENPGPKEY /* 61 */ {LDNS_RR_TYPE_OPENPGPKEY, "OPENPGPKEY", 1, 1, type_openpgpkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif /* 62 */ {LDNS_RR_TYPE_CSYNC, "CSYNC", 3, 3, type_csync_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 63 */ {LDNS_RR_TYPE_ZONEMD, "ZONEMD", 4, 4, type_zonemd_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #ifdef RRTYPE_SVCB_HTTPS /* 64 */ {LDNS_RR_TYPE_SVCB, "SVCB", 2, 3, type_svcb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 65 */ {LDNS_RR_TYPE_HTTPS, "HTTPS", 2, 3, type_svcb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, #else {LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif #ifdef RRTYPE_DSYNC /* 66 */ {LDNS_RR_TYPE_DSYNC, "DSYNC", 4, 4, type_dsync_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, #else {LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif #ifdef RRTYPE_HHIT_BRID /* 67 */ {LDNS_RR_TYPE_HHIT, "HHIT", 1, 1, type_hhit_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 68 */ {LDNS_RR_TYPE_BRID, "BRID", 1, 1, type_brid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif {LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 99 */ {LDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 }, /* UINFO [IANA-Reserved] */ {LDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* UID [IANA-Reserved] */ {LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* GID [IANA-Reserved] */ {LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* UNSPEC [IANA-Reserved] */ {LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 104 */ {LDNS_RR_TYPE_NID, "NID", 2, 2, type_nid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 105 */ {LDNS_RR_TYPE_L32, "L32", 2, 2, type_l32_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 106 */ {LDNS_RR_TYPE_L64, "L64", 2, 2, type_l64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 107 */ {LDNS_RR_TYPE_LP, "LP", 2, 2, type_lp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* 108 */ {LDNS_RR_TYPE_EUI48, "EUI48", 1, 1, type_eui48_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 109 */ {LDNS_RR_TYPE_EUI64, "EUI64", 1, 1, type_eui64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NXNAME, "NXNAME", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one. * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9. */ /* 249 */ {LDNS_RR_TYPE_TKEY, "TKEY", 7, 7, type_tkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one. * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9. */ /* 250 */ {LDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 }, /* IXFR: A request for a transfer of an incremental zone transfer */ {LDNS_RR_TYPE_NULL, "TYPE251", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* AXFR: A request for a transfer of an entire zone */ {LDNS_RR_TYPE_NULL, "TYPE252", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* MAILB: A request for mailbox-related records (MB, MG or MR) */ {LDNS_RR_TYPE_NULL, "TYPE253", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* MAILA: A request for mail agent RRs (Obsolete - see MX) */ {LDNS_RR_TYPE_NULL, "TYPE254", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* ANY: A request for all (available) records */ {LDNS_RR_TYPE_NULL, "TYPE255", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 256 */ {LDNS_RR_TYPE_URI, "URI", 3, 3, type_uri_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, /* 257 */ {LDNS_RR_TYPE_CAA, "CAA", 3, 3, type_caa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #ifdef RRTYPE_AVC /* 258 */ {LDNS_RR_TYPE_AVC, "AVC", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE258", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif #ifdef RRTYPE_DOA /* 259 */ {LDNS_RR_TYPE_DOA, "DOA", 5, 5, type_doa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE259", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif #ifdef RRTYPE_AMTRELAY /* 260 */ {LDNS_RR_TYPE_AMTRELAY, "AMTRELAY", 1, 1, type_amtrelay_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE260", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif #ifdef RRTYPE_RESINFO /* 261 */ {LDNS_RR_TYPE_RESINFO, "RESINFO", 1, 0, NULL, LDNS_RDF_TYPE_UNQUOTED, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE261", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif /* 262 */ {LDNS_RR_TYPE_WALLET, "WALLET", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 }, #ifdef RRTYPE_CLA_IPN /* 263 */ {LDNS_RR_TYPE_CLA, "CLA", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 }, /* 264 */ {LDNS_RR_TYPE_IPN, "IPN", 1, 1, type_ipn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE263", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, {LDNS_RR_TYPE_NULL, "TYPE264", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif /* split in array, no longer contiguous */ #ifdef RRTYPE_TA /* 32768 */ {LDNS_RR_TYPE_TA, "TA", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #else {LDNS_RR_TYPE_NULL, "TYPE32768", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }, #endif /* 32769 */ {LDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 } }; /** \endcond */ /** * \def LDNS_RDATA_FIELD_DESCRIPTORS_COUNT * computes the number of rdata fields */ #define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT \ (sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0])) /*---------------------------------------------------------------------------* * The functions below return an bitmap RDF with the space required to set * or unset all known RR types. Arguably these functions are better situated * in rdata.c, however for the space calculation it is necessary to walk * through rdata_field_descriptors which is not easily possible from anywhere * other than rr.c where it is declared static. * * Alternatively rr.c could have provided an iterator for rr_type or * rdf_descriptors, but this seemed overkill for internal use only. */ static ldns_rr_descriptor* rdata_field_descriptors_end = &rdata_field_descriptors[LDNS_RDATA_FIELD_DESCRIPTORS_COUNT]; /* From RFC3845: * * 2.1.2. The List of Type Bit Map(s) Field * * The RR type space is split into 256 window blocks, each representing * the low-order 8 bits of the 16-bit RR type space. Each block that * has at least one active RR type is encoded using a single octet * window number (from 0 to 255), a single octet bitmap length (from 1 * to 32) indicating the number of octets used for the window block's * bitmap, and up to 32 octets (256 bits) of bitmap. * * Window blocks are present in the NSEC RR RDATA in increasing * numerical order. * * "|" denotes concatenation * * Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) + * * * * Blocks with no types present MUST NOT be included. Trailing zero * octets in the bitmap MUST be omitted. The length of each block's * bitmap is determined by the type code with the largest numerical * value within that block, among the set of RR types present at the * NSEC RR's owner name. Trailing zero octets not specified MUST be * interpreted as zero octets. */ static ldns_status ldns_rdf_bitmap_known_rr_types_set(ldns_rdf** rdf, int value) { uint8_t window; /* most significant octet of type */ uint8_t subtype; /* least significant octet of type */ uint16_t windows[256] /* Max subtype per window */ #ifndef S_SPLINT_S = { 0 } #endif ; ldns_rr_descriptor* d; /* used to traverse rdata_field_descriptors */ size_t i; /* used to traverse windows array */ size_t sz; /* size needed for type bitmap rdf */ uint8_t* data = NULL; /* rdf data */ uint8_t* dptr; /* used to itraverse rdf data */ assert(rdf != NULL); /* Which windows need to be in the bitmap rdf? */ for (d=rdata_field_descriptors; d < rdata_field_descriptors_end; d++) { window = d->_type >> 8; subtype = d->_type & 0xff; /* In the code below, windows[window] == 0 means that the * window is not in use. So subtype == 0 is a problem. The * easiest solution is to set subtype to 1, that marks the * window as in use and doesn't have negative effects. */ if (subtype == 0) subtype = 1; if (windows[window] < subtype) { windows[window] = subtype; } } /* How much space do we need in the rdf for those windows? */ sz = 0; for (i = 0; i < 256; i++) { if (windows[i]) { sz += windows[i] / 8 + 3; } } if (sz > 0) { /* Format rdf data according RFC3845 Section 2.1.2 (see above) */ dptr = data = LDNS_XMALLOC(uint8_t, sz); if (!data) { return LDNS_STATUS_MEM_ERR; } memset(data, value, sz); for (i = 0; i < 256; i++) { if (windows[i]) { *dptr++ = (uint8_t)i; *dptr++ = (uint8_t)(windows[i] / 8 + 1); dptr += dptr[-1]; } } } /* Allocate and return rdf structure for the data */ *rdf = ldns_rdf_new(LDNS_RDF_TYPE_BITMAP, sz, data); if (!*rdf) { LDNS_FREE(data); return LDNS_STATUS_MEM_ERR; } return LDNS_STATUS_OK; } ldns_status ldns_rdf_bitmap_known_rr_types_space(ldns_rdf** rdf) { return ldns_rdf_bitmap_known_rr_types_set(rdf, 0); } ldns_status ldns_rdf_bitmap_known_rr_types(ldns_rdf** rdf) { return ldns_rdf_bitmap_known_rr_types_set(rdf, 255); } /* End of RDF bitmap functions *---------------------------------------------------------------------------*/ const ldns_rr_descriptor * ldns_rr_descript(uint16_t type) { size_t i; if (type < LDNS_RDATA_FIELD_DESCRIPTORS_COMMON) { return &rdata_field_descriptors[type]; } else { /* because not all array index equals type code */ for (i = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON; i < LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) { if (rdata_field_descriptors[i]._type == type) { return &rdata_field_descriptors[i]; } } return &rdata_field_descriptors[0]; } } size_t ldns_rr_descriptor_minimum(const ldns_rr_descriptor *descriptor) { if (descriptor) { return descriptor->_minimum; } else { return 0; } } size_t ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor) { if (descriptor) { if (descriptor->_variable != LDNS_RDF_TYPE_NONE) { /* Should really be SIZE_MAX... bad FreeBSD. */ return UINT_MAX; } else { return descriptor->_maximum; } } else { return 0; } } ldns_rdf_type ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor, size_t index) { assert(descriptor != NULL); assert(index < descriptor->_maximum || descriptor->_variable != LDNS_RDF_TYPE_NONE); if (index < descriptor->_maximum) { return descriptor->_wireformat[index]; } else { return descriptor->_variable; } } ldns_rr_type ldns_get_rr_type_by_name(const char *name) { unsigned int i; const char *desc_name; const ldns_rr_descriptor *desc; /* TYPEXX representation */ if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) { return atoi(name + 4); } /* Normal types */ for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) { desc = &rdata_field_descriptors[i]; desc_name = desc->_name; if(desc_name && strlen(name) == strlen(desc_name) && strncasecmp(name, desc_name, strlen(desc_name)) == 0) { /* because not all array index equals type code */ return desc->_type; } } /* special cases for query types */ if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) { return 251; } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) { return 252; } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) { return 253; } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) { return 254; } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) { return 255; } return 0; } ldns_rr_class ldns_get_rr_class_by_name(const char *name) { ldns_lookup_table *lt; /* CLASSXX representation */ if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) { return atoi(name + 5); } /* Normal types */ lt = ldns_lookup_by_name(ldns_rr_classes, name); if (lt) { return lt->id; } return 0; } ldns_rr_type ldns_rdf2rr_type(const ldns_rdf *rd) { ldns_rr_type r; if (!rd) { return 0; } if (ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_TYPE) { return 0; } r = (ldns_rr_type) ldns_rdf2native_int16(rd); return r; } ldns_rr_type ldns_rr_list_type(const ldns_rr_list *rr_list) { if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) { return ldns_rr_get_type(ldns_rr_list_rr(rr_list, 0)); } else { return 0; } } ldns_rdf * ldns_rr_list_owner(const ldns_rr_list *rr_list) { if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) { return ldns_rr_owner(ldns_rr_list_rr(rr_list, 0)); } else { return NULL; } } ldns-1.9.2/drill/0000775000175000017500000000000015212267520013141 5ustar willemwillemldns-1.9.2/drill/securetrace.c0000664000175000017500000005671415212267520015627 0ustar willemwillem/* * securechasetrace.c * Where all the hard work concerning secure tracing is done * * (c) 2005, 2006 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include #define SELF "[S]" /* self sig ok */ #define TRUST "[T]" /* chain from parent */ #define BOGUS "[B]" /* bogus */ #define UNSIGNED "[U]" /* no relevant dnssec data found */ #if 0 /* See if there is a key/ds in trusted that matches * a ds in *ds. */ static ldns_rr_list * ds_key_match(ldns_rr_list *ds, ldns_rr_list *trusted) { size_t i, j; bool match; ldns_rr *rr_i, *rr_j; ldns_rr_list *keys; if (!trusted || !ds) { return NULL; } match = false; keys = ldns_rr_list_new(); if (!keys) { return NULL; } if (!ds || !trusted) { return NULL; } for (i = 0; i < ldns_rr_list_rr_count(trusted); i++) { rr_i = ldns_rr_list_rr(trusted, i); for (j = 0; j < ldns_rr_list_rr_count(ds); j++) { rr_j = ldns_rr_list_rr(ds, j); if (ldns_rr_compare_ds(rr_i, rr_j)) { match = true; /* only allow unique RRs to match */ ldns_rr_set_push_rr(keys, rr_i); } } } if (match) { return keys; } else { return NULL; } } #endif static ldns_pkt * get_dnssec_pkt(ldns_resolver *r, ldns_rdf *name, ldns_rr_type t) { ldns_pkt *p = NULL; p = ldns_resolver_query(r, name, t, LDNS_RR_CLASS_IN, 0); if (!p) { return NULL; } else { if (verbosity >= 5) { ldns_pkt_print(stdout, p); } return p; } } #ifdef HAVE_SSL /* * retrieve keys for this zone */ static ldns_pkt_type get_key(ldns_pkt *p, ldns_rdf *apexname, ldns_rr_list **rrlist, ldns_rr_list **opt_sig) { return get_dnssec_rr(p, apexname, LDNS_RR_TYPE_DNSKEY, rrlist, opt_sig); } /* * check to see if we can find a DS rrset here which we can then follow */ static ldns_pkt_type get_ds(ldns_pkt *p, ldns_rdf *ownername, ldns_rr_list **rrlist, ldns_rr_list **opt_sig) { return get_dnssec_rr(p, ownername, LDNS_RR_TYPE_DS, rrlist, opt_sig); } #endif /* HAVE_SSL */ static void remove_resolver_nameservers(ldns_resolver *res) { ldns_rdf *pop; /* remove the old nameserver from the resolver */ while((pop = ldns_resolver_pop_nameserver(res))) { ldns_rdf_deep_free(pop); } } /*ldns_pkt **/ #ifdef HAVE_SSL int do_secure_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, ldns_rr_list *trusted_keys, ldns_rdf *start_name ) { ldns_resolver *res; ldns_pkt *p, *local_p; ldns_rr_list *new_nss; ldns_rr_list *ns_addr; ldns_rdf *pop; ldns_rdf **labels = NULL; ldns_status status, st; ssize_t i; size_t j; size_t k; size_t l; uint8_t labels_count = 0; /* dnssec */ ldns_rr_list *key_list; ldns_rr_list *key_sig_list; ldns_rr_list *ds_list; ldns_rr_list *ds_sig_list; ldns_rr_list *correct_key_list; ldns_rr_list *trusted_ds_rrs; bool new_keys_trusted = false; ldns_rr_list *current_correct_keys = NULL; ldns_rr_list *dataset; ldns_rr_list *nsec_rrs = NULL; ldns_rr_list *nsec_rr_sigs = NULL; /* empty non-terminal check */ bool ent; ldns_rr *nsecrr; /* The nsec that proofs the non-terminal */ ldns_rdf *hashed_name; /* The query hashed with nsec3 params */ ldns_rdf *label0; /* The first label of an nsec3 owner name */ /* glue handling */ ldns_rr_list *new_ns_addr; ldns_rr_list *old_ns_addr; ldns_rr *ns_rr; int result = 0; /* printing niceness */ const ldns_rr_descriptor *descriptor; descriptor = ldns_rr_descript(t); new_nss = NULL; ns_addr = NULL; key_list = NULL; ds_list = NULL; p = NULL; local_p = NULL; res = ldns_resolver_new(); key_sig_list = NULL; ds_sig_list = NULL; if (!res) { error("Memory allocation failed"); result = -1; return result; } correct_key_list = ldns_rr_list_new(); if (!correct_key_list) { error("Memory allocation failed"); result = -1; return result; } trusted_ds_rrs = ldns_rr_list_new(); if (!trusted_ds_rrs) { error("Memory allocation failed"); result = -1; return result; } /* Add all preset trusted DS signatures to the list of trusted DS RRs. */ for (j = 0; j < ldns_rr_list_rr_count(trusted_keys); j++) { ldns_rr* one_rr = ldns_rr_list_rr(trusted_keys, j); if (ldns_rr_get_type(one_rr) == LDNS_RR_TYPE_DS) { ldns_rr_list_push_rr(trusted_ds_rrs, ldns_rr_clone(one_rr)); } } /* transfer some properties of local_res to res */ ldns_resolver_set_ip6(res, ldns_resolver_ip6(local_res)); ldns_resolver_set_port(res, ldns_resolver_port(local_res)); ldns_resolver_set_debug(res, ldns_resolver_debug(local_res)); ldns_resolver_set_fail(res, ldns_resolver_fail(local_res)); ldns_resolver_set_usevc(res, ldns_resolver_usevc(local_res)); ldns_resolver_set_random(res, ldns_resolver_random(local_res)); ldns_resolver_set_source(res, ldns_resolver_source(local_res)); ldns_resolver_set_recursive(local_res, true); ldns_resolver_set_recursive(res, false); ldns_resolver_set_dnssec_cd(res, false); ldns_resolver_set_dnssec(res, true); /* setup the root nameserver in the new resolver */ status = ldns_resolver_push_nameserver_rr_list(res, global_dns_root); if (status != LDNS_STATUS_OK) { printf("ERRRRR: %s\n", ldns_get_errorstr_by_id(status)); ldns_rr_list_print(stdout, global_dns_root); result = status; goto done; } labels_count = ldns_dname_label_count(name); if (start_name) { if (ldns_dname_is_subdomain(name, start_name)) { labels_count -= ldns_dname_label_count(start_name); } else { fprintf(stderr, "Error; "); ldns_rdf_print(stderr, name); fprintf(stderr, " is not a subdomain of "); ldns_rdf_print(stderr, start_name); fprintf(stderr, "\n"); goto done; } } labels = LDNS_CALLOC(ldns_rdf*, labels_count + 2); if (!labels) { goto done; } labels[0] = ldns_dname_new_frm_str(LDNS_ROOT_LABEL_STR); labels[1] = ldns_rdf_clone(name); for(i = 2 ; i < (ssize_t)labels_count + 2; i++) { labels[i] = ldns_dname_left_chop(labels[i - 1]); } /* get the nameserver for the label * ask: dnskey and ds for the label */ for(i = (ssize_t)labels_count + 1; i > 0; i--) { status = ldns_resolver_send(&local_p, res, labels[i], LDNS_RR_TYPE_NS, c, 0); if (status != LDNS_STATUS_OK) { fprintf(stderr, "Error sending query: %s\n", ldns_get_errorstr_by_id(status)); result = status; goto done; } /* TODO: handle status */ if (verbosity >= 5) { ldns_pkt_print(stdout, local_p); } new_nss = ldns_pkt_rr_list_by_type(local_p, LDNS_RR_TYPE_NS, LDNS_SECTION_ANSWER); if (!new_nss) { /* if it's a delegation, servers put them in the auth section */ new_nss = ldns_pkt_rr_list_by_type(local_p, LDNS_RR_TYPE_NS, LDNS_SECTION_AUTHORITY); } /* if this is the final step there might not be nameserver records of course if the data is in the apex, there are, so cover both cases */ if (new_nss || i > 1) { for(j = 0; j < ldns_rr_list_rr_count(new_nss); j++) { ns_rr = ldns_rr_list_rr(new_nss, j); pop = ldns_rr_rdf(ns_rr, 0); if (!pop) { printf("nopo\n"); break; } /* retrieve it's addresses */ /* trust glue? */ new_ns_addr = NULL; if (ldns_dname_is_subdomain(pop, labels[i])) { if (ldns_resolver_ip6(res) == LDNS_RESOLV_INET6) { new_ns_addr = ldns_pkt_rr_list_by_name_and_type(local_p, pop, LDNS_RR_TYPE_AAAA, LDNS_SECTION_ADDITIONAL); } else { /* If IPv4 is specified, or no IP version is specified, default to A record and use IPv4 */ new_ns_addr = ldns_pkt_rr_list_by_name_and_type(local_p, pop, LDNS_RR_TYPE_A, LDNS_SECTION_ADDITIONAL); } } if (!new_ns_addr || ldns_rr_list_rr_count(new_ns_addr) == 0) { new_ns_addr = ldns_get_rr_list_addr_by_name(res, pop, c, 0); } if (!new_ns_addr || ldns_rr_list_rr_count(new_ns_addr) == 0) { new_ns_addr = ldns_get_rr_list_addr_by_name(local_res, pop, c, 0); } if (new_ns_addr) { old_ns_addr = ns_addr; ns_addr = ldns_rr_list_cat_clone(ns_addr, new_ns_addr); ldns_rr_list_deep_free(old_ns_addr); } ldns_rr_list_deep_free(new_ns_addr); } ldns_rr_list_deep_free(new_nss); if (ns_addr) { remove_resolver_nameservers(res); if (ldns_resolver_push_nameserver_rr_list(res, ns_addr) != LDNS_STATUS_OK) { error("Error adding new nameservers"); ldns_pkt_free(local_p); goto done; } ldns_rr_list_deep_free(ns_addr); } else { status = ldns_verify_denial(local_p, labels[i], LDNS_RR_TYPE_NS, &nsec_rrs, &nsec_rr_sigs); /* verify the nsec3 themselves*/ if (verbosity >= 4) { printf("NSEC(3) Records to verify:\n"); ldns_rr_list_print(stdout, nsec_rrs); printf("With signatures:\n"); ldns_rr_list_print(stdout, nsec_rr_sigs); printf("correct keys:\n"); ldns_rr_list_print(stdout, correct_key_list); } if (status == LDNS_STATUS_OK) { if ((st = ldns_verify(nsec_rrs, nsec_rr_sigs, trusted_keys, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", TRUST); fprintf(stdout, "Existence denied: "); ldns_rdf_print(stdout, labels[i]); /* if (descriptor && descriptor->_name) { printf(" %s", descriptor->_name); } else { printf(" TYPE%u", t); } */ fprintf(stdout, " NS\n"); } else if ((st = ldns_verify(nsec_rrs, nsec_rr_sigs, correct_key_list, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", SELF); fprintf(stdout, "Existence denied: "); ldns_rdf_print(stdout, labels[i]); /* if (descriptor && descriptor->_name) { printf(" %s", descriptor->_name); } else { printf(" TYPE%u", t); } */ fprintf(stdout, " NS\n"); } else { fprintf(stdout, "%s ", BOGUS); result = 1; printf(";; Error verifying denial of existence for name "); ldns_rdf_print(stdout, labels[i]); /* printf(" type "); if (descriptor && descriptor->_name) { printf("%s", descriptor->_name); } else { printf("TYPE%u", t); } */ printf("NS: %s\n", ldns_get_errorstr_by_id(st)); } } else { fprintf(stdout, "%s ", BOGUS); result = 1; printf(";; Error verifying denial of existence for name "); ldns_rdf_print(stdout, labels[i]); printf("NS: %s\n", ldns_get_errorstr_by_id(status)); } /* there might be an empty non-terminal, in which case we need to continue */ ent = false; for (j = 0; j < ldns_rr_list_rr_count(nsec_rrs); j++) { nsecrr = ldns_rr_list_rr(nsec_rrs, j); /* For NSEC when the next name is a subdomain of the question */ if (ldns_rr_get_type(nsecrr) == LDNS_RR_TYPE_NSEC && ldns_dname_is_subdomain(ldns_rr_rdf(nsecrr, 0), labels[i])) { ent = true; /* For NSEC3, the hash matches the name and the type bitmap is empty*/ } else if (ldns_rr_get_type(nsecrr) == LDNS_RR_TYPE_NSEC3) { hashed_name = ldns_nsec3_hash_name_frm_nsec3(nsecrr, labels[i]); label0 = ldns_dname_label(ldns_rr_owner(nsecrr), 0); if (hashed_name && label0 && ldns_dname_compare(hashed_name, label0) == 0 && ldns_nsec3_bitmap(nsecrr) == NULL) { ent = true; } if (label0) { LDNS_FREE(label0); } if (hashed_name) { LDNS_FREE(hashed_name); } } } if (!ent) { ldns_rr_list_deep_free(nsec_rrs); ldns_rr_list_deep_free(nsec_rr_sigs); ldns_pkt_free(local_p); goto done; } else { printf(";; There is an empty non-terminal here, continue\n"); continue; } } if (ldns_resolver_nameserver_count(res) == 0) { error("No nameservers found for this node"); goto done; } } ldns_pkt_free(local_p); fprintf(stdout, ";; Domain: "); ldns_rdf_print(stdout, labels[i]); fprintf(stdout, "\n"); /* retrieve keys for current domain, and verify them if they match an already trusted DS, or if one of the keys used to sign these is trusted, add the keys to the trusted list */ p = get_dnssec_pkt(res, labels[i], LDNS_RR_TYPE_DNSKEY); (void) get_key(p, labels[i], &key_list, &key_sig_list); if (key_sig_list) { if (key_list) { current_correct_keys = ldns_rr_list_new(); if ((st = ldns_verify(key_list, key_sig_list, key_list, current_correct_keys)) == LDNS_STATUS_OK) { /* add all signed keys (don't just add current_correct, you'd miss * the zsk's then */ for (j = 0; j < ldns_rr_list_rr_count(key_list); j++) { ldns_rr_list_push_rr(correct_key_list, ldns_rr_clone(ldns_rr_list_rr(key_list, j))); } /* check whether these keys were signed * by a trusted keys. if so, these * keys are also trusted */ new_keys_trusted = false; for (k = 0; k < ldns_rr_list_rr_count(current_correct_keys); k++) { for (j = 0; j < ldns_rr_list_rr_count(trusted_ds_rrs); j++) { if (ldns_rr_compare_ds(ldns_rr_list_rr(current_correct_keys, k), ldns_rr_list_rr(trusted_ds_rrs, j))) { new_keys_trusted = true; } } } /* also all keys are trusted if one of the current correct keys is trusted */ for (k = 0; k < ldns_rr_list_rr_count(current_correct_keys); k++) { for (j = 0; j < ldns_rr_list_rr_count(trusted_keys); j++) { if (ldns_rr_compare(ldns_rr_list_rr(current_correct_keys, k), ldns_rr_list_rr(trusted_keys, j)) == 0) { new_keys_trusted = true; } } } if (new_keys_trusted) { ldns_rr_list_push_rr_list(trusted_keys, key_list); print_rr_list_abbr(stdout, key_list, TRUST); ldns_rr_list_free(key_list); key_list = NULL; } else { if (verbosity >= 2) { printf(";; Signature ok but no chain to a trusted key or ds record\n"); } print_rr_list_abbr(stdout, key_list, SELF); ldns_rr_list_deep_free(key_list); key_list = NULL; } } else { print_rr_list_abbr(stdout, key_list, BOGUS); result = 2; ldns_rr_list_deep_free(key_list); key_list = NULL; } ldns_rr_list_free(current_correct_keys); current_correct_keys = NULL; } else { printf(";; No DNSKEY record found for "); ldns_rdf_print(stdout, labels[i]); printf("\n"); } } ldns_pkt_free(p); ldns_rr_list_deep_free(key_sig_list); key_sig_list = NULL; /* check the DS records for the next child domain */ if (i > 1) { p = get_dnssec_pkt(res, labels[i-1], LDNS_RR_TYPE_DS); (void) get_ds(p, labels[i-1], &ds_list, &ds_sig_list); if (!ds_list) { ldns_rr_list_deep_free(ds_sig_list); (void) get_dnssec_rr( p, labels[i-1] , LDNS_RR_TYPE_CNAME , &ds_list, &ds_sig_list); if (ds_list) { st = ldns_verify( ds_list, ds_sig_list , correct_key_list , current_correct_keys); if (st == LDNS_STATUS_OK) { printf(";; No DS record found " "for "); ldns_rdf_print(stdout, labels[i-1]); printf(", but valid CNAME"); } else { printf(BOGUS " Unable to verify " "denial of existence for "); ldns_rdf_print(stdout, labels[i-1]); printf(", because of BOGUS CNAME"); } printf("\n"); ldns_rr_list_deep_free(ds_sig_list); ldns_pkt_free(p); ldns_rr_list_deep_free(ds_list); ds_list = NULL; ds_sig_list = NULL; p = NULL; } else { ldns_rr_list_deep_free(ds_sig_list); ldns_pkt_free(p); p = get_dnssec_pkt(res, name, LDNS_RR_TYPE_DNSKEY); (void) get_ds(p, NULL , &ds_list, &ds_sig_list); } } if (ds_sig_list) { if (ds_list) { if (verbosity >= 4) { printf("VERIFYING:\n"); printf("DS LIST:\n"); ldns_rr_list_print(stdout, ds_list); printf("SIGS:\n"); ldns_rr_list_print(stdout, ds_sig_list); printf("KEYS:\n"); ldns_rr_list_print(stdout, correct_key_list); } current_correct_keys = ldns_rr_list_new(); if ((st = ldns_verify(ds_list, ds_sig_list, correct_key_list, current_correct_keys)) == LDNS_STATUS_OK) { /* if the ds is signed by a trusted key and a key from correct keys matches that ds, add that key to the trusted keys */ new_keys_trusted = false; if (verbosity >= 2) { printf("Checking if signing key is trusted:\n"); } for (j = 0; j < ldns_rr_list_rr_count(current_correct_keys); j++) { if (verbosity >= 2) { printf("New key: "); ldns_rr_print(stdout, ldns_rr_list_rr(current_correct_keys, j)); } for (k = 0; k < ldns_rr_list_rr_count(trusted_keys); k++) { if (verbosity >= 2) { printf("\tTrusted key: "); ldns_rr_print(stdout, ldns_rr_list_rr(trusted_keys, k)); } if (ldns_rr_compare(ldns_rr_list_rr(current_correct_keys, j), ldns_rr_list_rr(trusted_keys, k)) == 0) { if (verbosity >= 2) { printf("Key is now trusted!\n"); } for (l = 0; l < ldns_rr_list_rr_count(ds_list); l++) { ldns_rr_list_push_rr(trusted_ds_rrs, ldns_rr_clone(ldns_rr_list_rr(ds_list, l))); new_keys_trusted = true; } } } } if (new_keys_trusted) { print_rr_list_abbr(stdout, ds_list, TRUST); } else { print_rr_list_abbr(stdout, ds_list, SELF); } } else { result = 3; print_rr_list_abbr(stdout, ds_list, BOGUS); } ldns_rr_list_free(current_correct_keys); current_correct_keys = NULL; } else { /* wait apparently there were no keys either, go back to the ds packet */ ldns_pkt_free(p); ldns_rr_list_deep_free(ds_sig_list); p = get_dnssec_pkt(res, labels[i-1], LDNS_RR_TYPE_DS); (void) get_ds(p, labels[i-1], &ds_list, &ds_sig_list); status = ldns_verify_denial(p, labels[i-1], LDNS_RR_TYPE_DS, &nsec_rrs, &nsec_rr_sigs); if (verbosity >= 4) { printf("NSEC(3) Records to verify:\n"); ldns_rr_list_print(stdout, nsec_rrs); printf("With signatures:\n"); ldns_rr_list_print(stdout, nsec_rr_sigs); printf("correct keys:\n"); ldns_rr_list_print(stdout, correct_key_list); } if (status == LDNS_STATUS_OK) { if ((st = ldns_verify(nsec_rrs, nsec_rr_sigs, trusted_keys, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", TRUST); fprintf(stdout, "Existence denied: "); ldns_rdf_print(stdout, labels[i-1]); printf(" DS"); fprintf(stdout, "\n"); } else if ((st = ldns_verify(nsec_rrs, nsec_rr_sigs, correct_key_list, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", SELF); fprintf(stdout, "Existence denied: "); ldns_rdf_print(stdout, labels[i-1]); printf(" DS"); fprintf(stdout, "\n"); } else { result = 4; fprintf(stdout, "%s ", BOGUS); printf("Error verifying denial of existence for "); ldns_rdf_print(stdout, labels[i-1]); printf(" DS"); printf(": %s\n", ldns_get_errorstr_by_id(st)); } } else { if (status == LDNS_STATUS_CRYPTO_NO_RRSIG) { printf(";; No DS for "); ldns_rdf_print(stdout, labels[i - 1]); } else { printf(BOGUS " Unable to verify denial of existence for "); ldns_rdf_print(stdout, labels[i - 1]); printf(" DS: %s\n", ldns_get_errorstr_by_id(status)); } } if (verbosity >= 2) { printf(";; No ds record for delegation\n"); } } } ldns_rr_list_deep_free(ds_list); ldns_pkt_free(p); } else { /* if this is the last label, just verify the data and stop */ p = get_dnssec_pkt(res, labels[i], t); (void) get_dnssec_rr(p, labels[i], t, &dataset, &key_sig_list); if (dataset && ldns_rr_list_rr_count(dataset) > 0) { if (key_sig_list && ldns_rr_list_rr_count(key_sig_list) > 0) { /* If this is a wildcard, you must be able to deny exact match */ if ((st = ldns_verify(dataset, key_sig_list, trusted_keys, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", TRUST); ldns_rr_list_print(stdout, dataset); } else if ((st = ldns_verify(dataset, key_sig_list, correct_key_list, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", SELF); ldns_rr_list_print(stdout, dataset); } else { result = 5; fprintf(stdout, "%s ", BOGUS); ldns_rr_list_print(stdout, dataset); printf(";; Error: %s\n", ldns_get_errorstr_by_id(st)); } } else { fprintf(stdout, "%s ", UNSIGNED); ldns_rr_list_print(stdout, dataset); } ldns_rr_list_deep_free(dataset); } else { status = ldns_verify_denial(p, name, t, &nsec_rrs, &nsec_rr_sigs); if (status == LDNS_STATUS_OK) { /* verify the nsec3 themselves*/ if (verbosity >= 5) { printf("NSEC(3) Records to verify:\n"); ldns_rr_list_print(stdout, nsec_rrs); printf("With signatures:\n"); ldns_rr_list_print(stdout, nsec_rr_sigs); printf("correct keys:\n"); ldns_rr_list_print(stdout, correct_key_list); /* printf("trusted keys at %p:\n", trusted_keys); ldns_rr_list_print(stdout, trusted_keys); */ } if ((st = ldns_verify(nsec_rrs, nsec_rr_sigs, trusted_keys, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", TRUST); fprintf(stdout, "Existence denied: "); ldns_rdf_print(stdout, name); if (descriptor && descriptor->_name) { printf(" %s", descriptor->_name); } else { printf(" TYPE%u", t); } fprintf(stdout, "\n"); } else if ((st = ldns_verify(nsec_rrs, nsec_rr_sigs, correct_key_list, NULL)) == LDNS_STATUS_OK) { fprintf(stdout, "%s ", SELF); fprintf(stdout, "Existence denied: "); ldns_rdf_print(stdout, name); if (descriptor && descriptor->_name) { printf(" %s", descriptor->_name); } else { printf(" TYPE%u", t); } fprintf(stdout, "\n"); } else { result = 6; fprintf(stdout, "%s ", BOGUS); printf("Error verifying denial of existence for "); ldns_rdf_print(stdout, name); printf(" type "); if (descriptor && descriptor->_name) { printf("%s", descriptor->_name); } else { printf("TYPE%u", t); } printf(": %s\n", ldns_get_errorstr_by_id(st)); } ldns_rr_list_deep_free(nsec_rrs); ldns_rr_list_deep_free(nsec_rr_sigs); } else { /* */ if (status == LDNS_STATUS_CRYPTO_NO_RRSIG) { printf("%s ", UNSIGNED); printf("No data found for: "); ldns_rdf_print(stdout, name); printf(" type "); if (descriptor && descriptor->_name) { printf("%s", descriptor->_name); } else { printf("TYPE%u", t); } printf("\n"); } else { printf(BOGUS " Unable to verify denial of existence for "); ldns_rdf_print(stdout, name); printf(" type "); if (descriptor && descriptor->_name) { printf("%s", descriptor->_name); } else { printf("TYPE%u", t); } printf("\n"); } } } ldns_pkt_free(p); } new_nss = NULL; ns_addr = NULL; ldns_rr_list_deep_free(key_list); key_list = NULL; ldns_rr_list_deep_free(key_sig_list); key_sig_list = NULL; ds_list = NULL; ldns_rr_list_deep_free(ds_sig_list); ds_sig_list = NULL; } printf(";;" SELF " self sig OK; " BOGUS " bogus; " TRUST " trusted; " UNSIGNED " unsigned\n"); /* verbose mode? printf("Trusted keys:\n"); ldns_rr_list_print(stdout, trusted_keys); printf("trusted dss:\n"); ldns_rr_list_print(stdout, trusted_ds_rrs); */ done: ldns_rr_list_deep_free(trusted_ds_rrs); ldns_rr_list_deep_free(correct_key_list); ldns_resolver_deep_free(res); if (labels) { for(i = 0 ; i < (ssize_t)labels_count + 2; i++) { ldns_rdf_deep_free(labels[i]); } LDNS_FREE(labels); } return result; } #endif /* HAVE_SSL */ ldns-1.9.2/drill/drill.h0000664000175000017500000000507415212267520014426 0ustar willemwillem/* * drill.h * the main header file of drill * (c) 2005, 2006 NLnet Labs * * See the file LICENSE for the license * */ #ifndef _DRILL_H_ #define _DRILL_H_ #include "config.h" #include "drill_util.h" #define DRILL_VERSION PACKAGE_VERSION /* what kind of stuff do we allow */ #define DRILL_QUERY 0 #define DRILL_TRACE 1 #define DRILL_CHASE 2 #define DRILL_AFROMFILE 3 #define DRILL_QTOFILE 4 #define DRILL_NSEC 5 #define DRILL_SECTRACE 7 #define DRILL_ON(VAR, BIT) \ (VAR) = (VAR) | (BIT) #define DRILL_OFF(VAR, BIT) \ (VAR) = (VAR) & ~(BIT) extern ldns_rr_list *global_dns_root; extern int verbosity; void do_trace(ldns_resolver *res, ldns_rdf *name, ldns_rr_type type, ldns_rr_class c); ldns_status do_chase(ldns_resolver *res, ldns_rdf *name, ldns_rr_type type, ldns_rr_class c, ldns_rr_list *trusted_keys, ldns_pkt *pkt_o, uint16_t qflags, ldns_rr_list *prev_key_list); int do_secure_trace(ldns_resolver *res, ldns_rdf *name, ldns_rr_type type, ldns_rr_class c, ldns_rr_list *trusted_keys, ldns_rdf *start_name); ldns_rr_list * get_rr(ldns_resolver *res, ldns_rdf *zname, ldns_rr_type t, ldns_rr_class c); void drill_pkt_print(FILE *fd, ldns_resolver *r, ldns_pkt *p); void drill_pkt_print_footer(FILE *fd, ldns_resolver *r, ldns_pkt *p); ldns_pkt_type get_dnssec_rr(ldns_pkt *p, ldns_rdf *name, ldns_rr_type t, ldns_rr_list **rrlist, ldns_rr_list **sig); ldns_rr *ldns_nsec3_exact_match(ldns_rdf *qname, ldns_rr_type qtype, ldns_rr_list *nsec3s); ldns_rdf *ldns_nsec3_closest_encloser(ldns_rdf *qname, ldns_rr_type qtype, ldns_rr_list *nsec3s); /* verifies denial of existence of *name in *pkt (must contain NSEC or NSEC3 records * if *nsec_rrs and *nsec_rr_sigs are given, pointers to the relevant nsecs and their signatures are * placed there */ ldns_status ldns_verify_denial(ldns_pkt *pkt, ldns_rdf *name, ldns_rr_type type, ldns_rr_list **nsec_rrs, ldns_rr_list **nsec_rr_sigs); ldns_pkt *read_hex_pkt(char *filename); ldns_buffer *read_hex_buffer(char *filename); void init_root(void); ldns_rr_list *read_root_hints(const char *filename); void clear_root(void); void dump_hex(const ldns_pkt *pkt, const char *file); void warning(const char *fmt, ...); void error(const char *fmt, ...); void mesg(const char *fmt, ...); /* screen.c */ void resolver_print_nameservers(ldns_resolver *r); void print_dnskey(ldns_rr_list *key_list); void print_ds(ldns_rr_list *ds_list); #endif /* _DRILL_H_ */ ldns-1.9.2/drill/README0000664000175000017500000000045615212267520014026 0ustar willemwillemQUICK INSTALL GUIDE drill is a subdirectory in ldns. To compile drill you need: autoreconf && ./configure && make If ldns is installed in a different location, use --with-ldns=directory See also ./configure --help In the first case you must run drill as: LD_LIBRARY_PATH=../.libs ./drill ldns-1.9.2/drill/drill_util.h0000664000175000017500000000223115212267520015453 0ustar willemwillem/* * util.h * util.c header file * in ldns * (c) 2005 NLnet Labs * * See the file LICENSE for the license * */ #ifndef _DRILL_UTIL_H_ #define _DRILL_UTIL_H_ #include /** * Read keys from filename and append to key_list. */ ldns_status read_key_file(const char *filename, ldns_rr_list *key_list, bool silently); /** * return a address rdf, either A or AAAA * NULL if anything goes wrong */ ldns_rdf * ldns_rdf_new_addr_frm_str(char *); /** * print all the ds of the keys in the packet */ void print_ds_of_keys(ldns_pkt *p); /** * print some rdfs of a signature */ void print_rrsig_abbr(FILE *fp, ldns_rr *sig); /** * print some rdfs of a dnskey */ void print_dnskey_abbr(FILE *fp, ldns_rr *key); /** * print some rdfs of a ds */ void print_ds_abbr(FILE *fp, ldns_rr *ds); /** * print some rdfs of a rr in a rr_list */ void print_rr_list_abbr(FILE *fp, ldns_rr_list *sig, const char *usr); /** * Alloc some memory, with error checking */ void *xmalloc(size_t s); /** * Realloc some memory, with error checking */ void *xrealloc(void *p, size_t s); /** * Free the data */ void xfree(void *q); #endif /* _DRILL_UTIL_H_ */ ldns-1.9.2/drill/root.c0000664000175000017500000001324315212267520014273 0ustar willemwillem/* * root.c * Function to handle to the rootservers * and to update and prime them * (c) 2005 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include #include /* a global list of the root-servers */ ldns_rr_list *global_dns_root = NULL; /* put a hardcoded list in the root and * init the root rrlist structure */ void init_root(void) { ldns_rr *r; global_dns_root = ldns_rr_list_new(); (void)ldns_rr_new_frm_str(&r, "A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "B.ROOT-SERVERS.NET. 3600000 A 170.247.170.2", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "B.ROOT-SERVERS.NET. 3600000 AAAA 2801:1b8:10::B", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "C.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2::C", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "D.ROOT-SERVERS.NET. 3600000 A 199.7.91.13", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2D::D", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "E.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:A8::E", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2F::F", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "G.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:12::D0D", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "H.ROOT-SERVERS.NET. 3600000 A 198.97.190.53", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::53", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FE::53", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129 ", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FD::1", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:9F::42", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); (void)ldns_rr_new_frm_str(&r, "M.ROOT-SERVERS.NET. 3600000 AAAA 2001:DC3::35", 0, NULL, NULL); ldns_rr_list_push_rr(global_dns_root, r); } /* * Read a hints file as root * * The file with the given path should contain a list of NS RRs * for the root zone and A records for those NS RRs. * Read them, check them, and append the a records to the rr list given. */ ldns_rr_list * read_root_hints(const char *filename) { FILE *fp = NULL; int line_nr = 0; ldns_zone *z; ldns_status status; ldns_rr_list *addresses = NULL; ldns_rr *rr; size_t i; fp = fopen(filename, "r"); if (!fp) { fprintf(stderr, "Unable to open %s for reading: %s\n", filename, strerror(errno)); return NULL; } status = ldns_zone_new_frm_fp_l(&z, fp, NULL, 0, 0, &line_nr); fclose(fp); if (status != LDNS_STATUS_OK) { fprintf(stderr, "Error reading root hints file: %s\n", ldns_get_errorstr_by_id(status)); return NULL; } else { addresses = ldns_rr_list_new(); for (i = 0; i < ldns_rr_list_rr_count(ldns_zone_rrs(z)); i++) { rr = ldns_rr_list_rr(ldns_zone_rrs(z), i); /*if ((address_family == 0 || address_family == 1) && */ if ( ldns_rr_get_type(rr) == LDNS_RR_TYPE_A ) { ldns_rr_list_push_rr(addresses, ldns_rr_clone(rr)); } /*if ((address_family == 0 || address_family == 2) &&*/ if ( ldns_rr_get_type(rr) == LDNS_RR_TYPE_AAAA) { ldns_rr_list_push_rr(addresses, ldns_rr_clone(rr)); } } ldns_zone_deep_free(z); return addresses; } } void clear_root(void) { ldns_rr_list_deep_free(global_dns_root); } ldns-1.9.2/drill/ChangeLog.22-nov-20050000664000175000017500000000642015212267520016323 0ustar willemwillem--------- Drill now is a subdirectory in ldns. To make life easier --------- we are using ldns' version numbering for drill from now on. --------- Sadly this means we GO BACKWARDS in the versions --------- This ChangeLog will not be updated anymore - all changes are --------- documented in ldns' ChangeLog 1.0-pre3: to be released: drill-team * Secure tracing works * Added section about DNSSEC in the manual page * Allow the class information to be given to do_chase() * Lint fixes for the code * Bugzilla was setup for drill * Bug #97 (drill); -S crash was fixed * Add -Q (quiet) flag was added. This suppresses output from drill. 1.0-pre2: 20 Jun 2005: drill-team * Second prerelease * Bugs where fix in the chasing functionality 1.0-pre1: 1 Jun 2005: drill-team * First drill release based on ldns * drill's core code is not much more simple, as all the difficult stuff is moved to ldns. * Much saner argument parsing ---------- Above Newer drill based on ldns -------------- ---------- Below Older drill with it's own DNS handling -------------- 0.9.2: Feb 3 2005: drill-team * Added two more options (borrowed from dig) --rd, don't set the RD bit in queries --fail, don't query the next nameserver on SERVFAIL * Fixed handling of obscure data types * Handle classes other the 'IN' when making a query * For people using FreeBSD: drill is now in the ports (Thanks to Jaap Akkerhuis) 0.9.1: Jan 5 2005: drill-team * Makefile tweaks * drill ns . works * re-check the root in when tracing * added handling for some lesser known types (including WKS) 0.9: Dec 6 2004: drill-team * big configure.ac and Makefile.in updates (made more general) * escapes in names argument and txt and dname data * gcc 2(.95) support * packet wire data is now checked for dangerous elements (like looping compression etc) * (Multiple) Octal char representation * Responses can be saved to file * 'Answers' can be read from file instead of server * Lots and lots of bugfixes and improvements 0.8.1: Oct 27 2004: Miek * configure.ac updates * secure resolving updates (still doesn't work) * printing additions - CERT RR supported - LOC RR support * All non supported RRs are handled as unknown * If no nameservers found in /etc/resolv.conf default to 127.0.0.1 * Various bugs fixed - Close sockets after using them - Some memory leaks were plugged 0.8: Oct 26 2004: Miek * Lots of features added. Drill is almost feature complete * Unknown RR's are supported * Numerous smaller updates in documentation * Numerous code cleanups * Dig is no longer needed to build drill 0.7: Oct 21 2004: Miek * reworked internal code * DNSSEC is working, except the secure resolving * build updates * more sane options parsing * more sane argument handling 0.6-alpha: Oct 2004: Jelte * No log 0.5-alpha: Sept 22 2004: Miek * most of the DNS stuff is working * moved to configure * tested on Linux/FreeBSD * fully IPV6 capable * new DNSSEC types supported * DNSSEC somewhat working * gcc => 3 is needed for building 0.4-alpha: Sept 9 2004: Miek * moved to autoconf for building * lots of various updates * really a workable program now 0.3-alpha: Sept 6 2004: Miek * IPv6 support * automatic secure resolving * --trace updates * --chase updates * more checks ldns-1.9.2/drill/chasetrace.c0000664000175000017500000003176515212267520015423 0ustar willemwillem/* * chasetrace.c * Where all the hard work concerning chasing * and tracing is done * (c) 2005, 2006 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include /* Cache all RRs from rr_list "rr_list" to "referrals" database for lookup * later on. Print the NS RRs that were not already present. */ static void add_rr_list_to_referrals( ldns_dnssec_zone *referrals, ldns_rr_list *rr_list) { size_t i; ldns_rr *rr; ldns_dnssec_rrsets *rrset; ldns_dnssec_rrs *rrs; for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) { rr = ldns_rr_list_rr(rr_list, i); /* Check if a RR equal to "rr" is present in "referrals" */ rrset = ldns_dnssec_zone_find_rrset( referrals, ldns_rr_owner(rr), ldns_rr_get_type(rr)); if (rrset) { for (rrs = rrset->rrs; rrs; rrs = rrs->next) if (ldns_rr_compare(rr, rrs->rr) == 0) break; if (rrs) continue; /* "rr" is present, next! */ } if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_NS && verbosity != -1) ldns_rr_print(stdout, rr); (void) ldns_dnssec_zone_add_rr(referrals, rr); } } /* Cache all RRs from packet "p" to "referrals" database for lookup later on. * Print the NS RRs that were not already present. */ static void add_referrals(ldns_dnssec_zone *referrals, ldns_pkt *p) { ldns_rr_list *l = ldns_pkt_all_noquestion(p); if (l) { add_rr_list_to_referrals(referrals, l); ldns_rr_list_free(l); } } /* Equip name-server "res" with the name-servers authoritative for as much * of "name" as possible. Lookup addresses if needed. */ static bool set_nss_for_name( ldns_resolver *res, ldns_dnssec_zone *referrals, ldns_rdf *name, ldns_resolver *local_res, ldns_rr_class c) { ldns_dnssec_rrsets *nss = NULL; ldns_dnssec_rrs *nss_rrs; ldns_dnssec_rrsets *as = NULL; ldns_dnssec_rrs *as_rrs; ldns_rdf *lookup = ldns_rdf_clone(name); ldns_rdf *new_lookup; ldns_rdf *addr; ldns_rr_list *addrs; /* nss will become the rrset of as much of "name" as possible */ for (;;) { nss = ldns_dnssec_zone_find_rrset( referrals, lookup, LDNS_RR_TYPE_NS); if (nss != NULL) { ldns_rdf_deep_free(lookup); break; } new_lookup = ldns_dname_left_chop(lookup); ldns_rdf_deep_free(lookup); lookup = new_lookup; if (!lookup) { error("No referrals for name found"); return false; } } /* remove the old nameserver from the resolver */ while ((addr = ldns_resolver_pop_nameserver(res))) ldns_rdf_deep_free(addr); /* Find and add the address records for the rrset as name-servers */ for (nss_rrs = nss->rrs; nss_rrs; nss_rrs = nss_rrs->next) { if ((as = ldns_dnssec_zone_find_rrset( referrals, ldns_rr_rdf(nss_rrs->rr, 0), LDNS_RR_TYPE_A))) for (as_rrs = as->rrs; as_rrs; as_rrs = as_rrs->next) (void) ldns_resolver_push_nameserver( res, ldns_rr_rdf(as_rrs->rr, 0)); if ((as = ldns_dnssec_zone_find_rrset( referrals, ldns_rr_rdf(nss_rrs->rr, 0), LDNS_RR_TYPE_AAAA))) for (as_rrs = as->rrs; as_rrs; as_rrs = as_rrs->next) (void) ldns_resolver_push_nameserver( res, ldns_rr_rdf(as_rrs->rr, 0)); } /* Is our resolver equipped with name-servers? Good! We're done */ if (ldns_resolver_nameserver_count(res) > 0) return true; /* Lookup addresses with local resolver add add to "referrals" database */ addrs = ldns_rr_list_new(); for (nss_rrs = nss->rrs; nss_rrs; nss_rrs = nss_rrs->next) { ldns_rr_list *addrs_by_name = ldns_get_rr_list_addr_by_name( local_res, ldns_rr_rdf(nss_rrs->rr, 0), c, 0); ldns_rr_list_cat(addrs, addrs_by_name); ldns_rr_list_free(addrs_by_name); } if (ldns_rr_list_rr_count(addrs) == 0) error("Could not find the nameserver ip addr; abort"); else if (ldns_resolver_push_nameserver_rr_list(res, addrs) != LDNS_STATUS_OK) error("Error adding new nameservers"); else { ldns_rr_list_deep_free(addrs); return true; } add_rr_list_to_referrals(referrals, addrs); ldns_rr_list_deep_free(addrs); return false; } /** * trace down from the root to name */ /* same naive method as in drill0.9 * We resolve _ALL_ the names, which is of course not needed. * We _do_ use the local resolver to do that, so it still is * fast, but it can be made to run much faster. */ void do_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t, ldns_rr_class c) { static uint8_t zero[1] = { 0 }; static const ldns_rdf root_dname = { 1, LDNS_RDF_TYPE_DNAME, &zero }; ldns_resolver *res = NULL; ldns_pkt *p = NULL; ldns_rr_list *final_answer; ldns_rr_list *new_nss; ldns_rr_list *cname = NULL; ldns_rr_list *answers = NULL; uint16_t loop_count; ldns_status status; ldns_dnssec_zone* referrals = NULL; ldns_rdf *addr; loop_count = 0; final_answer = NULL; res = ldns_resolver_new(); if (!res) { error("Memory allocation failed"); goto cleanup; } /* transfer some properties of local_res to res, * because they were given on the command line */ ldns_resolver_set_ip6(res, ldns_resolver_ip6(local_res)); ldns_resolver_set_port(res, ldns_resolver_port(local_res)); ldns_resolver_set_debug(res, ldns_resolver_debug(local_res)); ldns_resolver_set_dnssec(res, ldns_resolver_dnssec(local_res)); ldns_resolver_set_fail(res, ldns_resolver_fail(local_res)); ldns_resolver_set_usevc(res, ldns_resolver_usevc(local_res)); ldns_resolver_set_random(res, ldns_resolver_random(local_res)); ldns_resolver_set_source(res, ldns_resolver_source(local_res)); ldns_resolver_set_recursive(res, false); /* setup the root nameserver in the new resolver */ status = ldns_resolver_push_nameserver_rr_list(res, global_dns_root); if (status != LDNS_STATUS_OK) { fprintf(stderr, "Error adding root servers to resolver: %s\n", ldns_get_errorstr_by_id(status)); ldns_rr_list_print(stdout, global_dns_root); goto cleanup; } /* this must be a real query to local_res */ status = ldns_resolver_send(&p, res, &root_dname, LDNS_RR_TYPE_NS, c, 0); /* p can still be NULL */ if (ldns_pkt_empty(p)) { warning("No root server information received"); } if (status == LDNS_STATUS_OK) { if (!ldns_pkt_empty(p)) { drill_pkt_print(stdout, local_res, p); } referrals = ldns_dnssec_zone_new(); add_referrals(referrals, p); } else { error("cannot use local resolver"); goto cleanup; } if (! set_nss_for_name(res, referrals, name, local_res, c)) { goto cleanup; } ldns_pkt_free(p); p = NULL; status = ldns_resolver_send(&p, res, name, t, c, 0); while(status == LDNS_STATUS_OK && ldns_pkt_reply_type(p) == LDNS_PACKET_REFERRAL) { if (!p) { /* some error occurred -- bail out */ goto cleanup; } add_referrals(referrals, p); /* checks itself for verbosity */ drill_pkt_print_footer(stdout, local_res, p); if (! set_nss_for_name(res, referrals, name, local_res, c)) { goto cleanup; } if (loop_count++ > 20) { /* unlikely that we are doing anything useful */ error("Looks like we are looping"); goto cleanup; } ldns_pkt_free(p); p = NULL; status = ldns_resolver_send(&p, res, name, t, c, 0); /* Exit trace on error */ if (status != LDNS_STATUS_OK) break; /* An answer might be the desired answer (and no referral) */ if (ldns_pkt_reply_type(p) != LDNS_PACKET_ANSWER) continue; /* Exit trace when the requested type is found */ answers = ldns_pkt_rr_list_by_type(p, t, LDNS_SECTION_ANSWER); if (answers && ldns_rr_list_rr_count(answers) > 0) { ldns_rr_list_free(answers); answers = NULL; break; } ldns_rr_list_free(answers); answers = NULL; /* Get the CNAMEs from the answer */ cname = ldns_pkt_rr_list_by_type( p, LDNS_RR_TYPE_CNAME, LDNS_SECTION_ANSWER); /* No CNAME either: exit trace */ if (ldns_rr_list_rr_count(cname) == 0) break; /* Print CNAME referral */ ldns_rr_list_print(stdout, cname); /* restart with the CNAME */ name = ldns_rr_rdf(ldns_rr_list_rr(cname, 0), 0); ldns_rr_list_free(cname); cname = NULL; /* remove the old nameserver from the resolver */ while((addr = ldns_resolver_pop_nameserver(res))) ldns_rdf_deep_free(addr); /* Restart trace from the root up */ (void) ldns_resolver_push_nameserver_rr_list( res, global_dns_root); ldns_pkt_free(p); p = NULL; status = ldns_resolver_send(&p, res, name, t, c, 0); } ldns_pkt_free(p); p = NULL; (void) ldns_resolver_send(&p, res, name, t, c, 0); if (!p) { goto cleanup; } new_nss = ldns_pkt_authority(p); final_answer = ldns_pkt_answer(p); if (verbosity != -1) { ldns_rr_list_print(stdout, final_answer); ldns_rr_list_print(stdout, new_nss); } drill_pkt_print_footer(stdout, local_res, p); cleanup: if (res) { while((addr = ldns_resolver_pop_nameserver(res))) ldns_rdf_deep_free(addr); ldns_resolver_free(res); } if (referrals) ldns_dnssec_zone_deep_free(referrals); if (p) ldns_pkt_free(p); } /** * Chase the given rr to a known and trusted key * * Based on drill 0.9 * * the last argument prev_key_list, if not null, and type == DS, then the ds * rr list we have must all be a ds for the keys in this list */ #ifdef HAVE_SSL ldns_status do_chase(ldns_resolver *res, ldns_rdf *name, ldns_rr_type type, ldns_rr_class c, ldns_rr_list *trusted_keys, ldns_pkt *pkt_o, uint16_t qflags, ldns_rr_list * ATTR_UNUSED(prev_key_list)) { ldns_rr_list *rrset = NULL; ldns_status result; ldns_rr *orig_rr = NULL; /* ldns_rr_list *sigs; ldns_rr *cur_sig; uint16_t sig_i; ldns_rr_list *keys; */ ldns_pkt *pkt; ldns_status tree_result; ldns_dnssec_data_chain *chain; ldns_dnssec_trust_tree *tree; const ldns_rr_descriptor *descriptor; descriptor = ldns_rr_descript(type); ldns_dname2canonical(name); pkt = ldns_pkt_clone(pkt_o); if (!name) { mesg("No name to chase"); ldns_pkt_free(pkt); return LDNS_STATUS_EMPTY_LABEL; } if (verbosity != -1) { printf(";; Chasing: "); ldns_rdf_print(stdout, name); if (descriptor && descriptor->_name) { printf(" %s\n", descriptor->_name); } else { printf(" type %d\n", type); } } if (!trusted_keys || ldns_rr_list_rr_count(trusted_keys) < 1) { warning("No trusted keys specified"); } if (pkt) { rrset = ldns_pkt_rr_list_by_name_and_type(pkt, name, type, LDNS_SECTION_ANSWER ); if (!rrset) { /* nothing in answer, try authority */ rrset = ldns_pkt_rr_list_by_name_and_type(pkt, name, type, LDNS_SECTION_AUTHORITY ); } /* answer might be a cname, chase that first, then chase cname target? (TODO) */ if (!rrset) { rrset = ldns_pkt_rr_list_by_name_and_type(pkt, name, LDNS_RR_TYPE_CNAME, LDNS_SECTION_ANSWER ); if (!rrset) { /* nothing in answer, try authority */ rrset = ldns_pkt_rr_list_by_name_and_type(pkt, name, LDNS_RR_TYPE_CNAME, LDNS_SECTION_AUTHORITY ); } } } else { /* no packet? */ if (verbosity >= 0) { fprintf(stderr, "%s", ldns_get_errorstr_by_id(LDNS_STATUS_MEM_ERR)); fprintf(stderr, "\n"); } return LDNS_STATUS_MEM_ERR; } if (!rrset) { /* not found in original packet, try again */ ldns_pkt_free(pkt); pkt = NULL; pkt = ldns_resolver_query(res, name, type, c, qflags); if (!pkt) { if (verbosity >= 0) { fprintf(stderr, "%s", ldns_get_errorstr_by_id(LDNS_STATUS_NETWORK_ERR)); fprintf(stderr, "\n"); } return LDNS_STATUS_NETWORK_ERR; } if (verbosity >= 5) { ldns_pkt_print(stdout, pkt); } rrset = ldns_pkt_rr_list_by_name_and_type(pkt, name, type, LDNS_SECTION_ANSWER ); } orig_rr = ldns_rr_new(); /* if the answer had no answer section, we need to construct our own rr (for instance if * the rr qe asked for doesn't exist. This rr will be destroyed when the chain is freed */ if (ldns_pkt_ancount(pkt) < 1) { ldns_rr_set_type(orig_rr, type); ldns_rr_set_owner(orig_rr, ldns_rdf_clone(name)); chain = ldns_dnssec_build_data_chain(res, qflags, rrset, pkt, ldns_rr_clone(orig_rr)); } else { /* chase the first answer */ chain = ldns_dnssec_build_data_chain(res, qflags, rrset, pkt, NULL); } if (verbosity >= 4) { printf("\n\nDNSSEC Data Chain:\n"); ldns_dnssec_data_chain_print(stdout, chain); } result = LDNS_STATUS_OK; tree = ldns_dnssec_derive_trust_tree(chain, NULL); if (verbosity >= 2) { printf("\n\nDNSSEC Trust tree:\n"); ldns_dnssec_trust_tree_print(stdout, tree, 0, true); } if (ldns_rr_list_rr_count(trusted_keys) > 0) { tree_result = ldns_dnssec_trust_tree_contains_keys(tree, trusted_keys); if (tree_result == LDNS_STATUS_DNSSEC_EXISTENCE_DENIED) { if (verbosity >= 1) { printf("Existence denied or verifiably insecure\n"); } result = LDNS_STATUS_OK; } else if (tree_result != LDNS_STATUS_OK) { if (verbosity >= 1) { printf("No trusted keys found in tree: first error was: %s\n", ldns_get_errorstr_by_id(tree_result)); } result = tree_result; } } else { if (verbosity >= 0) { printf("You have not provided any trusted keys.\n"); } } ldns_rr_free(orig_rr); ldns_dnssec_trust_tree_free(tree); ldns_dnssec_data_chain_deep_free(chain); ldns_rr_list_deep_free(rrset); ldns_pkt_free(pkt); /* ldns_rr_free(orig_rr);*/ return result; } #endif /* HAVE_SSL */ ldns-1.9.2/drill/dnssec.c0000664000175000017500000003267615212267520014602 0ustar willemwillem/* * dnssec.c * Some DNSSEC helper function are defined here * and tracing is done * (c) 2005 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include /* get rr_type from a server from a server */ ldns_rr_list * get_rr(ldns_resolver *res, ldns_rdf *zname, ldns_rr_type t, ldns_rr_class c) { /* query, retrieve, extract and return */ ldns_pkt *p; ldns_rr_list *found; p = ldns_pkt_new(); found = NULL; if (ldns_resolver_send(&p, res, zname, t, c, 0) == LDNS_STATUS_OK) { found = ldns_pkt_rr_list_by_type(p, t, LDNS_SECTION_ANY_NOQUESTION); } ldns_pkt_free(p); return found; } void drill_pkt_print(FILE *fd, ldns_resolver *r, ldns_pkt *p) { ldns_rr_list *new_nss; ldns_rr_list *hostnames; char *answerfrom_str; if (verbosity < 5) { return; } hostnames = ldns_get_rr_list_name_by_addr(r, ldns_pkt_answerfrom(p), 0, 0); new_nss = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_NS, LDNS_SECTION_ANSWER); ldns_rr_list_print(fd, new_nss); ldns_rr_list_deep_free(new_nss); fprintf(fd, ";; Received %d bytes from %s#%d(", (int) ldns_pkt_size(p), ldns_rdf2str(ldns_pkt_answerfrom(p)), (int) ldns_resolver_port(r)); /* if we can resolve this print it, other print the ip again */ if (hostnames) { ldns_rdf_print(fd, ldns_rr_rdf(ldns_rr_list_rr(hostnames, 0), 0)); ldns_rr_list_deep_free(hostnames); } else { answerfrom_str = ldns_rdf2str(ldns_pkt_answerfrom(p)); if (answerfrom_str) { fprintf(fd, "%s", answerfrom_str); LDNS_FREE(answerfrom_str); } } fprintf(fd, ") in %u ms\n\n", (unsigned int)ldns_pkt_querytime(p)); } void drill_pkt_print_footer(FILE *fd, ldns_resolver *r, ldns_pkt *p) { ldns_rr_list *hostnames; char *answerfrom_str; if (verbosity < 5) { return; } hostnames = ldns_get_rr_list_name_by_addr(r, ldns_pkt_answerfrom(p), 0, 0); fprintf(fd, ";; Received %d bytes from %s#%d(", (int) ldns_pkt_size(p), ldns_rdf2str(ldns_pkt_answerfrom(p)), (int) ldns_resolver_port(r)); /* if we can resolve this print it, other print the ip again */ if (hostnames) { ldns_rdf_print(fd, ldns_rr_rdf(ldns_rr_list_rr(hostnames, 0), 0)); ldns_rr_list_deep_free(hostnames); } else { answerfrom_str = ldns_rdf2str(ldns_pkt_answerfrom(p)); if (answerfrom_str) { fprintf(fd, "%s", answerfrom_str); LDNS_FREE(answerfrom_str); } } fprintf(fd, ") in %u ms\n\n", (unsigned int)ldns_pkt_querytime(p)); } /* * generic function to get some RRset from a nameserver * and possible some signatures too (that would be the day...) */ ldns_pkt_type get_dnssec_rr(ldns_pkt *p, ldns_rdf *name, ldns_rr_type t, ldns_rr_list **rrlist, ldns_rr_list **sig) { ldns_pkt_type pt = LDNS_PACKET_UNKNOWN; ldns_rr_list *sigs = NULL; size_t i; if (!p) { if (rrlist) { *rrlist = NULL; } return LDNS_PACKET_UNKNOWN; } pt = ldns_pkt_reply_type(p); if (name) { if (rrlist) { *rrlist = ldns_pkt_rr_list_by_name_and_type(p, name, t, LDNS_SECTION_ANSWER); if (!*rrlist) { *rrlist = ldns_pkt_rr_list_by_name_and_type( p, name, t, LDNS_SECTION_AUTHORITY); } } if (sig) { sigs = ldns_pkt_rr_list_by_name_and_type(p, name, LDNS_RR_TYPE_RRSIG, LDNS_SECTION_ANSWER); if (!sigs) { sigs = ldns_pkt_rr_list_by_name_and_type( p, name, LDNS_RR_TYPE_RRSIG, LDNS_SECTION_AUTHORITY); } } } else { /* A DS-referral - get the DS records if they are there */ if (rrlist) { *rrlist = ldns_pkt_rr_list_by_type( p, t, LDNS_SECTION_AUTHORITY); } if (sig) { sigs = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_RRSIG, LDNS_SECTION_AUTHORITY); } } if (sig) { *sig = ldns_rr_list_new(); for (i = 0; i < ldns_rr_list_rr_count(sigs); i++) { /* only add the sigs that cover this type */ if (t == ldns_rdf2rr_type(ldns_rr_rrsig_typecovered( ldns_rr_list_rr(sigs, i)))) { ldns_rr_list_push_rr(*sig, ldns_rr_clone( ldns_rr_list_rr( sigs, i))); } } } ldns_rr_list_deep_free(sigs); if (pt == LDNS_PACKET_NXDOMAIN || pt == LDNS_PACKET_NODATA) { return pt; } else { return LDNS_PACKET_ANSWER; } } ldns_status ldns_verify_denial(ldns_pkt *pkt, ldns_rdf *name, ldns_rr_type type, ldns_rr_list **nsec_rrs, ldns_rr_list **nsec_rr_sigs) { #ifdef HAVE_SSL uint16_t nsec_i; ldns_rr_list *nsecs; ldns_status result; const ldns_rr_descriptor *descriptor; if (!pkt) { descriptor = ldns_rr_descript(type); printf("NETWORk ERROR! Cannot verify denial for: "); ldns_rdf_print(stdout, name); printf(" type "); if (descriptor && descriptor->_name) printf("%s", descriptor->_name); else printf("TYPE%u", type); return LDNS_STATUS_CRYPTO_NO_RRSIG; } if (verbosity >= 5) { printf("VERIFY DENIAL FROM:\n"); ldns_pkt_print(stdout, pkt); } result = LDNS_STATUS_CRYPTO_NO_RRSIG; /* Try to see if there are NSECS in the packet */ nsecs = ldns_pkt_rr_list_by_type(pkt, LDNS_RR_TYPE_NSEC, LDNS_SECTION_ANY_NOQUESTION); if (nsecs) { for (nsec_i = 0; nsec_i < ldns_rr_list_rr_count(nsecs); nsec_i++) { /* there are four options: * - name equals ownername and is covered by the type bitmap * - name equals ownername but is not covered by the type bitmap * - name falls within nsec coverage but is not equal to the owner name * - name falls outside of nsec coverage */ if (ldns_dname_compare(ldns_rr_owner(ldns_rr_list_rr(nsecs, nsec_i)), name) == 0) { /* printf("CHECKING NSEC:\n"); ldns_rr_print(stdout, ldns_rr_list_rr(nsecs, nsec_i)); printf("DAWASEM\n"); */ if (ldns_nsec_bitmap_covers_type( ldns_nsec_get_bitmap(ldns_rr_list_rr(nsecs, nsec_i)), type)) { /* Error, according to the nsec this rrset is signed */ result = LDNS_STATUS_CRYPTO_NO_RRSIG; } else { /* ok nsec denies existence */ if (verbosity >= 3) { printf(";; Existence of data set with this type denied by NSEC\n"); } /*printf(";; Verifiably insecure.\n");*/ if (nsec_rrs && nsec_rr_sigs) { (void) get_dnssec_rr(pkt, ldns_rr_owner(ldns_rr_list_rr(nsecs, nsec_i)), LDNS_RR_TYPE_NSEC, nsec_rrs, nsec_rr_sigs); } ldns_rr_list_deep_free(nsecs); return LDNS_STATUS_OK; } } else if (ldns_nsec_covers_name(ldns_rr_list_rr(nsecs, nsec_i), name)) { if (verbosity >= 3) { printf(";; Existence of data set with this name denied by NSEC\n"); } if (nsec_rrs && nsec_rr_sigs) { (void) get_dnssec_rr(pkt, ldns_rr_owner(ldns_rr_list_rr(nsecs, nsec_i)), LDNS_RR_TYPE_NSEC, nsec_rrs, nsec_rr_sigs); } ldns_rr_list_deep_free(nsecs); return LDNS_STATUS_OK; } else { /* nsec has nothing to do with this data */ } } ldns_rr_list_deep_free(nsecs); } else if( (nsecs = ldns_pkt_rr_list_by_type(pkt, LDNS_RR_TYPE_NSEC3, LDNS_SECTION_ANY_NOQUESTION)) ) { ldns_rr_list* sigs = ldns_pkt_rr_list_by_type(pkt, LDNS_RR_TYPE_RRSIG, LDNS_SECTION_ANY_NOQUESTION); ldns_rr* q = ldns_rr_new(); ldns_rr* match = NULL; if(!sigs) { if (q) { ldns_rr_free(q); } ldns_rr_list_deep_free(nsecs); return LDNS_STATUS_MEM_ERR; } if(!q) { ldns_rr_list_deep_free(nsecs); ldns_rr_list_deep_free(sigs); return LDNS_STATUS_MEM_ERR; } ldns_rr_set_question(q, 1); ldns_rr_set_ttl(q, 0); ldns_rr_set_owner(q, ldns_rdf_clone(name)); if(!ldns_rr_owner(q)) { ldns_rr_free(q); ldns_rr_list_deep_free(sigs); ldns_rr_list_deep_free(nsecs); return LDNS_STATUS_MEM_ERR; } ldns_rr_set_type(q, type); /* result = ldns_dnssec_verify_denial_nsec3(q, nsecs, sigs, ldns_pkt_get_rcode(pkt), type, ldns_pkt_ancount(pkt) == 0); */ result = ldns_dnssec_verify_denial_nsec3_match(q, nsecs, sigs, ldns_pkt_get_rcode(pkt), type, ldns_pkt_ancount(pkt) == 0, &match); if (result == LDNS_STATUS_OK && match && nsec_rrs && nsec_rr_sigs) { (void) get_dnssec_rr(pkt, ldns_rr_owner(match), LDNS_RR_TYPE_NSEC3, nsec_rrs, nsec_rr_sigs); } ldns_rr_free(q); ldns_rr_list_deep_free(nsecs); ldns_rr_list_deep_free(sigs); } return result; #else (void)pkt; (void)name; (void)type; (void)nsec_rrs; (void)nsec_rr_sigs; return LDNS_STATUS_ERR; #endif /* HAVE_SSL */ } /* NSEC3 draft -07 */ /*return hash name match*/ ldns_rr * ldns_nsec3_exact_match(ldns_rdf *qname, ldns_rr_type qtype, ldns_rr_list *nsec3s) { uint8_t algorithm; uint32_t iterations; uint8_t salt_length; uint8_t *salt; ldns_rdf *sname = NULL, *hashed_sname = NULL; size_t nsec_i; ldns_rr *nsec; ldns_rr *result = NULL; const ldns_rr_descriptor *descriptor; ldns_rdf *zone_name = NULL; if (verbosity >= 4) { printf(";; finding exact match for "); descriptor = ldns_rr_descript(qtype); if (descriptor && descriptor->_name) { printf("%s ", descriptor->_name); } else { printf("TYPE%d ", qtype); } ldns_rdf_print(stdout, qname); printf("\n"); } if (!qname || !nsec3s || ldns_rr_list_rr_count(nsec3s) < 1) { if (verbosity >= 4) { printf("no qname, nsec3s or list empty\n"); } return NULL; } nsec = ldns_rr_list_rr(nsec3s, 0); algorithm = ldns_nsec3_algorithm(nsec); salt_length = ldns_nsec3_salt_length(nsec); salt = ldns_nsec3_salt_data(nsec); iterations = ldns_nsec3_iterations(nsec); if (salt == NULL) { goto done; } sname = ldns_rdf_clone(qname); if (sname == NULL) { goto done; } if (verbosity >= 4) { printf(";; owner name hashes to: "); } hashed_sname = ldns_nsec3_hash_name(sname, algorithm, iterations, salt_length, salt); if (hashed_sname == NULL) { goto done; } zone_name = ldns_dname_left_chop(ldns_rr_owner(nsec)); if (zone_name == NULL) { goto done; } if (ldns_dname_cat(hashed_sname, zone_name) != LDNS_STATUS_OK) { goto done; }; if (verbosity >= 4) { ldns_rdf_print(stdout, hashed_sname); printf("\n"); } for (nsec_i = 0; nsec_i < ldns_rr_list_rr_count(nsec3s); nsec_i++) { nsec = ldns_rr_list_rr(nsec3s, nsec_i); /* check values of iterations etc! */ /* exact match? */ if (ldns_dname_compare(ldns_rr_owner(nsec), hashed_sname) == 0) { result = nsec; goto done; } } done: ldns_rdf_deep_free(zone_name); ldns_rdf_deep_free(sname); ldns_rdf_deep_free(hashed_sname); LDNS_FREE(salt); if (verbosity >= 4) { if (result) { printf(";; Found.\n"); } else { printf(";; Not foud.\n"); } } return result; } /*return the owner name of the closest encloser for name from the list of rrs */ /* this is NOT the hash, but the original name! */ ldns_rdf * ldns_nsec3_closest_encloser(ldns_rdf *qname, ldns_rr_type qtype, ldns_rr_list *nsec3s) { /* remember parameters, they must match */ uint8_t algorithm; uint32_t iterations; uint8_t salt_length; uint8_t *salt; ldns_rdf *sname = NULL, *hashed_sname = NULL, *tmp; bool flag; bool exact_match_found; bool in_range_found; ldns_rdf *zone_name = NULL; size_t nsec_i; ldns_rr *nsec; ldns_rdf *result = NULL; if (!qname || !nsec3s || ldns_rr_list_rr_count(nsec3s) < 1) { return NULL; } if (verbosity >= 4) { printf(";; finding closest encloser for type %d ", qtype); ldns_rdf_print(stdout, qname); printf("\n"); } nsec = ldns_rr_list_rr(nsec3s, 0); algorithm = ldns_nsec3_algorithm(nsec); salt_length = ldns_nsec3_salt_length(nsec); salt = ldns_nsec3_salt_data(nsec); iterations = ldns_nsec3_iterations(nsec); if (salt == NULL) { goto done; } sname = ldns_rdf_clone(qname); if (sname == NULL) { goto done; } flag = false; zone_name = ldns_dname_left_chop(ldns_rr_owner(nsec)); if (zone_name == NULL) { goto done; } /* algorithm from nsec3-07 8.3 */ while (ldns_dname_label_count(sname) > 0) { exact_match_found = false; in_range_found = false; if (verbosity >= 3) { printf(";; "); ldns_rdf_print(stdout, sname); printf(" hashes to: "); } hashed_sname = ldns_nsec3_hash_name(sname, algorithm, iterations, salt_length, salt); if (hashed_sname == NULL) { goto done; } if (ldns_dname_cat(hashed_sname, zone_name) != LDNS_STATUS_OK){ ldns_rdf_deep_free(hashed_sname); goto done; } if (verbosity >= 3) { ldns_rdf_print(stdout, hashed_sname); printf("\n"); } for (nsec_i = 0; nsec_i < ldns_rr_list_rr_count(nsec3s); nsec_i++) { nsec = ldns_rr_list_rr(nsec3s, nsec_i); /* check values of iterations etc! */ /* exact match? */ if (ldns_dname_compare(ldns_rr_owner(nsec), hashed_sname) == 0) { if (verbosity >= 4) { printf(";; exact match found\n"); } exact_match_found = true; } else if (ldns_nsec_covers_name(nsec, hashed_sname)) { if (verbosity >= 4) { printf(";; in range of an nsec\n"); } in_range_found = true; } } if (!exact_match_found && in_range_found) { flag = true; } else if (exact_match_found && flag) { result = ldns_rdf_clone(sname); } else if (exact_match_found && !flag) { // error! if (verbosity >= 4) { printf(";; the closest encloser is the same name (ie. this is an exact match, ie there is no closest encloser)\n"); } ldns_rdf_deep_free(hashed_sname); goto done; } else { flag = false; } ldns_rdf_deep_free(hashed_sname); tmp = sname; sname = ldns_dname_left_chop(sname); ldns_rdf_deep_free(tmp); if (sname == NULL) { goto done; } } done: LDNS_FREE(salt); ldns_rdf_deep_free(zone_name); ldns_rdf_deep_free(sname); if (!result) { if (verbosity >= 4) { printf(";; no closest encloser found\n"); } } /* todo checks from end of 6.2. here or in caller? */ return result; } ldns-1.9.2/drill/drill.1.in0000664000175000017500000001454515212267520014747 0ustar willemwillem.\" @(#)drill.1 1.7.0 14-Jul-2004 OF; .TH drill 1 "28 May 2006" .SH NAME drill \- get (debug) information out of DNS(SEC) .SH SYNOPSIS .B drill [ .IR OPTIONS ] .IR name [ .IR @server ] [ .IR type ] [ .IR class ] .SH DESCRIPTION \fBdrill\fR is a tool designed to get all sorts of information out of the DNS. It is specifically designed to be used with DNSSEC. .PP The name \fBdrill\fR is a pun on \fBdig\fR. With \fBdrill\fR you should be able get even more information than with \fBdig\fR. .PP If no arguments are given class defaults to 'IN' and type to 'A'. The server(s) specified in /etc/resolv.conf are used to query against. .PP \fIname\fR Ask for this name. .PP \fI@server\fR Send to query to this server. If not specified use the nameservers from \fI/etc/resolv.conf\fR. .PP \fItype\fR Ask for this RR type. If type is not given on the command line it defaults to 'A'. Except when doing a reverse lookup when it defaults to 'PTR'. .PP \fIclass\fR Use this class when querying. .SH SAMPLE USAGE \fBdrill mx miek.nl\fR Show the MX records of the domain miek.nl .TP \fBdrill \-S jelte.nlnetlabs.nl\fR Chase any signatures in the jelte.nlnetlab.nl domain. This option is only available when ldns has been compiled with openssl-support. .TP \fBdrill \-TD www.example.com\fR Do a DNSSEC (\-D) trace (\-T) from the rootservers down to www.example.com. This option only works when ldns has been compiled with openssl support. .TP \fBdrill \-s dnskey jelte.nlnetlabs.nl\fR Show the DNSKEY record(s) for jelte.nlnetlabs.nl. For each found DNSKEY record also print the DS record. .SH OPTIONS .TP \fB\-D Enable DNSSEC in the query. When querying for DNSSEC types (DNSKEY, RRSIG, DS and NSEC) this is \fInot\fR automatically enabled. .TP \fB\-T Trace \fIname\fR from the root down. When using this option the @server arguments is not used. .TP \fB\-S Chase the signature(s) of 'name' to a known key or as high up in the tree as possible. .TP \fB\-I \fIIPv4 or IPv6 address\fR Source address to query from. The source address has to be present on an interface of the host running drill. .TP \fB\-V \fIlevel\fR Be more verbose. Set level to 5 to see the actual query that is sent. .TP \fB\-Q Quiet mode, this overrules \-V. .TP \fB\-f \fIfile\fR Read the query from a file. The query must be dumped with \-w. .TP \fB\-i \fIfile\fR read the answer from the file instead from the network. This aids in debugging and can be used to check if a query on disk is valid. If the file contains binary data it is assumed to be a query in network order. .TP \fB\-w \fIfile\fR Write an answer packet to file. .TP \fB\-q \fIfile\fR Write the query packet to file. .TP \fB\-v Show drill's version. .TP \fB\-h Show a short help message. .SS QUERY OPTIONS .TP \fB\-4 Stay on ip4. Only send queries to ip4 enabled nameservers. .TP \fB\-6 Stay on ip6. Only send queries to ip6 enabled nameservers. .TP \fB\-a Use the resolver structure's fallback mechanism if the answer is truncated (TC=1). If a truncated packet is received and this option is set, drill will first send a new query with EDNS0 buffer size 4096. If the EDNS0 buffer size was already set to 512+ bytes, or the above retry also results in a truncated answer, the resolver structure will fall back to TCP. .TP \fB\-b \fIsize\fR Use size as the buffer size in the EDNS0 pseudo RR. .TP \fB\-c \fIfile\fR Use file instead of /etc/resolv.conf for nameserver configuration. .TP \fB\-d \fIdomain\fR When tracing (\-T), start from this domain instead of the root. .TP \fB\-t Use TCP/IP when querying a server .TP \fB\-k \fIkeyfile\fR Use this file to read a (trusted) key from. When this options is given \fBdrill\fR tries to validate the current answer with this key. No chasing is done. When \fBdrill\fR is doing a secure trace, this key will be used as trust anchor. Can contain a DNSKEY or a DS record. Alternatively, when DNSSEC enabled tracing (\fB-TD\fR) or signature chasing (\fB-S\fR), if \fB-k\fR is not specified, and a default trust anchor (@LDNS_TRUST_ANCHOR_FILE@) exists and contains a valid DNSKEY or DS record, it will be used as the trust anchor. .TP \fB\-o \fImnemonic\fR Use this option to set or unset specific header bits. A bit is set by using the bit mnemonic in CAPITAL letters. A bit is unset when the mnemonic is given in lowercase. The following mnemonics are understood by \fBdrill\fR: QR, qr: set, unset QueRy (default: on) AA, aa: set, unset Authoritative Answer (default: off) TC, tc: set, unset TrunCated (default: off) RD, rd: set, unset Recursion Desired (default: on) CD, cd: set, unset Checking Disabled (default: off) RA, ra: set, unset Recursion Available (default: off) AD, ad: set, unset Authenticated Data (default: off) Thus: \fB-o CD\fR, will enable Checking Disabled, which instructs the cache to not validate the answers it gives out. .TP \fB\-p \fIport\fR Use this port instead of the default of 53. .TP \fB\-r \fIfile\fR When tracing (\-T), use file as a root servers hint file. .TP \fB\-s When encountering a DNSKEY print the equivalent DS also. .TP \fB\-u Use UDP when querying a server. This is the default. .TP \fB\-w \fIfile\fR write the answer to a file. The file will contain a hexadecimal dump of the query. This can be used in conjunction with \-f. .TP \fB\-x Do a reverse lookup. The type argument is not used, it is preset to PTR. .TP \fB\-y \fI\fR specify named base64 tsig key, and optional an algorithm (defaults to hmac-md5.sig-alg.reg.int) .TP \fB\-z \fR don't randomize the nameserver list before sending queries. .SS EDNS QUERY OPTIONS .TP \fB\+nsid \fR When set, this EDNS option includes an EDNS name server ID request in the query. .SH "EXIT STATUS" The exit status is 0 if the looked up answer is secure and trusted, or insecure. The exit status is not 0 if the looked up answer is untrusted or bogus, or an error occurred while performing the lookup. .SH "FILES" .TP @LDNS_TRUST_ANCHOR_FILE@ The file from which trusted keys are loaded when no \fB-k\fR option is given. .SH "SEE ALSO" .LP unbound-anchor(8) .SH AUTHOR Jelte Jansen and Miek Gieben. Both of NLnet Labs. .SH REPORTING BUGS Report bugs to . .SH BUGS .SH COPYRIGHT Copyright (c) 2004-2008 NLnet Labs. Licensed under the revised BSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. .SH SEE ALSO \fBdig\fR(1), \fIRFC403{3,4,5}\fR. ldns-1.9.2/drill/REGRESSIONS0000664000175000017500000000156215212267520014673 0ustar willemwillemREGRESSIONS This version of drill is based on ldns and as such some things are slightly changed. This file documents the changes. o When tracing (-T option) we use the local resolver (as specified in /etc/resolv.conf) to lookup names. This increases the speed dramatically, but you obviously need to be able to reach a recursive server/cache. Previously drill would try to resolve the names by itself. o Printing of DSs after DNSKEY records. Because we don't parse our own packets anymore, we cannot print the DS directly after the DNSKEY record. The DSs are now printed AFTER the packet. o The long options are removed. o The chase function has a different output, and will be subject to change in the near future. o The useless (for jokes only) -I option was dropped. FIXED: o the argument parsing is much smarter, the order doesn't matter (much) anymore ldns-1.9.2/drill/work.c0000664000175000017500000001175015212267520014273 0ustar willemwillem/* * work.c * Where all the hard work is done * (c) 2005 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include /** * Converts a hex string to binary data * len is the length of the string * buf is the buffer to store the result in * offset is the starting position in the result buffer * * This function returns the length of the result */ static size_t hexstr2bin(char *hexstr, int len, uint8_t *buf, size_t offset, size_t buf_len) { char c; int i; uint8_t int8 = 0; int sec = 0; size_t bufpos = 0; if (len % 2 != 0) { return 0; } for (i=0; i= '0' && c <= '9') { int8 += c & 0x0f; } else if (c >= 'a' && c <= 'z') { int8 += (c & 0x0f) + 9; } else if (c >= 'A' && c <= 'Z') { int8 += (c & 0x0f) + 9; } else { return 0; } if (sec == 0) { int8 = int8 << 4; sec = 1; } else { if (bufpos + offset + 1 <= buf_len) { buf[bufpos+offset] = int8; int8 = 0; sec = 0; bufpos++; } else { error("Buffer too small in hexstr2bin"); } } } } return bufpos; } static size_t packetbuffromfile(char *filename, uint8_t *wire) { FILE *fp = NULL; int c; /* stat hack * 0 = normal * 1 = comment (skip to end of line) * 2 = unprintable character found, read binary data directly */ int state = 0; uint8_t *hexbuf = xmalloc(LDNS_MAX_PACKETLEN); int hexbufpos = 0; size_t wirelen; if (strncmp(filename, "-", 2) == 0) { fp = stdin; } else { fp = fopen(filename, "r"); } if (fp == NULL) { perror("Unable to open file for reading"); xfree(hexbuf); return 0; } /*verbose("Opened %s\n", filename);*/ c = fgetc(fp); while (c != EOF && hexbufpos < LDNS_MAX_PACKETLEN) { if (state < 2 && !isascii(c)) { /*verbose("non ascii character found in file: (%d) switching to raw mode\n", c);*/ state = 2; } switch (state) { case 0: if ( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') ) { hexbuf[hexbufpos] = (uint8_t) c; hexbufpos++; } else if (c == ';') { state = 1; } else if (c == ' ' || c == '\t' || c == '\n') { /* skip whitespace */ } break; case 1: if (c == '\n' || c == EOF) { state = 0; } break; case 2: hexbuf[hexbufpos] = (uint8_t) c; hexbufpos++; break; } c = fgetc(fp); } if (c == EOF) { /* if (have_drill_opt && drill_opt->verbose) { verbose("END OF FILE REACHED\n"); if (state < 2) { verbose("read:\n"); verbose("%s\n", hexbuf); } else { verbose("Not printing wire because it contains non ascii data\n"); } } */ } if (hexbufpos >= LDNS_MAX_PACKETLEN) { /*verbose("packet size reached\n");*/ } /* lenient mode: length must be multiple of 2 */ if (hexbufpos % 2 != 0) { hexbuf[hexbufpos] = (uint8_t) '0'; hexbufpos++; } if (state < 2) { wirelen = hexstr2bin((char *) hexbuf, hexbufpos, wire, 0, LDNS_MAX_PACKETLEN); } else { memcpy(wire, hexbuf, (size_t) hexbufpos); wirelen = (size_t) hexbufpos; } if (fp != stdin) { fclose(fp); } xfree(hexbuf); return wirelen; } ldns_buffer * read_hex_buffer(char *filename) { uint8_t *wire; size_t wiresize; ldns_buffer *result_buffer = NULL; wire = xmalloc(LDNS_MAX_PACKETLEN); wiresize = packetbuffromfile(filename, wire); result_buffer = LDNS_MALLOC(ldns_buffer); ldns_buffer_new_frm_data(result_buffer, wire, wiresize); ldns_buffer_set_position(result_buffer, ldns_buffer_capacity(result_buffer)); xfree(wire); return result_buffer; } ldns_pkt * read_hex_pkt(char *filename) { uint8_t *wire; size_t wiresize; ldns_pkt *pkt = NULL; ldns_status status = LDNS_STATUS_ERR; wire = xmalloc(LDNS_MAX_PACKETLEN); wiresize = packetbuffromfile(filename, wire); if (wiresize > 0) { status = ldns_wire2pkt(&pkt, wire, wiresize); } xfree(wire); if (status == LDNS_STATUS_OK) { return pkt; } else { fprintf(stderr, "Error parsing hex file: %s\n", ldns_get_errorstr_by_id(status)); return NULL; } } void dump_hex(const ldns_pkt *pkt, const char *filename) { uint8_t *wire = NULL; size_t size, i; FILE *fp; ldns_status status; fp = fopen(filename, "w"); if (fp == NULL) { error("Unable to open %s for writing", filename); return; } status = ldns_pkt2wire(&wire, pkt, &size); if (status != LDNS_STATUS_OK) { error("Unable to convert packet: error code %u", status); LDNS_FREE(wire); fclose(fp); return; } fprintf(fp, "; 0"); for (i = 1; i < 20; i++) { fprintf(fp, " %2u", (unsigned int) i); } fprintf(fp, "\n"); fprintf(fp, ";--"); for (i = 1; i < 20; i++) { fprintf(fp, " --"); } fprintf(fp, "\n"); for (i = 0; i < size; i++) { if (i % 20 == 0 && i > 0) { fprintf(fp, "\t;\t%4u-%4u\n", (unsigned int) i-19, (unsigned int) i); } fprintf(fp, " %02x", (unsigned int)wire[i]); } fprintf(fp, "\n"); fclose(fp); LDNS_FREE(wire); } ldns-1.9.2/drill/drill_util.c0000664000175000017500000001545615212267520015463 0ustar willemwillem/* * util.c * some handy function needed in drill and not implemented * in ldns * (c) 2005 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include #include static int read_line(FILE *input, char *line, size_t len) { int i; int c; for (i = 0; i < (int)len-1; i++) { c = getc(input); if (c == EOF) { return -1; } else if (c != '\n') { line[i] = c; } else { break; } } line[i] = '\0'; return i; } /* key_list must be initialized with ldns_rr_list_new() */ ldns_status read_key_file(const char *filename, ldns_rr_list *key_list, bool silently) { int line_len = 0; int line_nr = 0; int key_count = 0; char line[LDNS_MAX_LINELEN]; ldns_status status; FILE *input_file; ldns_rr *rr; input_file = fopen(filename, "r"); if (!input_file) { if (! silently) { fprintf(stderr, "Error opening %s: %s\n", filename, strerror(errno)); } return LDNS_STATUS_ERR; } while (line_len >= 0) { line_len = (int) read_line(input_file, line, sizeof(line)); line_nr++; if (line_len > 0 && line[0] != ';') { status = ldns_rr_new_frm_str(&rr, line, 0, NULL, NULL); if (status != LDNS_STATUS_OK) { if (! silently) { fprintf(stderr, "Error parsing DNSKEY RR " "in line %d: %s\n", line_nr, ldns_get_errorstr_by_id(status) ); } } else if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_DNSKEY || ldns_rr_get_type(rr) == LDNS_RR_TYPE_DS) { ldns_rr_list_push_rr(key_list, rr); key_count++; } else { ldns_rr_free(rr); } } } fclose(input_file); if (key_count > 0) { return LDNS_STATUS_OK; } else { /*fprintf(stderr, "No keys read\n");*/ return LDNS_STATUS_ERR; } } ldns_rdf * ldns_rdf_new_addr_frm_str(char *str) { ldns_rdf *a; a = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_A, str); if (!a) { /* maybe ip6 */ a = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_AAAA, str); if (!a) { return NULL; } } return a; } static inline void local_print_ds(FILE* out, const char* pre, ldns_rr* ds) { if (out && ds) { fprintf(out, "%s", pre); ldns_rr_print(out, ds); ldns_rr_free(ds); } } /* * For all keys in a packet print the DS */ void print_ds_of_keys(ldns_pkt *p) { ldns_rr_list *keys; uint16_t i; ldns_rr *ds; /* TODO fix the section stuff, here or in ldns */ keys = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_DNSKEY, LDNS_SECTION_ANSWER); /* this also returns the question section rr, which does not * have any data.... and this inturn crashes everything */ if (keys) { for (i = 0; i < ldns_rr_list_rr_count(keys); i++) { fprintf(stdout, ";\n; equivalent DS records for key %u:\n", (unsigned int)ldns_calc_keytag(ldns_rr_list_rr(keys, i))); ds = ldns_key_rr2ds(ldns_rr_list_rr(keys, i), LDNS_SHA1); local_print_ds(stdout, "; sha1: ", ds); ds = ldns_key_rr2ds(ldns_rr_list_rr(keys, i), LDNS_SHA256); local_print_ds(stdout, "; sha256: ", ds); } ldns_rr_list_deep_free(keys); } } static void print_class_type(FILE *fp, ldns_rr *r) { ldns_lookup_table *lt; lt = ldns_lookup_by_id(ldns_rr_classes, ldns_rr_get_class(r)); if (lt) { fprintf(fp, " %s", lt->name); } else { fprintf(fp, " CLASS%d", ldns_rr_get_class(r)); } /* okay not THE way - but the quickest */ switch (ldns_rr_get_type(r)) { case LDNS_RR_TYPE_RRSIG: fprintf(fp, " RRSIG "); break; case LDNS_RR_TYPE_DNSKEY: fprintf(fp, " DNSKEY "); break; case LDNS_RR_TYPE_DS: fprintf(fp, " DS "); break; default: break; } } void print_ds_abbr(FILE *fp, ldns_rr *ds) { if (!ds || (ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS)) { return; } ldns_rdf_print(fp, ldns_rr_owner(ds)); fprintf(fp, " %d", (int)ldns_rr_ttl(ds)); print_class_type(fp, ds); ldns_rdf_print(fp, ldns_rr_rdf(ds, 0)); fprintf(fp, " "); ldns_rdf_print(fp, ldns_rr_rdf(ds, 1)); fprintf(fp, " "); ldns_rdf_print(fp, ldns_rr_rdf(ds, 2)); fprintf(fp, " "); ldns_rdf_print(fp, ldns_rr_rdf(ds, 3)); fprintf(fp, " "); } /* print some of the elements of a signature */ void print_rrsig_abbr(FILE *fp, ldns_rr *sig) { if (!sig || (ldns_rr_get_type(sig) != LDNS_RR_TYPE_RRSIG)) { return; } ldns_rdf_print(fp, ldns_rr_owner(sig)); fprintf(fp, " %d", (int)ldns_rr_ttl(sig)); print_class_type(fp, sig); /* print a number of rdf's */ /* typecovered */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 0)); fprintf(fp, " "); /* algo */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 1)); fprintf(fp, " "); /* labels */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 2)); fprintf(fp, " (\n\t\t\t"); /* expir */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 4)); fprintf(fp, " "); /* incep */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 5)); fprintf(fp, " "); /* key-id */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 6)); fprintf(fp, " "); /* key owner */ ldns_rdf_print(fp, ldns_rr_rdf(sig, 7)); fprintf(fp, ")"); } void print_dnskey_abbr(FILE *fp, ldns_rr *key) { if (!key || (ldns_rr_get_type(key) != LDNS_RR_TYPE_DNSKEY)) { return; } ldns_rdf_print(fp, ldns_rr_owner(key)); fprintf(fp, " %d", (int)ldns_rr_ttl(key)); print_class_type(fp, key); /* print a number of rdf's */ /* flags */ ldns_rdf_print(fp, ldns_rr_rdf(key, 0)); fprintf(fp, " "); /* proto */ ldns_rdf_print(fp, ldns_rr_rdf(key, 1)); fprintf(fp, " "); /* algo */ ldns_rdf_print(fp, ldns_rr_rdf(key, 2)); if (ldns_rdf2native_int16(ldns_rr_rdf(key, 0)) == 256) { fprintf(fp, " ;{id = %u (zsk), size = %db}", (unsigned int)ldns_calc_keytag(key), (int)ldns_rr_dnskey_key_size(key)); return; } if (ldns_rdf2native_int16(ldns_rr_rdf(key, 0)) == 257) { fprintf(fp, " ;{id = %u (ksk), size = %db}", (unsigned int)ldns_calc_keytag(key), (int)ldns_rr_dnskey_key_size(key)); return; } fprintf(fp, " ;{id = %u, size = %db}", (unsigned int)ldns_calc_keytag(key), (int)ldns_rr_dnskey_key_size(key)); } void print_rr_list_abbr(FILE *fp, ldns_rr_list *rrlist, const char *usr) { size_t i; ldns_rr_type tp; for(i = 0; i < ldns_rr_list_rr_count(rrlist); i++) { tp = ldns_rr_get_type(ldns_rr_list_rr(rrlist, i)); if (i == 0 && tp != LDNS_RR_TYPE_RRSIG) { if (usr) { fprintf(fp, "%s ", usr); } } switch(tp) { case LDNS_RR_TYPE_DNSKEY: print_dnskey_abbr(fp, ldns_rr_list_rr(rrlist, i)); break; case LDNS_RR_TYPE_RRSIG: print_rrsig_abbr(fp, ldns_rr_list_rr(rrlist, i)); break; case LDNS_RR_TYPE_DS: print_ds_abbr(fp, ldns_rr_list_rr(rrlist, i)); break; default: /* not handled */ break; } fputs("\n", fp); } } void * xmalloc(size_t s) { void *p; p = malloc(s); if (!p) { printf("Mem failure\n"); exit(EXIT_FAILURE); } return p; } void * xrealloc(void *p, size_t size) { void *q; q = realloc(p, size); if (!q) { printf("Mem failure\n"); exit(EXIT_FAILURE); } return q; } void xfree(void *p) { if (p) { free(p); } } ldns-1.9.2/drill/install-sh0000775000175000017500000003253715212267520015157 0ustar willemwillem#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: ldns-1.9.2/drill/error.c0000664000175000017500000000247315212267520014444 0ustar willemwillem/** * error.c * * error reporting routines * basically wrappers around printf * * (c) 2005 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include static void warning_va_list(const char *fmt, va_list args) { fprintf(stderr, "Warning: "); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); } void warning(const char *fmt, ...) { va_list args; va_start(args, fmt); warning_va_list(fmt, args); va_end(args); } static void error_va_list(const char *fmt, va_list args) { fprintf(stderr, "Error: "); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); } void error(const char *fmt, ...) { va_list args; va_start(args, fmt); error_va_list(fmt, args); va_end(args); exit(EXIT_FAILURE); } static void verbose_va_list(const char *fmt, va_list args) { vfprintf(stdout, fmt, args); fprintf(stdout, "\n"); } /* print stuff */ void mesg(const char *fmt, ...) { va_list args; if (verbosity == -1) { return; } fprintf(stdout, ";; "); va_start(args, fmt); verbose_va_list(fmt, args); va_end(args); } #if 0 /* print stuff when in verbose mode (1) */ void verbose(const char *fmt, ...) { va_list args; if (verbosity < 1) { return; } va_start(args, fmt); verbose_va_list(fmt, args); va_end(args); } #endif ldns-1.9.2/drill/drill.c0000664000175000017500000007200715212267520014421 0ustar willemwillem/* * drill.c * the main file of drill * (c) 2005-2008 NLnet Labs * * See the file LICENSE for the license * */ #include "drill.h" #include #ifdef HAVE_SSL #include #endif /* query debug, 2 hex dumps */ int verbosity; static int is_ixfr_with_serial(const char* name, uint32_t *serial) { char* end; if (strlen(name) > 5 && strncasecmp(name, "IXFR", 4) == 0 && name[4] == '=') { *serial = (uint32_t) strtol((name+5), &end, 10); return 1; } return 0; } static void usage(FILE *stream, const char *progname) { fprintf(stream, " Usage: %s name [@server] [type] [class]\n", progname); fprintf(stream, "\t can be a domain name or an IP address (-x lookups)\n"); fprintf(stream, "\t defaults to A\n"); fprintf(stream, "\t defaults to IN\n"); fprintf(stream, "\n\targuments may be placed in random order\n"); fprintf(stream, "\n Options:\n"); fprintf(stream, "\t-D\t\tenable DNSSEC (DO bit)\n"); #ifdef HAVE_SSL fprintf(stream, "\t-T\t\ttrace from the root down to \n"); fprintf(stream, "\t-S\t\tchase signature(s) from to a known key [*]\n"); #endif /*HAVE_SSL*/ fprintf(stream, "\t-I
\tsource address to query from\n"); fprintf(stream, "\t-V \tverbosity (0-5)\n"); fprintf(stream, "\t-Q\t\tquiet mode (overrules -V)\n"); fprintf(stream, "\n"); fprintf(stream, "\t-f file\t\tread packet from file and send it\n"); fprintf(stream, "\t-i file\t\tread packet from file and print it\n"); fprintf(stream, "\t-w file\t\twrite answer packet to file\n"); fprintf(stream, "\t-q file\t\twrite query packet to file\n"); fprintf(stream, "\t-h\t\tshow this help\n"); fprintf(stream, "\t-v\t\tshow version\n"); fprintf(stream, "\n Query options:\n"); fprintf(stream, "\t-4\t\tstay on ip4\n"); fprintf(stream, "\t-6\t\tstay on ip6\n"); fprintf(stream, "\t-a\t\tfallback to EDNS0 and TCP if the answer is truncated\n"); fprintf(stream, "\t-b \tuse as the buffer size (defaults to 512 b)\n"); fprintf(stream, "\t-c \tuse file for recursive nameserver configuration" "\n\t\t\t(/etc/resolv.conf)\n"); fprintf(stream, "\t-k \tspecify a file that contains a trusted DNSSEC key [**]\n"); fprintf(stream, "\t\t\tUsed to verify any signatures in the current answer.\n"); fprintf(stream, "\t\t\tWhen DNSSEC enabled tracing (-TD) or signature\n" "\t\t\tchasing (-S) and no key files are given, keys are read\n" "\t\t\tfrom: %s\n", LDNS_TRUST_ANCHOR_FILE); fprintf(stream, "\t-o \tset flags to:" "\n\t\t\t[QR|qr][AA|aa][TC|tc][RD|rd][CD|cd][RA|ra][AD|ad]\n"); fprintf(stream, "\t\t\tlowercase: unset bit, uppercase: set bit\n"); fprintf(stream, "\t-p \tuse as remote port number\n"); fprintf(stream, "\t-s\t\tshow the DS RR for each key in a packet\n"); fprintf(stream, "\t-u\t\tsend the query with udp (the default)\n"); fprintf(stream, "\t-x\t\tdo a reverse lookup\n"); fprintf(stream, "\twhen doing a secure trace:\n"); fprintf(stream, "\t-r \tuse file as root servers hint file\n"); fprintf(stream, "\t-t\t\tsend the query with tcp (connected)\n"); fprintf(stream, "\t-d \tuse domain as the start point for the trace\n"); fprintf(stream, "\t-y \tspecify named base64 tsig key, and optional an\n\t\t\talgorithm (defaults to hmac-md5.sig-alg.reg.int)\n"); fprintf(stream, "\t-z\t\tdon't randomize the nameservers before use\n"); fprintf(stream, "\n [*] = enables/implies DNSSEC\n"); fprintf(stream, " [**] = can be given more than once\n"); fprintf(stream, "\n dns-team@nlnetlabs.nl | http://www.nlnetlabs.nl/ldns/\n"); } /** * Prints the drill version to stderr */ static void version(FILE *stream, const char *progname) { fprintf(stream, "%s version %s (ldns version %s)\n", progname, DRILL_VERSION, ldns_version()); fprintf(stream, "Written by NLnet Labs.\n"); fprintf(stream, "\nCopyright (c) 2004-2008 NLnet Labs.\n"); fprintf(stream, "Licensed under the revised BSD license.\n"); fprintf(stream, "There is NO warranty; not even for MERCHANTABILITY or FITNESS\n"); fprintf(stream, "FOR A PARTICULAR PURPOSE.\n"); } /** * Main function of drill * parse the arguments and prepare a query */ int main(int argc, char *argv[]) { ldns_resolver *res = NULL; ldns_resolver *cmdline_res = NULL; /* only used to resolv @name names */ ldns_rr_list *cmdline_rr_list = NULL; ldns_rdf *cmdline_dname = NULL; ldns_rdf *qname; ldns_pkt *pkt; ldns_pkt *qpkt; char *serv; char *src = NULL; const char *name; char *progname; char *query_file = NULL; char *answer_file = NULL; ldns_buffer *query_buffer = NULL; ldns_rdf *serv_rdf; ldns_rdf *src_rdf = NULL; ldns_rr_type type; ldns_rr_class clas; #if 0 ldns_pkt_opcode opcode = LDNS_PACKET_QUERY; #endif int i, c; int int_type; int int_clas; int PURPOSE; char *tsig_name = NULL; char *tsig_data = NULL; char *tsig_algorithm = NULL; size_t tsig_separator; size_t tsig_separator2; ldns_rr *axfr_rr; ldns_status status; char *type_str; uint32_t serial = 0; /* list of keys used in dnssec operations */ ldns_rr_list *key_list = ldns_rr_list_new(); /* what key verify the current answer */ ldns_rr_list *key_verified; /* resolver options */ uint16_t qflags; uint16_t qbuf; uint16_t qport; uint8_t qfamily; bool qdnssec; bool qfallback; bool qds; bool qusevc; bool qrandom; bool drill_reverse = false; char *resolv_conf_file = NULL; ldns_rdf *trace_start_name = NULL; int result = 0; uint8_t s6addr[16]; char ip6_arpa_str[74]; uint8_t s4addr[4]; char in_addr_arpa_str[40]; #ifdef USE_WINSOCK int r; WSADATA wsa_data; #endif ldns_output_format_storage fmt_storage; ldns_output_format* fmt = ldns_output_format_init(&fmt_storage); int_type = -1; serv = NULL; type = 0; int_clas = -1; name = NULL; clas = 0; qname = NULL; src = NULL; progname = strdup(argv[0]); #ifdef USE_WINSOCK r = WSAStartup(MAKEWORD(2,2), &wsa_data); if(r != 0) { printf("Failed WSAStartup: %d\n", r); result = EXIT_FAILURE; goto exit; } #endif /* USE_WINSOCK */ PURPOSE = DRILL_QUERY; qflags = LDNS_RD; qport = LDNS_PORT; verbosity = 2; qdnssec = false; qfamily = LDNS_RESOLV_INETANY; qfallback = false; qds = false; qbuf = 0; qusevc = false; qrandom = true; key_verified = NULL; ldns_edns_option_list* edns_list = NULL; ldns_init_random(NULL, 0); /* string from orig drill: "i:w:I46Sk:TNp:b:DsvhVcuaq:f:xr" */ /* global first, query opt next, option with parm's last * and sorted */ /* "46DITSVQf:i:w:q:achuvxzy:so:p:b:k:" */ while ((c = getopt(argc, argv, "46ab:c:d:Df:hi:I:k:o:p:q:Qr:sStTuvV:w:xy:z")) != -1) { switch(c) { /* global options */ case '4': qfamily = LDNS_RESOLV_INET; break; case '6': qfamily = LDNS_RESOLV_INET6; break; case 'D': qdnssec = true; break; case 'I': src = optarg; break; case 'T': if (PURPOSE == DRILL_CHASE) { fprintf(stderr, "-T and -S cannot be used at the same time.\n"); exit(EXIT_FAILURE); } PURPOSE = DRILL_TRACE; break; #ifdef HAVE_SSL case 'S': if (PURPOSE == DRILL_TRACE) { fprintf(stderr, "-T and -S cannot be used at the same time.\n"); exit(EXIT_FAILURE); } PURPOSE = DRILL_CHASE; break; #endif /* HAVE_SSL */ case 'V': if (strtok(optarg, "0123456789") != NULL) { fprintf(stderr, "-V expects an number as an argument.\n"); exit(EXIT_FAILURE); } verbosity = atoi(optarg); break; case 'Q': fmt->flags |= LDNS_FMT_SHORT; verbosity = -1; break; case 'f': query_file = optarg; break; case 'i': answer_file = optarg; PURPOSE = DRILL_AFROMFILE; break; case 'w': answer_file = optarg; break; case 'q': query_file = optarg; PURPOSE = DRILL_QTOFILE; break; case 'r': if (global_dns_root) { fprintf(stderr, "There was already a series of root servers set\n"); exit(EXIT_FAILURE); } global_dns_root = read_root_hints(optarg); if (!global_dns_root) { fprintf(stderr, "Unable to read root hints file %s, aborting\n", optarg); exit(EXIT_FAILURE); } break; /* query options */ case 'a': qfallback = true; break; case 'b': qbuf = (uint16_t)atoi(optarg); if (qbuf == 0) { error("%s", " could not be converted"); } break; case 'c': resolv_conf_file = optarg; break; case 't': qusevc = true; break; case 'k': status = read_key_file(optarg, key_list, false); if (status != LDNS_STATUS_OK) { error("Could not parse the key file %s: %s", optarg, ldns_get_errorstr_by_id(status)); } qdnssec = true; /* enable that too */ break; case 'o': /* only looks at the first hit: capital=ON, lowercase=OFF*/ if (strstr(optarg, "QR")) { DRILL_ON(qflags, LDNS_QR); } if (strstr(optarg, "qr")) { DRILL_OFF(qflags, LDNS_QR); } if (strstr(optarg, "AA")) { DRILL_ON(qflags, LDNS_AA); } if (strstr(optarg, "aa")) { DRILL_OFF(qflags, LDNS_AA); } if (strstr(optarg, "TC")) { DRILL_ON(qflags, LDNS_TC); } if (strstr(optarg, "tc")) { DRILL_OFF(qflags, LDNS_TC); } if (strstr(optarg, "RD")) { DRILL_ON(qflags, LDNS_RD); } if (strstr(optarg, "rd")) { DRILL_OFF(qflags, LDNS_RD); } if (strstr(optarg, "CD")) { DRILL_ON(qflags, LDNS_CD); } if (strstr(optarg, "cd")) { DRILL_OFF(qflags, LDNS_CD); } if (strstr(optarg, "RA")) { DRILL_ON(qflags, LDNS_RA); } if (strstr(optarg, "ra")) { DRILL_OFF(qflags, LDNS_RA); } if (strstr(optarg, "AD")) { DRILL_ON(qflags, LDNS_AD); } if (strstr(optarg, "ad")) { DRILL_OFF(qflags, LDNS_AD); } break; case 'p': qport = (uint16_t)atoi(optarg); if (qport == 0) { error("%s", " could not be converted"); } break; case 's': qds = true; break; case 'u': qusevc = false; break; case 'v': version(stdout, progname); result = EXIT_SUCCESS; goto exit; case 'x': drill_reverse = true; break; case 'y': #ifdef HAVE_SSL if (strchr(optarg, ':')) { tsig_separator = (size_t) (strchr(optarg, ':') - optarg); if (tsig_algorithm) { free(tsig_algorithm); tsig_algorithm = NULL; } if (strchr(optarg + tsig_separator + 1, ':')) { tsig_separator2 = (size_t) (strchr(optarg + tsig_separator + 1, ':') - optarg); tsig_algorithm = xmalloc(strlen(optarg) - tsig_separator2); strncpy(tsig_algorithm, optarg + tsig_separator2 + 1, strlen(optarg) - tsig_separator2); tsig_algorithm[strlen(optarg) - tsig_separator2 - 1] = '\0'; } else { tsig_separator2 = strlen(optarg); tsig_algorithm = strdup("hmac-md5.sig-alg.reg.int"); } tsig_name = xmalloc(tsig_separator + 1); tsig_data = xmalloc(tsig_separator2 - tsig_separator); strncpy(tsig_name, optarg, tsig_separator); strncpy(tsig_data, optarg + tsig_separator + 1, tsig_separator2 - tsig_separator - 1); /* strncpy does not append \0 if source is longer than n */ tsig_name[tsig_separator] = '\0'; tsig_data[ tsig_separator2 - tsig_separator - 1] = '\0'; } #else fprintf(stderr, "TSIG requested, but SSL is not supported\n"); result = EXIT_FAILURE; goto exit; #endif /* HAVE_SSL */ break; case 'z': qrandom = false; break; case 'd': trace_start_name = ldns_dname_new_frm_str(optarg); if (!trace_start_name) { fprintf(stderr, "Unable to parse argument for -%c\n", c); result = EXIT_FAILURE; goto exit; } break; case 'h': version(stdout, progname); usage(stdout, progname); result = EXIT_SUCCESS; goto exit; break; default: fprintf(stderr, "Unknown argument: -%c, use -h to see usage\n", c); result = EXIT_FAILURE; goto exit; } } argc -= optind; argv += optind; if ((PURPOSE == DRILL_CHASE || (PURPOSE == DRILL_TRACE && qdnssec)) && ldns_rr_list_rr_count(key_list) == 0) { (void) read_key_file(LDNS_TRUST_ANCHOR_FILE, key_list, true); } if (ldns_rr_list_rr_count(key_list) > 0) { printf(";; Number of trusted keys: %d\n", (int) ldns_rr_list_rr_count(key_list)); } /* do a secure trace when requested */ if (PURPOSE == DRILL_TRACE && qdnssec) { #ifdef HAVE_SSL if (ldns_rr_list_rr_count(key_list) == 0) { warning("%s", "No trusted keys were given. Will not be able to verify authenticity!"); } PURPOSE = DRILL_SECTRACE; #else fprintf(stderr, "ldns has not been compiled with OpenSSL support. Secure trace not available\n"); exit(1); #endif /* HAVE_SSL */ } /* parse the arguments, with multiple arguments, the last argument * found is used */ for(i = 0; i < argc; i++) { /* if ^@ then it's a server */ if (argv[i][0] == '@') { if (strlen(argv[i]) == 1) { warning("%s", "No nameserver given"); exit(EXIT_FAILURE); } serv = argv[i] + 1; continue; } /* if ^+ then it's an EDNS option */ if (argv[i][0] == '+') { if (!strcmp(argv[i]+1, "nsid")) { ldns_edns_option *edns; edns_list = ldns_edns_option_list_new(); /* create NSID EDNS*/ edns = ldns_edns_new_from_data(LDNS_EDNS_NSID, 0, NULL); if (edns_list == NULL || edns == NULL) { error("EDNS option could not be allocated"); break; } if (!(ldns_edns_option_list_push(edns_list, edns))) { error("EDNS option NSID could not be attached"); break; } continue; } else { error("Unsupported argument after '+'"); break; } } /* if has a dot, it's a name */ if (strchr(argv[i], '.')) { name = argv[i]; continue; } /* if it matches a type, it's a type */ if (int_type == -1) { type = ldns_get_rr_type_by_name(argv[i]); if (type != 0) { int_type = 0; continue; } else if (is_ixfr_with_serial(argv[i], &serial)) { type = LDNS_RR_TYPE_IXFR; int_type = 0; continue; } } /* if it matches a class, it's a class */ if (int_clas == -1) { clas = ldns_get_rr_class_by_name(argv[i]); if (clas != 0) { int_clas = 0; continue; } } /* it all fails assume it's a name */ name = argv[i]; } /* act like dig and use for . NS */ if (!name) { name = "."; int_type = 0; type = LDNS_RR_TYPE_NS; } /* defaults if not given */ if (int_clas == -1) { clas = LDNS_RR_CLASS_IN; } if (int_type == -1) { if (!drill_reverse) { type = LDNS_RR_TYPE_A; } else { type = LDNS_RR_TYPE_PTR; } } if (!drill_reverse) ; /* pass */ else if (strchr(name, ':')) { /* ipv4 or ipv6 addr? */ if (!inet_pton(AF_INET6, name, &s6addr)) { error("Syntax error: cannot parse IPv6 address\n"); } (void) snprintf(ip6_arpa_str, sizeof(ip6_arpa_str), "%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa.", (unsigned int)(s6addr[15] & 0x0F), (unsigned int)(s6addr[15] >> 4), (unsigned int)(s6addr[14] & 0x0F), (unsigned int)(s6addr[14] >> 4), (unsigned int)(s6addr[13] & 0x0F), (unsigned int)(s6addr[13] >> 4), (unsigned int)(s6addr[12] & 0x0F), (unsigned int)(s6addr[12] >> 4), (unsigned int)(s6addr[11] & 0x0F), (unsigned int)(s6addr[11] >> 4), (unsigned int)(s6addr[10] & 0x0F), (unsigned int)(s6addr[10] >> 4), (unsigned int)(s6addr[9] & 0x0F), (unsigned int)(s6addr[9] >> 4), (unsigned int)(s6addr[8] & 0x0F), (unsigned int)(s6addr[8] >> 4), (unsigned int)(s6addr[7] & 0x0F), (unsigned int)(s6addr[7] >> 4), (unsigned int)(s6addr[6] & 0x0F), (unsigned int)(s6addr[6] >> 4), (unsigned int)(s6addr[5] & 0x0F), (unsigned int)(s6addr[5] >> 4), (unsigned int)(s6addr[4] & 0x0F), (unsigned int)(s6addr[4] >> 4), (unsigned int)(s6addr[3] & 0x0F), (unsigned int)(s6addr[3] >> 4), (unsigned int)(s6addr[2] & 0x0F), (unsigned int)(s6addr[2] >> 4), (unsigned int)(s6addr[1] & 0x0F), (unsigned int)(s6addr[1] >> 4), (unsigned int)(s6addr[0] & 0x0F), (unsigned int)(s6addr[0] >> 4)); name = ip6_arpa_str; } else if (!inet_pton(AF_INET, name, &s4addr)) { error("Syntax error: cannot parse IPv4 address\n"); } else { (void) snprintf(in_addr_arpa_str, sizeof(in_addr_arpa_str), "%d.%d.%d.%d.in-addr.arpa.", (int)s4addr[3], (int)s4addr[2], (int)s4addr[1], (int)s4addr[0]); name = in_addr_arpa_str; } if (src) { src_rdf = ldns_rdf_new_addr_frm_str(src); if(!src_rdf) { fprintf(stderr, "-I must be a valid IP[v6] address.\n"); exit(EXIT_FAILURE); } if (ldns_rdf_size(src_rdf) == 4) { qfamily = LDNS_RESOLV_INET; } else if (ldns_rdf_size(src_rdf) == 16) { qfamily = LDNS_RESOLV_INET6; } } /* set the nameserver to use */ if (!serv) { /* no server given -- make a resolver from /etc/resolv.conf */ status = ldns_resolver_new_frm_file(&res, resolv_conf_file); if (status != LDNS_STATUS_OK) { warning("Could not create a resolver structure: %s (%s)\n" "Try drill @localhost if you have a resolver running on your machine.", ldns_get_errorstr_by_id(status), resolv_conf_file); result = EXIT_FAILURE; goto exit; } } else { res = ldns_resolver_new(); if (!res || strlen(serv) <= 0) { warning("Could not create a resolver structure"); result = EXIT_FAILURE; goto exit; } /* add the nameserver */ serv_rdf = ldns_rdf_new_addr_frm_str(serv); if (!serv_rdf) { /* try to resolv the name if possible */ status = ldns_resolver_new_frm_file(&cmdline_res, resolv_conf_file); if (status != LDNS_STATUS_OK) { error("%s", "@server ip could not be converted"); } ldns_resolver_set_dnssec(cmdline_res, qdnssec); ldns_resolver_set_ip6(cmdline_res, qfamily); ldns_resolver_set_fallback(cmdline_res, qfallback); ldns_resolver_set_usevc(cmdline_res, qusevc); ldns_resolver_set_source(cmdline_res, src_rdf); cmdline_dname = ldns_dname_new_frm_str(serv); cmdline_rr_list = ldns_get_rr_list_addr_by_name( cmdline_res, cmdline_dname, LDNS_RR_CLASS_IN, qflags); ldns_rdf_deep_free(cmdline_dname); if (!cmdline_rr_list) { /* This error msg is not always accurate */ error("%s `%s\'", "could not find any address for the name:", serv); } else { if (ldns_resolver_push_nameserver_rr_list( res, cmdline_rr_list ) != LDNS_STATUS_OK) { error("%s", "pushing nameserver"); } } } else { if (ldns_resolver_push_nameserver(res, serv_rdf) != LDNS_STATUS_OK) { error("%s", "pushing nameserver"); } else { ldns_rdf_deep_free(serv_rdf); } } } /* set the resolver options */ ldns_resolver_set_ixfr_serial(res, serial); ldns_resolver_set_port(res, qport); ldns_resolver_set_source(res, src_rdf); if (verbosity >= 5) { ldns_resolver_set_debug(res, true); } else { ldns_resolver_set_debug(res, false); } ldns_resolver_set_dnssec(res, qdnssec); /* ldns_resolver_set_dnssec_cd(res, qdnssec);*/ ldns_resolver_set_ip6(res, qfamily); ldns_resolver_set_fallback(res, qfallback); ldns_resolver_set_usevc(res, qusevc); ldns_resolver_set_random(res, qrandom); if (qbuf != 0) { ldns_resolver_set_edns_udp_size(res, qbuf); } if (!name && PURPOSE != DRILL_AFROMFILE && !query_file ) { usage(stdout, progname); result = EXIT_FAILURE; goto exit; } if (tsig_name && tsig_data) { /* With dig TSIG keys are also specified with -y, * but format with drill is: -y * and with dig: -y [hmac:]name:key * * When we detect an unknown tsig algorithm in algo, * but a known algorithm in name, we cane assume dig * order was used. * * Following if statement is to anticipate and correct dig order */ if ( strcasecmp(tsig_algorithm, "hmac-md5.sig-alg.reg.int") && strcasecmp(tsig_algorithm, "hmac-md5") && strcasecmp(tsig_algorithm, "hmac-sha1") && strcasecmp(tsig_algorithm, "hmac-sha256") && ( strcasecmp(tsig_name, "hmac-md5.sig-alg.reg.int") == 0 || strcasecmp(tsig_name, "hmac-md5") == 0 || strcasecmp(tsig_name, "hmac-sha1") == 0 || strcasecmp(tsig_name, "hmac-sha256") == 0 )) { /* Roll options */ char *tmp_tsig_algorithm = tsig_name; tsig_name = tsig_data; tsig_data = tsig_algorithm; tsig_algorithm = tmp_tsig_algorithm; } if (strcasecmp(tsig_algorithm, "hmac-md5") == 0) { free(tsig_algorithm); tsig_algorithm = strdup("hmac-md5.sig-alg.reg.int"); } ldns_resolver_set_tsig_keyname(res, tsig_name); ldns_resolver_set_tsig_keydata(res, tsig_data); ldns_resolver_set_tsig_algorithm(res, tsig_algorithm); } /* main switching part of drill */ switch(PURPOSE) { case DRILL_TRACE: /* do a trace from the root down */ if (!global_dns_root) { init_root(); } qname = ldns_dname_new_frm_str(name); if (!qname) { error("%s", "parsing query name"); } /* don't care about return packet */ do_trace(res, qname, type, clas); clear_root(); break; case DRILL_SECTRACE: /* do a secure trace from the root down */ if (!global_dns_root) { init_root(); } qname = ldns_dname_new_frm_str(name); if (!qname) { error("%s", "making qname"); } /* don't care about return packet */ #ifdef HAVE_SSL result = do_secure_trace(res, qname, type, clas, key_list, trace_start_name); #endif /* HAVE_SSL */ clear_root(); break; case DRILL_CHASE: qname = ldns_dname_new_frm_str(name); if (!qname) { error("%s", "making qname"); } ldns_resolver_set_dnssec(res, true); ldns_resolver_set_dnssec_cd(res, true); /* set dnssec implies udp_size of 4096 */ ldns_resolver_set_edns_udp_size(res, 4096); pkt = NULL; status = ldns_resolver_query_status( &pkt, res, qname, type, clas, qflags); if (status != LDNS_STATUS_OK) { error("error sending query: %s", ldns_get_errorstr_by_id(status)); } if (!pkt) { if (status == LDNS_STATUS_OK) { error("%s", "error pkt sending"); } result = EXIT_FAILURE; } else { if (verbosity >= 3) { ldns_pkt_print(stdout, pkt); } if (!ldns_pkt_answer(pkt)) { mesg("No answer in packet"); } else { #ifdef HAVE_SSL ldns_resolver_set_dnssec_anchors(res, ldns_rr_list_clone(key_list)); result = do_chase(res, qname, type, clas, key_list, pkt, qflags, NULL); if (result == LDNS_STATUS_OK) { if (verbosity != -1) { mesg("Chase successful"); } result = 0; } else { if (verbosity != -1) { mesg("Chase failed."); } } #endif /* HAVE_SSL */ } ldns_pkt_free(pkt); } break; case DRILL_AFROMFILE: pkt = read_hex_pkt(answer_file); if (pkt) { if (verbosity != -1) { ldns_pkt_print(stdout, pkt); } ldns_pkt_free(pkt); } break; case DRILL_QTOFILE: qname = ldns_dname_new_frm_str(name); if (!qname) { error("%s", "making qname"); } status = ldns_resolver_prepare_query_pkt(&qpkt, res, qname, type, clas, qflags); if(status != LDNS_STATUS_OK) { error("%s", "making query: %s", ldns_get_errorstr_by_id(status)); } dump_hex(qpkt, query_file); ldns_pkt_free(qpkt); break; case DRILL_NSEC: break; case DRILL_QUERY: default: if (query_file) { /* this old way, the query packet needed to be parseable, but we want to be able to send mangled packets, so we need to do it directly */ #if 0 qpkt = read_hex_pkt(query_file); if (qpkt) { status = ldns_resolver_send_pkt(&pkt, res, qpkt); if (status != LDNS_STATUS_OK) { printf("Error: %s\n", ldns_get_errorstr_by_id(status)); exit(1); } } else { /* qpkt was bogus, reset pkt */ pkt = NULL; } #endif query_buffer = read_hex_buffer(query_file); if (query_buffer) { status = ldns_send_buffer(&pkt, res, query_buffer, NULL); ldns_buffer_free(query_buffer); if (status != LDNS_STATUS_OK) { fprintf(stderr, "Error: %s\n", ldns_get_errorstr_by_id(status)); exit(1); } } else { printf("NO BUFFER\n"); pkt = NULL; } } else { qname = ldns_dname_new_frm_str(name); if (!qname) { error("%s", "error in making qname"); } if (type == LDNS_RR_TYPE_AXFR) { status = ldns_axfr_start(res, qname, clas); if(status != LDNS_STATUS_OK) { error("Error starting axfr: %s", ldns_get_errorstr_by_id(status)); } axfr_rr = ldns_axfr_next(res); if(!axfr_rr) { fprintf(stderr, "AXFR failed.\n"); ldns_pkt_print(stdout, ldns_axfr_last_pkt(res)); goto exit; } while (axfr_rr) { if (verbosity != -1) { ldns_rr_print(stdout, axfr_rr); } ldns_rr_free(axfr_rr); axfr_rr = ldns_axfr_next(res); } goto exit; } else { /* create a packet and set the RD flag on it */ pkt = NULL; status = ldns_resolver_prepare_query_pkt(&qpkt, res, qname, type, clas, qflags); if(status != LDNS_STATUS_OK) { error("%s", "making query: %s", ldns_get_errorstr_by_id(status)); } if (edns_list) { /* attach the structed EDNS options */ ldns_pkt_set_edns_option_list(qpkt, edns_list); } status = ldns_resolver_send_pkt(&pkt, res, qpkt); ldns_pkt_free(qpkt); if (status != LDNS_STATUS_OK) { error("error sending query: %s" , ldns_get_errorstr_by_id( status)); } } } /* now handling the response message/packet */ if (!pkt) { mesg("No packet received"); result = EXIT_FAILURE; } else { ldns_pkt_print_fmt(stdout, fmt, pkt); if (verbosity != -1) { if (ldns_pkt_tc(pkt)) { fprintf(stdout, "\n;; WARNING: The answer packet was truncated; you might want to\n"); fprintf(stdout, ";; query again with TCP (-t argument), or EDNS0 (-b for buffer size)\n"); } } if (qds) { if (verbosity != -1) { print_ds_of_keys(pkt); printf("\n"); } } if (ldns_rr_list_rr_count(key_list) > 0) { /* -k's were given on the cmd line */ ldns_rr_list *rrset_verified; uint16_t key_count; rrset_verified = ldns_pkt_rr_list_by_name_and_type( pkt, qname, type, LDNS_SECTION_ANY_NOQUESTION); if (type == LDNS_RR_TYPE_ANY) { /* don't verify this */ break; } if (verbosity != -1) { printf("; "); ldns_rr_list_print(stdout, rrset_verified); } /* verify */ #ifdef HAVE_SSL key_verified = ldns_rr_list_new(); result = ldns_pkt_verify(pkt, type, qname, key_list, NULL, key_verified); if (result == LDNS_STATUS_ERR) { /* is the existence denied then? */ result = ldns_verify_denial(pkt, qname, type, NULL, NULL); if (result == LDNS_STATUS_OK) { if (verbosity != -1) { printf("Existence denied for "); ldns_rdf_print(stdout, qname); type_str = ldns_rr_type2str(type); printf("\t%s\n", type_str); LDNS_FREE(type_str); } } else { if (verbosity != -1) { printf("Bad data; RR for name and " "type not found or failed to " "verify, and denial of " "existence failed.\n"); } } } else if (result == LDNS_STATUS_OK) { for(key_count = 0; key_count < ldns_rr_list_rr_count(key_verified); key_count++) { if (verbosity != -1) { printf("; VALIDATED by id = %u, owner = ", (unsigned int)ldns_calc_keytag( ldns_rr_list_rr(key_verified, key_count))); ldns_rdf_print(stdout, ldns_rr_owner( ldns_rr_list_rr(key_list, key_count))); printf("\n"); } } } else { for(key_count = 0; key_count < ldns_rr_list_rr_count(key_list); key_count++) { if (verbosity != -1) { printf("; %s for id = %u, owner = ", ldns_get_errorstr_by_id(result), (unsigned int)ldns_calc_keytag( ldns_rr_list_rr(key_list, key_count))); ldns_rdf_print(stdout, ldns_rr_owner( ldns_rr_list_rr(key_list, key_count))); printf("\n"); } } } ldns_rr_list_free(key_verified); #else (void) key_count; #endif /* HAVE_SSL */ } if (answer_file) { dump_hex(pkt, answer_file); } ldns_pkt_free(pkt); } break; } exit: ldns_rdf_deep_free(qname); ldns_rdf_deep_free(src_rdf); ldns_resolver_deep_free(res); ldns_resolver_deep_free(cmdline_res); ldns_rr_list_deep_free(key_list); ldns_rr_list_deep_free(cmdline_rr_list); ldns_rdf_deep_free(trace_start_name); xfree(progname); xfree(tsig_name); xfree(tsig_data); xfree(tsig_algorithm); #ifdef HAVE_SSL #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(HAVE_LIBRESSL) #ifdef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA CRYPTO_cleanup_all_ex_data (); #endif #ifdef HAVE_ERR_FREE_STRINGS ERR_free_strings (); #endif #ifdef HAVE_EVP_CLEANUP EVP_cleanup (); #endif #endif #endif #ifdef USE_WINSOCK WSACleanup(); #endif return result; } ldns-1.9.2/README.snapshots0000664000175000017500000000037515212267520014741 0ustar willemwillemldns - snapshot releases Snapshot releases are not official released. They can be released to interested parties for development. Snapshots can be recognized from the date in the tar file name. They should not be used for packaging in distributions. ldns-1.9.2/libdns.doxygen.in0000664000175000017500000034037715212267520015330 0ustar willemwillem# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a double hash (##) is considered a comment and is placed in # front of the TAG it is preceding. # # All text after a single hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the configuration # file that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by # double-quotes, unless you are using Doxywizard) that should identify the # project for which the documentation is generated. This name is used in the # title of most generated pages and in a few other places. # The default value is: My Project. PROJECT_NAME = @PACKAGE_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. PROJECT_NUMBER = @PACKAGE_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. PROJECT_LOGO = @srcdir@/doc/images/LogoInGradientBar2-y100.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. OUTPUT_DIRECTORY = doc/ # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and # will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes # performance problems for the file system. # The default value is: NO. CREATE_SUBDIRS = NO # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode # U+3044. # The default value is: NO. ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, # Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English # The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all generated output in the proper direction. # Possible values are: None, LTR, RTL and Context. # The default value is: None. OUTPUT_TEXT_DIRECTION = None # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. # The default value is: YES. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief # description of a member or function before the detailed description # # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. # The default value is: YES. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator that is # used to form the text in various listings. Each string in this list, if found # as the leading text of the brief description, will be stripped from the text # and the result, after processing the whole list, is used as the annotated # text. Otherwise, the brief description is used as-is. If left blank, the # following values are used ($name is automatically replaced with the name of # the entity):The $name class, The $name widget, The $name file, is, provides, # specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # doxygen will generate a detailed section even if there is only a brief # description. # The default value is: NO. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. # The default value is: NO. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path # before files name in the file list and in the header files. If set to NO the # shortest path that makes the file name unique will be used # The default value is: YES. FULL_PATH_NAMES = YES # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand # part of the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the path to # strip. # # Note that you can specify absolute paths here, but also relative paths, which # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which # header file to include in order to use a class. If left blank only the name of # the header file containing the class definition is used. Otherwise one should # specify the list of include paths that are normally passed to the compiler # using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't # support long names like on DOS, Mac, or CD-ROM. # The default value is: NO. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the # first line (until the first dot) of a Javadoc-style comment as the brief # description. If set to NO, the Javadoc-style will behave just like regular Qt- # style comments (thus requiring an explicit @brief command for a brief # description.) # The default value is: NO. JAVADOC_AUTOBRIEF = YES # If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line # such as # /*************** # as being the beginning of a Javadoc-style comment "banner". If set to NO, the # Javadoc-style will behave just like regular comments and it will not be # interpreted by doxygen. # The default value is: NO. JAVADOC_BANNER = NO # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus # requiring an explicit \brief command for a brief description.) # The default value is: NO. QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a # multi-line C++ special comment block (i.e. a block of //! or /// comments) as # a brief description. This used to be the default behavior. The new default is # to treat a multi-line C++ comment block as a detailed description. Set this # tag to YES if you prefer the old behavior instead. # # Note that setting this tag to YES also means that rational rose comments are # not recognized any more. # The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO # By default Python docstrings are displayed as preformatted text and doxygen's # special commands cannot be used. By setting PYTHON_DOCSTRING to NO the # doxygen's special commands can be used and the contents of the docstring # documentation blocks is shown as doxygen documentation. # The default value is: YES. PYTHON_DOCSTRING = YES # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new # page for each member. If set to NO, the documentation of a member will be part # of the file/class/namespace that contains it. # The default value is: NO. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen # uses this value to replace tabs by spaces in code fragments. # Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that act as commands in # the documentation. An alias has the form: # name=value # For example adding # "sideeffect=@par Side Effects:\n" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines (in the resulting output). You can put ^^ in the value part of an # alias to insert a newline as if a physical newline was in the original file. # When you need a literal { or } or , in the value part of an alias you have to # escape them by means of a backslash (\), this can lead to conflicts with the # commands \{ and \} for these it is advised to use the version @{ and @} or use # a double escape (\\{ and \\}) ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all # members will be omitted, etc. # The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or # Python sources only. Doxygen will then generate output that is more tailored # for that language. For instance, namespaces will be presented as packages, # qualified scopes will look different, etc. # The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources. Doxygen will then generate output that is tailored for Fortran. # The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for VHDL. # The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice # sources only. Doxygen will then generate output that is more tailored for that # language. For instance, namespaces will be presented as modules, types will be # separated into more groups, etc. # The default value is: NO. OPTIMIZE_OUTPUT_SLICE = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, JavaScript, # Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # tries to guess whether the code is fixed or free formatted code, this is the # default for Fortran type files). For instance to make doxygen treat .inc files # as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. When specifying no_extension you should add # * to the FILE_PATTERNS. # # Note see also the list of default file extension mappings. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable # documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. # The default value is: YES. MARKDOWN_SUPPORT = YES # When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up # to that level are automatically included in the table of contents, even if # they do not have an id attribute. # Note: This feature currently applies only to Markdown headings. # Minimum value: 0, maximum value: 99, default value: 5. # This tag requires that the tag MARKDOWN_SUPPORT is set to YES. TOC_INCLUDE_HEADINGS = 5 # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. # The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should set this # tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); # versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. # The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. # The default value is: NO. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES will make # doxygen to replace the get and set methods by a property in the documentation. # This will only work if the methods are indeed getting or setting a simple # type. If this is not the case, or you want to show the methods anyway, you # should set this option to NO. # The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. # The default value is: NO. DISTRIBUTE_GROUP_DOC = NO # If one adds a struct or class to a group and this option is enabled, then also # any nested class or struct is added to the same group. By default this option # is disabled and one has to add nested compounds explicitly via \ingroup. # The default value is: NO. GROUP_NESTED_COMPOUNDS = NO # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent # subgrouping. Alternatively, this can be done per class using the # \nosubgrouping command. # The default value is: YES. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions # are shown inside the group in which they are included (e.g. using \ingroup) # instead of on a separate page (for HTML and Man pages) or section (for LaTeX # and RTF). # # Note that this feature does not work in combination with # SEPARATE_MEMBER_PAGES. # The default value is: NO. INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions # with only public data fields or simple typedef fields will be shown inline in # the documentation of the scope in which they are defined (i.e. file, # namespace, or group documentation), provided this scope is documented. If set # to NO, structs, classes, and unions are shown on a separate page (for HTML and # Man pages) or section (for LaTeX and RTF). # The default value is: NO. INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or # enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically be # useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. # The default value is: NO. TYPEDEF_HIDES_STRUCT = NO # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This # cache is used to resolve symbols given their name and scope. Since this can be # an expensive process and often the same symbol appears multiple times in the # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small # doxygen will become slower. If the cache is too large, memory is wasted. The # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 # symbols. At the end of a run doxygen will report the cache usage and suggest # the optimal cache size from a speed point of view. # Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 # The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use # during processing. When set to 0 doxygen will based this on the number of # cores available in the system. You can set it explicitly to a value larger # than 0 to get more control over the balance between CPU load and processing # speed. At this moment only the input processing can be done using multiple # threads. Since this is still an experimental feature the default is set to 1, # which efficively disables parallel processing. Please report any issues you # encounter. Generating dot graphs in parallel is controlled by the # DOT_NUM_THREADS setting. # Minimum value: 0, maximum value: 32, default value: 1. NUM_PROC_THREADS = 1 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in # documentation are documented, even if no documentation was available. Private # class members and static file members will be hidden unless the # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. # Note: This will also disable the warnings about undocumented members that are # normally produced when WARNINGS is set to YES. # The default value is: NO. EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. EXTRACT_PRIVATE = NO # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. # The default value is: NO. EXTRACT_PRIV_VIRTUAL = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES, all static members of a file will be # included in the documentation. # The default value is: NO. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, # only classes defined in header files are included. Does not have any effect # for Java sources. # The default value is: YES. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are # included in the documentation. If set to NO, only methods in the interface are # included. # The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base name of # the file that contains the anonymous namespace. By default anonymous namespace # are hidden. # The default value is: NO. EXTRACT_ANON_NSPACES = NO # If this flag is set to YES, the name of an unnamed parameter in a declaration # will be determined by the corresponding definition. By default unnamed # parameters remain unnamed in the output. # The default value is: YES. RESOLVE_UNNAMED_PARAMS = YES # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation # section is generated. This option has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option # has no effect if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend # declarations. If set to NO, these declarations will be included in the # documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any # documentation blocks found inside the body of a function. If set to NO, these # blocks will be appended to the function's detailed documentation block. # The default value is: NO. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation that is typed after a # \internal command is included. If the tag is set to NO then the documentation # will be excluded. Set it to YES to include the internal documentation. # The default value is: NO. INTERNAL_DOCS = NO # With the correct setting of option CASE_SENSE_NAMES doxygen will better be # able to match the capabilities of the underlying filesystem. In case the # filesystem is case sensitive (i.e. it supports files in the same directory # whose names only differ in casing), the option must be set to YES to properly # deal with such files in case they appear in the input. For filesystems that # are not case sensitive the option should be be set to NO to properly deal with # output files written for symbols that only differ in casing, such as for two # classes, one named CLASS and the other named Class, and to also support # references to files without having to specify the exact matching casing. On # Windows (including Cygwin) and MacOS, users should typically set this option # to NO, whereas on Linux or other Unix flavors it should typically be set to # YES. # The default value is: system dependent. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the # scope will be hidden. # The default value is: NO. HIDE_SCOPE_NAMES = NO # If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will # append additional text to a page's title, such as Class Reference. If set to # YES the compound reference will be hidden. # The default value is: NO. HIDE_COMPOUND_REFERENCE= NO # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. SHOW_INCLUDE_FILES = NO # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader # which file to include in order to use the member. # The default value is: NO. SHOW_GROUPED_MEMB_INC = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include # files with double quotes in the documentation rather than with sharp brackets. # The default value is: NO. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the # documentation for inline members. # The default value is: YES. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the # (detailed) documentation of file and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. # The default value is: YES. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief # descriptions of file, namespace and class members alphabetically by member # name. If set to NO, the members will appear in declaration order. Note that # this will also influence the order of the classes in the class list. # The default value is: NO. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the # (brief and detailed) documentation of class members so that constructors and # destructors are listed first. If set to NO the constructors will appear in the # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief # member documentation. # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting # detailed member documentation. # The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy # of group names into alphabetical order. If set to NO the group names will # appear in their defined order. # The default value is: NO. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will # be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the alphabetical # list. # The default value is: NO. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper # type resolution of all parameters of a function it will reject a match between # the prototype and the implementation of a member function even if there is # only one candidate or it is obvious which candidate to choose by doing a # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still # accept a match between prototype and implementation in such cases. # The default value is: NO. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo # list. This list is created by putting \todo commands in the documentation. # The default value is: YES. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test # list. This list is created by putting \test commands in the documentation. # The default value is: YES. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug # list. This list is created by putting \bug commands in the documentation. # The default value is: YES. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) # the deprecated list. This list is created by putting \deprecated commands in # the documentation. # The default value is: YES. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional documentation # sections, marked by \if ... \endif and \cond # ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the # documentation. If the initializer consists of more lines than specified here # it will be hidden. Use a value of 0 to hide initializers completely. The # appearance of the value of individual variables and macros / defines can be # controlled using \showinitializer or \hideinitializer command in the # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. # The default value is: YES. SHOW_USED_FILES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the # Folder Tree View (if specified). # The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command command input-file, where command is the value of the # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml # will be used as the name of the layout file. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool # to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated to # standard output by doxygen. If QUIET is set to YES this implies that the # messages are off. # The default value is: NO. QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are # generated to standard error (stderr) by doxygen. If WARNINGS is set to YES # this implies that the warnings are on. # # Tip: Turn warnings on while writing the documentation. # The default value is: YES. WARNINGS = YES # If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag # will automatically be disabled. # The default value is: YES. WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some parameters # in a documented function, or documenting parameters that don't exist or using # markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete # parameter documentation, but not about the absence of documentation. If # EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = NO # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when # a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS # then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but # at the end of the doxygen process doxygen will return with a non-zero status. # Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = NO # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) # The default value is: $file:$line: $text. WARN_FORMAT = "doxygen: $file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard # error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag is used to specify the files and/or directories that contain # documented source files. You may enter file names like myfile.cpp or # directories like /usr/src/myproject. Separate the files or directories with # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. INPUT = ldns/ \ @srcdir@/doc/ \ @srcdir@/examples/ldns-mx.c \ @srcdir@/examples/ldns-read-zone.c \ @srcdir@/examples/ldns-signzone.c \ @srcdir@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv # documentation (see: # https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # # Note the list of default checked file patterns might differ from the list of # default file extension mappings. # # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), # *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, # *.ucf, *.qsf and *.ice. FILE_PATTERNS = # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. # The default value is: NO. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. # The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). EXAMPLE_PATH = @srcdir@/examples # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and # *.h) to filter out the source-files in the directories. If left blank all # files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude commands # irrespective of the value of the RECURSIVE tag. # The default value is: NO. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or directories # that contain images that are to be included in the documentation (see the # \image command). IMAGE_PATH = @srcdir@/doc/images # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command: # # # # where is the value of the INPUT_FILTER tag, and is the # name of an input file. Doxygen will then use the output that the filter # program writes to standard output. If FILTER_PATTERNS is specified, this tag # will be ignored. # # Note that the filter must not add or remove lines; it is applied before the # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: pattern=filter # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how # filters are used. If the FILTER_PATTERNS tag is empty or if none of the # patterns match the file name, INPUT_FILTER is applied. # # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). # The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and # it is also possible to disable source filtering for a specific pattern using # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will be # generated. Documented entities will be cross-referenced with these sources. # # Note: To get rid of all source code in the generated output, make sure that # also VERBATIM_HEADERS is set to NO. # The default value is: NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. # The default value is: NO. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any # special comment blocks from generated source code fragments. Normal C, C++ and # Fortran comments will always remain visible. # The default value is: YES. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented # entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES then for each documented function # all documented entities called/used by that function will be listed. # The default value is: NO. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set # to YES then the hyperlinks from functions in REFERENCES_RELATION and # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will # link to the documentation. # The default value is: YES. REFERENCES_LINK_SOURCE = YES # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the # source code will show a tooltip with additional information such as prototype, # brief description and links to the definition and documentation. Since this # will make the HTML file larger and loading of large files a bit slower, you # can opt to disable this feature. # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system # (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global # - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # # Doxygen will invoke htags (and that will in turn invoke gtags), so these # tools must be available from the command line (i.e. in the search path). # # The result: instead of the source browser generated by doxygen, the links to # source code will now point to the output of htags. # The default value is: NO. # This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a # verbatim copy of the header file for each class for which an include is # specified. Set to NO to disable this. # See also: Section \class. # The default value is: YES. VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the # clang parser (see: # http://clang.llvm.org/) for more accurate parsing at the cost of reduced # performance. This can be particularly helpful with template rich C++ code for # which doxygen's built-in parser lacks the necessary type information. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. # The default value is: NO. CLANG_ASSISTED_PARSING = NO # If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to # YES then doxygen will add the directory of each input to the include path. # The default value is: YES. CLANG_ADD_INC_PATHS = YES # If clang assisted parsing is enabled you can provide the compiler with command # line options that you would normally use when invoking the compiler. Note that # the include paths will already be set by doxygen for the files and directories # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. CLANG_OPTIONS = # If clang assisted parsing is enabled you can provide the clang parser with the # path to the directory containing a file called compile_commands.json. This # file is the compilation database (see: # http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the # options used when the source files were built. This is equivalent to # specifying the -p option to a clang tool, such as clang-check. These options # will then be passed to the parser. Any options specified with CLANG_OPTIONS # will be added as well. # Note: The availability of this option depends on whether or not doxygen was # generated with the -Duse_libclang=ON option for CMake. CLANG_DATABASE_PATH = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all # compounds will be generated. Enable this if the project contains a lot of # classes, structs, unions or interfaces. # The default value is: YES. ALPHABETICAL_INDEX = YES # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = ldns_ #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of # it. # The default directory is: html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each # generated HTML page (for example: .htm, .php, .asp). # The default value is: .html. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a user-defined HTML header file for # each generated HTML page. If the tag is left blank doxygen will generate a # standard header. # # To get valid HTML the header file that includes any scripts and style sheets # that doxygen needs, which is dependent on the configuration options used (e.g. # the setting GENERATE_TREEVIEW). It is highly recommended to start with a # default header using # doxygen -w html new_header.html new_footer.html new_stylesheet.css # YourConfigFile # and then modify the file new_header.html. See also section "Doxygen usage" # for information on how to generate the default header that doxygen normally # uses. # Note: The header is subject to change so you typically have to regenerate the # default header when upgrading to a newer version of doxygen. For a description # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = doc/header.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard # footer. See HTML_HEADER for more information on how to generate a default # footer and what special commands can be used inside the footer. See also # section "Doxygen usage" for information on how to generate the default footer # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of # the HTML output. If left blank doxygen will generate a default style sheet. # See also section "Doxygen usage" for information on how to generate the style # sheet that doxygen normally uses. # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as # it is more robust and this tag (HTML_STYLESHEET) will in the future become # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the # standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that the # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see # https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors # in the HTML output. For a value of 0 the output will use grayscales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the # luminance component of the colors in the HTML output. Values below 100 # gradually make the output lighter, whereas values above 100 make the output # darker. The value divided by 100 is the actual gamma applied, so 80 represents # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not # change the gamma. # Minimum value: 40, maximum value: 240, default value: 80. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting this # to YES can help to show when doxygen was last run and thus if the # documentation is up to date. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that # are dynamically created via JavaScript. If disabled, the navigation index will # consists of multiple levels of tabs that are statically embedded in every HTML # page. Disable this option to support browsers that do not have JavaScript, # like the Qt help browser. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_MENUS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries # shown in the various tree structured indices initially; the user can expand # and collapse entries dynamically later on. Doxygen will expand the tree to # such a level that at most the specified number of entries are visible (unless # a fully collapsed tree already exceeds this amount). So setting the number of # entries 1 will produce a full collapsed tree by default. 0 is a special value # representing an infinite number of entries and will result in a full expanded # tree by default. # Minimum value: 0, maximum value: 9999, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development # environment (see: # https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To # create a documentation set, doxygen will generate a Makefile in the HTML # output directory. Running make will produce the docset in that directory and # running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO # This tag determines the name of the docset feed. A documentation feed provides # an umbrella under which multiple documentation sets from a single provider # (such as a company or product suite) can be grouped. # The default value is: Doxygen generated docs. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. # The default value is: org.doxygen.Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop # (see: # https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML # files are now used as the Windows 98 help format, and will replace the old # Windows help format (.hlp) on all Windows platforms in the future. Compressed # HTML files also contain an index, a table of contents, and you can search for # words in the documentation. The HTML workshop also contains a viewer for # compressed HTML files. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO # The CHM_FILE tag can be used to specify the file name of the resulting .chm # file. You can add a path in front of the file if the result should not be # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, # doxygen will try to run the HTML help compiler on the generated index.hhp. # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO # The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it # enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members to # the table of contents of the HTML help documentation and to the tree view. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help # (.qch) of the generated HTML documentation. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify # the file name of the resulting .qch file. The path specified is relative to # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace # (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual # Folders (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom # Filters (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom # Filters (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: # https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location (absolute path # including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to # run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To # install this plugin and make it available under the help contents menu in # Eclipse, the contents of the directory containing the HTML and XML files needs # to be copied into the plugins directory of eclipse. The name of the directory # within the plugins directory should be the same as the ECLIPSE_DOC_ID value. # After copying Eclipse needs to be restarted before the help appears. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO # A unique identifier for the Eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have this # name. Each documentation set should have its own identifier. # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project # If you want full control over the layout of the generated HTML pages it might # be necessary to disable the index and replace it with your own. The # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top # of each HTML page. A value of NO enables the index and the value YES disables # it. Since the tabs in the index contain the same information as the navigation # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. If the tag # value is set to YES, a side panel will be generated containing a tree-like # index structure (just like the one that is generated for HTML Help). For this # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can # further fine-tune the look of the index. As an example, the default style # sheet generated by doxygen has an example that shows how to put an image at # the root of the tree instead of the PROJECT_NAME. Since the tree basically has # the same information as the tab index, you could consider setting # DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # # Note that a value of 0 will completely suppress the enum values from appearing # in the overview section. # Minimum value: 0, maximum value: 20, default value: 4. # This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used # to set the initial width (in pixels) of the frame in which the tree is shown. # Minimum value: 0, maximum value: 1500, default value: 250. # This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 # If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to # external symbols imported via tag files in a separate window. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO # If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg # tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see # https://inkscape.org) to generate formulas as SVG images instead of PNGs for # the HTML output. These images will generally look nicer at scaled resolutions. # Possible values are: png (the default) and svg (looks nicer but requires the # pdf2svg or inkscape tool). # The default value is: png. # This tag requires that the tag GENERATE_HTML is set to YES. HTML_FORMULA_FORMAT = png # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML # output directory to force them to be regenerated. # Minimum value: 8, maximum value: 50, default value: 10. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # # Note that when changing this option you need to delete any form_*.png files in # the HTML output directory before the changes have effect. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES # The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands # to create new LaTeX commands to be used in formulas as building blocks. See # the section "Including formulas" for details. FORMULA_MACROFILE = # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see # https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path # to it using the MATHJAX_RELPATH option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: # http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the HTML # output directory using the MATHJAX_RELPATH option. The destination directory # should contain the MathJax.js script. For instance, if the mathjax directory # is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from https://www.mathjax.org before deployment. # The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site # (see: # http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and # should work on any modern browser. Note that when using HTML help # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) # there is already a search function so this one should typically be disabled. # For large projects the javascript based search engine can be slow, then # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to # search using the keyboard; to jump to the search box use + S # (what the is depends on the OS and browser, but it is typically # , /