mirror of
https://github.com/espressif/openthread.git
synced 2026-09-21 08:27:33 +00:00
Do not allow enabling Thread protocols when PAN ID is set to broadcast. (#405)
This commit is contained in:
@@ -23,6 +23,12 @@ $ cd <path-to-openthread>/output/<platform>/bin
|
||||
$ ./ot-cli 1
|
||||
```
|
||||
|
||||
Set the PAN ID:
|
||||
|
||||
```bash
|
||||
> panid 0x1234
|
||||
```
|
||||
|
||||
Bring up the IPv6 interface:
|
||||
|
||||
```bash
|
||||
@@ -65,6 +71,12 @@ $ cd <path-to-openthread>/output/<platform>/bin
|
||||
$ ./ot-cli 2
|
||||
```
|
||||
|
||||
Set the PAN ID:
|
||||
|
||||
```bash
|
||||
> panid 0x1234
|
||||
```
|
||||
|
||||
Bring up the IPv6 interface:
|
||||
|
||||
```bash
|
||||
|
||||
+12
-1
@@ -276,7 +276,17 @@ otPanId otGetPanId(void)
|
||||
|
||||
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)
|
||||
@@ -894,6 +904,7 @@ ThreadError otThreadStart(void)
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
VerifyOrExit(mEnabled, error = kThreadError_InvalidState);
|
||||
VerifyOrExit(sThreadNetif->GetMac().GetPanId() != Mac::kPanIdBroadcast, error = kThreadError_InvalidState);
|
||||
|
||||
error = sThreadNetif->GetMle().Start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user