325 lines
9.2 KiB
HTML
325 lines
9.2 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>waitDPIpacket()--Wait for a DPI Packet</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- Direct1 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
||
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!--End Header Records -->
|
||
|
<!-- Edited by Kersten Feb 02 -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<!-- Java sync-link -->
|
||
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>waitDPIpacket()--Wait for a DPI Packet</h2>
|
||
|
|
||
|
<div class="box" style="width: 65%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
<pre>
|
||
|
#include <qtossapi.h>
|
||
|
|
||
|
int waitDPIpacket(
|
||
|
long int <em>timeout</em>,
|
||
|
void <em>*dpimsgbuff_p</em>,
|
||
|
unsigned long int <em>*length</em> );
|
||
|
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
Service Program Name: QTOSSAPI<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: No<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>waitDPIpacket()</strong> function waits for a message on the
|
||
|
data queue with which the subagent has previously connected (see <a href=
|
||
|
"connsnmp.htm">connectSNMP()--Establish Connection with SNMP Agent</a>). When a
|
||
|
Distributed Protocol Interface (DPI) packet arrives, this function receives the
|
||
|
packet and copies it to a subagent buffer.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Authorities</h3>
|
||
|
|
||
|
<p>So that the subagent can receive messages from the SNMP agent, the following
|
||
|
conditions must be met:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li>The SNMP agent job must have write access to the data queue. If you suspect
|
||
|
a problem with the data queue, check the job log of the SNMP agent job (QTMSNMP
|
||
|
in subsystem QSYSWRK) for TCP4041 messages with reason code 001.</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong>timeout</strong></dt>
|
||
|
|
||
|
<dd>(Input) The number of seconds that the subagent is willing to wait for a
|
||
|
message (a call to this function will block the subagent until a message is
|
||
|
received or until this timeout is reached).
|
||
|
|
||
|
<p>Possible values have the indicated meaning;</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="5 95" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>< 0</em></td>
|
||
|
<td align="left" valign="top">Unlimited wait</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>0</em></td>
|
||
|
<td align="left" valign="top">No wait. This causes an immediate return if a
|
||
|
data queue message is not present.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>> 0</em></td>
|
||
|
<td align="left" valign="top">The number of seconds to wait (maximum is
|
||
|
99999).</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>dpimsgbuff_p</strong></dt>
|
||
|
|
||
|
<dd>(I/O) A pointer to a buffer that is owned by the subagent. This will
|
||
|
contain the serialized packet from the SNMP agent when <em>snmpsa_RC_ok</em> is
|
||
|
returned. The maximum length of a DPI packet is SNMP_DPI_BUFSIZE, defined in
|
||
|
the <strong><qtossapi.h></strong> file. The buffer will contain the data
|
||
|
queue message itself if that message is not from the SNMP agent, and
|
||
|
<strong>waitDPIpacket()</strong> will return
|
||
|
<em>snmpsa_RC_nonagentmsg</em>.<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>length</strong></dt>
|
||
|
|
||
|
<dd>(Output) When <em>snmpsa_RC_ok</em> is returned, the length (in bytes) of
|
||
|
the DPI packet received. When <em>snmpsa_RC_nonagentmsg</em> is returned, the
|
||
|
length of the data queue message. Otherwise, this value is 0.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<p>The return values are defined in the <strong><qtossapi.h></strong>
|
||
|
file.</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="5 95" -->
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>0</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_ok</em>
|
||
|
|
||
|
<p>The routine was successful.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-1</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_err</em>
|
||
|
|
||
|
<p>An exception occurred. Check the subagent job log for the exception
|
||
|
information, correct the condition, and resubmit the subagent job. (This return
|
||
|
code is only used when a more specific return code is not available.)</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-2</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_noagent</em>
|
||
|
|
||
|
<p>The SNMP agent is not available.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-3</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_mismatch</em>
|
||
|
|
||
|
<p>A previous DPI packet was found. The subagent may want to process this
|
||
|
packet or call the <strong>receiveDPIpacket()</strong> function again to get
|
||
|
the next packet.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-4</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_timedout</em>
|
||
|
|
||
|
<p>No message was received within the specified timeout.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-5</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_nonagentmsg</em>
|
||
|
|
||
|
<p>A data queue message arrived that is not from the SNMP agent.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-6</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_dqinvalid</em>
|
||
|
|
||
|
<p>The subagent data queue or library is invalid. This refers to the data queue
|
||
|
and library used in the <strong>connectSNMP()</strong> call.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-7</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_parmerr</em>
|
||
|
|
||
|
<p>A parameter error occurred, probably a null pointer.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-8</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_lengtherr</em>
|
||
|
|
||
|
<p>A parameter was an incorrect length.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-9</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_buffer</em>
|
||
|
|
||
|
<p>Check the job log of the subagent for MCH3802. If found, the problem was
|
||
|
likely due to agent workload, and the subagent can retry the request. If a
|
||
|
different exception is found, see any messages in the job log, correct any
|
||
|
errors that are indicated, and then retry the operation.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-12</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_connectfirst</em>
|
||
|
|
||
|
<p>The subagent must connect to the SNMP agent before making this call.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>For more information, see "SNMP Subagent Problem Determination" in the <a
|
||
|
href="../books/sc415412.pdf" target="_blank">Simple Network Management
|
||
|
Protocol</a> <img src="wbpdf.gif" alt="Link to PDF"> book.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Usage Notes</h3>
|
||
|
|
||
|
<p>The <strong>waitDPIpacket()</strong> function waits for a message on the
|
||
|
data queue that the subagent specified on the <strong>connectSNMP()</strong>
|
||
|
call. When a data queue message is received, the corresponding DPI packet is
|
||
|
copied to the specified subagent buffer.</p>
|
||
|
|
||
|
<p>If a data queue message arrives that is not from the SNMP agent, then it is
|
||
|
returned in the buffer and the code <em>snmpsa_RC_nonagentmsg</em> is
|
||
|
returned.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>qtossapi.h</strong>> file (see <a href="unix13.htm">Header
|
||
|
Files for UNIX-Type Functions</a>)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="connsnmp.htm">connectSNMP()</a>--Establish Connection with SNMP
|
||
|
Agent<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="ppacsnmp.htm">pDPIpacket()</a>--Parse a DPI Packet</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
<h3>Example</h3>
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <qtossapi.h>
|
||
|
#define MAX_LEN 4096
|
||
|
#define waitTIMEOUT 300
|
||
|
unsigned char *pack_p,
|
||
|
dpimsgbuff[MAX_LEN];
|
||
|
snmp_dpi_hdr *hdr_p;
|
||
|
snmp_dpi_set_packet *set_p;
|
||
|
long int num, length;
|
||
|
|
||
|
for(;;) {
|
||
|
|
||
|
rc = waitDPIpacket( waitTIMEOUT,
|
||
|
&dpimsgbuff[0], length );
|
||
|
|
||
|
if (rc<0) {
|
||
|
/* Handle exceptions. */
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
hdr_p = pDPIpacket(pack_p); /* Parse incoming packet. */
|
||
|
/* Assume it's in pack_p. */
|
||
|
if (hdr_p) {
|
||
|
/* Analyze packet, assume GET, no error. */
|
||
|
set_p = mkDPIset(snmp_dpi_set_packet_NULL_p,
|
||
|
"1.3.6.1.2.3.4.5.", "1.0",
|
||
|
SNMP_TYPE_Integer32,
|
||
|
sizeof(num), &num);
|
||
|
if (set_p) {
|
||
|
pack_p = mkDPIresponse(hdr_p,
|
||
|
SNMP_ERROR_noError, 0L, set_p);
|
||
|
if (pack_p) {
|
||
|
/* Send packet to subagent. */
|
||
|
|
||
|
} /*end if*/
|
||
|
} /*end if*/
|
||
|
} /*end if*/
|
||
|
} /*end else*/
|
||
|
} /*end for*/
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
<hr>
|
||
|
API introduced: V3R6
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> |
|
||
|
<a href="unix.htm">UNIX-Type APIs</a> |
|
||
|
<a href="aplist.htm">APIs by category</a> </td>
|
||
|
</tr>
|
||
|
</table></center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|