sigtype selector and treatment and fix not finding the switch id in test app.
diff --git a/apps/optical/src/main/java/org/onlab/onos/optical/testapp/LambdaForwarding.java b/apps/optical/src/main/java/org/onlab/onos/optical/testapp/LambdaForwarding.java
index b78501f..27b558c 100644
--- a/apps/optical/src/main/java/org/onlab/onos/optical/testapp/LambdaForwarding.java
+++ b/apps/optical/src/main/java/org/onlab/onos/optical/testapp/LambdaForwarding.java
@@ -83,8 +83,12 @@
int inport;
int outport;
short lambda = 10;
+ byte sigType = 1;
+ Integer switchNumber = uglyMap.get(device.id());
+ if (switchNumber == null) {
+ return;
+ }
- int switchNumber = uglyMap.get(device.id());
switch (switchNumber) {
case 1:
inport = 10;
@@ -95,13 +99,15 @@
case 2:
inport = 21;
outport = 11;
- sbuilder.matchLambda(lambda).matchInport(PortNumber.portNumber(inport)); // match sigtype
+ sbuilder.matchLambda(lambda).
+ matchInport(PortNumber.portNumber(inport)); // match sigtype
tbuilder.setOutput(PortNumber.portNumber(outport));
break;
case 3:
inport = 30;
outport = 31;
- sbuilder.matchLambda(lambda).matchInport(PortNumber.portNumber(inport));
+ sbuilder.matchLambda(lambda).
+ matchInport(PortNumber.portNumber(inport));
tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda);
break;
default:
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
index 63e7e24..b840318 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/DefaultTrafficSelector.java
@@ -176,11 +176,17 @@
}
@Override
- public Builder matchLambda(short lambda) {
+ public Builder matchLambda(Short lambda) {
return add(Criteria.matchLambda(lambda));
}
@Override
+ public Builder matchOpticalSignalType(Byte signalType) {
+ return add(Criteria.matchOpticalSignalType(signalType));
+
+ }
+
+ @Override
public TrafficSelector build() {
return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values()));
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java b/core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
index 49815db..ab9b4a1 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/TrafficSelector.java
@@ -134,7 +134,14 @@
* @param lambda
* @return a selection builder
*/
- public Builder matchLambda(short lambda);
+ public Builder matchLambda(Short lambda);
+
+ /**
+ * Matches an optical Signal Type.
+ * @param signalType
+ * @return a selection builder
+ */
+ public Builder matchOpticalSignalType(Byte signalType);
/**
* Builds an immutable traffic selector.
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java b/core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
index 2e177f7..9d8ab7b 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/criteria/Criteria.java
@@ -162,6 +162,17 @@
}
/**
+ * Creates a match on lambda field using the specified value.
+ *
+ * @param lambda
+ * @return match criterion
+ */
+ public static Criterion matchOpticalSignalType(Byte lambda) {
+ return new OpticalSignalTypeCriterion(lambda, Type.OCH_SIGTYPE);
+ }
+
+
+ /**
* Implementations of criteria.
*/
public static final class PortCriterion implements Criterion {
@@ -577,4 +588,48 @@
}
}
+ public static final class OpticalSignalTypeCriterion implements Criterion {
+
+ private final byte signalType;
+ private final Type type;
+
+ public OpticalSignalTypeCriterion(byte signalType, Type type) {
+ this.signalType = signalType;
+ this.type = type;
+ }
+
+ @Override
+ public Type type() {
+ return this.type;
+ }
+
+ public Byte signalType() {
+ return this.signalType;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(type().toString())
+ .add("signalType", signalType).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(signalType, type);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OpticalSignalTypeCriterion) {
+ OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj;
+ return Objects.equals(signalType, that.signalType) &&
+ Objects.equals(type, that.type);
+ }
+ return false;
+ }
+ }
+
}