SNMP Manager Programmer's Guide

Sending and Receiving Packets
SNMP Manager Programmer’s Guide–134249
7-5
Receiving Packets
If the NonStop agent detects an error, it generates an EMS event and returns a file
system error number of 306.
Receiving Packets
The descriptors of the encoded-packet buffer are reinitialized in preparation for handling
the response packet:
EBufferReset(ebuffp);
EBufferReset(&myEBuff);
Response packets are received into the buffer pointed to by ebuffp, starting at the byte to
which start_bp points. A call to READX() passes the file number, a pointer to the
beginning of the receiving buffer, and the number of bytes to read, indicated by the
value of the buffer descriptor remaining. If the call cannot be initiated,
FILE_GETINFO_() returns a number characterizing the failure:
status = READX (host_int->file_num, ebuffp->start_bp,
ebuffp->remaining);
if (status != CCE)
{
FILE_GETINFO_ (host_int->file_num, &err);
An AWAITIOX() call completes the read operation, and FILE_GETINFO_()
characterizes the outcome of the read operation after the number of bytes read is saved
in the count_read field of the host_int structure:
AWAITIOX (&temp_file_num, (long *) &IOC_buffp, &read_cnt,
&IO_tag, (long)(host_int->timeout));
host_int->count_read = read_cnt
FILE_GETINFO_ (host_int->file_num, &err);
If a response is received successfully, it is decoded using EBuff descriptors, starting at
the location indicated by start_bp and continuing for as many bytes as read_cnt
indicates, into rpkt:
*rpkt = SNMP_Decode_Packet_WER(myEBuff.start_bp, read_cnt,
(SNMPADDR_T*) 0, (SNMPADDR_T *) 0, &err2);
Communicating With Agents and Other Managers
Figure 7-2 summarizes the calls used to establish UDP communication with SNMP
agents and managers. The UDP socket library calls enable nowaited packet transmission
and receipt operations.
Establishing Communication
Before a socket is obtained, SNMP_Init_() initializes the host_int dest sockaddr_in
structure, which is used by the socket routines. The sin_family value describes an
Internet address; the sin_port value, the port number to be associated with the socket, is
assigned the default destination port (162); and the sin_addr.s_addr value is assigned the