3c4bf83d84877996edf0c8830fd04b47d1c698ab
[strongswan.git] / src / libimcv / imv / imv_database.h
1 /*
2 * Copyright (C) 2013 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_database_t imv_database
19 * @{ @ingroup libimcv_imv
20 */
21
22 #ifndef IMV_DATABASE_H_
23 #define IMV_DATABASE_H_
24
25 #include "imv_session.h"
26 #include "imv_workitem.h"
27
28 #include <tncifimv.h>
29
30 #include <library.h>
31
32 typedef struct imv_database_t imv_database_t;
33
34 /**
35 * IMV database interface
36 */
37 struct imv_database_t {
38
39 /**
40 * Create or get a session associated with a TNCCS connection
41 *
42 * @param conn_id TNCCS Connection ID
43 * @param ar_id_type Access Requestor identity type
44 * @param ar_id_value Access Requestor identity value
45 * @return Session associated with TNCCS Connection
46 */
47 imv_session_t* (*get_session)(imv_database_t *this,
48 TNC_ConnectionID conn_id,
49 u_int32_t ar_id_type, chunk_t ar_id_value);
50
51 /**
52 * Add product information string to a session database entry
53 *
54 * @param session Session
55 * @param product Product information string
56 * @return Product ID
57 */
58 int (*add_product)(imv_database_t *this, imv_session_t *session,
59 char *product);
60
61 /**
62 * Add device identification to a session database entry
63 *
64 * @param session Session
65 * @param device Device identification
66 * @return Device ID
67 */
68 int (*add_device)(imv_database_t *this, imv_session_t *session,
69 chunk_t device);
70
71 /**
72 * Announce session start/stop to policy script
73 *
74 * @param session Session
75 * @param start TRUE if session start, FALSE if session stop
76 * @return TRUE if command successful, FALSE otherwise
77 */
78 bool (*policy_script)(imv_database_t *this, imv_session_t *session,
79 bool start);
80
81 /**
82 * Finalize a workitem
83 *
84 * @param workitem Workitem to be finalized
85 */
86 bool (*finalize_workitem)(imv_database_t *this, imv_workitem_t *workitem);
87
88 /**
89 * Get database handle
90 *
91 * @return Database handle
92 */
93 database_t* (*get_database)(imv_database_t *this);
94
95 /**
96 * Destroys an imv_database_t object
97 */
98 void (*destroy)(imv_database_t *this);
99 };
100
101 /**
102 * Create an imv_database_t instance
103 *
104 * @param uri Database uri
105 * @param script Policy Manager script
106 */
107 imv_database_t* imv_database_create(char *uri, char *script);
108
109 #endif /** IMV_DATABASE_H_ @}*/