use of org.batfish.representation.juniper.Interface in project batfish by batfish.
the class ConfigurationBuilder method enterInt_named.
@Override
public void enterInt_named(Int_namedContext ctx) {
Interface currentInterface;
if (ctx.interface_id() == null) {
currentInterface = _configuration.getGlobalMasterInterface();
} else {
String ifaceName = getInterfaceName(ctx.interface_id());
Map<String, Interface> interfaces;
String nodeDevicePrefix = "";
if (ctx.interface_id().node == null) {
interfaces = _configuration.getInterfaces();
} else {
String nodeDeviceName = ctx.interface_id().node.getText();
nodeDevicePrefix = nodeDeviceName + ":";
NodeDevice nodeDevice = _configuration.getNodeDevices().computeIfAbsent(nodeDeviceName, NodeDevice::new);
interfaces = nodeDevice.getInterfaces();
}
currentInterface = interfaces.get(ifaceName);
if (currentInterface == null) {
String fullIfaceName = nodeDevicePrefix + ifaceName;
int definitionLine = ctx.interface_id().getStart().getLine();
currentInterface = new Interface(fullIfaceName, definitionLine);
currentInterface.setRoutingInstance(_currentRoutingInstance.getName());
currentInterface.setParent(_configuration.getGlobalMasterInterface());
interfaces.put(fullIfaceName, currentInterface);
}
}
_currentInterface = currentInterface;
_currentMasterInterface = currentInterface;
}
use of org.batfish.representation.juniper.Interface in project batfish by batfish.
the class ConfigurationBuilder method exitSeikg_external_interface.
@Override
public void exitSeikg_external_interface(Seikg_external_interfaceContext ctx) {
Interface_idContext interfaceId = ctx.interface_id();
int line = ctx.interface_id().getStart().getLine();
Interface iface = initInterface(interfaceId);
_currentIkeGateway.setExternalInterface(iface);
_currentIkeGateway.setExternalInterfaceLine(line);
}
use of org.batfish.representation.juniper.Interface in project batfish by batfish.
the class ConfigurationBuilder method exitPopsf_interface.
@Override
public void exitPopsf_interface(Popsf_interfaceContext ctx) {
String name = getInterfaceName(ctx.id);
int definitionLine = ctx.id.name.getLine();
String unit = null;
if (ctx.id.unit != null) {
unit = ctx.id.unit.getText();
definitionLine = ctx.id.unit.getLine();
}
String unitFullName = name + "." + unit;
Map<String, Interface> interfaces = _configuration.getInterfaces();
Interface iface = interfaces.get(name);
if (iface == null) {
iface = new Interface(name, definitionLine);
iface.setRoutingInstance(_currentRoutingInstance.getName());
interfaces.put(name, iface);
}
PsFrom from;
if (unit != null) {
Map<String, Interface> units = iface.getUnits();
iface = units.get(unitFullName);
if (iface == null) {
iface = new Interface(unitFullName, definitionLine);
iface.setRoutingInstance(_currentRoutingInstance.getName());
units.put(unitFullName, iface);
}
from = new PsFromInterface(unitFullName);
} else {
from = new PsFromInterface(name);
}
_currentPsTerm.getFroms().add(from);
}
use of org.batfish.representation.juniper.Interface in project batfish by batfish.
the class ConfigurationBuilder method initInterface.
private Interface initInterface(Interface_idContext id) {
String currentRoutingInstance = _currentRoutingInstance.getName();
Map<String, Interface> interfaces;
if (id.node != null) {
String nodeDeviceName = id.node.getText();
NodeDevice nodeDevice = _configuration.getNodeDevices().computeIfAbsent(nodeDeviceName, NodeDevice::new);
interfaces = nodeDevice.getInterfaces();
} else {
interfaces = _configuration.getInterfaces();
}
String name = getInterfaceName(id);
int definitionLine = id.name.getLine();
String unit = null;
if (id.unit != null) {
unit = id.unit.getText();
definitionLine = id.unit.getLine();
}
String unitFullName = name + "." + unit;
Interface iface = interfaces.get(name);
if (iface == null) {
iface = new Interface(name, definitionLine);
iface.setRoutingInstance(currentRoutingInstance);
interfaces.put(name, iface);
}
if (unit != null) {
Map<String, Interface> units = iface.getUnits();
iface = units.get(unitFullName);
if (iface == null) {
iface = new Interface(unitFullName, definitionLine);
iface.setRoutingInstance(currentRoutingInstance);
units.put(unitFullName, iface);
}
}
return iface;
}
use of org.batfish.representation.juniper.Interface in project batfish by batfish.
the class ConfigurationBuilder method exitFodg_interface.
@Override
public void exitFodg_interface(Fodg_interfaceContext ctx) {
if (ctx.ALL() != null) {
_currentDhcpRelayGroup.setAllInterfaces(true);
} else {
Interface iface = initInterface(ctx.interface_id());
String interfaceName = iface.getName();
_currentDhcpRelayGroup.getInterfaces().add(interfaceName);
}
}
Aggregations