blob: fef6416c378c1996f3a6966182498947f275cdec [file] [log] [blame]
Lorenzo Colitti174bab22014-06-12 13:41:17 +09001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.net;
18
Chalard Jean39175f22020-06-26 00:41:26 +090019import static com.android.testutils.MiscAsserts.assertEqualBothWays;
Chalard Jean39175f22020-06-26 00:41:26 +090020import static com.android.testutils.MiscAsserts.assertNotEqualEitherWay;
21import static com.android.testutils.ParcelUtils.assertParcelingIsLossless;
Chalard Jeanaf718362019-05-30 17:11:14 +090022
Hugo Benichif9c61862016-11-10 22:45:56 +090023import static org.junit.Assert.assertArrayEquals;
24import static org.junit.Assert.assertEquals;
Hugo Benichi8253be92017-08-08 13:06:04 +090025import static org.junit.Assert.assertFalse;
26import static org.junit.Assert.assertNotEquals;
Hugo Benichi8253be92017-08-08 13:06:04 +090027import static org.junit.Assert.assertTrue;
28import static org.junit.Assert.fail;
Lorenzo Colitti174bab22014-06-12 13:41:17 +090029
Brett Chabot147f6cf2019-03-04 14:14:56 -080030import androidx.test.filters.SmallTest;
31import androidx.test.runner.AndroidJUnit4;
32
Remi NGUYEN VANe3473012022-01-18 16:47:04 +090033import com.android.testutils.ConnectivityModuleTest;
34
Brett Chabot147f6cf2019-03-04 14:14:56 -080035import org.junit.Test;
36import org.junit.runner.RunWith;
Hugo Benichi8253be92017-08-08 13:06:04 +090037
38import java.net.InetAddress;
39import java.util.Random;
40
Hugo Benichi8253be92017-08-08 13:06:04 +090041@RunWith(AndroidJUnit4.class)
42@SmallTest
Remi NGUYEN VANe3473012022-01-18 16:47:04 +090043@ConnectivityModuleTest
Hugo Benichi8253be92017-08-08 13:06:04 +090044public class IpPrefixTest {
Lorenzo Colitti174bab22014-06-12 13:41:17 +090045
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090046 private static InetAddress address(String addr) {
Erik Klineb98afb02015-04-13 15:33:34 +090047 return InetAddress.parseNumericAddress(addr);
48 }
49
Lorenzo Colitti174bab22014-06-12 13:41:17 +090050 // Explicitly cast everything to byte because "error: possible loss of precision".
51 private static final byte[] IPV4_BYTES = { (byte) 192, (byte) 0, (byte) 2, (byte) 4};
52 private static final byte[] IPV6_BYTES = {
53 (byte) 0x20, (byte) 0x01, (byte) 0x0d, (byte) 0xb8,
54 (byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef,
55 (byte) 0x0f, (byte) 0x00, (byte) 0x00, (byte) 0x00,
56 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xa0
57 };
58
Hugo Benichi8253be92017-08-08 13:06:04 +090059 @Test
Lorenzo Colitti174bab22014-06-12 13:41:17 +090060 public void testConstructor() {
61 IpPrefix p;
62 try {
63 p = new IpPrefix((byte[]) null, 9);
64 fail("Expected NullPointerException: null byte array");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090065 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090066
67 try {
68 p = new IpPrefix((InetAddress) null, 10);
69 fail("Expected NullPointerException: null InetAddress");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090070 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090071
72 try {
73 p = new IpPrefix((String) null);
74 fail("Expected NullPointerException: null String");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090075 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090076
77
78 try {
79 byte[] b2 = {1, 2, 3, 4, 5};
80 p = new IpPrefix(b2, 29);
81 fail("Expected IllegalArgumentException: invalid array length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090082 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090083
84 try {
85 p = new IpPrefix("1.2.3.4");
86 fail("Expected IllegalArgumentException: no prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090087 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090088
89 try {
90 p = new IpPrefix("1.2.3.4/");
91 fail("Expected IllegalArgumentException: empty prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090092 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090093
94 try {
95 p = new IpPrefix("foo/32");
96 fail("Expected IllegalArgumentException: invalid address");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +090097 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +090098
99 try {
100 p = new IpPrefix("1/32");
101 fail("Expected IllegalArgumentException: deprecated IPv4 format");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900102 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900103
104 try {
105 p = new IpPrefix("1.2.3.256/32");
106 fail("Expected IllegalArgumentException: invalid IPv4 address");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900107 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900108
109 try {
110 p = new IpPrefix("foo/32");
111 fail("Expected IllegalArgumentException: non-address");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900112 } catch (IllegalArgumentException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900113
114 try {
115 p = new IpPrefix("f00:::/32");
116 fail("Expected IllegalArgumentException: invalid IPv6 address");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900117 } catch (IllegalArgumentException expected) { }
paulhu1013c812021-03-03 22:15:11 +0800118
119 p = new IpPrefix("/64");
120 assertEquals("::/64", p.toString());
121
122 p = new IpPrefix("/128");
123 assertEquals("::1/128", p.toString());
124
125 p = new IpPrefix("[2001:db8::123]/64");
126 assertEquals("2001:db8::/64", p.toString());
Taras Antoshchuk3bbbffe2021-12-19 11:54:56 +0000127
128 p = new IpPrefix(InetAddresses.parseNumericAddress("::128"), 64);
129 assertEquals("::/64", p.toString());
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900130 }
131
Hugo Benichi8253be92017-08-08 13:06:04 +0900132 @Test
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900133 public void testTruncation() {
134 IpPrefix p;
135
136 p = new IpPrefix(IPV4_BYTES, 32);
137 assertEquals("192.0.2.4/32", p.toString());
138
139 p = new IpPrefix(IPV4_BYTES, 29);
140 assertEquals("192.0.2.0/29", p.toString());
141
142 p = new IpPrefix(IPV4_BYTES, 8);
143 assertEquals("192.0.0.0/8", p.toString());
144
145 p = new IpPrefix(IPV4_BYTES, 0);
146 assertEquals("0.0.0.0/0", p.toString());
147
148 try {
149 p = new IpPrefix(IPV4_BYTES, 33);
150 fail("Expected IllegalArgumentException: invalid prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900151 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900152
153 try {
154 p = new IpPrefix(IPV4_BYTES, 128);
155 fail("Expected IllegalArgumentException: invalid prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900156 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900157
158 try {
159 p = new IpPrefix(IPV4_BYTES, -1);
160 fail("Expected IllegalArgumentException: negative prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900161 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900162
163 p = new IpPrefix(IPV6_BYTES, 128);
164 assertEquals("2001:db8:dead:beef:f00::a0/128", p.toString());
165
166 p = new IpPrefix(IPV6_BYTES, 122);
167 assertEquals("2001:db8:dead:beef:f00::80/122", p.toString());
168
169 p = new IpPrefix(IPV6_BYTES, 64);
170 assertEquals("2001:db8:dead:beef::/64", p.toString());
171
172 p = new IpPrefix(IPV6_BYTES, 3);
173 assertEquals("2000::/3", p.toString());
174
175 p = new IpPrefix(IPV6_BYTES, 0);
176 assertEquals("::/0", p.toString());
177
178 try {
179 p = new IpPrefix(IPV6_BYTES, -1);
180 fail("Expected IllegalArgumentException: negative prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900181 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900182
183 try {
184 p = new IpPrefix(IPV6_BYTES, 129);
185 fail("Expected IllegalArgumentException: negative prefix length");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900186 } catch (RuntimeException expected) { }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900187
188 }
189
Hugo Benichi8253be92017-08-08 13:06:04 +0900190 @Test
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900191 public void testEquals() {
192 IpPrefix p1, p2;
193
194 p1 = new IpPrefix("192.0.2.251/23");
195 p2 = new IpPrefix(new byte[]{(byte) 192, (byte) 0, (byte) 2, (byte) 251}, 23);
Chalard Jeanaf718362019-05-30 17:11:14 +0900196 assertEqualBothWays(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900197
198 p1 = new IpPrefix("192.0.2.5/23");
Chalard Jeanaf718362019-05-30 17:11:14 +0900199 assertEqualBothWays(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900200
201 p1 = new IpPrefix("192.0.2.5/24");
Chalard Jeanaf718362019-05-30 17:11:14 +0900202 assertNotEqualEitherWay(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900203
204 p1 = new IpPrefix("192.0.4.5/23");
Chalard Jeanaf718362019-05-30 17:11:14 +0900205 assertNotEqualEitherWay(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900206
207
208 p1 = new IpPrefix("2001:db8:dead:beef:f00::80/122");
209 p2 = new IpPrefix(IPV6_BYTES, 122);
210 assertEquals("2001:db8:dead:beef:f00::80/122", p2.toString());
Chalard Jeanaf718362019-05-30 17:11:14 +0900211 assertEqualBothWays(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900212
213 p1 = new IpPrefix("2001:db8:dead:beef:f00::bf/122");
Chalard Jeanaf718362019-05-30 17:11:14 +0900214 assertEqualBothWays(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900215
216 p1 = new IpPrefix("2001:db8:dead:beef:f00::8:0/123");
Chalard Jeanaf718362019-05-30 17:11:14 +0900217 assertNotEqualEitherWay(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900218
219 p1 = new IpPrefix("2001:db8:dead:beef::/122");
Chalard Jeanaf718362019-05-30 17:11:14 +0900220 assertNotEqualEitherWay(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900221
222 // 192.0.2.4/32 != c000:0204::/32.
223 byte[] ipv6bytes = new byte[16];
224 System.arraycopy(IPV4_BYTES, 0, ipv6bytes, 0, IPV4_BYTES.length);
225 p1 = new IpPrefix(ipv6bytes, 32);
Chalard Jeanaf718362019-05-30 17:11:14 +0900226 assertEqualBothWays(p1, new IpPrefix("c000:0204::/32"));
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900227
228 p2 = new IpPrefix(IPV4_BYTES, 32);
Chalard Jeanaf718362019-05-30 17:11:14 +0900229 assertNotEqualEitherWay(p1, p2);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900230 }
231
Hugo Benichi8253be92017-08-08 13:06:04 +0900232 @Test
Chalard Jean9cbc8822018-02-26 11:52:46 +0900233 public void testContainsInetAddress() {
Erik Klineb98afb02015-04-13 15:33:34 +0900234 IpPrefix p = new IpPrefix("2001:db8:f00::ace:d00d/127");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900235 assertTrue(p.contains(address("2001:db8:f00::ace:d00c")));
236 assertTrue(p.contains(address("2001:db8:f00::ace:d00d")));
237 assertFalse(p.contains(address("2001:db8:f00::ace:d00e")));
238 assertFalse(p.contains(address("2001:db8:f00::bad:d00d")));
239 assertFalse(p.contains(address("2001:4868:4860::8888")));
240 assertFalse(p.contains(address("8.8.8.8")));
Erik Klineb98afb02015-04-13 15:33:34 +0900241
242 p = new IpPrefix("192.0.2.0/23");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900243 assertTrue(p.contains(address("192.0.2.43")));
244 assertTrue(p.contains(address("192.0.3.21")));
245 assertFalse(p.contains(address("192.0.0.21")));
246 assertFalse(p.contains(address("8.8.8.8")));
247 assertFalse(p.contains(address("2001:4868:4860::8888")));
Erik Klineb98afb02015-04-13 15:33:34 +0900248
249 IpPrefix ipv6Default = new IpPrefix("::/0");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900250 assertTrue(ipv6Default.contains(address("2001:db8::f00")));
251 assertFalse(ipv6Default.contains(address("192.0.2.1")));
Erik Klineb98afb02015-04-13 15:33:34 +0900252
253 IpPrefix ipv4Default = new IpPrefix("0.0.0.0/0");
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900254 assertTrue(ipv4Default.contains(address("255.255.255.255")));
255 assertTrue(ipv4Default.contains(address("192.0.2.1")));
256 assertFalse(ipv4Default.contains(address("2001:db8::f00")));
Erik Klineb98afb02015-04-13 15:33:34 +0900257 }
258
Hugo Benichi8253be92017-08-08 13:06:04 +0900259 @Test
Chalard Jean9cbc8822018-02-26 11:52:46 +0900260 public void testContainsIpPrefix() {
261 assertTrue(new IpPrefix("0.0.0.0/0").containsPrefix(new IpPrefix("0.0.0.0/0")));
262 assertTrue(new IpPrefix("0.0.0.0/0").containsPrefix(new IpPrefix("1.2.3.4/0")));
263 assertTrue(new IpPrefix("0.0.0.0/0").containsPrefix(new IpPrefix("1.2.3.4/8")));
264 assertTrue(new IpPrefix("0.0.0.0/0").containsPrefix(new IpPrefix("1.2.3.4/24")));
265 assertTrue(new IpPrefix("0.0.0.0/0").containsPrefix(new IpPrefix("1.2.3.4/23")));
266
267 assertTrue(new IpPrefix("1.2.3.4/8").containsPrefix(new IpPrefix("1.2.3.4/8")));
268 assertTrue(new IpPrefix("1.2.3.4/8").containsPrefix(new IpPrefix("1.254.12.9/8")));
269 assertTrue(new IpPrefix("1.2.3.4/21").containsPrefix(new IpPrefix("1.2.3.4/21")));
270 assertTrue(new IpPrefix("1.2.3.4/32").containsPrefix(new IpPrefix("1.2.3.4/32")));
271
272 assertTrue(new IpPrefix("1.2.3.4/20").containsPrefix(new IpPrefix("1.2.3.0/24")));
273
274 assertFalse(new IpPrefix("1.2.3.4/32").containsPrefix(new IpPrefix("1.2.3.5/32")));
275 assertFalse(new IpPrefix("1.2.3.4/8").containsPrefix(new IpPrefix("2.2.3.4/8")));
276 assertFalse(new IpPrefix("0.0.0.0/16").containsPrefix(new IpPrefix("0.0.0.0/15")));
277 assertFalse(new IpPrefix("100.0.0.0/8").containsPrefix(new IpPrefix("99.0.0.0/8")));
278
279 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("::/0")));
280 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("2001:db8::f00/1")));
281 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("3d8a:661:a0::770/8")));
282 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("2001:db8::f00/8")));
283 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("2001:db8::f00/64")));
284 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("2001:db8::f00/113")));
285 assertTrue(new IpPrefix("::/0").containsPrefix(new IpPrefix("2001:db8::f00/128")));
286
287 assertTrue(new IpPrefix("2001:db8:f00::ace:d00d/64").containsPrefix(
288 new IpPrefix("2001:db8:f00::ace:d00d/64")));
289 assertTrue(new IpPrefix("2001:db8:f00::ace:d00d/64").containsPrefix(
290 new IpPrefix("2001:db8:f00::ace:d00d/120")));
291 assertFalse(new IpPrefix("2001:db8:f00::ace:d00d/64").containsPrefix(
292 new IpPrefix("2001:db8:f00::ace:d00d/32")));
293 assertFalse(new IpPrefix("2001:db8:f00::ace:d00d/64").containsPrefix(
294 new IpPrefix("2006:db8:f00::ace:d00d/96")));
295
296 assertTrue(new IpPrefix("2001:db8:f00::ace:d00d/128").containsPrefix(
297 new IpPrefix("2001:db8:f00::ace:d00d/128")));
298 assertTrue(new IpPrefix("2001:db8:f00::ace:d00d/100").containsPrefix(
299 new IpPrefix("2001:db8:f00::ace:ccaf/110")));
300
301 assertFalse(new IpPrefix("2001:db8:f00::ace:d00d/128").containsPrefix(
302 new IpPrefix("2001:db8:f00::ace:d00e/128")));
303 assertFalse(new IpPrefix("::/30").containsPrefix(new IpPrefix("::/29")));
304 }
305
306 @Test
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900307 public void testHashCode() {
Hugo Benichif9c61862016-11-10 22:45:56 +0900308 IpPrefix p = new IpPrefix(new byte[4], 0);
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900309 Random random = new Random();
310 for (int i = 0; i < 100; i++) {
Hugo Benichif9c61862016-11-10 22:45:56 +0900311 final IpPrefix oldP = p;
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900312 if (random.nextBoolean()) {
313 // IPv4.
314 byte[] b = new byte[4];
315 random.nextBytes(b);
316 p = new IpPrefix(b, random.nextInt(33));
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900317 } else {
318 // IPv6.
319 byte[] b = new byte[16];
320 random.nextBytes(b);
321 p = new IpPrefix(b, random.nextInt(129));
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900322 }
Hugo Benichif9c61862016-11-10 22:45:56 +0900323 if (p.equals(oldP)) {
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900324 assertEquals(p.hashCode(), oldP.hashCode());
Hugo Benichif9c61862016-11-10 22:45:56 +0900325 }
326 if (p.hashCode() != oldP.hashCode()) {
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900327 assertNotEquals(p, oldP);
Hugo Benichif9c61862016-11-10 22:45:56 +0900328 }
329 }
330 }
331
Hugo Benichi8253be92017-08-08 13:06:04 +0900332 @Test
Hugo Benichif9c61862016-11-10 22:45:56 +0900333 public void testHashCodeIsNotConstant() {
334 IpPrefix[] prefixes = {
335 new IpPrefix("2001:db8:f00::ace:d00d/127"),
336 new IpPrefix("192.0.2.0/23"),
337 new IpPrefix("::/0"),
338 new IpPrefix("0.0.0.0/0"),
339 };
340 for (int i = 0; i < prefixes.length; i++) {
Remi NGUYEN VAN49b15872019-04-03 17:21:41 +0900341 for (int j = i + 1; j < prefixes.length; j++) {
342 assertNotEquals(prefixes[i].hashCode(), prefixes[j].hashCode());
343 }
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900344 }
345 }
346
Hugo Benichi8253be92017-08-08 13:06:04 +0900347 @Test
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900348 public void testMappedAddressesAreBroken() {
349 // 192.0.2.0/24 != ::ffff:c000:0204/120, but because we use InetAddress,
350 // we are unable to comprehend that.
351 byte[] ipv6bytes = {
352 (byte) 0, (byte) 0, (byte) 0, (byte) 0,
353 (byte) 0, (byte) 0, (byte) 0, (byte) 0,
354 (byte) 0, (byte) 0, (byte) 0xff, (byte) 0xff,
355 (byte) 192, (byte) 0, (byte) 2, (byte) 0};
356 IpPrefix p = new IpPrefix(ipv6bytes, 120);
357 assertEquals(16, p.getRawAddress().length); // Fine.
358 assertArrayEquals(ipv6bytes, p.getRawAddress()); // Fine.
359
360 // Broken.
361 assertEquals("192.0.2.0/120", p.toString());
362 assertEquals(InetAddress.parseNumericAddress("192.0.2.0"), p.getAddress());
363 }
364
Hugo Benichi8253be92017-08-08 13:06:04 +0900365 @Test
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900366 public void testParceling() {
367 IpPrefix p;
368
369 p = new IpPrefix("2001:4860:db8::/64");
370 assertParcelingIsLossless(p);
Hugo Benichi8253be92017-08-08 13:06:04 +0900371 assertTrue(p.isIPv6());
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900372
373 p = new IpPrefix("192.0.2.0/25");
374 assertParcelingIsLossless(p);
Hugo Benichi8253be92017-08-08 13:06:04 +0900375 assertTrue(p.isIPv4());
Lorenzo Colitti174bab22014-06-12 13:41:17 +0900376 }
377}