output all known PA-TNC subtype names

This commit is contained in:
Andreas Steffen
2011-06-24 17:31:47 +02:00
parent 535f5d8a10
commit b324976aa1
9 changed files with 215 additions and 42 deletions
+32 -1
View File
@@ -23,6 +23,7 @@
#include "messages/tnccs_recommendation_msg.h"
#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
#include <daemon.h>
#include <debug.h>
@@ -99,6 +100,8 @@ METHOD(tnccs_t, send_msg, TNC_Result,
TNC_MessageType msg_type)
{
tnccs_msg_t *tnccs_msg;
u_int32_t vendor_id, subtype;
enum_name_t *pa_subtype_names;
if (!this->send_msg)
{
@@ -107,6 +110,19 @@ METHOD(tnccs_t, send_msg, TNC_Result,
this->is_server ? imv_id : imc_id);
return TNC_RESULT_ILLEGAL_OPERATION;
}
vendor_id = msg_type >> 8;
subtype = msg_type && 0xff;
pa_subtype_names = get_pa_subtype_names(vendor_id);
if (pa_subtype_names)
{
DBG2(DBG_TNC, "creating IMC-IMV message type '%N/%N' 0x%06x/0x%02x",
pen_names, vendor_id, pa_subtype_names, subtype, vendor_id, subtype);
}
else
{
DBG2(DBG_TNC, "creating PB-PA message type '%N' 0x%06x/0x%02x",
pen_names, vendor_id, vendor_id, subtype);
}
tnccs_msg = imc_imv_msg_create(msg_type, chunk_create(msg, msg_len));
/* adding an IMC-IMV Message to TNCCS batch */
@@ -132,12 +148,27 @@ static void handle_message(private_tnccs_11_t *this, tnccs_msg_t *msg)
imc_imv_msg_t *imc_imv_msg;
TNC_MessageType msg_type;
chunk_t msg_body;
u_int32_t vendor_id, subtype;
enum_name_t *pa_subtype_names;
imc_imv_msg = (imc_imv_msg_t*)msg;
msg_type = imc_imv_msg->get_msg_type(imc_imv_msg);
msg_body = imc_imv_msg->get_msg_body(imc_imv_msg);
vendor_id = msg_type >> 8;
subtype = msg_type && 0xff;
DBG2(DBG_TNC, "handling IMC_IMV message type 0x%08x", msg_type);
pa_subtype_names = get_pa_subtype_names(vendor_id);
if (pa_subtype_names)
{
DBG2(DBG_TNC, "handling IMC-IMV message type '%N/%N' 0x%06x/0x%02x",
pen_names, vendor_id, pa_subtype_names, subtype,
vendor_id, subtype);
}
else
{
DBG2(DBG_TNC, "handling IMC-IMV message type '%N' 0x%06x/0x%02x",
pen_names, vendor_id, vendor_id, subtype);
}
this->send_msg = TRUE;
if (this->is_server)
@@ -23,18 +23,6 @@
#include <pen/pen.h>
#include <debug.h>
ENUM(pa_tnc_subtype_names, PA_SUBTYPE_TESTING, PA_SUBTYPE_NEA_CLIENT,
"Testing",
"Operating System",
"Anti-Virus",
"Anti-Spyware",
"Anti-Malware",
"Firewall",
"IDPS",
"VPN",
"NEA Client"
);
typedef struct private_pb_pa_msg_t private_pb_pa_msg_t;
/**
@@ -21,31 +21,10 @@
#ifndef PB_PA_MSG_H_
#define PB_PA_MSG_H_
typedef enum pa_tnc_subtype_t pa_tnc_subtype_t;
typedef struct pb_pa_msg_t pb_pa_msg_t;
#include "pb_tnc_msg.h"
/**
* PA-TNC Subtypes as defined in section 3.5 of RFC 5792
*/
enum pa_tnc_subtype_t {
PA_SUBTYPE_TESTING = 0,
PA_SUBTYPE_OPERATING_SYSTEM = 1,
PA_SUBTYPE_ANTI_VIRUS = 2,
PA_SUBTYPE_ANTI_SPYWARE = 3,
PA_SUBTYPE_ANTI_MALWARE = 4,
PA_SUBTYPE_FIREWALL = 5,
PA_SUBTYPE_IDPS = 6,
PA_SUBTYPE_VPN = 7,
PA_SUBTYPE_NEA_CLIENT = 8
};
/**
* enum name for pa_tnc_subtype_t.
*/
extern enum_name_t *pa_tnc_subtype_names;
/**
* Class representing the PB-PA message type.
*/
+10 -5
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Sansar Choinyanbuu
* Copyright (C) 2010 Andreas Steffen
* Copyright (C) 2010-2011 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
#include "state_machine/pb_tnc_state_machine.h"
#include <tncif_names.h>
#include <tncif_pa_subtypes.h>
#include <debug.h>
#include <daemon.h>
@@ -102,6 +103,7 @@ METHOD(tnccs_t, send_msg, TNC_Result,
TNC_VendorID msg_vendor_id;
pb_tnc_msg_t *pb_tnc_msg;
pb_tnc_batch_type_t batch_type;
enum_name_t *pa_subtype_names;
if (!this->send_msg)
{
@@ -117,10 +119,11 @@ METHOD(tnccs_t, send_msg, TNC_Result,
pb_tnc_msg = pb_pa_msg_create(msg_vendor_id, msg_sub_type, imc_id, imv_id,
chunk_create(msg, msg_len));
if (msg_vendor_id == PEN_IETF)
pa_subtype_names = get_pa_subtype_names(msg_vendor_id);
if (pa_subtype_names)
{
DBG2(DBG_TNC, "creating PB-PA message type '%N/%N' 0x%06x/0x%02x",
pen_names, msg_vendor_id, pa_tnc_subtype_names, msg_sub_type,
pen_names, msg_vendor_id, pa_subtype_names, msg_sub_type,
msg_vendor_id, msg_sub_type);
}
else
@@ -164,16 +167,18 @@ static void handle_message(private_tnccs_20_t *this, pb_tnc_msg_t *msg)
TNC_MessageType msg_type;
u_int32_t vendor_id, subtype;
chunk_t msg_body;
enum_name_t *pa_subtype_names;
pa_msg = (pb_pa_msg_t*)msg;
vendor_id = pa_msg->get_vendor_id(pa_msg, &subtype);
msg_type = (vendor_id << 8) | (subtype & 0xff);
msg_body = pa_msg->get_body(pa_msg);
if (vendor_id == PEN_IETF)
pa_subtype_names = get_pa_subtype_names(vendor_id);
if (pa_subtype_names)
{
DBG2(DBG_TNC, "handling PB-PA message type '%N/%N' 0x%06x/0x%02x",
pen_names, vendor_id, pa_tnc_subtype_names, subtype,
pen_names, vendor_id, pa_subtype_names, subtype,
vendor_id, subtype);
}
else