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
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
10 import com.google.common.collect.ImmutableMap;
11 import com.google.common.collect.ImmutableMap.Builder;
12 import com.google.common.collect.Ordering;
13 import java.util.ArrayList;
14 import java.util.Arrays;
15 import java.util.Collection;
16 import java.util.List;
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
19 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
20 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.next.table.related.table.feature.property.NextTableIds;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.next.table.related.table.feature.property.NextTableIdsBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopMplsCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushMplsCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTtlCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
123 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;
124 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;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchKey;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfield;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMiss;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfield;
148 import org.opendaylight.yangtools.yang.common.Uint8;
149 import org.slf4j.Logger;
150 import org.slf4j.LoggerFactory;
153 * Converts a MD-SAL table features into the OF library table features.
159 * VersionConvertorData data = new VersionConvertorData(version);
160 * Optional<List<TableFeatures>> ofFeatures = convertorManager..convert(salTableFeatures, data);
164 public class TableFeaturesConvertor extends Convertor<
165 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures,
167 VersionConvertorData> {
169 private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class);
170 private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features
171 .table.features.table.properties.TableFeatureProperties> TABLE_FEATURE_PROPS_ORDERING =
172 Ordering.from(OrderComparator.build());
173 private static final Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm
174 .rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES;
175 private static final List<Class<?>> TYPES = Arrays.asList(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
176 .rev131026.TableFeatures.class, UpdatedTable.class);
179 Builder<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm
180 .rev150225.MatchField>> builder = ImmutableMap.builder();
181 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
182 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
183 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
184 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
185 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
186 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
187 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
188 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
189 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class,
191 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class,
193 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class,
195 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class,
197 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class,
199 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
200 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
201 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
202 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
203 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
204 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
205 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
206 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class,
208 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class,
210 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class,
212 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class,
214 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class,
216 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
217 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
218 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
219 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class,
221 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
222 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
223 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
224 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
225 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
226 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
227 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
228 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
229 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class, UdpSrc.class);
230 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
231 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
232 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class,
234 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class,
236 builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class, TcpFlags.class);
237 SAL_TO_OF_TABLE_FEATURES = builder.build();
240 private static List<TableFeatureProperties> toTableProperties(
241 final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features
242 .TableProperties tableProperties) {
243 if (tableProperties == null) {
247 List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
249 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
250 .properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(
251 tableProperties.nonnullTableFeatureProperties().values());
253 for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
254 .properties.TableFeatureProperties property : sortedTableProperties) {
255 TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
257 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type
258 .TableFeaturePropType propType = property.getTableFeaturePropType();
260 setTableFeatureProperty(propType);
262 if (propType instanceof Instructions) {
263 setTableFeatureProperty((Instructions) propType, propBuilder);
264 } else if (propType instanceof InstructionsMiss) {
265 setTableFeatureProperty((InstructionsMiss) propType, propBuilder);
266 } else if (propType instanceof NextTable) {
267 setTableFeatureProperty((NextTable) propType, propBuilder);
268 } else if (propType instanceof NextTableMiss) {
269 setTableFeatureProperty((NextTableMiss) propType, propBuilder);
270 } else if (propType instanceof WriteActions) {
271 setTableFeatureProperty((WriteActions) propType, propBuilder);
272 } else if (propType instanceof WriteActionsMiss) {
273 setTableFeatureProperty((WriteActionsMiss) propType, propBuilder);
274 } else if (propType instanceof ApplyActions) {
275 setTableFeatureProperty((ApplyActions) propType, propBuilder);
276 } else if (propType instanceof ApplyActionsMiss) {
277 setTableFeatureProperty((ApplyActionsMiss) propType, propBuilder);
278 } else if (propType instanceof Match) {
279 setTableFeatureProperty((Match) propType, propBuilder);
280 } else if (propType instanceof Wildcards) {
281 setTableFeatureProperty((Wildcards) propType, propBuilder);
282 } else if (propType instanceof WriteSetfield) {
283 setTableFeatureProperty((WriteSetfield) propType, propBuilder);
284 } else if (propType instanceof WriteSetfieldMiss) {
285 setTableFeatureProperty((WriteSetfieldMiss) propType, propBuilder);
286 } else if (propType instanceof ApplySetfield) {
287 setTableFeatureProperty((ApplySetfield) propType, propBuilder);
288 } else if (propType instanceof ApplySetfieldMiss) {
289 setTableFeatureProperty((ApplySetfieldMiss) propType, propBuilder);
292 // Experimenter and Experimenter miss Table features are unhandled
293 ofTablePropertiesList.add(propBuilder.build());
296 return ofTablePropertiesList;
299 private static void setTableFeatureProperty(final TableFeaturePropType propType) {
300 LOG.debug("Unknown TableFeaturePropType [{}]", propType.getClass());
303 private static void setTableFeatureProperty(final ApplySetfieldMiss propType,
304 final TableFeaturePropertiesBuilder propBuilder) {
305 Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
306 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
307 .type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = propType.getApplySetfieldMiss();
309 if (null != applySetfieldMiss) {
310 setFieldMatch = applySetfieldMiss.nonnullSetFieldMatch();
313 setSetFieldTableFeatureProperty(
315 TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS,
316 setFieldMatch == null ? Map.of() : setFieldMatch);
319 private static void setTableFeatureProperty(final ApplySetfield propType,
320 final TableFeaturePropertiesBuilder propBuilder) {
321 Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
322 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
323 .type.apply.setfield.ApplySetfield applySetfield = propType.getApplySetfield();
325 if (null != applySetfield) {
326 setFieldMatch = applySetfield.nonnullSetFieldMatch();
329 setSetFieldTableFeatureProperty(
331 TableFeaturesPropType.OFPTFPTAPPLYSETFIELD,
332 setFieldMatch == null ? Map.of() : setFieldMatch);
335 private static void setTableFeatureProperty(final WriteSetfieldMiss propType,
336 final TableFeaturePropertiesBuilder propBuilder) {
337 Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
338 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
339 .type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = propType.getWriteSetfieldMiss();
341 if (null != writeSetfieldMiss) {
342 setFieldMatch = writeSetfieldMiss.nonnullSetFieldMatch();
345 setSetFieldTableFeatureProperty(
347 TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS,
348 setFieldMatch == null ? Map.of() : setFieldMatch);
351 private static void setTableFeatureProperty(final WriteSetfield propType,
352 final TableFeaturePropertiesBuilder propBuilder) {
353 Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
354 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
355 .type.write.setfield.WriteSetfield writeSetField = propType.getWriteSetfield();
357 if (null != writeSetField) {
358 setFieldMatch = writeSetField.nonnullSetFieldMatch();
361 setSetFieldTableFeatureProperty(
363 TableFeaturesPropType.OFPTFPTWRITESETFIELD,
364 setFieldMatch == null ? Map.of() : setFieldMatch);
367 private static void setTableFeatureProperty(final Wildcards propType,
368 final TableFeaturePropertiesBuilder propBuilder) {
369 Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
370 WildcardSetfield wildcardSetField = propType.getWildcardSetfield();
372 if (null != wildcardSetField) {
373 setFieldMatch = wildcardSetField.nonnullSetFieldMatch();
376 setSetFieldTableFeatureProperty(
378 TableFeaturesPropType.OFPTFPTWILDCARDS,
379 setFieldMatch == null ? Map.of() : setFieldMatch);
382 private static void setTableFeatureProperty(final Match propType, final TableFeaturePropertiesBuilder propBuilder) {
383 MatchSetfield matchSetField = propType.getMatchSetfield();
384 Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
386 if (null != matchSetField) {
387 setFieldMatch = matchSetField.nonnullSetFieldMatch();
390 setSetFieldTableFeatureProperty(
392 TableFeaturesPropType.OFPTFPTMATCH,
393 setFieldMatch == null ? Map.of() : setFieldMatch);
396 private static void setTableFeatureProperty(final ApplyActionsMiss propType,
397 final TableFeaturePropertiesBuilder propBuilder) {
398 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
399 .type.apply.actions.miss.ApplyActionsMiss applyActionsMiss = propType.getApplyActionsMiss();
400 setActionTableFeatureProperty(
402 TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS,
403 applyActionsMiss == null ? Map.of() : applyActionsMiss.nonnullAction());
406 private static void setTableFeatureProperty(final ApplyActions propType,
407 final TableFeaturePropertiesBuilder propBuilder) {
408 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
409 .type.apply.actions.ApplyActions applyActions = propType.getApplyActions();
410 setActionTableFeatureProperty(
412 TableFeaturesPropType.OFPTFPTAPPLYACTIONS,
413 applyActions == null ? Map.of() : applyActions.nonnullAction());
416 private static void setTableFeatureProperty(final WriteActionsMiss propType,
417 final TableFeaturePropertiesBuilder propBuilder) {
418 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
419 .type.write.actions.miss.WriteActionsMiss writeActionsMiss = propType.getWriteActionsMiss();
420 setActionTableFeatureProperty(
422 TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS,
423 writeActionsMiss == null ? Map.of() : writeActionsMiss.nonnullAction());
426 private static void setTableFeatureProperty(final WriteActions propType,
427 final TableFeaturePropertiesBuilder propBuilder) {
428 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
429 .type.write.actions.WriteActions writeActions = propType.getWriteActions();
430 setActionTableFeatureProperty(
432 TableFeaturesPropType.OFPTFPTWRITEACTIONS,
433 writeActions == null ? Map.of() : writeActions.nonnullAction());
436 private static void setTableFeatureProperty(final NextTableMiss propType,
437 final TableFeaturePropertiesBuilder propBuilder) {
438 TablesMiss tables = propType.getTablesMiss();
439 setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLESMISS,
440 tables == null ? new ArrayList<>() : tables.getTableIds());
443 private static void setTableFeatureProperty(final NextTable propType,
444 final TableFeaturePropertiesBuilder propBuilder) {
445 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
446 .type.next.table.Tables tables = propType.getTables();
447 setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLES,
448 tables == null ? new ArrayList<>() : tables.getTableIds());
451 private static void setTableFeatureProperty(final InstructionsMiss propType,
452 final TableFeaturePropertiesBuilder propBuilder) {
453 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
454 .type.instructions.miss.InstructionsMiss instructions = propType.getInstructionsMiss();
455 setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS,
456 instructions == null ? Map.of() : instructions.nonnullInstruction());
459 private static void setTableFeatureProperty(final Instructions propType,
460 final TableFeaturePropertiesBuilder propBuilder) {
461 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
462 .type.instructions.Instructions instructions = propType.getInstructions();
463 setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS,
464 instructions == null ? Map.of() : instructions.nonnullInstruction());
467 private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
468 final TableFeaturesPropType type, final Map<InstructionKey, Instruction> instructionList) {
469 List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping
470 .Instruction> instructionTypeList = new ArrayList<>(instructionList.size());
472 for (Instruction currInstruction : instructionList.values()) {
473 InstructionBuilder instructionType = new InstructionBuilder();
475 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction =
476 currInstruction.getInstruction();
478 if (instruction instanceof GoToTableCase) {
479 GotoTableCaseBuilder goToTableCaseBuilder = new GotoTableCaseBuilder();
480 instructionType.setInstructionChoice(goToTableCaseBuilder.build());
481 } else if (instruction instanceof WriteMetadataCase) {
482 WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
483 instructionType.setInstructionChoice(writeMetadataCaseBuilder.build());
484 } else if (instruction instanceof WriteActionsCase) {
485 WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
486 instructionType.setInstructionChoice(writeActionsCaseBuilder.build());
487 } else if (instruction instanceof ApplyActionsCase) {
488 ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
489 instructionType.setInstructionChoice(applyActionsCaseBuilder.build());
490 } else if (instruction instanceof ClearActionsCase) {
491 ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
492 instructionType.setInstructionChoice(clearActionsCaseBuilder.build());
493 } else if (instruction instanceof MeterCase) {
494 MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
495 instructionType.setInstructionChoice(meterCaseBuilder.build());
498 // TODO: Experimenter instructions are unhandled
499 instructionTypeList.add(instructionType.build());
502 InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
503 propBuilder.setInstruction(instructionTypeList);
504 builder.setType(type);
505 builder.addAugmentation(propBuilder.build());
508 private static void setNextTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
509 final TableFeaturesPropType type, final List<Uint8> tableIds) {
510 List<NextTableIds> nextTableIdsList = new ArrayList<>();
512 for (Uint8 tableId : tableIds) {
513 nextTableIdsList.add(new NextTableIdsBuilder().setTableId(tableId).build());
516 builder.setType(type).addAugmentation(new NextTableRelatedTableFeaturePropertyBuilder()
517 .setNextTableIds(nextTableIdsList)
521 private static void setActionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
522 final TableFeaturesPropType type,
523 final Map<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey,
524 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
527 List<Action> actionList = new ArrayList<>(salActions.size());
529 for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction :
530 salActions.values()) {
531 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction
533 ActionBuilder actionBuilder = new ActionBuilder();
535 if (actionType instanceof OutputActionCase) {
536 OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
537 actionBuilder.setActionChoice(outputActionCaseBuilder.build());
538 } else if (actionType instanceof GroupActionCase) {
539 GroupCaseBuilder groupActionBuilder = new GroupCaseBuilder();
540 actionBuilder.setActionChoice(groupActionBuilder.build());
541 } else if (actionType instanceof CopyTtlOutCase) {
542 CopyTtlOutCaseBuilder copyTtlOutCaseBuilder = new CopyTtlOutCaseBuilder();
543 actionBuilder.setActionChoice(copyTtlOutCaseBuilder.build());
544 } else if (actionType instanceof CopyTtlInCase) {
545 CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();
546 actionBuilder.setActionChoice(copyTtlInCaseBuilder.build());
547 } else if (actionType instanceof SetMplsTtlActionCase) {
548 SetMplsTtlCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlCaseBuilder();
549 actionBuilder.setActionChoice(setMplsTtlActionBuilder.build());
550 } else if (actionType instanceof DecMplsTtlCase) {
551 DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder();
552 actionBuilder.setActionChoice(decMplsTtlCaseBuilder.build());
553 } else if (actionType instanceof PushVlanActionCase) {
554 PushVlanCaseBuilder pushVlanActionBuilder = new PushVlanCaseBuilder();
555 actionBuilder.setActionChoice(pushVlanActionBuilder.build());
556 } else if (actionType instanceof PopVlanActionCase) {
557 PopVlanCaseBuilder popVlanCaseBuilder = new PopVlanCaseBuilder();
558 actionBuilder.setActionChoice(popVlanCaseBuilder.build());
559 } else if (actionType instanceof PushMplsActionCase) {
560 PushMplsCaseBuilder pushMplsActionBuilder = new PushMplsCaseBuilder();
561 actionBuilder.setActionChoice(pushMplsActionBuilder.build());
562 } else if (actionType instanceof PopMplsActionCase) {
563 PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
564 actionBuilder.setActionChoice(popMplsCaseBuilder.build());
565 } else if (actionType instanceof SetQueueActionCase) {
566 SetQueueCaseBuilder setQueueActionBuilder = new SetQueueCaseBuilder();
567 actionBuilder.setActionChoice(setQueueActionBuilder.build());
568 } else if (actionType instanceof SetNwTtlActionCase) {
569 SetNwTtlCaseBuilder setNwTtlActionBuilder = new SetNwTtlCaseBuilder();
570 actionBuilder.setActionChoice(setNwTtlActionBuilder.build());
571 } else if (actionType instanceof DecNwTtlCase) {
572 DecNwTtlCaseBuilder decNwTtlCaseBuilder = new DecNwTtlCaseBuilder();
573 actionBuilder.setActionChoice(decNwTtlCaseBuilder.build());
574 } else if (actionType instanceof SetFieldCase) {
575 SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
576 actionBuilder.setActionChoice(setFieldCaseBuilder.build());
577 } else if (actionType instanceof PushPbbActionCase) {
578 PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
579 actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
580 } else if (actionType instanceof PopPbbActionCase) {
581 PopPbbCaseBuilder popPbbCaseBuilder = new PopPbbCaseBuilder();
582 actionBuilder.setActionChoice(popPbbCaseBuilder.build());
585 // Experimenter action is unhandled
586 actionList.add(actionBuilder.build());
589 ActionRelatedTableFeaturePropertyBuilder propBuilder = new ActionRelatedTableFeaturePropertyBuilder();
590 propBuilder.setAction(actionList);
591 builder.setType(type);
592 builder.addAugmentation(propBuilder.build());
595 private static void setSetFieldTableFeatureProperty(
596 final TableFeaturePropertiesBuilder builder,
597 final TableFeaturesPropType type,
598 final Map<SetFieldMatchKey, SetFieldMatch> setFields) {
599 List<MatchEntry> matchEntriesList = new ArrayList<>();
601 for (SetFieldMatch currMatch : setFields.values()) {
602 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>
603 currMatchType = currMatch.getMatchType();
604 MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
605 Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>
606 ofTableFeatureClass = SAL_TO_OF_TABLE_FEATURES.get(currMatchType);
607 setMatchEntry(matchEntryBuilder, ofTableFeatureClass, currMatch.getHasMask());
608 matchEntriesList.add(matchEntryBuilder.build());
611 builder.setType(type).addAugmentation(new OxmRelatedTableFeaturePropertyBuilder()
612 .setMatchEntry(matchEntriesList)
616 private static void setMatchEntry(final MatchEntryBuilder builder,
617 final Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225
618 .MatchField> field, final Boolean hasMask) {
619 if (field == TcpFlags.class) {
620 builder.setOxmClass(ExperimenterClass.class);
622 builder.setOxmClass(OpenflowBasicClass.class);
624 builder.setOxmMatchField(field);
625 builder.setHasMask(hasMask);
629 public Collection<Class<?>> getTypes() {
634 public List<TableFeatures> convert(
635 final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source,
636 final VersionConvertorData data) {
637 List<TableFeatures> ofTableFeaturesList = new ArrayList<>();
638 TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
640 for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures
641 salTableFeatures : source.nonnullTableFeatures().values()) {
642 ofTableFeatures.setTableId(salTableFeatures.getTableId());
643 ofTableFeatures.setName(salTableFeatures.getName());
644 ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
645 ofTableFeatures.setMetadataWrite(salTableFeatures.getMetadataWrite());
646 ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
648 if (salTableFeatures.getConfig() != null) {
649 ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().getDEPRECATEDMASK()));
652 ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));
653 ofTableFeaturesList.add(ofTableFeatures.build());
656 return ofTableFeaturesList;