[ip6] add check before adding or removing the unsecure port (#4839)

This commit is contained in:
Rongli Sun
2020-04-15 19:59:48 -07:00
committed by GitHub
parent 8e932e8c77
commit ec61d7e6fc
3 changed files with 16 additions and 8 deletions
+6 -4
View File
@@ -418,8 +418,9 @@ otError otIp6Send(otInstance *aInstance, otMessage *aMessage);
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The port value.
*
* @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list.
* @retval OT_ERROR_NO_BUFS The unsecure port list is full.
* @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list.
* @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use).
* @retval OT_ERROR_NO_BUFS The unsecure port list is full.
*
*/
otError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort);
@@ -434,8 +435,9 @@ otError otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort);
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPort The port value.
*
* @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list.
* @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list.
* @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list.
* @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use).
* @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list.
*
*/
otError otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort);
+4
View File
@@ -124,6 +124,8 @@ otError Filter::AddUnsecurePort(uint16_t aPort)
{
otError error = OT_ERROR_NONE;
VerifyOrExit(aPort != 0, error = OT_ERROR_INVALID_ARGS);
for (int i = 0; i < kMaxUnsecurePorts; i++)
{
if (mUnsecurePorts[i] == aPort)
@@ -152,6 +154,8 @@ otError Filter::RemoveUnsecurePort(uint16_t aPort)
{
otError error = OT_ERROR_NONE;
VerifyOrExit(aPort != 0, error = OT_ERROR_INVALID_ARGS);
for (int i = 0; i < kMaxUnsecurePorts; i++)
{
if (mUnsecurePorts[i] == aPort)
+6 -4
View File
@@ -80,8 +80,9 @@ public:
*
* @param[in] aPort The port value.
*
* @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list.
* @retval OT_ERROR_NO_BUFS The unsecure port list is full.
* @retval OT_ERROR_NONE The port was successfully added to the allowed unsecure port list.
* @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use).
* @retval OT_ERROR_NO_BUFS The unsecure port list is full.
*
*/
otError AddUnsecurePort(uint16_t aPort);
@@ -91,8 +92,9 @@ public:
*
* @param[in] aPort The port value.
*
* @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list.
* @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list.
* @retval OT_ERROR_NONE The port was successfully removed from the allowed unsecure port list.
* @retval OT_ERROR_INVALID_ARGS The port is invalid (value 0 is reserved for internal use).
* @retval OT_ERROR_NOT_FOUND The port was not found in the unsecure port list.
*
*/
otError RemoveUnsecurePort(uint16_t aPort);