mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 16:57:41 -04:00
Changes in FreeRTOS+TCP demo application files to add compatibility for running EndPoint changes in the IPv4 stack. (#907)
* Update main.c * Update main.c * Update main.c * Update main.c * TCP/IP Demo Changes for Sock Addr Changes * Update SimpleClientAndServer.c * Update TwoEchoClients.c * Update SimpleUDPClientAndServer.c * Update main.c * Update main_networking.c * Update TwoEchoClients.c * Update SimpleClientAndServer.c * Update TwoEchoClients.c * Update SimpleUDPClientAndServer.c * Update main_networking.c * Update main_networking.c * Update main_networking.c * Update main.c * Update main_networking.c * Update main_networking.c * Update main.c * Update main.c * Update main.c * Update main_networking.c * Update main_networking.c * Update plus_tcp_hooks_winsim.c * Update plus_tcp_hooks_winsim.c * Update main.c * Update main.c * Update main_networking.c * Update main_networking.c * Update plus_tcp_hooks_winsim.c * Update lexicon.txt * Update lexicon.txt * Update lexicon.txt * Fix core header check Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Update main_networking.c * Update CLI-commands.c * Update plus_tcp_hooks_winsim.c * Code review suggestions Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Remove incorrect spelling from lexicon Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> * Fix Build issues in QEMU and UDP demo * Lexicon spell check issue fix * WinPcap Network Interface update * Update Network_winPCap.c * Adding declaration for pxMyInterface for EndPoint changed function in WinPCap.c * Revert changes for WinPCap.c * Update NetworkInterface_WinPCap.c * Minor code review suggestions Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
cf603c60fa
commit
38d5e421eb
13 changed files with 661 additions and 127 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.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
|
* 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
|
* 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.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -266,28 +266,44 @@ uint32_t ulAddress;
|
||||||
switch( xIndex )
|
switch( xIndex )
|
||||||
{
|
{
|
||||||
case 0 :
|
case 0 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nIP address " );
|
sprintf( pcWriteBuffer, "\r\nIP address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1 :
|
case 1 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, &ulAddress, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nNet mask " );
|
sprintf( pcWriteBuffer, "\r\nNet mask " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, &ulAddress, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nGateway address " );
|
sprintf( pcWriteBuffer, "\r\nGateway address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3 :
|
case 3 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, NULL, &ulAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nDNS server address " );
|
sprintf( pcWriteBuffer, "\r\nDNS server address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.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
|
* 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
|
* 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.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -565,28 +565,44 @@ uint32_t ulAddress;
|
||||||
switch( xIndex )
|
switch( xIndex )
|
||||||
{
|
{
|
||||||
case 0 :
|
case 0 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nIP address " );
|
sprintf( pcWriteBuffer, "\r\nIP address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1 :
|
case 1 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, &ulAddress, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nNet mask " );
|
sprintf( pcWriteBuffer, "\r\nNet mask " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, &ulAddress, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nGateway address " );
|
sprintf( pcWriteBuffer, "\r\nGateway address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3 :
|
case 3 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, NULL, &ulAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
||||||
|
#endif
|
||||||
sprintf( pcWriteBuffer, "\r\nDNS server address " );
|
sprintf( pcWriteBuffer, "\r\nDNS server address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
|
|
|
@ -118,6 +118,19 @@ const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_
|
||||||
/* Use by the pseudo random number generator. */
|
/* Use by the pseudo random number generator. */
|
||||||
static UBaseType_t ulNextRand;
|
static UBaseType_t ulNextRand;
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
|
||||||
|
/* In case multiple interfaces are used, define them statically. */
|
||||||
|
|
||||||
|
/* There is only 1 physical interface. */
|
||||||
|
static NetworkInterface_t xInterfaces[ 1 ];
|
||||||
|
|
||||||
|
/* It will have several end-points. */
|
||||||
|
static NetworkEndPoint_t xEndPoints[ 4 ];
|
||||||
|
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void main_tcp_echo_client_tasks( void )
|
void main_tcp_echo_client_tasks( void )
|
||||||
|
@ -140,12 +153,29 @@ void main_tcp_echo_client_tasks( void )
|
||||||
* vApplicationIPNetworkEventHook() below). The address values passed in here
|
* vApplicationIPNetworkEventHook() below). The address values passed in here
|
||||||
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
|
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
|
||||||
* but a DHCP server cannot be contacted. */
|
* but a DHCP server cannot be contacted. */
|
||||||
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
|
|
||||||
FreeRTOS_IPInit( ucIPAddress,
|
/* Initialise the network interface.*/
|
||||||
ucNetMask,
|
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
|
||||||
ucGatewayAddress,
|
|
||||||
ucDNSServerAddress,
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
ucMACAddress );
|
/* Initialise the interface descriptor for WinPCap. */
|
||||||
|
pxFillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
|
||||||
|
|
||||||
|
/* === End-point 0 === */
|
||||||
|
FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints [ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#if ( ipconfigUSE_DHCP != 0 )
|
||||||
|
{
|
||||||
|
/* End-point 0 wants to use DHCPv4. */
|
||||||
|
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
|
||||||
|
}
|
||||||
|
#endif /* ( ipconfigUSE_DHCP != 0 ) */
|
||||||
|
|
||||||
|
memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) );
|
||||||
|
FreeRTOS_IPStart();
|
||||||
|
#else
|
||||||
|
/* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */
|
||||||
|
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
/* Start the RTOS scheduler. */
|
/* Start the RTOS scheduler. */
|
||||||
FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
|
FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
|
||||||
|
@ -195,7 +225,11 @@ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||||
|
|
||||||
/* Print out the network configuration, which may have come from a DHCP
|
/* Print out the network configuration, which may have come from a DHCP
|
||||||
* server. */
|
* server. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
||||||
|
#endif
|
||||||
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
||||||
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
* FreeRTOSConfig.h.
|
* FreeRTOSConfig.h.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#define mainCREATE_TCP_ECHO_TASKS_SINGLE 1
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -123,6 +124,18 @@ const uint8_t ucMACAddress[ 6 ] =
|
||||||
/* Use by the pseudo random number generator. */
|
/* Use by the pseudo random number generator. */
|
||||||
static UBaseType_t ulNextRand;
|
static UBaseType_t ulNextRand;
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
|
||||||
|
/* In case multiple interfaces are used, define them statically. */
|
||||||
|
|
||||||
|
/* There is only 1 physical interface. */
|
||||||
|
static NetworkInterface_t xInterfaces[ 1 ];
|
||||||
|
|
||||||
|
/* It will have several end-points. */
|
||||||
|
static NetworkEndPoint_t xEndPoints[ 4 ];
|
||||||
|
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void main_tcp_echo_client_tasks( void )
|
void main_tcp_echo_client_tasks( void )
|
||||||
|
@ -145,12 +158,31 @@ void main_tcp_echo_client_tasks( void )
|
||||||
* vApplicationIPNetworkEventHook() below). The address values passed in here
|
* vApplicationIPNetworkEventHook() below). The address values passed in here
|
||||||
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
|
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
|
||||||
* but a DHCP server cannot be contacted. */
|
* but a DHCP server cannot be contacted. */
|
||||||
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\n" ) );
|
|
||||||
FreeRTOS_IPInit( ucIPAddress,
|
/* Initialise the network interface.*/
|
||||||
ucNetMask,
|
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
|
||||||
ucGatewayAddress,
|
|
||||||
ucDNSServerAddress,
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
ucMACAddress );
|
/* Initialise the interface descriptor for WinPCap. */
|
||||||
|
pxMPS2_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
|
||||||
|
|
||||||
|
/* === End-point 0 === */
|
||||||
|
FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#if ( ipconfigUSE_DHCP != 0 )
|
||||||
|
{
|
||||||
|
/* End-point 0 wants to use DHCPv4. */
|
||||||
|
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
|
||||||
|
}
|
||||||
|
#endif /* ( ipconfigUSE_DHCP != 0 ) */
|
||||||
|
|
||||||
|
memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) );
|
||||||
|
|
||||||
|
FreeRTOS_IPStart();
|
||||||
|
#else
|
||||||
|
/* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */
|
||||||
|
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
|
|
||||||
/* Start the RTOS scheduler. */
|
/* Start the RTOS scheduler. */
|
||||||
FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
|
FreeRTOS_debug_printf( ( "vTaskStartScheduler\n" ) );
|
||||||
|
@ -205,7 +237,11 @@ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||||
|
|
||||||
/* Print out the network configuration, which may have come from a DHCP
|
/* Print out the network configuration, which may have come from a DHCP
|
||||||
* server. */
|
* server. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
||||||
|
#endif
|
||||||
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
||||||
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.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
|
* 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
|
* 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.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
* https://www.FreeRTOS.org
|
* https://www.FreeRTOS.org
|
||||||
* https://aws.amazon.com/freertos
|
* https://github.com/FreeRTOS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -104,8 +104,11 @@ const TickType_t x150ms = 150UL / portTICK_PERIOD_MS;
|
||||||
so the IP address can be obtained immediately. store the IP address being
|
so the IP address can be obtained immediately. store the IP address being
|
||||||
used in ulIPAddress. This is done so the socket can send to a different
|
used in ulIPAddress. This is done so the socket can send to a different
|
||||||
port on the same IP address. */
|
port on the same IP address. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
/* This test sends to itself, so data sent from here is received by a server
|
/* This test sends to itself, so data sent from here is received by a server
|
||||||
socket on the same IP address. Setup the freertos_sockaddr structure with
|
socket on the same IP address. Setup the freertos_sockaddr structure with
|
||||||
this nodes IP address, and the port number being sent to. The strange
|
this nodes IP address, and the port number being sent to. The strange
|
||||||
|
@ -214,8 +217,11 @@ const size_t xStringLength = strlen( pcStringToSend ) + 15;
|
||||||
so the IP address can be obtained immediately. store the IP address being
|
so the IP address can be obtained immediately. store the IP address being
|
||||||
used in ulIPAddress. This is done so the socket can send to a different
|
used in ulIPAddress. This is done so the socket can send to a different
|
||||||
port on the same IP address. */
|
port on the same IP address. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
/* This test sends to itself, so data sent from here is received by a server
|
/* This test sends to itself, so data sent from here is received by a server
|
||||||
socket on the same IP address. Setup the freertos_sockaddr structure with
|
socket on the same IP address. Setup the freertos_sockaddr structure with
|
||||||
this nodes IP address, and the port number being sent to. The strange
|
this nodes IP address, and the port number being sent to. The strange
|
||||||
|
@ -247,7 +253,11 @@ const size_t xStringLength = strlen( pcStringToSend ) + 15;
|
||||||
the do while loop is used to ensure a buffer is obtained. */
|
the do while loop is used to ensure a buffer is obtained. */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY, ipTYPE_IPv4 ) ) == NULL );
|
||||||
|
#else
|
||||||
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY ) ) == NULL );
|
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY ) ) == NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A buffer was successfully obtained. Create the string that is
|
/* A buffer was successfully obtained. Create the string that is
|
||||||
sent to the server. First the string is filled with zeros as this will
|
sent to the server. First the string is filled with zeros as this will
|
||||||
|
@ -317,7 +327,11 @@ Socket_t xListeningSocket;
|
||||||
the address being bound to. The strange casting is to try and remove
|
the address being bound to. The strange casting is to try and remove
|
||||||
compiler warnings on 32 bit machines. Note that this task is only created
|
compiler warnings on 32 bit machines. Note that this task is only created
|
||||||
after the network is up, so the IP address is valid here. */
|
after the network is up, so the IP address is valid here. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
xBindAddress.sin_addr = ulIPAddress;
|
xBindAddress.sin_addr = ulIPAddress;
|
||||||
xBindAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
xBindAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
||||||
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
||||||
|
|
|
@ -128,6 +128,18 @@ const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_
|
||||||
|
|
||||||
/* Use by the pseudo random number generator. */
|
/* Use by the pseudo random number generator. */
|
||||||
static UBaseType_t ulNextRand;
|
static UBaseType_t ulNextRand;
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
/* In case multiple interfaces are used, define them statically. */
|
||||||
|
|
||||||
|
/* With WinPCap there is only 1 physical interface. */
|
||||||
|
static NetworkInterface_t xInterfaces[ 1 ];
|
||||||
|
|
||||||
|
/* It will have several end-points. */
|
||||||
|
static NetworkEndPoint_t xEndPoints[ 4 ];
|
||||||
|
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -151,8 +163,30 @@ int main( void )
|
||||||
* vApplicationIPNetworkEventHook() below). The address values passed in here
|
* vApplicationIPNetworkEventHook() below). The address values passed in here
|
||||||
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
|
* are used if ipconfigUSE_DHCP is set to 0, or if ipconfigUSE_DHCP is set to 1
|
||||||
* but a DHCP server cannot be contacted. */
|
* but a DHCP server cannot be contacted. */
|
||||||
|
|
||||||
|
/* Initialise the network interface.*/
|
||||||
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
|
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
/* Initialise the interface descriptor for WinPCap. */
|
||||||
|
pxWinPcap_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
|
||||||
|
|
||||||
|
/* === End-point 0 === */
|
||||||
|
FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#if ( ipconfigUSE_DHCP != 0 )
|
||||||
|
{
|
||||||
|
/* End-point 0 wants to use DHCPv4. */
|
||||||
|
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
|
||||||
|
}
|
||||||
|
#endif /* ( ipconfigUSE_DHCP != 0 ) */
|
||||||
|
|
||||||
|
memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) );
|
||||||
|
|
||||||
|
FreeRTOS_IPStart();
|
||||||
|
#else
|
||||||
|
/* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */
|
||||||
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
/* Start the RTOS scheduler. */
|
/* Start the RTOS scheduler. */
|
||||||
FreeRTOS_debug_printf( ( "vTaskStartScheduler\r\n" ) );
|
FreeRTOS_debug_printf( ( "vTaskStartScheduler\r\n" ) );
|
||||||
|
@ -225,7 +259,15 @@ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||||
|
|
||||||
/* Print out the network configuration, which may have come from a DHCP
|
/* Print out the network configuration, which may have come from a DHCP
|
||||||
* server. */
|
* server. */
|
||||||
|
|
||||||
|
/* Using FREERTOS_PLUS_TCP_VERSION as the substitute of the
|
||||||
|
* downward compatibility*/
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
||||||
|
#endif
|
||||||
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
||||||
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
@ -323,6 +365,7 @@ static void prvMiscInitialisation( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
|
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callback that provides the inputs necessary to generate a randomized TCP
|
* Callback that provides the inputs necessary to generate a randomized TCP
|
||||||
|
@ -342,6 +385,7 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
|
||||||
|
|
||||||
return uxRand();
|
return uxRand();
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Supply a random number to FreeRTOS+TCP stack.
|
* Supply a random number to FreeRTOS+TCP stack.
|
||||||
|
@ -353,3 +397,16 @@ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
|
||||||
*( pulNumber ) = uxRand();
|
*( pulNumber ) = uxRand();
|
||||||
return pdTRUE;
|
return pdTRUE;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if ( ( ipconfigUSE_TCP == 1 ) && ( ipconfigUSE_DHCP_HOOK != 0 ) )
|
||||||
|
|
||||||
|
eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase,
|
||||||
|
uint32_t ulIPAddress )
|
||||||
|
{
|
||||||
|
/* Provide a stub for this function. */
|
||||||
|
return eDHCPContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
|
@ -532,28 +532,44 @@ uint32_t ulAddress;
|
||||||
switch( xIndex )
|
switch( xIndex )
|
||||||
{
|
{
|
||||||
case 0 :
|
case 0 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
sprintf( ( char * ) pcWriteBuffer, "\r\nIP address " );
|
sprintf( ( char * ) pcWriteBuffer, "\r\nIP address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1 :
|
case 1 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, &ulAddress, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( NULL, &ulAddress, NULL, NULL );
|
||||||
|
#endif
|
||||||
sprintf( ( char * ) pcWriteBuffer, "\r\nNet mask " );
|
sprintf( ( char * ) pcWriteBuffer, "\r\nNet mask " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, &ulAddress, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, &ulAddress, NULL );
|
||||||
|
#endif
|
||||||
sprintf( ( char * ) pcWriteBuffer, "\r\nGateway address " );
|
sprintf( ( char * ) pcWriteBuffer, "\r\nGateway address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3 :
|
case 3 :
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( NULL, NULL, NULL, &ulAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
FreeRTOS_GetAddressConfiguration( NULL, NULL, NULL, &ulAddress );
|
||||||
|
#endif
|
||||||
sprintf( ( char * ) pcWriteBuffer, "\r\nDNS server address " );
|
sprintf( ( char * ) pcWriteBuffer, "\r\nDNS server address " );
|
||||||
xReturn = pdTRUE;
|
xReturn = pdTRUE;
|
||||||
xIndex++;
|
xIndex++;
|
||||||
|
|
|
@ -94,7 +94,11 @@ const portTickType x150ms = 150UL / portTICK_RATE_MS;
|
||||||
so the IP address can be obtained immediately. store the IP address being
|
so the IP address can be obtained immediately. store the IP address being
|
||||||
used in ulIPAddress. This is done so the socket can send to a different
|
used in ulIPAddress. This is done so the socket can send to a different
|
||||||
port on the same IP address. */
|
port on the same IP address. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This test sends to itself, so data sent from here is received by a server
|
/* This test sends to itself, so data sent from here is received by a server
|
||||||
socket on the same IP address. Setup the freertos_sockaddr structure with
|
socket on the same IP address. Setup the freertos_sockaddr structure with
|
||||||
|
@ -210,8 +214,11 @@ const size_t xStringLength = strlen( ( char * ) pucStringToSend ) + 15;
|
||||||
so the IP address can be obtained immediately. store the IP address being
|
so the IP address can be obtained immediately. store the IP address being
|
||||||
used in ulIPAddress. This is done so the socket can send to a different
|
used in ulIPAddress. This is done so the socket can send to a different
|
||||||
port on the same IP address. */
|
port on the same IP address. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
/* This test sends to itself, so data sent from here is received by a server
|
/* This test sends to itself, so data sent from here is received by a server
|
||||||
socket on the same IP address. Setup the freertos_sockaddr structure with
|
socket on the same IP address. Setup the freertos_sockaddr structure with
|
||||||
this nodes IP address, and the port number being sent to. The strange
|
this nodes IP address, and the port number being sent to. The strange
|
||||||
|
@ -243,7 +250,11 @@ const size_t xStringLength = strlen( ( char * ) pucStringToSend ) + 15;
|
||||||
the do while loop is used to ensure a buffer is obtained. */
|
the do while loop is used to ensure a buffer is obtained. */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY, ipTYPE_IPv4 ) ) == NULL );
|
||||||
|
#else
|
||||||
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY ) ) == NULL );
|
} while( ( pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xStringLength, portMAX_DELAY ) ) == NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* A buffer was successfully obtained. Create the string that is
|
/* A buffer was successfully obtained. Create the string that is
|
||||||
sent to the server. First the string is filled with zeros as this will
|
sent to the server. First the string is filled with zeros as this will
|
||||||
|
@ -313,7 +324,11 @@ Socket_t xListeningSocket;
|
||||||
the address being bound to. The strange casting is to try and remove
|
the address being bound to. The strange casting is to try and remove
|
||||||
compiler warnings on 32 bit machines. Note that this task is only created
|
compiler warnings on 32 bit machines. Note that this task is only created
|
||||||
after the network is up, so the IP address is valid here. */
|
after the network is up, so the IP address is valid here. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, NULL, NULL, NULL, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, NULL, NULL, NULL );
|
||||||
|
#endif
|
||||||
xBindAddress.sin_addr = ulIPAddress;
|
xBindAddress.sin_addr = ulIPAddress;
|
||||||
xBindAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
xBindAddress.sin_port = ( uint16_t ) ( ( uint32_t ) pvParameters ) & 0xffffUL;
|
||||||
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
|
||||||
|
|
|
@ -295,7 +295,12 @@ const size_t xBufferLength = strlen( ( char * ) pucStringToSend ) + 15;
|
||||||
delay is used, the actual delay will be capped to
|
delay is used, the actual delay will be capped to
|
||||||
ipconfigMAX_SEND_BLOCK_TIME_TICKS, hence the test to ensure a buffer
|
ipconfigMAX_SEND_BLOCK_TIME_TICKS, hence the test to ensure a buffer
|
||||||
was actually obtained. */
|
was actually obtained. */
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xBufferLength, portMAX_DELAY, ipTYPE_IPv4 );
|
||||||
|
#else
|
||||||
pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xBufferLength, portMAX_DELAY );
|
pucUDPPayloadBuffer = ( uint8_t * ) FreeRTOS_GetUDPPayloadBuffer( xBufferLength, portMAX_DELAY );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( pucUDPPayloadBuffer != NULL )
|
if( pucUDPPayloadBuffer != NULL )
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,6 +108,18 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS
|
||||||
/* Used by the pseudo random number generator. */
|
/* Used by the pseudo random number generator. */
|
||||||
static UBaseType_t ulNextRand;
|
static UBaseType_t ulNextRand;
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
|
||||||
|
/* In case multiple interfaces are used, define them statically. */
|
||||||
|
|
||||||
|
/* There is only 1 physical interface. */
|
||||||
|
static NetworkInterface_t xInterfaces[ 1 ];
|
||||||
|
|
||||||
|
/* It will have several end-points. */
|
||||||
|
static NetworkEndPoint_t xEndPoints[ 4 ];
|
||||||
|
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* See the following web page for information on using this demo.
|
* See the following web page for information on using this demo.
|
||||||
|
@ -121,15 +133,36 @@ int main( void )
|
||||||
const uint32_t ulLongTime_ms = 250UL;
|
const uint32_t ulLongTime_ms = 250UL;
|
||||||
|
|
||||||
/* Create a mutex that is used to guard against the console being accessed
|
/* Create a mutex that is used to guard against the console being accessed
|
||||||
by more than one task simultaniously. */
|
* by more than one task simultaneously. */
|
||||||
xConsoleMutex = xSemaphoreCreateMutex();
|
xConsoleMutex = xSemaphoreCreateMutex();
|
||||||
|
|
||||||
/* Initialise the network interface. Tasks that use the network are
|
/* Initialise the network interface. Tasks that use the network are
|
||||||
created in the network event hook when the network is connected and ready
|
* created in the network event hook when the network is connected and ready
|
||||||
for use. The address values passed in here are used if ipconfigUSE_DHCP is
|
* for use. The address values passed in here are used if ipconfigUSE_DHCP is
|
||||||
set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be
|
* set to 0, or if ipconfigUSE_DHCP is set to 1 but a DHCP server cannot be
|
||||||
contacted. */
|
* contacted. */
|
||||||
|
|
||||||
|
/* Initialise the network interface.*/
|
||||||
|
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
/* Initialise the interface descriptor for WinPCap. */
|
||||||
|
pxWinPcap_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
|
||||||
|
|
||||||
|
/* === End-point 0 === */
|
||||||
|
FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#if ( ipconfigUSE_DHCP != 0 )
|
||||||
|
{
|
||||||
|
/* End-point 0 wants to use DHCPv4. */
|
||||||
|
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
|
||||||
|
}
|
||||||
|
#endif /* ( ipconfigUSE_DHCP != 0 ) */
|
||||||
|
memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) );
|
||||||
|
FreeRTOS_IPStart();
|
||||||
|
#else
|
||||||
|
/* Using the old /single /IPv4 library, or using backward compatible mode of the new /multi library. */
|
||||||
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
/* Initialise the logging. */
|
/* Initialise the logging. */
|
||||||
uint32_t ulLoggingIPAddress;
|
uint32_t ulLoggingIPAddress;
|
||||||
|
@ -148,11 +181,11 @@ const uint32_t ulLongTime_ms = 250UL;
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|
||||||
/* If all is well, the scheduler will now be running, and the following
|
/* If all is well, the scheduler will now be running, and the following
|
||||||
line will never be reached. If the following line does execute, then
|
* line will never be reached. If the following line does execute, then
|
||||||
there was insufficient FreeRTOS heap memory available for the idle and/or
|
* there was insufficient FreeRTOS heap memory available for the idle and/or
|
||||||
timer tasks to be created. See the memory management section on the
|
* timer tasks to be created. See the memory management section on the
|
||||||
FreeRTOS web site for more details (this is standard text that is not not
|
* FreeRTOS web site for more details (this is standard text that is not not
|
||||||
really applicable to the Win32 simulator port). */
|
* really applicable to the Win32 simulator port). */
|
||||||
for( ;; )
|
for( ;; )
|
||||||
{
|
{
|
||||||
Sleep( ulLongTime_ms );
|
Sleep( ulLongTime_ms );
|
||||||
|
@ -165,8 +198,8 @@ void vApplicationIdleHook( void )
|
||||||
const unsigned long ulMSToSleep = 5;
|
const unsigned long ulMSToSleep = 5;
|
||||||
|
|
||||||
/* This function is called on each cycle of the idle task if
|
/* This function is called on each cycle of the idle task if
|
||||||
configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
|
* configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
|
||||||
load. */
|
* load. */
|
||||||
Sleep( ulMSToSleep );
|
Sleep( ulMSToSleep );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -196,7 +229,7 @@ static uint8_t cMessage[ 50 ];
|
||||||
|
|
||||||
default :
|
default :
|
||||||
/* It is not possible to get here as all enums have their own
|
/* It is not possible to get here as all enums have their own
|
||||||
case. */
|
* case. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,16 +241,16 @@ static uint8_t cMessage[ 50 ];
|
||||||
void vApplicationMallocFailedHook( void )
|
void vApplicationMallocFailedHook( void )
|
||||||
{
|
{
|
||||||
/* vApplicationMallocFailedHook() will only be called if
|
/* vApplicationMallocFailedHook() will only be called if
|
||||||
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
|
* configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
|
||||||
function that will get called if a call to pvPortMalloc() fails.
|
* function that will get called if a call to pvPortMalloc() fails.
|
||||||
pvPortMalloc() is called internally by the kernel whenever a task, queue,
|
* pvPortMalloc() is called internally by the kernel whenever a task, queue,
|
||||||
timer or semaphore is created. It is also called by various parts of the
|
* timer or semaphore is created. It is also called by various parts of the
|
||||||
demo application. If heap_1.c, heap_2.c or heap_4.c are used, then the
|
* demo application. If heap_1.c, heap_2.c or heap_4.c are used, then the
|
||||||
size of the heap available to pvPortMalloc() is defined by
|
* size of the heap available to pvPortMalloc() is defined by
|
||||||
configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
|
* configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
|
||||||
API function can be used to query the size of free heap space that remains
|
* API function can be used to query the size of free heap space that remains
|
||||||
(although it does not provide information on how the remaining heap might
|
* (although it does not provide information on how the remaining heap might
|
||||||
be fragmented). */
|
* be fragmented). */
|
||||||
taskDISABLE_INTERRUPTS();
|
taskDISABLE_INTERRUPTS();
|
||||||
for( ;; );
|
for( ;; );
|
||||||
}
|
}
|
||||||
|
@ -263,4 +296,3 @@ void vApplicationMallocFailedHook( void )
|
||||||
|
|
||||||
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
|
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) */
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
#include "FreeRTOS_IP.h"
|
#include "FreeRTOS_IP.h"
|
||||||
#include "FreeRTOS_IP_Private.h"
|
#include "FreeRTOS_IP_Private.h"
|
||||||
#include "NetworkBufferManagement.h"
|
#include "NetworkBufferManagement.h"
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
#include "FreeRTOS_Routing.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Thread-safe circular buffers are being used to pass data to and from the PCAP
|
/* Thread-safe circular buffers are being used to pass data to and from the PCAP
|
||||||
* access functions. */
|
* access functions. */
|
||||||
|
@ -150,9 +153,31 @@ static StreamBuffer_t * xRecvBuffer = NULL;
|
||||||
/* Logs the number of WinPCAP send failures, for viewing in the debugger only. */
|
/* Logs the number of WinPCAP send failures, for viewing in the debugger only. */
|
||||||
static volatile uint32_t ulWinPCAPSendFailures = 0;
|
static volatile uint32_t ulWinPCAPSendFailures = 0;
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
/*
|
||||||
|
* A pointer to the network interface is needed later when receiving packets.
|
||||||
|
*/
|
||||||
|
static NetworkInterface_t * pxMyInterface;
|
||||||
|
|
||||||
|
extern NetworkEndPoint_t * pxGetEndpoint( BaseType_t xIPType );
|
||||||
|
|
||||||
|
static BaseType_t xWinPcap_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface );
|
||||||
|
static BaseType_t xWinPcap_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,
|
||||||
|
NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||||
|
BaseType_t bReleaseAfterSend );
|
||||||
|
static BaseType_t xWinPcap_GetPhyLinkStatus( NetworkInterface_t * pxInterface );
|
||||||
|
|
||||||
|
NetworkInterface_t * pxWinPcap_FillInterfaceDescriptor( BaseType_t xEMACIndex,
|
||||||
|
NetworkInterface_t * pxInterface );
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
static BaseType_t xWinPcap_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface )
|
||||||
|
#else
|
||||||
BaseType_t xNetworkInterfaceInitialise( void )
|
BaseType_t xNetworkInterfaceInitialise( void )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
BaseType_t xReturn = pdFALSE;
|
BaseType_t xReturn = pdFALSE;
|
||||||
pcap_if_t * pxAllNetworkInterfaces;
|
pcap_if_t * pxAllNetworkInterfaces;
|
||||||
|
@ -257,8 +282,14 @@ static size_t prvStreamBufferAdd( StreamBuffer_t * pxBuffer,
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
static BaseType_t xWinPcap_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,
|
||||||
|
NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||||
|
BaseType_t bReleaseAfterSend )
|
||||||
|
#else
|
||||||
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||||
BaseType_t bReleaseAfterSend )
|
BaseType_t bReleaseAfterSend )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
size_t xSpace;
|
size_t xSpace;
|
||||||
|
|
||||||
|
@ -298,6 +329,51 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkB
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
|
||||||
|
static BaseType_t xWinPcap_GetPhyLinkStatus( NetworkInterface_t * pxInterface )
|
||||||
|
{
|
||||||
|
BaseType_t xResult = pdFALSE;
|
||||||
|
|
||||||
|
( void ) pxInterface;
|
||||||
|
|
||||||
|
if( pxOpenedInterfaceHandle != NULL )
|
||||||
|
{
|
||||||
|
xResult = pdTRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return xResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
NetworkInterface_t * pxWinPcap_FillInterfaceDescriptor( BaseType_t xEMACIndex,
|
||||||
|
NetworkInterface_t * pxInterface )
|
||||||
|
{
|
||||||
|
static char pcName[ 17 ];
|
||||||
|
|
||||||
|
/* This function pxWinPcap_FillInterfaceDescriptor() adds a network-interface.
|
||||||
|
* Make sure that the object pointed to by 'pxInterface'
|
||||||
|
* is declared static or global, and that it will continue to exist. */
|
||||||
|
|
||||||
|
pxMyInterface = pxInterface;
|
||||||
|
|
||||||
|
snprintf( pcName, sizeof( pcName ), "eth%ld", xEMACIndex );
|
||||||
|
|
||||||
|
memset( pxInterface, '\0', sizeof( *pxInterface ) );
|
||||||
|
pxInterface->pcName = pcName; /* Just for logging, debugging. */
|
||||||
|
pxInterface->pvArgument = ( void * ) xEMACIndex; /* Has only meaning for the driver functions. */
|
||||||
|
pxInterface->pfInitialise = xWinPcap_NetworkInterfaceInitialise;
|
||||||
|
pxInterface->pfOutput = xWinPcap_NetworkInterfaceOutput;
|
||||||
|
pxInterface->pfGetPhyLinkStatus = xWinPcap_GetPhyLinkStatus;
|
||||||
|
|
||||||
|
FreeRTOS_AddNetworkInterface( pxInterface );
|
||||||
|
|
||||||
|
return pxInterface;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static pcap_if_t * prvPrintAvailableNetworkInterfaces( void )
|
static pcap_if_t * prvPrintAvailableNetworkInterfaces( void )
|
||||||
{
|
{
|
||||||
pcap_if_t * pxAllNetworkInterfaces = NULL, * xInterface;
|
pcap_if_t * pxAllNetworkInterfaces = NULL, * xInterface;
|
||||||
|
@ -592,10 +668,51 @@ DWORD WINAPI prvWinPcapSendThread( void * pvParam )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined ( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
|
||||||
|
static BaseType_t xPacketBouncedBack( const uint8_t * pucBuffer )
|
||||||
|
{
|
||||||
|
static BaseType_t xHasWarned = pdFALSE;
|
||||||
|
EthernetHeader_t * pxEtherHeader;
|
||||||
|
NetworkEndPoint_t * pxEndPoint;
|
||||||
|
BaseType_t xResult = pdFALSE;
|
||||||
|
|
||||||
|
pxEtherHeader = ( EthernetHeader_t * ) pucBuffer;
|
||||||
|
|
||||||
|
/* Sometimes, packets are bounced back by the driver and we need not process them. Check
|
||||||
|
* whether this packet is one such packet. */
|
||||||
|
for( pxEndPoint = FreeRTOS_FirstEndPoint( NULL );
|
||||||
|
pxEndPoint != NULL;
|
||||||
|
pxEndPoint = FreeRTOS_NextEndPoint( NULL, pxEndPoint ) )
|
||||||
|
{
|
||||||
|
if( memcmp( pxEndPoint->xMACAddress.ucBytes, pxEtherHeader->xSourceAddress.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ) == 0 )
|
||||||
|
{
|
||||||
|
if( xHasWarned == pdFALSE )
|
||||||
|
{
|
||||||
|
xHasWarned = pdTRUE;
|
||||||
|
FreeRTOS_printf( ( "Bounced back by WinPCAP interface: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
|
pxEndPoint->xMACAddress.ucBytes[ 0 ],
|
||||||
|
pxEndPoint->xMACAddress.ucBytes[ 1 ],
|
||||||
|
pxEndPoint->xMACAddress.ucBytes[ 2 ],
|
||||||
|
pxEndPoint->xMACAddress.ucBytes[ 3 ],
|
||||||
|
pxEndPoint->xMACAddress.ucBytes[ 4 ],
|
||||||
|
pxEndPoint->xMACAddress.ucBytes[ 5 ] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
xResult = pdTRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return xResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
static BaseType_t xPacketBouncedBack( const uint8_t * pucBuffer )
|
static BaseType_t xPacketBouncedBack( const uint8_t * pucBuffer )
|
||||||
{
|
{
|
||||||
EthernetHeader_t * pxEtherHeader;
|
EthernetHeader_t * pxEtherHeader;
|
||||||
BaseType_t xResult;
|
BaseType_t xResult = pdFALSE;
|
||||||
|
|
||||||
pxEtherHeader = ( EthernetHeader_t * ) pucBuffer;
|
pxEtherHeader = ( EthernetHeader_t * ) pucBuffer;
|
||||||
|
|
||||||
|
@ -612,6 +729,8 @@ static BaseType_t xPacketBouncedBack( const uint8_t * pucBuffer )
|
||||||
|
|
||||||
return xResult;
|
return xResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static void prvInterruptSimulatorTask( void * pvParameters )
|
static void prvInterruptSimulatorTask( void * pvParameters )
|
||||||
|
@ -684,6 +803,117 @@ static void prvInterruptSimulatorTask( void * pvParameters )
|
||||||
if( pxNetworkBuffer != NULL )
|
if( pxNetworkBuffer != NULL )
|
||||||
{
|
{
|
||||||
xRxEvent.pvData = ( void * ) pxNetworkBuffer;
|
xRxEvent.pvData = ( void * ) pxNetworkBuffer;
|
||||||
|
#if defined ( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
pxNetworkBuffer->pxInterface = pxMyInterface;
|
||||||
|
pxNetworkBuffer->pxEndPoint = FreeRTOS_MatchingEndpoint( pxMyInterface, pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
|
||||||
|
{
|
||||||
|
char pcDescription[ 129 ] = "unknown";
|
||||||
|
const EthernetHeader_t * pxEthernetHeader = ( ( const EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
uint8_t ucType = ipTYPE_IPv4;
|
||||||
|
|
||||||
|
switch( pxEthernetHeader->usFrameType )
|
||||||
|
{
|
||||||
|
case ipARP_FRAME_TYPE:
|
||||||
|
{
|
||||||
|
const ProtocolPacket_t * pxPacket = ( ( const ProtocolPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "ARP frame for %xip",
|
||||||
|
FreeRTOS_ntohl( pxPacket->xARPPacket.xARPHeader.ulTargetProtocolAddress ) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ipPROTOCOL_ICMP:
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "ICMP frame" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ipIPv4_FRAME_TYPE:
|
||||||
|
{
|
||||||
|
const IPPacket_t * pxIPPacket;
|
||||||
|
uint8_t ucProtocol;
|
||||||
|
pxIPPacket = ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
||||||
|
ucProtocol = pxIPPacket->xIPHeader.ucProtocol;
|
||||||
|
|
||||||
|
if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP )
|
||||||
|
{
|
||||||
|
const ProtocolHeaders_t * pxProtocolHeaders = ( ( const ProtocolHeaders_t * )
|
||||||
|
&( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + uxIPHeaderSizePacket( pxNetworkBuffer ) ] ) );
|
||||||
|
uint32_t ulLocalIP, ulRemoteIP;
|
||||||
|
uint16_t usLocalPort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usDestinationPort );
|
||||||
|
uint16_t usRemotePort = FreeRTOS_htons( pxProtocolHeaders->xTCPHeader.usSourcePort );
|
||||||
|
const IPHeader_t * pxIPHeader;
|
||||||
|
pxIPHeader = ( ( const IPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) );
|
||||||
|
ulLocalIP = FreeRTOS_htonl( pxIPHeader->ulDestinationIPAddress );
|
||||||
|
ulRemoteIP = FreeRTOS_htonl( pxIPHeader->ulSourceIPAddress );
|
||||||
|
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "TCP v4 packet %xip port%u to %xip: port %u",
|
||||||
|
ulRemoteIP, usRemotePort, ulLocalIP, usLocalPort );
|
||||||
|
}
|
||||||
|
else if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )
|
||||||
|
{
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "UDP v4 packet" );
|
||||||
|
const UDPPacket_t * pxUDPPacket = ( ( UDPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||||
|
|
||||||
|
if( pxUDPPacket->xIPHeader.ulSourceIPAddress == 0x642c6276U )
|
||||||
|
{
|
||||||
|
FreeRTOS_printf( ( "Received UDP packet from %xip\n",
|
||||||
|
( unsigned ) ( FreeRTOS_htonl( pxUDPPacket->xIPHeader.ulSourceIPAddress ) ) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "v4 packet protocol %02X", ucProtocol );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ipIPv6_FRAME_TYPE:
|
||||||
|
{
|
||||||
|
const IPHeader_IPv6_t * pxIPHeader_IPv6;
|
||||||
|
uint8_t ucProtocol;
|
||||||
|
|
||||||
|
ucType = ipTYPE_IPv6;
|
||||||
|
pxIPHeader_IPv6 = ( const IPHeader_IPv6_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] );
|
||||||
|
|
||||||
|
ucProtocol = pxIPHeader_IPv6->ucNextHeader;
|
||||||
|
|
||||||
|
if( ucProtocol == ( uint8_t ) ipPROTOCOL_TCP )
|
||||||
|
{
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "TCP v6 packet" );
|
||||||
|
}
|
||||||
|
else if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP )
|
||||||
|
{
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "UDP v6 packet" );
|
||||||
|
}
|
||||||
|
else if( ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP_IPv6 )
|
||||||
|
{
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "ICMP v6 packet" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "v6 packet protocol %02X", ucProtocol );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
snprintf( pcDescription, sizeof pcDescription, "Unknown frame %04x", pxEthernetHeader->usFrameType );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pxNetworkBuffer->pxEndPoint == NULL )
|
||||||
|
{
|
||||||
|
pxNetworkBuffer->pxEndPoint = pxGetEndpoint( ucType );
|
||||||
|
|
||||||
|
if( strncasecmp( "ARP", pcDescription, 3 ) != 0 )
|
||||||
|
{
|
||||||
|
FreeRTOS_printf( ( "No end-point for \"%s\". Using 0x%p type IPv%d\n",
|
||||||
|
pcDescription,
|
||||||
|
pxNetworkBuffer->pxEndPoint,
|
||||||
|
ucType == ipTYPE_IPv6 ? 6 : 4 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Data was received and stored. Send a message to
|
/* Data was received and stored. Send a message to
|
||||||
* the IP task to let it know. */
|
* the IP task to let it know. */
|
||||||
|
@ -757,6 +987,7 @@ static const char * prvRemoveSpaces( char * pcBuffer,
|
||||||
|
|
||||||
return pcBuffer;
|
return pcBuffer;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#define BUFFER_SIZE ( ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING )
|
#define BUFFER_SIZE ( ipTOTAL_ETHERNET_FRAME_SIZE + ipBUFFER_PADDING )
|
||||||
#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x07UL )
|
#define BUFFER_SIZE_ROUNDED_UP ( ( BUFFER_SIZE + 7 ) & ~0x07UL )
|
||||||
|
@ -795,3 +1026,4 @@ void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
|
@ -37,6 +37,20 @@
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
|
||||||
|
/* In case multiple interfaces are used, define them statically. */
|
||||||
|
|
||||||
|
/* there is only 1 physical interface. */
|
||||||
|
static NetworkInterface_t xInterfaces[ 1 ];
|
||||||
|
|
||||||
|
/* It will have several end-points. */
|
||||||
|
static NetworkEndPoint_t xEndPoints[ 4 ];
|
||||||
|
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
|
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) || ( ipconfigDHCP_REGISTER_HOSTNAME == 1 )
|
||||||
|
|
||||||
const char * pcApplicationHostnameHook( void )
|
const char * pcApplicationHostnameHook( void )
|
||||||
|
@ -122,7 +136,12 @@ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||||
{
|
{
|
||||||
/* Print out the network configuration, which may have come from a DHCP
|
/* Print out the network configuration, which may have come from a DHCP
|
||||||
* server. */
|
* server. */
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
FreeRTOS_GetEndPointConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress, pxNetworkEndPoints );
|
||||||
|
#else
|
||||||
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
|
||||||
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
|
||||||
|
|
||||||
|
@ -165,7 +184,28 @@ void vPlatformInitIpStack( void )
|
||||||
ucIPAddress[ 2 ] = ( ( uxRandomNumber >> 16 ) & 0xFF );
|
ucIPAddress[ 2 ] = ( ( uxRandomNumber >> 16 ) & 0xFF );
|
||||||
ucIPAddress[ 3 ] = ( ( uxRandomNumber >> 24 ) & 0xFF );
|
ucIPAddress[ 3 ] = ( ( uxRandomNumber >> 24 ) & 0xFF );
|
||||||
|
|
||||||
|
/* Initialise the network interface.*/
|
||||||
|
FreeRTOS_debug_printf( ( "FreeRTOS_IPInit\r\n" ) );
|
||||||
|
|
||||||
|
#if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 )
|
||||||
|
/* Initialise the interface descriptor for WinPCap. */
|
||||||
|
pxWinPcap_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
|
||||||
|
|
||||||
|
/* === End-point 0 === */
|
||||||
|
FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucNullAddress, ucNullAddress, ucMACAddress );
|
||||||
|
#if ( ipconfigUSE_DHCP != 0 )
|
||||||
|
{
|
||||||
|
/* End-point 0 wants to use DHCPv4. */
|
||||||
|
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
|
||||||
|
}
|
||||||
|
#endif /* ( ipconfigUSE_DHCP != 0 ) */
|
||||||
|
memcpy( ipLOCAL_MAC_ADDRESS, ucMACAddress, sizeof( ucMACAddress ) );
|
||||||
|
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, ucNullAddress, ucNullAddress, ucMACAddress );
|
||||||
|
#endif /* if defined( FREERTOS_PLUS_TCP_VERSION ) && ( FREERTOS_PLUS_TCP_VERSION >= 10 ) */
|
||||||
|
|
||||||
configASSERT( xResult == pdTRUE );
|
configASSERT( xResult == pdTRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,3 +217,15 @@ BaseType_t xPlatformIsNetworkUp( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if ( ( ipconfigUSE_TCP == 1 ) && ( ipconfigUSE_DHCP_HOOK != 0 ) )
|
||||||
|
|
||||||
|
eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase,
|
||||||
|
uint32_t ulIPAddress )
|
||||||
|
{
|
||||||
|
/* Provide a stub for this function. */
|
||||||
|
return eDHCPContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/*-----------------------------------------------------------*/
|
|
@ -178,6 +178,7 @@ burtcmodeem
|
||||||
busfault
|
busfault
|
||||||
buttonisr
|
buttonisr
|
||||||
bvic
|
bvic
|
||||||
|
bwantdhcp
|
||||||
bytesreceived
|
bytesreceived
|
||||||
bytessent
|
bytessent
|
||||||
bytestorecv
|
bytestorecv
|
||||||
|
@ -2139,6 +2140,7 @@ puxstackbuffer
|
||||||
pv
|
pv
|
||||||
pvalue
|
pvalue
|
||||||
pvargs
|
pvargs
|
||||||
|
pvargument
|
||||||
pvbuffer
|
pvbuffer
|
||||||
pvcontext
|
pvcontext
|
||||||
pvctx
|
pvctx
|
||||||
|
@ -2179,6 +2181,7 @@ pxdptr
|
||||||
pxecdsacontext
|
pxecdsacontext
|
||||||
pxecparams
|
pxecparams
|
||||||
pxecparamsptr
|
pxecparamsptr
|
||||||
|
pxendpoint
|
||||||
pxexpiredtimer
|
pxexpiredtimer
|
||||||
pxfilesize
|
pxfilesize
|
||||||
pxftpclient
|
pxftpclient
|
||||||
|
@ -2188,6 +2191,7 @@ pxhigherprioritytaskwoken
|
||||||
pxincomingpacket
|
pxincomingpacket
|
||||||
pxincomingpublishcallback
|
pxincomingpublishcallback
|
||||||
pxindex
|
pxindex
|
||||||
|
pxinterface
|
||||||
pxisrfunction
|
pxisrfunction
|
||||||
pxknownmessage
|
pxknownmessage
|
||||||
pxlist
|
pxlist
|
||||||
|
@ -2195,6 +2199,7 @@ pxmbedpkcontext
|
||||||
pxmbedtlspkctx
|
pxmbedtlspkctx
|
||||||
pxmetrics
|
pxmetrics
|
||||||
pxmqttcontext
|
pxmqttcontext
|
||||||
|
pxmyinterface
|
||||||
pxnetif
|
pxnetif
|
||||||
pxnetworkbuffer
|
pxnetworkbuffer
|
||||||
pxnetworkcontext
|
pxnetworkcontext
|
||||||
|
@ -2297,6 +2302,7 @@ readme
|
||||||
readonly
|
readonly
|
||||||
readtotaltimeoutconstant
|
readtotaltimeoutconstant
|
||||||
readtotaltimeoutmultiplier
|
readtotaltimeoutmultiplier
|
||||||
|
realtek
|
||||||
reblocked
|
reblocked
|
||||||
receiveloop
|
receiveloop
|
||||||
receivetimeout
|
receivetimeout
|
||||||
|
@ -2600,6 +2606,7 @@ stm
|
||||||
stor
|
stor
|
||||||
str
|
str
|
||||||
strcasecmp
|
strcasecmp
|
||||||
|
strcasestr
|
||||||
strin
|
strin
|
||||||
stringification
|
stringification
|
||||||
strintrx
|
strintrx
|
||||||
|
@ -3373,8 +3380,10 @@ xdoremove
|
||||||
xe
|
xe
|
||||||
xeb
|
xeb
|
||||||
xechoserveraddress
|
xechoserveraddress
|
||||||
|
xemacindex
|
||||||
xemaclite
|
xemaclite
|
||||||
xend
|
xend
|
||||||
|
xendpoints
|
||||||
xerrorcount
|
xerrorcount
|
||||||
xerrordetected
|
xerrordetected
|
||||||
xerrorline
|
xerrorline
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue