Java Code Examples for org.onosproject.net.flow.TrafficSelector#criteria()

The following examples show how to use org.onosproject.net.flow.TrafficSelector#criteria() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrafficSelectorCodec.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public ObjectNode encode(TrafficSelector selector, CodecContext context) {
    checkNotNull(selector, "Traffic selector cannot be null");

    final ObjectNode result = context.mapper().createObjectNode();
    final ArrayNode jsonCriteria = result.putArray(CRITERIA);

    if (selector.criteria() != null) {
        final JsonCodec<Criterion> criterionCodec =
                context.codec(Criterion.class);
        for (final Criterion criterion : selector.criteria()) {
            jsonCriteria.add(criterionCodec.encode(criterion, context));
        }
    }

    return result;
}
 
Example 2
Source File: HPPipelineV3800.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
    boolean unsupportedFeatures = false;

    for (Criterion criterion : selector.criteria()) {
        if (this.unsupportedCriteria.contains(criterion.type())) {
            log.warn("HP V3800 Driver - unsupported criteria {}", criterion.type());

            unsupportedFeatures = true;
        }
    }

    for (Instruction instruction : treatment.allInstructions()) {
        if (this.unsupportedInstructions.contains(instruction.type())) {
            log.warn("HP V3800 Driver - unsupported instruction {}", instruction.type());

            unsupportedFeatures = true;
        }

        if (instruction.type() == Instruction.Type.L2MODIFICATION) {
            if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3800 Driver - unsupported L2MODIFICATION instruction {}",
                        ((L2ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }

        if (instruction.type() == Instruction.Type.L3MODIFICATION) {
            if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3800 Driver - unsupported L3MODIFICATION instruction {}",
                        ((L3ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }
    }

    return unsupportedFeatures;
}
 
Example 3
Source File: HPPipelineV3500.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
    boolean unsupportedFeatures = false;

    for (Criterion criterion : selector.criteria()) {
        if (this.unsupportedCriteria.contains(criterion.type())) {
            log.warn("HP V3500 Driver - unsupported criteria {}", criterion.type());

            unsupportedFeatures = true;
        }
    }

    for (Instruction instruction : treatment.allInstructions()) {
        if (this.unsupportedInstructions.contains(instruction.type())) {
            log.warn("HP V3500 Driver - unsupported instruction {}", instruction.type());

            unsupportedFeatures = true;
        }

        if (instruction.type() == Instruction.Type.L2MODIFICATION) {
            if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3500 Driver - unsupported L2MODIFICATION instruction {}",
                        ((L2ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }

        if (instruction.type() == Instruction.Type.L3MODIFICATION) {
            if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3500 Driver - unsupported L3MODIFICATION instruction {}",
                        ((L3ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }
    }

    return unsupportedFeatures;
}
 
Example 4
Source File: HPPipelineV3.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
    boolean unsupportedFeatures = false;

    for (Criterion criterion : selector.criteria()) {
        if (this.unsupportedCriteria.contains(criterion.type())) {
            log.warn("HP V3 Driver - unsupported criteria {}", criterion.type());

            unsupportedFeatures = true;
        }
    }

    for (Instruction instruction : treatment.allInstructions()) {
        if (this.unsupportedInstructions.contains(instruction.type())) {
            log.warn("HP V3 Driver - unsupported instruction {}", instruction.type());

            unsupportedFeatures = true;
        }

        if (instruction.type() == Instruction.Type.L2MODIFICATION) {
            if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3 Driver - unsupported L2MODIFICATION instruction {}",
                        ((L2ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }

        if (instruction.type() == Instruction.Type.L3MODIFICATION) {
            if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
                log.warn("HP V3 Driver - unsupported L3MODIFICATION instruction {}",
                        ((L3ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }
    }

    return unsupportedFeatures;
}
 
Example 5
Source File: HPPipelineV2.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
    boolean unsupportedFeatures = false;

    for (Criterion criterion : selector.criteria()) {
        if (this.unsupportedCriteria.contains(criterion.type())) {
            log.warn("HP V2 Driver - unsupported criteria {}", criterion.type());

            unsupportedFeatures = true;
        }
    }

    for (Instruction instruction : treatment.allInstructions()) {
        if (this.unsupportedInstructions.contains(instruction.type())) {
            log.warn("HP V2 Driver - unsupported instruction {}", instruction.type());

            unsupportedFeatures = true;
        }

        if (instruction.type() == Instruction.Type.L2MODIFICATION) {
            if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                log.warn("HP V2 Driver - unsupported L2MODIFICATION instruction {}",
                        ((L2ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }

        if (instruction.type() == Instruction.Type.L3MODIFICATION) {
            if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
                log.warn("HP V2 Driver - unsupported L3MODIFICATION instruction {}",
                        ((L3ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }
    }

    return unsupportedFeatures;
}
 
Example 6
Source File: HPPipelineV1.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean checkUnSupportedFeatures(TrafficSelector selector, TrafficTreatment treatment) {
    boolean unsupportedFeatures = false;

    for (Criterion criterion : selector.criteria()) {
        if (this.unsupportedCriteria.contains(criterion.type())) {
            log.warn("HP V1 Driver - unsupported criteria {}", criterion.type());

            unsupportedFeatures = true;
        }
    }

    for (Instruction instruction : treatment.allInstructions()) {
        if (this.unsupportedInstructions.contains(instruction.type())) {
            log.warn("HP V1 Driver - unsupported instruction {}", instruction.type());

            unsupportedFeatures = true;
        }

        if (instruction.type() == Instruction.Type.L2MODIFICATION) {
            if (this.unsupportedL2mod.contains(((L2ModificationInstruction) instruction).subtype())) {
                log.warn("HP V1 Driver - unsupported L2MODIFICATION instruction {}",
                        ((L2ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }

        if (instruction.type() == Instruction.Type.L3MODIFICATION) {
            if (this.unsupportedL3mod.contains(((L3ModificationInstruction) instruction).subtype())) {
                log.warn("HP V1 Driver - unsupported L3MODIFICATION instruction {}",
                        ((L3ModificationInstruction) instruction).subtype());

                unsupportedFeatures = true;
            }
        }
    }

    return unsupportedFeatures;
}
 
Example 7
Source File: FlowObjectiveCompositionUtil.java    From onos with Apache License 2.0 5 votes vote down vote up
public static Set<Criterion.Type> getTypeSet(TrafficSelector trafficSelector) {
    Set<Criterion.Type> typeSet = new HashSet<>();
    for (Criterion criterion : trafficSelector.criteria()) {
        typeSet.add(criterion.type());
    }
    return typeSet;
}
 
Example 8
Source File: TrafficSelectorCodecTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests decoding of a traffic selector JSON object.
 */
@Test
public void testTrafficSelectorDecode() throws IOException {
    TrafficSelector selector = getSelector("TrafficSelector.json");

    Set<Criterion> criteria = selector.criteria();
    assertThat(criteria.size(), is(4));

    ImmutableSet<String> types = ImmutableSet.of("IN_PORT", "ETH_SRC", "ETH_DST", "ETH_TYPE");

    criteria.forEach(c -> assertThat(types.contains(c.type().name()), is(true)));
}