From 257188b5e94687b63391602b532b08a4a9681a5d Mon Sep 17 00:00:00 2001 From: kangping Date: Thu, 29 Apr 2021 22:50:19 +0800 Subject: [PATCH] [tmf] avoid binding TMF port for user UDP (#6534) --- src/core/net/udp6.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/net/udp6.cpp b/src/core/net/udp6.cpp index bd2584ebc..b16f4bd46 100644 --- a/src/core/net/udp6.cpp +++ b/src/core/net/udp6.cpp @@ -409,14 +409,17 @@ uint16_t Udp::GetEphemeralPort(void) { uint16_t rval = mEphemeralPort; - if (mEphemeralPort < kDynamicPortMax) + do { - mEphemeralPort++; - } - else - { - mEphemeralPort = kDynamicPortMin; - } + if (mEphemeralPort < kDynamicPortMax) + { + mEphemeralPort++; + } + else + { + mEphemeralPort = kDynamicPortMin; + } + } while (rval == Tmf::kUdpPort); return rval; }