ikev1: Handle queued TRANSACTION messages only after processing replies
[strongswan.git] / src / libimcv / pts / pts_database.h
1 /*
2 * Copyright (C) 2011-2014 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup pts_database pts_database
18 * @{ @ingroup pts
19 */
20
21 #ifndef PTS_DATABASE_H_
22 #define PTS_DATABASE_H_
23
24 typedef struct pts_database_t pts_database_t;
25
26 #include "pts_meas_algo.h"
27 #include "components/pts_comp_func_name.h"
28
29 #include <imv/imv_database.h>
30 #include <library.h>
31
32 /**
33 * Class implementing the PTS File Measurement database
34 *
35 */
36 struct pts_database_t {
37
38 /**
39 * Get absolute pathname for file or directory measurement
40 *
41 * @param is_dir TRUE if dir, FALSE if file
42 * @param id Primary key into directories or files table
43 * @return Absolute pathname as a text string
44 */
45 char* (*get_pathname)(pts_database_t *this, bool is_dir, int id);
46
47 /**
48 * Get stored measurement hash for single file or directory entries
49 *
50 * @param pid Primary key of software product in database
51 * @param algo Hash algorithm used for measurement
52 * @param is_dir TRUE if directory was measured
53 * @param id Primary key of measured file/directory
54 * @return Enumerator over all matching measurement hashes
55 */
56 enumerator_t* (*create_file_hash_enumerator)(pts_database_t *this,
57 int pid, pts_meas_algorithms_t algo,
58 bool is_dir, int id);
59
60 /**
61 * Add PTS file measurement reference value
62 *
63 * @param pid Primary key of software product in database
64 * @param algo File measurement hash algorithm used
65 * @param measurement File measurement hash
66 * @param filename Optional name of the file to be checked
67 * @param is_dir TRUE if part of directory measurement
68 * @param id Primary key into direcories/files table
69 * @return Status
70 */
71 status_t (*add_file_measurement)(pts_database_t *this, int pid,
72 pts_meas_algorithms_t algo,
73 chunk_t measurement, char *filename,
74 bool is_dir, int id);
75
76 /**
77 * Get PTS measurement[s] for a given filename stored in database
78 *
79 * @param pid Primary key of software product in database
80 * @param algo File measurement hash algorithm used
81 * @param filename Name of the file to be checked
82 * @return Enumerator over all matching measurement hashes
83 */
84 enumerator_t* (*create_file_meas_enumerator)(pts_database_t *this, int pid,
85 pts_meas_algorithms_t algo,
86 char *filename);
87
88 /**
89 * Check a functional component measurement against value stored in database
90 *
91 * @param measurement measurement hash
92 * @param cid Primary key of Component Functional Name entry
93 * @param aik_id Primary key of AIK entry in database
94 * @param seq_no Measurement sequence number
95 * @param prc Number of the PCR the measurement was extended into
96 * @param algo Hash algorithm used for measurement
97 * @return SUCCESS if check was successful
98 */
99 status_t (*check_comp_measurement)(pts_database_t *this, chunk_t measurement,
100 int cid, int aik_id, int seq_no, int pcr,
101 pts_meas_algorithms_t algo);
102
103 /**
104 * Insert a functional component measurement into the database
105 *
106 * @param measurement Measurement hash
107 * @param cid Primary key of Component Functional Name entry
108 * @param aik_id Primary key of AIK entry in database
109 * @param seq_no Measurement sequence number
110 * @param prc Number of the PCR the measurement was extended into
111 * @param algo Hash algorithm used for measurement
112 * @return SUCCESS if INSERT was successful
113 */
114 status_t (*insert_comp_measurement)(pts_database_t *this, chunk_t measurement,
115 int cid, int aik_id, int seq_no, int pcr,
116 pts_meas_algorithms_t algo);
117
118 /**
119 * Delete functional component measurements from the database
120 *
121 * @param cid Primary key of Component Functional Name entry
122 * @param aik_id Primary key of AIK entry in database
123 * @return number of deleted measurement entries
124 */
125 int (*delete_comp_measurements)(pts_database_t *this, int cid, int aik_id);
126
127 /**
128 * Get the number of measurements for a functional component and AIK
129 *
130 * @param comp_name Component Functional Name
131 * @param aik_id Primary key of AIK entry in database
132 * @param algo Hash algorithm used for measurement
133 * @param cid Primary key of Component Functional Name entry
134 * @param count measurement count
135 * @return SUCCESS if COUNT was successful
136 */
137 status_t (*get_comp_measurement_count)(pts_database_t *this,
138 pts_comp_func_name_t *comp_name, int aik_id,
139 pts_meas_algorithms_t algo, int *cid, int *count);
140
141 /**
142 * Destroys a pts_database_t object.
143 */
144 void (*destroy)(pts_database_t *this);
145
146 };
147
148 /**
149 * Creates an pts_database_t object
150 *
151 * @param imv_db Already attached IMV database
152 */
153 pts_database_t* pts_database_create(imv_database_t *imv_db);
154
155 #endif /** PTS_DATABASE_H_ @}*/