Fix of port-number model
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / ActionConvertor.java
1 /**
2  * Copyright (c) 2014 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  *
8  * Contributor: hema.gopalkrishnan@ericsson.com
9  */
10 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
11
12 import com.google.common.collect.Ordering;
13
14 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
15 import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
16 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
17 import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
18 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
19 import org.opendaylight.openflowplugin.api.OFConstants;
20 import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
21 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
23 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
24 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
25 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
26 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
27 import org.opendaylight.openflowplugin.openflow.md.util.ActionUtil;
28 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
29 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
30 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
32 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCase;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupAction;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputAction;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanAction;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstAction;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcAction;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlAction;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosAction;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueAction;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstAction;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Code;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv4Type;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Code;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Icmpv6Type;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
172 import org.slf4j.Logger;
173 import org.slf4j.LoggerFactory;
174
175 import java.math.BigInteger;
176 import java.util.ArrayList;
177 import java.util.List;
178
179 /**
180  * @author usha@ericsson Action List:This class takes data from SAL layer and
181  *         converts into OF Data
182  * @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
183  *         actions
184  */
185 public final class ActionConvertor {
186     private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
187     private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
188     
189     private ActionConvertor() {
190         // NOOP
191     }
192
193     /**
194      * Translates SAL actions into OF Library actions
195      *
196      * @param actions    SAL actions
197      * @param version    Openflow protocol version used
198      * @param datapathid
199      * @param flow TODO
200      * @return OF Library actions
201      */
202     public static List<Action> getActions(
203             List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions,
204             short version, BigInteger datapathid, Flow flow) {
205         List<Action> actionsList = new ArrayList<>();
206         Action ofAction;
207
208         final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions = 
209                 Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build())
210             .sortedCopy(actions);
211
212         for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) {
213             ofAction = null;
214             ActionBuilder actionBuilder = new ActionBuilder();
215
216             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = sortedActions.get(
217                     actionItem).getAction();
218
219             if (action instanceof OutputActionCase) {
220                 ofAction = salToOFAction((OutputActionCase)action, actionBuilder, version);
221             } else if (action instanceof GroupActionCase) {
222                 ofAction = salToOFGroupAction(action, actionBuilder);
223             } else if (action instanceof CopyTtlOutCase) {
224                 ofAction = salToOFCopyTTLIOut(actionBuilder);
225             } else if (action instanceof CopyTtlInCase) {
226                 ofAction = salToOFCopyTTLIIn(actionBuilder);
227             } else if (action instanceof SetMplsTtlActionCase) {
228                 ofAction = salToOFSetMplsTtl(action, actionBuilder);
229             } else if (action instanceof DecMplsTtlCase) {
230                 ofAction = salToOFDecMplsTtl(actionBuilder);
231             } else if (action instanceof PushVlanActionCase) {
232                 ofAction = salToOFPushVlanAction(action, actionBuilder, version);
233             } else if (action instanceof PopVlanActionCase) {
234                 ofAction = (version == OFConstants.OFP_VERSION_1_0) ?
235                     salToOFStripVlan(actionBuilder, version)
236                         : salToOFPopVlan(actionBuilder);
237             } else if (action instanceof PushMplsActionCase) {
238                 ofAction = salToOFPushMplsAction(action, actionBuilder);
239             } else if (action instanceof PopMplsActionCase) {
240                 ofAction = salToOFPopMpls(action, actionBuilder);
241             } else if (action instanceof SetQueueActionCase) {
242                 ofAction = salToOFSetQueue(action, actionBuilder);
243             } else if (action instanceof SetNwTtlActionCase) {
244                 ofAction = salToOFSetNwTtl(action, actionBuilder);
245             } else if (action instanceof DecNwTtlCase) {
246                 ofAction = salToOFDecNwTtl(actionBuilder);
247             } else if (action instanceof SetFieldCase) {
248                 ofAction = salToOFSetField(action, actionBuilder, version, datapathid); 
249             } else if (action instanceof PushPbbActionCase) {
250                 ofAction = salToOFPushPbbAction(action, actionBuilder);
251             } else if (action instanceof PopPbbActionCase) {
252                 ofAction = salToOFPopPBB(actionBuilder);
253
254                 // 1.0 Actions
255             } else if (action instanceof SetVlanIdActionCase) {
256                 /*if (version == OFConstants.OFP_VERSION_1_0) {
257
258                 } else {
259                     List<Action> setVlanIdActionsList = convertToOF13(action, actionBuilder);
260                     actionsList.addAll(setVlanIdActionsList);
261                 }*/
262                 ofAction = salToOFSetVlanId(action, actionBuilder, version);
263             } else if (action instanceof SetVlanPcpActionCase) {
264                 ofAction = salToOFSetVlanpcp(action, actionBuilder, version);
265             } else if (action instanceof StripVlanActionCase) {
266                 ofAction = salToOFStripVlan(actionBuilder, version);
267             } else if (action instanceof SetDlSrcActionCase) {
268                 ofAction = salToOFSetDlSrc(action, actionBuilder, version);
269             } else if (action instanceof SetDlDstActionCase) {
270                 ofAction = salToOFSetDlDst(action, actionBuilder, version);
271             } else if (action instanceof SetNwSrcActionCase) {
272                 ofAction = salToOFSetNwSrc(action, actionBuilder, version);
273             } else if (action instanceof SetNwDstActionCase) {
274                 ofAction = salToOFSetNwDst(action, actionBuilder, version);
275             } else if (action instanceof SetTpSrcActionCase) {
276                 ofAction = salToOFSetTpSrc(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch().
277                         getIpMatch().getIpProtocol()));
278             } else if (action instanceof SetTpDstActionCase) {
279                 ofAction = salToOFSetTpDst(action, actionBuilder, version, IPProtocols.fromProtocolNum(flow.getMatch().
280                         getIpMatch().getIpProtocol()));
281             } else if (action instanceof SetNwTosActionCase) {
282                 ofAction = salToOFSetNwTos(action, actionBuilder, version);
283             } else if (action instanceof GeneralExtensionGrouping) {
284                 
285                 /**
286                  * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
287                  * - we might need sessionContext as converter input
288                  * 
289                  */
290                 
291                 GeneralExtensionGrouping extensionCaseGrouping = (GeneralExtensionGrouping) action;
292                 Extension extAction = extensionCaseGrouping.getExtension();
293                 ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionCaseGrouping.getExtensionKey(), version);
294                 ConvertorToOFJava<Action> convertor = 
295                         OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
296                 if (convertor != null) {
297                     ofAction = convertor.convert(extAction);
298                 }
299             } else {
300                 // try vendor codecs
301                 TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
302                         new TypeVersionKey<>(
303                                 (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) action.getImplementedInterface(),
304                                 version);
305                 ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor = 
306                         OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
307                 if (convertor != null) {
308                     ofAction = convertor.convert(action);
309                 }
310             }
311             
312             if (ofAction != null) {
313                 actionsList.add(ofAction);
314             }
315         }
316         return actionsList;
317     }
318
319     private static Action salToOFSetField(
320             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
321             ActionBuilder actionBuilder, short version, BigInteger datapathid) {
322
323         SetFieldCase setFieldCase = (SetFieldCase) action;
324         org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match match =
325             setFieldCase.getSetField();
326
327         if (version == OFConstants.OFP_VERSION_1_0) {
328             // pushvlan +setField can be called to configure 1.0 switches via MDSAL app
329             if (match.getVlanMatch() != null) {
330                 VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
331                 vlanidActionBuilder.setVlanVid(match.getVlanMatch().getVlanId().getVlanId().getValue());
332                 actionBuilder.setType(
333                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
334                 actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
335                 return actionBuilder.build();
336             } else {
337                 return emtpyAction(actionBuilder);
338             }
339
340         } else {
341             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
342             MatchReactor.getInstance().convert(match, version, oxmFieldsActionBuilder, datapathid);
343
344             actionBuilder.setType(
345                 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
346
347             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
348             return actionBuilder.build();
349         }
350
351     }
352
353     private static Action salToOFDecNwTtl(ActionBuilder actionBuilder) {
354         actionBuilder
355                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class);
356         return emtpyAction(actionBuilder);
357     }
358
359     private static Action salToOFPushMplsAction(
360             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
361             ActionBuilder actionBuilder) {
362         PushMplsActionCase pushMplsActionCase = (PushMplsActionCase) action;
363         actionBuilder.setType(PushMpls.class);
364
365         return salToOFPushAction(pushMplsActionCase.getPushMplsAction().getEthernetType(), actionBuilder);
366     }
367
368     private static Action salToOFPushPbbAction(
369             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
370             ActionBuilder actionBuilder) {
371         PushPbbActionCase pushPbbActionCase = (PushPbbActionCase) action;
372         actionBuilder.setType(PushPbb.class);
373
374         return salToOFPushAction(pushPbbActionCase.getPushPbbAction().getEthernetType(), actionBuilder);
375     }
376
377     private static Action salToOFPushVlanAction(
378             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
379             ActionBuilder actionBuilder, short version) {
380         if (version == OFConstants.OFP_VERSION_1_0) {
381             // if client configure openflow 1.0 switch as a openflow 1.3 switch using openflow 1.3 instructions
382             // then we can ignore PUSH_VLAN as set-vlan-id will push a vlan header if not present
383             return null;
384         }
385
386         PushVlanActionCase pushVlanActionCase = (PushVlanActionCase) action;
387         PushVlanAction pushVlanAction = pushVlanActionCase.getPushVlanAction();
388         actionBuilder.setType(PushVlan.class);
389
390         return salToOFPushAction(pushVlanAction.getEthernetType(), actionBuilder);
391     }
392
393     private static Action salToOFSetNwTtl(
394             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
395             ActionBuilder actionBuilder) {
396         SetNwTtlActionCase nwTtlActionCase = (SetNwTtlActionCase) action;
397         NwTtlActionBuilder nwTtlActionBuilder = new NwTtlActionBuilder();
398         nwTtlActionBuilder.setNwTtl(nwTtlActionCase.getSetNwTtlAction().getNwTtl());
399         actionBuilder.setType(SetNwTtl.class);
400         actionBuilder.addAugmentation(NwTtlAction.class, nwTtlActionBuilder.build());
401         return actionBuilder.build();
402     }
403
404     private static Action salToOFSetQueue(
405             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
406             ActionBuilder actionBuilder) {
407         SetQueueActionCase setQueueActionCase = (SetQueueActionCase) action;
408         SetQueueAction setQueueAction = setQueueActionCase.getSetQueueAction();
409
410         QueueIdActionBuilder queueIdActionBuilder = new QueueIdActionBuilder();
411         queueIdActionBuilder.setQueueId(setQueueAction.getQueueId());
412         actionBuilder.setType(SetQueue.class);
413         actionBuilder.addAugmentation(QueueIdAction.class, queueIdActionBuilder.build());
414
415         return actionBuilder.build();
416     }
417
418     private static Action salToOFPopMpls(
419             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
420             ActionBuilder actionBuilder) {
421         PopMplsActionCase popMplsActionCase = (PopMplsActionCase) action;
422         actionBuilder.setType(PopMpls.class);
423
424         return salToOFPushAction(popMplsActionCase.getPopMplsAction().getEthernetType(), actionBuilder);
425     }
426
427     private static Action salToOFPopVlan(ActionBuilder actionBuilder) {
428         actionBuilder.setType(PopVlan.class);
429         return emtpyAction(actionBuilder);
430     }
431
432     private static Action salToOFPopPBB(ActionBuilder actionBuilder) {
433         actionBuilder.setType(PopPbb.class);
434         return emtpyAction(actionBuilder);
435     }
436
437     // set-vlan-id (1.0 feature) can be called on  1.3 switches as well using ADSAL apis
438     private static Action salToOFSetVlanId(
439             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
440             ActionBuilder actionBuilder, short version) {
441
442         SetVlanIdActionCase setvlanidcase = (SetVlanIdActionCase) action;
443         SetVlanIdAction setvlanidaction = setvlanidcase.getSetVlanIdAction();
444
445         if (version == OFConstants.OFP_VERSION_1_0) {
446
447             VlanVidActionBuilder vlanidActionBuilder = new VlanVidActionBuilder();
448             vlanidActionBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
449             actionBuilder
450                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanVid.class);
451             actionBuilder.addAugmentation(VlanVidAction.class, vlanidActionBuilder.build());
452             return actionBuilder.build();
453
454         } else if (version >= OFConstants.OFP_VERSION_1_3) {
455             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
456             actionBuilder
457                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
458             List<MatchEntries> matchEntriesList = new ArrayList<>();
459             MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
460             matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
461             matchEntriesBuilder.setOxmMatchField(VlanVid.class);
462             VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
463             vlanVidBuilder.setCfiBit(true);
464             vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
465             matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
466             matchEntriesBuilder.setHasMask(false);
467             matchEntriesList.add(matchEntriesBuilder.build());
468             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
469             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
470             return actionBuilder.build();
471         } else {
472             LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
473             return null;
474         }
475     }
476
477     private static Action salToOFSetVlanpcp(
478             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
479             ActionBuilder actionBuilder, short version) {
480
481         SetVlanPcpActionCase setvlanpcpcase = (SetVlanPcpActionCase) action;
482         SetVlanPcpAction setvlanpcpaction = setvlanpcpcase.getSetVlanPcpAction();
483
484         if (version == OFConstants.OFP_VERSION_1_0) {
485             VlanPcpActionBuilder vlanpcpActionBuilder = new VlanPcpActionBuilder();
486             vlanpcpActionBuilder.setVlanPcp(setvlanpcpaction.getVlanPcp().getValue());
487             actionBuilder
488                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetVlanPcp.class);
489             actionBuilder.addAugmentation(VlanPcpAction.class, vlanpcpActionBuilder.build());
490             return actionBuilder.build();
491         } else if (version >= OFConstants.OFP_VERSION_1_3) {
492             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
493             actionBuilder
494                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
495             List<MatchEntries> matchEntriesList = new ArrayList<>();
496             matchEntriesList.add(MatchConvertorImpl.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
497             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
498             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
499             return actionBuilder.build();
500         } else {
501             LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
502             return null;
503         }
504     }
505
506     private static Action salToOFStripVlan(ActionBuilder actionBuilder, short version) {
507         if (version == OFConstants.OFP_VERSION_1_0) {
508             actionBuilder
509                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class);
510
511             return emtpyAction(actionBuilder);
512         } else if (version >= OFConstants.OFP_VERSION_1_3) {
513             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
514             actionBuilder
515                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
516             List<MatchEntries> matchEntriesList = new ArrayList<>();
517             MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
518             matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
519             matchEntriesBuilder.setOxmMatchField(VlanVid.class);
520             VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
521             vlanVidBuilder.setCfiBit(true);
522             vlanVidBuilder.setVlanVid(0x0000);
523             matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
524             matchEntriesBuilder.setHasMask(false);
525             matchEntriesList.add(matchEntriesBuilder.build());
526             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
527             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
528             return actionBuilder.build();
529         } else {
530             LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
531             return null;
532         }
533     }
534
535     private static Action salToOFSetDlSrc(
536             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
537             ActionBuilder actionBuilder, short version) {
538
539         SetDlSrcActionCase setdlsrccase = (SetDlSrcActionCase) action;
540         SetDlSrcAction setdlsrcaction = setdlsrccase.getSetDlSrcAction();
541
542         if (version == OFConstants.OFP_VERSION_1_0) {
543             DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
544             dladdressactionbuilder.setDlAddress(setdlsrcaction.getAddress());
545             actionBuilder
546                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc.class);
547             actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
548             return actionBuilder.build();
549         } else if (version >= OFConstants.OFP_VERSION_1_3) {
550             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
551             actionBuilder
552                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
553             List<MatchEntries> matchEntriesList = new ArrayList<>();
554             matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthSrc.class, setdlsrcaction.getAddress(), null));
555             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
556             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
557             return actionBuilder.build();
558         } else {
559             LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
560             return null;
561         }
562     }
563
564     private static Action salToOFSetDlDst(
565             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
566             ActionBuilder actionBuilder, short version) {
567
568         SetDlDstActionCase setdldstcase = (SetDlDstActionCase) action;
569         SetDlDstAction setdldstaction = setdldstcase.getSetDlDstAction();
570
571         if (version == OFConstants.OFP_VERSION_1_0) {
572             DlAddressActionBuilder dladdressactionbuilder = new DlAddressActionBuilder();
573             dladdressactionbuilder.setDlAddress(setdldstaction.getAddress());
574             actionBuilder
575                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst.class);
576             actionBuilder.addAugmentation(DlAddressAction.class, dladdressactionbuilder.build());
577             return actionBuilder.build();
578         } else if (version >= OFConstants.OFP_VERSION_1_3) {
579             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
580             actionBuilder
581                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
582             List<MatchEntries> matchEntriesList = new ArrayList<>();
583             matchEntriesList.add(MatchConvertorImpl.toOfMacAddress(EthDst.class, setdldstaction.getAddress(), null));
584             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
585             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
586             return actionBuilder.build();
587         } else {
588             LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
589             return null;
590         }
591     }
592
593     protected static Action salToOFSetNwSrc(
594             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
595             ActionBuilder actionBuilder, short version) {
596
597         try {
598             ActionSetNwSrcReactor.getInstance().convert((SetNwSrcActionCase) action, version, actionBuilder, null);
599         } catch (Exception e) {
600             LOG.error(e.getMessage(), e);
601             return null;
602         }
603
604         return actionBuilder.build();
605     }
606
607     protected static Action salToOFSetNwDst(
608             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
609             ActionBuilder actionBuilder, short version) {
610
611         try {
612             ActionSetNwDstReactor.getInstance().convert((SetNwDstActionCase) action, version, actionBuilder, null);
613         } catch (Exception e) {
614             LOG.error(e.getMessage(), e);
615             return null;
616         }
617
618         return actionBuilder.build();
619     }
620
621     private static Action salToOFSetNwTos(
622             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
623             ActionBuilder actionBuilder, short version) {
624
625         SetNwTosActionCase setnwtoscase = (SetNwTosActionCase) action;
626         SetNwTosAction setnwtosaction = setnwtoscase.getSetNwTosAction();
627
628         if (version == OFConstants.OFP_VERSION_1_0) {
629             NwTosActionBuilder tosBuilder = new NwTosActionBuilder();
630             tosBuilder.setNwTos(setnwtosaction.getTos().shortValue());
631             actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build());
632             actionBuilder
633                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTos.class);
634
635             return actionBuilder.build();
636         } else if (version >= OFConstants.OFP_VERSION_1_3) {
637             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
638             actionBuilder
639                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
640             List<MatchEntries> matchEntriesList = new ArrayList<>();
641             matchEntriesList.add(MatchConvertorImpl.toOfIpDscp(new Dscp(
642                     ActionUtil.tosToDscp(setnwtosaction.getTos().shortValue())
643                     )));
644             oxmFieldsActionBuilder.setMatchEntries(matchEntriesList);
645             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
646             return actionBuilder.build();
647         } else {
648             LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
649             return null;
650         }
651
652     }
653
654     private static Action salToOFSetTpSrc(
655             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
656             ActionBuilder actionBuilder, short version, IPProtocols protocol) {
657
658         if (version == OFConstants.OFP_VERSION_1_0) {
659             SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
660             SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
661
662             PortActionBuilder settpsrc = new PortActionBuilder();
663             PortNumber port = new PortNumber(settpsrcaction.getPort().getValue().longValue());
664             settpsrc.setPort(port);
665
666             actionBuilder
667                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc.class);
668             actionBuilder.addAugmentation(PortAction.class, settpsrc.build());
669             return actionBuilder.build();
670         } else if (version == OFConstants.OFP_VERSION_1_3) {
671             SetTpSrcActionCase settpsrccase = (SetTpSrcActionCase) action;
672             SetTpSrcAction settpsrcaction = settpsrccase.getSetTpSrcAction();
673             
674             MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
675             matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
676             matchEntriesBuilder.setHasMask(false);
677             PortMatchEntryBuilder portMatchEntryBuilder = new PortMatchEntryBuilder();
678             int port = settpsrcaction.getPort().getValue().intValue();
679             int type = 0x0f & port;
680             
681             switch(protocol) {
682             case ICMP: 
683                 matchEntriesBuilder.setOxmMatchField(Icmpv4Type.class);
684                 Icmpv4TypeMatchEntryBuilder icmpv4TypeMatchEntryBuilder = new Icmpv4TypeMatchEntryBuilder();
685                 icmpv4TypeMatchEntryBuilder.setIcmpv4Type((short) type);
686                 matchEntriesBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeMatchEntryBuilder.build());
687                 break;
688             case ICMPV6: 
689                 matchEntriesBuilder.setOxmMatchField(Icmpv6Type.class);
690                 Icmpv6TypeMatchEntryBuilder icmpv6TypeMatchEntryBuilder = new Icmpv6TypeMatchEntryBuilder();
691                 icmpv6TypeMatchEntryBuilder.setIcmpv6Type((short) type);
692                 matchEntriesBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeMatchEntryBuilder.build());
693                 break;
694             case TCP: 
695                 matchEntriesBuilder.setOxmMatchField(TcpSrc.class);
696                 portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
697                 matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
698                 break;
699             case UDP: 
700                 matchEntriesBuilder.setOxmMatchField(UdpSrc.class);
701                 portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
702                 matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
703                 break;
704             default: LOG.warn("Unknown protocol with combination of SetSourcePort: {}", protocol);
705                 break;
706             }
707             
708             actionBuilder
709             .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
710             
711             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
712             List<MatchEntries> matchEntries = new ArrayList<MatchEntries>();
713             matchEntries.add(matchEntriesBuilder.build());
714             oxmFieldsActionBuilder.setMatchEntries(matchEntries);
715
716             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
717             return actionBuilder.build();
718         }
719         LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
720         return null;
721     }
722
723     private static Action salToOFSetTpDst(
724             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
725             ActionBuilder actionBuilder, short version, IPProtocols protocol) {
726
727         if (version == OFConstants.OFP_VERSION_1_0) {
728             SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
729             SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
730             PortActionBuilder settpdst = new PortActionBuilder();
731             PortNumber port = new PortNumber(settpdstaction.getPort().getValue().longValue());
732             settpdst.setPort(port);
733
734             actionBuilder
735                     .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst.class);
736             actionBuilder.addAugmentation(PortAction.class, settpdst.build());
737             return actionBuilder.build();
738         } else if (version == OFConstants.OFP_VERSION_1_3) {
739             SetTpDstActionCase settpdstcase = (SetTpDstActionCase) action;
740             SetTpDstAction settpdstaction = settpdstcase.getSetTpDstAction();
741             
742             MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
743             matchEntriesBuilder.setOxmClass(OpenflowBasicClass.class);
744             matchEntriesBuilder.setHasMask(false);
745             PortMatchEntryBuilder portMatchEntryBuilder = new PortMatchEntryBuilder();
746             int port = settpdstaction.getPort().getValue().intValue();
747             int code = 0x0f & port;
748             
749             switch(protocol) {
750             case ICMP: 
751                 matchEntriesBuilder.setOxmMatchField(Icmpv4Code.class);
752                 Icmpv4CodeMatchEntryBuilder icmpv4CodeMatchEntryBuilder = new Icmpv4CodeMatchEntryBuilder();
753                 icmpv4CodeMatchEntryBuilder.setIcmpv4Code((short) code);
754                 matchEntriesBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeMatchEntryBuilder.build());
755                 break;
756             case ICMPV6: 
757                 matchEntriesBuilder.setOxmMatchField(Icmpv6Code.class);
758                 Icmpv6CodeMatchEntryBuilder icmpv6CodeMatchEntryBuilder = new Icmpv6CodeMatchEntryBuilder();
759                 icmpv6CodeMatchEntryBuilder.setIcmpv6Code((short) code);
760                 matchEntriesBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeMatchEntryBuilder.build());
761                 break;
762             case TCP: 
763                 matchEntriesBuilder.setOxmMatchField(TcpDst.class);
764                 portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
765                 matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
766                 break;
767             case UDP: 
768                 matchEntriesBuilder.setOxmMatchField(UdpDst.class);
769                 portMatchEntryBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber(port));
770                 matchEntriesBuilder.addAugmentation(PortMatchEntry.class, portMatchEntryBuilder.build());
771                 break;
772             default: LOG.warn("Unknown protocol with combination of SetDestinationPort: {}", protocol);
773                 break;
774             }
775             
776             actionBuilder
777             .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class);
778             
779             OxmFieldsActionBuilder oxmFieldsActionBuilder = new OxmFieldsActionBuilder();
780             List<MatchEntries> matchEntries = new ArrayList<MatchEntries>();
781             matchEntries.add(matchEntriesBuilder.build());
782             oxmFieldsActionBuilder.setMatchEntries(matchEntries);
783
784             actionBuilder.addAugmentation(OxmFieldsAction.class, oxmFieldsActionBuilder.build());
785             return actionBuilder.build();
786         }
787         LOG.error(UNKNOWN_ACTION_TYPE_VERSION, version);
788         return null;
789     }
790
791     private static Action salToOFGroupAction(
792             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
793             ActionBuilder actionBuilder) {
794
795         GroupActionCase groupActionCase = (GroupActionCase) action;
796         GroupAction groupAction = groupActionCase.getGroupAction();
797
798         GroupIdActionBuilder groupIdBuilder = new GroupIdActionBuilder();
799         groupIdBuilder.setGroupId(groupAction.getGroupId());
800         actionBuilder.setType(Group.class);
801         actionBuilder.addAugmentation(GroupIdAction.class, groupIdBuilder.build());
802         return actionBuilder.build();
803     }
804
805     private static Action salToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
806         EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
807         if (ethernetType != null) {
808             ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
809         }
810
811         /* OF */
812         actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
813         return actionBuilder.build();
814     }
815
816     private static Action salToOFDecMplsTtl(ActionBuilder actionBuilder) {
817         actionBuilder
818                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class);
819         return emtpyAction(actionBuilder);
820     }
821
822     private static Action salToOFSetMplsTtl(
823             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
824             ActionBuilder actionBuilder) {
825         SetMplsTtlActionCase mplsTtlActionCase = (SetMplsTtlActionCase) action;
826         SetMplsTtlAction mplsTtlAction = mplsTtlActionCase.getSetMplsTtlAction();
827
828         MplsTtlActionBuilder mplsTtlActionBuilder = new MplsTtlActionBuilder();
829         mplsTtlActionBuilder.setMplsTtl(mplsTtlAction.getMplsTtl()/* SAL */);
830         /* OF */
831         actionBuilder.setType(SetMplsTtl.class);
832         actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtlActionBuilder.build());
833         return actionBuilder.build();
834     }
835
836     private static Action salToOFCopyTTLIIn(ActionBuilder actionBuilder) {
837         actionBuilder
838                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class);
839         return emtpyAction(actionBuilder);
840     }
841
842     private static Action salToOFCopyTTLIOut(ActionBuilder actionBuilder) {
843         actionBuilder
844                 .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class);
845         return emtpyAction(actionBuilder);
846
847     }
848
849     private static Action emtpyAction(ActionBuilder actionBuilder) {
850         return actionBuilder.build();
851     }
852
853     private static Action salToOFAction(
854             OutputActionCase outputActionCase,
855             ActionBuilder actionBuilder, short version) {
856
857         OutputAction outputAction = outputActionCase.getOutputAction();
858         PortActionBuilder portAction = new PortActionBuilder();
859         MaxLengthActionBuilder maxLenActionBuilder = new MaxLengthActionBuilder();
860         if (outputAction.getMaxLength() != null) {
861             maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
862         } else {
863             maxLenActionBuilder.setMaxLength(0);
864         }
865         actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
866
867         Uri uri = outputAction.getOutputNodeConnector();
868
869         OpenflowVersion ofVersion = OpenflowVersion.get(version);
870         Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
871         if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
872             portAction.setPort(new PortNumber(portNumber));
873         } else {
874             LOG.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
875         }
876
877         actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
878         actionBuilder.addAugmentation(PortAction.class, portAction.build());
879         return actionBuilder.build();
880
881     }
882
883     /**
884      * Method to convert OF actions associated with bucket to SAL Actions.
885      *
886      * @param actionList
887      * @param ofVersion  current ofp version
888      * @param actionPath TODO
889      * @return List of converted SAL Actions.
890      */
891     public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
892             List<Action> actionList, OpenflowVersion ofVersion, ActionPath actionPath) {
893
894         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
895         for (Action action : actionList) {
896             if (action.getType().equals(
897                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
898                 bucketActions.add(ofToSALOutputAction(ofVersion, action));
899
900             } else if (action.getType().equals(
901                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
902                 bucketActions.add(ofToSALGroupAction(action));
903
904             } else if (action.getType().equals(
905                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut.class)) {
906                 CopyTtlOutBuilder copyTtlOutaction = new CopyTtlOutBuilder();
907                 bucketActions.add(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyTtlOutaction.build()).build());
908
909             } else if (action.getType().equals(
910                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn.class)) {
911                 CopyTtlInBuilder copyTtlInaction = new CopyTtlInBuilder();
912                 bucketActions.add(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInaction.build()).build());
913
914             } else if (action.getType().equals(
915                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl.class)) {
916                 bucketActions.add(ofToSALSetMplsTtl(action));
917
918             } else if (action.getType().equals(
919                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl.class)) {
920                 DecMplsTtlBuilder decMplsTtl = new DecMplsTtlBuilder();
921                 bucketActions.add(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtl.build()).build());
922
923             } else if (action.getType().equals(
924                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan.class)) {
925                 bucketActions.add(ofToSALPushVlanAction(action));
926
927             } else if (action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan.class)
928                     || action.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan.class)) {
929                 // OF1.0 nodes will emit StripVlan and OF1.3+ will emit StripVlan/PopVlan, convert both to PopVlan for SAL
930                 PopVlanActionBuilder popVlan = new PopVlanActionBuilder();
931                 bucketActions.add(new PopVlanActionCaseBuilder().setPopVlanAction(popVlan.build()).build());
932
933             } else if (action.getType().equals(
934                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) {
935                 bucketActions.add(ofToSALPushMplsAction(action));
936
937             } else if (action.getType().equals(
938                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) {
939                 bucketActions.add(ofToSALPopMplsAction(action));
940
941             } else if (action.getType().equals(
942                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) {
943                 bucketActions.add(ofToSALSetQueue(action));
944
945             } else if (action.getType().equals(
946                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl.class)) {
947                 bucketActions.add(ofToSALSetNwTtl(action));
948
949             } else if (action.getType().equals(
950                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl.class)) {
951                 DecNwTtlBuilder decNwTtl = new DecNwTtlBuilder();
952                 bucketActions.add(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl.build()).build());
953
954             } else if (action.getType().equals(
955                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
956                 bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
957                         .build());
958             } else if (action.getType().equals(
959                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
960                 bucketActions.add(ofToSALPushPbbAction(action));
961
962             } else if (action.getType().equals(
963                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb.class)) {
964                 PopPbbActionBuilder popPbb = new PopPbbActionBuilder();
965                 bucketActions.add(new PopPbbActionCaseBuilder().setPopPbbAction(popPbb.build()).build());
966
967             } else if (action.getType().equals(
968                     org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
969                 /**
970                  * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
971                  * - we might also need a way on how to identify exact type of augmentation to be 
972                  *   used as match can be bound to multiple models
973                  */
974                 org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction = 
975                         ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
976                 if (processedAction != null) {
977                     bucketActions.add(processedAction);
978                 }
979             }
980         }
981         return bucketActions;
982     }
983
984     /**
985      * Method converts OF Output action object to SAL Output action object.
986      *
987      * @param ofVersion
988      * @param ofVersion
989      * @param action    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
990      *                  action.rev130731.actions.actions.list.Action
991      * @return OutputAction
992      */
993     public static OutputActionCase ofToSALOutputAction(OpenflowVersion ofVersion, Action action) {
994         OutputActionBuilder outputAction = new OutputActionBuilder();
995         PortAction port = action.getAugmentation(PortAction.class);
996         if (port != null) {
997             PortNumberUni protocolAgnosticPort = 
998                     OpenflowPortsUtil.getProtocolAgnosticPort(
999                     ofVersion, port.getPort().getValue());
1000             String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
1001             outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
1002         } else {
1003             LOG.error("Provided action is not OF Output action, no associated port found!");
1004         }
1005
1006         MaxLengthAction length = action.getAugmentation(MaxLengthAction.class);
1007         if (length != null) {
1008             outputAction.setMaxLength(length.getMaxLength());
1009         } else {
1010             LOG.error("Provided action is not OF Output action, no associated length found!");
1011         }
1012
1013         return new OutputActionCaseBuilder().setOutputAction(outputAction.build()).build();
1014     }
1015
1016     /**
1017      * Method converts OF GroupAction object to SAL GroupAction object
1018      *
1019      * @param action
1020      * @return GroupAction
1021      */
1022     public static GroupActionCase ofToSALGroupAction(Action action) {
1023
1024         GroupActionBuilder groupAction = new GroupActionBuilder();
1025
1026         GroupIdAction groupId = action.getAugmentation(GroupIdAction.class);
1027         groupAction.setGroupId(groupId.getGroupId());
1028
1029         return new GroupActionCaseBuilder().setGroupAction(groupAction.build()).build();
1030     }
1031
1032     /**
1033      * Method converts OF SetMplsTTL action object to SAL SetMplsTTL action
1034      * object.
1035      *
1036      * @param action
1037      * @return
1038      */
1039     public static SetMplsTtlActionCase ofToSALSetMplsTtl(Action action) {
1040
1041         SetMplsTtlActionBuilder mplsTtlAction = new SetMplsTtlActionBuilder();
1042         MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class);
1043         mplsTtlAction.setMplsTtl(mplsTtl.getMplsTtl());
1044         return new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(mplsTtlAction.build()).build();
1045     }
1046
1047     /**
1048      * Method converts OF Pushvlan action to SAL PushVlan action.
1049      *
1050      * @param action
1051      * @return PushVlanAction
1052      */
1053     public static PushVlanActionCase ofToSALPushVlanAction(Action action) {
1054
1055         PushVlanActionBuilder pushVlanAction = new PushVlanActionBuilder();
1056
1057         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
1058         pushVlanAction.setEthernetType(etherType.getEthertype().getValue());
1059
1060         return new PushVlanActionCaseBuilder().setPushVlanAction(pushVlanAction.build()).build();
1061     }
1062
1063     /**
1064      * Method converts OF PushMpls action to SAL PushMpls action.
1065      *
1066      * @param action
1067      * @return PushMplsAction
1068      */
1069     public static PushMplsActionCase ofToSALPushMplsAction(Action action) {
1070
1071         PushMplsActionBuilder pushMplsAction = new PushMplsActionBuilder();
1072
1073         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
1074         pushMplsAction.setEthernetType(etherType.getEthertype().getValue());
1075
1076         return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build();
1077     }
1078
1079     /**
1080      * Method converts OF PopMpls action to SAL PopMpls action.
1081      *
1082      * @param action
1083      * @return PopMplsActionCase
1084      */
1085     public static PopMplsActionCase ofToSALPopMplsAction(Action action) {
1086
1087         PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder();
1088
1089         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
1090         popMplsAction.setEthernetType(etherType.getEthertype().getValue());
1091
1092         return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build();
1093     }
1094
1095     /**
1096      * Method converts OF SetQueue action to SAL SetQueue action.
1097      *
1098      * @param action
1099      * @return SetQueueAction
1100      */
1101     public static SetQueueActionCase ofToSALSetQueue(Action action) {
1102
1103         SetQueueActionBuilder setQueueAction = new SetQueueActionBuilder();
1104
1105         QueueIdAction queueId = action.getAugmentation(QueueIdAction.class);
1106         setQueueAction.setQueueId(queueId.getQueueId());
1107         return new SetQueueActionCaseBuilder().setSetQueueAction(setQueueAction.build()).build();
1108     }
1109
1110     /**
1111      * Method converts OF SetNwTtl action to SAL SetNwTtl action.
1112      *
1113      * @param action
1114      * @return SetNwTtlAction
1115      */
1116     public static SetNwTtlActionCase ofToSALSetNwTtl(Action action) {
1117
1118         SetNwTtlActionBuilder setNwTtl = new SetNwTtlActionBuilder();
1119         NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class);
1120         setNwTtl.setNwTtl(nwTtl.getNwTtl());
1121
1122         return new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtl.build()).build();
1123     }
1124
1125     /**
1126      * Method converts OF Pushvlan action to SAL PushVlan action.
1127      *
1128      * @param action
1129      * @return PushVlanAction
1130      */
1131     public static PushPbbActionCase ofToSALPushPbbAction(Action action) {
1132
1133         PushPbbActionBuilder pushPbbAction = new PushPbbActionBuilder();
1134
1135         EthertypeAction etherType = action.getAugmentation(EthertypeAction.class);
1136         pushPbbAction.setEthernetType(etherType.getEthertype().getValue());
1137
1138         return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
1139     }
1140
1141     //TODO make a model in YANG for protocols 
1142     /*private enum IPProtocols {
1143         ICMP(1), 
1144         TCP(6), 
1145         UDP(17), 
1146         ICMPV6(58);
1147
1148         private int protocol;
1149         
1150         private static Map<Integer, IPProtocols> valueMap;
1151         static {
1152             valueMap = new HashMap<>();
1153             for(IPProtocols protocols : IPProtocols.values()) {
1154                 valueMap.put(protocols.protocol, protocols);
1155             }
1156         }
1157         
1158         private IPProtocols(int value) {
1159             this.protocol = value;
1160         }
1161
1162         private byte getValue() {
1163             return (byte) this.protocol;
1164         }
1165         
1166         private Short getShortValue() {
1167             return new Short((short) protocol);
1168         }
1169         
1170         private IPProtocols fromProtocolNum(Short protocolNum) {
1171             return valueMap.get(protocolNum);
1172         }
1173     }    */
1174     
1175 }