implemented batch_ending() and solicit_recommendation() functions
authorAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 8 Nov 2010 22:13:40 +0000 (23:13 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 9 Nov 2010 19:43:51 +0000 (20:43 +0100)
src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
src/libcharon/plugins/tnc_imv/tnc_imv_manager.c
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libcharon/tnc/imc/imc_manager.h
src/libcharon/tnc/imv/imv_manager.h

index 4f7bd7d..d78c92a 100644 (file)
@@ -175,6 +175,23 @@ METHOD(imc_manager_t, receive_message, void,
        enumerator->destroy(enumerator);
 }
 
+METHOD(imc_manager_t, batch_ending, void,
+       private_tnc_imc_manager_t *this, TNC_ConnectionID id)
+{
+       enumerator_t *enumerator;
+       imc_t *imc;
+
+       enumerator = this->imcs->create_enumerator(this->imcs);
+       while (enumerator->enumerate(enumerator, &imc))
+       {
+               if (imc->batch_ending)
+               {
+                       imc->batch_ending(imc->get_id(imc), id);
+               }
+       }
+       enumerator->destroy(enumerator);
+}
+
 METHOD(imc_manager_t, destroy, void,
        private_tnc_imc_manager_t *this)
 {
@@ -210,6 +227,7 @@ imc_manager_t* tnc_imc_manager_create(void)
                        .begin_handshake = _begin_handshake,
                        .set_message_types = _set_message_types,
                        .receive_message = _receive_message,
+                       .batch_ending = _batch_ending,
                        .destroy = _destroy,
         },
                .imcs = linked_list_create(),
index d46b1f3..9e4bc50 100644 (file)
@@ -140,6 +140,20 @@ METHOD(imv_manager_t, set_message_types, TNC_Result,
        return result;
 }
 
+METHOD(imv_manager_t, solicit_recommendation, void,
+       private_tnc_imv_manager_t *this, TNC_ConnectionID id)
+{
+       enumerator_t *enumerator;
+       imv_t *imv;
+
+       enumerator = this->imvs->create_enumerator(this->imvs);
+       while (enumerator->enumerate(enumerator, &imv))
+       {
+               imv->solicit_recommendation(imv->get_id(imv), id);
+       }
+       enumerator->destroy(enumerator);
+}
+
 METHOD(imv_manager_t, receive_message, void,
        private_tnc_imv_manager_t *this, TNC_ConnectionID connection_id,
                                                                         TNC_BufferReference message,
@@ -161,6 +175,23 @@ METHOD(imv_manager_t, receive_message, void,
        enumerator->destroy(enumerator);
 }
 
+METHOD(imv_manager_t, batch_ending, void,
+       private_tnc_imv_manager_t *this, TNC_ConnectionID id)
+{
+       enumerator_t *enumerator;
+       imv_t *imv;
+
+       enumerator = this->imvs->create_enumerator(this->imvs);
+       while (enumerator->enumerate(enumerator, &imv))
+       {
+               if (imv->batch_ending)
+               {
+                       imv->batch_ending(imv->get_id(imv), id);
+               }
+       }
+       enumerator->destroy(enumerator);
+}
+
 METHOD(imv_manager_t, destroy, void,
        private_tnc_imv_manager_t *this)
 {
@@ -194,7 +225,9 @@ imv_manager_t* tnc_imv_manager_create(void)
                        .get_count = _get_count,
                        .notify_connection_change = _notify_connection_change,
                        .set_message_types = _set_message_types,
+                       .solicit_recommendation = _solicit_recommendation,
                        .receive_message = _receive_message,
+                       .batch_ending = _batch_ending,
                        .destroy = _destroy,
         },
                .imvs = linked_list_create(),
index 1287109..04bf2a2 100644 (file)
@@ -100,11 +100,13 @@ METHOD(tls_t, process, status_t,
        {
                charon->imvs->receive_message(charon->imvs, this->connection_id,
                                                                          pos, len, 0x0080ab31);
+               charon->imvs->batch_ending(charon->imvs, this->connection_id);
        }
        else
        {
                charon->imcs->receive_message(charon->imcs, this->connection_id,
                                                                          pos, len, 0x0080ab31);
+               charon->imcs->batch_ending(charon->imcs, this->connection_id);
        }
        return NEED_MORE;
 }
index 7ce54da..4019937 100644 (file)
@@ -67,7 +67,7 @@ struct imc_manager_t {
        /**
         * Begin a handshake between the IMCs and a connection
         *
-        * @param id                            Connection ID
+        * @param id                            connection ID
         */
        void (*begin_handshake)(imc_manager_t *this, TNC_ConnectionID id);
 
@@ -99,6 +99,15 @@ struct imc_manager_t {
                                                        TNC_MessageType message_type);
 
        /**
+        * Notify all IMCs that all IMV messages received in a batch have been
+        * delivered and this is the IMCs last chance to send a message in the
+        * batch of IMC messages currently being collected.
+        *
+        * @param id                            connection ID
+        */
+       void (*batch_ending)(imc_manager_t *this, TNC_ConnectionID id);
+
+       /**
         * Destroy an IMC manager and all its controlled instances.
         */
        void (*destroy)(imc_manager_t *this);
index fca8d1b..1482361 100644 (file)
@@ -78,6 +78,13 @@ struct imv_manager_t {
                                                                        TNC_UInt32 type_count);
 
        /**
+        * Solicit recommendations from IMVs that have not yet provided one
+        *
+        * @param id                            connection ID
+        */
+       void (*solicit_recommendation)(imv_manager_t *this, TNC_ConnectionID id);
+
+       /**
         * Delivers a message to interested IMVs.
         *
         * @param connection_id         ID of connection over which message was received
@@ -92,6 +99,15 @@ struct imv_manager_t {
                                                        TNC_MessageType message_type);
 
        /**
+        * Notify all IMVs that all IMC messages received in a batch have been
+        * delivered and this is the IMVs last chance to send a message in the
+        * batch of IMV messages currently being collected.
+        *
+        * @param id                            connection ID
+        */
+       void (*batch_ending)(imv_manager_t *this, TNC_ConnectionID id);
+
+       /**
         * Destroy an IMV manager and all its controlled instances.
         */
        void (*destroy)(imv_manager_t *this);