snmpGetnext()--Retrieve Next MIB Object


  Syntax
 #include <qtomeapi.h>

 int snmpGetnext(snmppdu  *         pdu_ptr,   
              char  *            host_ptr,
              unsigned long int  time_out,
              char  *            comm_ptr,
              unsigned long int  comm_len);

  Service Program Name: QTOMEAPI

  Default Public Authority: *USE

  Threadsafe: No

An SNMP managing application uses the snmpGetnext() function to get the value of one or more management information base (MIB) objects from an SNMP agent or subagent on a local or remote system. The snmpGetnext() function gets the value of the object instance that is next in lexicographic order.

Parameters

pdu_ptr
(Input) A pointer to a structure of the protocol data unit (PDU) type as defined in the <qtomeapi.h> file.

This structure contains the PDU type (GET NEXT in this instance), the error status, the error index, and the pointer to the varbind structure.

The varbind structure (found in the qtomeapi.h file) consists of the following:

struct _varBind{
   struct _varBind * next;
   char   *oid;                          /* Null Terminated */
   unsigned char asn_type;
   int    val_len;
   union {
      int  * int_val;
      char * str_val;
   } val;
};

The fields for this structure are described as follows:


host_ptr
(Input) A pointer to the character string that contains the Internet Protocol (IP) address. The internet address may be an IPv4 or IPv6 address.

An IPv4 internet address is specified in the form nnn.nnn.nnn.nnn, where nnn is a decimal number ranging from 0 through 255. An IPv4 internet address is not valid if it has a value of all binary ones or all binary zeros for the network identifier (ID) portion or the host ID portion of the address.

An IPv6 internet address is specified in the form x:x:x:x:x:x:x:x, where x is a hexadecimal number ranging from 0 through X'FFFF'. "::" may be used once in the IPv6 address to indicate one or more groups of 16 bits of zeros. The "::" may be used to compress leading, imbedded, or trailing zeros in the address.

This parameter can also be stored in host address format, that is, mycompany.com. This parameter must contain printable characters only.

time_out
(Input) The time-out value.

This parameter is the amount of time in seconds that the management application is willing to wait for the response PDU. The minimum value is 1, and the maximum is 100.

comm_ptr
(Input) A pointer to the character string that contains the community name.

This parameter contains a variable-length field that contains printable and nonprintable values. Therefore, the user must supply the exact length of this value in another parameter. EBCDIC-to-ASCII translation will not be done, and it is the responsibility of the managing application to specify the community name in the correct notation for the SNMP agent system.

comm_len
(Input) The length of the community name.

This parameter is the exact length of the community name. The minimum value is 1, and the maximum is 255.


Authorities

Service Program Authority
*USE

Return Value

The following are the possible return codes posted by the snmpGetnext() function:

For more information, see the Simple Network Management Protocol (SNMP) SupportLink to PDF manual.


Error Conditions

Following are the possible error statuses returned in the error status field of the PDU structure. These values are returned by the SNMP agents.


Usage Notes

The area where the data is returned is the responsibility of the user, not the API. To allocate storage, the user may use the AddVarbind routine (see AddVarbind Routine). To deallocate storage, the user may use the FreePdu routine (see FreePdu Routine).

You must use the correct PDU type on AddVarbind. It must match the operation on which you call. For example, if you build a PDU wherein AddVarbind passes a PDU type of Set and then you call the snmpGet operation using the PDU that you just created with Set, you will receive an error on the snmpGet call.

All character strings that are passed to the APIs must be null-terminated unless you explicitly provide the length, if a length field is available.

If you are building a PDU to go to a remote agent, you must remember to do correct translation of strings. The IBM i system is an EBCDIC system, whereas an SNMP agent on an AIX computer is an ASCII system. Even though IBM i is an EBCDIC system, community names default to ASCII representation. For example, if you are sending a PDU to an AIX system and the community name is public, you would enter the community name string in hexadecimal, X'7075626C6963'. See the data conversion APIs to convert data from EBCDIC to ASCII and vice versa.

These APIs are blocked, which means that on a call to the API a PDU is sent across a communications protocol to an SNMP agent on a local or remote system. The call returns when a response has been received from the agent or when the command times out. On the return, all returned data is placed in the appropriate locations. You need do no further action to retrieve such data.


Related Information


Example

For examples that pertain to the SNMP manager APIs, see Using SNMP Manager APIs--Example.



API introduced: V3R6