DHCP 3.0 Beta 2 Patchlevel 9
This commit is contained in:
parent
f8920e714b
commit
70a42dc992
|
@ -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
|
||||
more information, see
|
||||
.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
|
||||
\fBmedium "\fImedia setup\fB";\fR
|
||||
.PP
|
||||
|
|
|
@ -22,6 +22,13 @@
|
|||
# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
|
||||
# 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.
|
||||
function exit_with_hooks() {
|
||||
exit_status=$1
|
||||
|
@ -136,10 +143,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
|||
ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
|
||||
route add -host $alias_ip_address $interface:0
|
||||
fi
|
||||
echo search $new_domain_name >/etc/resolv.conf
|
||||
for nameserver in $new_domain_name_servers; do
|
||||
echo nameserver $nameserver >>/etc/resolv.conf
|
||||
done
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
|
@ -180,14 +184,7 @@ if [ x$reason = xTIMEOUT ]; then
|
|||
for router in $new_routers; do
|
||||
route add default gw $router
|
||||
done
|
||||
echo search $new_domain_name >/etc/resolv.conf.std
|
||||
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
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
ifconfig $interface inet down
|
||||
|
|
|
@ -123,10 +123,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
|||
ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
|
||||
route add $alias_ip_address 127.0.0.1
|
||||
fi
|
||||
echo search $new_domain_name >/etc/resolv.conf
|
||||
for nameserver in $new_domain_name_servers; do
|
||||
echo nameserver $nameserver >>/etc/resolv.conf
|
||||
done
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
|
@ -183,14 +180,7 @@ if [ x$reason = xTIMEOUT ]; then
|
|||
route add $0 $1
|
||||
shift; shift
|
||||
done
|
||||
echo search $new_domain_name >/etc/resolv.conf.std
|
||||
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
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -116,10 +116,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
|
|||
$ifconfig ${interface}:1 inet $alias_ip_address $alias_subnet_arg
|
||||
route add $alias_ip_address 127.0.0.1 1
|
||||
fi
|
||||
echo search $new_domain_name >/etc/resolv.conf
|
||||
for nameserver in $new_domain_name_servers; do
|
||||
echo nameserver $nameserver >>/etc/resolv.conf
|
||||
done
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
|
||||
|
@ -161,14 +158,7 @@ if [ x$reason = xTIMEOUT ]; then
|
|||
for router in $new_routers; do
|
||||
route add default $router 1 >/dev/null 2>&1
|
||||
done
|
||||
echo search $new_domain_name >/etc/resolv.conf.std
|
||||
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
|
||||
make_resolv_conf
|
||||
exit_with_hooks 0
|
||||
fi
|
||||
$ifconfig $interface inet 0 down
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -647,6 +647,8 @@ static enum dhcp_token intern (atom, dfv)
|
|||
return ERROR;
|
||||
if (!strcasecmp (atom + 1, "val"))
|
||||
return EVAL;
|
||||
if (!strcasecmp (atom + 1, "ncapsulate"))
|
||||
return ENCAPSULATE;
|
||||
break;
|
||||
case 'f':
|
||||
if (!strcasecmp (atom + 1, "atal"))
|
||||
|
@ -1000,6 +1002,8 @@ static enum dhcp_token intern (atom, dfv)
|
|||
case 'v':
|
||||
if (!strcasecmp (atom + 1, "endor-class"))
|
||||
return VENDOR_CLASS;
|
||||
if (!strcasecmp (atom + 1, "endor"))
|
||||
return VENDOR;
|
||||
break;
|
||||
case 'w':
|
||||
if (!strcasecmp (atom + 1, "ith"))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
.\"
|
||||
.\" Support and other services are available for ISC products - see
|
||||
.\" http://www.isc.org for more information.
|
||||
.TH dhcpd-options 5
|
||||
.TH dhcpd-eval 5
|
||||
.SH NAME
|
||||
dhcp-conditionals - ISC DHCP conditional evaluation
|
||||
.SH DESCRIPTION
|
||||
|
@ -102,17 +102,6 @@ treated as false in conditionals.
|
|||
The following is the current list of boolean expressions that are
|
||||
supported by the DHCP distribution.
|
||||
.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
|
||||
.RS 0.25i
|
||||
.PP
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -138,19 +138,11 @@ isc_result_t find_tsig_key (ns_tsig_key **key, const char *zname,
|
|||
{
|
||||
isc_result_t status;
|
||||
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)
|
||||
return ISC_R_NOTFOUND;
|
||||
#endif
|
||||
|
||||
if (!zone -> key) {
|
||||
dns_zone_dereference (&zone, MDL);
|
||||
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 ||
|
||||
strlen (zone -> key -> algorithm) > NS_MAXDNAME) ||
|
||||
(!zone -> key)) {
|
||||
dns_zone_dereference (&zone, MDL);
|
||||
return ISC_R_INVALIDKEY;
|
||||
}
|
||||
tkey = dmalloc (sizeof *tkey, MDL);
|
||||
if (!tkey) {
|
||||
nomem:
|
||||
dns_zone_dereference (&zone, MDL);
|
||||
return ISC_R_NOMEMORY;
|
||||
}
|
||||
memset (tkey, 0, sizeof *tkey);
|
||||
|
@ -406,6 +396,70 @@ void repudiate_zone (struct dns_zone **zone)
|
|||
(*zone) -> timeout = cur_time - 1;
|
||||
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 */
|
||||
|
||||
HASH_FUNCTIONS (dns_zone, const char *, struct dns_zone)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -248,12 +248,8 @@ int execute_statements (result, packet, lease, in_options, out_options, scope,
|
|||
r -> data.option -> option -> name);
|
||||
option_statement:
|
||||
#endif
|
||||
if (r -> data.option -> option -> universe -> set_func)
|
||||
((r -> data.option -> option ->
|
||||
universe -> set_func)
|
||||
(r -> data.option -> option -> universe,
|
||||
out_options,
|
||||
r -> data.option, r -> op));
|
||||
set_option (r -> data.option -> option -> universe,
|
||||
out_options, r -> data.option, r -> op);
|
||||
break;
|
||||
|
||||
case set_statement:
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -79,9 +79,9 @@ void icmp_startup (routep, handler)
|
|||
if (dhcp_type_icmp)
|
||||
log_fatal ("attempted to reinitialize icmp protocol");
|
||||
|
||||
result = omapi_object_type_register (&dhcp_type_icmp,
|
||||
"icmp", 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, sizeof (struct icmp_state));
|
||||
result = omapi_object_type_register (&dhcp_type_icmp, "icmp",
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
sizeof (struct icmp_state), 0);
|
||||
|
||||
if (result != ISC_R_SUCCESS)
|
||||
log_fatal ("Can't register icmp object type: %s",
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -170,11 +170,14 @@ void if_deregister_send (info)
|
|||
in bpf includes... */
|
||||
extern struct sock_filter dhcp_bpf_filter [];
|
||||
extern int dhcp_bpf_filter_len;
|
||||
|
||||
#if defined (HAVE_TR_SUPPORT)
|
||||
extern struct sock_filter dhcp_bpf_tr_filter [];
|
||||
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_tr_filter_setup (struct interface_info *);
|
||||
|
||||
void if_register_receive (info)
|
||||
struct interface_info *info;
|
||||
|
@ -182,9 +185,11 @@ void if_register_receive (info)
|
|||
/* Open a LPF device and hang it on this interface... */
|
||||
info -> rfdesc = if_register_lpf (info);
|
||||
|
||||
#if defined (HAVE_TR_SUPPORT)
|
||||
if (info -> hw_address.hbuf [0] == HTYPE_IEEE802)
|
||||
lpf_tr_filter_setup (info);
|
||||
else
|
||||
#endif
|
||||
lpf_gen_filter_setup (info);
|
||||
|
||||
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)
|
||||
struct interface_info *info;
|
||||
{
|
||||
|
@ -279,6 +285,7 @@ static void lpf_tr_filter_setup (info)
|
|||
log_fatal ("Can't install packet filter program: %m");
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_TR_SUPPORT */
|
||||
#endif /* USE_LPF_RECEIVE */
|
||||
|
||||
#ifdef USE_LPF_SEND
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -120,7 +120,7 @@ int if_register_nit (info)
|
|||
/* XXX code below assumes ethernet interface! */
|
||||
info -> hw_address.hlen = 7;
|
||||
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);
|
||||
|
||||
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_udp_ip_header (interface, buf, &ibufp,
|
||||
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). */
|
||||
memcpy (buf + bufp, raw, len);
|
||||
memcpy (buf + ibufp, raw, len);
|
||||
|
||||
/* Set up the sockaddr structure... */
|
||||
#if USE_SIN_LEN
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -184,7 +184,7 @@ void if_register_send (info)
|
|||
info -> shared_network -> name : ""));
|
||||
}
|
||||
|
||||
#if !defined (USE_SOCKET_FALLBACK)
|
||||
#if defined (USE_SOCKET_SEND)
|
||||
void if_deregister_send (info)
|
||||
struct interface_info *info;
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ void if_deregister_send (info)
|
|||
(info -> shared_network ?
|
||||
info -> shared_network -> name : ""));
|
||||
}
|
||||
#endif /* !USE_SOCKET_FALLBACK */
|
||||
#endif /* USE_SOCKET_SEND */
|
||||
#endif /* USE_SOCKET_SEND || USE_SOCKET_FALLBACK */
|
||||
|
||||
#ifdef USE_SOCKET_RECEIVE
|
||||
|
@ -354,18 +354,23 @@ void maybe_setup_fallback ()
|
|||
{
|
||||
#if defined (USE_SOCKET_FALLBACK)
|
||||
isc_result_t status;
|
||||
struct interface_info *fbi;
|
||||
fbi = setup_fallback ();
|
||||
if (fbi) {
|
||||
struct interface_info *fbi = (struct interface_info *)0;
|
||||
if (setup_fallback (&fbi, MDL)) {
|
||||
fbi -> wfdesc = if_register_socket (fbi);
|
||||
fbi -> refcnt = 1;
|
||||
fbi -> type = dhcp_type_interface;
|
||||
fbi -> rfdesc = fbi -> wfdesc;
|
||||
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,
|
||||
if_readsocket, 0,
|
||||
fallback_discard, 0, 0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
log_fatal ("Can't register I/O handle for %s: %s",
|
||||
fbi -> name, isc_result_totext (status));
|
||||
interface_dereference (&fbi, MDL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -1021,10 +1021,10 @@ int evaluate_boolean_expression (result, packet, lease, in_options,
|
|||
case expr_exists:
|
||||
memset (&left, 0, sizeof left);
|
||||
if (!in_options ||
|
||||
!((*expr -> data.option -> universe -> get_func)
|
||||
(&left, expr -> data.exists -> universe,
|
||||
packet, lease, in_options, cfg_options, in_options,
|
||||
scope, expr -> data.exists -> code)))
|
||||
!get_option (&left, expr -> data.exists -> universe,
|
||||
packet, lease, in_options, cfg_options,
|
||||
in_options,
|
||||
scope, expr -> data.exists -> code))
|
||||
*result = 0;
|
||||
else {
|
||||
*result = 1;
|
||||
|
@ -1274,7 +1274,7 @@ int evaluate_data_expression (result, packet, lease,
|
|||
s1 = evaluate_numeric_expression (&len, packet, lease,
|
||||
in_options, cfg_options,
|
||||
scope,
|
||||
expr -> data.substring.len);
|
||||
expr -> data.suffix.len);
|
||||
if (s0 && s1) {
|
||||
data_string_copy (result, &data, MDL);
|
||||
|
||||
|
@ -1302,11 +1302,11 @@ int evaluate_data_expression (result, packet, lease,
|
|||
/* Extract an option. */
|
||||
case expr_option:
|
||||
if (in_options)
|
||||
s0 = ((*expr -> data.option -> universe -> get_func)
|
||||
(result, expr -> data.option -> universe,
|
||||
packet, lease,
|
||||
in_options, cfg_options, in_options,
|
||||
scope, expr -> data.option -> code));
|
||||
s0 = get_option (result,
|
||||
expr -> data.option -> universe,
|
||||
packet, lease,
|
||||
in_options, cfg_options, in_options,
|
||||
scope, expr -> data.option -> code);
|
||||
else
|
||||
s0 = 0;
|
||||
|
||||
|
@ -1321,11 +1321,11 @@ int evaluate_data_expression (result, packet, lease,
|
|||
|
||||
case expr_config_option:
|
||||
if (cfg_options)
|
||||
s0 = ((*expr -> data.option -> universe -> get_func)
|
||||
(result, expr -> data.option -> universe,
|
||||
packet, lease,
|
||||
in_options, cfg_options, cfg_options,
|
||||
scope, expr -> data.option -> code));
|
||||
s0 = get_option (result,
|
||||
expr -> data.option -> universe,
|
||||
packet, lease,
|
||||
in_options, cfg_options, cfg_options,
|
||||
scope, expr -> data.option -> code);
|
||||
else
|
||||
s0 = 0;
|
||||
|
||||
|
@ -3605,4 +3605,169 @@ int fundef_dereference (ptr, file, line)
|
|||
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: */
|
||||
|
|
|
@ -75,7 +75,7 @@ int main (argc, argv)
|
|||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp (argv[i], "-u")) {
|
||||
mode = up;
|
||||
} else if (!strcmp (argv [1], "-d")) {
|
||||
} else if (!strcmp (argv [i], "-d")) {
|
||||
mode = down;
|
||||
} else if (!strcmp (argv[i], "-n")) {
|
||||
if (++i == argc)
|
||||
|
|
|
@ -53,25 +53,38 @@ omapi_object_type_t *dhcpctl_remote_type;
|
|||
|
||||
dhcpctl_status dhcpctl_initialize ()
|
||||
{
|
||||
omapi_init();
|
||||
omapi_object_type_register (&dhcpctl_callback_type,
|
||||
"dhcpctl-callback",
|
||||
dhcpctl_callback_set_value,
|
||||
dhcpctl_callback_get_value,
|
||||
dhcpctl_callback_destroy,
|
||||
dhcpctl_callback_signal_handler,
|
||||
dhcpctl_callback_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (dhcpctl_callback_object_t));
|
||||
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));
|
||||
isc_result_t status;
|
||||
|
||||
status = omapi_init();
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
status = omapi_object_type_register (&dhcpctl_callback_type,
|
||||
"dhcpctl-callback",
|
||||
dhcpctl_callback_set_value,
|
||||
dhcpctl_callback_get_value,
|
||||
dhcpctl_callback_destroy,
|
||||
dhcpctl_callback_signal_handler,
|
||||
dhcpctl_callback_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof
|
||||
(dhcpctl_callback_object_t), 0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -381,6 +394,11 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection,
|
|||
{
|
||||
isc_result_t status;
|
||||
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);
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
|
@ -393,6 +411,7 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection,
|
|||
omapi_object_dereference (&message, MDL);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = omapi_set_object_value (message, (omapi_object_t *)0,
|
||||
"object", h);
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
|
@ -400,6 +419,13 @@ dhcpctl_status dhcpctl_object_update (dhcpctl_handle connection,
|
|||
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);
|
||||
status = omapi_protocol_send_message (connection -> outer,
|
||||
(omapi_object_t *)0,
|
||||
|
@ -417,6 +443,11 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection,
|
|||
{
|
||||
isc_result_t status;
|
||||
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);
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
|
@ -430,7 +461,7 @@ dhcpctl_status dhcpctl_object_refresh (dhcpctl_handle connection,
|
|||
return status;
|
||||
}
|
||||
status = omapi_set_int_value (message, (omapi_object_t *)0,
|
||||
"handle", (int)(h -> handle));
|
||||
"handle", (int)(ro -> remote_handle));
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
omapi_object_dereference (&message, MDL);
|
||||
return status;
|
||||
|
|
|
@ -111,13 +111,11 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h,
|
|||
omapi_object_t *g;
|
||||
isc_result_t status;
|
||||
|
||||
m = dmalloc (sizeof *m, MDL);
|
||||
if (!m)
|
||||
return ISC_R_NOMEMORY;
|
||||
memset (m, 0, sizeof *m);
|
||||
m -> type = dhcpctl_remote_type;
|
||||
m -> refcnt = 1;
|
||||
rc_register_mdl (&m, m, m -> refcnt);
|
||||
m = (dhcpctl_remote_object_t *)0;
|
||||
status = omapi_object_allocate ((omapi_object_t **)&m,
|
||||
dhcpctl_remote_type, 0, MDL);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
g = (omapi_object_t *)0;
|
||||
status = omapi_generic_new (&g, MDL);
|
||||
|
|
|
@ -122,6 +122,7 @@ int main (argc, argv)
|
|||
exit (1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Create a named group that contains the values we want to assign
|
||||
to the host. */
|
||||
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",
|
||||
(int)groupname -> len,
|
||||
groupname -> value);
|
||||
#endif
|
||||
|
||||
memset (&host_handle, 0, sizeof host_handle);
|
||||
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);
|
||||
}
|
||||
|
||||
cid -> value [0] = 0; cid -> value [1] = 0x10;
|
||||
cid -> value [2] = 0x5a; cid -> value [3] = 0xf8;
|
||||
cid -> value [4] = 0x00; cid -> value [5] = 0xbb;
|
||||
memset (&cid -> value [0], 0, 6);
|
||||
|
||||
doitagain:
|
||||
status = dhcpctl_set_value (host_handle,
|
||||
cid, "dhcp-client-identifier");
|
||||
/*#else
|
||||
doitagain: */
|
||||
status = dhcpctl_set_string_value (host_handle, "gnorf",
|
||||
"name");
|
||||
cid, "hardware-address");
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
fprintf (stderr, "dhcpctl_set_value: %s\n",
|
||||
isc_result_totext (status));
|
||||
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) {
|
||||
fprintf (stderr, "dhcpctl_set_value: %s\n",
|
||||
fprintf (stderr, "dhcpctl_set_string_value: %s\n",
|
||||
isc_result_totext (status));
|
||||
exit (1);
|
||||
}
|
||||
|
@ -244,6 +239,7 @@ option domain-name-servers 10.0.0.1, 10.0.0.2;",
|
|||
exit (1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
status = dhcpctl_set_string_value (host_handle, "\n\
|
||||
option host-name \"bar\";\n\
|
||||
option smtp-server 10.0.0.1;",
|
||||
|
@ -253,6 +249,7 @@ option smtp-server 10.0.0.1;",
|
|||
isc_result_totext (status));
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
status = dhcpctl_open_object (host_handle, connection,
|
||||
DHCPCTL_CREATE | DHCPCTL_EXCL);
|
||||
|
@ -264,75 +261,49 @@ option smtp-server 10.0.0.1;",
|
|||
|
||||
status = dhcpctl_wait_for_completion (host_handle, &waitstatus);
|
||||
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));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (waitstatus != ISC_R_SUCCESS) {
|
||||
status = dhcpctl_open_object (host_handle, connection, 0);
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
fprintf (stderr, "dhcpctl_open_object: %s\n",
|
||||
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;
|
||||
fprintf (stderr, "dhcpctl_open_object: %s\n",
|
||||
isc_result_totext (waitstatus));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
memset (&result, 0, sizeof result);
|
||||
status = dhcpctl_get_value (&result, host_handle, "name");
|
||||
cid -> value [0] = 0; cid -> value [1] = 0x10;
|
||||
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) {
|
||||
fprintf (stderr, "dhcpctl_get_value: %s\n",
|
||||
fprintf (stderr, "dhcpctl_set_value: %s\n",
|
||||
isc_result_totext (status));
|
||||
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);
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
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,
|
||||
&waitstatus);
|
||||
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));
|
||||
exit (1);
|
||||
}
|
||||
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));
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create a named group that contains the values we want to assign
|
||||
to the host. */
|
||||
memset (&lease_handle, 0, sizeof lease_handle);
|
||||
status = dhcpctl_new_object (&lease_handle, connection, "lease");
|
||||
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);
|
||||
}
|
||||
|
||||
memset (&ip_addr, 0, sizeof ip_addr);
|
||||
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);
|
||||
}
|
||||
memset (&cid -> value [0], 0, 6);
|
||||
|
||||
ip_addr -> value [0] = 10; ip_addr -> value [1] = 0;
|
||||
ip_addr -> value [2] = 0; ip_addr -> value [3] = 4;
|
||||
|
||||
status = dhcpctl_set_value (lease_handle, ip_addr, "ip-address");
|
||||
status = dhcpctl_set_value (host_handle,
|
||||
cid, "hardware-address");
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
fprintf (stderr, "dhcpctl_set_value: %s\n",
|
||||
isc_result_totext (status));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
status = dhcpctl_open_object (lease_handle, connection, 0);
|
||||
status = dhcpctl_set_string_value (host_handle, "gnorf",
|
||||
"name");
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
fprintf (stderr, "dhcpctl_open_object: %s\n",
|
||||
fprintf (stderr, "dhcpctl_set_string_value: %s\n",
|
||||
isc_result_totext (status));
|
||||
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) {
|
||||
fprintf (stderr, "dhcpctl_wait_for_completion: %s\n",
|
||||
fprintf (stderr, "dhcpctl_open_object 2: %s\n",
|
||||
isc_result_totext (status));
|
||||
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) {
|
||||
fprintf (stderr, "lease object lookup: %s\n",
|
||||
fprintf (stderr, "dhcpctl_open_object 2: %s\n",
|
||||
isc_result_totext (waitstatus));
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
|
||||
#define ssize_t int
|
||||
|
||||
#define SOCKLEN_T int
|
||||
|
||||
/* No endian.h either. */
|
||||
/*
|
||||
* Definitions for byte order, according to byte significance from low
|
||||
|
|
|
@ -100,6 +100,7 @@ extern int h_errno;
|
|||
#define INADDR_LOOPBACK ((u_int32_t)0x7f000001)
|
||||
#define EOL '\n'
|
||||
#define VOIDPTR void *
|
||||
#define SOCKLEN_T int
|
||||
|
||||
/*
|
||||
* Time stuff...
|
||||
|
|
|
@ -291,7 +291,9 @@ enum dhcp_token {
|
|||
PAUSED = 587,
|
||||
RECOVER_DONE = 588,
|
||||
SHUTDOWN = 589,
|
||||
STARTUP = 590
|
||||
STARTUP = 590,
|
||||
ENCAPSULATE = 591,
|
||||
VENDOR = 592
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
|
|
|
@ -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 forget_zone (void *);
|
||||
int repudiate_zone (void *);
|
||||
void cache_found_zone (ns_class, char *, struct in_addr *, int);
|
||||
|
||||
#define DprintQ(a,b,c,d)
|
||||
#define Dprint(a,b)
|
||||
|
|
|
@ -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
|
||||
|
@ -42,6 +42,6 @@
|
|||
struct udphdr {
|
||||
u_int16_t uh_sport; /* source 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 */
|
||||
};
|
||||
|
|
|
@ -125,6 +125,7 @@ typedef struct __omapi_object_type_t {
|
|||
isc_result_t (*allocator) (omapi_object_t **, const char *, int);
|
||||
isc_result_t (*sizer) (size_t);
|
||||
size_t size;
|
||||
isc_result_t (*initialize) (omapi_object_t *, const char *, int);
|
||||
} omapi_object_type_t;
|
||||
|
||||
#define OMAPI_OBJECT_PREAMBLE \
|
||||
|
@ -418,7 +419,9 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **,
|
|||
const char *, int),
|
||||
isc_result_t (*) (omapi_object_t **,
|
||||
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_in (omapi_object_t *, const char *, ...);
|
||||
isc_result_t omapi_set_value (omapi_object_t *, omapi_object_t *,
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
|
|
@ -284,34 +284,37 @@ struct lease; /* forward */
|
|||
|
||||
struct universe {
|
||||
const char *name;
|
||||
struct option_cache *(*lookup_func) PROTO ((struct universe *,
|
||||
struct option_state *,
|
||||
unsigned));
|
||||
void (*save_func) PROTO ((struct universe *, struct option_state *,
|
||||
struct option_cache *));
|
||||
int (*get_func) PROTO ((struct data_string *, struct universe *,
|
||||
struct packet *, struct lease *,
|
||||
struct option_state *, struct option_state *,
|
||||
struct option_state *, struct binding_scope **,
|
||||
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 option_cache *(*lookup_func) (struct universe *,
|
||||
struct option_state *,
|
||||
unsigned);
|
||||
void (*save_func) (struct universe *, struct option_state *,
|
||||
struct option_cache *);
|
||||
void (*foreach) (struct packet *, struct lease *,
|
||||
struct option_state *, struct option_state *,
|
||||
struct binding_scope **, struct universe *, void *,
|
||||
void (*) (struct option_cache *, struct packet *,
|
||||
struct lease *, struct option_state *,
|
||||
struct option_state *,
|
||||
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_length) PROTO ((unsigned char *, u_int32_t));
|
||||
int tag_size, length_size;
|
||||
struct hash_table *hash;
|
||||
struct option *options [256];
|
||||
struct option *enc_opt;
|
||||
int index;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#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 */
|
||||
|
||||
/*
|
||||
|
@ -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)
|
||||
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:
|
||||
DPRINTF(("FINISH n=%d (%s)", n, (n < 0) ? strerror(errno) : "OK"));
|
||||
free_nsrrset(&nsrrs);
|
||||
|
@ -262,7 +265,7 @@ get_soa(res_state statp, const char *dname, ns_class class,
|
|||
/* Is there an SOA? */
|
||||
rcode = do_query(statp, dname, class, ns_t_soa,
|
||||
resp, &msg, &n);
|
||||
if (rcode != ns_r_noerror) {
|
||||
if (n < 0) {
|
||||
DPRINTF(("get_soa: do_query('%s', %s) failed (%d)",
|
||||
dname, p_class(class), n));
|
||||
return rcode;
|
||||
|
|
|
@ -357,6 +357,8 @@ isc_result_t omapi_object_initialize (omapi_object_t *o,
|
|||
{
|
||||
memset (o, 0, psize);
|
||||
o -> type = type;
|
||||
if (type -> initialize)
|
||||
(*type -> initialize) (o, file, line);
|
||||
return ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -447,6 +447,10 @@ isc_result_t omapi_connection_write_typed_data (omapi_object_t *c,
|
|||
isc_result_t status;
|
||||
omapi_handle_t handle;
|
||||
|
||||
/* Null data is valid. */
|
||||
if (!data)
|
||||
return omapi_connection_put_uint32 (c, 0);
|
||||
|
||||
switch (data -> type) {
|
||||
case omapi_datatype_int:
|
||||
status = omapi_connection_put_uint32 (c, sizeof (u_int32_t));
|
||||
|
|
|
@ -197,9 +197,11 @@ isc_result_t omapi_connect_list (omapi_object_t *c,
|
|||
0, omapi_connection_writefd,
|
||||
0, omapi_connection_connect,
|
||||
omapi_connection_reaper));
|
||||
|
||||
if (status != ISC_R_SUCCESS)
|
||||
goto out;
|
||||
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);
|
||||
return status;
|
||||
}
|
||||
|
@ -358,7 +360,18 @@ isc_result_t omapi_connection_connect (omapi_object_t *h)
|
|||
error = errno;
|
||||
if (error != EINPROGRESS) {
|
||||
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;
|
||||
return ISC_R_INCOMPLETE;
|
||||
|
|
|
@ -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
|
|
@ -66,7 +66,7 @@ isc_result_t omapi_protocol_connect (omapi_object_t *h,
|
|||
return status;
|
||||
|
||||
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);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ isc_result_t omapi_init (void)
|
|||
omapi_connection_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof
|
||||
(omapi_connection_object_t));
|
||||
(omapi_connection_object_t), 0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -87,7 +87,8 @@ isc_result_t omapi_init (void)
|
|||
omapi_listener_signal_handler,
|
||||
omapi_listener_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_listener_object_t));
|
||||
sizeof (omapi_listener_object_t),
|
||||
0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -99,7 +100,7 @@ isc_result_t omapi_init (void)
|
|||
omapi_io_signal_handler,
|
||||
omapi_io_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_io_object_t));
|
||||
sizeof (omapi_io_object_t), 0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -111,7 +112,8 @@ isc_result_t omapi_init (void)
|
|||
omapi_generic_signal_handler,
|
||||
omapi_generic_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_generic_object_t));
|
||||
sizeof (omapi_generic_object_t),
|
||||
0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -123,7 +125,8 @@ isc_result_t omapi_init (void)
|
|||
omapi_protocol_signal_handler,
|
||||
omapi_protocol_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_protocol_object_t));
|
||||
sizeof (omapi_protocol_object_t),
|
||||
0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -135,7 +138,7 @@ isc_result_t omapi_init (void)
|
|||
omapi_protocol_listener_signal,
|
||||
omapi_protocol_listener_stuff,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_protocol_listener_object_t)));
|
||||
sizeof (omapi_protocol_listener_object_t), 0));
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -147,7 +150,8 @@ isc_result_t omapi_init (void)
|
|||
omapi_message_signal_handler,
|
||||
omapi_message_stuff_values,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_message_object_t));
|
||||
sizeof (omapi_message_object_t),
|
||||
0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -158,7 +162,8 @@ isc_result_t omapi_init (void)
|
|||
0,
|
||||
omapi_waiter_signal_handler, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
sizeof (omapi_waiter_object_t));
|
||||
sizeof (omapi_waiter_object_t),
|
||||
0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -171,7 +176,7 @@ isc_result_t omapi_init (void)
|
|||
omapi_auth_key_stuff_values,
|
||||
omapi_auth_key_lookup,
|
||||
0, 0, 0, 0, 0,
|
||||
sizeof (omapi_auth_key_t));
|
||||
sizeof (omapi_auth_key_t), 0);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
return status;
|
||||
|
||||
|
@ -218,7 +223,10 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **type,
|
|||
(omapi_object_t **,
|
||||
const char *, int),
|
||||
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;
|
||||
|
||||
|
@ -241,6 +249,7 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **type,
|
|||
t -> size = size;
|
||||
t -> freer = freer;
|
||||
t -> allocator = allocator;
|
||||
t -> initialize = initialize;
|
||||
omapi_object_types = t;
|
||||
if (type)
|
||||
*type = t;
|
||||
|
@ -290,13 +299,47 @@ isc_result_t omapi_set_value (omapi_object_t *h,
|
|||
omapi_typed_data_t *value)
|
||||
{
|
||||
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)
|
||||
;
|
||||
if (outer -> type -> set_value)
|
||||
return (*(outer -> type -> set_value)) (outer,
|
||||
id, name, value);
|
||||
return ISC_R_NOTFOUND;
|
||||
status = (*(outer -> type -> set_value)) (outer,
|
||||
id, name, value);
|
||||
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,
|
||||
|
@ -496,7 +539,7 @@ isc_result_t omapi_object_update (omapi_object_t *obj, omapi_object_t *id,
|
|||
status = omapi_set_value (obj, id,
|
||||
gsrc -> values [i] -> name,
|
||||
gsrc -> values [i] -> value);
|
||||
if (status != ISC_R_SUCCESS)
|
||||
if (status != ISC_R_SUCCESS && status != ISC_R_UNCHANGED)
|
||||
return status;
|
||||
}
|
||||
if (handle)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
|
@ -106,14 +106,42 @@ int check_collection (packet, lease, collection)
|
|||
log_info ("checking against class %s...", class -> name);
|
||||
#endif
|
||||
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) {
|
||||
status = (evaluate_data_expression
|
||||
(&data, packet, lease,
|
||||
packet -> options, (struct option_state *)0,
|
||||
&lease -> scope, class -> submatch));
|
||||
if (status) {
|
||||
lease ? &lease -> scope : &global_scope,
|
||||
class -> submatch));
|
||||
if (status && data.len) {
|
||||
nc = (struct class *)0;
|
||||
if (class_hash_lookup (&nc, class -> hash,
|
||||
(const char *)data.data,
|
||||
|
@ -126,6 +154,7 @@ int check_collection (packet, lease, collection)
|
|||
data_string_forget (&data, MDL);
|
||||
classify (packet, nc);
|
||||
matched = 1;
|
||||
class_dereference (&nc, MDL);
|
||||
continue;
|
||||
}
|
||||
if (!class -> spawning) {
|
||||
|
@ -136,11 +165,11 @@ int check_collection (packet, lease, collection)
|
|||
log_info ("spawning subclass %s.",
|
||||
print_hex_1 (data.len, data.data, 60));
|
||||
#endif
|
||||
nc = (struct class *)
|
||||
dmalloc (sizeof (struct class), MDL);
|
||||
memset (nc, 0, sizeof *nc);
|
||||
nc -> group = class -> group;
|
||||
nc -> superclass = class;
|
||||
status = class_allocate (&nc, MDL);
|
||||
group_reference (&nc -> group,
|
||||
class -> group, MDL);
|
||||
class_reference (&nc -> superclass,
|
||||
class, MDL);
|
||||
nc -> lease_limit = class -> lease_limit;
|
||||
nc -> dirty = 1;
|
||||
if (nc -> lease_limit) {
|
||||
|
@ -155,7 +184,7 @@ int check_collection (packet, lease, collection)
|
|||
data_string_forget
|
||||
(&nc -> hash_string,
|
||||
MDL);
|
||||
dfree (nc, MDL);
|
||||
class_dereference (&nc, MDL);
|
||||
data_string_forget (&data,
|
||||
MDL);
|
||||
continue;
|
||||
|
@ -177,18 +206,6 @@ int check_collection (packet, lease, collection)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ option subnet-mask 255.255.255.224;
|
|||
default-lease-time 600;
|
||||
max-lease-time 7200;
|
||||
|
||||
subnet 204.152.187.0 netmask 255.255.255.0 {
|
||||
}
|
||||
|
||||
subnet 204.254.239.0 netmask 255.255.255.224 {
|
||||
range 204.254.239.10 204.254.239.20;
|
||||
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
|
||||
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 routers snarg.fugue.com;
|
||||
}
|
||||
|
||||
subnet 192.5.5.0 netmask 255.255.255.224 {
|
||||
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 routers 192.5.5.1;
|
||||
option subnet-mask 255.255.255.224;
|
||||
|
@ -58,33 +61,3 @@ host fantasia {
|
|||
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";
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -68,17 +68,14 @@ void dhcp_failover_startup ()
|
|||
|
||||
/* In case the peer is already running, immediately try
|
||||
to establish a connection with it. */
|
||||
status = (dhcp_failover_link_initiate
|
||||
((omapi_object_t *)state));
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
status = dhcp_failover_link_initiate ((omapi_object_t *)state);
|
||||
if (status != ISC_R_SUCCESS && status != ISC_R_INCOMPLETE) {
|
||||
add_timeout (cur_time + 90,
|
||||
dhcp_failover_reconnect, state,
|
||||
(tvref_t)
|
||||
dhcp_failover_state_reference,
|
||||
(tvunref_t)
|
||||
dhcp_failover_state_dereference);
|
||||
}
|
||||
if (status != ISC_R_SUCCESS) {
|
||||
log_error ("failover peer %s: %s", state -> name,
|
||||
isc_result_totext (status));
|
||||
}
|
||||
|
@ -297,15 +294,20 @@ isc_result_t dhcp_failover_link_signal (omapi_object_t *h,
|
|||
if (!strcmp (name, "disconnect")) {
|
||||
if (link -> state_object &&
|
||||
link -> state_object -> link_to_peer == link) {
|
||||
if (link -> state_object -> i_am == primary) {
|
||||
add_timeout (cur_time + 5, dhcp_failover_reconnect,
|
||||
link -> state_object,
|
||||
(tvref_t)dhcp_failover_state_reference,
|
||||
(tvunref_t)dhcp_failover_state_dereference);
|
||||
}
|
||||
dhcp_failover_state_reference (&state,
|
||||
link -> state_object, MDL);
|
||||
link -> state = dhcp_flink_disconnected;
|
||||
|
||||
/* Make the transition. */
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -733,12 +733,25 @@ void enter_lease (lease)
|
|||
if (comp -> subnet)
|
||||
subnet_reference (&lease -> subnet,
|
||||
comp -> subnet, MDL);
|
||||
|
||||
lease_hash_delete (lease_ip_addr_hash,
|
||||
lease -> ip_addr.iabuf,
|
||||
lease -> ip_addr.len, 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 -> ip_addr.iabuf,
|
||||
lease -> ip_addr.len, lease, MDL);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#ifndef lint
|
||||
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 */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
@ -710,8 +710,13 @@ void initialize_server_option_spaces()
|
|||
/* Set up the Relay Agent Information Option suboption space... */
|
||||
agent_universe.name = "agent";
|
||||
agent_universe.option_state_dereference =
|
||||
agent_option_state_dereference;
|
||||
agent_universe.get_func = agent_option_get;
|
||||
linked_option_state_dereference;
|
||||
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.length_size = 1;
|
||||
agent_universe.tag_size = 1;
|
||||
|
@ -727,17 +732,18 @@ void initialize_server_option_spaces()
|
|||
agent_options [i].name, 0,
|
||||
&agent_options [i], MDL);
|
||||
}
|
||||
agent_universe.enc_opt = &dhcp_options [DHO_DHCP_AGENT_OPTIONS];
|
||||
|
||||
|
||||
/* Set up the server option universe... */
|
||||
server_universe.name = "server";
|
||||
server_universe.lookup_func = lookup_hashed_option;
|
||||
server_universe.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.delete_func = delete_hashed_option;
|
||||
server_universe.encapsulate = hashed_option_space_encapsulate;
|
||||
server_universe.foreach = hashed_option_space_foreach;
|
||||
server_universe.length_size = 1;
|
||||
server_universe.tag_size = 1;
|
||||
server_universe.store_tag = putUChar;
|
||||
|
@ -762,4 +768,5 @@ void initialize_server_option_spaces()
|
|||
|
||||
/* Make the server universe the configuration option universe. */
|
||||
config_universe = &server_universe;
|
||||
vendor_cfg_option = &server_options [SV_VENDOR_OPTION_SPACE];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue