z/OS Communications Server: IP Programmer's Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


The DPIsend_packet_to_agent() function

z/OS Communications Server: IP Programmer's Guide and Reference
SC27-3659-02

Format

#include <snmp_dpi.h>
 
int DPIsend_packet_to_agent(       /* send  a DPI packet      */
  int                   handle,    /* on this connection      */
  unsigned char        *message_p, /* ptr to the packet data  */
  unsigned long         length);   /* length of the packet    */

Parameters

handle
A handle as obtained with a DPIconnect_to_agent_xxxx() call.
message_p
A pointer to the buffer containing the DPI packet to be sent.
length
The length of the DPI packet to be sent. The DPI_PACKET_LEN macro is a useful macro to calculate the length.

Return codes

If successful, a 0 (DPI_RC_OK) is returned.

If not successful, a negative integer is returned, which indicates the kind of error that occurred. See Return codes from DPI transport-related functions for a list of possible error codes.

DPI_RC_NOK
This is a return code, but it really means the DPI code is out of sync or has a bug.
DPI_RC_IO_ERROR
An error occurred with an underlying send(), or the send() failed to send all of the data on the socket (incomplete send).
DPI_RC_INVALID_ARGUMENT
The message_p parameter is NULL or the length parameter has a value of 0.
DPI_RC_INVALID_HANDLE
A bad handle was passed as input. Either the handle is not valid, or it describes a connection that has been disconnected.

Usage

The DPIsend_packet_to_agent() function is used at the subagent side to send a DPI packet to the DPI-capable SNMP agent.

Examples

  #include <snmp_dpi.h>
  int                  handle;
  unsigned char       *pack_p;
 
  handle = DPIconnect_to_agent_TCP("127.0.0.1", "public");
  if (handle < 0) {
     printf("Error %d from connect\n",handle);
     exit(1);
  } /* endif */
  pack_p = mkDPIopen("1.3.6.1.2.3.4.5",
                "Sample DPI subagent"
                0L,2L,,DPI_NATIVE_CSET,
                0,(char *)0);
  if (pack_p) {
     rc = DPIsend_packet_to_agent(handle,pack_p,
                         DPI_PACKET_LEN(pack_p));
     if (rc) {
        printf("Error %d from send packet\n");
        exit(1);
     } /* endif */
  } else {
     printf("Can't make DPI OPEN packet\n");
     exit(1);
  } /* endif */
  /* await the response */

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014