@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { return new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(_name)); } }
@Override public BooleanExpr toBooleanExpr(VyosConfiguration vc, Configuration c, Warnings w) { PrefixList pl = vc.getPrefixLists().get(_prefixList); if (pl != null) { return new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(_prefixList)); } else { vc.undefined( VyosStructureType.PREFIX_LIST, _prefixList, VyosStructureUsage.ROUTE_MAP_MATCH_PREFIX_LIST, _statementLine); // TODO: see if vyos treats as true, false, or disallows return BooleanExprs.TRUE; } } }
@Override public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) { Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = d.getDisjuncts(); for (String listName : _listNames) { PrefixList list = cc.getPrefixLists().get(listName); if (list != null) { disjuncts.add( new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(listName))); } } return d.simplify(); } }
} else { AbstractionPrefixSet eps = new AbstractionPrefixSet(filter._prefixTrie); MatchPrefixSet match = new MatchPrefixSet(DestinationNetwork.instance(), eps); if (filter._isForDefaultSlice) {
@Override public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) { Disjunction d = new Disjunction(); List<BooleanExpr> disjuncts = d.getDisjuncts(); for (String listName : _listNames) { Object list; IpAccessList ipAccessList = null; RouteFilterList routeFilterList = null; if (_routing) { routeFilterList = c.getRouteFilterLists().get(listName); list = routeFilterList; } else { ipAccessList = c.getIpAccessLists().get(listName); list = ipAccessList; } if (list != null) { if (_routing) { disjuncts.add( new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(listName))); } else { disjuncts.add(new MatchIpAccessList(listName)); } } } return d.simplify(); } }
"Suppress more specific networks for summary-only aggregate-address networks", new MatchPrefixSet( DestinationNetwork.instance(), new NamedPrefixSet(matchLonger.getName())), ImmutableList.of(Statements.Suppress.toStaticStatement()), ImmutableList.of());
/** * For each static route in the given {@link RoutingInstance} that has at least one community set, * creates an {@link If} that matches that route (specifically, matches static routes with that * route's destination network), and sets communities for matching exported routes. */ @Nonnull private static List<If> getStaticRouteCommunitySetters(@Nonnull RoutingInstance ri) { MatchProtocol matchStatic = new MatchProtocol(RoutingProtocol.STATIC); return ri.getRibs().get(RoutingInformationBase.RIB_IPV4_UNICAST).getStaticRoutes().values() .stream() .filter(route -> !route.getCommunities().isEmpty()) .map( route -> { // Create matcher that matches routes that share this route's destination network PrefixExpr destNetworkMatcher = DestinationNetwork.instance(); PrefixSetExpr destNetwork = new ExplicitPrefixSet(new PrefixSpace(PrefixRange.fromPrefix(route.getPrefix()))); MatchPrefixSet networkMatcher = new MatchPrefixSet(destNetworkMatcher, destNetwork); // When a matching static route is exported, set its communities return new If( new Conjunction(ImmutableList.of(matchStatic, networkMatcher)), ImmutableList.of( new SetCommunity(new LiteralCommunitySet(route.getCommunities())))); }) .collect(ImmutableList.toImmutableList()); }
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { Interface iface = c.getAllInterfaces().get(_name); if (iface == null) { // No such interface, won't match anything return BooleanExprs.FALSE; } // Convert to conjunction of connected protocol and matching at least one of the interface // prefixes return new Conjunction( ImmutableList.of( new MatchProtocol(RoutingProtocol.CONNECTED), new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet( new PrefixSpace( c.getAllInterfaces().get(_name).getAllAddresses().stream() .map(InterfaceAddress::getPrefix) .map(PrefixRange::fromPrefix) .collect(ImmutableSet.toImmutableSet())))))); } }
@Override public BooleanExpr toBooleanExpr(CiscoConfiguration cc, Configuration c, Warnings w) { PrefixSetExpr prefixSetExpr = _prefixSet.toPrefixSetExpr(cc, c, w); if (prefixSetExpr != null) { return new MatchPrefixSet(DestinationNetwork.instance(), prefixSetExpr); } else { Prefix6SetExpr prefix6SetExpr = _prefixSet.toPrefix6SetExpr(cc, c, w); return new MatchPrefix6Set(new DestinationNetwork6(), prefix6SetExpr); } } }
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { RouteFilterList rfl = c.getRouteFilterLists().get(_routeFilterName); Route6FilterList rfl6 = c.getRoute6FilterLists().get(_routeFilterName); BooleanExpr match4 = null; BooleanExpr match6 = null; if (rfl != null) { match4 = new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(_routeFilterName)); } if (rfl6 != null) { match6 = new MatchPrefix6Set(new DestinationNetwork6(), new NamedPrefix6Set(_routeFilterName)); } if (match4 != null && match6 == null) { return match4; } else if (rfl == null && rfl6 != null) { return match6; } else if (rfl != null && rfl6 != null) { Disjunction d = new Disjunction(); d.getDisjuncts().add(match4); d.getDisjuncts().add(match6); return d; } else { throw new VendorConversionException( "missing route filter list: \"" + _routeFilterName + "\""); } } }
/** * Generates and returns a {@link RoutingPolicy} that matches routes that should be aggregated for * aggregate network indicated by the given {@link Prefix}. * * <p>Does the bookkeeping in the provided {@link Configuration} to ensure the generated policy is * available and tracked. */ static RoutingPolicy generateAggregateRoutePolicy( Configuration c, String vrfName, Prefix prefix) { BooleanExpr matchLongerNetworks = new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet(new PrefixSpace(PrefixRange.moreSpecificThan(prefix)))); If currentGeneratedRouteConditional = new If(matchLongerNetworks, singletonList(Statements.ReturnTrue.toStaticStatement())); RoutingPolicy policy = new RoutingPolicy("~AGGREGATE_ROUTE_GEN:" + vrfName + ":" + prefix + "~", c); policy.setStatements(ImmutableList.of(currentGeneratedRouteConditional)); c.getRoutingPolicies().put(policy.getName(), policy); return policy; }
new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(rflName)); RouteFilterList rfList = new RouteFilterList(rflName); rfList.addLine(
MatchPrefixSet mrf = new MatchPrefixSet( DestinationNetwork.instance(), new NamedPrefixSet(lineListName)); lineSpecificIfStatement.setGuard(mrf); lineSpecificIfStatement.getTrueStatements().addAll(toStatements(line.getThens()));
@Override public BooleanExpr toBooleanExpr(JuniperConfiguration jc, Configuration c, Warnings warnings) { PrefixList pl = jc.getMasterLogicalSystem().getPrefixLists().get(_prefixList); if (pl != null) { if (pl.getIpv6()) { return BooleanExprs.FALSE; } RouteFilterList rf = c.getRouteFilterLists().get(_prefixList); String orLongerListName = "~" + _prefixList + "~ORLONGER~"; RouteFilterList orLongerList = c.getRouteFilterLists().get(orLongerListName); if (orLongerList == null) { orLongerList = new RouteFilterList(orLongerListName); for (RouteFilterLine line : rf.getLines()) { Prefix prefix = line.getIpWildcard().toPrefix(); LineAction action = line.getAction(); SubRange orLongerLineRange = new SubRange(line.getLengthRange().getStart(), Prefix.MAX_PREFIX_LENGTH); RouteFilterLine orLongerLine = new RouteFilterLine(action, prefix, orLongerLineRange); orLongerList.addLine(orLongerLine); c.getRouteFilterLists().put(orLongerListName, orLongerList); } } return new MatchPrefixSet( DestinationNetwork.instance(), new NamedPrefixSet(orLongerListName)); } else { warnings.redFlag("Reference to undefined prefix-list: \"" + _prefixList + "\""); return BooleanExprs.FALSE; } } }
String rflName = "~SUMMARY" + policyNameSuffix + "_RF~"; MatchPrefixSet isContributingRoute = new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(rflName)); routingPolicyConditional.setGuard(isContributingRoute); RouteFilterList rfList = new RouteFilterList(rflName);
return new MatchPrefixSet(DestinationNetwork.instance(), new NamedPrefixSet(longerListName)); } else { warnings.redFlag("Reference to undefined prefix-list: \"" + _prefixList + "\"");
generateAggregateConditions.add( new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet(new PrefixSpace(PrefixRange.fromPrefix(prefix))))); generateAggregateConditions.add(new MatchProtocol(RoutingProtocol.AGGREGATE)); ImmutableList.of( new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet(exportSpace)), new Not(new MatchProtocol(RoutingProtocol.BGP)), new Not(new MatchProtocol(RoutingProtocol.IBGP)),
generateAggregateConditions.add( new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet(new PrefixSpace(PrefixRange.fromPrefix(prefix))))); generateAggregateConditions.add(new MatchProtocol(RoutingProtocol.AGGREGATE)); .add( new MatchPrefixSet( DestinationNetwork.instance(), new ExplicitPrefixSet(space))); exportNetworkConditions .getConjuncts()
.add( new MatchPrefixSet( DestinationNetwork.instance(), new NamedPrefixSet(originationPolicyName)));