Skip to content

Commit 485755f

Browse files
authored
Thread: disable security when Thread not started (project-chip#43076)
* Thread: disable security when Thread not started * Update GenericThreadStackManagerImpl_OpenThread_LwIP.cpp
1 parent 5e47925 commit 485755f

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/inet/UDPEndPointImplOpenThread.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,8 @@ CHIP_ERROR UDPEndPointImplOT::SendMsgImpl(const IPPacketInfo * aPktInfo, System:
262262

263263
LockOpenThread();
264264

265-
switch (otThreadGetDeviceRole(mOTInstance))
266-
{
267-
case OT_DEVICE_ROLE_DISABLED:
268-
case OT_DEVICE_ROLE_DETACHED:
269-
settings.mLinkSecurityEnabled = false;
270-
break;
271-
default:
272-
settings.mLinkSecurityEnabled = true;
273-
break;
274-
}
275-
276-
settings.mPriority = OT_MESSAGE_PRIORITY_NORMAL;
265+
settings.mPriority = OT_MESSAGE_PRIORITY_NORMAL;
266+
settings.mLinkSecurityEnabled = otThreadGetDeviceRole(mOTInstance) != OT_DEVICE_ROLE_DISABLED;
277267

278268
message = otUdpNewMessage(mOTInstance, &settings);
279269
VerifyOrExit(message != NULL, error = OT_ERROR_NO_BUFS);

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,17 @@ err_t GenericThreadStackManagerImpl_OpenThread_LwIP<ImplClass>::SendPacket(struc
290290
{
291291
err_t lwipErr = ERR_OK;
292292
otError otErr;
293-
otMessage * pktMsg = NULL;
294-
const otMessageSettings msgSettings = { true, OT_MESSAGE_PRIORITY_NORMAL };
293+
otMessage * pktMsg = NULL;
294+
otMessageSettings msgSettings = {};
295295
uint16_t remainingLen;
296296

297297
// Lock the OpenThread stack.
298298
// Note that at this point the LwIP core lock is also held.
299299
ThreadStackMgrImpl().LockThreadStack();
300300

301+
msgSettings.mLinkSecurityEnabled = otThreadGetDeviceRole(ThreadStackMgrImpl().OTInstance()) != OT_DEVICE_ROLE_DISABLED;
302+
msgSettings.mPriority = OT_MESSAGE_PRIORITY_NORMAL;
303+
301304
// Allocate an OpenThread message
302305
pktMsg = otIp6NewMessage(ThreadStackMgrImpl().OTInstance(), &msgSettings);
303306
VerifyOrExit(pktMsg != NULL, lwipErr = ERR_MEM);

0 commit comments

Comments
 (0)