public Ipv4Prefix ipv4PrefixFromUniqueRouteName(@Nonnull final String uniqueName) { String[] parts = uniqueName.split(UNDERSCORE); return new Ipv4Prefix(dotted(parts[1]) + "/" + parts[2]); }
/** * Converts byte array to {@link Ipv4Prefix} with specified prefixLength */ public static Ipv4Prefix arrayToIpv4Prefix(final byte[] address, byte prefixLength) { Ipv4AddressNoZone addressPart = arrayToIpv4AddressNoZone(address); return new Ipv4Prefix(addressPart.getValue().concat("/").concat(String.valueOf(prefixLength))); }
private List<Ipv4Prefix> extractPrefixes(final Collection<MapEntryNode> routes) { final List<Ipv4Prefix> prefs = new ArrayList<>(routes.size()); for (final MapEntryNode ipv4Route : routes) { final String prefix = (String) ipv4Route.getChild(this.routeKeyLeaf).get().getValue(); prefs.add(new Ipv4Prefix(prefix)); } return prefs; }
public static IpPrefix createGwPrefix(IpAddress ipAddress, IpPrefix network) { StringBuilder buf = new StringBuilder(); buf.append(ipAddress.getValue()); String str = network.getIpv4Prefix().getValue(); buf.append(str.substring(str.indexOf("/"))); return new IpPrefix(new Ipv4Prefix(buf.toString())); }
public static Ipv4Prefix createPrefix(final Ipv4Address ipv4Address, final String mask){ /* * Ipv4Address has already validated the address part of the prefix, * It is mandated to comply to the same regexp as the address * There is absolutely no point rerunning additional checks vs this * Note - there is no canonical form check here!!! */ if (null != mask && !mask.isEmpty()) { return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + mask); } else { return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + IPV4_ADDRESS_LENGTH); } }
public static IpPrefix getDefaultInstance(final String defaultValue) { return IPV4_PATTERN.matcher(defaultValue).matches() ? new IpPrefix(new Ipv4Prefix(defaultValue)) : new IpPrefix(new Ipv6Prefix(defaultValue)); } }
private List<IpPrefix> aggregateAddressesList(List<Addresses> addressesList) { List<IpPrefix> prefixList = new LinkedList<>(); for (Addresses addresses : addressesList) { if (addresses.getIp() == null) continue; String ipAddress = addresses.getIp().getIpv4Address().getValue(); IpPrefix prefix = new IpPrefix(new Ipv4Prefix(ipAddress + "/32")); prefixList.add(prefix); } return prefixList; }
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix v4LispPrefixToInetPrefix( final Ipv4Prefix prefix) { return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( prefix.getIpv4Prefix().getValue()); }
static void AdvertiseIpv4Prefixes(final ChannelOutputLimiter session, final int nPrefixes, final List<String> extCom, final boolean multipartSupport) { Ipv4Prefix addressPrefix = new Ipv4Prefix("1.1.1.1/31"); for (int i = 0; i < nPrefixes; i++) { buildAndSend(session, addressPrefix, extCom, multipartSupport); addressPrefix = incrementIpv4Prefix(addressPrefix); } }
public static IpPrefix createDefaultPrefix(IpAddress ipAddress) { if (ipAddress.getIpv4Address() == null) { return null; } String ipv4 = ipAddress.getIpv4Address().getValue(); long mask = getDefaultMask(ipv4); return new IpPrefix(new Ipv4Prefix(String.format("%s/%d", ipv4, mask))); }
static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix v4Prefix( final byte[] address, final byte prefix) { return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix( prefixValue(INSTANCE.arrayToIpv4AddressNoZone(address).getValue(), String.valueOf(prefix))); }
public static Action setIpv4SrcAction(Ipv4Address ipAddress) { Ipv4Builder ipSrc = new Ipv4Builder(); Ipv4Prefix prefixdst = new Ipv4Prefix(new Ipv4Prefix(ipAddress.getValue() + "/32")); ipSrc.setIpv4Address(prefixdst); SetNwSrcActionBuilder setNwSrcActionBuilder = new SetNwSrcActionBuilder(); setNwSrcActionBuilder.setAddress(ipSrc.build()); return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilder.build()).build(); }
public static Action setIpv4DstAction(Ipv4Address ipAddress) { Ipv4Builder ipDest = new Ipv4Builder(); Ipv4Prefix prefixdst = new Ipv4Prefix(new Ipv4Prefix(ipAddress.getValue() + "/32")); ipDest.setIpv4Address(prefixdst); SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder(); setNwDstActionBuilder.setAddress(ipDest.build()); return new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build(); }
public static IpPrefix ipAddressToIpPrefix(IpAddress address) { if (address.getIpv4Address() != null) { return new IpPrefix(new Ipv4Prefix(ipv4PrefixOf(address))); } else if (address.getIpv6Address() != null) { return new IpPrefix(new Ipv6Prefix(ipv6PrefixOf(address))); } throw new IllegalArgumentException("Ip address [{}] is not a valid Ipv4 or Ipv6 address." + address); }
private List<Ipv4Prefixes> extractPrefixes(final Collection<MapEntryNode> routes) { final List<Ipv4Prefixes> prefs = new ArrayList<>(routes.size()); for (final MapEntryNode route : routes) { final String prefix = (String) NormalizedNodes.findNode(route, routePrefixIdentifier()).get().getValue(); final Ipv4PrefixesBuilder prefixBuilder = new Ipv4PrefixesBuilder().setPrefix(new Ipv4Prefix(prefix)); prefixBuilder.setPathId(PathIdUtil.buildPathId(route, routePathIdNid())); prefs.add(prefixBuilder.build()); } return prefs; }
public static void addMatchArpRequestAndTpa(MatchBuilder match, String requestedIp){ ArpMatchBuilder arpmatch = new ArpMatchBuilder(); arpmatch.setArpOp(ARP_REQUEST); arpmatch.setArpTargetTransportAddress(new Ipv4Prefix(requestedIp + "/32")); match.setLayer3Match(arpmatch.build()); }
private static Subobject getDefaultEROEndpointHop() { final SubobjectBuilder builder = new SubobjectBuilder(); builder.setLoose(false); builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix( new IpPrefix(new Ipv4Prefix(ENDPOINT_PREFIX))).build()).build()); return builder.build(); } }
@Override public void addDefaultKeyIPv4() { Eid eid = LispAddressUtil.toEid(new Ipv4Prefix("0.0.0.0/0"), null); MappingAuthkey key = new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build(); mappingService.addAuthenticationKey(eid, key); } }
/** * Creates {@link ArpMatch} containing Reply ARP operation, THA and TPA for the given target * address and SPA for the given sender protocol address */ public static ArpMatch createArpMatch(ArpMessageAddress targetAddress, Ipv4Address senderProtocolAddress) { return new ArpMatchBuilder().setArpOp(ArpOperation.REPLY.intValue()) .setArpTargetHardwareAddress( new ArpTargetHardwareAddressBuilder().setAddress(targetAddress.getHardwareAddress()).build()) .setArpTargetTransportAddress(new Ipv4Prefix(targetAddress.getProtocolAddress().getValue() + HOST_MASK)) .setArpSourceTransportAddress(new Ipv4Prefix(senderProtocolAddress.getValue() + HOST_MASK)) .build(); }
public static Action createActionSetNwDst(String ipStr, int netmask, int order) { Ipv4Prefix prefixdst = new Ipv4Prefix(ipStr + "/" + String.valueOf(netmask)); Ipv4Builder ipdst = new Ipv4Builder(); ipdst.setIpv4Address(prefixdst); SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder(); nwDstBuilder.setAddress(ipdst.build()); SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder(); nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build()); ActionBuilder ab = createActionBuilder(order); ab.setAction(nwDstCaseBuilder.build()); return ab.build(); }