diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/DemoTasks/DefenderDemoExample.c b/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/DemoTasks/DefenderDemoExample.c index 74773b490a..084f53d82a 100644 --- a/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/DemoTasks/DefenderDemoExample.c +++ b/FreeRTOS-Plus/Demo/AWS/Device_Defender_Windows_Simulator/Device_Defender_Demo/DemoTasks/DefenderDemoExample.c @@ -116,6 +116,12 @@ typedef enum ReportStatusAccepted, ReportStatusRejected } ReportStatus_t; + +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; /*-----------------------------------------------------------*/ /** @@ -128,6 +134,11 @@ static MQTTContext_t xMqttContext; */ static NetworkContext_t xNetworkContext; +/** + * @brief The parameters for the network context using mbedTLS operation. + */ +static TlsTransportParams_t xTlsTransportParams; + /** * @brief Static buffer used to hold MQTT messages being sent and received. */ @@ -626,6 +637,9 @@ void prvDefenderDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + /* Start with report not received. */ xReportStatus = ReportStatusNotReceived; 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 68ea6d83be..91bffa58b3 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 @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.3.0 + * FreeRTOS V202011.00 * 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 @@ -19,10 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*** diff --git a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/DemoTasks/ShadowDemoMainExample.c b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/DemoTasks/ShadowDemoMainExample.c index f6fdf039c4..57f985f482 100755 --- a/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/DemoTasks/ShadowDemoMainExample.c +++ b/FreeRTOS-Plus/Demo/AWS/Device_Shadow_Windows_Simulator/Device_Shadow_Demo/DemoTasks/ShadowDemoMainExample.c @@ -22,7 +22,6 @@ * https://www.FreeRTOS.org * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /* @@ -162,6 +161,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The MQTT context used for MQTT operation. */ @@ -172,6 +179,11 @@ static MQTTContext_t xMqttContext; */ static NetworkContext_t xNetworkContext; +/** + * @brief The parameters for the network context using mbedTLS operation. + */ +static TlsTransportParams_t xTlsTransportParams; + /** * @brief Static buffer used to hold MQTT messages being sent and received. */ @@ -590,6 +602,9 @@ void prvShadowDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + /****************************** Connect. ******************************/ demoStatus = xEstablishMqttSession( &xMqttContext, diff --git a/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/DemoTasks/JobsDemoExample.c b/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/DemoTasks/JobsDemoExample.c index b7e3f97e09..3bf658ea77 100755 --- a/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/DemoTasks/JobsDemoExample.c +++ b/FreeRTOS-Plus/Demo/AWS/Jobs_Windows_Simulator/Jobs_Demo/DemoTasks/JobsDemoExample.c @@ -223,6 +223,14 @@ typedef enum JobActionType /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The MQTT context used for MQTT operation. */ @@ -233,6 +241,11 @@ static MQTTContext_t xMqttContext; */ static NetworkContext_t xNetworkContext; +/** + * @brief The parameters for the network context using mbedTLS operation. + */ +static TlsTransportParams_t xTlsTransportParams; + /** * @brief Static buffer used to hold MQTT messages being sent and received. */ @@ -726,6 +739,9 @@ void prvJobsDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + /* Establish an MQTT connection with AWS IoT over a mutually authenticated TLS session. */ xDemoStatus = xEstablishMqttSession( &xMqttContext, &xNetworkContext, 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 7535a7561c..8e7e606df9 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 @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.3.0 + * FreeRTOS V202011.00 * 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 @@ -19,10 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*** diff --git a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c index a2751e88bd..68b06814bb 100755 --- a/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c +++ b/FreeRTOS-Plus/Demo/AWS/Mqtt_Demo_Helpers/mqtt_demo_helpers.c @@ -202,6 +202,14 @@ typedef struct PublishPackets /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief Global entry time into the application to use as a reference timestamp * in the #prvGetTimeMs function. #prvGetTimeMs will always return the difference @@ -583,9 +591,8 @@ BaseType_t xEstablishMqttSession( MQTTContext_t * pxMqttContext, configASSERT( pxMqttContext != NULL ); configASSERT( pxNetworkContext != NULL ); - /* Initialize the mqtt context and network context. */ + /* Initialize the mqtt context. */ ( void ) memset( pxMqttContext, 0U, sizeof( MQTTContext_t ) ); - ( void ) memset( pxNetworkContext, 0U, sizeof( NetworkContext_t ) ); if( prvConnectToServerWithBackoffRetries( pxNetworkContext ) != TLS_TRANSPORT_SUCCESS ) { diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/http_demo_utils.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/http_demo_utils.c index bbbbef3532..99c30d2cbe 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/http_demo_utils.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/http_demo_utils.c @@ -56,6 +56,15 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. + * void * is used as this utility can be used by both plaintext and TLS demos. */ +struct NetworkContext +{ + void * pParams; +}; + +/*-----------------------------------------------------------*/ + extern UBaseType_t uxRand(); /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c index 17b5c3900b..580425013e 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/Common/main.c @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.3.0 + * FreeRTOS V202011.00 * 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 @@ -19,8 +19,8 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * */ diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c index a0a3e58e8c..9712f07c01 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth/DemoTasks/MutualAuthHTTPExample.c @@ -122,6 +122,12 @@ */ #define IOT_CORE_ALPN_PROTOCOL_NAME "\x0ex-amzn-http-ca" +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + /** * @brief A buffer used in the demo for storing HTTP request headers and * HTTP response headers and body. @@ -207,6 +213,7 @@ static void prvHTTPDemoTask( void * pvParameters ) TransportInterface_t xTransportInterface; /* The network context for the transport layer interface. */ NetworkContext_t xNetworkContext = { 0 }; + TlsTransportParams_t xTlsTransportParams = { 0 }; BaseType_t xIsConnectionEstablished = pdFALSE; /* The user of this demo must check the logs for any failure codes. */ @@ -215,6 +222,9 @@ static void prvHTTPDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + /**************************** Connect. ******************************/ /* Attempt to connect to the HTTP server. If connection fails, retry after a diff --git a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c index 504fd74586..ddf45c621b 100644 --- a/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c +++ b/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Plaintext/DemoTasks/PlainTextHTTPExample.c @@ -164,6 +164,12 @@ */ #define httpexampleNUMBER_HTTP_PATHS ( 4 ) +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + PlaintextTransportParams_t * pParams; +}; + /** * @brief A pair containing a path string of the URI and its length. */ @@ -269,6 +275,7 @@ static void prvHTTPDemoTask( void * pvParameters ) TransportInterface_t xTransportInterface; /* The network context for the transport layer interface. */ NetworkContext_t xNetworkContext = { 0 }; + PlaintextTransportParams_t xPlaintextTransportParams = { 0 }; /* An array of HTTP paths to request. */ const httpPathStrings_t xHttpMethodPaths[] = { @@ -294,6 +301,9 @@ static void prvHTTPDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xPlaintextTransportParams; + /**************************** Connect. ******************************/ /* Attempt to connect to the HTTP server. If connection fails, retry after a diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c index 6ca7762b94..27e775d91a 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/Common/main.c @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.3.0 + * FreeRTOS V202011.00 * 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 @@ -19,10 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*** diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c index 473f5b2ec2..d6342a4d69 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Basic_TLS/DemoTasks/BasicTLSMQTTExample.c @@ -185,6 +185,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The task used to demonstrate the MQTT API. * @@ -386,6 +394,7 @@ static void prvMQTTDemoTask( void * pvParameters ) uint32_t ulPublishCount = 0U, ulTopicCount = 0U; const uint32_t ulMaxPublishCount = 5UL; NetworkContext_t xNetworkContext = { 0 }; + TlsTransportParams_t xTlsTransportParams = { 0 }; NetworkCredentials_t xNetworkCredentials = { 0 }; MQTTContext_t xMQTTContext = { 0 }; MQTTStatus_t xMQTTStatus; @@ -394,6 +403,9 @@ static void prvMQTTDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + /* Set the entry time of the demo application. This entry time will be used * to calculate relative time elapsed in the execution of the demo application, * by the timer utility function that is provided to the MQTT library. diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c index 5e1673fcaa..a7317f45a6 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Keep_Alive/DemoTasks/KeepAliveMQTTExample.c @@ -207,6 +207,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + PlaintextTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The task used to demonstrate the MQTT API. * @@ -471,6 +479,7 @@ static void prvMQTTDemoTask( void * pvParameters ) { uint32_t ulTopicCount = 0U; NetworkContext_t xNetworkContext = { 0 }; + PlaintextTransportParams_t xPlaintextTransportParams = { 0 }; MQTTContext_t xMQTTContext; MQTTStatus_t xMQTTStatus; PlaintextTransportStatus_t xNetworkStatus; @@ -479,6 +488,9 @@ static void prvMQTTDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xPlaintextTransportParams; + /* Serialize a PINGREQ packet to send upon invoking the keep-alive timer * callback. */ xMQTTStatus = MQTT_SerializePingreq( &xPingReqBuffer ); diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/DemoTasks/MultitaskMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/DemoTasks/MultitaskMQTTExample.c index afabdeeb76..d992f23750 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/DemoTasks/MultitaskMQTTExample.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Multitask/DemoTasks/MultitaskMQTTExample.c @@ -375,6 +375,18 @@ typedef struct publishElement /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + #if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 ) + TlsTransportParams_t * pParams; + #else + PlaintextTransportParams_t * pParams; + #endif +}; + +/*-----------------------------------------------------------*/ + /** * @brief Initializes an MQTT context, including transport interface and * network buffer. @@ -686,6 +698,20 @@ static MQTTContext_t globalMqttContext; */ static NetworkContext_t xNetworkContext; +#if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 ) + +/** + * @brief The parameters for the network context using a TLS channel. + */ + static TlsTransportParams_t xTlsTransportParams; +#else + +/** + * @brief The parameters for the network context using a non-encrypted channel. + */ + static PlaintextTransportParams_t xPlaintextTransportParams; +#endif + /** * @brief List of operations that are awaiting an ack from the broker. */ @@ -981,6 +1007,8 @@ static BaseType_t prvSocketConnect( NetworkContext_t * pxNetworkContext ) BackoffAlgorithmContext_t xReconnectParams; uint16_t usNextRetryBackOff = 0U; + configASSERT( pxNetworkContext != NULL && pxNetworkContext->pParams != NULL ); + #if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 ) TlsTransportStatus_t xNetworkStatus = TLS_TRANSPORT_CONNECT_FAILURE; NetworkCredentials_t xNetworkCredentials = { 0 }; @@ -1079,7 +1107,7 @@ static BaseType_t prvSocketConnect( NetworkContext_t * pxNetworkContext ) /* Set the socket wakeup callback. */ if( xConnected ) { - ( void ) FreeRTOS_setsockopt( pxNetworkContext->tcpSocket, + ( void ) FreeRTOS_setsockopt( pxNetworkContext->pParams->tcpSocket, 0, /* Level - Unused. */ FREERTOS_SO_WAKEUP_CALLBACK, ( void * ) prvMQTTClientSocketWakeupCallback, @@ -1095,8 +1123,10 @@ static BaseType_t prvSocketDisconnect( NetworkContext_t * pxNetworkContext ) { BaseType_t xDisconnected = pdFAIL; + configASSERT( pxNetworkContext != NULL && pxNetworkContext->pParams != NULL ); + /* Set the wakeup callback to NULL since the socket will disconnect. */ - ( void ) FreeRTOS_setsockopt( pxNetworkContext->tcpSocket, + ( void ) FreeRTOS_setsockopt( pxNetworkContext->pParams->tcpSocket, 0, /* Level - Unused. */ FREERTOS_SO_WAKEUP_CALLBACK, ( void * ) NULL, @@ -2074,6 +2104,13 @@ static void prvMQTTDemoTask( void * pvParameters ) ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + #if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 ) + xNetworkContext.pParams = &xTlsTransportParams; + #else + xNetworkContext.pParams = &xPlaintextTransportParams; + #endif + ulGlobalEntryTimeMs = prvGetTimeMs(); /* Create command queue for processing MQTT commands. */ diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c index ddc94a2b8c..a87ecef579 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Mutual_Auth/DemoTasks/MutualAuthMQTTExample.c @@ -274,6 +274,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The task used to demonstrate the MQTT API. * @@ -475,6 +483,7 @@ static void prvMQTTDemoTask( void * pvParameters ) uint32_t ulPublishCount = 0U, ulTopicCount = 0U; const uint32_t ulMaxPublishCount = 5UL; NetworkContext_t xNetworkContext = { 0 }; + TlsTransportParams_t xTlsTransportParams = { 0 }; NetworkCredentials_t xNetworkCredentials = { 0 }; MQTTContext_t xMQTTContext = { 0 }; MQTTStatus_t xMQTTStatus; @@ -489,6 +498,9 @@ static void prvMQTTDemoTask( void * pvParameters ) */ ulGlobalEntryTimeMs = prvGetTimeMs(); + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + for( ; ; ) { /****************************** Connect. ******************************/ diff --git a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c index a9f8fb95cd..1fe22d17c3 100644 --- a/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c +++ b/FreeRTOS-Plus/Demo/coreMQTT_Windows_Simulator/MQTT_Plain_Text/DemoTasks/PlaintextMQTTExample.c @@ -176,6 +176,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + PlaintextTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The task used to demonstrate the MQTT API. * @@ -359,6 +367,7 @@ static void prvMQTTDemoTask( void * pvParameters ) uint32_t ulPublishCount = 0U, ulTopicCount = 0U; const uint32_t ulMaxPublishCount = 5UL; NetworkContext_t xNetworkContext = { 0 }; + PlaintextTransportParams_t xPlaintextTransportParams = { 0 }; MQTTContext_t xMQTTContext; MQTTStatus_t xMQTTStatus; PlaintextTransportStatus_t xNetworkStatus; @@ -366,6 +375,9 @@ static void prvMQTTDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xPlaintextTransportParams; + ulGlobalEntryTimeMs = prvGetTimeMs(); for( ; ; ) diff --git a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/DemoTasks/MutualAuthMQTTExample.c b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/DemoTasks/MutualAuthMQTTExample.c index a6c9698e5b..6047bb5eae 100644 --- a/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/DemoTasks/MutualAuthMQTTExample.c +++ b/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator/DemoTasks/MutualAuthMQTTExample.c @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.3.0 + * FreeRTOS V202011.00 * 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 @@ -19,8 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /* @@ -159,6 +160,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief The task used to demonstrate the MQTT API. * @@ -324,6 +333,7 @@ static void prvMQTTDemoTask( void * pvParameters ) uint32_t ulPublishCount = 0U; const uint32_t ulMaxPublishCount = 5UL; NetworkContext_t xNetworkContext = { 0 }; + TlsTransportParams_t xTlsTransportParams = { 0 }; NetworkCredentials_t xNetworkCredentials = { 0 }; MQTTContext_t xMQTTContext = { 0 }; MQTTStatus_t xMQTTStatus; @@ -331,6 +341,9 @@ static void prvMQTTDemoTask( void * pvParameters ) /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; + /* Set the pParams member of the network context with desired transport. */ + xNetworkContext.pParams = &xTlsTransportParams; + /* Set the entry time of the demo application. This entry time will be used * to calculate relative time elapsed in the execution of the demo application, * by the timer utility function that is provided to the MQTT library. 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 1cd795d93a..1effb922c7 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 @@ -1,5 +1,5 @@ /* - * FreeRTOS Kernel V10.3.0 + * FreeRTOS V202011.00 * 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 @@ -19,10 +19,9 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS * - * 1 tab == 4 spaces! */ /*** diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.c index 6b067917c4..4f24e7ac14 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.c +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.c @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.h b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.h index 6f5bbe8d43..1f189214d7 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.h +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/sockets_wrapper.h @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.c index 08193b12bf..b5d13e6ce8 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.c +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.c @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** @@ -46,6 +51,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief Represents string to be logged when mbedTLS returned error * does not contain a high-level code. @@ -282,17 +295,17 @@ static int32_t setClientCertificate( SSLContext_t * pSslContext, /*-----------------------------------------------------------*/ static int32_t setPrivateKey( SSLContext_t * pSslContext, - const uint8_t * pPrivateKeyPath, + const uint8_t * pPrivateKey, size_t privateKeySize ) { int32_t mbedtlsError = -1; configASSERT( pSslContext != NULL ); - configASSERT( pPrivateKeyPath != NULL ); + configASSERT( pPrivateKey != NULL ); /* Setup the client private key. */ mbedtlsError = mbedtls_pk_parse_key( &( pSslContext->privKey ), - pPrivateKeyPath, + pPrivateKey, privateKeySize, NULL, 0 ); @@ -424,18 +437,21 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, const char * pHostName, const NetworkCredentials_t * pNetworkCredentials ) { + TlsTransportParams_t * pTlsTransportParams = NULL; TlsTransportStatus_t returnStatus = TLS_TRANSPORT_SUCCESS; int32_t mbedtlsError = 0; configASSERT( pNetworkContext != NULL ); + configASSERT( pNetworkContext->pParams != NULL ); configASSERT( pHostName != NULL ); configASSERT( pNetworkCredentials != NULL ); configASSERT( pNetworkCredentials->pRootCa != NULL ); + pTlsTransportParams = pNetworkContext->pParams; /* Initialize the mbed TLS context structures. */ - sslContextInit( &( pNetworkContext->sslContext ) ); + sslContextInit( &( pTlsTransportParams->sslContext ) ); - mbedtlsError = mbedtls_ssl_config_defaults( &( pNetworkContext->sslContext.config ), + mbedtlsError = mbedtls_ssl_config_defaults( &( pTlsTransportParams->sslContext.config ), MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT ); @@ -452,7 +468,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, if( returnStatus == TLS_TRANSPORT_SUCCESS ) { - mbedtlsError = setCredentials( &( pNetworkContext->sslContext ), + mbedtlsError = setCredentials( &( pTlsTransportParams->sslContext ), pNetworkCredentials ); if( mbedtlsError != 0 ) @@ -462,7 +478,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, else { /* Optionally set SNI and ALPN protocols. */ - setOptionalConfigurations( &( pNetworkContext->sslContext ), + setOptionalConfigurations( &( pTlsTransportParams->sslContext ), pHostName, pNetworkCredentials ); } @@ -475,15 +491,18 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, static TlsTransportStatus_t tlsHandshake( NetworkContext_t * pNetworkContext, const NetworkCredentials_t * pNetworkCredentials ) { + TlsTransportParams_t * pTlsTransportParams = NULL; TlsTransportStatus_t returnStatus = TLS_TRANSPORT_SUCCESS; int32_t mbedtlsError = 0; configASSERT( pNetworkContext != NULL ); + configASSERT( pNetworkContext->pParams != NULL ); configASSERT( pNetworkCredentials != NULL ); + pTlsTransportParams = pNetworkContext->pParams; /* Initialize the mbed TLS secured connection context. */ - mbedtlsError = mbedtls_ssl_setup( &( pNetworkContext->sslContext.context ), - &( pNetworkContext->sslContext.config ) ); + mbedtlsError = mbedtls_ssl_setup( &( pTlsTransportParams->sslContext.context ), + &( pTlsTransportParams->sslContext.config ) ); if( mbedtlsError != 0 ) { @@ -502,8 +521,8 @@ static TlsTransportStatus_t tlsHandshake( NetworkContext_t * pNetworkContext, * #mbedtls_ssl_set_bio requires the second parameter as void *. */ /* coverity[misra_c_2012_rule_11_2_violation] */ - mbedtls_ssl_set_bio( &( pNetworkContext->sslContext.context ), - ( void * ) pNetworkContext->tcpSocket, + mbedtls_ssl_set_bio( &( pTlsTransportParams->sslContext.context ), + ( void * ) pTlsTransportParams->tcpSocket, mbedtls_platform_send, mbedtls_platform_recv, NULL ); @@ -514,7 +533,7 @@ static TlsTransportStatus_t tlsHandshake( NetworkContext_t * pNetworkContext, /* Perform the TLS handshake. */ do { - mbedtlsError = mbedtls_ssl_handshake( &( pNetworkContext->sslContext.context ) ); + mbedtlsError = mbedtls_ssl_handshake( &( pTlsTransportParams->sslContext.context ) ); } while( ( mbedtlsError == MBEDTLS_ERR_SSL_WANT_READ ) || ( mbedtlsError == MBEDTLS_ERR_SSL_WANT_WRITE ) ); @@ -602,10 +621,12 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, uint32_t receiveTimeoutMs, uint32_t sendTimeoutMs ) { + TlsTransportParams_t * pTlsTransportParams = NULL; TlsTransportStatus_t returnStatus = TLS_TRANSPORT_SUCCESS; BaseType_t socketStatus = 0; if( ( pNetworkContext == NULL ) || + ( pNetworkContext->pParams == NULL ) || ( pHostName == NULL ) || ( pNetworkCredentials == NULL ) ) { @@ -629,7 +650,8 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, /* Establish a TCP connection with the server. */ if( returnStatus == TLS_TRANSPORT_SUCCESS ) { - socketStatus = Sockets_Connect( &( pNetworkContext->tcpSocket ), + pTlsTransportParams = pNetworkContext->pParams; + socketStatus = Sockets_Connect( &( pTlsTransportParams->tcpSocket ), pHostName, port, receiveTimeoutMs, @@ -647,8 +669,8 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, /* Initialize mbedtls. */ if( returnStatus == TLS_TRANSPORT_SUCCESS ) { - returnStatus = initMbedtls( &( pNetworkContext->sslContext.entropyContext ), - &( pNetworkContext->sslContext.ctrDrgbContext ) ); + returnStatus = initMbedtls( &( pTlsTransportParams->sslContext.entropyContext ), + &( pTlsTransportParams->sslContext.ctrDrgbContext ) ); } /* Initialize TLS contexts and set credentials. */ @@ -666,13 +688,13 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, /* Clean up on failure. */ if( returnStatus != TLS_TRANSPORT_SUCCESS ) { - if( pNetworkContext != NULL ) + if( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ) { - sslContextFree( &( pNetworkContext->sslContext ) ); + sslContextFree( &( pTlsTransportParams->sslContext ) ); - if( pNetworkContext->tcpSocket != FREERTOS_INVALID_SOCKET ) + if( pTlsTransportParams->tcpSocket != FREERTOS_INVALID_SOCKET ) { - ( void ) FreeRTOS_closesocket( pNetworkContext->tcpSocket ); + ( void ) FreeRTOS_closesocket( pTlsTransportParams->tcpSocket ); } } } @@ -689,12 +711,14 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, void TLS_FreeRTOS_Disconnect( NetworkContext_t * pNetworkContext ) { + TlsTransportParams_t * pTlsTransportParams = NULL; BaseType_t tlsStatus = 0; - if( pNetworkContext != NULL ) + if( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ) { + pTlsTransportParams = pNetworkContext->pParams; /* Attempting to terminate TLS connection. */ - tlsStatus = ( BaseType_t ) mbedtls_ssl_close_notify( &( pNetworkContext->sslContext.context ) ); + tlsStatus = ( BaseType_t ) mbedtls_ssl_close_notify( &( pTlsTransportParams->sslContext.context ) ); /* Ignore the WANT_READ and WANT_WRITE return values. */ if( ( tlsStatus != ( BaseType_t ) MBEDTLS_ERR_SSL_WANT_READ ) && @@ -723,10 +747,10 @@ void TLS_FreeRTOS_Disconnect( NetworkContext_t * pNetworkContext ) } /* Call socket shutdown function to close connection. */ - Sockets_Disconnect( pNetworkContext->tcpSocket ); + Sockets_Disconnect( pTlsTransportParams->tcpSocket ); /* Free mbed TLS contexts. */ - sslContextFree( &( pNetworkContext->sslContext ) ); + sslContextFree( &( pTlsTransportParams->sslContext ) ); } /* Clear the mutex functions for mbed TLS thread safety. */ @@ -738,9 +762,13 @@ int32_t TLS_FreeRTOS_recv( NetworkContext_t * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { + TlsTransportParams_t * pTlsTransportParams = NULL; int32_t tlsStatus = 0; - tlsStatus = ( int32_t ) mbedtls_ssl_read( &( pNetworkContext->sslContext.context ), + configASSERT( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ); + + pTlsTransportParams = pNetworkContext->pParams; + tlsStatus = ( int32_t ) mbedtls_ssl_read( &( pTlsTransportParams->sslContext.context ), pBuffer, bytesToRecv ); @@ -776,9 +804,13 @@ int32_t TLS_FreeRTOS_send( NetworkContext_t * pNetworkContext, const void * pBuffer, size_t bytesToSend ) { + TlsTransportParams_t * pTlsTransportParams = NULL; int32_t tlsStatus = 0; - tlsStatus = ( int32_t ) mbedtls_ssl_write( &( pNetworkContext->sslContext.context ), + configASSERT( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ); + + pTlsTransportParams = pNetworkContext->pParams; + tlsStatus = ( int32_t ) mbedtls_ssl_write( &( pTlsTransportParams->sslContext.context ), pBuffer, bytesToSend ); diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.h b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.h index e9ce3ac817..39b1110513 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.h +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls/using_mbedtls.h @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** @@ -94,14 +99,14 @@ typedef struct SSLContext } SSLContext_t; /** - * @brief Definition of the network context for the transport interface - * implementation that uses mbedTLS and FreeRTOS+TLS sockets. + * @brief Parameters for the network context of the transport interface + * implementation that uses mbedTLS and FreeRTOS+TCP sockets. */ -struct NetworkContext +typedef struct TlsTransportParams { Socket_t tcpSocket; SSLContext_t sslContext; -}; +} TlsTransportParams_t; /** * @brief Contains the credentials necessary for tls connection setup. diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c index d2d072ced8..410011e20e 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.c @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** @@ -55,6 +60,14 @@ /*-----------------------------------------------------------*/ +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + TlsTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + /** * @brief Represents string to be logged when mbedTLS returned error * does not contain a high-level code. @@ -221,19 +234,23 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, const char * pHostName, const NetworkCredentials_t * pNetworkCredentials ) { + TlsTransportParams_t * pTlsTransportParams = NULL; TlsTransportStatus_t returnStatus = TLS_TRANSPORT_SUCCESS; int32_t mbedtlsError = 0; CK_RV xResult = CKR_OK; configASSERT( pNetworkContext != NULL ); + configASSERT( pNetworkContext->pParams != NULL ); configASSERT( pHostName != NULL ); configASSERT( pNetworkCredentials != NULL ); configASSERT( pNetworkCredentials->pRootCa != NULL ); - /* Initialize the mbed TLS context structures. */ - sslContextInit( &( pNetworkContext->sslContext ) ); + pTlsTransportParams = pNetworkContext->pParams; - mbedtlsError = mbedtls_ssl_config_defaults( &( pNetworkContext->sslContext.config ), + /* Initialize the mbed TLS context structures. */ + sslContextInit( &( pTlsTransportParams->sslContext ) ); + + mbedtlsError = mbedtls_ssl_config_defaults( &( pTlsTransportParams->sslContext.config ), MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT ); @@ -251,7 +268,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, if( returnStatus == TLS_TRANSPORT_SUCCESS ) { /* Set up the certificate security profile, starting from the default value. */ - pNetworkContext->sslContext.certProfile = mbedtls_x509_crt_profile_default; + pTlsTransportParams->sslContext.certProfile = mbedtls_x509_crt_profile_default; /* test.mosquitto.org only provides a 1024-bit RSA certificate, which is * not acceptable by the default mbed TLS certificate security profile. @@ -259,20 +276,20 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, * This block should be removed otherwise. */ if( strncmp( pHostName, "test.mosquitto.org", strlen( pHostName ) ) == 0 ) { - pNetworkContext->sslContext.certProfile.rsa_min_bitlen = 1024; + pTlsTransportParams->sslContext.certProfile.rsa_min_bitlen = 1024; } /* Set SSL authmode and the RNG context. */ - mbedtls_ssl_conf_authmode( &( pNetworkContext->sslContext.config ), + mbedtls_ssl_conf_authmode( &( pTlsTransportParams->sslContext.config ), MBEDTLS_SSL_VERIFY_REQUIRED ); - mbedtls_ssl_conf_rng( &( pNetworkContext->sslContext.config ), + mbedtls_ssl_conf_rng( &( pTlsTransportParams->sslContext.config ), generateRandomBytes, - &pNetworkContext->sslContext ); - mbedtls_ssl_conf_cert_profile( &( pNetworkContext->sslContext.config ), - &( pNetworkContext->sslContext.certProfile ) ); + &pTlsTransportParams->sslContext ); + mbedtls_ssl_conf_cert_profile( &( pTlsTransportParams->sslContext.config ), + &( pTlsTransportParams->sslContext.certProfile ) ); /* Parse the server root CA certificate into the SSL context. */ - mbedtlsError = mbedtls_x509_crt_parse( &( pNetworkContext->sslContext.rootCa ), + mbedtlsError = mbedtls_x509_crt_parse( &( pTlsTransportParams->sslContext.rootCa ), pNetworkCredentials->pRootCa, pNetworkCredentials->rootCaSize ); @@ -286,8 +303,8 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, } else { - mbedtls_ssl_conf_ca_chain( &( pNetworkContext->sslContext.config ), - &( pNetworkContext->sslContext.rootCa ), + mbedtls_ssl_conf_ca_chain( &( pTlsTransportParams->sslContext.config ), + &( pTlsTransportParams->sslContext.rootCa ), NULL ); } } @@ -295,7 +312,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, if( returnStatus == TLS_TRANSPORT_SUCCESS ) { /* Setup the client private key. */ - xResult = initializeClientKeys( &( pNetworkContext->sslContext ) ); + xResult = initializeClientKeys( &( pTlsTransportParams->sslContext ) ); if( xResult != CKR_OK ) { @@ -306,10 +323,10 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, else { /* Setup the client certificate. */ - xResult = readCertificateIntoContext( &( pNetworkContext->sslContext ), + xResult = readCertificateIntoContext( &( pTlsTransportParams->sslContext ), pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS, CKO_CERTIFICATE, - &( pNetworkContext->sslContext.clientCert ) ); + &( pTlsTransportParams->sslContext.clientCert ) ); if( xResult != CKR_OK ) { @@ -319,9 +336,9 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, } else { - ( void ) mbedtls_ssl_conf_own_cert( &( pNetworkContext->sslContext.config ), - &( pNetworkContext->sslContext.clientCert ), - &( pNetworkContext->sslContext.privKey ) ); + ( void ) mbedtls_ssl_conf_own_cert( &( pTlsTransportParams->sslContext.config ), + &( pTlsTransportParams->sslContext.clientCert ), + &( pTlsTransportParams->sslContext.privKey ) ); } } } @@ -330,7 +347,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, { /* Include an application protocol list in the TLS ClientHello * message. */ - mbedtlsError = mbedtls_ssl_conf_alpn_protocols( &( pNetworkContext->sslContext.config ), + mbedtlsError = mbedtls_ssl_conf_alpn_protocols( &( pTlsTransportParams->sslContext.config ), pNetworkCredentials->pAlpnProtos ); if( mbedtlsError != 0 ) @@ -346,8 +363,8 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, if( returnStatus == TLS_TRANSPORT_SUCCESS ) { /* Initialize the mbed TLS secured connection context. */ - mbedtlsError = mbedtls_ssl_setup( &( pNetworkContext->sslContext.context ), - &( pNetworkContext->sslContext.config ) ); + mbedtlsError = mbedtls_ssl_setup( &( pTlsTransportParams->sslContext.context ), + &( pTlsTransportParams->sslContext.config ) ); if( mbedtlsError != 0 ) { @@ -366,8 +383,8 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, * #mbedtls_ssl_set_bio requires the second parameter as void *. */ /* coverity[misra_c_2012_rule_11_2_violation] */ - mbedtls_ssl_set_bio( &( pNetworkContext->sslContext.context ), - ( void * ) pNetworkContext->tcpSocket, + mbedtls_ssl_set_bio( &( pTlsTransportParams->sslContext.context ), + ( void * ) pTlsTransportParams->tcpSocket, mbedtls_platform_send, mbedtls_platform_recv, NULL ); @@ -379,7 +396,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, /* Enable SNI if requested. */ if( pNetworkCredentials->disableSni == pdFALSE ) { - mbedtlsError = mbedtls_ssl_set_hostname( &( pNetworkContext->sslContext.context ), + mbedtlsError = mbedtls_ssl_set_hostname( &( pTlsTransportParams->sslContext.context ), pHostName ); if( mbedtlsError != 0 ) @@ -402,7 +419,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, * * Smaller values can be found in "mbedtls/include/ssl.h". */ - mbedtlsError = mbedtls_ssl_conf_max_frag_len( &( pNetworkContext->sslContext.config ), MBEDTLS_SSL_MAX_FRAG_LEN_4096 ); + mbedtlsError = mbedtls_ssl_conf_max_frag_len( &( pTlsTransportParams->sslContext.config ), MBEDTLS_SSL_MAX_FRAG_LEN_4096 ); if( mbedtlsError != 0 ) { @@ -419,7 +436,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, /* Perform the TLS handshake. */ do { - mbedtlsError = mbedtls_ssl_handshake( &( pNetworkContext->sslContext.context ) ); + mbedtlsError = mbedtls_ssl_handshake( &( pTlsTransportParams->sslContext.context ) ); } while( ( mbedtlsError == MBEDTLS_ERR_SSL_WANT_READ ) || ( mbedtlsError == MBEDTLS_ERR_SSL_WANT_WRITE ) ); @@ -435,7 +452,7 @@ static TlsTransportStatus_t tlsSetup( NetworkContext_t * pNetworkContext, if( returnStatus != TLS_TRANSPORT_SUCCESS ) { - sslContextFree( &( pNetworkContext->sslContext ) ); + sslContextFree( &( pTlsTransportParams->sslContext ) ); } else { @@ -774,10 +791,12 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, uint32_t receiveTimeoutMs, uint32_t sendTimeoutMs ) { + TlsTransportParams_t * pTlsTransportParams = NULL; TlsTransportStatus_t returnStatus = TLS_TRANSPORT_SUCCESS; BaseType_t socketStatus = 0; if( ( pNetworkContext == NULL ) || + ( pNetworkContext->pParams == NULL ) || ( pHostName == NULL ) || ( pNetworkCredentials == NULL ) ) { @@ -801,7 +820,8 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, /* Establish a TCP connection with the server. */ if( returnStatus == TLS_TRANSPORT_SUCCESS ) { - socketStatus = Sockets_Connect( &( pNetworkContext->tcpSocket ), + pTlsTransportParams = pNetworkContext->pParams; + socketStatus = Sockets_Connect( &( pTlsTransportParams->tcpSocket ), pHostName, port, receiveTimeoutMs, @@ -832,9 +852,9 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, if( returnStatus != TLS_TRANSPORT_SUCCESS ) { if( ( pNetworkContext != NULL ) && - ( pNetworkContext->tcpSocket != FREERTOS_INVALID_SOCKET ) ) + ( pTlsTransportParams->tcpSocket != FREERTOS_INVALID_SOCKET ) ) { - ( void ) FreeRTOS_closesocket( pNetworkContext->tcpSocket ); + ( void ) FreeRTOS_closesocket( pTlsTransportParams->tcpSocket ); } } else @@ -851,12 +871,14 @@ TlsTransportStatus_t TLS_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, void TLS_FreeRTOS_Disconnect( NetworkContext_t * pNetworkContext ) { + TlsTransportParams_t * pTlsTransportParams = NULL; BaseType_t tlsStatus = 0; - if( pNetworkContext != NULL ) + if( pNetworkContext != NULL && pNetworkContext->pParams != NULL ) { + pTlsTransportParams = pNetworkContext->pParams; /* Attempting to terminate TLS connection. */ - tlsStatus = ( BaseType_t ) mbedtls_ssl_close_notify( &( pNetworkContext->sslContext.context ) ); + tlsStatus = ( BaseType_t ) mbedtls_ssl_close_notify( &( pTlsTransportParams->sslContext.context ) ); /* Ignore the WANT_READ and WANT_WRITE return values. */ if( ( tlsStatus != ( BaseType_t ) MBEDTLS_ERR_SSL_WANT_READ ) && @@ -885,10 +907,10 @@ void TLS_FreeRTOS_Disconnect( NetworkContext_t * pNetworkContext ) } /* Call socket shutdown function to close connection. */ - Sockets_Disconnect( pNetworkContext->tcpSocket ); + Sockets_Disconnect( pTlsTransportParams->tcpSocket ); /* Free mbed TLS contexts. */ - sslContextFree( &( pNetworkContext->sslContext ) ); + sslContextFree( &( pTlsTransportParams->sslContext ) ); } /* Clear the mutex functions for mbed TLS thread safety. */ @@ -901,9 +923,13 @@ int32_t TLS_FreeRTOS_recv( NetworkContext_t * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { + TlsTransportParams_t * pTlsTransportParams = NULL; int32_t tlsStatus = 0; - tlsStatus = ( int32_t ) mbedtls_ssl_read( &( pNetworkContext->sslContext.context ), + configASSERT( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ); + + pTlsTransportParams = pNetworkContext->pParams; + tlsStatus = ( int32_t ) mbedtls_ssl_read( &( pTlsTransportParams->sslContext.context ), pBuffer, bytesToRecv ); @@ -940,9 +966,13 @@ int32_t TLS_FreeRTOS_send( NetworkContext_t * pNetworkContext, const void * pBuffer, size_t bytesToSend ) { + TlsTransportParams_t * pTlsTransportParams = NULL; int32_t tlsStatus = 0; - tlsStatus = ( int32_t ) mbedtls_ssl_write( &( pNetworkContext->sslContext.context ), + configASSERT( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ); + + pTlsTransportParams = pNetworkContext->pParams; + tlsStatus = ( int32_t ) mbedtls_ssl_write( &( pTlsTransportParams->sslContext.context ), pBuffer, bytesToSend ); diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.h b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.h index 0dc27cd97a..4601042389 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.h +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_mbedtls_pkcs11/using_mbedtls_pkcs11.h @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /** @@ -110,11 +115,11 @@ typedef struct SSLContext * @brief Definition of the network context for the transport interface * implementation that uses mbedTLS and FreeRTOS+TLS sockets. */ -struct NetworkContext +typedef struct TlsTransportParams { Socket_t tcpSocket; SSLContext_t sslContext; -}; +} TlsTransportParams_t; /** * @brief Contains the credentials necessary for tls connection setup. diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.c index 6ec16551ec..8f63e2b139 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.c +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.c @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /* Standard includes. */ @@ -35,16 +40,27 @@ /* Transport interface include. */ #include "using_plaintext.h" +/*-----------------------------------------------------------*/ + +/* Each compilation unit must define the NetworkContext struct. */ +struct NetworkContext +{ + PlaintextTransportParams_t * pParams; +}; + +/*-----------------------------------------------------------*/ + PlaintextTransportStatus_t Plaintext_FreeRTOS_Connect( NetworkContext_t * pNetworkContext, const char * pHostName, uint16_t port, uint32_t receiveTimeoutMs, uint32_t sendTimeoutMs ) { + PlaintextTransportParams_t * pPlaintextTransportParams = NULL; PlaintextTransportStatus_t plaintextStatus = PLAINTEXT_TRANSPORT_SUCCESS; BaseType_t socketStatus = 0; - if( ( pNetworkContext == NULL ) || ( pHostName == NULL ) ) + if( ( pNetworkContext == NULL ) || ( pNetworkContext->pParams == NULL ) || ( pHostName == NULL ) ) { LogError( ( "Invalid input parameter(s): Arguments cannot be NULL. pNetworkContext=%p, " "pHostName=%p.", @@ -54,8 +70,9 @@ PlaintextTransportStatus_t Plaintext_FreeRTOS_Connect( NetworkContext_t * pNetwo } else { + pPlaintextTransportParams = pNetworkContext->pParams; /* Establish a TCP connection with the server. */ - socketStatus = Sockets_Connect( &( pNetworkContext->tcpSocket ), + socketStatus = Sockets_Connect( &( pPlaintextTransportParams->tcpSocket ), pHostName, port, receiveTimeoutMs, @@ -76,22 +93,24 @@ PlaintextTransportStatus_t Plaintext_FreeRTOS_Connect( NetworkContext_t * pNetwo PlaintextTransportStatus_t Plaintext_FreeRTOS_Disconnect( const NetworkContext_t * pNetworkContext ) { + PlaintextTransportParams_t * pPlaintextTransportParams = NULL; PlaintextTransportStatus_t plaintextStatus = PLAINTEXT_TRANSPORT_SUCCESS; - if( pNetworkContext == NULL ) + if( ( pNetworkContext == NULL ) || ( pNetworkContext->pParams == NULL ) ) { LogError( ( "pNetworkContext cannot be NULL." ) ); plaintextStatus = PLAINTEXT_TRANSPORT_INVALID_PARAMETER; } - else if( pNetworkContext->tcpSocket == FREERTOS_INVALID_SOCKET ) + else if( pNetworkContext->pParams->tcpSocket == FREERTOS_INVALID_SOCKET ) { - LogError( ( "pNetworkContext->tcpSocket cannot be an invalid socket." ) ); + LogError( ( "pPlaintextTransportParams->tcpSocket cannot be an invalid socket." ) ); plaintextStatus = PLAINTEXT_TRANSPORT_INVALID_PARAMETER; } else { + pPlaintextTransportParams = pNetworkContext->pParams; /* Call socket disconnect function to close connection. */ - Sockets_Disconnect( pNetworkContext->tcpSocket ); + Sockets_Disconnect( pPlaintextTransportParams->tcpSocket ); } return plaintextStatus; @@ -101,9 +120,16 @@ int32_t Plaintext_FreeRTOS_recv( NetworkContext_t * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { + PlaintextTransportParams_t * pPlaintextTransportParams = NULL; int32_t socketStatus = 0; - socketStatus = FreeRTOS_recv( pNetworkContext->tcpSocket, pBuffer, bytesToRecv, 0 ); + configASSERT( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ); + + pPlaintextTransportParams = pNetworkContext->pParams; + socketStatus = FreeRTOS_recv( pPlaintextTransportParams->tcpSocket, + pBuffer, + bytesToRecv, + 0 ); return socketStatus; } @@ -112,9 +138,16 @@ int32_t Plaintext_FreeRTOS_send( NetworkContext_t * pNetworkContext, const void * pBuffer, size_t bytesToSend ) { + PlaintextTransportParams_t * pPlaintextTransportParams = NULL; int32_t socketStatus = 0; - socketStatus = FreeRTOS_send( pNetworkContext->tcpSocket, pBuffer, bytesToSend, 0 ); + configASSERT( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) ); + + pPlaintextTransportParams = pNetworkContext->pParams; + socketStatus = FreeRTOS_send( pPlaintextTransportParams->tcpSocket, + pBuffer, + bytesToSend, + 0 ); return socketStatus; } diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.h b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.h index e2d4dcb4de..7ef7a2e50b 100644 --- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.h +++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/freertos_plus_tcp/using_plaintext/using_plaintext.h @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ #ifndef USING_PLAINTEXT_H @@ -67,12 +72,12 @@ extern void vLoggingPrintf( const char * pcFormatString, #include "transport_interface.h" /** - * @brief Network context definition for FreeRTOS sockets. + * @brief Parameters for the network context that uses FreeRTOS+TCP sockets. */ -struct NetworkContext +typedef struct PlaintextTransportParams { Socket_t tcpSocket; -}; +} PlaintextTransportParams_t; /** * @brief Plain text transport Connect / Disconnect return status. diff --git a/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/threading_alt.h b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/threading_alt.h index 799ca5f5c3..193952f7a0 100644 --- a/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/threading_alt.h +++ b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/threading_alt.h @@ -1,4 +1,5 @@ /* + * FreeRTOS V202011.00 * 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 @@ -17,6 +18,10 @@ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * */ /**