sigtype selector and treatment and fix not finding the switch id in test app.
Showing
4 changed files
with
79 additions
and
5 deletions
... | @@ -83,8 +83,12 @@ public class LambdaForwarding { | ... | @@ -83,8 +83,12 @@ public class LambdaForwarding { |
83 | int inport; | 83 | int inport; |
84 | int outport; | 84 | int outport; |
85 | short lambda = 10; | 85 | short lambda = 10; |
86 | + byte sigType = 1; | ||
87 | + Integer switchNumber = uglyMap.get(device.id()); | ||
88 | + if (switchNumber == null) { | ||
89 | + return; | ||
90 | + } | ||
86 | 91 | ||
87 | - int switchNumber = uglyMap.get(device.id()); | ||
88 | switch (switchNumber) { | 92 | switch (switchNumber) { |
89 | case 1: | 93 | case 1: |
90 | inport = 10; | 94 | inport = 10; |
... | @@ -95,13 +99,15 @@ public class LambdaForwarding { | ... | @@ -95,13 +99,15 @@ public class LambdaForwarding { |
95 | case 2: | 99 | case 2: |
96 | inport = 21; | 100 | inport = 21; |
97 | outport = 11; | 101 | outport = 11; |
98 | - sbuilder.matchLambda(lambda).matchInport(PortNumber.portNumber(inport)); // match sigtype | 102 | + sbuilder.matchLambda(lambda). |
103 | + matchInport(PortNumber.portNumber(inport)); // match sigtype | ||
99 | tbuilder.setOutput(PortNumber.portNumber(outport)); | 104 | tbuilder.setOutput(PortNumber.portNumber(outport)); |
100 | break; | 105 | break; |
101 | case 3: | 106 | case 3: |
102 | inport = 30; | 107 | inport = 30; |
103 | outport = 31; | 108 | outport = 31; |
104 | - sbuilder.matchLambda(lambda).matchInport(PortNumber.portNumber(inport)); | 109 | + sbuilder.matchLambda(lambda). |
110 | + matchInport(PortNumber.portNumber(inport)); | ||
105 | tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda); | 111 | tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda); |
106 | break; | 112 | break; |
107 | default: | 113 | default: | ... | ... |
... | @@ -176,11 +176,17 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -176,11 +176,17 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
176 | } | 176 | } |
177 | 177 | ||
178 | @Override | 178 | @Override |
179 | - public Builder matchLambda(short lambda) { | 179 | + public Builder matchLambda(Short lambda) { |
180 | return add(Criteria.matchLambda(lambda)); | 180 | return add(Criteria.matchLambda(lambda)); |
181 | } | 181 | } |
182 | 182 | ||
183 | @Override | 183 | @Override |
184 | + public Builder matchOpticalSignalType(Byte signalType) { | ||
185 | + return add(Criteria.matchOpticalSignalType(signalType)); | ||
186 | + | ||
187 | + } | ||
188 | + | ||
189 | + @Override | ||
184 | public TrafficSelector build() { | 190 | public TrafficSelector build() { |
185 | return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); | 191 | return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); |
186 | } | 192 | } | ... | ... |
... | @@ -134,7 +134,14 @@ public interface TrafficSelector { | ... | @@ -134,7 +134,14 @@ public interface TrafficSelector { |
134 | * @param lambda | 134 | * @param lambda |
135 | * @return a selection builder | 135 | * @return a selection builder |
136 | */ | 136 | */ |
137 | - public Builder matchLambda(short lambda); | 137 | + public Builder matchLambda(Short lambda); |
138 | + | ||
139 | + /** | ||
140 | + * Matches an optical Signal Type. | ||
141 | + * @param signalType | ||
142 | + * @return a selection builder | ||
143 | + */ | ||
144 | + public Builder matchOpticalSignalType(Byte signalType); | ||
138 | 145 | ||
139 | /** | 146 | /** |
140 | * Builds an immutable traffic selector. | 147 | * Builds an immutable traffic selector. | ... | ... |
... | @@ -162,6 +162,17 @@ public final class Criteria { | ... | @@ -162,6 +162,17 @@ public final class Criteria { |
162 | } | 162 | } |
163 | 163 | ||
164 | /** | 164 | /** |
165 | + * Creates a match on lambda field using the specified value. | ||
166 | + * | ||
167 | + * @param lambda | ||
168 | + * @return match criterion | ||
169 | + */ | ||
170 | + public static Criterion matchOpticalSignalType(Byte lambda) { | ||
171 | + return new OpticalSignalTypeCriterion(lambda, Type.OCH_SIGTYPE); | ||
172 | + } | ||
173 | + | ||
174 | + | ||
175 | + /** | ||
165 | * Implementations of criteria. | 176 | * Implementations of criteria. |
166 | */ | 177 | */ |
167 | public static final class PortCriterion implements Criterion { | 178 | public static final class PortCriterion implements Criterion { |
... | @@ -577,4 +588,48 @@ public final class Criteria { | ... | @@ -577,4 +588,48 @@ public final class Criteria { |
577 | } | 588 | } |
578 | } | 589 | } |
579 | 590 | ||
591 | + public static final class OpticalSignalTypeCriterion implements Criterion { | ||
592 | + | ||
593 | + private final byte signalType; | ||
594 | + private final Type type; | ||
595 | + | ||
596 | + public OpticalSignalTypeCriterion(byte signalType, Type type) { | ||
597 | + this.signalType = signalType; | ||
598 | + this.type = type; | ||
599 | + } | ||
600 | + | ||
601 | + @Override | ||
602 | + public Type type() { | ||
603 | + return this.type; | ||
604 | + } | ||
605 | + | ||
606 | + public Byte signalType() { | ||
607 | + return this.signalType; | ||
608 | + } | ||
609 | + | ||
610 | + @Override | ||
611 | + public String toString() { | ||
612 | + return toStringHelper(type().toString()) | ||
613 | + .add("signalType", signalType).toString(); | ||
614 | + } | ||
615 | + | ||
616 | + @Override | ||
617 | + public int hashCode() { | ||
618 | + return Objects.hash(signalType, type); | ||
619 | + } | ||
620 | + | ||
621 | + @Override | ||
622 | + public boolean equals(Object obj) { | ||
623 | + if (this == obj) { | ||
624 | + return true; | ||
625 | + } | ||
626 | + if (obj instanceof OpticalSignalTypeCriterion) { | ||
627 | + OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj; | ||
628 | + return Objects.equals(signalType, that.signalType) && | ||
629 | + Objects.equals(type, that.type); | ||
630 | + } | ||
631 | + return false; | ||
632 | + } | ||
633 | + } | ||
634 | + | ||
580 | } | 635 | } | ... | ... |
-
Please register or login to post a comment