@Test public void testDeserialize() throws Exception { MPLS mpls = deserializer.deserialize(bytes, 0, bytes.length); assertEquals(label, mpls.label); assertEquals(bos, mpls.bos); assertEquals(ttl, mpls.ttl); assertEquals(protocol, mpls.protocol); }
@Override public IPacket deserialize(byte[] data, int offset, int length) { ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int mplsheader = bb.getInt(); this.label = ((mplsheader & 0xfffff000) >> 12); this.bos = (byte) ((mplsheader & 0x00000100) >> 8); this.bos = (byte) (mplsheader & 0x000000ff); this.protocol = (this.bos == 1) ? PROTOCOL_IPV4 : PROTOCOL_MPLS; Deserializer<? extends IPacket> deserializer; if (protocolDeserializerMap.containsKey(this.protocol)) { deserializer = protocolDeserializerMap.get(this.protocol); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; }
MPLS extends BasePacket { @Override public IPacket deserialize(byte[] data, int offset, int length) { ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int mplsheader = bb.getInt(); this.label = ((mplsheader & 0xfffff000) >> 12); this.bos = (byte) ((mplsheader & 0x00000100) >> 8); this.bos = (byte) (mplsheader & 0x000000ff); this.protocol = (this.bos == 1) ? PROTOCOL_IPV4 : PROTOCOL_MPLS; Deserializer<? extends IPacket> deserializer; if (protocolDeserializerMap.containsKey(this.protocol)) { deserializer = protocolDeserializerMap.get(this.protocol); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; } }
MPLS extends BasePacket { @Override public IPacket deserialize(byte[] data, int offset, int length) { ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int mplsheader = bb.getInt(); this.label = ((mplsheader & 0xfffff000) >> 12); this.bos = (byte) ((mplsheader & 0x00000100) >> 8); this.bos = (byte) (mplsheader & 0x000000ff); this.protocol = (this.bos == 1) ? PROTOCOL_IPV4 : PROTOCOL_MPLS; Deserializer<? extends IPacket> deserializer; if (protocolDeserializerMap.containsKey(this.protocol)) { deserializer = protocolDeserializerMap.get(this.protocol); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; } MPLS(); }
MPLS extends BasePacket { @Override public IPacket deserialize(byte[] data, int offset, int length) { ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int mplsheader = bb.getInt(); this.label = ((mplsheader & 0xfffff000) >> 12); this.bos = (byte) ((mplsheader & 0x00000100) >> 8); this.bos = (byte) (mplsheader & 0x000000ff); this.protocol = (this.bos == 1) ? PROTOCOL_IPV4 : PROTOCOL_MPLS; Deserializer<? extends IPacket> deserializer; if (protocolDeserializerMap.containsKey(this.protocol)) { deserializer = protocolDeserializerMap.get(this.protocol); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; } MPLS(); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); int getLabel(); void setLabel(int label); byte getTtl(); void setTtl(byte ttl); static Deserializer<MPLS> deserializer(); @Override String toString(); }
MPLS extends BasePacket { @Override public IPacket deserialize(byte[] data, int offset, int length) { ByteBuffer bb = ByteBuffer.wrap(data, offset, length); int mplsheader = bb.getInt(); this.label = ((mplsheader & 0xfffff000) >> 12); this.bos = (byte) ((mplsheader & 0x00000100) >> 8); this.bos = (byte) (mplsheader & 0x000000ff); this.protocol = (this.bos == 1) ? PROTOCOL_IPV4 : PROTOCOL_MPLS; Deserializer<? extends IPacket> deserializer; if (protocolDeserializerMap.containsKey(this.protocol)) { deserializer = protocolDeserializerMap.get(this.protocol); } else { deserializer = Data.deserializer(); } try { this.payload = deserializer.deserialize(data, bb.position(), bb.limit() - bb.position()); this.payload.setParent(this); } catch (DeserializationException e) { return this; } return this; } MPLS(); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); int getLabel(); void setLabel(int label); byte getTtl(); void setTtl(byte ttl); static Deserializer<MPLS> deserializer(); @Override String toString(); static final int HEADER_LENGTH; static final byte PROTOCOL_IPV4; static final byte PROTOCOL_MPLS; }