diff options
Diffstat (limited to 'framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java')
-rw-r--r-- | framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java index d12e4ad8..2ec301db 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java @@ -15,11 +15,14 @@ */ package org.onosproject.codec.impl; +import org.onlab.util.HexString; import org.onosproject.codec.CodecContext; import org.onosproject.net.OchSignal; +import org.onosproject.net.OduSignalId; import org.onosproject.net.flow.instructions.Instruction; import org.onosproject.net.flow.instructions.Instructions; import org.onosproject.net.flow.instructions.L0ModificationInstruction; +import org.onosproject.net.flow.instructions.L1ModificationInstruction; import org.onosproject.net.flow.instructions.L2ModificationInstruction; import org.onosproject.net.flow.instructions.L3ModificationInstruction; import org.onosproject.net.flow.instructions.L4ModificationInstruction; @@ -81,6 +84,36 @@ public final class EncodeInstructionCodecHelper { } /** + * Encode an L1 modification instruction. + * + * @param result json node that the instruction attributes are added to + * @param instruction The L1 instruction + * @param context context of the request + */ + private void encodeL1(ObjectNode result) { + L1ModificationInstruction instruction = + (L1ModificationInstruction) this.instruction; + result.put(InstructionCodec.SUBTYPE, instruction.subtype().name()); + + switch (instruction.subtype()) { + case ODU_SIGID: + final L1ModificationInstruction.ModOduSignalIdInstruction oduSignalIdInstruction = + (L1ModificationInstruction.ModOduSignalIdInstruction) instruction; + OduSignalId oduSignalId = oduSignalIdInstruction.oduSignalId(); + + ObjectNode child = result.putObject("oduSignalId"); + + child.put(InstructionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber()); + child.put(InstructionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength()); + child.put(InstructionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap())); + break; + default: + log.info("Cannot convert L1 subtype of {}", instruction.subtype()); + break; + } + } + + /** * Encode an L2 modification instruction. * * @param result json node that the instruction attributes are added to @@ -222,6 +255,10 @@ public final class EncodeInstructionCodecHelper { encodeL0(result); break; + case L1MODIFICATION: + encodeL1(result); + break; + case L2MODIFICATION: encodeL2(result); break; |