Defined generic non-nul terminated string PA-TNC attribute
This commit is contained in:
@@ -37,6 +37,7 @@ libimcv_la_SOURCES = \
|
||||
imv/imv_session_manager.h imv/imv_session_manager.c \
|
||||
imv/imv_workitem.h imv/imv_workitem.c \
|
||||
generic/generic_attr_bool.h generic/generic_attr_bool.c \
|
||||
generic/generic_attr_string.h generic/generic_attr_string.c \
|
||||
ietf/ietf_attr.h ietf/ietf_attr.c \
|
||||
ietf/ietf_attr_assess_result.h ietf/ietf_attr_assess_result.c \
|
||||
ietf/ietf_attr_attr_request.h ietf/ietf_attr_attr_request.c \
|
||||
@@ -54,7 +55,6 @@ libimcv_la_SOURCES = \
|
||||
ita/ita_attr_get_settings.h ita/ita_attr_get_settings.c \
|
||||
ita/ita_attr_settings.h ita/ita_attr_settings.c \
|
||||
ita/ita_attr_angel.h ita/ita_attr_angel.c \
|
||||
ita/ita_attr_device_id.h ita/ita_attr_device_id.c \
|
||||
os_info/os_info.h os_info/os_info.c \
|
||||
pa_tnc/pa_tnc_attr.h \
|
||||
pa_tnc/pa_tnc_msg.h pa_tnc/pa_tnc_msg.c \
|
||||
|
||||
@@ -124,14 +124,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
|
||||
bio_reader_t *reader;
|
||||
u_int32_t status;
|
||||
|
||||
pa_attr_names = imcv_pa_tnc_attributes->get_names(imcv_pa_tnc_attributes,
|
||||
this->type.vendor_id);
|
||||
*offset = 0;
|
||||
|
||||
if (this->value.len < this->length)
|
||||
{
|
||||
return NEED_MORE;
|
||||
}
|
||||
pa_attr_names = imcv_pa_tnc_attributes->get_names(imcv_pa_tnc_attributes,
|
||||
this->type.vendor_id);
|
||||
|
||||
if (this->value.len != ATTR_BOOL_SIZE)
|
||||
{
|
||||
DBG1(DBG_TNC, "incorrect attribute size for %N/%N",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Andreas Steffen
|
||||
* Copyright (C) 2013-2015 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -13,24 +13,23 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#include "ita_attr.h"
|
||||
#include "ita_attr_device_id.h"
|
||||
#include "generic_attr_string.h"
|
||||
|
||||
#include <imcv.h>
|
||||
#include <pen/pen.h>
|
||||
|
||||
#include <utils/debug.h>
|
||||
|
||||
typedef struct private_ita_attr_device_id_t private_ita_attr_device_id_t;
|
||||
typedef struct private_generic_attr_string_t private_generic_attr_string_t;
|
||||
|
||||
/**
|
||||
* Private data of an ita_attr_device_id_t object.
|
||||
* Private data of an generic_attr_string_t object.
|
||||
*/
|
||||
struct private_ita_attr_device_id_t {
|
||||
struct private_generic_attr_string_t {
|
||||
|
||||
/**
|
||||
* Public members of ita_attr_device_id_t
|
||||
* Public members of generic_attr_string_t
|
||||
*/
|
||||
ita_attr_device_id_t public;
|
||||
generic_attr_string_t public;
|
||||
|
||||
/**
|
||||
* Vendor-specific attribute type
|
||||
@@ -59,62 +58,76 @@ struct private_ita_attr_device_id_t {
|
||||
};
|
||||
|
||||
METHOD(pa_tnc_attr_t, get_type, pen_type_t,
|
||||
private_ita_attr_device_id_t *this)
|
||||
private_generic_attr_string_t *this)
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, get_value, chunk_t,
|
||||
private_ita_attr_device_id_t *this)
|
||||
private_generic_attr_string_t *this)
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
|
||||
private_ita_attr_device_id_t *this)
|
||||
private_generic_attr_string_t *this)
|
||||
{
|
||||
return this->noskip_flag;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, set_noskip_flag,void,
|
||||
private_ita_attr_device_id_t *this, bool noskip)
|
||||
private_generic_attr_string_t *this, bool noskip)
|
||||
{
|
||||
this->noskip_flag = noskip;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, build, void,
|
||||
private_ita_attr_device_id_t *this)
|
||||
private_generic_attr_string_t *this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, process, status_t,
|
||||
private_ita_attr_device_id_t *this, u_int32_t *offset)
|
||||
private_generic_attr_string_t *this, u_int32_t *offset)
|
||||
{
|
||||
enum_name_t *pa_attr_names;
|
||||
u_char *pos;
|
||||
*offset = 0;
|
||||
|
||||
if (this->value.len < this->length)
|
||||
{
|
||||
return NEED_MORE;
|
||||
}
|
||||
pa_attr_names = imcv_pa_tnc_attributes->get_names(imcv_pa_tnc_attributes,
|
||||
this->type.vendor_id);
|
||||
|
||||
pos = memchr(this->value.ptr, '\0', this->value.len);
|
||||
if (pos)
|
||||
{
|
||||
DBG1(DBG_TNC, "nul termination in %N/%N string attribute",
|
||||
pen_names, this->type.vendor_id, pa_attr_names, this->type.type);
|
||||
*offset = pos - this->value.ptr;
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, add_segment, void,
|
||||
private_ita_attr_device_id_t *this, chunk_t segment)
|
||||
private_generic_attr_string_t *this, chunk_t segment)
|
||||
{
|
||||
this->value = chunk_cat("mc", this->value, segment);
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
|
||||
private_ita_attr_device_id_t *this)
|
||||
private_generic_attr_string_t *this)
|
||||
{
|
||||
ref_get(&this->ref);
|
||||
return &this->public.pa_tnc_attribute;
|
||||
}
|
||||
|
||||
METHOD(pa_tnc_attr_t, destroy, void,
|
||||
private_ita_attr_device_id_t *this)
|
||||
private_generic_attr_string_t *this)
|
||||
{
|
||||
if (ref_put(&this->ref))
|
||||
{
|
||||
@@ -126,9 +139,10 @@ METHOD(pa_tnc_attr_t, destroy, void,
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
pa_tnc_attr_t *ita_attr_device_id_create_from_data(size_t length, chunk_t value)
|
||||
pa_tnc_attr_t *generic_attr_string_create_from_data(size_t length,
|
||||
chunk_t value, pen_type_t type)
|
||||
{
|
||||
private_ita_attr_device_id_t *this;
|
||||
private_generic_attr_string_t *this;
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
@@ -144,7 +158,7 @@ pa_tnc_attr_t *ita_attr_device_id_create_from_data(size_t length, chunk_t value)
|
||||
.destroy = _destroy,
|
||||
},
|
||||
},
|
||||
.type = { PEN_ITA, ITA_ATTR_DEVICE_ID },
|
||||
.type = type,
|
||||
.length = length,
|
||||
.value = chunk_clone(value),
|
||||
.ref = 1,
|
||||
@@ -156,8 +170,8 @@ pa_tnc_attr_t *ita_attr_device_id_create_from_data(size_t length, chunk_t value)
|
||||
/**
|
||||
* Described in header.
|
||||
*/
|
||||
pa_tnc_attr_t *ita_attr_device_id_create(chunk_t value)
|
||||
pa_tnc_attr_t *generic_attr_string_create(chunk_t value, pen_type_t type)
|
||||
{
|
||||
return ita_attr_device_id_create_from_data(value.len, value);
|
||||
return generic_attr_string_create_from_data(value.len, value, type);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Andreas Steffen
|
||||
* Copyright (C) 2015 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -14,43 +14,46 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup ita_attr_device_id ita_attr_device_id
|
||||
* @{ @ingroup ita_attr
|
||||
* @defgroup generic_attr_string generic_attr_string
|
||||
* @{ @ingroup generic_attr
|
||||
*/
|
||||
|
||||
#ifndef ITA_ATTR_DEVICE_ID_H_
|
||||
#define ITA_ATTR_DEVICE_ID_H_
|
||||
#ifndef GENERIC_ATTR_STRING_H_
|
||||
#define GENERIC_ATTR_STRING_H_
|
||||
|
||||
typedef struct ita_attr_device_id_t ita_attr_device_id_t;
|
||||
typedef struct generic_attr_string_t generic_attr_string_t;
|
||||
|
||||
#include <pen/pen.h>
|
||||
#include "pa_tnc/pa_tnc_attr.h"
|
||||
|
||||
/**
|
||||
* Class implementing the ITA Device ID PA-TNC attribute.
|
||||
*
|
||||
* Class implementing a generic PA-TNC attribute containing a non-nul
|
||||
* terminated string
|
||||
*/
|
||||
struct ita_attr_device_id_t {
|
||||
struct generic_attr_string_t {
|
||||
|
||||
/**
|
||||
* Public PA-TNC attribute interface
|
||||
*/
|
||||
pa_tnc_attr_t pa_tnc_attribute;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an ita_attr_device_id_t object
|
||||
* Creates a generic_attr_string_t object
|
||||
*
|
||||
* @param value ITA Device ID attribute value
|
||||
* @param string Non-nul terminated string
|
||||
* @param type Vendor ID / Attribute Type
|
||||
*/
|
||||
pa_tnc_attr_t* ita_attr_device_id_create(chunk_t value);
|
||||
pa_tnc_attr_t* generic_attr_string_create(chunk_t string, pen_type_t type);
|
||||
|
||||
/**
|
||||
* Creates an ita_attr_device_id_t object from received data
|
||||
* Creates an generic_attr_string_t object from received data
|
||||
*
|
||||
* @param length Total length of attribute value
|
||||
* @param value Unparsed attribute value (might be a segment)
|
||||
* @param type Vendor ID / Attribute Type
|
||||
*/
|
||||
pa_tnc_attr_t* ita_attr_device_id_create_from_data(size_t length, chunk_t value);
|
||||
pa_tnc_attr_t* generic_attr_string_create_from_data(size_t length,
|
||||
chunk_t value, pen_type_t type);
|
||||
|
||||
#endif /** ITA_ATTR_DEVICE_ID_H_ @}*/
|
||||
#endif /** GENERIC_ATTR_STRING_H_ @}*/
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "ita/ita_attr_get_settings.h"
|
||||
#include "ita/ita_attr_settings.h"
|
||||
#include "ita/ita_attr_angel.h"
|
||||
#include "ita/ita_attr_device_id.h"
|
||||
#include "generic/generic_attr_string.h"
|
||||
|
||||
ENUM(ita_attr_names, ITA_ATTR_COMMAND, ITA_ATTR_DEVICE_ID,
|
||||
"Command",
|
||||
@@ -53,7 +53,8 @@ pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, size_t length,
|
||||
case ITA_ATTR_STOP_ANGEL:
|
||||
return ita_attr_angel_create_from_data(FALSE);
|
||||
case ITA_ATTR_DEVICE_ID:
|
||||
return ita_attr_device_id_create_from_data(length, value);
|
||||
return generic_attr_string_create_from_data(length, value,
|
||||
pen_type_create(PEN_ITA, type));
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <imc/imc_msg.h>
|
||||
#include <imc/imc_os_info.h>
|
||||
#include <generic/generic_attr_bool.h>
|
||||
#include <generic/generic_attr_string.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_attr_request.h>
|
||||
#include <ietf/ietf_attr_installed_packages.h>
|
||||
@@ -29,7 +30,6 @@
|
||||
#include <ita/ita_attr.h>
|
||||
#include <ita/ita_attr_get_settings.h>
|
||||
#include <ita/ita_attr_settings.h>
|
||||
#include <ita/ita_attr_device_id.h>
|
||||
|
||||
#include <tncif_pa_subtypes.h>
|
||||
|
||||
@@ -331,7 +331,8 @@ static void add_device_id(imc_msg_t *msg)
|
||||
}
|
||||
|
||||
DBG1(DBG_IMC, "device ID is %.*s", value.len, value.ptr);
|
||||
attr = ita_attr_device_id_create(value);
|
||||
attr = generic_attr_string_create(value, pen_type_create(PEN_ITA,
|
||||
ITA_ATTR_DEVICE_ID));
|
||||
msg->add_attribute(msg, attr);
|
||||
free(value.ptr);
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
#include <imv/imv_msg.h>
|
||||
#include <imv/imv_session.h>
|
||||
#include <imv/imv_os_info.h>
|
||||
#include <generic/generic_attr_string.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_attr_request.h>
|
||||
#include <ietf/ietf_attr_pa_tnc_error.h>
|
||||
#include <ietf/ietf_attr_product_info.h>
|
||||
#include <ietf/ietf_attr_string_version.h>
|
||||
#include <ita/ita_attr.h>
|
||||
#include <ita/ita_attr_device_id.h>
|
||||
#include <tcg/tcg_attr.h>
|
||||
#include <tcg/pts/tcg_pts_attr_meas_algo.h>
|
||||
#include <tcg/pts/tcg_pts_attr_proto_caps.h>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <imv/imv_agent.h>
|
||||
#include <imv/imv_msg.h>
|
||||
#include <generic/generic_attr_bool.h>
|
||||
#include <generic/generic_attr_string.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_attr_request.h>
|
||||
#include <ietf/ietf_attr_installed_packages.h>
|
||||
@@ -36,7 +37,6 @@
|
||||
#include <ita/ita_attr.h>
|
||||
#include <ita/ita_attr_get_settings.h>
|
||||
#include <ita/ita_attr_settings.h>
|
||||
#include <ita/ita_attr_device_id.h>
|
||||
#include "tcg/seg/tcg_seg_attr_max_size.h"
|
||||
#include "tcg/seg/tcg_seg_attr_seg_env.h"
|
||||
|
||||
|
||||
+13
-11
@@ -83,28 +83,30 @@ pa_tnc_attr_t* pwg_attr_create_from_data(u_int32_t type, size_t length, chunk_t
|
||||
case PWG_HCD_PSTN_FAX_ENABLED:
|
||||
return generic_attr_bool_create_from_data(length, value,
|
||||
pen_type_create(PEN_PWG, type));
|
||||
case PWG_HCD_FIREWALL_SETTING:
|
||||
return ietf_attr_port_filter_create_from_data(length, value,
|
||||
pen_type_create(PEN_PWG, type));
|
||||
case PWG_HCD_ATTRS_NATURAL_LANG:
|
||||
case PWG_HCD_MACHINE_TYPE_MODEL:
|
||||
case PWG_HCD_VENDOR_NAME:
|
||||
case PWG_HCD_VENDOR_SMI_CODE:
|
||||
case PWG_HCD_TIME_SOURCE:
|
||||
case PWG_HCD_FIRMWARE_NAME:
|
||||
case PWG_HCD_FIRMWARE_PATCHES:
|
||||
case PWG_HCD_FIRMWARE_STRING_VERSION:
|
||||
case PWG_HCD_FIRMWARE_VERSION:
|
||||
case PWG_HCD_RESIDENT_APP_NAME:
|
||||
case PWG_HCD_RESIDENT_APP_PATCHES:
|
||||
case PWG_HCD_RESIDENT_APP_STRING_VERSION:
|
||||
case PWG_HCD_RESIDENT_APP_VERSION:
|
||||
case PWG_HCD_TIME_SOURCE:
|
||||
case PWG_HCD_USER_APP_NAME:
|
||||
case PWG_HCD_USER_APP_PATCHES:
|
||||
case PWG_HCD_USER_APP_STRING_VERSION:
|
||||
case PWG_HCD_USER_APP_VERSION:
|
||||
case PWG_HCD_RESIDENT_APP_NAME:
|
||||
case PWG_HCD_RESIDENT_APP_PATCHES:
|
||||
case PWG_HCD_RESIDENT_APP_STRING_VERSION:
|
||||
case PWG_HCD_CERTIFICATION_STATE:
|
||||
case PWG_HCD_CONFIGURATION_STATE:
|
||||
return generic_attr_string_create_from_data(length, value,
|
||||
pen_type_create(PEN_PWG, type));
|
||||
case PWG_HCD_FIREWALL_SETTING:
|
||||
return ietf_attr_port_filter_create_from_data(length, value,
|
||||
pen_type_create(PEN_PWG, type));
|
||||
case PWG_HCD_VENDOR_SMI_CODE:
|
||||
case PWG_HCD_FIRMWARE_VERSION:
|
||||
case PWG_HCD_RESIDENT_APP_VERSION:
|
||||
case PWG_HCD_USER_APP_VERSION:
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user