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

📄 c-agent12.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>    The WindNet SNMPv1/v2c Agent   </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="c-agent.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-agent11.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-config.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="84047">4.12  &nbsp;&nbsp;SNMP Agent Data Flow</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85240"> </a>The remainder of this chapter describes the data flow through a standard SNMP agent. If you are using a distributed SNMP agent, you will also need to see <a href="c-sub_agents3.html#89078"><i class="title">7.3&nbsp;Data Flow between SNMP Master Agents and Subagents</i></a>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84048">4.12.1  &nbsp;&nbsp;Initialization</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84049"> </a>VxWorks starts SNMP by invoking <b class="routine"><i class="routine">usrSnmpInit</i></b><b>(&nbsp;)</b> at boot-time, which eventually spawns a task which appears in the system task table as <b class="command">tSnmpd</b>. The main entry point into this task is <b class="routine"><i class="routine">snmpIoMain</i></b><b>(&nbsp;)</b>; this routine is provided in source and can be customized by the agent writer to perform user-defined initialization functions, such as reading a configuration file.</p><dd><p class="Body"><a name="84533"> </a>The following diagram describes the agent's initialization. Routines are shown with the files in which they appear.<div class="frame"><h4 class="EntityTitle"><a name="84613"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-2:&nbsp;&nbsp;SNMP Agent Initialization</font></a></h4><dl class="margin"><div class="CellBody"><a name="84579"> </a><img class="figure" border="0" src="images/c-agenta4.gif"></div></dl></div></p></dl></dl><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="84571"><br></a><img border="0" alt="*" src="icons/note.gif">&nbsp;&nbsp;&nbsp;</td><td><div class="Note"><hr><b class="symbol_UC">NOTE: </b>Part of configuring WindNet SNMPv1/v2c for your site likely involved editing the file snmpIoLib.c to reflect your local network-management paradigm; see <a href="c-config2.html#83591"><i class="title">5.2&nbsp;Configuring snmpIoLib</i></a> for details.<hr></div></td></tr></table><dl class="margin"><dd><p class="Body"><a name="84091"> </a>Initialization proceeds with the following stages:</p></dl><dl class="margin"><p><ol class="List"><li value="1."><a name="84092"> </a>As VxWorks boots, <b class="routine"><i class="routine">usrSnmpInit</i></b><b>(&nbsp;)</b> calls <b class="routine"><i class="routine">snmpdInit</i></b><b>(&nbsp;)</b>, thus starting the agent. </li></ol></p><p><ol class="List"><li value="2."><a name="84093"> </a><b class="routine"><i class="routine">snmpdInit</i></b><b>(&nbsp;)</b> spawns the routine <b class="routine"><i class="routine">snmpIoMain</i></b><b>(&nbsp;)</b>, which handles multiple user-defined aspects of initialization. Possible user-defined initializations include:</li></ol></p><dl class="margin"><ul class="DashSingle2" type="circle"><li><a name="84094"> </a>reading user-defined configuration files</li></ul><ul class="DashSingle2" type="circle"><li><a name="84095"> </a>any private initialization code</li></ul><ul class="DashSingle2" type="circle"><li><a name="84096"> </a>user-defined view-management tables</li></ul><ul class="DashSingle2" type="circle"><li><a name="84097"> </a>user-defined community-view map table</li></ul><ul class="DashSingle2" type="circle"><li><a name="84098"> </a>user-defined trap configuration tables</li></ul><ul class="DashSingle2" type="circle"><li><a name="84102"> </a>hook routines (see <a href="c-agent8.html#83905"><i class="title">4.8&nbsp;Hooks</i></a>)</li></ul></dl><p><ol class="List"><li value="3."><a name="84103"> </a><b class="routine"><i class="routine">snmpIoMain</i></b><b>(&nbsp;)</b> must invoke <b class="routine"><i class="routine">snmpdInitFinish</i></b><b>(&nbsp;)</b>to complete the initialization process. The <b class="routine"><i class="routine">snmpInitFinish</i></b><b>(&nbsp;)</b> routine sends a <b class="command">coldStart</b> trap (see <a href="c-agent7.html#83785"><i class="title">4.7&nbsp;Traps</i></a>) via a user-customized routine <b class="routine"><i class="routine">snmpIoTrapSend</i></b><b>(&nbsp;)</b>, which notifies the appropriate Network Management Stations that the SNMP agent is online.</li></ol></p><p><ol class="List"><li value="4."><a name="84107"> </a><b class="routine"><i class="routine">snmpInitFinish</i></b><b>(&nbsp;)</b> returns to <b class="routine"><i class="routine">snmpIoMain</i></b><b>(&nbsp;)</b>, which invokes the packet-processing loop to handle incoming PDUs from Network Management Stations.</li></ol></p></dl><dl class="margin"><dd><p class="Body"><a name="84108"> </a>For more information on individual routines, see <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84110">4.12.2  &nbsp;&nbsp;Packet-Processing Loop</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84111"> </a>The following diagram describes the SNMP agent's main activities, which involve:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84112"> </a>processing incoming packets and generating responses, and</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84113"> </a>generating traps based on user-defined specifications</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="84114"> </a>The loop occurs in <b class="routine"><i class="routine">snmpIoBody</i></b><b>(&nbsp;)</b>, which listens on the specified UDP port for incoming SNMP PDUs.</p><dd><p class="Body"><a name="84115"> </a>Routines are shown with the files in which they appear, if relevant. Arrows represent data flow.<div class="frame"><h4 class="EntityTitle"><a name="84698"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-3:&nbsp;&nbsp;SNMP Packet-Processing Loop</font></a></h4><dl class="margin"><div class="CellBody"><a name="84635"> </a><img class="figure" border="0" src="images/c-agenta6.gif"></div></dl></div></p><dd><p class="Body"><a name="84142"> </a>The stages involved in packet processing can be described as follows.</p></dl><dl class="margin"><p><ol class="List"><li value="1."><a name="84143"> </a>The user-defined routine <b class="routine"><i class="routine">snmpIoBody</i></b><b>(&nbsp;)</b> listens for incoming requests on UDP port 161. When a request is received, it is handed off to <b class="routine"><i class="routine">snmpdPktProcess</i></b><b>(&nbsp;)</b> for processing.</li></ol></p><p><ol class="List"><li value="2."><a name="84144"> </a>The routine <b class="routine"><i class="routine">snmpdPktProcess</i></b><b>(&nbsp;)</b> begins processing the packet and hands the information to the user-defined routine <b class="routine"><i class="routine">snmpIoCommunityValidate</i></b><b>(&nbsp;)</b>.</li></ol></p><p><ol class="List"><li value="3."><a name="84145"> </a><b class="routine"><i class="routine">snmpIoCommunityValidate</i></b><b>(&nbsp;)</b> validates the PDU's community name by checking it against a table which specifies permissions for various communities, translates the community to a view index, and allocates private packet memory; if needed, this memory can be deallocated with a private-memory-deallocation hook (see <a href="c-agent8.html#83905"><i class="title">4.8&nbsp;Hooks</i></a>).</li></ol></p><p><ol class="List"><li value="4."><a name="84149"> </a>The request is then processed by user-defined method routines. For <b class="keyword">SET</b> requests, hooks are activated at the appropriate time. For any asynchronous routines, a thread must take over processing from the main method routine code.</li></ol></p><p><ol class="List"><li value="5."><a name="84150"> </a>The information presented by the method routines is framed as a response PDU. The user-defined routine <b class="routine"><i class="routine">snmpIoWrite</i></b><b>(&nbsp;)</b> issues a response to the calling Network Management Station.</li></ol></p><p><ol class="List"><li value="6."><a name="84151"> </a>Resources allocated for hooks, for variable-binding in generating the response PDU, and for other agent activities are freed, and the process returns to its calling environment.</li></ol></p></dl><dl class="margin"><dd><p class="Body"><a name="84152"> </a>For more information on individual routines, see <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84153">4.12.3  &nbsp;&nbsp;Trap Processing</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84154"> </a>The following diagram describes the processing of traps, which are generated when a significant event occurs (see <a href="c-agent7.html#83785"><i class="title">4.7&nbsp;Traps</i></a>). Traps can be generated in two ways:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84158"> </a>a significant event can trigger an invocation of the designer-defined routine <b class="routine"><i class="routine">snmpIoTrapSend</i></b><b>(&nbsp;)</b>, which then invokes <b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b></li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84159"> </a>other designer-defined traps can invoke <b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> directly</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="84160"> </a>Also, if variables are to be relayed in the trap, a routine can be defined to bind those variables for transport. (For information on variable binding, see <a href="c-agent10.html#83927"><i class="title">4.10&nbsp;Access to MIB Variables</i></a>).<div class="frame"><h4 class="EntityTitle"><a name="84777"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-4:&nbsp;&nbsp;SNMP Trap Processing</font></a></h4><dl class="margin"><div class="CellBody"><a name="84736"> </a><img class="figure" border="0" src="images/c-agenta7.gif"></div></dl></div></p><dd><p class="Body"><a name="84196"> </a>The stages involved in trap processing can be described as follows.</p></dl><dl class="margin"><p><ol class="List"><li value="1."><a name="84200"> </a>A significant event occurs (see <a href="c-agent7.html#83785"><i class="title">4.7&nbsp;Traps</i></a>).</li></ol></p><p><ol class="List"><li value="2."><a name="84201"> </a><b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> is invoked, either from a call to the user-defined routine <b class="routine"><i class="routine">snmpIoTrapSend</i></b><b>(&nbsp;)</b> or directly from user-defined trap code.</li></ol></p><p><ol class="List"><li value="3."><a name="84202"> </a><b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> creates an SNMPv1- or SNMPv2c-style trap message, depending on the trap's input parameter.</li></ol></p><p><ol class="List"><li value="4."><a name="84203"> </a>If required, <b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> invokes a user-defined variable-binding routine to bind any variables in the trap.</li></ol></p><p><ol class="List"><li value="5."><a name="84204"> </a><b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> encodes the message as an SNMP packet, which is then handed off to <b class="routine"><i class="routine">snmpIoWrite</i></b><b>(&nbsp;)</b> for delivery to Network Management Stations.</li></ol></p><p><ol class="List"><li value="6."><a name="84205"> </a>Resources allocated for the variable-binding routine and for other agent activities are freed, and the process returns to its calling environment.</li></ol></p></dl><dl class="margin"><dd><p class="Body"><a name="84206"> </a>For more information on individual routines, see <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="84207">4.12.4  &nbsp;&nbsp;Exiting the Agent</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84208"> </a>In the event that the agent designer's code determines that the SNMP agent must exit, the code must free its allocated resources and then invoke the function <b class="routine"><i class="routine">snmpdExit</i></b><b>(&nbsp;)</b>.<div class="frame"><h4 class="EntityTitle"><a name="84813"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 4-5:&nbsp;&nbsp;SNMP Agent Exit</font></a></h4><dl class="margin"><div class="CellBody"><a name="84785"> </a><img class="figure" border="0" src="images/c-agenta8.gif"></div></dl></div></p><dd><p class="Body"><a name="84226"> </a><b class="routine"><i class="routine">snmpdExit</i></b><b>(&nbsp;)</b> calls MIB termination routines and frees all resources allocated by the agent itself. The user's code must then delete the associated task. After <b class="routine"><i class="routine">snmpdExit</i></b><b>(&nbsp;)</b> is called, no other SNMP services should be invoked.</p><dd><p class="Body"><a name="85519"> </a>For information on hook routines, see the reference entry for <b class="routine"><i class="routine">snmpdInitFinish</i></b><b>(&nbsp;)</b> in <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>.</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="c-agent.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-agent11.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-config.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 + -