Commit 4e631f44 authored by Alessandro Rubini's avatar Alessandro Rubini

snmp library: a little cleanup

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 8c75e089
......@@ -6,9 +6,7 @@
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* The sub-init functions */
#include "wrsScalar.h"
#include "wrsPstats.h"
#include "wrsVersion.h"
#include "wrsSnmp.h"
void
init_wrsSnmp(void)
......
......@@ -8,7 +8,7 @@
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/agent/auto_nlist.h>
#include "wrsPstats.h"
#include "wrsSnmp.h"
#include <stdarg.h>
static FILE *logf;
......@@ -137,7 +137,7 @@ wrsPstats_handler(netsnmp_mib_handler *handler,
logmsg("%s: %i\n", __func__, __LINE__);
/* our "context" is the counter number; "subid" the column i.e. the port */
counter = (int)netsnmp_extract_iterator_context(request);
counter = (intptr_t)netsnmp_extract_iterator_context(request);
table_info = netsnmp_extract_table_info(request);
wrport = table_info->colnum - 2; /* port is 0-based and position 1 is the string */
......@@ -240,7 +240,7 @@ wrsPstats_load(netsnmp_cache *cache, void *vmagic)
void
init_wrsPstats(void)
{
const oid wrsPstats_oid[] = { 1, 3, 6, 1, 4, 1, 96, 100, 2 };
const oid wrsPstats_oid[] = { WRS_OID, 2 };
netsnmp_table_registration_info *table_info;
netsnmp_iterator_info *iinfo;
......
#ifndef _PSTATSTABLE_H
#define _PSTATSTABLE_H
extern void init_wrsPstats(void);
#endif /* _PSTATSTABLE_H */
......@@ -6,28 +6,12 @@
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "wrsScalar.h"
#include "wrsSnmp.h"
#include <stdint.h>
static uint32_t fakeStatValue;
/** Initializes the wrsScalar module */
void
init_wrsScalar(void)
{
const oid wrsScalarOne_oid[] =
{ 1, 3, 6, 1, 4, 1, 96, 100, 1, 1 };
DEBUGMSGTL(("wrsScalar", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("wrsScalarOne", handle_wrsScalarOne,
wrsScalarOne_oid,
OID_LENGTH(wrsScalarOne_oid),
HANDLER_CAN_RWRITE));
}
int
static int
handle_wrsScalarOne(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
......@@ -96,3 +80,19 @@ handle_wrsScalarOne(netsnmp_mib_handler *handler,
return SNMP_ERR_NOERROR;
}
/** Initializes the wrsScalar module */
void
init_wrsScalar(void)
{
const oid wrsScalarOne_oid[] = { WRS_OID, 1 };
DEBUGMSGTL(("wrsScalar", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("wrsScalarOne", handle_wrsScalarOne,
wrsScalarOne_oid,
OID_LENGTH(wrsScalarOne_oid),
HANDLER_CAN_RWRITE));
}
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 17798 2009-10-27 06:44:54Z magfr $
*/
#ifndef WRSSCALAR_H
#define WRSSCALAR_H
/*
* function declarations
*/
void init_wrsScalar(void);
Netsnmp_Node_Handler handle_wrsScalarOne;
#endif /* WRSSCALAR_H */
#ifndef WRS_SNMP_H
#define WRS_SNMP_H
/* be safe, in case some other header had them slightly differntly */
#undef container_of
#undef offsetof
#undef ARRAY_SIZE
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define WRS_N_PORTS 18
/* Scalar is just a stupid thing, but let's keep it */
extern void init_wrsScalar(void);
/* Real stuff follows */
extern void init_wrsPstats(void);
extern void init_wrsPpsi(void);
extern void init_wrsVersion(void);
#define WRS_OID 1, 3, 6, 1, 4, 1, 96, 100
#endif /* WRS_SNMP_H */
......@@ -9,7 +9,7 @@
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/agent/auto_nlist.h>
#include "wrsVersion.h"
#include "wrsSnmp.h"
/* Our structure for caching data */
#define VERSION_N_STRINGS 6 /* sw, 3 gw, 2 hw */
......@@ -48,8 +48,7 @@ void
init_wrsVersion(void)
{
const oid wrsVersion_oid[] = { WRS_VERSION_OID };
const oid wrsVersion_oid[] = { WRS_OID, 4 };
netsnmp_handler_registration *hreg;
/* FIXME.... */
......
#ifndef _PSTATSTABLE_H
#define _PSTATSTABLE_H
#define WRS_VERSION_OID 1, 3, 6, 1, 4, 1, 96, 100, 4
extern void init_wrsVersion(void);
#endif /* _PSTATSTABLE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment