mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-15 06:26:49 +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,10 +696,8 @@ 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;
|
||||
|
@@ -67,7 +67,6 @@ typedef struct sys_mbox_s {
|
||||
#define sys_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
|
||||
#define sys_sem_set_invalid( x ) ( ( *x ) = NULL )
|
||||
|
||||
uint32_t system_get_time(void);
|
||||
void sys_delay_ms(uint32_t ms);
|
||||
sys_sem_t* sys_thread_sem_init(void);
|
||||
void sys_thread_sem_deinit(void);
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include "esp_task.h"
|
||||
#include "esp_system.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/* Enable all Espressif-only options */
|
||||
@@ -65,7 +66,7 @@
|
||||
*/
|
||||
#define SMEMCPY(dst,src,len) memcpy(dst,src,len)
|
||||
|
||||
#define LWIP_RAND rand
|
||||
#define LWIP_RAND esp_random
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
|
Reference in New Issue
Block a user