masteriolib.html

来自「vxworks相关论文」· HTML 代码 · 共 541 行 · 第 1/2 页

HTML
541
字号
</blockquote><h4>ASYNCHRONOUS COMMUNICATION</h4><blockquote><p><p>The shipped version of <b><i>snmpQueMonitor</i>(&nbsp;)</b> uses <b><i><a href="./subagentLib.html#snmpMasterHandlerWR">snmpMasterHandlerWR</a></i>(&nbsp;)</b> andthus processes messages asynchronously.  However, if necessary, you canrewrite <b><i>snmpQueMonitor</i>(&nbsp;)</b> to call <b><i><a href="./subagentLib.html#snmpMasterHandlerAsync">snmpMasterHandlerAsync</a></i>(&nbsp;)</b> instead.  Formore information on <b><i><a href="./subagentLib.html#snmpMasterHandlerAsync">snmpMasterHandlerAsync</a></i>(&nbsp;)</b>, see its reference entry.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterIpcComp"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterIpcComp</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterIpcComp</i>(&nbsp;)</strong> - transmit a completion of transmission message</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void masterIpcComp    (    OCTET_T     opcode,   /* this specifies what needs to be done */    EBUFFER_T * ebuf,     /* reply message to be sent */    VBL_T *     vblist,   /* list of varbinds that the message contained */    PTR_T       ipchandle /* subagent address */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>If the SNMP master agent uses <b><i><a href="./subagentLib.html#snmpMasterHandlerAsync">snmpMasterHandlerAsync</a></i>(&nbsp;)</b> to processa subagent's unsolicited control message (such as a registration request),it uses <b><i><a href="./masterIoLib.html#masterIpcComp">masterIpcComp</a></i>(&nbsp;)</b> to complete processing for the message.  In thecurrent implementation, this means telling the subagent the completionstatus of a registration or deregistration request.  However, you canrewrite this function to implement a broader range of responses (suchas forwarding traps to the SNMP manager).<p>When the master agent calls this routine, it uses <i>opcode</i> to indicatethe processing status of the message.  If the status indicates an error,<b><i><a href="./masterIoLib.html#masterIpcComp">masterIpcComp</a></i>(&nbsp;)</b> drops the packet.  If the status indicates success, themaster agent uses the <i>ebuf</i> parameter to pass in a message for the subagentat <i>ipchandle</i>.  Internally, <b><i><a href="./masterIoLib.html#masterIpcComp">masterIpcComp</a></i>(&nbsp;)</b> calls <b><i><a href="./masterIoLib.html#masterIoWrite">masterIoWrite</a></i>(&nbsp;)</b> toforward the message to the specified subagent.  If this message is theresponse to a successful registration request, it contains the group IDfor the MIB variables just added to the master agent's MIB tree.  Thesubagent needs this group ID for any deregistration request it mightsend later.  It also uses this ID to register instances of the objectjust registered.<p>If the <i>opcode</i> is a value of 1 or greater (up to and including 127),the master agent uses the <i>vblist</i> parameter to pass in a varbind listthat it extracted from the control message.  In the current implementation,the <b><i><a href="./masterIoLib.html#masterIpcComp">masterIpcComp</a></i>(&nbsp;)</b> routine does nothing with the message and returns.However, you could modify <b><i><a href="./masterIoLib.html#masterIpcComp">masterIpcComp</a></i>(&nbsp;)</b> to process the message accordingto the value specified by <i>opcode</i>.  For example, if <i>opcode</i> indicatesa trap, you could forward the information at <i>vblist</i> to the SNMP manager.<p>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).  You arefree to use the remaining opcodes for message types specific to yourimplementation.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterIoWrite"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterIoWrite</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterIoWrite</i>(&nbsp;)</strong> - send the encoded buffer to the subagent</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS masterIoWrite    (    EBUFFER_T * pBuf, /* reply message to be sent */    PTR_T       saId, /* subagent address */    INT_32_T    flg   /* type of message */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine transmits the byte array at <i>pBuf</i> to the subagent at <i>saId</i>.This routine is called from a wide variety of functions in the masteragent.  For example, <b><i><a href="./masterIoLib.html#masterIpcSend">masterIpcSend</a></i>(&nbsp;)</b> calls this routine when it needsto query the subagent about one of the MIB variables it manages.  Likewise,the <b><i><a href="./masterIoLib.html#masterIpcAyt">masterIpcAyt</a></i>(&nbsp;)</b> function calls this routine when needs to check the IPClink status.  Similarly, <b><i>snmpQueMonitor</i>(&nbsp;)</b> calls this routine to tell theagent the results of a registration or deregistration request.<p>The master agent uses the value <i>flg</i> to specify the general nature ofthe message it is writing to the subagent, which partially determines howthe subagent responds.  For example, when the master agent is respondingto the subagent after successfully handling its registration request, themaster agent uses a <i>flg</i> value of <b>REG_COMPLETE</b>.  When the master agentdoes an "are you there" check, it specifies a <i>flg</i> value of <b>IPC_AYT</b>.<b>REG_COMPLETE</b> and <b>IPC_AYT</b> are the only currently valid <i>flg</i> values.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK or ERROR.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterIpcSend"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterIpcSend</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterIpcSend</i>(&nbsp;)</strong> - send a message to a subagent</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>INT_32_T masterIpcSend    (    EBUFFER_T * pBuf,     /* message to be sent */    PTR_T       ipchandle /* address of subagent */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>The SNMP master agent calls when it needs to send a query in <i>buf</i> tothe subagent at the <i>ipchandle</i> address. If this routine is used with<b><i><a href="./subagentLib.html#snmpMasterHandlerAsync">snmpMasterHandlerAsync</a></i>(&nbsp;)</b>, you must rewrite the function according to theprototype of <b>IPCSEND_AS_T</b> (see <b>subagent.h</b>). The additionalparameter <i>reqid</i> in this prototype is the request ID of the messagebeing sent. Use <i>reqid</i> to call <b><i><a href="./subagentLib.html#snmpMasterCleanup">snmpMasterCleanup</a></i>(&nbsp;)</b> if the IPC layertimes out.<p>Internally, this function calls <b><i><a href="./masterIoLib.html#masterIoWrite">masterIoWrite</a></i>(&nbsp;)</b> to put a message on thesubagent's message queue.  If you have rewritten <b><i><a href="./masterIoLib.html#masterIoWrite">masterIoWrite</a></i>(&nbsp;)</b> to usedifferent IPC mechanism, such as sockets, you should take care that yourrewrite of <b><i><a href="./masterIoLib.html#masterIoWrite">masterIoWrite</a></i>(&nbsp;)</b> is compatible with its use in <b><i><a href="./masterIoLib.html#masterIpcSend">masterIpcSend</a></i>(&nbsp;)</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>0, if the packet has been sent successfully; 1, if and error has<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;been&nbsp;detected&nbsp;that&nbsp;caused&nbsp;the&nbsp;objects&nbsp;to&nbsp;be&nbsp;marked&nbsp;inactive&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;possibly&nbsp;removed;&nbsp;2,&nbsp;if&nbsp;the&nbsp;processing&nbsp;of&nbsp;the&nbsp;current&nbsp;packet&nbsp;is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;allowed&nbsp;to&nbsp;continue&nbsp;without&nbsp;freeing&nbsp;up&nbsp;objects.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterIpcRcv"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterIpcRcv</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterIpcRcv</i>(&nbsp;)</strong> - wait for a reply from the subagent</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>INT_32_T masterIpcRcv    (    EBUFFER_T * pBuf,     /* buffer to be filled */    PTR_T       ipchandle /* pointer to the IPC handle */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine waits for a response after query has been sent to thesubagent.  In the shipped implementation of the WindNet SNMP master agent,this function waits on a message queue that is local to the master agent.This message queue is used to facilitate communication between <b>tSnmpd</b>,the task that manages communication with the SNMP manager, and <b>tMonQue</b>,the task that manages communication between the SNMP master agent andits subagents.<p>In the shipped master agent code, subagents communicate with the masteragent by putting messages on the message queue monitored by <b>tMonQue</b>.If the message is a control message, it is processed by <b><i><a href="./subagentLib.html#snmpMasterHandlerWR">snmpMasterHandlerWR</a></i>(&nbsp;)</b>.If the message is a query response, it is transferred to the local messagequeue on which <b><i><a href="./masterIoLib.html#masterIpcRcv">masterIpcRcv</a></i>(&nbsp;)</b> is waiting.  All of this is handledsynchronously.  Thus, while the master agent is waiting for a responsefrom the subagent, it is blocked.  Normally, the amount of time spentblocked is quite short and is not a problem.<p>However, it is an imperfect world, so it is possible that a responsefor a query never makes it back to the subagent.  To handle thispossibility, the shipped version of the WindNet SNMP master agent putsa timeout on its wait for a query response.  If you should rewrite theSNMP master agent for any reason, make sure that you preserve this timeout.<p></blockquote><h4>RETURNS</h4><blockquote><p>0, if the packet was received successfully; 1, if an error or a<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;timeout&nbsp;has&nbsp;caused&nbsp;the&nbsp;objects&nbsp;to&nbsp;be&nbsp;marked&nbsp;inactive&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subsequently&nbsp;removed;&nbsp;2,&nbsp;if&nbsp;the&nbsp;master&nbsp;agent&nbsp;will&nbsp;allow&nbsp;the&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;current&nbsp;packet&nbsp;to&nbsp;be&nbsp;processed&nbsp;without&nbsp;freeing&nbsp;objects.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterIpcAyt"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterIpcAyt</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterIpcAyt</i>(&nbsp;)</strong> - check the status of the IPC link</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>INT_32_T masterIpcAyt    (    PTR_T ipchandle /* pointer to IPC handle */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This is an "are you there" routine.  The SNMP master agent calls thisroutine whenever it needs to do a status check on the IPC link to the address <i>ipchandle</i>.  This routine puts a null-buffer message of type <b>IPC_AYT</b> on the subagent's message queue. If the subagent replies with a message of the same type, the link is considered active.<p></blockquote><h4>RETURNS</h4><blockquote><p>0, if the link is inactive; 1, if the link is inactive</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterIpcFree"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterIpcFree</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterIpcFree</i>(&nbsp;)</strong> - free the IPC resources allocated by the SNMP master agent</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void masterIpcFree    (    PTR_T ipchandle /* pointer to IPC handle */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>The SNMP master agent calls this routine to free a pointer to an IPC handle.This is part of the deregistration process for an SNMP agent.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b><hr><a name="masterQueCleanup"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>masterQueCleanup</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>masterQueCleanup</i>(&nbsp;)</strong> - free resources allocated for SNMP master agent</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void masterQueCleanup (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine is called from the cleanup routine in <b><a href="./snmpIoLib.html#top">snmpIoLib</a></b> if theagent fails to allocate resources.  This routine deletes the message queueand all other resources that have been allocated for the master agent.<p></blockquote><h4>RETURNS</h4><blockquote><p>N/A</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./masterIoLib.html#top">masterIoLib</a></b></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?