Search in sources :

Example 1 with OFOxmVlanVid

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

Example 2 with OFOxmVlanVid

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

the class OfdpaExtensionTreatmentInterpreter 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 VLAN_VID:
                OFOxmVlanVid vlanVid = (OFOxmVlanVid) oxm;
                return new OfdpaSetVlanVid(VlanId.vlanId(vlanVid.getValue().getRawVid()));
            default:
                throw new UnsupportedOperationException("Driver does not support extension type " + oxm.getMatchField().id);
        }
    }
    throw new UnsupportedOperationException("Unexpected OFAction: " + action.toString());
}
Also used : OFOxmVlanVid(org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVid) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField)

Aggregations

OFOxmVlanVid (org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVid)2 VlanId (org.onlab.packet.VlanId)1 PortNumber (org.onosproject.net.PortNumber)1 OFActionSetField (org.projectfloodlight.openflow.protocol.action.OFActionSetField)1 OFOxmOfdpaAllowVlanTranslation (org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation)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