summaryrefslogtreecommitdiff
path: root/src/libimcv/imv/imv_session.h
blob: 107716f30aaeeb5015fbb927572ad39b8e55f63d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
 * Copyright (C) 2013-2015 Andreas Steffen
 * HSR Hochschule fuer Technik Rapperswil
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

/**
 *
 * @defgroup imv_session_t imv_session
 * @{ @ingroup libimcv_imv
 */

#ifndef  IMV_SESSION_H_
#define  IMV_SESSION_H_

#include "imv_workitem.h"
#include "imv_os_info.h"

#include <tncifimv.h>
#include <library.h>

#include <time.h>

typedef struct imv_session_t imv_session_t;

/**
 * IMV session interface
 */
struct imv_session_t {

	/**
	 * Set unique session ID
	 *
	 * @param session_id	primary key into sessions table
	 * @param pid			primary key into products table
	 * @param did			Primary key into devices table
	 */
	void (*set_session_id)(imv_session_t *this, int session_id, int pid, int did);

	/**
	 * Get unique session ID
	 *
	 * @param pid			primary key into products table
	 * @param did			Primary key into devices table
	 * @return				primary key into sessions table
	 */
	int (*get_session_id)(imv_session_t *this, int *pid, int *did);

	/**
	 * Get TNCCS Connection ID
	 *
	 * @return				TNCCS Connection ID
	 */
	TNC_ConnectionID (*get_connection_id)(imv_session_t *this);

	/**
	 * Get session creation time
	 *
	 * @return				Session creation time
	 */
	time_t (*get_creation_time)(imv_session_t *this);

	/**
	 * Get list of Access Requestor identities
	 *
	 * @return				List of Access Requestor identities
	 */
	enumerator_t* (*create_ar_identities_enumerator)(imv_session_t *this);

	/**
	 * Get OS Information
	 *
	 * @return				OS info object
	 */
	imv_os_info_t* (*get_os_info)(imv_session_t *this);

	/**
	 * Set Device ID
	 *
	 * @param device_id		Device ID
	 */
	void (*set_device_id)(imv_session_t *this, chunk_t device_id);

	/**
	 * Get Device ID
	 *
	 * @param device_id		Device ID
	 * @return				TRUE if Device ID has already been set
	 */
	bool (*get_device_id)(imv_session_t *this, chunk_t *device_id);

	/**
	 * Set trust into Device ID
	 *
	 * @param trusted		TRUE if Device ID is trusted
	 */
	void (*set_device_trust)(imv_session_t *this, bool trusted);


	/**
	 * Get device ID trust (needed for TPM-based attestation)
	 *
	 * @return				TRUE if Device ID is trusted
	 */
	bool (*get_device_trust)(imv_session_t *this);

	/**
	 * Set policy_started status
	 *
	 * @param start			TRUE if policy started, FALSE if policy stopped
	 */
	void (*set_policy_started)(imv_session_t *this, bool start);

	/**
	 * Get policy_started status
	 *
	 * @return				TRUE if policy started, FALSE if policy stopped
	 */
	bool (*get_policy_started)(imv_session_t *this);

	/**
	 * Insert workitem into list
	 *
	 * @param workitem		Workitem to be inserted
	 */
	void (*insert_workitem)(imv_session_t *this, imv_workitem_t *workitem);

	/**
	 * Remove workitem from list
	 *
	 * @param enumerator	Enumerator pointing to workitem to be removed
	 */
	void (*remove_workitem)(imv_session_t *this, enumerator_t *enumerator);

	/**
	 * Create workitem enumerator
	 *
	 */
	 enumerator_t* (*create_workitem_enumerator)(imv_session_t *this);

	/**
	 * Get number of workitem allocated to a given IMV
	 *
	 * @param imv_id		IMV ID
	 * @return				Number of workitems assigned to given IMV
	 */
	 int (*get_workitem_count)(imv_session_t *this, TNC_IMVID imv_id);

	/**
	 * Get reference to session
	 */
	imv_session_t* (*get_ref)(imv_session_t*);

	/**
	 * Destroys an imv_session_t object
	 */
	void (*destroy)(imv_session_t *this);
};

/**
 * Create an imv_session_t instance
 *
 * @param id				Associated Connection ID
 * @param created			Session creation time
 * @param ar_identities		List of Access Requestor identities
 */
imv_session_t* imv_session_create(TNC_ConnectionID id, time_t created,
								  linked_list_t *ar_identities);

#endif /**  IMV_SESSION_H_ @}*/