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/38f6bf6dc277
branches: trunk
changeset: 326999:38f6bf6dc277
user: roy <roy%NetBSD.org@localhost>
date: Tue Feb 25 13:20:23 2014 +0000
description:
Sync
diffstat:
external/bsd/dhcpcd/dist/dhcp.c | 764 +++++++++++++++++++++--------
external/bsd/dhcpcd/dist/dhcpcd.8.in | 38 +-
external/bsd/dhcpcd/dist/dhcpcd.conf.5.in | 100 +++-
external/bsd/dhcpcd/dist/if-bsd.c | 183 ++++--
external/bsd/dhcpcd/dist/if-options.c | 439 +++++++++++++---
external/bsd/dhcpcd/dist/ipv6nd.c | 537 ++++++++++----------
external/bsd/dhcpcd/dist/net.c | 106 ++-
external/bsd/dhcpcd/dist/script.c | 40 +-
8 files changed, 1485 insertions(+), 722 deletions(-)
diffs (truncated from 4551 to 300 lines):
diff -r 6a23d5c2b017 -r 38f6bf6dc277 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c Tue Feb 25 13:16:04 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c Tue Feb 25 13:20:23 2014 +0000
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.9 2014/01/15 20:43:21 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.10 2014/02/25 13:20:23 roy Exp $");
/*
* dhcpcd - DHCP client daemon
@@ -57,8 +57,8 @@
#include <syslog.h>
#include <unistd.h>
+#include "config.h"
#include "arp.h"
-#include "config.h"
#include "common.h"
#include "dhcp.h"
#include "dhcpcd.h"
@@ -72,13 +72,6 @@
#define DAD "Duplicate address detected"
#define DHCP_MIN_LEASE 20
-static uint8_t *packet;
-
-/* Our aggregate option buffer.
- * We ONLY use this when options are split, which for most purposes is
- * practically never. See RFC3396 for details. */
-static uint8_t *opt_buffer;
-
#define IPV4A ADDRIPV4 | ARRAY
#define IPV4R ADDRIPV4 | REQUEST
@@ -96,14 +89,15 @@
};
static const struct dhcp_op dhcp_ops[] = {
- { DHCP_DISCOVER, "DISCOVER" },
- { DHCP_OFFER, "OFFER" },
- { DHCP_REQUEST, "REQUEST" },
- { DHCP_DECLINE, "DECLINE" },
- { DHCP_ACK, "ACK" },
- { DHCP_NAK, "NAK" },
- { DHCP_RELEASE, "RELEASE" },
- { DHCP_INFORM, "INFORM" },
+ { DHCP_DISCOVER, "DISCOVER" },
+ { DHCP_OFFER, "OFFER" },
+ { DHCP_REQUEST, "REQUEST" },
+ { DHCP_DECLINE, "DECLINE" },
+ { DHCP_ACK, "ACK" },
+ { DHCP_NAK, "NAK" },
+ { DHCP_RELEASE, "RELEASE" },
+ { DHCP_INFORM, "INFORM" },
+ { DHCP_FORCERENEW, "DHCP_FORCERENEW"},
{ 0, NULL }
};
@@ -123,15 +117,12 @@
struct dhcp_message dhcp;
};
-struct dhcp_opt *dhcp_opts = NULL;
-size_t dhcp_opts_len = 0;
-
static const size_t udp_dhcp_len = sizeof(struct udp_dhcp_packet);
static int dhcp_open(struct interface *);
void
-dhcp_printoptions(void)
+dhcp_printoptions(const struct dhcpcd_ctx *ctx)
{
const char * const *p;
size_t i;
@@ -140,23 +131,14 @@
for (p = dhcp_params; *p; p++)
printf(" %s\n", *p);
- for (i = 0, opt = dhcp_opts; i < dhcp_opts_len; i++, opt++)
+ for (i = 0, opt = ctx->dhcp_opts; i < ctx->dhcp_opts_len; i++, opt++)
printf("%03d %s\n", opt->option, opt->var);
}
-#ifdef DEBUG_MEMORY
-static void
-dhcp_cleanup(void)
-{
-
- free(packet);
- free(opt_buffer);
-}
-#endif
-
-#define get_option_raw(dhcp, opt) get_option(dhcp, opt, NULL)
+#define get_option_raw(ctx, dhcp, opt) get_option(ctx, dhcp, opt, NULL)
static const uint8_t *
-get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len)
+get_option(struct dhcpcd_ctx *ctx,
+ const struct dhcp_message *dhcp, uint8_t opt, int *len)
{
const uint8_t *p = dhcp->options;
const uint8_t *e = p + sizeof(dhcp->options);
@@ -171,13 +153,13 @@
o = *p++;
if (o == opt) {
if (op) {
- if (!opt_buffer) {
- opt_buffer = malloc(sizeof(*dhcp));
- if (opt_buffer == NULL)
+ if (!ctx->opt_buffer) {
+ ctx->opt_buffer = malloc(sizeof(*dhcp));
+ if (ctx->opt_buffer == NULL)
return NULL;
}
if (!bp)
- bp = opt_buffer;
+ bp = ctx->opt_buffer;
memcpy(bp, op, ol);
bp += ol;
}
@@ -221,7 +203,7 @@
*len = bl;
if (bp) {
memcpy(bp, op, ol);
- return (const uint8_t *)opt_buffer;
+ return (const uint8_t *)ctx->opt_buffer;
}
if (op)
return op;
@@ -230,13 +212,14 @@
}
int
-get_option_addr(struct in_addr *a, const struct dhcp_message *dhcp,
+get_option_addr(struct dhcpcd_ctx *ctx,
+ struct in_addr *a, const struct dhcp_message *dhcp,
uint8_t option)
{
const uint8_t *p;
int len;
- p = get_option(dhcp, option, &len);
+ p = get_option(ctx, dhcp, option, &len);
if (!p || len < (ssize_t)sizeof(a->s_addr))
return -1;
memcpy(&a->s_addr, p, sizeof(a->s_addr));
@@ -244,13 +227,14 @@
}
static int
-get_option_uint32(uint32_t *i, const struct dhcp_message *dhcp, uint8_t option)
+get_option_uint32(struct dhcpcd_ctx *ctx,
+ uint32_t *i, const struct dhcp_message *dhcp, uint8_t option)
{
const uint8_t *p;
int len;
uint32_t d;
- p = get_option(dhcp, option, &len);
+ p = get_option(ctx, dhcp, option, &len);
if (!p || len < (ssize_t)sizeof(d))
return -1;
memcpy(&d, p, sizeof(d));
@@ -260,12 +244,13 @@
}
static int
-get_option_uint8(uint8_t *i, const struct dhcp_message *dhcp, uint8_t option)
+get_option_uint8(struct dhcpcd_ctx *ctx,
+ uint8_t *i, const struct dhcp_message *dhcp, uint8_t option)
{
const uint8_t *p;
int len;
- p = get_option(dhcp, option, &len);
+ p = get_option(ctx, dhcp, option, &len);
if (!p || len < (ssize_t)sizeof(*p))
return -1;
if (i)
@@ -500,14 +485,15 @@
return bytes;
}
-char *
-get_option_string(const struct dhcp_message *dhcp, uint8_t option)
+static char *
+get_option_string(struct dhcpcd_ctx *ctx,
+ const struct dhcp_message *dhcp, uint8_t option)
{
int len;
const uint8_t *p;
char *s;
- p = get_option(dhcp, option, &len);
+ p = get_option(ctx, dhcp, option, &len);
if (!p || len == 0 || *p == '\0')
return NULL;
@@ -564,12 +550,12 @@
/* If we have CSR's then we MUST use these only */
if (!has_option_mask(ifo->nomask, DHO_CSR))
- p = get_option(dhcp, DHO_CSR, &len);
+ p = get_option(ifp->ctx, dhcp, DHO_CSR, &len);
else
p = NULL;
/* Check for crappy MS option */
if (!p && !has_option_mask(ifo->nomask, DHO_MSCSR)) {
- p = get_option(dhcp, DHO_MSCSR, &len);
+ p = get_option(ifp->ctx, dhcp, DHO_MSCSR, &len);
if (p)
csr = "MS ";
}
@@ -594,7 +580,7 @@
}
TAILQ_INIT(routes);
if (!has_option_mask(ifo->nomask, DHO_STATICROUTE))
- p = get_option(dhcp, DHO_STATICROUTE, &len);
+ p = get_option(ifp->ctx, dhcp, DHO_STATICROUTE, &len);
else
p = NULL;
if (p) {
@@ -617,7 +603,7 @@
/* Now grab our routers */
if (!has_option_mask(ifo->nomask, DHO_ROUTER))
- p = get_option(dhcp, DHO_ROUTER, &len);
+ p = get_option(ifp->ctx, dhcp, DHO_ROUTER, &len);
else
p = NULL;
if (p) {
@@ -676,16 +662,18 @@
uint8_t type)
{
struct dhcp_message *dhcp;
- uint8_t *m, *lp, *p;
+ uint8_t *m, *lp, *p, *auth;
uint8_t *n_params = NULL;
uint32_t ul;
uint16_t sz;
size_t len, i;
+ int auth_len;
const struct dhcp_opt *opt;
- const struct if_options *ifo = iface->options;
+ struct if_options *ifo = iface->options;
const struct dhcp_state *state = D_CSTATE(iface);
const struct dhcp_lease *lease = &state->lease;
time_t up = uptime() - state->start_uptime;
+ char hbuf[HOSTNAME_MAX_LEN + 1];
const char *hostname;
const struct vivco *vivco;
@@ -767,7 +755,7 @@
}
if (type == DHCP_DISCOVER &&
- !(options & DHCPCD_TEST) &&
+ !(iface->ctx->options & DHCPCD_TEST) &&
has_option_mask(ifo->requestmask, DHO_RAPIDCOMMIT))
{
/* RFC 4039 Section 3 */
@@ -778,6 +766,13 @@
if (type == DHCP_DISCOVER && ifo->options & DHCPCD_REQUEST)
PUTADDR(DHO_IPADDRESS, ifo->req_addr);
+ /* RFC 2563 Auto Configure */
+ if (type == DHCP_DISCOVER && ifo->options & DHCPCD_IPV4LL) {
+ *p++ = DHO_AUTOCONFIGURE;
+ *p++ = 1;
+ *p++ = 1;
+ }
+
if (type == DHCP_DISCOVER ||
type == DHCP_INFORM ||
type == DHCP_REQUEST)
@@ -823,8 +818,8 @@
}
if (ifo->hostname[0] == '\0')
- hostname = get_hostname(ifo->options &
- DHCPCD_HOSTNAME_SHORT ? 1 : 0);
+ hostname = get_hostname(hbuf, sizeof(hbuf),
+ ifo->options & DHCPCD_HOSTNAME_SHORT ? 1 : 0);
else
hostname = ifo->hostname;
if (ifo->fqdn != FQDN_DISABLE) {
@@ -868,6 +863,15 @@
p += ifo->vendor[0] + 1;
}
+ if ((ifo->auth.options & DHCPCD_AUTH_SENDREQUIRE) !=
+ DHCPCD_AUTH_SENDREQUIRE)
+ {
+ /* We support HMAC-MD5 */
+ *p++ = DHO_FORCERENEW_NONCE;
+ *p++ = 1;
+ *p++ = AUTH_ALG_HMAC_MD5;
+ }
+
Home |
Main Index |
Thread Index |
Old Index