INT_32_T snmpMasterHandlerWR ( OCTET_T * pMsg, /* pointer to the message */ ALENGTH_T msgl, /* length of the message */ IPCSEND_T * pIpcSend, /* send routine */ IPCRCV_T * pIpcRcv, /* receive routine */ IPCFREE_T * pIpcFree, /* free routine */ IPCAYT_T * pIpcAyt, /* status Check Routine */ PTR_T ipchandle, /* ipchandle for the IPC scheme used */ EBUFFER_T * pBuf, /* buffer to place reply in */ VBL_T * pVblist, /* place to put varbinds */ PTR_T user_priv /* MIB tree identifier */ )
This function is called to process the control messages received from subagents when the communication method between master and subagent is synchronous.
To process a registration request, this function extracts the objects from the message and adds them as a group to the master agent's MIB tree. The actual get, test, and set methods for these objects reside in the subagent. To set up local methods for these routines, snmpMasterHandlerAsync( ) uses the function referenced in pIpcSend and pIpcRcv.
The methods local to the master agent use pIpcSend to send queries to the subagent which locally executes the actual method routine for the object. The subagent then transmits the results back to the master agent's public queue. When the function monitoring this queue sees the query response, it transfers the message to the master agent's local queue where the pIpcRcv function is waiting for the response.
To process a deregistration request, this function extracts a group ID from the message and removes that group of objects from the master agent's MIB tree. It also executes the function in pIpcFree to free any resources allocated locally to maintain the IPC link with the deregistered subagent.
The snmpMasterHandlerWR( ) routine returns information using the output parameters pBuf and pVblist and its function return value. If the returned function value indicates success, the master agent sends the message returned in pBuf to the subagent that sent the registration or deregistration request. If the returned value of this function indicates failure, the master agent silently drops the packet.
This function as has the ability to return an opcode value, although this functionality is unused in the shipped version of WindNet SNMP. In fact, if snmpMasterHandlerWR( ) were to return an opcode, the current implementation of the master agent would silently drop the packet. The possibility of returning an opcode is supported to make it possible for you to create subagents that send traps. In this case, snmpMasterHandlerWR( ) would return an opcode and a varbind list using the pVblist parameter. You could then rewrite snmpQueMonitor( ), the master agent function that calls snmpMasterHandlerWR( ), so that it responds appropriately to the returned opcode and forwards the contents of pVblist to the SNMP manager.
Use the snmpMasterHandlerWR( ) parameters as follows:
INT_32_T masterIpcSend ( EBUFFER_T * pBuf, /* message to be sent PTR_T ipchandle /* address of subagent )
INT_32_T masterIpcRcv ( EBUFFER_T * pBuf, /* buffer to receive message PTR_T ipchandle /* address of subagent )
void masterIpcFree ( PTR_T ipchandle )
INT_32_T masterIpcAyt ( PTR_T ipchandle )
If the message is trap request, it is the responsibility of the user code to acquire any values not specified in the trap message and to send the trap to the manager.
The opcode from the decoded packet or 0 or -1. An returned value of 0 indicates an error for which you should just drop the packet. A return value of -1 indicates success.
If this function returns an opcode, a value from 1 to 127, the shipped implementation just drops the packet. However, to support traps from the subagent, you could modify snmpQueMonitor( ) to note a returned value of SA_TRAP_REQUEST and then forward the varbind list in pVblist to the SNMP manager.