diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2011-12-09 23:32:30 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2011-12-09 23:32:30 +0100 |
commit | 54f53f90813542f3bf455ca9cc71859460e0e9b2 (patch) | |
tree | 356d8fb922caa3c1ada0ea503524229ea35e8251 /src/libimcv | |
parent | ac3331e1cd740d728d50a6753569ed53f6c0c659 (diff) | |
download | strongswan-54f53f90813542f3bf455ca9cc71859460e0e9b2.tar.bz2 strongswan-54f53f90813542f3bf455ca9cc71859460e0e9b2.tar.xz |
implemented IMC/IMV ReceiveMessageLong functions
Diffstat (limited to 'src/libimcv')
-rw-r--r-- | src/libimcv/imc/imc_agent.c | 69 | ||||
-rw-r--r-- | src/libimcv/imc/imc_agent.h | 14 | ||||
-rw-r--r-- | src/libimcv/imv/imv_agent.c | 74 | ||||
-rw-r--r-- | src/libimcv/imv/imv_agent.h | 14 | ||||
-rw-r--r-- | src/libimcv/plugins/imc_scanner/imc_scanner.c | 75 | ||||
-rw-r--r-- | src/libimcv/plugins/imc_test/imc_test.c | 75 | ||||
-rw-r--r-- | src/libimcv/plugins/imv_scanner/imv_scanner.c | 68 | ||||
-rw-r--r-- | src/libimcv/plugins/imv_test/imv_test.c | 68 |
8 files changed, 361 insertions, 96 deletions
diff --git a/src/libimcv/imc/imc_agent.c b/src/libimcv/imc/imc_agent.c index 0a01f7dc5..f7ce19181 100644 --- a/src/libimcv/imc/imc_agent.c +++ b/src/libimcv/imc/imc_agent.c @@ -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); diff --git a/src/libimcv/imc/imc_agent.h b/src/libimcv/imc/imc_agent.h index ef211d637..a00f3db34 100644 --- a/src/libimcv/imc/imc_agent.h +++ b/src/libimcv/imc/imc_agent.h @@ -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); /** diff --git a/src/libimcv/imv/imv_agent.c b/src/libimcv/imv/imv_agent.c index f25011c30..de2c85245 100644 --- a/src/libimcv/imv/imv_agent.c +++ b/src/libimcv/imv/imv_agent.c @@ -521,16 +521,40 @@ METHOD(imv_agent_t, set_recommendation, TNC_Result, } METHOD(imv_agent_t, receive_message, TNC_Result, - private_imv_agent_t *this, TNC_ConnectionID connection_id, chunk_t msg, - TNC_MessageType msg_type, pa_tnc_msg_t **pa_tnc_msg) + private_imv_agent_t *this, imv_state_t *state, chunk_t msg, + TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype, + TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_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_imv_id, dst_imc_id; + TNC_ConnectionID connection_id; TNC_Result result; - DBG2(DBG_IMV, "IMV %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_imv_id != TNC_IMVID_ANY) + { + DBG2(DBG_IMV, "IMV %u \"%s\" received message for Connection ID %u " + "from IMC %u to IMV %u", this->id, this->name, + connection_id, src_imc_id, dst_imv_id); + } + else + { + DBG2(DBG_IMV, "IMV %u \"%s\" received message for Connection ID %u " + "from IMC %u", this->id, this->name, connection_id, + src_imc_id); + } + } + else + { + DBG2(DBG_IMV, "IMV %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); @@ -541,12 +565,6 @@ METHOD(imv_agent_t, receive_message, TNC_Result, *pa_tnc_msg = pa_msg; break; case VERIFY_ERROR: - if (!this->send_message) - { - /* TNCS 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); @@ -560,8 +578,37 @@ METHOD(imv_agent_t, receive_message, TNC_Result, /* 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_imc_id = src_imc_id; + } + else + { + msg_flags = 0; + dst_imc_id = TNC_IMCID_ANY; + } + src_imv_id = (dst_imv_id == TNC_IMVID_ANY) ? this->id + : dst_imv_id; + + result = this->send_message_long(src_imv_id, connection_id, + msg_flags, msg.ptr, msg.len, msg_vid, + msg_subtype, dst_imc_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); @@ -570,7 +617,10 @@ METHOD(imv_agent_t, receive_message, TNC_Result, case FAILED: default: pa_msg->destroy(pa_msg); - return set_recommendation(this, connection_id, + state->set_recommendation(state, + TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION, + TNC_IMV_EVALUATION_RESULT_ERROR); + return this->provide_recommendation(this->id, connection_id, TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION, TNC_IMV_EVALUATION_RESULT_ERROR); } diff --git a/src/libimcv/imv/imv_agent.h b/src/libimcv/imv/imv_agent.h index 86780649e..c3070f555 100644 --- a/src/libimcv/imv/imv_agent.h +++ b/src/libimcv/imv/imv_agent.h @@ -115,15 +115,21 @@ struct imv_agent_t { /** * Call when a PA-TNC message was received * - * @param connection_id network connection ID assigned by TNCS + * @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_imc_id source IMC ID + * @param dst_imv_id destination IMV ID * @param pa_tnc_message parsed PA-TNC message or NULL if an error occurred * @return TNC result code */ TNC_Result (*receive_message)(imv_agent_t *this, - TNC_ConnectionID connection_id, chunk_t msg, - TNC_MessageType msg_type, + imv_state_t *state, chunk_t msg, + TNC_VendorID msg_vid, + TNC_MessageSubtype msg_subtype, + TNC_UInt32 src_imc_id, + TNC_UInt32 dst_imv_id, pa_tnc_msg_t **pa_tnc_msg); /** diff --git a/src/libimcv/plugins/imc_scanner/imc_scanner.c b/src/libimcv/plugins/imc_scanner/imc_scanner.c index 0b232e5b9..4cdf2bdb6 100644 --- a/src/libimcv/plugins/imc_scanner/imc_scanner.c +++ b/src/libimcv/plugins/imc_scanner/imc_scanner.c @@ -39,7 +39,7 @@ static const char imc_name[] = "Scanner"; static imc_agent_t *imc_scanner; /** - * see section 3.7.1 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.1 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id, TNC_Version min_version, @@ -66,7 +66,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id, } /** - * see section 3.7.2 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.2 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id, TNC_ConnectionID connection_id, @@ -245,7 +245,7 @@ static TNC_Result send_message(TNC_ConnectionID connection_id) } /** - * see section 3.7.3 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.3 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, TNC_ConnectionID connection_id) @@ -258,17 +258,18 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, return send_message(connection_id); } -/** - * see section 3.7.4 of TCG TNC IF-IMC Specification 1.2 - */ -TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, +static TNC_Result receive_message(TNC_IMCID imc_id, TNC_ConnectionID connection_id, - TNC_BufferReference msg, - TNC_UInt32 msg_len, - TNC_MessageType msg_type) + TNC_UInt32 msg_flags, + 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_attr_t *attr; + imc_state_t *state; enumerator_t *enumerator; TNC_Result result; bool fatal_error = FALSE; @@ -279,10 +280,15 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, return TNC_RESULT_NOT_INITIALIZED; } + /* get current IMC state */ + if (!imc_scanner->get_state(imc_scanner, connection_id, &state)) + { + return TNC_RESULT_FATAL; + } + /* parse received PA-TNC message and automatically handle any errors */ - result = imc_scanner->receive_message(imc_scanner, connection_id, - chunk_create(msg, msg_len), msg_type, - &pa_tnc_msg); + result = imc_scanner->receive_message(imc_scanner, state, msg, msg_vid, + msg_subtype, src_imv_id, dst_imc_id, &pa_tnc_msg); /* no parsed PA-TNC attributes available if an error occurred */ if (!pa_tnc_msg) @@ -334,7 +340,44 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, } /** - * see section 3.7.5 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.4 of TCG TNC IF-IMC Specification 1.3 + */ +TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, + TNC_ConnectionID connection_id, + TNC_BufferReference msg, + TNC_UInt32 msg_len, + TNC_MessageType msg_type) +{ + TNC_VendorID msg_vid; + TNC_MessageSubtype msg_subtype; + + msg_vid = msg_type >> 8; + msg_subtype = msg_type & TNC_SUBTYPE_ANY; + + return receive_message(imc_id, connection_id, 0, chunk_create(msg, msg_len), + msg_vid, msg_subtype, 0, TNC_IMCID_ANY); +} + +/** + * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3 + */ +TNC_Result TNC_IMC_ReceiveMessageLong(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 src_imv_id, + TNC_UInt32 dst_imc_id) +{ + return receive_message(imc_id, connection_id, msg_flags, + chunk_create(msg, msg_len), msg_vid, msg_subtype, + src_imv_id, dst_imc_id); +} + +/** + * see section 3.8.7 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_BatchEnding(TNC_IMCID imc_id, TNC_ConnectionID connection_id) @@ -348,7 +391,7 @@ TNC_Result TNC_IMC_BatchEnding(TNC_IMCID imc_id, } /** - * see section 3.7.6 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.8 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id) { @@ -364,7 +407,7 @@ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id) } /** - * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.2 + * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id, TNC_TNCC_BindFunctionPointer bind_function) diff --git a/src/libimcv/plugins/imc_test/imc_test.c b/src/libimcv/plugins/imc_test/imc_test.c index 915035f9a..732a625d4 100644 --- a/src/libimcv/plugins/imc_test/imc_test.c +++ b/src/libimcv/plugins/imc_test/imc_test.c @@ -37,7 +37,7 @@ static const char imc_name[] = "Test"; static imc_agent_t *imc_test; /** - * see section 3.7.1 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.1 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id, TNC_Version min_version, @@ -64,7 +64,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id, } /** - * see section 3.7.2 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.2 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id, TNC_ConnectionID connection_id, @@ -228,7 +228,7 @@ static TNC_Result send_message(TNC_ConnectionID connection_id) } /** - * see section 3.7.3 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.3 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, TNC_ConnectionID connection_id) @@ -241,17 +241,18 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id, return send_message(connection_id); } -/** - * see section 3.7.4 of TCG TNC IF-IMC Specification 1.2 - */ -TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, +static TNC_Result receive_message(TNC_IMCID imc_id, TNC_ConnectionID connection_id, - TNC_BufferReference msg, - TNC_UInt32 msg_len, - TNC_MessageType msg_type) + TNC_UInt32 msg_flags, + 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_attr_t *attr; + imc_state_t *state; enumerator_t *enumerator; TNC_Result result; bool fatal_error = FALSE; @@ -262,10 +263,15 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, return TNC_RESULT_NOT_INITIALIZED; } + /* get current IMC state */ + if (!imc_test->get_state(imc_test, connection_id, &state)) + { + return TNC_RESULT_FATAL; + } + /* parse received PA-TNC message and automatically handle any errors */ - result = imc_test->receive_message(imc_test, connection_id, - chunk_create(msg, msg_len), msg_type, - &pa_tnc_msg); + result = imc_test->receive_message(imc_test, state, msg, msg_vid, + msg_subtype, src_imv_id, dst_imc_id, &pa_tnc_msg); /* no parsed PA-TNC attributes available if an error occurred */ if (!pa_tnc_msg) @@ -324,7 +330,44 @@ TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, } /** - * see section 3.7.5 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.4 of TCG TNC IF-IMC Specification 1.3 + */ +TNC_Result TNC_IMC_ReceiveMessage(TNC_IMCID imc_id, + TNC_ConnectionID connection_id, + TNC_BufferReference msg, + TNC_UInt32 msg_len, + TNC_MessageType msg_type) +{ + TNC_VendorID msg_vid; + TNC_MessageSubtype msg_subtype; + + msg_vid = msg_type >> 8; + msg_subtype = msg_type & TNC_SUBTYPE_ANY; + + return receive_message(imc_id, connection_id, 0, chunk_create(msg, msg_len), + msg_vid, msg_subtype, 0, TNC_IMCID_ANY); +} + +/** + * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3 + */ +TNC_Result TNC_IMC_ReceiveMessageLong(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 src_imv_id, + TNC_UInt32 dst_imc_id) +{ + return receive_message(imc_id, connection_id, msg_flags, + chunk_create(msg, msg_len), msg_vid, msg_subtype, + src_imv_id, dst_imc_id); +} + +/** + * see section 3.8.7 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_BatchEnding(TNC_IMCID imc_id, TNC_ConnectionID connection_id) @@ -338,7 +381,7 @@ TNC_Result TNC_IMC_BatchEnding(TNC_IMCID imc_id, } /** - * see section 3.7.6 of TCG TNC IF-IMC Specification 1.2 + * see section 3.8.8 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id) { @@ -354,7 +397,7 @@ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id) } /** - * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.2 + * see section 4.2.8.1 of TCG TNC IF-IMC Specification 1.3 */ TNC_Result TNC_IMC_ProvideBindFunction(TNC_IMCID imc_id, TNC_TNCC_BindFunctionPointer bind_function) diff --git a/src/libimcv/plugins/imv_scanner/imv_scanner.c b/src/libimcv/plugins/imv_scanner/imv_scanner.c index 5561e6737..0b2187a24 100644 --- a/src/libimcv/plugins/imv_scanner/imv_scanner.c +++ b/src/libimcv/plugins/imv_scanner/imv_scanner.c @@ -111,7 +111,7 @@ static linked_list_t* get_port_list(char *label) /* - * see section 3.7.1 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.1 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id, TNC_Version min_version, @@ -149,7 +149,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id, } /** - * see section 3.7.2 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.2 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id, TNC_ConnectionID connection_id, @@ -175,14 +175,14 @@ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id, } } -/** - * see section 3.7.3 of TCG TNC IF-IMV Specification 1.2 - */ -TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, +static TNC_Result receive_message(TNC_IMVID imv_id, TNC_ConnectionID connection_id, - TNC_BufferReference msg, - TNC_UInt32 msg_len, - TNC_MessageType msg_type) + TNC_UInt32 msg_flags, + chunk_t msg, + TNC_VendorID msg_vid, + TNC_MessageSubtype msg_subtype, + TNC_UInt32 src_imc_id, + TNC_UInt32 dst_imv_id) { pa_tnc_msg_t *pa_tnc_msg; pa_tnc_attr_t *attr; @@ -204,9 +204,8 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, } /* parse received PA-TNC message and automatically handle any errors */ - result = imv_scanner->receive_message(imv_scanner, connection_id, - chunk_create(msg, msg_len), msg_type, - &pa_tnc_msg); + result = imv_scanner->receive_message(imv_scanner, state, msg, msg_vid, + msg_subtype, src_imc_id, dst_imv_id, &pa_tnc_msg); /* no parsed PA-TNC attributes available if an error occurred */ if (!pa_tnc_msg) @@ -339,10 +338,47 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, } return imv_scanner->provide_recommendation(imv_scanner, connection_id); + } + +/** + * see section 3.8.4 of TCG TNC IF-IMV Specification 1.3 + */ +TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, + TNC_ConnectionID connection_id, + TNC_BufferReference msg, + TNC_UInt32 msg_len, + TNC_MessageType msg_type) +{ + TNC_VendorID msg_vid; + TNC_MessageSubtype msg_subtype; + + msg_vid = msg_type >> 8; + msg_subtype = msg_type & TNC_SUBTYPE_ANY; + + return receive_message(imv_id, connection_id, 0, chunk_create(msg, msg_len), + msg_vid, msg_subtype, 0, TNC_IMVID_ANY); +} + +/** + * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3 + */ +TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_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 src_imc_id, + TNC_UInt32 dst_imv_id) +{ + return receive_message(imv_id, connection_id, msg_flags, + chunk_create(msg, msg_len), msg_vid, msg_subtype, + src_imc_id, dst_imv_id); } /** - * see section 3.7.4 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.7 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id, TNC_ConnectionID connection_id) @@ -356,7 +392,7 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id, } /** - * see section 3.7.5 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.8 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id, TNC_ConnectionID connection_id) @@ -370,7 +406,7 @@ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id, } /** - * see section 3.7.6 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.9 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_Terminate(TNC_IMVID imv_id) { @@ -388,7 +424,7 @@ TNC_Result TNC_IMV_Terminate(TNC_IMVID imv_id) } /** - * see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.2 + * see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_ProvideBindFunction(TNC_IMVID imv_id, TNC_TNCS_BindFunctionPointer bind_function) diff --git a/src/libimcv/plugins/imv_test/imv_test.c b/src/libimcv/plugins/imv_test/imv_test.c index d7067be41..d19c7c04c 100644 --- a/src/libimcv/plugins/imv_test/imv_test.c +++ b/src/libimcv/plugins/imv_test/imv_test.c @@ -37,7 +37,7 @@ static const char imv_name[] = "Test"; static imv_agent_t *imv_test; /** - * see section 3.7.1 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.1 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id, TNC_Version min_version, @@ -64,7 +64,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id, } /** - * see section 3.7.2 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.2 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_NotifyConnectionChange(TNC_IMVID imv_id, TNC_ConnectionID connection_id, @@ -125,14 +125,14 @@ static TNC_Result send_message(TNC_ConnectionID connection_id) return result; } -/** - * see section 3.7.3 of TCG TNC IF-IMV Specification 1.2 - */ -TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, +static TNC_Result receive_message(TNC_IMVID imv_id, TNC_ConnectionID connection_id, - TNC_BufferReference msg, - TNC_UInt32 msg_len, - TNC_MessageType msg_type) + TNC_UInt32 msg_flags, + chunk_t msg, + TNC_VendorID msg_vid, + TNC_MessageSubtype msg_subtype, + TNC_UInt32 src_imc_id, + TNC_UInt32 dst_imv_id) { pa_tnc_msg_t *pa_tnc_msg; pa_tnc_attr_t *attr; @@ -155,9 +155,8 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, } /* parse received PA-TNC message and automatically handle any errors */ - result = imv_test->receive_message(imv_test, connection_id, - chunk_create(msg, msg_len), msg_type, - &pa_tnc_msg); + result = imv_test->receive_message(imv_test, state, msg, msg_vid, + msg_subtype, src_imc_id, dst_imv_id, &pa_tnc_msg); /* no parsed PA-TNC attributes available if an error occurred */ if (!pa_tnc_msg) @@ -267,7 +266,44 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, } /** - * see section 3.7.4 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.4 of TCG TNC IF-IMV Specification 1.3 + */ +TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id, + TNC_ConnectionID connection_id, + TNC_BufferReference msg, + TNC_UInt32 msg_len, + TNC_MessageType msg_type) +{ + TNC_VendorID msg_vid; + TNC_MessageSubtype msg_subtype; + + msg_vid = msg_type >> 8; + msg_subtype = msg_type & TNC_SUBTYPE_ANY; + + return receive_message(imv_id, connection_id, 0, chunk_create(msg, msg_len), + msg_vid, msg_subtype, 0, TNC_IMVID_ANY); +} + +/** + * see section 3.8.6 of TCG TNC IF-IMV Specification 1.3 + */ +TNC_Result TNC_IMV_ReceiveMessageLong(TNC_IMVID imv_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 src_imc_id, + TNC_UInt32 dst_imv_id) +{ + return receive_message(imv_id, connection_id, msg_flags, + chunk_create(msg, msg_len), msg_vid, msg_subtype, + src_imc_id, dst_imv_id); +} + +/** + * see section 3.8.7 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id, TNC_ConnectionID connection_id) @@ -281,7 +317,7 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id, } /** - * see section 3.7.5 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.8 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id, TNC_ConnectionID connection_id) @@ -295,7 +331,7 @@ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id, } /** - * see section 3.7.6 of TCG TNC IF-IMV Specification 1.2 + * see section 3.8.9 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_Terminate(TNC_IMVID imv_id) { @@ -311,7 +347,7 @@ TNC_Result TNC_IMV_Terminate(TNC_IMVID imv_id) } /** - * see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.2 + * see section 4.2.8.1 of TCG TNC IF-IMV Specification 1.3 */ TNC_Result TNC_IMV_ProvideBindFunction(TNC_IMVID imv_id, TNC_TNCS_BindFunctionPointer bind_function) |