From ee83d45f7697d8a28707e28d56b2d5c715259617 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 3 May 2024 11:37:17 -0700 Subject: [PATCH] [cli] add `br pd omrprefix` command to display DHCPv6 PD OMR prefix (#10147) This commit introduces the `br pd omrprefix` command, which displays the DHCPv6 Prefix Delegation (PD) On-Mesh Routable (OMR) prefix when the DHCPv6 PD feature is enabled. Additionally, the `debug` command is updated to output `br pd state` and this new command when the feature is enabled --- src/cli/README_BR.md | 12 ++++++++++++ src/cli/cli.cpp | 4 ++++ src/cli/cli_br.cpp | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/cli/README_BR.md b/src/cli/README_BR.md index 8376290d6..d043a5718 100644 --- a/src/cli/README_BR.md +++ b/src/cli/README_BR.md @@ -209,6 +209,18 @@ running Done ``` +Usage `br pd omrprefix` + +Get the DHCPv6 Prefix Delegation (PD) provided off-mesh-routable (OMR) prefix. + +`OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE` is required. + +```bash +> br pd omrprefix +2001:db8:cafe:0:0/64 lifetime:1800 preferred:1800 +Done +``` + ### prefixtable Usage: `br prefixtable` diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 1619aca5d..e10198a46 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -7087,6 +7087,10 @@ template <> otError Interpreter::Process(Arg aArgs[]) #if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE "br nat64prefix", #endif +#if OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE + "br pd state", + "br pd omrprefix", +#endif #endif "bufferinfo", }; diff --git a/src/cli/cli_br.cpp b/src/cli/cli_br.cpp index 3aaa1959f..c8e9115b9 100644 --- a/src/cli/cli_br.cpp +++ b/src/cli/cli_br.cpp @@ -485,6 +485,25 @@ template <> otError Br::Process(Arg aArgs[]) OutputLine("%s", Stringify(otBorderRoutingDhcp6PdGetState(GetInstancePtr()), kDhcpv6PdStateStrings)); } + /** + * @cli br pd omrprefix + * @code + * br pd omrprefix + * 2001:db8:cafe:0:0/64 lifetime:1800 preferred:1800 + * Done + * @endcode + * @par api_copy + * #otBorderRoutingGetPdOmrPrefix + */ + else if (aArgs[0] == "omrprefix") + { + otBorderRoutingPrefixTableEntry entry; + + SuccessOrExit(error = otBorderRoutingGetPdOmrPrefix(GetInstancePtr(), &entry)); + + OutputIp6Prefix(entry.mPrefix); + OutputLine(" lifetime:%lu preferred:%lu", ToUlong(entry.mValidLifetime), ToUlong(entry.mPreferredLifetime)); + } else { ExitNow(error = OT_ERROR_INVALID_COMMAND);