test_data: add java unit tests for 1.0, some improvements
diff --git a/test_data/of10/flow_add.data b/test_data/of10/flow_add.data
index fc09a23..d1a4dd3 100644
--- a/test_data/of10/flow_add.data
+++ b/test_data/of10/flow_add.data
@@ -1,24 +1,49 @@
-- binary
-01 0e 00 70 12 34 56 78
-00 10 00 02 00 03 01 23
-45 67 89 ab cd ef 01 23
-45 67 00 00 00 00 00 00
-00 00 00 00 c0 a8 03 7f
-ff ff ff ff 00 00 00 00
-00 00 00 00 00 00 00 00
-00 00 00 05 00 00 00 00
-00 00 00 00 00 00 00 02
-00 00 00 08 ff fb 00 00
-ff ff 00 10 00 00 23 20
-00 12 00 00 00 00 00 00
-ff ff 00 10 00 5c 16 c7
-00 00 00 02 00 00 00 00
+01 0e # version, type
+00 70 # length
+12 34 56 78 # xid
+
+#### ofp_flow_mod
+00 30 00 e2 # wild cards=(OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS)
+00 03 # in_port
+01 23 45 67 89 ab # eth_src
+cd ef 01 23 45 67 # eth_dst
+00 00 # dl_vlan
+00 00 # dl_pcp, pad
+08 00 # dl_type
+00 00 00 00 # nw_tos, nw_proto, pad[2]
+c0 a8 03 7f # nw_src
+ff ff ff ff # nw_dst
+00 00 00 00 # tcp_src, tcp_dst
+
+00 00 00 00 00 00 00 00 # cookie
+00 00 # command
+00 05 # idle_timeout
+00 00 # hard_timeout
+00 00 # priority
+00 00 00 00 # buffer_id
+00 00 #out_port
+00 02 # flags (CHECK_OVERLAP)
+
+#list(ofp_action)
+00 00 00 08 # type=OUTPUT, len=8
+ff fb # port=FLOOD
+00 00 # maxLen=0
+ff ff 00 10 # type=VENDOR, len=16
+00 00 23 20 # vendor = Nicira
+00 12 # subtype=dec_ttl
+00 00 00 00 00 00 # pad(6)
+ff ff 00 10 # type=VENDOR, len=16
+00 5c 16 c7 # vendor = BSN
+00 00 00 02 # subype = set_tunnel_dst
+00 00 00 00 # tunnel dst ip
-- python
ofp.message.flow_add(
xid=0x12345678,
match=ofp.match(
- wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_DL_VLAN_PCP,
+ wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_NW_PROTO|ofp.OFPFW_TP_SRC|ofp.OFPFW_TP_DST|ofp.OFPFW_DL_VLAN_PCP|ofp.OFPFW_NW_TOS,
in_port=3,
+ eth_type=0x800,
ipv4_src=0xc0a8037f,
ipv4_dst=0xffffffff,
eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
@@ -33,13 +58,13 @@
flow_add {
xid = 0x12345678,
match = match_v1 {
- wildcards = OFPFW_DL_VLAN|OFPFW_DL_VLAN_PCP,
+ wildcards = OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS,
in_port = 3,
eth_src = 01:23:45:67:89:ab,
eth_dst = cd:ef:01:23:45:67,
vlan_vid = 0x0,
vlan_pcp = 0x0,
- eth_type = 0x0,
+ eth_type = 0x800,
ip_dscp = 0x0,
ip_proto = 0x0,
ipv4_src = 192.168.3.127,
@@ -70,20 +95,22 @@
match.fields.in_port = 3;
match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } };
match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } };
+ match.fields.eth_type = 0x800;
match.fields.ipv4_src = 0xc0a8037f;
match.fields.ipv4_dst = 0xffffffff;
OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match);
OF_MATCH_MASK_ETH_DST_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
//OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match);
//OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match);
OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
- OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
- OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match);
OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match);
- OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
- OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
of_flow_add_match_set(obj, &match);
}
{
@@ -106,3 +133,24 @@
of_list_action_append_bind(&actions, &action);
}
}
+-- java
+builder.setXid(0x12345678)
+ .setMatch(
+ factory.buildMatch()
+ .setExact(MatchField.IN_PORT, OFPort.of(3))
+ .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+ .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+ .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+ .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+ .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+ .build()
+ )
+ .setIdleTimeout(5)
+ .setFlags(Sets.immutableEnumSet(OFFlowModFlags.CHECK_OVERLAP))
+ .setActions(
+ ImmutableList.of(
+ factory.actions().output(OFPort.FLOOD, 0),
+ factory.actions().niciraDecTtl(),
+ factory.actions().bsnSetTunnelDst(0)
+ )
+ );
diff --git a/test_data/of10/flow_stats_entry.data b/test_data/of10/flow_stats_entry.data
index 2f9df64..3422064 100644
--- a/test_data/of10/flow_stats_entry.data
+++ b/test_data/of10/flow_stats_entry.data
@@ -2,12 +2,20 @@
00 68 # length
03 # table_id
00 # pad
-00 3f ff ff # match.wildcards
-00 00 00 00 # remaining match fields
-00 00 00 00 00 00 00 00 # ...
-00 00 00 00 00 00 00 00 # ...
-00 00 00 00 00 00 00 00 # ...
-00 00 00 00 00 00 00 00 # ...
+
+#### ofp_match_v1
+00 30 00 e2 # wild cards=(OFPFW_DL_VLAN|OFPFW_NW_PROTO|OFPFW_TP_SRC|OFPFW_TP_DST|OFPFW_DL_VLAN_PCP|OFPFW_NW_TOS)
+00 03 # in_port
+01 23 45 67 89 ab # eth_src
+cd ef 01 23 45 67 # eth_dst
+00 00 # dl_vlan
+00 00 # dl_pcp, pad
+08 00 # dl_type
+00 00 00 00 # nw_tos, nw_proto, pad[2]
+c0 a8 03 7f # nw_src
+ff ff ff ff # nw_dst
+00 00 00 00 # tcp_src, tcp_dst
+
00 00 00 01 # duration_sec
00 00 00 02 # duration_nsec
00 64 # priority
@@ -28,7 +36,14 @@
-- python
ofp.flow_stats_entry(
table_id=3,
- match=ofp.match(),
+ match=ofp.match(
+ wildcards=ofp.OFPFW_DL_VLAN|ofp.OFPFW_NW_PROTO|ofp.OFPFW_TP_SRC|ofp.OFPFW_TP_DST|ofp.OFPFW_DL_VLAN_PCP|ofp.OFPFW_NW_TOS,
+ in_port=3,
+ eth_type=0x800,
+ ipv4_src=0xc0a8037f,
+ ipv4_dst=0xffffffff,
+ eth_src=[0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
+ eth_dst=[0xcd, 0xef, 0x01, 0x23, 0x45, 0x67]),
duration_sec=1,
duration_nsec=2,
priority=100,
@@ -60,6 +75,7 @@
of_object_delete(obj);
}
}
+
of_flow_stats_entry_byte_count_set(obj, 1000);
of_flow_stats_entry_cookie_set(obj, 81985529216486895);
of_flow_stats_entry_duration_nsec_set(obj, 2);
@@ -68,8 +84,54 @@
of_flow_stats_entry_idle_timeout_set(obj, 5);
{
of_match_t match = { OF_VERSION_1_0 };
+ match.fields.in_port = 3;
+ match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } };
+ match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } };
+ match.fields.eth_type = 0x800;
+ match.fields.ipv4_src = 0xc0a8037f;
+ match.fields.ipv4_dst = 0xffffffff;
+ OF_MATCH_MASK_IN_PORT_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_DST_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
+ //OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match);
+ //OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match);
+ OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match);
+ //OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match);
+ OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match);
+ OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match);
+ //OF_MATCH_MASK_TCP_DST_EXACT_SET(&match);
of_flow_stats_entry_match_set(obj, &match);
}
of_flow_stats_entry_packet_count_set(obj, 10);
of_flow_stats_entry_priority_set(obj, 100);
of_flow_stats_entry_table_id_set(obj, 3);
+-- java
+ builder
+ .setTableId((short) 3)
+ .setMatch(
+ factory.buildMatch()
+ .setExact(MatchField.IN_PORT, OFPort.of(3))
+ .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+ .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+ .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+ .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+ .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+ .build()
+ )
+ .setDurationSec(1)
+ .setDurationNsec(2)
+ .setPriority(100)
+ .setIdleTimeout(5)
+ .setHardTimeout(10)
+ .setCookie(U64.of(0x0123456789abcdefL))
+ .setPacketCount(U64.of(10))
+ .setByteCount(U64.of(1000))
+ .setActions(
+ ImmutableList.<OFAction>of(
+ factory.actions().output(OFPort.of(1), 0),
+ factory.actions().output(OFPort.of(2), 0)
+ )
+ );
diff --git a/test_data/of13/flow_add.data b/test_data/of13/flow_add.data
index 049d797..692a7b9 100644
--- a/test_data/of13/flow_add.data
+++ b/test_data/of13/flow_add.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_delete.data b/test_data/of13/flow_delete.data
index 268304c..3762fab 100644
--- a/test_data/of13/flow_delete.data
+++ b/test_data/of13/flow_delete.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_delete_strict.data b/test_data/of13/flow_delete_strict.data
index 6165405..7a0347c 100644
--- a/test_data/of13/flow_delete_strict.data
+++ b/test_data/of13/flow_delete_strict.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_modify.data b/test_data/of13/flow_modify.data
index 188ab3d..620af3d 100644
--- a/test_data/of13/flow_modify.data
+++ b/test_data/of13/flow_modify.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
diff --git a/test_data/of13/flow_modify_strict.data b/test_data/of13/flow_modify_strict.data
index a40210a..79814e3 100644
--- a/test_data/of13/flow_modify_strict.data
+++ b/test_data/of13/flow_modify_strict.data
@@ -87,7 +87,7 @@
.setMatch(
factory.buildMatch()
.setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
- .setExact(MatchField.ETH_TYPE, EthType.ETH_TYPE_IPv6)
+ .setExact(MatchField.ETH_TYPE, EthType.IPv6)
.setExact(MatchField.IP_PROTO, IpProtocol.IP_PROTO_TCP)
.setMasked(MatchField.IPV6_SRC,
IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),