Enhance the LLDPTLV.java to handle the LLDP port ID 12/3812/2
authorPaiwei Wang <pwwang@itri.org.tw>
Wed, 18 Dec 2013 11:00:55 +0000 (03:00 -0800)
committerGiovanni Meo <gmeo@cisco.com>
Thu, 17 Apr 2014 11:19:48 +0000 (11:19 +0000)
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 <pwwang@itri.org.tw>
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java

index 2766022..efb938e 100644 (file)
@@ -291,10 +291,17 @@ public class LLDPTLV extends Packet {
      * @return the string
      */
     static public String getStringValue(byte[] tlvValue, int tlvLen) {
      * @return the string
      */
     static public String getStringValue(byte[] tlvValue, int tlvLen) {
+        byte[] pidSubType = new byte[portIDSubType.length];
         byte[] pidBytes = new byte[tlvLen - 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);
         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()));
+        }
     }
 
     /**
     }
 
     /**