summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>2023-03-06 05:35:32 -0800
committerGitHub <noreply@github.com>2023-03-06 05:35:32 -0800
commitb06d17086118549cc228d6062a3594203474e26e (patch)
treebe16af138eda2dc0953b28eabb4aec704bc6037f
parent3c09383fab25139ff6a1420a8a54048b7095910f (diff)
downloadfreertos-git-b06d17086118549cc228d6062a3594203474e26e.tar.gz
Make static IP address configurable (#947)
-rw-r--r--FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/plus_tcp_hooks_winsim.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/plus_tcp_hooks_winsim.c b/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/plus_tcp_hooks_winsim.c
index 941b051de..876b65660 100644
--- a/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/plus_tcp_hooks_winsim.c
+++ b/FreeRTOS-Plus/VisualStudio_StaticProjects/FreeRTOS+TCP/plus_tcp_hooks_winsim.c
@@ -160,29 +160,34 @@ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
void vPlatformInitIpStack( void )
{
- UBaseType_t uxRandomNumber;
BaseType_t xResult;
uint8_t ucIPAddress[ 4 ];
- uint8_t ucNetMask[ 4 ] = { 255, 255, 0, 0 };
- uint8_t ucNullAddress[ 4 ] = { 0, 0, 0, 0 };
+ uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
uint8_t ucMACAddress[ 6 ];
-
- /* Generate a random number */
- uxRandomNumber = uxRand();
-
- /* Generate a random MAC address in the reserved range */
- ucMACAddress[ 0 ] = 0x00;
- ucMACAddress[ 1 ] = 0x11;
- ucMACAddress[ 2 ] = ( uxRandomNumber & 0xFF );
- ucMACAddress[ 3 ] = ( ( uxRandomNumber >> 8 ) & 0xFF );
- ucMACAddress[ 4 ] = ( ( uxRandomNumber >> 16 ) & 0xFF );
- ucMACAddress[ 5 ] = ( ( uxRandomNumber >> 24 ) & 0xFF );
-
- /* Assign a link-local address in the 169.254.0.0/16 range */
- ucIPAddress[ 0 ] = 169U;
- ucIPAddress[ 1 ] = 254U;
- ucIPAddress[ 2 ] = ( ( uxRandomNumber >> 16 ) & 0xFF );
- ucIPAddress[ 3 ] = ( ( uxRandomNumber >> 24 ) & 0xFF );
+ uint8_t ucDNSServerAddress[ 4 ];
+ uint8_t ucGatewayAddress[ 4 ];
+
+ ucMACAddress[ 0 ] = configMAC_ADDR0;
+ ucMACAddress[ 1 ] = configMAC_ADDR1;
+ ucMACAddress[ 2 ] = configMAC_ADDR2;
+ ucMACAddress[ 3 ] = configMAC_ADDR3;
+ ucMACAddress[ 4 ] = configMAC_ADDR4;
+ ucMACAddress[ 5 ] = configMAC_ADDR5;
+
+ ucIPAddress[ 0 ] = configIP_ADDR0;
+ ucIPAddress[ 1 ] = configIP_ADDR1;
+ ucIPAddress[ 2 ] = configIP_ADDR2;
+ ucIPAddress[ 3 ] = configIP_ADDR3;
+
+ ucDNSServerAddress[ 0 ] = configDNS_SERVER_ADDR0;
+ ucDNSServerAddress[ 1 ] = configDNS_SERVER_ADDR1;
+ ucDNSServerAddress[ 2 ] = configDNS_SERVER_ADDR2;
+ ucDNSServerAddress[ 3 ] = configDNS_SERVER_ADDR3;
+
+ ucGatewayAddress[ 0 ] = configGATEWAY_ADDR0;
+ ucGatewayAddress[ 1 ] = configGATEWAY_ADDR1;
+ ucGatewayAddress[ 2 ] = configGATEWAY_ADDR2;
+ ucGatewayAddress[ 3 ] = configGATEWAY_ADDR3;
/* Initialise the network interface.*/
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
@@ -192,7 +197,7 @@ void vPlatformInitIpStack( void )
pxWinPcap_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
/* === End-point 0 === */
- FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucNullAddress, ucNullAddress, ucMACAddress );
+ FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
#if ( ipconfigUSE_DHCP != 0 )
{
/* End-point 0 wants to use DHCPv4. */
@@ -203,7 +208,7 @@ void vPlatformInitIpStack( void )
xResult = FreeRTOS_IPStart();
#else
/* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */
- xResult = FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucNullAddress, ucNullAddress, ucMACAddress );
+ xResult = FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
configASSERT( xResult == pdTRUE );
@@ -228,4 +233,4 @@ eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase,
}
#endif
-/*-----------------------------------------------------------*/ \ No newline at end of file
+/*-----------------------------------------------------------*/