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");
}
}
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);
}
}
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);
}
}
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));
}
}
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);
}
}
Aggregations