Search in sources :

Example 1 with Interface

use of org.batfish.representation.cisco.Interface in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitIf_ip_nat_source.

@Override
public void exitIf_ip_nat_source(If_ip_nat_sourceContext ctx) {
    CiscoSourceNat nat = new CiscoSourceNat();
    if (ctx.acl != null) {
        String acl = ctx.acl.getText();
        int aclLine = ctx.acl.getStart().getLine();
        nat.setAclName(acl);
        nat.setAclNameLine(aclLine);
        _configuration.referenceStructure(CiscoStructureType.IP_ACCESS_LIST, acl, CiscoStructureUsage.IP_NAT_SOURCE_ACCESS_LIST, aclLine);
    }
    if (ctx.pool != null) {
        String pool = ctx.pool.getText();
        int poolLine = ctx.pool.getStart().getLine();
        nat.setNatPool(pool);
        nat.setNatPoolLine(poolLine);
        _configuration.referenceStructure(CiscoStructureType.NAT_POOL, pool, CiscoStructureUsage.IP_NAT_SOURCE_POOL, poolLine);
    }
    for (Interface iface : _currentInterfaces) {
        if (iface.getSourceNats() == null) {
            iface.setSourceNats(new ArrayList<>(1));
        }
        iface.getSourceNats().add(nat);
    }
}
Also used : CiscoSourceNat(org.batfish.representation.cisco.CiscoSourceNat) VrrpInterface(org.batfish.representation.cisco.VrrpInterface) Interface(org.batfish.representation.cisco.Interface)

Example 2 with Interface

use of org.batfish.representation.cisco.Interface in project batfish by batfish.

the class CiscoControlPlaneExtractor method enterIf_description.

@Override
public void enterIf_description(If_descriptionContext ctx) {
    Token descriptionToken = ctx.description_line().text;
    String description = descriptionToken != null ? descriptionToken.getText().trim() : "";
    for (Interface currentInterface : _currentInterfaces) {
        currentInterface.setDescription(description);
    }
}
Also used : Token(org.antlr.v4.runtime.Token) VrrpInterface(org.batfish.representation.cisco.VrrpInterface) Interface(org.batfish.representation.cisco.Interface)

Example 3 with Interface

use of org.batfish.representation.cisco.Interface in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitIf_ip_vrf_forwarding.

@Override
public void exitIf_ip_vrf_forwarding(If_ip_vrf_forwardingContext ctx) {
    String name = ctx.name.getText();
    for (Interface currentInterface : _currentInterfaces) {
        currentInterface.setVrf(name);
        initVrf(name);
    }
}
Also used : VrrpInterface(org.batfish.representation.cisco.VrrpInterface) Interface(org.batfish.representation.cisco.Interface)

Example 4 with Interface

use of org.batfish.representation.cisco.Interface in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitIf_switchport.

@Override
public void exitIf_switchport(If_switchportContext ctx) {
    if (ctx.NO() != null) {
        for (Interface iface : _currentInterfaces) {
            iface.setSwitchportMode(SwitchportMode.NONE);
            iface.setSwitchport(false);
        }
    } else {
        for (Interface iface : _currentInterfaces) {
            iface.setSwitchportMode(SwitchportMode.ACCESS);
            iface.setSwitchport(true);
        }
    }
}
Also used : VrrpInterface(org.batfish.representation.cisco.VrrpInterface) Interface(org.batfish.representation.cisco.Interface)

Example 5 with Interface

use of org.batfish.representation.cisco.Interface in project batfish by batfish.

the class CiscoControlPlaneExtractor method exitIfvrrp_authentication.

@Override
public void exitIfvrrp_authentication(Ifvrrp_authenticationContext ctx) {
    String hashedAuthenticationText = CommonUtil.sha256Digest(ctx.text.getText() + CommonUtil.salt());
    final int line = ctx.getStart().getLine();
    for (Interface iface : _currentInterfaces) {
        String ifaceName = iface.getName();
        VrrpGroup vrrpGroup = _configuration.getVrrpGroups().computeIfAbsent(ifaceName, n -> new VrrpInterface(ifaceName, line)).getVrrpGroups().computeIfAbsent(_currentVrrpGroupNum, VrrpGroup::new);
        vrrpGroup.setAuthenticationTextHash(hashedAuthenticationText);
    }
}
Also used : VrrpGroup(org.batfish.representation.cisco.VrrpGroup) VrrpInterface(org.batfish.representation.cisco.VrrpInterface) Interface(org.batfish.representation.cisco.Interface) VrrpInterface(org.batfish.representation.cisco.VrrpInterface)

Aggregations

Interface (org.batfish.representation.cisco.Interface)25 VrrpInterface (org.batfish.representation.cisco.VrrpInterface)25 Ip (org.batfish.datamodel.Ip)6 RoutePolicyNextHopIp (org.batfish.representation.cisco.RoutePolicyNextHopIp)6 VrrpGroup (org.batfish.representation.cisco.VrrpGroup)4 InterfaceAddress (org.batfish.datamodel.InterfaceAddress)3 Token (org.antlr.v4.runtime.Token)1 BatfishException (org.batfish.common.BatfishException)1 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)1 Prefix (org.batfish.datamodel.Prefix)1 CiscoSourceNat (org.batfish.representation.cisco.CiscoSourceNat)1 OspfNetwork (org.batfish.representation.cisco.OspfNetwork)1