}
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];
}
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 =
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);
}
}
}
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];
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);
}
}
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;
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;
TNC_UInt32 messageLength,
TNC_MessageType messageType);
+ /**
+ * The TNC Client calls this function to deliver a message to the IMC.
+ * The message is contained in the buffer referenced by message and contains
+ * the number of octets indicated by messageLength. The type of the message
+ * is indicated by the message Vendor ID and message subtype.
+ *
+ * @param imcID IMC ID assigned by TNCS
+ * @param connectionID network connection ID assigned by TNCC
+ * @param messageFlags message flags
+ * @param message reference to buffer containing message
+ * @param messageLength number of octets in message
+ * @param messageVendorID message Vendor ID
+ * @param messageSubtype message subtype
+ * @param sourceIMVID source IMV ID
+ * @param destinationIMCID destination IMC ID
+ * @return TNC result code
+ */
+ TNC_Result (*receive_message_long)(TNC_IMCID imcID,
+ TNC_ConnectionID connectionID,
+ TNC_UInt32 messageFlags,
+ TNC_BufferReference message,
+ TNC_UInt32 messageLength,
+ TNC_VendorID messageVendorID,
+ TNC_MessageSubtype messageSubtype,
+ TNC_UInt32 sourceIMVID,
+ TNC_UInt32 destinationIMCID);
+
/**
* The TNC Client calls this function to notify IMCs that all IMV messages
* received in a batch have been delivered and this is the IMC’s last chance
/**
* Check if the IMC supports a given message type.
*
- * @param message_type message type
+ * @param msg_vid message vendor ID
+ * @param msg_subtype message subtype
* @return TRUE if supported
*/
- bool (*type_supported)(imc_t *this, TNC_MessageType message_type);
+ bool (*type_supported)(imc_t *this, TNC_VendorID msg_vid,
+ TNC_MessageSubtype msg_subtype);
/**
* Destroys an imc_t object.
/**
* Delivers a message to interested IMCs.
*
- * @param connection_id ID of connection over which message was received
- * @param message message
- * @param message_len message length
- * @param message_type message type
+ * @param connection_id connection ID
+ * @param excl exclusive message flag
+ * @param msg message
+ * @param msg_len message length
+ * @param msg_vid message Vendor ID
+ * @param msg_subtype message subtype
+ * @param src_imv_id source IMV ID
+ * @param dst_imc_id destination IMC ID
*/
void (*receive_message)(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);
/**
* Notify all IMCs that all IMV messages received in a batch have been
TNC_UInt32 messageLength,
TNC_MessageType messageType);
+ /**
+ * The TNC Server calls this function to deliver a message to the IMV.
+ * The message is contained in the buffer referenced by message and contains
+ * the number of octets indicated by messageLength. The type of the message
+ * is indicated by the message Vendor ID and message subtype.
+ *
+ * @param imvID IMV ID assigned by TNCS
+ * @param connectionID network connection ID assigned by TNCS
+ * @param messageFlags message flags
+ * @param message reference to buffer containing message
+ * @param messageLength number of octets in message
+ * @param messageVendorID message Vendor ID
+ * @param messageSubtype message subtype
+ * @param sourceIMCID source IMC ID
+ * @param destinationIMVID destination IMV ID
+ * @return TNC result code
+ */
+ TNC_Result (*receive_message_long)(TNC_IMVID imvID,
+ TNC_ConnectionID connectionID,
+ TNC_UInt32 messageFlags,
+ TNC_BufferReference message,
+ TNC_UInt32 messageLength,
+ TNC_VendorID messageVendorID,
+ TNC_MessageSubtype messageSubtype,
+ TNC_UInt32 sourceIMCID,
+ TNC_UInt32 destinationIMVID);
+
/**
* The TNC Server calls this function to notify IMVs that all IMC messages
* received in a batch have been delivered and this is the IMV’s last chance
/**
* Check if the IMV supports a given message type.
*
- * @param message_type message type
+ * @param msg_vid message vendor ID
+ * @param msg_subtype message subtype
* @return TRUE if supported
*/
- bool (*type_supported)(imv_t *this, TNC_MessageType message_type);
+ bool (*type_supported)(imv_t *this, TNC_VendorID msg_vid,
+ TNC_MessageSubtype msg_subtype);
/**
* Destroys an imv_t object.
/**
* Delivers a message to interested IMVs.
*
- * @param connection_id ID of connection over which message was received
- * @param message message
- * @param message_len message length
- * @param message_type message type
+ * @param connection_id connection ID
+ * @param excl exclusive message flag
+ * @param msg message
+ * @param msg_len message length
+ * @param msg_vid message Vendor ID
+ * @param msg_subtype message subtype
+ * @param src_imc_id source IMC ID
+ * @param dst_imv_id destination IMV ID
*/
void (*receive_message)(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);
/**
* Notify all IMVs that all IMC messages received in a batch have been