2 * Copyright (C) 2011 Sansar Choinyambuu
3 * HSR Hochschule fuer Technik Rapperswil
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>.
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
16 #include "imc_attestation_state.h"
18 #include <utils/linked_list.h>
21 typedef struct private_imc_attestation_state_t private_imc_attestation_state_t
;
24 * Private data of an imc_attestation_state_t object.
26 struct private_imc_attestation_state_t
{
29 * Public members of imc_attestation_state_t
31 imc_attestation_state_t
public;
36 TNC_ConnectionID connection_id
;
39 * TNCCS connection state
41 TNC_ConnectionState state
;
44 * Does the TNCCS connection support long message types?
49 * Does the TNCCS connection support exclusive delivery?
59 * PTS Component Evidence list
65 METHOD(imc_state_t
, get_connection_id
, TNC_ConnectionID
,
66 private_imc_attestation_state_t
*this)
68 return this->connection_id
;
71 METHOD(imc_state_t
, has_long
, bool,
72 private_imc_attestation_state_t
*this)
74 return this->has_long
;
77 METHOD(imc_state_t
, has_excl
, bool,
78 private_imc_attestation_state_t
*this)
80 return this->has_excl
;
83 METHOD(imc_state_t
, set_flags
, void,
84 private_imc_attestation_state_t
*this, bool has_long
, bool has_excl
)
86 this->has_long
= has_long
;
87 this->has_excl
= has_excl
;
90 METHOD(imc_state_t
, change_state
, void,
91 private_imc_attestation_state_t
*this, TNC_ConnectionState new_state
)
93 this->state
= new_state
;
97 METHOD(imc_state_t
, destroy
, void,
98 private_imc_attestation_state_t
*this)
100 this->pts
->destroy(this->pts
);
101 this->list
->destroy_offset(this->list
, offsetof(pts_comp_evidence_t
, destroy
));
105 METHOD(imc_attestation_state_t
, get_pts
, pts_t
*,
106 private_imc_attestation_state_t
*this)
111 METHOD(imc_attestation_state_t
, add_evidence
, void,
112 private_imc_attestation_state_t
*this, pts_comp_evidence_t
*evidence
)
114 this->list
->insert_last(this->list
, evidence
);
117 METHOD(imc_attestation_state_t
, next_evidence
, bool,
118 private_imc_attestation_state_t
*this, pts_comp_evidence_t
**evid
)
120 return this->list
->remove_first(this->list
, (void**)evid
) == SUCCESS
;
124 * Described in header.
126 imc_state_t
*imc_attestation_state_create(TNC_ConnectionID connection_id
)
128 private_imc_attestation_state_t
*this;
134 .get_connection_id
= _get_connection_id
,
135 .has_long
= _has_long
,
136 .has_excl
= _has_excl
,
137 .set_flags
= _set_flags
,
138 .change_state
= _change_state
,
142 .add_evidence
= _add_evidence
,
143 .next_evidence
= _next_evidence
,
145 .connection_id
= connection_id
,
146 .state
= TNC_CONNECTION_STATE_CREATE
,
147 .pts
= pts_create(TRUE
),
148 .list
= linked_list_create(),
151 platform_info
= lib
->settings
->get_str(lib
->settings
,
152 "libimcv.plugins.imc-attestation.platform_info", NULL
);
155 this->pts
->set_platform_info(this->pts
, platform_info
);
158 return &this->public.interface
;