blob: 7bbc3759c83624c361855bb2ea7e0c581aa196b0 [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.OchSignal;
Charles M.C. Chanfe421812015-01-12 18:20:51 +080022import org.onosproject.net.PortNumber;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.net.flow.FlowRule;
24import org.onosproject.net.flow.TrafficTreatment;
25import org.onosproject.net.flow.instructions.Instruction;
alshabib9af70072015-02-09 14:34:16 -080026import org.onosproject.net.flow.instructions.Instructions;
sangho8995ac52015-02-04 11:29:03 -080027import org.onosproject.net.flow.instructions.Instructions.GroupInstruction;
alshabib9af70072015-02-09 14:34:16 -080028import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080029import org.onosproject.net.flow.instructions.L0ModificationInstruction;
30import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -070031import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080032import org.onosproject.net.flow.instructions.L2ModificationInstruction;
33import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
Jonathan Hart29afca32015-01-20 18:17:39 -080034import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080035import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
36import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080037import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
Hyunsun Moona08c5d02015-07-14 17:53:00 -070038import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModTunnelIdInstruction;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import org.onosproject.net.flow.instructions.L3ModificationInstruction;
40import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080041import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
Jonathan Hart86e59352014-10-22 10:42:16 -070042import org.projectfloodlight.openflow.protocol.OFFactory;
43import org.projectfloodlight.openflow.protocol.OFFlowAdd;
44import org.projectfloodlight.openflow.protocol.OFFlowDelete;
45import org.projectfloodlight.openflow.protocol.OFFlowMod;
46import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
47import org.projectfloodlight.openflow.protocol.action.OFAction;
sangho8995ac52015-02-04 11:29:03 -080048import org.projectfloodlight.openflow.protocol.action.OFActionGroup;
Charles M.C. Chanfe421812015-01-12 18:20:51 +080049import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
alshabib9af70072015-02-09 14:34:16 -080050import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
Jonathan Hart86e59352014-10-22 10:42:16 -070051import org.projectfloodlight.openflow.protocol.match.Match;
52import org.projectfloodlight.openflow.protocol.oxm.OFOxm;
53import org.projectfloodlight.openflow.types.CircuitSignalID;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080054import org.projectfloodlight.openflow.types.EthType;
Jonathan Hart86e59352014-10-22 10:42:16 -070055import org.projectfloodlight.openflow.types.IPv4Address;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -080056import org.projectfloodlight.openflow.types.IPv6Address;
57import org.projectfloodlight.openflow.types.IPv6FlowLabel;
Jonathan Hart86e59352014-10-22 10:42:16 -070058import org.projectfloodlight.openflow.types.MacAddress;
59import org.projectfloodlight.openflow.types.OFBufferId;
sangho8995ac52015-02-04 11:29:03 -080060import org.projectfloodlight.openflow.types.OFGroup;
Jonathan Hart86e59352014-10-22 10:42:16 -070061import org.projectfloodlight.openflow.types.OFPort;
62import org.projectfloodlight.openflow.types.OFVlanVidMatch;
alshabib9af70072015-02-09 14:34:16 -080063import org.projectfloodlight.openflow.types.TableId;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -080064import org.projectfloodlight.openflow.types.U32;
Jonathan Hart86e59352014-10-22 10:42:16 -070065import org.projectfloodlight.openflow.types.U64;
66import org.projectfloodlight.openflow.types.VlanPcp;
67import org.slf4j.Logger;
68import org.slf4j.LoggerFactory;
69
Jonathan Hart29afca32015-01-20 18:17:39 -080070import java.util.Collections;
71import java.util.LinkedList;
72import java.util.List;
73import java.util.Optional;
74
Jonathan Hart86e59352014-10-22 10:42:16 -070075/**
76 * Flow mod builder for OpenFlow 1.3+.
77 */
78public class FlowModBuilderVer13 extends FlowModBuilder {
79
alshabib10580802015-02-18 18:30:33 -080080 private final Logger log = LoggerFactory.getLogger(getClass());
Charles M.C. Chanfe421812015-01-12 18:20:51 +080081 private static final int OFPCML_NO_BUFFER = 0xffff;
Jonathan Hart86e59352014-10-22 10:42:16 -070082
83 private final TrafficTreatment treatment;
84
85 /**
86 * Constructor for a flow mod builder for OpenFlow 1.3.
87 *
88 * @param flowRule the flow rule to transform into a flow mod
89 * @param factory the OpenFlow factory to use to build the flow mod
Pavlin Radoslavov119fd5c2014-11-25 19:08:19 -080090 * @param xid the transaction ID
Jonathan Hart86e59352014-10-22 10:42:16 -070091 */
Brian O'Connor427a1762014-11-19 18:40:32 -080092 protected FlowModBuilderVer13(FlowRule flowRule, OFFactory factory, Optional<Long> xid) {
93 super(flowRule, factory, xid);
Jonathan Hart86e59352014-10-22 10:42:16 -070094
95 this.treatment = flowRule.treatment();
96 }
97
98 @Override
99 public OFFlowAdd buildFlowAdd() {
100 Match match = buildMatch();
alshabib346b5b32015-03-06 00:42:16 -0800101 List<OFAction> deferredActions = buildActions(treatment.deferred());
102 List<OFAction> immediateActions = buildActions(treatment.immediate());
103 List<OFInstruction> instructions = Lists.newLinkedList();
Saurav Dascbe6de32015-03-01 18:30:46 -0800104
Jonathan Hartd4a8bba2014-10-28 12:44:20 -0700105
alshabib346b5b32015-03-06 00:42:16 -0800106 if (treatment.clearedDeferred()) {
107 instructions.add(factory().instructions().clearActions());
108 }
sangho1e575652015-05-14 00:39:53 -0700109 if (immediateActions.size() > 0) {
110 instructions.add(factory().instructions().applyActions(immediateActions));
111 }
alshabib346b5b32015-03-06 00:42:16 -0800112 if (deferredActions.size() > 0) {
113 instructions.add(factory().instructions().writeActions(deferredActions));
114 }
115 if (treatment.tableTransition() != null) {
116 instructions.add(buildTableGoto(treatment.tableTransition()));
Saurav Dascbe6de32015-03-01 18:30:46 -0800117 }
Saurav Das86af8f12015-05-25 23:55:33 -0700118 if (treatment.writeMetadata() != null) {
119 instructions.add(buildMetadata(treatment.writeMetadata()));
120 }
Jonathan Hart86e59352014-10-22 10:42:16 -0700121
122 long cookie = flowRule().id().value();
123
Jonathan Hart86e59352014-10-22 10:42:16 -0700124 OFFlowAdd fm = factory().buildFlowAdd()
Brian O'Connor427a1762014-11-19 18:40:32 -0800125 .setXid(xid)
Jonathan Hart86e59352014-10-22 10:42:16 -0700126 .setCookie(U64.of(cookie))
127 .setBufferId(OFBufferId.NO_BUFFER)
alshabib9af70072015-02-09 14:34:16 -0800128 .setInstructions(instructions)
Jonathan Hart86e59352014-10-22 10:42:16 -0700129 .setMatch(match)
130 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
131 .setPriority(flowRule().priority())
alshabib08d98982015-04-21 16:25:50 -0700132 .setTableId(TableId.of(flowRule().tableId()))
Jonathan Hart86e59352014-10-22 10:42:16 -0700133 .build();
134
135 return fm;
136 }
137
138 @Override
139 public OFFlowMod buildFlowMod() {
140 Match match = buildMatch();
alshabib346b5b32015-03-06 00:42:16 -0800141 List<OFAction> deferredActions = buildActions(treatment.deferred());
142 List<OFAction> immediateActions = buildActions(treatment.immediate());
143 List<OFInstruction> instructions = Lists.newLinkedList();
Jonathan Harteda33872015-02-18 10:22:32 -0800144
alshabib346b5b32015-03-06 00:42:16 -0800145
146 if (immediateActions.size() > 0) {
147 instructions.add(factory().instructions().applyActions(immediateActions));
148 }
149 if (treatment.clearedDeferred()) {
150 instructions.add(factory().instructions().clearActions());
151 }
152 if (deferredActions.size() > 0) {
153 instructions.add(factory().instructions().writeActions(deferredActions));
154 }
155 if (treatment.tableTransition() != null) {
156 instructions.add(buildTableGoto(treatment.tableTransition()));
Saurav Dascbe6de32015-03-01 18:30:46 -0800157 }
Saurav Das86af8f12015-05-25 23:55:33 -0700158 if (treatment.writeMetadata() != null) {
159 instructions.add(buildMetadata(treatment.writeMetadata()));
160 }
Jonathan Hart86e59352014-10-22 10:42:16 -0700161
162 long cookie = flowRule().id().value();
163
Jonathan Hart86e59352014-10-22 10:42:16 -0700164 OFFlowMod fm = factory().buildFlowModify()
Brian O'Connor427a1762014-11-19 18:40:32 -0800165 .setXid(xid)
Jonathan Hart86e59352014-10-22 10:42:16 -0700166 .setCookie(U64.of(cookie))
167 .setBufferId(OFBufferId.NO_BUFFER)
alshabib9af70072015-02-09 14:34:16 -0800168 .setInstructions(instructions)
Jonathan Hart86e59352014-10-22 10:42:16 -0700169 .setMatch(match)
170 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
171 .setPriority(flowRule().priority())
alshabib08d98982015-04-21 16:25:50 -0700172 .setTableId(TableId.of(flowRule().tableId()))
Jonathan Hart86e59352014-10-22 10:42:16 -0700173 .build();
174
175 return fm;
176 }
177
178 @Override
179 public OFFlowDelete buildFlowDel() {
180 Match match = buildMatch();
Jonathan Hart86e59352014-10-22 10:42:16 -0700181
182 long cookie = flowRule().id().value();
183
184 OFFlowDelete fm = factory().buildFlowDelete()
Brian O'Connor427a1762014-11-19 18:40:32 -0800185 .setXid(xid)
Jonathan Hart86e59352014-10-22 10:42:16 -0700186 .setCookie(U64.of(cookie))
187 .setBufferId(OFBufferId.NO_BUFFER)
Jonathan Hart86e59352014-10-22 10:42:16 -0700188 .setMatch(match)
189 .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
190 .setPriority(flowRule().priority())
alshabib08d98982015-04-21 16:25:50 -0700191 .setTableId(TableId.of(flowRule().tableId()))
Jonathan Hart86e59352014-10-22 10:42:16 -0700192 .build();
193
194 return fm;
195 }
196
alshabib346b5b32015-03-06 00:42:16 -0800197 private List<OFAction> buildActions(List<Instruction> treatments) {
Jonathan Hart86e59352014-10-22 10:42:16 -0700198 if (treatment == null) {
Sho SHIMIZU6601dd72015-05-11 19:00:29 -0700199 return Collections.emptyList();
Jonathan Hart86e59352014-10-22 10:42:16 -0700200 }
Sho SHIMIZU6601dd72015-05-11 19:00:29 -0700201
202 boolean tableFound = false;
203 List<OFAction> actions = new LinkedList<>();
alshabib346b5b32015-03-06 00:42:16 -0800204 for (Instruction i : treatments) {
Jonathan Hart86e59352014-10-22 10:42:16 -0700205 switch (i.type()) {
alshabib9af70072015-02-09 14:34:16 -0800206 case DROP:
Sho SHIMIZUb35ed362015-04-28 11:05:19 -0700207 return Collections.emptyList();
alshabib9af70072015-02-09 14:34:16 -0800208 case L0MODIFICATION:
209 actions.add(buildL0Modification(i));
210 break;
211 case L2MODIFICATION:
212 actions.add(buildL2Modification(i));
213 break;
214 case L3MODIFICATION:
215 actions.add(buildL3Modification(i));
216 break;
217 case OUTPUT:
218 OutputInstruction out = (OutputInstruction) i;
219 OFActionOutput.Builder action = factory().actions().buildOutput()
220 .setPort(OFPort.of((int) out.port().toLong()));
221 if (out.port().equals(PortNumber.CONTROLLER)) {
222 action.setMaxLen(OFPCML_NO_BUFFER);
223 }
224 actions.add(action.build());
225 break;
226 case GROUP:
227 GroupInstruction group = (GroupInstruction) i;
228 OFActionGroup.Builder groupBuilder = factory().actions().buildGroup()
229 .setGroup(OFGroup.of(group.groupId().id()));
230 actions.add(groupBuilder.build());
231 break;
alshabib10580802015-02-18 18:30:33 -0800232 case TABLE:
233 //FIXME: should not occur here.
Saurav Dascbe6de32015-03-01 18:30:46 -0800234 tableFound = true;
alshabib10580802015-02-18 18:30:33 -0800235 break;
alshabib9af70072015-02-09 14:34:16 -0800236 default:
237 log.warn("Instruction type {} not yet implemented.", i.type());
Jonathan Hart86e59352014-10-22 10:42:16 -0700238 }
239 }
Saurav Dascbe6de32015-03-01 18:30:46 -0800240 if (tableFound && actions.isEmpty()) {
241 // handles the case where there are no actions, but there is
242 // a goto instruction for the next table
Sho SHIMIZU6601dd72015-05-11 19:00:29 -0700243 return Collections.emptyList();
Saurav Dascbe6de32015-03-01 18:30:46 -0800244 }
Jonathan Hart86e59352014-10-22 10:42:16 -0700245 return actions;
246 }
247
alshabib9af70072015-02-09 14:34:16 -0800248 private OFInstruction buildTableGoto(Instructions.TableTypeTransition i) {
249 OFInstruction instruction = factory().instructions().gotoTable(
alshabibd17abc22015-04-21 18:26:35 -0700250 TableId.of(i.tableId()));
alshabib9af70072015-02-09 14:34:16 -0800251 return instruction;
252 }
253
Saurav Das86af8f12015-05-25 23:55:33 -0700254 private OFInstruction buildMetadata(Instructions.MetadataInstruction m) {
255 OFInstruction instruction = factory().instructions().writeMetadata(
256 U64.of(m.metadata()), U64.of(m.metadataMask()));
257 return instruction;
258 }
259
Jonathan Hart86e59352014-10-22 10:42:16 -0700260 private OFAction buildL0Modification(Instruction i) {
261 L0ModificationInstruction l0m = (L0ModificationInstruction) i;
262 switch (l0m.subtype()) {
Sho SHIMIZU5cd7ce92015-05-11 19:10:38 -0700263 case LAMBDA:
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -0700264 return buildModLambdaInstruction((ModLambdaInstruction) i);
265 case OCH:
266 try {
267 return buildModOchSignalInstruction((ModOchSignalInstruction) i);
Sho SHIMIZUc17042d2015-05-28 12:07:23 -0700268 } catch (NoMappingFoundException e) {
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -0700269 log.warn(e.getMessage());
270 break;
271 }
Sho SHIMIZU5cd7ce92015-05-11 19:10:38 -0700272 default:
273 log.warn("Unimplemented action type {}.", l0m.subtype());
274 break;
Jonathan Hart86e59352014-10-22 10:42:16 -0700275 }
276 return null;
277 }
278
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -0700279 private OFAction buildModLambdaInstruction(ModLambdaInstruction instruction) {
280 return factory().actions().circuit(factory().oxms().ochSigidBasic(
281 new CircuitSignalID((byte) 1, (byte) 2, instruction.lambda(), (short) 1)));
282 }
283
284 private OFAction buildModOchSignalInstruction(ModOchSignalInstruction instruction) {
285 OchSignal signal = instruction.lambda();
Sho SHIMIZUc17042d2015-05-28 12:07:23 -0700286 byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
287 byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
Sho SHIMIZUe397ffe2015-05-12 16:24:23 -0700288
289 return factory().actions().circuit(factory().oxms().ochSigidBasic(
290 new CircuitSignalID(gridType, channelSpacing,
291 (short) signal.spacingMultiplier(), (short) signal.slotGranularity())
292 ));
293 }
294
Jonathan Hart86e59352014-10-22 10:42:16 -0700295 private OFAction buildL2Modification(Instruction i) {
296 L2ModificationInstruction l2m = (L2ModificationInstruction) i;
297 ModEtherInstruction eth;
298 OFOxm<?> oxm = null;
299 switch (l2m.subtype()) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800300 case ETH_DST:
301 eth = (ModEtherInstruction) l2m;
302 oxm = factory().oxms().ethDst(MacAddress.of(eth.mac().toLong()));
303 break;
304 case ETH_SRC:
305 eth = (ModEtherInstruction) l2m;
306 oxm = factory().oxms().ethSrc(MacAddress.of(eth.mac().toLong()));
307 break;
308 case VLAN_ID:
309 ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m;
310 oxm = factory().oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort()));
311 break;
312 case VLAN_PCP:
313 ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m;
314 oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
315 break;
316 case MPLS_PUSH:
317 PushHeaderInstructions pushHeaderInstructions =
318 (PushHeaderInstructions) l2m;
319 return factory().actions().pushMpls(EthType.of(pushHeaderInstructions
alshabib7b808c52015-06-26 14:22:24 -0700320 .ethernetType().toShort()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800321 case MPLS_POP:
Jonathan Hart67fc0972015-03-19 15:21:20 -0700322 PushHeaderInstructions popHeaderInstructions =
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800323 (PushHeaderInstructions) l2m;
324 return factory().actions().popMpls(EthType.of(popHeaderInstructions
alshabib7b808c52015-06-26 14:22:24 -0700325 .ethernetType().toShort()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800326 case MPLS_LABEL:
327 ModMplsLabelInstruction mplsLabel =
328 (ModMplsLabelInstruction) l2m;
329 oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label()
330 .longValue()));
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800331 break;
sangho3f97a17d2015-01-29 22:56:29 -0800332 case DEC_MPLS_TTL:
333 return factory().actions().decMplsTtl();
Saurav Dasfbe25c52015-03-04 11:12:00 -0800334 case VLAN_POP:
335 return factory().actions().popVlan();
Jonathan Hart54b406b2015-03-06 16:24:14 -0800336 case VLAN_PUSH:
337 PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m;
338 return factory().actions().pushVlan(
alshabib7b808c52015-06-26 14:22:24 -0700339 EthType.of(pushVlanInstruction.ethernetType().toShort()));
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700340 case TUNNEL_ID:
341 ModTunnelIdInstruction tunnelId = (ModTunnelIdInstruction) l2m;
342 oxm = factory().oxms().tunnelId(U64.of(tunnelId.tunnelId()));
343 break;
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800344 default:
345 log.warn("Unimplemented action type {}.", l2m.subtype());
346 break;
Jonathan Hart86e59352014-10-22 10:42:16 -0700347 }
348
349 if (oxm != null) {
350 return factory().actions().buildSetField().setField(oxm).build();
351 }
352 return null;
353 }
354
355 private OFAction buildL3Modification(Instruction i) {
356 L3ModificationInstruction l3m = (L3ModificationInstruction) i;
357 ModIPInstruction ip;
Pavlin Radoslavov23e398d2014-11-05 15:17:57 -0800358 Ip4Address ip4;
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800359 Ip6Address ip6;
Jonathan Hart86e59352014-10-22 10:42:16 -0700360 OFOxm<?> oxm = null;
361 switch (l3m.subtype()) {
Sho SHIMIZU5cd7ce92015-05-11 19:10:38 -0700362 case IPV4_SRC:
363 ip = (ModIPInstruction) i;
364 ip4 = ip.ip().getIp4Address();
365 oxm = factory().oxms().ipv4Src(IPv4Address.of(ip4.toInt()));
366 break;
367 case IPV4_DST:
368 ip = (ModIPInstruction) i;
369 ip4 = ip.ip().getIp4Address();
370 oxm = factory().oxms().ipv4Dst(IPv4Address.of(ip4.toInt()));
371 break;
372 case IPV6_SRC:
373 ip = (ModIPInstruction) i;
374 ip6 = ip.ip().getIp6Address();
375 oxm = factory().oxms().ipv6Src(IPv6Address.of(ip6.toOctets()));
376 break;
377 case IPV6_DST:
378 ip = (ModIPInstruction) i;
379 ip6 = ip.ip().getIp6Address();
380 oxm = factory().oxms().ipv6Dst(IPv6Address.of(ip6.toOctets()));
381 break;
382 case IPV6_FLABEL:
383 ModIPv6FlowLabelInstruction flowLabelInstruction =
384 (ModIPv6FlowLabelInstruction) i;
385 int flowLabel = flowLabelInstruction.flowLabel();
386 oxm = factory().oxms().ipv6Flabel(IPv6FlowLabel.of(flowLabel));
387 break;
388 case DEC_TTL:
389 return factory().actions().decNwTtl();
390 case TTL_IN:
391 return factory().actions().copyTtlIn();
392 case TTL_OUT:
393 return factory().actions().copyTtlOut();
394 default:
395 log.warn("Unimplemented action type {}.", l3m.subtype());
396 break;
Jonathan Hart86e59352014-10-22 10:42:16 -0700397 }
398
399 if (oxm != null) {
400 return factory().actions().buildSetField().setField(oxm).build();
401 }
402 return null;
403 }
404
405}