Search in sources :

Example 11 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterVrf_block_rb_stanza.

@Override
public void enterVrf_block_rb_stanza(Vrf_block_rb_stanzaContext ctx) {
    _currentVrf = ctx.name.getText();
    int procNum = _configuration.getVrfs().get(Configuration.DEFAULT_VRF_NAME).getBgpProcess().getName();
    BgpProcess proc = new BgpProcess(_format, procNum);
    currentVrf().setBgpProcess(proc);
    pushPeer(proc.getMasterBgpPeerGroup());
    _currentBlockNeighborAddressFamilies.clear();
    _inBlockNeighbor = false;
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 12 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitNo_neighbor_activate_rb_stanza.

@Override
public void exitNo_neighbor_activate_rb_stanza(No_neighbor_activate_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.ip != null) {
        Ip ip = toIp(ctx.ip);
        IpBgpPeerGroup pg = proc.getIpPeerGroups().get(ip);
        if (pg == null) {
            String message = "ignoring attempt to activate undefined ip peer group: " + ip;
            _w.redFlag(message);
        } else {
            pg.setActive(false);
        }
    } else if (ctx.ip6 != null) {
        Ip6 ip6 = toIp6(ctx.ip6);
        Ipv6BgpPeerGroup pg = proc.getIpv6PeerGroups().get(ip6);
        if (pg == null) {
            String message = "ignoring attempt to activate undefined ipv6 peer group: " + ip6;
            _w.redFlag(message);
        } else {
            pg.setActive(false);
        }
    } else if (ctx.peergroup != null) {
        String pgName = ctx.peergroup.getText();
        NamedBgpPeerGroup npg = proc.getNamedPeerGroups().get(pgName);
        npg.setActive(false);
        for (IpBgpPeerGroup ipg : proc.getIpPeerGroups().values()) {
            String currentGroupName = ipg.getGroupName();
            if (currentGroupName != null && currentGroupName.equals(pgName)) {
                ipg.setActive(false);
            }
        }
        for (Ipv6BgpPeerGroup ipg : proc.getIpv6PeerGroups().values()) {
            String currentGroupName = ipg.getGroupName();
            if (currentGroupName != null && currentGroupName.equals(pgName)) {
                ipg.setActive(false);
            }
        }
    }
}
Also used : IpBgpPeerGroup(org.batfish.representation.cisco.IpBgpPeerGroup) DynamicIpBgpPeerGroup(org.batfish.representation.cisco.DynamicIpBgpPeerGroup) NamedBgpPeerGroup(org.batfish.representation.cisco.NamedBgpPeerGroup) 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 13 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitAlways_compare_med_rb_stanza.

@Override
public void exitAlways_compare_med_rb_stanza(Always_compare_med_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    proc.setAlwaysCompareMed(true);
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 14 with BgpProcess

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

the class CiscoControlPlaneExtractor method enterNeighbor_group_rb_stanza.

@Override
public void enterNeighbor_group_rb_stanza(Neighbor_group_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    String name = ctx.name.getText();
    int definitionLine = ctx.name.getStart().getLine();
    _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 15 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitUse_session_group_bgp_tail.

@Override
public void exitUse_session_group_bgp_tail(Use_session_group_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    String groupName = ctx.name.getText();
    int line = ctx.name.getStart().getLine();
    if (_currentIpPeerGroup != null) {
        _currentIpPeerGroup.setPeerSession(groupName);
        _currentIpPeerGroup.setPeerSessionLine(line);
    } else if (_currentNamedPeerGroup != null) {
        _currentNamedPeerGroup.setPeerSession(groupName);
        _currentNamedPeerGroup.setPeerSessionLine(line);
    } else if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        // Intentional identity comparison above
        throw new BatfishException("Invalid peer context for inheritance");
    } else {
        todo(ctx, F_BGP_INHERIT_PEER_SESSION_OTHER);
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) 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