Search in sources :

Example 16 with LineAction

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);
}
Also used : LineAction(org.batfish.datamodel.LineAction) PrefixListLine(org.batfish.representation.cisco.PrefixListLine) RouteMapMatchIpPrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpPrefixListLine) RouteMapMatchIpv6PrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpv6PrefixListLine) Prefix(org.batfish.datamodel.Prefix) SubRange(org.batfish.datamodel.SubRange)

Example 17 with LineAction

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);
}
Also used : LineAction(org.batfish.datamodel.LineAction)

Example 18 with LineAction

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));
}
Also used : LineAction(org.batfish.datamodel.LineAction) Route6FilterLine(org.batfish.datamodel.Route6FilterLine) BigInteger(java.math.BigInteger) SubRange(org.batfish.datamodel.SubRange) Ip6(org.batfish.datamodel.Ip6) Prefix6(org.batfish.datamodel.Prefix6)

Example 19 with LineAction

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));
}
Also used : LineAction(org.batfish.datamodel.LineAction) Ip(org.batfish.datamodel.Ip) Prefix(org.batfish.datamodel.Prefix) SubRange(org.batfish.datamodel.SubRange) RouteFilterLine(org.batfish.datamodel.RouteFilterLine)

Example 20 with LineAction

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))));
}
Also used : LineAction(org.batfish.datamodel.LineAction) Configuration(org.batfish.datamodel.Configuration) List(java.util.List) IpAccessList(org.batfish.datamodel.IpAccessList) ImmutableList(com.google.common.collect.ImmutableList) IpAccessList(org.batfish.datamodel.IpAccessList) Vrf(org.batfish.datamodel.Vrf) Topology(org.batfish.datamodel.Topology) Edge(org.batfish.datamodel.Edge) SynthesizerInputMatchers.hasArpTrueEdge(org.batfish.z3.matchers.SynthesizerInputMatchers.hasArpTrueEdge) Interface(org.batfish.datamodel.Interface) Test(org.junit.Test)

Aggregations

LineAction (org.batfish.datamodel.LineAction)21 SubRange (org.batfish.datamodel.SubRange)9 Prefix (org.batfish.datamodel.Prefix)5 ArrayList (java.util.ArrayList)4 TreeSet (java.util.TreeSet)4 IpAccessList (org.batfish.datamodel.IpAccessList)4 IpWildcard (org.batfish.datamodel.IpWildcard)4 ImmutableList (com.google.common.collect.ImmutableList)3 Ip (org.batfish.datamodel.Ip)3 Ip6 (org.batfish.datamodel.Ip6)3 IpAccessListLine (org.batfish.datamodel.IpAccessListLine)3 IpProtocol (org.batfish.datamodel.IpProtocol)3 RouteFilterLine (org.batfish.datamodel.RouteFilterLine)3 List (java.util.List)2 Ip6Wildcard (org.batfish.datamodel.Ip6Wildcard)2 Prefix6 (org.batfish.datamodel.Prefix6)2 RouteFilterList (org.batfish.datamodel.RouteFilterList)2 State (org.batfish.datamodel.State)2 TcpFlags (org.batfish.datamodel.TcpFlags)2 DestinationNetwork (org.batfish.datamodel.routing_policy.expr.DestinationNetwork)2