ietf/ietf_attr_product_info.h ietf/ietf_attr_product_info.c \
ita/ita_attr.h ita/ita_attr.c \
ita/ita_attr_command.h ita/ita_attr_command.c \
+ ita/ita_attr_dummy.h ita/ita_attr_dummy.c \
pa_tnc/pa_tnc_attr.h \
pa_tnc/pa_tnc_msg.h pa_tnc/pa_tnc_msg.c \
pa_tnc/pa_tnc_attr_manager.h pa_tnc/pa_tnc_attr_manager.c
#include "ita_attr.h"
#include "ita/ita_attr_command.h"
+#include "ita/ita_attr_dummy.h"
-ENUM(ita_attr_names, ITA_ATTR_COMMAND, ITA_ATTR_COMMAND,
+ENUM(ita_attr_names, ITA_ATTR_COMMAND, ITA_ATTR_DUMMY,
"Command",
+ "Dummy",
);
/**
{
case ITA_ATTR_COMMAND:
return ita_attr_command_create_from_data(value);
+ case ITA_ATTR_DUMMY:
+ return ita_attr_dummy_create_from_data(value);
default:
return NULL;
}
*/
enum ita_attr_t {
ITA_ATTR_COMMAND = 1,
+ ITA_ATTR_DUMMY = 2,
};
/**
--- /dev/null
+/*
+ * Copyright (C) 2011 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "ita_attr.h"
+#include "ita_attr_dummy.h"
+
+#include <pen/pen.h>
+
+#include <debug.h>
+
+typedef struct private_ita_attr_dummy_t private_ita_attr_dummy_t;
+
+/**
+ * Private data of an ita_attr_dummy_t object.
+ */
+struct private_ita_attr_dummy_t {
+
+ /**
+ * Public members of ita_attr_dummy_t
+ */
+ ita_attr_dummy_t public;
+
+ /**
+ * Attribute vendor ID
+ */
+ pen_t vendor_id;
+
+ /**
+ * Attribute type
+ */
+ u_int32_t type;
+
+ /**
+ * Attribute value
+ */
+ chunk_t value;
+
+ /**
+ * Noskip flag
+ */
+ bool noskip_flag;
+
+ /**
+ * Size of the attribute value
+ */
+ int size;
+
+ /**
+ * Reference count
+ */
+ 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,
+ private_ita_attr_dummy_t *this)
+{
+ return this->type;
+}
+
+METHOD(pa_tnc_attr_t, get_value, chunk_t,
+ private_ita_attr_dummy_t *this)
+{
+ return this->value;
+}
+
+METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
+ private_ita_attr_dummy_t *this)
+{
+ return this->noskip_flag;
+}
+
+METHOD(pa_tnc_attr_t, set_noskip_flag,void,
+ private_ita_attr_dummy_t *this, bool noskip)
+{
+ this->noskip_flag = noskip;
+}
+
+METHOD(pa_tnc_attr_t, build, void,
+ private_ita_attr_dummy_t *this)
+{
+ this->value = chunk_alloc(this->size);
+ memset(this->value.ptr, 0xdd, this->value.len);
+}
+
+METHOD(pa_tnc_attr_t, process, status_t,
+ private_ita_attr_dummy_t *this, u_int32_t *offset)
+{
+ this->size = this->value.len;
+
+ return SUCCESS;
+}
+
+METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
+ private_ita_attr_dummy_t *this)
+{
+ ref_get(&this->ref);
+ return &this->public.pa_tnc_attribute;
+}
+
+METHOD(pa_tnc_attr_t, destroy, void,
+ private_ita_attr_dummy_t *this)
+{
+ if (ref_put(&this->ref))
+ {
+ free(this->value.ptr);
+ free(this);
+ }
+}
+
+METHOD(ita_attr_dummy_t, get_size, int,
+ private_ita_attr_dummy_t *this)
+{
+ return this->size;
+}
+
+/**
+ * Described in header.
+ */
+pa_tnc_attr_t *ita_attr_dummy_create(int size)
+{
+ private_ita_attr_dummy_t *this;
+
+ 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,
+ .destroy = _destroy,
+ },
+ .get_size = _get_size,
+ },
+ .vendor_id = PEN_ITA,
+ .type = ITA_ATTR_DUMMY,
+ .size = size,
+ .ref = 1,
+ );
+
+ return &this->public.pa_tnc_attribute;
+}
+
+/**
+ * Described in header.
+ */
+pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
+{
+ private_ita_attr_dummy_t *this;
+
+ INIT(this,
+ .public = {
+ .pa_tnc_attribute = {
+ .get_vendor_id = _get_vendor_id,
+ .get_type = _get_type,
+ .get_value = _get_value,
+ .build = _build,
+ .process = _process,
+ .get_ref = _get_ref,
+ .destroy = _destroy,
+ },
+ .get_size = _get_size,
+ },
+ .vendor_id = PEN_ITA,
+ .type = ITA_ATTR_DUMMY,
+ .value = chunk_clone(data),
+ .ref = 1,
+ );
+
+ return &this->public.pa_tnc_attribute;
+}
+
+
--- /dev/null
+/*
+ * Copyright (C) 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+/**
+ * @defgroup ita_attr_dummyt ita_attr_dummy
+ * @{ @ingroup ita_attr_dummy
+ */
+
+#ifndef ITA_ATTR_DUMMY_H_
+#define ITA_ATTR_DUMMY_H_
+
+typedef struct ita_attr_dummy_t ita_attr_dummy_t;
+
+#include "pa_tnc/pa_tnc_attr.h"
+
+/**
+ * Class implementing the ITA Dummy PA-TNC attribute.
+ *
+ */
+struct ita_attr_dummy_t {
+
+ /**
+ * Public PA-TNC attribute interface
+ */
+ pa_tnc_attr_t pa_tnc_attribute;
+
+ /**
+ * Get the size the ITA Dummy attribute value
+ *
+ * @return size of dummy attribute value
+ */
+ int (*get_size)(ita_attr_dummy_t *this);
+};
+
+/**
+ * Creates an ita_attr_dummy_t object with a given size
+ *
+ * @param size size of dummy attribute value
+ */
+pa_tnc_attr_t* ita_attr_dummy_create(int size);
+
+/**
+ * Creates an ita_attr_dummy_t object from received data
+ *
+ * @param command ITA command string
+ */
+pa_tnc_attr_t* ita_attr_dummy_create_from_data(chunk_t value);
+
+#endif /** ITA_ATTR_DUMMY_H_ @}*/
#include <ietf/ietf_attr_pa_tnc_error.h>
#include <ita/ita_attr.h>
#include <ita/ita_attr_command.h>
+#include <ita/ita_attr_dummy.h>
#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
TNC_Result result;
char *command;
bool retry;
- int additional_ids;
+ int dummy_size, additional_ids;
if (!imc_test)
{
case TNC_CONNECTION_STATE_CREATE:
command = lib->settings->get_str(lib->settings,
"libimcv.plugins.imc-test.command", "none");
+ dummy_size = lib->settings->get_int(lib->settings,
+ "libimcv.plugins.imc-test.dummy_size", 0);
retry = lib->settings->get_bool(lib->settings,
"libimcv.plugins.imc-test.retry", FALSE);
- state = imc_test_state_create(connection_id, command, retry);
+ state = imc_test_state_create(connection_id, command, dummy_size,
+ retry);
result = imc_test->create_state(imc_test, state);
if (result != TNC_RESULT_SUCCESS)
connection_id = state->get_connection_id(state);
test_state = (imc_test_state_t*)state;
+
+ msg = pa_tnc_msg_create();
+ if (test_state->get_dummy_size(test_state))
+ {
+ attr = ita_attr_dummy_create(test_state->get_dummy_size(test_state));
+ attr->set_noskip_flag(attr, TRUE);
+ msg->add_attribute(msg, attr);
+ }
attr = ita_attr_command_create(test_state->get_command(test_state));
attr->set_noskip_flag(attr, TRUE);
- msg = pa_tnc_msg_create();
msg->add_attribute(msg, attr);
msg->build(msg);
excl = dst_imv_id != TNC_IMVID_ANY;
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_ITA &&
- attr->get_type(attr) == ITA_ATTR_COMMAND)
+ if (attr->get_vendor_id(attr) != PEN_ITA)
+ {
+ continue;
+ }
+ if (attr->get_type(attr) == ITA_ATTR_COMMAND)
{
ita_attr_command_t *ita_attr;
- char *command;
-
+
ita_attr = (ita_attr_command_t*)attr;
- command = ita_attr->get_command(ita_attr);
+ DBG1(DBG_IMC, "received command '%s'",
+ ita_attr->get_command(ita_attr));
+ }
+ else if (attr->get_type(attr) == ITA_ATTR_DUMMY)
+ {
+ ita_attr_dummy_t *ita_attr;
+
+ ita_attr = (ita_attr_dummy_t*)attr;
+ DBG1(DBG_IMC, "received dummy attribute value (%d bytes)",
+ ita_attr->get_size(ita_attr));
}
}
enumerator->destroy(enumerator);
*/
char *command;
+ /**
+ * Size of the dummy attribute value to transmit to IMV
+ */
+ int dummy_size;
+
/**
* Is it the first handshake?
*/
free(old_command);
}
+METHOD(imc_test_state_t, get_dummy_size, int,
+ private_imc_test_state_t *this)
+{
+ return this->dummy_size;
+}
+
+
METHOD(imc_test_state_t, is_first_handshake, bool,
private_imc_test_state_t *this)
{
* Described in header.
*/
imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
- char *command, bool retry)
+ char *command, int dummy_size, bool retry)
{
private_imc_test_state_t *this;
},
.get_command = _get_command,
.set_command = _set_command,
+ .get_dummy_size = _get_dummy_size,
.is_first_handshake = _is_first_handshake,
.do_handshake_retry = _do_handshake_retry,
},
.state = TNC_CONNECTION_STATE_CREATE,
.connection_id = connection_id,
.command = strdup(command),
+ .dummy_size = dummy_size,
.first_handshake = TRUE,
.handshake_retry = retry,
);
return &this->public.interface;
}
-
*/
void (*set_command)(imc_test_state_t *this, char *command);
+ /**
+ * get the value size of a dummy attribute to send to IMV
+ *
+ * @return size of the dummy attribute value to send to IMV
+ */
+ int (*get_dummy_size)(imc_test_state_t *this);
+
/**
* Test and reset the first handshake flag
*
/**
* Create an imc_test_state_t instance
*
- * @param id connection ID
- * @param command command to send to IMV
- * @param retry TRUE if a handshake retry should be done
+ * @param id connection ID
+ * @param command command to send to IMV
+ * @param dummy_size size of the dummy attribute to send (only if > 0)
+ * @param retry TRUE if a handshake retry should be done
*/
imc_state_t* imc_test_state_create(TNC_ConnectionID id, char* command,
- bool retry);
+ int dummy_size, bool retry);
#endif /** IMC_TEST_STATE_H_ @}*/
#include <ietf/ietf_attr_pa_tnc_error.h>
#include <ita/ita_attr.h>
#include <ita/ita_attr_command.h>
+#include <ita/ita_attr_dummy.h>
#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
enumerator = pa_tnc_msg->create_attribute_enumerator(pa_tnc_msg);
while (enumerator->enumerate(enumerator, &attr))
{
- if (attr->get_vendor_id(attr) == PEN_ITA &&
- attr->get_type(attr) == ITA_ATTR_COMMAND)
+ if (attr->get_vendor_id(attr) != PEN_ITA)
+ {
+ continue;
+ }
+ if (attr->get_type(attr) == ITA_ATTR_COMMAND)
{
ita_attr_command_t *ita_attr;
char *command;
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
TNC_IMV_EVALUATION_RESULT_ERROR);
}
- }
+ }
+ else if (attr->get_type(attr) == ITA_ATTR_DUMMY)
+ {
+ ita_attr_dummy_t *ita_attr;
+
+ ita_attr = (ita_attr_dummy_t*)attr;
+ DBG1(DBG_IMV, "received dummy attribute value (%d bytes)",
+ ita_attr->get_size(ita_attr));
+ }
}
enumerator->destroy(enumerator);
pa_tnc_msg->destroy(pa_tnc_msg);