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