updated Copyright info
[strongswan.git] / src / libimcv / plugins / imc_scanner / imc_scanner_state.c
1 /*
2 * Copyright (C) 2011-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 #include "imc_scanner_state.h"
17
18 #include <debug.h>
19
20 typedef struct private_imc_scanner_state_t private_imc_scanner_state_t;
21
22 /**
23 * Private data of an imc_scanner_state_t object.
24 */
25 struct private_imc_scanner_state_t {
26
27 /**
28 * Public members of imc_scanner_state_t
29 */
30 imc_scanner_state_t public;
31
32 /**
33 * TNCCS connection ID
34 */
35 TNC_ConnectionID connection_id;
36
37 /**
38 * TNCCS connection state
39 */
40 TNC_ConnectionState state;
41
42 /**
43 * Does the TNCCS connection support long message types?
44 */
45 bool has_long;
46
47 /**
48 * Does the TNCCS connection support exclusive delivery?
49 */
50 bool has_excl;
51
52 /**
53 * Maximum PA-TNC message size for this TNCCS connection
54 */
55 u_int32_t max_msg_len;
56 };
57
58 METHOD(imc_state_t, get_connection_id, TNC_ConnectionID,
59 private_imc_scanner_state_t *this)
60 {
61 return this->connection_id;
62 }
63
64 METHOD(imc_state_t, has_long, bool,
65 private_imc_scanner_state_t *this)
66 {
67 return this->has_long;
68 }
69
70 METHOD(imc_state_t, has_excl, bool,
71 private_imc_scanner_state_t *this)
72 {
73 return this->has_excl;
74 }
75
76 METHOD(imc_state_t, set_flags, void,
77 private_imc_scanner_state_t *this, bool has_long, bool has_excl)
78 {
79 this->has_long = has_long;
80 this->has_excl = has_excl;
81 }
82
83 METHOD(imc_state_t, set_max_msg_len, void,
84 private_imc_scanner_state_t *this, u_int32_t max_msg_len)
85 {
86 this->max_msg_len = max_msg_len;
87 }
88
89 METHOD(imc_state_t, get_max_msg_len, u_int32_t,
90 private_imc_scanner_state_t *this)
91 {
92 return this->max_msg_len;
93 }
94
95 METHOD(imc_state_t, change_state, void,
96 private_imc_scanner_state_t *this, TNC_ConnectionState new_state)
97 {
98 this->state = new_state;
99 }
100
101 METHOD(imc_state_t, destroy, void,
102 private_imc_scanner_state_t *this)
103 {
104 free(this);
105 }
106
107 /**
108 * Described in header.
109 */
110 imc_state_t *imc_scanner_state_create(TNC_ConnectionID connection_id)
111 {
112 private_imc_scanner_state_t *this;
113
114 INIT(this,
115 .public = {
116 .interface = {
117 .get_connection_id = _get_connection_id,
118 .has_long = _has_long,
119 .has_excl = _has_excl,
120 .set_flags = _set_flags,
121 .set_max_msg_len = _set_max_msg_len,
122 .get_max_msg_len = _get_max_msg_len,
123 .change_state = _change_state,
124 .destroy = _destroy,
125 },
126 },
127 .state = TNC_CONNECTION_STATE_CREATE,
128 .connection_id = connection_id,
129 );
130
131 return &this->public.interface;
132 }
133
134