[udp] forbid udp duplicate open (#6626)

This commit is contained in:
Simon Lin
2021-06-23 17:01:47 -07:00
committed by GitHub
parent d177c610f0
commit e9e875de24
7 changed files with 58 additions and 2 deletions
+7 -1
View File
@@ -109,7 +109,13 @@ otError UdpExample::ProcessOpen(uint8_t aArgsLength, Arg aArgs[])
OT_UNUSED_VARIABLE(aArgsLength);
OT_UNUSED_VARIABLE(aArgs);
return otUdpOpen(mInterpreter.mInstance, &mSocket, HandleUdpReceive, this);
otError error;
VerifyOrExit(!otUdpIsOpen(mInterpreter.mInstance, &mSocket), error = OT_ERROR_ALREADY);
error = otUdpOpen(mInterpreter.mInstance, &mSocket, HandleUdpReceive, this);
exit:
return error;
}
otError UdpExample::ProcessSend(uint8_t aArgsLength, Arg aArgs[])