implemented IMV session control

This commit is contained in:
Andreas Steffen
2013-06-21 23:25:21 +02:00
parent 1f179c63b3
commit b8db66de15
21 changed files with 978 additions and 454 deletions
+1
View File
@@ -10,6 +10,7 @@ libimcv_la_SOURCES = \
imc/imc_agent.h imc/imc_agent.c imc/imc_state.h \
imc/imc_msg.h imc/imc_msg.c \
imv/imv_agent.h imv/imv_agent.c imv/imv_state.h \
imv/imv_database.h imv/imv_database.c \
imv/imv_msg.h imv/imv_msg.c \
imv/imv_lang_string.h imv/imv_lang_string.c \
imv/imv_reason_string.h imv/imv_reason_string.c \
+47 -2
View File
@@ -62,6 +62,11 @@ struct private_imv_agent_t {
*/
linked_list_t *additional_ids;
/**
* IMV database
*/
imv_database_t *db;
/**
* list of TNCS connection entries
*/
@@ -402,11 +407,14 @@ METHOD(imv_agent_t, create_state, TNC_Result,
{
TNC_ConnectionID conn_id;
char *tnccs_p = NULL, *tnccs_v = NULL, *t_p = NULL, *t_v = NULL;
bool has_long = FALSE, has_excl = FALSE, has_soh = FALSE;
bool has_long = FALSE, has_excl = FALSE, has_soh = FALSE, first = TRUE;
linked_list_t *ar_identities;
enumerator_t *enumerator;
tncif_identity_t *tnc_id;
int session_id;
u_int32_t max_msg_len;
u_int32_t ar_id_type = TNC_ID_UNKNOWN;
chunk_t ar_id_value = chunk_empty;
conn_id = state->get_connection_id(state);
if (find_connection(this, conn_id))
@@ -462,10 +470,31 @@ METHOD(imv_agent_t, create_state, TNC_Result,
TNC_Subject_names, tcg_subject_type,
id_value.len, id_value.ptr,
TNC_Authentication_names, tcg_auth_type);
state->set_ar_id(state, tcg_id_type, id_value);
if (first)
{
ar_id_type = tcg_id_type;
ar_id_value = id_value;
state->set_ar_id(state, ar_id_type, ar_id_value);
first = FALSE;
}
}
enumerator->destroy(enumerator);
if (this->db)
{
session_id = this->db->get_session_id(this->db, conn_id,
ar_id_type, ar_id_value);
if (session_id)
{
DBG2(DBG_IMV, " assigned session ID %d", session_id);
state->set_session_id(state, session_id);
}
else
{
DBG1(DBG_IMV, " no session ID assigned");
}
}
ar_identities->destroy_offset(ar_identities,
offsetof(tncif_identity_t, destroy));
free(tnccs_p);
@@ -553,6 +582,12 @@ METHOD(imv_agent_t, get_state, bool,
return TRUE;
}
METHOD(imv_agent_t, get_database, imv_database_t*,
private_imv_agent_t *this)
{
return this->db;
}
METHOD(imv_agent_t, get_name, const char*,
private_imv_agent_t *this)
{
@@ -754,6 +789,7 @@ METHOD(imv_agent_t, destroy, void,
private_imv_agent_t *this)
{
DBG1(DBG_IMV, "IMV %u \"%s\" terminated", this->id, this->name);
DESTROY_IF(this->db);
this->additional_ids->destroy(this->additional_ids);
this->connections->destroy_offset(this->connections,
offsetof(imv_state_t, destroy));
@@ -772,6 +808,7 @@ imv_agent_t *imv_agent_create(const char *name,
TNC_IMVID id, TNC_Version *actual_version)
{
private_imv_agent_t *this;
char *uri;
/* initialize or increase the reference count */
if (!libimcv_init())
@@ -786,6 +823,7 @@ imv_agent_t *imv_agent_create(const char *name,
.delete_state = _delete_state,
.change_state = _change_state,
.get_state = _get_state,
.get_database = _get_database,
.get_name = _get_name,
.get_id = _get_id,
.reserve_additional_ids = _reserve_additional_ids,
@@ -804,6 +842,13 @@ imv_agent_t *imv_agent_create(const char *name,
.connection_lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
);
/* attach IMV database */
uri = lib->settings->get_str(lib->settings, "libimcv.database", NULL);
if (uri)
{
this->db = imv_database_create(uri);
}
*actual_version = TNC_IFIMV_VERSION_1;
DBG1(DBG_IMV, "IMV %u \"%s\" initialized", this->id, this->name);
+8
View File
@@ -23,6 +23,7 @@
#define IMV_AGENT_H_
#include "imv_state.h"
#include "imv_database.h"
#include "pa_tnc/pa_tnc_msg.h"
#include <tncifimv.h>
@@ -137,6 +138,13 @@ struct imv_agent_t {
bool (*get_state)(imv_agent_t *this,
TNC_ConnectionID connection_id, imv_state_t **state);
/**
* Get IMV database
*
* @return IMV database if it exists, NULL otherwise
*/
imv_database_t* (*get_database)(imv_agent_t *this);
/**
* Get IMV name
*
+209
View File
@@ -0,0 +1,209 @@
/*
* 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 "imv_database.h"
#include <utils/debug.h>
#include <string.h>
#include <time.h>
typedef struct private_imv_database_t private_imv_database_t;
#define SESSION_TIME_DELTA_MAX 2 /* seconds */
/**
* Private data of a imv_database_t object.
*
*/
struct private_imv_database_t {
/**
* Public imv_database_t interface.
*/
imv_database_t public;
/**
* database instance
*/
database_t *db;
};
METHOD(imv_database_t, get_session_id, int,
private_imv_database_t *this, TNC_ConnectionID id, u_int32_t ar_id_type,
chunk_t ar_id_value)
{
enumerator_t *e;
int ar_id = 0, session_id = 0;
u_int created;
time_t now;
/* get most recent session for a given connection ID if available */
e = this->db->query(this->db,
"SELECT id, time FROM sessions WHERE connection = ? "
"ORDER BY time DESC", DB_INT, id, DB_INT, DB_UINT);
if (e)
{
e->enumerate(e, &session_id, &created);
e->destroy(e);
}
/* get current time */
now = time(NULL);
/* check if a new session has already been created by another IMV */
if (session_id && (now - created) <= SESSION_TIME_DELTA_MAX)
{
return session_id;
}
if (ar_id_value.len)
{
/* get primary key of AR identity if it exists */
e = this->db->query(this->db,
"SELECT id FROM identities WHERE type = ? AND value = ?",
DB_INT, ar_id_type, DB_BLOB, ar_id_value, DB_INT);
if (e)
{
e->enumerate(e, &ar_id);
e->destroy(e);
}
/* if AR identity has not been found - register it */
if (!ar_id)
{
this->db->execute(this->db, &ar_id,
"INSERT INTO identities (type, value) VALUES (?, ?)",
DB_INT, ar_id_type, DB_BLOB, ar_id_value);
}
}
/* create a new session ID */
this->db->execute(this->db, &session_id,
"INSERT INTO sessions (time, connection, identity) "
"VALUES (?, ?, ?)", DB_UINT, now, DB_INT, id, DB_INT, ar_id);
return session_id;
}
METHOD(imv_database_t, add_product, int,
private_imv_database_t *this, int session_id, char *product)
{
enumerator_t *e;
int pid = 0;
/* get primary key of product info string if it exists */
e = this->db->query(this->db,
"SELECT id FROM products WHERE name = ?", DB_TEXT, product, DB_INT);
if (e)
{
e->enumerate(e, &pid);
e->destroy(e);
}
/* if product info string has not been found - register it */
if (!pid)
{
this->db->execute(this->db, &pid,
"INSERT INTO products (name) VALUES (?)", DB_TEXT, product);
}
/* add product reference to session */
if (pid)
{
this->db->execute(this->db, NULL,
"UPDATE sessions SET product = ? WHERE id = ?",
DB_INT, pid, DB_INT, session_id);
}
return pid;
}
METHOD(imv_database_t, add_device, int,
private_imv_database_t *this, int session_id, chunk_t device)
{
enumerator_t *e;
int did = 0;
/* get primary key of device identification if it exists */
e = this->db->query(this->db,
"SELECT id FROM devices WHERE value = ?", DB_BLOB, device, DB_INT);
if (e)
{
e->enumerate(e, &did);
e->destroy(e);
}
/* if device identification has not been found - register it */
if (!did)
{
this->db->execute(this->db, &did,
"INSERT INTO devices (value) VALUES (?)", DB_BLOB, device);
}
/* add device reference to session */
if (did)
{
this->db->execute(this->db, NULL,
"UPDATE sessions SET device = ? WHERE id = ?",
DB_INT, did, DB_INT, session_id);
}
return did;
}
METHOD(imv_database_t, get_database, database_t*,
private_imv_database_t *this)
{
return this->db;
}
METHOD(imv_database_t, destroy, void,
private_imv_database_t *this)
{
this->db->destroy(this->db);
free(this);
}
/**
* See header
*/
imv_database_t *imv_database_create(char *uri)
{
private_imv_database_t *this;
INIT(this,
.public = {
.get_session_id = _get_session_id,
.add_product = _add_product,
.add_device = _add_device,
.get_database = _get_database,
.destroy = _destroy,
},
.db = lib->db->create(lib->db, uri),
);
if (!this->db)
{
DBG1(DBG_IMV,
"failed to connect to IMV database '%s'", uri);
free(this);
return NULL;
}
return &this->public;
}
+85
View File
@@ -0,0 +1,85 @@
/*
* 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 imv_database_t imv_database
* @{ @ingroup libimcv_imv
*/
#ifndef IMV_DATABASE_H_
#define IMV_DATABASE_H_
#include <tncif.h>
#include <library.h>
typedef struct imv_database_t imv_database_t;
/**
* IMV database interface
*/
struct imv_database_t {
/**
* Register or get a unique session ID using the TNCCS connection ID
*
* @param id TNCCS Connection ID
* @param ar_id_type Access Requestor identity type
* @param ar_id_value Access Requestor identity value
* @return Session ID or 0 if not available
*/
int (*get_session_id)(imv_database_t *this, TNC_ConnectionID id,
u_int32_t ar_id_type, chunk_t ar_id_value);
/**
* Add product information string to a session
*
* @param session_id Session ID
* @param product Product information string
* @return Product ID or 0 if not available
*/
int (*add_product)(imv_database_t *this, int session_id, char *product);
/**
* Add device identification to a session
*
* @param session_id Sessiion ID
* @param device Device identification
* @return Device ID or 0 if not available
*/
int (*add_device)(imv_database_t *this, int session_id, chunk_t device);
/**
* Get database handle
*
* @return Database handle
*/
database_t* (*get_database)(imv_database_t *this);
/**
* Destroys an imv_database_t object
*/
void (*destroy)(imv_database_t *this);
};
/**
* Create an imv_database_t instance
*
* @param uri database uri
*/
imv_database_t* imv_database_create(char *uri);
#endif /** IMV_DATABASE_H_ @}*/
+14
View File
@@ -94,6 +94,20 @@ struct imv_state_t {
*/
chunk_t (*get_ar_id)(imv_state_t *this, u_int32_t *id_type);
/**
* Set unique session ID
*
* @param session_id Unique session ID
*/
void (*set_session_id)(imv_state_t *this, int session_id);
/**
* Get unique session_id
*
* @return Unique session ID
*/
int (*get_session_id)(imv_state_t *this);
/**
* Change the connection state
*
+24 -20
View File
@@ -65,8 +65,6 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
TNC_Version max_version,
TNC_Version *actual_version)
{
char *uri;
if (imv_os)
{
DBG1(DBG_IMV, "IMV \"%s\" has already been initialized", imv_name);
@@ -84,13 +82,8 @@ TNC_Result TNC_IMV_Initialize(TNC_IMVID imv_id,
return TNC_RESULT_NO_COMMON_VERSION;
}
/* attach OS database */
uri = lib->settings->get_str(lib->settings,
"libimcv.plugins.imv-os.database", NULL);
if (uri)
{
os_db = imv_os_database_create(uri);
}
/* attach OS database co-located with IMV database */
os_db = imv_os_database_create(imv_os->get_database(imv_os));
return TNC_RESULT_SUCCESS;
}
@@ -289,7 +282,9 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
case ITA_ATTR_SETTINGS:
{
ita_attr_settings_t *attr_cast;
imv_database_t *imv_db;
enumerator_t *e;
int did;
char *name;
chunk_t value;
@@ -306,8 +301,13 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
else if ((streq(name, android_id_str) ||
streq(name, machine_id_str)) && os_db)
{
os_state->set_device_id(os_state,
os_db->get_device_id(os_db, value));
imv_db = imv_os->get_database(imv_os);
if (imv_db)
{
did = imv_db->add_device(imv_db,
state->get_session_id(state), value);
os_state->set_device_id(os_state, did);
}
}
DBG1(DBG_IMV, "setting '%s'\n %.*s",
name, value.len, value.ptr);
@@ -332,11 +332,19 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
{
os_type_t os_type;
ita_attr_get_settings_t *attr_cast;
imv_database_t *imv_db;
/* 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);
imv_db = imv_os->get_database(imv_os);
if (imv_db)
{
imv_db->add_product(imv_db, state->get_session_id(state),
os_state->get_info(os_state, NULL, NULL, NULL));
}
/* requesting installed packages */
os_state->set_package_request(os_state, TRUE);
attr = ietf_attr_attr_request_create(PEN_IETF,
@@ -376,10 +384,8 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
!os_state->get_angel_count(os_state) &&
os_state->get_info(os_state, NULL, NULL, NULL))
{
int device_id, count, count_update, count_blacklist, count_ok;
int count, count_update, count_blacklist, count_ok;
u_int os_settings;
u_int32_t id_type;
chunk_t id_value;
os_settings = os_state->get_os_settings(os_state);
os_state->get_count(os_state, &count, &count_update, &count_blacklist,
@@ -389,13 +395,10 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
count_ok, count - count_update - count_blacklist - count_ok);
/* Store device information in database */
device_id = os_state->get_device_id(os_state);
id_value = state->get_ar_id(state, &id_type);
if (os_db && device_id)
if (os_db)
{
os_db->set_device_info(os_db, device_id, id_type, id_value,
os_state->get_info(os_state, NULL, NULL, NULL),
count, count_update, count_blacklist, os_settings);
os_db->set_device_info(os_db, state->get_session_id(state),
count, count_update, count_blacklist, os_settings);
}
if (count_update || count_blacklist || os_settings)
@@ -589,6 +592,7 @@ TNC_Result TNC_IMV_Terminate(TNC_IMVID imv_id)
return TNC_RESULT_NOT_INITIALIZED;
}
DESTROY_IF(os_db);
os_db = NULL;
imv_os->destroy(imv_os);
imv_os = NULL;
+14 -116
View File
@@ -187,148 +187,46 @@ METHOD(imv_os_database_t, check_packages, status_t,
return status;
}
METHOD(imv_os_database_t, get_device_id, int,
private_imv_os_database_t *this, chunk_t value)
{
enumerator_t *e;
int id;
/* get primary key of device ID */
e = this->db->query(this->db, "SELECT id FROM devices WHERE value = ?",
DB_BLOB, value, DB_INT);
if (!e)
{
return 0;
}
if (e->enumerate(e, &id))
{
/* device ID already exists in database - return primary key */
e->destroy(e);
return id;
}
e->destroy(e);
/* register new device ID in database and return primary key */
return (this->db->execute(this->db, &id,
"INSERT INTO devices (value) VALUES (?)", DB_BLOB, value) == 1) ?
id : 0;
}
METHOD(imv_os_database_t, set_device_info, void,
private_imv_os_database_t *this, int device_id, u_int32_t ar_id_type,
chunk_t ar_id_value, char *os_info, int count, int count_update,
int count_blacklist, u_int flags)
private_imv_os_database_t *this, int session_id, int count,
int count_update, int count_blacklist, u_int flags)
{
enumerator_t *e;
time_t last_time;
int pid = 0, last_pid = 0, iid = 0, last_iid;
int last_count_update = 0, last_count_blacklist = 0;
u_int last_flags;
bool found = FALSE;
/* get primary key of OS info string if it exists */
e = this->db->query(this->db,
"SELECT id FROM products WHERE name = ?", DB_TEXT, os_info,
DB_INT);
if (e)
{
e->enumerate(e, &pid);
e->destroy(e);
}
/* if OS info string has not been found - register it */
if (!pid)
{
this->db->execute(this->db, &pid,
"INSERT INTO products (name) VALUES (?)", DB_TEXT, os_info);
}
/* get primary key of AR identity if it exists */
e = this->db->query(this->db,
"SELECT id FROM identities WHERE type = ? AND data = ?",
DB_INT, ar_id_type, DB_BLOB, ar_id_value, DB_INT);
if (e)
{
e->enumerate(e, &iid);
e->destroy(e);
}
/* if AR identity has not been found - register it */
if (!iid)
{
this->db->execute(this->db, &iid,
"INSERT INTO identities (type, data) VALUES (?, ?)",
DB_INT, ar_id_type, DB_BLOB, ar_id_value);
}
/* get latest device info record if it exists */
e = this->db->query(this->db,
"SELECT time, ar_id, product, count_update, count_blacklist, flags "
"FROM device_infos WHERE device = ? ORDER BY time DESC",
DB_INT, device_id, DB_INT, DB_INT, DB_INT, DB_INT, DB_INT, DB_UINT);
if (e)
{
found = e->enumerate(e, &last_time, &last_iid, &last_pid,
&last_count_update, &last_count_blacklist,
&last_flags);
e->destroy(e);
}
if (found && !last_count_update && !last_count_blacklist && !last_flags &&
iid == last_iid && pid == last_pid)
{
/* update device info */
this->db->execute(this->db, NULL,
"UPDATE device_infos SET time = ?, count = ?, count_update = ?, "
"count_blacklist = ?, flags = ? WHERE device = ? AND time = ?",
DB_UINT, time(NULL), DB_INT, count, DB_INT, count_update,
DB_INT, count_blacklist, DB_UINT, flags,
DB_INT, device_id, DB_UINT, last_time);
}
else
{
/* insert device info */
this->db->execute(this->db, NULL,
"INSERT INTO device_infos (device, time, ar_id, product, count, "
"count_update, count_blacklist, flags) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
DB_INT, device_id, DB_UINT, time(NULL), DB_INT, iid, DB_INT, pid,
DB_INT, count, DB_INT, count_update, DB_INT, count_blacklist,
DB_UINT, flags);
}
this->db->execute(this->db, NULL,
"INSERT INTO device_infos (session, count, count_update, "
"count_blacklist, flags) VALUES (?, ?, ?, ?, ?)",
DB_INT, session_id, DB_INT, count, DB_INT, count_update,
DB_INT, count_blacklist, DB_UINT, flags);
}
METHOD(imv_os_database_t, destroy, void,
private_imv_os_database_t *this)
{
this->db->destroy(this->db);
free(this);
}
/**
* See header
*/
imv_os_database_t *imv_os_database_create(char *uri)
imv_os_database_t *imv_os_database_create(imv_database_t *imv_db)
{
private_imv_os_database_t *this;
if (!imv_db)
{
return NULL;
}
INIT(this,
.public = {
.check_packages = _check_packages,
.get_device_id = _get_device_id,
.set_device_info = _set_device_info,
.destroy = _destroy,
},
.db = lib->db->create(lib->db, uri),
.db = imv_db->get_database(imv_db),
);
if (!this->db)
{
DBG1(DBG_IMV,
"failed to connect to OS database '%s'", uri);
free(this);
return NULL;
}
return &this->public;
}
+15 -26
View File
@@ -22,6 +22,7 @@
#define IMV_OS_DATABASE_H_
#include "imv_os_state.h"
#include "imv/imv_database.h"
#include <library.h>
@@ -42,32 +43,20 @@ struct imv_os_database_t {
enumerator_t *package_enumerator);
/**
* Get the primary database key of the device ID
*
* @param value Device ID value
*/
int (*get_device_id)(imv_os_database_t *this, chunk_t value);
* Set health infos for a given device
*
* @param sesson_id Session ID
* @param count Number of installed packages
* @param count_update Number of packages to be updated
* @param count_blacklist Number of blacklisted packages
* @param flags Various flags, e.g. illegal OS settings
*/
void (*set_device_info)(imv_os_database_t *this, int session_id, int count,
int count_update, int count_blacklist, u_int flags);
/**
* Set health infos for a given device
*
* @param device_id Device ID primary key
* @param ar_id_type Access Requestor ID Type
* @param ar_id_value Access Requestor ID Value
* @param os_info OS info string
* @param count Number of installed packages
* @param count_update Number of packages to be updated
* @param count_blacklist Number of blacklisted packages
* @param flags Various flags, e.g. illegal OS settings
*/
void (*set_device_info)(imv_os_database_t *this, int device_id,
u_int32_t ar_id_type, chunk_t ar_id_value,
char *os_info, int count, int count_update,
int count_blacklist, u_int flags);
/**
* Destroys an imv_os_database_t object.
*/
* Destroys an imv_os_database_t object.
*/
void (*destroy)(imv_os_database_t *this);
};
@@ -75,8 +64,8 @@ struct imv_os_database_t {
/**
* Create an imv_os_database_t instance
*
* @param uri database uri
* @param imv_db Already attached IMV database
*/
imv_os_database_t* imv_os_database_create(char *uri);
imv_os_database_t* imv_os_database_create(imv_database_t *imv_db);
#endif /** IMV_OS_DATABASE_H_ @}*/
+19
View File
@@ -71,6 +71,11 @@ struct private_imv_os_state_t {
*/
chunk_t ar_id_value;
/**
* Unique session ID
*/
int session_id;
/**
* IMV action recommendation
*/
@@ -346,6 +351,18 @@ METHOD(imv_state_t, get_ar_id, chunk_t,
return this->ar_id_value;
}
METHOD(imv_state_t, set_session_id, void,
private_imv_os_state_t *this, int session_id)
{
this->session_id = session_id;
}
METHOD(imv_state_t, get_session_id, int,
private_imv_os_state_t *this)
{
return this->session_id;
}
METHOD(imv_state_t, change_state, void,
private_imv_os_state_t *this, TNC_ConnectionState new_state)
{
@@ -633,6 +650,8 @@ imv_state_t *imv_os_state_create(TNC_ConnectionID connection_id)
.get_max_msg_len = _get_max_msg_len,
.set_ar_id = _set_ar_id,
.get_ar_id = _get_ar_id,
.set_session_id = _set_session_id,
.get_session_id = _get_session_id,
.change_state = _change_state,
.get_recommendation = _get_recommendation,
.set_recommendation = _set_recommendation,
@@ -68,6 +68,11 @@ struct private_imv_scanner_state_t {
*/
chunk_t ar_id_value;
/**
* Unique session ID
*/
int session_id;
/**
* IMV action recommendation
*/
@@ -182,6 +187,18 @@ METHOD(imv_state_t, set_ar_id, void,
this->ar_id_value = chunk_clone(id_value);
}
METHOD(imv_state_t, set_session_id, void,
private_imv_scanner_state_t *this, int session_id)
{
this->session_id = session_id;
}
METHOD(imv_state_t, get_session_id, int,
private_imv_scanner_state_t *this)
{
return this->session_id;
}
METHOD(imv_state_t, get_ar_id, chunk_t,
private_imv_scanner_state_t *this, u_int32_t *id_type)
{
@@ -296,6 +313,8 @@ imv_state_t *imv_scanner_state_create(TNC_ConnectionID connection_id)
.get_max_msg_len = _get_max_msg_len,
.set_ar_id = _set_ar_id,
.get_ar_id = _get_ar_id,
.set_session_id = _set_session_id,
.get_session_id = _get_session_id,
.change_state = _change_state,
.get_recommendation = _get_recommendation,
.set_recommendation = _set_recommendation,
@@ -68,6 +68,11 @@ struct private_imv_test_state_t {
*/
chunk_t ar_id_value;
/**
* Unique session ID
*/
int session_id;
/**
* IMV action recommendation
*/
@@ -170,6 +175,18 @@ METHOD(imv_state_t, get_ar_id, chunk_t,
return this->ar_id_value;
}
METHOD(imv_state_t, set_session_id, void,
private_imv_test_state_t *this, int session_id)
{
this->session_id = session_id;
}
METHOD(imv_state_t, get_session_id, int,
private_imv_test_state_t *this)
{
return this->session_id;
}
METHOD(imv_state_t, change_state, void,
private_imv_test_state_t *this, TNC_ConnectionState new_state)
{
@@ -307,6 +324,8 @@ imv_state_t *imv_test_state_create(TNC_ConnectionID connection_id)
.get_max_msg_len = _get_max_msg_len,
.set_ar_id = _set_ar_id,
.get_ar_id = _get_ar_id,
.set_session_id = _set_session_id,
.get_session_id = _get_session_id,
.change_state = _change_state,
.get_recommendation = _get_recommendation,
.set_recommendation = _set_recommendation,