X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Flldp-speaker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Flldpspeaker%2FLLDPUtil.java;h=b443809a2081c05394729840392f81595fbb6fa7;hb=8c8afa72bf93734ea40367e0831a571c037d5ca2;hp=0bb7cea7e9ca83f9a4325e10104fc98e864e21e0;hpb=63edf950edba76102e4a5024f517961e72ba23d3;p=openflowplugin.git diff --git a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java index 0bb7cea7e9..b443809a20 100644 --- a/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java +++ b/applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPUtil.java @@ -13,6 +13,7 @@ import static org.opendaylight.openflowplugin.libraries.liblldp.LLDPTLV.CUSTOM_T import java.math.BigInteger; import java.security.NoSuchAlgorithmException; +import javax.annotation.Nonnull; import org.apache.commons.lang3.StringUtils; import org.opendaylight.openflowplugin.libraries.liblldp.EtherTypes; import org.opendaylight.openflowplugin.libraries.liblldp.Ethernet; @@ -37,8 +38,10 @@ public final class LLDPUtil { private LLDPUtil() { } + @Nonnull static byte[] buildLldpFrame(final NodeId nodeId, final NodeConnectorId nodeConnectorId, final MacAddress src, - final Long outPortNo, final MacAddress destinationAddress) { + final Long outPortNo, final MacAddress destinationAddress) + throws NoSuchAlgorithmException, PacketException { // Create discovery pkt LLDP discoveryPkt = new LLDP(); @@ -81,18 +84,12 @@ public final class LLDPUtil { discoveryPkt.addCustomTLV(customTlv); //Create LLDP CustomSec TLV - byte[] pureValue = new byte[1]; - try { - pureValue = getValueForLLDPPacketIntegrityEnsuring(nodeConnectorId); - byte[] customSecValue = LLDPTLV.createCustomTLVValue(CUSTOM_TLV_SUB_TYPE_CUSTOM_SEC, pureValue); - LLDPTLV customSecTlv = new LLDPTLV(); - customSecTlv.setType(LLDPTLV.TLVType.Custom.getValue()).setLength((short) customSecValue.length) - .setValue(customSecValue); - discoveryPkt.addCustomTLV(customSecTlv); - } catch (NoSuchAlgorithmException e) { - LOG.warn("LLDP extra authenticator creation failed.", e); - } - + byte[] pureValue = getValueForLLDPPacketIntegrityEnsuring(nodeConnectorId); + byte[] customSecValue = LLDPTLV.createCustomTLVValue(CUSTOM_TLV_SUB_TYPE_CUSTOM_SEC, pureValue); + LLDPTLV customSecTlv = new LLDPTLV(); + customSecTlv.setType(LLDPTLV.TLVType.Custom.getValue()).setLength((short) customSecValue.length) + .setValue(customSecValue); + discoveryPkt.addCustomTLV(customSecTlv); // Create ethernet pkt byte[] sourceMac = HexEncode.bytesFromHexString(src.getValue()); @@ -104,16 +101,12 @@ public final class LLDPUtil { ethPkt.setDestinationMACAddress(HexEncode.bytesFromHexString(destinationAddress.getValue())); } - try { - return ethPkt.serialize(); - } catch (PacketException e) { - LOG.warn("Error creating LLDP packet.", e); - } - return null; + return ethPkt.serialize(); } + @Nonnull static byte[] buildLldpFrame(final NodeId nodeId, final NodeConnectorId nodeConnectorId, - final MacAddress srcMacAddress, final Long outputPortNo) { + final MacAddress srcMacAddress, final Long outputPortNo) throws NoSuchAlgorithmException, PacketException { return buildLldpFrame(nodeId, nodeConnectorId, srcMacAddress, outputPortNo, null); }