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


Java OFFlowMod.setCookie方法代码示例

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


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

示例1: deleteFlow

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
private void deleteFlow(Long switchId, OFFlowStatisticsReply flowStat){
	List<IOFSwitch> switches = this.getSwitches();
	for(IOFSwitch sw : switches){
		if(sw.getId() == switchId){
			OFFlowMod flowMod = new OFFlowMod();
			flowMod.setMatch(flowStat.getMatch().clone());
			flowMod.setIdleTimeout(flowStat.getIdleTimeout());
			flowMod.setHardTimeout(flowStat.getHardTimeout());
			flowMod.setCookie(flowStat.getCookie());
			flowMod.setPriority(flowStat.getPriority());
			flowMod.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
			flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH);
			flowMod.setXid(sw.getNextTransactionId());

			List<OFMessage> msgs = new ArrayList<OFMessage>();
			msgs.add((OFMessage)flowMod);
			
			try {
				sw.write(msgs, null);
			} catch (IOException e) {
				log.error("Error attempting to send flow delete for flow that fits in NO flowspace");
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:27,代码来源:FlowStatCache.java

示例2: verifyFlowMod

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
private void verifyFlowMod(OFFlowMod testFlowMod,
        OFFlowMod goodFlowMod) {
    verifyMatch(testFlowMod, goodFlowMod);
    verifyActions(testFlowMod, goodFlowMod);
    // dont' bother testing the cookie; just copy it over
    goodFlowMod.setCookie(testFlowMod.getCookie());
    // .. so we can continue to use .equals()
    assertEquals(goodFlowMod, testFlowMod);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:10,代码来源:flowProgram.java

示例3: initDefaultFlowMod

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
 * Sets defaults for an OFFlowMod
 * @param fm The OFFlowMod to set defaults for
 * @param entryName The name of the entry. Used to compute the cookie.
 */
public static void initDefaultFlowMod(OFFlowMod fm, String entryName) {
    fm.setIdleTimeout((short) 0);   // infinite
    fm.setHardTimeout((short) 0);   // infinite
    fm.setBufferId(OFPacketOut.BUFFER_ID_NONE);
    fm.setCommand((short) 0);
    fm.setFlags((short) 0);
    fm.setOutPort(OFPort.OFPP_NONE.getValue());
    fm.setCookie(computeEntryCookie(fm, 0, entryName));  
    fm.setPriority(Short.MAX_VALUE);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:16,代码来源:StaticFlowEntries.java

示例4: buildFlowMod

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
 * buildFlowMod - builds a FlowMod based on a flowStat
 * @param flowStat
 * @return OFFlowMod
 */
private OFFlowMod buildFlowMod(OFFlowStatisticsReply flowStat){
	OFFlowMod flowMod = new OFFlowMod();
	flowMod.setMatch(flowStat.getMatch().clone());
	flowMod.setActions(flowStat.getActions());
	flowMod.setPriority(flowStat.getPriority());
	flowMod.setCookie(flowStat.getCookie());
	flowMod.setIdleTimeout(flowStat.getIdleTimeout());
	flowMod.setHardTimeout(flowStat.getHardTimeout());
	return flowMod;
}
 
开发者ID:GlobalNOC,项目名称:FlowSpaceFirewall,代码行数:16,代码来源:FlowStatCache.java

示例5: writeFlowMod

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
 * Writes a OFFlowMod to a switch.
 * @param sw The switch tow rite the flowmod to.
 * @param command The FlowMod actions (add, delete, etc).
 * @param bufferId The buffer ID if the switch has buffered the packet.
 * @param match The OFMatch structure to write.
 * @param outPort The switch port to output it to.
 */
private void writeFlowMod(IOFSwitch sw, short command, int bufferId,
        OFMatch match, short outPort) {
    // from openflow 1.0 spec - need to set these on a struct ofp_flow_mod:
    // struct ofp_flow_mod {
    //    struct ofp_header header;
    //    struct ofp_match match; /* Fields to match */
    //    uint64_t cookie; /* Opaque controller-issued identifier. */
    //
    //    /* Flow actions. */
    //    uint16_t command; /* One of OFPFC_*. */
    //    uint16_t idle_timeout; /* Idle time before discarding (seconds). */
    //    uint16_t hard_timeout; /* Max time before discarding (seconds). */
    //    uint16_t priority; /* Priority level of flow entry. */
    //    uint32_t buffer_id; /* Buffered packet to apply to (or -1).
    //                           Not meaningful for OFPFC_DELETE*. */
    //    uint16_t out_port; /* For OFPFC_DELETE* commands, require
    //                          matching entries to include this as an
    //                          output port. A value of OFPP_NONE
    //                          indicates no restriction. */
    //    uint16_t flags; /* One of OFPFF_*. */
    //    struct ofp_action_header actions[0]; /* The action length is inferred
    //                                            from the length field in the
    //                                            header. */
    //    };

    OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
    flowMod.setMatch(match);
    flowMod.setCookie(LearningSwitch.LEARNING_SWITCH_COOKIE);
    flowMod.setCommand(command);
    flowMod.setIdleTimeout(LearningSwitch.FLOWMOD_DEFAULT_IDLE_TIMEOUT);
    flowMod.setHardTimeout(LearningSwitch.FLOWMOD_DEFAULT_HARD_TIMEOUT);
    flowMod.setPriority(LearningSwitch.FLOWMOD_PRIORITY);
    flowMod.setBufferId(bufferId);
    flowMod.setOutPort((command == OFFlowMod.OFPFC_DELETE) ? outPort : OFPort.OFPP_NONE.getValue());
    flowMod.setFlags((command == OFFlowMod.OFPFC_DELETE) ? 0 : (short) (1 << 0)); // OFPFF_SEND_FLOW_REM

    // set the ofp_action_header/out actions:
    // from the openflow 1.0 spec: need to set these on a struct ofp_action_output:
    // uint16_t type; /* OFPAT_OUTPUT. */
    // uint16_t len; /* Length is 8. */
    // uint16_t port; /* Output port. */
    // uint16_t max_len; /* Max length to send to controller. */
    // type/len are set because it is OFActionOutput,
    // and port, max_len are arguments to this constructor
    flowMod.setActions(Arrays.asList((OFAction) new OFActionOutput(outPort, (short) 0xffff)));
    flowMod.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));

    if (log.isTraceEnabled()) {
        log.trace("{} {} flow mod {}",
                  new Object[]{ sw, (command == OFFlowMod.OFPFC_DELETE) ? "deleting" : "adding", flowMod });
    }

    counterStore.updatePktOutFMCounterStoreLocal(sw, flowMod);

    // and write it out
    try {
        sw.write(flowMod, null);
    } catch (IOException e) {
        log.error("Failed to write {} to switch {}", new Object[]{ flowMod, sw }, e);
    }
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:70,代码来源:LearningSwitch.java

示例6: writeFlowMod

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
 * Writes a OFFlowMod to a switch.
 * @param sw The switch tow rite the flowmod to.
 * @param command The FlowMod actions (add, delete, etc).
 * @param bufferId The buffer ID if the switch has buffered the packet.
 * @param match The OFMatch structure to write.
 * @param outPort The switch port to output it to.
 */
private void writeFlowMod(IOFSwitch sw, short command, int bufferId,
        OFMatch match, short outPort) {
    // from openflow 1.0 spec - need to set these on a struct ofp_flow_mod:
    // struct ofp_flow_mod {
    //    struct ofp_header header;
    //    struct ofp_match match; /* Fields to match */
    //    uint64_t cookie; /* Opaque controller-issued identifier. */
    //
    //    /* Flow actions. */
    //    uint16_t command; /* One of OFPFC_*. */
    //    uint16_t idle_timeout; /* Idle time before discarding (seconds). */
    //    uint16_t hard_timeout; /* Max time before discarding (seconds). */
    //    uint16_t priority; /* Priority level of flow entry. */
    //    uint32_t buffer_id; /* Buffered packet to apply to (or -1).
    //                           Not meaningful for OFPFC_DELETE*. */
    //    uint16_t out_port; /* For OFPFC_DELETE* commands, require
    //                          matching entries to include this as an
    //                          output port. A value of OFPP_NONE
    //                          indicates no restriction. */
    //    uint16_t flags; /* One of OFPFF_*. */
    //    struct ofp_action_header actions[0]; /* The action length is inferred
    //                                            from the length field in the
    //                                            header. */
    //    };
       
    OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
    flowMod.setMatch(match);
    flowMod.setCookie(LearningSwitch.LEARNING_SWITCH_COOKIE);
    flowMod.setCommand(command);
    flowMod.setIdleTimeout(LearningSwitch.IDLE_TIMEOUT_DEFAULT);
    flowMod.setHardTimeout(LearningSwitch.HARD_TIMEOUT_DEFAULT);
    flowMod.setPriority(LearningSwitch.PRIORITY_DEFAULT);
    flowMod.setBufferId(bufferId);
    flowMod.setOutPort((command == OFFlowMod.OFPFC_DELETE) ? outPort : OFPort.OFPP_NONE.getValue());
    flowMod.setFlags((command == OFFlowMod.OFPFC_DELETE) ? 0 : (short) (1 << 0)); // OFPFF_SEND_FLOW_REM

    // set the ofp_action_header/out actions:
    // from the openflow 1.0 spec: need to set these on a struct ofp_action_output:
    // uint16_t type; /* OFPAT_OUTPUT. */
    // uint16_t len; /* Length is 8. */
    // uint16_t port; /* Output port. */
    // uint16_t max_len; /* Max length to send to controller. */
    // type/len are set because it is OFActionOutput,
    // and port, max_len are arguments to this constructor
    flowMod.setActions(Arrays.asList((OFAction) new OFActionOutput(outPort, (short) 0xffff)));
    flowMod.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));

    if (log.isTraceEnabled()) {
        log.trace("{} {} flow mod {}", 
                  new Object[]{ sw, (command == OFFlowMod.OFPFC_DELETE) ? "deleting" : "adding", flowMod });
    }

    counterStore.updatePktOutFMCounterStore(sw, flowMod);
    
    // and write it out
    try {
        sw.write(flowMod, null);
    } catch (IOException e) {
        log.error("Failed to write {} to switch {}", new Object[]{ flowMod, sw }, e);
    }
}
 
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:70,代码来源:LearningSwitch.java

示例7: writeFlowMod

import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
 * Writes a OFFlowMod to a switch.
 * @param sw The switch tow rite the flowmod to.
 * @param command The FlowMod actions (add, delete, etc).
 * @param bufferId The buffer ID if the switch has buffered the packet.
 * @param match The OFMatch structure to write.
 * @param outPort The switch port to output it to.
 */
private void writeFlowMod(IOFSwitch sw, short command, int bufferId,
        OFMatch match, short outPort) {
    // from openflow 1.0 spec - need to set these on a struct ofp_flow_mod:
    // struct ofp_flow_mod {
    //    struct ofp_header header;
    //    struct ofp_match match; /* Fields to match */
    //    uint64_t cookie; /* Opaque controller-issued identifier. */
    //
    //    /* Flow actions. */
    //    uint16_t command; /* One of OFPFC_*. */
    //    uint16_t idle_timeout; /* Idle time before discarding (seconds). */
    //    uint16_t hard_timeout; /* Max time before discarding (seconds). */
    //    uint16_t priority; /* Priority level of flow entry. */
    //    uint32_t buffer_id; /* Buffered packet to apply to (or -1).
    //                           Not meaningful for OFPFC_DELETE*. */
    //    uint16_t out_port; /* For OFPFC_DELETE* commands, require
    //                          matching entries to include this as an
    //                          output port. A value of OFPP_NONE
    //                          indicates no restriction. */
    //    uint16_t flags; /* One of OFPFF_*. */
    //    struct ofp_action_header actions[0]; /* The action length is inferred
    //                                            from the length field in the
    //                                            header. */
    //    };
       
    OFFlowMod flowMod = (OFFlowMod) controllerProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
    flowMod.setMatch(match);
    flowMod.setCookie(LearningSwitch.LEARNING_SWITCH_COOKIE);
    flowMod.setCommand(command);
    flowMod.setIdleTimeout(LearningSwitch.FLOWMOD_DEFAULT_IDLE_TIMEOUT);
    flowMod.setHardTimeout(LearningSwitch.FLOWMOD_DEFAULT_HARD_TIMEOUT);
    flowMod.setPriority(LearningSwitch.FLOWMOD_PRIORITY);
    flowMod.setBufferId(bufferId);
    flowMod.setOutPort((command == OFFlowMod.OFPFC_DELETE) ? outPort : OFPort.OFPP_NONE.getValue());
    flowMod.setFlags((command == OFFlowMod.OFPFC_DELETE) ? 0 : (short) (1 << 0)); // OFPFF_SEND_FLOW_REM

    // set the ofp_action_header/out actions:
    // from the openflow 1.0 spec: need to set these on a struct ofp_action_output:
    // uint16_t type; /* OFPAT_OUTPUT. */
    // uint16_t len; /* Length is 8. */
    // uint16_t port; /* Output port. */
    // uint16_t max_len; /* Max length to send to controller. */
    // type/len are set because it is OFActionOutput,
    // and port, max_len are arguments to this constructor
    flowMod.setActions(Arrays.asList((OFAction) new OFActionOutput(outPort, (short) 0xffff)));
    flowMod.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));

    if (log.isTraceEnabled()) {
        log.trace("{} {} flow mod {}", 
                  new Object[]{ sw, (command == OFFlowMod.OFPFC_DELETE) ? "deleting" : "adding", flowMod });
    }

    counterStore.updatePktOutFMCounterStore(sw, flowMod);
    
    // and write it out
    try {
        sw.write(flowMod, null);
    } catch (IOException e) {
        log.error("Failed to write {} to switch {}", new Object[]{ flowMod, sw }, e);
    }
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:70,代码来源:LearningSwitch.java


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