aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/sql/sql_attribute.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-07-02 08:31:48 +0000
committerMartin Willi <martin@strongswan.org>2008-07-02 08:31:48 +0000
commitd932435e188a97d4b1ff0d4606a3420218f2d8c2 (patch)
tree8452f07903e71dbc73027c32552542b4cbf59518 /src/charon/plugins/sql/sql_attribute.c
parent11e855179e94c1cbc6580c19d499e9aaca0d48cf (diff)
downloadstrongswan-d932435e188a97d4b1ff0d4606a3420218f2d8c2.tar.bz2
strongswan-d932435e188a97d4b1ff0d4606a3420218f2d8c2.tar.xz
sql plugin supports a list of pools to fall back, specified by e.g. rightsourceip=%pool1,pool2
Diffstat (limited to 'src/charon/plugins/sql/sql_attribute.c')
-rw-r--r--src/charon/plugins/sql/sql_attribute.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/charon/plugins/sql/sql_attribute.c b/src/charon/plugins/sql/sql_attribute.c
index 15a886971..847042792 100644
--- a/src/charon/plugins/sql/sql_attribute.c
+++ b/src/charon/plugins/sql/sql_attribute.c
@@ -226,13 +226,24 @@ static host_t* acquire_address(private_sql_attribute_t *this,
char *name, identification_t *id,
auth_info_t *auth, host_t *requested)
{
- host_t *ip;
+ enumerator_t *enumerator;
+ host_t *ip = NULL;
- ip = get_lease(this, name, id);
- if (!ip)
+ enumerator = enumerator_create_token(name, ",", " ");
+ while (enumerator->enumerate(enumerator, &name))
{
+ ip = get_lease(this, name, id);
+ if (ip)
+ {
+ break;
+ }
ip = create_lease(this, name, id);
+ if (ip)
+ {
+ break;
+ }
}
+ enumerator->destroy(enumerator);
return ip;
}
@@ -242,15 +253,23 @@ static host_t* acquire_address(private_sql_attribute_t *this,
static bool release_address(private_sql_attribute_t *this,
char *name, host_t *address)
{
- if (this->db->execute(this->db, NULL,
- "UPDATE leases SET released = ? WHERE "
- "pool IN (SELECT id FROM pools WHERE name = ?) AND "
- "address = ? AND released IS NULL",
- DB_UINT, time(NULL),
- DB_TEXT, name, DB_BLOB, address->get_address(address)) > 0)
+ enumerator_t *enumerator;
+
+ enumerator = enumerator_create_token(name, ",", " ");
+ while (enumerator->enumerate(enumerator, &name))
{
- return TRUE;
+ if (this->db->execute(this->db, NULL,
+ "UPDATE leases SET released = ? WHERE "
+ "pool IN (SELECT id FROM pools WHERE name = ?) AND "
+ "address = ? AND released IS NULL",
+ DB_UINT, time(NULL),
+ DB_TEXT, name, DB_BLOB, address->get_address(address)) > 0)
+ {
+ enumerator->destroy(enumerator);
+ return TRUE;
+ }
}
+ enumerator->destroy(enumerator);
return FALSE;
}