match-1.3: add ipv4 tcp/udp src/dst tests
diff --git a/tests-1.3/match.py b/tests-1.3/match.py
index aa4083a..b0def5a 100644
--- a/tests-1.3/match.py
+++ b/tests-1.3/match.py
@@ -595,3 +595,99 @@
self.verify_match(match, matching, nonmatching)
# TODO IPv6 protocol (ICMP)
+
+class IPv4TCPSrc(MatchTest):
+ """
+ Match on ipv4 tcp source port
+ """
+ def runTest(self):
+ match = ofp.match([
+ ofp.oxm.eth_type(0x0800),
+ ofp.oxm.ip_proto(6),
+ ofp.oxm.tcp_src(53),
+ ])
+
+ matching = {
+ "tcp sport=53": simple_tcp_packet(tcp_sport=53),
+ }
+
+ nonmatching = {
+ "tcp sport=52": simple_tcp_packet(tcp_sport=52),
+ "udp sport=53": simple_udp_packet(udp_sport=53),
+ }
+
+ self.verify_match(match, matching, nonmatching)
+
+# TODO IPv6 tcp source port
+
+class IPv4TCPDst(MatchTest):
+ """
+ Match on ipv4 tcp destination port
+ """
+ def runTest(self):
+ match = ofp.match([
+ ofp.oxm.eth_type(0x0800),
+ ofp.oxm.ip_proto(6),
+ ofp.oxm.tcp_dst(53),
+ ])
+
+ matching = {
+ "tcp dport=53": simple_tcp_packet(tcp_dport=53),
+ }
+
+ nonmatching = {
+ "tcp dport=52": simple_tcp_packet(tcp_dport=52),
+ "udp dport=53": simple_udp_packet(udp_dport=53),
+ }
+
+ self.verify_match(match, matching, nonmatching)
+
+# TODO IPv6 tcp destination port
+
+class IPv4UDPSrc(MatchTest):
+ """
+ Match on ipv4 udp source port
+ """
+ def runTest(self):
+ match = ofp.match([
+ ofp.oxm.eth_type(0x0800),
+ ofp.oxm.ip_proto(17),
+ ofp.oxm.udp_src(53),
+ ])
+
+ matching = {
+ "udp sport=53": simple_udp_packet(udp_sport=53),
+ }
+
+ nonmatching = {
+ "udp sport=52": simple_udp_packet(udp_sport=52),
+ "tcp sport=53": simple_tcp_packet(tcp_sport=53),
+ }
+
+ self.verify_match(match, matching, nonmatching)
+
+# TODO IPv6 udp source port
+
+class IPv4UDPDst(MatchTest):
+ """
+ Match on ipv4 udp destination port
+ """
+ def runTest(self):
+ match = ofp.match([
+ ofp.oxm.eth_type(0x0800),
+ ofp.oxm.ip_proto(17),
+ ofp.oxm.udp_dst(53),
+ ])
+
+ matching = {
+ "udp dport=53": simple_udp_packet(udp_dport=53),
+ }
+
+ nonmatching = {
+ "udp dport=52": simple_udp_packet(udp_dport=52),
+ "tcp dport=53": simple_tcp_packet(tcp_dport=53),
+ }
+
+ self.verify_match(match, matching, nonmatching)
+
+# TODO IPv6 udp destination port