Search in sources :

Example 1 with OFActionSetDlSrc

use of org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc 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)

Aggregations

EthType (org.onlab.packet.EthType)1 GroupId (org.onosproject.core.GroupId)1 ExtensionTreatmentInterpreter (org.onosproject.openflow.controller.ExtensionTreatmentInterpreter)1 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)1 OFActionCircuit (org.projectfloodlight.openflow.protocol.action.OFActionCircuit)1 OFActionEnqueue (org.projectfloodlight.openflow.protocol.action.OFActionEnqueue)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 OFActionOutput (org.projectfloodlight.openflow.protocol.action.OFActionOutput)1 OFActionPopMpls (org.projectfloodlight.openflow.protocol.action.OFActionPopMpls)1 OFActionPushVlan (org.projectfloodlight.openflow.protocol.action.OFActionPushVlan)1 OFActionSetDlDst (org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst)1 OFActionSetDlSrc (org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc)1 OFActionSetField (org.projectfloodlight.openflow.protocol.action.OFActionSetField)1 OFActionSetNwDst (org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst)1 OFActionSetNwSrc (org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc)1 OFActionSetQueue (org.projectfloodlight.openflow.protocol.action.OFActionSetQueue)1 OFActionSetVlanPcp (org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp)1 OFActionSetVlanVid (org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid)1