121static int server_starting = 0;
136 log_error (
"dhcp client identifier may not be %s",
137 "specified conditionally.");
138 }
else if (!(*
evp)) {
142 log_error (
"only one dhcp client identifier may be %s",
151find_host_id_info(
unsigned int option_code,
int relays) {
156 (
p->relays == relays)) {
168 printf(
"--------------\n");
179 printf(
"--------------\n");
188 log_fatal(
"Can't allocate host/uid hash");
233 log_fatal (
"Can't allocate host name hash");
235 (
unsigned char *)
hd ->
name,
239 (
unsigned char *)
hd ->
name,
245 (
unsigned char *)
hd ->
name,
269 (
unsigned char *)
hd ->
name,
285 if (
hd -> interface.hlen) {
289 log_fatal (
"Can't allocate host/hw hash");
294 hd -> interface.hbuf,
295 hd -> interface.hlen,
MDL);
299 hd -> interface.hlen,
hd,
MDL);
304 for (
np =
hp;
np -> n_ipaddr;
np =
np -> n_ipaddr)
316 find_uid_statement, &
esp, 0)) {
324 if (
hd->client_identifier.len > 0 &&
cid.len > 0) {
328 hd->client_identifier.data,
329 sizeof(uid_buf) - 1, uid_buf);
334 log_error (
"Warning, host declaration '%s'"
335 " already has uid '%s',"
336 " ignoring dhcp-client-identifier '%s'",
347 if (
hd -> client_identifier.len) {
353 log_fatal (
"Can't allocate host/uid hash");
356 hd -> client_identifier.data,
357 hd -> client_identifier.len,
364 hd -> client_identifier.data,
365 hd -> client_identifier.len,
369 for (
np =
hp;
np -> n_ipaddr;
370 np =
np -> n_ipaddr) {
381 hd -> client_identifier.data,
382 hd -> client_identifier.len,
392 if (
hd->host_id_option !=
NULL) {
397 h_id_info = find_host_id_info(
hd->host_id_option->code,
402 log_fatal(
"No memory for host-identifier "
403 "option information.");
406 hd->host_id_option,
MDL);
409 log_fatal(
"No memory for host-identifier "
418 hd->host_id.data,
hd->host_id.len,
MDL)) {
431 while (
np->n_ipaddr !=
NULL) {
476 if (
cp->superclass) {
478 (
const char *)
cp->hash_string.data,
588 if (
hd->host_id_option !=
NULL) {
612 (
unsigned char *)
hd ->
name,
616 (
unsigned char *)
hd ->
name,
633 const unsigned char *haddr,
unsigned hlen,
637#if defined(LDAP_CONFIGURATION)
653 const unsigned char *data,
unsigned len,
671#if defined(LDAP_CONFIGURATION)
704 memset(&data, 0,
sizeof(data));
710 log_error(
"Error evaluating option cache");
744 memset (&fixed_addr, 0,
sizeof fixed_addr);
746 for (
hp = *host;
hp;
hp =
hp -> n_ipaddr) {
747 if (!
hp -> fixed_addr)
755 hp -> fixed_addr,
MDL))
757 for (
i = 0;
i < fixed_addr.
len;
i += 4) {
760 fixed_addr.
data +
i, 4);
789#if defined(COMPACT_LEASES)
797#if !defined(COMPACT_LEASES)
804 log_fatal (
"No shared network for network %s (%s)",
811 log_fatal (
"Can't allocate lease/uid hash");
816 log_fatal (
"Can't allocate lease/ip hash");
821 log_fatal (
"Can't allocate lease/hw hash");
828 log_fatal(
"bad range, address %s not in subnet %s netmask %s",
835 log_fatal(
"bad range, address %s not in subnet %s netmask %s",
854#if defined (BINARY_LEASES)
859#if defined (COMPACT_LEASES)
864 if (((
s %
sizeof (
struct lease)) != 0) ||
876 log_fatal (
"No memory for address range %s-%s.",
884#if defined (COMPACT_LEASES)
912 "lease %s is declared twice!",
919 lp->ip_addr.iabuf,
lp->ip_addr.len,
940 if (
addr.len !=
rv->netmask.len)
961 if (
addr.len !=
rv->netmask.len)
985 char n1buf[
sizeof(
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255")];
987 for (
i = 0;
i < 128;
i++)
991 for (
j = 0;
j < 128;
j++)
992 if (
scan->netmask.iabuf[3 - (
j >> 3)] &
997 log_error(
"Warning: subnet %s/%d overlaps subnet %s/%d",
1074 if (share -> interface) {
1076 "A subnet or shared network can't be connected %s",
1077 "to two interfaces.");
1087 log_fatal (
"new_shared_network_interface %s: %s",
1119 log_error (
"undeclared lease found in database: %s",
1164#if defined (FAILOVER_PROTOCOL)
1197 ((
comp -> hardware_addr.hlen !=
1198 lease -> hardware_addr.hlen) ||
1200 lease -> hardware_addr.hbuf,
1201 comp -> hardware_addr.hlen))))) {
1215 comp -> uid = (
unsigned char *)0;
1221 if (
comp->hardware_addr.hlen)
1225 if (
comp -> billing_class !=
lease -> billing_class) {
1226 if (
comp->billing_class)
1228 if (
lease -> billing_class)
1235 if (
lease -> uid_len <=
sizeof (
lease -> uid_buf)) {
1238 comp -> uid = &
comp -> uid_buf [0];
1239 comp -> uid_max =
sizeof comp -> uid_buf;
1241 }
else if (
lease -> uid != &
lease -> uid_buf [0]) {
1244 lease -> uid = (
unsigned char *)0;
1245 lease -> uid_max = 0;
1247 lease -> uid_len = 0;
1252 comp -> uid = (
unsigned char *)0;
1253 comp -> uid_len =
comp -> uid_max = 0;
1258 comp -> hardware_addr =
lease -> hardware_addr;
1261 if (
lease -> scope) {
1280 if (
comp -> client_hostname)
1282 comp -> client_hostname =
lease -> client_hostname;
1283 lease -> client_hostname = (
char *)0;
1286 if (
comp->on_star.on_expiry)
1288 (&
comp->on_star.on_expiry,
MDL);
1294 if (
comp->on_star.on_commit)
1296 (&
comp->on_star.on_commit,
MDL);
1302 if (
comp->on_star.on_release)
1304 (&
comp->on_star.on_release,
MDL);
1315 if (
comp->hardware_addr.hlen)
1319#if defined (FAILOVER_PROTOCOL)
1338#if defined (FAILOVER_PROTOCOL)
1349 log_error (
"Supersede_lease: lease %s with no pool.",
1355 switch (
comp -> binding_state) {
1358 lq = &
comp->pool->reserved;
1361 comp->pool->free_leases--;
1364#if defined(FAILOVER_PROTOCOL)
1387 lq = &
comp->pool->backup;
1388 comp->pool->backup_leases--;
1391#if defined(FAILOVER_PROTOCOL)
1397 log_error (
"Lease with bogus binding state: %d",
1398 comp -> binding_state);
1399#if defined (BINDING_STATE_DEBUG)
1452#if defined(FAILOVER_PROTOCOL)
1463 ((
comp->pool->failover_peer->service_state ==
1465 (
comp->pool->failover_peer->service_state ==
1467 comp->rewind_binding_state =
comp->binding_state;
1472 if ((server_starting &
SS_NOSYNC) == 0) {
1478#if defined (FAILOVER_PROTOCOL)
1480 comp -> desired_binding_state =
comp -> binding_state;
1497 (
comp->next_binding_state !=
comp->binding_state))
1506#if defined (FAILOVER_PROTOCOL)
1517 if (
lease -> next_binding_state !=
lease -> binding_state &&
1529#if defined (NSUPDATE)
1554 if (
lease -> client_hostname) {
1556 lease -> client_hostname = (
char *)0;
1567 if (
lease -> next_binding_state !=
lease -> binding_state &&
1578#if defined (NSUPDATE)
1618 if (
lease -> client_hostname) {
1620 lease -> client_hostname = (
char *)0;
1630#if defined (DEBUG_LEASE_STATE_TRANSITIONS)
1631 log_debug (
"lease %s moves from %s to %s",
1637 lease -> binding_state =
lease -> next_binding_state;
1638 switch (
lease -> binding_state) {
1640#if defined (FAILOVER_PROTOCOL)
1653#if defined(FAILOVER_PROTOCOL)
1669 lease -> next_binding_state =
lease -> binding_state;
1672#if defined (DEBUG_LEASE_STATE_TRANSITIONS)
1673 log_debug (
"lease %s: next binding state %s",
1700 lt ->
uid = (
unsigned char *)0;
1761#if defined (NSUPDATE)
1801#if defined (FAILOVER_PROTOCOL)
1809 (((
peer->i_am == primary) &&
1811 ((
peer->i_am == secondary) &&
1832 const char *message;
1835#if defined (NSUPDATE)
1858 lt->hardware_addr.hlen = 0;
1859 if (
lt->uid &&
lt->uid !=
lt->uid_buf) {
1885#if defined (NSUPDATE)
1892#if defined (FAILOVER_PROTOCOL)
1905 lt ->
uid = (
unsigned char *)0;
1921#define FREE_LEASES 0
1922#define ACTIVE_LEASES 1
1923#define EXPIRED_LEASES 2
1924#define ABANDONED_LEASES 3
1925#define BACKUP_LEASES 4
1926#define RESERVED_LEASES 5
1946#if defined (FAILOVER_PROTOCOL)
1999#if defined(FAILOVER_PROTOCOL)
2009 ((
peer->i_am == primary &&
2012 (
peer->i_am == secondary &&
2060 unsigned len,
const char *
file,
int line)
2155 if (client_lease_preferred(
cand,
lease))
2217 if (head ==
lease) {
2282 if (client_lease_preferred(
cand,
lease))
2356 if (head ==
lease) {
2371 while (head ->
n_hw) {
2402 for (
p =
s->pools;
p;
p =
p->next) {
2414#if !defined (DEBUG_DUMP_ALL_LEASES)
2415 if (
l->hardware_addr.hlen != 0 ||
l->uid_len != 0 ||
2416 l->tsfp != 0 ||
l->binding_state !=
FTS_FREE)
2450 (
unsigned char *)
cp->name,
2456 log_info (
"Wrote %d class decls to leases file.",
2495 log_info (
"Wrote %d deleted host decls to leases file.",
2512 log_info (
"Wrote %d new dynamic host decls to leases file.",
2516#if defined (FAILOVER_PROTOCOL)
2540#if !defined (BINARY_LEASES)
2593 log_fatal(
"Lease with binding state %s not on its queue.",
2594 (
comp->binding_state < 1 ||
2642 if (
lp->sort_time >=
comp->sort_time)
2691 lq = &
comp->pool->reserved;
2694 comp->pool->free_leases++;
2708#if defined(FAILOVER_PROTOCOL)
2721 if (
comp->pool->failover_peer &&
2740 lq = &
comp->pool->backup;
2741 comp->pool->backup_leases++;
2747 log_error (
"Lease with bogus binding state: %d",
2749#if defined (BINDING_STATE_DEBUG)
2768 struct class *
class;
2778#if defined (FAILOVER_PROTOCOL)
2809 if (
lease -> hardware_addr.hlen) {
2814 if (
lease -> billing_class) {
2846#if defined (BINARY_LEASES)
2855 if (
p->lease_count > 100) {
2885 p -> lease_count = 0;
2886 p -> free_leases = 0;
2887 p -> backup_leases = 0;
2916#if defined (FAILOVER_PROTOCOL)
2917 if (
p -> failover_peer &&
2930 server_starting = 0;
2979#if defined (DEBUG_MEMORY_LEAKAGE) && \
2980 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2993#if defined (COMPACT_LEASES)
3113 if (
sc -> next_subnet) {
3117 if (
sc -> next_sibling)
3122 if (
sc -> interface)
3190 if (lc -> billing_class)
3223#if defined(DELAYED_ACK)
3274#if defined(COMPACT_LEASES)
int group_dereference(struct group **ptr, const char *file, int line)
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
int option_chain_head_reference(struct option_chain_head **ptr, struct option_chain_head *bp, const char *file, int line)
int executable_statement_reference(struct executable_statement **ptr, struct executable_statement *bp, const char *file, int line)
int binding_scope_reference(struct binding_scope **ptr, struct binding_scope *bp, const char *file, int line)
int option_chain_head_dereference(struct option_chain_head **ptr, const char *file, int line)
void add_timeout(struct timeval *when, void *where, void *what, tvref_t ref, tvunref_t unref)
struct option_cache * lookup_option(struct universe *universe, struct option_state *options, unsigned code)
struct collection * collections
int parse_warn(struct parse *cfile, const char *fmt,...)
void print_lease(struct lease *lease)
void print_hex_or_string(unsigned len, const u_int8_t *data, unsigned limit, char *buf)
#define FAILOVER_PROTOCOL
int write_host(struct host_decl *host)
isc_result_t find_class(struct class **c, const char *s, const char *file, int line)
void unbill_class(struct lease *lease)
int write_lease(struct lease *lease)
#define DHO_DHCP_CLIENT_IDENTIFIER
#define DHO_PXE_CLIENT_ID
void cancel_all_timeouts(void)
struct lease * new_leases(unsigned, const char *, int)
void(* tvunref_t)(void *, const char *, int)
#define INTERFACE_REQUESTED
int bill_class(struct lease *, struct class *)
#define HOST_DECL_DYNAMIC
void relinquish_timeouts(void)
int write_group(struct group_object *)
#define GROUP_OBJECT_DELETED
#define HOST_DECL_DELETED
omapi_object_type_t * dhcp_type_lease
void free_lease_state(struct lease_state *, const char *, int)
#define LEASE_INSERTP(LQ, LEASE)
dhcp_control_object_t * dhcp_control_object
void(* tvref_t)(void *, void *, const char *, int)
u_int32_t abandon_lease_time
struct ipv6_pool ** pools
@ shutdown_drop_omapi_connections
void dhcp_failover_pool_check(struct pool *)
int dhcp_failover_queue_update(struct lease *, int)
#define LEASE_REMOVEP(LQ, LEASE)
void lc_init_growth(struct leasechain *lc, size_t growth)
int dhcp_failover_write_all_states(void)
enum dhcp_shutdown_state shutdown_state
struct executable_statement * default_classification_rules
#define GROUP_OBJECT_STATIC
struct universe dhcp_universe
isc_result_t unlink_class(struct class **class)
#define GROUP_OBJECT_DYNAMIC
#define LEASE_NOT_EMPTYP(LQ)
isc_result_t ddns_removals(struct lease *, struct iasubopt *, struct dhcp_ddns_cb *, isc_boolean_t)
#define CLASS_DECL_DELETED
isc_result_t dhcp_io_shutdown(omapi_object_t *, void *)
const char * binding_state_names[]
#define LEASE_GET_FIRSTP(LQ)
isc_result_t write_named_billing_class(const void *, unsigned, void *)
#define print_hex_1(len, data, limit)
#define LEASE_GET_NEXTP(LQ, LEASE)
void relinquish_lease_hunks(void)
struct interface_info * interfaces
struct interface_info ** interface_vector
dns_zone_hash_t * dns_zone_hash
int execute_statements(struct binding_value **result, struct packet *packet, struct lease *lease, struct client_state *client_state, struct option_state *in_options, struct option_state *out_options, struct binding_scope **scope, struct executable_statement *statements, struct on_star *on_star)
int executable_statement_foreach(struct executable_statement *stmt, int(*callback)(struct executable_statement *, void *, int), void *vp, int condp)
int executable_statement_dereference(struct executable_statement **ptr, const char *file, int line)
const char * binding_state_print(enum failover_state state)
int hash_foreach(struct hash_table *, hash_foreach_func)
void relinquish_hash_bucket_hunks(void)
unsigned do_id_hash(const void *, unsigned, unsigned)
#define HASH_FUNCTIONS(name, bufarg, type, hashtype, ref, deref, hasher)
unsigned do_string_hash(const void *, unsigned, unsigned)
unsigned do_ip4_hash(const void *, unsigned, unsigned)
u_int32_t host_addr(struct iaddr addr, struct iaddr mask)
struct iaddr ip_addr(struct iaddr subnet, struct iaddr mask, u_int32_t host_address)
const char * piaddr(const struct iaddr addr)
int addr_eq(struct iaddr addr1, struct iaddr addr2)
struct iaddr subnet_number(struct iaddr addr, struct iaddr mask)
@ supersede_option_statement
int lease_enqueue(struct lease *comp)
host_hash_t * host_hw_addr_hash
int lease_copy(struct lease **lp, struct lease *lease, const char *file, int line)
void hw_hash_add(struct lease *lease)
int find_grouped_subnet(struct subnet **sp, struct shared_network *share, struct iaddr addr, const char *file, int line)
void lease_insert(struct lease **lq, struct lease *comp)
lease_id_hash_t * lease_hw_addr_hash
struct shared_network * shared_networks
void hw_hash_delete(struct lease *lease)
void enter_subnet(struct subnet *subnet)
isc_result_t lease_instantiate(const void *key, unsigned len, void *object)
struct host_id_info host_id_info_t
void enter_lease(struct lease *lease)
int supersede_lease(struct lease *comp, struct lease *lease, int commit, int propogate, int pimmediate, int from_pool)
void uid_hash_add(struct lease *lease)
int find_hosts_by_uid(struct host_decl **hp, const unsigned char *data, unsigned len, const char *file, int line)
void new_address_range(struct parse *cfile, struct iaddr low, struct iaddr high, struct subnet *subnet, struct pool *pool, struct lease **lpchain)
lease_id_hash_t * lease_uid_hash
isc_result_t enter_class(struct class *cd, int dynamicp, int commit)
void change_host_uid(struct host_decl *host, const char *uid, int len)
void lease_remove_all(struct lease **lq)
void enter_shared_network(struct shared_network *share)
int find_host_for_network(struct subnet **sp, struct host_decl **host, struct iaddr *addr, struct shared_network *share)
host_hash_t * host_name_hash
isc_result_t enter_host(struct host_decl *hd, int dynamicp, int commit)
host_hash_t * host_uid_hash
void pool_timer(void *vpool)
int find_hosts_by_option(struct host_decl **hp, struct packet *packet, struct option_state *opt_state, const char *file, int line)
int find_lease_by_uid(struct lease **lp, const unsigned char *uid, unsigned len, const char *file, int line)
isc_result_t delete_class(struct class *cp, int commit)
int find_subnet(struct subnet **sp, struct iaddr addr, const char *file, int line)
int find_lease_by_hw_addr(struct lease **lp, const unsigned char *hwaddr, unsigned hwlen, const char *file, int line)
int find_lease_by_ip_addr(struct lease **lp, struct iaddr addr, const char *file, int line)
int find_hosts_by_haddr(struct host_decl **hp, int htype, const unsigned char *haddr, unsigned hlen, const char *file, int line)
void lease_remove(struct lease **lq, struct lease *comp)
void new_shared_network_interface(struct parse *cfile, struct shared_network *share, const char *name)
void uid_hash_delete(struct lease *lease)
isc_result_t delete_host(struct host_decl *hd, int commit)
int subnet_inner_than(const struct subnet *subnet, const struct subnet *scan, int warnp)
void release_lease(struct lease *lease, struct packet *packet)
void make_binding_state_transition(struct lease *lease)
lease_ip_hash_t * lease_ip_addr_hash
void abandon_lease(struct lease *lease, const char *message)
omapi_object_type_t * dhcp_type_host
struct group * root_group
group_hash_t * group_name_hash
isc_result_t omapi_object_dereference(omapi_object_t **, const char *, int)
isc_result_t omapi_unregister_io_object(omapi_object_t *)
isc_result_t omapi_io_state_foreach(isc_result_t(*func)(omapi_object_t *, void *), void *p)
calls a given function on every object
void omapi_type_relinquish(void)
void * dmalloc(size_t, const char *, int)
void dfree(void *, const char *, int)
isc_result_t omapi_object_initialize(omapi_object_t *, omapi_object_type_t *, size_t, size_t, 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 class * superclass
const unsigned char * data
enum executable_statement::statement_op op
union executable_statement::@7 data
u_int8_t hbuf[HARDWARE_ADDR_LEN+1]
struct option_cache * fixed_addr
struct data_string client_identifier
struct host_decl * n_ipaddr
struct hardware interface
struct host_id_info * next
host_hash_t * values_hash
struct interface_info * next
binding_state_t next_binding_state
struct dhcp_ddns_cb * ddns_cb
struct binding_scope * scope
struct hardware hardware_addr
binding_state_t rewind_binding_state
binding_state_t desired_binding_state
struct class * billing_class
binding_state_t binding_state
struct executable_statement * on_commit
struct executable_statement * on_expiry
struct executable_statement * on_release
struct packet * dhcpv6_container_packet
struct option_state * options
dhcp_failover_state_t * failover_peer
struct shared_network * next
struct subnet * next_subnet
struct subnet * next_sibling
int option_reference(struct option **dest, struct option *src, const char *file, int line)
int option_dereference(struct option **dest, const char *file, int line)
universe_hash_t * universe_hash
struct universe ** universes
void trace_free_all(void)
int binding_scope_dereference(struct binding_scope **ptr, const char *file, int line)
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)
struct binding_scope * global_scope