Search in sources :

Example 1 with BgpAggregateIpv4Network

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

BatfishException (org.batfish.common.BatfishException)1 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)1 Ip (org.batfish.datamodel.Ip)1 Prefix (org.batfish.datamodel.Prefix)1 Prefix6 (org.batfish.datamodel.Prefix6)1 BgpAggregateIpv4Network (org.batfish.representation.cisco.BgpAggregateIpv4Network)1 BgpAggregateIpv6Network (org.batfish.representation.cisco.BgpAggregateIpv6Network)1 BgpProcess (org.batfish.representation.cisco.BgpProcess)1 RoutePolicyNextHopIp (org.batfish.representation.cisco.RoutePolicyNextHopIp)1