Search in sources :

Example 1 with BgpProcess

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

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

the class CiscoControlPlaneExtractor method exitPeer_group_assignment_rb_stanza.

@Override
public void exitPeer_group_assignment_rb_stanza(Peer_group_assignment_rb_stanzaContext ctx) {
    String peerGroupName = ctx.name.getText();
    int line = ctx.name.getStart().getLine();
    BgpProcess proc = currentVrf().getBgpProcess();
    if (ctx.address != null) {
        Ip address = toIp(ctx.address);
        IpBgpPeerGroup ipPeerGroup = proc.getIpPeerGroups().get(address);
        if (ipPeerGroup == null) {
            proc.addIpPeerGroup(address);
            ipPeerGroup = proc.getIpPeerGroups().get(address);
        }
        ipPeerGroup.setGroupName(peerGroupName);
        ipPeerGroup.setGroupNameLine(line);
    } else if (ctx.address6 != null) {
        Ip6 address6 = toIp6(ctx.address6);
        Ipv6BgpPeerGroup ipv6PeerGroup = proc.getIpv6PeerGroups().get(address6);
        if (ipv6PeerGroup == null) {
            proc.addIpv6PeerGroup(address6);
            ipv6PeerGroup = proc.getIpv6PeerGroups().get(address6);
        }
        ipv6PeerGroup.setGroupName(peerGroupName);
        ipv6PeerGroup.setGroupNameLine(line);
    }
}
Also used : IpBgpPeerGroup(org.batfish.representation.cisco.IpBgpPeerGroup) DynamicIpBgpPeerGroup(org.batfish.representation.cisco.DynamicIpBgpPeerGroup) 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) Ip6(org.batfish.datamodel.Ip6)

Example 3 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitInherit_peer_policy_bgp_tail.

@Override
public void exitInherit_peer_policy_bgp_tail(Inherit_peer_policy_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    String groupName = ctx.name.getText();
    int line = ctx.name.getStart().getLine();
    if (_currentIpPeerGroup != null) {
        _currentIpPeerGroup.setGroupName(groupName);
        _currentIpPeerGroup.setGroupNameLine(line);
    } else if (_currentNamedPeerGroup != null) {
        // May not hit this since parser for peer-policy does not have
        // recursion.
        _currentNamedPeerGroup.setGroupName(groupName);
        _currentNamedPeerGroup.setGroupNameLine(line);
    } else if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        // Intentional identity comparison above
        throw new BatfishException("Invalid peer context for inheritance");
    } else {
        todo(ctx, F_BGP_INHERIT_PEER_SESSION_OTHER);
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 4 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitRemote_as_bgp_tail.

@Override
public void exitRemote_as_bgp_tail(Remote_as_bgp_tailContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    int as = toInteger(ctx.as);
    if (_currentPeerGroup != proc.getMasterBgpPeerGroup()) {
        _currentPeerGroup.setRemoteAs(as);
    } else {
        throw new BatfishException("no peer or peer group in context: " + getLocation(ctx) + getFullText(ctx));
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) BgpProcess(org.batfish.representation.cisco.BgpProcess)

Example 5 with BgpProcess

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

the class CiscoControlPlaneExtractor method exitNeighbor_block_inherit.

@Override
public void exitNeighbor_block_inherit(Neighbor_block_inheritContext ctx) {
    BgpProcess proc = currentVrf().getBgpProcess();
    String groupName = ctx.name.getText();
    if (_currentIpPeerGroup != null) {
        _currentIpPeerGroup.setGroupName(groupName);
    } else if (_currentIpv6PeerGroup != null) {
        _currentIpv6PeerGroup.setGroupName(groupName);
    } else if (_currentDynamicIpPeerGroup != null) {
        _currentDynamicIpPeerGroup.setGroupName(groupName);
    } else if (_currentDynamicIpv6PeerGroup != null) {
        _currentDynamicIpv6PeerGroup.setGroupName(groupName);
    } else if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
        // Intentional identity comparison above
        throw new BatfishException("Invalid peer context for inheritance");
    } else {
        todo(ctx, F_BGP_INHERIT_PEER_OTHER);
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) RedFlagBatfishException(org.batfish.common.RedFlagBatfishException) BgpProcess(org.batfish.representation.cisco.BgpProcess)

Aggregations

BgpProcess (org.batfish.representation.cisco.BgpProcess)31 BatfishException (org.batfish.common.BatfishException)12 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)12 Ip (org.batfish.datamodel.Ip)8 RoutePolicyNextHopIp (org.batfish.representation.cisco.RoutePolicyNextHopIp)8 DynamicIpv6BgpPeerGroup (org.batfish.representation.cisco.DynamicIpv6BgpPeerGroup)6 Ip6 (org.batfish.datamodel.Ip6)5 RoutingProtocol (org.batfish.datamodel.RoutingProtocol)5 Ipv6BgpPeerGroup (org.batfish.representation.cisco.Ipv6BgpPeerGroup)5 Prefix (org.batfish.datamodel.Prefix)4 Prefix6 (org.batfish.datamodel.Prefix6)4 BgpRedistributionPolicy (org.batfish.representation.cisco.BgpRedistributionPolicy)4 DynamicIpBgpPeerGroup (org.batfish.representation.cisco.DynamicIpBgpPeerGroup)4 IpBgpPeerGroup (org.batfish.representation.cisco.IpBgpPeerGroup)3 NamedBgpPeerGroup (org.batfish.representation.cisco.NamedBgpPeerGroup)3 BgpAggregateIpv4Network (org.batfish.representation.cisco.BgpAggregateIpv4Network)1 BgpAggregateIpv6Network (org.batfish.representation.cisco.BgpAggregateIpv6Network)1 BgpNetwork (org.batfish.representation.cisco.BgpNetwork)1 BgpNetwork6 (org.batfish.representation.cisco.BgpNetwork6)1 MasterBgpPeerGroup (org.batfish.representation.cisco.MasterBgpPeerGroup)1