use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNetwork6_bgp_tail.
@Override
public void exitNetwork6_bgp_tail(Network6_bgp_tailContext ctx) {
Prefix6 prefix6 = new Prefix6(ctx.prefix.getText());
String map = null;
Integer mapLine = null;
if (ctx.mapname != null) {
map = ctx.mapname.getText();
mapLine = ctx.mapname.getStart().getLine();
}
BgpProcess proc = currentVrf().getBgpProcess();
BgpNetwork6 bgpNetwork6 = new BgpNetwork6(prefix6, map, mapLine);
proc.getIpv6Networks().put(prefix6, bgpNetwork6);
}
use of org.batfish.datamodel.Prefix6 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.datamodel.Prefix6 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.datamodel.Prefix6 in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitIpv6_prefix_list_tail.
@Override
public void exitIpv6_prefix_list_tail(Ipv6_prefix_list_tailContext ctx) {
LineAction action = toLineAction(ctx.action);
Prefix6 prefix6 = new Prefix6(ctx.prefix6.getText());
int prefixLength = prefix6.getPrefixLength();
int minLen = prefixLength;
int maxLen = prefixLength;
if (ctx.minpl != null) {
minLen = toInteger(ctx.minpl);
maxLen = Prefix6.MAX_PREFIX_LENGTH;
}
if (ctx.maxpl != null) {
maxLen = toInteger(ctx.maxpl);
}
if (ctx.eqpl != null) {
minLen = toInteger(ctx.eqpl);
maxLen = toInteger(ctx.eqpl);
}
SubRange lengthRange = new SubRange(minLen, maxLen);
Prefix6ListLine line = new Prefix6ListLine(action, prefix6, lengthRange);
_currentPrefix6List.addLine(line);
}
use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitPrefix_set_elem.
@Override
public void exitPrefix_set_elem(Prefix_set_elemContext ctx) {
String name = _currentPrefixSetName;
if (name != null) {
if (ctx.ipa != null || ctx.prefix != null) {
PrefixList pl = _configuration.getPrefixLists().computeIfAbsent(name, n -> new PrefixList(n, _currentPrefixSetDefinitionLine));
Prefix prefix;
if (ctx.ipa != null) {
prefix = new Prefix(toIp(ctx.ipa), Prefix.MAX_PREFIX_LENGTH);
} else {
prefix = Prefix.parse(ctx.prefix.getText());
}
int prefixLength = prefix.getPrefixLength();
int minLen = prefixLength;
int maxLen = prefixLength;
if (ctx.minpl != null) {
minLen = toInteger(ctx.minpl);
maxLen = Prefix.MAX_PREFIX_LENGTH;
}
if (ctx.maxpl != null) {
maxLen = toInteger(ctx.maxpl);
}
if (ctx.eqpl != null) {
minLen = toInteger(ctx.eqpl);
maxLen = toInteger(ctx.eqpl);
}
SubRange lengthRange = new SubRange(minLen, maxLen);
PrefixListLine line = new PrefixListLine(LineAction.ACCEPT, prefix, lengthRange);
pl.addLine(line);
} else {
Prefix6List pl = _configuration.getPrefix6Lists().computeIfAbsent(name, n -> new Prefix6List(n, _currentPrefixSetDefinitionLine));
Prefix6 prefix6;
if (ctx.ipv6a != null) {
prefix6 = new Prefix6(toIp6(ctx.ipv6a), Prefix6.MAX_PREFIX_LENGTH);
} else {
prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
}
int prefixLength = prefix6.getPrefixLength();
int minLen = prefixLength;
int maxLen = prefixLength;
if (ctx.minpl != null) {
minLen = toInteger(ctx.minpl);
maxLen = Prefix6.MAX_PREFIX_LENGTH;
}
if (ctx.maxpl != null) {
maxLen = toInteger(ctx.maxpl);
}
if (ctx.eqpl != null) {
minLen = toInteger(ctx.eqpl);
maxLen = toInteger(ctx.eqpl);
}
SubRange lengthRange = new SubRange(minLen, maxLen);
Prefix6ListLine line = new Prefix6ListLine(LineAction.ACCEPT, prefix6, lengthRange);
pl.addLine(line);
}
}
}
Aggregations