@Test public void testDeserialize() throws Exception { LLDP lldp = deserializer.deserialize(bytes, 0, bytes.length); assertEquals(LLDP.CHASSIS_TLV_TYPE, lldp.getChassisId().getType()); assertEquals(LLDP.CHASSIS_TLV_SIZE, lldp.getChassisId().getLength()); assertTrue(Arrays.equals(chassisValue, lldp.getChassisId().getValue())); assertEquals(LLDP.PORT_TLV_TYPE, lldp.getPortId().getType()); assertEquals(LLDP.PORT_TLV_SIZE, lldp.getPortId().getLength()); assertTrue(Arrays.equals(portValue, lldp.getPortId().getValue())); assertEquals(LLDP.TTL_TLV_TYPE, lldp.getTtl().getType()); assertEquals(LLDP.TTL_TLV_SIZE, lldp.getTtl().getLength()); assertTrue(Arrays.equals(ttlValue, lldp.getTtl().getValue())); assertEquals(1, lldp.getOptionalTLVList().size()); LLDPTLV optionalTlv = lldp.getOptionalTLVList().get(0); assertEquals(LLDPOrganizationalTLV.ORGANIZATIONAL_TLV_TYPE, optionalTlv.getType()); assertEquals(optionalTlvSize, optionalTlv.getLength()); assertTrue(Arrays.equals(optionalTlvValue, optionalTlv.getValue())); }
@Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); LLDPTLV tlv; do { try { tlv = new LLDPOrganizationalTLV().deserialize(bb); } catch (DeserializationException e) { break; } if (tlv == null) { break; } switch (tlv.getType()) { case 0x0: break; case 0x1: this.chassisId = tlv; break; case 0x2: this.portId = tlv; break; case 0x3: this.ttl = tlv; break; default: this.optionalTLVList.add(tlv); break; } } while (tlv.getType() != 0 && bb.hasRemaining()); return this; }
LLDP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); LLDPTLV tlv; do { try { tlv = new LLDPOrganizationalTLV().deserialize(bb); } catch (DeserializationException e) { break; } if (tlv == null) { break; } switch (tlv.getType()) { case 0x0: break; case 0x1: this.chassisId = tlv; break; case 0x2: this.portId = tlv; break; case 0x3: this.ttl = tlv; break; default: this.optionalTLVList.add(tlv); break; } } while (tlv.getType() != 0 && bb.hasRemaining()); return this; } }
LLDP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); LLDPTLV tlv; do { try { tlv = new LLDPOrganizationalTLV().deserialize(bb); } catch (DeserializationException e) { break; } if (tlv == null) { break; } switch (tlv.getType()) { case 0x0: break; case 0x1: this.chassisId = tlv; break; case 0x2: this.portId = tlv; break; case 0x3: this.ttl = tlv; break; default: this.optionalTLVList.add(tlv); break; } } while (tlv.getType() != 0 && bb.hasRemaining()); return this; } LLDP(); }
LLDP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); LLDPTLV tlv; do { try { tlv = new LLDPOrganizationalTLV().deserialize(bb); } catch (DeserializationException e) { break; } if (tlv == null) { break; } switch (tlv.getType()) { case 0x0: break; case 0x1: this.chassisId = tlv; break; case 0x2: this.portId = tlv; break; case 0x3: this.ttl = tlv; break; default: this.optionalTLVList.add(tlv); break; } } while (tlv.getType() != 0 && bb.hasRemaining()); return this; } LLDP(); LLDPTLV getChassisId(); LLDP setChassisId(final LLDPTLV chassis); LLDPTLV getPortId(); LLDP setPortId(final LLDPTLV portId); LLDPTLV getTtl(); LLDP setTtl(final LLDPTLV ttl); List<LLDPTLV> getOptionalTLVList(); LLDP setOptionalTLVList(final List<LLDPTLV> optionalTLVList); @Override byte[] serialize(); @Override IPacket deserialize(final byte[] data, final int offset,
                               final int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<LLDP> deserializer(); @Override String toString(); }
LLDP extends BasePacket { @Override public IPacket deserialize(final byte[] data, final int offset, final int length) { final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); LLDPTLV tlv; do { try { tlv = new LLDPOrganizationalTLV().deserialize(bb); } catch (DeserializationException e) { break; } if (tlv == null) { break; } switch (tlv.getType()) { case 0x0: break; case 0x1: this.chassisId = tlv; break; case 0x2: this.portId = tlv; break; case 0x3: this.ttl = tlv; break; default: this.optionalTLVList.add(tlv); break; } } while (tlv.getType() != 0 && bb.hasRemaining()); return this; } LLDP(); LLDPTLV getChassisId(); LLDP setChassisId(final LLDPTLV chassis); LLDPTLV getPortId(); LLDP setPortId(final LLDPTLV portId); LLDPTLV getTtl(); LLDP setTtl(final LLDPTLV ttl); List<LLDPTLV> getOptionalTLVList(); LLDP setOptionalTLVList(final List<LLDPTLV> optionalTLVList); @Override byte[] serialize(); @Override IPacket deserialize(final byte[] data, final int offset,
                               final int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<LLDP> deserializer(); @Override String toString(); static final byte CHASSIS_TLV_TYPE; static final short CHASSIS_TLV_SIZE; static final byte CHASSIS_TLV_SUBTYPE; static final byte PORT_TLV_TYPE; static final short PORT_TLV_SIZE; static final byte PORT_TLV_SUBTYPE; static final byte TTL_TLV_TYPE; static final short TTL_TLV_SIZE; }