#ifndef lint
static char copyright[] =
-"$Id: clparse.c,v 1.21 1998/11/11 07:48:23 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: clparse.c,v 1.22 1999/02/24 17:56:42 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
top_level_config.on_receipt = new_group ("read_client_conf");
if (!top_level_config.on_receipt)
- error ("no memory for top-level on_receipt group");
+ log_fatal ("no memory for top-level on_receipt group");
top_level_config.on_transmission = new_group ("read_client_conf");
if (!top_level_config.on_transmission)
- error ("no memory for top-level on_transmission group");
+ log_fatal ("no memory for top-level on_transmission group");
if ((cfile = fopen (path_dhclient_conf, "r")) != NULL) {
do {
ip -> client = (struct client_state *)
malloc (sizeof (struct client_state));
if (!ip -> client)
- error ("no memory for client state.");
+ log_fatal ("no memory for client state.");
memset (ip -> client, 0, sizeof *(ip -> client));
}
config = (struct client_config *)
malloc (sizeof (struct client_config));
if (!config)
- error ("no memory for client config.");
+ log_fatal ("no memory for client config.");
memcpy (config, &top_level_config,
sizeof top_level_config);
}
if (token == EOF)
break;
if (token != LEASE) {
- warn ("Corrupt lease file - possible data loss!");
+ log_error ("Corrupt lease file - possible data loss!");
skip_to_semi (cfile);
break;
} else
token = next_token (&val, cfile);
name = dmalloc (strlen (val) + 1, "parse_client_statement");
if (!name)
- error ("no memory for pseudo interface name");
+ log_fatal ("no memory for pseudo interface name");
strcpy (name, val);
parse_interface_declaration (cfile, config, name);
return;
}
r = new_pair ("parse_option_list");
if (!r)
- error ("can't allocate pair for option code.");
+ log_fatal ("can't allocate pair for option code.");
r -> car = (caddr_t)i;
r -> cdr = (pair)0;
if (p)
dfree (*list, "parse_option_list");
*list = dmalloc (ix * sizeof **list, "parse_option_list");
if (!*list)
- warn ("no memory for option list.");
+ log_error ("no memory for option list.");
else {
ix = 0;
for (q = p; q; q = q -> cdr)
if (!ip) {
ip = ((struct interface_info *)malloc (sizeof *ip));
if (!ip)
- error ("Insufficient memory to record interface %s",
+ log_fatal ("Insufficient memory to record interface %s",
name);
memset (ip, 0, sizeof *ip);
strcpy (ip -> name, name);
*state = ((struct client_state *)dmalloc (sizeof **state,
"make_client_state"));
if (!*state)
- error ("no memory for client state\n");
+ log_fatal ("no memory for client state\n");
memset (*state, 0, sizeof **state);
}
dmalloc (sizeof (struct client_config),
"make_client_config")));
if (!client -> config)
- error ("no memory for client config\n");
+ log_fatal ("no memory for client config\n");
memcpy (client -> config, config, sizeof *config);
client -> config -> on_receipt =
clone_group (config -> on_receipt, "make_client_config");
lease = (struct client_lease *)malloc (sizeof (struct client_lease));
if (!lease)
- error ("no memory for lease.\n");
+ log_fatal ("no memory for lease.\n");
memset (lease, 0, sizeof *lease);
lease -> is_static = is_static;
goto alloc;
default:
- warn ("Bad format %c in parse_option_param.",
+ log_error ("Bad format %c in parse_option_param.",
*fmt);
skip_to_semi (cfile);
return 0;
bp = (struct buffer *)0;
if (!buffer_allocate (&bp, hunkix + nul_term, "parse_option_decl"))
- error ("no memory to store option declaration.");
+ log_fatal ("no memory to store option declaration.");
if (!bp -> data)
- error ("out of memory allocating option data.");
+ log_fatal ("out of memory allocating option data.");
memcpy (bp -> data, hunkbuf, hunkix + nul_term);
if (!option_cache_allocate (oc, "parse_option_decl"))
- error ("out of memory allocating option cache.");
+ log_fatal ("out of memory allocating option cache.");
(*oc) -> data.buffer = bp;
(*oc) -> data.data = &bp -> data [0];
sizeof
(struct string_list *));
if (!tmp)
- error ("no memory for string list entry.");
+ log_fatal ("no memory for string list entry.");
strcpy (tmp -> string, val);
tmp -> next = (struct string_list *)0;
list = (struct iaddrlist *)malloc (sizeof (struct iaddrlist));
if (!list)
- error ("no memory for reject list!");
+ log_fatal ("no memory for reject list!");
list -> addr = addr;
list -> next = config -> reject_list;
#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.55 1999/02/14 19:40:20 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.56 1999/02/24 17:56:42 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (++i == argc)
usage ();
local_port = htons (atoi (argv [i]));
- debug ("binding to user-specified port %d",
+ log_debug ("binding to user-specified port %d",
ntohs (local_port));
} else if (!strcmp (argv [i], "-d")) {
no_daemon = 1;
((struct interface_info *)
dmalloc (sizeof *tmp, "specified_interface"));
if (!tmp)
- error ("Insufficient memory to %s %s",
+ log_fatal ("Insufficient memory to %s %s",
"record interface", argv [i]);
memset (tmp, 0, sizeof *tmp);
strcpy (tmp -> name, argv [i]);
}
if (!quiet) {
- note (message);
- note (copyright);
- note (arr);
- note (contrib);
- note (url);
+ log_info (message);
+ log_info (copyright);
+ log_info (arr);
+ log_info (contrib);
+ log_info (url);
}
/* Default to the DHCP/BOOTP port. */
(struct string_list *)0);
script_go ((struct client_state *)0);
- note ("No broadcast interfaces found - exiting.");
+ log_info ("No broadcast interfaces found - exiting.");
/* Nothing more to do. */
exit (0);
static void usage ()
{
- error ("Usage: dhclient [-d] [-D] [-q] [-c] [-p <port>]\n [-lf %s",
+ log_fatal ("Usage: dhclient [-d] [-D] [-q] [-c] [-p <port>]\n [-lf %s",
"lease-file] [-pf pid-file] [-cf config-file] [interface]");
}
packet -> raw -> hlen) ||
(memcmp (packet -> interface -> hw_address.haddr,
packet -> raw -> chaddr, packet -> raw -> hlen))) {
- debug ("DHCPACK in wrong transaction.");
+ log_debug ("DHCPACK in wrong transaction.");
return;
}
client -> state != S_REQUESTING &&
client -> state != S_RENEWING &&
client -> state != S_REBINDING) {
- debug ("DHCPACK in wrong state.");
+ log_debug ("DHCPACK in wrong state.");
return;
}
- note ("DHCPACK from %s", piaddr (packet -> client_addr));
+ log_info ("DHCPACK from %s", piaddr (packet -> client_addr));
lease = packet_to_lease (packet);
if (!lease) {
- note ("packet_to_lease failed.");
+ log_info ("packet_to_lease failed.");
return;
}
client -> new -> expiry = 0;
if (!client -> new -> expiry) {
- warn ("no expiry time on offered lease.");
+ log_error ("no expiry time on offered lease.");
/* XXX this is going to be bad - if this _does_
XXX happen, we should probably dynamically
XXX disqualify the DHCP server that gave us the
add_timeout (client -> active -> renewal,
state_bound, client);
- note ("bound to %s -- renewal in %d seconds.",
+ log_info ("bound to %s -- renewal in %d seconds.",
piaddr (client -> active -> address),
client -> active -> renewal - cur_time);
client -> state = S_BOUND;
for (ap = packet -> interface -> client -> config -> reject_list;
ap; ap = ap -> next) {
if (addr_eq (packet -> client_addr, ap -> addr)) {
- note ("BOOTREPLY from %s rejected.",
+ log_info ("BOOTREPLY from %s rejected.",
piaddr (ap -> addr));
return;
}
for (ap = packet -> interface -> client -> config -> reject_list;
ap; ap = ap -> next) {
if (addr_eq (packet -> client_addr, ap -> addr)) {
- note ("%s from %s rejected.",
+ log_info ("%s from %s rejected.",
type, piaddr (ap -> addr));
return;
}
packet -> raw -> hlen) ||
(memcmp (packet -> interface -> hw_address.haddr,
packet -> raw -> chaddr, packet -> raw -> hlen))) {
- debug ("%s in wrong transaction.", name);
+ log_debug ("%s in wrong transaction.", name);
return;
}
- note ("%s from %s", name, piaddr (packet -> client_addr));
+ log_info ("%s from %s", name, piaddr (packet -> client_addr));
/* If this lease doesn't supply the minimum required parameters,
if (!lookup_option
(packet -> options.dhcp_hash,
client -> config -> required_options [i])) {
- note ("%s isn't satisfactory.", name);
+ log_info ("%s isn't satisfactory.", name);
return;
}
}
if (lease -> address.len == sizeof packet -> raw -> yiaddr &&
!memcmp (lease -> address.iabuf,
&packet -> raw -> yiaddr, lease -> address.len)) {
- debug ("%s already seen.", name);
+ log_debug ("%s already seen.", name);
return;
}
}
lease = packet_to_lease (packet);
if (!lease) {
- note ("packet_to_lease failed.");
+ log_info ("packet_to_lease failed.");
return;
}
lease = (struct client_lease *)new_client_lease ("packet_to_lease");
if (!lease) {
- warn ("dhcpoffer: no memory to record lease.\n");
+ log_error ("dhcpoffer: no memory to record lease.\n");
return (struct client_lease *)0;
}
break;
lease -> server_name = dmalloc (len + 1, "packet_to_lease");
if (!lease -> server_name) {
- warn ("dhcpoffer: no memory for filename.\n");
+ log_error ("dhcpoffer: no memory for filename.\n");
destroy_client_lease (lease);
return (struct client_lease *)0;
} else {
break;
lease -> filename = dmalloc (len + 1, "packet_to_lease");
if (!lease -> filename) {
- warn ("dhcpoffer: no memory for filename.\n");
+ log_error ("dhcpoffer: no memory for filename.\n");
destroy_client_lease (lease);
return (struct client_lease *)0;
} else {
packet -> raw -> hlen) ||
(memcmp (packet -> interface -> hw_address.haddr,
packet -> raw -> chaddr, packet -> raw -> hlen))) {
- debug ("DHCPNAK in wrong transaction.");
+ log_debug ("DHCPNAK in wrong transaction.");
return;
}
client -> state != S_REQUESTING &&
client -> state != S_RENEWING &&
client -> state != S_REBINDING) {
- debug ("DHCPNAK in wrong state.");
+ log_debug ("DHCPNAK in wrong state.");
return;
}
- note ("DHCPNAK from %s", piaddr (packet -> client_addr));
+ log_info ("DHCPNAK from %s", piaddr (packet -> client_addr));
if (!client -> active) {
- note ("DHCPNAK with no active lease.\n");
+ log_info ("DHCPNAK with no active lease.\n");
return;
}
}
if (!client -> medium) {
if (fail)
- error ("No valid media types for %s!",
+ log_fatal ("No valid media types for %s!",
client -> interface -> name);
client -> medium =
client -> config -> media;
increase = 1;
}
- note ("Trying medium \"%s\" %d",
+ log_info ("Trying medium \"%s\" %d",
client -> medium -> string, increase);
script_init (client, "MEDIUM", client -> medium);
if (script_go (client)) {
else
client -> packet.secs = 255;
- note ("DHCPDISCOVER on %s to %s port %d interval %ld",
+ log_info ("DHCPDISCOVER on %s to %s port %d interval %ld",
client -> name ? client -> name : client -> interface -> name,
inet_ntoa (sockaddr_broadcast.sin_addr),
ntohs (sockaddr_broadcast.sin_port), client -> interval);
inaddr_any, &sockaddr_broadcast,
(struct hardware *)0);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
add_timeout (cur_time + client -> interval, send_discover, client);
}
loop = lp = client -> active;
- note ("No DHCPOFFERS received.");
+ log_info ("No DHCPOFFERS received.");
/* We may not have an active lease, but we may have some
predefined leases that we can try. */
/* Run through the list of leases and see if one can be used. */
while (client -> active) {
if (client -> active -> expiry > cur_time) {
- note ("Trying recorded lease %s",
+ log_info ("Trying recorded lease %s",
piaddr (client -> active -> address));
/* Run the client script with the existing
parameters. */
if (cur_time <
client -> active -> renewal) {
client -> state = S_BOUND;
- note ("bound: renewal in %d seconds.",
+ log_info ("bound: renewal in %d seconds.",
client -> active -> renewal
- cur_time);
add_timeout ((client ->
state_bound, client);
} else {
client -> state = S_BOUND;
- note ("bound: immediate renewal.");
+ log_info ("bound: immediate renewal.");
state_bound (client);
}
reinitialize_interfaces ();
/* No leases were available, or what was available didn't work, so
tell the shell script that we failed to allocate an address,
and try again later. */
- note ("No working leases in persistent database - sleeping.\n");
+ log_info ("No working leases in persistent database - sleeping.\n");
script_init (client, "FAIL", (struct string_list *)0);
if (client -> alias)
script_write_params (client, "alias_", client -> alias);
else
client -> packet.secs = 255;
- note ("DHCPREQUEST on %s to %s port %d",
+ log_info ("DHCPREQUEST on %s to %s port %d",
client -> name ? client -> name : client -> interface -> name,
inet_ntoa (destination.sin_addr),
ntohs (destination.sin_port));
(struct hardware *)0);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
add_timeout (cur_time + client -> interval,
send_request, client);
int result;
- note ("DHCPDECLINE on %s to %s port %d",
+ log_info ("DHCPDECLINE on %s to %s port %d",
client -> name ? client -> name : client -> interface -> name,
inet_ntoa (sockaddr_broadcast.sin_addr),
ntohs (sockaddr_broadcast.sin_port));
inaddr_any, &sockaddr_broadcast,
(struct hardware *)0);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
}
void send_release (cpp)
int result;
- note ("DHCPRELEASE on %s to %s port %d",
+ log_info ("DHCPRELEASE on %s to %s port %d",
client -> name ? client -> name : client -> interface -> name,
inet_ntoa (sockaddr_broadcast.sin_addr),
ntohs (sockaddr_broadcast.sin_port));
inaddr_any, &sockaddr_broadcast,
(struct hardware *)0);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
}
void make_client_options (client, lease, type, sid, rip, prl,
rip -> iabuf, rip -> len,
&dhcp_options [DHO_DHCP_REQUESTED_ADDRESS],
"make_client_options")))
- warn ("can't make requested address option cache.");
+ log_error ("can't make requested address option cache.");
else {
save_option (options -> dhcp_hash, oc);
option_cache_dereference (&oc, "make_client_options");
(&oc, (struct buffer **)0,
type, 1, &dhcp_options [DHO_DHCP_MESSAGE_TYPE],
"make_client_options")))
- warn ("can't make message type.");
+ log_error ("can't make message type.");
else {
save_option (options -> dhcp_hash, oc);
option_cache_dereference (&oc, "make_client_options");
for (i = 0; prl [i]; i++)
;
if (!buffer_allocate (&bp, i, "make_client_options"))
- warn ("can't make buffer for parameter request list.");
+ log_error ("can't make buffer for parameter request list.");
else {
for (i = 0; prl [i]; i++)
bp -> data [i] = prl [i];
(&oc, &bp, (u_int8_t *)0, i,
&dhcp_options [DHO_DHCP_PARAMETER_REQUEST_LIST],
"make_client_options")))
- warn ("can't make option cache");
+ log_error ("can't make option cache");
else {
save_option (options -> dhcp_hash, oc);
option_cache_dereference
DHO_DHCP_LEASE_TIME))) {
if (!buffer_allocate (&bp, sizeof (u_int32_t),
"make_client_options"))
- warn ("can't make buffer for requested lease time.");
+ log_error ("can't make buffer for requested lease time.");
else {
putULong (bp -> data,
client -> config -> requested_lease);
(&oc, &bp, (u_int8_t *)0, sizeof (u_int32_t),
&dhcp_options [DHO_DHCP_LEASE_TIME],
"make_client_options")))
- warn ("can't make option cache");
+ log_error ("can't make option cache");
else {
save_option (options -> dhcp_hash, oc);
option_cache_dereference
fclose (leaseFile);
leaseFile = fopen (path_dhclient_db, "w");
if (!leaseFile)
- error ("can't create %s: %m", path_dhclient_db);
+ log_fatal ("can't create %s: %m", path_dhclient_db);
/* Write out all the leases attached to configured interfaces that
we know about. */
if (!leaseFile) { /* XXX */
leaseFile = fopen (path_dhclient_db, "w");
if (!leaseFile)
- error ("can't create %s: %m", path_dhclient_db);
+ log_fatal ("can't create %s: %m", path_dhclient_db);
}
fprintf (leaseFile, "lease {\n");
fd = mkstemp (scriptName);
#else
if (!mktemp (scriptName))
- error ("can't create temporary client script %s: %m",
+ log_fatal ("can't create temporary client script %s: %m",
scriptName);
fd = creat (scriptName, 0600);
} while (fd < 0);
scriptFile = fdopen (fd, "w");
if (!scriptFile)
- error ("can't write script file: %m");
+ log_fatal ("can't write script file: %m");
fprintf (scriptFile, "#!/bin/sh\n\n");
if (client) {
if (client -> interface) {
int i;
if (strlen (option -> name) + 1 > sizeof evbuf)
- error ("option %s name is larger than static buffer.");
+ log_fatal ("option %s name is larger than static buffer.");
for (i = 0; option -> name [i]; i++) {
if (option -> name [i] == '-')
evbuf [i] = '_';
/* Become a daemon... */
if ((pid = fork ()) < 0)
- error ("Can't fork daemon: %m");
+ log_fatal ("Can't fork daemon: %m");
else if (pid)
exit (0);
/* Become session leader and get pid... */
pfdesc = open (path_dhclient_pid, O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (pfdesc < 0) {
- warn ("Can't create %s: %m", path_dhclient_pid);
+ log_error ("Can't create %s: %m", path_dhclient_pid);
return;
}
pf = fdopen (pfdesc, "w");
if (!pf)
- warn ("Can't fdopen %s: %m", path_dhclient_pid);
+ log_error ("Can't fdopen %s: %m", path_dhclient_pid);
else {
fprintf (pf, "%ld\n", (long)getpid ());
fclose (pf);
#ifndef lint
static char copyright[] =
-"$Id: alloc.c,v 1.22 1999/02/23 19:04:25 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: alloc.c,v 1.23 1999/02/24 17:56:43 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
{
VOIDPTR foo = (VOIDPTR)malloc (size);
if (!foo)
- warn ("No memory for %s.", name);
+ log_error ("No memory for %s.", name);
else
memset (foo, 0, size);
return foo;
char *name;
{
if (!ptr) {
- warn ("dfree %s: free on null pointer.", name);
+ log_error ("dfree %s: free on null pointer.", name);
return;
}
free (ptr);
char *name;
{
if (!ptr) {
- warn ("Null pointer in expression_reference: %s", name);
+ log_error ("Null pointer in expression_reference: %s", name);
abort ();
}
if (*ptr) {
- warn ("Non-null pointer in expression_reference (%s)",
+ log_error ("Non-null pointer in expression_reference (%s)",
name);
abort ();
}
char *name;
{
if (!ptr) {
- warn ("Null pointer in option_cache_reference: %s", name);
+ log_error ("Null pointer in option_cache_reference: %s", name);
abort ();
}
if (*ptr) {
- warn ("Non-null pointer in option_cache_reference (%s)",
+ log_error ("Non-null pointer in option_cache_reference (%s)",
name);
abort ();
}
char *name;
{
if (!ptr) {
- warn ("Null pointer passed to buffer_reference: %s", name);
+ log_error ("Null pointer passed to buffer_reference: %s", name);
abort ();
}
if (*ptr) {
- warn ("Non-null pointer in buffer_reference (%s)", name);
+ log_error ("Non-null pointer in buffer_reference (%s)", name);
abort ();
}
*ptr = bp;
struct buffer *bp;
if (!ptr || !*ptr) {
- warn ("Null pointer passed to buffer_dereference: %s", name);
+ log_error ("Null pointer passed to buffer_dereference: %s", name);
abort ();
}
char *name;
{
if (!ptr) {
- warn ("Null pointer in dns_host_entry_reference: %s", name);
+ log_error ("Null pointer in dns_host_entry_reference: %s", name);
abort ();
}
if (*ptr) {
- warn ("Non-null pointer in dns_host_entry_reference (%s)",
+ log_error ("Non-null pointer in dns_host_entry_reference (%s)",
name);
abort ();
}
struct dns_host_entry *bp;
if (!ptr || !*ptr) {
- warn ("Null pointer in dns_host_entry_dereference: %s", name);
+ log_error ("Null pointer in dns_host_entry_dereference: %s", name);
abort ();
}
#ifndef lint
static char copyright[] =
-"$Id: bpf.c,v 1.20 1999/02/14 18:41:11 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bpf.c,v 1.21 1999/02/24 17:56:43 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
continue;
} else {
if (!b)
- error ("No bpf devices.%s%s%s",
+ log_fatal ("No bpf devices.%s%s%s",
" Please read the README",
" section for your operating",
" system.");
- error ("Can't find free bpf: %m");
+ log_fatal ("Can't find free bpf: %m");
}
} else {
break;
/* Set the BPF device to point at this interface. */
if (ioctl (sock, BIOCSETIF, info -> ifp) < 0)
- error ("Can't attach interface %s to bpf device %s: %m",
+ log_fatal ("Can't attach interface %s to bpf device %s: %m",
info -> name, filename);
return sock;
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
- note ("Sending on BPF/%s/%s/%s",
+ log_info ("Sending on BPF/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
/* Make sure the BPF version is in range... */
if (ioctl (info -> rfdesc, BIOCVERSION, &v) < 0)
- error ("Can't get BPF version: %m");
+ log_fatal ("Can't get BPF version: %m");
if (v.bv_major != BPF_MAJOR_VERSION ||
v.bv_minor < BPF_MINOR_VERSION)
- error ("Kernel BPF version out of range - recompile dhcpd!");
+ log_fatal ("Kernel BPF version out of range - recompile dhcpd!");
/* Set immediate mode so that reads return as soon as a packet
comes in, rather than waiting for the input buffer to fill with
packets. */
if (ioctl (info -> rfdesc, BIOCIMMEDIATE, &flag) < 0)
- error ("Can't set immediate mode on bpf device: %m");
+ log_fatal ("Can't set immediate mode on bpf device: %m");
#ifdef NEED_OSF_PFILT_HACKS
/* Allow the copyall flag to be set... */
if (ioctl(info -> rfdesc, EIOCALLOWCOPYALL, &flag) < 0)
- error ("Can't set ALLOWCOPYALL: %m");
+ log_fatal ("Can't set ALLOWCOPYALL: %m");
/* Clear all the packet filter mode bits first... */
bits = 0;
if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
- error ("Can't clear pfilt bits: %m");
+ log_fatal ("Can't clear pfilt bits: %m");
/* Set the ENBATCH, ENCOPYALL, ENBPFHDR bits... */
bits = ENBATCH | ENCOPYALL | ENBPFHDR;
if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
- error ("Can't set ENBATCH|ENCOPYALL|ENBPFHDR: %m");
+ log_fatal ("Can't set ENBATCH|ENCOPYALL|ENBPFHDR: %m");
#endif
/* Get the required BPF buffer length from the kernel. */
if (ioctl (info -> rfdesc, BIOCGBLEN, &info -> rbuf_max) < 0)
- error ("Can't get bpf buffer length: %m");
+ log_fatal ("Can't get bpf buffer length: %m");
info -> rbuf = malloc (info -> rbuf_max);
if (!info -> rbuf)
- error ("Can't allocate %d bytes for bpf input buffer.");
+ log_fatal ("Can't allocate %d bytes for bpf input buffer.");
info -> rbuf_offset = 0;
info -> rbuf_len = 0;
dhcp_bpf_filter [8].k = ntohs (local_port);
if (ioctl (info -> rfdesc, BIOCSETF, &p) < 0)
- error ("Can't install packet filter program: %m");
+ log_fatal ("Can't install packet filter program: %m");
if (!quiet_interface_discovery)
- note ("Listening on BPF/%s/%s/%s",
+ log_info ("Listening on BPF/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
#ifndef lint
static char copyright[] =
-"$Id: discover.c,v 1.3 1999/02/14 18:45:30 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: discover.c,v 1.4 1999/02/24 17:56:44 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
- error ("Can't create addrlist socket");
+ log_fatal ("Can't create addrlist socket");
/* Get the interface configuration information... */
ic.ifc_len = sizeof buf;
i = ioctl(sock, SIOCGIFCONF, &ic);
if (i < 0)
- error ("ioctl: SIOCGIFCONF: %m");
+ log_fatal ("ioctl: SIOCGIFCONF: %m");
/* If we already have a list of interfaces, and we're running as
a DHCP server, the interfaces were requested. */
deal with. */
strcpy (ifr.ifr_name, ifp -> ifr_name);
if (ioctl (sock, SIOCGIFFLAGS, &ifr) < 0)
- error ("Can't get interface flags for %s: %m",
+ log_fatal ("Can't get interface flags for %s: %m",
ifr.ifr_name);
/* See if we've seen an interface that matches this one. */
tmp = ((struct interface_info *)
dmalloc (sizeof *tmp, "discover_interfaces"));
if (!tmp)
- error ("Insufficient memory to %s %s",
+ log_fatal ("Insufficient memory to %s %s",
"record interface", ifp -> ifr_name);
strcpy (tmp -> name, ifp -> ifr_name);
tmp -> circuit_id = (u_int8_t *)tmp -> name;
#endif
tif = (struct ifreq *)malloc (len);
if (!tif)
- error ("no space to remember ifp.");
+ log_fatal ("no space to remember ifp.");
memcpy (tif, ifp, len);
tmp -> ifp = tif;
tmp -> primary_address = foo.sin_addr;
subnet -> interface = tmp;
subnet -> interface_address = addr;
} else if (subnet -> interface != tmp) {
- warn ("Multiple %s %s: %s %s",
+ log_error ("Multiple %s %s: %s %s",
"interfaces match the",
"same subnet",
subnet -> interface -> name,
share = subnet -> shared_network;
if (tmp -> shared_network &&
tmp -> shared_network != share) {
- warn ("Interface %s matches %s",
+ log_error ("Interface %s matches %s",
tmp -> name,
"multiple shared networks");
} else {
if (!share -> interface) {
share -> interface = tmp;
} else if (share -> interface != tmp) {
- warn ("Multiple %s %s: %s %s",
+ log_error ("Multiple %s %s: %s %s",
"interfaces match the",
"same shared network",
share -> interface -> name,
proc_dev = fopen (PROCDEV_DEVICE, "r");
if (!proc_dev)
- error ("%s: %m", PROCDEV_DEVICE);
+ log_fatal ("%s: %m", PROCDEV_DEVICE);
while (fgets (buffer, sizeof buffer, proc_dev)) {
char *name = buffer;
tmp = ((struct interface_info *)
dmalloc (sizeof *tmp, "discover_interfaces"));
if (!tmp)
- error ("Insufficient memory to %s %s",
+ log_fatal ("Insufficient memory to %s %s",
"record interface", name);
memset (tmp, 0, sizeof *tmp);
strcpy (tmp -> name, name);
/* Make up an ifreq structure. */
tif = (struct ifreq *)malloc (sizeof (struct ifreq));
if (!tif)
- error ("no space to remember ifp.");
+ log_fatal ("no space to remember ifp.");
memset (tif, 0, sizeof (struct ifreq));
strcpy (tif -> ifr_name, tmp -> name);
tmp -> ifp = tif;
#endif
default:
- error ("%s: unknown hardware address type %d",
+ log_fatal ("%s: unknown hardware address type %d",
ifr.ifr_name, sa.sa_family);
}
}
INTERFACE_REQUESTED);
if (!tmp -> ifp || !(tmp -> flags & INTERFACE_REQUESTED)) {
if ((tmp -> flags & INTERFACE_REQUESTED) != ir)
- error ("%s: not found", tmp -> name);
+ log_fatal ("%s: not found", tmp -> name);
if (!last)
interfaces = interfaces -> next;
else
/* We must have a subnet declaration for each interface. */
if (!tmp -> shared_network && (state == DISCOVER_SERVER))
- error ("No subnet declaration for %s (%s).",
+ log_fatal ("No subnet declaration for %s (%s).",
tmp -> name, inet_ntoa (foo.sin_addr));
/* Find subnets that don't have valid interface
((struct interface_info *)
dmalloc (sizeof *fallback_interface, "discover_interfaces"));
if (!fallback_interface)
- error ("Insufficient memory to record fallback interface.");
+ log_fatal ("Insufficient memory to record fallback interface.");
memset (fallback_interface, 0, sizeof *fallback_interface);
strcpy (fallback_interface -> name, "fallback");
fallback_interface -> shared_network =
new_shared_network ("parse_statement");
if (!fallback_interface -> shared_network)
- error ("No memory for shared subnet");
+ log_fatal ("No memory for shared subnet");
memset (fallback_interface -> shared_network, 0,
sizeof (struct shared_network));
fallback_interface -> shared_network -> name = "fallback-net";
if ((result =
receive_packet (ip, u.packbuf, sizeof u, &from, &hfrom)) < 0) {
- warn ("receive_packet failed on %s: %m", ip -> name);
+ log_error ("receive_packet failed on %s: %m", ip -> name);
return;
}
if (result == 0)
#ifndef lint
static char copyright[] =
-"$Id: dispatch.c,v 1.52 1999/02/14 18:46:20 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dispatch.c,v 1.53 1999/02/24 17:56:44 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
}
fds = (struct pollfd *)malloc ((nfds) * sizeof (struct pollfd));
if (!fds)
- error ("Can't allocate poll structures.");
+ log_fatal ("Can't allocate poll structures.");
do {
/* Call any expired timeouts, and then if there's
if (errno == EAGAIN || errno == EINTR)
continue;
else
- error ("poll: %m");
+ log_fatal ("poll: %m");
}
i = 0;
/* Not likely to be transitory... */
if (count < 0)
- error ("select: %m");
+ log_fatal ("select: %m");
for (l = protocols; l; l = l -> next) {
if (!FD_ISSET (l -> fd, &r))
} else {
q = (struct timeout *)malloc (sizeof (struct timeout));
if (!q)
- error ("Can't allocate timeout structure!");
+ log_fatal ("Can't allocate timeout structure!");
q -> func = where;
q -> what = what;
}
p = (struct protocol *)malloc (sizeof *p);
if (!p)
- error ("can't allocate protocol struct for %s", name);
+ log_fatal ("can't allocate protocol struct for %s", name);
p -> fd = fd;
p -> handler = handler;
#ifndef lint
static char copyright[] =
-"$Id: dlpi.c,v 1.3 1999/02/14 18:48:05 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dlpi.c,v 1.4 1999/02/24 17:56:44 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
static int strioctl PROTO ((int fd, int cmd, int timeout, int len, char *dp));
/* Open a DLPI device */
if ((sock = dlpiopen (info -> name)) < 0) {
- error ("Can't open DLPI device for %s: %m", info -> name);
+ log_fatal ("Can't open DLPI device for %s: %m", info -> name);
}
/*
* the dl_mac_type and dl_provider_style
*/
if (dlpiinforeq(sock) < 0 || dlpiinfoack(sock, (char *)buf) < 0) {
- error ("Can't get DLPI MAC type for %s: %m", info -> name);
+ log_fatal ("Can't get DLPI MAC type for %s: %m", info -> name);
} else {
switch (dlp -> info_ack.dl_mac_type) {
case DL_CSMACD: /* IEEE 802.3 */
info -> hw_address.htype = HTYPE_FDDI;
break;
default:
- error ("%s: unknown DLPI MAC type %d",
+ log_fatal ("%s: unknown DLPI MAC type %d",
info -> name,
dlp -> info_ack.dl_mac_type);
break;
if (dlpiattachreq (sock, unit) < 0
|| dlpiokack (sock, (char *)buf) < 0) {
- error ("Can't attach DLPI device for %s: %m", info -> name);
+ log_fatal ("Can't attach DLPI device for %s: %m", info -> name);
}
}
*/
if (dlpibindreq (sock, DLPI_DEFAULTSAP, 0, DL_CLDLS, 0, 0) < 0
|| dlpibindack (sock, (char *)buf) < 0) {
- error ("Can't bind DLPI device for %s: %m", info -> name);
+ log_fatal ("Can't bind DLPI device for %s: %m", info -> name);
}
/*
*/
if (dlpiphysaddrreq (sock, DL_CURR_PHYS_ADDR) < 0
|| dlpiphysaddrack (sock, (char *)buf) < 0) {
- error ("Can't get DLPI hardware address for %s: %m",
+ log_fatal ("Can't get DLPI hardware address for %s: %m",
info -> name);
}
#ifdef USE_DLPI_RAW
if (strioctl (sock, DLIOCRAW, INFTIM, 0, 0) < 0) {
- error ("Can't set DLPI RAW mode for %s: %m",
+ log_fatal ("Can't set DLPI RAW mode for %s: %m",
info -> name);
}
#endif
#ifdef USE_DLPI_PFMOD
if (ioctl (sock, I_PUSH, "pfmod") < 0) {
- error ("Can't push packet filter onto DLPI for %s: %m",
+ log_fatal ("Can't push packet filter onto DLPI for %s: %m",
info -> name);
}
#endif
/* Install the filter */
if (strioctl (info -> wfdesc, PFIOCSETF, INFTIM,
sizeof (pf), (char *)&pf) < 0) {
- error ("Can't set PFMOD send filter on %s: %m", info -> name);
+ log_fatal ("Can't set PFMOD send filter on %s: %m", info -> name);
}
# endif /* USE_DLPI_PFMOD */
#endif
if (!quiet_interface_discovery)
- note ("Sending on DLPI/%s/%s/%s",
+ log_info ("Sending on DLPI/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
/* Install the filter... */
if (strioctl (info -> rfdesc, PFIOCSETF, INFTIM,
sizeof (pf), (char *)&pf) < 0) {
- error ("Can't set PFMOD receive filter on %s: %m", info -> name);
+ log_fatal ("Can't set PFMOD receive filter on %s: %m", info -> name);
}
#endif
if (!quiet_interface_discovery)
- note ("Listening on DLPI/%s/%s/%s",
+ log_info ("Listening on DLPI/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
count = poll (&pfd, 1, to_msec);
if (count == 0) {
- /* error ("strgetmsg: timeout"); */
+ /* log_fatal ("strgetmsg: timeout"); */
return -1;
} else if (count < 0) {
if (errno == EAGAIN || errno == EINTR) {
time (&now);
continue;
} else {
- /* error ("poll: %m"); */
+ /* log_fatal ("poll: %m"); */
return -1;
}
} else {
(void) sigset (SIGALRM, sigalrm);
if (alarm (DLPI_MAXWAIT) < 0) {
- /* error ("alarm: %m"); */
+ /* log_fatal ("alarm: %m"); */
return -1;
}
#endif /* !defined (USE_POLL) */
* Stop timer.
*/
if (alarm (0) < 0) {
- /* error ("alarm: %m"); */
+ /* log_fatal ("alarm: %m"); */
return -1;
}
#endif
#ifndef lint
static char copyright[] =
-"$Id: dns.c,v 1.9 1998/03/17 06:09:59 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dns.c,v 1.10 1999/02/24 17:56:44 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Only initialize icmp once. */
if (dns_protocol_initialized)
- error ("attempted to reinitialize dns protocol");
+ log_fatal ("attempted to reinitialize dns protocol");
dns_protocol_initialized = 1;
/* Get the protocol number (should be 1). */
/* Get a socket for the DNS protocol. */
dns_protocol_fd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (dns_protocol_fd < 0)
- error ("unable to create dns socket: %m");
+ log_fatal ("unable to create dns socket: %m");
first_name_server ();
status = recvfrom (protocol -> fd, (char *)buf, sizeof buf, 0,
(struct sockaddr *)&from, &len);
if (status < 0) {
- warn ("dns_packet: %m");
+ log_error ("dns_packet: %m");
return;
}
/* Response is too long? */
if (len > 512) {
- warn ("dns_packet: dns message too long (%d)", len);
+ log_error ("dns_packet: dns message too long (%d)", len);
return;
}
/* If this is a response to a query from us, there should have
been only one query. */
if (ntohs (ns_header -> qdcount) != 1) {
- warn ("Bogus DNS answer packet from %s claims %d queries.\n",
+ log_error ("Bogus DNS answer packet from %s claims %d queries.\n",
inet_ntoa (from.sin_addr),
ntohs (ns_header -> qdcount));
return;
/* See if we asked this question. */
query = find_dns_query (&qbuf.q, 0);
if (!query) {
-warn ("got answer for question %s from DNS, which we didn't ask.",
+log_error ("got answer for question %s from DNS, which we didn't ask.",
qbuf.q.data);
return;
}
-note ("got answer for question %s from DNS", qbuf.q.data);
+log_info ("got answer for question %s from DNS", qbuf.q.data);
/* Wake up everybody who's waiting. */
for (wakeup = query -> wakeups; wakeup; wakeup = wakeup -> next) {
#ifndef lint
static char copyright[] =
-"$Id: errwarn.c,v 1.15 1997/05/09 08:03:44 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: errwarn.c,v 1.16 1999/02/24 17:56:45 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Log an error message, then exit... */
-void error (ANSI_DECL(char *) fmt, VA_DOTDOTDOT)
+void log_fatal (ANSI_DECL(char *) fmt, VA_DOTDOTDOT)
KandR (char *fmt;)
va_dcl
{
exit (1);
}
-/* Log a warning message... */
+/* Log an error message... */
-int warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
+int log_error (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
KandR (char *fmt;)
va_dcl
{
/* Log a note... */
-int note (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
+int log_info (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
KandR (char *fmt;)
va_dcl
{
/* Log a debug message... */
-int debug (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
+int log_debug (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
KandR (char *fmt;)
va_dcl
{
#ifndef lint
static char copyright[] =
-"$Id: execute.c,v 1.4 1998/11/11 07:51:41 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: execute.c,v 1.5 1999/02/24 17:56:45 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
in_options, r -> data.ie.expr);
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: if %s", (status
+ log_info ("exec: if %s", (status
? (result ? "true" : "false")
: "NULL"));
#endif
(&result,
packet, in_options, r -> data.eval);
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: evaluate: %s",
+ log_info ("exec: evaluate: %s",
(status
? (result ? "true" : "false") : "NULL"));
#endif
case add_statement:
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: add %s", (r -> data.add -> name
+ log_info ("exec: add %s", (r -> data.add -> name
? r -> data.add -> name
: "<unnamed class>"));
#endif
case break_statement:
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: break");
+ log_info ("exec: break");
#endif
return 0;
case supersede_option_statement:
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: supersede option %s.%s",
+ log_info ("exec: supersede option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
goto option_statement;
#endif
case default_option_statement:
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: default option %s.%s",
+ log_info ("exec: default option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
goto option_statement;
#endif
case append_option_statement:
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: append option %s.%s",
+ log_info ("exec: append option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
goto option_statement;
#endif
case prepend_option_statement:
#if defined (DEBUG_EXPRESSIONS)
- note ("exec: prepend option %s.%s",
+ log_info ("exec: prepend option %s.%s",
r -> data.option -> option -> universe -> name,
r -> data.option -> option -> name);
option_statement:
break;
default:
- error ("bogus statement type %d\n", r -> op);
+ log_fatal ("bogus statement type %d\n", r -> op);
}
}
#ifndef lint
static char copyright[] =
-"$Id: hash.c,v 1.10 1998/03/16 06:11:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: hash.c,v 1.11 1999/02/24 17:56:45 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
bp = new_hash_bucket ("add_hash");
if (!bp) {
- warn ("Can't add %s to hash table.", name);
+ log_error ("Can't add %s to hash table.", name);
return;
}
bp -> name = name;
#ifndef lint
static char copyright[] =
-"$Id: icmp.c,v 1.11 1998/06/25 22:54:13 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: icmp.c,v 1.12 1999/02/24 17:56:45 mellon Exp $ Copyright (c) 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Only initialize icmp once. */
if (icmp_protocol_initialized)
- error ("attempted to reinitialize icmp protocol");
+ log_fatal ("attempted to reinitialize icmp protocol");
icmp_protocol_initialized = 1;
/* Get the protocol number (should be 1). */
/* Get a raw socket for the ICMP protocol. */
icmp_protocol_fd = socket (AF_INET, SOCK_RAW, protocol);
if (icmp_protocol_fd < 0)
- error ("unable to create icmp socket: %m");
+ log_fatal ("unable to create icmp socket: %m");
/* Make sure it does routing... */
state = 0;
if (setsockopt (icmp_protocol_fd, SOL_SOCKET, SO_DONTROUTE,
(char *)&state, sizeof state) < 0)
- error ("Unable to disable SO_DONTROUTE on ICMP socket: %m");
+ log_fatal ("Unable to disable SO_DONTROUTE on ICMP socket: %m");
add_protocol ("icmp", icmp_protocol_fd,
icmp_echoreply, (void *)handler);
int status;
if (!icmp_protocol_initialized)
- error ("attempt to use ICMP protocol before initialization.");
+ log_fatal ("attempt to use ICMP protocol before initialization.");
#ifdef HAVE_SA_LEN
to.sin_len = sizeof to;
status = sendto (icmp_protocol_fd, (char *)&icmp, sizeof icmp, 0,
(struct sockaddr *)&to, sizeof to);
if (status < 0)
- warn ("icmp_echorequest %s: %m", inet_ntoa(to.sin_addr));
+ log_error ("icmp_echorequest %s: %m", inet_ntoa(to.sin_addr));
if (status != sizeof icmp)
return 0;
status = recvfrom (protocol -> fd, (char *)icbuf, sizeof icbuf, 0,
(struct sockaddr *)&from, &len);
if (status < 0) {
- warn ("icmp_echoreply: %m");
+ log_error ("icmp_echoreply: %m");
return;
}
#ifndef lint
static char copyright[] =
-"$Id: interact.c,v 1.1 1998/04/09 05:18:56 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: interact.c,v 1.2 1999/02/24 17:56:45 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Only initialize interact once. */
if (interact_initialized)
- error ("attempted to reinitialize interact protocol");
+ log_fatal ("attempted to reinitialize interact protocol");
interact_initialized = 1;
/* Make a socket... */
interact_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (interact_fd < 0)
- error ("unable to create interact socket: %m");
+ log_fatal ("unable to create interact socket: %m");
/* XXX for now... */
name.sun_family = PF_UNIX;
/* Bind to it... */
if (bind (interact_fd, (struct sockaddr *)&name, len) < 0) {
- warn ("can't bind to interact socket: %m");
+ log_error ("can't bind to interact socket: %m");
close (interact_fd);
umask (m);
return;
/* Listen for connections... */
if (listen (interact_fd, 1) < 0) {
- warn ("can't listen on interact socket: %m");
+ log_error ("can't listen on interact socket: %m");
close (interact_fd);
unlink (name.sun_path);
return;
tmp = (struct interact_client *)malloc (sizeof *tmp);
if (!tmp)
- error ("Can't find memory for new client!");
+ log_fatal ("Can't find memory for new client!");
memset (tmp, 0, sizeof *tmp);
namelen = sizeof name;
new_fd = accept (proto -> fd, (struct sockaddr *)&name, &namelen);
if (new_fd < 0) {
- warn ("accept: %m");
+ log_error ("accept: %m");
free (tmp);
return;
}
if ((arg = fcntl (new_fd, F_GETFL, 0)) < 0) {
bad_flag:
- warn ("Can't set flags on new interactive client: %m");
+ log_error ("Can't set flags on new interactive client: %m");
close (new_fd);
free (tmp);
return;
status = read (proto -> fd, &client -> ibuf [client -> ibuflen],
(sizeof client -> ibuf) - client -> ibuflen);
if (status < 0) {
- warn ("interact_client_input: %m");
+ log_error ("interact_client_input: %m");
blow:
close (proto -> fd);
remove_protocol (proto);
eobuf = memchr (client -> ibuf, '\n', client -> ibuflen);
if (!eobuf) {
if (client -> ibuflen == sizeof client -> ibuf) {
- warn ("interact_client_input: buffer overflow.");
+ log_error ("interact_client_input: buffer overflow.");
goto blow;
}
return;
obufmax = (strlen (string) + 1025) & ~1023;
obuf = malloc (obufmax);
if (!obuf) {
- warn ("interact_client_write: out of memory");
+ log_error ("interact_client_write: out of memory");
blow:
close (client -> proto -> fd);
remove_protocol (client -> proto);
#ifndef lint
static char copyright[] =
-"$Id: lpf.c,v 1.2 1999/02/14 06:05:49 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: lpf.c,v 1.3 1999/02/24 17:56:45 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT)
- error ("socket: %m - make sure %s %s!",
+ log_fatal ("socket: %m - make sure %s %s!",
"CONFIG_PACKET and CONFIG_FILTER are defined",
"in your kernel configuration");
error("Open a socket for LPF: %m");
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT)
- error ("socket: %m - make sure %s %s!",
+ log_fatal ("socket: %m - make sure %s %s!",
"CONFIG_PACKET and CONFIG_FILTER are defined",
"in your kernel configuration");
error("Bind socket to interface: %m");
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
- note ("Sending on LPF/%s/%s/%s",
+ log_info ("Sending on LPF/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT)
- error ("socket: %m - make sure %s %s!",
+ log_fatal ("socket: %m - make sure %s %s!",
"CONFIG_PACKET and CONFIG_FILTER are defined",
"in your kernel configuration");
- error ("Can't install packet filter program: %m");
+ log_fatal ("Can't install packet filter program: %m");
}
if (!quiet_interface_discovery)
- note ("Listening on LPF/%s/%s/%s",
+ log_info ("Listening on LPF/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
#ifndef lint
static char copyright[] =
-"$Id: memory.c,v 1.45 1999/02/14 18:49:45 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: memory.c,v 1.46 1999/02/24 17:56:46 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* All subnets should have attached shared network structures. */
if (!share) {
strcpy (netbuf, piaddr (subnet -> net));
- error ("No shared network for network %s (%s)",
+ log_fatal ("No shared network for network %s (%s)",
netbuf, piaddr (subnet -> netmask));
}
strcpy (lowbuf, piaddr (low));
strcpy (highbuf, piaddr (high));
strcpy (netbuf, piaddr (subnet -> netmask));
- error ("Address range %s to %s, netmask %s spans %s!",
+ log_fatal ("Address range %s to %s, netmask %s spans %s!",
lowbuf, highbuf, netbuf, "multiple subnets");
}
strcpy (lowbuf, piaddr (low));
strcpy (highbuf, piaddr (high));
strcpy (netbuf, piaddr (subnet -> netmask));
- error ("Address range %s to %s not on net %s/%s!",
+ log_fatal ("Address range %s to %s not on net %s/%s!",
lowbuf, highbuf, piaddr (subnet -> net), netbuf);
}
if (!address_range) {
strcpy (lowbuf, piaddr (low));
strcpy (highbuf, piaddr (high));
- error ("No memory for address range %s-%s.", lowbuf, highbuf);
+ log_fatal ("No memory for address range %s-%s.", lowbuf, highbuf);
}
memset (address_range, 0, (sizeof *address_range) * (max - min + 1));
break;
strcpy (n1buf, piaddr (subnet -> net));
if (warnp)
- warn ("%ssubnet %s/%d conflicts with subnet %s/%d",
+ log_error ("%ssubnet %s/%d conflicts with subnet %s/%d",
"Warning: ", n1buf, 32 - i,
piaddr (scan -> net), 32 - j);
if (i < j)
if (!comp) {
comp = new_lease ("enter_lease");
if (!comp) {
- error ("No memory for lease %s\n",
+ log_fatal ("No memory for lease %s\n",
piaddr (lease -> ip_addr));
}
*comp = *lease;
memcmp (comp -> hardware_addr.haddr,
lease -> hardware_addr.haddr,
comp -> hardware_addr.hlen))))) {
- warn ("Lease conflict at %s",
+ log_error ("Lease conflict at %s",
piaddr (comp -> ip_addr));
return 0;
}
lease -> uid = (unsigned char *)0;
lease -> uid_max = 0;
} else {
- error ("corrupt lease uid."); /* XXX */
+ log_fatal ("corrupt lease uid."); /* XXX */
}
} else {
comp -> uid = (unsigned char *)0;
lease -> flags |= ABANDONED_LEASE;
lt = *lease;
lt.ends = cur_time; /* XXX */
- warn ("Abandoning IP address %s: %s",
+ log_error ("Abandoning IP address %s: %s",
piaddr (lease -> ip_addr), message);
lt.hardware_addr.htype = 0;
lt.hardware_addr.hlen = 0;
{
struct group *g = new_group (caller);
if (!g)
- error ("%s: can't allocate new group", caller);
+ log_fatal ("%s: can't allocate new group", caller);
*g = *group;
g -> statements = (struct executable_statement *)0;
g -> next = group;
l -> uid_len ||
(l -> flags & ABANDONED_LEASE))
if (!write_lease (l))
- error ("Can't rewrite %s",
+ log_fatal ("Can't rewrite %s",
"lease database");
}
}
}
if (!commit_leases ())
- error ("Can't commit leases to new database: %m");
+ log_fatal ("Can't commit leases to new database: %m");
}
void dump_subnets ()
struct subnet *n;
struct pool *p;
- note ("Subnets:");
+ log_info ("Subnets:");
for (n = subnets; n; n = n -> next_subnet) {
- debug (" Subnet %s", piaddr (n -> net));
- debug (" netmask %s",
+ log_debug (" Subnet %s", piaddr (n -> net));
+ log_debug (" netmask %s",
piaddr (n -> netmask));
}
- note ("Shared networks:");
+ log_info ("Shared networks:");
for (s = shared_networks; s; s = s -> next) {
- note (" %s", s -> name);
+ log_info (" %s", s -> name);
for (p = s -> pools; p; p = p -> next) {
for (l = p -> leases; l; l = l -> next) {
print_lease (l);
}
- debug ("Last Lease:");
+ log_debug ("Last Lease:");
print_lease (p -> last_lease);
}
}
#ifndef lint
static char copyright[] =
-"$Id: nit.c,v 1.16 1999/02/14 18:50:25 mellon Exp $ Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: nit.c,v 1.17 1999/02/24 17:56:46 mellon Exp $ Copyright (c) 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Open a NIT device */
sock = open ("/dev/nit", O_RDWR);
if (sock < 0)
- error ("Can't open NIT device for %s: %m", info -> name);
+ log_fatal ("Can't open NIT device for %s: %m", info -> name);
/* Set the NIT device to point at this interface. */
sio.ic_cmd = NIOCBIND;
sio.ic_dp = (char *)(info -> ifp);
sio.ic_timout = INFTIM;
if (ioctl (sock, I_STR, &sio) < 0)
- error ("Can't attach interface %s to nit device: %m",
+ log_fatal ("Can't attach interface %s to nit device: %m",
info -> name);
/* Get the low-level address... */
sio.ic_dp = (char *)𝔦
sio.ic_timout = INFTIM;
if (ioctl (sock, I_STR, &sio) < 0)
- error ("Can't get physical layer address for %s: %m",
+ log_fatal ("Can't get physical layer address for %s: %m",
info -> name);
/* XXX code below assumes ethernet interface! */
memcpy (info -> hw_address.haddr, ifr.ifr_ifru.ifru_addr.sa_data, 6);
if (ioctl (sock, I_PUSH, "pf") < 0)
- error ("Can't push packet filter onto NIT for %s: %m",
+ log_fatal ("Can't push packet filter onto NIT for %s: %m",
info -> name);
return sock;
sio.ic_dp = (char *)&pf;
sio.ic_timout = INFTIM;
if (ioctl (info -> wfdesc, I_STR, &sio) < 0)
- error ("Can't set NIT filter: %m");
+ log_fatal ("Can't set NIT filter: %m");
#else
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
- note ("Sending on NIT/%s/%s",
+ log_info ("Sending on NIT/%s/%s",
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
info -> hw_address.haddr),
packet. */
x = 0;
if (ioctl (info -> rfdesc, NIOCSSNAP, &x) < 0)
- error ("Can't set NIT snap length on %s: %m", info -> name);
+ log_fatal ("Can't set NIT snap length on %s: %m", info -> name);
/* Set the stream to byte stream mode */
if (ioctl (info -> rfdesc, I_SRDOPT, RMSGN) != 0)
- note ("I_SRDOPT failed on %s: %m", info -> name);
+ log_info ("I_SRDOPT failed on %s: %m", info -> name);
#if 0
/* Push on the chunker... */
if (ioctl (info -> rfdesc, I_PUSH, "nbuf") < 0)
- error ("Can't push chunker onto NIT STREAM: %m");
+ log_fatal ("Can't push chunker onto NIT STREAM: %m");
/* Set the timeout to zero. */
t.tv_sec = 0;
t.tv_usec = 0;
if (ioctl (info -> rfdesc, NIOCSTIME, &t) < 0)
- error ("Can't set chunk timeout: %m");
+ log_fatal ("Can't set chunk timeout: %m");
#endif
/* Ask for no header... */
x = 0;
if (ioctl (info -> rfdesc, NIOCSFLAGS, &x) < 0)
- error ("Can't set NIT flags on %s: %m", info -> name);
+ log_fatal ("Can't set NIT flags on %s: %m", info -> name);
/* Set up the NIT filter program. */
/* XXX Unlike the BPF filter program, this one won't work if the
sio.ic_dp = (char *)&pf;
sio.ic_timout = INFTIM;
if (ioctl (info -> rfdesc, I_STR, &sio) < 0)
- error ("Can't set NIT filter on %s: %m", info -> name);
+ log_fatal ("Can't set NIT filter on %s: %m", info -> name);
if (!quiet_interface_discovery)
- note ("Listening on NIT/%s/%s",
+ log_info ("Listening on NIT/%s/%s",
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
info -> hw_address.haddr),
#ifndef lint
static char copyright[] =
-"$Id: options.c,v 1.34 1998/11/06 00:12:40 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: options.c,v 1.35 1999/02/24 17:56:46 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#define DHCP_OPTION_DATA
struct buffer *bp = (struct buffer *)0;
if (!buffer_allocate (&bp, length, "parse_option_buffer")) {
- warn ("parse_option_buffer: no memory for option buffer.");
+ log_error ("parse_option_buffer: no memory for option buffer.");
return 0;
}
memcpy (bp -> data, buffer, length);
/* If the length is outrageous, the options are bad. */
if (offset + len + 2 > length) {
- warn ("Option %s length %d overflows input buffer.",
+ log_error ("Option %s length %d overflows input buffer.",
dhcp_options [code].name,
len);
buffer_dereference (&bp, "parse_option_buffer");
if (code == DHO_DHCP_AGENT_OPTIONS) {
if (!parse_agent_information_option
(packet, len, buffer + offset + 2)) {
- warn ("malformed agent information option.");
+ log_error ("malformed agent information option.");
buffer_dereference (&bp,
"parse_option_buffer");
return 0;
} else {
if (!option_cache_allocate (&op,
"parse_option_buffer")) {
- warn ("Can't allocate storage for option %s.",
+ log_error ("Can't allocate storage for option %s.",
dhcp_options [code].name);
buffer_dereference (&bp,
"parse_option_buffer");
dmalloc (op [1] + 1 + sizeof *t,
"parse_agent_information_option");
if (!t)
- error ("can't allocate space for option tag data.");
+ log_fatal ("can't allocate space for option tag data.");
/* Link it in at the tail of the list. */
t -> next = (struct option_tag *)0;
a = (struct agent_options *)dmalloc (sizeof *a,
"parse_agent_information_option");
if (!a)
- error ("can't allocate space for agent option structure.");
+ log_fatal ("can't allocate space for agent option structure.");
/* Find the tail of the list. */
for (tail = &packet -> options.agent_options;
/* Code should be between 0 and 255. */
if (code > 255)
- error ("pretty_print_option: bad code %d\n", code);
+ log_fatal ("pretty_print_option: bad code %d\n", code);
if (emit_commas)
comma = ',';
/* Figure out the size of the data. */
for (i = 0; dhcp_options [code].format [i]; i++) {
if (!numhunk) {
- warn ("%s: Excess information in format string: %s\n",
+ log_error ("%s: Excess information in format string: %s\n",
dhcp_options [code].name,
&(dhcp_options [code].format [i]));
break;
case 'e':
break;
default:
- warn ("%s: garbage in format string: %s\n",
+ log_error ("%s: garbage in format string: %s\n",
dhcp_options [code].name,
&(dhcp_options [code].format [i]));
break;
/* Check for too few bytes... */
if (hunksize > len) {
- warn ("%s: expecting at least %d bytes; got %d",
+ log_error ("%s: expecting at least %d bytes; got %d",
dhcp_options [code].name,
hunksize, len);
return "<error>";
}
/* Check for too many bytes... */
if (numhunk == -1 && hunksize < len)
- warn ("%s: %d extra bytes",
+ log_error ("%s: %d extra bytes",
dhcp_options [code].name,
len - hunksize);
numhunk = len / hunksize;
/* See if we got an exact number of hunks. */
if (numhunk > 0 && numhunk * hunksize < len)
- warn ("%s: %d extra bytes at end of array\n",
+ log_error ("%s: %d extra bytes at end of array\n",
dhcp_options [code].name,
len - numhunk * hunksize);
strcpy (op, *dp++ ? "true" : "false");
break;
default:
- warn ("Unexpected format code %c", fmtbuf [j]);
+ log_error ("Unexpected format code %c", fmtbuf [j]);
}
op += strlen (op);
if (j + 1 < numelem && comma != ':')
tp.haddr = hfrom;
if (packet -> hlen > sizeof packet -> chaddr) {
- note ("Discarding packet with bogus hardware address length.");
+ log_info ("Discarding packet with bogus hardware address length.");
return;
}
if (!parse_options (&tp)) {
case eval_statement:
case break_statement:
default:
- warn ("bogus statement type in do_option_set.");
+ log_error ("bogus statement type in do_option_set.");
break;
case default_option_statement:
if (!oc -> expression && oc -> data.len) {
if (!expression_allocate (&oc -> expression,
"do_option_set")) {
- warn ("Can't allocate const expression.");
+ log_error ("Can't allocate const expression.");
break;
}
oc -> expression -> op = expr_const_data;
/* Otherwise, just put the new one at the head of the list. */
bptr = new_pair ("save_option");
if (!bptr) {
- warn ("No memory for option_cache reference.");
+ log_error ("No memory for option_cache reference.");
return;
}
bptr -> cdr = hash [hashix];
char *name;
{
if (!ptr || !*ptr) {
- warn ("Null pointer in option_cache_dereference: %s", name);
+ log_error ("Null pointer in option_cache_dereference: %s", name);
abort ();
}
#ifndef lint
static char copyright[] =
-"$Id: packet.c,v 1.19 1998/03/16 06:14:08 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: packet.c,v 1.20 1999/02/24 17:56:47 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
int i;
#ifdef DEBUG_CHECKSUM
- debug ("checksum (%x %d %x)", buf, nbytes, sum);
+ log_debug ("checksum (%x %d %x)", buf, nbytes, sum);
#endif
/* Checksum all the pairs of bytes first... */
for (i = 0; i < (nbytes & ~1); i += 2) {
#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
+ log_debug ("sum = %x", sum);
#endif
sum += (u_int16_t) ntohs(*((u_int16_t *)(buf + i)));
}
byte order is big-endian, so the remaining byte is the high byte. */
if (i < nbytes) {
#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
+ log_debug ("sum = %x", sum);
#endif
sum += buf [i] << 8;
}
u_int32_t sum;
{
#ifdef DEBUG_CHECKSUM
- debug ("wrapsum (%x)", sum);
+ log_debug ("wrapsum (%x)", sum);
#endif
while (sum > 0x10000) {
sum = (sum >> 16) + (sum & 0xFFFF);
#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
+ log_debug ("sum = %x", sum);
#endif
sum += (sum >> 16);
#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
+ log_debug ("sum = %x", sum);
#endif
}
sum = sum ^ 0xFFFF;
#ifdef DEBUG_CHECKSUM_VERBOSE
- debug ("sum = %x", sum);
+ log_debug ("sum = %x", sum);
#endif
#ifdef DEBUG_CHECKSUM
- debug ("wrapsum returns %x", htons (sum));
+ log_debug ("wrapsum returns %x", htons (sum));
#endif
return htons(sum);
}
/* Check the IP header checksum - it should be zero. */
if (wrapsum (checksum (buf + bufix, ip_len, 0))) {
- note ("Bad IP checksum: %x",
+ log_info ("Bad IP checksum: %x",
wrapsum (checksum (buf + bufix, sizeof *ip, 0)));
return -1;
}
ntohs (udp -> uh_ulen)))));
if (usum && usum != sum) {
- note ("Bad udp checksum: %x %x", usum, sum);
+ log_info ("Bad udp checksum: %x %x", usum, sum);
return -1;
}
#endif
#ifndef lint
static char copyright[] =
-"$Id: parse.c,v 1.12 1999/02/14 18:54:03 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: parse.c,v 1.13 1999/02/24 17:56:47 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
}
s = (char *)malloc (strlen (val) + 1);
if (!s)
- error ("no memory for string %s.", val);
+ log_fatal ("no memory for string %s.", val);
strcpy (s, val);
if (!parse_semi (cfile))
/* Store this identifier... */
if (!(s = (char *)malloc (strlen (val) + 1)))
- error ("can't allocate temp space for hostname.");
+ log_fatal ("can't allocate temp space for hostname.");
strcpy (s, val);
c = cons ((caddr_t)s, c);
len += strlen (s) + 1;
/* Assemble the hostname together into a string. */
if (!(s = (char *)malloc (len)))
- error ("can't allocate space for hostname.");
+ log_fatal ("can't allocate space for hostname.");
t = s + len;
*--t = 0;
while (c) {
if (!bufp && *max) {
bufp = (unsigned char *)malloc (*max * size / 8);
if (!bufp)
- error ("can't allocate space for numeric aggregate");
+ log_fatal ("can't allocate space for numeric aggregate");
} else
s = bufp;
} else {
t = (unsigned char *)malloc (strlen (val) + 1);
if (!t)
- error ("no temp space for number.");
+ log_fatal ("no temp space for number.");
strcpy ((char *)t, val);
c = cons ((caddr_t)t, c);
}
if (c) {
bufp = (unsigned char *)malloc (count * size / 8);
if (!bufp)
- error ("can't allocate space for numeric aggregate.");
+ log_fatal ("can't allocate space for numeric aggregate.");
s = bufp + count - size / 8;
*max = count;
}
else if (tval >= '0')
tval -= '0';
else {
- warn ("Bogus number: %s.", str);
+ log_error ("Bogus number: %s.", str);
break;
}
if (tval >= base) {
- warn ("Bogus number: %s: digit %d not in base %d\n",
+ log_error ("Bogus number: %s: digit %d not in base %d\n",
str, tval, base);
break;
}
if (val > max) {
switch (base) {
case 8:
- warn ("value %s%o exceeds max (%d) for precision.",
+ log_error ("value %s%o exceeds max (%d) for precision.",
negative ? "-" : "", val, max);
break;
case 16:
- warn ("value %s%x exceeds max (%d) for precision.",
+ log_error ("value %s%x exceeds max (%d) for precision.",
negative ? "-" : "", val, max);
break;
default:
- warn ("value %s%u exceeds max (%d) for precision.",
+ log_error ("value %s%u exceeds max (%d) for precision.",
negative ? "-" : "", val, max);
break;
}
putLong (buf, -(unsigned long)val);
break;
default:
- warn ("Unexpected integer size: %d\n", size);
+ log_error ("Unexpected integer size: %d\n", size);
break;
}
} else {
putULong (buf, val);
break;
default:
- warn ("Unexpected integer size: %d\n", size);
+ log_error ("Unexpected integer size: %d\n", size);
break;
}
}
}
vendor = malloc (strlen (val) + 1);
if (!vendor)
- error ("no memory for vendor information.");
+ log_fatal ("no memory for vendor information.");
strcpy (vendor, val);
token = peek_token (&val, cfile);
if (token == DOT) {
sizeof (struct option_tag),
"parse_cshl");
if (!next)
- error ("no memory for string list.");
+ log_fatal ("no memory for string list.");
memcpy (next -> data, ibuf, ilen);
*last = next;
last = &next -> next;
} while (1);
if (!buffer_allocate (&data -> buffer, tlen + ilen, "parse_cshl"))
- error ("no memory to store octet data.");
+ log_fatal ("no memory to store octet data.");
data -> data = &data -> buffer -> data [0];
data -> len = tlen + ilen;
data -> terminated = 0;
dmalloc (sizeof (struct executable_statement),
"parse_executable_statement"));
if (!stmt)
- error ("no memory for new statement.");
+ log_fatal ("no memory for new statement.");
*stmt = base;
return stmt;
}
dmalloc (sizeof (struct executable_statement),
"parse_if_statement"));
if (!stmt)
- error ("no memory for if statement.");
+ log_fatal ("no memory for if statement.");
memset (stmt, 0, sizeof *stmt);
stmt -> op = if_statement;
stmt -> data.ie.expr = if_condition;
return 0;
}
if (!expression_allocate (expr, "parse_expression: CHECK"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_check;
(*expr) -> data.check = col;
break;
case NOT:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: NOT"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_not;
if (!parse_non_binary (&(*expr) -> data.not,
cfile, lose, context)) {
case EXISTS:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: EXISTS"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_exists;
(*expr) -> data.option = parse_option_name (cfile);
if (!(*expr) -> data.option) {
case SUBSTRING:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: SUBSTRING"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_substring;
token = next_token (&val, cfile);
case SUFFIX:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: SUFFIX"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_suffix;
token = next_token (&val, cfile);
case OPTION:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: OPTION"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_option;
(*expr) -> data.option = parse_option_name (cfile);
if (!(*expr) -> data.option) {
case HARDWARE:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: HARDWARE"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_hardware;
break;
case PACKET:
token = next_token (&val, cfile);
if (!expression_allocate (expr, "parse_expression: PACKET"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
(*expr) -> op = expr_packet;
token = next_token (&val, cfile);
case STRING:
token = next_token (&val, cfile);
if (!make_const_data (expr, val, strlen (val), 1, 1))
- error ("can't make constant string expression.");
+ log_fatal ("can't make constant string expression.");
break;
case EXTRACT_INT:
if (!expression_allocate (expr,
"parse_expression: EXTRACT_INT"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
if (!parse_data_expression (&(*expr) -> data.extract_int,
cfile, lose)) {
case NUMBER:
if (!expression_allocate (expr,
"parse_expression: NUMBER"))
- error ("can't allocate expression");
+ log_fatal ("can't allocate expression");
/* If we're in a numeric context, this should just be a
number, by itself. */
if (next_op == expr_none) {
if (!expression_allocate (expr,
"parse_expression: COMBINE"))
- error ("Can't allocate expression!");
+ log_fatal ("Can't allocate expression!");
(*expr) -> op = binop;
/* All the binary operators' data union members
/* Now combine the LHS and the RHS using binop. */
tmp = (struct expression *)0;
if (!expression_allocate (&tmp, "parse_expression: COMBINE2"))
- error ("No memory for equal precedence combination.");
+ log_fatal ("No memory for equal precedence combination.");
/* Store the LHS and RHS. */
tmp -> data.equal [0] = lhs;
stmt -> op = op;
if (expr && !option_cache (&stmt -> data.option,
(struct data_string *)0, expr, option))
- error ("no memory for option cache in parse_option_statement");
+ log_fatal ("no memory for option cache in parse_option_statement");
return stmt;
}
token = next_token (&val, cfile);
if (!make_const_data (&t, (unsigned char *) val,
strlen (val), 1, 1))
- error ("No memory for concatenation");
+ log_fatal ("No memory for concatenation");
} else {
parse_warn ("expecting string %s.",
"or hexadecimal data");
}
if (!make_const_data (&t, (unsigned char *)val,
strlen (val), 1, 1))
- error ("No memory for concatenation");
+ log_fatal ("No memory for concatenation");
break;
case 'I': /* IP address or hostname. */
break;
default:
- warn ("Bad format %c in parse_option_param.",
+ log_error ("Bad format %c in parse_option_param.",
*fmt);
skip_to_semi (cfile);
return 0;
#ifndef lint
static char copyright[] =
-"$Id: print.c,v 1.19 1999/02/14 18:55:01 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: print.c,v 1.20 1999/02/24 17:56:47 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
struct tm *t;
char tbuf [32];
- debug (" Lease %s",
+ log_debug (" Lease %s",
piaddr (lease -> ip_addr));
t = gmtime (&lease -> starts);
strftime (tbuf, sizeof tbuf, "%Y/%m/%d %H:%M:%S", t);
- debug (" start %s", tbuf);
+ log_debug (" start %s", tbuf);
t = gmtime (&lease -> ends);
strftime (tbuf, sizeof tbuf, "%Y/%m/%d %H:%M:%S", t);
- debug (" end %s", tbuf);
+ log_debug (" end %s", tbuf);
t = gmtime (&lease -> timestamp);
strftime (tbuf, sizeof tbuf, "%Y/%m/%d %H:%M:%S", t);
- debug (" stamp %s", tbuf);
+ log_debug (" stamp %s", tbuf);
- debug (" hardware addr = %s",
+ log_debug (" hardware addr = %s",
print_hw_addr (lease -> hardware_addr.htype,
lease -> hardware_addr.hlen,
lease -> hardware_addr.haddr));
- debug (" host %s ",
+ log_debug (" host %s ",
lease -> host ? lease -> host -> name : "<none>");
}
{
struct dhcp_packet *tdp = tp -> raw;
- debug ("packet length %d", tp -> packet_length);
- debug ("op = %d htype = %d hlen = %d hops = %d",
+ log_debug ("packet length %d", tp -> packet_length);
+ log_debug ("op = %d htype = %d hlen = %d hops = %d",
tdp -> op, tdp -> htype, tdp -> hlen, tdp -> hops);
- debug ("xid = %x secs = %d flags = %x",
+ log_debug ("xid = %x secs = %d flags = %x",
tdp -> xid, tdp -> secs, tdp -> flags);
- debug ("ciaddr = %s", inet_ntoa (tdp -> ciaddr));
- debug ("yiaddr = %s", inet_ntoa (tdp -> yiaddr));
- debug ("siaddr = %s", inet_ntoa (tdp -> siaddr));
- debug ("giaddr = %s", inet_ntoa (tdp -> giaddr));
- debug ("chaddr = %02.2x:%02.2x:%02.2x:%02.2x:%02.2x:%02.2x",
+ log_debug ("ciaddr = %s", inet_ntoa (tdp -> ciaddr));
+ log_debug ("yiaddr = %s", inet_ntoa (tdp -> yiaddr));
+ log_debug ("siaddr = %s", inet_ntoa (tdp -> siaddr));
+ log_debug ("giaddr = %s", inet_ntoa (tdp -> giaddr));
+ log_debug ("chaddr = %02.2x:%02.2x:%02.2x:%02.2x:%02.2x:%02.2x",
((unsigned char *)(tdp -> chaddr)) [0],
((unsigned char *)(tdp -> chaddr)) [1],
((unsigned char *)(tdp -> chaddr)) [2],
((unsigned char *)(tdp -> chaddr)) [3],
((unsigned char *)(tdp -> chaddr)) [4],
((unsigned char *)(tdp -> chaddr)) [5]);
- debug ("filename = %s", tdp -> file);
- debug ("server_name = %s", tdp -> sname);
+ log_debug ("filename = %s", tdp -> file);
+ log_debug ("server_name = %s", tdp -> sname);
if (tp -> options_valid) {
int i;
for (i = 0; i < 256; i++) {
if (tp -> options [i].data)
- debug (" %s = %s",
+ log_debug (" %s = %s",
dhcp_options [i].name,
pretty_print_option
(i, tp -> options [i].data,
tp -> options [i].len, 1, 1));
}
}
- debug ("");
+ log_debug ("");
}
#endif
for (i = 0; i < len; i++) {
if ((i & 15) == 0) {
if (lbix)
- note (lbuf);
+ log_info (lbuf);
sprintf (lbuf, "%03x:", i);
lbix = 4;
} else if ((i & 7) == 0)
sprintf (&lbuf [lbix], " %02x", buf [i]);
lbix += 3;
}
- note (lbuf);
+ log_info (lbuf);
}
void hash_dump (table)
for (i = 0; i < table -> hash_count; i++) {
if (!table -> buckets [i])
continue;
- note ("hash bucket %d:", i);
+ log_info ("hash bucket %d:", i);
for (bp = table -> buckets [i]; bp; bp = bp -> next) {
if (bp -> len)
dump_raw (bp -> name, bp -> len);
else
- note ((char *)bp -> name);
+ log_info ((char *)bp -> name);
}
}
}
char buf [1024];
print_subexpression (expr, buf, sizeof buf);
- note ("%s: %s", name, buf);
+ log_info ("%s: %s", name, buf);
}
#ifndef lint
static char copyright[] =
-"$Id: raw.c,v 1.11 1997/10/20 21:47:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: raw.c,v 1.12 1999/02/24 17:56:47 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* List addresses on which we're listening. */
if (!quiet_interface_discovery)
- note ("Sending on %s, port %d",
+ log_info ("Sending on %s, port %d",
piaddr (info -> address), htons (local_port));
if ((sock = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0)
- error ("Can't create dhcp socket: %m");
+ log_fatal ("Can't create dhcp socket: %m");
/* Set the BROADCAST option so that we can broadcast DHCP responses. */
flag = 1;
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
&flag, sizeof flag) < 0)
- error ("Can't set SO_BROADCAST option on dhcp socket: %m");
+ log_fatal ("Can't set SO_BROADCAST option on dhcp socket: %m");
/* Set the IP_HDRINCL flag so that we can supply our own IP
headers... */
if (setsockopt (sock, IPPROTO_IP, IP_HDRINCL, &flag, sizeof flag) < 0)
- error ("Can't set IP_HDRINCL flag: %m");
+ log_fatal ("Can't set IP_HDRINCL flag: %m");
info -> wfdesc = sock;
if (!quiet_interface_discovery)
- note ("Sending on Raw/%s/%s",
+ log_info ("Sending on Raw/%s/%s",
info -> name,
(info -> shared_network ?
info -> shared_network -> name : "unattached"));
#ifndef lint
static char copyright[] =
-"$Id: resolv.c,v 1.6 1998/01/12 01:01:44 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: resolv.c,v 1.7 1999/02/24 17:56:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
eol_token = 1;
if ((cfile = fopen (path_resolv_conf, "r")) == NULL) {
- warn ("Can't open %s: %m", path_resolv_conf);
+ log_error ("Can't open %s: %m", path_resolv_conf);
return;
}
nd = new_domain_search_list
("read_resolv_conf");
if (!nd)
- error ("No memory for %s", dn);
+ log_fatal ("No memory for %s", dn);
nd -> next =
(struct domain_search_list *)0;
*dp = nd;
if (!ns) {
ns = new_name_server ("read_resolv_conf");
if (!ns)
- error ("No memory for nameserver %s",
+ log_fatal ("No memory for nameserver %s",
piaddr (iaddr));
ns -> next = (struct name_server *)0;
*sp = ns;
/* Check /etc/resolv.conf and reload it if it's changed. */
if (cur_time > rcdate) {
if (stat (path_resolv_conf, &st) < 0) {
- warn ("Can't stat %s", path_resolv_conf);
+ log_error ("Can't stat %s", path_resolv_conf);
return (struct name_server *)0;
}
if (st.st_mtime > rcdate) {
#ifndef lint
static char copyright[] =
-"$Id: socket.c,v 1.29 1999/02/14 19:40:21 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: socket.c,v 1.30 1999/02/24 17:56:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#if !defined (SO_BINDTODEVICE) && !defined (USE_FALLBACK)
/* Make sure only one interface is registered. */
if (once)
- error ("The standard socket API can only support %s",
+ log_fatal ("The standard socket API can only support %s",
"hosts with a single network interface.");
once = 1;
#endif
/* Make a socket... */
if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
- error ("Can't create dhcp socket: %m");
+ log_fatal ("Can't create dhcp socket: %m");
/* Set the REUSEADDR option so that we don't fail to start if
we're being restarted. */
flag = 1;
if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,
(char *)&flag, sizeof flag) < 0)
- error ("Can't set SO_REUSEADDR option on dhcp socket: %m");
+ log_fatal ("Can't set SO_REUSEADDR option on dhcp socket: %m");
/* Set the BROADCAST option so that we can broadcast DHCP responses. */
if (setsockopt (sock, SOL_SOCKET, SO_BROADCAST,
(char *)&flag, sizeof flag) < 0)
- error ("Can't set SO_BROADCAST option on dhcp socket: %m");
+ log_fatal ("Can't set SO_BROADCAST option on dhcp socket: %m");
/* Bind the socket to this interface's IP address. */
if (bind (sock, (struct sockaddr *)&name, sizeof name) < 0)
- error ("Can't bind to dhcp address: %m");
+ log_fatal ("Can't bind to dhcp address: %m");
#if defined (SO_BINDTODEVICE)
/* Bind this socket to this interface. */
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
- note ("Sending on Socket/%s/%s",
+ log_info ("Sending on Socket/%s/%s",
info -> name,
(info -> shared_network ?
info -> shared_network -> name : "unattached"));
we don't need to register this interface twice. */
info -> rfdesc = if_register_socket (info);
if (!quiet_interface_discovery)
- note ("Listening on Socket/%s/%s",
+ log_info ("Listening on Socket/%s/%s",
info -> name,
(info -> shared_network ?
info -> shared_network -> name : "unattached"));
status = recvfrom (interface -> wfdesc, buf, sizeof buf, 0,
(struct sockaddr *)&from, &flen);
if (status < 0)
- warn ("fallback_discard: %m");
+ log_error ("fallback_discard: %m");
}
#endif /* USE_SOCKET_SEND */
#ifndef lint
static char copyright[] =
-"$Id: sysconf.c,v 1.4 1998/03/16 06:14:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: sysconf.c,v 1.5 1999/02/24 17:56:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Only initialize sysconf once. */
if (sysconf_initialized)
- error ("attempted to reinitialize sysconf protocol");
+ log_fatal ("attempted to reinitialize sysconf protocol");
sysconf_initialized = 1;
sysconf_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (sysconf_fd < 0)
- error ("unable to create sysconf socket: %m");
+ log_fatal ("unable to create sysconf socket: %m");
/* XXX for now... */
name.sun_family = PF_UNIX;
if (connect (sysconf_fd, (struct sockaddr *)&name, len) < 0) {
if (!once)
- warn ("can't connect to sysconf socket: %m");
+ log_error ("can't connect to sysconf socket: %m");
once = 1;
close (sysconf_fd);
sysconf_initialized = 0;
status = read (sysconf_fd, &hdr, sizeof hdr);
if (status < 0) {
- warn ("sysconf_message: %m");
+ log_error ("sysconf_message: %m");
lose:
add_timeout (cur_time + 60, sysconf_restart, proto -> local);
remove_protocol (proto);
return;
}
if (status < sizeof (hdr)) {
- warn ("sysconf_message: short message");
+ log_error ("sysconf_message: short message");
goto lose;
}
if (hdr.length) {
buf = malloc (hdr.length);
if (!buf)
- error ("sysconf_message: can't buffer payload");
+ log_fatal ("sysconf_message: can't buffer payload");
status = read (sysconf_fd, buf, hdr.length);
if (status < 0)
- error ("sysconf_message payload read: %m");
+ log_fatal ("sysconf_message payload read: %m");
if (status != hdr.length)
- error ("sysconf_message payload: short read");
+ log_fatal ("sysconf_message payload: short read");
} else
buf = (char *)0;
#ifndef lint
static char copyright[] =
-"$Id: tables.c,v 1.18 1999/02/14 18:56:37 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: tables.c,v 1.19 1999/02/24 17:56:48 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
dhcp_universe.set_func = dhcp_option_set;
dhcp_universe.hash = new_hash ();
if (!dhcp_universe.hash)
- error ("Can't allocate dhcp option hash table.");
+ log_fatal ("Can't allocate dhcp option hash table.");
for (i = 0; i < 256; i++) {
dhcp_universe.options [i] = &dhcp_options [i];
add_hash (dhcp_universe.hash,
agent_universe.lookup_func = agent_suboption_lookup;
agent_universe.hash = new_hash ();
if (!agent_universe.hash)
- error ("Can't allocate agent option hash table.");
+ log_fatal ("Can't allocate agent option hash table.");
for (i = 0; i < 256; i++) {
agent_universe.options [i] = &agent_options [i];
add_hash (agent_universe.hash,
server_universe.set_func = server_option_set;
server_universe.hash = new_hash ();
if (!server_universe.hash)
- error ("Can't allocate server option hash table.");
+ log_fatal ("Can't allocate server option hash table.");
for (i = 0; i < 256; i++) {
server_universe.options [i] = &server_options [i];
add_hash (server_universe.hash,
#ifndef lint
static char copyright[] =
-"$Id: tree.c,v 1.18 1998/11/09 02:45:02 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: tree.c,v 1.19 1999/02/24 17:56:48 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
{
pair foo = (pair)dmalloc (sizeof *foo, "cons");
if (!foo)
- error ("no memory for cons.");
+ log_fatal ("no memory for cons.");
foo -> car = car;
foo -> cdr = cdr;
return foo;
} else {
bp = (struct buffer *)0;
if (!buffer_allocate (&bp, len, name)) {
- warn ("%s: can't allocate buffer.", name);
+ log_error ("%s: can't allocate buffer.", name);
return 0;
}
}
if (!option_cache_allocate (oc, name)) {
- warn ("%s: can't allocate option cache.");
+ log_error ("%s: can't allocate option cache.");
buffer_dereference (&bp, name);
return 0;
}
char *name;
{
if (!expression_allocate (expr, "make_host_lookup")) {
- warn ("No memory for host lookup tree node.");
+ log_error ("No memory for host lookup tree node.");
return 0;
}
(*expr) -> op = expr_host_lookup;
XXX already exists, if possible, rather than creating
XXX a new structure. */
if (!dns_host_entry_allocate (dh, name, "enter_dns_host")) {
- warn ("Can't allocate space for new host.");
+ log_error ("Can't allocate space for new host.");
return 0;
}
return 1;
struct expression *nt;
if (!expression_allocate (expr, "make_host_lookup")) {
- warn ("No memory for make_const_data tree node.");
+ log_error ("No memory for make_const_data tree node.");
return 0;
}
nt = *expr;
if (!buffer_allocate (&nt -> data.const_data.buffer,
len + terminated,
"make_const_data")) {
- warn ("Can't allocate const_data buffer.");
+ log_error ("Can't allocate const_data buffer.");
expression_dereference (expr,
"make_const_data");
return 0;
/* Otherwise, allocate a new node to concatenate the two. */
if (!expression_allocate (expr, "make_concat")) {
- warn ("No memory for concatenation expression node.");
+ log_error ("No memory for concatenation expression node.");
return 0;
}
{
/* Allocate an expression node to compute the substring. */
if (!expression_allocate (new, "make_substring")) {
- warn ("no memory for substring expression.");
+ log_error ("no memory for substring expression.");
return 0;
}
(*new) -> op = expr_substring;
/* Allocate a node to enforce a limit on evaluation. */
if (!expression_allocate (new, "make_limit"))
- warn ("no memory for limit expression");
+ log_error ("no memory for limit expression");
(*new) -> op = expr_substring;
expression_reference (&(*new) -> data.substring.expr,
expr, "make_limit");
/* Offset is a constant 0. */
if (!expression_allocate (&(*new) -> data.substring.offset,
"make_limit")) {
- warn ("no memory for limit offset expression");
+ log_error ("no memory for limit offset expression");
expression_dereference (new, "make_limit");
return 0;
}
/* Length is a constant: the specified limit. */
if (!expression_allocate (&(*new) -> data.substring.len,
"make_limit")) {
- warn ("no memory for limit length expression");
+ log_error ("no memory for limit length expression");
expression_dereference (new, "make_limit");
return 0;
}
int new_len;
#ifdef DEBUG_EVAL
- debug ("time: now = %d dns = %d %d diff = %d",
+ log_debug ("time: now = %d dns = %d %d diff = %d",
cur_time, dns -> timeout, cur_time - dns -> timeout);
#endif
/* If the record hasn't timed out, just copy the data and return. */
if (cur_time <= dns -> timeout) {
#ifdef DEBUG_EVAL
- debug ("easy copy: %d %s",
+ log_debug ("easy copy: %d %s",
dns -> data.len,
(dns -> data.len > 4
? inet_ntoa (*(struct in_addr *)(dns -> data.data))
return 1;
}
#ifdef DEBUG_EVAL
- debug ("Looking up %s", dns -> hostname);
+ log_debug ("Looking up %s", dns -> hostname);
#endif
/* Otherwise, look it up... */
switch (h_errno) {
case HOST_NOT_FOUND:
#endif
- warn ("%s: host unknown.", dns -> hostname);
+ log_error ("%s: host unknown.", dns -> hostname);
#ifndef NO_H_ERRNO
break;
case TRY_AGAIN:
- warn ("%s: temporary name server failure",
+ log_error ("%s: temporary name server failure",
dns -> hostname);
break;
case NO_RECOVERY:
- warn ("%s: name server failed", dns -> hostname);
+ log_error ("%s: name server failed", dns -> hostname);
break;
case NO_DATA:
- warn ("%s: no A record associated with address",
+ log_error ("%s: no A record associated with address",
dns -> hostname);
}
#endif /* !NO_H_ERRNO */
}
#ifdef DEBUG_EVAL
- debug ("Lookup succeeded; first address is %s",
+ log_debug ("Lookup succeeded; first address is %s",
inet_ntoa (h -> h_addr_list [0]));
#endif
new_len = count * h -> h_length;
if (!buffer_allocate (&dns -> data.buffer, new_len, "do_host_lookup"))
{
- warn ("No memory for %s.", dns -> hostname);
+ log_error ("No memory for %s.", dns -> hostname);
return 0;
}
h -> h_addr_list [i], h -> h_length);
}
#ifdef DEBUG_EVAL
- debug ("dns -> data: %x h -> h_addr_list [0]: %x",
+ log_debug ("dns -> data: %x h -> h_addr_list [0]: %x",
*(int *)(dns -> buffer), h -> h_addr_list [0]);
#endif
dns -> timeout = cur_time + 3600;
#ifdef DEBUG_EVAL
- debug ("hard copy: %d %s", dns -> data.len,
+ log_debug ("hard copy: %d %s", dns -> data.len,
(dns -> data.len > 4
? inet_ntoa (*(struct in_addr *)(dns -> data.data)) : 0));
#endif
case expr_check:
*result = check_collection (packet, expr -> data.check);
#if defined (DEBUG_EXPRESSIONS)
- note ("bool: check (%s) returns %s",
+ log_info ("bool: check (%s) returns %s",
expr -> data.check -> name, *result ? "true" : "false");
#endif
return 1;
}
#if defined (DEBUG_EXPRESSIONS)
- note ("bool: equal (%s, %s) = %s",
+ log_info ("bool: equal (%s, %s) = %s",
sleft ? print_hex_1 (left.len, left.data, 30) : "NULL",
sright ? print_hex_2 (right.len,
right.data, 30) : "NULL",
expr -> data.and [1]);
#if defined (DEBUG_EXPRESSIONS)
- note ("bool: and (%s, %s) = %s",
+ log_info ("bool: and (%s, %s) = %s",
sleft ? (bleft ? "true" : "false") : "NULL",
sright ? (bright ? "true" : "false") : "NULL",
((sleft && sright)
sright = evaluate_boolean_expression (&bright, packet, options,
expr -> data.or [1]);
#if defined (DEBUG_EXPRESSIONS)
- note ("bool: or (%s, %s) = %s",
+ log_info ("bool: or (%s, %s) = %s",
sleft ? (bleft ? "true" : "false") : "NULL",
sright ? (bright ? "true" : "false") : "NULL",
((sleft && sright)
sleft = evaluate_boolean_expression (&bleft, packet, options,
expr -> data.not);
#if defined (DEBUG_EXPRESSIONS)
- note ("bool: not (%s) = %s",
+ log_info ("bool: not (%s) = %s",
sleft ? (bleft ? "true" : "false") : "NULL",
((sleft && sright)
? (!bleft ? "true" : "false") : "NULL"));
"evaluate_boolean_expression");
}
#if defined (DEBUG_EXPRESSIONS)
- note ("data: exists %s.%s = %s",
+ log_info ("data: exists %s.%s = %s",
expr -> data.option -> universe -> name,
expr -> data.option -> name, *result ? "true" : "false");
#endif
case expr_packet:
case expr_concat:
case expr_host_lookup:
- warn ("Data opcode in evaluate_boolean_expression: %d",
+ log_error ("Data opcode in evaluate_boolean_expression: %d",
expr -> op);
return 0;
case expr_extract_int16:
case expr_extract_int32:
case expr_const_int:
- warn ("Numeric opcode in evaluate_boolean_expression: %d",
+ log_error ("Numeric opcode in evaluate_boolean_expression: %d",
expr -> op);
return 0;
}
- warn ("Bogus opcode in evaluate_boolean_expression: %d", expr -> op);
+ log_error ("Bogus opcode in evaluate_boolean_expression: %d", expr -> op);
return 0;
}
s3 = 0;
#if defined (DEBUG_EXPRESSIONS)
- note ("data: substring (%s, %s, %s) = %s",
+ log_info ("data: substring (%s, %s, %s) = %s",
s0 ? print_hex_1 (data.len, data.data, 30) : "NULL",
s1 ? print_dec_1 (offset) : "NULL",
s2 ? print_dec_2 (len) : "NULL",
}
#if defined (DEBUG_EXPRESSIONS)
- note ("data: suffix (%s, %d) = %s",
+ log_info ("data: suffix (%s, %d) = %s",
s0 ? print_hex_1 (data.len, data.data, 30) : "NULL",
s1 ? print_dec_1 (len) : "NULL",
((s0 && s1)
s0 = ((*expr -> data.option -> universe -> lookup_func)
(result, options, expr -> data.option -> code));
#if defined (DEBUG_EXPRESSIONS)
- note ("data: option %s.%s = %s",
+ log_info ("data: option %s.%s = %s",
expr -> data.option -> universe -> name,
expr -> data.option -> name,
s0 ? print_hex_1 (result -> len, result -> data, 60)
/* Combine the hardware type and address. */
case expr_hardware:
if (!packet || !packet -> raw) {
- warn ("data: hardware: raw packet not available");
+ log_error ("data: hardware: raw packet not available");
return 0;
}
result -> len = packet -> raw -> hlen + 1;
packet -> raw -> hlen);
result -> terminated = 0;
} else {
- warn ("data: hardware: no memory for buffer.");
+ log_error ("data: hardware: no memory for buffer.");
return 0;
}
#if defined (DEBUG_EXPRESSIONS)
- note ("data: hardware = %s",
+ log_info ("data: hardware = %s",
print_hex_1 (result -> len, result -> data, 60));
#endif
return 1;
/* Extract part of the raw packet. */
case expr_packet:
if (!packet || !packet -> raw) {
- warn ("data: packet: raw packet not available");
+ log_error ("data: packet: raw packet not available");
return 0;
}
+ offset), result -> len);
result -> terminated = 0;
} else {
- warn ("data: packet: no memory for buffer.");
+ log_error ("data: packet: no memory for buffer.");
return 0;
}
s2 = 1;
} else
s2 = 0;
#if defined (DEBUG_EXPRESSIONS)
- note ("data: packet (%d, %d) = %s",
+ log_info ("data: packet (%d, %d) = %s",
offset, len,
s2 ? print_hex_1 (result -> len,
result -> data, 60) : NULL);
/* Some constant data... */
case expr_const_data:
#if defined (DEBUG_EXPRESSIONS)
- note ("data: const = %s",
+ log_info ("data: const = %s",
print_hex_1 (expr -> data.const_data.len,
expr -> data.const_data.data, 60));
#endif
case expr_host_lookup:
s0 = do_host_lookup (result, expr -> data.host_lookup);
#if defined (DEBUG_EXPRESSIONS)
- note ("data: DNS lookup (%s) = %s",
+ log_info ("data: DNS lookup (%s) = %s",
expr -> data.host_lookup -> hostname,
(s0
? print_dotted_quads (result -> len, result -> data)
(result -> len +
other.terminated),
"expr_concat")) {
- warn ("data: concat: no memory");
+ log_error ("data: concat: no memory");
result -> len = 0;
data_string_forget (&data, "expr_concat");
data_string_forget (&other, "expr_concat");
else if (s1)
data_string_copy (result, &other, "expr_concat");
#if defined (DEBUG_EXPRESSIONS)
- note ("data: concat (%s, %s) = %s",
+ log_info ("data: concat (%s, %s) = %s",
s0 ? print_hex_1 (data.len, data.data, 20) : "NULL",
s1 ? print_hex_2 (other.len, other.data, 20) : "NULL",
((s0 || s1)
case expr_or:
case expr_not:
case expr_match:
- warn ("Boolean opcode in evaluate_data_expression: %d",
+ log_error ("Boolean opcode in evaluate_data_expression: %d",
expr -> op);
return 0;
case expr_extract_int16:
case expr_extract_int32:
case expr_const_int:
- warn ("Numeric opcode in evaluate_data_expression: %d",
+ log_error ("Numeric opcode in evaluate_data_expression: %d",
expr -> op);
return 0;
}
- warn ("Bogus opcode in evaluate_data_expression: %d", expr -> op);
+ log_error ("Bogus opcode in evaluate_data_expression: %d", expr -> op);
return 0;
}
case expr_or:
case expr_not:
case expr_match:
- warn ("Boolean opcode in evaluate_numeric_expression: %d",
+ log_error ("Boolean opcode in evaluate_numeric_expression: %d",
expr -> op);
return 0;
case expr_packet:
case expr_concat:
case expr_host_lookup:
- warn ("Data opcode in evaluate_numeric_expression: %d",
+ log_error ("Data opcode in evaluate_numeric_expression: %d",
expr -> op);
return 0;
if (status)
*result = data.data [0];
#if defined (DEBUG_EXPRESSIONS)
- note ("num: extract_int8 (%s) = %s",
+ log_info ("num: extract_int8 (%s) = %s",
status ? print_hex_1 (data.len, data.data, 60) : "NULL",
status ? print_dec_1 (*result) : "NULL" );
#endif
if (status && data.len >= 2)
*result = getUShort (data.data);
#if defined (DEBUG_EXPRESSIONS)
- note ("num: extract_int16 (%s) = %ld",
+ log_info ("num: extract_int16 (%s) = %ld",
((status && data.len >= 2) ?
print_hex_1 (data.len, data.data, 60) : "NULL"),
*result);
if (status && data.len >= 4)
*result = getULong (data.data);
#if defined (DEBUG_EXPRESSIONS)
- note ("num: extract_int32 (%s) = %ld",
+ log_info ("num: extract_int32 (%s) = %ld",
((status && data.len >= 4) ?
print_hex_1 (data.len, data.data, 60) : "NULL"),
*result);
return 1;
}
- warn ("Bogus opcode in evaluate_numeric_expression: %d", expr -> op);
+ log_error ("Bogus opcode in evaluate_numeric_expression: %d", expr -> op);
return 0;
}
if (--(expr -> refcnt) > 0)
return;
if (expr -> refcnt < 0) {
- warn ("expression_dereference: negative refcnt!");
+ log_error ("expression_dereference: negative refcnt!");
abort ();
}
#ifndef lint
static char copyright[] =
-"$Id: upf.c,v 1.4 1999/02/14 18:57:19 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: upf.c,v 1.5 1999/02/24 17:56:49 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (errno == EBUSY) {
continue;
} else {
- error ("Can't find free upf: %m");
+ log_fatal ("Can't find free upf: %m");
}
} else {
break;
/* Set the UPF device to point at this interface. */
if (ioctl (sock, EIOCSETIF, info -> ifp) < 0)
- error ("Can't attach interface %s to upf device %s: %m",
+ log_fatal ("Can't attach interface %s to upf device %s: %m",
info -> name, filename);
/* Get the hardware address. */
if (ioctl (sock, EIOCDEVP, ¶m) < 0)
- error ("Can't get interface %s hardware address: %m",
+ log_fatal ("Can't get interface %s hardware address: %m",
info -> name);
/* We only know how to do ethernet. */
if (param.end_dev_type != ENDT_10MB)
- error ("Invalid device type on network interface %s: %d",
+ log_fatal ("Invalid device type on network interface %s: %d",
info -> name, param.end_dev_type);
if (param.end_addr_len != 6)
- error ("Invalid hardware address length on %s: %d",
+ log_fatal ("Invalid hardware address length on %s: %d",
info -> name, param.end_addr_len);
info -> hw_address.hlen = 6;
info -> wfdesc = info -> rfdesc;
#endif
if (!quiet_interface_discovery)
- note ("Sending on UPF/%s/%s/%s",
+ log_info ("Sending on UPF/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
/* Allow the copyall flag to be set... */
if (ioctl(info -> rfdesc, EIOCALLOWCOPYALL, &flag) < 0)
- error ("Can't set ALLOWCOPYALL: %m");
+ log_fatal ("Can't set ALLOWCOPYALL: %m");
/* Clear all the packet filter mode bits first... */
flag = (ENHOLDSIG | ENBATCH | ENTSTAMP | ENPROMISC |
ENNONEXCL | ENCOPYALL);
if (ioctl (info -> rfdesc, EIOCMBIC, &flag) < 0)
- error ("Can't clear pfilt bits: %m");
+ log_fatal ("Can't clear pfilt bits: %m");
/* Set the ENBATCH and ENCOPYALL bits... */
bits = ENBATCH | ENCOPYALL;
if (ioctl (info -> rfdesc, EIOCMBIS, &bits) < 0)
- error ("Can't set ENBATCH|ENCOPYALL: %m");
+ log_fatal ("Can't set ENBATCH|ENCOPYALL: %m");
/* Set up the UPF filter program. */
/* XXX Unlike the BPF filter program, this one won't work if the
pf.enf_Filter [pf.enf_FilterLen++] = local_port;
if (ioctl (info -> rfdesc, EIOCSETF, &pf) < 0)
- error ("Can't install packet filter program: %m");
+ log_fatal ("Can't install packet filter program: %m");
if (!quiet_interface_discovery)
- note ("Listening on UPF/%s/%s/%s",
+ log_info ("Listening on UPF/%s/%s/%s",
info -> name,
print_hw_addr (info -> hw_address.htype,
info -> hw_address.hlen,
#ifndef lint
static char copyright[] =
-"$Id: dhcpctl.c,v 1.1 1998/04/09 05:20:14 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcpctl.c,v 1.2 1999/02/24 17:56:49 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
dhcpctl_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (dhcpctl_fd < 0)
- error ("unable to create dhcpctl socket: %m");
+ log_fatal ("unable to create dhcpctl socket: %m");
/* XXX for now... */
name.sun_family = PF_UNIX;
strlen (name.sun_path));
if (connect (dhcpctl_fd, (struct sockaddr *)&name, len) < 0)
- error ("can't connect to dhcpctl socket: %m");
+ log_fatal ("can't connect to dhcpctl socket: %m");
#if 0
if ((arg = fcntl (dhcpctl_fd, F_GETFL, 0)) < 0)
- error ("Can't get flags on socket: %m");
+ log_fatal ("Can't get flags on socket: %m");
arg |= O_ASYNC;
if (fcntl (dhcpctl_fd, F_SETFL, arg) < 0)
- error ("Can't set flags on socket: %m");
+ log_fatal ("Can't set flags on socket: %m");
#endif
dhcpctl = fdopen (dhcpctl_fd, "r+");
if (!dhcpctl)
- error ("Can't fdopen dhcpctl socket: %m");
+ log_fatal ("Can't fdopen dhcpctl socket: %m");
setlinebuf (dhcpctl);
/* Read the response. */
/* errwarn.c */
extern int warnings_occurred;
-void error PROTO ((char *, ...));
-int warn PROTO ((char *, ...));
-int note PROTO ((char *, ...));
-int debug PROTO ((char *, ...));
+void log_fatal PROTO ((char *, ...));
+int log_error PROTO ((char *, ...));
+int log_info PROTO ((char *, ...));
+int log_debug PROTO ((char *, ...));
int parse_warn PROTO ((char *, ...));
/* dhcpd.c */
#ifndef lint
static char ocopyright[] =
-"$Id: dhcrelay.c,v 1.18 1999/02/14 19:40:22 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcrelay.c,v 1.19 1999/02/24 17:56:50 mellon Exp $ Copyright (c) 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (++i == argc)
usage ();
local_port = htons (atoi (argv [i]));
- debug ("binding to user-specified port %d",
+ log_debug ("binding to user-specified port %d",
ntohs (local_port));
} else if (!strcmp (argv [i], "-d")) {
no_daemon = 1;
((struct interface_info *)
dmalloc (sizeof *tmp, "specified_interface"));
if (!tmp)
- error ("Insufficient memory to %s %s",
+ log_fatal ("Insufficient memory to %s %s",
"record interface", argv [i]);
if (++i == argc) {
usage ();
} else {
he = gethostbyname (argv [i]);
if (!he) {
- warn ("%s: host unknown", argv [i]);
+ log_error ("%s: host unknown", argv [i]);
} else {
iap = ((struct in_addr *)
he -> h_addr_list [0]);
if (iap) {
sp = (struct server_list *)malloc (sizeof *sp);
if (!sp)
- error ("no memory for server.\n");
+ log_fatal ("no memory for server.\n");
sp -> next = servers;
servers = sp;
memcpy (&sp -> to.sin_addr,
}
if (!quiet) {
- note (message);
- note (copyright);
- note (arr);
- note (contrib);
- note (url);
+ log_info (message);
+ log_info (copyright);
+ log_info (arr);
+ log_info (contrib);
+ log_info (url);
}
/* Default to the DHCP/BOOTP port. */
log_perror = 0;
if ((pid = fork()) < 0)
- error ("can't fork daemon: %m");
+ log_fatal ("can't fork daemon: %m");
else if (pid)
exit (0);
O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (pfdesc < 0) {
- warn ("Can't create %s: %m", path_dhcrelay_pid);
+ log_error ("Can't create %s: %m", path_dhcrelay_pid);
} else {
pf = fdopen (pfdesc, "w");
if (!pf)
- warn ("Can't fdopen %s: %m",
+ log_error ("Can't fdopen %s: %m",
path_dhcrelay_pid);
else {
fprintf (pf, "%ld\n", (long)getpid ());
struct hardware hto;
if (packet -> hlen > sizeof packet -> chaddr) {
- note ("Discarding packet with invalid hlen.");
+ log_info ("Discarding packet with invalid hlen.");
return;
}
return;
if (!out) {
- warn ("packet to bogus giaddr %s.\n",
+ log_error ("packet to bogus giaddr %s.\n",
inet_ntoa (packet -> giaddr));
++bogus_giaddr_drops;
return;
(struct packet *)0,
packet, length, out -> primary_address,
&to, &hto) < 0) {
- debug ("sendpkt: %m");
+ log_debug ("sendpkt: %m");
++server_packet_errors;
} else {
- debug ("forwarded BOOTREPLY for %s to %s",
+ log_debug ("forwarded BOOTREPLY for %s to %s",
print_hw_addr (packet -> htype, packet -> hlen,
packet -> chaddr),
inet_ntoa (to.sin_addr));
(struct packet *)0,
packet, length, ip -> primary_address,
&sp -> to, (struct hardware *)0) < 0) {
- debug ("send_packet: %m");
+ log_debug ("send_packet: %m");
++client_packet_errors;
} else {
- debug ("forwarded BOOTREQUEST for %s to %s",
+ log_debug ("forwarded BOOTREQUEST for %s to %s",
print_hw_addr (packet -> htype, packet -> hlen,
packet -> chaddr),
inet_ntoa (sp -> to.sin_addr));
static void usage ()
{
- error ("Usage: dhcrelay [-p <port>] [-d] [-D] [-i interface]\n%s%s%s",
+ log_fatal ("Usage: dhcrelay [-p <port>] [-d] [-D] [-i interface]\n%s%s%s",
" ",
"[-q] [-a] [-A length] [-m append|replace|forward|discard]\n",
" [server1 [... serverN]]");
*sp++ = RAI_CIRCUIT_ID;
/* Sanity check. Had better not every happen. */
if (ip -> circuit_id_len > 255 || ip -> circuit_id_len < 1)
- error ("completely bogus circuit id length %d on %s\n",
+ log_fatal ("completely bogus circuit id length %d on %s\n",
ip -> circuit_id_len, ip -> name);
*sp++ = ip -> circuit_id_len;
memcpy (sp, ip -> circuit_id, ip -> circuit_id_len);
if (ip -> remote_id) {
*sp++ = RAI_REMOTE_ID;
if (ip -> remote_id_len > 255 || ip -> remote_id_len < 1)
- error ("completely bogus remote id length %d on %s\n",
+ log_fatal ("completely bogus remote id length %d on %s\n",
ip -> circuit_id_len, ip -> name);
*sp++ = ip -> remote_id_len;
memcpy (sp, ip -> remote_id, ip -> remote_id_len);
/* Relay option's total length shouldn't ever get to be more than
257 bytes. */
if (sp - op > 257)
- error ("total agent option length exceeds 257 (%d) on %s\n",
+ log_fatal ("total agent option length exceeds 257 (%d) on %s\n",
sp - op, ip -> name);
/* Calculate length of RAI option. */
#ifndef lint
static char copyright[] =
-"$Id: bootp.c,v 1.37 1999/02/14 19:40:22 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bootp.c,v 1.38 1999/02/24 17:56:50 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
if (!locate_network (packet)) {
- note ("%s: network unknown", msgbuf);
+ log_info ("%s: network unknown", msgbuf);
return;
}
ack_lease (packet, lease, 0, 0, msgbuf);
return;
}
- note ("%s: no available leases", msgbuf);
+ log_info ("%s: no available leases", msgbuf);
return;
}
if (evaluate_boolean_option_cache (packet, &options,
lookup_option (options.dhcp_hash,
SV_ALLOW_BOOTP))) {
- note ("%s: bootp disallowed", msgbuf);
+ log_info ("%s: bootp disallowed", msgbuf);
return;
}
if (evaluate_boolean_option_cache (packet, &options,
lookup_option (options.dhcp_hash,
SV_ALLOW_BOOTING))) {
- note ("%s: booting disallowed", msgbuf);
+ log_info ("%s: booting disallowed", msgbuf);
return;
}
from = packet -> interface -> primary_address;
/* Report what we're doing... */
- note ("%s", msgbuf);
- note ("BOOTREPLY for %s to %s (%s) via %s",
+ log_info ("%s", msgbuf);
+ log_info ("BOOTREPLY for %s to %s (%s) via %s",
piaddr (ip_address), hp -> name,
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
&raw, outgoing.packet_length,
from, &to, &hto);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
return;
}
/* Otherwise, broadcast it on the local network. */
packet, &raw, outgoing.packet_length,
from, &to, &hto);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
}
#ifndef lint
static char copyright[] =
-"$Id: class.c,v 1.7 1998/11/11 07:58:35 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
+"$Id: class.c,v 1.8 1999/02/24 17:56:51 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
me = (struct expression *)dmalloc (sizeof (struct expression),
"default check expression");
if (!me)
- error ("Can't allocate default check expression");
+ log_fatal ("Can't allocate default check expression");
memset (me, 0, sizeof *me);
me -> op = expr_check;
me -> data.check = &default_collection;
dmalloc (sizeof (struct executable_statement),
"add default collection check rule");
if (!rules)
- error ("Can't allocate check of default collection");
+ log_fatal ("Can't allocate check of default collection");
memset (rules, 0, sizeof *rules);
rules -> op = eval_statement;
rules -> data.eval = me;
for (class = collection -> classes; class; class = class -> nic) {
#if defined (DEBUG_CLASS_MATCHING)
- note ("checking against class %s...", class -> name);
+ log_info ("checking against class %s...", class -> name);
#endif
memset (&data, 0, sizeof data);
/* If a class is for billing, don't put the client in the
data.data,
data.len)))) {
#if defined (DEBUG_CLASS_MATCHING)
- note ("matches subclass %s.",
+ log_info ("matches subclass %s.",
print_hex_1 (data.len,
data.data, 60));
#endif
continue;
}
#if defined (DEBUG_CLASS_MATCHING)
- note ("spawning subclass %s.",
+ log_info ("spawning subclass %s.",
print_hex_1 (data.len, data.data, 60));
#endif
nc = (struct class *)
sizeof (struct lease *),
"check_collection"));
if (!nc -> billed_leases) {
- warn ("no memory for billing");
+ log_error ("no memory for billing");
data_string_forget
(&nc -> hash_string,
"check_collection");
if (status) {
matched = 1;
#if defined (DEBUG_CLASS_MATCHING)
- note ("matches class.");
+ log_info ("matches class.");
#endif
classify (packet, class);
}
if (packet -> class_count < PACKET_MAX_CLASSES)
packet -> classes [packet -> class_count++] = class;
else
- warn ("too many groups for %s",
+ log_error ("too many groups for %s",
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr));
if (class -> billed_leases [i] == lease)
break;
if (i == class -> lease_limit) {
- warn ("lease %s unbilled with no billing arrangement.",
+ log_error ("lease %s unbilled with no billing arrangement.",
piaddr (lease -> ip_addr));
return 0;
}
break;
if (i == class -> lease_limit) {
- warn ("class billing consumption disagrees with leases.");
+ log_error ("class billing consumption disagrees with leases.");
return 0;
}
#ifndef lint
static char copyright[] =
-"$Id: confpars.c,v 1.59 1999/02/23 19:07:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: confpars.c,v 1.60 1999/02/24 17:56:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
root_group.authoritative = 0;
if ((cfile = fopen (path_dhcpd_conf, "r")) == NULL)
- error ("Can't open %s: %m", path_dhcpd_conf);
+ log_fatal ("Can't open %s: %m", path_dhcpd_conf);
do {
token = peek_token (&val, cfile);
if (token == EOF)
thinking that no leases have been assigned to anybody, which
could create severe network chaos. */
if ((cfile = fopen (path_dhcpd_db, "r")) == NULL)
- error ("Can't open lease database %s: %m -- %s",
+ log_fatal ("Can't open lease database %s: %m -- %s",
path_dhcpd_db,
"check for failed database rewrite attempt!");
do {
if (token == EOF)
break;
if (token != LEASE) {
- warn ("Corrupt lease file - possible data loss!");
+ log_error ("Corrupt lease file - possible data loss!");
skip_to_semi (cfile);
} else {
struct lease *lease;
share = new_shared_network ("parse_statement");
if (!share)
- error ("No memory for shared subnet");
+ log_fatal ("No memory for shared subnet");
share -> group = clone_group (group, "parse_statement:subnet");
share -> group -> shared_network = share;
n = piaddr (share -> subnets -> net);
t = malloc (strlen (n) + 1);
if (!t)
- error ("no memory for subnet name");
+ log_fatal ("no memory for subnet name");
strcpy (t, n);
share -> name = t;
et = (struct executable_statement *)dmalloc (sizeof *et,
"allow/deny");
if (!et)
- error ("no memory for %s statement",
+ log_fatal ("no memory for %s statement",
token == ALLOW ? "allow" : "deny");
memset (et, 0, sizeof *et);
et -> op = supersede_option_statement;
if (is_identifier (token) || token == STRING) {
name = dmalloc (strlen (name) + 1, "peer name");
if (!peer -> name)
- error ("no memory for peer name %s", name);
+ log_fatal ("no memory for peer name %s", name);
} else {
parse_warn ("expecting identifier or left brace");
skip_to_semi (cfile);
peer = new_failover_peer ("parse_failover_peer");
if (!peer)
- error ("no memory for %sfailover peer%s%s.",
+ log_fatal ("no memory for %sfailover peer%s%s.",
name ? "" : "anonymous", name ? " " : "", name);
/* Save the name. */
pool = new_pool ("parse_pool_statement");
if (!pool)
- error ("no memory for pool.");
+ log_fatal ("no memory for pool.");
if (!parse_lbrace (cfile))
return;
get_permit:
permit = new_permit ("parse_pool_statement");
if (!permit)
- error ("no memory for permit");
+ log_fatal ("no memory for permit");
next_token (&val, cfile);
token = next_token (&val, cfile);
switch (token) {
host = (struct host_decl *)dmalloc (sizeof (struct host_decl),
"parse_host_declaration");
if (!host)
- error ("can't allocate host decl struct %s.", name);
+ log_fatal ("can't allocate host decl struct %s.", name);
host -> name = name;
host -> group = clone_group (group, "parse_host_declaration");
data.buffer = (struct buffer *)0;
if (!buffer_allocate (&data.buffer,
data.len + 1, "parse_class_declaration"))
- error ("no memoy for class name.");
+ log_fatal ("no memoy for class name.");
data.data = &data.buffer -> data [0];
data.terminated = 1;
} else if (type == 2) {
if (!(name = dmalloc (strlen (val) + 1,
"parse_class_declaration")))
- error ("No memory for class name %s.", val);
+ log_fatal ("No memory for class name %s.", val);
strcpy (name, val);
} else {
name = (char *)0;
class = (struct class *)dmalloc (sizeof (struct class),
"parse_class_declaration");
if (!class)
- error ("No memory for class %s.", val);
+ log_fatal ("No memory for class %s.", val);
memset (class, 0, sizeof *class);
if (pc) {
class -> group = pc -> group;
sizeof (struct lease *),
"check_collection");
if (!class -> billed_leases)
- error ("no memory for billed leases");
+ log_fatal ("no memory for billed leases");
memset (class -> billed_leases, 0,
(class -> lease_limit *
sizeof class -> billed_leases));
dmalloc (sizeof (struct executable_statement),
"implicit user/vendor class"));
if (!stmt)
- error ("no memory for class statement.");
+ log_fatal ("no memory for class statement.");
memset (stmt, 0, sizeof *stmt);
stmt -> op = supersede_option_statement;
if (option_cache_allocate (&stmt -> data.option,
sizeof (struct lease *),
"check_collection");
if (!class -> billed_leases)
- error ("no memory for billed leases.");
+ log_fatal ("no memory for billed leases.");
memset (class -> billed_leases, 0,
(class -> lease_limit *
sizeof class -> billed_leases));
share = new_shared_network ("parse_shared_net_declaration");
if (!share)
- error ("No memory for shared subnet");
+ log_fatal ("No memory for shared subnet");
share -> pools = (struct pool *)0;
share -> next = (struct shared_network *)0;
share -> interface = (struct interface_info *)0;
}
name = malloc (strlen (val) + 1);
if (!name)
- error ("no memory for shared network name");
+ log_fatal ("no memory for shared network name");
strcpy (name, val);
} else {
name = parse_host_name (cfile);
subnet = new_subnet ("parse_subnet_declaration");
if (!subnet)
- error ("No memory for new subnet");
+ log_fatal ("No memory for new subnet");
subnet -> shared_network = share;
subnet -> group = clone_group (share -> group,
"parse_subnet_declaration");
lease.uid = (unsigned char *)
malloc (lease.uid_len);
if (!lease.uid) {
- warn ("no space for uid");
+ log_error ("no space for uid");
return (struct lease *)0;
}
memcpy (lease.uid, val, lease.uid_len);
(cfile, (unsigned char *)0,
&lease.uid_len, ':', 16, 8);
if (!lease.uid) {
- warn ("no space for uid");
+ log_error ("no space for uid");
return (struct lease *)0;
}
if (lease.uid_len == 0) {
}
}
if (!lease.uid) {
- error ("No memory for lease uid");
+ log_fatal ("No memory for lease uid");
}
break;
if (!pool) {
pool = new_pool ("parse_address_range");
if (!pool)
- error ("no memory for ad-hoc pool.");
+ log_fatal ("no memory for ad-hoc pool.");
if (dynamic) {
pool -> permit_list =
new_permit ("parse_address_range");
if (!pool -> permit_list)
- error ("no memory for ad-hoc permit.");
+ log_fatal ("no memory for ad-hoc permit.");
pool -> permit_list -> type =
permit_dynamic_bootp_clients;
}
#ifndef lint
static char copyright[] =
-"$Id: db.c,v 1.20 1998/11/11 08:00:11 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: db.c,v 1.21 1999/02/24 17:56:51 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
++errors;
}
if (errors)
- note ("write_lease: unable to write lease %s",
+ log_info ("write_lease: unable to write lease %s",
piaddr (lease -> ip_addr));
return !errors;
}
We need to do this even if we're rewriting the file below,
just in case the rewrite fails. */
if (fflush (db_file) == EOF) {
- note ("commit_leases: unable to commit: %m");
+ log_info ("commit_leases: unable to commit: %m");
return 0;
}
if (fsync (fileno (db_file)) < 0) {
- note ("commit_leases: unable to commit: %m");
+ log_info ("commit_leases: unable to commit: %m");
return 0;
}
sprintf (newfname, "%s.%d", path_dhcpd_db, (int)t);
db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
if (db_fd < 0) {
- error ("Can't create new lease file: %m");
+ log_fatal ("Can't create new lease file: %m");
}
if ((db_file = fdopen (db_fd, "w")) == NULL) {
- error ("Can't fdopen new lease file!");
+ log_fatal ("Can't fdopen new lease file!");
}
/* Write out all the leases that we know of... */
/* Get the old database out of the way... */
sprintf (backfname, "%s~", path_dhcpd_db);
if (unlink (backfname) < 0 && errno != ENOENT)
- error ("Can't remove old lease database backup %s: %m",
+ log_fatal ("Can't remove old lease database backup %s: %m",
backfname);
if (link (path_dhcpd_db, backfname) < 0)
- error ("Can't backup lease database %s to %s: %m",
+ log_fatal ("Can't backup lease database %s to %s: %m",
path_dhcpd_db, backfname);
/* Move in the new file... */
if (rename (newfname, path_dhcpd_db) < 0)
- error ("Can't install new lease database %s to %s: %m",
+ log_fatal ("Can't install new lease database %s to %s: %m",
newfname, path_dhcpd_db);
counting = 1;
#ifndef lint
static char copyright[] =
-"$Id: dhcp.c,v 1.74 1999/02/14 19:27:56 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhcp.c,v 1.75 1999/02/24 17:56:51 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Sourceless packets don't make sense here. */
if (!packet -> shared_network) {
- note ("Packet from unknown subnet: %s",
+ log_info ("Packet from unknown subnet: %s",
inet_ntoa (packet -> raw -> giaddr));
return;
}
lease = allocate_lease (packet,
packet -> shared_network -> pools, 0);
if (!lease) {
- note ("no free leases on network %s match %s",
+ log_info ("no free leases on network %s match %s",
packet -> shared_network -> name,
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
from there. Fry it. */
if (!packet -> shared_network) {
if (subnet && subnet -> group -> authoritative) {
- note ("%s: wrong network.", msgbuf);
+ log_info ("%s: wrong network.", msgbuf);
nak_lease (packet, &cip);
return;
}
if (!subnet) {
if (packet -> shared_network -> group -> authoritative)
{
- note ("%s: wrong network.", msgbuf);
+ log_info ("%s: wrong network.", msgbuf);
nak_lease (packet, &cip);
}
return;
it wasn't what got picked, the lease belongs to us,
so we should NAK it. */
if (ours) {
- note ("%s: wrong lease %s.", msgbuf, piaddr (cip));
+ log_info ("%s: wrong lease %s.", msgbuf, piaddr (cip));
nak_lease (packet, &cip);
} else
- note ("%s: wrong lease %s", msgbuf, piaddr (cip));
+ log_info ("%s: wrong lease %s", msgbuf, piaddr (cip));
return;
}
/* If the address the client asked for is ours, but it wasn't
available for the client, NAK it. */
if (!lease && ours) {
- note ("%s: lease %s unavailable.", msgbuf, piaddr (cip));
+ log_info ("%s: lease %s unavailable.", msgbuf, piaddr (cip));
nak_lease (packet, &cip);
return;
}
(lease -> uid_len != data.len ||
memcmp (data.data,
lease -> uid, lease -> uid_len))) {
- note ("%s: wrong owner %s.", msgbuf, piaddr (cip));
+ log_info ("%s: wrong owner %s.", msgbuf, piaddr (cip));
nak_lease (packet, &cip);
} else
ack_lease (packet, lease, DHCPACK, 0, msgbuf);
data_string_forget (&data, "dhcprequest");
return;
}
- note ("%s: unknown lease %s.", msgbuf, piaddr (cip));
+ log_info ("%s: unknown lease %s.", msgbuf, piaddr (cip));
}
void dhcprelease (packet)
so let it go. */
if ((oc = lookup_option (packet -> options.dhcp_hash,
DHO_DHCP_REQUESTED_ADDRESS))) {
- note ("DHCPRELEASE from %s specified requested-address.",
+ log_info ("DHCPRELEASE from %s specified requested-address.",
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr));
}
- note ("DHCPRELEASE of %s from %s via %s (%sfound)",
+ log_info ("DHCPRELEASE of %s from %s via %s (%sfound)",
inet_ntoa (packet -> raw -> ciaddr),
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
data_string_forget (&data, "dhcpdecline");
lease = find_lease_by_ip_addr (cip);
- note ("DHCPDECLINE on %s from %s via %s",
+ log_info ("DHCPDECLINE on %s from %s via %s",
piaddr (cip),
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
void dhcpinform (packet)
struct packet *packet;
{
- note ("DHCPINFORM from %s",
+ log_info ("DHCPINFORM from %s",
inet_ntoa (packet -> raw -> ciaddr));
}
/* Set DHCP_MESSAGE_TYPE to DHCPNAK */
if (!option_cache_allocate (&oc, "nak_lease")) {
- warn ("No memory for DHCPNAK message type.");
+ log_error ("No memory for DHCPNAK message type.");
return;
}
if (!make_const_data (&oc -> expression, &nak, sizeof nak, 0, 0)) {
- warn ("No memory for expr_const expression.");
+ log_error ("No memory for expr_const expression.");
option_cache_dereference (&oc, "nak_lease");
return;
}
/* Set DHCP_MESSAGE to whatever the message is */
if (!option_cache_allocate (&oc, "nak_lease")) {
- warn ("No memory for DHCPNAK message type.");
+ log_error ("No memory for DHCPNAK message type.");
return;
}
if (!make_const_data (&oc -> expression,
dhcp_message, strlen (dhcp_message), 1, 0)) {
- warn ("No memory for expr_const expression.");
+ log_error ("No memory for expr_const expression.");
option_cache_dereference (&oc, "nak_lease");
return;
}
raw.op = BOOTREPLY;
/* Report what we're sending... */
- note ("DHCPNAK on %s to %s via %s",
+ log_info ("DHCPNAK on %s to %s via %s",
piaddr (*cip),
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
outgoing.packet_length,
from, &to, &hto);
if (result < 0)
- warn ("send_fallback: %m");
+ log_error ("send_fallback: %m");
return;
}
} else {
packet, &raw, outgoing.packet_length,
from, &to, (struct hardware *)0);
if (result < 0)
- warn ("send_packet: %m");
+ log_error ("send_packet: %m");
}
void ack_lease (packet, lease, offer, when, msg)
/* Allocate a lease state structure... */
state = new_lease_state ("ack_lease");
if (!state)
- error ("unable to allocate lease state!");
+ log_fatal ("unable to allocate lease state!");
memset (state, 0, sizeof *state);
/* Replace the old lease hostname with the new one, if it's changed. */
lease -> client_hostname =
dmalloc (d1.len + 1, "ack_lease");
if (!lease -> client_hostname)
- warn ("no memory for client hostname.");
+ log_error ("no memory for client hostname.");
else {
memcpy (lease -> client_hostname, d1.data, d1.len);
lease -> client_hostname [d1.len] = 0;
&packet -> options, oc)) {
if (d1.len && packet -> raw -> secs < d1.data [0]) {
data_string_forget (&d1, "ack_lease");
- note ("%s: %d secs < %d",
+ log_info ("%s: %d secs < %d",
packet -> raw -> secs, d1.data [0]);
return;
}
if (evaluate_option_cache (&d1, packet,
&packet -> options, oc)) {
if (d1.len && !d1.data [0]) {
- note ("%s: unknown", msg);
+ log_info ("%s: unknown", msg);
data_string_forget (&d1, "ack_lease");
return;
}
&packet -> options, oc)) {
if (d1.len && !d1.data [0]) {
data_string_forget (&d1, "ack_lease");
- note ("%s: bootp disallowed", msg);
+ log_info ("%s: bootp disallowed", msg);
return;
}
data_string_forget (&d1, "ack_lease");
if (oc &&
evaluate_option_cache (&d1, packet, &packet -> options, oc)) {
if (d1.len && !d1.data [0]) {
- note ("%s: booting disallowed", msg);
+ log_info ("%s: booting disallowed", msg);
data_string_forget (&d1, "ack_lease");
return;
}
packet -> classes [i]))
break;
if (i == packet -> class_count) {
- note ("%s: no available billing", msg);
+ log_info ("%s: no available billing", msg);
return;
}
}
"ack_lease");
/* XXX inelegant */
if (!lt.uid)
- error ("can't allocate memory for large uid.");
+ log_fatal ("can't allocate memory for large uid.");
memcpy (lt.uid, d1.data, lt.uid_len);
}
data_string_forget (&d1, "ack_lease");
if (!(supersede_lease (lease, <, !offer || offer == DHCPACK)
|| (offer && offer != DHCPACK))) {
- note ("%s: database update failed", msg);
+ log_info ("%s: database update failed", msg);
return;
}
}
offered_lease_time);
i = DHO_DHCP_LEASE_TIME;
if (lookup_option (state -> options.dhcp_hash, i))
- warn ("dhcp-lease-time option for %s overridden.",
+ log_error ("dhcp-lease-time option for %s overridden.",
inet_ntoa (state -> ciaddr));
oc = (struct option_cache *)0;
if (option_cache_allocate (&oc, "ack_lease")) {
offered_lease_time);
i = DHO_DHCP_RENEWAL_TIME;
if (lookup_option (state -> options.dhcp_hash, i))
- warn ("dhcp-renewal-time option for %s overridden.",
+ log_error ("dhcp-renewal-time option for %s overridden.",
inet_ntoa (state -> ciaddr));
oc = (struct option_cache *)0;
if (option_cache_allocate (&oc, "ack_lease")) {
offered_lease_time);
i = DHO_DHCP_REBINDING_TIME;
if (lookup_option (state -> options.dhcp_hash, i))
- warn ("dhcp-rebinding-time option for %s overridden.",
+ log_error ("dhcp-rebinding-time option for %s overridden.",
inet_ntoa (state -> ciaddr));
oc = (struct option_cache *)0;
if (option_cache_allocate (&oc, "ack_lease")) {
h = gethostbyaddr ((char *)&ia, sizeof ia, AF_INET);
if (!h)
- warn ("No hostname for %s", inet_ntoa (ia));
+ log_error ("No hostname for %s", inet_ntoa (ia));
else {
oc = (struct option_cache *)0;
if (option_cache_allocate (&oc, "ack_lease")) {
lease -> state = state;
- note ("%s", msg);
+ log_info ("%s", msg);
/* If this is a DHCPOFFER, ping the lease address before actually
sending the offer. */
struct option_cache *oc;
if (!state)
- error ("dhcp_reply was supplied lease with no state!");
+ log_fatal ("dhcp_reply was supplied lease with no state!");
/* Compose a response for the client... */
memset (&raw, 0, sizeof raw);
raw.op = BOOTREPLY;
/* Say what we're doing... */
- note ("%s on %s to %s via %s",
+ log_info ("%s on %s to %s via %s",
(state -> offer
? (state -> offer == DHCPACK ? "DHCPACK" : "DHCPOFFER")
: "BOOTREPLY"),
&raw, packet_length,
raw.siaddr, &to, &hto);
if (result < 0)
- warn ("send_fallback: %m");
+ log_error ("send_fallback: %m");
free_lease_state (state, "dhcp_reply fallback 1");
lease -> state = (struct lease_state *)0;
&raw, packet_length,
raw.siaddr, &to, &hto);
if (result < 0)
- warn ("send_fallback: %m");
+ log_error ("send_fallback: %m");
free_lease_state (state, "dhcp_reply fallback 1");
lease -> state = (struct lease_state *)0;
return;
(struct packet *)0, &raw, packet_length,
from, &to, &hto);
if (result < 0)
- warn ("sendpkt: %m");
+ log_error ("sendpkt: %m");
free_lease_state (state, "dhcp_reply");
lease -> state = (struct lease_state *)0;
if (fixed_lease) {
#if defined (DEBUG_FIND_LEASE)
- note ("Found host for client identifier: %s.",
+ log_info ("Found host for client identifier: %s.",
piaddr (fixed_lease -> ip_addr));
#endif
uid_lease = (struct lease *)0;
fixed_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
if (uid_lease)
- note ("Found lease for client identifier: %s.",
+ log_info ("Found lease for client identifier: %s.",
piaddr (uid_lease -> ip_addr));
#endif
if (uid_lease &&
(uid_lease -> flags & ABANDONED_LEASE)) {
uid_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("...but it was abandoned.");
+ log_info ("...but it was abandoned.");
#endif
}
}
fixed_lease = mockup_lease (packet, share, hp);
#if defined (DEBUG_FIND_LEASE)
if (fixed_lease) {
- note ("Found host for hardware address: %s.",
+ log_info ("Found host for hardware address: %s.",
piaddr (fixed_lease -> ip_addr));
}
#endif
}
#if defined (DEBUG_FIND_LEASE)
if (hw_lease)
- note ("Found lease for hardware address: %s.",
+ log_info ("Found lease for hardware address: %s.",
piaddr (hw_lease -> ip_addr));
#endif
#if defined (DEBUG_FIND_LEASE)
if (ip_lease)
- note ("Found lease for requested address: %s.",
+ log_info ("Found lease for requested address: %s.",
piaddr (ip_lease -> ip_addr));
#endif
lease to be abandoned. If so, this request probably came from
that client. */
if (ip_lease && (ip_lease -> subnet -> shared_network != share)) {
- note ("...but it was on the wrong shared network.");
+ log_info ("...but it was on the wrong shared network.");
ip_lease = (struct lease *)0;
}
ip_lease -> uid_len))) {
#if defined (DEBUG_FIND_LEASE)
if (ip_lease)
- note ("rejecting lease for requested address.");
+ log_info ("rejecting lease for requested address.");
#endif
ip_lease = (struct lease *)0;
}
!memcmp (client_identifier.data,
ip_lease -> uid, ip_lease -> uid_len)) {
if (uid_lease -> ends > cur_time)
- warn ("client %s has duplicate leases on %s",
+ log_error ("client %s has duplicate leases on %s",
print_hw_addr (packet -> raw -> htype,
packet -> raw -> hlen,
packet -> raw -> chaddr),
hw_lease = hw_lease -> n_hw;
#if defined (DEBUG_FIND_LEASE)
if (hw_lease)
- note ("trying next lease matching hw addr: %s",
+ log_info ("trying next lease matching hw addr: %s",
piaddr (hw_lease -> ip_addr));
else
- note ("rejecting lease for hardware address.");
+ log_info ("rejecting lease for hardware address.");
#endif
}
if (ip_lease == hw_lease) {
ip_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("hardware lease and ip lease are identical.");
+ log_info ("hardware lease and ip lease are identical.");
#endif
}
if (hw_lease == uid_lease) {
#if defined (DEBUG_FIND_LEASE)
- note ("hardware lease and uid lease are identical.");
+ log_info ("hardware lease and uid lease are identical.");
#endif
hw_lease = (struct lease *)0;
}
if (ip_lease == uid_lease) {
ip_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("uid lease and ip lease are identical.");
+ log_info ("uid lease and ip lease are identical.");
#endif
}
release_lease (ip_lease);
ip_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("lease on requested address is on wrong network.");
+ log_info ("lease on requested address is on wrong network.");
#endif
}
if (uid_lease &&
release_lease (uid_lease);
uid_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("lease matching uid is on wrong network.");
+ log_info ("lease matching uid is on wrong network.");
#endif
}
if (hw_lease &&
release_lease (hw_lease);
hw_lease = (struct lease *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("lease matching hardware address is on wrong network.");
+ log_info ("lease matching hardware address is on wrong network.");
#endif
}
if (fixed_lease) {
lease = fixed_lease;
#if defined (DEBUG_FIND_LEASE)
- note ("choosing fixed address.");
+ log_info ("choosing fixed address.");
#endif
}
if (packet -> packet_type == DHCPREQUEST)
release_lease (ip_lease);
#if defined (DEBUG_FIND_LEASE)
- note ("not choosing requested address (!).");
+ log_info ("not choosing requested address (!).");
#endif
} else {
#if defined (DEBUG_FIND_LEASE)
- note ("choosing lease on requested address.");
+ log_info ("choosing lease on requested address.");
#endif
lease = ip_lease;
lease -> host = (struct host_decl *)0;
if (packet -> packet_type == DHCPREQUEST)
dissociate_lease (uid_lease);
#if defined (DEBUG_FIND_LEASE)
- note ("not choosing uid lease.");
+ log_info ("not choosing uid lease.");
#endif
} else {
lease = uid_lease;
lease -> host = (struct host_decl *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("choosing uid lease.");
+ log_info ("choosing uid lease.");
#endif
}
}
if (packet -> packet_type == DHCPREQUEST)
dissociate_lease (hw_lease);
#if defined (DEBUG_FIND_LEASE)
- note ("not choosing hardware lease.");
+ log_info ("not choosing hardware lease.");
#endif
} else {
lease = hw_lease;
lease -> host = (struct host_decl *)0;
#if defined (DEBUG_FIND_LEASE)
- note ("choosing hardware lease.");
+ log_info ("choosing hardware lease.");
#endif
}
}
#if defined (DEBUG_FIND_LEASE)
if (lease)
- note ("Returning lease: %s.",
+ log_info ("Returning lease: %s.",
piaddr (lease -> ip_addr));
else
- note ("Not returning a lease.");
+ log_info ("Not returning a lease.");
#endif
/* If we find an abandoned lease, but it's the one the client
be abandoned, so we reclaim it and let the client have it. */
if (lease && lease -> flags & ABANDONED_LEASE && lease == ip_lease &&
packet -> packet_type == DHCPREQUEST) {
- warn ("Reclaiming REQUESTed abandoned IP address %s.",
+ log_error ("Reclaiming REQUESTed abandoned IP address %s.",
piaddr (lease -> ip_addr));
lease -> flags &= ~ABANDONED_LEASE;
} else if (lease && lease -> flags & ABANDONED_LEASE) {
return allocate_lease (packet, pool -> next, ok);
lp = allocate_lease (packet, pool -> next, 0);
if (!lp) {
- warn ("Reclaiming abandoned IP address %s.",
+ log_error ("Reclaiming abandoned IP address %s.",
piaddr (lease -> ip_addr));
lease -> flags &= ~ABANDONED_LEASE;
return lease;
#ifndef lint
static char ocopyright[] =
-"$Id: dhcpd.c,v 1.54 1999/02/14 19:29:09 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
+"$Id: dhcpd.c,v 1.55 1999/02/24 17:56:52 mellon Exp $ Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
#endif
static char copyright[] =
usage ();
for (s = argv [i]; *s; s++)
if (!isdigit (*s))
- error ("%s: not a valid UDP port",
+ log_fatal ("%s: not a valid UDP port",
argv [i]);
status = atoi (argv [i]);
if (status < 1 || status > 65535)
- error ("%s: not a valid UDP port",
+ log_fatal ("%s: not a valid UDP port",
argv [i]);
local_port = htons (status);
- debug ("binding to user-specified port %d",
+ log_debug ("binding to user-specified port %d",
ntohs (local_port));
} else if (!strcmp (argv [i], "-f")) {
#ifndef DEBUG
((struct interface_info *)
dmalloc (sizeof *tmp, "get_interface_list"));
if (!tmp)
- error ("Insufficient memory to %s %s",
+ log_fatal ("Insufficient memory to %s %s",
"record interface", argv [i]);
memset (tmp, 0, sizeof *tmp);
strcpy (tmp -> name, argv [i]);
}
if (!quiet) {
- note (message);
- note (copyright);
- note (arr);
- note (contrib);
- note (url);
+ log_info (message);
+ log_info (copyright);
+ log_info (arr);
+ log_info (contrib);
+ log_info (url);
}
/* Default to the DHCP/BOOTP port. */
/* Read the dhcpd.conf file... */
if (!readconf ())
- error ("Configuration file errors encountered -- exiting");
+ log_fatal ("Configuration file errors encountered -- exiting");
/* test option should cause an early exit */
if (cftest)
if (daemon) {
/* First part of becoming a daemon... */
if ((pid = fork ()) < 0)
- error ("Can't fork daemon: %m");
+ log_fatal ("Can't fork daemon: %m");
else if (pid)
exit (0);
}
pidfilewritten = 1;
}
} else
- error ("There's already a DHCP server running.\n");
+ log_fatal ("There's already a DHCP server running.\n");
}
/* If we were requested to log to stdout on the command line,
static void usage ()
{
- note (message);
- note (copyright);
- note (arr);
+ log_info (message);
+ log_info (copyright);
+ log_info (arr);
- error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [-cf config-file]%s",
+ log_fatal ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [-cf config-file]%s",
"\n [-lf lease-file] [if0 [...ifN]]");
}
lp = find_lease_by_ip_addr (from);
if (!lp) {
- note ("unexpected ICMP Echo Reply from %s", piaddr (from));
+ log_info ("unexpected ICMP Echo Reply from %s", piaddr (from));
return;
}
if (!lp -> state) {
- warn ("ICMP Echo Reply for %s arrived late or is spurious.\n",
+ log_error ("ICMP Echo Reply for %s arrived late or is spurious.\n",
piaddr (from));
return;
}
if (lp -> ends > cur_time) {
- warn ("ICMP Echo reply arrived while lease %s was valid.\n",
+ log_error ("ICMP Echo reply arrived while lease %s was valid.\n",
piaddr (from));
}
#ifndef lint
static char copyright[] =
-"$Id: main.c,v 1.4 1998/03/16 06:18:50 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: main.c,v 1.5 1999/02/24 17:56:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
#endif
if (argc < 2)
- error ("usage: statmsg type [data]");
+ log_fatal ("usage: statmsg type [data]");
hdr.length = 0;
if (!strcmp (argv [1], "network-location-changed"))
hdr.type = NETWORK_LOCATION_CHANGED;
else
- error ("unknown status message type %s", argv [1]);
+ log_fatal ("unknown status message type %s", argv [1]);
sysconf_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (sysconf_fd < 0)
- error ("unable to create sysconf socket: %m");
+ log_fatal ("unable to create sysconf socket: %m");
/* XXX for now... */
name.sun_family = PF_UNIX;
strlen (name.sun_path));
if (connect (sysconf_fd, (struct sockaddr *)&name, len) < 0)
- error ("can't connect to sysconf socket: %m");
+ log_fatal ("can't connect to sysconf socket: %m");
status = write (sysconf_fd, &hdr, sizeof hdr);
if (status < 0)
- error ("sysconf: %m");
+ log_fatal ("sysconf: %m");
if (status < sizeof (hdr))
- error ("sysconf: short write");
+ log_fatal ("sysconf: short write");
if (hdr.length) {
status = write (sysconf_fd, buf, hdr.length);
if (status < 0)
- error ("sysconf payload write: %m");
+ log_fatal ("sysconf payload write: %m");
if (status != hdr.length)
- error ("sysconf payload: short write");
+ log_fatal ("sysconf payload: short write");
}
exit (0);
#ifndef lint
static char copyright[] =
-"$Id: sysconfd.c,v 1.7 1999/02/14 19:40:19 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: sysconfd.c,v 1.8 1999/02/24 17:56:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
/* Make a socket... */
sysconf_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (sysconf_fd < 0)
- error ("unable to create sysconf socket: %m");
+ log_fatal ("unable to create sysconf socket: %m");
/* XXX for now... */
name.sun_family = PF_UNIX;
/* Bind to it... */
if (bind (sysconf_fd, (struct sockaddr *)&name, len) < 0)
- error ("can't bind to sysconf socket: %m");
+ log_fatal ("can't bind to sysconf socket: %m");
/* Listen for connections... */
if (listen (sysconf_fd, 1) < 0)
- error ("can't listen on sysconf socket: %m");
+ log_fatal ("can't listen on sysconf socket: %m");
/* Stop logging to stderr... */
log_perror = 0;
/* Become a daemon... */
if ((pid = fork ()) < 0)
- error ("Can't fork daemon: %m");
+ log_fatal ("Can't fork daemon: %m");
else if (pid)
exit (0);
tmp = (struct sysconf_client *)malloc (sizeof *tmp);
if (!tmp) {
- warn ("Can't find memory for new client!");
+ log_error ("Can't find memory for new client!");
return;
}
memset (tmp, 0, sizeof *tmp);
namelen = sizeof name;
new_fd = accept (proto -> fd, (struct sockaddr *)&name, &namelen);
if (new_fd < 0) {
- warn ("accept: %m");
+ log_error ("accept: %m");
return;
}
status = read (proto -> fd, &hdr, sizeof hdr);
if (status < 0) {
blow:
- warn ("client_input: %m");
+ log_error ("client_input: %m");
close (proto -> fd);
remove_protocol (proto);
return;
}
if (status < sizeof (hdr)) {
- warn ("client_input: short message");
+ log_error ("client_input: short message");
goto blow;
}
if (hdr.length) {
buf = malloc (hdr.length);
if (!buf) {
- warn ("client_input: can't buffer payload");
+ log_error ("client_input: can't buffer payload");
goto blow;
}
status = read (proto -> fd, buf, hdr.length);
if (status < 0) {
- warn ("client_input payload read: %m");
+ log_error ("client_input payload read: %m");
goto blow;
}
if (status != hdr.length) {
- warn ("client_input payload: short read");
+ log_error ("client_input payload: short read");
goto blow;
}
} else
status = write (client -> fd, &hdr, sizeof hdr);
if (status < 0) {
- warn ("client_input: %m");
+ log_error ("client_input: %m");
continue;
}
if (status < sizeof (hdr)) {
- warn ("client_input: short write");
+ log_error ("client_input: short write");
continue;
}
if (hdr.length) {
status = write (client -> fd, buf, hdr.length);
if (status < 0) {
- warn ("client_input payload write: %m");
+ log_error ("client_input payload write: %m");
continue;
}
if (status != hdr.length) {
- warn ("client_input payload: short write");
+ log_error ("client_input payload: short write");
continue;
}
}