#include <qtossapi.h> int waitDPIpacket( long int timeout, void *dpimsgbuff_p, unsigned long int *length );
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.
So that the subagent can receive messages from the SNMP agent, the following conditions must be met:
Possible values have the indicated meaning;
< 0 | Unlimited wait |
0 | No wait. This causes an immediate return if a data queue message is not present. |
> 0 | The number of seconds to wait (maximum is 99999). |
The return values are defined in the <qtossapi.h> file.
0 | snmpsa_RC_ok
The routine was successful. |
-1 | snmpsa_RC_err
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.) |
-2 | snmpsa_RC_noagent
The SNMP agent is not available. |
-3 | snmpsa_RC_mismatch
A previous DPI packet was found. The subagent may want to process this packet or call the receiveDPIpacket() function again to get the next packet. |
-4 | snmpsa_RC_timedout
No message was received within the specified timeout. |
-5 | snmpsa_RC_nonagentmsg
A data queue message arrived that is not from the SNMP agent. |
-6 | snmpsa_RC_dqinvalid
The subagent data queue or library is invalid. This refers to the data queue and library used in the connectSNMP() call. |
-7 | snmpsa_RC_parmerr
A parameter error occurred, probably a null pointer. |
-8 | snmpsa_RC_lengtherr
A parameter was an incorrect length. |
-9 | snmpsa_RC_buffer
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. |
-12 | snmpsa_RC_connectfirst
The subagent must connect to the SNMP agent before making this call. |
For more information, see "SNMP Subagent Problem Determination" in the Simple Network Management Protocol book.
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.
See Code disclaimer information for information pertaining to code examples.
#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*/
Top | UNIX-Type APIs | APIs by category |