diff options
-rw-r--r-- | client/dhclient.c | 6 | ||||
-rw-r--r-- | client/dhclient.conf.cat5 | 110 | ||||
-rw-r--r-- | common/nsupdate.c | 28 | ||||
-rw-r--r-- | common/parse.c | 10 | ||||
-rw-r--r-- | common/print.c | 6 | ||||
-rw-r--r-- | common/tree.c | 211 | ||||
-rw-r--r-- | dhcpctl/Makefile.dist | 2 | ||||
-rw-r--r-- | includes/cf/sunos5-5.h | 2 | ||||
-rw-r--r-- | includes/dhcpd.h | 81 | ||||
-rw-r--r-- | includes/failover.h | 55 | ||||
-rw-r--r-- | includes/omapip/omapip.h | 10 | ||||
-rw-r--r-- | includes/site.h | 6 | ||||
-rw-r--r-- | includes/tree.h | 4 | ||||
-rw-r--r-- | omapip/Makefile.dist | 2 | ||||
-rw-r--r-- | omapip/connection.c | 2 | ||||
-rw-r--r-- | omapip/listener.c | 2 | ||||
-rw-r--r-- | omapip/protocol.c | 32 | ||||
-rw-r--r-- | omapip/support.c | 2 | ||||
-rw-r--r-- | server/confpars.c | 10 | ||||
-rw-r--r-- | server/dhcp.c | 199 | ||||
-rw-r--r-- | server/dhcpd.conf.cat5 | 554 | ||||
-rw-r--r-- | server/failover.c | 249 | ||||
-rw-r--r-- | server/mdb.c | 21 | ||||
-rw-r--r-- | server/omapi.c | 4 | ||||
-rw-r--r-- | server/stables.c | 129 |
25 files changed, 1044 insertions, 693 deletions
diff --git a/client/dhclient.c b/client/dhclient.c index 94a21480..d56e4387 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -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); diff --git a/client/dhclient.conf.cat5 b/client/dhclient.conf.cat5 index d83ac0eb..9988a627 100644 --- a/client/dhclient.conf.cat5 +++ b/client/dhclient.conf.cat5 @@ -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 - 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 + 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 + 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 - 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 + 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 - 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 + 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 + 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 - 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 + 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; @@ -651,10 +655,6 @@ AAUUTTHHOORR - - - - 10 diff --git a/common/nsupdate.c b/common/nsupdate.c index f60a8945..a5c81ad9 100644 --- a/common/nsupdate.c +++ b/common/nsupdate.c @@ -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" @@ -332,7 +332,7 @@ int nsupdatePTR (revname, hostname, ttl, opcode) } break; } - z = res_update(u); + z = res_update (u); log_info ("%s %s: %s %ld IN PTR %s", opcode == ADD ? "add" : "delete", z == 1 ? "succeeded" : "failed", NAME (revname), (unsigned long)ttl, NAME (u -> r_data)); @@ -505,11 +505,11 @@ int updateA (lhs, rhs, ttl, lease) int y; hostname[0] = '\0'; - strncat(hostname, (const char *)lhs -> data, lhs -> len); + strncat (hostname, (const char *)lhs -> data, lhs -> len); hostname[lhs -> len] = '\0'; ipaddr[0] = '\0'; - strncat(ipaddr, (const char *)rhs -> data, rhs -> len); + strncat (ipaddr, (const char *)rhs -> data, rhs -> len); ipaddr[rhs -> len] = '\0'; #if 0 /* Wrong! This causes zone churn on every DHCPREQUEST! @@ -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; } @@ -552,11 +548,11 @@ int updatePTR (lhs, rhs, ttl, lease) int y; revname[0] = '\0'; - strncat(revname, (const char *)lhs -> data, lhs -> len); + strncat (revname, (const char *)lhs -> data, lhs -> len); revname[lhs -> len] = '\0'; hostname[0] = '\0'; - strncat(hostname, (const char *)rhs -> data, rhs -> len); + strncat (hostname, (const char *)rhs -> data, rhs -> len); hostname[rhs -> len] = '\0'; #if 0 /* Wrong! This causes zone churn on every DHCPREQUEST! @@ -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; } @@ -598,11 +590,11 @@ int deleteA (lhs, rhs, lease) int y; hostname[0] = '\0'; - strncat(hostname, (const char *)lhs -> data, lhs -> len); + strncat (hostname, (const char *)lhs -> data, lhs -> len); hostname[lhs -> len] = '\0'; ipaddr[0] = '\0'; - strncat(ipaddr, (const char *)rhs -> data, rhs -> len); + strncat (ipaddr, (const char *)rhs -> data, rhs -> len); ipaddr[rhs -> len] = '\0'; #if 0 /* Wrong! This causes zone churn on every DHCPREQUEST! @@ -642,11 +634,11 @@ int deletePTR (lhs, rhs, lease) int y; revname[0] = '\0'; - strncat(revname, (const char *)lhs -> data, lhs -> len); + strncat (revname, (const char *)lhs -> data, lhs -> len); revname[lhs -> len] = '\0'; hostname[0] = '\0'; - strncat(hostname, (const char *)rhs -> data, rhs -> len); + strncat (hostname, (const char *)rhs -> data, rhs -> len); hostname[rhs -> len] = '\0'; #if 0 /* Wrong! This causes zone churn on every DHCPREQUEST! diff --git a/common/parse.c b/common/parse.c index 2b4bca2d..92cfaf84 100644 --- a/common/parse.c +++ b/common/parse.c @@ -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); diff --git a/common/print.c b/common/print.c index ca92c2c7..62993a6f 100644 --- a/common/print.c +++ b/common/print.c @@ -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 diff --git a/common/tree.c b/common/tree.c index ca4af5d3..a716ab16 100644 --- a/common/tree.c +++ b/common/tree.c @@ -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 (rrtype.len == 1 && - strncmp((const char *)rrtype.data, "a", 1) == 0) { + 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); + log_debug("calling updateA(%s, %s, %ld, lease)", + rrname.data, rrdata.data, ttl); #endif - updateA(&expr1, &expr2, ttl, lease); - } else if (rrtype.len == 3 && - strncmp((const char *)rrtype.data, - "ptr", 3) == 0) { + 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) { #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); - } - *result = 1; - } else { - log_error("dns-update: one or more subexpressions %s", - "evaluate to NULL."); - return 0; + 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; #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 (rrtype.len == 1 && - strncmp((const char *)rrtype.data, "a", 1) == 0) { + 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); + log_debug("calling deleteA(%s, %s, lease)", + rrname.data , rrdata.data); #endif - deleteA(&expr1, &expr2, lease); - } else if (rrtype.len == 3 && - strncmp((const char *)rrtype.data, - "ptr", 3) == 0) { + 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) { #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; } + *result = 1; #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, "", "", ")"); diff --git a/dhcpctl/Makefile.dist b/dhcpctl/Makefile.dist index d3784d38..5305fe64 100644 --- a/dhcpctl/Makefile.dist +++ b/dhcpctl/Makefile.dist @@ -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 diff --git a/includes/cf/sunos5-5.h b/includes/cf/sunos5-5.h index ec01e597..b5f3df2a 100644 --- a/includes/cf/sunos5-5.h +++ b/includes/cf/sunos5-5.h @@ -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(). */ diff --git a/includes/dhcpd.h b/includes/dhcpd.h index 74686faa..6d38680f 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -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 */ diff --git a/includes/failover.h b/includes/failover.h index e10abd9f..4432d0fa 100644 --- a/includes/failover.h +++ b/includes/failover.h @@ -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; + diff --git a/includes/omapip/omapip.h b/includes/omapip/omapip.h index b69f3fe6..233db8e7 100644 --- a/includes/omapip/omapip.h +++ b/includes/omapip/omapip.h @@ -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 *); diff --git a/includes/site.h b/includes/site.h index 7ef206d2..b823cb50 100644 --- a/includes/site.h +++ b/includes/site.h @@ -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 diff --git a/includes/tree.h b/includes/tree.h index 416248a0..d5e6fd6d 100644 --- a/includes/tree.h +++ b/includes/tree.h @@ -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; diff --git a/omapip/Makefile.dist b/omapip/Makefile.dist index eb528e7b..72b3b7a6 100644 --- a/omapip/Makefile.dist +++ b/omapip/Makefile.dist @@ -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 diff --git a/omapip/connection.c b/omapip/connection.c index 5fa4603d..78a70018 100644 --- a/omapip/connection.c +++ b/omapip/connection.c @@ -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; diff --git a/omapip/listener.c b/omapip/listener.c index cb58cbbf..cdb54a58 100644 --- a/omapip/listener.c +++ b/omapip/listener.c @@ -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; diff --git a/omapip/protocol.c b/omapip/protocol.c index cfb59c4e..d4f4a748 100644 --- a/omapip/protocol.c +++ b/omapip/protocol.c @@ -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; diff --git a/omapip/support.c b/omapip/support.c index dfd06704..5b2cb9e0 100644 --- a/omapip/support.c +++ b/omapip/support.c @@ -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; diff --git a/server/confpars.c b/server/confpars.c index 5f10fb4c..85799858 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -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; diff --git a/server/dhcp.c b/server/dhcp.c index 7cf151be..58ba31d8 100644 --- a/server/dhcp.c +++ b/server/dhcp.c @@ -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 -> hlen, - packet -> raw -> chaddr), - (packet -> raw -> giaddr.s_addr + (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)); + : 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,15 +325,28 @@ void dhcprelease (packet) } - log_info ("DHCPRELEASE of %s from %s via %s (%sfound)", - inet_ntoa (packet -> raw -> ciaddr), - print_hw_addr (packet -> raw -> htype, + 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), + (packet -> raw -> htype + ? 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, - lease ? "" : "not "); + : (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, + lease ? "" : "not "); /* If we found a lease, release it. */ if (lease && lease -> ends > cur_time) @@ -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 -> hlen, - packet -> raw -> chaddr), + (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,18 +978,25 @@ 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 (lease -> on_expiry) - executable_statement_dereference (&lease -> on_expiry, - "ack_lease"); - if (lease -> on_commit) - executable_statement_dereference (&lease -> on_commit, - "ack_lease"); - if (lease -> on_release) - executable_statement_dereference (&lease -> on_release, - "ack_lease"); + /* 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"); + if (lease -> on_commit) + executable_statement_dereference (&lease -> on_commit, + "ack_lease"); + 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,21 +1920,25 @@ 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 - ? print_hw_addr (lease -> hardware_addr.htype, - lease -> hardware_addr.hlen, - lease -> hardware_addr.haddr) - : print_hex_1 (lease -> uid_len, lease -> uid, - lease -> uid_len)), + s ? "(" : "", s ? s : "", s ? ") " : "", + (lease -> hardware_addr.htype + ? print_hw_addr (lease -> hardware_addr.htype, + lease -> hardware_addr.hlen, + lease -> hardware_addr.haddr) + : print_hex_1 (lease -> uid_len, lease -> uid, + lease -> uid_len)), state -> giaddr.s_addr ? inet_ntoa (state -> giaddr) : state -> ip -> name); diff --git a/server/dhcpd.conf.cat5 b/server/dhcpd.conf.cat5 index a5e639d7..f97bec6b 100644 --- a/server/dhcpd.conf.cat5 +++ b/server/dhcpd.conf.cat5 @@ -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 - words can be used to set up access lists for address allo - 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 @@ -916,21 +978,21 @@ 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 -dhcpd.conf(5) dhcpd.conf(5) +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;; @@ -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 + 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 @@ -1004,75 +1087,75 @@ dhcpd.conf(5) dhcpd.conf(5) mmaaxx--lleeaassee--ttiimmee _t_i_m_e;; - _T_i_m_e should be the maximum length in seconds that will be - assigned to a lease. The only exception to this is that - Dynamic BOOTP lease lengths, which are not specified by + _T_i_m_e should be the maximum length in seconds that will be + assigned to a lease. The only exception to this is that + Dynamic BOOTP lease lengths, which are not specified by the client, are not limited by this maximum. TThhee _m_i_n_-_l_e_a_s_e_-_t_i_m_e ssttaatteemmeenntt mmiinn--lleeaassee--ttiimmee _t_i_m_e;; - _T_i_m_e should be the minimum length in seconds that will be + _T_i_m_e should be the minimum length in seconds that will be assigned to a lease. TThhee _m_i_n_-_s_e_c_s ssttaatteemmeenntt mmiinn--sseeccss _s_e_c_o_n_d_s;; - _S_e_c_o_n_d_s should be the minimum number of seconds since a + _S_e_c_o_n_d_s should be the minimum number of seconds since a client began trying to acquire a new lease before the DHCP server will respond to its request. The number of seconds is based on what the client reports, and the maximum value - that the client can report is 255 seconds. Generally, - setting this to one will result in the DHCP server not - responding to the client's first request, but always + that the client can report is 255 seconds. Generally, + setting this to one will result in the DHCP server not + responding to the client's first request, but always responding to its second request. - This can be used to set up a secondary DHCP server which - never offers an address to a client until the primary - 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 - primary. Note that this does not, by itself, permit a - primary server and a secondary server to share a pool of - dynamically-allocatable addresses. + This can be used to set up a secondary DHCP server which + never offers an address to a client until the primary - TThhee _h_a_r_d_w_a_r_e ssttaatteemmeenntt - hhaarrddwwaarree _h_a_r_d_w_a_r_e_-_t_y_p_e _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s;; - In order for a BOOTP client to be recognized, its network - hardware address must be declared using a _h_a_r_d_w_a_r_e clause - in the _h_o_s_t statement. _h_a_r_d_w_a_r_e_-_t_y_p_e must be the name of - 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 + 17 - 16 +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 + primary. Note that this does not, by itself, permit a + primary server and a secondary server to share a pool of + dynamically-allocatable addresses. -dhcpd.conf(5) dhcpd.conf(5) + TThhee _h_a_r_d_w_a_r_e ssttaatteemmeenntt + hhaarrddwwaarree _h_a_r_d_w_a_r_e_-_t_y_p_e _h_a_r_d_w_a_r_e_-_a_d_d_r_e_s_s;; - 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 + In order for a BOOTP client to be recognized, its network + hardware address must be declared using a _h_a_r_d_w_a_r_e clause + in the _h_o_s_t statement. _h_a_r_d_w_a_r_e_-_t_y_p_e must be the name of + 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 + 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 DHCP clients. TThhee _f_i_l_e_n_a_m_e ssttaatteemmeenntt ffiilleennaammee ""_f_i_l_e_n_a_m_e"";; - The _f_i_l_e_n_a_m_e statement can be used to specify the name of - the initial boot file which is to be loaded by a client. + The _f_i_l_e_n_a_m_e statement can be used to specify the name of + the initial boot file which is to be loaded by a client. The _f_i_l_e_n_a_m_e should be a filename recognizable to whatever - file transfer protocol the client can be expected to use + file transfer protocol the client can be expected to use to load the file. TThhee _s_e_r_v_e_r_-_n_a_m_e ssttaatteemmeenntt @@ -1087,52 +1170,51 @@ dhcpd.conf(5) dhcpd.conf(5) nneexxtt--sseerrvveerr _s_e_r_v_e_r_-_n_a_m_e;; - The _n_e_x_t_-_s_e_r_v_e_r statement is used to specify the host - address of the server from which the initial boot file - (specified in the _f_i_l_e_n_a_m_e statement) is to be loaded. - _S_e_r_v_e_r_-_n_a_m_e should be a numeric IP address or a domain - name. If no _n_e_x_t_-_s_e_r_v_e_r parameter applies to a given + The _n_e_x_t_-_s_e_r_v_e_r statement is used to specify the host + address of the server from which the initial boot file + (specified in the _f_i_l_e_n_a_m_e statement) is to be loaded. + _S_e_r_v_e_r_-_n_a_m_e should be a numeric IP address or a domain + name. If no _n_e_x_t_-_s_e_r_v_e_r parameter applies to a given client, the DHCP server's IP address is used. TThhee _f_i_x_e_d_-_a_d_d_r_e_s_s ssttaatteemmeenntt ffiixxeedd--aaddddrreessss _a_d_d_r_e_s_s [,, _a_d_d_r_e_s_s ... ];; - 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, - then when the client boots, it will be assigned the - address which corresponds to the network on which it is - booting. If none of the addresses in the _f_i_x_e_d_-_a_d_d_r_e_s_s - statement are on the network on which the client is boot - ing, that client will not match the _h_o_s_t declaration con - taining that _f_i_x_e_d_-_a_d_d_r_e_s_s statement. Each _a_d_d_r_e_s_s should - be either an IP address or a domain name which resolves to - one or more IP addresses. - - TThhee _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f ssttaatteemmeenntt - ddyynnaammiicc--bboooottpp--lleeaassee--ccuuttooffff _d_a_t_e;; + 18 - 17 +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, + then when the client boots, it will be assigned the + address which corresponds to the network on which it is + booting. If none of the addresses in the _f_i_x_e_d_-_a_d_d_r_e_s_s + statement are on the network on which the client is boot + ing, that client will not match the _h_o_s_t declaration con + taining that _f_i_x_e_d_-_a_d_d_r_e_s_s statement. Each _a_d_d_r_e_s_s should + be either an IP address or a domain name which resolves to + one or more IP addresses. -dhcpd.conf(5) dhcpd.conf(5) + TThhee _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_c_u_t_o_f_f ssttaatteemmeenntt + ddyynnaammiicc--bboooottpp--lleeaassee--ccuuttooffff _d_a_t_e;; - 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 + 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 - leases, and don't know that their leases could expire, by + Because BOOTP clients do not have any way of renewing + leases, and don't know that their leases could expire, by default dhcpd assignes infinite leases to all BOOTP clients. However, it may make sense in some situations to - set a cutoff date for all BOOTP leases - for example, the + set a cutoff date for all BOOTP leases - for example, the end of a school term, or the time at night when a facility is closed and all machines are required to be powered off. @@ -1141,60 +1223,60 @@ dhcpd.conf(5) dhcpd.conf(5) W YYYY/MM/DD HH:MM:SS - W is the day of the week expressed as a number from zero - (Sunday) to six (Saturday). YYYY is the year, including + W is the day of the week expressed as a number from zero + (Sunday) to six (Saturday). YYYY is the year, including the century. MM is the month expressed as a number from 1 - to 12. DD is the day of the month, counting from 1. HH - is the hour, from zero to 23. MM is the minute and SS is - the second. The time is always in Greenwich Mean Time + to 12. DD is the day of the month, counting from 1. HH + is the hour, from zero to 23. MM is the minute and SS is + the second. The time is always in Greenwich Mean Time (GMT), not local time. TThhee _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h ssttaatteemmeenntt ddyynnaammiicc--bboooottpp--lleeaassee--lleennggtthh _l_e_n_g_t_h;; - The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h statement is used to set - the length of leases dynamically assigned to BOOTP - clients. At some sites, it may be possible to assume - that a lease is no longer in use if its holder has not - used BOOTP or DHCP to get its address within a certain + The _d_y_n_a_m_i_c_-_b_o_o_t_p_-_l_e_a_s_e_-_l_e_n_g_t_h statement is used to set + the length of leases dynamically assigned to BOOTP + clients. At some sites, it may be possible to assume + that a lease is no longer in use if its holder has not + used BOOTP or DHCP to get its address within a certain time period. The period is specified in _l_e_n_g_t_h as a num - ber of seconds. If a client reboots using BOOTP during + ber of seconds. If a client reboots using BOOTP during the timeout period, the lease duration is reset to _l_e_n_g_t_h, - so a BOOTP client that boots frequently enough will never + so a BOOTP client that boots frequently enough will never lose its lease. Needless to say, this parameter should be adjusted with extreme caution. - 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;; - The _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s statement is used to tell dhcpd - whether or not to look up the domain name corresponding to - the IP address of each address in the lease pool and use - that address for the DHCP _h_o_s_t_n_a_m_e option. If _f_l_a_g is - true, then this lookup is done for all addresses in the - current scope. By default, or if _f_l_a_g is false, no - lookups are done. + 19 - TThhee _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s ssttaatteemmeenntt - uussee--hhoosstt--ddeeccll--nnaammeess _f_l_a_g;; - 18 +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;; + The _g_e_t_-_l_e_a_s_e_-_h_o_s_t_n_a_m_e_s statement is used to tell dhcpd + whether or not to look up the domain name corresponding to + the IP address of each address in the lease pool and use + that address for the DHCP _h_o_s_t_n_a_m_e option. If _f_l_a_g is + true, then this lookup is done for all addresses in the + current scope. By default, or if _f_l_a_g is false, no + lookups are done. -dhcpd.conf(5) dhcpd.conf(5) + TThhee _u_s_e_-_h_o_s_t_-_d_e_c_l_-_n_a_m_e_s ssttaatteemmeenntt + uussee--hhoosstt--ddeeccll--nnaammeess _f_l_a_g;; - 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 + 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 plied to the client as its hostname. So, for example, group { @@ -1214,7 +1296,7 @@ dhcpd.conf(5) dhcpd.conf(5) option host-name "joe"; } - An _o_p_t_i_o_n _h_o_s_t_-_n_a_m_e statement within a host declaration + An _o_p_t_i_o_n _h_o_s_t_-_n_a_m_e statement within a host declaration will override the use of the name in the host declaration. TThhee _a_u_t_h_o_r_i_t_a_t_i_v_e ssttaatteemmeenntt @@ -1223,108 +1305,107 @@ dhcpd.conf(5) dhcpd.conf(5) nnoott aauutthhoorriittaattiivvee;; - The DHCP server will normally assume that the configura + The DHCP server will normally assume that the configura tion information about a given network segment is known to be correct and is authoritative. So if a client requests - an IP address on a given network segment that the server - knows is not valid for that segment, the server will + an IP address on a given network segment that the server + knows is not valid for that segment, the server will respond with a DHCPNAK message, causing the client to for get its IP address and try to get a new one. - 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 - "not authoritative" should be written in the appropriate - scope in the configuration file. - - Usually, writing nnoott aauutthhoorriittaattiivvee;; at the top level of - the file should be sufficient. However, if a DHCP server - is to be set up so that it is aware of some networks for - which it is authoritative and some networks for which it - is not, it may be more appropriate to declare authority on - a per-network-segment basis. - Note that the most specific scope for which the concept of - authority makes any sense is the physical network segment + 20 - 19 +dhcpd.conf(5) dhcpd.conf(5) -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 + "not authoritative" should be written in the appropriate + scope in the configuration file. + Usually, writing nnoott aauutthhoorriittaattiivvee;; at the top level of + the file should be sufficient. However, if a DHCP server + is to be set up so that it is aware of some networks for + which it is authoritative and some networks for which it + is not, it may be more appropriate to declare authority on + a per-network-segment basis. - - either a shared-network statement or a subnet statement - that is not contained within a shared-network statement. + Note that the most specific scope for which the concept of + authority makes any sense is the physical network segment + - 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 - itative for some subnets within a shared network, but not - authoritative for others, nor is it meaningful to specify - that the server is authoritative for some host declara + itative for some subnets within a shared network, but not + authoritative for others, nor is it meaningful to specify + that the server is authoritative for some host declara tions and not others. TThhee _a_l_w_a_y_s_-_r_e_p_l_y_-_r_f_c_1_0_4_8 ssttaatteemmeenntt aallwwaayyss--rreeppllyy--rrffcc11004488 _f_l_a_g;; - Some BOOTP clients expect RFC1048-style responses, but do - not follow RFC1048 when sending their requests. You can - tell that a client is having this problem if it is not - getting the options you have configured for it and if you - see in the server log the message "(non-rfc1048)" printed + Some BOOTP clients expect RFC1048-style responses, but do + not follow RFC1048 when sending their requests. You can + tell that a client is having this problem if it is not + getting the options you have configured for it and if you + see in the server log the message "(non-rfc1048)" printed with each BOOTREQUEST that is logged. - If you want to send rfc1048 options to such a client, you - can set the aallwwaayyss--rreeppllyy--rrffcc11004488 option in that client's + If you want to send rfc1048 options to such a client, you + can set the aallwwaayyss--rreeppllyy--rrffcc11004488 option in that client's host declaration, and the DHCP server will respond with an - RFC-1048-style vendor options field. This flag can be - set in any scope, and will affect all clients covered by + RFC-1048-style vendor options field. This flag can be + set in any scope, and will affect all clients covered by that scope. TThhee _a_l_w_a_y_s_-_b_r_o_a_d_c_a_s_t ssttaatteemmeenntt aallwwaayyss--bbrrooaaddccaasstt _f_l_a_g;; - The DHCP and BOOTP protocols both require DHCP and BOOTP + The DHCP and BOOTP protocols both require DHCP and BOOTP clients to set the broadcast bit in the flags field of the - BOOTP message header. Unfortunately, some DHCP and BOOTP - clients do not do this, and therefore may not receive - responses from the DHCP server. The DHCP server can be - made to always broadcast its responses to clients by set - ting this flag to 'on' for the relevant scope. To avoid + BOOTP message header. Unfortunately, some DHCP and BOOTP + clients do not do this, and therefore may not receive + responses from the DHCP server. The DHCP server can be + made to always broadcast its responses to clients by set + ting this flag to 'on' for the relevant scope. To avoid creating excess broadcast traffic on your network, we rec - ommend that you restrict the use of this option to as few - clients as possible. For example, the Microsoft DHCP - client is known not to have this problem, as are the Open - Transport and ISC DHCP clients. + ommend that you restrict the use of this option to as few - TThhee _o_n_e_-_l_e_a_s_e_-_p_e_r_-_c_l_i_e_n_t ssttaatteemmeenntt - oonnee--lleeaassee--ppeerr--cclliieenntt _f_l_a_g;; - If this flag is enabled, whenever a client sends a DHCPRE - QUEST for a particular lease, the server will automati - cally free any other leases the client holds. This pre - sumes that when the client sends a DHCPREQUEST, it has - 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 + 21 - 20 +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 + Transport and ISC DHCP clients. -dhcpd.conf(5) dhcpd.conf(5) + TThhee _o_n_e_-_l_e_a_s_e_-_p_e_r_-_c_l_i_e_n_t ssttaatteemmeenntt + oonnee--lleeaassee--ppeerr--cclliieenntt _f_l_a_g;; - which it is not currently attached. Neither of these + If this flag is enabled, whenever a client sends a DHCPRE + QUEST for a particular lease, the server will automati + cally free any other leases the client holds. This pre + sumes that when the client sends a DHCPREQUEST, it has + 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 + which it is not currently attached. Neither of these assumptions are guaranteed or provable, so we urge caution in the use of this statement. @@ -1332,73 +1413,73 @@ dhcpd.conf(5) dhcpd.conf(5) uussee--lleeaassee--aaddddrr--ffoorr--ddeeffaauulltt--rroouuttee _f_l_a_g;; - If the _u_s_e_-_l_e_a_s_e_-_a_d_d_r_-_f_o_r_-_d_e_f_a_u_l_t_-_r_o_u_t_e parameter is true + If the _u_s_e_-_l_e_a_s_e_-_a_d_d_r_-_f_o_r_-_d_e_f_a_u_l_t_-_r_o_u_t_e parameter is true in a given scope, then instead of sending the value speci - fied in the routers option (or sending no value at all), - the IP address of the lease being assigned is sent to the + fied in the routers option (or sending no value at all), + the IP address of the lease being assigned is sent to the client. This supposedly causes Win95 machines to ARP for - all IP addresses, which can be helpful if your router is + all IP addresses, which can be helpful if your router is configured for proxy ARP. TThhee _s_e_r_v_e_r_-_i_d_e_n_t_i_f_i_e_r ssttaatteemmeenntt sseerrvveerr--iiddeennttiiffiieerr _h_o_s_t_n_a_m_e;; - The server-identifier statement can be used to define the - value that is sent in the DHCP Server Identifier option - for a given scope. The value specified mmuusstt be an IP - address for the DHCP server, and must be reachable by all + The server-identifier statement can be used to define the + value that is sent in the DHCP Server Identifier option + for a given scope. The value specified mmuusstt be an IP + address for the DHCP server, and must be reachable by all clients served by a particular scope. - The use of the server-identifier statement is not recom - mended - the only reason to use it is to force a value + The use of the server-identifier statement is not recom + mended - the only reason to use it is to force a value other than the default value to be sent on occasions where - the default value would be incorrect. The default value - is the first IP address associated with the physical net + the default value would be incorrect. The default value + is the first IP address associated with the physical net work interface on which the request arrived. The usual case where the _s_e_r_v_e_r_-_i_d_e_n_t_i_f_i_e_r statement needs - to be sent is when a physical interface has more than one + to be sent is when a physical interface has more than one IP address, and the one being sent by default isn't appro - 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 - server, and it is desired that the clients use this IP - address when contacting the server. + 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 - Supplying a value for the dhcp-server-identifier option is - equivalent to using the server-identifier statement. -RREEFFEERREENNCCEE:: OOPPTTIIOONN SSTTAATTEEMMEENNTTSS - DHCP option statements are documented in the ddhhccpp-- - ooppttiioonnss((55)) manual page. -VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD OOPPTTIIOONNSS - The DHCP protocol defines the 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 + 22 - 21 +dhcpd.conf(5) dhcpd.conf(5) + server, and it is desired that the clients use this IP + address when contacting the server. -dhcpd.conf(5) dhcpd.conf(5) + Supplying a value for the dhcp-server-identifier option is + equivalent to using the server-identifier statement. +RREEFFEERREENNCCEE:: OOPPTTIIOONN SSTTAATTEEMMEENNTTSS + DHCP option statements are documented in the ddhhccpp-- + ooppttiioonnss((55)) manual page. - either a hunk of opaque data, or an actual option buffer +VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD OOPPTTIIOONNSS + The DHCP protocol defines the 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 + either a hunk of opaque data, or an actual option buffer just like a standard DHCP option buffer. - You can send this option to clients in one of two ways - - either define the data directly, using a text string or a - colon-seperated list of hexadecimal values, or define an - option space, define some options in that option space, - provide values for them, and specify that that option - space should be used to generate the vveennddoorr--eennccaappssuullaatteedd-- + You can send this option to clients in one of two ways - + either define the data directly, using a text string or a + colon-seperated list of hexadecimal values, or define an + option space, define some options in that option space, + provide values for them, and specify that that option + space should be used to generate the vveennddoorr--eennccaappssuullaatteedd-- ooppttiioonnss option in some scope. To send a simple clump of data, simply provide a value for @@ -1409,13 +1490,13 @@ dhcpd.conf(5) dhcpd.conf(5) 3:12:73:75:6e:64:68:63:70:2d:73:65:72:76:65:72:31:37:2d:31: 4:12:2f:65:78:70:6f:72:74:2f:72:6f:6f:74:2f:69:38:36:70:63; - To define a new option space in which vendor options can + To define a new option space in which vendor options can be stored, use the option space statement: ooppttiioonn ssppaaccee _n_a_m_e ;; - The name can then be used in option definitions, as - described in the ddhhccpp--ooppttiioonnss((55)) manual page. For exam + The name can then be used in option definitions, as + described in the ddhhccpp--ooppttiioonnss((55)) manual page. For exam ple: option space SUNW; @@ -1423,51 +1504,52 @@ dhcpd.conf(5) dhcpd.conf(5) option SUNW.server-name code 3 = text; option SUNW.root-path code 4 = text; - Once you have defined an option space and some options, - 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 - lated-options definition shown earlier can be done as fol - lows: + Once you have defined an option space and some options, + 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 VVEENNDDOORR EENNCCAAPPSSUULLAATTEEDD + OOPPTTIIOONNSS section. Using the option space definition shown - class "vendor-classes" { - match option vendor-class-identifier; - } - option SUNW.server-address 172.17.65.1; - option SUNW.server-name "sundhcp-server17-1"; - subclass "vendor-classes" "SUNW.Ultra-5_10" { - vendor-option-space SUNW; - option SUNW.root-path "/export/root/sparc"; - } + 23 - 22 +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: -dhcpd.conf(5) dhcpd.conf(5) + class "vendor-classes" { + match option vendor-class-identifier; + } + + option SUNW.server-address 172.17.65.1; + option SUNW.server-name "sundhcp-server17-1"; + subclass "vendor-classes" "SUNW.Ultra-5_10" { + vendor-option-space SUNW; + option SUNW.root-path "/export/root/sparc"; + } subclass "vendor-classes" "SUNW.i86pc" { vendor-option-space SUNW; option SUNW.root-path "/export/root/i86pc"; } - As you can see in the preceding example, regular scoping - rules apply, so you can define values that are global in + As you can see in the preceding example, regular scoping + rules apply, so you can define values that are global in the global scope, and only define values that are specific - to a particular class in the local scope. The vveennddoorr-- + to a particular class in the local scope. The vveennddoorr-- ooppttiioonn--ssppaaccee declaration indicates that in that scope, the - vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option should be constructed - using the values of all the options in the SUNW option + vveennddoorr--eennccaappssuullaatteedd--ooppttiioonnss option should be constructed + using the values of all the options in the SUNW option space. SSEEEE AALLSSOO @@ -1475,9 +1557,9 @@ SSEEEE AALLSSOO AAUUTTHHOORR ddhhccppdd((88)) was written by Ted Lemon <mellon@vix.com> under a - contract with Vixie Labs. Funding for this project was + contract with Vixie Labs. Funding for this project was provided by the Internet Software Consortium. Information - about the Internet Software Consortium can be found at + about the Internet Software Consortium can be found at hhttttpp::////wwwwww..iisscc..oorrgg//iisscc.. @@ -1497,22 +1579,6 @@ AAUUTTHHOORR - - - - - - - - - - - - - - - - - 23 + 24 diff --git a/server/failover.c b/server/failover.c index 4c221979..1da507b2 100644 --- a/server/failover.c +++ b/server/failover.c @@ -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; - - status = omapi_get_int_value (&port, value); - omapi_typed_data_dereference (&value, "dhcp_failover_link_initiate"); + if (!value -> value) { + omapi_value_dereference (&value, + "dhcp_failover_link_initiate"); + return ISC_R_INVALIDARG; + } + + 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, - "dhcp_failover_link_initiate"); + 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, - "dhcp_failover_link_initiate"); + 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, diff --git a/server/mdb.c b/server/mdb.c index d3712684..2f992ce0 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -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]; @@ -948,9 +948,9 @@ int supersede_lease (comp, lease, commit) break; if (lp && lp -> on_expiry) { comp -> pool -> next_expiry = lp; - if (commit) - add_timeout (lp -> ends, - pool_timer, lp -> pool); + if (commit) + add_timeout (lp -> ends, + pool_timer, lp -> pool); } else { comp -> pool -> next_expiry = (struct lease *)0; if (commit) @@ -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 diff --git a/server/omapi.c b/server/omapi.c index b17e77ec..2c710f9a 100644 --- a/server/omapi.c +++ b/server/omapi.c @@ -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 () { diff --git a/server/stables.c b/server/stables.c index 0d48c52d..37dd69ec 100644 --- a/server/stables.c +++ b/server/stables.c @@ -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; |