Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/dhcpcd/dist Sync



details:   https://anonhg.NetBSD.org/src/rev/1d5b5b14738e
branches:  trunk
changeset: 345129:1d5b5b14738e
user:      roy <roy%NetBSD.org@localhost>
date:      Mon May 09 10:15:59 2016 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/arp.c            |    29 +-
 external/bsd/dhcpcd/dist/arp.h            |     3 +-
 external/bsd/dhcpcd/dist/auth.c           |    14 +-
 external/bsd/dhcpcd/dist/common.c         |    49 +-
 external/bsd/dhcpcd/dist/common.h         |     7 +-
 external/bsd/dhcpcd/dist/config.h         |     3 +-
 external/bsd/dhcpcd/dist/control.c        |    25 +-
 external/bsd/dhcpcd/dist/control.h        |     6 +-
 external/bsd/dhcpcd/dist/crypt/hmac_md5.c |     8 +-
 external/bsd/dhcpcd/dist/defs.h           |     6 +-
 external/bsd/dhcpcd/dist/dhcp-common.c    |   184 ++-
 external/bsd/dhcpcd/dist/dhcp-common.h    |    74 +-
 external/bsd/dhcpcd/dist/dhcp.c           |  1233 +++++++++++++++-------------
 external/bsd/dhcpcd/dist/dhcp.h           |    88 +-
 external/bsd/dhcpcd/dist/dhcp6.c          |   213 ++--
 external/bsd/dhcpcd/dist/dhcpcd.8.in      |    51 +-
 external/bsd/dhcpcd/dist/dhcpcd.c         |    56 +-
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in |    14 +-
 external/bsd/dhcpcd/dist/dhcpcd.h         |     6 +-
 external/bsd/dhcpcd/dist/duid.c           |    61 +-
 external/bsd/dhcpcd/dist/eloop.c          |    13 +-
 external/bsd/dhcpcd/dist/if-bsd.c         |   167 ++-
 external/bsd/dhcpcd/dist/if-options.c     |   143 ++-
 external/bsd/dhcpcd/dist/if-options.h     |     4 +-
 external/bsd/dhcpcd/dist/if.c             |    27 +-
 external/bsd/dhcpcd/dist/if.h             |    10 +-
 external/bsd/dhcpcd/dist/ipv4.c           |    67 +-
 external/bsd/dhcpcd/dist/ipv4.h           |     6 +-
 external/bsd/dhcpcd/dist/ipv4ll.c         |    11 +-
 external/bsd/dhcpcd/dist/ipv6.c           |   143 ++-
 external/bsd/dhcpcd/dist/ipv6.h           |    36 +-
 external/bsd/dhcpcd/dist/script.c         |    21 +-
 32 files changed, 1557 insertions(+), 1221 deletions(-)

diffs (truncated from 6130 to 300 lines):

diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c    Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c    Mon May 09 10:15:59 2016 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.18 2016/04/20 08:53:01 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.19 2016/05/09 10:15:59 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -175,8 +175,13 @@
                            memcmp(hw_s, ifn->hwaddr, ifn->hwlen) == 0)
                                break;
                }
-               if (ifn)
+               if (ifn) {
+#if 0
+                       logger(ifp->ctx, LOG_DEBUG,
+                           "%s: ignoring ARP from self", ifp->name);
+#endif
                        continue;
+               }
                /* Copy out the HW and IP addresses */
                memcpy(&arm.sha, hw_s, ar.ar_hln);
                memcpy(&arm.sip.s_addr, hw_s + ar.ar_hln, ar.ar_pln);
@@ -191,7 +196,7 @@
        }
 }
 
-static void
+int
 arp_open(struct interface *ifp)
 {
        struct iarp_state *state;
@@ -202,10 +207,11 @@
                if (state->fd == -1) {
                        logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
                            __func__, ifp->name);
-                       return;
+                       return -1;
                }
                eloop_event_add(ifp->ctx->eloop, state->fd, arp_packet, ifp);
        }
+       return state->fd;
 }
 
 static void
@@ -218,8 +224,7 @@
                return;
        }
 
-       /* Nothing more to do, so free us */
-       arp_free(astate);
+       /* Keep ARP open so we can detect duplicates. */
 }
 
 static void
@@ -250,7 +255,11 @@
 arp_announce(struct arp_state *astate)
 {
 
-       arp_open(astate->iface);
+       if (arp_open(astate->iface) == -1) {
+               logger(astate->iface->ctx, LOG_ERR,
+                   "%s: %s: %m", __func__, astate->iface->name);
+               return;
+       }
        astate->claims = 0;
        arp_announce1(astate);
 }
@@ -294,7 +303,11 @@
 arp_probe(struct arp_state *astate)
 {
 
-       arp_open(astate->iface);
+       if (arp_open(astate->iface) == -1) {
+               logger(astate->iface->ctx, LOG_ERR,
+                   "%s: %s: %m", __func__, astate->iface->name);
+               return;
+       }
        astate->probes = 0;
        logger(astate->iface->ctx, LOG_DEBUG, "%s: probing for %s",
            astate->iface->name, inet_ntoa(astate->addr));
diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/arp.h
--- a/external/bsd/dhcpcd/dist/arp.h    Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/arp.h    Mon May 09 10:15:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arp.h,v 1.12 2016/04/20 08:53:01 roy Exp $ */
+/* $NetBSD: arp.h,v 1.13 2016/05/09 10:15:59 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -79,6 +79,7 @@
        ((const struct iarp_state *)(ifp)->if_data[IF_DATA_ARP])
 
 #ifdef INET
+int arp_open(struct interface *);
 ssize_t arp_request(const struct interface *, in_addr_t, in_addr_t);
 void arp_report_conflicted(const struct arp_state *, const struct arp_msg *);
 void arp_announce(struct arp_state *);
diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/auth.c
--- a/external/bsd/dhcpcd/dist/auth.c   Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/auth.c   Mon May 09 10:15:59 2016 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: auth.c,v 1.10 2015/07/09 10:15:34 roy Exp $");
+ __RCSID("$NetBSD: auth.c,v 1.11 2016/05/09 10:15:59 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -323,8 +323,8 @@
 
        /* RFC3318, section 5.2 - zero giaddr and hops */
        if (mp == 4) {
-               *(mm + offsetof(struct dhcp_message, hwopcount)) = '\0';
-               memset(mm + offsetof(struct dhcp_message, giaddr), 0, 4);
+               *(mm + offsetof(struct bootp, hops)) = '\0';
+               memset(mm + offsetof(struct bootp, giaddr), 0, 4);
        }
 
        memset(hmac, 0, sizeof(hmac));
@@ -641,10 +641,10 @@
 
        /* RFC3318, section 5.2 - zero giaddr and hops */
        if (mp == 4) {
-               p = m + offsetof(struct dhcp_message, hwopcount);
+               p = m + offsetof(struct bootp, hops);
                hops = *p;
                *p = '\0';
-               p = m + offsetof(struct dhcp_message, giaddr);
+               p = m + offsetof(struct bootp, giaddr);
                memcpy(&giaddr, p, sizeof(giaddr));
                memset(p, 0, sizeof(giaddr));
        } else {
@@ -663,9 +663,9 @@
 
        /* RFC3318, section 5.2 - restore giaddr and hops */
        if (mp == 4) {
-               p = m + offsetof(struct dhcp_message, hwopcount);
+               p = m + offsetof(struct bootp, hops);
                *p = hops;
-               p = m + offsetof(struct dhcp_message, giaddr);
+               p = m + offsetof(struct bootp, giaddr);
                memcpy(p, &giaddr, sizeof(giaddr));
        }
 
diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/common.c
--- a/external/bsd/dhcpcd/dist/common.c Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/common.c Mon May 09 10:15:59 2016 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: common.c,v 1.19 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: common.c,v 1.20 2016/05/09 10:15:59 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -279,7 +279,7 @@
 }
 
 char *
-hwaddr_ntoa(const unsigned char *hwaddr, size_t hwlen, char *buf, size_t buflen)
+hwaddr_ntoa(const uint8_t *hwaddr, size_t hwlen, char *buf, size_t buflen)
 {
        char *p;
        size_t i;
@@ -304,16 +304,18 @@
 }
 
 size_t
-hwaddr_aton(unsigned char *buffer, const char *addr)
+hwaddr_aton(uint8_t *buffer, const char *addr)
 {
        char c[3];
        const char *p = addr;
-       unsigned char *bp = buffer;
+       uint8_t *bp = buffer;
        size_t len = 0;
 
        c[2] = '\0';
        while (*p) {
                c[0] = *p++;
+               if (c[0] == '\n')
+                       continue;
                c[1] = *p++;
                /* Ensure that digits are hex */
                if (isxdigit((unsigned char)c[0]) == 0 ||
@@ -328,15 +330,50 @@
                        return 0;
                }
                /* Ensure that next data is EOL or a seperator with data */
-               if (!(*p == '\0' || (*p == ':' && *(p + 1) != '\0'))) {
+               if (!(*p == '\0' || *p == '\n' ||
+                   (*p == ':' && *(p + 1) != '\0')))
+               {
                        errno = EINVAL;
                        return 0;
                }
                if (*p)
                        p++;
                if (bp)
-                       *bp++ = (unsigned char)strtol(c, NULL, 16);
+                       *bp++ = (uint8_t)strtol(c, NULL, 16);
                len++;
        }
        return len;
 }
+
+size_t
+read_hwaddr_aton(uint8_t **data, const char *path)
+{
+       FILE *fp;
+       char *buf;
+       size_t buf_len, len;
+       ssize_t llen;
+
+       if ((fp = fopen(path, "r")) == NULL)
+               return 0;
+
+       buf = NULL;
+       buf_len = len = 0;
+       *data = NULL;
+       while ((llen = getline(&buf, &buf_len, fp)) != -1) {
+               if ((len = hwaddr_aton(NULL, buf)) != 0) {
+                       if (buf_len >= len)
+                               *data = (uint8_t *)buf;
+                       else {
+                               if ((*data = malloc(len)) == NULL)
+                                       len = 0;
+                       }
+                       if (len != 0)
+                               (void)hwaddr_aton(*data, buf);
+                       if (buf_len < len)
+                               free(buf);
+                       break;
+               }
+       }
+       fclose(fp);
+       return len;
+}
diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/common.h
--- a/external/bsd/dhcpcd/dist/common.h Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/common.h Mon May 09 10:15:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: common.h,v 1.13 2016/04/10 21:00:53 roy Exp $ */
+/* $NetBSD: common.h,v 1.14 2016/05/09 10:15:59 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -195,6 +195,7 @@
 ssize_t addvard(struct dhcpcd_ctx *,
     char ***, const char *, const char *, size_t);
 
-char *hwaddr_ntoa(const unsigned char *, size_t, char *, size_t);
-size_t hwaddr_aton(unsigned char *, const char *);
+char *hwaddr_ntoa(const uint8_t *, size_t, char *, size_t);
+size_t hwaddr_aton(uint8_t *, const char *);
+size_t read_hwaddr_aton(uint8_t **, const char *);
 #endif
diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/config.h
--- a/external/bsd/dhcpcd/dist/config.h Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/config.h Mon May 09 10:15:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.10 2016/04/10 21:00:53 roy Exp $ */
+/* $NetBSD: config.h,v 1.11 2016/05/09 10:15:59 roy Exp $ */
 
 /* netbsd */
 #define SYSCONFDIR     "/etc"
@@ -10,6 +10,7 @@
 #define HAVE_UTIL_H
 #define HAVE_SYS_QUEUE_H
 #define HAVE_SPAWN_H
+#define HAVE_REALLOCARRAY
 #define HAVE_KQUEUE
 #define HAVE_KQUEUE1
 #define HAVE_SYS_BITOPS_H
diff -r 19db062c1f98 -r 1d5b5b14738e external/bsd/dhcpcd/dist/control.c
--- a/external/bsd/dhcpcd/dist/control.c        Mon May 09 07:02:10 2016 +0000
+++ b/external/bsd/dhcpcd/dist/control.c        Mon May 09 10:15:59 2016 +0000
@@ -1,9 +1,9 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: control.c,v 1.12 2016/04/20 08:53:01 roy Exp $");
+ __RCSID("$NetBSD: control.c,v 1.13 2016/05/09 10:15:59 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2016 Roy Marples <roy%marples.name@localhost>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -314,20 +314,21 @@
 }
 
 int
-control_open(struct dhcpcd_ctx *ctx, const char *ifname)
+control_open(const char *ifname)
 {
        struct sockaddr_un sa;
-       socklen_t len;
+       int fd;



Home | Main Index | Thread Index | Old Index