Separated IMV session management from IMV policy database
[strongswan.git] / src / libimcv / imv / imv_session.h
1 /*
2 * Copyright (C) 2013-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 *
18 * @defgroup imv_session_t imv_session
19 * @{ @ingroup libimcv_imv
20 */
21
22 #ifndef IMV_SESSION_H_
23 #define IMV_SESSION_H_
24
25 #include "imv_workitem.h"
26 #include "imv_os_info.h"
27
28 #include <tncifimv.h>
29 #include <library.h>
30
31 #include <time.h>
32
33 typedef struct imv_session_t imv_session_t;
34
35 /**
36 * IMV session interface
37 */
38 struct imv_session_t {
39
40 /**
41 * Set unique session ID
42 *
43 * @param session_id primary key into sessions table
44 * @param pid primary key into products table
45 * @param did Primary key into devices table
46 */
47 void (*set_session_id)(imv_session_t *this, int session_id, int pid, int did);
48
49 /**
50 * Get unique session ID
51 *
52 * @param pid primary key into products table
53 * @param did Primary key into devices table
54 * @return primary key into sessions table
55 */
56 int (*get_session_id)(imv_session_t *this, int *pid, int *did);
57
58 /**
59 * Get TNCCS Connection ID
60 *
61 * @return TNCCS Connection ID
62 */
63 TNC_ConnectionID (*get_connection_id)(imv_session_t *this);
64
65 /**
66 * Get session creation time
67 *
68 * @return Session creation time
69 */
70 time_t (*get_creation_time)(imv_session_t *this);
71
72 /**
73 * Get Access Requestor ID
74 *
75 * @param id_type Access Requestor TCG Standard ID Type
76 * @return Access Requestor TCG Standard ID Value
77 */
78 chunk_t (*get_ar_id)(imv_session_t *this, uint32_t *id_type);
79
80 /**
81 * Get OS Information
82 *
83 * @return OS info object
84 */
85 imv_os_info_t* (*get_os_info)(imv_session_t *this);
86
87 /**
88 * Set Device ID
89 *
90 * @param device_id Device ID
91 */
92 void (*set_device_id)(imv_session_t *this, chunk_t device_id);
93
94 /**
95 * Get Device ID
96 *
97 * @param device_id Device ID
98 * @return TRUE if Device ID has already been set
99 */
100 bool (*get_device_id)(imv_session_t *this, chunk_t *device_id);
101
102 /**
103 * Set trust into Device ID
104 *
105 * @param trusted TRUE if Device ID is trusted
106 */
107 void (*set_device_trust)(imv_session_t *this, bool trusted);
108
109
110 /**
111 * Get device ID trust (needed for TPM-based attestation)
112 *
113 * @return TRUE if Device ID is trusted
114 */
115 bool (*get_device_trust)(imv_session_t *this);
116
117 /**
118 * Set policy_started status
119 *
120 * @param start TRUE if policy started, FALSE if policy stopped
121 */
122 void (*set_policy_started)(imv_session_t *this, bool start);
123
124 /**
125 * Get policy_started status
126 *
127 * @return TRUE if policy started, FALSE if policy stopped
128 */
129 bool (*get_policy_started)(imv_session_t *this);
130
131 /**
132 * Insert workitem into list
133 *
134 * @param workitem Workitem to be inserted
135 */
136 void (*insert_workitem)(imv_session_t *this, imv_workitem_t *workitem);
137
138 /**
139 * Remove workitem from list
140 *
141 * @param enumerator Enumerator pointing to workitem to be removed
142 */
143 void (*remove_workitem)(imv_session_t *this, enumerator_t *enumerator);
144
145 /**
146 * Create workitem enumerator
147 *
148 */
149 enumerator_t* (*create_workitem_enumerator)(imv_session_t *this);
150
151 /**
152 * Get number of workitem allocated to a given IMV
153 *
154 * @param imv_id IMV ID
155 * @return Number of workitems assigned to given IMV
156 */
157 int (*get_workitem_count)(imv_session_t *this, TNC_IMVID imv_id);
158
159 /**
160 * Get reference to session
161 */
162 imv_session_t* (*get_ref)(imv_session_t*);
163
164 /**
165 * Destroys an imv_session_t object
166 */
167 void (*destroy)(imv_session_t *this);
168 };
169
170 /**
171 * Create an imv_session_t instance
172 *
173 * @param id Associated Connection ID
174 * @param created Session creation time
175 * @param ar_id_type Access Requestor ID type
176 * @param ar_id_value Access Requestor ID value
177 */
178 imv_session_t* imv_session_create(TNC_ConnectionID id, time_t created,
179 uint32_t ar_id_type, chunk_t ar_id_value);
180
181 #endif /** IMV_SESSION_H_ @}*/