implemented receive_message() function

This commit is contained in:
Andreas Steffen
2010-11-09 20:43:50 +01:00
parent 296636252b
commit e6b6fc881f
9 changed files with 172 additions and 2 deletions
+28
View File
@@ -84,6 +84,33 @@ METHOD(imc_t, set_message_types, void,
}
}
METHOD(imc_t, type_supported, bool,
private_tnc_imc_t *this, TNC_MessageType message_type)
{
TNC_VendorID msg_vid, vid;
TNC_MessageSubtype msg_subtype, subtype;
int i;
msg_vid = (message_type >> 8) & TNC_VENDORID_ANY;
msg_subtype = message_type & TNC_SUBTYPE_ANY;
for (i = 0; i < this->type_count; i++)
{
vid = (this->supported_types[i] >> 8) & TNC_VENDORID_ANY;
subtype = this->supported_types[i] & TNC_SUBTYPE_ANY;
if (this->supported_types[i] == message_type
|| (subtype == TNC_SUBTYPE_ANY
&& (msg_vid == vid || vid == TNC_VENDORID_ANY))
|| (vid == TNC_VENDORID_ANY
&& (msg_subtype == subtype || subtype == TNC_SUBTYPE_ANY)))
{
return TRUE;
}
}
return FALSE;
}
METHOD(imc_t, destroy, void,
private_tnc_imc_t *this)
{
@@ -106,6 +133,7 @@ imc_t* tnc_imc_create(char* name, char *filename)
.get_id = _get_id,
.get_name = _get_name,
.set_message_types = _set_message_types,
.type_supported = _type_supported,
.destroy = _destroy,
},
);
@@ -124,6 +124,26 @@ METHOD(imc_manager_t, set_message_types, TNC_Result,
return result;
}
METHOD(imc_manager_t, receive_message, void,
private_tnc_imc_manager_t *this, TNC_ConnectionID connection_id,
TNC_BufferReference message,
TNC_UInt32 message_len,
TNC_MessageType message_type)
{
enumerator_t *enumerator;
imc_t *imc;
enumerator = this->imcs->create_enumerator(this->imcs);
while (enumerator->enumerate(enumerator, &imc))
{
if (imc->receive_message && imc->type_supported(imc, message_type))
{
imc->receive_message(imc->get_id(imc), connection_id,
message, message_len, message_type);
}
}
enumerator->destroy(enumerator);
}
METHOD(imc_manager_t, destroy, void,
private_tnc_imc_manager_t *this)
@@ -157,6 +177,7 @@ imc_manager_t* tnc_imc_manager_create(void)
.notify_connection_change = _notify_connection_change,
.begin_handshake = _begin_handshake,
.set_message_types = _set_message_types,
.receive_message = _receive_message,
.destroy = _destroy,
},
.imcs = linked_list_create(),