301 lines
9.1 KiB
HTML
301 lines
9.1 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>connectSNMP()--Establish Connection with SNMP Agent</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- 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. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- YYMMDD USERID Change description -->
|
||
|
<!-- Direct1 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
||
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
||
|
<!-- Edited by Kersten Feb 02 -->
|
||
|
<!-- End Header Records -->
|
||
|
<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>connectSNMP()--Establish Connection with SNMP Agent</h2>
|
||
|
|
||
|
<div class="box" style="width: 60%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
<pre>
|
||
|
#include <qtossapi.h>
|
||
|
|
||
|
int connectSNMP(
|
||
|
char <em>*queue_name</em>,
|
||
|
char <em>*lib_name</em>,
|
||
|
long int <em>timeout</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>connectSNMP()</strong> function establishes a logical connection
|
||
|
between the SNMP subagent and the local (the same iSeries server) SNMP agent.
|
||
|
The data queue named by the <em>queue_name</em> parameter is used by the SNMP
|
||
|
agent as the target data queue in a call to the Send Data Queue (QSNDDTAQ) API
|
||
|
when it sends a message to the subagent. Only a single connection is allowed
|
||
|
per data queue and library, hence a subagent may have only a single data queue.
|
||
|
(Of course, a subagent may have multiple registrations. See <a href=
|
||
|
"regsnmp.htm">mkDPIregister()--Make a DPI Register Packet</a>.)</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 library and data queue whose names are passed as a parameter in the
|
||
|
<strong>connectSNMP()</strong> call must exist prior to the call.<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<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>queue_name</strong></dt>
|
||
|
|
||
|
<dd>(Input) The name of the data queue (as a null-terminated string) on which
|
||
|
the subagent wants to receive Distributed Protocol Interface (DPI) packets. The
|
||
|
value must conform to i5/OS rules for data queue names (such as using
|
||
|
uppercase letters and starting with a letter, $, #, @, and so forth).<br>
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>lib_name</strong></dt>
|
||
|
|
||
|
<dd>(Input) The name of the i5/OS library (as a null-terminated string) to
|
||
|
which the data queue belongs. QTEMP is not an allowed value. The value must
|
||
|
conform to i5/OS rules for library names (such as using uppercase letters and
|
||
|
starting with a letter, $, #, @, and so forth).
|
||
|
|
||
|
<p>Note that the actual character representation of the specific library name
|
||
|
must be used. Special values such as *LIBL and *CURLIB are not allowed.</p>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong>timeout</strong></dt>
|
||
|
|
||
|
<dd>(Input) The amount of time in seconds that the subagent is willing to wait
|
||
|
for a connection. This field may contain the following values:
|
||
|
|
||
|
<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">The number of seconds to wait (maximum is
|
||
|
2 147 483 647)</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>Any other values result in an error return code.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<p>The return values are defined in the <strong><qtossapi.h></strong>
|
||
|
file in the QSYSINC library.</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 call 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>There is a code-level mismatch between the agent and the subagent. If this
|
||
|
occurs, report the problem to the appropriate service organization.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-4</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_timedout</em>
|
||
|
|
||
|
<p>The specified timeout value was exceeded.</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. This is more likely caused by errors in the
|
||
|
value of a parameter (for example, a value was too large or too small) or by a
|
||
|
pointer parameter that has a NULL value and should not. For char* parameters,
|
||
|
it may also be caused if the length of the string exceeds some limit.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-8</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_lengtherr</em>
|
||
|
|
||
|
<p>During an attempt to communicate with the agent, a length exception
|
||
|
occurred.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-9</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_buffer</em>
|
||
|
|
||
|
<p>An internal buffer was not obtained. See any messages in the job log and
|
||
|
correct any errors that are indicated, then retry the operation.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-10</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_duplicate</em>
|
||
|
|
||
|
<p>The agent already has a subagent with this queue and library name. The
|
||
|
subagent may continue as usual with the <strong>mkDPIopen()</strong> and
|
||
|
<strong>mkDPIregister()</strong> functions. If these fail, the subagent should
|
||
|
use different library and queue names.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top"><em>-13</em></td>
|
||
|
<td align="left" valign="top"><em>snmpsa_RC_alreadyconnected</em>
|
||
|
|
||
|
<p>The subagent is already connected using the same data queue and library
|
||
|
names passed on the call. If the SNMP agent still does not forward requests to
|
||
|
the subagent properly, use the <strong>disconnectSNMP()</strong> function, then
|
||
|
the <strong>connectSNMP()</strong> function.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>For more information, see "SNMP Subagent Problem Determination" in
|
||
|
the <a href="../bookssc415412.pdf" target="_blank">Simple Network
|
||
|
Management Protocol (SNMP) Support</a> <img src="wbpdf.gif" alt="Link to PDF">
|
||
|
book.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Usage Notes</h3>
|
||
|
|
||
|
<p>The <strong>connectSNMP()</strong> function establishes a logical connection
|
||
|
with the SNMP agent that is running on the same system as the subagent. This is
|
||
|
normally the first subagent API that a subagent calls.</p>
|
||
|
|
||
|
<p>This API, like all the subagent APIs, checks to ensure that the pointers
|
||
|
passed are generally valid for user data, for example, user domain. Such audits
|
||
|
occur for all pointer parameters and for all pointers that appear in all C
|
||
|
structures that are passed as parameters. If one of these checks fail, a
|
||
|
CPF9872 exception is generated. This can occur from all the subagent APIs
|
||
|
except <strong>debugDPI()</strong>, <strong>DPI_PACKET_LEN()</strong>, and
|
||
|
<strong>mkDPIAreYouThere()</strong>.</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="discsnmp.htm">disconnectSNMP()</a>--End Connection with SNMP
|
||
|
Agent<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="regsnmp.htm">mkDPIregister()</a>--Make a DPI Register 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>
|
||
|
int rc;
|
||
|
|
||
|
rc = connectSNMP( "QABCDEFG", "LIBABC", 0 );
|
||
|
if (rc) {
|
||
|
/* Handle exception. */
|
||
|
}
|
||
|
|
||
|
</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>
|
||
|
|