當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。