server/mdb6.c File Reference

#include "config.h"
#include <sys/types.h>
#include <time.h>
#include <netinet/in.h>
#include <stdarg.h>
#include "dhcpd.h"
#include "omapip/omapip.h"
#include "omapip/hash.h"
#include <isc/md5.h>

Go to the source code of this file.

Functions

 HASH_FUNCTIONS (ia, unsigned char *, struct ia_xx, ia_hash_t, ia_reference, ia_dereference, do_string_hash)
isc_result_t iasubopt_reference (struct iasubopt **iasubopt, struct iasubopt *src, const char *file, int line)
isc_result_t iasubopt_dereference (struct iasubopt **iasubopt, const char *file, int line)
isc_result_t ia_make_key (struct data_string *key, u_int32_t iaid, const char *duid, unsigned int duid_len, const char *file, int line)
isc_result_t ia_allocate (struct ia_xx **ia, u_int32_t iaid, const char *duid, unsigned int duid_len, const char *file, int line)
isc_result_t ia_reference (struct ia_xx **ia, struct ia_xx *src, const char *file, int line)
isc_result_t ia_dereference (struct ia_xx **ia, const char *file, int line)
isc_result_t ia_add_iasubopt (struct ia_xx *ia, struct iasubopt *iasubopt, const char *file, int line)
void ia_remove_iasubopt (struct ia_xx *ia, struct iasubopt *iasubopt, const char *file, int line)
void ia_remove_all_lease (struct ia_xx *ia, const char *file, int line)
isc_boolean_t ia_equal (const struct ia_xx *a, const struct ia_xx *b)
isc_result_t ipv6_pool_allocate (struct ipv6_pool **pool, u_int16_t type, const struct in6_addr *start_addr, int bits, int units, const char *file, int line)
 Create a new IPv6 lease pool structure.
isc_result_t ipv6_pool_reference (struct ipv6_pool **pool, struct ipv6_pool *src, const char *file, int line)
 reference an IPv6 pool structure.
isc_result_t ipv6_pool_dereference (struct ipv6_pool **pool, const char *file, int line)
 de-reference an IPv6 pool structure.
isc_result_t create_lease6 (struct ipv6_pool *pool, struct iasubopt **addr, unsigned int *attempts, const struct data_string *uid, time_t soft_lifetime_end_time)
isc_result_t cleanup_lease6 (ia_hash_t *ia_table, struct ipv6_pool *pool, struct iasubopt *lease, struct ia_xx *ia)
 Cleans up leases when reading from a lease file.
isc_result_t add_lease6 (struct ipv6_pool *pool, struct iasubopt *lease, time_t valid_lifetime_end_time)
isc_boolean_t lease6_exists (const struct ipv6_pool *pool, const struct in6_addr *addr)
isc_boolean_t lease6_usable (struct iasubopt *lease)
 Check if address is available to a lease.
isc_result_t renew_lease6 (struct ipv6_pool *pool, struct iasubopt *lease)
 Renew a lease in the pool.
isc_result_t expire_lease6 (struct iasubopt **leasep, struct ipv6_pool *pool, time_t now)
isc_result_t decline_lease6 (struct ipv6_pool *pool, struct iasubopt *lease)
isc_result_t release_lease6 (struct ipv6_pool *pool, struct iasubopt *lease)
void build_prefix6 (struct in6_addr *pref, const struct in6_addr *net_start_pref, int pool_bits, int pref_bits, const struct data_string *input)
isc_result_t create_prefix6 (struct ipv6_pool *pool, struct iasubopt **pref, unsigned int *attempts, const struct data_string *uid, time_t soft_lifetime_end_time)
isc_boolean_t prefix6_exists (const struct ipv6_pool *pool, const struct in6_addr *pref, u_int8_t plen)
isc_result_t mark_lease_unavailable (struct ipv6_pool *pool, const struct in6_addr *addr)
isc_result_t add_ipv6_pool (struct ipv6_pool *pool)
void schedule_lease_timeout (struct ipv6_pool *pool)
void schedule_all_ipv6_lease_timeouts (void)
isc_boolean_t ipv6_in_pool (const struct in6_addr *addr, const struct ipv6_pool *pool)
isc_result_t find_ipv6_pool (struct ipv6_pool **pool, u_int16_t type, const struct in6_addr *addr)
isc_result_t renew_leases (struct ia_xx *ia)
isc_result_t release_leases (struct ia_xx *ia)
isc_result_t decline_leases (struct ia_xx *ia)
int write_leases6 (void)
void mark_hosts_unavailable (void)
void mark_phosts_unavailable (void)
void mark_interfaces_unavailable (void)
isc_result_t ipv6_pond_allocate (struct ipv6_pond **pond, const char *file, int line)
 Create a new IPv6 pond structure.
isc_result_t ipv6_pond_reference (struct ipv6_pond **pond, struct ipv6_pond *src, const char *file, int line)
 reference an IPv6 pond structure.
isc_result_t ipv6_pond_dereference (struct ipv6_pond **pond, const char *file, int line)
 de-reference an IPv6 pond structure.

Detailed Description

Todo:

assert()

simplify functions, as pool is now in iaaddr

Definition in file mdb6.c.


Function Documentation

isc_result_t add_ipv6_pool ( struct ipv6_pool pool  ) 

Definition at line 1798 of file mdb6.c.

isc_result_t add_lease6 ( struct ipv6_pool pool,
struct iasubopt lease,
time_t  valid_lifetime_end_time 
)

Definition at line 1226 of file mdb6.c.

void build_prefix6 ( struct in6_addr *  pref,
const struct in6_addr *  net_start_pref,
int  pool_bits,
int  pref_bits,
const struct data_string input 
)

Definition at line 1588 of file mdb6.c.

isc_result_t cleanup_lease6 ( ia_hash_t ia_table,
struct ipv6_pool pool,
struct iasubopt lease,
struct ia_xx ia 
)

Cleans up leases when reading from a lease file.

This function is only expected to be run when reading leases in from a file. It checks to see if a lease already exists for the new leases's address. We don't add expired leases to the structures when reading a lease file which limits what can happen. We have two variables the owners of the leases being the same or different and the new lease being active or non-active: Owners active same no remove old lease and its connections same yes nothing to do, other code will update the structures. diff no nothing to do diff yes this combination shouldn't happen, we should only have a single active lease per address at a time and that lease should move to non-active before any other lease can become active for that address. Currently we delete the previous lease and pass an error to the caller who should log an error.

When we remove a lease we remove it from the hash table and active heap (remember only active leases are in the structures at this time) for the pool, and from the IA's array. If, after we've removed the pointer from IA's array to the lease, the IA has no more pointers we remove it from the appropriate hash table as well.

Parameters:
[in] ia_table = the hash table for the IA
[in] pool = the pool to update
[in] lease = the new lease we want to add
[in] ia = the new ia we are building
Returns:
ISC_R_SUCCESS = the incoming lease and any previous lease were in an expected state - one of the first 3 options above. If necessary the old lease was removed. ISC_R_FAILURE = there is already an active lease for the address in the incoming lease. This shouldn't happen if it does flag an error for the caller to log.

Definition at line 1124 of file mdb6.c.

isc_result_t create_lease6 ( struct ipv6_pool pool,
struct iasubopt **  addr,
unsigned int attempts,
const struct data_string uid,
time_t  soft_lifetime_end_time 
)

Definition at line 953 of file mdb6.c.

isc_result_t create_prefix6 ( struct ipv6_pool pool,
struct iasubopt **  pref,
unsigned int attempts,
const struct data_string uid,
time_t  soft_lifetime_end_time 
)

Definition at line 1668 of file mdb6.c.

isc_result_t decline_lease6 ( struct ipv6_pool pool,
struct iasubopt lease 
)

Definition at line 1555 of file mdb6.c.

isc_result_t decline_leases ( struct ia_xx ia  ) 

Definition at line 2142 of file mdb6.c.

isc_result_t expire_lease6 ( struct iasubopt **  leasep,
struct ipv6_pool pool,
time_t  now 
)

Definition at line 1521 of file mdb6.c.

isc_result_t find_ipv6_pool ( struct ipv6_pool **  pool,
u_int16_t  type,
const struct in6_addr *  addr 
)

Definition at line 2065 of file mdb6.c.

HASH_FUNCTIONS ( ia  ,
unsigned char *  ,
struct ia_xx  ,
ia_hash_t  ,
ia_reference  ,
ia_dereference  ,
do_string_hash   
)

Definition at line 180 of file mdb6.c.

isc_result_t ia_add_iasubopt ( struct ia_xx ia,
struct iasubopt iasubopt,
const char *  file,
int  line 
)

Definition at line 438 of file mdb6.c.

isc_result_t ia_allocate ( struct ia_xx **  ia,
u_int32_t  iaid,
const char *  duid,
unsigned int  duid_len,
const char *  file,
int  line 
)

Definition at line 338 of file mdb6.c.

isc_result_t ia_dereference ( struct ia_xx **  ia,
const char *  file,
int  line 
)

Definition at line 402 of file mdb6.c.

isc_boolean_t ia_equal ( const struct ia_xx a,
const struct ia_xx b 
)

Definition at line 517 of file mdb6.c.

isc_result_t ia_make_key ( struct data_string key,
u_int32_t  iaid,
const char *  duid,
unsigned int  duid_len,
const char *  file,
int  line 
)

Definition at line 310 of file mdb6.c.

isc_result_t ia_reference ( struct ia_xx **  ia,
struct ia_xx src,
const char *  file,
int  line 
)

Definition at line 376 of file mdb6.c.

void ia_remove_all_lease ( struct ia_xx ia,
const char *  file,
int  line 
)

Definition at line 503 of file mdb6.c.

void ia_remove_iasubopt ( struct ia_xx ia,
struct iasubopt iasubopt,
const char *  file,
int  line 
)

Definition at line 475 of file mdb6.c.

isc_result_t iasubopt_dereference ( struct iasubopt **  iasubopt,
const char *  file,
int  line 
)

Definition at line 260 of file mdb6.c.

isc_result_t iasubopt_reference ( struct iasubopt **  iasubopt,
struct iasubopt src,
const char *  file,
int  line 
)

Definition at line 233 of file mdb6.c.

isc_boolean_t ipv6_in_pool ( const struct in6_addr *  addr,
const struct ipv6_pool pool 
)

Definition at line 2047 of file mdb6.c.

isc_result_t ipv6_pond_allocate ( struct ipv6_pond **  pond,
const char *  file,
int  line 
)

Create a new IPv6 pond structure.

Allocate space for a new ipv6_pond structure and return a reference to it, includes setting the reference count to 1.

Parameters:
pond = space for returning a referenced pointer to the pond. This must point to a space that has been initialzied to NULL by the caller.
Returns:
ISC_R_SUCCESS = The pond was successfully created, pond points to it. DHCP_R_INVALIDARG = One of the arugments was invalid, pond has not been modified ISC_R_NOMEMORY = The system wasn't able to allocate memory, pond has not been modified.

Definition at line 2344 of file mdb6.c.

isc_result_t ipv6_pond_dereference ( struct ipv6_pond **  pond,
const char *  file,
int  line 
)

de-reference an IPv6 pond structure.

This function decrements the reference count in an ipv6_pond structure. If this was the last reference then the memory for the structure is freed.

Parameters:
[in] pond = A pointer to the pointer to the pond that should be de-referenced. On success the pointer to the pond is cleared. It must not be NULL and must not point to NULL.
Returns:
ISC_R_SUCCESS = The pond was successfully de-referenced, pond now points to NULL DHCP_R_INVALIDARG = One of the arugments was invalid, pond has not been modified.

Definition at line 2427 of file mdb6.c.

isc_result_t ipv6_pond_reference ( struct ipv6_pond **  pond,
struct ipv6_pond src,
const char *  file,
int  line 
)

reference an IPv6 pond structure.

This function genreates a reference to an ipv6_pond structure and increments the reference count on the structure.

Parameters:
[out] pond = space for returning a referenced pointer to the pond. This must point to a space that has been initialzied to NULL by the caller.
[in] src = A pointer to the pond to reference. This must not be NULL.
Returns:
ISC_R_SUCCESS = The pond was successfully referenced, pond now points to src. DHCP_R_INVALIDARG = One of the arugments was invalid, pond has not been modified.

Definition at line 2387 of file mdb6.c.

isc_result_t ipv6_pool_allocate ( struct ipv6_pool **  pool,
u_int16_t  type,
const struct in6_addr *  start_addr,
int  bits,
int  units,
const char *  file,
int  line 
)

Create a new IPv6 lease pool structure.

Allocate space for a new ipv6_pool structure and return a reference to it, includes setting the reference count to 1.

Parameters:
pool = space for returning a referenced pointer to the pool. This must point to a space that has been initialzied to NULL by the caller.
[in] type = The type of the pool NA, TA or PD
[in] start_addr = The first address in the range for the pool
[in] bits = The contiguous bits of the pool
Returns:
ISC_R_SUCCESS = The pool was successfully created, pool points to it. DHCP_R_INVALIDARG = One of the arugments was invalid, pool has not been modified ISC_R_NOMEMORY = The system wasn't able to allocate memory, pool has not been modified.

Definition at line 635 of file mdb6.c.

isc_result_t ipv6_pool_dereference ( struct ipv6_pool **  pool,
const char *  file,
int  line 
)

de-reference an IPv6 pool structure.

This function decrements the reference count in an ipv6_pool structure. If this was the last reference then the memory for the structure is freed.

Parameters:
[in] pool = A pointer to the pointer to the pool that should be de-referenced. On success the pointer to the pool is cleared. It must not be NULL and must not point to NULL.
Returns:
ISC_R_SUCCESS = The pool was successfully de-referenced, pool now points to NULL DHCP_R_INVALIDARG = One of the arugments was invalid, pool has not been modified.

Definition at line 772 of file mdb6.c.

isc_result_t ipv6_pool_reference ( struct ipv6_pool **  pool,
struct ipv6_pool src,
const char *  file,
int  line 
)

reference an IPv6 pool structure.

This function genreates a reference to an ipv6_pool structure and increments the reference count on the structure.

Parameters:
[out] pool = space for returning a referenced pointer to the pool. This must point to a space that has been initialzied to NULL by the caller.
[in] src = A pointer to the pool to reference. This must not be NULL.
Returns:
ISC_R_SUCCESS = The pool was successfully referenced, pool now points to src. DHCP_R_INVALIDARG = One of the arugments was invalid, pool has not been modified.

Definition at line 701 of file mdb6.c.

isc_boolean_t lease6_exists ( const struct ipv6_pool pool,
const struct in6_addr *  addr 
)

Definition at line 1318 of file mdb6.c.

isc_boolean_t lease6_usable ( struct iasubopt lease  ) 

Check if address is available to a lease.

Determine if the address in the lease is available to that lease. Either the address isn't in use or it is in use but by that lease.

Parameters:
[in] lease = lease to check
Returns:
ISC_TRUE = The lease is allowed to use that address ISC_FALSE = The lease isn't allowed to use that address

Definition at line 1346 of file mdb6.c.

void mark_hosts_unavailable ( void   ) 

Definition at line 2245 of file mdb6.c.

void mark_interfaces_unavailable ( void   ) 

Definition at line 2300 of file mdb6.c.

isc_result_t mark_lease_unavailable ( struct ipv6_pool pool,
const struct in6_addr *  addr 
)

Definition at line 1780 of file mdb6.c.

void mark_phosts_unavailable ( void   ) 

Definition at line 2295 of file mdb6.c.

isc_boolean_t prefix6_exists ( const struct ipv6_pool pool,
const struct in6_addr *  pref,
u_int8_t  plen 
)

Definition at line 1757 of file mdb6.c.

isc_result_t release_lease6 ( struct ipv6_pool pool,
struct iasubopt lease 
)

Definition at line 1575 of file mdb6.c.

isc_result_t release_leases ( struct ia_xx ia  ) 

Definition at line 2134 of file mdb6.c.

isc_result_t renew_lease6 ( struct ipv6_pool pool,
struct iasubopt lease 
)

Renew a lease in the pool.

The hard_lifetime_end_time of the lease should be set to the current expiration time. The soft_lifetime_end_time of the lease should be set to the desired expiration time.

This routine will compare the two and call the correct heap routine to move the lease. If the lease is active and the new expiration time is greater (the normal case) then we call isc_heap_decreased() as a larger time is a lower priority. If the new expiration time is less then we call isc_heap_increased().

If the lease is abandoned then it will be on the active list and we will always call isc_heap_increased() as the previous expiration would have been all 1s (as close as we can get to infinite).

If the lease is moving to active we call that routine which will move it from the inactive list to the active list.

Parameters:
pool = a pool the lease belongs to
lease = the lease to be renewed
Returns:
result of the renew operation (ISC_R_SUCCESS if successful, ISC_R_NOMEMORY when run out of memory)

Definition at line 1415 of file mdb6.c.

isc_result_t renew_leases ( struct ia_xx ia  ) 

Definition at line 2126 of file mdb6.c.

void schedule_all_ipv6_lease_timeouts ( void   ) 

Definition at line 1982 of file mdb6.c.

void schedule_lease_timeout ( struct ipv6_pool pool  ) 

Definition at line 1939 of file mdb6.c.

int write_leases6 ( void   ) 

Definition at line 2168 of file mdb6.c.


Generated on 5 Apr 2014 for ISC DHCP by  doxygen 1.6.1