次の方法で共有


Worker Callback Functions and Data (Windows Embedded CE 6.0)

1/6/2010

The callback functions that implement the extension agent perform the actual work of the extension agent. Because the SnmpTfx framework does not hand an OID of the selected object to the callback routines, there must be at least as many functions as there are unique accessible data elements (not counting array instances) in the MIB to eliminate ambiguity about the object that is being accessed. The framework allows you to implement a separate Get and Set operation for each unique data element, but it does not require it.

You do not need to define Get operations for read-only MIB variables. Inaccessible variables do not require a definition of either a Get or Set operation.

In addition to defining the Get and Set operations for each MIB variable, you need to define a buffer structure for each MIB element that is to be accessed. The framework creates the per-variable buffer to pass information to and from your callback functions. You must define a single structure that contains one AsnAny variable for each MIB variable that is accessed in your extension agent.

The following code example shows how to define a single structure in the extension agent.

typedef struct
{
  AsnAny snmpErrNumber;
  AsnAny snmpErrCode;
  AsnAny snmpTriggerTrap;
} SNMPTEST_VARS;

The order of the MIB variable definitions must match the lexicographic ordering of the variables in your MIB that are accessed. After declaring the functions and data buffer variables in a header file (see Mibfuncs.h in the SNMP sample, which is included in %_WINCEROOT%\Public\Astb\Samples\Snmpsamp), you need to define each MIB variable in a #define declaration.

You need to define the Get and Set operations, as well as a variable instance for getting and setting for each MIB variable (SomeMibVar) that has read and write access. The following code example uses SomeMibVar as the common base name.

UINT accessor_function (
  UINT actID, 
  AsnAny *aryObject, 
  UINT *pErrIndex
);

UINT setter_function (
  UINT actID, 
  AsnAny *aryObject, 
  UINT *pErrIndex
);

typedef struct
{
  AsnAny someAccessedVariable ;
  (...plus other variables...)
} MY_MIB_STRUCT ;

#define gf_SomeMibVar              accessor_function
#define sf_SomeMibVar              setter_function
#define gb_SomeMibVar              MY_MIB_STRUCT
#define sb_someMibVar              MY_MIB_STRUCT

See Also

Concepts

SnmpTfx Framework