7.5   Registering a WindNet SNMP Subagent

For an example of how you would write code that registered a subagent with the master agent, see target/src/snmpv1/agent/taskRoutine.c. This code implements a simple subagent that manages a task table. To initialize this subagent, you would call taskObjReg( ). Internally, this function calls snmpSaInit( ) to setup the IPC mechanism that the master agent can use to send messages to this subagent. This function also specifies taskRegComp( ) as the registration completion routine.

After setting up the IPC mechanism, taskObjReg( )sets up a varbind list describing the task table and uses hdrBlkCreate( ) to send a message to the master agent that registers the task table variables. In response to the registration request, the master agent puts a message on the subagents message queue. To process the message, the subagent calls its registration completion routine, taskRegComp( ). If the registration request was successful, taskRegComp( ) extracts a group ID from the completion message and uses it to register task-specific instances for each variable in the task variable.