Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/mpl/dhcp Gut omapip support since the socket stuff ...



details:   https://anonhg.NetBSD.org/src/rev/ca3ddb68542c
branches:  trunk
changeset: 995931:ca3ddb68542c
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 10 17:41:47 2019 +0000

description:
Gut omapip support since the socket stuff to support it is gone, and
adjust to the new isc library reality.

diffstat:

 external/mpl/dhcp/Makefile.inc             |   4 +-
 external/mpl/dhcp/dist/common/dns.c        |  84 ++++++++++++++++++++++++-----
 external/mpl/dhcp/dist/omapip/buffer.c     |   6 +-
 external/mpl/dhcp/dist/omapip/connection.c |   7 +-
 external/mpl/dhcp/dist/omapip/dispatch.c   |  14 ++++-
 external/mpl/dhcp/dist/omapip/isclib.c     |  10 ++-
 external/mpl/dhcp/dist/server/dhcpv6.c     |  12 ++--
 external/mpl/dhcp/dist/server/mdb6.c       |  34 +++--------
 external/mpl/dhcp/include/config.h         |  13 ++++
 9 files changed, 127 insertions(+), 57 deletions(-)

diffs (truncated from 539 to 300 lines):

diff -r f68e244771a9 -r ca3ddb68542c external/mpl/dhcp/Makefile.inc
--- a/external/mpl/dhcp/Makefile.inc    Thu Jan 10 17:05:56 2019 +0000
+++ b/external/mpl/dhcp/Makefile.inc    Thu Jan 10 17:41:47 2019 +0000
@@ -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 @@
                        -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}
diff -r f68e244771a9 -r ca3ddb68542c external/mpl/dhcp/dist/common/dns.c
--- a/external/mpl/dhcp/dist/common/dns.c       Thu Jan 10 17:05:56 2019 +0000
+++ b/external/mpl/dhcp/dist/common/dns.c       Thu Jan 10 17:41:47 2019 +0000
@@ -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 @@
                  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 @@
        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 @@
        /* 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 @@
                   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 @@
        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 @@
        id->terminated = 1;
 
        return (1);
+end:
+       if (md != NULL) {
+               isc_md_free(md);
+       }
+       return (0);
 }
 
 int get_dhcid(dhcp_ddns_cb_t *ddns_cb,
diff -r f68e244771a9 -r ca3ddb68542c external/mpl/dhcp/dist/omapip/buffer.c
--- a/external/mpl/dhcp/dist/omapip/buffer.c    Thu Jan 10 17:05:56 2019 +0000
+++ b/external/mpl/dhcp/dist/omapip/buffer.c    Thu Jan 10 17:41:47 2019 +0000
@@ -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 @@
        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_SOCKFDWATCH_WRITE);
                }
        }
+#endif
 
        return (status);
 }
diff -r f68e244771a9 -r ca3ddb68542c external/mpl/dhcp/dist/omapip/connection.c
--- a/external/mpl/dhcp/dist/omapip/connection.c        Thu Jan 10 17:05:56 2019 +0000
+++ b/external/mpl/dhcp/dist/omapip/connection.c        Thu Jan 10 17:41:47 2019 +0000
@@ -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 @@
 
        /* 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;
                }
diff -r f68e244771a9 -r ca3ddb68542c external/mpl/dhcp/dist/omapip/dispatch.c
--- a/external/mpl/dhcp/dist/omapip/dispatch.c  Thu Jan 10 17:05:56 2019 +0000
+++ b/external/mpl/dhcp/dist/omapip/dispatch.c  Thu Jan 10 17:41:47 2019 +0000
@@ -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 @@
  * 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 @@
         */
        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 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 @@
         * 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 @@
                        return (status);
                }
        }
+#endif
 
 
        /* Find the last I/O state, if there are any. */
@@ -318,7 +324,9 @@
                                                (omapi_object_t *))
 {
        omapi_io_object_t *obj;
+#ifdef ISC_SOCKFDWATCH_READ
        int fd_flags = 0;
+#endif
 



Home | Main Index | Thread Index | Old Index