Add wrappers to IMC/IMV managers loading IMC/IMVs from function pointers
This commit is contained in:
@@ -116,6 +116,37 @@ METHOD(imc_manager_t, load, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(imc_manager_t, load_from_functions, bool,
|
||||
private_tnc_imc_manager_t *this, char *name,
|
||||
TNC_IMC_InitializePointer initialize,
|
||||
TNC_IMC_NotifyConnectionChangePointer notify_connection_change,
|
||||
TNC_IMC_BeginHandshakePointer begin_handshake,
|
||||
TNC_IMC_ReceiveMessagePointer receive_message,
|
||||
TNC_IMC_ReceiveMessageLongPointer receive_message_long,
|
||||
TNC_IMC_BatchEndingPointer batch_ending,
|
||||
TNC_IMC_TerminatePointer terminate,
|
||||
TNC_IMC_ProvideBindFunctionPointer provide_bind_function)
|
||||
{
|
||||
imc_t *imc;
|
||||
|
||||
imc = tnc_imc_create_from_functions(name,
|
||||
initialize, notify_connection_change,
|
||||
begin_handshake, receive_message,
|
||||
receive_message_long, batch_ending,
|
||||
terminate, provide_bind_function);
|
||||
if (!imc)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!add(this, imc))
|
||||
{
|
||||
imc->destroy(imc);
|
||||
return FALSE;
|
||||
}
|
||||
DBG1(DBG_TNC, "IMC %u \"%s\" loaded", imc->get_id(imc), name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(imc_manager_t, is_registered, bool,
|
||||
private_tnc_imc_manager_t *this, TNC_IMCID id)
|
||||
{
|
||||
@@ -346,6 +377,7 @@ imc_manager_t* tnc_imc_manager_create(void)
|
||||
.add = _add,
|
||||
.remove = _remove_, /* avoid name conflict with stdio.h */
|
||||
.load = _load,
|
||||
.load_from_functions = _load_from_functions,
|
||||
.is_registered = _is_registered,
|
||||
.reserve_id = _reserve_id,
|
||||
.get_preferred_language = _get_preferred_language,
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
typedef struct private_tnc_imv_manager_t private_tnc_imv_manager_t;
|
||||
|
||||
|
||||
/**
|
||||
* Private data of an imv_manager_t object.
|
||||
*/
|
||||
@@ -132,6 +131,37 @@ METHOD(imv_manager_t, load, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(imv_manager_t, load_from_functions, bool,
|
||||
private_tnc_imv_manager_t *this, char *name,
|
||||
TNC_IMV_InitializePointer initialize,
|
||||
TNC_IMV_NotifyConnectionChangePointer notify_connection_change,
|
||||
TNC_IMV_ReceiveMessagePointer receive_message,
|
||||
TNC_IMV_ReceiveMessageLongPointer receive_message_long,
|
||||
TNC_IMV_SolicitRecommendationPointer solicit_recommendation,
|
||||
TNC_IMV_BatchEndingPointer batch_ending,
|
||||
TNC_IMV_TerminatePointer terminate,
|
||||
TNC_IMV_ProvideBindFunctionPointer provide_bind_function)
|
||||
{
|
||||
imv_t *imv;
|
||||
|
||||
imv = tnc_imv_create_from_functions(name,
|
||||
initialize,notify_connection_change,
|
||||
receive_message, receive_message_long,
|
||||
solicit_recommendation, batch_ending,
|
||||
terminate, provide_bind_function);
|
||||
if (!imv)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (!add(this, imv))
|
||||
{
|
||||
imv->destroy(imv);
|
||||
return FALSE;
|
||||
}
|
||||
DBG1(DBG_TNC, "IMV %u \"%s\" loaded", imv->get_id(imv), name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(imv_manager_t, is_registered, bool,
|
||||
private_tnc_imv_manager_t *this, TNC_IMVID id)
|
||||
{
|
||||
@@ -427,6 +457,7 @@ imv_manager_t* tnc_imv_manager_create(void)
|
||||
.add = _add,
|
||||
.remove = _remove_, /* avoid name conflict with stdio.h */
|
||||
.load = _load,
|
||||
.load_from_functions = _load_from_functions,
|
||||
.is_registered = _is_registered,
|
||||
.reserve_id = _reserve_id,
|
||||
.get_recommendation_policy = _get_recommendation_policy,
|
||||
|
||||
@@ -55,7 +55,31 @@ struct imc_manager_t {
|
||||
* @param path path of the IMC dynamic library file
|
||||
* @return TRUE if loading succeeded
|
||||
*/
|
||||
bool (*load)(imc_manager_t *this, char *name, char *path);
|
||||
bool (*load)(imc_manager_t *this, char *name, char *path);
|
||||
|
||||
/**
|
||||
* Load and initialize an IMC from a set of TNC IMC functions.
|
||||
*
|
||||
* @param name name of the IMC
|
||||
* @param initialize TNC_IMC_InitializePointer
|
||||
* @param notify_connection_change TNC_IMC_NotifyConnectionChangePointer
|
||||
* @param begin_handshake TNC_IMC_BeginHandshakePointer
|
||||
* @param receive_message TNC_IMC_ReceiveMessagePointer
|
||||
* @param receive_message_long TNC_IMC_ReceiveMessageLongPointer
|
||||
* @param batch_ending TNC_IMC_BatchEndingPointer
|
||||
* @param terminate TNC_IMC_TerminatePointer
|
||||
* @param provide_bind_function TNC_IMC_ProvideBindFunctionPointer
|
||||
* @return TRUE if loading succeeded
|
||||
*/
|
||||
bool (*load_from_functions)(imc_manager_t *this, char *name,
|
||||
TNC_IMC_InitializePointer initialize,
|
||||
TNC_IMC_NotifyConnectionChangePointer notify_connection_change,
|
||||
TNC_IMC_BeginHandshakePointer begin_handshake,
|
||||
TNC_IMC_ReceiveMessagePointer receive_message,
|
||||
TNC_IMC_ReceiveMessageLongPointer receive_message_long,
|
||||
TNC_IMC_BatchEndingPointer batch_ending,
|
||||
TNC_IMC_TerminatePointer terminate,
|
||||
TNC_IMC_ProvideBindFunctionPointer provide_bind_function);
|
||||
|
||||
/**
|
||||
* Check if an IMC with a given ID is registered with the IMC manager
|
||||
|
||||
@@ -56,8 +56,31 @@ struct imv_manager_t {
|
||||
* @param path path of the IMV dynamic library file
|
||||
* @return TRUE if loading succeeded
|
||||
*/
|
||||
bool (*load)(imv_manager_t *this, char *name, char *path);
|
||||
bool (*load)(imv_manager_t *this, char *name, char *path);
|
||||
|
||||
/**
|
||||
* Load and initialize an IMV from a set of TNC IMC functions.
|
||||
*
|
||||
* @param name name of the IMV
|
||||
* @param initialize TNC_IMV_InitializePointer
|
||||
* @param notify_connection_change TNC_IMV_NotifyConnectionChangePointer
|
||||
* @param receive_message TNC_IMV_ReceiveMessagePointer
|
||||
* @param receive_message_long TNC_IMV_ReceiveMessageLongPointer
|
||||
* @param solicit_recommendation TNC_IMV_SolicitRecommendationPointer
|
||||
* @param batch_ending TNC_IMV_BatchEndingPointer
|
||||
* @param terminate TNC_IMV_TerminatePointer
|
||||
* @param provide_bind_function TNC_IMV_ProvideBindFunctionPointer
|
||||
* @return TRUE if loading succeeded
|
||||
*/
|
||||
bool (*load_from_functions)(imv_manager_t *this, char *name,
|
||||
TNC_IMV_InitializePointer initialize,
|
||||
TNC_IMV_NotifyConnectionChangePointer notify_connection_change,
|
||||
TNC_IMV_ReceiveMessagePointer receive_message,
|
||||
TNC_IMV_ReceiveMessageLongPointer receive_message_long,
|
||||
TNC_IMV_SolicitRecommendationPointer solicit_recommendation,
|
||||
TNC_IMV_BatchEndingPointer batch_ending,
|
||||
TNC_IMV_TerminatePointer terminate,
|
||||
TNC_IMV_ProvideBindFunctionPointer provide_bind_function);
|
||||
|
||||
/**
|
||||
* Check if an IMV with a given ID is registered with the IMV manager
|
||||
|
||||
Reference in New Issue
Block a user