2 * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
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>.
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
15 #include "ita_attr_command.h"
17 #include <tnc/pen/pen.h>
20 typedef struct private_ita_attr_command_t private_ita_attr_command_t
;
23 * Private data of an ita_attr_command_t object.
25 struct private_ita_attr_command_t
{
28 * Public members of ita_attr_command_t
30 ita_attr_command_t
public;
58 METHOD(pa_tnc_attr_t
, get_vendor_id
, pen_t
,
59 private_ita_attr_command_t
*this)
61 return this->vendor_id
;
64 METHOD(pa_tnc_attr_t
, get_type
, u_int32_t
,
65 private_ita_attr_command_t
*this)
70 METHOD(pa_tnc_attr_t
, get_value
, chunk_t
,
71 private_ita_attr_command_t
*this)
76 METHOD(pa_tnc_attr_t
, get_noskip_flag
, bool,
77 private_ita_attr_command_t
*this)
79 return this->noskip_flag
;
82 METHOD(pa_tnc_attr_t
, set_noskip_flag
,void,
83 private_ita_attr_command_t
*this, bool noskip
)
85 this->noskip_flag
= noskip
;
88 METHOD(pa_tnc_attr_t
, build
, void,
89 private_ita_attr_command_t
*this)
91 this->value
= chunk_create(this->command
, strlen(this->command
));
92 this->value
= chunk_clone(this->value
);
95 METHOD(pa_tnc_attr_t
, process
, status_t
,
96 private_ita_attr_command_t
*this)
98 this->command
= malloc(this->value
.len
+ 1);
99 memcpy(this->command
, this->value
.ptr
, this->value
.len
);
100 this->command
[this->value
.len
] = '\0';
105 METHOD(pa_tnc_attr_t
, destroy
, void,
106 private_ita_attr_command_t
*this)
108 free(this->value
.ptr
);
113 METHOD(ita_attr_command_t
, get_command
, char*,
114 private_ita_attr_command_t
*this)
116 return this->command
;
120 * Described in header.
122 pa_tnc_attr_t
*ita_attr_command_create(char *command
)
124 private_ita_attr_command_t
*this;
128 .pa_tnc_attribute
= {
129 .get_vendor_id
= _get_vendor_id
,
130 .get_type
= _get_type
,
131 .get_value
= _get_value
,
132 .get_noskip_flag
= _get_noskip_flag
,
133 .set_noskip_flag
= _set_noskip_flag
,
138 .get_command
= _get_command
,
140 .vendor_id
= PEN_ITA
,
141 .type
= ITA_ATTR_COMMAND
,
142 .command
= strdup(command
),
145 return &this->public.pa_tnc_attribute
;
149 * Described in header.
151 pa_tnc_attr_t
*ita_attr_command_create_from_data(chunk_t data
)
153 private_ita_attr_command_t
*this;
157 .pa_tnc_attribute
= {
158 .get_vendor_id
= _get_vendor_id
,
159 .get_type
= _get_type
,
160 .get_value
= _get_value
,
165 .get_command
= _get_command
,
167 .vendor_id
= PEN_ITA
,
168 .type
= ITA_ATTR_COMMAND
,
169 .value
= chunk_clone(data
),
172 return &this->public.pa_tnc_attribute
;