connectSNMP()--Establish Connection with SNMP Agent


  Syntax
 #include <qtossapi.h>

 int               connectSNMP(
           char         *queue_name,   
           char         *lib_name,
           long int     timeout );


  Service Program Name: QTOSSAPI

  Default Public Authority: *USE

  Threadsafe: No

The connectSNMP() function establishes a logical connection between the SNMP subagent and the local (the same system) SNMP agent. The data queue named by the queue_name 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 mkDPIregister()--Make a DPI Register Packet.)


Authorities

So that the subagent can receive messages from the SNMP agent, the following conditions must be met:


Parameters

queue_name
(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 IBM® i rules for data queue names (such as using uppercase letters and starting with a letter, $, #, @, and so forth).

lib_name
(Input) The name of the IBM i library (as a null-terminated string) to which the data queue belongs. QTEMP is not an allowed value. The value must conform to IBM i rules for library names (such as using uppercase letters and starting with a letter, $, #, @, and so forth).

Note that the actual character representation of the specific library name must be used. Special values such as *LIBL and *CURLIB are not allowed.

timeout
(Input) The amount of time in seconds that the subagent is willing to wait for a connection. This field may contain the following values:

Any other values result in an error return code.


Return Value

The return values are defined in the <qtossapi.h> file in the QSYSINC library.

For more information, see the Simple Network Management Protocol (SNMP) SupportLink to PDF manual.


Usage Notes

The connectSNMP() 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.

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 debugDPI(), DPI_PACKET_LEN(), and mkDPIAreYouThere().


Related Information


Example

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

  #include <qtossapi.h>
  int      rc;

  rc = connectSNMP( "QABCDEFG", "LIBABC", 0 );
  if (rc) {
     /* Handle exception. */
  }



API introduced: V3R6

[ Back to top | UNIX-Type APIs | APIs by category ]