Search in sources :

Example 26 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterNeighbor_flat_rb_stanza.

@Override
public void enterNeighbor_flat_rb_stanza(Neighbor_flat_rb_stanzaContext ctx) {
    // do no further processing for unsupported address families / containers
    if (_currentPeerGroup == _dummyPeerGroup) {
        pushPeer(_dummyPeerGroup);
        return;
    }
    BgpProcess proc = currentVrf().getBgpProcess();
    // we must create peer group if it does not exist and this is a remote_as
    // declaration
    boolean create = ctx.remote_as_bgp_tail() != null || ctx.inherit_peer_session_bgp_tail() != null;
    if (ctx.ip != null) {
        Ip ip = toIp(ctx.ip);
        _currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
        if (_currentIpPeerGroup == null) {
            if (create) {
                proc.addIpPeerGroup(ip);
                _currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
                pushPeer(_currentIpPeerGroup);
            } else {
                String message = "Ignoring reference to undeclared peer group: '" + ip + "'";
                _w.redFlag(message);
                pushPeer(_dummyPeerGroup);
            }
        } else {
            pushPeer(_currentIpPeerGroup);
        }
    } else if (ctx.ip6 != null) {
        Ip6 ip6 = toIp6(ctx.ip6);
        Ipv6BgpPeerGroup pg6 = proc.getIpv6PeerGroups().get(ip6);
        if (pg6 == null) {
            if (create) {
                proc.addIpv6PeerGroup(ip6);
                pg6 = proc.getIpv6PeerGroups().get(ip6);
                pushPeer(pg6);
            } else {
                String message = "Ignoring reference to undeclared peer group: '" + ip6 + "'";
                _w.redFlag(message);
                pushPeer(_dummyPeerGroup);
            }
        } else {
            pushPeer(pg6);
        }
        _currentIpv6PeerGroup = pg6;
    } else if (ctx.peergroup != null) {
        String name = ctx.peergroup.getText();
        int definitionLine = ctx.peergroup.getLine();
        _currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
        if (_currentNamedPeerGroup == null) {
            if (create || _configuration.getVendor() == ConfigurationFormat.ARISTA) {
                proc.addNamedPeerGroup(name, definitionLine);
                _currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
            } else {
                int line = ctx.peergroup.getLine();
                _configuration.getUndefinedPeerGroups().put(name, line);
                _w.redFlag("reference to undeclared peer group: '" + name + "'");
            }
        }
        pushPeer(_currentNamedPeerGroup);
    } else {
        throw new BatfishException("unknown neighbor type");
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) 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) Ip6(org.batfish.datamodel.Ip6)

Example 27 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterTemplate_peer_session_rb_stanza.

@Override
public void enterTemplate_peer_session_rb_stanza(Template_peer_session_rb_stanzaContext ctx) {
    String name = ctx.name.getText();
    int definitionLine = ctx.name.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 28 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterRouter_bgp_stanza.

@Override
public void enterRouter_bgp_stanza(Router_bgp_stanzaContext ctx) {
    int procNum = (ctx.procnum == null) ? 0 : toInteger(ctx.procnum);
    BgpProcess proc = new BgpProcess(_format, procNum);
    _configuration.getVrfs().get(Configuration.DEFAULT_VRF_NAME).setBgpProcess(proc);
    _dummyPeerGroup = new MasterBgpPeerGroup();
    pushPeer(proc.getMasterBgpPeerGroup());
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess) MasterBgpPeerGroup(org.batfish.representation.cisco.MasterBgpPeerGroup)

Example 29 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterTemplate_peer_policy_rb_stanza.

@Override
public void enterTemplate_peer_policy_rb_stanza(Template_peer_policy_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)

Example 30 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitRouter_id_bgp_tail.

@Override
public void exitRouter_id_bgp_tail(Router_id_bgp_tailContext ctx) {
    Ip routerId = toIp(ctx.routerid);
    BgpProcess proc = currentVrf().getBgpProcess();
    proc.setRouterId(routerId);
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess) Ip(org.batfish.datamodel.Ip) RoutePolicyNextHopIp(org.batfish.representation.cisco.RoutePolicyNextHopIp)

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