Search in sources :

Example 6 with Interface

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;
}
Also used : PsFromInterface(org.batfish.representation.juniper.PsFromInterface) Interface(org.batfish.representation.juniper.Interface) NodeDevice(org.batfish.representation.juniper.NodeDevice)

Example 7 with Interface

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);
}
Also used : Interface_idContext(org.batfish.grammar.flatjuniper.FlatJuniperParser.Interface_idContext) PsFromInterface(org.batfish.representation.juniper.PsFromInterface) Interface(org.batfish.representation.juniper.Interface)

Example 8 with Interface

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);
}
Also used : PsFrom(org.batfish.representation.juniper.PsFrom) PsFromInterface(org.batfish.representation.juniper.PsFromInterface) PsFromInterface(org.batfish.representation.juniper.PsFromInterface) Interface(org.batfish.representation.juniper.Interface)

Example 9 with Interface

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;
}
Also used : PsFromInterface(org.batfish.representation.juniper.PsFromInterface) Interface(org.batfish.representation.juniper.Interface) NodeDevice(org.batfish.representation.juniper.NodeDevice)

Example 10 with Interface

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);
    }
}
Also used : PsFromInterface(org.batfish.representation.juniper.PsFromInterface) Interface(org.batfish.representation.juniper.Interface)

Aggregations

Interface (org.batfish.representation.juniper.Interface)10 PsFromInterface (org.batfish.representation.juniper.PsFromInterface)10 NodeDevice (org.batfish.representation.juniper.NodeDevice)2 BatfishException (org.batfish.common.BatfishException)1 Ip (org.batfish.datamodel.Ip)1 Interface_idContext (org.batfish.grammar.flatjuniper.FlatJuniperParser.Interface_idContext)1 FwThenNextIp (org.batfish.representation.juniper.FwThenNextIp)1 PsFrom (org.batfish.representation.juniper.PsFrom)1 PsThenNextHopIp (org.batfish.representation.juniper.PsThenNextHopIp)1