📄 snmp.refentries.toc75.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title><i class="i">snmpMonitorSpawn</i>( ) SNMP Reference </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="snmp.refEntries.TOC.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="snmp.refEntries.TOC74.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="snmp.refEntries.TOC76.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h2 class="H1"><i><a name="89419"> <i class="i">snmpMonitorSpawn</i>( ) </a></i></h2></font><h4 class="SH"><a name="89420"> </a>NAME </h4><dl class="margin"><dl class="margin"><dd><a name="89421"><div class="aX"><b class="routine"><i class="routine">snmpMonitorSpawn</i></b><b>( )</b> - spawn <b class="symbol_lc">tMonQue</b> to run <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> </div></a></dl></dl><h4 class="SH"><a name="89422"> </a>SYNOPSIS </h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="89423">void snmpMonitorSpawn (void)</a></b></pre></dl></dl><h4 class="SH"><a name="89424"> </a>DESCRIPTION </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89425"> </a>This function spawns the <b>tMonQue</b> task to run <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> a function that waits on the message queue that subagents use to leave messages for the master agent. The <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> waits forever on the master agent's message queue. When message comes in, it is interpreted using an <b>SA_MESSAGE_T</b> structure, which is defined in <b>ipcLib.h</b> as:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="89426">typedef struct SA_MESSAGE_S { int msgType; MSG_Q_ID saId; EBUFFER_T mesg; } SA_MESSAGE_T;</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="89432"> </a>A switch internal to <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> handles the message according to the value of the <b>msgType</b> member.</p><dd><p class="Body"><a name="89433"> </a>If the message type is <b class="symbol_UC">CALL_QUERY_HANDLER</b>, the message is a response to a query from the master agent. The buffer referenced in the <b>mesg</b> is then transferred to the local message queue monitored by <b>tSnmpd</b>, where a <b class="routine"><i class="routine">masterIpcRcv</i></b><b>( )</b> routine is waiting for a query response from a subagent.</p><dd><p class="Body"><a name="89435"> </a>If the message type is <b>CALL_REG_HANDLER</b>, the message is a control message such as a registration request, a deregistration request, or a trap. To respond to such requests, <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> passes the buffer in <b>mesg</b> on to <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b>.</p><dd><p class="Body"><a name="89436"> </a>If the message in the buffer passed to <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> is not correctly formed, the returned function value indicates failure and <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> drops the packet.</p><dd><p class="Body"><a name="89437"> </a>If the buffer passed to <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> is a correctly formed registration request, <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> adds the specified objects to the master agent's MIB tree. If the buffer contains a correctly formed deregistration request, <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> removes the specified objects from the master agent's MIB tree. In both cases the returned value of <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> indicates success and its <i class="i">pBuf </i>parameter contains a message that <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> forwards to the subagent that sent the message.</p><dd><p class="Body"><a name="89438"> </a>In the case of a successful registration request, the message sent to the subagent contains a group ID for the objects just added to the master agent's MIB tree. When the subagent deregisters itself, it includes this ID in its deregistration message to the master agent. It also uses this group ID when it must register instances of the object just registered.</p><dd><p class="Body"><a name="89439"> </a>If the buffer passed to <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> contains a trap, the returned function value is <b>SA_TRAP_REQUEST</b>, the value extracted from the <b>opcode2</b> member of the header associated with the message. The message itself (minus the header) is a varbind list. It is returned using the <i class="i">pVblist </i>parameter. The current implementation of <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> just drops this message. However, you can rewrite <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> to make a <b class="routine"><i class="routine">snmpIoTrapSend</i></b><b>( )</b> that forwards the varbind list to the SNMP manager. Likewise, you can implement appropriate responses to other <b>opcode2</b> values. Currently, <b>subagent.h</b> defines symbolic constants for opcodes 1 through 12 (with opcode 11, <b>SA_TRAP_REQUEST</b>, reserved for trap requests). If necessary you are free to use the remaining opcodes for message types specific to your implementation.</p><dd><p class="Body"><a name="89440"> </a>If your transport needs require that you rewrite <b>masterIoLib</b> to use an IPC other than message queues, you might need to modify this function, which is called from <b class="routine"><i class="routine">snmpIoMain</i></b><b>( )</b> just before a call to <b class="routine"><i class="routine">snmpIoBody</i></b><b>( )</b>. For example, if you use sockets as your IPC between the SNMP master agent and its subagents, <b>tSnmpd</b> could monitor the socket connection with the SNMP manager as well as the socket connections with the SNMP subagents. </p></dl></dl><h4 class="SH"><a name="89441"> </a>ASYNCHRONOUS COMMUNICATION </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89442"> </a>The shipped version of <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> uses <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>( )</b> and thus processes messages asynchronously. However, if necessary, you can rewrite <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>( )</b> to call <b class="routine"><i class="routine">snmpMasterHandlerAsync</i></b><b>( )</b> instead. For more information on <b class="routine"><i class="routine">snmpMasterHandlerAsync</i></b><b>( )</b>, see its reference entry. </p></dl></dl><h4 class="SH"><a name="89443"> </a>RETURNS </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89444"> </a>N/A </p></dl></dl><h4 class="SH"><a name="89445"> </a>SEE ALSO </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89446"> </a><b>masterIoLib</b> </p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="snmp.refEntries.TOC.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="snmp.refEntries.TOC74.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="snmp.refEntries.TOC76.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -