110 lines
3.4 KiB
C
110 lines
3.4 KiB
C
/*
|
|
* Note: this file originally auto-generated by mib2c using
|
|
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
|
|
*/
|
|
|
|
#include <net-snmp/net-snmp-config.h>
|
|
#include <net-snmp/net-snmp-includes.h>
|
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
#include "mirror-mib.h"
|
|
#include "mirror-nl-glue.h"
|
|
|
|
void
|
|
init_mirror_mib(void)
|
|
{
|
|
static oid cogentBytes_oid[] =
|
|
{ 1, 3, 6, 1, 4, 1, 27934, 2, 2, 1 };
|
|
static oid orionBytes_oid[] =
|
|
{ 1, 3, 6, 1, 4, 1, 27934, 2, 2, 2 };
|
|
static oid campusBytes_oid[] =
|
|
{ 1, 3, 6, 1, 4, 1, 27934, 2, 2, 3 };
|
|
|
|
DEBUGMSGTL(("mirror_mib", "Initializing\n"));
|
|
|
|
mirror_stats_initialize();
|
|
|
|
netsnmp_register_scalar(netsnmp_create_handler_registration
|
|
("cogentBytes", handle_cogentBytes,
|
|
cogentBytes_oid, OID_LENGTH(cogentBytes_oid),
|
|
HANDLER_CAN_RONLY));
|
|
netsnmp_register_scalar(netsnmp_create_handler_registration
|
|
("orionBytes", handle_orionBytes,
|
|
orionBytes_oid, OID_LENGTH(orionBytes_oid),
|
|
HANDLER_CAN_RONLY));
|
|
netsnmp_register_scalar(netsnmp_create_handler_registration
|
|
("campusBytes", handle_campusBytes,
|
|
campusBytes_oid, OID_LENGTH(campusBytes_oid),
|
|
HANDLER_CAN_RONLY));
|
|
}
|
|
|
|
void explode_counter64(uint64_t num, struct counter64 *counter) {
|
|
counter->low = num & 0xFFFFFFFF;
|
|
counter->high = (num >> 32) & 0xFFFFFFFF;
|
|
}
|
|
|
|
int
|
|
handle_cogentBytes(netsnmp_mib_handler *handler,
|
|
netsnmp_handler_registration *reginfo,
|
|
netsnmp_agent_request_info *reqinfo,
|
|
netsnmp_request_info *requests)
|
|
{
|
|
struct counter64 counter;
|
|
mirror_stats_refresh();
|
|
explode_counter64(get_class_byte_count(&cogent_class), &counter);
|
|
|
|
switch (reqinfo->mode) {
|
|
case MODE_GET:
|
|
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
|
|
(u_char *)&counter, sizeof(counter));
|
|
break;
|
|
default:
|
|
die("unknown mode");
|
|
}
|
|
|
|
return SNMP_ERR_NOERROR;
|
|
}
|
|
|
|
int
|
|
handle_orionBytes(netsnmp_mib_handler *handler,
|
|
netsnmp_handler_registration *reginfo,
|
|
netsnmp_agent_request_info *reqinfo,
|
|
netsnmp_request_info *requests)
|
|
{
|
|
struct counter64 counter;
|
|
mirror_stats_refresh();
|
|
explode_counter64(get_class_byte_count(&orion_class), &counter);
|
|
|
|
switch (reqinfo->mode) {
|
|
case MODE_GET:
|
|
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
|
|
(u_char *)&counter, sizeof(counter));
|
|
break;
|
|
default:
|
|
die("unknown mode");
|
|
}
|
|
|
|
return SNMP_ERR_NOERROR;
|
|
}
|
|
|
|
int
|
|
handle_campusBytes(netsnmp_mib_handler *handler,
|
|
netsnmp_handler_registration *reginfo,
|
|
netsnmp_agent_request_info *reqinfo,
|
|
netsnmp_request_info *requests)
|
|
{
|
|
struct counter64 counter;
|
|
mirror_stats_refresh();
|
|
explode_counter64(get_class_byte_count(&campus_class), &counter);
|
|
|
|
switch (reqinfo->mode) {
|
|
case MODE_GET:
|
|
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
|
|
(u_char *)&counter, sizeof(counter));
|
|
break;
|
|
default:
|
|
die("unknown mode");
|
|
}
|
|
|
|
return SNMP_ERR_NOERROR;
|
|
}
|