SNMP Subagent Programmer's Guide
MIB Variable Declarations
4-4 119728—SNMP Subagent Programmer’s Guide
Writing Subagent Logic
Variable-length data is modeled as struct octet_string data that looks like this:
The subagent must allocate memory for the data portion of this structure. Ensure that
enough data space is allocated to hold the maximum length of data. For example, the
Hello World program uses a variable-length MIB object, helloOutputText, defined as
follows in the MIB definition:
helloOutputText OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"The textual message that is displayed to stdout
by the Hello World program."
::= { hello 1 }
...
EXTEND OBJECT-TYPE helloOutputText
WITH C_VARIABLE helloText
IN C
Hello World declares the variable that holds helloOutputText as a global variable named
helloText, using the typedef construct named DisplayString:
static char text[256] = {DEF_TEXT}
static DisplayString helloText = {sizeof(DEF_TEXT)-1,
(ubyte *) text};
length
value
data
€ €
€
401