added TNC_IMC_ReceiveMessageLong() and TNC_IMV_ReceiveMessageLong() support

This commit is contained in:
Andreas Steffen
2011-12-08 12:38:45 +01:00
parent 115d49a748
commit 584282d7c9
10 changed files with 192 additions and 69 deletions
+5 -6
View File
@@ -279,15 +279,12 @@ METHOD(imc_t, set_message_types_long, void,
}
METHOD(imc_t, type_supported, bool,
private_tnc_imc_t *this, TNC_MessageType message_type)
private_tnc_imc_t *this, TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype)
{
TNC_VendorID msg_vid, vid;
TNC_MessageSubtype msg_subtype, subtype;
TNC_VendorID vid;
TNC_MessageSubtype 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_vids[i];
@@ -371,6 +368,8 @@ imc_t* tnc_imc_create(char *name, char *path)
}
this->public.receive_message =
dlsym(this->handle, "TNC_IMC_ReceiveMessage");
this->public.receive_message_long =
dlsym(this->handle, "TNC_IMC_ReceiveMessageLong");
this->public.batch_ending =
dlsym(this->handle, "TNC_IMC_BatchEnding");
this->public.terminate =
@@ -253,28 +253,50 @@ METHOD(imc_manager_t, set_message_types_long, TNC_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)
bool excl,
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)
{
bool type_supported = FALSE;
TNC_MessageType msg_type;
TNC_UInt32 msg_flags;
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))
if (imc->type_supported(imc, msg_vid, msg_subtype) &&
(!excl || (excl && imc->has_id(imc, dst_imc_id)) ))
{
type_supported = TRUE;
imc->receive_message(imc->get_id(imc), connection_id,
message, message_len, message_type);
if (imc->receive_message_long && src_imv_id)
{
type_supported = TRUE;
msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
imc->receive_message_long(imc->get_id(imc), connection_id,
msg_flags, msg, msg_len, msg_vid, msg_subtype,
src_imv_id, dst_imc_id);
}
else if (imc->receive_message && msg_vid <= TNC_VENDORID_ANY &&
msg_subtype <= TNC_SUBTYPE_ANY)
{
type_supported = TRUE;
msg_type = (msg_vid << 8) | msg_subtype;
imc->receive_message(imc->get_id(imc), connection_id,
msg, msg_len, msg_type);
}
}
}
enumerator->destroy(enumerator);
if (!type_supported)
{
DBG2(DBG_TNC, "message type 0x%08x not supported by any IMC", message_type);
DBG2(DBG_TNC, "message type 0x%06x/0x%08x not supported by any IMC",
msg_vid, msg_subtype);
}
}
+3 -6
View File
@@ -279,15 +279,12 @@ METHOD(imv_t, set_message_types_long, void,
}
METHOD(imv_t, type_supported, bool,
private_tnc_imv_t *this, TNC_MessageType message_type)
private_tnc_imv_t *this, TNC_VendorID msg_vid, TNC_MessageSubtype msg_subtype)
{
TNC_VendorID msg_vid, vid;
TNC_MessageSubtype msg_subtype, subtype;
TNC_VendorID vid;
TNC_MessageSubtype 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_vids[i];
@@ -331,28 +331,52 @@ METHOD(imv_manager_t, solicit_recommendation, void,
METHOD(imv_manager_t, receive_message, void,
private_tnc_imv_manager_t *this, TNC_ConnectionID connection_id,
TNC_BufferReference message,
TNC_UInt32 message_len,
TNC_MessageType message_type)
bool excl,
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)
{
bool type_supported = FALSE;
TNC_MessageType msg_type;
TNC_UInt32 msg_flags;
enumerator_t *enumerator;
imv_t *imv;
msg_type = (msg_vid << 8) | msg_subtype;
enumerator = this->imvs->create_enumerator(this->imvs);
while (enumerator->enumerate(enumerator, &imv))
{
if (imv->receive_message && imv->type_supported(imv, message_type))
if (imv->type_supported(imv, msg_vid, msg_subtype) &&
(!excl || (excl && imv->has_id(imv, dst_imv_id)) ))
{
type_supported = TRUE;
imv->receive_message(imv->get_id(imv), connection_id,
message, message_len, message_type);
if (imv->receive_message_long && src_imc_id)
{
type_supported = TRUE;
msg_flags = excl ? TNC_MESSAGE_FLAGS_EXCLUSIVE : 0;
imv->receive_message_long(imv->get_id(imv), connection_id,
msg_flags, msg, msg_len, msg_vid, msg_subtype,
src_imc_id, dst_imv_id);
}
else if (imv->receive_message && msg_vid <= TNC_VENDORID_ANY &&
msg_subtype <= TNC_SUBTYPE_ANY)
{
type_supported = TRUE;
msg_type = (msg_vid << 8) | msg_subtype;
imv->receive_message(imv->get_id(imv), connection_id,
msg, msg_len, msg_type);
}
}
}
enumerator->destroy(enumerator);
if (!type_supported)
{
DBG2(DBG_TNC, "message type 0x%08x not supported by any IMV", message_type);
DBG2(DBG_TNC, "message type 0x%06x/0x%08x not supported by any IMV",
msg_vid, msg_subtype);
}
}
+13 -11
View File
@@ -160,38 +160,40 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
imc_imv_msg_t *imc_imv_msg;
TNC_MessageType msg_type;
chunk_t msg_body;
u_int32_t vendor_id, subtype;
u_int32_t msg_vid, msg_subtype;
enum_name_t *pa_subtype_names;
imc_imv_msg = (imc_imv_msg_t*)msg;
msg_type = imc_imv_msg->get_msg_type(imc_imv_msg);
msg_body = imc_imv_msg->get_msg_body(imc_imv_msg);
vendor_id = msg_type >> 8;
subtype = msg_type & 0xff;
msg_vid = (msg_type >> 8) & TNC_VENDORID_ANY;
msg_subtype = msg_type & TNC_SUBTYPE_ANY;
pa_subtype_names = get_pa_subtype_names(vendor_id);
pa_subtype_names = get_pa_subtype_names(msg_vid);
if (pa_subtype_names)
{
DBG2(DBG_TNC, "handling IMC-IMV message type '%N/%N' 0x%06x/0x%02x",
pen_names, vendor_id, pa_subtype_names, subtype,
vendor_id, subtype);
pen_names, msg_vid, pa_subtype_names, msg_subtype,
msg_vid, msg_subtype);
}
else
{
DBG2(DBG_TNC, "handling IMC-IMV message type '%N' 0x%06x/0x%02x",
pen_names, vendor_id, vendor_id, subtype);
pen_names, msg_vid, msg_vid, msg_subtype);
}
this->send_msg = TRUE;
if (this->is_server)
{
tnc->imvs->receive_message(tnc->imvs,
this->connection_id, msg_body.ptr, msg_body.len, msg_type);
tnc->imvs->receive_message(tnc->imvs, this->connection_id,
FALSE, msg_body.ptr, msg_body.len,
msg_vid, msg_subtype, 0, TNC_IMVID_ANY);
}
else
{
tnc->imcs->receive_message(tnc->imcs,
this->connection_id, msg_body.ptr, msg_body.len,msg_type);
tnc->imcs->receive_message(tnc->imcs, this->connection_id,
FALSE, msg_body.ptr, msg_body.len,
msg_vid, msg_subtype, 0, TNC_IMCID_ANY);
}
this->send_msg = FALSE;
break;
+17 -12
View File
@@ -167,39 +167,44 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
case PB_MSG_PA:
{
pb_pa_msg_t *pa_msg;
TNC_MessageType msg_type;
u_int32_t vendor_id, subtype;
u_int32_t msg_vid, msg_subtype;
u_int16_t imc_id, imv_id;
chunk_t msg_body;
bool excl;
enum_name_t *pa_subtype_names;
pa_msg = (pb_pa_msg_t*)msg;
vendor_id = pa_msg->get_vendor_id(pa_msg, &subtype);
msg_type = (vendor_id << 8) | (subtype & 0xff);
msg_vid = pa_msg->get_vendor_id(pa_msg, &msg_subtype);
msg_body = pa_msg->get_body(pa_msg);
imc_id = pa_msg->get_collector_id(pa_msg);
imv_id = pa_msg->get_validator_id(pa_msg);
excl = pa_msg->get_exclusive_flag(pa_msg);
pa_subtype_names = get_pa_subtype_names(vendor_id);
pa_subtype_names = get_pa_subtype_names(msg_vid);
if (pa_subtype_names)
{
DBG2(DBG_TNC, "handling PB-PA message type '%N/%N' 0x%06x/0x%08x",
pen_names, vendor_id, pa_subtype_names, subtype,
vendor_id, subtype);
pen_names, msg_vid, pa_subtype_names, msg_subtype,
msg_vid, msg_subtype);
}
else
{
DBG2(DBG_TNC, "handling PB-PA message type '%N' 0x%06x/0x%08x",
pen_names, vendor_id, vendor_id, subtype);
pen_names, msg_vid, msg_vid, msg_subtype);
}
this->send_msg = TRUE;
if (this->is_server)
{
tnc->imvs->receive_message(tnc->imvs,
this->connection_id, msg_body.ptr, msg_body.len, msg_type);
tnc->imvs->receive_message(tnc->imvs, this->connection_id,
excl, msg_body.ptr, msg_body.len,
msg_vid, msg_subtype, imc_id, imv_id);
}
else
{
tnc->imcs->receive_message(tnc->imcs,
this->connection_id, msg_body.ptr, msg_body.len,msg_type);
tnc->imcs->receive_message(tnc->imcs, this->connection_id,
excl, msg_body.ptr, msg_body.len,
msg_vid, msg_subtype, imv_id, imc_id);
}
this->send_msg = FALSE;
break;