implemented IMC/IMV ReceiveMessageLong functions

This commit is contained in:
Andreas Steffen
2011-12-09 23:32:30 +01:00
parent ac3331e1cd
commit 54f53f9081
11 changed files with 467 additions and 128 deletions
+57 -12
View File
@@ -485,16 +485,40 @@ METHOD(imc_agent_t, send_message, TNC_Result,
}
METHOD(imc_agent_t, receive_message, TNC_Result,
private_imc_agent_t *this, TNC_ConnectionID connection_id, chunk_t msg,
TNC_MessageType msg_type, pa_tnc_msg_t **pa_tnc_msg)
private_imc_agent_t *this, imc_state_t *state, chunk_t msg,
TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype,
TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id, pa_tnc_msg_t **pa_tnc_msg)
{
pa_tnc_msg_t *pa_msg, *error_msg;
pa_tnc_attr_t *error_attr;
enumerator_t *enumerator;
TNC_MessageType msg_type;
TNC_UInt32 msg_flags, src_imc_id, dst_imv_id;
TNC_ConnectionID connection_id;
TNC_Result result;
DBG2(DBG_IMV, "IMC %u \"%s\" received message type 0x%08x for Connection ID %u",
this->id, this->name, msg_type, connection_id);
connection_id = state->get_connection_id(state);
if (state->has_long(state))
{
if (dst_imc_id != TNC_IMCID_ANY)
{
DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u "
"from IMV %u to IMC %u", this->id, this->name,
connection_id, src_imv_id, dst_imc_id);
}
else
{
DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u "
"from IMV %u", this->id, this->name, connection_id,
src_imv_id);
}
}
else
{
DBG2(DBG_IMC, "IMC %u \"%s\" received message for Connection ID %u",
this->id, this->name, connection_id);
}
*pa_tnc_msg = NULL;
pa_msg = pa_tnc_msg_create_from_data(msg);
@@ -505,12 +529,6 @@ METHOD(imc_agent_t, receive_message, TNC_Result,
*pa_tnc_msg = pa_msg;
break;
case VERIFY_ERROR:
if (!this->send_message)
{
/* TNCC doen't have a SendMessage() function */
return TNC_RESULT_FATAL;
}
/* build error message */
error_msg = pa_tnc_msg_create();
enumerator = pa_msg->create_error_enumerator(pa_msg);
@@ -523,9 +541,36 @@ METHOD(imc_agent_t, receive_message, TNC_Result,
error_msg->build(error_msg);
/* send error message */
msg = error_msg->get_encoding(error_msg);
result = this->send_message(this->id, connection_id,
if (state->has_long(state) && this->send_message_long)
{
if (state->has_excl(state))
{
msg_flags = TNC_MESSAGE_FLAGS_EXCLUSIVE;
dst_imv_id = src_imv_id;
}
else
{
msg_flags = 0;
dst_imv_id = TNC_IMVID_ANY;
}
src_imc_id = (dst_imc_id == TNC_IMCID_ANY) ? this->id
: dst_imc_id;
result = this->send_message_long(src_imc_id, connection_id,
msg_flags, msg.ptr, msg.len, msg_vid,
msg_subtype, dst_imv_id);
}
else if (this->send_message)
{
msg_type = (msg_vid << 8) | msg_subtype;
result = this->send_message(this->id, connection_id,
msg.ptr, msg.len, msg_type);
}
else
{
result = TNC_RESULT_FATAL;
}
/* clean up */
error_msg->destroy(error_msg);
+10 -4
View File
@@ -115,15 +115,21 @@ struct imc_agent_t {
/**
* Call when a PA-TNC message was received
*
* @param connection_id network connection ID assigned by TNCC
* @param state state for current connection
* @param msg received unparsed message
* @param msg_type message type of the received message
* @param msg_vid message vendorID of the received message
* @param msg_subtype message subtype of the received message
* @param src_imv_id source IMV ID
* @param dst_imc_id destination IMC ID
* @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred
* @return TNC result code
*/
TNC_Result (*receive_message)(imc_agent_t *this,
TNC_ConnectionID connection_id, chunk_t msg,
TNC_MessageType msg_type,
imc_state_t *state, chunk_t msg,
TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype,
TNC_UInt32 src_imv_id,
TNC_UInt32 dst_imc_id,
pa_tnc_msg_t **pa_tnc_msg);
/**