Pavlin Radoslavov

Fix toward ONOS-960 - Signed/unsigned value mismatch for OpenFlow-related

match/action conditions

Fixed the signed/unsigned issue for the match conditions

Also:
  * Reordered some of the code in CriterionCodec.java so the order
    of handling various Criterion types follows the order as defined in
    Criterion.java
    - In the process, removed a duplicated entry for Type.MPLS_LABE
    - Fixed an issue with TCP/UDP/SCTP ports being accessed as 8-bit integers
      instead of 16-bit integers

  * Updated some of the unit tests in CriterionCodecTest.java to use
    larger integer values that could expose better potential bugs in
    the tested code.

Change-Id: I531d13bd258ebc559ce6be716863c01613427a98
...@@ -63,8 +63,8 @@ public class CriteriaTest { ...@@ -63,8 +63,8 @@ public class CriteriaTest {
63 Criterion sameAsMatchEth1 = Criteria.matchEthSrc(mac1); 63 Criterion sameAsMatchEth1 = Criteria.matchEthSrc(mac1);
64 Criterion matchEth2 = Criteria.matchEthDst(mac2); 64 Criterion matchEth2 = Criteria.matchEthDst(mac2);
65 65
66 - short ethType1 = 1; 66 + int ethType1 = 1;
67 - short ethType2 = 2; 67 + int ethType2 = 2;
68 Criterion matchEthType1 = Criteria.matchEthType(ethType1); 68 Criterion matchEthType1 = Criteria.matchEthType(ethType1);
69 Criterion sameAsMatchEthType1 = Criteria.matchEthType(ethType1); 69 Criterion sameAsMatchEthType1 = Criteria.matchEthType(ethType1);
70 Criterion matchEthType2 = Criteria.matchEthType(ethType2); 70 Criterion matchEthType2 = Criteria.matchEthType(ethType2);
...@@ -95,8 +95,8 @@ public class CriteriaTest { ...@@ -95,8 +95,8 @@ public class CriteriaTest {
95 Criterion sameAsMatchIpEcn1 = Criteria.matchIPEcn(ipEcn1); 95 Criterion sameAsMatchIpEcn1 = Criteria.matchIPEcn(ipEcn1);
96 Criterion matchIpEcn2 = Criteria.matchIPEcn(ipEcn2); 96 Criterion matchIpEcn2 = Criteria.matchIPEcn(ipEcn2);
97 97
98 - byte protocol1 = 1; 98 + short protocol1 = 1;
99 - byte protocol2 = 2; 99 + short protocol2 = 2;
100 Criterion matchIpProtocol1 = Criteria.matchIPProtocol(protocol1); 100 Criterion matchIpProtocol1 = Criteria.matchIPProtocol(protocol1);
101 Criterion sameAsMatchIpProtocol1 = Criteria.matchIPProtocol(protocol1); 101 Criterion sameAsMatchIpProtocol1 = Criteria.matchIPProtocol(protocol1);
102 Criterion matchIpProtocol2 = Criteria.matchIPProtocol(protocol2); 102 Criterion matchIpProtocol2 = Criteria.matchIPProtocol(protocol2);
...@@ -116,26 +116,26 @@ public class CriteriaTest { ...@@ -116,26 +116,26 @@ public class CriteriaTest {
116 Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61); 116 Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61);
117 Criterion matchIpv62 = Criteria.matchIPSrc(ipv62); 117 Criterion matchIpv62 = Criteria.matchIPSrc(ipv62);
118 118
119 - Criterion matchTcpPort1 = Criteria.matchTcpSrc((short) 1); 119 + Criterion matchTcpPort1 = Criteria.matchTcpSrc(1);
120 - Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc((short) 1); 120 + Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(1);
121 - Criterion matchTcpPort2 = Criteria.matchTcpDst((short) 2); 121 + Criterion matchTcpPort2 = Criteria.matchTcpDst(2);
122 122
123 - Criterion matchUdpPort1 = Criteria.matchUdpSrc((short) 1); 123 + Criterion matchUdpPort1 = Criteria.matchUdpSrc(1);
124 - Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc((short) 1); 124 + Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(1);
125 - Criterion matchUdpPort2 = Criteria.matchUdpDst((short) 2); 125 + Criterion matchUdpPort2 = Criteria.matchUdpDst(2);
126 126
127 - Criterion matchSctpPort1 = Criteria.matchSctpSrc((short) 1); 127 + Criterion matchSctpPort1 = Criteria.matchSctpSrc(1);
128 - Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc((short) 1); 128 + Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(1);
129 - Criterion matchSctpPort2 = Criteria.matchSctpDst((short) 2); 129 + Criterion matchSctpPort2 = Criteria.matchSctpDst(2);
130 130
131 - byte icmpType1 = 1; 131 + short icmpType1 = 1;
132 - byte icmpType2 = 2; 132 + short icmpType2 = 2;
133 Criterion matchIcmpType1 = Criteria.matchIcmpType(icmpType1); 133 Criterion matchIcmpType1 = Criteria.matchIcmpType(icmpType1);
134 Criterion sameAsMatchIcmpType1 = Criteria.matchIcmpType(icmpType1); 134 Criterion sameAsMatchIcmpType1 = Criteria.matchIcmpType(icmpType1);
135 Criterion matchIcmpType2 = Criteria.matchIcmpType(icmpType2); 135 Criterion matchIcmpType2 = Criteria.matchIcmpType(icmpType2);
136 136
137 - byte icmpCode1 = 1; 137 + short icmpCode1 = 1;
138 - byte icmpCode2 = 2; 138 + short icmpCode2 = 2;
139 Criterion matchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1); 139 Criterion matchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1);
140 Criterion sameAsMatchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1); 140 Criterion sameAsMatchIcmpCode1 = Criteria.matchIcmpCode(icmpCode1);
141 Criterion matchIcmpCode2 = Criteria.matchIcmpCode(icmpCode2); 141 Criterion matchIcmpCode2 = Criteria.matchIcmpCode(icmpCode2);
...@@ -146,14 +146,14 @@ public class CriteriaTest { ...@@ -146,14 +146,14 @@ public class CriteriaTest {
146 Criterion sameAsMatchFlowLabel1 = Criteria.matchIPv6FlowLabel(flowLabel1); 146 Criterion sameAsMatchFlowLabel1 = Criteria.matchIPv6FlowLabel(flowLabel1);
147 Criterion matchFlowLabel2 = Criteria.matchIPv6FlowLabel(flowLabel2); 147 Criterion matchFlowLabel2 = Criteria.matchIPv6FlowLabel(flowLabel2);
148 148
149 - byte icmpv6Type1 = 1; 149 + short icmpv6Type1 = 1;
150 - byte icmpv6Type2 = 2; 150 + short icmpv6Type2 = 2;
151 Criterion matchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1); 151 Criterion matchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1);
152 Criterion sameAsMatchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1); 152 Criterion sameAsMatchIcmpv6Type1 = Criteria.matchIcmpv6Type(icmpv6Type1);
153 Criterion matchIcmpv6Type2 = Criteria.matchIcmpv6Type(icmpv6Type2); 153 Criterion matchIcmpv6Type2 = Criteria.matchIcmpv6Type(icmpv6Type2);
154 154
155 - byte icmpv6Code1 = 1; 155 + short icmpv6Code1 = 1;
156 - byte icmpv6Code2 = 2; 156 + short icmpv6Code2 = 2;
157 Criterion matchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1); 157 Criterion matchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1);
158 Criterion sameAsMatchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1); 158 Criterion sameAsMatchIcmpv6Code1 = Criteria.matchIcmpv6Code(icmpv6Code1);
159 Criterion matchIcmpv6Code2 = Criteria.matchIcmpv6Code(icmpv6Code2); 159 Criterion matchIcmpv6Code2 = Criteria.matchIcmpv6Code(icmpv6Code2);
...@@ -192,14 +192,14 @@ public class CriteriaTest { ...@@ -192,14 +192,14 @@ public class CriteriaTest {
192 Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1); 192 Criterion sameAsMatchMpls1 = Criteria.matchMplsLabel(mpls1);
193 Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2); 193 Criterion matchMpls2 = Criteria.matchMplsLabel(mpls2);
194 194
195 - short lambda1 = 1; 195 + int lambda1 = 1;
196 - short lambda2 = 2; 196 + int lambda2 = 2;
197 Criterion matchLambda1 = Criteria.matchLambda(lambda1); 197 Criterion matchLambda1 = Criteria.matchLambda(lambda1);
198 Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1); 198 Criterion sameAsMatchLambda1 = Criteria.matchLambda(lambda1);
199 Criterion matchLambda2 = Criteria.matchLambda(lambda2); 199 Criterion matchLambda2 = Criteria.matchLambda(lambda2);
200 200
201 - short signalLambda1 = 1; 201 + int signalLambda1 = 1;
202 - short signalLambda2 = 2; 202 + int signalLambda2 = 2;
203 Criterion matchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1); 203 Criterion matchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1);
204 Criterion sameAsMatchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1); 204 Criterion sameAsMatchSignalLambda1 = Criteria.matchOpticalSignalType(signalLambda1);
205 Criterion matchSignalLambda2 = Criteria.matchOpticalSignalType(signalLambda2); 205 Criterion matchSignalLambda2 = Criteria.matchOpticalSignalType(signalLambda2);
...@@ -379,7 +379,7 @@ public class CriteriaTest { ...@@ -379,7 +379,7 @@ public class CriteriaTest {
379 */ 379 */
380 @Test 380 @Test
381 public void testMatchEthTypeMethod() { 381 public void testMatchEthTypeMethod() {
382 - Short ethType = 12; 382 + int ethType = 12;
383 Criterion matchEthType = Criteria.matchEthType(ethType); 383 Criterion matchEthType = Criteria.matchEthType(ethType);
384 Criteria.EthTypeCriterion ethTypeCriterion = 384 Criteria.EthTypeCriterion ethTypeCriterion =
385 checkAndConvert(matchEthType, 385 checkAndConvert(matchEthType,
...@@ -606,12 +606,12 @@ public class CriteriaTest { ...@@ -606,12 +606,12 @@ public class CriteriaTest {
606 */ 606 */
607 @Test 607 @Test
608 public void testMatchTcpSrcMethod() { 608 public void testMatchTcpSrcMethod() {
609 - Criterion matchTcpSrc = Criteria.matchTcpSrc((short) 1); 609 + Criterion matchTcpSrc = Criteria.matchTcpSrc(1);
610 Criteria.TcpPortCriterion tcpPortCriterion = 610 Criteria.TcpPortCriterion tcpPortCriterion =
611 checkAndConvert(matchTcpSrc, 611 checkAndConvert(matchTcpSrc,
612 Criterion.Type.TCP_SRC, 612 Criterion.Type.TCP_SRC,
613 Criteria.TcpPortCriterion.class); 613 Criteria.TcpPortCriterion.class);
614 - assertThat(tcpPortCriterion.tcpPort(), is(equalTo((short) 1))); 614 + assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
615 } 615 }
616 616
617 /** 617 /**
...@@ -619,12 +619,12 @@ public class CriteriaTest { ...@@ -619,12 +619,12 @@ public class CriteriaTest {
619 */ 619 */
620 @Test 620 @Test
621 public void testMatchTcpDstMethod() { 621 public void testMatchTcpDstMethod() {
622 - Criterion matchTcpDst = Criteria.matchTcpDst((short) 1); 622 + Criterion matchTcpDst = Criteria.matchTcpDst(1);
623 Criteria.TcpPortCriterion tcpPortCriterion = 623 Criteria.TcpPortCriterion tcpPortCriterion =
624 checkAndConvert(matchTcpDst, 624 checkAndConvert(matchTcpDst,
625 Criterion.Type.TCP_DST, 625 Criterion.Type.TCP_DST,
626 Criteria.TcpPortCriterion.class); 626 Criteria.TcpPortCriterion.class);
627 - assertThat(tcpPortCriterion.tcpPort(), is(equalTo((short) 1))); 627 + assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1)));
628 } 628 }
629 629
630 /** 630 /**
...@@ -645,12 +645,12 @@ public class CriteriaTest { ...@@ -645,12 +645,12 @@ public class CriteriaTest {
645 */ 645 */
646 @Test 646 @Test
647 public void testMatchUdpSrcMethod() { 647 public void testMatchUdpSrcMethod() {
648 - Criterion matchUdpSrc = Criteria.matchUdpSrc((short) 1); 648 + Criterion matchUdpSrc = Criteria.matchUdpSrc(1);
649 Criteria.UdpPortCriterion udpPortCriterion = 649 Criteria.UdpPortCriterion udpPortCriterion =
650 checkAndConvert(matchUdpSrc, 650 checkAndConvert(matchUdpSrc,
651 Criterion.Type.UDP_SRC, 651 Criterion.Type.UDP_SRC,
652 Criteria.UdpPortCriterion.class); 652 Criteria.UdpPortCriterion.class);
653 - assertThat(udpPortCriterion.udpPort(), is(equalTo((short) 1))); 653 + assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
654 } 654 }
655 655
656 /** 656 /**
...@@ -658,12 +658,12 @@ public class CriteriaTest { ...@@ -658,12 +658,12 @@ public class CriteriaTest {
658 */ 658 */
659 @Test 659 @Test
660 public void testMatchUdpDstMethod() { 660 public void testMatchUdpDstMethod() {
661 - Criterion matchUdpDst = Criteria.matchUdpDst((short) 1); 661 + Criterion matchUdpDst = Criteria.matchUdpDst(1);
662 Criteria.UdpPortCriterion udpPortCriterion = 662 Criteria.UdpPortCriterion udpPortCriterion =
663 checkAndConvert(matchUdpDst, 663 checkAndConvert(matchUdpDst,
664 Criterion.Type.UDP_DST, 664 Criterion.Type.UDP_DST,
665 Criteria.UdpPortCriterion.class); 665 Criteria.UdpPortCriterion.class);
666 - assertThat(udpPortCriterion.udpPort(), is(equalTo((short) 1))); 666 + assertThat(udpPortCriterion.udpPort(), is(equalTo(1)));
667 } 667 }
668 668
669 /** 669 /**
...@@ -684,12 +684,12 @@ public class CriteriaTest { ...@@ -684,12 +684,12 @@ public class CriteriaTest {
684 */ 684 */
685 @Test 685 @Test
686 public void testMatchSctpSrcMethod() { 686 public void testMatchSctpSrcMethod() {
687 - Criterion matchSctpSrc = Criteria.matchSctpSrc((short) 1); 687 + Criterion matchSctpSrc = Criteria.matchSctpSrc(1);
688 Criteria.SctpPortCriterion sctpPortCriterion = 688 Criteria.SctpPortCriterion sctpPortCriterion =
689 checkAndConvert(matchSctpSrc, 689 checkAndConvert(matchSctpSrc,
690 Criterion.Type.SCTP_SRC, 690 Criterion.Type.SCTP_SRC,
691 Criteria.SctpPortCriterion.class); 691 Criteria.SctpPortCriterion.class);
692 - assertThat(sctpPortCriterion.sctpPort(), is(equalTo((short) 1))); 692 + assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
693 } 693 }
694 694
695 /** 695 /**
...@@ -697,12 +697,12 @@ public class CriteriaTest { ...@@ -697,12 +697,12 @@ public class CriteriaTest {
697 */ 697 */
698 @Test 698 @Test
699 public void testMatchSctpDstMethod() { 699 public void testMatchSctpDstMethod() {
700 - Criterion matchSctpDst = Criteria.matchSctpDst((short) 1); 700 + Criterion matchSctpDst = Criteria.matchSctpDst(1);
701 Criteria.SctpPortCriterion sctpPortCriterion = 701 Criteria.SctpPortCriterion sctpPortCriterion =
702 checkAndConvert(matchSctpDst, 702 checkAndConvert(matchSctpDst,
703 Criterion.Type.SCTP_DST, 703 Criterion.Type.SCTP_DST,
704 Criteria.SctpPortCriterion.class); 704 Criteria.SctpPortCriterion.class);
705 - assertThat(sctpPortCriterion.sctpPort(), is(equalTo((short) 1))); 705 + assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1)));
706 } 706 }
707 707
708 /** 708 /**
...@@ -723,7 +723,7 @@ public class CriteriaTest { ...@@ -723,7 +723,7 @@ public class CriteriaTest {
723 */ 723 */
724 @Test 724 @Test
725 public void testMatchIcmpTypeMethod() { 725 public void testMatchIcmpTypeMethod() {
726 - Byte icmpType = 12; 726 + short icmpType = 12;
727 Criterion matchIcmpType = Criteria.matchIcmpType(icmpType); 727 Criterion matchIcmpType = Criteria.matchIcmpType(icmpType);
728 Criteria.IcmpTypeCriterion icmpTypeCriterion = 728 Criteria.IcmpTypeCriterion icmpTypeCriterion =
729 checkAndConvert(matchIcmpType, 729 checkAndConvert(matchIcmpType,
...@@ -750,7 +750,7 @@ public class CriteriaTest { ...@@ -750,7 +750,7 @@ public class CriteriaTest {
750 */ 750 */
751 @Test 751 @Test
752 public void testMatchIcmpCodeMethod() { 752 public void testMatchIcmpCodeMethod() {
753 - Byte icmpCode = 12; 753 + short icmpCode = 12;
754 Criterion matchIcmpCode = Criteria.matchIcmpCode(icmpCode); 754 Criterion matchIcmpCode = Criteria.matchIcmpCode(icmpCode);
755 Criteria.IcmpCodeCriterion icmpCodeCriterion = 755 Criteria.IcmpCodeCriterion icmpCodeCriterion =
756 checkAndConvert(matchIcmpCode, 756 checkAndConvert(matchIcmpCode,
...@@ -777,7 +777,7 @@ public class CriteriaTest { ...@@ -777,7 +777,7 @@ public class CriteriaTest {
777 */ 777 */
778 @Test 778 @Test
779 public void testMatchIPv6FlowLabelMethod() { 779 public void testMatchIPv6FlowLabelMethod() {
780 - Integer flowLabel = 12; 780 + int flowLabel = 12;
781 Criterion matchFlowLabel = Criteria.matchIPv6FlowLabel(flowLabel); 781 Criterion matchFlowLabel = Criteria.matchIPv6FlowLabel(flowLabel);
782 Criteria.IPv6FlowLabelCriterion flowLabelCriterion = 782 Criteria.IPv6FlowLabelCriterion flowLabelCriterion =
783 checkAndConvert(matchFlowLabel, 783 checkAndConvert(matchFlowLabel,
...@@ -804,7 +804,7 @@ public class CriteriaTest { ...@@ -804,7 +804,7 @@ public class CriteriaTest {
804 */ 804 */
805 @Test 805 @Test
806 public void testMatchIcmpv6TypeMethod() { 806 public void testMatchIcmpv6TypeMethod() {
807 - Byte icmpv6Type = 12; 807 + short icmpv6Type = 12;
808 Criterion matchIcmpv6Type = Criteria.matchIcmpv6Type(icmpv6Type); 808 Criterion matchIcmpv6Type = Criteria.matchIcmpv6Type(icmpv6Type);
809 Criteria.Icmpv6TypeCriterion icmpv6TypeCriterion = 809 Criteria.Icmpv6TypeCriterion icmpv6TypeCriterion =
810 checkAndConvert(matchIcmpv6Type, 810 checkAndConvert(matchIcmpv6Type,
...@@ -831,7 +831,7 @@ public class CriteriaTest { ...@@ -831,7 +831,7 @@ public class CriteriaTest {
831 */ 831 */
832 @Test 832 @Test
833 public void testMatchIcmpv6CodeMethod() { 833 public void testMatchIcmpv6CodeMethod() {
834 - Byte icmpv6Code = 12; 834 + short icmpv6Code = 12;
835 Criterion matchIcmpv6Code = Criteria.matchIcmpv6Code(icmpv6Code); 835 Criterion matchIcmpv6Code = Criteria.matchIcmpv6Code(icmpv6Code);
836 Criteria.Icmpv6CodeCriterion icmpv6CodeCriterion = 836 Criteria.Icmpv6CodeCriterion icmpv6CodeCriterion =
837 checkAndConvert(matchIcmpv6Code, 837 checkAndConvert(matchIcmpv6Code,
......
...@@ -333,12 +333,12 @@ public abstract class FlowModBuilder { ...@@ -333,12 +333,12 @@ public abstract class FlowModBuilder {
333 case ICMPV6_TYPE: 333 case ICMPV6_TYPE:
334 Icmpv6TypeCriterion icmpv6Type = (Icmpv6TypeCriterion) c; 334 Icmpv6TypeCriterion icmpv6Type = (Icmpv6TypeCriterion) c;
335 mBuilder.setExact(MatchField.ICMPV6_TYPE, 335 mBuilder.setExact(MatchField.ICMPV6_TYPE,
336 - U8.of(icmpv6Type.icmpv6Type().byteValue())); 336 + U8.of(icmpv6Type.icmpv6Type()));
337 break; 337 break;
338 case ICMPV6_CODE: 338 case ICMPV6_CODE:
339 Icmpv6CodeCriterion icmpv6Code = (Icmpv6CodeCriterion) c; 339 Icmpv6CodeCriterion icmpv6Code = (Icmpv6CodeCriterion) c;
340 mBuilder.setExact(MatchField.ICMPV6_CODE, 340 mBuilder.setExact(MatchField.ICMPV6_CODE,
341 - U8.of(icmpv6Code.icmpv6Code().byteValue())); 341 + U8.of(icmpv6Code.icmpv6Code()));
342 break; 342 break;
343 case IPV6_ND_TARGET: 343 case IPV6_ND_TARGET:
344 IPv6NDTargetAddressCriterion targetAddressCriterion = 344 IPv6NDTargetAddressCriterion targetAddressCriterion =
...@@ -361,19 +361,19 @@ public abstract class FlowModBuilder { ...@@ -361,19 +361,19 @@ public abstract class FlowModBuilder {
361 break; 361 break;
362 case MPLS_LABEL: 362 case MPLS_LABEL:
363 Criteria.MplsCriterion mp = (Criteria.MplsCriterion) c; 363 Criteria.MplsCriterion mp = (Criteria.MplsCriterion) c;
364 - mBuilder.setExact(MatchField.MPLS_LABEL, 364 + mBuilder.setExact(MatchField.MPLS_LABEL, U32.of(mp.label()));
365 - U32.of(mp.label().intValue()));
366 break; 365 break;
367 case OCH_SIGID: 366 case OCH_SIGID:
368 LambdaCriterion lc = (LambdaCriterion) c; 367 LambdaCriterion lc = (LambdaCriterion) c;
369 mBuilder.setExact(MatchField.OCH_SIGID, 368 mBuilder.setExact(MatchField.OCH_SIGID,
370 - new CircuitSignalID((byte) 1, (byte) 2, lc.lambda(), (short) 1)); 369 + new CircuitSignalID((byte) 1, (byte) 2,
370 + (short) lc.lambda(), (short) 1));
371 break; 371 break;
372 case OCH_SIGTYPE: 372 case OCH_SIGTYPE:
373 Criteria.OpticalSignalTypeCriterion sc = 373 Criteria.OpticalSignalTypeCriterion sc =
374 (Criteria.OpticalSignalTypeCriterion) c; 374 (Criteria.OpticalSignalTypeCriterion) c;
375 mBuilder.setExact(MatchField.OCH_SIGTYPE, 375 mBuilder.setExact(MatchField.OCH_SIGTYPE,
376 - U8.of(sc.signalType())); 376 + U8.of((short) sc.signalType()));
377 break; 377 break;
378 case ARP_OP: 378 case ARP_OP:
379 case ARP_SHA: 379 case ARP_SHA:
......
...@@ -43,19 +43,17 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -43,19 +43,17 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
43 43
44 formatMap.put(Criterion.Type.IN_PORT, new FormatInPort()); 44 formatMap.put(Criterion.Type.IN_PORT, new FormatInPort());
45 formatMap.put(Criterion.Type.IN_PHY_PORT, new FormatInPort()); 45 formatMap.put(Criterion.Type.IN_PHY_PORT, new FormatInPort());
46 + formatMap.put(Criterion.Type.METADATA, new FormatMetadata());
46 formatMap.put(Criterion.Type.ETH_DST, new FormatEth()); 47 formatMap.put(Criterion.Type.ETH_DST, new FormatEth());
47 formatMap.put(Criterion.Type.ETH_SRC, new FormatEth()); 48 formatMap.put(Criterion.Type.ETH_SRC, new FormatEth());
48 - formatMap.put(Criterion.Type.IP_PROTO, new FormatIpProto());
49 formatMap.put(Criterion.Type.ETH_TYPE, new FormatEthType()); 49 formatMap.put(Criterion.Type.ETH_TYPE, new FormatEthType());
50 - formatMap.put(Criterion.Type.METADATA, new FormatMetadata());
51 formatMap.put(Criterion.Type.VLAN_VID, new FormatVlanVid()); 50 formatMap.put(Criterion.Type.VLAN_VID, new FormatVlanVid());
52 formatMap.put(Criterion.Type.VLAN_PCP, new FormatVlanPcp()); 51 formatMap.put(Criterion.Type.VLAN_PCP, new FormatVlanPcp());
53 formatMap.put(Criterion.Type.IP_DSCP, new FormatIpDscp()); 52 formatMap.put(Criterion.Type.IP_DSCP, new FormatIpDscp());
54 formatMap.put(Criterion.Type.IP_ECN, new FormatIpEcn()); 53 formatMap.put(Criterion.Type.IP_ECN, new FormatIpEcn());
54 + formatMap.put(Criterion.Type.IP_PROTO, new FormatIpProto());
55 formatMap.put(Criterion.Type.IPV4_SRC, new FormatIp()); 55 formatMap.put(Criterion.Type.IPV4_SRC, new FormatIp());
56 formatMap.put(Criterion.Type.IPV4_DST, new FormatIp()); 56 formatMap.put(Criterion.Type.IPV4_DST, new FormatIp());
57 - formatMap.put(Criterion.Type.IPV6_SRC, new FormatIp());
58 - formatMap.put(Criterion.Type.IPV6_DST, new FormatIp());
59 formatMap.put(Criterion.Type.TCP_SRC, new FormatTcp()); 57 formatMap.put(Criterion.Type.TCP_SRC, new FormatTcp());
60 formatMap.put(Criterion.Type.TCP_DST, new FormatTcp()); 58 formatMap.put(Criterion.Type.TCP_DST, new FormatTcp());
61 formatMap.put(Criterion.Type.UDP_SRC, new FormatUdp()); 59 formatMap.put(Criterion.Type.UDP_SRC, new FormatUdp());
...@@ -64,6 +62,8 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -64,6 +62,8 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
64 formatMap.put(Criterion.Type.SCTP_DST, new FormatSctp()); 62 formatMap.put(Criterion.Type.SCTP_DST, new FormatSctp());
65 formatMap.put(Criterion.Type.ICMPV4_TYPE, new FormatIcmpV4Type()); 63 formatMap.put(Criterion.Type.ICMPV4_TYPE, new FormatIcmpV4Type());
66 formatMap.put(Criterion.Type.ICMPV4_CODE, new FormatIcmpV4Code()); 64 formatMap.put(Criterion.Type.ICMPV4_CODE, new FormatIcmpV4Code());
65 + formatMap.put(Criterion.Type.IPV6_SRC, new FormatIp());
66 + formatMap.put(Criterion.Type.IPV6_DST, new FormatIp());
67 formatMap.put(Criterion.Type.IPV6_FLABEL, new FormatIpV6FLabel()); 67 formatMap.put(Criterion.Type.IPV6_FLABEL, new FormatIpV6FLabel());
68 formatMap.put(Criterion.Type.ICMPV6_TYPE, new FormatIcmpV6Type()); 68 formatMap.put(Criterion.Type.ICMPV6_TYPE, new FormatIcmpV6Type());
69 formatMap.put(Criterion.Type.ICMPV6_CODE, new FormatIcmpV6Code()); 69 formatMap.put(Criterion.Type.ICMPV6_CODE, new FormatIcmpV6Code());
...@@ -73,21 +73,20 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -73,21 +73,20 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
73 formatMap.put(Criterion.Type.MPLS_LABEL, new FormatMplsLabel()); 73 formatMap.put(Criterion.Type.MPLS_LABEL, new FormatMplsLabel());
74 formatMap.put(Criterion.Type.OCH_SIGID, new FormatOchSigId()); 74 formatMap.put(Criterion.Type.OCH_SIGID, new FormatOchSigId());
75 formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType()); 75 formatMap.put(Criterion.Type.OCH_SIGTYPE, new FormatOchSigType());
76 - formatMap.put(Criterion.Type.MPLS_LABEL, new FormatMplsLabel());
77 76
78 // Currently unimplemented 77 // Currently unimplemented
79 formatMap.put(Criterion.Type.ARP_OP, new FormatUnknown()); 78 formatMap.put(Criterion.Type.ARP_OP, new FormatUnknown());
80 - formatMap.put(Criterion.Type.ARP_SHA, new FormatUnknown());
81 formatMap.put(Criterion.Type.ARP_SPA, new FormatUnknown()); 79 formatMap.put(Criterion.Type.ARP_SPA, new FormatUnknown());
82 - formatMap.put(Criterion.Type.ARP_THA, new FormatUnknown());
83 formatMap.put(Criterion.Type.ARP_TPA, new FormatUnknown()); 80 formatMap.put(Criterion.Type.ARP_TPA, new FormatUnknown());
81 + formatMap.put(Criterion.Type.ARP_SHA, new FormatUnknown());
82 + formatMap.put(Criterion.Type.ARP_THA, new FormatUnknown());
84 formatMap.put(Criterion.Type.MPLS_TC, new FormatUnknown()); 83 formatMap.put(Criterion.Type.MPLS_TC, new FormatUnknown());
85 formatMap.put(Criterion.Type.MPLS_BOS, new FormatUnknown()); 84 formatMap.put(Criterion.Type.MPLS_BOS, new FormatUnknown());
86 formatMap.put(Criterion.Type.PBB_ISID, new FormatUnknown()); 85 formatMap.put(Criterion.Type.PBB_ISID, new FormatUnknown());
87 - formatMap.put(Criterion.Type.PBB_UCA, new FormatUnknown());
88 formatMap.put(Criterion.Type.TUNNEL_ID, new FormatUnknown()); 86 formatMap.put(Criterion.Type.TUNNEL_ID, new FormatUnknown());
89 formatMap.put(Criterion.Type.IPV6_EXTHDR, new FormatUnknown()); 87 formatMap.put(Criterion.Type.IPV6_EXTHDR, new FormatUnknown());
90 formatMap.put(Criterion.Type.UNASSIGNED_40, new FormatUnknown()); 88 formatMap.put(Criterion.Type.UNASSIGNED_40, new FormatUnknown());
89 + formatMap.put(Criterion.Type.PBB_UCA, new FormatUnknown());
91 formatMap.put(Criterion.Type.TCP_FLAGS, new FormatUnknown()); 90 formatMap.put(Criterion.Type.TCP_FLAGS, new FormatUnknown());
92 formatMap.put(Criterion.Type.ACTSET_OUTPUT, new FormatUnknown()); 91 formatMap.put(Criterion.Type.ACTSET_OUTPUT, new FormatUnknown());
93 formatMap.put(Criterion.Type.PACKET_TYPE, new FormatUnknown()); 92 formatMap.put(Criterion.Type.PACKET_TYPE, new FormatUnknown());
...@@ -112,20 +111,20 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -112,20 +111,20 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
112 } 111 }
113 } 112 }
114 113
115 - private static class FormatEth implements CriterionTypeFormatter { 114 + private static class FormatMetadata implements CriterionTypeFormatter {
116 @Override 115 @Override
117 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 116 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
118 - final Criteria.EthCriterion ethCriterion = (Criteria.EthCriterion) criterion; 117 + final Criteria.MetadataCriterion metadataCriterion =
119 - return root.put("mac", ethCriterion.mac().toString()); 118 + (Criteria.MetadataCriterion) criterion;
119 + return root.put("metadata", metadataCriterion.metadata());
120 } 120 }
121 } 121 }
122 122
123 - private static class FormatIpProto implements CriterionTypeFormatter { 123 + private static class FormatEth implements CriterionTypeFormatter {
124 @Override 124 @Override
125 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 125 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
126 - final Criteria.IPProtocolCriterion iPProtocolCriterion = 126 + final Criteria.EthCriterion ethCriterion = (Criteria.EthCriterion) criterion;
127 - (Criteria.IPProtocolCriterion) criterion; 127 + return root.put("mac", ethCriterion.mac().toString());
128 - return root.put("protocol", iPProtocolCriterion.protocol());
129 } 128 }
130 } 129 }
131 130
...@@ -138,15 +137,6 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -138,15 +137,6 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
138 } 137 }
139 } 138 }
140 139
141 - private static class FormatMetadata implements CriterionTypeFormatter {
142 - @Override
143 - public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
144 - final Criteria.MetadataCriterion metadataCriterion =
145 - (Criteria.MetadataCriterion) criterion;
146 - return root.put("metadata", metadataCriterion.metadata());
147 - }
148 - }
149 -
150 private static class FormatVlanVid implements CriterionTypeFormatter { 140 private static class FormatVlanVid implements CriterionTypeFormatter {
151 @Override 141 @Override
152 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 142 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
...@@ -183,6 +173,15 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -183,6 +173,15 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
183 } 173 }
184 } 174 }
185 175
176 + private static class FormatIpProto implements CriterionTypeFormatter {
177 + @Override
178 + public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
179 + final Criteria.IPProtocolCriterion iPProtocolCriterion =
180 + (Criteria.IPProtocolCriterion) criterion;
181 + return root.put("protocol", iPProtocolCriterion.protocol());
182 + }
183 + }
184 +
186 private static class FormatIp implements CriterionTypeFormatter { 185 private static class FormatIp implements CriterionTypeFormatter {
187 @Override 186 @Override
188 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 187 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
...@@ -196,7 +195,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -196,7 +195,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
196 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 195 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
197 final Criteria.TcpPortCriterion tcpPortCriterion = 196 final Criteria.TcpPortCriterion tcpPortCriterion =
198 (Criteria.TcpPortCriterion) criterion; 197 (Criteria.TcpPortCriterion) criterion;
199 - return root.put("tcpPort", tcpPortCriterion.tcpPort().byteValue()); 198 + return root.put("tcpPort", tcpPortCriterion.tcpPort());
200 } 199 }
201 } 200 }
202 201
...@@ -205,7 +204,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -205,7 +204,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
205 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 204 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
206 final Criteria.UdpPortCriterion udpPortCriterion = 205 final Criteria.UdpPortCriterion udpPortCriterion =
207 (Criteria.UdpPortCriterion) criterion; 206 (Criteria.UdpPortCriterion) criterion;
208 - return root.put("udpPort", udpPortCriterion.udpPort().byteValue()); 207 + return root.put("udpPort", udpPortCriterion.udpPort());
209 } 208 }
210 } 209 }
211 210
...@@ -214,8 +213,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> { ...@@ -214,8 +213,7 @@ public final class CriterionCodec extends JsonCodec<Criterion> {
214 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) { 213 public ObjectNode formatCriterion(ObjectNode root, Criterion criterion) {
215 final Criteria.SctpPortCriterion sctpPortCriterion = 214 final Criteria.SctpPortCriterion sctpPortCriterion =
216 (Criteria.SctpPortCriterion) criterion; 215 (Criteria.SctpPortCriterion) criterion;
217 - return root.put("sctpPort", 216 + return root.put("sctpPort", sctpPortCriterion.sctpPort());
218 - sctpPortCriterion.sctpPort().byteValue());
219 } 217 }
220 } 218 }
221 219
......
...@@ -134,10 +134,10 @@ public class CriterionCodecTest { ...@@ -134,10 +134,10 @@ public class CriterionCodecTest {
134 */ 134 */
135 @Test 135 @Test
136 public void matchEthTypeTest() { 136 public void matchEthTypeTest() {
137 - Criterion criterion = Criteria.matchEthType((short) 3); 137 + Criterion criterion = Criteria.matchEthType((short) 0x8844);
138 ObjectNode result = criterionCodec.encode(criterion, context); 138 ObjectNode result = criterionCodec.encode(criterion, context);
139 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 139 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
140 - assertThat(result.get("ethType").asInt(), is(3)); 140 + assertThat(result.get("ethType").asInt(), is(0x8844));
141 } 141 }
142 142
143 /** 143 /**
...@@ -156,10 +156,10 @@ public class CriterionCodecTest { ...@@ -156,10 +156,10 @@ public class CriterionCodecTest {
156 */ 156 */
157 @Test 157 @Test
158 public void matchVlanPcpTest() { 158 public void matchVlanPcpTest() {
159 - Criterion criterion = Criteria.matchVlanPcp((byte) 4); 159 + Criterion criterion = Criteria.matchVlanPcp((byte) 7);
160 ObjectNode result = criterionCodec.encode(criterion, context); 160 ObjectNode result = criterionCodec.encode(criterion, context);
161 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 161 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
162 - assertThat(result.get("priority").asInt(), is(4)); 162 + assertThat(result.get("priority").asInt(), is(7));
163 } 163 }
164 164
165 /** 165 /**
...@@ -167,10 +167,10 @@ public class CriterionCodecTest { ...@@ -167,10 +167,10 @@ public class CriterionCodecTest {
167 */ 167 */
168 @Test 168 @Test
169 public void matchIPDscpTest() { 169 public void matchIPDscpTest() {
170 - Criterion criterion = Criteria.matchIPDscp((byte) 5); 170 + Criterion criterion = Criteria.matchIPDscp((byte) 63);
171 ObjectNode result = criterionCodec.encode(criterion, context); 171 ObjectNode result = criterionCodec.encode(criterion, context);
172 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 172 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
173 - assertThat(result.get("ipDscp").asInt(), is(5)); 173 + assertThat(result.get("ipDscp").asInt(), is(63));
174 } 174 }
175 175
176 /** 176 /**
...@@ -178,10 +178,10 @@ public class CriterionCodecTest { ...@@ -178,10 +178,10 @@ public class CriterionCodecTest {
178 */ 178 */
179 @Test 179 @Test
180 public void matchIPEcnTest() { 180 public void matchIPEcnTest() {
181 - Criterion criterion = Criteria.matchIPEcn((byte) 2); 181 + Criterion criterion = Criteria.matchIPEcn((byte) 7);
182 ObjectNode result = criterionCodec.encode(criterion, context); 182 ObjectNode result = criterionCodec.encode(criterion, context);
183 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 183 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
184 - assertThat(result.get("ipEcn").asInt(), is(2)); 184 + assertThat(result.get("ipEcn").asInt(), is(7));
185 } 185 }
186 186
187 /** 187 /**
...@@ -189,10 +189,10 @@ public class CriterionCodecTest { ...@@ -189,10 +189,10 @@ public class CriterionCodecTest {
189 */ 189 */
190 @Test 190 @Test
191 public void matchIPProtocolTest() { 191 public void matchIPProtocolTest() {
192 - Criterion criterion = Criteria.matchIPProtocol((byte) 7); 192 + Criterion criterion = Criteria.matchIPProtocol((byte) 250);
193 ObjectNode result = criterionCodec.encode(criterion, context); 193 ObjectNode result = criterionCodec.encode(criterion, context);
194 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 194 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
195 - assertThat(result.get("protocol").asInt(), is(7)); 195 + assertThat(result.get("protocol").asInt(), is(250));
196 } 196 }
197 197
198 /** 198 /**
...@@ -222,10 +222,10 @@ public class CriterionCodecTest { ...@@ -222,10 +222,10 @@ public class CriterionCodecTest {
222 */ 222 */
223 @Test 223 @Test
224 public void matchTcpSrcTest() { 224 public void matchTcpSrcTest() {
225 - Criterion criterion = Criteria.matchTcpSrc((short) 22); 225 + Criterion criterion = Criteria.matchTcpSrc((short) 40000);
226 ObjectNode result = criterionCodec.encode(criterion, context); 226 ObjectNode result = criterionCodec.encode(criterion, context);
227 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 227 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
228 - assertThat(result.get("tcpPort").asInt(), is(22)); 228 + assertThat(result.get("tcpPort").asInt(), is(40000));
229 } 229 }
230 230
231 /** 231 /**
...@@ -233,10 +233,10 @@ public class CriterionCodecTest { ...@@ -233,10 +233,10 @@ public class CriterionCodecTest {
233 */ 233 */
234 @Test 234 @Test
235 public void matchTcpDstTest() { 235 public void matchTcpDstTest() {
236 - Criterion criterion = Criteria.matchTcpDst((short) 22); 236 + Criterion criterion = Criteria.matchTcpDst((short) 40000);
237 ObjectNode result = criterionCodec.encode(criterion, context); 237 ObjectNode result = criterionCodec.encode(criterion, context);
238 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 238 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
239 - assertThat(result.get("tcpPort").asInt(), is(22)); 239 + assertThat(result.get("tcpPort").asInt(), is(40000));
240 } 240 }
241 241
242 /** 242 /**
...@@ -244,10 +244,10 @@ public class CriterionCodecTest { ...@@ -244,10 +244,10 @@ public class CriterionCodecTest {
244 */ 244 */
245 @Test 245 @Test
246 public void matchUdpSrcTest() { 246 public void matchUdpSrcTest() {
247 - Criterion criterion = Criteria.matchUdpSrc((short) 22); 247 + Criterion criterion = Criteria.matchUdpSrc((short) 40000);
248 ObjectNode result = criterionCodec.encode(criterion, context); 248 ObjectNode result = criterionCodec.encode(criterion, context);
249 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 249 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
250 - assertThat(result.get("udpPort").asInt(), is(22)); 250 + assertThat(result.get("udpPort").asInt(), is(40000));
251 } 251 }
252 252
253 /** 253 /**
...@@ -255,10 +255,10 @@ public class CriterionCodecTest { ...@@ -255,10 +255,10 @@ public class CriterionCodecTest {
255 */ 255 */
256 @Test 256 @Test
257 public void matchUdpDstTest() { 257 public void matchUdpDstTest() {
258 - Criterion criterion = Criteria.matchUdpDst((short) 22); 258 + Criterion criterion = Criteria.matchUdpDst((short) 40000);
259 ObjectNode result = criterionCodec.encode(criterion, context); 259 ObjectNode result = criterionCodec.encode(criterion, context);
260 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 260 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
261 - assertThat(result.get("udpPort").asInt(), is(22)); 261 + assertThat(result.get("udpPort").asInt(), is(40000));
262 } 262 }
263 263
264 /** 264 /**
...@@ -266,10 +266,10 @@ public class CriterionCodecTest { ...@@ -266,10 +266,10 @@ public class CriterionCodecTest {
266 */ 266 */
267 @Test 267 @Test
268 public void matchSctpSrcTest() { 268 public void matchSctpSrcTest() {
269 - Criterion criterion = Criteria.matchSctpSrc((short) 22); 269 + Criterion criterion = Criteria.matchSctpSrc((short) 40000);
270 ObjectNode result = criterionCodec.encode(criterion, context); 270 ObjectNode result = criterionCodec.encode(criterion, context);
271 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 271 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
272 - assertThat(result.get("sctpPort").asInt(), is(22)); 272 + assertThat(result.get("sctpPort").asInt(), is(40000));
273 } 273 }
274 274
275 /** 275 /**
...@@ -277,10 +277,10 @@ public class CriterionCodecTest { ...@@ -277,10 +277,10 @@ public class CriterionCodecTest {
277 */ 277 */
278 @Test 278 @Test
279 public void matchSctpDstTest() { 279 public void matchSctpDstTest() {
280 - Criterion criterion = Criteria.matchSctpDst((short) 22); 280 + Criterion criterion = Criteria.matchSctpDst((short) 40000);
281 ObjectNode result = criterionCodec.encode(criterion, context); 281 ObjectNode result = criterionCodec.encode(criterion, context);
282 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 282 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
283 - assertThat(result.get("sctpPort").asInt(), is(22)); 283 + assertThat(result.get("sctpPort").asInt(), is(40000));
284 } 284 }
285 285
286 /** 286 /**
...@@ -288,10 +288,10 @@ public class CriterionCodecTest { ...@@ -288,10 +288,10 @@ public class CriterionCodecTest {
288 */ 288 */
289 @Test 289 @Test
290 public void matchIcmpTypeTest() { 290 public void matchIcmpTypeTest() {
291 - Criterion criterion = Criteria.matchIcmpType((byte) 6); 291 + Criterion criterion = Criteria.matchIcmpType((byte) 250);
292 ObjectNode result = criterionCodec.encode(criterion, context); 292 ObjectNode result = criterionCodec.encode(criterion, context);
293 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 293 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
294 - assertThat(result.get("icmpType").asInt(), is(6)); 294 + assertThat(result.get("icmpType").asInt(), is(250));
295 } 295 }
296 296
297 /** 297 /**
...@@ -299,10 +299,10 @@ public class CriterionCodecTest { ...@@ -299,10 +299,10 @@ public class CriterionCodecTest {
299 */ 299 */
300 @Test 300 @Test
301 public void matchIcmpCodeTest() { 301 public void matchIcmpCodeTest() {
302 - Criterion criterion = Criteria.matchIcmpCode((byte) 6); 302 + Criterion criterion = Criteria.matchIcmpCode((byte) 250);
303 ObjectNode result = criterionCodec.encode(criterion, context); 303 ObjectNode result = criterionCodec.encode(criterion, context);
304 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 304 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
305 - assertThat(result.get("icmpCode").asInt(), is(6)); 305 + assertThat(result.get("icmpCode").asInt(), is(250));
306 } 306 }
307 307
308 /** 308 /**
...@@ -332,10 +332,10 @@ public class CriterionCodecTest { ...@@ -332,10 +332,10 @@ public class CriterionCodecTest {
332 */ 332 */
333 @Test 333 @Test
334 public void matchIPv6FlowLabelTest() { 334 public void matchIPv6FlowLabelTest() {
335 - Criterion criterion = Criteria.matchIPv6FlowLabel(7); 335 + Criterion criterion = Criteria.matchIPv6FlowLabel(0xffffe);
336 ObjectNode result = criterionCodec.encode(criterion, context); 336 ObjectNode result = criterionCodec.encode(criterion, context);
337 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 337 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
338 - assertThat(result.get("flowLabel").asInt(), is(7)); 338 + assertThat(result.get("flowLabel").asInt(), is(0xffffe));
339 } 339 }
340 340
341 /** 341 /**
...@@ -343,10 +343,10 @@ public class CriterionCodecTest { ...@@ -343,10 +343,10 @@ public class CriterionCodecTest {
343 */ 343 */
344 @Test 344 @Test
345 public void matchIcmpv6TypeTest() { 345 public void matchIcmpv6TypeTest() {
346 - Criterion criterion = Criteria.matchIcmpv6Type((byte) 15); 346 + Criterion criterion = Criteria.matchIcmpv6Type((byte) 250);
347 ObjectNode result = criterionCodec.encode(criterion, context); 347 ObjectNode result = criterionCodec.encode(criterion, context);
348 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 348 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
349 - assertThat(result.get("icmpv6Type").asInt(), is(15)); 349 + assertThat(result.get("icmpv6Type").asInt(), is(250));
350 } 350 }
351 351
352 /** 352 /**
...@@ -354,10 +354,10 @@ public class CriterionCodecTest { ...@@ -354,10 +354,10 @@ public class CriterionCodecTest {
354 */ 354 */
355 @Test 355 @Test
356 public void matchIcmpv6CodeTest() { 356 public void matchIcmpv6CodeTest() {
357 - Criterion criterion = Criteria.matchIcmpv6Code((byte) 17); 357 + Criterion criterion = Criteria.matchIcmpv6Code((byte) 250);
358 ObjectNode result = criterionCodec.encode(criterion, context); 358 ObjectNode result = criterionCodec.encode(criterion, context);
359 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 359 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
360 - assertThat(result.get("icmpv6Code").asInt(), is(17)); 360 + assertThat(result.get("icmpv6Code").asInt(), is(250));
361 } 361 }
362 362
363 /** 363 /**
...@@ -400,10 +400,10 @@ public class CriterionCodecTest { ...@@ -400,10 +400,10 @@ public class CriterionCodecTest {
400 */ 400 */
401 @Test 401 @Test
402 public void matchMplsLabelTest() { 402 public void matchMplsLabelTest() {
403 - Criterion criterion = Criteria.matchMplsLabel(88); 403 + Criterion criterion = Criteria.matchMplsLabel(0xffffe);
404 ObjectNode result = criterionCodec.encode(criterion, context); 404 ObjectNode result = criterionCodec.encode(criterion, context);
405 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 405 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
406 - assertThat(result.get("label").asInt(), is(88)); 406 + assertThat(result.get("label").asInt(), is(0xffffe));
407 } 407 }
408 408
409 /** 409 /**
...@@ -411,10 +411,10 @@ public class CriterionCodecTest { ...@@ -411,10 +411,10 @@ public class CriterionCodecTest {
411 */ 411 */
412 @Test 412 @Test
413 public void matchLambdaTest() { 413 public void matchLambdaTest() {
414 - Criterion criterion = Criteria.matchLambda((short) 9); 414 + Criterion criterion = Criteria.matchLambda((short) 40000);
415 ObjectNode result = criterionCodec.encode(criterion, context); 415 ObjectNode result = criterionCodec.encode(criterion, context);
416 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 416 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
417 - assertThat(result.get("lambda").asInt(), is(9)); 417 + assertThat(result.get("lambda").asInt(), is(40000));
418 } 418 }
419 419
420 /** 420 /**
...@@ -422,10 +422,10 @@ public class CriterionCodecTest { ...@@ -422,10 +422,10 @@ public class CriterionCodecTest {
422 */ 422 */
423 @Test 423 @Test
424 public void matchOpticalSignalTypeTest() { 424 public void matchOpticalSignalTypeTest() {
425 - Criterion criterion = Criteria.matchOpticalSignalType((short) 11); 425 + Criterion criterion = Criteria.matchOpticalSignalType((short) 40000);
426 ObjectNode result = criterionCodec.encode(criterion, context); 426 ObjectNode result = criterionCodec.encode(criterion, context);
427 assertThat(result.get("type").textValue(), is(criterion.type().toString())); 427 assertThat(result.get("type").textValue(), is(criterion.type().toString()));
428 - assertThat(result.get("signalType").asInt(), is(11)); 428 + assertThat(result.get("signalType").asInt(), is(40000));
429 } 429 }
430 430
431 } 431 }
......
...@@ -84,7 +84,8 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -84,7 +84,8 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
84 case ETH_TYPE: 84 case ETH_TYPE:
85 final Criteria.EthTypeCriterion ethTypeCriterion = 85 final Criteria.EthTypeCriterion ethTypeCriterion =
86 (Criteria.EthTypeCriterion) criterion; 86 (Criteria.EthTypeCriterion) criterion;
87 - final String ethType = ethTypeCriterion.ethType().toString(); 87 + final String ethType =
88 + Long.toHexString(ethTypeCriterion.ethType());
88 final String jsonEthType = jsonCriterion.get("ethType").textValue(); 89 final String jsonEthType = jsonCriterion.get("ethType").textValue();
89 if (!ethType.equals(jsonEthType)) { 90 if (!ethType.equals(jsonEthType)) {
90 description.appendText("ethType was " + jsonEthType); 91 description.appendText("ethType was " + jsonEthType);
...@@ -139,10 +140,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -139,10 +140,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
139 case IP_PROTO: 140 case IP_PROTO:
140 final Criteria.IPProtocolCriterion iPProtocolCriterion = 141 final Criteria.IPProtocolCriterion iPProtocolCriterion =
141 (Criteria.IPProtocolCriterion) criterion; 142 (Criteria.IPProtocolCriterion) criterion;
142 - final byte protocol = iPProtocolCriterion.protocol(); 143 + final short protocol = iPProtocolCriterion.protocol();
143 - final byte jsonProtocol = (byte) jsonCriterion.get("protocol").shortValue(); 144 + final short jsonProtocol = jsonCriterion.get("protocol").shortValue();
144 if (protocol != jsonProtocol) { 145 if (protocol != jsonProtocol) {
145 - description.appendText("protocol was " + Byte.toString(jsonProtocol)); 146 + description.appendText("protocol was " + Short.toString(jsonProtocol));
146 return false; 147 return false;
147 } 148 }
148 break; 149 break;
...@@ -165,10 +166,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -165,10 +166,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
165 case TCP_DST: 166 case TCP_DST:
166 final Criteria.TcpPortCriterion tcpPortCriterion = 167 final Criteria.TcpPortCriterion tcpPortCriterion =
167 (Criteria.TcpPortCriterion) criterion; 168 (Criteria.TcpPortCriterion) criterion;
168 - final short tcpPort = tcpPortCriterion.tcpPort(); 169 + final int tcpPort = tcpPortCriterion.tcpPort();
169 - final short jsonTcpPort = jsonCriterion.get("tcpPort").shortValue(); 170 + final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue();
170 if (tcpPort != jsonTcpPort) { 171 if (tcpPort != jsonTcpPort) {
171 - description.appendText("tcp port was " + Short.toString(jsonTcpPort)); 172 + description.appendText("tcp port was " + Integer.toString(jsonTcpPort));
172 return false; 173 return false;
173 } 174 }
174 break; 175 break;
...@@ -177,10 +178,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -177,10 +178,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
177 case UDP_DST: 178 case UDP_DST:
178 final Criteria.UdpPortCriterion udpPortCriterion = 179 final Criteria.UdpPortCriterion udpPortCriterion =
179 (Criteria.UdpPortCriterion) criterion; 180 (Criteria.UdpPortCriterion) criterion;
180 - final short udpPort = udpPortCriterion.udpPort(); 181 + final int udpPort = udpPortCriterion.udpPort();
181 - final short jsonUdpPort = jsonCriterion.get("udpPort").shortValue(); 182 + final int jsonUdpPort = jsonCriterion.get("udpPort").intValue();
182 if (udpPort != jsonUdpPort) { 183 if (udpPort != jsonUdpPort) {
183 - description.appendText("udp port was " + Short.toString(jsonUdpPort)); 184 + description.appendText("udp port was " + Integer.toString(jsonUdpPort));
184 return false; 185 return false;
185 } 186 }
186 break; 187 break;
...@@ -189,10 +190,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -189,10 +190,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
189 case SCTP_DST: 190 case SCTP_DST:
190 final Criteria.SctpPortCriterion sctpPortCriterion = 191 final Criteria.SctpPortCriterion sctpPortCriterion =
191 (Criteria.SctpPortCriterion) criterion; 192 (Criteria.SctpPortCriterion) criterion;
192 - final short sctpPort = sctpPortCriterion.sctpPort(); 193 + final int sctpPort = sctpPortCriterion.sctpPort();
193 - final short jsonSctpPort = jsonCriterion.get("sctpPort").shortValue(); 194 + final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue();
194 if (sctpPort != jsonSctpPort) { 195 if (sctpPort != jsonSctpPort) {
195 - description.appendText("sctp port was " + Short.toString(jsonSctpPort)); 196 + description.appendText("sctp port was " + Integer.toString(jsonSctpPort));
196 return false; 197 return false;
197 } 198 }
198 break; 199 break;
...@@ -200,10 +201,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -200,10 +201,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
200 case ICMPV4_TYPE: 201 case ICMPV4_TYPE:
201 final Criteria.IcmpTypeCriterion icmpTypeCriterion = 202 final Criteria.IcmpTypeCriterion icmpTypeCriterion =
202 (Criteria.IcmpTypeCriterion) criterion; 203 (Criteria.IcmpTypeCriterion) criterion;
203 - final byte icmpType = icmpTypeCriterion.icmpType(); 204 + final short icmpType = icmpTypeCriterion.icmpType();
204 - final byte jsonIcmpType = (byte) jsonCriterion.get("icmpType").shortValue(); 205 + final short jsonIcmpType = jsonCriterion.get("icmpType").shortValue();
205 if (icmpType != jsonIcmpType) { 206 if (icmpType != jsonIcmpType) {
206 - description.appendText("icmp type was " + Byte.toString(jsonIcmpType)); 207 + description.appendText("icmp type was " + Short.toString(jsonIcmpType));
207 return false; 208 return false;
208 } 209 }
209 break; 210 break;
...@@ -211,10 +212,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -211,10 +212,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
211 case ICMPV4_CODE: 212 case ICMPV4_CODE:
212 final Criteria.IcmpCodeCriterion icmpCodeCriterion = 213 final Criteria.IcmpCodeCriterion icmpCodeCriterion =
213 (Criteria.IcmpCodeCriterion) criterion; 214 (Criteria.IcmpCodeCriterion) criterion;
214 - final byte icmpCode = icmpCodeCriterion.icmpCode(); 215 + final short icmpCode = icmpCodeCriterion.icmpCode();
215 - final byte jsonIcmpCode = (byte) jsonCriterion.get("icmpCode").shortValue(); 216 + final short jsonIcmpCode = jsonCriterion.get("icmpCode").shortValue();
216 if (icmpCode != jsonIcmpCode) { 217 if (icmpCode != jsonIcmpCode) {
217 - description.appendText("icmp code was " + Byte.toString(jsonIcmpCode)); 218 + description.appendText("icmp code was " + Short.toString(jsonIcmpCode));
218 return false; 219 return false;
219 } 220 }
220 break; 221 break;
...@@ -233,10 +234,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -233,10 +234,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
233 case ICMPV6_TYPE: 234 case ICMPV6_TYPE:
234 final Criteria.Icmpv6TypeCriterion icmpv6TypeCriterion = 235 final Criteria.Icmpv6TypeCriterion icmpv6TypeCriterion =
235 (Criteria.Icmpv6TypeCriterion) criterion; 236 (Criteria.Icmpv6TypeCriterion) criterion;
236 - final byte icmpv6Type = icmpv6TypeCriterion.icmpv6Type(); 237 + final short icmpv6Type = icmpv6TypeCriterion.icmpv6Type();
237 - final byte jsonIcmpv6Type = (byte) jsonCriterion.get("icmpv6Type").shortValue(); 238 + final short jsonIcmpv6Type = jsonCriterion.get("icmpv6Type").shortValue();
238 if (icmpv6Type != jsonIcmpv6Type) { 239 if (icmpv6Type != jsonIcmpv6Type) {
239 - description.appendText("icmpv6 type was " + Byte.toString(jsonIcmpv6Type)); 240 + description.appendText("icmpv6 type was " + Short.toString(jsonIcmpv6Type));
240 return false; 241 return false;
241 } 242 }
242 break; 243 break;
...@@ -244,10 +245,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -244,10 +245,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
244 case ICMPV6_CODE: 245 case ICMPV6_CODE:
245 final Criteria.Icmpv6CodeCriterion icmpv6CodeCriterion = 246 final Criteria.Icmpv6CodeCriterion icmpv6CodeCriterion =
246 (Criteria.Icmpv6CodeCriterion) criterion; 247 (Criteria.Icmpv6CodeCriterion) criterion;
247 - final byte icmpv6Code = icmpv6CodeCriterion.icmpv6Code(); 248 + final short icmpv6Code = icmpv6CodeCriterion.icmpv6Code();
248 - final byte jsonIcmpv6Code = (byte) jsonCriterion.get("icmpv6Code").shortValue(); 249 + final short jsonIcmpv6Code = jsonCriterion.get("icmpv6Code").shortValue();
249 if (icmpv6Code != jsonIcmpv6Code) { 250 if (icmpv6Code != jsonIcmpv6Code) {
250 - description.appendText("icmpv6 code was " + Byte.toString(jsonIcmpv6Code)); 251 + description.appendText("icmpv6 code was " + Short.toString(jsonIcmpv6Code));
251 return false; 252 return false;
252 } 253 }
253 break; 254 break;
...@@ -296,10 +297,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -296,10 +297,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
296 case OCH_SIGID: 297 case OCH_SIGID:
297 final Criteria.LambdaCriterion lambdaCriterion = 298 final Criteria.LambdaCriterion lambdaCriterion =
298 (Criteria.LambdaCriterion) criterion; 299 (Criteria.LambdaCriterion) criterion;
299 - final short lambda = lambdaCriterion.lambda(); 300 + final int lambda = lambdaCriterion.lambda();
300 - final short jsonLambda = jsonCriterion.get("lambda").shortValue(); 301 + final int jsonLambda = jsonCriterion.get("lambda").intValue();
301 if (lambda != jsonLambda) { 302 if (lambda != jsonLambda) {
302 - description.appendText("lambda was " + Short.toString(lambda)); 303 + description.appendText("lambda was " + Integer.toString(lambda));
303 return false; 304 return false;
304 } 305 }
305 break; 306 break;
...@@ -307,10 +308,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo ...@@ -307,10 +308,10 @@ public final class CriterionJsonMatcher extends TypeSafeDiagnosingMatcher<JsonNo
307 case OCH_SIGTYPE: 308 case OCH_SIGTYPE:
308 final Criteria.OpticalSignalTypeCriterion opticalSignalTypeCriterion = 309 final Criteria.OpticalSignalTypeCriterion opticalSignalTypeCriterion =
309 (Criteria.OpticalSignalTypeCriterion) criterion; 310 (Criteria.OpticalSignalTypeCriterion) criterion;
310 - final short signalType = opticalSignalTypeCriterion.signalType(); 311 + final int signalType = opticalSignalTypeCriterion.signalType();
311 - final short jsonSignalType = jsonCriterion.get("signalType").shortValue(); 312 + final int jsonSignalType = jsonCriterion.get("signalType").intValue();
312 if (signalType != jsonSignalType) { 313 if (signalType != jsonSignalType) {
313 - description.appendText("signal type was " + Short.toString(signalType)); 314 + description.appendText("signal type was " + Integer.toString(signalType));
314 return false; 315 return false;
315 } 316 }
316 break; 317 break;
......