X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fpacket%2FLLDP.java;h=9b5dc082bb2303084775026131a11552b5614add;hb=437c90de7f8f7fd578fb218d4b195162075e7d27;hp=1a0033ee963ebb1a4ec01c7923cece40dea0bdf9;hpb=340a93f17c03395391339a82b3a036afd374f569;p=controller.git diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java index 1a0033ee96..9b5dc082bb 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java @@ -12,6 +12,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + +import org.opendaylight.controller.sal.utils.HexEncode; import org.opendaylight.controller.sal.utils.NetUtils; /** @@ -20,9 +22,10 @@ import org.opendaylight.controller.sal.utils.NetUtils; public class LLDP extends Packet { private static final String CHASSISID = "ChassisId"; + private static final String SYSTEMNAMEID = "SystemNameID"; private static final String PORTID = "PortId"; private static final String TTL = "TTL"; - private static final int LLDPDefaultTlvs = 3; + private static final int LLDPDefaultTlvs = 4; private static LLDPTLV emptyTLV = new LLDPTLV().setLength((short) 0) .setType((byte) 0); public static final byte[] LLDPMulticastMac = { 1, (byte) 0x80, @@ -100,6 +103,22 @@ public class LLDP extends Packet { return this; } + /** + * @return the SystemName TLV + */ + public LLDPTLV getSystemNameId() { + return getTLV(SYSTEMNAMEID); + } + + /** + * @param LLDPTLV + * - the chassisId to set + */ + public LLDP setSystemNameId(LLDPTLV systemNameId) { + tlvList.put(getType(SYSTEMNAMEID), systemNameId); + return this; + } + /** * @return LLDPTLV - the portId TLV */ @@ -170,12 +189,19 @@ public class LLDP extends Packet { int lldpOffset = bitOffset; // LLDP start int lldpSize = size; // LLDP size + if (logger.isTraceEnabled()) { + logger.trace("LLDP: {} (offset {} bitsize {})", new Object[] { + HexEncode.bytesToHexString(data), lldpOffset, lldpSize }); + } /* * Deserialize the TLVs until we reach the end of the packet */ while (lldpSize > 0) { LLDPTLV tlv = new LLDPTLV(); tlv.deserialize(data, lldpOffset, lldpSize); + if (tlv.getType() == 0 && tlv.getLength() == 0) { + break; + } int tlvSize = tlv.getTLVSize(); // Size of current TLV in bits lldpOffset += tlvSize; lldpSize -= tlvSize; @@ -209,12 +235,16 @@ public class LLDP extends Packet { throw new PacketException(e.getMessage()); } + if (logger.isTraceEnabled()) { + logger.trace("LLDP: serialized: {}", + HexEncode.bytesToHexString(serializedBytes)); + } return serializedBytes; } /** * Returns the size of LLDP packet in bytes - * + * * @return int - LLDP Packet size in bytes */ private int getLLDPPacketLength() {