Commit 31bbee78 authored by Ted Lemon's avatar Ted Lemon

Sync with 3.0rc7

parent cb7cfe5c
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: conflex.c,v 1.92 2001/05/02 06:32:54 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: conflex.c,v 1.93 2001/05/17 19:03:43 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
...@@ -926,6 +926,8 @@ static enum dhcp_token intern (atom, dfv) ...@@ -926,6 +926,8 @@ static enum dhcp_token intern (atom, dfv)
return TOKEN_RESET; return TOKEN_RESET;
if (!strcasecmp (atom + 1, "eserved")) if (!strcasecmp (atom + 1, "eserved"))
return TOKEN_RESERVED; return TOKEN_RESERVED;
if (!strcasecmp (atom + 1, "emove"))
return REMOVE;
break; break;
case 's': case 's':
if (!strcasecmp (atom + 1, "tate")) if (!strcasecmp (atom + 1, "tate"))
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: discover.c,v 1.42 2001/05/02 06:36:54 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n"; "$Id: discover.c,v 1.43 2001/05/17 19:03:44 mellon Exp $ Copyright (c) 1995-2001 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
...@@ -184,6 +184,15 @@ void discover_interfaces (state) ...@@ -184,6 +184,15 @@ void discover_interfaces (state)
if (i < 0) if (i < 0)
log_fatal ("ioctl: SIOCGIFCONF: %m"); log_fatal ("ioctl: SIOCGIFCONF: %m");
#ifdef SIOCGIFCONF_ZERO_PROBE
/* Workaround for SIOCGIFCONF bug on some Linux versions. */
if (ic.ifc_ifcu.ifcu_buf == 0 && ic.ifc_len == 0) {
ic.ifc_len = sizeof buf;
ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
goto gifconf_again;
}
#endif
/* If the SIOCGIFCONF resulted in more data than would fit in /* If the SIOCGIFCONF resulted in more data than would fit in
a buffer, allocate a bigger buffer. */ a buffer, allocate a bigger buffer. */
if ((ic.ifc_ifcu.ifcu_buf == buf if ((ic.ifc_ifcu.ifcu_buf == buf
...@@ -198,7 +207,7 @@ void discover_interfaces (state) ...@@ -198,7 +207,7 @@ void discover_interfaces (state)
#ifdef SIOCGIFCONF_ZERO_PROBE #ifdef SIOCGIFCONF_ZERO_PROBE
} else if (ic.ifc_ifcu.ifcu_buf == 0) { } else if (ic.ifc_ifcu.ifcu_buf == 0) {
ic.ifc_ifcu.ifcu_buf = (caddr_t)buf; ic.ifc_ifcu.ifcu_buf = (caddr_t)buf;
if.ifc_len = sizeof buf; ic.ifc_len = sizeof buf;
goto gifconf_again; goto gifconf_again;
#endif #endif
} }
......
...@@ -321,6 +321,43 @@ dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle h, const char *value, ...@@ -321,6 +321,43 @@ dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle h, const char *value,
return status; return status;
} }
/* dhcpctl_set_buffer_value
Sets a NUL-terminated ASCII value on an object referred to by
a dhcpctl_handle. like dhcpctl_set_value, but saves the
trouble of creating a data_string for a NUL-terminated string.
Does not update the server - just sets the value on the handle. */
dhcpctl_status dhcpctl_set_data_value (dhcpctl_handle h,
const char *value, unsigned len,
const char *value_name)
{
isc_result_t status;
omapi_typed_data_t *tv = (omapi_typed_data_t *)0;
omapi_data_string_t *name = (omapi_data_string_t *)0;
int ip;
unsigned ll;
ll = strlen (value_name);
status = omapi_data_string_new (&name, ll, MDL);
if (status != ISC_R_SUCCESS)
return status;
memcpy (name -> value, value_name, ll);
status = omapi_typed_data_new (MDL, &tv,
omapi_datatype_data, len, value);
if (status != ISC_R_SUCCESS) {
omapi_data_string_dereference (&name, MDL);
return status;
}
memcpy (tv -> u.buffer.value, value, len);
status = omapi_set_value (h, (omapi_object_t *)0, name, tv);
omapi_data_string_dereference (&name, MDL);
omapi_typed_data_dereference (&tv, MDL);
return status;
}
/* dhcpctl_set_boolean_value /* dhcpctl_set_boolean_value
Sets a boolean value on an object - like dhcpctl_set_value, Sets a boolean value on an object - like dhcpctl_set_value,
......
...@@ -85,6 +85,8 @@ dhcpctl_status dhcpctl_set_value (dhcpctl_handle, ...@@ -85,6 +85,8 @@ dhcpctl_status dhcpctl_set_value (dhcpctl_handle,
dhcpctl_data_string, const char *); dhcpctl_data_string, const char *);
dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle, const char *, dhcpctl_status dhcpctl_set_string_value (dhcpctl_handle, const char *,
const char *); const char *);
dhcpctl_status dhcpctl_set_data_value (dhcpctl_handle,
const char *, unsigned, const char *);
dhcpctl_status dhcpctl_set_boolean_value (dhcpctl_handle, int, const char *); dhcpctl_status dhcpctl_set_boolean_value (dhcpctl_handle, int, const char *);
dhcpctl_status dhcpctl_set_int_value (dhcpctl_handle, int, const char *); dhcpctl_status dhcpctl_set_int_value (dhcpctl_handle, int, const char *);
dhcpctl_status dhcpctl_object_update (dhcpctl_handle, dhcpctl_handle); dhcpctl_status dhcpctl_object_update (dhcpctl_handle, dhcpctl_handle);
......
...@@ -107,6 +107,13 @@ int main (int argc, char **argv, char **envp) ...@@ -107,6 +107,13 @@ int main (int argc, char **argv, char **envp)
usage(argv[0]); usage(argv[0]);
} }
/* Initially, log errors to stderr as well as to syslogd. */
#ifdef SYSLOG_4_2
openlog ("dhcpd", LOG_NDELAY);
log_priority = DHCPD_LOG_FACILITY;
#else
openlog ("dhcpd", LOG_NDELAY, DHCPD_LOG_FACILITY);
#endif
status = dhcpctl_initialize (); status = dhcpctl_initialize ();
if (status != ISC_R_SUCCESS) { if (status != ISC_R_SUCCESS) {
fprintf (stderr, "dhcpctl_initialize: %s\n", fprintf (stderr, "dhcpctl_initialize: %s\n",
...@@ -208,7 +215,7 @@ int main (int argc, char **argv, char **envp) ...@@ -208,7 +215,7 @@ int main (int argc, char **argv, char **envp)
if (se) if (se)
port = ntohs (se -> s_port); port = ntohs (se -> s_port);
else { else {
printf ("unknown service name: %s", val); printf ("unknown service name: %s\n", val);
break; break;
} }
} else if (token == NUMBER) { } else if (token == NUMBER) {
...@@ -287,7 +294,7 @@ int main (int argc, char **argv, char **envp) ...@@ -287,7 +294,7 @@ int main (int argc, char **argv, char **envp)
s = dmalloc (strlen (val) + 1, MDL); s = dmalloc (strlen (val) + 1, MDL);
if (!server) { if (!server) {
printf ("no memory to store server name."); printf ("no memory to store server name.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
...@@ -305,13 +312,13 @@ int main (int argc, char **argv, char **envp) ...@@ -305,13 +312,13 @@ int main (int argc, char **argv, char **envp)
case KEY: case KEY:
token = next_token (&val, (unsigned *)0, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (!is_identifier (token)) { if (!is_identifier (token)) {
printf ("usage: key <name> <value>"); printf ("usage: key <name> <value>\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
s = dmalloc (strlen (val) + 1, MDL); s = dmalloc (strlen (val) + 1, MDL);
if (!s) { if (!s) {
printf ("no memory for key name."); printf ("no memory for key name.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
...@@ -379,7 +386,7 @@ int main (int argc, char **argv, char **envp) ...@@ -379,7 +386,7 @@ int main (int argc, char **argv, char **envp)
} }
if (!connected) { if (!connected) {
printf ("not connected."); printf ("not connected.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
...@@ -408,7 +415,7 @@ int main (int argc, char **argv, char **envp) ...@@ -408,7 +415,7 @@ int main (int argc, char **argv, char **envp)
} }
if (!connected) { if (!connected) {
printf ("not connected."); printf ("not connected.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
...@@ -434,7 +441,7 @@ int main (int argc, char **argv, char **envp) ...@@ -434,7 +441,7 @@ int main (int argc, char **argv, char **envp)
} }
if (!connected) { if (!connected) {
printf ("not connected."); printf ("not connected.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
...@@ -450,23 +457,77 @@ int main (int argc, char **argv, char **envp) ...@@ -450,23 +457,77 @@ int main (int argc, char **argv, char **envp)
switch (token) { switch (token) {
case STRING: case STRING:
dhcpctl_set_string_value (oh, val, s1); dhcpctl_set_string_value (oh, val, s1);
token = next_token (&val, (unsigned *)0, cfile);
break; break;
case NUMBER: case NUMBER:
dhcpctl_set_int_value (oh, atoi (val), s1); strcpy (buf, val);
token = peek_token (&val, (unsigned *)0, cfile);
/* Colon-seperated hex list? */
if (token == COLON)
goto cshl;
else if (token == DOT) {
s = buf;
val = buf;
do {
int intval = atoi (val);
if (intval > 255) {
parse_warn (cfile,
"dotted octet > 255: %s",
val);
skip_to_semi (cfile);
goto badnum;
}
*s++ = intval;
token = next_token (&val,
(unsigned *)0, cfile);
if (token != DOT)
break;
token = next_token (&val,
(unsigned *)0, cfile);
} while (token == NUMBER);
dhcpctl_set_data_value (oh, buf,
(unsigned)(s - buf),
s1);
break;
}
dhcpctl_set_int_value (oh, atoi (buf), s1);
token = next_token (&val, (unsigned *)0, cfile);
badnum:
break; break;
case NUMBER_OR_NAME:
strcpy (buf, val);
cshl:
s = buf;
val = buf;
do {
convert_num (cfile, s, val, 16, 8);
++s;
token = next_token (&val,
(unsigned *)0, cfile);
if (token != COLON)
break;
token = next_token (&val,
(unsigned *)0, cfile);
} while (token == NUMBER ||
token == NUMBER_OR_NAME);
dhcpctl_set_data_value (oh, buf,
(unsigned)(s - buf), s1);
break;
default: default:
printf ("invalid value.\n"); printf ("invalid value.\n");
skip_to_semi (cfile);
} }
token = next_token (&val, (unsigned *)0, cfile);
if (token != END_OF_FILE && token != EOL) if (token != END_OF_FILE && token != EOL)
goto set_usage; goto set_usage;
break; break;
case TOKEN_CREATE: case TOKEN_CREATE:
case TOKEN_OPEN: case TOKEN_OPEN:
i = token;
token = next_token (&val, (unsigned *)0, cfile); token = next_token (&val, (unsigned *)0, cfile);
if (token != END_OF_FILE && token != EOL) { if (token != END_OF_FILE && token != EOL) {
printf ("usage: %s\n", val); printf ("usage: %s\n", val);
...@@ -475,14 +536,21 @@ int main (int argc, char **argv, char **envp) ...@@ -475,14 +536,21 @@ int main (int argc, char **argv, char **envp)
} }
if (!connected) { if (!connected) {
printf ("not connected."); printf ("not connected.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
i = 0; if (!oh) {
if (token == TOKEN_CREATE) printf ("you must make a new object first!\n");
skip_to_semi (cfile);
break;
}
if (i == TOKEN_CREATE)
i = DHCPCTL_CREATE | DHCPCTL_EXCL; i = DHCPCTL_CREATE | DHCPCTL_EXCL;
else
i = 0;
status = dhcpctl_open_object (oh, connection, i); status = dhcpctl_open_object (oh, connection, i);
if (status == ISC_R_SUCCESS) if (status == ISC_R_SUCCESS)
...@@ -507,7 +575,7 @@ int main (int argc, char **argv, char **envp) ...@@ -507,7 +575,7 @@ int main (int argc, char **argv, char **envp)
} }
if (!connected) { if (!connected) {
printf ("not connected."); printf ("not connected.\n");
skip_to_semi (cfile); skip_to_semi (cfile);
break; break;
} }
...@@ -524,9 +592,37 @@ int main (int argc, char **argv, char **envp) ...@@ -524,9 +592,37 @@ int main (int argc, char **argv, char **envp)
break; break;
} }
break;
case REMOVE:
token = next_token (&val, (unsigned *)0, cfile);
if (token != END_OF_FILE && token != EOL) {
printf ("usage: %s\n", val);
skip_to_semi (cfile);
break;
}
if (!connected) {
printf ("not connected.\n");
skip_to_semi (cfile);
break;
}
status = dhcpctl_object_remove(connection, oh);
if (status == ISC_R_SUCCESS)
status = dhcpctl_wait_for_completion
(oh, &waitstatus);
if (status == ISC_R_SUCCESS)
status = waitstatus;
if (status != ISC_R_SUCCESS) {
printf ("can't destroy object: %s\n",
isc_result_totext (status));
break;
}
break; break;
} }
} while (token != END_OF_FILE); } while (1);
exit (0); exit (0);
} }
...@@ -125,7 +125,7 @@ extern int h_errno; ...@@ -125,7 +125,7 @@ extern int h_errno;
# define USE_LPF # define USE_LPF
# endif # endif
# if !defined (__sparc__) /* XXX hopefully this will be fixed someday */ # if !defined (__sparc__) /* XXX hopefully this will be fixed someday */
# define SIOCGIFCONF_NULL_BUF_GIVES_CORRECT_LEN # define SIOCGIFCONF_ZERO_PROBE
# endif # endif
# define LINUX_SLASHPROC_DISCOVERY # define LINUX_SLASHPROC_DISCOVERY
# define PROCDEV_DEVICE "/proc/net/dev" # define PROCDEV_DEVICE "/proc/net/dev"
......
...@@ -2475,11 +2475,12 @@ void update_partner PROTO ((struct lease *)); ...@@ -2475,11 +2475,12 @@ void update_partner PROTO ((struct lease *));
int load_balance_mine (struct packet *, dhcp_failover_state_t *); int load_balance_mine (struct packet *, dhcp_failover_state_t *);
binding_state_t normal_binding_state_transition_check (struct lease *, binding_state_t normal_binding_state_transition_check (struct lease *,
dhcp_failover_state_t *, dhcp_failover_state_t *,
binding_state_t); binding_state_t,
u_int32_t);
binding_state_t binding_state_t
conflict_binding_state_transition_check (struct lease *, conflict_binding_state_transition_check (struct lease *,
dhcp_failover_state_t *, dhcp_failover_state_t *,
binding_state_t); binding_state_t, u_int32_t);
int lease_mine_to_reallocate (struct lease *); int lease_mine_to_reallocate (struct lease *);
OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t, OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t,
......
...@@ -312,7 +312,8 @@ enum dhcp_token { ...@@ -312,7 +312,8 @@ enum dhcp_token {
END_OF_FILE = 607, END_OF_FILE = 607,
RECOVER_WAIT = 608, RECOVER_WAIT = 608,
SERVER = 609, SERVER = 609,
CONNECT = 610 CONNECT = 610,
REMOVE = 611
}; };
#define is_identifier(x) ((x) >= FIRST_TOKEN && \ #define is_identifier(x) ((x) >= FIRST_TOKEN && \
......
/* Current version of ISC DHCP Distribution. */ /* Current version of ISC DHCP Distribution. */
#define DHCP_VERSION "V3.0rc4" #define DHCP_VERSION "V3.1-unreleased"
...@@ -293,35 +293,34 @@ void dmalloc_dump_outstanding () ...@@ -293,35 +293,34 @@ void dmalloc_dump_outstanding ()
somewhere. */ somewhere. */
if (dp -> file) { if (dp -> file) {
#if defined (DEBUG_RC_HISTORY) #if defined (DEBUG_RC_HISTORY)
int i, count, inhistory = 0, noted = 0;
/* If we have the info, see if this is actually /* If we have the info, see if this is actually
new garbage. */ new garbage. */
if (rc_history_count < RC_HISTORY_MAX) { if (rc_history_count < RC_HISTORY_MAX) {
int i, printit = 0, inhistory = 0, prefcnt = 0; count = rc_history_count;
i = rc_history_index - rc_history_count;
if (i < 0)
i += RC_HISTORY_MAX;
do {
if (rc_history [i].addr == dp + 1) {
if (rc_history [i].refcnt == 1 &&
prefcnt == 0 && !printit) {
printit = 1;
inhistory = 1;
log_info (" %s(%d): %d",
dp -> file,
dp -> line,
dp -> size);
}
prefcnt = rc_history [i].refcnt;
if (printit)
print_rc_hist_entry (i);
}
if (++i == RC_HISTORY_MAX)
i = 0;
} while (i != rc_history_index);
if (!inhistory)
log_info (" %s(%d): %d", dp -> file,
dp -> line, dp -> size);
} else } else
count = RC_HISTORY_MAX;
i = rc_history_index - 1;
if (i < 0)
i += RC_HISTORY_MAX;
do {
if (rc_history [i].addr == dp + 1) {
inhistory = 1;
if (!noted) {
log_info (" %s(%d): %d", dp -> file,
dp -> line, dp -> size);
noted = 1;
}
print_rc_hist_entry (i);
if (!rc_history [i].refcnt)
break;
}
if (--i < 0)
i = RC_HISTORY_MAX - 1;
} while (count--);
if (!inhistory)
#endif #endif
log_info (" %s(%d): %d", log_info (" %s(%d): %d",
dp -> file, dp -> line, dp -> size); dp -> file, dp -> line, dp -> size);
...@@ -516,16 +515,20 @@ isc_result_t omapi_object_dereference (omapi_object_t **h, ...@@ -516,16 +515,20 @@ isc_result_t omapi_object_dereference (omapi_object_t **h,
extra_references = 0; extra_references = 0;
for (p = (*h) -> inner; for (p = (*h) -> inner;
p && !extra_references; p = p -> inner) { p && !extra_references; p = p -> inner) {
extra_references += p -> refcnt - 1; extra_references += p -> refcnt;
if (p -> inner) if (p -> inner && p -> inner -> outer == p)
--extra_references;
if (p -> outer)
--extra_references; --extra_references;
if (p -> handle) if (p -> handle)
--extra_references; --extra_references;
} }
for (p = (*h) -> outer; for (p = (*h) -> outer;
p && !extra_references; p = p -> outer) { p && !extra_references; p = p -> outer) {
extra_references += p -> refcnt - 1; extra_references += p -> refcnt;
if (p -> outer) if (p -> outer && p -> outer -> inner == p)
--extra_references;
if (p -> inner)
--extra_references; --extra_references;
if (p -> handle) if (p -> handle)
--extra_references; --extra_references;
...@@ -549,6 +552,11 @@ isc_result_t omapi_object_dereference (omapi_object_t **h, ...@@ -549,6 +552,11 @@ isc_result_t omapi_object_dereference (omapi_object_t **h,
((*h) -> type -> freer (*h, file, line)); ((*h) -> type -> freer (*h, file, line));
else else
dfree (*h, file, line); dfree (*h, file, line);
} else {
(*h) -> refcnt--;
if (!(*h) -> type -> freer)
rc_register (file, line,
h, *h, (*h) -> refcnt);
} }
} else { } else {
(*h) -> refcnt--; (*h) -> refcnt--;
......
...@@ -273,6 +273,7 @@ void omapi_connection_register (omapi_connection_object_t *obj, ...@@ -273,6 +273,7 @@ void omapi_connection_register (omapi_connection_object_t *obj,
return; return;
} }
#if defined (TRACING)