Java Code Examples for org.onosproject.net.flowobjective.FilteringObjective#meta()
The following examples show how to use
org.onosproject.net.flowobjective.FilteringObjective#meta() .
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: OfdpaPipelineUtility.java From onos with Apache License 2.0 | 6 votes |
/** * Determines if the filtering objective will be used for a pseudowire. * * @param filteringObjective the filtering objective * @return True if objective was created for a pseudowire, false otherwise. */ static boolean isPseudowire(FilteringObjective filteringObjective) { if (filteringObjective.meta() != null) { TrafficTreatment treatment = filteringObjective.meta(); for (Instruction instr : treatment.immediate()) { if (instr.type().equals(Instruction.Type.L2MODIFICATION)) { L2ModificationInstruction l2Instr = (L2ModificationInstruction) instr; if (l2Instr.subtype().equals(L2SubType.TUNNEL_ID)) { return true; } } } } return false; }
Example 2
Source File: OfdpaPipelineUtility.java From onos with Apache License 2.0 | 5 votes |
/** * Determines if the filtering objective will be used for double-tagged packets. * * @param fob Filtering objective * @return True if the objective was created for double-tagged packets, false otherwise. */ static boolean isDoubleTagged(FilteringObjective fob) { return fob.meta() != null && fob.meta().allInstructions().stream().anyMatch(inst -> inst.type() == L2MODIFICATION && ((L2ModificationInstruction) inst).subtype() == L2SubType.VLAN_POP) && fob.conditions().stream().anyMatch(criterion -> criterion.type() == VLAN_VID) && fob.conditions().stream().anyMatch(criterion -> criterion.type() == INNER_VLAN_VID); }
Example 3
Source File: FilteringObjectiveCodec.java From onos with Apache License 2.0 | 5 votes |
@Override public ObjectNode encode(FilteringObjective filteringObjective, CodecContext context) { checkNotNull(filteringObjective, NOT_NULL_MESSAGE); final JsonCodec<Criterion> criterionCodec = context.codec(Criterion.class); final JsonCodec<TrafficTreatment> trafficTreatmentCodec = context.codec(TrafficTreatment.class); // encode common properties ObjectiveCodecHelper och = new ObjectiveCodecHelper(); ObjectNode result = och.encode(filteringObjective, context); // encode id result.put(ID, filteringObjective.id()); // encode type result.put(TYPE, filteringObjective.type().toString()); // encode key if (filteringObjective.key() != null) { ObjectNode criterionNode = criterionCodec.encode(filteringObjective.key(), context); result.set(KEY, criterionNode); } // encode meta if (filteringObjective.meta() != null) { ObjectNode trafficTreatmentNode = trafficTreatmentCodec.encode(filteringObjective.meta(), context); result.set(META, trafficTreatmentNode); } // encode conditions ArrayNode conditions = context.mapper().createArrayNode(); filteringObjective.conditions().forEach(c -> { ObjectNode criterionJson = criterionCodec.encode(c, context); conditions.add(criterionJson); }); result.set(CONDITIONS, conditions); return result; }
Example 4
Source File: FilteringObjectiveTranslator.java From onos with Apache License 2.0 | 4 votes |
private boolean isDoubleTagged(FilteringObjective obj) { return obj.meta() != null && FabricUtils.l2Instruction(obj.meta(), L2ModificationInstruction.L2SubType.VLAN_POP) != null && FabricUtils.criterion(obj.conditions(), VLAN_VID) != null && FabricUtils.criterion(obj.conditions(), INNER_VLAN_VID) != null; }
Example 5
Source File: FilteringObjectiveTranslator.java From onos with Apache License 2.0 | 4 votes |
private void ingressPortVlanRule( FilteringObjective obj, Criterion inPortCriterion, VlanIdCriterion outerVlanCriterion, VlanIdCriterion innerVlanCriterion, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException { final boolean outerVlanValid = outerVlanCriterion != null && !outerVlanCriterion.vlanId().equals(VlanId.NONE); final boolean innerVlanValid = innerVlanCriterion != null && !innerVlanCriterion.vlanId().equals(VlanId.NONE); if (innerVlanValid && !capabilities.supportDoubleVlanTerm()) { throw new FabricPipelinerException( "Found 2 VLAN IDs, but the pipeline does not support double VLAN termination", ObjectiveError.UNSUPPORTED); } final PiCriterion piCriterion = PiCriterion.builder() .matchExact(FabricConstants.HDR_VLAN_IS_VALID, outerVlanValid ? ONE : ZERO) .build(); final TrafficSelector.Builder selector = DefaultTrafficSelector.builder() .add(inPortCriterion) .add(piCriterion); if (outerVlanValid) { selector.add(outerVlanCriterion); } if (innerVlanValid) { selector.add(innerVlanCriterion); } final TrafficTreatment treatment; if (obj.type().equals(FilteringObjective.Type.DENY)) { treatment = DefaultTrafficTreatment.builder() .piTableAction(DENY) .build(); } else { treatment = obj.meta() == null ? DefaultTrafficTreatment.emptyTreatment() : obj.meta(); } resultBuilder.addFlowRule(flowRule( obj, FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN, selector.build(), treatment)); }