@Override public String toString() { return _prefix.toString(); }
@Override public String getName() { return _prefix.toString(); }
/** * Parse a {@link Prefix} from a string. * * @throws IllegalArgumentException if the string does not represent a prefix in canonical form. */ public static @Nonnull Prefix strict(String prefixStr) { Prefix prefix = parse(prefixStr); checkArgument(prefix.toString().equals(prefixStr), "Non-canonical prefix: %s", prefixStr); return prefix; }
private static String getTextDesc(Prefix prefix, Vrf v) { return String.format("BGP neighbor %s in vrf %s", prefix.toString(), v.getName()); }
@VisibleForTesting public static Set<String> getPrefixes(Map<String, Configuration> configurations) { ImmutableSet.Builder<String> prefixes = ImmutableSet.builder(); configurations .values() .forEach( configuration -> configuration .getAllInterfaces() .values() .forEach( iface -> iface.getAllAddresses().stream() .map(interfaceAddress -> interfaceAddress.getPrefix().toString()) .forEach(prefixes::add))); return prefixes.build(); }
@Override public String visitPrefixIpSpace(PrefixIpSpace prefixIpSpace) { String metadataDescription = computeMetadataDescription(prefixIpSpace); if (metadataDescription != null) { return metadataDescription; } return prefixIpSpace.getPrefix().toString(); }
@Override @JsonValue public String toString() { int prefixLength = _prefix.getPrefixLength(); int low = _lengthRange.getStart(); int high = _lengthRange.getEnd(); if (prefixLength == low && prefixLength == high) { return _prefix.toString(); } else { return _prefix + ":" + low + "-" + high; } }
public String prettyPrint(String prefix) { String net = getNetwork().toString(); String prot = _srcProtocol.protocolName(); String routeStr = String.format( "%s%s dstNode:%s dstVrf:%s dstIp:%s srcNode:%s srcVrf:%s srcIp:%s net:%s nhip:%s " + "origin:%s lp:%s med:%s weight:%s asPath:%s communities:%s orIp:%s clst:%s " + "srcProt:%s\n", prefix, _type, _dstNode, _dstVrf, _dstIp, _srcNode, _srcVrf, _srcIp, net, _nextHopIp, _originType, _localPreference, _med, _weight, _asPath, _communities, _originatorIp, _clusterList, prot); return routeStr; }
@JsonValue @Override public String toString() { if (_second.equals(Ip.ZERO)) { return _first.toString(); } else if (isPrefix()) { return toPrefix().toString(); } else { return _first + ":" + _second; } } }
String net = getNetwork().toString(); String admin = Integer.toString(getAdministrativeCost()); String cost = Long.toString(getMetric());
@Test public void testStrictCanonical() { String canonicalStr = "1.0.0.0/8"; Prefix canonical = strict(canonicalStr); assertThat(strict(canonicalStr).toString(), equalTo(canonicalStr)); assertThat(parse(canonicalStr), equalTo(canonical)); }
int len = Integer.parseInt(x); Prefix p1 = Prefix.create(dip, len); recordMap.put("prefix", p1.toString());
@Test public void testGetPrefixes() { String nodeName = "nodeName"; String int1 = "int1"; String int2 = "int2"; String address1 = "10.1.3.7/30"; String address2 = "128.212.155.30/24"; String address3 = "124.51.32.2/20"; InterfaceAddress interfaceAddress1 = new InterfaceAddress(address1); InterfaceAddress interfaceAddress2 = new InterfaceAddress(address2); InterfaceAddress interfaceAddress3 = new InterfaceAddress(address3); Map<String, Configuration> configs = new HashMap<>(); Configuration config = createTestConfiguration(nodeName, ConfigurationFormat.HOST, int1, int2); config .getAllInterfaces() .get(int1) .setAllAddresses(ImmutableSet.of(interfaceAddress1, interfaceAddress2)); config .getAllInterfaces() .get(int2) .setAllAddresses(ImmutableSet.of(interfaceAddress2, interfaceAddress3)); configs.put(nodeName, config); assertThat( getPrefixes(configs), equalTo( ImmutableSet.of( interfaceAddress1.getPrefix().toString(), interfaceAddress2.getPrefix().toString(), interfaceAddress3.getPrefix().toString()))); }
private org.batfish.datamodel.GeneratedRoute ospfSummaryToAggregateRoute( Prefix prefix, OspfAreaSummary summary) { int prefixLength = prefix.getPrefixLength(); String policyNameSuffix = prefix.toString().replace('/', '_').replace('.', '_'); String policyName = "~SUMMARY" + policyNameSuffix + "~"; RoutingPolicy routingPolicy = new RoutingPolicy(policyName, _c);