Allow vendor-specific PB-TNC messages
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 17 Sep 2013 09:19:11 +0000 (11:19 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 17 Sep 2013 09:19:11 +0000 (11:19 +0200)
39 files changed:
src/libtnccs/plugins/tnccs_20/Makefile.am
src/libtnccs/plugins/tnccs_20/batch/pb_tnc_batch.c
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_access_recommendation_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_access_recommendation_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_assessment_result_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_assessment_result_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_error_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_error_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_language_preference_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_language_preference_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_pa_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_pa_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_reason_string_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_reason_string_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_remediation_parameters_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/ietf/pb_remediation_parameters_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/pb_access_recommendation_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_access_recommendation_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_assessment_result_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_assessment_result_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_error_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_error_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_experimental_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_experimental_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_language_preference_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_language_preference_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_pa_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_pa_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_reason_string_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_reason_string_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_remediation_parameters_msg.h [deleted file]
src/libtnccs/plugins/tnccs_20/messages/pb_tnc_msg.c
src/libtnccs/plugins/tnccs_20/messages/pb_tnc_msg.h
src/libtnccs/plugins/tnccs_20/messages/tcg/pb_pdp_referral_msg.c [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/messages/tcg/pb_pdp_referral_msg.h [new file with mode: 0644]
src/libtnccs/plugins/tnccs_20/tnccs_20.c

index c268f59..f64526e 100644 (file)
@@ -20,14 +20,15 @@ libstrongswan_tnccs_20_la_SOURCES = \
        tnccs_20_plugin.h tnccs_20_plugin.c tnccs_20.h tnccs_20.c \
        batch/pb_tnc_batch.h batch/pb_tnc_batch.c \
        messages/pb_tnc_msg.h messages/pb_tnc_msg.c \
-       messages/pb_experimental_msg.h messages/pb_experimental_msg.c \
-       messages/pb_pa_msg.h messages/pb_pa_msg.c \
-       messages/pb_assessment_result_msg.h messages/pb_assessment_result_msg.c \
-       messages/pb_access_recommendation_msg.h messages/pb_access_recommendation_msg.c \
-       messages/pb_error_msg.h messages/pb_error_msg.c \
-       messages/pb_language_preference_msg.h messages/pb_language_preference_msg.c \
-       messages/pb_reason_string_msg.h messages/pb_reason_string_msg.c \
-       messages/pb_remediation_parameters_msg.h messages/pb_remediation_parameters_msg.c \
+       messages/ietf/pb_experimental_msg.h messages/ietf/pb_experimental_msg.c \
+       messages/ietf/pb_pa_msg.h messages/ietf/pb_pa_msg.c \
+       messages/ietf/pb_assessment_result_msg.h messages/ietf/pb_assessment_result_msg.c \
+       messages/ietf/pb_access_recommendation_msg.h messages/ietf/pb_access_recommendation_msg.c \
+       messages/ietf/pb_error_msg.h messages/ietf/pb_error_msg.c \
+       messages/ietf/pb_language_preference_msg.h messages/ietf/pb_language_preference_msg.c \
+       messages/ietf/pb_reason_string_msg.h messages/ietf/pb_reason_string_msg.c \
+       messages/ietf/pb_remediation_parameters_msg.h messages/ietf/pb_remediation_parameters_msg.c \
+       messages/tcg/pb_pdp_referral_msg.h messages/tcg/pb_pdp_referral_msg.c \
        state_machine/pb_tnc_state_machine.h state_machine/pb_tnc_state_machine.c
 
 libstrongswan_tnccs_20_la_LDFLAGS = -module -avoid-version
index d87e0cc..6dacfc6 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 #include "pb_tnc_batch.h"
-#include "messages/pb_error_msg.h"
+#include "messages/ietf/pb_error_msg.h"
 #include "state_machine/pb_tnc_state_machine.h"
 
 #include <tnc/tnccs/tnccs.h>
@@ -141,7 +141,9 @@ METHOD(pb_tnc_batch_t, get_encoding, chunk_t,
 METHOD(pb_tnc_batch_t, add_msg, bool,
        private_pb_tnc_batch_t *this, pb_tnc_msg_t* msg)
 {
+       enum_name_t *msg_type_names;
        chunk_t msg_value;
+       pen_type_t msg_type;
        size_t msg_len;
 
        msg->build(msg);
@@ -155,8 +157,19 @@ METHOD(pb_tnc_batch_t, add_msg, bool,
        }
        this->batch_len += msg_len;
 
-       DBG2(DBG_TNC, "adding %N message", pb_tnc_msg_type_names,
-                                                                          msg->get_type(msg));
+       msg_type = msg->get_type(msg);
+       switch (msg_type.vendor_id)
+       {
+               default:
+               case PEN_IETF:
+                       msg_type_names = pb_tnc_msg_type_names;
+                       break;
+               case PEN_TCG:
+                       msg_type_names = pb_tnc_tcg_msg_type_names;
+                       break;
+       }
+       DBG2(DBG_TNC, "adding %N/%N message", pen_names, msg_type.vendor_id,
+                                                                                 msg_type_names, msg_type.type);
        this->messages->insert_last(this->messages, msg);
        return TRUE;
 }
@@ -167,8 +180,9 @@ METHOD(pb_tnc_batch_t, build, void,
        u_int32_t msg_len;
        chunk_t msg_value;
        enumerator_t *enumerator;
-       pb_tnc_msg_type_t msg_type;
+       pen_type_t msg_type;
        pb_tnc_msg_t *msg;
+       pb_tnc_msg_info_t *msg_infos;
        bio_writer_t *writer;
 
        /* build PB-TNC batch header */
@@ -189,13 +203,23 @@ METHOD(pb_tnc_batch_t, build, void,
                msg_value = msg->get_encoding(msg);
                msg_len = PB_TNC_HEADER_SIZE + msg_value.len;
                msg_type = msg->get_type(msg);
-               if (pb_tnc_msg_infos[msg_type].has_noskip_flag)
+               switch (msg_type.vendor_id)
+               {
+                       default:
+                       case PEN_IETF:
+                               msg_infos = pb_tnc_msg_infos;
+                               break;
+                       case PEN_TCG:
+                               msg_infos = pb_tnc_tcg_msg_infos;
+                               break;
+               }
+               if (msg_infos[msg_type.type].has_noskip_flag)
                {
                        flags |= PB_TNC_FLAG_NOSKIP;
                }
                writer->write_uint8 (writer, flags);
-               writer->write_uint24(writer, PEN_IETF);
-               writer->write_uint32(writer, msg_type);
+               writer->write_uint24(writer, msg_type.vendor_id);
+               writer->write_uint32(writer, msg_type.type);
                writer->write_uint32(writer, msg_len);
                writer->write_data  (writer, msg_value);
        }
@@ -304,10 +328,13 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
 {
        bio_reader_t *reader;
        pb_tnc_msg_t *pb_tnc_msg, *msg;
+       pb_tnc_msg_info_t *msg_infos;
        u_int8_t flags;
        u_int32_t vendor_id, msg_type, msg_len, offset;
        chunk_t data, msg_value;
        bool noskip_flag;
+       enum_name_t *msg_type_names;
+       pen_type_t msg_pen_type;
        status_t status;
 
        data = chunk_skip(this->encoding, this->offset);
@@ -356,8 +383,25 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
                goto fatal;
        }
 
-
-       if (vendor_id != PEN_IETF || msg_type > PB_MSG_ROOF)
+       if (vendor_id == PEN_IETF && msg_type <= PB_MSG_ROOF)
+       {
+               if (msg_type == PB_MSG_EXPERIMENTAL && noskip_flag)
+               {
+                       DBG1(DBG_TNC, "reject IETF/PB-Experimental message with "
+                                                 "NOSKIP flag set");
+                       msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
+                                                       PB_ERROR_UNSUPPORTED_MANDATORY_MSG, this->offset);
+                       goto fatal;
+               }
+               msg_type_names = pb_tnc_msg_type_names;
+               msg_infos = pb_tnc_msg_infos;
+       }
+       else if (vendor_id == PEN_IETF && msg_type <= PB_TCG_MSG_ROOF)
+       {
+               msg_type_names = pb_tnc_tcg_msg_type_names;
+               msg_infos = pb_tnc_tcg_msg_infos;
+       }
+       else
        {
                if (msg_len < PB_TNC_HEADER_SIZE)
                {
@@ -384,65 +428,56 @@ static status_t process_tnc_msg(private_pb_tnc_batch_t *this)
                        return SUCCESS;
                }
        }
-       else
+
+       if (msg_infos[msg_type].has_noskip_flag != TRUE_OR_FALSE &&
+               msg_infos[msg_type].has_noskip_flag != noskip_flag)
        {
-               if (msg_type == PB_MSG_EXPERIMENTAL && noskip_flag)
-               {
-                       DBG1(DBG_TNC, "reject PB-Experimental message with NOSKIP flag set");
-                       msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
-                                                       PB_ERROR_UNSUPPORTED_MANDATORY_MSG, this->offset);
-                       goto fatal;
-               }
-               if (pb_tnc_msg_infos[msg_type].has_noskip_flag != TRUE_OR_FALSE &&
-                       pb_tnc_msg_infos[msg_type].has_noskip_flag != noskip_flag)
-               {
-                       DBG1(DBG_TNC, "%N message must%s have NOSKIP flag set",
-                                pb_tnc_msg_type_names, msg_type,
-                                pb_tnc_msg_infos[msg_type].has_noskip_flag ? "" : " not");
-                       msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
-                                                               PB_ERROR_INVALID_PARAMETER, this->offset);
-                       goto fatal;
-               }
+               DBG1(DBG_TNC, "%N/%N message must%s have NOSKIP flag set",
+                        pen_names, vendor_id, msg_type_names, msg_type,
+                        msg_infos[msg_type].has_noskip_flag ? "" : " not");
+               msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
+                                                       PB_ERROR_INVALID_PARAMETER, this->offset);
+               goto fatal;
+       }
 
-               if (msg_len < pb_tnc_msg_infos[msg_type].min_size ||
-                  (pb_tnc_msg_infos[msg_type].exact_size &&
-                       msg_len != pb_tnc_msg_infos[msg_type].min_size))
-               {
-                       DBG1(DBG_TNC, "%N message length must be %s %u bytes but is %u bytes",
-                                pb_tnc_msg_type_names, msg_type,
-                                pb_tnc_msg_infos[msg_type].exact_size ? "exactly" : "at least",
-                                pb_tnc_msg_infos[msg_type].min_size, msg_len);
-                       msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
-                                                               PB_ERROR_INVALID_PARAMETER, this->offset);
-                       goto fatal;
-               }
+       if (msg_len < msg_infos[msg_type].min_size ||
+          (msg_infos[msg_type].exact_size && 
+               msg_len != msg_infos[msg_type].min_size))
+       {
+               DBG1(DBG_TNC, "%N/%N message length must be %s %u bytes but is %u bytes",
+                        pen_names, vendor_id, msg_type_names, msg_type,
+                        msg_infos[msg_type].exact_size ? "exactly" : "at least",
+                        msg_infos[msg_type].min_size, msg_len);
+               msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
+                                                       PB_ERROR_INVALID_PARAMETER, this->offset);
+               goto fatal;
        }
 
-       if (pb_tnc_msg_infos[msg_type].in_result_batch &&
-               this->type != PB_BATCH_RESULT)
+       if (msg_infos[msg_type].in_result_batch && this->type != PB_BATCH_RESULT)
        {
                if (this->is_server)
                {
-                       DBG1(DBG_TNC,"reject %N message received from a PB-TNC client",
-                                                 pb_tnc_msg_type_names, msg_type);
+                       DBG1(DBG_TNC,"reject %N/%N message received from a PB-TNC client",
+                                pen_names, vendor_id, msg_type_names, msg_type);
                        msg = pb_error_msg_create_with_offset(TRUE, PEN_IETF,
                                                                PB_ERROR_INVALID_PARAMETER, this->offset);
                        goto fatal;
                }
                else
                {
-                       DBG1(DBG_TNC,"ignore %N message not received within RESULT batch",
-                                                 pb_tnc_msg_type_names, msg_type);
+                       DBG1(DBG_TNC,"ignore %N/%N message not received within RESULT batch",
+                                pen_names, vendor_id, msg_type_names, msg_type);
                        this->offset += msg_len;
                        return SUCCESS;
                }
        }
 
-       DBG2(DBG_TNC, "processing %N message (%u bytes)", pb_tnc_msg_type_names,
-                                  msg_type, msg_len);
+       DBG2(DBG_TNC, "processing %N/%N message (%u bytes)", pen_names, vendor_id,
+                msg_type_names, msg_type, msg_len);
        data.len = msg_len;
        msg_value = chunk_skip(data, PB_TNC_HEADER_SIZE);
-       pb_tnc_msg = pb_tnc_msg_create_from_data(msg_type, msg_value);
+       msg_pen_type = pen_type_create(vendor_id, msg_type);
+       pb_tnc_msg = pb_tnc_msg_create_from_data(msg_pen_type, msg_value);
 
        status = pb_tnc_msg->process(pb_tnc_msg, &offset);
        if (status == FAILED || status == VERIFY_ERROR)
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_access_recommendation_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_access_recommendation_msg.c
new file mode 100644 (file)
index 0000000..5c4b5ae
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 "pb_access_recommendation_msg.h"
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <utils/debug.h>
+
+ENUM(pb_access_recommendation_code_names, PB_REC_ACCESS_ALLOWED, PB_REC_QUARANTINED,
+       "Access Allowed",
+       "Access Denied",
+       "Quarantined"
+);
+
+typedef struct private_pb_access_recommendation_msg_t private_pb_access_recommendation_msg_t;
+
+/**
+ *   PB-Access-Recommendation message (see section 4.7 of RFC 5793)
+ *
+ *      0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |          Reserved             |   Access Recommendation Code  |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define ACCESS_RECOMMENDATION_RESERVED         0x0000
+#define ACCESS_RECOMMENDATION_MSG_SIZE         4
+/**
+ * Private data of a pb_access_recommendation_msg_t object.
+ *
+ */
+struct private_pb_access_recommendation_msg_t {
+       /**
+        * Public pb_access_recommendation_msg_t interface.
+        */
+       pb_access_recommendation_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Access recommendation code
+        */
+       u_int16_t recommendation;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_access_recommendation_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_access_recommendation_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_access_recommendation_msg_t *this)
+{
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+       writer = bio_writer_create(ACCESS_RECOMMENDATION_MSG_SIZE);
+       writer->write_uint16(writer, ACCESS_RECOMMENDATION_RESERVED);
+       writer->write_uint16(writer, this->recommendation);
+       this->encoding = writer->get_buf(writer);
+       this->encoding = chunk_clone(this->encoding);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_access_recommendation_msg_t *this, u_int32_t *offset)
+{
+       bio_reader_t *reader;
+       u_int16_t reserved;
+
+       reader = bio_reader_create(this->encoding);
+       reader->read_uint16(reader, &reserved);
+       reader->read_uint16(reader, &this->recommendation);
+       reader->destroy(reader);
+
+       if (this->recommendation < PB_REC_ACCESS_ALLOWED ||
+               this->recommendation > PB_REC_QUARANTINED)
+       {
+               DBG1(DBG_TNC, "invalid access recommendation code (%u)",
+                                          this->recommendation);
+               *offset = 2;
+               return FAILED;
+       }
+
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_access_recommendation_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this);
+}
+
+METHOD(pb_access_recommendation_msg_t, get_access_recommendation, u_int16_t,
+       private_pb_access_recommendation_msg_t *this)
+{
+       return this->recommendation;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_access_recommendation_msg_create_from_data(chunk_t data)
+{
+       private_pb_access_recommendation_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_access_recommendation = _get_access_recommendation,
+               },
+               .type = { PEN_IETF, PB_MSG_ACCESS_RECOMMENDATION },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_access_recommendation_msg_create(u_int16_t recommendation)
+{
+       private_pb_access_recommendation_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_access_recommendation = _get_access_recommendation,
+               },
+               .type = { PEN_IETF, PB_MSG_ACCESS_RECOMMENDATION },
+               .recommendation = recommendation,
+       );
+
+       return &this->public.pb_interface;
+}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_access_recommendation_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_access_recommendation_msg.h
new file mode 100644 (file)
index 0000000..d0dc635
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 pb_access_recommendation_msg pb_access_recommendation_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_ACCESS_RECOMMENDATION_MSG_H_
+#define PB_ACCESS_RECOMMENDATION_MSG_H_
+
+typedef enum pb_access_recommendation_code_t pb_access_recommendation_code_t;
+typedef struct pb_access_recommendation_msg_t pb_access_recommendation_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+/**
+ * PB Access Recommendation Codes as defined in section 4.7 of RFC 5793
+ */
+enum pb_access_recommendation_code_t {
+       PB_REC_ACCESS_ALLOWED = 1,
+       PB_REC_ACCESS_DENIED =  2,
+       PB_REC_QUARANTINED =    3,
+};
+
+/**
+ * enum name for pb_access_recommendation_code_t.
+ */
+extern enum_name_t *pb_access_recommendation_code_names;
+
+
+/**
+ * Class representing the PB-Access-Recommendation message type.
+ */
+struct pb_access_recommendation_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get PB Access Recommendation
+        *
+        * @return                      PB Access Recommendation
+        */
+       u_int16_t (*get_access_recommendation)(pb_access_recommendation_msg_t *this);
+};
+
+/**
+ * Create a PB-Access-Recommendation message from parameters
+ *
+ * @param recommendation       Access Recommendation code
+ */
+pb_tnc_msg_t* pb_access_recommendation_msg_create(u_int16_t recommendation);
+
+/**
+ * Create an unprocessed PB-Access-Recommendation message from raw data
+ *
+  * @param data                PB-Access-Recommendation message data
+ */
+pb_tnc_msg_t* pb_access_recommendation_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_assessment_result_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_assessment_result_msg.c
new file mode 100644 (file)
index 0000000..e234935
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 "pb_assessment_result_msg.h"
+
+#include <tncifimv.h>
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <utils/debug.h>
+
+typedef struct private_pb_assessment_result_msg_t private_pb_assessment_result_msg_t;
+
+/**
+ *   PB-Assessment-Result message (see section 4.6 of RFC 5793)
+ *
+ *                          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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                       Assessment Result                       |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define ASSESSMENT_RESULT_MSG_SIZE     4
+
+/**
+ * Private data of a pb_assessment_result_msg_t object.
+ *
+ */
+struct private_pb_assessment_result_msg_t {
+       /**
+        * Public pb_assessment_result_msg_t interface.
+        */
+       pb_assessment_result_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Assessment result code
+        */
+       u_int32_t assessment_result;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_assessment_result_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_assessment_result_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_assessment_result_msg_t *this)
+{
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+       writer = bio_writer_create(ASSESSMENT_RESULT_MSG_SIZE);
+       writer->write_uint32(writer, this->assessment_result);
+       this->encoding = writer->get_buf(writer);
+       this->encoding = chunk_clone(this->encoding);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_assessment_result_msg_t *this, u_int32_t *offset)
+{
+       bio_reader_t *reader;
+
+       reader = bio_reader_create(this->encoding);
+       reader->read_uint32(reader, &this->assessment_result);
+       reader->destroy(reader);
+
+       if (this->assessment_result < TNC_IMV_EVALUATION_RESULT_COMPLIANT ||
+               this->assessment_result > TNC_IMV_EVALUATION_RESULT_DONT_KNOW)
+       {
+               DBG1(DBG_TNC, "invalid assessment result (%u)",
+                                          this->assessment_result);
+               *offset = 0;
+               return FAILED;
+       }
+
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_assessment_result_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this);
+}
+
+METHOD(pb_assessment_result_msg_t, get_assessment_result, u_int32_t,
+       private_pb_assessment_result_msg_t *this)
+{
+       return this->assessment_result;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_assessment_result_msg_create_from_data(chunk_t data)
+{
+       private_pb_assessment_result_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_assessment_result = _get_assessment_result,
+               },
+               .type = { PEN_IETF, PB_MSG_ASSESSMENT_RESULT },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_assessment_result_msg_create(u_int32_t assessment_result)
+{
+       private_pb_assessment_result_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_assessment_result = _get_assessment_result,
+               },
+               .type = { PEN_IETF, PB_MSG_ASSESSMENT_RESULT },
+               .assessment_result = assessment_result,
+       );
+
+       return &this->public.pb_interface;
+}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_assessment_result_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_assessment_result_msg.h
new file mode 100644 (file)
index 0000000..11cfdbe
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 pb_assessment_result_msg pb_assessment_result_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_ASSESSMENT_RESULT_MSG_H_
+#define PB_ASSESSMENT_RESULT_MSG_H_
+
+typedef struct pb_assessment_result_msg_t pb_assessment_result_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+/**
+ * Class representing the PB-Assessment-Result message type.
+ */
+struct pb_assessment_result_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get PB Assessment result
+        *
+        * @return                      PB Assessment result
+        */
+       u_int32_t (*get_assessment_result)(pb_assessment_result_msg_t *this);
+};
+
+/**
+ * Create a PB-Assessment-Result message from parameters
+ *
+ * @param assessment_result            Assessment result code
+ */
+pb_tnc_msg_t* pb_assessment_result_msg_create(u_int32_t assessment_result);
+
+/**
+ * Create an unprocessed PB-Assessment-Result message from raw data
+ *
+  * @param data                PB-Assessment-Result message data
+ */
+pb_tnc_msg_t* pb_assessment_result_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_error_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_error_msg.c
new file mode 100644 (file)
index 0000000..d9910f6
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 "pb_error_msg.h"
+
+#include <tnc/tnccs/tnccs.h>
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <pen/pen.h>
+#include <utils/debug.h>
+
+ENUM(pb_tnc_error_code_names, PB_ERROR_UNEXPECTED_BATCH_TYPE,
+                                                         PB_ERROR_VERSION_NOT_SUPPORTED,
+       "Unexpected Batch Type",
+       "Invalid Parameter",
+       "Local Error",
+       "Unsupported Mandatory Message",
+       "Version Not Supported"
+);
+
+typedef struct private_pb_error_msg_t private_pb_error_msg_t;
+
+/**
+ *   PB-Error message (see section 4.9 of RFC 5793)
+ *
+ *      0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |    Flags      |              Error Code Vendor ID             |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |           Error Code          |           Reserved            |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                Error Parameters (Variable Length)             |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define ERROR_FLAG_NONE                0x00
+#define ERROR_FLAG_FATAL       (1<<7)
+#define ERROR_RESERVED         0x0000
+#define ERROR_HEADER_SIZE      8
+
+/**
+ * Private data of a pb_error_msg_t object.
+ *
+ */
+struct private_pb_error_msg_t {
+       /**
+        * Public pb_error_msg_t interface.
+        */
+       pb_error_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Fatal flag
+        */
+       bool fatal;
+
+       /**
+        * PB Error Code Vendor ID
+        */
+       u_int32_t vendor_id;
+
+       /**
+        * PB Error Code
+        */
+       u_int16_t error_code;
+
+       /**
+        * PB Error Offset
+        */
+       u_int32_t error_offset;
+
+       /**
+        * Bad PB-TNC version received
+        */
+       u_int8_t bad_version;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+
+       /**
+        * reference count
+        */
+       refcount_t ref;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_error_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_error_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_error_msg_t *this)
+{
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+
+       /* build message header */
+       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);
+       writer->write_uint16(writer, this->error_code);
+       writer->write_uint16(writer, ERROR_RESERVED);
+
+       /* build message body */
+       if (this->error_code == PB_ERROR_VERSION_NOT_SUPPORTED)
+       {
+               /* Bad version */
+               writer->write_uint8(writer, this->bad_version);
+               writer->write_uint8(writer, PB_TNC_VERSION); /* Max version */
+               writer->write_uint8(writer, PB_TNC_VERSION); /* Min version */
+               writer->write_uint8(writer, 0x00);           /* Reserved */
+       }
+       else
+       {
+               /* Error Offset */
+               writer->write_uint32(writer, this->error_offset);
+       }
+       this->encoding = writer->get_buf(writer);
+       this->encoding = chunk_clone(this->encoding);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_error_msg_t *this, u_int32_t *offset)
+{
+       u_int8_t flags, max_version, min_version;
+       u_int16_t reserved;
+       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 = 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 == PEN_IETF && reader->remaining(reader) == 4)
+       {
+               if (this->error_code == PB_ERROR_VERSION_NOT_SUPPORTED)
+               {
+                       reader->read_uint8(reader, &this->bad_version);
+                       reader->read_uint8(reader, &max_version);
+                       reader->read_uint8(reader, &min_version);
+               }
+               else
+               {
+                       reader->read_uint32(reader, &this->error_offset);
+               }
+       }
+       reader->destroy(reader);
+
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, get_ref, pb_tnc_msg_t*,
+       private_pb_error_msg_t *this)
+{
+       ref_get(&this->ref);
+       return &this->public.pb_interface;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_error_msg_t *this)
+{
+       if (ref_put(&this->ref))
+       {
+               free(this->encoding.ptr);
+               free(this);
+       }
+}
+
+METHOD(pb_error_msg_t, get_fatal_flag, bool,
+       private_pb_error_msg_t *this)
+{
+       return this->fatal;
+}
+
+METHOD(pb_error_msg_t, get_vendor_id, u_int32_t,
+       private_pb_error_msg_t *this)
+{
+       return this->vendor_id;
+}
+
+METHOD(pb_error_msg_t, get_error_code, u_int16_t,
+       private_pb_error_msg_t *this)
+{
+       return this->error_code;
+}
+
+METHOD(pb_error_msg_t, get_offset, u_int32_t,
+       private_pb_error_msg_t *this)
+{
+       return this->error_offset;
+}
+
+METHOD(pb_error_msg_t, get_bad_version, u_int8_t,
+       private_pb_error_msg_t *this)
+{
+       return this->bad_version;
+}
+
+METHOD(pb_error_msg_t, set_bad_version, void,
+       private_pb_error_msg_t *this, u_int8_t version)
+{
+       this->bad_version = version;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t* pb_error_msg_create(bool fatal, u_int32_t vendor_id,
+                                                                 pb_tnc_error_code_t error_code)
+{
+       private_pb_error_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .get_ref = _get_ref,
+                               .destroy = _destroy,
+                       },
+                       .get_fatal_flag = _get_fatal_flag,
+                       .get_vendor_id = _get_vendor_id,
+                       .get_error_code = _get_error_code,
+                       .get_offset = _get_offset,
+                       .get_bad_version = _get_bad_version,
+                       .set_bad_version = _set_bad_version,
+               },
+               .type = { PEN_IETF, PB_MSG_ERROR },
+               .ref = 1,
+               .fatal = fatal,
+               .vendor_id = vendor_id,
+               .error_code = error_code,
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t* pb_error_msg_create_with_offset(bool fatal, u_int32_t vendor_id,
+                                                                                         pb_tnc_error_code_t error_code,
+                                                                                         u_int32_t error_offset)
+{
+       private_pb_error_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .get_ref = _get_ref,
+                               .destroy = _destroy,
+                       },
+                       .get_fatal_flag = _get_fatal_flag,
+                       .get_vendor_id = _get_vendor_id,
+                       .get_error_code = _get_error_code,
+                       .get_offset = _get_offset,
+                       .get_bad_version = _get_bad_version,
+                       .set_bad_version = _set_bad_version,
+               },
+               .type = { PEN_IETF, PB_MSG_ERROR },
+               .ref = 1,
+               .fatal = fatal,
+               .vendor_id = vendor_id,
+               .error_code = error_code,
+               .error_offset = error_offset,
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_error_msg_create_from_data(chunk_t data)
+{
+       private_pb_error_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .get_ref = _get_ref,
+                               .destroy = _destroy,
+                       },
+                       .get_fatal_flag = _get_fatal_flag,
+                       .get_vendor_id = _get_vendor_id,
+                       .get_error_code = _get_error_code,
+                       .get_offset = _get_offset,
+                       .get_bad_version = _get_bad_version,
+                       .set_bad_version = _set_bad_version,
+               },
+               .type = { PEN_IETF, PB_MSG_ERROR },
+               .ref = 1,
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_error_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_error_msg.h
new file mode 100644 (file)
index 0000000..9c0ad82
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 pb_error_msg pb_error_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_ERROR_MSG_H_
+#define PB_ERROR_MSG_H_
+
+typedef enum pb_tnc_error_code_t pb_tnc_error_code_t;
+typedef struct pb_error_msg_t pb_error_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+/**
+ * PB-TNC Error Codes as defined in section 4.9.1 of RFC 5793
+ */
+enum  pb_tnc_error_code_t {
+       PB_ERROR_UNEXPECTED_BATCH_TYPE =                0,
+       PB_ERROR_INVALID_PARAMETER =                    1,
+       PB_ERROR_LOCAL_ERROR =                                  2,
+       PB_ERROR_UNSUPPORTED_MANDATORY_MSG =    3,
+       PB_ERROR_VERSION_NOT_SUPPORTED =                4
+};
+
+/**
+ * enum name for pb_tnc_error_code_t.
+ */
+extern enum_name_t *pb_tnc_error_code_names;
+
+/**
+ * Class representing the PB-Error message type.
+ */
+struct pb_error_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get the fatal flag
+        *
+        * @return                              fatal flag
+        */
+       bool (*get_fatal_flag)(pb_error_msg_t *this);
+
+       /**
+        * Get PB Error code Vendor ID
+        *
+        * @return                              PB Error Code Vendor ID
+        */
+       u_int32_t (*get_vendor_id)(pb_error_msg_t *this);
+
+       /**
+        * Get PB Error Code
+        *
+        * @return                              PB Error Code
+        */
+       u_int16_t (*get_error_code)(pb_error_msg_t *this);
+
+       /**
+        * Get the PB Error Offset
+        *
+        * @return                              PB Error Offset
+        */
+       u_int32_t (*get_offset)(pb_error_msg_t *this);
+
+       /**
+        * Get the PB Bad Version
+        *
+        * @return                              PB Bad Version
+        */
+       u_int8_t (*get_bad_version)(pb_error_msg_t *this);
+
+       /**
+        * Set the PB Bad Version
+        *
+        * @param version               PB Bad Version
+        */
+       void (*set_bad_version)(pb_error_msg_t *this, u_int8_t version);
+};
+
+/**
+ * Create a PB-Error message from parameters
+ *
+ * @param fatal                                fatal flag
+ * @param vendor_id                    Error Code Vendor ID
+ * @param error_code           Error Code
+ */
+pb_tnc_msg_t* pb_error_msg_create(bool fatal, u_int32_t vendor_id,
+                                                                 pb_tnc_error_code_t error_code);
+       
+/**
+ * Create a PB-Error message from parameters with offset field
+ *
+ * @param fatal                                fatal flag
+ * @param vendor_id                    Error Code Vendor ID
+ * @param error_code           Error Code
+ * @param error_offset         Error Offset
+ */
+pb_tnc_msg_t* pb_error_msg_create_with_offset(bool fatal, u_int32_t vendor_id,
+                                                                                         pb_tnc_error_code_t error_code,
+                                                                                         u_int32_t error_offset);
+
+/**
+ * Create an unprocessed PB-Error message from raw data
+ *
+ * @param data                         PB-Error message data
+ */
+pb_tnc_msg_t* pb_error_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.c
new file mode 100644 (file)
index 0000000..c629088
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 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 "pb_experimental_msg.h"
+
+typedef struct private_pb_experimental_msg_t private_pb_experimental_msg_t;
+
+/**
+ * Private data of a pb_experimental_msg_t object.
+ *
+ */
+struct private_pb_experimental_msg_t {
+       /**
+        * Public pb_experimental_msg_t interface.
+        */
+       pb_experimental_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_experimental_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_experimental_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_experimental_msg_t *this)
+{
+       /* nothing to do since message contents equal encoding */
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_experimental_msg_t *this, u_int32_t *offset)
+{
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_experimental_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this);
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_experimental_msg_create_from_data(chunk_t data)
+{
+       private_pb_experimental_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+               },
+               .type = { PEN_IETF, PB_MSG_EXPERIMENTAL },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_experimental_msg_create(chunk_t body)
+{
+       return pb_experimental_msg_create_from_data(body);
+}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_experimental_msg.h
new file mode 100644 (file)
index 0000000..fb9ede1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 pb_experimental_msg pb_experimental_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_EXPERIMENTAL_MSG_H_
+#define PB_EXPERIMENTAL_MSG_H_
+
+typedef struct pb_experimental_msg_t pb_experimental_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+/**
+ * Class representing the PB-Experimental message type.
+ */
+struct pb_experimental_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+};
+
+/**
+ * Create a PB-Experimental message from parameters
+ *
+ * @param body                 message body
+ */
+pb_tnc_msg_t* pb_experimental_msg_create(chunk_t body);
+
+/**
+ * Create an unprocessed PB-Experimental message from raw data
+ *
+ * @param data                 PB-Experimental message data
+ */
+pb_tnc_msg_t* pb_experimental_msg_create_from_data(chunk_t data);
+
+#endif /** PB_EXPERIMENTAL_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_language_preference_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_language_preference_msg.c
new file mode 100644 (file)
index 0000000..f14f289
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 "pb_language_preference_msg.h"
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <utils/debug.h>
+
+typedef struct private_pb_language_preference_msg_t private_pb_language_preference_msg_t;
+
+/**
+ *   PB-Language-Preference message (see section 4.10 of RFC 5793)
+ *
+ *      0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |              Language Preference (Variable Length)            |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define PB_LANG_PREFIX                 "Accept-Language: "
+#define PB_LANG_PREFIX_LEN             strlen(PB_LANG_PREFIX)
+
+/**
+ * Private data of a pb_language_preference_msg_t object.
+ *
+ */
+struct private_pb_language_preference_msg_t {
+       /**
+        * Public pb_access_recommendation_msg_t interface.
+        */
+       pb_language_preference_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Language preference
+        */
+       chunk_t language_preference;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_language_preference_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_language_preference_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_language_preference_msg_t *this)
+{
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+       this->encoding = chunk_cat("cc",
+                                               chunk_create(PB_LANG_PREFIX, PB_LANG_PREFIX_LEN),
+                                               this->language_preference);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_language_preference_msg_t *this, u_int32_t *offset)
+{
+       chunk_t lang;
+
+       if (this->encoding.len >= PB_LANG_PREFIX_LEN &&
+               memeq(this->encoding.ptr, PB_LANG_PREFIX, PB_LANG_PREFIX_LEN))
+       {
+               lang = chunk_skip(this->encoding, PB_LANG_PREFIX_LEN);
+               this->language_preference = lang.len ? chunk_clone(lang) : chunk_empty;
+       }
+       else
+    {
+               DBG1(DBG_TNC, "language preference must be preceded by '%s'",
+                                          PB_LANG_PREFIX);
+               *offset = 0;
+               return FAILED;
+       }
+
+       if (this->language_preference.len &&
+               this->language_preference.ptr[this->language_preference.len-1] == '\0')
+       {
+               DBG1(DBG_TNC, "language preference must not be null terminated");
+               *offset = PB_LANG_PREFIX_LEN + this->language_preference.len - 1;
+               return FAILED;
+       }
+
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_language_preference_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this->language_preference.ptr);
+       free(this);
+}
+
+METHOD(pb_language_preference_msg_t, get_language_preference, chunk_t,
+       private_pb_language_preference_msg_t *this)
+{
+       return this->language_preference;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_language_preference_msg_create_from_data(chunk_t data)
+{
+       private_pb_language_preference_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_language_preference = _get_language_preference,
+               },
+               .type = { PEN_IETF, PB_MSG_LANGUAGE_PREFERENCE },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_language_preference_msg_create(chunk_t language_preference)
+{
+       private_pb_language_preference_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_language_preference = _get_language_preference,
+               },
+               .type = { PEN_IETF, PB_MSG_LANGUAGE_PREFERENCE },
+               .language_preference = chunk_clone(language_preference),
+       );
+
+       return &this->public.pb_interface;
+}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_language_preference_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_language_preference_msg.h
new file mode 100644 (file)
index 0000000..512cab3
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 pb_language_preference_msg pb_language_preference_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_LANGUAGE_PREFERENCE_MSG_H_
+#define PB_LANGUAGE_PREFERENCE_MSG_H_
+
+typedef struct pb_language_preference_msg_t pb_language_preference_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+/**
+ * Class representing the PB-Language-Preference message type.
+ */
+struct pb_language_preference_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get PB Language Preference
+        *
+        * @return                      Language preference
+        */
+       chunk_t (*get_language_preference)(pb_language_preference_msg_t *this);
+};
+
+/**
+ * Create a PB-Language-Preference message from parameters
+ *
+ * @param language_preference          Preferred language(s)
+ */
+pb_tnc_msg_t* pb_language_preference_msg_create(chunk_t language_preference);
+
+/**
+ * Create an unprocessed PB-Language-Preference message from raw data
+ *
+  * @param data                PB-Language-Preference message data
+ */
+pb_tnc_msg_t* pb_language_preference_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_pa_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_pa_msg.c
new file mode 100644 (file)
index 0000000..a9a097b
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyanbuu
+ * Copyright (C) 2010 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 "pb_pa_msg.h"
+
+#include <tnc/tnccs/tnccs.h>
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <pen/pen.h>
+#include <utils/debug.h>
+
+typedef struct private_pb_pa_msg_t private_pb_pa_msg_t;
+
+/**
+ *   PB-PA message
+ *
+ *      0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |    Flags      |               PA Message Vendor ID            |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                           PA Subtype                          |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |  Posture Collector Identifier | Posture Validator Identifier  |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                 PA Message Body (Variable Length)             |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define PA_FLAG_NONE                   0x00
+#define PA_FLAG_EXCL                   (1<<7)
+#define PA_RESERVED_SUBTYPE            0xffffffff
+
+
+/**
+ * Private data of a pb_pa_msg_t object.
+ *
+ */
+struct private_pb_pa_msg_t {
+       /**
+        * Public pb_pa_msg_t interface.
+        */
+       pb_pa_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Exclusive flag
+        */
+       bool excl;
+
+       /**
+        * Vendor-specific PA Subtype
+        */
+       pen_type_t subtype;
+
+       /**
+        * Posture Validator Identifier
+        */
+       u_int16_t collector_id;
+
+       /**
+        * Posture Validator Identifier
+        */
+       u_int16_t validator_id;
+
+       /**
+        * PA Message Body
+        */
+       chunk_t msg_body;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_pa_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_pa_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_pa_msg_t *this)
+{
+       chunk_t msg_header;
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+
+       /* build message header */
+       writer = bio_writer_create(64);
+       writer->write_uint8 (writer, this->excl ? PA_FLAG_EXCL : PA_FLAG_NONE);
+       writer->write_uint24(writer, this->subtype.vendor_id);
+       writer->write_uint32(writer, this->subtype.type);
+       writer->write_uint16(writer, this->collector_id);
+       writer->write_uint16(writer, this->validator_id);
+       msg_header = writer->get_buf(writer);
+
+       /* create encoding by concatenating message header and message body */
+       this->encoding = chunk_cat("cc", msg_header, this->msg_body);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_pa_msg_t *this, u_int32_t *offset)
+{
+       u_int8_t flags;
+       size_t msg_body_len;
+       bio_reader_t *reader;
+
+       /* process message header */
+       reader = bio_reader_create(this->encoding);
+       reader->read_uint8 (reader, &flags);
+       reader->read_uint24(reader, &this->subtype.vendor_id);
+       reader->read_uint32(reader, &this->subtype.type);
+       reader->read_uint16(reader, &this->collector_id);
+       reader->read_uint16(reader, &this->validator_id);
+       this->excl = ((flags & PA_FLAG_EXCL) != PA_FLAG_NONE);
+
+       /* process message body */
+       msg_body_len = reader->remaining(reader);
+       if (msg_body_len)
+       {
+               reader->read_data(reader, msg_body_len, &this->msg_body);
+               this->msg_body = chunk_clone(this->msg_body);
+       }
+       reader->destroy(reader);
+
+       if (this->subtype.vendor_id == PEN_RESERVED)
+       {
+               DBG1(DBG_TNC, "Vendor ID 0x%06x is reserved", PEN_RESERVED);
+               *offset = 1;
+               return FAILED;
+       }
+
+       if (this->subtype.type == PA_RESERVED_SUBTYPE)
+       {
+               DBG1(DBG_TNC, "PA Subtype 0x%08x is reserved", PA_RESERVED_SUBTYPE);
+               *offset = 4;
+               return FAILED;
+       }
+
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_pa_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this->msg_body.ptr);
+       free(this);
+}
+
+METHOD(pb_pa_msg_t, get_subtype, pen_type_t,
+       private_pb_pa_msg_t *this)
+{
+       return this->subtype;
+}
+
+METHOD(pb_pa_msg_t, get_collector_id, u_int16_t,
+       private_pb_pa_msg_t *this)
+{
+       return this->collector_id;
+}
+
+METHOD(pb_pa_msg_t, get_validator_id, u_int16_t,
+       private_pb_pa_msg_t *this)
+{
+       return this->validator_id;
+}
+
+METHOD(pb_pa_msg_t, get_body, chunk_t,
+       private_pb_pa_msg_t *this)
+{
+       return this->msg_body;
+}
+
+METHOD(pb_pa_msg_t, get_exclusive_flag, bool,
+       private_pb_pa_msg_t *this)
+{
+       return this->excl;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_pa_msg_create_from_data(chunk_t data)
+{
+       private_pb_pa_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_subtype = _get_subtype,
+                       .get_collector_id = _get_collector_id,
+                       .get_validator_id = _get_validator_id,
+                       .get_body = _get_body,
+                       .get_exclusive_flag = _get_exclusive_flag,
+               },
+               .type = { PEN_IETF, PB_MSG_PA },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+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,
+                                                          bool excl, chunk_t msg_body)
+{
+       private_pb_pa_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_subtype= _get_subtype,
+                       .get_collector_id = _get_collector_id,
+                       .get_validator_id = _get_validator_id,
+                       .get_body = _get_body,
+                       .get_exclusive_flag = _get_exclusive_flag,
+               },
+               .type = { PEN_IETF, PB_MSG_PA },
+               .subtype = { vendor_id, subtype },
+               .collector_id = collector_id,
+               .validator_id = validator_id,
+               .excl = excl,
+               .msg_body = chunk_clone(msg_body),
+       );
+
+       return &this->public.pb_interface;
+}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_pa_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_pa_msg.h
new file mode 100644 (file)
index 0000000..093bb45
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010 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 pb_pa_msg pb_pa_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_PA_MSG_H_
+#define PB_PA_MSG_H_
+
+typedef struct pb_pa_msg_t pb_pa_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+#include <pen/pen.h>
+
+/**
+ * Class representing the PB-PA message type.
+ */
+struct pb_pa_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get PA Message Vendor ID and Subtype
+        *
+        * @return                              Vendor-specific PA Subtype
+        */
+       pen_type_t (*get_subtype)(pb_pa_msg_t *this);
+
+       /**
+        * Get Posture Collector ID
+        *
+        * @return                              Posture Collector ID
+        */
+       u_int16_t (*get_collector_id)(pb_pa_msg_t *this);
+
+       /**
+        * Get Posture Validator ID
+        *
+        * @return                              Posture Validator ID
+        */
+       u_int16_t (*get_validator_id)(pb_pa_msg_t *this);
+
+       /**
+        * Get the PA Message Body
+        *
+        * @return                              PA Message Body
+        */
+       chunk_t (*get_body)(pb_pa_msg_t *this);
+
+       /**
+        * Get the exclusive flag
+        *
+        * @return                              exclusive flag
+        */
+       bool (*get_exclusive_flag)(pb_pa_msg_t *this);
+
+};
+
+/**
+ * Create a PB-PA message from parameters
+ *
+ * @param vendor_id                    PA Message Vendor ID
+ * @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,
+                                                          bool excl, chunk_t msg_body);
+
+/**
+ * Create an unprocessed PB-PA message from raw data
+ *
+  * @param data                PB-PA message data
+ */
+pb_tnc_msg_t* pb_pa_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_reason_string_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_reason_string_msg.c
new file mode 100644 (file)
index 0000000..cafc4ec
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 "pb_reason_string_msg.h"
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <utils/debug.h>
+
+typedef struct private_pb_reason_string_msg_t private_pb_reason_string_msg_t;
+
+/**
+ *   PB-Language-Preference message (see section 4.11 of RFC 5793)
+ *
+ *      0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                      Reason String Length                     |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                Reason String (Variable Length)                |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     | Lang Code Len | Reason String Language Code (Variable Length) |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+/**
+ * Private data of a pb_reason_string_msg_t object.
+ *
+ */
+struct private_pb_reason_string_msg_t {
+       /**
+        * Public pb_reason_string_msg_t interface.
+        */
+       pb_reason_string_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Reason string
+        */
+       chunk_t reason_string;
+
+       /**
+        * Language code
+        */
+       chunk_t language_code;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_reason_string_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_reason_string_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_reason_string_msg_t *this)
+{
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+       writer = bio_writer_create(64);
+       writer->write_data32(writer, this->reason_string);
+       writer->write_data8 (writer, this->language_code);
+
+       this->encoding = writer->get_buf(writer);
+       this->encoding = chunk_clone(this->encoding);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_reason_string_msg_t *this, u_int32_t *offset)
+{
+       bio_reader_t *reader;
+
+       reader = bio_reader_create(this->encoding);
+       if (!reader->read_data32(reader, &this->reason_string))
+       {
+               DBG1(DBG_TNC, "could not parse reason string");
+               reader->destroy(reader);
+               *offset = 0;
+               return FAILED;
+       };
+       this->reason_string = chunk_clone(this->reason_string);
+
+       if (this->reason_string.len &&
+               this->reason_string.ptr[this->reason_string.len-1] == '\0')
+       {
+               DBG1(DBG_TNC, "reason string must not be null terminated");
+               reader->destroy(reader);
+               *offset = 3 + this->reason_string.len;
+               return FAILED;
+       }
+
+       if (!reader->read_data8(reader, &this->language_code))
+       {
+               DBG1(DBG_TNC, "could not parse language code");
+               reader->destroy(reader);
+               *offset = 4 + this->reason_string.len;
+               return FAILED;
+       };
+       this->language_code = chunk_clone(this->language_code);
+       reader->destroy(reader);
+
+       if (this->language_code.len &&
+               this->language_code.ptr[this->language_code.len-1] == '\0')
+       {
+               DBG1(DBG_TNC, "language code must not be null terminated");
+               *offset = 4 + this->reason_string.len + this->language_code.len;
+               return FAILED;
+       }
+
+       return SUCCESS;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_reason_string_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this->reason_string.ptr);
+       free(this->language_code.ptr);
+       free(this);
+}
+
+METHOD(pb_reason_string_msg_t, get_reason_string, chunk_t,
+       private_pb_reason_string_msg_t *this)
+{
+       return this->reason_string;
+}
+
+METHOD(pb_reason_string_msg_t, get_language_code, chunk_t,
+       private_pb_reason_string_msg_t *this)
+{
+       return this->language_code;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_reason_string_msg_create_from_data(chunk_t data)
+{
+       private_pb_reason_string_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_reason_string = _get_reason_string,
+                       .get_language_code = _get_language_code,
+               },
+               .type = { PEN_IETF, PB_MSG_REASON_STRING },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_reason_string_msg_create(chunk_t reason_string,
+                                                                                 chunk_t language_code)
+{
+       private_pb_reason_string_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_reason_string = _get_reason_string,
+                       .get_language_code = _get_language_code,
+               },
+               .type = { PEN_IETF, PB_MSG_REASON_STRING },
+               .reason_string = chunk_clone(reason_string),
+               .language_code = chunk_clone(language_code),
+       );
+
+       return &this->public.pb_interface;
+}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_reason_string_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_reason_string_msg.h
new file mode 100644 (file)
index 0000000..65e3e88
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Sansar Choinyambuu
+ * 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 pb_reason_string_msg pb_reason_string_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_REASON_STRING_MSG_H_
+#define PB_REASON_STRING_MSG_H_
+
+typedef struct pb_reason_string_msg_t pb_reason_string_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+/**
+ * Class representing the PB-Reason-String message type.
+ */
+struct pb_reason_string_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get Reason String
+        *
+        * @return                      Reason string
+        */
+       chunk_t (*get_reason_string)(pb_reason_string_msg_t *this);
+
+       /**
+        * Get Reason String Language Code
+        *
+        * @return                      Language code
+        */
+       chunk_t (*get_language_code)(pb_reason_string_msg_t *this);
+};
+
+/**
+ * Create a PB-Reason-String message from parameters
+ *
+ * @param reason_string                Reason string
+  * @param language_code       Language code
+ */
+pb_tnc_msg_t* pb_reason_string_msg_create(chunk_t reason_string,
+                                                                                 chunk_t language_code);
+
+/**
+ * Create an unprocessed PB-Reason-String message from raw data
+ *
+  * @param data                PB-Reason-String message data
+ */
+pb_tnc_msg_t* pb_reason_string_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_remediation_parameters_msg.c b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_remediation_parameters_msg.c
new file mode 100644 (file)
index 0000000..8dc5906
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2010 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 "pb_remediation_parameters_msg.h"
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <utils/debug.h>
+
+ENUM(pb_tnc_remed_param_type_names, PB_REMEDIATION_URI, PB_REMEDIATION_STRING,
+       "Remediation-URI",
+       "Remediation-String"
+);
+
+typedef struct private_pb_remediation_parameters_msg_t private_pb_remediation_parameters_msg_t;
+
+/**
+ *   PB-Remediation-Parameters message (see section 4.8 of RFC 5793)
+ *
+ *      0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |    Reserved   |       Remediation Parameters Vendor ID        |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                  Remediation Parameters Type                  |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |            Remediation Parameters (Variable Length)           |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *     0                   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
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                   Remediation String Length                   |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     |                Remediation String (Variable Length)           |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *     | Lang Code Len |  Remediation String Lang Code (Variable Len)  |
+ *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+/**
+ * Private data of a pb_remediation_parameters_msg_t object.
+ *
+ */
+struct private_pb_remediation_parameters_msg_t {
+       /**
+        * Public pb_remediation_parameters_msg_t interface.
+        */
+       pb_remediation_parameters_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * Remediation Parameters Type
+        */
+       pen_type_t parameters_type;
+
+       /**
+        * Remediation Parameters
+        */
+       chunk_t parameters;
+
+       /**
+        * Remediation String
+        */
+       chunk_t string;
+
+       /**
+        * Remediation Language Code
+        */
+       chunk_t lang_code;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_remediation_parameters_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_remediation_parameters_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_remediation_parameters_msg_t *this)
+{
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+       writer = bio_writer_create(64);
+       writer->write_uint32(writer, this->parameters_type.vendor_id);
+       writer->write_uint32(writer, this->parameters_type.type);
+       writer->write_data  (writer, this->parameters);
+
+       this->encoding = writer->get_buf(writer);
+       this->encoding = chunk_clone(this->encoding);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_remediation_parameters_msg_t *this, u_int32_t *offset)
+{
+       bio_reader_t *reader;
+       u_int8_t reserved;
+       status_t status = SUCCESS;
+       u_char *pos;
+
+       *offset = 0;
+
+       /* process message */
+       reader = bio_reader_create(this->encoding);
+       reader->read_uint8 (reader, &reserved);
+       reader->read_uint24(reader, &this->parameters_type.vendor_id);
+       reader->read_uint32(reader, &this->parameters_type.type);
+       reader->read_data  (reader, reader->remaining(reader), &this->parameters);
+
+       this->parameters = chunk_clone(this->parameters);
+       reader->destroy(reader);
+
+       if (this->parameters_type.vendor_id == PEN_IETF &&
+               this->parameters_type.type == PB_REMEDIATION_STRING)
+       {
+               reader = bio_reader_create(this->parameters);
+               status = FAILED;
+               *offset = 8;
+
+               if (!reader->read_data32(reader, &this->string))
+               {
+                       DBG1(DBG_TNC, "insufficient data for remediation string");
+                       goto end;
+               };
+               *offset += 4;
+
+               pos = memchr(this->string.ptr, '\0', this->string.len);
+               if (pos)
+               {
+                       DBG1(DBG_TNC, "nul termination in remediation string");
+                       *offset += (pos - this->string.ptr);
+                       goto end;
+               }
+               *offset += this->string.len;
+
+               if (!reader->read_data8(reader, &this->lang_code))
+               {
+                       DBG1(DBG_TNC, "insufficient data for remediation string lang code");
+                       goto end;
+               };
+               *offset += 1;
+
+               pos = memchr(this->lang_code.ptr, '\0', this->lang_code.len);
+
+               if (pos)
+               {
+                       DBG1(DBG_TNC, "nul termination in remediation string lang code");
+                       *offset += (pos - this->lang_code.ptr);
+                       goto end;
+               }
+               status = SUCCESS;
+
+end:
+               reader->destroy(reader);
+       }
+       return status;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_remediation_parameters_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this->parameters.ptr);
+       free(this);
+}
+
+METHOD(pb_remediation_parameters_msg_t, get_parameters_type, pen_type_t,
+       private_pb_remediation_parameters_msg_t *this)
+{
+       return this->parameters_type;
+}
+
+METHOD(pb_remediation_parameters_msg_t, get_parameters, chunk_t,
+       private_pb_remediation_parameters_msg_t *this)
+{
+       return this->parameters;
+}
+
+METHOD(pb_remediation_parameters_msg_t, get_string, chunk_t,
+       private_pb_remediation_parameters_msg_t *this, chunk_t *lang_code)
+{
+       if (lang_code)
+       {
+               *lang_code = this->lang_code;
+       }
+       return this->string;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create(pen_type_t parameters_type,
+                                                                                                  chunk_t parameters)
+{
+       private_pb_remediation_parameters_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_parameters_type = _get_parameters_type,
+                       .get_parameters = _get_parameters,
+                       .get_uri = _get_parameters,
+                       .get_string = _get_string,
+               },
+               .type = { PEN_IETF, PB_MSG_REMEDIATION_PARAMETERS },
+               .parameters_type = parameters_type,
+               .parameters = chunk_clone(parameters),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * Described in header.
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_uri(chunk_t uri)
+{
+       pen_type_t type = { PEN_IETF, PB_REMEDIATION_URI };
+
+       return pb_remediation_parameters_msg_create(type, uri);
+}
+
+/**
+ * Described in header.
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_string(chunk_t string,
+                                                                                                                          chunk_t lang_code)
+{
+       pb_tnc_msg_t *msg;
+       bio_writer_t *writer;
+       pen_type_t type = { PEN_IETF, PB_REMEDIATION_STRING };
+
+       /* limit language code to 255 octets */
+       lang_code.len = min(255, lang_code.len);
+
+       writer = bio_writer_create(4 + string.len + 1 + lang_code.len);
+       writer->write_data32(writer, string);
+       writer->write_data8 (writer, lang_code);
+
+       msg = pb_remediation_parameters_msg_create(type, writer->get_buf(writer));
+       writer->destroy(writer);
+
+       return msg;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_remediation_parameters_msg_create_from_data(chunk_t data)
+{
+       private_pb_remediation_parameters_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_parameters_type = _get_parameters_type,
+                       .get_parameters = _get_parameters,
+                       .get_uri = _get_parameters,
+                       .get_string = _get_string,
+               },
+               .type = { PEN_IETF, PB_MSG_REMEDIATION_PARAMETERS },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
diff --git a/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_remediation_parameters_msg.h b/src/libtnccs/plugins/tnccs_20/messages/ietf/pb_remediation_parameters_msg.h
new file mode 100644 (file)
index 0000000..c07e527
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2011-2013 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 pb_remediation_parameters_msg pb_remediation_parameters_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_REMEDIATION_PARAMETERS_MSG_H_
+#define PB_REMEDIATION_PARAMETERS_MSG_H_
+
+typedef enum pb_tnc_remed_param_type_t pb_tnc_remed_param_type_t;
+typedef struct pb_remediation_parameters_msg_t pb_remediation_parameters_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+#include <pen/pen.h>
+
+/**
+ * PB-TNC Remediation Parameter Types as defined in section 4.8.1 of RFC 5793
+ */
+enum pb_tnc_remed_param_type_t {
+       PB_REMEDIATION_URI =                    1,
+       PB_REMEDIATION_STRING =                 2,
+};
+
+/**
+ * enum name for pb_tnc_remed_param_type_t.
+ */
+extern enum_name_t *pb_tnc_remed_param_type_names;
+
+/**
+ * Class representing the PB-Remediation-Parameters message type.
+ */
+struct pb_remediation_parameters_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get the Remediation Parameters Type (Vendor ID and Type)
+        *
+        * @return                              Remediation Parameters Type
+        */
+       pen_type_t (*get_parameters_type)(pb_remediation_parameters_msg_t *this);
+
+       /**
+        * Get the Remediation Parameters
+        *
+        * @return                              Remediation Parameters
+        */
+       chunk_t (*get_parameters)(pb_remediation_parameters_msg_t *this);
+
+       /**
+        * Get the Remediation URI
+        *
+        * @return                              Remediation URI
+        */
+       chunk_t (*get_uri)(pb_remediation_parameters_msg_t *this);
+
+       /**
+        * Get the Remediation String
+        *
+        * @param lang_code             Optional Language Code
+        * @return                              Remediation String
+        */
+       chunk_t (*get_string)(pb_remediation_parameters_msg_t *this,
+                                                 chunk_t *lang_code);
+
+};
+
+/**
+ * Create a general PB-Remediation-Parameters message
+ *
+ * @param parameters_type      Remediation Parameters Type
+ * @param parameters           Remediation Parameters
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create(pen_type_t parameters_type,
+                                                                                                  chunk_t parameters);
+
+/**
+ * Create a PB-Remediation-Parameters message of IETF Type Remediation URI
+ *
+ * @param uri                          Remediation URI
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_uri(chunk_t uri);
+
+/**
+ * Create a PB-Remediation-Parameters message of IETF Type Remediation String
+ *
+ * @param string                       Remediation String
+ * @param lang_code                    Remediation String Language Code
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_string(chunk_t string,
+                                                                                                                          chunk_t lang_code);
+
+/**
+ * Create an unprocessed PB-Remediation-Parameters message from raw data
+ *
+  * @param data                PB-Remediation-Parameters message data
+ */
+pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_access_recommendation_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_access_recommendation_msg.c
deleted file mode 100644 (file)
index cdd0d0d..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 "pb_access_recommendation_msg.h"
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-ENUM(pb_access_recommendation_code_names, PB_REC_ACCESS_ALLOWED, PB_REC_QUARANTINED,
-       "Access Allowed",
-       "Access Denied",
-       "Quarantined"
-);
-
-typedef struct private_pb_access_recommendation_msg_t private_pb_access_recommendation_msg_t;
-
-/**
- *   PB-Access-Recommendation message (see section 4.7 of RFC 5793)
- *
- *      0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |          Reserved             |   Access Recommendation Code  |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define ACCESS_RECOMMENDATION_RESERVED         0x0000
-#define ACCESS_RECOMMENDATION_MSG_SIZE         4
-/**
- * Private data of a pb_access_recommendation_msg_t object.
- *
- */
-struct private_pb_access_recommendation_msg_t {
-       /**
-        * Public pb_access_recommendation_msg_t interface.
-        */
-       pb_access_recommendation_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Access recommendation code
-        */
-       u_int16_t recommendation;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_access_recommendation_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_access_recommendation_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_access_recommendation_msg_t *this)
-{
-       bio_writer_t *writer;
-
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-       writer = bio_writer_create(ACCESS_RECOMMENDATION_MSG_SIZE);
-       writer->write_uint16(writer, ACCESS_RECOMMENDATION_RESERVED);
-       writer->write_uint16(writer, this->recommendation);
-       this->encoding = writer->get_buf(writer);
-       this->encoding = chunk_clone(this->encoding);
-       writer->destroy(writer);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_access_recommendation_msg_t *this, u_int32_t *offset)
-{
-       bio_reader_t *reader;
-       u_int16_t reserved;
-
-       reader = bio_reader_create(this->encoding);
-       reader->read_uint16(reader, &reserved);
-       reader->read_uint16(reader, &this->recommendation);
-       reader->destroy(reader);
-
-       if (this->recommendation < PB_REC_ACCESS_ALLOWED ||
-               this->recommendation > PB_REC_QUARANTINED)
-       {
-               DBG1(DBG_TNC, "invalid access recommendation code (%u)",
-                                          this->recommendation);
-               *offset = 2;
-               return FAILED;
-       }
-
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_access_recommendation_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this);
-}
-
-METHOD(pb_access_recommendation_msg_t, get_access_recommendation, u_int16_t,
-       private_pb_access_recommendation_msg_t *this)
-{
-       return this->recommendation;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_access_recommendation_msg_create_from_data(chunk_t data)
-{
-       private_pb_access_recommendation_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_access_recommendation = _get_access_recommendation,
-               },
-               .type = PB_MSG_ACCESS_RECOMMENDATION,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_access_recommendation_msg_create(u_int16_t recommendation)
-{
-       private_pb_access_recommendation_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_access_recommendation = _get_access_recommendation,
-               },
-               .type = PB_MSG_ACCESS_RECOMMENDATION,
-               .recommendation = recommendation,
-       );
-
-       return &this->public.pb_interface;
-}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_access_recommendation_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_access_recommendation_msg.h
deleted file mode 100644 (file)
index 01b83cf..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 pb_access_recommendation_msg pb_access_recommendation_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_ACCESS_RECOMMENDATION_MSG_H_
-#define PB_ACCESS_RECOMMENDATION_MSG_H_
-
-typedef enum pb_access_recommendation_code_t pb_access_recommendation_code_t;
-typedef struct pb_access_recommendation_msg_t pb_access_recommendation_msg_t;
-
-#include "pb_tnc_msg.h"
-
-/**
- * PB Access Recommendation Codes as defined in section 4.7 of RFC 5793
- */
-enum pb_access_recommendation_code_t {
-       PB_REC_ACCESS_ALLOWED = 1,
-       PB_REC_ACCESS_DENIED =  2,
-       PB_REC_QUARANTINED =    3,
-};
-
-/**
- * enum name for pb_access_recommendation_code_t.
- */
-extern enum_name_t *pb_access_recommendation_code_names;
-
-
-/**
- * Class representing the PB-Access-Recommendation message type.
- */
-struct pb_access_recommendation_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get PB Access Recommendation
-        *
-        * @return                      PB Access Recommendation
-        */
-       u_int16_t (*get_access_recommendation)(pb_access_recommendation_msg_t *this);
-};
-
-/**
- * Create a PB-Access-Recommendation message from parameters
- *
- * @param recommendation       Access Recommendation code
- */
-pb_tnc_msg_t* pb_access_recommendation_msg_create(u_int16_t recommendation);
-
-/**
- * Create an unprocessed PB-Access-Recommendation message from raw data
- *
-  * @param data                PB-Access-Recommendation message data
- */
-pb_tnc_msg_t* pb_access_recommendation_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_assessment_result_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_assessment_result_msg.c
deleted file mode 100644 (file)
index 4e50446..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 "pb_assessment_result_msg.h"
-
-#include <tncifimv.h>
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_pb_assessment_result_msg_t private_pb_assessment_result_msg_t;
-
-/**
- *   PB-Assessment-Result message (see section 4.6 of RFC 5793)
- *
- *                          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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                       Assessment Result                       |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define ASSESSMENT_RESULT_MSG_SIZE     4
-
-/**
- * Private data of a pb_assessment_result_msg_t object.
- *
- */
-struct private_pb_assessment_result_msg_t {
-       /**
-        * Public pb_assessment_result_msg_t interface.
-        */
-       pb_assessment_result_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Assessment result code
-        */
-       u_int32_t assessment_result;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_assessment_result_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_assessment_result_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_assessment_result_msg_t *this)
-{
-       bio_writer_t *writer;
-
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-       writer = bio_writer_create(ASSESSMENT_RESULT_MSG_SIZE);
-       writer->write_uint32(writer, this->assessment_result);
-       this->encoding = writer->get_buf(writer);
-       this->encoding = chunk_clone(this->encoding);
-       writer->destroy(writer);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_assessment_result_msg_t *this, u_int32_t *offset)
-{
-       bio_reader_t *reader;
-
-       reader = bio_reader_create(this->encoding);
-       reader->read_uint32(reader, &this->assessment_result);
-       reader->destroy(reader);
-
-       if (this->assessment_result < TNC_IMV_EVALUATION_RESULT_COMPLIANT ||
-               this->assessment_result > TNC_IMV_EVALUATION_RESULT_DONT_KNOW)
-       {
-               DBG1(DBG_TNC, "invalid assessment result (%u)",
-                                          this->assessment_result);
-               *offset = 0;
-               return FAILED;
-       }
-
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_assessment_result_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this);
-}
-
-METHOD(pb_assessment_result_msg_t, get_assessment_result, u_int32_t,
-       private_pb_assessment_result_msg_t *this)
-{
-       return this->assessment_result;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_assessment_result_msg_create_from_data(chunk_t data)
-{
-       private_pb_assessment_result_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_assessment_result = _get_assessment_result,
-               },
-               .type = PB_MSG_ASSESSMENT_RESULT,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_assessment_result_msg_create(u_int32_t assessment_result)
-{
-       private_pb_assessment_result_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_assessment_result = _get_assessment_result,
-               },
-               .type = PB_MSG_ASSESSMENT_RESULT,
-               .assessment_result = assessment_result,
-       );
-
-       return &this->public.pb_interface;
-}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_assessment_result_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_assessment_result_msg.h
deleted file mode 100644 (file)
index d2b0051..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 pb_assessment_result_msg pb_assessment_result_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_ASSESSMENT_RESULT_MSG_H_
-#define PB_ASSESSMENT_RESULT_MSG_H_
-
-typedef struct pb_assessment_result_msg_t pb_assessment_result_msg_t;
-
-#include "pb_tnc_msg.h"
-
-/**
- * Class representing the PB-Assessment-Result message type.
- */
-struct pb_assessment_result_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get PB Assessment result
-        *
-        * @return                      PB Assessment result
-        */
-       u_int32_t (*get_assessment_result)(pb_assessment_result_msg_t *this);
-};
-
-/**
- * Create a PB-Assessment-Result message from parameters
- *
- * @param assessment_result            Assessment result code
- */
-pb_tnc_msg_t* pb_assessment_result_msg_create(u_int32_t assessment_result);
-
-/**
- * Create an unprocessed PB-Assessment-Result message from raw data
- *
-  * @param data                PB-Assessment-Result message data
- */
-pb_tnc_msg_t* pb_assessment_result_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_error_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_error_msg.c
deleted file mode 100644 (file)
index d048f43..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 "pb_error_msg.h"
-
-#include <tnc/tnccs/tnccs.h>
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <pen/pen.h>
-#include <utils/debug.h>
-
-ENUM(pb_tnc_error_code_names, PB_ERROR_UNEXPECTED_BATCH_TYPE,
-                                                         PB_ERROR_VERSION_NOT_SUPPORTED,
-       "Unexpected Batch Type",
-       "Invalid Parameter",
-       "Local Error",
-       "Unsupported Mandatory Message",
-       "Version Not Supported"
-);
-
-typedef struct private_pb_error_msg_t private_pb_error_msg_t;
-
-/**
- *   PB-Error message (see section 4.9 of RFC 5793)
- *
- *      0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |    Flags      |              Error Code Vendor ID             |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |           Error Code          |           Reserved            |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                Error Parameters (Variable Length)             |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define ERROR_FLAG_NONE                0x00
-#define ERROR_FLAG_FATAL       (1<<7)
-#define ERROR_RESERVED         0x0000
-#define ERROR_HEADER_SIZE      8
-
-/**
- * Private data of a pb_error_msg_t object.
- *
- */
-struct private_pb_error_msg_t {
-       /**
-        * Public pb_error_msg_t interface.
-        */
-       pb_error_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Fatal flag
-        */
-       bool fatal;
-
-       /**
-        * PB Error Code Vendor ID
-        */
-       u_int32_t vendor_id;
-
-       /**
-        * PB Error Code
-        */
-       u_int16_t error_code;
-
-       /**
-        * PB Error Offset
-        */
-       u_int32_t error_offset;
-
-       /**
-        * Bad PB-TNC version received
-        */
-       u_int8_t bad_version;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-
-       /**
-        * reference count
-        */
-       refcount_t ref;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_error_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_error_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_error_msg_t *this)
-{
-       bio_writer_t *writer;
-
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-
-       /* build message header */
-       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);
-       writer->write_uint16(writer, this->error_code);
-       writer->write_uint16(writer, ERROR_RESERVED);
-
-       /* build message body */
-       if (this->error_code == PB_ERROR_VERSION_NOT_SUPPORTED)
-       {
-               /* Bad version */
-               writer->write_uint8(writer, this->bad_version);
-               writer->write_uint8(writer, PB_TNC_VERSION); /* Max version */
-               writer->write_uint8(writer, PB_TNC_VERSION); /* Min version */
-               writer->write_uint8(writer, 0x00);           /* Reserved */
-       }
-       else
-       {
-               /* Error Offset */
-               writer->write_uint32(writer, this->error_offset);
-       }
-       this->encoding = writer->get_buf(writer);
-       this->encoding = chunk_clone(this->encoding);
-       writer->destroy(writer);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_error_msg_t *this, u_int32_t *offset)
-{
-       u_int8_t flags, max_version, min_version;
-       u_int16_t reserved;
-       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 = 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 == PEN_IETF && reader->remaining(reader) == 4)
-       {
-               if (this->error_code == PB_ERROR_VERSION_NOT_SUPPORTED)
-               {
-                       reader->read_uint8(reader, &this->bad_version);
-                       reader->read_uint8(reader, &max_version);
-                       reader->read_uint8(reader, &min_version);
-               }
-               else
-               {
-                       reader->read_uint32(reader, &this->error_offset);
-               }
-       }
-       reader->destroy(reader);
-
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, get_ref, pb_tnc_msg_t*,
-       private_pb_error_msg_t *this)
-{
-       ref_get(&this->ref);
-       return &this->public.pb_interface;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_error_msg_t *this)
-{
-       if (ref_put(&this->ref))
-       {
-               free(this->encoding.ptr);
-               free(this);
-       }
-}
-
-METHOD(pb_error_msg_t, get_fatal_flag, bool,
-       private_pb_error_msg_t *this)
-{
-       return this->fatal;
-}
-
-METHOD(pb_error_msg_t, get_vendor_id, u_int32_t,
-       private_pb_error_msg_t *this)
-{
-       return this->vendor_id;
-}
-
-METHOD(pb_error_msg_t, get_error_code, u_int16_t,
-       private_pb_error_msg_t *this)
-{
-       return this->error_code;
-}
-
-METHOD(pb_error_msg_t, get_offset, u_int32_t,
-       private_pb_error_msg_t *this)
-{
-       return this->error_offset;
-}
-
-METHOD(pb_error_msg_t, get_bad_version, u_int8_t,
-       private_pb_error_msg_t *this)
-{
-       return this->bad_version;
-}
-
-METHOD(pb_error_msg_t, set_bad_version, void,
-       private_pb_error_msg_t *this, u_int8_t version)
-{
-       this->bad_version = version;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t* pb_error_msg_create(bool fatal, u_int32_t vendor_id,
-                                                                 pb_tnc_error_code_t error_code)
-{
-       private_pb_error_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .get_ref = _get_ref,
-                               .destroy = _destroy,
-                       },
-                       .get_fatal_flag = _get_fatal_flag,
-                       .get_vendor_id = _get_vendor_id,
-                       .get_error_code = _get_error_code,
-                       .get_offset = _get_offset,
-                       .get_bad_version = _get_bad_version,
-                       .set_bad_version = _set_bad_version,
-               },
-               .type = PB_MSG_ERROR,
-               .ref = 1,
-               .fatal = fatal,
-               .vendor_id = vendor_id,
-               .error_code = error_code,
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t* pb_error_msg_create_with_offset(bool fatal, u_int32_t vendor_id,
-                                                                                         pb_tnc_error_code_t error_code,
-                                                                                         u_int32_t error_offset)
-{
-       private_pb_error_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .get_ref = _get_ref,
-                               .destroy = _destroy,
-                       },
-                       .get_fatal_flag = _get_fatal_flag,
-                       .get_vendor_id = _get_vendor_id,
-                       .get_error_code = _get_error_code,
-                       .get_offset = _get_offset,
-                       .get_bad_version = _get_bad_version,
-                       .set_bad_version = _set_bad_version,
-               },
-               .type = PB_MSG_ERROR,
-               .ref = 1,
-               .fatal = fatal,
-               .vendor_id = vendor_id,
-               .error_code = error_code,
-               .error_offset = error_offset,
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_error_msg_create_from_data(chunk_t data)
-{
-       private_pb_error_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .get_ref = _get_ref,
-                               .destroy = _destroy,
-                       },
-                       .get_fatal_flag = _get_fatal_flag,
-                       .get_vendor_id = _get_vendor_id,
-                       .get_error_code = _get_error_code,
-                       .get_offset = _get_offset,
-                       .get_bad_version = _get_bad_version,
-                       .set_bad_version = _set_bad_version,
-               },
-               .type = PB_MSG_ERROR,
-               .ref = 1,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_error_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_error_msg.h
deleted file mode 100644 (file)
index 8b92742..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 pb_error_msg pb_error_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_ERROR_MSG_H_
-#define PB_ERROR_MSG_H_
-
-typedef enum pb_tnc_error_code_t pb_tnc_error_code_t;
-typedef struct pb_error_msg_t pb_error_msg_t;
-
-#include "pb_tnc_msg.h"
-
-/**
- * PB-TNC Error Codes as defined in section 4.9.1 of RFC 5793
- */
-enum  pb_tnc_error_code_t {
-       PB_ERROR_UNEXPECTED_BATCH_TYPE =                0,
-       PB_ERROR_INVALID_PARAMETER =                    1,
-       PB_ERROR_LOCAL_ERROR =                                  2,
-       PB_ERROR_UNSUPPORTED_MANDATORY_MSG =    3,
-       PB_ERROR_VERSION_NOT_SUPPORTED =                4
-};
-
-/**
- * enum name for pb_tnc_error_code_t.
- */
-extern enum_name_t *pb_tnc_error_code_names;
-
-/**
- * Class representing the PB-Error message type.
- */
-struct pb_error_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get the fatal flag
-        *
-        * @return                              fatal flag
-        */
-       bool (*get_fatal_flag)(pb_error_msg_t *this);
-
-       /**
-        * Get PB Error code Vendor ID
-        *
-        * @return                              PB Error Code Vendor ID
-        */
-       u_int32_t (*get_vendor_id)(pb_error_msg_t *this);
-
-       /**
-        * Get PB Error Code
-        *
-        * @return                              PB Error Code
-        */
-       u_int16_t (*get_error_code)(pb_error_msg_t *this);
-
-       /**
-        * Get the PB Error Offset
-        *
-        * @return                              PB Error Offset
-        */
-       u_int32_t (*get_offset)(pb_error_msg_t *this);
-
-       /**
-        * Get the PB Bad Version
-        *
-        * @return                              PB Bad Version
-        */
-       u_int8_t (*get_bad_version)(pb_error_msg_t *this);
-
-       /**
-        * Set the PB Bad Version
-        *
-        * @param version               PB Bad Version
-        */
-       void (*set_bad_version)(pb_error_msg_t *this, u_int8_t version);
-};
-
-/**
- * Create a PB-Error message from parameters
- *
- * @param fatal                                fatal flag
- * @param vendor_id                    Error Code Vendor ID
- * @param error_code           Error Code
- */
-pb_tnc_msg_t* pb_error_msg_create(bool fatal, u_int32_t vendor_id,
-                                                                 pb_tnc_error_code_t error_code);
-       
-/**
- * Create a PB-Error message from parameters with offset field
- *
- * @param fatal                                fatal flag
- * @param vendor_id                    Error Code Vendor ID
- * @param error_code           Error Code
- * @param error_offset         Error Offset
- */
-pb_tnc_msg_t* pb_error_msg_create_with_offset(bool fatal, u_int32_t vendor_id,
-                                                                                         pb_tnc_error_code_t error_code,
-                                                                                         u_int32_t error_offset);
-
-/**
- * Create an unprocessed PB-Error message from raw data
- *
- * @param data                         PB-Error message data
- */
-pb_tnc_msg_t* pb_error_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_experimental_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_experimental_msg.c
deleted file mode 100644 (file)
index 7dfba13..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2010 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 "pb_experimental_msg.h"
-
-typedef struct private_pb_experimental_msg_t private_pb_experimental_msg_t;
-
-/**
- * Private data of a pb_experimental_msg_t object.
- *
- */
-struct private_pb_experimental_msg_t {
-       /**
-        * Public pb_experimental_msg_t interface.
-        */
-       pb_experimental_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_experimental_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_experimental_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_experimental_msg_t *this)
-{
-       /* nothing to do since message contents equal encoding */
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_experimental_msg_t *this, u_int32_t *offset)
-{
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_experimental_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this);
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_experimental_msg_create_from_data(chunk_t data)
-{
-       private_pb_experimental_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-               },
-               .type = PB_MSG_EXPERIMENTAL,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_experimental_msg_create(chunk_t body)
-{
-       return pb_experimental_msg_create_from_data(body);
-}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_experimental_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_experimental_msg.h
deleted file mode 100644 (file)
index b1cc4f4..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 pb_experimental_msg pb_experimental_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_EXPERIMENTAL_MSG_H_
-#define PB_EXPERIMENTAL_MSG_H_
-
-typedef struct pb_experimental_msg_t pb_experimental_msg_t;
-
-#include "pb_tnc_msg.h"
-
-/**
- * Class representing the PB-Experimental message type.
- */
-struct pb_experimental_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-};
-
-/**
- * Create a PB-Experimental message from parameters
- *
- * @param body                 message body
- */
-pb_tnc_msg_t* pb_experimental_msg_create(chunk_t body);
-
-/**
- * Create an unprocessed PB-Experimental message from raw data
- *
- * @param data                 PB-Experimental message data
- */
-pb_tnc_msg_t* pb_experimental_msg_create_from_data(chunk_t data);
-
-#endif /** PB_EXPERIMENTAL_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_language_preference_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_language_preference_msg.c
deleted file mode 100644 (file)
index 70a03cd..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 "pb_language_preference_msg.h"
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_pb_language_preference_msg_t private_pb_language_preference_msg_t;
-
-/**
- *   PB-Language-Preference message (see section 4.10 of RFC 5793)
- *
- *      0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |              Language Preference (Variable Length)            |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PB_LANG_PREFIX                 "Accept-Language: "
-#define PB_LANG_PREFIX_LEN             strlen(PB_LANG_PREFIX)
-
-/**
- * Private data of a pb_language_preference_msg_t object.
- *
- */
-struct private_pb_language_preference_msg_t {
-       /**
-        * Public pb_access_recommendation_msg_t interface.
-        */
-       pb_language_preference_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Language preference
-        */
-       chunk_t language_preference;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_language_preference_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_language_preference_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_language_preference_msg_t *this)
-{
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-       this->encoding = chunk_cat("cc",
-                                               chunk_create(PB_LANG_PREFIX, PB_LANG_PREFIX_LEN),
-                                               this->language_preference);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_language_preference_msg_t *this, u_int32_t *offset)
-{
-       chunk_t lang;
-
-       if (this->encoding.len >= PB_LANG_PREFIX_LEN &&
-               memeq(this->encoding.ptr, PB_LANG_PREFIX, PB_LANG_PREFIX_LEN))
-       {
-               lang = chunk_skip(this->encoding, PB_LANG_PREFIX_LEN);
-               this->language_preference = lang.len ? chunk_clone(lang) : chunk_empty;
-       }
-       else
-    {
-               DBG1(DBG_TNC, "language preference must be preceded by '%s'",
-                                          PB_LANG_PREFIX);
-               *offset = 0;
-               return FAILED;
-       }
-
-       if (this->language_preference.len &&
-               this->language_preference.ptr[this->language_preference.len-1] == '\0')
-       {
-               DBG1(DBG_TNC, "language preference must not be null terminated");
-               *offset = PB_LANG_PREFIX_LEN + this->language_preference.len - 1;
-               return FAILED;
-       }
-
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_language_preference_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this->language_preference.ptr);
-       free(this);
-}
-
-METHOD(pb_language_preference_msg_t, get_language_preference, chunk_t,
-       private_pb_language_preference_msg_t *this)
-{
-       return this->language_preference;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_language_preference_msg_create_from_data(chunk_t data)
-{
-       private_pb_language_preference_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_language_preference = _get_language_preference,
-               },
-               .type = PB_MSG_LANGUAGE_PREFERENCE,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_language_preference_msg_create(chunk_t language_preference)
-{
-       private_pb_language_preference_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_language_preference = _get_language_preference,
-               },
-               .type = PB_MSG_LANGUAGE_PREFERENCE,
-               .language_preference = chunk_clone(language_preference),
-       );
-
-       return &this->public.pb_interface;
-}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_language_preference_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_language_preference_msg.h
deleted file mode 100644 (file)
index 17106f6..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 pb_language_preference_msg pb_language_preference_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_LANGUAGE_PREFERENCE_MSG_H_
-#define PB_LANGUAGE_PREFERENCE_MSG_H_
-
-typedef struct pb_language_preference_msg_t pb_language_preference_msg_t;
-
-#include "pb_tnc_msg.h"
-
-/**
- * Class representing the PB-Language-Preference message type.
- */
-struct pb_language_preference_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get PB Language Preference
-        *
-        * @return                      Language preference
-        */
-       chunk_t (*get_language_preference)(pb_language_preference_msg_t *this);
-};
-
-/**
- * Create a PB-Language-Preference message from parameters
- *
- * @param language_preference          Preferred language(s)
- */
-pb_tnc_msg_t* pb_language_preference_msg_create(chunk_t language_preference);
-
-/**
- * Create an unprocessed PB-Language-Preference message from raw data
- *
-  * @param data                PB-Language-Preference message data
- */
-pb_tnc_msg_t* pb_language_preference_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_pa_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_pa_msg.c
deleted file mode 100644 (file)
index aa5e9c7..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyanbuu
- * Copyright (C) 2010 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 "pb_pa_msg.h"
-
-#include <tnc/tnccs/tnccs.h>
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <pen/pen.h>
-#include <utils/debug.h>
-
-typedef struct private_pb_pa_msg_t private_pb_pa_msg_t;
-
-/**
- *   PB-PA message
- *
- *      0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |    Flags      |               PA Message Vendor ID            |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                           PA Subtype                          |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |  Posture Collector Identifier | Posture Validator Identifier  |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                 PA Message Body (Variable Length)             |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-#define PA_FLAG_NONE                   0x00
-#define PA_FLAG_EXCL                   (1<<7)
-#define PA_RESERVED_SUBTYPE            0xffffffff
-
-
-/**
- * Private data of a pb_pa_msg_t object.
- *
- */
-struct private_pb_pa_msg_t {
-       /**
-        * Public pb_pa_msg_t interface.
-        */
-       pb_pa_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Exclusive flag
-        */
-       bool excl;
-
-       /**
-        * Vendor-specific PA Subtype
-        */
-       pen_type_t subtype;
-
-       /**
-        * Posture Validator Identifier
-        */
-       u_int16_t collector_id;
-
-       /**
-        * Posture Validator Identifier
-        */
-       u_int16_t validator_id;
-
-       /**
-        * PA Message Body
-        */
-       chunk_t msg_body;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_pa_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_pa_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_pa_msg_t *this)
-{
-       chunk_t msg_header;
-       bio_writer_t *writer;
-
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-
-       /* build message header */
-       writer = bio_writer_create(64);
-       writer->write_uint8 (writer, this->excl ? PA_FLAG_EXCL : PA_FLAG_NONE);
-       writer->write_uint24(writer, this->subtype.vendor_id);
-       writer->write_uint32(writer, this->subtype.type);
-       writer->write_uint16(writer, this->collector_id);
-       writer->write_uint16(writer, this->validator_id);
-       msg_header = writer->get_buf(writer);
-
-       /* create encoding by concatenating message header and message body */
-       this->encoding = chunk_cat("cc", msg_header, this->msg_body);
-       writer->destroy(writer);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_pa_msg_t *this, u_int32_t *offset)
-{
-       u_int8_t flags;
-       size_t msg_body_len;
-       bio_reader_t *reader;
-
-       /* process message header */
-       reader = bio_reader_create(this->encoding);
-       reader->read_uint8 (reader, &flags);
-       reader->read_uint24(reader, &this->subtype.vendor_id);
-       reader->read_uint32(reader, &this->subtype.type);
-       reader->read_uint16(reader, &this->collector_id);
-       reader->read_uint16(reader, &this->validator_id);
-       this->excl = ((flags & PA_FLAG_EXCL) != PA_FLAG_NONE);
-
-       /* process message body */
-       msg_body_len = reader->remaining(reader);
-       if (msg_body_len)
-       {
-               reader->read_data(reader, msg_body_len, &this->msg_body);
-               this->msg_body = chunk_clone(this->msg_body);
-       }
-       reader->destroy(reader);
-
-       if (this->subtype.vendor_id == PEN_RESERVED)
-       {
-               DBG1(DBG_TNC, "Vendor ID 0x%06x is reserved", PEN_RESERVED);
-               *offset = 1;
-               return FAILED;
-       }
-
-       if (this->subtype.type == PA_RESERVED_SUBTYPE)
-       {
-               DBG1(DBG_TNC, "PA Subtype 0x%08x is reserved", PA_RESERVED_SUBTYPE);
-               *offset = 4;
-               return FAILED;
-       }
-
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_pa_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this->msg_body.ptr);
-       free(this);
-}
-
-METHOD(pb_pa_msg_t, get_subtype, pen_type_t,
-       private_pb_pa_msg_t *this)
-{
-       return this->subtype;
-}
-
-METHOD(pb_pa_msg_t, get_collector_id, u_int16_t,
-       private_pb_pa_msg_t *this)
-{
-       return this->collector_id;
-}
-
-METHOD(pb_pa_msg_t, get_validator_id, u_int16_t,
-       private_pb_pa_msg_t *this)
-{
-       return this->validator_id;
-}
-
-METHOD(pb_pa_msg_t, get_body, chunk_t,
-       private_pb_pa_msg_t *this)
-{
-       return this->msg_body;
-}
-
-METHOD(pb_pa_msg_t, get_exclusive_flag, bool,
-       private_pb_pa_msg_t *this)
-{
-       return this->excl;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_pa_msg_create_from_data(chunk_t data)
-{
-       private_pb_pa_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_subtype = _get_subtype,
-                       .get_collector_id = _get_collector_id,
-                       .get_validator_id = _get_validator_id,
-                       .get_body = _get_body,
-                       .get_exclusive_flag = _get_exclusive_flag,
-               },
-               .type = PB_MSG_PA,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-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,
-                                                          bool excl, chunk_t msg_body)
-{
-       private_pb_pa_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_subtype= _get_subtype,
-                       .get_collector_id = _get_collector_id,
-                       .get_validator_id = _get_validator_id,
-                       .get_body = _get_body,
-                       .get_exclusive_flag = _get_exclusive_flag,
-               },
-               .type = PB_MSG_PA,
-               .subtype = { vendor_id, subtype },
-               .collector_id = collector_id,
-               .validator_id = validator_id,
-               .excl = excl,
-               .msg_body = chunk_clone(msg_body),
-       );
-
-       return &this->public.pb_interface;
-}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_pa_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_pa_msg.h
deleted file mode 100644 (file)
index 5c9b7c0..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2010 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 pb_pa_msg pb_pa_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_PA_MSG_H_
-#define PB_PA_MSG_H_
-
-typedef struct pb_pa_msg_t pb_pa_msg_t;
-
-#include "pb_tnc_msg.h"
-
-#include <pen/pen.h>
-
-/**
- * Class representing the PB-PA message type.
- */
-struct pb_pa_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get PA Message Vendor ID and Subtype
-        *
-        * @return                              Vendor-specific PA Subtype
-        */
-       pen_type_t (*get_subtype)(pb_pa_msg_t *this);
-
-       /**
-        * Get Posture Collector ID
-        *
-        * @return                              Posture Collector ID
-        */
-       u_int16_t (*get_collector_id)(pb_pa_msg_t *this);
-
-       /**
-        * Get Posture Validator ID
-        *
-        * @return                              Posture Validator ID
-        */
-       u_int16_t (*get_validator_id)(pb_pa_msg_t *this);
-
-       /**
-        * Get the PA Message Body
-        *
-        * @return                              PA Message Body
-        */
-       chunk_t (*get_body)(pb_pa_msg_t *this);
-
-       /**
-        * Get the exclusive flag
-        *
-        * @return                              exclusive flag
-        */
-       bool (*get_exclusive_flag)(pb_pa_msg_t *this);
-
-};
-
-/**
- * Create a PB-PA message from parameters
- *
- * @param vendor_id                    PA Message Vendor ID
- * @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,
-                                                          bool excl, chunk_t msg_body);
-
-/**
- * Create an unprocessed PB-PA message from raw data
- *
-  * @param data                PB-PA message data
- */
-pb_tnc_msg_t* pb_pa_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_reason_string_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_reason_string_msg.c
deleted file mode 100644 (file)
index 935c52d..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 "pb_reason_string_msg.h"
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-typedef struct private_pb_reason_string_msg_t private_pb_reason_string_msg_t;
-
-/**
- *   PB-Language-Preference message (see section 4.11 of RFC 5793)
- *
- *      0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                      Reason String Length                     |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                Reason String (Variable Length)                |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     | Lang Code Len | Reason String Language Code (Variable Length) |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/**
- * Private data of a pb_reason_string_msg_t object.
- *
- */
-struct private_pb_reason_string_msg_t {
-       /**
-        * Public pb_reason_string_msg_t interface.
-        */
-       pb_reason_string_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Reason string
-        */
-       chunk_t reason_string;
-
-       /**
-        * Language code
-        */
-       chunk_t language_code;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_reason_string_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_reason_string_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_reason_string_msg_t *this)
-{
-       bio_writer_t *writer;
-
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-       writer = bio_writer_create(64);
-       writer->write_data32(writer, this->reason_string);
-       writer->write_data8 (writer, this->language_code);
-
-       this->encoding = writer->get_buf(writer);
-       this->encoding = chunk_clone(this->encoding);
-       writer->destroy(writer);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_reason_string_msg_t *this, u_int32_t *offset)
-{
-       bio_reader_t *reader;
-
-       reader = bio_reader_create(this->encoding);
-       if (!reader->read_data32(reader, &this->reason_string))
-       {
-               DBG1(DBG_TNC, "could not parse reason string");
-               reader->destroy(reader);
-               *offset = 0;
-               return FAILED;
-       };
-       this->reason_string = chunk_clone(this->reason_string);
-
-       if (this->reason_string.len &&
-               this->reason_string.ptr[this->reason_string.len-1] == '\0')
-       {
-               DBG1(DBG_TNC, "reason string must not be null terminated");
-               reader->destroy(reader);
-               *offset = 3 + this->reason_string.len;
-               return FAILED;
-       }
-
-       if (!reader->read_data8(reader, &this->language_code))
-       {
-               DBG1(DBG_TNC, "could not parse language code");
-               reader->destroy(reader);
-               *offset = 4 + this->reason_string.len;
-               return FAILED;
-       };
-       this->language_code = chunk_clone(this->language_code);
-       reader->destroy(reader);
-
-       if (this->language_code.len &&
-               this->language_code.ptr[this->language_code.len-1] == '\0')
-       {
-               DBG1(DBG_TNC, "language code must not be null terminated");
-               *offset = 4 + this->reason_string.len + this->language_code.len;
-               return FAILED;
-       }
-
-       return SUCCESS;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_reason_string_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this->reason_string.ptr);
-       free(this->language_code.ptr);
-       free(this);
-}
-
-METHOD(pb_reason_string_msg_t, get_reason_string, chunk_t,
-       private_pb_reason_string_msg_t *this)
-{
-       return this->reason_string;
-}
-
-METHOD(pb_reason_string_msg_t, get_language_code, chunk_t,
-       private_pb_reason_string_msg_t *this)
-{
-       return this->language_code;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_reason_string_msg_create_from_data(chunk_t data)
-{
-       private_pb_reason_string_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_reason_string = _get_reason_string,
-                       .get_language_code = _get_language_code,
-               },
-               .type = PB_MSG_REASON_STRING,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_reason_string_msg_create(chunk_t reason_string,
-                                                                                 chunk_t language_code)
-{
-       private_pb_reason_string_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_reason_string = _get_reason_string,
-                       .get_language_code = _get_language_code,
-               },
-               .type = PB_MSG_REASON_STRING,
-               .reason_string = chunk_clone(reason_string),
-               .language_code = chunk_clone(language_code),
-       );
-
-       return &this->public.pb_interface;
-}
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_reason_string_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_reason_string_msg.h
deleted file mode 100644 (file)
index bb296a9..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 Sansar Choinyambuu
- * 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 pb_reason_string_msg pb_reason_string_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_REASON_STRING_MSG_H_
-#define PB_REASON_STRING_MSG_H_
-
-typedef struct pb_reason_string_msg_t pb_reason_string_msg_t;
-
-#include "pb_tnc_msg.h"
-
-/**
- * Class representing the PB-Reason-String message type.
- */
-struct pb_reason_string_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get Reason String
-        *
-        * @return                      Reason string
-        */
-       chunk_t (*get_reason_string)(pb_reason_string_msg_t *this);
-
-       /**
-        * Get Reason String Language Code
-        *
-        * @return                      Language code
-        */
-       chunk_t (*get_language_code)(pb_reason_string_msg_t *this);
-};
-
-/**
- * Create a PB-Reason-String message from parameters
- *
- * @param reason_string                Reason string
-  * @param language_code       Language code
- */
-pb_tnc_msg_t* pb_reason_string_msg_create(chunk_t reason_string,
-                                                                                 chunk_t language_code);
-
-/**
- * Create an unprocessed PB-Reason-String message from raw data
- *
-  * @param data                PB-Reason-String message data
- */
-pb_tnc_msg_t* pb_reason_string_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c b/src/libtnccs/plugins/tnccs_20/messages/pb_remediation_parameters_msg.c
deleted file mode 100644 (file)
index 2ef8dd6..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (C) 2010 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 "pb_remediation_parameters_msg.h"
-
-#include <bio/bio_writer.h>
-#include <bio/bio_reader.h>
-#include <utils/debug.h>
-
-ENUM(pb_tnc_remed_param_type_names, PB_REMEDIATION_URI, PB_REMEDIATION_STRING,
-       "Remediation-URI",
-       "Remediation-String"
-);
-
-typedef struct private_pb_remediation_parameters_msg_t private_pb_remediation_parameters_msg_t;
-
-/**
- *   PB-Remediation-Parameters message (see section 4.8 of RFC 5793)
- *
- *      0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |    Reserved   |       Remediation Parameters Vendor ID        |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                  Remediation Parameters Type                  |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |            Remediation Parameters (Variable Length)           |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- *     0                   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
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                   Remediation String Length                   |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     |                Remediation String (Variable Length)           |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *     | Lang Code Len |  Remediation String Lang Code (Variable Len)  |
- *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-/**
- * Private data of a pb_remediation_parameters_msg_t object.
- *
- */
-struct private_pb_remediation_parameters_msg_t {
-       /**
-        * Public pb_remediation_parameters_msg_t interface.
-        */
-       pb_remediation_parameters_msg_t public;
-
-       /**
-        * PB-TNC message type
-        */
-       pb_tnc_msg_type_t type;
-
-       /**
-        * Remediation Parameters Type
-        */
-       pen_type_t parameters_type;
-
-       /**
-        * Remediation Parameters
-        */
-       chunk_t parameters;
-
-       /**
-        * Remediation String
-        */
-       chunk_t string;
-
-       /**
-        * Remediation Language Code
-        */
-       chunk_t lang_code;
-
-       /**
-        * Encoded message
-        */
-       chunk_t encoding;
-};
-
-METHOD(pb_tnc_msg_t, get_type, pb_tnc_msg_type_t,
-       private_pb_remediation_parameters_msg_t *this)
-{
-       return this->type;
-}
-
-METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
-       private_pb_remediation_parameters_msg_t *this)
-{
-       return this->encoding;
-}
-
-METHOD(pb_tnc_msg_t, build, void,
-       private_pb_remediation_parameters_msg_t *this)
-{
-       bio_writer_t *writer;
-
-       if (this->encoding.ptr)
-       {
-               return;
-       }
-       writer = bio_writer_create(64);
-       writer->write_uint32(writer, this->parameters_type.vendor_id);
-       writer->write_uint32(writer, this->parameters_type.type);
-       writer->write_data32(writer, this->parameters);
-
-       this->encoding = writer->get_buf(writer);
-       this->encoding = chunk_clone(this->encoding);
-       writer->destroy(writer);
-}
-
-METHOD(pb_tnc_msg_t, process, status_t,
-       private_pb_remediation_parameters_msg_t *this, u_int32_t *offset)
-{
-       bio_reader_t *reader;
-       u_int8_t reserved;
-       status_t status = SUCCESS;
-       u_char *pos;
-
-       *offset = 0;
-
-       /* process message */
-       reader = bio_reader_create(this->encoding);
-       reader->read_uint8 (reader, &reserved);
-       reader->read_uint24(reader, &this->parameters_type.vendor_id);
-       reader->read_uint32(reader, &this->parameters_type.type);
-       reader->read_data  (reader, reader->remaining(reader), &this->parameters);
-
-       this->parameters = chunk_clone(this->parameters);
-       reader->destroy(reader);
-
-       if (this->parameters_type.vendor_id == PEN_IETF &&
-               this->parameters_type.type == PB_REMEDIATION_STRING)
-       {
-               reader = bio_reader_create(this->parameters);
-               status = FAILED;
-               *offset = 8;
-
-               if (!reader->read_data32(reader, &this->string))
-               {
-                       DBG1(DBG_TNC, "insufficient data for remediation string");
-                       goto end;
-               };
-               *offset += 4;
-
-               pos = memchr(this->string.ptr, '\0', this->string.len);
-               if (pos)
-               {
-                       DBG1(DBG_TNC, "nul termination in remediation string");
-                       *offset += (pos - this->string.ptr);
-                       goto end;
-               }
-               *offset += this->string.len;
-
-               if (!reader->read_data8(reader, &this->lang_code))
-               {
-                       DBG1(DBG_TNC, "insufficient data for remediation string lang code");
-                       goto end;
-               };
-               *offset += 1;
-
-               pos = memchr(this->lang_code.ptr, '\0', this->lang_code.len);
-
-               if (pos)
-               {
-                       DBG1(DBG_TNC, "nul termination in remediation string lang code");
-                       *offset += (pos - this->lang_code.ptr);
-                       goto end;
-               }
-               status = SUCCESS;
-
-end:
-               reader->destroy(reader);
-       }
-       return status;
-}
-
-METHOD(pb_tnc_msg_t, destroy, void,
-       private_pb_remediation_parameters_msg_t *this)
-{
-       free(this->encoding.ptr);
-       free(this->parameters.ptr);
-       free(this);
-}
-
-METHOD(pb_remediation_parameters_msg_t, get_parameters_type, pen_type_t,
-       private_pb_remediation_parameters_msg_t *this)
-{
-       return this->parameters_type;
-}
-
-METHOD(pb_remediation_parameters_msg_t, get_parameters, chunk_t,
-       private_pb_remediation_parameters_msg_t *this)
-{
-       return this->parameters;
-}
-
-METHOD(pb_remediation_parameters_msg_t, get_string, chunk_t,
-       private_pb_remediation_parameters_msg_t *this, chunk_t *lang_code)
-{
-       if (lang_code)
-       {
-               *lang_code = this->lang_code;
-       }
-       return this->string;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create(pen_type_t parameters_type,
-                                                                                                  chunk_t parameters)
-{
-       private_pb_remediation_parameters_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_parameters_type = _get_parameters_type,
-                       .get_parameters = _get_parameters,
-                       .get_uri = _get_parameters,
-                       .get_string = _get_string,
-               },
-               .type = PB_MSG_REMEDIATION_PARAMETERS,
-               .parameters_type = parameters_type,
-               .parameters = chunk_clone(parameters),
-       );
-
-       return &this->public.pb_interface;
-}
-
-/**
- * Described in header.
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_uri(chunk_t uri)
-{
-       pen_type_t type = { PEN_IETF, PB_REMEDIATION_URI };
-
-       return pb_remediation_parameters_msg_create(type, uri);
-}
-
-/**
- * Described in header.
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_string(chunk_t string,
-                                                                                                                          chunk_t lang_code)
-{
-       pb_tnc_msg_t *msg;
-       bio_writer_t *writer;
-       pen_type_t type = { PEN_IETF, PB_REMEDIATION_STRING };
-
-       /* limit language code to 255 octets */
-       lang_code.len = min(255, lang_code.len);
-
-       writer = bio_writer_create(4 + string.len + 1 + lang_code.len);
-       writer->write_data32(writer, string);
-       writer->write_data8 (writer, lang_code);
-
-       msg = pb_remediation_parameters_msg_create(type, writer->get_buf(writer));
-       writer->destroy(writer);
-
-       return msg;
-}
-
-/**
- * See header
- */
-pb_tnc_msg_t *pb_remediation_parameters_msg_create_from_data(chunk_t data)
-{
-       private_pb_remediation_parameters_msg_t *this;
-
-       INIT(this,
-               .public = {
-                       .pb_interface = {
-                               .get_type = _get_type,
-                               .get_encoding = _get_encoding,
-                               .build = _build,
-                               .process = _process,
-                               .destroy = _destroy,
-                       },
-                       .get_parameters_type = _get_parameters_type,
-                       .get_parameters = _get_parameters,
-                       .get_uri = _get_parameters,
-                       .get_string = _get_string,
-               },
-               .type = PB_MSG_REMEDIATION_PARAMETERS,
-               .encoding = chunk_clone(data),
-       );
-
-       return &this->public.pb_interface;
-}
-
diff --git a/src/libtnccs/plugins/tnccs_20/messages/pb_remediation_parameters_msg.h b/src/libtnccs/plugins/tnccs_20/messages/pb_remediation_parameters_msg.h
deleted file mode 100644 (file)
index f3a1c10..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2011-2013 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 pb_remediation_parameters_msg pb_remediation_parameters_msg
- * @{ @ingroup tnccs_20
- */
-
-#ifndef PB_REMEDIATION_PARAMETERS_MSG_H_
-#define PB_REMEDIATION_PARAMETERS_MSG_H_
-
-typedef enum pb_tnc_remed_param_type_t pb_tnc_remed_param_type_t;
-typedef struct pb_remediation_parameters_msg_t pb_remediation_parameters_msg_t;
-
-#include "pb_tnc_msg.h"
-
-#include <pen/pen.h>
-
-/**
- * PB-TNC Remediation Parameter Types as defined in section 4.8.1 of RFC 5793
- */
-enum pb_tnc_remed_param_type_t {
-       PB_REMEDIATION_URI =                    1,
-       PB_REMEDIATION_STRING =                 2,
-};
-
-/**
- * enum name for pb_tnc_remed_param_type_t.
- */
-extern enum_name_t *pb_tnc_remed_param_type_names;
-
-/**
- * Class representing the PB-Remediation-Parameters message type.
- */
-struct pb_remediation_parameters_msg_t {
-
-       /**
-        * PB-TNC Message interface
-        */
-       pb_tnc_msg_t pb_interface;
-
-       /**
-        * Get the Remediation Parameters Type (Vendor ID and Type)
-        *
-        * @return                              Remediation Parameters Type
-        */
-       pen_type_t (*get_parameters_type)(pb_remediation_parameters_msg_t *this);
-
-       /**
-        * Get the Remediation Parameters
-        *
-        * @return                              Remediation Parameters
-        */
-       chunk_t (*get_parameters)(pb_remediation_parameters_msg_t *this);
-
-       /**
-        * Get the Remediation URI
-        *
-        * @return                              Remediation URI
-        */
-       chunk_t (*get_uri)(pb_remediation_parameters_msg_t *this);
-
-       /**
-        * Get the Remediation String
-        *
-        * @param lang_code             Optional Language Code
-        * @return                              Remediation String
-        */
-       chunk_t (*get_string)(pb_remediation_parameters_msg_t *this,
-                                                 chunk_t *lang_code);
-
-};
-
-/**
- * Create a general PB-Remediation-Parameters message
- *
- * @param parameters_type      Remediation Parameters Type
- * @param parameters           Remediation Parameters
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create(pen_type_t parameters_type,
-                                                                                                  chunk_t parameters);
-
-/**
- * Create a PB-Remediation-Parameters message of IETF Type Remediation URI
- *
- * @param uri                          Remediation URI
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_uri(chunk_t uri);
-
-/**
- * Create a PB-Remediation-Parameters message of IETF Type Remediation String
- *
- * @param string                       Remediation String
- * @param lang_code                    Remediation String Language Code
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_string(chunk_t string,
-                                                                                                                          chunk_t lang_code);
-
-/**
- * Create an unprocessed PB-Remediation-Parameters message from raw data
- *
-  * @param data                PB-Remediation-Parameters message data
- */
-pb_tnc_msg_t* pb_remediation_parameters_msg_create_from_data(chunk_t data);
-
-#endif /** PB_PA_MSG_H_ @}*/
index 3565c2d..be81ee1 100644 (file)
  */
 
 #include "pb_tnc_msg.h"
-#include "pb_experimental_msg.h"
-#include "pb_pa_msg.h"
-#include "pb_error_msg.h"
-#include "pb_language_preference_msg.h"
-#include "pb_assessment_result_msg.h"
-#include "pb_access_recommendation_msg.h"
-#include "pb_remediation_parameters_msg.h"
-#include "pb_reason_string_msg.h"
+#include "ietf/pb_experimental_msg.h"
+#include "ietf/pb_pa_msg.h"
+#include "ietf/pb_error_msg.h"
+#include "ietf/pb_language_preference_msg.h"
+#include "ietf/pb_assessment_result_msg.h"
+#include "ietf/pb_access_recommendation_msg.h"
+#include "ietf/pb_remediation_parameters_msg.h"
+#include "ietf/pb_reason_string_msg.h"
+#include "tcg/pb_pdp_referral_msg.h"
 
 #include <library.h>
 
@@ -36,6 +37,10 @@ ENUM(pb_tnc_msg_type_names, PB_MSG_EXPERIMENTAL, PB_MSG_REASON_STRING,
        "PB-Reason-String"
 );
 
+ENUM(pb_tnc_tcg_msg_type_names, PB_TCG_MSG_PDP_REFERRAL, PB_TCG_MSG_PDP_REFERRAL,
+       "PB-PDP-Referral"
+);
+
 pb_tnc_msg_info_t pb_tnc_msg_infos[] = {
        { 12, FALSE, FALSE, TRUE_OR_FALSE },
        { 24, FALSE, FALSE, TRUE  },
@@ -47,29 +52,43 @@ pb_tnc_msg_info_t pb_tnc_msg_infos[] = {
        { 17, FALSE, TRUE,  FALSE },
 };
 
+pb_tnc_msg_info_t pb_tnc_tcg_msg_infos[] = {
+       { 20, FALSE, TRUE, FALSE },
+};
+
 /**
  * See header
  */
-pb_tnc_msg_t* pb_tnc_msg_create_from_data(pb_tnc_msg_type_t type, chunk_t value)
+pb_tnc_msg_t* pb_tnc_msg_create_from_data(pen_type_t msg_type, chunk_t value)
 {
-       switch (type)
+       if (msg_type.vendor_id == PEN_IETF)
+       {
+               switch (msg_type.type)
+               {
+                       case PB_MSG_PA:
+                               return pb_pa_msg_create_from_data(value);
+                       case PB_MSG_ERROR:
+                               return pb_error_msg_create_from_data(value);
+                       case PB_MSG_EXPERIMENTAL:
+                               return pb_experimental_msg_create_from_data(value);
+                       case PB_MSG_LANGUAGE_PREFERENCE:
+                               return pb_language_preference_msg_create_from_data(value);
+                       case PB_MSG_ASSESSMENT_RESULT:
+                               return pb_assessment_result_msg_create_from_data(value);
+                       case PB_MSG_ACCESS_RECOMMENDATION:
+                               return pb_access_recommendation_msg_create_from_data(value);
+                       case PB_MSG_REMEDIATION_PARAMETERS:
+                               return pb_remediation_parameters_msg_create_from_data(value);
+                       case PB_MSG_REASON_STRING:
+                               return pb_reason_string_msg_create_from_data(value);
+               }
+       }
+       else if (msg_type.vendor_id == PEN_TCG)
        {
-               case PB_MSG_PA:
-                       return pb_pa_msg_create_from_data(value);
-               case PB_MSG_ERROR:
-                       return pb_error_msg_create_from_data(value);
-               case PB_MSG_EXPERIMENTAL:
-                       return pb_experimental_msg_create_from_data(value);
-               case PB_MSG_LANGUAGE_PREFERENCE:
-                       return pb_language_preference_msg_create_from_data(value);
-               case PB_MSG_ASSESSMENT_RESULT:
-                       return pb_assessment_result_msg_create_from_data(value);
-               case PB_MSG_ACCESS_RECOMMENDATION:
-                       return pb_access_recommendation_msg_create_from_data(value);
-               case PB_MSG_REMEDIATION_PARAMETERS:
-                       return pb_remediation_parameters_msg_create_from_data(value);
-               case PB_MSG_REASON_STRING:
-                       return pb_reason_string_msg_create_from_data(value);
+               if (msg_type.type == PB_TCG_MSG_PDP_REFERRAL)
+               {
+                       return pb_pdp_referral_msg_create_from_data(value);
+               }
        }
        return NULL;
 }
index 97ebed2..ace5d78 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Andreas Steffen
+ * Copyright (C) 2010-213 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@ typedef struct pb_tnc_msg_info_t pb_tnc_msg_info_t;
 typedef struct pb_tnc_msg_t pb_tnc_msg_t;
 
 #include <library.h>
+#include <pen/pen.h>
 
 #define PB_TNC_VERSION         2
 
@@ -50,6 +51,19 @@ enum pb_tnc_msg_type_t {
 extern enum_name_t *pb_tnc_msg_type_names;
 
 /**
+ * PB-TNC Message Type defined in the TCG namespace
+ */
+enum pb_tnc_tcg_msg_type_t {
+       PB_TCG_MSG_PDP_REFERRAL =                       1,
+       PB_TCG_MSG_ROOF =                                       1
+};
+
+/**
+ * enum name for pb_tnc_tcg_msg_type_t.
+ */
+extern enum_name_t *pb_tnc_tcg_msg_type_names;
+
+/**
  * Information entry describing a PB-TNC Message Type
  */
 struct pb_tnc_msg_info_t {
@@ -67,6 +81,11 @@ struct pb_tnc_msg_info_t {
 extern pb_tnc_msg_info_t pb_tnc_msg_infos[];
 
 /**
+ * Information on PB-TNC TCG Message Types
+ */
+extern pb_tnc_msg_info_t pb_tnc_tcg_msg_infos[];
+
+/**
  * Generic interface for all PB-TNC message types.
  *
  * To handle all messages in a generic way, this interface
@@ -79,7 +98,7 @@ struct pb_tnc_msg_t {
         *
         * @return                                       PB-TNC Message Type
         */
-       pb_tnc_msg_type_t (*get_type)(pb_tnc_msg_t *this);
+       pen_type_t (*get_type)(pb_tnc_msg_t *this);
 
        /**
         * Get the encoding of the PB-TNC Message Value
@@ -120,9 +139,10 @@ struct pb_tnc_msg_t {
  * Useful for the parser which wants a generic constructor for all
  * pb_tnc_message_t types.
  *
- * @param type         PB-TNC message type
- * @param value                PB-TNC message value
+ * @param vendor_id                    PB-TNC vendor ID
+ * @param type                         PB-TNC message type
+ * @param value                                PB-TNC message value
  */
-pb_tnc_msg_t* pb_tnc_msg_create_from_data(pb_tnc_msg_type_t type, chunk_t value);
+pb_tnc_msg_t* pb_tnc_msg_create_from_data(pen_type_t msg_type, chunk_t value);
 
 #endif /** PB_TNC_MSG_H_ @}*/
diff --git a/src/libtnccs/plugins/tnccs_20/messages/tcg/pb_pdp_referral_msg.c b/src/libtnccs/plugins/tnccs_20/messages/tcg/pb_pdp_referral_msg.c
new file mode 100644 (file)
index 0000000..f8c78b6
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2013 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 "pb_pdp_referral_msg.h"
+
+#include <bio/bio_writer.h>
+#include <bio/bio_reader.h>
+#include <utils/debug.h>
+
+ENUM(pb_tnc_pdp_identifier_type_names, PB_PDP_ID_FQDN, PB_PDP_ID_IPV6,
+       "PDP FQDN ID",
+       "PDP IPv4 ID",
+       "PDP IPv6 ID"
+);
+
+typedef struct private_pb_pdp_referral_msg_t private_pb_pdp_referral_msg_t;
+
+/**
+ *   PB-PDP-Referral message (see section 3.1.1.1 of
+ *   TCG TNC PDP Discovery and Validation Specification 1.0
+ *
+ *    0                   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
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |   Reserved    |           PDP Identifier Vendor ID            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                      PDP Identifier Type                      |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                 PDP Identifier (Variable Length)              |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *   Section 3.1.1.2.1 FQDN Identifier
+ *
+ *    0                   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
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |   Reserved    |   Protocol    |        Port Number            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                     FQDN (Variable Length)                    |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *   Section 3.1.1.2.2 IPv4 Identifier
+ *
+ *    0                   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
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |   Reserved    |   Protocol    |        Port Number            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                          IPv4 Address                         |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *   Section 3.1.1.2.3 IPv6 Identifier
+ * 
+ *    0                   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
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |   Reserved    |   Protocol    |        Port Number            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                    IPv6 Address (octets 1-4)                  |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                    IPv6 Address (octets 5-8)                  |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                    IPv6 Address (octets 9-12)                 |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                    IPv6 Address (octets 13-16)                |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+
+/**
+ * Private data of a pb_pdp_referral_msg_t object.
+ *
+ */
+struct private_pb_pdp_referral_msg_t {
+       /**
+        * Public pb_pdp_referral_msg_t interface.
+        */
+       pb_pdp_referral_msg_t public;
+
+       /**
+        * PB-TNC message type
+        */
+       pen_type_t type;
+
+       /**
+        * PDP Identifier Type
+        */
+       pen_type_t identifier_type;
+
+       /**
+        * PDP Identifier Value
+        */
+       chunk_t identifier;
+
+       /**
+        * Encoded message
+        */
+       chunk_t encoding;
+};
+
+METHOD(pb_tnc_msg_t, get_type, pen_type_t,
+       private_pb_pdp_referral_msg_t *this)
+{
+       return this->type;
+}
+
+METHOD(pb_tnc_msg_t, get_encoding, chunk_t,
+       private_pb_pdp_referral_msg_t *this)
+{
+       return this->encoding;
+}
+
+METHOD(pb_tnc_msg_t, build, void,
+       private_pb_pdp_referral_msg_t *this)
+{
+       bio_writer_t *writer;
+
+       if (this->encoding.ptr)
+       {
+               return;
+       }
+       writer = bio_writer_create(64);
+       writer->write_uint32(writer, this->identifier_type.vendor_id);
+       writer->write_uint32(writer, this->identifier_type.type);
+       writer->write_data(writer, this->identifier);
+
+       this->encoding = writer->get_buf(writer);
+       this->encoding = chunk_clone(this->encoding);
+       writer->destroy(writer);
+}
+
+METHOD(pb_tnc_msg_t, process, status_t,
+       private_pb_pdp_referral_msg_t *this, u_int32_t *offset)
+{
+       bio_reader_t *reader;
+       u_int8_t reserved;
+       status_t status = SUCCESS;
+
+       *offset = 0;
+
+       /* process message */
+       reader = bio_reader_create(this->encoding);
+       reader->read_uint8 (reader, &reserved);
+       reader->read_uint24(reader, &this->identifier_type.vendor_id);
+       reader->read_uint32(reader, &this->identifier_type.type);
+       reader->read_data  (reader, reader->remaining(reader), &this->identifier);
+
+       this->identifier = chunk_clone(this->identifier);
+       reader->destroy(reader);
+
+       if (this->identifier_type.vendor_id == PEN_TCG)
+       {
+               /* TODO parse PDP Identifier Types */
+       }
+       return status;
+}
+
+METHOD(pb_tnc_msg_t, destroy, void,
+       private_pb_pdp_referral_msg_t *this)
+{
+       free(this->encoding.ptr);
+       free(this->identifier.ptr);
+       free(this);
+}
+
+METHOD(pb_pdp_referral_msg_t, get_identifier_type, pen_type_t,
+       private_pb_pdp_referral_msg_t *this)
+{
+       return this->identifier_type;
+}
+
+METHOD(pb_pdp_referral_msg_t, get_identifier, chunk_t,
+       private_pb_pdp_referral_msg_t *this)
+{
+       return this->identifier;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t* pb_pdp_referral_msg_create(pen_type_t identifier_type,
+                                                                                chunk_t identifier)
+{
+       private_pb_pdp_referral_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_identifier_type = _get_identifier_type,
+                       .get_identifier = _get_identifier,
+               },
+               .type = { PEN_TCG, PB_TCG_MSG_PDP_REFERRAL },
+               .identifier_type = identifier_type,
+               .identifier = chunk_clone(identifier),
+       );
+
+       return &this->public.pb_interface;
+}
+
+/**
+ * See header
+ */
+pb_tnc_msg_t *pb_pdp_referral_msg_create_from_data(chunk_t data)
+{
+       private_pb_pdp_referral_msg_t *this;
+
+       INIT(this,
+               .public = {
+                       .pb_interface = {
+                               .get_type = _get_type,
+                               .get_encoding = _get_encoding,
+                               .build = _build,
+                               .process = _process,
+                               .destroy = _destroy,
+                       },
+                       .get_identifier_type = _get_identifier_type,
+                       .get_identifier = _get_identifier,
+               },
+               .type = { PEN_TCG, PB_TCG_MSG_PDP_REFERRAL },
+               .encoding = chunk_clone(data),
+       );
+
+       return &this->public.pb_interface;
+}
+
diff --git a/src/libtnccs/plugins/tnccs_20/messages/tcg/pb_pdp_referral_msg.h b/src/libtnccs/plugins/tnccs_20/messages/tcg/pb_pdp_referral_msg.h
new file mode 100644 (file)
index 0000000..a472557
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2013 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 pb_pdp_referral_msg pb_pdp_referral_msg
+ * @{ @ingroup tnccs_20
+ */
+
+#ifndef PB_PDP_REFERRAL_MSG_H_
+#define PB_PDP_REFERRAL_MSG_H_
+
+typedef enum pb_pdp_identifier_type_t pb_pdp_identifier_type_t;
+typedef struct pb_pdp_referral_msg_t pb_pdp_referral_msg_t;
+
+#include "messages/pb_tnc_msg.h"
+
+#include <pen/pen.h>
+
+/**
+ * PB-TNC PDP Identifier Types as defined in section 3.1.1.2 of the
+ * TCG TNC PDP Discovery and Validation Specification 1.0
+ */
+enum pb_pdp_identifier_type_t {
+       PB_PDP_ID_FQDN =        0,
+       PB_PDP_ID_IPV4 =        1,
+       PB_PDP_ID_IPV6 =        2
+};
+
+/**
+ * enum name for pb_pdp_identifier_type_t.
+ */
+extern enum_name_t *pb_pdp_identifier_type_names;
+
+/**
+ * Class representing the PB-Remediation-Parameters message type.
+ */
+struct pb_pdp_referral_msg_t {
+
+       /**
+        * PB-TNC Message interface
+        */
+       pb_tnc_msg_t pb_interface;
+
+       /**
+        * Get the PDP Identifier Type (Vendor ID and Type)
+        *
+        * @return                              PDP Identifier Type
+        */
+       pen_type_t (*get_identifier_type)(pb_pdp_referral_msg_t *this);
+
+       /**
+        * Get the PDP Identifier Value
+        *
+        * @return                              PDP Identifier Value
+        */
+       chunk_t (*get_identifier)(pb_pdp_referral_msg_t *this);
+
+};
+
+/**
+ * Create a general PB-PDP-Referral message
+ *
+ * @param identifier_type      PDP Identifier Type
+ * @param identifier           PDP Identifier
+ */
+pb_tnc_msg_t* pb_pdp_referral_msg_create(pen_type_t identifier_type,
+                                                                                chunk_t identifier);
+
+/**
+ * Create an unprocessed PB-PDP-Referral message from raw data
+ *
+  * @param data                PB-PDP-Referral message data
+ */
+pb_tnc_msg_t* pb_pdp_referral_msg_create_from_data(chunk_t data);
+
+#endif /** PB_PA_MSG_H_ @}*/
index 5d2d7ee..6759c92 100644 (file)
 #include "tnccs_20.h"
 #include "batch/pb_tnc_batch.h"
 #include "messages/pb_tnc_msg.h"
-#include "messages/pb_pa_msg.h"
-#include "messages/pb_error_msg.h"
-#include "messages/pb_assessment_result_msg.h"
-#include "messages/pb_access_recommendation_msg.h"
-#include "messages/pb_remediation_parameters_msg.h"
-#include "messages/pb_reason_string_msg.h"
-#include "messages/pb_language_preference_msg.h"
+#include "messages/ietf/pb_pa_msg.h"
+#include "messages/ietf/pb_error_msg.h"
+#include "messages/ietf/pb_assessment_result_msg.h"
+#include "messages/ietf/pb_access_recommendation_msg.h"
+#include "messages/ietf/pb_remediation_parameters_msg.h"
+#include "messages/ietf/pb_reason_string_msg.h"
+#include "messages/ietf/pb_language_preference_msg.h"
 #include "state_machine/pb_tnc_state_machine.h"
 
 #include <tncif_names.h>
@@ -225,11 +225,13 @@ METHOD(tnccs_t, send_msg, TNC_Result,
 }
 
 /**
- * Handle a single PB-TNC message according to its type
+ * Handle a single PB-TNC IETF standard message according to its type
  */
-static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
+static void handle_ietf_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
 {
-       switch (msg->get_type(msg))
+       pen_type_t msg_type = msg->get_type(msg);
+
+       switch (msg_type.type)
        {
                case PB_MSG_EXPERIMENTAL:
                        /* nothing to do */
@@ -441,6 +443,43 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
 }
 
 /**
+ * Handle a single PB-TNC TCG standard message according to its type
+ */
+static void handle_tcg_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
+{
+       pen_type_t msg_type = msg->get_type(msg);
+
+       switch (msg_type.type)
+       {
+               case PB_TCG_MSG_PDP_REFERRAL:
+                       /* TODO handle PDP Referral */
+                       break;
+               default:
+                       break;
+       }
+}
+
+/**
+ * Handle a single PB-TNC message according to its type
+ */
+static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
+{
+       pen_type_t msg_type = msg->get_type(msg);
+
+       switch (msg_type.vendor_id)
+       {
+               case PEN_IETF:
+                       handle_ietf_message(this, msg);
+                       break;
+               case PEN_TCG:
+                       handle_tcg_message(this, msg);
+                       break;
+               default:
+                       break;
+       }
+}
+
+/**
  *  Build a CRETRY or SRETRY batch
  */
 static void build_retry_batch(private_tnccs_20_t *this)