diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-03 14:08:10 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-03 14:08:10 -0800 |
commit | 643ee33289bd2cb9e6afbfb09b4ed72d467ba1c2 (patch) | |
tree | c2c376a44a359544fe3d4c45eb0cc0e2ec4a7080 /framework/src/onos/core/common/src/main/java/org | |
parent | 46eeb79b54345bdafb6055b8ee4bad4ce8b01274 (diff) |
This updates ONOS src tree to commit id
03fa5e571cabbd001ddb1598847e1150b11c7333
Change-Id: I13b554026d6f902933e35887d29bd5fdb669c0bd
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core/common/src/main/java/org')
5 files changed, 122 insertions, 9 deletions
diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java index 4e0f2bd9..69c5e791 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeCriterionCodecHelper.java @@ -15,6 +15,8 @@ */ package org.onosproject.codec.impl; +import static org.onlab.util.Tools.nullIsIllegal; + import java.util.HashMap; import java.util.Map; @@ -24,9 +26,13 @@ import org.onlab.packet.MacAddress; import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; +import org.onlab.util.HexString; import org.onosproject.net.ChannelSpacing; import org.onosproject.net.GridType; import org.onosproject.net.Lambda; +import org.onosproject.net.OchSignalType; +import org.onosproject.net.OduSignalId; +import org.onosproject.net.OduSignalType; import org.onosproject.net.PortNumber; import org.onosproject.net.flow.criteria.Criteria; import org.onosproject.net.flow.criteria.Criterion; @@ -34,8 +40,6 @@ import org.onosproject.net.flow.criteria.Criterion; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import static org.onlab.util.Tools.nullIsIllegal; - /** * Decode portion of the criterion codec. */ @@ -95,6 +99,8 @@ public final class DecodeCriterionCodecHelper { decoderMap.put(Criterion.Type.OCH_SIGID.name(), new OchSigIdDecoder()); decoderMap.put(Criterion.Type.OCH_SIGTYPE.name(), new OchSigTypeDecoder()); decoderMap.put(Criterion.Type.TUNNEL_ID.name(), new TunnelIdDecoder()); + decoderMap.put(Criterion.Type.ODU_SIGID.name(), new OduSigIdDecoder()); + decoderMap.put(Criterion.Type.ODU_SIGTYPE.name(), new OduSigTypeDecoder()); } private class EthTypeDecoder implements CriterionDecoder { @@ -415,7 +421,9 @@ public final class DecodeCriterionCodecHelper { private class OchSigTypeDecoder implements CriterionDecoder { @Override public Criterion decodeCriterion(ObjectNode json) { - return null; + OchSignalType ochSignalType = OchSignalType.valueOf(nullIsIllegal(json.get(CriterionCodec.OCH_SIGNAL_TYPE), + CriterionCodec.OCH_SIGNAL_TYPE + MISSING_MEMBER_MESSAGE).asText()); + return Criteria.matchOchSignalType(ochSignalType); } } @@ -428,6 +436,34 @@ public final class DecodeCriterionCodecHelper { } } + private class OduSigIdDecoder implements CriterionDecoder { + @Override + public Criterion decodeCriterion(ObjectNode json) { + JsonNode oduSignalId = nullIsIllegal(json.get(CriterionCodec.ODU_SIGNAL_ID), + CriterionCodec.TRIBUTARY_PORT_NUMBER + MISSING_MEMBER_MESSAGE); + + int tributaryPortNumber = nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_PORT_NUMBER), + CriterionCodec.TRIBUTARY_PORT_NUMBER + MISSING_MEMBER_MESSAGE).asInt(); + int tributarySlotLen = nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_SLOT_LEN), + CriterionCodec.TRIBUTARY_SLOT_LEN + MISSING_MEMBER_MESSAGE).asInt(); + byte[] tributarySlotBitmap = HexString.fromHexString( + nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP), + CriterionCodec.TRIBUTARY_SLOT_BITMAP + MISSING_MEMBER_MESSAGE).asText()); + + return Criteria.matchOduSignalId( + OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap)); + } + } + + private class OduSigTypeDecoder implements CriterionDecoder { + @Override + public Criterion decodeCriterion(ObjectNode json) { + OduSignalType oduSignalType = OduSignalType.valueOf(nullIsIllegal(json.get(CriterionCodec.ODU_SIGNAL_TYPE), + CriterionCodec.ODU_SIGNAL_TYPE + MISSING_MEMBER_MESSAGE).asText()); + return Criteria.matchOduSignalType(oduSignalType); + } + } + /** * Decodes the JSON into a criterion object. * diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java index 6a97a076..14555b3d 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/DecodeInstructionCodecHelper.java @@ -15,26 +15,29 @@ */ package org.onosproject.codec.impl; +import static org.onlab.util.Tools.nullIsIllegal; + import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; import org.onlab.packet.MplsLabel; import org.onlab.packet.TpPort; import org.onlab.packet.VlanId; +import org.onlab.util.HexString; import org.onosproject.net.ChannelSpacing; import org.onosproject.net.GridType; import org.onosproject.net.Lambda; import org.onosproject.net.OchSignal; +import org.onosproject.net.OduSignalId; import org.onosproject.net.PortNumber; - -import com.fasterxml.jackson.databind.node.ObjectNode; 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; -import static org.onlab.util.Tools.nullIsIllegal; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Decoding portion of the instruction codec. @@ -174,6 +177,30 @@ public final class DecodeInstructionCodecHelper { } /** + * Decodes a Layer 1 instruction. + * + * @return instruction object decoded from the JSON + * @throws IllegalArgumentException if the JSON is invalid + */ + private Instruction decodeL1() { + String subType = json.get(InstructionCodec.SUBTYPE).asText(); + if (subType.equals(L1ModificationInstruction.L1SubType.ODU_SIGID.name())) { + int tributaryPortNumber = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_PORT_NUMBER), + InstructionCodec.TRIBUTARY_PORT_NUMBER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt(); + int tributarySlotLen = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_LEN), + InstructionCodec.TRIBUTARY_SLOT_LEN + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt(); + byte[] tributarySlotBitmap = null; + tributarySlotBitmap = HexString.fromHexString( + nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_BITMAP), + InstructionCodec.TRIBUTARY_SLOT_BITMAP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText()); + return Instructions.modL1OduSignalId(OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, + tributarySlotBitmap)); + } + throw new IllegalArgumentException("L1 Instruction subtype " + + subType + " is not supported"); + } + + /** * Decodes a Layer 4 instruction. * * @return instruction object decoded from the JSON @@ -221,6 +248,8 @@ public final class DecodeInstructionCodecHelper { return Instructions.createDrop(); } else if (type.equals(Instruction.Type.L0MODIFICATION.name())) { return decodeL0(); + } else if (type.equals(Instruction.Type.L1MODIFICATION.name())) { + return decodeL1(); } else if (type.equals(Instruction.Type.L2MODIFICATION.name())) { return decodeL2(); } else if (type.equals(Instruction.Type.L3MODIFICATION.name())) { diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java index f7af736e..8fc6bbcf 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java @@ -17,8 +17,10 @@ package org.onosproject.codec.impl; import java.util.EnumMap; +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.criteria.Criterion; import org.onosproject.net.flow.criteria.EthCriterion; import org.onosproject.net.flow.criteria.EthTypeCriterion; @@ -370,12 +372,18 @@ public final class EncodeCriterionCodecHelper { private static class FormatOduSignalId implements CriterionTypeFormatter { @Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { - final OduSignalIdCriterion oduSignalIdCriterion = - (OduSignalIdCriterion) criterion; - return root.put(CriterionCodec.ODU_SIGNAL_ID, oduSignalIdCriterion.oduSignalId().toString()); + OduSignalId oduSignalId = ((OduSignalIdCriterion) criterion).oduSignalId(); + ObjectNode child = root.putObject(CriterionCodec.ODU_SIGNAL_ID); + + child.put(CriterionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber()); + child.put(CriterionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength()); + child.put(CriterionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap())); + + return root; } } + private static class FormatOduSignalType implements CriterionTypeFormatter { @Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { 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; diff --git a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java index f4d5008a..d7307ad3 100644 --- a/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java +++ b/framework/src/onos/core/common/src/main/java/org/onosproject/codec/impl/InstructionCodec.java @@ -50,6 +50,9 @@ public final class InstructionCodec extends JsonCodec<Instruction> { protected static final String TUNNEL_ID = "tunnelId"; protected static final String TCP_PORT = "tcpPort"; protected static final String UDP_PORT = "udpPort"; + protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber"; + protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLength"; + protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap"; protected static final String MISSING_MEMBER_MESSAGE = " member is required in Instruction"; |