@Test public void testSerialize() throws Exception { IPacket ethernet = getPacket(); assertTrue(Arrays.equals(pkt, ethernet.serialize())); }
@Override public byte[] serialize() { int length = 2+this.chassisId.getLength() + 2+this.portId.getLength() + 2+this.ttl.getLength() + 2; for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) length += 2 + tlv.getLength(); } byte[] data = new byte[length]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.chassisId.serialize()); bb.put(this.portId.serialize()); bb.put(this.ttl.serialize()); for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) bb.put(tlv.serialize()); } bb.putShort((short) 0); if (this.parent != null && this.parent instanceof Ethernet) ((Ethernet)this.parent).setEtherType(ethType); return data; }
LLDP extends BasePacket { @Override public byte[] serialize() { int length = 2+this.chassisId.getLength() + 2+this.portId.getLength() + 2+this.ttl.getLength() + 2; for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) length += 2 + tlv.getLength(); } byte[] data = new byte[length]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.chassisId.serialize()); bb.put(this.portId.serialize()); bb.put(this.ttl.serialize()); for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) bb.put(tlv.serialize()); } bb.putShort((short) 0); if (this.parent != null && this.parent instanceof Ethernet) ((Ethernet)this.parent).setEtherType(ethType); return data; } }
LLDP extends BasePacket { @Override public byte[] serialize() { int length = 2+this.chassisId.getLength() + 2+this.portId.getLength() + 2+this.ttl.getLength() + 2; for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) length += 2 + tlv.getLength(); } byte[] data = new byte[length]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.chassisId.serialize()); bb.put(this.portId.serialize()); bb.put(this.ttl.serialize()); for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) bb.put(tlv.serialize()); } bb.putShort((short) 0); if (this.parent != null && this.parent instanceof Ethernet) ((Ethernet)this.parent).setEtherType(ethType); return data; } LLDP(); }
LLDP extends BasePacket { @Override public byte[] serialize() { int length = 2+this.chassisId.getLength() + 2+this.portId.getLength() + 2+this.ttl.getLength() + 2; for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) length += 2 + tlv.getLength(); } byte[] data = new byte[length]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.chassisId.serialize()); bb.put(this.portId.serialize()); bb.put(this.ttl.serialize()); for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) bb.put(tlv.serialize()); } bb.putShort((short) 0); if (this.parent != null && this.parent instanceof Ethernet) ((Ethernet)this.parent).setEtherType(ethType); return data; } LLDP(); LLDPTLV getChassisId(); LLDP setChassisId(LLDPTLV chassisId); LLDPTLV getPortId(); LLDP setPortId(LLDPTLV portId); LLDPTLV getTtl(); LLDP setTtl(LLDPTLV ttl); List<LLDPTLV> getOptionalTLVList(); LLDP setOptionalTLVList(List<LLDPTLV> optionalTLVList); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
LLDP extends BasePacket { @Override public byte[] serialize() { int length = 2+this.chassisId.getLength() + 2+this.portId.getLength() + 2+this.ttl.getLength() + 2; for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) length += 2 + tlv.getLength(); } byte[] data = new byte[length]; ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.chassisId.serialize()); bb.put(this.portId.serialize()); bb.put(this.ttl.serialize()); for (LLDPTLV tlv : this.optionalTLVList) { if (tlv != null) bb.put(tlv.serialize()); } bb.putShort((short) 0); if (this.parent != null && this.parent instanceof Ethernet) ((Ethernet)this.parent).setEtherType(ethType); return data; } LLDP(); LLDPTLV getChassisId(); LLDP setChassisId(LLDPTLV chassisId); LLDPTLV getPortId(); LLDP setPortId(LLDPTLV portId); LLDPTLV getTtl(); LLDP setTtl(LLDPTLV ttl); List<LLDPTLV> getOptionalTLVList(); LLDP setOptionalTLVList(List<LLDPTLV> optionalTLVList); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }