Module Name: src Committed By: christos Date: Thu Jan 10 17:41:48 UTC 2019
Modified Files: src/external/mpl/dhcp: Makefile.inc src/external/mpl/dhcp/dist/common: dns.c src/external/mpl/dhcp/dist/omapip: buffer.c connection.c dispatch.c isclib.c src/external/mpl/dhcp/dist/server: dhcpv6.c mdb6.c src/external/mpl/dhcp/include: config.h Log Message: Gut omapip support since the socket stuff to support it is gone, and adjust to the new isc library reality. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/mpl/dhcp/Makefile.inc cvs rdiff -u -r1.2 -r1.3 src/external/mpl/dhcp/dist/common/dns.c cvs rdiff -u -r1.2 -r1.3 src/external/mpl/dhcp/dist/omapip/buffer.c \ src/external/mpl/dhcp/dist/omapip/connection.c \ src/external/mpl/dhcp/dist/omapip/dispatch.c \ src/external/mpl/dhcp/dist/omapip/isclib.c cvs rdiff -u -r1.2 -r1.3 src/external/mpl/dhcp/dist/server/dhcpv6.c \ src/external/mpl/dhcp/dist/server/mdb6.c cvs rdiff -u -r1.1 -r1.2 src/external/mpl/dhcp/include/config.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/mpl/dhcp/Makefile.inc diff -u src/external/mpl/dhcp/Makefile.inc:1.4 src/external/mpl/dhcp/Makefile.inc:1.5 --- src/external/mpl/dhcp/Makefile.inc:1.4 Sun Aug 12 11:39:22 2018 +++ src/external/mpl/dhcp/Makefile.inc Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.4 2018/08/12 15:39:22 christos Exp $ +# $NetBSD: Makefile.inc,v 1.5 2019/01/10 17:41:47 christos Exp $ WARNS?= 1 # XXX -Wshadow -Wcast-qual -Wsign-compare @@ -10,7 +10,7 @@ CWARNFLAGS.clang+= -Wno-tautological-com -Wno-format-security -Wno-error=unused-const-variable DIST:= ${.PARSEDIR}/dist -BIND:= ${.PARSEDIR}/../../bsd/bind/dist +BIND:= ${.PARSEDIR}/../../mpl/bind/dist .PATH: ${DIST}/${DHCPSRCDIR} COBJDIR!=cd ${.PARSEDIR}/lib/common && ${PRINTOBJDIR} Index: src/external/mpl/dhcp/dist/common/dns.c diff -u src/external/mpl/dhcp/dist/common/dns.c:1.2 src/external/mpl/dhcp/dist/common/dns.c:1.3 --- src/external/mpl/dhcp/dist/common/dns.c:1.2 Sat Apr 7 18:37:29 2018 +++ src/external/mpl/dhcp/dist/common/dns.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dns.c,v 1.2 2018/04/07 22:37:29 christos Exp $ */ +/* $NetBSD: dns.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* dns.c @@ -29,14 +29,13 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: dns.c,v 1.2 2018/04/07 22:37:29 christos Exp $"); +__RCSID("$NetBSD: dns.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); /*! \file common/dns.c */ #include "dhcpd.h" #include "arpa/nameser.h" -#include <isc/md5.h> -#include <isc/sha2.h> +#include <isc/md.h> #include <dns/result.h> /* @@ -1482,8 +1481,9 @@ static int get_std_dhcid(dhcp_ddns_cb_t unsigned id_len) { struct data_string *id = &ddns_cb->dhcid; - isc_sha256_t sha256; - unsigned char buf[ISC_SHA256_DIGESTLENGTH]; + isc_md_t *md; + isc_result_t result; + unsigned char buf[256]; // XXX: big enough > 32 unsigned char fwd_buf[256]; unsigned fwd_buflen = 0; @@ -1491,6 +1491,11 @@ static int get_std_dhcid(dhcp_ddns_cb_t if (type < 0 || type > 65535) return (0); + md = isc_md_new(); + if (md == NULL) { + return (0); + } + /* We need to convert the fwd name to wire representation */ if (MRns_name_pton((char *)ddns_cb->fwd_name.data, fwd_buf, 256) == -1) return (0); @@ -1511,17 +1516,41 @@ static int get_std_dhcid(dhcp_ddns_cb_t /* The next is the digest type, SHA-256 is 1 */ putUChar(id->buffer->data + 2, 1u); + /* Computing the digest */ - isc_sha256_init(&sha256); - isc_sha256_update(&sha256, identifier, id_len); - isc_sha256_update(&sha256, fwd_buf, fwd_buflen); - isc_sha256_final(buf, &sha256); + result = isc_md_init(md, ISC_MD_SHA256); + if (result != ISC_R_SUCCESS) { + goto end; + } + + result = isc_md_update(md, identifier, id_len); + if (result != ISC_R_SUCCESS) { + goto end; + } + + result = isc_md_update(md, fwd_buf, fwd_buflen); + if (result != ISC_R_SUCCESS) { + goto end; + } + + result = isc_md_final(md, buf, &id_len); + if (result != ISC_R_SUCCESS) { + goto end; + } + + isc_md_free(md); + md = NULL; memcpy(id->buffer->data + 3, &buf, ISC_SHA256_DIGESTLENGTH); id->len = ISC_SHA256_DIGESTLENGTH + 2 + 1; return (1); +end: + if (md != NULL) { + isc_md_free(md); + } + return (0); } /*! @@ -1551,8 +1580,9 @@ static int get_int_dhcid (dhcp_ddns_cb_t unsigned len) { struct data_string *id = &ddns_cb->dhcid; - unsigned char buf[ISC_MD5_DIGESTLENGTH]; - isc_md5_t md5; + unsigned char buf[256]; // XXX: big enough (> 16) + isc_md_t *md; + isc_result_t result; int i; /* Types can only be 0..(2^16)-1. */ @@ -1584,9 +1614,28 @@ static int get_int_dhcid (dhcp_ddns_cb_t id->buffer->data[2] = "0123456789abcdef"[type % 15]; /* Mash together an MD5 hash of the identifier. */ - isc_md5_init(&md5); - isc_md5_update(&md5, data, len); - isc_md5_final(&md5, buf); + md = isc_md_new(); + if (md == NULL) { + return (0); + } + + result = isc_md_init(md, ISC_MD_MD5); + if (result != ISC_R_SUCCESS) { + goto end; + } + + result = isc_md_update(md, data, len); + if (result != ISC_R_SUCCESS) { + goto end; + } + + result = isc_md_final(md, buf, &len); + if (result != ISC_R_SUCCESS) { + goto end; + } + + isc_md_free(md); + md = NULL; /* Convert into ASCII. */ for (i = 0; i < ISC_MD5_DIGESTLENGTH; i++) { @@ -1601,6 +1650,11 @@ static int get_int_dhcid (dhcp_ddns_cb_t id->terminated = 1; return (1); +end: + if (md != NULL) { + isc_md_free(md); + } + return (0); } int get_dhcid(dhcp_ddns_cb_t *ddns_cb, Index: src/external/mpl/dhcp/dist/omapip/buffer.c diff -u src/external/mpl/dhcp/dist/omapip/buffer.c:1.2 src/external/mpl/dhcp/dist/omapip/buffer.c:1.3 --- src/external/mpl/dhcp/dist/omapip/buffer.c:1.2 Sat Apr 7 18:37:30 2018 +++ src/external/mpl/dhcp/dist/omapip/buffer.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: buffer.c,v 1.2 2018/04/07 22:37:30 christos Exp $ */ +/* $NetBSD: buffer.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* buffer.c @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: buffer.c,v 1.2 2018/04/07 22:37:30 christos Exp $"); +__RCSID("$NetBSD: buffer.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); #include "dhcpd.h" @@ -341,6 +341,7 @@ isc_result_t omapi_connection_copyin (om status = ISC_R_SUCCESS; leave: +#if 0 /* * If we have any bytes to send and we have a proper io object * inform the socket code that we would like to know when we @@ -354,6 +355,7 @@ isc_result_t omapi_connection_copyin (om ISC_SOCKFDWATCH_WRITE); } } +#endif return (status); } Index: src/external/mpl/dhcp/dist/omapip/connection.c diff -u src/external/mpl/dhcp/dist/omapip/connection.c:1.2 src/external/mpl/dhcp/dist/omapip/connection.c:1.3 --- src/external/mpl/dhcp/dist/omapip/connection.c:1.2 Sat Apr 7 18:37:30 2018 +++ src/external/mpl/dhcp/dist/omapip/connection.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: connection.c,v 1.2 2018/04/07 22:37:30 christos Exp $ */ +/* $NetBSD: connection.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* connection.c @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: connection.c,v 1.2 2018/04/07 22:37:30 christos Exp $"); +__RCSID("$NetBSD: connection.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); #include "dhcpd.h" #include <isc/util.h> @@ -843,7 +843,8 @@ isc_result_t omapi_connection_sign_data /* Create the context for the dst module */ if (mode & SIG_MODE_INIT) { - status = dst_context_create(key, dhcp_gbl_ctx.mctx, dctx); + status = dst_context_create(key, dhcp_gbl_ctx.mctx, + ISC_LOGCATEGORY_GENERAL, false, 0, dctx); if (status != ISC_R_SUCCESS) { return status; } Index: src/external/mpl/dhcp/dist/omapip/dispatch.c diff -u src/external/mpl/dhcp/dist/omapip/dispatch.c:1.2 src/external/mpl/dhcp/dist/omapip/dispatch.c:1.3 --- src/external/mpl/dhcp/dist/omapip/dispatch.c:1.2 Sat Apr 7 18:37:30 2018 +++ src/external/mpl/dhcp/dist/omapip/dispatch.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dispatch.c,v 1.2 2018/04/07 22:37:30 christos Exp $ */ +/* $NetBSD: dispatch.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* dispatch.c @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: dispatch.c,v 1.2 2018/04/07 22:37:30 christos Exp $"); +__RCSID("$NetBSD: dispatch.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); #include "dhcpd.h" @@ -121,6 +121,7 @@ trigger_event(struct eventqueue **queue) * 1 is delete, 0 is leave in place */ #define SOCKDELETE 1 +#ifdef ISC_SOCKFDWATCH_READ static int omapi_iscsock_cb(isc_task_t *task, isc_socket_t *socket, @@ -197,6 +198,7 @@ omapi_iscsock_cb(isc_task_t *task, */ return (0); } +#endif /* Register an I/O handle so that we can do asynchronous I/O on it. */ @@ -212,7 +214,9 @@ isc_result_t omapi_register_io_object (o { isc_result_t status; omapi_io_object_t *obj, *p; +#ifdef ISC_SOCKFDWATCH_READ int fd_flags = 0, fd = 0; +#endif /* omapi_io_states is a static object. If its reference count is zero, this is the first I/O handle to be registered, so @@ -250,6 +254,7 @@ isc_result_t omapi_register_io_object (o * a write socket we asssume they are the same socket. */ +#ifdef ISC_SOCKFDWATCH_READ if (readfd) { fd_flags |= ISC_SOCKFDWATCH_READ; fd = readfd(h); @@ -278,6 +283,7 @@ isc_result_t omapi_register_io_object (o return (status); } } +#endif /* Find the last I/O state, if there are any. */ @@ -318,7 +324,9 @@ isc_result_t omapi_reregister_io_object (omapi_object_t *)) { omapi_io_object_t *obj; +#ifdef ISC_SOCKFDWATCH_READ int fd_flags = 0; +#endif if ((!h -> outer) || (h -> outer -> type != omapi_type_io_object)) { /* @@ -344,6 +352,7 @@ isc_result_t omapi_reregister_io_object obj->writer = writer; obj->reaper = reaper; +#ifdef ISC_SOCKFDWATCH_READ if (readfd) { fd_flags |= ISC_SOCKFDWATCH_READ; } @@ -353,6 +362,7 @@ isc_result_t omapi_reregister_io_object } isc_socket_fdwatchpoke(obj->fd, fd_flags); +#endif return (ISC_R_SUCCESS); } Index: src/external/mpl/dhcp/dist/omapip/isclib.c diff -u src/external/mpl/dhcp/dist/omapip/isclib.c:1.2 src/external/mpl/dhcp/dist/omapip/isclib.c:1.3 --- src/external/mpl/dhcp/dist/omapip/isclib.c:1.2 Sat Apr 7 18:37:30 2018 +++ src/external/mpl/dhcp/dist/omapip/isclib.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: isclib.c,v 1.2 2018/04/07 22:37:30 christos Exp $ */ +/* $NetBSD: isclib.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* * Copyright(c) 2009-2017 by Internet Systems Consortium, Inc.("ISC") @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: isclib.c,v 1.2 2018/04/07 22:37:30 christos Exp $"); +__RCSID("$NetBSD: isclib.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); /*Trying to figure out what we need to define to get things to work. It looks like we want/need the library but need the fdwatchcommand @@ -159,9 +159,11 @@ dhcp_context_create(int flags, isc_lib_register(); +#if 0 /* get the current time for use as the random seed */ gettimeofday(&cur_tv, (struct timezone *)0); isc_random_seed(cur_tv.tv_sec); +#endif /* we need to create the memory context before * the lib inits in case we aren't doing NSUPDATE @@ -351,7 +353,7 @@ void dhcp_signal_handler(int signal) { shutdown_signal = signal; /* Use reload (aka suspend) for easier dispatch() reenter. */ - if (ctx && ctx->methods && ctx->methods->ctxsuspend) { + if (ctx) { (void) isc_app_ctxsuspend(ctx); } } @@ -359,7 +361,7 @@ void dhcp_signal_handler(int signal) { isc_result_t dns_client_init() { isc_result_t result; if (dhcp_gbl_ctx.dnsclient == NULL) { - result = dns_client_createx2(dhcp_gbl_ctx.mctx, + result = dns_client_createx(dhcp_gbl_ctx.mctx, dhcp_gbl_ctx.actx, dhcp_gbl_ctx.taskmgr, dhcp_gbl_ctx.socketmgr, Index: src/external/mpl/dhcp/dist/server/dhcpv6.c diff -u src/external/mpl/dhcp/dist/server/dhcpv6.c:1.2 src/external/mpl/dhcp/dist/server/dhcpv6.c:1.3 --- src/external/mpl/dhcp/dist/server/dhcpv6.c:1.2 Sat Apr 7 18:37:30 2018 +++ src/external/mpl/dhcp/dist/server/dhcpv6.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dhcpv6.c,v 1.2 2018/04/07 22:37:30 christos Exp $ */ +/* $NetBSD: dhcpv6.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* * Copyright (C) 2006-2017 by Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: dhcpv6.c,v 1.2 2018/04/07 22:37:30 christos Exp $"); +__RCSID("$NetBSD: dhcpv6.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); /*! \file server/dhcpv6.c */ @@ -1036,7 +1036,7 @@ static void check_pool6_threshold(struct pond->low_threshold = 0; pond->logged = 0; log_error("Pool threshold reset - shared subnet: %s; " - "address: %s; low threshold %llu/%llu.", + "address: %s; low threshold %" PRIu64 "/%" PRIu64 ".", shared_name, inet_ntop(AF_INET6, &lease->addr, tmp_addr, sizeof(tmp_addr)), @@ -1069,7 +1069,7 @@ static void check_pool6_threshold(struct /* we've exceeded it, output a message */ log_error("Pool threshold exceeded - shared subnet: %s; " - "address: %s; high threshold %d%% %llu/%llu.", + "address: %s; high threshold %d%% %" PRIu64 "/%" PRIu64 ".", shared_name, inet_ntop(AF_INET6, &lease->addr, tmp_addr, sizeof(tmp_addr)), poolhigh, used, count); @@ -1441,12 +1441,12 @@ pick_v6_address(struct reply_state *repl if (jumbo_range != 0) { log_debug("Unable to pick client address: " "no addresses available - shared network %s: " - " 2^64-1 < total, %llu active, %llu abandoned", + " 2^64-1 < total, %" PRIu64 " active, %" PRIu64 " abandoned", shared_name, active - abandoned, abandoned); } else { log_debug("Unable to pick client address: " "no addresses available - shared network %s: " - "%llu total, %llu active, %llu abandoned", + "%" PRIu64 " total, %" PRIu64 " active, %" PRIu64 " abandoned", shared_name, total, active - abandoned, abandoned); } Index: src/external/mpl/dhcp/dist/server/mdb6.c diff -u src/external/mpl/dhcp/dist/server/mdb6.c:1.2 src/external/mpl/dhcp/dist/server/mdb6.c:1.3 --- src/external/mpl/dhcp/dist/server/mdb6.c:1.2 Sat Apr 7 18:37:30 2018 +++ src/external/mpl/dhcp/dist/server/mdb6.c Thu Jan 10 12:41:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mdb6.c,v 1.2 2018/04/07 22:37:30 christos Exp $ */ +/* $NetBSD: mdb6.c,v 1.3 2019/01/10 17:41:47 christos Exp $ */ /* * Copyright (C) 2007-2017 by Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: mdb6.c,v 1.2 2018/04/07 22:37:30 christos Exp $"); +__RCSID("$NetBSD: mdb6.c,v 1.3 2019/01/10 17:41:47 christos Exp $"); /*! @@ -181,7 +181,7 @@ __RCSID("$NetBSD: mdb6.c,v 1.2 2018/04/0 #include "dhcpd.h" #include "omapip/omapip.h" #include "omapip/hash.h" -#include <isc/md5.h> +#include <isc/md.h> HASH_FUNCTIONS(ia, unsigned char *, struct ia_xx, ia_hash_t, ia_reference, ia_dereference, do_string_hash) @@ -819,20 +819,13 @@ static void build_address6(struct in6_addr *addr, const struct in6_addr *net_start_addr, int net_bits, const struct data_string *input) { - isc_md5_t ctx; int net_bytes; int i; + unsigned int len; char *str; const char *net_str; - /* - * Use MD5 to get a nice 128 bit hash of the input. - * Yes, we know MD5 isn't cryptographically sound. - * No, we don't care. - */ - isc_md5_init(&ctx); - isc_md5_update(&ctx, input->data, input->len); - isc_md5_final(&ctx, (unsigned char *)addr); + isc_md(ISC_MD_MD5, input->data, input->len, (void *)addr, &len); /* * Copy the [0..128] network bits over. @@ -946,25 +939,22 @@ build_temporary6(struct in6_addr *addr, const struct data_string *input) { static u_int32_t history[2]; static u_int32_t counter = 0; - isc_md5_t ctx; unsigned char md[16]; + unsigned int len; /* * First time/time to reseed. * Please use a good pseudo-random generator here! */ if (counter == 0) { - isc_random_get(&history[0]); - isc_random_get(&history[1]); + history[0] = arc4random(); + history[1] = arc4random(); } /* * Use MD5 as recommended by RFC 4941. */ - isc_md5_init(&ctx); - isc_md5_update(&ctx, (unsigned char *)&history[0], 8UL); - isc_md5_update(&ctx, input->data, input->len); - isc_md5_final(&ctx, md); + isc_md(ISC_MD_MD5, input->data, input->len, (void *)&history[0], &len); /* * Build the address. @@ -1819,9 +1809,9 @@ build_prefix6(struct in6_addr *pref, const struct in6_addr *net_start_pref, int pool_bits, int pref_bits, const struct data_string *input) { - isc_md5_t ctx; int net_bytes; int i; + unsigned int len; char *str; const char *net_str; @@ -1830,9 +1820,7 @@ build_prefix6(struct in6_addr *pref, * Yes, we know MD5 isn't cryptographically sound. * No, we don't care. */ - isc_md5_init(&ctx); - isc_md5_update(&ctx, input->data, input->len); - isc_md5_final(&ctx, (unsigned char *)pref); + isc_md(ISC_MD_MD5, input->data, input->len, (void *)&pref, &len); /* * Copy the network bits over. Index: src/external/mpl/dhcp/include/config.h diff -u src/external/mpl/dhcp/include/config.h:1.1 src/external/mpl/dhcp/include/config.h:1.2 --- src/external/mpl/dhcp/include/config.h:1.1 Sat Apr 7 18:31:37 2018 +++ src/external/mpl/dhcp/include/config.h Thu Jan 10 12:41:48 2019 @@ -324,3 +324,16 @@ /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ /* #undef uint8_t */ + +/* + * XXX: compat + */ +#include <stdbool.h> +#include <limits.h> +#define isc_boolean_t bool +#define ISC_TRUE true +#define ISC_FALSE false +#define isc_uint64_t uint64_t +#define isc_boolean_true true +#define isc_boolean_false false +#define ISC_UINT64_MAX UINT64_MAX