From: Andreas Steffen Date: Wed, 29 May 2013 22:06:12 +0000 (+0200) Subject: Defined a generic IMV agent interface X-Git-Tag: 5.1.0dr1~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97f0a7ea77993d13c4c7451ca9ed02d3209019b5;p=thirdparty%2Fstrongswan.git Defined a generic IMV agent interface --- diff --git a/src/libimcv/Makefile.am b/src/libimcv/Makefile.am index 44e812c924..cf257c04bf 100644 --- a/src/libimcv/Makefile.am +++ b/src/libimcv/Makefile.am @@ -9,7 +9,7 @@ libimcv_la_SOURCES = \ imcv.h imcv.c \ imc/imc_agent.h imc/imc_agent.c imc/imc_state.h \ imc/imc_msg.h imc/imc_msg.c \ - imv/imv_agent.h imv/imv_agent.c imv/imv_state.h \ + imv/imv_agent.h imv/imv_agent.c imv/imv_agent_if.h imv/imv_state.h \ imv/imv_database.h imv/imv_database.c \ imv/imv_msg.h imv/imv_msg.c \ imv/imv_lang_string.h imv/imv_lang_string.c \ diff --git a/src/libimcv/imv/imv_agent_if.h b/src/libimcv/imv/imv_agent_if.h new file mode 100644 index 0000000000..175cf6880c --- /dev/null +++ b/src/libimcv/imv/imv_agent_if.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2013 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 + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup imv_agent_if_t imv_agent_if + * @{ @ingroup imv_os + */ + +#ifndef IMV_AGENT_IF_H_ +#define IMV_AGENT_IF_H_ + +#include + +#include + +typedef struct imv_agent_if_t imv_agent_if_t; + +/** + * IF-IMV interface for IMV agents + */ +struct imv_agent_if_t { + + /** + * Implements the TNC_IMV_ProvideBindFunction function of the IMV + * + * @param bind_function Function offered by the TNCS + * @return TNC result code + */ + TNC_Result (*bind_functions)(imv_agent_if_t *this, + TNC_TNCS_BindFunctionPointer bind_function); + + /** + * Implements the TNC_IMV_NotifyConnectionChange() function of the IMV + * + * @param id Network connection ID assigned by TNCS + * @param new_state New connection state to be set + * @return TNC result code + */ + TNC_Result (*notify_connection_change)(imv_agent_if_t *this, + TNC_ConnectionID id, + TNC_ConnectionState new_state); + + /** + * Implements the TNC_IMV_ReceiveMessage() function of the IMV + * + * @param id Network connection ID assigned by TNCS + * @param msg_type PA-TNC message type + * @param msg Received message + * @return TNC result code + */ + TNC_Result (*receive_message)(imv_agent_if_t *this, TNC_ConnectionID id, + TNC_MessageType msg_type, chunk_t msg); + + /** + * Implements the TNC_IMV_ReceiveMessageLong() function of the IMV + * + * @param id Network connection ID assigned by TNCS + * @param src_imc_id ID of source IMC + * @param dst_imv_id ID of destination IMV + * @param msg_vid Vendor ID of message type + * @param msg_subtype PA-TNC message subtype + * @param msg Received message + * @return TNC result code + */ + TNC_Result (*receive_message_long)(imv_agent_if_t *this, + TNC_ConnectionID id, + TNC_UInt32 src_imc_id, + TNC_UInt32 dst_imv_id, + TNC_VendorID msg_vid, + TNC_MessageSubtype msg_subtype, + chunk_t msg); + + /** + * Implements the TNC_IMV_BatchEnding() function of the IMV + * + * @param id Network connection ID assigned by TNCS + * @return TNC result code + */ + TNC_Result (*batch_ending)(imv_agent_if_t *this, TNC_ConnectionID id); + + /** + * Implements the TNC_IMV_SolicitRecommendation() function of the IMV + * + * @param id Network connection ID assigned by TNCS + * @return TNC result code + */ + TNC_Result (*solicit_recommendation)(imv_agent_if_t *this, + TNC_ConnectionID id); + + /** + * Destroys an imv_agent_if_t object + */ + void (*destroy)(imv_agent_if_t *this); + +}; + +/** + * Creates the an IMV agent + * + * @param name Name of the IMV + * @param id ID of the IMV + * @param actual_version TNC IF-IMV version + */ +imv_agent_if_t* imv_agent_if_create(const char* name, TNC_IMVID id, + TNC_Version *actual_version); + +#endif /** IMV_AGENT_IF_H_ @}*/ diff --git a/src/libimcv/plugins/imv_os/imv_os.c b/src/libimcv/plugins/imv_os/imv_os.c index 3caa9c40c7..ad80976e44 100644 --- a/src/libimcv/plugins/imv_os/imv_os.c +++ b/src/libimcv/plugins/imv_os/imv_os.c @@ -21,7 +21,7 @@ static const char imv_name[] = "OS"; -static imv_os_agent_t *imv_agent; +static imv_agent_if_t *imv_agent; /* * see section 3.8.1 of TCG TNC IF-IMV Specification 1.3 @@ -37,7 +37,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id, return TNC_RESULT_ALREADY_INITIALIZED; } - imv_agent =imv_os_agent_create(imv_name, imv_id, actual_version); + imv_agent = imv_os_agent_create(imv_name, imv_id, actual_version); if (!imv_agent) { diff --git a/src/libimcv/plugins/imv_os/imv_os_agent.c b/src/libimcv/plugins/imv_os/imv_os_agent.c index 9fc6110c31..17c0585f10 100644 --- a/src/libimcv/plugins/imv_os/imv_os_agent.c +++ b/src/libimcv/plugins/imv_os/imv_os_agent.c @@ -80,7 +80,7 @@ struct private_imv_os_agent_t { /** * Public members of imv_os_agent_t */ - imv_os_agent_t public; + imv_agent_if_t public; /** * IMV agent responsible for generic functions @@ -94,13 +94,13 @@ struct private_imv_os_agent_t { }; -METHOD(imv_os_agent_t, bind_functions, TNC_Result, +METHOD(imv_agent_if_t, bind_functions, TNC_Result, private_imv_os_agent_t *this, TNC_TNCS_BindFunctionPointer bind_function) { return this->agent->bind_functions(this->agent, bind_function); } -METHOD(imv_os_agent_t, notify_connection_change, TNC_Result, +METHOD(imv_agent_if_t, notify_connection_change, TNC_Result, private_imv_os_agent_t *this, TNC_ConnectionID id, TNC_ConnectionState new_state) { @@ -420,7 +420,7 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state, return result; } -METHOD(imv_os_agent_t, receive_message, TNC_Result, +METHOD(imv_agent_if_t, receive_message, TNC_Result, private_imv_os_agent_t *this, TNC_ConnectionID id, TNC_MessageType msg_type, chunk_t msg) { @@ -439,7 +439,7 @@ METHOD(imv_os_agent_t, receive_message, TNC_Result, return result; } -METHOD(imv_os_agent_t, receive_message_long, TNC_Result, +METHOD(imv_agent_if_t, receive_message_long, TNC_Result, private_imv_os_agent_t *this, TNC_ConnectionID id, TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id, TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype, chunk_t msg) @@ -503,7 +503,7 @@ static pa_tnc_attr_t* build_attr_request(u_int received) return attr; } -METHOD(imv_os_agent_t, batch_ending, TNC_Result, +METHOD(imv_agent_if_t, batch_ending, TNC_Result, private_imv_os_agent_t *this, TNC_ConnectionID id) { imv_msg_t *out_msg; @@ -747,7 +747,7 @@ METHOD(imv_os_agent_t, batch_ending, TNC_Result, return result; } -METHOD(imv_os_agent_t, solicit_recommendation, TNC_Result, +METHOD(imv_agent_if_t, solicit_recommendation, TNC_Result, private_imv_os_agent_t *this, TNC_ConnectionID id) { imv_state_t *state; @@ -759,7 +759,7 @@ METHOD(imv_os_agent_t, solicit_recommendation, TNC_Result, return this->agent->provide_recommendation(this->agent, state); } -METHOD(imv_os_agent_t, destroy, void, +METHOD(imv_agent_if_t, destroy, void, private_imv_os_agent_t *this) { DESTROY_IF(this->agent); @@ -770,7 +770,7 @@ METHOD(imv_os_agent_t, destroy, void, /** * Described in header. */ -imv_os_agent_t *imv_os_agent_create(const char *name, TNC_IMVID id, +imv_agent_if_t *imv_os_agent_create(const char *name, TNC_IMVID id, TNC_Version *actual_version) { private_imv_os_agent_t *this; diff --git a/src/libimcv/plugins/imv_os/imv_os_agent.h b/src/libimcv/plugins/imv_os/imv_os_agent.h index 401695484f..cec1b1f209 100644 --- a/src/libimcv/plugins/imv_os/imv_os_agent.h +++ b/src/libimcv/plugins/imv_os/imv_os_agent.h @@ -21,100 +21,16 @@ #ifndef IMV_OS_AGENT_H_ #define IMV_OS_AGENT_H_ -#include -#include - -#include - -typedef struct imv_os_agent_t imv_os_agent_t; - -/** - * Public interface of the OS IMV agent - */ -struct imv_os_agent_t { - - /** - * Implements the TNC_IMV_ProvideBindFunction function of the OS IMV - * - * @param bind_function Function offered by the TNCS - * @return TNC result code - */ - TNC_Result (*bind_functions)(imv_os_agent_t *this, - TNC_TNCS_BindFunctionPointer bind_function); - - /** - * Implements the TNC_IMV_NotifyConnectionChange() function of the OS IMV - * - * @param id Network connection ID assigned by TNCS - * @param new_state New connection state to be set - * @return TNC result code - */ - TNC_Result (*notify_connection_change)(imv_os_agent_t *this, - TNC_ConnectionID id, - TNC_ConnectionState new_state); - - /** - * Implements the TNC_IMV_ReceiveMessage() function of the OS IMV - * - * @param id Network connection ID assigned by TNCS - * @param msg_type PA-TNC message type - * @param msg Received message - * @return TNC result code - */ - TNC_Result (*receive_message)(imv_os_agent_t *this, TNC_ConnectionID id, - TNC_MessageType msg_type, chunk_t msg); - - /** - * Implements the TNC_IMV_ReceiveMessageLong() function of the OS IMV - * - * @param id Network connection ID assigned by TNCS - * @param src_imc_id ID of source IMC - * @param dst_imv_id ID of destination IMV - * @param msg_vid Vendor ID of message type - * @param msg_subtype PA-TNC message subtype - * @param msg Received message - * @return TNC result code - */ - TNC_Result (*receive_message_long)(imv_os_agent_t *this, - TNC_ConnectionID id, - TNC_UInt32 src_imc_id, - TNC_UInt32 dst_imv_id, - TNC_VendorID msg_vid, - TNC_MessageSubtype msg_subtype, - chunk_t msg); - - /** - * Implements the TNC_IMV_BatchEnding() function of the OS IMV - * - * @param id Network connection ID assigned by TNCS - * @return TNC result code - */ - TNC_Result (*batch_ending)(imv_os_agent_t *this, TNC_ConnectionID id); - - /** - * Implements the TNC_IMV_SolicitRecommendation() function of the OS IMV - * - * @param id Network connection ID assigned by TNCS - * @return TNC result code - */ - TNC_Result (*solicit_recommendation)(imv_os_agent_t *this, - TNC_ConnectionID id); - - /** - * Destroys an imv_os_agent_t object - */ - void (*destroy)(imv_os_agent_t *this); - -}; +#include /** - * Creates the an OS IMV agent + * Creates an OS IMV agent * * @param name Name of the IMV * @param id ID of the IMV * @param actual_version TNC IF-IMV version */ -imv_os_agent_t* imv_os_agent_create(const char* name, TNC_IMVID id, +imv_agent_if_t* imv_os_agent_create(const char* name, TNC_IMVID id, TNC_Version *actual_version); #endif /** IMV_OS_AGENT_H_ @}*/