From 275d22d8d70da011f65ae3fdf5bf5dff9efba451 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 21 Oct 2016 21:55:45 -0700 Subject: [PATCH] Ncp: Fix join existing network feature (#865) This commit changes the NcpBase and join-existing-network feature by ensuring that the flag `mRequireJoinExistingNetwork` is not cleared when role changes to detached or disabled. This fixes the issue where a "join" command could seemingly succeed with device forming its own partition (e.g, if a wrong network key is used). --- src/ncp/ncp_base.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index 9e1b784ea..06429b0bc 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -740,7 +740,16 @@ void NcpBase::UpdateChangedProps(void) { if (mRequireJoinExistingNetwork) { - mRequireJoinExistingNetwork = false; + switch (otGetDeviceRole(mInstance)) + { + case kDeviceRoleDetached: + case kDeviceRoleDisabled: + break; + + default: + mRequireJoinExistingNetwork = false; + break; + } if ( (otGetDeviceRole(mInstance) == kDeviceRoleLeader) && otIsSingleton(mInstance)