Java Code Examples for org.onosproject.net.pi.model.PiTableId#equals()

The following examples show how to use org.onosproject.net.pi.model.PiTableId#equals() . 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: FabricTreatmentInterpreter.java    From onos with Apache License 2.0 6 votes vote down vote up
static PiAction mapFilteringTreatment(TrafficTreatment treatment, PiTableId tableId)
        throws PiInterpreterException {

    if (!tableId.equals(FabricConstants.FABRIC_INGRESS_FILTERING_INGRESS_PORT_VLAN)) {
        // Mapping for other tables of the filtering block must be handled
        // in the pipeliner.
        tableException(tableId);
    }

    // VLAN_POP action is equivalent to the permit action (VLANs pop is done anyway)
    if (isNoAction(treatment) || isFilteringPopAction(treatment)) {
        // Permit action if table is ingress_port_vlan;
        return nop(tableId);
    }

    final ModVlanIdInstruction setVlanInst = (ModVlanIdInstruction) l2InstructionOrFail(
            treatment, VLAN_ID, tableId);
    return PiAction.builder()
            .withId(FabricConstants.FABRIC_INGRESS_FILTERING_PERMIT_WITH_INTERNAL_VLAN)
            .withParameter(new PiActionParam(
                    FabricConstants.VLAN_ID, setVlanInst.vlanId().toShort()))
            .build();
}
 
Example 2
Source File: FabricForwardingPipelineTest.java    From onos with Apache License 2.0 5 votes vote down vote up
private void testSpecificForward(PiTableId expectedTableId, TrafficSelector expectedSelector,
                                 TrafficSelector selector, Integer nextId) throws FabricPipelinerException {
    TrafficTreatment setNextIdTreatment;
    if (nextId == null) {
        // Ref: RoutingRulePopulator.java->revokeIpRuleForRouter

        setNextIdTreatment = DefaultTrafficTreatment.builder().
                piTableAction(PiAction.builder()
                                      .withId(FabricConstants.FABRIC_INGRESS_FORWARDING_NOP_ROUTING_V4)
                                      .build())
                .build();
    } else {
        PiActionParam nextIdParam = new PiActionParam(FabricConstants.NEXT_ID, nextId);
        PiAction.Builder setNextIdAction = PiAction.builder()
                .withParameter(nextIdParam);

        if (expectedTableId.equals(FabricConstants.FABRIC_INGRESS_FORWARDING_BRIDGING)) {
            setNextIdAction.withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID_BRIDGING);
        } else if (expectedTableId.equals(FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4)) {
            setNextIdAction.withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID_ROUTING_V4);
        } else if (expectedTableId.equals(FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V6)) {
            setNextIdAction.withId(FabricConstants.FABRIC_INGRESS_FORWARDING_SET_NEXT_ID_ROUTING_V6);
        }

        setNextIdTreatment = DefaultTrafficTreatment.builder()
                .piTableAction(setNextIdAction.build())
                .build();
    }

    testSpecificForward(expectedTableId, expectedSelector, selector, nextId, setNextIdTreatment);

}
 
Example 3
Source File: BasicInterpreterImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public PiAction mapTreatment(TrafficTreatment treatment, PiTableId piTableId)
        throws PiInterpreterException {
    if (treatment.allInstructions().isEmpty()) {
        // No actions means drop.
        return PiAction.builder().withId(INGRESS_TABLE0_CONTROL_DROP).build();
    } else if (treatment.allInstructions().size() > 1) {
        // We understand treatments with only 1 instruction.
        throw new PiInterpreterException("Treatment has multiple instructions");
    }

    Instruction instruction = treatment.allInstructions().get(0);
    switch (instruction.type()) {
        case OUTPUT:
            if (piTableId.equals(INGRESS_TABLE0_CONTROL_TABLE0)) {
                return outputPiAction((OutputInstruction) instruction, INGRESS_TABLE0_CONTROL_SET_EGRESS_PORT);
            } else if (piTableId.equals(INGRESS_WCMP_CONTROL_WCMP_TABLE)) {
                return outputPiAction((OutputInstruction) instruction, INGRESS_WCMP_CONTROL_SET_EGRESS_PORT);
            } else {
                throw new PiInterpreterException(
                        "Output instruction not supported in table " + piTableId);
            }
        case NOACTION:
            return PiAction.builder().withId(NO_ACTION).build();
        default:
            throw new PiInterpreterException(format(
                    "Instruction type '%s' not supported", instruction.type()));
    }
}