Hyunsun Moon
Committed by Gerrit Code Review

ONOS-2711 Replaced short to TpPort for tcp/udp ports

Change-Id: Ibf0474b5369d11d377fd33cf5ab48083cbca3308
Showing 36 changed files with 548 additions and 231 deletions
...@@ -35,6 +35,7 @@ import org.onlab.packet.IpAddress; ...@@ -35,6 +35,7 @@ import org.onlab.packet.IpAddress;
35 import org.onlab.packet.MacAddress; 35 import org.onlab.packet.MacAddress;
36 import org.onlab.packet.RADIUS; 36 import org.onlab.packet.RADIUS;
37 import org.onlab.packet.RADIUSAttribute; 37 import org.onlab.packet.RADIUSAttribute;
38 +import org.onlab.packet.TpPort;
38 import org.onlab.packet.UDP; 39 import org.onlab.packet.UDP;
39 import org.onlab.packet.VlanId; 40 import org.onlab.packet.VlanId;
40 import org.onlab.util.Tools; 41 import org.onlab.util.Tools;
...@@ -236,8 +237,8 @@ public class AAA { ...@@ -236,8 +237,8 @@ public class AAA {
236 TrafficSelector radSelector = DefaultTrafficSelector.builder() 237 TrafficSelector radSelector = DefaultTrafficSelector.builder()
237 .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) 238 .matchEthType(EthType.EtherType.IPV4.ethType().toShort())
238 .matchIPProtocol(IPv4.PROTOCOL_UDP) 239 .matchIPProtocol(IPv4.PROTOCOL_UDP)
239 - .matchUdpDst((short) 1812) 240 + .matchUdpDst(TpPort.tpPort(1812))
240 - .matchUdpSrc((short) 1812) 241 + .matchUdpSrc(TpPort.tpPort(1812))
241 .build(); 242 .build();
242 packetService.requestPackets(radSelector, CONTROL, appId); 243 packetService.requestPackets(radSelector, CONTROL, appId);
243 } 244 }
...@@ -253,8 +254,8 @@ public class AAA { ...@@ -253,8 +254,8 @@ public class AAA {
253 TrafficSelector radSelector = DefaultTrafficSelector.builder() 254 TrafficSelector radSelector = DefaultTrafficSelector.builder()
254 .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) 255 .matchEthType(EthType.EtherType.IPV4.ethType().toShort())
255 .matchIPProtocol(IPv4.PROTOCOL_UDP) 256 .matchIPProtocol(IPv4.PROTOCOL_UDP)
256 - .matchUdpDst((short) 1812) 257 + .matchUdpDst(TpPort.tpPort(1812))
257 - .matchUdpSrc((short) 1812) 258 + .matchUdpSrc(TpPort.tpPort(1812))
258 .build(); 259 .build();
259 packetService.cancelPackets(radSelector, CONTROL, appId); 260 packetService.cancelPackets(radSelector, CONTROL, appId);
260 } 261 }
......
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
19 */ 19 */
20 package org.onos.acl.impl; 20 package org.onos.acl.impl;
21 21
22 +import org.onlab.packet.Ethernet;
23 +import org.onlab.packet.IPv4;
24 +import org.onlab.packet.Ip4Address;
25 +import org.onlab.packet.Ip4Prefix;
26 +import org.onlab.packet.IpAddress;
27 +import org.onlab.packet.TpPort;
22 import org.onos.acl.AclRule; 28 import org.onos.acl.AclRule;
23 import org.onos.acl.AclService; 29 import org.onos.acl.AclService;
24 import org.onos.acl.AclStore; 30 import org.onos.acl.AclStore;
...@@ -28,11 +34,6 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -28,11 +34,6 @@ import org.apache.felix.scr.annotations.Deactivate;
28 import org.apache.felix.scr.annotations.Reference; 34 import org.apache.felix.scr.annotations.Reference;
29 import org.apache.felix.scr.annotations.ReferenceCardinality; 35 import org.apache.felix.scr.annotations.ReferenceCardinality;
30 import org.apache.felix.scr.annotations.Service; 36 import org.apache.felix.scr.annotations.Service;
31 -import org.onlab.packet.Ethernet;
32 -import org.onlab.packet.IPv4;
33 -import org.onlab.packet.Ip4Address;
34 -import org.onlab.packet.Ip4Prefix;
35 -import org.onlab.packet.IpAddress;
36 import org.onos.acl.RuleId; 37 import org.onos.acl.RuleId;
37 import org.onosproject.core.ApplicationId; 38 import org.onosproject.core.ApplicationId;
38 import org.onosproject.core.CoreService; 39 import org.onosproject.core.CoreService;
...@@ -278,10 +279,10 @@ public class AclManager implements AclService { ...@@ -278,10 +279,10 @@ public class AclManager implements AclService {
278 if (rule.dstTpPort() != 0) { 279 if (rule.dstTpPort() != 0) {
279 switch (rule.ipProto()) { 280 switch (rule.ipProto()) {
280 case IPv4.PROTOCOL_TCP: 281 case IPv4.PROTOCOL_TCP:
281 - selectorBuilder.matchTcpDst(rule.dstTpPort()); 282 + selectorBuilder.matchTcpDst(TpPort.tpPort(rule.dstTpPort()));
282 break; 283 break;
283 case IPv4.PROTOCOL_UDP: 284 case IPv4.PROTOCOL_UDP:
284 - selectorBuilder.matchUdpDst(rule.dstTpPort()); 285 + selectorBuilder.matchUdpDst(TpPort.tpPort(rule.dstTpPort()));
285 break; 286 break;
286 default: 287 default:
287 break; 288 break;
......
...@@ -21,6 +21,7 @@ import org.onlab.packet.Ethernet; ...@@ -21,6 +21,7 @@ import org.onlab.packet.Ethernet;
21 import org.onlab.packet.IPv4; 21 import org.onlab.packet.IPv4;
22 import org.onlab.packet.IpAddress; 22 import org.onlab.packet.IpAddress;
23 import org.onlab.packet.TCP; 23 import org.onlab.packet.TCP;
24 +import org.onlab.packet.TpPort;
24 import org.onosproject.core.ApplicationId; 25 import org.onosproject.core.ApplicationId;
25 import org.onosproject.net.ConnectPoint; 26 import org.onosproject.net.ConnectPoint;
26 import org.onosproject.net.flow.DefaultTrafficSelector; 27 import org.onosproject.net.flow.DefaultTrafficSelector;
...@@ -101,13 +102,13 @@ public class TunnellingConnectivityManager { ...@@ -101,13 +102,13 @@ public class TunnellingConnectivityManager {
101 TrafficSelector selectorDst = DefaultTrafficSelector.builder() 102 TrafficSelector selectorDst = DefaultTrafficSelector.builder()
102 .matchEthType(Ethernet.TYPE_IPV4) 103 .matchEthType(Ethernet.TYPE_IPV4)
103 .matchIPProtocol(IPv4.PROTOCOL_TCP) 104 .matchIPProtocol(IPv4.PROTOCOL_TCP)
104 - .matchTcpDst(BGP_PORT) 105 + .matchTcpDst(TpPort.tpPort(BGP_PORT))
105 .build(); 106 .build();
106 107
107 TrafficSelector selectorSrc = DefaultTrafficSelector.builder() 108 TrafficSelector selectorSrc = DefaultTrafficSelector.builder()
108 .matchEthType(Ethernet.TYPE_IPV4) 109 .matchEthType(Ethernet.TYPE_IPV4)
109 .matchIPProtocol(IPv4.PROTOCOL_TCP) 110 .matchIPProtocol(IPv4.PROTOCOL_TCP)
110 - .matchTcpSrc(BGP_PORT) 111 + .matchTcpSrc(TpPort.tpPort(BGP_PORT))
111 .build(); 112 .build();
112 113
113 TrafficTreatment treatment = DefaultTrafficTreatment.builder() 114 TrafficTreatment treatment = DefaultTrafficTreatment.builder()
......
...@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Service; ...@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.Service;
27 import org.onlab.packet.Ethernet; 27 import org.onlab.packet.Ethernet;
28 import org.onlab.packet.IPv4; 28 import org.onlab.packet.IPv4;
29 import org.onlab.packet.MacAddress; 29 import org.onlab.packet.MacAddress;
30 +import org.onlab.packet.TpPort;
30 import org.onlab.packet.VlanId; 31 import org.onlab.packet.VlanId;
31 import org.onosproject.core.ApplicationId; 32 import org.onosproject.core.ApplicationId;
32 import org.onosproject.core.CoreService; 33 import org.onosproject.core.CoreService;
...@@ -119,14 +120,14 @@ public class CordFabricManager implements FabricService { ...@@ -119,14 +120,14 @@ public class CordFabricManager implements FabricService {
119 TrafficSelector ofInBandMatchUp = DefaultTrafficSelector.builder() 120 TrafficSelector ofInBandMatchUp = DefaultTrafficSelector.builder()
120 .matchEthType(Ethernet.TYPE_IPV4) 121 .matchEthType(Ethernet.TYPE_IPV4)
121 .matchIPProtocol(IPv4.PROTOCOL_TCP) 122 .matchIPProtocol(IPv4.PROTOCOL_TCP)
122 - .matchTcpDst(ofPort) 123 + .matchTcpDst(TpPort.tpPort(ofPort))
123 .matchInPort(PortNumber.portNumber(6)) 124 .matchInPort(PortNumber.portNumber(6))
124 .build(); 125 .build();
125 126
126 TrafficSelector ofInBandMatchDown = DefaultTrafficSelector.builder() 127 TrafficSelector ofInBandMatchDown = DefaultTrafficSelector.builder()
127 .matchEthType(Ethernet.TYPE_IPV4) 128 .matchEthType(Ethernet.TYPE_IPV4)
128 .matchIPProtocol(IPv4.PROTOCOL_TCP) 129 .matchIPProtocol(IPv4.PROTOCOL_TCP)
129 - .matchTcpSrc(ofPort) 130 + .matchTcpSrc(TpPort.tpPort(ofPort))
130 .matchInPort(PortNumber.portNumber(1)) 131 .matchInPort(PortNumber.portNumber(1))
131 .build(); 132 .build();
132 133
...@@ -152,14 +153,14 @@ public class CordFabricManager implements FabricService { ...@@ -152,14 +153,14 @@ public class CordFabricManager implements FabricService {
152 .matchInPort(PortNumber.portNumber(2)) 153 .matchInPort(PortNumber.portNumber(2))
153 .matchEthType(Ethernet.TYPE_IPV4) 154 .matchEthType(Ethernet.TYPE_IPV4)
154 .matchIPProtocol(IPv4.PROTOCOL_UDP) 155 .matchIPProtocol(IPv4.PROTOCOL_UDP)
155 - .matchUdpDst(radiusPort) 156 + .matchUdpDst(TpPort.tpPort(radiusPort))
156 .build(); 157 .build();
157 158
158 TrafficSelector fromRadius = DefaultTrafficSelector.builder() 159 TrafficSelector fromRadius = DefaultTrafficSelector.builder()
159 .matchInPort(PortNumber.portNumber(5)) 160 .matchInPort(PortNumber.portNumber(5))
160 .matchEthType(Ethernet.TYPE_IPV4) 161 .matchEthType(Ethernet.TYPE_IPV4)
161 .matchIPProtocol(IPv4.PROTOCOL_UDP) 162 .matchIPProtocol(IPv4.PROTOCOL_UDP)
162 - .matchUdpDst(radiusPort) 163 + .matchUdpDst(TpPort.tpPort(radiusPort))
163 .build(); 164 .build();
164 165
165 TrafficTreatment toOlt = DefaultTrafficTreatment.builder() 166 TrafficTreatment toOlt = DefaultTrafficTreatment.builder()
......
...@@ -32,6 +32,7 @@ import org.onlab.packet.Ip4Prefix; ...@@ -32,6 +32,7 @@ import org.onlab.packet.Ip4Prefix;
32 import org.onlab.packet.Ip6Prefix; 32 import org.onlab.packet.Ip6Prefix;
33 import org.onlab.packet.MacAddress; 33 import org.onlab.packet.MacAddress;
34 import org.onlab.packet.TCP; 34 import org.onlab.packet.TCP;
35 +import org.onlab.packet.TpPort;
35 import org.onlab.packet.UDP; 36 import org.onlab.packet.UDP;
36 import org.onlab.packet.VlanId; 37 import org.onlab.packet.VlanId;
37 import org.onosproject.cfg.ComponentConfigService; 38 import org.onosproject.cfg.ComponentConfigService;
...@@ -587,14 +588,14 @@ public class ReactiveForwarding { ...@@ -587,14 +588,14 @@ public class ReactiveForwarding {
587 if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_TCP) { 588 if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_TCP) {
588 TCP tcpPacket = (TCP) ipv4Packet.getPayload(); 589 TCP tcpPacket = (TCP) ipv4Packet.getPayload();
589 selectorBuilder.matchIPProtocol(ipv4Protocol) 590 selectorBuilder.matchIPProtocol(ipv4Protocol)
590 - .matchTcpSrc(tcpPacket.getSourcePort()) 591 + .matchTcpSrc(TpPort.tpPort(tcpPacket.getSourcePort()))
591 - .matchTcpDst(tcpPacket.getDestinationPort()); 592 + .matchTcpDst(TpPort.tpPort(tcpPacket.getDestinationPort()));
592 } 593 }
593 if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_UDP) { 594 if (matchTcpUdpPorts && ipv4Protocol == IPv4.PROTOCOL_UDP) {
594 UDP udpPacket = (UDP) ipv4Packet.getPayload(); 595 UDP udpPacket = (UDP) ipv4Packet.getPayload();
595 selectorBuilder.matchIPProtocol(ipv4Protocol) 596 selectorBuilder.matchIPProtocol(ipv4Protocol)
596 - .matchUdpSrc(udpPacket.getSourcePort()) 597 + .matchUdpSrc(TpPort.tpPort(udpPacket.getSourcePort()))
597 - .matchUdpDst(udpPacket.getDestinationPort()); 598 + .matchUdpDst(TpPort.tpPort(udpPacket.getDestinationPort()));
598 } 599 }
599 if (matchIcmpFields && ipv4Protocol == IPv4.PROTOCOL_ICMP) { 600 if (matchIcmpFields && ipv4Protocol == IPv4.PROTOCOL_ICMP) {
600 ICMP icmpPacket = (ICMP) ipv4Packet.getPayload(); 601 ICMP icmpPacket = (ICMP) ipv4Packet.getPayload();
...@@ -628,14 +629,14 @@ public class ReactiveForwarding { ...@@ -628,14 +629,14 @@ public class ReactiveForwarding {
628 if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_TCP) { 629 if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_TCP) {
629 TCP tcpPacket = (TCP) ipv6Packet.getPayload(); 630 TCP tcpPacket = (TCP) ipv6Packet.getPayload();
630 selectorBuilder.matchIPProtocol(ipv6NextHeader) 631 selectorBuilder.matchIPProtocol(ipv6NextHeader)
631 - .matchTcpSrc(tcpPacket.getSourcePort()) 632 + .matchTcpSrc(TpPort.tpPort(tcpPacket.getSourcePort()))
632 - .matchTcpDst(tcpPacket.getDestinationPort()); 633 + .matchTcpDst(TpPort.tpPort(tcpPacket.getDestinationPort()));
633 } 634 }
634 if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_UDP) { 635 if (matchTcpUdpPorts && ipv6NextHeader == IPv6.PROTOCOL_UDP) {
635 UDP udpPacket = (UDP) ipv6Packet.getPayload(); 636 UDP udpPacket = (UDP) ipv6Packet.getPayload();
636 selectorBuilder.matchIPProtocol(ipv6NextHeader) 637 selectorBuilder.matchIPProtocol(ipv6NextHeader)
637 - .matchUdpSrc(udpPacket.getSourcePort()) 638 + .matchUdpSrc(TpPort.tpPort(udpPacket.getSourcePort()))
638 - .matchUdpDst(udpPacket.getDestinationPort()); 639 + .matchUdpDst(TpPort.tpPort(udpPacket.getDestinationPort()));
639 } 640 }
640 if (matchIcmpFields && ipv6NextHeader == IPv6.PROTOCOL_ICMP6) { 641 if (matchIcmpFields && ipv6NextHeader == IPv6.PROTOCOL_ICMP6) {
641 ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload(); 642 ICMP6 icmp6Packet = (ICMP6) ipv6Packet.getPayload();
......
...@@ -20,6 +20,7 @@ import org.onlab.packet.IPv4; ...@@ -20,6 +20,7 @@ import org.onlab.packet.IPv4;
20 import org.onlab.packet.IPv6; 20 import org.onlab.packet.IPv6;
21 import org.onlab.packet.IpAddress; 21 import org.onlab.packet.IpAddress;
22 import org.onlab.packet.IpPrefix; 22 import org.onlab.packet.IpPrefix;
23 +import org.onlab.packet.TpPort;
23 import org.onosproject.core.ApplicationId; 24 import org.onosproject.core.ApplicationId;
24 import org.onosproject.net.ConnectPoint; 25 import org.onosproject.net.ConnectPoint;
25 import org.onosproject.net.flow.DefaultTrafficSelector; 26 import org.onosproject.net.flow.DefaultTrafficSelector;
...@@ -321,11 +322,11 @@ public class PeerConnectivityManager { ...@@ -321,11 +322,11 @@ public class PeerConnectivityManager {
321 } 322 }
322 323
323 if (srcTcpPort != null) { 324 if (srcTcpPort != null) {
324 - builder.matchTcpSrc(srcTcpPort); 325 + builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
325 } 326 }
326 327
327 if (dstTcpPort != null) { 328 if (dstTcpPort != null) {
328 - builder.matchTcpDst(dstTcpPort); 329 + builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
329 } 330 }
330 331
331 return builder.build(); 332 return builder.build();
......
...@@ -26,6 +26,7 @@ import org.onlab.packet.IPv4; ...@@ -26,6 +26,7 @@ import org.onlab.packet.IPv4;
26 import org.onlab.packet.IpAddress; 26 import org.onlab.packet.IpAddress;
27 import org.onlab.packet.IpPrefix; 27 import org.onlab.packet.IpPrefix;
28 import org.onlab.packet.MacAddress; 28 import org.onlab.packet.MacAddress;
29 +import org.onlab.packet.TpPort;
29 import org.onlab.packet.VlanId; 30 import org.onlab.packet.VlanId;
30 import org.onosproject.core.ApplicationId; 31 import org.onosproject.core.ApplicationId;
31 import org.onosproject.net.ConnectPoint; 32 import org.onosproject.net.ConnectPoint;
...@@ -290,10 +291,10 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest { ...@@ -290,10 +291,10 @@ public class PeerConnectivityManagerTest extends AbstractIntentTest {
290 .matchIPDst(IpPrefix.valueOf(dstPrefix)); 291 .matchIPDst(IpPrefix.valueOf(dstPrefix));
291 292
292 if (srcTcpPort != null) { 293 if (srcTcpPort != null) {
293 - builder.matchTcpSrc(srcTcpPort); 294 + builder.matchTcpSrc(TpPort.tpPort(srcTcpPort));
294 } 295 }
295 if (dstTcpPort != null) { 296 if (dstTcpPort != null) {
296 - builder.matchTcpDst(dstTcpPort); 297 + builder.matchTcpDst(TpPort.tpPort(dstTcpPort));
297 } 298 }
298 299
299 PointToPointIntent intent = PointToPointIntent.builder() 300 PointToPointIntent intent = PointToPointIntent.builder()
......
...@@ -18,6 +18,7 @@ package org.onosproject.segmentrouting; ...@@ -18,6 +18,7 @@ package org.onosproject.segmentrouting;
18 18
19 import org.onlab.packet.Ethernet; 19 import org.onlab.packet.Ethernet;
20 import org.onlab.packet.IpPrefix; 20 import org.onlab.packet.IpPrefix;
21 +import org.onlab.packet.TpPort;
21 import org.onosproject.cli.net.IpProtocol; 22 import org.onosproject.cli.net.IpProtocol;
22 import org.onosproject.core.ApplicationId; 23 import org.onosproject.core.ApplicationId;
23 import org.onosproject.net.DeviceId; 24 import org.onosproject.net.DeviceId;
...@@ -193,17 +194,17 @@ public class PolicyHandler { ...@@ -193,17 +194,17 @@ public class PolicyHandler {
193 tsb.matchIPProtocol(ipProto.byteValue()); 194 tsb.matchIPProtocol(ipProto.byteValue());
194 if (IpProtocol.valueOf(policy.ipProto()).equals(IpProtocol.TCP)) { 195 if (IpProtocol.valueOf(policy.ipProto()).equals(IpProtocol.TCP)) {
195 if (policy.srcPort() != 0) { 196 if (policy.srcPort() != 0) {
196 - tsb.matchTcpSrc(policy.srcPort()); 197 + tsb.matchTcpSrc(TpPort.tpPort(policy.srcPort()));
197 } 198 }
198 if (policy.dstPort() != 0) { 199 if (policy.dstPort() != 0) {
199 - tsb.matchTcpDst(policy.dstPort()); 200 + tsb.matchTcpDst(TpPort.tpPort(policy.dstPort()));
200 } 201 }
201 } else if (IpProtocol.valueOf(policy.ipProto()).equals(IpProtocol.UDP)) { 202 } else if (IpProtocol.valueOf(policy.ipProto()).equals(IpProtocol.UDP)) {
202 if (policy.srcPort() != 0) { 203 if (policy.srcPort() != 0) {
203 - tsb.matchUdpSrc(policy.srcPort()); 204 + tsb.matchUdpSrc(TpPort.tpPort(policy.srcPort()));
204 } 205 }
205 if (policy.dstPort() != 0) { 206 if (policy.dstPort() != 0) {
206 - tsb.matchUdpDst(policy.dstPort()); 207 + tsb.matchUdpDst(TpPort.tpPort(policy.dstPort()));
207 } 208 }
208 } 209 }
209 } 210 }
......
...@@ -24,6 +24,9 @@ import java.util.List; ...@@ -24,6 +24,9 @@ import java.util.List;
24 import org.apache.karaf.shell.commands.Option; 24 import org.apache.karaf.shell.commands.Option;
25 import org.onlab.packet.Ip6Address; 25 import org.onlab.packet.Ip6Address;
26 import org.onlab.packet.IpAddress; 26 import org.onlab.packet.IpAddress;
27 +import org.onlab.packet.IpPrefix;
28 +import org.onlab.packet.MacAddress;
29 +import org.onlab.packet.TpPort;
27 import org.onlab.packet.VlanId; 30 import org.onlab.packet.VlanId;
28 import org.onlab.util.Bandwidth; 31 import org.onlab.util.Bandwidth;
29 import org.onosproject.cli.AbstractShellCommand; 32 import org.onosproject.cli.AbstractShellCommand;
...@@ -42,8 +45,6 @@ import org.onosproject.net.intent.constraint.LambdaConstraint; ...@@ -42,8 +45,6 @@ import org.onosproject.net.intent.constraint.LambdaConstraint;
42 import org.onosproject.net.intent.constraint.LinkTypeConstraint; 45 import org.onosproject.net.intent.constraint.LinkTypeConstraint;
43 import org.onosproject.net.intent.constraint.PartialFailureConstraint; 46 import org.onosproject.net.intent.constraint.PartialFailureConstraint;
44 import org.onosproject.net.resource.link.BandwidthResource; 47 import org.onosproject.net.resource.link.BandwidthResource;
45 -import org.onlab.packet.IpPrefix;
46 -import org.onlab.packet.MacAddress;
47 48
48 /** 49 /**
49 * Base class for command line operations for connectivity based intents. 50 * Base class for command line operations for connectivity based intents.
...@@ -266,11 +267,11 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { ...@@ -266,11 +267,11 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
266 } 267 }
267 268
268 if (!isNullOrEmpty(srcTcpString)) { 269 if (!isNullOrEmpty(srcTcpString)) {
269 - selectorBuilder.matchTcpSrc((short) Integer.parseInt(srcTcpString)); 270 + selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpString)));
270 } 271 }
271 272
272 if (!isNullOrEmpty(dstTcpString)) { 273 if (!isNullOrEmpty(dstTcpString)) {
273 - selectorBuilder.matchTcpDst((short) Integer.parseInt(dstTcpString)); 274 + selectorBuilder.matchTcpDst(TpPort.tpPort(Integer.parseInt(dstTcpString)));
274 } 275 }
275 276
276 if (extHdrStringList != null) { 277 if (extHdrStringList != null) {
......
...@@ -21,6 +21,7 @@ import org.onlab.packet.Ip6Address; ...@@ -21,6 +21,7 @@ import org.onlab.packet.Ip6Address;
21 import org.onlab.packet.IpPrefix; 21 import org.onlab.packet.IpPrefix;
22 import org.onlab.packet.MacAddress; 22 import org.onlab.packet.MacAddress;
23 import org.onlab.packet.MplsLabel; 23 import org.onlab.packet.MplsLabel;
24 +import org.onlab.packet.TpPort;
24 import org.onlab.packet.VlanId; 25 import org.onlab.packet.VlanId;
25 import org.onosproject.net.IndexedLambda; 26 import org.onosproject.net.IndexedLambda;
26 import org.onosproject.net.PortNumber; 27 import org.onosproject.net.PortNumber;
...@@ -208,37 +209,73 @@ public final class DefaultTrafficSelector implements TrafficSelector { ...@@ -208,37 +209,73 @@ public final class DefaultTrafficSelector implements TrafficSelector {
208 return add(Criteria.matchIPDst(ip)); 209 return add(Criteria.matchIPDst(ip));
209 } 210 }
210 211
212 + @Deprecated
211 @Override 213 @Override
212 public Builder matchTcpSrc(short tcpPort) { 214 public Builder matchTcpSrc(short tcpPort) {
213 return add(Criteria.matchTcpSrc(tcpPort)); 215 return add(Criteria.matchTcpSrc(tcpPort));
214 } 216 }
215 217
216 @Override 218 @Override
219 + public Builder matchTcpSrc(TpPort tcpPort) {
220 + return add(Criteria.matchTcpSrc(tcpPort));
221 + }
222 +
223 + @Deprecated
224 + @Override
217 public Builder matchTcpDst(short tcpPort) { 225 public Builder matchTcpDst(short tcpPort) {
218 return add(Criteria.matchTcpDst(tcpPort)); 226 return add(Criteria.matchTcpDst(tcpPort));
219 } 227 }
220 228
221 @Override 229 @Override
230 + public Builder matchTcpDst(TpPort tcpPort) {
231 + return add(Criteria.matchTcpDst(tcpPort));
232 + }
233 +
234 + @Deprecated
235 + @Override
222 public Builder matchUdpSrc(short udpPort) { 236 public Builder matchUdpSrc(short udpPort) {
223 return add(Criteria.matchUdpSrc(udpPort)); 237 return add(Criteria.matchUdpSrc(udpPort));
224 } 238 }
225 239
226 @Override 240 @Override
241 + public Builder matchUdpSrc(TpPort udpPort) {
242 + return add(Criteria.matchUdpSrc(udpPort));
243 + }
244 +
245 + @Deprecated
246 + @Override
227 public Builder matchUdpDst(short udpPort) { 247 public Builder matchUdpDst(short udpPort) {
228 return add(Criteria.matchUdpDst(udpPort)); 248 return add(Criteria.matchUdpDst(udpPort));
229 } 249 }
230 250
231 @Override 251 @Override
252 + public Builder matchUdpDst(TpPort udpPort) {
253 + return add(Criteria.matchUdpDst(udpPort));
254 + }
255 +
256 + @Deprecated
257 + @Override
232 public Builder matchSctpSrc(short sctpPort) { 258 public Builder matchSctpSrc(short sctpPort) {
233 return add(Criteria.matchSctpSrc(sctpPort)); 259 return add(Criteria.matchSctpSrc(sctpPort));
234 } 260 }
235 261
236 @Override 262 @Override
263 + public Builder matchSctpSrc(TpPort sctpPort) {
264 + return add(Criteria.matchSctpSrc(sctpPort));
265 + }
266 +
267 + @Deprecated
268 + @Override
237 public Builder matchSctpDst(short sctpPort) { 269 public Builder matchSctpDst(short sctpPort) {
238 return add(Criteria.matchSctpDst(sctpPort)); 270 return add(Criteria.matchSctpDst(sctpPort));
239 } 271 }
240 272
241 @Override 273 @Override
274 + public Builder matchSctpDst(TpPort sctpPort) {
275 + return add(Criteria.matchSctpDst(sctpPort));
276 + }
277 +
278 + @Override
242 public Builder matchIcmpType(byte icmpType) { 279 public Builder matchIcmpType(byte icmpType) {
243 return add(Criteria.matchIcmpType(icmpType)); 280 return add(Criteria.matchIcmpType(icmpType));
244 } 281 }
......
...@@ -22,6 +22,7 @@ import org.onlab.packet.EthType; ...@@ -22,6 +22,7 @@ import org.onlab.packet.EthType;
22 import org.onlab.packet.IpAddress; 22 import org.onlab.packet.IpAddress;
23 import org.onlab.packet.MacAddress; 23 import org.onlab.packet.MacAddress;
24 import org.onlab.packet.MplsLabel; 24 import org.onlab.packet.MplsLabel;
25 +import org.onlab.packet.TpPort;
25 import org.onlab.packet.VlanId; 26 import org.onlab.packet.VlanId;
26 import org.onosproject.core.GroupId; 27 import org.onosproject.core.GroupId;
27 import org.onosproject.net.IndexedLambda; 28 import org.onosproject.net.IndexedLambda;
...@@ -416,27 +417,51 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -416,27 +417,51 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
416 return add(Instructions.modTunnelId(tunnelId)); 417 return add(Instructions.modTunnelId(tunnelId));
417 } 418 }
418 419
420 + @Deprecated
419 @Override 421 @Override
420 public TrafficTreatment.Builder setTcpSrc(short port) { 422 public TrafficTreatment.Builder setTcpSrc(short port) {
421 return add(Instructions.modTcpSrc(port)); 423 return add(Instructions.modTcpSrc(port));
422 } 424 }
423 425
424 @Override 426 @Override
427 + public TrafficTreatment.Builder setTcpSrc(TpPort port) {
428 + return add(Instructions.modTcpSrc(port));
429 + }
430 +
431 + @Deprecated
432 + @Override
425 public TrafficTreatment.Builder setTcpDst(short port) { 433 public TrafficTreatment.Builder setTcpDst(short port) {
426 return add(Instructions.modTcpDst(port)); 434 return add(Instructions.modTcpDst(port));
427 } 435 }
428 436
429 @Override 437 @Override
438 + public TrafficTreatment.Builder setTcpDst(TpPort port) {
439 + return add(Instructions.modTcpDst(port));
440 + }
441 +
442 + @Deprecated
443 + @Override
430 public TrafficTreatment.Builder setUdpSrc(short port) { 444 public TrafficTreatment.Builder setUdpSrc(short port) {
431 return add(Instructions.modUdpSrc(port)); 445 return add(Instructions.modUdpSrc(port));
432 } 446 }
433 447
434 @Override 448 @Override
449 + public TrafficTreatment.Builder setUdpSrc(TpPort port) {
450 + return add(Instructions.modUdpSrc(port));
451 + }
452 +
453 + @Deprecated
454 + @Override
435 public TrafficTreatment.Builder setUdpDst(short port) { 455 public TrafficTreatment.Builder setUdpDst(short port) {
436 return add(Instructions.modUdpDst(port)); 456 return add(Instructions.modUdpDst(port));
437 } 457 }
438 458
439 @Override 459 @Override
460 + public TrafficTreatment.Builder setUdpDst(TpPort port) {
461 + return add(Instructions.modUdpDst(port));
462 + }
463 +
464 + @Override
440 public TrafficTreatment build() { 465 public TrafficTreatment build() {
441 //Don't add DROP instruction by default when instruction 466 //Don't add DROP instruction by default when instruction
442 //set is empty. This will be handled in DefaultSingleTablePipeline 467 //set is empty. This will be handled in DefaultSingleTablePipeline
......
...@@ -17,14 +17,15 @@ package org.onosproject.net.flow; ...@@ -17,14 +17,15 @@ package org.onosproject.net.flow;
17 17
18 import java.util.Set; 18 import java.util.Set;
19 19
20 -import org.onosproject.net.PortNumber;
21 -import org.onosproject.net.flow.DefaultTrafficSelector.Builder;
22 -import org.onosproject.net.flow.criteria.Criterion;
23 -import org.onlab.packet.IpPrefix;
24 import org.onlab.packet.Ip6Address; 20 import org.onlab.packet.Ip6Address;
21 +import org.onlab.packet.IpPrefix;
25 import org.onlab.packet.MacAddress; 22 import org.onlab.packet.MacAddress;
26 import org.onlab.packet.MplsLabel; 23 import org.onlab.packet.MplsLabel;
24 +import org.onlab.packet.TpPort;
27 import org.onlab.packet.VlanId; 25 import org.onlab.packet.VlanId;
26 +import org.onosproject.net.PortNumber;
27 +import org.onosproject.net.flow.DefaultTrafficSelector.Builder;
28 +import org.onosproject.net.flow.criteria.Criterion;
28 29
29 /** 30 /**
30 * Abstraction of a slice of network traffic. 31 * Abstraction of a slice of network traffic.
...@@ -170,50 +171,110 @@ public interface TrafficSelector { ...@@ -170,50 +171,110 @@ public interface TrafficSelector {
170 * 171 *
171 * @param tcpPort a TCP source port number 172 * @param tcpPort a TCP source port number
172 * @return a selection builder 173 * @return a selection builder
174 + * @deprecated in Drake release
173 */ 175 */
176 + @Deprecated
174 Builder matchTcpSrc(short tcpPort); 177 Builder matchTcpSrc(short tcpPort);
175 178
176 /** 179 /**
180 + * Matches a TCP source port number.
181 + *
182 + * @param tcpPort a TCP source port number
183 + * @return a selection builder
184 + */
185 + Builder matchTcpSrc(TpPort tcpPort);
186 +
187 + /**
177 * Matches a TCP destination port number. 188 * Matches a TCP destination port number.
178 * 189 *
179 * @param tcpPort a TCP destination port number 190 * @param tcpPort a TCP destination port number
180 * @return a selection builder 191 * @return a selection builder
192 + * @deprecated in Drake release
181 */ 193 */
194 + @Deprecated
182 Builder matchTcpDst(short tcpPort); 195 Builder matchTcpDst(short tcpPort);
183 196
184 /** 197 /**
198 + * Matches a TCP destination port number.
199 + *
200 + * @param tcpPort a TCP destination port number
201 + * @return a selection builder
202 + */
203 + Builder matchTcpDst(TpPort tcpPort);
204 +
205 + /**
185 * Matches an UDP source port number. 206 * Matches an UDP source port number.
186 * 207 *
187 * @param udpPort an UDP source port number 208 * @param udpPort an UDP source port number
188 * @return a selection builder 209 * @return a selection builder
210 + * @deprecated in Drake release
189 */ 211 */
212 + @Deprecated
190 Builder matchUdpSrc(short udpPort); 213 Builder matchUdpSrc(short udpPort);
191 214
192 /** 215 /**
216 + * Matches an UDP source port number.
217 + *
218 + * @param udpPort an UDP source port number
219 + * @return a selection builder
220 + */
221 + Builder matchUdpSrc(TpPort udpPort);
222 +
223 + /**
193 * Matches an UDP destination port number. 224 * Matches an UDP destination port number.
194 * 225 *
195 * @param udpPort an UDP destination port number 226 * @param udpPort an UDP destination port number
196 * @return a selection builder 227 * @return a selection builder
228 + * @deprecated in Drake release
197 */ 229 */
230 + @Deprecated
198 Builder matchUdpDst(short udpPort); 231 Builder matchUdpDst(short udpPort);
199 232
200 /** 233 /**
234 + * Matches an UDP destination port number.
235 + *
236 + * @param udpPort an UDP destination port number
237 + * @return a selection builder
238 + */
239 + Builder matchUdpDst(TpPort udpPort);
240 +
241 + /**
201 * Matches a SCTP source port number. 242 * Matches a SCTP source port number.
202 * 243 *
203 * @param sctpPort a SCTP source port number 244 * @param sctpPort a SCTP source port number
204 * @return a selection builder 245 * @return a selection builder
246 + * @deprecated in Drake release
205 */ 247 */
248 + @Deprecated
206 Builder matchSctpSrc(short sctpPort); 249 Builder matchSctpSrc(short sctpPort);
207 250
208 /** 251 /**
252 + * Matches a SCTP source port number.
253 + *
254 + * @param sctpPort a SCTP source port number
255 + * @return a selection builder
256 + */
257 + Builder matchSctpSrc(TpPort sctpPort);
258 +
259 + /**
209 * Matches a SCTP destination port number. 260 * Matches a SCTP destination port number.
210 * 261 *
211 * @param sctpPort a SCTP destination port number 262 * @param sctpPort a SCTP destination port number
212 * @return a selection builder 263 * @return a selection builder
264 + * @deprecated in Drake release
213 */ 265 */
266 + @Deprecated
214 Builder matchSctpDst(short sctpPort); 267 Builder matchSctpDst(short sctpPort);
215 268
216 /** 269 /**
270 + * Matches a SCTP destination port number.
271 + *
272 + * @param sctpPort a SCTP destination port number
273 + * @return a selection builder
274 + */
275 + Builder matchSctpDst(TpPort sctpPort);
276 +
277 + /**
217 * Matches an ICMP type. 278 * Matches an ICMP type.
218 * 279 *
219 * @param icmpType an ICMP type 280 * @param icmpType an ICMP type
......
...@@ -19,6 +19,7 @@ import org.onlab.packet.EthType; ...@@ -19,6 +19,7 @@ import org.onlab.packet.EthType;
19 import org.onlab.packet.IpAddress; 19 import org.onlab.packet.IpAddress;
20 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
21 import org.onlab.packet.MplsLabel; 21 import org.onlab.packet.MplsLabel;
22 +import org.onlab.packet.TpPort;
22 import org.onlab.packet.VlanId; 23 import org.onlab.packet.VlanId;
23 import org.onosproject.core.GroupId; 24 import org.onosproject.core.GroupId;
24 import org.onosproject.net.PortNumber; 25 import org.onosproject.net.PortNumber;
...@@ -346,34 +347,74 @@ public interface TrafficTreatment { ...@@ -346,34 +347,74 @@ public interface TrafficTreatment {
346 * 347 *
347 * @param port a port number 348 * @param port a port number
348 * @return a treatment builder 349 * @return a treatment builder
350 + * @deprecated in Drake release
349 */ 351 */
352 + @Deprecated
350 Builder setTcpSrc(short port); 353 Builder setTcpSrc(short port);
351 354
352 /** 355 /**
356 + * Sets the src TCP port.
357 + *
358 + * @param port a port number
359 + * @return a treatment builder
360 + */
361 + Builder setTcpSrc(TpPort port);
362 +
363 + /**
353 * Sets the dst TCP port. 364 * Sets the dst TCP port.
354 * 365 *
355 * @param port a port number 366 * @param port a port number
356 * @return a treatment builder 367 * @return a treatment builder
368 + * @deprecated in Drake release
357 */ 369 */
370 + @Deprecated
358 Builder setTcpDst(short port); 371 Builder setTcpDst(short port);
359 372
360 /** 373 /**
374 + * Sets the dst TCP port.
375 + *
376 + * @param port a port number
377 + * @return a treatment builder
378 + */
379 + Builder setTcpDst(TpPort port);
380 +
381 + /**
361 * Sets the src UDP port. 382 * Sets the src UDP port.
362 * 383 *
363 * @param port a port number 384 * @param port a port number
364 * @return a treatment builder 385 * @return a treatment builder
386 + * @deprecated in Drake release
365 */ 387 */
388 + @Deprecated
366 Builder setUdpSrc(short port); 389 Builder setUdpSrc(short port);
367 390
368 /** 391 /**
392 + * Sets the src UDP port.
393 + *
394 + * @param port a port number
395 + * @return a treatment builder
396 + */
397 + Builder setUdpSrc(TpPort port);
398 +
399 + /**
369 * Sets the dst UDP port. 400 * Sets the dst UDP port.
370 * 401 *
371 * @param port a port number 402 * @param port a port number
372 * @return a treatment builder 403 * @return a treatment builder
404 + * @deprecated in Drake release
373 */ 405 */
406 + @Deprecated
374 Builder setUdpDst(short port); 407 Builder setUdpDst(short port);
375 408
376 /** 409 /**
410 + * Sets the dst UDP port.
411 + *
412 + * @param port a port number
413 + * @return a treatment builder
414 + */
415 + Builder setUdpDst(TpPort port);
416 +
417 + /**
377 * Builds an immutable traffic treatment descriptor. 418 * Builds an immutable traffic treatment descriptor.
378 * <p> 419 * <p>
379 * If the treatment is empty when build() is called, it will add a default 420 * If the treatment is empty when build() is called, it will add a default
......
...@@ -16,16 +16,17 @@ ...@@ -16,16 +16,17 @@
16 package org.onosproject.net.flow.criteria; 16 package org.onosproject.net.flow.criteria;
17 17
18 import org.onlab.packet.EthType; 18 import org.onlab.packet.EthType;
19 +import org.onlab.packet.Ip6Address;
20 +import org.onlab.packet.IpPrefix;
21 +import org.onlab.packet.MacAddress;
22 +import org.onlab.packet.MplsLabel;
23 +import org.onlab.packet.TpPort;
24 +import org.onlab.packet.VlanId;
19 import org.onosproject.net.IndexedLambda; 25 import org.onosproject.net.IndexedLambda;
20 import org.onosproject.net.Lambda; 26 import org.onosproject.net.Lambda;
21 import org.onosproject.net.OchSignal; 27 import org.onosproject.net.OchSignal;
22 import org.onosproject.net.PortNumber; 28 import org.onosproject.net.PortNumber;
23 import org.onosproject.net.flow.criteria.Criterion.Type; 29 import org.onosproject.net.flow.criteria.Criterion.Type;
24 -import org.onlab.packet.IpPrefix;
25 -import org.onlab.packet.Ip6Address;
26 -import org.onlab.packet.MacAddress;
27 -import org.onlab.packet.MplsLabel;
28 -import org.onlab.packet.VlanId;
29 import org.onosproject.net.OchSignalType; 30 import org.onosproject.net.OchSignalType;
30 31
31 /** 32 /**
...@@ -184,50 +185,110 @@ public final class Criteria { ...@@ -184,50 +185,110 @@ public final class Criteria {
184 /** 185 /**
185 * Creates a match on TCP source port field using the specified value. 186 * Creates a match on TCP source port field using the specified value.
186 * 187 *
187 - * @param tcpPort TCP source port (16 bits unsigned integer) 188 + * @param tcpPort TCP source port
189 + * @return match criterion
190 + * @deprecated in Drake release
191 + */
192 + @Deprecated
193 + public static Criterion matchTcpSrc(short tcpPort) {
194 + return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
195 + }
196 +
197 + /**
198 + * Creates a match on TCP source port field using the specified value.
199 + *
200 + * @param tcpPort TCP source port
188 * @return match criterion 201 * @return match criterion
189 */ 202 */
190 - public static Criterion matchTcpSrc(int tcpPort) { 203 + public static Criterion matchTcpSrc(TpPort tcpPort) {
191 return new TcpPortCriterion(tcpPort, Type.TCP_SRC); 204 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
192 } 205 }
193 206
194 /** 207 /**
195 * Creates a match on TCP destination port field using the specified value. 208 * Creates a match on TCP destination port field using the specified value.
196 * 209 *
197 - * @param tcpPort TCP destination port (16 bits unsigned integer) 210 + * @param tcpPort TCP destination port
198 * @return match criterion 211 * @return match criterion
212 + * @deprecated in Drake release
199 */ 213 */
200 - public static Criterion matchTcpDst(int tcpPort) { 214 + @Deprecated
215 + public static Criterion matchTcpDst(short tcpPort) {
216 + return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
217 + }
218 +
219 + /**
220 + * Creates a match on TCP destination port field using the specified value.
221 + *
222 + * @param tcpPort TCP destination port
223 + * @return match criterion
224 + */
225 + public static Criterion matchTcpDst(TpPort tcpPort) {
201 return new TcpPortCriterion(tcpPort, Type.TCP_DST); 226 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
202 } 227 }
203 228
204 /** 229 /**
205 * Creates a match on UDP source port field using the specified value. 230 * Creates a match on UDP source port field using the specified value.
206 * 231 *
207 - * @param udpPort UDP source port (16 bits unsigned integer) 232 + * @param udpPort UDP source port
208 * @return match criterion 233 * @return match criterion
234 + * @deprecated in Drake release
209 */ 235 */
210 - public static Criterion matchUdpSrc(int udpPort) { 236 + @Deprecated
237 + public static Criterion matchUdpSrc(short udpPort) {
238 + return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
239 + }
240 +
241 + /**
242 + * Creates a match on UDP source port field using the specified value.
243 + *
244 + * @param udpPort UDP source port
245 + * @return match criterion
246 + */
247 + public static Criterion matchUdpSrc(TpPort udpPort) {
211 return new UdpPortCriterion(udpPort, Type.UDP_SRC); 248 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
212 } 249 }
213 250
214 /** 251 /**
215 * Creates a match on UDP destination port field using the specified value. 252 * Creates a match on UDP destination port field using the specified value.
216 * 253 *
217 - * @param udpPort UDP destination port (16 bits unsigned integer) 254 + * @param udpPort UDP destination port
218 * @return match criterion 255 * @return match criterion
256 + * @deprecated in Drake release
219 */ 257 */
220 - public static Criterion matchUdpDst(int udpPort) { 258 + @Deprecated
259 + public static Criterion matchUdpDst(short udpPort) {
260 + return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
261 + }
262 +
263 + /**
264 + * Creates a match on UDP destination port field using the specified value.
265 + *
266 + * @param udpPort UDP destination port
267 + * @return match criterion
268 + */
269 + public static Criterion matchUdpDst(TpPort udpPort) {
221 return new UdpPortCriterion(udpPort, Type.UDP_DST); 270 return new UdpPortCriterion(udpPort, Type.UDP_DST);
222 } 271 }
223 272
224 /** 273 /**
225 * Creates a match on SCTP source port field using the specified value. 274 * Creates a match on SCTP source port field using the specified value.
226 * 275 *
227 - * @param sctpPort SCTP source port (16 bits unsigned integer) 276 + * @param sctpPort SCTP source port
228 * @return match criterion 277 * @return match criterion
278 + * @deprecated in Drake release
229 */ 279 */
230 - public static Criterion matchSctpSrc(int sctpPort) { 280 + @Deprecated
281 + public static Criterion matchSctpSrc(short sctpPort) {
282 + return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
283 + }
284 +
285 + /**
286 + * Creates a match on SCTP source port field using the specified value.
287 + *
288 + * @param sctpPort SCTP source port
289 + * @return match criterion
290 + */
291 + public static Criterion matchSctpSrc(TpPort sctpPort) {
231 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC); 292 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
232 } 293 }
233 294
...@@ -235,10 +296,23 @@ public final class Criteria { ...@@ -235,10 +296,23 @@ public final class Criteria {
235 * Creates a match on SCTP destination port field using the specified 296 * Creates a match on SCTP destination port field using the specified
236 * value. 297 * value.
237 * 298 *
238 - * @param sctpPort SCTP destination port (16 bits unsigned integer) 299 + * @param sctpPort SCTP destination port
300 + * @return match criterion
301 + * @deprecated in Drake release
302 + */
303 + @Deprecated
304 + public static Criterion matchSctpDst(short sctpPort) {
305 + return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
306 + }
307 +
308 + /**
309 + * Creates a match on SCTP destination port field using the specified
310 + * value.
311 + *
312 + * @param sctpPort SCTP destination port
239 * @return match criterion 313 * @return match criterion
240 */ 314 */
241 - public static Criterion matchSctpDst(int sctpPort) { 315 + public static Criterion matchSctpDst(TpPort sctpPort) {
242 return new SctpPortCriterion(sctpPort, Type.SCTP_DST); 316 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
243 } 317 }
244 318
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.flow.criteria; 16 package org.onosproject.net.flow.criteria;
17 17
18 +import org.onlab.packet.TpPort;
19 +
18 import java.util.Objects; 20 import java.util.Objects;
19 21
20 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
...@@ -23,19 +25,18 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -23,19 +25,18 @@ import static com.google.common.base.MoreObjects.toStringHelper;
23 * Implementation of SCTP port criterion (16 bits unsigned integer). 25 * Implementation of SCTP port criterion (16 bits unsigned integer).
24 */ 26 */
25 public final class SctpPortCriterion implements Criterion { 27 public final class SctpPortCriterion implements Criterion {
26 - private static final int MASK = 0xffff; 28 + private final TpPort sctpPort;
27 - private final int sctpPort; // Port value: 16 bits
28 private final Type type; 29 private final Type type;
29 30
30 /** 31 /**
31 * Constructor. 32 * Constructor.
32 * 33 *
33 - * @param sctpPort the SCTP port to match (16 bits unsigned integer) 34 + * @param sctpPort the SCTP port to match
34 * @param type the match type. Should be either Type.SCTP_SRC or 35 * @param type the match type. Should be either Type.SCTP_SRC or
35 * Type.SCTP_DST 36 * Type.SCTP_DST
36 */ 37 */
37 - SctpPortCriterion(int sctpPort, Type type) { 38 + SctpPortCriterion(TpPort sctpPort, Type type) {
38 - this.sctpPort = sctpPort & MASK; 39 + this.sctpPort = sctpPort;
39 this.type = type; 40 this.type = type;
40 } 41 }
41 42
...@@ -47,9 +48,9 @@ public final class SctpPortCriterion implements Criterion { ...@@ -47,9 +48,9 @@ public final class SctpPortCriterion implements Criterion {
47 /** 48 /**
48 * Gets the SCTP port to match. 49 * Gets the SCTP port to match.
49 * 50 *
50 - * @return the SCTP port to match (16 bits unsigned integer) 51 + * @return the SCTP port to match
51 */ 52 */
52 - public int sctpPort() { 53 + public TpPort sctpPort() {
53 return this.sctpPort; 54 return this.sctpPort;
54 } 55 }
55 56
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.flow.criteria; 16 package org.onosproject.net.flow.criteria;
17 17
18 +import org.onlab.packet.TpPort;
19 +
18 import java.util.Objects; 20 import java.util.Objects;
19 21
20 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
...@@ -23,19 +25,18 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -23,19 +25,18 @@ import static com.google.common.base.MoreObjects.toStringHelper;
23 * Implementation of TCP port criterion (16 bits unsigned integer). 25 * Implementation of TCP port criterion (16 bits unsigned integer).
24 */ 26 */
25 public final class TcpPortCriterion implements Criterion { 27 public final class TcpPortCriterion implements Criterion {
26 - private static final int MASK = 0xffff; 28 + private final TpPort tcpPort;
27 - private final int tcpPort; // Port value: 16 bits
28 private final Type type; 29 private final Type type;
29 30
30 /** 31 /**
31 * Constructor. 32 * Constructor.
32 * 33 *
33 - * @param tcpPort the TCP port to match (16 bits unsigned integer) 34 + * @param tcpPort the TCP port to match
34 * @param type the match type. Should be either Type.TCP_SRC or 35 * @param type the match type. Should be either Type.TCP_SRC or
35 * Type.TCP_DST 36 * Type.TCP_DST
36 */ 37 */
37 - TcpPortCriterion(int tcpPort, Type type) { 38 + TcpPortCriterion(TpPort tcpPort, Type type) {
38 - this.tcpPort = tcpPort & MASK; 39 + this.tcpPort = tcpPort;
39 this.type = type; 40 this.type = type;
40 } 41 }
41 42
...@@ -47,9 +48,9 @@ public final class TcpPortCriterion implements Criterion { ...@@ -47,9 +48,9 @@ public final class TcpPortCriterion implements Criterion {
47 /** 48 /**
48 * Gets the TCP port to match. 49 * Gets the TCP port to match.
49 * 50 *
50 - * @return the TCP port to match (16 bits unsigned integer) 51 + * @return the TCP port to match
51 */ 52 */
52 - public int tcpPort() { 53 + public TpPort tcpPort() {
53 return this.tcpPort; 54 return this.tcpPort;
54 } 55 }
55 56
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.flow.criteria; 16 package org.onosproject.net.flow.criteria;
17 17
18 +import org.onlab.packet.TpPort;
19 +
18 import java.util.Objects; 20 import java.util.Objects;
19 21
20 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
...@@ -23,19 +25,18 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -23,19 +25,18 @@ import static com.google.common.base.MoreObjects.toStringHelper;
23 * Implementation of UDP port criterion (16 bits unsigned integer). 25 * Implementation of UDP port criterion (16 bits unsigned integer).
24 */ 26 */
25 public final class UdpPortCriterion implements Criterion { 27 public final class UdpPortCriterion implements Criterion {
26 - private static final int MASK = 0xffff; 28 + private final TpPort udpPort;
27 - private final int udpPort; // Port value: 16 bits
28 private final Type type; 29 private final Type type;
29 30
30 /** 31 /**
31 * Constructor. 32 * Constructor.
32 * 33 *
33 - * @param udpPort the UDP port to match (16 bits unsigned integer) 34 + * @param udpPort the UDP port to match
34 * @param type the match type. Should be either Type.UDP_SRC or 35 * @param type the match type. Should be either Type.UDP_SRC or
35 * Type.UDP_DST 36 * Type.UDP_DST
36 */ 37 */
37 - UdpPortCriterion(int udpPort, Type type) { 38 + UdpPortCriterion(TpPort udpPort, Type type) {
38 - this.udpPort = udpPort & MASK; 39 + this.udpPort = udpPort;
39 this.type = type; 40 this.type = type;
40 } 41 }
41 42
...@@ -47,9 +48,9 @@ public final class UdpPortCriterion implements Criterion { ...@@ -47,9 +48,9 @@ public final class UdpPortCriterion implements Criterion {
47 /** 48 /**
48 * Gets the UDP port to match. 49 * Gets the UDP port to match.
49 * 50 *
50 - * @return the UDP port to match (16 bits unsigned integer) 51 + * @return the UDP port to match
51 */ 52 */
52 - public int udpPort() { 53 + public TpPort udpPort() {
53 return this.udpPort; 54 return this.udpPort;
54 } 55 }
55 56
......
...@@ -19,6 +19,7 @@ import org.onlab.packet.EthType; ...@@ -19,6 +19,7 @@ import org.onlab.packet.EthType;
19 import org.onlab.packet.IpAddress; 19 import org.onlab.packet.IpAddress;
20 import org.onlab.packet.MacAddress; 20 import org.onlab.packet.MacAddress;
21 import org.onlab.packet.MplsLabel; 21 import org.onlab.packet.MplsLabel;
22 +import org.onlab.packet.TpPort;
22 import org.onlab.packet.VlanId; 23 import org.onlab.packet.VlanId;
23 import org.onosproject.core.GroupId; 24 import org.onosproject.core.GroupId;
24 import org.onosproject.net.IndexedLambda; 25 import org.onosproject.net.IndexedLambda;
...@@ -383,9 +384,22 @@ public final class Instructions { ...@@ -383,9 +384,22 @@ public final class Instructions {
383 * 384 *
384 * @param port the TCP port number to modify to 385 * @param port the TCP port number to modify to
385 * @return a L4 modification 386 * @return a L4 modification
387 + * @deprecated in Drake release
386 */ 388 */
389 + @Deprecated
387 public static L4ModificationInstruction modTcpSrc(short port) { 390 public static L4ModificationInstruction modTcpSrc(short port) {
388 checkNotNull(port, "Src TCP port cannot be null"); 391 checkNotNull(port, "Src TCP port cannot be null");
392 + return new ModTransportPortInstruction(L4SubType.TCP_SRC, TpPort.tpPort(port));
393 + }
394 +
395 + /**
396 + * Creates a TCP src modification.
397 + *
398 + * @param port the TCP port number to modify to
399 + * @return a L4 modification
400 + */
401 + public static L4ModificationInstruction modTcpSrc(TpPort port) {
402 + checkNotNull(port, "Src TCP port cannot be null");
389 return new ModTransportPortInstruction(L4SubType.TCP_SRC, port); 403 return new ModTransportPortInstruction(L4SubType.TCP_SRC, port);
390 } 404 }
391 405
...@@ -394,9 +408,22 @@ public final class Instructions { ...@@ -394,9 +408,22 @@ public final class Instructions {
394 * 408 *
395 * @param port the TCP port number to modify to 409 * @param port the TCP port number to modify to
396 * @return a L4 modification 410 * @return a L4 modification
411 + * @deprecated in Drake release
397 */ 412 */
413 + @Deprecated
398 public static L4ModificationInstruction modTcpDst(short port) { 414 public static L4ModificationInstruction modTcpDst(short port) {
399 checkNotNull(port, "Dst TCP port cannot be null"); 415 checkNotNull(port, "Dst TCP port cannot be null");
416 + return new ModTransportPortInstruction(L4SubType.TCP_DST, TpPort.tpPort(port));
417 + }
418 +
419 + /**
420 + * Creates a TCP dst modification.
421 + *
422 + * @param port the TCP port number to modify to
423 + * @return a L4 modification
424 + */
425 + public static L4ModificationInstruction modTcpDst(TpPort port) {
426 + checkNotNull(port, "Dst TCP port cannot be null");
400 return new ModTransportPortInstruction(L4SubType.TCP_DST, port); 427 return new ModTransportPortInstruction(L4SubType.TCP_DST, port);
401 } 428 }
402 429
...@@ -405,9 +432,22 @@ public final class Instructions { ...@@ -405,9 +432,22 @@ public final class Instructions {
405 * 432 *
406 * @param port the UDP port number to modify to 433 * @param port the UDP port number to modify to
407 * @return a L4 modification 434 * @return a L4 modification
435 + * @deprecated in Drake release
408 */ 436 */
437 + @Deprecated
409 public static L4ModificationInstruction modUdpSrc(short port) { 438 public static L4ModificationInstruction modUdpSrc(short port) {
410 checkNotNull(port, "Src UDP port cannot be null"); 439 checkNotNull(port, "Src UDP port cannot be null");
440 + return new ModTransportPortInstruction(L4SubType.UDP_SRC, TpPort.tpPort(port));
441 + }
442 +
443 + /**
444 + * Creates a UDP src modification.
445 + *
446 + * @param port the UDP port number to modify to
447 + * @return a L4 modification
448 + */
449 + public static L4ModificationInstruction modUdpSrc(TpPort port) {
450 + checkNotNull(port, "Src UDP port cannot be null");
411 return new ModTransportPortInstruction(L4SubType.UDP_SRC, port); 451 return new ModTransportPortInstruction(L4SubType.UDP_SRC, port);
412 } 452 }
413 453
...@@ -416,9 +456,22 @@ public final class Instructions { ...@@ -416,9 +456,22 @@ public final class Instructions {
416 * 456 *
417 * @param port the UDP port number to modify to 457 * @param port the UDP port number to modify to
418 * @return a L4 modification 458 * @return a L4 modification
459 + * @deprecated in Drake release
419 */ 460 */
461 + @Deprecated
420 public static L4ModificationInstruction modUdpDst(short port) { 462 public static L4ModificationInstruction modUdpDst(short port) {
421 checkNotNull(port, "Dst UDP port cannot be null"); 463 checkNotNull(port, "Dst UDP port cannot be null");
464 + return new ModTransportPortInstruction(L4SubType.UDP_DST, TpPort.tpPort(port));
465 + }
466 +
467 + /**
468 + * Creates a UDP dst modification.
469 + *
470 + * @param port the UDP port number to modify to
471 + * @return a L4 modification
472 + */
473 + public static L4ModificationInstruction modUdpDst(TpPort port) {
474 + checkNotNull(port, "Dst UDP port cannot be null");
422 return new ModTransportPortInstruction(L4SubType.UDP_DST, port); 475 return new ModTransportPortInstruction(L4SubType.UDP_DST, port);
423 } 476 }
424 477
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
15 */ 15 */
16 package org.onosproject.net.flow.instructions; 16 package org.onosproject.net.flow.instructions;
17 17
18 +import org.onlab.packet.TpPort;
19 +
18 import java.util.Objects; 20 import java.util.Objects;
19 21
20 import static com.google.common.base.MoreObjects.toStringHelper; 22 import static com.google.common.base.MoreObjects.toStringHelper;
...@@ -69,9 +71,9 @@ public abstract class L4ModificationInstruction implements Instruction { ...@@ -69,9 +71,9 @@ public abstract class L4ModificationInstruction implements Instruction {
69 public static final class ModTransportPortInstruction extends L4ModificationInstruction { 71 public static final class ModTransportPortInstruction extends L4ModificationInstruction {
70 72
71 private final L4SubType subtype; 73 private final L4SubType subtype;
72 - private final short port; 74 + private final TpPort port;
73 75
74 - public ModTransportPortInstruction(L4SubType subtype, short port) { 76 + public ModTransportPortInstruction(L4SubType subtype, TpPort port) {
75 this.subtype = subtype; 77 this.subtype = subtype;
76 this.port = port; 78 this.port = port;
77 } 79 }
...@@ -81,7 +83,7 @@ public abstract class L4ModificationInstruction implements Instruction { ...@@ -81,7 +83,7 @@ public abstract class L4ModificationInstruction implements Instruction {
81 return this.subtype; 83 return this.subtype;
82 } 84 }
83 85
84 - public short port() { 86 + public TpPort port() {
85 return this.port; 87 return this.port;
86 } 88 }
87 89
......
...@@ -22,15 +22,16 @@ import org.hamcrest.Factory; ...@@ -22,15 +22,16 @@ import org.hamcrest.Factory;
22 import org.hamcrest.Matcher; 22 import org.hamcrest.Matcher;
23 import org.hamcrest.TypeSafeMatcher; 23 import org.hamcrest.TypeSafeMatcher;
24 import org.junit.Test; 24 import org.junit.Test;
25 -import org.onosproject.net.IndexedLambda;
26 -import org.onosproject.net.PortNumber;
27 -import org.onosproject.net.flow.criteria.Criteria;
28 -import org.onosproject.net.flow.criteria.Criterion;
29 import org.onlab.packet.Ip6Address; 25 import org.onlab.packet.Ip6Address;
30 import org.onlab.packet.IpPrefix; 26 import org.onlab.packet.IpPrefix;
31 import org.onlab.packet.MacAddress; 27 import org.onlab.packet.MacAddress;
32 import org.onlab.packet.MplsLabel; 28 import org.onlab.packet.MplsLabel;
29 +import org.onlab.packet.TpPort;
33 import org.onlab.packet.VlanId; 30 import org.onlab.packet.VlanId;
31 +import org.onosproject.net.IndexedLambda;
32 +import org.onosproject.net.PortNumber;
33 +import org.onosproject.net.flow.criteria.Criteria;
34 +import org.onosproject.net.flow.criteria.Criterion;
34 35
35 import com.google.common.testing.EqualsTester; 36 import com.google.common.testing.EqualsTester;
36 37
...@@ -196,27 +197,27 @@ public class DefaultTrafficSelectorTest { ...@@ -196,27 +197,27 @@ public class DefaultTrafficSelectorTest {
196 assertThat(selector, hasCriterionWithType(Type.IPV4_DST)); 197 assertThat(selector, hasCriterionWithType(Type.IPV4_DST));
197 198
198 selector = DefaultTrafficSelector.builder() 199 selector = DefaultTrafficSelector.builder()
199 - .matchTcpSrc(shortValue).build(); 200 + .matchTcpSrc(TpPort.tpPort(intValue)).build();
200 assertThat(selector, hasCriterionWithType(Type.TCP_SRC)); 201 assertThat(selector, hasCriterionWithType(Type.TCP_SRC));
201 202
202 selector = DefaultTrafficSelector.builder() 203 selector = DefaultTrafficSelector.builder()
203 - .matchTcpDst(shortValue).build(); 204 + .matchTcpDst(TpPort.tpPort(intValue)).build();
204 assertThat(selector, hasCriterionWithType(Type.TCP_DST)); 205 assertThat(selector, hasCriterionWithType(Type.TCP_DST));
205 206
206 selector = DefaultTrafficSelector.builder() 207 selector = DefaultTrafficSelector.builder()
207 - .matchUdpSrc(shortValue).build(); 208 + .matchUdpSrc(TpPort.tpPort(intValue)).build();
208 assertThat(selector, hasCriterionWithType(Type.UDP_SRC)); 209 assertThat(selector, hasCriterionWithType(Type.UDP_SRC));
209 210
210 selector = DefaultTrafficSelector.builder() 211 selector = DefaultTrafficSelector.builder()
211 - .matchUdpDst(shortValue).build(); 212 + .matchUdpDst(TpPort.tpPort(intValue)).build();
212 assertThat(selector, hasCriterionWithType(Type.UDP_DST)); 213 assertThat(selector, hasCriterionWithType(Type.UDP_DST));
213 214
214 selector = DefaultTrafficSelector.builder() 215 selector = DefaultTrafficSelector.builder()
215 - .matchSctpSrc(shortValue).build(); 216 + .matchSctpSrc(TpPort.tpPort(intValue)).build();
216 assertThat(selector, hasCriterionWithType(Type.SCTP_SRC)); 217 assertThat(selector, hasCriterionWithType(Type.SCTP_SRC));
217 218
218 selector = DefaultTrafficSelector.builder() 219 selector = DefaultTrafficSelector.builder()
219 - .matchSctpDst(shortValue).build(); 220 + .matchSctpDst(TpPort.tpPort(intValue)).build();
220 assertThat(selector, hasCriterionWithType(Type.SCTP_DST)); 221 assertThat(selector, hasCriterionWithType(Type.SCTP_DST));
221 222
222 selector = DefaultTrafficSelector.builder() 223 selector = DefaultTrafficSelector.builder()
......
...@@ -17,15 +17,16 @@ package org.onosproject.net.flow.criteria; ...@@ -17,15 +17,16 @@ package org.onosproject.net.flow.criteria;
17 17
18 import org.junit.Test; 18 import org.junit.Test;
19 import org.onlab.packet.EthType; 19 import org.onlab.packet.EthType;
20 -import org.onosproject.net.ChannelSpacing;
21 -import org.onosproject.net.GridType;
22 -import org.onosproject.net.Lambda;
23 -import org.onosproject.net.PortNumber;
24 -import org.onlab.packet.IpPrefix;
25 import org.onlab.packet.Ip6Address; 20 import org.onlab.packet.Ip6Address;
21 +import org.onlab.packet.IpPrefix;
26 import org.onlab.packet.MacAddress; 22 import org.onlab.packet.MacAddress;
27 import org.onlab.packet.MplsLabel; 23 import org.onlab.packet.MplsLabel;
24 +import org.onlab.packet.TpPort;
28 import org.onlab.packet.VlanId; 25 import org.onlab.packet.VlanId;
26 +import org.onosproject.net.ChannelSpacing;
27 +import org.onosproject.net.GridType;
28 +import org.onosproject.net.Lambda;
29 +import org.onosproject.net.PortNumber;
29 30
30 import com.google.common.testing.EqualsTester; 31 import com.google.common.testing.EqualsTester;
31 import org.onosproject.net.OchSignalType; 32 import org.onosproject.net.OchSignalType;
...@@ -122,17 +123,19 @@ public class CriteriaTest { ...@@ -122,17 +123,19 @@ public class CriteriaTest {
122 Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61); 123 Criterion sameAsMatchIpv61 = Criteria.matchIPSrc(ipv61);
123 Criterion matchIpv62 = Criteria.matchIPSrc(ipv62); 124 Criterion matchIpv62 = Criteria.matchIPSrc(ipv62);
124 125
125 - Criterion matchTcpPort1 = Criteria.matchTcpSrc(1); 126 + private TpPort tpPort1 = TpPort.tpPort(1);
126 - Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(1); 127 + private TpPort tpPort2 = TpPort.tpPort(2);
127 - Criterion matchTcpPort2 = Criteria.matchTcpDst(2); 128 + Criterion matchTcpPort1 = Criteria.matchTcpSrc(tpPort1);
129 + Criterion sameAsMatchTcpPort1 = Criteria.matchTcpSrc(tpPort1);
130 + Criterion matchTcpPort2 = Criteria.matchTcpDst(tpPort2);
128 131
129 - Criterion matchUdpPort1 = Criteria.matchUdpSrc(1); 132 + Criterion matchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
130 - Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(1); 133 + Criterion sameAsMatchUdpPort1 = Criteria.matchUdpSrc(tpPort1);
131 - Criterion matchUdpPort2 = Criteria.matchUdpDst(2); 134 + Criterion matchUdpPort2 = Criteria.matchUdpDst(tpPort2);
132 135
133 - Criterion matchSctpPort1 = Criteria.matchSctpSrc(1); 136 + Criterion matchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
134 - Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(1); 137 + Criterion sameAsMatchSctpPort1 = Criteria.matchSctpSrc(tpPort1);
135 - Criterion matchSctpPort2 = Criteria.matchSctpDst(2); 138 + Criterion matchSctpPort2 = Criteria.matchSctpDst(tpPort2);
136 139
137 short icmpType1 = 1; 140 short icmpType1 = 1;
138 short icmpType2 = 2; 141 short icmpType2 = 2;
...@@ -652,12 +655,12 @@ public class CriteriaTest { ...@@ -652,12 +655,12 @@ public class CriteriaTest {
652 */ 655 */
653 @Test 656 @Test
654 public void testMatchTcpSrcMethod() { 657 public void testMatchTcpSrcMethod() {
655 - Criterion matchTcpSrc = Criteria.matchTcpSrc(1); 658 + Criterion matchTcpSrc = Criteria.matchTcpSrc(tpPort1);
656 TcpPortCriterion tcpPortCriterion = 659 TcpPortCriterion tcpPortCriterion =
657 checkAndConvert(matchTcpSrc, 660 checkAndConvert(matchTcpSrc,
658 Criterion.Type.TCP_SRC, 661 Criterion.Type.TCP_SRC,
659 TcpPortCriterion.class); 662 TcpPortCriterion.class);
660 - assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1))); 663 + assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
661 } 664 }
662 665
663 /** 666 /**
...@@ -665,12 +668,12 @@ public class CriteriaTest { ...@@ -665,12 +668,12 @@ public class CriteriaTest {
665 */ 668 */
666 @Test 669 @Test
667 public void testMatchTcpDstMethod() { 670 public void testMatchTcpDstMethod() {
668 - Criterion matchTcpDst = Criteria.matchTcpDst(1); 671 + Criterion matchTcpDst = Criteria.matchTcpDst(tpPort1);
669 TcpPortCriterion tcpPortCriterion = 672 TcpPortCriterion tcpPortCriterion =
670 checkAndConvert(matchTcpDst, 673 checkAndConvert(matchTcpDst,
671 Criterion.Type.TCP_DST, 674 Criterion.Type.TCP_DST,
672 TcpPortCriterion.class); 675 TcpPortCriterion.class);
673 - assertThat(tcpPortCriterion.tcpPort(), is(equalTo(1))); 676 + assertThat(tcpPortCriterion.tcpPort(), is(equalTo(tpPort1)));
674 } 677 }
675 678
676 /** 679 /**
...@@ -691,12 +694,12 @@ public class CriteriaTest { ...@@ -691,12 +694,12 @@ public class CriteriaTest {
691 */ 694 */
692 @Test 695 @Test
693 public void testMatchUdpSrcMethod() { 696 public void testMatchUdpSrcMethod() {
694 - Criterion matchUdpSrc = Criteria.matchUdpSrc(1); 697 + Criterion matchUdpSrc = Criteria.matchUdpSrc(tpPort1);
695 UdpPortCriterion udpPortCriterion = 698 UdpPortCriterion udpPortCriterion =
696 checkAndConvert(matchUdpSrc, 699 checkAndConvert(matchUdpSrc,
697 Criterion.Type.UDP_SRC, 700 Criterion.Type.UDP_SRC,
698 UdpPortCriterion.class); 701 UdpPortCriterion.class);
699 - assertThat(udpPortCriterion.udpPort(), is(equalTo(1))); 702 + assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
700 } 703 }
701 704
702 /** 705 /**
...@@ -704,12 +707,12 @@ public class CriteriaTest { ...@@ -704,12 +707,12 @@ public class CriteriaTest {
704 */ 707 */
705 @Test 708 @Test
706 public void testMatchUdpDstMethod() { 709 public void testMatchUdpDstMethod() {
707 - Criterion matchUdpDst = Criteria.matchUdpDst(1); 710 + Criterion matchUdpDst = Criteria.matchUdpDst(tpPort1);
708 UdpPortCriterion udpPortCriterion = 711 UdpPortCriterion udpPortCriterion =
709 checkAndConvert(matchUdpDst, 712 checkAndConvert(matchUdpDst,
710 Criterion.Type.UDP_DST, 713 Criterion.Type.UDP_DST,
711 UdpPortCriterion.class); 714 UdpPortCriterion.class);
712 - assertThat(udpPortCriterion.udpPort(), is(equalTo(1))); 715 + assertThat(udpPortCriterion.udpPort(), is(equalTo(tpPort1)));
713 } 716 }
714 717
715 /** 718 /**
...@@ -730,12 +733,12 @@ public class CriteriaTest { ...@@ -730,12 +733,12 @@ public class CriteriaTest {
730 */ 733 */
731 @Test 734 @Test
732 public void testMatchSctpSrcMethod() { 735 public void testMatchSctpSrcMethod() {
733 - Criterion matchSctpSrc = Criteria.matchSctpSrc(1); 736 + Criterion matchSctpSrc = Criteria.matchSctpSrc(tpPort1);
734 SctpPortCriterion sctpPortCriterion = 737 SctpPortCriterion sctpPortCriterion =
735 checkAndConvert(matchSctpSrc, 738 checkAndConvert(matchSctpSrc,
736 Criterion.Type.SCTP_SRC, 739 Criterion.Type.SCTP_SRC,
737 SctpPortCriterion.class); 740 SctpPortCriterion.class);
738 - assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1))); 741 + assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
739 } 742 }
740 743
741 /** 744 /**
...@@ -743,12 +746,12 @@ public class CriteriaTest { ...@@ -743,12 +746,12 @@ public class CriteriaTest {
743 */ 746 */
744 @Test 747 @Test
745 public void testMatchSctpDstMethod() { 748 public void testMatchSctpDstMethod() {
746 - Criterion matchSctpDst = Criteria.matchSctpDst(1); 749 + Criterion matchSctpDst = Criteria.matchSctpDst(tpPort1);
747 SctpPortCriterion sctpPortCriterion = 750 SctpPortCriterion sctpPortCriterion =
748 checkAndConvert(matchSctpDst, 751 checkAndConvert(matchSctpDst,
749 Criterion.Type.SCTP_DST, 752 Criterion.Type.SCTP_DST,
750 SctpPortCriterion.class); 753 SctpPortCriterion.class);
751 - assertThat(sctpPortCriterion.sctpPort(), is(equalTo(1))); 754 + assertThat(sctpPortCriterion.sctpPort(), is(equalTo(tpPort1)));
752 } 755 }
753 756
754 /** 757 /**
......
...@@ -16,15 +16,16 @@ ...@@ -16,15 +16,16 @@
16 package org.onosproject.net.flow.instructions; 16 package org.onosproject.net.flow.instructions;
17 17
18 import org.junit.Test; 18 import org.junit.Test;
19 +import org.onlab.packet.IpAddress;
20 +import org.onlab.packet.MacAddress;
21 +import org.onlab.packet.MplsLabel;
22 +import org.onlab.packet.TpPort;
23 +import org.onlab.packet.VlanId;
19 import org.onosproject.net.ChannelSpacing; 24 import org.onosproject.net.ChannelSpacing;
20 import org.onosproject.net.GridType; 25 import org.onosproject.net.GridType;
21 import org.onosproject.net.IndexedLambda; 26 import org.onosproject.net.IndexedLambda;
22 import org.onosproject.net.Lambda; 27 import org.onosproject.net.Lambda;
23 import org.onosproject.net.PortNumber; 28 import org.onosproject.net.PortNumber;
24 -import org.onlab.packet.IpAddress;
25 -import org.onlab.packet.MacAddress;
26 -import org.onlab.packet.MplsLabel;
27 -import org.onlab.packet.VlanId;
28 29
29 import com.google.common.testing.EqualsTester; 30 import com.google.common.testing.EqualsTester;
30 31
...@@ -638,22 +639,22 @@ public class InstructionsTest { ...@@ -638,22 +639,22 @@ public class InstructionsTest {
638 639
639 // ModTransportPortInstruction 640 // ModTransportPortInstruction
640 641
641 - private final short l4port1 = 1; 642 + private final TpPort tpPort1 = TpPort.tpPort(1);
642 - private final short l4port2 = 2; 643 + private final TpPort tpPort2 = TpPort.tpPort(2);
643 - private final Instruction modTransportPortInstruction1 = Instructions.modTcpSrc(l4port1); 644 + private final Instruction modTransportPortInstruction1 = Instructions.modTcpSrc(tpPort1);
644 - private final Instruction sameAsModTransportPortInstruction1 = Instructions.modTcpSrc(l4port1); 645 + private final Instruction sameAsModTransportPortInstruction1 = Instructions.modTcpSrc(tpPort1);
645 - private final Instruction modTransportPortInstruction2 = Instructions.modTcpSrc(l4port2); 646 + private final Instruction modTransportPortInstruction2 = Instructions.modTcpSrc(tpPort2);
646 647
647 /** 648 /**
648 * Test the modTcpSrc() method. 649 * Test the modTcpSrc() method.
649 */ 650 */
650 @Test 651 @Test
651 public void testModTcpSrcMethod() { 652 public void testModTcpSrcMethod() {
652 - final Instruction instruction = Instructions.modTcpSrc(l4port1); 653 + final Instruction instruction = Instructions.modTcpSrc(tpPort1);
653 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction = 654 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
654 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION, 655 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
655 L4ModificationInstruction.ModTransportPortInstruction.class); 656 L4ModificationInstruction.ModTransportPortInstruction.class);
656 - assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1))); 657 + assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
657 assertThat(modTransportPortInstruction.subtype(), 658 assertThat(modTransportPortInstruction.subtype(),
658 is(equalTo(L4ModificationInstruction.L4SubType.TCP_SRC))); 659 is(equalTo(L4ModificationInstruction.L4SubType.TCP_SRC)));
659 } 660 }
...@@ -663,11 +664,11 @@ public class InstructionsTest { ...@@ -663,11 +664,11 @@ public class InstructionsTest {
663 */ 664 */
664 @Test 665 @Test
665 public void testModTcpDstMethod() { 666 public void testModTcpDstMethod() {
666 - final Instruction instruction = Instructions.modTcpDst(l4port1); 667 + final Instruction instruction = Instructions.modTcpDst(tpPort1);
667 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction = 668 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
668 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION, 669 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
669 L4ModificationInstruction.ModTransportPortInstruction.class); 670 L4ModificationInstruction.ModTransportPortInstruction.class);
670 - assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1))); 671 + assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
671 assertThat(modTransportPortInstruction.subtype(), 672 assertThat(modTransportPortInstruction.subtype(),
672 is(equalTo(L4ModificationInstruction.L4SubType.TCP_DST))); 673 is(equalTo(L4ModificationInstruction.L4SubType.TCP_DST)));
673 } 674 }
...@@ -677,11 +678,11 @@ public class InstructionsTest { ...@@ -677,11 +678,11 @@ public class InstructionsTest {
677 */ 678 */
678 @Test 679 @Test
679 public void testModUdpSrcMethod() { 680 public void testModUdpSrcMethod() {
680 - final Instruction instruction = Instructions.modUdpSrc(l4port1); 681 + final Instruction instruction = Instructions.modUdpSrc(tpPort1);
681 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction = 682 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
682 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION, 683 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
683 L4ModificationInstruction.ModTransportPortInstruction.class); 684 L4ModificationInstruction.ModTransportPortInstruction.class);
684 - assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1))); 685 + assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
685 assertThat(modTransportPortInstruction.subtype(), 686 assertThat(modTransportPortInstruction.subtype(),
686 is(equalTo(L4ModificationInstruction.L4SubType.UDP_SRC))); 687 is(equalTo(L4ModificationInstruction.L4SubType.UDP_SRC)));
687 } 688 }
...@@ -691,11 +692,11 @@ public class InstructionsTest { ...@@ -691,11 +692,11 @@ public class InstructionsTest {
691 */ 692 */
692 @Test 693 @Test
693 public void testModUdpDstMethod() { 694 public void testModUdpDstMethod() {
694 - final Instruction instruction = Instructions.modUdpDst(l4port1); 695 + final Instruction instruction = Instructions.modUdpDst(tpPort1);
695 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction = 696 final L4ModificationInstruction.ModTransportPortInstruction modTransportPortInstruction =
696 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION, 697 checkAndConvert(instruction, Instruction.Type.L4MODIFICATION,
697 L4ModificationInstruction.ModTransportPortInstruction.class); 698 L4ModificationInstruction.ModTransportPortInstruction.class);
698 - assertThat(modTransportPortInstruction.port(), is(equalTo(l4port1))); 699 + assertThat(modTransportPortInstruction.port(), is(equalTo(tpPort1)));
699 assertThat(modTransportPortInstruction.subtype(), 700 assertThat(modTransportPortInstruction.subtype(),
700 is(equalTo(L4ModificationInstruction.L4SubType.UDP_DST))); 701 is(equalTo(L4ModificationInstruction.L4SubType.UDP_DST)));
701 } 702 }
......
...@@ -22,6 +22,7 @@ import org.onlab.packet.Ip6Address; ...@@ -22,6 +22,7 @@ import org.onlab.packet.Ip6Address;
22 import org.onlab.packet.IpPrefix; 22 import org.onlab.packet.IpPrefix;
23 import org.onlab.packet.MacAddress; 23 import org.onlab.packet.MacAddress;
24 import org.onlab.packet.MplsLabel; 24 import org.onlab.packet.MplsLabel;
25 +import org.onlab.packet.TpPort;
25 import org.onlab.packet.VlanId; 26 import org.onlab.packet.VlanId;
26 import org.onosproject.net.ChannelSpacing; 27 import org.onosproject.net.ChannelSpacing;
27 import org.onosproject.net.GridType; 28 import org.onosproject.net.GridType;
...@@ -241,8 +242,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -241,8 +242,8 @@ public final class DecodeCriterionCodecHelper {
241 private class TcpSrcDecoder implements CriterionDecoder { 242 private class TcpSrcDecoder implements CriterionDecoder {
242 @Override 243 @Override
243 public Criterion decodeCriterion(ObjectNode json) { 244 public Criterion decodeCriterion(ObjectNode json) {
244 - int tcpPort = nullIsIllegal(json.get(CriterionCodec.TCP_PORT), 245 + TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_PORT),
245 - CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt(); 246 + CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt());
246 return Criteria.matchTcpSrc(tcpPort); 247 return Criteria.matchTcpSrc(tcpPort);
247 } 248 }
248 } 249 }
...@@ -250,8 +251,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -250,8 +251,8 @@ public final class DecodeCriterionCodecHelper {
250 private class TcpDstDecoder implements CriterionDecoder { 251 private class TcpDstDecoder implements CriterionDecoder {
251 @Override 252 @Override
252 public Criterion decodeCriterion(ObjectNode json) { 253 public Criterion decodeCriterion(ObjectNode json) {
253 - int tcpPort = nullIsIllegal(json.get(CriterionCodec.TCP_PORT), 254 + TpPort tcpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.TCP_PORT),
254 - CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt(); 255 + CriterionCodec.TCP_PORT + MISSING_MEMBER_MESSAGE).asInt());
255 return Criteria.matchTcpDst(tcpPort); 256 return Criteria.matchTcpDst(tcpPort);
256 } 257 }
257 } 258 }
...@@ -259,8 +260,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -259,8 +260,8 @@ public final class DecodeCriterionCodecHelper {
259 private class UdpSrcDecoder implements CriterionDecoder { 260 private class UdpSrcDecoder implements CriterionDecoder {
260 @Override 261 @Override
261 public Criterion decodeCriterion(ObjectNode json) { 262 public Criterion decodeCriterion(ObjectNode json) {
262 - int udpPort = nullIsIllegal(json.get(CriterionCodec.UDP_PORT), 263 + TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_PORT),
263 - CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt(); 264 + CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt());
264 return Criteria.matchUdpSrc(udpPort); 265 return Criteria.matchUdpSrc(udpPort);
265 } 266 }
266 } 267 }
...@@ -268,8 +269,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -268,8 +269,8 @@ public final class DecodeCriterionCodecHelper {
268 private class UdpDstDecoder implements CriterionDecoder { 269 private class UdpDstDecoder implements CriterionDecoder {
269 @Override 270 @Override
270 public Criterion decodeCriterion(ObjectNode json) { 271 public Criterion decodeCriterion(ObjectNode json) {
271 - int udpPort = nullIsIllegal(json.get(CriterionCodec.UDP_PORT), 272 + TpPort udpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.UDP_PORT),
272 - CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt(); 273 + CriterionCodec.UDP_PORT + MISSING_MEMBER_MESSAGE).asInt());
273 return Criteria.matchUdpDst(udpPort); 274 return Criteria.matchUdpDst(udpPort);
274 } 275 }
275 } 276 }
...@@ -277,8 +278,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -277,8 +278,8 @@ public final class DecodeCriterionCodecHelper {
277 private class SctpSrcDecoder implements CriterionDecoder { 278 private class SctpSrcDecoder implements CriterionDecoder {
278 @Override 279 @Override
279 public Criterion decodeCriterion(ObjectNode json) { 280 public Criterion decodeCriterion(ObjectNode json) {
280 - int sctpPort = nullIsIllegal(json.get(CriterionCodec.SCTP_PORT), 281 + TpPort sctpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_PORT),
281 - CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt(); 282 + CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt());
282 return Criteria.matchSctpSrc(sctpPort); 283 return Criteria.matchSctpSrc(sctpPort);
283 } 284 }
284 } 285 }
...@@ -286,8 +287,8 @@ public final class DecodeCriterionCodecHelper { ...@@ -286,8 +287,8 @@ public final class DecodeCriterionCodecHelper {
286 private class SctpDstDecoder implements CriterionDecoder { 287 private class SctpDstDecoder implements CriterionDecoder {
287 @Override 288 @Override
288 public Criterion decodeCriterion(ObjectNode json) { 289 public Criterion decodeCriterion(ObjectNode json) {
289 - int sctpPort = nullIsIllegal(json.get(CriterionCodec.SCTP_PORT), 290 + TpPort sctpPort = TpPort.tpPort(nullIsIllegal(json.get(CriterionCodec.SCTP_PORT),
290 - CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt(); 291 + CriterionCodec.SCTP_PORT + MISSING_MEMBER_MESSAGE).asInt());
291 return Criteria.matchSctpDst(sctpPort); 292 return Criteria.matchSctpDst(sctpPort);
292 } 293 }
293 } 294 }
......
...@@ -228,7 +228,7 @@ public final class EncodeCriterionCodecHelper { ...@@ -228,7 +228,7 @@ public final class EncodeCriterionCodecHelper {
228 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { 228 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
229 final TcpPortCriterion tcpPortCriterion = 229 final TcpPortCriterion tcpPortCriterion =
230 (TcpPortCriterion) criterion; 230 (TcpPortCriterion) criterion;
231 - return root.put(CriterionCodec.TCP_PORT, tcpPortCriterion.tcpPort()); 231 + return root.put(CriterionCodec.TCP_PORT, tcpPortCriterion.tcpPort().toInt());
232 } 232 }
233 } 233 }
234 234
...@@ -237,7 +237,7 @@ public final class EncodeCriterionCodecHelper { ...@@ -237,7 +237,7 @@ public final class EncodeCriterionCodecHelper {
237 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { 237 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
238 final UdpPortCriterion udpPortCriterion = 238 final UdpPortCriterion udpPortCriterion =
239 (UdpPortCriterion) criterion; 239 (UdpPortCriterion) criterion;
240 - return root.put(CriterionCodec.UDP_PORT, udpPortCriterion.udpPort()); 240 + return root.put(CriterionCodec.UDP_PORT, udpPortCriterion.udpPort().toInt());
241 } 241 }
242 } 242 }
243 243
...@@ -246,7 +246,7 @@ public final class EncodeCriterionCodecHelper { ...@@ -246,7 +246,7 @@ public final class EncodeCriterionCodecHelper {
246 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { 246 public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
247 final SctpPortCriterion sctpPortCriterion = 247 final SctpPortCriterion sctpPortCriterion =
248 (SctpPortCriterion) criterion; 248 (SctpPortCriterion) criterion;
249 - return root.put(CriterionCodec.SCTP_PORT, sctpPortCriterion.sctpPort()); 249 + return root.put(CriterionCodec.SCTP_PORT, sctpPortCriterion.sctpPort().toInt());
250 } 250 }
251 } 251 }
252 252
......
...@@ -23,6 +23,7 @@ import org.onlab.packet.Ip6Address; ...@@ -23,6 +23,7 @@ import org.onlab.packet.Ip6Address;
23 import org.onlab.packet.IpPrefix; 23 import org.onlab.packet.IpPrefix;
24 import org.onlab.packet.MacAddress; 24 import org.onlab.packet.MacAddress;
25 import org.onlab.packet.MplsLabel; 25 import org.onlab.packet.MplsLabel;
26 +import org.onlab.packet.TpPort;
26 import org.onlab.packet.VlanId; 27 import org.onlab.packet.VlanId;
27 import org.onosproject.codec.CodecContext; 28 import org.onosproject.codec.CodecContext;
28 import org.onosproject.codec.JsonCodec; 29 import org.onosproject.codec.JsonCodec;
...@@ -54,6 +55,7 @@ public class CriterionCodecTest { ...@@ -54,6 +55,7 @@ public class CriterionCodecTest {
54 final IpPrefix ipPrefix4 = IpPrefix.valueOf("10.1.1.0/24"); 55 final IpPrefix ipPrefix4 = IpPrefix.valueOf("10.1.1.0/24");
55 final IpPrefix ipPrefix6 = IpPrefix.valueOf("fe80::/64"); 56 final IpPrefix ipPrefix6 = IpPrefix.valueOf("fe80::/64");
56 final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01"); 57 final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
58 + final TpPort tpPort = TpPort.tpPort(40000);
57 59
58 /** 60 /**
59 * Sets up for each test. Creates a context and fetches the criterion 61 * Sets up for each test. Creates a context and fetches the criterion
...@@ -219,7 +221,7 @@ public class CriterionCodecTest { ...@@ -219,7 +221,7 @@ public class CriterionCodecTest {
219 */ 221 */
220 @Test 222 @Test
221 public void matchTcpSrcTest() { 223 public void matchTcpSrcTest() {
222 - Criterion criterion = Criteria.matchTcpSrc((short) 40000); 224 + Criterion criterion = Criteria.matchTcpSrc(tpPort);
223 ObjectNode result = criterionCodec.encode(criterion, context); 225 ObjectNode result = criterionCodec.encode(criterion, context);
224 assertThat(result, matchesCriterion(criterion)); 226 assertThat(result, matchesCriterion(criterion));
225 } 227 }
...@@ -229,7 +231,7 @@ public class CriterionCodecTest { ...@@ -229,7 +231,7 @@ public class CriterionCodecTest {
229 */ 231 */
230 @Test 232 @Test
231 public void matchTcpDstTest() { 233 public void matchTcpDstTest() {
232 - Criterion criterion = Criteria.matchTcpDst((short) 40000); 234 + Criterion criterion = Criteria.matchTcpDst(tpPort);
233 ObjectNode result = criterionCodec.encode(criterion, context); 235 ObjectNode result = criterionCodec.encode(criterion, context);
234 assertThat(result, matchesCriterion(criterion)); 236 assertThat(result, matchesCriterion(criterion));
235 } 237 }
...@@ -239,7 +241,7 @@ public class CriterionCodecTest { ...@@ -239,7 +241,7 @@ public class CriterionCodecTest {
239 */ 241 */
240 @Test 242 @Test
241 public void matchUdpSrcTest() { 243 public void matchUdpSrcTest() {
242 - Criterion criterion = Criteria.matchUdpSrc(40000); 244 + Criterion criterion = Criteria.matchUdpSrc(tpPort);
243 ObjectNode result = criterionCodec.encode(criterion, context); 245 ObjectNode result = criterionCodec.encode(criterion, context);
244 assertThat(result, matchesCriterion(criterion)); 246 assertThat(result, matchesCriterion(criterion));
245 } 247 }
...@@ -249,7 +251,7 @@ public class CriterionCodecTest { ...@@ -249,7 +251,7 @@ public class CriterionCodecTest {
249 */ 251 */
250 @Test 252 @Test
251 public void matchUdpDstTest() { 253 public void matchUdpDstTest() {
252 - Criterion criterion = Criteria.matchUdpDst(40000); 254 + Criterion criterion = Criteria.matchUdpDst(tpPort);
253 ObjectNode result = criterionCodec.encode(criterion, context); 255 ObjectNode result = criterionCodec.encode(criterion, context);
254 assertThat(result, matchesCriterion(criterion)); 256 assertThat(result, matchesCriterion(criterion));
255 } 257 }
...@@ -259,7 +261,7 @@ public class CriterionCodecTest { ...@@ -259,7 +261,7 @@ public class CriterionCodecTest {
259 */ 261 */
260 @Test 262 @Test
261 public void matchSctpSrcTest() { 263 public void matchSctpSrcTest() {
262 - Criterion criterion = Criteria.matchSctpSrc(40000); 264 + Criterion criterion = Criteria.matchSctpSrc(tpPort);
263 ObjectNode result = criterionCodec.encode(criterion, context); 265 ObjectNode result = criterionCodec.encode(criterion, context);
264 assertThat(result, matchesCriterion(criterion)); 266 assertThat(result, matchesCriterion(criterion));
265 } 267 }
...@@ -269,7 +271,7 @@ public class CriterionCodecTest { ...@@ -269,7 +271,7 @@ public class CriterionCodecTest {
269 */ 271 */
270 @Test 272 @Test
271 public void matchSctpDstTest() { 273 public void matchSctpDstTest() {
272 - Criterion criterion = Criteria.matchSctpDst(40000); 274 + Criterion criterion = Criteria.matchSctpDst(tpPort);
273 ObjectNode result = criterionCodec.encode(criterion, context); 275 ObjectNode result = criterionCodec.encode(criterion, context);
274 assertThat(result, matchesCriterion(criterion)); 276 assertThat(result, matchesCriterion(criterion));
275 } 277 }
......
...@@ -249,7 +249,7 @@ public final class CriterionJsonMatcher extends ...@@ -249,7 +249,7 @@ public final class CriterionJsonMatcher extends
249 * @return true if the JSON matches the criterion, false otherwise. 249 * @return true if the JSON matches the criterion, false otherwise.
250 */ 250 */
251 private boolean matchCriterion(TcpPortCriterion criterion) { 251 private boolean matchCriterion(TcpPortCriterion criterion) {
252 - final int tcpPort = criterion.tcpPort(); 252 + final int tcpPort = criterion.tcpPort().toInt();
253 final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue(); 253 final int jsonTcpPort = jsonCriterion.get("tcpPort").intValue();
254 if (tcpPort != jsonTcpPort) { 254 if (tcpPort != jsonTcpPort) {
255 description.appendText("tcp port was " 255 description.appendText("tcp port was "
...@@ -266,7 +266,7 @@ public final class CriterionJsonMatcher extends ...@@ -266,7 +266,7 @@ public final class CriterionJsonMatcher extends
266 * @return true if the JSON matches the criterion, false otherwise. 266 * @return true if the JSON matches the criterion, false otherwise.
267 */ 267 */
268 private boolean matchCriterion(UdpPortCriterion criterion) { 268 private boolean matchCriterion(UdpPortCriterion criterion) {
269 - final int udpPort = criterion.udpPort(); 269 + final int udpPort = criterion.udpPort().toInt();
270 final int jsonUdpPort = jsonCriterion.get("udpPort").intValue(); 270 final int jsonUdpPort = jsonCriterion.get("udpPort").intValue();
271 if (udpPort != jsonUdpPort) { 271 if (udpPort != jsonUdpPort) {
272 description.appendText("udp port was " 272 description.appendText("udp port was "
...@@ -283,7 +283,7 @@ public final class CriterionJsonMatcher extends ...@@ -283,7 +283,7 @@ public final class CriterionJsonMatcher extends
283 * @return true if the JSON matches the criterion, false otherwise. 283 * @return true if the JSON matches the criterion, false otherwise.
284 */ 284 */
285 private boolean matchCriterion(SctpPortCriterion criterion) { 285 private boolean matchCriterion(SctpPortCriterion criterion) {
286 - final int sctpPort = criterion.sctpPort(); 286 + final int sctpPort = criterion.sctpPort().toInt();
287 final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue(); 287 final int jsonSctpPort = jsonCriterion.get("sctpPort").intValue();
288 if (sctpPort != jsonSctpPort) { 288 if (sctpPort != jsonSctpPort) {
289 description.appendText("sctp port was " 289 description.appendText("sctp port was "
......
...@@ -419,27 +419,27 @@ public class FlowRuleCodecTest { ...@@ -419,27 +419,27 @@ public class FlowRuleCodecTest {
419 is((IpPrefix.valueOf("4.2.0.0/32")))); 419 is((IpPrefix.valueOf("4.2.0.0/32"))));
420 420
421 criterion = getCriterion(Criterion.Type.TCP_SRC); 421 criterion = getCriterion(Criterion.Type.TCP_SRC);
422 - assertThat(((TcpPortCriterion) criterion).tcpPort(), 422 + assertThat(((TcpPortCriterion) criterion).tcpPort().toInt(),
423 is(80)); 423 is(80));
424 424
425 criterion = getCriterion(Criterion.Type.TCP_DST); 425 criterion = getCriterion(Criterion.Type.TCP_DST);
426 - assertThat(((TcpPortCriterion) criterion).tcpPort(), 426 + assertThat(((TcpPortCriterion) criterion).tcpPort().toInt(),
427 is(443)); 427 is(443));
428 428
429 criterion = getCriterion(Criterion.Type.UDP_SRC); 429 criterion = getCriterion(Criterion.Type.UDP_SRC);
430 - assertThat(((UdpPortCriterion) criterion).udpPort(), 430 + assertThat(((UdpPortCriterion) criterion).udpPort().toInt(),
431 is(180)); 431 is(180));
432 432
433 criterion = getCriterion(Criterion.Type.UDP_DST); 433 criterion = getCriterion(Criterion.Type.UDP_DST);
434 - assertThat(((UdpPortCriterion) criterion).udpPort(), 434 + assertThat(((UdpPortCriterion) criterion).udpPort().toInt(),
435 is(1443)); 435 is(1443));
436 436
437 criterion = getCriterion(Criterion.Type.SCTP_SRC); 437 criterion = getCriterion(Criterion.Type.SCTP_SRC);
438 - assertThat(((SctpPortCriterion) criterion).sctpPort(), 438 + assertThat(((SctpPortCriterion) criterion).sctpPort().toInt(),
439 is(280)); 439 is(280));
440 440
441 criterion = getCriterion(Criterion.Type.SCTP_DST); 441 criterion = getCriterion(Criterion.Type.SCTP_DST);
442 - assertThat(((SctpPortCriterion) criterion).sctpPort(), 442 + assertThat(((SctpPortCriterion) criterion).sctpPort().toInt(),
443 is(2443)); 443 is(2443));
444 444
445 criterion = getCriterion(Criterion.Type.ICMPV4_TYPE); 445 criterion = getCriterion(Criterion.Type.ICMPV4_TYPE);
......
...@@ -29,6 +29,7 @@ import org.onlab.packet.Ip6Prefix; ...@@ -29,6 +29,7 @@ import org.onlab.packet.Ip6Prefix;
29 import org.onlab.packet.IpAddress; 29 import org.onlab.packet.IpAddress;
30 import org.onlab.packet.IpPrefix; 30 import org.onlab.packet.IpPrefix;
31 import org.onlab.packet.MacAddress; 31 import org.onlab.packet.MacAddress;
32 +import org.onlab.packet.TpPort;
32 import org.onlab.packet.VlanId; 33 import org.onlab.packet.VlanId;
33 import org.onlab.util.Bandwidth; 34 import org.onlab.util.Bandwidth;
34 import org.onlab.util.Frequency; 35 import org.onlab.util.Frequency;
...@@ -320,6 +321,7 @@ public final class KryoNamespaces { ...@@ -320,6 +321,7 @@ public final class KryoNamespaces {
320 IPEcnCriterion.class, 321 IPEcnCriterion.class,
321 IPProtocolCriterion.class, 322 IPProtocolCriterion.class,
322 IPCriterion.class, 323 IPCriterion.class,
324 + TpPort.class,
323 TcpPortCriterion.class, 325 TcpPortCriterion.class,
324 UdpPortCriterion.class, 326 UdpPortCriterion.class,
325 SctpPortCriterion.class, 327 SctpPortCriterion.class,
......
...@@ -9,6 +9,7 @@ import com.google.common.cache.RemovalNotification; ...@@ -9,6 +9,7 @@ import com.google.common.cache.RemovalNotification;
9 import org.onlab.osgi.ServiceDirectory; 9 import org.onlab.osgi.ServiceDirectory;
10 import org.onlab.packet.Ethernet; 10 import org.onlab.packet.Ethernet;
11 import org.onlab.packet.IPv4; 11 import org.onlab.packet.IPv4;
12 +import org.onlab.packet.TpPort;
12 import org.onlab.packet.VlanId; 13 import org.onlab.packet.VlanId;
13 import org.onlab.util.KryoNamespace; 14 import org.onlab.util.KryoNamespace;
14 import org.onosproject.core.ApplicationId; 15 import org.onosproject.core.ApplicationId;
...@@ -515,7 +516,7 @@ public class CentecV350Pipeline extends AbstractHandlerBehaviour implements Pipe ...@@ -515,7 +516,7 @@ public class CentecV350Pipeline extends AbstractHandlerBehaviour implements Pipe
515 treatment = DefaultTrafficTreatment.builder(); 516 treatment = DefaultTrafficTreatment.builder();
516 selector.matchEthType(Ethernet.TYPE_IPV4) 517 selector.matchEthType(Ethernet.TYPE_IPV4)
517 .matchIPProtocol(IPv4.PROTOCOL_TCP) 518 .matchIPProtocol(IPv4.PROTOCOL_TCP)
518 - .matchTcpSrc(BGP_PORT); 519 + .matchTcpSrc(TpPort.tpPort(BGP_PORT));
519 treatment.punt(); 520 treatment.punt();
520 rule = DefaultFlowRule.builder() 521 rule = DefaultFlowRule.builder()
521 .forDevice(deviceId) 522 .forDevice(deviceId)
...@@ -531,7 +532,7 @@ public class CentecV350Pipeline extends AbstractHandlerBehaviour implements Pipe ...@@ -531,7 +532,7 @@ public class CentecV350Pipeline extends AbstractHandlerBehaviour implements Pipe
531 treatment = DefaultTrafficTreatment.builder(); 532 treatment = DefaultTrafficTreatment.builder();
532 selector.matchEthType(Ethernet.TYPE_IPV4) 533 selector.matchEthType(Ethernet.TYPE_IPV4)
533 .matchIPProtocol(IPv4.PROTOCOL_TCP) 534 .matchIPProtocol(IPv4.PROTOCOL_TCP)
534 - .matchTcpDst(BGP_PORT); 535 + .matchTcpDst(TpPort.tpPort(BGP_PORT));
535 treatment.punt(); 536 treatment.punt();
536 rule = DefaultFlowRule.builder() 537 rule = DefaultFlowRule.builder()
537 .forDevice(deviceId) 538 .forDevice(deviceId)
......
...@@ -30,6 +30,7 @@ import org.onlab.packet.Ip6Address; ...@@ -30,6 +30,7 @@ import org.onlab.packet.Ip6Address;
30 import org.onlab.packet.Ip6Prefix; 30 import org.onlab.packet.Ip6Prefix;
31 import org.onlab.packet.MacAddress; 31 import org.onlab.packet.MacAddress;
32 import org.onlab.packet.MplsLabel; 32 import org.onlab.packet.MplsLabel;
33 +import org.onlab.packet.TpPort;
33 import org.onlab.packet.VlanId; 34 import org.onlab.packet.VlanId;
34 import org.onosproject.core.DefaultGroupId; 35 import org.onosproject.core.DefaultGroupId;
35 import org.onosproject.net.DeviceId; 36 import org.onosproject.net.DeviceId;
...@@ -417,22 +418,22 @@ public class FlowEntryBuilder { ...@@ -417,22 +418,22 @@ public class FlowEntryBuilder {
417 case TCP_DST: 418 case TCP_DST:
418 @SuppressWarnings("unchecked") 419 @SuppressWarnings("unchecked")
419 OFOxm<TransportPort> tcpdst = (OFOxm<TransportPort>) oxm; 420 OFOxm<TransportPort> tcpdst = (OFOxm<TransportPort>) oxm;
420 - builder.setTcpDst((short) tcpdst.getValue().getPort()); 421 + builder.setTcpDst(TpPort.tpPort(tcpdst.getValue().getPort()));
421 break; 422 break;
422 case TCP_SRC: 423 case TCP_SRC:
423 @SuppressWarnings("unchecked") 424 @SuppressWarnings("unchecked")
424 OFOxm<TransportPort> tcpsrc = (OFOxm<TransportPort>) oxm; 425 OFOxm<TransportPort> tcpsrc = (OFOxm<TransportPort>) oxm;
425 - builder.setTcpSrc((short) tcpsrc.getValue().getPort()); 426 + builder.setTcpSrc(TpPort.tpPort(tcpsrc.getValue().getPort()));
426 break; 427 break;
427 case UDP_DST: 428 case UDP_DST:
428 @SuppressWarnings("unchecked") 429 @SuppressWarnings("unchecked")
429 OFOxm<TransportPort> udpdst = (OFOxm<TransportPort>) oxm; 430 OFOxm<TransportPort> udpdst = (OFOxm<TransportPort>) oxm;
430 - builder.setUdpDst((short) udpdst.getValue().getPort()); 431 + builder.setUdpDst(TpPort.tpPort(udpdst.getValue().getPort()));
431 break; 432 break;
432 case UDP_SRC: 433 case UDP_SRC:
433 @SuppressWarnings("unchecked") 434 @SuppressWarnings("unchecked")
434 OFOxm<TransportPort> udpsrc = (OFOxm<TransportPort>) oxm; 435 OFOxm<TransportPort> udpsrc = (OFOxm<TransportPort>) oxm;
435 - builder.setUdpSrc((short) udpsrc.getValue().getPort()); 436 + builder.setUdpSrc(TpPort.tpPort(udpsrc.getValue().getPort()));
436 break; 437 break;
437 case ARP_OP: 438 case ARP_OP:
438 case ARP_SHA: 439 case ARP_SHA:
...@@ -588,16 +589,16 @@ public class FlowEntryBuilder { ...@@ -588,16 +589,16 @@ public class FlowEntryBuilder {
588 builder.matchIPDst(ip4Prefix); 589 builder.matchIPDst(ip4Prefix);
589 break; 590 break;
590 case TCP_SRC: 591 case TCP_SRC:
591 - builder.matchTcpSrc((short) match.get(MatchField.TCP_SRC).getPort()); 592 + builder.matchTcpSrc(TpPort.tpPort(match.get(MatchField.TCP_SRC).getPort()));
592 break; 593 break;
593 case TCP_DST: 594 case TCP_DST:
594 - builder.matchTcpDst((short) match.get(MatchField.TCP_DST).getPort()); 595 + builder.matchTcpDst(TpPort.tpPort(match.get(MatchField.TCP_DST).getPort()));
595 break; 596 break;
596 case UDP_SRC: 597 case UDP_SRC:
597 - builder.matchUdpSrc((short) match.get(MatchField.UDP_SRC).getPort()); 598 + builder.matchUdpSrc(TpPort.tpPort(match.get(MatchField.UDP_SRC).getPort()));
598 break; 599 break;
599 case UDP_DST: 600 case UDP_DST:
600 - builder.matchUdpDst((short) match.get(MatchField.UDP_DST).getPort()); 601 + builder.matchUdpDst(TpPort.tpPort(match.get(MatchField.UDP_DST).getPort()));
601 break; 602 break;
602 case MPLS_LABEL: 603 case MPLS_LABEL:
603 builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL) 604 builder.matchMplsLabel(MplsLabel.mplsLabel((int) match.get(MatchField.MPLS_LABEL)
...@@ -607,10 +608,10 @@ public class FlowEntryBuilder { ...@@ -607,10 +608,10 @@ public class FlowEntryBuilder {
607 builder.matchMplsBos(match.get(MatchField.MPLS_BOS).getValue()); 608 builder.matchMplsBos(match.get(MatchField.MPLS_BOS).getValue());
608 break; 609 break;
609 case SCTP_SRC: 610 case SCTP_SRC:
610 - builder.matchSctpSrc((short) match.get(MatchField.SCTP_SRC).getPort()); 611 + builder.matchSctpSrc(TpPort.tpPort(match.get(MatchField.SCTP_SRC).getPort()));
611 break; 612 break;
612 case SCTP_DST: 613 case SCTP_DST:
613 - builder.matchSctpDst((short) match.get(MatchField.SCTP_DST).getPort()); 614 + builder.matchSctpDst(TpPort.tpPort(match.get(MatchField.SCTP_DST).getPort()));
614 break; 615 break;
615 case ICMPV4_TYPE: 616 case ICMPV4_TYPE:
616 byte icmpType = (byte) match.get(MatchField.ICMPV4_TYPE).getType(); 617 byte icmpType = (byte) match.get(MatchField.ICMPV4_TYPE).getType();
......
...@@ -268,32 +268,32 @@ public abstract class FlowModBuilder { ...@@ -268,32 +268,32 @@ public abstract class FlowModBuilder {
268 case TCP_SRC: 268 case TCP_SRC:
269 tcpPortCriterion = (TcpPortCriterion) c; 269 tcpPortCriterion = (TcpPortCriterion) c;
270 mBuilder.setExact(MatchField.TCP_SRC, 270 mBuilder.setExact(MatchField.TCP_SRC,
271 - TransportPort.of(tcpPortCriterion.tcpPort())); 271 + TransportPort.of(tcpPortCriterion.tcpPort().toInt()));
272 break; 272 break;
273 case TCP_DST: 273 case TCP_DST:
274 tcpPortCriterion = (TcpPortCriterion) c; 274 tcpPortCriterion = (TcpPortCriterion) c;
275 mBuilder.setExact(MatchField.TCP_DST, 275 mBuilder.setExact(MatchField.TCP_DST,
276 - TransportPort.of(tcpPortCriterion.tcpPort())); 276 + TransportPort.of(tcpPortCriterion.tcpPort().toInt()));
277 break; 277 break;
278 case UDP_SRC: 278 case UDP_SRC:
279 udpPortCriterion = (UdpPortCriterion) c; 279 udpPortCriterion = (UdpPortCriterion) c;
280 mBuilder.setExact(MatchField.UDP_SRC, 280 mBuilder.setExact(MatchField.UDP_SRC,
281 - TransportPort.of(udpPortCriterion.udpPort())); 281 + TransportPort.of(udpPortCriterion.udpPort().toInt()));
282 break; 282 break;
283 case UDP_DST: 283 case UDP_DST:
284 udpPortCriterion = (UdpPortCriterion) c; 284 udpPortCriterion = (UdpPortCriterion) c;
285 mBuilder.setExact(MatchField.UDP_DST, 285 mBuilder.setExact(MatchField.UDP_DST,
286 - TransportPort.of(udpPortCriterion.udpPort())); 286 + TransportPort.of(udpPortCriterion.udpPort().toInt()));
287 break; 287 break;
288 case SCTP_SRC: 288 case SCTP_SRC:
289 sctpPortCriterion = (SctpPortCriterion) c; 289 sctpPortCriterion = (SctpPortCriterion) c;
290 mBuilder.setExact(MatchField.SCTP_SRC, 290 mBuilder.setExact(MatchField.SCTP_SRC,
291 - TransportPort.of(sctpPortCriterion.sctpPort())); 291 + TransportPort.of(sctpPortCriterion.sctpPort().toInt()));
292 break; 292 break;
293 case SCTP_DST: 293 case SCTP_DST:
294 sctpPortCriterion = (SctpPortCriterion) c; 294 sctpPortCriterion = (SctpPortCriterion) c;
295 mBuilder.setExact(MatchField.SCTP_DST, 295 mBuilder.setExact(MatchField.SCTP_DST,
296 - TransportPort.of(sctpPortCriterion.sctpPort())); 296 + TransportPort.of(sctpPortCriterion.sctpPort().toInt()));
297 break; 297 break;
298 case ICMPV4_TYPE: 298 case ICMPV4_TYPE:
299 IcmpTypeCriterion icmpType = (IcmpTypeCriterion) c; 299 IcmpTypeCriterion icmpType = (IcmpTypeCriterion) c;
......
...@@ -431,19 +431,19 @@ public class FlowModBuilderVer13 extends FlowModBuilder { ...@@ -431,19 +431,19 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
431 switch (l4m.subtype()) { 431 switch (l4m.subtype()) {
432 case TCP_SRC: 432 case TCP_SRC:
433 tp = (ModTransportPortInstruction) l4m; 433 tp = (ModTransportPortInstruction) l4m;
434 - oxm = factory().oxms().tcpSrc(TransportPort.of(tp.port())); 434 + oxm = factory().oxms().tcpSrc(TransportPort.of(tp.port().toInt()));
435 break; 435 break;
436 case TCP_DST: 436 case TCP_DST:
437 tp = (ModTransportPortInstruction) l4m; 437 tp = (ModTransportPortInstruction) l4m;
438 - oxm = factory().oxms().tcpDst(TransportPort.of(tp.port())); 438 + oxm = factory().oxms().tcpDst(TransportPort.of(tp.port().toInt()));
439 break; 439 break;
440 case UDP_SRC: 440 case UDP_SRC:
441 tp = (ModTransportPortInstruction) l4m; 441 tp = (ModTransportPortInstruction) l4m;
442 - oxm = factory().oxms().udpSrc(TransportPort.of(tp.port())); 442 + oxm = factory().oxms().udpSrc(TransportPort.of(tp.port().toInt()));
443 break; 443 break;
444 case UDP_DST: 444 case UDP_DST:
445 tp = (ModTransportPortInstruction) l4m; 445 tp = (ModTransportPortInstruction) l4m;
446 - oxm = factory().oxms().udpDst(TransportPort.of(tp.port())); 446 + oxm = factory().oxms().udpDst(TransportPort.of(tp.port().toInt()));
447 break; 447 break;
448 default: 448 default:
449 log.warn("Unimplemented action type {}.", l4m.subtype()); 449 log.warn("Unimplemented action type {}.", l4m.subtype());
......
...@@ -30,8 +30,8 @@ public class TCP extends BasePacket { ...@@ -30,8 +30,8 @@ public class TCP extends BasePacket {
30 30
31 private static final short TCP_HEADER_LENGTH = 20; 31 private static final short TCP_HEADER_LENGTH = 20;
32 32
33 - protected short sourcePort; 33 + protected int sourcePort;
34 - protected short destinationPort; 34 + protected int destinationPort;
35 protected int sequence; 35 protected int sequence;
36 protected int acknowledge; 36 protected int acknowledge;
37 protected byte dataOffset; 37 protected byte dataOffset;
...@@ -46,17 +46,17 @@ public class TCP extends BasePacket { ...@@ -46,17 +46,17 @@ public class TCP extends BasePacket {
46 * 46 *
47 * @return TCP source port 47 * @return TCP source port
48 */ 48 */
49 - public short getSourcePort() { 49 + public int getSourcePort() {
50 return this.sourcePort; 50 return this.sourcePort;
51 } 51 }
52 52
53 /** 53 /**
54 * Sets TCP source port. 54 * Sets TCP source port.
55 * 55 *
56 - * @param sourcePort the sourcePort to set 56 + * @param sourcePort the sourcePort to set (unsigned 16 bits integer)
57 * @return this 57 * @return this
58 */ 58 */
59 - public TCP setSourcePort(final short sourcePort) { 59 + public TCP setSourcePort(final int sourcePort) {
60 this.sourcePort = sourcePort; 60 this.sourcePort = sourcePort;
61 return this; 61 return this;
62 } 62 }
...@@ -66,17 +66,17 @@ public class TCP extends BasePacket { ...@@ -66,17 +66,17 @@ public class TCP extends BasePacket {
66 * 66 *
67 * @return the destinationPort 67 * @return the destinationPort
68 */ 68 */
69 - public short getDestinationPort() { 69 + public int getDestinationPort() {
70 return this.destinationPort; 70 return this.destinationPort;
71 } 71 }
72 72
73 /** 73 /**
74 * Sets TCP destination port. 74 * Sets TCP destination port.
75 * 75 *
76 - * @param destinationPort the destinationPort to set 76 + * @param destinationPort the destinationPort to set (unsigned 16 bits integer)
77 * @return this 77 * @return this
78 */ 78 */
79 - public TCP setDestinationPort(final short destinationPort) { 79 + public TCP setDestinationPort(final int destinationPort) {
80 this.destinationPort = destinationPort; 80 this.destinationPort = destinationPort;
81 return this; 81 return this;
82 } 82 }
...@@ -270,8 +270,8 @@ public class TCP extends BasePacket { ...@@ -270,8 +270,8 @@ public class TCP extends BasePacket {
270 final byte[] data = new byte[length]; 270 final byte[] data = new byte[length];
271 final ByteBuffer bb = ByteBuffer.wrap(data); 271 final ByteBuffer bb = ByteBuffer.wrap(data);
272 272
273 - bb.putShort(this.sourcePort); 273 + bb.putShort((short) (this.sourcePort & 0xffff));
274 - bb.putShort(this.destinationPort); 274 + bb.putShort((short) (this.destinationPort & 0xffff));
275 bb.putInt(this.sequence); 275 bb.putInt(this.sequence);
276 bb.putInt(this.acknowledge); 276 bb.putInt(this.acknowledge);
277 bb.putShort((short) (this.flags | this.dataOffset << 12)); 277 bb.putShort((short) (this.flags | this.dataOffset << 12));
...@@ -348,8 +348,8 @@ public class TCP extends BasePacket { ...@@ -348,8 +348,8 @@ public class TCP extends BasePacket {
348 public IPacket deserialize(final byte[] data, final int offset, 348 public IPacket deserialize(final byte[] data, final int offset,
349 final int length) { 349 final int length) {
350 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); 350 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
351 - this.sourcePort = bb.getShort(); 351 + this.sourcePort = (bb.getShort() & 0xffff);
352 - this.destinationPort = bb.getShort(); 352 + this.destinationPort = (bb.getShort() & 0xffff);
353 this.sequence = bb.getInt(); 353 this.sequence = bb.getInt();
354 this.acknowledge = bb.getInt(); 354 this.acknowledge = bb.getInt();
355 this.flags = bb.getShort(); 355 this.flags = bb.getShort();
...@@ -435,8 +435,8 @@ public class TCP extends BasePacket { ...@@ -435,8 +435,8 @@ public class TCP extends BasePacket {
435 TCP tcp = new TCP(); 435 TCP tcp = new TCP();
436 436
437 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); 437 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
438 - tcp.sourcePort = bb.getShort(); 438 + tcp.sourcePort = (bb.getShort() & 0xffff);
439 - tcp.destinationPort = bb.getShort(); 439 + tcp.destinationPort = (bb.getShort() & 0xffff);
440 tcp.sequence = bb.getInt(); 440 tcp.sequence = bb.getInt();
441 tcp.acknowledge = bb.getInt(); 441 tcp.acknowledge = bb.getInt();
442 tcp.flags = bb.getShort(); 442 tcp.flags = bb.getShort();
......
...@@ -46,24 +46,24 @@ public class UDP extends BasePacket { ...@@ -46,24 +46,24 @@ public class UDP extends BasePacket {
46 46
47 } 47 }
48 48
49 - protected short sourcePort; 49 + protected int sourcePort;
50 - protected short destinationPort; 50 + protected int destinationPort;
51 protected short length; 51 protected short length;
52 protected short checksum; 52 protected short checksum;
53 53
54 /** 54 /**
55 * @return the sourcePort 55 * @return the sourcePort
56 */ 56 */
57 - public short getSourcePort() { 57 + public int getSourcePort() {
58 return this.sourcePort; 58 return this.sourcePort;
59 } 59 }
60 60
61 /** 61 /**
62 * @param sourcePort 62 * @param sourcePort
63 - * the sourcePort to set 63 + * the sourcePort to set (16 bits unsigned integer)
64 * @return this 64 * @return this
65 */ 65 */
66 - public UDP setSourcePort(final short sourcePort) { 66 + public UDP setSourcePort(final int sourcePort) {
67 this.sourcePort = sourcePort; 67 this.sourcePort = sourcePort;
68 return this; 68 return this;
69 } 69 }
...@@ -71,16 +71,16 @@ public class UDP extends BasePacket { ...@@ -71,16 +71,16 @@ public class UDP extends BasePacket {
71 /** 71 /**
72 * @return the destinationPort 72 * @return the destinationPort
73 */ 73 */
74 - public short getDestinationPort() { 74 + public int getDestinationPort() {
75 return this.destinationPort; 75 return this.destinationPort;
76 } 76 }
77 77
78 /** 78 /**
79 * @param destinationPort 79 * @param destinationPort
80 - * the destinationPort to set 80 + * the destinationPort to set (16 bits unsigned integer)
81 * @return this 81 * @return this
82 */ 82 */
83 - public UDP setDestinationPort(final short destinationPort) { 83 + public UDP setDestinationPort(final int destinationPort) {
84 this.destinationPort = destinationPort; 84 this.destinationPort = destinationPort;
85 return this; 85 return this;
86 } 86 }
...@@ -134,8 +134,8 @@ public class UDP extends BasePacket { ...@@ -134,8 +134,8 @@ public class UDP extends BasePacket {
134 final byte[] data = new byte[this.length]; 134 final byte[] data = new byte[this.length];
135 final ByteBuffer bb = ByteBuffer.wrap(data); 135 final ByteBuffer bb = ByteBuffer.wrap(data);
136 136
137 - bb.putShort(this.sourcePort); 137 + bb.putShort((short) (this.sourcePort & 0xffff));
138 - bb.putShort(this.destinationPort); 138 + bb.putShort((short) (this.destinationPort & 0xffff));
139 bb.putShort(this.length); 139 bb.putShort(this.length);
140 bb.putShort(this.checksum); 140 bb.putShort(this.checksum);
141 if (payloadData != null) { 141 if (payloadData != null) {
...@@ -200,8 +200,8 @@ public class UDP extends BasePacket { ...@@ -200,8 +200,8 @@ public class UDP extends BasePacket {
200 public IPacket deserialize(final byte[] data, final int offset, 200 public IPacket deserialize(final byte[] data, final int offset,
201 final int length) { 201 final int length) {
202 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length); 202 final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
203 - this.sourcePort = bb.getShort(); 203 + this.sourcePort = (bb.getShort() & 0xffff);
204 - this.destinationPort = bb.getShort(); 204 + this.destinationPort = (bb.getShort() & 0xffff);
205 this.length = bb.getShort(); 205 this.length = bb.getShort();
206 this.checksum = bb.getShort(); 206 this.checksum = bb.getShort();
207 207
...@@ -284,8 +284,8 @@ public class UDP extends BasePacket { ...@@ -284,8 +284,8 @@ public class UDP extends BasePacket {
284 UDP udp = new UDP(); 284 UDP udp = new UDP();
285 285
286 ByteBuffer bb = ByteBuffer.wrap(data, offset, length); 286 ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
287 - udp.sourcePort = bb.getShort(); 287 + udp.sourcePort = (bb.getShort() & 0xffff);
288 - udp.destinationPort = bb.getShort(); 288 + udp.destinationPort = (bb.getShort() & 0xffff);
289 udp.length = bb.getShort(); 289 udp.length = bb.getShort();
290 udp.checksum = bb.getShort(); 290 udp.checksum = bb.getShort();
291 291
......
...@@ -88,8 +88,8 @@ public class TCPTest { ...@@ -88,8 +88,8 @@ public class TCPTest {
88 @Test 88 @Test
89 public void testSerialize() { 89 public void testSerialize() {
90 TCP tcp = new TCP(); 90 TCP tcp = new TCP();
91 - tcp.setSourcePort((short) 0x50); 91 + tcp.setSourcePort(0x50);
92 - tcp.setDestinationPort((short) 0x60); 92 + tcp.setDestinationPort(0x60);
93 tcp.setSequence(0x10); 93 tcp.setSequence(0x10);
94 tcp.setAcknowledge(0x20); 94 tcp.setAcknowledge(0x20);
95 tcp.setDataOffset((byte) 0x5); 95 tcp.setDataOffset((byte) 0x5);
...@@ -121,8 +121,8 @@ public class TCPTest { ...@@ -121,8 +121,8 @@ public class TCPTest {
121 public void testDeserialize() throws Exception { 121 public void testDeserialize() throws Exception {
122 TCP tcp = deserializer.deserialize(bytePacketTCP4, 0, bytePacketTCP4.length); 122 TCP tcp = deserializer.deserialize(bytePacketTCP4, 0, bytePacketTCP4.length);
123 123
124 - assertThat(tcp.getSourcePort(), is((short) 0x50)); 124 + assertThat(tcp.getSourcePort(), is(0x50));
125 - assertThat(tcp.getDestinationPort(), is((short) 0x60)); 125 + assertThat(tcp.getDestinationPort(), is(0x60));
126 assertThat(tcp.getSequence(), is(0x10)); 126 assertThat(tcp.getSequence(), is(0x10));
127 assertThat(tcp.getAcknowledge(), is(0x20)); 127 assertThat(tcp.getAcknowledge(), is(0x20));
128 assertThat(tcp.getDataOffset(), is((byte) 0x5)); 128 assertThat(tcp.getDataOffset(), is((byte) 0x5));
...@@ -138,8 +138,8 @@ public class TCPTest { ...@@ -138,8 +138,8 @@ public class TCPTest {
138 @Test 138 @Test
139 public void testEqual() { 139 public void testEqual() {
140 TCP tcp1 = new TCP(); 140 TCP tcp1 = new TCP();
141 - tcp1.setSourcePort((short) 0x50); 141 + tcp1.setSourcePort(0x50);
142 - tcp1.setDestinationPort((short) 0x60); 142 + tcp1.setDestinationPort(0x60);
143 tcp1.setSequence(0x10); 143 tcp1.setSequence(0x10);
144 tcp1.setAcknowledge(0x20); 144 tcp1.setAcknowledge(0x20);
145 tcp1.setDataOffset((byte) 0x5); 145 tcp1.setDataOffset((byte) 0x5);
...@@ -148,8 +148,8 @@ public class TCPTest { ...@@ -148,8 +148,8 @@ public class TCPTest {
148 tcp1.setUrgentPointer((short) 0x1); 148 tcp1.setUrgentPointer((short) 0x1);
149 149
150 TCP tcp2 = new TCP(); 150 TCP tcp2 = new TCP();
151 - tcp2.setSourcePort((short) 0x70); 151 + tcp2.setSourcePort(0x70);
152 - tcp2.setDestinationPort((short) 0x60); 152 + tcp2.setDestinationPort(0x60);
153 tcp2.setSequence(0x10); 153 tcp2.setSequence(0x10);
154 tcp2.setAcknowledge(0x20); 154 tcp2.setAcknowledge(0x20);
155 tcp2.setDataOffset((byte) 0x5); 155 tcp2.setDataOffset((byte) 0x5);
......
...@@ -82,8 +82,8 @@ public class UDPTest { ...@@ -82,8 +82,8 @@ public class UDPTest {
82 @Test 82 @Test
83 public void testSerialize() { 83 public void testSerialize() {
84 UDP udp = new UDP(); 84 UDP udp = new UDP();
85 - udp.setSourcePort((short) 0x50); 85 + udp.setSourcePort(0x50);
86 - udp.setDestinationPort((short) 0x60); 86 + udp.setDestinationPort(0x60);
87 87
88 udp.setParent(ipv4); 88 udp.setParent(ipv4);
89 assertArrayEquals(bytePacketUDP4, udp.serialize()); 89 assertArrayEquals(bytePacketUDP4, udp.serialize());
...@@ -109,8 +109,8 @@ public class UDPTest { ...@@ -109,8 +109,8 @@ public class UDPTest {
109 public void testDeserialize() throws Exception { 109 public void testDeserialize() throws Exception {
110 UDP udp = deserializer.deserialize(bytePacketUDP4, 0, bytePacketUDP4.length); 110 UDP udp = deserializer.deserialize(bytePacketUDP4, 0, bytePacketUDP4.length);
111 111
112 - assertThat(udp.getSourcePort(), is((short) 0x50)); 112 + assertThat(udp.getSourcePort(), is(0x50));
113 - assertThat(udp.getDestinationPort(), is((short) 0x60)); 113 + assertThat(udp.getDestinationPort(), is(0x60));
114 assertThat(udp.getLength(), is((short) 8)); 114 assertThat(udp.getLength(), is((short) 8));
115 assertThat(udp.getChecksum(), is((short) 0x7bda)); 115 assertThat(udp.getChecksum(), is((short) 0x7bda));
116 } 116 }
...@@ -121,12 +121,12 @@ public class UDPTest { ...@@ -121,12 +121,12 @@ public class UDPTest {
121 @Test 121 @Test
122 public void testEqual() { 122 public void testEqual() {
123 UDP udp1 = new UDP(); 123 UDP udp1 = new UDP();
124 - udp1.setSourcePort((short) 0x50); 124 + udp1.setSourcePort(0x50);
125 - udp1.setDestinationPort((short) 0x60); 125 + udp1.setDestinationPort(0x60);
126 126
127 UDP udp2 = new UDP(); 127 UDP udp2 = new UDP();
128 - udp2.setSourcePort((short) 0x70); 128 + udp2.setSourcePort(0x70);
129 - udp2.setDestinationPort((short) 0x60); 129 + udp2.setDestinationPort(0x60);
130 130
131 assertTrue(udp1.equals(udp1)); 131 assertTrue(udp1.equals(udp1));
132 assertFalse(udp1.equals(udp2)); 132 assertFalse(udp1.equals(udp2));
......