SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-51
SNMPGT
{
if (oidstr_to_oid( oidstr[i], &base_oid) < 0 )
{
fprintf(stderr, "Bad object identifier: %s\n", oidstr[i]);
exit(0);
}
if (SNMP_Bind_Null(send_pkt, i,
base_oid.num_components, base_oid.component_list) < 0)
{
fprintf(stderr, "Error binding value\n");
exit(0);
}
}
EBufferInitialize(&ebuff); <-- 20
/* Send request and receive response */
for (j = 0; j <= retrycnt; j++) { <-- 21
if (j == 0)
{
firstid = requestid;
} else
{
printf("RESENDING PACKET \n");
/*
* PDU request ID is reset to 1 by setting
* requestid to 0 and then incrementing it
*/
if (requestid == MAX_REQID_VALUE)
requestid = 0;
send_pkt->pdu.std_pdu.request_id = ++requestid;
}
rcode = SNMP_Encode_Packet(send_pkt, &ebuff); <-- 22
printf("\nSENDING PACKET:\n");
print_pkt(send_pkt); <-- 23
memcpy (sndbuff, (void*) &dest, sizeof(dest)); <-- 24
memcpy (sndbuff + sizeof(struct sockaddr_in), ebuff.start_bp,
EBufferUsed(&ebuff));
cbSend = sizeof(struct sockaddr_in) + EBufferUsed(&ebuff);
Example 2-4. Contents of snmpgtc (page 6 of 8)