Search in sources :

Example 1 with LLDP

use of net.floodlightcontroller.packet.LLDP in project open-kilda by telstra.

the class ConnectedDevicesService method deserializeLldp.

@VisibleForTesting
LldpPacketData deserializeLldp(Ethernet eth, SwitchId switchId, long cookie) {
    try {
        List<Integer> vlans = new ArrayList<>();
        IPacket payload = EthernetPacketToolbox.extractPayload(eth, vlans);
        if (payload instanceof LLDP) {
            LldpPacket lldpPacket = new LldpPacket((LLDP) payload);
            return new LldpPacketData(lldpPacket, vlans);
        }
    } catch (Exception exception) {
        logger.info("Could not deserialize LLDP packet {} on switch {}. Cookie {}. Deserialization failure: {}", eth, switchId, Cookie.toString(cookie), exception.getMessage(), exception);
        return null;
    }
    logger.info("Got invalid lldp packet: {} on switch {}. Cookie {}", eth, switchId, cookie);
    return null;
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) ArrayList(java.util.ArrayList) LLDP(net.floodlightcontroller.packet.LLDP) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with LLDP

use of net.floodlightcontroller.packet.LLDP in project open-kilda by telstra.

the class LldpPacketTest method buildLldpPacket.

static LldpPacket buildLldpPacket(byte[] packet) {
    LLDP lldp = new LLDP();
    lldp.deserialize(packet, 0, packet.length);
    return new LldpPacket(lldp);
}
Also used : LLDP(net.floodlightcontroller.packet.LLDP)

Aggregations

LLDP (net.floodlightcontroller.packet.LLDP)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ArrayList (java.util.ArrayList)1 IPacket (net.floodlightcontroller.packet.IPacket)1