diff options
author | Martin Willi <martin@revosec.ch> | 2012-09-11 10:41:11 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2012-09-11 16:18:28 +0200 |
commit | 594c58e1118e496eadd284647755b16b74665337 (patch) | |
tree | 743e0f33a01beffab57e363fe1e154944c63dd01 /src/libcharon/plugins/dhcp | |
parent | dc7b79d8a5c8104001bba4c52a8b3716a0cf6d88 (diff) | |
download | strongswan-594c58e1118e496eadd284647755b16b74665337.tar.bz2 strongswan-594c58e1118e496eadd284647755b16b74665337.tar.xz |
Pass the full list of pools to acquire_address, enumerate in providers
If the provider has access to the full pool list, it can enumerate
them twice, for example to search for existing leases first, and
only search for new leases in a second step.
Fixes lease enumeration in attr-sql using multiple pools.
Diffstat (limited to 'src/libcharon/plugins/dhcp')
-rw-r--r-- | src/libcharon/plugins/dhcp/dhcp_provider.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/libcharon/plugins/dhcp/dhcp_provider.c b/src/libcharon/plugins/dhcp/dhcp_provider.c index e46cc4d90..eaaad45d1 100644 --- a/src/libcharon/plugins/dhcp/dhcp_provider.c +++ b/src/libcharon/plugins/dhcp/dhcp_provider.c @@ -81,18 +81,29 @@ static uintptr_t hash_transaction(dhcp_transaction_t *transaction) } METHOD(attribute_provider_t, acquire_address, host_t*, - private_dhcp_provider_t *this, char *pool, + private_dhcp_provider_t *this, linked_list_t *pools, identification_t *id, host_t *requested) { - if (streq(pool, "dhcp") && requested->get_family(requested) == AF_INET) - { - dhcp_transaction_t *transaction, *old; - host_t *vip; + dhcp_transaction_t *transaction, *old; + enumerator_t *enumerator; + char *pool; + host_t *vip = NULL; + if (requested->get_family(requested) != AF_INET) + { + return NULL; + } + enumerator = pools->create_enumerator(pools); + while (enumerator->enumerate(enumerator, &pool)) + { + if (!streq(pool, "dhcp")) + { + continue; + } transaction = this->socket->enroll(this->socket, id); if (!transaction) { - return NULL; + continue; } vip = transaction->get_address(transaction); vip = vip->clone(vip); @@ -101,9 +112,10 @@ METHOD(attribute_provider_t, acquire_address, host_t*, (void*)hash_transaction(transaction), transaction); this->mutex->unlock(this->mutex); DESTROY_IF(old); - return vip; + break; } - return NULL; + enumerator->destroy(enumerator); + return vip; } METHOD(attribute_provider_t, release_address, bool, |