hp.com home products and services support and drivers solutions how to buy
cd-rom home
End of Jump to page title
HP OpenVMS systems
documentation

Jump to content


HP TCP/IP Services for OpenVMS

HP TCP/IP Services for OpenVMS
SNMP Programming and Reference


Previous Contents Index

5.2.1 Processing *_set Routines

This following is the sequence of operations performed for *_set routines

  1. Every variable binding is parsed and its object is located in the object table. A METHOD structure is created for each VARBIND structure. These METHOD structures point to a ROW_CONTEXT structure, which is useful for handling these phases. Objects in the same conceptual row all point to the same ROW_CONTEXT structure. This determination is made by checking the following:
  2. Each ROW_CONTEXT structure is loaded with the instance information for that conceptual row. The ROW_CONTEXT structure context and save fields are set to NULL, and the state field is set to ESNMP_SET_UNKNOWN structure.
  3. The method routine for each object is called and is passed its METHOD structure with an action code of ESNMP_ACT_SET.
    If all method routines return success, a single method routine (the last one called for the row) is called for each row, with method->action equal to ESNMP_ACT_COMMIT.
    If any row reports failure, all rows that were successfully committed are told to undo the phase. This is accomplished by calling a single method routine for each row (the same one that was called for the commit phase), with a method->action equal to ESNMP_ACT_UNDO.
  4. Each row is released. The same single method routine for each row is called with a method->action equal to ESNMP_ACT_CLEANUP. This occurs for every row, regardless of the results of previous processing.

The action codes are processed as follows:

5.2.2 Method Routine Applications Programming

You must write the code for the method routines declared in the subtree_TBL.H file. Each method routine has one argument, which is a pointer to the METHOD structure, as follows:


int mib_group_get( 
        METHOD *method int mib_group_set( 
        METHOD *method ); 

The Get method routines are used to perform Get , GetNext , and GetBulk operations.

The Get method routines perform the following tasks:

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.)

5.3 Support Routines

The support routines are provided as a convenience for developers writing method routines that handle specific MIB elements. The following support routines are provided:
Routine Function
o_integer Loads an integer value.
o_octet Loads an octet value.
o_oid Loads an OID value.
o_string Loads a string value.
o_counter64 Loads a Counter64 variable into the varbind .
str2oid Converts a string OID to dot notation.
sprintoid Converts an OID into a string.
instance2oid Creates a full OID for a value.
oid2instance Extracts an instance and loads an array.
inst2ip Returns an IP address for an OID.
cmp_oid Compares two OIDs.
cmp_oid_prefix Compares an OID's prefix.
clone_oid Makes a copy of an OID.
free_oid Frees a buffer.
clone_buf Duplicates a buffer.
mem2oct Converts a string to an oct structure.
cmp_oct Compares two octets.
clone_oct Makes a copy of an oct structure.
free_oct Frees a buffer attached to an oct structure.
free_varbind_date Frees the fields in the VARBIND structure.
set_debug_level Sets the logging level.
is_debug_level Tests the logging level.
ESNMP_LOG Directs log messages.
print_varbind Displays the varbind and its structure.
set_select_limit Sets the error limit for SNMP client requests.
__set_progname Sets the program name to be displayed in log messages.
__restore_progname Resets the program name back to the previous name.
__parse_progname Parses the application file name to determine the program name.
esnmp_cleanup Closes a socket that is used by a subagent for communicating with the master agent.

o_integer

Loads an integer value into the VARBIND structure with the appropriate type. This function does not allocate the VARBIND structure.

Format

int o_integer ( VARBIND *vb,
OBJECT *obj,
unsigned long value );


Arguments

vb

A pointer to the VARBIND structure that is supposed to receive the data.

obj

A pointer to the OBJECT structure for the MIB variable associated with the OID in the VARBIND structure.

value

The value to be inserted into the VARBIND structure.

The real type as defined in the object structure must be one of the following; otherwise, an error is returned.
ESNMP_TYPE_Integer32 32-bit integer
ESNMP_TYPE_Counter32 32-bit counter (unsigned)
ESNMP_TYPE_Gauge32 32-bit gauge (unsigned)
ESNMP_TYPE_TimeTicks 32-bit timeticks (unsigned)
ESNMP_TYPE_UInteger32 32-bit integer (unsigned)
ESNMP_TYPE_Counter64 64-bit counter (unsigned)
ESNMP_TYPE_IpAddress Implicit octet string (4)

Note

If the real type is IpAddress , then eSNMP assumes that the 4-byte integer is in network byte order and packages it into an octet string.

Return Values

ESNMP_MTHD_noError The routine completed successfully.
ESNMP_MTHD_genErr An error has occurred.

Example


 
#include <esnmp.h> 
#include "ip_tbl.h"  <-- for ipNetToMediaEntry_type definition 
VARBIND     *vb       = method->varbind; 
OBJECT      *object   = method->object; 
ipNetToMediaEntry_type *data; 
: 
: assume buffer and structure member assignments occur here 
: 
switch(arg) { 
case I_atIfIndex: 
return o_integer(vb, object, data->ipNetToMediaIfIndex); 
 


o_octet

Loads an octet value into the VARBIND structure with the appropriate type. This function does not allocate the VARBIND structure.

Format

int o_octet ( VARBIND *vb,
OBJECT *obj,
unsigned long value );


Arguments

vb

A pointer to the VARBIND structure that is supposed to receive the data.

If the original value in the vb field is not null, this routine attempts to free it. So if you dynamically allocate memory or issue the malloc command to allocate your own VARBIND structure, fill the structure with zeros before using it.

obj

A pointer to the OBJECT structure for the MIB variable associated with the OID in the VARBIND structure.

value

The value to be inserted into the VARBIND structure.

The real type as defined in the object structure must be one of the following; otherwise, an error is returned.
ESNMP_TYPE_OCTET_STRING Octet string (ASN.1)
ESNMP_TYPE_IpAddress Implicit octet string (4) (in octet form, network byte order)
ESNMP_TYPE_DisplayString DisplayString (textual convention)
ESNMP_TYPE_Opaque Implicit octet string


Return Values

ESNMP_MTHD_noError The routine completed successfully.
ESNMP_MTHD_genErr An error occurred.

Example


 
#include <esnmp.h> 
#include "ip_tbl.h"  <-- for ipNetToMediaEntry_type definition 
VARBIND     *vb       = method->varbind; 
OBJECT      *object   = method->object; 
ipNetToMediaEntry_type *data; 
: 
: assume buffer and structure member assignments occur here 
: 
switch(arg) { 
 case I_atPhysAddress: 
 return o_octet(vb, object, &data->ipNetToMediaPhysAddress); 
 


Previous Next Contents Index