package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
import com.google.common.collect.Ordering;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
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.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.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;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.DlAddressActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.EthertypeActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.GroupIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MaxLengthActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmFieldsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.QueueIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.VlanVidActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
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.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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
* actions
*/
public final class ActionConvertor {
- private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
+ private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
private ActionConvertor() {
// NOOP
* @param actions SAL actions
* @param version Openflow protocol version used
* @param datapathid
+ * @param flow TODO
* @return OF Library actions
*/
public static List<Action> getActions(
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
- short version, BigInteger datapathid) {
+ short version, BigInteger datapathid, Flow flow) {
List<Action> actionsList = new ArrayList<>();
Action ofAction;
- actions = Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>toInstance())
- .sortedCopy(actions);
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions =
+ Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build())
+ .sortedCopy(actions);
- for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
+ for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) {
ofAction = null;
ActionBuilder actionBuilder = new ActionBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = actions.get(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = sortedActions.get(
actionItem).getAction();
- if (action instanceof OutputActionCase)
- ofAction = salToOFOutputAction(action, actionBuilder, version);
- else if (action instanceof GroupActionCase)
- ofAction = SalToOFGroupAction(action, actionBuilder);
- else if (action instanceof CopyTtlOutCase)
- ofAction = SalToOFCopyTTLIOut(actionBuilder);
- else if (action instanceof CopyTtlInCase)
- ofAction = SalToOFCopyTTLIIn(actionBuilder);
- else if (action instanceof SetMplsTtlActionCase)
- ofAction = SalToOFSetMplsTtl(action, actionBuilder);
- else if (action instanceof DecMplsTtlCase)
- ofAction = SalToOFDecMplsTtl(actionBuilder);
- else if (action instanceof PushVlanActionCase)
- ofAction = SalToOFPushVlanAction(action, actionBuilder, version);
- else if (action instanceof PopVlanActionCase)
+ if (action instanceof OutputActionCase) {
+ ofAction = salToOFAction((OutputActionCase) action, actionBuilder, version);
+ } else if (action instanceof GroupActionCase) {
+ ofAction = salToOFGroupAction(action, actionBuilder);
+ } else if (action instanceof CopyTtlOutCase) {
+ ofAction = salToOFCopyTTLIOut(actionBuilder);
+ } else if (action instanceof CopyTtlInCase) {
+ ofAction = salToOFCopyTTLIIn(actionBuilder);
+ } else if (action instanceof SetMplsTtlActionCase) {
+ ofAction = salToOFSetMplsTtl(action, actionBuilder);
+ } else if (action instanceof DecMplsTtlCase) {
+ ofAction = salToOFDecMplsTtl(actionBuilder);
+ } else if (action instanceof PushVlanActionCase) {
+ ofAction = salToOFPushVlanAction(action, actionBuilder, version);
+ } else if (action instanceof PopVlanActionCase) {
ofAction = (version == OFConstants.OFP_VERSION_1_0) ?
- SalToOFStripVlan(actionBuilder, version)
- : SalToOFPopVlan(actionBuilder);
- else if (action instanceof PushMplsActionCase)
- ofAction = SalToOFPushMplsAction(action, actionBuilder);
- else if (action instanceof PopMplsActionCase)
- ofAction = SalToOFPopMpls(action, actionBuilder);
- else if (action instanceof SetQueueActionCase)
- ofAction = SalToOFSetQueue(action, actionBuilder);
- else if (action instanceof SetNwTtlActionCase)
- ofAction = SalToOFSetNwTtl(action, actionBuilder);
- else if (action instanceof DecNwTtlCase)
- ofAction = SalToOFDecNwTtl(actionBuilder);
- else if (action instanceof SetFieldCase)
- ofAction = SalToOFSetField(action, actionBuilder, version, datapathid);
- else if (action instanceof PushPbbActionCase)
- ofAction = SalToOFPushPbbAction(action, actionBuilder);
- else if (action instanceof PopPbbActionCase)
- ofAction = SalToOFPopPBB(actionBuilder);
+ salToOFStripVlan(actionBuilder, version)
+ : salToOFPopVlan(actionBuilder);
+ } else if (action instanceof PushMplsActionCase) {
+ ofAction = salToOFPushMplsAction(action, actionBuilder);
+ } else if (action instanceof PopMplsActionCase) {
+ ofAction = salToOFPopMpls(action, actionBuilder);
+ } else if (action instanceof SetQueueActionCase) {
+ ofAction = salToOFSetQueue(action, actionBuilder);
+ } else if (action instanceof SetNwTtlActionCase) {
+ ofAction = salToOFSetNwTtl(action, actionBuilder);
+ } else if (action instanceof DecNwTtlCase) {
+ ofAction = salToOFDecNwTtl(actionBuilder);
+ } else if (action instanceof SetFieldCase) {
+ ofAction = salToOFSetField(action, actionBuilder, version, datapathid);
+ } else if (action instanceof PushPbbActionCase) {
+ ofAction = salToOFPushPbbAction(action, actionBuilder);
+ } else if (action instanceof PopPbbActionCase) {
+ ofAction = salToOFPopPBB(actionBuilder);
// 1.0 Actions
- else if (action instanceof SetVlanIdActionCase) {
+ } else if (action instanceof SetVlanIdActionCase) {
/*if (version == OFConstants.OFP_VERSION_1_0) {
} else {
List<Action> setVlanIdActionsList = convertToOF13(action, actionBuilder);
actionsList.addAll(setVlanIdActionsList);
}*/
- ofAction = SalToOFSetVlanId(action, actionBuilder, version);
- }
- else if (action instanceof SetVlanPcpActionCase)
- ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
- else if (action instanceof StripVlanActionCase)
- ofAction = SalToOFStripVlan(actionBuilder, version);
- else if (action instanceof SetDlSrcActionCase)
- ofAction = SalToOFSetDlSrc(action, actionBuilder, version);
- else if (action instanceof SetDlDstActionCase)
- ofAction = SalToOFSetDlDst(action, actionBuilder, version);
- else if (action instanceof SetNwSrcActionCase)
- 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 SetNwTosActionCase)
- ofAction = SalToOFSetNwTos(action, actionBuilder, version);
- else if (action instanceof GeneralExtensionGrouping) {
-
+ ofAction = salToOFSetVlanId(action, actionBuilder, version);
+ } else if (action instanceof SetVlanPcpActionCase) {
+ ofAction = salToOFSetVlanpcp(action, actionBuilder, version);
+ } else if (action instanceof StripVlanActionCase) {
+ ofAction = salToOFStripVlan(actionBuilder, version);
+ } else if (action instanceof SetDlSrcActionCase) {
+ ofAction = salToOFSetDlSrc(action, actionBuilder, version);
+ } else if (action instanceof SetDlDstActionCase) {
+ ofAction = salToOFSetDlDst(action, actionBuilder, version);
+ } else if (action instanceof SetNwSrcActionCase) {
+ 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, 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) {
+
/**
* TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
* - we might need sessionContext as converter input
- *
+ *
*/
-
+
GeneralExtensionGrouping extensionCaseGrouping = (GeneralExtensionGrouping) action;
Extension extAction = extensionCaseGrouping.getExtension();
ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionCaseGrouping.getExtensionKey(), version);
- ConvertorToOFJava<Action> convertor =
+ ConvertorToOFJava<Action> convertor =
OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
if (convertor != null) {
ofAction = convertor.convert(extAction);
new TypeVersionKey<>(
(Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) action.getImplementedInterface(),
version);
- ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
+ ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
if (convertor != null) {
ofAction = convertor.convert(action);
}
}
-
+
if (ofAction != null) {
actionsList.add(ofAction);
}
return actionsList;
}
- private static Action SalToOFSetField(
+ private static Action salToOFSetField(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version, BigInteger datapathid) {
SetFieldCase setFieldCase = (SetFieldCase) action;
org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match =
- setFieldCase.getSetField();
+ setFieldCase.getSetField();
if (version == OFConstants.OFP_VERSION_1_0) {
// pushvlan +setField can be called to configure 1.0 switches via MDSAL app
VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
vlanidActionBuilder.setVlanVid(match.getVlanMatch().getVlanId().getVlanId().getValue());
actionBuilder.setType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
return actionBuilder.build();
} else {
MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
actionBuilder.setType(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
}
- private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
+ private static Action salToOFDecNwTtl(ActionBuilder actionBuilder) {
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
return emtpyAction(actionBuilder);
}
- private static Action SalToOFPushMplsAction(
+ private static Action salToOFPushMplsAction(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
actionBuilder.setType(PushMpls.class);
- return SalToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
+ return salToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
}
- private static Action SalToOFPushPbbAction(
+ private static Action salToOFPushPbbAction(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
actionBuilder.setType(PushPbb.class);
- return SalToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
+ return salToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
}
- private static Action SalToOFPushVlanAction(
+ private static Action salToOFPushVlanAction(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
if (version == OFConstants.OFP_VERSION_1_0) {
PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
actionBuilder.setType(PushVlan.class);
- return SalToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
+ return salToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
}
- private static Action SalToOFSetNwTtl(
+ private static Action salToOFSetNwTtl(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
return actionBuilder.build();
}
- private static Action SalToOFSetQueue(
+ private static Action salToOFSetQueue(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
return actionBuilder.build();
}
- private static Action SalToOFPopMpls(
+ private static Action salToOFPopMpls(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
actionBuilder.setType(PopMpls.class);
- return SalToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
+ return salToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
}
- private static Action SalToOFPopVlan(ActionBuilder actionBuilder) {
+ private static Action salToOFPopVlan(ActionBuilder actionBuilder) {
actionBuilder.setType(PopVlan.class);
return emtpyAction(actionBuilder);
}
- private static Action SalToOFPopPBB(ActionBuilder actionBuilder) {
+ private static Action salToOFPopPBB(ActionBuilder actionBuilder) {
actionBuilder.setType(PopPbb.class);
return emtpyAction(actionBuilder);
}
// set-vlan-id (1.0 feature) can be called on 1.3 switches as well using ADSAL apis
- private static Action SalToOFSetVlanId(
+ private static Action salToOFSetVlanId(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
return actionBuilder.build();
- } else if (version >= OFConstants.OFP_VERSION_1_3) {
- OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
- actionBuilder
- .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
- List<MatchEntries> matchEntriesList = new ArrayList<>();
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
- matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntriesBuilder.setOxmMatchField(VlanVid.class);
- VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
- vlanVidBuilder.setCfiBit(true);
- vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
- matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
- matchEntriesBuilder.setHasMask(false);
- matchEntriesList.add(matchEntriesBuilder.build());
- oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
- actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
- return actionBuilder.build();
} else {
- logger.error("Unknown Action Type for the Version", version);
- return null;
+ if (version >= OFConstants.OFP_VERSION_1_3) {
+ OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
+ actionBuilder
+ .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntriesBuilder = new MatchEntryBuilder();
+ matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntriesBuilder.setOxmMatchField(VlanVid.class);
+ VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+ VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+ vlanVidBuilder.setCfiBit(true);
+ vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
+ vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+ matchEntriesBuilder.setHasMask(false);
+ matchEntriesList.add(matchEntriesBuilder.build());
+ oxmFieldsActionBuilder.setMatchEntry(matchEntriesList);
+ actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
+ return actionBuilder.build();
+ } else {
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
+ return null;
+ }
}
}
- private static Action SalToOFSetVlanpcp(
+ private static Action salToOFSetVlanpcp(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
- List<MatchEntries> matchEntriesList = new ArrayList<>();
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
- oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
+ oxmFieldsActionBuilder.setMatchEntry(matchEntriesList);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
} else {
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
}
- private static Action SalToOFStripVlan(ActionBuilder actionBuilder, short version) {
+ private static Action salToOFStripVlan(ActionBuilder actionBuilder, short version) {
if (version == OFConstants.OFP_VERSION_1_0) {
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
- List<MatchEntries> matchEntriesList = new ArrayList<>();
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntriesBuilder = new MatchEntryBuilder();
matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntriesBuilder.setOxmMatchField(VlanVid.class);
- VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
+ VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+ VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setCfiBit(true);
vlanVidBuilder.setVlanVid(0x0000);
- matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
+ vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
matchEntriesBuilder.setHasMask(false);
matchEntriesList.add(matchEntriesBuilder.build());
- oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
+ oxmFieldsActionBuilder.setMatchEntry(matchEntriesList);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
} else {
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
}
- private static Action SalToOFSetDlSrc(
+ private static Action salToOFSetDlSrc(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
- List<MatchEntries> matchEntriesList = new ArrayList<>();
- matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
- oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
+ EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
+ ethSrcBuilder.setMacAddress(setdlsrcaction.getAddress());
+ ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
+ matchEntryBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
+ matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntryBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc.class);
+ matchEntryBuilder.setHasMask(false);
+ matchEntriesList.add(matchEntryBuilder.build());
+ oxmFieldsActionBuilder.setMatchEntry(matchEntriesList);
+
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
} else {
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
}
- private static Action SalToOFSetDlDst(
+ private static Action salToOFSetDlDst(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
- List<MatchEntries> matchEntriesList = new ArrayList<>();
- matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
- oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntryBuilder.setOxmMatchField(EthDst.class);
+ EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
+ EthDstBuilder ethDstBuilder = new EthDstBuilder();
+ ethDstBuilder.setMacAddress(setdldstaction.getAddress());
+ matchEntryBuilder.setHasMask(false);
+
+ ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
+ matchEntryBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
+
+ matchEntriesList.add(matchEntryBuilder.build());
+ oxmFieldsActionBuilder.setMatchEntry(matchEntriesList);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
} else {
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
}
- protected static Action SalToOFSetNwSrc(
+ protected static Action salToOFSetNwSrc(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
try {
ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
return null;
}
return actionBuilder.build();
}
- protected static Action SalToOFSetNwDst(
+ protected static Action salToOFSetNwDst(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
try {
ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ LOG.error(e.getMessage(), e);
return null;
}
return actionBuilder.build();
}
- private static Action SalToOFSetNwTos(
+ private static Action salToOFSetNwTos(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
- List<MatchEntries> matchEntriesList = new ArrayList<>();
- matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
- oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(
+ ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
+ )));
+ oxmFieldsActionBuilder.setMatchEntry(matchEntriesList);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
} else {
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
}
- private static Action SalToOFSetTpSrc(
+ 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;
} else if (version == OFConstants.OFP_VERSION_1_3) {
SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
-
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
+
+ MatchEntryBuilder matchEntriesBuilder = new MatchEntryBuilder();
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());
-
+
+ InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
+ int port = settpsrcaction.getPort().getValue().intValue();
+ int type = 0x0f & port;
+
+ switch (protocol) {
+ case ICMP:
+ matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
+ Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
+ Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
+ icmpv4TypeBuilder.setIcmpv4Type((short) type);
+ icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
+ break;
+ case ICMPV6:
+ matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
+ Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
+ Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
+ icmpv6TypeBuilder.setIcmpv6Type((short) type);
+ icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
+ break;
+ case TCP:
+ matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
+ TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
+ TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
+ tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+ tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
+ break;
+ case UDP:
+ matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
+ UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
+ UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
+ udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+ udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
+ break;
+ default:
+ LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+ break;
+ }
+
actionBuilder
- .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
-
+ .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
- List<MatchEntries> matchEntries = new ArrayList<MatchEntries>();
+ List<MatchEntry> matchEntries = new ArrayList<MatchEntry>();
matchEntries.add(matchEntriesBuilder.build());
- oxmFieldsActionBuilder.setMatchEntries(matchEntries);
+ oxmFieldsActionBuilder.setMatchEntry(matchEntries);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
}
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
- private static Action SalToOFSetTpDst(
+ 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;
} else if (version == OFConstants.OFP_VERSION_1_3) {
SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
-
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
+
+ MatchEntryBuilder matchEntriesBuilder = new MatchEntryBuilder();
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(Icmpv4Type.class);
+ Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
+ Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
+ icmpv4CodeBuilder.setIcmpv4Code((short) code);
+ icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
+ break;
+ case ICMPV6:
+ matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
+ Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
+ Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
+ icmpv6CodeBuilder.setIcmpv6Code((short) code);
+ icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
+ break;
+ case TCP:
+ matchEntriesBuilder.setOxmMatchField(TcpDst.class);
+ TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
+ TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
+ tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+ tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
+ break;
+ case UDP:
+ matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
+ UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
+ UdpSrcBuilder udpSrcBuilder = new UdpSrcBuilder();
+ udpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
+ udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
+ matchEntriesBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
+ break;
+ default:
+ LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+ break;
+ }
+
actionBuilder
- .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
-
+ .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
+
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
- List<MatchEntries> matchEntries = new ArrayList<MatchEntries>();
+ List<MatchEntry> matchEntries = new ArrayList<MatchEntry>();
matchEntries.add(matchEntriesBuilder.build());
- oxmFieldsActionBuilder.setMatchEntries(matchEntries);
+ oxmFieldsActionBuilder.setMatchEntry(matchEntries);
actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
return actionBuilder.build();
}
- logger.error("Unknown Action Type for the Version", version);
+ LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
return null;
}
- private static Action SalToOFGroupAction(
+ private static Action salToOFGroupAction(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
return actionBuilder.build();
}
- private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
+ private static Action salToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
if (ethernetType != null) {
ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
return actionBuilder.build();
}
- private static Action SalToOFDecMplsTtl(ActionBuilder actionBuilder) {
+ private static Action salToOFDecMplsTtl(ActionBuilder actionBuilder) {
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
return emtpyAction(actionBuilder);
}
- private static Action SalToOFSetMplsTtl(
+ private static Action salToOFSetMplsTtl(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder) {
SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
return actionBuilder.build();
}
- private static Action SalToOFCopyTTLIIn(ActionBuilder actionBuilder) {
+ private static Action salToOFCopyTTLIIn(ActionBuilder actionBuilder) {
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
return emtpyAction(actionBuilder);
}
- private static Action SalToOFCopyTTLIOut(ActionBuilder actionBuilder) {
+ private static Action salToOFCopyTTLIOut(ActionBuilder actionBuilder) {
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
return emtpyAction(actionBuilder);
return actionBuilder.build();
}
- private static Action salToOFOutputAction(
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
+ private static Action salToOFAction(
+ OutputActionCase outputActionCase,
ActionBuilder actionBuilder, short version) {
- OutputActionCase outputActionCase = ((OutputActionCase) action);
OutputAction outputAction = outputActionCase.getOutputAction();
PortActionBuilder portAction = new PortActionBuilder();
MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
portAction.setPort(new PortNumber(portNumber));
} else {
- logger.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
+ LOG.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
}
actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
/**
* TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
- * - we might also need a way on how to identify exact type of augmentation to be
+ * - we might also need a way on how to identify exact type of augmentation to be
* used as match can be bound to multiple models
*/
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction =
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction =
ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
if (processedAction != null) {
bucketActions.add(processedAction);
OutputActionBuilder outputAction = new OutputActionBuilder();
PortAction port = action.getAugmentation(PortAction.class);
if (port != null) {
- CommonPort.PortNumber protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
+ PortNumberUni protocolAgnosticPort =
+ OpenflowPortsUtil.getProtocolAgnosticPort(
ofVersion, port.getPort().getValue());
String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
} else {
- logger.error("Provided action is not OF Output action, no associated port found!");
+ LOG.error("Provided action is not OF Output action, no associated port found!");
}
MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
if (length != null) {
outputAction.setMaxLength(length.getMaxLength());
} else {
- logger.error("Provided action is not OF Output action, no associated length found!");
+ LOG.error("Provided action is not OF Output action, no associated length found!");
}
return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
setQueueAction.setQueueId(queueId.getQueueId());
-
return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
}
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<Integer, IPProtocols> 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);
+ }
+ } */
+
}