33#define LEASE_REWRITE_PERIOD 3600
40static int counting = 0;
55 if (
bnd->value->type == binding_data) {
56 if (
bnd->value->value.data.data !=
NULL) {
58 bnd->value->value.data.len,
'"',
MDL);
62 prepend,
bnd->name,
s);
70 }
else if (
bnd->value->type == binding_numeric) {
73 bnd->name,
bnd->value->value.intval);
76 }
else if (
bnd->value->type == binding_boolean) {
79 bnd->value->value.intval ?
"true" :
"false");
82 }
else if (
bnd->value->type == binding_dns) {
83 log_error(
"%s: persistent dns values not supported.",
85 }
else if (
bnd->value->type == binding_function) {
86 log_error(
"%s: persistent functions not supported.",
151 ((
lease -> binding_state > 0 &&
157 if (
lease -> binding_state !=
lease -> next_binding_state)
159 ((
lease -> next_binding_state > 0 &&
162 [
lease -> next_binding_state - 1])
198 if (
lease -> hardware_addr.hlen) {
203 lease -> hardware_addr.hlen - 1,
204 &
lease -> hardware_addr.hbuf [1]));
208 if (
lease -> uid_len) {
250 if (
lease -> client_hostname &&
266 ?
" or release" :
"");
290 log_info (
"write_lease: unable to write lease %s",
335 if (host -> interface.hlen) {
340 host -> interface.hlen - 1,
341 &host -> interface.hbuf [1]));
345 if (host -> client_identifier.len) {
349 host -> client_identifier.len)) {
351 (
int)host -> client_identifier.len,
352 host -> client_identifier.data);
358 host -> client_identifier.data [0]);
362 i < host -> client_identifier.len;
i++) {
366 client_identifier.data [
i]);
379 if (host -> fixed_addr &&
386 host -> fixed_addr,
MDL)) {
415 if (host -> named_group) {
418 host -> named_group -> name);
424 (!host -> named_group ||
425 host ->
group != host -> named_group ->
group) &&
429 host ->
group -> statements, 8);
441 log_info (
"write_host: unable to write host %s",
506 log_info (
"write_group: unable to write group %s",
522 char addr_buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff.255.255.255.255")];
523 const char *binding_state;
579 log_error(
"Unknown ia type %u for %s at %s:%d",
611 log_fatal(
"Unknown iasubopt state %d at %s:%d",
616 binding_state) < 0) {
670 ?
" or release" :
"") < 0)
699 log_info(
"write_ia: unable to write ia");
759 log_info(
"write_server_duid: unable to write server-duid");
765#if defined (FAILOVER_PROTOCOL)
776 fprintf (
db_file,
"\nfailover peer \"%s\" state {", state -> name);
796 if (state ->
i_am == secondary) {
799 (
unsigned long)state ->
mclt);
810 log_info (
"write_failover_state: unable to write state %s",
822 const unsigned char *
s;
825 for (
i = 0;
s [
i];
i++)
827 ||
s [
i] ==
'"' ||
s [
i] ==
'\\')
833 const unsigned char *
s;
840 s [
i] ==
'"' ||
s [
i] ==
'\\')
845static int print_hash_string(
FILE *
fp,
struct class *
class)
849 for (
i = 0 ;
i <
class->hash_string.len ;
i++)
857 log_error(
"Failure writing hash string: %m");
862 log_error(
"Failure writing hash string: %m");
865 for (
i = 1 ;
i <
class->hash_string.len ;
i++) {
868 log_error(
"Failure writing hash string: %m");
881 const unsigned char *name = key;
882 struct class *
class = object;
893 if (!print_hash_string(
db_file,
class))
1010 if (!print_hash_string(
db_file,
class))
1016 class -> dirty = !
errors;
1037 log_info(
"commit_leases: unable to commit, fflush(): %m");
1042 log_info (
"commit_leases: unable to commit, fsync(): %m");
1077#if defined (TRACING)
1086 (
struct group *)0, 0, 1);
1092#if defined (TRACING)
1096#if defined (TRACING)
1114#if defined (TRACING)
1122#if defined(REPORT_HASH_PERFORMANCE)
1155 log_fatal(
"new_lease_file: lease file path too long");
1159 log_error (
"Can't create new lease file: %m");
1163#if defined (PARANOIA)
1173 log_fatal (
"Can't chown new lease file: %m");
1179 log_error(
"Can't fdopen new lease file: %m");
1190 fprintf (
db_file,
"# The format of this file is documented in the %s",
1191 "dhcpd.leases(5) manual page.\n");
1196 fprintf (
db_file,
"# This lease file was written by isc-dhcp-%s\n\n",
1202 " DO NOT DELETE\n");
1208 "little-endian" :
"big-endian"));
1224 " removing temp lease file: %s",
1230#if defined (TRACING)
1241 log_fatal(
"new_lease_file: backup lease file path too long");
1245 log_error (
"Can't remove old lease database backup %s: %m",
1251 log_error(
"%s is missing - no lease db to backup.",
1254 log_error(
"Can't backup lease database %s to %s: %m",
1259#if defined (TRACING)
1265 log_error (
"Can't install new lease database %s to %s: %m",
void data_string_forget(struct data_string *data, const char *file, int line)
const char * pretty_print_option(struct option *option, const unsigned char *data, unsigned len, int emit_commas, int emit_quotes)
struct collection * collections
char * format_lease_id(const unsigned char *s, unsigned len, int format, const char *file, int line)
char * quotify_string(const char *s, const char *file, int line)
char * quotify_buf(const unsigned char *s, unsigned len, char enclose_char, const char *file, int line)
char * print_hw_addr(int htype, const int hlen, const unsigned char *data) const
const char * print_time(TIME t)
int write_group(struct group_object *group)
int lease_file_is_corrupt
void commit_leases_timeout(void *foo)
int write_ia(const struct ia_xx *ia)
int write_host(struct host_decl *host)
void write_billing_classes()
int db_printable_len(unsigned char *s, unsigned len) const
int db_printable(unsigned char *s) const
int new_lease_file(int test_mode)
void db_startup(int test_mode)
int write_billing_class(struct class *class)
int commit_leases_timed()
int write_lease(struct lease *lease)
int group_writer(struct group_object *group)
#define LEASE_REWRITE_PERIOD
isc_result_t write_named_billing_class(const void *key, unsigned len, void *object)
host_hash_t * host_hw_addr_hash
int write_server_duid(void)
int write_failover_state(dhcp_failover_state_t *)
#define HOST_DECL_DYNAMIC
#define GROUP_OBJECT_DELETED
#define HOST_DECL_DELETED
lease_id_hash_t * lease_hw_addr_hash
void expire_all_pools(void)
void copy_server_duid(struct data_string *ds, const char *file, int line)
const char * path_dhcpd_db
lease_id_hash_t * lease_uid_hash
host_hash_t * host_uid_hash
#define GROUP_OBJECT_STATIC
#define GROUP_OBJECT_DYNAMIC
isc_boolean_t server_duid_isset(void)
const char * dhcp_failover_state_name_print(enum failover_state)
#define CLASS_DECL_DELETED
isc_result_t read_conf_file(const char *, struct group *, int, int)
const char * binding_state_names[]
#define CLASS_DECL_DYNAMIC
lease_ip_hash_t * lease_ip_addr_hash
void write_statements(FILE *file, struct executable_statement *statements, int indent)
struct iaddr ip_addr(struct iaddr subnet, struct iaddr mask, u_int32_t host_address)
const char * piaddr(const struct iaddr addr)
struct group * root_group
void dfree(void *, const char *, int)
int log_error(const char *,...) __attribute__((__format__(__printf__
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
int int log_info(const char *,...) __attribute__((__format__(__printf__
#define DHCP_R_INVALIDARG
struct binding * bindings
struct executable_statement * statements
struct expression * submatch
struct class * superclass
struct data_string hash_string
const unsigned char * data
struct executable_statement * statements
struct data_string iaid_duid
struct iasubopt ** iasubopt
time_t hard_lifetime_end_time
struct binding_scope * scope
struct ipv6_pool * ipv6_pool
time_t soft_lifetime_end_time
struct ipv6_pond * ipv6_pond
struct binding_scope * scope
binding_state_t rewind_binding_state
binding_state_t binding_state
struct executable_statement * on_expiry
struct executable_statement * on_release
const char * hardware_types[]
int evaluate_option_cache(struct data_string *result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *cfg_options, struct binding_scope **scope, struct option_cache *oc, const char *file, int line)
int write_expression(FILE *file, struct expression *expr, int col, int indent, int firstp)
struct binding_scope * global_scope