当前位置: 首页>>代码示例>>Java>>正文


Java OFAction.getType方法代码示例

本文整理汇总了Java中org.openflow.protocol.action.OFAction.getType方法的典型用法代码示例。如果您正苦于以下问题:Java OFAction.getType方法的具体用法?Java OFAction.getType怎么用?Java OFAction.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openflow.protocol.action.OFAction的用法示例。


在下文中一共展示了OFAction.getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isLegalAction

import org.openflow.protocol.action.OFAction; //导入方法依赖的package包/类
/**
 * Checks one OFACtion for legallity (e.g. is Outport > maxPortNum)
 *
 * @param action the Action
 * @return legal?
 */
private boolean isLegalAction(OFAction action) {
    switch (action.getType()) {
        case OPAQUE_ENQUEUE:
            break;
        case OUTPUT:
            OFActionOutput actionOutput = (OFActionOutput) action;
            short port = actionOutput.getPort();
            return (this.config.getSwitchConfig().getPortCountperSwitch() >= port);
        case SET_DL_DST:
            break;
        case SET_DL_SRC:
            break;
        case SET_NW_DST:
            break;
        case SET_NW_SRC:
            break;
        case SET_NW_TOS:
            break;
        case SET_TP_DST:
            break;
        case SET_TP_SRC:
            break;
        case SET_VLAN_PCP:
            break;
        case SET_VLAN_VID:
            break;
        case STRIP_VLAN:
            break;
        case VENDOR:
            break;
        default:
            break;

    }

    return true;
}
 
开发者ID:lsinfo3,项目名称:ofcprobe,代码行数:44,代码来源:OFFlowModHandler.java

示例2: getAction

import org.openflow.protocol.action.OFAction; //导入方法依赖的package包/类
/**
 * Returns a JSON object of the provided OF Action
 * @param action to be serialized to JSON
 * @return
 */
public static JSONObject getAction(OFAction action) {
	JSONObject json = new JSONObject();
	switch (action.getType()) {
		case OUTPUT:
			json.put("outport", (0x0FFFF&(((OFActionOutput)action).getPort())));
			break;
		case SET_DL_DST:
			json.put("dstmac", ((OFActionDataLayerDestination)action).getDataLayerAddress());
			break;
		case SET_DL_SRC:
			json.put("srcmac", ((OFActionDataLayerSource)action).getDataLayerAddress());
			break;
		case SET_NW_DST:
			int ipDst = ((OFActionNetworkLayerDestination)action).getNetworkAddress();
			json.put("dstip", IPv4.toIPv4AddressBytes(ipDst));
			break;
		case SET_NW_SRC:
			int ipSrc = ((OFActionNetworkLayerSource)action).getNetworkAddress();
			json.put("dstmac", IPv4.toIPv4AddressBytes(ipSrc));
			break;
		case SET_NW_TOS:
			json.put("tos", ((OFActionNetworkTypeOfService)action).getNetworkTypeOfService());
		case SET_TP_DST:
			json.put("dstport", (0x0FFFF&((OFActionTransportLayer)action).getTransportPort()));
			break;
		case SET_TP_SRC:
			json.put("srcport", (0x0FFFF&((OFActionTransportLayer)action).getTransportPort()));
			break;
		case SET_VLAN_ID:
		case SET_VLAN_PCP:
		case STRIP_VLAN:
		case VENDOR:
		case OPAQUE_ENQUEUE:
	}
	return json;
}
 
开发者ID:fp7-netide,项目名称:Engine,代码行数:42,代码来源:MessageSerializer.java

示例3: flowModActionsToString

import org.openflow.protocol.action.OFAction; //导入方法依赖的package包/类
/**
 * Returns a String representation of all the openflow actions.
 * @param fmActions A list of OFActions to encode into one string
 * @return A string of the actions encoded for our database
 */
@LogMessageDoc(level="ERROR",
        message="Could not decode action {action}",
        explanation="A static flow entry contained an invalid action",
        recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static String flowModActionsToString(List<OFAction> fmActions) {
    StringBuilder sb = new StringBuilder();
    for (OFAction a : fmActions) {
        if (sb.length() > 0) {
            sb.append(',');
        }
        switch(a.getType()) {
            case OUTPUT:
                sb.append("output=" + Short.toString(((OFActionOutput)a).getPort()));
                break;
            case OPAQUE_ENQUEUE:
                int queue = ((OFActionEnqueue)a).getQueueId();
                short port = ((OFActionEnqueue)a).getPort();
                sb.append("enqueue=" + Short.toString(port) + ":0x" + String.format("%02x", queue));
                break;
            case STRIP_VLAN:
                sb.append("strip-vlan");
                break;
            case SET_VLAN_ID:
                sb.append("set-vlan-id=" + 
                    Short.toString(((OFActionVirtualLanIdentifier)a).getVirtualLanIdentifier()));
                break;
            case SET_VLAN_PCP:
                sb.append("set-vlan-priority=" +
                    Byte.toString(((OFActionVirtualLanPriorityCodePoint)a).getVirtualLanPriorityCodePoint()));
                break;
            case SET_DL_SRC:
                sb.append("set-src-mac=" + 
                    HexString.toHexString(((OFActionDataLayerSource)a).getDataLayerAddress()));
                break;
            case SET_DL_DST:
                sb.append("set-dst-mac=" + 
                    HexString.toHexString(((OFActionDataLayerDestination)a).getDataLayerAddress()));
                break;
            case SET_NW_TOS:
                sb.append("set-tos-bits=" +
                    Byte.toString(((OFActionNetworkTypeOfService)a).getNetworkTypeOfService()));
                break;
            case SET_NW_SRC:
                sb.append("set-src-ip=" +
                    IPv4.fromIPv4Address(((OFActionNetworkLayerSource)a).getNetworkAddress()));
                break;
            case SET_NW_DST:
                sb.append("set-dst-ip=" +
                    IPv4.fromIPv4Address(((OFActionNetworkLayerDestination)a).getNetworkAddress()));
                break;
            case SET_TP_SRC:
                sb.append("set-src-port=" +
                    Short.toString(((OFActionTransportLayerSource)a).getTransportPort()));
                break;
            case SET_TP_DST:
                sb.append("set-dst-port=" +
                    Short.toString(((OFActionTransportLayerDestination)a).getTransportPort()));
                break;
            default:
                log.error("Could not decode action: {}", a);
                break;
        }
            
    }
    return sb.toString();
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:72,代码来源:StaticFlowEntries.java

示例4: switchPath

import org.openflow.protocol.action.OFAction; //导入方法依赖的package包/类
/**
 * Switches over to the next backup path given as a list of physical links
 * with the given priority.
 *
 * @param physicalLinks the new path
 * @param priority the priority of the new path
 */
public void switchPath(List<PhysicalLink> physicalLinks, byte priority) {
    // Register the new path as primary path in the OVXMap
    OVXMap.getInstance().removeRoute(this);
    OVXMap.getInstance().addRoute(this, physicalLinks);
    // Set the route priority to the new one
    this.setPriority(priority);

    int counter = 0;
    SwitchRoute.log.info(
            "Virtual network {}: switching all existing flow-mods crossing"
            + "the big-switch {} route {} between ports ({},{}) to the new path: {}",
            this.getTenantId(), this.getSrcPort().getParentSwitch()
                    .getSwitchName(), this.getRouteId(), this.getSrcPort()
                    .getPortNumber(), this.getDstPort().getPortNumber(),
            physicalLinks);
    Collection<OVXFlowMod> flows = this.getSrcPort().getParentSwitch()
            .getFlowTable().getFlowTable();
    for (OVXFlowMod fe : flows) {
        for (OFAction act : fe.getActions()) {
            if (act.getType() == OFActionType.OUTPUT
                    && fe.getMatch().getInputPort() == this.getSrcPort()
                            .getPortNumber()
                    && ((OFActionOutput) act).getPort() == this
                            .getDstPort().getPortNumber()) {
                SwitchRoute.log.info(
                        "Virtual network {}, switch {}, route {} between ports {}-{}: switch fm {}",
                        this.getTenantId(), this.getSrcPort()
                                .getParentSwitch().getSwitchName(), this
                                .getRouteId(), this.getSrcPort()
                                .getPortNumber(), this.getDstPort()
                                .getPortNumber(), fe);
                counter++;

                OVXFlowMod fm = fe.clone();
                fm.setCookie(((OVXFlowTable) this.getSrcPort()
                        .getParentSwitch().getFlowTable()).getCookie(fe,
                        true));
                this.generateRouteFMs(fm);
                this.generateFirstFM(fm);
            }
        }
    }
    log.info(
            "Virtual network {}, switch {}, route {} between ports {}-{}: {} flow-mod switched to the new path",
            this.getTenantId(), this.getSrcPort().getParentSwitch()
                    .getSwitchName(), this.getRouteId(), this.getSrcPort()
                    .getPortNumber(), this.getDstPort().getPortNumber(),
            counter);
}
 
开发者ID:CoVisor,项目名称:CoVisor,代码行数:57,代码来源:SwitchRoute.java


注:本文中的org.openflow.protocol.action.OFAction.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。