fix MEF URL
[public/mirror.git] / snmp / mirror-mib.c
1 /*
2  * Note: this file originally auto-generated by mib2c using
3  *        : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
4  */
5
6 #include <net-snmp/net-snmp-config.h>
7 #include <net-snmp/net-snmp-includes.h>
8 #include <net-snmp/agent/net-snmp-agent-includes.h>
9 #include "mirror-mib.h"
10 #include "mirror-nl-glue.h"
11
12 void
13 init_mirror_mib(void)
14 {
15     static oid      cogentBytes_oid[] =
16         { 1, 3, 6, 1, 4, 1, 27934, 2, 2, 1 };
17     static oid      orionBytes_oid[] =
18         { 1, 3, 6, 1, 4, 1, 27934, 2, 2, 2 };
19     static oid      campusBytes_oid[] =
20         { 1, 3, 6, 1, 4, 1, 27934, 2, 2, 3 };
21
22     DEBUGMSGTL(("mirror_mib", "Initializing\n"));
23
24     mirror_stats_initialize();
25
26     netsnmp_register_scalar(netsnmp_create_handler_registration
27                             ("cogentBytes", handle_cogentBytes,
28                              cogentBytes_oid, OID_LENGTH(cogentBytes_oid),
29                              HANDLER_CAN_RONLY));
30     netsnmp_register_scalar(netsnmp_create_handler_registration
31                             ("orionBytes", handle_orionBytes,
32                              orionBytes_oid, OID_LENGTH(orionBytes_oid),
33                              HANDLER_CAN_RONLY));
34     netsnmp_register_scalar(netsnmp_create_handler_registration
35                             ("campusBytes", handle_campusBytes,
36                              campusBytes_oid, OID_LENGTH(campusBytes_oid),
37                              HANDLER_CAN_RONLY));
38 }
39
40 void explode_counter64(uint64_t num, struct counter64 *counter) {
41     counter->low = num & 0xFFFFFFFF;
42     counter->high = (num >> 32) & 0xFFFFFFFF;
43 }
44
45 int
46 handle_cogentBytes(netsnmp_mib_handler *handler,
47                    netsnmp_handler_registration *reginfo,
48                    netsnmp_agent_request_info *reqinfo,
49                    netsnmp_request_info *requests)
50 {
51     struct counter64 counter;
52     mirror_stats_refresh();
53     explode_counter64(get_class_byte_count(&cogent_class), &counter);
54
55     switch (reqinfo->mode) {
56         case MODE_GET:
57             snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
58                     (u_char *)&counter, sizeof(counter));
59             break;
60         default:
61             die("unknown mode");
62     }
63
64     return SNMP_ERR_NOERROR;
65 }
66
67 int
68 handle_orionBytes(netsnmp_mib_handler *handler,
69                   netsnmp_handler_registration *reginfo,
70                   netsnmp_agent_request_info *reqinfo,
71                   netsnmp_request_info *requests)
72 {
73     struct counter64 counter;
74     mirror_stats_refresh();
75     explode_counter64(get_class_byte_count(&orion_class), &counter);
76
77     switch (reqinfo->mode) {
78         case MODE_GET:
79             snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
80                     (u_char *)&counter, sizeof(counter));
81             break;
82         default:
83             die("unknown mode");
84     }
85
86     return SNMP_ERR_NOERROR;
87 }
88
89 int
90 handle_campusBytes(netsnmp_mib_handler *handler,
91                    netsnmp_handler_registration *reginfo,
92                    netsnmp_agent_request_info *reqinfo,
93                    netsnmp_request_info *requests)
94 {
95     struct counter64 counter;
96     mirror_stats_refresh();
97     explode_counter64(get_class_byte_count(&campus_class), &counter);
98
99     switch (reqinfo->mode) {
100         case MODE_GET:
101             snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
102                     (u_char *)&counter, sizeof(counter));
103             break;
104         default:
105             die("unknown mode");
106     }
107
108     return SNMP_ERR_NOERROR;
109 }