X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fpacket%2FLLDPTLV.java;h=35244ea697d871617b09db6e232da95af0d51ebf;hb=44a86821d69cd804b6b23b437e0b27136eaac2b5;hp=bf674022596d8eb09df2b99bdb72314bdbdaf2cc;hpb=e9ca35a2cd3c7b3e19c56d8496bfedd09fc1ce54;p=controller.git 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 bf67402259..35244ea697 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 @@ -151,18 +151,23 @@ public class LLDPTLV extends Packet { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } LLDPTLV other = (LLDPTLV) obj; if (fieldValues == null) { - if (other.fieldValues != null) + if (other.fieldValues != null) { return false; - } else if (!fieldValues.equals(other.fieldValues)) + } + } else if (!fieldValues.equals(other.fieldValues)) { return false; + } return true; } @@ -187,6 +192,18 @@ public class LLDPTLV extends Packet { getfieldnumBits(VALUE)); // variable } + /** + * Creates the SystemName TLV value + * + * @param nodeId + * node identifier string + * @return the SystemName TLV value in byte array + */ + static public byte[] createSystemNameTLVValue(String nodeId) { + byte[] nid = nodeId.getBytes(); + return nid; + } + /** * Creates the ChassisID TLV value including the subtype and ChassisID * string @@ -279,10 +296,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())); + } } /**