int previous_usage = -1;
int new_usage = -1;
- for (i = 0; i < pool->size; ++i)
+ for (i = 0; i < pool->ipv4.size; ++i)
{
struct ifconfig_pool_entry *ipe = &pool->list[i];
if (!ipe->in_use)
ASSERT(start <= end && end - start < IFCONFIG_POOL_MAX);
ALLOC_OBJ_CLEAR(pool, struct ifconfig_pool);
- pool->type = type;
+ pool->ipv4.type = type;
pool->duplicate_cn = duplicate_cn;
- switch (type)
+ switch (pool->ipv4.type)
{
case IFCONFIG_POOL_30NET:
- pool->base = start & ~3;
- pool->size = (((end | 3) + 1) - pool->base) >> 2;
+ pool->ipv4.base = start & ~3;
+ pool->ipv4.size = (((end | 3) + 1) - pool->ipv4.base) >> 2;
break;
case IFCONFIG_POOL_INDIV:
- pool->base = start;
- pool->size = end - start + 1;
+ pool->ipv4.base = start;
+ pool->ipv4.size = end - start + 1;
break;
default:
}
/* IPv6 pools are always "INDIV" type */
- pool->ipv6 = ipv6_pool;
+ pool->ipv6.enabled = ipv6_pool;
- if (pool->ipv6)
+ if (pool->ipv6.enabled)
{
- pool->base_ipv6 = ipv6_base;
- pool->size_ipv6 = ipv6_netbits>96 ? ( 1<<(128-ipv6_netbits) )
+ pool->ipv6.base = ipv6_base;
+ pool->ipv6.size = ipv6_netbits > 96 ? (1 << (128 - ipv6_netbits))
: IFCONFIG_POOL_MAX;
msg( D_IFCONFIG_POOL, "IFCONFIG POOL IPv6: (IPv4) size=%d, size_ipv6=%d, netbits=%d, base_ipv6=%s",
- pool->size, pool->size_ipv6, ipv6_netbits,
- print_in6_addr( pool->base_ipv6, 0, &gc ));
+ pool->ipv4.size, pool->ipv6.size, ipv6_netbits,
+ print_in6_addr(pool->ipv6.base, 0, &gc));
/* the current code is very simple and assumes that the IPv6
* pool is at least as big as the IPv4 pool, and we don't need
* to do separate math etc. for IPv6
*/
- ASSERT( pool->size < pool->size_ipv6 );
+ ASSERT(pool->ipv4.size < pool->ipv6.size);
}
- ALLOC_ARRAY_CLEAR(pool->list, struct ifconfig_pool_entry, pool->size);
+ ALLOC_ARRAY_CLEAR(pool->list, struct ifconfig_pool_entry, pool->ipv4.size);
msg(D_IFCONFIG_POOL, "IFCONFIG POOL: base=%s size=%d, ipv6=%d",
- print_in_addr_t(pool->base, 0, &gc),
- pool->size, pool->ipv6 );
+ print_in_addr_t(pool->ipv4.base, 0, &gc),
+ pool->ipv4.size, pool->ipv6.enabled);
gc_free(&gc);
return pool;
if (pool)
{
int i;
- for (i = 0; i < pool->size; ++i)
+ for (i = 0; i < pool->ipv4.size; ++i)
{
ifconfig_pool_entry_free(&pool->list[i], true);
}
ipe->common_name = string_alloc(common_name, NULL);
}
- switch (pool->type)
+ switch (pool->ipv4.type)
{
case IFCONFIG_POOL_30NET:
{
- in_addr_t b = pool->base + (i << 2);
+ in_addr_t b = pool->ipv4.base + (i << 2);
*local = b + 1;
*remote = b + 2;
break;
case IFCONFIG_POOL_INDIV:
{
- in_addr_t b = pool->base + i;
+ in_addr_t b = pool->ipv4.base + i;
*local = 0;
*remote = b;
break;
}
/* IPv6 pools are always INDIV (--linear) */
- if (pool->ipv6 && remote_ipv6)
+ if (pool->ipv6.enabled && remote_ipv6)
{
- *remote_ipv6 = add_in6_addr( pool->base_ipv6, i );
+ *remote_ipv6 = add_in6_addr(pool->ipv6.base, i);
}
}
return i;
ifconfig_pool_release(struct ifconfig_pool *pool, ifconfig_pool_handle hand, const bool hard)
{
bool ret = false;
- if (pool && hand >= 0 && hand < pool->size)
+ if (pool && hand >= 0 && hand < pool->ipv4.size)
{
ifconfig_pool_entry_free(&pool->list[hand], hard);
ret = true;
{
ifconfig_pool_handle ret = -1;
- switch (pool->type)
+ switch (pool->ipv4.type)
{
case IFCONFIG_POOL_30NET:
{
- ret = (addr - pool->base) >> 2;
+ ret = (addr - pool->ipv4.base) >> 2;
break;
}
case IFCONFIG_POOL_INDIV:
{
- ret = (addr - pool->base);
+ ret = (addr - pool->ipv4.base);
break;
}
ASSERT(0);
}
- if (ret < 0 || ret >= pool->size)
+ if (ret < 0 || ret >= pool->ipv4.size)
{
ret = -1;
}
{
in_addr_t ret = 0;
- if (hand >= 0 && hand < pool->size)
+ if (hand >= 0 && hand < pool->ipv4.size)
{
- switch (pool->type)
+ switch (pool->ipv4.type)
{
case IFCONFIG_POOL_30NET:
{
- ret = pool->base + (hand << 2);
+ ret = pool->ipv4.base + (hand << 2);
break;
}
case IFCONFIG_POOL_INDIV:
{
- ret = pool->base + hand;
+ ret = pool->ipv4.base + hand;
break;
}
struct in6_addr ret = in6addr_any;
/* IPv6 pools are always INDIV (--linear) */
- if (hand >= 0 && hand < pool->size_ipv6)
+ if (hand >= 0 && hand < pool->ipv6.size)
{
- ret = add_in6_addr( pool->base_ipv6, hand );
+ ret = add_in6_addr( pool->ipv6.base, hand );
}
return ret;
}
struct gc_arena gc = gc_new();
int i;
- for (i = 0; i < pool->size; ++i)
+ for (i = 0; i < pool->ipv4.size; ++i)
{
const struct ifconfig_pool_entry *e = &pool->list[i];
if (e->common_name)
{
const in_addr_t ip = ifconfig_pool_handle_to_ip_base(pool, i);
- if (pool->ipv6)
+ if (pool->ipv6.enabled)
{
struct in6_addr ip6 = ifconfig_pool_handle_to_ipv6_base(pool, i);
status_printf(out, "%s,%s,%s",