use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterNeighbor_flat_rb_stanza.
@Override
public void enterNeighbor_flat_rb_stanza(Neighbor_flat_rb_stanzaContext ctx) {
// do no further processing for unsupported address families / containers
if (_currentPeerGroup == _dummyPeerGroup) {
pushPeer(_dummyPeerGroup);
return;
}
BgpProcess proc = currentVrf().getBgpProcess();
// we must create peer group if it does not exist and this is a remote_as
// declaration
boolean create = ctx.remote_as_bgp_tail() != null || ctx.inherit_peer_session_bgp_tail() != null;
if (ctx.ip != null) {
Ip ip = toIp(ctx.ip);
_currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
if (_currentIpPeerGroup == null) {
if (create) {
proc.addIpPeerGroup(ip);
_currentIpPeerGroup = proc.getIpPeerGroups().get(ip);
pushPeer(_currentIpPeerGroup);
} else {
String message = "Ignoring reference to undeclared peer group: '" + ip + "'";
_w.redFlag(message);
pushPeer(_dummyPeerGroup);
}
} else {
pushPeer(_currentIpPeerGroup);
}
} else if (ctx.ip6 != null) {
Ip6 ip6 = toIp6(ctx.ip6);
Ipv6BgpPeerGroup pg6 = proc.getIpv6PeerGroups().get(ip6);
if (pg6 == null) {
if (create) {
proc.addIpv6PeerGroup(ip6);
pg6 = proc.getIpv6PeerGroups().get(ip6);
pushPeer(pg6);
} else {
String message = "Ignoring reference to undeclared peer group: '" + ip6 + "'";
_w.redFlag(message);
pushPeer(_dummyPeerGroup);
}
} else {
pushPeer(pg6);
}
_currentIpv6PeerGroup = pg6;
} else if (ctx.peergroup != null) {
String name = ctx.peergroup.getText();
int definitionLine = ctx.peergroup.getLine();
_currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
if (_currentNamedPeerGroup == null) {
if (create || _configuration.getVendor() == ConfigurationFormat.ARISTA) {
proc.addNamedPeerGroup(name, definitionLine);
_currentNamedPeerGroup = proc.getNamedPeerGroups().get(name);
} else {
int line = ctx.peergroup.getLine();
_configuration.getUndefinedPeerGroups().put(name, line);
_w.redFlag("reference to undeclared peer group: '" + name + "'");
}
}
pushPeer(_currentNamedPeerGroup);
} else {
throw new BatfishException("unknown neighbor type");
}
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterTemplate_peer_session_rb_stanza.
@Override
public void enterTemplate_peer_session_rb_stanza(Template_peer_session_rb_stanzaContext ctx) {
String name = ctx.name.getText();
int definitionLine = ctx.name.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 enterRouter_bgp_stanza.
@Override
public void enterRouter_bgp_stanza(Router_bgp_stanzaContext ctx) {
int procNum = (ctx.procnum == null) ? 0 : toInteger(ctx.procnum);
BgpProcess proc = new BgpProcess(_format, procNum);
_configuration.getVrfs().get(Configuration.DEFAULT_VRF_NAME).setBgpProcess(proc);
_dummyPeerGroup = new MasterBgpPeerGroup();
pushPeer(proc.getMasterBgpPeerGroup());
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterTemplate_peer_policy_rb_stanza.
@Override
public void enterTemplate_peer_policy_rb_stanza(Template_peer_policy_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);
}
use of org.batfish.representation.cisco.BgpProcess in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitRouter_id_bgp_tail.
@Override
public void exitRouter_id_bgp_tail(Router_id_bgp_tailContext ctx) {
Ip routerId = toIp(ctx.routerid);
BgpProcess proc = currentVrf().getBgpProcess();
proc.setRouterId(routerId);
}
Aggregations