mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
lwip: Use hardware RNG for LWIP_RAND(), use LWIP_RAND() for random port assignment
This commit is contained in:

committed by
Angus Gratton

parent
72995bfcec
commit
73b3ae8a2d
@@ -696,14 +696,12 @@ tcp_new_port(void)
|
||||
again:
|
||||
|
||||
#if ESP_RANDOM_TCP_PORT
|
||||
tcp_port = system_get_time();
|
||||
if (tcp_port < 0)
|
||||
tcp_port = LWIP_RAND() - tcp_port;
|
||||
tcp_port %= TCP_LOCAL_PORT_RANGE_START;
|
||||
tcp_port = abs(LWIP_RAND()) % (TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START);
|
||||
tcp_port += TCP_LOCAL_PORT_RANGE_START;
|
||||
#else
|
||||
if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) {
|
||||
tcp_port = TCP_LOCAL_PORT_RANGE_START;
|
||||
}
|
||||
if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) {
|
||||
tcp_port = TCP_LOCAL_PORT_RANGE_START;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check all PCB lists. */
|
||||
|
Reference in New Issue
Block a user