Saurav Das
Committed by Gerrit Code Review

Support for setting the MPLS BOS indicator bit.

Change-Id: Ib42747445113aadb62fd161a1c79ca59783884af
...@@ -343,6 +343,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -343,6 +343,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
343 } 343 }
344 344
345 @Override 345 @Override
346 + public Builder setMplsBos(boolean mplsBos) {
347 + return add(Instructions.modMplsBos(mplsBos));
348 + }
349 +
350 + @Override
346 public Builder decMplsTtl() { 351 public Builder decMplsTtl() {
347 return add(Instructions.decMplsTtl()); 352 return add(Instructions.decMplsTtl());
348 } 353 }
......
...@@ -227,6 +227,14 @@ public interface TrafficTreatment { ...@@ -227,6 +227,14 @@ public interface TrafficTreatment {
227 Builder setMpls(MplsLabel mplsLabel); 227 Builder setMpls(MplsLabel mplsLabel);
228 228
229 /** 229 /**
230 + * Sets the mpls bottom-of-stack indicator bit.
231 + *
232 + * @param mplsBos boolean to set BOS=1 (true) or BOS=0 (false).
233 + * @return a treatment builder.
234 + */
235 + Builder setMplsBos(boolean mplsBos);
236 +
237 + /**
230 * Decrement MPLS TTL. 238 * Decrement MPLS TTL.
231 * 239 *
232 * @return a treatment builder 240 * @return a treatment builder
......
...@@ -176,6 +176,16 @@ public final class Instructions { ...@@ -176,6 +176,16 @@ public final class Instructions {
176 } 176 }
177 177
178 /** 178 /**
179 + * Creates a MPLS BOS bit modification.
180 + *
181 + * @param mplsBos MPLS BOS bit to set (true) or unset (false)
182 + * @return a L2 Modification
183 + */
184 + public static L2ModificationInstruction modMplsBos(boolean mplsBos) {
185 + return new L2ModificationInstruction.ModMplsBosInstruction(mplsBos);
186 + }
187 +
188 + /**
179 * Creates a MPLS decrement TTL modification. 189 * Creates a MPLS decrement TTL modification.
180 * 190 *
181 * @return a L2 Modification 191 * @return a L2 Modification
...@@ -673,6 +683,7 @@ public final class Instructions { ...@@ -673,6 +683,7 @@ public final class Instructions {
673 return false; 683 return false;
674 } 684 }
675 } 685 }
686 +
676 } 687 }
677 688
678 689
......
...@@ -84,9 +84,14 @@ public abstract class L2ModificationInstruction implements Instruction { ...@@ -84,9 +84,14 @@ public abstract class L2ModificationInstruction implements Instruction {
84 VLAN_PUSH, 84 VLAN_PUSH,
85 85
86 /** 86 /**
87 - * Tunnle id modification. 87 + * Tunnel id modification.
88 */ 88 */
89 - TUNNEL_ID 89 + TUNNEL_ID,
90 +
91 + /**
92 + * MPLS BOS instruction.
93 + */
94 + MPLS_BOS
90 } 95 }
91 96
92 // TODO: Create factory class 'Instructions' that will have various factory 97 // TODO: Create factory class 'Instructions' that will have various factory
...@@ -371,6 +376,51 @@ public abstract class L2ModificationInstruction implements Instruction { ...@@ -371,6 +376,51 @@ public abstract class L2ModificationInstruction implements Instruction {
371 } 376 }
372 377
373 /** 378 /**
379 + * Represents a MPLS BOS modification.
380 + */
381 + public static final class ModMplsBosInstruction
382 + extends L2ModificationInstruction {
383 +
384 + private final boolean mplsBos;
385 +
386 + ModMplsBosInstruction(boolean mplsBos) {
387 + this.mplsBos = mplsBos;
388 + }
389 +
390 + public boolean mplsBos() {
391 + return mplsBos;
392 + }
393 +
394 + @Override
395 + public L2SubType subtype() {
396 + return L2SubType.MPLS_BOS;
397 + }
398 +
399 + @Override
400 + public String toString() {
401 + return toStringHelper(subtype().toString()).add("bos", mplsBos)
402 + .toString();
403 + }
404 +
405 + @Override
406 + public int hashCode() {
407 + return Objects.hash(type(), subtype(), mplsBos);
408 + }
409 +
410 + @Override
411 + public boolean equals(Object obj) {
412 + if (this == obj) {
413 + return true;
414 + }
415 + if (obj instanceof ModMplsBosInstruction) {
416 + ModMplsBosInstruction that = (ModMplsBosInstruction) obj;
417 + return Objects.equals(mplsBos, that.mplsBos());
418 + }
419 + return false;
420 + }
421 + }
422 +
423 + /**
374 * Represents a MPLS TTL modification. 424 * Represents a MPLS TTL modification.
375 */ 425 */
376 public static final class ModMplsTtlInstruction 426 public static final class ModMplsTtlInstruction
......
...@@ -404,6 +404,11 @@ public class FlowEntryBuilder { ...@@ -404,6 +404,11 @@ public class FlowEntryBuilder {
404 OFOxm<U32> labelId = (OFOxm<U32>) oxm; 404 OFOxm<U32> labelId = (OFOxm<U32>) oxm;
405 builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue())); 405 builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue()));
406 break; 406 break;
407 + case MPLS_BOS:
408 + @SuppressWarnings("unchecked")
409 + OFOxm<U8> mplsBos = (OFOxm<U8>) oxm;
410 + builder.setMplsBos(mplsBos.getValue() == U8.ZERO ? false : true);
411 + break;
407 case TUNNEL_ID: 412 case TUNNEL_ID:
408 @SuppressWarnings("unchecked") 413 @SuppressWarnings("unchecked")
409 OFOxm<U64> tunnelId = (OFOxm<U64>) oxm; 414 OFOxm<U64> tunnelId = (OFOxm<U64>) oxm;
......
...@@ -31,6 +31,7 @@ import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambda ...@@ -31,6 +31,7 @@ import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambda
31 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction; 31 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
32 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 32 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
33 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; 33 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
34 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsBosInstruction;
34 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction; 35 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
35 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; 36 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
36 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; 37 import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
...@@ -58,6 +59,7 @@ import org.projectfloodlight.openflow.types.IPv4Address; ...@@ -58,6 +59,7 @@ import org.projectfloodlight.openflow.types.IPv4Address;
58 import org.projectfloodlight.openflow.types.IPv6Address; 59 import org.projectfloodlight.openflow.types.IPv6Address;
59 import org.projectfloodlight.openflow.types.IPv6FlowLabel; 60 import org.projectfloodlight.openflow.types.IPv6FlowLabel;
60 import org.projectfloodlight.openflow.types.MacAddress; 61 import org.projectfloodlight.openflow.types.MacAddress;
62 +import org.projectfloodlight.openflow.types.OFBooleanValue;
61 import org.projectfloodlight.openflow.types.OFBufferId; 63 import org.projectfloodlight.openflow.types.OFBufferId;
62 import org.projectfloodlight.openflow.types.OFGroup; 64 import org.projectfloodlight.openflow.types.OFGroup;
63 import org.projectfloodlight.openflow.types.OFPort; 65 import org.projectfloodlight.openflow.types.OFPort;
...@@ -343,6 +345,12 @@ public class FlowModBuilderVer13 extends FlowModBuilder { ...@@ -343,6 +345,12 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
343 oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label() 345 oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label()
344 .longValue())); 346 .longValue()));
345 break; 347 break;
348 + case MPLS_BOS:
349 + ModMplsBosInstruction mplsBos = (ModMplsBosInstruction) l2m;
350 + oxm = factory().oxms()
351 + .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE
352 + : OFBooleanValue.FALSE);
353 + break;
346 case DEC_MPLS_TTL: 354 case DEC_MPLS_TTL:
347 return factory().actions().decMplsTtl(); 355 return factory().actions().decMplsTtl();
348 case VLAN_POP: 356 case VLAN_POP:
......
...@@ -56,6 +56,7 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic; ...@@ -56,6 +56,7 @@ import org.projectfloodlight.openflow.protocol.oxm.OFOxmOchSigidBasic;
56 import org.projectfloodlight.openflow.types.IPv4Address; 56 import org.projectfloodlight.openflow.types.IPv4Address;
57 import org.projectfloodlight.openflow.types.OFVlanVidMatch; 57 import org.projectfloodlight.openflow.types.OFVlanVidMatch;
58 import org.projectfloodlight.openflow.types.U32; 58 import org.projectfloodlight.openflow.types.U32;
59 +import org.projectfloodlight.openflow.types.U8;
59 import org.projectfloodlight.openflow.types.VlanPcp; 60 import org.projectfloodlight.openflow.types.VlanPcp;
60 import org.slf4j.Logger; 61 import org.slf4j.Logger;
61 62
...@@ -277,6 +278,11 @@ public class GroupBucketEntryBuilder { ...@@ -277,6 +278,11 @@ public class GroupBucketEntryBuilder {
277 OFOxm<U32> labelId = (OFOxm<U32>) oxm; 278 OFOxm<U32> labelId = (OFOxm<U32>) oxm;
278 builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue())); 279 builder.setMpls(MplsLabel.mplsLabel((int) labelId.getValue().getValue()));
279 break; 280 break;
281 + case MPLS_BOS:
282 + @SuppressWarnings("unchecked")
283 + OFOxm<U8> mplsBos = (OFOxm<U8>) oxm;
284 + builder.setMplsBos(mplsBos.getValue() == U8.ZERO ? false : true);
285 + break;
280 case ARP_OP: 286 case ARP_OP:
281 case ARP_SHA: 287 case ARP_SHA:
282 case ARP_SPA: 288 case ARP_SPA:
......
...@@ -44,6 +44,7 @@ import org.projectfloodlight.openflow.types.IPv4Address; ...@@ -44,6 +44,7 @@ import org.projectfloodlight.openflow.types.IPv4Address;
44 import org.projectfloodlight.openflow.types.IPv6Address; 44 import org.projectfloodlight.openflow.types.IPv6Address;
45 import org.projectfloodlight.openflow.types.IPv6FlowLabel; 45 import org.projectfloodlight.openflow.types.IPv6FlowLabel;
46 import org.projectfloodlight.openflow.types.MacAddress; 46 import org.projectfloodlight.openflow.types.MacAddress;
47 +import org.projectfloodlight.openflow.types.OFBooleanValue;
47 import org.projectfloodlight.openflow.types.OFGroup; 48 import org.projectfloodlight.openflow.types.OFGroup;
48 import org.projectfloodlight.openflow.types.OFPort; 49 import org.projectfloodlight.openflow.types.OFPort;
49 import org.projectfloodlight.openflow.types.OFVlanVidMatch; 50 import org.projectfloodlight.openflow.types.OFVlanVidMatch;
...@@ -286,6 +287,13 @@ public final class GroupModBuilder { ...@@ -286,6 +287,13 @@ public final class GroupModBuilder {
286 oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label() 287 oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label()
287 .longValue())); 288 .longValue()));
288 break; 289 break;
290 + case MPLS_BOS:
291 + L2ModificationInstruction.ModMplsBosInstruction mplsBos =
292 + (L2ModificationInstruction.ModMplsBosInstruction) l2m;
293 + oxm = factory.oxms()
294 + .mplsBos(mplsBos.mplsBos() ? OFBooleanValue.TRUE
295 + : OFBooleanValue.FALSE);
296 + break;
289 case DEC_MPLS_TTL: 297 case DEC_MPLS_TTL:
290 return factory.actions().decMplsTtl(); 298 return factory.actions().decMplsTtl();
291 default: 299 default:
......