diff options
author | Yves-Alexis Perez <corsac@debian.org> | 2013-10-17 21:23:38 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@debian.org> | 2013-10-17 21:23:38 +0200 |
commit | 9d37ad77ef660b92ea51b69d74e14f931d2a04e2 (patch) | |
tree | d6bbb4a5fed1959f8675df9ee7c03713b543fcc9 /src/libimcv/ita/ita_attr_command.c | |
parent | 104f57d4b0fb6d7547d6898352eaa5fb4b222010 (diff) | |
parent | e5ee4e7fcdd58b7d86bf1b458da2c63e8e19627b (diff) | |
download | vyos-strongswan-9d37ad77ef660b92ea51b69d74e14f931d2a04e2.tar.gz vyos-strongswan-9d37ad77ef660b92ea51b69d74e14f931d2a04e2.zip |
Merge tag 'v5.1.0-1' into sid
tag strongSwan 5.1.0-1
Diffstat (limited to 'src/libimcv/ita/ita_attr_command.c')
-rw-r--r-- | src/libimcv/ita/ita_attr_command.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/src/libimcv/ita/ita_attr_command.c b/src/libimcv/ita/ita_attr_command.c index 5c1577a7c..f32ab2bfe 100644 --- a/src/libimcv/ita/ita_attr_command.c +++ b/src/libimcv/ita/ita_attr_command.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 @@ -16,8 +17,9 @@ #include "ita_attr_command.h" #include <pen/pen.h> +#include <utils/debug.h> -#include <debug.h> +#include <string.h> typedef struct private_ita_attr_command_t private_ita_attr_command_t; @@ -32,14 +34,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 @@ -62,13 +59,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; @@ -95,6 +86,10 @@ METHOD(pa_tnc_attr_t, set_noskip_flag,void, METHOD(pa_tnc_attr_t, build, void, private_ita_attr_command_t *this) { + if (this->value.ptr) + { + return; + } this->value = chunk_create(this->command, strlen(this->command)); this->value = chunk_clone(this->value); } @@ -102,11 +97,9 @@ METHOD(pa_tnc_attr_t, build, void, METHOD(pa_tnc_attr_t, process, status_t, private_ita_attr_command_t *this, u_int32_t *offset) { - this->command = malloc(this->value.len + 1); - memcpy(this->command, this->value.ptr, this->value.len); - this->command[this->value.len] = '\0'; + this->command = strndup(this->value.ptr, this->value.len); - return SUCCESS; + return SUCCESS; } METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*, @@ -143,7 +136,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, @@ -155,8 +147,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, ); @@ -174,9 +165,10 @@ 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, + .get_noskip_flag = _get_noskip_flag, + .set_noskip_flag = _set_noskip_flag, .build = _build, .process = _process, .get_ref = _get_ref, @@ -184,8 +176,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, ); |