SNMP Manager Programmer's Guide
Sending and Receiving Packets
SNMP Manager Programmer’s Guide–134249
7-7
Receiving Packets
bytes to send is the sum of the socket information and the number of used bytes
indicated by myEBuff:
send_cnt = EBufferUsed(&myEBuff);
memcpy (ebuffp->start_bp, (void*) &host_int->dest,
sizeof(struct sockaddr_in);
send_cnt += sizeof(struct sockaddr_in);
A t_sendto_nw() call sends the encoded-packet buffer on the nowait socket. It passes
the socket number, a pointer to the byte indicated by start_bp in ebuffp, and the number
of bytes to transmit:
if ((err = t_sendto_nw(host_int->file_num,
(struct sendto_recvfrom_buf*) ebuffp-
>start_bp,
send_cnt, 0, 0)) == -1)
The same AWAITIOX() and FILE_GETINFO() calls used for IPC communication are
used to complete the write operation:
AWAITIOX (&temp_file_num, (long *) &IOC_buffp, &written_cnt,
&IO_tag, (long)(host_int->timeout));
FILE_GETINFO_ (host_int->file_num, &err);
The socket_get_len() function obtains the number of bytes sent:
host_int->count_written = socket_get_len(host_int->file_num);
Receiving Packets
A call to t_recvfrom_nw() receives a response packet on the UDP socket into the
encoded-packet buffer, starting at the location indicated by start_bp in ebuffp. The size
of the buffer is characterized by the value of remaining:
if (err = t_recvfrom_nw(host_int->file_num,
(struct sendto_recvfrom_buf*) ebuffp-
>start_bp,
ebuffp->remaining, 0, IO_tag ) == -1)
AWAITIOX() and FILE_GETINFO_() calls complete the read operation:
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);
Before the response packet is decoded, read_cnt is adjusted so that decoding starts after
the information in sockaddr_in:
memcpy ((char*) &host_int->from,
(void *) ebuffp->start_bp,
sizeof(host_int->from));
read_cnt -= sizeof(struct sockaddr_in);
*rpkt = SNMP_Decode_Packet_WER(myEBuff.start_bp, read_cnt,
(SNMPADDR_T*) 0, (SNMPADDR_T *) 0, &err2);