SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-121
SNMPHOST Source Code
SNMPHOST Source Code
The source code of SNMPHOST defines and calls the functions declared in snmphosh to
construct and parse packets and calls functions defined in snmpfsc to perform activities
related to packet encoding, decoding, and transport. Figure 2-4
summarizes the calling
sequence.
Figure 2-4. Logic Flow of SNMPHOST
209
SNMP_Init_()
Determine protocol to use
Start
SNMP_Open_()
Initiate communication with agent
InitDevTable()
Allocate pointer array memory
GetHostDevices()
Retrieve device information
DisplayHostDevices()
Print device information
AllocateDevEntry()
Allocate DEV_ENTRY_T memory
SNMP_Create_Request()
oidstring2oid()
SNMP_Bind_Null()
Create GetNext packets for hrDeviceTable
Send requests and receive responses
SNMP_WriteRead_()
oidcmp2()
Ensure objects are from hrDeviceTable
GetAuxDeviceTbl()
Retrieve additional device information Create Get packet
SNMP_Create_Request()
oidstring2oid()
SNMP_Bind_Null()
Send request and receive response
SNMP_WriteRead_()
SetCpuLoad()
SetPrinterStatus()
SetDiskCapacity()
Save MIB object values
dev_status_to_str()
prn_status_to_str()
GetCpuLoad()
GetPrinterStatus()
GetDiskCapacity()
Read and format values
SNMP_Close_()
Terminate communication with agent
Stop