17static struct ec_dict *pools = NULL;
28void ip_pool_exit(
void)
33static void __ip_pool_free(
void *_pool)
35 struct ip_pool *pool = _pool;
45struct ip_pool *ip_pool(
const char *name)
47 struct ip_pool *pool = NULL;
54 pool = calloc(1,
sizeof(*pool));
59 if (pool->addrs == NULL)
62 if (
ec_dict_set(pools, name, pool, __ip_pool_free) < 0)
73struct ip_pool *ip_pool_lookup(
const char *name)
81 struct ec_dict_elt_ref *iter = NULL;
104void ip_pool_free(
const char *name)
106 struct ip_pool *pool;
116int ip_pool_addr_add(
struct ip_pool *pool,
const char *addr)
123 if (
ec_dict_set(pool->addrs, addr, NULL, NULL) < 0)
130int ip_pool_addr_del(
struct ip_pool *pool,
const char *addr)
136struct ec_strvec *ip_pool_addr_list(
const struct ip_pool *pool)
138 struct ec_dict_elt_ref *iter = NULL;
bool ec_dict_has_key(const struct ec_dict *dict, const char *key)
Check if the hash table contains this key.
void ec_dict_free(struct ec_dict *dict)
Free a hash table and all its objects.
struct ec_dict * ec_dict(void)
Create a hash table.
struct ec_dict_elt_ref * ec_dict_iter_next(struct ec_dict_elt_ref *iter)
Make the iterator point to the next element in the hash table.
void * ec_dict_get(const struct ec_dict *dict, const char *key)
Get a value from the hash table.
const char * ec_dict_iter_get_key(const struct ec_dict_elt_ref *iter)
Get a pointer to the key of the current element.
struct ec_dict_elt_ref * ec_dict_iter(const struct ec_dict *dict)
Iterate the elements in the hash table.
int ec_dict_del(struct ec_dict *dict, const char *key)
Delete an object from the hash table.
int ec_dict_set(struct ec_dict *dict, const char *key, void *val, ec_dict_elt_free_t free_cb)
Add/replace an object in the hash table.
void ec_strvec_free(struct ec_strvec *strvec)
Free a string vector.
struct ec_strvec * ec_strvec(void)
Allocate a new empty string vector.
int ec_strvec_add(struct ec_strvec *strvec, const char *s)
Add a string in a vector.