added IMC/IMV support for send_message_long() and reserve_additional_id() functions
This commit is contained in:
@@ -105,6 +105,29 @@ struct private_imc_agent_t {
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_MessageType msg_type);
|
||||
|
||||
|
||||
/**
|
||||
* Call when an IMC-IMC message is to be sent with long message types
|
||||
*
|
||||
* @param imc_id IMC ID assigned by TNCC
|
||||
* @param connection_id network connection ID assigned by TNCC
|
||||
* @param msg_flags message flags
|
||||
* @param msg message to send
|
||||
* @param msg_len message length in bytes
|
||||
* @param msg_vid message vendor ID
|
||||
* @param msg_subtype message subtype
|
||||
* @param dst_imc_id destination IMV ID
|
||||
* @return TNC result code
|
||||
*/
|
||||
TNC_Result (*send_message_long)(TNC_IMCID imc_id,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_UInt32 msg_flags,
|
||||
TNC_BufferReference msg,
|
||||
TNC_UInt32 msg_len,
|
||||
TNC_VendorID msg_vid,
|
||||
TNC_MessageSubtype msg_subtype,
|
||||
TNC_UInt32 dst_imv_id);
|
||||
|
||||
/**
|
||||
* Get the value of an attribute associated with a connection
|
||||
* or with the TNCC as a whole.
|
||||
@@ -140,6 +163,17 @@ struct private_imc_agent_t {
|
||||
TNC_AttributeID attribute_id,
|
||||
TNC_UInt32 buffer_len,
|
||||
TNC_BufferReference buffer);
|
||||
|
||||
/**
|
||||
* Reserve an additional IMC ID
|
||||
*
|
||||
* @param imc_id primary IMC ID assigned by TNCC
|
||||
* @param out_imc_id additional IMC ID assigned by TNCC
|
||||
* @return TNC result code
|
||||
*/
|
||||
TNC_Result (*reserve_additional_id)(TNC_IMCID imc_id,
|
||||
TNC_UInt32 *out_imc_id);
|
||||
|
||||
};
|
||||
|
||||
METHOD(imc_agent_t, bind_functions, TNC_Result,
|
||||
@@ -170,6 +204,11 @@ METHOD(imc_agent_t, bind_functions, TNC_Result,
|
||||
{
|
||||
this->send_message = NULL;
|
||||
}
|
||||
if (bind_function(this->id, "TNC_TNCC_SendMessageLong",
|
||||
(void**)&this->send_message_long) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
this->send_message_long = NULL;
|
||||
}
|
||||
if (bind_function(this->id, "TNC_TNCC_GetAttribute",
|
||||
(void**)&this->get_attribute) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
@@ -180,6 +219,11 @@ METHOD(imc_agent_t, bind_functions, TNC_Result,
|
||||
{
|
||||
this->set_attribute = NULL;
|
||||
}
|
||||
if (bind_function(this->id, "TNC_TNCC_ReserveAdditionalIMCID",
|
||||
(void**)&this->reserve_additional_id) != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
this->reserve_additional_id = NULL;
|
||||
}
|
||||
DBG2(DBG_IMC, "IMC %u \"%s\" provided with bind function",
|
||||
this->id, this->name);
|
||||
|
||||
@@ -403,16 +447,41 @@ METHOD(imc_agent_t, get_state, bool,
|
||||
}
|
||||
|
||||
METHOD(imc_agent_t, send_message, TNC_Result,
|
||||
private_imc_agent_t *this, TNC_ConnectionID connection_id, chunk_t msg)
|
||||
private_imc_agent_t *this, TNC_ConnectionID connection_id, bool excl,
|
||||
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id, chunk_t msg)
|
||||
{
|
||||
TNC_MessageType type;
|
||||
TNC_UInt32 msg_flags;
|
||||
imc_state_t *state;
|
||||
|
||||
if (!this->send_message)
|
||||
state = find_connection(this, connection_id);
|
||||
if (!state)
|
||||
{
|
||||
DBG1(DBG_IMV, "IMC %u \"%s\" has no state for Connection ID %u",
|
||||
this->id, this->name, connection_id);
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
type = (this->vendor_id << 8) | this->subtype;
|
||||
return this->send_message(this->id, connection_id, msg.ptr, msg.len, type);
|
||||
|
||||
if (state->has_long(state) && this->send_message_long)
|
||||
{
|
||||
if (!src_imc_id)
|
||||
{
|
||||
src_imc_id = this->id;
|
||||
}
|
||||
msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
|
||||
|
||||
return this->send_message_long(src_imc_id, connection_id, msg_flags,
|
||||
msg.ptr, msg.len, this->vendor_id,
|
||||
this->subtype, dst_imv_id);
|
||||
}
|
||||
if (this->send_message)
|
||||
{
|
||||
type = (this->vendor_id << 8) | this->subtype;
|
||||
|
||||
return this->send_message(this->id, connection_id, msg.ptr, msg.len,
|
||||
type);
|
||||
}
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
METHOD(imc_agent_t, receive_message, TNC_Result,
|
||||
@@ -470,6 +539,16 @@ METHOD(imc_agent_t, receive_message, TNC_Result,
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
METHOD(imc_agent_t, reserve_additional_id, TNC_Result,
|
||||
private_imc_agent_t *this, TNC_UInt32 *id)
|
||||
{
|
||||
if (!this->reserve_additional_id)
|
||||
{
|
||||
return TNC_RESULT_ILLEGAL_OPERATION;
|
||||
}
|
||||
return this->reserve_additional_id(this->id, id);
|
||||
}
|
||||
|
||||
METHOD(imc_agent_t, destroy, void,
|
||||
private_imc_agent_t *this)
|
||||
{
|
||||
@@ -506,6 +585,7 @@ imc_agent_t *imc_agent_create(const char *name,
|
||||
.get_state = _get_state,
|
||||
.send_message = _send_message,
|
||||
.receive_message = _receive_message,
|
||||
.reserve_additional_id = _reserve_additional_id,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.name = name,
|
||||
|
||||
@@ -101,11 +101,15 @@ struct imc_agent_t {
|
||||
* Call when an PA-TNC message is to be sent
|
||||
*
|
||||
* @param connection_id network connection ID assigned by TNCC
|
||||
* @param excl exclusive flag
|
||||
* @param src_imc_id IMC ID to be set as source
|
||||
* @param dst_imv_id IMV ID to be set as destination
|
||||
* @param msg message to send
|
||||
* @return TNC result code
|
||||
*/
|
||||
TNC_Result (*send_message)(imc_agent_t *this,
|
||||
TNC_ConnectionID connection_id,
|
||||
TNC_ConnectionID connection_id, bool excl,
|
||||
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
|
||||
chunk_t msg);
|
||||
|
||||
/**
|
||||
@@ -122,6 +126,14 @@ struct imc_agent_t {
|
||||
TNC_MessageType msg_type,
|
||||
pa_tnc_msg_t **pa_tnc_msg);
|
||||
|
||||
/**
|
||||
* Reserve an additional IMC ID
|
||||
*
|
||||
* @param id additional IMC ID assigned by TNCC
|
||||
* @return TNC result code
|
||||
*/
|
||||
TNC_Result (*reserve_additional_id)(imc_agent_t *this, TNC_UInt32 *id);
|
||||
|
||||
/**
|
||||
* Destroys an imc_agent_t object
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user