summaryrefslogtreecommitdiff
path: root/src/libimcv/plugins/imv_os/imv_os_state.h
blob: 1c2adeaf95df92a72c909596ab7c2f17295370a4 (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
180
181
/*
 * Copyright (C) 2012 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_os imv_os
 * @ingroup libimcv_plugins
 *
 * @defgroup imv_os_state_t imv_os_state
 * @{ @ingroup imv_os
 */

#ifndef IMV_OS_STATE_H_
#define IMV_OS_STATE_H_

#include "os_info/os_info.h"
#include <imv/imv_state.h>
#include <library.h>

typedef struct imv_os_state_t imv_os_state_t;
typedef enum os_settings_t os_settings_t;

enum os_settings_t {
	OS_SETTINGS_FWD_ENABLED =         1,
	OS_SETTINGS_DEFAULT_PWD_ENABLED = 2,
	OS_SETTINGS_NON_MARKET_APPS =     4
};

/**
 * Internal state of an imv_os_t connection instance
 */
struct imv_os_state_t {

	/**
	 * imv_state_t interface
	 */
	imv_state_t interface;

	/**
	 * Set OS Product Information
	 *
	 * @param type			OS type (enumerated)
	 * @param name			OS name (string)
	 * @param version		OS version
	 */
	void (*set_info)(imv_os_state_t *this, os_type_t os_type,
					 chunk_t name, chunk_t version);

	/**
	 * Get OS Product Information
	 *
	 * @param type			OS type (enumerated)
	 * @param name			OS name (string)
	 * @param version		OS version
	 * @return				OS name & version as a concatenated string
	 */
	char* (*get_info)(imv_os_state_t *this, os_type_t *os_type,
					  chunk_t *name, chunk_t *version);

	/**
	 * Set [or with multiple attributes increment] package counters
	 *
	 * @param count				Number of processed packages
	 * @param count_update		Number of not updated packages
	 * @param count_blacklist	Number of blacklisted packages
	 * @param count_ok			Number of whitelisted packages
	 */
	void (*set_count)(imv_os_state_t *this, int count, int count_update,
					  int count_blacklist, int count_ok);

	/**
	 * Set [or with multiple attributes increment] package counters
	 *
	 * @param count				Number of processed packages
	 * @param count_update		Number of not updated packages
	 * @param count_blacklist	Number of blacklisted packages
	 * @param count_ok			Number of whitelisted packages
	 */
	void (*get_count)(imv_os_state_t *this, int *count, int *count_update,
					  int *count_blacklist, int *count_ok);

	/**
	 * Set/reset attribute request status
	 *
	 * @param set			TRUE to set, FALSE to clear
	 */
	void (*set_attribute_request)(imv_os_state_t *this, bool set);

	/**
	 * Get attribute request status
	 *
	 * @return				TRUE if set, FALSE if unset
	 */
	bool (*get_attribute_request)(imv_os_state_t *this);

	/**
	 * Set/reset OS Installed Packages request status
	 *
	 * @param set			TRUE to set, FALSE to clear
	 */
	void (*set_package_request)(imv_os_state_t *this, bool set);

	/**
	 * Get OS Installed Packages request status
	 *
	 * @return				TRUE if set, FALSE if unset
	 */
	bool (*get_package_request)(imv_os_state_t *this);

	/**
	 * Set device ID
	 *
	 * @param device_id		Device ID primary database key
	 */
	void (*set_device_id)(imv_os_state_t *this, int id);

	/**
	 * Get device ID
	 *
	 * @return				Device ID primary database key
	 */
	int (*get_device_id)(imv_os_state_t *this);

	/**
	 * Set OS settings
	 *
	 * @param settings		OS settings
	 */
	void (*set_os_settings)(imv_os_state_t *this, u_int settings);

	/**
	 * Get OS settings
	 *
	 * @return				OS settings
	 */
	u_int (*get_os_settings)(imv_os_state_t *this);

	/**
	 * Increase/Decrease the ITA Angel count
	 *
	 * @param start			TRUE increases and FALSE decreases count by one
	 */
	void (*set_angel_count)(imv_os_state_t *this, bool start);

	/**
	 * Get the ITA Angel count
	 *
	 * @return				ITA Angel count
	 */
	int (*get_angel_count)(imv_os_state_t *this);

	/**
	 * Store a bad package that has to be updated or removed
	 *
	 * @param package		Name of software package
	 * @param package_state	Security state of software package
	 */
	void (*add_bad_package)(imv_os_state_t *this, char *package,
							os_package_state_t package_state);

};

/**
 * Create an imv_os_state_t instance
 *
 * @param id			connection ID
 */
imv_state_t* imv_os_state_create(TNC_ConnectionID id);

#endif /** IMV_OS_STATE_H_ @}*/