added option to send statistics periodically to sec-mod

This commit is contained in:
Nikos Mavrogiannopoulos
2014-12-10 10:15:02 +01:00
parent ed5b177691
commit 35e93c6341
9 changed files with 96 additions and 11 deletions

View File

@@ -249,6 +249,42 @@ int process_packet(void *pool, sec_mod_st * sec, cmd_request_t cmd,
return ret;
case SM_CMD_CLI_STATS:{
CliStatsMsg *tmsg;
client_entry_st *e;
tmsg = cli_stats_msg__unpack(&pa, data.size, data.data);
if (tmsg == NULL) {
seclog(sec, LOG_ERR, "error unpacking data");
ret = ERR_BAD_COMMAND;
return -1;
}
if (tmsg->has_sid == 0 || tmsg->sid.len != SID_SIZE) {
cli_stats_msg__free_unpacked(tmsg, &pa);
seclog(sec, LOG_INFO, "error in SID received by client (size: %d)",
(int)tmsg->sid.len);
return -1;
}
e = find_client_entry(sec, tmsg->sid.data);
if (e == NULL) {
cli_stats_msg__free_unpacked(tmsg, &pa);
seclog(sec, LOG_INFO, "session stats received with non-existing sid!");
return -1;
}
cli_stats_msg__free_unpacked(tmsg, &pa);
if (e->status != PS_AUTH_COMPLETED) {
seclog(sec, LOG_ERR, "session stats received in unauthenticated client!");
return -1;
}
e->bytes_in = tmsg->bytes_in;
e->bytes_out = tmsg->bytes_out;
}
break;
case SM_CMD_AUTH_INIT:{
SecAuthInitMsg *auth_init;