Search in sources :

Example 1 with OFActionEnqueue

use of org.projectfloodlight.openflow.protocol.action.OFActionEnqueue in project onos by opennetworkinglab.

the class FlowEntryBuilder method configureTreatmentBuilder.

/**
 * Configures traffic treatment builder with a given collection of actions.
 *
 * @param actions a set of OpenFlow actions
 * @param builder traffic treatment builder
 * @param driverHandler driver handler
 * @param deviceId device identifier
 * @return configured traffic treatment builder
 */
public static TrafficTreatment.Builder configureTreatmentBuilder(List<OFAction> actions, TrafficTreatment.Builder builder, DriverHandler driverHandler, DeviceId deviceId) {
    ExtensionTreatmentInterpreter interpreter;
    if (driverHandler.hasBehaviour(ExtensionTreatmentInterpreter.class)) {
        interpreter = driverHandler.behaviour(ExtensionTreatmentInterpreter.class);
    } else {
        interpreter = null;
    }
    for (OFAction act : actions) {
        switch(act.getType()) {
            case OUTPUT:
                OFActionOutput out = (OFActionOutput) act;
                builder.setOutput(PortNumber.portNumber(out.getPort().getPortNumber()));
                break;
            case SET_VLAN_VID:
                OFActionSetVlanVid vlan = (OFActionSetVlanVid) act;
                builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan()));
                break;
            case SET_VLAN_PCP:
                OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act;
                builder.setVlanPcp(pcp.getVlanPcp().getValue());
                break;
            case SET_DL_DST:
                OFActionSetDlDst dldst = (OFActionSetDlDst) act;
                builder.setEthDst(MacAddress.valueOf(dldst.getDlAddr().getLong()));
                break;
            case SET_DL_SRC:
                OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act;
                builder.setEthSrc(MacAddress.valueOf(dlsrc.getDlAddr().getLong()));
                break;
            case SET_NW_DST:
                OFActionSetNwDst nwdst = (OFActionSetNwDst) act;
                IPv4Address di = nwdst.getNwAddr();
                builder.setIpDst(Ip4Address.valueOf(di.getInt()));
                break;
            case SET_NW_SRC:
                OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act;
                IPv4Address si = nwsrc.getNwAddr();
                builder.setIpSrc(Ip4Address.valueOf(si.getInt()));
                break;
            case EXPERIMENTER:
                OFActionExperimenter exp = (OFActionExperimenter) act;
                if (exp.getExperimenter() == 0x80005A06 || exp.getExperimenter() == 0x748771) {
                    OFActionCircuit ct = (OFActionCircuit) exp;
                    CircuitSignalID circuitSignalID = ((OFOxmOchSigid) ct.getField()).getValue();
                    builder.add(Instructions.modL0Lambda(Lambda.ochSignal(lookupGridType(circuitSignalID.getGridType()), lookupChannelSpacing(circuitSignalID.getChannelSpacing()), circuitSignalID.getChannelNumber(), circuitSignalID.getSpectralWidth())));
                } else if (interpreter != null) {
                    builder.extension(interpreter.mapAction(exp), deviceId);
                } else {
                    log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
                }
                break;
            case SET_FIELD:
                OFActionSetField setField = (OFActionSetField) act;
                handleSetField(builder, setField, driverHandler, deviceId);
                break;
            case POP_MPLS:
                OFActionPopMpls popMpls = (OFActionPopMpls) act;
                builder.popMpls(new EthType(popMpls.getEthertype().getValue()));
                break;
            case PUSH_MPLS:
                builder.pushMpls();
                break;
            case COPY_TTL_IN:
                builder.copyTtlIn();
                break;
            case COPY_TTL_OUT:
                builder.copyTtlOut();
                break;
            case DEC_MPLS_TTL:
                builder.decMplsTtl();
                break;
            case DEC_NW_TTL:
                builder.decNwTtl();
                break;
            case GROUP:
                OFActionGroup group = (OFActionGroup) act;
                builder.group(new GroupId(group.getGroup().getGroupNumber()));
                break;
            case SET_QUEUE:
                OFActionSetQueue setQueue = (OFActionSetQueue) act;
                builder.setQueue(setQueue.getQueueId());
                break;
            case ENQUEUE:
                OFActionEnqueue enqueue = (OFActionEnqueue) act;
                builder.setQueue(enqueue.getQueueId(), PortNumber.portNumber(enqueue.getPort().getPortNumber()));
                break;
            case STRIP_VLAN:
            case POP_VLAN:
                builder.popVlan();
                break;
            case PUSH_VLAN:
                OFActionPushVlan pushVlan = (OFActionPushVlan) act;
                builder.pushVlan(new EthType((short) pushVlan.getEthertype().getValue()));
                break;
            case METER:
                OFActionMeter actionMeter = (OFActionMeter) act;
                builder.meter(MeterId.meterId(actionMeter.getMeterId()));
                break;
            case SET_TP_DST:
            case SET_TP_SRC:
            case POP_PBB:
            case PUSH_PBB:
            case SET_MPLS_LABEL:
            case SET_MPLS_TC:
            case SET_MPLS_TTL:
            case SET_NW_ECN:
            case SET_NW_TOS:
            case SET_NW_TTL:
            default:
                log.warn("Action type {} not yet implemented.", act.getType());
        }
    }
    return builder;
}
Also used : OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFOxmOchSigid(org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigid) OFActionSetQueue(org.projectfloodlight.openflow.protocol.action.OFActionSetQueue) OFActionSetDlSrc(org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc) OFActionPopMpls(org.projectfloodlight.openflow.protocol.action.OFActionPopMpls) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFActionExperimenter(org.projectfloodlight.openflow.protocol.action.OFActionExperimenter) OFActionEnqueue(org.projectfloodlight.openflow.protocol.action.OFActionEnqueue) CircuitSignalID(org.projectfloodlight.openflow.types.CircuitSignalID) OFActionPushVlan(org.projectfloodlight.openflow.protocol.action.OFActionPushVlan) OFActionSetDlDst(org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst) OFActionGroup(org.projectfloodlight.openflow.protocol.action.OFActionGroup) OFActionSetVlanPcp(org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp) IPv4Address(org.projectfloodlight.openflow.types.IPv4Address) ExtensionTreatmentInterpreter(org.onosproject.openflow.controller.ExtensionTreatmentInterpreter) GroupId(org.onosproject.core.GroupId) OFActionSetVlanVid(org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid) OFActionMeter(org.projectfloodlight.openflow.protocol.action.OFActionMeter) OFActionSetNwDst(org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst) EthType(org.onlab.packet.EthType) OFActionSetNwSrc(org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) OFActionCircuit(org.projectfloodlight.openflow.protocol.action.OFActionCircuit)

Example 2 with OFActionEnqueue

use of org.projectfloodlight.openflow.protocol.action.OFActionEnqueue in project onos by opennetworkinglab.

the class FlowModBuilderVer10 method buildActions.

private List<OFAction> buildActions() {
    List<OFAction> acts = new LinkedList<>();
    OFAction act;
    if (treatment == null) {
        return acts;
    }
    for (Instruction i : treatment.immediate()) {
        switch(i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L2MODIFICATION:
                act = buildL2Modification(i);
                if (act != null) {
                    acts.add(buildL2Modification(i));
                }
                break;
            case L3MODIFICATION:
                act = buildL3Modification(i);
                if (act != null) {
                    acts.add(buildL3Modification(i));
                }
                break;
            case OUTPUT:
                OutputInstruction out = (OutputInstruction) i;
                OFActionOutput.Builder action = factory().actions().buildOutput().setPort(OFPort.of((int) out.port().toLong()));
                if (out.port().equals(PortNumber.CONTROLLER)) {
                    action.setMaxLen(OFPCML_NO_BUFFER);
                }
                acts.add(action.build());
                break;
            case QUEUE:
                SetQueueInstruction queue = (SetQueueInstruction) i;
                if (queue.port() == null) {
                    log.warn("Required argument 'port' undefined for OFActionEnqueue");
                }
                OFActionEnqueue.Builder queueBuilder = factory().actions().buildEnqueue().setQueueId(queue.queueId()).setPort(OFPort.ofInt((int) queue.port().toLong()));
                acts.add(queueBuilder.build());
                break;
            case L0MODIFICATION:
            case L1MODIFICATION:
            case GROUP:
            case TABLE:
            case METADATA:
                log.warn("Instruction type {} not supported with protocol version {}", i.type(), factory().getVersion());
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    return acts;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) OFActionEnqueue(org.projectfloodlight.openflow.protocol.action.OFActionEnqueue) ModIPInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction) ModVlanPcpInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction) L2ModificationInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction) OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) L3ModificationInstruction(org.onosproject.net.flow.instructions.L3ModificationInstruction) Instruction(org.onosproject.net.flow.instructions.Instruction) ModVlanIdInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction) ModEtherInstruction(org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction) SetQueueInstruction(org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction) LinkedList(java.util.LinkedList)

Aggregations

OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)2 OFActionEnqueue (org.projectfloodlight.openflow.protocol.action.OFActionEnqueue)2 OFActionOutput (org.projectfloodlight.openflow.protocol.action.OFActionOutput)2 LinkedList (java.util.LinkedList)1 EthType (org.onlab.packet.EthType)1 GroupId (org.onosproject.core.GroupId)1 Instruction (org.onosproject.net.flow.instructions.Instruction)1 OutputInstruction (org.onosproject.net.flow.instructions.Instructions.OutputInstruction)1 SetQueueInstruction (org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction)1 L2ModificationInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction)1 ModEtherInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction)1 ModVlanIdInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction)1 ModVlanPcpInstruction (org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction)1 L3ModificationInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction)1 ModIPInstruction (org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction)1 ExtensionTreatmentInterpreter (org.onosproject.openflow.controller.ExtensionTreatmentInterpreter)1 OFActionCircuit (org.projectfloodlight.openflow.protocol.action.OFActionCircuit)1 OFActionExperimenter (org.projectfloodlight.openflow.protocol.action.OFActionExperimenter)1 OFActionGroup (org.projectfloodlight.openflow.protocol.action.OFActionGroup)1 OFActionMeter (org.projectfloodlight.openflow.protocol.action.OFActionMeter)1