add overall recommendation to session database entry

This commit is contained in:
Andreas Steffen
2013-06-21 23:25:22 +02:00
parent 4f6bf1a843
commit 2964562199
6 changed files with 75 additions and 38 deletions
+11
View File
@@ -189,6 +189,16 @@ METHOD(imv_database_t, add_device, int,
return did;
}
METHOD(imv_database_t, add_recommendation, void,
private_imv_database_t *this, imv_session_t *session,
TNC_IMV_Action_Recommendation rec)
{
/* add final recommendation to session */
this->db->execute(this->db, NULL,
"UPDATE sessions SET rec = ? WHERE id = ?",
DB_INT, rec, DB_INT, session->get_session_id(session));
}
METHOD(imv_database_t, policy_script, bool,
private_imv_database_t *this, imv_session_t *session, bool start)
{
@@ -322,6 +332,7 @@ imv_database_t *imv_database_create(char *uri, char *script)
.get_session = _get_session,
.add_product = _add_product,
.add_device = _add_device,
.add_recommendation = _add_recommendation,
.policy_script = _policy_script,
.finalize_workitem = _finalize_workitem,
.get_database = _get_database,
+9
View File
@@ -68,6 +68,15 @@ struct imv_database_t {
int (*add_device)(imv_database_t *this, imv_session_t *session,
chunk_t device);
/**
* Add final recommendation to a session database entry
*
* @param session Session
* @param rec Final recommendation
*/
void (*add_recommendation)(imv_database_t *this, imv_session_t *session,
TNC_IMV_Action_Recommendation rec);
/**
* Announce session start/stop to policy script
*
+2 -11
View File
@@ -63,7 +63,8 @@ CREATE TABLE sessions (
connection INTEGER NOT NULL,
identity INTEGER DEFAULT 0 REFERENCES identities(id),
device INTEGER DEFAULT 0 REFERENCES devices(id),
product INTEGER DEFAULT 0 REFERENCES products(id)
product INTEGER DEFAULT 0 REFERENCES products(id),
rec INTEGER DEFAULT 3
);
DROP TABLE IF EXISTS workitems;
@@ -150,16 +151,6 @@ CREATE INDEX devices_value ON devices (
value
);
DROP TABLE IF EXISTS device_infos;
CREATE TABLE device_infos (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
session INTEGER NOT NULL REFERENCES sessions(id),
count INTEGER DEFAULT 0,
count_update INTEGER DEFAULT 0,
count_blacklist INTEGER DEFAULT 0,
flags INTEGER DEFAULT 0
);
DROP TABLE IF EXISTS identities;
CREATE TABLE identities (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,