summaryrefslogtreecommitdiff
path: root/accel-pppd/extra/net-snmp/statIPOE.c
blob: 24f154fd613f0fb27cf170c3f7288875d478128e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * Note: this file originally auto-generated by mib2c using
 *        : mib2c.int_watch.conf 13957 2005-12-20 15:33:08Z tanders $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>

#include "triton.h"
#include "statIPOE.h"

/*
 * The variables we want to tie the relevant OIDs to.
 * The agent will handle all GET and (if applicable) SET requests
 * to these variables automatically, changing the values as needed.
 */

void ipoe_get_stat(unsigned int **, unsigned int **);

static unsigned int *stat_starting;
static unsigned int *stat_active;

/*
 * Our initialization routine, called automatically by the agent
 * (Note that the function name must match init_FILENAME())
 */
void
init_statIPOE(void)
{
  netsnmp_handler_registration *reg;
  netsnmp_watcher_info         *winfo;

    static oid statIPOEStarting_oid[] = { 1,3,6,1,4,1,8072,100,1,6,1 };
    static oid statIPOEActive_oid[] = { 1,3,6,1,4,1,8072,100,1,6,2 };

  /*
   * a debugging statement.  Run the agent with -DstatIPOE to see
   * the output of this debugging statement.
   */
  DEBUGMSGTL(("statIPOE", "Initializing the statIPOE module\n"));

	if (!triton_module_loaded("ipoe"))
		return;

	ipoe_get_stat(&stat_starting, &stat_active);

    /*
     * Register scalar watchers for each of the MIB objects.
     * The ASN type and RO/RW status are taken from the MIB definition,
     * but can be adjusted if needed.
     *
     * In most circumstances, the scalar watcher will handle all
     * of the necessary processing.  But the NULL parameter in the
     * netsnmp_create_handler_registration() call can be used to
     * supply a user-provided handler if necessary.
     *
     * This approach can also be used to handle Counter64, string-
     * and OID-based watched scalars (although variable-sized writeable
     * objects will need some more specialised initialisation).
     */
    DEBUGMSGTL(("statIPOE",
                "Initializing statIPOEStarting scalar integer.  Default value = %d\n",
                0));
    reg = netsnmp_create_handler_registration(
             "statIPOEStarting", NULL,
              statIPOEStarting_oid, OID_LENGTH(statIPOEStarting_oid),
              HANDLER_CAN_RONLY);
    winfo = netsnmp_create_watcher_info(
                stat_starting, sizeof(*stat_starting),
                 ASN_INTEGER, WATCHER_FIXED_SIZE);
    if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
        snmp_log( LOG_ERR, "Failed to register watched statIPOEStarting" );
    }

    DEBUGMSGTL(("statIPOE",
                "Initializing statIPOEActive scalar integer.  Default value = %d\n",
                0));
    reg = netsnmp_create_handler_registration(
             "statIPOEActive", NULL,
              statIPOEActive_oid, OID_LENGTH(statIPOEActive_oid),
              HANDLER_CAN_RONLY);
    winfo = netsnmp_create_watcher_info(
                stat_active, sizeof(*stat_active),
                 ASN_INTEGER, WATCHER_FIXED_SIZE);
    if (netsnmp_register_watched_scalar( reg, winfo ) < 0 ) {
        snmp_log( LOG_ERR, "Failed to register watched statIPOEActive" );
    }


  DEBUGMSGTL(("statIPOE",
              "Done initalizing statIPOE module\n"));
}