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.util.ArrayList;
12 import java.util.Collections;
13 import java.util.List;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder;
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.InstructionRelatedTableFeaturePropertyBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeaturePropertyBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfield;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMiss;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfield;
117 import org.slf4j.Logger;
118 import org.slf4j.LoggerFactory;
121 * Utility class for converting a MD-SAL Table features into the OF library table
124 public class TableFeaturesConvertor {
125 private static final Logger logger = LoggerFactory.getLogger(TableFeaturesConvertor.class);
127 public static List<TableFeatures> toTableFeaturesRequest(
128 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures salTableFeaturesList) {
129 List<TableFeatures> ofTableFeaturesList = new ArrayList<>();
130 TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
131 for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures salTableFeatures : salTableFeaturesList
132 .getTableFeatures()) {
133 ofTableFeatures.setTableId(salTableFeatures.getTableId());
134 ofTableFeatures.setName(salTableFeatures.getName());
135 ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
136 ofTableFeatures.setMetadataWrite(salTableFeatures.getMetadataWrite());
137 ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
138 if (salTableFeatures.getConfig() != null) {
139 ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().isDEPRECATEDMASK()));
141 ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));
142 ofTableFeaturesList.add(ofTableFeatures.build());
144 return ofTableFeaturesList;
147 private static List<TableFeatureProperties> toTableProperties(
148 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) {
149 if (tableProperties == null) {
150 return Collections.<TableFeatureProperties> emptyList();
152 List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
155 for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property : tableProperties
156 .getTableFeatureProperties()) {
157 TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
159 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property
160 .getTableFeaturePropType();
162 if (propType instanceof Instructions) {
163 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions instructions = ((Instructions) propType)
165 setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS,
166 (instructions == null) ? new ArrayList<Instruction>() : instructions.getInstruction());
167 } else if (propType instanceof InstructionsMiss) {
168 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMiss instructions = ((InstructionsMiss) propType)
169 .getInstructionsMiss();
170 setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS,
171 (instructions == null) ? new ArrayList<Instruction>() : instructions.getInstruction());
172 } else if (propType instanceof NextTable) {
173 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.Tables tables = ((NextTable) propType)
175 setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLES,
176 (tables == null) ? new ArrayList<Short>() : tables.getTableIds());
177 } else if (propType instanceof NextTableMiss) {
178 TablesMiss tables = ((NextTableMiss) propType)
180 setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLESMISS,
181 (tables == null) ? new ArrayList<Short>() : tables.getTableIds());
182 } else if (propType instanceof WriteActions) {
183 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActions writeActions = ((WriteActions) propType)
185 setActionTableFeatureProperty(
187 TableFeaturesPropType.OFPTFPTWRITEACTIONS,
188 ((writeActions == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
189 : writeActions.getAction()));
190 } else if (propType instanceof WriteActionsMiss) {
191 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMiss writeActionsMiss = ((WriteActionsMiss) propType)
192 .getWriteActionsMiss();
193 setActionTableFeatureProperty(
195 TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS,
196 ((writeActionsMiss == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
197 : writeActionsMiss.getAction()));
198 } else if (propType instanceof ApplyActions) {
199 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActions applyActions = ((ApplyActions) propType)
201 setActionTableFeatureProperty(
203 TableFeaturesPropType.OFPTFPTAPPLYACTIONS,
204 ((applyActions == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
205 : applyActions.getAction()));
206 } else if (propType instanceof ApplyActionsMiss) {
207 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMiss applyActionsMiss = ((ApplyActionsMiss) propType)
208 .getApplyActionsMiss();
209 setActionTableFeatureProperty(
211 TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS,
212 ((applyActionsMiss == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>()
213 : applyActionsMiss.getAction()));
214 } else if (propType instanceof Match) {
215 MatchSetfield matchSetField = ((Match) propType).getMatchSetfield();
216 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
218 if( null != matchSetField) {
219 setFieldMatch = matchSetField.getSetFieldMatch();
222 setSetFieldTableFeatureProperty(
224 TableFeaturesPropType.OFPTFPTMATCH,
225 ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
227 } else if (propType instanceof Wildcards) {
228 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
229 WildcardSetfield wildcardSetField = ((Wildcards) propType).getWildcardSetfield();
231 if (null != wildcardSetField) {
232 setFieldMatch = wildcardSetField.getSetFieldMatch();
235 setSetFieldTableFeatureProperty(
237 TableFeaturesPropType.OFPTFPTWILDCARDS,
238 ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
240 } else if (propType instanceof WriteSetfield) {
241 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
242 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfield writeSetField = ((WriteSetfield) propType).getWriteSetfield();
244 if (null != writeSetField) {
245 setFieldMatch = writeSetField.getSetFieldMatch();
248 setSetFieldTableFeatureProperty(
250 TableFeaturesPropType.OFPTFPTWRITESETFIELD,
251 ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
253 } else if (propType instanceof WriteSetfieldMiss) {
254 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
255 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = ((WriteSetfieldMiss) propType).getWriteSetfieldMiss();
257 if (null != writeSetfieldMiss) {
258 setFieldMatch = writeSetfieldMiss.getSetFieldMatch();
260 setSetFieldTableFeatureProperty(
262 TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS,
263 ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
265 } else if (propType instanceof ApplySetfield) {
266 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
267 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfield applySetfield = ((ApplySetfield) propType).getApplySetfield();
269 if (null != applySetfield) {
270 setFieldMatch = applySetfield.getSetFieldMatch();
272 setSetFieldTableFeatureProperty(
274 TableFeaturesPropType.OFPTFPTAPPLYSETFIELD,
275 ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
277 } else if (propType instanceof ApplySetfieldMiss) {
278 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFieldMatch = null;
279 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = ((ApplySetfieldMiss) propType).getApplySetfieldMiss();
281 if (null != applySetfieldMiss) {
282 setFieldMatch = applySetfieldMiss.getSetFieldMatch();
284 setSetFieldTableFeatureProperty(
286 TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS,
287 ((setFieldMatch == null) ? new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>()
289 } // Experimenter and Experimeneter miss Table features are
291 ofTablePropertiesList.add(propBuilder.build());
293 return ofTablePropertiesList;
296 private static void setInstructionTableFeatureProperty(TableFeaturePropertiesBuilder builder,
297 TableFeaturesPropType type, List<Instruction> instructionList) {
298 List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> instructionTypeList = new ArrayList<>();
300 for (Instruction currInstruction : instructionList) {
301 InstructionBuilder instructionType = new InstructionBuilder();
303 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction = currInstruction
305 if (instruction instanceof GoToTableCase) {
307 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable.class);
308 } else if (instruction instanceof WriteMetadataCase) {
310 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata.class);
311 } else if (instruction instanceof WriteActionsCase) {
313 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class);
314 } else if (instruction instanceof ApplyActionsCase) {
316 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class);
317 } else if (instruction instanceof ClearActionsCase) {
319 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class);
320 } else if (instruction instanceof MeterCase) {
322 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter.class);
323 } // TODO: Experimeneter instructions are unhandled
324 instructionTypeList.add(instructionType.build());
326 InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
327 propBuilder.setInstruction(instructionTypeList);
328 builder.setType(type);
329 builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, propBuilder.build());
332 private static void setNextTableFeatureProperty(TableFeaturePropertiesBuilder builder, TableFeaturesPropType type,
333 List<Short> tableIds) {
334 List<NextTableIds> nextTableIdsList = new ArrayList<>();
336 for (Short tableId : tableIds) {
337 NextTableIdsBuilder nextTableId = new NextTableIdsBuilder();
338 nextTableId.setTableId(tableId);
339 nextTableIdsList.add(nextTableId.build());
341 NextTableRelatedTableFeaturePropertyBuilder propBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
342 propBuilder.setNextTableIds(nextTableIdsList);
343 builder.setType(type);
344 builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, propBuilder.build());
347 private static void setActionTableFeatureProperty(TableFeaturePropertiesBuilder builder,
348 TableFeaturesPropType type,
349 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> salActions) {
350 List<Action> actionList = new ArrayList<>();
352 for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction : salActions) {
353 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction
355 ActionBuilder actionBuilder = new ActionBuilder();
356 if (actionType instanceof OutputActionCase) {
358 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
359 } else if (actionType instanceof GroupActionCase) {
361 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class);
362 } else if (actionType instanceof CopyTtlOutCase) {
364 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
365 } else if (actionType instanceof CopyTtlInCase) {
367 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
368 } else if (actionType instanceof SetMplsTtlActionCase) {
370 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class);
371 } else if (actionType instanceof DecMplsTtlCase) {
373 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
374 } else if (actionType instanceof PushVlanActionCase) {
376 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class);
377 } else if (actionType instanceof PopVlanActionCase) {
379 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class);
380 } else if (actionType instanceof PushMplsActionCase) {
382 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class);
383 } else if (actionType instanceof PopMplsActionCase) {
385 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class);
386 } else if (actionType instanceof SetQueueActionCase) {
388 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class);
389 } else if (actionType instanceof SetNwTtlActionCase) {
391 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class);
392 } else if (actionType instanceof DecNwTtlCase) {
394 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
395 } else if (actionType instanceof SetFieldCase) {
397 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
398 } else if (actionType instanceof PushPbbActionCase) {
400 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class);
401 } else if (actionType instanceof PopPbbActionCase) {
403 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class);
404 } // Experimenter action is unhandled
405 actionList.add(actionBuilder.build());
407 ActionRelatedTableFeaturePropertyBuilder propBuilder = new ActionRelatedTableFeaturePropertyBuilder();
408 propBuilder.setAction(actionList);
409 builder.setType(type);
410 builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
413 private static void setSetFieldTableFeatureProperty(
414 TableFeaturePropertiesBuilder builder,
415 TableFeaturesPropType type,
416 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> setFields) {
417 List<MatchEntries> matchEntriesList = new ArrayList<>();
419 for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch currMatch : setFields) {
420 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> currMatchType = currMatch
422 MatchEntriesBuilder matchEntryBuilder = new MatchEntriesBuilder();
423 if (currMatchType.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class)) {
424 setMatchEntry(matchEntryBuilder, ArpOp.class, currMatch.isHasMask());
425 } else if (currMatchType
426 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class)) {
427 setMatchEntry(matchEntryBuilder, ArpSha.class, currMatch.isHasMask());
428 } else if (currMatchType
429 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class)) {
430 setMatchEntry(matchEntryBuilder, ArpSpa.class, currMatch.isHasMask());
431 } else if (currMatchType
432 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class)) {
433 setMatchEntry(matchEntryBuilder, ArpTha.class, currMatch.isHasMask());
434 } else if (currMatchType
435 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class)) {
436 setMatchEntry(matchEntryBuilder, ArpTpa.class, currMatch.isHasMask());
437 } else if (currMatchType
438 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class)) {
439 setMatchEntry(matchEntryBuilder, EthDst.class, currMatch.isHasMask());
440 } else if (currMatchType
441 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class)) {
442 setMatchEntry(matchEntryBuilder, EthSrc.class, currMatch.isHasMask());
443 } else if (currMatchType
444 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class)) {
445 setMatchEntry(matchEntryBuilder, EthType.class, currMatch.isHasMask());
446 } else if (currMatchType
447 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class)) {
448 setMatchEntry(matchEntryBuilder, Icmpv4Code.class, currMatch.isHasMask());
449 } else if (currMatchType
450 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class)) {
451 setMatchEntry(matchEntryBuilder, Icmpv4Type.class, currMatch.isHasMask());
452 } else if (currMatchType
453 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class)) {
454 setMatchEntry(matchEntryBuilder, Icmpv6Code.class, currMatch.isHasMask());
455 } else if (currMatchType
456 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class)) {
457 setMatchEntry(matchEntryBuilder, Icmpv6Type.class, currMatch.isHasMask());
458 } else if (currMatchType
459 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class)) {
460 setMatchEntry(matchEntryBuilder, InPhyPort.class, currMatch.isHasMask());
461 } else if (currMatchType
462 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class)) {
463 setMatchEntry(matchEntryBuilder, InPort.class, currMatch.isHasMask());
464 } else if (currMatchType
465 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class)) {
466 setMatchEntry(matchEntryBuilder, IpDscp.class, currMatch.isHasMask());
467 } else if (currMatchType
468 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class)) {
469 setMatchEntry(matchEntryBuilder, IpEcn.class, currMatch.isHasMask());
470 } else if (currMatchType
471 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class)) {
472 setMatchEntry(matchEntryBuilder, IpProto.class, currMatch.isHasMask());
473 } else if (currMatchType
474 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class)) {
475 setMatchEntry(matchEntryBuilder, Ipv4Dst.class, currMatch.isHasMask());
476 } else if (currMatchType
477 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class)) {
478 setMatchEntry(matchEntryBuilder, Ipv4Src.class, currMatch.isHasMask());
479 } else if (currMatchType
480 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class)) {
481 setMatchEntry(matchEntryBuilder, Ipv6Dst.class, currMatch.isHasMask());
482 } else if (currMatchType
483 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class)) {
484 setMatchEntry(matchEntryBuilder, Ipv6Exthdr.class, currMatch.isHasMask());
485 } else if (currMatchType
486 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class)) {
487 setMatchEntry(matchEntryBuilder, Ipv6Flabel.class, currMatch.isHasMask());
488 } else if (currMatchType
489 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class)) {
490 setMatchEntry(matchEntryBuilder, Ipv6NdSll.class, currMatch.isHasMask());
491 } else if (currMatchType
492 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class)) {
493 setMatchEntry(matchEntryBuilder, Ipv6NdTarget.class, currMatch.isHasMask());
494 } else if (currMatchType
495 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class)) {
496 setMatchEntry(matchEntryBuilder, Ipv6NdTll.class, currMatch.isHasMask());
497 } else if (currMatchType
498 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class)) {
499 setMatchEntry(matchEntryBuilder, Ipv6Src.class, currMatch.isHasMask());
500 } else if (currMatchType
501 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class)) {
502 setMatchEntry(matchEntryBuilder, Metadata.class, currMatch.isHasMask());
503 } else if (currMatchType
504 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class)) {
505 setMatchEntry(matchEntryBuilder, MplsBos.class, currMatch.isHasMask());
506 } else if (currMatchType
507 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class)) {
508 setMatchEntry(matchEntryBuilder, MplsLabel.class, currMatch.isHasMask());
509 } else if (currMatchType
510 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class)) {
511 setMatchEntry(matchEntryBuilder, MplsTc.class, currMatch.isHasMask());
512 } else if (currMatchType
513 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class)) {
514 setMatchEntry(matchEntryBuilder, PbbIsid.class, currMatch.isHasMask());
515 } else if (currMatchType
516 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class)) {
517 setMatchEntry(matchEntryBuilder, SctpDst.class, currMatch.isHasMask());
518 } else if (currMatchType
519 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class)) {
520 setMatchEntry(matchEntryBuilder, SctpSrc.class, currMatch.isHasMask());
521 } else if (currMatchType
522 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class)) {
523 setMatchEntry(matchEntryBuilder, TcpDst.class, currMatch.isHasMask());
524 } else if (currMatchType
525 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class)) {
526 setMatchEntry(matchEntryBuilder, TcpSrc.class, currMatch.isHasMask());
527 } else if (currMatchType
528 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class)) {
529 setMatchEntry(matchEntryBuilder, TunnelId.class, currMatch.isHasMask());
530 } else if (currMatchType
531 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class)) {
532 setMatchEntry(matchEntryBuilder, UdpDst.class, currMatch.isHasMask());
533 } else if (currMatchType
534 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class)) {
535 setMatchEntry(matchEntryBuilder, UdpSrc.class, currMatch.isHasMask());
536 } else if (currMatchType
537 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class)) {
538 setMatchEntry(matchEntryBuilder, VlanPcp.class, currMatch.isHasMask());
539 } else if (currMatchType
540 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class)) {
541 setMatchEntry(matchEntryBuilder, VlanVid.class, currMatch.isHasMask());
543 matchEntriesList.add(matchEntryBuilder.build());
545 OxmRelatedTableFeaturePropertyBuilder propBuilder = new OxmRelatedTableFeaturePropertyBuilder();
546 propBuilder.setMatchEntries(matchEntriesList);
547 builder.setType(type);
548 builder.addAugmentation(OxmRelatedTableFeatureProperty.class, propBuilder.build());
551 private static void setMatchEntry(MatchEntriesBuilder builder,
552 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField> field,
554 builder.setOxmClass(OpenflowBasicClass.class);
555 builder.setOxmMatchField(field);
556 builder.setHasMask(hasMask);