當前位置: 首頁>>代碼示例>>Java>>正文


Java SetVlanId類代碼示例

本文整理匯總了Java中org.opendaylight.controller.sal.action.SetVlanId的典型用法代碼示例。如果您正苦於以下問題:Java SetVlanId類的具體用法?Java SetVlanId怎麽用?Java SetVlanId使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SetVlanId類屬於org.opendaylight.controller.sal.action包,在下文中一共展示了SetVlanId類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSampleFlowV6

import org.opendaylight.controller.sal.action.SetVlanId; //導入依賴的package包/類
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
    byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34, (byte) 0x9a, (byte) 0xee };
    InetAddress srcIP = InetAddress.getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress.getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMask2 = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Controller());
    actions.add(new SetVlanId(5));
    actions.add(new SetDlDst(newMac));
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:52,代碼來源:frmTest.java

示例2: getSampleFlowV6

import org.opendaylight.controller.sal.action.SetVlanId; //導入依賴的package包/類
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34,
            (byte) 0x9a, (byte) 0xee };
    InetAddress srcIP = InetAddress
            .getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress
            .getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = InetAddress
            .getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMask2 = InetAddress
            .getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Controller());
    actions.add(new SetVlanId(5));
    actions.add(new SetDlDst(newMac));
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    actions.add(new Controller());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:63,代碼來源:FlowTest.java


注:本文中的org.opendaylight.controller.sal.action.SetVlanId類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。