imv-swima: Created SWIMA IMV plugin
[strongswan.git] / src / libimcv / plugins / imv_swima / imv_swima_state.h
1 /*
2 * Copyright (C) 2017 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_swima imv_swima
18 * @ingroup libimcv_plugins
19 *
20 * @defgroup imv_swima_state_t imv_swima_state
21 * @{ @ingroup imv_swima
22 */
23
24 #ifndef IMV_SWIMA_STATE_H_
25 #define IMV_SWIMA_STATE_H_
26
27 #include <imv/imv_state.h>
28 #include <swima/swima_inventory.h>
29 #include <swima/swima_events.h>
30 #include <library.h>
31
32 #include <json.h>
33
34 typedef struct imv_swima_state_t imv_swima_state_t;
35 typedef enum imv_swima_handshake_state_t imv_swima_handshake_state_t;
36
37 /**
38 * IMV OS Handshake States (state machine)
39 */
40 enum imv_swima_handshake_state_t {
41 IMV_SWIMA_STATE_INIT,
42 IMV_SWIMA_STATE_WORKITEMS,
43 IMV_SWIMA_STATE_END
44 };
45
46 /**
47 * Internal state of an imv_swima_t connection instance
48 */
49 struct imv_swima_state_t {
50
51 /**
52 * imv_state_t interface
53 */
54 imv_state_t interface;
55
56 /**
57 * Set state of the handshake
58 *
59 * @param new_state the handshake state of IMV
60 */
61 void (*set_handshake_state)(imv_swima_state_t *this,
62 imv_swima_handshake_state_t new_state);
63
64 /**
65 * Get state of the handshake
66 *
67 * @return the handshake state of IMV
68 */
69 imv_swima_handshake_state_t (*get_handshake_state)(imv_swima_state_t *this);
70
71 /**
72 * Set the SWID request ID
73 *
74 * @param request_id SWID request ID to be set
75 */
76 void (*set_request_id)(imv_swima_state_t *this, uint32_t request_id);
77
78 /**
79 * Get the SWID request ID
80 *
81 * @return SWID request ID
82 */
83 uint32_t (*get_request_id)(imv_swima_state_t *this);
84
85 /**
86 * Set or extend the SWID Tag ID inventory in the state
87 *
88 * @param inventory SWID Tags ID inventory to be added
89 */
90 void (*set_inventory)(imv_swima_state_t *this, swima_inventory_t *inventory);
91
92 /**
93 * Get the encoding of the complete SWID Tag ID inventory
94 *
95 * @return SWID Tags ID inventory as a JSON array
96 */
97 json_object* (*get_inventory)(imv_swima_state_t *this);
98
99 /**
100 * Set or extend the SWID Tag ID Events in the state
101 *
102 * @param inventory SWID Tags ID inventory to be added
103 */
104 void (*set_events)(imv_swima_state_t *this, swima_events_t *events);
105
106 /**
107 * Get the encoding of the complete Software ID Events
108 *
109 * @return Software ID events as a JSON array
110 */
111 json_object* (*get_events)(imv_swima_state_t *this);
112
113 /**
114 * Set the number of still missing SW [ID] records or envents
115 *
116 * @param count Number of missing SW [ID] records or envents
117 */
118 void (*set_missing)(imv_swima_state_t *this, uint32_t count);
119
120 /**
121 * Get the number of still missing SWID Tags or Tag IDs
122 *
123 * @result Number of missing SWID Tags or Tag IDs
124 */
125 uint32_t (*get_missing)(imv_swima_state_t *this);
126
127 /**
128 * Set [or with multiple attributes increment] SWID Tag [ID] counters
129 *
130 * @param tag_id_count Number of received SWID Tag IDs
131 * @param tag_count Number of received SWID Tags
132 * @param imc_id SWID IMC ID
133 */
134 void (*set_count)(imv_swima_state_t *this, int tag_id_count, int tag_count,
135 TNC_UInt32 imc_id);
136
137 /**
138 * Set [or with multiple attributes increment] SWID Tag [ID] counters
139 *
140 * @param tag_id_count Number of received SWID Tag IDs
141 * @param tag_count Number of received SWID Tags
142 */
143 void (*get_count)(imv_swima_state_t *this, int *tag_id_count, int *tag_count);
144
145 /**
146 * Get SWID IMC ID
147 *
148 * @return SWID IMC ID
149 */
150 TNC_UInt32 (*get_imc_id)(imv_swima_state_t *this);
151 };
152
153 /**
154 * Create an imv_swima_state_t instance
155 *
156 * @param id connection ID
157 */
158 imv_state_t* imv_swima_state_create(TNC_ConnectionID id);
159
160 #endif /** IMV_SWIMA_STATE_H_ @}*/