Do not allow enabling Thread protocols when PAN ID is set to broadcast. (#405)

This commit is contained in:
Jonathan Hui
2016-08-17 14:32:55 -07:00
committed by GitHub
parent 8ed1c72e21
commit ceb2a9b22a
2 changed files with 24 additions and 1 deletions
+12
View File
@@ -23,6 +23,12 @@ $ cd <path-to-openthread>/output/<platform>/bin
$ ./ot-cli 1 $ ./ot-cli 1
``` ```
Set the PAN ID:
```bash
> panid 0x1234
```
Bring up the IPv6 interface: Bring up the IPv6 interface:
```bash ```bash
@@ -65,6 +71,12 @@ $ cd <path-to-openthread>/output/<platform>/bin
$ ./ot-cli 2 $ ./ot-cli 2
``` ```
Set the PAN ID:
```bash
> panid 0x1234
```
Bring up the IPv6 interface: Bring up the IPv6 interface:
```bash ```bash
+12 -1
View File
@@ -276,7 +276,17 @@ otPanId otGetPanId(void)
ThreadError otSetPanId(otPanId aPanId) ThreadError otSetPanId(otPanId aPanId)
{ {
return sThreadNetif->GetMac().SetPanId(aPanId); ThreadError error = kThreadError_None;
// do not allow setting PAN ID to broadcast if Thread is running
VerifyOrExit(aPanId != Mac::kPanIdBroadcast ||
sThreadNetif->GetMle().GetDeviceState() != Mle::kDeviceStateDisabled,
error = kThreadError_InvalidState);
error = sThreadNetif->GetMac().SetPanId(aPanId);
exit:
return error;
} }
bool otIsRouterRoleEnabled(void) bool otIsRouterRoleEnabled(void)
@@ -894,6 +904,7 @@ ThreadError otThreadStart(void)
ThreadError error = kThreadError_None; ThreadError error = kThreadError_None;
VerifyOrExit(mEnabled, error = kThreadError_InvalidState); VerifyOrExit(mEnabled, error = kThreadError_InvalidState);
VerifyOrExit(sThreadNetif->GetMac().GetPanId() != Mac::kPanIdBroadcast, error = kThreadError_InvalidState);
error = sThreadNetif->GetMle().Start(); error = sThreadNetif->GetMle().Start();