From 5227b247c8b6da5b07d5e1a4541e59be3ed32346 Mon Sep 17 00:00:00 2001 From: Daniel Gollub Date: Mon, 11 Nov 2019 15:07:38 +0100 Subject: DANOS Import --- tacplus-daemon/statistics.c | 134 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 tacplus-daemon/statistics.c (limited to 'tacplus-daemon/statistics.c') diff --git a/tacplus-daemon/statistics.c b/tacplus-daemon/statistics.c new file mode 100644 index 0000000..c644aca --- /dev/null +++ b/tacplus-daemon/statistics.c @@ -0,0 +1,134 @@ +/* + TACACS+ D-Bus Daemon code + + Copyright (c) 2019 AT&T Intellectual Property. + Copyright (c) 2015-2016 Brocade Communications Systems, Inc. + + SPDX-License-Identifier: GPL-2.0-only +*/ + +#include "statistics.h" + +static struct statistics **stats; +static int created = 0; + +int create_statistics(int n) +{ + int i; + int ret = 0; + + if(!created) { + stats = malloc(sizeof(*stats) * n); + + if(!stats) + return -1; + + for(i=0; iauthen_requests++; +} + +void inc_authen_replies(int i) +{ + stats[i]->authen_replies++; +} + +void inc_author_requests(int i) +{ + stats[i]->author_requests++; +} + +void inc_author_replies(int i) +{ + stats[i]->author_replies++; +} + +void inc_acct_requests(int i) +{ + stats[i]->acct_requests++; +} + +void inc_acct_replies(int i) +{ + stats[i]->acct_replies++; +} + +void inc_unknown_replies(int i) +{ + stats[i]->unknown_replies++; +} + +void inc_failed_connects(int i) +{ + stats[i]->failed_connects++; +} + +int get_authen_requests(int i) +{ + return stats[i]->authen_requests; +} + +int get_authen_replies(int i) +{ + return stats[i]->authen_replies; +} + +int get_author_requests(int i) +{ + return stats[i]->author_requests; +} + +int get_author_replies(int i) +{ + return stats[i]->author_replies; +} + +int get_acct_requests(int i) +{ + return stats[i]->acct_requests; +} + +int get_acct_replies(int i) +{ + return stats[i]->acct_replies; +} + +int get_failed_connects(int i) +{ + return stats[i]->failed_connects; +} + +int get_unknown_replies(int i) +{ + return stats[i]->unknown_replies; +} + +void free_statistics() +{ + int i; + + if (created) { + for(i=0; i