From 66ca7f84baed5633cd135c5037a8aa847d2b9621 Mon Sep 17 00:00:00 2001 From: Paiwei Wang Date: Wed, 18 Dec 2013 03:00:55 -0800 Subject: [PATCH] Enhance the LLDPTLV.java to handle the LLDP port ID subtypes 3 (MAC) in addition to 7 (Local). Many Ethernet switches take MAC addresses as the port IDs. Change-Id: I8a0d0e5cf0e914a9fe77acd3d0d4787a2ac98760 Signed-off-by: Paiwei Wang --- .../org/opendaylight/controller/sal/packet/LLDPTLV.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java index 27660221ce..efb938e37f 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java @@ -291,10 +291,17 @@ public class LLDPTLV extends Packet { * @return the string */ static public String getStringValue(byte[] tlvValue, int tlvLen) { + byte[] pidSubType = new byte[portIDSubType.length]; byte[] pidBytes = new byte[tlvLen - portIDSubType.length]; + System.arraycopy(tlvValue, 0, pidSubType, 0, + pidSubType.length); System.arraycopy(tlvValue, portIDSubType.length, pidBytes, 0, pidBytes.length); - return (new String(pidBytes, Charset.defaultCharset())); + if (pidSubType[0] == (byte) 0x3) { + return HexEncode.bytesToHexStringFormat(pidBytes); + } else { + return (new String(pidBytes, Charset.defaultCharset())); + } } /** -- 2.36.6