aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/tnc_imc
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-11-07 01:17:21 +0100
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-11-09 20:43:50 +0100
commite6b6fc881f70211a1510cf2a23230b6fc546e59c (patch)
treeb34f098383803062b3de65ad4f5facd25f86ceab /src/libcharon/plugins/tnc_imc
parent296636252b514846bd3ec83fbeff6fe40c301745 (diff)
downloadstrongswan-e6b6fc881f70211a1510cf2a23230b6fc546e59c.tar.bz2
strongswan-e6b6fc881f70211a1510cf2a23230b6fc546e59c.tar.xz
implemented receive_message() function
Diffstat (limited to 'src/libcharon/plugins/tnc_imc')
-rw-r--r--src/libcharon/plugins/tnc_imc/tnc_imc.c28
-rw-r--r--src/libcharon/plugins/tnc_imc/tnc_imc_manager.c21
2 files changed, 49 insertions, 0 deletions
diff --git a/src/libcharon/plugins/tnc_imc/tnc_imc.c b/src/libcharon/plugins/tnc_imc/tnc_imc.c
index f87853bf9..29f34d939 100644
--- a/src/libcharon/plugins/tnc_imc/tnc_imc.c
+++ b/src/libcharon/plugins/tnc_imc/tnc_imc.c
@@ -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,
},
);
diff --git a/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c b/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
index e6555cb51..8e0564446 100644
--- a/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
+++ b/src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
@@ -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(),