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/bd6d5d9587a6
branches: trunk
changeset: 352433:bd6d5d9587a6
user: roy <roy%NetBSD.org@localhost>
date: Fri Mar 31 20:53:55 2017 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/.gitignore | 28 +
external/bsd/dhcpcd/dist/arp.c | 471 -
external/bsd/dhcpcd/dist/arp.h | 99 -
external/bsd/dhcpcd/dist/auth.h | 94 -
external/bsd/dhcpcd/dist/bpf-filter.h | 103 -
external/bsd/dhcpcd/dist/common.c | 434 -
external/bsd/dhcpcd/dist/common.h | 207 -
external/bsd/dhcpcd/dist/config.h | 21 -
external/bsd/dhcpcd/dist/control.c | 427 -
external/bsd/dhcpcd/dist/control.h | 66 -
external/bsd/dhcpcd/dist/crypt/crypt.h | 35 -
external/bsd/dhcpcd/dist/crypt/hmac_md5.c | 94 -
external/bsd/dhcpcd/dist/defs.h | 78 -
external/bsd/dhcpcd/dist/dev.h | 62 -
external/bsd/dhcpcd/dist/dhcp-common.c | 1097 ----
external/bsd/dhcpcd/dist/dhcp-common.h | 125 -
external/bsd/dhcpcd/dist/dhcp.c | 3736 -------------
external/bsd/dhcpcd/dist/dhcp.h | 278 -
external/bsd/dhcpcd/dist/dhcp6.c | 3755 --------------
external/bsd/dhcpcd/dist/dhcp6.h | 271 -
external/bsd/dhcpcd/dist/dhcpcd-definitions-small.conf | 125 -
external/bsd/dhcpcd/dist/dhcpcd-definitions.conf | 589 --
external/bsd/dhcpcd/dist/dhcpcd-embedded.c.in | 36 -
external/bsd/dhcpcd/dist/dhcpcd-embedded.h.in | 32 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test | 10 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump | 10 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/10-wpa_supplicant | 121 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/15-timezone | 50 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf | 206 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/29-lookup-hostname | 42 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname | 157 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf | 143 -
external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ypbind | 88 -
external/bsd/dhcpcd/dist/dhcpcd-run-hooks.8.in | 218 -
external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in | 389 -
external/bsd/dhcpcd/dist/dhcpcd.8.in | 815 ---
external/bsd/dhcpcd/dist/dhcpcd.c | 1991 -------
external/bsd/dhcpcd/dist/dhcpcd.conf | 40 -
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in | 919 ---
external/bsd/dhcpcd/dist/dhcpcd.h | 208 -
external/bsd/dhcpcd/dist/duid.c | 165 -
external/bsd/dhcpcd/dist/duid.h | 37 -
external/bsd/dhcpcd/dist/eloop.c | 982 ---
external/bsd/dhcpcd/dist/eloop.h | 113 -
external/bsd/dhcpcd/dist/genembedc | 18 -
external/bsd/dhcpcd/dist/genembedh | 17 -
external/bsd/dhcpcd/dist/if-bsd.c | 1914 -------
external/bsd/dhcpcd/dist/if-options.c | 2654 ---------
external/bsd/dhcpcd/dist/if-options.h | 231 -
external/bsd/dhcpcd/dist/if.c | 768 --
external/bsd/dhcpcd/dist/if.h | 220 -
external/bsd/dhcpcd/dist/ipv4.c | 1378 -----
external/bsd/dhcpcd/dist/ipv4.h | 175 -
external/bsd/dhcpcd/dist/ipv4ll.c | 497 -
external/bsd/dhcpcd/dist/ipv4ll.h | 85 -
external/bsd/dhcpcd/dist/ipv6.c | 2609 ---------
external/bsd/dhcpcd/dist/ipv6.h | 354 -
external/bsd/dhcpcd/dist/ipv6nd.c | 1701 ------
external/bsd/dhcpcd/dist/ipv6nd.h | 128 -
external/bsd/dhcpcd/dist/script.c | 804 --
external/bsd/dhcpcd/dist/script.h | 39 -
61 files changed, 28 insertions(+), 32531 deletions(-)
diffs (truncated from 32803 to 300 lines):
diff -r f76f4a132120 -r bd6d5d9587a6 external/bsd/dhcpcd/dist/.gitignore
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/.gitignore Fri Mar 31 20:53:55 2017 +0000
@@ -0,0 +1,28 @@
+# Ignore configure generated files
+config.h
+config.mk
+config.log
+
+# Ignore object files
+.depend
+*.o
+*.So
+*.so
+dhcpcd
+
+# Ignore generated embedded files
+dhcpcd-embedded.c
+dhcpcd-embedded.h
+
+# Ignore generated man pages and scripts
+dhcpcd.8
+dhcpcd-run-hooks
+dhcpcd-run-hooks.8
+dhcpcd.conf.5
+hooks/50-ypbind
+
+# Ignore distribution
+dhcpcd*.xz*
+
+# Ignore Coverity
+cov-int
diff -r f76f4a132120 -r bd6d5d9587a6 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c Fri Mar 31 20:51:14 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,471 +0,0 @@
-#include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.22 2016/10/09 09:18:26 roy Exp $");
-
-/*
- * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy%marples.name@localhost>
- * All rights reserved
-
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/socket.h>
-#include <sys/types.h>
-
-#include <arpa/inet.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define ELOOP_QUEUE 5
-#include "config.h"
-#include "arp.h"
-#include "if.h"
-#include "ipv4.h"
-#include "common.h"
-#include "dhcpcd.h"
-#include "eloop.h"
-#include "if.h"
-#include "if-options.h"
-#include "ipv4ll.h"
-
-#define ARP_LEN \
- (sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN))
-
-ssize_t
-arp_request(const struct interface *ifp, in_addr_t sip, in_addr_t tip)
-{
- uint8_t arp_buffer[ARP_LEN];
- struct arphdr ar;
- size_t len;
- uint8_t *p;
- const struct iarp_state *state;
-
- ar.ar_hrd = htons(ifp->family);
- ar.ar_pro = htons(ETHERTYPE_IP);
- ar.ar_hln = ifp->hwlen;
- ar.ar_pln = sizeof(sip);
- ar.ar_op = htons(ARPOP_REQUEST);
-
- p = arp_buffer;
- len = 0;
-
-#define CHECK(fun, b, l) \
- do { \
- if (len + (l) > sizeof(arp_buffer)) \
- goto eexit; \
- fun(p, (b), (l)); \
- p += (l); \
- len += (l); \
- } while (/* CONSTCOND */ 0)
-#define APPEND(b, l) CHECK(memcpy, b, l)
-#define ZERO(l) CHECK(memset, 0, l)
-
- APPEND(&ar, sizeof(ar));
- APPEND(ifp->hwaddr, ifp->hwlen);
- APPEND(&sip, sizeof(sip));
- ZERO(ifp->hwlen);
- APPEND(&tip, sizeof(tip));
-
- state = ARP_CSTATE(ifp);
- return if_sendraw(ifp, state->fd, ETHERTYPE_ARP, arp_buffer, len);
-
-eexit:
- errno = ENOBUFS;
- return -1;
-}
-
-void
-arp_report_conflicted(const struct arp_state *astate,
- const struct arp_msg *amsg)
-{
-
- if (amsg != NULL) {
- char buf[HWADDR_LEN * 3];
-
- logger(astate->iface->ctx, LOG_ERR,
- "%s: hardware address %s claims %s",
- astate->iface->name,
- hwaddr_ntoa(amsg->sha, astate->iface->hwlen,
- buf, sizeof(buf)),
- inet_ntoa(astate->failed));
- } else
- logger(astate->iface->ctx, LOG_ERR,
- "%s: DAD detected %s",
- astate->iface->name, inet_ntoa(astate->failed));
-}
-
-static void
-arp_packet(struct interface *ifp, uint8_t *data, size_t len)
-{
- const struct interface *ifn;
- struct arphdr ar;
- struct arp_msg arm;
- const struct iarp_state *state;
- struct arp_state *astate, *astaten;
- uint8_t *hw_s, *hw_t;
-
- /* We must have a full ARP header */
- if (len < sizeof(ar))
- return;
- memcpy(&ar, data, sizeof(ar));
- /* Families must match */
- if (ar.ar_hrd != htons(ifp->family))
- return;
-#if 0
- /* These checks are enforced in the BPF filter. */
- /* Protocol must be IP. */
- if (ar.ar_pro != htons(ETHERTYPE_IP))
- continue;
- /* Only these types are recognised */
- if (ar.ar_op != htons(ARPOP_REPLY) &&
- ar.ar_op != htons(ARPOP_REQUEST))
- continue;
-#endif
- if (ar.ar_pln != sizeof(arm.sip.s_addr))
- return;
-
- /* Get pointers to the hardware addreses */
- hw_s = data + sizeof(ar);
- hw_t = hw_s + ar.ar_hln + ar.ar_pln;
- /* Ensure we got all the data */
- if ((size_t)((hw_t + ar.ar_hln + ar.ar_pln) - data) > len)
- return;
- /* Ignore messages from ourself */
- TAILQ_FOREACH(ifn, ifp->ctx->ifaces, next) {
- if (ar.ar_hln == ifn->hwlen &&
- memcmp(hw_s, ifn->hwaddr, ifn->hwlen) == 0)
- break;
- }
- if (ifn) {
-#if 0
- logger(ifp->ctx, LOG_DEBUG,
- "%s: ignoring ARP from self", ifp->name);
-#endif
- return;
- }
- /* 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);
- memcpy(&arm.tha, hw_t, ar.ar_hln);
- memcpy(&arm.tip.s_addr, hw_t + ar.ar_hln, ar.ar_pln);
-
- /* Run the conflicts */
- state = ARP_CSTATE(ifp);
- TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, astaten) {
- if (astate->conflicted_cb)
- astate->conflicted_cb(astate, &arm);
- }
-}
-
-static void
-arp_read(void *arg)
-{
- struct interface *ifp = arg;
- const struct iarp_state *state;
- uint8_t buf[ARP_LEN];
- int flags;
- ssize_t bytes;
-
- /* Some RAW mechanisms are generic file descriptors, not sockets.
- * This means we have no kernel call to just get one packet,
- * so we have to process the entire buffer. */
- state = ARP_CSTATE(ifp);
- flags = 0;
- while (!(flags & RAW_EOF)) {
- bytes = if_readraw(ifp, state->fd, buf, sizeof(buf), &flags);
- if (bytes == -1) {
- logger(ifp->ctx, LOG_ERR,
- "%s: arp if_readrawpacket: %m", ifp->name);
- arp_close(ifp);
- return;
- }
- arp_packet(ifp, buf, (size_t)bytes);
- }
-}
-
-int
-arp_open(struct interface *ifp)
-{
- struct iarp_state *state;
-
- state = ARP_STATE(ifp);
- if (state->fd == -1) {
- state->fd = if_openraw(ifp, ETHERTYPE_ARP);
- if (state->fd == -1) {
- logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
- __func__, ifp->name);
- return -1;
- }
- eloop_event_add(ifp->ctx->eloop, state->fd, arp_read, ifp);
- }
- return state->fd;
-}
-
-static void
-arp_announced(void *arg)
-{
- struct arp_state *astate = arg;
-
- if (astate->announced_cb) {
- astate->announced_cb(astate);
- return;
- }
-
- /* Keep ARP open so we can detect duplicates. */
-}
-
-static void
-arp_announce1(void *arg)
-{
- struct arp_state *astate = arg;
- struct interface *ifp = astate->iface;
-
- if (++astate->claims < ANNOUNCE_NUM)
- logger(ifp->ctx, LOG_DEBUG,
- "%s: ARP announcing %s (%d of %d), "
- "next in %d.0 seconds",
- ifp->name, inet_ntoa(astate->addr),
- astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
- else
- logger(ifp->ctx, LOG_DEBUG,
- "%s: ARP announcing %s (%d of %d)",
- ifp->name, inet_ntoa(astate->addr),
- astate->claims, ANNOUNCE_NUM);
- if (arp_request(ifp, astate->addr.s_addr, astate->addr.s_addr) == -1)
- logger(ifp->ctx, LOG_ERR, "send_arp: %m");
- eloop_timeout_add_sec(ifp->ctx->eloop, ANNOUNCE_WAIT,
- astate->claims < ANNOUNCE_NUM ? arp_announce1 : arp_announced,
Home |
Main Index |
Thread Index |
Old Index