Added Check_Measurement function to pts_database instead of returning enumerator...
[strongswan.git] / src / libimcv / plugins / imv_attestation / imv_attestation_state.h
1 /*
2 * Copyright (C) 2011 Sansar Choinyambuu
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 *
18 * @defgroup imv_attestation_state_t imv_attestation_state
19 * @{ @ingroup imv_attestation_state
20 */
21
22 #ifndef IMV_ATTESTATION_STATE_H_
23 #define IMV_ATTESTATION_STATE_H_
24
25 #include <imv/imv_state.h>
26 #include <tcg/pts/pts.h>
27 #include <library.h>
28 #include <utils/linked_list.h>
29
30 typedef struct imv_attestation_state_t imv_attestation_state_t;
31 typedef enum imv_attestation_handshake_state_t imv_attestation_handshake_state_t;
32 typedef struct file_request_t file_request_t;
33
34 /**
35 * IMV Attestation Handshake States (state machine)
36 */
37 enum imv_attestation_handshake_state_t {
38 IMV_ATTESTATION_STATE_INIT,
39 IMV_ATTESTATION_STATE_MEAS,
40 IMV_ATTESTATION_STATE_COMP_EVID,
41 IMV_ATTESTATION_STATE_IML,
42 IMV_ATTESTATION_STATE_END,
43 };
44
45 /**
46 * Defines an structure to hold requested file/directory
47 */
48 struct file_request_t {
49 int request_id;
50 int is_dir;
51 };
52
53 /**
54 * Internal state of an imv_attestation_t connection instance
55 */
56 struct imv_attestation_state_t {
57
58 /**
59 * imv_state_t interface
60 */
61 imv_state_t interface;
62
63 /**
64 * Get state of the handshake
65 *
66 * @return the handshake state of IMV
67 */
68 imv_attestation_handshake_state_t (*get_handshake_state)(imv_attestation_state_t *this);
69
70 /**
71 * Set state of the handshake
72 *
73 * @param new_state the handshake state of IMV
74 */
75 void (*set_handshake_state)(imv_attestation_state_t *this,
76 imv_attestation_handshake_state_t new_state);
77
78 /**
79 * Get the PTS object
80 *
81 * @return PTS object
82 */
83 pts_t* (*get_pts)(imv_attestation_state_t *this);
84
85 /**
86 * Add an entry to list of requested files/directories
87 *
88 * @param request_id unique request id
89 * @param is_dir 0 for file and 1 for directory
90 */
91 void (*add_requested_file)(imv_attestation_state_t *this, int request_id, int is_dir);
92
93 /**
94 * Creates enumerator over the list of requested file/directories
95 *
96 * @return enumerator over requested files/directories list
97 */
98 enumerator_t* (*create_requests_enumerator)(imv_attestation_state_t *this);
99
100 /**
101 * Returns number of entries in the list of requested file/directories
102 *
103 * @return number of entries in the list of requested file/directories
104 */
105 int (*get_requests_count)(imv_attestation_state_t *this);
106
107 /**
108 * Removes an entry with matching request_id from list of requested files/directories
109 *
110 * @param request_id unique request id
111 * @return TRUE if request entry found, FALSE otherwise
112 */
113 bool (*remove_requested_file)(imv_attestation_state_t *this, int request_id);
114
115 /**
116 * Returns TRUE if entry with given ID is directory and FALSE otherwise
117 *
118 * @param request_id unique request id
119 * @return TRUE if request entry found, FALSE otherwise
120 */
121 bool (*is_request_dir)(imv_attestation_state_t *this, int request_id, bool *is_dir);
122 };
123
124 /**
125 * Create an imv_attestation_state_t instance
126 *
127 * @param id connection ID
128 */
129 imv_state_t* imv_attestation_state_create(TNC_ConnectionID id);
130
131 #endif /** IMV_ATTESTATION_STATE_H_ @}*/