beautypg.com

2 method routine applications programming – Compaq AAR04BCTE User Manual

Page 84

background image

eSNMP API Routines
*_set Routine

ESNMP_ACT_UNDO

For each conceptual row that was successfully committed, the same method
routine is called with method->action equal to ESNMP_ACT_UNDO. The
ROW_CONTEXT structures that have not yet been called for the COMMIT
phase are not called for the UNDO phase; they are called for CLEANUP
phase.

The method routine should attempt to restore conditions to what they were
before it executed the COMMIT phase. (This is typically done using the data
pointed to by the method->row->save field.)

If successful, return ESNMP_MTHD_noError; otherwise, return ESNMP_
MTHD_undoFail.

ESNMP_ACT_CLEANUP

Regardless of what else has happened, at this point each ROW_CONTEXT
participates in cleanup phase. The same method routine that was
called for in the COMMIT phase is called with method->action equal to
ESNMP_ACT_CLEANUP.

This indicates the end of processing for the

set

request. The method routine

should perform whatever cleanup is required; for instance, freeing dynamic
memory that might have been allocated and stored in method->row->context
and method->row->save fields, and so on.

The function return status value is ignored for the CLEANUP phase.

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:

Extract the instance portion of the requested OID. You can do this manually
by comparing the method->object->oid field (the object’s base OID) to
the method->varbind->name field (the requested OID). You can use the

oid2instance

support routine to do this.

Determine the instance validity. The instance OID can be null or any length,
depending on what was requested and how your object was selected. You may
be able to reject the request immediately by checking on the instance OID.

Extract the data. Based on the instance OID and method->action field,
determine what data, if any, is to be returned.

5–26 eSNMP API Routines