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