Java 类org.projectfloodlight.openflow.protocol.action.OFActionSetField 实例源码

项目:athena    文件:OfdpaExtensionTreatmentInterpreter.java   
@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());
}
项目:athena    文件:OfOpticalSwitchImplLinc13.java   
/**
 * Rewrite actions to use LINC OF optical extensions.
 *
 * @param actions original actions
 * @return rewritten actions
 */
private List<OFAction> rewriteActions(List<OFAction> actions) {
    List<OFAction> newActions = new LinkedList<>();

    for (OFAction action : actions) {
        if (!(action instanceof OFActionSetField)) {
            newActions.add(action);
            continue;
        }

        OFActionSetField sf = (OFActionSetField) action;
        if (!(sf.getField() instanceof OFOxmExpOchSigId)) {
            newActions.add(action);
            continue;
        }

        OFOxmExpOchSigId oxm = (OFOxmExpOchSigId) sf.getField();
        CircuitSignalID signalId = oxm.getValue();

        newActions.add(
                factory().actions().circuit(factory().oxms().ochSigid(signalId)));
    }

    return newActions;
}
项目:onos    文件:OfdpaExtensionTreatmentInterpreter.java   
@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());
}
项目:onos    文件:OfOpticalSwitchImplLinc13.java   
/**
 * Rewrite actions to use LINC OF optical extensions.
 *
 * @param actions original actions
 * @return rewritten actions
 */
private List<OFAction> rewriteActions(List<OFAction> actions) {
    List<OFAction> newActions = new LinkedList<>();

    for (OFAction action : actions) {
        if (!(action instanceof OFActionSetField)) {
            newActions.add(action);
            continue;
        }

        OFActionSetField sf = (OFActionSetField) action;
        if (!(sf.getField() instanceof OFOxmExpOchSigId)) {
            newActions.add(action);
            continue;
        }

        OFOxmExpOchSigId oxm = (OFOxmExpOchSigId) sf.getField();
        CircuitSignalID signalId = oxm.getValue();

        newActions.add(
                factory().actions().circuit(factory().oxms().ochSigid(signalId)));
    }

    return newActions;
}
项目:spring-open    文件:OFSwitchImplSpringOpenTTP.java   
private BucketInfo getDriverBucketFromOFBucket(OFBucket bucket) {
    List<OFAction> actions = bucket.getActions();
    int bucketPort = -1;
    int bucketLabel = -1;
    int bucketToGroup = -1;
    MacAddress dlSrc = null;
    MacAddress dlDst = null;
    for (OFAction action : actions) {
        if (action.getType().compareTo(OFActionType.OUTPUT) == 0) {
            bucketPort = ((OFActionOutput) action).getPort()
                    .getPortNumber();
        }
        else if (action.getType().compareTo(OFActionType.GROUP) == 0) {
            bucketToGroup = ((OFActionGroup) action).getGroup()
                    .getGroupNumber();
        }
        else if (action.getType().compareTo(OFActionType.SET_FIELD) == 0) {
            if (((OFActionSetField) action).getField().toString()
                    .contains("OFOxmMplsLabelVer13")) {
                bucketLabel = Integer.decode(
                        ((OFActionSetField) action).
                                getField().getValue().toString());
            }
            else if (((OFActionSetField) action).getField().toString()
                    .contains("OFOxmEthSrcVer13")) {
                dlSrc = MacAddress.of(((OFActionSetField) action)
                        .getField().getValue().toString());
            }
            else if (((OFActionSetField) action).getField().toString()
                    .contains("OFOxmEthDstVer13")) {
                dlDst = MacAddress.of(((OFActionSetField) action)
                        .getField().getValue().toString());
            }
        }
    }

    if ((bucketPort == -1) && (bucketLabel == -1)
            && (bucketToGroup == -1)) {
        log.warn("processGroupDesc: A group with no port, no label, no to group");
    }
    BucketInfo driverBucket = new BucketInfo(null, dlSrc, dlDst,
            PortNumber.uint32(bucketPort), bucketLabel, true,
            bucketToGroup);

    return driverBucket;
}
项目:onos    文件:Ofdpa3ExtensionTreatmentInterpreter.java   
@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;
            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());
            }
        }
        throw new UnsupportedOperationException(
                "Unexpected OFAction: " + action.toString());
    }
    throw new UnsupportedOperationException(
            "Unexpected OFAction: " + action.toString());
}