Search in sources :

Example 51 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitPrefix_list_bgp_tail.

@Override
public void exitPrefix_list_bgp_tail(Prefix_list_bgp_tailContext ctx) {
    String listName = ctx.list_name.getText();
    int line = ctx.list_name.getLine();
    if (ctx.IN() != null) {
        _currentPeerGroup.setInboundPrefixList(listName);
        _currentPeerGroup.setInboundPrefixListLine(line);
    } else if (ctx.OUT() != null) {
        _currentPeerGroup.setOutboundPrefixList(listName);
        _currentPeerGroup.setOutboundPrefixListLine(line);
    } else {
        throw new BatfishException("bad direction");
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException)

Example 52 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitNeighbor_block_inherit.

@Override
public void exitNeighbor_block_inherit(Neighbor_block_inheritContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    String groupName = ctx.name.getText();
    if (_currentIpPeerGroup != null) {
        _currentIpPeerGroup.setGroupName(groupName);
    } else if (_currentIpv6PeerGroup != null) {
        _currentIpv6PeerGroup.setGroupName(groupName);
    } else if (_currentDynamicIpPeerGroup != null) {
        _currentDynamicIpPeerGroup.setGroupName(groupName);
    } else if (_currentDynamicIpv6PeerGroup != null) {
        _currentDynamicIpv6PeerGroup.setGroupName(groupName);
    } else if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        // Intentional identity comparison above
        throw new BatfishException("Invalid peer context for inheritance");
    } else {
        todo(ctx, F_BGP_INHERIT_PEER_OTHER);
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 53 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method enterStandard_ipv6_access_list_stanza.

@Override
public void enterStandard_ipv6_access_list_stanza(Standard_ipv6_access_list_stanzaContext ctx) {
    String name;
    int definitionLine;
    if (ctx.name != null) {
        name = ctx.name.getText();
        definitionLine = ctx.name.getStart().getLine();
    } else {
        throw new BatfishException("Invalid standard access-list name");
    }
    StandardIpv6AccessList list = _configuration.getStandardIpv6Acls().computeIfAbsent(name, n -> new StandardIpv6AccessList(n, definitionLine));
    _currentStandardIpv6Acl = list;
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) StandardIpv6AccessList(org.batfish.representation.cisco.StandardIpv6AccessList)

Example 54 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitRedistribute_static_bgp_tail.

@Override
public void exitRedistribute_static_bgp_tail(Redistribute_static_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.STATIC;
        BgpRedistributionPolicy r = new BgpRedistributionPolicy(sourceProtocol);
        proc.getRedistributionPolicies().put(sourceProtocol, r);
        if (ctx.metric != null) {
            long metric = toLong(ctx.metric);
            r.setMetric(metric);
        }
        if (ctx.map != null) {
            String map = ctx.map.getText();
            int mapLine = ctx.map.getStart().getLine();
            r.setRouteMap(map);
            r.setRouteMapLine(mapLine);
        }
    } else if (_currentIpPeerGroup != null || _currentNamedPeerGroup != null) {
        throw new BatfishException("do not currently handle per-neighbor redistribution policies");
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) RoutingProtocol(org.batfish.datamodel.RoutingProtocol) BgpProcess(org.batfish.representation.cisco.BgpProcess) BgpRedistributionPolicy(org.batfish.representation.cisco.BgpRedistributionPolicy)

Example 55 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitL_transport.

@Override
public void exitL_transport(L_transportContext ctx) {
    SortedSet<String> protocols = new TreeSet<>(ctx.prot.stream().map(c -> c.getText()).collect(Collectors.toSet()));
    BiConsumer<Line, SortedSet<String>> setter;
    if (ctx.INPUT() != null) {
        setter = Line::setTransportInput;
    } else if (ctx.OUTPUT() != null) {
        setter = Line::setTransportOutput;
    } else if (ctx.PREFERRED() != null) {
        setter = Line::setTransportPreferred;
    } else {
        throw new BatfishException("Invalid or unsupported line transport type");
    }
    for (String currentName : _currentLineNames) {
        Line line = _configuration.getCf().getLines().get(currentName);
        setter.accept(line, protocols);
    }
}
Also used : RouteMapSetAsPathPrependLine(org.batfish.representation.cisco.RouteMapSetAsPathPrependLine) RouteMapMatchAsPathAccessListLine(org.batfish.representation.cisco.RouteMapMatchAsPathAccessListLine) RouteMapSetCommunityNoneLine(org.batfish.representation.cisco.RouteMapSetCommunityNoneLine) RouteMapSetCommunityLine(org.batfish.representation.cisco.RouteMapSetCommunityLine) RouteMapSetDeleteCommunityLine(org.batfish.representation.cisco.RouteMapSetDeleteCommunityLine) RouteMapSetLocalPreferenceLine(org.batfish.representation.cisco.RouteMapSetLocalPreferenceLine) PrefixListLine(org.batfish.representation.cisco.PrefixListLine) ExtendedIpv6AccessListLine(org.batfish.representation.cisco.ExtendedIpv6AccessListLine) RouteMapMatchCommunityListLine(org.batfish.representation.cisco.RouteMapMatchCommunityListLine) ExpandedCommunityListLine(org.batfish.representation.cisco.ExpandedCommunityListLine) RouteMapMatchIpv6AccessListLine(org.batfish.representation.cisco.RouteMapMatchIpv6AccessListLine) RouteMapMatchIpAccessListLine(org.batfish.representation.cisco.RouteMapMatchIpAccessListLine) Prefix6ListLine(org.batfish.representation.cisco.Prefix6ListLine) RouteMapMatchIpPrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpPrefixListLine) RouteMapMatchIpv6PrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpv6PrefixListLine) StandardAccessListLine(org.batfish.representation.cisco.StandardAccessListLine) RouteMapSetAdditiveCommunityLine(org.batfish.representation.cisco.RouteMapSetAdditiveCommunityLine) RouteMapSetAdditiveCommunityListLine(org.batfish.representation.cisco.RouteMapSetAdditiveCommunityListLine) RouteMapMatchTagLine(org.batfish.representation.cisco.RouteMapMatchTagLine) RouteMapSetCommunityListLine(org.batfish.representation.cisco.RouteMapSetCommunityListLine) Line(org.batfish.datamodel.vendor_family.cisco.Line) StandardCommunityListLine(org.batfish.representation.cisco.StandardCommunityListLine) RouteMapSetOriginTypeLine(org.batfish.representation.cisco.RouteMapSetOriginTypeLine) ExtendedAccessListLine(org.batfish.representation.cisco.ExtendedAccessListLine) RouteMapSetMetricLine(org.batfish.representation.cisco.RouteMapSetMetricLine) RouteMapSetNextHopLine(org.batfish.representation.cisco.RouteMapSetNextHopLine) StandardIpv6AccessListLine(org.batfish.representation.cisco.StandardIpv6AccessListLine) IpAsPathAccessListLine(org.batfish.representation.cisco.IpAsPathAccessListLine) RouteMapSetLine(org.batfish.representation.cisco.RouteMapSetLine) BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet)

Aggregations

BatfishException (org.batfish.common.BatfishException)264 IOException (java.io.IOException)61 Path (java.nio.file.Path)54 CleanBatfishException (org.batfish.common.CleanBatfishException)35 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)34 TreeMap (java.util.TreeMap)31 ArrayList (java.util.ArrayList)30 JSONException (org.codehaus.jettison.json.JSONException)30 Ip (org.batfish.datamodel.Ip)25 JSONObject (org.codehaus.jettison.json.JSONObject)25 Configuration (org.batfish.datamodel.Configuration)24 Map (java.util.Map)23 Prefix (org.batfish.datamodel.Prefix)22 HashMap (java.util.HashMap)20 HashSet (java.util.HashSet)20 TreeSet (java.util.TreeSet)20 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)18 Test (org.junit.Test)18 Set (java.util.Set)17 SortedMap (java.util.SortedMap)17