~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/target/target_counters.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-09-13 12:06:21 UTC
  • Revision ID: james.westby@ubuntu.com-20040913120621-g952ntonlleihcvm
Tags: upstream-5.1.1
ImportĀ upstreamĀ versionĀ 5.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <net-snmp/net-snmp-config.h>
 
2
 
 
3
#if HAVE_STRING_H
 
4
#include <string.h>
 
5
#else
 
6
#include <strings.h>
 
7
#endif
 
8
 
 
9
#include <net-snmp/net-snmp-includes.h>
 
10
#include <net-snmp/agent/net-snmp-agent-includes.h>
 
11
 
 
12
#include "target_counters.h"
 
13
#include <net-snmp/agent/instance.h>
 
14
 
 
15
static oid      unavailable_context_oid[] =
 
16
    { 1, 3, 6, 1, 6, 3, 12, 1, 4, 0 };
 
17
static oid      unknown_context_oid[] = { 1, 3, 6, 1, 6, 3, 12, 1, 5, 0 };
 
18
 
 
19
void
 
20
init_target_counters(void)
 
21
{
 
22
    DEBUGMSGTL(("target_counters", "initializing\n"));
 
23
 
 
24
    /*
 
25
     * unknown contexts
 
26
     */
 
27
 
 
28
    netsnmp_register_read_only_instance(netsnmp_create_handler_registration
 
29
                                        ("myInstance",
 
30
                                         get_unknown_context_count,
 
31
                                         unknown_context_oid,
 
32
                                         sizeof(unknown_context_oid) /
 
33
                                         sizeof(oid), HANDLER_CAN_RONLY));
 
34
 
 
35
    /*
 
36
     * unavailable available
 
37
     */
 
38
 
 
39
    netsnmp_register_read_only_instance(netsnmp_create_handler_registration
 
40
                                        ("myInstance",
 
41
                                         get_unavailable_context_count,
 
42
                                         unavailable_context_oid,
 
43
                                         sizeof(unavailable_context_oid) /
 
44
                                         sizeof(oid), HANDLER_CAN_RONLY));
 
45
 
 
46
}
 
47
 
 
48
int
 
49
get_unknown_context_count(netsnmp_mib_handler *handler,
 
50
                          netsnmp_handler_registration *reginfo,
 
51
                          netsnmp_agent_request_info *reqinfo,
 
52
                          netsnmp_request_info *requests)
 
53
{
 
54
    /*
 
55
     * we're only called for GETs of the right node, so this is easy: 
 
56
     */
 
57
 
 
58
    u_long          long_ret =
 
59
        snmp_get_statistic(STAT_SNMPUNKNOWNCONTEXTS);
 
60
    snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
 
61
                             (u_char *) & long_ret, sizeof(long_ret));
 
62
    return SNMP_ERR_NOERROR;
 
63
}
 
64
 
 
65
 
 
66
int
 
67
get_unavailable_context_count(netsnmp_mib_handler *handler,
 
68
                              netsnmp_handler_registration *reginfo,
 
69
                              netsnmp_agent_request_info *reqinfo,
 
70
                              netsnmp_request_info *requests)
 
71
{
 
72
    /*
 
73
     * we're only called for GETs of the right node, so this is easy: 
 
74
     */
 
75
 
 
76
    u_long          long_ret =
 
77
        snmp_get_statistic(STAT_SNMPUNAVAILABLECONTEXTS);
 
78
    snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
 
79
                             (u_char *) & long_ret, sizeof(long_ret));
 
80
    return SNMP_ERR_NOERROR;
 
81
}