summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/tnccs_20/messages
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon/plugins/tnccs_20/messages')
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_access_recommendation_msg.c12
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_assessment_result_msg.c15
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_error_msg.c19
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_language_preference_msg.c4
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.c41
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.h30
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_reason_string_msg.c12
-rw-r--r--src/libcharon/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c12
8 files changed, 53 insertions, 92 deletions
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_access_recommendation_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_access_recommendation_msg.c
index 41b9e31f6..fa3deddf6 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_access_recommendation_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_access_recommendation_msg.c
@@ -15,8 +15,8 @@
#include "pb_access_recommendation_msg.h"
-#include <tls_writer.h>
-#include <tls_reader.h>
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
#include <debug.h>
ENUM(pb_access_recommendation_code_names, PB_REC_ACCESS_ALLOWED, PB_REC_QUARANTINED,
@@ -80,10 +80,10 @@ METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
METHOD(pb_tnc_msg_t, build, void,
private_pb_access_recommendation_msg_t *this)
{
- tls_writer_t *writer;
+ bio_writer_t *writer;
/* build message */
- writer = tls_writer_create(ACCESS_RECOMMENDATION_MSG_SIZE);
+ writer = bio_writer_create(ACCESS_RECOMMENDATION_MSG_SIZE);
writer->write_uint16(writer, ACCESS_RECOMMENDATION_RESERVED);
writer->write_uint16(writer, this->recommendation);
free(this->encoding.ptr);
@@ -95,11 +95,11 @@ METHOD(pb_tnc_msg_t, build, void,
METHOD(pb_tnc_msg_t, process, status_t,
private_pb_access_recommendation_msg_t *this, u_int32_t *offset)
{
- tls_reader_t *reader;
+ bio_reader_t *reader;
u_int16_t reserved;
/* process message */
- reader = tls_reader_create(this->encoding);
+ reader = bio_reader_create(this->encoding);
reader->read_uint16(reader, &reserved);
reader->read_uint16(reader, &this->recommendation);
reader->destroy(reader);
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_assessment_result_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_assessment_result_msg.c
index c91e54176..0d558c0d4 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_assessment_result_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_assessment_result_msg.c
@@ -15,9 +15,10 @@
#include "pb_assessment_result_msg.h"
-#include <tls_writer.h>
-#include <tls_reader.h>
-#include <tnc/tncifimv.h>
+#include <tncifimv.h>
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_pb_assessment_result_msg_t private_pb_assessment_result_msg_t;
@@ -75,10 +76,10 @@ METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
METHOD(pb_tnc_msg_t, build, void,
private_pb_assessment_result_msg_t *this)
{
- tls_writer_t *writer;
+ bio_writer_t *writer;
/* build message */
- writer = tls_writer_create(ASSESSMENT_RESULT_MSG_SIZE);
+ writer = bio_writer_create(ASSESSMENT_RESULT_MSG_SIZE);
writer->write_uint32(writer, this->assessment_result);
free(this->encoding.ptr);
this->encoding = writer->get_buf(writer);
@@ -89,10 +90,10 @@ METHOD(pb_tnc_msg_t, build, void,
METHOD(pb_tnc_msg_t, process, status_t,
private_pb_assessment_result_msg_t *this, u_int32_t *offset)
{
- tls_reader_t *reader;
+ bio_reader_t *reader;
/* process message */
- reader = tls_reader_create(this->encoding);
+ reader = bio_reader_create(this->encoding);
reader->read_uint32(reader, &this->assessment_result);
reader->destroy(reader);
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_error_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_error_msg.c
index e1755c512..03e3cec92 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_error_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_error_msg.c
@@ -15,11 +15,13 @@
#include "pb_error_msg.h"
-#include <debug.h>
-#include <tls_writer.h>
-#include <tls_reader.h>
#include <tnc/tnccs/tnccs.h>
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <pen/pen.h>
+#include <debug.h>
+
ENUM(pb_tnc_error_code_names, PB_ERROR_UNEXPECTED_BATCH_TYPE,
PB_ERROR_VERSION_NOT_SUPPORTED,
"Unexpected Batch Type",
@@ -116,10 +118,10 @@ METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
METHOD(pb_tnc_msg_t, build, void,
private_pb_error_msg_t *this)
{
- tls_writer_t *writer;
+ bio_writer_t *writer;
/* build message header */
- writer = tls_writer_create(ERROR_HEADER_SIZE);
+ writer = bio_writer_create(ERROR_HEADER_SIZE);
writer->write_uint8 (writer, this->fatal ?
ERROR_FLAG_FATAL : ERROR_FLAG_NONE);
writer->write_uint24(writer, this->vendor_id);
@@ -152,24 +154,25 @@ METHOD(pb_tnc_msg_t, process, status_t,
{
u_int8_t flags, max_version, min_version;
u_int16_t reserved;
- tls_reader_t *reader;
+ bio_reader_t *reader;
if (this->encoding.len < ERROR_HEADER_SIZE)
{
DBG1(DBG_TNC,"%N message is shorter than header size of %u bytes",
pb_tnc_msg_type_names, PB_MSG_ERROR, ERROR_HEADER_SIZE);
+ *offset = 0;
return FAILED;
}
/* process message header */
- reader = tls_reader_create(this->encoding);
+ reader = bio_reader_create(this->encoding);
reader->read_uint8 (reader, &flags);
reader->read_uint24(reader, &this->vendor_id);
reader->read_uint16(reader, &this->error_code);
reader->read_uint16(reader, &reserved);
this->fatal = (flags & ERROR_FLAG_FATAL) != ERROR_FLAG_NONE;
- if (this->vendor_id == IETF_VENDOR_ID && reader->remaining(reader) == 4)
+ if (this->vendor_id == PEN_IETF && reader->remaining(reader) == 4)
{
if (this->error_code == PB_ERROR_VERSION_NOT_SUPPORTED)
{
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_language_preference_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_language_preference_msg.c
index 9a94edf30..297cc8df7 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_language_preference_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_language_preference_msg.c
@@ -15,8 +15,8 @@
#include "pb_language_preference_msg.h"
-#include <tls_writer.h>
-#include <tls_reader.h>
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_pb_language_preference_msg_t private_pb_language_preference_msg_t;
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.c
index 8315bfb76..1c4913e5e 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.c
@@ -17,22 +17,12 @@
#include "pb_pa_msg.h"
-#include <tls_writer.h>
-#include <tls_reader.h>
#include <tnc/tnccs/tnccs.h>
-#include <debug.h>
-ENUM(pa_tnc_subtype_names, PA_SUBTYPE_TESTING, PA_SUBTYPE_NEA_CLIENT,
- "Testing",
- "Operating System",
- "Anti-Virus",
- "Anti-Spyware",
- "Anti-Malware",
- "Firewall",
- "IDPS",
- "VPN",
- "NEA Client"
-);
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <pen/pen.h>
+#include <debug.h>
typedef struct private_pb_pa_msg_t private_pb_pa_msg_t;
@@ -124,10 +114,10 @@ METHOD(pb_tnc_msg_t, build, void,
private_pb_pa_msg_t *this)
{
chunk_t msg_header;
- tls_writer_t *writer;
+ bio_writer_t *writer;
/* build message header */
- writer = tls_writer_create(64);
+ writer = bio_writer_create(64);
writer->write_uint8 (writer, this->excl ? PA_FLAG_EXCL : PA_FLAG_NONE);
writer->write_uint24(writer, this->vendor_id);
writer->write_uint32(writer, this->subtype);
@@ -146,10 +136,10 @@ METHOD(pb_tnc_msg_t, process, status_t,
{
u_int8_t flags;
size_t msg_body_len;
- tls_reader_t *reader;
+ bio_reader_t *reader;
/* process message header */
- reader = tls_reader_create(this->encoding);
+ reader = bio_reader_create(this->encoding);
reader->read_uint8 (reader, &flags);
reader->read_uint24(reader, &this->vendor_id);
reader->read_uint32(reader, &this->subtype);
@@ -166,9 +156,9 @@ METHOD(pb_tnc_msg_t, process, status_t,
}
reader->destroy(reader);
- if (this->vendor_id == RESERVED_VENDOR_ID)
+ if (this->vendor_id == PEN_RESERVED)
{
- DBG1(DBG_TNC, "Vendor ID 0x%06x is reserved", RESERVED_VENDOR_ID);
+ DBG1(DBG_TNC, "Vendor ID 0x%06x is reserved", PEN_RESERVED);
*offset = 1;
return FAILED;
}
@@ -221,12 +211,6 @@ METHOD(pb_pa_msg_t, get_exclusive_flag, bool,
return this->excl;
}
-METHOD(pb_pa_msg_t, set_exclusive_flag, void,
- private_pb_pa_msg_t *this, bool excl)
-{
- this->excl = excl;
-}
-
/**
* See header
*/
@@ -247,7 +231,6 @@ pb_tnc_msg_t *pb_pa_msg_create_from_data(chunk_t data)
.get_validator_id = _get_validator_id,
.get_body = _get_body,
.get_exclusive_flag = _get_exclusive_flag,
- .set_exclusive_flag = _set_exclusive_flag,
},
.type = PB_MSG_PA,
.encoding = chunk_clone(data),
@@ -261,7 +244,7 @@ pb_tnc_msg_t *pb_pa_msg_create_from_data(chunk_t data)
*/
pb_tnc_msg_t *pb_pa_msg_create(u_int32_t vendor_id, u_int32_t subtype,
u_int16_t collector_id, u_int16_t validator_id,
- chunk_t msg_body)
+ bool excl, chunk_t msg_body)
{
private_pb_pa_msg_t *this;
@@ -279,13 +262,13 @@ pb_tnc_msg_t *pb_pa_msg_create(u_int32_t vendor_id, u_int32_t subtype,
.get_validator_id = _get_validator_id,
.get_body = _get_body,
.get_exclusive_flag = _get_exclusive_flag,
- .set_exclusive_flag = _set_exclusive_flag,
},
.type = PB_MSG_PA,
.vendor_id = vendor_id,
.subtype = subtype,
.collector_id = collector_id,
.validator_id = validator_id,
+ .excl = excl,
.msg_body = chunk_clone(msg_body),
);
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.h b/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.h
index 366d790f6..d9db9a1ce 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.h
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_pa_msg.h
@@ -21,32 +21,11 @@
#ifndef PB_PA_MSG_H_
#define PB_PA_MSG_H_
-typedef enum pa_tnc_subtype_t pa_tnc_subtype_t;
typedef struct pb_pa_msg_t pb_pa_msg_t;
#include "pb_tnc_msg.h"
/**
- * PA-TNC Subtypes as defined in section 3.5 of RFC 5792
- */
- enum pa_tnc_subtype_t {
- PA_SUBTYPE_TESTING = 0,
- PA_SUBTYPE_OPERATING_SYSTEM = 1,
- PA_SUBTYPE_ANTI_VIRUS = 2,
- PA_SUBTYPE_ANTI_SPYWARE = 3,
- PA_SUBTYPE_ANTI_MALWARE = 4,
- PA_SUBTYPE_FIREWALL = 5,
- PA_SUBTYPE_IDPS = 6,
- PA_SUBTYPE_VPN = 7,
- PA_SUBTYPE_NEA_CLIENT = 8
-};
-
-/**
- * enum name for pa_tnc_subtype_t.
- */
-extern enum_name_t *pa_tnc_subtype_names;
-
-/**
* Class representing the PB-PA message type.
*/
struct pb_pa_msg_t {
@@ -92,12 +71,6 @@ struct pb_pa_msg_t {
*/
bool (*get_exclusive_flag)(pb_pa_msg_t *this);
- /**
- * Set the exclusive flag
- *
- * @param excl vexclusive flag
- */
- void (*set_exclusive_flag)(pb_pa_msg_t *this, bool excl);
};
/**
@@ -107,11 +80,12 @@ struct pb_pa_msg_t {
* @param subtype PA Subtype
* @param collector_id Posture Collector ID
* @param validator_id Posture Validator ID
+ * @param excl Exclusive Flag
* @param msg_body PA Message Body
*/
pb_tnc_msg_t *pb_pa_msg_create(u_int32_t vendor_id, u_int32_t subtype,
u_int16_t collector_id, u_int16_t validator_id,
- chunk_t msg_body);
+ bool excl, chunk_t msg_body);
/**
* Create an unprocessed PB-PA message from raw data
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_reason_string_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_reason_string_msg.c
index e361cf2b2..181ecf61b 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_reason_string_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_reason_string_msg.c
@@ -15,8 +15,8 @@
#include "pb_reason_string_msg.h"
-#include <tls_writer.h>
-#include <tls_reader.h>
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
#include <debug.h>
typedef struct private_pb_reason_string_msg_t private_pb_reason_string_msg_t;
@@ -81,10 +81,10 @@ METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
METHOD(pb_tnc_msg_t, build, void,
private_pb_reason_string_msg_t *this)
{
- tls_writer_t *writer;
+ bio_writer_t *writer;
/* build message */
- writer = tls_writer_create(64);
+ writer = bio_writer_create(64);
writer->write_data32(writer, this->reason_string);
writer->write_data8 (writer, this->language_code);
@@ -97,10 +97,10 @@ METHOD(pb_tnc_msg_t, build, void,
METHOD(pb_tnc_msg_t, process, status_t,
private_pb_reason_string_msg_t *this, u_int32_t *offset)
{
- tls_reader_t *reader;
+ bio_reader_t *reader;
/* process message */
- reader = tls_reader_create(this->encoding);
+ reader = bio_reader_create(this->encoding);
if (!reader->read_data32(reader, &this->reason_string))
{
DBG1(DBG_TNC, "could not parse reason string");
diff --git a/src/libcharon/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c b/src/libcharon/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c
index 79381a7b1..d213db313 100644
--- a/src/libcharon/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c
+++ b/src/libcharon/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c
@@ -15,8 +15,8 @@
#include "pb_remediation_parameters_msg.h"
-#include <tls_writer.h>
-#include <tls_reader.h>
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
#include <debug.h>
ENUM(pb_tnc_remed_param_type_names, PB_REMEDIATION_URI, PB_REMEDIATION_STRING,
@@ -106,10 +106,10 @@ METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
METHOD(pb_tnc_msg_t, build, void,
private_pb_remediation_parameters_msg_t *this)
{
- tls_writer_t *writer;
+ bio_writer_t *writer;
/* build message */
- writer = tls_writer_create(64);
+ writer = bio_writer_create(64);
writer->write_uint32(writer, this->vendor_id);
writer->write_uint32(writer, this->parameters_type);
writer->write_data32(writer, this->remediation_string);
@@ -124,10 +124,10 @@ METHOD(pb_tnc_msg_t, build, void,
METHOD(pb_tnc_msg_t, process, status_t,
private_pb_remediation_parameters_msg_t *this, u_int32_t *offset)
{
- tls_reader_t *reader;
+ bio_reader_t *reader;
/* process message */
- reader = tls_reader_create(this->encoding);
+ reader = bio_reader_create(this->encoding);
reader->read_uint32(reader, &this->vendor_id);
reader->read_uint32(reader, &this->parameters_type);