Search in sources :

Example 1 with OFOxmOfdpaAllowVlanTranslation

use of org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation in project onos by opennetworkinglab.

the class Ofdpa3ExtensionTreatmentInterpreter method mapAction.

@Override
public ExtensionTreatment mapAction(OFAction action) throws UnsupportedOperationException {
    if (action.getType().equals(OFActionType.SET_FIELD)) {
        OFActionSetField setFieldAction = (OFActionSetField) action;
        OFOxm<?> oxm = setFieldAction.getField();
        switch(oxm.getMatchField().id) {
            case OFDPA_MPLS_TYPE:
                OFOxmOfdpaMplsType mplsType = (OFOxmOfdpaMplsType) oxm;
                return new Ofdpa3SetMplsType(mplsType.getValue().getRaw());
            case OFDPA_OVID:
                OFOxmOfdpaOvid ovid = ((OFOxmOfdpaOvid) oxm);
                short mask = (short) 0x0FFF;
                short oVid = (short) (mask & ovid.getValue().getRaw());
                VlanId vlanId = VlanId.vlanId(oVid);
                return new Ofdpa3SetOvid(vlanId);
            case OFDPA_MPLS_L2_PORT:
                OFOxmOfdpaMplsL2Port mplsl2Port = ((OFOxmOfdpaMplsL2Port) oxm);
                Integer mplsL2Port = mplsl2Port.getValue().getRaw();
                if ((mplsL2Port >= 0 && mplsL2Port <= 0x0000FFFF) || (mplsL2Port >= 0x00020000 && mplsL2Port <= 0x0002FFFF)) {
                    return new Ofdpa3SetMplsL2Port(mplsL2Port);
                }
                break;
            case OFDPA_QOS_INDEX:
                OFOxmOfdpaQosIndex qosindex = ((OFOxmOfdpaQosIndex) oxm);
                Integer qosIndex = (int) qosindex.getValue().getRaw();
                if (qosIndex >= 0 && qosIndex <= 255) {
                    return new Ofdpa3SetQosIndex(qosIndex);
                }
                break;
            case OFDPA_ALLOW_VLAN_TRANSLATION:
                OFOxmOfdpaAllowVlanTranslation allowVlanTranslation = (OFOxmOfdpaAllowVlanTranslation) oxm;
                Byte allowVlan = allowVlanTranslation.getValue().getRaw();
                if ((allowVlan == 0) || (allowVlan == 1)) {
                    return new OfdpaSetAllowVlanTranslation(allowVlan);
                }
                break;
            default:
                throw new UnsupportedOperationException("Driver does not support extension type " + oxm.getMatchField().id);
        }
    } else if (action.getType().equals(OFActionType.EXPERIMENTER)) {
        OFActionExperimenter experimenter = (OFActionExperimenter) action;
        if (Long.valueOf(experimenter.getExperimenter()).intValue() == TYPE_OFDPA) {
            OFActionOfdpa ofdpa = (OFActionOfdpa) experimenter;
            switch(ofdpa.getExpType()) {
                case SUB_TYPE_PUSH_L2_HEADER:
                    return new Ofdpa3PushL2Header();
                case SUB_TYPE_POP_L2_HEADER:
                    return new Ofdpa3PopL2Header();
                case SUB_TYPE_PUSH_CW:
                    return new Ofdpa3PushCw();
                case SUB_TYPE_POP_CW:
                    return new Ofdpa3PopCw();
                default:
                    throw new UnsupportedOperationException("Unexpected OFAction: " + action.toString());
            }
        } else if (Long.valueOf(experimenter.getExperimenter()).intValue() == TYPE_ONF) {
            OFActionOnf onf = (OFActionOnf) experimenter;
            switch(onf.getExpType()) {
                case SUB_TYPE_COPY_FIELD:
                    return new Ofdpa3CopyField(((OFActionOnfCopyField) onf).getNBits(), ((OFActionOnfCopyField) onf).getSrcOffset(), ((OFActionOnfCopyField) onf).getDstOffset(), (int) ((OFActionOnfCopyField) onf).getSrc(), (int) ((OFActionOnfCopyField) onf).getDst());
                default:
                    throw new UnsupportedOperationException("Unexpected OFAction: " + action.toString());
            }
        }
        throw new UnsupportedOperationException("Unexpected OFAction: " + action.toString());
    }
    throw new UnsupportedOperationException("Unexpected OFAction: " + action.toString());
}
Also used : OFOxmOfdpaAllowVlanTranslation(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation) OFOxmOfdpaOvid(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaOvid) OFOxmOfdpaQosIndex(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaQosIndex) OFActionExperimenter(org.projectfloodlight.openflow.protocol.action.OFActionExperimenter) OFActionOnf(org.projectfloodlight.openflow.protocol.action.OFActionOnf) OFOxmOfdpaMplsL2Port(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaMplsL2Port) OFActionOfdpa(org.projectfloodlight.openflow.protocol.action.OFActionOfdpa) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) OFActionOnfCopyField(org.projectfloodlight.openflow.protocol.action.OFActionOnfCopyField) VlanId(org.onlab.packet.VlanId) OFOxmOfdpaMplsType(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaMplsType)

Example 2 with OFOxmOfdpaAllowVlanTranslation

use of org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation in project onos by opennetworkinglab.

the class OfdpaExtensionSelectorInterpreter method mapOxm.

@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
    VlanId vlanId;
    if (oxm.getMatchField().equals(MatchField.VLAN_VID)) {
        if (oxm.isMasked()) {
            OFVlanVidMatch vid = ((OFOxmVlanVidMasked) oxm).getValue();
            OFVlanVidMatch mask = ((OFOxmVlanVidMasked) oxm).getMask();
            if (vid.equals(OFVlanVidMatch.ofRawVid((short) 0))) {
                vlanId = VlanId.NONE;
            } else if (vid.equals(OFVlanVidMatch.PRESENT) && mask.equals(OFVlanVidMatch.PRESENT)) {
                vlanId = VlanId.ANY;
            } else {
                vlanId = VlanId.vlanId(vid.getVlan());
            }
        } else {
            OFVlanVidMatch vid = ((OFOxmVlanVid) oxm).getValue();
            if (!vid.isPresentBitSet()) {
                vlanId = VlanId.NONE;
            } else {
                vlanId = VlanId.vlanId(vid.getVlan());
            }
        }
        return new OfdpaMatchVlanVid(vlanId);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
        U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
        PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
        return new OfdpaMatchActsetOutput(portNumber);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_ALLOW_VLAN_TRANSLATION)) {
        U8 value = ((OFOxmOfdpaAllowVlanTranslation) oxm).getValue();
        return new OfdpaMatchAllowVlanTranslation(value.getValue());
    }
    throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
Also used : OFOxmOfdpaAllowVlanTranslation(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) U8(org.projectfloodlight.openflow.types.U8) OFOxmVlanVidMasked(org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVidMasked) U32(org.projectfloodlight.openflow.types.U32) OFOxmVlanVid(org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVid) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Aggregations

VlanId (org.onlab.packet.VlanId)2 OFOxmOfdpaAllowVlanTranslation (org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation)2 PortNumber (org.onosproject.net.PortNumber)1 OFActionExperimenter (org.projectfloodlight.openflow.protocol.action.OFActionExperimenter)1 OFActionOfdpa (org.projectfloodlight.openflow.protocol.action.OFActionOfdpa)1 OFActionOnf (org.projectfloodlight.openflow.protocol.action.OFActionOnf)1 OFActionOnfCopyField (org.projectfloodlight.openflow.protocol.action.OFActionOnfCopyField)1 OFActionSetField (org.projectfloodlight.openflow.protocol.action.OFActionSetField)1 OFOxmOfdpaMplsL2Port (org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaMplsL2Port)1 OFOxmOfdpaMplsType (org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaMplsType)1 OFOxmOfdpaOvid (org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaOvid)1 OFOxmOfdpaQosIndex (org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaQosIndex)1 OFOxmVlanVid (org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVid)1 OFOxmVlanVidMasked (org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVidMasked)1 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)1 U32 (org.projectfloodlight.openflow.types.U32)1 U8 (org.projectfloodlight.openflow.types.U8)1