本文整理汇总了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;
}
示例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;
}