Add libtool-ltdl-devel as a prerequisite for building.
[freeradius.git] / src / include / radius_snmp.h
1 #ifndef _RADIUS_SNMP_H
2 #define _RADIUS_SNMP_H
3 /*
4  * Version:     $Id$
5  */
6 #ifdef WITH_SNMP
7
8 typedef enum smux_event_t {
9   SMUX_NONE, SMUX_CONNECT, SMUX_READ
10 } smux_event_t;
11
12 extern void radius_snmp_init(void);
13 extern int smux_connect(void);
14 extern int smux_read(void);
15
16 /*
17  *      The RADIUS server snmp data structures.
18  */
19 typedef struct rad_snmp_server_t {
20         const char      *ident;
21         time_t          start_time;
22         int32_t         uptime; /* in hundredths of a second */
23
24         time_t          last_reset_time;
25         int32_t         reset_time;
26         int32_t         config_reset;
27         int32_t         total_requests;
28         int32_t         total_invalid_requests;
29         int32_t         total_dup_requests;
30         int32_t         total_responses;
31         int32_t         total_access_accepts;
32         int32_t         total_access_rejects;
33         int32_t         total_access_challenges;
34         int32_t         total_malformed_requests;
35         int32_t         total_bad_authenticators;
36         int32_t         total_packets_dropped;
37         int32_t         total_no_records;
38         int32_t         total_unknown_types;
39 } rad_snmp_server_t;
40
41 typedef struct rad_snmp_t {
42         rad_snmp_server_t auth;
43         rad_snmp_server_t acct;
44         smux_event_t      smux_event;
45         const char        *smux_password;
46         int               snmp_write_access;
47         int               smux_fd;
48         int               smux_failures;
49         int               smux_max_failures;
50 } rad_snmp_t;
51
52 /*
53  *  Taken from RFC 2619 and RFC 2621
54  */
55 typedef struct rad_snmp_client_entry_t {
56         int             index;
57         /* IP address */
58         /* Client ID (string ) */
59         int             access_requests;
60         int             dup_access_requests;
61         int             access_accepts;
62         int             access_rejects;
63         int             access_challenges;
64         int             auth_malformed_requests;
65         int             auth_bad_authenticators;
66         int             auth_packets_dropped;
67         int             auth_unknown_types;
68         int             acct_packets_dropped;
69         int             acct_requests;
70         int             acct_dup_requests;
71         int             acct_responses;
72         int             acct_bad_authenticators;
73         int             acct_malformed_requests;
74         int             acct_no_records;
75         int             acct_unknown_types;
76 } rad_snmp_client_entry_t;
77
78 extern rad_snmp_t       rad_snmp;
79
80 #define RAD_SNMP_INC(_x) if (mainconfig.do_snmp) _x++
81 #define RAD_SNMP_TYPE_INC(_listener, _x) if (mainconfig.do_snmp) { \
82                                      if (_listener->type == RAD_LISTEN_AUTH) { \
83                                        rad_snmp.auth._x++; \
84                                      } else { if (_listener->type == RAD_LISTEN_ACCT) \
85                                        rad_snmp.acct._x++; } } \
86
87
88 #else
89 #define  RAD_SNMP_INC(_x)
90 #define RAD_SNMP_TYPE_INC(_listener, _x)
91
92 #endif /* WITH_SNMP */
93
94 #endif /* _RADIUS_SNMP_H */