@Test public void testSerialize() { NeighborAdvertisement na = new NeighborAdvertisement(); na.setRouterFlag((byte) 1); na.setSolicitedFlag((byte) 1); na.setOverrideFlag((byte) 1); na.setTargetAddress(TARGET_ADDRESS); na.addOption(NeighborDiscoveryOptions.TYPE_TARGET_LL_ADDRESS, MAC_ADDRESS.toBytes()); assertArrayEquals(na.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.putInt((this.routerFlag & 0x1) << 31 | (this.solicitedFlag & 0x1) << 30 | (this.overrideFlag & 0x1) << 29); bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH); if (optionsData != null) { bb.put(optionsData); } return data; }
NeighborAdvertisement 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.putInt((this.routerFlag & 0x1) << 31 | (this.solicitedFlag & 0x1) << 30 | (this.overrideFlag & 0x1) << 29); bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH); if (optionsData != null) { bb.put(optionsData); } return data; } }
NeighborAdvertisement 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.putInt((this.routerFlag & 0x1) << 31 | (this.solicitedFlag & 0x1) << 30 | (this.overrideFlag & 0x1) << 29); bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH); if (optionsData != null) { bb.put(optionsData); } return data; }  }
NeighborAdvertisement 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.putInt((this.routerFlag & 0x1) << 31 | (this.solicitedFlag & 0x1) << 30 | (this.overrideFlag & 0x1) << 29); bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH); if (optionsData != null) { bb.put(optionsData); } return data; }  byte getRouterFlag(); NeighborAdvertisement setRouterFlag(final byte routerFlag); byte getSolicitedFlag(); NeighborAdvertisement setSolicitedFlag(final byte solicitedFlag); byte getOverrideFlag(); NeighborAdvertisement setOverrideFlag(final byte overrideFlag); byte[] getTargetAddress(); NeighborAdvertisement setTargetAddress(final byte[] targetAddress); List<NeighborDiscoveryOptions.Option> getOptions(); NeighborAdvertisement 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<NeighborAdvertisement> deserializer(); @Override String toString(); }
NeighborAdvertisement 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.putInt((this.routerFlag & 0x1) << 31 | (this.solicitedFlag & 0x1) << 30 | (this.overrideFlag & 0x1) << 29); bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH); if (optionsData != null) { bb.put(optionsData); } return data; }  byte getRouterFlag(); NeighborAdvertisement setRouterFlag(final byte routerFlag); byte getSolicitedFlag(); NeighborAdvertisement setSolicitedFlag(final byte solicitedFlag); byte getOverrideFlag(); NeighborAdvertisement setOverrideFlag(final byte overrideFlag); byte[] getTargetAddress(); NeighborAdvertisement setTargetAddress(final byte[] targetAddress); List<NeighborDiscoveryOptions.Option> getOptions(); NeighborAdvertisement 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<NeighborAdvertisement> deserializer(); @Override String toString(); static final byte HEADER_LENGTH; }