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.action.rev130731.actions.grouping.Action;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfieldBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMissBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
107 import org.slf4j.Logger;
108 import org.slf4j.LoggerFactory;
111 * Utility class for converting a OF library table features to MD-SAL table
114 public class TableFeaturesReplyConvertor {
115 private static final Logger logger = LoggerFactory.getLogger(TableFeaturesReplyConvertor.class);
117 public static List<TableFeatures> toTableFeaturesReply(
118 final MultipartReplyTableFeatures ofTableFeaturesList) {
119 if (ofTableFeaturesList == null || ofTableFeaturesList.getTableFeatures() == null) {
120 return Collections.<TableFeatures> emptyList();
122 List<TableFeatures> salTableFeaturesList = new ArrayList<>();
123 TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
124 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.
125 multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures ofTableFeatures : ofTableFeaturesList
126 .getTableFeatures()) {
127 salTableFeatures.setTableId(ofTableFeatures.getTableId());
128 salTableFeatures.setName(ofTableFeatures.getName());
129 if (ofTableFeatures.getMetadataMatch() != null) {
130 salTableFeatures.setMetadataMatch(new BigInteger(ofTableFeatures.getMetadataMatch()));
132 if (ofTableFeatures.getMetadataWrite() != null) {
133 salTableFeatures.setMetadataWrite(new BigInteger(ofTableFeatures.getMetadataWrite()));
135 if (ofTableFeatures.getConfig() != null) {
136 salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
138 salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
139 salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
140 salTableFeaturesList.add(salTableFeatures.build());
142 return salTableFeaturesList;
145 private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
146 if (ofTablePropertiesList == null) {
147 return new TablePropertiesBuilder()
148 .setTableFeatureProperties(
150 .<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> emptyList())
153 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
154 TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
155 for (TableFeatureProperties property : ofTablePropertiesList) {
156 TableFeaturesPropType propType = property.getType();
157 if (propType != null) {
159 case OFPTFPTINSTRUCTIONS:
160 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();
162 .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
163 .setInstruction(setInstructionTableFeatureProperty(property)).build());
164 propBuilder.setTableFeaturePropType(instructionBuilder.build());
166 case OFPTFPTINSTRUCTIONSMISS:
167 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();
168 instructionMissBuilder
169 .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
170 .setInstruction(setInstructionTableFeatureProperty(property)).build());
171 propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
173 case OFPTFPTNEXTTABLES:
174 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();
176 .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
177 .setTableIds(setNextTableFeatureProperty(property)).build());
178 propBuilder.setTableFeaturePropType(nextTableBuilder.build());
180 case OFPTFPTNEXTTABLESMISS:
181 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();
183 .setTablesMiss(new TablesMissBuilder()
184 .setTableIds(setNextTableFeatureProperty(property)).build());
185 propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
187 case OFPTFPTWRITEACTIONS:
188 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();
190 .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
191 .setAction(setActionTableFeatureProperty(property)).build());
192 propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
194 case OFPTFPTWRITEACTIONSMISS:
195 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();
196 writeActionsMissBuilder
197 .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
198 .setAction(setActionTableFeatureProperty(property)).build());
199 propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
201 case OFPTFPTAPPLYACTIONS:
202 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();
204 .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
205 .setAction(setActionTableFeatureProperty(property)).build());
206 propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
208 case OFPTFPTAPPLYACTIONSMISS:
209 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();
210 applyActionsMissBuilder
211 .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
212 .setAction(setActionTableFeatureProperty(property)).build());
213 propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
216 MatchSetfieldBuilder matchBuilder = new MatchSetfieldBuilder();
217 matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
218 propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
220 case OFPTFPTWILDCARDS:
221 WildcardSetfieldBuilder wildcardsBuilder = new WildcardSetfieldBuilder();
222 wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
223 propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
225 case OFPTFPTWRITESETFIELD:
226 WriteSetfieldBuilder writeSetfieldBuilder = new WriteSetfieldBuilder();
227 writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
228 propBuilder.setTableFeaturePropType(new
229 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
231 case OFPTFPTWRITESETFIELDMISS:
232 WriteSetfieldMissBuilder writeSetfieldMissBuilder = new WriteSetfieldMissBuilder();
233 writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
234 propBuilder.setTableFeaturePropType(new
235 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
237 case OFPTFPTAPPLYSETFIELD:
238 ApplySetfieldBuilder applySetfieldBuilder = new ApplySetfieldBuilder();
239 applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
240 propBuilder.setTableFeaturePropType(new
241 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
243 case OFPTFPTAPPLYSETFIELDMISS:
244 ApplySetfieldMissBuilder applySetfieldMissBuilder = new ApplySetfieldMissBuilder();
245 applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
246 propBuilder.setTableFeaturePropType(new
247 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder().setApplySetfieldMiss(applySetfieldMissBuilder.build()).build());
249 case OFPTFPTEXPERIMENTER:
250 // Experimenter Table features are unhandled
252 case OFPTFPTEXPERIMENTERMISS:
253 // Experimenter miss Table features are unhandled
256 logger.error("Unsupported table feature property : " + propType);
259 salTablePropertiesList.add(propBuilder.build());
262 return new TablePropertiesBuilder().setTableFeatureProperties(salTablePropertiesList).build();
265 private static List<Instruction> setInstructionTableFeatureProperty(final TableFeatureProperties properties) {
266 List<Instruction> instructionList = new ArrayList<>();
267 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();
268 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731
269 .instructions.grouping.Instruction currInstruction : properties
270 .getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstruction()) {
271 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase> currInstructionType = currInstruction
273 if (currInstructionType
274 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable.class)) {
275 builder.setInstruction((new GoToTableCaseBuilder()
277 } else if (currInstructionType
278 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata.class)) {
279 builder.setInstruction((new WriteMetadataCaseBuilder()
281 } else if (currInstructionType
282 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class)) {
283 builder.setInstruction((new WriteActionsCaseBuilder()
285 } else if (currInstructionType
286 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class)) {
287 builder.setInstruction((new ApplyActionsCaseBuilder()
289 } else if (currInstructionType
290 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class)) {
291 builder.setInstruction((new ClearActionsCaseBuilder()
293 } else if (currInstructionType
294 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter.class)) {
295 builder.setInstruction((new MeterCaseBuilder()
297 } else if (currInstructionType
298 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class)) {
299 // TODO: Experimenter instructions are unhandled
301 instructionList.add(builder.build());
303 return instructionList;
306 private static List<Short> setNextTableFeatureProperty(final TableFeatureProperties properties) {
307 List<Short> nextTableIdsList = new ArrayList<>();
308 for (NextTableIds tableId : properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
309 .getNextTableIds()) {
310 nextTableIdsList.add(tableId.getTableId());
312 return nextTableIdsList;
315 private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
316 final TableFeatureProperties properties) {
317 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
319 for (Action action : properties
320 .getAugmentation(ActionRelatedTableFeatureProperty.class).getAction()) {
321 if (action != null) {
322 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();
324 actionBuilder.setOrder(order++);
325 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase> actionType = action
328 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
329 actionBuilder.setAction(new OutputActionCaseBuilder().build());
330 } else if (actionType
331 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
332 actionBuilder.setAction(new GroupActionCaseBuilder().build());
333 } else if (actionType
334 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
335 actionBuilder.setAction(new CopyTtlOutCaseBuilder().build());
336 } else if (actionType
337 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
338 actionBuilder.setAction(new CopyTtlInCaseBuilder().build());
339 } else if (actionType
340 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
341 actionBuilder.setAction(new SetMplsTtlActionCaseBuilder().build());
342 } else if (actionType
343 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
344 actionBuilder.setAction(new DecMplsTtlCaseBuilder().build());
345 } else if (actionType
346 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
347 actionBuilder.setAction(new PushVlanActionCaseBuilder().build());
348 } else if (actionType
349 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) {
350 actionBuilder.setAction(new PopVlanActionCaseBuilder().build());
351 } else if (actionType
352 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
353 actionBuilder.setAction(new PushMplsActionCaseBuilder().build());
354 } else if (actionType
355 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
356 actionBuilder.setAction(new PopMplsActionCaseBuilder().build());
357 } else if (actionType
358 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
359 actionBuilder.setAction(new SetQueueActionCaseBuilder().build());
360 } else if (actionType
361 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
362 actionBuilder.setAction(new SetNwTtlActionCaseBuilder().build());
363 } else if (actionType
364 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
365 actionBuilder.setAction(new DecNwTtlCaseBuilder().build());
366 } else if (actionType
367 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
368 actionBuilder.setAction(new SetFieldCaseBuilder().build());
369 } else if (actionType
370 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
371 actionBuilder.setAction(new PushPbbActionCaseBuilder().build());
372 } else if (actionType
373 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
374 actionBuilder.setAction(new PopPbbActionCaseBuilder().build());
375 } else if (actionType
376 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
377 // TODO: Experimenter Action unhandled.
379 actionList.add(actionBuilder.build());
385 private static List<SetFieldMatch> setSetFieldTableFeatureProperty(final TableFeatureProperties properties,
386 final boolean setHasMask) {
387 List<SetFieldMatch> setFieldMatchList = new ArrayList<>();
388 SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
389 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> salMatchField = null;
390 Class<? extends MatchField> ofMatchField = null;
392 // This handles only OpenflowBasicClass oxm class.
393 for (MatchEntries currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class)
394 .getMatchEntries()) {
395 ofMatchField = currMatch.getOxmMatchField();
396 if (ofMatchField.equals(ArpOp.class)) {
397 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class;
398 } else if (ofMatchField.equals(ArpSha.class)) {
399 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class;
400 } else if (ofMatchField.equals(ArpSpa.class)) {
401 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class;
402 } else if (ofMatchField.equals(ArpTha.class)) {
403 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class;
404 } else if (ofMatchField.equals(ArpTpa.class)) {
405 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class;
406 } else if (ofMatchField.equals(EthDst.class)) {
407 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class;
408 } else if (ofMatchField.equals(EthSrc.class)) {
409 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class;
410 } else if (ofMatchField.equals(EthType.class)) {
411 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class;
412 } else if (ofMatchField.equals(Icmpv4Code.class)) {
413 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class;
414 } else if (ofMatchField.equals(Icmpv4Type.class)) {
415 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class;
416 } else if (ofMatchField.equals(Icmpv6Code.class)) {
417 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class;
418 } else if (ofMatchField.equals(Icmpv6Type.class)) {
419 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class;
420 } else if (ofMatchField.equals(InPhyPort.class)) {
421 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class;
422 } else if (ofMatchField.equals(InPort.class)) {
423 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class;
424 } else if (ofMatchField.equals(IpDscp.class)) {
425 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class;
426 } else if (ofMatchField.equals(IpEcn.class)) {
427 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class;
428 } else if (ofMatchField.equals(IpProto.class)) {
429 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class;
430 } else if (ofMatchField.equals(Ipv4Dst.class)) {
431 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class;
432 } else if (ofMatchField.equals(Ipv4Src.class)) {
433 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class;
434 } else if (ofMatchField.equals(Ipv6Dst.class)) {
435 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class;
436 } else if (ofMatchField.equals(Ipv6Exthdr.class)) {
437 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class;
438 } else if (ofMatchField.equals(Ipv6Flabel.class)) {
439 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class;
440 } else if (ofMatchField.equals(Ipv6NdSll.class)) {
441 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class;
442 } else if (ofMatchField.equals(Ipv6NdTarget.class)) {
443 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class;
444 } else if (ofMatchField.equals(Ipv6NdTll.class)) {
445 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class;
446 } else if (ofMatchField.equals(Ipv6Src.class)) {
447 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class;
448 } else if (ofMatchField.equals(Metadata.class)) {
449 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class;
450 } else if (ofMatchField.equals(MplsBos.class)) {
451 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class;
452 } else if (ofMatchField.equals(MplsLabel.class)) {
453 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class;
454 } else if (ofMatchField.equals(MplsTc.class)) {
455 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class;
456 } else if (ofMatchField.equals(PbbIsid.class)) {
457 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class;
458 } else if (ofMatchField.equals(SctpDst.class)) {
459 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class;
460 } else if (ofMatchField.equals(SctpSrc.class)) {
461 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class;
462 } else if (ofMatchField.equals(TcpDst.class)) {
463 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class;
464 } else if (ofMatchField.equals(TcpSrc.class)) {
465 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class;
466 } else if (ofMatchField.equals(TunnelId.class)) {
467 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class;
468 } else if (ofMatchField.equals(UdpDst.class)) {
469 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class;
470 } else if (ofMatchField.equals(UdpSrc.class)) {
471 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class;
472 } else if (ofMatchField.equals(VlanPcp.class)) {
473 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class;
474 } else if (ofMatchField.equals(VlanVid.class)) {
475 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class;
478 setFieldMatchBuilder.setMatchType(salMatchField);
480 setFieldMatchBuilder.setHasMask(currMatch.isHasMask());
482 setFieldMatchList.add(setFieldMatchBuilder.build());
484 return setFieldMatchList;