@Override public Ip4Prefix read(Kryo kryo, Input input, Class<Ip4Prefix> type) { int octLen = input.readInt(); checkArgument(octLen <= Ip4Address.BYTE_LENGTH); byte[] octs = new byte[octLen]; input.readBytes(octs); int prefLen = input.readInt(); return Ip4Prefix.valueOf(octs, prefLen); } }
/** * Gets the {@link Ip4Prefix} view of the IP prefix. * * @return the {@link Ip4Prefix} view of the IP prefix if it is IPv4, * otherwise null */ public Ip4Prefix getIp4Prefix() { if (!isIp4()) { return null; } // Return this object itself if it is already instance of Ip4Prefix if (this instanceof Ip4Prefix) { return (Ip4Prefix) this; } return Ip4Prefix.valueOf(address.getIp4Address(), prefixLength); }
Ip4Prefix prefix = Ip4Prefix.valueOf(Ip4Address.valueOf(buffer), prefixBitlen); result.add(prefix);
if (match.isPartiallyMasked(MatchField.IPV4_SRC)) { Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC); ip4Prefix = Ip4Prefix.valueOf( maskedIp.getValue().getInt(), maskedIp.getMask().asCidrMaskLength()); } else { ip4Prefix = Ip4Prefix.valueOf( match.get(MatchField.IPV4_SRC).getInt(), Ip4Prefix.MAX_MASK_LENGTH); if (match.isPartiallyMasked(MatchField.IPV4_DST)) { Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST); ip4Prefix = Ip4Prefix.valueOf( maskedIp.getValue().getInt(), maskedIp.getMask().asCidrMaskLength()); } else { ip4Prefix = Ip4Prefix.valueOf( match.get(MatchField.IPV4_DST).getInt(), Ip4Prefix.MAX_MASK_LENGTH);