Compaq AAR04BCTE manual Method Routine Applications Programming, eSNMP API Routines set Routine

Models: AAR04BCTE

1 132
Download 132 pages 53.41 Kb
Page 84
Image 84
5.2.2Method Routine Applications Programming

eSNMP API Routines

*_set Routine

ESNMP_ACT_UNDO

For each conceptual row that was successfully committed, the same method routine is called with method->actionequal 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->savefield.)

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->actionequal 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->contextand method->row->savefields, and so on.

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

5.2.2Method 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->oidfield (the object’s base OID) to

the method->varbind->namefield (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->actionfield, determine what data, if any, is to be returned.

5–26eSNMP API Routines

Page 84
Image 84
Compaq AAR04BCTE Method Routine Applications Programming, eSNMP API Routines set Routine, int mibgroupget, METHOD *method