blob: b12d8a60f40e58df90fe936e333c6cd5b129a7ed [file] [log] [blame]
Thomas Vachuska781d18b2014-10-27 10:31:25 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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
Jonathan Hart8cf212a2015-10-29 17:42:03 -070018import com.google.common.collect.Lists;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080019import org.onlab.packet.Ip4Address;
20import org.onlab.packet.Ip4Prefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080021import org.onlab.packet.Ip6Address;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +080022import org.onlab.packet.Ip6Prefix;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080023import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010024import org.onlab.packet.MplsLabel;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070025import org.onlab.packet.TpPort;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080026import org.onlab.packet.VlanId;
sangho8995ac52015-02-04 11:29:03 -080027import org.onosproject.core.DefaultGroupId;
Brian O'Connorabafb502014-12-02 22:26:20 -080028import org.onosproject.net.DeviceId;
Sho SHIMIZU4f828ee2015-05-28 09:38:21 -070029import org.onosproject.net.Lambda;
Yafit Hadar73514612015-11-04 10:14:21 +020030import org.onosproject.net.OduSignalId;
Brian O'Connorabafb502014-12-02 22:26:20 -080031import org.onosproject.net.PortNumber;
Jonathan Hart3c259162015-10-21 21:31:19 -070032import org.onosproject.net.driver.DefaultDriverData;
33import org.onosproject.net.driver.DefaultDriverHandler;
34import org.onosproject.net.driver.Driver;
35import org.onosproject.net.driver.DriverHandler;
36import org.onosproject.net.driver.DriverService;
Brian O'Connorabafb502014-12-02 22:26:20 -080037import org.onosproject.net.flow.DefaultFlowEntry;
38import org.onosproject.net.flow.DefaultFlowRule;
39import org.onosproject.net.flow.DefaultTrafficSelector;
40import org.onosproject.net.flow.DefaultTrafficTreatment;
41import org.onosproject.net.flow.FlowEntry;
42import org.onosproject.net.flow.FlowEntry.FlowEntryState;
43import org.onosproject.net.flow.FlowRule;
44import org.onosproject.net.flow.TrafficSelector;
45import org.onosproject.net.flow.TrafficTreatment;
Sho SHIMIZU9553bb82015-06-30 16:02:45 -070046import org.onosproject.net.flow.instructions.Instructions;
Brian O'Connorabafb502014-12-02 22:26:20 -080047import org.onosproject.openflow.controller.Dpid;
alshabib880b6442015-11-23 22:13:04 -080048import org.onosproject.openflow.controller.ExtensionTreatmentInterpreter;
Brian O'Connor72cb19a2015-01-16 16:14:41 -080049import org.projectfloodlight.openflow.protocol.OFFlowMod;
alshabib6b5cfec2014-09-18 17:42:18 -070050import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
51import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
52import org.projectfloodlight.openflow.protocol.action.OFAction;
Marc De Leenheer49087752014-10-23 13:54:09 -070053import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
Steffen Gebertba2d3b72015-10-22 11:14:31 +020054import org.projectfloodlight.openflow.protocol.action.OFActionEnqueue;
Marc De Leenheer49087752014-10-23 13:54:09 -070055import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter;
sangho8995ac52015-02-04 11:29:03 -080056import org.projectfloodlight.openflow.protocol.action.OFActionGroup;
alshabib6b5cfec2014-09-18 17:42:18 -070057import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
sangho3f97a17d2015-01-29 22:56:29 -080058import org.projectfloodlight.openflow.protocol.action.OFActionPopMpls;
alshabib6b5cfec2014-09-18 17:42:18 -070059import org.projectfloodlight.openflow.protocol.action.OFActionSetDlDst;
60import org.projectfloodlight.openflow.protocol.action.OFActionSetDlSrc;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080061import org.projectfloodlight.openflow.protocol.action.OFActionSetField;
alshabib6b5cfec2014-09-18 17:42:18 -070062import org.projectfloodlight.openflow.protocol.action.OFActionSetNwDst;
63import org.projectfloodlight.openflow.protocol.action.OFActionSetNwSrc;
Jonathan Hart8cf212a2015-10-29 17:42:03 -070064import org.projectfloodlight.openflow.protocol.action.OFActionSetQueue;
alshabib6b5cfec2014-09-18 17:42:18 -070065import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanPcp;
66import org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid;
alshabib19fdc122014-10-03 11:38:19 -070067import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
Jonathan Hartcf783202014-11-24 18:55:42 -080068import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions;
alshabibbdcbb102015-04-22 14:16:38 -070069import org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable;
alshabib346b5b32015-03-06 00:42:16 -080070import org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteActions;
Saurav Das86af8f12015-05-25 23:55:33 -070071import org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata;
alshabib6b5cfec2014-09-18 17:42:18 -070072import org.projectfloodlight.openflow.protocol.match.Match;
73import org.projectfloodlight.openflow.protocol.match.MatchField;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080074import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
Marc De Leenheer49087752014-10-23 13:54:09 -070075import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
alshabib346b5b32015-03-06 00:42:16 -080076import org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13;
Sho SHIMIZU4f828ee2015-05-28 09:38:21 -070077import org.projectfloodlight.openflow.types.CircuitSignalID;
alshabib6b5cfec2014-09-18 17:42:18 -070078import org.projectfloodlight.openflow.types.IPv4Address;
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +080079import org.projectfloodlight.openflow.types.IPv6Address;
Jonathan Hart0e12fad2014-10-17 14:54:58 -070080import org.projectfloodlight.openflow.types.Masked;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080081import org.projectfloodlight.openflow.types.OFVlanVidMatch;
Hyunsun Moonc8bd97c2015-07-18 22:47:33 -070082import org.projectfloodlight.openflow.types.TransportPort;
sangho3f97a17d2015-01-29 22:56:29 -080083import org.projectfloodlight.openflow.types.U32;
Hyunsun Moona08c5d02015-07-14 17:53:00 -070084import org.projectfloodlight.openflow.types.U64;
Sho SHIMIZU4f828ee2015-05-28 09:38:21 -070085import org.projectfloodlight.openflow.types.U8;
Jonathan Hartd0ef7522014-12-11 11:51:18 -080086import org.projectfloodlight.openflow.types.VlanPcp;
Yafit Hadar73514612015-11-04 10:14:21 +020087import org.projectfloodlight.openflow.types.OduSignalID;
alshabib6b5cfec2014-09-18 17:42:18 -070088import org.slf4j.Logger;
89
Jonathan Hart8cf212a2015-10-29 17:42:03 -070090import java.util.List;
91
92import static org.onosproject.net.flow.criteria.Criteria.matchLambda;
93import static org.onosproject.net.flow.criteria.Criteria.matchOchSignalType;
Yafit Hadar73514612015-11-04 10:14:21 +020094import static org.onosproject.net.flow.criteria.Criteria.matchOduSignalType;
95import static org.onosproject.net.flow.criteria.Criteria.matchOduSignalId;
96import static org.onosproject.net.flow.instructions.Instructions.modL0Lambda;
97import static org.onosproject.net.flow.instructions.Instructions.modL1OduSignalId;
Jonathan Hart8cf212a2015-10-29 17:42:03 -070098import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupChannelSpacing;
99import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupGridType;
100import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOchSignalType;
Yafit Hadar73514612015-11-04 10:14:21 +0200101import static org.onosproject.provider.of.flow.impl.OpenFlowValueMapper.lookupOduSignalType;
Jonathan Hart8cf212a2015-10-29 17:42:03 -0700102import static org.slf4j.LoggerFactory.getLogger;
alshabib19fdc122014-10-03 11:38:19 -0700103
alshabib1c319ff2014-10-04 20:29:09 -0700104public class FlowEntryBuilder {
alshabib6b5cfec2014-09-18 17:42:18 -0700105 private final Logger log = getLogger(getClass());
106
107 private final OFFlowStatsEntry stat;
108 private final OFFlowRemoved removed;
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800109 private final OFFlowMod flowMod;
alshabib6b5cfec2014-09-18 17:42:18 -0700110
111 private final Match match;
alshabib346b5b32015-03-06 00:42:16 -0800112
Jonathan Hart67fc0972015-03-19 15:21:20 -0700113 // All actions are contained in an OFInstruction. For OF1.0
114 // the instruction type is apply instruction (immediate set in ONOS speak)
alshabib346b5b32015-03-06 00:42:16 -0800115 private final List<OFInstruction> instructions;
alshabib6b5cfec2014-09-18 17:42:18 -0700116
117 private final Dpid dpid;
118
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800119 public enum FlowType { STAT, REMOVED, MOD }
120
121 private final FlowType type;
alshabib6b5cfec2014-09-18 17:42:18 -0700122
Jonathan Hart3c259162015-10-21 21:31:19 -0700123 private final DriverService driverService;
124
125 public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry, DriverService driverService) {
Saurav Dasfa2fa932015-03-03 11:29:48 -0800126 this.stat = entry;
127 this.match = entry.getMatch();
alshabib346b5b32015-03-06 00:42:16 -0800128 this.instructions = getInstructions(entry);
Saurav Dasfa2fa932015-03-03 11:29:48 -0800129 this.dpid = dpid;
130 this.removed = null;
131 this.flowMod = null;
132 this.type = FlowType.STAT;
Jonathan Hart3c259162015-10-21 21:31:19 -0700133 this.driverService = driverService;
Saurav Dasfa2fa932015-03-03 11:29:48 -0800134 }
135
Jonathan Hart3c259162015-10-21 21:31:19 -0700136 public FlowEntryBuilder(Dpid dpid, OFFlowRemoved removed, DriverService driverService) {
alshabib6b5cfec2014-09-18 17:42:18 -0700137 this.match = removed.getMatch();
138 this.removed = removed;
139
140 this.dpid = dpid;
alshabib346b5b32015-03-06 00:42:16 -0800141 this.instructions = null;
alshabib6b5cfec2014-09-18 17:42:18 -0700142 this.stat = null;
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800143 this.flowMod = null;
144 this.type = FlowType.REMOVED;
Jonathan Hart3c259162015-10-21 21:31:19 -0700145 this.driverService = driverService;
alshabib6b5cfec2014-09-18 17:42:18 -0700146 }
147
Jonathan Hart3c259162015-10-21 21:31:19 -0700148 public FlowEntryBuilder(Dpid dpid, OFFlowMod fm, DriverService driverService) {
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800149 this.match = fm.getMatch();
150 this.dpid = dpid;
alshabib346b5b32015-03-06 00:42:16 -0800151 this.instructions = getInstructions(fm);
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800152 this.type = FlowType.MOD;
153 this.flowMod = fm;
154 this.stat = null;
155 this.removed = null;
Jonathan Hart3c259162015-10-21 21:31:19 -0700156 this.driverService = driverService;
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800157 }
alshabib1c319ff2014-10-04 20:29:09 -0700158
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800159 public FlowEntry build(FlowEntryState... state) {
160 FlowRule rule;
161 switch (this.type) {
162 case STAT:
alshabibbdcbb102015-04-22 14:16:38 -0700163 rule = DefaultFlowRule.builder()
164 .forDevice(DeviceId.deviceId(Dpid.uri(dpid)))
165 .withSelector(buildSelector())
166 .withTreatment(buildTreatment())
167 .withPriority(stat.getPriority())
168 .makeTemporary(stat.getIdleTimeout())
169 .withCookie(stat.getCookie().getValue())
170 .forTable(stat.getTableId().getValue())
171 .build();
172
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800173 return new DefaultFlowEntry(rule, FlowEntryState.ADDED,
174 stat.getDurationSec(), stat.getPacketCount().getValue(),
175 stat.getByteCount().getValue());
176 case REMOVED:
alshabibbdcbb102015-04-22 14:16:38 -0700177 rule = DefaultFlowRule.builder()
178 .forDevice(DeviceId.deviceId(Dpid.uri(dpid)))
179 .withSelector(buildSelector())
180 .withPriority(removed.getPriority())
181 .makeTemporary(removed.getIdleTimeout())
182 .withCookie(removed.getCookie().getValue())
183 .forTable(removed.getTableId().getValue())
184 .build();
185
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800186 return new DefaultFlowEntry(rule, FlowEntryState.REMOVED, removed.getDurationSec(),
187 removed.getPacketCount().getValue(), removed.getByteCount().getValue());
188 case MOD:
189 FlowEntryState flowState = state.length > 0 ? state[0] : FlowEntryState.FAILED;
alshabibbdcbb102015-04-22 14:16:38 -0700190 rule = DefaultFlowRule.builder()
191 .forDevice(DeviceId.deviceId(Dpid.uri(dpid)))
192 .withSelector(buildSelector())
193 .withTreatment(buildTreatment())
194 .withPriority(flowMod.getPriority())
195 .makeTemporary(flowMod.getIdleTimeout())
196 .withCookie(flowMod.getCookie().getValue())
197 .forTable(flowMod.getTableId().getValue())
198 .build();
199
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800200 return new DefaultFlowEntry(rule, flowState, 0, 0, 0);
201 default:
202 log.error("Unknown flow type : {}", this.type);
203 return null;
alshabib6b5cfec2014-09-18 17:42:18 -0700204 }
Brian O'Connor72cb19a2015-01-16 16:14:41 -0800205
alshabib6b5cfec2014-09-18 17:42:18 -0700206 }
207
alshabib346b5b32015-03-06 00:42:16 -0800208 private List<OFInstruction> getInstructions(OFFlowMod entry) {
alshabib19fdc122014-10-03 11:38:19 -0700209 switch (entry.getVersion()) {
210 case OF_10:
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -0700211 return Lists.newArrayList(OFFactoryVer13.INSTANCE.instructions()
212 .applyActions(
213 entry.getActions()));
alshabib19fdc122014-10-03 11:38:19 -0700214 case OF_11:
215 case OF_12:
216 case OF_13:
alshabib346b5b32015-03-06 00:42:16 -0800217 return entry.getInstructions();
218 default:
219 log.warn("Unknown OF version {}", entry.getVersion());
220 }
221 return Lists.newLinkedList();
222 }
223
224 private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
225 switch (entry.getVersion()) {
226 case OF_10:
227 return Lists.newArrayList(
228 OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
229 case OF_11:
230 case OF_12:
231 case OF_13:
232 return entry.getInstructions();
alshabib19fdc122014-10-03 11:38:19 -0700233 default:
234 log.warn("Unknown OF version {}", entry.getVersion());
235 }
236 return Lists.newLinkedList();
237 }
alshabib6b5cfec2014-09-18 17:42:18 -0700238
239 private TrafficTreatment buildTreatment() {
tom9a693fd2014-10-03 11:32:19 -0700240 TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
alshabib346b5b32015-03-06 00:42:16 -0800241 for (OFInstruction in : instructions) {
242 switch (in.getType()) {
243 case GOTO_TABLE:
alshabibbdcbb102015-04-22 14:16:38 -0700244 builder.transition(((int) ((OFInstructionGotoTable) in)
245 .getTableId().getValue()));
alshabib346b5b32015-03-06 00:42:16 -0800246 break;
247 case WRITE_METADATA:
Saurav Das86af8f12015-05-25 23:55:33 -0700248 OFInstructionWriteMetadata m = (OFInstructionWriteMetadata) in;
249 builder.writeMetadata(m.getMetadata().getValue(),
250 m.getMetadataMask().getValue());
alshabib346b5b32015-03-06 00:42:16 -0800251 break;
252 case WRITE_ACTIONS:
253 builder.deferred();
254 buildActions(((OFInstructionWriteActions) in).getActions(),
255 builder);
256 break;
257 case APPLY_ACTIONS:
258 builder.immediate();
259 buildActions(((OFInstructionApplyActions) in).getActions(),
260 builder);
261 break;
262 case CLEAR_ACTIONS:
263 builder.wipeDeferred();
264 break;
265 case EXPERIMENTER:
266 break;
267 case METER:
268 break;
269 default:
270 log.warn("Unknown instructions type {}", in.getType());
alshabib6b5cfec2014-09-18 17:42:18 -0700271 }
272 }
273
274 return builder.build();
275 }
276
alshabib346b5b32015-03-06 00:42:16 -0800277 private TrafficTreatment.Builder buildActions(List<OFAction> actions,
278 TrafficTreatment.Builder builder) {
279 for (OFAction act : actions) {
280 switch (act.getType()) {
281 case OUTPUT:
282 OFActionOutput out = (OFActionOutput) act;
283 builder.setOutput(
284 PortNumber.portNumber(out.getPort().getPortNumber()));
285 break;
286 case SET_VLAN_VID:
287 OFActionSetVlanVid vlan = (OFActionSetVlanVid) act;
288 builder.setVlanId(VlanId.vlanId(vlan.getVlanVid().getVlan()));
289 break;
290 case SET_VLAN_PCP:
291 OFActionSetVlanPcp pcp = (OFActionSetVlanPcp) act;
292 builder.setVlanPcp(pcp.getVlanPcp().getValue());
293 break;
294 case SET_DL_DST:
295 OFActionSetDlDst dldst = (OFActionSetDlDst) act;
296 builder.setEthDst(
297 MacAddress.valueOf(dldst.getDlAddr().getLong()));
298 break;
299 case SET_DL_SRC:
300 OFActionSetDlSrc dlsrc = (OFActionSetDlSrc) act;
301 builder.setEthSrc(
302 MacAddress.valueOf(dlsrc.getDlAddr().getLong()));
303
304 break;
305 case SET_NW_DST:
306 OFActionSetNwDst nwdst = (OFActionSetNwDst) act;
307 IPv4Address di = nwdst.getNwAddr();
308 builder.setIpDst(Ip4Address.valueOf(di.getInt()));
309 break;
310 case SET_NW_SRC:
311 OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act;
312 IPv4Address si = nwsrc.getNwAddr();
313 builder.setIpSrc(Ip4Address.valueOf(si.getInt()));
314 break;
315 case EXPERIMENTER:
316 OFActionExperimenter exp = (OFActionExperimenter) act;
317 if (exp.getExperimenter() == 0x80005A06 ||
318 exp.getExperimenter() == 0x748771) {
319 OFActionCircuit ct = (OFActionCircuit) exp;
Sho SHIMIZU9553bb82015-06-30 16:02:45 -0700320 short lambda = ((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber();
321 builder.add(Instructions.modL0Lambda(Lambda.indexedLambda(lambda)));
alshabib346b5b32015-03-06 00:42:16 -0800322 } else {
323 log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
324 }
325 break;
326 case SET_FIELD:
327 OFActionSetField setField = (OFActionSetField) act;
Jonathan Hart3c259162015-10-21 21:31:19 -0700328 handleSetField(builder, setField);
alshabib346b5b32015-03-06 00:42:16 -0800329 break;
330 case POP_MPLS:
331 OFActionPopMpls popMpls = (OFActionPopMpls) act;
332 builder.popMpls((short) popMpls.getEthertype().getValue());
333 break;
334 case PUSH_MPLS:
335 builder.pushMpls();
336 break;
337 case COPY_TTL_IN:
338 builder.copyTtlIn();
339 break;
340 case COPY_TTL_OUT:
341 builder.copyTtlOut();
342 break;
343 case DEC_MPLS_TTL:
344 builder.decMplsTtl();
345 break;
346 case DEC_NW_TTL:
347 builder.decNwTtl();
348 break;
349 case GROUP:
350 OFActionGroup group = (OFActionGroup) act;
351 builder.group(new DefaultGroupId(group.getGroup().getGroupNumber()));
352 break;
Steffen Gebertbbfdaaa2015-09-29 11:01:46 +0200353 case SET_QUEUE:
354 OFActionSetQueue setQueue = (OFActionSetQueue) act;
355 builder.setQueue(setQueue.getQueueId());
356 break;
Steffen Gebertba2d3b72015-10-22 11:14:31 +0200357 case ENQUEUE:
358 OFActionEnqueue enqueue = (OFActionEnqueue) act;
359 builder.setQueue(enqueue.getQueueId(), PortNumber.portNumber(enqueue.getPort().getPortNumber()));
360 break;
Jonathan Hart67fc0972015-03-19 15:21:20 -0700361 case STRIP_VLAN:
alshabib346b5b32015-03-06 00:42:16 -0800362 case POP_VLAN:
363 builder.popVlan();
364 break;
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -0700365 case PUSH_VLAN:
366 builder.pushVlan();
367 break;
alshabib346b5b32015-03-06 00:42:16 -0800368 case SET_TP_DST:
369 case SET_TP_SRC:
370 case POP_PBB:
371 case PUSH_PBB:
alshabib346b5b32015-03-06 00:42:16 -0800372 case SET_MPLS_LABEL:
373 case SET_MPLS_TC:
374 case SET_MPLS_TTL:
375 case SET_NW_ECN:
376 case SET_NW_TOS:
377 case SET_NW_TTL:
alshabib346b5b32015-03-06 00:42:16 -0800378
alshabib346b5b32015-03-06 00:42:16 -0800379 default:
380 log.warn("Action type {} not yet implemented.", act.getType());
381 }
382 }
383 return builder;
384 }
385
386
Jonathan Hart3c259162015-10-21 21:31:19 -0700387 private void handleSetField(TrafficTreatment.Builder builder, OFActionSetField action) {
388 OFOxm<?> oxm = action.getField();
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800389 switch (oxm.getMatchField().id) {
390 case VLAN_PCP:
391 @SuppressWarnings("unchecked")
392 OFOxm<VlanPcp> vlanpcp = (OFOxm<VlanPcp>) oxm;
393 builder.setVlanPcp(vlanpcp.getValue().getValue());
394 break;
395 case VLAN_VID:
396 @SuppressWarnings("unchecked")
397 OFOxm<OFVlanVidMatch> vlanvid = (OFOxm<OFVlanVidMatch>) oxm;
398 builder.setVlanId(VlanId.vlanId(vlanvid.getValue().getVlan()));
399 break;
400 case ETH_DST:
401 @SuppressWarnings("unchecked")
402 OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethdst =
403 (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
404 builder.setEthDst(MacAddress.valueOf(ethdst.getValue().getLong()));
405 break;
406 case ETH_SRC:
407 @SuppressWarnings("unchecked")
408 OFOxm<org.projectfloodlight.openflow.types.MacAddress> ethsrc =
409 (OFOxm<org.projectfloodlight.openflow.types.MacAddress>) oxm;
410 builder.setEthSrc(MacAddress.valueOf(ethsrc.getValue().getLong()));
411 break;
412 case IPV4_DST:
413 @SuppressWarnings("unchecked")
414 OFOxm<IPv4Address> ip4dst = (OFOxm<IPv4Address>) oxm;
415 builder.setIpDst(Ip4Address.valueOf(ip4dst.getValue().getInt()));
416 break;
417 case IPV4_SRC:
418 @SuppressWarnings("unchecked")
419 OFOxm<IPv4Address> ip4src = (OFOxm<IPv4Address>) oxm;
420 builder.setIpSrc(Ip4Address.valueOf(ip4src.getValue().getInt()));
421 break;
sangho3f97a17d2015-01-29 22:56:29 -0800422 case MPLS_LABEL:
423 @SuppressWarnings("unchecked")
424 OFOxm<U32> labelId = (OFOxm<U32>) oxm;
Michele Santuari4b6019e2014-12-19 11:31:45 +0100425 builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue()));
sangho3f97a17d2015-01-29 22:56:29 -0800426 break;
Saurav Das73a7dd42015-08-19 22:20:31 -0700427 case MPLS_BOS:
428 @SuppressWarnings("unchecked")
429 OFOxm<U8> mplsBos = (OFOxm<U8>) oxm;
430 builder.setMplsBos(mplsBos.getValue() == U8.ZERO ? false : true);
431 break;
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700432 case TUNNEL_ID:
433 @SuppressWarnings("unchecked")
434 OFOxm<U64> tunnelId = (OFOxm<U64>) oxm;
435 builder.setTunnelId(tunnelId.getValue().getValue());
436 break;
Hyunsun Moonc8bd97c2015-07-18 22:47:33 -0700437 case TCP_DST:
438 @SuppressWarnings("unchecked")
439 OFOxm<TransportPort> tcpdst = (OFOxm<TransportPort>) oxm;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700440 builder.setTcpDst(TpPort.tpPort(tcpdst.getValue().getPort()));
Hyunsun Moonc8bd97c2015-07-18 22:47:33 -0700441 break;
442 case TCP_SRC:
443 @SuppressWarnings("unchecked")
444 OFOxm<TransportPort> tcpsrc = (OFOxm<TransportPort>) oxm;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700445 builder.setTcpSrc(TpPort.tpPort(tcpsrc.getValue().getPort()));
Hyunsun Moonc8bd97c2015-07-18 22:47:33 -0700446 break;
447 case UDP_DST:
448 @SuppressWarnings("unchecked")
449 OFOxm<TransportPort> udpdst = (OFOxm<TransportPort>) oxm;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700450 builder.setUdpDst(TpPort.tpPort(udpdst.getValue().getPort()));
Hyunsun Moonc8bd97c2015-07-18 22:47:33 -0700451 break;
452 case UDP_SRC:
453 @SuppressWarnings("unchecked")
454 OFOxm<TransportPort> udpsrc = (OFOxm<TransportPort>) oxm;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700455 builder.setUdpSrc(TpPort.tpPort(udpsrc.getValue().getPort()));
Hyunsun Moonc8bd97c2015-07-18 22:47:33 -0700456 break;
Jonathan Hart3c259162015-10-21 21:31:19 -0700457 case TUNNEL_IPV4_DST:
458 DriverHandler driver = getDriver(dpid);
alshabib880b6442015-11-23 22:13:04 -0800459 ExtensionTreatmentInterpreter interpreter = driver.behaviour(ExtensionTreatmentInterpreter.class);
Jonathan Hart3c259162015-10-21 21:31:19 -0700460 if (interpreter != null) {
461 builder.extension(interpreter.mapAction(action), DeviceId.deviceId(Dpid.uri(dpid)));
462 }
463 break;
Yafit Hadar73514612015-11-04 10:14:21 +0200464 case EXP_ODU_SIG_ID:
465 @SuppressWarnings("unchecked")
466 OFOxm<OduSignalID> oduID = (OFOxm<OduSignalID>) oxm;
467 OduSignalID oduSignalID = oduID.getValue();
468 OduSignalId oduSignalId = OduSignalId.oduSignalId(oduSignalID.getTpn(),
469 oduSignalID.getTslen(),
470 oduSignalID.getTsmap());
471 builder.add(modL1OduSignalId(oduSignalId));
472 break;
473 case EXP_OCH_SIG_ID:
474 try {
475 @SuppressWarnings("unchecked")
476 OFOxm<CircuitSignalID> ochId = (OFOxm<CircuitSignalID>) oxm;
477 CircuitSignalID circuitSignalID = ochId.getValue();
478 builder.add(modL0Lambda(Lambda.ochSignal(
479 lookupGridType(circuitSignalID.getGridType()),
480 lookupChannelSpacing(circuitSignalID.getChannelSpacing()),
481 circuitSignalID.getChannelNumber(), circuitSignalID.getSpectralWidth())));
482 } catch (NoMappingFoundException e) {
483 log.warn(e.getMessage());
484 break;
485 }
486 break;
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800487 case ARP_OP:
488 case ARP_SHA:
489 case ARP_SPA:
490 case ARP_THA:
491 case ARP_TPA:
492 case BSN_EGR_PORT_GROUP_ID:
493 case BSN_GLOBAL_VRF_ALLOWED:
494 case BSN_IN_PORTS_128:
495 case BSN_L3_DST_CLASS_ID:
496 case BSN_L3_INTERFACE_CLASS_ID:
497 case BSN_L3_SRC_CLASS_ID:
498 case BSN_LAG_ID:
499 case BSN_TCP_FLAGS:
500 case BSN_UDF0:
501 case BSN_UDF1:
502 case BSN_UDF2:
503 case BSN_UDF3:
504 case BSN_UDF4:
505 case BSN_UDF5:
506 case BSN_UDF6:
507 case BSN_UDF7:
508 case BSN_VLAN_XLATE_PORT_GROUP_ID:
509 case BSN_VRF:
510 case ETH_TYPE:
511 case ICMPV4_CODE:
512 case ICMPV4_TYPE:
513 case ICMPV6_CODE:
514 case ICMPV6_TYPE:
515 case IN_PHY_PORT:
516 case IN_PORT:
517 case IPV6_DST:
518 case IPV6_FLABEL:
519 case IPV6_ND_SLL:
520 case IPV6_ND_TARGET:
521 case IPV6_ND_TLL:
522 case IPV6_SRC:
523 case IP_DSCP:
524 case IP_ECN:
525 case IP_PROTO:
526 case METADATA:
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800527 case MPLS_TC:
528 case OCH_SIGID:
529 case OCH_SIGID_BASIC:
530 case OCH_SIGTYPE:
531 case OCH_SIGTYPE_BASIC:
532 case SCTP_DST:
533 case SCTP_SRC:
Yafit Hadar73514612015-11-04 10:14:21 +0200534 case EXP_ODU_SIGTYPE:
535 case EXP_OCH_SIGTYPE:
Jonathan Hartd0ef7522014-12-11 11:51:18 -0800536 default:
537 log.warn("Set field type {} not yet implemented.", oxm.getMatchField().id);
538 break;
539 }
540 }
541
Sho SHIMIZU6f1b09e2015-05-05 11:26:22 -0700542 // CHECKSTYLE IGNORE MethodLength FOR NEXT 1 LINES
alshabib6b5cfec2014-09-18 17:42:18 -0700543 private TrafficSelector buildSelector() {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800544 MacAddress mac;
545 Ip4Prefix ip4Prefix;
546 Ip6Address ip6Address;
547 Ip6Prefix ip6Prefix;
BitOhenryc1e5fcc2015-11-23 20:47:53 +0800548 Ip4Address ip;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800549
tom9a693fd2014-10-03 11:32:19 -0700550 TrafficSelector.Builder builder = DefaultTrafficSelector.builder();
alshabib6b5cfec2014-09-18 17:42:18 -0700551 for (MatchField<?> field : match.getMatchFields()) {
552 switch (field.id) {
553 case IN_PORT:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800554 builder.matchInPort(PortNumber
alshabib010c31d2014-09-26 10:01:12 -0700555 .portNumber(match.get(MatchField.IN_PORT).getPortNumber()));
alshabib6b5cfec2014-09-18 17:42:18 -0700556 break;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800557 case IN_PHY_PORT:
558 builder.matchInPhyPort(PortNumber
559 .portNumber(match.get(MatchField.IN_PHY_PORT).getPortNumber()));
560 break;
561 case METADATA:
562 long metadata =
563 match.get(MatchField.METADATA).getValue().getValue();
564 builder.matchMetadata(metadata);
565 break;
alshabib6b5cfec2014-09-18 17:42:18 -0700566 case ETH_DST:
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800567 mac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong());
568 builder.matchEthDst(mac);
569 break;
570 case ETH_SRC:
571 mac = MacAddress.valueOf(match.get(MatchField.ETH_SRC).getLong());
572 builder.matchEthSrc(mac);
alshabib6b5cfec2014-09-18 17:42:18 -0700573 break;
574 case ETH_TYPE:
575 int ethType = match.get(MatchField.ETH_TYPE).getValue();
Jonathan Hart8cf212a2015-10-29 17:42:03 -0700576 builder.matchEthType((short) ethType);
alshabib6b5cfec2014-09-18 17:42:18 -0700577 break;
alshabib6b5cfec2014-09-18 17:42:18 -0700578 case VLAN_VID:
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800579 VlanId vlanId = null;
580 if (match.isPartiallyMasked(MatchField.VLAN_VID)) {
581 Masked<OFVlanVidMatch> masked = match.getMasked(MatchField.VLAN_VID);
582 if (masked.getValue().equals(OFVlanVidMatch.PRESENT)
583 && masked.getMask().equals(OFVlanVidMatch.PRESENT)) {
584 vlanId = VlanId.ANY;
585 }
586 } else {
Jonathan Hart1468fee2015-07-16 18:50:34 -0700587 if (!match.get(MatchField.VLAN_VID).isPresentBitSet()) {
588 vlanId = VlanId.NONE;
589 } else {
590 vlanId = VlanId.vlanId(match.get(MatchField.VLAN_VID).getVlan());
591 }
Jonathan Hart6cd2f352015-01-13 17:44:45 -0800592 }
593 if (vlanId != null) {
594 builder.matchVlanId(vlanId);
595 }
alshabib6b5cfec2014-09-18 17:42:18 -0700596 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800597 case VLAN_PCP:
598 byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue();
599 builder.matchVlanPcp(vlanPcp);
600 break;
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800601 case IP_DSCP:
602 byte ipDscp = match.get(MatchField.IP_DSCP).getDscpValue();
603 builder.matchIPDscp(ipDscp);
604 break;
605 case IP_ECN:
606 byte ipEcn = match.get(MatchField.IP_ECN).getEcnValue();
607 builder.matchIPEcn(ipEcn);
608 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800609 case IP_PROTO:
610 short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber();
611 builder.matchIPProtocol((byte) proto);
612 break;
613 case IPV4_SRC:
614 if (match.isPartiallyMasked(MatchField.IPV4_SRC)) {
615 Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_SRC);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800616 ip4Prefix = Ip4Prefix.valueOf(
617 maskedIp.getValue().getInt(),
618 maskedIp.getMask().asCidrMaskLength());
619 } else {
620 ip4Prefix = Ip4Prefix.valueOf(
621 match.get(MatchField.IPV4_SRC).getInt(),
622 Ip4Prefix.MAX_MASK_LENGTH);
623 }
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800624 builder.matchIPSrc(ip4Prefix);
625 break;
626 case IPV4_DST:
627 if (match.isPartiallyMasked(MatchField.IPV4_DST)) {
628 Masked<IPv4Address> maskedIp = match.getMasked(MatchField.IPV4_DST);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800629 ip4Prefix = Ip4Prefix.valueOf(
630 maskedIp.getValue().getInt(),
631 maskedIp.getMask().asCidrMaskLength());
632 } else {
633 ip4Prefix = Ip4Prefix.valueOf(
634 match.get(MatchField.IPV4_DST).getInt(),
635 Ip4Prefix.MAX_MASK_LENGTH);
636 }
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800637 builder.matchIPDst(ip4Prefix);
Jonathan Hart34bc6142014-10-17 11:00:43 -0700638 break;
639 case TCP_SRC:
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700640 builder.matchTcpSrc(TpPort.tpPort(match.get(MatchField.TCP_SRC).getPort()));
Jonathan Hart34bc6142014-10-17 11:00:43 -0700641 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800642 case TCP_DST:
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700643 builder.matchTcpDst(TpPort.tpPort(match.get(MatchField.TCP_DST).getPort()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800644 break;
645 case UDP_SRC:
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700646 builder.matchUdpSrc(TpPort.tpPort(match.get(MatchField.UDP_SRC).getPort()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800647 break;
648 case UDP_DST:
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700649 builder.matchUdpDst(TpPort.tpPort(match.get(MatchField.UDP_DST).getPort()));
Sho SHIMIZU6f1b09e2015-05-05 11:26:22 -0700650 break;
Michele Santuari4b6019e2014-12-19 11:31:45 +0100651 case MPLS_LABEL:
652 builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL)
653 .getValue()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800654 break;
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700655 case MPLS_BOS:
656 builder.matchMplsBos(match.get(MatchField.MPLS_BOS).getValue());
657 break;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800658 case SCTP_SRC:
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700659 builder.matchSctpSrc(TpPort.tpPort(match.get(MatchField.SCTP_SRC).getPort()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800660 break;
661 case SCTP_DST:
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700662 builder.matchSctpDst(TpPort.tpPort(match.get(MatchField.SCTP_DST).getPort()));
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800663 break;
664 case ICMPV4_TYPE:
665 byte icmpType = (byte) match.get(MatchField.ICMPV4_TYPE).getType();
666 builder.matchIcmpType(icmpType);
667 break;
668 case ICMPV4_CODE:
669 byte icmpCode = (byte) match.get(MatchField.ICMPV4_CODE).getCode();
670 builder.matchIcmpCode(icmpCode);
671 break;
672 case IPV6_SRC:
673 if (match.isPartiallyMasked(MatchField.IPV6_SRC)) {
674 Masked<IPv6Address> maskedIp = match.getMasked(MatchField.IPV6_SRC);
675 ip6Prefix = Ip6Prefix.valueOf(
676 maskedIp.getValue().getBytes(),
677 maskedIp.getMask().asCidrMaskLength());
678 } else {
679 ip6Prefix = Ip6Prefix.valueOf(
680 match.get(MatchField.IPV6_SRC).getBytes(),
681 Ip6Prefix.MAX_MASK_LENGTH);
682 }
683 builder.matchIPv6Src(ip6Prefix);
684 break;
685 case IPV6_DST:
686 if (match.isPartiallyMasked(MatchField.IPV6_DST)) {
687 Masked<IPv6Address> maskedIp = match.getMasked(MatchField.IPV6_DST);
688 ip6Prefix = Ip6Prefix.valueOf(
689 maskedIp.getValue().getBytes(),
690 maskedIp.getMask().asCidrMaskLength());
691 } else {
692 ip6Prefix = Ip6Prefix.valueOf(
693 match.get(MatchField.IPV6_DST).getBytes(),
694 Ip6Prefix.MAX_MASK_LENGTH);
695 }
696 builder.matchIPv6Dst(ip6Prefix);
697 break;
698 case IPV6_FLABEL:
699 int flowLabel =
700 match.get(MatchField.IPV6_FLABEL).getIPv6FlowLabelValue();
701 builder.matchIPv6FlowLabel(flowLabel);
702 break;
703 case ICMPV6_TYPE:
704 byte icmpv6type = (byte) match.get(MatchField.ICMPV6_TYPE).getValue();
705 builder.matchIcmpv6Type(icmpv6type);
706 break;
707 case ICMPV6_CODE:
708 byte icmpv6code = (byte) match.get(MatchField.ICMPV6_CODE).getValue();
709 builder.matchIcmpv6Code(icmpv6code);
710 break;
711 case IPV6_ND_TARGET:
712 ip6Address =
713 Ip6Address.valueOf(match.get(MatchField.IPV6_ND_TARGET).getBytes());
714 builder.matchIPv6NDTargetAddress(ip6Address);
715 break;
716 case IPV6_ND_SLL:
717 mac = MacAddress.valueOf(match.get(MatchField.IPV6_ND_SLL).getLong());
718 builder.matchIPv6NDSourceLinkLayerAddress(mac);
719 break;
720 case IPV6_ND_TLL:
721 mac = MacAddress.valueOf(match.get(MatchField.IPV6_ND_TLL).getLong());
722 builder.matchIPv6NDTargetLinkLayerAddress(mac);
723 break;
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800724 case IPV6_EXTHDR:
Charles M.C. Chan2184de12015-04-26 02:24:53 +0800725 builder.matchIPv6ExthdrFlags((short) match.get(MatchField.IPV6_EXTHDR)
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700726 .getValue());
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800727 break;
Marc De Leenheer49087752014-10-23 13:54:09 -0700728 case OCH_SIGID:
Sho SHIMIZU4f828ee2015-05-28 09:38:21 -0700729 CircuitSignalID sigId = match.get(MatchField.OCH_SIGID);
730 builder.add(matchLambda(Lambda.ochSignal(
Sho SHIMIZUc17042d2015-05-28 12:07:23 -0700731 lookupGridType(sigId.getGridType()), lookupChannelSpacing(sigId.getChannelSpacing()),
Marc De Leenheer0b8b2ef2015-08-03 15:39:00 -0700732 sigId.getChannelNumber(), sigId.getSpectralWidth())
Sho SHIMIZU4f828ee2015-05-28 09:38:21 -0700733 ));
Marc De Leenheer49087752014-10-23 13:54:09 -0700734 break;
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800735 case OCH_SIGTYPE:
Sho SHIMIZU4f828ee2015-05-28 09:38:21 -0700736 U8 sigType = match.get(MatchField.OCH_SIGTYPE);
Sho SHIMIZUc17042d2015-05-28 12:07:23 -0700737 builder.add(matchOchSignalType(lookupOchSignalType((byte) sigType.getValue())));
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800738 break;
Yafit Hadar73514612015-11-04 10:14:21 +0200739 case EXP_OCH_SIG_ID:
740 try {
741 CircuitSignalID expSigId = match.get(MatchField.EXP_OCH_SIG_ID);
742 builder.add(matchLambda(Lambda.ochSignal(
743 lookupGridType(expSigId.getGridType()), lookupChannelSpacing(expSigId.getChannelSpacing()),
744 expSigId.getChannelNumber(), expSigId.getSpectralWidth())));
745 } catch (NoMappingFoundException e) {
746 log.warn(e.getMessage());
747 break;
748 }
749 break;
750 case EXP_OCH_SIGTYPE:
751 try {
752 U8 expOchSigType = match.get(MatchField.EXP_OCH_SIGTYPE);
753 builder.add(matchOchSignalType(lookupOchSignalType((byte) expOchSigType.getValue())));
754 } catch (NoMappingFoundException e) {
755 log.warn(e.getMessage());
756 break;
757 }
758 break;
759 case EXP_ODU_SIG_ID:
760 OduSignalId oduSignalId = OduSignalId.oduSignalId(match.get(MatchField.EXP_ODU_SIG_ID).getTpn(),
761 match.get(MatchField.EXP_ODU_SIG_ID).getTslen(),
762 match.get(MatchField.EXP_ODU_SIG_ID).getTsmap());
763 builder.add(matchOduSignalId(oduSignalId));
764 break;
765 case EXP_ODU_SIGTYPE:
766 try {
767 U8 oduSigType = match.get(MatchField.EXP_ODU_SIGTYPE);
768 builder.add(matchOduSignalType(lookupOduSignalType((byte) oduSigType.getValue())));
769 } catch (NoMappingFoundException e) {
770 log.warn(e.getMessage());
771 break;
772 }
773 break;
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700774 case TUNNEL_ID:
775 long tunnelId = match.get(MatchField.TUNNEL_ID).getValue();
776 builder.matchTunnelId(tunnelId);
777 break;
BitOhenryb40129a2015-11-30 12:41:18 +0800778 case ARP_OP:
779 int arpOp = match.get(MatchField.ARP_OP).getOpcode();
780 builder.matchArpOp(arpOp);
781 break;
BitOhenrya331b182015-11-23 08:39:37 +0800782 case ARP_SHA:
783 mac = MacAddress.valueOf(match.get(MatchField.ARP_SHA).getLong());
784 builder.matchArpSha(mac);
785 break;
BitOhenry296b4542015-11-24 08:41:58 +0800786 case ARP_SPA:
787 ip = Ip4Address.valueOf(match.get(MatchField.ARP_SPA).getInt());
788 builder.matchArpSpa(ip);
789 break;
BitOhenry76430852015-11-20 19:04:49 +0800790 case ARP_THA:
791 mac = MacAddress.valueOf(match.get(MatchField.ARP_THA).getLong());
792 builder.matchArpTha(mac);
793 break;
BitOhenryc1e5fcc2015-11-23 20:47:53 +0800794 case ARP_TPA:
795 ip = Ip4Address.valueOf(match.get(MatchField.ARP_TPA).getInt());
796 builder.matchArpTpa(ip);
797 break;
alshabib6b5cfec2014-09-18 17:42:18 -0700798 case MPLS_TC:
alshabib6b5cfec2014-09-18 17:42:18 -0700799 default:
800 log.warn("Match type {} not yet implemented.", field.id);
alshabib6b5cfec2014-09-18 17:42:18 -0700801 }
802 }
803 return builder.build();
804 }
Jonathan Hart3c259162015-10-21 21:31:19 -0700805
806 private DriverHandler getDriver(Dpid dpid) {
807 DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
808 Driver driver = driverService.getDriver(deviceId);
809 DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, deviceId));
810 return handler;
811 }
alshabib6b5cfec2014-09-18 17:42:18 -0700812}