use of org.batfish.representation.cisco.Ipv6BgpPeerGroup 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.Ipv6BgpPeerGroup in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNo_neighbor_activate_rb_stanza.
@Override
public void exitNo_neighbor_activate_rb_stanza(No_neighbor_activate_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
if (ctx.ip != null) {
Ip ip = toIp(ctx.ip);
IpBgpPeerGroup pg = proc.getIpPeerGroups().get(ip);
if (pg == null) {
String message = "ignoring attempt to activate undefined ip peer group: " + ip;
_w.redFlag(message);
} else {
pg.setActive(false);
}
} else if (ctx.ip6 != null) {
Ip6 ip6 = toIp6(ctx.ip6);
Ipv6BgpPeerGroup pg = proc.getIpv6PeerGroups().get(ip6);
if (pg == null) {
String message = "ignoring attempt to activate undefined ipv6 peer group: " + ip6;
_w.redFlag(message);
} else {
pg.setActive(false);
}
} else if (ctx.peergroup != null) {
String pgName = ctx.peergroup.getText();
NamedBgpPeerGroup npg = proc.getNamedPeerGroups().get(pgName);
npg.setActive(false);
for (IpBgpPeerGroup ipg : proc.getIpPeerGroups().values()) {
String currentGroupName = ipg.getGroupName();
if (currentGroupName != null && currentGroupName.equals(pgName)) {
ipg.setActive(false);
}
}
for (Ipv6BgpPeerGroup ipg : proc.getIpv6PeerGroups().values()) {
String currentGroupName = ipg.getGroupName();
if (currentGroupName != null && currentGroupName.equals(pgName)) {
ipg.setActive(false);
}
}
}
}
use of org.batfish.representation.cisco.Ipv6BgpPeerGroup in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNo_neighbor_shutdown_rb_stanza.
@Override
public void exitNo_neighbor_shutdown_rb_stanza(No_neighbor_shutdown_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
if (ctx.ip != null) {
Ip ip = toIp(ctx.ip);
IpBgpPeerGroup pg = proc.getIpPeerGroups().get(ip);
// TODO: see if it is always ok to set active on 'no shutdown'
if (pg == null) {
String message = "ignoring attempt to shut down to undefined ip peer group: " + ip;
_w.redFlag(message);
} else {
pg.setActive(true);
pg.setShutdown(false);
}
} else if (ctx.ip6 != null) {
Ip6 ip6 = toIp6(ctx.ip6);
Ipv6BgpPeerGroup pg = proc.getIpv6PeerGroups().get(ip6);
// TODO: see if it is always ok to set active on 'no shutdown'
if (pg == null) {
String message = "ignoring attempt to shut down undefined ipv6 peer group: " + ip6;
_w.redFlag(message);
} else {
pg.setActive(true);
pg.setShutdown(false);
}
} else if (ctx.peergroup != null) {
_w.redFlag("'no shutdown' of peer group unsupported");
}
}
use of org.batfish.representation.cisco.Ipv6BgpPeerGroup 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.Ipv6BgpPeerGroup 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");
}
}
Aggregations