Java Code Examples for org.onosproject.net.flowobjective.NextObjective#meta()

The following examples show how to use org.onosproject.net.flowobjective.NextObjective#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: OfdpaGroupHandlerUtility.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * The purpose of this function is to verify if the hashed next
 * objective is supported by the current pipeline.
 *
 * @param nextObjective the hashed objective to verify
 * @return true if the hashed objective is supported. Otherwise false.
 */
public static boolean verifyHashedNextObjective(NextObjective nextObjective) {
    // if it is not hashed, there is something wrong;
    if (nextObjective.type() != HASHED) {
        return false;
    }
    // The case non supported is the MPLS-ECMP. For now, we try
    // to create a MPLS-ECMP for the transport of a VPWS. The
    // necessary info are contained in the meta selector. In particular
    // we are looking for the case of BoS==False;
    TrafficSelector metaSelector = nextObjective.meta();
    if (metaSelector != null && isNotMplsBos(metaSelector)) {
        return false;
    }

    return true;
}
 
Example 2
Source File: NextObjectiveTranslator.java    From onos with Apache License 2.0 5 votes vote down vote up
private void egressVlanPop(PortNumber outPort, NextObjective obj,
                           ObjectiveTranslation.Builder resultBuilder)
        throws FabricPipelinerException {

    if (obj.meta() == null) {
        throw new FabricPipelinerException(
                "Cannot process egress pop VLAN rule, NextObjective has null meta",
                ObjectiveError.BADPARAMS);
    }

    final VlanIdCriterion vlanIdCriterion = (VlanIdCriterion) criterion(
            obj.meta(), Criterion.Type.VLAN_VID);
    if (vlanIdCriterion == null) {
        throw new FabricPipelinerException(
                "Cannot process egress pop VLAN rule, missing VLAN_VID criterion " +
                        "in NextObjective meta",
                ObjectiveError.BADPARAMS);
    }

    final PiCriterion egressVlanTableMatch = PiCriterion.builder()
            .matchExact(FabricConstants.HDR_EG_PORT, outPort.toLong())
            .build();
    final TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchPi(egressVlanTableMatch)
            .matchVlanId(vlanIdCriterion.vlanId())
            .build();
    final TrafficTreatment treatment = DefaultTrafficTreatment.builder()
            .popVlan()
            .build();

    resultBuilder.addFlowRule(flowRule(
            obj, FabricConstants.FABRIC_EGRESS_EGRESS_NEXT_EGRESS_VLAN,
            selector, treatment));
}
 
Example 3
Source File: NextObjectiveCodec.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectNode encode(NextObjective nextObjective, CodecContext context) {

    checkNotNull(nextObjective, NOT_NULL_MESSAGE);

    final JsonCodec<TrafficTreatment> trafficTreatmentCodec = context.codec(TrafficTreatment.class);
    final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class);

    // encode common properties
    ObjectiveCodecHelper och = new ObjectiveCodecHelper();
    ObjectNode result = och.encode(nextObjective, context);

    // encode id
    result.put(ID, nextObjective.id());

    // encode type
    result.put(TYPE, nextObjective.type().toString());

    // encode operation
    result.put(OPERATION, nextObjective.op().toString());

    // encode treatments
    ArrayNode treatments = context.mapper().createArrayNode();
    nextObjective.next().forEach(t -> {
        ObjectNode treatmentJson = trafficTreatmentCodec.encode(t, context);
        treatments.add(treatmentJson);
    });
    result.set(TREATMENTS, treatments);

    // encode meta
    if (nextObjective.meta() != null) {
        ObjectNode trafficSelectorNode = trafficSelectorCodec.encode(nextObjective.meta(), context);
        result.set(META, trafficSelectorNode);
    }

    return result;
}