blob: e6060a28046a36f67c9f9aef74d2d788ffb79ce6 [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska781d18b2014-10-27 10:31:25 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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 Vachuska781d18b2014-10-27 10:31:25 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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 Vachuska781d18b2014-10-27 10:31:25 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.provider.of.flow.impl;
alshabib6b5cfec2014-09-18 17:42:18 -070017
18import static org.slf4j.LoggerFactory.getLogger;
19
20import java.util.List;
21
Jonathan Hartd0ef7522014-12-11 11:51:18 -080022import org.onlab.packet.Ip4Address;
23import org.onlab.packet.Ip4Prefix;
24import org.onlab.packet.MacAddress;
25import org.onlab.packet.VlanId;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.net.DeviceId;
27import org.onosproject.net.PortNumber;
28import org.onosproject.net.flow.DefaultFlowEntry;
29import org.onosproject.net.flow.DefaultFlowRule;
30import org.onosproject.net.flow.DefaultTrafficSelector;
31import org.onosproject.net.flow.DefaultTrafficTreatment;
32import org.onosproject.net.flow.FlowEntry;
33import org.onosproject.net.flow.FlowEntry.FlowEntryState;
34import org.onosproject.net.flow.FlowRule;
35import org.onosproject.net.flow.TrafficSelector;
36import org.onosproject.net.flow.TrafficTreatment;
37import org.onosproject.openflow.controller.Dpid;
alshabib6b5cfec2014-09-18 17:42:18 -070038import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
39import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
alshabib19fdc122014-10-03 11:38:19 -070040import org.projectfloodlight.openflow.protocol.OFInstructionType;
alshabib6b5cfec2014-09-18 17:42:18 -070041import org.projectfloodlight.openflow.protocol.action.OFAction;
Marc De Leenheer49087752014-10-23 13:54:09 -070042import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
43import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter;
alshabib6b5cfec2014-09-18 17:42:18 -070044import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
45import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst;
46import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080047import org.projectfloodlight.openflow.protocol.action.OFActionSetField;
alshabib6b5cfec2014-09-18 17:42:18 -070048import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst;
49import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc;
50import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp;
51import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid;
alshabib19fdc122014-10-03 11:38:19 -070052import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
Jonathan Hartcf783202014-11-24 18:55:42 -080053import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
alshabib6b5cfec2014-09-18 17:42:18 -070054import org.projectfloodlight.openflow.protocol.match.Match;
55import org.projectfloodlight.openflow.protocol.match.MatchField;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080056import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
Marc De Leenheer49087752014-10-23 13:54:09 -070057import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
alshabib6b5cfec2014-09-18 17:42:18 -070058import org.projectfloodlight.openflow.types.IPv4Address;
Jonathan Hart0e12fad2014-10-17 14:54:58 -070059import org.projectfloodlight.openflow.types.Masked;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080060import org.projectfloodlight.openflow.types.OFVlanVidMatch;
61import org.projectfloodlight.openflow.types.VlanPcp;
alshabib6b5cfec2014-09-18 17:42:18 -070062import org.slf4j.Logger;
63
alshabib19fdc122014-10-03 11:38:19 -070064import com.google.common.collect.Lists;
65
alshabib1c319ff2014-10-04 20:29:09 -070066public class FlowEntryBuilder {
alshabib6b5cfec2014-09-18 17:42:18 -070067 private final Logger log = getLogger(getClass());
68
69 private final OFFlowStatsEntry stat;
70 private final OFFlowRemoved removed;
71
72 private final Match match;
73 private final List<OFAction> actions;
74
75 private final Dpid dpid;
76
alshabib19fdc122014-10-03 11:38:19 -070077 private final boolean addedRule;
alshabib6b5cfec2014-09-18 17:42:18 -070078
79
alshabib1c319ff2014-10-04 20:29:09 -070080 public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry) {
alshabib6b5cfec2014-09-18 17:42:18 -070081 this.stat = entry;
82 this.match = entry.getMatch();
alshabib19fdc122014-10-03 11:38:19 -070083 this.actions = getActions(entry);
alshabib6b5cfec2014-09-18 17:42:18 -070084 this.dpid = dpid;
alshabib219ebaa2014-09-22 15:41:24 -070085 this.removed = null;
alshabib19fdc122014-10-03 11:38:19 -070086 this.addedRule = true;
alshabib6b5cfec2014-09-18 17:42:18 -070087 }
88
alshabib1c319ff2014-10-04 20:29:09 -070089 public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed) {
alshabib6b5cfec2014-09-18 17:42:18 -070090 this.match = removed.getMatch();
91 this.removed = removed;
92
93 this.dpid = dpid;
94 this.actions = null;
95 this.stat = null;
alshabib19fdc122014-10-03 11:38:19 -070096 this.addedRule = false;
alshabib6b5cfec2014-09-18 17:42:18 -070097
98 }
99
alshabib1c319ff2014-10-04 20:29:09 -0700100 public FlowEntry build() {
alshabib19fdc122014-10-03 11:38:19 -0700101 if (addedRule) {
alshabib1c319ff2014-10-04 20:29:09 -0700102 FlowRule rule = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)),
alshabib6b5cfec2014-09-18 17:42:18 -0700103 buildSelector(), buildTreatment(), stat.getPriority(),
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700104 stat.getCookie().getValue(), stat.getIdleTimeout(), false);
alshabib1c319ff2014-10-04 20:29:09 -0700105 return new DefaultFlowEntry(rule, FlowEntryState.ADDED,
106 stat.getDurationSec(), stat.getPacketCount().getValue(),
107 stat.getByteCount().getValue());
108
alshabib6b5cfec2014-09-18 17:42:18 -0700109 } else {
alshabib1c319ff2014-10-04 20:29:09 -0700110 FlowRule rule = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)),
alshabib6b5cfec2014-09-18 17:42:18 -0700111 buildSelector(), null, removed.getPriority(),
Jonathan Hartbc4a7932014-10-21 11:46:00 -0700112 removed.getCookie().getValue(), removed.getIdleTimeout(), false);
alshabib1c319ff2014-10-04 20:29:09 -0700113 return new DefaultFlowEntry(rule, FlowEntryState.REMOVED, removed.getDurationSec(),
114 removed.getPacketCount().getValue(), removed.getByteCount().getValue());
alshabib6b5cfec2014-09-18 17:42:18 -0700115 }
116 }
117
alshabib19fdc122014-10-03 11:38:19 -0700118 private List<OFAction> getActions(OFFlowStatsEntry entry) {
119 switch (entry.getVersion()) {
120 case OF_10:
121 return entry.getActions();
122 case OF_11:
123 case OF_12:
124 case OF_13:
125 List<OFInstruction> ins = entry.getInstructions();
126 for (OFInstruction in : ins) {
Jonathan Hartcf783202014-11-24 18:55:42 -0800127 if (in.getType().equals(OFInstructionType.APPLY_ACTIONS)) {
128 OFInstructionApplyActions apply = (OFInstructionApplyActions) in;
alshabib19fdc122014-10-03 11:38:19 -0700129 return apply.getActions();
130 }
131 }
132 return Lists.newLinkedList();
133 default:
134 log.warn("Unknown OF version {}", entry.getVersion());
135 }
136 return Lists.newLinkedList();
137 }
alshabib6b5cfec2014-09-18 17:42:18 -0700138
139 private TrafficTreatment buildTreatment() {
tom9a693fd2014-10-03 11:32:19 -0700140 TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
alshabib6b5cfec2014-09-18 17:42:18 -0700141 // If this is a drop rule
142 if (actions.size() == 0) {
alshabib010c31d2014-09-26 10:01:12 -0700143 builder.drop();
alshabib6b5cfec2014-09-18 17:42:18 -0700144 return builder.build();
145 }
146 for (OFAction act : actions) {
147 switch (act.getType()) {
148 case OUTPUT:
149 OFActionOutput out = (OFActionOutput) act;
alshabib010c31d2014-09-26 10:01:12 -0700150 builder.setOutput(
151 PortNumber.portNumber(out.getPort().getPortNumber()));
alshabib6b5cfec2014-09-18 17:42:18 -0700152 break;
153 case SET_VLAN_VID:
alshabib010c31d2014-09-26 10:01:12 -0700154 OFActionSetVlanVid vlan = (OFActionSetVlanVid) act;
155 builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan()));
156 break;
157 case SET_VLAN_PCP:
alshabib6b5cfec2014-09-18 17:42:18 -0700158 OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act;
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800159 builder.setVlanPcp(pcp.getVlanPcp().getValue());
alshabib6b5cfec2014-09-18 17:42:18 -0700160 break;
161 case SET_DL_DST:
162 OFActionSetDlDst dldst = (OFActionSetDlDst) act;
alshabib010c31d2014-09-26 10:01:12 -0700163 builder.setEthDst(
164 MacAddress.valueOf(dldst.getDlAddr().getLong()));
alshabib6b5cfec2014-09-18 17:42:18 -0700165 break;
166 case SET_DL_SRC:
167 OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act;
alshabib010c31d2014-09-26 10:01:12 -0700168 builder.setEthSrc(
169 MacAddress.valueOf(dlsrc.getDlAddr().getLong()));
alshabib6b5cfec2014-09-18 17:42:18 -0700170
171 break;
172 case SET_NW_DST:
173 OFActionSetNwDst nwdst = (OFActionSetNwDst) act;
174 IPv4Address di = nwdst.getNwAddr();
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800175 builder.setIpDst(Ip4Address.valueOf(di.getInt()));
alshabib6b5cfec2014-09-18 17:42:18 -0700176 break;
177 case SET_NW_SRC:
178 OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act;
179 IPv4Address si = nwsrc.getNwAddr();
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800180 builder.setIpSrc(Ip4Address.valueOf(si.getInt()));
alshabib6b5cfec2014-09-18 17:42:18 -0700181 break;
Marc De Leenheer49087752014-10-23 13:54:09 -0700182 case EXPERIMENTER:
183 OFActionExperimenter exp = (OFActionExperimenter) act;
Praseed Balakrishnandb8a9d22014-12-03 11:47:55 -0800184 if (exp.getExperimenter() == 0x80005A06 ||
185 exp.getExperimenter() == 0x748771) {
Marc De Leenheer49087752014-10-23 13:54:09 -0700186 OFActionCircuit ct = (OFActionCircuit) exp;
187 builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber());
188 } else {
189 log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
190 }
191 break;
Jonathan Hart1f8e0d72014-11-25 11:13:00 -0800192 case SET_FIELD:
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800193 OFActionSetField setField = (OFActionSetField) act;
194 handleSetField(builder, setField.getField());
Jonathan Hart1f8e0d72014-11-25 11:13:00 -0800195 break;
alshabib6b5cfec2014-09-18 17:42:18 -0700196 case SET_TP_DST:
197 case SET_TP_SRC:
198 case POP_MPLS:
199 case POP_PBB:
200 case POP_VLAN:
201 case PUSH_MPLS:
202 case PUSH_PBB:
203 case PUSH_VLAN:
alshabib6b5cfec2014-09-18 17:42:18 -0700204 case SET_MPLS_LABEL:
205 case SET_MPLS_TC:
206 case SET_MPLS_TTL:
207 case SET_NW_ECN:
208 case SET_NW_TOS:
209 case SET_NW_TTL:
210 case SET_QUEUE:
211 case STRIP_VLAN:
212 case COPY_TTL_IN:
213 case COPY_TTL_OUT:
214 case DEC_MPLS_TTL:
215 case DEC_NW_TTL:
216 case ENQUEUE:
Marc De Leenheer49087752014-10-23 13:54:09 -0700217
alshabib6b5cfec2014-09-18 17:42:18 -0700218 case GROUP:
219 default:
220 log.warn("Action type {} not yet implemented.", act.getType());
221 }
222 }
223
224 return builder.build();
225 }
226
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800227 private void handleSetField(TrafficTreatment.Builder builder, OFOxm<?> oxm) {
228 switch (oxm.getMatchField().id) {
229 case VLAN_PCP:
230 @SuppressWarnings("unchecked")
231 OFOxm<VlanPcp> vlanpcp = (OFOxm<VlanPcp>) oxm;
232 builder.setVlanPcp(vlanpcp.getValue().getValue());
233 break;
234 case VLAN_VID:
235 @SuppressWarnings("unchecked")
236 OFOxm<OFVlanVidMatch> vlanvid = (OFOxm<OFVlanVidMatch>) oxm;
237 builder.setVlanId(VlanId.vlanId(vlanvid.getValue().getVlan()));
238 break;
239 case ETH_DST:
240 @SuppressWarnings("unchecked")
241 OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethdst =
242 (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
243 builder.setEthDst(MacAddress.valueOf(ethdst.getValue().getLong()));
244 break;
245 case ETH_SRC:
246 @SuppressWarnings("unchecked")
247 OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethsrc =
248 (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
249 builder.setEthSrc(MacAddress.valueOf(ethsrc.getValue().getLong()));
250 break;
251 case IPV4_DST:
252 @SuppressWarnings("unchecked")
253 OFOxm<IPv4Address> ip4dst = (OFOxm<IPv4Address>) oxm;
254 builder.setIpDst(Ip4Address.valueOf(ip4dst.getValue().getInt()));
255 break;
256 case IPV4_SRC:
257 @SuppressWarnings("unchecked")
258 OFOxm<IPv4Address> ip4src = (OFOxm<IPv4Address>) oxm;
259 builder.setIpSrc(Ip4Address.valueOf(ip4src.getValue().getInt()));
260 break;
261 case ARP_OP:
262 case ARP_SHA:
263 case ARP_SPA:
264 case ARP_THA:
265 case ARP_TPA:
266 case BSN_EGR_PORT_GROUP_ID:
267 case BSN_GLOBAL_VRF_ALLOWED:
268 case BSN_IN_PORTS_128:
269 case BSN_L3_DST_CLASS_ID:
270 case BSN_L3_INTERFACE_CLASS_ID:
271 case BSN_L3_SRC_CLASS_ID:
272 case BSN_LAG_ID:
273 case BSN_TCP_FLAGS:
274 case BSN_UDF0:
275 case BSN_UDF1:
276 case BSN_UDF2:
277 case BSN_UDF3:
278 case BSN_UDF4:
279 case BSN_UDF5:
280 case BSN_UDF6:
281 case BSN_UDF7:
282 case BSN_VLAN_XLATE_PORT_GROUP_ID:
283 case BSN_VRF:
284 case ETH_TYPE:
285 case ICMPV4_CODE:
286 case ICMPV4_TYPE:
287 case ICMPV6_CODE:
288 case ICMPV6_TYPE:
289 case IN_PHY_PORT:
290 case IN_PORT:
291 case IPV6_DST:
292 case IPV6_FLABEL:
293 case IPV6_ND_SLL:
294 case IPV6_ND_TARGET:
295 case IPV6_ND_TLL:
296 case IPV6_SRC:
297 case IP_DSCP:
298 case IP_ECN:
299 case IP_PROTO:
300 case METADATA:
301 case MPLS_LABEL:
302 case MPLS_TC:
303 case OCH_SIGID:
304 case OCH_SIGID_BASIC:
305 case OCH_SIGTYPE:
306 case OCH_SIGTYPE_BASIC:
307 case SCTP_DST:
308 case SCTP_SRC:
309 case TCP_DST:
310 case TCP_SRC:
311 case TUNNEL_ID:
312 case UDP_DST:
313 case UDP_SRC:
314 default:
315 log.warn("Set field type {} not yet implemented.", oxm.getMatchField().id);
316 break;
317 }
318 }
319
alshabib6b5cfec2014-09-18 17:42:18 -0700320 private TrafficSelector buildSelector() {
tom9a693fd2014-10-03 11:32:19 -0700321 TrafficSelector.Builder builder = DefaultTrafficSelector.builder();
alshabib6b5cfec2014-09-18 17:42:18 -0700322 for (MatchField<?> field : match.getMatchFields()) {
323 switch (field.id) {
324 case IN_PORT:
alshabib010c31d2014-09-26 10:01:12 -0700325 builder.matchInport(PortNumber
326 .portNumber(match.get(MatchField.IN_PORT).getPortNumber()));
alshabib6b5cfec2014-09-18 17:42:18 -0700327 break;
328 case ETH_SRC:
329 MacAddress sMac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong());
alshabib010c31d2014-09-26 10:01:12 -0700330 builder.matchEthSrc(sMac);
alshabib6b5cfec2014-09-18 17:42:18 -0700331 break;
332 case ETH_DST:
333 MacAddress dMac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong());
alshabib010c31d2014-09-26 10:01:12 -0700334 builder.matchEthDst(dMac);
alshabib6b5cfec2014-09-18 17:42:18 -0700335 break;
336 case ETH_TYPE:
337 int ethType = match.get(MatchField.ETH_TYPE).getValue();
alshabib010c31d2014-09-26 10:01:12 -0700338 builder.matchEthType((short) ethType);
alshabib6b5cfec2014-09-18 17:42:18 -0700339 break;
340 case IPV4_DST:
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800341 Ip4Prefix dip;
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700342 if (match.isPartiallyMasked(MatchField.IPV4_DST)) {
343 Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST);
344
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800345 dip = Ip4Prefix.valueOf(
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700346 maskedIp.getValue().getInt(),
347 maskedIp.getMask().asCidrMaskLength());
alshabib6b5cfec2014-09-18 17:42:18 -0700348 } else {
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800349 dip = Ip4Prefix.valueOf(
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700350 match.get(MatchField.IPV4_DST).getInt(),
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800351 Ip4Prefix.MAX_MASK_LENGTH);
alshabib6b5cfec2014-09-18 17:42:18 -0700352 }
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700353
alshabib010c31d2014-09-26 10:01:12 -0700354 builder.matchIPDst(dip);
alshabib6b5cfec2014-09-18 17:42:18 -0700355 break;
356 case IPV4_SRC:
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800357 Ip4Prefix sip;
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700358 if (match.isPartiallyMasked(MatchField.IPV4_SRC)) {
359 Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC);
360
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800361 sip = Ip4Prefix.valueOf(
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700362 maskedIp.getValue().getInt(),
363 maskedIp.getMask().asCidrMaskLength());
alshabib6b5cfec2014-09-18 17:42:18 -0700364 } else {
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800365 sip = Ip4Prefix.valueOf(
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700366 match.get(MatchField.IPV4_SRC).getInt(),
Pavlin Radoslavovff894a22014-11-05 16:09:35 -0800367 Ip4Prefix.MAX_MASK_LENGTH);
alshabib6b5cfec2014-09-18 17:42:18 -0700368 }
Jonathan Hart0e12fad2014-10-17 14:54:58 -0700369
alshabib010c31d2014-09-26 10:01:12 -0700370 builder.matchIPSrc(sip);
alshabib6b5cfec2014-09-18 17:42:18 -0700371 break;
372 case IP_PROTO:
373 short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber();
alshabib010c31d2014-09-26 10:01:12 -0700374 builder.matchIPProtocol((byte) proto);
alshabib6b5cfec2014-09-18 17:42:18 -0700375 break;
376 case VLAN_PCP:
377 byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue();
alshabib010c31d2014-09-26 10:01:12 -0700378 builder.matchVlanPcp(vlanPcp);
alshabib6b5cfec2014-09-18 17:42:18 -0700379 break;
380 case VLAN_VID:
381 VlanId vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan());
alshabib010c31d2014-09-26 10:01:12 -0700382 builder.matchVlanId(vlanId);
alshabib6b5cfec2014-09-18 17:42:18 -0700383 break;
Jonathan Hart34bc6142014-10-17 11:00:43 -0700384 case TCP_DST:
385 builder.matchTcpDst((short) match.get(MatchField.TCP_DST).getPort());
386 break;
387 case TCP_SRC:
388 builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort());
389 break;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800390 case MPLS_LABEL:
391 builder.matchMplsLabel((int) match.get(MatchField.MPLS_LABEL)
392 .getValue());
393 break;
Marc De Leenheer49087752014-10-23 13:54:09 -0700394 case OCH_SIGID:
395 builder.matchLambda(match.get(MatchField.OCH_SIGID).getChannelNumber());
396 break;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800397 case OCH_SIGTYPE:
398 builder.matchOpticalSignalType(match.get(MatchField
399 .OCH_SIGTYPE).getValue());
400 break;
alshabib6b5cfec2014-09-18 17:42:18 -0700401 case ARP_OP:
402 case ARP_SHA:
403 case ARP_SPA:
404 case ARP_THA:
405 case ARP_TPA:
406 case ICMPV4_CODE:
407 case ICMPV4_TYPE:
408 case ICMPV6_CODE:
409 case ICMPV6_TYPE:
410 case IN_PHY_PORT:
411 case IPV6_DST:
412 case IPV6_FLABEL:
413 case IPV6_ND_SLL:
414 case IPV6_ND_TARGET:
415 case IPV6_ND_TLL:
416 case IPV6_SRC:
417 case IP_DSCP:
418 case IP_ECN:
419 case METADATA:
alshabib6b5cfec2014-09-18 17:42:18 -0700420 case MPLS_TC:
421 case SCTP_DST:
422 case SCTP_SRC:
alshabib6b5cfec2014-09-18 17:42:18 -0700423 case TUNNEL_ID:
424 case UDP_DST:
425 case UDP_SRC:
426 default:
427 log.warn("Match type {} not yet implemented.", field.id);
428
429
430 }
431 }
432 return builder.build();
433 }
434
435}