swid-gen: Share SWID generator between sw-collector, imc-swima and imc-swid
[strongswan.git] / src / libimcv / plugins / imv_swid / imv_swid_state.h
1 /*
2 * Copyright (C) 2013-2016 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_swid imv_swid
18 * @ingroup libimcv_plugins
19 *
20 * @defgroup imv_swid_state_t imv_swid_state
21 * @{ @ingroup imv_swid
22 */
23
24 #ifndef IMV_SWID_STATE_H_
25 #define IMV_SWID_STATE_H_
26
27 #include <imv/imv_state.h>
28 #include <swid/swid_inventory.h>
29 #include <library.h>
30
31 #include <json.h>
32
33 typedef struct imv_swid_state_t imv_swid_state_t;
34 typedef enum imv_swid_handshake_state_t imv_swid_handshake_state_t;
35
36 /**
37 * IMV OS Handshake States (state machine)
38 */
39 enum imv_swid_handshake_state_t {
40 IMV_SWID_STATE_INIT,
41 IMV_SWID_STATE_WORKITEMS,
42 IMV_SWID_STATE_END
43 };
44
45 /**
46 * Internal state of an imv_swid_t connection instance
47 */
48 struct imv_swid_state_t {
49
50 /**
51 * imv_state_t interface
52 */
53 imv_state_t interface;
54
55 /**
56 * Set state of the handshake
57 *
58 * @param new_state the handshake state of IMV
59 */
60 void (*set_handshake_state)(imv_swid_state_t *this,
61 imv_swid_handshake_state_t new_state);
62
63 /**
64 * Get state of the handshake
65 *
66 * @return the handshake state of IMV
67 */
68 imv_swid_handshake_state_t (*get_handshake_state)(imv_swid_state_t *this);
69
70 /**
71 * Set the SWID request ID
72 *
73 * @param request_id SWID request ID to be set
74 */
75 void (*set_request_id)(imv_swid_state_t *this, uint32_t request_id);
76
77 /**
78 * Get the SWID request ID
79 *
80 * @return SWID request ID
81 */
82 uint32_t (*get_request_id)(imv_swid_state_t *this);
83
84 /**
85 * Set or extend the SWID Tag ID inventory in the state
86 *
87 * @param inventory SWID Tags ID inventory to be added
88 */
89 void (*set_swid_inventory)(imv_swid_state_t *this, swid_inventory_t *inventory);
90
91 /**
92 * Get the encoding of the complete SWID Tag ID inventory
93 *
94 * @return SWID Tags ID inventory as a JSON array
95 */
96 json_object* (*get_swid_inventory)(imv_swid_state_t *this);
97
98 /**
99 * Set the number of still missing SWID Tags or Tag IDs
100 *
101 * @param count Number of missing SWID Tags or Tag IDs
102 */
103 void (*set_missing)(imv_swid_state_t *this, uint32_t count);
104
105 /**
106 * Get the number of still missing SWID Tags or Tag IDs
107 *
108 * @result Number of missing SWID Tags or Tag IDs
109 */
110 uint32_t (*get_missing)(imv_swid_state_t *this);
111
112 /**
113 * Set [or with multiple attributes increment] SWID Tag [ID] counters
114 *
115 * @param tag_id_count Number of received SWID Tag IDs
116 * @param tag_count Number of received SWID Tags
117 * @param imc_id SWID IMC ID
118 */
119 void (*set_count)(imv_swid_state_t *this, int tag_id_count, int tag_count,
120 TNC_UInt32 imc_id);
121
122 /**
123 * Set [or with multiple attributes increment] SWID Tag [ID] counters
124 *
125 * @param tag_id_count Number of received SWID Tag IDs
126 * @param tag_count Number of received SWID Tags
127 */
128 void (*get_count)(imv_swid_state_t *this, int *tag_id_count, int *tag_count);
129
130 /**
131 * Get SWID IMC ID
132 *
133 * @return SWID IMC ID
134 */
135 TNC_UInt32 (*get_imc_id)(imv_swid_state_t *this);
136 };
137
138 /**
139 * Create an imv_swid_state_t instance
140 *
141 * @param id connection ID
142 */
143 imv_state_t* imv_swid_state_create(TNC_ConnectionID id);
144
145 #endif /** IMV_SWID_STATE_H_ @}*/