Search in sources :

Example 1 with VLAN_POP

use of org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_POP in project onos by opennetworkinglab.

the class CorsaPipelineV39 method processNextTreatment.

@Override
protected CorsaTrafficTreatment processNextTreatment(TrafficTreatment treatment) {
    TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
    treatment.immediate().stream().filter(i -> {
        switch(i.type()) {
            case L2MODIFICATION:
                L2ModificationInstruction l2i = (L2ModificationInstruction) i;
                return l2i.subtype() == VLAN_ID || l2i.subtype() == VLAN_POP || l2i.subtype() == ETH_DST || l2i.subtype() == ETH_SRC;
            case OUTPUT:
                return true;
            default:
                return false;
        }
    }).forEach(i -> tb.add(i));
    TrafficTreatment t = tb.build();
    boolean isPresentModVlanId = false;
    boolean isPresentModEthSrc = false;
    boolean isPresentModEthDst = false;
    boolean isPresentOutpuPort = false;
    for (Instruction instruction : t.immediate()) {
        switch(instruction.type()) {
            case L2MODIFICATION:
                L2ModificationInstruction l2i = (L2ModificationInstruction) instruction;
                if (l2i instanceof L2ModificationInstruction.ModVlanIdInstruction) {
                    isPresentModVlanId = true;
                }
                if (l2i instanceof L2ModificationInstruction.ModEtherInstruction) {
                    L2ModificationInstruction.L2SubType subType = l2i.subtype();
                    if (subType.equals(L2ModificationInstruction.L2SubType.ETH_SRC)) {
                        isPresentModEthSrc = true;
                    } else if (subType.equals(L2ModificationInstruction.L2SubType.ETH_DST)) {
                        isPresentModEthDst = true;
                    }
                }
                break;
            case OUTPUT:
                isPresentOutpuPort = true;
                break;
            default:
        }
    }
    CorsaTrafficTreatmentType type = CorsaTrafficTreatmentType.ACTIONS;
    /**
     * These are the allowed groups for CorsaPipelinev39
     */
    if (isPresentModVlanId && isPresentModEthSrc && isPresentModEthDst && isPresentOutpuPort) {
        type = CorsaTrafficTreatmentType.GROUP;
    } else if ((!isPresentModVlanId && isPresentModEthSrc && isPresentModEthDst && isPresentOutpuPort) || (!isPresentModVlanId && !isPresentModEthSrc && isPresentModEthDst && isPresentOutpuPort) || (!isPresentModVlanId && !isPresentModEthSrc && !isPresentModEthDst && isPresentOutpuPort)) {
        type = CorsaTrafficTreatmentType.GROUP;
        TrafficTreatment.Builder tb2 = DefaultTrafficTreatment.builder(t);
        tb2.add(Instructions.popVlan());
        t = tb2.build();
    }
    CorsaTrafficTreatment corsaTreatment = new CorsaTrafficTreatment(type, t);
    return corsaTreatment;
}
Also used : VLAN_POP(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_POP) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) ETH_DST(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.ETH_DST) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ObjectiveError(org.onosproject.net.flowobjective.ObjectiveError) Ethernet(org.onlab.packet.Ethernet) TrafficSelector(org.onosproject.net.flow.TrafficSelector) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) VLAN_ID(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.VLAN_ID) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Instructions(org.onosproject.net.flow.instructions.Instructions) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Instruction(org.onosproject.net.flow.instructions.Instruction) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) ETH_SRC(org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.ETH_SRC) IPv4(org.onlab.packet.IPv4) Builder(org.onosproject.net.flow.FlowRule.Builder) FlowRule(org.onosproject.net.flow.FlowRule) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Collections(java.util.Collections) Builder(org.onosproject.net.flow.FlowRule.Builder) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Ethernet (org.onlab.packet.Ethernet)1 IPv4 (org.onlab.packet.IPv4)1 VlanId (org.onlab.packet.VlanId)1 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 FlowRule (org.onosproject.net.flow.FlowRule)1 Builder (org.onosproject.net.flow.FlowRule.Builder)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 Criterion (org.onosproject.net.flow.criteria.Criterion)1 IPCriterion (org.onosproject.net.flow.criteria.IPCriterion)1 IPProtocolCriterion (org.onosproject.net.flow.criteria.IPProtocolCriterion)1 Instruction (org.onosproject.net.flow.instructions.Instruction)1 Instructions (org.onosproject.net.flow.instructions.Instructions)1 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)1 ETH_DST (org.onosproject.net.flow.instructions.L2ModificationInstruction.L2SubType.ETH_DST)1