Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 19 | package org.onlab.onos.provider.of.flow.impl; |
| 20 | |
| 21 | import static org.slf4j.LoggerFactory.getLogger; |
| 22 | |
| 23 | import java.util.List; |
| 24 | |
| 25 | import org.onlab.onos.net.DeviceId; |
| 26 | import org.onlab.onos.net.PortNumber; |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 27 | import org.onlab.onos.net.flow.DefaultFlowEntry; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 28 | import org.onlab.onos.net.flow.DefaultFlowRule; |
| 29 | import org.onlab.onos.net.flow.DefaultTrafficSelector; |
| 30 | import org.onlab.onos.net.flow.DefaultTrafficTreatment; |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 31 | import org.onlab.onos.net.flow.FlowEntry; |
| 32 | import org.onlab.onos.net.flow.FlowEntry.FlowEntryState; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 33 | import org.onlab.onos.net.flow.FlowRule; |
| 34 | import org.onlab.onos.net.flow.TrafficSelector; |
| 35 | import org.onlab.onos.net.flow.TrafficTreatment; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 36 | import org.onlab.onos.openflow.controller.Dpid; |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 37 | import org.onlab.packet.IpPrefix; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 38 | import org.onlab.packet.MacAddress; |
| 39 | import org.onlab.packet.VlanId; |
| 40 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
| 41 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 42 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 43 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 44 | import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; |
| 45 | import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 46 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
| 47 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst; |
| 48 | import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc; |
| 49 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst; |
| 50 | import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc; |
| 51 | import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp; |
| 52 | import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 53 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 54 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 55 | import org.projectfloodlight.openflow.protocol.match.Match; |
| 56 | import org.projectfloodlight.openflow.protocol.match.MatchField; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 57 | import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 58 | import org.projectfloodlight.openflow.types.IPv4Address; |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 59 | import org.projectfloodlight.openflow.types.Masked; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 60 | import org.slf4j.Logger; |
| 61 | |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 62 | import com.google.common.collect.Lists; |
| 63 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 64 | public class FlowEntryBuilder { |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 65 | private final Logger log = getLogger(getClass()); |
| 66 | |
| 67 | private final OFFlowStatsEntry stat; |
| 68 | private final OFFlowRemoved removed; |
| 69 | |
| 70 | private final Match match; |
| 71 | private final List<OFAction> actions; |
| 72 | |
| 73 | private final Dpid dpid; |
| 74 | |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 75 | private final boolean addedRule; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 76 | |
| 77 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 78 | public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry) { |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 79 | this.stat = entry; |
| 80 | this.match = entry.getMatch(); |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 81 | this.actions = getActions(entry); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 82 | this.dpid = dpid; |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 83 | this.removed = null; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 84 | this.addedRule = true; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 85 | } |
| 86 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 87 | public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed) { |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 88 | this.match = removed.getMatch(); |
| 89 | this.removed = removed; |
| 90 | |
| 91 | this.dpid = dpid; |
| 92 | this.actions = null; |
| 93 | this.stat = null; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 94 | this.addedRule = false; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 95 | |
| 96 | } |
| 97 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 98 | public FlowEntry build() { |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 99 | if (addedRule) { |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 100 | FlowRule rule = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 101 | buildSelector(), buildTreatment(), stat.getPriority(), |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 102 | stat.getCookie().getValue(), stat.getIdleTimeout(), false); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 103 | return new DefaultFlowEntry(rule, FlowEntryState.ADDED, |
| 104 | stat.getDurationSec(), stat.getPacketCount().getValue(), |
| 105 | stat.getByteCount().getValue()); |
| 106 | |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 107 | } else { |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 108 | FlowRule rule = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 109 | buildSelector(), null, removed.getPriority(), |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 110 | removed.getCookie().getValue(), removed.getIdleTimeout(), false); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 111 | return new DefaultFlowEntry(rule, FlowEntryState.REMOVED, removed.getDurationSec(), |
| 112 | removed.getPacketCount().getValue(), removed.getByteCount().getValue()); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 113 | } |
| 114 | } |
| 115 | |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 116 | private List<OFAction> getActions(OFFlowStatsEntry entry) { |
| 117 | switch (entry.getVersion()) { |
| 118 | case OF_10: |
| 119 | return entry.getActions(); |
| 120 | case OF_11: |
| 121 | case OF_12: |
| 122 | case OF_13: |
| 123 | List<OFInstruction> ins = entry.getInstructions(); |
| 124 | for (OFInstruction in : ins) { |
Jonathan Hart | 86e5935 | 2014-10-22 10:42:16 -0700 | [diff] [blame] | 125 | if (in.getType().equals(OFInstructionType.WRITE_ACTIONS)) { |
| 126 | OFInstructionWriteActions apply = (OFInstructionWriteActions) in; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 127 | return apply.getActions(); |
| 128 | } |
| 129 | } |
| 130 | return Lists.newLinkedList(); |
| 131 | default: |
| 132 | log.warn("Unknown OF version {}", entry.getVersion()); |
| 133 | } |
| 134 | return Lists.newLinkedList(); |
| 135 | } |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 136 | |
| 137 | private TrafficTreatment buildTreatment() { |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 138 | TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 139 | // If this is a drop rule |
| 140 | if (actions.size() == 0) { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 141 | builder.drop(); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 142 | return builder.build(); |
| 143 | } |
| 144 | for (OFAction act : actions) { |
| 145 | switch (act.getType()) { |
| 146 | case OUTPUT: |
| 147 | OFActionOutput out = (OFActionOutput) act; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 148 | builder.setOutput( |
| 149 | PortNumber.portNumber(out.getPort().getPortNumber())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 150 | break; |
| 151 | case SET_VLAN_VID: |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 152 | OFActionSetVlanVid vlan = (OFActionSetVlanVid) act; |
| 153 | builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan())); |
| 154 | break; |
| 155 | case SET_VLAN_PCP: |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 156 | OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 157 | builder.setVlanId(VlanId.vlanId(pcp.getVlanPcp().getValue())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 158 | break; |
| 159 | case SET_DL_DST: |
| 160 | OFActionSetDlDst dldst = (OFActionSetDlDst) act; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 161 | builder.setEthDst( |
| 162 | MacAddress.valueOf(dldst.getDlAddr().getLong())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 163 | break; |
| 164 | case SET_DL_SRC: |
| 165 | OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 166 | builder.setEthSrc( |
| 167 | MacAddress.valueOf(dlsrc.getDlAddr().getLong())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 168 | |
| 169 | break; |
| 170 | case SET_NW_DST: |
| 171 | OFActionSetNwDst nwdst = (OFActionSetNwDst) act; |
| 172 | IPv4Address di = nwdst.getNwAddr(); |
| 173 | if (di.isCidrMask()) { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 174 | builder.setIpDst(IpPrefix.valueOf(di.getInt(), |
| 175 | di.asCidrMaskLength())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 176 | } else { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 177 | builder.setIpDst(IpPrefix.valueOf(di.getInt())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 178 | } |
| 179 | break; |
| 180 | case SET_NW_SRC: |
| 181 | OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act; |
| 182 | IPv4Address si = nwsrc.getNwAddr(); |
| 183 | if (si.isCidrMask()) { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 184 | builder.setIpSrc(IpPrefix.valueOf(si.getInt(), |
| 185 | si.asCidrMaskLength())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 186 | } else { |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 187 | builder.setIpSrc(IpPrefix.valueOf(si.getInt())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 188 | } |
| 189 | break; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 190 | case EXPERIMENTER: |
| 191 | OFActionExperimenter exp = (OFActionExperimenter) act; |
| 192 | if (exp.getExperimenter() == 0x80005A06) { |
| 193 | OFActionCircuit ct = (OFActionCircuit) exp; |
| 194 | builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber()); |
| 195 | } else { |
| 196 | log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter()); |
| 197 | } |
| 198 | break; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 199 | case SET_TP_DST: |
| 200 | case SET_TP_SRC: |
| 201 | case POP_MPLS: |
| 202 | case POP_PBB: |
| 203 | case POP_VLAN: |
| 204 | case PUSH_MPLS: |
| 205 | case PUSH_PBB: |
| 206 | case PUSH_VLAN: |
| 207 | case SET_FIELD: |
| 208 | case SET_MPLS_LABEL: |
| 209 | case SET_MPLS_TC: |
| 210 | case SET_MPLS_TTL: |
| 211 | case SET_NW_ECN: |
| 212 | case SET_NW_TOS: |
| 213 | case SET_NW_TTL: |
| 214 | case SET_QUEUE: |
| 215 | case STRIP_VLAN: |
| 216 | case COPY_TTL_IN: |
| 217 | case COPY_TTL_OUT: |
| 218 | case DEC_MPLS_TTL: |
| 219 | case DEC_NW_TTL: |
| 220 | case ENQUEUE: |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 221 | |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 222 | case GROUP: |
| 223 | default: |
| 224 | log.warn("Action type {} not yet implemented.", act.getType()); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return builder.build(); |
| 229 | } |
| 230 | |
| 231 | private TrafficSelector buildSelector() { |
tom | 9a693fd | 2014-10-03 11:32:19 -0700 | [diff] [blame] | 232 | TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 233 | for (MatchField<?> field : match.getMatchFields()) { |
| 234 | switch (field.id) { |
| 235 | case IN_PORT: |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 236 | builder.matchInport(PortNumber |
| 237 | .portNumber(match.get(MatchField.IN_PORT).getPortNumber())); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 238 | break; |
| 239 | case ETH_SRC: |
| 240 | MacAddress sMac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong()); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 241 | builder.matchEthSrc(sMac); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 242 | break; |
| 243 | case ETH_DST: |
| 244 | MacAddress dMac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong()); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 245 | builder.matchEthDst(dMac); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 246 | break; |
| 247 | case ETH_TYPE: |
| 248 | int ethType = match.get(MatchField.ETH_TYPE).getValue(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 249 | builder.matchEthType((short) ethType); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 250 | break; |
| 251 | case IPV4_DST: |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 252 | IpPrefix dip; |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 253 | if (match.isPartiallyMasked(MatchField.IPV4_DST)) { |
| 254 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST); |
| 255 | |
| 256 | dip = IpPrefix.valueOf( |
| 257 | maskedIp.getValue().getInt(), |
| 258 | maskedIp.getMask().asCidrMaskLength()); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 259 | } else { |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 260 | dip = IpPrefix.valueOf( |
| 261 | match.get(MatchField.IPV4_DST).getInt(), |
| 262 | IpPrefix.MAX_INET_MASK); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 263 | } |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 264 | |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 265 | builder.matchIPDst(dip); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 266 | break; |
| 267 | case IPV4_SRC: |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 268 | IpPrefix sip; |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 269 | if (match.isPartiallyMasked(MatchField.IPV4_SRC)) { |
| 270 | Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC); |
| 271 | |
| 272 | sip = IpPrefix.valueOf( |
| 273 | maskedIp.getValue().getInt(), |
| 274 | maskedIp.getMask().asCidrMaskLength()); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 275 | } else { |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 276 | sip = IpPrefix.valueOf( |
| 277 | match.get(MatchField.IPV4_SRC).getInt(), |
| 278 | IpPrefix.MAX_INET_MASK); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 279 | } |
Jonathan Hart | 0e12fad | 2014-10-17 14:54:58 -0700 | [diff] [blame] | 280 | |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 281 | builder.matchIPSrc(sip); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 282 | break; |
| 283 | case IP_PROTO: |
| 284 | short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 285 | builder.matchIPProtocol((byte) proto); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 286 | break; |
| 287 | case VLAN_PCP: |
| 288 | byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue(); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 289 | builder.matchVlanPcp(vlanPcp); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 290 | break; |
| 291 | case VLAN_VID: |
| 292 | VlanId vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan()); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 293 | builder.matchVlanId(vlanId); |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 294 | break; |
Jonathan Hart | 34bc614 | 2014-10-17 11:00:43 -0700 | [diff] [blame] | 295 | case TCP_DST: |
| 296 | builder.matchTcpDst((short) match.get(MatchField.TCP_DST).getPort()); |
| 297 | break; |
| 298 | case TCP_SRC: |
| 299 | builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort()); |
| 300 | break; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 301 | case OCH_SIGID: |
| 302 | builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber()); |
| 303 | break; |
| 304 | case OCH_SIGTYPE_BASIC: |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 305 | case ARP_OP: |
| 306 | case ARP_SHA: |
| 307 | case ARP_SPA: |
| 308 | case ARP_THA: |
| 309 | case ARP_TPA: |
| 310 | case ICMPV4_CODE: |
| 311 | case ICMPV4_TYPE: |
| 312 | case ICMPV6_CODE: |
| 313 | case ICMPV6_TYPE: |
| 314 | case IN_PHY_PORT: |
| 315 | case IPV6_DST: |
| 316 | case IPV6_FLABEL: |
| 317 | case IPV6_ND_SLL: |
| 318 | case IPV6_ND_TARGET: |
| 319 | case IPV6_ND_TLL: |
| 320 | case IPV6_SRC: |
| 321 | case IP_DSCP: |
| 322 | case IP_ECN: |
| 323 | case METADATA: |
| 324 | case MPLS_LABEL: |
| 325 | case MPLS_TC: |
| 326 | case SCTP_DST: |
| 327 | case SCTP_SRC: |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 328 | case TUNNEL_ID: |
| 329 | case UDP_DST: |
| 330 | case UDP_SRC: |
| 331 | default: |
| 332 | log.warn("Match type {} not yet implemented.", field.id); |
| 333 | |
| 334 | |
| 335 | } |
| 336 | } |
| 337 | return builder.build(); |
| 338 | } |
| 339 | |
| 340 | } |