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.CopyTtlInBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeatureProperty;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpDscp;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpEcn;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.IpProto;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
90 import org.slf4j.Logger;
91 import org.slf4j.LoggerFactory;
94 * Utility class for converting a OF library table features to MD-SAL table
97 public class TableFeaturesReplyConvertor {
98 private static final Logger logger = LoggerFactory.getLogger(TableFeaturesReplyConvertor.class);
100 public static List<TableFeatures> toTableFeaturesReply(
101 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures ofTableFeaturesList) {
102 if (ofTableFeaturesList == null || ofTableFeaturesList.getTableFeatures() == null) {
103 return Collections.<TableFeatures> emptyList();
105 List<TableFeatures> salTableFeaturesList = new ArrayList<>();
106 TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
107 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features.TableFeatures ofTableFeatures : ofTableFeaturesList
108 .getTableFeatures()) {
109 salTableFeatures.setTableId(ofTableFeatures.getTableId());
110 salTableFeatures.setName(ofTableFeatures.getName());
111 if (ofTableFeatures.getMetadataMatch() != null) {
112 salTableFeatures.setMetadataMatch(new BigInteger(ofTableFeatures.getMetadataMatch()));
114 if (ofTableFeatures.getMetadataWrite() != null) {
115 salTableFeatures.setMetadataWrite(new BigInteger(ofTableFeatures.getMetadataWrite()));
117 if (ofTableFeatures.getConfig() != null) {
118 salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
120 salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
121 salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
122 salTableFeaturesList.add(salTableFeatures.build());
124 return salTableFeaturesList;
127 private static TableProperties toTableProperties(List<TableFeatureProperties> ofTablePropertiesList) {
128 if (ofTablePropertiesList == null) {
129 return new TablePropertiesBuilder()
130 .setTableFeatureProperties(
132 .<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> emptyList())
135 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
136 TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
137 for (TableFeatureProperties property : ofTablePropertiesList) {
138 TableFeaturesPropType propType = property.getType();
139 if (propType != null) {
141 case OFPTFPTINSTRUCTIONS:
142 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();
144 .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
145 .setInstruction(setInstructionTableFeatureProperty(property)).build());
146 propBuilder.setTableFeaturePropType(instructionBuilder.build());
148 case OFPTFPTINSTRUCTIONSMISS:
149 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();
150 instructionMissBuilder
151 .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
152 .setInstruction(setInstructionTableFeatureProperty(property)).build());
153 propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
155 case OFPTFPTNEXTTABLES:
156 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();
158 .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
159 .setTableIds(setNextTableFeatureProperty(property)).build());
160 propBuilder.setTableFeaturePropType(nextTableBuilder.build());
162 case OFPTFPTNEXTTABLESMISS:
163 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();
165 .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesBuilder()
166 .setTableIds(setNextTableFeatureProperty(property)).build());
167 propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
169 case OFPTFPTWRITEACTIONS:
170 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();
172 .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
173 .setAction(setActionTableFeatureProperty(property)).build());
174 propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
176 case OFPTFPTWRITEACTIONSMISS:
177 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();
178 writeActionsMissBuilder
179 .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
180 .setAction(setActionTableFeatureProperty(property)).build());
181 propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
183 case OFPTFPTAPPLYACTIONS:
184 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();
186 .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
187 .setAction(setActionTableFeatureProperty(property)).build());
188 propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
190 case OFPTFPTAPPLYACTIONSMISS:
191 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();
192 applyActionsMissBuilder
193 .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
194 .setAction(setActionTableFeatureProperty(property)).build());
195 propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
198 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder matchBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder();
199 matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
200 propBuilder.setTableFeaturePropType(matchBuilder.build());
202 case OFPTFPTWILDCARDS:
203 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder wildcardsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder();
204 wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
205 propBuilder.setTableFeaturePropType(wildcardsBuilder.build());
207 case OFPTFPTWRITESETFIELD:
208 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder writeSetfieldBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder();
209 writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
210 propBuilder.setTableFeaturePropType(writeSetfieldBuilder.build());
212 case OFPTFPTWRITESETFIELDMISS:
213 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder writeSetfieldMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder();
214 writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
215 propBuilder.setTableFeaturePropType(writeSetfieldMissBuilder.build());
217 case OFPTFPTAPPLYSETFIELD:
218 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder applySetfieldBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder();
219 applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
220 propBuilder.setTableFeaturePropType(applySetfieldBuilder.build());
222 case OFPTFPTAPPLYSETFIELDMISS:
223 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder applySetfieldMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder();
224 applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
225 propBuilder.setTableFeaturePropType(applySetfieldMissBuilder.build());
227 case OFPTFPTEXPERIMENTER:
228 // Experimenter Table features are unhandled
230 case OFPTFPTEXPERIMENTERMISS:
231 // Experimenter miss Table features are unhandled
234 logger.error("Unsupported table feature property : " + propType);
237 salTablePropertiesList.add(propBuilder.build());
240 return new TablePropertiesBuilder().setTableFeatureProperties(salTablePropertiesList).build();
243 private static List<Instruction> setInstructionTableFeatureProperty(TableFeatureProperties properties) {
244 List<Instruction> instructionList = new ArrayList<>();
245 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();
246 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions currInstruction : properties
247 .getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstructions()) {
248 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Instruction> currInstructionType = currInstruction
250 if (currInstructionType
251 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable.class)) {
252 builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableBuilder()
254 } else if (currInstructionType
255 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata.class)) {
256 builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataBuilder()
258 } else if (currInstructionType
259 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions.class)) {
260 builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsBuilder()
262 } else if (currInstructionType
263 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions.class)) {
264 builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsBuilder()
266 } else if (currInstructionType
267 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions.class)) {
268 builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsBuilder()
270 } else if (currInstructionType
271 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter.class)) {
272 builder.setInstruction((new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterBuilder()
274 } else if (currInstructionType
275 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class)) {
276 // TODO: Experimenter instructions are unhandled
278 instructionList.add(builder.build());
280 return instructionList;
283 private static List<Short> setNextTableFeatureProperty(TableFeatureProperties properties) {
284 List<Short> nextTableIdsList = new ArrayList<>();
285 for (NextTableIds tableId : properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
286 .getNextTableIds()) {
287 nextTableIdsList.add(tableId.getTableId());
289 return nextTableIdsList;
292 private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
293 TableFeatureProperties properties) {
294 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
295 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();
296 for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList currAction : properties
297 .getAugmentation(ActionRelatedTableFeatureProperty.class).getActionsList()) {
298 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action action = currAction
300 if (action != null) {
301 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Action> actionType = action
304 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
305 actionBuilder.setAction(new OutputActionBuilder().build());
306 } else if (actionType
307 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
308 actionBuilder.setAction(new GroupActionBuilder().build());
309 } else if (actionType
310 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
311 actionBuilder.setAction(new CopyTtlOutBuilder().build());
312 } else if (actionType
313 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
314 actionBuilder.setAction(new CopyTtlInBuilder().build());
315 } else if (actionType
316 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
317 actionBuilder.setAction(new SetMplsTtlActionBuilder().build());
318 } else if (actionType
319 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
320 actionBuilder.setAction(new DecMplsTtlBuilder().build());
321 } else if (actionType
322 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
323 actionBuilder.setAction(new PushVlanActionBuilder().build());
324 } else if (actionType
325 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) {
326 actionBuilder.setAction(new PopVlanActionBuilder().build());
327 } else if (actionType
328 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
329 actionBuilder.setAction(new PushMplsActionBuilder().build());
330 } else if (actionType
331 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
332 actionBuilder.setAction(new PopMplsActionBuilder().build());
333 } else if (actionType
334 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
335 actionBuilder.setAction(new SetQueueActionBuilder().build());
336 } else if (actionType
337 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
338 actionBuilder.setAction(new SetNwTtlActionBuilder().build());
339 } else if (actionType
340 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
341 actionBuilder.setAction(new DecNwTtlBuilder().build());
342 } else if (actionType
343 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
344 actionBuilder.setAction(new SetFieldBuilder().build());
345 } else if (actionType
346 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
347 actionBuilder.setAction(new PushPbbActionBuilder().build());
348 } else if (actionType
349 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
350 actionBuilder.setAction(new PopPbbActionBuilder().build());
351 } else if (actionType
352 .equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
353 // TODO: Experimenter Action unhandled.
355 actionList.add(actionBuilder.build());
361 private static List<SetFieldMatch> setSetFieldTableFeatureProperty(TableFeatureProperties properties,
362 boolean setHasMask) {
363 List<SetFieldMatch> setFieldMatchList = new ArrayList<>();
364 SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
365 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> salMatchField = null;
366 Class<? extends MatchField> ofMatchField = null;
368 // This handles only OpenflowBasicClass oxm class.
369 for (MatchEntries currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class)
370 .getMatchEntries()) {
371 ofMatchField = currMatch.getOxmMatchField();
372 if (ofMatchField.equals(ArpOp.class)) {
373 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class;
374 } else if (ofMatchField.equals(ArpSha.class)) {
375 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class;
376 } else if (ofMatchField.equals(ArpSpa.class)) {
377 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class;
378 } else if (ofMatchField.equals(ArpTha.class)) {
379 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class;
380 } else if (ofMatchField.equals(ArpTpa.class)) {
381 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class;
382 } else if (ofMatchField.equals(EthDst.class)) {
383 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class;
384 } else if (ofMatchField.equals(EthSrc.class)) {
385 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class;
386 } else if (ofMatchField.equals(EthType.class)) {
387 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class;
388 } else if (ofMatchField.equals(Icmpv4Code.class)) {
389 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class;
390 } else if (ofMatchField.equals(Icmpv4Type.class)) {
391 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class;
392 } else if (ofMatchField.equals(Icmpv6Code.class)) {
393 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class;
394 } else if (ofMatchField.equals(Icmpv6Type.class)) {
395 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class;
396 } else if (ofMatchField.equals(InPhyPort.class)) {
397 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class;
398 } else if (ofMatchField.equals(InPort.class)) {
399 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class;
400 } else if (ofMatchField.equals(IpDscp.class)) {
401 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class;
402 } else if (ofMatchField.equals(IpEcn.class)) {
403 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class;
404 } else if (ofMatchField.equals(IpProto.class)) {
405 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class;
406 } else if (ofMatchField.equals(Ipv4Dst.class)) {
407 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class;
408 } else if (ofMatchField.equals(Ipv4Src.class)) {
409 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class;
410 } else if (ofMatchField.equals(Ipv6Dst.class)) {
411 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class;
412 } else if (ofMatchField.equals(Ipv6Exthdr.class)) {
413 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class;
414 } else if (ofMatchField.equals(Ipv6Flabel.class)) {
415 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class;
416 } else if (ofMatchField.equals(Ipv6NdSll.class)) {
417 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class;
418 } else if (ofMatchField.equals(Ipv6NdTarget.class)) {
419 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class;
420 } else if (ofMatchField.equals(Ipv6NdTll.class)) {
421 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class;
422 } else if (ofMatchField.equals(Ipv6Src.class)) {
423 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class;
424 } else if (ofMatchField.equals(Metadata.class)) {
425 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class;
426 } else if (ofMatchField.equals(MplsBos.class)) {
427 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class;
428 } else if (ofMatchField.equals(MplsLabel.class)) {
429 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class;
430 } else if (ofMatchField.equals(MplsTc.class)) {
431 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class;
432 } else if (ofMatchField.equals(PbbIsid.class)) {
433 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class;
434 } else if (ofMatchField.equals(SctpDst.class)) {
435 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class;
436 } else if (ofMatchField.equals(SctpSrc.class)) {
437 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class;
438 } else if (ofMatchField.equals(TcpDst.class)) {
439 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class;
440 } else if (ofMatchField.equals(TcpSrc.class)) {
441 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class;
442 } else if (ofMatchField.equals(TunnelId.class)) {
443 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class;
444 } else if (ofMatchField.equals(UdpDst.class)) {
445 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class;
446 } else if (ofMatchField.equals(UdpSrc.class)) {
447 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class;
448 } else if (ofMatchField.equals(VlanPcp.class)) {
449 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class;
450 } else if (ofMatchField.equals(VlanVid.class)) {
451 salMatchField = org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class;
454 setFieldMatchBuilder.setMatchType(salMatchField);
456 setFieldMatchBuilder.setHasMask(currMatch.isHasMask());
458 setFieldMatchList.add(setFieldMatchBuilder.build());
460 return setFieldMatchList;