@Test public void testSerialize() { RouterAdvertisement ra = new RouterAdvertisement(); ra.setCurrentHopLimit((byte) 3); ra.setMFlag((byte) 1); ra.setOFlag((byte) 1); ra.setRouterLifetime((short) 0x258); ra.setReachableTime(0x3e8); ra.setRetransmitTimer(0x1f4); ra.addOption(NeighborDiscoveryOptions.TYPE_TARGET_LL_ADDRESS, MAC_ADDRESS.toBytes()); assertArrayEquals(ra.serialize(), bytePacket); }
@Override public byte[] serialize() { byte[] optionsData = null; if (this.options.hasOptions()) { optionsData = this.options.serialize(); } int optionsLength = 0; if (optionsData != null) { optionsLength = optionsData.length; } final byte[] data = new byte[HEADER_LENGTH + optionsLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.currentHopLimit); bb.put((byte) ((this.mFlag & 0x1) << 7 | (this.oFlag & 0x1) << 6)); bb.putShort(routerLifetime); bb.putInt(reachableTime); bb.putInt(retransmitTimer); if (optionsData != null) { bb.put(optionsData); } return data; }
RouterAdvertisement extends BasePacket { @Override public byte[] serialize() { byte[] optionsData = null; if (this.options.hasOptions()) { optionsData = this.options.serialize(); } int optionsLength = 0; if (optionsData != null) { optionsLength = optionsData.length; } final byte[] data = new byte[HEADER_LENGTH + optionsLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.currentHopLimit); bb.put((byte) ((this.mFlag & 0x1) << 7 | (this.oFlag & 0x1) << 6)); bb.putShort(routerLifetime); bb.putInt(reachableTime); bb.putInt(retransmitTimer); if (optionsData != null) { bb.put(optionsData); } return data; } }
RouterAdvertisement extends BasePacket { @Override public byte[] serialize() { byte[] optionsData = null; if (this.options.hasOptions()) { optionsData = this.options.serialize(); } int optionsLength = 0; if (optionsData != null) { optionsLength = optionsData.length; } final byte[] data = new byte[HEADER_LENGTH + optionsLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.currentHopLimit); bb.put((byte) ((this.mFlag & 0x1) << 7 | (this.oFlag & 0x1) << 6)); bb.putShort(routerLifetime); bb.putInt(reachableTime); bb.putInt(retransmitTimer); if (optionsData != null) { bb.put(optionsData); } return data; }  }
RouterAdvertisement extends BasePacket { @Override public byte[] serialize() { byte[] optionsData = null; if (this.options.hasOptions()) { optionsData = this.options.serialize(); } int optionsLength = 0; if (optionsData != null) { optionsLength = optionsData.length; } final byte[] data = new byte[HEADER_LENGTH + optionsLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.currentHopLimit); bb.put((byte) ((this.mFlag & 0x1) << 7 | (this.oFlag & 0x1) << 6)); bb.putShort(routerLifetime); bb.putInt(reachableTime); bb.putInt(retransmitTimer); if (optionsData != null) { bb.put(optionsData); } return data; }  byte getCurrentHopLimit(); RouterAdvertisement setCurrentHopLimit(final byte currentHopLimit); byte getMFlag(); RouterAdvertisement setMFlag(final byte mFlag); byte getOFlag(); RouterAdvertisement setOFlag(final byte oFlag); short getRouterLifetime(); RouterAdvertisement setRouterLifetime(final short routerLifetime); int getReachableTime(); RouterAdvertisement setReachableTime(final int reachableTime); int getRetransmitTimer(); RouterAdvertisement setRetransmitTimer(final int retransmitTimer); List<NeighborDiscoveryOptions.Option> getOptions(); RouterAdvertisement addOption(final byte type, final byte[] data); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<RouterAdvertisement> deserializer(); @Override String toString(); }
RouterAdvertisement extends BasePacket { @Override public byte[] serialize() { byte[] optionsData = null; if (this.options.hasOptions()) { optionsData = this.options.serialize(); } int optionsLength = 0; if (optionsData != null) { optionsLength = optionsData.length; } final byte[] data = new byte[HEADER_LENGTH + optionsLength]; final ByteBuffer bb = ByteBuffer.wrap(data); bb.put(this.currentHopLimit); bb.put((byte) ((this.mFlag & 0x1) << 7 | (this.oFlag & 0x1) << 6)); bb.putShort(routerLifetime); bb.putInt(reachableTime); bb.putInt(retransmitTimer); if (optionsData != null) { bb.put(optionsData); } return data; }  byte getCurrentHopLimit(); RouterAdvertisement setCurrentHopLimit(final byte currentHopLimit); byte getMFlag(); RouterAdvertisement setMFlag(final byte mFlag); byte getOFlag(); RouterAdvertisement setOFlag(final byte oFlag); short getRouterLifetime(); RouterAdvertisement setRouterLifetime(final short routerLifetime); int getReachableTime(); RouterAdvertisement setReachableTime(final int reachableTime); int getRetransmitTimer(); RouterAdvertisement setRetransmitTimer(final int retransmitTimer); List<NeighborDiscoveryOptions.Option> getOptions(); RouterAdvertisement addOption(final byte type, final byte[] data); @Override byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); @Override int hashCode(); @Override boolean equals(final Object obj); static Deserializer<RouterAdvertisement> deserializer(); @Override String toString(); static final byte HEADER_LENGTH; }