aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-08-12 12:46:39 +0200
committerHarald Welte <laforge@gnumonks.org>2017-08-12 18:23:25 +0200
commitb7829076cd8371005f2f864ffd59dc9dc0db58a0 (patch)
tree6eedf8489e14b4e6d039f7e5dd8fb67431e74b15
parenteca48374c0e4b6eccb3edd149f6e78fd5ad95bab (diff)
lib/ippool: Add back-pointer from pool member to pool
This allows us to remove pool members without having to keep a pointer to the pool around. Change-Id: I9042eb85989c5451d7894678eca110dd19e78002
-rw-r--r--lib/ippool.c2
-rw-r--r--lib/ippool.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/ippool.c b/lib/ippool.c
index 1729ec7..b1b242d 100644
--- a/lib/ippool.c
+++ b/lib/ippool.c
@@ -295,6 +295,7 @@ int ippool_new(struct ippool_t **this, const char *dyn, const char *stat,
in46a_inc(&addr);
(*this)->member[i].inuse = 0;
+ (*this)->member[i].pool = *this;
/* Insert into list of unused */
(*this)->member[i].prev = (*this)->lastdyn;
@@ -315,6 +316,7 @@ int ippool_new(struct ippool_t **this, const char *dyn, const char *stat,
struct in46_addr *i6al = &(*this)->member[i].addr;
memset(i6al, 0, sizeof(*i6al));
(*this)->member[i].inuse = 0;
+ (*this)->member[i].pool = *this;
/* Insert into list of unused */
(*this)->member[i].prev = (*this)->laststat;
diff --git a/lib/ippool.h b/lib/ippool.h
index ba92a56..8249b7f 100644
--- a/lib/ippool.h
+++ b/lib/ippool.h
@@ -56,6 +56,7 @@ struct ippool_t {
struct ippoolm_t {
struct in46_addr addr; /* IP address of this member */
+ struct ippool_t *pool; /* Pool to which we belong */
int inuse; /* 0=available; 1= dynamic; 2 = static */
struct ippoolm_t *nexthash; /* Linked list part of hash table */
struct ippoolm_t *prev, *next; /* Linked list of free dynamic or static */