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

📄 c-extend5.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>    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-extend4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-sub_agents.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="84336">6.5  &nbsp;&nbsp;Asynchronous Method Routines</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84337"> </a>Method routines can be written to behave asynchronously from the SNMP agent. In this case, the method routine spawns a task to complete the requested activities, and the method routine returns before the task completes.</p></dl></dl><dl class="margin"><dd><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><a name="85971"><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>The processing of a single message from an SNMP master may require the execution of several method routines. As mentioned above, it is possible for the SNMP agent to run these method routines asynchronously. However, this does not make the SNMP agent asynchronous with respect to the SNMP manager. The SNMP agent processes messages from the SNMP manager synchronously. Thus, it does not accept a new message until it has completed processing for the last message. <hr></div></td></tr></table><dl class="margin"><dd><p class="Body"><a name="85962"> </a>The method routine must first lock the packet in question using <b class="routine"><i class="routine">snmpdPktLockGet</i></b><b>(&nbsp;)</b>, and call the appropriate process mechanism depending on the type of operation (<b class="routine"><i class="routine">getproc_started</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">nextproc_started</i></b><b>(&nbsp;)</b>, or <b class="routine"><i class="routine">setproc_started</i></b><b>(&nbsp;)</b>) to indicate that the activity has begun.</p><dd><p class="Body"><a name="84339"> </a>When the task completes, which is again indicatedwith a call to the appropriate process mechanism (<b class="routine"><i class="routine">getproc_good</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">nextproc_good</i></b><b>(&nbsp;)</b>, or <b class="routine"><i class="routine">setproc_good</i></b><b>(&nbsp;)</b>), the routine must call <b class="routine"><i class="routine">snmpdContinue</i></b><b>(&nbsp;)</b> to complete processing of the packet and issue the response.</p><dd><p class="Body"><a name="84340"> </a>For more information on process mechanisms, see the manual pages for snmpProcLib and for the individual process routines in <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>. Also see the manual pages for <b class="routine"><i class="routine">snmpdPktLockGet</i></b><b>(&nbsp;)</b> and <b class="routine"><i class="routine">snmpdContinue</i></b><b>(&nbsp;)</b> in the same section.</p></dl></dl><h4 class="EntityTitle"><a name="84341"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-10:&nbsp;&nbsp;Asynchronous Method Routine</font></a></h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="84342">groupGet     (     OIDC_T              lastmatch,     int                 compc,     OIDC_T *            compl,     SNMP_PKT_T *        pktp,     VB_T *              vbp     )     {      snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl);      if ( (compc != 1) || (*compl != 0) )          {         for ( ; vbp != NULL; vbp = vbp-&gt;vb_link)             {             getproc_nosuchins (pktp, vbp);             }         return;         }      /* At this stage we are ready to spawn an asynchronous task that will        continue withe the job of getting the vars and installing those        values in the response pkt. However we must first indicate to the        agent that the getproc for all these varbinds has been started,        else the agent could start them again */      for (vbp = pVbpSaved ; vbp != NULL; vbp = vbp-&gt;vb_link)             {             getproc_started (pktp, vbp);             }      /* Now spawn the asynch routine */      status = taskSpawn (asyncRtn, ...);      if (status != OK)         {         for (vbp = pVbpSaved ; vbp != NULL; vbp = vbp-&gt;vb_link)             {             getproc_error (pktp, vbp);             return;             }         }        return;      }   void asyncRtn     (     OIDC_T              lastmatch,     int                 compc,     OIDC_T *            compl,     SNMP_PKT_T *        pktp,     VB_T *              vbp     )     {       /* time consumng tasks done here */       .....       /* after doing all the time consuming  tasks we are now ready to         install the values in the pkt. */       snmpdPktLockGet (pktp);             for (vbp = pVbpSaved ; vbp != NULL; vbp = vbp-&gt;vb_link)             {              /* Do whatever steps are reqd to install the var bind value                  as in the synchronous method routines */               ......               }       snmpdContinue (pktp);      }  </a></b></pre></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-extend.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-extend4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-sub_agents.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 + -