Moved data structures to new collections subfolder

This commit is contained in:
Tobias Brunner
2012-10-24 16:00:49 +02:00
parent fdee6b5f5a
commit 12642a6831
229 changed files with 338 additions and 332 deletions
+4 -4
View File
@@ -19,7 +19,7 @@
#include <pa_tnc/pa_tnc_msg.h>
#include <bio/bio_writer.h>
#include <bio/bio_reader.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
@@ -114,12 +114,12 @@ METHOD(pa_tnc_attr_t, build, void,
{
return;
}
writer = bio_writer_create(ATTR_REQUEST_ENTRY_SIZE *
writer = bio_writer_create(ATTR_REQUEST_ENTRY_SIZE *
this->list->get_count(this->list));
enumerator = this->list->create_enumerator(this->list);
while (enumerator->enumerate(enumerator, &entry))
{
{
writer->write_uint32(writer, entry->vendor_id);
writer->write_uint32(writer, entry->type);
}
@@ -161,7 +161,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
reader = bio_reader_create(this->value);
while (count--)
{
reader->read_uint8 (reader, &reserved);
reader->read_uint8 (reader, &reserved);
reader->read_uint24(reader, &vendor_id);
reader->read_uint32(reader, &type);
@@ -20,7 +20,7 @@
#include <pa_tnc/pa_tnc_msg.h>
#include <bio/bio_writer.h>
#include <bio/bio_reader.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
@@ -87,7 +87,7 @@ struct package_entry_t {
chunk_t version;
};
/**
/**
* Free a package entry
*/
static void free_package_entry(package_entry_t *entry)
@@ -169,7 +169,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
reader->read_uint16(reader, &reserved);
reader->read_uint16(reader, &count);
*offset = INSTALLED_PACKAGES_MIN_SIZE;
while (reader->remaining(reader))
{
if (!reader->read_data8(reader, &name))
@@ -190,7 +190,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
{
DBG1(DBG_TNC, "insufficient data for IETF installed package version");
goto end;
}
}
pos = memchr(version.ptr, '\0', version.len);
if (pos)
{
@@ -199,8 +199,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
goto end;
}
*offset += 1 + version.len;
entry = malloc_thing(package_entry_t);
entry = malloc_thing(package_entry_t);
entry->name = chunk_clone(name);
entry->version = chunk_clone(version);
this->packages->insert_last(this->packages, entry);
@@ -216,7 +216,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
end:
reader->destroy(reader);
return status;
return status;
}
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
@@ -249,7 +249,7 @@ METHOD(ietf_attr_installed_packages_t, add, void,
entry = malloc_thing(package_entry_t);
entry->name = chunk_clone(name);
entry->version = chunk_clone(version);
this->packages->insert_last(this->packages, entry);
this->packages->insert_last(this->packages, entry);
}
/**
+4 -4
View File
@@ -17,7 +17,7 @@
#include <pa_tnc/pa_tnc_msg.h>
#include <bio/bio_writer.h>
#include <bio/bio_reader.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
@@ -152,7 +152,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
while (reader->remaining(reader))
{
entry = malloc_thing(port_entry_t);
entry = malloc_thing(port_entry_t);
reader->read_uint8 (reader, &blocked);
entry->blocked = blocked & 0x01;
reader->read_uint8 (reader, &entry->protocol);
@@ -161,7 +161,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
}
reader->destroy(reader);
return SUCCESS;
return SUCCESS;
}
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
@@ -192,7 +192,7 @@ METHOD(ietf_attr_port_filter_t, add_port, void,
entry->blocked = blocked;
entry->protocol = protocol;
entry->port = port;
this->ports->insert_last(this->ports, entry);
this->ports->insert_last(this->ports, entry);
}
/**
+1 -1
View File
@@ -27,7 +27,7 @@
#include <tncifimc.h>
#include <pen/pen.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <library.h>
+1 -1
View File
@@ -21,7 +21,7 @@
#include <tncif_names.h>
#include <pen/pen.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
typedef struct private_imc_msg_t private_imc_msg_t;
+1 -1
View File
@@ -27,7 +27,7 @@
#include <tncifimv.h>
#include <pen/pen.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <library.h>
+1 -1
View File
@@ -21,7 +21,7 @@
#include <tncif_names.h>
#include <pen/pen.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
typedef struct private_imv_msg_t private_imv_msg_t;
+10 -10
View File
@@ -18,7 +18,7 @@
#include <sys/utsname.h>
#include <stdio.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
typedef struct private_os_info_t private_os_info_t;
@@ -132,13 +132,13 @@ METHOD(os_info_t, get_uptime, time_t,
if (!file)
{
DBG1(DBG_IMC, "failed to open \"%s\"", proc_uptime);
return 0;
return 0;
}
if (fscanf(file, "%u", &uptime) != 1)
{
DBG1(DBG_IMC, "failed to read file \"%s\"", proc_uptime);
uptime = 0;
}
}
fclose(file);
return uptime;
@@ -229,7 +229,7 @@ static bool extract_platform_info(chunk_t *name, chunk_t *version)
{
case RELEASE_LSB:
{
/* Determine Distribution ID */
/* Determine Distribution ID */
pos = strstr(buf, lsb_distrib_id);
if (!pos)
{
@@ -249,7 +249,7 @@ static bool extract_platform_info(chunk_t *name, chunk_t *version)
os_name.len = pos - os_name.ptr;
/* Determine Distribution Release */
/* Determine Distribution Release */
pos = strstr(buf, lsb_distrib_release);
if (!pos)
{
@@ -270,7 +270,7 @@ static bool extract_platform_info(chunk_t *name, chunk_t *version)
os_version.len = pos - os_version.ptr;
break;
}
}
case RELEASE_DEBIAN:
{
char str_debian[] = "Debian";
@@ -344,7 +344,7 @@ static bool extract_platform_info(chunk_t *name, chunk_t *version)
*pos++ = ' ';
memcpy(pos, uninfo.machine, strlen(uninfo.machine));
return TRUE;
return TRUE;
}
/**
@@ -356,9 +356,9 @@ os_info_t *os_info_create(void)
chunk_t name, version;
/* As an opton OS name and OS version can be configured manually */
name.ptr = lib->settings->get_str(lib->settings,
name.ptr = lib->settings->get_str(lib->settings,
"libimcv.os_info.name", NULL);
version.ptr = lib->settings->get_str(lib->settings,
version.ptr = lib->settings->get_str(lib->settings,
"libimcv.os_info.version", NULL);
if (name.ptr && version.ptr)
{
@@ -366,7 +366,7 @@ os_info_t *os_info_create(void)
name = chunk_clone(name);
version.len = strlen(version.ptr);
version = chunk_clone(version);
version = chunk_clone(version);
}
else
{
+3 -3
View File
@@ -16,7 +16,7 @@
#include "pa_tnc_attr_manager.h"
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
typedef struct private_pa_tnc_attr_manager_t private_pa_tnc_attr_manager_t;
@@ -46,7 +46,7 @@ struct private_pa_tnc_attr_manager_t {
};
METHOD(pa_tnc_attr_manager_t, add_vendor, void,
private_pa_tnc_attr_manager_t *this, pen_t vendor_id,
private_pa_tnc_attr_manager_t *this, pen_t vendor_id,
pa_tnc_attr_create_t attr_create, enum_name_t *attr_names)
{
entry_t *entry;
@@ -128,7 +128,7 @@ METHOD(pa_tnc_attr_manager_t, create, pa_tnc_attr_t*,
METHOD(pa_tnc_attr_manager_t, destroy, void,
private_pa_tnc_attr_manager_t *this)
{
this->list->destroy_function(this->list, free);
this->list->destroy_function(this->list, free);
free(this);
}
+6 -6
View File
@@ -19,7 +19,7 @@
#include <bio/bio_writer.h>
#include <bio/bio_reader.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <pen/pen.h>
#include <debug.h>
@@ -42,7 +42,7 @@ typedef struct private_pa_tnc_msg_t private_pa_tnc_msg_t;
#define PA_TNC_RESERVED 0x000000
/**
* PA-TNC attribute
* PA-TNC attribute
*
* 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -229,7 +229,7 @@ METHOD(pa_tnc_msg_t, process, status_t,
error = ietf_attr_pa_tnc_error_create(error_code, this->encoding);
goto err;
}
/* offset of the first PA-TNC attribute in the PA-TNC message */
offset = PA_TNC_HEADER_SIZE;
@@ -280,8 +280,8 @@ METHOD(pa_tnc_msg_t, process, status_t,
DBG1(DBG_TNC, "insufficient bytes for PA-TNC attribute value");
error = ietf_attr_pa_tnc_error_create_with_offset(error_code,
this->encoding, offset + PA_TNC_ATTR_INFO_SIZE);
goto err;
}
goto err;
}
DBG3(DBG_TNC, "%B", &value);
attr = imcv_pa_tnc_attributes->create(imcv_pa_tnc_attributes,
@@ -416,7 +416,7 @@ METHOD(pa_tnc_msg_t, destroy, void,
private_pa_tnc_msg_t *this)
{
this->attributes->destroy_offset(this->attributes,
offsetof(pa_tnc_attr_t, destroy));
offsetof(pa_tnc_attr_t, destroy));
this->errors->destroy_offset(this->errors,
offsetof(pa_tnc_attr_t, destroy));
free(this->encoding.ptr);
@@ -18,7 +18,7 @@
#include <tncif_names.h>
#include <debug.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
typedef struct private_imc_test_state_t private_imc_test_state_t;
typedef struct entry_t entry_t;
@@ -82,7 +82,7 @@ struct private_imc_test_state_t {
* Do a handshake retry
*/
bool handshake_retry;
};
/**
@@ -280,7 +280,7 @@ imc_state_t *imc_test_state_create(TNC_ConnectionID connection_id,
.first_handshake = TRUE,
.handshake_retry = retry,
);
return &this->public.interface;
}
+5 -5
View File
@@ -34,7 +34,7 @@
#include <tncif_pa_subtypes.h>
#include <pen/pen.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
/* IMV definitions */
@@ -208,7 +208,7 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
break;
}
case IETF_ATTR_INSTALLED_PACKAGES:
{
{
ietf_attr_installed_packages_t *attr_cast;
enumerator_t *e;
chunk_t name, version;
@@ -224,13 +224,13 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
state->set_recommendation(state,
TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
TNC_IMV_EVALUATION_RESULT_COMPLIANT);
TNC_IMV_EVALUATION_RESULT_COMPLIANT);
assessment = TRUE;
break;
}
default:
break;
}
}
}
enumerator->destroy(enumerator);
@@ -263,7 +263,7 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
assessment = TRUE;
}
else
{
{
DBG1(DBG_IMV, "requesting installed packages for '%s'",
product_info);
attr = ietf_attr_attr_request_create(PEN_IETF,
@@ -25,7 +25,7 @@
#include <tncif_pa_subtypes.h>
#include <pen/pen.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <utils/lexparser.h>
#include <debug.h>
@@ -47,7 +47,7 @@ struct port_range_t {
/**
* Default port policy
* Default port policy
*
* TRUE: all server ports on the TNC client must be closed
* FALSE: any server port on the TNC client is allowed to be open
@@ -207,7 +207,7 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
char buf[BUF_LEN], *pos = buf;
size_t len = BUF_LEN;
bool blocked, compliant = TRUE;
attr_port_filter = (ietf_attr_port_filter_t*)attr;
enumerator = attr_port_filter->create_port_enumerator(attr_port_filter);
while (enumerator->enumerate(enumerator, &blocked, &protocol, &port))
@@ -237,7 +237,7 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
e->destroy(e);
passed = (closed_port_policy == found);
DBG2(DBG_IMV, "%s port %5u %s: %s",
DBG2(DBG_IMV, "%s port %5u %s: %s",
(protocol == IPPROTO_TCP) ? "tcp" : "udp", port,
blocked ? "closed" : "open", passed ? "ok" : "fatal");
if (!passed)
@@ -253,14 +253,14 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
pos += written;
len -= written;
}
}
}
enumerator->destroy(enumerator);
if (compliant)
{
state->set_recommendation(state,
TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
TNC_IMV_EVALUATION_RESULT_COMPLIANT);
TNC_IMV_EVALUATION_RESULT_COMPLIANT);
}
else
{
@@ -270,9 +270,9 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
imv_scanner_state->set_violating_ports(imv_scanner_state, buf);
state->set_recommendation(state,
TNC_IMV_ACTION_RECOMMENDATION_NO_ACCESS,
TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR);
}
}
TNC_IMV_EVALUATION_RESULT_NONCOMPLIANT_MAJOR);
}
}
}
enumerator->destroy(enumerator);
@@ -16,7 +16,7 @@
#include "imv_test_state.h"
#include <utils/lexparser.h>
#include <utils/linked_list.h>
#include <collections/linked_list.h>
#include <debug.h>
typedef struct private_imv_test_state_t private_imv_test_state_t;
@@ -94,7 +94,7 @@ struct entry_t {
};
/**
* Table of multi-lingual reason string entries
* Table of multi-lingual reason string entries
*/
static entry_t reasons[] = {
{ "en", "IMC Test was not configured with \"command = allow\"" },
@@ -191,7 +191,7 @@ METHOD(imv_state_t, get_reason_string, bool,
if (chunk_equals(lang, pref_lang))
{
*reason_language = lang;
*reason_string = chunk_create(reasons[i].string,
*reason_string = chunk_create(reasons[i].string,
strlen(reasons[i].string));
return TRUE;
}
@@ -201,7 +201,7 @@ METHOD(imv_state_t, get_reason_string, bool,
/* no preferred language match found - use the default language */
*reason_string = chunk_create(reasons[0].string,
strlen(reasons[0].string));
*reason_language = chunk_create(reasons[0].lang,
*reason_language = chunk_create(reasons[0].lang,
strlen(reasons[0].lang));
return TRUE;
}
@@ -274,8 +274,8 @@ METHOD(imv_test_state_t, another_round, bool,
}
}
enumerator->destroy(enumerator);
return not_finished;
return not_finished;
}
/**
@@ -310,7 +310,7 @@ imv_state_t *imv_test_state_create(TNC_ConnectionID connection_id)
.connection_id = connection_id,
.imcs = linked_list_create(),
);
return &this->public.interface;
}