and added files
[bcm963xx.git] / userapps / opensource / net-snmp / agent / mibgroup / snmpv3 / usmStats.c
1
2 /*
3  * usmStats.c: implements the usmStats portion of the SNMP-USER-BASED-SM-MIB 
4  */
5
6 #include <net-snmp/net-snmp-config.h>
7
8 #if HAVE_WINSOCK_H
9 #include <winsock.h>
10 #endif
11
12 #include <net-snmp/net-snmp-includes.h>
13 #include <net-snmp/agent/net-snmp-agent-includes.h>
14
15 #include "util_funcs.h"
16 #include "mibII/sysORTable.h"
17 #include "usmStats.h"
18
19 struct variable2 usmStats_variables[] = {
20     {USMSTATSUNSUPPORTEDSECLEVELS, ASN_COUNTER, RONLY, var_usmStats, 1,
21      {1}},
22     {USMSTATSNOTINTIMEWINDOWS, ASN_COUNTER, RONLY, var_usmStats, 1, {2}},
23     {USMSTATSUNKNOWNUSERNAMES, ASN_COUNTER, RONLY, var_usmStats, 1, {3}},
24     {USMSTATSUNKNOWNENGINEIDS, ASN_COUNTER, RONLY, var_usmStats, 1, {4}},
25     {USMSTATSWRONGDIGESTS, ASN_COUNTER, RONLY, var_usmStats, 1, {5}},
26     {USMSTATSDECRYPTIONERRORS, ASN_COUNTER, RONLY, var_usmStats, 1, {6}},
27 };
28
29 /*
30  * now load this mib into the agents mib table 
31  */
32 oid             usmStats_variables_oid[] = { 1, 3, 6, 1, 6, 3, 15, 1, 1 };
33
34
35 void
36 init_usmStats(void)
37 {
38 #ifdef USING_MIBII_SYSORTABLE_MODULE
39     static oid      reg[] = { 1, 3, 6, 1, 6, 3, 15, 2, 1, 1 };
40     register_sysORTable(reg, 10,
41                         "The management information definitions for the SNMP User-based Security Model.");
42 #endif
43
44     REGISTER_MIB("snmpv3/usmStats", usmStats_variables, variable2,
45                  usmStats_variables_oid);
46 }
47
48 u_char         *
49 var_usmStats(struct variable *vp,
50              oid * name,
51              size_t * length,
52              int exact, size_t * var_len, WriteMethod ** write_method)
53 {
54
55     /*
56      * variables we may use later 
57      */
58     static long     long_ret;
59     int             tmagic;
60
61     *write_method = 0;          /* assume it isnt writable for the time being */
62     *var_len = sizeof(long_ret);        /* assume an integer and change later if not */
63
64     if (header_generic(vp, name, length, exact, var_len, write_method))
65         return 0;
66
67     /*
68      * this is where we do the value assignments for the mib results. 
69      */
70     tmagic = vp->magic;
71     if ((tmagic >= 0)
72         && (tmagic <= (STAT_USM_STATS_END - STAT_USM_STATS_START))) {
73         long_ret = snmp_get_statistic(tmagic + STAT_USM_STATS_START);
74         return (unsigned char *) &long_ret;
75     }
76     return 0;
77 }