📄 c-extend4.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Extending 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-extend.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-extend3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-extend5.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="84262">6.4 Dynamic MIB Additions</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84263"> </a>As an aid to developing an SNMP agent and its associated MIB, the MIB tree can be dynamically changed at run-time from alternate tasks in VxWorks. The functions <b class="routine"><i class="routine">snmpdTreeAdd</i></b><b>( )</b> and <b class="routine"><i class="routine">snmpdTreeRemove</i></b><b>( )</b> can be used to dynamically add and remove sections of a MIB tree, respectively. For more information, see the explanations of each function in <a href="snmp.refEntries.TOC.html#83416"><i class="title">F. SNMP Reference</i></a>. </p></dl></dl><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="84273"><br></a><img border="0" alt="*" src="icons/warning.gif"> </td><td><div class="Warning"><hr><b class="symbol_UC">WARNING: </b>Sections of the MIB tree can only be removed dynamically if they are added dynamically.<hr></div></td></tr></table><dl class="margin"><dd><p class="Body"><a name="84274"> </a>A MIB addition which is to be added dynamically to the data tree is developed in a similar fashion to that developed at compile-time. </p></dl><dl class="margin"><p><ol class="List"><li value="1."><a name="84275"> </a>Define the information to be managed.</li></ol></p><p><ol class="List"><li value="2."><a name="84276"> </a>Express the information as a MIB definition.</li></ol></p><p><ol class="List"><li value="3."><a name="84277"> </a>Add the new variables to the system.</li></ol></p><p><ol class="List"><li value="4."><a name="84278"> </a>Write the method routines</li></ol></p><p><ol class="List"><li value="5."><a name="84279"> </a>Build the new Management Information Base</li></ol></p><p><ol class="List"><li value="6."><a name="84280"> </a>Load the new MIB into a running SNMP agent</li></ol></p></dl><dl class="margin"><dd><p class="Body"><a name="84281"> </a>Rather than walk through each step, please refer to the above examples in <a href="c-extend3.html#83539"><i class="title">6.3 Compile-time MIB Extensions</i></a> for instructions on Steps 1 through 4.</p></dl></dl><h4 class="EntityTitle"><a name="84285"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-6: Refer to the above examples for illustrations of Steps 1 through 4. </font></a></h4><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="84294"><br></a><img border="0" alt="*" src="icons/note.gif"> </td><td><div class="Note"><hr><b class="symbol_UC">NOTE: </b>If you develop the new MIB extension in the same file as the standard MIB, you can easily extract the new information using the <b class="keyword">EXCLUDE</b> directive (or the <b class="command">mibcomp</b> option <b class="command">-exclude</b>). For more information, see <a href="c-config1.html#83423"><i class="title">5.1 Configuring VxWorks for Use with WindNet SNMP</i></a> and <a href="x-mibcomp4.html#83627"><i class="title">The EXCLUDE Keyword</i></a>.<hr></div></td></tr></table></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h4 class="HStep"><i><a name="84301">Step 5: (Dynamic) Build the New Management Information Base</a></i></h4></font><dl class="margin"><dd><p class="Body"><a name="84302"> </a>Use <b class="command">mibcomp</b> to compile the new MIB information into a C representation of the new data tree. Use the <b class="command">-leaf</b> option to generate a C header file that defines constants specifying the last component of each object's identifier (<b class="symbol_UC">OID</b>) as well as any enumerated values associated with the object's <b class="keyword">SYNTAX</b> and any known bounds on the object's value. (See <a href="x-mibcomp.html#83422"><i class="title">A. The MIB Compiler User's Guide</i></a> for more information on <b class="command">mibcomp</b> and its options.)</p></dl></dl><h4 class="EntityTitle"><a name="84306"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-7: Generating a C Representation of the MIB Data Structure </font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84307"> </a>(The <kbd>\</kbd> character in these command lines indicates continuation onto the next line.)</p><dl class="margin"><dd><pre class="Code2"><b><a name="84308">% mibcomp -l $WIND_BASE/target/src/snmpv1/mibs rfc1155.smi rfc1213.mib \ -start wrs -o mibhand.h -skel.h demo.mib</a></b><dd> <b><a name="84309"></b><tt class="output">% </tt><b>mibcomp -l $WIND_BASE/target/src/snmpv1/mibs rfc1155.smi rfc1213.mib \ -start wrs -o demomib.c demo.mib</a></b><dd> <b><a name="84310"></b><tt class="output">% </tt><b>mibcomp -l $WIND_BASE/target/src/snmpv1/mibs -leaf rfc1155.smi \ rfc1213.mib -start wrs -o mibleaf.h demo.mib</a></b></pre></dl><dd><p class="Body"><a name="84311"> </a>Now compile these C files as shown in the example below.</p></dl></dl><h4 class="EntityTitle"><a name="84312"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-8: Compiling and Linking the Generated Files into a Single Module </font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84313"> </a>This example shows commands for compiling for a 68020-based target. (The <kbd>\</kbd> character indicates continuation onto the next line.)</p><dl class="margin"><dd><pre class="Code2"><b><a name="84314"></b><tt class="output">% </tt><b>cc68k -m68020 -msoft-float -O -fvolatile -fno-builtin -Wall -ansi \ -nostdinc -DCPU=MC68020 -DVXWORKS -I$WIND_BASE/target/h \ -I$WIND_BASE/target/h/snmp/ -I. -c demo.c demomib.c</a></b><dd> <b><a name="84315"></b><tt class="output">% </tt><b>ld68k -r -o demomodule.o demomib.o demo.o</a></b></pre></dl></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h4 class="HStep"><i><a name="84316">Step 6: (Dynamic) Load the New MIB Into a Running SNMP Agent</a></i></h4></font><dl class="margin"><dd><p class="Body"><a name="84317"> </a>Use the <b class="routine"><i class="routine">ld</i></b><b>( )</b> routine under VxWorks to load the newly-created module into VxWorks. Once the module is loaded, use <b class="routine"><i class="routine">snmpdTreeAdd</i></b><b>( )</b> to add the module to the running MIB.</p><dd><p class="Body"><a name="84318"> </a>(For more information on <b class="routine"><i class="routine">ld</i></b><b>( )</b>, see the <i class="title">VxWorks Reference Manual</i>. For more information on <b class="routine"><i class="routine">snmpdTreeAdd</i></b><b>( )</b>, see the appropriate manual page in <a href="snmp.refEntries.TOC.html#83416"><i class="title">F. SNMP Reference</i></a>.)</p></dl></dl><h4 class="EntityTitle"><a name="84319"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-9: Loading New MIB Information into a VxWorks Target</font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84320"> </a>This example loads the new MIB information into a running VxWorks target and adds the information to the MIB tree on the running SNMP agent. NOTE: perform these operations on the VxWorks target, for example in a shell window.</p><dl class="margin"><dd><pre class="Code2"><b><a name="84321">ld < demomodule.o</a></b><dd> <b><a name="84322">snmpdTreeAdd ("1.3.6.1.4.1.731", & wrs_node);</a></b></pre></dl></dl></dl><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="84331"><br></a><img border="0" alt="*" src="icons/note.gif"> </td><td><div class="Note"><hr><b class="symbol_UC">NOTE: </b>Depending on how views were initialized in the agent, you may now need to update the view tables. See <a href="c-agent9.html#83916"><i class="title">4.9 View Tables</i></a>.<hr></div></td></tr></table></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-extend.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-extend3.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-extend5.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 + -