Search in sources :

Example 1 with PrefixListLine

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

the class CiscoControlPlaneExtractor method exitIp_prefix_list_tail.

@Override
public void exitIp_prefix_list_tail(Ip_prefix_list_tailContext ctx) {
    LineAction action = toLineAction(ctx.action);
    Prefix prefix = Prefix.parse(ctx.prefix.getText());
    int prefixLength = prefix.getPrefixLength();
    int minLen = prefixLength;
    int maxLen = prefixLength;
    if (ctx.minpl != null) {
        minLen = toInteger(ctx.minpl);
        maxLen = Prefix.MAX_PREFIX_LENGTH;
    }
    if (ctx.maxpl != null) {
        maxLen = toInteger(ctx.maxpl);
    }
    if (ctx.eqpl != null) {
        minLen = toInteger(ctx.eqpl);
        maxLen = toInteger(ctx.eqpl);
    }
    SubRange lengthRange = new SubRange(minLen, maxLen);
    PrefixListLine line = new PrefixListLine(action, prefix, lengthRange);
    _currentPrefixList.addLine(line);
}
Also used : LineAction(org.batfish.datamodel.LineAction) PrefixListLine(org.batfish.representation.cisco.PrefixListLine) RouteMapMatchIpPrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpPrefixListLine) RouteMapMatchIpv6PrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpv6PrefixListLine) Prefix(org.batfish.datamodel.Prefix) SubRange(org.batfish.datamodel.SubRange)

Example 2 with PrefixListLine

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

the class CiscoControlPlaneExtractor method exitPrefix_set_elem.

@Override
public void exitPrefix_set_elem(Prefix_set_elemContext ctx) {
    String name = _currentPrefixSetName;
    if (name != null) {
        if (ctx.ipa != null || ctx.prefix != null) {
            PrefixList pl = _configuration.getPrefixLists().computeIfAbsent(name, n -> new PrefixList(n, _currentPrefixSetDefinitionLine));
            Prefix prefix;
            if (ctx.ipa != null) {
                prefix = new Prefix(toIp(ctx.ipa), Prefix.MAX_PREFIX_LENGTH);
            } else {
                prefix = Prefix.parse(ctx.prefix.getText());
            }
            int prefixLength = prefix.getPrefixLength();
            int minLen = prefixLength;
            int maxLen = prefixLength;
            if (ctx.minpl != null) {
                minLen = toInteger(ctx.minpl);
                maxLen = Prefix.MAX_PREFIX_LENGTH;
            }
            if (ctx.maxpl != null) {
                maxLen = toInteger(ctx.maxpl);
            }
            if (ctx.eqpl != null) {
                minLen = toInteger(ctx.eqpl);
                maxLen = toInteger(ctx.eqpl);
            }
            SubRange lengthRange = new SubRange(minLen, maxLen);
            PrefixListLine line = new PrefixListLine(LineAction.ACCEPT, prefix, lengthRange);
            pl.addLine(line);
        } else {
            Prefix6List pl = _configuration.getPrefix6Lists().computeIfAbsent(name, n -> new Prefix6List(n, _currentPrefixSetDefinitionLine));
            Prefix6 prefix6;
            if (ctx.ipv6a != null) {
                prefix6 = new Prefix6(toIp6(ctx.ipv6a), Prefix6.MAX_PREFIX_LENGTH);
            } else {
                prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
            }
            int prefixLength = prefix6.getPrefixLength();
            int minLen = prefixLength;
            int maxLen = prefixLength;
            if (ctx.minpl != null) {
                minLen = toInteger(ctx.minpl);
                maxLen = Prefix6.MAX_PREFIX_LENGTH;
            }
            if (ctx.maxpl != null) {
                maxLen = toInteger(ctx.maxpl);
            }
            if (ctx.eqpl != null) {
                minLen = toInteger(ctx.eqpl);
                maxLen = toInteger(ctx.eqpl);
            }
            SubRange lengthRange = new SubRange(minLen, maxLen);
            Prefix6ListLine line = new Prefix6ListLine(LineAction.ACCEPT, prefix6, lengthRange);
            pl.addLine(line);
        }
    }
}
Also used : Prefix6ListLine(org.batfish.representation.cisco.Prefix6ListLine) Prefix6List(org.batfish.representation.cisco.Prefix6List) PrefixListLine(org.batfish.representation.cisco.PrefixListLine) RouteMapMatchIpPrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpPrefixListLine) RouteMapMatchIpv6PrefixListLine(org.batfish.representation.cisco.RouteMapMatchIpv6PrefixListLine) PrefixList(org.batfish.representation.cisco.PrefixList) Prefix(org.batfish.datamodel.Prefix) SubRange(org.batfish.datamodel.SubRange) Prefix6(org.batfish.datamodel.Prefix6)

Aggregations

Prefix (org.batfish.datamodel.Prefix)2 SubRange (org.batfish.datamodel.SubRange)2 PrefixListLine (org.batfish.representation.cisco.PrefixListLine)2 RouteMapMatchIpPrefixListLine (org.batfish.representation.cisco.RouteMapMatchIpPrefixListLine)2 RouteMapMatchIpv6PrefixListLine (org.batfish.representation.cisco.RouteMapMatchIpv6PrefixListLine)2 LineAction (org.batfish.datamodel.LineAction)1 Prefix6 (org.batfish.datamodel.Prefix6)1 Prefix6List (org.batfish.representation.cisco.Prefix6List)1 Prefix6ListLine (org.batfish.representation.cisco.Prefix6ListLine)1 PrefixList (org.batfish.representation.cisco.PrefixList)1