use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitPrefix_list_bgp_tail.
@Override
public void exitPrefix_list_bgp_tail(Prefix_list_bgp_tailContext ctx) {
String listName = ctx.list_name.getText();
int line = ctx.list_name.getLine();
if (ctx.IN() != null) {
_currentPeerGroup.setInboundPrefixList(listName);
_currentPeerGroup.setInboundPrefixListLine(line);
} else if (ctx.OUT() != null) {
_currentPeerGroup.setOutboundPrefixList(listName);
_currentPeerGroup.setOutboundPrefixListLine(line);
} else {
throw new BatfishException("bad direction");
}
}
use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNeighbor_block_inherit.
@Override
public void exitNeighbor_block_inherit(Neighbor_block_inheritContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
String groupName = ctx.name.getText();
if (_currentIpPeerGroup != null) {
_currentIpPeerGroup.setGroupName(groupName);
} else if (_currentIpv6PeerGroup != null) {
_currentIpv6PeerGroup.setGroupName(groupName);
} else if (_currentDynamicIpPeerGroup != null) {
_currentDynamicIpPeerGroup.setGroupName(groupName);
} else if (_currentDynamicIpv6PeerGroup != null) {
_currentDynamicIpv6PeerGroup.setGroupName(groupName);
} else if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
// Intentional identity comparison above
throw new BatfishException("Invalid peer context for inheritance");
} else {
todo(ctx, F_BGP_INHERIT_PEER_OTHER);
}
}
use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterStandard_ipv6_access_list_stanza.
@Override
public void enterStandard_ipv6_access_list_stanza(Standard_ipv6_access_list_stanzaContext ctx) {
String name;
int definitionLine;
if (ctx.name != null) {
name = ctx.name.getText();
definitionLine = ctx.name.getStart().getLine();
} else {
throw new BatfishException("Invalid standard access-list name");
}
StandardIpv6AccessList list = _configuration.getStandardIpv6Acls().computeIfAbsent(name, n -> new StandardIpv6AccessList(n, definitionLine));
_currentStandardIpv6Acl = list;
}
use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitRedistribute_static_bgp_tail.
@Override
public void exitRedistribute_static_bgp_tail(Redistribute_static_bgp_tailContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
RoutingProtocol sourceProtocol = RoutingProtocol.STATIC;
BgpRedistributionPolicy r = new BgpRedistributionPolicy(sourceProtocol);
proc.getRedistributionPolicies().put(sourceProtocol, r);
if (ctx.metric != null) {
long metric = toLong(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.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitL_transport.
@Override
public void exitL_transport(L_transportContext ctx) {
SortedSet<String> protocols = new TreeSet<>(ctx.prot.stream().map(c -> c.getText()).collect(Collectors.toSet()));
BiConsumer<Line, SortedSet<String>> setter;
if (ctx.INPUT() != null) {
setter = Line::setTransportInput;
} else if (ctx.OUTPUT() != null) {
setter = Line::setTransportOutput;
} else if (ctx.PREFERRED() != null) {
setter = Line::setTransportPreferred;
} else {
throw new BatfishException("Invalid or unsupported line transport type");
}
for (String currentName : _currentLineNames) {
Line line = _configuration.getCf().getLines().get(currentName);
setter.accept(line, protocols);
}
}
Aggregations