SNMP Subagent Programmer's Guide
Programming Tutorials
SNMP Subagent Programmer’s Guide—119728 2-9
Hello World Program
MIB objects included in traps must have been defined earlier in the MIB definition. 
Note that helloPrintFreq is defined before the trap, helloFreqChange, in the Hello World 
MIB.
Mapping Objects to Variables
The EXTEND OBJECT-TYPE statements at the end of the MIB definition tell the run-
time library where in the subagent source code the value for MIB objects is maintained. 
These statements are examples of MIB constructs known as “extensions.” Extensions 
are embedded in your MIB definition to map MIB objects to structures in your subagent 
that contain the values of the MIB objects.
For example, the value of helloOutputText is maintained in a global C variable named 
helloText:
EXTEND OBJECT-TYPE helloOutputText
 WITH C_VARIABLE helloText
 IN C
You need to declare variables for MIB object values globally unless you have provided 
access functions in your subagent.  Refer to Section 4, “Writing Subagent Logic,” for 
complete information on variable declarations and access functions.
As Section 3, “Writing and Compiling MIBs,” describes, you can segregate extensions 
from MIB object definitions, as in the Hello World MIB, or you can embed extensions 
within a MIB object definition. In the latter case, the definition for helloOutputText 
would look like this:
helloOutputText OBJECT-TYPE
 SYNTAX DisplayString (SIZE (0..255))
 ACCESS read-write
 C_VARIABLE helloText
 STATUS mandatory
 DESCRIPTION
 "The textual message that is displayed to stdout
 by the Hello World program."
 ::= { hello 1 }
Isolating the extensions is the recommended approach, because this practice makes 
installing your MIB on manager stations easier.
Installing the MIB
Before using a manager to interact with an executing subagent, you compile its MIB 
definition on any manager station to be used to interact with the subagent. Different 
managers have different requirements for MIB installation. You have to modify your 
MIB definition slightly to accommodate a manager’s requirements.  










