Skip to content

Commit

Permalink
Applying the fix for NMS-4902 on PhysInterfaceTableTracker.
Browse files Browse the repository at this point in the history
The way to process the ifPhysAddress was changed in IfTableEntry because
of NMS-4902 (added the MAC address handling from IpNetToMediaTableEntry
to IfTableEntry). The fix for NMS-5418 didn't include the same
post-processing of the MAC Address which is not correct.

Now both clases are going to provide the same functionality regarding
the MAC address.
  • Loading branch information
agalue committed Sep 5, 2013
1 parent 7e57f59 commit a8f26fe
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

package org.opennms.netmgt.provision.service;

import org.opennms.core.utils.InetAddressUtils;

import org.opennms.core.utils.LogUtils;
import org.opennms.netmgt.model.OnmsSnmpInterface;
import org.opennms.netmgt.snmp.RowCallback;
import org.opennms.netmgt.snmp.SnmpInstId;
Expand Down Expand Up @@ -172,7 +175,25 @@ private Integer getIfAdminStatus() {

private String getPhysAddr() {
final SnmpValue value = getValue(IF_PHYS_ADDR);
return value == null ? null : value.toHexString();
String hexString = value == null ? null : value.toHexString();
String displayString = value == null ? null : value.toDisplayString();
// See ifTableEntry: NMS-4902 (revision cee964fe979e6465aeb4e2efd4772e50ebc54831)
try {
if (hexString != null && hexString.length() == 12) {
// If the hex string is 12 characters long, than the agent is kinda weird and
// is returning the value as a raw binary value that is 6 bytes in length.
// But that's OK, as long as we can convert it into a string, that's fine.
return hexString;
} else {
// This is the normal case that most agents conform to: the value is an ASCII
// string representing the colon-separated MAC address. We just need to reformat
// it to remove the colons and convert it into a 12-character string.
return InetAddressUtils.normalizeMacAddress(displayString);
}
} catch (IllegalArgumentException e) {
LogUtils.warnf(this, e, e.getMessage());
return displayString;
}
}

public OnmsSnmpInterface createInterfaceFromRow() {
Expand Down

0 comments on commit a8f26fe

Please sign in to comment.