📄 snmpddoc.c
字号:
** RETURNS: N/A**/void snmpdTrapSend ( void * pSnmpEndpoint, /* snmp agent transport endpoint */ int numDestn, /* number of destinations */ void ** ppDestAddrTbl, /* array of ptrs to destinations */ void * pLocalAddr, /* local address */ int version, /* SNMP version */ char * pTrapCmnty, /* trap community string */ OIDC_T * pMyOid, /* agent object identifier */ int myOidLen, /* length of agent object identifier */ u_long * pIpAddr, /* ip address of sender */ int trapType, /* trap type */ int trapSpecific, /* trap specific code */ int numVarBinds, /* number of varbinds in packet */ FUNCPTR trapVarBindsRtn, /* routine to bind varbinds */ void * pCookie /* argument to binding routine */ ) { ... }/******************************************************************************** snmpdInitFinish - complete the initialization of the agent** This routine is required to be called by the user to complete the* initialization of the SNMP agent after the transport endpoint has* been initialized. This routine must be called \f2after\fR the endpoint has* been established, since it depends on that endpoint to function* correctly.** This routine also installs any user-supplied hooks for customizing* the agent. If a hook is not required, a NULL pointer should be passed* in that position. The function snmpIoTrapSend() is invoked by this* routine, so any configuration required by that routine should be* done prior to calling snmpdInitFinish().** The hook routines are as follows:** .iP "<pPrivRlse>" 8 * This routine is used by the agent to free any memory attached to the* private field of the SNMP_PKT_T structure. * .iP "<pSetPduVldt>"* This routine is called before any processing of a `set' request has* taken place. It can be used to perform global validation of the* request, if needed. The return values for this routine must meet the* following requirements:* * 0 - indicates that the `set' PDU is valid, and processing should continue.* * 1 - indicates that the `set' PDU is valid, and that this routine has* already completed all the required `set' operations.* * -1 - indicates that the `set' PDU is invalid and should be rejected.* .iP "<pPreSet>"* This routine is called after all `testproc' operations have* completed successfully, but before any `setproc' operation is begun.* Return value requirements are as follows* * 0 - indicates that the `set' PDU is valid, and processing should continue.* * 1 - indicates that the `set' PDU is valid, and that this routine has* already completed all the required `set' operations.* * -1 - indicates that the `set' PDU is invalid and should be rejected.* .iP "<pPostSet>"* This routine is called after all `setproc' have completed* successfully. This routine can be used to free resources allocated* during `set' processing. * .iP "<pSetFailed>"* This routine is possibly called under two sets of circumstances:* after all `testproc' operations have returned and some of them have* failed, and/or after all `undoproc' operations have returned and* some `setproc' operations have failed. It can be used to do any* required cleanup. * .LP** RETURNS: N/A*/void snmpdInitFinish ( VOIDFUNCPTR pPrivRlse, /* user's privare release routine */ FUNCPTR pSetPduVldt, /* user's set pdu validate routine */ FUNCPTR pPreSet, /* user's pre set routine */ FUNCPTR pPostSet, /* user's post set routine */ FUNCPTR pSetFailed /* user's set failed routine */ ) { ... }/******************************************************************************** snmpdExit - exit the SNMP agent** This routine causes the SNMP agent to exit. It is available in case* the user encounters some problem after a successful startup. * * This routine must be called from the main thread. Any other tasks* spawned by the user (for asynchronous method routines) should be* deleted prior to calling this function.*** RETURNS: N/A**/void snmpdExit (void) { ... }/******************************************************************************** snmpdContinue - continue processing of an SNMP packet* * This routine continues processing a packet. snmpdPktProcess() begins* the method routines needed to fulfill the request, while this* routine determines whether the current set of method routines have* finished; it then either starts more method routines or sends a* response packet.** If a method routine returns before completing its task, it must* arrange for snmpdContinue() to be called when the task is completed.* You must obtain the write-lock on this packet by calling* snmpdPktLockGet() prior to calling snmpdContinue(). snmpdContinue() * releases the write-lock when it completes.** <pktp> is a pointer to the structure that contains the packet.** RETURNS: N/A**/void snmpdContinue ( SNMP_PKT_T * pktp /* snmp packet */ ) { ... }/******************************************************************************** snmpdGroupByGetprocAndInstance - gather set of similar variable bindings** This routine gathers a set of similar variable bindings together by* searching the variable bindings in <pktp>, starting at <firstVbp>* for a match of the `getproc' pointer of <firstVbp> and with an* instance specified by <compc> and <compl>. This routine then links* the variable bindings found which match <firsVbp>.** This routine does not set any flags in the variable bindings. It is* left to the calling routine to decide whether the <tested> or <set> flags* should be set.** RETURNS: N/A**/void snmpdGroupByGetprocAndInstance ( SNMP_PKT_T * pktp, /* snmp packet */ VB_T * firstVbp, /* first var bind */ int compc, /* component count */ OIDC_T * compl /* component length */ ) { ... }/******************************************************************************** snmpdVbRowExtract - extract required pieces of a row for a `set' operation** This routine assists in implementing row-creation `set' operations.* It is typically used by the `testproc' routine for a table. It scans* the SNMP packet looking for all the pieces that go together for the* purposes of creating a new row in an SNMP table.** The parameter <row> describes what this routine is looking for.* <row> is a list of MIB leaf pointers referring to variables in the* table in question, and a flag indicating if this variable (<column>)* in the table is required. This routine searches the variable* bindings in <pktp> for a match of the MIB leaf pointer specified in* the row array and the instance specified by <compc> and <compl>. It* links the variable bindings found from the first MIB leaf node in* the row array. This first variable binding must be in the packet * whether it is marked as needed or not, and is the return value of* snmpdVbRowExtract().** If snmpdVbRowExtract() does not find a matching variable binding and* that leaf is flagged ROW_FLAG_NEEDED in the row array, the routine* returns NULL to indicate an error.** This routine marks the variable bindings in the resulting list as* already tested except for the first entry, which is marked as* already set. As a result, the agent only calls the `set' routine* associated with the first MIB leaf in the row array. This `set'* routine should handle creation of the necessary data structures and* reading the variable binding list to execute the required `set'* operations. You can force other entries set routines to be called* by flagging entries with ROW_FLAG_CALL_SET.** RETURNS: a pointer to the first variable binding if successful,* otherwise NULL.**/VB_T * snmpdVbRowExtract ( SNMP_PKT_T * pktp, /* snmp packet */ int start_index, /* starting index */ int compc, /* component count */ OIDC_T * compl, /* component length */ int row_structure_length, /* length of row structure */ struct create_row * row /* row structure */ ) { ... }/******************************************************************************** snmpdVbExtractRowLoose - incrementally extract pieces of a row for a set ** This routine assists in implementing row-creation `set' operations,* especially in the case of ``dribble'' creation. In ``dribble''* creation, the network management station may choose to break the* creation of a new entry in some table into multiple packets. Using* multiple packets does not work with snmpdVbRowExtract(), which* requires at least one specified item to be in the packet.** In dribble creation, there is no single item that is guaranteed to* be in every packet. As its name implies, this routine is similar to* snmpdVbRowExtract(). It searches the variable bindings in <pktp>* starting at <indx> for a match of the MIB leaf pointer specified in* the <leaves> array and with an instance specified by <compc> and* <compl>. The routine then links the variable bindings found from* the last variable binding found.* * If no variable bindings are found, this routine returns a NULL* pointer. This routine does not set any of the flags in the variable* bindings. It is left to the calling routine to decide if the <tested>* or <set> flags should be set.** RETURNS: a pointer to the last variable binding if successful,* otherwise NULL.**/VB_T * snmpdVbExtractRowLoose ( SNMP_PKT_T * pktp, /* snmp packet */ int indx, /* index */ MIBLEAF_T ** leaves, /* mib leaves */ int compc, /* component count */ OIDC_T * compl /* component length */ ) { ... }/******************************************************************************** snmpdPktLockGet - lock an SNMP packet ** This routine obtains a lock on the SNMP packet being processed,* which must be obtained by any asynchronous method routine prior to* calling any of the routines `getproc_*', `nextproc_*', `testproc_*',* or `setproc_*', or also snmpdContinue(). snmpdContinue() releases* the lock before returning. No other routine can release this lock.** This routine blocks until the lock is obtained.** Returns: OK, or ERROR on failure.** SEE ALSO: `snmpProcLib', snmpdContinue()*/STATUS snmpdPktLockGet ( SNMP_PKT_T * pktp /* snmp packet */ ) { ... }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -