summaryrefslogtreecommitdiff
path: root/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-04-26 14:57:47 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-04-26 14:57:47 +0200
commit10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43 (patch)
treebf1d05a2e37dbd1911b86fcc026fbe49b0239c71 /src/libimcv/ietf/ietf_attr_pa_tnc_error.c
parent7585facf05d927eb6df3929ce09ed5e60d905437 (diff)
downloadvyos-strongswan-10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43.tar.gz
vyos-strongswan-10e5fb2b9b2f27c83b3e5a1d048b158d5cf42a43.zip
Imported Upstream version 5.0.3
Diffstat (limited to 'src/libimcv/ietf/ietf_attr_pa_tnc_error.c')
-rw-r--r--src/libimcv/ietf/ietf_attr_pa_tnc_error.c96
1 files changed, 33 insertions, 63 deletions
diff --git a/src/libimcv/ietf/ietf_attr_pa_tnc_error.c b/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
index f92022fe0..5f20f8958 100644
--- a/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
+++ b/src/libimcv/ietf/ietf_attr_pa_tnc_error.c
@@ -206,7 +206,7 @@ METHOD(pa_tnc_attr_t, build, void,
break;
}
}
- this->value = chunk_clone(writer->get_buf(writer));
+ this->value = writer->extract_buf(writer);
writer->destroy(writer);
}
@@ -325,22 +325,12 @@ METHOD(ietf_attr_pa_tnc_error_t, get_offset, u_int32_t,
}
/**
- * Described in header.
+ * Generic constructor
*/
-pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_type_t error_code,
- chunk_t msg_info)
+static private_ietf_attr_pa_tnc_error_t* create_generic()
{
private_ietf_attr_pa_tnc_error_t *this;
- if (error_code.vendor_id == PEN_IETF)
- {
- msg_info.len = PA_ERROR_MSG_INFO_SIZE;
- }
- else if (msg_info.len > PA_ERROR_MSG_INFO_MAX_SIZE)
- {
- msg_info.len = PA_ERROR_MSG_INFO_MAX_SIZE;
- }
-
INIT(this,
.public = {
.pa_tnc_attribute = {
@@ -360,11 +350,33 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create(pen_type_t error_code,
.get_offset = _get_offset,
},
.type = { PEN_IETF, IETF_ATTR_PA_TNC_ERROR },
- .error_code = error_code,
- .msg_info = chunk_clone(msg_info),
.ref = 1,
);
+ return this;
+}
+
+/**
+ * Described in header.
+ */
+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 (error_code.vendor_id == PEN_IETF)
+ {
+ msg_info.len = PA_ERROR_MSG_INFO_SIZE;
+ }
+ else if (msg_info.len > PA_ERROR_MSG_INFO_MAX_SIZE)
+ {
+ msg_info.len = PA_ERROR_MSG_INFO_MAX_SIZE;
+ }
+
+ this = create_generic();
+ this->error_code = error_code;
+ this->msg_info = chunk_clone(msg_info);
+
return &this->public.pa_tnc_attribute;
}
@@ -380,30 +392,10 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_with_offset(pen_type_t error_code,
/* the first 8 bytes of the erroneous PA-TNC message are sent back */
msg_info.len = PA_ERROR_MSG_INFO_SIZE;
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .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,
- },
- .type = { PEN_IETF, IETF_ATTR_PA_TNC_ERROR },
- .error_code = error_code,
- .msg_info = chunk_clone(msg_info),
- .error_offset = error_offset,
- .ref = 1,
- );
+ this = create_generic();
+ this->error_code = error_code;
+ this->msg_info = chunk_clone(msg_info);
+ this->error_offset = error_offset;
return &this->public.pa_tnc_attribute;
}
@@ -415,30 +407,8 @@ pa_tnc_attr_t *ietf_attr_pa_tnc_error_create_from_data(chunk_t data)
{
private_ietf_attr_pa_tnc_error_t *this;
- INIT(this,
- .public = {
- .pa_tnc_attribute = {
- .get_type = _get_type,
- .get_value = _get_value,
- .get_noskip_flag = _get_noskip_flag,
- .set_noskip_flag = _set_noskip_flag,
- .build = _build,
- .process = _process,
- .get_ref = _get_ref,
- .destroy = _destroy,
- },
- .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,
- },
- .type = { PEN_IETF, IETF_ATTR_PA_TNC_ERROR },
- .value = chunk_clone(data),
- .ref = 1,
- );
+ this = create_generic();
+ this->value = chunk_clone(data);
return &this->public.pa_tnc_attribute;
}
-
-