Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/usr.sbin/dhcp Pull up revision 1.4 (requested by mellon):
details: https://anonhg.NetBSD.org/src/rev/93a228f066aa
branches: netbsd-1-5
changeset: 491103:93a228f066aa
user: he <he%NetBSD.org@localhost>
date: Wed Apr 04 20:56:15 2001 +0000
description:
Pull up revision 1.4 (requested by mellon):
Update DHCP software to ISC version 3, Beta 2, Patchlevel 23.
diffstat:
usr.sbin/dhcp/common/dns.c | 97 ++-
usr.sbin/dhcp/common/packet.c | 6 +-
usr.sbin/dhcp/common/parse.c | 1239 ++++++++++++++++++++++++------------
usr.sbin/dhcp/common/print.c | 109 ++-
usr.sbin/dhcp/includes/dhcp.h | 13 +-
usr.sbin/dhcp/includes/failover.h | 12 +-
6 files changed, 1032 insertions(+), 444 deletions(-)
diffs (truncated from 3330 to 300 lines):
diff -r 0e063ab8e07b -r 93a228f066aa usr.sbin/dhcp/common/dns.c
--- a/usr.sbin/dhcp/common/dns.c Wed Apr 04 20:56:08 2001 +0000
+++ b/usr.sbin/dhcp/common/dns.c Wed Apr 04 20:56:15 2001 +0000
@@ -42,11 +42,12 @@
#ifndef lint
static char copyright[] =
-"$Id: dns.c,v 1.1.1.5.2.4 2000/11/09 22:57:30 tv Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dns.c,v 1.1.1.5.2.5 2001/04/04 20:56:15 he Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include "arpa/nameser.h"
+#include "dst/md5.h"
/* This file is kind of a crutch for the BIND 8 nsupdate code, which has
* itself been cruelly hacked from its original state. What this code
@@ -291,10 +292,11 @@
}
#if defined (NSUPDATE)
-ns_rcode find_cached_zone (const char *dname, ns_class class,
- char *zname, size_t zsize,
- struct in_addr *addrs, int naddrs, int *naddrout,
- struct dns_zone **zcookie)
+isc_result_t find_cached_zone (const char *dname, ns_class class,
+ char *zname, size_t zsize,
+ struct in_addr *addrs,
+ int naddrs, int *naddrout,
+ struct dns_zone **zcookie)
{
isc_result_t status = ISC_R_NOTFOUND;
const char *np;
@@ -306,7 +308,11 @@
succeeded previously, but the update itself failed, meaning
that we shouldn't use the cached zone. */
if (!zcookie)
- return ns_r_servfail;
+ return ISC_R_NOTFOUND;
+
+ /* We can't look up a null zone. */
+ if (!dname || !*dname)
+ return ISC_R_INVALIDARG;
/* For each subzone, try to find a cached zone. */
for (np = dname - 1; np; np = strchr (np, '.')) {
@@ -317,18 +323,18 @@
}
if (status != ISC_R_SUCCESS)
- return ns_r_servfail;
+ return status;
/* Make sure the zone is valid. */
if (zone -> timeout && zone -> timeout < cur_time) {
dns_zone_dereference (&zone, MDL);
- return ns_r_servfail;
+ return ISC_R_CANCELED;
}
/* Make sure the zone name will fit. */
if (strlen (zone -> name) > zsize) {
dns_zone_dereference (&zone, MDL);
- return ns_r_servfail;
+ return ISC_R_NOSPACE;
}
strcpy (zname, zone -> name);
@@ -338,6 +344,7 @@
if (zone -> primary) {
if (evaluate_option_cache (&nsaddrs, (struct packet *)0,
(struct lease *)0,
+ (struct client_state *)0,
(struct option_state *)0,
(struct option_state *)0,
&global_scope,
@@ -356,6 +363,7 @@
if (zone -> secondary) {
if (evaluate_option_cache (&nsaddrs, (struct packet *)0,
(struct lease *)0,
+ (struct client_state *)0,
(struct option_state *)0,
(struct option_state *)0,
&global_scope,
@@ -380,7 +388,7 @@
dns_zone_dereference (&zone, MDL);
if (naddrout)
*naddrout = ix;
- return ns_r_noerror;
+ return ISC_R_SUCCESS;
}
void forget_zone (struct dns_zone **zone)
@@ -421,9 +429,7 @@
option_cache_dereference (&zone -> primary, MDL);
if (zone -> secondary)
option_cache_dereference (&zone -> secondary, MDL);
- }
-
- if (!dns_zone_allocate (&zone, MDL))
+ } else if (!dns_zone_allocate (&zone, MDL))
return;
if (!zone -> name) {
@@ -462,6 +468,71 @@
enter_dns_zone (zone);
}
+
+int get_dhcid (struct data_string *id, struct lease *lease)
+{
+ unsigned char buf[MD5_DIGEST_LENGTH];
+ MD5_CTX md5;
+ int i;
+
+ if (!buffer_allocate (&id -> buffer,
+ (MD5_DIGEST_LENGTH * 2) + 3, MDL))
+ return 0;
+ id -> data = id -> buffer -> data;
+
+ /*
+ * DHCP clients and servers should use the following forms of client
+ * identification, starting with the most preferable, and finishing
+ * with the least preferable. If the client does not send any of these
+ * forms of identification, the DHCP/DDNS interaction is not defined by
+ * this specification. The most preferable form of identification is
+ * the Globally Unique Identifier Option [TBD]. Next is the DHCP
+ * Client Identifier option. Last is the client's link-layer address,
+ * as conveyed in its DHCPREQUEST message. Implementors should note
+ * that the link-layer address cannot be used if there are no
+ * significant bytes in the chaddr field of the DHCP client's request,
+ * because this does not constitute a unique identifier.
+ * -- "Interaction between DHCP and DNS"
+ * <draft-ietf-dhc-dhcp-dns-12.txt>
+ * M. Stapp, Y. Rekhter
+ */
+
+ MD5_Init (&md5);
+
+ if (lease -> uid) {
+ id -> buffer -> data [0] =
+ "0123456789abcdef" [DHO_DHCP_CLIENT_IDENTIFIER >> 4];
+ id -> buffer -> data [1] =
+ "0123456789abcdef" [DHO_DHCP_CLIENT_IDENTIFIER % 15];
+ /* Use the DHCP Client Identifier option. */
+ MD5_Update (&md5, lease -> uid, lease -> uid_len);
+ } else if (lease -> hardware_addr.hlen) {
+ id -> buffer -> data [0] = '0';
+ id -> buffer -> data [1] = '0';
+ /* Use the link-layer address. */
+ MD5_Update (&md5,
+ lease -> hardware_addr.hbuf,
+ lease -> hardware_addr.hlen);
+ } else {
+ /* Uh-oh. Something isn't right here. */
+ return 1;
+ }
+
+ MD5_Final (buf, &md5);
+
+ /* Convert into ASCII. */
+ for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
+ id -> buffer -> data [i * 2 + 2] =
+ "0123456789abcdef" [(buf [i] >> 4) & 0xf];
+ id -> buffer -> data [i * 2 + 3] =
+ "0123456789abcdef" [buf [i] & 0xf];
+ }
+ id -> len = MD5_DIGEST_LENGTH * 2 + 2;
+ id -> buffer -> data [id -> len] = 0;
+ id -> terminated = 1;
+
+ return 0;
+}
#endif /* NSUPDATE */
HASH_FUNCTIONS (dns_zone, const char *, struct dns_zone)
diff -r 0e063ab8e07b -r 93a228f066aa usr.sbin/dhcp/common/packet.c
--- a/usr.sbin/dhcp/common/packet.c Wed Apr 04 20:56:08 2001 +0000
+++ b/usr.sbin/dhcp/common/packet.c Wed Apr 04 20:56:15 2001 +0000
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: packet.c,v 1.2.2.1 2000/10/18 04:11:12 tv Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: packet.c,v 1.2.2.2 2001/04/04 20:56:15 he Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -305,8 +305,8 @@
if (len + data < buf + bufix + buflen)
log_debug ("accepting packet with data after udp payload.");
if (len + data > buf + bufix + buflen) {
- log_debug ("dropping packet with bogus uh_ulen %d",
- len + sizeof *udp);
+ log_debug ("dropping packet with bogus uh_ulen %ld",
+ (long)(len + sizeof *udp));
return -1;
}
}
diff -r 0e063ab8e07b -r 93a228f066aa usr.sbin/dhcp/common/parse.c
--- a/usr.sbin/dhcp/common/parse.c Wed Apr 04 20:56:08 2001 +0000
+++ b/usr.sbin/dhcp/common/parse.c Wed Apr 04 20:56:15 2001 +0000
@@ -3,7 +3,7 @@
Common parser code for dhcpd and dhclient. */
/*
- * Copyright (c) 1995-2000 Internet Software Consortium.
+ * Copyright (c) 1995-2001 Internet Software Consortium.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,11 +43,50 @@
#ifndef lint
static char copyright[] =
-"$Id: parse.c,v 1.1.1.6.2.2 2000/10/18 04:11:12 tv Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: parse.c,v 1.1.1.6.2.3 2001/04/04 20:56:15 he Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
+/* Enumerations can be specified in option formats, and are used for
+ parsing, so we define the routines that manage them here. */
+
+struct enumeration *enumerations;
+
+void add_enumeration (struct enumeration *enumeration)
+{
+ enumeration -> next = enumerations;
+ enumerations = enumeration;
+}
+
+struct enumeration *find_enumeration (const char *name, int length)
+{
+ struct enumeration *e;
+
+ for (e = enumerations; e; e = e -> next)
+ if (strlen (e -> name) == length &&
+ !memcmp (e -> name, name, (unsigned)length))
+ return e;
+ return (struct enumeration *)0;
+}
+
+struct enumeration_value *find_enumeration_value (const char *name,
+ int length,
+ const char *value)
+{
+ struct enumeration *e;
+ int i;
+
+ e = find_enumeration (name, length);
+ if (e) {
+ for (i = 0; e -> values [i].name; i++) {
+ if (!strcmp (value, e -> values [i].name))
+ return &e -> values [i];
+ }
+ }
+ return (struct enumeration_value *)0;
+}
+
/* Skip to the semicolon ending the current statement. If we encounter
braces, the matching closing brace terminates the statement. If we
encounter a right brace but haven't encountered a left brace, return
@@ -79,9 +118,9 @@
log_error ("skip_to_rbrace: %d\n", brace_count);
#endif
do {
- token = peek_token (&val, cfile);
+ token = peek_token (&val, (unsigned *)0, cfile);
if (token == RBRACE) {
- token = next_token (&val, cfile);
+ token = next_token (&val, (unsigned *)0, cfile);
if (brace_count) {
if (!--brace_count)
return;
@@ -90,17 +129,17 @@
} else if (token == LBRACE) {
brace_count++;
} else if (token == SEMI && !brace_count) {
- token = next_token (&val, cfile);
+ token = next_token (&val, (unsigned *)0, cfile);
return;
} else if (token == EOL) {
/* EOL only happens when parsing /etc/resolv.conf,
and we treat it like a semicolon because the
resolv.conf file is line-oriented. */
- token = next_token (&val, cfile);
+ token = next_token (&val, (unsigned *)0, cfile);
return;
}
- token = next_token (&val, cfile);
- } while (token != EOF);
+ token = next_token (&val, (unsigned *)0, cfile);
+ } while (token != END_OF_FILE);
}
int parse_semi (cfile)
@@ -109,7 +148,7 @@
enum dhcp_token token;
const char *val;
Home |
Main Index |
Thread Index |
Old Index