mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
f90d50b220
This commit introduces the `Dhcp6PdClient` class, which implements DHCPv6 Prefix Delegation (PD) client functionality. It integrates with `BorderRouter::RoutingManager` and its `PdPrefixManager` sub-component. The CMake `OT_BORDER_ROUTING_DHCP6_PD_CLIENT` mapped to `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` config enables this feature. Previously, the platform layer was expected to implement client functionality, acquiring and providing the delegated prefix(es) to the OT stack using `otPlatBorderRouter*` callbacks. This approach continues to be supported. The `Dhcp6PdClient` feature adds native support for this functionality in the OpenThread core. The `Dhcp6PdClient` implementation follows RFC 8415, focusing on prefix delegation and all required behaviors. The client follows the standard four-message Solicit/Advertise/Request/Reply exchange to obtain a delegated prefix, followed by a two-message Renew/Reply or Rebind/Reply exchange to extend the lifetime of the delegated prefix. When the prefix is no longer needed, a two-message Release/Reply exchange ends its lease. The current client implementation does not support the optional "Reconfigure Accept" mechanism. A set of `otPlatInfraIfDhcp6PdClient*` platform APIs are also introduced for use by the `Dhcp6PdClient`. These APIs are used to enable or disable listening for DHCPv6 messages and to handle sending and receiving them on the standard client and server UDP ports (546 and 547), effectively acting as a UDP socket. This commit also includes a comprehensive unit test covering various aspects of `Dhcp6PdClient`, including common behaviors and many specific edge cases.