Yafit Hadar
Committed by Gerrit Code Review

REST API related implemetations for ODU SIGID and SIGTYPE Fields in Flow Criteria and Instruction

Change-Id: I78ddc162409d377b8c55e7f8eedd9a91939ab277
...@@ -15,8 +15,14 @@ ...@@ -15,8 +15,14 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 -import com.google.common.base.MoreObjects; 18 +import java.util.Collections;
19 -import com.google.common.collect.ImmutableSet; 19 +import java.util.Comparator;
20 +import java.util.HashMap;
21 +import java.util.Map;
22 +import java.util.Objects;
23 +import java.util.Set;
24 +import java.util.TreeSet;
25 +
20 import org.onlab.packet.Ip6Address; 26 import org.onlab.packet.Ip6Address;
21 import org.onlab.packet.IpPrefix; 27 import org.onlab.packet.IpPrefix;
22 import org.onlab.packet.MacAddress; 28 import org.onlab.packet.MacAddress;
...@@ -27,13 +33,8 @@ import org.onosproject.net.PortNumber; ...@@ -27,13 +33,8 @@ import org.onosproject.net.PortNumber;
27 import org.onosproject.net.flow.criteria.Criteria; 33 import org.onosproject.net.flow.criteria.Criteria;
28 import org.onosproject.net.flow.criteria.Criterion; 34 import org.onosproject.net.flow.criteria.Criterion;
29 35
30 -import java.util.Collections; 36 +import com.google.common.base.MoreObjects;
31 -import java.util.Comparator; 37 +import com.google.common.collect.ImmutableSet;
32 -import java.util.HashMap;
33 -import java.util.Map;
34 -import java.util.Objects;
35 -import java.util.Set;
36 -import java.util.TreeSet;
37 38
38 /** 39 /**
39 * Default traffic selector implementation. 40 * Default traffic selector implementation.
......
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 -import com.google.common.base.MoreObjects; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import com.google.common.collect.ImmutableList; 19 +
20 -import com.google.common.collect.Lists; 20 +import java.util.List;
21 +import java.util.Objects;
22 +
21 import org.onlab.packet.EthType; 23 import org.onlab.packet.EthType;
22 import org.onlab.packet.IpAddress; 24 import org.onlab.packet.IpAddress;
23 import org.onlab.packet.MacAddress; 25 import org.onlab.packet.MacAddress;
...@@ -31,10 +33,9 @@ import org.onosproject.net.flow.instructions.Instruction; ...@@ -31,10 +33,9 @@ import org.onosproject.net.flow.instructions.Instruction;
31 import org.onosproject.net.flow.instructions.Instructions; 33 import org.onosproject.net.flow.instructions.Instructions;
32 import org.onosproject.net.meter.MeterId; 34 import org.onosproject.net.meter.MeterId;
33 35
34 -import java.util.List; 36 +import com.google.common.base.MoreObjects;
35 -import java.util.Objects; 37 +import com.google.common.collect.ImmutableList;
36 - 38 +import com.google.common.collect.Lists;
37 -import static com.google.common.base.Preconditions.checkNotNull;
38 39
39 /** 40 /**
40 * Default traffic treatment implementation. 41 * Default traffic treatment implementation.
...@@ -239,6 +240,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -239,6 +240,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
239 case GROUP: 240 case GROUP:
240 case QUEUE: 241 case QUEUE:
241 case L0MODIFICATION: 242 case L0MODIFICATION:
243 + case L1MODIFICATION:
242 case L2MODIFICATION: 244 case L2MODIFICATION:
243 case L3MODIFICATION: 245 case L3MODIFICATION:
244 case L4MODIFICATION: 246 case L4MODIFICATION:
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.flow; 16 package org.onosproject.net.flow;
17 17
18 +import java.util.List;
19 +
18 import org.onlab.packet.EthType; 20 import org.onlab.packet.EthType;
19 import org.onlab.packet.IpAddress; 21 import org.onlab.packet.IpAddress;
20 import org.onlab.packet.MacAddress; 22 import org.onlab.packet.MacAddress;
...@@ -27,8 +29,6 @@ import org.onosproject.net.flow.instructions.Instruction; ...@@ -27,8 +29,6 @@ import org.onosproject.net.flow.instructions.Instruction;
27 import org.onosproject.net.flow.instructions.Instructions; 29 import org.onosproject.net.flow.instructions.Instructions;
28 import org.onosproject.net.meter.MeterId; 30 import org.onosproject.net.meter.MeterId;
29 31
30 -import java.util.List;
31 -
32 /** 32 /**
33 * Abstraction of network traffic treatment. 33 * Abstraction of network traffic treatment.
34 */ 34 */
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 +import static org.onlab.util.Tools.nullIsIllegal;
19 +
18 import java.util.HashMap; 20 import java.util.HashMap;
19 import java.util.Map; 21 import java.util.Map;
20 22
...@@ -24,9 +26,13 @@ import org.onlab.packet.MacAddress; ...@@ -24,9 +26,13 @@ import org.onlab.packet.MacAddress;
24 import org.onlab.packet.MplsLabel; 26 import org.onlab.packet.MplsLabel;
25 import org.onlab.packet.TpPort; 27 import org.onlab.packet.TpPort;
26 import org.onlab.packet.VlanId; 28 import org.onlab.packet.VlanId;
29 +import org.onlab.util.HexString;
27 import org.onosproject.net.ChannelSpacing; 30 import org.onosproject.net.ChannelSpacing;
28 import org.onosproject.net.GridType; 31 import org.onosproject.net.GridType;
29 import org.onosproject.net.Lambda; 32 import org.onosproject.net.Lambda;
33 +import org.onosproject.net.OchSignalType;
34 +import org.onosproject.net.OduSignalId;
35 +import org.onosproject.net.OduSignalType;
30 import org.onosproject.net.PortNumber; 36 import org.onosproject.net.PortNumber;
31 import org.onosproject.net.flow.criteria.Criteria; 37 import org.onosproject.net.flow.criteria.Criteria;
32 import org.onosproject.net.flow.criteria.Criterion; 38 import org.onosproject.net.flow.criteria.Criterion;
...@@ -34,8 +40,6 @@ import org.onosproject.net.flow.criteria.Criterion; ...@@ -34,8 +40,6 @@ import org.onosproject.net.flow.criteria.Criterion;
34 import com.fasterxml.jackson.databind.JsonNode; 40 import com.fasterxml.jackson.databind.JsonNode;
35 import com.fasterxml.jackson.databind.node.ObjectNode; 41 import com.fasterxml.jackson.databind.node.ObjectNode;
36 42
37 -import static org.onlab.util.Tools.nullIsIllegal;
38 -
39 /** 43 /**
40 * Decode portion of the criterion codec. 44 * Decode portion of the criterion codec.
41 */ 45 */
...@@ -95,6 +99,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -95,6 +99,8 @@ public final class DecodeCriterionCodecHelper {
95 decoderMap.put(Criterion.Type.OCH_SIGID.name(), new OchSigIdDecoder()); 99 decoderMap.put(Criterion.Type.OCH_SIGID.name(), new OchSigIdDecoder());
96 decoderMap.put(Criterion.Type.OCH_SIGTYPE.name(), new OchSigTypeDecoder()); 100 decoderMap.put(Criterion.Type.OCH_SIGTYPE.name(), new OchSigTypeDecoder());
97 decoderMap.put(Criterion.Type.TUNNEL_ID.name(), new TunnelIdDecoder()); 101 decoderMap.put(Criterion.Type.TUNNEL_ID.name(), new TunnelIdDecoder());
102 + decoderMap.put(Criterion.Type.ODU_SIGID.name(), new OduSigIdDecoder());
103 + decoderMap.put(Criterion.Type.ODU_SIGTYPE.name(), new OduSigTypeDecoder());
98 } 104 }
99 105
100 private class EthTypeDecoder implements CriterionDecoder { 106 private class EthTypeDecoder implements CriterionDecoder {
...@@ -415,7 +421,9 @@ public final class DecodeCriterionCodecHelper { ...@@ -415,7 +421,9 @@ public final class DecodeCriterionCodecHelper {
415 private class OchSigTypeDecoder implements CriterionDecoder { 421 private class OchSigTypeDecoder implements CriterionDecoder {
416 @Override 422 @Override
417 public Criterion decodeCriterion(ObjectNode json) { 423 public Criterion decodeCriterion(ObjectNode json) {
418 - return null; 424 + OchSignalType ochSignalType = OchSignalType.valueOf(nullIsIllegal(json.get(CriterionCodec.OCH_SIGNAL_TYPE),
425 + CriterionCodec.OCH_SIGNAL_TYPE + MISSING_MEMBER_MESSAGE).asText());
426 + return Criteria.matchOchSignalType(ochSignalType);
419 } 427 }
420 } 428 }
421 429
...@@ -428,6 +436,34 @@ public final class DecodeCriterionCodecHelper { ...@@ -428,6 +436,34 @@ public final class DecodeCriterionCodecHelper {
428 } 436 }
429 } 437 }
430 438
439 + private class OduSigIdDecoder implements CriterionDecoder {
440 + @Override
441 + public Criterion decodeCriterion(ObjectNode json) {
442 + JsonNode oduSignalId = nullIsIllegal(json.get(CriterionCodec.ODU_SIGNAL_ID),
443 + CriterionCodec.TRIBUTARY_PORT_NUMBER + MISSING_MEMBER_MESSAGE);
444 +
445 + int tributaryPortNumber = nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_PORT_NUMBER),
446 + CriterionCodec.TRIBUTARY_PORT_NUMBER + MISSING_MEMBER_MESSAGE).asInt();
447 + int tributarySlotLen = nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_SLOT_LEN),
448 + CriterionCodec.TRIBUTARY_SLOT_LEN + MISSING_MEMBER_MESSAGE).asInt();
449 + byte[] tributarySlotBitmap = HexString.fromHexString(
450 + nullIsIllegal(oduSignalId.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP),
451 + CriterionCodec.TRIBUTARY_SLOT_BITMAP + MISSING_MEMBER_MESSAGE).asText());
452 +
453 + return Criteria.matchOduSignalId(
454 + OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap));
455 + }
456 + }
457 +
458 + private class OduSigTypeDecoder implements CriterionDecoder {
459 + @Override
460 + public Criterion decodeCriterion(ObjectNode json) {
461 + OduSignalType oduSignalType = OduSignalType.valueOf(nullIsIllegal(json.get(CriterionCodec.ODU_SIGNAL_TYPE),
462 + CriterionCodec.ODU_SIGNAL_TYPE + MISSING_MEMBER_MESSAGE).asText());
463 + return Criteria.matchOduSignalType(oduSignalType);
464 + }
465 + }
466 +
431 /** 467 /**
432 * Decodes the JSON into a criterion object. 468 * Decodes the JSON into a criterion object.
433 * 469 *
......
...@@ -15,26 +15,29 @@ ...@@ -15,26 +15,29 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 +import static org.onlab.util.Tools.nullIsIllegal;
19 +
18 import org.onlab.packet.IpAddress; 20 import org.onlab.packet.IpAddress;
19 import org.onlab.packet.MacAddress; 21 import org.onlab.packet.MacAddress;
20 import org.onlab.packet.MplsLabel; 22 import org.onlab.packet.MplsLabel;
21 import org.onlab.packet.TpPort; 23 import org.onlab.packet.TpPort;
22 import org.onlab.packet.VlanId; 24 import org.onlab.packet.VlanId;
25 +import org.onlab.util.HexString;
23 import org.onosproject.net.ChannelSpacing; 26 import org.onosproject.net.ChannelSpacing;
24 import org.onosproject.net.GridType; 27 import org.onosproject.net.GridType;
25 import org.onosproject.net.Lambda; 28 import org.onosproject.net.Lambda;
26 import org.onosproject.net.OchSignal; 29 import org.onosproject.net.OchSignal;
30 +import org.onosproject.net.OduSignalId;
27 import org.onosproject.net.PortNumber; 31 import org.onosproject.net.PortNumber;
28 -
29 -import com.fasterxml.jackson.databind.node.ObjectNode;
30 import org.onosproject.net.flow.instructions.Instruction; 32 import org.onosproject.net.flow.instructions.Instruction;
31 import org.onosproject.net.flow.instructions.Instructions; 33 import org.onosproject.net.flow.instructions.Instructions;
32 import org.onosproject.net.flow.instructions.L0ModificationInstruction; 34 import org.onosproject.net.flow.instructions.L0ModificationInstruction;
35 +import org.onosproject.net.flow.instructions.L1ModificationInstruction;
33 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 36 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
34 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 37 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
35 import org.onosproject.net.flow.instructions.L4ModificationInstruction; 38 import org.onosproject.net.flow.instructions.L4ModificationInstruction;
36 39
37 -import static org.onlab.util.Tools.nullIsIllegal; 40 +import com.fasterxml.jackson.databind.node.ObjectNode;
38 41
39 /** 42 /**
40 * Decoding portion of the instruction codec. 43 * Decoding portion of the instruction codec.
...@@ -174,6 +177,30 @@ public final class DecodeInstructionCodecHelper { ...@@ -174,6 +177,30 @@ public final class DecodeInstructionCodecHelper {
174 } 177 }
175 178
176 /** 179 /**
180 + * Decodes a Layer 1 instruction.
181 + *
182 + * @return instruction object decoded from the JSON
183 + * @throws IllegalArgumentException if the JSON is invalid
184 + */
185 + private Instruction decodeL1() {
186 + String subType = json.get(InstructionCodec.SUBTYPE).asText();
187 + if (subType.equals(L1ModificationInstruction.L1SubType.ODU_SIGID.name())) {
188 + int tributaryPortNumber = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_PORT_NUMBER),
189 + InstructionCodec.TRIBUTARY_PORT_NUMBER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
190 + int tributarySlotLen = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_LEN),
191 + InstructionCodec.TRIBUTARY_SLOT_LEN + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
192 + byte[] tributarySlotBitmap = null;
193 + tributarySlotBitmap = HexString.fromHexString(
194 + nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_BITMAP),
195 + InstructionCodec.TRIBUTARY_SLOT_BITMAP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
196 + return Instructions.modL1OduSignalId(OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen,
197 + tributarySlotBitmap));
198 + }
199 + throw new IllegalArgumentException("L1 Instruction subtype "
200 + + subType + " is not supported");
201 + }
202 +
203 + /**
177 * Decodes a Layer 4 instruction. 204 * Decodes a Layer 4 instruction.
178 * 205 *
179 * @return instruction object decoded from the JSON 206 * @return instruction object decoded from the JSON
...@@ -221,6 +248,8 @@ public final class DecodeInstructionCodecHelper { ...@@ -221,6 +248,8 @@ public final class DecodeInstructionCodecHelper {
221 return Instructions.createDrop(); 248 return Instructions.createDrop();
222 } else if (type.equals(Instruction.Type.L0MODIFICATION.name())) { 249 } else if (type.equals(Instruction.Type.L0MODIFICATION.name())) {
223 return decodeL0(); 250 return decodeL0();
251 + } else if (type.equals(Instruction.Type.L1MODIFICATION.name())) {
252 + return decodeL1();
224 } else if (type.equals(Instruction.Type.L2MODIFICATION.name())) { 253 } else if (type.equals(Instruction.Type.L2MODIFICATION.name())) {
225 return decodeL2(); 254 return decodeL2();
226 } else if (type.equals(Instruction.Type.L3MODIFICATION.name())) { 255 } else if (type.equals(Instruction.Type.L3MODIFICATION.name())) {
......
...@@ -17,8 +17,10 @@ package org.onosproject.codec.impl; ...@@ -17,8 +17,10 @@ package org.onosproject.codec.impl;
17 17
18 import java.util.EnumMap; 18 import java.util.EnumMap;
19 19
20 +import org.onlab.util.HexString;
20 import org.onosproject.codec.CodecContext; 21 import org.onosproject.codec.CodecContext;
21 import org.onosproject.net.OchSignal; 22 import org.onosproject.net.OchSignal;
23 +import org.onosproject.net.OduSignalId;
22 import org.onosproject.net.flow.criteria.Criterion; 24 import org.onosproject.net.flow.criteria.Criterion;
23 import org.onosproject.net.flow.criteria.EthCriterion; 25 import org.onosproject.net.flow.criteria.EthCriterion;
24 import org.onosproject.net.flow.criteria.EthTypeCriterion; 26 import org.onosproject.net.flow.criteria.EthTypeCriterion;
...@@ -370,12 +372,18 @@ public final class EncodeCriterionCodecHelper { ...@@ -370,12 +372,18 @@ public final class EncodeCriterionCodecHelper {
370 private static class FormatOduSignalId implements CriterionTypeFormatter { 372 private static class FormatOduSignalId implements CriterionTypeFormatter {
371 @Override 373 @Override
372 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { 374 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
373 - final OduSignalIdCriterion oduSignalIdCriterion = 375 + OduSignalId oduSignalId = ((OduSignalIdCriterion) criterion).oduSignalId();
374 - (OduSignalIdCriterion) criterion; 376 + ObjectNode child = root.putObject(CriterionCodec.ODU_SIGNAL_ID);
375 - return root.put(CriterionCodec.ODU_SIGNAL_ID, oduSignalIdCriterion.oduSignalId().toString()); 377 +
378 + child.put(CriterionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
379 + child.put(CriterionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
380 + child.put(CriterionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap()));
381 +
382 + return root;
376 } 383 }
377 } 384 }
378 385
386 +
379 private static class FormatOduSignalType implements CriterionTypeFormatter { 387 private static class FormatOduSignalType implements CriterionTypeFormatter {
380 @Override 388 @Override
381 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { 389 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
......
...@@ -15,11 +15,14 @@ ...@@ -15,11 +15,14 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 +import org.onlab.util.HexString;
18 import org.onosproject.codec.CodecContext; 19 import org.onosproject.codec.CodecContext;
19 import org.onosproject.net.OchSignal; 20 import org.onosproject.net.OchSignal;
21 +import org.onosproject.net.OduSignalId;
20 import org.onosproject.net.flow.instructions.Instruction; 22 import org.onosproject.net.flow.instructions.Instruction;
21 import org.onosproject.net.flow.instructions.Instructions; 23 import org.onosproject.net.flow.instructions.Instructions;
22 import org.onosproject.net.flow.instructions.L0ModificationInstruction; 24 import org.onosproject.net.flow.instructions.L0ModificationInstruction;
25 +import org.onosproject.net.flow.instructions.L1ModificationInstruction;
23 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 26 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
24 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 27 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
25 import org.onosproject.net.flow.instructions.L4ModificationInstruction; 28 import org.onosproject.net.flow.instructions.L4ModificationInstruction;
...@@ -81,6 +84,36 @@ public final class EncodeInstructionCodecHelper { ...@@ -81,6 +84,36 @@ public final class EncodeInstructionCodecHelper {
81 } 84 }
82 85
83 /** 86 /**
87 + * Encode an L1 modification instruction.
88 + *
89 + * @param result json node that the instruction attributes are added to
90 + * @param instruction The L1 instruction
91 + * @param context context of the request
92 + */
93 + private void encodeL1(ObjectNode result) {
94 + L1ModificationInstruction instruction =
95 + (L1ModificationInstruction) this.instruction;
96 + result.put(InstructionCodec.SUBTYPE, instruction.subtype().name());
97 +
98 + switch (instruction.subtype()) {
99 + case ODU_SIGID:
100 + final L1ModificationInstruction.ModOduSignalIdInstruction oduSignalIdInstruction =
101 + (L1ModificationInstruction.ModOduSignalIdInstruction) instruction;
102 + OduSignalId oduSignalId = oduSignalIdInstruction.oduSignalId();
103 +
104 + ObjectNode child = result.putObject("oduSignalId");
105 +
106 + child.put(InstructionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
107 + child.put(InstructionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
108 + child.put(InstructionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap()));
109 + break;
110 + default:
111 + log.info("Cannot convert L1 subtype of {}", instruction.subtype());
112 + break;
113 + }
114 + }
115 +
116 + /**
84 * Encode an L2 modification instruction. 117 * Encode an L2 modification instruction.
85 * 118 *
86 * @param result json node that the instruction attributes are added to 119 * @param result json node that the instruction attributes are added to
...@@ -222,6 +255,10 @@ public final class EncodeInstructionCodecHelper { ...@@ -222,6 +255,10 @@ public final class EncodeInstructionCodecHelper {
222 encodeL0(result); 255 encodeL0(result);
223 break; 256 break;
224 257
258 + case L1MODIFICATION:
259 + encodeL1(result);
260 + break;
261 +
225 case L2MODIFICATION: 262 case L2MODIFICATION:
226 encodeL2(result); 263 encodeL2(result);
227 break; 264 break;
......
...@@ -50,6 +50,9 @@ public final class InstructionCodec extends JsonCodec<Instruction> { ...@@ -50,6 +50,9 @@ public final class InstructionCodec extends JsonCodec<Instruction> {
50 protected static final String TUNNEL_ID = "tunnelId"; 50 protected static final String TUNNEL_ID = "tunnelId";
51 protected static final String TCP_PORT = "tcpPort"; 51 protected static final String TCP_PORT = "tcpPort";
52 protected static final String UDP_PORT = "udpPort"; 52 protected static final String UDP_PORT = "udpPort";
53 + protected static final String TRIBUTARY_PORT_NUMBER = "tributaryPortNumber";
54 + protected static final String TRIBUTARY_SLOT_LEN = "tributarySlotLength";
55 + protected static final String TRIBUTARY_SLOT_BITMAP = "tributarySlotBitmap";
53 56
54 protected static final String MISSING_MEMBER_MESSAGE = 57 protected static final String MISSING_MEMBER_MESSAGE =
55 " member is required in Instruction"; 58 " member is required in Instruction";
......
...@@ -31,6 +31,8 @@ import org.onosproject.net.ChannelSpacing; ...@@ -31,6 +31,8 @@ import org.onosproject.net.ChannelSpacing;
31 import org.onosproject.net.GridType; 31 import org.onosproject.net.GridType;
32 import org.onosproject.net.Lambda; 32 import org.onosproject.net.Lambda;
33 import org.onosproject.net.OchSignalType; 33 import org.onosproject.net.OchSignalType;
34 +import org.onosproject.net.OduSignalId;
35 +import org.onosproject.net.OduSignalType;
34 import org.onosproject.net.PortNumber; 36 import org.onosproject.net.PortNumber;
35 import org.onosproject.net.flow.criteria.Criteria; 37 import org.onosproject.net.flow.criteria.Criteria;
36 import org.onosproject.net.flow.criteria.Criterion; 38 import org.onosproject.net.flow.criteria.Criterion;
...@@ -54,6 +56,10 @@ public class CriterionCodecTest { ...@@ -54,6 +56,10 @@ public class CriterionCodecTest {
54 final IpPrefix ipPrefix6 = IpPrefix.valueOf("fe80::/64"); 56 final IpPrefix ipPrefix6 = IpPrefix.valueOf("fe80::/64");
55 final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01"); 57 final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
56 final TpPort tpPort = TpPort.tpPort(40000); 58 final TpPort tpPort = TpPort.tpPort(40000);
59 + final int tributaryPortNumber = 11;
60 + final int tributarySlotLen = 80;
61 + final byte[] tributarySlotBitmap = new byte[] {1, 2, 3, 4, 2, 3, 4, 2, 3, 4};
62 +
57 63
58 /** 64 /**
59 * Sets up for each test. Creates a context and fetches the criterion 65 * Sets up for each test. Creates a context and fetches the criterion
...@@ -427,4 +433,31 @@ public class CriterionCodecTest { ...@@ -427,4 +433,31 @@ public class CriterionCodecTest {
427 ObjectNode result = criterionCodec.encode(criterion, context); 433 ObjectNode result = criterionCodec.encode(criterion, context);
428 assertThat(result, matchesCriterion(criterion)); 434 assertThat(result, matchesCriterion(criterion));
429 } 435 }
436 +
437 + /**
438 + * Tests Odu Signal ID criterion.
439 + */
440 + @Test
441 + public void matchOduSignalIdTest() {
442 +
443 + OduSignalId oduSignalId = OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap);
444 +
445 + Criterion criterion = Criteria.matchOduSignalId(oduSignalId);
446 + ObjectNode result = criterionCodec.encode(criterion, context);
447 + assertThat(result, matchesCriterion(criterion));
448 + }
449 +
450 + /**
451 + * Tests Odu Signal Type criterion.
452 + */
453 + @Test
454 + public void matchOduSignalTypeTest() {
455 +
456 + OduSignalType signalType = OduSignalType.ODU2;
457 +
458 + Criterion criterion = Criteria.matchOduSignalType(signalType);
459 + ObjectNode result = criterionCodec.encode(criterion, context);
460 + assertThat(result, matchesCriterion(criterion));
461 + }
462 +
430 } 463 }
......
...@@ -15,13 +15,14 @@ ...@@ -15,13 +15,14 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 -import com.google.common.base.Joiner; 18 +import java.util.Objects;
19 +
19 import org.hamcrest.Description; 20 import org.hamcrest.Description;
20 import org.hamcrest.TypeSafeDiagnosingMatcher; 21 import org.hamcrest.TypeSafeDiagnosingMatcher;
22 +import org.onlab.util.HexString;
21 import org.onosproject.net.OchSignal; 23 import org.onosproject.net.OchSignal;
24 +import org.onosproject.net.OduSignalId;
22 import org.onosproject.net.flow.criteria.Criterion; 25 import org.onosproject.net.flow.criteria.Criterion;
23 -
24 -import com.fasterxml.jackson.databind.JsonNode;
25 import org.onosproject.net.flow.criteria.EthCriterion; 26 import org.onosproject.net.flow.criteria.EthCriterion;
26 import org.onosproject.net.flow.criteria.EthTypeCriterion; 27 import org.onosproject.net.flow.criteria.EthTypeCriterion;
27 import org.onosproject.net.flow.criteria.IPCriterion; 28 import org.onosproject.net.flow.criteria.IPCriterion;
...@@ -40,6 +41,8 @@ import org.onosproject.net.flow.criteria.MetadataCriterion; ...@@ -40,6 +41,8 @@ import org.onosproject.net.flow.criteria.MetadataCriterion;
40 import org.onosproject.net.flow.criteria.MplsCriterion; 41 import org.onosproject.net.flow.criteria.MplsCriterion;
41 import org.onosproject.net.flow.criteria.OchSignalCriterion; 42 import org.onosproject.net.flow.criteria.OchSignalCriterion;
42 import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; 43 import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
44 +import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
45 +import org.onosproject.net.flow.criteria.OduSignalTypeCriterion;
43 import org.onosproject.net.flow.criteria.PortCriterion; 46 import org.onosproject.net.flow.criteria.PortCriterion;
44 import org.onosproject.net.flow.criteria.SctpPortCriterion; 47 import org.onosproject.net.flow.criteria.SctpPortCriterion;
45 import org.onosproject.net.flow.criteria.TcpPortCriterion; 48 import org.onosproject.net.flow.criteria.TcpPortCriterion;
...@@ -47,7 +50,8 @@ import org.onosproject.net.flow.criteria.UdpPortCriterion; ...@@ -47,7 +50,8 @@ import org.onosproject.net.flow.criteria.UdpPortCriterion;
47 import org.onosproject.net.flow.criteria.VlanIdCriterion; 50 import org.onosproject.net.flow.criteria.VlanIdCriterion;
48 import org.onosproject.net.flow.criteria.VlanPcpCriterion; 51 import org.onosproject.net.flow.criteria.VlanPcpCriterion;
49 52
50 -import java.util.Objects; 53 +import com.fasterxml.jackson.databind.JsonNode;
54 +import com.google.common.base.Joiner;
51 55
52 /** 56 /**
53 * Hamcrest matcher for criterion objects. 57 * Hamcrest matcher for criterion objects.
...@@ -496,6 +500,44 @@ public final class CriterionJsonMatcher extends ...@@ -496,6 +500,44 @@ public final class CriterionJsonMatcher extends
496 return true; 500 return true;
497 } 501 }
498 502
503 + /**
504 + * Matches an ODU signal ID criterion object.
505 + *
506 + * @param criterion criterion to match
507 + * @return true if the JSON matches the criterion, false otherwise.
508 + */
509 + private boolean matchCriterion(OduSignalIdCriterion criterion) {
510 + final OduSignalId oduSignal = criterion.oduSignalId();
511 + final JsonNode jsonOduSignal = jsonCriterion.get(CriterionCodec.ODU_SIGNAL_ID);
512 + int jsonTpn = jsonOduSignal.get(CriterionCodec.TRIBUTARY_PORT_NUMBER).intValue();
513 + int jsonTsLen = jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_LEN).intValue();
514 + byte[] jsonTributaryBitMap = HexString.fromHexString(
515 + jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP).asText());
516 + OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, jsonTributaryBitMap);
517 + if (!oduSignal.equals(jsonOduSignalId)) {
518 + description.appendText("oduSignalId was " + criterion);
519 + return false;
520 + }
521 + return true;
522 + }
523 +
524 + /**
525 + * Matches an ODU signal Type criterion object.
526 + *
527 + * @param criterion criterion to match
528 + * @return true if the JSON matches the criterion, false otherwise.
529 + */
530 + private boolean matchCriterion(OduSignalTypeCriterion criterion) {
531 + final String signalType = criterion.signalType().name();
532 + final String jsonOduSignalType = jsonCriterion.get("oduSignalType").textValue();
533 + if (!signalType.equals(jsonOduSignalType)) {
534 + description.appendText("signalType was " + signalType);
535 + return false;
536 + }
537 + return true;
538 + }
539 +
540 +
499 @Override 541 @Override
500 public boolean matchesSafely(JsonNode jsonCriterion, 542 public boolean matchesSafely(JsonNode jsonCriterion,
501 Description description) { 543 Description description) {
...@@ -594,6 +636,12 @@ public final class CriterionJsonMatcher extends ...@@ -594,6 +636,12 @@ public final class CriterionJsonMatcher extends
594 case OCH_SIGTYPE: 636 case OCH_SIGTYPE:
595 return matchCriterion((OchSignalTypeCriterion) criterion); 637 return matchCriterion((OchSignalTypeCriterion) criterion);
596 638
639 + case ODU_SIGID:
640 + return matchCriterion((OduSignalIdCriterion) criterion);
641 +
642 + case ODU_SIGTYPE:
643 + return matchCriterion((OduSignalTypeCriterion) criterion);
644 +
597 default: 645 default:
598 // Don't know how to format this type 646 // Don't know how to format this type
599 description.appendText("unknown criterion type " + 647 description.appendText("unknown criterion type " +
......
...@@ -15,6 +15,15 @@ ...@@ -15,6 +15,15 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 +import static org.easymock.EasyMock.createMock;
19 +import static org.easymock.EasyMock.expect;
20 +import static org.easymock.EasyMock.replay;
21 +import static org.hamcrest.MatcherAssert.assertThat;
22 +import static org.hamcrest.Matchers.instanceOf;
23 +import static org.hamcrest.Matchers.is;
24 +import static org.hamcrest.Matchers.notNullValue;
25 +import static org.onosproject.net.NetTestTools.APP_ID;
26 +
18 import java.io.IOException; 27 import java.io.IOException;
19 import java.io.InputStream; 28 import java.io.InputStream;
20 import java.util.SortedMap; 29 import java.util.SortedMap;
...@@ -35,6 +44,8 @@ import org.onosproject.net.ChannelSpacing; ...@@ -35,6 +44,8 @@ import org.onosproject.net.ChannelSpacing;
35 import org.onosproject.net.GridType; 44 import org.onosproject.net.GridType;
36 import org.onosproject.net.Lambda; 45 import org.onosproject.net.Lambda;
37 import org.onosproject.net.OchSignal; 46 import org.onosproject.net.OchSignal;
47 +import org.onosproject.net.OchSignalType;
48 +import org.onosproject.net.OduSignalType;
38 import org.onosproject.net.PortNumber; 49 import org.onosproject.net.PortNumber;
39 import org.onosproject.net.flow.FlowRule; 50 import org.onosproject.net.flow.FlowRule;
40 import org.onosproject.net.flow.criteria.Criterion; 51 import org.onosproject.net.flow.criteria.Criterion;
...@@ -55,6 +66,9 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion; ...@@ -55,6 +66,9 @@ import org.onosproject.net.flow.criteria.Icmpv6TypeCriterion;
55 import org.onosproject.net.flow.criteria.IndexedLambdaCriterion; 66 import org.onosproject.net.flow.criteria.IndexedLambdaCriterion;
56 import org.onosproject.net.flow.criteria.MplsCriterion; 67 import org.onosproject.net.flow.criteria.MplsCriterion;
57 import org.onosproject.net.flow.criteria.OchSignalCriterion; 68 import org.onosproject.net.flow.criteria.OchSignalCriterion;
69 +import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
70 +import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
71 +import org.onosproject.net.flow.criteria.OduSignalTypeCriterion;
58 import org.onosproject.net.flow.criteria.PortCriterion; 72 import org.onosproject.net.flow.criteria.PortCriterion;
59 import org.onosproject.net.flow.criteria.SctpPortCriterion; 73 import org.onosproject.net.flow.criteria.SctpPortCriterion;
60 import org.onosproject.net.flow.criteria.TcpPortCriterion; 74 import org.onosproject.net.flow.criteria.TcpPortCriterion;
...@@ -62,9 +76,6 @@ import org.onosproject.net.flow.criteria.TunnelIdCriterion; ...@@ -62,9 +76,6 @@ import org.onosproject.net.flow.criteria.TunnelIdCriterion;
62 import org.onosproject.net.flow.criteria.UdpPortCriterion; 76 import org.onosproject.net.flow.criteria.UdpPortCriterion;
63 import org.onosproject.net.flow.criteria.VlanIdCriterion; 77 import org.onosproject.net.flow.criteria.VlanIdCriterion;
64 import org.onosproject.net.flow.criteria.VlanPcpCriterion; 78 import org.onosproject.net.flow.criteria.VlanPcpCriterion;
65 -
66 -import com.fasterxml.jackson.databind.JsonNode;
67 -import com.fasterxml.jackson.databind.node.ObjectNode;
68 import org.onosproject.net.flow.instructions.Instruction; 79 import org.onosproject.net.flow.instructions.Instruction;
69 import org.onosproject.net.flow.instructions.Instructions; 80 import org.onosproject.net.flow.instructions.Instructions;
70 import org.onosproject.net.flow.instructions.L0ModificationInstruction; 81 import org.onosproject.net.flow.instructions.L0ModificationInstruction;
...@@ -72,14 +83,8 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction; ...@@ -72,14 +83,8 @@ import org.onosproject.net.flow.instructions.L2ModificationInstruction;
72 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 83 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
73 import org.onosproject.net.flow.instructions.L4ModificationInstruction; 84 import org.onosproject.net.flow.instructions.L4ModificationInstruction;
74 85
75 -import static org.easymock.EasyMock.createMock; 86 +import com.fasterxml.jackson.databind.JsonNode;
76 -import static org.easymock.EasyMock.expect; 87 +import com.fasterxml.jackson.databind.node.ObjectNode;
77 -import static org.easymock.EasyMock.replay;
78 -import static org.hamcrest.MatcherAssert.assertThat;
79 -import static org.hamcrest.Matchers.instanceOf;
80 -import static org.hamcrest.Matchers.is;
81 -import static org.hamcrest.Matchers.notNullValue;
82 -import static org.onosproject.net.NetTestTools.APP_ID;
83 88
84 /** 89 /**
85 * Flow rule codec unit tests. 90 * Flow rule codec unit tests.
...@@ -382,7 +387,7 @@ public class FlowRuleCodecTest { ...@@ -382,7 +387,7 @@ public class FlowRuleCodecTest {
382 387
383 checkCommonData(rule); 388 checkCommonData(rule);
384 389
385 - assertThat(rule.selector().criteria().size(), is(33)); 390 + assertThat(rule.selector().criteria().size(), is(36));
386 391
387 rule.selector().criteria() 392 rule.selector().criteria()
388 .stream() 393 .stream()
...@@ -518,6 +523,25 @@ public class FlowRuleCodecTest { ...@@ -518,6 +523,25 @@ public class FlowRuleCodecTest {
518 criterion = getCriterion(Criterion.Type.TUNNEL_ID); 523 criterion = getCriterion(Criterion.Type.TUNNEL_ID);
519 assertThat(((TunnelIdCriterion) criterion).tunnelId(), 524 assertThat(((TunnelIdCriterion) criterion).tunnelId(),
520 is(100L)); 525 is(100L));
526 +
527 + criterion = getCriterion(Criterion.Type.OCH_SIGTYPE);
528 + assertThat(((OchSignalTypeCriterion) criterion).signalType(),
529 + is(OchSignalType.FIXED_GRID));
530 +
531 + criterion = getCriterion(Criterion.Type.ODU_SIGTYPE);
532 + assertThat(((OduSignalTypeCriterion) criterion).signalType(),
533 + is(OduSignalType.ODU4));
534 +
535 +
536 + criterion = getCriterion(Criterion.Type.ODU_SIGID);
537 + assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributaryPortNumber(),
538 + is(1));
539 +
540 + assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributarySlotLength(),
541 + is(80));
542 +
543 + assertThat(((OduSignalIdCriterion) criterion).oduSignalId().tributarySlotBitmap(),
544 + is(new byte [] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}));
521 } 545 }
522 546
523 /** 547 /**
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
15 */ 15 */
16 package org.onosproject.codec.impl; 16 package org.onosproject.codec.impl;
17 17
18 +import static org.hamcrest.MatcherAssert.assertThat;
19 +import static org.hamcrest.Matchers.notNullValue;
20 +import static org.onosproject.codec.impl.InstructionJsonMatcher.matchesInstruction;
21 +
18 import org.junit.Before; 22 import org.junit.Before;
19 import org.junit.Test; 23 import org.junit.Test;
20 import org.onlab.packet.Ip4Address; 24 import org.onlab.packet.Ip4Address;
...@@ -28,26 +32,23 @@ import org.onosproject.net.ChannelSpacing; ...@@ -28,26 +32,23 @@ import org.onosproject.net.ChannelSpacing;
28 import org.onosproject.net.GridType; 32 import org.onosproject.net.GridType;
29 import org.onosproject.net.IndexedLambda; 33 import org.onosproject.net.IndexedLambda;
30 import org.onosproject.net.Lambda; 34 import org.onosproject.net.Lambda;
35 +import org.onosproject.net.OduSignalId;
31 import org.onosproject.net.PortNumber; 36 import org.onosproject.net.PortNumber;
32 import org.onosproject.net.flow.instructions.Instruction; 37 import org.onosproject.net.flow.instructions.Instruction;
33 import org.onosproject.net.flow.instructions.Instructions; 38 import org.onosproject.net.flow.instructions.Instructions;
34 import org.onosproject.net.flow.instructions.L0ModificationInstruction; 39 import org.onosproject.net.flow.instructions.L0ModificationInstruction;
40 +import org.onosproject.net.flow.instructions.L1ModificationInstruction;
35 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 41 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
36 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 42 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
37 43
38 import com.fasterxml.jackson.databind.node.ObjectNode; 44 import com.fasterxml.jackson.databind.node.ObjectNode;
39 45
40 -import static org.hamcrest.MatcherAssert.assertThat;
41 -import static org.hamcrest.Matchers.notNullValue;
42 -import static org.onosproject.codec.impl.InstructionJsonMatcher.matchesInstruction;
43 -
44 /** 46 /**
45 * Unit tests for Instruction codec. 47 * Unit tests for Instruction codec.
46 */ 48 */
47 public class InstructionCodecTest { 49 public class InstructionCodecTest {
48 CodecContext context; 50 CodecContext context;
49 JsonCodec<Instruction> instructionCodec; 51 JsonCodec<Instruction> instructionCodec;
50 -
51 /** 52 /**
52 * Sets up for each test. Creates a context and fetches the instruction 53 * Sets up for each test. Creates a context and fetches the instruction
53 * codec. 54 * codec.
...@@ -122,6 +123,20 @@ public class InstructionCodecTest { ...@@ -122,6 +123,20 @@ public class InstructionCodecTest {
122 } 123 }
123 124
124 /** 125 /**
126 + * Tests the encoding of mod ODU signal ID instructions.
127 + */
128 + @Test
129 + public void modOduSignalIdInstructionTest() {
130 + OduSignalId oduSignalId = OduSignalId.oduSignalId(1, 8, new byte [] {8, 0, 0, 0, 0, 0, 0, 0, 0, 0});
131 + L1ModificationInstruction.ModOduSignalIdInstruction instruction =
132 + (L1ModificationInstruction.ModOduSignalIdInstruction)
133 + Instructions.modL1OduSignalId(oduSignalId);
134 + ObjectNode instructionJson =
135 + instructionCodec.encode(instruction, context);
136 + assertThat(instructionJson, matchesInstruction(instruction));
137 + }
138 +
139 + /**
125 * Tests the encoding of mod ether instructions. 140 * Tests the encoding of mod ether instructions.
126 */ 141 */
127 @Test 142 @Test
......
...@@ -17,15 +17,25 @@ package org.onosproject.codec.impl; ...@@ -17,15 +17,25 @@ package org.onosproject.codec.impl;
17 17
18 import org.hamcrest.Description; 18 import org.hamcrest.Description;
19 import org.hamcrest.TypeSafeDiagnosingMatcher; 19 import org.hamcrest.TypeSafeDiagnosingMatcher;
20 +import org.onlab.util.HexString;
21 +import org.onosproject.net.OduSignalId;
20 import org.onosproject.net.flow.instructions.Instruction; 22 import org.onosproject.net.flow.instructions.Instruction;
23 +import org.onosproject.net.flow.instructions.Instructions.DropInstruction;
24 +import org.onosproject.net.flow.instructions.Instructions.NoActionInstruction;
25 +import org.onosproject.net.flow.instructions.Instructions.OutputInstruction;
26 +import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
27 +import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
28 +import org.onosproject.net.flow.instructions.L1ModificationInstruction.ModOduSignalIdInstruction;
29 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
30 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModMplsLabelInstruction;
31 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction;
32 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction;
33 +import org.onosproject.net.flow.instructions.L2ModificationInstruction.PushHeaderInstructions;
34 +import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
35 +import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
21 36
22 import com.fasterxml.jackson.databind.JsonNode; 37 import com.fasterxml.jackson.databind.JsonNode;
23 38
24 -import static org.onosproject.net.flow.instructions.Instructions.*;
25 -import static org.onosproject.net.flow.instructions.L0ModificationInstruction.*;
26 -import static org.onosproject.net.flow.instructions.L2ModificationInstruction.*;
27 -import static org.onosproject.net.flow.instructions.L3ModificationInstruction.*;
28 -
29 /** 39 /**
30 * Hamcrest matcher for instructions. 40 * Hamcrest matcher for instructions.
31 */ 41 */
...@@ -133,7 +143,7 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -133,7 +143,7 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
133 } 143 }
134 144
135 /** 145 /**
136 - * Matches teh contents of a mod OCh singal instruction. 146 + * Matches the contents of a mod OCh singal instruction.
137 * 147 *
138 * @param instructionJson JSON instruction to match 148 * @param instructionJson JSON instruction to match
139 * @param description Description object used for recording errors 149 * @param description Description object used for recording errors
...@@ -184,6 +194,40 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -184,6 +194,40 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
184 } 194 }
185 195
186 /** 196 /**
197 + * Matches the contents of a mod ODU singal Id instruction.
198 + *
199 + * @param instructionJson JSON instruction to match
200 + * @param description Description object used for recording errors
201 + * @return true if contents matches, false otherwise
202 + */
203 + private boolean matchModOduSingalIdInstruction(JsonNode instructionJson,
204 + Description description) {
205 + ModOduSignalIdInstruction instructionToMatch =
206 + (ModOduSignalIdInstruction) instruction;
207 + String jsonSubType = instructionJson.get("subtype").textValue();
208 + if (!instructionToMatch.subtype().name().equals(jsonSubType)) {
209 + description.appendText("subtype was " + jsonSubType);
210 + return false;
211 + }
212 + String jsonType = instructionJson.get("type").textValue();
213 + if (!instructionToMatch.type().name().equals(jsonType)) {
214 + description.appendText("type was " + jsonType);
215 + return false;
216 + }
217 + final JsonNode jsonOduSignal = instructionJson.get("oduSignalId");
218 + int jsonTpn = jsonOduSignal.get("tributaryPortNumber").intValue();
219 + int jsonTsLen = jsonOduSignal.get("tributarySlotLength").intValue();
220 + byte [] tributaryBitMap = HexString.fromHexString(jsonOduSignal.get("tributarySlotBitmap").asText());
221 + OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, tributaryBitMap);
222 + if (!instructionToMatch.oduSignalId().equals(jsonOduSignalId)) {
223 + description.appendText("oduSignalId was " + instructionToMatch);
224 + return false;
225 + }
226 + return true;
227 + }
228 +
229 +
230 + /**
187 * Matches the contents of a mod Ethernet instruction. 231 * Matches the contents of a mod Ethernet instruction.
188 * 232 *
189 * @param instructionJson JSON instruction to match 233 * @param instructionJson JSON instruction to match
...@@ -416,6 +460,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json ...@@ -416,6 +460,8 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
416 description); 460 description);
417 } else if (instruction instanceof ModMplsLabelInstruction) { 461 } else if (instruction instanceof ModMplsLabelInstruction) {
418 return matchModMplsLabelInstruction(jsonInstruction, description); 462 return matchModMplsLabelInstruction(jsonInstruction, description);
463 + } else if (instruction instanceof ModOduSignalIdInstruction) {
464 + return matchModOduSingalIdInstruction(jsonInstruction, description);
419 } else if (instruction instanceof NoActionInstruction) { 465 } else if (instruction instanceof NoActionInstruction) {
420 return true; 466 return true;
421 } 467 }
......
...@@ -38,7 +38,10 @@ ...@@ -38,7 +38,10 @@
38 {"type":"MPLS_LABEL", "label":123}, 38 {"type":"MPLS_LABEL", "label":123},
39 {"type":"IPV6_EXTHDR", "exthdrFlags":99}, 39 {"type":"IPV6_EXTHDR", "exthdrFlags":99},
40 {"type":"OCH_SIGID", "lambda":122}, 40 {"type":"OCH_SIGID", "lambda":122},
41 - {"type":"TUNNEL_ID", "tunnelId":100} 41 + {"type":"TUNNEL_ID", "tunnelId":100},
42 + {"type":"OCH_SIGTYPE", "ochSignalType":"FIXED_GRID"},
43 + {"type":"ODU_SIGTYPE", "oduSignalType":"ODU4"},
44 + {"type":"ODU_SIGID", "oduSignalId" : {"tributaryPortNumber":1, "tributarySlotLen":80, "tributarySlotBitmap":"01:01:01:01:01:01:01:01:01:01"}}
42 ] 45 ]
43 } 46 }
44 } 47 }
......
...@@ -29,9 +29,11 @@ import org.onosproject.net.flow.criteria.VlanPcpCriterion; ...@@ -29,9 +29,11 @@ import org.onosproject.net.flow.criteria.VlanPcpCriterion;
29 import org.onosproject.net.flow.criteria.MplsCriterion; 29 import org.onosproject.net.flow.criteria.MplsCriterion;
30 import org.onosproject.net.flow.criteria.IPCriterion; 30 import org.onosproject.net.flow.criteria.IPCriterion;
31 import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion; 31 import org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion;
32 +import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
32 import org.onosproject.net.flow.criteria.Criteria; 33 import org.onosproject.net.flow.criteria.Criteria;
33 import org.onosproject.net.flow.instructions.Instruction; 34 import org.onosproject.net.flow.instructions.Instruction;
34 import org.onosproject.net.flow.instructions.L0ModificationInstruction; 35 import org.onosproject.net.flow.instructions.L0ModificationInstruction;
36 +import org.onosproject.net.flow.instructions.L1ModificationInstruction;
35 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 37 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
36 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 38 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
37 import org.onosproject.net.flowobjective.DefaultForwardingObjective; 39 import org.onosproject.net.flowobjective.DefaultForwardingObjective;
...@@ -155,6 +157,7 @@ public final class FlowObjectiveCompositionUtil { ...@@ -155,6 +157,7 @@ public final class FlowObjectiveCompositionUtil {
155 return treatmentBuilder.build(); 157 return treatmentBuilder.build();
156 } 158 }
157 159
160 + //CHECKSTYLE:OFF
158 public static TrafficSelector revertTreatmentSelector(TrafficTreatment trafficTreatment, 161 public static TrafficSelector revertTreatmentSelector(TrafficTreatment trafficTreatment,
159 TrafficSelector trafficSelector) { 162 TrafficSelector trafficSelector) {
160 163
...@@ -195,14 +198,30 @@ public final class FlowObjectiveCompositionUtil { ...@@ -195,14 +198,30 @@ public final class FlowObjectiveCompositionUtil {
195 } else { 198 } else {
196 return null; 199 return null;
197 } 200 }
198 - } else {
199 - break;
200 } 201 }
201 default: 202 default:
202 break; 203 break;
203 } 204 }
204 break; 205 break;
205 } 206 }
207 + case L1MODIFICATION: {
208 + L1ModificationInstruction l1 = (L1ModificationInstruction) instruction;
209 + switch (l1.subtype()) {
210 + case ODU_SIGID:
211 + if (criterionMap.containsKey(Criterion.Type.ODU_SIGID)) {
212 + if (((OduSignalIdCriterion) criterionMap.get((Criterion.Type.ODU_SIGID))).oduSignalId()
213 + .equals(((L1ModificationInstruction.ModOduSignalIdInstruction) l1)
214 + .oduSignalId())) {
215 + criterionMap.remove(Criterion.Type.ODU_SIGID);
216 + } else {
217 + return null;
218 + }
219 + }
220 + default:
221 + break;
222 + }
223 + break;
224 + }
206 case L2MODIFICATION: { 225 case L2MODIFICATION: {
207 L2ModificationInstruction l2 = (L2ModificationInstruction) instruction; 226 L2ModificationInstruction l2 = (L2ModificationInstruction) instruction;
208 switch (l2.subtype()) { 227 switch (l2.subtype()) {
...@@ -344,6 +363,7 @@ public final class FlowObjectiveCompositionUtil { ...@@ -344,6 +363,7 @@ public final class FlowObjectiveCompositionUtil {
344 363
345 return selectorBuilder.build(); 364 return selectorBuilder.build();
346 } 365 }
366 + //CHECKSTYLE:ON
347 367
348 public static Set<Criterion.Type> getTypeSet(TrafficSelector trafficSelector) { 368 public static Set<Criterion.Type> getTypeSet(TrafficSelector trafficSelector) {
349 Set<Criterion.Type> typeSet = new HashSet<>(); 369 Set<Criterion.Type> typeSet = new HashSet<>();
......
...@@ -70,6 +70,7 @@ import org.onosproject.net.OchPort; ...@@ -70,6 +70,7 @@ import org.onosproject.net.OchPort;
70 import org.onosproject.net.OchSignal; 70 import org.onosproject.net.OchSignal;
71 import org.onosproject.net.OchSignalType; 71 import org.onosproject.net.OchSignalType;
72 import org.onosproject.net.OduCltPort; 72 import org.onosproject.net.OduCltPort;
73 +import org.onosproject.net.OduSignalId;
73 import org.onosproject.net.OduSignalType; 74 import org.onosproject.net.OduSignalType;
74 import org.onosproject.net.OmsPort; 75 import org.onosproject.net.OmsPort;
75 import org.onosproject.net.Port; 76 import org.onosproject.net.Port;
...@@ -118,6 +119,8 @@ import org.onosproject.net.flow.criteria.MetadataCriterion; ...@@ -118,6 +119,8 @@ import org.onosproject.net.flow.criteria.MetadataCriterion;
118 import org.onosproject.net.flow.criteria.MplsCriterion; 119 import org.onosproject.net.flow.criteria.MplsCriterion;
119 import org.onosproject.net.flow.criteria.OchSignalCriterion; 120 import org.onosproject.net.flow.criteria.OchSignalCriterion;
120 import org.onosproject.net.flow.criteria.OchSignalTypeCriterion; 121 import org.onosproject.net.flow.criteria.OchSignalTypeCriterion;
122 +import org.onosproject.net.flow.criteria.OduSignalIdCriterion;
123 +import org.onosproject.net.flow.criteria.OduSignalTypeCriterion;
121 import org.onosproject.net.flow.criteria.PortCriterion; 124 import org.onosproject.net.flow.criteria.PortCriterion;
122 import org.onosproject.net.flow.criteria.SctpPortCriterion; 125 import org.onosproject.net.flow.criteria.SctpPortCriterion;
123 import org.onosproject.net.flow.criteria.TcpPortCriterion; 126 import org.onosproject.net.flow.criteria.TcpPortCriterion;
...@@ -127,6 +130,7 @@ import org.onosproject.net.flow.criteria.VlanIdCriterion; ...@@ -127,6 +130,7 @@ import org.onosproject.net.flow.criteria.VlanIdCriterion;
127 import org.onosproject.net.flow.criteria.VlanPcpCriterion; 130 import org.onosproject.net.flow.criteria.VlanPcpCriterion;
128 import org.onosproject.net.flow.instructions.Instructions; 131 import org.onosproject.net.flow.instructions.Instructions;
129 import org.onosproject.net.flow.instructions.L0ModificationInstruction; 132 import org.onosproject.net.flow.instructions.L0ModificationInstruction;
133 +import org.onosproject.net.flow.instructions.L1ModificationInstruction;
130 import org.onosproject.net.flow.instructions.L2ModificationInstruction; 134 import org.onosproject.net.flow.instructions.L2ModificationInstruction;
131 import org.onosproject.net.flow.instructions.L3ModificationInstruction; 135 import org.onosproject.net.flow.instructions.L3ModificationInstruction;
132 import org.onosproject.net.flow.instructions.L4ModificationInstruction; 136 import org.onosproject.net.flow.instructions.L4ModificationInstruction;
...@@ -337,6 +341,8 @@ public final class KryoNamespaces { ...@@ -337,6 +341,8 @@ public final class KryoNamespaces {
337 IndexedLambdaCriterion.class, 341 IndexedLambdaCriterion.class,
338 OchSignalCriterion.class, 342 OchSignalCriterion.class,
339 OchSignalTypeCriterion.class, 343 OchSignalTypeCriterion.class,
344 + OduSignalIdCriterion.class,
345 + OduSignalTypeCriterion.class,
340 Criterion.class, 346 Criterion.class,
341 Criterion.Type.class, 347 Criterion.Type.class,
342 DefaultTrafficTreatment.class, 348 DefaultTrafficTreatment.class,
...@@ -349,6 +355,9 @@ public final class KryoNamespaces { ...@@ -349,6 +355,9 @@ public final class KryoNamespaces {
349 L0ModificationInstruction.L0SubType.class, 355 L0ModificationInstruction.L0SubType.class,
350 L0ModificationInstruction.ModLambdaInstruction.class, 356 L0ModificationInstruction.ModLambdaInstruction.class,
351 L0ModificationInstruction.ModOchSignalInstruction.class, 357 L0ModificationInstruction.ModOchSignalInstruction.class,
358 + L1ModificationInstruction.class,
359 + L1ModificationInstruction.L1SubType.class,
360 + L1ModificationInstruction.ModOduSignalIdInstruction.class,
352 L2ModificationInstruction.class, 361 L2ModificationInstruction.class,
353 L2ModificationInstruction.L2SubType.class, 362 L2ModificationInstruction.L2SubType.class,
354 L2ModificationInstruction.ModEtherInstruction.class, 363 L2ModificationInstruction.ModEtherInstruction.class,
...@@ -458,6 +467,7 @@ public final class KryoNamespaces { ...@@ -458,6 +467,7 @@ public final class KryoNamespaces {
458 .register(OduCltPort.SignalType.class) 467 .register(OduCltPort.SignalType.class)
459 .register(IndexedLambda.class) 468 .register(IndexedLambda.class)
460 .register(OchSignal.class) 469 .register(OchSignal.class)
470 + .register(OduSignalId.class)
461 .register(OduCltPortDescription.class) 471 .register(OduCltPortDescription.class)
462 .register(OchPortDescription.class) 472 .register(OchPortDescription.class)
463 .register(OmsPortDescription.class) 473 .register(OmsPortDescription.class)
......