⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snmp.refentries.toc1.html

📁 vxworks相关论文
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>masterIoLib     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.TOC.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="snmp.refEntries.TOC2.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="88594"> masterIoLib </a></i></h2></font><h4 class="SH"><a name="88595"> </a>NAME </h4><dl class="margin"><dl class="margin"><dd><a name="88596"><div class="aX"><b class="library">masterIoLib</b>     -     default I/O routines for the SNMP master agent </div></a></dl></dl><h4 class="SH"><a name="88597"> </a>SYNOPSIS </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88598"> </a><b class="routine"><i class="routine">masterIoInit</i></b><b>(&nbsp;)</b>     -     create the IPC mechanism at the SNMP master agent </p><dd><p class="Body"><a name="88599"> </a><b class="routine"><i class="routine">snmpMonitorSpawn</i></b><b>(&nbsp;)</b>     -     spawn <b>tMonQue</b> to run <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> </p><dd><p class="Body"><a name="88600"> </a><b class="routine"><i class="routine">masterIpcComp</i></b><b>(&nbsp;)</b>     -     transmit a completion of transmission message </p><dd><p class="Body"><a name="88601"> </a><b class="routine"><i class="routine">masterIoWrite</i></b><b>(&nbsp;)</b>     -     send the encoded buffer to the subagent </p><dd><p class="Body"><a name="88602"> </a><b class="routine"><i class="routine">masterIpcSend</i></b><b>(&nbsp;)</b>     -     send a message to a subagent </p><dd><p class="Body"><a name="88603"> </a><b class="routine"><i class="routine">masterIpcRcv</i></b><b>(&nbsp;)</b>     -     wait for a reply from the subagent </p><dd><p class="Body"><a name="88604"> </a><b class="routine"><i class="routine">masterIpcAyt</i></b><b>(&nbsp;)</b>     -     check the status of the IPC link </p><dd><p class="Body"><a name="88605"> </a><b class="routine"><i class="routine">masterIpcFree</i></b><b>(&nbsp;)</b>     -     free the IPC resources allocated by the SNMP master agent </p><dd><p class="Body"><a name="88606"> </a><b class="routine"><i class="routine">masterQueCleanup</i></b><b>(&nbsp;)</b>    -     free resources allocated for SNMP master agent </p></dl><dl class="margin"><dd><pre class="Code"><b><a name="88607">STATUS&nbsp;masterIoInit  (void) </a></b><dd> <b><a name="88608">void&nbsp;snmpMonitorSpawn  (void) </a></b><dd> <b><a name="88609">void&nbsp;masterIpcComp  (OCTET_T&nbsp;opcode, EBUFFER_T&nbsp;*&nbsp;ebuf, VBL_T&nbsp;*&nbsp;vblist, PTR_T&nbsp;ipchandle) </a></b><dd> <b><a name="88610">STATUS&nbsp;masterIoWrite  (EBUFFER_T&nbsp;*&nbsp;pBuf, PTR_T&nbsp;saId, INT_32_T&nbsp;flg) </a></b><dd> <b><a name="88611">INT_32_T&nbsp;masterIpcSend  (EBUFFER_T&nbsp;*&nbsp;pBuf, PTR_T&nbsp;ipchandle) </a></b><dd> <b><a name="88612">INT_32_T&nbsp;masterIpcRcv  (EBUFFER_T&nbsp;*&nbsp;pBuf, PTR_T&nbsp;ipchandle) </a></b><dd> <b><a name="88613">INT_32_T&nbsp;masterIpcAyt  (PTR_T&nbsp;ipchandle) </a></b><dd> <b><a name="88614">void&nbsp;masterIpcFree  (PTR_T&nbsp;ipchandle) </a></b><dd> <b><a name="88615">void&nbsp;masterQueCleanup  (void) </a></b></pre></dl></dl><h4 class="SH"><a name="88616"> </a>DESCRIPTION </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88617"> </a>This module implements the I/O routines used by the SNMP master agent. As shipped, the WindNet SNMP code uses message queues to communicate between the master agent and its subagents. The SNMP master agent also uses a message queue to handle communication between its two component tasks, <b>tSnmpd</b> and <b>tMonQue</b>. The <b>tSnmpd </b>task handles communication with the SNMP manager. The <b>tMonQue</b> task is a secondary task spawned from <b>tSnmpd</b> to receive messages from subagents.</p><dd><p class="Body"><a name="88618"> </a>When <b>tSnmpd</b> spawns <b>tMonQue</b>, it assigns <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> to manage the process. This function waits on the message queue that subagents use to send messages to the master agent. The <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> function interprets messages on its queue 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="88619">typedef struct SA_MESSAGE_S</a></b><dd> <b><a name="88620">&nbsp;&nbsp;&nbsp;&nbsp;{</a></b><dd> <b><a name="88621">&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msgType;</a></b><dd> <b><a name="88622">&nbsp;&nbsp;&nbsp;&nbsp;MSG_Q_ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; saId;</a></b><dd> <b><a name="88623">&nbsp;&nbsp;&nbsp;&nbsp;EBUFFER_T&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mesg;</a></b><dd> <b><a name="88624">&nbsp;&nbsp;&nbsp;&nbsp;} SA_MESSAGE_T;</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="88625"> </a>A switch internal to <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> handles the message according to the value of the <b>msgType</b> member.</p><dd><p class="Body"><a name="88626"> </a>If the message type is <b>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>, which is waiting for a query response from a subagent.</p><dd><p class="Body"><a name="88628"> </a>If the message type is <b>CALL_REG_HANDLER</b>, the message is either a registration request, a deregistration request, or some other control message (such as a trap). To respond to such requests, <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> passes the buffer in <b>mesg</b> to <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>(&nbsp;)</b>.</p><dd><p class="Body"><a name="88629"> </a>If the message submitted to <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>(&nbsp;)</b> is a registration request, it includes information on a set of leaves representing the objects that the subagent wants to add to the master agent's MIB tree. If the message passes all checks, the objects are added to the master agent's MIB tree and <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>(&nbsp;)</b> returns success. All objects registered in one message become part of a group. They share the same IPC information, and, if the IPC link to their subagent is broken, they are deactivated as a group.</p><dd><p class="Body"><a name="88630"> </a>If <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>(&nbsp;)</b> returns a function value indicating success, it also returns a message for the subagent containing the group ID for the variables just added. The <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> takes responsibility for forwarding this message to the subagent. The subagent uses the group ID contained in this message when it comes time to deregister, as well as when it must register instances of an already registered object.</p><dd><p class="Body"><a name="88631"> </a>The returned function value of <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>(&nbsp;)</b> can indicate failure or an opcode. You might want to rewrite this code to do something different. For example, if the subagent has sent a trap up to the master agent, the returned value of <b class="routine"><i class="routine">snmpMasterHandlerWR</i></b><b>(&nbsp;)</b> is <b>SA_TRAP_REQUEST</b>, and the <i class="i">vblist</i> parameter contains a varbind list from the subagent. In this case, you would want to modify <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> to pass the trap on to the SNMP manager.</p></dl></dl><h4 class="SH"><a name="88632"> </a>MIB VARIABLES ADDED BY A SUBAGENT </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88633"> </a>These MIB variables that the subagent adds to the master agent's MIB tree look transparent to the SNMP manager that is in communication with the master agent. However, the method routines associated with these MIB variables in the master agent are not standard MIB routines. Instead, they are special routines that know how to queue test, get, and set work on the subagent that registered the MIB variables with the master agent. From the point of view of the PDU processing code, these special method routines look like any other method routines. However, when <b>tSnmpd</b> executes one of these routines, the special method routine actually passes the work on to a subagent while <b>tSnmpd</b> waits on a local message queue.</p><dd><p class="Body"><a name="88634"> </a>Because the subagent does not know about this local message queue, its response to the master agent is somewhat indirect. The only master agent message queue known to the subagent is the message queue managed by <b>tMonQue</b>, so the subagent puts its response on that queue. When the <b class="routine"><i class="routine">snmpQueMonitor</i></b><b>(&nbsp;)</b> function that <b>tMonQue</b> runs to monitor the message queue sees that the message is a query response, it then transfers the message to the local queue upon which <b>tSnmpd</b> is awaiting a response. When <b>tSnmpd</b> sees the response, it parses it and merges the message into the PDU processing system.</p></dl></dl><h4 class="SH"><a name="88635"> </a>SERIAL VERSUS ASYNCHRONOUS SUBAGENT PROCESSING </h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88636"> </a>In the shipped implementation, communication between the master agent and its subagents is handled serially. For example, if the SNMP manager made a request concerning three MIB variables managed by three different subagents, the master agent would query each subagent in turn. After gathering all three responses, the master agent would then pack them up and ship the information back to the SNMP manager.</p><dd><p class="Body"><a name="88637"> </a>With some modifications to the code, you could rewrite the SNMP master agent to query all three subagents simultaneously (see the description of the <b class="routine"><i class="routine">snmpMasterHandlerAsync</i></b><b>(&nbsp;)</b> function defined in <b>subagentLib.c</b>). That is, the master agent would query all three subagent one after the other without waiting for a response after making each request. If the subagents reside on different targets (each with its own processor), this asynchronous query method of multiple subagents lets you take advantage of the capacity for parallel processing.</p><dd><p class="Body"><a name="88638"> </a>However, if the subagents reside on different targets, you will also need to replace the code that implements the IPC mechanism used between the master agent and its subagents. In the shipped code, message queues serve as the IPC mechanism. To support agents that reside on different machines, you must replace this IPC mechanism with something such as sockets. To make this possible, the functions that implement the IPC mechanism are isolated to <b>masterIoLib.c</b> and <b>saIoLib.c</b>. These files ship as source code that you should feel free to edit as needed. </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.TOC.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="snmp.refEntries.TOC2.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 + -