Search in sources :

Example 1 with Prefix6

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

the class Ip6Prefix method evaluate.

@Override
public Prefix6 evaluate(Environment env) {
    Ip6 ip6 = _ip6.evaluate(env);
    int prefixLength = _prefixLength.evaluate(env);
    return new Prefix6(ip6, prefixLength);
}
Also used : Ip6(org.batfish.datamodel.Ip6) Prefix6(org.batfish.datamodel.Prefix6)

Example 2 with Prefix6

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

the class CiscoControlPlaneExtractor method exitAggregate_address_rb_stanza.

@Override
public void exitAggregate_address_rb_stanza(Aggregate_address_rb_stanzaContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    // Intentional identity comparison
    if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        boolean summaryOnly = ctx.summary_only != null;
        boolean asSet = ctx.as_set != null;
        if (ctx.network != null || ctx.prefix != null) {
            // ipv4
            Prefix prefix;
            if (ctx.network != null) {
                Ip network = toIp(ctx.network);
                Ip subnet = toIp(ctx.subnet);
                int prefixLength = subnet.numSubnetBits();
                prefix = new Prefix(network, prefixLength);
            } else {
                // ctx.prefix != null
                prefix = Prefix.parse(ctx.prefix.getText());
            }
            BgpAggregateIpv4Network net = new BgpAggregateIpv4Network(prefix);
            net.setAsSet(asSet);
            net.setSummaryOnly(summaryOnly);
            if (ctx.mapname != null) {
                String mapName = ctx.mapname.getText();
                int mapLine = ctx.mapname.getStart().getLine();
                net.setAttributeMap(mapName);
                net.setAttributeMapLine(mapLine);
            }
            proc.getAggregateNetworks().put(prefix, net);
        } else if (ctx.ipv6_prefix != null) {
            // ipv6
            Prefix6 prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
            BgpAggregateIpv6Network net = new BgpAggregateIpv6Network(prefix6);
            net.setAsSet(asSet);
            net.setSummaryOnly(summaryOnly);
            if (ctx.mapname != null) {
                String mapName = ctx.mapname.getText();
                int mapLine = ctx.mapname.getStart().getLine();
                net.setAttributeMap(mapName);
                net.setAttributeMapLine(mapLine);
            }
            proc.getAggregateIpv6Networks().put(prefix6, net);
        }
    } else if (_currentIpPeerGroup != null || _currentIpv6PeerGroup != null || _currentDynamicIpPeerGroup != null || _currentDynamicIpv6PeerGroup != null || _currentNamedPeerGroup != null) {
        throw new BatfishException("unexpected occurrence in peer group/neighbor context");
    } else if (ctx.mapname != null) {
        String map = ctx.mapname.getText();
        int line = ctx.mapname.getStart().getLine();
        _configuration.getBgpVrfAggregateAddressRouteMaps().add(map);
        _configuration.referenceStructure(CiscoStructureType.ROUTE_MAP, map, CiscoStructureUsage.BGP_VRF_AGGREGATE_ROUTE_MAP, line);
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) BgpProcess(org.batfish.representation.cisco.BgpProcess) Ip(org.batfish.datamodel.Ip) RoutePolicyNextHopIp(org.batfish.representation.cisco.RoutePolicyNextHopIp) BgpAggregateIpv4Network(org.batfish.representation.cisco.BgpAggregateIpv4Network) Prefix(org.batfish.datamodel.Prefix) BgpAggregateIpv6Network(org.batfish.representation.cisco.BgpAggregateIpv6Network) Prefix6(org.batfish.datamodel.Prefix6)

Example 3 with Prefix6

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

the class ConfigurationBuilder method enterPopsfrf_through.

@Override
public void enterPopsfrf_through(Popsfrf_throughContext ctx) {
    if (_currentRouteFilterPrefix != null) {
        // ipv4
        Prefix throughPrefix = Prefix.parse(ctx.IP_PREFIX().getText());
        Route4FilterLine line = new Route4FilterLineThrough(_currentRouteFilterPrefix, throughPrefix);
        _currentRouteFilterLine = _currentRouteFilter.insertLine(line, Route4FilterLine.class);
    } else if (_currentRoute6FilterPrefix != null) {
        // ipv6
        Prefix6 throughPrefix6 = new Prefix6(ctx.IPV6_PREFIX().getText());
        Route6FilterLine line = new Route6FilterLineThrough(_currentRoute6FilterPrefix, throughPrefix6);
        _currentRoute6FilterLine = _currentRouteFilter.insertLine(line, Route6FilterLine.class);
    }
}
Also used : Route6FilterLine(org.batfish.representation.juniper.Route6FilterLine) Route6FilterLineThrough(org.batfish.representation.juniper.Route6FilterLineThrough) Route4FilterLineThrough(org.batfish.representation.juniper.Route4FilterLineThrough) Route4FilterLine(org.batfish.representation.juniper.Route4FilterLine) Prefix(org.batfish.datamodel.Prefix) Prefix6(org.batfish.datamodel.Prefix6)

Example 4 with Prefix6

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

the class ConfigurationBuilder method enterPopsf_route_filter.

@Override
public void enterPopsf_route_filter(Popsf_route_filterContext ctx) {
    _currentRouteFilter = _termRouteFilters.get(_currentPsTerm);
    if (_currentRouteFilter == null) {
        String rfName = _currentPolicyStatement.getName() + ":" + _currentPsTerm.getName();
        _currentRouteFilter = new RouteFilter(rfName);
        _termRouteFilters.put(_currentPsTerm, _currentRouteFilter);
        _configuration.getRouteFilters().put(rfName, _currentRouteFilter);
        PsFromRouteFilter from = new PsFromRouteFilter(rfName);
        _currentPsTerm.getFroms().add(from);
    }
    if (ctx.IP_PREFIX() != null) {
        _currentRouteFilterPrefix = Prefix.parse(ctx.IP_PREFIX().getText());
        _currentRouteFilter.setIpv4(true);
    } else if (ctx.IPV6_PREFIX() != null) {
        _currentRoute6FilterPrefix = new Prefix6(ctx.IPV6_PREFIX().getText());
        _currentRouteFilter.setIpv6(true);
    }
}
Also used : PsFromRouteFilter(org.batfish.representation.juniper.PsFromRouteFilter) PsFromRouteFilter(org.batfish.representation.juniper.PsFromRouteFilter) RouteFilter(org.batfish.representation.juniper.RouteFilter) Prefix6(org.batfish.datamodel.Prefix6)

Example 5 with Prefix6

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

the class CiscoControlPlaneExtractor method toRoutePolicyPrefixSet.

private RoutePolicyPrefixSet toRoutePolicyPrefixSet(Rp_prefix_setContext ctx) {
    if (ctx.name != null) {
        // named
        String name = ctx.name.getText();
        int expressionLine = ctx.name.getStart().getLine();
        return new RoutePolicyPrefixSetName(name, expressionLine);
    } else {
        // inline
        PrefixSpace prefixSpace = new PrefixSpace();
        Prefix6Space prefix6Space = new Prefix6Space();
        boolean ipv6 = false;
        for (Prefix_set_elemContext pctxt : ctx.elems) {
            int lower;
            int upper;
            Prefix prefix = null;
            Prefix6 prefix6 = null;
            if (pctxt.prefix != null) {
                prefix = Prefix.parse(pctxt.prefix.getText());
                lower = prefix.getPrefixLength();
                upper = Prefix.MAX_PREFIX_LENGTH;
            } else if (pctxt.ipa != null) {
                prefix = new Prefix(toIp(pctxt.ipa), Prefix.MAX_PREFIX_LENGTH);
                lower = prefix.getPrefixLength();
                upper = Prefix.MAX_PREFIX_LENGTH;
            } else if (pctxt.ipv6a != null) {
                prefix6 = new Prefix6(toIp6(pctxt.ipv6a), Prefix6.MAX_PREFIX_LENGTH);
                lower = prefix6.getPrefixLength();
                upper = Prefix6.MAX_PREFIX_LENGTH;
            } else if (pctxt.ipv6_prefix != null) {
                prefix6 = new Prefix6(pctxt.ipv6_prefix.getText());
                lower = prefix6.getPrefixLength();
                upper = Prefix6.MAX_PREFIX_LENGTH;
            } else {
                throw new BatfishException("Unhandled alternative");
            }
            if (pctxt.minpl != null) {
                lower = toInteger(pctxt.minpl);
            }
            if (pctxt.maxpl != null) {
                upper = toInteger(pctxt.maxpl);
            }
            if (pctxt.eqpl != null) {
                lower = toInteger(pctxt.eqpl);
                upper = lower;
            }
            if (prefix != null) {
                prefixSpace.addPrefixRange(new PrefixRange(prefix, new SubRange(lower, upper)));
            } else {
                prefix6Space.addPrefix6Range(new Prefix6Range(prefix6, new SubRange(lower, upper)));
                ipv6 = true;
            }
        }
        if (ipv6) {
            return new RoutePolicyInlinePrefix6Set(prefix6Space);
        } else {
            return new RoutePolicyInlinePrefixSet(prefixSpace);
        }
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) PrefixRange(org.batfish.datamodel.PrefixRange) RoutePolicyInlinePrefixSet(org.batfish.representation.cisco.RoutePolicyInlinePrefixSet) RoutePolicyPrefixSetName(org.batfish.representation.cisco.RoutePolicyPrefixSetName) PrefixSpace(org.batfish.datamodel.PrefixSpace) Prefix_set_elemContext(org.batfish.grammar.cisco.CiscoParser.Prefix_set_elemContext) Prefix(org.batfish.datamodel.Prefix) Prefix6Space(org.batfish.datamodel.Prefix6Space) Prefix6Range(org.batfish.datamodel.Prefix6Range) RoutePolicyInlinePrefix6Set(org.batfish.representation.cisco.RoutePolicyInlinePrefix6Set) SubRange(org.batfish.datamodel.SubRange) Prefix6(org.batfish.datamodel.Prefix6)

Aggregations

Prefix6 (org.batfish.datamodel.Prefix6)14 Prefix (org.batfish.datamodel.Prefix)7 SubRange (org.batfish.datamodel.SubRange)6 Ip6 (org.batfish.datamodel.Ip6)4 BgpProcess (org.batfish.representation.cisco.BgpProcess)4 Ip (org.batfish.datamodel.Ip)3 BigInteger (java.math.BigInteger)2 BatfishException (org.batfish.common.BatfishException)2 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)2 LineAction (org.batfish.datamodel.LineAction)2 Prefix6Range (org.batfish.datamodel.Prefix6Range)2 Prefix6Space (org.batfish.datamodel.Prefix6Space)2 PrefixRange (org.batfish.datamodel.PrefixRange)2 PrefixSpace (org.batfish.datamodel.PrefixSpace)2 Route6FilterLine (org.batfish.datamodel.Route6FilterLine)2 DynamicIpv6BgpPeerGroup (org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup)2 Prefix6ListLine (org.batfish.representation.cisco.Prefix6ListLine)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1