package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
-import java.util.ArrayList;
-import java.util.List;
-
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.openflow.md.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstAction;
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.tos.action._case.SetNwTosAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
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.SetQueueAction;
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.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.action.types.rev131112.address.address.Ipv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author usha@ericsson Action List:This class takes data from SAL layer and
* converts into OF Data
public static List<ActionsList> getActionList(
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
- short version)
+ short version,BigInteger datapathid)
{
ActionsListBuilder actionsListBuilder = new ActionsListBuilder();
else if (action instanceof DecNwTtlCase)
actionsList.add(SalToOFDecNwTtl(action, actionsListBuilder));
else if (action instanceof SetFieldCase)
- actionsList.add(SalToOFSetField(action, actionsListBuilder, version));
+ actionsList.add(SalToOFSetField(action, actionsListBuilder, version,datapathid));
else if (action instanceof PushPbbActionCase)
actionsList.add(SalToOFPushPbbAction(action, actionsListBuilder));
else if (action instanceof PopPbbActionCase)
actionsList.add(SalToOFPopPBB(action, actionsListBuilder));
else if (action instanceof ExperimenterAction)
actionsList.add(SalToOFExperimenter(action, actionsListBuilder));
-
+
// 1.0 Actions
else if (action instanceof SetVlanIdActionCase)
actionsList.add(SalToOFSetVlanId(action, actionsListBuilder, version));
private static ActionsList SalToOFSetField(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- ActionsListBuilder actionsListBuilder, short version) {
+ ActionsListBuilder actionsListBuilder, short version,BigInteger datapathid) {
SetFieldCase setFieldCase = (SetFieldCase) action;
org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
.getSetField();
OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
- MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder);
+ MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder,datapathid);
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder
SetNwSrcAction setnwsrcaction = setnwsrccase.getSetNwSrcAction();
IpAddressActionBuilder ipvaddress = new IpAddressActionBuilder();
- ipvaddress.setIpAddress((Ipv4Address) setnwsrcaction.getAddress());
+ Ipv4 address_ipv4 = (Ipv4) setnwsrcaction.getAddress();
+ Ipv4Address address = new Ipv4Address(address_ipv4.getIpv4Address().getValue());
+ ipvaddress.setIpAddress(address);
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc.class);
actionBuilder.addAugmentation(
SetNwDstAction setnwdstaction = setnwdstcase.getSetNwDstAction();
IpAddressActionBuilder ipvaddress = new IpAddressActionBuilder();
- ipvaddress.setIpAddress((Ipv4Address) setnwdstaction.getAddress());
+ Ipv4 address_ipv4 = (Ipv4) setnwdstaction.getAddress();
+ Ipv4Address address = new Ipv4Address(address_ipv4.getIpv4Address().getValue());
+ ipvaddress.setIpAddress(address);
actionBuilder
.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst.class);
actionBuilder.addAugmentation(
ActionBuilder actionBuilder = new ActionBuilder();
SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
-
+
NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
-
+
actionsListBuilder.setAction(actionBuilder.build());
return actionsListBuilder.build();
}
-
+
private static ActionsList SalToOFSetTpSrc(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionsListBuilder actionsListBuilder, short version) {
OutputAction outputAction = outputActionCase.getOutputAction();
PortActionBuilder portAction = new PortActionBuilder();
MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
- maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
+ if (outputAction.getMaxLength() != null) {
+ maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
+ } else {
+ maxLenActionBuilder.setMaxLength(new Integer(0));
+ }
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
Uri uri = outputAction.getOutputNodeConnector();
if (version >= OFConstants.OFP_VERSION_1_3) {
+
if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.CONTROLLER
.getIntValue())));
} else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
logger.error("Unknown Port Type for the Version");
- } else if (Long.parseLong(uri.getValue()) > 0 && Long.parseLong(uri.getValue()) < MAXPortOF13) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(Integer.parseInt(uri.getValue()))));
+ } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector().getValue()) < MAXPortOF13) {
+ portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector().getValue())));
} else {
logger.error("Invalid Port for Output Action");
}
portAction.setPort(new PortNumber((long) PortNumberValuesV10.NONE.getIntValue()));
} else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
logger.error("Unknown Port Type for the Version");
- } else if (Long.parseLong(uri.getValue()) > 0 && Long.parseLong(uri.getValue()) < MAXPortOF10) {
- portAction.setPort(new PortNumber((long) Integer.parseInt(uri.getValue())));
+ } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector().getValue()) < MAXPortOF10) {
+ portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector().getValue())));
} else {
logger.error("Invalid Port for Output Action");
}