Defined a generic IMV agent interface
This commit is contained in:
@@ -9,7 +9,7 @@ libimcv_la_SOURCES = \
|
|||||||
imcv.h imcv.c \
|
imcv.h imcv.c \
|
||||||
imc/imc_agent.h imc/imc_agent.c imc/imc_state.h \
|
imc/imc_agent.h imc/imc_agent.c imc/imc_state.h \
|
||||||
imc/imc_msg.h imc/imc_msg.c \
|
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_database.h imv/imv_database.c \
|
||||||
imv/imv_msg.h imv/imv_msg.c \
|
imv/imv_msg.h imv/imv_msg.c \
|
||||||
imv/imv_lang_string.h imv/imv_lang_string.c \
|
imv/imv_lang_string.h imv/imv_lang_string.c \
|
||||||
|
|||||||
@@ -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 <http://www.fsf.org/copyleft/gpl.txt>.
|
||||||
|
*
|
||||||
|
* 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 <tncifimv.h>
|
||||||
|
|
||||||
|
#include <library.h>
|
||||||
|
|
||||||
|
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_ @}*/
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
static const char imv_name[] = "OS";
|
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
|
* 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;
|
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)
|
if (!imv_agent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ struct private_imv_os_agent_t {
|
|||||||
/**
|
/**
|
||||||
* Public members of 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
|
* 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)
|
private_imv_os_agent_t *this, TNC_TNCS_BindFunctionPointer bind_function)
|
||||||
{
|
{
|
||||||
return this->agent->bind_functions(this->agent, 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,
|
private_imv_os_agent_t *this, TNC_ConnectionID id,
|
||||||
TNC_ConnectionState new_state)
|
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;
|
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,
|
private_imv_os_agent_t *this, TNC_ConnectionID id,
|
||||||
TNC_MessageType msg_type, chunk_t msg)
|
TNC_MessageType msg_type, chunk_t msg)
|
||||||
{
|
{
|
||||||
@@ -439,7 +439,7 @@ METHOD(imv_os_agent_t, receive_message, TNC_Result,
|
|||||||
return 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,
|
private_imv_os_agent_t *this, TNC_ConnectionID id,
|
||||||
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
|
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
|
||||||
TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype, chunk_t msg)
|
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;
|
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)
|
private_imv_os_agent_t *this, TNC_ConnectionID id)
|
||||||
{
|
{
|
||||||
imv_msg_t *out_msg;
|
imv_msg_t *out_msg;
|
||||||
@@ -747,7 +747,7 @@ METHOD(imv_os_agent_t, batch_ending, TNC_Result,
|
|||||||
return 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)
|
private_imv_os_agent_t *this, TNC_ConnectionID id)
|
||||||
{
|
{
|
||||||
imv_state_t *state;
|
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);
|
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)
|
private_imv_os_agent_t *this)
|
||||||
{
|
{
|
||||||
DESTROY_IF(this->agent);
|
DESTROY_IF(this->agent);
|
||||||
@@ -770,7 +770,7 @@ METHOD(imv_os_agent_t, destroy, void,
|
|||||||
/**
|
/**
|
||||||
* Described in header.
|
* 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)
|
TNC_Version *actual_version)
|
||||||
{
|
{
|
||||||
private_imv_os_agent_t *this;
|
private_imv_os_agent_t *this;
|
||||||
|
|||||||
@@ -21,100 +21,16 @@
|
|||||||
#ifndef IMV_OS_AGENT_H_
|
#ifndef IMV_OS_AGENT_H_
|
||||||
#define IMV_OS_AGENT_H_
|
#define IMV_OS_AGENT_H_
|
||||||
|
|
||||||
#include <imv/imv_state.h>
|
#include <imv/imv_agent_if.h>
|
||||||
#include <imv/imv_msg.h>
|
|
||||||
|
|
||||||
#include <tncif.h>
|
|
||||||
|
|
||||||
typedef struct imv_os_agent_t imv_os_agent_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public interface of the OS IMV agent
|
* Creates an 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);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the an OS IMV agent
|
|
||||||
*
|
*
|
||||||
* @param name Name of the IMV
|
* @param name Name of the IMV
|
||||||
* @param id ID of the IMV
|
* @param id ID of the IMV
|
||||||
* @param actual_version TNC IF-IMV version
|
* @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);
|
TNC_Version *actual_version);
|
||||||
|
|
||||||
#endif /** IMV_OS_AGENT_H_ @}*/
|
#endif /** IMV_OS_AGENT_H_ @}*/
|
||||||
|
|||||||
Reference in New Issue
Block a user