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


Java OFFlowModify类代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFFlowModify的典型用法代码示例。如果您正苦于以下问题:Java OFFlowModify类的具体用法?Java OFFlowModify怎么用?Java OFFlowModify使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toFlowModify

import org.projectfloodlight.openflow.protocol.OFFlowModify; //导入依赖的package包/类
public static OFFlowModify toFlowModify(OFFlowMod fm) {
	OFVersion version = fm.getVersion();
	OFFlowModify.Builder b = OFFactories.getFactory(version).buildFlowModify();
	if (b.getVersion().compareTo(OFVersion.OF_10) == 0) {
		return b.setActions(fm.getActions())
				.setBufferId(fm.getBufferId())
				.setCookie(fm.getCookie())
				// cookie-mask not supported
				.setFlags(fm.getFlags())
				.setHardTimeout(fm.getHardTimeout())
				.setIdleTimeout(fm.getIdleTimeout())
				// instructions not supported
				.setMatch(fm.getMatch())
				// out-group not supported
				.setOutPort(fm.getOutPort())
				.setPriority(fm.getPriority())
				// table-id not supported
				.setXid(fm.getXid())
				.build();
	} else {
		return b.setActions(fm.getActions())
				.setBufferId(fm.getBufferId())
				.setCookie(fm.getCookie())
				.setCookieMask(fm.getCookieMask()) // added in OF1.1
				.setFlags(fm.getFlags())
				.setHardTimeout(fm.getHardTimeout())
				.setIdleTimeout(fm.getIdleTimeout())
				.setInstructions(fm.getInstructions()) // added in OF1.1
				.setMatch(fm.getMatch())
				.setOutGroup(fm.getOutGroup()) // added in OF1.1
				.setOutPort(fm.getOutPort())
				.setPriority(fm.getPriority())
				.setTableId(fm.getTableId())
				.setXid(fm.getXid())
				.build();
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:38,代码来源:FlowModUtils.java

示例2: testAddFlow

import org.projectfloodlight.openflow.protocol.OFFlowModify; //导入依赖的package包/类
/**
 * Test FlowObject is correctly converted to message and is sent to a switch.
 */
@SuppressWarnings("unchecked")
@Test
public void testAddFlow() {
    Dpid dpid = new Dpid(DPID_TO_VERIFY);

    // instantiate required objects
    FlowEntry flowEntry1 =
            new FlowEntry(DPID_TO_VERIFY, 1, 11, null,
                    null, 0, 0, Operator.ADD);

    beginInitMock();

    OFFlowModify fm = createMock(OFFlowModify.class);

    OFFlowModify.Builder bld = createMock(OFFlowModify.Builder.class);

    expect(bld.setIdleTimeout(anyInt())).andReturn(bld);
    expect(bld.setHardTimeout(anyInt())).andReturn(bld);
    expect(bld.setPriority(anyShort())).andReturn(bld);
    expect(bld.setBufferId(OFBufferId.NO_BUFFER)).andReturn(bld);
    expect(bld.setCookie(U64.of(anyLong()))).andReturn(bld);
    expect(bld.setMatch(anyObject(Match.class))).andReturn(bld);
    expect(bld.setActions((List<OFAction>) anyObject())).andReturn(bld);
    expect(bld.setOutPort(OFPort.of(anyInt()))).andReturn(bld).atLeastOnce();
    expect(bld.build()).andReturn(fm);

    expect(fm.getXid()).andReturn(XID_TO_VERIFY).anyTimes();
    expect(fm.getType()).andReturn(OFType.FLOW_MOD).anyTimes();

    IOFSwitch sw = createConnectedSwitchMock(DPID_TO_VERIFY);

    try {
        sw.write(anyObject(OFMessage.class), eq((FloodlightContext) null));
        expectLastCall().once();
    } catch (IOException e1) {
        fail("Failed in IOFWrite#write()");
    }

    replay(bld, fm);
    replay(sw);

    endInitMock();
    initPusher(1);

    pusher.pushFlowEntry(dpid, flowEntry1);

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        fail("Failed to sleep");
    }

    verify(sw);
    verifyAll();

    pusher.stop();
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:61,代码来源:FlowPusherTest.java


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