diff options
author | Aaron Huang <huangaaron@google.com> | 2019-05-15 06:17:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-05-15 06:17:43 +0000 |
commit | 6ee95f00c2eff5a46421430e01ed8ec8e0273ce4 (patch) | |
tree | c927e1b5fa3e44f64d05145568b7a9a15e53289a /tests/src/android/net/apf/ApfTest.java | |
parent | 49fea5701093695db7732fc28b2b30056a8c4b7d (diff) | |
parent | 47178cfcd8247c87e340a9d32ffa3432dcd48198 (diff) |
Merge "apf: Remove IPv6 NAT-T keepalive related codes and ApfTest improvement"
Diffstat (limited to 'tests/src/android/net/apf/ApfTest.java')
-rw-r--r-- | tests/src/android/net/apf/ApfTest.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/src/android/net/apf/ApfTest.java b/tests/src/android/net/apf/ApfTest.java index 41c3fab..8f2b968 100644 --- a/tests/src/android/net/apf/ApfTest.java +++ b/tests/src/android/net/apf/ApfTest.java @@ -1734,7 +1734,8 @@ public class ApfTest { final int dstPort = 4500; final int slot1 = 1; // NAT-T keepalive - final byte[] payload = {(byte) 0xff}; + final byte[] kaPayload = {(byte) 0xff}; + final byte[] nonKaPayload = {(byte) 0xfe}; // src: 10.0.0.5, port: 1024 // dst: 10.0.0.6, port: 4500 @@ -1753,15 +1754,21 @@ public class ApfTest { // Verify IPv4 keepalive packet is dropped // src: 10.0.0.6, port: 4500 // dst: 10.0.0.5, port: 1024 - final byte[] nattKaPkt = ipv4UdpPacket(IPV4_KEEPALIVE_DST_ADDR, + byte[] pkt = ipv4UdpPacket(IPV4_KEEPALIVE_DST_ADDR, IPV4_KEEPALIVE_SRC_ADDR, dstPort, srcPort, 1 /* dataLength */); - System.arraycopy(payload, 0, nattKaPkt, IPV4_UDP_PAYLOAD_OFFSET, payload.length); - assertDrop(program, nattKaPkt); - // Verify IPv4 non-keepalive packet from the same source address is passed + System.arraycopy(kaPayload, 0, pkt, IPV4_UDP_PAYLOAD_OFFSET, kaPayload.length); + assertDrop(program, pkt); + + // Verify a packet with payload length 1 byte but it is not 0xff will pass the filter. + System.arraycopy(nonKaPayload, 0, pkt, IPV4_UDP_PAYLOAD_OFFSET, nonKaPayload.length); + assertPass(program, pkt); + + // Verify IPv4 non-keepalive response packet from the same source address is passed assertPass(program, ipv4UdpPacket(IPV4_KEEPALIVE_DST_ADDR, IPV4_KEEPALIVE_SRC_ADDR, dstPort, srcPort, 10 /* dataLength */)); - // Verify IPv4 non-keepalive packet from other source address is passed + + // Verify IPv4 non-keepalive response packet from other source address is passed assertPass(program, ipv4UdpPacket(IPV4_ANOTHER_ADDR, IPV4_KEEPALIVE_SRC_ADDR, dstPort, srcPort, 10 /* dataLength */)); |