aboutsummaryrefslogtreecommitdiffstats
path: root/src/libimcv
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2012-08-20 22:37:08 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2012-08-20 22:37:08 +0200
commitdbb7859f9f3a82da2c379d7f257a6810540e4dd8 (patch)
treebe6f7a5d9502e85f1ff401c4661037c6b869daf2 /src/libimcv
parent88a5abf5e202b4aedae85a7891b759fe15b6198a (diff)
downloadstrongswan-dbb7859f9f3a82da2c379d7f257a6810540e4dd8.tar.bz2
strongswan-dbb7859f9f3a82da2c379d7f257a6810540e4dd8.tar.xz
define pen_type_t as a vendor-specific type
Diffstat (limited to 'src/libimcv')
-rw-r--r--src/libimcv/ietf/ietf_attr_attr_request.c25
-rw-r--r--src/libimcv/ietf/ietf_attr_pa_tnc_error.c78
-rw-r--r--src/libimcv/ietf/ietf_attr_pa_tnc_error.h18
-rw-r--r--src/libimcv/ietf/ietf_attr_port_filter.c25
-rw-r--r--src/libimcv/ietf/ietf_attr_product_info.c25
-rw-r--r--src/libimcv/ita/ita_attr_command.c25
-rw-r--r--src/libimcv/ita/ita_attr_dummy.c25
-rw-r--r--src/libimcv/pa_tnc/pa_tnc_attr.h15
-rw-r--r--src/libimcv/pa_tnc/pa_tnc_msg.c75
-rw-r--r--src/libimcv/plugins/imc_test/imc_test.c9
-rw-r--r--src/libimcv/plugins/imv_scanner/imv_scanner.c6
-rw-r--r--src/libimcv/plugins/imv_test/imv_test.c9
12 files changed, 115 insertions, 220 deletions
diff --git a/src/libimcv/ietf/ietf_attr_attr_request.c b/src/libimcv/ietf/ietf_attr_attr_request.c
index e173ef1bd..41040a5cf 100644
--- a/src/libimcv/ietf/ietf_attr_attr_request.c
+++ b/src/libimcv/ietf/ietf_attr_attr_request.c
@@ -55,14 +55,9 @@ struct private_ietf_attr_attr_request_t {
ietf_attr_attr_request_t public;
/**
- * Attribute vendor ID
+ * Vendor-specific attribute type
*/
- pen_t vendor_id;
-
- /**
- * Attribute type
- */
- u_int32_t type;
+ pen_type_t type;
/**
* Attribute value
@@ -93,13 +88,7 @@ struct entry_t {
u_int32_t type;
};
-METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
- private_ietf_attr_attr_request_t *this)
-{
- return this->vendor_id;
-}
-
-METHOD(pa_tnc_attr_t, get_type, u_int32_t,
+METHOD(pa_tnc_attr_t, get_type, pen_type_t,
private_ietf_attr_attr_request_t *this)
{
return this->type;
@@ -250,7 +239,6 @@ pa_tnc_attr_t *ietf_attr_attr_request_create(pen_t vendor_id, u_int32_t type)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -263,8 +251,7 @@ pa_tnc_attr_t *ietf_attr_attr_request_create(pen_t vendor_id, u_int32_t type)
.add = _add,
.create_enumerator = _create_enumerator,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_ATTRIBUTE_REQUEST,
+ .type = { PEN_IETF, IETF_ATTR_ATTRIBUTE_REQUEST },
.list = linked_list_create(),
.ref = 1,
);
@@ -283,7 +270,6 @@ pa_tnc_attr_t *ietf_attr_attr_request_create_from_data(chunk_t data)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.build = _build,
@@ -294,8 +280,7 @@ pa_tnc_attr_t *ietf_attr_attr_request_create_from_data(chunk_t data)
.add = _add,
.create_enumerator = _create_enumerator,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_ATTRIBUTE_REQUEST,
+ .type = { PEN_IETF,IETF_ATTR_ATTRIBUTE_REQUEST },
.value = chunk_clone(data),
.list = linked_list_create(),
.ref = 1,
diff --git a/src/libimcv/ietf/ietf_attr_pa_tnc_error.c b/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
index 479c47c30..46f5d6716 100644
--- a/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
+++ b/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2011 Andreas Steffen, HSR Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2011-2012 Andreas Steffen
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -107,14 +108,9 @@ struct private_ietf_attr_pa_tnc_error_t {
ietf_attr_pa_tnc_error_t public;
/**
- * Attribute vendor ID
+ * Vendor-specific attribute type
*/
- pen_t vendor_id;
-
- /**
- * Attribute type
- */
- u_int32_t type;
+ pen_type_t type;
/**
* Attribute value
@@ -127,14 +123,9 @@ struct private_ietf_attr_pa_tnc_error_t {
bool noskip_flag;
/**
- * Error code vendor ID
+ * Vendor-specific error code
*/
- pen_t error_vendor_id;
-
- /**
- * Error code
- */
- u_int32_t error_code;
+ pen_type_t error_code;
/**
* First 8 bytes of erroneous PA-TNC message
@@ -157,13 +148,7 @@ struct private_ietf_attr_pa_tnc_error_t {
refcount_t ref;
};
-METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
- private_ietf_attr_pa_tnc_error_t *this)
-{
- return this->vendor_id;
-}
-
-METHOD(pa_tnc_attr_t, get_type, u_int32_t,
+METHOD(pa_tnc_attr_t, get_type, pen_type_t,
private_ietf_attr_pa_tnc_error_t *this)
{
return this->type;
@@ -198,13 +183,13 @@ METHOD(pa_tnc_attr_t, build, void,
}
writer = bio_writer_create(PA_ERROR_HEADER_SIZE + PA_ERROR_MSG_INFO_SIZE);
writer->write_uint8 (writer, PA_ERROR_RESERVED);
- writer->write_uint24(writer, this->error_vendor_id);
- writer->write_uint32(writer, this->error_code);
+ writer->write_uint24(writer, this->error_code.vendor_id);
+ writer->write_uint32(writer, this->error_code.type);
writer->write_data (writer, this->msg_info);
- if (this->error_vendor_id == PEN_IETF)
+ if (this->error_code.vendor_id == PEN_IETF)
{
- switch (this->error_code)
+ switch (this->error_code.type)
{
case PA_ERROR_INVALID_PARAMETER:
writer->write_uint32(writer, this->error_offset);
@@ -239,10 +224,10 @@ METHOD(pa_tnc_attr_t, process, status_t,
}
reader = bio_reader_create(this->value);
reader->read_uint8 (reader, &reserved);
- reader->read_uint24(reader, &this->error_vendor_id);
- reader->read_uint32(reader, &this->error_code);
+ reader->read_uint24(reader, &this->error_code.vendor_id);
+ reader->read_uint32(reader, &this->error_code.type);
- if (this->error_vendor_id == PEN_IETF)
+ if (this->error_code.vendor_id == PEN_IETF)
{
if (!reader->read_data(reader, PA_ERROR_MSG_INFO_SIZE, &this->msg_info))
{
@@ -253,7 +238,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
}
this->msg_info = chunk_clone(this->msg_info);
- switch (this->error_code)
+ switch (this->error_code.type)
{
case PA_ERROR_INVALID_PARAMETER:
if (!reader->read_uint32(reader, &this->error_offset))
@@ -309,13 +294,7 @@ METHOD(pa_tnc_attr_t, destroy, void,
}
}
-METHOD(ietf_attr_pa_tnc_error_t, get_error_vendor_id, pen_t,
- private_ietf_attr_pa_tnc_error_t *this)
-{
- return this->error_vendor_id;
-}
-
-METHOD(ietf_attr_pa_tnc_error_t, get_error_code, u_int32_t,
+METHOD(ietf_attr_pa_tnc_error_t, get_error_code, pen_type_t,
private_ietf_attr_pa_tnc_error_t *this)
{
return this->error_code;
@@ -348,13 +327,12 @@ METHOD(ietf_attr_pa_tnc_error_t, get_offset, u_int32_t,
/**
* Described in header.
*/
-pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_t vendor_id,
- u_int32_t error_code,
+pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_type_t error_code,
chunk_t msg_info)
{
private_ietf_attr_pa_tnc_error_t *this;
- if (vendor_id == PEN_IETF)
+ if (error_code.vendor_id == PEN_IETF)
{
msg_info.len = PA_ERROR_MSG_INFO_SIZE;
}
@@ -366,7 +344,6 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_t vendor_id,
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -376,16 +353,13 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_t vendor_id,
.get_ref = _get_ref,
.destroy = _destroy,
},
- .get_vendor_id = _get_error_vendor_id,
.get_error_code = _get_error_code,
.get_msg_info = _get_msg_info,
.get_attr_info = _get_attr_info,
.set_attr_info = _set_attr_info,
.get_offset = _get_offset,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PA_TNC_ERROR,
- .error_vendor_id = vendor_id,
+ .type = { PEN_IETF, IETF_ATTR_PA_TNC_ERROR },
.error_code = error_code,
.msg_info = chunk_clone(msg_info),
.ref = 1,
@@ -397,8 +371,7 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_t vendor_id,
/**
* Described in header.
*/
-pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_with_offset(pen_t vendor_id,
- u_int32_t error_code,
+pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_with_offset(pen_type_t error_code,
chunk_t msg_info,
u_int32_t error_offset)
{
@@ -410,7 +383,6 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_with_offset(pen_t vendor_id,
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -420,16 +392,13 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_with_offset(pen_t vendor_id,
.get_ref = _get_ref,
.destroy = _destroy,
},
- .get_vendor_id = _get_error_vendor_id,
.get_error_code = _get_error_code,
.get_msg_info = _get_msg_info,
.get_attr_info = _get_attr_info,
.set_attr_info = _set_attr_info,
.get_offset = _get_offset,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PA_TNC_ERROR,
- .error_vendor_id = vendor_id,
+ .type = { PEN_IETF, IETF_ATTR_PA_TNC_ERROR },
.error_code = error_code,
.msg_info = chunk_clone(msg_info),
.error_offset = error_offset,
@@ -449,7 +418,6 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_from_data(chunk_t data)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.build = _build,
@@ -457,15 +425,13 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_from_data(chunk_t data)
.get_ref = _get_ref,
.destroy = _destroy,
},
- .get_vendor_id = _get_error_vendor_id,
.get_error_code = _get_error_code,
.get_msg_info = _get_msg_info,
.get_attr_info = _get_attr_info,
.set_attr_info = _set_attr_info,
.get_offset = _get_offset,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PA_TNC_ERROR,
+ .type = { PEN_IETF, IETF_ATTR_PA_TNC_ERROR },
.value = chunk_clone(data),
.ref = 1,
);
diff --git a/src/libimcv/ietf/ietf_attr_pa_tnc_error.h b/src/libimcv/ietf/ietf_attr_pa_tnc_error.h
index 945e06c62..d28c524aa 100644
--- a/src/libimcv/ietf/ietf_attr_pa_tnc_error.h
+++ b/src/libimcv/ietf/ietf_attr_pa_tnc_error.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2012 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -62,11 +62,11 @@ struct ietf_attr_pa_tnc_error_t {
pen_t (*get_vendor_id)(ietf_attr_pa_tnc_error_t *this);
/**
- * Get PA-TNC error code
+ * Get Vendor-specific PA-TNC error code
*
* @return error code
*/
- pa_tnc_error_code_t (*get_error_code)(ietf_attr_pa_tnc_error_t *this);
+ pen_type_t (*get_error_code)(ietf_attr_pa_tnc_error_t *this);
/**
* Get first 8 bytes of erroneous PA-TNC message
@@ -101,26 +101,22 @@ struct ietf_attr_pa_tnc_error_t {
/**
* Creates an ietf_attr_pa_tnc_error_t object from an error code
*
- * @param vendor_id PA-TNC error code vendor ID
- * @param error_code PA-TNC error code
+ * @param error_code Vendor-specific PA-TNC error code
* @param header PA-TNC message header (first 8 bytes)
*
*/
-pa_tnc_attr_t* ietf_attr_pa_tnc_error_create(pen_t vendor_id,
- u_int32_t error_code,
+pa_tnc_attr_t* ietf_attr_pa_tnc_error_create(pen_type_t error_code,
chunk_t header);
/**
* Creates an ietf_attr_pa_tnc_error_t object from an error code with offset
*
- * @param vendor_id PA-TNC error code vendor ID
- * @param error_code PA-TNC error code
+ * @param error_code Vendor-specifica PA-TNC error code
* @param header PA-TNC message header (first 8 bytes)
* @param error_offset PA-TNC error offset in bytes
*
*/
-pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_with_offset(pen_t vendor_id,
- u_int32_t error_code,
+pa_tnc_attr_t* ietf_attr_pa_tnc_error_create_with_offset(pen_type_t error_code,
chunk_t header,
u_int32_t error_offset);
diff --git a/src/libimcv/ietf/ietf_attr_port_filter.c b/src/libimcv/ietf/ietf_attr_port_filter.c
index ebf498cc0..5ea52256b 100644
--- a/src/libimcv/ietf/ietf_attr_port_filter.c
+++ b/src/libimcv/ietf/ietf_attr_port_filter.c
@@ -58,14 +58,9 @@ struct private_ietf_attr_port_filter_t {
ietf_attr_port_filter_t public;
/**
- * Attribute vendor ID
+ * Vendor-specific attribute type
*/
- pen_t vendor_id;
-
- /**
- * Attribute type
- */
- u_int32_t type;
+ pen_type_t type;
/**
* Attribute value
@@ -88,13 +83,7 @@ struct private_ietf_attr_port_filter_t {
refcount_t ref;
};
-METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
- private_ietf_attr_port_filter_t *this)
-{
- return this->vendor_id;
-}
-
-METHOD(pa_tnc_attr_t, get_type, u_int32_t,
+METHOD(pa_tnc_attr_t, get_type, pen_type_t,
private_ietf_attr_port_filter_t *this)
{
return this->type;
@@ -236,7 +225,6 @@ pa_tnc_attr_t *ietf_attr_port_filter_create(void)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -249,8 +237,7 @@ pa_tnc_attr_t *ietf_attr_port_filter_create(void)
.add_port = _add_port,
.create_port_enumerator = _create_port_enumerator,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PORT_FILTER,
+ .type = { PEN_IETF, IETF_ATTR_PORT_FILTER },
.ports = linked_list_create(),
.ref = 1,
);
@@ -268,7 +255,6 @@ pa_tnc_attr_t *ietf_attr_port_filter_create_from_data(chunk_t data)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.build = _build,
@@ -279,8 +265,7 @@ pa_tnc_attr_t *ietf_attr_port_filter_create_from_data(chunk_t data)
.add_port = _add_port,
.create_port_enumerator = _create_port_enumerator,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PORT_FILTER,
+ .type = {PEN_IETF, IETF_ATTR_PORT_FILTER },
.value = chunk_clone(data),
.ports = linked_list_create(),
.ref = 1,
diff --git a/src/libimcv/ietf/ietf_attr_product_info.c b/src/libimcv/ietf/ietf_attr_product_info.c
index 703a8ab6d..dcc0e0294 100644
--- a/src/libimcv/ietf/ietf_attr_product_info.c
+++ b/src/libimcv/ietf/ietf_attr_product_info.c
@@ -46,14 +46,9 @@ struct private_ietf_attr_product_info_t {
ietf_attr_product_info_t public;
/**
- * Attribute vendor ID
+ * Vendor-specific attribute type
*/
- pen_t vendor_id;
-
- /**
- * Attribute type
- */
- u_int32_t type;
+ pen_type_t type;
/**
* Attribute value
@@ -86,13 +81,7 @@ struct private_ietf_attr_product_info_t {
refcount_t ref;
};
-METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
- private_ietf_attr_product_info_t *this)
-{
- return this->vendor_id;
-}
-
-METHOD(pa_tnc_attr_t, get_type, u_int32_t,
+METHOD(pa_tnc_attr_t, get_type, pen_type_t,
private_ietf_attr_product_info_t *this)
{
return this->type;
@@ -205,7 +194,6 @@ pa_tnc_attr_t *ietf_attr_product_info_create(pen_t vendor_id, u_int16_t id,
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -217,8 +205,7 @@ pa_tnc_attr_t *ietf_attr_product_info_create(pen_t vendor_id, u_int16_t id,
},
.get_info = _get_info,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PRODUCT_INFORMATION,
+ .type = { PEN_IETF, IETF_ATTR_PRODUCT_INFORMATION },
.product_vendor_id = vendor_id,
.product_id = id,
.product_name = strdup(name),
@@ -238,7 +225,6 @@ pa_tnc_attr_t *ietf_attr_product_info_create_from_data(chunk_t data)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.build = _build,
@@ -248,8 +234,7 @@ pa_tnc_attr_t *ietf_attr_product_info_create_from_data(chunk_t data)
},
.get_info = _get_info,
},
- .vendor_id = PEN_IETF,
- .type = IETF_ATTR_PRODUCT_INFORMATION,
+ .type = { PEN_IETF, IETF_ATTR_PRODUCT_INFORMATION },
.value = chunk_clone(data),
.ref = 1,
);
diff --git a/src/libimcv/ita/ita_attr_command.c b/src/libimcv/ita/ita_attr_command.c
index d5a2bfcac..d43e4777b 100644
--- a/src/libimcv/ita/ita_attr_command.c
+++ b/src/libimcv/ita/ita_attr_command.c
@@ -33,14 +33,9 @@ struct private_ita_attr_command_t {
ita_attr_command_t public;
/**
- * Attribute vendor ID
+ * Vendor-specific attribute type
*/
- pen_t vendor_id;
-
- /**
- * Attribute type
- */
- u_int32_t type;
+ pen_type_t type;
/**
* Attribute value
@@ -63,13 +58,7 @@ struct private_ita_attr_command_t {
refcount_t ref;
};
-METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
- private_ita_attr_command_t *this)
-{
- return this->vendor_id;
-}
-
-METHOD(pa_tnc_attr_t, get_type, u_int32_t,
+METHOD(pa_tnc_attr_t, get_type, pen_type_t,
private_ita_attr_command_t *this)
{
return this->type;
@@ -148,7 +137,6 @@ pa_tnc_attr_t *ita_attr_command_create(char *command)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -160,8 +148,7 @@ pa_tnc_attr_t *ita_attr_command_create(char *command)
},
.get_command = _get_command,
},
- .vendor_id = PEN_ITA,
- .type = ITA_ATTR_COMMAND,
+ .type = { PEN_ITA, ITA_ATTR_COMMAND },
.command = strdup(command),
.ref = 1,
);
@@ -179,7 +166,6 @@ pa_tnc_attr_t *ita_attr_command_create_from_data(chunk_t data)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.build = _build,
@@ -189,8 +175,7 @@ pa_tnc_attr_t *ita_attr_command_create_from_data(chunk_t data)
},
.get_command = _get_command,
},
- .vendor_id = PEN_ITA,
- .type = ITA_ATTR_COMMAND,
+ .type = {PEN_ITA, ITA_ATTR_COMMAND },
.value = chunk_clone(data),
.ref = 1,
);
diff --git a/src/libimcv/ita/ita_attr_dummy.c b/src/libimcv/ita/ita_attr_dummy.c
index 59b5d221c..f122256a1 100644
--- a/src/libimcv/ita/ita_attr_dummy.c
+++ b/src/libimcv/ita/ita_attr_dummy.c
@@ -33,14 +33,9 @@ struct private_ita_attr_dummy_t {
ita_attr_dummy_t public;
/**
- * Attribute vendor ID
+ * Vendor-specific attribute type
*/
- pen_t vendor_id;
-
- /**
- * Attribute type
- */
- u_int32_t type;
+ pen_type_t type;
/**
* Attribute value
@@ -63,13 +58,7 @@ struct private_ita_attr_dummy_t {
refcount_t ref;
};
-METHOD(pa_tnc_attr_t, get_vendor_id, pen_t,
- private_ita_attr_dummy_t *this)
-{
- return this->vendor_id;
-}
-
-METHOD(pa_tnc_attr_t, get_type, u_int32_t,
+METHOD(pa_tnc_attr_t, get_type, pen_type_t,
private_ita_attr_dummy_t *this)
{
return this->type;
@@ -145,7 +134,6 @@ pa_tnc_attr_t *ita_attr_dummy_create(int size)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.get_noskip_flag = _get_noskip_flag,
@@ -157,8 +145,7 @@ pa_tnc_attr_t *ita_attr_dummy_create(int size)
},
.get_size = _get_size,
},
- .vendor_id = PEN_ITA,
- .type = ITA_ATTR_DUMMY,
+ .type = { PEN_ITA, ITA_ATTR_DUMMY },
.size = size,
.ref = 1,
);
@@ -176,7 +163,6 @@ pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
INIT(this,
.public = {
.pa_tnc_attribute = {
- .get_vendor_id = _get_vendor_id,
.get_type = _get_type,
.get_value = _get_value,
.build = _build,
@@ -186,8 +172,7 @@ pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
},
.get_size = _get_size,
},
- .vendor_id = PEN_ITA,
- .type = ITA_ATTR_DUMMY,
+ .type = { PEN_ITA, ITA_ATTR_DUMMY },
.value = chunk_clone(data),
.ref = 1,
);
diff --git a/src/libimcv/pa_tnc/pa_tnc_attr.h b/src/libimcv/pa_tnc/pa_tnc_attr.h
index b6057a70b..9abdba78c 100644
--- a/src/libimcv/pa_tnc/pa_tnc_attr.h
+++ b/src/libimcv/pa_tnc/pa_tnc_attr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2012 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -33,18 +33,11 @@ typedef struct pa_tnc_attr_t pa_tnc_attr_t;
struct pa_tnc_attr_t {
/**
- * Get the vendor ID of an PA-TNC attribute
+ * Get the vendor ID/type of an PA-TNC attribute
*
- * @return attribute vendor ID
+ * @return vendor-specific attribute type
*/
- u_int32_t (*get_vendor_id)(pa_tnc_attr_t *this);
-
- /**
- * Get the type of an PA-TNC attribute
- *
- * @return attribute type
- */
- u_int32_t (*get_type)(pa_tnc_attr_t *this);
+ pen_type_t (*get_type)(pa_tnc_attr_t *this);
/**
* Get the value of an PA-TNC attribute
diff --git a/src/libimcv/pa_tnc/pa_tnc_msg.c b/src/libimcv/pa_tnc/pa_tnc_msg.c
index 62e59f9bc..b1476fc7f 100644
--- a/src/libimcv/pa_tnc/pa_tnc_msg.c
+++ b/src/libimcv/pa_tnc/pa_tnc_msg.c
@@ -138,8 +138,7 @@ METHOD(pa_tnc_msg_t, build, bool,
enumerator_t *enumerator;
pa_tnc_attr_t *attr;
enum_name_t *pa_attr_names;
- pen_t vendor_id;
- u_int32_t type;
+ pen_type_t type;
u_int8_t flags;
chunk_t value;
nonce_gen_t *ng;
@@ -165,31 +164,30 @@ METHOD(pa_tnc_msg_t, build, bool,
enumerator = this->attributes->create_enumerator(this->attributes);
while (enumerator->enumerate(enumerator, &attr))
{
- vendor_id = attr->get_vendor_id(attr);
- type = attr->get_type(attr);
+ type = attr->get_type(attr);
value = attr->get_value(attr);
flags = attr->get_noskip_flag(attr) ? PA_TNC_ATTR_FLAG_NOSKIP :
PA_TNC_ATTR_FLAG_NONE;
pa_attr_names = imcv_pa_tnc_attributes->get_names(imcv_pa_tnc_attributes,
- vendor_id);
+ type.vendor_id);
if (pa_attr_names)
{
DBG2(DBG_TNC, "creating PA-TNC attribute type '%N/%N' "
- "0x%06x/0x%08x", pen_names, vendor_id,
- pa_attr_names, type, vendor_id, type);
+ "0x%06x/0x%08x", pen_names, type.vendor_id,
+ pa_attr_names, type.type, type.vendor_id, type.type);
}
else
{
DBG2(DBG_TNC, "creating PA-TNC attribute type '%N' "
- "0x%06x/0x%08x", pen_names, vendor_id,
- vendor_id, type);
+ "0x%06x/0x%08x", pen_names, type.vendor_id,
+ type.vendor_id, type.type);
}
DBG3(DBG_TNC, "%B", &value);
writer->write_uint8 (writer, flags);
- writer->write_uint24(writer, vendor_id);
- writer->write_uint32(writer, type);
+ writer->write_uint24(writer, type.vendor_id);
+ writer->write_uint32(writer, type.type);
writer->write_uint32(writer, PA_TNC_ATTR_HEADER_SIZE + value.len);
writer->write_data (writer, value);
}
@@ -209,6 +207,7 @@ METHOD(pa_tnc_msg_t, process, status_t,
pa_tnc_attr_t *error;
u_int8_t version;
u_int32_t reserved, offset, attr_offset;
+ pen_type_t error_code;
/* process message header */
if (this->encoding.len < PA_TNC_HEADER_SIZE)
@@ -225,9 +224,10 @@ METHOD(pa_tnc_msg_t, process, status_t,
if (version != PA_TNC_VERSION)
{
+ pen_type_t error_code = { PEN_IETF, PA_ERROR_VERSION_NOT_SUPPORTED };
+
DBG1(DBG_TNC, "PA-TNC version %u not supported", version);
- error = ietf_attr_pa_tnc_error_create(PEN_IETF,
- PA_ERROR_VERSION_NOT_SUPPORTED, this->encoding);
+ error = ietf_attr_pa_tnc_error_create(error_code, this->encoding);
goto err;
}
@@ -244,6 +244,7 @@ METHOD(pa_tnc_msg_t, process, status_t,
pa_tnc_attr_t *attr;
enum_name_t *pa_attr_names;
ietf_attr_pa_tnc_error_t *error_attr;
+ pen_type_t error_code;
attr_info = reader->peek(reader);
attr_info.len = PA_TNC_ATTR_INFO_SIZE;
@@ -271,18 +272,18 @@ METHOD(pa_tnc_msg_t, process, status_t,
{
DBG1(DBG_TNC, "%u bytes too small for PA-TNC attribute length",
length);
- error = ietf_attr_pa_tnc_error_create_with_offset(PEN_IETF,
- PA_ERROR_INVALID_PARAMETER, this->encoding,
- offset + PA_TNC_ATTR_INFO_SIZE);
+ error_code = pen_type_create(PEN_IETF, PA_ERROR_INVALID_PARAMETER);
+ error = ietf_attr_pa_tnc_error_create_with_offset(error_code,
+ this->encoding, offset + PA_TNC_ATTR_INFO_SIZE);
goto err;
}
if (!reader->read_data(reader, length - PA_TNC_ATTR_HEADER_SIZE, &value))
{
DBG1(DBG_TNC, "insufficient bytes for PA-TNC attribute value");
- error = ietf_attr_pa_tnc_error_create_with_offset(PEN_IETF,
- PA_ERROR_INVALID_PARAMETER, this->encoding,
- offset + PA_TNC_ATTR_INFO_SIZE);
+ error_code = pen_type_create(PEN_IETF, PA_ERROR_INVALID_PARAMETER);
+ error = ietf_attr_pa_tnc_error_create_with_offset(error_code,
+ this->encoding, offset + PA_TNC_ATTR_INFO_SIZE);
goto err;
}
DBG3(DBG_TNC, "%B", &value);
@@ -294,8 +295,10 @@ METHOD(pa_tnc_msg_t, process, status_t,
if (flags & PA_TNC_ATTR_FLAG_NOSKIP)
{
DBG1(DBG_TNC, "unsupported PA-TNC attribute with NOSKIP flag");
- error = ietf_attr_pa_tnc_error_create(PEN_IETF,
- PA_ERROR_ATTR_TYPE_NOT_SUPPORTED, this->encoding);
+ error_code = pen_type_create(PEN_IETF,
+ PA_ERROR_ATTR_TYPE_NOT_SUPPORTED);
+ error = ietf_attr_pa_tnc_error_create(error_code,
+ this->encoding);
error_attr = (ietf_attr_pa_tnc_error_t*)error;
error_attr->set_attr_info(error_attr, attr_info);
goto err;
@@ -311,14 +314,17 @@ METHOD(pa_tnc_msg_t, process, status_t,
if (attr->process(attr, &attr_offset) != SUCCESS)
{
attr->destroy(attr);
- if (vendor_id == PEN_IETF && type == IETF_ATTR_PA_TNC_ERROR)
+ if (error_code.vendor_id == PEN_IETF &&
+ error_code.type == IETF_ATTR_PA_TNC_ERROR)
{
/* error while processing a PA-TNC error attribute - abort */
reader->destroy(reader);
return FAILED;
}
- error = ietf_attr_pa_tnc_error_create_with_offset(PEN_IETF,
- PA_ERROR_INVALID_PARAMETER, this->encoding,
+ error_code = pen_type_create(PEN_IETF,
+ PA_ERROR_ATTR_TYPE_NOT_SUPPORTED);
+ error = ietf_attr_pa_tnc_error_create_with_offset(error_code,
+ this->encoding,
offset + PA_TNC_ATTR_HEADER_SIZE + attr_offset);
goto err;
}
@@ -332,8 +338,9 @@ METHOD(pa_tnc_msg_t, process, status_t,
return SUCCESS;
}
DBG1(DBG_TNC, "insufficient bytes for PA-TNC attribute header");
- error = ietf_attr_pa_tnc_error_create_with_offset(PEN_IETF,
- PA_ERROR_INVALID_PARAMETER, this->encoding, offset);
+ error_code = pen_type_create(PEN_IETF, PA_ERROR_INVALID_PARAMETER);
+ error = ietf_attr_pa_tnc_error_create_with_offset(error_code,
+ this->encoding, offset);
err:
reader->destroy(reader);
@@ -346,35 +353,35 @@ METHOD(pa_tnc_msg_t, process_ietf_std_errors, bool,
{
enumerator_t *enumerator;
pa_tnc_attr_t *attr;
+ pen_type_t type;
bool fatal_error = FALSE;
enumerator = this->attributes->create_enumerator(this->attributes);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_IETF &&
- attr->get_type(attr) == IETF_ATTR_PA_TNC_ERROR)
+ type = attr->get_type(attr);
+
+ if (type.vendor_id == PEN_IETF && type.type == IETF_ATTR_PA_TNC_ERROR)
{
ietf_attr_pa_tnc_error_t *error_attr;
- pen_t error_vendor_id;
- pa_tnc_error_code_t error_code;
+ pen_type_t error_code;
chunk_t msg_info, attr_info;
u_int32_t offset;
error_attr = (ietf_attr_pa_tnc_error_t*)attr;
- error_vendor_id = error_attr->get_vendor_id(error_attr);
error_code = error_attr->get_error_code(error_attr);
msg_info = error_attr->get_msg_info(error_attr);
/* skip errors from non-IETF namespaces */
- if (error_vendor_id != PEN_IETF)
+ if (error_code.vendor_id != PEN_IETF)
{
continue;
}
DBG1(DBG_IMC, "received PA-TNC error '%N' concerning message "
- "0x%08x/0x%08x", pa_tnc_error_code_names, error_code,
+ "0x%08x/0x%08x", pa_tnc_error_code_names, error_code.type,
untoh32(msg_info.ptr), untoh32(msg_info.ptr + 4));
- switch (error_code)
+ switch (error_code.type)
{
case PA_ERROR_INVALID_PARAMETER:
offset = error_attr->get_offset(error_attr);
diff --git a/src/libimcv/plugins/imc_test/imc_test.c b/src/libimcv/plugins/imc_test/imc_test.c
index 39442c3e8..bc2a233f6 100644
--- a/src/libimcv/plugins/imc_test/imc_test.c
+++ b/src/libimcv/plugins/imc_test/imc_test.c
@@ -257,6 +257,7 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
{
pa_tnc_msg_t *pa_tnc_msg;
pa_tnc_attr_t *attr;
+ pen_type_t attr_type;
imc_state_t *state;
enumerator_t *enumerator;
TNC_Result result;
@@ -291,11 +292,13 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) != PEN_ITA)
+ attr_type = attr->get_type(attr);
+
+ if (attr_type.vendor_id != PEN_ITA)
{
continue;
}
- if (attr->get_type(attr) == ITA_ATTR_COMMAND)
+ if (attr_type.type == ITA_ATTR_COMMAND)
{
ita_attr_command_t *ita_attr;
@@ -303,7 +306,7 @@ static TNC_Result receive_message(TNC_IMCID imc_id,
DBG1(DBG_IMC, "received command '%s'",
ita_attr->get_command(ita_attr));
}
- else if (attr->get_type(attr) == ITA_ATTR_DUMMY)
+ else if (attr_type.type == ITA_ATTR_DUMMY)
{
ita_attr_dummy_t *ita_attr;
diff --git a/src/libimcv/plugins/imv_scanner/imv_scanner.c b/src/libimcv/plugins/imv_scanner/imv_scanner.c
index 1146e44e6..1c5d18e75 100644
--- a/src/libimcv/plugins/imv_scanner/imv_scanner.c
+++ b/src/libimcv/plugins/imv_scanner/imv_scanner.c
@@ -187,6 +187,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
{
pa_tnc_msg_t *pa_tnc_msg;
pa_tnc_attr_t *attr;
+ pen_type_t type;
imv_state_t *state;
enumerator_t *enumerator;
TNC_Result result;
@@ -221,8 +222,9 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_IETF &&
- attr->get_type(attr) == IETF_ATTR_PORT_FILTER)
+ type = attr->get_type(attr);
+
+ if (type.vendor_id == PEN_IETF && type.type == IETF_ATTR_PORT_FILTER)
{
ietf_attr_port_filter_t *attr_port_filter;
enumerator_t *enumerator;
diff --git a/src/libimcv/plugins/imv_test/imv_test.c b/src/libimcv/plugins/imv_test/imv_test.c
index e183c5cf9..10a206b1c 100644
--- a/src/libimcv/plugins/imv_test/imv_test.c
+++ b/src/libimcv/plugins/imv_test/imv_test.c
@@ -103,6 +103,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
{
pa_tnc_msg_t *pa_tnc_msg;
pa_tnc_attr_t *attr;
+ pen_type_t attr_type;
linked_list_t *attr_list;
imv_state_t *state;
imv_test_state_t *test_state;
@@ -146,11 +147,13 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) != PEN_ITA)
+ attr_type = attr->get_type(attr);
+
+ if (attr_type.vendor_id != PEN_ITA)
{
continue;
}
- if (attr->get_type(attr) == ITA_ATTR_COMMAND)
+ if (attr_type.type == ITA_ATTR_COMMAND)
{
ita_attr_command_t *ita_attr;
char *command;
@@ -189,7 +192,7 @@ static TNC_Result receive_message(TNC_IMVID imv_id,
TNC_IMV_EVALUATION_RESULT_ERROR);
}
}
- else if (attr->get_type(attr) == ITA_ATTR_DUMMY)
+ else if (attr_type.type == ITA_ATTR_DUMMY)
{
ita_attr_dummy_t *ita_attr;