mkDPIresponse()--Make a DPI Response Packet


  Syntax
 #include <qtossapi.h>

 unsigned char     *mkDPIresponse(
      snmp_dpi_hdr        *hdr_p,
      long int            error_code,
      long int            error_index,
      snmp_dpi_set_packet *packet_p );   


  Service Program Name: QTOSSAPI

  Default Public Authority: *USE

  Threadsafe: No

The mkDPIresponse() function makes a DPI® response packet and returns a pointer to the packet.


Authorities and Locks

None.


Parameters

hdr_p
(Input) A pointer to the snmp_dpi_hdr structure of the DPI request to which this DPI packet will be the response. The function uses this structure to copy the packet_id and the DPI version and release so that the DPI packet is correctly formatted as a response.

error_code
(Input) The error code from the <qtossapi.h> file.

error_index
(Input) The first varbind in error. Counting starts at 1 for the first varbind. This field should be zero if there is no error.

packet_p
(Input) A pointer to a chain of snmp_dpi_set_packet structures. This partial structure will be freed by the mkDPIresponse() function. Therefore, on return, you cannot refer to it anymore. Pass a NULL pointer if there are no varbinds to be returned.

Return Value

value The value returned is a pointer to the DPI packet.

If successful, then a pointer to a static DPI packet buffer is returned. The first 2 bytes of the buffer (in network byte order) contain the length of the remaining packet. The DPI_PACKET_LEN() function can be used to calculate the total length of the DPI packet.

NULL If unsuccessful, then a NULL pointer is returned.

Be aware that the static buffer for the DPI packet is shared by other mkDPIxxxx() functions that create a serialized DPI packet.

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


Usage Notes

The mkDPIresponse() function is used by a subagent to prepare a DPI RESPONSE packet to a GET, GETNEXT, SET, COMMIT, or UNDO request. The resulting packet can be sent to the SNMP agent.

Unnecessary free operations may result in an MCH6902 (type 2). If this occurs, remove the call to fDPIset().


Related Information


Example

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

  #include <qtossapi.h>
  unsigned char       *pack_p;
  snmp_dpi_hdr        *hdr_p;
  snmp_dpi_set_packet *set_p;
  long int             num;

  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. */
        }
     }
  }




API introduced: V3R6

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