Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / agent / mibgroup / snmpv3 / snmpMPDStats.c
1 /*
2  * snmpMPDStats.c: tallies errors for SNMPv3 message processing. 
3  */
4
5 #include <net-snmp/net-snmp-config.h>
6
7 #if HAVE_WINSOCK_H
8 #include <winsock.h>
9 #endif
10
11 #include <net-snmp/net-snmp-includes.h>
12 #include <net-snmp/agent/net-snmp-agent-includes.h>
13
14 #include "mibII/sysORTable.h"
15 #include "snmpMPDStats.h"
16 #include "util_funcs.h"
17
18
19 struct variable2 snmpMPDStats_variables[] = {
20     {SNMPUNKNOWNSECURITYMODELS, ASN_COUNTER, RONLY, var_snmpMPDStats, 1,
21      {1}},
22     {SNMPINVALIDMSGS, ASN_COUNTER, RONLY, var_snmpMPDStats, 1, {2}},
23     {SNMPUNKNOWNPDUHANDLERS, ASN_COUNTER, RONLY, var_snmpMPDStats, 1, {3}},
24 };
25
26 /*
27  * now load this mib into the agents mib table 
28  */
29 oid             snmpMPDStats_variables_oid[] =
30     { 1, 3, 6, 1, 6, 3, 11, 2, 1 };
31
32 void
33 init_snmpMPDStats(void)
34 {
35 #ifdef USING_MIBII_SYSORTABLE_MODULE
36     static oid      reg[] = { 1, 3, 6, 1, 6, 3, 11, 3, 1, 1 };
37     register_sysORTable(reg, 10,
38                         "The MIB for Message Processing and Dispatching.");
39 #endif
40
41     REGISTER_MIB("snmpv3/snmpMPDStats", snmpMPDStats_variables, variable2,
42                  snmpMPDStats_variables_oid);
43 }
44
45 u_char         *
46 var_snmpMPDStats(struct variable *vp,
47                  oid * name,
48                  size_t * length,
49                  int exact, size_t * var_len, WriteMethod ** write_method)
50 {
51
52     /*
53      * variables we may use later 
54      */
55     static long     long_ret;
56     int             tmagic;
57
58
59     *write_method = 0;          /* assume it isnt writable for the time being */
60     *var_len = sizeof(long_ret);        /* assume an integer and change later if not */
61
62     if (header_generic(vp, name, length, exact, var_len, write_method))
63         return 0;
64
65     /*
66      * this is where we do the value assignments for the mib results. 
67      */
68     tmagic = vp->magic;
69     if ((tmagic >= 0)
70         && (tmagic <= (STAT_MPD_STATS_END - STAT_MPD_STATS_START))) {
71         long_ret = snmp_get_statistic(tmagic + STAT_MPD_STATS_START);
72         return (unsigned char *) &long_ret;
73     }
74     return 0;
75 }