Skip to content

Commit 8b4aa35

Browse files
authored
Merge branch 'dev/IPv6_integration' into dev-defines
2 parents a2dfcfa + c8972e7 commit 8b4aa35

File tree

9 files changed

+115
-44
lines changed

9 files changed

+115
-44
lines changed

GettingStarted_4.0.0-rc1.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Moving to 4.0.0-rc1 from 3.x.x:
2+
-----------------------------
3+
In version 4.0.0-rc1, new files have been added to support IPv6 functionality and each file has been broken down into logically separated IPv4 and IPv6 files. The folder structure of FreeRTOS-Plus-TCP has not changed.
4+
5+
Some of the APIs have changed which is illustrated in the section below. However, there is a backward compatibility mode provided as well.
6+
7+
Backward Compatibility Mode:
8+
---------------------------
9+
If you are moving your code from V3.x.x to V4.0.0-rc1, then set the "ipconfigIPv4_BACKWARD_COMPATIBLE" macro to 1 in “FreeRTOSIPConfigDefaults.h” to run the code in backward compatible mode.
10+
The "Existing API's" defined in all the API changes below work only when the backward compatibility mode is enabled.
11+
12+
API changes in 4.0.0-rc1:
13+
----------------------
14+
Change 1:
15+
16+
- Existing API: FreeRTOS_IPInit
17+
- Backward compatibility with the IPv4 FreeRTOS+TCP V3.x.x which only supports single network interface. This can be used for single interface IPv4 systems.
18+
- New API: FreeRTOS_IPInit_Multi
19+
- Supports multiple interfaces. Before calling this function, at least 1 interface and 1 end-point must have been set-up. FreeRTOS_IPInit_Multi() replaces the earlier FreeRTOS_IPInit().
20+
21+
Change 2:
22+
23+
- Existing API: FreeRTOS_GetAddressConfiguration/FreeRTOS_SetAddressConfiguration
24+
- Get/Set the address configuration from the global variables initialised during FreeRTOS_IPInit
25+
- New API: FreeRTOS_GetEndPointConfiguration/FreeRTOS_SetEndPointConfiguration
26+
- Get/Set the same address configuration from/to the end point
27+
28+
Change 3:
29+
30+
- Existing API: FreeRTOS_GetUDPPayloadBuffer
31+
- Backward compatibility with the IPv4 FreeRTOS+TCP V3.x.x. This can still be used for IPv4 use cases.
32+
- New API:FreeRTOS_GetUDPPayloadBuffer_Multi
33+
- A new argument (uint8_t ucIPType) to specify IP type to support both IPv4 and IPv6
34+
35+
Change 4:
36+
37+
- Existing API: pxFillInterfaceDescriptor
38+
- It is there for backward compatibility. The function FreeRTOS_IPInit() will call it to initialise the interface and end-point objects
39+
- New API: prefix_pxFillInterfaceDescriptor
40+
- where prefix = Network Interface Name
41+
- E.g pxWinPcap_FillInterfaceDescriptor
42+
- New function with the same functionality
43+
44+
Change 5:
45+
46+
- Existing API: vApplicationIPNetworkEventHook
47+
- New API: vApplicationIPNetworkEventHook_Multi
48+
- New argument “struct xNetworkInterface * pxNetworkInterface” added.
49+
- ipconfigIPv4_BACKWARD_COMPATIBLE flag is used to differentiate between old API and new API.
50+
51+
**NOTE** : We are NOT considering the APIs changes in FreeRTOS_IP_Private.h for backward compatibility as those are not part of published interface.
52+
53+
Running Demos:
54+
-------------
55+
The demos can be found at: https://github.com/FreeRTOS/FreeRTOS/tree/devIPv6/FreeRTOS-Plus/Demo
56+
57+
In all the demos, there is a backward compatibility mode which can be enabled by setting the flag “ipconfigIPv4_BACKWARD_COMPATIBLE” to 1 in the header file “FreeRTOSIPConfigDefaults.h”.
58+
This flag is by default set to zero.
59+
60+
New IPv6 WinSim Demo: https://github.com/FreeRTOS/FreeRTOS/tree/devIPv6/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_IPv6_Demo/IPv6_Multi_WinSim_demo

History.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Changes between dev/ipv6_integration branch RC1 and main branch V3.0.0 releases:
22
+ Unified code for IPv4 and IPv6
3-
+ Multiple Interface/Endpoint support.
4-
+ Neighbour Discovery & Router Advertisement.
3+
+ Multiple Interface/Endpoint support
4+
((Reference: https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/freertostcp-multiple-interfaces.html).
55
+ New WinSim demo to support both IPv4 and IPv6.
6+
**Note**- This release does not support ESP32/ M487/ mw300_rd ports yet. This will be released soon.
67

78
Changes between V3.0.0 and V2.4.0 releases:
89
+ Split the source files according to the function the code performs.

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
## NOTE - Work In Progress
22

3-
This branch is for development purpose of merging IPv4 and IPv6 code.
3+
This branch contains unified IPv4 and IPv6 functionalities.
4+
Refer to the Getting started Guide (found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/dev/IPv6_integration/GettingStarted_4.0.0-rc1.md)) for more details.
45

56
## FreeRTOS-Plus-TCP Library
67
FreeRTOS-Plus-TCP is a lightweight TCP/IP stack for FreeRTOS. It provides a familiar Berkeley sockets interface, making it as simple to use and learn as possible. FreeRTOS-Plus-TCP's features and RAM footprint are fully scalable, making FreeRTOS-Plus-TCP equally applicable to smaller lower throughput microcontrollers as well as larger higher throughput microprocessors.
78

89
This library has undergone static code analysis and checks for compliance with the [MISRA coding standard](https://www.misra.org.uk/). Any deviations from the MISRA C:2012 guidelines are documented under [MISRA Deviations](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md). The library is validated for memory safety and data structure invariance through the [CBMC automated reasoning tool](https://www.cprover.org/cbmc/) for the functions that parse data originating from the network.
910

1011
## Getting started
11-
The easiest way to use FreeRTOS-Plus-TCP is to start with the pre-configured demo application project (found in [this directory](https://github.com/FreeRTOS/FreeRTOS/tree/master/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator)). That way you will have the correct FreeRTOS source files included, and the correct include paths configured. Once a demo application is building and executing you can remove the demo application files, and start to add in your own application source files. See the [FreeRTOS Kernel Quick Start Guide](https://www.freertos.org/FreeRTOS-quick-start-guide.html) for detailed instructions and other useful links.
12+
The easiest way to use the 4.0.0-rc1 version of FreeRTOS-Plus-TCP is to refer to to the Getting started Guide (found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/dev/IPv6_integration/GettingStarted_4.0.0-rc1.md))
13+
Another way is to start with the pre-configured demo application project (found in [this directory](https://github.com/FreeRTOS/FreeRTOS/tree/devIPv6/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator)). That way you will have the correct FreeRTOS source files included, and the correct include paths configured. Once a demo application is building and executing you can remove the demo application files, and start to add in your own application source files. See the [FreeRTOS Kernel Quick Start Guide](https://www.freertos.org/FreeRTOS-quick-start-guide.html) for detailed instructions and other useful links.
1214

1315
Additionally, for FreeRTOS-Plus-TCP source code organization refer to the [Documentation](http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial.html), and [API Reference](https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/FreeRTOS_TCP_API_Functions.html).
1416

15-
FreeRTOS-Plus-TCP V2.3.2-LTS-Patch-2 [source code](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/tree/V2.3.2-LTS-Patch-2)(.c .h) is part of the [FreeRTOS 202012.04 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.04-LTS) release.
16-
1717
### Getting help
1818
If you have any questions or need assistance troubleshooting your FreeRTOS project, we have an active community that can help on the [FreeRTOS Community Support Forum](https://forums.freertos.org). Please also refer to [FAQ](http://www.freertos.org/FAQHelp.html) for frequently asked questions.
1919

2020
Also see the [Submitting a bugs/feature request](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/.github/CONTRIBUTING.md#submitting-a-bugsfeature-request) section of CONTRIBUTING.md for more details.
2121

22+
**Note:** All the remaining sections are generic and applies to all the versions from V3.0.0 onwards.
23+
2224
## Upgrading to V3.0.0 and above
2325
In version 3.0.0 or higher, the folder structure of FreeRTOS-Plus-TCP has changed and the files have been broken down into smaller logically separated modules. This change makes the code more modular and conducive to unit-tests. FreeRTOS-Plus-TCP V3.0.0 improves the robustness, security, and modularity of the library. Version 3.0.0 adds comprehensive unit test coverage for all lines and branches of code and has undergone protocol testing, and penetration testing by AWS Security to reduce the exposure to security vulnerabilities. Additionally, the source files have been moved to a `source` directory. This change requires modification of any existing project(s) to include the modified source files and directories. There are examples on how to use the new files and directory structure. For a windows simulator based example, refer to this [demo](https://github.com/FreeRTOS/FreeRTOS/tree/TCPRefactorDemo/FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Minimal_Windows_Simulator). For an example based on the Xilinx Zynq-7000, use the code in this [branch](https://github.com/aws/amazon-freertos/tree/TCPRefactorDemo) and follow these [instructions](https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_xilinx.html) to build and run the demo.
2426

docs/doxygen/config.doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = FreeRTOS-Plus-TCP
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = V3.0.0
51+
PROJECT_NUMBER = V4.0.0-rc1
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name : "FreeRTOS-Plus-TCP"
2-
version: "V3.0.0"
2+
version: "V4.0.0-rc1"
33
description: "Thread safe FreeRTOS TCP/IP stack working on top of the FreeRTOS-Kernel to implement the TCP/IP protocol. Suitable for microcontrollers."
44
license: "MIT"
55
dependencies:

source/FreeRTOS_DHCPv6.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@
133133

134134
/** @brief If a lease time is not received, use the default of two days. 48 hours in ticks.
135135
* Do not use the macro pdMS_TO_TICKS() here as integer overflow can occur. */
136-
#define dhcpDEFAULT_LEASE_TIME ( ( 48U * 60U * 60U ) * configTICK_RATE_HZ )
136+
#define dhcpv6DEFAULT_LEASE_TIME ( ( 48U * 60U * 60U ) * configTICK_RATE_HZ )
137137

138138
/** @brief Don't allow the lease time to be too short. */
139-
#define dhcpMINIMUM_LEASE_TIME ( pdMS_TO_TICKS( 60000U ) ) /* 60 seconds in ticks. */
139+
#define dhcpv6MINIMUM_LEASE_TIME ( pdMS_TO_TICKS( 60000U ) ) /* 60 seconds in ticks. */
140140

141141
/** @brief The function time() counts since 1-1-1970. The DHCPv6 time-stamp however
142142
* uses a time stamp that had zero on 1-1-2000. */
@@ -405,11 +405,11 @@ static void vDHCPv6ProcessEndPoint_HandleReply( NetworkEndPoint_t * pxEndPoint,
405405

406406
if( EP_DHCPData.ulLeaseTime == 0U )
407407
{
408-
EP_DHCPData.ulLeaseTime = dhcpDEFAULT_LEASE_TIME;
408+
EP_DHCPData.ulLeaseTime = dhcpv6DEFAULT_LEASE_TIME;
409409
}
410-
else if( EP_DHCPData.ulLeaseTime < dhcpMINIMUM_LEASE_TIME )
410+
else if( EP_DHCPData.ulLeaseTime < dhcpv6MINIMUM_LEASE_TIME )
411411
{
412-
EP_DHCPData.ulLeaseTime = dhcpMINIMUM_LEASE_TIME;
412+
EP_DHCPData.ulLeaseTime = dhcpv6MINIMUM_LEASE_TIME;
413413
}
414414
else
415415
{
@@ -1033,7 +1033,7 @@ static void prvSendDHCPMessage( NetworkEndPoint_t * pxEndPoint )
10331033
xAddress.sin_family = FREERTOS_AF_INET6;
10341034
xAddress.sin_port = FreeRTOS_htons( DHCPv6_SERVER_PORT );
10351035

1036-
struct freertos_sockaddr * pxAddress = ( ( sockaddr4_t * ) &( xAddress ) );
1036+
struct freertos_sockaddr * pxAddress = &( xAddress );
10371037

10381038
( void ) FreeRTOS_sendto( EP_DHCPData.xDHCPSocket, ( const void * ) xMessage.ucContents, xMessage.uxIndex, 0, pxAddress, sizeof xAddress );
10391039
}

source/include/FreeRTOSIPConfigDefaults.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@
135135
/*---------------------------------------------------------------------------*/
136136

137137
#if ( ipconfigUSE_IPv4 == 0 ) || ( ipconfigUSE_IPv6 == 0 )
138-
#error "Build separation for both IPv4 and IPv6 is work in progress. \
139-
Please enable both ipconfigUSE_IPv4 and ipconfigUSE_IPv6 flags."
138+
#error "Build separation for both IPv4 and IPv6 is work in progress. Please enable both ipconfigUSE_IPv4 and ipconfigUSE_IPv6 flags."
140139
#endif
141140

142141
/*---------------------------------------------------------------------------*/

source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,14 @@ static void prvEthernetUpdateConfig( BaseType_t xForce );
182182
*/
183183
static BaseType_t prvNetworkInterfaceInput( void );
184184

185-
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_MDNS != 0 ) || ( ipconfigUSE_IPv6 != 0 )
186185

187186
/*
188187
* For LLMNR, an extra MAC-address must be configured to
189188
* be able to receive the multicast messages.
190189
*/
191-
static void prvMACAddressConfig( ETH_HandleTypeDef * heth,
192-
uint32_t ulIndex,
193-
uint8_t * Addr );
194-
#endif
190+
static void prvMACAddressConfig( ETH_HandleTypeDef * heth,
191+
uint32_t ulIndex,
192+
uint8_t * Addr );
195193

196194
/* FreeRTOS+TCP/multi :
197195
* Each network device has 3 access functions:
@@ -452,9 +450,7 @@ BaseType_t xSTM32F_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface
452450
BaseType_t xResult;
453451
NetworkEndPoint_t * pxEndPoint;
454452

455-
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_MDNS != 0 )
456-
BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */
457-
#endif
453+
BaseType_t xMACEntry = ETH_MAC_ADDRESS1; /* ETH_MAC_ADDRESS0 reserved for the primary MAC-address. */
458454

459455
if( xMacInitStatus == eMACInit )
460456
{
@@ -757,28 +753,28 @@ static void prvDMARxDescListInit()
757753
}
758754
/*-----------------------------------------------------------*/
759755

760-
#if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_MDNS != 0 )
761-
static void prvMACAddressConfig( ETH_HandleTypeDef * heth,
762-
uint32_t ulIndex,
763-
uint8_t * Addr )
764-
{
765-
uint32_t ulTempReg;
766756

767-
( void ) heth;
757+
static void prvMACAddressConfig( ETH_HandleTypeDef * heth,
758+
uint32_t ulIndex,
759+
uint8_t * Addr )
760+
{
761+
uint32_t ulTempReg;
768762

769-
/* Calculate the selected MAC address high register. */
770-
ulTempReg = 0x80000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ];
763+
( void ) heth;
771764

772-
/* Load the selected MAC address high register. */
773-
( *( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg;
765+
/* Calculate the selected MAC address high register. */
766+
ulTempReg = 0x80000000ul | ( ( uint32_t ) Addr[ 5 ] << 8 ) | ( uint32_t ) Addr[ 4 ];
774767

775-
/* Calculate the selected MAC address low register. */
776-
ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ];
768+
/* Load the selected MAC address high register. */
769+
( *( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_HBASE + ulIndex ) ) ) = ulTempReg;
770+
771+
/* Calculate the selected MAC address low register. */
772+
ulTempReg = ( ( uint32_t ) Addr[ 3 ] << 24 ) | ( ( uint32_t ) Addr[ 2 ] << 16 ) | ( ( uint32_t ) Addr[ 1 ] << 8 ) | Addr[ 0 ];
773+
774+
/* Load the selected MAC address low register */
775+
( *( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg;
776+
}
777777

778-
/* Load the selected MAC address low register */
779-
( *( __IO uint32_t * ) ( ( uint32_t ) ( ETH_MAC_ADDR_LBASE + ulIndex ) ) ) = ulTempReg;
780-
}
781-
#endif /* if ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_MDNS != 0 ) */
782778
/*-----------------------------------------------------------*/
783779

784780
static BaseType_t xSTM32F_NetworkInterfaceOutput( NetworkInterface_t * pxInterface,

test/build-combination/Common/main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ int main( void )
123123
return 0;
124124
}
125125
/*-----------------------------------------------------------*/
126-
127-
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
128-
struct xNetworkEndPoint * pxEndPoint )
126+
/* *INDENT-OFF* */
127+
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
128+
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
129+
#else
130+
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
131+
struct xNetworkEndPoint * pxEndPoint )
132+
#endif
133+
/* *INDENT-ON* */
129134
{
130135
static BaseType_t xTasksAlreadyCreated = pdFALSE;
131136

@@ -314,3 +319,11 @@ void vApplicationPingReplyHook( ePingReplyStatus_t eStatus,
314319
{
315320
/* Provide a stub for this function. */
316321
}
322+
323+
#if ( ipconfigUSE_IPv6 != 0 ) && ( ipconfigUSE_DHCPv6 != 0 )
324+
/* DHCPv6 needs a time-stamp, seconds after 1970. */
325+
uint32_t ulApplicationTimeHook( void )
326+
{
327+
return time( NULL );
328+
}
329+
#endif

0 commit comments

Comments
 (0)