use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitRo_network.
@Override
public void exitRo_network(Ro_networkContext ctx) {
Ip address;
Ip wildcard;
if (ctx.prefix != null) {
Prefix prefix = Prefix.parse(ctx.prefix.getText());
address = prefix.getStartIp();
wildcard = prefix.getPrefixWildcard();
} else {
address = toIp(ctx.ip);
wildcard = toIp(ctx.wildcard);
}
if (_configuration.getVendor() == ConfigurationFormat.CISCO_ASA) {
wildcard = wildcard.inverted();
}
long area;
if (ctx.area_int != null) {
area = toLong(ctx.area_int);
} else if (ctx.area_ip != null) {
area = toIp(ctx.area_ip).asLong();
} else {
throw new BatfishException("bad area");
}
OspfWildcardNetwork network = new OspfWildcardNetwork(address, wildcard, area);
_currentOspfProcess.getWildcardNetworks().add(network);
}
use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterSs_host.
@Override
public void enterSs_host(Ss_hostContext ctx) {
String hostname;
if (ctx.ip4 != null) {
hostname = ctx.ip4.getText();
} else if (ctx.ip6 != null) {
hostname = ctx.ip6.getText();
} else if (ctx.host != null) {
hostname = ctx.host.getText();
} else {
throw new BatfishException("Invalid host");
}
Map<String, SnmpHost> hosts = _configuration.getSnmpServer().getHosts();
SnmpHost host = hosts.computeIfAbsent(hostname, SnmpHost::new);
_currentSnmpHost = host;
}
use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method enterS_line.
@Override
public void enterS_line(S_lineContext ctx) {
String lineType = ctx.line_type().getText();
if (lineType.equals("")) {
lineType = "<UNNAMED>";
}
String nameBase = lineType;
Integer slot1 = null;
Integer slot2 = null;
Integer port1 = null;
Integer port2 = null;
List<String> names = new ArrayList<>();
if (ctx.first != null) {
if (ctx.slot1 != null) {
slot1 = toInteger(ctx.slot1);
slot2 = slot1;
if (ctx.port1 != null) {
port1 = toInteger(ctx.port1);
port2 = port1;
}
}
int first = toInteger(ctx.first);
int last;
if (ctx.last != null) {
if (ctx.slot2 != null) {
slot2 = toInteger(ctx.slot2);
if (ctx.port2 != null) {
port2 = toInteger(ctx.port2);
}
}
last = toInteger(ctx.last);
} else {
last = first;
}
if (last < first) {
throw new BatfishException("Do not support decreasing line range: " + first + " " + last);
}
if (slot1 != null && port1 != null) {
for (int s = slot1; s <= slot2; s++) {
for (int p = port1; p <= port2; p++) {
for (int i = first; i <= last; i++) {
String name = nameBase + s + "/" + p + "/" + i;
names.add(name);
}
}
}
} else if (slot1 != null) {
for (int s = slot1; s <= slot2; s++) {
for (int i = first; i <= last; i++) {
String name = nameBase + s + "/" + i;
names.add(name);
}
}
} else {
for (int i = first; i <= last; i++) {
String name = nameBase + i;
names.add(name);
}
}
} else {
names.add(nameBase);
}
for (String name : names) {
if (_configuration.getCf().getLines().get(name) == null) {
Line line = new Line(name);
line.setLoginAuthentication(AaaAuthenticationLogin.DEFAULT_LIST_NAME);
_configuration.getCf().getLines().put(name, line);
}
}
_currentLineNames = names;
}
use of org.batfish.common.BatfishException in project batfish by batfish.
the class CiscoControlPlaneExtractor method exitNo_redistribute_connected_rb_stanza.
@Override
public void exitNo_redistribute_connected_rb_stanza(No_redistribute_connected_rb_stanzaContext ctx) {
BgpProcess proc = currentVrf().getBgpProcess();
// Intentional identity comparison
if (_currentPeerGroup == proc.getMasterBgpPeerGroup()) {
RoutingProtocol sourceProtocol = RoutingProtocol.CONNECTED;
proc.getRedistributionPolicies().remove(sourceProtocol);
} 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 enterCip_transform_set.
@Override
public void enterCip_transform_set(Cip_transform_setContext ctx) {
if (_currentIpsecTransformSet != null) {
throw new BatfishException("IpsecTransformSet should be null!");
}
_currentIpsecTransformSet = new IpsecTransformSet(ctx.name.getText(), ctx.getStart().getLine());
IpsecProposal proposal = _currentIpsecTransformSet.getProposal();
proposal.setEncryptionAlgorithm(toEncryptionAlgorithm(ctx.ipsec_encryption()));
proposal.setAuthenticationAlgorithm(toIpsecAuthenticationAlgorithm(ctx.ipsec_authentication()));
proposal.setProtocol(toProtocol(ctx.ipsec_authentication()));
}
Aggregations