From: Andreas Steffen Date: Sat, 6 Nov 2010 22:01:59 +0000 (+0100) Subject: support of reportMessageTypes() function X-Git-Tag: 4.5.1~555 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=296636252b514846bd3ec83fbeff6fe40c301745;p=thirdparty%2Fstrongswan.git support of reportMessageTypes() function --- diff --git a/src/libcharon/plugins/tnc_imc/tnc_imc.c b/src/libcharon/plugins/tnc_imc/tnc_imc.c index 13068474a0..f87853bf91 100644 --- a/src/libcharon/plugins/tnc_imc/tnc_imc.c +++ b/src/libcharon/plugins/tnc_imc/tnc_imc.c @@ -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, }, ); diff --git a/src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c b/src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c index 6a266f2256..c8a0875f4c 100644 --- a/src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c +++ b/src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c @@ -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); } /** diff --git a/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c b/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c index 47b00da702..e6555cb514 100644 --- a/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c +++ b/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c @@ -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(), diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv.c b/src/libcharon/plugins/tnc_imv/tnc_imv.c index 7f59926edc..722f6d946d 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv.c @@ -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, }, ); diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c b/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c index 395501abe6..48de93c389 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c @@ -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); } /** diff --git a/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c b/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c index 44849c1eac..a5309e4622 100644 --- a/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c +++ b/src/libcharon/plugins/tnc_imv/tnc_imv_manager.c @@ -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(), diff --git a/src/libcharon/tnc/imc/imc.h b/src/libcharon/tnc/imc/imc.h index bfa1573417..2f859e87b6 100644 --- a/src/libcharon/tnc/imc/imc.h +++ b/src/libcharon/tnc/imc/imc.h @@ -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. */ diff --git a/src/libcharon/tnc/imc/imc_manager.h b/src/libcharon/tnc/imc/imc_manager.h index 945a5cf02d..9621f05cc6 100644 --- a/src/libcharon/tnc/imc/imc_manager.h +++ b/src/libcharon/tnc/imc/imc_manager.h @@ -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. */ diff --git a/src/libcharon/tnc/imv/imv.h b/src/libcharon/tnc/imv/imv.h index ca07473aed..fa8e048fd8 100644 --- a/src/libcharon/tnc/imv/imv.h +++ b/src/libcharon/tnc/imv/imv.h @@ -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. */ diff --git a/src/libcharon/tnc/imv/imv_manager.h b/src/libcharon/tnc/imv/imv_manager.h index b532275c33..4d985552f7 100644 --- a/src/libcharon/tnc/imv/imv_manager.h +++ b/src/libcharon/tnc/imv/imv_manager.h @@ -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. */ diff --git a/src/libcharon/tnc/tnccs/tnccs_manager.h b/src/libcharon/tnc/tnccs/tnccs_manager.h index 127147e26c..b061e859e8 100644 --- a/src/libcharon/tnc/tnccs/tnccs_manager.h +++ b/src/libcharon/tnc/tnccs/tnccs_manager.h @@ -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,