SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-124
SNMPHOST Source Code
19. The OID for hrDeviceType is prepared and bound to the request packet.
20. The OID for hrDeviceDescr is prepared and bound.
21. The OID for hrDeviceStatus is prepared and bound.
22. A while loop continues to send GetNext packets and process response packets as
long as the value of bMoreEntries is 1.
23. A for loop uses the retry counter to encode, transmit, receive, and decode a
GetNext packet, using SNMP_WriteRead_() and resets the request ID to 1 if it has
reached MAX_REQID_VALUE. The response packet is received into ebuff and
decoded into recv_pkt.
24. The memory used for the request packet is deallocated, and the descriptors for ebuff
are reset.
25. The contents of the response packet are saved in pkt for parsing.
26. Four of the response packet fields are assigned new values in preparation for using
the packet as the next GetNext packet.
27. The oidcmp2() function is used to determine whether the OID of the first variable
binding in the response is within the range of hrDeviceTable OIDs.
28. If the value of the first variable binding is a number, as hrDeviceIndex values should
be, it is saved in the nDeviceIndex field of the current DEV_ENTRY_T structure.
29. The second variable binding in the response is processed. If its value is an OID, as
hrDeviceType values should be, it, too, is saved.
30. The third variable binding, expected to be hrDeviceDescr, is likewise processed.
31. The value of the final variable binding, hrDeviceStatus, is saved.
32. GetAuxDeviceTbl() is called to retrieve an additional MIB object value for the
current device.
33. The value of the index into pptable is incremented in preparation for saving
information for the next device. If the value of nCurrDevIndex is equal to or greater
than the number of devices for which information is sought, the while loop
terminates.
34. The packet memory used for the string value of hrDeviceDescr is prepared for
another GetNext request operation.
35. Before completing, GetHostDevices() releases memory allocated for pkt and returns
the value of nCurrDevIndex, used subsequently to indicate the number of
DEV_ENTRY_T structures to read, format, and display.
36. GetAuxDeviceTbl() retrieves a value from the hrProcessorTable, the hrPrinterTable,
or the hrDiskStorageTable when the device currently being handled by
GetHostDevices() is a processor, printer, or disk, respectively. Except for the
number of devices, it accepts the same parameters as GetHostDevices(), and it
returns an integer describing the outcome of its operations (0 if successful).