SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-132
SNMPHOST Source Code
/* Save the hrIndex OID for later use */
devIndexObj.num_components = base_oid.num_components; <--18
devIndexObj.component_list = (OIDC_T*) malloc (sizeof(OIDC_T)*
MAX_OID_COUNT);
memcpy (devIndexObj.component_list, base_oid.component_list,
sizeof(OIDC_T) * devIndexObj.num_components);
SNMP_Bind_Null(pkt, vbIndex++,
base_oid.num_components,
base_oid.component_list);
/* Set up the hrDeviceType */
base_oid.num_components = oidstring2oid (hrDeviceType, <--19
base_oid.component_list, MAX_OID_COUNT);
if (base_oid.num_components == 0) {
fprintf(stdout, "Bad object identifier: %s\n", hrDeviceType);
exit(0);
}
SNMP_Bind_Null(pkt, vbIndex++,
base_oid.num_components,
base_oid.component_list);
/* Set up the hrDeviceDescr */
base_oid.num_components = oidstring2oid (hrDeviceDescr, <--20
base_oid.component_list, MAX_OID_COUNT);
if (base_oid.num_components == 0) {
fprintf(stdout, "Bad object identifier: %s\n", hrDeviceDescr);
exit(0);
}
SNMP_Bind_Null(pkt, vbIndex++,
base_oid.num_components,
base_oid.component_list);
/* Set up the hrDeviceStatus */
base_oid.num_components = oidstring2oid (hrDeviceStatus, <--21
base_oid.component_list, MAX_OID_COUNT);
Example 2-18. Contents of snmphosc (page 7 of 23)