+++ /dev/null
-/**
- * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. 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 com.google.common.collect.Ordering;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-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.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.common.IPProtocols;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
-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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.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.CopyTtlOutCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
-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.PortNumberUni;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.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.rev150225.EthDst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
-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.UdpDst;
-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.UdpDstCaseBuilder;
-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.dst._case.UdpDstBuilder;
-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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author usha@ericsson Action List:This class takes data from SAL layer and
- * converts into OF Data
- * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
- * actions
- */
-public final class ActionConvertor {
- private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
- private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
- private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
- Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
-
- private ActionConvertor() {
- // NOOP
- }
-
- /**
- * Translates SAL actions into OF Library actions
- *
- * @param actions SAL actions
- * @param version Openflow protocol version used
- * @param datapathid datapath id
- * @param flow TODO
- * @return OF Library actions
- */
- public static List<Action> getActions(
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
- final short version, final BigInteger datapathid, final Flow flow) {
- List<Action> actionsList = new ArrayList<>();
- Action ofAction;
-
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions =
- ACTION_ORDERING.sortedCopy(actions);
-
- 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 = sortedActions.get(
- actionItem).getAction();
-
-
- if (action instanceof OutputActionCase) {
- ofAction = salToOFAction((OutputActionCase) action, actionBuilder, version);
- } else if (action instanceof DropActionCase){
- //noop
- } 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);
-
- // 1.0 Actions
- } else if (action instanceof SetVlanIdActionCase) {
- 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 =
- OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
- if (convertor != null) {
- ofAction = convertor.convert(extAction);
- }
- } else {
- // try vendor codecs
- TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
- 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 =
- OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
- LOG.trace("OFP Extension action, key:{}, converter:{}", key, convertor);
- if (convertor != null) {
- ofAction = convertor.convert(action);
- }
- }
-
- if (ofAction != null) {
- actionsList.add(ofAction);
- }
- }
- return actionsList;
- }
-
- private static Action salToOFSetField(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version, final BigInteger datapathid) {
-
- SetFieldCase setFieldCase = (SetFieldCase) action;
- org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match =
- setFieldCase.getSetField();
-
- if (version == OFConstants.OFP_VERSION_1_0) {
- // pushvlan +setField can be called to configure 1.0 switches via MDSAL app
- if (match.getVlanMatch() != null) {
- SetVlanVidActionBuilder vlanidActionBuilder = new SetVlanVidActionBuilder();
- SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
- vlanidActionBuilder.setVlanVid(match.getVlanMatch().getVlanId().getVlanId().getValue());
- setVlanVidCaseBuilder.setSetVlanVidAction(vlanidActionBuilder.build());
-
- actionBuilder.setActionChoice(setVlanVidCaseBuilder.build());
- return actionBuilder.build();
- } else {
- return emtpyAction(actionBuilder);
- }
-
- } else {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
- MatchReactor.getInstance().convert(match, version, setFieldBuilder);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-
- return actionBuilder.build();
- }
- }
-
- private static Action salToOFDecNwTtl(final ActionBuilder actionBuilder) {
- actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
- return emtpyAction(actionBuilder);
- }
-
- private static Action salToOFPushMplsAction(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
- PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
- PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
- pushMplsBuilder.setEthertype(new EtherType(pushMplsActionCase.getPushMplsAction().getEthernetType()));
- pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
- actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFPushPbbAction(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
- PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
- PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
- pushPbbBuilder.setEthertype(new EtherType(pushPbbActionCase.getPushPbbAction().getEthernetType()));
- pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
- actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFPushVlanAction(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
- if (version == OFConstants.OFP_VERSION_1_0) {
- // if client configure openflow 1.0 switch as a openflow 1.3 switch using openflow 1.3 instructions
- // then we can ignore PUSH_VLAN as set-vlan-id will push a vlan header if not present
- return null;
- }
- PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
- PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
-
- PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
- PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
- if (null != pushVlanAction.getEthernetType()) {
- pushVlanBuilder.setEthertype(new EtherType(pushVlanAction.getEthernetType()));
- }
- pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
- actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFSetNwTtl(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
-
- SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
- SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
- nwTtlBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
- nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
- actionBuilder.setActionChoice(nwTtlCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFSetQueue(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
- SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
-
- SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
- SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
- setQueueBuilder.setQueueId(setQueueAction.getQueueId());
- setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
- actionBuilder.setActionChoice(setQueueCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFPopMpls(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
-
- PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
- PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
- popMplsBuilder.setEthertype(new EtherType(new EtherType(popMplsActionCase.getPopMplsAction().getEthernetType())));
- popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
- actionBuilder.setActionChoice(popMplsCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFPopVlan(final ActionBuilder actionBuilder) {
- actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
- return emtpyAction(actionBuilder);
- }
-
- private static Action salToOFPopPBB(final ActionBuilder actionBuilder) {
- actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
- 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(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
- SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
-
- SetVlanVidActionBuilder vlanidActionBuilder = new SetVlanVidActionBuilder();
- SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
-
- if (version == OFConstants.OFP_VERSION_1_0) {
- vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
- setVlanVidCaseBuilder.setSetVlanVidAction(vlanidActionBuilder.build());
- actionBuilder.setActionChoice(setVlanVidCaseBuilder.build());
- return actionBuilder.build();
-
- } else {
- if (version >= OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
- List<MatchEntry> entries = new ArrayList<>();
- MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
- matchBuilder.setOxmClass(OpenflowBasicClass.class);
- matchBuilder.setOxmMatchField(VlanVid.class);
- matchBuilder.setHasMask(false);
- VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
- VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
- vlanVidBuilder.setCfiBit(true);
- vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
- vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
- matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
- entries.add(matchBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
- return actionBuilder.build();
- } else {
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
- }
- }
-
- private static Action salToOFSetVlanpcp(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
- SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
-
- if (version == OFConstants.OFP_VERSION_1_0) {
- SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
- SetVlanPcpCaseBuilder setVlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
- setVlanPcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
- setVlanPcpCaseBuilder.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
- actionBuilder.setActionChoice(setVlanPcpCaseBuilder.build());
- return actionBuilder.build();
- } else if (version >= OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
- List<MatchEntry> matchEntriesList = new ArrayList<>();
-
- matchEntriesList.add(MatchConvertorUtil.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
- setFieldBuilder.setMatchEntry(matchEntriesList);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-
- return actionBuilder.build();
- } else {
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
- }
-
- private static Action salToOFStripVlan(final ActionBuilder actionBuilder, final short version) {
- if (version == OFConstants.OFP_VERSION_1_0) {
- actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
- return emtpyAction(actionBuilder);
- } else if (version >= OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
- List<MatchEntry> entries = new ArrayList<>();
- MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
- matchBuilder.setOxmClass(OpenflowBasicClass.class);
- matchBuilder.setOxmMatchField(VlanVid.class);
- matchBuilder.setHasMask(false);
- VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
- VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
- vlanVidBuilder.setCfiBit(true);
- vlanVidBuilder.setVlanVid(0x0000);
- vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
- matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
- matchBuilder.setHasMask(false);
- entries.add(matchBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
- return actionBuilder.build();
- } else {
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
- }
-
- private static Action salToOFSetDlSrc(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
- SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
-
- if (version == OFConstants.OFP_VERSION_1_0) {
- SetDlSrcCaseBuilder setDlSrcCaseBuilder = new SetDlSrcCaseBuilder();
- SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
- setDlSrcActionBuilder.setDlSrcAddress(setdlsrcaction.getAddress());
- setDlSrcCaseBuilder.setSetDlSrcAction(setDlSrcActionBuilder.build());
- actionBuilder.setActionChoice(setDlSrcCaseBuilder.build());
- return actionBuilder.build();
- } else if (version >= OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
- List<MatchEntry> entries = new ArrayList<>();
- MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
- matchBuilder.setOxmClass(OpenflowBasicClass.class);
- matchBuilder.setOxmMatchField(EthSrc.class);
- EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
- EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
- ethSrcBuilder.setMacAddress(setdlsrcaction.getAddress());
- matchBuilder.setHasMask(false);
- ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
- matchBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
- entries.add(matchBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
-
- return actionBuilder.build();
- } else {
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
- }
-
- private static Action salToOFSetDlDst(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
- SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
-
- if (version == OFConstants.OFP_VERSION_1_0) {
- SetDlDstCaseBuilder setDlDstCaseBuilder = new SetDlDstCaseBuilder();
- SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
- setDlDstActionBuilder.setDlDstAddress(setdldstaction.getAddress());
- setDlDstCaseBuilder.setSetDlDstAction(setDlDstActionBuilder.build());
- actionBuilder.setActionChoice(setDlDstCaseBuilder.build());
- return actionBuilder.build();
- } else if (version >= OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
- List<MatchEntry> entries = new ArrayList<>();
-
- MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
- matchBuilder.setOxmClass(OpenflowBasicClass.class);
- matchBuilder.setOxmMatchField(EthDst.class);
- EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
- EthDstBuilder ethDstBuilder = new EthDstBuilder();
- ethDstBuilder.setMacAddress(setdldstaction.getAddress());
- matchBuilder.setHasMask(false);
- ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
- matchBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
- entries.add(matchBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
- return actionBuilder.build();
- } else {
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
- }
-
- protected static Action salToOFSetNwSrc(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- try {
- ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder);
- } catch (Exception e) {
- LOG.error(e.getMessage(), e);
- return null;
- }
-
- return actionBuilder.build();
- }
-
- protected static Action salToOFSetNwDst(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- try {
- ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder);
- } catch (Exception e) {
- LOG.error(e.getMessage(), e);
- return null;
- }
-
- return actionBuilder.build();
- }
-
- private static Action salToOFSetNwTos(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version) {
-
- SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
- SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
-
- if (version == OFConstants.OFP_VERSION_1_0) {
- SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
- SetNwTosCaseBuilder setNwTosCaseBuilder = new SetNwTosCaseBuilder();
- setNwTosActionBuilder.setNwTos(setnwtosaction.getTos().shortValue());
- setNwTosCaseBuilder.setSetNwTosAction(setNwTosActionBuilder.build());
- actionBuilder.setActionChoice(setNwTosCaseBuilder.build());
- return actionBuilder.build();
- } else if (version >= OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
- List<MatchEntry> entries = new ArrayList<>();
- entries.add(MatchConvertorUtil.toOfIpDscp(new Dscp(
- ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
- )));
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
- return actionBuilder.build();
- } else {
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
-
- }
-
- private static Action salToOFSetTpSrc(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version, final IPProtocols protocol) {
-
- SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
- SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
- if (version == OFConstants.OFP_VERSION_1_0) {
- SetTpSrcCaseBuilder setTpSrcCaseBuilder = new SetTpSrcCaseBuilder();
- SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
- setTpSrcActionBuilder.setPort(new PortNumber(settpsrcaction.getPort()
- .getValue()
- .longValue()));
- setTpSrcCaseBuilder.setSetTpSrcAction(setTpSrcActionBuilder.build());
- actionBuilder.setActionChoice(setTpSrcCaseBuilder.build());
- return actionBuilder.build();
- } else if (version == OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
- MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
- matchBuilder.setOxmClass(OpenflowBasicClass.class);
- matchBuilder.setHasMask(false);
-
- InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
- int port = settpsrcaction.getPort().getValue().intValue();
- int type = 0xff & port;
-
- switch (protocol) {
- case ICMP:
- matchBuilder.setOxmMatchField(Icmpv4Type.class);
- Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
- Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
- icmpv4TypeBuilder.setIcmpv4Type((short) type);
- icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
- matchBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
- break;
- case ICMPV6:
- matchBuilder.setOxmMatchField(Icmpv6Type.class);
- Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
- Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
- icmpv6TypeBuilder.setIcmpv6Type((short) type);
- icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
- matchBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
- break;
- case TCP:
- matchBuilder.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.rev130715.PortNumber(port));
- tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
- matchBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
- break;
- case UDP:
- matchBuilder.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.rev130715.PortNumber(port));
- udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
- matchBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
- break;
- default:
- LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
- break;
- }
- List<MatchEntry> entries = new ArrayList<MatchEntry>();
- entries.add(matchBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
- return actionBuilder.build();
- }
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
-
- private static Action salToOFSetTpDst(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder, final short version, final IPProtocols protocol) {
-
- SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
- SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
- if (version == OFConstants.OFP_VERSION_1_0) {
- SetTpDstCaseBuilder setTpDstCaseBuilder = new SetTpDstCaseBuilder();
- SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
- setTpDstActionBuilder.setPort(new PortNumber(settpdstaction.getPort().getValue().longValue()));
- setTpDstCaseBuilder.setSetTpDstAction(setTpDstActionBuilder.build());
- actionBuilder.setActionChoice(setTpDstCaseBuilder.build());
- return actionBuilder.build();
- } else if (version == OFConstants.OFP_VERSION_1_3) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
-
- MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
- matchBuilder.setOxmClass(OpenflowBasicClass.class);
- matchBuilder.setHasMask(false);
- int port = settpdstaction.getPort().getValue().intValue();
- int code = 0xff & port;
-
- switch (protocol) {
- case ICMP:
- matchBuilder.setOxmMatchField(Icmpv4Code.class);
- Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
- Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
- icmpv4CodeBuilder.setIcmpv4Code((short) code);
- icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
- matchBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
- break;
- case ICMPV6:
- matchBuilder.setOxmMatchField(Icmpv6Code.class);
- Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
- Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
- icmpv6CodeBuilder.setIcmpv6Code((short) code);
- icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
- matchBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
- break;
- case TCP:
- matchBuilder.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.rev130715.PortNumber(port));
- tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
- matchBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
- break;
- case UDP:
- matchBuilder.setOxmMatchField(UdpDst.class);
- UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
- UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
- udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
- udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
- matchBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
- break;
- default:
- LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
- break;
- }
- List<MatchEntry> entries = new ArrayList<MatchEntry>();
- entries.add(matchBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- actionBuilder.setActionChoice(setFieldCaseBuilder.build());
- return actionBuilder.build();
- }
- LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
- return null;
- }
-
- private static Action salToOFGroupAction(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- GroupActionCase groupActionCase = (GroupActionCase) action;
- GroupAction groupAction = groupActionCase.getGroupAction();
- GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
- GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
-
- if (null != groupAction.getGroupId()) {
- groupActionBuilder.setGroupId(groupAction.getGroupId());
- } else {
- groupActionBuilder.setGroupId(Long.parseLong(groupAction.getGroup()));
- }
-
- groupCaseBuilder.setGroupAction(groupActionBuilder.build());
- actionBuilder.setActionChoice(groupCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFDecMplsTtl(final ActionBuilder actionBuilder) {
- actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build());
- return emtpyAction(actionBuilder);
- }
-
- private static Action salToOFSetMplsTtl(
- final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- final ActionBuilder actionBuilder) {
- SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
- SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
- SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
- SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder();
- setMplsTtlBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
- setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build());
- actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build());
- return actionBuilder.build();
- }
-
- private static Action salToOFCopyTTLIIn(final ActionBuilder actionBuilder) {
- actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
- return emtpyAction(actionBuilder);
- }
-
- private static Action salToOFCopyTTLIOut(final ActionBuilder actionBuilder) {
- actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
- return emtpyAction(actionBuilder);
-
- }
-
- private static Action emtpyAction(final ActionBuilder actionBuilder) {
- return actionBuilder.build();
- }
-
- private static Action salToOFAction(
- final OutputActionCase outputActionCase,
- final ActionBuilder actionBuilder, final short version) {
-
- OutputAction outputAction = outputActionCase.getOutputAction();
- OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
- OutputActionBuilder outputBuilder = new OutputActionBuilder();
-
- if (outputAction.getMaxLength() != null) {
- outputBuilder.setMaxLength(outputAction.getMaxLength());
- } else {
- outputBuilder.setMaxLength(0);
- }
- Uri uri = outputAction.getOutputNodeConnector();
- OpenflowVersion ofVersion = OpenflowVersion.get(version);
- Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
- if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
- outputBuilder.setPort(new PortNumber(portNumber));
- } else {
- LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, ofVersion);
- }
- caseBuilder.setOutputAction(outputBuilder.build());
- actionBuilder.setActionChoice(caseBuilder.build());
- return actionBuilder.build();
-
- }
-
- /**
- * Method to convert OF actions associated with bucket to SAL Actions.
- *
- * @param actionList action list
- * @param ofVersion current ofp version
- * @param actionPath TODO
- * @return List of converted SAL Actions.
- */
- public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
- final List<Action> actionList, final OpenflowVersion ofVersion, final ActionPath actionPath) {
-
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
- if(actionList != null){
- for (Action action : actionList) {
- if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) {
- bucketActions.add(ofToSALOutputAction(ofVersion, action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase) {
- bucketActions.add(ofToSALGroupAction(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase) {
- CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
- bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase) {
- CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
- bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
-
- } else if (action.getActionChoice() instanceof SetMplsTtlCase) {
- bucketActions.add(ofToSALSetMplsTtl(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase) {
- DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
- bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase) {
- bucketActions.add(ofToSALPushVlanAction(action));
- } else if ((action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase)
- || (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase)) {
- // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
- PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
- bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase) {
- bucketActions.add(ofToSALPushMplsAction(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase) {
- bucketActions.add(ofToSALPopMplsAction(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase) {
- bucketActions.add(ofToSALSetQueue(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase) {
- bucketActions.add(ofToSALSetNwTtl(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase) {
- DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
- bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder()
- .setDecNwTtl(decNwTtl.build()).build());
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(ofVersion.getVersion());
- final SetFieldAction setFieldAction = setFieldCase.getSetFieldAction();
- final SetFieldBuilder setField = new SetFieldBuilder();
- final Optional<MatchBuilder> matchOptional = ConvertorManager.getInstance().convert(setFieldAction, datapathIdConvertorData);
-
- if (matchOptional.isPresent()) {
- setField.fieldsFrom(matchOptional.get().build());
- }
-
- bucketActions.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder().setSetField(setField.build()).build());
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase) {
- bucketActions.add(ofToSALPushPbbAction(action));
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase) {
- PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
- bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
-
- } else if (action.getActionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder setNwDstActionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder();
- bucketActions.add(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
-
- } else {
- /**
- * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
- * - 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 =
- ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
- if (processedAction != null) {
- bucketActions.add(processedAction);
- }
- }
- }
- }
- return bucketActions;
- }
-
- /**
- * Method converts OF Output action object to SAL Output action object.
- *
- * @param ofVersion openflow version
- * @param action org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
- * action.rev130731.actions.actions.list.Action
- * @return OutputAction
- */
- public static OutputActionCase ofToSALOutputAction(final OpenflowVersion ofVersion, final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder outputAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder();
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase) action.getActionChoice();
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputAction outputActionFromOF = actionCase.getOutputAction();
- if (outputActionFromOF.getPort() != null) {
- PortNumberUni protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
- ofVersion, outputActionFromOF.getPort().getValue());
- String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
- outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
- } else {
- LOG.error("Provided action is not OF Output action, no associated port found!");
- }
-
- Integer maxLength = outputActionFromOF.getMaxLength();
- if (maxLength != null) {
- outputAction.setMaxLength(maxLength);
- } else {
- LOG.error("Provided action is not OF Output action, no associated length found!");
- }
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder outputActionCaseBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder();
- outputActionCaseBuilder.setOutputAction(outputAction.build());
- return outputActionCaseBuilder.build();
- }
-
- /**
- * Method converts OF GroupAction object to SAL GroupAction object
- *
- * @param action action
- * @return GroupAction group action
- */
- public static GroupActionCase ofToSALGroupAction(final Action action) {
- GroupCase actionCase = (GroupCase) action.getActionChoice();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupAction groupActionFromOF =
- actionCase.getGroupAction();
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder groupAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder();
- groupAction.setGroupId(groupActionFromOF.getGroupId());
-
- return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
- }
-
- /**
- * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
- * object.
- *
- * @param action action
- * @return set-mpls ttl action
- */
- public static SetMplsTtlActionCase ofToSALSetMplsTtl(final Action action) {
- SetMplsTtlCase actionCase = (SetMplsTtlCase) action.getActionChoice();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action
- .choice.set.mpls.ttl._case.SetMplsTtlAction setMplsTtlActionFromOF = actionCase.getSetMplsTtlAction();
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder mplsTtlAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder();
- mplsTtlAction.setMplsTtl(setMplsTtlActionFromOF.getMplsTtl());
- return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
- }
-
- /**
- * Method converts OF Pushvlan action to SAL PushVlan action.
- *
- * @param action input actioj
- * @return PushVlanAction
- */
- public static PushVlanActionCase ofToSALPushVlanAction(final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase) action.getActionChoice();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanAction pushVlanActionFromOF =
- actionCase.getPushVlanAction();
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder pushVlanAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder();
-
- pushVlanAction.setEthernetType(pushVlanActionFromOF.getEthertype().getValue());
- return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
- }
-
- /**
- * Method converts OF PushMpls action to SAL PushMpls action.
- *
- * @param action action
- * @return PushMplsAction
- */
- public static PushMplsActionCase ofToSALPushMplsAction(final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase) action.getActionChoice();
- PushMplsAction pushMplsActionFromOF = actionCase.getPushMplsAction();
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder pushMplsAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder();
- pushMplsAction.setEthernetType(pushMplsActionFromOF.getEthertype().getValue());
- return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
- }
-
- /**
- * Method converts OF PopMpls action to SAL PopMpls action.
- *
- * @param action action
- * @return PopMplsActionCase
- */
- public static PopMplsActionCase ofToSALPopMplsAction(final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase) action.getActionChoice();
- PopMplsAction popMplsActionFromOF = actionCase.getPopMplsAction();
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder popMplsAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder();
- popMplsAction.setEthernetType(popMplsActionFromOF.getEthertype().getValue());
- return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
- }
-
- /**
- * Method converts OF SetQueue action to SAL SetQueue action.
- *
- * @param action action
- * @return SetQueueAction
- */
- public static SetQueueActionCase ofToSALSetQueue(final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase) action.getActionChoice();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueAction queueActionFromOF =
- actionCase.getSetQueueAction();
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder setQueueAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder();
- setQueueAction.setQueueId(queueActionFromOF.getQueueId());
- return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
- }
-
- /**
- * Method converts OF SetNwTtl action to SAL SetNwTtl action.
- *
- * @param action action
- * @return SetNwTtlAction
- */
- public static SetNwTtlActionCase ofToSALSetNwTtl(final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase) action.getActionChoice();
- SetNwTtlAction setNwTtlActionFromOf = actionCase.getSetNwTtlAction();
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder setNwTtl =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder();
- setNwTtl.setNwTtl(setNwTtlActionFromOf.getNwTtl());
- return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
- }
-
- /**
- * Method converts OF Pushvlan action to SAL PushVlan action.
- *
- * @param action action
- * @return PushVlanAction
- */
- public static PushPbbActionCase ofToSALPushPbbAction(final Action action) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase actionCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase) action.getActionChoice();
- PushPbbAction pushPbbActionFromOf = actionCase.getPushPbbAction();
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder pushPbbAction =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder();
- pushPbbAction.setEthernetType(pushPbbActionFromOf.getEthertype().getValue());
- 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 (short) protocol;
- }
-
- private IPProtocols fromProtocolNum(Short protocolNum) {
- return valueMap.get(protocolNum);
- }
- } */
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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;
-
-/**
- * Created by Martin Bobak <mbobak@cisco.com> on 13.3.2015.
- */
-public final class ActionUtil {
-
- private ActionUtil() {
- throw new IllegalStateException("This class should not be instantiated");
- }
-
-}
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ParametrizedConvertor;
// TODO: Add MatchConvertor
INSTANCE.registerConvertor(new MatchResponseConvertor());
INSTANCE.registerConvertor(new MatchV10ResponseConvertor());
+ INSTANCE.registerConvertor(new ActionConvertor());
+ INSTANCE.registerConvertor(new ActionResponseConvertor());
}
// Actual convertor keys
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Ordering;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag.FlowFlagReactor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Ordering;
/**
* Utility class for converting a MD-SAL Flow into the OF flow mod
InstructionBuilder instructionBuilder = new InstructionBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
.getInstruction();
+ ActionConvertorData data = new ActionConvertorData(version);
+ data.setDatapathId(datapathid);
+
+ if (flow.getMatch() != null && flow.getMatch().getIpMatch() != null) {
+ data.setIpProtocol(flow.getMatch().getIpMatch().getIpProtocol());
+ }
+
if (curInstruction instanceof GoToTableCase) {
GoToTableCase goToTablecase = (GoToTableCase) curInstruction;
GoToTable goToTable = goToTablecase.getGoToTable();
WriteActions writeActions = writeActionscase.getWriteActions();
WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
- writeActionsBuilder.setAction(ActionConvertor.getActions(writeActions.getAction(),version, datapathid, flow));
+
+ final java.util.Optional<List<Action>> actions = ConvertorManager.getInstance().convert(
+ writeActions.getAction(), data);
+
+ writeActionsBuilder.setAction(actions.orElse(Collections.emptyList()));
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
instructionBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder applyActionsBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder();
- applyActionsBuilder.setAction(ActionConvertor.getActions(applyActions.getAction(), version, datapathid, flow));
+ final java.util.Optional<List<Action>> actionList = ConvertorManager.getInstance().convert(
+ applyActions.getAction(), data);
+
+ applyActionsBuilder.setAction(actionList.orElse(Collections.emptyList()));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
instructionBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
if (curInstruction instanceof ApplyActionsCase) {
ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
- return ActionConvertor.getActions(applyActions.getAction(), version, datapathid, flow);
+ final ActionConvertorData data = new ActionConvertorData(version);
+ data.setDatapathId(datapathid);
+
+ if (flow.getMatch() != null && flow.getMatch().getIpMatch() != null) {
+ data.setIpProtocol(flow.getMatch().getIpMatch().getIpProtocol());
+ }
+
+ java.util.Optional<List<Action>> result = ConvertorManager.getInstance().convert(applyActions.getAction(), data);
+ return result.orElse(Collections.emptyList());
}
}
return null;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-
+import java.util.Optional;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
private static List<BucketsList> salToOFBucketList(Buckets buckets, short version, int groupType,BigInteger datapathid) {
final List<BucketsList> bucketLists = new ArrayList<>();
+ final ActionConvertorData data = new ActionConvertorData(version);
+ data.setDatapathId(datapathid);
for (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket groupBucket : buckets
.getBucket()) {
BucketsListBuilder bucketBuilder = new BucketsListBuilder();
salToOFBucketListWatchGroup(groupBucket, bucketBuilder, groupType);
salToOFBucketListWatchPort(groupBucket, bucketBuilder, groupType);
- List<Action> bucketActionList = ActionConvertor.getActions(groupBucket.getAction(), version, datapathid, null);
- bucketBuilder.setAction(bucketActionList);
+ Optional<List<Action>> bucketActionList = ConvertorManager.getInstance().convert(
+ groupBucket.getAction(), data);
+
+ bucketBuilder.setAction(bucketActionList.orElse(Collections.emptyList()));
BucketsList bucket = bucketBuilder.build();
bucketLists.add(bucket);
}
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-
-import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import java.util.Optional;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
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.action.list.ActionKey;
public org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets toSALBucketsDesc(
List<BucketsList> bucketDescStats, OpenflowVersion ofVersion ){
+ final ActionResponseConvertorData data = new ActionResponseConvertorData(ofVersion.getVersion());
+ data.setActionPath(ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION);
org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder salBucketsDesc =
new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder();
int bucketKey = 0;
for(BucketsList bucketDetails : bucketDescStats){
BucketBuilder bucketDesc = new BucketBuilder();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedSalActions =
- ActionConvertor.toMDSalActions (bucketDetails.getAction(), ofVersion,
- ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION);
-
- List<Action> actions = new ArrayList<>();
- int actionKey = 0;
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : convertedSalActions){
- ActionBuilder wrappedAction = new ActionBuilder();
- wrappedAction.setAction(action);
- wrappedAction.setKey(new ActionKey(actionKey));
- wrappedAction.setOrder(actionKey);
- actions.add(wrappedAction.build());
- actionKey++;
+ final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> convertedSalActions =
+ ConvertorManager.getInstance().convert(bucketDetails.getAction(), data);
+
+ if (convertedSalActions.isPresent()) {
+ List<Action> actions = new ArrayList<>();
+ int actionKey = 0;
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : convertedSalActions.get()) {
+ ActionBuilder wrappedAction = new ActionBuilder();
+ wrappedAction.setAction(action);
+ wrappedAction.setKey(new ActionKey(actionKey));
+ wrappedAction.setOrder(actionKey);
+ actions.add(wrappedAction.build());
+ actionKey++;
+ }
+
+ bucketDesc.setAction(actions);
+ } else {
+ bucketDesc.setAction(Collections.emptyList());
}
- bucketDesc.setAction(actions);
+
bucketDesc.setWeight(bucketDetails.getWeight());
bucketDesc.setWatchPort(bucketDetails.getWatchPort().getValue());
bucketDesc.setWatchGroup(bucketDetails.getWatchGroup());
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
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.action.list.ActionKey;
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
+ final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(ofVersion.getVersion());
+ actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);
- applyActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsInstruction.getApplyActions().getAction(), ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION)));
+ final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> actions = ConvertorManager.getInstance().convert(
+ actionsInstruction.getApplyActions().getAction(), actionResponseConvertorData);
+ applyActionsBuilder.setAction(wrapActionList(actions.orElse(Collections.emptyList())));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
salInstruction = applyActionsCaseBuilder.build();
} else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
- writeActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(writeActionsCase.getWriteActions().getAction(), ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION)));
+
+ final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(ofVersion.getVersion());
+ actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+
+ final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> actions = ConvertorManager.getInstance().convert(
+ writeActionsCase.getWriteActions().getAction(), actionResponseConvertorData);
+
+ writeActionsBuilder.setAction(wrapActionList(actions.orElse(Collections.emptyList())));
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
salInstruction = writeActionsCaseBuilder.build();
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
- applyActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsList, ofVersion, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION)));
+ final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(ofVersion.getVersion());
+ actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+
+ final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> actions = ConvertorManager.getInstance().convert(
+ actionsList, actionResponseConvertorData);
+ applyActionsBuilder.setAction(wrapActionList(actions.orElse(Collections.emptyList())));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
InstructionBuilder instBuilder = new InstructionBuilder();
import com.google.common.collect.Iterables;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import org.opendaylight.controller.sal.common.util.Arguments;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions =
inputPacket.getAction();
if (inputActions != null) {
- actions = ActionConvertor.getActions(inputActions, version, datapathid, null);
+ final ActionConvertorData actionConvertorData = new ActionConvertorData(version);
+ actionConvertorData.setDatapathId(datapathid);
+
+ final Optional<List<Action>> convertedActions = ConvertorManager.getInstance().convert(
+ inputActions, actionConvertorData);
+
+ actions = convertedActions.orElse(Collections.emptyList());
} else {
actions = new ArrayList<>();
--- /dev/null
+/*
+ * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. 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.action;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfCopyTtlInCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfCopyTtlOutCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfDecMplsTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfDecNwTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfDropActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfGeneralExtensionGroupingCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfGroupActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfOutputActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopMplsActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopPbbActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopVlanActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPopVlanActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPushMplsActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPushPbbActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfPushVlanActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlDstActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlDstActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlSrcActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetDlSrcActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetFieldCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetFieldV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetMplsTtlActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwDstActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwDstActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwSrcActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwSrcActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwTosActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwTosActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetNwTtlActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetQueueActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpDstActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpDstActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpSrcActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetTpSrcActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanIdActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanIdActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanPcpActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfSetVlanPcpActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfStripVlanActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfStripVlanActionV10Case;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.SalToOfVendorCodecCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ParametrizedConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+
+/**
+ * Converts SAL actions into OF Library actions
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * ActionConvertorData data = new ActionConvertorData(version);
+ * data.setDatapathId(datapathId);
+ * data.setIpProtocol(ipProtocol);
+ * Optional<List<Action>> ofActions = ConvertorManager.getInstance().convert(salActions, data);
+ * }
+ * </pre>
+ */
+public final class ActionConvertor implements ParametrizedConvertor<
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>,
+ List<Action>,
+ ActionConvertorData> {
+
+ private static final ConvertorProcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action, ActionConvertorData> PROCESSOR = new ConvertorProcessor<
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action,
+ Action,
+ ActionConvertorData>()
+ // Set default rule, what will be used if no rule match is found
+ .setDefaultCase(new SalToOfVendorCodecCase())
+ // Add rules for each action type
+ .addCase(new SalToOfCopyTtlInCase())
+ .addCase(new SalToOfCopyTtlOutCase())
+ .addCase(new SalToOfDecMplsTtlCase())
+ .addCase(new SalToOfDecNwTtlCase())
+ .addCase(new SalToOfDropActionCase())
+ .addCase(new SalToOfGroupActionCase())
+ .addCase(new SalToOfOutputActionCase())
+ .addCase(new SalToOfPopMplsActionCase())
+ .addCase(new SalToOfPopPbbActionCase())
+ .addCase(new SalToOfPopVlanActionCase())
+ .addCase(new SalToOfPopVlanActionV10Case())
+ .addCase(new SalToOfPushMplsActionCase())
+ .addCase(new SalToOfPushPbbActionCase())
+ .addCase(new SalToOfPushVlanActionCase())
+ .addCase(new SalToOfSetFieldCase())
+ .addCase(new SalToOfSetFieldV10Case())
+ .addCase(new SalToOfSetMplsTtlActionCase())
+ .addCase(new SalToOfSetNwTtlActionCase())
+ .addCase(new SalToOfSetQueueActionCase())
+ // Openflow 1.0 actions, with support for Openflow 1.3
+ .addCase(new SalToOfSetVlanIdActionCase())
+ .addCase(new SalToOfSetVlanIdActionV10Case())
+ .addCase(new SalToOfSetVlanPcpActionCase())
+ .addCase(new SalToOfSetVlanPcpActionV10Case())
+ .addCase(new SalToOfStripVlanActionCase())
+ .addCase(new SalToOfStripVlanActionV10Case())
+ .addCase(new SalToOfSetDlSrcActionCase())
+ .addCase(new SalToOfSetDlSrcActionV10Case())
+ .addCase(new SalToOfSetDlDstActionCase())
+ .addCase(new SalToOfSetDlDstActionV10Case())
+ .addCase(new SalToOfSetNwSrcActionCase())
+ .addCase(new SalToOfSetNwSrcActionV10Case())
+ .addCase(new SalToOfSetNwDstActionCase())
+ .addCase(new SalToOfSetNwDstActionV10Case())
+ .addCase(new SalToOfSetTpSrcActionCase())
+ .addCase(new SalToOfSetTpSrcActionV10Case())
+ .addCase(new SalToOfSetTpDstActionCase())
+ .addCase(new SalToOfSetTpDstActionV10Case())
+ .addCase(new SalToOfSetNwTosActionCase())
+ .addCase(new SalToOfSetNwTosActionV10Case())
+ // Try to convert action grouping using converters from openflowplugin-extension
+ .addCase(new SalToOfGeneralExtensionGroupingCase());
+
+ @Override
+ public Class<?> getType() {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action.class;
+ }
+
+ @Override
+ public List<Action> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> source, ActionConvertorData data) {
+ // Prepare list of converted actions
+ final List<Action> result = new ArrayList<>();
+
+ // Iterate over SAL actions, run them through tokenizer and then add them to list of converted actions
+ if (source != null) {
+ for (final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : source) {
+ final Optional<Action> convertedAction = PROCESSOR.process(action.getAction(), data);
+
+ if (convertedAction.isPresent()) {
+ result.add(convertedAction.get());
+ }
+ }
+ }
+
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. 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.action;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalCopyTtlInCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalCopyTtlOutCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalDecMplsTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalDecNwTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalGroupCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalOutputActionCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPopMplsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPopPbbCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPopVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushMplsCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushPbbCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetFieldCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetMplsTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwTtlCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetQueueCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalStripVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ParametrizedConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+
+/**
+ * Converts OF actions associated with bucket to SAL Actions.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * ActionResponseConvertorData data = new ActionResponseConvertorData(version);
+ * data.setActionPath(actionPath);
+ * Optional<List<Action>> salActions = ConvertorManager.getInstance().convert(ofActions, data);
+ * }
+ * </pre>
+ */
+public final class ActionResponseConvertor implements ParametrizedConvertor<
+ List<Action>,
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>,
+ ActionResponseConvertorData> {
+
+ private static final ConvertorProcessor<ActionChoice, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, ActionResponseConvertorData> PROCESSOR = new ConvertorProcessor<
+ ActionChoice,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action,
+ ActionResponseConvertorData>()
+ // Add rules for each action type
+ .addCase(new OfToSalCopyTtlInCase())
+ .addCase(new OfToSalCopyTtlOutCase())
+ .addCase(new OfToSalDecMplsTtlCase())
+ .addCase(new OfToSalDecNwTtlCase())
+ .addCase(new OfToSalGroupCase())
+ .addCase(new OfToSalOutputActionCase())
+ .addCase(new OfToSalPopMplsCase())
+ .addCase(new OfToSalPopPbbCase())
+ .addCase(new OfToSalPopVlanCase())
+ .addCase(new OfToSalPushMplsCase())
+ .addCase(new OfToSalPushPbbCase())
+ .addCase(new OfToSalPushVlanCase())
+ .addCase(new OfToSalSetFieldCase())
+ .addCase(new OfToSalSetMplsTtlCase())
+ .addCase(new OfToSalSetNwDstCase())
+ .addCase(new OfToSalSetNwTtlCase())
+ .addCase(new OfToSalSetQueueCase())
+ .addCase(new OfToSalStripVlanCase());
+
+ @Override
+ public Class<?> getType() {
+ return Action.class;
+ }
+
+ @Override
+ public List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convert(List<Action> source, ActionResponseConvertorData data) {
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> result = new ArrayList<>();
+ final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
+
+ // Iterate over Openflow actions, run them through tokenizer and then add them to list of converted actions
+ if (source != null) {
+ for (final Action action : source) {
+ final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedAction = PROCESSOR.process(action.getActionChoice(), data);
+
+ if (convertedAction.isPresent()) {
+ result.add(convertedAction.get());
+ } else {
+ /**
+ * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
+ * - 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 =
+ ActionExtensionHelper.processAlienAction(action, ofVersion, data.getActionPath());
+
+ if (processedAction != null) {
+ result.add(processedAction);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+}
+++ /dev/null
-/**
- * Copyright (c) 2013 Ericsson. 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.action;
-
-import com.google.common.base.Splitter;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwDstConvertorImpl implements Convertor<SetNwDstActionCase, Object> {
- private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
-
- @Override
- public Class<?> getType() {
- return SetNwDstActionCase.class;
- }
-
- @Override
- public Object convert(final SetNwDstActionCase source) {
- Address address = source.getSetNwDstAction().getAddress();
- if (address instanceof Ipv4) {
- Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
- return new Ipv4Address(addressParts.iterator().next());
- } else if (address instanceof Ipv6) {
- Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
- return new Ipv6Address(addressParts.iterator().next());
- } else {
- throw new IllegalArgumentException("Address is not supported: "+address.getClass().getName());
- }
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 Ericsson. 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.action;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwDstConvertorV10Impl implements Convertor<SetNwDstActionCase, Object> {
-
- @Override
- public Class<?> getType() {
- return SetNwDstActionCase.class;
- }
-
- @Override
- public Object convert(SetNwDstActionCase source) {
- Address address = source.getSetNwDstAction().getAddress();
- if (address instanceof Ipv4) {
- //FIXME use of substring should be removed and OF models should distinguish where
- //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
-
- String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
- ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
- return new Ipv4Address(ipAddress);
- } else {
- throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
- }
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 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.action;
-
-import java.util.Map;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-
-/**
- *
- */
-public class ActionSetNwDstReactor extends ConvertReactor<SetNwDstActionCase> {
-
- private static ActionSetNwDstReactor INSTANCE = new ActionSetNwDstReactor();
-
- private ActionSetNwDstReactor() {
- //NOOP
- }
-
- /**
- * @return singleton
- */
- public static ActionSetNwDstReactor getInstance() {
- return INSTANCE;
- }
-
- @Override
- protected void initMappings(final Map<Short, Convertor<SetNwDstActionCase,?>> conversions,
- final Map<InjectionKey, ResultInjector<?,?>> injections) {
- ActionSetNwDstReactorMappingFactory.addSetNwDstConvertors(conversions);
- ActionSetNwDstReactorMappingFactory.addSetNwDstInjectors(injections);
- }
-
- @Override
- protected InjectionKey buildInjectionKey(final short version,
- final Object convertedItem, final Object target) {
- InjectionResultTargetKey key = null;
- if (convertedItem != null) {
- key = new InjectionResultTargetKey(version, target.getClass(), convertedItem.getClass());
- }
- return key;
- }
-
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 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.action;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
-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.Ipv4DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
-
-/**
- * add prepared convertors and injectors into given mappings
- *
- * @see ActionSetNwSrcReactor
- */
-public class ActionSetNwDstReactorMappingFactory {
-
- /**
- * @param conversionMapping conversion mapping
- */
- public static void addSetNwDstConvertors(final Map<Short, Convertor<SetNwDstActionCase, ?>> conversionMapping) {
- conversionMapping.put(OFConstants.OFP_VERSION_1_0, new ActionSetNwDstConvertorV10Impl());
- conversionMapping.put(OFConstants.OFP_VERSION_1_3, new ActionSetNwDstConvertorImpl());
- }
-
- /**
- * @param injectionMapping injection mapping
- */
- public static void addSetNwDstInjectors(final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping) {
- // OF-1.0| Ipv4Address -> ActionBuilder; SetNwDst
- injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_0,
- ActionBuilder.class, Ipv4Address.class),
- new ResultInjector<Ipv4Address, ActionBuilder>() {
- @Override
- public void inject(final Ipv4Address result, final ActionBuilder target) {
- SetNwDstCaseBuilder setNwDstCaseBuilder = new SetNwDstCaseBuilder();
- SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
- setNwDstActionBuilder.setIpAddress(result);
- setNwDstCaseBuilder.setSetNwDstAction(setNwDstActionBuilder.build());
- target.setActionChoice(setNwDstCaseBuilder.build());
- }
- });
-
- // OF-1.3| Ipv4Address -> ActionBuilder; SetNwDst
- injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
- ActionBuilder.class, Ipv4Address.class),
- new ResultInjector<Ipv4Address, ActionBuilder>() {
- @Override
- public void inject(final Ipv4Address result, final ActionBuilder target) {
- List<MatchEntry> matchEntriesList = new ArrayList<>();
- MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
- matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
-
- Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
- Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
- ipv4DstBuilder.setIpv4Address(result);
- Integer prefix = IpConversionUtil.extractPrefix(result);
- if (prefix != null) {
- ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
- }
- ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
-
- matchEntryBuilder.setHasMask(false);
- matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
- matchEntriesList.add(matchEntryBuilder.build());
-
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
- setFieldActionBuilder.setMatchEntry(matchEntriesList);
- setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
- target.setActionChoice(setFieldCaseBuilder.build());
- }
- });
-
- // OF-1.3| Ipv6Address -> ActionBuilder; SetNwDst
- injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
- ActionBuilder.class, Ipv6Address.class),
- new ResultInjector<Ipv6Address, ActionBuilder>() {
- @Override
- public void inject(final Ipv6Address result, final ActionBuilder target) {
- List<MatchEntry> matchEntriesList = new ArrayList<>();
- MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
- matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
-
- Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
- Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
- ipv6DstBuilder.setIpv6Address(result);
- Integer prefix = IpConversionUtil.extractPrefix(result);
- if (prefix != null) {
- ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
- }
- ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
-
- matchEntryBuilder.setHasMask(false);
- matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
- matchEntriesList.add(matchEntryBuilder.build());
-
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
- setFieldActionBuilder.setMatchEntry(matchEntriesList);
- setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
- target.setActionChoice(setFieldCaseBuilder.build());
- }
- });
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 Ericsson. 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.action;
-
-import com.google.common.base.Splitter;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwSrcConvertorImpl implements Convertor<SetNwSrcActionCase, Object> {
-
- private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
-
- @Override
- public Class<?> getType() {
- return SetNwSrcActionCase.class;
- }
-
- @Override
- public Object convert(final SetNwSrcActionCase source) {
- Address address = source.getSetNwSrcAction().getAddress();
- if (address instanceof Ipv4) {
- Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
- return new Ipv4Address(addressParts.iterator().next());
- } else if (address instanceof Ipv6) {
- Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
- return new Ipv6Address(addressParts.iterator().next());
- } else {
- throw new IllegalArgumentException("Address is not supported: "+address.getClass().getName());
- }
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 Ericsson. 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.action;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-
-/**
- * Utility class for converting a MD-SAL action subelement into the OF subelement
- */
-public class ActionSetNwSrcConvertorV10Impl implements Convertor<SetNwSrcActionCase, Object> {
-
- @Override
- public Class<?> getType() {
- return SetNwSrcActionCase.class;
- }
-
- @Override
- public Object convert(SetNwSrcActionCase source) {
- Address address = source.getSetNwSrcAction().getAddress();
- if (address instanceof Ipv4) {
- //FIXME use of substring should be removed and OF models should distinguish where
- //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
-
- String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
- ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
- return new Ipv4Address(ipAddress);
- } else {
- throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
- }
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 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.action;
-
-import java.util.Map;
-
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertReactor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-
-/**
- *
- */
-public class ActionSetNwSrcReactor extends ConvertReactor<SetNwSrcActionCase> {
-
- private static ActionSetNwSrcReactor INSTANCE = new ActionSetNwSrcReactor();
-
- private ActionSetNwSrcReactor() {
- //NOOP
- }
-
- /**
- * @return singleton
- */
- public static ActionSetNwSrcReactor getInstance() {
- return INSTANCE;
- }
-
- @Override
- protected void initMappings(final Map<Short, Convertor<SetNwSrcActionCase,?>> conversions,
- final Map<InjectionKey, ResultInjector<?,?>> injections) {
- ActionSetNwSrcReactorMappingFactory.addSetNwSrcConvertors(conversions);
- ActionSetNwSrcReactorMappingFactory.addSetNwSrcInjectors(injections);
- }
-
- @Override
- protected InjectionKey buildInjectionKey(final short version,
- final Object convertedItem, final Object target) {
- InjectionResultTargetKey key = null;
- if (convertedItem != null) {
- key = new InjectionResultTargetKey(version, target.getClass(), convertedItem.getClass());
- }
- return key;
- }
-
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 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.action;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.InjectionResultTargetKey;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ResultInjector;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
-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.Ipv4SrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
-
-/**
- * add prepared convertors and injectors into given mappings
- *
- * @see ActionSetNwSrcReactor
- */
-public class ActionSetNwSrcReactorMappingFactory {
-
- /**
- * @param conversionMapping conversion mapping
- */
- public static void addSetNwSrcConvertors(final Map<Short, Convertor<SetNwSrcActionCase, ?>> conversionMapping) {
- conversionMapping.put(OFConstants.OFP_VERSION_1_0, new ActionSetNwSrcConvertorV10Impl());
- conversionMapping.put(OFConstants.OFP_VERSION_1_3, new ActionSetNwSrcConvertorImpl());
- }
-
- /**
- * @param injectionMapping injection mapping
- */
- public static void addSetNwSrcInjectors(final Map<InjectionKey, ResultInjector<?, ?>> injectionMapping) {
- // OF-1.0| Ipv4Address -> ActionBuilder; SetNwSrc
- injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_0,
- ActionBuilder.class, Ipv4Address.class),
- new ResultInjector<Ipv4Address, ActionBuilder>() {
- @Override
- public void inject(final Ipv4Address result, final ActionBuilder target) {
- SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
- SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
- nwSrcBuilder.setIpAddress(new Ipv4Address(result));
- nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
- target.setActionChoice(nwSrcCaseBuilder.build());
- }
- });
-
- // OF-1.3| Ipv4Address -> ActionBuilder; SetNwSrc
- injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
- ActionBuilder.class, Ipv4Address.class),
- new ResultInjector<Ipv4Address, ActionBuilder>() {
- @Override
- public void inject(final Ipv4Address result, final ActionBuilder target) {
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
- List<MatchEntry> entries = new ArrayList<>();
- MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
- matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
-
- Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
- Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
- ipv4SrcBuilder.setIpv4Address(result);
- Integer prefix = IpConversionUtil.extractPrefix(result);
- if (prefix != null) {
- ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
- }
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
-
- matchEntryBuilder.setHasMask(false);
- matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
- entries.add(matchEntryBuilder.build());
- setFieldBuilder.setMatchEntry(entries);
- setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
- target.setActionChoice(setFieldCaseBuilder.build());
- }
- });
-
- // OF-1.3| Ipv6Address -> ActionBuilder; SetNwSrc
- injectionMapping.put(new InjectionResultTargetKey(OFConstants.OFP_VERSION_1_3,
- ActionBuilder.class, Ipv6Address.class),
- new ResultInjector<Ipv6Address, ActionBuilder>() {
- @Override
- public void inject(final Ipv6Address result, final ActionBuilder target) {
- List<MatchEntry> matchEntriesList = new ArrayList<>();
- MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
- matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
- matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
-
- Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
- Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
- ipv6SrcBuilder.setIpv6Address(result);
- Integer prefix = IpConversionUtil.extractPrefix(result);
- if (prefix != null) {
- ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
- }
- ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
-
- matchEntryBuilder.setHasMask(false);
- matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
- matchEntriesList.add(matchEntryBuilder.build());
-
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
- setFieldActionBuilder.setMatchEntry(matchEntriesList);
- setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
- target.setActionChoice(setFieldCaseBuilder.build());
-
- }
- });
- }
-
- private static byte[] extractIpv4Mask(boolean hasMask, final Iterator<String> addressParts) {
- final int prefix;
- if (addressParts.hasNext()) {
- int potentionalPrefix = Integer.parseInt(addressParts.next());
- prefix = potentionalPrefix < 32 ? potentionalPrefix : 0;
- } else {
- prefix = 0;
- }
-
- if (prefix != 0) {
- int mask = 0xffffffff << (32 - prefix);
- byte[] maskBytes = new byte[]{(byte) (mask >>> 24), (byte) (mask >>> 16), (byte) (mask >>> 8),
- (byte) mask};
- hasMask = true;
- return maskBytes;
- }
- return null;
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
+
+public class OfToSalCopyTtlInCase extends ConvertorCase<CopyTtlInCase, Action, ActionResponseConvertorData> {
+ public OfToSalCopyTtlInCase() {
+ super(CopyTtlInCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final CopyTtlInCase source, final ActionResponseConvertorData data) {
+ CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
+ return Optional.of(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
+
+public class OfToSalCopyTtlOutCase extends ConvertorCase<CopyTtlOutCase, Action, ActionResponseConvertorData> {
+ public OfToSalCopyTtlOutCase() {
+ super(CopyTtlOutCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final CopyTtlOutCase source, final ActionResponseConvertorData data) {
+ CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
+ return Optional.of(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
+
+public class OfToSalDecMplsTtlCase extends ConvertorCase<DecMplsTtlCase, Action, ActionResponseConvertorData> {
+ public OfToSalDecMplsTtlCase() {
+ super(DecMplsTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final DecMplsTtlCase source, final ActionResponseConvertorData data) {
+ DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
+ return Optional.of(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase;
+
+public class OfToSalDecNwTtlCase extends ConvertorCase<DecNwTtlCase, Action, ActionResponseConvertorData> {
+ public OfToSalDecNwTtlCase() {
+ super(DecNwTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final DecNwTtlCase source, final ActionResponseConvertorData data) {
+ DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
+ return Optional.of(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupAction;
+
+public class OfToSalGroupCase extends ConvertorCase<GroupCase, Action, ActionResponseConvertorData> {
+ public OfToSalGroupCase() {
+ super(GroupCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final GroupCase source, final ActionResponseConvertorData data) {
+ GroupAction groupActionFromOF = source.getGroupAction();
+ GroupActionBuilder groupAction = new GroupActionBuilder();
+ groupAction.setGroupId(groupActionFromOF.getGroupId());
+
+ return Optional.of(new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OfToSalOutputActionCase extends ConvertorCase<OutputActionCase, Action, ActionResponseConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(OfToSalOutputActionCase.class);
+
+ public OfToSalOutputActionCase() {
+ super(OutputActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionResponseConvertorData data) {
+ final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
+
+ OutputActionBuilder outputAction = new OutputActionBuilder();
+ OutputAction outputActionFromOF = source.getOutputAction();
+
+ if (outputActionFromOF.getPort() != null) {
+ PortNumberUni protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(ofVersion, outputActionFromOF.getPort().getValue());
+ String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
+ outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
+ } else {
+ LOG.error("Provided action is not OF Output action, no associated port found!");
+ }
+
+ Integer maxLength = outputActionFromOF.getMaxLength();
+
+ if (maxLength != null) {
+ outputAction.setMaxLength(maxLength);
+ } else {
+ LOG.error("Provided action is not OF Output action, no associated length found!");
+ }
+
+ OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+ outputActionCaseBuilder.setOutputAction(outputAction.build());
+
+ return Optional.of(outputActionCaseBuilder.build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsAction;
+
+public class OfToSalPopMplsCase extends ConvertorCase<PopMplsCase, Action, ActionResponseConvertorData> {
+ public OfToSalPopMplsCase() {
+ super(PopMplsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final PopMplsCase source, final ActionResponseConvertorData data) {
+ PopMplsAction popMplsActionFromOF = source.getPopMplsAction();
+ PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
+ popMplsAction.setEthernetType(popMplsActionFromOF.getEthertype().getValue());
+ return Optional.of(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase;
+
+public class OfToSalPopPbbCase extends ConvertorCase<PopPbbCase, Action, ActionResponseConvertorData> {
+ public OfToSalPopPbbCase() {
+ super(PopPbbCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final PopPbbCase source, final ActionResponseConvertorData data) {
+ PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
+ return Optional.of(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
+
+public class OfToSalPopVlanCase extends ConvertorCase<PopVlanCase, Action, ActionResponseConvertorData> {
+ public OfToSalPopVlanCase() {
+ super(PopVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final PopVlanCase source, final ActionResponseConvertorData data) {
+ PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
+ return Optional.of(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsAction;
+
+public class OfToSalPushMplsCase extends ConvertorCase<PushMplsCase, Action, ActionResponseConvertorData> {
+ public OfToSalPushMplsCase() {
+ super(PushMplsCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final PushMplsCase source, final ActionResponseConvertorData data) {
+ PushMplsAction pushMplsActionFromOF = source.getPushMplsAction();
+ PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
+ pushMplsAction.setEthernetType(pushMplsActionFromOF.getEthertype().getValue());
+ return Optional.of(new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbAction;
+
+public class OfToSalPushPbbCase extends ConvertorCase<PushPbbCase, Action, ActionResponseConvertorData> {
+ public OfToSalPushPbbCase() {
+ super(PushPbbCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final PushPbbCase source, final ActionResponseConvertorData data) {
+ PushPbbAction pushPbbActionFromOf = source.getPushPbbAction();
+ PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
+ pushPbbAction.setEthernetType(pushPbbActionFromOf.getEthertype().getValue());
+ return Optional.of(new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanAction;
+
+public class OfToSalPushVlanCase extends ConvertorCase<PushVlanCase, Action, ActionResponseConvertorData> {
+ public OfToSalPushVlanCase() {
+ super(PushVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final PushVlanCase source, final ActionResponseConvertorData data) {
+ PushVlanAction pushVlanActionFromOF = source.getPushVlanAction();
+ PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
+ pushVlanAction.setEthernetType(pushVlanActionFromOF.getEthertype().getValue());
+ return Optional.of(new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldAction;
+
+public class OfToSalSetFieldCase extends ConvertorCase<SetFieldCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetFieldCase() {
+ super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionResponseConvertorData data) {
+ final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(data.getVersion());
+ final SetFieldAction setFieldAction = source.getSetFieldAction();
+ final SetFieldBuilder setField = new SetFieldBuilder();
+ final Optional<MatchBuilder> matchOptional = ConvertorManager.getInstance().convert(setFieldAction, datapathIdConvertorData);
+ setField.fieldsFrom(matchOptional.orElse(new MatchBuilder()).build());
+
+ return Optional.of(new SetFieldCaseBuilder().setSetField(setField.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlAction;
+
+public class OfToSalSetMplsTtlCase extends ConvertorCase<SetMplsTtlCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetMplsTtlCase() {
+ super(SetMplsTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetMplsTtlCase source, final ActionResponseConvertorData data) {
+ SetMplsTtlAction setMplsTtlActionFromOF = source.getSetMplsTtlAction();
+
+ SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
+ mplsTtlAction.setMplsTtl(setMplsTtlActionFromOF.getMplsTtl());
+ return Optional.of(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase;
+
+public class OfToSalSetNwDstCase extends ConvertorCase<SetNwDstCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetNwDstCase() {
+ super(SetNwDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwDstCase source, final ActionResponseConvertorData data) {
+ SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+ return Optional.of(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlAction;
+
+public class OfToSalSetNwTtlCase extends ConvertorCase<SetNwTtlCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetNwTtlCase() {
+ super(SetNwTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwTtlCase source, final ActionResponseConvertorData data) {
+ SetNwTtlAction setNwTtlActionFromOf = source.getSetNwTtlAction();
+ SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
+ setNwTtl.setNwTtl(setNwTtlActionFromOf.getNwTtl());
+ return Optional.of(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueAction;
+
+public class OfToSalSetQueueCase extends ConvertorCase<SetQueueCase, Action, ActionResponseConvertorData> {
+ public OfToSalSetQueueCase() {
+ super(SetQueueCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final SetQueueCase source, final ActionResponseConvertorData data) {
+ SetQueueAction queueActionFromOF = source.getSetQueueAction();
+ SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
+ setQueueAction.setQueueId(queueActionFromOF.getQueueId());
+ return Optional.of(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase;
+
+public class OfToSalStripVlanCase extends ConvertorCase<StripVlanCase, Action, ActionResponseConvertorData> {
+ public OfToSalStripVlanCase() {
+ super(StripVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Override
+ public Optional<Action> process(@Nonnull final StripVlanCase source, final ActionResponseConvertorData data) {
+ PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
+ return Optional.of(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfCopyTtlInCase extends ConvertorCase<CopyTtlInCase, Action, ActionConvertorData> {
+ public SalToOfCopyTtlInCase() {
+ super(CopyTtlInCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final CopyTtlInCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new CopyTtlInCaseBuilder().build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfCopyTtlOutCase extends ConvertorCase<CopyTtlOutCase, Action, ActionConvertorData> {
+ public SalToOfCopyTtlOutCase() {
+ super(CopyTtlOutCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final CopyTtlOutCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new CopyTtlOutCaseBuilder().build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfDecMplsTtlCase extends ConvertorCase<DecMplsTtlCase, Action, ActionConvertorData> {
+ public SalToOfDecMplsTtlCase() {
+ super(DecMplsTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final DecMplsTtlCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new DecMplsTtlCaseBuilder().build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfDecNwTtlCase extends ConvertorCase<DecNwTtlCase, Action, ActionConvertorData> {
+ public SalToOfDecNwTtlCase() {
+ super(DecNwTtlCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final DecNwTtlCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new DecNwTtlCaseBuilder().build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+
+public class SalToOfDropActionCase extends ConvertorCase<DropActionCase, Action, ActionConvertorData> {
+ public SalToOfDropActionCase() {
+ super(DropActionCase.class, false, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final DropActionCase source, final ActionConvertorData data) {
+ return Optional.empty();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfGeneralExtensionGroupingCase extends ConvertorCase<GeneralExtensionGrouping, Action, ActionConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(SalToOfGeneralExtensionGroupingCase.class);
+
+ public SalToOfGeneralExtensionGroupingCase() {
+ super(GeneralExtensionGrouping.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final GeneralExtensionGrouping source, final ActionConvertorData data) {
+ final short version = data.getVersion();
+ /**
+ * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
+ * - we might need sessionContext as converter input
+ *
+ */
+
+ Extension extAction = source.getExtension();
+ ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(source.getExtensionKey(), version);
+ ConvertorToOFJava<Action> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+ return convertor != null ? Optional.of(convertor.convert(extAction)) : Optional.empty();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfGroupActionCase extends ConvertorCase<GroupActionCase, Action, ActionConvertorData> {
+ public SalToOfGroupActionCase() {
+ super(GroupActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final GroupActionCase source, final ActionConvertorData data) {
+ GroupAction groupAction = source.getGroupAction();
+ GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
+
+ if (null != groupAction.getGroupId()) {
+ groupActionBuilder.setGroupId(groupAction.getGroupId());
+ } else {
+ groupActionBuilder.setGroupId(Long.parseLong(groupAction.getGroup()));
+ }
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new GroupCaseBuilder()
+ .setGroupAction(groupActionBuilder.build())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfOutputActionCase extends ConvertorCase<OutputActionCase, Action, ActionConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(SalToOfOutputActionCase.class);
+
+ public SalToOfOutputActionCase() {
+ super(OutputActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionConvertorData data) {
+ final OutputAction outputAction = source.getOutputAction();
+ final OutputActionBuilder outputBuilder = new OutputActionBuilder();
+
+ if (outputAction.getMaxLength() != null) {
+ outputBuilder.setMaxLength(outputAction.getMaxLength());
+ } else {
+ outputBuilder.setMaxLength(0);
+ }
+
+ final OpenflowVersion version = OpenflowVersion.get(data.getVersion());
+ final String nodeConnectorId = outputAction.getOutputNodeConnector().getValue();
+ final Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(version, nodeConnectorId);
+
+ if (OpenflowPortsUtil.checkPortValidity(version, portNumber)) {
+ outputBuilder.setPort(new PortNumber(portNumber));
+ } else {
+ LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, version);
+ }
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new OutputActionCaseBuilder()
+ .setOutputAction(outputBuilder.build())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPopMplsActionCase extends ConvertorCase<PopMplsActionCase, Action, ActionConvertorData> {
+ public SalToOfPopMplsActionCase() {
+ super(PopMplsActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PopMplsActionCase source, final ActionConvertorData data) {
+ PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
+ PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
+ popMplsBuilder.setEthertype(new EtherType(new EtherType(source.getPopMplsAction().getEthernetType())));
+ popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(popMplsCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfPopPbbActionCase extends ConvertorCase<PopPbbActionCase, Action, ActionConvertorData> {
+ public SalToOfPopPbbActionCase() {
+ super(PopPbbActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PopPbbActionCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new PopPbbCaseBuilder().build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfPopVlanActionCase extends ConvertorCase<PopVlanActionCase, Action, ActionConvertorData> {
+ public SalToOfPopVlanActionCase() {
+ super(PopVlanActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PopVlanActionCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new PopVlanCaseBuilder().build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfPopVlanActionV10Case extends ConvertorCase<PopVlanActionCase, Action, ActionConvertorData> {
+ public SalToOfPopVlanActionV10Case() {
+ super(PopVlanActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PopVlanActionCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new StripVlanCaseBuilder().build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPushMplsActionCase extends ConvertorCase<PushMplsActionCase, Action, ActionConvertorData> {
+ public SalToOfPushMplsActionCase() {
+ super(PushMplsActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PushMplsActionCase source, final ActionConvertorData data) {
+ PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
+ PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
+ pushMplsBuilder.setEthertype(new EtherType(source.getPushMplsAction().getEthernetType()));
+ pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(pushMplsCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPushPbbActionCase extends ConvertorCase<PushPbbActionCase, Action, ActionConvertorData> {
+ public SalToOfPushPbbActionCase() {
+ super(PushPbbActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PushPbbActionCase source, final ActionConvertorData data) {
+ PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
+ PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
+ pushPbbBuilder.setEthertype(new EtherType(source.getPushPbbAction().getEthernetType()));
+ pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(pushPbbCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+
+public class SalToOfPushVlanActionCase extends ConvertorCase<PushVlanActionCase, Action, ActionConvertorData> {
+ public SalToOfPushVlanActionCase() {
+ super(PushVlanActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final PushVlanActionCase source, final ActionConvertorData data) {
+ PushVlanAction pushVlanAction = source.getPushVlanAction();
+
+ PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
+ PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
+
+ if (pushVlanAction.getEthernetType() != null) {
+ pushVlanBuilder.setEthertype(new EtherType(pushVlanAction.getEthernetType()));
+ }
+
+ pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(pushVlanCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.eth.dst._case.EthDstBuilder;
+
+public class SalToOfSetDlDstActionCase extends ConvertorCase<SetDlDstActionCase, Action, ActionConvertorData> {
+ public SalToOfSetDlDstActionCase() {
+ super(SetDlDstActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetDlDstActionCase source, final ActionConvertorData data) {
+ SetDlDstAction setdldstaction = source.getSetDlDstAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ List<MatchEntry> entries = new ArrayList<>();
+
+ MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+ matchBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchBuilder.setOxmMatchField(EthDst.class);
+ EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
+ EthDstBuilder ethDstBuilder = new EthDstBuilder();
+ ethDstBuilder.setMacAddress(setdldstaction.getAddress());
+ matchBuilder.setHasMask(false);
+ ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
+ matchBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
+ entries.add(matchBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.dst._case.SetDlDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetDlDstActionV10Case extends ConvertorCase<SetDlDstActionCase, Action, ActionConvertorData> {
+ public SalToOfSetDlDstActionV10Case() {
+ super(SetDlDstActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetDlDstActionCase source, final ActionConvertorData data) {
+ SetDlDstAction setdldstaction = source.getSetDlDstAction();
+ SetDlDstCaseBuilder setDlDstCaseBuilder = new SetDlDstCaseBuilder();
+ SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
+ setDlDstActionBuilder.setDlDstAddress(setdldstaction.getAddress());
+ setDlDstCaseBuilder.setSetDlDstAction(setDlDstActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setDlDstCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.EthSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;
+
+public class SalToOfSetDlSrcActionCase extends ConvertorCase<SetDlSrcActionCase, Action, ActionConvertorData> {
+ public SalToOfSetDlSrcActionCase() {
+ super(SetDlSrcActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetDlSrcActionCase source, final ActionConvertorData data) {
+ SetDlSrcAction setdlsrcaction = source.getSetDlSrcAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+ matchBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchBuilder.setOxmMatchField(EthSrc.class);
+ EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
+ EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
+ ethSrcBuilder.setMacAddress(setdlsrcaction.getAddress());
+ matchBuilder.setHasMask(false);
+ ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
+ matchBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
+ entries.add(matchBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.dl.src._case.SetDlSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetDlSrcActionV10Case extends ConvertorCase<SetDlSrcActionCase, Action, ActionConvertorData> {
+ public SalToOfSetDlSrcActionV10Case() {
+ super(SetDlSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetDlSrcActionCase source, final ActionConvertorData data) {
+ SetDlSrcAction setdlsrcaction = source.getSetDlSrcAction();
+ SetDlSrcCaseBuilder setDlSrcCaseBuilder = new SetDlSrcCaseBuilder();
+ SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
+ setDlSrcActionBuilder.setDlSrcAddress(setdlsrcaction.getAddress());
+ setDlSrcCaseBuilder.setSetDlSrcAction(setDlSrcActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setDlSrcCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetFieldCase extends ConvertorCase<SetFieldCase, Action, ActionConvertorData> {
+ public SalToOfSetFieldCase() {
+ super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionConvertorData data) {
+ final short version = data.getVersion();
+ final SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ MatchReactor.getInstance().convert(source.getSetField(), version, setFieldBuilder);
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new SetFieldCaseBuilder()
+ .setSetFieldAction(setFieldBuilder.build())
+ .build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetFieldV10Case extends ConvertorCase<SetFieldCase, Action, ActionConvertorData> {
+ public SalToOfSetFieldV10Case() {
+ super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionConvertorData data) {
+ SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
+
+ if (source.getSetField().getVlanMatch() != null) {
+ setVlanVidCaseBuilder.setSetVlanVidAction(new SetVlanVidActionBuilder()
+ .setVlanVid(source.getSetField().getVlanMatch().getVlanId().getVlanId().getValue())
+ .build());
+ }
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setVlanVidCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetMplsTtlActionCase extends ConvertorCase<SetMplsTtlActionCase, Action, ActionConvertorData> {
+ public SalToOfSetMplsTtlActionCase() {
+ super(SetMplsTtlActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetMplsTtlActionCase source, final ActionConvertorData data) {
+ SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder()
+ .setMplsTtl(source.getSetMplsTtlAction().getMplsTtl());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new SetMplsTtlCaseBuilder()
+ .setSetMplsTtlAction(setMplsTtlBuilder.build())
+ .build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import com.google.common.base.Splitter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
+
+public class SalToOfSetNwDstActionCase extends ConvertorCase<SetNwDstActionCase, Action, ActionConvertorData> {
+ private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
+
+ public SalToOfSetNwDstActionCase() {
+ super(SetNwDstActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data) {
+ final ActionBuilder builder = new ActionBuilder();
+ final Address address = source.getSetNwDstAction().getAddress();
+
+ if (address instanceof Ipv4) {
+ Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
+ Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
+
+ Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
+ ipv4DstBuilder.setIpv4Address(result);
+ Integer prefix = IpConversionUtil.extractPrefix(result);
+ ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
+
+ matchEntryBuilder.setHasMask(false);
+ matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ matchEntriesList.add(matchEntryBuilder.build());
+
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+ setFieldActionBuilder.setMatchEntry(matchEntriesList);
+ setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+ builder.setActionChoice(setFieldCaseBuilder.build());
+ } else if (address instanceof Ipv6) {
+ Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
+ Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
+
+ Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
+ ipv6DstBuilder.setIpv6Address(result);
+ Integer prefix = IpConversionUtil.extractPrefix(result);
+ ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+
+ matchEntryBuilder.setHasMask(false);
+ matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ matchEntriesList.add(matchEntryBuilder.build());
+
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+ setFieldActionBuilder.setMatchEntry(matchEntriesList);
+ setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+ builder.setActionChoice(setFieldCaseBuilder.build());
+ } else {
+ throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
+ }
+
+ return Optional.of(builder.build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.dst._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwDstActionV10Case extends ConvertorCase<SetNwDstActionCase, Action, ActionConvertorData> {
+ public SalToOfSetNwDstActionV10Case() {
+ super(SetNwDstActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data) {
+ final ActionBuilder builder = new ActionBuilder();
+ final Address address = source.getSetNwDstAction().getAddress();
+
+ if (address instanceof Ipv4) {
+ //FIXME use of substring should be removed and OF models should distinguish where
+ //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
+
+ String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
+ ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
+ Ipv4Address result = new Ipv4Address(ipAddress);
+ SetNwDstCaseBuilder setNwDstCaseBuilder = new SetNwDstCaseBuilder();
+ SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+ setNwDstActionBuilder.setIpAddress(result);
+ setNwDstCaseBuilder.setSetNwDstAction(setNwDstActionBuilder.build());
+ builder.setActionChoice(setNwDstCaseBuilder.build());
+ } else {
+ throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
+ }
+
+ return Optional.of(builder.build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import com.google.common.base.Splitter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
+
+public class SalToOfSetNwSrcActionCase extends ConvertorCase<SetNwSrcActionCase, Action, ActionConvertorData> {
+ private static final Splitter PREFIX_SPLITTER = Splitter.on('/');
+
+ public SalToOfSetNwSrcActionCase() {
+ super(SetNwSrcActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data) {
+ final ActionBuilder builder = new ActionBuilder();
+ final Address address = source.getSetNwSrcAction().getAddress();
+
+ if (address instanceof Ipv4) {
+ Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
+ Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
+
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+ List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
+
+ Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(result);
+ Integer prefix = IpConversionUtil.extractPrefix(result);
+ ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+
+ matchEntryBuilder.setHasMask(false);
+ matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(matchEntryBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+ builder.setActionChoice(setFieldCaseBuilder.build());
+ } else if (address instanceof Ipv6) {
+ Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
+ Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
+
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
+
+ Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+ ipv6SrcBuilder.setIpv6Address(result);
+ Integer prefix = IpConversionUtil.extractPrefix(result);
+ ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+
+ matchEntryBuilder.setHasMask(false);
+ matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ matchEntriesList.add(matchEntryBuilder.build());
+
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+ setFieldActionBuilder.setMatchEntry(matchEntriesList);
+ setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+ builder.setActionChoice(setFieldCaseBuilder.build());
+ } else {
+ throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
+ }
+
+ return Optional.of(builder.build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwSrcActionV10Case extends ConvertorCase<SetNwSrcActionCase, Action, ActionConvertorData> {
+ public SalToOfSetNwSrcActionV10Case() {
+ super(SetNwSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data) {
+ final ActionBuilder builder = new ActionBuilder();
+ final Address address = source.getSetNwSrcAction().getAddress();
+
+ if (address instanceof Ipv4) {
+ //FIXME use of substring should be removed and OF models should distinguish where
+ //FIXME to use Ipv4Prefix (with mask) and where to use Ipv4Address (without mask)
+
+ String ipAddress = ((Ipv4) address).getIpv4Address().getValue();
+ ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
+ Ipv4Address result = new Ipv4Address(ipAddress);
+ SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
+ SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
+ nwSrcBuilder.setIpAddress(new Ipv4Address(result));
+ nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
+ builder.setActionChoice(nwSrcCaseBuilder.build());
+ } else {
+ throw new IllegalArgumentException("Address is not supported by OF-1.0: " + address.getClass().getName());
+ }
+
+ return Optional.of(builder.build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+
+public class SalToOfSetNwTosActionCase extends ConvertorCase<SetNwTosActionCase, Action, ActionConvertorData> {
+ public SalToOfSetNwTosActionCase() {
+ super(SetNwTosActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data) {
+ SetNwTosAction setnwtosaction = source.getSetNwTosAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ List<MatchEntry> entries = new ArrayList<>();
+ entries.add(MatchConvertorUtil.toOfIpDscp(new Dscp(
+ ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
+ )));
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.tos._case.SetNwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwTosActionV10Case extends ConvertorCase<SetNwTosActionCase, Action, ActionConvertorData> {
+ public SalToOfSetNwTosActionV10Case() {
+ super(SetNwTosActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwTosActionCase source, final ActionConvertorData data) {
+ SetNwTosAction setnwtosaction = source.getSetNwTosAction();
+ SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+ SetNwTosCaseBuilder setNwTosCaseBuilder = new SetNwTosCaseBuilder();
+ setNwTosActionBuilder.setNwTos(setnwtosaction.getTos().shortValue());
+ setNwTosCaseBuilder.setSetNwTosAction(setNwTosActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setNwTosCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetNwTtlActionCase extends ConvertorCase<SetNwTtlActionCase, Action, ActionConvertorData> {
+ public SalToOfSetNwTtlActionCase() {
+ super(SetNwTtlActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetNwTtlActionCase source, final ActionConvertorData data) {
+ SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
+ SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
+ nwTtlBuilder.setNwTtl(source.getSetNwTtlAction().getNwTtl());
+ nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(nwTtlCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.queue._case.SetQueueActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetQueueActionCase extends ConvertorCase<SetQueueActionCase, Action, ActionConvertorData> {
+ public SalToOfSetQueueActionCase() {
+ super(SetQueueActionCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetQueueActionCase source, final ActionConvertorData data) {
+ SetQueueAction setQueueAction = source.getSetQueueAction();
+ SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
+ SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
+ setQueueBuilder.setQueueId(setQueueAction.getQueueId());
+ setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setQueueCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
+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.UdpDst;
+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.Icmpv4CodeCaseBuilder;
+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.TcpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
+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.icmpv6.code._case.Icmpv6CodeBuilder;
+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.udp.dst._case.UdpDstBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfSetTpDstActionCase extends ConvertorCase<SetTpDstActionCase, Action, ActionConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpDstActionCase.class);
+
+ public SalToOfSetTpDstActionCase() {
+ super(SetTpDstActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data) {
+ IPProtocols protocol = null;
+
+ if (data.getIpProtocol() != null) {
+ protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
+ }
+
+ SetTpDstAction settpdstaction = source.getSetTpDstAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+ matchBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchBuilder.setHasMask(false);
+ int port = settpdstaction.getPort().getValue();
+ int code = 0xff & port;
+
+ if (protocol != null) {
+ switch (protocol) {
+ case ICMP:
+ matchBuilder.setOxmMatchField(Icmpv4Code.class);
+ Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
+ Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
+ icmpv4CodeBuilder.setIcmpv4Code((short) code);
+ icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
+ matchBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
+ break;
+ case ICMPV6:
+ matchBuilder.setOxmMatchField(Icmpv6Code.class);
+ Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
+ Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
+ icmpv6CodeBuilder.setIcmpv6Code((short) code);
+ icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
+ matchBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
+ break;
+ case TCP:
+ matchBuilder.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.rev130715.PortNumber(port));
+ tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
+ matchBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
+ break;
+ case UDP:
+ matchBuilder.setOxmMatchField(UdpDst.class);
+ UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
+ UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
+ udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(port));
+ udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
+ matchBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
+ break;
+ default:
+ LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+ break;
+ }
+ } else {
+ LOG.warn("Missing protocol with combination of SetSourcePort");
+ }
+
+ List<MatchEntry> entries = new ArrayList<>();
+ entries.add(matchBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.dst._case.SetTpDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+
+public class SalToOfSetTpDstActionV10Case extends ConvertorCase<SetTpDstActionCase, Action, ActionConvertorData> {
+ public SalToOfSetTpDstActionV10Case() {
+ super(SetTpDstActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetTpDstActionCase source, final ActionConvertorData data) {
+ SetTpDstAction settpdstaction = source.getSetTpDstAction();
+ SetTpDstCaseBuilder setTpDstCaseBuilder = new SetTpDstCaseBuilder();
+ SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+ setTpDstActionBuilder.setPort(new PortNumber(settpdstaction.getPort().getValue().longValue()));
+ setTpDstCaseBuilder.setSetTpDstAction(setTpDstActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setTpDstCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IPProtocols;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
+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.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
+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.Icmpv4TypeCaseBuilder;
+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.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.icmpv4.type._case.Icmpv4TypeBuilder;
+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.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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfSetTpSrcActionCase extends ConvertorCase<SetTpSrcActionCase, Action, ActionConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpSrcActionCase.class);
+
+ public SalToOfSetTpSrcActionCase() {
+ super(SetTpSrcActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data) {
+ IPProtocols protocol = null;
+
+ if (data.getIpProtocol() != null) {
+ protocol = IPProtocols.fromProtocolNum(data.getIpProtocol());
+ }
+
+ SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+ matchBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchBuilder.setHasMask(false);
+
+ int port = settpsrcaction.getPort().getValue();
+ int type = 0xff & port;
+
+ if (protocol != null) {
+ switch (protocol) {
+ case ICMP:
+ matchBuilder.setOxmMatchField(Icmpv4Type.class);
+ Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
+ Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
+ icmpv4TypeBuilder.setIcmpv4Type((short) type);
+ icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
+ matchBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
+ break;
+ case ICMPV6:
+ matchBuilder.setOxmMatchField(Icmpv6Type.class);
+ Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
+ Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
+ icmpv6TypeBuilder.setIcmpv6Type((short) type);
+ icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
+ matchBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
+ break;
+ case TCP:
+ matchBuilder.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.rev130715.PortNumber(port));
+ tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
+ matchBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
+ break;
+ case UDP:
+ matchBuilder.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.rev130715.PortNumber(port));
+ udpSrcCaseBuilder.setUdpSrc(udpSrcBuilder.build());
+ matchBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
+ break;
+ default:
+ LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
+ break;
+ }
+ } else {
+ LOG.warn("Null protocol with combination of SetSourcePort");
+ }
+
+ List<MatchEntry> entries = new ArrayList<>();
+ entries.add(matchBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.tp.src._case.SetTpSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfSetTpSrcActionV10Case extends ConvertorCase<SetTpSrcActionCase, Action, ActionConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(SalToOfSetTpSrcActionV10Case.class);
+
+ public SalToOfSetTpSrcActionV10Case() {
+ super(SetTpSrcActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetTpSrcActionCase source, final ActionConvertorData data) {
+ SetTpSrcAction settpsrcaction = source.getSetTpSrcAction();
+ SetTpSrcCaseBuilder setTpSrcCaseBuilder = new SetTpSrcCaseBuilder();
+ SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+ setTpSrcActionBuilder.setPort(new PortNumber(settpsrcaction.getPort()
+ .getValue()
+ .longValue()));
+ setTpSrcCaseBuilder.setSetTpSrcAction(setTpSrcActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setTpSrcCaseBuilder.build())
+ .build());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+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.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.VlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
+
+public class SalToOfSetVlanIdActionCase extends ConvertorCase<SetVlanIdActionCase, Action, ActionConvertorData> {
+ public SalToOfSetVlanIdActionCase() {
+ super(SetVlanIdActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetVlanIdActionCase source, final ActionConvertorData data) {
+ SetVlanIdAction setvlanidaction = source.getSetVlanIdAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+ List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+ matchBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchBuilder.setOxmMatchField(VlanVid.class);
+ matchBuilder.setHasMask(false);
+ VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+ VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+ vlanVidBuilder.setCfiBit(true);
+ vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
+ vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+ matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+ entries.add(matchBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+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.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.vid._case.SetVlanVidActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetVlanIdActionV10Case extends ConvertorCase<SetVlanIdActionCase, Action, ActionConvertorData> {
+ public SalToOfSetVlanIdActionV10Case() {
+ super(SetVlanIdActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetVlanIdActionCase source, final ActionConvertorData data) {
+ SetVlanIdAction setvlanidaction = source.getSetVlanIdAction();
+ SetVlanVidActionBuilder vlanidActionBuilder = new SetVlanVidActionBuilder();
+ SetVlanVidCaseBuilder setVlanVidCaseBuilder = new SetVlanVidCaseBuilder();
+ vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
+ setVlanVidCaseBuilder.setSetVlanVidAction(vlanidActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setVlanVidCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+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.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+
+public class SalToOfSetVlanPcpActionCase extends ConvertorCase<SetVlanPcpActionCase, Action, ActionConvertorData> {
+ public SalToOfSetVlanPcpActionCase() {
+ super(SetVlanPcpActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetVlanPcpActionCase source, final ActionConvertorData data) {
+ SetVlanPcpAction setvlanpcpaction = source.getSetVlanPcpAction();
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+
+ List<MatchEntry> matchEntriesList = new ArrayList<>();
+ matchEntriesList.add(MatchConvertorUtil.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
+ setFieldBuilder.setMatchEntry(matchEntriesList);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+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.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.vlan.pcp._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfSetVlanPcpActionV10Case extends ConvertorCase<SetVlanPcpActionCase, Action, ActionConvertorData> {
+ public SalToOfSetVlanPcpActionV10Case() {
+ super(SetVlanPcpActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final SetVlanPcpActionCase source, final ActionConvertorData data) {
+ SetVlanPcpAction setvlanpcpaction = source.getSetVlanPcpAction();
+ SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
+ SetVlanPcpCaseBuilder setVlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
+ setVlanPcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
+ setVlanPcpCaseBuilder.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setVlanPcpCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+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.VlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
+
+public class SalToOfStripVlanActionCase extends ConvertorCase<StripVlanActionCase, Action, ActionConvertorData> {
+ public SalToOfStripVlanActionCase() {
+ super(StripVlanActionCase.class, true, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final StripVlanActionCase source, final ActionConvertorData data) {
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
+ List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
+ matchBuilder.setOxmClass(OpenflowBasicClass.class);
+ matchBuilder.setOxmMatchField(VlanVid.class);
+ matchBuilder.setHasMask(false);
+ VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+ VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+ vlanVidBuilder.setCfiBit(true);
+ vlanVidBuilder.setVlanVid(0x0000);
+ vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+ matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+ matchBuilder.setHasMask(false);
+ entries.add(matchBuilder.build());
+ setFieldBuilder.setMatchEntry(entries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
+
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(setFieldCaseBuilder.build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+
+public class SalToOfStripVlanActionV10Case extends ConvertorCase<StripVlanActionCase, Action, ActionConvertorData> {
+ public SalToOfStripVlanActionV10Case() {
+ super(StripVlanActionCase.class, true, OFConstants.OFP_VERSION_1_0);
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final StripVlanActionCase source, final ActionConvertorData data) {
+ return Optional.of(new ActionBuilder()
+ .setActionChoice(new StripVlanCaseBuilder().build())
+ .build());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
+import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SalToOfVendorCodecCase extends ConvertorCase<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action, ActionConvertorData> {
+ private static final Logger LOG = LoggerFactory.getLogger(SalToOfVendorCodecCase.class);
+
+ public SalToOfVendorCodecCase() {
+ super(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Nonnull
+ @Override
+ public Optional<Action> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action source, final ActionConvertorData data) {
+ final short version = data.getVersion();
+ final TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
+ new TypeVersionKey<>(
+ (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) source.getImplementedInterface(),
+ version);
+
+ ExtensionConverterProvider extensionConverterProvider = OFSessionUtil.getExtensionConvertorProvider();
+
+ if (extensionConverterProvider == null) {
+ return Optional.empty();
+ }
+
+ final ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
+ extensionConverterProvider.getConverter(key);
+
+ LOG.trace("OFP Extension action, key:{}, converter:{}", key, convertor);
+ return convertor != null ? Optional.of(convertor.convert(source)) : Optional.empty();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.data;
+
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+
+/**
+ * Convertor data used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor}
+ * containing Openflow version, datapath ID and IP protocol from flow
+ */
+public class ActionConvertorData extends VersionDatapathIdConvertorData {
+ private Short ipProtocol;
+
+ /**
+ * Instantiates a new Action convertor data.
+ *
+ * @param version the version
+ */
+ public ActionConvertorData(short version) {
+ super(version);
+ }
+
+ /**
+ * Gets ip protocol.
+ *
+ * @return the ip protocol
+ */
+ public Short getIpProtocol() {
+ return ipProtocol;
+ }
+
+ /**
+ * Sets ip protocol.
+ *
+ * @param ipProtocol the ip protocol
+ */
+ public void setIpProtocol(Short ipProtocol) {
+ this.ipProtocol = ipProtocol;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.action.data;
+
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
+
+/**
+ * Convertor data used in {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor}
+ * containing Openflow version and {@link org.opendaylight.openflowplugin.extension.api.path.ActionPath}
+ */
+public class ActionResponseConvertorData extends ConvertorData {
+ private ActionPath actionPath;
+
+ /**
+ * Instantiates a new Action response convertor data.
+ *
+ * @param version the version
+ */
+ public ActionResponseConvertorData(short version) {
+ super(version);
+ }
+
+ /**
+ * Gets action path.
+ *
+ * @return the action path
+ */
+ public ActionPath getActionPath() {
+ return actionPath;
+ }
+
+ /**
+ * Sets action path.
+ *
+ * @param actionPath the action path
+ */
+ public void setActionPath(ActionPath actionPath) {
+ this.actionPath = actionPath;
+ }
+}
+++ /dev/null
-/**
- * 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.common;
-
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
-
-/**
- *
- */
-public class InjectionResultTargetKey extends InjectionKey {
-
- private final Class<?> resultClazz;
-
- /**
- * @param version openflow version
- * @param targetClazz target class
- * @param resultClazz result class
- */
- public InjectionResultTargetKey(final int version, final Class<?> targetClazz, final Class<?> resultClazz) {
- super(version, targetClazz);
- this.resultClazz = Preconditions.checkNotNull(resultClazz);
- }
-
- @Override
- public int hashCode() {
- return super.hashCode() ^ resultClazz.hashCode();
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- final InjectionResultTargetKey other = (InjectionResultTargetKey) obj;
- return resultClazz.equals(other.resultClazz);
- }
-
- @Override
- protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return super.addToStringAttributes(toStringHelper).add("resultClazz", resultClazz);
- }
-}
\r
import java.math.BigInteger;\r
import java.util.ArrayList;\r
+import java.util.Collections;\r
import java.util.List;\r
+import java.util.Optional;\r
import org.junit.Assert;\r
import org.junit.Before;\r
import org.junit.Test;\r
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
import org.opendaylight.openflowplugin.api.OFConstants;\r
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;\r
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;\r
import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;\r
Assert.assertEquals((Object) version,\r
Short.valueOf(message.getVersion()));\r
Assert.assertEquals(xid, message.getXid());\r
- Assert.assertEquals(\r
- ActionConvertor.getActions(actionList, version, datapathId, null),\r
- message.getAction());\r
+ ActionConvertorData actionConvertorData = new ActionConvertorData(version);\r
+ actionConvertorData.setDatapathId(datapathId);\r
+\r
+ Optional<List<Action>> actionsOptional = ConvertorManager.getInstance().convert(\r
+ actionList, actionConvertorData);\r
+\r
+ List<Action> actions = actionsOptional.orElse(Collections.emptyList());\r
+ Assert.assertEquals(actions, message.getAction());\r
Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());\r
}\r
\r
* 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;
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
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;
-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.types.rev131026.OutputPortValues;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
-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.entry.value.grouping.match.entry.value.Ipv4DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCase;
/**
* test for {@link ActionConvertor}
pbbActionData();
setFieldData();
setExperimenterData();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> OFActionsList = ActionConvertor.getActions(actions, (short) 0X4, BigInteger.ONE, null);
+ dropActionData();
- outputActions(OFActionsList);
+ ActionConvertorData data = new ActionConvertorData((short) 0X4);
+ data.setDatapathId(BigInteger.ONE);
+
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> OFActionsList =
+ ConvertorManager.getInstance().convert(actions, data);
+
+ outputActions(OFActionsList.orElse(Collections.emptyList()));
}
}
- private void setFieldData() {
+ private void dropActionData() {
+ ActionBuilder AB = new ActionBuilder();
+ AB.setOrder(actionItem).setAction(new DropActionCaseBuilder().build());
- SetFieldBuilder setFA = new SetFieldBuilder();
+ actions.add(actionItem++, AB.build());
+
+ }
+
+ private void setFieldData() {
- SetFieldBuilder matchBuilder = setFA;
+ SetFieldBuilder matchBuilder = new SetFieldBuilder();
matchBuilder.setInPort(new NodeConnectorId("openflow:1:2125"));
private static void outputActions(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> oFActionsList) {
- for (int item = 0; item < oFActionsList.size(); item++) {
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = oFActionsList
- .get(item);
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action : oFActionsList) {
if (action.getActionChoice() instanceof OutputActionCase) {
OutputActionCase outputActionCase = (OutputActionCase) action.getActionChoice();
ActionBuilder AB = new ActionBuilder();
AB.setOrder(actionItem).setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtlB.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, AB.build());
}
private void vlanActionData() {
actions.add(actionItem++, AB1.build());
}
- /**
- * testing {@link ActionConvertor#ofToSALPushMplsAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)}
- * with OF-1.3, IPv6
- */
- @Test
- public void testOFtoSALPushMplsAction() {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder
- = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder pushMplsBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.mpls._case.PushMplsActionBuilder();
- pushMplsBuilder.setEthertype(new EtherType(new Integer(34888)));
- pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
- actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actionBuilder.build();
- Assert.assertEquals(34888, ActionConvertor.ofToSALPushMplsAction(action).getPushMplsAction().getEthernetType().intValue());
- }
-
private void setQueueActionData() {
SetQueueActionBuilder setQB = new SetQueueActionBuilder();
}
- /**
- * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.0, IPv4
- */
- @Test
- public void testSalToOFSetNwDst10v4() {
- short version = 1;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
- SetNwDstActionCase action = provisionNwDstActionBuilder(address);
- ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
- Assert.assertEquals(SetNwDstCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
- SetNwDstCase setNwDstCase = (SetNwDstCase) actionBuilder.getActionChoice();
- Assert.assertEquals("10.0.0.1", setNwDstCase.getSetNwDstAction().getIpAddress().getValue());
- }
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.0, IPv6
- */
- @Test
- public void testSalToOFSetNwDst10v6() {
- short version = 1;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- /* Use canonical form - no leading zeroes!!! */
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
- SetNwDstActionCase action = provisionNwDstActionBuilder(address);
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
- Assert.assertNull(ofAction);
- }
-
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.3, IPv4
- */
- @Test
- public void testSalToOFSetNwDst13v4() {
- short version = 4;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
- SetNwDstActionCase action = provisionNwDstActionBuilder(address);
- ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
- Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
- SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
- MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- Assert.assertEquals(Ipv4Dst.class.getName(), matchEntry.getOxmMatchField().getName());
- Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) matchEntry.getMatchEntryValue());
- Assert.assertEquals("10.0.0.1", ipv4DstCase.getIpv4Dst().getIpv4Address().getValue());
- }
-
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwDst(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.3, IPv6
- */
- @Test
- public void testSalToOFSetNwDst13v6() {
- short version = 4;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
- SetNwDstActionCase action = provisionNwDstActionBuilder(address);
- ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
- Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
- SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
- MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- Assert.assertEquals(Ipv6Dst.class.getName(), matchEntry.getOxmMatchField().getName());
- Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) matchEntry.getMatchEntryValue());
- /* We check the IP only, the netmask should have gone into the wildcard field */
- Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6DstCase.getIpv6Dst().getIpv6Address().getValue());
- }
-
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.0, IPv4
- */
- @Test
- public void testSalToOFSetNwSrc10v4() {
- short version = 1;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
- SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
- ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
- Assert.assertEquals(SetNwSrcCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
- SetNwSrcCase setNwSrcCase = (SetNwSrcCase) actionBuilder.getActionChoice();
- Assert.assertEquals("10.0.0.1", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());
- }
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.0, IPv6
- */
- @Test
- public void testSalToOFSetNwSrc10v6() {
- short version = 1;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
- SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
- Assert.assertNull(ofAction);
- }
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.3, IPv4
- */
- @Test
- public void testSalToOFSetNwSrc13v4() {
- short version = 4;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.0.1/32")).build();
- SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
- ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
- Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
- SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
- MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- Assert.assertEquals(Ipv4Src.class, matchEntry.getOxmMatchField());
- Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) matchEntry.getMatchEntryValue());
- Assert.assertEquals("10.0.0.1", ipv4SrcCase.getIpv4Src().getIpv4Address().getValue());
- }
-
- /**
- * testing {@link ActionConvertor#salToOFSetNwSrc(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder, short)}
- * with OF-1.3, IPv6
- */
- @Test
- public void testSalToOFSetNwSrc13v6() {
- short version = 4;
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- Address address;
- /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
- SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
- ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
- Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
- SetFieldCase setFieldCase = (SetFieldCase) actionBuilder.getActionChoice();
- MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) matchEntry.getMatchEntryValue());
- Assert.assertEquals(Ipv6Src.class.getName(), matchEntry.getOxmMatchField().getName());
- /* We check the IP only, the netmask should have gone into the wildcard field */
- Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6SrcCase.getIpv6Src().getIpv6Address().getValue());
- }
-
- /**
- * testing {@link ActionConvertor#ofToSALPopMplsAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)}
- * with OF-1.3, IPv6
- */
- @Test
- public void testOFtoSALPopMplsAction() {
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
- PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder popMplsBuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder();
- popMplsBuilder.setEthertype(new EtherType(new EtherType(34888)));
- popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
- actionBuilder.setActionChoice(popMplsCaseBuilder.build());
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actionBuilder.build();
- Assert.assertEquals(34888, ActionConvertor.ofToSALPopMplsAction(action).getPopMplsAction().getEthernetType().intValue());
- }
-
- private static SetNwDstActionCase provisionNwDstActionBuilder(final Address address) {
- SetNwDstAction nwDstAction = new SetNwDstActionBuilder().setAddress(address).build();
- SetNwDstActionCase action = new SetNwDstActionCaseBuilder()
- .setSetNwDstAction(nwDstAction)
- .build();
- return action;
- }
-
- private static SetNwSrcActionCase provisionNwSrcActionBuilder(final Address address) {
- SetNwSrcAction nwSrcAction = new SetNwSrcActionBuilder().setAddress(address).build();
- SetNwSrcActionCase action = new SetNwSrcActionCaseBuilder()
- .setSetNwSrcAction(nwSrcAction)
- .build();
- return action;
- }
-
}
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;\r
\r
import java.math.BigInteger;\r
import java.util.ArrayList;\r
+import java.util.Collections;\r
import java.util.List;\r
-\r
+import java.util.Optional;\r
import org.junit.Assert;\r
import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;\r
import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpVersion;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase;\r
public class ActionConvertorV10Test {\r
\r
/**\r
- * Test {@link ActionConvertor#getActions(List, short, BigInteger)}\r
+ * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)}}\r
*/\r
@Test\r
public void testGetActions() {\r
actionBuilder.setAction(vlanPcpCaseBuilder.build());\r
actionBuilder.setOrder(0);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
StripVlanActionCaseBuilder stripCaseBuilder = new StripVlanActionCaseBuilder();\r
StripVlanActionBuilder stripBuilder = new StripVlanActionBuilder();\r
actionBuilder.setAction(stripCaseBuilder.build());\r
actionBuilder.setOrder(1);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
SetDlDstActionCaseBuilder dlDstCaseBuilder = new SetDlDstActionCaseBuilder();\r
SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();\r
actionBuilder.setAction(dlDstCaseBuilder.build());\r
actionBuilder.setOrder(2);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
SetDlSrcActionCaseBuilder dlSrcCaseBuilder = new SetDlSrcActionCaseBuilder();\r
SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();\r
actionBuilder.setAction(nwDstCaseBuilder.build());\r
actionBuilder.setOrder(5);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
SetTpSrcActionCaseBuilder tpSrcCaseBuilder = new SetTpSrcActionCaseBuilder();\r
SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();\r
actionBuilder.setAction(tpSrcCaseBuilder.build());\r
actionBuilder.setOrder(6);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
SetTpDstActionCaseBuilder tpDstCaseBuilder = new SetTpDstActionCaseBuilder();\r
SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();\r
actionBuilder.setAction(tpDstCaseBuilder.build());\r
actionBuilder.setOrder(7);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
SetNwTosActionCaseBuilder tosCaseBuilder = new SetNwTosActionCaseBuilder();\r
SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();\r
actionBuilder.setAction(tosCaseBuilder.build());\r
actionBuilder.setOrder(8);\r
salActions.add(actionBuilder.build());\r
+\r
actionBuilder = new ActionBuilder();\r
SetVlanIdActionCaseBuilder vlanIdCaseBuilder = new SetVlanIdActionCaseBuilder();\r
SetVlanIdActionBuilder vlanIdBuilder = new SetVlanIdActionBuilder();\r
actionBuilder.setAction(vlanIdCaseBuilder.build());\r
actionBuilder.setOrder(9);\r
salActions.add(actionBuilder.build());\r
+\r
+ actionBuilder = new ActionBuilder();\r
+ PopVlanActionCaseBuilder popVlanActionCaseBuilder = new PopVlanActionCaseBuilder();\r
+ actionBuilder.setAction(popVlanActionCaseBuilder.build());\r
+ actionBuilder.setOrder(10);\r
+ salActions.add(actionBuilder.build());\r
+\r
+ actionBuilder = new ActionBuilder();\r
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();\r
+ SetFieldBuilder setFieldBuilder = new SetFieldBuilder();\r
+ VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();\r
+ vlanMatchBuilder.setVlanId(new VlanIdBuilder().setVlanId(new VlanId(22)).build());\r
+ setFieldBuilder.setVlanMatch(vlanMatchBuilder.build());\r
+ setFieldCaseBuilder.setSetField(setFieldBuilder.build());\r
+ actionBuilder.setAction(setFieldCaseBuilder.build());\r
+ actionBuilder.setOrder(11);\r
+ salActions.add(actionBuilder.build());\r
\r
IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProto(IpVersion.Ipv4);\r
MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());\r
FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = ActionConvertor.getActions(salActions, EncodeConstants.OF10_VERSION_ID, new BigInteger("42"), flowBld.build());\r
+ Flow flow = flowBld.build();\r
+\r
+ ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_0);\r
+ data.setDatapathId(new BigInteger("42"));\r
+ if (flow.getMatch() != null && flow.getMatch().getIpMatch() != null) {\r
+ data.setIpProtocol(flow.getMatch().getIpMatch().getIpProtocol());\r
+ }\r
+\r
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> actionsOptional =\r
+ ConvertorManager.getInstance().convert(salActions, data);\r
+\r
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = actionsOptional.orElse(Collections.emptyList());\r
\r
- Assert.assertEquals("Wrong number of actions", 10, actions.size());\r
+ Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
\r
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actions.get(0);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
+ ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());\r
SetVlanVidCase setVlanVidCase = (SetVlanVidCase) action.getActionChoice();\r
Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());\r
+\r
+ action = actions.get(10);\r
+ Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
+ + ".action.rev150203.action.grouping.action.choice.StripVlanCase", action.getActionChoice().getImplementedInterface().getName());\r
+\r
+ action = actions.get(11);\r
+ Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
+ + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());\r
+ setVlanVidCase = (SetVlanVidCase) action.getActionChoice();\r
+ Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());\r
}\r
\r
/**\r
- * Test {@link ActionConvertor#toMDSalActions(List, OpenflowVersion, ActionPath)}\r
+ * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)}}\r
*/\r
@Test\r
public void testToMDSalActions() {\r
outputBuilder.setMaxLength(555);\r
caseBuilder.setOutputAction(outputBuilder.build());\r
actionbuilder.setActionChoice(caseBuilder.build());\r
- \r
-// actionbuilder.setType(Output.class);\r
-// PortActionBuilder portBuilder = new PortActionBuilder();\r
-// portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(14L));\r
-// actionbuilder.addAugmentation(PortAction.class, portBuilder.build());\r
-// MaxLengthActionBuilder lengthBuilder = new MaxLengthActionBuilder();\r
-// lengthBuilder.setMaxLength(555);\r
-// actionbuilder.addAugmentation(MaxLengthAction.class, lengthBuilder.build());\r
actions.add(actionbuilder.build());\r
\r
+ ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_0);\r
+ data.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+\r
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
+ .Action>> mdSalActionsOptional =\r
+ ConvertorManager.getInstance().convert(\r
+ actions, data);\r
+\r
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
- .Action> mdSalActions = ActionConvertor.toMDSalActions(actions, OpenflowVersion.OF10,\r
- ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+ .Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());\r
\r
Assert.assertEquals("Wrong number of output actions", 1, mdSalActions.size());\r
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);\r
* and is available at http://www.eclipse.org/legal/epl-v10.html\r
*/\r
\r
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;\r
\r
import java.math.BigInteger;\r
import java.util.ArrayList;\r
+import java.util.Collections;\r
import java.util.List;\r
-\r
+import java.util.Optional;\r
import org.junit.Assert;\r
import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
+import org.opendaylight.openflowplugin.api.OFConstants;\r
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;\r
import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.pop.mpls._case.PopMplsActionBuilder;\r
*/\r
public class ActionConvertorV13Test {\r
/**\r
- * Test {@link ActionConvertor#toMDSalActions(List, OpenflowVersion, ActionPath)}\r
+ * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)}}\r
*/\r
@Test\r
public void testToMDSalActions() {\r
List<Action> actions = new ArrayList<>();\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
- .Action> mdSalActions = ActionConvertor.toMDSalActions(actions, OpenflowVersion.OF13,\r
- ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+ ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);\r
+ data.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
\r
- Assert.assertEquals("Wrong number of output actions", 0, mdSalActions.size());\r
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
+ .Action>> mdSalActions = ConvertorManager.getInstance().convert(actions, data);\r
+\r
+ Assert.assertEquals("Wrong number of output actions", 0, mdSalActions.orElse(Collections.emptyList()).size());\r
}\r
\r
/**\r
- * Test {@link ActionConvertor#toMDSalActions(List, OpenflowVersion, ActionPath)}\r
+ * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)}}\r
*/\r
@Test\r
public void testToMDSalActions2() {\r
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());\r
actions.add(actionBuilder.build());\r
\r
+ actionBuilder = new ActionBuilder();\r
+ actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());\r
+ actions.add(actionBuilder.build());\r
+\r
+ actionBuilder = new ActionBuilder();\r
+ actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());\r
+ actions.add(actionBuilder.build());\r
+\r
+ ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);\r
+ data.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+\r
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
+ .Action>> mdSalActionsOptional = ConvertorManager.getInstance().convert(actions, data);\r
+\r
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
- .Action> mdSalActions = ActionConvertor.toMDSalActions(actions, OpenflowVersion.OF13,\r
- ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);\r
+ .Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());\r
\r
- Assert.assertEquals("Wrong number of output actions", 16, mdSalActions.size());\r
+ Assert.assertEquals("Wrong number of output actions", 18, mdSalActions.size());\r
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+ ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());\r
action = mdSalActions.get(15);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+ ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());\r
+ action = mdSalActions.get(16);\r
+ Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+ + ".rev131112.action.action.SetNwDstActionCase", action.getImplementedInterface().getName());\r
+ action = mdSalActions.get(17);\r
+ Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
+ + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());\r
}\r
\r
/**\r
- * Test {@link ActionConvertor#getActions(java.util.List, short, java.math.BigInteger, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow)}\r
+ * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)} }\r
*/\r
@Test\r
public void testGetActions() {\r
IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProtocol((short) 6);\r
MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());\r
FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());\r
+ Flow flow = flowBld.build();\r
+\r
+ ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_3);\r
+ data.setDatapathId(new BigInteger("42"));\r
+\r
+ if (flow.getMatch() != null && flow.getMatch().getIpMatch() != null) {\r
+ data.setIpProtocol(flow.getMatch().getIpMatch().getIpProtocol());\r
+ }\r
\r
- List<Action> actions = ActionConvertor.getActions(salActions, EncodeConstants.OF13_VERSION_ID, new BigInteger("42"), flowBld.build());\r
+ Optional<List<Action>> actionsOptional = ConvertorManager.getInstance().convert(salActions, data);\r
+ List<Action> actions = actionsOptional.orElse(Collections.emptyList());\r
\r
Assert.assertEquals("Wrong number of actions", 12, actions.size());\r
Action action = actions.get(0);\r
+++ /dev/null
-/**
- * Copyright (c) 2013 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.action;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-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.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-
-/**
- * match conversion and injection test
- */
-public class ActionSetNwDstReactorTest {
-
- private Address[] addresses;
-
- /**
- * prepare input match
- */
- @Before
- public void setUp() {
- addresses = new Address[]{
- new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
- new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
- new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
- new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
- };
- }
-
- /**
- * convert for OF-1.3, inject into {@link ActionBuilder}
- */
- @Test
- public void testMatchConvertorV13_flow() {
- final ActionBuilder target = new ActionBuilder();
- for (final Address address : addresses) {
- final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
- ActionSetNwDstReactor.getInstance().convert(action,
- OFConstants.OFP_VERSION_1_3, target);
- final Object mEntry = target.getActionChoice();
-/*
- Assert.assertNotNull(mEntry);
- if (address instanceof Ipv4) {
- Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) mEntry.getMatchEntryValue());
- Assert.assertNotNull(ipv4DstCase.getIpv4Dst());
- } else if (address instanceof Ipv6) {
- Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) mEntry.getMatchEntryValue());
- Assert.assertNotNull(ipv6DstCase.getIpv6Dst());
- } else {
- Assert.fail("not tested yet: " + address.getClass().getName());
- }
-*/
- }
- }
-
- /**
- * @param address
- * @return
- */
- private static SetNwDstActionCase prepareSetNwDstActionCase(final Address address) {
- return new SetNwDstActionCaseBuilder().setSetNwDstAction(
- new SetNwDstActionBuilder().setAddress(address).build()).build();
- }
-
- /**
- * convert for OF-1.0, inject into {@link ActionBuilder}
- */
- @Test
- public void testMatchConvertorV10_flow() {
- final ActionBuilder target = new ActionBuilder();
- for (final Address address : addresses) {
- final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
-
- if (address instanceof Ipv4) {
- ActionSetNwDstReactor.getInstance().convert(action,
- OFConstants.OFP_VERSION_1_0, target);
-// Assert.assertNotNull(target.getAugmentation(IpAddressAction.class).getIpAddress());
- } else {
- try {
- ActionSetNwDstReactor.getInstance().convert(action,
- OFConstants.OFP_VERSION_1_0, target);
- Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
- } catch (final Exception e) {
- //expected
- Assert.assertEquals(IllegalArgumentException.class, e.getClass());
- }
- }
- }
- }
-}
+++ /dev/null
-/**
- * Copyright (c) 2013 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.action;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
-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.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-
-/**
- * match conversion and injection test
- */
-public class ActionSetNwSrcReactorTest {
-
- private Address[] addresses;
-
- /**
- * prepare input match
- */
- @Before
- public void setUp() {
- addresses = new Address[]{
- new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
- new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
- new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
- new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
- };
- }
-
- /**
- * convert for OF-1.3, inject into {@link ActionBuilder}
- */
-
- @Test
- public void testMatchConvertorV13_flow() {
- final ActionBuilder target = new ActionBuilder();
- for (final Address address : addresses) {
- final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
- ActionSetNwSrcReactor.getInstance().convert(action,
- OFConstants.OFP_VERSION_1_3, target);
-/*
- MatchEntry mEntry = target.getActionChoice() getAugmentation(OxmFieldsAction.class).getMatchEntry().get(0);
- Assert.assertNotNull(mEntry);
- if (address instanceof Ipv4) {
- Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) mEntry.getMatchEntryValue());
- Assert.assertNotNull(ipv4SrcCase.getIpv4Src());
- } else if (address instanceof Ipv6) {
- Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) mEntry.getMatchEntryValue());
- Assert.assertNotNull(ipv6SrcCase.getIpv6Src().getIpv6Address());
- } else {
- Assert.fail("not tested yet: " + address.getClass().getName());
- }
-*/
- }
- }
-
- /**
- * @param address
- * @return
- */
- private static SetNwSrcActionCase prepareSetNwSrcActionCase(final Address address) {
- return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(
- new SetNwSrcActionBuilder().setAddress(address).build()).build();
- }
-
- /**
- * convert for OF-1.0, inject into {@link ActionBuilder}
- */
- @Test
- public void testMatchConvertorV10_flow() {
- final ActionBuilder target = new ActionBuilder();
- for (final Address address : addresses) {
- final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
-
- if (address instanceof Ipv4) {
- ActionSetNwSrcReactor.getInstance().convert(action,
- OFConstants.OFP_VERSION_1_0, target);
- } else {
- try {
- ActionSetNwSrcReactor.getInstance().convert(action,
- OFConstants.OFP_VERSION_1_0, target);
- Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
- } catch (final Exception e) {
- //expected
- Assert.assertEquals(IllegalArgumentException.class, e.getClass());
- }
- }
- }
- }
-}