From 07c7ba7aa90de251488d12e73935c4a6a0d36e13 Mon Sep 17 00:00:00 2001 From: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Mon, 31 Jan 2022 11:18:55 -0800 Subject: [PATCH] Remove deprecated macro (ipconfigRAND32) references (#781) * Remove ipconfigRAND32 referances from demos * Fix license header --- .../Device_Defender_Demo/main.c | 10 +++++++--- .../Common/main.c | 10 +++++++--- .../Fleet_Provisioning_With_CSR_Demo/main.c | 10 +++++++--- .../AWS/Jobs_Windows_Simulator/Jobs_Demo/main.c | 10 +++++++--- .../Ota_Over_Http_Demo/main.c | 14 +++++++++++--- .../Ota_Over_Mqtt_Demo/main.c | 14 +++++++++++--- .../Common/main.c | 2 -- .../TCPEchoClient_SingleTasks.c | 4 +++- .../main_networking.c | 15 ++++++++++----- .../TCPEchoClient_SingleTasks.c | 4 +++- .../main_networking.c | 14 ++++++++++---- .../DemoTasks/TCPEchoClient_SingleTasks.c | 4 +++- .../main.c | 16 +++++++++++++--- .../coreHTTP_Windows_Simulator/Common/main.c | 14 +++++++++++--- .../coreMQTT_Windows_Simulator/Common/main.c | 14 +++++++++++--- .../main.c | 14 +++++++++++--- .../Demo/coreSNTP_Windows_Simulator/main.c | 14 +++++++++++--- 17 files changed, 136 insertions(+), 47 deletions(-) diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/main.c b/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/main.c index d2c1272bc0..c98b3316c2 100644 --- a/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/main.c @@ -231,6 +231,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -245,7 +246,12 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ulRandomNumbers[ 0 ], ulRandomNumbers[ 1 ], ulRandomNumbers[ 2 ], ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -313,8 +319,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c index f4e640ecbb..bdb550b2c5 100644 --- a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Common/main.c @@ -230,6 +230,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -244,7 +245,12 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ulRandomNumbers[ 0 ], ulRandomNumbers[ 1 ], ulRandomNumbers[ 2 ], ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -312,8 +318,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c index 84c9a9d47b..2152c18fbe 100644 --- a/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Fleet_Provisioning_Windows_Simulator/Fleet_Provisioning_With_CSR_Demo/main.c @@ -227,6 +227,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -241,7 +242,12 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ulRandomNumbers[ 0 ], ulRandomNumbers[ 1 ], ulRandomNumbers[ 2 ], ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -309,8 +315,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/main.c b/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/main.c index f8a2928c0c..0f6dcb73ce 100755 --- a/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/main.c @@ -226,6 +226,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -240,7 +241,12 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ulRandomNumbers[ 0 ], ulRandomNumbers[ 1 ], ulRandomNumbers[ 2 ], ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -308,8 +314,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/main.c b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/main.c index 010a4d2d7b..501a14f825 100644 --- a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Http_Demo/main.c @@ -225,6 +225,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -239,7 +240,16 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -307,8 +317,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/main.c b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/main.c index 4e5f61df06..c7cf22b0fe 100644 --- a/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/main.c +++ b/FreeRTOS-Plus/Demo/AWS/Ota_Windows_Simulator/Ota_Over_Mqtt_Demo/main.c @@ -226,6 +226,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -240,7 +241,16 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -308,8 +318,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/main.c index b62afe625a..3492c10796 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/Common/main.c @@ -278,8 +278,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/TCPEchoClient_SingleTasks.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/TCPEchoClient_SingleTasks.c index 6ba3fe5afc..a345f5d781 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/TCPEchoClient_SingleTasks.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/TCPEchoClient_SingleTasks.c @@ -313,12 +313,14 @@ missing data. */ BaseType_t lCharactersToAdd, lCharacter; char cChar = '0'; const BaseType_t lMinimumLength = 60; + uint32_t ulRandomNumber; /* Randomise the number of characters that will be sent in the echo request. */ do { - lCharactersToAdd = ipconfigRAND32() % ( ulBufferLength - 20UL ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumber ); + lCharactersToAdd = ulRandomNumber % ( ulBufferLength - 20UL ); } while( ( lCharactersToAdd == 0 ) || ( lCharactersToAdd < lMinimumLength ) ); /* Must be at least enough to add the unique text to the start of the string later. */ /* Fill the buffer. */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/main_networking.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/main_networking.c index 7fe04901be..cd4b130689 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/main_networking.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Posix/main_networking.c @@ -236,16 +236,21 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { time_t xTimeNow; - + uint32_t ulRandomNumbers[ 4 ]; /* Seed the random number generator. */ time( &xTimeNow ); FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); + + ( 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", - ipconfigRAND32(), - ipconfigRAND32(), - ipconfigRAND32(), - ipconfigRAND32() ) ); + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c index ad83f19137..db7d413b00 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/TCPEchoClient_SingleTasks.c @@ -318,12 +318,14 @@ missing data. */ BaseType_t lCharactersToAdd, lCharacter; char cChar = '0'; const BaseType_t lMinimumLength = 60; + uint32_t ulRandomNumber; /* Randomise the number of characters that will be sent in the echo request. */ do { - lCharactersToAdd = ipconfigRAND32() % ( ulBufferLength - 20UL ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumber ); + lCharactersToAdd = ulRandomNumber % ( ulBufferLength - 20UL ); } while( ( lCharactersToAdd == 0 ) || ( lCharactersToAdd < lMinimumLength ) ); /* Must be at least enough to add the unique text to the start of the string later. */ /* Fill the buffer. */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c index cc14ead23a..bec60deacb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/main_networking.c @@ -257,16 +257,22 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { time_t xTimeNow; + uint32_t ulRandomNumbers[ 4 ]; /* Seed the random number generator. */ time( &xTimeNow ); FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); + + ( 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", - ipconfigRAND32(), - ipconfigRAND32(), - ipconfigRAND32(), - ipconfigRAND32() ) ); + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/DemoTasks/TCPEchoClient_SingleTasks.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/DemoTasks/TCPEchoClient_SingleTasks.c index 92dfb32a7c..db7a9b9e8e 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/DemoTasks/TCPEchoClient_SingleTasks.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/DemoTasks/TCPEchoClient_SingleTasks.c @@ -298,12 +298,14 @@ static BaseType_t prvCreateTxData( char *cBuffer, uint32_t ulBufferLength ) BaseType_t lCharactersToAdd, lCharacter; char cChar = '0'; const BaseType_t lMinimumLength = 60; +uint32_t ulRandomNumber; /* Randomise the number of characters that will be sent in the echo request. */ do { - lCharactersToAdd = ipconfigRAND32() % ( ulBufferLength - 20UL ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumber ); + lCharactersToAdd = ulRandomNumber % ( ulBufferLength - 20UL ); } while ( ( lCharactersToAdd == 0 ) || ( lCharactersToAdd < lMinimumLength ) ); /* Must be at least enough to add the unique text to the start of the string later. */ /* Fill the buffer. */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c index 790a40c3b7..865ccde500 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator/main.c @@ -1,6 +1,6 @@ /* * FreeRTOS V202112.00 - * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -20,7 +20,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * https://www.FreeRTOS.org - * https://aws.amazon.com/freertos + * https://github.com/FreeRTOS * */ @@ -300,6 +300,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -308,7 +309,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\r\n", + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c index 323510da11..c362e98028 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c @@ -226,6 +226,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -240,7 +241,16 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -308,8 +318,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c index 42446b40fc..bbd9f24962 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c @@ -262,6 +262,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -276,7 +277,16 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -344,8 +354,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c index b1b957164e..65907b7a67 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/main.c @@ -220,6 +220,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumbers[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -234,7 +235,16 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", + ulRandomNumbers[ 0 ], + ulRandomNumbers[ 1 ], + ulRandomNumbers[ 2 ], + ulRandomNumbers[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -302,8 +312,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS. diff --git a/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/main.c b/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/main.c index 4f97365ef4..62e41700ee 100755 --- a/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/main.c +++ b/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/main.c @@ -273,6 +273,7 @@ static void prvMiscInitialisation( void ) { time_t xTimeNow; uint32_t ulLoggingIPAddress; + uint32_t ulRandomNumber[ 4 ]; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configUDP_LOGGING_ADDR0, configUDP_LOGGING_ADDR1, configUDP_LOGGING_ADDR2, configUDP_LOGGING_ADDR3 ); vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); @@ -287,7 +288,16 @@ static void prvMiscInitialisation( void ) time( &xTimeNow ); LogDebug( ( "Seed for randomizer: %lu\n", xTimeNow ) ); prvSRand( ( uint32_t ) xTimeNow ); - LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32() ) ); + + ( void ) xApplicationGetRandomNumber( &ulRandomNumber[ 0 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumber[ 1 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumber[ 2 ] ); + ( void ) xApplicationGetRandomNumber( &ulRandomNumber[ 3 ] ); + LogDebug( ( "Random numbers: %08X %08X %08X %08X\n", + ulRandomNumber[ 0 ], + ulRandomNumber[ 1 ], + ulRandomNumber[ 2 ], + ulRandomNumber[ 3 ] ) ); } /*-----------------------------------------------------------*/ @@ -355,8 +365,6 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress, /* * Set *pulNumber to a random number, and return pdTRUE. When the random number * generator is broken, it shall return pdFALSE. - * The macros ipconfigRAND32() and configRAND32() are not in use - * anymore in FreeRTOS+TCP. * * THIS IS ONLY A DUMMY IMPLEMENTATION THAT RETURNS A PSEUDO RANDOM NUMBER SO IS * NOT INTENDED FOR USE IN PRODUCTION SYSTEMS.