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