use of org.batfish.datamodel.routing_policy.expr.Disjunction in project batfish by batfish.
the class RoutingPolicyTests method testRoutingPolicyDeepCircularReference.
/**
* Policy with actual circular reference deep in the policy
*/
@Test
public void testRoutingPolicyDeepCircularReference() {
String parentPolicyName = "parent";
CallStatement callStatement = new CallStatement(parentPolicyName);
BufferedStatement bs = new BufferedStatement(callStatement);
WithEnvironmentExpr we1 = new WithEnvironmentExpr();
we1.setPostStatements(ImmutableList.of(bs));
If if1 = new If();
if1.setGuard(we1);
WithEnvironmentExpr we2 = new WithEnvironmentExpr();
we2.setPostTrueStatements(ImmutableList.of(if1));
If if2 = new If();
if2.setGuard(we2);
If if3 = new If();
if3.setTrueStatements(ImmutableList.of(if2));
If if4 = new If();
if4.setFalseStatements(ImmutableList.of(if3));
WithEnvironmentExpr we3 = new WithEnvironmentExpr();
we3.setPreStatements(ImmutableList.of(if4));
WithEnvironmentExpr we4 = new WithEnvironmentExpr();
we4.setExpr(we3);
Conjunction conj = new Conjunction();
conj.setConjuncts(ImmutableList.of(we4));
ConjunctionChain conjunctionChain = new ConjunctionChain(ImmutableList.of(conj));
Disjunction disjunction = new Disjunction();
disjunction.setDisjuncts(ImmutableList.of(conjunctionChain));
DisjunctionChain disjunctionChain = new DisjunctionChain(ImmutableList.of(disjunction));
Not not = new Not(disjunctionChain);
If if5 = new If();
if5.setGuard(not);
_rpb.setName(parentPolicyName).setStatements(ImmutableList.of(if5)).build();
_c.computeRoutingPolicySources(_w);
/*
* A circular reference warning should be emitted containing the name of the circularly
* referenced policy.
*/
assertThat(_w.getRedFlagWarnings(), not(empty()));
assertThat(_w.getRedFlagWarnings().iterator().next().getText(), containsString(parentPolicyName));
}
use of org.batfish.datamodel.routing_policy.expr.Disjunction in project batfish by batfish.
the class RouteMapMatchIpAccessListLine method toBooleanExpr.
@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) {
cc.undefined(CiscoStructureType.IP_ACCESS_LIST, listName, CiscoStructureUsage.ROUTE_MAP_MATCH_IP_ACCESS_LIST, _statementLine);
} else {
String msg = "route-map match ip access-list line";
ExtendedAccessList extendedAccessList = cc.getExtendedAcls().get(listName);
if (extendedAccessList != null) {
extendedAccessList.getReferers().put(this, msg);
}
StandardAccessList standardAccessList = cc.getStandardAcls().get(listName);
if (standardAccessList != null) {
standardAccessList.getReferers().put(this, msg);
}
if (_routing) {
disjuncts.add(new MatchPrefixSet(new DestinationNetwork(), new NamedPrefixSet(listName)));
} else {
disjuncts.add(new MatchIpAccessList(listName));
}
}
}
return d.simplify();
}
use of org.batfish.datamodel.routing_policy.expr.Disjunction in project batfish by batfish.
the class RouteMapMatchTagLine method toBooleanExpr.
@Override
public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) {
Disjunction d = new Disjunction();
List<BooleanExpr> disjuncts = d.getDisjuncts();
for (int tag : _tags) {
disjuncts.add(new MatchTag(IntComparator.EQ, new LiteralInt(tag)));
}
return d.simplify();
}
use of org.batfish.datamodel.routing_policy.expr.Disjunction in project batfish by batfish.
the class RouteMapMatchCommunityListLine method toBooleanExpr.
@Override
public BooleanExpr toBooleanExpr(Configuration c, CiscoConfiguration cc, Warnings w) {
Disjunction d = new Disjunction();
List<BooleanExpr> disjuncts = d.getDisjuncts();
for (String listName : _listNames) {
CommunityList list = c.getCommunityLists().get(listName);
if (list != null) {
String msg = "match community line";
StandardCommunityList standardCommunityList = cc.getStandardCommunityLists().get(listName);
if (standardCommunityList != null) {
standardCommunityList.getReferers().put(this, msg);
}
ExpandedCommunityList expandedCommunityList = cc.getExpandedCommunityLists().get(listName);
if (expandedCommunityList != null) {
expandedCommunityList.getReferers().put(this, msg);
}
disjuncts.add(new MatchCommunitySet(new NamedCommunitySet(listName)));
} else {
cc.undefined(CiscoStructureType.COMMUNITY_LIST, listName, CiscoStructureUsage.ROUTE_MAP_MATCH_COMMUNITY_LIST, _statementLine);
}
}
return d.simplify();
}
use of org.batfish.datamodel.routing_policy.expr.Disjunction in project batfish by batfish.
the class RoutePolicyBooleanOr method toBooleanExpr.
@Override
public BooleanExpr toBooleanExpr(CiscoConfiguration cc, Configuration c, Warnings w) {
Disjunction disj = new Disjunction();
BooleanExpr left = _left.toBooleanExpr(cc, c, w);
BooleanExpr right = _right.toBooleanExpr(cc, c, w);
List<BooleanExpr> disjuncts = disj.getDisjuncts();
disjuncts.add(left);
disjuncts.add(right);
return disj.simplify();
}
Aggregations