]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Do not send empty PA-TNC message
authorSansar Choinyambuu <schoinya@hsr.ch>
Wed, 7 Dec 2011 09:38:23 +0000 (10:38 +0100)
committerSansar Choinyambuu <schoinya@hsr.ch>
Wed, 7 Dec 2011 09:38:23 +0000 (10:38 +0100)
src/libimcv/pa_tnc/pa_tnc_msg.c
src/libimcv/pa_tnc/pa_tnc_msg.h
src/libpts/plugins/imv_attestation/imv_attestation.c
src/libpts/plugins/imv_attestation/imv_attestation_build.c

index f8d3b9d0e8034a52cfd3f3bcf084f76bac98e53f..bcb5427ce220e503824c6af95f523eaba8f62d8f 100644 (file)
@@ -317,6 +317,12 @@ METHOD(pa_tnc_msg_t, create_attribute_enumerator, enumerator_t*,
        return this->attributes->create_enumerator(this->attributes);
 }
 
+METHOD(pa_tnc_msg_t, get_attribute_count, int,
+       private_pa_tnc_msg_t *this)
+{
+       return this->attributes->get_count(this->attributes);
+}
+
 METHOD(pa_tnc_msg_t, create_error_enumerator, enumerator_t*,
        private_pa_tnc_msg_t *this)
 {
@@ -348,6 +354,7 @@ pa_tnc_msg_t *pa_tnc_msg_create_from_data(chunk_t data)
                        .build = _build,
                        .process = _process,
                        .create_attribute_enumerator = _create_attribute_enumerator,
+                       .get_attribute_count = _get_attribute_count,
                        .create_error_enumerator = _create_error_enumerator,
                        .destroy = _destroy,
                },
index bff954678e6279586581548ad4e7411378c87c7f..97e9344e91211dc3e5960fd3a2644907a370a321 100644 (file)
@@ -68,6 +68,13 @@ struct pa_tnc_msg_t {
         */
        enumerator_t* (*create_attribute_enumerator)(pa_tnc_msg_t *this);
 
+       /**
+        * Get Count of the PA-TNC attributes
+        *
+        * @return                              return attributes count
+        */
+       int (*get_attribute_count)(pa_tnc_msg_t *this);
+
        /**
         * Enumerates over all parsing errors
         *
index 7d8445c1314b9e48b75065f01e7eadcbc584c18c..70f574e531a95149040157f35b9922f6b0cfe693 100644 (file)
@@ -181,11 +181,18 @@ static TNC_Result send_message(TNC_ConnectionID connection_id)
        msg = pa_tnc_msg_create();
 
        if (imv_attestation_build(msg, attestation_state, supported_algorithms,
-                                                         supported_dh_groups, pts_db))
+               supported_dh_groups, pts_db))
        {
-               msg->build(msg);
-               result = imv_attestation->send_message(imv_attestation, connection_id,
-                                                                                          msg->get_encoding(msg));
+               if (!msg->get_attribute_count(msg))
+               {
+                       result = TNC_RESULT_SUCCESS;
+               }
+               else
+               {
+                       msg->build(msg);
+                       result = imv_attestation->send_message(imv_attestation,
+                                                                       connection_id, msg->get_encoding(msg));
+               }
        }
        else
        {
index 2477924b2ee1c7cbcde287bd94c56049540a0559..f20cead3e49f7130491e636bb4ca3bea243e7c6e 100644 (file)
@@ -236,11 +236,11 @@ bool imv_attestation_build(pa_tnc_msg_t *msg,
                        {
                                break;
                        }
-                       DBG2(DBG_IMV, "evidence request by");
                        while (enumerator->enumerate(enumerator, &vid, &name,
                                &qualifier, &depth))
                        {
                                comp_name = pts_comp_func_name_create(vid, name, qualifier);
+                               DBG2(DBG_IMV, "evidence request by");
                                comp_name->log(comp_name, "  ");
 
                                comp = pts_components->create(pts_components, comp_name,