blob: c644aca9435c5c8f7f4d2845ead4e2fc5ca25970 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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; i<n ; i++) {
stats[i] = calloc(1, sizeof(**stats));
if(!stats[i]) {
free_statistics();
return -1;
}
created++;
}
}
return ret;
}
void inc_authen_requests(int i)
{
stats[i]->authen_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<created ; i++) {
free(stats[i]);
}
}
free(stats);
stats = NULL;
created = 0;
}
|