NetBurner 3.5.7
PDF Version
Registering scalar (single-value) MIB variables

Bind one C getter/setter to one OID that ends in .0. More...

Classes

class  SNMPReadObject
 Registers a scalar read callback with the SNMP agent. More...
 
class  SNMPWriteObject
 Registers a scalar write callback with the SNMP agent. More...
 

Macros

#define SNMPREADFUNC(w, x, y, z, q)   static SNMPReadObject W##w(x, y, z, q);
 Register a read callback for one SNMP scalar at file scope.
 
#define SNMPWRITEFUNC(w, x, y, z, q)   static SNMPWriteObject R##w(x, y, z, q);
 Register a write callback for one SNMP scalar at file scope.
 

Detailed Description

Bind one C getter/setter to one OID that ends in .0.

Use SNMPREADFUNC for a read callback and SNMPWRITEFUNC for a write callback. The return type of the read callback (or the value parameter of the write callback) selects the ASN.1 encoding via the matching ASN_type* tag from SMI type aliases, ASN.1 tags, and SET return codes.

Macro Definition Documentation

◆ SNMPREADFUNC

#define SNMPREADFUNC ( w,
x,
y,
z,
q )   static SNMPReadObject W##w(x, y, z, q);

#include <snmp_table.h>

Register a read callback for one SNMP scalar at file scope.

Parameters
wBase identifier used to name the generated static instance.
xDotted-decimal OID string (scalars end in .0).
yOne of the ASN_type* tags (e.g. ASN_typeInteger32).
zPointer to the read callback (matching one of GetpIFunc etc.).
qCommunity mask, typically READ_COMMUNITY_MASK.

Expands to a file-static SNMPReadObject so the callback is registered before main() runs. Use once per scalar; pair with SNMPWRITEFUNC if the variable is writable.

Example
snmp_typeInteger32 ReadVoltage() { return g_voltage_mv; }
SNMPREADFUNC(VOLTAGE, "1.3.6.1.4.1.8174.10.1.0", ASN_typeInteger32,
ReadVoltage, READ_COMMUNITY_MASK);
#define READ_COMMUNITY_MASK
Bitmask indicating read community access.
Definition snmp.h:312
#define SNMPREADFUNC(w, x, y, z, q)
Register a read callback for one SNMP scalar at file scope.
Definition snmp_table.h:444
#define ASN_typeInteger32
Use with snmp_typeInteger32.
Definition snmp_table.h:139

◆ SNMPWRITEFUNC

#define SNMPWRITEFUNC ( w,
x,
y,
z,
q )   static SNMPWriteObject R##w(x, y, z, q);

#include <snmp_table.h>

Register a write callback for one SNMP scalar at file scope.

Parameters
wBase identifier used to name the generated static instance.
xDotted-decimal OID string (scalars end in .0).
yOne of the ASN_type* tags (e.g. ASN_typeInteger32).
zPointer to the write callback (matching one of PutpIFunc etc.).
qCommunity mask, typically WRITE_COMMUNITY_MASK.

Expands to a file-static SNMPWriteObject so the callback is registered before main() runs. The callback is invoked twice for each SET request: first with bTest != 0 for validation, then with bTest == 0 to commit. Return SNMP_SET_OK or SNMP_SET_FAIL.

Example
int WriteOutput(int var, int bTest) {
if (bTest) return (var == 0 || var == 1) ? SNMP_SET_OK : SNMP_SET_FAIL;
g_output_on = var;
return SNMP_SET_OK;
}
SNMPWRITEFUNC(OUTPUT, "1.3.6.1.4.1.8174.10.2.0", ASN_typeInteger32,
WriteOutput, WRITE_COMMUNITY_MASK);
#define WRITE_COMMUNITY_MASK
Bitmask indicating write community access.
Definition snmp.h:313
#define SNMPWRITEFUNC(w, x, y, z, q)
Register a write callback for one SNMP scalar at file scope.
Definition snmp_table.h:471
#define SNMP_SET_OK
Value is acceptable / applied successfully.
Definition snmp_table.h:90
#define SNMP_SET_FAIL
Value is invalid or the set cannot be applied.
Definition snmp_table.h:89