...
 
Commits (58)
/.libs/ /.libs/
.*.swp .*.swp
/_ldns.la /_ldns.la
/Makefile
/aclocal.m4 /aclocal.m4
/autom4te.cache/ /autom4te.cache/
/buffer.lo /buffer.lo
...@@ -16,7 +15,6 @@ ...@@ -16,7 +15,6 @@
/compat/timegm.o /compat/timegm.o
/compat/timegm.lo /compat/timegm.lo
/config.guess /config.guess
/config.h
/config.log /config.log
/config.status /config.status
/config.sub /config.sub
...@@ -150,12 +148,8 @@ ...@@ -150,12 +148,8 @@
/install-sh /install-sh
/keys.lo /keys.lo
/keys.o /keys.o
/ldns/common.h
/ldns/config.h
/ldns/config.h.in /ldns/config.h.in
/ldns/config.h.in~ /ldns/config.h.in~
/ldns/net.h
/ldns/util.h
/ldns_wrapper.lo /ldns_wrapper.lo
/ldns_wrapper.o /ldns_wrapper.o
/lib /lib
...@@ -241,3 +235,5 @@ ...@@ -241,3 +235,5 @@
/wire2host.o /wire2host.o
/zone.lo /zone.lo
/zone.o /zone.o
.DS_Store
This diff is collapsed.
ldns/config.h
\ No newline at end of file
...@@ -17,13 +17,22 @@ ...@@ -17,13 +17,22 @@
#include <strings.h> #include <strings.h>
#include <time.h> #include <time.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#ifdef HAVE_SSL #ifdef HAVE_SSL
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#endif
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#include <openssl/dsa.h>
#include <openssl/rsa.h>
#endif /* TARGET_OS_IPHONE */
#endif /* HAVE_SSL */
ldns_rr * ldns_rr *
ldns_dnssec_get_rrsig_for_name_and_type(const ldns_rdf *name, ldns_dnssec_get_rrsig_for_name_and_type(const ldns_rdf *name,
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include <strings.h> #include <strings.h>
#include <time.h> #include <time.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#ifdef HAVE_SSL #ifdef HAVE_SSL
/* this entire file is rather useless when you don't have /* this entire file is rather useless when you don't have
* crypto... * crypto...
...@@ -17,6 +21,12 @@ ...@@ -17,6 +21,12 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#include <openssl/dsa.h>
#include <openssl/rsa.h>
#endif /* TARGET_OS_IPHONE */
#endif /* HAVE_SSL */ #endif /* HAVE_SSL */
ldns_rr * ldns_rr *
......
...@@ -15,6 +15,15 @@ ...@@ -15,6 +15,15 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
# define ERR_load_crypto_strings() \
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
#endif /* TARGET_OS_IPHONE */
ldns_dnssec_data_chain * ldns_dnssec_data_chain *
ldns_dnssec_data_chain_new(void) ldns_dnssec_data_chain_new(void)
{ {
......
...@@ -16,6 +16,18 @@ ...@@ -16,6 +16,18 @@
#include <limits.h> #include <limits.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#ifdef HAVE_SSL
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#include <openssl/bn.h>
#include <openssl/rsa.h>
#include <openssl/dsa.h>
#endif /* TARGET_OS_IPHONE */
#endif /* HAVE_SSL */
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
......
...@@ -14,10 +14,22 @@ ...@@ -14,10 +14,22 @@
#include <ldns/ldns.h> #include <ldns/ldns.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#ifdef HAVE_SSL #ifdef HAVE_SSL
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/engine.h> #include <openssl/engine.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#include <openssl/bn.h>
#include <openssl/dsa.h>
#include <openssl/rsa.h>
#include <openssl/ui.h>
#endif /* TARGET_OS_IPHONE */
#endif /* HAVE_SSL */ #endif /* HAVE_SSL */
ldns_lookup_table ldns_signing_algorithms[] = { ldns_lookup_table ldns_signing_algorithms[] = {
......
/**
* \file common.h
*
* Common definitions for LDNS
*/
/**
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2004-2006
*
* See the file LICENSE for the license
*/
#ifndef LDNS_COMMON_H
#define LDNS_COMMON_H
/*
* The build configuration that is used in the distributed headers,
* as detected and determined by the auto configure script.
*/
#define LDNS_BUILD_CONFIG_HAVE_SSL 1
#define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H 1
#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT 1
#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED 1
#define LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T 1
#define LDNS_BUILD_CONFIG_USE_DANE 0
#define LDNS_BUILD_CONFIG_HAVE_B32_PTON 0
#define LDNS_BUILD_CONFIG_HAVE_B32_NTOP 0
/*
* HAVE_STDBOOL_H is not available when distributed as a library, but no build
* configuration variables may be used (like those above) because the header
* is sometimes only available when using special compiler flags to enable the
* c99 environment. Because we cannot force the usage of this flag, we have to
* provide a default type. Below what is suggested by the autoconf manual.
*/
/*@ignore@*/
/* splint barfs on this construct */
#ifndef __bool_true_false_are_defined
# ifdef HAVE_STDBOOL_H
# include <stdbool.h>
# else
# ifndef HAVE__BOOL
# ifdef __cplusplus
typedef bool _Bool;
# else
# define _Bool signed char
# endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
# endif
#endif
/*@end@*/
#if LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT
#define ATTR_FORMAT(archetype, string_index, first_to_check) \
__attribute__ ((format (archetype, string_index, first_to_check)))
#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT */
#if defined(__cplusplus)
#define ATTR_UNUSED(x)
#elif LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED
#define ATTR_UNUSED(x) x __attribute__((unused))
#else /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
#define ATTR_UNUSED(x) x
#endif /* !LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED */
#if !LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T
typedef int socklen_t;
#endif
#endif /* LDNS_COMMON_H */
/* ldns/config.h. Generated from config.h.in by configure. */
/* ldns/config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Whether the C compiler accepts the "format" attribute */
#define HAVE_ATTR_FORMAT 1
/* Whether the C compiler accepts the "unused" attribute */
#define HAVE_ATTR_UNUSED 1
/* Define to 1 if you have the `b32_ntop' function. */
/* #undef HAVE_B32_NTOP */
/* Define to 1 if you have the `b32_pton' function. */
/* #undef HAVE_B32_PTON */
/* Define to 1 if you have the `b64_ntop' function. */
/* #undef HAVE_B64_NTOP */
/* Define to 1 if you have the `b64_pton' function. */
/* #undef HAVE_B64_PTON */
/* Define to 1 if you have the `bzero' function. */
#define HAVE_BZERO 1
/* Define to 1 if you have the `calloc' function. */
#define HAVE_CALLOC 1
/* Define to 1 if you have the `ctime_r' function. */
#define HAVE_CTIME_R 1
/* Is a CAFILE given at configure time */
#define HAVE_DANE_CA_FILE 0
/* Is a CAPATH given at configure time */
#define HAVE_DANE_CA_PATH 0
/* Define to 1 if you have the declaration of `NID_secp384r1', and to 0 if you
don't. */
#define HAVE_DECL_NID_SECP384R1 1
/* Define to 1 if you have the declaration of `NID_X25519', and to 0 if you
don't. */
/* #undef HAVE_DECL_NID_X25519 */
/* Define to 1 if you have the declaration of `NID_X448', and to 0 if you
don't. */
/* #undef HAVE_DECL_NID_X448 */
/* Define to 1 if you have the declaration of `NID_X9_62_prime256v1', and to 0
if you don't. */
#define HAVE_DECL_NID_X9_62_PRIME256V1 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the `DSA_get0_key' function. */
#define HAVE_DSA_GET0_KEY 1
/* Define to 1 if you have the `DSA_get0_pqg' function. */
#define HAVE_DSA_GET0_PQG 1
/* Define to 1 if you have the `DSA_SIG_get0' function. */
#define HAVE_DSA_SIG_GET0 1
/* Define to 1 if you have the `DSA_SIG_set0' function. */
#define HAVE_DSA_SIG_SET0 1
/* Define to 1 if you have the `ECDSA_SIG_get0' function. */
#define HAVE_ECDSA_SIG_GET0 1
/* Define to 1 if you have the `endprotoent' function. */
#define HAVE_ENDPROTOENT 1
/* Define to 1 if you have the `endservent' function. */
#define HAVE_ENDSERVENT 1
/* Define to 1 if you have the `ENGINE_load_cryptodev' function. */
/* #undef HAVE_ENGINE_LOAD_CRYPTODEV */
/* Define to 1 if you have the `EVP_dss1' function. */
/* #undef HAVE_EVP_DSS1 */
/* Define to 1 if you have the `EVP_MD_CTX_new' function. */
#define HAVE_EVP_MD_CTX_NEW 1
/* Define to 1 if you have the `EVP_PKEY_base_id' function. */
#define HAVE_EVP_PKEY_BASE_ID 1
/* Define to 1 if you have the `EVP_PKEY_keygen' function. */
#define HAVE_EVP_PKEY_KEYGEN 1
/* Define to 1 if you have the `EVP_sha256' function. */
#define HAVE_EVP_SHA256 1
/* Define to 1 if you have the `EVP_sha384' function. */
#define HAVE_EVP_SHA384 1
/* Define to 1 if you have the `EVP_sha512' function. */
#define HAVE_EVP_SHA512 1
/* Define to 1 if you have the `fcntl' function. */
#define HAVE_FCNTL 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
/* Whether getaddrinfo is available */
#define HAVE_GETADDRINFO 1
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define to 1 if you have the `gmtime_r' function. */
#define HAVE_GMTIME_R 1
/* If you have HMAC_Update */
#define HAVE_HMAC_UPDATE 1
/* Define to 1 if you have the `inet_aton' function. */
#define HAVE_INET_ATON 1
/* Define to 1 if you have the `inet_ntop' function. */
#define HAVE_INET_NTOP 1
/* Define to 1 if you have the `inet_pton' function. */
#define HAVE_INET_PTON 1
/* define if you have inttypes.h */
#define HAVE_INTTYPES_H 1
/* if the function 'ioctlsocket' is available */
/* #undef HAVE_IOCTLSOCKET */
/* Define to 1 if you have the `isascii' function. */
#define HAVE_ISASCII 1
/* Define to 1 if you have the `isblank' function. */
#define HAVE_ISBLANK 1
/* Define to 1 if you have the `pcap' library (-lpcap). */
/* #undef HAVE_LIBPCAP */
/* Define if we have LibreSSL */
/* #undef HAVE_LIBRESSL */
/* Define to 1 if you have the `localtime_r' function. */
#define HAVE_LOCALTIME_R 1
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC 1
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the <netdb.h> header file. */
#define HAVE_NETDB_H 1
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
/* #undef HAVE_NETINET_IF_ETHER_H */
/* Define to 1 if you have the <netinet/igmp.h> header file. */
/* #undef HAVE_NETINET_IGMP_H */
/* Define to 1 if you have the <netinet/in.h> header file. */
#define HAVE_NETINET_IN_H 1
/* Define to 1 if you have the <netinet/in_systm.h> header file. */
/* #undef HAVE_NETINET_IN_SYSTM_H */
/* Define to 1 if you have the <netinet/ip6.h> header file. */
/* #undef HAVE_NETINET_IP6_H */
/* Define to 1 if you have the <netinet/ip_compat.h> header file. */
/* #undef HAVE_NETINET_IP_COMPAT_H */
/* Define to 1 if you have the <netinet/ip.h> header file. */
/* #undef HAVE_NETINET_IP_H */
/* Define to 1 if you have the <netinet/udp.h> header file. */
/* #undef HAVE_NETINET_UDP_H */
/* Define to 1 if you have the <net/ethernet.h> header file. */
/* #undef HAVE_NET_ETHERNET_H */
/* Define to 1 if you have the <net/if.h> header file. */
/* #undef HAVE_NET_IF_H */
/* Define to 1 if you have the <openssl/err.h> header file. */
#define HAVE_OPENSSL_ERR_H 1
/* Define to 1 if you have the <openssl/rand.h> header file. */
#define HAVE_OPENSSL_RAND_H 1
/* Define to 1 if you have the <openssl/ssl.h> header file. */
#define HAVE_OPENSSL_SSL_H 1
/* Define to 1 if you have the <pcap.h> header file. */
/* #undef HAVE_PCAP_H */
/* This platform supports poll(7). */
#define HAVE_POLL 1
/* If available, contains the Python version number currently in use. */
/* #undef HAVE_PYTHON */
/* Define to 1 if you have the `random' function. */
#define HAVE_RANDOM 1
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#define HAVE_REALLOC 1
/* Define to 1 if you have the `sleep' function. */
#define HAVE_SLEEP 1
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1
/* Define if you have the SSL libraries installed. */
#define HAVE_SSL /**/
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strlcpy' function. */
#define HAVE_STRLCPY 1
/* Define to 1 if you have the `strtoul' function. */
#define HAVE_STRTOUL 1
/* Define if you have SWIG libraries and header files. */
/* #undef HAVE_SWIG */
/* Define to 1 if you have the <sys/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* define if you have sys/socket.h */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* define if you have sys/types.h */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the `timegm' function. */
#define HAVE_TIMEGM 1
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* define if you have unistd.h */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `vfork' function. */
#define HAVE_VFORK 1
/* Define to 1 if you have the <vfork.h> header file. */
/* #undef HAVE_VFORK_H */
/* Define to 1 if you have the <winsock2.h> header file. */
/* #undef HAVE_WINSOCK2_H */
/* Define to 1 if `fork' works. */
#define HAVE_WORKING_FORK 1
/* Define to 1 if `vfork' works. */
#define HAVE_WORKING_VFORK 1
/* Define to 1 if you have the <ws2tcpip.h> header file. */
/* #undef HAVE_WS2TCPIP_H */
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* Is a CAFILE given at configure time */
/* #undef LDNS_DANE_CA_FILE */
/* Is a CAPATH given at configure time */
/* #undef LDNS_DANE_CA_PATH */
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "libdns@nlnetlabs.nl"
/* Define to the full name of this package. */
#define PACKAGE_NAME "ldns"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "ldns 1.7.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libdns"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.7.0"
/* Define this to enable RR type AVC. */
/* #undef RRTYPE_AVC */
/* Define this to enable RR type NINFO. */
/* #undef RRTYPE_NINFO */
/* Define this to enable RR type OPENPGPKEY. */
#define RRTYPE_OPENPGPKEY /**/
/* Define this to enable RR type RKEY. */
/* #undef RRTYPE_RKEY */
/* Define this to enable RR type TA. */
/* #undef RRTYPE_TA */
/* The size of `time_t', as computed by sizeof. */
#define SIZEOF_TIME_T 8
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define this to enable messages to stderr. */
/* #undef STDERR_MSGS */
/* System configuration dir */
#define SYSCONFDIR sysconfdir
/* Define this to enable DANE support. */
/* #undef USE_DANE */
/* Define this to enable DANE-TA usage type support. */
/* #undef USE_DANE_TA_USAGE */
/* Define this to enable DANE verify support. */
/* #undef USE_DANE_VERIFY */
/* Define this to enable DSA support. */
#define USE_DSA 1
/* Define this to enable ECDSA support. */
#define USE_ECDSA 1
/* Define this to enable ED25519 support. */
/* #undef USE_ED25519 */
/* Define this to enable ED448 support. */
/* #undef USE_ED448 */
/* Define this to enable GOST support. */
/* #undef USE_GOST */
/* Define this to enable SHA256 and SHA512 support. */
#define USE_SHA2 1
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* Whether the windows socket API is used */
/* #undef USE_WINSOCK */
/* the version of the windows API enabled */
#define WINVER 0x0502
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Enable for compile on Minix */
/* #undef _NETBSD_SOURCE */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* in_addr_t */
/* #undef in_addr_t */
/* in_port_t */
/* #undef in_port_t */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `short' if <sys/types.h> does not define. */
/* #undef int16_t */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef int32_t */
/* Define to `long long' if <sys/types.h> does not define. */
/* #undef int64_t */
/* Define to `char' if <sys/types.h> does not define. */
/* #undef int8_t */
/* Define to `size_t' if <sys/types.h> does not define. */
/* #undef intptr_t */
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef malloc */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef pid_t */
/* Define to rpl_realloc if the replacement function should be used. */
/* #undef realloc */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
/* Define to 'int' if not defined */
/* #undef socklen_t */
/* Fallback member name for socket family in struct sockaddr_storage */
/* #undef ss_family */
/* Define to `int' if <sys/types.h> does not define. */
/* #undef ssize_t */
/* Define to `unsigned short' if <sys/types.h> does not define. */
/* #undef uint16_t */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef uint32_t */
/* Define to `unsigned long long' if <sys/types.h> does not define. */
/* #undef uint64_t */
/* Define to `unsigned char' if <sys/types.h> does not define. */
/* #undef uint8_t */
/* Define as `fork' if `vfork' does not work. */
/* #undef vfork */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
#ifndef BYTE_ORDER
#ifdef WORDS_BIGENDIAN
#define BYTE_ORDER BIG_ENDIAN
#else
#define BYTE_ORDER LITTLE_ENDIAN
#endif /* WORDS_BIGENDIAN */
#endif /* BYTE_ORDER */
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
/* 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
#ifdef __cplusplus
extern "C" {
#endif
int ldns_b64_ntop(uint8_t const *src, size_t srclength,
char *target, size_t targsize);
/**
* calculates the size needed to store the result of b64_ntop
*/
/*@unused@*/
static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
{
return ((((srcsize + 2) / 3) * 4) + 1);
}
int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
/**
* calculates the size needed to store the result of ldns_b64_pton
*/
/*@unused@*/
static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
{
return (((((srcsize + 3) / 4) * 3)) + 1);
}
/**
* Given in dnssec_zone.c, also used in dnssec_sign.c:w
*/
int ldns_dname_compare_v(const void *a, const void *b);
#ifndef HAVE_SLEEP
/* use windows sleep, in millisecs, instead */
#define sleep(x) Sleep((x)*1000)
#endif
#ifndef HAVE_RANDOM
#define srandom(x) srand(x)
#define random(x) rand(x)
#endif
#ifndef HAVE_TIMEGM
#include <time.h>
time_t timegm (struct tm *tm);
#endif /* !TIMEGM */
#ifndef HAVE_GMTIME_R
struct tm *gmtime_r(const time_t *timep, struct tm *result);
#endif
#ifndef HAVE_LOCALTIME_R
struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif
#ifndef HAVE_ISBLANK
int isblank(int c);
#endif /* !HAVE_ISBLANK */
#ifndef HAVE_ISASCII
int isascii(int c);
#endif /* !HAVE_ISASCII */
#ifndef HAVE_SNPRINTF
#include <stdarg.h>
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 */
#ifndef HAVE_INET_PTON
int inet_pton(int af, const char* src, void* dst);
#endif /* HAVE_INET_PTON */
#ifndef HAVE_INET_NTOP
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
#endif
#ifndef HAVE_INET_ATON
int inet_aton(const char *cp, struct in_addr *addr);
#endif
#ifndef HAVE_MEMMOVE
void *memmove(void *dest, const void *src, size_t n);
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
#ifdef USE_WINSOCK
#define SOCK_INVALID INVALID_SOCKET
#define close_socket(_s) do { if (_s > SOCK_INVALID) {closesocket(_s); _s = SOCK_INVALID;} } while(0)
#else
#define SOCK_INVALID -1
#define close_socket(_s) do { if (_s > SOCK_INVALID) {close(_s); _s = SOCK_INVALID;} } while(0)
#endif
#ifdef __cplusplus
}
#endif
#ifndef HAVE_GETADDRINFO
#include "compat/fake-rfc2553.h"
#endif
#ifndef HAVE_STRTOUL
#define strtoul (unsigned long)strtol
#endif
/*
* net.h
*
* DNS Resolver definitions
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2005-2006
*
* See the file LICENSE for the license
*/
#ifndef LDNS_NET_H
#define LDNS_NET_H
#include <ldns/ldns.h>
#include <sys/socket.h>
#ifdef __cplusplus
extern "C" {
#endif
#define LDNS_DEFAULT_TIMEOUT_SEC 5
#define LDNS_DEFAULT_TIMEOUT_USEC 0
/**
* \file
*
* Contains functions to send and receive packets over a network.
*/
/**
* Sends a buffer to an ip using udp and return the respons as a ldns_pkt
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the network
* \param[out] answersize size of the packet
* \param[out] result packet with the answer
* \return status
*/
ldns_status ldns_udp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout, size_t *answersize);
/**
* Send an udp query and don't wait for an answer but return
* the socket
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout *unused*, was the timeout value for the network
* \return the socket used
*/
int ldns_udp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
* Send an tcp query and don't wait for an answer but return
* the socket
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the connect attempt
* \return the socket used
*/
int ldns_tcp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
* Sends a buffer to an ip using tcp and return the respons as a ldns_pkt
* \param[in] qbin the ldns_buffer to be send
* \param[in] qbin the ldns_buffer to be send
* \param[in] to the ip addr to send to
* \param[in] tolen length of the ip addr
* \param[in] timeout the timeout value for the network
* \param[out] answersize size of the packet
* \param[out] result packet with the answer
* \return status
*/
ldns_status ldns_tcp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout, size_t *answersize);
/**
* Sends ptk to the nameserver at the resolver object. Returns the data
* as a ldns_pkt
*
* \param[out] pkt packet received from the nameserver
* \param[in] r the resolver to use
* \param[in] query_pkt the query to send
* \return status
*/
ldns_status ldns_send(ldns_pkt **pkt, ldns_resolver *r, const ldns_pkt *query_pkt);
/**
* Sends and ldns_buffer (presumably containing a packet to the nameserver at the resolver object. Returns the data
* as a ldns_pkt
*
* \param[out] pkt packet received from the nameserver
* \param[in] r the resolver to use
* \param[in] qb the buffer to send
* \param[in] tsig_mac the tsig MAC to authenticate the response with (NULL to do no TSIG authentication)
* \return status
*/
ldns_status ldns_send_buffer(ldns_pkt **pkt, ldns_resolver *r, ldns_buffer *qb, ldns_rdf *tsig_mac);
/**
* Create a tcp socket to the specified address
* \param[in] to ip and family
* \param[in] tolen length of to
* \param[in] timeout timeout for the connect attempt
* \return a socket descriptor
*/
int ldns_tcp_connect(const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
* Create a udp socket to the specified address
* \param[in] to ip and family
* \param[in] timeout *unused*, was timeout for the socket
* \return a socket descriptor
*/
int ldns_udp_connect(const struct sockaddr_storage *to, struct timeval timeout);
/**
* send a query via tcp to a server. Don't want for the answer
*
* \param[in] qbin the buffer to send
* \param[in] sockfd the socket to use
* \param[in] to which ip to send it
* \param[in] tolen socketlen
* \return number of bytes sent
*/
ssize_t ldns_tcp_send_query(ldns_buffer *qbin, int sockfd, const struct sockaddr_storage *to, socklen_t tolen);
/**
* send a query via udp to a server. Don;t want for the answer
*
* \param[in] qbin the buffer to send
* \param[in] sockfd the socket to use
* \param[in] to which ip to send it
* \param[in] tolen socketlen
* \return number of bytes sent
*/
ssize_t ldns_udp_send_query(ldns_buffer *qbin, int sockfd, const struct sockaddr_storage *to, socklen_t tolen);
/**
* Gives back a raw packet from the wire and reads the header data from the given
* socket. Allocates the data (of size size) itself, so don't forget to free
*
* \param[in] sockfd the socket to read from
* \param[out] size the number of bytes that are read
* \param[in] timeout the time allowed between packets.
* \return the data read
*/
uint8_t *ldns_tcp_read_wire_timeout(int sockfd, size_t *size, struct timeval timeout);
/**
* This routine may block. Use ldns_tcp_read_wire_timeout, it checks timeouts.
* Gives back a raw packet from the wire and reads the header data from the given
* socket. Allocates the data (of size size) itself, so don't forget to free
*
* \param[in] sockfd the socket to read from
* \param[out] size the number of bytes that are read
* \return the data read
*/
uint8_t *ldns_tcp_read_wire(int sockfd, size_t *size);
/**
* Gives back a raw packet from the wire and reads the header data from the given
* socket. Allocates the data (of size size) itself, so don't forget to free
*
* \param[in] sockfd the socket to read from
* \param[in] fr the address of the client (if applicable)
* \param[in] *frlen the length of the client's addr (if applicable)
* \param[out] size the number of bytes that are read
* \return the data read
*/
uint8_t *ldns_udp_read_wire(int sockfd, size_t *size, struct sockaddr_storage *fr, socklen_t *frlen);
/**
* returns the native sockaddr representation from the rdf.
* \param[in] rd the ldns_rdf to operate on
* \param[in] port what port to use. 0 means; use default (53)
* \param[out] size what is the size of the sockaddr_storage
* \return struct sockaddr* the address in the format so other
* functions can use it (sendto)
*/
struct sockaddr_storage * ldns_rdf2native_sockaddr_storage(const ldns_rdf *rd, uint16_t port, size_t *size);
/**
* returns an rdf with the sockaddr info. works for ip4 and ip6
* \param[in] sock the struct sockaddr_storage to convert
* \param[in] port what port was used. When NULL this is not set
* \return ldns_rdf* wth the address
*/
ldns_rdf * ldns_sockaddr_storage2rdf(const struct sockaddr_storage *sock, uint16_t *port);
/**
* Prepares the resolver for an axfr query
* The query is sent and the answers can be read with ldns_axfr_next
* \param[in] resolver the resolver to use
* \param[in] domain the domain to exfr
* \param[in] c the class to use
* \return ldns_status the status of the transfer
*/
ldns_status ldns_axfr_start(ldns_resolver *resolver, const ldns_rdf *domain, ldns_rr_class c);
#ifdef __cplusplus
}
#endif
#endif /* LDNS_NET_H */
/*
* util.h
*
* helper function header file
*
* a Net::DNS like library for C
*
* (c) NLnet Labs, 2004
*
* See the file LICENSE for the license
*/
#ifndef _UTIL_H
#define _UTIL_H
#include <inttypes.h>
#include <sys/types.h>
#include <unistd.h>
#include <ldns/common.h>
#include <time.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#define dprintf(X,Y) fprintf(stderr, (X), (Y))
/* #define dprintf(X, Y) */
#define LDNS_VERSION "1.7.0"
#define LDNS_REVISION ((1<<16)|(7<<8)|(0))
/**
* splint static inline workaround
*/
#ifdef S_SPLINT_S
# define INLINE
#else
# ifdef SWIG
# define INLINE static
# else
# define INLINE static inline
# endif
#endif
/**
* Memory management macros
*/
#define LDNS_MALLOC(type) LDNS_XMALLOC(type, 1)
#define LDNS_XMALLOC(type, count) ((type *) malloc((count) * sizeof(type)))
#define LDNS_CALLOC(type, count) ((type *) calloc((count), sizeof(type)))
#define LDNS_REALLOC(ptr, type) LDNS_XREALLOC((ptr), type, 1)
#define LDNS_XREALLOC(ptr, type, count) \
((type *) realloc((ptr), (count) * sizeof(type)))
#define LDNS_FREE(ptr) \
do { free((ptr)); (ptr) = NULL; } while (0)
#define LDNS_DEP printf("DEPRECATED FUNCTION!\n");
/*
* Copy data allowing for unaligned accesses in network byte order
* (big endian).
*/
INLINE uint16_t
ldns_read_uint16(const void *src)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
return ntohs(*(const uint16_t *) src);
#else
const uint8_t *p = (const uint8_t *) src;
return ((uint16_t) p[0] << 8) | (uint16_t) p[1];
#endif
}
INLINE uint32_t
ldns_read_uint32(const void *src)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
return ntohl(*(const uint32_t *) src);
#else
const uint8_t *p = (const uint8_t *) src;
return ( ((uint32_t) p[0] << 24)
| ((uint32_t) p[1] << 16)
| ((uint32_t) p[2] << 8)
| (uint32_t) p[3]);
#endif
}
/*
* Copy data allowing for unaligned accesses in network byte order
* (big endian).
*/
INLINE void
ldns_write_uint16(void *dst, uint16_t data)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
* (uint16_t *) dst = htons(data);
#else
uint8_t *p = (uint8_t *) dst;
p[0] = (uint8_t) ((data >> 8) & 0xff);
p[1] = (uint8_t) (data & 0xff);
#endif
}
INLINE void
ldns_write_uint32(void *dst, uint32_t data)
{
#ifdef ALLOW_UNALIGNED_ACCESSES
* (uint32_t *) dst = htonl(data);
#else
uint8_t *p = (uint8_t *) dst;
p[0] = (uint8_t) ((data >> 24) & 0xff);
p[1] = (uint8_t) ((data >> 16) & 0xff);
p[2] = (uint8_t) ((data >> 8) & 0xff);
p[3] = (uint8_t) (data & 0xff);
#endif
}
/* warning. */
INLINE void
ldns_write_uint64_as_uint48(void *dst, uint64_t data)
{
uint8_t *p = (uint8_t *) dst;
p[0] = (uint8_t) ((data >> 40) & 0xff);
p[1] = (uint8_t) ((data >> 32) & 0xff);
p[2] = (uint8_t) ((data >> 24) & 0xff);
p[3] = (uint8_t) ((data >> 16) & 0xff);
p[4] = (uint8_t) ((data >> 8) & 0xff);
p[5] = (uint8_t) (data & 0xff);
}
/**
* Structure to do a Schwartzian-like transformation, for instance when
* sorting. If you need a transformation on the objects that are sorted,
* you can sue this to store the transformed values, so you do not
* need to do the transformation again for each comparison
*/
struct ldns_schwartzian_compare_struct {
void *original_object;
void *transformed_object;
};
/** A general purpose lookup table
*
* Lookup tables are arrays of (id, name) pairs,
* So you can for instance lookup the RCODE 3, which is "NXDOMAIN",
* and vice versa. The lookup tables themselves are defined wherever needed,
* for instance in \ref host2str.c
*/
struct ldns_struct_lookup_table {
int id;
const char *name;
};
typedef struct ldns_struct_lookup_table ldns_lookup_table;
/**
* Looks up the table entry by name, returns NULL if not found.
* \param[in] table the lookup table to search in
* \param[in] name what to search for
* \return the item found
*/
ldns_lookup_table *ldns_lookup_by_name(ldns_lookup_table table[],
const char *name);
/**
* Looks up the table entry by id, returns NULL if not found.
* \param[in] table the lookup table to search in
* \param[in] id what to search for
* \return the item found
*/
ldns_lookup_table *ldns_lookup_by_id(ldns_lookup_table table[], int id);
/**
* Returns the value of the specified bit
* The bits are counted from left to right, so bit #0 is the
* left most bit.
* \param[in] bits array holding the bits
* \param[in] index to the wanted bit
* \return
*/
int ldns_get_bit(uint8_t bits[], size_t index);
/**
* Returns the value of the specified bit
* The bits are counted from right to left, so bit #0 is the
* right most bit.
* \param[in] bits array holding the bits
* \param[in] index to the wanted bit
* \return 1 or 0 depending no the bit state
*/
int ldns_get_bit_r(uint8_t bits[], size_t index);
/**
* sets the specified bit in the specified byte to
* 1 if value is true, 0 if false
* The bits are counted from right to left, so bit #0 is the
* right most bit.
* \param[in] byte the bit to set the bit in
* \param[in] bit_nr the bit to set (0 <= n <= 7)
* \param[in] value whether to set the bit to 1 or 0
* \return 1 or 0 depending no the bit state
*/
void ldns_set_bit(uint8_t *byte, int bit_nr, bool value);
/**
* Returns the value of a to the power of b
* (or 1 of b < 1)
*/
/*@unused@*/
INLINE long
ldns_power(long a, long b) {
long result = 1;
while (b > 0) {
if (b & 1) {
result *= a;
if (b == 1) {
return result;
}
}
a *= a;
b /= 2;
}
return result;
}
/**
* Returns the int value of the given (hex) digit
* \param[in] ch the hex char to convert
* \return the converted decimal value
*/
int ldns_hexdigit_to_int(char ch);
/**
* Returns the char (hex) representation of the given int
* \param[in] ch the int to convert
* \return the converted hex char
*/
char ldns_int_to_hexdigit(int ch);
/**
* Converts a hex string to binary data
*
* \param[out] data The binary result is placed here.
* At least strlen(str)/2 bytes should be allocated
* \param[in] str The hex string to convert.
* This string should not contain spaces
* \return The number of bytes of converted data, or -1 if one of the arguments * is NULL, or -2 if the string length is not an even number
*/
int
ldns_hexstring_to_data(uint8_t *data, const char *str);
/**
* Show the internal library version
* \return a string with the version in it
*/
const char * ldns_version(void);
/**
* Convert TM to seconds since epoch (midnight, January 1st, 1970).
* Like timegm(3), which is not always available.
* \param[in] tm a struct tm* with the date
* \return the seconds since epoch
*/
time_t ldns_mktime_from_utc(const struct tm *tm);
time_t mktime_from_utc(const struct tm *tm);
/**
* The function interprets time as the number of seconds since epoch
* with respect to now using serial arithmitics (rfc1982).
* That number of seconds is then converted to broken-out time information.
* This is especially useful when converting the inception and expiration
* fields of RRSIG records.
*
* \param[in] time number of seconds since epoch (midnight, January 1st, 1970)
* to be intepreted as a serial arithmitics number relative to now.
* \param[in] now number of seconds since epoch (midnight, January 1st, 1970)
* to which the time value is compared to determine the final value.
* \param[out] result the struct with the broken-out time information
* \return result on success or NULL on error
*/
struct tm * ldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result);
/**
* Seed the random function.
* If the file descriptor is specified, the random generator is seeded with
* data from that file. If not, /dev/urandom is used.
*
* 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
*
* \param[in] fd a file providing entropy data for the seed
* \param[in] size the number of bytes to use as entropy data. If this is 0,
* only the minimal amount is taken (usually 4 bytes)
* \return 0 if seeding succeeds, 1 if it fails
*/
int ldns_init_random(FILE *fd, unsigned int size);
/**
* Get random number.
* \return random number.
*
*/
uint16_t ldns_get_random(void);
/**
* Encode data as BubbleBabble
*
* \param[in] data a pointer to data to be encoded
* \param[in] len size the number of bytes of data
* \return a string of BubbleBabble
*/
char *ldns_bubblebabble(uint8_t *data, size_t len);
INLINE time_t ldns_time(time_t *t) { return time(t); }
/**
* calculates the size needed to store the result of b32_ntop
*/
/*@unused@*/
INLINE size_t ldns_b32_ntop_calculate_size(size_t src_data_length)
{
return src_data_length == 0 ? 0 : ((src_data_length - 1) / 5 + 1) * 8;
}
INLINE size_t ldns_b32_ntop_calculate_size_no_padding(size_t src_data_length)
{
return ((src_data_length + 3) * 8 / 5) - 4;
}
int ldns_b32_ntop(const uint8_t* src_data, size_t src_data_length,
char* target_text_buffer, size_t target_text_buffer_size);
int ldns_b32_ntop_extended_hex(const uint8_t* src_data, size_t src_data_length,
char* target_text_buffer, size_t target_text_buffer_size);
#if ! LDNS_BUILD_CONFIG_HAVE_B32_NTOP
int b32_ntop(const uint8_t* src_data, size_t src_data_length,
char* target_text_buffer, size_t target_text_buffer_size);
int b32_ntop_extended_hex(const uint8_t* src_data, size_t src_data_length,
char* target_text_buffer, size_t target_text_buffer_size);
#endif /* ! LDNS_BUILD_CONFIG_HAVE_B32_NTOP */
/**
* calculates the size needed to store the result of b32_pton
*/
/*@unused@*/
INLINE size_t ldns_b32_pton_calculate_size(size_t src_text_length)
{
return src_text_length * 5 / 8;
}
int ldns_b32_pton(const char* src_text, size_t src_text_length,
uint8_t* target_data_buffer, size_t target_data_buffer_size);
int ldns_b32_pton_extended_hex(const char* src_text, size_t src_text_length,
uint8_t* target_data_buffer, size_t target_data_buffer_size);
#if ! LDNS_BUILD_CONFIG_HAVE_B32_PTON
int b32_pton(const char* src_text, size_t src_text_length,
uint8_t* target_data_buffer, size_t target_data_buffer_size);
int b32_pton_extended_hex(const char* src_text, size_t src_text_length,
uint8_t* target_data_buffer, size_t target_data_buffer_size);
#endif /* ! LDNS_BUILD_CONFIG_HAVE_B32_PTON */
#ifdef __cplusplus
}
#endif
#endif /* !_UTIL_H */
...@@ -15,6 +15,17 @@ ...@@ -15,6 +15,17 @@
#include <ldns/ldns.h> #include <ldns/ldns.h>
#include <strings.h> #include <strings.h>
#if __APPLE__
#include "TargetConditionals.h"
#endif
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#include <resolv.h>
#include <netdb.h>
#endif
/* Access function for reading /* Access function for reading
* and setting the different Resolver * and setting the different Resolver
* options */ * options */
...@@ -997,10 +1008,69 @@ ldns_resolver_new_frm_fp_l(ldns_resolver **res, FILE *fp, int *line_nr) ...@@ -997,10 +1008,69 @@ ldns_resolver_new_frm_fp_l(ldns_resolver **res, FILE *fp, int *line_nr)
} }
} }
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
ldns_status
ldns_resolver_new_iOS(ldns_resolver **res)
{
res_state the_res_state = malloc(sizeof(struct __res_state));
int result = res_ninit(the_res_state);
if (result == 0) {
union res_sockaddr_union servers[NI_MAXSERV];
int serversFound = res_getservers(the_res_state, servers, NI_MAXSERV);
ldns_resolver *the_resolver = ldns_resolver_new();
uint16_t default_port = ldns_resolver_port(the_resolver);
for (int i = 0; i < serversFound; i ++) {
union res_sockaddr_union s = servers[i];
uint16_t port;
ldns_rdf *rdf = ldns_sockaddr_storage2rdf(&s.sin, &port);
if (rdf) {
uint16_t existing_port = ldns_resolver_port(the_resolver);
if (port != existing_port && existing_port != default_port) {
// have different servers with different ports, stop here
free(the_res_state);
*res = the_resolver;
return LDNS_STATUS_OK;
}
ldns_status status = ldns_resolver_push_nameserver(the_resolver, rdf);
ldns_rdf_free(rdf);
if (status != LDNS_STATUS_OK) {
free(the_res_state);
ldns_resolver_free(the_resolver);
return status;
} else {
ldns_resolver_set_port(the_resolver, port);
}
} else {
free(the_res_state);
ldns_resolver_free(the_resolver);
return LDNS_STATUS_ERR;
}
}
free(the_res_state);
*res = the_resolver;
return LDNS_STATUS_OK;
}
free(the_res_state);
return LDNS_STATUS_ERR;
}
#endif
ldns_status ldns_status
ldns_resolver_new_frm_file(ldns_resolver **res, const char *filename) ldns_resolver_new_frm_file(ldns_resolver **res, const char *filename)
{ {
ldns_resolver *r; #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
return ldns_resolver_new_iOS(res);
#else
ldns_resolver *r;
FILE *fp; FILE *fp;
ldns_status s; ldns_status s;
...@@ -1026,6 +1096,7 @@ ldns_resolver_new_frm_file(ldns_resolver **res, const char *filename) ...@@ -1026,6 +1096,7 @@ ldns_resolver_new_frm_file(ldns_resolver **res, const char *filename)
} }
} }
return s; return s;
#endif
} }
void void
......
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
#include <time.h> #include <time.h>
#include <ctype.h> #include <ctype.h>
#if __APPLE__
#include <TargetConditionals.h>
#endif
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#include <resolv.h> // for b64_ntop/b64_pton
#endif /* TARGET_OS_IPHONE */
#ifdef HAVE_SSL #ifdef HAVE_SSL
#include <openssl/rand.h> #include <openssl/rand.h>
#endif #endif
...@@ -465,9 +473,9 @@ ldns_bubblebabble(uint8_t *data, size_t len) ...@@ -465,9 +473,9 @@ ldns_bubblebabble(uint8_t *data, size_t len)
/* /*
* For backwards compatibility, because we have always exported this symbol. * For backwards compatibility, because we have always exported this symbol.
*/ */
#ifdef HAVE_B64_NTOP #if defined(HAVE_B64_NTOP) || (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
int ldns_b64_ntop(const uint8_t* src, size_t srclength, int ldns_b64_ntop(const uint8_t* src, size_t srclength,
char *target, size_t targsize); char *target, size_t targsize)
{ {
return b64_ntop(src, srclength, target, targsize); return b64_ntop(src, srclength, target, targsize);
} }
...@@ -476,14 +484,13 @@ int ldns_b64_ntop(const uint8_t* src, size_t srclength, ...@@ -476,14 +484,13 @@ int ldns_b64_ntop(const uint8_t* src, size_t srclength,
/* /*
* For backwards compatibility, because we have always exported this symbol. * For backwards compatibility, because we have always exported this symbol.
*/ */
#ifdef HAVE_B64_PTON #if defined(HAVE_B64_PTON) || (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
int ldns_b64_pton(const char* src, uint8_t *target, size_t targsize) int ldns_b64_pton(const char* src, uint8_t *target, size_t targsize)
{ {
return b64_pton(src, target, targsize); return b64_pton(src, target, targsize);
} }
#endif #endif
static int static int
ldns_b32_ntop_base(const uint8_t* src, size_t src_sz, ldns_b32_ntop_base(const uint8_t* src, size_t src_sz,
char* dst, size_t dst_sz, char* dst, size_t dst_sz,
......
.DS_Store
xcuserdata/
Makefile
aclocal.m4
autom4te.cache/
config.guess
config.log
config.status
config.sub
configure
install-sh
ldns/common.h
ldns/config.h
ldns/config.h.in
ldns/config.h.in~
ldns/net.h
ldns/util.h
libtool
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
packaging/ldns-config
packaging/libldns.pc
//
// main.m
// ldns-xcode-config
//
// Created by Dirk Zimmermann on 27.11.17.
// Copyright © 2017 pEp Security S.A. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
}
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ldns-xcode.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
//
// ldns_xcode.h
// ldns-xcode
//
// Created by Dirk Zimmermann on 23.11.17.
// Copyright © 2017 pEp Security S.A. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for ldns_xcode.
FOUNDATION_EXPORT double ldns_xcodeVersionNumber;
//! Project version string for ldns_xcode.
FOUNDATION_EXPORT const unsigned char ldns_xcodeVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <ldns_xcode/PublicHeader.h>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
//
// ldns_xcodeTests.m
// ldns-xcodeTests
//
// Created by Dirk Zimmermann on 23.11.17.
// Copyright © 2017 pEp Security S.A. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface ldns_xcodeTests : XCTestCase
@end
@implementation ldns_xcodeTests
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
@end
#!/bin/sh
# configure.sh
# ldns-xcode
#
# Created by Dirk Zimmermann on 29.11.17.
# Copyright © 2017 pEp Security S.A. All rights reserved.
#
# Sample invocation:
# PROJECT_DIR=.. sh configure.sh # from the script directory
# PROJECT_DIR=xcode/ldns-xcode/ sh xcode/ldns-xcode/scripts/configure.sh # from the ldns base
#
#
# PROJECT_DIR must be set correctly, to the root of the xcode project.
# Set this manually if you don't use this script from xcode.
#
#
# Macport dependencies:
#
# sudo port install autoconf
# sudo port install libtool
# sudo port install automake
#
# macports must be in PATH
PATH=$PATH:/opt/local/bin
LDNS_BASE=$PROJECT_DIR/../..
if [ -f $LDNS_BASE/ldns/config.h ]; then
exit 0
fi
sdks=( ../OpenSSL-for-iPhone/bin/iPhoneSimulator*-x86_64.sdk )
SDK="${sdks[${#sdks[@]}-1]}"
echo Using OpenSSL at $SDK
pushd $LDNS_BASE
git submodule update --init
glibtoolize -ci
autoreconf -fi
./configure --disable-dane --disable-dane-verify --disable-dane-ta-usage --with-ssl=$SDK
popd