Store device with product ID
[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 IMV_OS_STATE_END
44 };
45
46 /**
47 * Flags for detected OS Settings
48 */
49 enum os_settings_t {
50 OS_SETTINGS_FWD_ENABLED = (1<<0),
51 OS_SETTINGS_DEFAULT_PWD_ENABLED = (1<<1),
52 OS_SETTINGS_UNKNOWN_SOURCE = (1<<2)
53 };
54
55 /**
56 * Internal state of an imv_os_t connection instance
57 */
58 struct imv_os_state_t {
59
60 /**
61 * imv_state_t interface
62 */
63 imv_state_t interface;
64
65 /**
66 * Set state of the handshake
67 *
68 * @param new_state the handshake state of IMV
69 */
70 void (*set_handshake_state)(imv_os_state_t *this,
71 imv_os_handshake_state_t new_state);
72
73 /**
74 * Get state of the handshake
75 *
76 * @return the handshake state of IMV
77 */
78 imv_os_handshake_state_t (*get_handshake_state)(imv_os_state_t *this);
79
80 /**
81 * Set OS Product Information
82 *
83 * @param type OS type (enumerated)
84 * @param name OS name (string)
85 * @param version OS version
86 */
87 void (*set_info)(imv_os_state_t *this, os_type_t os_type,
88 chunk_t name, chunk_t version);
89
90 /**
91 * Get OS Product Information
92 *
93 * @param type OS type (enumerated)
94 * @param name OS name (string)
95 * @param version OS version
96 * @return OS name & version as a concatenated string
97 */
98 char* (*get_info)(imv_os_state_t *this, os_type_t *os_type,
99 chunk_t *name, chunk_t *version);
100
101 /**
102 * Set [or with multiple attributes increment] package counters
103 *
104 * @param count Number of processed packages
105 * @param count_update Number of not updated packages
106 * @param count_blacklist Number of blacklisted packages
107 * @param count_ok Number of whitelisted packages
108 */
109 void (*set_count)(imv_os_state_t *this, int count, int count_update,
110 int count_blacklist, int count_ok);
111
112 /**
113 * Set [or with multiple attributes increment] package counters
114 *
115 * @param count Number of processed packages
116 * @param count_update Number of not updated packages
117 * @param count_blacklist Number of blacklisted packages
118 * @param count_ok Number of whitelisted packages
119 */
120 void (*get_count)(imv_os_state_t *this, int *count, int *count_update,
121 int *count_blacklist, int *count_ok);
122
123 /**
124 * Set device ID
125 *
126 * @param device_id Device ID
127 */
128 void (*set_device_id)(imv_os_state_t *this, chunk_t id);
129
130 /**
131 * Get device ID
132 *
133 * @return Device ID
134 */
135 chunk_t (*get_device_id)(imv_os_state_t *this);
136
137 /**
138 * Set OS settings
139 *
140 * @param settings OS settings
141 */
142 void (*set_os_settings)(imv_os_state_t *this, u_int settings);
143
144 /**
145 * Get OS settings
146 *
147 * @return OS settings
148 */
149 u_int (*get_os_settings)(imv_os_state_t *this);
150
151 /**
152 * Increase/Decrease the ITA Angel count
153 *
154 * @param start TRUE increases and FALSE decreases count by one
155 */
156 void (*set_angel_count)(imv_os_state_t *this, bool start);
157
158 /**
159 * Get the ITA Angel count
160 *
161 * @return ITA Angel count
162 */
163 int (*get_angel_count)(imv_os_state_t *this);
164
165 /**
166 * Store a bad package that has to be updated or removed
167 *
168 * @param package Name of software package
169 * @param package_state Security state of software package
170 */
171 void (*add_bad_package)(imv_os_state_t *this, char *package,
172 os_package_state_t package_state);
173
174 };
175
176 /**
177 * Create an imv_os_state_t instance
178 *
179 * @param id connection ID
180 */
181 imv_state_t* imv_os_state_create(TNC_ConnectionID id);
182
183 #endif /** IMV_OS_STATE_H_ @}*/