mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-06 22:20:43 +08:00
Merge branch 'feature/lwip_allocate_a_new_random_local_tcp_port' into 'master'
feat:Make lallocate a new local TCP port is random See merge request sdk/ESP8266_RTOS_SDK!616
This commit is contained in:
@ -62,6 +62,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if ESP_LWIP
|
||||
#include "arch/sys_arch.h"
|
||||
#endif
|
||||
|
||||
#ifdef LWIP_HOOK_FILENAME
|
||||
#include LWIP_HOOK_FILENAME
|
||||
#endif
|
||||
@ -847,9 +851,13 @@ tcp_new_port(void)
|
||||
struct tcp_pcb *pcb;
|
||||
|
||||
again:
|
||||
#if ESP_LWIP
|
||||
tcp_port = (u16_t)(esp_random() % (TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START)) + TCP_LOCAL_PORT_RANGE_START;
|
||||
#else
|
||||
if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) {
|
||||
tcp_port = TCP_LOCAL_PORT_RANGE_START;
|
||||
}
|
||||
#endif
|
||||
/* Check all PCB lists. */
|
||||
for (i = 0; i < NUM_TCP_PCB_LISTS; i++) {
|
||||
for (pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) {
|
||||
|
Reference in New Issue
Block a user