Search in sources :

Example 1 with BgpRedistributionPolicy

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

the class CiscoControlPlaneExtractor method exitRedistribute_ospf_bgp_tail.

@Override
public void exitRedistribute_ospf_bgp_tail(Redistribute_ospf_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.OSPF;
        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);
        }
        int procNum = toInteger(ctx.procnum);
        r.getSpecialAttributes().put(BgpRedistributionPolicy.OSPF_PROCESS_NUMBER, procNum);
    } 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 2 with BgpRedistributionPolicy

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

the class CiscoControlPlaneExtractor method exitRedistribute_static_bgp_tail.

@Override
public void exitRedistribute_static_bgp_tail(Redistribute_static_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        RoutingProtocol sourceProtocol = RoutingProtocol.STATIC;
        BgpRedistributionPolicy r = new BgpRedistributionPolicy(sourceProtocol);
        proc.getRedistributionPolicies().put(sourceProtocol, r);
        if (ctx.metric != null) {
            long metric = toLong(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 3 with BgpRedistributionPolicy

use of org.batfish.representation.cisco.BgpRedistributionPolicy 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 4 with BgpRedistributionPolicy

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

Aggregations

BatfishException (org.batfish.common.BatfishException)4 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)4 RoutingProtocol (org.batfish.datamodel.RoutingProtocol)4 BgpProcess (org.batfish.representation.cisco.BgpProcess)4 BgpRedistributionPolicy (org.batfish.representation.cisco.BgpRedistributionPolicy)4