/** * Converts Ipv4Prefix to byte array. Prefix length at the beginning. * Prefix bytes are trimmed from the end to match prefix length. * * @param prefix Ipv4Prefix to be converted * @return byte array with the prefix length at the beginning * * @deprecated This is inefficient, refactor code to use {@link #bytesForAddress(Ipv4Address)} or * {@link ByteBufWriteUtil#writeMinimalPrefix(Ipv4Prefix, ByteBuf)}. */ @Deprecated public static byte[] bytesForPrefixBegin(final Ipv4Prefix prefix) { final byte[] addrWithPrefix = bytesForPrefix(prefix); return prefixedBytes(addrWithPrefix[IP4_LENGTH], addrWithPrefix); }
/** * Writes IPv4 prefix if not null, otherwise writes zeros to the * <code>output</code> ByteBuf. ByteBuf's writerIndex is increased by 5. * * @param ipv4Prefix * IPv4 prefix value to be written to the output. Prefix is * written in the last byte. * @param output * ByteBuf, where ipv4Prefix or zeros are written. */ public static void writeIpv4Prefix(final Ipv4Prefix ipv4Prefix, final ByteBuf output) { if (ipv4Prefix != null) { output.writeBytes(Ipv4Util.bytesForPrefix(ipv4Prefix)); } else { output.writeZero(IPV4_PREFIX_BYTE_LENGTH); } }