DHCP 3.0 Beta 2 Patchlevel 9

This commit is contained in:
taca 2000-10-17 15:07:41 +00:00
parent f8920e714b
commit 70a42dc992
37 changed files with 789 additions and 373 deletions

View File

@ -367,6 +367,17 @@ no lease is acquired, the script is used to test predefined leases, if
any, and also called once if no valid lease can be identified. For any, and also called once if no valid lease can be identified. For
more information, see more information, see
.B dhclient-script(8). .B dhclient-script(8).
.PP
\fBvendor option space "\fIname\fB";\fR
.PP
The
.B vendor option space
statement is used to specify which option space should be used for
decoding the vendor-encapsulate-options option if one is received.
The \fIdhcp-vendor-identifier\fR can be used to request a specific
class of vendor options from the server. See
.B dhcp-options(5)
for details.
.PP .PP
\fBmedium "\fImedia setup\fB";\fR \fBmedium "\fImedia setup\fB";\fR
.PP .PP

View File

@ -22,6 +22,13 @@
# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
# of the $1 in its args. # of the $1 in its args.
function make_resolv_conf() {
echo search $new_domain_name >/etc/resolv.conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
}
# Must be used on exit. Invokes the local dhcp client exit hooks, if any. # Must be used on exit. Invokes the local dhcp client exit hooks, if any.
function exit_with_hooks() { function exit_with_hooks() {
exit_status=$1 exit_status=$1
@ -136,10 +143,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
route add -host $alias_ip_address $interface:0 route add -host $alias_ip_address $interface:0
fi fi
echo search $new_domain_name >/etc/resolv.conf make_resolv_conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
exit_with_hooks 0 exit_with_hooks 0
fi fi
@ -180,14 +184,7 @@ if [ x$reason = xTIMEOUT ]; then
for router in $new_routers; do for router in $new_routers; do
route add default gw $router route add default gw $router
done done
echo search $new_domain_name >/etc/resolv.conf.std make_resolv_conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.std
done
if [ -f /etc/resolv.conf ]; then
rm -f /etc/resolv.conf
ln /etc/resolv.conf.std /etc/resolv.conf
fi
exit_with_hooks 0 exit_with_hooks 0
fi fi
ifconfig $interface inet down ifconfig $interface inet down

View File

@ -123,10 +123,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1 route add $alias_ip_address 127.0.0.1
fi fi
echo search $new_domain_name >/etc/resolv.conf make_resolv_conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
exit_with_hooks 0 exit_with_hooks 0
fi fi
@ -183,14 +180,7 @@ if [ x$reason = xTIMEOUT ]; then
route add $0 $1 route add $0 $1
shift; shift shift; shift
done done
echo search $new_domain_name >/etc/resolv.conf.std make_resolv_conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.std
done
if [ -f /etc/resolv.conf ]; then
rm -f /etc/resolv.conf
fi
mv /etc/resolv.conf.std /etc/resolv.conf
exit_with_hooks 0 exit_with_hooks 0
fi fi
fi fi

View File

@ -116,10 +116,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
$ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg $ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1 1 route add $alias_ip_address 127.0.0.1 1
fi fi
echo search $new_domain_name >/etc/resolv.conf make_resolv_conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf
done
exit_with_hooks 0 exit_with_hooks 0
fi fi
@ -161,14 +158,7 @@ if [ x$reason = xTIMEOUT ]; then
for router in $new_routers; do for router in $new_routers; do
route add default $router 1 >/dev/null 2>&1 route add default $router 1 >/dev/null 2>&1
done done
echo search $new_domain_name >/etc/resolv.conf.std make_resolv_conf
for nameserver in $new_domain_name_servers; do
echo nameserver $nameserver >>/etc/resolv.conf.std
done
if [ -f /etc/resolv.conf ]; then
rm -f /etc/resolv.conf
ln /etc/resolv.conf.std /etc/resolv.conf
fi
exit_with_hooks 0 exit_with_hooks 0
fi fi
$ifconfig $interface inet 0 down $ifconfig $interface inet 0 down

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: conflex.c,v 1.1.1.10 2000/09/04 23:10:06 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: conflex.c,v 1.1.1.11 2000/10/17 15:07:53 taca Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -647,6 +647,8 @@ static enum dhcp_token intern (atom, dfv)
return ERROR; return ERROR;
if (!strcasecmp (atom + 1, "val")) if (!strcasecmp (atom + 1, "val"))
return EVAL; return EVAL;
if (!strcasecmp (atom + 1, "ncapsulate"))
return ENCAPSULATE;
break; break;
case 'f': case 'f':
if (!strcasecmp (atom + 1, "atal")) if (!strcasecmp (atom + 1, "atal"))
@ -1000,6 +1002,8 @@ static enum dhcp_token intern (atom, dfv)
case 'v': case 'v':
if (!strcasecmp (atom + 1, "endor-class")) if (!strcasecmp (atom + 1, "endor-class"))
return VENDOR_CLASS; return VENDOR_CLASS;
if (!strcasecmp (atom + 1, "endor"))
return VENDOR;
break; break;
case 'w': case 'w':
if (!strcasecmp (atom + 1, "ith")) if (!strcasecmp (atom + 1, "ith"))

View File

@ -15,7 +15,7 @@
.\" .\"
.\" Support and other services are available for ISC products - see .\" Support and other services are available for ISC products - see
.\" http://www.isc.org for more information. .\" http://www.isc.org for more information.
.TH dhcpd-options 5 .TH dhcpd-eval 5
.SH NAME .SH NAME
dhcp-conditionals - ISC DHCP conditional evaluation dhcp-conditionals - ISC DHCP conditional evaluation
.SH DESCRIPTION .SH DESCRIPTION
@ -102,17 +102,6 @@ treated as false in conditionals.
The following is the current list of boolean expressions that are The following is the current list of boolean expressions that are
supported by the DHCP distribution. supported by the DHCP distribution.
.PP .PP
.B check \fIclass-name\fR
.RS 0.25i
.PP
The check operator returns a true value if the packet being considered
comes from a client that falls into the specified
class.
.I Class-name
must be a string that corresponds to the name of a defined class.
Classes are only supported in the DHCP server.
.RE
.PP
.I data-expression-1 \fB=\fI data-expression-2\fR .I data-expression-1 \fB=\fI data-expression-2\fR
.RS 0.25i .RS 0.25i
.PP .PP

View File

@ -42,7 +42,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: dns.c,v 1.1.1.7 2000/09/04 23:10:10 mellon Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: dns.c,v 1.1.1.8 2000/10/17 15:08:09 taca Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -138,19 +138,11 @@ isc_result_t find_tsig_key (ns_tsig_key **key, const char *zname,
{ {
isc_result_t status; isc_result_t status;
ns_tsig_key *tkey; ns_tsig_key *tkey;
#if 0
struct dns_zone *zone;
zone = (struct dns_zone *)0;
status = dns_zone_lookup (&zone, zname);
if (status != ISC_R_SUCCESS)
return status;
#else
if (!zone) if (!zone)
return ISC_R_NOTFOUND; return ISC_R_NOTFOUND;
#endif
if (!zone -> key) { if (!zone -> key) {
dns_zone_dereference (&zone, MDL);
return ISC_R_KEY_UNKNOWN; return ISC_R_KEY_UNKNOWN;
} }
@ -159,13 +151,11 @@ isc_result_t find_tsig_key (ns_tsig_key **key, const char *zname,
(!zone -> key -> algorithm || (!zone -> key -> algorithm ||
strlen (zone -> key -> algorithm) > NS_MAXDNAME) || strlen (zone -> key -> algorithm) > NS_MAXDNAME) ||
(!zone -> key)) { (!zone -> key)) {
dns_zone_dereference (&zone, MDL);
return ISC_R_INVALIDKEY; return ISC_R_INVALIDKEY;
} }
tkey = dmalloc (sizeof *tkey, MDL); tkey = dmalloc (sizeof *tkey, MDL);
if (!tkey) { if (!tkey) {
nomem: nomem:
dns_zone_dereference (&zone, MDL);
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
} }
memset (tkey, 0, sizeof *tkey); memset (tkey, 0, sizeof *tkey);
@ -406,6 +396,70 @@ void repudiate_zone (struct dns_zone **zone)
(*zone) -> timeout = cur_time - 1; (*zone) -> timeout = cur_time - 1;
dns_zone_dereference (zone, MDL); dns_zone_dereference (zone, MDL);
} }
void cache_found_zone (ns_class class,
char *zname, struct in_addr *addrs, int naddrs)
{
isc_result_t status = ISC_R_NOTFOUND;
const char *np;
struct dns_zone *zone = (struct dns_zone *)0;
struct data_string nsaddrs;
int ix = strlen (zname);
if (zname [ix - 1] == '.')
ix = 0;
/* See if there's already such a zone. */
if (dns_zone_lookup (&zone, np) == ISC_R_SUCCESS) {
/* If it's not a dynamic zone, leave it alone. */
if (!zone -> timeout)
return;
/* Address may have changed, so just blow it away. */
if (zone -> primary)
option_cache_dereference (&zone -> primary, MDL);
if (zone -> secondary)
option_cache_dereference (&zone -> secondary, MDL);
}
if (!dns_zone_allocate (&zone, MDL))
return;
if (!zone -> name) {
zone -> name =
dmalloc (strlen (zname) + 1 + (ix != 0), MDL);
if (!zone -> name) {
dns_zone_dereference (&zone, MDL);
return;
}
strcpy (zone -> name, zname);
/* Add a trailing '.' if it was missing. */
if (ix) {
zone -> name [ix] = '.';
zone -> name [ix + 1] = 0;
}
}
/* XXX Need to get the lower-level code to push the actual zone
XXX TTL up to us. */
zone -> timeout = cur_time + 1800;
if (!option_cache_allocate (&zone -> primary, MDL)) {
dns_zone_dereference (&zone, MDL);
return;
}
if (!buffer_allocate (&zone -> primary -> data.buffer,
naddrs * sizeof (struct in_addr), MDL)) {
dns_zone_dereference (&zone, MDL);
return;
}
memcpy (zone -> primary -> data.buffer -> data,
addrs, naddrs * sizeof *addrs);
zone -> primary -> data.data =
&zone -> primary -> data.buffer -> data [0];
zone -> primary -> data.len = naddrs * sizeof *addrs;
enter_dns_zone (zone);
}
#endif /* NSUPDATE */ #endif /* NSUPDATE */
HASH_FUNCTIONS (dns_zone, const char *, struct dns_zone) HASH_FUNCTIONS (dns_zone, const char *, struct dns_zone)

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: execute.c,v 1.1.1.5 2000/09/04 23:10:11 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: execute.c,v 1.1.1.6 2000/10/17 15:08:12 taca Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -248,12 +248,8 @@ int execute_statements (result, packet, lease, in_options, out_options, scope,
r -> data.option -> option -> name); r -> data.option -> option -> name);
option_statement: option_statement:
#endif #endif
if (r -> data.option -> option -> universe -> set_func) set_option (r -> data.option -> option -> universe,
((r -> data.option -> option -> out_options, r -> data.option, r -> op);
universe -> set_func)
(r -> data.option -> option -> universe,
out_options,
r -> data.option, r -> op));
break; break;
case set_statement: case set_statement:

View File

@ -44,7 +44,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: icmp.c,v 1.1.1.9 2000/07/08 20:40:20 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: icmp.c,v 1.1.1.10 2000/10/17 15:08:12 taca Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -79,9 +79,9 @@ void icmp_startup (routep, handler)
if (dhcp_type_icmp) if (dhcp_type_icmp)
log_fatal ("attempted to reinitialize icmp protocol"); log_fatal ("attempted to reinitialize icmp protocol");
result = omapi_object_type_register (&dhcp_type_icmp, result = omapi_object_type_register (&dhcp_type_icmp, "icmp",
"icmp", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, sizeof (struct icmp_state)); sizeof (struct icmp_state), 0);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
log_fatal ("Can't register icmp object type: %s", log_fatal ("Can't register icmp object type: %s",

View File

@ -37,7 +37,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: lpf.c,v 1.1.1.7 2000/09/04 23:10:11 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: lpf.c,v 1.1.1.8 2000/10/17 15:08:14 taca Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -170,11 +170,14 @@ void if_deregister_send (info)
in bpf includes... */ in bpf includes... */
extern struct sock_filter dhcp_bpf_filter []; extern struct sock_filter dhcp_bpf_filter [];
extern int dhcp_bpf_filter_len; extern int dhcp_bpf_filter_len;
#if defined (HAVE_TR_SUPPORT)
extern struct sock_filter dhcp_bpf_tr_filter []; extern struct sock_filter dhcp_bpf_tr_filter [];
extern int dhcp_bpf_tr_filter_len; extern int dhcp_bpf_tr_filter_len;
static void lpf_tr_filter_setup (struct interface_info *);
#endif
static void lpf_gen_filter_setup (struct interface_info *); static void lpf_gen_filter_setup (struct interface_info *);
static void lpf_tr_filter_setup (struct interface_info *);
void if_register_receive (info) void if_register_receive (info)
struct interface_info *info; struct interface_info *info;
@ -182,9 +185,11 @@ void if_register_receive (info)
/* Open a LPF device and hang it on this interface... */ /* Open a LPF device and hang it on this interface... */
info -> rfdesc = if_register_lpf (info); info -> rfdesc = if_register_lpf (info);
#if defined (HAVE_TR_SUPPORT)
if (info -> hw_address.hbuf [0] == HTYPE_IEEE802) if (info -> hw_address.hbuf [0] == HTYPE_IEEE802)
lpf_tr_filter_setup (info); lpf_tr_filter_setup (info);
else else
#endif
lpf_gen_filter_setup (info); lpf_gen_filter_setup (info);
if (!quiet_interface_discovery) if (!quiet_interface_discovery)
@ -247,6 +252,7 @@ static void lpf_gen_filter_setup (info)
} }
} }
#if defined (HAVE_TR_SUPPORT)
static void lpf_tr_filter_setup (info) static void lpf_tr_filter_setup (info)
struct interface_info *info; struct interface_info *info;
{ {
@ -279,6 +285,7 @@ static void lpf_tr_filter_setup (info)
log_fatal ("Can't install packet filter program: %m"); log_fatal ("Can't install packet filter program: %m");
} }
} }
#endif /* HAVE_TR_SUPPORT */
#endif /* USE_LPF_RECEIVE */ #endif /* USE_LPF_RECEIVE */
#ifdef USE_LPF_SEND #ifdef USE_LPF_SEND

View File

@ -44,7 +44,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: nit.c,v 1.1.1.9 2000/09/04 23:10:12 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: nit.c,v 1.1.1.10 2000/10/17 15:08:15 taca Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -120,7 +120,7 @@ int if_register_nit (info)
/* XXX code below assumes ethernet interface! */ /* XXX code below assumes ethernet interface! */
info -> hw_address.hlen = 7; info -> hw_address.hlen = 7;
info -> hw_address.hbuf [0] = ARPHRD_ETHER; info -> hw_address.hbuf [0] = ARPHRD_ETHER;
memcpy (&info -> hw_address.jbuf [1], memcpy (&info -> hw_address.hbuf [1],
ifr.ifr_ifru.ifru_addr.sa_data, 6); ifr.ifr_ifru.ifru_addr.sa_data, 6);
if (ioctl (sock, I_PUSH, "pf") < 0) if (ioctl (sock, I_PUSH, "pf") < 0)
@ -321,10 +321,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto)
assemble_hw_header (interface, (unsigned char *)junk, &hbufp, hto); assemble_hw_header (interface, (unsigned char *)junk, &hbufp, hto);
assemble_udp_ip_header (interface, buf, &ibufp, assemble_udp_ip_header (interface, buf, &ibufp,
from.s_addr, to -> sin_addr.s_addr, from.s_addr, to -> sin_addr.s_addr,
to -> sin_port, raw, len); to -> sin_port, (unsigned char *)raw, len);
/* Copy the data into the buffer (yuk). */ /* Copy the data into the buffer (yuk). */
memcpy (buf + bufp, raw, len); memcpy (buf + ibufp, raw, len);
/* Set up the sockaddr structure... */ /* Set up the sockaddr structure... */
#if USE_SIN_LEN #if USE_SIN_LEN

View File

@ -51,7 +51,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: socket.c,v 1.1.1.12 2000/09/04 23:10:15 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; "$Id: socket.c,v 1.1.1.13 2000/10/17 15:08:31 taca Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -184,7 +184,7 @@ void if_register_send (info)
info -> shared_network -> name : "")); info -> shared_network -> name : ""));
} }
#if !defined (USE_SOCKET_FALLBACK) #if defined (USE_SOCKET_SEND)
void if_deregister_send (info) void if_deregister_send (info)
struct interface_info *info; struct interface_info *info;
{ {
@ -200,7 +200,7 @@ void if_deregister_send (info)
(info -> shared_network ? (info -> shared_network ?
info -> shared_network -> name : "")); info -> shared_network -> name : ""));
} }
#endif /* !USE_SOCKET_FALLBACK */ #endif /* USE_SOCKET_SEND */
#endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */ #endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
#ifdef USE_SOCKET_RECEIVE #ifdef USE_SOCKET_RECEIVE
@ -354,18 +354,23 @@ void maybe_setup_fallback ()
{ {
#if defined (USE_SOCKET_FALLBACK) #if defined (USE_SOCKET_FALLBACK)
isc_result_t status; isc_result_t status;
struct interface_info *fbi; struct interface_info *fbi = (struct interface_info *)0;
fbi = setup_fallback (); if (setup_fallback (&fbi, MDL)) {
if (fbi) {
fbi -> wfdesc = if_register_socket (fbi); fbi -> wfdesc = if_register_socket (fbi);
fbi -> refcnt = 1; fbi -> rfdesc = fbi -> wfdesc;
fbi -> type = dhcp_type_interface; log_info ("Sending on Socket/%s%s%s",
fbi -> name,
(fbi -> shared_network ? "/" : ""),
(fbi -> shared_network ?
fbi -> shared_network -> name : ""));
status = omapi_register_io_object ((omapi_object_t *)fbi, status = omapi_register_io_object ((omapi_object_t *)fbi,
if_readsocket, 0, if_readsocket, 0,
fallback_discard, 0, 0); fallback_discard, 0, 0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
log_fatal ("Can't register I/O handle for %s: %s", log_fatal ("Can't register I/O handle for %s: %s",
fbi -> name, isc_result_totext (status)); fbi -> name, isc_result_totext (status));
interface_dereference (&fbi, MDL);
} }
#endif #endif
} }

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: tree.c,v 1.1.1.7 2000/09/04 23:10:17 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: tree.c,v 1.1.1.8 2000/10/17 15:08:49 taca Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -1021,10 +1021,10 @@ int evaluate_boolean_expression (result, packet, lease, in_options,
case expr_exists: case expr_exists:
memset (&left, 0, sizeof left); memset (&left, 0, sizeof left);
if (!in_options || if (!in_options ||
!((*expr -> data.option -> universe -> get_func) !get_option (&left, expr -> data.exists -> universe,
(&left, expr -> data.exists -> universe, packet, lease, in_options, cfg_options,
packet, lease, in_options, cfg_options, in_options, in_options,
scope, expr -> data.exists -> code))) scope, expr -> data.exists -> code))
*result = 0; *result = 0;
else { else {
*result = 1; *result = 1;
@ -1274,7 +1274,7 @@ int evaluate_data_expression (result, packet, lease,
s1 = evaluate_numeric_expression (&len, packet, lease, s1 = evaluate_numeric_expression (&len, packet, lease,
in_options, cfg_options, in_options, cfg_options,
scope, scope,
expr -> data.substring.len); expr -> data.suffix.len);
if (s0 && s1) { if (s0 && s1) {
data_string_copy (result, &data, MDL); data_string_copy (result, &data, MDL);
@ -1302,11 +1302,11 @@ int evaluate_data_expression (result, packet, lease,
/* Extract an option. */ /* Extract an option. */
case expr_option: case expr_option:
if (in_options) if (in_options)
s0 = ((*expr -> data.option -> universe -> get_func) s0 = get_option (result,
(result, expr -> data.option -> universe, expr -> data.option -> universe,
packet, lease, packet, lease,
in_options, cfg_options, in_options, in_options, cfg_options, in_options,
scope, expr -> data.option -> code)); scope, expr -> data.option -> code);
else else
s0 = 0; s0 = 0;
@ -1321,11 +1321,11 @@ int evaluate_data_expression (result, packet, lease,
case expr_config_option: case expr_config_option:
if (cfg_options) if (cfg_options)
s0 = ((*expr -> data.option -> universe -> get_func) s0 = get_option (result,
(result, expr -> data.option -> universe, expr -> data.option -> universe,
packet, lease, packet, lease,
in_options, cfg_options, cfg_options, in_options, cfg_options, cfg_options,
scope, expr -> data.option -> code)); scope, expr -> data.option -> code);
else else
s0 = 0; s0 = 0;
@ -3605,4 +3605,169 @@ int fundef_dereference (ptr, file, line)
return 1; return 1;
} }
#if defined (NOTYET) /* Post 3.0 final. */
int data_subexpression_length (int *rv,
struct expression *expr)
{
int crhs, clhs, llhs, lrhs;
switch (expr -> op) {
case expr_substring:
if (expr -> data.substring.len &&
expr -> data.substring.len -> op == expr_const_int) {
(*rv =
(int)expr -> data.substring.len -> data.const_int);
return 1;
}
return 0;
case expr_packet:
case expr_suffix:
if (expr -> data.suffix.len &&
expr -> data.suffix.len -> op == expr_const_int) {
(*rv =
(int)expr -> data.suffix.len -> data.const_int);
return 1;
}
return 0;
case expr_concat:
clhs = data_subexpression_length (&llhs,
expr -> data.concat [0]);
crhs = data_subexpression_length (&lrhs,
expr -> data.concat [1]);
if (crhs == 0 || clhs == 0)
return 0;
*rv = llhs + lrhs;
return 1;
break;
case expr_hardware:
return 0;
case expr_const_data:
*rv = expr -> data.const_data.len;
return 2;
case expr_reverse:
return data_subexpression_length (rv,
expr -> data.reverse.buffer);
case expr_leased_address:
case expr_lease_time:
*rv = 4;
return 2;
case expr_pick_first_value:
clhs = data_subexpression_length (&llhs,
expr -> data.concat [0]);
crhs = data_subexpression_length (&lrhs,
expr -> data.concat [1]);
if (crhs == 0 || clhs == 0)
return 0;
if (llhs > lrhs)
*rv = llhs;
else
*rv = lrhs;
return 1;
case expr_binary_to_ascii:
case expr_config_option:
case expr_host_decl_name:
case expr_encapsulate:
case expr_filename:
case expr_sname:
case expr_host_lookup:
case expr_option:
case expr_none:
case expr_match:
case expr_check:
case expr_equal:
case expr_and:
case expr_or:
case expr_not:
case expr_extract_int8:
case expr_extract_int16:
case expr_extract_int32:
case expr_encode_int8:
case expr_encode_int16:
case expr_encode_int32:
case expr_const_int:
case expr_exists:
case expr_known:
case expr_dns_transaction:
case expr_static:
case expr_ns_add:
case expr_ns_delete:
case expr_ns_exists:
case expr_ns_not_exists:
case expr_not_equal:
case expr_null:
case expr_variable_exists:
case expr_variable_reference:
case expr_arg:
case expr_funcall:
case expr_function:
case expr_add:
case expr_subtract:
case expr_multiply:
case expr_divide:
case expr_remainder:
case expr_binary_and:
case expr_binary_or:
case expr_binary_xor:
return 0;
}
return 0;
}
int expr_valid_for_context (struct expression *expr,
enum expression_context context)
{
/* We don't know at parse time what type of value a function may
return, so we can't flag an error on it. */
if (expr -> op == expr_funcall ||
expr -> op == expr_variable_reference)
return 1;
switch (context) {
case context_any:
return 1;
case context_boolean:
if (is_boolean_expression (expr))
return 1;
return 0;
case context_data:
if (is_data_expression (expr))
return 1;
return 0;
case context_numeric:
if (is_numeric_expression (expr))
return 1;
return 0;
case context_dns:
if (is_dns_expression (expr)) {
return 1;
}
return 0;
case context_data_or_numeric:
if (is_numeric_expression (expr) ||
is_data_expression (expr)) {
return 1;
}
return 0;
case context_function:
if (expr -> op == expr_function)
return 1;
return 0;
}
return 0;
}
#endif /* NOTYET */
/* vim: set tabstop=8: */ /* vim: set tabstop=8: */

View File

@ -75,7 +75,7 @@ int main (argc, argv)
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
if (!strcmp (argv[i], "-u")) { if (!strcmp (argv[i], "-u")) {
mode = up; mode = up;
} else if (!strcmp (argv [1], "-d")) { } else if (!strcmp (argv [i], "-d")) {
mode = down; mode = down;
} else if (!strcmp (argv[i], "-n")) { } else if (!strcmp (argv[i], "-n")) {
if (++i == argc) if (++i == argc)

View File

@ -53,25 +53,38 @@ omapi_object_type_t *dhcpctl_remote_type;
dhcpctl_status dhcpctl_initialize () dhcpctl_status dhcpctl_initialize ()
{ {
omapi_init(); isc_result_t status;
omapi_object_type_register (&dhcpctl_callback_type,
"dhcpctl-callback", status = omapi_init();
dhcpctl_callback_set_value, if (status != ISC_R_SUCCESS)
dhcpctl_callback_get_value, return status;
dhcpctl_callback_destroy,
dhcpctl_callback_signal_handler, status = omapi_object_type_register (&dhcpctl_callback_type,
dhcpctl_callback_stuff_values, "dhcpctl-callback",
0, 0, 0, 0, 0, 0, dhcpctl_callback_set_value,
sizeof (dhcpctl_callback_object_t)); dhcpctl_callback_get_value,
omapi_object_type_register (&dhcpctl_remote_type, dhcpctl_callback_destroy,
"dhcpctl-remote", dhcpctl_callback_signal_handler,
dhcpctl_remote_set_value, dhcpctl_callback_stuff_values,
dhcpctl_remote_get_value, 0, 0, 0, 0, 0, 0,
dhcpctl_remote_destroy, sizeof
dhcpctl_remote_signal_handler, (dhcpctl_callback_object_t), 0);
dhcpctl_remote_stuff_values, if (status != ISC_R_SUCCESS)
0, 0, 0, 0, 0, 0, return status;
sizeof (dhcpctl_remote_object_t));
status = omapi_object_type_register (&dhcpctl_remote_type,
"dhcpctl-remote",
dhcpctl_remote_set_value,
dhcpctl_remote_get_value,
dhcpctl_remote_destroy,
dhcpctl_remote_signal_handler,
dhcpctl_remote_stuff_values,
0, 0, 0, 0, 0, 0,
sizeof (dhcpctl_remote_object_t),
0);
if (status != ISC_R_SUCCESS)
return status;
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
} }
@ -381,6 +394,11 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection,
{ {
isc_result_t status; isc_result_t status;
omapi_object_t *message = (omapi_object_t *)0; omapi_object_t *message = (omapi_object_t *)0;
dhcpctl_remote_object_t *ro;
if (h -> type != dhcpctl_remote_type)
return ISC_R_INVALIDARG;
ro = (dhcpctl_remote_object_t *)h;
status = omapi_message_new (&message, MDL); status = omapi_message_new (&message, MDL);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
@ -393,6 +411,7 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection,
omapi_object_dereference (&message, MDL); omapi_object_dereference (&message, MDL);
return status; return status;
} }
status = omapi_set_object_value (message, (omapi_object_t *)0, status = omapi_set_object_value (message, (omapi_object_t *)0,
"object", h); "object", h);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
@ -400,6 +419,13 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection,
return status; return status;
} }
status = omapi_set_int_value (message, (omapi_object_t *)0, "handle",
(int)(ro -> remote_handle));
if (status != ISC_R_SUCCESS) {
omapi_object_dereference (&message, MDL);
return status;
}
omapi_message_register (message); omapi_message_register (message);
status = omapi_protocol_send_message (connection -> outer, status = omapi_protocol_send_message (connection -> outer,
(omapi_object_t *)0, (omapi_object_t *)0,
@ -417,6 +443,11 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection,
{ {
isc_result_t status; isc_result_t status;
omapi_object_t *message = (omapi_object_t *)0; omapi_object_t *message = (omapi_object_t *)0;
dhcpctl_remote_object_t *ro;
if (h -> type != dhcpctl_remote_type)
return ISC_R_INVALIDARG;
ro = (dhcpctl_remote_object_t *)h;
status = omapi_message_new (&message, MDL); status = omapi_message_new (&message, MDL);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
@ -430,7 +461,7 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection,
return status; return status;
} }
status = omapi_set_int_value (message, (omapi_object_t *)0, status = omapi_set_int_value (message, (omapi_object_t *)0,
"handle", (int)(h -> handle)); "handle", (int)(ro -> remote_handle));
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
omapi_object_dereference (&message, MDL); omapi_object_dereference (&message, MDL);
return status; return status;

View File

@ -111,13 +111,11 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h,
omapi_object_t *g; omapi_object_t *g;
isc_result_t status; isc_result_t status;
m = dmalloc (sizeof *m, MDL); m = (dhcpctl_remote_object_t *)0;
if (!m) status = omapi_object_allocate ((omapi_object_t **)&m,
return ISC_R_NOMEMORY; dhcpctl_remote_type, 0, MDL);
memset (m, 0, sizeof *m); if (status != ISC_R_SUCCESS)
m -> type = dhcpctl_remote_type; return status;
m -> refcnt = 1;
rc_register_mdl (&m, m, m -> refcnt);
g = (omapi_object_t *)0; g = (omapi_object_t *)0;
status = omapi_generic_new (&g, MDL); status = omapi_generic_new (&g, MDL);

View File

@ -122,6 +122,7 @@ int main (argc, argv)
exit (1); exit (1);
} }
#if 0
/* Create a named group that contains the values we want to assign /* Create a named group that contains the values we want to assign
to the host. */ to the host. */
memset (&group_handle, 0, sizeof group_handle); memset (&group_handle, 0, sizeof group_handle);
@ -173,6 +174,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
printf ("group name = %.*s\n", printf ("group name = %.*s\n",
(int)groupname -> len, (int)groupname -> len,
groupname -> value); groupname -> value);
#endif
memset (&host_handle, 0, sizeof host_handle); memset (&host_handle, 0, sizeof host_handle);
status = dhcpctl_new_object (&host_handle, connection, "host"); status = dhcpctl_new_object (&host_handle, connection, "host");
@ -191,27 +193,20 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
exit (1); exit (1);
} }
cid -> value [0] = 0; cid -> value [1] = 0x10; memset (&cid -> value [0], 0, 6);
cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
doitagain:
status = dhcpctl_set_value (host_handle, status = dhcpctl_set_value (host_handle,
cid, "dhcp-client-identifier"); cid, "hardware-address");
/*#else
doitagain: */
status = dhcpctl_set_string_value (host_handle, "gnorf",
"name");
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_set_value: %s\n", fprintf (stderr, "dhcpctl_set_value: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
/*#endif*/
status = dhcpctl_set_value (host_handle, groupname, "group"); status = dhcpctl_set_string_value (host_handle, "gnorf",
"name");
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_set_value: %s\n", fprintf (stderr, "dhcpctl_set_string_value: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
@ -244,6 +239,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
exit (1); exit (1);
} }
#if 0
status = dhcpctl_set_string_value (host_handle, "\n\ status = dhcpctl_set_string_value (host_handle, "\n\
option host-name \"bar\";\n\ option host-name \"bar\";\n\
option smtp-server 10.0.0.1;", option smtp-server 10.0.0.1;",
@ -253,6 +249,7 @@ option smtp-server 10.0.0.1;",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
#endif
status = dhcpctl_open_object (host_handle, connection, status = dhcpctl_open_object (host_handle, connection,
DHCPCTL_CREATE | DHCPCTL_EXCL); DHCPCTL_CREATE | DHCPCTL_EXCL);
@ -264,75 +261,49 @@ option smtp-server 10.0.0.1;",
status = dhcpctl_wait_for_completion (host_handle, &waitstatus); status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_wait_for_completion: %s\n", fprintf (stderr, "create: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
if (waitstatus != ISC_R_SUCCESS) { if (waitstatus != ISC_R_SUCCESS) {
status = dhcpctl_open_object (host_handle, connection, 0); fprintf (stderr, "dhcpctl_open_object: %s\n",
if (status != ISC_R_SUCCESS) { isc_result_totext (waitstatus));
fprintf (stderr, "dhcpctl_open_object: %s\n", exit (1);
isc_result_totext (status));
exit (1);
}
status = dhcpctl_wait_for_completion (host_handle,
&waitstatus);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
if (waitstatus != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
isc_result_totext (waitstatus));
exit (1);
}
status = dhcpctl_object_remove (connection, host_handle);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_object_remove: %s\n",
isc_result_totext (status));
exit (1);
}
status = dhcpctl_wait_for_completion (host_handle,
&waitstatus);
if (status != ISC_R_SUCCESS) {
fprintf (stderr,
"remove: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
if (waitstatus != ISC_R_SUCCESS) {
fprintf (stderr,
"remove: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (waitstatus));
exit (1);
}
omapi_object_dereference (&host_handle, MDL);
status = dhcpctl_new_object (&host_handle, connection, "host");
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_new_object: %s\n",
isc_result_totext (status));
exit (1);
}
goto doitagain;
} }
memset (&result, 0, sizeof result); cid -> value [0] = 0; cid -> value [1] = 0x10;
status = dhcpctl_get_value (&result, host_handle, "name"); cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
status = dhcpctl_set_value (host_handle,
cid, "hardware-address");
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_get_value: %s\n", fprintf (stderr, "dhcpctl_set_value: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
printf ("host name = %.*s\n", (int)result -> len, result -> value); status = dhcpctl_object_update (connection, host_handle);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_object_update: %s\n",
isc_result_totext (status));
exit (1);
}
status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "update: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
if (waitstatus != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_object_update: %s\n",
isc_result_totext (waitstatus));
exit (1);
}
#if 0
status = dhcpctl_object_remove (connection, host_handle); status = dhcpctl_object_remove (connection, host_handle);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_object_remove: %s\n", fprintf (stderr, "dhcpctl_object_remove: %s\n",
@ -342,97 +313,65 @@ option smtp-server 10.0.0.1;",
status = dhcpctl_wait_for_completion (host_handle, status = dhcpctl_wait_for_completion (host_handle,
&waitstatus); &waitstatus);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "remove: dhcpctl_wait_for_completion: %s\n", fprintf (stderr,
"remove: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
if (waitstatus != ISC_R_SUCCESS) { if (waitstatus != ISC_R_SUCCESS) {
fprintf (stderr, "remove: dhcpctl_wait_for_completion: %s\n", fprintf (stderr,
"remove: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (waitstatus)); isc_result_totext (waitstatus));
exit (1); exit (1);
} }
#endif
/* Create a named group that contains the values we want to assign omapi_object_dereference (&host_handle, MDL);
to the host. */
memset (&lease_handle, 0, sizeof lease_handle); status = dhcpctl_new_object (&host_handle, connection, "host");
status = dhcpctl_new_object (&lease_handle, connection, "lease");
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_new_object: %s\n", fprintf (stderr, "dhcpctl_new_object: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
memset (&ip_addr, 0, sizeof ip_addr); memset (&cid -> value [0], 0, 6);
status = omapi_data_string_new (&ip_addr, 4, MDL);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "omapi_data_string_new: %s\n",
isc_result_totext (status));
exit (1);
}
ip_addr -> value [0] = 10; ip_addr -> value [1] = 0; status = dhcpctl_set_value (host_handle,
ip_addr -> value [2] = 0; ip_addr -> value [3] = 4; cid, "hardware-address");
status = dhcpctl_set_value (lease_handle, ip_addr, "ip-address");
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_set_value: %s\n", fprintf (stderr, "dhcpctl_set_value: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
status = dhcpctl_open_object (lease_handle, connection, 0); status = dhcpctl_set_string_value (host_handle, "gnorf",
"name");
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_open_object: %s\n", fprintf (stderr, "dhcpctl_set_string_value: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
status = dhcpctl_wait_for_completion (lease_handle, &waitstatus); status = dhcpctl_open_object (host_handle, connection,
DHCPCTL_CREATE | DHCPCTL_EXCL);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_wait_for_completion: %s\n", fprintf (stderr, "dhcpctl_open_object 2: %s\n",
isc_result_totext (status)); isc_result_totext (status));
exit (1); exit (1);
} }
status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
if (status != ISC_R_SUCCESS) {
fprintf (stderr, "create: dhcpctl_wait_for_completion: %s\n",
isc_result_totext (status));
exit (1);
}
if (waitstatus != ISC_R_SUCCESS) { if (waitstatus != ISC_R_SUCCESS) {
fprintf (stderr, "lease object lookup: %s\n", fprintf (stderr, "dhcpctl_open_object 2: %s\n",
isc_result_totext (waitstatus)); isc_result_totext (waitstatus));
exit (1); exit (1);
} }
memset (&identifier, 0, sizeof identifier);
status = dhcpctl_get_value (&identifier, lease_handle,
"dhcp-client-identifier");
if (status == ISC_R_SUCCESS) {
printf ("lease client-identifier = %02x",
identifier -> value [0]);
for (i = 1; i < identifier -> len; i++) {
printf (":%02x", identifier -> value [i]);
}
putchar ('\n');
} else {
status = dhcpctl_get_value (&identifier, lease_handle,
"hardware-address");
if (status == ISC_R_SUCCESS) {
printf ("lease hardware address = %02x",
identifier -> value [0]);
for (i = 1; i < identifier -> len; i++) {
printf (":%02x", identifier -> value [i]);
}
putchar ('\n');
dhcpctl_data_string_dereference (&identifier, MDL);
status = dhcpctl_get_value (&identifier, lease_handle,
"hardware-type");
if (status == ISC_R_SUCCESS) {
printf ("lease hardware type = %d\n",
identifier -> value [0]);
dhcpctl_data_string_dereference (&identifier,
MDL);
}
} else {
printf ("Unable to find identifier for lease.\n");
}
}
exit (0); exit (0);
} }

View File

@ -53,6 +53,8 @@
#define ssize_t int #define ssize_t int
#define SOCKLEN_T int
/* No endian.h either. */ /* No endian.h either. */
/* /*
* Definitions for byte order, according to byte significance from low * Definitions for byte order, according to byte significance from low

View File

@ -100,6 +100,7 @@ extern int h_errno;
#define INADDR_LOOPBACK ((u_int32_t)0x7f000001) #define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
#define EOL '\n' #define EOL '\n'
#define VOIDPTR void * #define VOIDPTR void *
#define SOCKLEN_T int
/* /*
* Time stuff... * Time stuff...

View File

@ -291,7 +291,9 @@ enum dhcp_token {
PAUSED = 587, PAUSED = 587,
RECOVER_DONE = 588, RECOVER_DONE = 588,
SHUTDOWN = 589, SHUTDOWN = 589,
STARTUP = 590 STARTUP = 590,
ENCAPSULATE = 591,
VENDOR = 592
}; };
#define is_identifier(x) ((x) >= FIRST_TOKEN && \ #define is_identifier(x) ((x) >= FIRST_TOKEN && \

View File

@ -197,6 +197,7 @@ ns_rcode find_cached_zone (const char *, ns_class, char *,
int find_tsig_key (ns_tsig_key **, const char *, void *); int find_tsig_key (ns_tsig_key **, const char *, void *);
int forget_zone (void *); int forget_zone (void *);
int repudiate_zone (void *); int repudiate_zone (void *);
void cache_found_zone (ns_class, char *, struct in_addr *, int);
#define DprintQ(a,b,c,d) #define DprintQ(a,b,c,d)
#define Dprint(a,b) #define Dprint(a,b)

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp.h,v 1.1.1.1 1997/03/29 21:52:18 mellon Exp $ */ /* $NetBSD: udp.h,v 1.1.1.2 2000/10/17 15:09:17 taca Exp $ */
/* /*
* Copyright (c) 1982, 1986, 1993 * Copyright (c) 1982, 1986, 1993
@ -42,6 +42,6 @@
struct udphdr { struct udphdr {
u_int16_t uh_sport; /* source port */ u_int16_t uh_sport; /* source port */
u_int16_t uh_dport; /* destination port */ u_int16_t uh_dport; /* destination port */
int16_t uh_ulen; /* udp length */ u_int16_t uh_ulen; /* udp length */
u_int16_t uh_sum; /* udp checksum */ u_int16_t uh_sum; /* udp checksum */
}; };

View File

@ -125,6 +125,7 @@ typedef struct __omapi_object_type_t {
isc_result_t (*allocator) (omapi_object_t **, const char *, int); isc_result_t (*allocator) (omapi_object_t **, const char *, int);
isc_result_t (*sizer) (size_t); isc_result_t (*sizer) (size_t);
size_t size; size_t size;
isc_result_t (*initialize) (omapi_object_t *, const char *, int);
} omapi_object_type_t; } omapi_object_type_t;
#define OMAPI_OBJECT_PREAMBLE \ #define OMAPI_OBJECT_PREAMBLE \
@ -418,7 +419,9 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **,
const char *, int), const char *, int),
isc_result_t (*) (omapi_object_t **, isc_result_t (*) (omapi_object_t **,
const char *, int), const char *, int),
isc_result_t (*) (size_t), size_t); isc_result_t (*) (size_t), size_t,
isc_result_t (*) (omapi_object_t *,
const char *, int));
isc_result_t omapi_signal (omapi_object_t *, const char *, ...); isc_result_t omapi_signal (omapi_object_t *, const char *, ...);
isc_result_t omapi_signal_in (omapi_object_t *, const char *, ...); isc_result_t omapi_signal_in (omapi_object_t *, const char *, ...);
isc_result_t omapi_set_value (omapi_object_t *, omapi_object_t *, isc_result_t omapi_set_value (omapi_object_t *, omapi_object_t *,

View File

@ -60,6 +60,7 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <memory.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>

View File

@ -284,34 +284,37 @@ struct lease; /* forward */
struct universe { struct universe {
const char *name; const char *name;
struct option_cache *(*lookup_func) PROTO ((struct universe *, struct option_cache *(*lookup_func) (struct universe *,
struct option_state *, struct option_state *,
unsigned)); unsigned);
void (*save_func) PROTO ((struct universe *, struct option_state *, void (*save_func) (struct universe *, struct option_state *,
struct option_cache *)); struct option_cache *);
int (*get_func) PROTO ((struct data_string *, struct universe *, void (*foreach) (struct packet *, struct lease *,
struct packet *, struct lease *, struct option_state *, struct option_state *,
struct option_state *, struct option_state *, struct binding_scope **, struct universe *, void *,
struct option_state *, struct binding_scope **, void (*) (struct option_cache *, struct packet *,
unsigned));
void (*set_func) PROTO ((struct universe *, struct option_state *,
struct option_cache *, enum statement_op));
void (*delete_func) PROTO ((struct universe *universe,
struct option_state *, int));
int (*option_state_dereference) PROTO ((struct universe *,
struct option_state *,
const char *, int));
int (*encapsulate) PROTO ((struct data_string *, struct packet *,
struct lease *, struct option_state *, struct lease *, struct option_state *,
struct option_state *, struct option_state *,
struct binding_scope **, struct binding_scope **,
struct universe *)); struct universe *, void *));
void (*delete_func) (struct universe *universe,
struct option_state *, int);
int (*option_state_dereference) (struct universe *,
struct option_state *,
const char *, int);
int (*decode) (struct option_state *,
unsigned char *, unsigned, struct universe *);
int (*encapsulate) (struct data_string *, struct packet *,
struct lease *, struct option_state *,
struct option_state *,
struct binding_scope **,
struct universe *);
void (*store_tag) PROTO ((unsigned char *, u_int32_t)); void (*store_tag) PROTO ((unsigned char *, u_int32_t));
void (*store_length) PROTO ((unsigned char *, u_int32_t)); void (*store_length) PROTO ((unsigned char *, u_int32_t));
int tag_size, length_size; int tag_size, length_size;
struct hash_table *hash; struct hash_table *hash;
struct option *options [256]; struct option *options [256];
struct option *enc_opt;
int index; int index;
}; };

View File

@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER) #if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: res_findzonecut.c,v 1.1.1.4 2000/07/20 05:50:17 mellon Exp $"; static const char rcsid[] = "$Id: res_findzonecut.c,v 1.1.1.5 2000/10/17 15:09:34 taca Exp $";
#endif /* not lint */ #endif /* not lint */
/* /*
@ -175,6 +175,9 @@ res_findzonecut(res_state statp, const char *dname, ns_class class, int opts,
if ((rcode = get_glue(statp, class, &nsrrs)) == ns_r_noerror) if ((rcode = get_glue(statp, class, &nsrrs)) == ns_r_noerror)
n = satisfy(statp, mname, &nsrrs, addrs, naddrs); n = satisfy(statp, mname, &nsrrs, addrs, naddrs);
/* If we found the zone, cache it. */
if (n > 0)
cache_found_zone (class, zname, addrs, n);
done: done:
DPRINTF(("FINISH n=%d (%s)", n, (n < 0) ? strerror(errno) : "OK")); DPRINTF(("FINISH n=%d (%s)", n, (n < 0) ? strerror(errno) : "OK"));
free_nsrrset(&nsrrs); free_nsrrset(&nsrrs);
@ -262,7 +265,7 @@ get_soa(res_state statp, const char *dname, ns_class class,
/* Is there an SOA? */ /* Is there an SOA? */
rcode = do_query(statp, dname, class, ns_t_soa, rcode = do_query(statp, dname, class, ns_t_soa,
resp, &msg, &n); resp, &msg, &n);
if (rcode != ns_r_noerror) { if (n < 0) {
DPRINTF(("get_soa: do_query('%s', %s) failed (%d)", DPRINTF(("get_soa: do_query('%s', %s) failed (%d)",
dname, p_class(class), n)); dname, p_class(class), n));
return rcode; return rcode;

View File

@ -357,6 +357,8 @@ isc_result_t omapi_object_initialize (omapi_object_t *o,
{ {
memset (o, 0, psize); memset (o, 0, psize);
o -> type = type; o -> type = type;
if (type -> initialize)
(*type -> initialize) (o, file, line);
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
} }

View File

@ -447,6 +447,10 @@ isc_result_t omapi_connection_write_typed_data (omapi_object_t *c,
isc_result_t status; isc_result_t status;
omapi_handle_t handle; omapi_handle_t handle;
/* Null data is valid. */
if (!data)
return omapi_connection_put_uint32 (c, 0);
switch (data -> type) { switch (data -> type) {
case omapi_datatype_int: case omapi_datatype_int:
status = omapi_connection_put_uint32 (c, sizeof (u_int32_t)); status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));

View File

@ -197,9 +197,11 @@ isc_result_t omapi_connect_list (omapi_object_t *c,
0, omapi_connection_writefd, 0, omapi_connection_writefd,
0, omapi_connection_connect, 0, omapi_connection_connect,
omapi_connection_reaper)); omapi_connection_reaper));
if (status != ISC_R_SUCCESS)
goto out;
obj -> state = omapi_connection_unconnected; obj -> state = omapi_connection_unconnected;
omapi_connection_connect ((omapi_object_t *)obj); status = omapi_connection_connect ((omapi_object_t *)obj);
out:
omapi_connection_dereference (&obj, MDL); omapi_connection_dereference (&obj, MDL);
return status; return status;
} }
@ -358,7 +360,18 @@ isc_result_t omapi_connection_connect (omapi_object_t *h)
error = errno; error = errno;
if (error != EINPROGRESS) { if (error != EINPROGRESS) {
omapi_disconnect (h, 1); omapi_disconnect (h, 1);
return ISC_R_UNEXPECTED; switch (error) {
case ECONNREFUSED:
status = ISC_R_CONNREFUSED;
break;
case ENETUNREACH:
status = ISC_R_NETUNREACH;
break;
default:
status = ISC_R_UNEXPECTED;
break;
}
return status;
} }
c -> state = omapi_connection_connecting; c -> state = omapi_connection_connecting;
return ISC_R_INCOMPLETE; return ISC_R_INCOMPLETE;

View File

@ -0,0 +1,150 @@
/* $NetBSD: inet_addr.c,v 1.6 1996/02/02 15:22:23 mrg Exp $ */
/*
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
#else
static char rcsid[] = "$NetBSD: inet_addr.c,v 1.6 1996/02/02 15:22:23 mrg Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
#ifndef lint
static char copyright[] =
"$Id: inet_addr.c,v 1.1 2000/09/20 00:01:50 mellon Exp $ Copyright (c) 1983, 1990, 1993 The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#include "omapip/omapip_p.h"
#ifdef NEED_INET_ATON
/*
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.
* Returns 1 if the address is valid, 0 if not.
* This replaces inet_addr, the return value from which
* cannot distinguish between failure and a local broadcast address.
*/
int
inet_aton(cp, addr)
const char *cp;
struct in_addr *addr;
{
register u_long val;
register int base, n;
register char c;
u_int parts[4];
register u_int *pp = parts;
for (;;) {
/*
* Collect number up to ``.''.
* Values are specified as for C:
* 0x=hex, 0=octal, other=decimal.
*/
val = 0; base = 10;
if (*cp == '0') {
if (*++cp == 'x' || *cp == 'X')
base = 16, cp++;
else
base = 8;
}
while ((c = *cp) != '\0') {
if (isascii(c) && isdigit(c)) {
val = (val * base) + (c - '0');
cp++;
continue;
}
if (base == 16 && isascii(c) && isxdigit(c)) {
val = (val << 4) +
(c + 10 - (islower(c) ? 'a' : 'A'));
cp++;
continue;
}
break;
}
if (*cp == '.') {
/*
* Internet format:
* a.b.c.d
* a.b.c (with c treated as 16-bits)
* a.b (with b treated as 24 bits)
*/
if (pp >= parts + 3 || val > 0xff)
return (0);
*pp++ = val, cp++;
} else
break;
}
/*
* Check for trailing characters.
*/
if (*cp && (!isascii(*cp) || !isspace(*cp)))
return (0);
/*
* Concoct the address according to
* the number of parts specified.
*/
n = pp - parts + 1;
switch (n) {
case 0:
return (0); /* initial nondigit */
case 1: /* a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
if (val > 0xffffff)
return (0);
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
if (addr)
addr->s_addr = htonl(val);
return (1);
}
#endif

View File

@ -66,7 +66,7 @@ isc_result_t omapi_protocol_connect (omapi_object_t *h,
return status; return status;
status = omapi_connect ((omapi_object_t *)obj, server_name, port); status = omapi_connect ((omapi_object_t *)obj, server_name, port);
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS && status != ISC_R_INCOMPLETE) {
omapi_protocol_dereference (&obj, MDL); omapi_protocol_dereference (&obj, MDL);
return status; return status;
} }

View File

@ -75,7 +75,7 @@ isc_result_t omapi_init (void)
omapi_connection_stuff_values, omapi_connection_stuff_values,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof sizeof
(omapi_connection_object_t)); (omapi_connection_object_t), 0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -87,7 +87,8 @@ isc_result_t omapi_init (void)
omapi_listener_signal_handler, omapi_listener_signal_handler,
omapi_listener_stuff_values, omapi_listener_stuff_values,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_listener_object_t)); sizeof (omapi_listener_object_t),
0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -99,7 +100,7 @@ isc_result_t omapi_init (void)
omapi_io_signal_handler, omapi_io_signal_handler,
omapi_io_stuff_values, omapi_io_stuff_values,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_io_object_t)); sizeof (omapi_io_object_t), 0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -111,7 +112,8 @@ isc_result_t omapi_init (void)
omapi_generic_signal_handler, omapi_generic_signal_handler,
omapi_generic_stuff_values, omapi_generic_stuff_values,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_generic_object_t)); sizeof (omapi_generic_object_t),
0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -123,7 +125,8 @@ isc_result_t omapi_init (void)
omapi_protocol_signal_handler, omapi_protocol_signal_handler,
omapi_protocol_stuff_values, omapi_protocol_stuff_values,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_protocol_object_t)); sizeof (omapi_protocol_object_t),
0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -135,7 +138,7 @@ isc_result_t omapi_init (void)
omapi_protocol_listener_signal, omapi_protocol_listener_signal,
omapi_protocol_listener_stuff, omapi_protocol_listener_stuff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_protocol_listener_object_t))); sizeof (omapi_protocol_listener_object_t), 0));
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -147,7 +150,8 @@ isc_result_t omapi_init (void)
omapi_message_signal_handler, omapi_message_signal_handler,
omapi_message_stuff_values, omapi_message_stuff_values,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_message_object_t)); sizeof (omapi_message_object_t),
0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -158,7 +162,8 @@ isc_result_t omapi_init (void)
0, 0,
omapi_waiter_signal_handler, 0, omapi_waiter_signal_handler, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_waiter_object_t)); sizeof (omapi_waiter_object_t),
0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -171,7 +176,7 @@ isc_result_t omapi_init (void)
omapi_auth_key_stuff_values, omapi_auth_key_stuff_values,
omapi_auth_key_lookup, omapi_auth_key_lookup,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
sizeof (omapi_auth_key_t)); sizeof (omapi_auth_key_t), 0);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS)
return status; return status;
@ -218,7 +223,10 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **type,
(omapi_object_t **, (omapi_object_t **,
const char *, int), const char *, int),
isc_result_t (*sizer) (size_t), isc_result_t (*sizer) (size_t),
size_t size) size_t size,
isc_result_t (*initialize)
(omapi_object_t *,
const char *, int))
{ {
omapi_object_type_t *t; omapi_object_type_t *t;
@ -241,6 +249,7 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **type,
t -> size = size; t -> size = size;
t -> freer = freer; t -> freer = freer;
t -> allocator = allocator; t -> allocator = allocator;
t -> initialize = initialize;
omapi_object_types = t; omapi_object_types = t;
if (type) if (type)
*type = t; *type = t;
@ -290,13 +299,47 @@ isc_result_t omapi_set_value (omapi_object_t *h,
omapi_typed_data_t *value) omapi_typed_data_t *value)
{ {
omapi_object_t *outer; omapi_object_t *outer;
isc_result_t status;
#if defined (DEBUG)
if (!value) {
log_info ("omapi_set_value (%.*s, NULL)",
(int)name -> len, name -> value);
} else if (value -> type == omapi_datatype_int) {
log_info ("omapi_set_value (%.*s, %ld)",
(int)name -> len, name -> value,
(long)value -> u.integer);
} else if (value -> type == omapi_datatype_string) {
log_info ("omapi_set_value (%.*s, %.*s)",
(int)name -> len, name -> value,
(int)value -> u.buffer.len, value -> u.buffer.value);
} else if (value -> type == omapi_datatype_data) {
log_info ("omapi_set_value (%.*s, %ld %lx)",
(int)name -> len, name -> value,
(long)value -> u.buffer.len,
(unsigned long)value -> u.buffer.value);
} else if (value -> type == omapi_datatype_object) {
log_info ("omapi_set_value (%.*s, %s)",
(int)name -> len, name -> value,
value -> u.object
? (value -> u.object -> type
? value -> u.object -> type -> name
: "(unknown object)")
: "(unknown object)");
}
#endif
for (outer = h; outer -> outer; outer = outer -> outer) for (outer = h; outer -> outer; outer = outer -> outer)
; ;
if (outer -> type -> set_value) if (outer -> type -> set_value)
return (*(outer -> type -> set_value)) (outer, status = (*(outer -> type -> set_value)) (outer,
id, name, value); id, name, value);
return ISC_R_NOTFOUND; else
status = ISC_R_NOTFOUND;
#if defined (DEBUG)
log_info (" ==> %s", isc_result_totext (status));
#endif
return status;
} }
isc_result_t omapi_set_value_str (omapi_object_t *h, isc_result_t omapi_set_value_str (omapi_object_t *h,
@ -496,7 +539,7 @@ isc_result_t omapi_object_update (omapi_object_t *obj, omapi_object_t *id,
status = omapi_set_value (obj, id, status = omapi_set_value (obj, id,
gsrc -> values [i] -> name, gsrc -> values [i] -> name,
gsrc -> values [i] -> value); gsrc -> values [i] -> value);
if (status != ISC_R_SUCCESS) if (status != ISC_R_SUCCESS && status != ISC_R_UNCHANGED)
return status; return status;
} }
if (handle) if (handle)

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: class.c,v 1.1.1.3 2000/09/04 23:10:37 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: class.c,v 1.1.1.4 2000/10/17 15:10:03 taca Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
@ -106,14 +106,42 @@ int check_collection (packet, lease, collection)
log_info ("checking against class %s...", class -> name); log_info ("checking against class %s...", class -> name);
#endif #endif
memset (&data, 0, sizeof data); memset (&data, 0, sizeof data);
/* If a class is for billing, don't put the client in the
class if we've already billed it to a different class. */ /* If there is a "match if" expression, check it. If
we get a match, and there's no subclass expression,
it's a match. If we get a match and there is a subclass
expression, then we check the submatch. If it's not a
match, that's final - we don't check the submatch. */
if (class -> expr) {
status = (evaluate_boolean_expression_result
(&ignorep, packet, lease,
packet -> options, (struct option_state *)0,
lease ? &lease -> scope : &global_scope,
class -> expr));
if (status) {
if (!class -> submatch) {
matched = 1;
#if defined (DEBUG_CLASS_MATCHING)
log_info ("matches class.");
#endif
classify (packet, class);
continue;
}
} else
continue;
}
/* Check to see if the client matches an existing subclass.
If it doesn't, and this is a spawning class, spawn a new
subclass and put the client in it. */
if (class -> submatch) { if (class -> submatch) {
status = (evaluate_data_expression status = (evaluate_data_expression
(&data, packet, lease, (&data, packet, lease,
packet -> options, (struct option_state *)0, packet -> options, (struct option_state *)0,
&lease -> scope, class -> submatch)); lease ? &lease -> scope : &global_scope,
if (status) { class -> submatch));
if (status && data.len) {
nc = (struct class *)0; nc = (struct class *)0;
if (class_hash_lookup (&nc, class -> hash, if (class_hash_lookup (&nc, class -> hash,
(const char *)data.data, (const char *)data.data,
@ -126,6 +154,7 @@ int check_collection (packet, lease, collection)
data_string_forget (&data, MDL); data_string_forget (&data, MDL);
classify (packet, nc); classify (packet, nc);
matched = 1; matched = 1;
class_dereference (&nc, MDL);
continue; continue;
} }
if (!class -> spawning) { if (!class -> spawning) {
@ -136,11 +165,11 @@ int check_collection (packet, lease, collection)
log_info ("spawning subclass %s.", log_info ("spawning subclass %s.",
print_hex_1 (data.len, data.data, 60)); print_hex_1 (data.len, data.data, 60));
#endif #endif
nc = (struct class *) status = class_allocate (&nc, MDL);
dmalloc (sizeof (struct class), MDL); group_reference (&nc -> group,
memset (nc, 0, sizeof *nc); class -> group, MDL);
nc -> group = class -> group; class_reference (&nc -> superclass,
nc -> superclass = class; class, MDL);
nc -> lease_limit = class -> lease_limit; nc -> lease_limit = class -> lease_limit;
nc -> dirty = 1; nc -> dirty = 1;
if (nc -> lease_limit) { if (nc -> lease_limit) {
@ -155,7 +184,7 @@ int check_collection (packet, lease, collection)
data_string_forget data_string_forget
(&nc -> hash_string, (&nc -> hash_string,
MDL); MDL);
dfree (nc, MDL); class_dereference (&nc, MDL);
data_string_forget (&data, data_string_forget (&data,
MDL); MDL);
continue; continue;
@ -177,18 +206,6 @@ int check_collection (packet, lease, collection)
classify (packet, nc); classify (packet, nc);
} }
} }
status = (evaluate_boolean_expression_result
(&ignorep, packet, lease,
packet -> options, (struct option_state *)0,
&lease -> scope, class -> expr));
if (status) {
matched = 1;
#if defined (DEBUG_CLASS_MATCHING)
log_info ("matches class.");
#endif
classify (packet, class);
}
} }
return matched; return matched;
} }

View File

@ -11,6 +11,9 @@ option subnet-mask 255.255.255.224;
default-lease-time 600; default-lease-time 600;
max-lease-time 7200; max-lease-time 7200;
subnet 204.152.187.0 netmask 255.255.255.0 {
}
subnet 204.254.239.0 netmask 255.255.255.224 { subnet 204.254.239.0 netmask 255.255.255.224 {
range 204.254.239.10 204.254.239.20; range 204.254.239.10 204.254.239.20;
option broadcast-address 204.254.239.31; option broadcast-address 204.254.239.31;
@ -19,14 +22,14 @@ subnet 204.254.239.0 netmask 255.255.255.224 {
# The other subnet that shares this physical network # The other subnet that shares this physical network
subnet 204.254.239.32 netmask 255.255.255.224 { subnet 204.254.239.32 netmask 255.255.255.224 {
range dynamic-bootp 204.254.239.10 204.254.239.20; range dynamic-bootp 204.254.239.40 204.254.239.60;
option broadcast-address 204.254.239.31; option broadcast-address 204.254.239.31;
option routers snarg.fugue.com; option routers snarg.fugue.com;
} }
subnet 192.5.5.0 netmask 255.255.255.224 { subnet 192.5.5.0 netmask 255.255.255.224 {
range 192.5.5.26 192.5.5.30; range 192.5.5.26 192.5.5.30;
option name-servers bb.home.vix.com, gw.home.vix.com; option domain-name-servers bb.home.vix.com, gw.home.vix.com;
option domain-name "vix.com"; option domain-name "vix.com";
option routers 192.5.5.1; option routers 192.5.5.1;
option subnet-mask 255.255.255.224; option subnet-mask 255.255.255.224;
@ -58,33 +61,3 @@ host fantasia {
fixed-address fantasia.fugue.com; fixed-address fantasia.fugue.com;
} }
# If a DHCP or BOOTP client is mobile and might be connected to a variety
# of networks, more than one fixed address for that host can be specified.
# Hosts can have fixed addresses on some networks, but receive dynamically
# allocated address on other subnets; in order to support this, a host
# declaration for that client must be given which does not have a fixed
# address. If a client should get different parameters depending on
# what subnet it boots on, host declarations for each such network should
# be given. Finally, if a domain name is given for a host's fixed address
# and that domain name evaluates to more than one address, the address
# corresponding to the network to which the client is attached, if any,
# will be assigned.
host confusia {
hardware ethernet 02:03:04:05:06:07;
fixed-address confusia-1.fugue.com, confusia-2.fugue.com;
filename "vmunix.confusia";
server-name "toccata.fugue.com";
}
host confusia {
hardware ethernet 02:03:04:05:06:07;
fixed-address confusia-3.fugue.com;
filename "vmunix.confusia";
server-name "snarg.fugue.com";
}
host confusia {
hardware ethernet 02:03:04:05:06:07;
filename "vmunix.confusia";
server-name "bb.home.vix.com";
}

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: failover.c,v 1.1.1.5 2000/09/04 23:10:50 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: failover.c,v 1.1.1.6 2000/10/17 15:10:42 taca Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -68,17 +68,14 @@ void dhcp_failover_startup ()
/* In case the peer is already running, immediately try /* In case the peer is already running, immediately try
to establish a connection with it. */ to establish a connection with it. */
status = (dhcp_failover_link_initiate status = dhcp_failover_link_initiate ((omapi_object_t *)state);
((omapi_object_t *)state)); if (status != ISC_R_SUCCESS && status != ISC_R_INCOMPLETE) {
if (status != ISC_R_SUCCESS) {
add_timeout (cur_time + 90, add_timeout (cur_time + 90,
dhcp_failover_reconnect, state, dhcp_failover_reconnect, state,
(tvref_t) (tvref_t)
dhcp_failover_state_reference, dhcp_failover_state_reference,
(tvunref_t) (tvunref_t)
dhcp_failover_state_dereference); dhcp_failover_state_dereference);
}
if (status != ISC_R_SUCCESS) {
log_error ("failover peer %s: %s", state -> name, log_error ("failover peer %s: %s", state -> name,
isc_result_totext (status)); isc_result_totext (status));
} }
@ -297,15 +294,20 @@ isc_result_t dhcp_failover_link_signal (omapi_object_t *h,
if (!strcmp (name, "disconnect")) { if (!strcmp (name, "disconnect")) {
if (link -> state_object && if (link -> state_object &&
link -> state_object -> link_to_peer == link) { link -> state_object -> link_to_peer == link) {
if (link -> state_object -> i_am == primary) { dhcp_failover_state_reference (&state,
add_timeout (cur_time + 5, dhcp_failover_reconnect, link -> state_object, MDL);
link -> state_object,
(tvref_t)dhcp_failover_state_reference,
(tvunref_t)dhcp_failover_state_dereference);
}
link -> state = dhcp_flink_disconnected; link -> state = dhcp_flink_disconnected;
/* Make the transition. */ /* Make the transition. */
dhcp_failover_state_transition (link -> state_object, name); dhcp_failover_state_transition (link -> state_object, name);
/* Start trying to reconnect. */
add_timeout (cur_time + 5, dhcp_failover_reconnect,
state,
(tvref_t)dhcp_failover_state_reference,
(tvunref_t)dhcp_failover_state_dereference);
dhcp_failover_state_dereference (&state, MDL);
} }
return ISC_R_SUCCESS; return ISC_R_SUCCESS;
} }

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: mdb.c,v 1.1.1.5 2000/09/04 23:10:50 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: mdb.c,v 1.1.1.6 2000/10/17 15:10:46 taca Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -733,12 +733,25 @@ void enter_lease (lease)
if (comp -> subnet) if (comp -> subnet)
subnet_reference (&lease -> subnet, subnet_reference (&lease -> subnet,
comp -> subnet, MDL); comp -> subnet, MDL);
lease_hash_delete (lease_ip_addr_hash, lease_hash_delete (lease_ip_addr_hash,
lease -> ip_addr.iabuf, lease -> ip_addr.iabuf,
lease -> ip_addr.len, MDL); lease -> ip_addr.len, MDL);
lease_dereference (&comp, MDL); lease_dereference (&comp, MDL);
} }
/* The only way a lease can get here without a subnet is if it's in
the lease file, but not in the dhcpd.conf file. In this case, we
*should* keep it around until it's expired, but never reallocate it
or renew it. Currently, to maintain consistency, we are not doing
this.
XXX fix this so that the lease is kept around until it expires.
XXX this will be important in IPv6 with addresses that become
XXX non-renewable as a result of a renumbering event. */
if (!lease -> subnet) {
log_error ("lease %s: no subnet.", piaddr (lease -> ip_addr));
return;
}
lease_hash_add (lease_ip_addr_hash, lease_hash_add (lease_ip_addr_hash,
lease -> ip_addr.iabuf, lease -> ip_addr.iabuf,
lease -> ip_addr.len, lease, MDL); lease -> ip_addr.len, lease, MDL);

View File

@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: stables.c,v 1.1.1.4 2000/09/04 23:10:52 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n"; "$Id: stables.c,v 1.1.1.5 2000/10/17 15:10:52 taca Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@ -710,8 +710,13 @@ void initialize_server_option_spaces()
/* Set up the Relay Agent Information Option suboption space... */ /* Set up the Relay Agent Information Option suboption space... */
agent_universe.name = "agent"; agent_universe.name = "agent";
agent_universe.option_state_dereference = agent_universe.option_state_dereference =
agent_option_state_dereference; linked_option_state_dereference;
agent_universe.get_func = agent_option_get; agent_universe.lookup_func = lookup_linked_option;
agent_universe.save_func = save_linked_option;
agent_universe.delete_func = delete_linked_option;
agent_universe.encapsulate = linked_option_space_encapsulate;
agent_universe.foreach = linked_option_space_foreach;
agent_universe.decode = parse_option_buffer;
agent_universe.index = universe_count++; agent_universe.index = universe_count++;
agent_universe.length_size = 1; agent_universe.length_size = 1;
agent_universe.tag_size = 1; agent_universe.tag_size = 1;
@ -727,17 +732,18 @@ void initialize_server_option_spaces()
agent_options [i].name, 0, agent_options [i].name, 0,
&agent_options [i], MDL); &agent_options [i], MDL);
} }
agent_universe.enc_opt = &dhcp_options [DHO_DHCP_AGENT_OPTIONS];
/* Set up the server option universe... */ /* Set up the server option universe... */
server_universe.name = "server"; server_universe.name = "server";
server_universe.lookup_func = lookup_hashed_option; server_universe.lookup_func = lookup_hashed_option;
server_universe.option_state_dereference = server_universe.option_state_dereference =
hashed_option_state_dereference; hashed_option_state_dereference;
server_universe.get_func = hashed_option_get;
server_universe.set_func = hashed_option_set;
server_universe.save_func = save_hashed_option; server_universe.save_func = save_hashed_option;
server_universe.delete_func = delete_hashed_option; server_universe.delete_func = delete_hashed_option;
server_universe.encapsulate = hashed_option_space_encapsulate; server_universe.encapsulate = hashed_option_space_encapsulate;
server_universe.foreach = hashed_option_space_foreach;
server_universe.length_size = 1; server_universe.length_size = 1;
server_universe.tag_size = 1; server_universe.tag_size = 1;
server_universe.store_tag = putUChar; server_universe.store_tag = putUChar;
@ -762,4 +768,5 @@ void initialize_server_option_spaces()
/* Make the server universe the configuration option universe. */ /* Make the server universe the configuration option universe. */
config_universe = &server_universe; config_universe = &server_universe;
vendor_cfg_option = &server_options [SV_VENDOR_OPTION_SPACE];
} }