Remove deprecated ipconfigRAND32 (#1108)

* Remove deprecated ipconfigRAND32

* Uncrustify: triggered by comment.

* Update

* Check for return value

* Uncrustify: triggered by comment.

* Update

---------

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Monika Singh 2023-11-01 12:33:25 +05:30 committed by GitHub
parent b1cadcc6fc
commit f60dd88609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 131 additions and 182 deletions

View file

@ -60,26 +60,26 @@ extern void vLoggingPrintf( const char * pcFormatString,
/* Define the byte order of the target MCU (the MCU FreeRTOS+TCP is executing
* on). Valid options are pdFREERTOS_BIG_ENDIAN and pdFREERTOS_LITTLE_ENDIAN. */
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
/* If the network card/driver includes checksum offloading (IP/TCP/UDP checksums)
* then set ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM to 1 to prevent the software
* stack repeating the checksum calculations. */
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 1
/* Several API's will block until the result is known, or the action has been
* performed, for example FreeRTOS_send() and FreeRTOS_recv(). The timeouts can be
* set per socket, using setsockopt(). If not set, the times below will be
* used as defaults. */
#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
#define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME ( 5000 )
#define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME ( 5000 )
/* Include support for LLMNR: Link-local Multicast Name Resolution
* (non-Microsoft) */
#define ipconfigUSE_LLMNR ( 1 )
#define ipconfigUSE_LLMNR ( 1 )
/* Include support for NBNS: NetBIOS Name Service (Microsoft) */
#define ipconfigUSE_NBNS ( 1 )
#define ipconfigUSE_NBNS ( 1 )
/* Include support for DNS caching. For TCP, having a small DNS cache is very
* useful. When a cache is present, ipconfigDNS_REQUEST_ATTEMPTS can be kept low
@ -87,13 +87,13 @@ extern void vLoggingPrintf( const char * pcFormatString,
* socket has been destroyed, the result will be stored into the cache. The next
* call to FreeRTOS_gethostbyname() will return immediately, without even creating
* a socket. */
#define ipconfigUSE_DNS_CACHE ( 1 )
#define ipconfigDNS_CACHE_NAME_LENGTH ( 33 )
#define ipconfigDNS_CACHE_ENTRIES ( 4 )
#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
#define ipconfigUSE_DNS_CACHE ( 1 )
#define ipconfigDNS_CACHE_NAME_LENGTH ( 33 )
#define ipconfigDNS_CACHE_ENTRIES ( 4 )
#define ipconfigDNS_REQUEST_ATTEMPTS ( 2 )
/* Let DNS wait for 3 seconds for an answer. */
#define ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS pdMS_TO_TICKS( 3000U )
#define ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS pdMS_TO_TICKS( 3000U )
/* The IP stack executes it its own task (although any application task can make
* use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY
@ -104,22 +104,14 @@ extern void vLoggingPrintf( const char * pcFormatString,
* FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to
* the priority assigned to the task executing the IP stack relative to the
* priority assigned to tasks that use the IP stack. */
#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
#define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
/* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP
* task. This setting is less important when the FreeRTOS Win32 simulator is used
* as the Win32 simulator only stores a fixed amount of information on the task
* stack. FreeRTOS includes optional stack overflow detection, see:
* http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for
* things such as a DHCP transaction number or initial sequence number. Random
* number generation is performed via this macro to allow applications to use their
* own random number generation method. For example, it might be possible to
* generate a random number by sampling noise on an analogue input. */
extern UBaseType_t uxRand();
#define ipconfigRAND32() uxRand()
#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the
* network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK

View file

@ -464,15 +464,6 @@ UBaseType_t uxRand( void )
}
/*-----------------------------------------------------------*/
uint32_t uxRand32( void )
{
/* uxRand only returns 15 random bits. Call it 3 times. */
uint32_t ul[ 3 ] = { uxRand(), uxRand(), uxRand() };
uint32_t uxReturn = ul[ 0 ] | ( ul[ 1 ] << 15 ) | ( ul[ 2 ] << 30 );
return uxReturn;
}
static void prvSRand( UBaseType_t ulSeed )
{
/* Utility function to seed the pseudo random number generator. */
@ -483,6 +474,7 @@ static void prvSRand( UBaseType_t ulSeed )
static void prvMiscInitialisation( void )
{
time_t xTimeNow;
uint32_t ulRandomNumbers[ 4 ];
uint32_t ulLoggingIPAddress;
ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
@ -492,7 +484,16 @@ static void prvMiscInitialisation( void )
time( &xTimeNow );
FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\r\n", xTimeNow ) );
prvSRand( ( uint32_t ) xTimeNow );
FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\r\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] );
FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\n",
ulRandomNumbers[ 0 ],
ulRandomNumbers[ 1 ],
ulRandomNumbers[ 2 ],
ulRandomNumbers[ 3 ] ) );
}
/*-----------------------------------------------------------*/
@ -637,12 +638,16 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort )
{
uint32_t ulRandomNumber;
( void ) ulSourceAddress;
( void ) usSourcePort;
( void ) ulDestinationAddress;
( void ) usDestinationPort;
return uxRand32();
( void ) xApplicationGetRandomNumber( &ulRandomNumber );
return ulRandomNumber;
}
/*-----------------------------------------------------------*/
@ -930,34 +935,41 @@ static void vDNSEvent( const char * pcName,
static void dns_test( const char * pcHostName )
{
uint32_t ulID = uxRand32();
uint32_t ulID;
BaseType_t rc;
FreeRTOS_dnsclear();
if( xApplicationGetRandomNumber( &( ulID ) ) != pdFALSE )
{
FreeRTOS_dnsclear();
struct freertos_addrinfo xHints;
struct freertos_addrinfo * pxResult = NULL;
struct freertos_addrinfo xHints;
struct freertos_addrinfo * pxResult = NULL;
memset( &xHints, 0, sizeof xHints );
xHints.ai_family = FREERTOS_AF_INET6;
memset( &xHints, 0, sizeof xHints );
xHints.ai_family = FREERTOS_AF_INET6;
rc = FreeRTOS_getaddrinfo( pcHostName, NULL, &xHints, &pxResult );
rc = FreeRTOS_getaddrinfo( pcHostName, NULL, &xHints, &pxResult );
FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );
FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );
FreeRTOS_dnsclear();
xDNSResult = -2;
rc = FreeRTOS_getaddrinfo_a( pcHostName,
NULL,
&xHints,
&pxResult, /* An allocated struct, containing the results. */
vDNSEvent,
( void * ) ulID,
pdMS_TO_TICKS( 1000U ) );
vTaskDelay( pdMS_TO_TICKS( 1000U ) );
rc = xDNSResult;
FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );
/* FreeRTOS_gethostbyname( pcHostName ); */
FreeRTOS_dnsclear();
xDNSResult = -2;
rc = FreeRTOS_getaddrinfo_a( pcHostName,
NULL,
&xHints,
&pxResult, /* An allocated struct, containing the results. */
vDNSEvent,
( void * ) ulID,
pdMS_TO_TICKS( 1000U ) );
vTaskDelay( pdMS_TO_TICKS( 1000U ) );
rc = xDNSResult;
FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );
/* FreeRTOS_gethostbyname( pcHostName ); */
}
else
{
FreeRTOS_printf( ( "dns_test: Failed to generate a random SearchID\n" ) );
}
}
void showAddressInfo( struct freertos_addrinfo * pxAddrInfo )