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;
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();
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());
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);
}