Search in sources :

Example 6 with BgpProcess

use of org.batfish.representation.cisco.BgpProcess 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 7 with BgpProcess

use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.

the class CiscoControlPlaneExtractor method enterAf_group_rb_stanza.

@Override
public void enterAf_group_rb_stanza(Af_group_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    String name = ctx.name.getText();
    int definitionLine = ctx.name.getStart().getLine();
    // String af = ctx.bgp_address_family().getText();
    NamedBgpPeerGroup afGroup = proc.getAfGroups().get(name);
    if (afGroup == null) {
        proc.addNamedPeerGroup(name, definitionLine);
        afGroup = proc.getNamedPeerGroups().get(name);
    }
    pushPeer(afGroup);
    _currentNamedPeerGroup = afGroup;
}
Also used : NamedBgpPeerGroup(org.batfish.representation.cisco.NamedBgpPeerGroup) BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 8 with BgpProcess

use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitNo_redistribute_connected_rb_stanza.

@Override
public void exitNo_redistribute_connected_rb_stanza(No_redistribute_connected_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED;
        proc.getRedistributionPolicies().remove(sourceProtocol);
    } 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)

Example 9 with BgpProcess

use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitNetwork_bgp_tail.

@Override
public void exitNetwork_bgp_tail(Network_bgp_tailContext ctx) {
    Prefix prefix;
    if (ctx.prefix != null) {
        prefix = Prefix.parse(ctx.prefix.getText());
    } else {
        Ip address = toIp(ctx.ip);
        Ip mask = (ctx.mask != null) ? toIp(ctx.mask) : address.getClassMask();
        int prefixLength = mask.numSubnetBits();
        prefix = new Prefix(address, prefixLength);
    }
    String map = null;
    Integer mapLine = null;
    if (ctx.mapname != null) {
        map = ctx.mapname.getText();
        mapLine = ctx.mapname.getStart().getLine();
    }
    BgpNetwork bgpNetwork = new BgpNetwork(prefix, map, mapLine);
    BgpProcess proc = currentVrf().getBgpProcess();
    proc.getIpNetworks().put(prefix, bgpNetwork);
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess) BgpNetwork(org.batfish.representation.cisco.BgpNetwork) Ip(org.batfish.datamodel.Ip) RoutePolicyNextHopIp(org.batfish.representation.cisco.RoutePolicyNextHopIp) Prefix(org.batfish.datamodel.Prefix)

Example 10 with BgpProcess

use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitAggregate_address_rb_stanza.

@Override
public void exitAggregate_address_rb_stanza(Aggregate_address_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        boolean summaryOnly = ctx.summary_only != null;
        boolean asSet = ctx.as_set != null;
        if (ctx.network != null || ctx.prefix != null) {
            // ipv4
            Prefix prefix;
            if (ctx.network != null) {
                Ip network = toIp(ctx.network);
                Ip subnet = toIp(ctx.subnet);
                int prefixLength = subnet.numSubnetBits();
                prefix = new Prefix(network, prefixLength);
            } else {
                // ctx.prefix != null
                prefix = Prefix.parse(ctx.prefix.getText());
            }
            BgpAggregateIpv4Network net = new BgpAggregateIpv4Network(prefix);
            net.setAsSet(asSet);
            net.setSummaryOnly(summaryOnly);
            if (ctx.mapname != null) {
                String mapName = ctx.mapname.getText();
                int mapLine = ctx.mapname.getStart().getLine();
                net.setAttributeMap(mapName);
                net.setAttributeMapLine(mapLine);
            }
            proc.getAggregateNetworks().put(prefix, net);
        } else if (ctx.ipv6_prefix != null) {
            // ipv6
            Prefix6 prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
            BgpAggregateIpv6Network net = new BgpAggregateIpv6Network(prefix6);
            net.setAsSet(asSet);
            net.setSummaryOnly(summaryOnly);
            if (ctx.mapname != null) {
                String mapName = ctx.mapname.getText();
                int mapLine = ctx.mapname.getStart().getLine();
                net.setAttributeMap(mapName);
                net.setAttributeMapLine(mapLine);
            }
            proc.getAggregateIpv6Networks().put(prefix6, net);
        }
    } else if (_currentIpPeerGroup != null || _currentIpv6PeerGroup != null || _currentDynamicIpPeerGroup != null || _currentDynamicIpv6PeerGroup != null || _currentNamedPeerGroup != null) {
        throw new BatfishException("unexpected occurrence in peer group/neighbor context");
    } else if (ctx.mapname != null) {
        String map = ctx.mapname.getText();
        int line = ctx.mapname.getStart().getLine();
        _configuration.getBgpVrfAggregateAddressRouteMaps().add(map);
        _configuration.referenceStructure(CiscoStructureType.ROUTE_MAP, map, CiscoStructureUsage.BGP_VRF_AGGREGATE_ROUTE_MAP, line);
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) BgpProcess(org.batfish.representation.cisco.BgpProcess) Ip(org.batfish.datamodel.Ip) RoutePolicyNextHopIp(org.batfish.representation.cisco.RoutePolicyNextHopIp) BgpAggregateIpv4Network(org.batfish.representation.cisco.BgpAggregateIpv4Network) Prefix(org.batfish.datamodel.Prefix) BgpAggregateIpv6Network(org.batfish.representation.cisco.BgpAggregateIpv6Network) Prefix6(org.batfish.datamodel.Prefix6)

Aggregations

BgpProcess (org.batfish.representation.cisco.BgpProcess)31 BatfishException (org.batfish.common.BatfishException)12 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)12 Ip (org.batfish.datamodel.Ip)8 RoutePolicyNextHopIp (org.batfish.representation.cisco.RoutePolicyNextHopIp)8 DynamicIpv6BgpPeerGroup (org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup)6 Ip6 (org.batfish.datamodel.Ip6)5 RoutingProtocol (org.batfish.datamodel.RoutingProtocol)5 Ipv6BgpPeerGroup (org.batfish.representation.cisco.Ipv6BgpPeerGroup)5 Prefix (org.batfish.datamodel.Prefix)4 Prefix6 (org.batfish.datamodel.Prefix6)4 BgpRedistributionPolicy (org.batfish.representation.cisco.BgpRedistributionPolicy)4 DynamicIpBgpPeerGroup (org.batfish.representation.cisco.DynamicIpBgpPeerGroup)4 IpBgpPeerGroup (org.batfish.representation.cisco.IpBgpPeerGroup)3 NamedBgpPeerGroup (org.batfish.representation.cisco.NamedBgpPeerGroup)3 BgpAggregateIpv4Network (org.batfish.representation.cisco.BgpAggregateIpv4Network)1 BgpAggregateIpv6Network (org.batfish.representation.cisco.BgpAggregateIpv6Network)1 BgpNetwork (org.batfish.representation.cisco.BgpNetwork)1 BgpNetwork6 (org.batfish.representation.cisco.BgpNetwork6)1 MasterBgpPeerGroup (org.batfish.representation.cisco.MasterBgpPeerGroup)1