Implement some of the missing Selector and Match Conditions
Work toward ONOS-509 The following match conditions are added/implemented: - IN_PHY_PORT - IP_DSCP - IP_ECN - METADATA Change-Id: I6f529ee90b2b9e0d5046f83c034e8be3faf86d8b
Showing
9 changed files
with
516 additions
and
21 deletions
... | @@ -135,6 +135,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -135,6 +135,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
135 | } | 135 | } |
136 | 136 | ||
137 | @Override | 137 | @Override |
138 | + public Builder matchInPhyPort(PortNumber port) { | ||
139 | + return add(Criteria.matchInPhyPort(port)); | ||
140 | + } | ||
141 | + | ||
142 | + @Override | ||
143 | + public Builder matchMetadata(Long metadata) { | ||
144 | + return add(Criteria.matchMetadata(metadata)); | ||
145 | + } | ||
146 | + | ||
147 | + @Override | ||
138 | public Builder matchEthDst(MacAddress addr) { | 148 | public Builder matchEthDst(MacAddress addr) { |
139 | return add(Criteria.matchEthDst(addr)); | 149 | return add(Criteria.matchEthDst(addr)); |
140 | } | 150 | } |
... | @@ -160,6 +170,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -160,6 +170,16 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
160 | } | 170 | } |
161 | 171 | ||
162 | @Override | 172 | @Override |
173 | + public Builder matchIPDscp(Byte ipDscp) { | ||
174 | + return add(Criteria.matchIPDscp(ipDscp)); | ||
175 | + } | ||
176 | + | ||
177 | + @Override | ||
178 | + public Builder matchIPEcn(Byte ipEcn) { | ||
179 | + return add(Criteria.matchIPEcn(ipEcn)); | ||
180 | + } | ||
181 | + | ||
182 | + @Override | ||
163 | public Builder matchIPProtocol(Byte proto) { | 183 | public Builder matchIPProtocol(Byte proto) { |
164 | return add(Criteria.matchIPProtocol(proto)); | 184 | return add(Criteria.matchIPProtocol(proto)); |
165 | } | 185 | } |
... | @@ -273,7 +293,5 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -273,7 +293,5 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
273 | public TrafficSelector build() { | 293 | public TrafficSelector build() { |
274 | return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); | 294 | return new DefaultTrafficSelector(ImmutableSet.copyOf(selector.values())); |
275 | } | 295 | } |
276 | - | ||
277 | } | 296 | } |
278 | - | ||
279 | } | 297 | } | ... | ... |
... | @@ -68,6 +68,22 @@ public interface TrafficSelector { | ... | @@ -68,6 +68,22 @@ public interface TrafficSelector { |
68 | public Builder matchInPort(PortNumber port); | 68 | public Builder matchInPort(PortNumber port); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | + * Matches a physical inport. | ||
72 | + * | ||
73 | + * @param port the physical inport | ||
74 | + * @return a selection builder | ||
75 | + */ | ||
76 | + public Builder matchInPhyPort(PortNumber port); | ||
77 | + | ||
78 | + /** | ||
79 | + * Matches a metadata. | ||
80 | + * | ||
81 | + * @param metadata the metadata | ||
82 | + * @return a selection builder | ||
83 | + */ | ||
84 | + public Builder matchMetadata(Long metadata); | ||
85 | + | ||
86 | + /** | ||
71 | * Matches a l2 dst address. | 87 | * Matches a l2 dst address. |
72 | * | 88 | * |
73 | * @param addr a l2 address | 89 | * @param addr a l2 address |
... | @@ -108,6 +124,22 @@ public interface TrafficSelector { | ... | @@ -108,6 +124,22 @@ public interface TrafficSelector { |
108 | public Builder matchVlanPcp(Byte vlanPcp); | 124 | public Builder matchVlanPcp(Byte vlanPcp); |
109 | 125 | ||
110 | /** | 126 | /** |
127 | + * Matches an IP DSCP (6 bits in ToS field). | ||
128 | + * | ||
129 | + * @param ipDscp an IP DSCP value | ||
130 | + * @return a selection builder | ||
131 | + */ | ||
132 | + public Builder matchIPDscp(Byte ipDscp); | ||
133 | + | ||
134 | + /** | ||
135 | + * Matches an IP ECN (2 bits in ToS field). | ||
136 | + * | ||
137 | + * @param ipEcn an IP ECN value | ||
138 | + * @return a selection builder | ||
139 | + */ | ||
140 | + public Builder matchIPEcn(Byte ipEcn); | ||
141 | + | ||
142 | + /** | ||
111 | * Matches the l3 protocol. | 143 | * Matches the l3 protocol. |
112 | * | 144 | * |
113 | * @param proto a l3 protocol | 145 | * @param proto a l3 protocol | ... | ... |
... | @@ -43,7 +43,27 @@ public final class Criteria { | ... | @@ -43,7 +43,27 @@ public final class Criteria { |
43 | * @return match criterion | 43 | * @return match criterion |
44 | */ | 44 | */ |
45 | public static Criterion matchInPort(PortNumber port) { | 45 | public static Criterion matchInPort(PortNumber port) { |
46 | - return new PortCriterion(port); | 46 | + return new PortCriterion(port, Type.IN_PORT); |
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Creates a match on IN_PHY_PORT field using the specified value. | ||
51 | + * | ||
52 | + * @param port inport value | ||
53 | + * @return match criterion | ||
54 | + */ | ||
55 | + public static Criterion matchInPhyPort(PortNumber port) { | ||
56 | + return new PortCriterion(port, Type.IN_PHY_PORT); | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a match on METADATA field using the specified value. | ||
61 | + * | ||
62 | + * @param metadata metadata value | ||
63 | + * @return match criterion | ||
64 | + */ | ||
65 | + public static Criterion matchMetadata(Long metadata) { | ||
66 | + return new MetadataCriterion(metadata); | ||
47 | } | 67 | } |
48 | 68 | ||
49 | /** | 69 | /** |
... | @@ -99,6 +119,26 @@ public final class Criteria { | ... | @@ -99,6 +119,26 @@ public final class Criteria { |
99 | } | 119 | } |
100 | 120 | ||
101 | /** | 121 | /** |
122 | + * Creates a match on IP DSCP field using the specified value. | ||
123 | + * | ||
124 | + * @param ipDscp ip dscp value | ||
125 | + * @return match criterion | ||
126 | + */ | ||
127 | + public static Criterion matchIPDscp(Byte ipDscp) { | ||
128 | + return new IPDscpCriterion(ipDscp); | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Creates a match on IP ECN field using the specified value. | ||
133 | + * | ||
134 | + * @param ipEcn ip ecn value | ||
135 | + * @return match criterion | ||
136 | + */ | ||
137 | + public static Criterion matchIPEcn(Byte ipEcn) { | ||
138 | + return new IPEcnCriterion(ipEcn); | ||
139 | + } | ||
140 | + | ||
141 | + /** | ||
102 | * Creates a match on IP proto field using the specified value. | 142 | * Creates a match on IP proto field using the specified value. |
103 | * | 143 | * |
104 | * @param proto ip protocol value | 144 | * @param proto ip protocol value |
... | @@ -327,19 +367,23 @@ public final class Criteria { | ... | @@ -327,19 +367,23 @@ public final class Criteria { |
327 | */ | 367 | */ |
328 | public static final class PortCriterion implements Criterion { | 368 | public static final class PortCriterion implements Criterion { |
329 | private final PortNumber port; | 369 | private final PortNumber port; |
370 | + private final Type type; | ||
330 | 371 | ||
331 | /** | 372 | /** |
332 | * Constructor. | 373 | * Constructor. |
333 | * | 374 | * |
334 | * @param port the input port number to match | 375 | * @param port the input port number to match |
376 | + * @param type the match type. Should be either Type.IN_PORT or | ||
377 | + * Type.IN_PHY_PORT | ||
335 | */ | 378 | */ |
336 | - public PortCriterion(PortNumber port) { | 379 | + public PortCriterion(PortNumber port, Type type) { |
337 | this.port = port; | 380 | this.port = port; |
381 | + this.type = type; | ||
338 | } | 382 | } |
339 | 383 | ||
340 | @Override | 384 | @Override |
341 | public Type type() { | 385 | public Type type() { |
342 | - return Type.IN_PORT; | 386 | + return this.type; |
343 | } | 387 | } |
344 | 388 | ||
345 | /** | 389 | /** |
... | @@ -371,7 +415,61 @@ public final class Criteria { | ... | @@ -371,7 +415,61 @@ public final class Criteria { |
371 | PortCriterion that = (PortCriterion) obj; | 415 | PortCriterion that = (PortCriterion) obj; |
372 | return Objects.equals(port, that.port) && | 416 | return Objects.equals(port, that.port) && |
373 | Objects.equals(this.type(), that.type()); | 417 | Objects.equals(this.type(), that.type()); |
418 | + } | ||
419 | + return false; | ||
420 | + } | ||
421 | + } | ||
374 | 422 | ||
423 | + /** | ||
424 | + * Implementation of Metadata criterion. | ||
425 | + */ | ||
426 | + public static final class MetadataCriterion implements Criterion { | ||
427 | + private final Long metadata; | ||
428 | + | ||
429 | + /** | ||
430 | + * Constructor. | ||
431 | + * | ||
432 | + * @param metadata the metadata to match | ||
433 | + */ | ||
434 | + public MetadataCriterion(Long metadata) { | ||
435 | + this.metadata = metadata; | ||
436 | + } | ||
437 | + | ||
438 | + @Override | ||
439 | + public Type type() { | ||
440 | + return Type.METADATA; | ||
441 | + } | ||
442 | + | ||
443 | + /** | ||
444 | + * Gets the metadata to match. | ||
445 | + * | ||
446 | + * @return the metadata to match | ||
447 | + */ | ||
448 | + public Long metadata() { | ||
449 | + return metadata; | ||
450 | + } | ||
451 | + | ||
452 | + @Override | ||
453 | + public String toString() { | ||
454 | + return toStringHelper(type().toString()) | ||
455 | + .add("metadata", Long.toHexString(metadata)) | ||
456 | + .toString(); | ||
457 | + } | ||
458 | + | ||
459 | + @Override | ||
460 | + public int hashCode() { | ||
461 | + return Objects.hash(type(), metadata); | ||
462 | + } | ||
463 | + | ||
464 | + @Override | ||
465 | + public boolean equals(Object obj) { | ||
466 | + if (this == obj) { | ||
467 | + return true; | ||
468 | + } | ||
469 | + if (obj instanceof MetadataCriterion) { | ||
470 | + MetadataCriterion that = (MetadataCriterion) obj; | ||
471 | + return Objects.equals(metadata, that.metadata) && | ||
472 | + Objects.equals(this.type(), that.type()); | ||
375 | } | 473 | } |
376 | return false; | 474 | return false; |
377 | } | 475 | } |
... | @@ -601,6 +699,118 @@ public final class Criteria { | ... | @@ -601,6 +699,118 @@ public final class Criteria { |
601 | } | 699 | } |
602 | 700 | ||
603 | /** | 701 | /** |
702 | + * Implementation of IP DSCP criterion (6-bit Differentiated Services | ||
703 | + * Code Point). | ||
704 | + */ | ||
705 | + public static final class IPDscpCriterion implements Criterion { | ||
706 | + private static final byte DSCP_MASK = 0x3f; | ||
707 | + private final Byte ipDscp; // IP DSCP value: 6 bits | ||
708 | + | ||
709 | + /** | ||
710 | + * Constructor. | ||
711 | + * | ||
712 | + * @param ipDscp the IP DSCP value to match | ||
713 | + */ | ||
714 | + public IPDscpCriterion(Byte ipDscp) { | ||
715 | + this.ipDscp = (byte) (ipDscp & DSCP_MASK); | ||
716 | + } | ||
717 | + | ||
718 | + @Override | ||
719 | + public Type type() { | ||
720 | + return Type.IP_DSCP; | ||
721 | + } | ||
722 | + | ||
723 | + /** | ||
724 | + * Gets the IP DSCP value to match. | ||
725 | + * | ||
726 | + * @return the IP DSCP value to match | ||
727 | + */ | ||
728 | + public Byte ipDscp() { | ||
729 | + return ipDscp; | ||
730 | + } | ||
731 | + | ||
732 | + @Override | ||
733 | + public String toString() { | ||
734 | + return toStringHelper(type().toString()) | ||
735 | + .add("ipDscp", ipDscp).toString(); | ||
736 | + } | ||
737 | + | ||
738 | + @Override | ||
739 | + public int hashCode() { | ||
740 | + return Objects.hash(type(), ipDscp); | ||
741 | + } | ||
742 | + | ||
743 | + @Override | ||
744 | + public boolean equals(Object obj) { | ||
745 | + if (this == obj) { | ||
746 | + return true; | ||
747 | + } | ||
748 | + if (obj instanceof IPDscpCriterion) { | ||
749 | + IPDscpCriterion that = (IPDscpCriterion) obj; | ||
750 | + return Objects.equals(ipDscp, that.ipDscp) && | ||
751 | + Objects.equals(this.type(), that.type()); | ||
752 | + } | ||
753 | + return false; | ||
754 | + } | ||
755 | + } | ||
756 | + | ||
757 | + /** | ||
758 | + * Implementation of IP ECN criterion (3-bit Explicit Congestion | ||
759 | + * Notification). | ||
760 | + */ | ||
761 | + public static final class IPEcnCriterion implements Criterion { | ||
762 | + private static final byte ECN_MASK = 0x3; | ||
763 | + private final Byte ipEcn; // IP ECN value: 3 bits | ||
764 | + | ||
765 | + /** | ||
766 | + * Constructor. | ||
767 | + * | ||
768 | + * @param ipEcn the IP ECN value to match | ||
769 | + */ | ||
770 | + public IPEcnCriterion(Byte ipEcn) { | ||
771 | + this.ipEcn = (byte) (ipEcn & ECN_MASK); | ||
772 | + } | ||
773 | + | ||
774 | + @Override | ||
775 | + public Type type() { | ||
776 | + return Type.IP_ECN; | ||
777 | + } | ||
778 | + | ||
779 | + /** | ||
780 | + * Gets the IP ECN value to match. | ||
781 | + * | ||
782 | + * @return the IP ECN value to match | ||
783 | + */ | ||
784 | + public Byte ipEcn() { | ||
785 | + return ipEcn; | ||
786 | + } | ||
787 | + | ||
788 | + @Override | ||
789 | + public String toString() { | ||
790 | + return toStringHelper(type().toString()) | ||
791 | + .add("ipEcn", ipEcn).toString(); | ||
792 | + } | ||
793 | + | ||
794 | + @Override | ||
795 | + public int hashCode() { | ||
796 | + return Objects.hash(type(), ipEcn); | ||
797 | + } | ||
798 | + | ||
799 | + @Override | ||
800 | + public boolean equals(Object obj) { | ||
801 | + if (this == obj) { | ||
802 | + return true; | ||
803 | + } | ||
804 | + if (obj instanceof IPEcnCriterion) { | ||
805 | + IPEcnCriterion that = (IPEcnCriterion) obj; | ||
806 | + return Objects.equals(ipEcn, that.ipEcn) && | ||
807 | + Objects.equals(this.type(), that.type()); | ||
808 | + } | ||
809 | + return false; | ||
810 | + } | ||
811 | + } | ||
812 | + | ||
813 | + /** | ||
604 | * Implementation of Internet Protocol Number criterion. | 814 | * Implementation of Internet Protocol Number criterion. |
605 | */ | 815 | */ |
606 | public static final class IPProtocolCriterion implements Criterion { | 816 | public static final class IPProtocolCriterion implements Criterion { | ... | ... |
... | @@ -127,9 +127,12 @@ public class DefaultTrafficSelectorTest { | ... | @@ -127,9 +127,12 @@ public class DefaultTrafficSelectorTest { |
127 | public void testCriteriaCreation() { | 127 | public void testCriteriaCreation() { |
128 | TrafficSelector selector; | 128 | TrafficSelector selector; |
129 | 129 | ||
130 | + final long longValue = 0x12345678; | ||
130 | final int intValue = 22; | 131 | final int intValue = 22; |
131 | final short shortValue = 33; | 132 | final short shortValue = 33; |
132 | final byte byteValue = 44; | 133 | final byte byteValue = 44; |
134 | + final byte dscpValue = 0xf; | ||
135 | + final byte ecnValue = 3; | ||
133 | final MacAddress macValue = MacAddress.valueOf("11:22:33:44:55:66"); | 136 | final MacAddress macValue = MacAddress.valueOf("11:22:33:44:55:66"); |
134 | final IpPrefix ipPrefixValue = IpPrefix.valueOf("192.168.1.0/24"); | 137 | final IpPrefix ipPrefixValue = IpPrefix.valueOf("192.168.1.0/24"); |
135 | final IpPrefix ipv6PrefixValue = IpPrefix.valueOf("fe80::1/64"); | 138 | final IpPrefix ipv6PrefixValue = IpPrefix.valueOf("fe80::1/64"); |
... | @@ -140,6 +143,14 @@ public class DefaultTrafficSelectorTest { | ... | @@ -140,6 +143,14 @@ public class DefaultTrafficSelectorTest { |
140 | assertThat(selector, hasCriterionWithType(Type.IN_PORT)); | 143 | assertThat(selector, hasCriterionWithType(Type.IN_PORT)); |
141 | 144 | ||
142 | selector = DefaultTrafficSelector.builder() | 145 | selector = DefaultTrafficSelector.builder() |
146 | + .matchInPhyPort(PortNumber.portNumber(11)).build(); | ||
147 | + assertThat(selector, hasCriterionWithType(Type.IN_PHY_PORT)); | ||
148 | + | ||
149 | + selector = DefaultTrafficSelector.builder() | ||
150 | + .matchMetadata(longValue).build(); | ||
151 | + assertThat(selector, hasCriterionWithType(Type.METADATA)); | ||
152 | + | ||
153 | + selector = DefaultTrafficSelector.builder() | ||
143 | .matchEthDst(macValue).build(); | 154 | .matchEthDst(macValue).build(); |
144 | assertThat(selector, hasCriterionWithType(Type.ETH_DST)); | 155 | assertThat(selector, hasCriterionWithType(Type.ETH_DST)); |
145 | 156 | ||
... | @@ -160,6 +171,14 @@ public class DefaultTrafficSelectorTest { | ... | @@ -160,6 +171,14 @@ public class DefaultTrafficSelectorTest { |
160 | assertThat(selector, hasCriterionWithType(Type.VLAN_PCP)); | 171 | assertThat(selector, hasCriterionWithType(Type.VLAN_PCP)); |
161 | 172 | ||
162 | selector = DefaultTrafficSelector.builder() | 173 | selector = DefaultTrafficSelector.builder() |
174 | + .matchIPDscp(dscpValue).build(); | ||
175 | + assertThat(selector, hasCriterionWithType(Type.IP_DSCP)); | ||
176 | + | ||
177 | + selector = DefaultTrafficSelector.builder() | ||
178 | + .matchIPEcn(ecnValue).build(); | ||
179 | + assertThat(selector, hasCriterionWithType(Type.IP_ECN)); | ||
180 | + | ||
181 | + selector = DefaultTrafficSelector.builder() | ||
163 | .matchIPProtocol(byteValue).build(); | 182 | .matchIPProtocol(byteValue).build(); |
164 | assertThat(selector, hasCriterionWithType(Type.IP_PROTO)); | 183 | assertThat(selector, hasCriterionWithType(Type.IP_PROTO)); |
165 | 184 | ... | ... |
... | @@ -45,6 +45,16 @@ public class CriteriaTest { | ... | @@ -45,6 +45,16 @@ public class CriteriaTest { |
45 | Criterion sameAsMatchInPort1 = Criteria.matchInPort(port1); | 45 | Criterion sameAsMatchInPort1 = Criteria.matchInPort(port1); |
46 | Criterion matchInPort2 = Criteria.matchInPort(port2); | 46 | Criterion matchInPort2 = Criteria.matchInPort(port2); |
47 | 47 | ||
48 | + Criterion matchInPhyPort1 = Criteria.matchInPhyPort(port1); | ||
49 | + Criterion sameAsMatchInPhyPort1 = Criteria.matchInPhyPort(port1); | ||
50 | + Criterion matchInPhyPort2 = Criteria.matchInPhyPort(port2); | ||
51 | + | ||
52 | + long metadata1 = 1; | ||
53 | + long metadata2 = 2; | ||
54 | + Criterion matchMetadata1 = Criteria.matchMetadata(metadata1); | ||
55 | + Criterion sameAsMatchMetadata1 = Criteria.matchMetadata(metadata1); | ||
56 | + Criterion matchMetadata2 = Criteria.matchMetadata(metadata2); | ||
57 | + | ||
48 | private static final String MAC1 = "00:00:00:00:00:01"; | 58 | private static final String MAC1 = "00:00:00:00:00:01"; |
49 | private static final String MAC2 = "00:00:00:00:00:02"; | 59 | private static final String MAC2 = "00:00:00:00:00:02"; |
50 | private MacAddress mac1 = MacAddress.valueOf(MAC1); | 60 | private MacAddress mac1 = MacAddress.valueOf(MAC1); |
... | @@ -73,6 +83,18 @@ public class CriteriaTest { | ... | @@ -73,6 +83,18 @@ public class CriteriaTest { |
73 | Criterion sameAsMatchVlanPcp1 = Criteria.matchVlanPcp(vlanPcp1); | 83 | Criterion sameAsMatchVlanPcp1 = Criteria.matchVlanPcp(vlanPcp1); |
74 | Criterion matchVlanPcp2 = Criteria.matchVlanPcp(vlanPcp2); | 84 | Criterion matchVlanPcp2 = Criteria.matchVlanPcp(vlanPcp2); |
75 | 85 | ||
86 | + byte ipDscp1 = 1; | ||
87 | + byte ipDscp2 = 2; | ||
88 | + Criterion matchIpDscp1 = Criteria.matchIPDscp(ipDscp1); | ||
89 | + Criterion sameAsMatchIpDscp1 = Criteria.matchIPDscp(ipDscp1); | ||
90 | + Criterion matchIpDscp2 = Criteria.matchIPDscp(ipDscp2); | ||
91 | + | ||
92 | + byte ipEcn1 = 1; | ||
93 | + byte ipEcn2 = 2; | ||
94 | + Criterion matchIpEcn1 = Criteria.matchIPEcn(ipEcn1); | ||
95 | + Criterion sameAsMatchIpEcn1 = Criteria.matchIPEcn(ipEcn1); | ||
96 | + Criterion matchIpEcn2 = Criteria.matchIPEcn(ipEcn2); | ||
97 | + | ||
76 | byte protocol1 = 1; | 98 | byte protocol1 = 1; |
77 | byte protocol2 = 2; | 99 | byte protocol2 = 2; |
78 | Criterion matchIpProtocol1 = Criteria.matchIPProtocol(protocol1); | 100 | Criterion matchIpProtocol1 = Criteria.matchIPProtocol(protocol1); |
... | @@ -214,10 +236,13 @@ public class CriteriaTest { | ... | @@ -214,10 +236,13 @@ public class CriteriaTest { |
214 | @Test | 236 | @Test |
215 | public void testCriteriaImmutability() { | 237 | public void testCriteriaImmutability() { |
216 | assertThatClassIsImmutable(Criteria.PortCriterion.class); | 238 | assertThatClassIsImmutable(Criteria.PortCriterion.class); |
239 | + assertThatClassIsImmutable(Criteria.MetadataCriterion.class); | ||
217 | assertThatClassIsImmutable(Criteria.EthCriterion.class); | 240 | assertThatClassIsImmutable(Criteria.EthCriterion.class); |
218 | assertThatClassIsImmutable(Criteria.EthTypeCriterion.class); | 241 | assertThatClassIsImmutable(Criteria.EthTypeCriterion.class); |
219 | assertThatClassIsImmutable(Criteria.VlanIdCriterion.class); | 242 | assertThatClassIsImmutable(Criteria.VlanIdCriterion.class); |
220 | assertThatClassIsImmutable(Criteria.VlanPcpCriterion.class); | 243 | assertThatClassIsImmutable(Criteria.VlanPcpCriterion.class); |
244 | + assertThatClassIsImmutable(Criteria.IPDscpCriterion.class); | ||
245 | + assertThatClassIsImmutable(Criteria.IPEcnCriterion.class); | ||
221 | assertThatClassIsImmutable(Criteria.IPProtocolCriterion.class); | 246 | assertThatClassIsImmutable(Criteria.IPProtocolCriterion.class); |
222 | assertThatClassIsImmutable(Criteria.IPCriterion.class); | 247 | assertThatClassIsImmutable(Criteria.IPCriterion.class); |
223 | assertThatClassIsImmutable(Criteria.TcpPortCriterion.class); | 248 | assertThatClassIsImmutable(Criteria.TcpPortCriterion.class); |
... | @@ -252,6 +277,20 @@ public class CriteriaTest { | ... | @@ -252,6 +277,20 @@ public class CriteriaTest { |
252 | } | 277 | } |
253 | 278 | ||
254 | /** | 279 | /** |
280 | + * Test the matchInPhyPort method. | ||
281 | + */ | ||
282 | + @Test | ||
283 | + public void testMatchInPhyPortMethod() { | ||
284 | + PortNumber p1 = portNumber(1); | ||
285 | + Criterion matchInPhyPort = Criteria.matchInPhyPort(p1); | ||
286 | + Criteria.PortCriterion portCriterion = | ||
287 | + checkAndConvert(matchInPhyPort, | ||
288 | + Criterion.Type.IN_PHY_PORT, | ||
289 | + Criteria.PortCriterion.class); | ||
290 | + assertThat(portCriterion.port(), is(equalTo(p1))); | ||
291 | + } | ||
292 | + | ||
293 | + /** | ||
255 | * Test the equals() method of the PortCriterion class. | 294 | * Test the equals() method of the PortCriterion class. |
256 | */ | 295 | */ |
257 | @Test | 296 | @Test |
... | @@ -260,6 +299,38 @@ public class CriteriaTest { | ... | @@ -260,6 +299,38 @@ public class CriteriaTest { |
260 | .addEqualityGroup(matchInPort1, sameAsMatchInPort1) | 299 | .addEqualityGroup(matchInPort1, sameAsMatchInPort1) |
261 | .addEqualityGroup(matchInPort2) | 300 | .addEqualityGroup(matchInPort2) |
262 | .testEquals(); | 301 | .testEquals(); |
302 | + | ||
303 | + new EqualsTester() | ||
304 | + .addEqualityGroup(matchInPhyPort1, sameAsMatchInPhyPort1) | ||
305 | + .addEqualityGroup(matchInPhyPort2) | ||
306 | + .testEquals(); | ||
307 | + } | ||
308 | + | ||
309 | + // MetadataCriterion class | ||
310 | + | ||
311 | + /** | ||
312 | + * Test the matchMetadata method. | ||
313 | + */ | ||
314 | + @Test | ||
315 | + public void testMatchMetadataMethod() { | ||
316 | + Long metadata = 12L; | ||
317 | + Criterion matchMetadata = Criteria.matchMetadata(metadata); | ||
318 | + Criteria.MetadataCriterion metadataCriterion = | ||
319 | + checkAndConvert(matchMetadata, | ||
320 | + Criterion.Type.METADATA, | ||
321 | + Criteria.MetadataCriterion.class); | ||
322 | + assertThat(metadataCriterion.metadata(), is(equalTo(metadata))); | ||
323 | + } | ||
324 | + | ||
325 | + /** | ||
326 | + * Test the equals() method of the MetadataCriterion class. | ||
327 | + */ | ||
328 | + @Test | ||
329 | + public void testMetadataCriterionEquals() { | ||
330 | + new EqualsTester() | ||
331 | + .addEqualityGroup(matchMetadata1, sameAsMatchMetadata1) | ||
332 | + .addEqualityGroup(matchMetadata2) | ||
333 | + .testEquals(); | ||
263 | } | 334 | } |
264 | 335 | ||
265 | // EthCriterion class | 336 | // EthCriterion class |
... | @@ -380,6 +451,58 @@ public class CriteriaTest { | ... | @@ -380,6 +451,58 @@ public class CriteriaTest { |
380 | .testEquals(); | 451 | .testEquals(); |
381 | } | 452 | } |
382 | 453 | ||
454 | + // IPDscpCriterion class | ||
455 | + | ||
456 | + /** | ||
457 | + * Test the matchIPDscp method. | ||
458 | + */ | ||
459 | + @Test | ||
460 | + public void testMatchIPDscpMethod() { | ||
461 | + Criterion matchIPDscp = Criteria.matchIPDscp(ipDscp1); | ||
462 | + Criteria.IPDscpCriterion ipDscpCriterion = | ||
463 | + checkAndConvert(matchIPDscp, | ||
464 | + Criterion.Type.IP_DSCP, | ||
465 | + Criteria.IPDscpCriterion.class); | ||
466 | + assertThat(ipDscpCriterion.ipDscp(), is(equalTo(ipDscp1))); | ||
467 | + } | ||
468 | + | ||
469 | + /** | ||
470 | + * Test the equals() method of the IPDscpCriterion class. | ||
471 | + */ | ||
472 | + @Test | ||
473 | + public void testIPDscpCriterionEquals() { | ||
474 | + new EqualsTester() | ||
475 | + .addEqualityGroup(matchIpDscp1, sameAsMatchIpDscp1) | ||
476 | + .addEqualityGroup(matchIpDscp2) | ||
477 | + .testEquals(); | ||
478 | + } | ||
479 | + | ||
480 | + // IPEcnCriterion class | ||
481 | + | ||
482 | + /** | ||
483 | + * Test the matchIPEcn method. | ||
484 | + */ | ||
485 | + @Test | ||
486 | + public void testMatchIPEcnMethod() { | ||
487 | + Criterion matchIPEcn = Criteria.matchIPEcn(ipEcn1); | ||
488 | + Criteria.IPEcnCriterion ipEcnCriterion = | ||
489 | + checkAndConvert(matchIPEcn, | ||
490 | + Criterion.Type.IP_ECN, | ||
491 | + Criteria.IPEcnCriterion.class); | ||
492 | + assertThat(ipEcnCriterion.ipEcn(), is(equalTo(ipEcn1))); | ||
493 | + } | ||
494 | + | ||
495 | + /** | ||
496 | + * Test the equals() method of the IPEcnCriterion class. | ||
497 | + */ | ||
498 | + @Test | ||
499 | + public void testIPEcnCriterionEquals() { | ||
500 | + new EqualsTester() | ||
501 | + .addEqualityGroup(matchIpEcn1, sameAsMatchIpEcn1) | ||
502 | + .addEqualityGroup(matchIpEcn2) | ||
503 | + .testEquals(); | ||
504 | + } | ||
505 | + | ||
383 | // IpProtocolCriterion class | 506 | // IpProtocolCriterion class |
384 | 507 | ||
385 | /** | 508 | /** | ... | ... |
... | @@ -355,6 +355,15 @@ public class FlowEntryBuilder { | ... | @@ -355,6 +355,15 @@ public class FlowEntryBuilder { |
355 | builder.matchInPort(PortNumber | 355 | builder.matchInPort(PortNumber |
356 | .portNumber(match.get(MatchField.IN_PORT).getPortNumber())); | 356 | .portNumber(match.get(MatchField.IN_PORT).getPortNumber())); |
357 | break; | 357 | break; |
358 | + case IN_PHY_PORT: | ||
359 | + builder.matchInPhyPort(PortNumber | ||
360 | + .portNumber(match.get(MatchField.IN_PHY_PORT).getPortNumber())); | ||
361 | + break; | ||
362 | + case METADATA: | ||
363 | + long metadata = | ||
364 | + match.get(MatchField.METADATA).getValue().getValue(); | ||
365 | + builder.matchMetadata(metadata); | ||
366 | + break; | ||
358 | case ETH_DST: | 367 | case ETH_DST: |
359 | mac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong()); | 368 | mac = MacAddress.valueOf(match.get(MatchField.ETH_DST).getLong()); |
360 | builder.matchEthDst(mac); | 369 | builder.matchEthDst(mac); |
... | @@ -386,6 +395,14 @@ public class FlowEntryBuilder { | ... | @@ -386,6 +395,14 @@ public class FlowEntryBuilder { |
386 | byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue(); | 395 | byte vlanPcp = match.get(MatchField.VLAN_PCP).getValue(); |
387 | builder.matchVlanPcp(vlanPcp); | 396 | builder.matchVlanPcp(vlanPcp); |
388 | break; | 397 | break; |
398 | + case IP_DSCP: | ||
399 | + byte ipDscp = match.get(MatchField.IP_DSCP).getDscpValue(); | ||
400 | + builder.matchIPDscp(ipDscp); | ||
401 | + break; | ||
402 | + case IP_ECN: | ||
403 | + byte ipEcn = match.get(MatchField.IP_ECN).getEcnValue(); | ||
404 | + builder.matchIPEcn(ipEcn); | ||
405 | + break; | ||
389 | case IP_PROTO: | 406 | case IP_PROTO: |
390 | short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber(); | 407 | short proto = match.get(MatchField.IP_PROTO).getIpProtocolNumber(); |
391 | builder.matchIPProtocol((byte) proto); | 408 | builder.matchIPProtocol((byte) proto); |
... | @@ -514,10 +531,6 @@ public class FlowEntryBuilder { | ... | @@ -514,10 +531,6 @@ public class FlowEntryBuilder { |
514 | case ARP_SPA: | 531 | case ARP_SPA: |
515 | case ARP_THA: | 532 | case ARP_THA: |
516 | case ARP_TPA: | 533 | case ARP_TPA: |
517 | - case IN_PHY_PORT: | ||
518 | - case IP_DSCP: | ||
519 | - case IP_ECN: | ||
520 | - case METADATA: | ||
521 | case MPLS_TC: | 534 | case MPLS_TC: |
522 | case TUNNEL_ID: | 535 | case TUNNEL_ID: |
523 | default: | 536 | default: | ... | ... |
... | @@ -30,11 +30,14 @@ import org.onosproject.net.flow.criteria.Criteria.IcmpTypeCriterion; | ... | @@ -30,11 +30,14 @@ import org.onosproject.net.flow.criteria.Criteria.IcmpTypeCriterion; |
30 | import org.onosproject.net.flow.criteria.Criteria.Icmpv6CodeCriterion; | 30 | import org.onosproject.net.flow.criteria.Criteria.Icmpv6CodeCriterion; |
31 | import org.onosproject.net.flow.criteria.Criteria.Icmpv6TypeCriterion; | 31 | import org.onosproject.net.flow.criteria.Criteria.Icmpv6TypeCriterion; |
32 | import org.onosproject.net.flow.criteria.Criteria.IPCriterion; | 32 | import org.onosproject.net.flow.criteria.Criteria.IPCriterion; |
33 | +import org.onosproject.net.flow.criteria.Criteria.IPDscpCriterion; | ||
34 | +import org.onosproject.net.flow.criteria.Criteria.IPEcnCriterion; | ||
33 | import org.onosproject.net.flow.criteria.Criteria.IPProtocolCriterion; | 35 | import org.onosproject.net.flow.criteria.Criteria.IPProtocolCriterion; |
34 | import org.onosproject.net.flow.criteria.Criteria.IPv6FlowLabelCriterion; | 36 | import org.onosproject.net.flow.criteria.Criteria.IPv6FlowLabelCriterion; |
35 | import org.onosproject.net.flow.criteria.Criteria.IPv6NDLinkLayerAddressCriterion; | 37 | import org.onosproject.net.flow.criteria.Criteria.IPv6NDLinkLayerAddressCriterion; |
36 | import org.onosproject.net.flow.criteria.Criteria.IPv6NDTargetAddressCriterion; | 38 | import org.onosproject.net.flow.criteria.Criteria.IPv6NDTargetAddressCriterion; |
37 | import org.onosproject.net.flow.criteria.Criteria.LambdaCriterion; | 39 | import org.onosproject.net.flow.criteria.Criteria.LambdaCriterion; |
40 | +import org.onosproject.net.flow.criteria.Criteria.MetadataCriterion; | ||
38 | import org.onosproject.net.flow.criteria.Criteria.PortCriterion; | 41 | import org.onosproject.net.flow.criteria.Criteria.PortCriterion; |
39 | import org.onosproject.net.flow.criteria.Criteria.SctpPortCriterion; | 42 | import org.onosproject.net.flow.criteria.Criteria.SctpPortCriterion; |
40 | import org.onosproject.net.flow.criteria.Criteria.TcpPortCriterion; | 43 | import org.onosproject.net.flow.criteria.Criteria.TcpPortCriterion; |
... | @@ -55,9 +58,12 @@ import org.projectfloodlight.openflow.types.ICMPv4Type; | ... | @@ -55,9 +58,12 @@ import org.projectfloodlight.openflow.types.ICMPv4Type; |
55 | import org.projectfloodlight.openflow.types.IPv4Address; | 58 | import org.projectfloodlight.openflow.types.IPv4Address; |
56 | import org.projectfloodlight.openflow.types.IPv6Address; | 59 | import org.projectfloodlight.openflow.types.IPv6Address; |
57 | import org.projectfloodlight.openflow.types.IPv6FlowLabel; | 60 | import org.projectfloodlight.openflow.types.IPv6FlowLabel; |
61 | +import org.projectfloodlight.openflow.types.IpDscp; | ||
62 | +import org.projectfloodlight.openflow.types.IpEcn; | ||
58 | import org.projectfloodlight.openflow.types.IpProtocol; | 63 | import org.projectfloodlight.openflow.types.IpProtocol; |
59 | import org.projectfloodlight.openflow.types.MacAddress; | 64 | import org.projectfloodlight.openflow.types.MacAddress; |
60 | import org.projectfloodlight.openflow.types.Masked; | 65 | import org.projectfloodlight.openflow.types.Masked; |
66 | +import org.projectfloodlight.openflow.types.OFMetadata; | ||
61 | import org.projectfloodlight.openflow.types.OFPort; | 67 | import org.projectfloodlight.openflow.types.OFPort; |
62 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; | 68 | import org.projectfloodlight.openflow.types.OFVlanVidMatch; |
63 | import org.projectfloodlight.openflow.types.TransportPort; | 69 | import org.projectfloodlight.openflow.types.TransportPort; |
... | @@ -161,8 +167,19 @@ public abstract class FlowModBuilder { | ... | @@ -161,8 +167,19 @@ public abstract class FlowModBuilder { |
161 | for (Criterion c : selector.criteria()) { | 167 | for (Criterion c : selector.criteria()) { |
162 | switch (c.type()) { | 168 | switch (c.type()) { |
163 | case IN_PORT: | 169 | case IN_PORT: |
164 | - PortCriterion inport = (PortCriterion) c; | 170 | + PortCriterion inPort = (PortCriterion) c; |
165 | - mBuilder.setExact(MatchField.IN_PORT, OFPort.of((int) inport.port().toLong())); | 171 | + mBuilder.setExact(MatchField.IN_PORT, |
172 | + OFPort.of((int) inPort.port().toLong())); | ||
173 | + break; | ||
174 | + case IN_PHY_PORT: | ||
175 | + PortCriterion inPhyPort = (PortCriterion) c; | ||
176 | + mBuilder.setExact(MatchField.IN_PORT, | ||
177 | + OFPort.of((int) inPhyPort.port().toLong())); | ||
178 | + break; | ||
179 | + case METADATA: | ||
180 | + MetadataCriterion metadata = (MetadataCriterion) c; | ||
181 | + mBuilder.setExact(MatchField.METADATA, | ||
182 | + OFMetadata.ofRaw(metadata.metadata())); | ||
166 | break; | 183 | break; |
167 | case ETH_DST: | 184 | case ETH_DST: |
168 | ethCriterion = (EthCriterion) c; | 185 | ethCriterion = (EthCriterion) c; |
... | @@ -193,6 +210,16 @@ public abstract class FlowModBuilder { | ... | @@ -193,6 +210,16 @@ public abstract class FlowModBuilder { |
193 | VlanPcpCriterion vpcp = (VlanPcpCriterion) c; | 210 | VlanPcpCriterion vpcp = (VlanPcpCriterion) c; |
194 | mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority())); | 211 | mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority())); |
195 | break; | 212 | break; |
213 | + case IP_DSCP: | ||
214 | + IPDscpCriterion ipDscpCriterion = (IPDscpCriterion) c; | ||
215 | + mBuilder.setExact(MatchField.IP_DSCP, | ||
216 | + IpDscp.of(ipDscpCriterion.ipDscp())); | ||
217 | + break; | ||
218 | + case IP_ECN: | ||
219 | + IPEcnCriterion ipEcnCriterion = (IPEcnCriterion) c; | ||
220 | + mBuilder.setExact(MatchField.IP_ECN, | ||
221 | + IpEcn.of(ipEcnCriterion.ipEcn())); | ||
222 | + break; | ||
196 | case IP_PROTO: | 223 | case IP_PROTO: |
197 | IPProtocolCriterion p = (IPProtocolCriterion) c; | 224 | IPProtocolCriterion p = (IPProtocolCriterion) c; |
198 | mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol())); | 225 | mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol())); |
... | @@ -353,11 +380,7 @@ public abstract class FlowModBuilder { | ... | @@ -353,11 +380,7 @@ public abstract class FlowModBuilder { |
353 | case ARP_SPA: | 380 | case ARP_SPA: |
354 | case ARP_THA: | 381 | case ARP_THA: |
355 | case ARP_TPA: | 382 | case ARP_TPA: |
356 | - case IN_PHY_PORT: | ||
357 | case IPV6_EXTHDR: | 383 | case IPV6_EXTHDR: |
358 | - case IP_DSCP: | ||
359 | - case IP_ECN: | ||
360 | - case METADATA: | ||
361 | case MPLS_BOS: | 384 | case MPLS_BOS: |
362 | case MPLS_TC: | 385 | case MPLS_TC: |
363 | case PBB_ISID: | 386 | case PBB_ISID: | ... | ... |
... | @@ -43,10 +43,17 @@ public final class CriterionCodec extends JsonCodec<Criterion> { | ... | @@ -43,10 +43,17 @@ public final class CriterionCodec extends JsonCodec<Criterion> { |
43 | switch (criterion.type()) { | 43 | switch (criterion.type()) { |
44 | 44 | ||
45 | case IN_PORT: | 45 | case IN_PORT: |
46 | + case IN_PHY_PORT: | ||
46 | final Criteria.PortCriterion portCriterion = (Criteria.PortCriterion) criterion; | 47 | final Criteria.PortCriterion portCriterion = (Criteria.PortCriterion) criterion; |
47 | result.put("port", portCriterion.port().toLong()); | 48 | result.put("port", portCriterion.port().toLong()); |
48 | break; | 49 | break; |
49 | 50 | ||
51 | + case METADATA: | ||
52 | + final Criteria.MetadataCriterion metadataCriterion = | ||
53 | + (Criteria.MetadataCriterion) criterion; | ||
54 | + result.put("metadata", metadataCriterion.metadata()); | ||
55 | + break; | ||
56 | + | ||
50 | case ETH_DST: | 57 | case ETH_DST: |
51 | case ETH_SRC: | 58 | case ETH_SRC: |
52 | final Criteria.EthCriterion ethCriterion = (Criteria.EthCriterion) criterion; | 59 | final Criteria.EthCriterion ethCriterion = (Criteria.EthCriterion) criterion; |
... | @@ -71,6 +78,18 @@ public final class CriterionCodec extends JsonCodec<Criterion> { | ... | @@ -71,6 +78,18 @@ public final class CriterionCodec extends JsonCodec<Criterion> { |
71 | result.put("priority", vlanPcpCriterion.priority()); | 78 | result.put("priority", vlanPcpCriterion.priority()); |
72 | break; | 79 | break; |
73 | 80 | ||
81 | + case IP_DSCP: | ||
82 | + final Criteria.IPDscpCriterion ipDscpCriterion = | ||
83 | + (Criteria.IPDscpCriterion) criterion; | ||
84 | + result.put("ipDscp", ipDscpCriterion.ipDscp()); | ||
85 | + break; | ||
86 | + | ||
87 | + case IP_ECN: | ||
88 | + final Criteria.IPEcnCriterion ipEcnCriterion = | ||
89 | + (Criteria.IPEcnCriterion) criterion; | ||
90 | + result.put("ipEcn", ipEcnCriterion.ipEcn()); | ||
91 | + break; | ||
92 | + | ||
74 | case IP_PROTO: | 93 | case IP_PROTO: |
75 | final Criteria.IPProtocolCriterion iPProtocolCriterion = | 94 | final Criteria.IPProtocolCriterion iPProtocolCriterion = |
76 | (Criteria.IPProtocolCriterion) criterion; | 95 | (Criteria.IPProtocolCriterion) criterion; | ... | ... |
... | @@ -35,7 +35,8 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -35,7 +35,8 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
35 | 35 | ||
36 | // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES | 36 | // CHECKSTYLE IGNORE MethodLength FOR NEXT 300 LINES |
37 | @Override | 37 | @Override |
38 | - public boolean matchesSafely(JsonNode jsonCriterion, Description description) { | 38 | + public boolean matchesSafely(JsonNode jsonCriterion, |
39 | + Description description) { | ||
39 | final String type = criterion.type().name(); | 40 | final String type = criterion.type().name(); |
40 | final String jsonType = jsonCriterion.get("type").asText(); | 41 | final String jsonType = jsonCriterion.get("type").asText(); |
41 | if (!type.equals(jsonType)) { | 42 | if (!type.equals(jsonType)) { |
... | @@ -46,7 +47,9 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -46,7 +47,9 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
46 | switch (criterion.type()) { | 47 | switch (criterion.type()) { |
47 | 48 | ||
48 | case IN_PORT: | 49 | case IN_PORT: |
49 | - final Criteria.PortCriterion portCriterion = (Criteria.PortCriterion) criterion; | 50 | + case IN_PHY_PORT: |
51 | + final Criteria.PortCriterion portCriterion = | ||
52 | + (Criteria.PortCriterion) criterion; | ||
50 | final long port = portCriterion.port().toLong(); | 53 | final long port = portCriterion.port().toLong(); |
51 | final long jsonPort = jsonCriterion.get("port").asLong(); | 54 | final long jsonPort = jsonCriterion.get("port").asLong(); |
52 | if (port != jsonPort) { | 55 | if (port != jsonPort) { |
... | @@ -55,9 +58,21 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -55,9 +58,21 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
55 | } | 58 | } |
56 | break; | 59 | break; |
57 | 60 | ||
61 | + case METADATA: | ||
62 | + final Criteria.MetadataCriterion metadataCriterion = | ||
63 | + (Criteria.MetadataCriterion) criterion; | ||
64 | + final long metadata = metadataCriterion.metadata(); | ||
65 | + final long jsonMetadata = jsonCriterion.get("metadata").asLong(); | ||
66 | + if (metadata != jsonMetadata) { | ||
67 | + description.appendText("metadata was " + Long.toString(jsonMetadata)); | ||
68 | + return false; | ||
69 | + } | ||
70 | + break; | ||
71 | + | ||
58 | case ETH_DST: | 72 | case ETH_DST: |
59 | case ETH_SRC: | 73 | case ETH_SRC: |
60 | - final Criteria.EthCriterion ethCriterion = (Criteria.EthCriterion) criterion; | 74 | + final Criteria.EthCriterion ethCriterion = |
75 | + (Criteria.EthCriterion) criterion; | ||
61 | final String mac = ethCriterion.mac().toString(); | 76 | final String mac = ethCriterion.mac().toString(); |
62 | final String jsonMac = jsonCriterion.get("mac").textValue(); | 77 | final String jsonMac = jsonCriterion.get("mac").textValue(); |
63 | if (!mac.equals(jsonMac)) { | 78 | if (!mac.equals(jsonMac)) { |
... | @@ -99,6 +114,28 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -99,6 +114,28 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
99 | } | 114 | } |
100 | break; | 115 | break; |
101 | 116 | ||
117 | + case IP_DSCP: | ||
118 | + final Criteria.IPDscpCriterion ipDscpCriterion = | ||
119 | + (Criteria.IPDscpCriterion) criterion; | ||
120 | + final byte ipDscp = ipDscpCriterion.ipDscp(); | ||
121 | + final byte jsonIpDscp = (byte) jsonCriterion.get("ipDscp").shortValue(); | ||
122 | + if (ipDscp != jsonIpDscp) { | ||
123 | + description.appendText("IP DSCP was " + Byte.toString(jsonIpDscp)); | ||
124 | + return false; | ||
125 | + } | ||
126 | + break; | ||
127 | + | ||
128 | + case IP_ECN: | ||
129 | + final Criteria.IPEcnCriterion ipEcnCriterion = | ||
130 | + (Criteria.IPEcnCriterion) criterion; | ||
131 | + final byte ipEcn = ipEcnCriterion.ipEcn(); | ||
132 | + final byte jsonIpEcn = (byte) jsonCriterion.get("ipEcn").shortValue(); | ||
133 | + if (ipEcn != jsonIpEcn) { | ||
134 | + description.appendText("IP ECN was " + Byte.toString(jsonIpEcn)); | ||
135 | + return false; | ||
136 | + } | ||
137 | + break; | ||
138 | + | ||
102 | case IP_PROTO: | 139 | case IP_PROTO: |
103 | final Criteria.IPProtocolCriterion iPProtocolCriterion = | 140 | final Criteria.IPProtocolCriterion iPProtocolCriterion = |
104 | (Criteria.IPProtocolCriterion) criterion; | 141 | (Criteria.IPProtocolCriterion) criterion; |
... | @@ -114,7 +151,8 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -114,7 +151,8 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
114 | case IPV4_DST: | 151 | case IPV4_DST: |
115 | case IPV6_SRC: | 152 | case IPV6_SRC: |
116 | case IPV6_DST: | 153 | case IPV6_DST: |
117 | - final Criteria.IPCriterion ipCriterion = (Criteria.IPCriterion) criterion; | 154 | + final Criteria.IPCriterion ipCriterion = |
155 | + (Criteria.IPCriterion) criterion; | ||
118 | final String ip = ipCriterion.ip().toString(); | 156 | final String ip = ipCriterion.ip().toString(); |
119 | final String jsonIp = jsonCriterion.get("ip").textValue(); | 157 | final String jsonIp = jsonCriterion.get("ip").textValue(); |
120 | if (!ip.equals(jsonIp)) { | 158 | if (!ip.equals(jsonIp)) { |
... | @@ -217,7 +255,7 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -217,7 +255,7 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
217 | case IPV6_ND_TARGET: | 255 | case IPV6_ND_TARGET: |
218 | final Criteria.IPv6NDTargetAddressCriterion | 256 | final Criteria.IPv6NDTargetAddressCriterion |
219 | ipv6NDTargetAddressCriterion = | 257 | ipv6NDTargetAddressCriterion = |
220 | - (Criteria.IPv6NDTargetAddressCriterion) criterion; | 258 | + (Criteria.IPv6NDTargetAddressCriterion) criterion; |
221 | final String targetAddress = | 259 | final String targetAddress = |
222 | ipv6NDTargetAddressCriterion.targetAddress().toString(); | 260 | ipv6NDTargetAddressCriterion.targetAddress().toString(); |
223 | final String jsonTargetAddress = | 261 | final String jsonTargetAddress = |
... | @@ -233,7 +271,7 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo | ... | @@ -233,7 +271,7 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo |
233 | case IPV6_ND_TLL: | 271 | case IPV6_ND_TLL: |
234 | final Criteria.IPv6NDLinkLayerAddressCriterion | 272 | final Criteria.IPv6NDLinkLayerAddressCriterion |
235 | ipv6NDLinkLayerAddressCriterion = | 273 | ipv6NDLinkLayerAddressCriterion = |
236 | - (Criteria.IPv6NDLinkLayerAddressCriterion) criterion; | 274 | + (Criteria.IPv6NDLinkLayerAddressCriterion) criterion; |
237 | final String llAddress = | 275 | final String llAddress = |
238 | ipv6NDLinkLayerAddressCriterion.mac().toString(); | 276 | ipv6NDLinkLayerAddressCriterion.mac().toString(); |
239 | final String jsonLlAddress = | 277 | final String jsonLlAddress = | ... | ... |
-
Please register or login to post a comment