allow registration of multiple message type
This commit is contained in:
+44
-22
@@ -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(),
|
||||
|
||||
@@ -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_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user