mirror of
https://github.com/espressif/openthread.git
synced 2026-09-19 15:40:07 +00:00
[ip6] add check before adding or removing the unsecure port (#4839)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user