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


Java OFConstants类代码示例

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


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

示例1: createFlow

import org.opendaylight.openflowplugin.api.OFConstants; //导入依赖的package包/类
/**
 * Adds an application flow by using the REST API.
 */
private Flow createFlow(String edge_nodeconnector) {


    FlowBuilder flowBuilder = new FlowBuilder() //
            .setTableId((short) 0) //
            .setFlowName("random");

    //
    flowBuilder.setId(new FlowId(Long.toString(flowBuilder.hashCode())));

    Ipv4Prefix srcIp = new Ipv4Prefix("10.0.0.1/32");
    Ipv4Prefix dstIp = new Ipv4Prefix("10.0.0.2/32");
    Match match = new MatchBuilder()

            .setLayer3Match(new Ipv4MatchBuilder()
                    .setIpv4Source(srcIp)
                    .setIpv4Destination(dstIp)
                    .build())
            .setEthernetMatch(new EthernetMatchBuilder()
                    .setEthernetType(new EthernetTypeBuilder()
                            .setType(new EtherType(0x0800L))
                            .build())
                    .build())
            .build();

    ActionBuilder actionBuilder = new ActionBuilder();
    List<Action> actions = new ArrayList<Action>();

    //Actions
    //currently changing tos and sending to output connector

    Action queueAction = actionBuilder
            .setOrder(0).setAction(new SetQueueActionCaseBuilder()
                .setSetQueueAction(new SetQueueActionBuilder()
                .setQueueId((long)1)
                .build())
            .build())
            .build();
    actions.add(queueAction);

    Action outputNodeConnectorAction = actionBuilder
            .setOrder(1).setAction(new OutputActionCaseBuilder()
                    .setOutputAction(new OutputActionBuilder()
                            .setOutputNodeConnector(new Uri(edge_nodeconnector.split(":")[2]))
                            .build())
                    .build())
            .build();
    actions.add(outputNodeConnectorAction);

    //ApplyActions
    ApplyActions applyActions = new ApplyActionsBuilder().setAction(actions).build();

    //Instruction
    Instruction applyActionsInstruction = new InstructionBuilder() //
            .setOrder(0).setInstruction(new ApplyActionsCaseBuilder()//
                    .setApplyActions(applyActions) //
                    .build()) //
            .build();

    Instructions applyInstructions =  new InstructionsBuilder()
            .setInstruction(ImmutableList.of(applyActionsInstruction))
            .build();

    // Put our Instruction in a list of Instructions
    flowBuilder
            .setMatch(match)
            .setBufferId(OFConstants.OFP_NO_BUFFER)
            .setInstructions(applyInstructions)
            .setPriority(1000)
            .setHardTimeout((int)300)
            .setIdleTimeout(0)
            .setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement())))
            .setFlags(new FlowModFlags(false, false, false, false, false));

    return flowBuilder.build();
}
 
开发者ID:geopet85,项目名称:virtuwind-example,代码行数:80,代码来源:SwitchConfigurator.java


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