SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-70
SNMPSET
Example 2-9 illustrates the contents of snmpsetc, the source code file for the main block
of SNMPSET. Numbers in the example correspond to numbers in the observations
made between here and the example.
1. Variables for handling the value of MIB objects of type OBJECT_IDENTIFIER are
declared.
2. The following local declarations are in addition to those used for SNMPGET:
3. If the -l startup parameter was specified at invocation, longform is assigned the value
1 when parsing invocation line arguments.
4. In the for loop that extracts OIDs from the invocation line arguments, any data type
entered is stored in typestr and the value entered is stored in valstr.
5. SNMP_Init_() is called.
6. SNMP_Open_() is called.
7. A packet is initialized to handle the Set request.
8. This for loop assigns variable bindings to the Set packet.
9. If -l was specified in the invocation line, the common utility function str_to_type() is
used to validate whether the type specified is one of the valid SNMP data types.
10. The common utility function oid_to_namerec() is used to obtain the Manager
Services representation of the data type of MIB-II objects.
host3 A pointer to the host interface structure used by functions in
snmpfsc; used for binding values of type IpAddress.
ipaddr A variable for the value of a MIB object of type IpAddress.
longform A variable for determining whether the -l parameter was
specified at invocation.
mibtype A variable used when validating the SNMP data type of the
target MIB object.
p A pointer to a structure describing a MIB-II object’s name,
OID, and data type.
peertype A variable used when validating the SNMP data type of the
target MIB object.
typestr A variable for the data type of a non-MIB-II object.
valstr The value to assign the MIB object.