eSNMP API Routines
*_set Routine
•
Load the response OID back into the method routine’s VARBIND structure.
Set the method->varbind field with the OID of the actual MIB variable
instance you are returning. This is usually accomplished by loading an
array of integers with the instance OID you wish to return and calling the
instance2OID
support routine.
•
Load the response data back into the method routine’s VARBIND structure.
Use one of the support routines with the corresponding data type to load the
method->varbind field with the data to return:
•
o_integer
•
o_string
•
o_octet
•
o_oid
These routines make a copy of the data you specify. The
libesnmp
function
manages any memory associated with copied data. The method routine must
manage the original data’s memory.
The routine does any necessary conversions to the type defined in the
object table for the MIB variable and copies the converted data into the
method->varbind field. See Section 5.2.3 for information on data value
representation.
•
Return the correct status value, as follows:
ESNMP_MTHD_noError
The routine completed successfully or
no errors were found.
ESNMP_MTHD_noSuchInstance
There is no such instance of the
requested object.
ESNMP_MTHD_noSuchObject
No such object exists.
ESNMP_MTHD_ genErr
An error occurred and the routine did
not complete successfully.
5.2.3 Value Representation
The values in a VARBIND structure for each data type are represented as follows.
(Refer to the ESNMP.H file for a definition of the OCT and OID structures.)
•
ESNMP_TYPE_Integer32 (varbind->value.sl field)
This is a 32-bit signed integer. Use the
o_integer
routine to insert an integer
value into the VARBIND structure. Note that the prototype for the value
argument is unsigned long; therefore, you may need to cast this to a signed
integer.
•
ESNMP_TYPE_DisplayString, ESNMP_TYPE_Opaque
ESNMP_TYPE_OctetString (varbind->value.oct field)
This is an octet string. It is contained in the VARBIND structure as an OCT
structure that contains a length and a pointer to a dynamically allocated
character array.
eSNMP API Routines 5–27