allow registration of multiple message type

This commit is contained in:
Andreas Steffen
2012-10-14 17:37:00 +02:00
parent 07a3dee937
commit 5f085d7e13
12 changed files with 179 additions and 142 deletions
+44 -22
View File
@@ -39,14 +39,14 @@ struct private_imc_agent_t {
const char *name;
/**
* message vendor ID of IMC
* message types registered by IMC
*/
TNC_VendorID vendor_id;
pen_type_t *supported_types;
/**
* message subtype of IMC
* number of message types registered by IMC
*/
TNC_MessageSubtype subtype;
u_int32_t type_count;
/**
* ID of IMC as assigned by TNCC
@@ -234,17 +234,37 @@ METHOD(imc_agent_t, bind_functions, TNC_Result,
if (this->report_message_types_long)
{
this->report_message_types_long(this->id, &this->vendor_id,
&this->subtype, 1);
}
else if (this->report_message_types &&
this->vendor_id <= TNC_VENDORID_ANY &&
this->subtype <= TNC_SUBTYPE_ANY)
{
TNC_MessageType type;
TNC_VendorIDList vendor_id_list;
TNC_MessageSubtypeList subtype_list;
int i;
type = (this->vendor_id << 8) | this->subtype;
this->report_message_types(this->id, &type, 1);
vendor_id_list = malloc(this->type_count * sizeof(TNC_UInt32));
subtype_list = malloc(this->type_count * sizeof(TNC_UInt32));
for (i = 0; i < this->type_count; i++)
{
vendor_id_list[i] = this->supported_types[i].vendor_id;
subtype_list[i] = this->supported_types[i].type;
}
this->report_message_types_long(this->id, vendor_id_list, subtype_list,
this->type_count);
free(vendor_id_list);
free(subtype_list);
}
else if (this->report_message_types)
{
TNC_MessageTypeList type_list;
int i;
type_list = malloc(this->type_count * sizeof(TNC_UInt32));
for (i = 0; i < this->type_count; i++)
{
type_list[i] = (this->supported_types[i].vendor_id << 8) |
(this->supported_types[i].type & 0xff);
}
this->report_message_types(this->id, type_list, this->type_count);
free(type_list);
}
return TNC_RESULT_SUCCESS;
}
@@ -476,7 +496,8 @@ METHOD(imc_agent_t, get_state, bool,
METHOD(imc_agent_t, send_message, TNC_Result,
private_imc_agent_t *this, TNC_ConnectionID connection_id, bool excl,
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id, linked_list_t *attr_list)
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id, TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype, linked_list_t *attr_list)
{
TNC_MessageType type;
TNC_UInt32 msg_flags;
@@ -541,12 +562,12 @@ METHOD(imc_agent_t, send_message, TNC_Result,
msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
result = this->send_message_long(src_imc_id, connection_id,
msg_flags, msg.ptr, msg.len, this->vendor_id,
this->subtype, dst_imv_id);
msg_flags, msg.ptr, msg.len, msg_vid,
msg_subtype, dst_imv_id);
}
else if (this->send_message)
{
type = (this->vendor_id << 8) | this->subtype;
type = msg_vid << 8 | msg_subtype;
result = this->send_message(this->id, connection_id, msg.ptr,
msg.len, type);
@@ -622,7 +643,8 @@ METHOD(imc_agent_t, receive_message, TNC_Result,
dst_imv_id = state->has_excl(state) ? src_imv_id : TNC_IMVID_ANY;
result = send_message(this, connection_id, state->has_excl(state),
src_imc_id, dst_imv_id, error_attr_list);
src_imc_id, dst_imv_id, msg_vid, msg_subtype,
error_attr_list);
error_attr_list->destroy(error_attr_list);
pa_msg->destroy(pa_msg);
@@ -697,7 +719,7 @@ METHOD(imc_agent_t, destroy, void,
* Described in header.
*/
imc_agent_t *imc_agent_create(const char *name,
pen_t vendor_id, u_int32_t subtype,
pen_type_t *supported_types, u_int32_t type_count,
TNC_IMCID id, TNC_Version *actual_version)
{
private_imc_agent_t *this;
@@ -723,8 +745,8 @@ imc_agent_t *imc_agent_create(const char *name,
.destroy = _destroy,
},
.name = name,
.vendor_id = vendor_id,
.subtype = subtype,
.supported_types = supported_types,
.type_count = type_count,
.id = id,
.additional_ids = linked_list_create(),
.connections = linked_list_create(),
+7 -3
View File
@@ -106,12 +106,16 @@ struct imc_agent_t {
* @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_vid message vendor ID
* @param msg_subtype message subtype
* @param attr_list list of PA-TNC attributes to send
* @return TNC result code
*/
TNC_Result (*send_message)(imc_agent_t *this,
TNC_ConnectionID connection_id, bool excl,
TNC_UInt32 src_imc_id, TNC_UInt32 dst_imv_id,
TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype,
linked_list_t *attr_list);
/**
@@ -164,14 +168,14 @@ struct imc_agent_t {
* Create an imc_agent_t object
*
* @param name name of the IMC
* @param vendor_id vendor ID of the IMC
* @param subtype message subtype of the IMC
* @param supported_types list of message types registered by the IMC
* @param type_count number of registered message types
* @param id ID of the IMC as assigned by the TNCS
* @param actual_version actual version of the IF-IMC API
*
*/
imc_agent_t *imc_agent_create(const char *name,
pen_t vendor_id, u_int32_t subtype,
pen_type_t *supported_types, u_int32_t type_count,
TNC_IMCID id, TNC_Version *actual_version);
#endif /** IMC_AGENT_H_ @}*/
+47 -31
View File
@@ -40,19 +40,14 @@ struct private_imv_agent_t {
const char *name;
/**
* message vendor ID of IMV
* message types registered by IMV
*/
TNC_VendorID vendor_id;
pen_type_t *supported_types;
/**
* message subtype of IMV
* number of message types registered by IMV
*/
TNC_MessageSubtype subtype;
/**
* Maximum PA-TNC Message size
*/
size_t max_msg_len;
u_int32_t type_count;
/**
* ID of IMV as assigned by TNCS
@@ -258,17 +253,37 @@ METHOD(imv_agent_t, bind_functions, TNC_Result,
if (this->report_message_types_long)
{
this->report_message_types_long(this->id, &this->vendor_id,
&this->subtype, 1);
}
else if (this->report_message_types &&
this->vendor_id <= TNC_VENDORID_ANY &&
this->subtype <= TNC_SUBTYPE_ANY)
{
TNC_MessageType type;
TNC_VendorIDList vendor_id_list;
TNC_MessageSubtypeList subtype_list;
int i;
type = (this->vendor_id << 8) | this->subtype;
this->report_message_types(this->id, &type, 1);
vendor_id_list = malloc(this->type_count * sizeof(TNC_UInt32));
subtype_list = malloc(this->type_count * sizeof(TNC_UInt32));
for (i = 0; i < this->type_count; i++)
{
vendor_id_list[i] = this->supported_types[i].vendor_id;
subtype_list[i] = this->supported_types[i].type;
}
this->report_message_types_long(this->id, vendor_id_list, subtype_list,
this->type_count);
free(vendor_id_list);
free(subtype_list);
}
else if (this->report_message_types)
{
TNC_MessageTypeList type_list;
int i;
type_list = malloc(this->type_count * sizeof(TNC_UInt32));
for (i = 0; i < this->type_count; i++)
{
type_list[i] = (this->supported_types[i].vendor_id << 8) |
(this->supported_types[i].type & 0xff);
}
this->report_message_types(this->id, type_list, this->type_count);
free(type_list);
}
return TNC_RESULT_SUCCESS;
}
@@ -499,7 +514,8 @@ METHOD(imv_agent_t, get_state, bool,
METHOD(imv_agent_t, send_message, TNC_Result,
private_imv_agent_t *this, TNC_ConnectionID connection_id, bool excl,
TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id, linked_list_t *attr_list)
TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id, TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype, linked_list_t *attr_list)
{
TNC_MessageType type;
TNC_UInt32 msg_flags;
@@ -521,7 +537,7 @@ METHOD(imv_agent_t, send_message, TNC_Result,
while (attr_list->get_count(attr_list))
{
pa_tnc_msg = pa_tnc_msg_create(this->max_msg_len);
pa_tnc_msg = pa_tnc_msg_create(state->get_max_msg_len(state));
attr_added = FALSE;
enumerator = attr_list->create_enumerator(attr_list);
@@ -564,12 +580,12 @@ METHOD(imv_agent_t, send_message, TNC_Result,
msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
result = this->send_message_long(src_imv_id, connection_id,
msg_flags, msg.ptr, msg.len, this->vendor_id,
this->subtype, dst_imc_id);
msg_flags, msg.ptr, msg.len, msg_vid,
msg_subtype, dst_imc_id);
}
else if (this->send_message)
{
type = (this->vendor_id << 8) | this->subtype;
type = msg_vid << 8 | msg_subtype;
result = this->send_message(this->id, connection_id, msg.ptr,
msg.len, type);
@@ -664,7 +680,8 @@ METHOD(imv_agent_t, receive_message, TNC_Result,
dst_imc_id = state->has_excl(state) ? src_imc_id : TNC_IMCID_ANY;
result = send_message(this, connection_id, state->has_excl(state),
src_imv_id, dst_imc_id, error_attr_list);
src_imv_id, dst_imc_id, msg_vid, msg_subtype,
error_attr_list);
error_attr_list->destroy(error_attr_list);
pa_msg->destroy(pa_msg);
@@ -684,7 +701,7 @@ METHOD(imv_agent_t, receive_message, TNC_Result,
METHOD(imv_agent_t, provide_recommendation, TNC_Result,
private_imv_agent_t *this, TNC_ConnectionID connection_id,
TNC_UInt32 dst_imc_id)
TNC_UInt32 dst_imc_id, TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype)
{
imv_state_t *state;
linked_list_t *attr_list;
@@ -741,7 +758,7 @@ METHOD(imv_agent_t, provide_recommendation, TNC_Result,
attr_list = linked_list_create();
attr_list->insert_last(attr_list, attr);
result = send_message(this, connection_id, FALSE, this->id, dst_imc_id,
attr_list);
msg_vid, msg_subtype, attr_list);
attr_list->destroy(attr_list);
if (result != TNC_RESULT_SUCCESS)
{
@@ -814,7 +831,7 @@ METHOD(imv_agent_t, destroy, void,
* Described in header.
*/
imv_agent_t *imv_agent_create(const char *name,
pen_t vendor_id, u_int32_t subtype,
pen_type_t *supported_types, u_int32_t type_count,
TNC_IMVID id, TNC_Version *actual_version)
{
private_imv_agent_t *this;
@@ -842,9 +859,8 @@ imv_agent_t *imv_agent_create(const char *name,
.destroy = _destroy,
},
.name = name,
.vendor_id = vendor_id,
.subtype = subtype,
.max_msg_len = 65490,
.supported_types = supported_types,
.type_count = type_count,
.id = id,
.additional_ids = linked_list_create(),
.connections = linked_list_create(),
+12 -4
View File
@@ -106,12 +106,16 @@ struct imv_agent_t {
* @param excl exclusive flag
* @param src_imv_id IMV ID to be set as source
* @param dst_imc_id IMD ID to be set as destination
* @param msg_vid message vendor ID
* @param msg_subtype message subtype
* @param attr_list list of PA-TNC attributes to send
* @return TNC result code
*/
TNC_Result (*send_message)(imv_agent_t *this,
TNC_ConnectionID connection_id, bool excl,
TNC_UInt32 src_imv_id, TNC_UInt32 dst_imc_id,
TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype,
linked_list_t *attr_list);
/**
@@ -152,11 +156,15 @@ struct imv_agent_t {
*
* @param connection_id network connection ID assigned by TNCS
* @param dst_imc_id IMD ID to be set as destination
* @param msg_vid message vendor ID
* @param msg_subtype message subtype
* @return TNC result code
*/
TNC_Result (*provide_recommendation)(imv_agent_t *this,
TNC_ConnectionID connection_id,
TNC_UInt32 dst_imc_id);
TNC_UInt32 dst_imc_id,
TNC_VendorID msg_vid,
TNC_MessageSubtype msg_subtype);
/**
* Reserve additional IMV IDs from TNCS
@@ -188,14 +196,14 @@ struct imv_agent_t {
* Create an imv_agent_t object
*
* @param name name of the IMV
* @param vendor_id vendor ID of the IMV
* @param subtype message subtype of the IMV
* @param supported_types list of message types registered by the IMV
* @param type_count number of registered message types
* @param id ID of the IMV as assigned by the TNCS
* @param actual_version actual version of the IF-IMV API
*
*/
imv_agent_t *imv_agent_create(const char *name,
pen_t vendor_id, u_int32_t subtype,
pen_type_t *supported_types, u_int32_t type_count,
TNC_IMVID id, TNC_Version *actual_version);
#endif /** IMV_AGENT_H_ @}*/
+8 -6
View File
@@ -38,8 +38,9 @@
static const char imc_name[] = "OS";
#define IMC_VENDOR_ID PEN_IETF
#define IMC_SUBTYPE PA_SUBTYPE_IETF_OPERATING_SYSTEM
static pen_type_t msg_types[] = {
{ PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM }
};
static imc_agent_t *imc_os;
static os_info_t *os;
@@ -57,8 +58,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name);
return TNC_RESULT_ALREADY_INITIALIZED;
}
imc_os = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
imc_id, actual_version);
imc_os = imc_agent_create(imc_name, msg_types, 1, imc_id, actual_version);
if (!imc_os)
{
return TNC_RESULT_FATAL;
@@ -231,7 +231,8 @@ TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
add_fwd_enabled(attr_list);
add_default_pwd_enabled(attr_list);
result = imc_os->send_message(imc_os, connection_id, FALSE, 0,
TNC_IMVID_ANY, attr_list);
TNC_IMVID_ANY, PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM,
attr_list);
attr_list->destroy(attr_list);
}
@@ -356,7 +357,8 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
if (attr_list->get_count(attr_list))
{
result = imc_os->send_message(imc_os, connection_id, TRUE, imc_id,
src_imv_id, attr_list);
src_imv_id, PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM,
attr_list);
}
else
{
@@ -34,8 +34,9 @@
static const char imc_name[] = "Scanner";
#define IMC_VENDOR_ID PEN_ITA
#define IMC_SUBTYPE PA_SUBTYPE_ITA_SCANNER
static pen_type_t msg_types[] = {
{ PEN_ITA, PA_SUBTYPE_ITA_SCANNER }
};
static imc_agent_t *imc_scanner;
@@ -52,8 +53,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name);
return TNC_RESULT_ALREADY_INITIALIZED;
}
imc_scanner = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
imc_id, actual_version);
imc_scanner = imc_agent_create(imc_name, msg_types, 1, imc_id, actual_version);
if (!imc_scanner)
{
return TNC_RESULT_FATAL;
@@ -247,7 +247,8 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
attr_list = linked_list_create();
attr_list->insert_last(attr_list, attr);
result = imc_scanner->send_message(imc_scanner, connection_id, FALSE, 0,
TNC_IMVID_ANY, attr_list);
TNC_IMVID_ANY, PEN_ITA, PA_SUBTYPE_ITA_SCANNER,
attr_list);
attr_list->destroy(attr_list);
return result;
+6 -5
View File
@@ -33,8 +33,9 @@
static const char imc_name[] = "Test";
#define IMC_VENDOR_ID PEN_ITA
#define IMC_SUBTYPE PA_SUBTYPE_ITA_TEST
static pen_type_t msg_types[] = {
{ PEN_ITA, PA_SUBTYPE_ITA_TEST }
};
static imc_agent_t *imc_test;
@@ -51,8 +52,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
DBG1(DBG_IMC, "IMC \"%s\" has already been initialized", imc_name);
return TNC_RESULT_ALREADY_INITIALIZED;
}
imc_test = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
imc_id, actual_version);
imc_test = imc_agent_create(imc_name, msg_types, 1, imc_id, actual_version);
if (!imc_test)
{
return TNC_RESULT_FATAL;
@@ -208,7 +208,8 @@ static TNC_Result send_message(imc_state_t *state, TNC_UInt32 src_imc_id,
excl = dst_imv_id != TNC_IMVID_ANY;
result = imc_test->send_message(imc_test, connection_id, excl, src_imc_id,
dst_imv_id, attr_list);
dst_imv_id, PEN_ITA, PA_SUBTYPE_ITA_TEST,
attr_list);
attr_list->destroy(attr_list);
return result;
+12 -9
View File
@@ -39,8 +39,9 @@
static const char imv_name[] = "OS";
#define IMV_VENDOR_ID PEN_IETF
#define IMV_SUBTYPE PA_SUBTYPE_IETF_OPERATING_SYSTEM
static pen_type_t msg_types[] = {
{ PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM }
};
static imv_agent_t *imv_os;
@@ -57,8 +58,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
DBG1(DBG_IMV, "IMV \"%s\" has already been initialized", imv_name);
return TNC_RESULT_ALREADY_INITIALIZED;
}
imv_os = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
imv_id, actual_version);
imv_os = imv_agent_create(imv_name, msg_types, 1, imv_id, actual_version);
if (!imv_os)
{
return TNC_RESULT_FATAL;
@@ -285,11 +285,13 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
if (assessment)
{
attr_list->destroy_offset(attr_list, offsetof(pa_tnc_attr_t, destroy));
return imv_os->provide_recommendation(imv_os, connection_id, src_imc_id);
return imv_os->provide_recommendation(imv_os, connection_id, src_imc_id,
PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM);
}
result = imv_os->send_message(imv_os, connection_id, TRUE, imv_id,
src_imc_id, attr_list);
src_imc_id, PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM,
attr_list);
attr_list->destroy(attr_list);
return result;
@@ -343,8 +345,8 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
DBG1(DBG_IMV, "IMV \"%s\" has not been initialized", imv_name);
return TNC_RESULT_NOT_INITIALIZED;
}
return imv_os->provide_recommendation(imv_os, connection_id,
TNC_IMCID_ANY);
return imv_os->provide_recommendation(imv_os, connection_id, TNC_IMCID_ANY,
PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM);
}
/**
@@ -386,7 +388,8 @@ TNC_Result TNC_IMV_BatchEnding(TNC_IMVID imv_id,
attr_cast->add(attr_cast, PEN_IETF, IETF_ATTR_FACTORY_DEFAULT_PWD_ENABLED);
attr_list->insert_last(attr_list, attr);
result = imv_os->send_message(imv_os, connection_id, FALSE, imv_id,
TNC_IMCID_ANY, attr_list);
TNC_IMCID_ANY, PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM,
attr_list);
attr_list->destroy(attr_list);
}
@@ -33,8 +33,9 @@
static const char imv_name[] = "Scanner";
#define IMV_VENDOR_ID PEN_ITA
#define IMV_SUBTYPE PA_SUBTYPE_ITA_SCANNER
static pen_type_t msg_types[] = {
{ PEN_ITA, PA_SUBTYPE_ITA_SCANNER }
};
static imv_agent_t *imv_scanner;
@@ -124,8 +125,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
DBG1(DBG_IMV, "IMV \"%s\" has already been initialized", imv_name);
return TNC_RESULT_ALREADY_INITIALIZED;
}
imv_scanner = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
imv_id, actual_version);
imv_scanner = imv_agent_create(imv_name, msg_types, 1, imv_id, actual_version);
if (!imv_scanner)
{
return TNC_RESULT_FATAL;
@@ -310,7 +310,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_EVALUATION_RESULT_ERROR);
}
return imv_scanner->provide_recommendation(imv_scanner, connection_id,
src_imc_id);
src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_SCANNER);
}
/**
@@ -362,7 +362,7 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
return TNC_RESULT_NOT_INITIALIZED;
}
return imv_scanner->provide_recommendation(imv_scanner, connection_id,
TNC_IMCID_ANY);
TNC_IMCID_ANY, PEN_ITA, PA_SUBTYPE_ITA_SCANNER);
}
/**
+9 -8
View File
@@ -33,8 +33,9 @@
static const char imv_name[] = "Test";
#define IMV_VENDOR_ID PEN_ITA
#define IMV_SUBTYPE PA_SUBTYPE_ITA_TEST
static pen_type_t msg_types[] = {
{ PEN_ITA, PA_SUBTYPE_ITA_TEST }
};
static imv_agent_t *imv_test;
@@ -51,8 +52,7 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
DBG1(DBG_IMV, "IMV \"%s\" has already been initialized", imv_name);
return TNC_RESULT_ALREADY_INITIALIZED;
}
imv_test = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
imv_id, actual_version);
imv_test = imv_agent_create(imv_name, msg_types, 1, imv_id, actual_version);
if (!imv_test)
{
return TNC_RESULT_FATAL;
@@ -210,7 +210,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
TNC_IMV_EVALUATION_RESULT_ERROR);
return imv_test->provide_recommendation(imv_test, connection_id,
src_imc_id);
src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_TEST);
}
/* request a handshake retry ? */
@@ -228,14 +228,15 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
attr = ita_attr_command_create("repeat");
attr_list->insert_last(attr_list, attr);
result = imv_test->send_message(imv_test, connection_id, TRUE, imv_id,
src_imc_id, attr_list);
src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_TEST, attr_list);
attr_list->destroy(attr_list);
return result;
}
return received_command ? imv_test->provide_recommendation(imv_test,
connection_id, src_imc_id) : TNC_RESULT_SUCCESS;
connection_id, src_imc_id, PEN_ITA, PA_SUBTYPE_ITA_TEST) :
TNC_RESULT_SUCCESS;
}
/**
@@ -287,7 +288,7 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
return TNC_RESULT_NOT_INITIALIZED;
}
return imv_test->provide_recommendation(imv_test, connection_id,
TNC_IMCID_ANY);
TNC_IMCID_ANY, PEN_ITA, PA_SUBTYPE_ITA_TEST);
}
/**
@@ -42,11 +42,11 @@
static const char imc_name[] = "Attestation";
#define IMC_VENDOR_ID PEN_TCG
#define IMC_SUBTYPE PA_SUBTYPE_TCG_PTS
static pen_type_t msg_types[] = {
{ PEN_TCG, PA_SUBTYPE_TCG_PTS }
};
static imc_agent_t *imc_attestation;
static os_info_t *os;
/**
* Supported PTS measurement algorithms
@@ -76,22 +76,13 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
{
return TNC_RESULT_FATAL;
}
imc_attestation = imc_agent_create(imc_name, IMC_VENDOR_ID, IMC_SUBTYPE,
imc_id, actual_version);
imc_attestation = imc_agent_create(imc_name, msg_types, 1, imc_id,
actual_version);
if (!imc_attestation)
{
return TNC_RESULT_FATAL;
}
os = os_info_create();
if (!os)
{
imc_attestation->destroy(imc_attestation);
imc_attestation = NULL;
return TNC_RESULT_FATAL;
}
libpts_init();
if (min_version > TNC_IFIMC_VERSION_1 || max_version < TNC_IFIMC_VERSION_1)
@@ -147,27 +138,13 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
TNC_Result TNC_IMC_BeginHandshake(TNC_IMCID imc_id,
TNC_ConnectionID connection_id)
{
linked_list_t *attr_list;
pa_tnc_attr_t *attr;
TNC_Result result = TNC_RESULT_SUCCESS;
if (!imc_attestation)
{
DBG1(DBG_IMC, "IMC \"%s\" has not been initialized", imc_name);
return TNC_RESULT_NOT_INITIALIZED;
}
attr_list = linked_list_create();
attr = ietf_attr_product_info_create(0, 0, os->get_name(os));
attr_list->insert_last(attr_list, attr);
attr = ietf_attr_string_version_create(os->get_version(os),
chunk_empty, chunk_empty);
attr_list->insert_last(attr_list, attr);
result = imc_attestation->send_message(imc_attestation, connection_id,
FALSE, 0, TNC_IMVID_ANY, attr_list);
attr_list->destroy(attr_list);
return result;
return TNC_RESULT_SUCCESS;
}
static TNC_Result receive_message(TNC_IMCID imc_id,
@@ -272,7 +249,8 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
if (result == TNC_RESULT_SUCCESS && attr_list->get_count(attr_list))
{
result = imc_attestation->send_message(imc_attestation, connection_id,
FALSE, 0, TNC_IMVID_ANY, attr_list);
FALSE, 0, TNC_IMVID_ANY, PEN_TCG, PA_SUBTYPE_TCG_PTS,
attr_list);
}
attr_list->destroy(attr_list);
@@ -346,9 +324,6 @@ TNC_Result TNC_IMC_Terminate(TNC_IMCID imc_id)
imc_attestation->destroy(imc_attestation);
imc_attestation = NULL;
os->destroy(os);
os = NULL;
return TNC_RESULT_SUCCESS;
}
@@ -43,8 +43,10 @@
static const char imv_name[] = "Attestation";
#define IMV_VENDOR_ID PEN_TCG
#define IMV_SUBTYPE PA_SUBTYPE_TCG_PTS
static pen_type_t msg_types[] = {
{ PEN_TCG, PA_SUBTYPE_TCG_PTS },
{ PEN_IETF, PA_SUBTYPE_IETF_OPERATING_SYSTEM }
};
static imv_agent_t *imv_attestation;
@@ -93,8 +95,8 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
{
return TNC_RESULT_FATAL;
}
imv_attestation = imv_agent_create(imv_name, IMV_VENDOR_ID, IMV_SUBTYPE,
imv_id, actual_version);
imv_attestation = imv_agent_create(imv_name, msg_types, 2, imv_id,
actual_version);
if (!imv_attestation)
{
return TNC_RESULT_FATAL;
@@ -187,7 +189,8 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
if (attr_list->get_count(attr_list))
{
result = imv_attestation->send_message(imv_attestation,
connection_id, FALSE, 0, TNC_IMCID_ANY, attr_list);
connection_id, FALSE, 0, TNC_IMCID_ANY,
PEN_TCG, PA_SUBTYPE_TCG_PTS, attr_list);
}
else
{
@@ -331,13 +334,14 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_ACTION_RECOMMENDATION_ISOLATE,
TNC_IMV_EVALUATION_RESULT_ERROR);
return imv_attestation->provide_recommendation(imv_attestation,
connection_id, src_imc_id);
connection_id, src_imc_id, PEN_TCG, PA_SUBTYPE_TCG_PTS);
}
if (attr_list->get_count(attr_list))
{
result = imv_attestation->send_message(imv_attestation, connection_id,
FALSE, 0, TNC_IMCID_ANY, attr_list);
FALSE, 0, TNC_IMCID_ANY, PEN_TCG, PA_SUBTYPE_TCG_PTS,
attr_list);
attr_list->destroy(attr_list);
return result;
}
@@ -351,7 +355,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
TNC_IMV_EVALUATION_RESULT_ERROR);
return imv_attestation->provide_recommendation(imv_attestation,
connection_id, src_imc_id);
connection_id, src_imc_id, PEN_TCG, PA_SUBTYPE_TCG_PTS);
}
if (attestation_state->get_handshake_state(attestation_state) ==
@@ -376,7 +380,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_EVALUATION_RESULT_COMPLIANT);
}
return imv_attestation->provide_recommendation(imv_attestation,
connection_id, src_imc_id);
connection_id, src_imc_id, PEN_TCG, PA_SUBTYPE_TCG_PTS);
}
return result;
@@ -431,7 +435,7 @@ TNC_Result TNC_IMV_SolicitRecommendation(TNC_IMVID imv_id,
return TNC_RESULT_NOT_INITIALIZED;
}
return imv_attestation->provide_recommendation(imv_attestation,
connection_id, TNC_IMCID_ANY);
connection_id, TNC_IMCID_ANY, PEN_TCG, PA_SUBTYPE_TCG_PTS);
}
/**