From 307112f889be8f75e083319bd7e586f121b4be95 Mon Sep 17 00:00:00 2001 From: Xiao Ma Date: Thu, 12 Jun 2025 01:14:06 +0900 Subject: [PATCH] DHCPv6 addr reg: get the DHCPv6 message type. Flag: EXEMPT guarded by an legacy experiment flag Bug: 293393743 Test: TH Change-Id: If072a5bce0c8516af3fa4f7f9b63137de86b7500 --- .../net/module/util/dhcp6/Dhcp6AddrRegInformPacket.java | 7 +++++++ .../net/module/util/dhcp6/Dhcp6AddrRegReplyPacket.java | 7 +++++++ .../net/module/util/dhcp6/Dhcp6AdvertisePacket.java | 7 +++++++ .../com/android/net/module/util/dhcp6/Dhcp6Packet.java | 7 ++++++- .../android/net/module/util/dhcp6/Dhcp6RebindPacket.java | 7 +++++++ .../android/net/module/util/dhcp6/Dhcp6RenewPacket.java | 7 +++++++ .../android/net/module/util/dhcp6/Dhcp6ReplyPacket.java | 7 +++++++ .../android/net/module/util/dhcp6/Dhcp6RequestPacket.java | 7 +++++++ .../android/net/module/util/dhcp6/Dhcp6SolicitPacket.java | 7 +++++++ 9 files changed, 62 insertions(+), 1 deletion(-) diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegInformPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegInformPacket.java index 6cf1ea1f9e..9fd1f963d0 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegInformPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegInformPacket.java @@ -48,6 +48,13 @@ public class Dhcp6AddrRegInformPacket extends Dhcp6Packet { mValid = valid; } + /** + * Return the DHCPv6 ADDR_REG_INFORM message type (36). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_ADDR_REG_INFORM; + } + /** * Build a DHCPv6 ADDR-REG-INFORM message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegReplyPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegReplyPacket.java index aecf2209df..c9914566ea 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegReplyPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AddrRegReplyPacket.java @@ -49,6 +49,13 @@ public class Dhcp6AddrRegReplyPacket extends Dhcp6Packet { mValid = valid; } + /** + * Return the DHCPv6 ADDR_REG_REPLY message type (37). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_ADDR_REG_REPLY; + } + /** * Build a DHCPv6 ADDR-REG-REPLY message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AdvertisePacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AdvertisePacket.java index 57dfb07c3c..400cd5af50 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AdvertisePacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6AdvertisePacket.java @@ -35,6 +35,13 @@ public class Dhcp6AdvertisePacket extends Dhcp6Packet { super(transId, 0 /* elapsedTime */, clientDuid, serverDuid, iapd); } + /** + * Return the DHCPv6 ADVERTISE message type (2). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_ADVERTISE; + } + /** * Build a DHCPv6 Advertise message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6Packet.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6Packet.java index 6ecb74827c..152b422570 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6Packet.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6Packet.java @@ -47,7 +47,7 @@ import java.util.OptionalInt; * * @hide */ -public class Dhcp6Packet { +public abstract class Dhcp6Packet { private static final String TAG = Dhcp6Packet.class.getSimpleName(); /** DHCP constants copied from NetworkStackConstants.java */ protected static final int DHCP_MAX_LENGTH = 1500; @@ -72,6 +72,11 @@ public class Dhcp6Packet { public static final byte DHCP6_MESSAGE_TYPE_ADDR_REG_INFORM = 36; public static final byte DHCP6_MESSAGE_TYPE_ADDR_REG_REPLY = 37; + /** + * Returns a specific DHCPv6 message type. + */ + public abstract byte getMessageType(); + /** * DHCPv6 Optional Type: Client Identifier. * DHCPv6 message from client must have this option. diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RebindPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RebindPacket.java index 5f795fe37a..95825c21aa 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RebindPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RebindPacket.java @@ -36,6 +36,13 @@ public class Dhcp6RebindPacket extends Dhcp6Packet { super(transId, elapsedTime, clientDuid, null /* serverDuid */, iapd); } + /** + * Return the DHCPv6 REBIND message type (6). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_REBIND; + } + /** * Build a DHCPv6 Rebind message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RenewPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RenewPacket.java index 7dc7267959..4ed7d289bc 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RenewPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RenewPacket.java @@ -36,6 +36,13 @@ public class Dhcp6RenewPacket extends Dhcp6Packet { super(transId, elapsedTime, clientDuid, serverDuid, iapd); } + /** + * Return the DHCPv6 RENEW message type (5). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_RENEW; + } + /** * Build a DHCPv6 Renew message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6ReplyPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6ReplyPacket.java index 74ccee2a60..b55f2f95b6 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6ReplyPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6ReplyPacket.java @@ -37,6 +37,13 @@ public class Dhcp6ReplyPacket extends Dhcp6Packet { mRapidCommit = rapidCommit; } + /** + * Return the DHCPv6 REPLY message type (7). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_REPLY; + } + /** * Build a DHCPv6 Reply message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RequestPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RequestPacket.java index cfb16437db..f01f28666b 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RequestPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6RequestPacket.java @@ -35,6 +35,13 @@ public class Dhcp6RequestPacket extends Dhcp6Packet { super(transId, elapsedTime, clientDuid, serverDuid, iapd); } + /** + * Return the DHCPv6 REQUEST message type (3). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_REQUEST; + } + /** * Build a DHCPv6 Request message with the specific parameters. */ diff --git a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6SolicitPacket.java b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6SolicitPacket.java index ff86052f64..34ba4b1f17 100644 --- a/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6SolicitPacket.java +++ b/staticlibs/device/com/android/net/module/util/dhcp6/Dhcp6SolicitPacket.java @@ -35,6 +35,13 @@ public class Dhcp6SolicitPacket extends Dhcp6Packet { mRapidCommit = rapidCommit; } + /** + * Return the DHCPv6 SOLICIT message type (1). + */ + public byte getMessageType() { + return DHCP6_MESSAGE_TYPE_SOLICIT; + } + /** * Build a DHCPv6 Solicit message with the specific parameters. */