[cli] add command to set mesh-local prefix (#7663)

Also add an expect test for getting/setting mesh-local prefix.
This commit is contained in:
Jonathan Hui
2022-05-05 21:42:58 -07:00
committed by GitHub
parent fa939be97b
commit 3a125c66d2
3 changed files with 29 additions and 1 deletions
+9
View File
@@ -2177,6 +2177,15 @@ fdde:ad00:beef:0::/64
Done
```
### prefix meshlocal <prefix>
Set the mesh local prefix.
```bash
> prefix meshlocal fdde:ad00:beef:0::/64
Done
```
### prefix remove \<prefix\>
Invalidate a prefix in the Network Data.
+13 -1
View File
@@ -3564,7 +3564,19 @@ template <> otError Interpreter::Process<Cmd("prefix")>(Arg aArgs[])
}
else if (aArgs[0] == "meshlocal")
{
OutputIp6PrefixLine(*otThreadGetMeshLocalPrefix(GetInstancePtr()));
if (aArgs[1].IsEmpty())
{
OutputIp6PrefixLine(*otThreadGetMeshLocalPrefix(GetInstancePtr()));
}
else
{
otIp6Prefix prefix;
SuccessOrExit(error = aArgs[1].ParseAsIp6Prefix(prefix));
VerifyOrExit(prefix.mLength == OT_IP6_PREFIX_BITSIZE, error = OT_ERROR_INVALID_ARGS);
error =
otThreadSetMeshLocalPrefix(GetInstancePtr(), reinterpret_cast<otMeshLocalPrefix *>(&prefix.mPrefix));
}
}
else
{
+7
View File
@@ -180,6 +180,13 @@ expect "Done"
send "ba state\n"
expect "Done"
send "prefix meshlocal fd00:dead:beef:cafe::/96\n"
expect_line "Error 7: InvalidArgs"
send "prefix meshlocal fd00:dead:beef:cafe::/64\n"
expect_line "Done"
send "prefix meshlocal\n"
expect_line "fd00:dead:beef:cafe::/64"
send "invalidcommand\n"
expect_line "Error 35: InvalidCommand"