From ac520f2fdf70cd8ea65c18782e66d3fa8649695c Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Sat, 20 Aug 2011 11:33:22 +0200 Subject: [PATCH] log PA-TNC attribute names --- src/libimcv/Makefile.am | 1 + src/libimcv/ita/ita_attr.c | 21 +++++++++++++ src/libimcv/ita/ita_attr.h | 40 +++++++++++++++++++++++++ src/libimcv/ita/ita_attr_command.c | 1 + src/libimcv/ita/ita_attr_command.h | 2 -- src/libimcv/pa_tnc/pa_tnc_attr.c | 1 + src/libimcv/pa_tnc/pa_tnc_attr.h | 8 +++++ src/libimcv/pa_tnc/pa_tnc_msg.c | 35 +++++++++++++++++++--- src/libimcv/plugins/imc_test/imc_test.c | 1 + src/libimcv/plugins/imv_test/imv_test.c | 1 + 10 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 src/libimcv/ita/ita_attr.c create mode 100644 src/libimcv/ita/ita_attr.h diff --git a/src/libimcv/Makefile.am b/src/libimcv/Makefile.am index 9719a06d8..7b0266f8d 100644 --- a/src/libimcv/Makefile.am +++ b/src/libimcv/Makefile.am @@ -12,6 +12,7 @@ libimcv_la_SOURCES = \ ietf/ietf_attr.h ietf/ietf_attr.c \ ietf/ietf_attr_pa_tnc_error.h ietf/ietf_attr_pa_tnc_error.c \ ietf/ietf_attr_port_filter.h ietf/ietf_attr_port_filter.c \ + ita/ita_attr.h ita/ita_attr.c \ ita/ita_attr_command.h ita/ita_attr_command.c \ pa_tnc/pa_tnc_msg.h pa_tnc/pa_tnc_msg.c \ pa_tnc/pa_tnc_attr.h pa_tnc/pa_tnc_attr.c \ diff --git a/src/libimcv/ita/ita_attr.c b/src/libimcv/ita/ita_attr.c new file mode 100644 index 000000000..7dda74294 --- /dev/null +++ b/src/libimcv/ita/ita_attr.c @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2011 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "ita_attr.h" + +ENUM(ita_attr_names, ITA_ATTR_COMMAND, ITA_ATTR_COMMAND, + "Command", +); + diff --git a/src/libimcv/ita/ita_attr.h b/src/libimcv/ita/ita_attr.h new file mode 100644 index 000000000..a1b233ee6 --- /dev/null +++ b/src/libimcv/ita/ita_attr.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * @defgroup ita_attrt ita_attr + * @{ @ingroup ita_attr + */ + +#ifndef ITA_ATTR_H_ +#define ITA_ATTR_H_ + +#include + +typedef enum ita_attr_t ita_attr_t; + +/** + * IETF standard PA-TNC attribute types defined by RFC 5792 + */ +enum ita_attr_t { + ITA_ATTR_COMMAND = 1, +}; + +/** + * enum name for ita_attr_t. + */ +extern enum_name_t *ita_attr_names; + +#endif /** ITA_ATTR_H_ @}*/ diff --git a/src/libimcv/ita/ita_attr_command.c b/src/libimcv/ita/ita_attr_command.c index dae8e9202..5c1577a7c 100644 --- a/src/libimcv/ita/ita_attr_command.c +++ b/src/libimcv/ita/ita_attr_command.c @@ -12,6 +12,7 @@ * for more details. */ +#include "ita_attr.h" #include "ita_attr_command.h" #include diff --git a/src/libimcv/ita/ita_attr_command.h b/src/libimcv/ita/ita_attr_command.h index 0e0b74e60..372355197 100644 --- a/src/libimcv/ita/ita_attr_command.h +++ b/src/libimcv/ita/ita_attr_command.h @@ -25,8 +25,6 @@ typedef struct ita_attr_command_t ita_attr_command_t; #include "pa_tnc/pa_tnc_attr.h" -#define ITA_ATTR_COMMAND 0x01 - /** * Class implementing the ITA Command PA-TNC attribute. * diff --git a/src/libimcv/pa_tnc/pa_tnc_attr.c b/src/libimcv/pa_tnc/pa_tnc_attr.c index bf1931508..1a1ea0762 100644 --- a/src/libimcv/pa_tnc/pa_tnc_attr.c +++ b/src/libimcv/pa_tnc/pa_tnc_attr.c @@ -30,6 +30,7 @@ #include "tcg/tcg_pts_attr_simple_evid_final.h" #include "tcg/tcg_pts_attr_req_file_meas.h" #include "tcg/tcg_pts_attr_file_meas.h" +#include "ita/ita_attr.h" #include "ita/ita_attr_command.h" /** diff --git a/src/libimcv/pa_tnc/pa_tnc_attr.h b/src/libimcv/pa_tnc/pa_tnc_attr.h index 45d83ae37..07dd9935e 100644 --- a/src/libimcv/pa_tnc/pa_tnc_attr.h +++ b/src/libimcv/pa_tnc/pa_tnc_attr.h @@ -26,6 +26,14 @@ typedef struct pa_tnc_attr_t pa_tnc_attr_t; #include #include +/** + * Return the PA-TNC attribute names for a given PEN + * + * @param pen Private Enterprise Number (PEN) + * @return pa_attr_names if found, NULL else + */ +extern enum_name_t *get_pa_attr_names(pen_t pen); + /** * Interface for an RFC 5792 PA-TNC Posture Attribute. * diff --git a/src/libimcv/pa_tnc/pa_tnc_msg.c b/src/libimcv/pa_tnc/pa_tnc_msg.c index 1b243c692..3b84f3da8 100644 --- a/src/libimcv/pa_tnc/pa_tnc_msg.c +++ b/src/libimcv/pa_tnc/pa_tnc_msg.c @@ -15,7 +15,10 @@ */ #include "pa_tnc_msg.h" +#include "ietf/ietf_attr.h" #include "ietf/ietf_attr_pa_tnc_error.h" +#include "tcg/tcg_attr.h" +#include "ita/ita_attr.h" #include #include @@ -112,6 +115,7 @@ METHOD(pa_tnc_msg_t, build, void, bio_writer_t *writer; enumerator_t *enumerator; pa_tnc_attr_t *attr; + enum_name_t *pa_attr_names; pen_t vendor_id; u_int32_t type; u_int8_t flags; @@ -140,11 +144,13 @@ METHOD(pa_tnc_msg_t, build, void, value = attr->get_value(attr); flags = attr->get_noskip_flag(attr) ? PA_TNC_ATTR_FLAG_NOSKIP : PA_TNC_ATTR_FLAG_NONE; - if (vendor_id == PEN_IETF) + + pa_attr_names = get_pa_attr_names(vendor_id); + if (pa_attr_names) { DBG2(DBG_TNC, "creating PA-TNC attribute type '%N/%N' " "0x%06x/0x%08x", pen_names, vendor_id, - ietf_attr_names, type, vendor_id, type); + pa_attr_names, type, vendor_id, type); } else { @@ -207,6 +213,7 @@ METHOD(pa_tnc_msg_t, process, status_t, u_int32_t type, length; chunk_t value, attr_info; pa_tnc_attr_t *attr; + enum_name_t *pa_attr_names; ietf_attr_pa_tnc_error_t *error_attr; attr_info = reader->peek(reader); @@ -215,11 +222,13 @@ METHOD(pa_tnc_msg_t, process, status_t, reader->read_uint24(reader, &vendor_id); reader->read_uint32(reader, &type); reader->read_uint32(reader, &length); - if (vendor_id == PEN_IETF) + + pa_attr_names = get_pa_attr_names(vendor_id); + if (pa_attr_names) { DBG2(DBG_TNC, "processing PA-TNC attribute type '%N/%N' " "0x%06x/0x%08x", pen_names, vendor_id, - ietf_attr_names, type, vendor_id, type); + pa_attr_names, type, vendor_id, type); } else { @@ -357,3 +366,21 @@ pa_tnc_msg_t *pa_tnc_msg_create(void) return pa_tnc_msg_create_from_data(chunk_empty); } +/** + * See header + */ +enum_name_t* get_pa_attr_names(pen_t pen) +{ + switch (pen) + { + case PEN_IETF: + return ietf_attr_names; + case PEN_TCG: + return tcg_attr_names; + case PEN_ITA: + return ita_attr_names; + default: + return NULL; + } +} + diff --git a/src/libimcv/plugins/imc_test/imc_test.c b/src/libimcv/plugins/imc_test/imc_test.c index 06cc076db..01e70e8af 100644 --- a/src/libimcv/plugins/imc_test/imc_test.c +++ b/src/libimcv/plugins/imc_test/imc_test.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/src/libimcv/plugins/imv_test/imv_test.c b/src/libimcv/plugins/imv_test/imv_test.c index a0bc31c8d..88db24983 100644 --- a/src/libimcv/plugins/imv_test/imv_test.c +++ b/src/libimcv/plugins/imv_test/imv_test.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include