From: Francis Dupont Date: Mon, 31 Mar 2008 13:49:45 +0000 (+0000) Subject: rename iaaddr structure & co X-Git-Tag: v4_1_0a2~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d17db44a7747d6e1a3d7b774ba3766878753ab8;p=thirdparty%2Fdhcp.git rename iaaddr structure & co --- diff --git a/includes/dhcpd.h b/includes/dhcpd.h index fd86ab256..85046d047 100644 --- a/includes/dhcpd.h +++ b/includes/dhcpd.h @@ -1334,12 +1334,11 @@ typedef unsigned char option_mask [16]; /* these are referenced */ typedef struct hash_table ia_hash_t; -typedef struct hash_table iaaddr_hash_t; +typedef struct hash_table iasubopt_hash_t; - /* should be lease6 */ - /* shared with iaprefix */ + /* IAADDR/IAPREFIX lease */ -struct iaaddr { +struct iasubopt { int refcnt; /* reference count */ struct in6_addr addr; /* IPv6 address/prefix */ u_int8_t plen; /* iaprefix prefix length */ @@ -1365,10 +1364,10 @@ struct ia_xx { int refcnt; /* reference count */ struct data_string iaid_duid; /* from the client */ u_int16_t ia_type; /* IA_XX */ - int num_iaaddr; /* number of IAADDR for this IA */ - int max_iaaddr; /* space available for IAADDR */ + int num_iasubopt; /* number of IAADDR/PREFIX */ + int max_iasubopt; /* space available for IAADDR/PREFIX */ time_t cltt; /* client last transaction time */ - struct iaaddr **iaaddr; /* pointers to the various IAADDRs */ + struct iasubopt **iasubopt; /* pointers to the IAADDR/IAPREFIXs */ }; extern ia_hash_t *ia_na_active; @@ -1381,10 +1380,10 @@ struct ipv6_pool { struct in6_addr start_addr; /* first IPv6 address */ int bits; /* number of bits, CIDR style */ int units; /* allocation unit in bits */ - iaaddr_hash_t *addrs; /* non-free IAADDR */ - int num_active; /* count of active IAADDR */ + iasubopt_hash_t *leases; /* non-free leases */ + int num_active; /* count of active leases */ isc_heap_t *active_timeouts; /* timeouts for active leases */ - int num_inactive; /* count of inactive IAADDR */ + int num_inactive; /* count of inactive leases */ isc_heap_t *inactive_timeouts; /* timeouts for expired or released leases */ struct shared_network *shared_network; /* shared_network for @@ -1725,8 +1724,8 @@ void parse_server_duid_conf(struct parse *cfile); /* ddns.c */ int ddns_updates(struct packet *, struct lease *, struct lease *, - struct iaaddr *, struct iaaddr *, struct option_state *); -int ddns_removals(struct lease *, struct iaaddr *); + struct iasubopt *, struct iasubopt *, struct option_state *); +int ddns_removals(struct lease *, struct iasubopt *); /* parse.c */ void add_enumeration (struct enumeration *); @@ -3198,7 +3197,7 @@ isc_result_t dhcp_failover_process_update_request_all (dhcp_failover_state_t *, failover_message_t *); isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *, failover_message_t *); -void ia_remove_all_iaaddr(struct ia_xx *ia, const char *file, int line); +void ia_remove_all_lease(struct ia_xx *ia, const char *file, int line); void dhcp_failover_recover_done (void *); void failover_print PROTO ((char *, unsigned *, unsigned, const char *)); void update_partner PROTO ((struct lease *)); @@ -3227,14 +3226,16 @@ const char *binding_state_print (enum failover_state); /* mdb6.c */ HASH_FUNCTIONS_DECL(ia, unsigned char *, struct ia_xx, ia_hash_t); -HASH_FUNCTIONS_DECL(iaaddr, struct in6_addr *, struct iaaddr, iaaddr_hash_t); +HASH_FUNCTIONS_DECL(iasubopt, struct in6_addr *, struct iasubopt, + iasubopt_hash_t); -isc_result_t iaaddr_allocate(struct iaaddr **iaaddr, - const char *file, int line); -isc_result_t iaaddr_reference(struct iaaddr **iaaddr, struct iaaddr *src, - const char *file, int line); -isc_result_t iaaddr_dereference(struct iaaddr **iaaddr, +isc_result_t iasubopt_allocate(struct iasubopt **iasubopt, + const char *file, int line); +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, @@ -3246,10 +3247,10 @@ 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_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, - const char *file, int line); -void ia_remove_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, - 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); 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, @@ -3262,25 +3263,25 @@ isc_result_t ipv6_pool_reference(struct ipv6_pool **pool, isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool, const char *file, int line); isc_result_t create_lease6(struct ipv6_pool *pool, - struct iaaddr **addr, + struct iasubopt **addr, unsigned int *attempts, const struct data_string *uid, time_t soft_lifetime_end_time); isc_result_t add_lease6(struct ipv6_pool *pool, - struct iaaddr *addr, + struct iasubopt *lease, time_t valid_lifetime_end_time); -isc_result_t renew_lease6(struct ipv6_pool *pool, struct iaaddr *addr); -isc_result_t expire_lease6(struct iaaddr **addr, +isc_result_t renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease); +isc_result_t expire_lease6(struct iasubopt **leasep, struct ipv6_pool *pool, time_t now); -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 release_lease6(struct ipv6_pool *pool, struct iasubopt *lease); +isc_result_t decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease); isc_boolean_t lease6_exists(const struct ipv6_pool *pool, const struct in6_addr *addr); isc_result_t mark_lease_unavailble(struct ipv6_pool *pool, const struct in6_addr *addr); isc_result_t create_prefix6(struct ipv6_pool *pool, - struct iaaddr **pref, + struct iasubopt **pref, unsigned int *attempts, const struct data_string *uid, time_t soft_lifetime_end_time); diff --git a/server/confpars.c b/server/confpars.c index 96e4c4b0e..747779a9f 100644 --- a/server/confpars.c +++ b/server/confpars.c @@ -4085,7 +4085,7 @@ parse_ia_na_declaration(struct parse *cfile) { u_int32_t prefer; u_int32_t valid; TIME end_time; - struct iaaddr *iaaddr; + struct iasubopt *iaaddr; struct ipv6_pool *pool; char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; isc_boolean_t newbinding; @@ -4343,7 +4343,7 @@ parse_ia_na_declaration(struct parse *cfile) { } iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { log_fatal("Out of memory."); } memcpy(&iaaddr->addr, iaddr.iabuf, sizeof(iaaddr->addr)); @@ -4360,7 +4360,7 @@ parse_ia_na_declaration(struct parse *cfile) { } /* add to our various structures */ - ia_add_iaaddr(ia, iaaddr, MDL); + ia_add_iasubopt(ia, iaaddr, MDL); ia_reference(&iaaddr->ia, ia, MDL); pool = NULL; if (find_ipv6_pool(&pool, D6O_IA_NA, @@ -4373,7 +4373,7 @@ parse_ia_na_declaration(struct parse *cfile) { } add_lease6(pool, iaaddr, end_time); ipv6_pool_dereference(&pool, MDL); - iaaddr_dereference(&iaaddr, MDL); + iasubopt_dereference(&iaaddr, MDL); } /* @@ -4392,7 +4392,7 @@ parse_ia_na_declaration(struct parse *cfile) { /* * If we have addresses, add this, otherwise don't bother. */ - if (ia->num_iaaddr > 0) { + if (ia->num_iasubopt > 0) { ia_hash_add(ia_na_active, (unsigned char *)ia->iaid_duid.data, ia->iaid_duid.len, ia, MDL); @@ -4418,7 +4418,7 @@ parse_ia_ta_declaration(struct parse *cfile) { u_int32_t prefer; u_int32_t valid; TIME end_time; - struct iaaddr *iaaddr; + struct iasubopt *iaaddr; struct ipv6_pool *pool; char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; isc_boolean_t newbinding; @@ -4676,7 +4676,7 @@ parse_ia_ta_declaration(struct parse *cfile) { } iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { log_fatal("Out of memory."); } memcpy(&iaaddr->addr, iaddr.iabuf, sizeof(iaaddr->addr)); @@ -4693,7 +4693,7 @@ parse_ia_ta_declaration(struct parse *cfile) { } /* add to our various structures */ - ia_add_iaaddr(ia, iaaddr, MDL); + ia_add_iasubopt(ia, iaaddr, MDL); ia_reference(&iaaddr->ia, ia, MDL); pool = NULL; if (find_ipv6_pool(&pool, D6O_IA_TA, @@ -4706,7 +4706,7 @@ parse_ia_ta_declaration(struct parse *cfile) { } add_lease6(pool, iaaddr, end_time); ipv6_pool_dereference(&pool, MDL); - iaaddr_dereference(&iaaddr, MDL); + iasubopt_dereference(&iaaddr, MDL); } /* @@ -4725,7 +4725,7 @@ parse_ia_ta_declaration(struct parse *cfile) { /* * If we have addresses, add this, otherwise don't bother. */ - if (ia->num_iaaddr > 0) { + if (ia->num_iasubopt > 0) { ia_hash_add(ia_ta_active, (unsigned char *)ia->iaid_duid.data, ia->iaid_duid.len, ia, MDL); @@ -4752,7 +4752,7 @@ parse_ia_pd_declaration(struct parse *cfile) { u_int32_t prefer; u_int32_t valid; TIME end_time; - struct iaaddr *iapref; + struct iasubopt *iapref; struct ipv6_pool *pool; char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; isc_boolean_t newbinding; @@ -5010,7 +5010,7 @@ parse_ia_pd_declaration(struct parse *cfile) { } iapref = NULL; - if (iaaddr_allocate(&iapref, MDL) != ISC_R_SUCCESS) { + if (iasubopt_allocate(&iapref, MDL) != ISC_R_SUCCESS) { log_fatal("Out of memory."); } memcpy(&iapref->addr, iaddr.iabuf, sizeof(iapref->addr)); @@ -5027,7 +5027,7 @@ parse_ia_pd_declaration(struct parse *cfile) { } /* add to our various structures */ - ia_add_iaaddr(ia, iapref, MDL); + ia_add_iasubopt(ia, iapref, MDL); ia_reference(&iapref->ia, ia, MDL); pool = NULL; if (find_ipv6_pool(&pool, D6O_IA_PD, @@ -5040,7 +5040,7 @@ parse_ia_pd_declaration(struct parse *cfile) { } add_lease6(pool, iapref, end_time); ipv6_pool_dereference(&pool, MDL); - iaaddr_dereference(&iapref, MDL); + iasubopt_dereference(&iapref, MDL); } /* @@ -5059,7 +5059,7 @@ parse_ia_pd_declaration(struct parse *cfile) { /* * If we have prefixes, add this, otherwise don't bother. */ - if (ia->num_iaaddr > 0) { + if (ia->num_iasubopt > 0) { ia_hash_add(ia_pd_active, (unsigned char *)ia->iaid_duid.data, ia->iaid_duid.len, ia, MDL); diff --git a/server/db.c b/server/db.c index 42120d318..7669480d3 100644 --- a/server/db.c +++ b/server/db.c @@ -501,7 +501,7 @@ int write_group (group) */ int write_ia(const struct ia_xx *ia) { - struct iaaddr *iaaddr; + struct iasubopt *iasubopt; struct binding *bnd; int i; char addr_buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff.255.255.255.255")]; @@ -557,46 +557,47 @@ write_ia(const struct ia_xx *ia) { goto error_exit; } } - for (i=0; inum_iaaddr; i++) { - iaaddr = ia->iaaddr[i]; + for (i=0; inum_iasubopt; i++) { + iasubopt = ia->iasubopt[i]; - inet_ntop(AF_INET6, &iaaddr->addr, addr_buf, sizeof(addr_buf)); + inet_ntop(AF_INET6, &iasubopt->addr, + addr_buf, sizeof(addr_buf)); 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)) { + addr_buf, (int)iasubopt->plen) < 0)) { goto error_exit; } - if ((iaaddr->state <= 0) || (iaaddr->state > FTS_LAST)) { - log_fatal("Unknown iaaddr state %d at %s:%d", - iaaddr->state, MDL); + if ((iasubopt->state <= 0) || (iasubopt->state > FTS_LAST)) { + log_fatal("Unknown iasubopt state %d at %s:%d", + iasubopt->state, MDL); } - binding_state = binding_state_names[iaaddr->state-1]; + binding_state = binding_state_names[iasubopt->state-1]; if (fprintf(db_file, " binding state %s;\n", binding_state) < 0) { goto error_exit; } if (fprintf(db_file, " preferred-life %u\n", - (unsigned)iaaddr->prefer) < 0) { + (unsigned)iasubopt->prefer) < 0) { goto error_exit; } if (fprintf(db_file, " max-life %u\n", - (unsigned)iaaddr->valid) < 0) { + (unsigned)iasubopt->valid) < 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 ((iaaddr->state == FTS_ACTIVE) || - (iaaddr->state == FTS_ABANDONED) || - (iaaddr->hard_lifetime_end_time != 0)) { - tval = print_time(iaaddr->hard_lifetime_end_time); + if ((iasubopt->state == FTS_ACTIVE) || + (iasubopt->state == FTS_ABANDONED) || + (iasubopt->hard_lifetime_end_time != 0)) { + tval = print_time(iasubopt->hard_lifetime_end_time); } else { - tval = print_time(iaaddr->soft_lifetime_end_time); + tval = print_time(iasubopt->soft_lifetime_end_time); } if (tval == NULL) { goto error_exit; @@ -608,8 +609,8 @@ write_ia(const struct ia_xx *ia) { /* Write out any binding scopes: note that 'ends' above does * not have \n on the end! We want that. */ - if (iaaddr->scope != NULL) - bnd = iaaddr->scope->bindings; + if (iasubopt->scope != NULL) + bnd = iasubopt->scope->bindings; else bnd = NULL; diff --git a/server/ddns.c b/server/ddns.c index b87924bd2..6a23f298a 100644 --- a/server/ddns.c +++ b/server/ddns.c @@ -213,7 +213,7 @@ static isc_result_t ddns_remove_ptr (struct data_string *ddns_rev_name) */ int ddns_updates(struct packet *packet, struct lease *lease, struct lease *old, - struct iaaddr *lease6, struct iaaddr *old6, + struct iasubopt *lease6, struct iasubopt *old6, struct option_state *options) { unsigned long ddns_ttl = DEFAULT_DDNS_TTL; @@ -801,7 +801,7 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old, /* Remove relevant entries from DNS. */ int -ddns_removals(struct lease *lease, struct iaaddr *lease6) +ddns_removals(struct lease *lease, struct iasubopt *lease6) { struct data_string ddns_fwd_name; struct data_string ddns_rev_name; diff --git a/server/dhcpleasequery.c b/server/dhcpleasequery.c index 7a353cd0e..8a142f7b1 100644 --- a/server/dhcpleasequery.c +++ b/server/dhcpleasequery.c @@ -862,7 +862,7 @@ process_lq_by_address(struct lq6_state *lq) { struct ipv6_pool *pool = NULL; struct data_string data; struct in6_addr addr; - struct iaaddr *iaaddr = NULL; + struct iasubopt *iaaddr = NULL; struct option_state *opt_state = NULL; u_int32_t lifetime; unsigned opt_cursor; @@ -909,8 +909,8 @@ process_lq_by_address(struct lq6_state *lq) { ret_val = 1; goto exit; } - if (iaaddr_hash_lookup(&iaaddr, pool->addrs, &addr, - sizeof(addr), MDL) == 0) { + if (iasubopt_hash_lookup(&iaaddr, pool->leases, &addr, + sizeof(addr), MDL) == 0) { ret_val = 1; goto exit; } @@ -993,7 +993,7 @@ process_lq_by_address(struct lq6_state *lq) { if (pool != NULL) ipv6_pool_dereference(&pool, MDL); if (iaaddr != NULL) - iaaddr_dereference(&iaaddr, MDL); + iasubopt_dereference(&iaaddr, MDL); if (opt_state != NULL) option_state_dereference(&opt_state, MDL); return ret_val; diff --git a/server/dhcpv6.c b/server/dhcpv6.c index 1b5aa4fd6..a2e6ac75b 100644 --- a/server/dhcpv6.c +++ b/server/dhcpv6.c @@ -60,7 +60,7 @@ struct reply_state { struct data_string fixed; /* IAADDR/PREFIX level persistent state */ - struct iaaddr *lease; + struct iasubopt *lease; /* * "t1", "t2", preferred, and valid lifetimes records for calculating @@ -118,7 +118,8 @@ static isc_result_t reply_process_is_addressed(struct reply_state *reply, struct group *group); static isc_result_t reply_process_send_addr(struct reply_state *reply, struct iaddr *addr); -static struct iaaddr *lease_compare(struct iaaddr *alpha, struct iaaddr *beta); +static struct iasubopt *lease_compare(struct iasubopt *alpha, + struct iasubopt *beta); static isc_result_t reply_process_ia_pd(struct reply_state *reply, struct option_cache *ia_pd); static isc_result_t reply_process_prefix(struct reply_state *reply, @@ -133,9 +134,9 @@ static isc_result_t reply_process_is_prefixed(struct reply_state *reply, struct group *group); static isc_result_t reply_process_send_prefix(struct reply_state *reply, struct iaddrcidrnet *pref); -static struct iaaddr *prefix_compare(struct reply_state *reply, - struct iaaddr *alpha, - struct iaaddr *beta); +static struct iasubopt *prefix_compare(struct reply_state *reply, + struct iasubopt *alpha, + struct iasubopt *beta); /* * This function returns the time since DUID time start for the @@ -937,7 +938,7 @@ start_reply(struct packet *packet, * requested_addr is the address the client wants */ static isc_result_t -try_client_v6_address(struct iaaddr **addr, +try_client_v6_address(struct iasubopt **addr, struct ipv6_pool *pool, const struct data_string *requested_addr) { @@ -960,7 +961,7 @@ try_client_v6_address(struct iaaddr **addr, return ISC_R_ADDRINUSE; } - result = iaaddr_allocate(addr, MDL); + result = iasubopt_allocate(addr, MDL); if (result != ISC_R_SUCCESS) { return result; } @@ -970,7 +971,7 @@ try_client_v6_address(struct iaaddr **addr, /* Default is soft binding for 2 minutes. */ result = add_lease6(pool, *addr, cur_time + 120); if (result != ISC_R_SUCCESS) { - iaaddr_dereference(addr, MDL); + iasubopt_dereference(addr, MDL); } return result; } @@ -984,7 +985,7 @@ try_client_v6_address(struct iaaddr **addr, * client_id is the DUID for the client */ static isc_result_t -pick_v6_address(struct iaaddr **addr, struct shared_network *shared_network, +pick_v6_address(struct iasubopt **addr, struct shared_network *shared_network, const struct data_string *client_id) { struct ipv6_pool *p; @@ -1070,7 +1071,7 @@ pick_v6_address(struct iaaddr **addr, struct shared_network *shared_network, * requested_pref is the address the client wants */ static isc_result_t -try_client_v6_prefix(struct iaaddr **pref, +try_client_v6_prefix(struct iasubopt **pref, struct ipv6_pool *pool, const struct data_string *requested_pref) { @@ -1105,7 +1106,7 @@ try_client_v6_prefix(struct iaaddr **pref, return ISC_R_ADDRINUSE; } - result = iaaddr_allocate(pref, MDL); + result = iasubopt_allocate(pref, MDL); if (result != ISC_R_SUCCESS) { return result; } @@ -1115,7 +1116,7 @@ try_client_v6_prefix(struct iaaddr **pref, /* Default is soft binding for 2 minutes. */ result = add_lease6(pool, *pref, cur_time + 120); if (result != ISC_R_SUCCESS) { - iaaddr_dereference(pref, MDL); + iasubopt_dereference(pref, MDL); } return result; } @@ -1130,7 +1131,7 @@ try_client_v6_prefix(struct iaaddr **pref, * client_id is the DUID for the client */ static isc_result_t -pick_v6_prefix(struct iaaddr **pref, int plen, +pick_v6_prefix(struct iasubopt **pref, int plen, struct shared_network *shared_network, const struct data_string *client_id) { @@ -1778,13 +1779,13 @@ reply_process_ia_na(struct reply_state *reply, struct option_cache *ia) { */ if ((status != ISC_R_CANCELED) && !reply->static_lease && (reply->buf.reply.msg_type == DHCPV6_REPLY) && - (reply->ia->num_iaaddr != 0)) { - struct iaaddr *tmp; + (reply->ia->num_iasubopt != 0)) { + struct iasubopt *tmp; struct data_string *ia_id; int i; - for (i = 0 ; i < reply->ia->num_iaaddr ; i++) { - tmp = reply->ia->iaaddr[i]; + for (i = 0 ; i < reply->ia->num_iasubopt ; i++) { + tmp = reply->ia->iasubopt[i]; if (tmp->ia != NULL) ia_dereference(&tmp->ia, MDL); @@ -1846,7 +1847,7 @@ reply_process_ia_na(struct reply_state *reply, struct option_cache *ia) { if (reply->old_ia != NULL) ia_dereference(&reply->old_ia, MDL); if (reply->lease != NULL) - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); if (reply->fixed.data != NULL) data_string_forget(&reply->fixed, MDL); @@ -2143,7 +2144,7 @@ reply_process_addr(struct reply_state *reply, struct option_cache *addr) { if (data.data != NULL) data_string_forget(&data, MDL); if (reply->lease != NULL) - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); return status; } @@ -2171,16 +2172,16 @@ address_is_owned(struct reply_state *reply, struct iaddr *addr) { return ISC_FALSE; } - if ((reply->old_ia == NULL) || (reply->old_ia->num_iaaddr == 0)) + if ((reply->old_ia == NULL) || (reply->old_ia->num_iasubopt == 0)) return ISC_FALSE; - for (i = 0 ; i < reply->old_ia->num_iaaddr ; i++) { - struct iaaddr *tmp; + for (i = 0 ; i < reply->old_ia->num_iasubopt ; i++) { + struct iasubopt *tmp; - tmp = reply->old_ia->iaaddr[i]; + tmp = reply->old_ia->iasubopt[i]; if (memcmp(addr->iabuf, &tmp->addr, 16) == 0) { - iaaddr_reference(&reply->lease, tmp, MDL); + iasubopt_reference(&reply->lease, tmp, MDL); return ISC_TRUE; } } @@ -2393,13 +2394,13 @@ reply_process_ia_ta(struct reply_state *reply, struct option_cache *ia) { */ if ((status != ISC_R_CANCELED) && (reply->buf.reply.msg_type == DHCPV6_REPLY) && - (reply->ia->num_iaaddr != 0)) { - struct iaaddr *tmp; + (reply->ia->num_iasubopt != 0)) { + struct iasubopt *tmp; struct data_string *ia_id; int i; - for (i = 0 ; i < reply->ia->num_iaaddr ; i++) { - tmp = reply->ia->iaaddr[i]; + for (i = 0 ; i < reply->ia->num_iasubopt ; i++) { + tmp = reply->ia->iasubopt[i]; if (tmp->ia != NULL) ia_dereference(&tmp->ia, MDL); @@ -2463,7 +2464,7 @@ reply_process_ia_ta(struct reply_state *reply, struct option_cache *ia) { if (reply->old_ia != NULL) ia_dereference(&reply->old_ia, MDL); if (reply->lease != NULL) - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); /* * ISC_R_CANCELED is a status code used by the addr processing to @@ -2528,13 +2529,13 @@ find_client_temporaries(struct reply_state *reply) { goto cleanup; } if (reply->lease != NULL) { - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); } } cleanup: if (reply->lease != NULL) { - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); } return status; } @@ -2582,7 +2583,7 @@ static isc_result_t find_client_address(struct reply_state *reply) { struct iaddr send_addr; isc_result_t status = ISC_R_NORESOURCES; - struct iaaddr *lease, *best_lease = NULL; + struct iasubopt *lease, *best_lease = NULL; struct binding_scope **scope; struct group *group; int i; @@ -2605,8 +2606,8 @@ find_client_address(struct reply_state *reply) { } if (reply->old_ia != NULL) { - for (i = 0 ; i < reply->old_ia->num_iaaddr ; i++) { - lease = reply->old_ia->iaaddr[i]; + for (i = 0 ; i < reply->old_ia->num_iasubopt ; i++) { + lease = reply->old_ia->iasubopt[i]; best_lease = lease_compare(lease, best_lease); } @@ -2619,7 +2620,7 @@ find_client_address(struct reply_state *reply) { status = pick_v6_address(&reply->lease, reply->shared, &reply->client_id); } else if (best_lease != NULL) { - iaaddr_reference(&reply->lease, best_lease, MDL); + iasubopt_reference(&reply->lease, best_lease, MDL); status = ISC_R_SUCCESS; } @@ -2629,7 +2630,7 @@ find_client_address(struct reply_state *reply) { log_error("Reclaiming abandoned addresses is not yet " "supported. Treating this as an out of space " "condition."); - /* iaaddr_reference(&reply->lease, best_lease, MDL); */ + /* iasubopt_reference(&reply->lease, best_lease, MDL); */ } /* Give up now if we didn't find a lease. */ @@ -2760,7 +2761,7 @@ reply_process_is_addressed(struct reply_state *reply, /* Wait before renew! */ } - status = ia_add_iaaddr(reply->ia, reply->lease, MDL); + status = ia_add_iasubopt(reply->ia, reply->lease, MDL); if (status != ISC_R_SUCCESS) { log_fatal("reply_process_is_addressed: Unable to " "attach lease to new IA: %s", @@ -2831,8 +2832,8 @@ reply_process_send_addr(struct reply_state *reply, struct iaddr *addr) { } /* Choose the better of two leases. */ -static struct iaaddr * -lease_compare(struct iaaddr *alpha, struct iaaddr *beta) { +static struct iasubopt * +lease_compare(struct iasubopt *alpha, struct iasubopt *beta) { if (alpha == NULL) return beta; if (beta == NULL) @@ -3159,13 +3160,13 @@ reply_process_ia_pd(struct reply_state *reply, struct option_cache *ia) { */ if ((status != ISC_R_CANCELED) && (reply->static_prefixes == 0) && (reply->buf.reply.msg_type == DHCPV6_REPLY) && - (reply->ia->num_iaaddr != 0)) { - struct iaaddr *tmp; + (reply->ia->num_iasubopt != 0)) { + struct iasubopt *tmp; struct data_string *ia_id; int i; - for (i = 0 ; i < reply->ia->num_iaaddr ; i++) { - tmp = reply->ia->iaaddr[i]; + for (i = 0 ; i < reply->ia->num_iasubopt ; i++) { + tmp = reply->ia->iasubopt[i]; if (tmp->ia != NULL) ia_dereference(&tmp->ia, MDL); @@ -3211,7 +3212,7 @@ reply_process_ia_pd(struct reply_state *reply, struct option_cache *ia) { if (reply->old_ia != NULL) ia_dereference(&reply->old_ia, MDL); if (reply->lease != NULL) - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); /* * ISC_R_CANCELED is a status code used by the prefix processing to @@ -3439,7 +3440,7 @@ reply_process_prefix(struct reply_state *reply, struct option_cache *pref) { if (data.data != NULL) data_string_forget(&data, MDL); if (reply->lease != NULL) - iaaddr_dereference(&reply->lease, MDL); + iasubopt_dereference(&reply->lease, MDL); return status; } @@ -3469,17 +3470,17 @@ prefix_is_owned(struct reply_state *reply, struct iaddrcidrnet *pref) { } if ((reply->old_ia == NULL) || - (reply->old_ia->num_iaaddr == 0)) + (reply->old_ia->num_iasubopt == 0)) return ISC_FALSE; - for (i = 0 ; i < reply->old_ia->num_iaaddr ; i++) { - struct iaaddr *tmp; + for (i = 0 ; i < reply->old_ia->num_iasubopt ; i++) { + struct iasubopt *tmp; - tmp = reply->old_ia->iaaddr[i]; + tmp = reply->old_ia->iasubopt[i]; if ((pref->bits == (int) tmp->plen) && memcmp(pref->lo_addr.iabuf, &tmp->addr, 16) == 0) { - iaaddr_reference(&reply->lease, tmp, MDL); + iasubopt_reference(&reply->lease, tmp, MDL); return ISC_TRUE; } } @@ -3536,7 +3537,7 @@ static isc_result_t find_client_prefix(struct reply_state *reply) { struct iaddrcidrnet send_pref; isc_result_t status = ISC_R_NORESOURCES; - struct iaaddr *prefix, *best_prefix = NULL; + struct iasubopt *prefix, *best_prefix = NULL; struct binding_scope **scope; struct group *group; int i; @@ -3571,8 +3572,8 @@ find_client_prefix(struct reply_state *reply) { } if (reply->old_ia != NULL) { - for (i = 0 ; i < reply->old_ia->num_iaaddr ; i++) { - prefix = reply->old_ia->iaaddr[i]; + for (i = 0 ; i < reply->old_ia->num_iasubopt ; i++) { + prefix = reply->old_ia->iasubopt[i]; best_prefix = prefix_compare(reply, prefix, best_prefix); @@ -3586,7 +3587,7 @@ find_client_prefix(struct reply_state *reply) { status = pick_v6_prefix(&reply->lease, reply->preflen, reply->shared, &reply->client_id); } else if (best_prefix != NULL) { - iaaddr_reference(&reply->lease, best_prefix, MDL); + iasubopt_reference(&reply->lease, best_prefix, MDL); status = ISC_R_SUCCESS; } @@ -3596,7 +3597,7 @@ find_client_prefix(struct reply_state *reply) { log_error("Reclaiming abandoned prefixes is not yet " "supported. Treating this as an out of space " "condition."); - /* iaaddr_reference(&reply->lease, best_prefix, MDL); */ + /* iasubopt_reference(&reply->lease, best_prefix, MDL); */ } /* Give up now if we didn't find a prefix. */ @@ -3713,7 +3714,7 @@ reply_process_is_prefixed(struct reply_state *reply, /* Wait before renew! */ } - status = ia_add_iaaddr(reply->ia, reply->lease, MDL); + status = ia_add_iasubopt(reply->ia, reply->lease, MDL); if (status != ISC_R_SUCCESS) { log_fatal("reply_process_is_prefixed: Unable to " "attach prefix to new IA_PD: %s", @@ -3786,9 +3787,9 @@ reply_process_send_prefix(struct reply_state *reply, } /* Choose the better of two prefixes. */ -static struct iaaddr * +static struct iasubopt * prefix_compare(struct reply_state *reply, - struct iaaddr *alpha, struct iaaddr *beta) { + struct iasubopt *alpha, struct iasubopt *beta) { if (alpha == NULL) return beta; if (beta == NULL) @@ -4273,7 +4274,7 @@ dhcpv6_rebind(struct data_string *reply, struct packet *packet) { static void ia_na_match_decline(const struct data_string *client_id, const struct data_string *iaaddr, - struct iaaddr *lease) + struct iasubopt *lease) { char tmp_addr[INET6_ADDRSTRLEN]; @@ -4387,7 +4388,7 @@ iterate_over_ia_na(struct data_string *reply_ret, struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data; int reply_ofs = (int)((char *)reply->options - (char *)reply); char status_msg[32]; - struct iaaddr *lease; + struct iasubopt *lease; struct ia_xx *existing_ia_na; int i; struct data_string key; @@ -4576,16 +4577,16 @@ iterate_over_ia_na(struct data_string *reply_ret, /* * Make sure this address is in the IA_NA. */ - for (i=0; inum_iaaddr; i++) { - struct iaaddr *tmp; + for (i=0; inum_iasubopt; i++) { + struct iasubopt *tmp; struct in6_addr *in6_addr; - tmp = existing_ia_na->iaaddr[i]; + tmp = existing_ia_na->iasubopt[i]; in6_addr = &tmp->addr; if (memcmp(in6_addr, iaaddr.data, 16) == 0) { - iaaddr_reference(&lease, - tmp, MDL); + iasubopt_reference(&lease, + tmp, MDL); break; } } @@ -4604,7 +4605,7 @@ iterate_over_ia_na(struct data_string *reply_ret, } if (lease != NULL) { - iaaddr_dereference(&lease, MDL); + iasubopt_dereference(&lease, MDL); } data_string_forget(&iaaddr, MDL); @@ -4625,7 +4626,7 @@ iterate_over_ia_na(struct data_string *reply_ret, exit: if (lease != NULL) { - iaaddr_dereference(&lease, MDL); + iasubopt_dereference(&lease, MDL); } if (host_opt_state != NULL) { option_state_dereference(&host_opt_state, MDL); @@ -4692,7 +4693,7 @@ dhcpv6_decline(struct data_string *reply, struct packet *packet) { static void ia_na_match_release(const struct data_string *client_id, const struct data_string *iaaddr, - struct iaaddr *lease) + struct iasubopt *lease) { char tmp_addr[INET6_ADDRSTRLEN]; @@ -4783,7 +4784,7 @@ exit: static void ia_pd_match_release(const struct data_string *client_id, const struct data_string *iapref, - struct iaaddr *prefix) + struct iasubopt *prefix) { char tmp_addr[INET6_ADDRSTRLEN]; @@ -4899,7 +4900,7 @@ iterate_over_ia_pd(struct data_string *reply_ret, int iaprefix_is_found; char reply_data[65536]; int reply_ofs; - struct iaaddr *prefix; + struct iasubopt *prefix; struct ia_xx *existing_ia_pd; int i; struct data_string key; @@ -5044,19 +5045,19 @@ iterate_over_ia_pd(struct data_string *reply_ret, * Make sure this prefix is in the IA_PD. */ for (i = 0; - i < existing_ia_pd->num_iaaddr; + i < existing_ia_pd->num_iasubopt; i++) { - struct iaaddr *tmp; + struct iasubopt *tmp; u_int8_t plen; plen = getUChar(iaprefix.data + 8); - tmp = existing_ia_pd->iaaddr[i]; + tmp = existing_ia_pd->iasubopt[i]; if ((tmp->plen == plen) && (memcmp(&tmp->addr, iaprefix.data + 9, 16) == 0)) { - iaaddr_reference(&prefix, - tmp, MDL); + iasubopt_reference(&prefix, + tmp, MDL); break; } } @@ -5075,7 +5076,7 @@ iterate_over_ia_pd(struct data_string *reply_ret, } if (prefix != NULL) { - iaaddr_dereference(&prefix, MDL); + iasubopt_dereference(&prefix, MDL); } data_string_forget(&iaprefix, MDL); @@ -5104,7 +5105,7 @@ iterate_over_ia_pd(struct data_string *reply_ret, exit: if (prefix != NULL) { - iaaddr_dereference(&prefix, MDL); + iasubopt_dereference(&prefix, MDL); } if (host_opt_state != NULL) { option_state_dereference(&host_opt_state, MDL); diff --git a/server/mdb6.c b/server/mdb6.c index 021fdc37f..3c6899132 100644 --- a/server/mdb6.c +++ b/server/mdb6.c @@ -36,8 +36,8 @@ ia_hash_t *ia_na_active; ia_hash_t *ia_ta_active; ia_hash_t *ia_pd_active; -HASH_FUNCTIONS(iaaddr, struct in6_addr *, struct iaaddr, iaaddr_hash_t, - iaaddr_reference, iaaddr_dereference, do_string_hash); +HASH_FUNCTIONS(iasubopt, struct in6_addr *, struct iasubopt, iasubopt_hash_t, + iasubopt_reference, iasubopt_dereference, do_string_hash); struct ipv6_pool **pools; int num_pools; @@ -45,18 +45,18 @@ int num_pools; /* * Create a new IAADDR/PREFIX structure. * - * - iaaddr must be a pointer to a (struct iaaddr *) pointer previously + * - iasubopt must be a pointer to a (struct iasubopt *) pointer previously * initialized to NULL */ isc_result_t -iaaddr_allocate(struct iaaddr **iaaddr, const char *file, int line) { - struct iaaddr *tmp; +iasubopt_allocate(struct iasubopt **iasubopt, const char *file, int line) { + struct iasubopt *tmp; - if (iaaddr == NULL) { + if (iasubopt == NULL) { log_error("%s(%d): NULL pointer reference", file, line); return ISC_R_INVALIDARG; } - if (*iaaddr != NULL) { + if (*iasubopt != NULL) { log_error("%s(%d): non-NULL pointer", file, line); return ISC_R_INVALIDARG; } @@ -71,24 +71,24 @@ iaaddr_allocate(struct iaaddr **iaaddr, const char *file, int line) { tmp->heap_index = -1; tmp->plen = 255; - *iaaddr = tmp; + *iasubopt = tmp; return ISC_R_SUCCESS; } /* * Reference an IAADDR/PREFIX structure. * - * - iaaddr must be a pointer to a (struct iaaddr *) pointer previously + * - iasubopt must be a pointer to a (struct iasubopt *) pointer previously * initialized to NULL */ isc_result_t -iaaddr_reference(struct iaaddr **iaaddr, struct iaaddr *src, +iasubopt_reference(struct iasubopt **iasubopt, struct iasubopt *src, const char *file, int line) { - if (iaaddr == NULL) { + if (iasubopt == NULL) { log_error("%s(%d): NULL pointer reference", file, line); return ISC_R_INVALIDARG; } - if (*iaaddr != NULL) { + if (*iasubopt != NULL) { log_error("%s(%d): non-NULL pointer", file, line); return ISC_R_INVALIDARG; } @@ -96,7 +96,7 @@ iaaddr_reference(struct iaaddr **iaaddr, struct iaaddr *src, log_error("%s(%d): NULL pointer reference", file, line); return ISC_R_INVALIDARG; } - *iaaddr = src; + *iasubopt = src; src->refcnt++; return ISC_R_SUCCESS; } @@ -109,16 +109,16 @@ iaaddr_reference(struct iaaddr **iaaddr, struct iaaddr *src, * structure is freed. */ isc_result_t -iaaddr_dereference(struct iaaddr **iaaddr, const char *file, int line) { - struct iaaddr *tmp; +iasubopt_dereference(struct iasubopt **iasubopt, const char *file, int line) { + struct iasubopt *tmp; - if ((iaaddr == NULL) || (*iaaddr == NULL)) { + if ((iasubopt == NULL) || (*iasubopt == NULL)) { log_error("%s(%d): NULL pointer", file, line); return ISC_R_INVALIDARG; } - tmp = *iaaddr; - *iaaddr = NULL; + tmp = *iasubopt; + *iasubopt = NULL; tmp->refcnt--; if (tmp->refcnt < 0) { @@ -255,12 +255,12 @@ ia_dereference(struct ia_xx **ia, const char *file, int line) { tmp->refcnt = 0; } if (tmp->refcnt == 0) { - if (tmp->iaaddr != NULL) { - for (i=0; inum_iaaddr; i++) { - iaaddr_dereference(&(tmp->iaaddr[i]), - file, line); + if (tmp->iasubopt != NULL) { + for (i=0; inum_iasubopt; i++) { + iasubopt_dereference(&(tmp->iasubopt[i]), + file, line); } - dfree(tmp->iaaddr, file, line); + dfree(tmp->iasubopt, file, line); } data_string_forget(&(tmp->iaid_duid), file, line); dfree(tmp, file, line); @@ -273,10 +273,10 @@ ia_dereference(struct ia_xx **ia, const char *file, int line) { * Add an IAADDR/PREFIX entry to an IA structure. */ isc_result_t -ia_add_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, - const char *file, int line) { +ia_add_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt, + const char *file, int line) { int max; - struct iaaddr **new; + struct iasubopt **new; /* * Grow our array if we need to. @@ -285,21 +285,21 @@ ia_add_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, * guess as to how many addresses/prefixes we might expect * on an interface. */ - if (ia->max_iaaddr <= ia->num_iaaddr) { - max = ia->max_iaaddr + 4; - new = dmalloc(max * sizeof(struct iaaddr *), file, line); + if (ia->max_iasubopt <= ia->num_iasubopt) { + max = ia->max_iasubopt + 4; + new = dmalloc(max * sizeof(struct iasubopt *), file, line); if (new == NULL) { return ISC_R_NOMEMORY; } - memcpy(new, ia->iaaddr, - ia->num_iaaddr * sizeof(struct iaaddr *)); - ia->iaaddr = new; - ia->max_iaaddr = max; + memcpy(new, ia->iasubopt, + ia->num_iasubopt * sizeof(struct iasubopt *)); + ia->iasubopt = new; + ia->max_iasubopt = max; } - iaaddr_reference(&(ia->iaaddr[ia->num_iaaddr]), iaaddr, - file, line); - ia->num_iaaddr++; + iasubopt_reference(&(ia->iasubopt[ia->num_iasubopt]), iasubopt, + file, line); + ia->num_iasubopt++; return ISC_R_SUCCESS; } @@ -307,25 +307,25 @@ ia_add_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, /* * Remove an IAADDR/PREFIX entry to an IA structure. * - * Note: if an IAADDR appears more than once, then only ONE will be removed. + * Note: if a suboption appears more than once, then only ONE will be removed. */ void -ia_remove_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, - const char *file, int line) { +ia_remove_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt, + const char *file, int line) { int i, j; - for (i=0; inum_iaaddr; i++) { - if (ia->iaaddr[i] == iaaddr) { - /* remove this IAADDR */ - iaaddr_dereference(&(ia->iaaddr[i]), file, line); - /* move remaining IAADDR pointers down one */ - for (j=i+1; j < ia->num_iaaddr; j++) { - ia->iaaddr[j-1] = ia->iaaddr[j]; + for (i=0; inum_iasubopt; i++) { + if (ia->iasubopt[i] == iasubopt) { + /* remove this sub option */ + iasubopt_dereference(&(ia->iasubopt[i]), file, line); + /* move remaining suboption pointers down one */ + for (j=i+1; j < ia->num_iasubopt; j++) { + ia->iasubopt[j-1] = ia->iasubopt[j]; } /* decrease our total count */ - /* remove the back-reference in the IAADDR itself */ - ia_dereference(&iaaddr->ia, file, line); - ia->num_iaaddr--; + /* remove the back-reference in the suboption itself */ + ia_dereference(&iasubopt->ia, file, line); + ia->num_iasubopt--; return; } } @@ -336,14 +336,14 @@ ia_remove_iaaddr(struct ia_xx *ia, struct iaaddr *iaaddr, * Remove all addresses/prefixes from an IA. */ void -ia_remove_all_iaaddr(struct ia_xx *ia, const char *file, int line) { +ia_remove_all_lease(struct ia_xx *ia, const char *file, int line) { int i; - for (i=0; inum_iaaddr; i++) { - ia_dereference(&(ia->iaaddr[i]->ia), file, line); - iaaddr_dereference(&(ia->iaaddr[i]), file, line); + for (i=0; inum_iasubopt; i++) { + ia_dereference(&(ia->iasubopt[i]->ia), file, line); + iasubopt_dereference(&(ia->iasubopt[i]), file, line); } - ia->num_iaaddr = 0; + ia->num_iasubopt = 0; } /* @@ -387,20 +387,20 @@ ia_equal(const struct ia_xx *a, const struct ia_xx *b) /* * Make sure we have the same number of addresses/prefixes in each. */ - if (a->num_iaaddr != b->num_iaaddr) { + if (a->num_iasubopt != b->num_iasubopt) { return ISC_FALSE; } /* * Check that each address/prefix is present in both. */ - for (i=0; inum_iaaddr; i++) { + for (i=0; inum_iasubopt; i++) { found = ISC_FALSE; - for (j=0; jnum_iaaddr; j++) { - if (a->iaaddr[i]->plen != b->iaaddr[i]->plen) + for (j=0; jnum_iasubopt; j++) { + if (a->iasubopt[i]->plen != b->iasubopt[i]->plen) continue; - if (memcmp(&(a->iaaddr[i]->addr), - &(b->iaaddr[j]->addr), + if (memcmp(&(a->iasubopt[i]->addr), + &(b->iasubopt[j]->addr), sizeof(struct in6_addr)) == 0) { found = ISC_TRUE; break; @@ -423,15 +423,15 @@ ia_equal(const struct ia_xx *a, const struct ia_xx *b) */ static isc_boolean_t lease_older(void *a, void *b) { - struct iaaddr *ia = (struct iaaddr *)a; - struct iaaddr *ib = (struct iaaddr *)b; + struct iasubopt *la = (struct iasubopt *)a; + struct iasubopt *lb = (struct iasubopt *)b; - if (ia->hard_lifetime_end_time == ib->hard_lifetime_end_time) { - return difftime(ia->soft_lifetime_end_time, - ib->soft_lifetime_end_time) < 0; + if (la->hard_lifetime_end_time == lb->hard_lifetime_end_time) { + return difftime(la->soft_lifetime_end_time, + lb->soft_lifetime_end_time) < 0; } else { - return difftime(ia->hard_lifetime_end_time, - ib->hard_lifetime_end_time) < 0; + return difftime(la->hard_lifetime_end_time, + lb->hard_lifetime_end_time) < 0; } } @@ -440,8 +440,8 @@ lease_older(void *a, void *b) { * Callback when an address's position in the heap changes. */ static void -lease_index_changed(void *iaaddr, unsigned int new_heap_index) { - ((struct iaaddr *)iaaddr)-> heap_index = new_heap_index; +lease_index_changed(void *iasubopt, unsigned int new_heap_index) { + ((struct iasubopt *)iasubopt)-> heap_index = new_heap_index; } @@ -476,20 +476,20 @@ ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type, tmp->start_addr = *start_addr; tmp->bits = bits; tmp->units = units; - if (!iaaddr_new_hash(&tmp->addrs, DEFAULT_HASH_SIZE, file, line)) { + if (!iasubopt_new_hash(&tmp->leases, DEFAULT_HASH_SIZE, file, line)) { dfree(tmp, file, line); return ISC_R_NOMEMORY; } if (isc_heap_create(lease_older, lease_index_changed, 0, &(tmp->active_timeouts)) != ISC_R_SUCCESS) { - iaaddr_free_hash_table(&(tmp->addrs), file, line); + iasubopt_free_hash_table(&(tmp->leases), file, line); dfree(tmp, file, line); return ISC_R_NOMEMORY; } if (isc_heap_create(lease_older, lease_index_changed, 0, &(tmp->inactive_timeouts)) != ISC_R_SUCCESS) { isc_heap_destroy(&(tmp->active_timeouts)); - iaaddr_free_hash_table(&(tmp->addrs), file, line); + iasubopt_free_hash_table(&(tmp->leases), file, line); dfree(tmp, file, line); return ISC_R_NOMEMORY; } @@ -526,7 +526,7 @@ ipv6_pool_reference(struct ipv6_pool **pool, struct ipv6_pool *src, /* * Note: Each IAADDR/PREFIX in a pool is referenced by the pool. This is needed - * to prevent the IAADDR from being garbage collected out from under the + * to prevent the lease from being garbage collected out from under the * pool. * * The references are made from the hash and from the heap. The following @@ -539,9 +539,9 @@ ipv6_pool_reference(struct ipv6_pool **pool, struct ipv6_pool *src, */ static isc_result_t dereference_hash_entry(const void *name, unsigned len, void *value) { - struct iaaddr *iaaddr = (struct iaaddr *)value; + struct iasubopt *iasubopt = (struct iasubopt *)value; - iaaddr_dereference(&iaaddr, MDL); + iasubopt_dereference(&iasubopt, MDL); return ISC_R_SUCCESS; } @@ -551,9 +551,9 @@ dereference_hash_entry(const void *name, unsigned len, void *value) { */ static void dereference_heap_entry(void *value, void *dummy) { - struct iaaddr *iaaddr = (struct iaaddr *)value; + struct iasubopt *iasubopt = (struct iasubopt *)value; - iaaddr_dereference(&iaaddr, MDL); + iasubopt_dereference(&iasubopt, MDL); } @@ -581,8 +581,8 @@ ipv6_pool_dereference(struct ipv6_pool **pool, const char *file, int line) { tmp->refcnt = 0; } if (tmp->refcnt == 0) { - iaaddr_hash_foreach(tmp->addrs, dereference_hash_entry); - iaaddr_free_hash_table(&(tmp->addrs), file, line); + iasubopt_hash_foreach(tmp->leases, dereference_hash_entry); + iasubopt_free_hash_table(&(tmp->leases), file, line); isc_heap_foreach(tmp->active_timeouts, dereference_heap_entry, NULL); isc_heap_destroy(&(tmp->active_timeouts)); @@ -712,14 +712,14 @@ static struct in6_addr resany; * the long term. */ isc_result_t -create_lease6(struct ipv6_pool *pool, struct iaaddr **addr, +create_lease6(struct ipv6_pool *pool, struct iasubopt **addr, unsigned int *attempts, const struct data_string *uid, time_t soft_lifetime_end_time) { struct data_string ds; struct in6_addr tmp; - struct iaaddr *test_iaaddr; + struct iasubopt *test_iaaddr; struct data_string new_ds; - struct iaaddr *iaaddr; + struct iasubopt *iaaddr; isc_result_t result; isc_boolean_t reserved_iid; static isc_boolean_t init_resiid = ISC_FALSE; @@ -792,12 +792,12 @@ create_lease6(struct ipv6_pool *pool, struct iaaddr **addr, */ test_iaaddr = NULL; if (!reserved_iid && - (iaaddr_hash_lookup(&test_iaaddr, pool->addrs, - &tmp, sizeof(tmp), MDL) == 0)) { + (iasubopt_hash_lookup(&test_iaaddr, pool->leases, + &tmp, sizeof(tmp), MDL) == 0)) { break; } if (test_iaaddr != NULL) - iaaddr_dereference(&test_iaaddr, MDL); + iasubopt_dereference(&test_iaaddr, MDL); /* * Otherwise, we create a new input, adding the address @@ -823,7 +823,7 @@ create_lease6(struct ipv6_pool *pool, struct iaaddr **addr, * to hold it. */ iaaddr = NULL; - result = iaaddr_allocate(&iaaddr, MDL); + result = iasubopt_allocate(&iaaddr, MDL); if (result != ISC_R_SUCCESS) { return result; } @@ -835,9 +835,9 @@ create_lease6(struct ipv6_pool *pool, struct iaaddr **addr, */ result = add_lease6(pool, iaaddr, soft_lifetime_end_time); if (result == ISC_R_SUCCESS) { - iaaddr_reference(addr, iaaddr, MDL); + iasubopt_reference(addr, iaaddr, MDL); } - iaaddr_dereference(&iaaddr, MDL); + iasubopt_dereference(&iaaddr, MDL); return result; } @@ -846,88 +846,88 @@ create_lease6(struct ipv6_pool *pool, struct iaaddr **addr, * loading leases from the file. */ isc_result_t -add_lease6(struct ipv6_pool *pool, struct iaaddr *iaaddr, +add_lease6(struct ipv6_pool *pool, struct iasubopt *lease, time_t valid_lifetime_end_time) { isc_result_t insert_result; - struct iaaddr *test_iaaddr; - struct iaaddr *tmp_iaaddr; + struct iasubopt *test_iasubopt; + struct iasubopt *tmp_iasubopt; /* If a state was not assigned by the caller, assume active. */ - if (iaaddr->state == 0) - iaaddr->state = FTS_ACTIVE; + if (lease->state == 0) + lease->state = FTS_ACTIVE; - ipv6_pool_reference(&iaaddr->ipv6_pool, pool, MDL); + ipv6_pool_reference(&lease->ipv6_pool, pool, MDL); /* * If this IAADDR/PREFIX is already in our structures, remove the * old one. */ - test_iaaddr = NULL; - if (iaaddr_hash_lookup(&test_iaaddr, pool->addrs, - &iaaddr->addr, sizeof(iaaddr->addr), MDL)) { - /* XXX: we should probably ask the iaaddr what heap it is on + test_iasubopt = NULL; + if (iasubopt_hash_lookup(&test_iasubopt, pool->leases, + &lease->addr, sizeof(lease->addr), MDL)) { + /* XXX: we should probably ask the lease what heap it is on * (as a consistency check). * XXX: we should probably have one function to "put this lease * on its heap" rather than doing these if's everywhere. If * you add more states to this list, don't. */ - if ((test_iaaddr->state == FTS_ACTIVE) || - (test_iaaddr->state == FTS_ABANDONED)) { + if ((test_iasubopt->state == FTS_ACTIVE) || + (test_iasubopt->state == FTS_ABANDONED)) { isc_heap_delete(pool->active_timeouts, - test_iaaddr->heap_index); + test_iasubopt->heap_index); pool->num_active--; } else { isc_heap_delete(pool->inactive_timeouts, - test_iaaddr->heap_index); + test_iasubopt->heap_index); pool->num_inactive--; } - iaaddr_hash_delete(pool->addrs, &test_iaaddr->addr, - sizeof(test_iaaddr->addr), MDL); + iasubopt_hash_delete(pool->leases, &test_iasubopt->addr, + sizeof(test_iasubopt->addr), MDL); /* * We're going to do a bit of evil trickery here. * * We need to dereference the entry once to remove our - * current reference (in test_iaaddr), and then one + * current reference (in test_iasubopt), and then one * more time to remove the reference left when the * address was added to the pool before. */ - tmp_iaaddr = test_iaaddr; - iaaddr_dereference(&test_iaaddr, MDL); - iaaddr_dereference(&tmp_iaaddr, MDL); + tmp_iasubopt = test_iasubopt; + iasubopt_dereference(&test_iasubopt, MDL); + iasubopt_dereference(&tmp_iasubopt, MDL); } /* * Add IAADDR/PREFIX to our structures. */ - tmp_iaaddr = NULL; - iaaddr_reference(&tmp_iaaddr, iaaddr, MDL); - if ((tmp_iaaddr->state == FTS_ACTIVE) || - (tmp_iaaddr->state == FTS_ABANDONED)) { - tmp_iaaddr->hard_lifetime_end_time = valid_lifetime_end_time; - iaaddr_hash_add(pool->addrs, &tmp_iaaddr->addr, - sizeof(tmp_iaaddr->addr), iaaddr, MDL); + tmp_iasubopt = NULL; + iasubopt_reference(&tmp_iasubopt, lease, MDL); + if ((tmp_iasubopt->state == FTS_ACTIVE) || + (tmp_iasubopt->state == FTS_ABANDONED)) { + tmp_iasubopt->hard_lifetime_end_time = valid_lifetime_end_time; + iasubopt_hash_add(pool->leases, &tmp_iasubopt->addr, + sizeof(tmp_iasubopt->addr), lease, MDL); insert_result = isc_heap_insert(pool->active_timeouts, - tmp_iaaddr); + tmp_iasubopt); if (insert_result == ISC_R_SUCCESS) pool->num_active++; } else { - tmp_iaaddr->soft_lifetime_end_time = valid_lifetime_end_time; + tmp_iasubopt->soft_lifetime_end_time = valid_lifetime_end_time; insert_result = isc_heap_insert(pool->inactive_timeouts, - tmp_iaaddr); + tmp_iasubopt); if (insert_result == ISC_R_SUCCESS) pool->num_inactive++; } if (insert_result != ISC_R_SUCCESS) { - iaaddr_hash_delete(pool->addrs, &iaaddr->addr, - sizeof(iaaddr->addr), MDL); - iaaddr_dereference(&tmp_iaaddr, MDL); + iasubopt_hash_delete(pool->leases, &lease->addr, + sizeof(lease->addr), MDL); + iasubopt_dereference(&tmp_iasubopt, MDL); return insert_result; } /* - * Note: we intentionally leave tmp_iaaddr referenced; there + * Note: we intentionally leave tmp_iasubopt referenced; there * is a reference in the heap/hash, after all. */ @@ -939,12 +939,12 @@ add_lease6(struct ipv6_pool *pool, struct iaaddr *iaaddr, */ isc_boolean_t lease6_exists(const struct ipv6_pool *pool, const struct in6_addr *addr) { - struct iaaddr *test_iaaddr; + struct iasubopt *test_iaaddr; test_iaaddr = NULL; - if (iaaddr_hash_lookup(&test_iaaddr, pool->addrs, - (void *)addr, sizeof(*addr), MDL)) { - iaaddr_dereference(&test_iaaddr, MDL); + if (iasubopt_hash_lookup(&test_iaaddr, pool->leases, + (void *)addr, sizeof(*addr), MDL)) { + iasubopt_dereference(&test_iaaddr, MDL); return ISC_TRUE; } else { return ISC_FALSE; @@ -955,19 +955,19 @@ lease6_exists(const struct ipv6_pool *pool, const struct in6_addr *addr) { * Put the lease on our active pool. */ static isc_result_t -move_lease_to_active(struct ipv6_pool *pool, struct iaaddr *addr) { +move_lease_to_active(struct ipv6_pool *pool, struct iasubopt *lease) { isc_result_t insert_result; int old_heap_index; - old_heap_index = addr->heap_index; - insert_result = isc_heap_insert(pool->active_timeouts, addr); + old_heap_index = lease->heap_index; + insert_result = isc_heap_insert(pool->active_timeouts, lease); if (insert_result == ISC_R_SUCCESS) { - iaaddr_hash_add(pool->addrs, &addr->addr, - sizeof(addr->addr), addr, MDL); + iasubopt_hash_add(pool->leases, &lease->addr, + sizeof(lease->addr), lease, MDL); isc_heap_delete(pool->inactive_timeouts, old_heap_index); pool->num_active++; pool->num_inactive--; - addr->state = FTS_ACTIVE; + lease->state = FTS_ACTIVE; } return insert_result; } @@ -981,7 +981,7 @@ move_lease_to_active(struct ipv6_pool *pool, struct iaaddr *addr) { * WARNING: lease times must only be extended, never reduced!!! */ isc_result_t -renew_lease6(struct ipv6_pool *pool, struct iaaddr *addr) { +renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease) { /* * If we're already active, then we can just move our expiration * time down the heap. @@ -989,11 +989,11 @@ renew_lease6(struct ipv6_pool *pool, struct iaaddr *addr) { * Otherwise, we have to move from the inactive heap to the * active heap. */ - if (addr->state == FTS_ACTIVE) { - isc_heap_decreased(pool->active_timeouts, addr->heap_index); + if (lease->state == FTS_ACTIVE) { + isc_heap_decreased(pool->active_timeouts, lease->heap_index); return ISC_R_SUCCESS; } else { - return move_lease_to_active(pool, addr); + return move_lease_to_active(pool, lease); } } @@ -1001,30 +1001,30 @@ renew_lease6(struct ipv6_pool *pool, struct iaaddr *addr) { * Put the lease on our inactive pool, with the specified state. */ static isc_result_t -move_lease_to_inactive(struct ipv6_pool *pool, struct iaaddr *addr, +move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease, binding_state_t state) { isc_result_t insert_result; int old_heap_index; - old_heap_index = addr->heap_index; - insert_result = isc_heap_insert(pool->inactive_timeouts, addr); + old_heap_index = lease->heap_index; + insert_result = isc_heap_insert(pool->inactive_timeouts, lease); if (insert_result == ISC_R_SUCCESS) { /* Process events upon expiration. */ if (pool->pool_type != D6O_IA_PD) { - ddns_removals(NULL, addr); + ddns_removals(NULL, lease); } /* Binding scopes are no longer valid after expiry or * release. */ - if (addr->scope != NULL) { - binding_scope_dereference(&addr->scope, MDL); + if (lease->scope != NULL) { + binding_scope_dereference(&lease->scope, MDL); } - iaaddr_hash_delete(pool->addrs, - &addr->addr, sizeof(addr->addr), MDL); + iasubopt_hash_delete(pool->leases, + &lease->addr, sizeof(lease->addr), MDL); isc_heap_delete(pool->active_timeouts, old_heap_index); - addr->state = state; + lease->state = state; pool->num_active--; pool->num_inactive++; } @@ -1035,33 +1035,34 @@ move_lease_to_inactive(struct ipv6_pool *pool, struct iaaddr *addr, * Expire the oldest lease if it's lifetime_end_time is * older than the given time. * - * - iaaddr must be a pointer to a (struct iaaddr *) pointer previously + * - leasep must be a pointer to a (struct iasubopt *) pointer previously * initialized to NULL * - * On return iaaddr has a reference to the removed entry. It is left + * On return leasep has a reference to the removed entry. It is left * pointing to NULL if the oldest lease has not expired. */ isc_result_t -expire_lease6(struct iaaddr **addr, struct ipv6_pool *pool, time_t now) { - struct iaaddr *tmp; +expire_lease6(struct iasubopt **leasep, struct ipv6_pool *pool, time_t now) { + struct iasubopt *tmp; isc_result_t result; - if (addr == NULL) { + if (leasep == NULL) { log_error("%s(%d): NULL pointer reference", MDL); return ISC_R_INVALIDARG; } - if (*addr != NULL) { + if (*leasep != NULL) { log_error("%s(%d): non-NULL pointer", MDL); return ISC_R_INVALIDARG; } if (pool->num_active > 0) { - tmp = (struct iaaddr *)isc_heap_element(pool->active_timeouts, - 1); + tmp = (struct iasubopt *) + isc_heap_element(pool->active_timeouts, 1); if (now > tmp->hard_lifetime_end_time) { - result = move_lease_to_inactive(pool, tmp, FTS_EXPIRED); + result = move_lease_to_inactive(pool, tmp, + FTS_EXPIRED); if (result == ISC_R_SUCCESS) { - iaaddr_reference(addr, tmp, MDL); + iasubopt_reference(leasep, tmp, MDL); } return result; } @@ -1075,18 +1076,18 @@ expire_lease6(struct iaaddr **addr, struct ipv6_pool *pool, time_t now) { * it as declined. Give it an infinite (well, really long) life. */ isc_result_t -decline_lease6(struct ipv6_pool *pool, struct iaaddr *addr) { +decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease) { isc_result_t result; - if (addr->state != FTS_ACTIVE) { - result = move_lease_to_active(pool, addr); + if (lease->state != FTS_ACTIVE) { + result = move_lease_to_active(pool, lease); if (result != ISC_R_SUCCESS) { return result; } } - addr->state = FTS_ABANDONED; - addr->hard_lifetime_end_time = MAX_TIME; - isc_heap_decreased(pool->active_timeouts, addr->heap_index); + lease->state = FTS_ABANDONED; + lease->hard_lifetime_end_time = MAX_TIME; + isc_heap_decreased(pool->active_timeouts, lease->heap_index); return ISC_R_SUCCESS; } @@ -1094,9 +1095,9 @@ decline_lease6(struct ipv6_pool *pool, struct iaaddr *addr) { * Put the returned lease on our inactive pool. */ isc_result_t -release_lease6(struct ipv6_pool *pool, struct iaaddr *addr) { - if (addr->state == FTS_ACTIVE) { - return move_lease_to_inactive(pool, addr, FTS_RELEASED); +release_lease6(struct ipv6_pool *pool, struct iasubopt *lease) { + if (lease->state == FTS_ACTIVE) { + return move_lease_to_inactive(pool, lease, FTS_RELEASED); } else { return ISC_R_SUCCESS; } @@ -1187,15 +1188,15 @@ build_prefix6(struct in6_addr *pref, * the long term. */ isc_result_t -create_prefix6(struct ipv6_pool *pool, struct iaaddr **pref, +create_prefix6(struct ipv6_pool *pool, struct iasubopt **pref, unsigned int *attempts, const struct data_string *uid, time_t soft_lifetime_end_time) { struct data_string ds; struct in6_addr tmp; - struct iaaddr *test_iapref; + struct iasubopt *test_iapref; struct data_string new_ds; - struct iaaddr *iapref; + struct iasubopt *iapref; isc_result_t result; /* @@ -1224,11 +1225,11 @@ create_prefix6(struct ipv6_pool *pool, struct iaaddr **pref, * If this prefix is not in use, we're happy with it */ test_iapref = NULL; - if (iaaddr_hash_lookup(&test_iapref, pool->addrs, - &tmp, sizeof(tmp), MDL) == 0) { + if (iasubopt_hash_lookup(&test_iapref, pool->leases, + &tmp, sizeof(tmp), MDL) == 0) { break; } - iaaddr_dereference(&test_iapref, MDL); + iasubopt_dereference(&test_iapref, MDL); /* * Otherwise, we create a new input, adding the prefix @@ -1254,7 +1255,7 @@ create_prefix6(struct ipv6_pool *pool, struct iaaddr **pref, * to hold it. */ iapref = NULL; - result = iaaddr_allocate(&iapref, MDL); + result = iasubopt_allocate(&iapref, MDL); if (result != ISC_R_SUCCESS) { return result; } @@ -1266,9 +1267,9 @@ create_prefix6(struct ipv6_pool *pool, struct iaaddr **pref, */ result = add_lease6(pool, iapref, soft_lifetime_end_time); if (result == ISC_R_SUCCESS) { - iaaddr_reference(pref, iapref, MDL); + iasubopt_reference(pref, iapref, MDL); } - iaaddr_dereference(&iapref, MDL); + iasubopt_dereference(&iapref, MDL); return result; } @@ -1278,15 +1279,15 @@ create_prefix6(struct ipv6_pool *pool, struct iaaddr **pref, isc_boolean_t prefix6_exists(const struct ipv6_pool *pool, const struct in6_addr *pref, u_int8_t plen) { - struct iaaddr *test_iapref; + struct iasubopt *test_iapref; if ((int)plen != pool->units) return ISC_FALSE; test_iapref = NULL; - if (iaaddr_hash_lookup(&test_iapref, pool->addrs, - (void *)pref, sizeof(*pref), MDL)) { - iaaddr_dereference(&test_iapref, MDL); + if (iasubopt_hash_lookup(&test_iapref, pool->leases, + (void *)pref, sizeof(*pref), MDL)) { + iasubopt_dereference(&test_iapref, MDL); return ISC_TRUE; } else { return ISC_FALSE; @@ -1300,15 +1301,15 @@ prefix6_exists(const struct ipv6_pool *pool, */ isc_result_t mark_lease_unavailable(struct ipv6_pool *pool, const struct in6_addr *addr) { - struct iaaddr *dummy_iaaddr; + struct iasubopt *dummy_iasubopt; isc_result_t result; - dummy_iaaddr = NULL; - result = iaaddr_allocate(&dummy_iaaddr, MDL); + dummy_iasubopt = NULL; + result = iasubopt_allocate(&dummy_iasubopt, MDL); if (result == ISC_R_SUCCESS) { - dummy_iaaddr->addr = *addr; - iaaddr_hash_add(pool->addrs, &dummy_iaaddr->addr, - sizeof(*addr), dummy_iaaddr, MDL); + dummy_iasubopt->addr = *addr; + iasubopt_hash_add(pool->leases, &dummy_iasubopt->addr, + sizeof(*addr), dummy_iasubopt, MDL); } return result; } @@ -1340,15 +1341,15 @@ add_ipv6_pool(struct ipv6_pool *pool) { static void cleanup_old_expired(struct ipv6_pool *pool) { - struct iaaddr *tmp; + struct iasubopt *tmp; struct ia_xx *ia; struct ia_xx *ia_active; unsigned char *tmpd; time_t timeout; while (pool->num_inactive > 0) { - tmp = (struct iaaddr *)isc_heap_element(pool->inactive_timeouts, - 1); + tmp = (struct iasubopt *) + isc_heap_element(pool->inactive_timeouts, 1); if (tmp->hard_lifetime_end_time != 0) { timeout = tmp->hard_lifetime_end_time; timeout += EXPIRED_IPV6_CLEANUP_TIME; @@ -1370,11 +1371,11 @@ cleanup_old_expired(struct ipv6_pool *pool) { */ ia = NULL; ia_reference(&ia, tmp->ia, MDL); - ia_remove_iaaddr(ia, tmp, MDL); + ia_remove_iasubopt(ia, tmp, MDL); ia_active = NULL; tmpd = (unsigned char *)ia->iaid_duid.data; if ((ia->ia_type == D6O_IA_NA) && - (ia->num_iaaddr <= 0) && + (ia->num_iasubopt <= 0) && (ia_hash_lookup(&ia_active, ia_na_active, tmpd, ia->iaid_duid.len, MDL) == 0) && (ia_active == ia)) { @@ -1382,7 +1383,7 @@ cleanup_old_expired(struct ipv6_pool *pool) { ia->iaid_duid.len, MDL); } if ((ia->ia_type == D6O_IA_TA) && - (ia->num_iaaddr <= 0) && + (ia->num_iasubopt <= 0) && (ia_hash_lookup(&ia_active, ia_ta_active, tmpd, ia->iaid_duid.len, MDL) == 0) && (ia_active == ia)) { @@ -1390,7 +1391,7 @@ cleanup_old_expired(struct ipv6_pool *pool) { ia->iaid_duid.len, MDL); } if ((ia->ia_type == D6O_IA_PD) && - (ia->num_iaaddr <= 0) && + (ia->num_iasubopt <= 0) && (ia_hash_lookup(&ia_active, ia_pd_active, tmpd, ia->iaid_duid.len, MDL) == 0) && (ia_active == ia)) { @@ -1399,14 +1400,14 @@ cleanup_old_expired(struct ipv6_pool *pool) { } ia_dereference(&ia, MDL); } - iaaddr_dereference(&tmp, MDL); + iasubopt_dereference(&tmp, MDL); } } static void lease_timeout_support(void *vpool) { struct ipv6_pool *pool; - struct iaaddr *addr; + struct iasubopt *lease; pool = (struct ipv6_pool *)vpool; for (;;) { @@ -1417,11 +1418,11 @@ lease_timeout_support(void *vpool) { * expire_lease6() will return ISC_R_SUCCESS with * a NULL lease. */ - addr = NULL; - if (expire_lease6(&addr, pool, cur_time) != ISC_R_SUCCESS) { + lease = NULL; + if (expire_lease6(&lease, pool, cur_time) != ISC_R_SUCCESS) { break; } - if (addr == NULL) { + if (lease == NULL) { break; } @@ -1432,12 +1433,12 @@ lease_timeout_support(void *vpool) { * timer rather than expiration timer? */ if (pool->pool_type != D6O_IA_PD) { - ddns_removals(NULL, addr); + ddns_removals(NULL, lease); } - write_ia(addr->ia); + write_ia(lease->ia); - iaaddr_dereference(&addr, MDL); + iasubopt_dereference(&lease, MDL); } /* @@ -1457,7 +1458,7 @@ lease_timeout_support(void *vpool) { */ void schedule_lease_timeout(struct ipv6_pool *pool) { - struct iaaddr *tmp; + struct iasubopt *tmp; time_t timeout; time_t next_timeout; struct timeval tv; @@ -1465,16 +1466,16 @@ schedule_lease_timeout(struct ipv6_pool *pool) { next_timeout = MAX_TIME; if (pool->num_active > 0) { - tmp = (struct iaaddr *)isc_heap_element(pool->active_timeouts, - 1); + tmp = (struct iasubopt *) + isc_heap_element(pool->active_timeouts, 1); if (tmp->hard_lifetime_end_time < next_timeout) { next_timeout = tmp->hard_lifetime_end_time + 1; } } if (pool->num_inactive > 0) { - tmp = (struct iaaddr *)isc_heap_element(pool->inactive_timeouts, - 1); + tmp = (struct iasubopt *) + isc_heap_element(pool->inactive_timeouts, 1); if (tmp->hard_lifetime_end_time != 0) { timeout = tmp->hard_lifetime_end_time; timeout += EXPIRED_IPV6_CLEANUP_TIME; @@ -1612,7 +1613,8 @@ find_ipv6_pool(struct ipv6_pool **pool, u_int16_t type, */ static isc_result_t change_leases(struct ia_xx *ia, - isc_result_t (*change_func)(struct ipv6_pool *, struct iaaddr*)) { + isc_result_t (*change_func)(struct ipv6_pool *, + struct iasubopt *)) { isc_result_t retval; isc_result_t renew_retval; struct ipv6_pool *pool; @@ -1620,12 +1622,12 @@ change_leases(struct ia_xx *ia, int i; retval = ISC_R_SUCCESS; - for (i=0; inum_iaaddr; i++) { + for (i=0; inum_iasubopt; i++) { pool = NULL; - addr = &ia->iaaddr[i]->addr; + addr = &ia->iasubopt[i]->addr; if (find_ipv6_pool(&pool, ia->ia_type, addr) == ISC_R_SUCCESS) { - renew_retval = change_func(pool, ia->iaaddr[i]); + renew_retval = change_func(pool, ia->iasubopt[i]); if (renew_retval != ISC_R_SUCCESS) { retval = renew_retval; } @@ -1844,8 +1846,8 @@ mark_interfaces_unavailable(void) { int main(int argc, char *argv[]) { - struct iaaddr *iaaddr; - struct iaaddr *iaaddr_copy; + struct iasubopt *iaaddr; + struct iasubopt *iaaddr_copy; u_int32_t iaid; struct ia_xx *ia_na; struct ia_xx *ia_na_copy; @@ -1856,15 +1858,15 @@ main(int argc, char *argv[]) { char addr_buf[INET6_ADDRSTRLEN]; char *uid; struct data_string ds; - struct iaaddr *expired_iaaddr; + struct iasubopt *expired_iaaddr; unsigned int attempts; /* * Test 0: Basic iaaddr manipulation. */ iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } if (iaaddr->state != FTS_FREE) { @@ -1876,16 +1878,16 @@ main(int argc, char *argv[]) { return 1; } iaaddr_copy = NULL; - if (iaaddr_reference(&iaaddr_copy, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_reference(&iaaddr_copy, iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr_copy, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr_copy, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } @@ -1893,49 +1895,49 @@ main(int argc, char *argv[]) { * Test 1: Error iaaddr manipulation. */ /* bogus allocate arguments */ - if (iaaddr_allocate(NULL, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + if (iasubopt_allocate(NULL, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } - iaaddr = (struct iaaddr *)1; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + iaaddr = (struct iasubopt *)1; + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } /* bogus reference arguments */ iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } - if (iaaddr_reference(NULL, iaaddr, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_reference(NULL, iaaddr, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } - iaaddr_copy = (struct iaaddr *)1; - if (iaaddr_reference(&iaaddr_copy, iaaddr, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + iaaddr_copy = (struct iasubopt *)1; + if (iasubopt_reference(&iaaddr_copy, iaaddr, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } iaaddr_copy = NULL; - if (iaaddr_reference(&iaaddr_copy, NULL, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_reference(&iaaddr_copy, NULL, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } /* bogus dereference arguments */ - if (iaaddr_dereference(NULL, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(NULL, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } iaaddr = NULL; - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_INVALIDARG) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_INVALIDARG) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } @@ -1956,8 +1958,8 @@ main(int argc, char *argv[]) { printf("ERROR: bad IAID_DUID %s:%d\n", MDL); return 1; } - if (ia_na->num_iaaddr != 0) { - printf("ERROR: bad num_iaaddr %s:%d\n", MDL); + if (ia_na->num_iasubopt != 0) { + printf("ERROR: bad num_iasubopt %s:%d\n", MDL); return 1; } ia_na_copy = NULL; @@ -1966,17 +1968,17 @@ main(int argc, char *argv[]) { return 1; } iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } - if (ia_add_iaaddr(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_add_iaaddr() %s:%d\n", MDL); + if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: ia_add_iasubopt() %s:%d\n", MDL); return 1; } - ia_remove_iaaddr(ia_na, iaaddr, MDL); - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + ia_remove_iasubopt(ia_na, iaaddr, MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { @@ -2001,22 +2003,22 @@ main(int argc, char *argv[]) { } for (i=0; i<100; i++) { iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } - if (ia_add_iaaddr(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_add_iaaddr() %s:%d\n", MDL); + if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: ia_add_iasubopt() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } } for (i=0; i<100; i++) { - iaaddr = ia_na->iaaddr[random() % ia_na->num_iaaddr]; - ia_remove_iaaddr(ia_na, iaaddr, MDL); + iaaddr = ia_na->iasubopt[random() % ia_na->num_iasubopt]; + ia_remove_iasubopt(ia_na, iaaddr, MDL); } if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { printf("ERROR: ia_dereference() %s:%d\n", MDL); @@ -2032,16 +2034,16 @@ main(int argc, char *argv[]) { } for (i=0; i<100; i++) { iaaddr = NULL; - if (iaaddr_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_allocate() %s:%d\n", MDL); + if (iasubopt_allocate(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_allocate() %s:%d\n", MDL); return 1; } - if (ia_add_iaaddr(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: ia_add_iaaddr() %s:%d\n", MDL); + if (ia_add_iasubopt(ia_na, iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: ia_add_iasubopt() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_reference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_reference() %s:%d\n", MDL); return 1; } } @@ -2103,7 +2105,7 @@ main(int argc, char *argv[]) { printf("ERROR: ia_allocate() %s:%d\n", MDL); return 1; } - ia_remove_iaaddr(ia_na, NULL, MDL); + ia_remove_iasubopt(ia_na, NULL, MDL); if (ia_dereference(&ia_na, MDL) != ISC_R_SUCCESS) { printf("ERROR: ia_dereference() %s:%d\n", MDL); return 1; @@ -2188,16 +2190,16 @@ main(int argc, char *argv[]) { printf("ERROR: should have expired a lease %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } if (pool->num_active != 0) { printf("ERROR: bad num_active %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } @@ -2223,8 +2225,8 @@ main(int argc, char *argv[]) { printf("ERROR: bad num_active %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } if (create_lease6(pool, &iaaddr, &attempts, @@ -2248,8 +2250,8 @@ main(int argc, char *argv[]) { printf("ERROR: bad num_active %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } @@ -2316,8 +2318,8 @@ main(int argc, char *argv[]) { printf("ERROR: renew_lease6() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } if (pool->num_active != (i / 10)) { @@ -2349,8 +2351,9 @@ main(int argc, char *argv[]) { MDL); return 1; } - if (iaaddr_dereference(&expired_iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&expired_iaaddr, MDL) != + ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } } @@ -2386,8 +2389,8 @@ main(int argc, char *argv[]) { printf("ERROR: renew_lease6() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } if (create_lease6(pool, &iaaddr, &attempts, @@ -2399,8 +2402,8 @@ main(int argc, char *argv[]) { printf("ERROR: renew_lease6() %s:%d\n", MDL); return 1; } - if (iaaddr_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { - printf("ERROR: iaaddr_dereference() %s:%d\n", MDL); + if (iasubopt_dereference(&iaaddr, MDL) != ISC_R_SUCCESS) { + printf("ERROR: iasubopt_dereference() %s:%d\n", MDL); return 1; } if (create_lease6(pool, &iaaddr, &attempts,