use of org.batfish.datamodel.IpWildcard in project batfish by batfish.
the class FwFromDestinationPrefixListExcept method applyTo.
@Override
public void applyTo(IpAccessListLine line, JuniperConfiguration jc, Warnings w, Configuration c) {
PrefixList pl = jc.getPrefixLists().get(_name);
if (pl != null) {
pl.getReferers().put(this, "firewall from destination-prefix-list");
if (pl.getIpv6()) {
return;
}
RouteFilterList destinationPrefixList = c.getRouteFilterLists().get(_name);
List<IpWildcard> wildcards = destinationPrefixList.getMatchingIps();
line.setNotDstIps(Iterables.concat(line.getNotDstIps(), wildcards));
} else {
w.redFlag("Reference to undefined source prefix-list: \"" + _name + "\"");
}
}
use of org.batfish.datamodel.IpWildcard in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitIp.
@Test
public void testVisitIp() {
Ip ip = new Ip("1.2.3.4");
BooleanExpr matchSrcExpr = ip.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(matchSrcExpr, equalTo(HeaderSpaceMatchExpr.matchSrcIp(ImmutableSet.of(new IpWildcard(ip)))));
BooleanExpr matchDstExpr = ip.accept(DST_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(matchDstExpr, equalTo(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(ip)))));
BooleanExpr matchSrcOrDstExpr = ip.accept(SRC_OR_DST_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(matchSrcOrDstExpr, equalTo(HeaderSpaceMatchExpr.matchSrcOrDstIp(ImmutableSet.of(new IpWildcard(ip)))));
}
use of org.batfish.datamodel.IpWildcard in project batfish by batfish.
the class IpSpaceBooleanExprTransformerTest method testVisitIpWildcardSetIpSpace.
@Test
public void testVisitIpWildcardSetIpSpace() {
IpWildcard includeWildcard = new IpWildcard("1.1.1.1");
IpWildcard excludeWildcard = new IpWildcard("2.2.2.2");
IpWildcardSetIpSpace ipSpace = IpWildcardSetIpSpace.builder().including(includeWildcard).excluding(excludeWildcard).build();
BooleanExpr expr = ipSpace.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
BooleanExpr includeExpr = includeWildcard.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
BooleanExpr excludeExpr = excludeWildcard.accept(SRC_IP_SPACE_BOOLEAN_EXPR_TRANSFORMER);
assertThat(expr, equalTo(new AndExpr(ImmutableList.of(new NotExpr(excludeExpr), includeExpr))));
}
use of org.batfish.datamodel.IpWildcard in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitPreOut.
@Test
public void testVisitPreOut() {
SynthesizerInput input = MockSynthesizerInput.builder().setIpsByHostname(ImmutableMap.of(NODE1, ImmutableSet.of(IP1, IP2), NODE2, ImmutableSet.of(IP3, IP4))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(PreOut.State.INSTANCE)));
// PostInNotMine
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP1), new IpWildcard(IP2)))), ImmutableSet.of(new PostIn(NODE1)), new PreOut(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(new NotExpr(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP3), new IpWildcard(IP4)))), ImmutableSet.of(new PostIn(NODE2)), new PreOut(NODE2))));
}
use of org.batfish.datamodel.IpWildcard in project batfish by batfish.
the class DefaultTransitionGeneratorTest method testVisitNodeAccept.
@Test
public void testVisitNodeAccept() {
SynthesizerInput input = MockSynthesizerInput.builder().setEnabledNodes(ImmutableSet.of(NODE1, NODE2)).setIpsByHostname(ImmutableMap.of(NODE1, ImmutableSet.of(IP1, IP2), NODE2, ImmutableSet.of(IP3, IP4))).build();
Set<RuleStatement> rules = ImmutableSet.copyOf(DefaultTransitionGenerator.generateTransitions(input, ImmutableSet.of(NodeAccept.State.INSTANCE)));
// PostInForMe
assertThat(rules, hasItem(new BasicRuleStatement(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP1), new IpWildcard(IP2))), ImmutableSet.of(new PostIn(NODE1)), new NodeAccept(NODE1))));
assertThat(rules, hasItem(new BasicRuleStatement(HeaderSpaceMatchExpr.matchDstIp(ImmutableSet.of(new IpWildcard(IP3), new IpWildcard(IP4))), ImmutableSet.of(new PostIn(NODE2)), new NodeAccept(NODE2))));
}
Aggregations