]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
added TNC_IMC_ReceiveMessageLong() and TNC_IMV_ReceiveMessageLong() support
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 8 Dec 2011 11:38:45 +0000 (12:38 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 8 Dec 2011 11:38:45 +0000 (12:38 +0100)
src/libcharon/plugins/tnc_imc/tnc_imc.c
src/libcharon/plugins/tnc_imc/tnc_imc_manager.c
src/libcharon/plugins/tnc_imv/tnc_imv.c
src/libcharon/plugins/tnc_imv/tnc_imv_manager.c
src/libcharon/plugins/tnccs_11/tnccs_11.c
src/libcharon/plugins/tnccs_20/tnccs_20.c
src/libtnccs/tnc/imc/imc.h
src/libtnccs/tnc/imc/imc_manager.h
src/libtnccs/tnc/imv/imv.h
src/libtnccs/tnc/imv/imv_manager.h

index 6bd69dc874405eb7f83dbb9540f9966ebd4b28de..dc326cf4d14c51710d174dcf4927c35f98daec6f 100644 (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 =
index 5e06d9eb451a4119b835703820f3fdd31aa0c7b3..4ea01e49b9b71233ee43a403250f4c77f09d8beb 100644 (file)
@@ -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);
        }
 }
 
index 7d7b668c4996587dd5e2877fb56bc161f8f203c0..7ea23f5b4fe8493b1bce233dd5eebdc4687a9a46 100644 (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];
index 3231248542741b1e19ccc28c742d01bb9d461d33..10a4adc463b599598d89eaa02ce8e2f8a51a034c 100644 (file)
@@ -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);
        }
 }
 
index 835ddf1333a67c1da07e8a5b309ba78c58c832c2..37ead6e4bd2e6f6d7be3f646be31ac05d3bbba64 100644 (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;
index fe0ba985b203f22afb0898bd0816fb492f5b1320..ca72b854f5422fb32ebbc199b38117638359457a 100644 (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;
index 3794fd26d4b81527b0b4e49a00038811119662cb..3ff7d5194e3558d6b0428df8bff59fe9d182e653 100644 (file)
@@ -94,6 +94,33 @@ struct imc_t {
                                                                  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
@@ -187,10 +214,12 @@ struct imc_t {
        /**
         * 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.
index ef2dcc6540994ffa53e96d43c0623b3d9732f761..25e0efe9d3072b1c899ae91ec4568622d1d7ab92 100644 (file)
@@ -128,16 +128,24 @@ struct imc_manager_t {
        /**
         * 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
index 67de8a47b97bc99bf49748dd46c06246a3d2a243..3716532d672e9b64ac3d6501c74bc13b51480772 100644 (file)
@@ -95,6 +95,33 @@ struct imv_t {
                                                                  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
@@ -187,10 +214,12 @@ struct imv_t {
        /**
         * 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.
index 780d0f6259b0e16a4cb2d135273edfdae234f841..43f40973c65230b878da21c0852e869a9d42e1aa 100644 (file)
@@ -149,16 +149,24 @@ struct imv_manager_t {
        /**
         * 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