2 * Copyright (c) 2013 Ericsson. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.Collections;
14 import java.util.List;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
97 import org.slf4j.Logger;
98 import org.slf4j.LoggerFactory;
101 * Utility class for converting a OF library table features to MD-SAL table
104 public class TableFeaturesReplyConvertor {
105 private static final Logger logger = LoggerFactory.getLogger(TableFeaturesReplyConvertor.class);
107 public static List<TableFeatures> toTableFeaturesReply(
108 MultipartReplyTableFeatures ofTableFeaturesList) {
109 if (ofTableFeaturesList == null || ofTableFeaturesList.getTableFeatures() == null) {
110 return Collections.<TableFeatures> emptyList();
112 List<TableFeatures> salTableFeaturesList = new ArrayList<>();
113 TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
114 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.
115 multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures ofTableFeatures : ofTableFeaturesList
116 .getTableFeatures()) {
117 salTableFeatures.setTableId(ofTableFeatures.getTableId());
118 salTableFeatures.setName(ofTableFeatures.getName());
119 if (ofTableFeatures.getMetadataMatch() != null) {
120 salTableFeatures.setMetadataMatch(new BigInteger(ofTableFeatures.getMetadataMatch()));
122 if (ofTableFeatures.getMetadataWrite() != null) {
123 salTableFeatures.setMetadataWrite(new BigInteger(ofTableFeatures.getMetadataWrite()));
125 if (ofTableFeatures.getConfig() != null) {
126 salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
128 salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
129 salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
130 salTableFeaturesList.add(salTableFeatures.build());
132 return salTableFeaturesList;
135 private static TableProperties toTableProperties(List<TableFeatureProperties> ofTablePropertiesList) {
136 if (ofTablePropertiesList == null) {
137 return new TablePropertiesBuilder()
138 .setTableFeatureProperties(
140 .<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> emptyList())
143 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
144 TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
145 for (TableFeatureProperties property : ofTablePropertiesList) {
146 TableFeaturesPropType propType = property.getType();
147 if (propType != null) {
149 case OFPTFPTINSTRUCTIONS:
150 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();
152 .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
153 .setInstruction(setInstructionTableFeatureProperty(property)).build());
154 propBuilder.setTableFeaturePropType(instructionBuilder.build());
156 case OFPTFPTINSTRUCTIONSMISS:
157 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();
158 instructionMissBuilder
159 .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
160 .setInstruction(setInstructionTableFeatureProperty(property)).build());
161 propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
163 case OFPTFPTNEXTTABLES:
164 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();
166 .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
167 .setTableIds(setNextTableFeatureProperty(property)).build());
168 propBuilder.setTableFeaturePropType(nextTableBuilder.build());
170 case OFPTFPTNEXTTABLESMISS:
171 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();
173 .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesBuilder()
174 .setTableIds(setNextTableFeatureProperty(property)).build());
175 propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
177 case OFPTFPTWRITEACTIONS:
178 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();
180 .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
181 .setAction(setActionTableFeatureProperty(property)).build());
182 propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
184 case OFPTFPTWRITEACTIONSMISS:
185 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();
186 writeActionsMissBuilder
187 .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
188 .setAction(setActionTableFeatureProperty(property)).build());
189 propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
191 case OFPTFPTAPPLYACTIONS:
192 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();
194 .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
195 .setAction(setActionTableFeatureProperty(property)).build());
196 propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
198 case OFPTFPTAPPLYACTIONSMISS:
199 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();
200 applyActionsMissBuilder
201 .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
202 .setAction(setActionTableFeatureProperty(property)).build());
203 propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
206 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();
207 matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
208 propBuilder.setTableFeaturePropType(matchBuilder.build());
210 case OFPTFPTWILDCARDS:
211 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();
212 wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
213 propBuilder.setTableFeaturePropType(wildcardsBuilder.build());
215 case OFPTFPTWRITESETFIELD:
216 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();
217 writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
218 propBuilder.setTableFeaturePropType(writeSetfieldBuilder.build());
220 case OFPTFPTWRITESETFIELDMISS:
221 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();
222 writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
223 propBuilder.setTableFeaturePropType(writeSetfieldMissBuilder.build());
225 case OFPTFPTAPPLYSETFIELD:
226 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();
227 applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
228 propBuilder.setTableFeaturePropType(applySetfieldBuilder.build());
230 case OFPTFPTAPPLYSETFIELDMISS:
231 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();
232 applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
233 propBuilder.setTableFeaturePropType(applySetfieldMissBuilder.build());
235 case OFPTFPTEXPERIMENTER:
236 // Experimenter Table features are unhandled
238 case OFPTFPTEXPERIMENTERMISS:
239 // Experimenter miss Table features are unhandled
242 logger.error("Unsupported table feature property : " + propType);
245 salTablePropertiesList.add(propBuilder.build());
248 return new TablePropertiesBuilder().setTableFeatureProperties(salTablePropertiesList).build();
251 private static List<Instruction> setInstructionTableFeatureProperty(TableFeatureProperties properties) {
252 List<Instruction> instructionList = new ArrayList<>();
253 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();
254 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions currInstruction : properties
255 .getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstructions()) {
256 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Instruction> currInstructionType = currInstruction
258 if (currInstructionType
259 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable.class)) {
260 builder.setInstruction((new GoToTableCaseBuilder()
262 } else if (currInstructionType
263 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata.class)) {
264 builder.setInstruction((new WriteMetadataCaseBuilder()
266 } else if (currInstructionType
267 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class)) {
268 builder.setInstruction((new WriteActionsCaseBuilder()
270 } else if (currInstructionType
271 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class)) {
272 builder.setInstruction((new ApplyActionsCaseBuilder()
274 } else if (currInstructionType
275 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class)) {
276 builder.setInstruction((new ClearActionsCaseBuilder()
278 } else if (currInstructionType
279 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter.class)) {
280 builder.setInstruction((new MeterCaseBuilder()
282 } else if (currInstructionType
283 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class)) {
284 // TODO: Experimenter instructions are unhandled
286 instructionList.add(builder.build());
288 return instructionList;
291 private static List<Short> setNextTableFeatureProperty(TableFeatureProperties properties) {
292 List<Short> nextTableIdsList = new ArrayList<>();
293 for (NextTableIds tableId : properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
294 .getNextTableIds()) {
295 nextTableIdsList.add(tableId.getTableId());
297 return nextTableIdsList;
300 private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
301 TableFeatureProperties properties) {
302 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
303 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();
304 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList currAction : properties
305 .getAugmentation(ActionRelatedTableFeatureProperty.class).getActionsList()) {
306 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action action = currAction
308 if (action != null) {
309 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Action> actionType = action
312 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
313 actionBuilder.setAction(new OutputActionCaseBuilder().build());
314 } else if (actionType
315 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
316 actionBuilder.setAction(new GroupActionCaseBuilder().build());
317 } else if (actionType
318 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
319 actionBuilder.setAction(new CopyTtlOutCaseBuilder().build());
320 } else if (actionType
321 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
322 actionBuilder.setAction(new CopyTtlInCaseBuilder().build());
323 } else if (actionType
324 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
325 actionBuilder.setAction(new SetMplsTtlActionCaseBuilder().build());
326 } else if (actionType
327 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
328 actionBuilder.setAction(new DecMplsTtlCaseBuilder().build());
329 } else if (actionType
330 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
331 actionBuilder.setAction(new PushVlanActionCaseBuilder().build());
332 } else if (actionType
333 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) {
334 actionBuilder.setAction(new PopVlanActionCaseBuilder().build());
335 } else if (actionType
336 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
337 actionBuilder.setAction(new PushMplsActionCaseBuilder().build());
338 } else if (actionType
339 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
340 actionBuilder.setAction(new PopMplsActionCaseBuilder().build());
341 } else if (actionType
342 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
343 actionBuilder.setAction(new SetQueueActionCaseBuilder().build());
344 } else if (actionType
345 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
346 actionBuilder.setAction(new SetNwTtlActionCaseBuilder().build());
347 } else if (actionType
348 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
349 actionBuilder.setAction(new DecNwTtlCaseBuilder().build());
350 } else if (actionType
351 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
352 actionBuilder.setAction(new SetFieldCaseBuilder().build());
353 } else if (actionType
354 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
355 actionBuilder.setAction(new PushPbbActionCaseBuilder().build());
356 } else if (actionType
357 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
358 actionBuilder.setAction(new PopPbbActionCaseBuilder().build());
359 } else if (actionType
360 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
361 // TODO: Experimenter Action unhandled.
363 actionList.add(actionBuilder.build());
369 private static List<SetFieldMatch> setSetFieldTableFeatureProperty(TableFeatureProperties properties,
370 boolean setHasMask) {
371 List<SetFieldMatch> setFieldMatchList = new ArrayList<>();
372 SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
373 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> salMatchField = null;
374 Class<? extends MatchField> ofMatchField = null;
376 // This handles only OpenflowBasicClass oxm class.
377 for (MatchEntries currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class)
378 .getMatchEntries()) {
379 ofMatchField = currMatch.getOxmMatchField();
380 if (ofMatchField.equals(ArpOp.class)) {
381 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class;
382 } else if (ofMatchField.equals(ArpSha.class)) {
383 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class;
384 } else if (ofMatchField.equals(ArpSpa.class)) {
385 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class;
386 } else if (ofMatchField.equals(ArpTha.class)) {
387 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class;
388 } else if (ofMatchField.equals(ArpTpa.class)) {
389 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class;
390 } else if (ofMatchField.equals(EthDst.class)) {
391 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class;
392 } else if (ofMatchField.equals(EthSrc.class)) {
393 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class;
394 } else if (ofMatchField.equals(EthType.class)) {
395 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class;
396 } else if (ofMatchField.equals(Icmpv4Code.class)) {
397 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class;
398 } else if (ofMatchField.equals(Icmpv4Type.class)) {
399 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class;
400 } else if (ofMatchField.equals(Icmpv6Code.class)) {
401 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class;
402 } else if (ofMatchField.equals(Icmpv6Type.class)) {
403 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class;
404 } else if (ofMatchField.equals(InPhyPort.class)) {
405 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class;
406 } else if (ofMatchField.equals(InPort.class)) {
407 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class;
408 } else if (ofMatchField.equals(IpDscp.class)) {
409 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class;
410 } else if (ofMatchField.equals(IpEcn.class)) {
411 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class;
412 } else if (ofMatchField.equals(IpProto.class)) {
413 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class;
414 } else if (ofMatchField.equals(Ipv4Dst.class)) {
415 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class;
416 } else if (ofMatchField.equals(Ipv4Src.class)) {
417 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class;
418 } else if (ofMatchField.equals(Ipv6Dst.class)) {
419 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class;
420 } else if (ofMatchField.equals(Ipv6Exthdr.class)) {
421 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class;
422 } else if (ofMatchField.equals(Ipv6Flabel.class)) {
423 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class;
424 } else if (ofMatchField.equals(Ipv6NdSll.class)) {
425 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class;
426 } else if (ofMatchField.equals(Ipv6NdTarget.class)) {
427 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class;
428 } else if (ofMatchField.equals(Ipv6NdTll.class)) {
429 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class;
430 } else if (ofMatchField.equals(Ipv6Src.class)) {
431 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class;
432 } else if (ofMatchField.equals(Metadata.class)) {
433 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class;
434 } else if (ofMatchField.equals(MplsBos.class)) {
435 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class;
436 } else if (ofMatchField.equals(MplsLabel.class)) {
437 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class;
438 } else if (ofMatchField.equals(MplsTc.class)) {
439 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class;
440 } else if (ofMatchField.equals(PbbIsid.class)) {
441 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class;
442 } else if (ofMatchField.equals(SctpDst.class)) {
443 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class;
444 } else if (ofMatchField.equals(SctpSrc.class)) {
445 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class;
446 } else if (ofMatchField.equals(TcpDst.class)) {
447 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class;
448 } else if (ofMatchField.equals(TcpSrc.class)) {
449 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class;
450 } else if (ofMatchField.equals(TunnelId.class)) {
451 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class;
452 } else if (ofMatchField.equals(UdpDst.class)) {
453 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class;
454 } else if (ofMatchField.equals(UdpSrc.class)) {
455 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class;
456 } else if (ofMatchField.equals(VlanPcp.class)) {
457 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class;
458 } else if (ofMatchField.equals(VlanVid.class)) {
459 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class;
462 setFieldMatchBuilder.setMatchType(salMatchField);
464 setFieldMatchBuilder.setHasMask(currMatch.isHasMask());
466 setFieldMatchList.add(setFieldMatchBuilder.build());
468 return setFieldMatchList;