added TNC_TNCS_ReserveAdditionalIMVID() function
[strongswan.git] / src / libcharon / plugins / tnc_imv / tnc_imv_manager.c
index 6e7c253..3231248 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2006 Mike McCauley
- * Copyright (C) 2010 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2010-2011 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -147,8 +148,30 @@ METHOD(imv_manager_t, is_registered, bool,
        enumerator = this->imvs->create_enumerator(this->imvs);
        while (enumerator->enumerate(enumerator, &imv))
        {
-               if (id == imv->get_id(imv))
+               if (imv->has_id(imv, id))
+               {
+                       found = TRUE;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+
+       return found;
+}
+
+METHOD(imv_manager_t, reserve_id, bool,
+       private_tnc_imv_manager_t *this, TNC_IMVID id, TNC_UInt32 *new_id)
+{
+       enumerator_t *enumerator;
+       imv_t *imv;
+       bool found = FALSE;
+
+       enumerator = this->imvs->create_enumerator(this->imvs);
+       while (enumerator->enumerate(enumerator, &imv))
+       {
+               if (imv->get_id(imv))
                {
+                       imv->add_id(imv, this->next_imv_id++);
                        found = TRUE;
                        break;
                }
@@ -384,6 +407,7 @@ imv_manager_t* tnc_imv_manager_create(void)
                        .remove = _remove_, /* avoid name conflict with stdio.h */
                        .load = _load,
                        .is_registered = _is_registered,
+                       .reserve_id = _reserve_id,
                        .get_recommendation_policy = _get_recommendation_policy,
                        .create_recommendations = _create_recommendations,
                        .enforce_recommendation = _enforce_recommendation,