blob: 316e9d24c9fbc12a66d6f635ef7a3930814d2531 [file] [log] [blame]
Ray Milkeyd43fe452015-05-29 09:35:12 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Ray Milkeyd43fe452015-05-29 09:35:12 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.codec.impl;
17
Jian Lidab72562016-04-12 14:10:32 -070018import com.fasterxml.jackson.databind.JsonNode;
Jian Li1ef82db2016-03-03 14:43:21 -080019import com.fasterxml.jackson.databind.node.ObjectNode;
Jian Lidab72562016-04-12 14:10:32 -070020import org.onlab.osgi.DefaultServiceDirectory;
21import org.onlab.osgi.ServiceDirectory;
Ray Milkeyd43fe452015-05-29 09:35:12 -070022import org.onlab.packet.IpAddress;
23import org.onlab.packet.MacAddress;
24import org.onlab.packet.MplsLabel;
Hyunsun Moonfab29502015-08-25 13:39:16 -070025import org.onlab.packet.TpPort;
Ray Milkeyd43fe452015-05-29 09:35:12 -070026import org.onlab.packet.VlanId;
Yafit Hadar5796d972015-10-15 13:16:11 +030027import org.onlab.util.HexString;
Jonathan Harte3bcfc32016-08-16 17:12:49 -070028import org.onosproject.codec.CodecContext;
Jian Lidab72562016-04-12 14:10:32 -070029import org.onosproject.codec.ExtensionTreatmentCodec;
Jian Lice8c5602016-03-03 21:43:24 -080030import org.onosproject.core.DefaultGroupId;
31import org.onosproject.core.GroupId;
Ray Milkeyd43fe452015-05-29 09:35:12 -070032import org.onosproject.net.ChannelSpacing;
Jian Lidab72562016-04-12 14:10:32 -070033import org.onosproject.net.Device;
34import org.onosproject.net.DeviceId;
Ray Milkeyd43fe452015-05-29 09:35:12 -070035import org.onosproject.net.GridType;
Ray Milkeyd43fe452015-05-29 09:35:12 -070036import org.onosproject.net.OchSignal;
Yafit Hadar5796d972015-10-15 13:16:11 +030037import org.onosproject.net.OduSignalId;
Ray Milkeyd43fe452015-05-29 09:35:12 -070038import org.onosproject.net.PortNumber;
Jian Lidab72562016-04-12 14:10:32 -070039import org.onosproject.net.device.DeviceService;
40import org.onosproject.net.flow.instructions.ExtensionTreatment;
Ray Milkeyd43fe452015-05-29 09:35:12 -070041import org.onosproject.net.flow.instructions.Instruction;
42import org.onosproject.net.flow.instructions.Instructions;
43import org.onosproject.net.flow.instructions.L0ModificationInstruction;
Yafit Hadar5796d972015-10-15 13:16:11 +030044import org.onosproject.net.flow.instructions.L1ModificationInstruction;
Ray Milkeyd43fe452015-05-29 09:35:12 -070045import org.onosproject.net.flow.instructions.L2ModificationInstruction;
46import org.onosproject.net.flow.instructions.L3ModificationInstruction;
Hyunsun Moonfab29502015-08-25 13:39:16 -070047import org.onosproject.net.flow.instructions.L4ModificationInstruction;
Jian Li47b26232016-03-07 09:59:59 -080048import org.onosproject.net.meter.MeterId;
Jian Lidab72562016-04-12 14:10:32 -070049import org.slf4j.Logger;
Ray Milkeyd43fe452015-05-29 09:35:12 -070050
Jian Li1ef82db2016-03-03 14:43:21 -080051import static org.onlab.util.Tools.nullIsIllegal;
Jian Lidab72562016-04-12 14:10:32 -070052import static org.slf4j.LoggerFactory.getLogger;
Ray Milkeyd43fe452015-05-29 09:35:12 -070053
54/**
55 * Decoding portion of the instruction codec.
56 */
Ray Milkey6d7968e2015-07-06 14:30:02 -070057public final class DecodeInstructionCodecHelper {
Jian Lidab72562016-04-12 14:10:32 -070058 protected static final Logger log = getLogger(DecodeInstructionCodecHelper.class);
Ray Milkeyd43fe452015-05-29 09:35:12 -070059 private final ObjectNode json;
Jonathan Harte3bcfc32016-08-16 17:12:49 -070060 private final CodecContext context;
Ray Milkeyd43fe452015-05-29 09:35:12 -070061
62 /**
63 * Creates a decode instruction codec object.
64 *
65 * @param json JSON object to decode
66 */
Jonathan Harte3bcfc32016-08-16 17:12:49 -070067 public DecodeInstructionCodecHelper(ObjectNode json, CodecContext context) {
Ray Milkeyd43fe452015-05-29 09:35:12 -070068 this.json = json;
Jonathan Harte3bcfc32016-08-16 17:12:49 -070069 this.context = context;
Ray Milkeyd43fe452015-05-29 09:35:12 -070070 }
71
72 /**
73 * Decodes a Layer 2 instruction.
74 *
75 * @return instruction object decoded from the JSON
76 * @throws IllegalArgumentException if the JSON is invalid
77 */
78 private Instruction decodeL2() {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +053079 String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE),
80 InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText();
Ray Milkeyd43fe452015-05-29 09:35:12 -070081
82 if (subType.equals(L2ModificationInstruction.L2SubType.ETH_SRC.name())) {
83 String mac = nullIsIllegal(json.get(InstructionCodec.MAC),
84 InstructionCodec.MAC + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
85 return Instructions.modL2Src(MacAddress.valueOf(mac));
86 } else if (subType.equals(L2ModificationInstruction.L2SubType.ETH_DST.name())) {
87 String mac = nullIsIllegal(json.get(InstructionCodec.MAC),
88 InstructionCodec.MAC + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
89 return Instructions.modL2Dst(MacAddress.valueOf(mac));
90 } else if (subType.equals(L2ModificationInstruction.L2SubType.VLAN_ID.name())) {
91 short vlanId = (short) nullIsIllegal(json.get(InstructionCodec.VLAN_ID),
92 InstructionCodec.VLAN_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
93 return Instructions.modVlanId(VlanId.vlanId(vlanId));
94 } else if (subType.equals(L2ModificationInstruction.L2SubType.VLAN_PCP.name())) {
95 byte vlanPcp = (byte) nullIsIllegal(json.get(InstructionCodec.VLAN_PCP),
96 InstructionCodec.VLAN_PCP + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
97 return Instructions.modVlanPcp(vlanPcp);
98 } else if (subType.equals(L2ModificationInstruction.L2SubType.MPLS_LABEL.name())) {
99 int label = nullIsIllegal(json.get(InstructionCodec.MPLS_LABEL),
100 InstructionCodec.MPLS_LABEL + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
101 return Instructions.modMplsLabel(MplsLabel.mplsLabel(label));
102 } else if (subType.equals(L2ModificationInstruction.L2SubType.MPLS_PUSH.name())) {
103 return Instructions.pushMpls();
104 } else if (subType.equals(L2ModificationInstruction.L2SubType.MPLS_POP.name())) {
105 return Instructions.popMpls();
106 } else if (subType.equals(L2ModificationInstruction.L2SubType.DEC_MPLS_TTL.name())) {
107 return Instructions.decMplsTtl();
108 } else if (subType.equals(L2ModificationInstruction.L2SubType.VLAN_POP.name())) {
109 return Instructions.popVlan();
110 } else if (subType.equals(L2ModificationInstruction.L2SubType.VLAN_PUSH.name())) {
111 return Instructions.pushVlan();
Hyunsun Moon7080a0d2015-08-14 19:18:48 -0700112 } else if (subType.equals(L2ModificationInstruction.L2SubType.TUNNEL_ID.name())) {
113 long tunnelId = nullIsIllegal(json.get(InstructionCodec.TUNNEL_ID),
114 InstructionCodec.TUNNEL_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asLong();
115 return Instructions.modTunnelId(tunnelId);
Ray Milkeyd43fe452015-05-29 09:35:12 -0700116 }
117 throw new IllegalArgumentException("L2 Instruction subtype "
118 + subType + " is not supported");
119 }
120
121 /**
122 * Decodes a Layer 3 instruction.
123 *
124 * @return instruction object decoded from the JSON
125 * @throws IllegalArgumentException if the JSON is invalid
126 */
127 private Instruction decodeL3() {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530128 String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE),
129 InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText();
Ray Milkeyd43fe452015-05-29 09:35:12 -0700130
131 if (subType.equals(L3ModificationInstruction.L3SubType.IPV4_SRC.name())) {
132 IpAddress ip = IpAddress.valueOf(nullIsIllegal(json.get(InstructionCodec.IP),
133 InstructionCodec.IP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
134 return Instructions.modL3Src(ip);
135 } else if (subType.equals(L3ModificationInstruction.L3SubType.IPV4_DST.name())) {
136 IpAddress ip = IpAddress.valueOf(nullIsIllegal(json.get(InstructionCodec.IP),
137 InstructionCodec.IP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
138 return Instructions.modL3Dst(ip);
139 } else if (subType.equals(L3ModificationInstruction.L3SubType.IPV6_SRC.name())) {
140 IpAddress ip = IpAddress.valueOf(nullIsIllegal(json.get(InstructionCodec.IP),
141 InstructionCodec.IP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
142 return Instructions.modL3IPv6Src(ip);
143 } else if (subType.equals(L3ModificationInstruction.L3SubType.IPV6_DST.name())) {
144 IpAddress ip = IpAddress.valueOf(nullIsIllegal(json.get(InstructionCodec.IP),
145 InstructionCodec.IP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
146 return Instructions.modL3IPv6Dst(ip);
147 } else if (subType.equals(L3ModificationInstruction.L3SubType.IPV6_FLABEL.name())) {
148 int flowLabel = nullIsIllegal(json.get(InstructionCodec.FLOW_LABEL),
149 InstructionCodec.FLOW_LABEL + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
150 return Instructions.modL3IPv6FlowLabel(flowLabel);
151 }
152 throw new IllegalArgumentException("L3 Instruction subtype "
153 + subType + " is not supported");
154 }
155
156 /**
157 * Decodes a Layer 0 instruction.
158 *
159 * @return instruction object decoded from the JSON
160 * @throws IllegalArgumentException if the JSON is invalid
161 */
162 private Instruction decodeL0() {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530163 String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE),
164 InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText();
Ray Milkeyd43fe452015-05-29 09:35:12 -0700165
Sho SHIMIZUcc137a92016-03-11 15:10:54 -0800166 if (subType.equals(L0ModificationInstruction.L0SubType.OCH.name())) {
Ray Milkeyd43fe452015-05-29 09:35:12 -0700167 String gridTypeString = nullIsIllegal(json.get(InstructionCodec.GRID_TYPE),
168 InstructionCodec.GRID_TYPE + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
169 GridType gridType = GridType.valueOf(gridTypeString);
170 if (gridType == null) {
171 throw new IllegalArgumentException("Unknown grid type "
172 + gridTypeString);
173 }
174 String channelSpacingString = nullIsIllegal(json.get(InstructionCodec.CHANNEL_SPACING),
175 InstructionCodec.CHANNEL_SPACING + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
176 ChannelSpacing channelSpacing = ChannelSpacing.valueOf(channelSpacingString);
177 if (channelSpacing == null) {
178 throw new IllegalArgumentException("Unknown channel spacing "
179 + channelSpacingString);
180 }
181 int spacingMultiplier = nullIsIllegal(json.get(InstructionCodec.SPACING_MULTIPLIER),
182 InstructionCodec.SPACING_MULTIPLIER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
183 int slotGranularity = nullIsIllegal(json.get(InstructionCodec.SLOT_GRANULARITY),
184 InstructionCodec.SLOT_GRANULARITY + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
185 return Instructions.modL0Lambda(new OchSignal(gridType, channelSpacing,
186 spacingMultiplier, slotGranularity));
187 }
188 throw new IllegalArgumentException("L0 Instruction subtype "
189 + subType + " is not supported");
190 }
191
192 /**
Yafit Hadar5796d972015-10-15 13:16:11 +0300193 * Decodes a Layer 1 instruction.
194 *
195 * @return instruction object decoded from the JSON
196 * @throws IllegalArgumentException if the JSON is invalid
197 */
198 private Instruction decodeL1() {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530199 String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE),
200 InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText();
Yafit Hadar5796d972015-10-15 13:16:11 +0300201 if (subType.equals(L1ModificationInstruction.L1SubType.ODU_SIGID.name())) {
202 int tributaryPortNumber = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_PORT_NUMBER),
203 InstructionCodec.TRIBUTARY_PORT_NUMBER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
204 int tributarySlotLen = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_LEN),
205 InstructionCodec.TRIBUTARY_SLOT_LEN + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
206 byte[] tributarySlotBitmap = null;
207 tributarySlotBitmap = HexString.fromHexString(
208 nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_BITMAP),
209 InstructionCodec.TRIBUTARY_SLOT_BITMAP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
210 return Instructions.modL1OduSignalId(OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen,
211 tributarySlotBitmap));
212 }
213 throw new IllegalArgumentException("L1 Instruction subtype "
214 + subType + " is not supported");
215 }
216
217 /**
Hyunsun Moonfab29502015-08-25 13:39:16 -0700218 * Decodes a Layer 4 instruction.
219 *
220 * @return instruction object decoded from the JSON
221 * @throws IllegalArgumentException if the JSON is invalid
222 */
223 private Instruction decodeL4() {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530224 String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE),
225 InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText();
Hyunsun Moonfab29502015-08-25 13:39:16 -0700226
227 if (subType.equals(L4ModificationInstruction.L4SubType.TCP_DST.name())) {
228 TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.TCP_PORT),
229 InstructionCodec.TCP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt());
230 return Instructions.modTcpDst(tcpPort);
231 } else if (subType.equals(L4ModificationInstruction.L4SubType.TCP_SRC.name())) {
232 TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.TCP_PORT),
233 InstructionCodec.TCP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt());
234 return Instructions.modTcpSrc(tcpPort);
235 } else if (subType.equals(L4ModificationInstruction.L4SubType.UDP_DST.name())) {
236 TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.UDP_PORT),
237 InstructionCodec.UDP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt());
238 return Instructions.modUdpDst(udpPort);
239 } else if (subType.equals(L4ModificationInstruction.L4SubType.UDP_SRC.name())) {
240 TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(InstructionCodec.UDP_PORT),
241 InstructionCodec.UDP_PORT + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt());
242 return Instructions.modUdpSrc(udpPort);
243 }
244 throw new IllegalArgumentException("L4 Instruction subtype "
245 + subType + " is not supported");
246 }
247
248 /**
Jian Lidab72562016-04-12 14:10:32 -0700249 * Decodes a extension instruction.
250 *
251 * @return extension treatment
252 */
253 private Instruction decodeExtension() {
254 ObjectNode node = (ObjectNode) json.get(InstructionCodec.EXTENSION);
255 if (node != null) {
256 DeviceId deviceId = getDeviceId();
257
258 ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
259 DeviceService deviceService = serviceDirectory.get(DeviceService.class);
260 Device device = deviceService.getDevice(deviceId);
261
Jonathan Harte3bcfc32016-08-16 17:12:49 -0700262 if (device == null) {
263 throw new IllegalArgumentException("Device not found");
264 }
265
Jian Lidab72562016-04-12 14:10:32 -0700266 if (device.is(ExtensionTreatmentCodec.class)) {
267 ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
Jonathan Harte3bcfc32016-08-16 17:12:49 -0700268 ExtensionTreatment treatment = treatmentCodec.decode(node, context);
Jian Lidab72562016-04-12 14:10:32 -0700269 return Instructions.extension(treatment, deviceId);
270 } else {
Jonathan Harte3bcfc32016-08-16 17:12:49 -0700271 throw new IllegalArgumentException(
272 "There is no codec to decode extension for device " + deviceId.toString());
Jian Lidab72562016-04-12 14:10:32 -0700273 }
274 }
275 return null;
276 }
277
278 /**
279 * Returns device identifier.
280 *
281 * @return device identifier
282 * @throws IllegalArgumentException if the JSON is invalid
283 */
284 private DeviceId getDeviceId() {
285 JsonNode deviceIdNode = json.get(InstructionCodec.DEVICE_ID);
286 if (deviceIdNode != null) {
287 return DeviceId.deviceId(deviceIdNode.asText());
288 }
289 throw new IllegalArgumentException("Empty device identifier");
290 }
291
292 /**
Jian Li70dffe42016-03-08 22:23:02 -0800293 * Extracts port number of the given json node.
294 *
295 * @param jsonNode json node
296 * @return port number
297 */
298 private PortNumber getPortNumber(ObjectNode jsonNode) {
299 PortNumber portNumber;
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530300 JsonNode portNode = nullIsIllegal(jsonNode.get(InstructionCodec.PORT),
301 InstructionCodec.PORT + InstructionCodec.ERROR_MESSAGE);
302 if (portNode.isLong() || portNode.isInt()) {
303 portNumber = PortNumber.portNumber(portNode.asLong());
304 } else if (portNode.isTextual()) {
305 portNumber = PortNumber.fromString(portNode.textValue());
Jian Li70dffe42016-03-08 22:23:02 -0800306 } else {
307 throw new IllegalArgumentException("Port value "
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530308 + portNode.toString()
Jian Li70dffe42016-03-08 22:23:02 -0800309 + " is not supported");
310 }
311 return portNumber;
312 }
313
314 /**
Ray Milkeyd43fe452015-05-29 09:35:12 -0700315 * Decodes the JSON into an instruction object.
316 *
317 * @return Criterion object
318 * @throws IllegalArgumentException if the JSON is invalid
319 */
320 public Instruction decode() {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530321 String type = nullIsIllegal(json.get(InstructionCodec.TYPE),
322 InstructionCodec.TYPE + InstructionCodec.ERROR_MESSAGE).asText();
Ray Milkeyd43fe452015-05-29 09:35:12 -0700323
324 if (type.equals(Instruction.Type.OUTPUT.name())) {
Jian Li70dffe42016-03-08 22:23:02 -0800325 return Instructions.createOutput(getPortNumber(json));
Ray Milkey2be39ed2016-02-22 15:54:19 -0800326 } else if (type.equals(Instruction.Type.NOACTION.name())) {
327 return Instructions.createNoAction();
Jian Li1ef82db2016-03-03 14:43:21 -0800328 } else if (type.equals(Instruction.Type.TABLE.name())) {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530329 return Instructions.transition(nullIsIllegal(json.get(InstructionCodec.TABLE_ID),
330 InstructionCodec.TABLE_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt());
Jian Lice8c5602016-03-03 21:43:24 -0800331 } else if (type.equals(Instruction.Type.GROUP.name())) {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530332 GroupId groupId = new DefaultGroupId(nullIsIllegal(json.get(InstructionCodec.GROUP_ID),
333 InstructionCodec.GROUP_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt());
Jian Lice8c5602016-03-03 21:43:24 -0800334 return Instructions.createGroup(groupId);
Jian Li47b26232016-03-07 09:59:59 -0800335 } else if (type.equals(Instruction.Type.METER.name())) {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530336 MeterId meterId = MeterId.meterId(nullIsIllegal(json.get(InstructionCodec.METER_ID),
337 InstructionCodec.METER_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asLong());
Jian Li47b26232016-03-07 09:59:59 -0800338 return Instructions.meterTraffic(meterId);
Jian Li70dffe42016-03-08 22:23:02 -0800339 } else if (type.equals(Instruction.Type.QUEUE.name())) {
Jayasree Ghosh8aca6772016-10-04 03:32:11 +0530340 long queueId = nullIsIllegal(json.get(InstructionCodec.QUEUE_ID),
341 InstructionCodec.QUEUE_ID + InstructionCodec.MISSING_MEMBER_MESSAGE).asLong();
Jian Li70dffe42016-03-08 22:23:02 -0800342 return Instructions.setQueue(queueId, getPortNumber(json));
Ray Milkeyd43fe452015-05-29 09:35:12 -0700343 } else if (type.equals(Instruction.Type.L0MODIFICATION.name())) {
344 return decodeL0();
Yafit Hadar5796d972015-10-15 13:16:11 +0300345 } else if (type.equals(Instruction.Type.L1MODIFICATION.name())) {
346 return decodeL1();
Ray Milkeyd43fe452015-05-29 09:35:12 -0700347 } else if (type.equals(Instruction.Type.L2MODIFICATION.name())) {
348 return decodeL2();
349 } else if (type.equals(Instruction.Type.L3MODIFICATION.name())) {
350 return decodeL3();
Hyunsun Moonfab29502015-08-25 13:39:16 -0700351 } else if (type.equals(Instruction.Type.L4MODIFICATION.name())) {
352 return decodeL4();
Jian Lidab72562016-04-12 14:10:32 -0700353 } else if (type.equals(Instruction.Type.EXTENSION.name())) {
354 return decodeExtension();
Ray Milkeyd43fe452015-05-29 09:35:12 -0700355 }
356 throw new IllegalArgumentException("Instruction type "
357 + type + " is not supported");
358 }
Ray Milkeyd43fe452015-05-29 09:35:12 -0700359}