/** * Converts Ipv6Prefix to byte array. Prefix length at the end. * * @param prefix Ipv6Prefix to be converted * @return byte array with prefix length at the end */ public static byte[] bytesForPrefix(final Ipv6Prefix prefix) { return IetfInetUtil.INSTANCE.ipv6PrefixToBytes(prefix); }
public static void writeMinimalPrefix(final Ipv6Prefix ipv6Prefix, final ByteBuf output) { final byte[] bytes = IetfInetUtil.INSTANCE.ipv6PrefixToBytes(ipv6Prefix); writeMinimalPrefix(output, bytes, bytes[Ipv6Util.IPV6_LENGTH]); }
private byte[] icmp6RAPayloadtoByte(RouterAdvertisementPacket pdu) { byte[] data = new byte[pdu.getIpv6Length()]; Arrays.fill(data, (byte)0); ByteBuffer buf = ByteBuffer.wrap(data); buf.put((byte)pdu.getIcmp6Type().shortValue()); buf.put((byte)pdu.getIcmp6Code().shortValue()); buf.putShort((short)pdu.getIcmp6Chksum().intValue()); buf.put((byte)pdu.getCurHopLimit().shortValue()); buf.put((byte)pdu.getFlags().shortValue()); buf.putShort((short)pdu.getRouterLifetime().intValue()); buf.putInt((int)pdu.getReachableTime().longValue()); buf.putInt((int)pdu.getRetransTime().longValue()); buf.put((byte)pdu.getOptionSourceAddr().shortValue()); buf.put((byte)pdu.getSourceAddrLength().shortValue()); buf.put(ipv6Utils.bytesFromHexString(pdu.getSourceLlAddress().getValue().toString())); for (PrefixList prefix : pdu.getPrefixList()) { buf.put((byte)prefix.getOptionType().shortValue()); buf.put((byte)prefix.getOptionLength().shortValue()); buf.put((byte)prefix.getPrefixLength().shortValue()); buf.put((byte)prefix.getFlags().shortValue()); buf.putInt((int)prefix.getValidLifetime().longValue()); buf.putInt((int)prefix.getPreferredLifetime().longValue()); buf.putInt((int)prefix.getReserved().longValue()); buf.put(IetfInetUtil.INSTANCE.ipv6PrefixToBytes(new Ipv6Prefix(prefix.getPrefix())),0,16); } return data; } }