]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
support of reportMessageTypes() function
authorAndreas Steffen <andreas.steffen@strongswan.org>
Sat, 6 Nov 2010 22:01:59 +0000 (23:01 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 9 Nov 2010 19:43:50 +0000 (20:43 +0100)
src/libcharon/plugins/tnc_imc/tnc_imc.c
src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c
src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
src/libcharon/plugins/tnc_imv/tnc_imv.c
src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c
src/libcharon/plugins/tnc_imv/tnc_imv_manager.c
src/libcharon/tnc/imc/imc.h
src/libcharon/tnc/imc/imc_manager.h
src/libcharon/tnc/imv/imv.h
src/libcharon/tnc/imv/imv_manager.h
src/libcharon/tnc/tnccs/tnccs_manager.h

index 13068474a0c4384d3e36639ea56c46bd6caea8a9..f87853bf916f1e2c9112fcd56ad7e38166bbf7ee 100644 (file)
@@ -38,6 +38,16 @@ struct private_tnc_imc_t {
         * ID of loaded IMC
         */
        TNC_IMCID id;
+
+       /**
+        * List of message types supported by IMC
+        */
+       TNC_MessageTypeList supported_types;
+
+       /**
+        * Number of supported message types
+        */
+       TNC_UInt32 type_count;
 };
 
 METHOD(imc_t, set_id, void,
@@ -58,10 +68,27 @@ METHOD(imc_t, get_name, char*,
        return this->name;
 }
 
+METHOD(imc_t, set_message_types, void,
+       private_tnc_imc_t *this, TNC_MessageTypeList supported_types,
+                                                        TNC_UInt32 type_count)
+{
+       free(this->supported_types);
+       this->supported_types = NULL;
+       this->type_count = type_count;
+       if (type_count && supported_types)
+       {
+               size_t size = type_count * sizeof(TNC_MessageType);
+
+               this->supported_types = malloc(size);
+               memcpy(this->supported_types, supported_types, size);
+       }
+}
+
 METHOD(imc_t, destroy, void,
        private_tnc_imc_t *this)
 {
        free(this->name);
+       free(this->supported_types);
        free(this);
 }
 
@@ -78,6 +105,7 @@ imc_t* tnc_imc_create(char* name, char *filename)
                        .set_id = _set_id,
                        .get_id = _get_id,
                        .get_name = _get_name,
+                       .set_message_types = _set_message_types,
                        .destroy = _destroy,
         },
        );
index 6a266f22560ff68b8929cbb34a5efe7e82c88bb2..c8a0875f4c9d618799f226abea41ad3f71f4c0ab 100644 (file)
@@ -27,7 +27,8 @@ TNC_Result TNC_TNCC_ReportMessageTypes(TNC_IMCID imc_id,
                                                                           TNC_UInt32 type_count)
 {
        DBG2(DBG_TNC,"TNCC_ReportMessageTypes %u %u", imc_id, type_count);
-       return TNC_RESULT_SUCCESS;
+       return charon->imcs->set_message_types(charon->imcs, imc_id,
+                                                                                  supported_types, type_count);
 }
 
 /**
index 47b00da702759a1744aeebb206e94baf45377951..e6555cb514386e85c853d9ecb73a3356d781c368 100644 (file)
@@ -101,6 +101,30 @@ METHOD(imc_manager_t, begin_handshake, void,
        enumerator->destroy(enumerator);
 }
 
+METHOD(imc_manager_t, set_message_types, TNC_Result,
+       private_tnc_imc_manager_t *this, TNC_IMCID id,
+                                                                        TNC_MessageTypeList supported_types,
+                                                                        TNC_UInt32 type_count)
+{
+       enumerator_t *enumerator;
+       imc_t *imc;
+       TNC_Result result = TNC_RESULT_FATAL;
+
+       enumerator = this->imcs->create_enumerator(this->imcs);
+       while (enumerator->enumerate(enumerator, &imc))
+       {
+               if (id == imc->get_id(imc))
+               {
+                       imc->set_message_types(imc, supported_types, type_count);
+                       result = TNC_RESULT_SUCCESS;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+       return result;
+}
+
+
 METHOD(imc_manager_t, destroy, void,
        private_tnc_imc_manager_t *this)
 {
@@ -132,6 +156,7 @@ imc_manager_t* tnc_imc_manager_create(void)
                        .add = _add,
                        .notify_connection_change = _notify_connection_change,
                        .begin_handshake = _begin_handshake,
+                       .set_message_types = _set_message_types,
                        .destroy = _destroy,
         },
                .imcs = linked_list_create(),
index 7f59926edcb25183f2660dead1b693b4e03c3976..722f6d946d21ce50a88f1f163ea23af42374dba2 100644 (file)
@@ -38,6 +38,16 @@ struct private_tnc_imv_t {
         * ID of loaded IMV
         */
        TNC_IMVID id;
+
+       /**
+        * List of message types supported by IMC
+        */
+       TNC_MessageTypeList supported_types;
+
+       /**
+        * Number of supported message types
+        */
+       TNC_UInt32 type_count;
 };
 
 METHOD(imv_t, set_id, void,
@@ -58,10 +68,27 @@ METHOD(imv_t, get_name, char*,
        return this->name;
 }
 
+METHOD(imv_t, set_message_types, void,
+       private_tnc_imv_t *this, TNC_MessageTypeList supported_types,
+                                                        TNC_UInt32 type_count)
+{
+       free(this->supported_types);
+       this->supported_types = NULL;
+       this->type_count = type_count;
+       if (type_count && supported_types)
+       {
+               size_t size = type_count * sizeof(TNC_MessageType);
+
+               this->supported_types = malloc(size);
+               memcpy(this->supported_types, supported_types, size);
+       }
+}
+
 METHOD(imv_t, destroy, void,
        private_tnc_imv_t *this)
 {
        free(this->name);
+       free(this->supported_types);
        free(this);
 }
 
@@ -78,6 +105,7 @@ imv_t* tnc_imv_create(char *name, char *filename)
                        .set_id = _set_id,
                        .get_id = _get_id,
                        .get_name = _get_name,
+                       .set_message_types = _set_message_types,
                        .destroy = _destroy,
         },
        );
index 395501abe6df332eee9a163d00573ed67eb4fbc0..48de93c389ce3d38e7d080626c6b1693ee7dd644 100644 (file)
@@ -27,7 +27,8 @@ TNC_Result TNC_TNCS_ReportMessageTypes(TNC_IMVID imv_id,
                                                                           TNC_UInt32 type_count)
 {
        DBG2(DBG_TNC,"TNCS_ReportMessageTypes %u %u", imv_id, type_count);
-       return TNC_RESULT_SUCCESS;
+       return charon->imvs->set_message_types(charon->imvs, imv_id,
+                                                                                  supported_types, type_count);
 }
 
 /**
index 44849c1eacba2f515869395eadfcd921aea4097b..a5309e4622ea9404e85cf27d7cb44a7baa956d95 100644 (file)
@@ -70,7 +70,7 @@ METHOD(imv_manager_t, add, bool,
 
 METHOD(imv_manager_t, notify_connection_change, void,
        private_tnc_imv_manager_t *this, TNC_ConnectionID id,
-       TNC_ConnectionState state)
+                                                                        TNC_ConnectionState state)
 {
        enumerator_t *enumerator;
        imv_t *imv;
@@ -86,6 +86,29 @@ METHOD(imv_manager_t, notify_connection_change, void,
        enumerator->destroy(enumerator);
 }
 
+METHOD(imv_manager_t, set_message_types, TNC_Result,
+       private_tnc_imv_manager_t *this, TNC_IMVID id,
+                                                                        TNC_MessageTypeList supported_types,
+                                                                        TNC_UInt32 type_count)
+{
+       enumerator_t *enumerator;
+       imv_t *imv;
+       TNC_Result result = TNC_RESULT_FATAL;
+
+       enumerator = this->imvs->create_enumerator(this->imvs);
+       while (enumerator->enumerate(enumerator, &imv))
+       {
+               if (id == imv->get_id(imv))
+               {
+                       imv->set_message_types(imv, supported_types, type_count);
+                       result = TNC_RESULT_SUCCESS;
+                       break;
+               }
+       }
+       enumerator->destroy(enumerator);
+       return result;
+}
+
 METHOD(imv_manager_t, destroy, void,
        private_tnc_imv_manager_t *this)
 {
@@ -116,6 +139,7 @@ imv_manager_t* tnc_imv_manager_create(void)
                .public = {
                        .add = _add,
                        .notify_connection_change = _notify_connection_change,
+                       .set_message_types = _set_message_types,
                        .destroy = _destroy,
         },
                .imvs = linked_list_create(),
index bfa15734174ef3c9971c33eac34988d304aef866..2f859e87b6729f14c5b6619e891446e47397733d 100644 (file)
@@ -36,7 +36,7 @@ struct imc_t {
         * @param minVersion            Minimum API version supported by TNCC
         * @param maxVersion            Maximum API version supported by TNCC
         * @param OutActualVersion      Mutually supported API version number
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*initialize)(TNC_IMCID imcID,
                                                         TNC_Version minVersion,
@@ -50,7 +50,7 @@ struct imc_t {
         * @param imcID                         IMC ID assigned by TNCC
         * @param connectionID          Network connection ID assigned by TNCC
         * @param newState                      New network connection state
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*notify_connection_change)(TNC_IMCID imcID,
                                                                                   TNC_ConnectionID connectionID,
@@ -62,7 +62,7 @@ struct imc_t {
         *
         * @param imcID                         IMC ID assigned by TNCC
         * @param connectionID          Network connection ID assigned by TNCC
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*begin_handshake)(TNC_IMCID imcID,
                                                                  TNC_ConnectionID connectionID);
@@ -78,7 +78,7 @@ struct imc_t {
         * @param message                       Reference to buffer containing message
         * @param messageLength         Number of octets in message
         * @param messageType           Message type of message
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*receive_message)(TNC_IMCID imcID,
                                                                  TNC_ConnectionID connectionID,
@@ -93,7 +93,7 @@ struct imc_t {
         *
         * @param imcID                         IMC ID assigned by TNCC
         * @param connectionID          Network connection ID assigned by TNCC
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*batch_ending)(TNC_IMCID imcID,
                                                           TNC_ConnectionID connectionID);
@@ -103,7 +103,7 @@ struct imc_t {
         * complete or the IMC reports TNC_RESULT_FATAL.
         *
         * @param imcID                         IMC ID assigned by TNCC
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*terminate)(TNC_IMCID imcID);
 
@@ -116,7 +116,7 @@ struct imc_t {
         *
         * @param imcID                         IMC ID assigned by TNCC
         * @param bindFunction          Pointer to TNC_TNCC_BindFunction
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*provide_bind_function)(TNC_IMCID imcID,
                                                                                TNC_TNCC_BindFunctionPointer bindFunction);
@@ -131,17 +131,26 @@ struct imc_t {
        /**
         * Returns the ID of an imc_t object.
         *
-        * @result                                      assigned IMC ID
+        * @return                                      assigned IMC ID
         */
        TNC_IMCID (*get_id)(imc_t *this);
 
        /**
         * Returns the name of an imc_t object.
         *
-        * @result                                      name of IMC
+        * @return                                      name of IMC
         */
        char* (*get_name)(imc_t *this);
 
+       /**
+        * Sets the supported message types of an imc_t object.
+        *
+        * @param supported_types       List of messages type supported by IMC
+        * @param type_count            Number of supported message types
+        */
+       void (*set_message_types)(imc_t *this, TNC_MessageTypeList supported_types,
+                                                                                  TNC_UInt32 type_count);
+
        /**
         * Destroys an imc_t object.
         */
index 945a5cf02d8e6666517d2577699d68fb8d6bfb34..9621f05cc6820408f841333029bfee6571b66ed0 100644 (file)
@@ -56,6 +56,19 @@ struct imc_manager_t {
         */
        void (*begin_handshake)(imc_manager_t *this, TNC_ConnectionID id);
 
+       /**
+        * Sets the supported message types reported by a given IMC
+        *
+        * @param id                            ID of reporting IMC
+        * @param supported_types       List of messages type supported by IMC
+        * @param type_count            Number of supported message types
+        * @return                                      TNC result code
+        */
+       TNC_Result (*set_message_types)(imc_manager_t *this,
+                                                                       TNC_IMCID id,
+                                                                       TNC_MessageTypeList supported_types,
+                                                                       TNC_UInt32 type_count);
+
        /**
         * Destroy an IMC manager and all its controlled instances.
         */
index ca07473aed6b78dcf5bd75ed607504879c9ee993..fa8e048fd837f59e7164e9c9efee8463d8f25d1e 100644 (file)
@@ -36,7 +36,7 @@ struct imv_t {
         * @param minVersion            Minimum API version supported
         * @param maxVersion            Maximum API version supported by TNCS
         * @param OutActualVersion      Mutually supported API version number
-        * @result                                      TNC result code
+        * @return                              TNC result code
         */
        TNC_Result (*initialize)(TNC_IMVID imvID,
                                                         TNC_Version minVersion,
@@ -50,7 +50,7 @@ struct imv_t {
         * @param imvID                         IMV ID assigned by TNCS
         * @param connectionID          Network connection ID assigned by TNCS
         * @param newState                      New network connection state
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*notify_connection_change)(TNC_IMVID imvID,
                                                                                   TNC_ConnectionID connectionID,
@@ -63,7 +63,7 @@ struct imv_t {
         *
         * @param imvID                         IMV ID assigned by TNCS
         * @param connectionID          Network connection ID assigned by TNCS
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*solicit_recommendation)(TNC_IMVID imvID,
                                                                                 TNC_ConnectionID connectionID);
@@ -79,7 +79,7 @@ struct imv_t {
         * @param message                       Reference to buffer containing message
         * @param messageLength         Number of octets in message
         * @param messageType           Message type of message
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*receive_message)(TNC_IMVID imvID,
                                                                  TNC_ConnectionID connectionID,
@@ -94,7 +94,7 @@ struct imv_t {
         *
         * @param imvID                         IMV ID assigned by TNCS
         * @param connectionID          Network connection ID assigned by TNCS
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*batch_ending)(TNC_IMVID imvID,
                                                           TNC_ConnectionID connectionID);
@@ -103,7 +103,7 @@ struct imv_t {
         * The TNC Server calls this function to close down the IMV.
         *
         * @param imvID                         IMV ID assigned by TNCS
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*terminate)(TNC_IMVID imvID);
 
@@ -116,7 +116,7 @@ struct imv_t {
         *
         * @param imvID                         IMV ID assigned by TNCS
         * @param bindFunction          Pointer to TNC_TNCS_BindFunction
-        * @result                                      TNC result code
+        * @return                                      TNC result code
         */
        TNC_Result (*provide_bind_function)(TNC_IMVID imvID,
                                                                                TNC_TNCS_BindFunctionPointer bindFunction);
@@ -131,17 +131,26 @@ struct imv_t {
        /**
         * Returns the ID of an imv_t object.
         *
-        * @result                                      IMV ID assigned by TNCS
+        * @return                                      IMV ID assigned by TNCS
         */
        TNC_IMVID (*get_id)(imv_t *this);
 
        /**
         * Returns the name of an imv_t object.
         *
-        * @result                                      name of IMV
+        * @return                                      name of IMV
         */
        char* (*get_name)(imv_t *this);
 
+       /**
+        * Sets the supported message types of an imv_t object.
+        *
+        * @param supported_types       List of messages type supported by IMV
+        * @param type_count            Number of supported message types
+        */
+       void (*set_message_types)(imv_t *this, TNC_MessageTypeList supported_types,
+                                                                                  TNC_UInt32 type_count);
+
        /**
         * Destroys an imv_t object.
         */
index b532275c33a508bed585b8a1304563b8244286b3..4d985552f7c08b7c26d7990c11d7a137bf627fa0 100644 (file)
@@ -48,6 +48,20 @@ struct imv_manager_t {
        void (*notify_connection_change)(imv_manager_t *this,
                                                                         TNC_ConnectionID id,
                                                                         TNC_ConnectionState state);
+
+       /**
+        * Sets the supported message types reported by a given IMV
+        *
+        * @param id                            ID of reporting IMV
+        * @param supported_types       List of messages type supported by IMV
+        * @param type_count            Number of supported message types
+        * @return                                      TNC result code
+        */
+       TNC_Result (*set_message_types)(imv_manager_t *this,
+                                                                       TNC_IMVID id,
+                                                                       TNC_MessageTypeList supported_types,
+                                                                       TNC_UInt32 type_count);
+
        /**
         * Destroy an IMV manager and all its controlled instances.
         */
index 127147e26c5113b0bd506e9e297fcb92dc9ce0e0..b061e859e84bb23b3709da8a23ef3f980c146164 100644 (file)
@@ -66,7 +66,7 @@ struct tnccs_manager_t {
         *
         * @param tnccs                 TNCCS connection instance
         * @param send_message  callback function adding a message to a TNCCS batch
-        * @result                              assigned connection ID
+        * @return                              assigned connection ID
         */
        TNC_ConnectionID (*create_connection)(tnccs_manager_t *this, tnccs_t *tnccs,
                                                                                  tnccs_send_message_t send_message);
@@ -85,7 +85,7 @@ struct tnccs_manager_t {
         * @param message               message to be added
         * @param message_len   message length
         * @param message_type  message type
-        * @result                              return code
+        * @return                              return code
         */
        TNC_Result (*send_message)(tnccs_manager_t *this, TNC_ConnectionID id,
                                                                                                TNC_BufferReference message,