#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. More... | |
isc_result_t | ipv6_pool_reference (struct ipv6_pool **pool, struct ipv6_pool *src, const char *file, int line) |
reference an IPv6 pool structure. More... | |
isc_result_t | ipv6_pool_dereference (struct ipv6_pool **pool, const char *file, int line) |
de-reference an IPv6 pool structure. More... | |
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. More... | |
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. More... | |
isc_result_t | renew_lease6 (struct ipv6_pool *pool, struct iasubopt *lease) |
Renew a lease in the pool. More... | |
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) |
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. More... | |
isc_result_t | ipv6_pond_reference (struct ipv6_pond **pond, struct ipv6_pond *src, const char *file, int line) |
reference an IPv6 pond structure. More... | |
isc_result_t | ipv6_pond_dereference (struct ipv6_pond **pond, const char *file, int line) |
de-reference an IPv6 pond structure. More... | |
void | report_jumbo_ranges () |
int | htype_bounds_check (uint16_t htype) |
int | find_hosts_by_haddr6 (struct host_decl **hp, struct packet *packet, struct option_state *opt_state, const char *file, int line) |
Look for hosts by MAC address if it's available. More... | |
int | find_hosts_by_duid_chaddr (struct host_decl **host, const struct data_string *client_id) |
int | find_hosts6 (struct host_decl **host, struct packet *packet, const struct data_string *client_id, char *file, int line) |
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 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.
[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 |
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 create_prefix6 | ( | struct ipv6_pool * | pool, |
struct iasubopt ** | pref, | ||
unsigned int * | attempts, | ||
const struct data_string * | uid, | ||
time_t | soft_lifetime_end_time | ||
) |
int find_hosts6 | ( | struct host_decl ** | host, |
struct packet * | packet, | ||
const struct data_string * | client_id, | ||
char * | file, | ||
int | line | ||
) |
int find_hosts_by_duid_chaddr | ( | struct host_decl ** | host, |
const struct data_string * | client_id | ||
) |
int find_hosts_by_haddr6 | ( | struct host_decl ** | hp, |
struct packet * | packet, | ||
struct option_state * | opt_state, | ||
const char * | file, | ||
int | line | ||
) |
Look for hosts by MAC address if it's available.
Checks the inbound packet against host declarations which specified:
"hardware ethernet <MAC>;"
For directly connected clients, the function will use the MAC address contained in packet:haddr if it's populated. - While the logic is in place for this search, the socket layer does not yet populate packet:haddr, this is to be done under rt41523.
For relayed clients, the function will use the MAC address from the client-linklayer-address option if it has been supplied by the relay directly connected to the client.
hp[out] | - pointer to storage for the host delcaration if found |
packet | - received packet |
opt_state | - option state to search |
file | - source file |
line | - line number |
isc_result_t find_ipv6_pool | ( | struct ipv6_pool ** | pool, |
u_int16_t | type, | ||
const struct in6_addr * | addr | ||
) |
HASH_FUNCTIONS | ( | ia | , |
unsigned char * | , | ||
struct ia_xx | , | ||
ia_hash_t | , | ||
ia_reference | , | ||
ia_dereference | , | ||
do_string_hash | |||
) |
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_boolean_t ipv6_in_pool | ( | const struct in6_addr * | addr, |
const struct ipv6_pool * | pool | ||
) |
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.
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. |
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.
[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. |
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.
[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. |
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.
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 |
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.
[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. |
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.
[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. |
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.
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.
[in] | lease | = lease to check |
isc_result_t mark_lease_unavailable | ( | struct ipv6_pool * | pool, |
const struct in6_addr * | addr | ||
) |
isc_boolean_t prefix6_exists | ( | const struct ipv6_pool * | pool, |
const struct in6_addr * | pref, | ||
u_int8_t | plen | ||
) |
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.
pool | = a pool the lease belongs to |
lease | = the lease to be renewed |