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

项目:open-kilda    文件:SwitchManager.java   
/**
 * Create an OFAction to change the outer most vlan.
 *
 * @param sw      switch object
 * @param newVlan final VLAN to be set on the packet
 * @return {@link OFAction}
 */
private OFAction actionReplaceVlan(final IOFSwitch sw, final int newVlan) {
    OFFactory factory = sw.getOFFactory();
    OFOxms oxms = factory.oxms();
    OFActions actions = factory.actions();

    if (OF_12.compareTo(factory.getVersion()) == 0) {
        return actions.buildSetField().setField(oxms.buildVlanVid()
                .setValue(OFVlanVidMatch.ofRawVid((short) newVlan))
                .build()).build();
    } else {
        return actions.buildSetField().setField(oxms.buildVlanVid()
                .setValue(OFVlanVidMatch.ofVlan(newVlan))
                .build()).build();
    }
}
项目:SDN-Multicast    文件:MulticastTree.java   
private void addQoSOFBucketToGroup(IOFSwitch sw, OFPort destPort, long bandwidth) {

        /* creates queue using OVSDBContext on the switch */
        OVSDBContext ovsdbContext = mcObject.ovsdbChannelMap.get(sw.getId());

        /* FIXME: hardcoded priority '1' for all flows */
        int queueId = ovsdbContext.createQueueOnPort(destPort, Long.toString(bandwidth), "1");

        OFFactory of13Factory = sw.getOFFactory();

        /* creates actions for the bucket */
        ArrayList<OFAction> actionList = new ArrayList<OFAction>();
        OFActions actions = of13Factory.actions();
        OFActionSetQueue setQueue = actions.buildSetQueue().setQueueId(queueId).build();
        actionList.add(setQueue);
        OFActionOutput output = actions.buildOutput()
                .setMaxLen(0xFFffFFff)
                .setPort(destPort).build();
        actionList.add(output);

        /* creates a bucket */
        OFBucket bucket = of13Factory.buildBucket()
                .setActions(actionList)
                .setWatchGroup(OFGroup.ANY)
                .setWatchPort(OFPort.ANY)
                .build();
        /* store the bucket in multicastGroup object */
        multicastGroup.addMemberOFBucket(sw.getId(), 
                destPort.getShortPortNumber(), bucket);
    }
项目:ACAMPController    文件:TestStaticFlowPusher.java   
@Override
public void switchAdded(DatapathId switchId) {
    logger.info("Detected a added switch, switch DPID:{}", switchId.toString());
    OFFactory my13Factory = OFFactories.getFactory(OFVersion.OF_13);
    Match myMatch = my13Factory.buildMatch()
            .setExact(MatchField.IN_PORT, OFPort.of(2))
            .setExact(MatchField.IP_PROTO, IpProtocol.UDP)
            .build();
    ArrayList<OFAction> actionList = new ArrayList<OFAction>();
    OFActions actions = my13Factory.actions();
    OFActionOutput output = actions.buildOutput()
            .setMaxLen(0xFFffFFff)
            .setPort(OFPort.CONTROLLER)
            .build();
    actionList.add(output);
    OFFlowAdd flowAdd = my13Factory.buildFlowAdd()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setHardTimeout(INFINITE_TIMEOUT)
            .setIdleTimeout(INFINITE_TIMEOUT)
            .setPriority(Integer.MAX_VALUE)
            .setMatch(myMatch)
            .setActions(actionList)
            .setTableId(TableId.of(0))
            .build();
    flowEntryPusherService.addFlow(TestStaticFlowPusher.class.getSimpleName(), flowAdd, switchId);

}
项目:open-kilda    文件:SwitchManager.java   
/**
 * Create an action to set the DstMac of a packet
 *
 * @param sw         switch object
 * @param macAddress MacAddress to set
 * @return {@link OFAction}
 */
private OFAction actionSetDstMac(final IOFSwitch sw, final MacAddress macAddress) {
    OFOxms oxms = sw.getOFFactory().oxms();
    OFActions actions = sw.getOFFactory().actions();
    return actions.buildSetField()
            .setField(oxms.buildEthDst().setValue(macAddress).build()).build();
}
项目:open-kilda    文件:SwitchManager.java   
/**
 * Create an OFAction which sets the output port.
 *
 * @param sw         switch object
 * @param outputPort port to set in the action
 * @return {@link OFAction}
 */
private OFAction actionSetOutputPort(final IOFSwitch sw, final int outputPort) {
    OFActions actions = sw.getOFFactory().actions();
    return actions.buildOutput().setMaxLen(0xFFFFFFFF).setPort(OFPort.of(outputPort)).build();
}
项目:open-kilda    文件:SwitchManager.java   
/**
 * Create an OFAction to add a VLAN header.
 *
 * @param sw        switch object
 * @param etherType ethernet type of the new VLAN header
 * @return {@link OFAction}
 */
private OFAction actionPushVlan(final IOFSwitch sw, final int etherType) {
    OFActions actions = sw.getOFFactory().actions();
    return actions.buildPushVlan().setEthertype(EthType.of(etherType)).build();
}
项目:open-kilda    文件:SwitchManager.java   
/**
 * Create an OFAction to remove the outer most VLAN.
 *
 * @param sw - switch object
 * @return {@link OFAction}
 */
private OFAction actionPopVlan(final IOFSwitch sw) {
    OFActions actions = sw.getOFFactory().actions();
    return actions.popVlan();
}
项目:open-kilda    文件:SwitchManager.java   
/**
 * Create an action to send packet to the controller.
 *
 * @param sw switch object
 * @return {@link OFAction}
 */
private OFAction actionSendToController(final IOFSwitch sw) {
    OFActions actions = sw.getOFFactory().actions();
    return actions.buildOutput().setMaxLen(0xFFffFFff).setPort(OFPort.CONTROLLER)
            .build();
}