4646#include " common/pool.hpp"
4747#include " common/tasklet.hpp"
4848#include " common/time.hpp"
49- #include " mac/mac_types.hpp"
50- #include " net/ip6_address.hpp"
51- #include " net/socket.hpp"
5249#include " radio/trel_packet.hpp"
53- #include " thread/mle_types .hpp"
50+ #include " radio/trel_peer .hpp"
5451
5552namespace ot {
5653namespace Trel {
5754
5855class Link ;
56+ class Interface ;
5957
6058extern " C" void otPlatTrelHandleReceived (otInstance *aInstance,
6159 uint8_t *aBuffer,
@@ -81,84 +79,6 @@ class Interface : public InstanceLocator
8179 friend void otPlatTrelHandleDiscoveredPeerInfo (otInstance *aInstance, const otPlatTrelPeerInfo *aInfo);
8280
8381public:
84- /* *
85- * Represents information about a discovered TREL peer.
86- */
87- class Peer : public otTrelPeer , public LinkedListEntry <Peer>
88- {
89- friend class Interface ;
90- friend class LinkedListEntry <Peer>;
91- friend void otPlatTrelHandleDiscoveredPeerInfo (otInstance *aInstance, const otPlatTrelPeerInfo *aInfo);
92-
93- public:
94- /* *
95- * Returns the Extended MAC Address of the discovered TREL peer.
96- *
97- * @returns The Extended MAC Address of the TREL peer.
98- */
99- const Mac::ExtAddress &GetExtAddress (void ) const { return static_cast <const Mac::ExtAddress &>(mExtAddress ); }
100-
101- /* *
102- * Returns the Extended PAN Identifier of the discovered TREL peer.
103- *
104- * @returns The Extended PAN Identifier of the TREL peer.
105- */
106- const MeshCoP::ExtendedPanId &GetExtPanId (void ) const
107- {
108- return static_cast <const MeshCoP::ExtendedPanId &>(mExtPanId );
109- }
110-
111- /* *
112- * Returns the IPv6 socket address of the discovered TREL peer.
113- *
114- * @returns The IPv6 socket address of the TREL peer.
115- */
116- const Ip6::SockAddr &GetSockAddr (void ) const { return static_cast <const Ip6::SockAddr &>(mSockAddr ); }
117-
118- /* *
119- * Set the IPv6 socket address of the discovered TREL peer.
120- *
121- * @param[in] aSockAddr The IPv6 socket address.
122- */
123- void SetSockAddr (const Ip6::SockAddr &aSockAddr) { mSockAddr = aSockAddr; }
124-
125- /* *
126- * Indicates whether the peer matches a given Extended Address.
127- *
128- * @param[in] aExtAddress A Extended Address to match with.
129- *
130- * @retval TRUE if the peer matches @p aExtAddress.
131- * @retval FALSE if the peer does not match @p aExtAddress.
132- */
133- bool Matches (const Mac::ExtAddress &aExtAddress) const { return GetExtAddress () == aExtAddress; }
134-
135- /* *
136- * Indicates whether the peer matches a given Socket Address.
137- *
138- * @param[in] aSockAddr A Socket Address to match with.
139- *
140- * @retval TRUE if the peer matches @p aSockAddr.
141- * @retval FALSE if the peer does not match @p aSockAddr.
142- */
143- bool Matches (const Ip6::SockAddr &aSockAddr) const { return GetSockAddr () == aSockAddr; }
144-
145- private:
146- class Info : public otPlatTrelPeerInfo
147- {
148- public:
149- bool IsRemoved (void ) const { return mRemoved ; }
150- const uint8_t *GetTxtData (void ) const { return mTxtData ; }
151- uint16_t GetTxtLength (void ) const { return mTxtLength ; }
152- const Ip6::SockAddr &GetSockAddr (void ) const { return static_cast <const Ip6::SockAddr &>(mSockAddr ); }
153- };
154-
155- void SetExtAddress (const Mac::ExtAddress &aExtAddress) { mExtAddress = aExtAddress; }
156- void SetExtPanId (const MeshCoP::ExtendedPanId &aExtPanId) { mExtPanId = aExtPanId; }
157- void Log (const char *aAction) const ;
158-
159- Peer *mNext ;
160- };
161-
16282 /* *
16383 * Represents an iterator for iterating over TREL peer table entries.
16484 */
@@ -288,6 +208,13 @@ class Interface : public InstanceLocator
288208 static const char kTxtRecordExtAddressKey [];
289209 static const char kTxtRecordExtPanIdKey [];
290210
211+ struct PeerInfo : public otPlatTrelPeerInfo
212+ {
213+ bool IsRemoved (void ) const { return mRemoved ; }
214+ const Ip6::SockAddr &GetSockAddr (void ) const { return AsCoreType (&mSockAddr ); }
215+ Error ParseTxtData (Mac::ExtAddress &aExtAddress, MeshCoP::ExtendedPanId &aExtPanId) const ;
216+ };
217+
291218 explicit Interface (Instance &aInstance);
292219
293220 // Methods used by `Trel::Link`.
@@ -298,12 +225,9 @@ class Interface : public InstanceLocator
298225
299226 // Callbacks from `otPlatTrel`.
300227 void HandleReceived (uint8_t *aBuffer, uint16_t aLength, const Ip6::SockAddr &aSenderAddr);
301- void HandleDiscoveredPeerInfo (const Peer::Info &aInfo);
228+ void HandleDiscoveredPeerInfo (const PeerInfo &aInfo);
302229
303230 void RegisterService (void );
304- Error ParsePeerInfoTxtData (const Peer::Info &aInfo,
305- Mac::ExtAddress &aExtAddress,
306- MeshCoP::ExtendedPanId &aExtPanId) const ;
307231 Peer *GetNewPeerEntry (void );
308232 void RemovePeerEntry (Peer &aEntry);
309233 void ClearPeerList (void );
0 commit comments