/** * 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; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Utility class for converting a OF library table features to MD-SAL table * features. */ public class TableFeaturesReplyConvertor { private static final Logger logger = LoggerFactory.getLogger(TableFeaturesReplyConvertor.class); public static List toTableFeaturesReply( org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures ofTableFeaturesList) { if (ofTableFeaturesList == null || ofTableFeaturesList.getTableFeatures() == null) { return Collections. emptyList(); } List salTableFeaturesList = new ArrayList<>(); TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures ofTableFeatures : ofTableFeaturesList .getTableFeatures()) { salTableFeatures.setTableId(ofTableFeatures.getTableId()); salTableFeatures.setName(ofTableFeatures.getName()); if (ofTableFeatures.getMetadataMatch() != null) { salTableFeatures.setMetadataMatch(new BigInteger(ofTableFeatures.getMetadataMatch())); } if (ofTableFeatures.getMetadataWrite() != null) { salTableFeatures.setMetadataWrite(new BigInteger(ofTableFeatures.getMetadataWrite())); } if (ofTableFeatures.getConfig() != null) { salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK())); } salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries()); salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties())); salTableFeaturesList.add(salTableFeatures.build()); } return salTableFeaturesList; } private static TableProperties toTableProperties(List ofTablePropertiesList) { if (ofTablePropertiesList == null) { return new TablePropertiesBuilder() .setTableFeatureProperties( Collections . emptyList()) .build(); } List salTablePropertiesList = new ArrayList<>(); TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); for (TableFeatureProperties property : ofTablePropertiesList) { TableFeaturesPropType propType = property.getType(); if (propType != null) { switch (propType) { case OFPTFPTINSTRUCTIONS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder(); instructionBuilder .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder() .setInstruction(setInstructionTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(instructionBuilder.build()); break; case OFPTFPTINSTRUCTIONSMISS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder instructionMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder(); instructionMissBuilder .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder() .setInstruction(setInstructionTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(instructionMissBuilder.build()); break; case OFPTFPTNEXTTABLES: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder nextTableBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder(); nextTableBuilder .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder() .setTableIds(setNextTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(nextTableBuilder.build()); break; case OFPTFPTNEXTTABLESMISS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder nextTableMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder(); nextTableMissBuilder .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesBuilder() .setTableIds(setNextTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(nextTableMissBuilder.build()); break; case OFPTFPTWRITEACTIONS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder writeActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder(); writeActionsBuilder .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder() .setAction(setActionTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(writeActionsBuilder.build()); break; case OFPTFPTWRITEACTIONSMISS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder writeActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder(); writeActionsMissBuilder .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder() .setAction(setActionTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build()); break; case OFPTFPTAPPLYACTIONS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder applyActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder(); applyActionsBuilder .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder() .setAction(setActionTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(applyActionsBuilder.build()); break; case OFPTFPTAPPLYACTIONSMISS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder applyActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder(); applyActionsMissBuilder .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder() .setAction(setActionTableFeatureProperty(property)).build()); propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build()); break; case OFPTFPTMATCH: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder matchBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder(); matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true)); propBuilder.setTableFeaturePropType(matchBuilder.build()); break; case OFPTFPTWILDCARDS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder wildcardsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder(); wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false)); propBuilder.setTableFeaturePropType(wildcardsBuilder.build()); break; case OFPTFPTWRITESETFIELD: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder writeSetfieldBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder(); writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false)); propBuilder.setTableFeaturePropType(writeSetfieldBuilder.build()); break; case OFPTFPTWRITESETFIELDMISS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder writeSetfieldMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder(); writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false)); propBuilder.setTableFeaturePropType(writeSetfieldMissBuilder.build()); break; case OFPTFPTAPPLYSETFIELD: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder applySetfieldBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder(); applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false)); propBuilder.setTableFeaturePropType(applySetfieldBuilder.build()); break; case OFPTFPTAPPLYSETFIELDMISS: org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder applySetfieldMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder(); applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false)); propBuilder.setTableFeaturePropType(applySetfieldMissBuilder.build()); break; case OFPTFPTEXPERIMENTER: // Experimenter Table features are unhandled break; case OFPTFPTEXPERIMENTERMISS: // Experimenter miss Table features are unhandled break; default: logger.error("Unsupported table feature property : " + propType); break; } salTablePropertiesList.add(propBuilder.build()); } } return new TablePropertiesBuilder().setTableFeatureProperties(salTablePropertiesList).build(); } private static List setInstructionTableFeatureProperty(TableFeatureProperties properties) { List instructionList = new ArrayList<>(); org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions currInstruction : properties .getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstructions()) { Class currInstructionType = currInstruction .getType(); if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable.class)) { builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableBuilder() .build())); } else if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata.class)) { builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataBuilder() .build())); } else if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class)) { builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsBuilder() .build())); } else if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class)) { builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder() .build())); } else if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class)) { builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsBuilder() .build())); } else if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter.class)) { builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterBuilder() .build())); } else if (currInstructionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class)) { // TODO: Experimenter instructions are unhandled } instructionList.add(builder.build()); } return instructionList; } private static List setNextTableFeatureProperty(TableFeatureProperties properties) { List nextTableIdsList = new ArrayList<>(); for (NextTableIds tableId : properties.getAugmentation(NextTableRelatedTableFeatureProperty.class) .getNextTableIds()) { nextTableIdsList.add(tableId.getTableId()); } return nextTableIdsList; } private static List setActionTableFeatureProperty( TableFeatureProperties properties) { List actionList = new ArrayList<>(); org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList currAction : properties .getAugmentation(ActionRelatedTableFeatureProperty.class).getActionsList()) { org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action action = currAction .getAction(); if (action != null) { Class actionType = action .getType(); if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) { actionBuilder.setAction(new OutputActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) { actionBuilder.setAction(new GroupActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) { actionBuilder.setAction(new CopyTtlOutBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) { actionBuilder.setAction(new CopyTtlInBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) { actionBuilder.setAction(new SetMplsTtlActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) { actionBuilder.setAction(new DecMplsTtlBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) { actionBuilder.setAction(new PushVlanActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) { actionBuilder.setAction(new PopVlanActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) { actionBuilder.setAction(new PushMplsActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) { actionBuilder.setAction(new PopMplsActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) { actionBuilder.setAction(new SetQueueActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) { actionBuilder.setAction(new SetNwTtlActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) { actionBuilder.setAction(new DecNwTtlBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) { actionBuilder.setAction(new SetFieldBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) { actionBuilder.setAction(new PushPbbActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) { actionBuilder.setAction(new PopPbbActionBuilder().build()); } else if (actionType .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) { // TODO: Experimenter Action unhandled. } actionList.add(actionBuilder.build()); } } return actionList; } private static List setSetFieldTableFeatureProperty(TableFeatureProperties properties, boolean setHasMask) { List setFieldMatchList = new ArrayList<>(); SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder(); Class salMatchField = null; Class ofMatchField = null; // This handles only OpenflowBasicClass oxm class. for (MatchEntries currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class) .getMatchEntries()) { ofMatchField = currMatch.getOxmMatchField(); if (ofMatchField.equals(ArpOp.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class; } else if (ofMatchField.equals(ArpSha.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class; } else if (ofMatchField.equals(ArpSpa.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class; } else if (ofMatchField.equals(ArpTha.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class; } else if (ofMatchField.equals(ArpTpa.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class; } else if (ofMatchField.equals(EthDst.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class; } else if (ofMatchField.equals(EthSrc.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class; } else if (ofMatchField.equals(EthType.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class; } else if (ofMatchField.equals(Icmpv4Code.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class; } else if (ofMatchField.equals(Icmpv4Type.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class; } else if (ofMatchField.equals(Icmpv6Code.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class; } else if (ofMatchField.equals(Icmpv6Type.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class; } else if (ofMatchField.equals(InPhyPort.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class; } else if (ofMatchField.equals(InPort.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class; } else if (ofMatchField.equals(IpDscp.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class; } else if (ofMatchField.equals(IpEcn.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class; } else if (ofMatchField.equals(IpProto.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class; } else if (ofMatchField.equals(Ipv4Dst.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class; } else if (ofMatchField.equals(Ipv4Src.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class; } else if (ofMatchField.equals(Ipv6Dst.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class; } else if (ofMatchField.equals(Ipv6Exthdr.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class; } else if (ofMatchField.equals(Ipv6Flabel.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class; } else if (ofMatchField.equals(Ipv6NdSll.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class; } else if (ofMatchField.equals(Ipv6NdTarget.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class; } else if (ofMatchField.equals(Ipv6NdTll.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class; } else if (ofMatchField.equals(Ipv6Src.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class; } else if (ofMatchField.equals(Metadata.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class; } else if (ofMatchField.equals(MplsBos.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class; } else if (ofMatchField.equals(MplsLabel.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class; } else if (ofMatchField.equals(MplsTc.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class; } else if (ofMatchField.equals(PbbIsid.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class; } else if (ofMatchField.equals(SctpDst.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class; } else if (ofMatchField.equals(SctpSrc.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class; } else if (ofMatchField.equals(TcpDst.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class; } else if (ofMatchField.equals(TcpSrc.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class; } else if (ofMatchField.equals(TunnelId.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class; } else if (ofMatchField.equals(UdpDst.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class; } else if (ofMatchField.equals(UdpSrc.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class; } else if (ofMatchField.equals(VlanPcp.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class; } else if (ofMatchField.equals(VlanVid.class)) { salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class; } setFieldMatchBuilder.setMatchType(salMatchField); if (setHasMask) { setFieldMatchBuilder.setHasMask(currMatch.isHasMask()); } setFieldMatchList.add(setFieldMatchBuilder.build()); } return setFieldMatchList; } }