mkDPIset()--Make a DPI Set Packet


  Syntax
 #include <qtossapi.h>

 snmp_dpi_set_packet *mkDPIset(
      snmp_dpi_set_packet *packet_p,
      char                *group_p,
      char                *instance_p,    
      int                 value_type,
      int                 value_len,
      void                *value_p );

  Service Program Name: QTOSSAPI

  Default Public Authority: *USE

  Threadsafe: No

The mkDPIset() function makes a DPI set structure and adds it to a chained list of set structures if previous calls have been made.


Authorities and Locks

None.


Parameters

packet_p
(Input) A pointer to a chain of snmp_dpi_set_packet structures. Pass a NULL pointer if this is the first structure to be created. Typically, to handle multiple varbinds, this routine will be called repeatedly with this parameter having as its value the result returned from the previous call. Each new snmp_dpi_set_packet will be chained at the end.

group_p
(Input) A pointer to a NULL-terminated character string that represents the registered subtree that caused this GET request to be passed to this DPI subagent. The subtree must have a trailing dot.

instance_p
(Input) A pointer to a NULL-terminated character string that represents the rest (the piece following the subtree part) of the OBJECT IDENTIFIER of the variable instance being accessed. Use of the term instance_p here should not be confused with an OBJECT instance because this instance_p string may consist of a piece of the OBJECT IDENTIFIER plus the INSTANCE IDENTIFIER.

value_type
(Input) The type of the value.

See the <qtossapi.h> file for a list of currently defined value types.

value_len
(Input) A signed integer that specifies the length (in bytes) of the value pointed to by the value_p parameter. The length may be zero if the value is of type SNMP_TYPE_NULL.

value_p
(Input) A pointer to the actual value. This parameter may contain a NULL pointer if the value is of (implicit or explicit) type SNMP_TYPE_NULL.

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.

For more information, see "SNMP Subagent Problem Determination" in the Simple Network Management Protocol Link to PDF book.


Usage Notes

The mkDPIset() function is used at the subagent side to prepare a chain of one or more snmp_dpi_set_packet structures. This chain is then later used to create a DPI packet, using a call to mkDPIresponse() or mkDPItrap(), which can then be sent to an SNMP agent. Each occurrence of an snmp_dpi_set_packet corresponds to a varbind in a protocol data unit (PDU).

This function is unlike the other subagent APIs that have names beginning mkDPI, in that this function does not make a DPI packet that can be sent directly. Hence, it returns a pointer to an snmp_dpi_set_packet rather than a char * (as do the other mkDPI functions).

Note that if the nth (n > 1) call to this function fails for some reason, the pointer to the chain of previously built snmp_dpi_set_packet structures will be lost unless the caller saves it.


Related Information


Example

See Code disclaimer information for information pertaining to code examples.

  #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
Top | UNIX-Type APIs | APIs by category