@Test public void deserializeLldpWithTwoVlanTest() { short innerVlan = 1234; short outerVlan = 2345; Ethernet ethernet = buildEthernet(srcAndDstMacAddresses, ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(outerVlan), ethTypeToByteArray(EthType.VLAN_FRAME), shortToByteArray(innerVlan), ethTypeToByteArray(EthType.LLDP), LldpPacketTest.packet); LldpPacketData data = service.deserializeLldp(ethernet, null, 0); assertNotNull(data); assertEquals(2, data.getVlans().size()); assertEquals(Integer.valueOf(outerVlan), data.getVlans().get(0)); assertEquals(Integer.valueOf(innerVlan), data.getVlans().get(1)); assertEquals(LldpPacketTest.buildLldpPacket(LldpPacketTest.packet), data.getLldpPacket()); }
@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; }
ConnectedDevicesService implements IService, IInputTranslator { @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; } }
ConnectedDevicesService implements IService, IInputTranslator { @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; }  }
ConnectedDevicesService implements IService, IInputTranslator { @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; }  @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context); }
ConnectedDevicesService implements IService, IInputTranslator { @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; }  @Override Command makeCommand(CommandContext context, OfInput input); @Override void setup(FloodlightModuleContext context);  }