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

项目:athena    文件:FlowModBuilderVer13.java   
private List<OFAction> buildActions(List<Instruction> treatments) {
    if (treatment == null) {
        return Collections.emptyList();
    }

    boolean tableFound = false;
    List<OFAction> actions = new LinkedList<>();
    for (Instruction i : treatments) {
        switch (i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L1MODIFICATION:
                actions.add(buildL1Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case L4MODIFICATION:
                actions.add(buildL4Modification(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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                GroupInstruction group = (GroupInstruction) i;
                OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
                        .setGroup(OFGroup.of(group.groupId().id()));
                actions.add(groupBuilder.build());
                break;
            case QUEUE:
                SetQueueInstruction queue = (SetQueueInstruction) i;
                OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue()
                        .setQueueId(queue.queueId());
                actions.add(queueBuilder.build());
                break;
            case TABLE:
                //FIXME: should not occur here.
                tableFound = true;
                break;
            case EXTENSION:
                actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i)
                        .extensionInstruction()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    if (tableFound && actions.isEmpty()) {
        // handles the case where there are no actions, but there is
        // a goto instruction for the next table
        return Collections.emptyList();
    }
    return actions;
}
项目:athena    文件:GroupModBuilder.java   
private List<OFAction> buildActions(TrafficTreatment treatment) {
    if (treatment == null) {
        return Collections.emptyList();
    }

    List<OFAction> actions = new LinkedList<>();
    for (Instruction i : treatment.allInstructions()) {
        switch (i.type()) {
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case OUTPUT:
                Instructions.OutputInstruction out =
                        (Instructions.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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                Instructions.GroupInstruction grp =
                        (Instructions.GroupInstruction) i;
                OFActionGroup.Builder actgrp = factory.actions().buildGroup()
                        .setGroup(OFGroup.of(grp.groupId().id()));
                actions.add(actgrp.build());
                break;
            case EXTENSION:
                Instructions.ExtensionInstructionWrapper wrapper =
                (Instructions.ExtensionInstructionWrapper) i;
                actions.add(buildExtensionAction(
                        wrapper.extensionInstruction(), wrapper.deviceId()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }

    return actions;
}
项目:ravikumaran201504    文件:FlowModBuilderVer13.java   
private List<OFAction> buildActions(List<Instruction> treatments) {
    List<OFAction> actions = new LinkedList<>();
    boolean tableFound = false;
    if (treatment == null) {
        return actions;
    }
    for (Instruction i : treatments) {
        switch (i.type()) {
            case DROP:
                log.warn("Saw drop action; assigning drop action");
                return new LinkedList<>();
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                GroupInstruction group = (GroupInstruction) i;
                OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
                        .setGroup(OFGroup.of(group.groupId().id()));
                actions.add(groupBuilder.build());
                break;
            case TABLE:
                //FIXME: should not occur here.
                tableFound = true;
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    if (tableFound && actions.isEmpty()) {
        // handles the case where there are no actions, but there is
        // a goto instruction for the next table
        return null;
    }
    return actions;
}
项目:Engine    文件:FlowModBuilderVer13.java   
private List<OFAction> buildActions(List<Instruction> treatments) {
    if (treatment == null) {
        return Collections.emptyList();
    }

    boolean tableFound = false;
    List<OFAction> actions = new LinkedList<>();
    for (Instruction i : treatments) {
        switch (i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L1MODIFICATION:
                actions.add(buildL1Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case L4MODIFICATION:
                actions.add(buildL4Modification(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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                GroupInstruction group = (GroupInstruction) i;
                OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
                        .setGroup(OFGroup.of(group.groupId().id()));
                actions.add(groupBuilder.build());
                break;
            case QUEUE:
                SetQueueInstruction queue = (SetQueueInstruction) i;
                OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue()
                        .setQueueId(queue.queueId());
                actions.add(queueBuilder.build());
                break;
            case TABLE:
                //FIXME: should not occur here.
                tableFound = true;
                break;
            case EXTENSION:
                actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i)
                        .extensionInstruction()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    if (tableFound && actions.isEmpty()) {
        // handles the case where there are no actions, but there is
        // a goto instruction for the next table
        return Collections.emptyList();
    }
    return actions;
}
项目: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    文件:FlowModBuilderVer13.java   
private List<OFAction> buildActions(List<Instruction> treatments) {
    if (treatment == null) {
        return Collections.emptyList();
    }

    boolean tableFound = false;
    List<OFAction> actions = new LinkedList<>();
    for (Instruction i : treatments) {
        switch (i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L1MODIFICATION:
                actions.add(buildL1Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case L4MODIFICATION:
                actions.add(buildL4Modification(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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                GroupInstruction group = (GroupInstruction) i;
                OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
                        .setGroup(OFGroup.of(group.groupId().id()));
                actions.add(groupBuilder.build());
                break;
            case QUEUE:
                SetQueueInstruction queue = (SetQueueInstruction) i;
                OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue()
                        .setQueueId(queue.queueId());
                actions.add(queueBuilder.build());
                break;
            case TABLE:
                //FIXME: should not occur here.
                tableFound = true;
                break;
            case EXTENSION:
                actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i)
                        .extensionInstruction()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }
    if (tableFound && actions.isEmpty()) {
        // handles the case where there are no actions, but there is
        // a goto instruction for the next table
        return Collections.emptyList();
    }
    return actions;
}
项目:onos    文件:FlowModBuilderVer15.java   
private List<OFAction> buildActions(List<Instruction> treatments, Boolean immediateActions) {
    if (treatment == null) {
        return Collections.emptyList();
    }

    boolean tableFound = false;
    List<OFAction> actions = new LinkedList<>();

    //Meter action handling
    if (null != treatment.meters() && immediateActions) {
        treatment.meters().forEach(meterInstruction -> {
            OFAction meterAction = buildMeterAction(meterInstruction);
            actions.add(meterAction);
        });
    }

    for (Instruction i : treatments) {
        switch (i.type()) {
            case NOACTION:
                return Collections.emptyList();
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L1MODIFICATION:
                actions.add(buildL1Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case L4MODIFICATION:
                actions.add(buildL4Modification(i));
                break;
            case OUTPUT:
                Instructions.OutputInstruction out = (Instructions.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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                Instructions.GroupInstruction group = (Instructions.GroupInstruction) i;
                OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
                        .setGroup(OFGroup.of(group.groupId().id()));
                actions.add(groupBuilder.build());
                break;
            case QUEUE:
                Instructions.SetQueueInstruction queue = (Instructions.SetQueueInstruction) i;
                OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue()
                        .setQueueId(queue.queueId());
                actions.add(queueBuilder.build());
                break;
            case TABLE:
                //FIXME: should not occur here.
                tableFound = true;
                break;
            case EXTENSION:
                actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i)
                        .extensionInstruction()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }

    if (tableFound && actions.isEmpty()) {
        // handles the case where there are no actions, but there is
        // a goto instruction for the next table
        return Collections.emptyList();
    }
    return actions;
}
项目:onos    文件:GroupModBuilder.java   
private List<OFAction> buildActions(TrafficTreatment treatment) {
    if (treatment == null) {
        return Collections.emptyList();
    }

    List<OFAction> actions = new LinkedList<>();
    for (Instruction i : treatment.allInstructions()) {
        switch (i.type()) {
            case L0MODIFICATION:
                actions.add(buildL0Modification(i));
                break;
            case L2MODIFICATION:
                actions.add(buildL2Modification(i));
                break;
            case L3MODIFICATION:
                actions.add(buildL3Modification(i));
                break;
            case OUTPUT:
                Instructions.OutputInstruction out =
                        (Instructions.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);
                }
                actions.add(action.build());
                break;
            case GROUP:
                Instructions.GroupInstruction grp =
                        (Instructions.GroupInstruction) i;
                OFActionGroup.Builder actgrp = factory.actions().buildGroup()
                        .setGroup(OFGroup.of(grp.groupId().id()));
                actions.add(actgrp.build());
                break;
            case EXTENSION:
                Instructions.ExtensionInstructionWrapper wrapper =
                (Instructions.ExtensionInstructionWrapper) i;
                actions.add(buildExtensionAction(
                        wrapper.extensionInstruction(), wrapper.deviceId()));
                break;
            default:
                log.warn("Instruction type {} not yet implemented.", i.type());
        }
    }

    return actions;
}