mirror of https://github.com/ARMmbed/mbed-os.git
random socket port number
parent
52cb119571
commit
b7bad77569
|
@ -15,6 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "CellularUtil.h"
|
#include "CellularUtil.h"
|
||||||
|
#include "randLIB.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -315,12 +316,9 @@ int char_str_to_hex_str(const char* str, uint16_t len, char *buf, bool omit_lead
|
||||||
|
|
||||||
uint16_t get_dynamic_ip_port()
|
uint16_t get_dynamic_ip_port()
|
||||||
{
|
{
|
||||||
static uint16_t port;
|
randLIB_seed_random();
|
||||||
port++;
|
|
||||||
if (port < 49152) {
|
return (randLIB_get_16bit() | 0xC000);
|
||||||
port = 49152;
|
|
||||||
}
|
|
||||||
return port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mbed_cellular_util
|
} // namespace mbed_cellular_util
|
||||||
|
|
Loading…
Reference in New Issue