refactored tnccs->remove_connection()
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 6 May 2011 13:13:05 +0000 (15:13 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 6 May 2011 13:13:05 +0000 (15:13 +0200)
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libcharon/tnc/tnccs/tnccs_manager.c
src/libcharon/tnc/tnccs/tnccs_manager.h

index 9d8f00e..edacb97 100644 (file)
@@ -454,17 +454,8 @@ METHOD(tls_t, get_eap_msk, chunk_t,
 METHOD(tls_t, destroy, void,
        private_tnccs_11_t *this)
 {
-       if (this->is_server)
-       {
-               charon->imvs->notify_connection_change(charon->imvs,
-                                                       this->connection_id, TNC_CONNECTION_STATE_DELETE);
-       }
-       else
-       {
-               charon->imcs->notify_connection_change(charon->imcs,
-                                                       this->connection_id, TNC_CONNECTION_STATE_DELETE);
-       }
-       charon->tnccs->remove_connection(charon->tnccs, this->connection_id);
+       charon->tnccs->remove_connection(charon->tnccs, this->connection_id
+                                                                                                       this->is_server);
        this->mutex->destroy(this->mutex);
        DESTROY_IF(this->batch);
        free(this);
index 38ed3aa..0bf2419 100644 (file)
@@ -625,17 +625,8 @@ METHOD(tls_t, get_eap_msk, chunk_t,
 METHOD(tls_t, destroy, void,
        private_tnccs_20_t *this)
 {
-       if (this->is_server)
-       {
-               charon->imvs->notify_connection_change(charon->imvs,
-                                                       this->connection_id, TNC_CONNECTION_STATE_DELETE);
-       }
-       else
-       {
-               charon->imcs->notify_connection_change(charon->imcs,
-                                                       this->connection_id, TNC_CONNECTION_STATE_DELETE);
-       }
-       charon->tnccs->remove_connection(charon->tnccs, this->connection_id);
+       charon->tnccs->remove_connection(charon->tnccs, this->connection_id,
+                                                                                                       this->is_server);
        this->state_machine->destroy(this->state_machine);
        this->mutex->destroy(this->mutex);
        DESTROY_IF(this->batch);
index abe4c65..2444855 100644 (file)
@@ -215,11 +215,28 @@ METHOD(tnccs_manager_t, create_connection, TNC_ConnectionID,
 }
 
 METHOD(tnccs_manager_t, remove_connection, void,
-       private_tnccs_manager_t *this, TNC_ConnectionID id)
+       private_tnccs_manager_t *this, TNC_ConnectionID id, bool is_server)
 {
        enumerator_t *enumerator;
        tnccs_connection_entry_t *entry;
 
+       if (is_server)
+       {
+               if (charon->imvs)
+               {
+                       charon->imvs->notify_connection_change(charon->imvs, id,
+                                                                               TNC_CONNECTION_STATE_DELETE);
+               }
+       }
+       else
+       {
+               if (charon->imcs)
+               {
+                       charon->imcs->notify_connection_change(charon->imcs, id,
+                                                                               TNC_CONNECTION_STATE_DELETE);
+               }
+       }
+
        this->connection_lock->write_lock(this->connection_lock);
        enumerator = this->connections->create_enumerator(this->connections);
        while (enumerator->enumerate(enumerator, &entry))
index c02eac0..34f6002 100644 (file)
@@ -82,8 +82,10 @@ struct tnccs_manager_t {
         * Remove a TNCCS connection using its connection ID.
         *
         * @param id                            ID of the connection to be removed
+        * @param is_server                     TNC Server if TRUE, TNC Client if FALSE
         */
-       void (*remove_connection)(tnccs_manager_t *this, TNC_ConnectionID id);
+       void (*remove_connection)(tnccs_manager_t *this, TNC_ConnectionID id,
+                                                         bool is_server);
 
        /**
         * Request a handshake retry