9737245ad751a15300a549ad43fe18ca2d35614d
[strongswan.git] / src / libimcv / plugins / imc_scanner / imc_scanner_state.c
1 /*
2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15 #include "imc_scanner_state.h"
16
17 #include <debug.h>
18
19 typedef struct private_imc_scanner_state_t private_imc_scanner_state_t;
20
21 /**
22 * Private data of an imc_scanner_state_t object.
23 */
24 struct private_imc_scanner_state_t {
25
26 /**
27 * Public members of imc_scanner_state_t
28 */
29 imc_scanner_state_t public;
30
31 /**
32 * TNCCS connection ID
33 */
34 TNC_ConnectionID connection_id;
35
36 /**
37 * TNCCS connection state
38 */
39 TNC_ConnectionState state;
40
41 /**
42 * Does the TNCCS connection support long message types?
43 */
44 bool has_long;
45
46 /**
47 * Does the TNCCS connection support exclusive delivery?
48 */
49 bool has_excl;
50
51 /**
52 * Maximum PA-TNC message size for this TNCCS connection
53 */
54 u_int32_t max_msg_len;
55 };
56
57 METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
58 private_imc_scanner_state_t *this)
59 {
60 return this->connection_id;
61 }
62
63 METHOD(imc_state_t, has_long, bool,
64 private_imc_scanner_state_t *this)
65 {
66 return this->has_long;
67 }
68
69 METHOD(imc_state_t, has_excl, bool,
70 private_imc_scanner_state_t *this)
71 {
72 return this->has_excl;
73 }
74
75 METHOD(imc_state_t, set_flags, void,
76 private_imc_scanner_state_t *this, bool has_long, bool has_excl)
77 {
78 this->has_long = has_long;
79 this->has_excl = has_excl;
80 }
81
82 METHOD(imc_state_t, set_max_msg_len, void,
83 private_imc_scanner_state_t *this, u_int32_t max_msg_len)
84 {
85 this->max_msg_len = max_msg_len;
86 }
87
88 METHOD(imc_state_t, get_max_msg_len, u_int32_t,
89 private_imc_scanner_state_t *this)
90 {
91 return this->max_msg_len;
92 }
93
94 METHOD(imc_state_t, change_state, void,
95 private_imc_scanner_state_t *this, TNC_ConnectionState new_state)
96 {
97 this->state = new_state;
98 }
99
100 METHOD(imc_state_t, destroy, void,
101 private_imc_scanner_state_t *this)
102 {
103 free(this);
104 }
105
106 /**
107 * Described in header.
108 */
109 imc_state_t *imc_scanner_state_create(TNC_ConnectionID connection_id)
110 {
111 private_imc_scanner_state_t *this;
112
113 INIT(this,
114 .public = {
115 .interface = {
116 .get_connection_id = _get_connection_id,
117 .has_long = _has_long,
118 .has_excl = _has_excl,
119 .set_flags = _set_flags,
120 .set_max_msg_len = _set_max_msg_len,
121 .get_max_msg_len = _get_max_msg_len,
122 .change_state = _change_state,
123 .destroy = _destroy,
124 },
125 },
126 .state = TNC_CONNECTION_STATE_CREATE,
127 .connection_id = connection_id,
128 );
129
130 return &this->public.interface;
131 }
132
133