summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Sun <smn@amazon.com>2021-10-26 15:11:29 +0800
committerAndy Sun <smn@amazon.com>2021-11-09 17:14:19 +0800
commite1fe33000597e4696ae57653dcc9f0c5ae0f5549 (patch)
treeb64628e1ad266fef5ed78924cbba68aba6a2eb21
parentc5de17a053cb77eacbf1010c7a799c70856b4f60 (diff)
downloadfreertos-git-e1fe33000597e4696ae57653dcc9f0c5ae0f5549.tar.gz
The modification for mbedtls platform send/recv function for cellular
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj3
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj.filters11
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/mbedtls_config.h4
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj3
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj.filters11
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/mbedtls_config.h4
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj6
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj.filters11
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/mbedtls_config.h4
-rw-r--r--FreeRTOS-Plus/Source/Application-Protocols/network_transport/cellular/using_mbedtls/using_mbedtls.c4
-rw-r--r--FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_cellular.c90
-rw-r--r--FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_plus_tcp.c141
-rw-r--r--FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_freertos_port.c101
13 files changed, 270 insertions, 123 deletions
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj
index 81b61e606..212cfcfa0 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj
@@ -170,6 +170,8 @@
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\FreeRTOS_UDP_IP.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_cellular.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
@@ -496,7 +498,6 @@
<ClCompile Include="..\Common\cellular_setup.c" />
<ClCompile Include="..\Common\comm_if_windows.c" />
<ClCompile Include="..\Common\main.c" />
- <ClCompile Include="..\Common\mbedtls\mbedtls_freertos_port.c" />
<ClCompile Include="DemoTasks\MutualAuthMQTTExample.c" />
</ItemGroup>
<ItemGroup>
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj.filters
index 84dbacbfe..0eeca069d 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/WIN32.vcxproj.filters
@@ -449,9 +449,6 @@
<Filter>FreeRTOS+\FreeRTOS+TCP</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
- <ClCompile Include="..\Common\mbedtls\mbedtls_freertos_port.c">
- <Filter>Common\mbedtls</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Cellular-Interface\source\cellular_3gpp_api.c">
@@ -463,6 +460,13 @@
<Filter>Common\mbedtls</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Source\Application-Protocols\network_transport\cellular\using_mbedtls\using_mbedtls.c" />
+ <ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c">
+ <Filter>Common\mbedtls</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_cellular.c">
+ <Filter>Common\mbedtls</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\FreeRTOS\Source\include\timers.h">
@@ -877,5 +881,6 @@
<Filter>Common\mbedtls</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\Application-Protocols\network_transport\cellular\using_mbedtls\using_mbedtls.h" />
+ <ClInclude Include="..\..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/mbedtls_config.h b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/mbedtls_config.h
index 1745d60dd..13d34b8be 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/mbedtls_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_BG96/mbedtls_config.h
@@ -114,10 +114,10 @@ void mbedtls_platform_free( void * ptr );
#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free
/* The network send and receive functions on FreeRTOS. */
-int mbedtls_platform_send( void * ctx,
+int mbedtls_cellular_send( void * ctx,
const unsigned char * buf,
size_t len );
-int mbedtls_platform_recv( void * ctx,
+int mbedtls_cellular_recv( void * ctx,
unsigned char * buf,
size_t len );
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj
index a47a2bbf9..9cbd9dc74 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj
@@ -170,6 +170,8 @@
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\FreeRTOS_UDP_IP.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_cellular.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
@@ -496,7 +498,6 @@
<ClCompile Include="..\Common\cellular_setup.c" />
<ClCompile Include="..\Common\comm_if_windows.c" />
<ClCompile Include="..\Common\main.c" />
- <ClCompile Include="..\Common\mbedtls\mbedtls_freertos_port.c" />
<ClCompile Include="DemoTasks\MutualAuthMQTTExample.c" />
</ItemGroup>
<ItemGroup>
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj.filters
index b611ad3b2..b3014b36a 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/WIN32.vcxproj.filters
@@ -453,9 +453,6 @@
<Filter>Module</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
- <ClCompile Include="..\Common\mbedtls\mbedtls_freertos_port.c">
- <Filter>Common\mbedtls</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\network_transport\cellular\sockets_wrapper.c">
@@ -463,6 +460,13 @@
</ClCompile>
<ClCompile Include="..\..\..\Source\Application-Protocols\network_transport\cellular\using_mbedtls\using_mbedtls.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
+ <ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_cellular.c">
+ <Filter>Common\mbedtls</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c">
+ <Filter>Common\mbedtls</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\FreeRTOS\Source\include\timers.h">
@@ -879,5 +883,6 @@
</ClInclude>
<ClInclude Include="..\..\..\Source\Application-Protocols\network_transport\cellular\using_mbedtls\using_mbedtls.h" />
<ClInclude Include="..\..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
+ <ClInclude Include="..\..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/mbedtls_config.h b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/mbedtls_config.h
index 1745d60dd..13d34b8be 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/mbedtls_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_HL7802/mbedtls_config.h
@@ -114,10 +114,10 @@ void mbedtls_platform_free( void * ptr );
#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free
/* The network send and receive functions on FreeRTOS. */
-int mbedtls_platform_send( void * ctx,
+int mbedtls_cellular_send( void * ctx,
const unsigned char * buf,
size_t len );
-int mbedtls_platform_recv( void * ctx,
+int mbedtls_cellular_recv( void * ctx,
unsigned char * buf,
size_t len );
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj
index 74c7d3325..1eca9ead8 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj
@@ -170,6 +170,8 @@
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\FreeRTOS_UDP_IP.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_cellular.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT\source\core_mqtt_serializer.c" />
@@ -496,7 +498,6 @@
<ClCompile Include="..\Common\cellular_setup.c" />
<ClCompile Include="..\Common\comm_if_windows.c" />
<ClCompile Include="..\Common\main.c" />
- <ClCompile Include="..\Common\mbedtls\mbedtls_freertos_port.c" />
<ClCompile Include="DemoTasks\MutualAuthMQTTExample.c" />
</ItemGroup>
<ItemGroup>
@@ -630,7 +631,6 @@
<ClInclude Include="..\..\..\ThirdParty\mbedtls\include\mbedtls\x509_csr.h" />
<ClInclude Include="..\..\..\ThirdParty\mbedtls\include\mbedtls\xtea.h" />
<ClInclude Include="..\Common\cellular_platform.h" />
-
<ClInclude Include="cellular_config.h" />
<ClInclude Include="mbedtls_config.h" />
<ClInclude Include="demo_config.h" />
@@ -641,4 +641,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj.filters b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj.filters
index 864c15835..a4dc622f8 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj.filters
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/WIN32.vcxproj.filters
@@ -453,9 +453,6 @@
<Filter>Module</Filter>
</ClCompile>
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
- <ClCompile Include="..\Common\mbedtls\mbedtls_freertos_port.c">
- <Filter>Common\mbedtls</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\network_transport\cellular\using_mbedtls\using_mbedtls.c" />
@@ -463,6 +460,13 @@
<ClCompile Include="..\..\..\Source\Application-Protocols\network_transport\cellular\sockets_wrapper.c">
<Filter>Common\mbedtls</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\ThirdParty\mbedtls\library\error.c" />
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_bio_freertos_cellular.c">
+ <Filter>Common\mbedtls</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c">
+ <Filter>Common\mbedtls</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\FreeRTOS\Source\include\timers.h">
@@ -877,5 +881,6 @@
<ClInclude Include="..\..\..\Source\Application-Protocols\network_transport\cellular\sockets_wrapper.h">
<Filter>Common\mbedtls</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\ThirdParty\mbedtls\include\mbedtls\error.h" />
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/mbedtls_config.h b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/mbedtls_config.h
index 1745d60dd..13d34b8be 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/mbedtls_config.h
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_Cellular_Interface_Windows_Simulator/MQTT_Mutual_Auth_Demo_with_SARA_R4/mbedtls_config.h
@@ -114,10 +114,10 @@ void mbedtls_platform_free( void * ptr );
#define MBEDTLS_PLATFORM_FREE_MACRO mbedtls_platform_free
/* The network send and receive functions on FreeRTOS. */
-int mbedtls_platform_send( void * ctx,
+int mbedtls_cellular_send( void * ctx,
const unsigned char * buf,
size_t len );
-int mbedtls_platform_recv( void * ctx,
+int mbedtls_cellular_recv( void * ctx,
unsigned char * buf,
size_t len );
diff --git a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/cellular/using_mbedtls/using_mbedtls.c b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/cellular/using_mbedtls/using_mbedtls.c
index e0d3fff9b..65f39831d 100644
--- a/FreeRTOS-Plus/Source/Application-Protocols/network_transport/cellular/using_mbedtls/using_mbedtls.c
+++ b/FreeRTOS-Plus/Source/Application-Protocols/network_transport/cellular/using_mbedtls/using_mbedtls.c
@@ -527,8 +527,8 @@ static TlsTransportStatus_t tlsHandshake( NetworkContext_t * pNetworkContext,
/* coverity[misra_c_2012_rule_11_2_violation] */
mbedtls_ssl_set_bio( &( pTlsTransportParams->sslContext.context ),
( void * ) pTlsTransportParams->tcpSocket,
- mbedtls_platform_send,
- mbedtls_platform_recv,
+ mbedtls_cellular_send,
+ mbedtls_cellular_recv,
NULL );
}
diff --git a/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_cellular.c b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_cellular.c
new file mode 100644
index 000000000..443163302
--- /dev/null
+++ b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_cellular.c
@@ -0,0 +1,90 @@
+/*
+ * FreeRTOS V202107.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
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * 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
+ *
+ */
+
+/**
+ * @file mbedtls_bio_freertos_cellular.c
+ * @brief Implements mbed TLS platform send/receive functions for cellular.
+ */
+
+/* FreeRTOS includes. */
+#include "FreeRTOS.h"
+#include "FreeRTOS_Sockets.h"
+
+/* mbed TLS includes. */
+#include "mbedtls_config.h"
+#include "threading_alt.h"
+#include "mbedtls/entropy.h"
+#include "mbedtls/ssl.h"
+
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief Sends data over FreeRTOS+TCP sockets.
+ *
+ * @param[in] ctx The network context containing the socket handle.
+ * @param[in] buf Buffer containing the bytes to send.
+ * @param[in] len Number of bytes to send from the buffer.
+ *
+ * @return Number of bytes sent on success; else a negative value.
+ */
+int mbedtls_cellular_send( void * ctx,
+ const unsigned char * buf,
+ size_t len )
+{
+ Socket_t socket;
+
+ configASSERT( ctx != NULL );
+ configASSERT( buf != NULL );
+
+ socket = ( Socket_t ) ctx;
+
+ return Sockets_Send( socket, buf, len );
+}
+
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief Receives data from FreeRTOS+TCP socket.
+ *
+ * @param[in] ctx The network context containing the socket handle.
+ * @param[out] buf Buffer to receive bytes into.
+ * @param[in] len Number of bytes to receive from the network.
+ *
+ * @return Number of bytes received if successful; Negative value on error.
+ */
+int mbedtls_cellular_recv( void * ctx,
+ unsigned char * buf,
+ size_t len )
+{
+ Socket_t socket;
+
+ configASSERT( ctx != NULL );
+ configASSERT( buf != NULL );
+
+ socket = ( Socket_t ) ctx;
+
+ return ( int ) Sockets_Recv( socket, buf, len );
+} \ No newline at end of file
diff --git a/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_plus_tcp.c b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_plus_tcp.c
new file mode 100644
index 000000000..8a12438d8
--- /dev/null
+++ b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_bio_freertos_plus_tcp.c
@@ -0,0 +1,141 @@
+/*
+ * FreeRTOS V202107.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
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * 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
+ *
+ */
+
+/**
+ * @file mbedtls_bio_freertos_plus_tcp.c
+ * @brief Implements mbed TLS platform send/receive functions for freertos plus tcp.
+ */
+
+/* FreeRTOS includes. */
+#include "FreeRTOS.h"
+#include "FreeRTOS_Sockets.h"
+
+/* mbed TLS includes. */
+#include "mbedtls_config.h"
+#include "threading_alt.h"
+#include "mbedtls/entropy.h"
+#include "mbedtls/ssl.h"
+
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief Sends data over FreeRTOS+TCP sockets.
+ *
+ * @param[in] ctx The network context containing the socket handle.
+ * @param[in] buf Buffer containing the bytes to send.
+ * @param[in] len Number of bytes to send from the buffer.
+ *
+ * @return Number of bytes sent on success; else a negative value.
+ */
+int mbedtls_platform_send( void * ctx,
+ const unsigned char * buf,
+ size_t len )
+{
+ Socket_t socket;
+ BaseType_t sendStatus = 0;
+ int returnStatus = -1;
+
+ configASSERT( ctx != NULL );
+ configASSERT( buf != NULL );
+
+ socket = ( Socket_t ) ctx;
+ sendStatus = FreeRTOS_send( socket, buf, len, 0 );
+
+ switch( sendStatus )
+ {
+ /* Socket was closed or just got closed. */
+ case -pdFREERTOS_ERRNO_ENOTCONN:
+ /* Not enough memory for the socket to create either an Rx or Tx stream. */
+ case -pdFREERTOS_ERRNO_ENOMEM:
+ /* Socket is not valid, is not a TCP socket, or is not bound. */
+ case -pdFREERTOS_ERRNO_EINVAL:
+ /* Socket received a signal, causing the read operation to be aborted. */
+ case -pdFREERTOS_ERRNO_EINTR:
+ returnStatus = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
+ break;
+
+ /* A timeout occurred before any data could be sent. */
+ case -pdFREERTOS_ERRNO_ENOSPC:
+ returnStatus = MBEDTLS_ERR_SSL_TIMEOUT;
+ break;
+
+ default:
+ returnStatus = ( int ) sendStatus;
+ break;
+ }
+
+ return returnStatus;
+}
+
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief Receives data from FreeRTOS+TCP socket.
+ *
+ * @param[in] ctx The network context containing the socket handle.
+ * @param[out] buf Buffer to receive bytes into.
+ * @param[in] len Number of bytes to receive from the network.
+ *
+ * @return Number of bytes received if successful; Negative value on error.
+ */
+int mbedtls_platform_recv( void * ctx,
+ unsigned char * buf,
+ size_t len )
+{
+ Socket_t socket;
+ BaseType_t recvStatus = 0;
+ int returnStatus = -1;
+
+ configASSERT( ctx != NULL );
+ configASSERT( buf != NULL );
+
+ socket = ( Socket_t ) ctx;
+
+ recvStatus = FreeRTOS_recv( socket, buf, len, 0 );
+
+ switch( recvStatus )
+ {
+ /* No data could be sent because the socket was or just got closed. */
+ case -pdFREERTOS_ERRNO_ENOTCONN:
+ /* No data could be sent because there was insufficient memory. */
+ case -pdFREERTOS_ERRNO_ENOMEM:
+ /* No data could be sent because xSocket was not a valid TCP socket. */
+ case -pdFREERTOS_ERRNO_EINVAL:
+ returnStatus = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
+ break;
+
+ /* A timeout occurred before any data could be received. */
+ case 0:
+ returnStatus = MBEDTLS_ERR_SSL_WANT_READ;
+ break;
+
+ default:
+ returnStatus = ( int ) recvStatus;
+ break;
+ }
+
+ return returnStatus;
+} \ No newline at end of file
diff --git a/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_freertos_port.c b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_freertos_port.c
index 9b1c37020..fd6aa7133 100644
--- a/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_freertos_port.c
+++ b/FreeRTOS-Plus/Source/Utilities/mbedtls_freertos/mbedtls_freertos_port.c
@@ -99,107 +99,6 @@ void mbedtls_platform_free( void * ptr )
/*-----------------------------------------------------------*/
/**
- * @brief Sends data over FreeRTOS+TCP sockets.
- *
- * @param[in] ctx The network context containing the socket handle.
- * @param[in] buf Buffer containing the bytes to send.
- * @param[in] len Number of bytes to send from the buffer.
- *
- * @return Number of bytes sent on success; else a negative value.
- */
-int mbedtls_platform_send( void * ctx,
- const unsigned char * buf,
- size_t len )
-{
- Socket_t socket;
- BaseType_t sendStatus = 0;
- int returnStatus = -1;
-
- configASSERT( ctx != NULL );
- configASSERT( buf != NULL );
-
- socket = ( Socket_t ) ctx;
- sendStatus = FreeRTOS_send( socket, buf, len, 0 );
-
- switch( sendStatus )
- {
- /* Socket was closed or just got closed. */
- case -pdFREERTOS_ERRNO_ENOTCONN:
- /* Not enough memory for the socket to create either an Rx or Tx stream. */
- case -pdFREERTOS_ERRNO_ENOMEM:
- /* Socket is not valid, is not a TCP socket, or is not bound. */
- case -pdFREERTOS_ERRNO_EINVAL:
- /* Socket received a signal, causing the read operation to be aborted. */
- case -pdFREERTOS_ERRNO_EINTR:
- returnStatus = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
- break;
-
- /* A timeout occurred before any data could be sent. */
- case -pdFREERTOS_ERRNO_ENOSPC:
- returnStatus = MBEDTLS_ERR_SSL_TIMEOUT;
- break;
-
- default:
- returnStatus = ( int ) sendStatus;
- break;
- }
-
- return returnStatus;
-}
-
-/*-----------------------------------------------------------*/
-
-/**
- * @brief Receives data from FreeRTOS+TCP socket.
- *
- * @param[in] ctx The network context containing the socket handle.
- * @param[out] buf Buffer to receive bytes into.
- * @param[in] len Number of bytes to receive from the network.
- *
- * @return Number of bytes received if successful; Negative value on error.
- */
-int mbedtls_platform_recv( void * ctx,
- unsigned char * buf,
- size_t len )
-{
- Socket_t socket;
- BaseType_t recvStatus = 0;
- int returnStatus = -1;
-
- configASSERT( ctx != NULL );
- configASSERT( buf != NULL );
-
- socket = ( Socket_t ) ctx;
-
- recvStatus = FreeRTOS_recv( socket, buf, len, 0 );
-
- switch( recvStatus )
- {
- /* No data could be sent because the socket was or just got closed. */
- case -pdFREERTOS_ERRNO_ENOTCONN:
- /* No data could be sent because there was insufficient memory. */
- case -pdFREERTOS_ERRNO_ENOMEM:
- /* No data could be sent because xSocket was not a valid TCP socket. */
- case -pdFREERTOS_ERRNO_EINVAL:
- returnStatus = MBEDTLS_ERR_SSL_INTERNAL_ERROR;
- break;
-
- /* A timeout occurred before any data could be received. */
- case 0:
- returnStatus = MBEDTLS_ERR_SSL_WANT_READ;
- break;
-
- default:
- returnStatus = ( int ) recvStatus;
- break;
- }
-
- return returnStatus;
-}
-
-/*-----------------------------------------------------------*/
-
-/**
* @brief Creates a mutex.
*
* @param[in, out] pMutex mbedtls mutex handle.