Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 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; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 18 | import org.onlab.packet.Ip4Address; |
| 19 | import org.onlab.packet.Ip4Prefix; |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 20 | import org.onlab.packet.Ip6Address; |
| 21 | import org.onlab.packet.Ip6Prefix; |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 22 | import org.onlab.packet.VlanId; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 23 | import org.onosproject.net.DeviceId; |
Sho SHIMIZU | c15ce51 | 2015-05-26 16:54:08 -0700 | [diff] [blame] | 24 | import org.onosproject.net.OchSignal; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 25 | import org.onosproject.net.driver.DefaultDriverData; |
| 26 | import org.onosproject.net.driver.DefaultDriverHandler; |
| 27 | import org.onosproject.net.driver.Driver; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 28 | import org.onosproject.net.driver.DriverService; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 29 | import org.onosproject.net.OduSignalId; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.net.flow.FlowRule; |
| 31 | import org.onosproject.net.flow.TrafficSelector; |
BitOhenry | 7643085 | 2015-11-20 19:04:49 +0800 | [diff] [blame] | 32 | import org.onosproject.net.flow.criteria.ArpHaCriterion; |
BitOhenry | b40129a | 2015-11-30 12:41:18 +0800 | [diff] [blame] | 33 | import org.onosproject.net.flow.criteria.ArpOpCriterion; |
BitOhenry | c1e5fcc | 2015-11-23 20:47:53 +0800 | [diff] [blame] | 34 | import org.onosproject.net.flow.criteria.ArpPaCriterion; |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 35 | import org.onosproject.net.flow.criteria.Criterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 36 | import org.onosproject.net.flow.criteria.EthCriterion; |
| 37 | import org.onosproject.net.flow.criteria.EthTypeCriterion; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 38 | import org.onosproject.net.flow.criteria.ExtensionCriterion; |
| 39 | import org.onosproject.net.flow.criteria.ExtensionSelector; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 40 | import org.onosproject.net.flow.criteria.IPCriterion; |
| 41 | import org.onosproject.net.flow.criteria.IPDscpCriterion; |
| 42 | import org.onosproject.net.flow.criteria.IPEcnCriterion; |
| 43 | import org.onosproject.net.flow.criteria.IPProtocolCriterion; |
| 44 | import org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion; |
| 45 | import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion; |
| 46 | import org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion; |
| 47 | import org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion; |
| 48 | import org.onosproject.net.flow.criteria.IcmpCodeCriterion; |
| 49 | import org.onosproject.net.flow.criteria.IcmpTypeCriterion; |
| 50 | import org.onosproject.net.flow.criteria.Icmpv6CodeCriterion; |
| 51 | import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 52 | import org.onosproject.net.flow.criteria.MetadataCriterion; |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 53 | import org.onosproject.net.flow.criteria.MplsBosCriterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 54 | import org.onosproject.net.flow.criteria.MplsCriterion; |
Sho SHIMIZU | c15ce51 | 2015-05-26 16:54:08 -0700 | [diff] [blame] | 55 | import org.onosproject.net.flow.criteria.OchSignalCriterion; |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 56 | import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 57 | import org.onosproject.net.flow.criteria.OduSignalIdCriterion; |
| 58 | import org.onosproject.net.flow.criteria.OduSignalTypeCriterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 59 | import org.onosproject.net.flow.criteria.PortCriterion; |
| 60 | import org.onosproject.net.flow.criteria.SctpPortCriterion; |
| 61 | import org.onosproject.net.flow.criteria.TcpPortCriterion; |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 62 | import org.onosproject.net.flow.criteria.TunnelIdCriterion; |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 63 | import org.onosproject.net.flow.criteria.UdpPortCriterion; |
| 64 | import org.onosproject.net.flow.criteria.VlanIdCriterion; |
| 65 | import org.onosproject.net.flow.criteria.VlanPcpCriterion; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 66 | import org.onosproject.openflow.controller.ExtensionSelectorInterpreter; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 67 | import org.projectfloodlight.openflow.protocol.OFFactory; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 68 | import org.projectfloodlight.openflow.protocol.OFFlowAdd; |
| 69 | import org.projectfloodlight.openflow.protocol.OFFlowDelete; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 70 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 71 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 72 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 73 | import org.projectfloodlight.openflow.protocol.oxm.OFOxm; |
BitOhenry | b40129a | 2015-11-30 12:41:18 +0800 | [diff] [blame] | 74 | import org.projectfloodlight.openflow.types.ArpOpcode; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 75 | import org.projectfloodlight.openflow.types.CircuitSignalID; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 76 | import org.projectfloodlight.openflow.types.EthType; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 77 | import org.projectfloodlight.openflow.types.ICMPv4Code; |
| 78 | import org.projectfloodlight.openflow.types.ICMPv4Type; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 79 | import org.projectfloodlight.openflow.types.IPv4Address; |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 80 | import org.projectfloodlight.openflow.types.IPv6Address; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 81 | import org.projectfloodlight.openflow.types.IPv6FlowLabel; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 82 | import org.projectfloodlight.openflow.types.IpDscp; |
| 83 | import org.projectfloodlight.openflow.types.IpEcn; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 84 | import org.projectfloodlight.openflow.types.IpProtocol; |
| 85 | import org.projectfloodlight.openflow.types.MacAddress; |
| 86 | import org.projectfloodlight.openflow.types.Masked; |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 87 | import org.projectfloodlight.openflow.types.OFBooleanValue; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 88 | import org.projectfloodlight.openflow.types.OFMetadata; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 89 | import org.projectfloodlight.openflow.types.OFPort; |
| 90 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
Jonathan Hart | 34bc614 | 2014-10-17 11:00:43 -0700 | [diff] [blame] | 91 | import org.projectfloodlight.openflow.types.TransportPort; |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 92 | import org.projectfloodlight.openflow.types.U16; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 93 | import org.projectfloodlight.openflow.types.U32; |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 94 | import org.projectfloodlight.openflow.types.U64; |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 95 | import org.projectfloodlight.openflow.types.U8; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 96 | import org.projectfloodlight.openflow.types.VlanPcp; |
| 97 | import org.projectfloodlight.openflow.types.VlanVid; |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 98 | import org.projectfloodlight.openflow.types.OduSignalID; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 99 | import org.slf4j.Logger; |
| 100 | |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 101 | import java.util.Optional; |
| 102 | |
| 103 | import static org.slf4j.LoggerFactory.getLogger; |
| 104 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 105 | /** |
| 106 | * Builder for OpenFlow flow mods based on FlowRules. |
| 107 | */ |
| 108 | public abstract class FlowModBuilder { |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 109 | |
| 110 | private final Logger log = getLogger(getClass()); |
| 111 | |
| 112 | private final OFFactory factory; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 113 | private final FlowRule flowRule; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 114 | private final TrafficSelector selector; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 115 | protected final Long xid; |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 116 | protected final Optional<DriverService> driverService; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 117 | protected final DeviceId deviceId; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 118 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 119 | /** |
| 120 | * Creates a new flow mod builder. |
| 121 | * |
| 122 | * @param flowRule the flow rule to transform into a flow mod |
| 123 | * @param factory the OpenFlow factory to use to build the flow mod |
Pavlin Radoslavov | 119fd5c | 2014-11-25 19:08:19 -0800 | [diff] [blame] | 124 | * @param xid the transaction ID |
Charles Chan | 30ba400 | 2015-11-05 14:45:16 -0800 | [diff] [blame] | 125 | * @param driverService the device driver service |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 126 | * @return the new flow mod builder |
| 127 | */ |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 128 | public static FlowModBuilder builder(FlowRule flowRule, |
alshabib | 9af7007 | 2015-02-09 14:34:16 -0800 | [diff] [blame] | 129 | OFFactory factory, |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 130 | Optional<Long> xid, |
| 131 | Optional<DriverService> driverService) { |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 132 | switch (factory.getVersion()) { |
| 133 | case OF_10: |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 134 | return new FlowModBuilderVer10(flowRule, factory, xid, driverService); |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 135 | case OF_13: |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 136 | return new FlowModBuilderVer13(flowRule, factory, xid, driverService); |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 137 | default: |
| 138 | throw new UnsupportedOperationException( |
| 139 | "No flow mod builder for protocol version " + factory.getVersion()); |
| 140 | } |
| 141 | } |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 142 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 143 | /** |
| 144 | * Constructs a flow mod builder. |
| 145 | * |
| 146 | * @param flowRule the flow rule to transform into a flow mod |
| 147 | * @param factory the OpenFlow factory to use to build the flow mod |
Charles Chan | 30ba400 | 2015-11-05 14:45:16 -0800 | [diff] [blame] | 148 | * @param driverService the device driver service |
Pavlin Radoslavov | 119fd5c | 2014-11-25 19:08:19 -0800 | [diff] [blame] | 149 | * @param xid the transaction ID |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 150 | */ |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 151 | protected FlowModBuilder(FlowRule flowRule, OFFactory factory, Optional<Long> xid, |
| 152 | Optional<DriverService> driverService) { |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 153 | this.factory = factory; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 154 | this.flowRule = flowRule; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 155 | this.selector = flowRule.selector(); |
Sho SHIMIZU | c14b2a2 | 2015-05-05 18:15:13 -0700 | [diff] [blame] | 156 | this.xid = xid.orElse(0L); |
Jonathan Hart | 3c25916 | 2015-10-21 21:31:19 -0700 | [diff] [blame] | 157 | this.driverService = driverService; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 158 | this.deviceId = flowRule.deviceId(); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 161 | /** |
| 162 | * Builds an ADD flow mod. |
| 163 | * |
| 164 | * @return the flow mod |
| 165 | */ |
| 166 | public abstract OFFlowAdd buildFlowAdd(); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 167 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 168 | /** |
| 169 | * Builds a MODIFY flow mod. |
| 170 | * |
| 171 | * @return the flow mod |
| 172 | */ |
| 173 | public abstract OFFlowMod buildFlowMod(); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 174 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 175 | /** |
| 176 | * Builds a DELETE flow mod. |
| 177 | * |
| 178 | * @return the flow mod |
| 179 | */ |
| 180 | public abstract OFFlowDelete buildFlowDel(); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 181 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 182 | /** |
| 183 | * Builds the match for the flow mod. |
| 184 | * |
| 185 | * @return the match |
| 186 | */ |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 187 | // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 188 | protected Match buildMatch() { |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 189 | Match.Builder mBuilder = factory.buildMatch(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 190 | Ip6Address ip6Address; |
Pavlin Radoslavov | 23e398d | 2014-11-05 15:17:57 -0800 | [diff] [blame] | 191 | Ip4Prefix ip4Prefix; |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 192 | Ip6Prefix ip6Prefix; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 193 | EthCriterion ethCriterion; |
| 194 | IPCriterion ipCriterion; |
| 195 | TcpPortCriterion tcpPortCriterion; |
| 196 | UdpPortCriterion udpPortCriterion; |
| 197 | SctpPortCriterion sctpPortCriterion; |
| 198 | IPv6NDLinkLayerAddressCriterion llAddressCriterion; |
BitOhenry | 7643085 | 2015-11-20 19:04:49 +0800 | [diff] [blame] | 199 | ArpHaCriterion arpHaCriterion; |
BitOhenry | c1e5fcc | 2015-11-23 20:47:53 +0800 | [diff] [blame] | 200 | ArpPaCriterion arpPaCriterion; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 201 | |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 202 | for (Criterion c : selector.criteria()) { |
| 203 | switch (c.type()) { |
| 204 | case IN_PORT: |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 205 | PortCriterion inPort = (PortCriterion) c; |
| 206 | mBuilder.setExact(MatchField.IN_PORT, |
| 207 | OFPort.of((int) inPort.port().toLong())); |
| 208 | break; |
| 209 | case IN_PHY_PORT: |
| 210 | PortCriterion inPhyPort = (PortCriterion) c; |
| 211 | mBuilder.setExact(MatchField.IN_PORT, |
| 212 | OFPort.of((int) inPhyPort.port().toLong())); |
| 213 | break; |
| 214 | case METADATA: |
| 215 | MetadataCriterion metadata = (MetadataCriterion) c; |
| 216 | mBuilder.setExact(MatchField.METADATA, |
| 217 | OFMetadata.ofRaw(metadata.metadata())); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 218 | break; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 219 | case ETH_DST: |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 220 | ethCriterion = (EthCriterion) c; |
| 221 | mBuilder.setExact(MatchField.ETH_DST, |
| 222 | MacAddress.of(ethCriterion.mac().toLong())); |
| 223 | break; |
| 224 | case ETH_SRC: |
| 225 | ethCriterion = (EthCriterion) c; |
| 226 | mBuilder.setExact(MatchField.ETH_SRC, |
| 227 | MacAddress.of(ethCriterion.mac().toLong())); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 228 | break; |
| 229 | case ETH_TYPE: |
| 230 | EthTypeCriterion ethType = (EthTypeCriterion) c; |
alshabib | caf1ca2 | 2015-06-25 15:18:16 -0700 | [diff] [blame] | 231 | mBuilder.setExact(MatchField.ETH_TYPE, EthType.of(ethType.ethType().toShort())); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 232 | break; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 233 | case VLAN_VID: |
| 234 | VlanIdCriterion vid = (VlanIdCriterion) c; |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 235 | |
| 236 | if (vid.vlanId().equals(VlanId.ANY)) { |
| 237 | mBuilder.setMasked(MatchField.VLAN_VID, OFVlanVidMatch.PRESENT, |
| 238 | OFVlanVidMatch.PRESENT); |
Jonathan Hart | 1468fee | 2015-07-16 18:50:34 -0700 | [diff] [blame] | 239 | } else if (vid.vlanId().equals(VlanId.NONE)) { |
| 240 | mBuilder.setExact(MatchField.VLAN_VID, OFVlanVidMatch.NONE); |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 241 | } else { |
| 242 | mBuilder.setExact(MatchField.VLAN_VID, |
Charles Chan | 14967c2 | 2015-12-07 11:11:50 -0800 | [diff] [blame^] | 243 | OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vid.vlanId().toShort()))); |
Jonathan Hart | 6cd2f35 | 2015-01-13 17:44:45 -0800 | [diff] [blame] | 244 | } |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 245 | break; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 246 | case VLAN_PCP: |
| 247 | VlanPcpCriterion vpcp = (VlanPcpCriterion) c; |
| 248 | mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority())); |
| 249 | break; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 250 | case IP_DSCP: |
| 251 | IPDscpCriterion ipDscpCriterion = (IPDscpCriterion) c; |
| 252 | mBuilder.setExact(MatchField.IP_DSCP, |
| 253 | IpDscp.of(ipDscpCriterion.ipDscp())); |
| 254 | break; |
| 255 | case IP_ECN: |
| 256 | IPEcnCriterion ipEcnCriterion = (IPEcnCriterion) c; |
| 257 | mBuilder.setExact(MatchField.IP_ECN, |
| 258 | IpEcn.of(ipEcnCriterion.ipEcn())); |
| 259 | break; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 260 | case IP_PROTO: |
| 261 | IPProtocolCriterion p = (IPProtocolCriterion) c; |
| 262 | mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol())); |
| 263 | break; |
| 264 | case IPV4_SRC: |
| 265 | ipCriterion = (IPCriterion) c; |
| 266 | ip4Prefix = ipCriterion.ip().getIp4Prefix(); |
| 267 | if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) { |
| 268 | Ip4Address maskAddr = |
| 269 | Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength()); |
| 270 | Masked<IPv4Address> maskedIp = |
| 271 | Masked.of(IPv4Address.of(ip4Prefix.address().toInt()), |
| 272 | IPv4Address.of(maskAddr.toInt())); |
| 273 | mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp); |
| 274 | } else { |
| 275 | mBuilder.setExact(MatchField.IPV4_SRC, |
| 276 | IPv4Address.of(ip4Prefix.address().toInt())); |
| 277 | } |
| 278 | break; |
| 279 | case IPV4_DST: |
| 280 | ipCriterion = (IPCriterion) c; |
| 281 | ip4Prefix = ipCriterion.ip().getIp4Prefix(); |
| 282 | if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) { |
| 283 | Ip4Address maskAddr = |
| 284 | Ip4Address.makeMaskPrefix(ip4Prefix.prefixLength()); |
| 285 | Masked<IPv4Address> maskedIp = |
| 286 | Masked.of(IPv4Address.of(ip4Prefix.address().toInt()), |
| 287 | IPv4Address.of(maskAddr.toInt())); |
| 288 | mBuilder.setMasked(MatchField.IPV4_DST, maskedIp); |
| 289 | } else { |
| 290 | mBuilder.setExact(MatchField.IPV4_DST, |
| 291 | IPv4Address.of(ip4Prefix.address().toInt())); |
| 292 | } |
Jonathan Hart | 34bc614 | 2014-10-17 11:00:43 -0700 | [diff] [blame] | 293 | break; |
| 294 | case TCP_SRC: |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 295 | tcpPortCriterion = (TcpPortCriterion) c; |
| 296 | mBuilder.setExact(MatchField.TCP_SRC, |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 297 | TransportPort.of(tcpPortCriterion.tcpPort().toInt())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 298 | break; |
| 299 | case TCP_DST: |
| 300 | tcpPortCriterion = (TcpPortCriterion) c; |
| 301 | mBuilder.setExact(MatchField.TCP_DST, |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 302 | TransportPort.of(tcpPortCriterion.tcpPort().toInt())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 303 | break; |
| 304 | case UDP_SRC: |
| 305 | udpPortCriterion = (UdpPortCriterion) c; |
| 306 | mBuilder.setExact(MatchField.UDP_SRC, |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 307 | TransportPort.of(udpPortCriterion.udpPort().toInt())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 308 | break; |
| 309 | case UDP_DST: |
| 310 | udpPortCriterion = (UdpPortCriterion) c; |
| 311 | mBuilder.setExact(MatchField.UDP_DST, |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 312 | TransportPort.of(udpPortCriterion.udpPort().toInt())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 313 | break; |
| 314 | case SCTP_SRC: |
| 315 | sctpPortCriterion = (SctpPortCriterion) c; |
| 316 | mBuilder.setExact(MatchField.SCTP_SRC, |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 317 | TransportPort.of(sctpPortCriterion.sctpPort().toInt())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 318 | break; |
| 319 | case SCTP_DST: |
| 320 | sctpPortCriterion = (SctpPortCriterion) c; |
| 321 | mBuilder.setExact(MatchField.SCTP_DST, |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 322 | TransportPort.of(sctpPortCriterion.sctpPort().toInt())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 323 | break; |
| 324 | case ICMPV4_TYPE: |
| 325 | IcmpTypeCriterion icmpType = (IcmpTypeCriterion) c; |
| 326 | mBuilder.setExact(MatchField.ICMPV4_TYPE, |
| 327 | ICMPv4Type.of(icmpType.icmpType())); |
| 328 | break; |
| 329 | case ICMPV4_CODE: |
| 330 | IcmpCodeCriterion icmpCode = (IcmpCodeCriterion) c; |
| 331 | mBuilder.setExact(MatchField.ICMPV4_CODE, |
| 332 | ICMPv4Code.of(icmpCode.icmpCode())); |
| 333 | break; |
| 334 | case IPV6_SRC: |
| 335 | ipCriterion = (IPCriterion) c; |
| 336 | ip6Prefix = ipCriterion.ip().getIp6Prefix(); |
| 337 | if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) { |
| 338 | Ip6Address maskAddr = |
| 339 | Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength()); |
| 340 | Masked<IPv6Address> maskedIp = |
| 341 | Masked.of(IPv6Address.of(ip6Prefix.address().toString()), |
| 342 | IPv6Address.of(maskAddr.toString())); |
| 343 | mBuilder.setMasked(MatchField.IPV6_SRC, maskedIp); |
| 344 | } else { |
| 345 | mBuilder.setExact(MatchField.IPV6_SRC, |
| 346 | IPv6Address.of(ip6Prefix.address().toString())); |
| 347 | } |
| 348 | break; |
| 349 | case IPV6_DST: |
| 350 | ipCriterion = (IPCriterion) c; |
| 351 | ip6Prefix = ipCriterion.ip().getIp6Prefix(); |
| 352 | if (ip6Prefix.prefixLength() != Ip6Prefix.MAX_MASK_LENGTH) { |
| 353 | Ip6Address maskAddr = |
| 354 | Ip6Address.makeMaskPrefix(ip6Prefix.prefixLength()); |
| 355 | Masked<IPv6Address> maskedIp = |
| 356 | Masked.of(IPv6Address.of(ip6Prefix.address().toString()), |
| 357 | IPv6Address.of(maskAddr.toString())); |
| 358 | mBuilder.setMasked(MatchField.IPV6_DST, maskedIp); |
| 359 | } else { |
| 360 | mBuilder.setExact(MatchField.IPV6_DST, |
| 361 | IPv6Address.of(ip6Prefix.address().toString())); |
| 362 | } |
| 363 | break; |
| 364 | case IPV6_FLABEL: |
| 365 | IPv6FlowLabelCriterion flowLabelCriterion = |
| 366 | (IPv6FlowLabelCriterion) c; |
| 367 | mBuilder.setExact(MatchField.IPV6_FLABEL, |
| 368 | IPv6FlowLabel.of(flowLabelCriterion.flowLabel())); |
| 369 | break; |
| 370 | case ICMPV6_TYPE: |
| 371 | Icmpv6TypeCriterion icmpv6Type = (Icmpv6TypeCriterion) c; |
| 372 | mBuilder.setExact(MatchField.ICMPV6_TYPE, |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 373 | U8.of(icmpv6Type.icmpv6Type())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 374 | break; |
| 375 | case ICMPV6_CODE: |
| 376 | Icmpv6CodeCriterion icmpv6Code = (Icmpv6CodeCriterion) c; |
| 377 | mBuilder.setExact(MatchField.ICMPV6_CODE, |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 378 | U8.of(icmpv6Code.icmpv6Code())); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 379 | break; |
| 380 | case IPV6_ND_TARGET: |
| 381 | IPv6NDTargetAddressCriterion targetAddressCriterion = |
| 382 | (IPv6NDTargetAddressCriterion) c; |
| 383 | ip6Address = targetAddressCriterion.targetAddress(); |
| 384 | mBuilder.setExact(MatchField.IPV6_ND_TARGET, |
| 385 | IPv6Address.of(ip6Address.toOctets())); |
| 386 | break; |
| 387 | case IPV6_ND_SLL: |
| 388 | llAddressCriterion = |
| 389 | (IPv6NDLinkLayerAddressCriterion) c; |
| 390 | mBuilder.setExact(MatchField.IPV6_ND_SLL, |
| 391 | MacAddress.of(llAddressCriterion.mac().toLong())); |
| 392 | break; |
| 393 | case IPV6_ND_TLL: |
| 394 | llAddressCriterion = |
| 395 | (IPv6NDLinkLayerAddressCriterion) c; |
| 396 | mBuilder.setExact(MatchField.IPV6_ND_TLL, |
| 397 | MacAddress.of(llAddressCriterion.mac().toLong())); |
Jonathan Hart | 34bc614 | 2014-10-17 11:00:43 -0700 | [diff] [blame] | 398 | break; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 399 | case MPLS_LABEL: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 400 | MplsCriterion mp = (MplsCriterion) c; |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 401 | mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label().toInt())); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 402 | break; |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 403 | case IPV6_EXTHDR: |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 404 | IPv6ExthdrFlagsCriterion exthdrFlagsCriterion = |
| 405 | (IPv6ExthdrFlagsCriterion) c; |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 406 | mBuilder.setExact(MatchField.IPV6_EXTHDR, |
| 407 | U16.of(exthdrFlagsCriterion.exthdrFlags())); |
| 408 | break; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 409 | case OCH_SIGID: |
Sho SHIMIZU | c15ce51 | 2015-05-26 16:54:08 -0700 | [diff] [blame] | 410 | try { |
| 411 | OchSignalCriterion ochSignalCriterion = (OchSignalCriterion) c; |
| 412 | OchSignal signal = ochSignalCriterion.lambda(); |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 413 | byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType()); |
| 414 | byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing()); |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 415 | mBuilder.setExact(MatchField.EXP_OCH_SIG_ID, |
Sho SHIMIZU | c15ce51 | 2015-05-26 16:54:08 -0700 | [diff] [blame] | 416 | new CircuitSignalID(gridType, channelSpacing, |
| 417 | (short) signal.spacingMultiplier(), (short) signal.slotGranularity())); |
Sho SHIMIZU | c17042d | 2015-05-28 12:07:23 -0700 | [diff] [blame] | 418 | } catch (NoMappingFoundException e) { |
Sho SHIMIZU | c15ce51 | 2015-05-26 16:54:08 -0700 | [diff] [blame] | 419 | log.warn(e.getMessage()); |
| 420 | } |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 421 | break; |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 422 | case OCH_SIGTYPE: |
Yafit Hadar | 7351461 | 2015-11-04 10:14:21 +0200 | [diff] [blame] | 423 | try { |
| 424 | OchSignalTypeCriterion sc = (OchSignalTypeCriterion) c; |
| 425 | byte signalType = OpenFlowValueMapper.lookupOchSignalType(sc.signalType()); |
| 426 | mBuilder.setExact(MatchField.EXP_OCH_SIGTYPE, U8.of(signalType)); |
| 427 | } catch (NoMappingFoundException e) { |
| 428 | log.warn(e.getMessage()); |
| 429 | } |
| 430 | break; |
| 431 | case ODU_SIGID: |
| 432 | OduSignalIdCriterion oduSignalIdCriterion = (OduSignalIdCriterion) c; |
| 433 | OduSignalId oduSignalId = oduSignalIdCriterion.oduSignalId(); |
| 434 | mBuilder.setExact(MatchField.EXP_ODU_SIG_ID, |
| 435 | new OduSignalID((short) oduSignalId.tributaryPortNumber(), |
| 436 | (short) oduSignalId.tributarySlotLength(), |
| 437 | oduSignalId.tributarySlotBitmap())); |
| 438 | break; |
| 439 | case ODU_SIGTYPE: |
| 440 | try { |
| 441 | OduSignalTypeCriterion oduSignalTypeCriterion = (OduSignalTypeCriterion) c; |
| 442 | byte oduSigType = OpenFlowValueMapper.lookupOduSignalType(oduSignalTypeCriterion.signalType()); |
| 443 | mBuilder.setExact(MatchField.EXP_ODU_SIGTYPE, U8.of(oduSigType)); |
| 444 | } catch (NoMappingFoundException e) { |
| 445 | log.warn(e.getMessage()); |
| 446 | } |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 447 | break; |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 448 | case TUNNEL_ID: |
| 449 | TunnelIdCriterion tunnelId = (TunnelIdCriterion) c; |
| 450 | mBuilder.setExact(MatchField.TUNNEL_ID, |
| 451 | U64.of(tunnelId.tunnelId())); |
| 452 | break; |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 453 | case MPLS_BOS: |
| 454 | MplsBosCriterion mplsBos = (MplsBosCriterion) c; |
| 455 | mBuilder.setExact(MatchField.MPLS_BOS, |
| 456 | mplsBos.mplsBos() ? OFBooleanValue.TRUE |
| 457 | : OFBooleanValue.FALSE); |
| 458 | break; |
BitOhenry | b40129a | 2015-11-30 12:41:18 +0800 | [diff] [blame] | 459 | case ARP_OP: |
| 460 | ArpOpCriterion arpOp = (ArpOpCriterion) c; |
| 461 | mBuilder.setExact(MatchField.ARP_OP, |
| 462 | ArpOpcode.of(arpOp.arpOp())); |
| 463 | break; |
BitOhenry | a331b18 | 2015-11-23 08:39:37 +0800 | [diff] [blame] | 464 | case ARP_SHA: |
| 465 | arpHaCriterion = (ArpHaCriterion) c; |
| 466 | mBuilder.setExact(MatchField.ARP_SHA, |
| 467 | MacAddress.of(arpHaCriterion.mac().toLong())); |
| 468 | break; |
BitOhenry | 296b454 | 2015-11-24 08:41:58 +0800 | [diff] [blame] | 469 | case ARP_SPA: |
| 470 | arpPaCriterion = (ArpPaCriterion) c; |
| 471 | mBuilder.setExact(MatchField.ARP_SPA, |
| 472 | IPv4Address.of(arpPaCriterion.ip().toInt())); |
| 473 | break; |
BitOhenry | 7643085 | 2015-11-20 19:04:49 +0800 | [diff] [blame] | 474 | case ARP_THA: |
| 475 | arpHaCriterion = (ArpHaCriterion) c; |
| 476 | mBuilder.setExact(MatchField.ARP_THA, |
| 477 | MacAddress.of(arpHaCriterion.mac().toLong())); |
| 478 | break; |
BitOhenry | c1e5fcc | 2015-11-23 20:47:53 +0800 | [diff] [blame] | 479 | case ARP_TPA: |
| 480 | arpPaCriterion = (ArpPaCriterion) c; |
| 481 | mBuilder.setExact(MatchField.ARP_TPA, |
| 482 | IPv4Address.of(arpPaCriterion.ip().toInt())); |
| 483 | break; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 484 | case EXTENSION: |
| 485 | ExtensionCriterion extensionCriterion = (ExtensionCriterion) c; |
| 486 | OFOxm oxm = buildExtensionOxm(extensionCriterion.extensionSelector()); |
| 487 | if (oxm == null) { |
| 488 | log.warn("Unable to build extension selector"); |
| 489 | break; |
| 490 | } |
| 491 | |
| 492 | if (oxm.isMasked()) { |
| 493 | mBuilder.setMasked(oxm.getMatchField(), oxm.getValue(), oxm.getMask()); |
| 494 | } else { |
| 495 | mBuilder.setExact(oxm.getMatchField(), oxm.getValue()); |
| 496 | } |
| 497 | |
| 498 | break; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 499 | case MPLS_TC: |
| 500 | case PBB_ISID: |
Jian Li | f1ecf99 | 2015-12-02 17:48:54 -0800 | [diff] [blame] | 501 | // TODO: need to implement PBB-ISID case when OpenFlowJ is ready |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 502 | default: |
| 503 | log.warn("Match type {} not yet implemented.", c.type()); |
| 504 | } |
| 505 | } |
| 506 | return mBuilder.build(); |
| 507 | } |
| 508 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 509 | /** |
| 510 | * Returns the flow rule for this builder. |
| 511 | * |
| 512 | * @return the flow rule |
| 513 | */ |
| 514 | protected FlowRule flowRule() { |
| 515 | return flowRule; |
| 516 | } |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 517 | |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 518 | /** |
| 519 | * Returns the factory used for building OpenFlow constructs. |
| 520 | * |
| 521 | * @return the factory |
| 522 | */ |
| 523 | protected OFFactory factory() { |
| 524 | return factory; |
| 525 | } |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 526 | |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 527 | private OFOxm buildExtensionOxm(ExtensionSelector extension) { |
| 528 | if (!driverService.isPresent()) { |
| 529 | log.error("No driver service present"); |
| 530 | return null; |
| 531 | } |
| 532 | Driver driver = driverService.get().getDriver(deviceId); |
| 533 | if (driver.hasBehaviour(ExtensionSelectorInterpreter.class)) { |
| 534 | DefaultDriverHandler handler = |
| 535 | new DefaultDriverHandler(new DefaultDriverData(driver, deviceId)); |
| 536 | ExtensionSelectorInterpreter interpreter = handler.behaviour(ExtensionSelectorInterpreter.class); |
| 537 | |
| 538 | return interpreter.mapSelector(factory(), extension); |
| 539 | } |
| 540 | |
| 541 | return null; |
| 542 | } |
| 543 | |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 544 | } |