Port of ldns and drill

Drill is a DNS utility inspired by dig.

https://www.nlnetlabs.nl/projects/ldns/

Fix #99
This commit is contained in:
Emery Hemingway
2018-02-22 13:38:53 +01:00
committed by Norman Feske
parent 995be00f3f
commit cdc389ef3d
8 changed files with 417 additions and 0 deletions

224
include/ldns/config.h Normal file
View File

@@ -0,0 +1,224 @@
/* configure vomit from linux */
#define HAVE_ARPA_INET_H 1
#define HAVE_ATTR_FORMAT 1
#define HAVE_ATTR_UNUSED 1
#define HAVE_BZERO 1
#define HAVE_CALLOC 1
#define HAVE_CTIME_R 1
#define HAVE_DANE_CA_FILE 0
#define HAVE_DANE_CA_PATH 0
#define HAVE_DECL_NID_SECP384R1 1
#define HAVE_DECL_NID_X9_62_PRIME256V1 1
#define HAVE_DLFCN_H 1
#define HAVE_ENGINE_LOAD_CRYPTODEV 1
#define HAVE_EVP_DSS1 1
#define HAVE_EVP_PKEY_BASE_ID 1
#define HAVE_EVP_PKEY_KEYGEN 1
#define HAVE_EVP_SHA256 1
#define HAVE_EVP_SHA384 1
#define HAVE_EVP_SHA512 1
#define HAVE_FCNTL 1
#define HAVE_GETADDRINFO 1
#define HAVE_GETOPT_H 1
#define HAVE_GMTIME_R 1
#define HAVE_HMAC_UPDATE 1
#define HAVE_INET_ATON 1
#define HAVE_INET_NTOP 1
#define HAVE_INET_PTON 1
#define HAVE_INTTYPES_H 1
#define HAVE_ISASCII 1
#define HAVE_ISBLANK 1
#define HAVE_LOCALTIME_R 1
#define HAVE_MALLOC 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMORY_H 1
#define HAVE_MEMSET 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_OPENSSL_ERR_H 1
#define HAVE_OPENSSL_RAND_H 1
#define HAVE_OPENSSL_SSL_H 1
#define HAVE_POLL 1
#define HAVE_RANDOM 1
#define HAVE_REALLOC 1
#define HAVE_SLEEP 1
#define HAVE_SNPRINTF 1
#define HAVE_SSL /**/
#define HAVE_STDARG_H 1
#define HAVE_STDBOOL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRTOUL 1
#define HAVE_SYS_MOUNT_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_TIMEGM 1
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE__BOOL 1
#define LT_OBJDIR ".libs/"
#define PACKAGE_BUGREPORT "libdns@nlnetlabs.nl"
#define PACKAGE_NAME "ldns"
#define PACKAGE_STRING "ldns"
#define PACKAGE_TARNAME "libdns"
#define PACKAGE_URL ""
#define PACKAGE_VERSION ""
#define RRTYPE_OPENPGPKEY /**/
#define SIZEOF_TIME_T 8
#define STDC_HEADERS 1
#define SYSCONFDIR sysconfdir
#define USE_DANE 1
#define USE_DANE_VERIFY 1
#define USE_DSA 1
#define USE_ECDSA 1
#define USE_GOST 1
#define USE_SHA2 1
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
#define WINVER 0x0502
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# endif
#endif
#ifndef __cplusplus
#endif
#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
#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);
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);
static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
{
return (((((srcsize + 3) / 4) * 3)) + 1);
}
int ldns_dname_compare_v(const void *a, const void *b);
#ifndef HAVE_SLEEP
#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

View File

@@ -0,0 +1,3 @@
LDNS_PORT_DIR := $(call select_from_ports,ldns)
INC_DIR += $(LDNS_PORT_DIR)/include
CC_DEF += -DLDNS_TRUST_ANCHOR_FILE=\"/etc/unbound/root.key\"

13
lib/mk/ldns.mk Normal file
View File

@@ -0,0 +1,13 @@
include $(REP_DIR)/lib/import/import-ldns.mk
LDNS_SRC_DIR := $(LDNS_PORT_DIR)/src/lib/ldns
LIBS += libc libssl
SRC_LDNS_C := $(notdir $(wildcard $(LDNS_SRC_DIR)/*.c))
SRC_C += $(filter-out linktest.c,$(SRC_LDNS_C))
SRC_C += $(notdir $(wildcard $(LDNS_SRC_DIR)/compat/b64*.c))
SRC_CC += getproto.cc
vpath %.c $(LDNS_SRC_DIR) $(LDNS_SRC_DIR)/compat
vpath %.cc $(REP_DIR)/src/lib/ldns

1
ports/ldns.hash Normal file
View File

@@ -0,0 +1 @@
42e260601f199b0a24d9312918601fc97cb65cdb

50
ports/ldns.port Normal file
View File

@@ -0,0 +1,50 @@
LICENSE = BSD
DOWNLOADS = ldns.archive
VERSION = 1.7.0
URL(ldns) := https://www.nlnetlabs.nl/downloads/ldns/ldns-$(VERSION).tar.gz
SHA(ldns) := ceeeccf8a27e61a854762737f6ee02f44662c1b8
DIR(ldns) := src/lib/ldns
DIRS := include/ldns
DIR_CONTENT(include/ldns) = src/lib/ldns/ldns/*.h
default: include/ldns/common.h include/ldns/net.h include/ldns/util.h
include/ldns/common.h: src/lib/ldns/ldns/common.h.in
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)mkdir -p include/ldns
$(VERBOSE)sed \
-e 's/@ldns_build_config_have_ssl@/1/' \
-e 's/@ldns_build_config_have_inttypes_h@/1/' \
-e 's/@ldns_build_config_have_attr_format@/1/' \
-e 's/@ldns_build_config_have_attr_unused@/1/' \
-e 's/@ldns_build_config_have_socklen_t@/1/' \
-e 's/@ldns_build_config_use_dane@/1/' \
-e 's/@ldns_build_config_have_b32_pton@/0/' \
-e 's/@ldns_build_config_have_b32_ntop@/0/' \
$< > $@
include/ldns/net.h: src/lib/ldns/ldns/net.h.in
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)mkdir -p include/ldns
$(VERBOSE)sed \
-e 's?@include_sys_socket_h@?#include <sys/socket.h>?' \
$< > $@
include/ldns/util.h: src/lib/ldns/ldns/util.h.in
@$(MSG_GENERATE)$(notdir $@)
$(VERBOSE)mkdir -p include/ldns
$(VERBOSE)sed \
-e 's?@include_inttypes_h@?#include <inttypes.h>?' \
-e 's?@include_systypes_h@?#include <sys/types.h>?' \
-e 's?@include_unistd_h@?#include <unistd.h>?' \
-e 's?@PACKAGE_VERSION@?$(VERSION)?' \
-e 's?@LDNS_VERSION_MAJOR@?1?' \
-e 's?@LDNS_VERSION_MINOR@?7?' \
-e 's?@LDNS_VERSION_MICRO@?0?' \
$< > $@
src/lib/ldns/ldns/common.h.in: $(DOWNLOADS)
src/lib/ldns/ldns/net.h.in: $(DOWNLOADS)
src/lib/ldns/ldns/util.h.in: $(DOWNLOADS)

101
run/drill.run Normal file
View File

@@ -0,0 +1,101 @@
if {[have_spec linux]} {
puts "The [run_name] scenario requires QEMU networking."
exit 1
}
source ${genode_dir}/repos/base/run/platform_drv.inc
set build_components {
core init
app/drill
drivers/timer
drivers/nic
drivers/rtc
lib/vfs/jitterentropy
}
append_platform_drv_build_components
build $build_components
create_boot_directory
append config {
<config>
<parent-provides>
<service name="CPU"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="IRQ"/>
<service name="LOG"/>
<service name="PD"/>
<service name="RM"/>
<service name="ROM"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/></any-service>
</default-route>
<default caps="100"/>}
append_platform_drv_config
append config {
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>
<start name="nic_drv">
<binary name="} [nic_drv_binary] {"/>
<resource name="RAM" quantum="4M"/>
<provides> <service name="Nic"/> </provides>
</start>
<start name="rtc_drv">
<resource name="RAM" quantum="4M"/>
<provides> <service name="Rtc"/> </provides>
</start>
<start name="drill" caps="256">
<resource name="RAM" quantum="32M"/>
<config>
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc" socket="/socket"/>
<vfs>
<dir name="dev">
<log/> <rtc/>
<jitterentropy name="random"/>
<jitterentropy name="urandom"/>
</dir>
<dir name="socket"> <lxip dhcp="yes"/> </dir>
</vfs>
<arg value="drill"/>
<arg value="-T"/>
<arg value="genode.org"/>
<arg value="@10.0.2.3"/>
</config>
</start>
</config>
}
install_config $config
set boot_modules {
core init ld.lib.so
drill
libc.lib.so
libcrypto.lib.so
libm.lib.so
libssl.lib.so
posix.lib.so
rtc_drv
timer
vfs_jitterentropy.lib.so
vfs_lxip.lib.so lxip.lib.so
}
# platform-specific modules
append_platform_drv_boot_modules
lappend boot_modules [nic_drv_binary]
build_boot_image $boot_modules
append qemu_args " -nographic -net nic,model=e1000 -net user -net dump,file=[run_dir]/dump.pcap"
run_genode_until {child "drill" exited with exit value 0.*\n} 120

11
src/app/drill/target.mk Normal file
View File

@@ -0,0 +1,11 @@
TARGET = drill
LIBS += base libc posix ldns libssl libcrypto
DRILL_SRC_DIR += $(call select_from_ports,ldns)/src/lib/ldns/drill
INC_DIR += $(REP_DIR)/include/ldns
SRC_C += $(notdir $(wildcard $(DRILL_SRC_DIR)/*.c))
vpath %.c $(DRILL_SRC_DIR)

14
src/lib/ldns/getproto.cc Normal file
View File

@@ -0,0 +1,14 @@
#include <netdb.h>
#include <base/log.h>
#include <util/string.h>
struct protoent *getprotobynumber(int proto)
{
static protoent pe;
Genode::error(__func__, "(", proto, ") not implemented");
Genode::memset(&pe, 0x00, sizeof(pe));
return &pe;
}