use of org.batfish.datamodel.LineAction in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitIp_prefix_list_tail.
@Override
public void exitIp_prefix_list_tail(Ip_prefix_list_tailContext ctx) {
LineAction action = toLineAction(ctx.action);
Prefix prefix = Prefix.parse(ctx.prefix.getText());
int prefixLength = prefix.getPrefixLength();
int minLen = prefixLength;
int maxLen = prefixLength;
if (ctx.minpl != null) {
minLen = toInteger(ctx.minpl);
maxLen = Prefix.MAX_PREFIX_LENGTH;
}
if (ctx.maxpl != null) {
maxLen = toInteger(ctx.maxpl);
}
if (ctx.eqpl != null) {
minLen = toInteger(ctx.eqpl);
maxLen = toInteger(ctx.eqpl);
}
SubRange lengthRange = new SubRange(minLen, maxLen);
PrefixListLine line = new PrefixListLine(action, prefix, lengthRange);
_currentPrefixList.addLine(line);
}
use of org.batfish.datamodel.LineAction in project batfish by batfish.
the class FlatVyosControlPlaneExtractor method exitPlrt_action.
@Override
public void exitPlrt_action(Plrt_actionContext ctx) {
LineAction action = toAction(ctx.action);
_currentPrefixListRule.setAction(action);
}
use of org.batfish.datamodel.LineAction in project batfish by batfish.
the class CiscoConfiguration method toRoute6FilterLine.
private Route6FilterLine toRoute6FilterLine(ExtendedIpv6AccessListLine fromLine) {
LineAction action = fromLine.getAction();
Ip6 ip = fromLine.getSourceIpWildcard().getIp();
BigInteger minSubnet = fromLine.getDestinationIpWildcard().getIp().asBigInteger();
BigInteger maxSubnet = minSubnet.or(fromLine.getDestinationIpWildcard().getWildcard().asBigInteger());
int minPrefixLength = fromLine.getDestinationIpWildcard().getIp().numSubnetBits();
int maxPrefixLength = new Ip6(maxSubnet).numSubnetBits();
int statedPrefixLength = fromLine.getSourceIpWildcard().getWildcard().inverted().numSubnetBits();
int prefixLength = Math.min(statedPrefixLength, minPrefixLength);
Prefix6 prefix = new Prefix6(ip, prefixLength);
return new Route6FilterLine(action, prefix, new SubRange(minPrefixLength, maxPrefixLength));
}
use of org.batfish.datamodel.LineAction in project batfish by batfish.
the class CiscoConfiguration method toRouteFilterLine.
private RouteFilterLine toRouteFilterLine(ExtendedAccessListLine fromLine) {
LineAction action = fromLine.getAction();
Ip ip = fromLine.getSourceIpWildcard().getIp();
long minSubnet = fromLine.getDestinationIpWildcard().getIp().asLong();
long maxSubnet = minSubnet | fromLine.getDestinationIpWildcard().getWildcard().asLong();
int minPrefixLength = fromLine.getDestinationIpWildcard().getIp().numSubnetBits();
int maxPrefixLength = new Ip(maxSubnet).numSubnetBits();
int statedPrefixLength = fromLine.getSourceIpWildcard().getWildcard().inverted().numSubnetBits();
int prefixLength = Math.min(statedPrefixLength, minPrefixLength);
Prefix prefix = new Prefix(ip, prefixLength);
return new RouteFilterLine(action, prefix, new SubRange(minPrefixLength, maxPrefixLength));
}
use of org.batfish.datamodel.LineAction in project batfish by batfish.
the class SynthesizerInputImplTest method testComputeAclActions.
@Test
public void testComputeAclActions() {
Configuration srcNode = _cb.build();
Configuration nextHop = _cb.build();
IpAccessList edgeInterfaceInAcl = _aclb.setOwner(srcNode).setLines(ImmutableList.of(IpAccessListLine.builder().setAction(LineAction.ACCEPT).build(), IpAccessListLine.builder().setAction(LineAction.REJECT).build())).build();
IpAccessList srcInterfaceOutAcl = _aclb.build();
IpAccessList iNoEdgeInAcl = _aclb.build();
IpAccessList iNoEdgeOutAcl = _aclb.build();
IpAccessList nextHopInterfaceInAcl = _aclb.setOwner(nextHop).build();
IpAccessList nextHopInterfaceOutAcl = _aclb.build();
Vrf srcVrf = _vb.setOwner(srcNode).build();
Vrf nextHopVrf = _vb.setOwner(nextHop).build();
Interface srcInterface = _ib.setOwner(srcNode).setVrf(srcVrf).setIncomingFilter(edgeInterfaceInAcl).setOutgoingFilter(srcInterfaceOutAcl).build();
/*
* Interface without an edge: Its ACLs should be absent with data plane, but present without
* data plane.
*/
_ib.setIncomingFilter(iNoEdgeInAcl).setOutgoingFilter(iNoEdgeOutAcl).build();
Interface nextHopInterface = _ib.setIncomingFilter(nextHopInterfaceInAcl).setOutgoingFilter(nextHopInterfaceOutAcl).setOwner(nextHop).setVrf(nextHopVrf).build();
Edge forwardEdge = new Edge(srcInterface, nextHopInterface);
Edge backEdge = new Edge(nextHopInterface, srcInterface);
SynthesizerInput inputWithoutDataPlane = _inputBuilder.setConfigurations(ImmutableMap.of(srcNode.getName(), srcNode, nextHop.getName(), nextHop)).build();
SynthesizerInput inputWithDataPlane = _inputBuilder.setForwardingAnalysis(MockForwardingAnalysis.builder().build()).setTopology(new Topology(ImmutableSortedSet.of(forwardEdge, backEdge))).build();
List<LineAction> expectedActions = ImmutableList.of(LineAction.ACCEPT, LineAction.REJECT);
Map<String, List<LineAction>> expectedSrcNodeWithDataPlane = ImmutableMap.of(edgeInterfaceInAcl.getName(), expectedActions, srcInterfaceOutAcl.getName(), expectedActions);
Map<String, List<LineAction>> expectedSrcNodeWithoutDataPlane = ImmutableMap.<String, List<LineAction>>builder().putAll(expectedSrcNodeWithDataPlane).put(iNoEdgeInAcl.getName(), expectedActions).put(iNoEdgeOutAcl.getName(), expectedActions).build();
Map<String, List<LineAction>> expectedNextHop = ImmutableMap.of(nextHopInterfaceInAcl.getName(), expectedActions, nextHopInterfaceOutAcl.getName(), expectedActions);
assertThat(inputWithDataPlane, hasAclActions(equalTo(ImmutableMap.of(srcNode.getName(), expectedSrcNodeWithDataPlane, nextHop.getName(), expectedNextHop))));
assertThat(inputWithoutDataPlane, hasAclActions(equalTo(ImmutableMap.of(srcNode.getName(), expectedSrcNodeWithoutDataPlane, nextHop.getName(), expectedNextHop))));
}
Aggregations