2 * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. 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 * Contributor: hema.gopalkrishnan@ericsson.com
10 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
12 import java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.List;
16 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
17 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
19 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
20 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstAction;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcAction;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterAction;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValuesV10;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
154 import org.opendaylight.yangtools.yang.binding.Augmentation;
155 import org.slf4j.Logger;
156 import org.slf4j.LoggerFactory;
159 * @author usha@ericsson Action List:This class takes data from SAL layer and
160 * converts into OF Data
161 * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
165 public final class ActionConvertor {
166 private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
167 private static final String PREFIX_SEPARATOR = "/";
168 final private static Long MAXPortOF13 = new Long(4294967040L); // 0xffffff00
169 final private static Long MAXPortOF10 = new Long(0xff00);
171 private ActionConvertor() {
176 * Translates SAL actions into OF Library actions
177 * @param actions SAL actions
178 * @param version Openflow protocol version used
180 * @return OF Library actions
182 public static List<Action> getActions(
183 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
184 short version, BigInteger datapathid)
187 List<Action> actionsList = new ArrayList<>();
190 for (int actionItem = 0; actionItem < actions.size(); actionItem++) {
192 ActionBuilder actionBuilder = new ActionBuilder();
194 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = actions.get(
195 actionItem).getAction();
197 if (action instanceof OutputActionCase)
198 ofAction = salToOFOutputAction(action, actionBuilder, version);
199 else if (action instanceof GroupActionCase)
200 ofAction = SalToOFGroupAction(action, actionBuilder);
201 else if (action instanceof CopyTtlOutCase)
202 ofAction = SalToOFCopyTTLIOut(actionBuilder);
203 else if (action instanceof CopyTtlInCase)
204 ofAction = SalToOFCopyTTLIIn(actionBuilder);
205 else if (action instanceof SetMplsTtlActionCase)
206 ofAction = SalToOFSetMplsTtl(action, actionBuilder);
207 else if (action instanceof DecMplsTtlCase)
208 ofAction = SalToOFDecMplsTtl(actionBuilder);
209 else if (action instanceof PushVlanActionCase)
210 ofAction = SalToOFPushVlanAction(action, actionBuilder);
211 else if (action instanceof PopVlanActionCase)
212 ofAction = SalToOFPopVlan(actionBuilder);
213 else if (action instanceof PushMplsActionCase)
214 ofAction = SalToOFPushMplsAction(action, actionBuilder);
215 else if (action instanceof PopMplsActionCase)
216 ofAction = SalToOFPopMpls(action, actionBuilder);
217 else if (action instanceof SetQueueActionCase)
218 ofAction = SalToOFSetQueue(action, actionBuilder);
219 else if (action instanceof SetNwTtlActionCase)
220 ofAction = SalToOFSetNwTtl(action, actionBuilder);
221 else if (action instanceof DecNwTtlCase)
222 ofAction = SalToOFDecNwTtl(actionBuilder);
223 else if (action instanceof SetFieldCase)
224 ofAction = SalToOFSetField(action, actionBuilder, version, datapathid);
225 else if (action instanceof PushPbbActionCase)
226 ofAction = SalToOFPushPbbAction(action, actionBuilder);
227 else if (action instanceof PopPbbActionCase)
228 ofAction = SalToOFPopPBB(actionBuilder);
229 else if (action instanceof ExperimenterAction)
230 ofAction = SalToOFExperimenter(action, actionBuilder);
233 else if (action instanceof SetVlanIdActionCase)
234 ofAction = SalToOFSetVlanId(action, actionBuilder, version);
235 else if (action instanceof SetVlanPcpActionCase)
236 ofAction = SalToOFSetVlanpcp(action, actionBuilder, version);
237 else if (action instanceof StripVlanActionCase)
238 ofAction = SalToOFStripVlan(actionBuilder, version);
239 else if (action instanceof SetDlSrcActionCase)
240 ofAction = SalToOFSetDlSrc(action, actionBuilder, version);
241 else if (action instanceof SetDlDstActionCase)
242 ofAction = SalToOFSetDlDst(action, actionBuilder, version);
243 else if (action instanceof SetNwSrcActionCase)
244 ofAction = SalToOFSetNwSrc(action, actionBuilder, version);
245 else if (action instanceof SetNwDstActionCase)
246 ofAction = SalToOFSetNwDst(action, actionBuilder, version);
247 else if (action instanceof SetTpSrcActionCase)
248 ofAction = SalToOFSetTpSrc(action, actionBuilder, version);
249 else if (action instanceof SetTpDstActionCase)
250 ofAction = SalToOFSetTpDst(action, actionBuilder, version);
251 else if (action instanceof SetNwTosActionCase)
252 ofAction = SalToOFSetNwTos(action, actionBuilder, version);
254 if (ofAction != null) {
255 actionsList.add(ofAction);
261 private static Action SalToOFSetField(
262 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
263 ActionBuilder actionBuilder, short version, BigInteger datapathid) {
265 SetFieldCase setFieldCase = (SetFieldCase) action;
266 org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match = setFieldCase
269 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
270 MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
273 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
275 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
276 return actionBuilder.build();
279 private static Action SalToOFDecNwTtl(ActionBuilder actionBuilder) {
281 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
282 return emtpyAction(actionBuilder);
285 private static Action SalToOFPushMplsAction(
286 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
287 ActionBuilder actionBuilder) {
288 PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
289 actionBuilder.setType(PushMpls.class);
291 return SalToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
294 private static Action SalToOFPushPbbAction(
295 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
296 ActionBuilder actionBuilder) {
297 PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
298 actionBuilder.setType(PushPbb.class);
300 return SalToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
303 private static Action SalToOFPushVlanAction(
304 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
305 ActionBuilder actionBuilder) {
306 PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
307 PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
308 actionBuilder.setType(PushVlan.class);
310 return SalToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
313 private static Action SalToOFSetNwTtl(
314 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
315 ActionBuilder actionBuilder) {
316 SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
317 NwTtlActionBuilder nwTtlActionBuilder = new NwTtlActionBuilder();
318 nwTtlActionBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
319 actionBuilder.setType(SetNwTtl.class);
320 actionBuilder.addAugmentation(NwTtlAction.class, nwTtlActionBuilder.build());
321 return actionBuilder.build();
324 private static Action SalToOFSetQueue(
325 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
326 ActionBuilder actionBuilder) {
327 SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
328 SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
330 QueueIdActionBuilder queueIdActionBuilder = new QueueIdActionBuilder();
331 queueIdActionBuilder.setQueueId(setQueueAction.getQueueId());
332 actionBuilder.setType(SetQueue.class);
333 actionBuilder.addAugmentation(QueueIdAction.class, queueIdActionBuilder.build());
335 return actionBuilder.build();
338 private static Action SalToOFPopMpls(
339 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
340 ActionBuilder actionBuilder) {
341 PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
342 actionBuilder.setType(PopMpls.class);
344 return SalToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
347 private static Action SalToOFPopVlan(ActionBuilder actionBuilder) {
348 actionBuilder.setType(PopVlan.class);
349 return emtpyAction(actionBuilder);
352 private static Action SalToOFPopPBB(ActionBuilder actionBuilder) {
353 actionBuilder.setType(PopPbb.class);
354 return emtpyAction(actionBuilder);
357 private static Action SalToOFExperimenter(
358 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
359 ActionBuilder actionBuilder) {
360 ExperimenterActionBuilder experimenterActionBuilder = new ExperimenterActionBuilder();
361 experimenterActionBuilder.setExperimenter(((ExperimenterAction) action).getExperimenter());
362 actionBuilder.setType(Experimenter.class);
365 ExperimenterAction.class,
366 (Augmentation<Action>) experimenterActionBuilder);
367 return actionBuilder.build();
370 private static Action SalToOFSetVlanId(
371 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
372 ActionBuilder actionBuilder, short version) {
374 SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
375 SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
377 if (version == OFConstants.OFP_VERSION_1_0) {
379 VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
380 vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
382 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
383 actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
384 return actionBuilder.build();
385 } else if (version >= OFConstants.OFP_VERSION_1_3) {
386 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
388 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
389 List<MatchEntries> matchEntriesList = new ArrayList<>();
390 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
391 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
392 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
393 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
394 vlanVidBuilder.setCfiBit(true);
395 vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
396 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
397 matchEntriesBuilder.setHasMask(false);
398 matchEntriesList.add(matchEntriesBuilder.build());
399 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
400 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
401 return actionBuilder.build();
403 logger.error("Unknown Action Type for the Version", version);
408 private static Action SalToOFSetVlanpcp(
409 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
410 ActionBuilder actionBuilder, short version) {
412 SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
413 SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
415 if (version == OFConstants.OFP_VERSION_1_0) {
416 VlanPcpActionBuilder vlanpcpActionBuilder = new VlanPcpActionBuilder();
417 vlanpcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
419 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp.class);
420 actionBuilder.addAugmentation(VlanPcpAction.class, vlanpcpActionBuilder.build());
421 return actionBuilder.build();
422 } else if (version >= OFConstants.OFP_VERSION_1_3) {
423 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
425 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
426 List<MatchEntries> matchEntriesList = new ArrayList<>();
427 matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
428 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
429 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
430 return actionBuilder.build();
432 logger.error("Unknown Action Type for the Version", version);
437 private static Action SalToOFStripVlan(ActionBuilder actionBuilder, short version) {
438 if (version == OFConstants.OFP_VERSION_1_0) {
440 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
442 return emtpyAction(actionBuilder);
443 } else if (version >= OFConstants.OFP_VERSION_1_3) {
444 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
446 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
447 List<MatchEntries> matchEntriesList = new ArrayList<>();
448 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
449 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
450 matchEntriesBuilder.setOxmMatchField(VlanVid.class);
451 VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
452 vlanVidBuilder.setCfiBit(true);
453 vlanVidBuilder.setVlanVid(new Integer(0x0000));
454 matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
455 matchEntriesBuilder.setHasMask(false);
456 matchEntriesList.add(matchEntriesBuilder.build());
457 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
458 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
459 return actionBuilder.build();
461 logger.error("Unknown Action Type for the Version", version);
466 private static Action SalToOFSetDlSrc(
467 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
468 ActionBuilder actionBuilder, short version) {
470 SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
471 SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
473 if (version == OFConstants.OFP_VERSION_1_0) {
474 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
475 dladdressactionbuilder.setDlAddress(setdlsrcaction.getAddress());
477 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc.class);
478 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
479 return actionBuilder.build();
480 } else if (version >= OFConstants.OFP_VERSION_1_3) {
481 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
483 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
484 List<MatchEntries> matchEntriesList = new ArrayList<>();
485 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
486 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
487 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
488 return actionBuilder.build();
490 logger.error("Unknown Action Type for the Version", version);
496 private static Action SalToOFSetDlDst(
497 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
498 ActionBuilder actionBuilder, short version) {
500 SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
501 SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
503 if (version == OFConstants.OFP_VERSION_1_0) {
504 DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
505 dladdressactionbuilder.setDlAddress(setdldstaction.getAddress());
507 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst.class);
508 actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
509 return actionBuilder.build();
510 } else if (version >= OFConstants.OFP_VERSION_1_3) {
511 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
513 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
514 List<MatchEntries> matchEntriesList = new ArrayList<>();
515 matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
516 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
517 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
518 return actionBuilder.build();
520 logger.error("Unknown Action Type for the Version", version);
526 private static Action SalToOFSetNwSrc(
527 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
528 ActionBuilder actionBuilder, short version) {
530 SetNwSrcActionCase setnwsrccase = (SetNwSrcActionCase) action;
531 SetNwSrcAction setnwsrcaction = setnwsrccase.getSetNwSrcAction();
532 Ipv4 address_ipv4 = (Ipv4) setnwsrcaction.getAddress();
534 if (version == OFConstants.OFP_VERSION_1_0) {
535 IpAddressActionBuilder ipvaddress = new IpAddressActionBuilder();
537 Ipv4Address address = new Ipv4Address(address_ipv4.getIpv4Address().getValue());
538 ipvaddress.setIpAddress(address);
540 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc.class);
541 actionBuilder.addAugmentation(
542 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction.class,
544 return actionBuilder.build();
545 } else if (version >= OFConstants.OFP_VERSION_1_3) {
546 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
548 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
549 List<MatchEntries> matchEntriesList = new ArrayList<>();
550 String[] addressParts = address_ipv4.getIpv4Address().getValue().split(PREFIX_SEPARATOR);
551 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
552 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
553 matchEntriesBuilder.setOxmMatchField(Ipv4Src.class);
554 Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
555 Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
556 ipv4AddressBuilder.setIpv4Address(ipv4Address);
557 matchEntriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
558 matchEntriesBuilder.setHasMask(false);
559 matchEntriesList.add(matchEntriesBuilder.build());
560 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
561 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
562 return actionBuilder.build();
564 logger.error("Unknown Action Type for the Version", version);
570 private static Action SalToOFSetNwDst(
571 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
572 ActionBuilder actionBuilder, short version) {
574 SetNwDstActionCase setnwdstcase = (SetNwDstActionCase) action;
575 SetNwDstAction setnwdstaction = setnwdstcase.getSetNwDstAction();
576 Ipv4 address_ipv4 = (Ipv4) setnwdstaction.getAddress();
578 if (version == OFConstants.OFP_VERSION_1_0) {
579 IpAddressActionBuilder ipvaddress = new IpAddressActionBuilder();
581 Ipv4Address address = new Ipv4Address(address_ipv4.getIpv4Address().getValue());
582 ipvaddress.setIpAddress(address);
584 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst.class);
585 actionBuilder.addAugmentation(
586 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction.class,
588 return actionBuilder.build();
590 } else if (version >= OFConstants.OFP_VERSION_1_3) {
591 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
593 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
594 List<MatchEntries> matchEntriesList = new ArrayList<>();
595 String[] addressParts = address_ipv4.getIpv4Address().getValue().split(PREFIX_SEPARATOR);
596 MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
597 matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
598 matchEntriesBuilder.setOxmMatchField(Ipv4Dst.class);
599 Ipv4Address ipv4Address = new Ipv4Address(addressParts[0]);
600 Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
601 ipv4AddressBuilder.setIpv4Address(ipv4Address);
602 matchEntriesBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
603 matchEntriesBuilder.setHasMask(false);
604 matchEntriesList.add(matchEntriesBuilder.build());
605 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
606 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
607 return actionBuilder.build();
609 logger.error("Unknown Action Type for the Version", version);
615 private static Action SalToOFSetNwTos(
616 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
617 ActionBuilder actionBuilder, short version) {
619 SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
620 SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
622 if (version == OFConstants.OFP_VERSION_1_0) {
623 NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
624 tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
625 actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
627 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
629 return actionBuilder.build();
630 } else if (version >= OFConstants.OFP_VERSION_1_3) {
631 OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
633 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
634 List<MatchEntries> matchEntriesList = new ArrayList<>();
635 matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(setnwtosaction.getTos().shortValue())));
636 oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
637 actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
638 return actionBuilder.build();
640 logger.error("Unknown Action Type for the Version", version);
646 private static Action SalToOFSetTpSrc(
647 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
648 ActionBuilder actionBuilder, short version) {
650 if (version == OFConstants.OFP_VERSION_1_0) {
651 SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
652 SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
654 PortActionBuilder settpsrc = new PortActionBuilder();
655 PortNumber port = new PortNumber(settpsrcaction.getPort().getValue().longValue());
656 settpsrc.setPort(port);
659 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
660 actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
661 return actionBuilder.build();
663 logger.error("Unknown Action Type for the Version", version);
667 private static Action SalToOFSetTpDst(
668 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
669 ActionBuilder actionBuilder, short version) {
671 if (version == OFConstants.OFP_VERSION_1_0) {
672 SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
673 SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
674 PortActionBuilder settpdst = new PortActionBuilder();
675 PortNumber port = new PortNumber(settpdstaction.getPort().getValue().longValue());
676 settpdst.setPort(port);
679 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
680 actionBuilder.addAugmentation(PortAction.class, settpdst.build());
681 return actionBuilder.build();
683 logger.error("Unknown Action Type for the Version", version);
687 private static Action SalToOFGroupAction(
688 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
689 ActionBuilder actionBuilder) {
691 GroupActionCase groupActionCase = (GroupActionCase) action;
692 GroupAction groupAction = groupActionCase.getGroupAction();
694 GroupIdActionBuilder groupIdBuilder = new GroupIdActionBuilder();
695 groupIdBuilder.setGroupId(groupAction.getGroupId());
696 actionBuilder.setType(Group.class);
697 actionBuilder.addAugmentation(GroupIdAction.class, groupIdBuilder.build());
698 return actionBuilder.build();
701 private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
702 EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
703 ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
706 actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
707 return actionBuilder.build();
710 private static Action SalToOFDecMplsTtl(ActionBuilder actionBuilder) {
712 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
713 return emtpyAction(actionBuilder);
716 private static Action SalToOFSetMplsTtl(
717 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
718 ActionBuilder actionBuilder) {
719 SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
720 SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
722 MplsTtlActionBuilder mplsTtlActionBuilder = new MplsTtlActionBuilder();
723 mplsTtlActionBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
725 actionBuilder.setType(SetMplsTtl.class);
726 actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtlActionBuilder.build());
727 return actionBuilder.build();
730 private static Action SalToOFCopyTTLIIn(ActionBuilder actionBuilder) {
732 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
733 return emtpyAction(actionBuilder);
736 private static Action SalToOFCopyTTLIOut(ActionBuilder actionBuilder) {
738 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
739 return emtpyAction(actionBuilder);
743 private static Action emtpyAction(ActionBuilder actionBuilder) {
744 return actionBuilder.build();
747 private static Action salToOFOutputAction(
748 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
749 ActionBuilder actionBuilder, short version) {
751 OutputActionCase outputActionCase = ((OutputActionCase) action);
752 OutputAction outputAction = outputActionCase.getOutputAction();
753 PortActionBuilder portAction = new PortActionBuilder();
754 MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
755 if (outputAction.getMaxLength() != null) {
756 maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
758 maxLenActionBuilder.setMaxLength(new Integer(0));
760 actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
762 Uri uri = outputAction.getOutputNodeConnector();
764 if (version >= OFConstants.OFP_VERSION_1_3) {
766 if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
767 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.CONTROLLER
769 } else if (uri.getValue().equals(OutputPortValues.ALL.toString())) {
770 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.ALL.getIntValue())));
771 } else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
772 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.ANY.getIntValue())));
774 } else if (uri.getValue().equals(OutputPortValues.FLOOD.toString())) {
775 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.FLOOD.getIntValue())));
777 } else if (uri.getValue().equals(OutputPortValues.INPORT.toString())) {
778 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.INPORT.getIntValue())));
780 } else if (uri.getValue().equals(OutputPortValues.LOCAL.toString())) {
781 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.LOCAL.getIntValue())));
783 } else if (uri.getValue().equals(OutputPortValues.NORMAL.toString())) {
784 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.NORMAL.getIntValue())));
786 } else if (uri.getValue().equals(OutputPortValues.TABLE.toString())) {
787 portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.TABLE.getIntValue())));
789 } else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
790 logger.error("Unknown Port Type for the Version");
791 } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector()
792 .getValue()) < MAXPortOF13) {
793 portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction
794 .getOutputNodeConnector().getValue())));
796 logger.error("Invalid Port for Output Action");
798 } else if (version == OFConstants.OFP_VERSION_1_0) {
800 if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
801 portAction.setPort(new PortNumber((long) PortNumberValuesV10.CONTROLLER.getIntValue()));
802 } else if (uri.getValue().equals(OutputPortValues.ALL.toString())) {
803 portAction.setPort(new PortNumber((long) PortNumberValuesV10.ALL.getIntValue()));
804 } else if (uri.getValue().equals(OutputPortValues.FLOOD.toString())) {
805 portAction.setPort(new PortNumber((long) PortNumberValuesV10.FLOOD.getIntValue()));
806 } else if (uri.getValue().equals(OutputPortValues.INPORT.toString())) {
807 portAction.setPort(new PortNumber((long) PortNumberValuesV10.INPORT.getIntValue()));
808 } else if (uri.getValue().equals(OutputPortValues.LOCAL.toString())) {
809 portAction.setPort(new PortNumber((long) PortNumberValuesV10.LOCAL.getIntValue()));
810 } else if (uri.getValue().equals(OutputPortValues.NORMAL.toString())) {
811 portAction.setPort(new PortNumber((long) PortNumberValuesV10.NORMAL.getIntValue()));
812 } else if (uri.getValue().equals(OutputPortValues.TABLE.toString())) {
813 portAction.setPort(new PortNumber((long) PortNumberValuesV10.TABLE.getIntValue()));
814 } else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
815 portAction.setPort(new PortNumber((long) PortNumberValuesV10.NONE.getIntValue()));
816 } else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
817 logger.error("Unknown Port Type for the Version");
818 } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector()
819 .getValue()) < MAXPortOF10) {
820 portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction
821 .getOutputNodeConnector().getValue())));
823 logger.error("Invalid Port for Output Action");
828 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
829 actionBuilder.addAugmentation(PortAction.class, portAction.build());
830 return actionBuilder.build();
835 * Method to convert OF actions associated with bucket to SAL Actions.
838 * @return List of converted SAL Actions.
840 public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
841 List<Action> actionList) {
843 List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
844 for (Action action : actionList) {
845 if (action.getType().equals(
846 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class))
847 bucketActions.add(ofToSALOutputAction(action));
848 else if (action.getType().equals(
849 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class))
850 bucketActions.add(ofToSALGroupAction(action));
851 else if (action.getType().equals(
852 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
853 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
854 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
855 } else if (action.getType().equals(
856 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
857 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
858 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
859 } else if (action.getType().equals(
860 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class))
861 bucketActions.add(ofToSALSetMplsTtl(action));
862 else if (action.getType().equals(
863 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
864 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
865 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
866 } else if (action.getType().equals(
867 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class))
868 bucketActions.add(ofToSALPushVlanAction(action));
869 else if (action.getType().equals(
870 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)) {
871 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
872 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
873 } else if (action.getType().equals(
874 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
875 PushMplsActionBuilder pushMpls = new PushMplsActionBuilder();
876 bucketActions.add(new PushMplsActionCaseBuilder().setPushMplsAction(pushMpls.build()).build());
877 } else if (action.getType().equals(
878 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
879 PopMplsActionBuilder popMpls = new PopMplsActionBuilder();
880 bucketActions.add(new PopMplsActionCaseBuilder().setPopMplsAction(popMpls.build()).build());
881 } else if (action.getType().equals(
882 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class))
883 bucketActions.add(ofToSALSetQueue(action));
885 else if (action.getType().equals(
886 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class))
887 bucketActions.add(ofToSALSetNwTtl(action));
888 else if (action.getType().equals(
889 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
890 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
891 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
892 } else if (action.getType().equals(
893 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class))
894 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.ofToSALSetField(action))
897 else if (action.getType().equals(
898 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class))
899 bucketActions.add(ofToSALPushPbbAction(action));
900 else if (action.getType().equals(
901 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
902 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
903 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
904 } else if (action.getType().equals(
905 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
906 // bucketActions.add(ofToSALExperimenter(action));
907 // TODO: Need to explore/discuss on how to handle experimenter
912 return bucketActions;
916 * Method converts OF Output action object to SAL Output action object.
919 * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
920 * action.rev130731.actions.actions.list.Action
921 * @return OutputAction
923 public static OutputActionCase ofToSALOutputAction(Action action) {
925 OutputActionBuilder outputAction = new OutputActionBuilder();
926 PortAction port = action.getAugmentation(PortAction.class);
928 outputAction.setOutputNodeConnector(new Uri(port.getPort().getValue().toString()));
930 logger.error("Provided action is not OF Output action, no associated port found!");
933 MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
934 if (length != null) {
935 outputAction.setMaxLength(length.getMaxLength());
937 logger.error("Provided action is not OF Output action, no associated length found!");
940 return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
944 * Method converts OF GroupAction object to SAL GroupAction object
947 * @return GroupAction
949 public static GroupActionCase ofToSALGroupAction(Action action) {
951 GroupActionBuilder groupAction = new GroupActionBuilder();
953 GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
954 groupAction.setGroupId(groupId.getGroupId());
956 return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
960 * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
966 public static SetMplsTtlActionCase ofToSALSetMplsTtl(Action action) {
968 SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
969 MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
970 mplsTtlAction.setMplsTtl(mplsTtl.getMplsTtl());
971 return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
975 * Method converts OF Pushvlan action to SAL PushVlan action.
978 * @return PushVlanAction
980 public static PushVlanActionCase ofToSALPushVlanAction(Action action) {
982 PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
984 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
985 pushVlanAction.setVlanId(new VlanId(etherType.getEthertype().getValue()));
987 return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
991 * Method converts OF SetQueue action to SAL SetQueue action.
994 * @return SetQueueAction
996 public static SetQueueActionCase ofToSALSetQueue(Action action) {
998 SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
1000 QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
1001 setQueueAction.setQueueId(queueId.getQueueId());
1003 return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
1007 * Method converts OF SetNwTtl action to SAL SetNwTtl action.
1010 * @return SetNwTtlAction
1012 public static SetNwTtlActionCase ofToSALSetNwTtl(Action action) {
1014 SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
1015 NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
1016 setNwTtl.setNwTtl(nwTtl.getNwTtl());
1018 return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
1022 * Method converts OF Pushvlan action to SAL PushVlan action.
1025 * @return PushVlanAction
1027 public static PushPbbActionCase ofToSALPushPbbAction(Action action) {
1029 PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
1031 EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
1032 pushPbbAction.setEthernetType(etherType.getEthertype().getValue());
1034 return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
1037 public static Object ofToSALExperimenter(Action action) {
1039 ExperimenterAction ExperimenterAction = action.getAugmentation(ExperimenterAction.class);
1043 * TODO: Need to explore/discuss about how to handle experimenter