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; }