Search in sources :

Example 16 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitNetwork6_bgp_tail.

@Override
public void exitNetwork6_bgp_tail(Network6_bgp_tailContext ctx) {
    Prefix6 prefix6 = new Prefix6(ctx.prefix.getText());
    String map = null;
    Integer mapLine = null;
    if (ctx.mapname != null) {
        map = ctx.mapname.getText();
        mapLine = ctx.mapname.getStart().getLine();
    }
    BgpProcess proc = currentVrf().getBgpProcess();
    BgpNetwork6 bgpNetwork6 = new BgpNetwork6(prefix6, map, mapLine);
    proc.getIpv6Networks().put(prefix6, bgpNetwork6);
}
Also used : BgpNetwork6(org.batfish.representation.cisco.BgpNetwork6) BgpProcess(org.batfish.representation.cisco.BgpProcess) Prefix6(org.batfish.datamodel.Prefix6)

Example 17 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitNo_neighbor_shutdown_rb_stanza.

@Override
public void exitNo_neighbor_shutdown_rb_stanza(No_neighbor_shutdown_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.ip != null) {
        Ip ip = toIp(ctx.ip);
        IpBgpPeerGroup pg = proc.getIpPeerGroups().get(ip);
        // TODO: see if it is always ok to set active on 'no shutdown'
        if (pg == null) {
            String message = "ignoring attempt to shut down to undefined ip peer group: " + ip;
            _w.redFlag(message);
        } else {
            pg.setActive(true);
            pg.setShutdown(false);
        }
    } else if (ctx.ip6 != null) {
        Ip6 ip6 = toIp6(ctx.ip6);
        Ipv6BgpPeerGroup pg = proc.getIpv6PeerGroups().get(ip6);
        // TODO: see if it is always ok to set active on 'no shutdown'
        if (pg == null) {
            String message = "ignoring attempt to shut down undefined ipv6 peer group: " + ip6;
            _w.redFlag(message);
        } else {
            pg.setActive(true);
            pg.setShutdown(false);
        }
    } else if (ctx.peergroup != null) {
        _w.redFlag("'no shutdown' of  peer group unsupported");
    }
}
Also used : IpBgpPeerGroup(org.batfish.representation.cisco.IpBgpPeerGroup) DynamicIpBgpPeerGroup(org.batfish.representation.cisco.DynamicIpBgpPeerGroup) 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 18 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitRedistribute_rip_bgp_tail.

@Override
public void exitRedistribute_rip_bgp_tail(Redistribute_rip_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.RIP;
        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 19 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitMaximum_paths_bgp_tail.

@Override
public void exitMaximum_paths_bgp_tail(Maximum_paths_bgp_tailContext ctx) {
    int maximumPaths = toInteger(ctx.paths);
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.EBGP() != null) {
        proc.setMaximumPathsEbgp(maximumPaths);
    } else if (ctx.IBGP() != null) {
        proc.setMaximumPathsIbgp(maximumPaths);
    } else if (ctx.EIBGP() != null) {
        proc.setMaximumPathsEibgp(maximumPaths);
    } else {
        proc.setMaximumPaths(maximumPaths);
    }
}
Also used : BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 20 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitInherit_peer_session_bgp_tail.

@Override
public void exitInherit_peer_session_bgp_tail(Inherit_peer_session_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