public Integer getIfIndex() { final SnmpValue value = getValue(IF_INDEX); if (value != null) { return value.toInt(); } else { // ifIndex is the instance id as well final SnmpInstId inst = getInstance(); if (inst != null && inst.length() == 1) { return inst.toInt(); } } return null; }
/** * matches * * @param base a {@link org.opennms.netmgt.snmp.SnmpObjId} object. * @param inst a {@link org.opennms.netmgt.snmp.SnmpInstId} object. * @return a boolean. */ public boolean matches(SnmpObjId base, SnmpInstId inst) { if (!base.equals(getSnmpObjId())) { return false; } if (getInstance().equals(MibObject.INSTANCE_IFINDEX) || m_mibObj.getResourceType() != null) { return true; } else { return getInstance().equals(inst.toString()); } }
public static String getPhysAddrFromInstance(SnmpInstId instance) { String[] elm; elm = instance.toString().split("\\."); if (elm.length != 6) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < 6; i++) { int val = Integer.parseInt(elm[i]); if (val < 16) { sb.append('0'); } sb.append(Integer.toHexString(val)); if (i < 5) { sb.append(':'); } } return sb.toString().toUpperCase(); }