Moved all functionality into imv_os_agent_t class turning imv_os_t into an IF-IMV...
[strongswan.git] / src / libimcv / plugins / imv_os / imv_os_state.h
1 /*
2 * Copyright (C) 2012 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 imv_os imv_os
18 * @ingroup libimcv_plugins
19 *
20 * @defgroup imv_os_state_t imv_os_state
21 * @{ @ingroup imv_os
22 */
23
24 #ifndef IMV_OS_STATE_H_
25 #define IMV_OS_STATE_H_
26
27 #include "os_info/os_info.h"
28 #include <imv/imv_state.h>
29 #include <library.h>
30
31 typedef struct imv_os_state_t imv_os_state_t;
32 typedef enum imv_os_handshake_state_t imv_os_handshake_state_t;
33 typedef enum os_settings_t os_settings_t;
34
35 /**
36 * IMV OS Handshake States (state machine)
37 */
38 enum imv_os_handshake_state_t {
39 IMV_OS_STATE_INIT,
40 IMV_OS_STATE_ATTR_REQ,
41 IMV_OS_STATE_POLICY_START,
42 IMV_OS_STATE_WORKITEMS
43 };
44
45 /**
46 * Flags for detected OS Settings
47 */
48 enum os_settings_t {
49 OS_SETTINGS_FWD_ENABLED = (1<<0),
50 OS_SETTINGS_DEFAULT_PWD_ENABLED = (1<<1),
51 OS_SETTINGS_UNKNOWN_SOURCE = (1<<2)
52 };
53
54 /**
55 * Internal state of an imv_os_t connection instance
56 */
57 struct imv_os_state_t {
58
59 /**
60 * imv_state_t interface
61 */
62 imv_state_t interface;
63
64 /**
65 * Set state of the handshake
66 *
67 * @param new_state the handshake state of IMV
68 */
69 void (*set_handshake_state)(imv_os_state_t *this,
70 imv_os_handshake_state_t new_state);
71
72 /**
73 * Get state of the handshake
74 *
75 * @return the handshake state of IMV
76 */
77 imv_os_handshake_state_t (*get_handshake_state)(imv_os_state_t *this);
78
79 /**
80 * Set OS Product Information
81 *
82 * @param type OS type (enumerated)
83 * @param name OS name (string)
84 * @param version OS version
85 */
86 void (*set_info)(imv_os_state_t *this, os_type_t os_type,
87 chunk_t name, chunk_t version);
88
89 /**
90 * Get OS Product Information
91 *
92 * @param type OS type (enumerated)
93 * @param name OS name (string)
94 * @param version OS version
95 * @return OS name & version as a concatenated string
96 */
97 char* (*get_info)(imv_os_state_t *this, os_type_t *os_type,
98 chunk_t *name, chunk_t *version);
99
100 /**
101 * Set [or with multiple attributes increment] package counters
102 *
103 * @param count Number of processed packages
104 * @param count_update Number of not updated packages
105 * @param count_blacklist Number of blacklisted packages
106 * @param count_ok Number of whitelisted packages
107 */
108 void (*set_count)(imv_os_state_t *this, int count, int count_update,
109 int count_blacklist, int count_ok);
110
111 /**
112 * Set [or with multiple attributes increment] package counters
113 *
114 * @param count Number of processed packages
115 * @param count_update Number of not updated packages
116 * @param count_blacklist Number of blacklisted packages
117 * @param count_ok Number of whitelisted packages
118 */
119 void (*get_count)(imv_os_state_t *this, int *count, int *count_update,
120 int *count_blacklist, int *count_ok);
121
122 /**
123 * Set flags for received attributes
124 *
125 * @param flags Flags to be set
126 */
127 void (*set_received)(imv_os_state_t *this, u_int flags);
128
129 /**
130 * Get flags set for received attributes
131 *
132 * @return Flags set for received attributes
133 */
134 u_int (*get_received)(imv_os_state_t *this);
135
136 /**
137 * Set device ID
138 *
139 * @param device_id Device ID primary database key
140 */
141 void (*set_device_id)(imv_os_state_t *this, int id);
142
143 /**
144 * Get device ID
145 *
146 * @return Device ID primary database key
147 */
148 int (*get_device_id)(imv_os_state_t *this);
149
150 /**
151 * Set OS settings
152 *
153 * @param settings OS settings
154 */
155 void (*set_os_settings)(imv_os_state_t *this, u_int settings);
156
157 /**
158 * Get OS settings
159 *
160 * @return OS settings
161 */
162 u_int (*get_os_settings)(imv_os_state_t *this);
163
164 /**
165 * Increase/Decrease the ITA Angel count
166 *
167 * @param start TRUE increases and FALSE decreases count by one
168 */
169 void (*set_angel_count)(imv_os_state_t *this, bool start);
170
171 /**
172 * Get the ITA Angel count
173 *
174 * @return ITA Angel count
175 */
176 int (*get_angel_count)(imv_os_state_t *this);
177
178 /**
179 * Store a bad package that has to be updated or removed
180 *
181 * @param package Name of software package
182 * @param package_state Security state of software package
183 */
184 void (*add_bad_package)(imv_os_state_t *this, char *package,
185 os_package_state_t package_state);
186
187 };
188
189 /**
190 * Create an imv_os_state_t instance
191 *
192 * @param id connection ID
193 */
194 imv_state_t* imv_os_state_create(TNC_ConnectionID id);
195
196 #endif /** IMV_OS_STATE_H_ @}*/