summaryrefslogtreecommitdiff
path: root/common/device/com/android/net/module/util/structs
diff options
context:
space:
mode:
Diffstat (limited to 'common/device/com/android/net/module/util/structs')
-rw-r--r--common/device/com/android/net/module/util/structs/EthernetHeader.java60
-rw-r--r--common/device/com/android/net/module/util/structs/IaAddressOption.java84
-rw-r--r--common/device/com/android/net/module/util/structs/IaPdOption.java81
-rw-r--r--common/device/com/android/net/module/util/structs/IaPrefixOption.java89
-rw-r--r--common/device/com/android/net/module/util/structs/Icmpv4Header.java43
-rw-r--r--common/device/com/android/net/module/util/structs/Icmpv6Header.java45
-rw-r--r--common/device/com/android/net/module/util/structs/Ipv4Header.java94
-rw-r--r--common/device/com/android/net/module/util/structs/Ipv6Header.java75
-rw-r--r--common/device/com/android/net/module/util/structs/Ipv6PktInfo.java42
-rw-r--r--common/device/com/android/net/module/util/structs/LlaOption.java61
-rw-r--r--common/device/com/android/net/module/util/structs/MtuOption.java65
-rw-r--r--common/device/com/android/net/module/util/structs/NaHeader.java57
-rw-r--r--common/device/com/android/net/module/util/structs/NsHeader.java61
-rw-r--r--common/device/com/android/net/module/util/structs/PrefixInformationOption.java98
-rw-r--r--common/device/com/android/net/module/util/structs/RaHeader.java62
-rw-r--r--common/device/com/android/net/module/util/structs/RdnssOption.java92
-rw-r--r--common/device/com/android/net/module/util/structs/RouteInformationOption.java97
-rw-r--r--common/device/com/android/net/module/util/structs/RsHeader.java44
-rw-r--r--common/device/com/android/net/module/util/structs/TcpHeader.java79
-rw-r--r--common/device/com/android/net/module/util/structs/UdpHeader.java53
20 files changed, 0 insertions, 1382 deletions
diff --git a/common/device/com/android/net/module/util/structs/EthernetHeader.java b/common/device/com/android/net/module/util/structs/EthernetHeader.java
deleted file mode 100644
index 92ef8a7e..00000000
--- a/common/device/com/android/net/module/util/structs/EthernetHeader.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import android.net.MacAddress;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * L2 ethernet header as per IEEE 802.3. Does not include a 802.1Q tag.
- *
- * 0 1
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Destination |
- * +- -+
- * | Ethernet |
- * +- -+
- * | Address |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Source |
- * +- -+
- * | Ethernet |
- * +- -+
- * | Address |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | EtherType |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class EthernetHeader extends Struct {
- @Field(order = 0, type = Type.EUI48)
- public final MacAddress dstMac;
- @Field(order = 1, type = Type.EUI48)
- public final MacAddress srcMac;
- @Field(order = 2, type = Type.U16)
- public final int etherType;
-
- public EthernetHeader(final MacAddress dstMac, final MacAddress srcMac,
- final int etherType) {
- this.dstMac = dstMac;
- this.srcMac = srcMac;
- this.etherType = etherType;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/IaAddressOption.java b/common/device/com/android/net/module/util/structs/IaAddressOption.java
deleted file mode 100644
index 575a1f36..00000000
--- a/common/device/com/android/net/module/util/structs/IaAddressOption.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.DHCP6_OPTION_IA_ADDR;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet6Address;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * DHCPv6 IA Address option.
- * https://tools.ietf.org/html/rfc8415. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | OPTION_IAADDR | option-len |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | IPv6-address |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | preferred-lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | valid-lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * . .
- * . IAaddr-options .
- * . .
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class IaAddressOption extends Struct {
- public static final int LENGTH = 24; // option length excluding IAaddr-options
-
- @Field(order = 0, type = Type.S16)
- public final short code;
- @Field(order = 1, type = Type.S16)
- public final short length;
- @Field(order = 2, type = Type.Ipv6Address)
- public final Inet6Address address;
- @Field(order = 3, type = Type.U32)
- public final long preferred;
- @Field(order = 4, type = Type.U32)
- public final long valid;
-
- IaAddressOption(final short code, final short length, final Inet6Address address,
- final long preferred, final long valid) {
- this.code = code;
- this.length = length;
- this.address = address;
- this.preferred = preferred;
- this.valid = valid;
- }
-
- /**
- * Build an IA Address option from the required specific parameters.
- */
- public static ByteBuffer build(final short length, final long id, final Inet6Address address,
- final long preferred, final long valid) {
- final IaAddressOption option = new IaAddressOption((short) DHCP6_OPTION_IA_ADDR,
- length /* 24 + IAaddr-options length */, address, preferred, valid);
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/IaPdOption.java b/common/device/com/android/net/module/util/structs/IaPdOption.java
deleted file mode 100644
index dbf79dcb..00000000
--- a/common/device/com/android/net/module/util/structs/IaPdOption.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.DHCP6_OPTION_IA_PD;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * DHCPv6 IA_PD option.
- * https://tools.ietf.org/html/rfc8415. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | OPTION_IA_PD | option-len |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | IAID (4 octets) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | T1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | T2 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * . .
- * . IA_PD-options .
- * . .
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-public class IaPdOption extends Struct {
- public static final int LENGTH = 12; // option length excluding IA_PD options
-
- @Field(order = 0, type = Type.S16)
- public final short code;
- @Field(order = 1, type = Type.S16)
- public final short length;
- @Field(order = 2, type = Type.U32)
- public final long id;
- @Field(order = 3, type = Type.U32)
- public final long t1;
- @Field(order = 4, type = Type.U32)
- public final long t2;
-
- IaPdOption(final short code, final short length, final long id, final long t1,
- final long t2) {
- this.code = code;
- this.length = length;
- this.id = id;
- this.t1 = t1;
- this.t2 = t2;
- }
-
- /**
- * Build an IA_PD option from the required specific parameters.
- */
- public static ByteBuffer build(final short length, final long id, final long t1,
- final long t2) {
- final IaPdOption option = new IaPdOption((short) DHCP6_OPTION_IA_PD,
- length /* 12 + IA_PD options length */, id, t1, t2);
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/IaPrefixOption.java b/common/device/com/android/net/module/util/structs/IaPrefixOption.java
deleted file mode 100644
index 59d655ca..00000000
--- a/common/device/com/android/net/module/util/structs/IaPrefixOption.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.DHCP6_OPTION_IAPREFIX;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * DHCPv6 IA Prefix Option.
- * https://tools.ietf.org/html/rfc8415. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | OPTION_IAPREFIX | option-len |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | preferred-lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | valid-lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | prefix-length | |
- * +-+-+-+-+-+-+-+-+ IPv6-prefix |
- * | (16 octets) |
- * | |
- * | |
- * | |
- * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | | .
- * +-+-+-+-+-+-+-+-+ .
- * . IAprefix-options .
- * . .
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class IaPrefixOption extends Struct {
- public static final int LENGTH = 25; // option length excluding IAprefix-options
-
- @Field(order = 0, type = Type.S16)
- public final short code;
- @Field(order = 1, type = Type.S16)
- public final short length;
- @Field(order = 2, type = Type.U32)
- public final long preferred;
- @Field(order = 3, type = Type.U32)
- public final long valid;
- @Field(order = 4, type = Type.S8)
- public final byte prefixLen;
- @Field(order = 5, type = Type.ByteArray, arraysize = 16)
- public final byte[] prefix;
-
- public IaPrefixOption(final short code, final short length, final long preferred,
- final long valid, final byte prefixLen, final byte[] prefix) {
- this.code = code;
- this.length = length;
- this.preferred = preferred;
- this.valid = valid;
- this.prefixLen = prefixLen;
- this.prefix = prefix.clone();
- }
-
- /**
- * Build an IA_PD prefix option with given specific parameters.
- */
- public static ByteBuffer build(final short length, final long preferred, final long valid,
- final byte prefixLen, final byte[] prefix) {
- final IaPrefixOption option = new IaPrefixOption((byte) DHCP6_OPTION_IAPREFIX,
- length /* 25 + IAPrefix options length */, preferred, valid, prefixLen, prefix);
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/Icmpv4Header.java b/common/device/com/android/net/module/util/structs/Icmpv4Header.java
deleted file mode 100644
index 454bb074..00000000
--- a/common/device/com/android/net/module/util/structs/Icmpv4Header.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * ICMPv4 header as per https://tools.ietf.org/html/rfc792.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Code | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class Icmpv4Header extends Struct {
- @Field(order = 0, type = Type.U8)
- public short type;
- @Field(order = 1, type = Type.U8)
- public short code;
- @Field(order = 2, type = Type.S16)
- public short checksum;
- public Icmpv4Header(final short type, final short code, final short checksum) {
- this.type = type;
- this.code = code;
- this.checksum = checksum;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/Icmpv6Header.java b/common/device/com/android/net/module/util/structs/Icmpv6Header.java
deleted file mode 100644
index c82ae02b..00000000
--- a/common/device/com/android/net/module/util/structs/Icmpv6Header.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * ICMPv6 header as per https://tools.ietf.org/html/rfc4443.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Code | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class Icmpv6Header extends Struct {
- @Field(order = 0, type = Type.U8)
- public short type;
- @Field(order = 1, type = Type.U8)
- public short code;
- @Field(order = 2, type = Type.S16)
- public short checksum;
-
- public Icmpv6Header(final short type, final short code, final short checksum) {
- this.type = type;
- this.code = code;
- this.checksum = checksum;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/Ipv4Header.java b/common/device/com/android/net/module/util/structs/Ipv4Header.java
deleted file mode 100644
index 5249454c..00000000
--- a/common/device/com/android/net/module/util/structs/Ipv4Header.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet4Address;
-
-/**
- * L3 IPv4 header as per https://tools.ietf.org/html/rfc791.
- * This class doesn't contain options field.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |Version| IHL |Type of Service| Total Length |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Identification |Flags| Fragment Offset |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Time to Live | Protocol | Header Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Source Address |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Destination Address |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class Ipv4Header extends Struct {
- // IP Version=IPv4, IHL is always 5(*4bytes) because options are not supported.
- @VisibleForTesting
- public static final byte IPHDR_VERSION_IHL = 0x45;
-
- @Field(order = 0, type = Type.S8)
- // version (4 bits), IHL (4 bits)
- public final byte vi;
- @Field(order = 1, type = Type.S8)
- public final byte tos;
- @Field(order = 2, type = Type.U16)
- public final int totalLength;
- @Field(order = 3, type = Type.S16)
- public final short id;
- @Field(order = 4, type = Type.S16)
- // flags (3 bits), fragment offset (13 bits)
- public final short flagsAndFragmentOffset;
- @Field(order = 5, type = Type.U8)
- public final short ttl;
- @Field(order = 6, type = Type.S8)
- public final byte protocol;
- @Field(order = 7, type = Type.S16)
- public final short checksum;
- @Field(order = 8, type = Type.Ipv4Address)
- public final Inet4Address srcIp;
- @Field(order = 9, type = Type.Ipv4Address)
- public final Inet4Address dstIp;
-
- public Ipv4Header(final byte tos, final int totalLength, final short id,
- final short flagsAndFragmentOffset, final short ttl, final byte protocol,
- final short checksum, final Inet4Address srcIp, final Inet4Address dstIp) {
- this(IPHDR_VERSION_IHL, tos, totalLength, id, flagsAndFragmentOffset, ttl,
- protocol, checksum, srcIp, dstIp);
- }
-
- private Ipv4Header(final byte vi, final byte tos, final int totalLength, final short id,
- final short flagsAndFragmentOffset, final short ttl, final byte protocol,
- final short checksum, final Inet4Address srcIp, final Inet4Address dstIp) {
- this.vi = vi;
- this.tos = tos;
- this.totalLength = totalLength;
- this.id = id;
- this.flagsAndFragmentOffset = flagsAndFragmentOffset;
- this.ttl = ttl;
- this.protocol = protocol;
- this.checksum = checksum;
- this.srcIp = srcIp;
- this.dstIp = dstIp;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/Ipv6Header.java b/common/device/com/android/net/module/util/structs/Ipv6Header.java
deleted file mode 100644
index a14e064d..00000000
--- a/common/device/com/android/net/module/util/structs/Ipv6Header.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet6Address;
-
-/**
- * L3 IPv6 header as per https://tools.ietf.org/html/rfc8200.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |Version| Traffic Class | Flow Label |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Payload Length | Next Header | Hop Limit |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * + +
- * | |
- * + Source Address +
- * | |
- * + +
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * + +
- * | |
- * + Destination Address +
- * | |
- * + +
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class Ipv6Header extends Struct {
- @Field(order = 0, type = Type.S32)
- public int vtf;
- @Field(order = 1, type = Type.U16)
- public int payloadLength;
- @Field(order = 2, type = Type.S8)
- public byte nextHeader;
- @Field(order = 3, type = Type.U8)
- public short hopLimit;
- @Field(order = 4, type = Type.Ipv6Address)
- public Inet6Address srcIp;
- @Field(order = 5, type = Type.Ipv6Address)
- public Inet6Address dstIp;
-
- public Ipv6Header(final int vtf, final int payloadLength, final byte nextHeader,
- final short hopLimit, final Inet6Address srcIp, final Inet6Address dstIp) {
- this.vtf = vtf;
- this.payloadLength = payloadLength;
- this.nextHeader = nextHeader;
- this.hopLimit = hopLimit;
- this.srcIp = srcIp;
- this.dstIp = dstIp;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/Ipv6PktInfo.java b/common/device/com/android/net/module/util/structs/Ipv6PktInfo.java
deleted file mode 100644
index 0dccb727..00000000
--- a/common/device/com/android/net/module/util/structs/Ipv6PktInfo.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet6Address;
-
-/**
- * structure in6_pktinfo
- *
- * see also:
- *
- * include/uapi/linux/ipv6.h
- */
-public class Ipv6PktInfo extends Struct {
- @Field(order = 0, type = Type.Ipv6Address)
- public final Inet6Address addr; // IPv6 source or destination address
- @Field(order = 1, type = Type.S32)
- public final int ifindex; // interface index
-
- public Ipv6PktInfo(final Inet6Address addr, final int ifindex) {
- this.addr = addr;
- this.ifindex = ifindex;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/LlaOption.java b/common/device/com/android/net/module/util/structs/LlaOption.java
deleted file mode 100644
index fbaccabc..00000000
--- a/common/device/com/android/net/module/util/structs/LlaOption.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import android.net.MacAddress;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * ICMPv6 source/target link-layer address option, as per https://tools.ietf.org/html/rfc4861.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Link-Layer Address ...
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class LlaOption extends Struct {
- @Field(order = 0, type = Type.S8)
- public final byte type;
- @Field(order = 1, type = Type.S8)
- public final byte length; // Length in 8-byte units
- @Field(order = 2, type = Type.EUI48)
- // Link layer address length and format varies on different link layers, which is not
- // guaranteed to be a 6-byte MAC address. However, Struct only supports 6-byte MAC
- // addresses type(EUI-48) for now.
- public final MacAddress linkLayerAddress;
-
- LlaOption(final byte type, final byte length, final MacAddress linkLayerAddress) {
- this.type = type;
- this.length = length;
- this.linkLayerAddress = linkLayerAddress;
- }
-
- /**
- * Build a target link-layer address option from the required specified parameters.
- */
- public static ByteBuffer build(final byte type, final MacAddress linkLayerAddress) {
- final LlaOption option = new LlaOption(type, (byte) 1 /* option len */, linkLayerAddress);
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/MtuOption.java b/common/device/com/android/net/module/util/structs/MtuOption.java
deleted file mode 100644
index 34bc21c1..00000000
--- a/common/device/com/android/net/module/util/structs/MtuOption.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_MTU;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * ICMPv6 MTU option, as per https://tools.ietf.org/html/rfc4861.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | MTU |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class MtuOption extends Struct {
- @Field(order = 0, type = Type.S8)
- public final byte type;
- @Field(order = 1, type = Type.S8)
- public final byte length; // Length in 8-byte units
- @Field(order = 2, type = Type.S16)
- public final short reserved;
- @Field(order = 3, type = Type.U32)
- public final long mtu;
-
- MtuOption(final byte type, final byte length, final short reserved,
- final long mtu) {
- this.type = type;
- this.length = length;
- this.reserved = reserved;
- this.mtu = mtu;
- }
-
- /**
- * Build a MTU option from the required specified parameters.
- */
- public static ByteBuffer build(final long mtu) {
- final MtuOption option = new MtuOption((byte) ICMPV6_ND_OPTION_MTU,
- (byte) 1 /* option len */, (short) 0 /* reserved */, mtu);
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/NaHeader.java b/common/device/com/android/net/module/util/structs/NaHeader.java
deleted file mode 100644
index 90c078e8..00000000
--- a/common/device/com/android/net/module/util/structs/NaHeader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet6Address;
-
-/**
- * ICMPv6 Neighbor Advertisement header, follow {@link Icmpv6Header}, as per
- * https://tools.ietf.org/html/rfc4861. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Code | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |R|S|O| Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * + +
- * | |
- * + Target Address +
- * | |
- * + +
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Options ...
- * +-+-+-+-+-+-+-+-+-+-+-+-
- */
-public class NaHeader extends Struct {
- @Field(order = 0, type = Type.S32)
- public int flags; // Router flag, Solicited flag, Override flag and 29 Reserved bits.
- @Field(order = 1, type = Type.Ipv6Address)
- public Inet6Address target;
-
- public NaHeader(final int flags, final Inet6Address target) {
- this.flags = flags;
- this.target = target;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/NsHeader.java b/common/device/com/android/net/module/util/structs/NsHeader.java
deleted file mode 100644
index 2e8b77ba..00000000
--- a/common/device/com/android/net/module/util/structs/NsHeader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet6Address;
-
-/**
- * ICMPv6 Neighbor Solicitation header, follow {@link Icmpv6Header}, as per
- * https://tools.ietf.org/html/rfc4861. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Code | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * + +
- * | |
- * + Target Address +
- * | |
- * + +
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Options ...
- * +-+-+-+-+-+-+-+-+-+-+-+-
- */
-public class NsHeader extends Struct {
- @Field(order = 0, type = Type.S32)
- public int reserved; // 32 Reserved bits.
- @Field(order = 1, type = Type.Ipv6Address)
- public Inet6Address target;
-
- NsHeader(int reserved, final Inet6Address target) {
- this.reserved = reserved;
- this.target = target;
- }
-
- public NsHeader(final Inet6Address target) {
- this(0, target);
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/PrefixInformationOption.java b/common/device/com/android/net/module/util/structs/PrefixInformationOption.java
deleted file mode 100644
index 49d7654d..00000000
--- a/common/device/com/android/net/module/util/structs/PrefixInformationOption.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_PIO;
-
-import android.net.IpPrefix;
-
-import androidx.annotation.NonNull;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * ICMPv6 prefix information option, as per https://tools.ietf.org/html/rfc4861.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Prefix Length |L|A| Reserved1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Valid Lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Preferred Lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reserved2 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * + +
- * | |
- * + Prefix +
- * | |
- * + +
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class PrefixInformationOption extends Struct {
- @Field(order = 0, type = Type.S8)
- public final byte type;
- @Field(order = 1, type = Type.S8)
- public final byte length; // Length in 8-byte units
- @Field(order = 2, type = Type.S8)
- public final byte prefixLen;
- @Field(order = 3, type = Type.S8)
- // On-link flag, Autonomous address configuration flag, 6-reserved bits
- public final byte flags;
- @Field(order = 4, type = Type.U32)
- public final long validLifetime;
- @Field(order = 5, type = Type.U32)
- public final long preferredLifetime;
- @Field(order = 6, type = Type.S32)
- public final int reserved;
- @Field(order = 7, type = Type.ByteArray, arraysize = 16)
- public final byte[] prefix;
-
- PrefixInformationOption(final byte type, final byte length, final byte prefixLen,
- final byte flags, final long validLifetime, final long preferredLifetime,
- final int reserved, @NonNull final byte[] prefix) {
- this.type = type;
- this.length = length;
- this.prefixLen = prefixLen;
- this.flags = flags;
- this.validLifetime = validLifetime;
- this.preferredLifetime = preferredLifetime;
- this.reserved = reserved;
- this.prefix = prefix;
- }
-
- /**
- * Build a Prefix Information option from the required specified parameters.
- */
- public static ByteBuffer build(final IpPrefix prefix, final byte flags,
- final long validLifetime, final long preferredLifetime) {
- final PrefixInformationOption option = new PrefixInformationOption(
- (byte) ICMPV6_ND_OPTION_PIO, (byte) 4 /* option len */,
- (byte) prefix.getPrefixLength(), flags, validLifetime, preferredLifetime,
- (int) 0, prefix.getRawAddress());
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/RaHeader.java b/common/device/com/android/net/module/util/structs/RaHeader.java
deleted file mode 100644
index 31a5cb76..00000000
--- a/common/device/com/android/net/module/util/structs/RaHeader.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * ICMPv6 Router Advertisement header, follow [Icmpv6Header], as per
- * https://tools.ietf.org/html/rfc4861. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Code | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Cur Hop Limit |M|O| Reserved | Router Lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reachable Time |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Retrans Timer |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Options ...
- * +-+-+-+-+-+-+-+-+-+-+-+-
- */
-public class RaHeader extends Struct {
- @Field(order = 0, type = Type.S8)
- public final byte hopLimit;
- // "Managed address configuration", "Other configuration" bits, and 6 reserved bits
- @Field(order = 1, type = Type.S8)
- public final byte flags;
- @Field(order = 2, type = Type.U16)
- public final int lifetime;
- @Field(order = 3, type = Type.U32)
- public final long reachableTime;
- @Field(order = 4, type = Type.U32)
- public final long retransTimer;
-
- public RaHeader(final byte hopLimit, final byte flags, final int lifetime,
- final long reachableTime, final long retransTimer) {
- this.hopLimit = hopLimit;
- this.flags = flags;
- this.lifetime = lifetime;
- this.reachableTime = reachableTime;
- this.retransTimer = retransTimer;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/RdnssOption.java b/common/device/com/android/net/module/util/structs/RdnssOption.java
deleted file mode 100644
index 4a5bd7e9..00000000
--- a/common/device/com/android/net/module/util/structs/RdnssOption.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_RDNSS;
-
-import android.net.InetAddresses;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.net.Inet6Address;
-import java.nio.ByteBuffer;
-
-/**
- * IPv6 RA recursive DNS server option, as per https://tools.ietf.org/html/rfc8106.
- * This should be followed by a series of DNSv6 server addresses.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * : Addresses of IPv6 Recursive DNS Servers :
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class RdnssOption extends Struct {
- @Field(order = 0, type = Type.S8)
- public final byte type;
- @Field(order = 1, type = Type.S8)
- public final byte length; // Length in 8-byte units
- @Field(order = 2, type = Type.S16)
- public final short reserved;
- @Field(order = 3, type = Type.U32)
- public final long lifetime;
-
- public RdnssOption(final byte type, final byte length, final short reserved,
- final long lifetime) {
- this.type = type;
- this.length = length;
- this.reserved = reserved;
- this.lifetime = lifetime;
- }
-
- /**
- * Build a RDNSS option from the required specified Inet6Address parameters.
- */
- public static ByteBuffer build(final long lifetime, final Inet6Address... servers) {
- final byte length = (byte) (1 + 2 * servers.length);
- final RdnssOption option = new RdnssOption((byte) ICMPV6_ND_OPTION_RDNSS,
- length, (short) 0, lifetime);
- final ByteBuffer buffer = ByteBuffer.allocate(length * 8);
- option.writeToByteBuffer(buffer);
- for (Inet6Address server : servers) {
- buffer.put(server.getAddress());
- }
- buffer.flip();
- return buffer;
- }
-
- /**
- * Build a RDNSS option from the required specified String parameters.
- *
- * @throws IllegalArgumentException if {@code servers} does not contain only numeric addresses.
- */
- public static ByteBuffer build(final long lifetime, final String... servers) {
- final Inet6Address[] serverArray = new Inet6Address[servers.length];
- for (int i = 0; i < servers.length; i++) {
- serverArray[i] = (Inet6Address) InetAddresses.parseNumericAddress(servers[i]);
- }
- return build(lifetime, serverArray);
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/RouteInformationOption.java b/common/device/com/android/net/module/util/structs/RouteInformationOption.java
deleted file mode 100644
index 49bafedb..00000000
--- a/common/device/com/android/net/module/util/structs/RouteInformationOption.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ND_OPTION_RIO;
-
-import android.net.IpPrefix;
-
-import androidx.annotation.NonNull;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * ICMPv6 route information option, as per https://tools.ietf.org/html/rfc4191.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Length | Prefix Length |Resvd|Prf|Resvd|
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Route Lifetime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Prefix (Variable Length) |
- * . .
- * . .
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class RouteInformationOption extends Struct {
- public enum Preference {
- HIGH((byte) 0x1),
- MEDIUM((byte) 0x0),
- LOW((byte) 0x3),
- RESERVED((byte) 0x2);
-
- final byte mValue;
- Preference(byte value) {
- this.mValue = value;
- }
- }
-
- @Field(order = 0, type = Type.S8)
- public final byte type;
- @Field(order = 1, type = Type.S8)
- public final byte length; // Length in 8-byte octets
- @Field(order = 2, type = Type.U8)
- public final short prefixLen;
- @Field(order = 3, type = Type.S8)
- public final byte prf;
- @Field(order = 4, type = Type.U32)
- public final long routeLifetime;
- @Field(order = 5, type = Type.ByteArray, arraysize = 16)
- public final byte[] prefix;
-
- RouteInformationOption(final byte type, final byte length, final short prefixLen,
- final byte prf, final long routeLifetime, @NonNull final byte[] prefix) {
- this.type = type;
- this.length = length;
- this.prefixLen = prefixLen;
- this.prf = prf;
- this.routeLifetime = routeLifetime;
- this.prefix = prefix;
- }
-
- /**
- * Build a Route Information option from the required specified parameters.
- */
- public static ByteBuffer build(final IpPrefix prefix, final Preference prf,
- final long routeLifetime) {
- // The prefix field is always assumed to have 16 bytes, but the number of leading
- // bits in this prefix depends on IpPrefix#prefixLength, then we can simply set the
- // option length to 3.
- final RouteInformationOption option = new RouteInformationOption(
- (byte) ICMPV6_ND_OPTION_RIO, (byte) 3 /* option length */,
- (short) prefix.getPrefixLength(), (byte) (prf.mValue << 3), routeLifetime,
- prefix.getRawAddress());
- return ByteBuffer.wrap(option.writeToBytes(ByteOrder.BIG_ENDIAN));
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/RsHeader.java b/common/device/com/android/net/module/util/structs/RsHeader.java
deleted file mode 100644
index 0b51ff25..00000000
--- a/common/device/com/android/net/module/util/structs/RsHeader.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * ICMPv6 Router Solicitation header, follow [Icmpv6Header], as per
- * https://tools.ietf.org/html/rfc4861. This does not contain any option.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Type | Code | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Options ...
- * +-+-+-+-+-+-+-+-+-+-+-+-
- */
-public class RsHeader extends Struct {
- @Field(order = 0, type = Type.S32)
- public final int reserved;
-
- public RsHeader(final int reserved) {
- this.reserved = reserved;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/TcpHeader.java b/common/device/com/android/net/module/util/structs/TcpHeader.java
deleted file mode 100644
index 0c97401c..00000000
--- a/common/device/com/android/net/module/util/structs/TcpHeader.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * L4 TCP header as per https://tools.ietf.org/html/rfc793.
- * This class does not contain option and data fields.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Source Port | Destination Port |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Sequence Number |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Acknowledgment Number |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Data | |U|A|P|R|S|F| |
- * | Offset| Reserved |R|C|S|S|Y|I| Window |
- * | | |G|K|H|T|N|N| |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Checksum | Urgent Pointer |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Options | Padding |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | data |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-public class TcpHeader extends Struct {
- @Field(order = 0, type = Type.U16)
- public final int srcPort;
- @Field(order = 1, type = Type.U16)
- public final int dstPort;
- @Field(order = 2, type = Type.U32)
- public final long seq;
- @Field(order = 3, type = Type.U32)
- public final long ack;
- @Field(order = 4, type = Type.S16)
- // data Offset (4 bits), reserved (6 bits), control bits (6 bits)
- // TODO: update with bitfields once class Struct supports it
- public final short dataOffsetAndControlBits;
- @Field(order = 5, type = Type.U16)
- public final int window;
- @Field(order = 6, type = Type.S16)
- public final short checksum;
- @Field(order = 7, type = Type.U16)
- public final int urgentPointer;
-
- public TcpHeader(final int srcPort, final int dstPort, final long seq, final long ack,
- final short dataOffsetAndControlBits, final int window, final short checksum,
- final int urgentPointer) {
- this.srcPort = srcPort;
- this.dstPort = dstPort;
- this.seq = seq;
- this.ack = ack;
- this.dataOffsetAndControlBits = dataOffsetAndControlBits;
- this.window = window;
- this.checksum = checksum;
- this.urgentPointer = urgentPointer;
- }
-}
diff --git a/common/device/com/android/net/module/util/structs/UdpHeader.java b/common/device/com/android/net/module/util/structs/UdpHeader.java
deleted file mode 100644
index 8b0316bf..00000000
--- a/common/device/com/android/net/module/util/structs/UdpHeader.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.net.module.util.structs;
-
-import com.android.net.module.util.Struct;
-import com.android.net.module.util.Struct.Field;
-import com.android.net.module.util.Struct.Type;
-
-/**
- * L4 UDP header as per https://tools.ietf.org/html/rfc768.
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Source Port | Destination Port |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Length | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | data octets ...
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ...
- */
-public class UdpHeader extends Struct {
- @Field(order = 0, type = Type.U16)
- public final int srcPort;
- @Field(order = 1, type = Type.U16)
- public final int dstPort;
- @Field(order = 2, type = Type.U16)
- public final int length;
- @Field(order = 3, type = Type.S16)
- public final short checksum;
-
- public UdpHeader(final int srcPort, final int dstPort, final int length,
- final short checksum) {
- this.srcPort = srcPort;
- this.dstPort = dstPort;
- this.length = length;
- this.checksum = checksum;
- }
-}