@@ -85,6 +85,7 @@ typedef struct otBorderRoutingPrefixTableIterator
8585{
8686 const void * mPtr1 ;
8787 const void * mPtr2 ;
88+ uint32_t mData0 ;
8889 uint32_t mData1 ;
8990 uint8_t mData2 ;
9091 uint8_t mData3 ;
@@ -93,15 +94,23 @@ typedef struct otBorderRoutingPrefixTableIterator
9394/**
9495 * Represents a discovered router on the infrastructure link.
9596 *
97+ * The `mIsPeerBr` field requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TRACK_PEER_BR_INFO_ENABLE`. Routing Manager
98+ * determines whether the router is a peer BR (connected to the same Thread mesh network) by comparing its advertised
99+ * PIO/RIO prefixes with the entries in the Thread Network Data. While this method is generally effective, it may not
100+ * be 100% accurate in all scenarios, so the `mIsPeerBr` flag should be used with caution.
101+ *
96102 */
97103typedef struct otBorderRoutingRouterEntry
98104{
99105 otIp6Address mAddress ; ///< IPv6 address of the router.
100106 uint32_t mMsecSinceLastUpdate ; ///< Milliseconds since last update (any message rx) from this router.
107+ uint32_t mAge ; ///< The router's age in seconds (duration since its first discovery).
101108 bool mManagedAddressConfigFlag : 1 ; ///< The router's Managed Address Config flag (`M` flag).
102109 bool mOtherConfigFlag : 1 ; ///< The router's Other Config flag (`O` flag).
103110 bool mStubRouterFlag : 1 ; ///< The router's Stub Router flag.
104111 bool mIsLocalDevice : 1 ; ///< This router is the local device (this BR).
112+ bool mIsReachable : 1 ; ///< This router is reachable.
113+ bool mIsPeerBr : 1 ; ///< This router is (likely) a peer BR.
105114} otBorderRoutingRouterEntry ;
106115
107116/**
@@ -122,6 +131,16 @@ typedef struct otBorderRoutingPrefixTableEntry
122131 uint32_t mPreferredLifetime ; ///< Preferred lifetime of the on-link prefix when `mIsOnLink`.
123132} otBorderRoutingPrefixTableEntry ;
124133
134+ /**
135+ * Represents information about a peer Border Router found in the Network Data.
136+ *
137+ */
138+ typedef struct otBorderRoutingPeerBorderRouterEntry
139+ {
140+ uint16_t mRloc16 ; ///< The RLOC16 of BR.
141+ uint32_t mAge ; ///< Seconds since the BR appeared in the Network Data.
142+ } otBorderRoutingPeerBorderRouterEntry ;
143+
125144/**
126145 * Represents a group of data of platform-generated RA messages processed.
127146 *
@@ -479,6 +498,58 @@ otError otBorderRoutingGetNextRouterEntry(otInstance *aI
479498 otBorderRoutingPrefixTableIterator * aIterator ,
480499 otBorderRoutingRouterEntry * aEntry );
481500
501+ /**
502+ * Iterates over the peer BRs found in the Network Data.
503+ *
504+ * Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TRACK_PEER_BR_INFO_ENABLE`.
505+ *
506+ * Peer BRs are other devices within the Thread mesh that provide external IP connectivity. A device is considered
507+ * to provide external IP connectivity if at least one of the following conditions is met regarding its Network Data
508+ * entries:
509+ *
510+ * - It has added at least one external route entry.
511+ * - It has added at least one prefix entry with both the default-route and on-mesh flags set.
512+ * - It has added at least one domain prefix (with both the domain and on-mesh flags set).
513+ *
514+ * The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
515+ *
516+ * @param[in] aInstance The OpenThread instance.
517+ * @param[in,out] aIterator A pointer to the iterator.
518+ * @param[out] aEntry A pointer to the entry to populate.
519+ *
520+ * @retval OT_ERROR_NONE Iterated to the next entry, @p aEntry and @p aIterator are updated.
521+ * @retval OT_ERROR_NOT_FOUND No more entries.
522+ *
523+ */
524+ otError otBorderRoutingGetNextPeerBrEntry (otInstance * aInstance ,
525+ otBorderRoutingPrefixTableIterator * aIterator ,
526+ otBorderRoutingPeerBorderRouterEntry * aEntry );
527+
528+ /**
529+ * Returns the number of peer BRs found in the Network Data.
530+ *
531+ * Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TRACK_PEER_BR_INFO_ENABLE`.
532+ *
533+ * Peer BRs are other devices within the Thread mesh that provide external IP connectivity. A device is considered
534+ * to provide external IP connectivity if at least one of the following conditions is met regarding its Network Data
535+ * entries:
536+ *
537+ * - It has added at least one external route entry.
538+ * - It has added at least one prefix entry with both the default-route and on-mesh flags set.
539+ * - It has added at least one domain prefix (with both the domain and on-mesh flags set).
540+ *
541+ * The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
542+ *
543+ * @param[in] aInstance The OpenThread instance.
544+ * @param[out] aMinAge Pointer to an `uint32_t` to return the minimum age among all peer BRs.
545+ * Can be NULL if the caller does not need this information.
546+ * Age is represented as seconds since appearance of the BR entry in the Network Data.
547+ *
548+ * @returns The number of peer BRs.
549+ *
550+ */
551+ uint16_t otBorderRoutingCountPeerBrs (otInstance * aInstance , uint32_t * aMinAge );
552+
482553/**
483554 * Enables / Disables DHCPv6 Prefix Delegation.
484555 *
@@ -527,6 +598,18 @@ void otBorderRoutingDhcp6PdSetRequestCallback(otInstance
527598 otBorderRoutingRequestDhcp6PdCallback aCallback ,
528599 void * aContext );
529600
601+ /**
602+ * Sets the local on-link prefix.
603+ *
604+ * Requires `OPENTHREAD_CONFIG_BORDER_ROUTING_TESTING_API_ENABLE`.
605+ *
606+ * This is intended for testing only and using it will make the BR non-compliant with the Thread Specification.
607+ *
608+ * @param[in] aPrefix The on-link prefix to use.
609+ *
610+ */
611+ void otBorderRoutingSetOnLinkPrefix (otInstance * aInstance , const otIp6Prefix * aPrefix );
612+
530613/**
531614 * @}
532615 *
0 commit comments