本文整理汇总了Java中org.opendaylight.controller.sal.action.Action类的典型用法代码示例。如果您正苦于以下问题:Java Action类的具体用法?Java Action怎么用?Java Action使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Action类属于org.opendaylight.controller.sal.action包,在下文中一共展示了Action类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: actionsFromJson
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
/**
* Create OpenDaylight actions from JSON specifications.
*
* @param node the node to be programmed (required for specifying valid output actions with correct node connectors)
* @param actionsJson JSON array specifying actions
* @return list of created OpenDaylight actions
*/
private List<Action> actionsFromJson(Node node, JSONArray actionsJson) throws JSONException {
List<Action> actions = new LinkedList<Action>();
for (int i = 0; i < actionsJson.length(); i++) {
JSONObject actionJson = actionsJson.getJSONObject(i);
Action action = parseAction(node, actionJson);
if (action == null) {
log.error("Invalid action: " + actionJson.toString());
return null;
} else {
actions.add(action);
}
}
return actions;
}
开发者ID:duerrfk,项目名称:sdn-mq,代码行数:24,代码来源:FlowProgrammer.java
示例2: testFlowEntries
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Test
public void testFlowEntries() {
Flow flow = new Flow();
Match match = new Match();
try {
match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1"));
} catch (UnknownHostException e) {
}
flow.setMatch(match);
Action action = new Drop();
List<Action> actions = new ArrayList<Action>();
actions.add(action);
flow.setActions(actions);
Node node = NodeCreator.createOFNode(1L);
FlowEntry fe = new FlowEntry("g1", "f1", flow, node);
Status stat = manager.installFlowEntry(fe);
// OF plugin is not there in integration testing mode
Assert.assertTrue(stat.getCode() == StatusCode.NOSERVICE);
}
开发者ID:lbchen,项目名称:ODL,代码行数:25,代码来源:ForwardingRulesManagerIT.java
示例3: removeOutputPort
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Override
public void removeOutputPort(Node node, String flowName, List<NodeConnector> portList) {
for (FlowEntryInstall index : this.nodeFlows.get(node)) {
FlowEntryInstall flow = this.installedSwView.get(index);
if (flow.getFlowName().equals(flowName)) {
FlowEntry currentFlowEntry = flow.getOriginal();
FlowEntry newFlowEntry = currentFlowEntry.clone();
for (NodeConnector dstPort : portList) {
Action action = new Output(dstPort);
newFlowEntry.getFlow().removeAction(action);
}
Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);
if (status.isSuccess()) {
log.info("Ports {} removed from FlowEntry {}", portList, flowName);
} else {
log.warn("Failed to remove ports {} from Flow entry {}. The failure is: {}", portList,
currentFlowEntry.toString(), status.getDescription());
}
return;
}
}
log.warn("Failed to remove ports from Flow {} on Node {}: Entry Not Found", flowName, node);
}
开发者ID:lbchen,项目名称:ODL,代码行数:24,代码来源:ForwardingRulesManager.java
示例4: actionsAreIPv6
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
/**
* Returns true if it finds at least one action which is for IPv6 in the
* list of actions for this Flow
*
* @return
*/
private boolean actionsAreIPv6() {
if (this.actions != null) {
for (Action action : actions) {
switch (action.getType()) {
case SET_NW_SRC:
if (((SetNwSrc) action).getAddress() instanceof Inet6Address) {
return true;
}
break;
case SET_NW_DST:
if (((SetNwDst) action).getAddress() instanceof Inet6Address) {
return true;
}
break;
case SET_DL_TYPE:
if (((SetDlType) action).getDlType() == EtherTypes.IPv6.intValue()) {
return true;
}
break;
default:
}
}
}
return false;
}
开发者ID:lbchen,项目名称:ODL,代码行数:32,代码来源:Flow.java
示例5: testFlowActions
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Test
public void testFlowActions() throws UnknownHostException {
Node node = NodeCreator.createOFNode(55l);
Flow flow = getSampleFlowV6(node);
List<Action> actions = flow.getActions();
actions.add(new Loopback());
Assert.assertTrue(flow.getActions() != actions);
Assert.assertTrue(!flow.getActions().equals(actions));
flow.addAction(new Loopback());
Assert.assertTrue(flow.getActions().equals(actions));
actions.remove(new Loopback());
flow.removeAction(new Loopback());
Assert.assertTrue(flow.getActions().equals(actions));
// Add a malformed action
Assert.assertFalse(flow.addAction(new PushVlan(EtherTypes.CISCOQINQ, 3,
3, 8000)));
}
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:FlowTest.java
示例6: flowPortsBelongToContainer
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
/**
* Check whether the ports in the flow match and flow actions for
* the specified node belong to the container
*
* @param container
* @param node
* @param flow
* @return
*/
private boolean flowPortsBelongToContainer(String container, Node node,
Flow flow) {
Match m = flow.getMatch();
if (m.isPresent(MatchType.IN_PORT)) {
NodeConnector inPort = (NodeConnector) m.getField(MatchType.IN_PORT).getValue();
// If the incoming port is specified, check if it belongs to
if (!containerOwnsNodeConnector(container, inPort)) {
return false;
}
}
// If an outgoing port is specified, it must belong to this container
for (Action action : flow.getActions()) {
if (action.getType() == ActionType.OUTPUT) {
NodeConnector outPort = ((Output) action).getPort();
if (!containerOwnsNodeConnector(container, outPort)) {
return false;
}
}
}
return true;
}
开发者ID:lbchen,项目名称:ODL,代码行数:32,代码来源:ReadServiceFilter.java
示例7: testFlowEntrySet
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Test
public void testFlowEntrySet() throws UnknownHostException {
Set<FlowEntry> set = new HashSet<FlowEntry>();
Node node1 = NodeCreator.createOFNode(1L);
Node node2 = NodeCreator.createOFNode(2L);
Node node3 = NodeCreator.createOFNode(3L);
Match match = new Match();
match.setField(MatchType.NW_SRC, InetAddress.getAllByName("1.1.1.1"));
match.setField(MatchType.NW_DST, InetAddress.getAllByName("2.2.2.2"));
match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
List<Action> actionList = new ArrayList<Action>();
// actionList.add(new Drop());
Flow flow = new Flow(match, actionList);
FlowEntry pol1 = new FlowEntry("m1", "same", flow, node1);
FlowEntry pol2 = new FlowEntry("m2", "same", flow, node2);
FlowEntry pol3 = new FlowEntry("m3", "same", flow, node3);
set.add(pol1);
set.add(pol2);
set.add(pol3);
Assert.assertTrue(set.contains(pol1));
Assert.assertTrue(set.contains(pol2));
Assert.assertTrue(set.contains(pol3));
Assert.assertTrue(set.contains(pol1.clone()));
Assert.assertTrue(set.contains(pol2.clone()));
Assert.assertTrue(set.contains(pol3.clone()));
}
开发者ID:lbchen,项目名称:ODL,代码行数:35,代码来源:frmTest.java
示例8: getOutputPort
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Override
public NodeConnector getOutputPort(Node node, String flowName) {
for (FlowEntryInstall index : this.nodeFlows.get(node)) {
FlowEntryInstall flow = this.installedSwView.get(index);
if (flow.getFlowName().equals(flowName)) {
for (Action action : flow.getOriginal().getFlow().getActions()) {
if (action.getType() == ActionType.OUTPUT) {
return ((Output) action).getPort();
}
}
}
}
return null;
}
开发者ID:lbchen,项目名称:ODL,代码行数:15,代码来源:ForwardingRulesManager.java
示例9: Flow
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
public Flow(Match match, List<Action> actions) {
if (match.isIPv4() && actionsAreIPv6()) {
try {
throw new Exception("Conflicting Match and Action list");
} catch (Exception e) {
logger.error("", e);
}
} else {
this.match = match;
this.actions = actions;
}
}
开发者ID:lbchen,项目名称:ODL,代码行数:13,代码来源:Flow.java
示例10: setActions
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
/**
* Set the actions list for this flow If a list is already present, it will
* be replaced with the passed one. During addition, only the valid actions
* will be added It is a no op if the passed actions is null An empty
* actions is a vlaid input
*
* @param actions
*/
public void setActions(List<Action> actions) {
if (actions == null) {
return;
}
this.actions = new ArrayList<Action>(actions.size());
for (Action action : actions) {
if (action.isValid()) {
this.actions.add(action);
}
}
}
开发者ID:lbchen,项目名称:ODL,代码行数:21,代码来源:Flow.java
示例11: removeAction
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
/**
* remove ALL actions of type actionType from the list of actions of this
* flow
*
* @param actionType
* @return false if an action of that type is present and it fails to remove
* it
*/
public boolean removeAction(ActionType actionType) {
Iterator<Action> actionIter = this.getActions().iterator();
while (actionIter.hasNext()) {
Action action = actionIter.next();
if (action.getType() == actionType) {
if (!this.removeAction(action)) {
return false;
}
}
}
return true;
}
开发者ID:lbchen,项目名称:ODL,代码行数:21,代码来源:Flow.java
示例12: testFlowEquality
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Test
public void testFlowEquality() throws Exception {
Node node = NodeCreator.createOFNode(1055l);
Flow flow1 = getSampleFlowV6(node);
Flow flow2 = getSampleFlowV6(node);
Flow flow3 = getSampleFlow(node);
// Check Match equality
Assert.assertTrue(flow1.getMatch().equals(flow2.getMatch()));
// Check Actions equality
for (int i = 0; i < flow1.getActions().size(); i++) {
Action a = flow1.getActions().get(i);
Action b = flow2.getActions().get(i);
Assert.assertTrue(a != b);
Assert.assertTrue(a.equals(b));
}
Assert.assertTrue(flow1.equals(flow2));
Assert.assertFalse(flow2.equals(flow3));
// Check Flow equality where Flow has null action list (pure match)
List<Action> emptyList = new ArrayList<Action>(1);
Flow x = flow1.clone();
x.setActions(emptyList);
Assert.assertFalse(flow1.equals(x));
flow1.setActions(emptyList);
Assert.assertTrue(flow1.equals(x));
}
开发者ID:lbchen,项目名称:ODL,代码行数:30,代码来源:FlowTest.java
示例13: testFlowOnNodeMethods
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Test
public void testFlowOnNodeMethods () {
Match match = new Match();
NodeConnector inNC = NodeConnectorCreator.createNodeConnector((short)10, NodeCreator.createOFNode((long)10));
NodeConnector outNC = NodeConnectorCreator.createNodeConnector((short)20, NodeCreator.createOFNode((long)20));
match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
match.setField(MatchType.IN_PORT, inNC);
Output output = new Output(outNC);
ArrayList<Action> action = new ArrayList<Action>();
action.add(output);
Flow flow = new Flow (match, action);
FlowOnNode flowOnNode = new FlowOnNode (flow);
Assert.assertTrue(flowOnNode.getFlow().equals(flow));
flowOnNode.setPacketCount((long)100);
flowOnNode.setByteCount((long)800);
flowOnNode.setTableId((byte)0x55);
flowOnNode.setDurationNanoseconds(40);
flowOnNode.setDurationSeconds(45);
Assert.assertTrue(flowOnNode.getPacketCount() == 100);
Assert.assertTrue(flowOnNode.getByteCount() == 800);
Assert.assertTrue(flowOnNode.getDurationNanoseconds() == 40);
Assert.assertTrue(flowOnNode.getDurationSeconds() == 45);
Assert.assertTrue(flowOnNode.getTableId() == (byte)0x55);
}
开发者ID:lbchen,项目名称:ODL,代码行数:32,代码来源:FlowOnNodeTest.java
示例14: getSampleFlowV6
import org.opendaylight.controller.sal.action.Action; //导入依赖的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
示例15: replaceOutputPort
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
@Override
public void replaceOutputPort(Node node, String flowName, NodeConnector outPort) {
FlowEntry currentFlowEntry = null;
FlowEntry newFlowEntry = null;
// Find the flow
for (FlowEntryInstall index : this.nodeFlows.get(node)) {
FlowEntryInstall flow = this.installedSwView.get(index);
if (flow.getFlowName().equals(flowName)) {
currentFlowEntry = flow.getOriginal();
break;
}
}
if (currentFlowEntry == null) {
log.warn("Failed to replace output port for flow {} on node {}: Entry Not Found", flowName, node);
return;
}
// Create a flow copy with the new output port
newFlowEntry = currentFlowEntry.clone();
Action target = null;
for (Action action : newFlowEntry.getFlow().getActions()) {
if (action.getType() == ActionType.OUTPUT) {
target = action;
break;
}
}
newFlowEntry.getFlow().removeAction(target);
newFlowEntry.getFlow().addAction(new Output(outPort));
// Modify on network node
Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);
if (status.isSuccess()) {
log.info("Output port replaced with {} for flow {} on node {}", outPort, flowName, node);
} else {
log.warn("Failed to replace output port for flow {} on node {}. The failure is: {}", flowName, node,
status.getDescription());
}
return;
}
开发者ID:lbchen,项目名称:ODL,代码行数:42,代码来源:ForwardingRulesManager.java
示例16: getSampleFlow
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
private Flow getSampleFlow(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 };
InetAddress srcIP = InetAddress.getByName("172.28.30.50");
InetAddress dstIP = InetAddress.getByName("171.71.9.52");
InetAddress ipMask = InetAddress.getByName("255.255.255.0");
InetAddress ipMask2 = InetAddress.getByName("255.0.0.0");
short ethertype = EtherTypes.IPv4.shortValue();
short vlan = (short) 27;
byte vlanPr = 3;
Byte tos = 4;
byte proto = IPProtocols.TCP.byteValue();
short src = (short) 55000;
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 Output(oport));
actions.add(new PopVlan());
actions.add(new Flood());
actions.add(new Controller());
return new Flow(match, actions);
}
开发者ID:lbchen,项目名称:ODL,代码行数:42,代码来源:ForwardingRulesManager.java
示例17: allowsFlow
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
/**
* Returns whether the specified flow is allowed
*
* @return true if the flow is allowed, false otherwise
*/
public boolean allowsFlow(Flow flow) {
Match target = flow.getMatch();
// Check if flow's match is allowed
if (!this.allowsMatch(target)) {
return false;
}
// Now check if the flow's actions are not allowed
// Create a Match which summarizes the list of actions
if (flow.getActions() == null) {
return true;
}
Match actionMatch = new Match();
for (Action action : flow.getActions()) {
switch (action.getType()) {
case SET_DL_TYPE:
actionMatch.setField(MatchType.DL_TYPE,
((Integer) ((SetDlType) action).getDlType())
.shortValue());
break;
case SET_NW_SRC:
actionMatch.setField(MatchType.NW_SRC, ((SetNwSrc) action)
.getAddress());
break;
case SET_NW_DST:
actionMatch.setField(MatchType.NW_DST, ((SetNwDst) action)
.getAddress());
break;
case SET_TP_SRC:
actionMatch.setField(MatchType.TP_SRC,
((Integer) ((SetTpSrc) action).getPort()).shortValue());
break;
case SET_TP_DST:
actionMatch.setField(MatchType.TP_DST,
((Integer) ((SetTpDst) action).getPort()).shortValue());
break;
default:
// This action cannot conflict
}
}
return this.allowsMatch(actionMatch);
}
开发者ID:lbchen,项目名称:ODL,代码行数:50,代码来源:ContainerFlow.java
示例18: getSampleFlow
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
private Flow getSampleFlow(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 };
InetAddress srcIP = InetAddress.getByName("172.28.30.50");
InetAddress dstIP = InetAddress.getByName("171.71.9.52");
InetAddress newIP = InetAddress.getByName("200.200.100.1");
InetAddress ipMask = InetAddress.getByName("255.255.255.0");
InetAddress ipMask2 = InetAddress.getByName("255.240.0.0");
short ethertype = EtherTypes.IPv4.shortValue();
short vlan = (short) 27;
byte vlanPr = 3;
Byte tos = 4;
byte proto = IPProtocols.TCP.byteValue();
short src = (short) 55000;
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 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) 100);
flow.setHardTimeout((short) 360);
return flow;
}
开发者ID:lbchen,项目名称:ODL,代码行数:53,代码来源:FlowTest.java
示例19: getSampleFlowV6
import org.opendaylight.controller.sal.action.Action; //导入依赖的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
示例20: getSampleFlow
import org.opendaylight.controller.sal.action.Action; //导入依赖的package包/类
private Flow getSampleFlow(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 };
InetAddress srcIP = InetAddress.getByName("172.28.30.50");
InetAddress dstIP = InetAddress.getByName("171.71.9.52");
InetAddress ipMask = InetAddress.getByName("255.255.255.0");
InetAddress ipMask2 = InetAddress.getByName("255.0.0.0");
short ethertype = EtherTypes.IPv4.shortValue();
short vlan = (short) 27;
byte vlanPr = 3;
Byte tos = 4;
byte proto = IPProtocols.TCP.byteValue();
short src = (short) 55000;
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 Output(oport));
actions.add(new PopVlan());
actions.add(new Flood());
actions.add(new Controller());
return new Flow(match, actions);
}
开发者ID:lbchen,项目名称:ODL,代码行数:46,代码来源:ReadService.java
注:本文中的org.opendaylight.controller.sal.action.Action类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论