blob: 18f43bf335838b19a4cf5878fdb1fa3742e7bc6c [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;
Jonathan Hart86e59352014-10-22 10:42:16 -070017
alshabib346b5b32015-03-06 00:42:16 -080018import com.google.common.collect.Lists;
Jonathan Hart29afca32015-01-20 18:17:39 -080019import org.onlab.packet.Ip4Address;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080020import org.onlab.packet.Ip6Address;
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -070021import org.onosproject.net.ChannelSpacing;
22import org.onosproject.net.GridType;
23import org.onosproject.net.OchSignal;
Charles M.C. Chanfe421812015-01-12 18:20:51 +080024import org.onosproject.net.PortNumber;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import org.onosproject.net.flow.FlowRule;
26import org.onosproject.net.flow.TrafficTreatment;
27import org.onosproject.net.flow.instructions.Instruction;
alshabib9af70072015-02-09 14:34:16 -080028import org.onosproject.net.flow.instructions.Instructions;
sangho8995ac52015-02-04 11:29:03 -080029import org.onosproject.net.flow.instructions.Instructions.GroupInstruction;
alshabib9af70072015-02-09 14:34:16 -080030import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080031import org.onosproject.net.flow.instructions.L0ModificationInstruction;
32import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -070033import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080034import org.onosproject.net.flow.instructions.L2ModificationInstruction;
35import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
Jonathan Hart29afca32015-01-20 18:17:39 -080036import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080037import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
38import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
40import org.onosproject.net.flow.instructions.L3ModificationInstruction;
41import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080042import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
Jonathan Hart86e59352014-10-22 10:42:16 -070043import org.projectfloodlight.openflow.protocol.OFFactory;
44import org.projectfloodlight.openflow.protocol.OFFlowAdd;
45import org.projectfloodlight.openflow.protocol.OFFlowDelete;
46import org.projectfloodlight.openflow.protocol.OFFlowMod;
47import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
48import org.projectfloodlight.openflow.protocol.action.OFAction;
sangho8995ac52015-02-04 11:29:03 -080049import org.projectfloodlight.openflow.protocol.action.OFActionGroup;
Charles M.C. Chanfe421812015-01-12 18:20:51 +080050import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
alshabib9af70072015-02-09 14:34:16 -080051import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
Jonathan Hart86e59352014-10-22 10:42:16 -070052import org.projectfloodlight.openflow.protocol.match.Match;
53import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
54import org.projectfloodlight.openflow.types.CircuitSignalID;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080055import org.projectfloodlight.openflow.types.EthType;
Jonathan Hart86e59352014-10-22 10:42:16 -070056import org.projectfloodlight.openflow.types.IPv4Address;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080057import org.projectfloodlight.openflow.types.IPv6Address;
58import org.projectfloodlight.openflow.types.IPv6FlowLabel;
Jonathan Hart86e59352014-10-22 10:42:16 -070059import org.projectfloodlight.openflow.types.MacAddress;
60import org.projectfloodlight.openflow.types.OFBufferId;
sangho8995ac52015-02-04 11:29:03 -080061import org.projectfloodlight.openflow.types.OFGroup;
Jonathan Hart86e59352014-10-22 10:42:16 -070062import org.projectfloodlight.openflow.types.OFPort;
63import org.projectfloodlight.openflow.types.OFVlanVidMatch;
alshabib9af70072015-02-09 14:34:16 -080064import org.projectfloodlight.openflow.types.TableId;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080065import org.projectfloodlight.openflow.types.U32;
Jonathan Hart86e59352014-10-22 10:42:16 -070066import org.projectfloodlight.openflow.types.U64;
67import org.projectfloodlight.openflow.types.VlanPcp;
68import org.slf4j.Logger;
69import org.slf4j.LoggerFactory;
70
Jonathan Hart29afca32015-01-20 18:17:39 -080071import java.util.Collections;
72import java.util.LinkedList;
73import java.util.List;
74import java.util.Optional;
75
Jonathan Hart86e59352014-10-22 10:42:16 -070076/**
77 * Flow mod builder for OpenFlow 1.3+.
78 */
79public class FlowModBuilderVer13 extends FlowModBuilder {
80
alshabib10580802015-02-18 18:30:33 -080081 private final Logger log = LoggerFactory.getLogger(getClass());
Charles M.C. Chanfe421812015-01-12 18:20:51 +080082 private static final int OFPCML_NO_BUFFER = 0xffff;
Jonathan Hart86e59352014-10-22 10:42:16 -070083
84 private final TrafficTreatment treatment;
85
86 /**
87 * Constructor for a flow mod builder for OpenFlow 1.3.
88 *
89 * @param flowRule the flow rule to transform into a flow mod
90 * @param factory the OpenFlow factory to use to build the flow mod
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -080091 * @param xid the transaction ID
Jonathan Hart86e59352014-10-22 10:42:16 -070092 */
Brian O'Connor427a1762014-11-19 18:40:32 -080093 protected FlowModBuilderVer13(FlowRule flowRule, OFFactory factory, Optional<Long> xid) {
94 super(flowRule, factory, xid);
Jonathan Hart86e59352014-10-22 10:42:16 -070095
96 this.treatment = flowRule.treatment();
97 }
98
99 @Override
100 public OFFlowAdd buildFlowAdd() {
101 Match match = buildMatch();
alshabib346b5b32015-03-06 00:42:16 -0800102 List<OFAction> deferredActions = buildActions(treatment.deferred());
103 List<OFAction> immediateActions = buildActions(treatment.immediate());
104 List<OFInstruction> instructions = Lists.newLinkedList();
Saurav Dascbe6de32015-03-01 18:30:46 -0800105
Jonathan Hartd4a8bba2014-10-28 12:44:20 -0700106
alshabib346b5b32015-03-06 00:42:16 -0800107 if (treatment.clearedDeferred()) {
108 instructions.add(factory().instructions().clearActions());
109 }
sangho1e575652015-05-14 00:39:53 -0700110 if (immediateActions.size() > 0) {
111 instructions.add(factory().instructions().applyActions(immediateActions));
112 }
alshabib346b5b32015-03-06 00:42:16 -0800113 if (deferredActions.size() > 0) {
114 instructions.add(factory().instructions().writeActions(deferredActions));
115 }
116 if (treatment.tableTransition() != null) {
117 instructions.add(buildTableGoto(treatment.tableTransition()));
Saurav Dascbe6de32015-03-01 18:30:46 -0800118 }
Jonathan Hart86e59352014-10-22 10:42:16 -0700119
120 long cookie = flowRule().id().value();
121
Jonathan Hart86e59352014-10-22 10:42:16 -0700122 OFFlowAdd fm = factory().buildFlowAdd()
Brian O'Connor427a1762014-11-19 18:40:32 -0800123 .setXid(xid)
Jonathan Hart86e59352014-10-22 10:42:16 -0700124 .setCookie(U64.of(cookie))
125 .setBufferId(OFBufferId.NO_BUFFER)
alshabib9af70072015-02-09 14:34:16 -0800126 .setInstructions(instructions)
Jonathan Hart86e59352014-10-22 10:42:16 -0700127 .setMatch(match)
128 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
129 .setPriority(flowRule().priority())
alshabib08d98982015-04-21 16:25:50 -0700130 .setTableId(TableId.of(flowRule().tableId()))
Jonathan Hart86e59352014-10-22 10:42:16 -0700131 .build();
132
133 return fm;
134 }
135
136 @Override
137 public OFFlowMod buildFlowMod() {
138 Match match = buildMatch();
alshabib346b5b32015-03-06 00:42:16 -0800139 List<OFAction> deferredActions = buildActions(treatment.deferred());
140 List<OFAction> immediateActions = buildActions(treatment.immediate());
141 List<OFInstruction> instructions = Lists.newLinkedList();
Jonathan Harteda33872015-02-18 10:22:32 -0800142
alshabib346b5b32015-03-06 00:42:16 -0800143
144 if (immediateActions.size() > 0) {
145 instructions.add(factory().instructions().applyActions(immediateActions));
146 }
147 if (treatment.clearedDeferred()) {
148 instructions.add(factory().instructions().clearActions());
149 }
150 if (deferredActions.size() > 0) {
151 instructions.add(factory().instructions().writeActions(deferredActions));
152 }
153 if (treatment.tableTransition() != null) {
154 instructions.add(buildTableGoto(treatment.tableTransition()));
Saurav Dascbe6de32015-03-01 18:30:46 -0800155 }
Jonathan Hart86e59352014-10-22 10:42:16 -0700156
157 long cookie = flowRule().id().value();
158
Jonathan Hart86e59352014-10-22 10:42:16 -0700159 OFFlowMod fm = factory().buildFlowModify()
Brian O'Connor427a1762014-11-19 18:40:32 -0800160 .setXid(xid)
Jonathan Hart86e59352014-10-22 10:42:16 -0700161 .setCookie(U64.of(cookie))
162 .setBufferId(OFBufferId.NO_BUFFER)
alshabib9af70072015-02-09 14:34:16 -0800163 .setInstructions(instructions)
Jonathan Hart86e59352014-10-22 10:42:16 -0700164 .setMatch(match)
165 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
166 .setPriority(flowRule().priority())
alshabib08d98982015-04-21 16:25:50 -0700167 .setTableId(TableId.of(flowRule().tableId()))
Jonathan Hart86e59352014-10-22 10:42:16 -0700168 .build();
169
170 return fm;
171 }
172
173 @Override
174 public OFFlowDelete buildFlowDel() {
175 Match match = buildMatch();
Jonathan Hart86e59352014-10-22 10:42:16 -0700176
177 long cookie = flowRule().id().value();
178
179 OFFlowDelete fm = factory().buildFlowDelete()
Brian O'Connor427a1762014-11-19 18:40:32 -0800180 .setXid(xid)
Jonathan Hart86e59352014-10-22 10:42:16 -0700181 .setCookie(U64.of(cookie))
182 .setBufferId(OFBufferId.NO_BUFFER)
Jonathan Hart86e59352014-10-22 10:42:16 -0700183 .setMatch(match)
184 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
185 .setPriority(flowRule().priority())
alshabib08d98982015-04-21 16:25:50 -0700186 .setTableId(TableId.of(flowRule().tableId()))
Jonathan Hart86e59352014-10-22 10:42:16 -0700187 .build();
188
189 return fm;
190 }
191
alshabib346b5b32015-03-06 00:42:16 -0800192 private List<OFAction> buildActions(List<Instruction> treatments) {
Jonathan Hart86e59352014-10-22 10:42:16 -0700193 if (treatment == null) {
Sho SHIMIZU6601dd72015-05-11 19:00:29 -0700194 return Collections.emptyList();
Jonathan Hart86e59352014-10-22 10:42:16 -0700195 }
Sho SHIMIZU6601dd72015-05-11 19:00:29 -0700196
197 boolean tableFound = false;
198 List<OFAction> actions = new LinkedList<>();
alshabib346b5b32015-03-06 00:42:16 -0800199 for (Instruction i : treatments) {
Jonathan Hart86e59352014-10-22 10:42:16 -0700200 switch (i.type()) {
alshabib9af70072015-02-09 14:34:16 -0800201 case DROP:
Sho SHIMIZUb35ed362015-04-28 11:05:19 -0700202 return Collections.emptyList();
alshabib9af70072015-02-09 14:34:16 -0800203 case L0MODIFICATION:
204 actions.add(buildL0Modification(i));
205 break;
206 case L2MODIFICATION:
207 actions.add(buildL2Modification(i));
208 break;
209 case L3MODIFICATION:
210 actions.add(buildL3Modification(i));
211 break;
212 case OUTPUT:
213 OutputInstruction out = (OutputInstruction) i;
214 OFActionOutput.Builder action = factory().actions().buildOutput()
215 .setPort(OFPort.of((int) out.port().toLong()));
216 if (out.port().equals(PortNumber.CONTROLLER)) {
217 action.setMaxLen(OFPCML_NO_BUFFER);
218 }
219 actions.add(action.build());
220 break;
221 case GROUP:
222 GroupInstruction group = (GroupInstruction) i;
223 OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
224 .setGroup(OFGroup.of(group.groupId().id()));
225 actions.add(groupBuilder.build());
226 break;
alshabib10580802015-02-18 18:30:33 -0800227 case TABLE:
228 //FIXME: should not occur here.
Saurav Dascbe6de32015-03-01 18:30:46 -0800229 tableFound = true;
alshabib10580802015-02-18 18:30:33 -0800230 break;
alshabib9af70072015-02-09 14:34:16 -0800231 default:
232 log.warn("Instruction type {} not yet implemented.", i.type());
Jonathan Hart86e59352014-10-22 10:42:16 -0700233 }
234 }
Saurav Dascbe6de32015-03-01 18:30:46 -0800235 if (tableFound && actions.isEmpty()) {
236 // handles the case where there are no actions, but there is
237 // a goto instruction for the next table
Sho SHIMIZU6601dd72015-05-11 19:00:29 -0700238 return Collections.emptyList();
Saurav Dascbe6de32015-03-01 18:30:46 -0800239 }
Jonathan Hart86e59352014-10-22 10:42:16 -0700240 return actions;
241 }
242
alshabib9af70072015-02-09 14:34:16 -0800243 private OFInstruction buildTableGoto(Instructions.TableTypeTransition i) {
244 OFInstruction instruction = factory().instructions().gotoTable(
alshabibd17abc22015-04-21 18:26:35 -0700245 TableId.of(i.tableId()));
alshabib9af70072015-02-09 14:34:16 -0800246 return instruction;
247 }
248
Jonathan Hart86e59352014-10-22 10:42:16 -0700249 private OFAction buildL0Modification(Instruction i) {
250 L0ModificationInstruction l0m = (L0ModificationInstruction) i;
251 switch (l0m.subtype()) {
Sho SHIMIZU5cd7ce92015-05-11 19:10:38 -0700252 case LAMBDA:
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -0700253 return buildModLambdaInstruction((ModLambdaInstruction) i);
254 case OCH:
255 try {
256 return buildModOchSignalInstruction((ModOchSignalInstruction) i);
257 } catch (UnsupportedGridTypeException | UnsupportedChannelSpacingException e) {
258 log.warn(e.getMessage());
259 break;
260 }
Sho SHIMIZU5cd7ce92015-05-11 19:10:38 -0700261 default:
262 log.warn("Unimplemented action type {}.", l0m.subtype());
263 break;
Jonathan Hart86e59352014-10-22 10:42:16 -0700264 }
265 return null;
266 }
267
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -0700268 private OFAction buildModLambdaInstruction(ModLambdaInstruction instruction) {
269 return factory().actions().circuit(factory().oxms().ochSigidBasic(
270 new CircuitSignalID((byte) 1, (byte) 2, instruction.lambda(), (short) 1)));
271 }
272
273 private OFAction buildModOchSignalInstruction(ModOchSignalInstruction instruction) {
274 OchSignal signal = instruction.lambda();
275 byte gridType = convertGridType(signal.gridType());
276 byte channelSpacing = convertChannelSpacing(signal.channelSpacing());
277
278 return factory().actions().circuit(factory().oxms().ochSigidBasic(
279 new CircuitSignalID(gridType, channelSpacing,
280 (short) signal.spacingMultiplier(), (short) signal.slotGranularity())
281 ));
282 }
283
284 private byte convertGridType(GridType type) {
285 // See ONF "Optical Transport Protocol Extensions Version 1.0"
286 // for the following values
287 switch (type) {
288 case DWDM:
289 // OFPGRIDT_DWDM of enum ofp_grid_type
290 return 1;
291 case CWDM:
292 // OFPGRIDT_CWDM of enum ofp_grid_type
293 return 2;
294 case FLEX:
295 // OFPGRIDT_FLEX of enum ofp_grid_type
296 return 3;
297 default:
298 throw new UnsupportedGridTypeException(type);
299 }
300 }
301
302 private byte convertChannelSpacing(ChannelSpacing spacing) {
303 // See ONF "Optical Transport Protocol Extensions Version 1.0"
304 // for the following values
305 switch (spacing) {
306 case CHL_100GHZ:
307 // OFPCS_100GHZ of enum ofp_chl_spacing
308 return 1;
309 case CHL_50GHZ:
310 // OFPCS_50GHZ of enum ofp_chl_spacing
311 return 2;
312 case CHL_25GHZ:
313 // OFPCS_25GHZ of enum ofp_chl_spacing
314 return 3;
315 case CHL_12P5GHZ:
316 // OFPCS_12P5GHZ of enum ofp_chl_spacing
317 return 4;
318 case CHL_6P25GHZ:
319 // OFPCS_6P25GHZ of enum ofp_chl_spacing
320 return 5;
321 default:
322 throw new UnsupportedChannelSpacingException(spacing);
323 }
324 }
325
Jonathan Hart86e59352014-10-22 10:42:16 -0700326 private OFAction buildL2Modification(Instruction i) {
327 L2ModificationInstruction l2m = (L2ModificationInstruction) i;
328 ModEtherInstruction eth;
329 OFOxm<?> oxm = null;
330 switch (l2m.subtype()) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800331 case ETH_DST:
332 eth = (ModEtherInstruction) l2m;
333 oxm = factory().oxms().ethDst(MacAddress.of(eth.mac().toLong()));
334 break;
335 case ETH_SRC:
336 eth = (ModEtherInstruction) l2m;
337 oxm = factory().oxms().ethSrc(MacAddress.of(eth.mac().toLong()));
338 break;
339 case VLAN_ID:
340 ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m;
341 oxm = factory().oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort()));
342 break;
343 case VLAN_PCP:
344 ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m;
345 oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
346 break;
347 case MPLS_PUSH:
348 PushHeaderInstructions pushHeaderInstructions =
349 (PushHeaderInstructions) l2m;
350 return factory().actions().pushMpls(EthType.of(pushHeaderInstructions
Yuta HIGUCHI32a53c52015-02-08 01:25:40 -0800351 .ethernetType()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800352 case MPLS_POP:
Jonathan Hart67fc0972015-03-19 15:21:20 -0700353 PushHeaderInstructions popHeaderInstructions =
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800354 (PushHeaderInstructions) l2m;
355 return factory().actions().popMpls(EthType.of(popHeaderInstructions
Yuta HIGUCHI32a53c52015-02-08 01:25:40 -0800356 .ethernetType()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800357 case MPLS_LABEL:
358 ModMplsLabelInstruction mplsLabel =
359 (ModMplsLabelInstruction) l2m;
360 oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label()
361 .longValue()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800362 break;
sangho3f97a17d2015-01-29 22:56:29 -0800363 case DEC_MPLS_TTL:
364 return factory().actions().decMplsTtl();
Saurav Dasfbe25c52015-03-04 11:12:00 -0800365 case VLAN_POP:
366 return factory().actions().popVlan();
Jonathan Hart54b406b2015-03-06 16:24:14 -0800367 case VLAN_PUSH:
368 PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m;
369 return factory().actions().pushVlan(
370 EthType.of(pushVlanInstruction.ethernetType()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800371 default:
372 log.warn("Unimplemented action type {}.", l2m.subtype());
373 break;
Jonathan Hart86e59352014-10-22 10:42:16 -0700374 }
375
376 if (oxm != null) {
377 return factory().actions().buildSetField().setField(oxm).build();
378 }
379 return null;
380 }
381
382 private OFAction buildL3Modification(Instruction i) {
383 L3ModificationInstruction l3m = (L3ModificationInstruction) i;
384 ModIPInstruction ip;
Pavlin Radoslavov23e398d2014-11-05 15:17:57 -0800385 Ip4Address ip4;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800386 Ip6Address ip6;
Jonathan Hart86e59352014-10-22 10:42:16 -0700387 OFOxm<?> oxm = null;
388 switch (l3m.subtype()) {
Sho SHIMIZU5cd7ce92015-05-11 19:10:38 -0700389 case IPV4_SRC:
390 ip = (ModIPInstruction) i;
391 ip4 = ip.ip().getIp4Address();
392 oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt()));
393 break;
394 case IPV4_DST:
395 ip = (ModIPInstruction) i;
396 ip4 = ip.ip().getIp4Address();
397 oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt()));
398 break;
399 case IPV6_SRC:
400 ip = (ModIPInstruction) i;
401 ip6 = ip.ip().getIp6Address();
402 oxm = factory().oxms().ipv6Src(IPv6Address.of(ip6.toOctets()));
403 break;
404 case IPV6_DST:
405 ip = (ModIPInstruction) i;
406 ip6 = ip.ip().getIp6Address();
407 oxm = factory().oxms().ipv6Dst(IPv6Address.of(ip6.toOctets()));
408 break;
409 case IPV6_FLABEL:
410 ModIPv6FlowLabelInstruction flowLabelInstruction =
411 (ModIPv6FlowLabelInstruction) i;
412 int flowLabel = flowLabelInstruction.flowLabel();
413 oxm = factory().oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel));
414 break;
415 case DEC_TTL:
416 return factory().actions().decNwTtl();
417 case TTL_IN:
418 return factory().actions().copyTtlIn();
419 case TTL_OUT:
420 return factory().actions().copyTtlOut();
421 default:
422 log.warn("Unimplemented action type {}.", l3m.subtype());
423 break;
Jonathan Hart86e59352014-10-22 10:42:16 -0700424 }
425
426 if (oxm != null) {
427 return factory().actions().buildSetField().setField(oxm).build();
428 }
429 return null;
430 }
431
432}