From 82dfbd6cb1f60fbe88c0b1a0c1420f1dd6a56831 Mon Sep 17 00:00:00 2001 From: Timotej Kubas Date: Fri, 19 Sep 2014 17:37:36 +0200 Subject: [PATCH] BUG-1491: handle SET_TP_SRC/SET_TP_DST actions - set_tp_src/set_tp_dst action corrected for setting of different protocols (UDP,TCP, ICMPv4, ICMPv6) - fixed tests Change-Id: Ia53caaccc57b13d05d9a4ce18e4bf9354e81b69b Signed-off-by: Timotej Kubas Signed-off-by: Michal Rehak --- .../core/sal/convertor/ActionConvertor.java | 135 ++++++++++++++++-- .../md/core/sal/convertor/FlowConvertor.java | 21 +-- .../md/core/sal/convertor/GroupConvertor.java | 2 +- .../md/core/sal/convertor/IPProtocols.java | 46 ++++++ .../sal/convertor/PacketOutConvertor.java | 2 +- .../sal/convertor/ActionConvertorTest.java | 2 +- .../sal/convertor/ActionConvertorV10Test.java | 9 +- .../sal/convertor/ActionConvertorV13Test.java | 8 +- .../sal/convertor/PacketOutConvertorTest.java | 2 +- 9 files changed, 198 insertions(+), 29 deletions(-) create mode 100644 openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java index 796b3e7164..5f1e2f1110 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java @@ -100,12 +100,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; @@ -144,9 +153,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; @@ -158,7 +173,9 @@ import org.slf4j.LoggerFactory; import java.math.BigInteger; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author usha@ericsson Action List:This class takes data from SAL layer and @@ -179,11 +196,12 @@ public final class ActionConvertor { * @param actions SAL actions * @param version Openflow protocol version used * @param datapathid + * @param flow TODO * @return OF Library actions */ public static List getActions( List actions, - short version, BigInteger datapathid) { + short version, BigInteger datapathid, Flow flow) { List actionsList = new ArrayList<>(); Action ofAction; @@ -254,10 +272,14 @@ public final class ActionConvertor { ofAction = SalToOFSetNwSrc(action, actionBuilder, version); else if (action instanceof SetNwDstActionCase) ofAction = SalToOFSetNwDst(action, actionBuilder, version); - else if (action instanceof SetTpSrcActionCase) - ofAction = SalToOFSetTpSrc(action, actionBuilder, version); - else if (action instanceof SetTpDstActionCase) - ofAction = SalToOFSetTpDst(action, actionBuilder, version); + else if (action instanceof SetTpSrcActionCase) { + ofAction = SalToOFSetTpSrc(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch(). + getIpMatch().getIpProtocol())); + } + else if (action instanceof SetTpDstActionCase) { + ofAction = SalToOFSetTpDst(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch(). + getIpMatch().getIpProtocol())); + } else if (action instanceof SetNwTosActionCase) ofAction = SalToOFSetNwTos(action, actionBuilder, version); else if (action instanceof GeneralExtensionGrouping) { @@ -633,7 +655,7 @@ public final class ActionConvertor { private static Action SalToOFSetTpSrc( org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action, - ActionBuilder actionBuilder, short version) { + ActionBuilder actionBuilder, short version, IPProtocols protocol) { if (version == OFConstants.OFP_VERSION_1_0) { SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action; @@ -654,10 +676,36 @@ public final class ActionConvertor { MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder(); matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class); matchEntriesBuilder.setHasMask(false); - matchEntriesBuilder.setOxmMatchField(TcpSrc.class); PortMatchEntryBuilder portMatchEntryBuilder = new PortMatchEntryBuilder(); - portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(settpsrcaction.getPort().getValue().intValue())); - matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build()); + int port = settpsrcaction.getPort().getValue().intValue(); + int type = 0x0f & port; + + switch(protocol) { + case ICMP: + matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class); + Icmpv4TypeMatchEntryBuilder icmpv4TypeMatchEntryBuilder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4TypeMatchEntryBuilder.setIcmpv4Type((short) type); + matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeMatchEntryBuilder.build()); + break; + case ICMPV6: + matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class); + Icmpv6TypeMatchEntryBuilder icmpv6TypeMatchEntryBuilder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6TypeMatchEntryBuilder.setIcmpv6Type((short) type); + matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeMatchEntryBuilder.build()); + break; + case TCP: + matchEntriesBuilder.setOxmMatchField(TcpSrc.class); + portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port)); + matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build()); + break; + case UDP: + matchEntriesBuilder.setOxmMatchField(UdpSrc.class); + portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port)); + matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build()); + break; + default: logger.warn("Unknown protocol with combination of SetSourcePort: {}", protocol); + break; + } actionBuilder .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class); @@ -676,7 +724,7 @@ public final class ActionConvertor { private static Action SalToOFSetTpDst( org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action, - ActionBuilder actionBuilder, short version) { + ActionBuilder actionBuilder, short version, IPProtocols protocol) { if (version == OFConstants.OFP_VERSION_1_0) { SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action; @@ -696,10 +744,36 @@ public final class ActionConvertor { MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder(); matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class); matchEntriesBuilder.setHasMask(false); - matchEntriesBuilder.setOxmMatchField(TcpDst.class); PortMatchEntryBuilder portMatchEntryBuilder = new PortMatchEntryBuilder(); - portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(settpdstaction.getPort().getValue().intValue())); - matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build()); + int port = settpdstaction.getPort().getValue().intValue(); + int code = 0x0f & port; + + switch(protocol) { + case ICMP: + matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class); + Icmpv4CodeMatchEntryBuilder icmpv4CodeMatchEntryBuilder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4CodeMatchEntryBuilder.setIcmpv4Code((short) code); + matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeMatchEntryBuilder.build()); + break; + case ICMPV6: + matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class); + Icmpv6CodeMatchEntryBuilder icmpv6CodeMatchEntryBuilder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6CodeMatchEntryBuilder.setIcmpv6Code((short) code); + matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeMatchEntryBuilder.build()); + break; + case TCP: + matchEntriesBuilder.setOxmMatchField(TcpDst.class); + portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port)); + matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build()); + break; + case UDP: + matchEntriesBuilder.setOxmMatchField(UdpDst.class); + portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port)); + matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build()); + break; + default: logger.warn("Unknown protocol with combination of SetDestinationPort: {}", protocol); + break; + } actionBuilder .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class); @@ -1032,7 +1106,6 @@ public final class ActionConvertor { QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); setQueueAction.setQueueId(queueId.getQueueId()); - return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build(); } @@ -1067,4 +1140,38 @@ public final class ActionConvertor { return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build(); } + //TODO make a model in YANG for protocols + /*private enum IPProtocols { + ICMP(1), + TCP(6), + UDP(17), + ICMPV6(58); + + private int protocol; + + private static Map valueMap; + static { + valueMap = new HashMap<>(); + for(IPProtocols protocols : IPProtocols.values()) { + valueMap.put(protocols.protocol, protocols); + } + } + + private IPProtocols(int value) { + this.protocol = value; + } + + private byte getValue() { + return (byte) this.protocol; + } + + private Short getShortValue() { + return new Short((short) protocol); + } + + private IPProtocols fromProtocolNum(Short protocolNum) { + return valueMap.get(protocolNum); + } + } */ + } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java index e2c6ddae20..b6e37717e6 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertor.java @@ -206,8 +206,8 @@ public class FlowConvertor { MatchReactor.getInstance().convert(flow.getMatch(), version, flowMod,datapathid); if (flow.getInstructions() != null) { - flowMod.setInstruction(toInstructions(flow.getInstructions(), version,datapathid)); - flowMod.setAction(getActions(flow.getInstructions(), version,datapathid)); + flowMod.setInstruction(toInstructions(flow, version,datapathid)); + flowMod.setAction(getActions(version,datapathid, flow)); } flowMod.setVersion(version); @@ -215,10 +215,11 @@ public class FlowConvertor { } private static List toInstructions( - org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions, + Flow flow, short version,BigInteger datapathid) { List instructionsList = new ArrayList<>(); + org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions .getInstruction()) { InstructionBuilder instructionBuilder = new InstructionBuilder(); @@ -257,7 +258,7 @@ public class FlowConvertor { .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class); ActionsInstructionBuilder actionsInstructionBuilder = new ActionsInstructionBuilder(); actionsInstructionBuilder.setAction(ActionConvertor.getActions(writeActions.getAction(), - version,datapathid)); + version,datapathid, flow)); instructionBuilder.addAugmentation(ActionsInstruction.class, actionsInstructionBuilder.build()); instructionsList.add(instructionBuilder.build()); } @@ -269,7 +270,7 @@ public class FlowConvertor { .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class); ActionsInstructionBuilder actionsInstructionBuilder = new ActionsInstructionBuilder(); actionsInstructionBuilder.setAction(ActionConvertor.getActions(applyActions.getAction(), - version,datapathid)); + version,datapathid, flow)); instructionBuilder.addAugmentation(ActionsInstruction.class, actionsInstructionBuilder.build()); instructionsList.add(instructionBuilder.build()); } @@ -297,10 +298,12 @@ public class FlowConvertor { return instructionsList; } - private static List getActions( + /*private static List getActions( org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions, - short version,BigInteger datapathid) { - + short version,BigInteger datapathid) {*/ + private static List getActions(short version,BigInteger datapathid, Flow flow) { + + org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions(); List sortedInstructions = Ordering.from(OrderComparator.toInstance()) .sortedCopy(instructions.getInstruction()); @@ -312,7 +315,7 @@ public class FlowConvertor { if (curInstruction instanceof ApplyActionsCase) { ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction; ApplyActions applyActions = applyActionscase.getApplyActions(); - return ActionConvertor.getActions(applyActions.getAction(), version,datapathid); + return ActionConvertor.getActions(applyActions.getAction(), version,datapathid, flow); } } return null; diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java index 5647d16e4f..26842fbcab 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java @@ -139,7 +139,7 @@ public final class GroupConvertor { bucketBuilder.setWatchPort(new PortNumber(BinContent.intToUnsignedLong(DEFAULT_WATCH_PORT.intValue()))); } - List bucketActionList = ActionConvertor.getActions(groupBucket.getAction(), version,datapathid); + List bucketActionList = ActionConvertor.getActions(groupBucket.getAction(), version,datapathid, null); bucketBuilder.setAction(bucketActionList); BucketsList bucket = bucketBuilder.build(); bucketLists.add(bucket); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java new file mode 100644 index 0000000000..a9b136580d --- /dev/null +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/IPProtocols.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author tkubas + * + */ + +//TODO make a model in YANG for protocols +public enum IPProtocols { + ICMP((short) 1), + TCP((short) 6), + UDP((short) 17), + ICMPV6((short) 58); + + private short protocol; + + private static Map valueMap; + static { + valueMap = new HashMap<>(); + for(IPProtocols protocols : IPProtocols.values()) { + valueMap.put(protocols.protocol, protocols); + } + } + + private IPProtocols(short value) { + this.protocol = value; + } + + private byte getValue() { + return (byte) this.protocol; + } + + public static IPProtocols fromProtocolNum(Short protocolNum) { + return valueMap.get(protocolNum); + } +} diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java index 33a501f2f9..2eeb584f33 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java @@ -97,7 +97,7 @@ public class PacketOutConvertor { actions.add(aBuild.build()); builder.setAction(actions); } else { - builder.setAction(ActionConvertor.getActions(inputPacket.getAction(), version, datapathid)); + builder.setAction(ActionConvertor.getActions(inputPacket.getAction(), version, datapathid, null)); } builder.setData(inputPacket.getPayload()); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java index e6d81db25a..c9d4f09690 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java @@ -128,7 +128,7 @@ public class ActionConvertorTest { setFieldData(); setExperimenterData(); List OFActionsList = ActionConvertor.getActions(actions, (short) 0X4, BigInteger.ONE); + .actions.grouping.Action> OFActionsList = ActionConvertor.getActions(actions, (short) 0X4, BigInteger.ONE, null); // OutputActions(OFActionsList); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV10Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV10Test.java index da9c3c86ac..38d698a9e4 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV10Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV10Test.java @@ -18,6 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.extension.api.path.ActionPath; import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpVersion; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; @@ -45,8 +46,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder; @@ -153,8 +157,11 @@ public class ActionConvertorV10Test { actionBuilder.setOrder(9); salActions.add(actionBuilder.build()); + IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProto(IpVersion.Ipv4); + MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build()); + FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build()); List actions = ActionConvertor.getActions(salActions, EncodeConstants.OF10_VERSION_ID, new BigInteger("42")); + .Action> actions = ActionConvertor.getActions(salActions, EncodeConstants.OF10_VERSION_ID, new BigInteger("42"), flowBld.build()); Assert.assertEquals("Wrong number of actions", 10, actions.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV13Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV13Test.java index ed60aeba4b..ed31683ccb 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV13Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorV13Test.java @@ -53,8 +53,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; @@ -425,8 +428,11 @@ public class ActionConvertorV13Test { actionBuilder.setOrder(11); salActions.add(actionBuilder.build()); + IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProtocol((short) 6); + MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build()); + FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build()); List actions = ActionConvertor.getActions(salActions, EncodeConstants.OF13_VERSION_ID, new BigInteger("42")); + .Action> actions = ActionConvertor.getActions(salActions, EncodeConstants.OF13_VERSION_ID, new BigInteger("42"), flowBld.build()); Assert.assertEquals("Wrong number of actions", 12, actions.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java index 418e4ae26c..be3dd90b53 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java @@ -175,7 +175,7 @@ public class PacketOutConvertorTest{ Short.valueOf(message.getVersion())); Assert.assertEquals(xid, message.getXid()); Assert.assertEquals( - ActionConvertor.getActions(actionList, version, datapathId), + ActionConvertor.getActions(actionList, version, datapathId, null), message.getAction()); Assert.assertEquals(transmitPacketInput.getPayload(), message.getData()); } -- 2.36.6