Merge changes from topic "update-ipv4-multicast" into main
* changes: Throw `IllegalArgumentException` instead of `RuntimeException` in hexStringToByteArray() Add IPv4 all host address definition
This commit is contained in:
commit
3ffdc0b516
3 changed files with 9 additions and 1 deletions
|
|
@ -202,7 +202,7 @@ public class HexDump {
|
|||
if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
|
||||
if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
|
||||
|
||||
throw new RuntimeException("Invalid hex char '" + c + "'");
|
||||
throw new IllegalArgumentException("Invalid hex char '" + c + "'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public final class NetworkStackConstants {
|
|||
(byte) 0, (byte) 0, (byte) 0, (byte) 0,
|
||||
(byte) 0, (byte) 0, (byte) 0, (byte) 0,
|
||||
(byte) 0, (byte) 0, (byte) 0, (byte) 0 });
|
||||
public static final Inet4Address IPV4_ADDR_ALL_HOST_MULTICAST =
|
||||
(Inet4Address) InetAddresses.parseNumericAddress("224.0.0.1");
|
||||
|
||||
/**
|
||||
* CLAT constants
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.net.module.util;
|
|||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
|
@ -49,6 +50,11 @@ public class HexDumpTest {
|
|||
HexDump.hexStringToByteArray("ABCDEF"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidHexStringToByteArray() {
|
||||
assertThrows(IllegalArgumentException.class, () -> HexDump.hexStringToByteArray("abxX"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntegerToByteArray() {
|
||||
assertArrayEquals(new byte[]{(byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x04},
|
||||
|
|
|
|||
Loading…
Reference in a new issue