Search in sources :

Example 11 with RoutingProtocol

use of org.batfish.datamodel.RoutingProtocol in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitSummary_address_is_stanza.

// @Override
// public void exitSubnet_bgp_tail(Subnet_bgp_tailContext ctx) {
// BgpProcess proc = currentVrf().getBgpProcess();
// if (ctx.IP_PREFIX() != null) {
// Prefix prefix = new Prefix(ctx.IP_PREFIX().getText());
// NamedBgpPeerGroup namedGroup = _currentNamedPeerGroup;
// namedGroup.addNeighborIpPrefix(prefix);
// DynamicIpBgpPeerGroup pg = proc.addDynamicIpPeerGroup(prefix);
// pg.setGroupName(namedGroup.getName());
// }
// else if (ctx.IPV6_PREFIX() != null) {
// Prefix6 prefix6 = new Prefix6(ctx.IPV6_PREFIX().getText());
// NamedBgpPeerGroup namedGroup = _currentNamedPeerGroup;
// namedGroup.addNeighborIpv6Prefix(prefix6);
// DynamicIpv6BgpPeerGroup pg = proc.addDynamicIpv6PeerGroup(prefix6);
// pg.setGroupName(namedGroup.getName());
// }
// }
// 
@Override
public void exitSummary_address_is_stanza(Summary_address_is_stanzaContext ctx) {
    Ip ip = toIp(ctx.ip);
    Ip mask = toIp(ctx.mask);
    Prefix prefix = new Prefix(ip, mask);
    RoutingProtocol sourceProtocol = RoutingProtocol.ISIS_L1;
    IsisRedistributionPolicy r = new IsisRedistributionPolicy(sourceProtocol);
    r.setSummaryPrefix(prefix);
    _currentIsisProcess.getRedistributionPolicies().put(sourceProtocol, r);
    if (ctx.metric != null) {
        int metric = toInteger(ctx.metric);
        r.setMetric(metric);
    }
    if (!ctx.LEVEL_1().isEmpty()) {
        r.setLevel(IsisLevel.LEVEL_1);
    } else if (!ctx.LEVEL_2().isEmpty()) {
        r.setLevel(IsisLevel.LEVEL_2);
    } else if (!ctx.LEVEL_1_2().isEmpty()) {
        r.setLevel(IsisLevel.LEVEL_1_2);
    } else {
        r.setLevel(IsisRedistributionPolicy.DEFAULT_LEVEL);
    }
}
Also used : RoutingProtocol(org.batfish.datamodel.RoutingProtocol) Ip(org.batfish.datamodel.Ip) RoutePolicyNextHopIp(org.batfish.representation.cisco.RoutePolicyNextHopIp) IsisRedistributionPolicy(org.batfish.representation.cisco.IsisRedistributionPolicy) Prefix(org.batfish.datamodel.Prefix)

Example 12 with RoutingProtocol

use of org.batfish.datamodel.RoutingProtocol in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitRo_redistribute_bgp.

@Override
public void exitRo_redistribute_bgp(Ro_redistribute_bgpContext ctx) {
    OspfProcess proc = _currentOspfProcess;
    RoutingProtocol sourceProtocol = RoutingProtocol.BGP;
    OspfRedistributionPolicy r = new OspfRedistributionPolicy(sourceProtocol);
    proc.getRedistributionPolicies().put(sourceProtocol, r);
    int as = toInteger(ctx.as);
    r.getSpecialAttributes().put(OspfRedistributionPolicy.BGP_AS, as);
    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.getLine();
        r.setRouteMap(map);
        r.setRouteMapLine(mapLine);
    }
    if (ctx.type != null) {
        int typeInt = toInteger(ctx.type);
        OspfMetricType type = OspfMetricType.fromInteger(typeInt);
        r.setOspfMetricType(type);
    } else {
        r.setOspfMetricType(OspfRedistributionPolicy.DEFAULT_METRIC_TYPE);
    }
    if (ctx.tag != null) {
        long tag = toLong(ctx.tag);
        r.setTag(tag);
    }
    r.setSubnets(ctx.subnets != null);
}
Also used : RoutingProtocol(org.batfish.datamodel.RoutingProtocol) OspfMetricType(org.batfish.datamodel.OspfMetricType) RoutePolicySetOspfMetricType(org.batfish.representation.cisco.RoutePolicySetOspfMetricType) OspfRedistributionPolicy(org.batfish.representation.cisco.OspfRedistributionPolicy) OspfProcess(org.batfish.representation.cisco.OspfProcess)

Example 13 with RoutingProtocol

use of org.batfish.datamodel.RoutingProtocol in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitRedistribute_connected_is_stanza.

@Override
public void exitRedistribute_connected_is_stanza(Redistribute_connected_is_stanzaContext ctx) {
    IsisProcess proc = currentVrf().getIsisProcess();
    RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED;
    IsisRedistributionPolicy r = new IsisRedistributionPolicy(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();
        r.setMap(map);
    }
    if (ctx.LEVEL_1() != null) {
        r.setLevel(IsisLevel.LEVEL_1);
    } else if (ctx.LEVEL_2() != null) {
        r.setLevel(IsisLevel.LEVEL_2);
    } else if (ctx.LEVEL_1_2() != null) {
        r.setLevel(IsisLevel.LEVEL_1_2);
    } else {
        r.setLevel(IsisRedistributionPolicy.DEFAULT_LEVEL);
    }
}
Also used : RoutingProtocol(org.batfish.datamodel.RoutingProtocol) IsisProcess(org.batfish.representation.cisco.IsisProcess) IsisRedistributionPolicy(org.batfish.representation.cisco.IsisRedistributionPolicy)

Example 14 with RoutingProtocol

use of org.batfish.datamodel.RoutingProtocol 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 15 with RoutingProtocol

use of org.batfish.datamodel.RoutingProtocol 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

RoutingProtocol (org.batfish.datamodel.RoutingProtocol)19 BatfishException (org.batfish.common.BatfishException)10 Ip (org.batfish.datamodel.Ip)7 Prefix (org.batfish.datamodel.Prefix)6 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)5 BgpProcess (org.batfish.representation.cisco.BgpProcess)5 TreeSet (java.util.TreeSet)4 BgpRedistributionPolicy (org.batfish.representation.cisco.BgpRedistributionPolicy)4 AsPath (org.batfish.datamodel.AsPath)3 BgpAdvertisement (org.batfish.datamodel.BgpAdvertisement)3 BgpAdvertisementType (org.batfish.datamodel.BgpAdvertisement.BgpAdvertisementType)3 BgpNeighbor (org.batfish.datamodel.BgpNeighbor)3 BgpRoute (org.batfish.datamodel.BgpRoute)3 OriginType (org.batfish.datamodel.OriginType)3 OspfMetricType (org.batfish.datamodel.OspfMetricType)3 Route (org.batfish.datamodel.Route)3 RouteBuilder (org.batfish.datamodel.RouteBuilder)3 RoutingPolicy (org.batfish.datamodel.routing_policy.RoutingPolicy)3 IsisRedistributionPolicy (org.batfish.representation.cisco.IsisRedistributionPolicy)3 AbstractRoute (org.batfish.datamodel.AbstractRoute)2