aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-11-08 15:53:50 +0100
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-11-09 20:43:51 +0100
commit1dc7b22c537115e85de4683f83970146b10b9242 (patch)
treea8290b714ab6c2a260f8f3ef7de925865787b348 /src
parentbcd386a95fda77ad3c07be41896155d6c8ebec74 (diff)
downloadstrongswan-1dc7b22c537115e85de4683f83970146b10b9242.tar.bz2
strongswan-1dc7b22c537115e85de4683f83970146b10b9242.tar.xz
added imc/imv_manager remove method
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/plugins/tnc_imc/tnc_imc_manager.c20
-rw-r--r--src/libcharon/plugins/tnc_imv/tnc_imv_manager.c20
-rw-r--r--src/libcharon/tnc/imc/imc_manager.h8
-rw-r--r--src/libcharon/tnc/imv/imv_manager.h8
4 files changed, 56 insertions, 0 deletions
diff --git a/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c b/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
index da10274f1..bc1147ad8 100644
--- a/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
+++ b/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
@@ -67,12 +67,31 @@ METHOD(imc_manager_t, add, bool,
{
DBG1(DBG_TNC, "could not provide bind function for IMC '%s'",
imc->get_name(imc));
+ this->imcs->remove_last(this->imcs, (void**)&imc);
return FALSE;
}
return TRUE;
}
+METHOD(imc_manager_t, remove_, imc_t*,
+ private_tnc_imc_manager_t *this, TNC_IMCID id)
+{
+ enumerator_t *enumerator;
+ imc_t *imc;
+
+ enumerator = this->imcs->create_enumerator(this->imcs);
+ while (enumerator->enumerate(enumerator, &imc))
+ {
+ if (id == imc->get_id(imc))
+ {
+ this->imcs->remove_at(this->imcs, enumerator);
+ return imc;
+ }
+ }
+ enumerator->destroy(enumerator);
+}
+
METHOD(imc_manager_t, notify_connection_change, void,
private_tnc_imc_manager_t *this, TNC_ConnectionID id,
TNC_ConnectionState state)
@@ -178,6 +197,7 @@ imc_manager_t* tnc_imc_manager_create(void)
INIT(this,
.public = {
.add = _add,
+ .remove = _remove_, /* avoid name conflict with stdio.h */
.notify_connection_change = _notify_connection_change,
.begin_handshake = _begin_handshake,
.set_message_types = _set_message_types,
diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c b/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c
index 4beaccc07..667f1e322 100644
--- a/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c
+++ b/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c
@@ -67,11 +67,30 @@ METHOD(imv_manager_t, add, bool,
{
DBG1(DBG_TNC, "could not provide bind function for IMV '%s'",
imv->get_name(imv));
+ this->imvs->remove_last(this->imvs, (void**)&imv);
return FALSE;
}
return TRUE;
}
+METHOD(imv_manager_t, remove_, imv_t*,
+ private_tnc_imv_manager_t *this, TNC_IMVID id)
+{
+ enumerator_t *enumerator;
+ imv_t *imv;
+
+ enumerator = this->imvs->create_enumerator(this->imvs);
+ while (enumerator->enumerate(enumerator, &imv))
+ {
+ if (id == imv->get_id(imv))
+ {
+ this->imvs->remove_at(this->imvs, enumerator);
+ return imv;
+ }
+ }
+ enumerator->destroy(enumerator);
+}
+
METHOD(imv_manager_t, notify_connection_change, void,
private_tnc_imv_manager_t *this, TNC_ConnectionID id,
TNC_ConnectionState state)
@@ -163,6 +182,7 @@ imv_manager_t* tnc_imv_manager_create(void)
INIT(this,
.public = {
.add = _add,
+ .remove = _remove_, /* avoid name conflict with stdio.h */
.notify_connection_change = _notify_connection_change,
.set_message_types = _set_message_types,
.receive_message = _receive_message,
diff --git a/src/libcharon/tnc/imc/imc_manager.h b/src/libcharon/tnc/imc/imc_manager.h
index 60bfe3499..169259f72 100644
--- a/src/libcharon/tnc/imc/imc_manager.h
+++ b/src/libcharon/tnc/imc/imc_manager.h
@@ -41,6 +41,14 @@ struct imc_manager_t {
bool (*add)(imc_manager_t *this, imc_t *imc);
/**
+ * Remove an IMC instance from the list and return it
+ *
+ * @param id ID of IMC instance
+ * @return removed IMC instance
+ */
+ imc_t* (*remove)(imc_manager_t *this, TNC_IMCID id);
+
+ /**
* Notify all IMC instances
*
* @param state communicate the state a connection has reached
diff --git a/src/libcharon/tnc/imv/imv_manager.h b/src/libcharon/tnc/imv/imv_manager.h
index c93f572fc..56cb6a0f8 100644
--- a/src/libcharon/tnc/imv/imv_manager.h
+++ b/src/libcharon/tnc/imv/imv_manager.h
@@ -41,6 +41,14 @@ struct imv_manager_t {
bool (*add)(imv_manager_t *this, imv_t *imv);
/**
+ * Remove an IMV instance from the list and return it
+ *
+ * @param id ID of IMV instance
+ * @return removed IMC instance
+ */
+ void (*remove)(imv_manager_t *this, TNC_IMVID id);
+
+ /**
* Notify all IMV instances
*
* @param state communicate the state a connection has reached