mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-01 14:55:30 +00:00
- Add equivalent config-file options for command-line options.
- Start the failover protocol if enabled.
This commit is contained in:
108
server/dhcpd.c
108
server/dhcpd.c
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char ocopyright[] =
|
static char ocopyright[] =
|
||||||
"$Id: dhcpd.c,v 1.88 2000/04/14 16:28:07 mellon Exp $ Copyright 1995-2000 The Internet Software Consortium.";
|
"$Id: dhcpd.c,v 1.89 2000/05/02 00:11:49 mellon Exp $ Copyright 1995-2000 The Internet Software Consortium.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
@@ -66,11 +66,6 @@ struct binding_scope global_scope;
|
|||||||
struct iaddr server_identifier;
|
struct iaddr server_identifier;
|
||||||
int server_identifier_matched;
|
int server_identifier_matched;
|
||||||
|
|
||||||
u_int16_t local_port;
|
|
||||||
u_int16_t remote_port;
|
|
||||||
|
|
||||||
struct in_addr limited_broadcast;
|
|
||||||
|
|
||||||
/* This is the standard name service updater that is executed whenever a
|
/* This is the standard name service updater that is executed whenever a
|
||||||
lease is committed. Right now it's not following the DHCP-DNS draft
|
lease is committed. Right now it's not following the DHCP-DNS draft
|
||||||
at all, but as soon as I fix the resolver it should try to. */
|
at all, but as soon as I fix the resolver it should try to. */
|
||||||
@@ -164,11 +159,12 @@ int main (argc, argv, envp)
|
|||||||
omapi_object_t *listener;
|
omapi_object_t *listener;
|
||||||
unsigned seed;
|
unsigned seed;
|
||||||
struct interface_info *ip;
|
struct interface_info *ip;
|
||||||
struct data_string fname;
|
struct data_string db;
|
||||||
struct option_cache *oc;
|
struct option_cache *oc;
|
||||||
struct option_state *options = (struct option_state *)0;
|
struct option_state *options = (struct option_state *)0;
|
||||||
struct parse *parse;
|
struct parse *parse;
|
||||||
int lose;
|
int lose;
|
||||||
|
u_int16_t omapi_port;
|
||||||
|
|
||||||
/* Initially, log errors to stderr as well as to syslogd. */
|
/* Initially, log errors to stderr as well as to syslogd. */
|
||||||
#ifdef SYSLOG_4_2
|
#ifdef SYSLOG_4_2
|
||||||
@@ -350,37 +346,105 @@ int main (argc, argv, envp)
|
|||||||
options, &global_scope,
|
options, &global_scope,
|
||||||
&root_group,
|
&root_group,
|
||||||
(struct group *)0);
|
(struct group *)0);
|
||||||
memset (&fname, 0, sizeof fname);
|
memset (&db, 0, sizeof db);
|
||||||
oc = lookup_option (&server_universe, options, SV_LEASE_FILE_NAME);
|
oc = lookup_option (&server_universe, options, SV_LEASE_FILE_NAME);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&fname, (struct packet *)0,
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
(struct lease *)0, options,
|
(struct lease *)0, options,
|
||||||
(struct option_state *)0,
|
(struct option_state *)0,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
s = dmalloc (fname.len + 1, MDL);
|
s = dmalloc (db.len + 1, MDL);
|
||||||
if (!s)
|
if (!s)
|
||||||
log_fatal ("no memory for lease db filename.");
|
log_fatal ("no memory for lease db filename.");
|
||||||
memcpy (s, fname.data, fname.len);
|
memcpy (s, db.data, db.len);
|
||||||
s [fname.len] = 0;
|
s [db.len] = 0;
|
||||||
data_string_forget (&fname, MDL);
|
data_string_forget (&db, MDL);
|
||||||
path_dhcpd_db = s;
|
path_dhcpd_db = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
oc = lookup_option (&server_universe, options, SV_PID_FILE_NAME);
|
oc = lookup_option (&server_universe, options, SV_PID_FILE_NAME);
|
||||||
if (oc &&
|
if (oc &&
|
||||||
evaluate_option_cache (&fname, (struct packet *)0,
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
(struct lease *)0, options,
|
(struct lease *)0, options,
|
||||||
(struct option_state *)0,
|
(struct option_state *)0,
|
||||||
&global_scope, oc, MDL)) {
|
&global_scope, oc, MDL)) {
|
||||||
s = dmalloc (fname.len + 1, MDL);
|
s = dmalloc (db.len + 1, MDL);
|
||||||
if (!s)
|
if (!s)
|
||||||
log_fatal ("no memory for lease db filename.");
|
log_fatal ("no memory for lease db filename.");
|
||||||
memcpy (s, fname.data, fname.len);
|
memcpy (s, db.data, db.len);
|
||||||
s [fname.len] = 0;
|
s [db.len] = 0;
|
||||||
data_string_forget (&fname, MDL);
|
data_string_forget (&db, MDL);
|
||||||
path_dhcpd_pid = s;
|
path_dhcpd_pid = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
omapi_port = OMAPI_PROTOCOL_PORT;
|
||||||
|
oc = lookup_option (&server_universe, options, SV_OMAPI_PORT);
|
||||||
|
if (oc &&
|
||||||
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
|
(struct lease *)0, options,
|
||||||
|
(struct option_state *)0,
|
||||||
|
&global_scope, oc, MDL)) {
|
||||||
|
if (db.len == 2) {
|
||||||
|
omapi_port = getUShort (db.data);
|
||||||
|
} else
|
||||||
|
log_fatal ("invalid omapi port data length");
|
||||||
|
data_string_forget (&db, MDL);
|
||||||
|
}
|
||||||
|
|
||||||
|
oc = lookup_option (&server_universe, options, SV_LOCAL_PORT);
|
||||||
|
if (oc &&
|
||||||
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
|
(struct lease *)0, options,
|
||||||
|
(struct option_state *)0,
|
||||||
|
&global_scope, oc, MDL)) {
|
||||||
|
if (db.len == 2) {
|
||||||
|
local_port = htons (getUShort (db.data));
|
||||||
|
} else
|
||||||
|
log_fatal ("invalid local port data length");
|
||||||
|
data_string_forget (&db, MDL);
|
||||||
|
}
|
||||||
|
|
||||||
|
oc = lookup_option (&server_universe, options, SV_REMOTE_PORT);
|
||||||
|
if (oc &&
|
||||||
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
|
(struct lease *)0, options,
|
||||||
|
(struct option_state *)0,
|
||||||
|
&global_scope, oc, MDL)) {
|
||||||
|
if (db.len == 2) {
|
||||||
|
remote_port = htons (getUShort (db.data));
|
||||||
|
} else
|
||||||
|
log_fatal ("invalid remote port data length");
|
||||||
|
data_string_forget (&db, MDL);
|
||||||
|
}
|
||||||
|
|
||||||
|
oc = lookup_option (&server_universe, options,
|
||||||
|
SV_LIMITED_BROADCAST_ADDRESS);
|
||||||
|
if (oc &&
|
||||||
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
|
(struct lease *)0, options,
|
||||||
|
(struct option_state *)0,
|
||||||
|
&global_scope, oc, MDL)) {
|
||||||
|
if (db.len == 4) {
|
||||||
|
memcpy (&limited_broadcast, db.data, 4);
|
||||||
|
} else
|
||||||
|
log_fatal ("invalid remote port data length");
|
||||||
|
data_string_forget (&db, MDL);
|
||||||
|
}
|
||||||
|
|
||||||
|
oc = lookup_option (&server_universe, options,
|
||||||
|
SV_LOCAL_ADDRESS);
|
||||||
|
if (oc &&
|
||||||
|
evaluate_option_cache (&db, (struct packet *)0,
|
||||||
|
(struct lease *)0, options,
|
||||||
|
(struct option_state *)0,
|
||||||
|
&global_scope, oc, MDL)) {
|
||||||
|
if (db.len == 4) {
|
||||||
|
memcpy (&local_address, db.data, 4);
|
||||||
|
} else
|
||||||
|
log_fatal ("invalid remote port data length");
|
||||||
|
data_string_forget (&db, MDL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Don't need the options anymore. */
|
/* Don't need the options anymore. */
|
||||||
option_state_dereference (&options, MDL);
|
option_state_dereference (&options, MDL);
|
||||||
|
|
||||||
@@ -417,12 +481,16 @@ int main (argc, argv, envp)
|
|||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
log_fatal ("Can't allocate new generic object: %s\n",
|
log_fatal ("Can't allocate new generic object: %s\n",
|
||||||
isc_result_totext (result));
|
isc_result_totext (result));
|
||||||
result = omapi_protocol_listen (listener,
|
result = omapi_protocol_listen (listener, omapi_port, 1);
|
||||||
OMAPI_PROTOCOL_PORT, 1);
|
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
log_fatal ("Can't start OMAPI protocol: %s",
|
log_fatal ("Can't start OMAPI protocol: %s",
|
||||||
isc_result_totext (result));
|
isc_result_totext (result));
|
||||||
|
|
||||||
|
#if defined (FAILOVER_PROTOCOL)
|
||||||
|
/* Start the failover protocol. */
|
||||||
|
dhcp_failover_startup ();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
if (daemon) {
|
if (daemon) {
|
||||||
/* First part of becoming a daemon... */
|
/* First part of becoming a daemon... */
|
||||||
|
Reference in New Issue
Block a user