Search in sources :

Example 6 with Prefix6

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

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

the class CiscoControlPlaneExtractor method enterNeighbor_block_rb_stanza.

@Override
public void enterNeighbor_block_rb_stanza(Neighbor_block_rb_stanzaContext ctx) {
    _currentBlockNeighborAddressFamilies.clear();
    _inBlockNeighbor = true;
    // do no further processing for unsupported address families / containers
    if (_currentPeerGroup == _dummyPeerGroup) {
        pushPeer(_dummyPeerGroup);
        return;
    }
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.ip_address != null) {
        Ip ip = toIp(ctx.ip_address);
        _currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
        if (_currentIpPeerGroup == null) {
            proc.addIpPeerGroup(ip);
            _currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
        } else {
            _w.redFlag("Duplicate IP peer group in neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(_currentIpPeerGroup);
    } else if (ctx.ip_prefix != null) {
        Prefix prefix = Prefix.parse(ctx.ip_prefix.getText());
        _currentDynamicIpPeerGroup = proc.getDynamicIpPeerGroups().get(prefix);
        if (_currentDynamicIpPeerGroup == null) {
            _currentDynamicIpPeerGroup = proc.addDynamicIpPeerGroup(prefix);
        } else {
            _w.redFlag("Duplicate DynamicIP peer group neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(_currentDynamicIpPeerGroup);
    } else if (ctx.ipv6_address != null) {
        Ip6 ip6 = toIp6(ctx.ipv6_address);
        Ipv6BgpPeerGroup pg = proc.getIpv6PeerGroups().get(ip6);
        if (pg == null) {
            proc.addIpv6PeerGroup(ip6);
            pg = proc.getIpv6PeerGroups().get(ip6);
        } else {
            _w.redFlag("Duplicate IPV6 peer group in neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(pg);
        _currentIpv6PeerGroup = pg;
    } else if (ctx.ipv6_prefix != null) {
        Prefix6 prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
        DynamicIpv6BgpPeerGroup pg = proc.getDynamicIpv6PeerGroups().get(prefix6);
        if (pg == null) {
            pg = proc.addDynamicIpv6PeerGroup(prefix6);
        } else {
            _w.redFlag("Duplicate Dynamic Ipv6 peer group neighbor config (line:" + ctx.start.getLine() + ")", DUPLICATE);
        }
        pushPeer(pg);
        _currentDynamicIpv6PeerGroup = pg;
    }
    if (ctx.REMOTE_AS() != null) {
        int remoteAs = toInteger(ctx.asnum);
        _currentPeerGroup.setRemoteAs(remoteAs);
    }
    // TODO: verify if this is correct for nexus
    _currentPeerGroup.setActive(true);
    _currentPeerGroup.setShutdown(false);
}
Also used : DynamicIpv6BgpPeerGroup(org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup) 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) Prefix(org.batfish.datamodel.Prefix) Ip6(org.batfish.datamodel.Ip6) Prefix6(org.batfish.datamodel.Prefix6)

Example 8 with Prefix6

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

the class CiscoControlPlaneExtractor method exitBgp_listen_range_rb_stanza.

@Override
public void exitBgp_listen_range_rb_stanza(Bgp_listen_range_rb_stanzaContext ctx) {
    String name = ctx.name.getText();
    int line = ctx.name.getStart().getLine();
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.IP_PREFIX() != null) {
        Prefix prefix = Prefix.parse(ctx.IP_PREFIX().getText());
        DynamicIpBgpPeerGroup pg = proc.addDynamicIpPeerGroup(prefix);
        pg.setGroupName(name);
        pg.setGroupNameLine(line);
        if (ctx.as != null) {
            int remoteAs = toInteger(ctx.as);
            pg.setRemoteAs(remoteAs);
        }
    } else if (ctx.IPV6_PREFIX() != null) {
        Prefix6 prefix6 = new Prefix6(ctx.IPV6_PREFIX().getText());
        DynamicIpv6BgpPeerGroup pg = proc.addDynamicIpv6PeerGroup(prefix6);
        pg.setGroupName(name);
        pg.setGroupNameLine(line);
        if (ctx.as != null) {
            int remoteAs = toInteger(ctx.as);
            pg.setRemoteAs(remoteAs);
        }
    }
}
Also used : DynamicIpv6BgpPeerGroup(org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup) BgpProcess(org.batfish.representation.cisco.BgpProcess) Prefix(org.batfish.datamodel.Prefix) DynamicIpBgpPeerGroup(org.batfish.representation.cisco.DynamicIpBgpPeerGroup) Prefix6(org.batfish.datamodel.Prefix6)

Example 9 with Prefix6

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

the class CiscoControlPlaneExtractor method exitIpv6_prefix_list_tail.

@Override
public void exitIpv6_prefix_list_tail(Ipv6_prefix_list_tailContext ctx) {
    LineAction action = toLineAction(ctx.action);
    Prefix6 prefix6 = new Prefix6(ctx.prefix6.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(action, prefix6, lengthRange);
    _currentPrefix6List.addLine(line);
}
Also used : LineAction(org.batfish.datamodel.LineAction) Prefix6ListLine(org.batfish.representation.cisco.Prefix6ListLine) SubRange(org.batfish.datamodel.SubRange) Prefix6(org.batfish.datamodel.Prefix6)

Example 10 with Prefix6

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

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