moved listing of file measurements to pts_file_meas
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 13 Jul 2012 20:15:13 +0000 (22:15 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 16 Jul 2012 07:54:11 +0000 (09:54 +0200)
src/libpts/plugins/imv_attestation/imv_attestation_process.c
src/libpts/pts/pts_file_meas.c
src/libpts/pts/pts_file_meas.h

index 2ad5d78..842144f 100644 (file)
@@ -193,9 +193,8 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
                        int file_count, file_id;
                        pts_meas_algorithms_t algo;
                        pts_file_meas_t *measurements;
-                       char *platform_info, *filename;
-                       chunk_t measurement;
-                       enumerator_t *e, *e_hash;
+                       char *platform_info;
+                       enumerator_t *e_hash;
                        bool is_dir;
 
                        platform_info = pts->get_platform_info(pts);
@@ -238,12 +237,7 @@ bool imv_attestation_process(pa_tnc_attr_t *attr, linked_list_t *attr_list,
                        }
                        else
                        {
-                               e = measurements->create_enumerator(measurements);
-                               while (e->enumerate(e, &filename, &measurement))
-                               {
-                                       DBG2(DBG_PTS, "  %#B for '%s'", &measurement, filename);
-                               }
-                               e->destroy(e);
+                               measurements->insert(measurements, pts_db, platform_info);
                        }
                        break;
                }
index f0e0d4c..8db3ea9 100644 (file)
@@ -107,6 +107,22 @@ METHOD(pts_file_meas_t, create_enumerator, enumerator_t*,
                                                                   (void*)entry_filter, NULL, NULL);
 }
 
+METHOD(pts_file_meas_t, insert, bool,
+       private_pts_file_meas_t *this, pts_database_t *pts_db, char *product)
+{
+       enumerator_t *enumerator;
+       entry_t *entry;
+
+       enumerator = this->list->create_enumerator(this->list);
+       while (enumerator->enumerate(enumerator, &entry))
+       {
+               DBG2(DBG_PTS, "  %#B for '%s'", &entry->measurement, entry->filename);
+       }
+       enumerator->destroy(enumerator);
+
+       return TRUE;
+}
+
 METHOD(pts_file_meas_t, verify, bool,
        private_pts_file_meas_t *this, enumerator_t *e_hash, bool is_dir)
 {
@@ -174,6 +190,7 @@ pts_file_meas_t *pts_file_meas_create(u_int16_t request_id)
                        .get_file_count = _get_file_count,
                        .add = _add,
                        .create_enumerator = _create_enumerator,
+                       .insert = _insert,
                        .verify = _verify,
                        .destroy = _destroy,
                },
index 3ebb5c2..9b197e7 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef PTS_FILE_MEAS_H_
 #define PTS_FILE_MEAS_H_
 
+#include "pts/pts_database.h"
+
 #include <library.h>
 
 typedef struct pts_file_meas_t pts_file_meas_t;
@@ -60,6 +62,15 @@ struct pts_file_meas_t {
        enumerator_t* (*create_enumerator)(pts_file_meas_t *this);
 
        /**
+        * Insert PTS File Measurements into the database
+        *
+        * @param db                    PTS Measurement database
+        * @param product               Software product (os, vpn client, etc.)
+        * @return                              TRUE if all measurements could be inserted
+        */
+       bool (*insert)(pts_file_meas_t *this, pts_database_t *db, char* product);
+
+       /**
         * Verify stored hashes against PTS File Measurements
         *
         * @param e_hash                Hash enumerator