Search in sources :

Example 21 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterNeighbor_block_rb_stanza.

@Override
public void enterNeighbor_block_rb_stanza(Neighbor_block_rb_stanzaContext ctx) {
    _currentBlockNeighborAddressFamilies.clear();
    _inBlockNeighbor = true;
    // do no further processing for unsupported address families / containers
    if (_currentPeerGroup == _dummyPeerGroup) {
        pushPeer(_dummyPeerGroup);
        return;
    }
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.ip_address != null) {
        Ip ip = toIp(ctx.ip_address);
        _currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
        if (_currentIpPeerGroup == null) {
            proc.addIpPeerGroup(ip);
            _currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
        } else {
            _w.redFlag("Duplicate IP peer group in neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(_currentIpPeerGroup);
    } else if (ctx.ip_prefix != null) {
        Prefix prefix = Prefix.parse(ctx.ip_prefix.getText());
        _currentDynamicIpPeerGroup = proc.getDynamicIpPeerGroups().get(prefix);
        if (_currentDynamicIpPeerGroup == null) {
            _currentDynamicIpPeerGroup = proc.addDynamicIpPeerGroup(prefix);
        } else {
            _w.redFlag("Duplicate DynamicIP peer group neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(_currentDynamicIpPeerGroup);
    } else if (ctx.ipv6_address != null) {
        Ip6 ip6 = toIp6(ctx.ipv6_address);
        Ipv6BgpPeerGroup pg = proc.getIpv6PeerGroups().get(ip6);
        if (pg == null) {
            proc.addIpv6PeerGroup(ip6);
            pg = proc.getIpv6PeerGroups().get(ip6);
        } else {
            _w.redFlag("Duplicate IPV6 peer group in neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(pg);
        _currentIpv6PeerGroup = pg;
    } else if (ctx.ipv6_prefix != null) {
        Prefix6 prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
        DynamicIpv6BgpPeerGroup pg = proc.getDynamicIpv6PeerGroups().get(prefix6);
        if (pg == null) {
            pg = proc.addDynamicIpv6PeerGroup(prefix6);
        } else {
            _w.redFlag("Duplicate Dynamic Ipv6 peer group neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(pg);
        _currentDynamicIpv6PeerGroup = pg;
    }
    if (ctx.REMOTE_AS() != null) {
        int remoteAs = toInteger(ctx.asnum);
        _currentPeerGroup.setRemoteAs(remoteAs);
    }
    // TODO: verify if this is correct for nexus
    _currentPeerGroup.setActive(true);
    _currentPeerGroup.setShutdown(false);
}
Also used : DynamicIpv6BgpPeerGroup(org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup) BgpProcess(org.batfish.representation.cisco.BgpProcess) Ipv6BgpPeerGroup(org.batfish.representation.cisco.Ipv6BgpPeerGroup) DynamicIpv6BgpPeerGroup(org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup) Ip(org.batfish.datamodel.Ip) RoutePolicyNextHopIp(org.batfish.representation.cisco.RoutePolicyNextHopIp) Prefix(org.batfish.datamodel.Prefix) Ip6(org.batfish.datamodel.Ip6) Prefix6(org.batfish.datamodel.Prefix6)

Example 22 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitRedistribute_connected_bgp_tail.

@Override
public void exitRedistribute_connected_bgp_tail(Redistribute_connected_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED;
        BgpRedistributionPolicy r = new BgpRedistributionPolicy(sourceProtocol);
        proc.getRedistributionPolicies().put(sourceProtocol, r);
        if (ctx.metric != null) {
            int metric = toInteger(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 23 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterSession_group_rb_stanza.

@Override
public void enterSession_group_rb_stanza(Session_group_rb_stanzaContext ctx) {
    String name = ctx.name.getText();
    int definitionLine = ctx.name.getStart().getLine();
    BgpProcess proc = currentVrf().getBgpProcess();
    _currentPeerSession = proc.getPeerSessions().get(name);
    if (_currentPeerSession == null) {
        proc.addPeerSession(name, definitionLine);
        _currentPeerSession = proc.getPeerSessions().get(name);
    }
    pushPeer(_currentPeerSession);
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 24 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitBgp_listen_range_rb_stanza.

@Override
public void exitBgp_listen_range_rb_stanza(Bgp_listen_range_rb_stanzaContext ctx) {
    String name = ctx.name.getText();
    int line = ctx.name.getStart().getLine();
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.IP_PREFIX() != null) {
        Prefix prefix = Prefix.parse(ctx.IP_PREFIX().getText());
        DynamicIpBgpPeerGroup pg = proc.addDynamicIpPeerGroup(prefix);
        pg.setGroupName(name);
        pg.setGroupNameLine(line);
        if (ctx.as != null) {
            int remoteAs = toInteger(ctx.as);
            pg.setRemoteAs(remoteAs);
        }
    } else if (ctx.IPV6_PREFIX() != null) {
        Prefix6 prefix6 = new Prefix6(ctx.IPV6_PREFIX().getText());
        DynamicIpv6BgpPeerGroup pg = proc.addDynamicIpv6PeerGroup(prefix6);
        pg.setGroupName(name);
        pg.setGroupNameLine(line);
        if (ctx.as != null) {
            int remoteAs = toInteger(ctx.as);
            pg.setRemoteAs(remoteAs);
        }
    }
}
Also used : DynamicIpv6BgpPeerGroup(org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup) BgpProcess(org.batfish.representation.cisco.BgpProcess) Prefix(org.batfish.datamodel.Prefix) DynamicIpBgpPeerGroup(org.batfish.representation.cisco.DynamicIpBgpPeerGroup) Prefix6(org.batfish.datamodel.Prefix6)

Example 25 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterTemplate_peer_rb_stanza.

@Override
public void enterTemplate_peer_rb_stanza(Template_peer_rb_stanzaContext ctx) {
    String name = ctx.name.getText();
    int definitionLine = ctx.name.getLine();
    BgpProcess proc = currentVrf().getBgpProcess();
    _currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
    if (_currentNamedPeerGroup == null) {
        proc.addNamedPeerGroup(name, definitionLine);
        _currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
    }
    pushPeer(_currentNamedPeerGroup);
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess)

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