2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 22:35:25 +00:00

Mass commit for Brian Murrell.

This commit is contained in:
Ted Lemon
1999-11-20 18:36:32 +00:00
parent b3677620b6
commit d9eefc5dec
25 changed files with 1169 additions and 818 deletions

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char ocopyright[] =
"$Id: dhclient.c,v 1.89 1999/11/13 23:49:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: dhclient.c,v 1.90 1999/11/20 18:36:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1995,8 +1995,8 @@ void script_init (client, reason, medium)
if (!mktemp (scriptName))
log_fatal ("can't create temporary script %s: %m",
scriptName);
fd = creat (scriptName, 0600);
} while (fd < 0 && errno == EEXISTS);
fd = open (scriptName, O_EXCL | O_CREAT | O_WRONLY, 0600);
} while (fd < 0 && errno == EEXIST);
#endif
if (fd < 0)
log_fatal ("can't create temporary script %s: %m", scriptName);

View File

@@ -171,7 +171,15 @@ LLEEAASSEE RREEQQUUIIRREEMMEENNTTSS AANNDD RREEQQUUEES
any server responding to the client send the client its
values for the specified options. Only the option names
should be specified in the request statement - not option
parameters.
parameters. By default, the DHCP server requests the
subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers and host-name options.
In some cases, it may be desirable to send no parameter
request list at all. To do this, simply write the
request statement but specify no parameters:
request;
_T_h_e rreeqquuiirree _s_t_a_t_e_m_e_n_t
@@ -183,14 +191,6 @@ LLEEAASSEE RREEQQUUIIRREEMMEENNTTSS AANNDD RREEQQUUEES
_T_h_e sseenndd _s_t_a_t_e_m_e_n_t
sseenndd {{ [[ _o_p_t_i_o_n _d_e_c_l_a_r_a_t_i_o_n ] [,, _._._. _o_p_t_i_o_n _d_e_c_l_a_r_a_t_i_o_n
]}}
The send statement causes the client to send the specified
options to the server with the specified values. These
are full option declarations as described in ddhhccpp--
ooppttiioonnss((55)). Options that are always sent in the DHCP
3
@@ -202,11 +202,18 @@ LLEEAASSEE RREEQQUUIIRREEMMEENNTTSS AANNDD RREEQQUUEES
dhclient.conf(5) dhclient.conf(5)
protocol should not be specified here, except that the
client can specify a rreeqquueesstteedd--lleeaassee--ttiimmee option other
than the default requested lease time, which is two hours.
The other obvious use for this statement is to send infor<6F>
mation to the server that will allow it to differentiate
sseenndd {{ [[ _o_p_t_i_o_n _d_e_c_l_a_r_a_t_i_o_n ] [,, _._._. _o_p_t_i_o_n _d_e_c_l_a_r_a_t_i_o_n
]}}
The send statement causes the client to send the specified
options to the server with the specified values. These
are full option declarations as described in ddhhccpp--
ooppttiioonnss((55)). Options that are always sent in the DHCP pro<72>
tocol should not be specified here, except that the client
can specify a rreeqquueesstteedd--lleeaassee--ttiimmee option other than the
default requested lease time, which is two hours. The
other obvious use for this statement is to send informa<6D>
tion to the server that will allow it to differentiate
between this client and other clients or kinds of clients.
OOPPTTIIOONN MMOODDIIFFIIEERRSS
@@ -250,13 +257,6 @@ OOPPTTIIOONN MMOODDIIFFIIEERRSS
_T_h_e aappppeenndd _s_t_a_t_e_m_e_n_t
aappppeenndd [[ _o_p_t_i_o_n _d_e_c_l_a_r_a_t_i_o_n ] ;;
If for some set of options the client should first use the
values supplied by the server, if any, and then use values
you supply, these values can be defined in the aappppeenndd
statement. The aappppeenndd statement can only be used for
4
@@ -268,6 +268,12 @@ OOPPTTIIOONN MMOODDIIFFIIEERRSS
dhclient.conf(5) dhclient.conf(5)
aappppeenndd [[ _o_p_t_i_o_n _d_e_c_l_a_r_a_t_i_o_n ] ;;
If for some set of options the client should first use the
values supplied by the server, if any, and then use values
you supply, these values can be defined in the aappppeenndd
statement. The aappppeenndd statement can only be used for
options which allow more than one value to be given.
This restriction is not enforced - if you ignore it, the
behaviour will be unpredictable.
@@ -316,12 +322,6 @@ LLEEAASSEE DDEECCLLAARRAATTIIOONNSS
the client receives a lease from a server, it always
records the interface number on which it received that
lease. If predefined leases are specified in the
dhclient.conf file, the interface should also be speci<63>
fied, although this is not required.
ffiixxeedd--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;;
The ffiixxeedd--aaddddrreessss statement is used to set the ip address
@@ -334,6 +334,12 @@ LLEEAASSEE DDEECCLLAARRAATTIIOONNSS
dhclient.conf(5) dhclient.conf(5)
dhclient.conf file, the interface should also be speci<63>
fied, although this is not required.
ffiixxeedd--aaddddrreessss _i_p_-_a_d_d_r_e_s_s;;
The ffiixxeedd--aaddddrreessss statement is used to set the ip address
of a particular lease. This is required for all lease
statements. The IP address must be specified as a dotted
quad (e.g., 12.34.56.78).
@@ -382,12 +388,6 @@ dhclient.conf(5) dhclient.conf(5)
passed on the ifconfig command line when configuring te
interface.
The dhcp client automatically declares this parameter if
it used a media type (see the mmeeddiiaa statement) when con<6F>
figuring the interface in order to obtain a lease. This
statement should be used in predefined leases only if the
network interface requires media type configuration.
@@ -400,6 +400,12 @@ dhclient.conf(5) dhclient.conf(5)
dhclient.conf(5) dhclient.conf(5)
The dhcp client automatically declares this parameter if
it used a media type (see the mmeeddiiaa statement) when con<6F>
figuring the interface in order to obtain a lease. This
statement should be used in predefined leases only if the
network interface requires media type configuration.
rreenneeww _d_a_t_e;;
rreebbiinndd _d_a_t_e;;
@@ -449,12 +455,6 @@ AALLIIAASS DDEECCLLAARRAATTIIOONNSS
the dhcp client can be set up to configure an IP alias
using the aalliiaass declaration.
The alias declaration resembles a lease declaration,
except that options other than the subnet-mask option are
ignored by the standard client configuration script, and
expiry times are ignored. A typical alias declaration
includes an interface declaration, a fixed-address
7
@@ -466,9 +466,14 @@ AALLIIAASS DDEECCLLAARRAATTIIOONNSS
dhclient.conf(5) dhclient.conf(5)
declaration for the IP alias address, and a subnet-mask
option declaration. A medium statement should never be
included in an alias declaration.
The alias declaration resembles a lease declaration,
except that options other than the subnet-mask option are
ignored by the standard client configuration script, and
expiry times are ignored. A typical alias declaration
includes an interface declaration, a fixed-address decla<6C>
ration for the IP alias address, and a subnet-mask option
declaration. A medium statement should never be included
in an alias declaration.
OOTTHHEERR DDEECCLLAARRAATTIIOONNSS
rreejjeecctt _i_p_-_a_d_d_r_e_s_s;;
@@ -516,11 +521,6 @@ OOTTHHEERR DDEECCLLAARRAATTIIOONNSS
script "/etc/dhclient-secondary";
}
The client script for the pseudo-interface should not con<6F>
figure the interface up or down - essentially, all it
needs to handle are the states where a lease has been
acquired or renewed, and the states where a lease has
8
@@ -532,6 +532,10 @@ OOTTHHEERR DDEECCLLAARRAATTIIOONNSS
dhclient.conf(5) dhclient.conf(5)
The client script for the pseudo-interface should not con<6F>
figure the interface up or down - essentially, all it
needs to handle are the states where a lease has been
acquired or renewed, and the states where a lease has
expired. See ddhhcclliieenntt--ssccrriipptt((88)) for more information.
mmeeddiiaa ""_m_e_d_i_a _s_e_t_u_p"" _[ ,, ""_m_e_d_i_a _s_e_t_u_p"",, _._._. _];;
@@ -582,10 +586,6 @@ SSAAMMPPLLEE
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name;
require subnet-mask, domain-name-servers;
script "/etc/dhclient-script";
media "media 10baseT/UTP", "media 10base2/BNC";
}
@@ -598,6 +598,10 @@ SSAAMMPPLLEE
dhclient.conf(5) dhclient.conf(5)
script "/etc/dhclient-script";
media "media 10baseT/UTP", "media 10base2/BNC";
}
alias {
interface "ep0";
fixed-address 192.5.5.213;
@@ -646,10 +650,6 @@ AAUUTTHHOORR

View File

@@ -25,7 +25,7 @@
#ifndef lint
static char copyright[] =
"$Id: nsupdate.c,v 1.13 1999/10/25 15:14:52 mellon Exp $ Copyright (c) 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: nsupdate.c,v 1.14 1999/11/20 18:36:09 mellon Exp $ Copyright (c) 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -532,10 +532,6 @@ int updateA (lhs, rhs, ttl, lease)
if (y < 1)
return 0;
/* remember this in the lease structure for release */
lease -> ddns_fwd_name = dmalloc (strlen(hostname) + 1, "nsupdate");
strcpy (lease -> ddns_fwd_name, hostname);
return 1;
}
@@ -579,10 +575,6 @@ int updatePTR (lhs, rhs, ttl, lease)
if (y < 1)
return 0;
/* remember this in the lease structure for release */
lease -> ddns_rev_name = dmalloc (strlen(revname) + 1, "nsupdate");
strcpy (lease -> ddns_rev_name, revname);
return 1;
}

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: parse.c,v 1.55 1999/11/13 23:53:57 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: parse.c,v 1.56 1999/11/20 18:36:09 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1992,7 +1992,7 @@ int parse_non_binary (expr, cfile, lose, context)
goto nocomma;
if (!(parse_data_expression
(&(*expr) -> data.dns_update.expr1, cfile, lose)))
(&(*expr) -> data.dns_update.rrname, cfile, lose)))
goto nodata;
token = next_token (&val, cfile);
@@ -2000,7 +2000,7 @@ int parse_non_binary (expr, cfile, lose, context)
goto nocomma;
if (!(parse_data_expression
(&(*expr) -> data.dns_update.expr2, cfile, lose)))
(&(*expr) -> data.dns_update.rrdata, cfile, lose)))
goto nodata;
token = next_token (&val, cfile);
@@ -2052,7 +2052,7 @@ int parse_non_binary (expr, cfile, lose, context)
goto nocomma;
if (!(parse_data_expression
(&(*expr) -> data.dns_update.expr1, cfile, lose)))
(&(*expr) -> data.dns_update.rrname, cfile, lose)))
goto nodata;
token = next_token (&val, cfile);
@@ -2060,7 +2060,7 @@ int parse_non_binary (expr, cfile, lose, context)
goto nocomma;
if (!(parse_data_expression
(&(*expr) -> data.dns_update.expr2, cfile, lose)))
(&(*expr) -> data.dns_update.rrdata, cfile, lose)))
goto nodata;
token = next_token (&val, cfile);

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: print.c,v 1.28 1999/11/14 00:01:08 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: print.c,v 1.29 1999/11/20 18:36:10 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -663,11 +663,11 @@ static unsigned print_subexpression (expr, buf, len)
buf + rv, len - rv - 4);
buf [rv++] = ' ';
rv += print_subexpression
(expr -> data.dns_update.expr1,
(expr -> data.dns_update.rrname,
buf + rv, len - rv - 3);
buf [rv++] = ' ';
rv += print_subexpression
(expr -> data.dns_update.expr2,
(expr -> data.dns_update.rrdata,
buf + rv, len - rv - 2);
buf [rv++] = ' ';
rv += print_subexpression

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: tree.c,v 1.64 1999/11/03 16:10:41 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
"$Id: tree.c,v 1.65 1999/11/20 18:36:10 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -388,9 +388,9 @@ int evaluate_boolean_expression (result, packet, lease, in_options,
struct expression *expr;
{
struct data_string left, right;
struct data_string rrtype, expr1, expr2;
struct data_string rrtype, rrname, rrdata;
unsigned long ttl;
int s0, s1, s2, s3;
int srrtype, srrname, srrdata, sttl;
int bleft, bright;
int sleft, sright;
@@ -557,52 +557,94 @@ int evaluate_boolean_expression (result, packet, lease, in_options,
if (!packet || packet -> packet_type != DHCPREQUEST)
return 0;
memset (&rrtype, 0, sizeof rrtype);
s0 = evaluate_data_expression (&rrtype, packet, lease,
srrtype = evaluate_data_expression (&rrtype, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.type);
memset (&expr1, 0, sizeof expr1);
s1 = evaluate_data_expression (&expr1, packet, lease,
memset (&rrname, 0, sizeof rrname);
srrname = evaluate_data_expression (&rrname, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.expr1);
memset (&expr2, 0, sizeof expr2);
s2 = evaluate_data_expression (&expr2, packet, lease,
expr -> data.dns_update.rrname);
memset (&rrdata, 0, sizeof rrdata);
srrdata = evaluate_data_expression (&rrdata, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.expr2);
s3 = evaluate_numeric_expression (&ttl, packet, lease,
expr -> data.dns_update.rrdata);
sttl = evaluate_numeric_expression (&ttl, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.ttl);
*result = 0; /* assume failure */
if (s0 && s1 && s2 && s3) {
if (!sttl) {
log_error("dns-update: RR type subexpression %s",
"evaluates to NULL.");
goto done_dns_update;
}
if (!srrname) {
log_error("dns-update: RR name subexpression %s",
"evaluates to NULL.");
goto done_dns_update;
}
if (!srrdata) {
log_error("dns-update: RR data subexpression %s",
"evaluates to NULL.");
goto done_dns_update;
}
if (!srrtype) {
log_error("dns-update: RR ttl subexpression %s",
"evaluates to NULL.");
goto done_dns_update;
}
if (rrtype.len == 1 &&
strncmp((const char *)rrtype.data, "a", 1) == 0) {
#if defined (DEBUG_EXPRESSIONS)
log_debug("calling updateA(%s, %s, %ld, lease)",
expr1.data, expr2.data, ttl);
rrname.data, rrdata.data, ttl);
#endif
updateA(&expr1, &expr2, ttl, lease);
if (!updateA(&rrname, &rrdata, ttl, lease)) {
log_error("dns-update: DNS add of A %s",
"record failed");
goto done_dns_update;
}
/* remember this in the lease structure for release */
lease -> ddns_fwd_name = dmalloc (rrname.len,
"evaluate_boolean_expression");
strncpy (lease -> ddns_fwd_name, rrname.data,
rrname.len);
} else if (rrtype.len == 3 &&
strncmp((const char *)rrtype.data,
"ptr", 3) == 0) {
strncmp((const char *)rrtype.data, "ptr", 3) == 0) {
#if defined (DEBUG_EXPRESSIONS)
log_debug ("%s updatePTR(%s, %s, %ld, lease)",
"calling", expr1.data, expr2.data, ttl);
"calling", rrname.data, rrdata.data, ttl);
#endif
updatePTR(&expr1, &expr2, ttl, lease);
if (!updatePTR(&rrname, &rrdata, ttl, lease)) {
log_error("dns-update: DNS add of PTR %s",
"record failed");
goto done_dns_update;
}
/* remember this in the lease structure for release */
lease -> ddns_rev_name = dmalloc (rrname.len,
"evaluate_boolean_expression");
strncpy (lease -> ddns_rev_name, rrname.data,
rrname.len);
}
*result = 1;
} else {
log_error("dns-update: one or more subexpressions %s",
"evaluate to NULL.");
return 0;
}
#if defined (DEBUG_EXPRESSIONS)
log_debug ("dns-update (%s, %s, %s):",
print_hex_1(rrtype.len, rrtype.data, 60),
print_hex_2(expr1.len, expr1.data, 60),
print_hex_3(expr2.len, expr2.data, 60));
print_hex_2(rrname.len, rrname.data, 60),
print_hex_3(rrdata.len, rrdata.data, 60));
#endif
return 1;
done_dns_update:
if (srrname)
data_string_forget (&rrname,
"evaluate_boolean_expression");
if (srrdata)
data_string_forget (&rrdata,
"evaluate_boolean_expression");
if (srrtype)
data_string_forget (&rrtype,
"evaluate_boolean_expression");
return *result;
#endif /* NSUPDATE */
case expr_dns_delete:
@@ -610,50 +652,85 @@ int evaluate_boolean_expression (result, packet, lease, in_options,
return 0;
#else
memset (&rrtype, 0, sizeof rrtype);
s0 = evaluate_data_expression (&rrtype, packet, lease,
srrtype = evaluate_data_expression (&rrtype, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.type);
memset (&expr1, 0, sizeof expr1);
s1 = evaluate_data_expression (&expr1, packet, lease,
memset (&rrname, 0, sizeof rrname);
srrname = evaluate_data_expression (&rrname, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.expr1);
memset (&expr2, 0, sizeof expr2);
s2 = evaluate_data_expression (&expr2, packet, lease,
expr -> data.dns_update.rrname);
memset (&rrdata, 0, sizeof rrdata);
srrdata = evaluate_data_expression (&rrdata, packet, lease,
in_options, cfg_options,
expr -> data.dns_update.expr2);
expr -> data.dns_update.rrdata);
*result = 0; /* assume failure */
if (s0 && s1 && s2) {
if (!srrtype) {
log_error("dns-delete: RR type subexpression %s",
"evaluates to NULL.");
goto done_dns_delete;
}
if (!srrname) {
log_error("dns-delete: RR name subexpression %s",
"evaluates to NULL.");
goto done_dns_delete;
}
if (!srrdata) {
log_error("dns-delete: RR data subexpression %s",
"evaluates to NULL.");
goto done_dns_delete;
}
if (rrtype.len == 1 &&
strncmp((const char *)rrtype.data, "a", 1) == 0) {
#if defined (DEBUG_EXPRESSIONS)
log_debug("calling deleteA(%s, %s, lease)",
expr1.data , expr2.data);
rrname.data , rrdata.data);
#endif
deleteA(&expr1, &expr2, lease);
if (!deleteA(&rrname, &rrdata, lease)) {
log_error("dns-delete: DNS delete of A %s",
"record failed");
goto done_dns_delete;
}
if (lease -> ddns_fwd_name) {
dfree (lease -> ddns_fwd_name,
"evaluate_boolean_expression");
lease -> ddns_fwd_name = (char *)0;
}
} else if (rrtype.len == 3 &&
strncmp((const char *)rrtype.data,
"ptr", 3) == 0) {
strncmp((const char *)rrtype.data, "ptr", 3) == 0) {
#if defined (DEBUG_EXPRESSIONS)
log_debug ("%s deletePTR(%s, %s, lease)",
"calling", expr1.data,
expr2.data);
log_debug ("calling deletePTR(%s, %s, lease)",
rrname.data, rrdata.data);
#endif
deletePTR(&expr1, &expr2, lease);
if (!deletePTR(&rrname, &rrdata, lease)) {
log_error("dns-delete: DNS delete of PTR %s",
"record failed");
goto done_dns_delete;
}
if (lease -> ddns_rev_name) {
dfree (lease -> ddns_rev_name,
"evaluate_boolean_expression");
lease -> ddns_rev_name = (char *)0;
}
}
*result = 1;
} else {
log_error("dns-update: one or more subexpressions %s",
"evaluate to NULL.");
return 0;
}
#if defined (DEBUG_EXPRESSIONS)
log_debug ("dns-delete (%s, %s, %s):",
print_hex_1(rrtype.len, rrtype.data, 60),
print_hex_2(expr1.len, expr1.data, 60),
print_hex_3(expr2.len, expr2.data, 60));
print_hex_2(rrname.len, rrname.data, 60),
print_hex_3(rrdata.len, rrdata.data, 60));
#endif
return 1;
done_dns_delete:
if (srrname)
data_string_forget (&rrname,
"evaluate_boolean_expression");
if (srrdata)
data_string_forget (&rrdata,
"evaluate_boolean_expression");
if (srrtype)
data_string_forget (&rrtype,
"evaluate_boolean_expression");
return *result;
#endif /* NSUPDATE */
case expr_none:
@@ -1784,11 +1861,11 @@ void expression_dereference (eptr, name)
if (expr -> data.dns_update.type)
expression_dereference (&expr -> data.dns_update.type,
name);
if (expr -> data.dns_update.expr1)
expression_dereference (&expr -> data.dns_update.expr1,
if (expr -> data.dns_update.rrname)
expression_dereference (&expr -> data.dns_update.rrname,
name);
if (expr -> data.dns_update.expr2)
expression_dereference (&expr -> data.dns_update.expr2,
if (expr -> data.dns_update.rrdata)
expression_dereference (&expr -> data.dns_update.rrdata,
name);
if (expr -> data.dns_update.ttl)
expression_dereference (&expr -> data.dns_update.ttl,
@@ -2344,11 +2421,11 @@ int write_expression (file, expr, col, indent)
col, scol);
col = token_print_indent (file, col, scol, "", " ",
",");
col = write_expression (file, expr -> data.dns_update.expr1,
col = write_expression (file, expr -> data.dns_update.rrname,
col, scol);
col = token_print_indent (file, col, scol, "", " ",
",");
col = write_expression (file, expr -> data.dns_update.expr2,
col = write_expression (file, expr -> data.dns_update.rrdata,
col, scol);
col = token_print_indent (file, col, scol, "", " ",
",");
@@ -2380,11 +2457,11 @@ int write_expression (file, expr, col, indent)
col, scol);
col = token_print_indent (file, col, scol, "", " ",
",");
col = write_expression (file, expr -> data.dns_update.expr1,
col = write_expression (file, expr -> data.dns_update.rrname,
col, scol);
col = token_print_indent (file, col, scol, "", " ",
",");
col = write_expression (file, expr -> data.dns_update.expr2,
col = write_expression (file, expr -> data.dns_update.rrdata,
col, scol);
col = token_print_indent (file, col, indent, "", "",
")");

View File

@@ -67,7 +67,7 @@ clean:
-rm -f $(OBJ) test.o test
realclean: clean
-rm -f libdhcp.a *~ $(CATMANPAGES) $(SEDMANPAGES)
-rm -f libdhcpctl.a *~ $(CATMANPAGES) $(SEDMANPAGES)
distclean: realclean
-rm -f Makefile

View File

@@ -118,6 +118,8 @@ extern int h_errno;
#define TIME time_t
#define GET_TIME(x) time ((x))
#define HAVE_MKSTEMP
/* Solaris prior to 2.5 didn't have random(). Rather than being clever and
using random() only on versions >2.5, always use rand() and srand(). */

View File

@@ -58,13 +58,14 @@
#include "inet.h"
#include "auth.h"
#include "dhctoken.h"
#if defined (FAILOVER_PROTOCOL)
# include "failover.h"
#endif
#include <isc/result.h>
#include <omapip/omapip.h>
#if defined (FAILOVER_PROTOCOL)
# include "failover.h"
#endif
#if !defined (OPTION_HASH_SIZE)
# define OPTION_HASH_SIZE 17
#endif
@@ -102,6 +103,13 @@ struct parse {
unsigned bufsiz;
};
/* Client FQDN option, failover FQDN option, etc. */
typedef struct {
u_int8_t codes [2];
unsigned length;
u_int8_t *data;
} ddns_fqdn_t;
/* Variable-length array of data. */
struct string_list {
@@ -1417,6 +1425,12 @@ extern struct hash_table universe_hash;
void initialize_common_option_spaces PROTO ((void));
/* stables.c */
#if defined (FAILOVER_PROTOCOL)
struct failover_option_info ft_options [0];
u_int32_t fto_allowed [0];
int ft_sizes [0];
char *dhcp_failover_link_state_names [0];
#endif
extern struct universe agent_universe;
extern struct option agent_options [256];
extern struct universe server_universe;
@@ -1685,6 +1699,11 @@ extern omapi_object_type_t *dhcp_type_pool;
extern omapi_object_type_t *dhcp_type_shared_network;
extern omapi_object_type_t *dhcp_type_subnet;
extern omapi_object_type_t *dhcp_type_class;
#if defined (FAILOVER_PROTOCOL)
extern omapi_object_type_t *dhcp_type_failover_state;
extern omapi_object_type_t *dhcp_type_failover_link;
extern omapi_object_type_t *dhcp_type_failover_listener;
#endif
void dhcp_db_objects_setup (void);
@@ -1875,3 +1894,59 @@ int deleteA (const struct data_string *, const struct data_string *,
struct lease *);
int deletePTR (const struct data_string *, const struct data_string *,
struct lease *);
/* failover.c */
#if defined (FAILOVER_PROTOCOL)
void enter_failover_peer PROTO ((struct failover_peer *));
struct failover_peer *find_failover_peer PROTO ((char *));
isc_result_t dhcp_failover_link_initiate PROTO ((omapi_object_t *));
isc_result_t dhcp_failover_link_signal PROTO ((omapi_object_t *,
const char *, va_list));
isc_result_t dhcp_failover_link_set_value PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_data_string_t *,
omapi_typed_data_t *));
isc_result_t dhcp_failover_link_get_value PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_data_string_t *,
omapi_value_t **));
isc_result_t dhcp_failover_link_destroy PROTO ((omapi_object_t *,
const char *));
isc_result_t dhcp_failover_link_stuff_values PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_object_t *));
isc_result_t dhcp_failover_listen PROTO ((omapi_object_t *));
isc_result_t dhcp_failover_listener_signal PROTO ((omapi_object_t *,
const char *,
va_list));
isc_result_t dhcp_failover_listener_set_value PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_data_string_t *,
omapi_typed_data_t *));
isc_result_t dhcp_failover_listener_get_value PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_data_string_t *,
omapi_value_t **));
isc_result_t dhcp_failover_listener_destroy PROTO ((omapi_object_t *,
const char *));
isc_result_t dhcp_failover_listener_stuff PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_object_t *));
isc_result_t dhcp_failover_register PROTO ((omapi_object_t *));
isc_result_t dhcp_failover_state_signal PROTO ((omapi_object_t *,
const char *, va_list));
isc_result_t dhcp_failover_state_set_value PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_data_string_t *,
omapi_typed_data_t *));
isc_result_t dhcp_failover_state_get_value PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_data_string_t *,
omapi_value_t **));
isc_result_t dhcp_failover_state_destroy PROTO ((omapi_object_t *,
const char *));
isc_result_t dhcp_failover_state_stuff PROTO ((omapi_object_t *,
omapi_object_t *,
omapi_object_t *));
#endif /* FAILOVER_PROTOCOL */

View File

@@ -20,15 +20,21 @@
* http://www.isc.org for more information.
*/
struct failover_option {
struct failover_option_info {
int code;
char *name;
enum { FT_UINT8, FT_IPADDR, FT_UINT32, FT_BYTES, FT_DDNS,
FT_UINT16, FT_TEXT, FT_UNDEF, FT_DIGEST } data_type;
enum { FT_UINT8, FT_IPADDR, FT_UINT32, FT_BYTES, FT_DDNS, FT_DDNS1,
FT_UINT16, FT_TEXT, FT_UNDEF, FT_DIGEST } type;
int num_present;
int data_offset;
int offset;
u_int32_t bit;
};
typedef struct {
int count;
u_int8_t *data;
} failover_option_t;
#define FM_OFFSET(x) ((char *)(((struct failover_message *)0).x) - \
(char *)(((struct failover_message *)0)))
@@ -102,3 +108,44 @@ struct failover_option {
#define FTM_STATE 10
#define FTM_CONTACT 11
#define FTM_DISCONNECT 12
#define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
typedef struct {
u_int8_t type;
u_int32_t time;
u_int32_t xid;
int options_present;
} failover_message_t;
typedef struct {
OMAPI_OBJECT_PREAMBLE;
char *peer_name;
unsigned peer_port;
int options_present;
enum dhcp_flink_state {
dhcp_flink_start,
dhcp_flink_message_length_wait,
dhcp_flink_message_wait,
dhcp_flink_disconnected,
dhcp_flink_state_max
} state;
failover_message_t *imsg;
u_int16_t imsg_len;
unsigned imsg_count;
u_int8_t imsg_payoff; /* Pay*load* offset. :') */
} dhcp_failover_link_t;
typedef struct {
OMAPI_OBJECT_PREAMBLE;
unsigned local_port;
char *peer_name;
} dhcp_failover_listener_t;
typedef struct _dhcp_failover_state {
OMAPI_OBJECT_PREAMBLE;
struct _dhcp_failover_state *next;
char *remote_peer;
int listen_port;
} dhcp_failover_state_t;

View File

@@ -116,8 +116,8 @@ struct __omapi_object {
#define OMAPI_PROTOCOL_PORT 7911
isc_result_t omapi_protocol_connect (omapi_object_t *,
const char *, int, omapi_object_t *);
isc_result_t omapi_protocol_listen (omapi_object_t *, int, int);
const char *, unsigned, omapi_object_t *);
isc_result_t omapi_protocol_listen (omapi_object_t *, unsigned, int);
isc_result_t omapi_protocol_accept (omapi_object_t *);
isc_result_t omapi_protocol_send_intro (omapi_object_t *, unsigned, unsigned);
isc_result_t omapi_protocol_ready (omapi_object_t *);
@@ -157,7 +157,7 @@ isc_result_t omapi_protocol_send_status (omapi_object_t *, omapi_object_t *,
isc_result_t omapi_protocol_send_update (omapi_object_t *, omapi_object_t *,
unsigned, omapi_object_t *);
isc_result_t omapi_connect (omapi_object_t *, const char *, int);
isc_result_t omapi_connect (omapi_object_t *, const char *, unsigned);
isc_result_t omapi_disconnect (omapi_object_t *, int);
int omapi_connection_readfd (omapi_object_t *);
int omapi_connection_writefd (omapi_object_t *);
@@ -184,7 +184,7 @@ isc_result_t omapi_connection_put_handle (omapi_object_t *c,
omapi_object_t *h);
isc_result_t omapi_listen (omapi_object_t *, int, int);
isc_result_t omapi_listen (omapi_object_t *, unsigned, int);
isc_result_t omapi_listener_accept (omapi_object_t *);
int omapi_listener_readfd (omapi_object_t *);
isc_result_t omapi_accept (omapi_object_t *);
@@ -334,7 +334,7 @@ isc_result_t omapi_make_int_value (omapi_value_t **, omapi_data_string_t *,
isc_result_t omapi_make_handle_value (omapi_value_t **, omapi_data_string_t *,
omapi_object_t *, const char *);
isc_result_t omapi_make_string_value (omapi_value_t **, omapi_data_string_t *,
char *, const char *);
const char *, const char *);
isc_result_t omapi_get_int_value (unsigned long *, omapi_typed_data_t *);
isc_result_t omapi_object_handle (omapi_handle_t *, omapi_object_t *);

View File

@@ -51,17 +51,17 @@
/* Define this if you want debugging output for DHCP failover protocol
messages. */
/* #define DEBUG_FAILOVER_MESSAGES */
#define DEBUG_FAILOVER_MESSAGES
/* Define this if you want debugging output for DHCP failover protocol
lease assignment timing. */
/* #define DEBUG_FAILOVER_TIMING */
#define DEBUG_FAILOVER_TIMING
/* Define this if you want DHCP failover protocol support in the DHCP
server. */
/* #define FAILOVER_PROTOCOL */
#define FAILOVER_PROTOCOL
/* Define this if you want the dhcpd.pid file to go somewhere other than
the default (which varies from system to system, but is usually either

View File

@@ -145,8 +145,8 @@ struct expression {
} pick_first_value;
struct {
struct expression *type;
struct expression *expr1;
struct expression *expr2;
struct expression *rrname;
struct expression *rrdata;
struct expression *ttl;
} dns_update;
struct expression *updated_dns_rr;

View File

@@ -70,7 +70,7 @@ clean:
-rm -f $(OBJ) test.o test
realclean: clean
-rm -f libdhcp.a *~ $(CATMANPAGES) $(SEDMANPAGES)
-rm -f libomapi.a *~ $(CATMANPAGES) $(SEDMANPAGES)
distclean: realclean
-rm -f Makefile

View File

@@ -24,7 +24,7 @@
isc_result_t omapi_connect (omapi_object_t *c,
const char *server_name,
int port)
unsigned port)
{
struct hostent *he;
int hix;

View File

@@ -23,7 +23,7 @@
#include <omapip/omapip_p.h>
isc_result_t omapi_listen (omapi_object_t *h,
int port,
unsigned port,
int max)
{
struct hostent *he;

View File

@@ -24,7 +24,7 @@
isc_result_t omapi_protocol_connect (omapi_object_t *h,
const char *server_name,
int port,
unsigned port,
omapi_object_t *authinfo)
{
isc_result_t status;
@@ -257,10 +257,8 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
case omapi_protocol_intro_wait:
/* Get protocol version and header size in network
byte order. */
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> protocol_version);
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> header_size);
omapi_connection_get_uint32 (c, &p -> protocol_version);
omapi_connection_get_uint32 (c, &p -> header_size);
/* We currently only support the current protocol version. */
if (p -> protocol_version != OMAPI_PROTOCOL_VERSION) {
@@ -282,8 +280,8 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
/* Register a need for the number of bytes in a
header, and if we already have that many, process
them immediately. */
if ((omapi_connection_require
(c, p -> header_size)) != ISC_R_SUCCESS)
if ((omapi_connection_require (c, p -> header_size)) !=
ISC_R_SUCCESS)
break;
/* If we already have the data, fall through. */
@@ -296,20 +294,14 @@ isc_result_t omapi_protocol_signal_handler (omapi_object_t *h,
}
/* Swap in the header... */
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> message -> authid);
omapi_connection_get_uint32 (c, &p -> message -> authid);
/* XXX bind the authenticator here! */
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> message -> authlen);
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> message -> op);
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> message -> handle);
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> message -> id);
omapi_connection_get_uint32
(c, (u_int32_t *)&p -> message -> rid);
omapi_connection_get_uint32 (c, &p -> message -> authlen);
omapi_connection_get_uint32 (c, &p -> message -> op);
omapi_connection_get_uint32 (c, &p -> message -> handle);
omapi_connection_get_uint32 (c, &p -> message -> id);
omapi_connection_get_uint32 (c, &p -> message -> rid);
/* If there was any extra header data, skip over it. */
if (p -> header_size > sizeof (omapi_protocol_header_t)) {
@@ -554,7 +546,7 @@ isc_result_t omapi_protocol_stuff_values (omapi_object_t *c,
a listener object, not a protocol object. */
isc_result_t omapi_protocol_listen (omapi_object_t *h,
int port,
unsigned port,
int max)
{
isc_result_t status;

View File

@@ -639,7 +639,7 @@ isc_result_t omapi_make_handle_value (omapi_value_t **vp,
isc_result_t omapi_make_string_value (omapi_value_t **vp,
omapi_data_string_t *name,
char *value, const char *caller)
const char *value, const char *caller)
{
isc_result_t status;

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: confpars.c,v 1.91 1999/11/14 00:17:47 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
"$Id: confpars.c,v 1.92 1999/11/20 18:36:27 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -589,7 +589,7 @@ void parse_failover_peer (cfile, group, type)
if (type != SHARED_NET_DECL && type != ROOT_GROUP) {
parse_warn (cfile,
"failover peer statements not in shared-network%s"
"failover peer statements not in shared-network%s",
" declaration or at top level.");
skip_to_semi (cfile);
return;
@@ -1610,7 +1610,7 @@ void parse_group_declaration (cfile, group)
int declaration = 0;
struct group_object *t;
isc_result_t status;
char *name;
char *name = NULL;
int deletedp = 0;
int dynamicp = 0;
int staticp = 0;
@@ -2117,7 +2117,7 @@ void parse_address_range (cfile, group, type, pool)
pool -> permit_list &&
!pool -> permit_list -> next &&
(pool -> permit_list -> type ==
permit_dynamic_bootp_clients))) {
permit_all_clients))) {
break;
}
last = pool;
@@ -2135,7 +2135,7 @@ void parse_address_range (cfile, group, type, pool)
log_fatal ("no memory for ad-hoc %s.",
"permit");
pool -> permit_list -> type =
permit_dynamic_bootp_clients;
permit_all_clients;
}
if (share -> pools)
last -> next = pool;

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: dhcp.c,v 1.128 1999/11/14 00:22:29 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: dhcp.c,v 1.129 1999/11/20 18:36:28 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -70,19 +70,33 @@ void dhcpdiscover (packet)
struct packet *packet;
{
struct lease *lease;
char msgbuf [1024];
char msgbuf [1024]; /* XXX */
TIME when;
sprintf (msgbuf, "DHCPDISCOVER from %s via %s",
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr),
(packet -> raw -> giaddr.s_addr
? inet_ntoa (packet -> raw -> giaddr)
: packet -> interface -> name));
char *s;
lease = find_lease (packet, packet -> shared_network, 0);
if (lease && lease -> client_hostname &&
db_printable (lease -> client_hostname))
s = lease -> client_hostname;
else
s = (char *)0;
/* Say what we're doing... */
sprintf (msgbuf, "DHCPDISCOVER from %s %s%s%svia %s",
(packet -> raw -> htype
? print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr),
: (lease
? print_hex_1 (lease -> uid_len, lease -> uid,
lease -> uid_len)
: "<no identifier>")),
s ? "(" : "", s ? s : "", s ? ") " : "",
packet -> raw -> giaddr.s_addr
? inet_ntoa (packet -> raw -> giaddr)
: packet -> interface -> name);
/* Sourceless packets don't make sense here. */
if (!packet -> shared_network) {
log_info ("Packet from unknown subnet: %s",
@@ -123,7 +137,8 @@ void dhcprequest (packet)
struct option_cache *oc;
struct data_string data;
int status;
char msgbuf [1024];
char msgbuf [1024]; /* XXX */
char *s;
oc = lookup_option (&dhcp_universe, packet -> options,
DHO_DHCP_REQUESTED_ADDRESS);
@@ -150,14 +165,27 @@ void dhcprequest (packet)
else
lease = (struct lease *)0;
sprintf (msgbuf, "DHCPREQUEST for %s from %s via %s",
if (lease && lease -> client_hostname &&
db_printable (lease -> client_hostname))
s = lease -> client_hostname;
else
s = (char *)0;
/* Say what we're doing... */
sprintf (msgbuf, "DHCPREQUEST for from %s %s%s%svia %s",
piaddr (cip),
print_hw_addr (packet -> raw -> htype,
(packet -> raw -> htype
? print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr),
(packet -> raw -> giaddr.s_addr
: (lease
? print_hex_1 (lease -> uid_len, lease -> uid,
lease -> uid_len)
: "<no identifier>")),
s ? "(" : "", s ? s : "", s ? ") " : "",
packet -> raw -> giaddr.s_addr
? inet_ntoa (packet -> raw -> giaddr)
: packet -> interface -> name));
: packet -> interface -> name);
/* If a client on a given network REQUESTs a lease on an
address on a different network, NAK it. If the Requested
@@ -297,11 +325,24 @@ void dhcprelease (packet)
}
log_info ("DHCPRELEASE of %s from %s via %s (%sfound)",
if (lease && lease -> client_hostname &&
db_printable (lease -> client_hostname))
s = lease -> client_hostname;
else
s = (char *)0;
/* Say what we're doing... */
log_info ("DHCPRELEASE of %s from %s %s%s%svia %s (%sfound)",
inet_ntoa (packet -> raw -> ciaddr),
print_hw_addr (packet -> raw -> htype,
(packet -> raw -> htype
? print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr),
: (lease
? print_hex_1 (lease -> uid_len, lease -> uid,
lease -> uid_len)
: "<no identifier>")),
s ? "(" : "", s ? s : "", s ? ") " : "",
packet -> raw -> giaddr.s_addr
? inet_ntoa (packet -> raw -> giaddr)
: packet -> interface -> name,
@@ -323,6 +364,7 @@ void dhcpdecline (packet)
int ignorep;
int i;
const char *status;
char *s;
/* DHCPDECLINE must specify address. */
if (!(oc = lookup_option (&dhcp_universe, packet -> options,
@@ -372,15 +414,29 @@ void dhcpdecline (packet)
} else
status = " (ignored)";
if (!ignorep)
log_info ("DHCPDECLINE on %s from %s via %s%s",
if (!ignorep) {
char *s;
if (lease && lease -> client_hostname &&
db_printable (lease -> client_hostname))
s = lease -> client_hostname;
else
s = (char *)0;
log_info ("DHCPDECLINE of %s from %s %s%s%svia %s %s",
piaddr (cip),
print_hw_addr (packet -> raw -> htype,
(packet -> raw -> htype
? print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr),
: (lease
? print_hex_1 (lease -> uid_len, lease -> uid,
lease -> uid_len)
: "<no identifier>")),
s ? "(" : "", s ? s : "", s ? ") " : "",
packet -> raw -> giaddr.s_addr
? inet_ntoa (packet -> raw -> giaddr)
: packet -> interface -> name, status);
: packet -> interface -> name,
status);
option_state_dereference (&options, "dhcpdecline");
}
@@ -922,9 +978,15 @@ void ack_lease (packet, lease, offer, when, msg)
(struct agent_options *)0;
}
/* Get rid of any old expiry or release statements - by executing
the statements below, we will be inserting new ones if there are
any to insert. */
/* If we are offering a lease that is still currently valid, preserve
the events. We need to do this because if the client does not
REQUEST our offer, it will expire in 2 minutes, overriding the
expire time in the currently in force lease. We want the expire
events to be executed at that point. */
if (lease -> ends <= cur_time && offer != DHCPOFFER) {
/* Get rid of any old expiry or release statements - by
executing the statements below, we will be inserting new
ones if there are any to insert. */
if (lease -> on_expiry)
executable_statement_dereference (&lease -> on_expiry,
"ack_lease");
@@ -934,6 +996,7 @@ void ack_lease (packet, lease, offer, when, msg)
if (lease -> on_release)
executable_statement_dereference (&lease -> on_release,
"ack_lease");
}
/* Execute statements in scope starting with the subnet scope. */
execute_statements_in_scope (packet, lease,
@@ -1352,20 +1415,6 @@ void ack_lease (packet, lease, offer, when, msg)
}
}
/* Do the DDNS update. It needs to be done here so that the lease
structure values for the forward and reverse names are in place for
supersede() -> write_lease() to be able to write into the
dhcpd.leases file. We have to pass the "state" structure here as it
is not yet hanging off the lease. */
/* why not update for static leases too? */
/* Because static leases aren't currently recorded? */
/* XXX
#if defined (NSUPDATE)
if (!(lease -> flags & STATIC_LEASE) && offer == DHCPACK)
nsupdate (lease, state, packet, ADD);
#endif
*/
/* If there are statements to execute when the lease is
committed, execute them. */
if (lease -> on_commit && (!offer || offer == DHCPACK)) {
@@ -1401,6 +1450,19 @@ void ack_lease (packet, lease, offer, when, msg)
free_lease_state (state, "ack_lease");
static_lease_dereference (lease, "ack_lease");
return;
} else {
/* If this is a DHCPOFFER transaction, supersede_lease
will not add the timer for the expire event to the
queue. This is because DHCPOFFERS are not commited,
and supersede_lease only adds commited leases to the
timer queue. So if supersede_lease set this lease
as the next one to expire for the pool we need to
put it on the timer queue ourself. */
/* XXX need to think about this. */
if (offer == DHCPOFFER && lease -> pool &&
lease -> pool -> next_expiry == lease)
add_timeout (lease -> ends, pool_timer,
lease -> pool);
}
}
@@ -1787,6 +1849,7 @@ void dhcp_reply (lease)
struct option_tag *ot, *not;
struct data_string d1;
struct option_cache *oc;
char *s;
if (!state)
log_fatal ("dhcp_reply was supplied lease with no state!");
@@ -1857,16 +1920,20 @@ void dhcp_reply (lease)
raw.hops = state -> hops;
raw.op = BOOTREPLY;
if (lease -> client_hostname &&
db_printable (lease -> client_hostname))
s = lease -> client_hostname;
else
s = (char *)0;
/* Say what we're doing... */
log_info ("%s on %s to %s via %s",
log_info ("%s on %s to %s %s%s%svia %s",
(state -> offer
? (state -> offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
: "BOOTREPLY"),
piaddr (lease -> ip_addr),
(lease -> client_hostname &&
db_printable (lease -> client_hostname))
? lease -> client_hostname
: (lease -> hardware_addr.htype
s ? "(" : "", s ? s : "", s ? ") " : "",
(lease -> hardware_addr.htype
? print_hw_addr (lease -> hardware_addr.htype,
lease -> hardware_addr.hlen,
lease -> hardware_addr.haddr)

View File

@@ -539,7 +539,7 @@ dhcpd.conf(5) dhcpd.conf(5)
you might write the following subclass declaration for
that client:
subclass "allocation-class-2" 08:00:2b:a1:11:31 {
subclass "allocation-class-2" 1:08:00:2b:a1:11:31 {
option root-path "samsara:/var/diskless/alphapc";
filename "/tftpboot/netbsd.alphapc-diskless";
}
@@ -828,16 +828,18 @@ dhcpd.conf(5) dhcpd.conf(5)
RREEFFEERREENNCCEE:: AALLLLOOWW AANNDD DDEENNYY
The _a_l_l_o_w and _d_e_n_y statements can be used to control the
behaviour of dhcpd to various sorts of requests. The
allow and deny keywords actually have different meanings
depending on the context. In a pool context, these key<65>
words can be used to set up access lists for address allo<6C>
cation pools. In other contexts, the keywords simply
response of the DHCP server to various sorts of requests.
The allow and deny keywords actually have different mean<EFBFBD>
ings depending on the context. In a pool context, these
keywords can be used to set up access lists for address
allocation pools. In other contexts, the keywords simply
control general server behaviour with respect to clients
based on scope.
based on scope. In a non-pool context, the _i_g_n_o_r_e key<65>
word can be used in place of the _d_e_n_y keyword to prevent
logging of denied requests.
AALLLLOOWW AANNDD DDEENNYY IINN SSCCOOPPEE
AALLLLOOWW DDEENNYY AANNDD IIGGNNOORREE IINN SSCCOOPPEE
The following usages of allow and deny will work in any
scope, although it is not recommended that they be used in
pool declarations.
@@ -846,10 +848,8 @@ AALLLLOOWW AANNDD DDEENNYY IINN SSCCOOPPEE
aallllooww uunnkknnoowwnn--cclliieennttss;;
ddeennyy uunnkknnoowwnn--cclliieennttss;;
iiggnnoorree uunnkknnoowwnn--cclliieennttss;;
The uunnkknnoowwnn--cclliieennttss flag is used to tell dhcpd whether or
not to dynamically assign addresses to unknown clients.
Dynamic address assignment to unknown clients is aalllloowwed
@@ -862,12 +862,16 @@ AALLLLOOWW AANNDD DDEENNYY IINN SSCCOOPPEE
dhcpd.conf(5) dhcpd.conf(5)
The uunnkknnoowwnn--cclliieennttss flag is used to tell dhcpd whether or
not to dynamically assign addresses to unknown clients.
Dynamic address assignment to unknown clients is aalllloowwed
by default.
TThhee _b_o_o_t_p kkeeyywwoorrdd
aallllooww bboooottpp;;
ddeennyy bboooottpp;;
iiggnnoorree bboooottpp;;
The bboooottpp flag is used to tell dhcpd whether or not to
respond to bootp queries. Bootp queries are aalllloowwed by
@@ -877,13 +881,71 @@ dhcpd.conf(5) dhcpd.conf(5)
aallllooww bboooottiinngg;;
ddeennyy bboooottiinngg;;
iiggnnoorree bboooottiinngg;;
The bboooottiinngg flag is used to tell dhcpd whether or not to
respond to queries from a particular client. This keyword
only has meaning when it appears in a host declaration.
By default, booting is aalllloowwed, but if it is disabled for
a particular client, then that client will not be able to
get and address from the DHCP server.
get and address from the DHCP server. TThhee _d_u_p_l_i_c_a_t_e_s kkeeyy<><08>
wwoorrdd
aallllooww dduupplliiccaatteess;;
ddeennyy dduupplliiccaatteess;;
Host declarations can match client messages based on the
DHCP Client Identifer option or based on the client's net<65>
work hardware type and MAC address. If the MAC address
is used, the host declaration will match any client with
that MAC address - even clients with different client
identifiers. This doesn't normally happen, but is possi<73>
ble when one computer has more than one operating system
installed on it - for example, Microsoft Windows and
NetBSD or Linux.
The dduupplliiccaatteess flag tells the DHCP server that if a
request is received from a client that matches the MAC
address of a host declaration, any other leases matching
that MAC address should be discarded by the server, even
if the UID is not the same. This is a violation of the
DHCP protocol, but can prevent clients whose client iden<65>
tifiers change regularly from holding many leases at the
same time. By default, duplicates are aalllloowwed. TThhee
_d_e_c_l_i_n_e_s kkeeyywwoorrdd
aallllooww ddeecclliinneess;;
ddeennyy ddeecclliinneess;;
14
dhcpd.conf(5) dhcpd.conf(5)
iiggnnoorree ddeecclliinneess;;
The DHCPDECLINE message is used by DHCP clients to indi<64>
cate that the lease the server has offered is not valid.
When the server receives a DHCPDECLINE for a particular
address, it normally abandons that address, assuming that
some unauthorized system is using it. Unfortunately, a
malicious or buggy client can, using DHCPDECLINE messages,
completely exhaust the DHCP server's allocation pool.
The server will reclaim these leases, but while the client
is running through the pool, it may cause serious thrash<73>
ing in the DNS, and it will also cause the DHCP server to
forget old DHCP client address allocations.
The ddeecclliinneess flag tells the DHCP server whether or not to
honor DHCPDECLINE messages. If it is set to ddeennyy or
iiggnnoorree in a particular scope, the DHCP server will not
respond to DHCPDECLINE messages.
AALLLLOOWW AANNDD DDEENNYY WWIITTHHIINN PPOOOOLL DDEECCLLAARRAATTIIOONNSS
The uses of the allow and deny keyword shown in the previ<76>
@@ -916,10 +978,14 @@ AALLLLOOWW AANNDD DDEENNYY WWIITTHHIINN PPOOOOLL DDEECC
allocation process is done as described previously in the
ADDRESS ALLOCATION section.
When declaring permit lists for address allocation pools,
the following syntaxes are recognized following the allow
or deny keyword:
14
15
@@ -928,10 +994,6 @@ AALLLLOOWW AANNDD DDEENNYY WWIITTHHIINN PPOOOOLL DDEECC
dhcpd.conf(5) dhcpd.conf(5)
When declaring permit lists for address allocation pools,
the following syntaxes are recognized following the allow
or deny keyword:
kknnoowwnn cclliieennttss;;
If specified, this statement either allows or prevents
@@ -981,11 +1043,15 @@ dhcpd.conf(5) dhcpd.conf(5)
next renew.
RREEFFEERREENNCCEE:: PPAARRAAMMEETTEERRSS
TThhee _d_e_f_a_u_l_t_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt
TThhee _l_e_a_s_e_-_f_i_l_e_-_n_a_m_e ssttaatteemmeenntt
lleeaassee--ffiillee--nnaammee _n_a_m_e;;
_N_a_m_e should be the name of the DHCP server's lease file.
15
16
@@ -994,6 +1060,23 @@ RREEFFEERREENNCCEE:: PPAARRAAMMEETTEERRSS
dhcpd.conf(5) dhcpd.conf(5)
By default, this is /var/db/dhcpd.leases. This statement
mmuusstt appear in the outer scope of the configuration file -
if it appears in some other scope, it will have no effect.
TThhee _p_i_d_-_f_i_l_e_-_n_a_m_e ssttaatteemmeenntt
ppiidd--ffiillee--nnaammee _n_a_m_e;;
_N_a_m_e should be the name of the DHCP server's process ID
file. This is the file in which the DHCP server's pro<72>
cess ID is stored when the server starts. By default,
this is /var/run/dhcpd.pid. Like the lease-file-name
statement, this statement must appear in the outer scope
of the configuration file.
TThhee _d_e_f_a_u_l_t_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt
ddeeffaauulltt--lleeaassee--ttiimmee _t_i_m_e;;
_T_i_m_e should be the length in seconds that will be assigned
@@ -1031,6 +1114,18 @@ dhcpd.conf(5) dhcpd.conf(5)
This can be used to set up a secondary DHCP server which
never offers an address to a client until the primary
17
dhcpd.conf(5) dhcpd.conf(5)
server has been given a chance to do so. If the primary
server is down, the client will bind to the secondary
server, but otherwise clients should always bind to the
@@ -1048,18 +1143,6 @@ dhcpd.conf(5) dhcpd.conf(5)
a physical hardware interface type. Currently, only the
eetthheerrnneett and ttookkeenn--rriinngg types are recognized, although
support for a ffddddii hardware type (and others) would also
16
dhcpd.conf(5) dhcpd.conf(5)
be desirable. The _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s should be a set of
hexadecimal octets (numbers from 0 through ff) seperated
by colons. The _h_a_r_d_w_a_r_e statement may also be used for
@@ -1098,6 +1181,17 @@ dhcpd.conf(5) dhcpd.conf(5)
ffiixxeedd--aaddddrreessss _a_d_d_r_e_s_s [,, _a_d_d_r_e_s_s ... ];;
18
dhcpd.conf(5) dhcpd.conf(5)
The _f_i_x_e_d_-_a_d_d_r_e_s_s statement is used to assign one or more
fixed IP addresses to a client. It should only appear in
a _h_o_s_t declaration. If more than one address is supplied,
@@ -1114,18 +1208,6 @@ dhcpd.conf(5) dhcpd.conf(5)
ddyynnaammiicc--bboooottpp--lleeaassee--ccuuttooffff _d_a_t_e;;
17
dhcpd.conf(5) dhcpd.conf(5)
The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f statement sets the ending
time for all leases assigned dynamically to BOOTP clients.
Because BOOTP clients do not have any way of renewing
@@ -1165,6 +1247,17 @@ dhcpd.conf(5) dhcpd.conf(5)
lose its lease. Needless to say, this parameter should be
adjusted with extreme caution.
19
dhcpd.conf(5) dhcpd.conf(5)
TThhee _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s ssttaatteemmeenntt
ggeett--lleeaassee--hhoossttnnaammeess _f_l_a_g;;
@@ -1181,17 +1274,6 @@ dhcpd.conf(5) dhcpd.conf(5)
uussee--hhoosstt--ddeeccll--nnaammeess _f_l_a_g;;
18
dhcpd.conf(5) dhcpd.conf(5)
If the _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s parameter is true in a given
scope, then for every host declaration within that scope,
the name provided for the host declaration will be sup<75>
@@ -1231,6 +1313,17 @@ dhcpd.conf(5) dhcpd.conf(5)
respond with a DHCPNAK message, causing the client to for<6F>
get its IP address and try to get a new one.
20
dhcpd.conf(5) dhcpd.conf(5)
If a DHCP server is being configured by somebody who is
not the network administrator and who therefore does not
wish to assert this level of authority, then the statement
@@ -1246,18 +1339,6 @@ dhcpd.conf(5) dhcpd.conf(5)
Note that the most specific scope for which the concept of
authority makes any sense is the physical network segment
19
dhcpd.conf(5) dhcpd.conf(5)
- either a shared-network statement or a subnet statement
that is not contained within a shared-network statement.
It is not meaningful to specify that the server is author<6F>
@@ -1297,6 +1378,18 @@ dhcpd.conf(5) dhcpd.conf(5)
ting this flag to 'on' for the relevant scope. To avoid
creating excess broadcast traffic on your network, we rec<65>
ommend that you restrict the use of this option to as few
21
dhcpd.conf(5) dhcpd.conf(5)
clients as possible. For example, the Microsoft DHCP
client is known not to have this problem, as are the Open<65>
Transport and ISC DHCP clients.
@@ -1312,18 +1405,6 @@ dhcpd.conf(5) dhcpd.conf(5)
forgotten any lease not mentioned in the DHCPREQUEST -
i.e., the client has only a single network interface _a_n_d
it does not remember leases it's holding on networks to
20
dhcpd.conf(5) dhcpd.conf(5)
which it is not currently attached. Neither of these
assumptions are guaranteed or provable, so we urge caution
in the use of this statement.
@@ -1363,6 +1444,18 @@ dhcpd.conf(5) dhcpd.conf(5)
priate for some or all clients served by that interface.
Another common case is when an alias is defined for the
purpose of having a consistent IP address for the DHCP
22
dhcpd.conf(5) dhcpd.conf(5)
server, and it is desired that the clients use this IP
address when contacting the server.
@@ -1378,18 +1471,6 @@ VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD OOPPTTIIOONNSS
option, which allows vendors to define their own options
that will be sent encapsulated in a standard DHCP option.
The format of the vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option is
21
dhcpd.conf(5) dhcpd.conf(5)
either a hunk of opaque data, or an actual option buffer
just like a standard DHCP option buffer.
@@ -1427,11 +1508,23 @@ dhcpd.conf(5) dhcpd.conf(5)
you can set up scopes that define values for those
options, and you can say when to use them. For example,
suppose you want to handle two different classes of
clients, as in the example in the CCLLIIEENNTT CCLLAASSSSIINNGG section.
Using the option space definition shown in the previous
example, something very similar to the vendor-encapsu<73>
lated-options definition shown earlier can be done as fol<6F>
lows:
clients, as in the example in the VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD
OOPPTTIIOONNSS section. Using the option space definition shown
23
dhcpd.conf(5) dhcpd.conf(5)
in the previous example, something very similar to the
vendor-encapsulated-options definition shown earlier can
be done as follows:
class "vendor-classes" {
match option vendor-class-identifier;
@@ -1445,17 +1538,6 @@ dhcpd.conf(5) dhcpd.conf(5)
option SUNW.root-path "/export/root/sparc";
}
22
dhcpd.conf(5) dhcpd.conf(5)
subclass "vendor-classes" "SUNW.i86pc" {
vendor-option-space SUNW;
option SUNW.root-path "/export/root/i86pc";
@@ -1497,22 +1579,6 @@ AAUUTTHHOORR
23
24

View File

@@ -22,14 +22,16 @@
#ifndef lint
static char copyright[] =
"$Id: failover.c,v 1.3 1999/11/14 00:42:57 mellon Exp $ Copyright (c) 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: failover.c,v 1.4 1999/11/20 18:36:31 mellon Exp $ Copyright (c) 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#include <omapip/omapip_p.h>
#if defined (FAILOVER_PROTOCOL)
static struct hash_table *failover_hash;
static isc_result_t do_a_failover_option (omapi_connection_object_t *,
static dhcp_failover_state_t *failover_states;
static isc_result_t do_a_failover_option (omapi_object_t *,
dhcp_failover_link_t *);
void enter_failover_peer (peer)
@@ -70,15 +72,20 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h)
dhcp_failover_link_t *obj;
char *peer_name;
unsigned long port;
omapi_typed_data_t *value = (omapi_typed_data_t *)0;
omapi_value_t *value = (omapi_value_t *)0;
status = omapi_get_value_str (h, (omapi_object_t *)0,
"remote-port", &value);
if (status != ISC_R_SUCCESS)
return status;
if (!value -> value) {
omapi_value_dereference (&value,
"dhcp_failover_link_initiate");
return ISC_R_INVALIDARG;
}
status = omapi_get_int_value (&port, value);
omapi_typed_data_dereference (&value, "dhcp_failover_link_initiate");
status = omapi_get_int_value (&port, value -> value);
omapi_value_dereference (&value, "dhcp_failover_link_initiate");
if (status != ISC_R_SUCCESS)
return status;
@@ -86,24 +93,26 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h)
"remote-peer", &value);
if (status != ISC_R_SUCCESS)
return status;
if (value -> type != omapi_datatype_string &&
value -> type != omapu_datatype_data) {
omapi_typed_data_dereference (&value,
if (!value -> value ||
(value -> value -> type != omapi_datatype_string &&
value -> value -> type != omapi_datatype_data)) {
omapi_value_dereference (&value,
"dhcp_failover_link_initiate");
return ISC_R_INVALIDARG;
}
/* Save the name. */
peer_name = malloc (value -> u.buffer.len + 1);
peer_name = malloc (value -> value -> u.buffer.len + 1);
if (!peer_name) {
omapi_typed_data_dereference (&value,
omapi_value_dereference (&value,
"dhcp_failover_link_initiate");
return ISC_R_NOMEMORY;
}
memcpy (peer_name, value -> u.buffer.data, value -> u.buffer.len);
peer_name [value -> u.buffer.len] = 0;
omapi_typed_data_dereference (&value, "dhcp_failover_link_initiate");
memcpy (peer_name, value -> value -> u.buffer.value,
value -> value -> u.buffer.len);
peer_name [value -> value -> u.buffer.len] = 0;
omapi_value_dereference (&value, "dhcp_failover_link_initiate");
obj = (dhcp_failover_link_t *)malloc (sizeof *obj);
if (!obj)
@@ -112,9 +121,9 @@ isc_result_t dhcp_failover_link_initiate (omapi_object_t *h)
obj -> refcnt = 1;
obj -> type = dhcp_type_failover_link;
obj -> peer_name = peer_name;
obj -> port = port;
obj -> peer_port = port;
status = omapi_connect ((omapi_object_t *)obj, server_name, port);
status = omapi_connect ((omapi_object_t *)obj, peer_name, port);
if (status != ISC_R_SUCCESS) {
omapi_object_dereference ((omapi_object_t **)&obj,
"dhcp_failover_link_initiate");
@@ -165,41 +174,50 @@ isc_result_t dhcp_failover_link_signal (omapi_object_t *h,
/* Not a signal we recognize? */
if (strcmp (name, "ready")) {
if (p -> inner && p -> inner -> type -> signal_handler)
return (*(p -> inner -> type -> signal_handler)) (h,
if (h -> inner && h -> inner -> type -> signal_handler)
return (*(h -> inner -> type -> signal_handler)) (h,
name,
ap);
return ISC_R_NOTFOUND;
}
if (!p -> outer || p -> outer -> type != omapi_type_connection)
if (!h -> outer || h -> outer -> type != omapi_type_connection)
return ISC_R_INVALIDARG;
c = p -> outer;
c = h -> outer;
/* We get here because we requested that we be woken up after
some number of bytes were read, and that number of bytes
has in fact been read. */
switch (p -> state) {
switch (link -> state) {
case dhcp_flink_start:
p -> state = dhcp_flink_message_length_wait;
link -> state = dhcp_flink_message_length_wait;
if ((omapi_connection_require (c, 2)) != ISC_R_SUCCESS)
break;
case dhcp_flink_message_length_wait:
p -> state = dhcp_flink_message_wait;
memset (link -> incoming_message, 0, sizeof (link -> imsg));
/* Get the length: */
omapi_connection_get_uint16 (c, &link -> imsg_len);
link -> imsg_count = 0; /* Bytes read. */
/* Maximum of 2048 bytes in any failover message. */
if (link -> imsg_len > DHCP_FAILOVER_MAX_MESSAGE_SIZE) {
link -> state = dhcp_flink_message_wait;
link -> imsg = dmalloc (sizeof (failover_message_t),
"dhcp_failover_link_signal");
if (!link -> imsg) {
dhcp_flink_fail:
if (link -> imsg) {
dfree (link -> imsg,
"dhcp_failover_link_signal");
link -> imsg = (failover_message_t *)0;
}
link -> state = dhcp_flink_disconnected;
omapi_disconnect (c, 1);
/* XXX just blow away the protocol state now?
XXX or will disconnect blow it away? */
return ISC_R_UNEXPECTED;
}
memset (link -> imsg, 0, sizeof (link -> imsg));
/* Get the length: */
omapi_connection_get_uint16 (c, &link -> imsg_len);
link -> imsg_count = 0; /* Bytes read. */
/* Maximum of 2048 bytes in any failover message. */
if (link -> imsg_len > DHCP_FAILOVER_MAX_MESSAGE_SIZE)
goto dhcp_flink_fail;
if ((omapi_connection_require (c, link -> imsg_len)) !=
ISC_R_SUCCESS)
@@ -234,11 +252,11 @@ isc_result_t dhcp_failover_link_signal (omapi_object_t *h,
/* Skip over any portions of the message header that we
don't understand. */
if (link -> payoff - link -> imsg_count) {
if (link -> imsg_payoff - link -> imsg_count) {
omapi_connection_copyout ((unsigned char *)0, c,
(link -> payoff -
(link -> imsg_payoff -
link -> imsg_count));
link -> imsg_count = link -> payoff;
link -> imsg_count = link -> imsg_payoff;
}
/* Get transaction ID. */
@@ -264,14 +282,15 @@ isc_result_t dhcp_failover_link_signal (omapi_object_t *h,
}
static isc_result_t do_a_failover_option (c, link)
omapi_connection_object_t *c;
omapi_object_t *c;
dhcp_failover_link_t *link;
{
u_int16_t option_code;
u_int16_t option_len;
char *op;
int op_size;
int op_count;
unsigned char *op;
unsigned op_size;
unsigned op_count;
int i;
if (link -> imsg_count + 2 > link -> imsg_len) {
log_error ("FAILOVER: message overflow at option code.");
@@ -299,7 +318,7 @@ static isc_result_t do_a_failover_option (c, link)
option_code, option_len);
#endif
omapi_connection_copyout ((unsigned char *)0, c, option_len);
link -> imsg_count = += option_len;
link -> imsg_count += option_len;
return ISC_R_SUCCESS;
}
@@ -320,7 +339,7 @@ static isc_result_t do_a_failover_option (c, link)
}
/* Only accept an option once. */
if (imsg -> options_present & ft_options [option_code].bit) {
if (link -> imsg -> options_present & ft_options [option_code].bit) {
log_error ("FAILOVER: duplicate option %s",
ft_options [option_code].name);
return ISC_R_PROTOCOLERROR;
@@ -335,7 +354,7 @@ static isc_result_t do_a_failover_option (c, link)
if (ft_options [option_code].bit &&
!(fto_allowed [option_code] & ft_options [option_code].bit)) {
omapi_connection_copyout ((unsigned char *)0, c, option_len);
link -> imsg_count = += option_len;
link -> imsg_count += option_len;
return ISC_R_SUCCESS;
}
@@ -346,27 +365,28 @@ static isc_result_t do_a_failover_option (c, link)
we expect the space for them to be preallocated,
and we can just read the data in. */
op = ((char *)&link -> imsg) + ft_options [option_code].offset;
op = ((unsigned char *)&link -> imsg) +
ft_options [option_code].offset;
op_size = ft_sizes [ft_options [option_code].type];
op_count = ft_options [option_code].num_present;
if (option_length != op_size * op_count) {
if (option_len != op_size * op_count) {
log_error ("FAILOVER: option size (%d:%d), option %s",
option_length,
option_len,
(ft_sizes [ft_options [option_code].type] *
ft_options [option_code].num_present),
ft_options [option_code].name);
return ISC_R_PROTOCOLERROR;
}
} else {
struct failover_option *fo;
failover_option_t *fo;
/* FT_DDNS* are special - one or two bytes of status
followed by the client FQDN. */
if (ft_options [option_code].type == FT_DDNS1 ||
ft_options [option_code].type == FT_DDNS1) {
struct failover_ddns *ddns =
((struct failover_ddns *)
ddns_fqdn_t *ddns =
((ddns_fqdn_t *)
(((char *)&link -> imsg) +
ft_options [option_code].offset));
@@ -378,7 +398,7 @@ static isc_result_t do_a_failover_option (c, link)
if (op_count == 1)
ddns -> codes [1] = 0;
op_size = 1;
op_count = option_length - op_count;
op_count = option_len - op_count;
ddns -> length = op_count;
ddns -> data = malloc (op_count);
@@ -393,7 +413,7 @@ static isc_result_t do_a_failover_option (c, link)
omapi_connection_copyout (ddns -> data, c, op_count);
goto out;
}
} else {
/* A zero for num_present means that any number of
elements can appear, so we have to figure out how
many we got from the length of the option, and then
@@ -403,20 +423,20 @@ static isc_result_t do_a_failover_option (c, link)
/* Make sure that option data length is a multiple of the
size of the data type being sent. */
if (op_size > 1 && option_length % op_size) {
log_error ("FAILOVER: option_length %d not %s%d",
option_length, "multiple of ", option_size);
if (op_size > 1 && option_len % op_size) {
log_error ("FAILOVER: option_len %d not %s%d",
option_len, "multiple of ", op_size);
return ISC_R_PROTOCOLERROR;
}
op_count = option_length / op_size;
op_count = option_len / op_size;
fo = ((struct failover_option *)
fo = ((failover_option_t *)
(((char *)&link -> imsg) +
ft_options [option_code].offset));
fo -> count = op_count;
fo -> data = malloc (option_length);
fo -> data = malloc (option_len);
if (!fo -> data) {
log_error ("FAILOVER: no memory getting %s (%d)",
"option data", op_count);
@@ -438,12 +458,12 @@ static isc_result_t do_a_failover_option (c, link)
for (i = 0; i < op_count; i++) {
switch (ft_options [option_code].type) {
case FT_UINT32:
omapi_connection_get_uint32 (c, op);
omapi_connection_get_uint32 (c, (u_int32_t *)op);
op += 4;
break;
case FT_UINT16:
omapi_connection_get_uint16 (c, op);
omapi_connection_get_uint16 (c, (u_int16_t *)op);
op += 2;
break;
@@ -458,7 +478,7 @@ static isc_result_t do_a_failover_option (c, link)
}
out:
/* Remember that we got this option. */
link -> options_present |= ft_options [option_code].bit;
link -> imsg -> options_present |= ft_options [option_code].bit;
return ISC_R_SUCCESS;
}
@@ -471,7 +491,7 @@ isc_result_t dhcp_failover_link_set_value (omapi_object_t *h,
return ISC_R_INVALIDARG;
/* Never valid to set these. */
if (!omapi_ds_strcmp (name, "port") ||
if (!omapi_ds_strcmp (name, "link-port") ||
!omapi_ds_strcmp (name, "link-name") ||
!omapi_ds_strcmp (name, "link-state"))
return ISC_R_NOPERM;
@@ -493,8 +513,9 @@ isc_result_t dhcp_failover_link_get_value (omapi_object_t *h,
return ISC_R_INVALIDARG;
link = (dhcp_failover_link_t *)h;
if (!omapi_ds_strcmp (name, "port")) {
return omapi_make_int_value (value, name, link -> port,
if (!omapi_ds_strcmp (name, "link-port")) {
return omapi_make_int_value (value, name,
(int)link -> peer_port,
"dhcp_failover_link_get_value");
} else if (!omapi_ds_strcmp (name, "link-name")) {
return omapi_make_string_value
@@ -502,7 +523,7 @@ isc_result_t dhcp_failover_link_get_value (omapi_object_t *h,
"dhcp_failover_link_get_value");
} else if (!omapi_ds_strcmp (name, "link-state")) {
if (link -> state < 0 ||
link -> state >= dhcp_failover_link_state_max)
link -> state >= dhcp_flink_state_max)
return omapi_make_string_value
(value, name, "invalid link state",
"dhcp_failover_link_get_value");
@@ -520,13 +541,14 @@ isc_result_t dhcp_failover_link_get_value (omapi_object_t *h,
isc_result_t dhcp_failover_link_destroy (omapi_object_t *h, const char *name)
{
dhcp_failover_link_t *p;
dhcp_failover_link_t *link;
if (h -> type != dhcp_type_failover_link)
return ISC_R_INVALIDARG;
p = (dhcp_failover_link_object_t *)h;
if (p -> message)
omapi_object_dereference ((omapi_object_t **)&p -> message,
name);
link = (dhcp_failover_link_t *)h;
if (link -> imsg) {
dfree (link -> imsg, "dhcp_failover_link_destroy");
link -> imsg = (failover_message_t *)0;
}
return ISC_R_SUCCESS;
}
@@ -535,21 +557,22 @@ isc_result_t dhcp_failover_link_destroy (omapi_object_t *h, const char *name)
isc_result_t dhcp_failover_link_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *p)
omapi_object_t *l)
{
dhcp_failover_link_t *link;
isc_result_t status;
if (h -> type != omapi_type_protocol)
if (l -> type != dhcp_type_failover_link)
return ISC_R_INVALIDARG;
link = (dhcp_failover_link_t *)h;
link = (dhcp_failover_link_t *)l;
status = omapi_connection_put_name (c, "port");
status = omapi_connection_put_name (c, "link-port");
if (status != ISC_R_SUCCESS)
return status;
status = omapi_put_uint32 (c, sizeof (int));
status = omapi_connection_put_uint32 (c, sizeof (int));
if (status != ISC_R_SUCCESS)
return status;
status = omapi_put_uint32 (c, link -> port);
status = omapi_connection_put_uint32 (c, link -> peer_port);
if (status != ISC_R_SUCCESS)
return status;
@@ -564,7 +587,7 @@ isc_result_t dhcp_failover_link_stuff_values (omapi_object_t *c,
if (status != ISC_R_SUCCESS)
return status;
if (link -> state < 0 ||
link -> state >= dhcp_failover_link_state_max)
link -> state >= dhcp_flink_state_max)
status = omapi_connection_put_string (c, "invalid link state");
else
status = (omapi_connection_put_string
@@ -572,19 +595,19 @@ isc_result_t dhcp_failover_link_stuff_values (omapi_object_t *c,
if (status != ISC_R_SUCCESS)
return status;
if (p -> inner && p -> inner -> type -> stuff_values)
return (*(p -> inner -> type -> stuff_values)) (c, id,
p -> inner);
if (link -> inner && link -> inner -> type -> stuff_values)
return (*(link -> inner -> type -> stuff_values)) (c, id,
link -> inner);
return ISC_R_SUCCESS;
}
/* Set up a listener for the omapi protocol. The handle stored points to
a listener object, not a protocol object. */
isc_result_t dhcp_failover_listen (omapi_object_t *h);
isc_result_t dhcp_failover_listen (omapi_object_t *h)
{
isc_result_t status;
dhcp_failover_listener_object_t *obj;
dhcp_failover_listener_t *obj;
unsigned long port;
omapi_value_t *value = (omapi_value_t *)0;
@@ -592,19 +615,23 @@ isc_result_t dhcp_failover_listen (omapi_object_t *h);
"local-port", &value);
if (status != ISC_R_SUCCESS)
return status;
if (!value -> value) {
omapi_value_dereference (&value, "dhcp_failover_listen");
return ISC_R_INVALIDARG;
}
status = omapi_get_int_value (&port, value);
omapi_typed_data_dereference (&value, "dhcp_failover_listen");
status = omapi_get_int_value (&port, value -> value);
omapi_value_dereference (&value, "dhcp_failover_listen");
if (status != ISC_R_SUCCESS)
return status;
obj = (dhcp_failover_listener_object_t *)malloc (sizeof *obj);
obj = (dhcp_failover_listener_t *)malloc (sizeof *obj);
if (!obj)
return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj);
obj -> refcnt = 1;
obj -> type = dhcp_type_failover_listener;
obj -> port = port;
obj -> local_port = port;
status = omapi_listen ((omapi_object_t *)obj, port, 1);
omapi_object_dereference ((omapi_object_t **)&obj,
@@ -638,14 +665,14 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o,
{
isc_result_t status;
omapi_connection_object_t *c;
omapi_protocol_object_t *obj;
dhcp_failover_listener_object_t *p;
dhcp_failover_state_object_t *state;
dhcp_failover_link_t *obj;
dhcp_failover_listener_t *p;
dhcp_failover_state_t *state;
char *peer_name;
if (!o || o -> type != dhcp_type_failover_listener)
return ISC_R_INVALIDARG;
p = (dhcp_failover_listener_object_t *)o;
p = (dhcp_failover_listener_t *)o;
/* Not a signal we recognize? */
if (strcmp (name, "connect")) {
@@ -661,13 +688,13 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o,
/* See if we can find a secondary failover_state object that
matches this connection. */
for (state = states; state; state = state -> next) {
for (state = failover_states; state; state = state -> next) {
struct hostent *he;
int hix;
struct in_addr ia;
if (inet_aton (state -> remote_peer, &ia)) {
if (ia == c -> remote_addr.sin_addr)
if (ia.s_addr == c -> remote_addr.sin_addr.s_addr)
break;
} else {
he = gethostbyname (state -> remote_peer);
@@ -695,26 +722,26 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o,
return ISC_R_INVALIDARG;
}
obj = (omapi_protocol_object_t *)malloc (sizeof *obj);
obj = (dhcp_failover_link_t *)malloc (sizeof *obj);
if (!obj)
return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj);
obj -> refcnt = 1;
obj -> type = omapi_type_protocol;
obj -> type = dhcp_type_failover_link;
peer_name = malloc (strlen (state -> remote_peer) + 1);
if (!peer_name)
return ISC_R_NOMEMORY;
strcpy (peer_name, state -> remote_peer);
obj -> peer_name = peer_name;
obj -> port = ntohs (c -> remote_addr.sin_port);
obj -> peer_port = ntohs (c -> remote_addr.sin_port);
status = omapi_object_reference (&obj -> outer, c,
status = omapi_object_reference (&obj -> outer, (omapi_object_t *)c,
"dhcp_failover_listener_signal");
if (status != ISC_R_SUCCESS) {
lose:
omapi_object_dereference ((omapi_object_t **)&obj,
"dhcp_failover_listener_signal");
omapi_disconnect (c, 1);
omapi_disconnect ((omapi_object_t *)c, 1);
return status;
}
@@ -725,7 +752,7 @@ isc_result_t dhcp_failover_listener_signal (omapi_object_t *o,
/* Notify the master state machine of the arrival of a new
connection. */
status = omapi_signal (state, "connect", obj);
status = omapi_signal_in ((omapi_object_t *)state, "connect", obj);
if (status != ISC_R_SUCCESS)
goto lose;
@@ -790,10 +817,10 @@ isc_result_t dhcp_failover_listener_stuff (omapi_object_t *c,
/* Set up master state machine for the failover protocol. */
isc_result_t dhcp_failover_register (omapi_object_t *h);
isc_result_t dhcp_failover_register (omapi_object_t *h)
{
isc_result_t status;
dhcp_failover_state_object_t *obj;
dhcp_failover_state_t *obj;
unsigned long port;
omapi_value_t *value = (omapi_value_t *)0;
@@ -801,19 +828,23 @@ isc_result_t dhcp_failover_register (omapi_object_t *h);
"local-port", &value);
if (status != ISC_R_SUCCESS)
return status;
if (!value -> value) {
omapi_value_dereference (&value, "dhcp_failover_register");
return ISC_R_INVALIDARG;
}
status = omapi_get_int_value (&port, value);
omapi_typed_data_dereference (&value, "dhcp_failover_listen");
status = omapi_get_int_value (&port, value -> value);
omapi_value_dereference (&value, "dhcp_failover_listen");
if (status != ISC_R_SUCCESS)
return status;
obj = (dhcp_failover_state_object_t *)malloc (sizeof *obj);
obj = (dhcp_failover_state_t *)malloc (sizeof *obj);
if (!obj)
return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj);
obj -> refcnt = 1;
obj -> type = dhcp_type_failover_state;
obj -> port = port;
obj -> listen_port = port;
status = omapi_listen ((omapi_object_t *)obj, port, 1);
omapi_object_dereference ((omapi_object_t **)&obj,
@@ -847,25 +878,25 @@ isc_result_t dhcp_failover_state_signal (omapi_object_t *o,
isc_result_t status;
omapi_connection_object_t *c;
omapi_protocol_object_t *obj;
dhcp_failover_state_object_t *p;
dhcp_failover_state_object_t *state;
dhcp_failover_state_t *state;
char *peer_name;
if (!o || o -> type != dhcp_type_failover_state)
return ISC_R_INVALIDARG;
p = (dhcp_failover_state_object_t *)o;
state = (dhcp_failover_state_t *)o;
/* Not a signal we recognize? */
if (strcmp (name, "connect") &&
strcmp (name, "disconnect") &&
strcmp (name, "message")) {
if (p -> inner && p -> inner -> type -> signal_handler)
return (*(p -> inner -> type -> signal_handler))
(p -> inner, name, ap);
if (state -> inner && state -> inner -> type -> signal_handler)
return (*(state -> inner -> type -> signal_handler))
(state -> inner, name, ap);
return ISC_R_NOTFOUND;
}
/* Handle all the events we care about... */
return ISC_R_SUCCESS;
}
isc_result_t dhcp_failover_state_set_value (omapi_object_t *h,

View File

@@ -22,7 +22,7 @@
#ifndef lint
static char copyright[] =
"$Id: mdb.c,v 1.20 1999/11/14 00:32:28 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: mdb.c,v 1.21 1999/11/20 18:36:32 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -867,7 +867,7 @@ int supersede_lease (comp, lease, commit)
/* Copy the data files, but not the linkages. */
comp -> starts = lease -> starts;
if (lease -> uid) {
if (lease -> uid_len < sizeof (lease -> uid_buf)) {
if (lease -> uid_len <= sizeof (lease -> uid_buf)) {
memcpy (comp -> uid_buf,
lease -> uid, lease -> uid_len);
comp -> uid = &comp -> uid_buf [0];
@@ -1096,22 +1096,13 @@ void release_lease (lease, packet)
#endif
/* If there are statements to execute when the lease is
committed, execute them. */
released, execute them. */
if (lease -> on_release) {
execute_statements (packet, lease, packet -> options,
(struct option_state *)0, /* XXX */
lease -> on_release);
executable_statement_dereference (&lease -> on_release,
"dhcprelease");
if (lease -> ddns_fwd_name) {
dfree (lease -> ddns_fwd_name, "pool_timer");
lease -> ddns_fwd_name = (char *)0;
}
if (lease -> ddns_rev_name) {
dfree (lease -> ddns_rev_name, "pool_timer");
lease -> ddns_rev_name = (char *)0;
}
}
/* We do either the on_release or the on_expiry events, but

View File

@@ -29,7 +29,7 @@
#ifndef lint
static char copyright[] =
"$Id: omapi.c,v 1.20 1999/11/14 00:39:33 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: omapi.c,v 1.21 1999/11/20 18:36:32 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -41,9 +41,11 @@ omapi_object_type_t *dhcp_type_pool;
omapi_object_type_t *dhcp_type_shared_network;
omapi_object_type_t *dhcp_type_subnet;
omapi_object_type_t *dhcp_type_class;
#if defined (FAILOVER_PROTOCOL)
omapi_object_type_t *dhcp_type_failover_state;
omapi_object_type_t *dhcp_type_failover_link;
omapi_object_type_t *dhcp_type_failover_listener;
#endif
void dhcp_db_objects_setup ()
{

View File

@@ -22,73 +22,74 @@
#ifndef lint
static char copyright[] =
"$Id: stables.c,v 1.1 1999/11/14 00:36:51 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
"$Id: stables.c,v 1.2 1999/11/20 18:36:32 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#if defined (FAILOVER_PROTOCOL)
struct failover_option ft_options [] =
struct failover_option_info ft_options [] =
{
{ 0, "unused", FT_UNDEF, 0, 0 },
{ 1, "binding-status",
FT_UINT8, 1, FM_OFFSET (binding_status) },
{ 2, "assigned-IP-address",
FT_IPADDR, 1, FM_OFFSET (assigned_addr) },
{ 3, "sending-server-IP-address",
FT_IPADDR, 1, FM_OFFSET (sending_server) },
{ 4, "addresses-transferred",
FT_UINT32, 1, FM_OFFSET (addresses_transferred) },
{ 5, "client-identifier",
FT_BYTES, 0, FM_OFFSET (client_identifier) },
{ 6, "client-hardware-address",
FT_BYTES, 0, FM_OFFSET (chaddr) },
{ 7, "DDNS",
FT_DDNS, 1, FM_OFFSET (ddns) },
{ 8, "reject-reason",
FT_UINT8, 1, FM_OFFSET (reject_reason) },
{ 9, "message",
FT_TEXT, 0, FM_OFFSET (message) },
{ 10, "MCLT",
FT_UINT32, 1, FM_OFFSET (mclt) },
{ 11, "vendor-class-identifier",
FT_BYTES, 0, FM_OFFSET (vendor_class) },
{ 12, "undefined", FT_UNDEF, 0, 0 },
{ 13, "lease-expiration-time",
FT_UINT32, 1, FM_OFFSET (expiry) },
{ 14, "potential-expiration-time",
FT_UINT32, 1, FM_OFFSET (potential_expiry) },
{ 15, "grace-expiration-time",
FT_UINT32, 1, FM_OFFSET (grace_expiry) },
{ 16, "client-last-transaction-time",
FT_UINT32, 1, FM_OFFSET (client_ltt) },
{ 17, "start-time-of-state",
FT_UINT32, 1, FM_OFFSET (stos) },
{ 18, "server-state",
FT_UINT8, 1, FM_OFFSET (server_state) },
{ 19, "server-flags",
FT_UINT8, 1, FM_OFFSET (server_flags) },
{ 20, "vendor-specific-options",
FT_BYTES, 0, FM_OFFSET (vendor_options) },
{ 21, "max-unacked-bndupd",
FT_UINT32, 1, FM_OFFSET (max_unacked) },
{ 0, "unused", FT_UNDEF, 0, 0, 0 },
{ FTO_BINDING_STATUS, "binding-status",
FT_UINT8, 1, FM_OFFSET (binding_status), FTB_BINDING_STATUS },
{ FTO_ASSIGNED_IP_ADDRESS, "assigned-IP-address",
FT_IPADDR, 1, FM_OFFSET (assigned_addr), FTB_ASSIGNED_IP_ADDRESS },
{ FTO_SERVER_ADDR, "sending-server-IP-address",
FT_IPADDR, 1, FM_OFFSET (sending_server), FTB_SERVER_ADDR },
{ FTO_ADDRESSES_TRANSFERRED, "addresses-transferred",
FT_UINT32, 1, FM_OFFSET (addresses_transferred),
FTB_ADDRESSES_TRANSFERRED },
{ FTO_CLIENT_IDENTIFIER, "client-identifier",
FT_BYTES, 0, FM_OFFSET (client_identifier), FTB_CLIENT_IDENTIFIER },
{ FTO_CLIENT_HARDWARE_ADDRESS, "client-hardware-address",
FT_BYTES, 0, FM_OFFSET (chaddr), FTB_CLIENT_HARDWARE_ADDRESS },
{ FTO_DDNS, "DDNS",
FT_DDNS, 1, FM_OFFSET (ddns), FTB_DDNS },
{ FTO_REJECT_REASON, "reject-reason",
FT_UINT8, 1, FM_OFFSET (reject_reason), FTB_REJECT_REASON },
{ FTO_MESSAGE, "message",
FT_TEXT, 0, FM_OFFSET (message), FTB_MESSAGE },
{ FTO_MCLT, "MCLT",
FT_UINT32, 1, FM_OFFSET (mclt), FTB_MCLT },
{ FTO_VENDOR_CLASS, "vendor-class-identifier",
FT_BYTES, 0, FM_OFFSET (vendor_class), FTB_VENDOR_CLASS },
{ FTO_UNDEFINED, "undefined", FT_UNDEF, 0, 0, FTB_UNDEFINED },
{ FTO_LEASE_EXPIRY, "lease-expiration-time",
FT_UINT32, 1, FM_OFFSET (expiry), FTB_LEASE_EXPIRY },
{ FTO_POTENTIAL_EXPIRY, "potential-expiration-time",
FT_UINT32, 1, FM_OFFSET (potential_expiry), FTB_POTENTIAL_EXPIRY },
{ FTO_GRACE_EXPIRY, "grace-expiration-time",
FT_UINT32, 1, FM_OFFSET (grace_expiry), FTB_GRACE_EXPIRY },
{ FTO_CLTT, "client-last-transaction-time",
FT_UINT32, 1, FM_OFFSET (client_ltt), FTB_CLTT },
{ FTO_STOS, "start-time-of-state",
FT_UINT32, 1, FM_OFFSET (stos), FTB_STOS },
{ FTO_SERVER_STATE, "server-state",
FT_UINT8, 1, FM_OFFSET (server_state), FTB_SERVER_STATE },
{ FTO_SERVER_FLAGS, "server-flags",
FT_UINT8, 1, FM_OFFSET (server_flags), FTB_SERVER_FLAGS },
{ FTO_VENDOR_OPTIONS, "vendor-specific-options",
FT_BYTES, 0, FM_OFFSET (vendor_options), FTB_VENDOR_OPTIONS },
{ FTO_MAX_UNACKED, "max-unacked-bndupd",
FT_UINT32, 1, FM_OFFSET (max_unacked), FTB_MAX_UNACKED },
{ 22, "undefined", FT_UNDEF, 0, 0 },
{ 23, "receive-timer",
FT_UINT32, 1, FM_OFFSET (receive_timer) },
{ 24, "hash-bucket-assignment",
FT_BYTES, 0, FM_OFFSET (hba) },
{ 25, "message-digest",
FT_DIGEST, 0, 0 },
{ 26, "protocol-version",
FT_UINT8, 1, FM_OFFSET (protocol_version) },
{ 27, "TLS-request",
FT_UINT8, 2, FM_OFFSET (tls_request) },
{ 28, "TLS-reply",
FT_BYTES, 1, FM_OFFSET (tls_reply ) },
{ 29, "client-request-options",
FT_BYTES, 0, FM_OFFSET (request_options) },
{ 30, "client-reply-options",
FT_BYTES, 0, FM_OFFSET (reply_options) }
{ FTO_RECEIVE_TIMER, "receive-timer",
FT_UINT32, 1, FM_OFFSET (receive_timer), FTB_RECEIVE_TIMER },
{ FTO_HBA, "hash-bucket-assignment",
FT_BYTES, 0, FM_OFFSET (hba), FTB_HBA },
{ FTO_MESSAGE_DIGEST, "message-digest",
FT_DIGEST, 0, 0, FTB_MESSAGE_DIGEST },
{ FTO_PROTOCOL_VERSION, "protocol-version",
FT_UINT8, 1, FM_OFFSET (protocol_version), FTB_PROTOCOL_VERSION },
{ FTO_TLS_REQUEST, "TLS-request",
FT_UINT8, 2, FM_OFFSET (tls_request), FTB_TLS_REQUEST },
{ FTO_TLS_REPLY, "TLS-reply",
FT_BYTES, 1, FM_OFFSET (tls_reply ), FTB_TLS_REPLY },
{ FTO_REQUEST_OPTIONS, "client-request-options",
FT_BYTES, 0, FM_OFFSET (request_options), FTB_REQUEST_OPTIONS },
{ FTO_REPLY_OPTIONS, "client-reply-options",
FT_BYTES, 0, FM_OFFSET (reply_options), FTB_REPLY_OPTIONS }
};
/* These are really options that make sense for a particular request - if
@@ -132,6 +133,14 @@ int ft_sizes [] = {
0, /* FT_UNDEF */
0, /* FT_DIGEST */
};
char *dhcp_flink_state_names [] = {
"invalid state 0",
"startup",
"message length wait",
"message wait",
"disconnected"
};
#endif /* FAILOVER_PROTOCOL */
struct universe agent_universe;