Skip to content

Commit 99a747c

Browse files
NordicBuilderanangl
authored andcommitted
openthread: add libraries based on commit a57d927
Update OpenThread libraries with newest commit Signed-off-by: Nordic Builder <[email protected]>
1 parent 0f8384c commit 99a747c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1543
-92
lines changed

openthread/include/openthread/border_agent.h

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ extern "C" {
5757
*/
5858
#define OT_BORDER_AGENT_ID_LENGTH (16)
5959

60+
/**
61+
* Minimum length of the ephemeral key string.
62+
*
63+
*/
64+
#define OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH (6)
65+
66+
/**
67+
* Maximum length of the ephemeral key string.
68+
*
69+
*/
70+
#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH (32)
71+
72+
/**
73+
* Default ephemeral key timeout interval in milliseconds.
74+
*
75+
*/
76+
#define OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT (2 * 60 * 1000u)
77+
78+
/**
79+
* Maximum ephemeral key timeout interval in milliseconds.
80+
*
81+
*/
82+
#define OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT (10 * 60 * 1000u)
83+
6084
/**
6185
* @struct otBorderAgentId
6286
*
@@ -109,6 +133,8 @@ uint16_t otBorderAgentGetUdpPort(otInstance *aInstance);
109133
/**
110134
* Gets the randomly generated Border Agent ID.
111135
*
136+
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE`.
137+
*
112138
* The ID is saved in persistent storage and survives reboots. The typical use case of the ID is to
113139
* be published in the MeshCoP mDNS service as the `id` TXT value for the client to identify this
114140
* Border Router/Agent device.
@@ -127,6 +153,8 @@ otError otBorderAgentGetId(otInstance *aInstance, otBorderAgentId *aId);
127153
/**
128154
* Sets the Border Agent ID.
129155
*
156+
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE`.
157+
*
130158
* The Border Agent ID will be saved in persistent storage and survive reboots. It's required to
131159
* set the ID only once after factory reset. If the ID has never been set by calling this function,
132160
* a random ID will be generated and returned when `otBorderAgentGetId` is called.
@@ -142,6 +170,112 @@ otError otBorderAgentGetId(otInstance *aInstance, otBorderAgentId *aId);
142170
*/
143171
otError otBorderAgentSetId(otInstance *aInstance, const otBorderAgentId *aId);
144172

173+
/**
174+
* Sets the ephemeral key for a given timeout duration.
175+
*
176+
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
177+
*
178+
* The ephemeral key can be set when the Border Agent is already running and is not currently connected to any external
179+
* commissioner (i.e., it is in `OT_BORDER_AGENT_STATE_STARTED` state). Otherwise `OT_ERROR_INVALID_STATE` is returned.
180+
*
181+
* The given @p aKeyString is directly used as the ephemeral PSK (excluding the trailing null `\0` character ).
182+
* The @p aKeyString length must be between `OT_BORDER_AGENT_MIN_EPHEMERAL_KEY_LENGTH` and
183+
* `OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_LENGTH`, inclusive.
184+
*
185+
* Setting the ephemeral key again before a previously set key has timed out will replace the previously set key and
186+
* reset the timeout.
187+
*
188+
* While the timeout interval is in effect, the ephemeral key can be used only once by an external commissioner to
189+
* connect. Once the commissioner disconnects, the ephemeral key is cleared, and the Border Agent reverts to using
190+
* PSKc.
191+
*
192+
* @param[in] aInstance The OpenThread instance.
193+
* @param[in] aKeyString The ephemeral key string (used as PSK excluding the trailing null `\0` character).
194+
* @param[in] aTimeout The timeout duration in milliseconds to use the ephemeral key.
195+
* If zero, the default `OT_BORDER_AGENT_DEFAULT_EPHEMERAL_KEY_TIMEOUT` value will be used.
196+
* If the given timeout value is larger than `OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT`, the
197+
* max value `OT_BORDER_AGENT_MAX_EPHEMERAL_KEY_TIMEOUT` will be used instead.
198+
* @param[in] aUdpPort The UDP port to use with ephemeral key. If zero, an ephemeral port will be used.
199+
* `otBorderAgentGetUdpPort()` will return the current UDP port being used.
200+
*
201+
* @retval OT_ERROR_NONE Successfully set the ephemeral key.
202+
* @retval OT_ERROR_INVALID_STATE Border Agent is not running or it is connected to an external commissioner.
203+
* @retval OT_ERROR_INVALID_ARGS The given @p aKeyString is not valid (too short or too long).
204+
* @retval OT_ERROR_FAILED Failed to set the key (e.g., could not bind to UDP port).
205+
206+
*
207+
*/
208+
otError otBorderAgentSetEphemeralKey(otInstance *aInstance,
209+
const char *aKeyString,
210+
uint32_t aTimeout,
211+
uint16_t aUdpPort);
212+
213+
/**
214+
* Cancels the ephemeral key that is in use.
215+
*
216+
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
217+
*
218+
* Can be used to cancel a previously set ephemeral key before it times out. If the Border Agent is not running or
219+
* there is no ephemeral key in use, calling this function has no effect.
220+
*
221+
* If a commissioner is connected using the ephemeral key and is currently active, calling this function does not
222+
* change its state. In this case the `otBorderAgentIsEphemeralKeyActive()` will continue to return `TRUE` until the
223+
* commissioner disconnects.
224+
*
225+
* @param[in] aInstance The OpenThread instance.
226+
*
227+
*/
228+
void otBorderAgentClearEphemeralKey(otInstance *aInstance);
229+
230+
/**
231+
* Indicates whether or not an ephemeral key is currently active.
232+
*
233+
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
234+
*
235+
* @param[in] aInstance The OpenThread instance.
236+
*
237+
* @retval TRUE An ephemeral key is active.
238+
* @retval FALSE No ephemeral key is active.
239+
*
240+
*/
241+
bool otBorderAgentIsEphemeralKeyActive(otInstance *aInstance);
242+
243+
/**
244+
* Callback function pointer to signal changes related to the Border Agent's ephemeral key.
245+
*
246+
* This callback is invoked whenever:
247+
*
248+
* - The Border Agent starts using an ephemeral key.
249+
* - Any parameter related to the ephemeral key, such as the port number, changes.
250+
* - The Border Agent stops using the ephemeral key due to:
251+
* - A direct call to `otBorderAgentClearEphemeralKey()`.
252+
* - The ephemeral key timing out.
253+
* - An external commissioner successfully using the key to connect and then disconnecting.
254+
* - Reaching the maximum number of allowed failed connection attempts.
255+
*
256+
* Any OpenThread API, including `otBorderAgent` APIs, can be safely called from this callback.
257+
*
258+
* @param[in] aContext A pointer to an arbitrary context (provided when callback is set).
259+
*
260+
*/
261+
typedef void (*otBorderAgentEphemeralKeyCallback)(void *aContext);
262+
263+
/**
264+
* Sets the callback function used by the Border Agent to notify any changes related to use of ephemeral key.
265+
*
266+
* Requires `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
267+
*
268+
* A subsequent call to this function will replace any previously set callback.
269+
*
270+
* @param[in] aInstance The OpenThread instance.
271+
* @param[in] aCallback The callback function pointer.
272+
* @param[in] aContext The arbitrary context to use with callback.
273+
*
274+
*/
275+
void otBorderAgentSetEphemeralKeyCallback(otInstance *aInstance,
276+
otBorderAgentEphemeralKeyCallback aCallback,
277+
void *aContext);
278+
145279
/**
146280
* @}
147281
*

openthread/include/openthread/border_routing.h

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ typedef struct otBorderRoutingPrefixTableIterator
8585
{
8686
const void *mPtr1;
8787
const void *mPtr2;
88-
uint32_t mData32;
88+
uint32_t mData1;
89+
uint8_t mData2;
90+
uint8_t mData3;
8991
} otBorderRoutingPrefixTableIterator;
9092

9193
/**
@@ -95,9 +97,11 @@ typedef struct otBorderRoutingPrefixTableIterator
9597
typedef struct otBorderRoutingRouterEntry
9698
{
9799
otIp6Address mAddress; ///< IPv6 address of the router.
100+
uint32_t mMsecSinceLastUpdate; ///< Milliseconds since last update (any message rx) from this router.
98101
bool mManagedAddressConfigFlag : 1; ///< The router's Managed Address Config flag (`M` flag).
99102
bool mOtherConfigFlag : 1; ///< The router's Other Config flag (`O` flag).
100103
bool mStubRouterFlag : 1; ///< The router's Stub Router flag.
104+
bool mIsLocalDevice : 1; ///< This router is the local device (this BR).
101105
} otBorderRoutingRouterEntry;
102106

103107
/**
@@ -239,6 +243,22 @@ void otBorderRoutingSetRouteInfoOptionPreference(otInstance *aInstance, otRouteP
239243
*/
240244
void otBorderRoutingClearRouteInfoOptionPreference(otInstance *aInstance);
241245

246+
/**
247+
* Sets additional options to append at the end of emitted Router Advertisement (RA) messages.
248+
*
249+
* The content of @p aOptions is copied internally, so it can be a temporary buffer (e.g., a stack allocated array).
250+
*
251+
* Subsequent calls to this function overwrite the previously set value.
252+
*
253+
* @param[in] aOptions A pointer to the encoded options. Can be `NULL` to clear.
254+
* @param[in] aLength Number of bytes in @p aOptions.
255+
*
256+
* @retval OT_ERROR_NONE Successfully set the extra option bytes.
257+
* @retval OT_ERROR_NO_BUFS Could not allocate buffer to save the buffer.
258+
*
259+
*/
260+
otError otBorderRoutingSetExtraRouterAdvertOptions(otInstance *aInstance, const uint8_t *aOptions, uint16_t aLength);
261+
242262
/**
243263
* Gets the current preference used for published routes in Network Data.
244264
*
@@ -482,6 +502,31 @@ void otBorderRoutingDhcp6PdSetEnabled(otInstance *aInstance, bool aEnabled);
482502
*/
483503
otBorderRoutingDhcp6PdState otBorderRoutingDhcp6PdGetState(otInstance *aInstance);
484504

505+
/**
506+
* When the state of a DHCPv6 Prefix Delegation (PD) on the Thread interface changes, this callback notifies processes
507+
* in the OS of this changed state.
508+
*
509+
* @param[in] aState The state of DHCPv6 Prefix Delegation State.
510+
* @param[in] aContext A pointer to arbitrary context information.
511+
*
512+
*/
513+
typedef void (*otBorderRoutingRequestDhcp6PdCallback)(otBorderRoutingDhcp6PdState aState, void *aContext);
514+
515+
/**
516+
* Sets the callback whenever the DHCPv6 PD state changes on the Thread interface.
517+
*
518+
* Subsequent calls to this function replace the previously set callback.
519+
*
520+
* @param[in] aInstance A pointer to an OpenThread instance.
521+
* @param[in] aCallback A pointer to a function that is called whenever the DHCPv6 PD state changes.
522+
* @param[in] aContext A pointer to arbitrary context information.
523+
*
524+
*
525+
*/
526+
void otBorderRoutingDhcp6PdSetRequestCallback(otInstance *aInstance,
527+
otBorderRoutingRequestDhcp6PdCallback aCallback,
528+
void *aContext);
529+
485530
/**
486531
* @}
487532
*

openthread/include/openthread/channel_manager.h

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ extern "C" {
4747
* @brief
4848
* This module includes functions for Channel Manager.
4949
*
50-
* The functions in this module are available when Channel Manager feature
51-
* (`OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE`) is enabled. Channel Manager is available only on an FTD build.
50+
* The functions in this module are available when Channel Manager features
51+
* `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` or `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
52+
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` are enabled. Channel Manager behavior depends on the
53+
* device role. It manages the network-wide PAN channel on a Full Thread Device in rx-on-when-idle mode, or with
54+
* `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` set,
55+
* selects CSL channel in synchronized rx-off-when-idle mode. On a Minimal Thread Device
56+
* `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` selects
57+
* the CSL channel.
5258
*
5359
* @{
5460
*
@@ -77,7 +83,9 @@ void otChannelManagerRequestChannelChange(otInstance *aInstance, uint8_t aChanne
7783
uint8_t otChannelManagerGetRequestedChannel(otInstance *aInstance);
7884

7985
/**
80-
* Gets the delay (in seconds) used by Channel Manager for a channel change.
86+
* Gets the delay (in seconds) used by Channel Manager for a network channel change.
87+
*
88+
* Only available on FTDs.
8189
*
8290
* @param[in] aInstance A pointer to an OpenThread instance.
8391
*
@@ -87,10 +95,10 @@ uint8_t otChannelManagerGetRequestedChannel(otInstance *aInstance);
8795
uint16_t otChannelManagerGetDelay(otInstance *aInstance);
8896

8997
/**
90-
* Sets the delay (in seconds) used for a channel change.
98+
* Sets the delay (in seconds) used for a network channel change.
9199
*
92-
* The delay should preferably be longer than the maximum data poll interval used by all sleepy-end-devices within the
93-
* Thread network.
100+
* Only available on FTDs. The delay should preferably be longer than the maximum data poll interval used by all
101+
* Sleepy End Devices within the Thread network.
94102
*
95103
* @param[in] aInstance A pointer to an OpenThread instance.
96104
* @param[in] aDelay Delay in seconds.
@@ -117,7 +125,7 @@ otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay);
117125
*
118126
* 2) If the first step passes, then `ChannelManager` selects a potentially better channel. It uses the collected
119127
* channel quality data by `ChannelMonitor` module. The supported and favored channels are used at this step.
120-
* (see otChannelManagerSetSupportedChannels() and otChannelManagerSetFavoredChannels()).
128+
* (see `otChannelManagerSetSupportedChannels()` and `otChannelManagerSetFavoredChannels()`).
121129
*
122130
* 3) If the newly selected channel is different from the current channel, `ChannelManager` requests/starts the
123131
* channel change process (internally invoking a `RequestChannelChange()`).
@@ -132,10 +140,41 @@ otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay);
132140
otError otChannelManagerRequestChannelSelect(otInstance *aInstance, bool aSkipQualityCheck);
133141

134142
/**
135-
* Enables or disables the auto-channel-selection functionality.
143+
* Requests that `ChannelManager` checks and selects a new CSL channel and starts a CSL channel change.
144+
*
145+
* Only available with `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
146+
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE`. This function asks the `ChannelManager` to select a
147+
* channel by itself (based on collected channel quality info).
148+
*
149+
* Once called, the Channel Manager will perform the following 3 steps:
150+
*
151+
* 1) `ChannelManager` decides if the CSL channel change would be helpful. This check can be skipped if
152+
* `aSkipQualityCheck` is set to true (forcing a CSL channel selection to happen and skipping the quality check).
153+
* This step uses the collected link quality metrics on the device (such as CCA failure rate, frame and message
154+
* error rates per neighbor, etc.) to determine if the current channel quality is at the level that justifies
155+
* a CSL channel change.
156+
*
157+
* 2) If the first step passes, then `ChannelManager` selects a potentially better CSL channel. It uses the collected
158+
* channel quality data by `ChannelMonitor` module. The supported and favored channels are used at this step.
159+
* (see `otChannelManagerSetSupportedChannels()` and `otChannelManagerSetFavoredChannels()`).
160+
*
161+
* 3) If the newly selected CSL channel is different from the current CSL channel, `ChannelManager` starts the
162+
* CSL channel change process.
163+
*
164+
* @param[in] aInstance A pointer to an OpenThread instance.
165+
* @param[in] aSkipQualityCheck Indicates whether the quality check (step 1) should be skipped.
166+
*
167+
* @retval OT_ERROR_NONE Channel selection finished successfully.
168+
* @retval OT_ERROR_NOT_FOUND Supported channel mask is empty, therefore could not select a channel.
169+
*
170+
*/
171+
otError otChannelManagerRequestCslChannelSelect(otInstance *aInstance, bool aSkipQualityCheck);
172+
173+
/**
174+
* Enables or disables the auto-channel-selection functionality for network channel.
136175
*
137176
* When enabled, `ChannelManager` will periodically invoke a `RequestChannelSelect(false)`. The period interval
138-
* can be set by `SetAutoChannelSelectionInterval()`.
177+
* can be set by `otChannelManagerSetAutoChannelSelectionInterval()`.
139178
*
140179
* @param[in] aInstance A pointer to an OpenThread instance.
141180
* @param[in] aEnabled Indicates whether to enable or disable this functionality.
@@ -144,7 +183,7 @@ otError otChannelManagerRequestChannelSelect(otInstance *aInstance, bool aSkipQu
144183
void otChannelManagerSetAutoChannelSelectionEnabled(otInstance *aInstance, bool aEnabled);
145184

146185
/**
147-
* Indicates whether the auto-channel-selection functionality is enabled or not.
186+
* Indicates whether the auto-channel-selection functionality for a network channel is enabled or not.
148187
*
149188
* @param[in] aInstance A pointer to an OpenThread instance.
150189
*
@@ -153,6 +192,33 @@ void otChannelManagerSetAutoChannelSelectionEnabled(otInstance *aInstance, bool
153192
*/
154193
bool otChannelManagerGetAutoChannelSelectionEnabled(otInstance *aInstance);
155194

195+
/**
196+
* Enables or disables the auto-channel-selection functionality for a CSL channel.
197+
*
198+
* Only available with `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
199+
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE`. When enabled, `ChannelManager` will periodically invoke
200+
* a `otChannelManagerRequestCslChannelSelect()`. The period interval can be set by
201+
* `otChannelManagerSetAutoChannelSelectionInterval()`.
202+
*
203+
* @param[in] aInstance A pointer to an OpenThread instance.
204+
* @param[in] aEnabled Indicates whether to enable or disable this functionality.
205+
*
206+
*/
207+
void otChannelManagerSetAutoCslChannelSelectionEnabled(otInstance *aInstance, bool aEnabled);
208+
209+
/**
210+
* Indicates whether the auto-csl-channel-selection functionality is enabled or not.
211+
*
212+
* Only available with `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE &&
213+
* OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE`.
214+
*
215+
* @param[in] aInstance A pointer to an OpenThread instance.
216+
*
217+
* @returns TRUE if enabled, FALSE if disabled.
218+
*
219+
*/
220+
bool otChannelManagerGetAutoCslChannelSelectionEnabled(otInstance *aInstance);
221+
156222
/**
157223
* Sets the period interval (in seconds) used by auto-channel-selection functionality.
158224
*

0 commit comments

Comments
 (0)