| 1 |
/* |
| 2 |
* usmStats.c: implements the usmStats portion of the SNMP-USER-BASED-SM-MIB |
| 3 |
*/ |
| 4 |
|
| 5 |
#include <net-snmp/net-snmp-config.h> |
| 6 |
|
| 7 |
#include <net-snmp/net-snmp-features.h> |
| 8 |
|
| 9 |
#include <net-snmp/net-snmp-includes.h> |
| 10 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 11 |
#include <net-snmp/agent/sysORTable.h> |
| 12 |
|
| 13 |
#include "usmStats.h" |
| 14 |
|
| 15 |
#include <net-snmp/agent/snmp_get_statistic.h> |
| 16 |
|
| 17 |
#define snmpUsmMIB 1, 3, 6, 1, 6, 3, 15 |
| 18 |
#define usmMIBCompliances snmpUsmMIB, 2, 1 |
| 19 |
|
| 20 |
static oid usmStats[] = { snmpUsmMIB, 1, 1 }; |
| 21 |
|
| 22 |
static netsnmp_handler_registration* usmStats_reg = NULL; |
| 23 |
static oid usmMIBCompliance[] = { usmMIBCompliances, 1 }; |
| 24 |
|
| 25 |
netsnmp_feature_require(helper_statistics); |
| 26 |
|
| 27 |
void |
| 28 |
init_usmStats(void) |
| 29 |
{ |
| 30 |
netsnmp_handler_registration* s = |
| 31 |
netsnmp_create_handler_registration( |
| 32 |
"usmStats", NULL, usmStats, OID_LENGTH(usmStats), |
| 33 |
HANDLER_CAN_RONLY); |
| 34 |
if (s && |
| 35 |
NETSNMP_REGISTER_STATISTIC_HANDLER(s, 1, USM) == MIB_REGISTERED_OK) { |
| 36 |
REGISTER_SYSOR_ENTRY(usmMIBCompliance, |
| 37 |
"The management information definitions for the " |
| 38 |
"SNMP User-based Security Model."); |
| 39 |
usmStats_reg = s; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
void |
| 44 |
shutdown_usmStats(void) |
| 45 |
{ |
| 46 |
UNREGISTER_SYSOR_ENTRY(usmMIBCompliance); |
| 47 |
if (usmStats_reg) { |
| 48 |
netsnmp_unregister_handler(usmStats_reg); |
| 49 |
usmStats_reg = NULL; |
| 50 |
} |
| 51 |
} |