Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.provider.of.flow.impl; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 17 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 18 | import com.google.common.collect.Lists; |
Jonathan Hart | 29afca3 | 2015-01-20 18:17:39 -0800 | [diff] [blame] | 19 | import org.onlab.packet.Ip4Address; |
Pavlin Radoslavov | febe82c | 2015-02-11 19:08:15 -0800 | [diff] [blame] | 20 | import org.onlab.packet.Ip6Address; |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 21 | import org.onosproject.net.OchSignal; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 22 | import org.onosproject.net.OduSignalId; |
Charles M.C. Chan | fe42181 | 2015-01-12 18:20:51 +0800 | [diff] [blame] | 23 | import org.onosproject.net.PortNumber; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 24 | import org.onosproject.net.driver.DefaultDriverData; |
| 25 | import org.onosproject.net.driver.DefaultDriverHandler; |
| 26 | import org.onosproject.net.driver.Driver; |
| 27 | import org.onosproject.net.driver.DriverService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 28 | import org.onosproject.net.flow.FlowRule; |
| 29 | import org.onosproject.net.flow.TrafficTreatment; |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 30 | import org.onosproject.net.flow.instructions.ExtensionTreatment; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 31 | import org.onosproject.net.flow.instructions.Instruction; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 32 | import org.onosproject.net.flow.instructions.Instructions; |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 33 | import org.onosproject.net.flow.instructions.Instructions.GroupInstruction; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 34 | import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; |
Steffen Gebert | bbfdaaa | 2015-09-29 11:01:46 +0200 | [diff] [blame] | 35 | import org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 36 | import org.onosproject.net.flow.instructions.L0ModificationInstruction; |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 37 | import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 38 | import org.onosproject.net.flow.instructions.L1ModificationInstruction; |
| 39 | import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 40 | import org.onosproject.net.flow.instructions.L2ModificationInstruction; |
| 41 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; |
Saurav Das | 73a7dd4 | 2015-08-19 22:20:31 -0700 | [diff] [blame] | 42 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsBosInstruction; |
Jonathan Hart | 29afca3 | 2015-01-20 18:17:39 -0800 | [diff] [blame] | 43 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 44 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 45 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; |
| 46 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 47 | import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions; |
| 48 | import org.onosproject.net.flow.instructions.L3ModificationInstruction; |
lishuai | 3cce60b | 2015-12-01 19:35:16 +0800 | [diff] [blame] | 49 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpEthInstruction; |
Jonathan Hart | 42feabd | 2016-02-03 17:56:21 -0800 | [diff] [blame] | 50 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpIPInstruction; |
lishuai | 3cce60b | 2015-12-01 19:35:16 +0800 | [diff] [blame] | 51 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModArpOpInstruction; |
Jonathan Hart | 42feabd | 2016-02-03 17:56:21 -0800 | [diff] [blame] | 52 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; |
Pavlin Radoslavov | febe82c | 2015-02-11 19:08:15 -0800 | [diff] [blame] | 53 | import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction; |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 54 | import org.onosproject.net.flow.instructions.L4ModificationInstruction; |
| 55 | import org.onosproject.net.flow.instructions.L4ModificationInstruction.ModTransportPortInstruction; |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 56 | import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter; |
Thomas Vachuska | 95caba3 | 2016-04-04 10:42:05 -0700 | [diff] [blame] | 57 | import org.onosproject.provider.of.flow.util.NoMappingFoundException; |
| 58 | import org.onosproject.provider.of.flow.util.OpenFlowValueMapper; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 59 | import org.projectfloodlight.openflow.protocol.OFFactory; |
| 60 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
Jonathan Hart | 42feabd | 2016-02-03 17:56:21 -0800 | [diff] [blame] | 61 | import org.projectfloodlight.openflow.protocol.OFFlowDeleteStrict; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 62 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
| 63 | import org.projectfloodlight.openflow.protocol.OFFlowModFlags; |
| 64 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 65 | import org.projectfloodlight.openflow.protocol.action.OFActionGroup; |
Charles M.C. Chan | fe42181 | 2015-01-12 18:20:51 +0800 | [diff] [blame] | 66 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
Steffen Gebert | bbfdaaa | 2015-09-29 11:01:46 +0200 | [diff] [blame] | 67 | import org.projectfloodlight.openflow.protocol.action.OFActionSetQueue; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 68 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 69 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 70 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; |
lishuai | 3cce60b | 2015-12-01 19:35:16 +0800 | [diff] [blame] | 71 | import org.projectfloodlight.openflow.types.ArpOpcode; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 72 | import org.projectfloodlight.openflow.types.CircuitSignalID; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 73 | import org.projectfloodlight.openflow.types.EthType; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 74 | import org.projectfloodlight.openflow.types.IPv4Address; |
Pavlin Radoslavov | febe82c | 2015-02-11 19:08:15 -0800 | [diff] [blame] | 75 | import org.projectfloodlight.openflow.types.IPv6Address; |
| 76 | import org.projectfloodlight.openflow.types.IPv6FlowLabel; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 77 | import org.projectfloodlight.openflow.types.MacAddress; |
Saurav Das | 73a7dd4 | 2015-08-19 22:20:31 -0700 | [diff] [blame] | 78 | import org.projectfloodlight.openflow.types.OFBooleanValue; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 79 | import org.projectfloodlight.openflow.types.OFBufferId; |
sangho | 8995ac5 | 2015-02-04 11:29:03 -0800 | [diff] [blame] | 80 | import org.projectfloodlight.openflow.types.OFGroup; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 81 | import org.projectfloodlight.openflow.types.OFPort; |
| 82 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 83 | import org.projectfloodlight.openflow.types.OduSignalID; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 84 | import org.projectfloodlight.openflow.types.TableId; |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 85 | import org.projectfloodlight.openflow.types.TransportPort; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 86 | import org.projectfloodlight.openflow.types.U32; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 87 | import org.projectfloodlight.openflow.types.U64; |
| 88 | import org.projectfloodlight.openflow.types.VlanPcp; |
| 89 | import org.slf4j.Logger; |
| 90 | import org.slf4j.LoggerFactory; |
| 91 | |
Jonathan Hart | 29afca3 | 2015-01-20 18:17:39 -0800 | [diff] [blame] | 92 | import java.util.Collections; |
| 93 | import java.util.LinkedList; |
| 94 | import java.util.List; |
| 95 | import java.util.Optional; |
| 96 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 97 | /** |
| 98 | * Flow mod builder for OpenFlow 1.3+. |
| 99 | */ |
| 100 | public class FlowModBuilderVer13 extends FlowModBuilder { |
| 101 | |
alshabib | 1058080 | 2015-02-18 18:30:33 -0800 | [diff] [blame] | 102 | private final Logger log = LoggerFactory.getLogger(getClass()); |
Charles M.C. Chan | fe42181 | 2015-01-12 18:20:51 +0800 | [diff] [blame] | 103 | private static final int OFPCML_NO_BUFFER = 0xffff; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 104 | |
| 105 | private final TrafficTreatment treatment; |
| 106 | |
| 107 | /** |
| 108 | * Constructor for a flow mod builder for OpenFlow 1.3. |
| 109 | * |
| 110 | * @param flowRule the flow rule to transform into a flow mod |
| 111 | * @param factory the OpenFlow factory to use to build the flow mod |
Pavlin Radoslavov | 119fd5c | 2014-11-25 19:08:19 -0800 | [diff] [blame] | 112 | * @param xid the transaction ID |
Charles Chan | 30ba400 | 2015-11-05 14:45:16 -0800 | [diff] [blame] | 113 | * @param driverService the device driver service |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 114 | */ |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 115 | protected FlowModBuilderVer13(FlowRule flowRule, OFFactory factory, Optional<Long> xid, |
| 116 | Optional<DriverService> driverService) { |
| 117 | super(flowRule, factory, xid, driverService); |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 118 | |
| 119 | this.treatment = flowRule.treatment(); |
| 120 | } |
| 121 | |
| 122 | @Override |
Jonathan Hart | 42feabd | 2016-02-03 17:56:21 -0800 | [diff] [blame] | 123 | public OFFlowMod buildFlowAdd() { |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 124 | Match match = buildMatch(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 125 | List<OFAction> deferredActions = buildActions(treatment.deferred()); |
| 126 | List<OFAction> immediateActions = buildActions(treatment.immediate()); |
| 127 | List<OFInstruction> instructions = Lists.newLinkedList(); |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 128 | |
Jonathan Hart | d4a8bba | 2014-10-28 12:44:20 -0700 | [diff] [blame] | 129 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 130 | if (treatment.clearedDeferred()) { |
| 131 | instructions.add(factory().instructions().clearActions()); |
| 132 | } |
sangho | 1e57565 | 2015-05-14 00:39:53 -0700 | [diff] [blame] | 133 | if (immediateActions.size() > 0) { |
| 134 | instructions.add(factory().instructions().applyActions(immediateActions)); |
| 135 | } |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 136 | if (deferredActions.size() > 0) { |
| 137 | instructions.add(factory().instructions().writeActions(deferredActions)); |
| 138 | } |
| 139 | if (treatment.tableTransition() != null) { |
| 140 | instructions.add(buildTableGoto(treatment.tableTransition())); |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 141 | } |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 142 | if (treatment.writeMetadata() != null) { |
| 143 | instructions.add(buildMetadata(treatment.writeMetadata())); |
| 144 | } |
chengfan | e264bef | 2015-09-28 08:38:19 +0800 | [diff] [blame] | 145 | if (treatment.metered() != null) { |
| 146 | instructions.add(buildMeter(treatment.metered())); |
| 147 | } |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 148 | |
| 149 | long cookie = flowRule().id().value(); |
| 150 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 151 | OFFlowAdd fm = factory().buildFlowAdd() |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 152 | .setXid(xid) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 153 | .setCookie(U64.of(cookie)) |
| 154 | .setBufferId(OFBufferId.NO_BUFFER) |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 155 | .setInstructions(instructions) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 156 | .setMatch(match) |
| 157 | .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)) |
| 158 | .setPriority(flowRule().priority()) |
alshabib | 08d9898 | 2015-04-21 16:25:50 -0700 | [diff] [blame] | 159 | .setTableId(TableId.of(flowRule().tableId())) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 160 | .build(); |
| 161 | |
| 162 | return fm; |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public OFFlowMod buildFlowMod() { |
| 167 | Match match = buildMatch(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 168 | List<OFAction> deferredActions = buildActions(treatment.deferred()); |
| 169 | List<OFAction> immediateActions = buildActions(treatment.immediate()); |
| 170 | List<OFInstruction> instructions = Lists.newLinkedList(); |
Jonathan Hart | eda3387 | 2015-02-18 10:22:32 -0800 | [diff] [blame] | 171 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 172 | |
| 173 | if (immediateActions.size() > 0) { |
| 174 | instructions.add(factory().instructions().applyActions(immediateActions)); |
| 175 | } |
| 176 | if (treatment.clearedDeferred()) { |
| 177 | instructions.add(factory().instructions().clearActions()); |
| 178 | } |
| 179 | if (deferredActions.size() > 0) { |
| 180 | instructions.add(factory().instructions().writeActions(deferredActions)); |
| 181 | } |
| 182 | if (treatment.tableTransition() != null) { |
| 183 | instructions.add(buildTableGoto(treatment.tableTransition())); |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 184 | } |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 185 | if (treatment.writeMetadata() != null) { |
| 186 | instructions.add(buildMetadata(treatment.writeMetadata())); |
| 187 | } |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 188 | if (treatment.metered() != null) { |
| 189 | instructions.add(buildMeter(treatment.metered())); |
| 190 | } |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 191 | |
| 192 | long cookie = flowRule().id().value(); |
| 193 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 194 | OFFlowMod fm = factory().buildFlowModify() |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 195 | .setXid(xid) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 196 | .setCookie(U64.of(cookie)) |
| 197 | .setBufferId(OFBufferId.NO_BUFFER) |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 198 | .setInstructions(instructions) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 199 | .setMatch(match) |
| 200 | .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)) |
| 201 | .setPriority(flowRule().priority()) |
alshabib | 08d9898 | 2015-04-21 16:25:50 -0700 | [diff] [blame] | 202 | .setTableId(TableId.of(flowRule().tableId())) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 203 | .build(); |
| 204 | |
| 205 | return fm; |
| 206 | } |
| 207 | |
| 208 | @Override |
Jonathan Hart | 42feabd | 2016-02-03 17:56:21 -0800 | [diff] [blame] | 209 | public OFFlowMod buildFlowDel() { |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 210 | Match match = buildMatch(); |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 211 | |
| 212 | long cookie = flowRule().id().value(); |
| 213 | |
Jonathan Hart | 42feabd | 2016-02-03 17:56:21 -0800 | [diff] [blame] | 214 | OFFlowDeleteStrict fm = factory().buildFlowDeleteStrict() |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 215 | .setXid(xid) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 216 | .setCookie(U64.of(cookie)) |
| 217 | .setBufferId(OFBufferId.NO_BUFFER) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 218 | .setMatch(match) |
| 219 | .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)) |
| 220 | .setPriority(flowRule().priority()) |
alshabib | 08d9898 | 2015-04-21 16:25:50 -0700 | [diff] [blame] | 221 | .setTableId(TableId.of(flowRule().tableId())) |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 222 | .build(); |
| 223 | |
| 224 | return fm; |
| 225 | } |
| 226 | |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 227 | private List<OFAction> buildActions(List<Instruction> treatments) { |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 228 | if (treatment == null) { |
Sho SHIMIZU | 6601dd7 | 2015-05-11 19:00:29 -0700 | [diff] [blame] | 229 | return Collections.emptyList(); |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 230 | } |
Sho SHIMIZU | 6601dd7 | 2015-05-11 19:00:29 -0700 | [diff] [blame] | 231 | |
| 232 | boolean tableFound = false; |
| 233 | List<OFAction> actions = new LinkedList<>(); |
alshabib | 346b5b3 | 2015-03-06 00:42:16 -0800 | [diff] [blame] | 234 | for (Instruction i : treatments) { |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 235 | switch (i.type()) { |
Charles Chan | 7efabeb | 2015-09-28 15:12:19 -0700 | [diff] [blame] | 236 | case NOACTION: |
Sho SHIMIZU | b35ed36 | 2015-04-28 11:05:19 -0700 | [diff] [blame] | 237 | return Collections.emptyList(); |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 238 | case L0MODIFICATION: |
| 239 | actions.add(buildL0Modification(i)); |
| 240 | break; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 241 | case L1MODIFICATION: |
| 242 | actions.add(buildL1Modification(i)); |
| 243 | break; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 244 | case L2MODIFICATION: |
| 245 | actions.add(buildL2Modification(i)); |
| 246 | break; |
| 247 | case L3MODIFICATION: |
| 248 | actions.add(buildL3Modification(i)); |
| 249 | break; |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 250 | case L4MODIFICATION: |
| 251 | actions.add(buildL4Modification(i)); |
| 252 | break; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 253 | case OUTPUT: |
| 254 | OutputInstruction out = (OutputInstruction) i; |
| 255 | OFActionOutput.Builder action = factory().actions().buildOutput() |
| 256 | .setPort(OFPort.of((int) out.port().toLong())); |
| 257 | if (out.port().equals(PortNumber.CONTROLLER)) { |
| 258 | action.setMaxLen(OFPCML_NO_BUFFER); |
| 259 | } |
| 260 | actions.add(action.build()); |
| 261 | break; |
| 262 | case GROUP: |
| 263 | GroupInstruction group = (GroupInstruction) i; |
| 264 | OFActionGroup.Builder groupBuilder = factory().actions().buildGroup() |
| 265 | .setGroup(OFGroup.of(group.groupId().id())); |
| 266 | actions.add(groupBuilder.build()); |
| 267 | break; |
Steffen Gebert | bbfdaaa | 2015-09-29 11:01:46 +0200 | [diff] [blame] | 268 | case QUEUE: |
| 269 | SetQueueInstruction queue = (SetQueueInstruction) i; |
| 270 | OFActionSetQueue.Builder queueBuilder = factory().actions().buildSetQueue() |
| 271 | .setQueueId(queue.queueId()); |
| 272 | actions.add(queueBuilder.build()); |
| 273 | break; |
alshabib | 1058080 | 2015-02-18 18:30:33 -0800 | [diff] [blame] | 274 | case TABLE: |
| 275 | //FIXME: should not occur here. |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 276 | tableFound = true; |
alshabib | 1058080 | 2015-02-18 18:30:33 -0800 | [diff] [blame] | 277 | break; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 278 | case EXTENSION: |
| 279 | actions.add(buildExtensionAction(((Instructions.ExtensionInstructionWrapper) i) |
| 280 | .extensionInstruction())); |
| 281 | break; |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 282 | default: |
| 283 | log.warn("Instruction type {} not yet implemented.", i.type()); |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 284 | } |
| 285 | } |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 286 | if (tableFound && actions.isEmpty()) { |
| 287 | // handles the case where there are no actions, but there is |
| 288 | // a goto instruction for the next table |
Sho SHIMIZU | 6601dd7 | 2015-05-11 19:00:29 -0700 | [diff] [blame] | 289 | return Collections.emptyList(); |
Saurav Das | cbe6de3 | 2015-03-01 18:30:46 -0800 | [diff] [blame] | 290 | } |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 291 | return actions; |
| 292 | } |
| 293 | |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 294 | private OFInstruction buildTableGoto(Instructions.TableTypeTransition i) { |
| 295 | OFInstruction instruction = factory().instructions().gotoTable( |
alshabib | d17abc2 | 2015-04-21 18:26:35 -0700 | [diff] [blame] | 296 | TableId.of(i.tableId())); |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 297 | return instruction; |
| 298 | } |
| 299 | |
Saurav Das | 86af8f1 | 2015-05-25 23:55:33 -0700 | [diff] [blame] | 300 | private OFInstruction buildMetadata(Instructions.MetadataInstruction m) { |
| 301 | OFInstruction instruction = factory().instructions().writeMetadata( |
| 302 | U64.of(m.metadata()), U64.of(m.metadataMask())); |
| 303 | return instruction; |
| 304 | } |
| 305 | |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 306 | private OFInstruction buildMeter(Instructions.MeterInstruction metered) { |
| 307 | return factory().instructions().meter(metered.meterId().id()); |
| 308 | } |
| 309 | |
| 310 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 311 | private OFAction buildL0Modification(Instruction i) { |
| 312 | L0ModificationInstruction l0m = (L0ModificationInstruction) i; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 313 | OFOxm<?> oxm = null; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 314 | switch (l0m.subtype()) { |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 315 | case OCH: |
| 316 | try { |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 317 | ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m; |
| 318 | OchSignal signal = modOchSignalInstruction.lambda(); |
| 319 | byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); |
| 320 | byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); |
| 321 | oxm = factory().oxms().expOchSigId( |
| 322 | new CircuitSignalID(gridType, channelSpacing, |
| 323 | (short) signal.spacingMultiplier(), (short) signal.slotGranularity())); |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 324 | } catch (NoMappingFoundException e) { |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 325 | log.warn(e.getMessage()); |
| 326 | break; |
| 327 | } |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 328 | break; |
Sho SHIMIZU | 5cd7ce9 | 2015-05-11 19:10:38 -0700 | [diff] [blame] | 329 | default: |
| 330 | log.warn("Unimplemented action type {}.", l0m.subtype()); |
| 331 | break; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 332 | } |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 333 | if (oxm != null) { |
| 334 | return factory().actions().buildSetField().setField(oxm).build(); |
| 335 | } |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 336 | return null; |
| 337 | } |
| 338 | |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 339 | private OFAction buildModOchSignalInstruction(ModOchSignalInstruction instruction) { |
| 340 | OchSignal signal = instruction.lambda(); |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 341 | byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); |
| 342 | byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 343 | |
Marc De Leenheer | c2999f3 | 2015-11-20 15:52:16 -0800 | [diff] [blame] | 344 | return factory().actions().circuit(factory().oxms().expOchSigId( |
Sho SHIMIZU | e397ffe | 2015-05-12 16:24:23 -0700 | [diff] [blame] | 345 | new CircuitSignalID(gridType, channelSpacing, |
| 346 | (short) signal.spacingMultiplier(), (short) signal.slotGranularity()) |
| 347 | )); |
| 348 | } |
| 349 | |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 350 | private OFAction buildL1Modification(Instruction i) { |
| 351 | L1ModificationInstruction l1m = (L1ModificationInstruction) i; |
| 352 | OFOxm<?> oxm = null; |
| 353 | switch (l1m.subtype()) { |
| 354 | case ODU_SIGID: |
| 355 | ModOduSignalIdInstruction modOduSignalIdInstruction = (ModOduSignalIdInstruction) l1m; |
| 356 | OduSignalId oduSignalId = modOduSignalIdInstruction.oduSignalId(); |
| 357 | |
| 358 | OduSignalID oduSignalID = new OduSignalID((short) oduSignalId.tributaryPortNumber(), |
| 359 | (short) oduSignalId.tributarySlotLength(), |
| 360 | oduSignalId.tributarySlotBitmap()); |
| 361 | |
| 362 | oxm = factory().oxms().expOduSigId(oduSignalID); |
| 363 | break; |
| 364 | default: |
| 365 | log.warn("Unimplemented action type {}.", l1m.subtype()); |
| 366 | break; |
| 367 | } |
| 368 | |
| 369 | if (oxm != null) { |
| 370 | return factory().actions().buildSetField().setField(oxm).build(); |
| 371 | } |
| 372 | return null; |
| 373 | } |
| 374 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 375 | private OFAction buildL2Modification(Instruction i) { |
| 376 | L2ModificationInstruction l2m = (L2ModificationInstruction) i; |
| 377 | ModEtherInstruction eth; |
| 378 | OFOxm<?> oxm = null; |
| 379 | switch (l2m.subtype()) { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 380 | case ETH_DST: |
| 381 | eth = (ModEtherInstruction) l2m; |
| 382 | oxm = factory().oxms().ethDst(MacAddress.of(eth.mac().toLong())); |
| 383 | break; |
| 384 | case ETH_SRC: |
| 385 | eth = (ModEtherInstruction) l2m; |
| 386 | oxm = factory().oxms().ethSrc(MacAddress.of(eth.mac().toLong())); |
| 387 | break; |
| 388 | case VLAN_ID: |
| 389 | ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m; |
| 390 | oxm = factory().oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort())); |
| 391 | break; |
| 392 | case VLAN_PCP: |
| 393 | ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m; |
| 394 | oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); |
| 395 | break; |
| 396 | case MPLS_PUSH: |
| 397 | PushHeaderInstructions pushHeaderInstructions = |
| 398 | (PushHeaderInstructions) l2m; |
| 399 | return factory().actions().pushMpls(EthType.of(pushHeaderInstructions |
alshabib | 7b808c5 | 2015-06-26 14:22:24 -0700 | [diff] [blame] | 400 | .ethernetType().toShort())); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 401 | case MPLS_POP: |
Jonathan Hart | 67fc097 | 2015-03-19 15:21:20 -0700 | [diff] [blame] | 402 | PushHeaderInstructions popHeaderInstructions = |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 403 | (PushHeaderInstructions) l2m; |
| 404 | return factory().actions().popMpls(EthType.of(popHeaderInstructions |
alshabib | 7b808c5 | 2015-06-26 14:22:24 -0700 | [diff] [blame] | 405 | .ethernetType().toShort())); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 406 | case MPLS_LABEL: |
| 407 | ModMplsLabelInstruction mplsLabel = |
| 408 | (ModMplsLabelInstruction) l2m; |
Ray Milkey | 125572b | 2016-02-22 16:48:17 -0800 | [diff] [blame] | 409 | oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label().toInt())); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 410 | break; |
Saurav Das | 73a7dd4 | 2015-08-19 22:20:31 -0700 | [diff] [blame] | 411 | case MPLS_BOS: |
| 412 | ModMplsBosInstruction mplsBos = (ModMplsBosInstruction) l2m; |
| 413 | oxm = factory().oxms() |
| 414 | .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE |
| 415 | : OFBooleanValue.FALSE); |
| 416 | break; |
sangho | 3f97a17d | 2015-01-29 22:56:29 -0800 | [diff] [blame] | 417 | case DEC_MPLS_TTL: |
| 418 | return factory().actions().decMplsTtl(); |
Saurav Das | fbe25c5 | 2015-03-04 11:12:00 -0800 | [diff] [blame] | 419 | case VLAN_POP: |
| 420 | return factory().actions().popVlan(); |
Jonathan Hart | 54b406b | 2015-03-06 16:24:14 -0800 | [diff] [blame] | 421 | case VLAN_PUSH: |
| 422 | PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m; |
| 423 | return factory().actions().pushVlan( |
alshabib | 7b808c5 | 2015-06-26 14:22:24 -0700 | [diff] [blame] | 424 | EthType.of(pushVlanInstruction.ethernetType().toShort())); |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 425 | case TUNNEL_ID: |
| 426 | ModTunnelIdInstruction tunnelId = (ModTunnelIdInstruction) l2m; |
| 427 | oxm = factory().oxms().tunnelId(U64.of(tunnelId.tunnelId())); |
| 428 | break; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 429 | default: |
| 430 | log.warn("Unimplemented action type {}.", l2m.subtype()); |
| 431 | break; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | if (oxm != null) { |
| 435 | return factory().actions().buildSetField().setField(oxm).build(); |
| 436 | } |
| 437 | return null; |
| 438 | } |
| 439 | |
| 440 | private OFAction buildL3Modification(Instruction i) { |
| 441 | L3ModificationInstruction l3m = (L3ModificationInstruction) i; |
| 442 | ModIPInstruction ip; |
Pavlin Radoslavov | 23e398d | 2014-11-05 15:17:57 -0800 | [diff] [blame] | 443 | Ip4Address ip4; |
Pavlin Radoslavov | febe82c | 2015-02-11 19:08:15 -0800 | [diff] [blame] | 444 | Ip6Address ip6; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 445 | OFOxm<?> oxm = null; |
| 446 | switch (l3m.subtype()) { |
Sho SHIMIZU | 5cd7ce9 | 2015-05-11 19:10:38 -0700 | [diff] [blame] | 447 | case IPV4_SRC: |
| 448 | ip = (ModIPInstruction) i; |
| 449 | ip4 = ip.ip().getIp4Address(); |
| 450 | oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt())); |
| 451 | break; |
| 452 | case IPV4_DST: |
| 453 | ip = (ModIPInstruction) i; |
| 454 | ip4 = ip.ip().getIp4Address(); |
| 455 | oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt())); |
| 456 | break; |
| 457 | case IPV6_SRC: |
| 458 | ip = (ModIPInstruction) i; |
| 459 | ip6 = ip.ip().getIp6Address(); |
| 460 | oxm = factory().oxms().ipv6Src(IPv6Address.of(ip6.toOctets())); |
| 461 | break; |
| 462 | case IPV6_DST: |
| 463 | ip = (ModIPInstruction) i; |
| 464 | ip6 = ip.ip().getIp6Address(); |
| 465 | oxm = factory().oxms().ipv6Dst(IPv6Address.of(ip6.toOctets())); |
| 466 | break; |
| 467 | case IPV6_FLABEL: |
| 468 | ModIPv6FlowLabelInstruction flowLabelInstruction = |
| 469 | (ModIPv6FlowLabelInstruction) i; |
| 470 | int flowLabel = flowLabelInstruction.flowLabel(); |
| 471 | oxm = factory().oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel)); |
| 472 | break; |
lishuai | 3cce60b | 2015-12-01 19:35:16 +0800 | [diff] [blame] | 473 | case ARP_SPA: |
| 474 | ModArpIPInstruction aip = (ModArpIPInstruction) i; |
| 475 | ip4 = aip.ip().getIp4Address(); |
| 476 | oxm = factory().oxms().arpSpa(IPv4Address.of(ip4.toInt())); |
| 477 | break; |
| 478 | case ARP_SHA: |
| 479 | ModArpEthInstruction ei = (ModArpEthInstruction) i; |
| 480 | oxm = factory().oxms().arpSha(MacAddress.of(ei.mac().toLong())); |
| 481 | break; |
| 482 | case ARP_OP: |
| 483 | ModArpOpInstruction oi = (ModArpOpInstruction) i; |
| 484 | oxm = factory().oxms().arpOp(ArpOpcode.of((int) oi.op())); |
| 485 | break; |
Sho SHIMIZU | 5cd7ce9 | 2015-05-11 19:10:38 -0700 | [diff] [blame] | 486 | case DEC_TTL: |
| 487 | return factory().actions().decNwTtl(); |
| 488 | case TTL_IN: |
| 489 | return factory().actions().copyTtlIn(); |
| 490 | case TTL_OUT: |
| 491 | return factory().actions().copyTtlOut(); |
| 492 | default: |
| 493 | log.warn("Unimplemented action type {}.", l3m.subtype()); |
| 494 | break; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | if (oxm != null) { |
| 498 | return factory().actions().buildSetField().setField(oxm).build(); |
| 499 | } |
| 500 | return null; |
| 501 | } |
| 502 | |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 503 | private OFAction buildL4Modification(Instruction i) { |
| 504 | L4ModificationInstruction l4m = (L4ModificationInstruction) i; |
| 505 | ModTransportPortInstruction tp; |
| 506 | OFOxm<?> oxm = null; |
| 507 | switch (l4m.subtype()) { |
| 508 | case TCP_SRC: |
| 509 | tp = (ModTransportPortInstruction) l4m; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 510 | oxm = factory().oxms().tcpSrc(TransportPort.of(tp.port().toInt())); |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 511 | break; |
| 512 | case TCP_DST: |
| 513 | tp = (ModTransportPortInstruction) l4m; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 514 | oxm = factory().oxms().tcpDst(TransportPort.of(tp.port().toInt())); |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 515 | break; |
| 516 | case UDP_SRC: |
| 517 | tp = (ModTransportPortInstruction) l4m; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 518 | oxm = factory().oxms().udpSrc(TransportPort.of(tp.port().toInt())); |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 519 | break; |
| 520 | case UDP_DST: |
| 521 | tp = (ModTransportPortInstruction) l4m; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 522 | oxm = factory().oxms().udpDst(TransportPort.of(tp.port().toInt())); |
Hyunsun Moon | c8bd97c | 2015-07-18 22:47:33 -0700 | [diff] [blame] | 523 | break; |
| 524 | default: |
| 525 | log.warn("Unimplemented action type {}.", l4m.subtype()); |
| 526 | break; |
| 527 | } |
| 528 | |
| 529 | if (oxm != null) { |
| 530 | return factory().actions().buildSetField().setField(oxm).build(); |
| 531 | } |
| 532 | return null; |
| 533 | } |
| 534 | |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 535 | private OFAction buildExtensionAction(ExtensionTreatment i) { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 536 | if (!driverService.isPresent()) { |
| 537 | log.error("No driver service present"); |
| 538 | return null; |
| 539 | } |
| 540 | Driver driver = driverService.get().getDriver(deviceId); |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 541 | if (driver.hasBehaviour(ExtensionTreatmentInterpreter.class)) { |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 542 | DefaultDriverHandler handler = |
| 543 | new DefaultDriverHandler(new DefaultDriverData(driver, deviceId)); |
alshabib | 880b644 | 2015-11-23 22:13:04 -0800 | [diff] [blame] | 544 | ExtensionTreatmentInterpreter interpreter = handler.behaviour(ExtensionTreatmentInterpreter.class); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 545 | return interpreter.mapInstruction(factory(), i); |
| 546 | } |
| 547 | |
| 548 | return null; |
| 549 | } |
| 550 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 551 | } |