use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class Ip6Prefix method evaluate.
@Override
public Prefix6 evaluate(Environment env) {
Ip6 ip6 = _ip6.evaluate(env);
int prefixLength = _prefixLength.evaluate(env);
return new Prefix6(ip6, prefixLength);
}
use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitAggregate_address_rb_stanza.
@Override
public void exitAggregate_address_rb_stanza(Aggregate_address_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
boolean summaryOnly = ctx.summary_only != null;
boolean asSet = ctx.as_set != null;
if (ctx.network != null || ctx.prefix != null) {
// ipv4
Prefix prefix;
if (ctx.network != null) {
Ip network = toIp(ctx.network);
Ip subnet = toIp(ctx.subnet);
int prefixLength = subnet.numSubnetBits();
prefix = new Prefix(network, prefixLength);
} else {
// ctx.prefix != null
prefix = Prefix.parse(ctx.prefix.getText());
}
BgpAggregateIpv4Network net = new BgpAggregateIpv4Network(prefix);
net.setAsSet(asSet);
net.setSummaryOnly(summaryOnly);
if (ctx.mapname != null) {
String mapName = ctx.mapname.getText();
int mapLine = ctx.mapname.getStart().getLine();
net.setAttributeMap(mapName);
net.setAttributeMapLine(mapLine);
}
proc.getAggregateNetworks().put(prefix, net);
} else if (ctx.ipv6_prefix != null) {
// ipv6
Prefix6 prefix6 = new Prefix6(ctx.ipv6_prefix.getText());
BgpAggregateIpv6Network net = new BgpAggregateIpv6Network(prefix6);
net.setAsSet(asSet);
net.setSummaryOnly(summaryOnly);
if (ctx.mapname != null) {
String mapName = ctx.mapname.getText();
int mapLine = ctx.mapname.getStart().getLine();
net.setAttributeMap(mapName);
net.setAttributeMapLine(mapLine);
}
proc.getAggregateIpv6Networks().put(prefix6, net);
}
} else if (_currentIpPeerGroup != null || _currentIpv6PeerGroup != null || _currentDynamicIpPeerGroup != null || _currentDynamicIpv6PeerGroup != null || _currentNamedPeerGroup != null) {
throw new BatfishException("unexpected occurrence in peer group/neighbor context");
} else if (ctx.mapname != null) {
String map = ctx.mapname.getText();
int line = ctx.mapname.getStart().getLine();
_configuration.getBgpVrfAggregateAddressRouteMaps().add(map);
_configuration.referenceStructure(CiscoStructureType.ROUTE_MAP, map, CiscoStructureUsage.BGP_VRF_AGGREGATE_ROUTE_MAP, line);
}
}
use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class ConfigurationBuilder method enterPopsfrf_through.
@Override
public void enterPopsfrf_through(Popsfrf_throughContext ctx) {
if (_currentRouteFilterPrefix != null) {
// ipv4
Prefix throughPrefix = Prefix.parse(ctx.IP_PREFIX().getText());
Route4FilterLine line = new Route4FilterLineThrough(_currentRouteFilterPrefix, throughPrefix);
_currentRouteFilterLine = _currentRouteFilter.insertLine(line, Route4FilterLine.class);
} else if (_currentRoute6FilterPrefix != null) {
// ipv6
Prefix6 throughPrefix6 = new Prefix6(ctx.IPV6_PREFIX().getText());
Route6FilterLine line = new Route6FilterLineThrough(_currentRoute6FilterPrefix, throughPrefix6);
_currentRoute6FilterLine = _currentRouteFilter.insertLine(line, Route6FilterLine.class);
}
}
use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class ConfigurationBuilder method enterPopsf_route_filter.
@Override
public void enterPopsf_route_filter(Popsf_route_filterContext ctx) {
_currentRouteFilter = _termRouteFilters.get(_currentPsTerm);
if (_currentRouteFilter == null) {
String rfName = _currentPolicyStatement.getName() + ":" + _currentPsTerm.getName();
_currentRouteFilter = new RouteFilter(rfName);
_termRouteFilters.put(_currentPsTerm, _currentRouteFilter);
_configuration.getRouteFilters().put(rfName, _currentRouteFilter);
PsFromRouteFilter from = new PsFromRouteFilter(rfName);
_currentPsTerm.getFroms().add(from);
}
if (ctx.IP_PREFIX() != null) {
_currentRouteFilterPrefix = Prefix.parse(ctx.IP_PREFIX().getText());
_currentRouteFilter.setIpv4(true);
} else if (ctx.IPV6_PREFIX() != null) {
_currentRoute6FilterPrefix = new Prefix6(ctx.IPV6_PREFIX().getText());
_currentRouteFilter.setIpv6(true);
}
}
use of org.batfish.datamodel.Prefix6 in project batfish by batfish.
the class CiscoControlPlaneExtractor method toRoutePolicyPrefixSet.
private RoutePolicyPrefixSet toRoutePolicyPrefixSet(Rp_prefix_setContext ctx) {
if (ctx.name != null) {
// named
String name = ctx.name.getText();
int expressionLine = ctx.name.getStart().getLine();
return new RoutePolicyPrefixSetName(name, expressionLine);
} else {
// inline
PrefixSpace prefixSpace = new PrefixSpace();
Prefix6Space prefix6Space = new Prefix6Space();
boolean ipv6 = false;
for (Prefix_set_elemContext pctxt : ctx.elems) {
int lower;
int upper;
Prefix prefix = null;
Prefix6 prefix6 = null;
if (pctxt.prefix != null) {
prefix = Prefix.parse(pctxt.prefix.getText());
lower = prefix.getPrefixLength();
upper = Prefix.MAX_PREFIX_LENGTH;
} else if (pctxt.ipa != null) {
prefix = new Prefix(toIp(pctxt.ipa), Prefix.MAX_PREFIX_LENGTH);
lower = prefix.getPrefixLength();
upper = Prefix.MAX_PREFIX_LENGTH;
} else if (pctxt.ipv6a != null) {
prefix6 = new Prefix6(toIp6(pctxt.ipv6a), Prefix6.MAX_PREFIX_LENGTH);
lower = prefix6.getPrefixLength();
upper = Prefix6.MAX_PREFIX_LENGTH;
} else if (pctxt.ipv6_prefix != null) {
prefix6 = new Prefix6(pctxt.ipv6_prefix.getText());
lower = prefix6.getPrefixLength();
upper = Prefix6.MAX_PREFIX_LENGTH;
} else {
throw new BatfishException("Unhandled alternative");
}
if (pctxt.minpl != null) {
lower = toInteger(pctxt.minpl);
}
if (pctxt.maxpl != null) {
upper = toInteger(pctxt.maxpl);
}
if (pctxt.eqpl != null) {
lower = toInteger(pctxt.eqpl);
upper = lower;
}
if (prefix != null) {
prefixSpace.addPrefixRange(new PrefixRange(prefix, new SubRange(lower, upper)));
} else {
prefix6Space.addPrefix6Range(new Prefix6Range(prefix6, new SubRange(lower, upper)));
ipv6 = true;
}
}
if (ipv6) {
return new RoutePolicyInlinePrefix6Set(prefix6Space);
} else {
return new RoutePolicyInlinePrefixSet(prefixSpace);
}
}
}
Aggregations