use of org.batfish.representation.cisco.BgpProcess 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);
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitRedistribute_connected_bgp_tail.
@Override
public void exitRedistribute_connected_bgp_tail(Redistribute_connected_bgp_tailContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED;
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);
}
} 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 enterSession_group_rb_stanza.
@Override
public void enterSession_group_rb_stanza(Session_group_rb_stanzaContext ctx) {
String name = ctx.name.getText();
int definitionLine = ctx.name.getStart().getLine();
BgpProcess proc = currentVrf().getBgpProcess();
_currentPeerSession = proc.getPeerSessions().get(name);
if (_currentPeerSession == null) {
proc.addPeerSession(name, definitionLine);
_currentPeerSession = proc.getPeerSessions().get(name);
}
pushPeer(_currentPeerSession);
}
use of org.batfish.representation.cisco.BgpProcess 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);
}
}
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterTemplate_peer_rb_stanza.
@Override
public void enterTemplate_peer_rb_stanza(Template_peer_rb_stanzaContext ctx) {
String name = ctx.name.getText();
int definitionLine = ctx.name.getLine();
BgpProcess proc = currentVrf().getBgpProcess();
_currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
if (_currentNamedPeerGroup == null) {
proc.addNamedPeerGroup(name, definitionLine);
_currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
}
pushPeer(_currentNamedPeerGroup);
}
Aggregations