added TNC_TNCC_GetAttribute() and TNC_TNCC_SetAttribute() functions
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 8 Dec 2011 13:52:08 +0000 (14:52 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 8 Dec 2011 13:52:08 +0000 (14:52 +0100)
src/libcharon/plugins/tnc_imc/tnc_imc_bind_function.c
src/libcharon/plugins/tnc_imv/tnc_imv_bind_function.c
src/libcharon/plugins/tnc_tnccs/tnc_tnccs_manager.c
src/libtnccs/tnc/tnccs/tnccs_manager.h

index 95293c9..90a607c 100644 (file)
@@ -121,6 +121,47 @@ TNC_Result TNC_TNCC_SendMessageLong(TNC_IMCID imc_id,
 }
 
 /**
+ * Called by the IMC to get the value of an attribute associated with a
+ * connection or with the TNCC as a whole.
+ */
+TNC_Result TNC_TNCC_GetAttribute(TNC_IMCID imc_id,
+                                                                TNC_ConnectionID connection_id,
+                                                                TNC_AttributeID attribute_id,
+                                                                TNC_UInt32 buffer_len,
+                                                                TNC_BufferReference buffer,
+                                                                TNC_UInt32 *out_value_len)
+{
+       if (!tnc->imcs->is_registered(tnc->imcs, imc_id))
+       {
+               DBG1(DBG_TNC, "ignoring GetAttribute() from unregistered IMC %u",
+                                          imc_id);
+               return TNC_RESULT_INVALID_PARAMETER;
+       }
+       return tnc->tnccs->get_attribute(tnc->tnccs, TRUE, imc_id, connection_id,
+                                                       attribute_id, buffer_len, buffer, out_value_len);
+}
+
+/**
+ * Called by the IMC to set the value of an attribute associated with a
+ * connection or with the TNCC as a whole.
+ */
+TNC_Result TNC_TNCC_SetAttribute(TNC_IMCID imc_id,
+                                                                TNC_ConnectionID connection_id,
+                                                                TNC_AttributeID attribute_id,
+                                                                TNC_UInt32 buffer_len,
+                                                                TNC_BufferReference buffer)
+{
+       if (!tnc->imcs->is_registered(tnc->imcs, imc_id))
+       {
+               DBG1(DBG_TNC, "ignoring SetAttribute() from unregistered IMC %u",
+                                          imc_id);
+               return TNC_RESULT_INVALID_PARAMETER;
+       }
+       return tnc->tnccs->set_attribute(tnc->tnccs, TRUE, imc_id, connection_id,
+                                                                        attribute_id, buffer_len, buffer);
+}
+
+/**
  * Called by the IMC when it wants to reserve an additional IMC ID for itself
  */
 TNC_Result TNC_TNCC_ReserveAdditionalIMCID(TNC_IMCID imc_id, TNC_UInt32 *new_id)
@@ -161,6 +202,14 @@ TNC_Result TNC_TNCC_BindFunction(TNC_IMCID id,
        {
                *function_pointer = (void*)TNC_TNCC_SendMessageLong;
        }
+       else if (streq(function_name, "TNC_TNCC_GetAttribute"))
+       {
+               *function_pointer = (void*)TNC_TNCC_GetAttribute;
+       }
+       else if (streq(function_name, "TNC_TNCC_SetAttribute"))
+       {
+               *function_pointer = (void*)TNC_TNCC_SetAttribute;
+       }
     else if (streq(function_name, "TNC_TNCC_ReserveAdditionalIMCID"))
        {
                *function_pointer = (void*)TNC_TNCC_ReserveAdditionalIMCID;
index f24aaac..dd11c50 100644 (file)
@@ -157,7 +157,7 @@ TNC_Result TNC_TNCS_GetAttribute(TNC_IMVID imv_id,
                                           imv_id);
                return TNC_RESULT_INVALID_PARAMETER;
        }
-       return tnc->tnccs->get_attribute(tnc->tnccs, imv_id, connection_id,
+       return tnc->tnccs->get_attribute(tnc->tnccs, FALSE, imv_id, connection_id,
                                                        attribute_id, buffer_len, buffer, out_value_len);
 }
 
@@ -177,7 +177,7 @@ TNC_Result TNC_TNCS_SetAttribute(TNC_IMVID imv_id,
                                           imv_id);
                return TNC_RESULT_INVALID_PARAMETER;
        }
-       return tnc->tnccs->set_attribute(tnc->tnccs, imv_id, connection_id,
+       return tnc->tnccs->set_attribute(tnc->tnccs, FALSE, imv_id, connection_id,
                                                                         attribute_id, buffer_len, buffer);
 }
 
index e6674ae..5a21556 100644 (file)
@@ -368,7 +368,8 @@ METHOD(tnccs_manager_t, provide_recommendation, TNC_Result,
 }
 
 METHOD(tnccs_manager_t, get_attribute, TNC_Result,
-       private_tnc_tnccs_manager_t *this, TNC_IMVID imv_id,
+       private_tnc_tnccs_manager_t *this, bool is_imc,
+                                                                          TNC_UInt32 imcv_id,
                                                                           TNC_ConnectionID id,
                                                                           TNC_AttributeID attribute_id,
                                                                           TNC_UInt32 buffer_len,
@@ -379,7 +380,7 @@ METHOD(tnccs_manager_t, get_attribute, TNC_Result,
        tnccs_connection_entry_t *entry;
        recommendations_t *recs = NULL;
 
-       if (id == TNC_CONNECTIONID_ANY ||
+       if (is_imc || id == TNC_CONNECTIONID_ANY ||
                attribute_id != TNC_ATTRIBUTEID_PREFERRED_LANGUAGE)
        {
                return TNC_RESULT_INVALID_PARAMETER;
@@ -418,7 +419,8 @@ METHOD(tnccs_manager_t, get_attribute, TNC_Result,
 }
 
 METHOD(tnccs_manager_t, set_attribute, TNC_Result,
-       private_tnc_tnccs_manager_t *this, TNC_IMVID imv_id,
+       private_tnc_tnccs_manager_t *this, bool is_imc,
+                                                                          TNC_UInt32 imcv_id,
                                                                           TNC_ConnectionID id,
                                                                           TNC_AttributeID attribute_id,
                                                                           TNC_UInt32 buffer_len,
@@ -428,7 +430,7 @@ METHOD(tnccs_manager_t, set_attribute, TNC_Result,
        tnccs_connection_entry_t *entry;
        recommendations_t *recs = NULL;
 
-       if (id == TNC_CONNECTIONID_ANY ||
+       if (is_imc || id == TNC_CONNECTIONID_ANY ||
                (attribute_id != TNC_ATTRIBUTEID_REASON_STRING &&
                 attribute_id != TNC_ATTRIBUTEID_REASON_LANGUAGE))
        {
@@ -454,11 +456,11 @@ METHOD(tnccs_manager_t, set_attribute, TNC_Result,
 
                if (attribute_id == TNC_ATTRIBUTEID_REASON_STRING)
                {
-                       return recs->set_reason_string(recs, imv_id, attribute);
+                       return recs->set_reason_string(recs, imcv_id, attribute);
                }
                else
                {
-                       return recs->set_reason_language(recs, imv_id, attribute);
+                       return recs->set_reason_language(recs, imcv_id, attribute);
                }
        }
        return TNC_RESULT_INVALID_PARAMETER;
index 0720fb4..fb5eaf5 100644 (file)
@@ -142,7 +142,8 @@ struct tnccs_manager_t {
         * Get the value of an attribute associated with a connection or with the
         * TNCS as a whole.
         *
-        * @param imv_id                        ID of the IMV requesting the attribute
+        * @param is_imc                        TRUE if IMC, FALSE if IMV
+        * @param imcv_id                       ID of the IMC/IMV requesting the attribute
         * @param id                            ID of target connection
         * @param attribute_id          ID of the requested attribute
         * @param buffer_len            length of the buffer in bytes
@@ -150,8 +151,8 @@ struct tnccs_manager_t {
         * @param out_value_len         actual length of the returned attribute
         * @return                                      return code
         */
-       TNC_Result (*get_attribute)(tnccs_manager_t *this,
-                                                          TNC_IMVID imv_id,
+       TNC_Result (*get_attribute)(tnccs_manager_t *this, bool is_imc,
+                                                          TNC_UInt32 imcv_id,
                                                           TNC_ConnectionID id,
                                                           TNC_AttributeID attribute_id,
                                                           TNC_UInt32 buffer_len,
@@ -162,15 +163,16 @@ struct tnccs_manager_t {
         * Set the value of an attribute associated with a connection or with the
         * TNCS as a whole.
         *
-        * @param imv_id                        ID of the IMV setting the attribute
+        * @param is_imc                        TRUE if IMC, FALSE if IMV
+        * @param imcv_id                       ID of the IMC/IMV setting the attribute
         * @param id                            ID of target connection
         * @param attribute_id          ID of the attribute to be set
         * @param buffer_len            length of the buffer in bytes
         * @param buffer                        pointer to the buffer
         * @return                                      return code
         */
-       TNC_Result (*set_attribute)(tnccs_manager_t *this,
-                                                               TNC_IMVID imv_id,
+       TNC_Result (*set_attribute)(tnccs_manager_t *this, bool is_imc,
+                                                               TNC_UInt32 imcv_id,
                                                                TNC_ConnectionID id,
                                                                TNC_AttributeID attribute_id,
                                                                TNC_UInt32 buffer_len,