Separated IMV session management from IMV policy database
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <imc/imc_agent.h>
|
||||
#include <imc/imc_msg.h>
|
||||
#include <imc/imc_os_info.h>
|
||||
#include <ietf/ietf_attr.h>
|
||||
#include <ietf/ietf_attr_attr_request.h>
|
||||
#include <ietf/ietf_attr_default_pwd_enabled.h>
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <ita/ita_attr_settings.h>
|
||||
#include <ita/ita_attr_angel.h>
|
||||
#include <ita/ita_attr_device_id.h>
|
||||
#include <os_info/os_info.h>
|
||||
|
||||
#include <tncif_pa_subtypes.h>
|
||||
|
||||
@@ -47,7 +47,7 @@ static pen_type_t msg_types[] = {
|
||||
};
|
||||
|
||||
static imc_agent_t *imc_os;
|
||||
static os_info_t *os;
|
||||
static imc_os_info_t *os;
|
||||
|
||||
/**
|
||||
* see section 3.8.1 of TCG TNC IF-IMC Specification 1.3
|
||||
@@ -69,7 +69,7 @@ TNC_Result TNC_IMC_Initialize(TNC_IMCID imc_id,
|
||||
return TNC_RESULT_FATAL;
|
||||
}
|
||||
|
||||
os = os_info_create();
|
||||
os = imc_os_info_create();
|
||||
if (!os)
|
||||
{
|
||||
imc_os->destroy(imc_os);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Andreas Steffen
|
||||
* Copyright (C) 2013-2014 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -134,7 +134,13 @@ METHOD(imv_agent_if_t, notify_connection_change, TNC_Result,
|
||||
}
|
||||
session = state->get_session(state);
|
||||
imcv_db->add_recommendation(imcv_db, session, rec);
|
||||
imcv_db->policy_script(imcv_db, session, FALSE);
|
||||
if (session->get_policy_started(session))
|
||||
{
|
||||
if (!imcv_db->policy_script(imcv_db, session, FALSE))
|
||||
{
|
||||
DBG1(DBG_IMV, "error in policy script stop");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* fall through to default state */
|
||||
default:
|
||||
@@ -150,6 +156,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
{
|
||||
imv_msg_t *out_msg;
|
||||
imv_os_state_t *os_state;
|
||||
imv_session_t *session;
|
||||
imv_os_info_t *os_info = NULL;
|
||||
enumerator_t *enumerator;
|
||||
pa_tnc_attr_t *attr;
|
||||
pen_type_t type;
|
||||
@@ -159,6 +167,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
bool fatal_error = FALSE, assessment = FALSE;
|
||||
|
||||
os_state = (imv_os_state_t*)state;
|
||||
session = state->get_session(state);
|
||||
os_info = session->get_os_info(session);
|
||||
|
||||
/* parse received PA-TNC message and handle local and remote errors */
|
||||
result = in_msg->receive(in_msg, &fatal_error);
|
||||
@@ -188,6 +198,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
IMV_OS_ATTR_PRODUCT_INFORMATION);
|
||||
attr_cast = (ietf_attr_product_info_t*)attr;
|
||||
os_name = attr_cast->get_info(attr_cast, &vendor_id, NULL);
|
||||
os_info->set_name(os_info, os_name);
|
||||
|
||||
if (vendor_id != PEN_IETF)
|
||||
{
|
||||
DBG1(DBG_IMV, "operating system name is '%.*s' "
|
||||
@@ -209,6 +221,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
IMV_OS_ATTR_STRING_VERSION);
|
||||
attr_cast = (ietf_attr_string_version_t*)attr;
|
||||
os_version = attr_cast->get_version(attr_cast, NULL, NULL);
|
||||
os_info->set_version(os_info, os_version);
|
||||
|
||||
if (os_version.len)
|
||||
{
|
||||
DBG1(DBG_IMV, "operating system version is '%.*s'",
|
||||
@@ -350,8 +364,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
state->set_action_flags(state, IMV_OS_ATTR_DEVICE_ID);
|
||||
|
||||
value = attr->get_value(attr);
|
||||
os_state->set_device_id(os_state, value);
|
||||
DBG1(DBG_IMV, "device ID is %.*s", value.len, value.ptr);
|
||||
session->set_device_id(session, value);
|
||||
break;
|
||||
}
|
||||
case ITA_ATTR_START_ANGEL:
|
||||
@@ -367,25 +381,6 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
/**
|
||||
* The IETF Product Information and String Version attributes
|
||||
* are supposed to arrive in the same PA-TNC message
|
||||
*/
|
||||
if (os_name.len && os_version.len)
|
||||
{
|
||||
os_type_t os_type;
|
||||
|
||||
/* set the OS type, name and version */
|
||||
os_type = os_type_from_name(os_name);
|
||||
os_state->set_info(os_state,os_type, os_name, os_version);
|
||||
|
||||
if (imcv_db)
|
||||
{
|
||||
imcv_db->add_product(imcv_db, state->get_session(state),
|
||||
os_state->get_info(os_state, NULL, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
if (fatal_error)
|
||||
{
|
||||
state->set_recommendation(state,
|
||||
@@ -542,56 +537,69 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
|
||||
if (handshake_state < IMV_OS_STATE_POLICY_START)
|
||||
{
|
||||
if (((received & IMV_OS_ATTR_PRODUCT_INFORMATION) &&
|
||||
(received & IMV_OS_ATTR_STRING_VERSION)) &&
|
||||
((received & IMV_OS_ATTR_DEVICE_ID) ||
|
||||
(handshake_state == IMV_OS_STATE_ATTR_REQ)))
|
||||
if (session->get_policy_started(session))
|
||||
{
|
||||
if (imcv_db)
|
||||
{
|
||||
imcv_db->add_device(imcv_db, session,
|
||||
os_state->get_device_id(os_state));
|
||||
|
||||
/* trigger the policy manager */
|
||||
imcv_db->policy_script(imcv_db, session, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG2(DBG_IMV, "no workitems available - no evaluation possible");
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
|
||||
TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
|
||||
}
|
||||
/* the policy script has already been started by another IMV */
|
||||
handshake_state = IMV_OS_STATE_POLICY_START;
|
||||
}
|
||||
else if (handshake_state == IMV_OS_STATE_ATTR_REQ)
|
||||
{
|
||||
/**
|
||||
* both the IETF Product Information and IETF String Version
|
||||
* attribute should have been present
|
||||
*/
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
TNC_IMV_EVALUATION_RESULT_ERROR);
|
||||
|
||||
/* send assessment */
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return this->agent->provide_recommendation(this->agent, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
handshake_state = IMV_OS_STATE_ATTR_REQ;
|
||||
if (((received & IMV_OS_ATTR_PRODUCT_INFORMATION) &&
|
||||
(received & IMV_OS_ATTR_STRING_VERSION)) &&
|
||||
((received & IMV_OS_ATTR_DEVICE_ID) ||
|
||||
(handshake_state == IMV_OS_STATE_ATTR_REQ)))
|
||||
{
|
||||
if (!session->get_device_id(session, NULL))
|
||||
{
|
||||
session->set_device_id(session, chunk_empty);
|
||||
}
|
||||
if (imcv_db)
|
||||
{
|
||||
/* start the policy script */
|
||||
if (!imcv_db->policy_script(imcv_db, session, TRUE))
|
||||
{
|
||||
DBG1(DBG_IMV, "error in policy script start");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG2(DBG_IMV, "no workitems available - "
|
||||
"no evaluation possible");
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
|
||||
TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
|
||||
}
|
||||
handshake_state = IMV_OS_STATE_POLICY_START;
|
||||
}
|
||||
else if (handshake_state == IMV_OS_STATE_ATTR_REQ)
|
||||
{
|
||||
/**
|
||||
* both the IETF Product Information and IETF String Version
|
||||
* attribute should have been present
|
||||
*/
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
TNC_IMV_EVALUATION_RESULT_ERROR);
|
||||
|
||||
/* send assessment */
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return this->agent->provide_recommendation(this->agent, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
handshake_state = IMV_OS_STATE_ATTR_REQ;
|
||||
}
|
||||
}
|
||||
os_state->set_handshake_state(os_state, handshake_state);
|
||||
}
|
||||
|
||||
if (handshake_state == IMV_OS_STATE_POLICY_START && session)
|
||||
if (handshake_state == IMV_OS_STATE_POLICY_START)
|
||||
{
|
||||
enumerator = session->create_workitem_enumerator(session);
|
||||
if (enumerator)
|
||||
@@ -638,7 +646,7 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
}
|
||||
}
|
||||
|
||||
if (handshake_state == IMV_OS_STATE_WORKITEMS && session)
|
||||
if (handshake_state == IMV_OS_STATE_WORKITEMS)
|
||||
{
|
||||
TNC_IMV_Evaluation_Result eval;
|
||||
TNC_IMV_Action_Recommendation rec;
|
||||
|
||||
@@ -41,19 +41,26 @@ struct private_imv_os_database_t {
|
||||
};
|
||||
|
||||
METHOD(imv_os_database_t, check_packages, status_t,
|
||||
private_imv_os_database_t *this, imv_os_state_t *state,
|
||||
private_imv_os_database_t *this, imv_os_state_t *os_state,
|
||||
enumerator_t *package_enumerator)
|
||||
{
|
||||
imv_state_t *state;
|
||||
imv_session_t *session;
|
||||
imv_os_info_t *os_info;
|
||||
os_type_t os_type;
|
||||
char *product, *package, *release, *cur_release;
|
||||
chunk_t name, version;
|
||||
os_type_t os_type;
|
||||
int pid, gid, security, blacklist;
|
||||
int count = 0, count_ok = 0, count_no_match = 0, count_blacklist = 0;
|
||||
enumerator_t *e;
|
||||
status_t status = SUCCESS;
|
||||
bool found, match;
|
||||
|
||||
product = state->get_info(state, &os_type, NULL, NULL);
|
||||
state = &os_state->interface;
|
||||
session = state->get_session(state);
|
||||
os_info = session->get_os_info(session);
|
||||
os_type = os_info->get_type(os_info);
|
||||
product = os_info->get_info(os_info);
|
||||
|
||||
if (os_type == OS_TYPE_ANDROID)
|
||||
{
|
||||
@@ -143,8 +150,8 @@ METHOD(imv_os_database_t, check_packages, status_t,
|
||||
DBG2(DBG_IMV, "package '%s' (%s) is blacklisted",
|
||||
package, release);
|
||||
count_blacklist++;
|
||||
state->add_bad_package(state, package,
|
||||
OS_PACKAGE_STATE_BLACKLIST);
|
||||
os_state->add_bad_package(os_state, package,
|
||||
OS_PACKAGE_STATE_BLACKLIST);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -157,8 +164,8 @@ METHOD(imv_os_database_t, check_packages, status_t,
|
||||
{
|
||||
DBG1(DBG_IMV, "package '%s' (%s) no match", package, release);
|
||||
count_no_match++;
|
||||
state->add_bad_package(state, package,
|
||||
OS_PACKAGE_STATE_SECURITY);
|
||||
os_state->add_bad_package(os_state, package,
|
||||
OS_PACKAGE_STATE_SECURITY);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -168,7 +175,8 @@ METHOD(imv_os_database_t, check_packages, status_t,
|
||||
free(package);
|
||||
free(release);
|
||||
}
|
||||
state->set_count(state, count, count_no_match, count_blacklist, count_ok);
|
||||
os_state->set_count(os_state, count, count_no_match,
|
||||
count_blacklist, count_ok);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Andreas Steffen
|
||||
* Copyright (C) 2012-2014 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "imv/imv_lang_string.h"
|
||||
#include "imv/imv_reason_string.h"
|
||||
#include "imv/imv_remediation_string.h"
|
||||
#include "imv/imv_os_info.h"
|
||||
|
||||
#include <tncif_policy.h>
|
||||
|
||||
@@ -62,22 +63,12 @@ struct private_imv_os_state_t {
|
||||
/**
|
||||
* Maximum PA-TNC message size for this TNCCS connection
|
||||
*/
|
||||
u_int32_t max_msg_len;
|
||||
uint32_t max_msg_len;
|
||||
|
||||
/**
|
||||
* Flags set for completed actions
|
||||
*/
|
||||
u_int32_t action_flags;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Type
|
||||
*/
|
||||
u_int32_t ar_id_type;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Value
|
||||
*/
|
||||
chunk_t ar_id_value;
|
||||
uint32_t action_flags;
|
||||
|
||||
/**
|
||||
* IMV database session associated with TNCCS connection
|
||||
@@ -99,33 +90,13 @@ struct private_imv_os_state_t {
|
||||
*/
|
||||
imv_os_handshake_state_t handshake_state;
|
||||
|
||||
/**
|
||||
* OS Product Information (concatenation of OS Name and Version)
|
||||
*/
|
||||
char *info;
|
||||
|
||||
/**
|
||||
* OS Type
|
||||
*/
|
||||
os_type_t type;
|
||||
|
||||
/**
|
||||
* OS Name
|
||||
*/
|
||||
chunk_t name;
|
||||
|
||||
/**
|
||||
* OS Version
|
||||
*/
|
||||
chunk_t version;
|
||||
|
||||
/**
|
||||
* List of blacklisted packages to be removed
|
||||
*/
|
||||
linked_list_t *remove_packages;
|
||||
|
||||
/**
|
||||
* List of vulnerable packages to be updated
|
||||
h* List of vulnerable packages to be updated
|
||||
*/
|
||||
linked_list_t *update_packages;
|
||||
|
||||
@@ -139,11 +110,6 @@ struct private_imv_os_state_t {
|
||||
*/
|
||||
imv_remediation_string_t *remediation_string;
|
||||
|
||||
/**
|
||||
* Dgevice ID
|
||||
*/
|
||||
chunk_t device_id;
|
||||
|
||||
/**
|
||||
* Number of processed packages
|
||||
*/
|
||||
@@ -326,46 +292,29 @@ METHOD(imv_state_t, set_flags, void,
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_max_msg_len, void,
|
||||
private_imv_os_state_t *this, u_int32_t max_msg_len)
|
||||
private_imv_os_state_t *this, uint32_t max_msg_len)
|
||||
{
|
||||
this->max_msg_len = max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_max_msg_len, u_int32_t,
|
||||
METHOD(imv_state_t, get_max_msg_len, uint32_t,
|
||||
private_imv_os_state_t *this)
|
||||
{
|
||||
return this->max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_action_flags, void,
|
||||
private_imv_os_state_t *this, u_int32_t flags)
|
||||
private_imv_os_state_t *this, uint32_t flags)
|
||||
{
|
||||
this->action_flags |= flags;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_action_flags, u_int32_t,
|
||||
METHOD(imv_state_t, get_action_flags, uint32_t,
|
||||
private_imv_os_state_t *this)
|
||||
{
|
||||
return this->action_flags;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_ar_id, void,
|
||||
private_imv_os_state_t *this, u_int32_t id_type, chunk_t id_value)
|
||||
{
|
||||
this->ar_id_type = id_type;
|
||||
this->ar_id_value = chunk_clone(id_value);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_ar_id, chunk_t,
|
||||
private_imv_os_state_t *this, u_int32_t *id_type)
|
||||
{
|
||||
if (id_type)
|
||||
{
|
||||
*id_type = this->ar_id_type;
|
||||
}
|
||||
return this->ar_id_value;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_session, void,
|
||||
private_imv_os_state_t *this, imv_session_t *session)
|
||||
{
|
||||
@@ -440,6 +389,9 @@ METHOD(imv_state_t, get_remediation_instructions, bool,
|
||||
private_imv_os_state_t *this, enumerator_t *language_enumerator,
|
||||
chunk_t *string, char **lang_code, char **uri)
|
||||
{
|
||||
imv_os_info_t *os_info;
|
||||
bool as_xml = FALSE;
|
||||
|
||||
if (!this->count_update && !this->count_blacklist & !this->os_settings)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -449,8 +401,12 @@ METHOD(imv_state_t, get_remediation_instructions, bool,
|
||||
|
||||
/* Instantiate an IETF Remediation Instructions String object */
|
||||
DESTROY_IF(this->remediation_string);
|
||||
this->remediation_string = imv_remediation_string_create(
|
||||
this->type == OS_TYPE_ANDROID, *lang_code);
|
||||
if (this->session)
|
||||
{
|
||||
os_info = this->session->get_os_info(this->session);
|
||||
as_xml = os_info->get_type(os_info) == OS_TYPE_ANDROID;
|
||||
}
|
||||
this->remediation_string = imv_remediation_string_create(as_xml, *lang_code);
|
||||
|
||||
/* List of blacklisted packages to be removed, if any */
|
||||
if (this->count_blacklist)
|
||||
@@ -507,11 +463,6 @@ METHOD(imv_state_t, destroy, void,
|
||||
DESTROY_IF(this->remediation_string);
|
||||
this->update_packages->destroy_function(this->update_packages, free);
|
||||
this->remove_packages->destroy_function(this->remove_packages, free);
|
||||
free(this->info);
|
||||
free(this->name.ptr);
|
||||
free(this->version.ptr);
|
||||
free(this->ar_id_value.ptr);
|
||||
free(this->device_id.ptr);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -527,39 +478,6 @@ METHOD(imv_os_state_t, get_handshake_state, imv_os_handshake_state_t,
|
||||
return this->handshake_state;
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, set_info, void,
|
||||
private_imv_os_state_t *this, os_type_t type, chunk_t name, chunk_t version)
|
||||
{
|
||||
int len = name.len + 1 + version.len + 1;
|
||||
|
||||
/* OS info is a concatenation of OS name and OS version */
|
||||
free(this->info);
|
||||
this->info = malloc(len);
|
||||
snprintf(this->info, len, "%.*s %.*s", (int)name.len, name.ptr,
|
||||
(int)version.len, version.ptr);
|
||||
this->type = type;
|
||||
this->name = chunk_clone(name);
|
||||
this->version = chunk_clone(version);
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, get_info, char*,
|
||||
private_imv_os_state_t *this, os_type_t *type, chunk_t *name,
|
||||
chunk_t *version)
|
||||
{
|
||||
if (type)
|
||||
{
|
||||
*type = this->type;
|
||||
}
|
||||
if (name)
|
||||
{
|
||||
*name = this->name;
|
||||
}
|
||||
if (version)
|
||||
{
|
||||
*version = this->version;
|
||||
}
|
||||
return this->info;
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, set_count, void,
|
||||
private_imv_os_state_t *this, int count, int count_update,
|
||||
@@ -593,18 +511,6 @@ METHOD(imv_os_state_t, get_count, void,
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, set_device_id, void,
|
||||
private_imv_os_state_t *this, chunk_t id)
|
||||
{
|
||||
this->device_id = chunk_clone(id);
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, get_device_id, chunk_t,
|
||||
private_imv_os_state_t *this)
|
||||
{
|
||||
return this->device_id;
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, set_os_settings, void,
|
||||
private_imv_os_state_t *this, u_int settings)
|
||||
{
|
||||
@@ -663,8 +569,6 @@ imv_state_t *imv_os_state_create(TNC_ConnectionID connection_id)
|
||||
.get_max_msg_len = _get_max_msg_len,
|
||||
.set_action_flags = _set_action_flags,
|
||||
.get_action_flags = _get_action_flags,
|
||||
.set_ar_id = _set_ar_id,
|
||||
.get_ar_id = _get_ar_id,
|
||||
.set_session = _set_session,
|
||||
.get_session = _get_session,
|
||||
.change_state = _change_state,
|
||||
@@ -677,12 +581,8 @@ imv_state_t *imv_os_state_create(TNC_ConnectionID connection_id)
|
||||
},
|
||||
.set_handshake_state = _set_handshake_state,
|
||||
.get_handshake_state = _get_handshake_state,
|
||||
.set_info = _set_info,
|
||||
.get_info = _get_info,
|
||||
.set_count = _set_count,
|
||||
.get_count = _get_count,
|
||||
.set_device_id = _set_device_id,
|
||||
.get_device_id = _get_device_id,
|
||||
.set_os_settings = _set_os_settings,
|
||||
.get_os_settings = _get_os_settings,
|
||||
.set_angel_count = _set_angel_count,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Andreas Steffen
|
||||
* Copyright (C) 2012-2014 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -77,27 +77,6 @@ struct imv_os_state_t {
|
||||
*/
|
||||
imv_os_handshake_state_t (*get_handshake_state)(imv_os_state_t *this);
|
||||
|
||||
/**
|
||||
* Set OS Product Information
|
||||
*
|
||||
* @param type OS type (enumerated)
|
||||
* @param name OS name (string)
|
||||
* @param version OS version
|
||||
*/
|
||||
void (*set_info)(imv_os_state_t *this, os_type_t os_type,
|
||||
chunk_t name, chunk_t version);
|
||||
|
||||
/**
|
||||
* Get OS Product Information
|
||||
*
|
||||
* @param type OS type (enumerated)
|
||||
* @param name OS name (string)
|
||||
* @param version OS version
|
||||
* @return OS name & version as a concatenated string
|
||||
*/
|
||||
char* (*get_info)(imv_os_state_t *this, os_type_t *os_type,
|
||||
chunk_t *name, chunk_t *version);
|
||||
|
||||
/**
|
||||
* Set [or with multiple attributes increment] package counters
|
||||
*
|
||||
@@ -120,20 +99,6 @@ struct imv_os_state_t {
|
||||
void (*get_count)(imv_os_state_t *this, int *count, int *count_update,
|
||||
int *count_blacklist, int *count_ok);
|
||||
|
||||
/**
|
||||
* Set device ID
|
||||
*
|
||||
* @param device_id Device ID
|
||||
*/
|
||||
void (*set_device_id)(imv_os_state_t *this, chunk_t id);
|
||||
|
||||
/**
|
||||
* Get device ID
|
||||
*
|
||||
* @return Device ID
|
||||
*/
|
||||
chunk_t (*get_device_id)(imv_os_state_t *this);
|
||||
|
||||
/**
|
||||
* Set OS settings
|
||||
*
|
||||
|
||||
@@ -259,7 +259,7 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
out_msg = imv_msg_create(this->agent, state, id, imv_id, TNC_IMCID_ANY,
|
||||
msg_types[0]);
|
||||
|
||||
if (!session)
|
||||
if (!imcv_db)
|
||||
{
|
||||
DBG2(DBG_IMV, "no workitems available - no evaluation possible");
|
||||
state->set_recommendation(state,
|
||||
@@ -276,7 +276,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
return this->agent->provide_recommendation(this->agent, state);
|
||||
}
|
||||
|
||||
if (handshake_state == IMV_SCANNER_STATE_INIT)
|
||||
if (handshake_state == IMV_SCANNER_STATE_INIT &&
|
||||
session->get_policy_started(session))
|
||||
{
|
||||
enumerator = session->create_workitem_enumerator(session);
|
||||
if (enumerator)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2013 Andreas Steffen
|
||||
* Copyright (C) 2011-2014 Andreas Steffen
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -58,22 +58,12 @@ struct private_imv_scanner_state_t {
|
||||
/**
|
||||
* Maximum PA-TNC message size for this TNCCS connection
|
||||
*/
|
||||
u_int32_t max_msg_len;
|
||||
uint32_t max_msg_len;
|
||||
|
||||
/**
|
||||
* Flags set for completed actions
|
||||
*/
|
||||
u_int32_t action_flags;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Type
|
||||
*/
|
||||
u_int32_t ar_id_type;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Value
|
||||
*/
|
||||
chunk_t ar_id_value;
|
||||
uint32_t action_flags;
|
||||
|
||||
/**
|
||||
* IMV database session associatied with TNCCS connection
|
||||
@@ -186,46 +176,29 @@ METHOD(imv_state_t, set_flags, void,
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_max_msg_len, void,
|
||||
private_imv_scanner_state_t *this, u_int32_t max_msg_len)
|
||||
private_imv_scanner_state_t *this, uint32_t max_msg_len)
|
||||
{
|
||||
this->max_msg_len = max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_max_msg_len, u_int32_t,
|
||||
METHOD(imv_state_t, get_max_msg_len, uint32_t,
|
||||
private_imv_scanner_state_t *this)
|
||||
{
|
||||
return this->max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_action_flags, void,
|
||||
private_imv_scanner_state_t *this, u_int32_t flags)
|
||||
private_imv_scanner_state_t *this, uint32_t flags)
|
||||
{
|
||||
this->action_flags |= flags;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_action_flags, u_int32_t,
|
||||
METHOD(imv_state_t, get_action_flags, uint32_t,
|
||||
private_imv_scanner_state_t *this)
|
||||
{
|
||||
return this->action_flags;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_ar_id, void,
|
||||
private_imv_scanner_state_t *this, u_int32_t id_type, chunk_t id_value)
|
||||
{
|
||||
this->ar_id_type = id_type;
|
||||
this->ar_id_value = chunk_clone(id_value);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_ar_id, chunk_t,
|
||||
private_imv_scanner_state_t *this, u_int32_t *id_type)
|
||||
{
|
||||
if (id_type)
|
||||
{
|
||||
*id_type = this->ar_id_type;
|
||||
}
|
||||
return this->ar_id_value;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_session, void,
|
||||
private_imv_scanner_state_t *this, imv_session_t *session)
|
||||
{
|
||||
@@ -327,7 +300,6 @@ METHOD(imv_state_t, destroy, void,
|
||||
DESTROY_IF(this->remediation_string);
|
||||
DESTROY_IF(&this->port_filter_attr->pa_tnc_attribute);
|
||||
this->violating_ports->destroy_function(this->violating_ports, free);
|
||||
free(this->ar_id_value.ptr);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -380,8 +352,6 @@ imv_state_t *imv_scanner_state_create(TNC_ConnectionID connection_id)
|
||||
.get_max_msg_len = _get_max_msg_len,
|
||||
.set_action_flags = _set_action_flags,
|
||||
.get_action_flags = _get_action_flags,
|
||||
.set_ar_id = _set_ar_id,
|
||||
.get_ar_id = _get_ar_id,
|
||||
.set_session = _set_session,
|
||||
.get_session= _get_session,
|
||||
.change_state = _change_state,
|
||||
|
||||
@@ -58,17 +58,7 @@ struct private_imv_test_state_t {
|
||||
/**
|
||||
* Maximum PA-TNC message size for this TNCCS connection
|
||||
*/
|
||||
u_int32_t max_msg_len;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Type
|
||||
*/
|
||||
u_int32_t ar_id_type;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Value
|
||||
*/
|
||||
chunk_t ar_id_value;
|
||||
uint32_t max_msg_len;
|
||||
|
||||
/**
|
||||
* IMV database session associated with TNCCS connection
|
||||
@@ -149,34 +139,17 @@ METHOD(imv_state_t, set_flags, void,
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_max_msg_len, void,
|
||||
private_imv_test_state_t *this, u_int32_t max_msg_len)
|
||||
private_imv_test_state_t *this, uint32_t max_msg_len)
|
||||
{
|
||||
this->max_msg_len = max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_max_msg_len, u_int32_t,
|
||||
METHOD(imv_state_t, get_max_msg_len, uint32_t,
|
||||
private_imv_test_state_t *this)
|
||||
{
|
||||
return this->max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_ar_id, void,
|
||||
private_imv_test_state_t *this, u_int32_t id_type, chunk_t id_value)
|
||||
{
|
||||
this->ar_id_type = id_type;
|
||||
this->ar_id_value = chunk_clone(id_value);
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_ar_id, chunk_t,
|
||||
private_imv_test_state_t *this, u_int32_t *id_type)
|
||||
{
|
||||
if (id_type)
|
||||
{
|
||||
*id_type = this->ar_id_type;
|
||||
}
|
||||
return this->ar_id_value;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_session, void,
|
||||
private_imv_test_state_t *this, imv_session_t *session)
|
||||
{
|
||||
@@ -248,7 +221,6 @@ METHOD(imv_state_t, destroy, void,
|
||||
DESTROY_IF(this->session);
|
||||
DESTROY_IF(this->reason_string);
|
||||
this->imcs->destroy_function(this->imcs, free);
|
||||
free(this->ar_id_value.ptr);
|
||||
free(this);
|
||||
}
|
||||
|
||||
@@ -333,8 +305,6 @@ imv_state_t *imv_test_state_create(TNC_ConnectionID connection_id)
|
||||
.set_flags = _set_flags,
|
||||
.set_max_msg_len = _set_max_msg_len,
|
||||
.get_max_msg_len = _get_max_msg_len,
|
||||
.set_ar_id = _set_ar_id,
|
||||
.get_ar_id = _get_ar_id,
|
||||
.set_session = _set_session,
|
||||
.get_session = _get_session,
|
||||
.change_state = _change_state,
|
||||
|
||||
Reference in New Issue
Block a user