SNMP Manager Programmer's Guide

Programming Examples
SNMP Manager Programmer’s Guide–134249
2-135
SNMPHOST Source Code
/* resetting request ID */
/*
* PDU request ID is reset to 1 by setting
* requestid to 0 and then incrementing it
*/
if (requestid == MAX_REQID_VALUE)
requestid = 0;
requestid++; <--26
pkt->pdu_type = GET_NEXT_REQUEST_PDU;
pkt->pdu.std_pdu.request_id = requestid;
pkt->pdu.std_pdu.error_status = 0;
pkt->pdu.std_pdu.error_index = 0;
vbp = pkt->pdu.std_pdu.std_vbl.vblist;
/* check that we have got at least one varbind */
if (pkt->pdu.std_pdu.std_vbl.vbl_count <= 0)
break;
/* Check if we have not rolled off the device table */
objp = &(vbp->vb_obj_id);
if (oidcmp2 ((short) objp->num_components - 1, <--27
objp->component_list,
(short) devIndexObj.num_components,
devIndexObj.component_list) != 0) {
bMoreEntries = 0;
break;
}
/* Store the device entry for later printing */
pCurrOutputEntry = ppDevTable[nCurrDevIndex]; <--28
if (vbp->vb_data_flags_n_type != VT_NUMBER) {
printf ("Unexpected error (varbind[0] not NUMBER)\n");
exit(0);
}
pCurrOutputEntry->nDeviceIndex = vbp->value_u.v_number;
vbp = &pkt->pdu.std_pdu.std_vbl.vblist[1]; <--29
objp = &vbp->value_u.v_object;
if (vbp->vb_data_flags_n_type != VT_OBJECT) {
printf ("Unexpected error (varbind[1] not Object Id)\n");
exit(0);
}
Example 2-18. Contents of snmphosc (page 10 of 23)