waitDPIpacket()--Wait for a DPI Packet


  Syntax
 #include <qtossapi.h>

 int   waitDPIpacket(
         long int            timeout,
         void                *dpimsgbuff_p,   
         unsigned long int   *length );


  Service Program Name: QTOSSAPI

  Default Public Authority: *USE

  Threadsafe: No

The waitDPIpacket() function waits for a message on the data queue with which the subagent has previously connected (see connectSNMP()--Establish Connection with SNMP Agent). When a Distributed Protocol Interface (DPI®) packet arrives, this function receives the packet and copies it to a subagent buffer.


Authorities

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


Parameters

timeout
(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).

Possible values have the indicated meaning;


dpimsgbuff_p
(I/O) A pointer to a buffer that is owned by the subagent. This will contain the serialized packet from the SNMP agent when snmpsa_RC_ok is returned. The maximum length of a DPI packet is SNMP_DPI_BUFSIZE, defined in the <qtossapi.h> file. The buffer will contain the data queue message itself if that message is not from the SNMP agent, and waitDPIpacket() will return snmpsa_RC_nonagentmsg.

length
(Output) When snmpsa_RC_ok is returned, the length (in bytes) of the DPI packet received. When snmpsa_RC_nonagentmsg is returned, the length of the data queue message. Otherwise, this value is 0.

Return Value

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

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


Usage Notes

The waitDPIpacket() function waits for a message on the data queue that the subagent specified on the connectSNMP() call. When a data queue message is received, the corresponding DPI packet is copied to the specified subagent buffer.

If a data queue message arrives that is not from the SNMP agent, then it is returned in the buffer and the code snmpsa_RC_nonagentmsg is returned.


Related Information


Example

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

  #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*/


API introduced: V3R6

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