Syntax
#include <snmp_dpi.h>
unsigned char *mkDPIresponse( /* Make a DPI response packet*/
snmp_dpi_hdr *hdr_p, /* ptr to packet to respnd to*/
long int error_code, /* error code: SNMP_ERROR_xxx*/
long int error_index, /* index to varBind in error */
snmp_dpi_set_packet *packet_p);/* ptr to varBinds, a chain */
/* of dpi_set_packets */
Parameters
hdr_p
See DPI RESPONSE Error Codes for a list of valid codes.
Return Values
If successful, a pointer to a static DPI packet buffer is returned. The first two bytes of the buffer in network byte order contain the length of the remaining packet. The macro DPI_PACKET_LEN can be used to calculate the total length of the DPI packet.
If failure, a NULL pointer is returned.
Note: The static buffer for the DPI packet is shared by other mkDPIxxxx() functions that create a serialized DPI packet.
Description
The mkDPIresponse() function is used at the subagent side to prepare a DPI RESPONSE packet to a GET, GETNEXT, GETBULK, SET, COMMIT or UNDO request. The resulting packet can be sent to the DPI peer, which is normally a DPI capable SNMP agent.
Examples
#include <snmp_dpi.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 */
} /* endif */
} /* endif */
} /* endif */
The mkDPIresponse() function is used at the agent side to prepare a DPI RESPONSE packet to an OPEN, REGISTER or UNREGISTER request. In the case of a RESPONSE to a REGISTER request and if there is no error, the actually assigned priority must be passed in the error_index parameter. The resulting packet can be sent to the DPI peer, which is normally a subagent.
Examples
#include <snmp_dpi.h>
unsigned char *pack_p;
snmp_dpi_hdr *hdr_p;
long int priority;
hdr_p = pDPIpacket(pack_p); /* parse incoming packet */
/* assume it's in pack_p */
if (hdr_p) {
/* analyze packet, assume REGISTER and OK */
pack_p = mkDPIresponse(hdr_p,
SNMP_ERROR_DPI_noError,
priority,
snmp_dpi_set_packet_NULL_p);
if (pack_p) {
/* send packet to subagent */
} /* endif */
} /* endif */
Related Information