mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-02 15:25:48 +00:00
Merged IA_XXrelated structures
This commit is contained in:
2
RELNOTES
2
RELNOTES
@@ -71,6 +71,8 @@ work on other platforms. Please report any problems and suggested fixes to
|
|||||||
|
|
||||||
- Prefix pools are attached to shared network scopes.
|
- Prefix pools are attached to shared network scopes.
|
||||||
|
|
||||||
|
- Merged IA_XX related structures.
|
||||||
|
|
||||||
Changes since 4.0.0 (new features)
|
Changes since 4.0.0 (new features)
|
||||||
|
|
||||||
- Added DHCPv6 rapid commit support.
|
- Added DHCPv6 rapid commit support.
|
||||||
|
168
includes/dhcpd.h
168
includes/dhcpd.h
@@ -813,7 +813,6 @@ struct shared_network {
|
|||||||
struct ipv6_pool **ipv6_pools; /* NULL-terminated array */
|
struct ipv6_pool **ipv6_pools; /* NULL-terminated array */
|
||||||
int last_ipv6_pool; /* offset of last IPv6 pool
|
int last_ipv6_pool; /* offset of last IPv6 pool
|
||||||
used to issue a lease */
|
used to issue a lease */
|
||||||
struct ipv6_ppool **ipv6_ppools; /* NULL-terminated array */
|
|
||||||
struct group *group;
|
struct group *group;
|
||||||
#if defined (FAILOVER_PROTOCOL)
|
#if defined (FAILOVER_PROTOCOL)
|
||||||
dhcp_failover_state_t *failover_peer;
|
dhcp_failover_state_t *failover_peer;
|
||||||
@@ -1334,19 +1333,22 @@ typedef unsigned char option_mask [16];
|
|||||||
#define MIN_TIME 0
|
#define MIN_TIME 0
|
||||||
|
|
||||||
/* these are referenced */
|
/* these are referenced */
|
||||||
typedef struct hash_table ia_na_hash_t;
|
typedef struct hash_table ia_hash_t;
|
||||||
typedef struct hash_table iaaddr_hash_t;
|
typedef struct hash_table iaaddr_hash_t;
|
||||||
|
|
||||||
|
/* should be lease6 */
|
||||||
|
/* shared with iaprefix */
|
||||||
|
|
||||||
struct iaaddr {
|
struct iaaddr {
|
||||||
int refcnt; /* reference count */
|
int refcnt; /* reference count */
|
||||||
struct in6_addr addr; /* IPv6 address */
|
struct in6_addr addr; /* IPv6 address/prefix */
|
||||||
u_int8_t plen; /* unused/placeholder */
|
u_int8_t plen; /* iaprefix prefix length */
|
||||||
binding_state_t state; /* state */
|
binding_state_t state; /* state */
|
||||||
struct binding_scope *scope; /* "set var = value;" */
|
struct binding_scope *scope; /* "set var = value;" */
|
||||||
time_t hard_lifetime_end_time; /* time address expires */
|
time_t hard_lifetime_end_time; /* time address expires */
|
||||||
time_t soft_lifetime_end_time; /* time ephemeral expires */
|
time_t soft_lifetime_end_time; /* time ephemeral expires */
|
||||||
struct ia_na *ia_na; /* IA for this address */
|
struct ia_xx *ia; /* IA for this lease */
|
||||||
struct ipv6_pool *ipv6_pool; /* pool for this address */
|
struct ipv6_pool *ipv6_pool; /* pool for this lease */
|
||||||
/*
|
/*
|
||||||
* For now, just pick an arbitrary time to keep old hard leases
|
* For now, just pick an arbitrary time to keep old hard leases
|
||||||
* around (value in seconds).
|
* around (value in seconds).
|
||||||
@@ -1357,23 +1359,25 @@ struct iaaddr {
|
|||||||
(internal use only) */
|
(internal use only) */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ia_na {
|
struct ia_xx {
|
||||||
int refcnt; /* reference count */
|
int refcnt; /* reference count */
|
||||||
struct data_string iaid_duid; /* from the client */
|
struct data_string iaid_duid; /* from the client */
|
||||||
u_int16_t ia_type; /* IA_NA or IA_TA */
|
u_int16_t ia_type; /* IA_XX */
|
||||||
int num_iaaddr; /* number of IAADDR for this IA_NA */
|
int num_iaaddr; /* number of IAADDR for this IA */
|
||||||
int max_iaaddr; /* space available for IAADDR */
|
int max_iaaddr; /* space available for IAADDR */
|
||||||
struct iaaddr **iaaddr; /* pointers to the various IAADDRs */
|
struct iaaddr **iaaddr; /* pointers to the various IAADDRs */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ia_na_hash_t *ia_na_active;
|
extern ia_hash_t *ia_na_active;
|
||||||
extern ia_na_hash_t *ia_ta_active;
|
extern ia_hash_t *ia_ta_active;
|
||||||
|
extern ia_hash_t *ia_pd_active;
|
||||||
|
|
||||||
struct ipv6_pool {
|
struct ipv6_pool {
|
||||||
int refcnt; /* reference count */
|
int refcnt; /* reference count */
|
||||||
|
u_int16_t pool_type; /* IA_xx */
|
||||||
struct in6_addr start_addr; /* first IPv6 address */
|
struct in6_addr start_addr; /* first IPv6 address */
|
||||||
#define POOL_IS_FOR_TEMP 0x8000
|
|
||||||
int bits; /* number of bits, CIDR style */
|
int bits; /* number of bits, CIDR style */
|
||||||
|
int units; /* allocation unit in bits */
|
||||||
iaaddr_hash_t *addrs; /* non-free IAADDR */
|
iaaddr_hash_t *addrs; /* non-free IAADDR */
|
||||||
int num_active; /* count of active IAADDR */
|
int num_active; /* count of active IAADDR */
|
||||||
isc_heap_t *active_timeouts; /* timeouts for active leases */
|
isc_heap_t *active_timeouts; /* timeouts for active leases */
|
||||||
@@ -1387,54 +1391,6 @@ struct ipv6_pool {
|
|||||||
extern struct ipv6_pool **pools;
|
extern struct ipv6_pool **pools;
|
||||||
extern int num_pools;
|
extern int num_pools;
|
||||||
|
|
||||||
/* Sames thing for IA_PDs */
|
|
||||||
|
|
||||||
typedef struct hash_table ia_pd_hash_t;
|
|
||||||
typedef struct hash_table iaprefix_hash_t;
|
|
||||||
|
|
||||||
struct iaprefix {
|
|
||||||
/* Must keep the same layout than iaaddr */
|
|
||||||
int refcnt; /* reference count */
|
|
||||||
struct in6_addr pref; /* IPv6 prefix */
|
|
||||||
u_int8_t plen; /* prefix length */
|
|
||||||
binding_state_t state; /* state */
|
|
||||||
struct binding_scope *scope; /* "set var = value;" */
|
|
||||||
time_t hard_lifetime_end_time; /* time prefix expires */
|
|
||||||
time_t soft_lifetime_end_time; /* time ephemeral expires */
|
|
||||||
struct ia_pd *ia_pd; /* IA for this prefix */
|
|
||||||
struct ipv6_ppool *ipv6_ppool; /* pool for this prefix */
|
|
||||||
int heap_index; /* index into heap, or -1
|
|
||||||
(internal use only) */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ia_pd {
|
|
||||||
int refcnt; /* reference count */
|
|
||||||
struct data_string iaid_duid; /* from the client */
|
|
||||||
int num_iaprefix; /* number of IAPREFIX for this IA_PD */
|
|
||||||
int max_iaprefix; /* space available for IAPREFIX */
|
|
||||||
struct iaprefix **iaprefix; /* pointers to the various IAPREFIXs */
|
|
||||||
};
|
|
||||||
|
|
||||||
extern ia_pd_hash_t *ia_pd_active;
|
|
||||||
|
|
||||||
struct ipv6_ppool {
|
|
||||||
int refcnt; /* reference count */
|
|
||||||
struct in6_addr start_pref; /* first IPv6 prefix */
|
|
||||||
u_int8_t pool_plen; /* pool prefix length */
|
|
||||||
u_int8_t alloc_plen; /* allocation prefix length */
|
|
||||||
iaprefix_hash_t *prefs; /* non-free IAPREFIX */
|
|
||||||
int num_active; /* count of active IAPREFIX */
|
|
||||||
isc_heap_t *active_timeouts; /* timeouts for active leases */
|
|
||||||
int num_inactive; /* count of inactive IAADDR */
|
|
||||||
isc_heap_t *inactive_timeouts; /* timeouts for expired or
|
|
||||||
released leases */
|
|
||||||
struct shared_network *shared_network; /* shared_network for
|
|
||||||
this pool */
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct ipv6_ppool **ppools;
|
|
||||||
extern int num_ppools;
|
|
||||||
|
|
||||||
/* External definitions... */
|
/* External definitions... */
|
||||||
|
|
||||||
HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t)
|
HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t)
|
||||||
@@ -2590,8 +2546,7 @@ int commit_leases PROTO ((void));
|
|||||||
void db_startup PROTO ((int));
|
void db_startup PROTO ((int));
|
||||||
int new_lease_file PROTO ((void));
|
int new_lease_file PROTO ((void));
|
||||||
int group_writer (struct group_object *);
|
int group_writer (struct group_object *);
|
||||||
int write_ia(const struct ia_na *);
|
int write_ia(const struct ia_xx *);
|
||||||
int write_ia_pd(const struct ia_pd *);
|
|
||||||
|
|
||||||
/* packet.c */
|
/* packet.c */
|
||||||
u_int32_t checksum PROTO ((unsigned char *, unsigned, u_int32_t));
|
u_int32_t checksum PROTO ((unsigned char *, unsigned, u_int32_t));
|
||||||
@@ -3240,7 +3195,7 @@ isc_result_t dhcp_failover_process_update_request_all (dhcp_failover_state_t *,
|
|||||||
failover_message_t *);
|
failover_message_t *);
|
||||||
isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *,
|
isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *,
|
||||||
failover_message_t *);
|
failover_message_t *);
|
||||||
void ia_na_remove_all_iaaddr(struct ia_na *ia_na, const char *file, int line);
|
void ia_remove_all_iaaddr(struct ia_xx *ia, const char *file, int line);
|
||||||
void dhcp_failover_recover_done (void *);
|
void dhcp_failover_recover_done (void *);
|
||||||
void failover_print PROTO ((char *, unsigned *, unsigned, const char *));
|
void failover_print PROTO ((char *, unsigned *, unsigned, const char *));
|
||||||
void update_partner PROTO ((struct lease *));
|
void update_partner PROTO ((struct lease *));
|
||||||
@@ -3268,11 +3223,8 @@ const char *binding_state_print (enum failover_state);
|
|||||||
|
|
||||||
|
|
||||||
/* mdb6.c */
|
/* mdb6.c */
|
||||||
HASH_FUNCTIONS_DECL(ia_na, unsigned char *, struct ia_na, ia_na_hash_t);
|
HASH_FUNCTIONS_DECL(ia, unsigned char *, struct ia_xx, ia_hash_t);
|
||||||
HASH_FUNCTIONS_DECL(ia_pd, unsigned char *, struct ia_pd, ia_pd_hash_t);
|
|
||||||
HASH_FUNCTIONS_DECL(iaaddr, struct in6_addr *, struct iaaddr, iaaddr_hash_t);
|
HASH_FUNCTIONS_DECL(iaaddr, struct in6_addr *, struct iaaddr, iaaddr_hash_t);
|
||||||
HASH_FUNCTIONS_DECL(iaprefix, struct in6_addr *,
|
|
||||||
struct iaprefix, iaaddr_hash_t);
|
|
||||||
|
|
||||||
isc_result_t iaaddr_allocate(struct iaaddr **iaaddr,
|
isc_result_t iaaddr_allocate(struct iaaddr **iaaddr,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
@@ -3281,60 +3233,31 @@ isc_result_t iaaddr_reference(struct iaaddr **iaaddr, struct iaaddr *src,
|
|||||||
isc_result_t iaaddr_dereference(struct iaaddr **iaaddr,
|
isc_result_t iaaddr_dereference(struct iaaddr **iaaddr,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
|
|
||||||
isc_result_t iaprefix_allocate(struct iaprefix **iaprefix,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t iaprefix_reference(struct iaprefix **iaprefix,
|
|
||||||
struct iaprefix *src,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t iaprefix_dereference(struct iaprefix **iaprefix,
|
|
||||||
const char *file, int line);
|
|
||||||
|
|
||||||
isc_result_t ia_make_key(struct data_string *key, u_int32_t iaid,
|
isc_result_t ia_make_key(struct data_string *key, u_int32_t iaid,
|
||||||
const char *duid, unsigned int duid_len,
|
const char *duid, unsigned int duid_len,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ia_na_allocate(struct ia_na **ia_na, u_int32_t iaid,
|
isc_result_t ia_allocate(struct ia_xx **ia, u_int32_t iaid,
|
||||||
const char *duid, unsigned int duid_len,
|
const char *duid, unsigned int duid_len,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ia_na_reference(struct ia_na **ia_na, struct ia_na *src,
|
isc_result_t ia_reference(struct ia_xx **ia, struct ia_xx *src,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ia_na_dereference(struct ia_na **ia_na,
|
isc_result_t ia_dereference(struct ia_xx **ia,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ia_na_add_iaaddr(struct ia_na *ia_na, struct iaaddr *iaaddr,
|
isc_result_t ia_add_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
void ia_na_remove_iaaddr(struct ia_na *ia_na, struct iaaddr *iaaddr,
|
void ia_remove_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_boolean_t ia_na_equal(const struct ia_na *a, const struct ia_na *b);
|
isc_boolean_t ia_equal(const struct ia_xx *a, const struct ia_xx *b);
|
||||||
|
|
||||||
isc_result_t ia_pd_allocate(struct ia_pd **ia_pd, u_int32_t iaid,
|
isc_result_t ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type,
|
||||||
const char *duid, unsigned int duid_len,
|
const struct in6_addr *start_addr,
|
||||||
const char *file, int line);
|
int bits, int units,
|
||||||
isc_result_t ia_pd_reference(struct ia_pd **ia_pd, struct ia_pd *src,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t ia_pd_dereference(struct ia_pd **ia_pd,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t ia_pd_add_iaprefix(struct ia_pd *ia_pd, struct iaprefix *iaprefix,
|
|
||||||
const char *file, int line);
|
|
||||||
void ia_pd_remove_iaprefix(struct ia_pd *ia_pd, struct iaprefix *iaprefix,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_boolean_t ia_pd_equal(const struct ia_pd *a, const struct ia_pd *b);
|
|
||||||
|
|
||||||
isc_result_t ipv6_pool_allocate(struct ipv6_pool **pool,
|
|
||||||
const struct in6_addr *start_addr, int bits,
|
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ipv6_pool_reference(struct ipv6_pool **pool,
|
isc_result_t ipv6_pool_reference(struct ipv6_pool **pool,
|
||||||
struct ipv6_pool *src,
|
struct ipv6_pool *src,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool,
|
isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool,
|
||||||
const char *file, int line);
|
const char *file, int line);
|
||||||
isc_result_t ipv6_ppool_allocate(struct ipv6_ppool **ppool,
|
|
||||||
const struct in6_addr *start_pref,
|
|
||||||
u_int8_t pool_plen, u_int8_t alloc_plen,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t ipv6_ppool_reference(struct ipv6_ppool **ppool,
|
|
||||||
struct ipv6_ppool *src,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t ipv6_ppool_dereference(struct ipv6_ppool **ppool,
|
|
||||||
const char *file, int line);
|
|
||||||
isc_result_t create_lease6(struct ipv6_pool *pool,
|
isc_result_t create_lease6(struct ipv6_pool *pool,
|
||||||
struct iaaddr **addr,
|
struct iaaddr **addr,
|
||||||
unsigned int *attempts,
|
unsigned int *attempts,
|
||||||
@@ -3350,46 +3273,29 @@ isc_result_t release_lease6(struct ipv6_pool *pool, struct iaaddr *addr);
|
|||||||
isc_result_t decline_lease6(struct ipv6_pool *pool, struct iaaddr *addr);
|
isc_result_t decline_lease6(struct ipv6_pool *pool, struct iaaddr *addr);
|
||||||
isc_boolean_t lease6_exists(const struct ipv6_pool *pool,
|
isc_boolean_t lease6_exists(const struct ipv6_pool *pool,
|
||||||
const struct in6_addr *addr);
|
const struct in6_addr *addr);
|
||||||
isc_result_t mark_address_unavailble(struct ipv6_pool *pool,
|
isc_result_t mark_lease_unavailble(struct ipv6_pool *pool,
|
||||||
const struct in6_addr *addr);
|
const struct in6_addr *addr);
|
||||||
|
|
||||||
isc_result_t create_prefix6(struct ipv6_ppool *ppool,
|
isc_result_t create_prefix6(struct ipv6_pool *pool,
|
||||||
struct iaprefix **pref,
|
struct iaaddr **pref,
|
||||||
unsigned int *attempts,
|
unsigned int *attempts,
|
||||||
const struct data_string *uid,
|
const struct data_string *uid,
|
||||||
time_t soft_lifetime_end_time);
|
time_t soft_lifetime_end_time);
|
||||||
isc_result_t add_prefix6(struct ipv6_ppool *ppool,
|
isc_boolean_t prefix6_exists(const struct ipv6_pool *pool,
|
||||||
struct iaprefix *pref,
|
|
||||||
time_t valid_lifetime_end_time);
|
|
||||||
isc_result_t renew_prefix6(struct ipv6_ppool *ppool, struct iaprefix *pref);
|
|
||||||
isc_result_t expire_prefix6(struct iaprefix **pref,
|
|
||||||
struct ipv6_ppool *ppool, time_t now);
|
|
||||||
isc_result_t release_prefix6(struct ipv6_ppool *ppool, struct iaprefix *pref);
|
|
||||||
isc_boolean_t prefix6_exists(const struct ipv6_ppool *ppool,
|
|
||||||
const struct in6_addr *pref, u_int8_t plen);
|
const struct in6_addr *pref, u_int8_t plen);
|
||||||
|
|
||||||
isc_result_t add_ipv6_pool(struct ipv6_pool *pool);
|
isc_result_t add_ipv6_pool(struct ipv6_pool *pool);
|
||||||
isc_result_t find_ipv6_pool(struct ipv6_pool **pool, int temp,
|
isc_result_t find_ipv6_pool(struct ipv6_pool **pool, u_int16_t type,
|
||||||
const struct in6_addr *addr);
|
const struct in6_addr *addr);
|
||||||
isc_boolean_t ipv6_addr_in_pool(const struct in6_addr *addr,
|
isc_boolean_t ipv6_in_pool(const struct in6_addr *addr,
|
||||||
const struct ipv6_pool *pool);
|
const struct ipv6_pool *pool);
|
||||||
isc_result_t add_ipv6_ppool(struct ipv6_ppool *ppool);
|
|
||||||
isc_result_t find_ipv6_ppool(struct ipv6_ppool **pool,
|
|
||||||
const struct in6_addr *pref);
|
|
||||||
isc_boolean_t ipv6_prefix_in_ppool(const struct in6_addr *pref,
|
|
||||||
const struct ipv6_ppool *ppool);
|
|
||||||
|
|
||||||
isc_result_t renew_leases(struct ia_na *ia_na);
|
isc_result_t renew_leases(struct ia_xx *ia);
|
||||||
isc_result_t release_leases(struct ia_na *ia_na);
|
isc_result_t release_leases(struct ia_xx *ia);
|
||||||
isc_result_t decline_leases(struct ia_na *ia_na);
|
isc_result_t decline_leases(struct ia_xx *ia);
|
||||||
void schedule_lease_timeout(struct ipv6_pool *pool);
|
void schedule_lease_timeout(struct ipv6_pool *pool);
|
||||||
void schedule_all_ipv6_lease_timeouts();
|
void schedule_all_ipv6_lease_timeouts();
|
||||||
|
|
||||||
isc_result_t renew_prefixes(struct ia_pd *ia_pd);
|
|
||||||
isc_result_t release_prefixes(struct ia_pd *ia_pd);
|
|
||||||
void schedule_prefix_timeout(struct ipv6_ppool *ppool);
|
|
||||||
void schedule_all_ipv6_prefix_timeouts();
|
|
||||||
|
|
||||||
void mark_hosts_unavailable(void);
|
void mark_hosts_unavailable(void);
|
||||||
void mark_phosts_unavailable(void);
|
void mark_phosts_unavailable(void);
|
||||||
void mark_interfaces_unavailable(void);
|
void mark_interfaces_unavailable(void);
|
||||||
|
@@ -590,12 +590,12 @@ int parse_statement (cfile, group, type, host_decl, declaration)
|
|||||||
|
|
||||||
case POOL:
|
case POOL:
|
||||||
next_token (&val, (unsigned *)0, cfile);
|
next_token (&val, (unsigned *)0, cfile);
|
||||||
if (type != SUBNET_DECL && type != SHARED_NET_DECL) {
|
if (type == POOL_DECL) {
|
||||||
parse_warn (cfile, "pool declared outside of network");
|
|
||||||
skip_to_semi(cfile);
|
|
||||||
} else if (type == POOL_DECL) {
|
|
||||||
parse_warn (cfile, "pool declared within pool.");
|
parse_warn (cfile, "pool declared within pool.");
|
||||||
skip_to_semi(cfile);
|
skip_to_semi(cfile);
|
||||||
|
} else if (type != SUBNET_DECL && type != SHARED_NET_DECL) {
|
||||||
|
parse_warn (cfile, "pool declared outside of network");
|
||||||
|
skip_to_semi(cfile);
|
||||||
} else
|
} else
|
||||||
parse_pool_statement (cfile, group, type);
|
parse_pool_statement (cfile, group, type);
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ int parse_statement (cfile, group, type, host_decl, declaration)
|
|||||||
next_token(NULL, NULL, cfile);
|
next_token(NULL, NULL, cfile);
|
||||||
if ((type != SUBNET_DECL) || (group->subnet == NULL)) {
|
if ((type != SUBNET_DECL) || (group->subnet == NULL)) {
|
||||||
parse_warn (cfile,
|
parse_warn (cfile,
|
||||||
"prefix6 definitions may not be scoped.");
|
"prefix6 declaration not allowed here.");
|
||||||
skip_to_semi(cfile);
|
skip_to_semi(cfile);
|
||||||
return declaration;
|
return declaration;
|
||||||
}
|
}
|
||||||
@@ -3637,8 +3637,10 @@ void parse_address_range (cfile, group, type, inpool, lpchain)
|
|||||||
#ifdef DHCPv6
|
#ifdef DHCPv6
|
||||||
static void
|
static void
|
||||||
add_ipv6_pool_to_shared_network(struct shared_network *share,
|
add_ipv6_pool_to_shared_network(struct shared_network *share,
|
||||||
|
u_int16_t type,
|
||||||
struct iaddr *lo_addr,
|
struct iaddr *lo_addr,
|
||||||
int bits) {
|
int bits,
|
||||||
|
int units) {
|
||||||
struct ipv6_pool *pool;
|
struct ipv6_pool *pool;
|
||||||
struct in6_addr tmp_in6_addr;
|
struct in6_addr tmp_in6_addr;
|
||||||
int num_pools;
|
int num_pools;
|
||||||
@@ -3653,8 +3655,8 @@ add_ipv6_pool_to_shared_network(struct shared_network *share,
|
|||||||
}
|
}
|
||||||
memcpy(&tmp_in6_addr, lo_addr->iabuf, sizeof(tmp_in6_addr));
|
memcpy(&tmp_in6_addr, lo_addr->iabuf, sizeof(tmp_in6_addr));
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
if (ipv6_pool_allocate(&pool, &tmp_in6_addr,
|
if (ipv6_pool_allocate(&pool, type, &tmp_in6_addr,
|
||||||
bits, MDL) != ISC_R_SUCCESS) {
|
bits, units, MDL) != ISC_R_SUCCESS) {
|
||||||
log_fatal("Out of memory");
|
log_fatal("Out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3765,7 +3767,8 @@ parse_address_range6(struct parse *cfile, struct group *group) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_ipv6_pool_to_shared_network(share, &lo, bits);
|
add_ipv6_pool_to_shared_network(share, D6O_IA_NA, &lo,
|
||||||
|
bits, 128);
|
||||||
|
|
||||||
} else if (token == TEMPORARY) {
|
} else if (token == TEMPORARY) {
|
||||||
/*
|
/*
|
||||||
@@ -3778,9 +3781,9 @@ parse_address_range6(struct parse *cfile, struct group *group) {
|
|||||||
skip_to_semi(cfile);
|
skip_to_semi(cfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bits |= POOL_IS_FOR_TEMP;
|
|
||||||
|
|
||||||
add_ipv6_pool_to_shared_network(share, &lo, bits);
|
add_ipv6_pool_to_shared_network(share, D6O_IA_TA, &lo,
|
||||||
|
bits, 128);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* No '/', so we are looking for the end address of
|
* No '/', so we are looking for the end address of
|
||||||
@@ -3799,9 +3802,9 @@ parse_address_range6(struct parse *cfile, struct group *group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (p=nets; p != NULL; p=p->next) {
|
for (p=nets; p != NULL; p=p->next) {
|
||||||
add_ipv6_pool_to_shared_network(share,
|
add_ipv6_pool_to_shared_network(share, D6O_IA_NA,
|
||||||
&p->cidrnet.lo_addr,
|
&p->cidrnet.lo_addr,
|
||||||
p->cidrnet.bits);
|
p->cidrnet.bits, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_iaddrcidrnetlist(&nets);
|
free_iaddrcidrnetlist(&nets);
|
||||||
@@ -3816,75 +3819,6 @@ parse_address_range6(struct parse *cfile, struct group *group) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
add_ipv6_ppool_to_shared_network(struct shared_network *share,
|
|
||||||
struct iaddr *start_addr,
|
|
||||||
int pool_bits,
|
|
||||||
int alloc_bits) {
|
|
||||||
struct ipv6_ppool *ppool;
|
|
||||||
struct in6_addr tmp_in6_addr;
|
|
||||||
int num_ppools;
|
|
||||||
struct ipv6_ppool **tmp;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create our prefix pool.
|
|
||||||
*/
|
|
||||||
if (start_addr->len != sizeof(tmp_in6_addr)) {
|
|
||||||
log_fatal("Internal error: Attempt to add non-IPv6 prefix.");
|
|
||||||
}
|
|
||||||
memcpy(&tmp_in6_addr, start_addr->iabuf, sizeof(tmp_in6_addr));
|
|
||||||
ppool = NULL;
|
|
||||||
if (ipv6_ppool_allocate(&ppool, &tmp_in6_addr,
|
|
||||||
(u_int8_t) pool_bits, (u_int8_t) alloc_bits,
|
|
||||||
MDL) != ISC_R_SUCCESS) {
|
|
||||||
log_fatal("Out of memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add to our IPv6 prefix pool set.
|
|
||||||
*/
|
|
||||||
if (add_ipv6_ppool(ppool) != ISC_R_SUCCESS) {
|
|
||||||
log_fatal ("Out of memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Link our prefix pool to our shared_network.
|
|
||||||
*/
|
|
||||||
ppool->shared_network = NULL;
|
|
||||||
shared_network_reference(&ppool->shared_network, share, MDL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Increase our array size for ipv6_ppools in the shared_network.
|
|
||||||
*/
|
|
||||||
if (share->ipv6_ppools == NULL) {
|
|
||||||
num_ppools = 0;
|
|
||||||
} else {
|
|
||||||
num_ppools = 0;
|
|
||||||
while (share->ipv6_ppools[num_ppools] != NULL) {
|
|
||||||
num_ppools++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmp = dmalloc(sizeof(struct ipv6_ppool *) * (num_ppools + 2), MDL);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
log_fatal("Out of memory");
|
|
||||||
}
|
|
||||||
if (num_ppools > 0) {
|
|
||||||
memcpy(tmp, share->ipv6_ppools,
|
|
||||||
sizeof(struct ipv6_ppool *) * num_ppools);
|
|
||||||
}
|
|
||||||
if (share->ipv6_ppools != NULL) {
|
|
||||||
dfree(share->ipv6_ppools, MDL);
|
|
||||||
}
|
|
||||||
share->ipv6_ppools = tmp;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Record this prefix pool in our array of prefix pools
|
|
||||||
* for this shared network.
|
|
||||||
*/
|
|
||||||
ipv6_ppool_reference(&share->ipv6_ppools[num_ppools], ppool, MDL);
|
|
||||||
share->ipv6_ppools[num_ppools+1] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* prefix6-declaration :== ip-address6 ip-address6 SLASH number SEMI */
|
/* prefix6-declaration :== ip-address6 ip-address6 SLASH number SEMI */
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -3973,7 +3907,7 @@ parse_prefix6(struct parse *cfile, struct group *group) {
|
|||||||
parse_warn(cfile, "impossible mask length");
|
parse_warn(cfile, "impossible mask length");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
add_ipv6_ppool_to_shared_network(share,
|
add_ipv6_pool_to_shared_network(share, D6O_IA_PD,
|
||||||
&p->cidrnet.lo_addr,
|
&p->cidrnet.lo_addr,
|
||||||
p->cidrnet.bits, bits);
|
p->cidrnet.bits, bits);
|
||||||
}
|
}
|
||||||
@@ -4141,9 +4075,9 @@ parse_ia_na_declaration(struct parse *cfile) {
|
|||||||
skip_to_semi(cfile);
|
skip_to_semi(cfile);
|
||||||
#else /* defined(DHCPv6) */
|
#else /* defined(DHCPv6) */
|
||||||
enum dhcp_token token;
|
enum dhcp_token token;
|
||||||
struct ia_na *ia;
|
struct ia_xx *ia;
|
||||||
const char *val;
|
const char *val;
|
||||||
struct ia_na *old_ia;
|
struct ia_xx *old_ia;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
u_int32_t iaid;
|
u_int32_t iaid;
|
||||||
struct iaddr iaddr;
|
struct iaddr iaddr;
|
||||||
@@ -4179,7 +4113,7 @@ parse_ia_na_declaration(struct parse *cfile) {
|
|||||||
|
|
||||||
memcpy(&iaid, val, 4);
|
memcpy(&iaid, val, 4);
|
||||||
ia = NULL;
|
ia = NULL;
|
||||||
if (ia_na_allocate(&ia, iaid, val+4, len-4, MDL) != ISC_R_SUCCESS) {
|
if (ia_allocate(&ia, iaid, val+4, len-4, MDL) != ISC_R_SUCCESS) {
|
||||||
log_fatal("Out of memory.");
|
log_fatal("Out of memory.");
|
||||||
}
|
}
|
||||||
ia->ia_type = D6O_IA_NA;
|
ia->ia_type = D6O_IA_NA;
|
||||||
@@ -4379,6 +4313,7 @@ parse_ia_na_declaration(struct parse *cfile) {
|
|||||||
log_fatal("Out of memory.");
|
log_fatal("Out of memory.");
|
||||||
}
|
}
|
||||||
memcpy(&iaaddr->addr, iaddr.iabuf, sizeof(iaaddr->addr));
|
memcpy(&iaaddr->addr, iaddr.iabuf, sizeof(iaaddr->addr));
|
||||||
|
iaaddr->plen = 0;
|
||||||
iaaddr->state = state;
|
iaaddr->state = state;
|
||||||
if (iaaddr->state == FTS_RELEASED)
|
if (iaaddr->state == FTS_RELEASED)
|
||||||
iaaddr->hard_lifetime_end_time = end_time;
|
iaaddr->hard_lifetime_end_time = end_time;
|
||||||
@@ -4389,10 +4324,11 @@ parse_ia_na_declaration(struct parse *cfile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add to our various structures */
|
/* add to our various structures */
|
||||||
ia_na_add_iaaddr(ia, iaaddr, MDL);
|
ia_add_iaaddr(ia, iaaddr, MDL);
|
||||||
ia_na_reference(&iaaddr->ia_na, ia, MDL);
|
ia_reference(&iaaddr->ia, ia, MDL);
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
if (find_ipv6_pool(&pool, 0, &iaaddr->addr) != ISC_R_SUCCESS) {
|
if (find_ipv6_pool(&pool, D6O_IA_NA,
|
||||||
|
&iaaddr->addr) != ISC_R_SUCCESS) {
|
||||||
inet_ntop(AF_INET6, &iaaddr->addr,
|
inet_ntop(AF_INET6, &iaaddr->addr,
|
||||||
addr_buf, sizeof(addr_buf));
|
addr_buf, sizeof(addr_buf));
|
||||||
parse_warn(cfile, "no pool found for address %s",
|
parse_warn(cfile, "no pool found for address %s",
|
||||||
@@ -4408,24 +4344,24 @@ parse_ia_na_declaration(struct parse *cfile) {
|
|||||||
* If we have an existing record for this IA_NA, remove it.
|
* If we have an existing record for this IA_NA, remove it.
|
||||||
*/
|
*/
|
||||||
old_ia = NULL;
|
old_ia = NULL;
|
||||||
if (ia_na_hash_lookup(&old_ia, ia_na_active,
|
if (ia_hash_lookup(&old_ia, ia_na_active,
|
||||||
(unsigned char *)ia->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia->iaid_duid.len, MDL)) {
|
ia->iaid_duid.len, MDL)) {
|
||||||
ia_na_hash_delete(ia_na_active,
|
ia_hash_delete(ia_na_active,
|
||||||
(unsigned char *)ia->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia->iaid_duid.len, MDL);
|
ia->iaid_duid.len, MDL);
|
||||||
ia_na_dereference(&old_ia, MDL);
|
ia_dereference(&old_ia, MDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have addresses, add this, otherwise don't bother.
|
* If we have addresses, add this, otherwise don't bother.
|
||||||
*/
|
*/
|
||||||
if (ia->num_iaaddr > 0) {
|
if (ia->num_iaaddr > 0) {
|
||||||
ia_na_hash_add(ia_na_active,
|
ia_hash_add(ia_na_active,
|
||||||
(unsigned char *)ia->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia->iaid_duid.len, ia, MDL);
|
ia->iaid_duid.len, ia, MDL);
|
||||||
}
|
}
|
||||||
ia_na_dereference(&ia, MDL);
|
ia_dereference(&ia, MDL);
|
||||||
#endif /* defined(DHCPv6) */
|
#endif /* defined(DHCPv6) */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4436,9 +4372,9 @@ parse_ia_ta_declaration(struct parse *cfile) {
|
|||||||
skip_to_semi(cfile);
|
skip_to_semi(cfile);
|
||||||
#else /* defined(DHCPv6) */
|
#else /* defined(DHCPv6) */
|
||||||
enum dhcp_token token;
|
enum dhcp_token token;
|
||||||
struct ia_na *ia;
|
struct ia_xx *ia;
|
||||||
const char *val;
|
const char *val;
|
||||||
struct ia_na *old_ia;
|
struct ia_xx *old_ia;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
u_int32_t iaid;
|
u_int32_t iaid;
|
||||||
struct iaddr iaddr;
|
struct iaddr iaddr;
|
||||||
@@ -4474,7 +4410,7 @@ parse_ia_ta_declaration(struct parse *cfile) {
|
|||||||
|
|
||||||
memcpy(&iaid, val, 4);
|
memcpy(&iaid, val, 4);
|
||||||
ia = NULL;
|
ia = NULL;
|
||||||
if (ia_na_allocate(&ia, iaid, val+4, len-4, MDL) != ISC_R_SUCCESS) {
|
if (ia_allocate(&ia, iaid, val+4, len-4, MDL) != ISC_R_SUCCESS) {
|
||||||
log_fatal("Out of memory.");
|
log_fatal("Out of memory.");
|
||||||
}
|
}
|
||||||
ia->ia_type = D6O_IA_TA;
|
ia->ia_type = D6O_IA_TA;
|
||||||
@@ -4674,6 +4610,7 @@ parse_ia_ta_declaration(struct parse *cfile) {
|
|||||||
log_fatal("Out of memory.");
|
log_fatal("Out of memory.");
|
||||||
}
|
}
|
||||||
memcpy(&iaaddr->addr, iaddr.iabuf, sizeof(iaaddr->addr));
|
memcpy(&iaaddr->addr, iaddr.iabuf, sizeof(iaaddr->addr));
|
||||||
|
iaaddr->plen = 0;
|
||||||
iaaddr->state = state;
|
iaaddr->state = state;
|
||||||
if (iaaddr->state == FTS_RELEASED)
|
if (iaaddr->state == FTS_RELEASED)
|
||||||
iaaddr->hard_lifetime_end_time = end_time;
|
iaaddr->hard_lifetime_end_time = end_time;
|
||||||
@@ -4684,10 +4621,11 @@ parse_ia_ta_declaration(struct parse *cfile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add to our various structures */
|
/* add to our various structures */
|
||||||
ia_na_add_iaaddr(ia, iaaddr, MDL);
|
ia_add_iaaddr(ia, iaaddr, MDL);
|
||||||
ia_na_reference(&iaaddr->ia_na, ia, MDL);
|
ia_reference(&iaaddr->ia, ia, MDL);
|
||||||
pool = NULL;
|
pool = NULL;
|
||||||
if (find_ipv6_pool(&pool, 1, &iaaddr->addr) != ISC_R_SUCCESS) {
|
if (find_ipv6_pool(&pool, D6O_IA_TA,
|
||||||
|
&iaaddr->addr) != ISC_R_SUCCESS) {
|
||||||
inet_ntop(AF_INET6, &iaaddr->addr,
|
inet_ntop(AF_INET6, &iaaddr->addr,
|
||||||
addr_buf, sizeof(addr_buf));
|
addr_buf, sizeof(addr_buf));
|
||||||
parse_warn(cfile, "no pool found for address %s",
|
parse_warn(cfile, "no pool found for address %s",
|
||||||
@@ -4703,24 +4641,24 @@ parse_ia_ta_declaration(struct parse *cfile) {
|
|||||||
* If we have an existing record for this IA_TA, remove it.
|
* If we have an existing record for this IA_TA, remove it.
|
||||||
*/
|
*/
|
||||||
old_ia = NULL;
|
old_ia = NULL;
|
||||||
if (ia_na_hash_lookup(&old_ia, ia_ta_active,
|
if (ia_hash_lookup(&old_ia, ia_ta_active,
|
||||||
(unsigned char *)ia->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia->iaid_duid.len, MDL)) {
|
ia->iaid_duid.len, MDL)) {
|
||||||
ia_na_hash_delete(ia_ta_active,
|
ia_hash_delete(ia_ta_active,
|
||||||
(unsigned char *)ia->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia->iaid_duid.len, MDL);
|
ia->iaid_duid.len, MDL);
|
||||||
ia_na_dereference(&old_ia, MDL);
|
ia_dereference(&old_ia, MDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have addresses, add this, otherwise don't bother.
|
* If we have addresses, add this, otherwise don't bother.
|
||||||
*/
|
*/
|
||||||
if (ia->num_iaaddr > 0) {
|
if (ia->num_iaaddr > 0) {
|
||||||
ia_na_hash_add(ia_ta_active,
|
ia_hash_add(ia_ta_active,
|
||||||
(unsigned char *)ia->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia->iaid_duid.len, ia, MDL);
|
ia->iaid_duid.len, ia, MDL);
|
||||||
}
|
}
|
||||||
ia_na_dereference(&ia, MDL);
|
ia_dereference(&ia, MDL);
|
||||||
#endif /* defined(DHCPv6) */
|
#endif /* defined(DHCPv6) */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4731,17 +4669,17 @@ parse_ia_pd_declaration(struct parse *cfile) {
|
|||||||
skip_to_semi(cfile);
|
skip_to_semi(cfile);
|
||||||
#else /* defined(DHCPv6) */
|
#else /* defined(DHCPv6) */
|
||||||
enum dhcp_token token;
|
enum dhcp_token token;
|
||||||
struct ia_pd *ia_pd;
|
struct ia_xx *ia;
|
||||||
const char *val;
|
const char *val;
|
||||||
struct ia_pd *old_ia_pd;
|
struct ia_xx *old_ia;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
u_int32_t iaid;
|
u_int32_t iaid;
|
||||||
struct iaddr iaddr;
|
struct iaddr iaddr;
|
||||||
u_int8_t plen;
|
u_int8_t plen;
|
||||||
binding_state_t state;
|
binding_state_t state;
|
||||||
TIME end_time;
|
TIME end_time;
|
||||||
struct iaprefix *iapref;
|
struct iaaddr *iapref;
|
||||||
struct ipv6_ppool *ppool;
|
struct ipv6_pool *pool;
|
||||||
char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||||
isc_boolean_t newbinding;
|
isc_boolean_t newbinding;
|
||||||
struct binding_scope *scope=NULL;
|
struct binding_scope *scope=NULL;
|
||||||
@@ -4769,10 +4707,11 @@ parse_ia_pd_declaration(struct parse *cfile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&iaid, val, 4);
|
memcpy(&iaid, val, 4);
|
||||||
ia_pd = NULL;
|
ia = NULL;
|
||||||
if (ia_pd_allocate(&ia_pd, iaid, val+4, len-4, MDL) != ISC_R_SUCCESS) {
|
if (ia_allocate(&ia, iaid, val+4, len-4, MDL) != ISC_R_SUCCESS) {
|
||||||
log_fatal("Out of memory.");
|
log_fatal("Out of memory.");
|
||||||
}
|
}
|
||||||
|
ia->ia_type = D6O_IA_PD;
|
||||||
|
|
||||||
token = next_token(&val, NULL, cfile);
|
token = next_token(&val, NULL, cfile);
|
||||||
if (token != LBRACE) {
|
if (token != LBRACE) {
|
||||||
@@ -4965,10 +4904,10 @@ parse_ia_pd_declaration(struct parse *cfile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
iapref = NULL;
|
iapref = NULL;
|
||||||
if (iaprefix_allocate(&iapref, MDL) != ISC_R_SUCCESS) {
|
if (iaaddr_allocate(&iapref, MDL) != ISC_R_SUCCESS) {
|
||||||
log_fatal("Out of memory.");
|
log_fatal("Out of memory.");
|
||||||
}
|
}
|
||||||
memcpy(&iapref->pref, iaddr.iabuf, sizeof(iapref->pref));
|
memcpy(&iapref->addr, iaddr.iabuf, sizeof(iapref->addr));
|
||||||
iapref->plen = plen;
|
iapref->plen = plen;
|
||||||
iapref->state = state;
|
iapref->state = state;
|
||||||
if (iapref->state == FTS_RELEASED)
|
if (iapref->state == FTS_RELEASED)
|
||||||
@@ -4980,43 +4919,44 @@ parse_ia_pd_declaration(struct parse *cfile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add to our various structures */
|
/* add to our various structures */
|
||||||
ia_pd_add_iaprefix(ia_pd, iapref, MDL);
|
ia_add_iaaddr(ia, iapref, MDL);
|
||||||
ia_pd_reference(&iapref->ia_pd, ia_pd, MDL);
|
ia_reference(&iapref->ia, ia, MDL);
|
||||||
ppool = NULL;
|
pool = NULL;
|
||||||
if (find_ipv6_ppool(&ppool, &iapref->pref) != ISC_R_SUCCESS) {
|
if (find_ipv6_pool(&pool, D6O_IA_PD,
|
||||||
inet_ntop(AF_INET6, &iapref->pref,
|
&iapref->addr) != ISC_R_SUCCESS) {
|
||||||
|
inet_ntop(AF_INET6, &iapref->addr,
|
||||||
addr_buf, sizeof(addr_buf));
|
addr_buf, sizeof(addr_buf));
|
||||||
parse_warn(cfile, "no ppool found for address %s",
|
parse_warn(cfile, "no pool found for address %s",
|
||||||
addr_buf);
|
addr_buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
add_prefix6(ppool, iapref, end_time);
|
add_lease6(pool, iapref, end_time);
|
||||||
ipv6_ppool_dereference(&ppool, MDL);
|
ipv6_pool_dereference(&pool, MDL);
|
||||||
iaprefix_dereference(&iapref, MDL);
|
iaaddr_dereference(&iapref, MDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have an existing record for this IA_PD, remove it.
|
* If we have an existing record for this IA_PD, remove it.
|
||||||
*/
|
*/
|
||||||
old_ia_pd = NULL;
|
old_ia = NULL;
|
||||||
if (ia_pd_hash_lookup(&old_ia_pd, ia_pd_active,
|
if (ia_hash_lookup(&old_ia, ia_pd_active,
|
||||||
(unsigned char *)ia_pd->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia_pd->iaid_duid.len, MDL)) {
|
ia->iaid_duid.len, MDL)) {
|
||||||
ia_pd_hash_delete(ia_pd_active,
|
ia_hash_delete(ia_pd_active,
|
||||||
(unsigned char *)ia_pd->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia_pd->iaid_duid.len, MDL);
|
ia->iaid_duid.len, MDL);
|
||||||
ia_pd_dereference(&old_ia_pd, MDL);
|
ia_dereference(&old_ia, MDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have prefixes, add this, otherwise don't bother.
|
* If we have prefixes, add this, otherwise don't bother.
|
||||||
*/
|
*/
|
||||||
if (ia_pd->num_iaprefix > 0) {
|
if (ia->num_iaaddr > 0) {
|
||||||
ia_pd_hash_add(ia_pd_active,
|
ia_hash_add(ia_pd_active,
|
||||||
(unsigned char *)ia_pd->iaid_duid.data,
|
(unsigned char *)ia->iaid_duid.data,
|
||||||
ia_pd->iaid_duid.len, ia_pd, MDL);
|
ia->iaid_duid.len, ia, MDL);
|
||||||
}
|
}
|
||||||
ia_pd_dereference(&ia_pd, MDL);
|
ia_dereference(&ia, MDL);
|
||||||
#endif /* defined(DHCPv6) */
|
#endif /* defined(DHCPv6) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
138
server/db.c
138
server/db.c
@@ -500,7 +500,7 @@ int write_group (group)
|
|||||||
* Write an IA and the options it has.
|
* Write an IA and the options it has.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
write_ia(const struct ia_na *ia) {
|
write_ia(const struct ia_xx *ia) {
|
||||||
struct iaaddr *iaaddr;
|
struct iaaddr *iaaddr;
|
||||||
struct binding *bnd;
|
struct binding *bnd;
|
||||||
int i;
|
int i;
|
||||||
@@ -529,14 +529,20 @@ write_ia(const struct ia_na *ia) {
|
|||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
if (ia->ia_type == D6O_IA_NA) {
|
switch (ia->ia_type) {
|
||||||
|
case D6O_IA_NA:
|
||||||
fprintf_ret = fprintf(db_file, "ia-na \"%s\" {\n", s);
|
fprintf_ret = fprintf(db_file, "ia-na \"%s\" {\n", s);
|
||||||
} else if (ia->ia_type == D6O_IA_TA) {
|
break;
|
||||||
|
case D6O_IA_TA:
|
||||||
fprintf_ret = fprintf(db_file, "ia-ta \"%s\" {\n", s);
|
fprintf_ret = fprintf(db_file, "ia-ta \"%s\" {\n", s);
|
||||||
} else {
|
break;
|
||||||
log_error("Unknown ia type %u at %s:%d",
|
case D6O_IA_PD:
|
||||||
(unsigned)ia->ia_type, MDL);
|
fprintf_ret = fprintf(db_file, "ia-pd \"%s\" {\n", s);
|
||||||
goto error_exit;
|
break;
|
||||||
|
default:
|
||||||
|
log_error("Unknown ia type %u for \"%s\" at %s:%d",
|
||||||
|
(unsigned)ia->ia_type, s, MDL);
|
||||||
|
fprintf_ret = -1;
|
||||||
}
|
}
|
||||||
dfree(s, MDL);
|
dfree(s, MDL);
|
||||||
if (fprintf_ret < 0) {
|
if (fprintf_ret < 0) {
|
||||||
@@ -546,7 +552,13 @@ write_ia(const struct ia_na *ia) {
|
|||||||
iaaddr = ia->iaaddr[i];
|
iaaddr = ia->iaaddr[i];
|
||||||
|
|
||||||
inet_ntop(AF_INET6, &iaaddr->addr, addr_buf, sizeof(addr_buf));
|
inet_ntop(AF_INET6, &iaaddr->addr, addr_buf, sizeof(addr_buf));
|
||||||
if (fprintf(db_file, " iaaddr %s {\n", addr_buf) < 0) {
|
if ((ia->ia_type != D6O_IA_PD) &&
|
||||||
|
(fprintf(db_file, " iaaddr %s {\n", addr_buf) < 0)) {
|
||||||
|
goto error_exit;
|
||||||
|
}
|
||||||
|
if ((ia->ia_type == D6O_IA_PD) &&
|
||||||
|
(fprintf(db_file, " iaprefix %s/%d {\n",
|
||||||
|
addr_buf, (int)iaaddr->plen) < 0)) {
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
if ((iaaddr->state <= 0) || (iaaddr->state > FTS_LAST)) {
|
if ((iaaddr->state <= 0) || (iaaddr->state > FTS_LAST)) {
|
||||||
@@ -607,115 +619,7 @@ write_ia(const struct ia_na *ia) {
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
log_info("write_ia: unable to write ia-na");
|
log_info("write_ia: unable to write ia");
|
||||||
lease_file_is_corrupt = 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Write an IA_PD and the options it has.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
write_ia_pd(const struct ia_pd *ia_pd) {
|
|
||||||
struct iaprefix *iapref;
|
|
||||||
struct binding *bnd;
|
|
||||||
int i;
|
|
||||||
char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff.255.255.255.255")];
|
|
||||||
const char *binding_state;
|
|
||||||
const char *tval;
|
|
||||||
char *s;
|
|
||||||
int fprintf_ret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the lease file is corrupt, don't try to write any more
|
|
||||||
* leases until we've written a good lease file.
|
|
||||||
*/
|
|
||||||
if (lease_file_is_corrupt) {
|
|
||||||
if (!new_lease_file()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (counting) {
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
s = quotify_buf(ia_pd->iaid_duid.data, ia_pd->iaid_duid.len, MDL);
|
|
||||||
if (s == NULL) {
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
fprintf_ret = fprintf(db_file, "ia-pd \"%s\" {\n", s);
|
|
||||||
dfree(s, MDL);
|
|
||||||
if (fprintf_ret < 0) {
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
for (i=0; i<ia_pd->num_iaprefix; i++) {
|
|
||||||
iapref = ia_pd->iaprefix[i];
|
|
||||||
|
|
||||||
inet_ntop(AF_INET6, &iapref->pref, addr_buf, sizeof(addr_buf));
|
|
||||||
if (fprintf(db_file, " iaprefix %s/%d {\n",
|
|
||||||
addr_buf, (int)iapref->plen) < 0) {
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
if ((iapref->state <= 0) || (iapref->state > FTS_LAST)) {
|
|
||||||
log_fatal("Unknown iaprefix state %d at %s:%d",
|
|
||||||
iapref->state, MDL);
|
|
||||||
}
|
|
||||||
binding_state = binding_state_names[iapref->state-1];
|
|
||||||
if (fprintf(db_file, " binding state %s;\n",
|
|
||||||
binding_state) < 0) {
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note that from here on out, the \n is prepended to the
|
|
||||||
* next write, rather than appended to the current write.
|
|
||||||
*/
|
|
||||||
if ((iapref->state == FTS_ACTIVE) ||
|
|
||||||
(iapref->state == FTS_ABANDONED)) {
|
|
||||||
tval = print_time(iapref->hard_lifetime_end_time);
|
|
||||||
} else {
|
|
||||||
tval = print_time(iapref->soft_lifetime_end_time);
|
|
||||||
}
|
|
||||||
if (tval == NULL) {
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
if (fprintf(db_file, " ends %s", tval) < 0) {
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write out any binding scopes: note that 'ends' above does
|
|
||||||
* not have \n on the end! We want that.
|
|
||||||
*/
|
|
||||||
if (iapref->scope != NULL)
|
|
||||||
bnd = iapref->scope->bindings;
|
|
||||||
else
|
|
||||||
bnd = NULL;
|
|
||||||
|
|
||||||
for (; bnd != NULL ; bnd = bnd->next) {
|
|
||||||
if (bnd->value == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* We don't do a regular error_exit because the
|
|
||||||
* lease db is not corrupt in this case.
|
|
||||||
*/
|
|
||||||
if (write_binding_scope(db_file, bnd,
|
|
||||||
"\n ") != ISC_R_SUCCESS)
|
|
||||||
goto error_exit;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fprintf(db_file, "\n }\n") < 0)
|
|
||||||
goto error_exit;
|
|
||||||
}
|
|
||||||
if (fprintf(db_file, "}\n\n") < 0)
|
|
||||||
goto error_exit;
|
|
||||||
|
|
||||||
fflush(db_file);
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
error_exit:
|
|
||||||
log_info("write_ia_pd: unable to write ia-pd");
|
|
||||||
lease_file_is_corrupt = 1;
|
lease_file_is_corrupt = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -565,8 +565,8 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old,
|
|||||||
memset (&ddns_dhcid, 0, sizeof ddns_dhcid);
|
memset (&ddns_dhcid, 0, sizeof ddns_dhcid);
|
||||||
if (lease6 != NULL)
|
if (lease6 != NULL)
|
||||||
result = get_dhcid(&ddns_dhcid, 2,
|
result = get_dhcid(&ddns_dhcid, 2,
|
||||||
lease6->ia_na->iaid_duid.data,
|
lease6->ia->iaid_duid.data,
|
||||||
lease6->ia_na->iaid_duid.len);
|
lease6->ia->iaid_duid.len);
|
||||||
else if ((lease != NULL) && (lease->uid != NULL) &&
|
else if ((lease != NULL) && (lease->uid != NULL) &&
|
||||||
(lease->uid_len != 0))
|
(lease->uid_len != 0))
|
||||||
result = get_dhcid (&ddns_dhcid,
|
result = get_dhcid (&ddns_dhcid,
|
||||||
|
@@ -655,13 +655,13 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
#ifdef DHCPv6
|
#ifdef DHCPv6
|
||||||
/* set up DHCPv6 hashes */
|
/* set up DHCPv6 hashes */
|
||||||
if (!ia_na_new_hash(&ia_na_active, DEFAULT_HASH_SIZE, MDL)) {
|
if (!ia_new_hash(&ia_na_active, DEFAULT_HASH_SIZE, MDL)) {
|
||||||
log_fatal("Out of memory creating hash for active IA_NA.");
|
log_fatal("Out of memory creating hash for active IA_NA.");
|
||||||
}
|
}
|
||||||
if (!ia_na_new_hash(&ia_ta_active, DEFAULT_HASH_SIZE, MDL)) {
|
if (!ia_new_hash(&ia_ta_active, DEFAULT_HASH_SIZE, MDL)) {
|
||||||
log_fatal("Out of memory creating hash for active IA_TA.");
|
log_fatal("Out of memory creating hash for active IA_TA.");
|
||||||
}
|
}
|
||||||
if (!ia_pd_new_hash(&ia_pd_active, DEFAULT_HASH_SIZE, MDL)) {
|
if (!ia_new_hash(&ia_pd_active, DEFAULT_HASH_SIZE, MDL)) {
|
||||||
log_fatal("Out of memory creating hash for active IA_PD.");
|
log_fatal("Out of memory creating hash for active IA_PD.");
|
||||||
}
|
}
|
||||||
#endif /* DHCPv6 */
|
#endif /* DHCPv6 */
|
||||||
|
439
server/dhcpv6.c
439
server/dhcpv6.c
File diff suppressed because it is too large
Load Diff
1426
server/mdb6.c
1426
server/mdb6.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user