Remove dependency on secure sockets

Network interface implementation for FreeRTOS now directly calls into
FreeRTOS+TCP instead of going via secure sockets.
This commit is contained in:
Gaurav Aggarwal
2019-07-23 06:55:54 +00:00
parent 68fd276886
commit 05e7d9cc08
10 changed files with 166 additions and 1404 deletions

View File

@ -348,7 +348,7 @@ IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
xNetworkInfo.u.setup.pNetworkCredentialInfo = NULL;
/* Use FreeRTOS+TCP network. */
xNetworkInfo.pNetworkInterface = IOT_NETWORK_INTERFACE_AFR;
xNetworkInfo.pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS;
/* Setup the callback which is called when the MQTT connection is disconnected. */
xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();

View File

@ -148,7 +148,6 @@
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\freertos\iot_clock_freertos.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\freertos\iot_network_freertos.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\freertos\iot_threads_freertos.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\freertos_plus_tcp\iot_secure_sockets.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\logging\iot_logging.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\taskpool\iot_taskpool.c" />
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\mqtt\src\iot_mqtt_api.c" />
@ -193,12 +192,8 @@
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\include\platform\iot_network.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\include\platform\iot_threads.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\include\types\iot_platform_types.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\include\iot_secure_sockets.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\include\iot_secure_sockets_config_defaults.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\include\iot_secure_sockets_wrapper_metrics.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\iot_taskpool.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\private\iot_error.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\private\iot_lib_init.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\private\iot_logging.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\private\iot_static_memory.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\private\iot_taskpool_internal.h" />

View File

@ -93,15 +93,6 @@
<Filter Include="FreeRTOS+\FreeRTOS IoT Libraries\standard\common\logging">
<UniqueIdentifier>{1943ad1a-a367-4ef5-ab65-1313801e6327}</UniqueIdentifier>
</Filter>
<Filter Include="FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets">
<UniqueIdentifier>{9a82e058-c6c5-4da5-817e-a28c5137749b}</UniqueIdentifier>
</Filter>
<Filter Include="FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets\include">
<UniqueIdentifier>{cf6813fa-76cf-4e4d-86f7-18f1ae92ad44}</UniqueIdentifier>
</Filter>
<Filter Include="FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets\freertos_plus_tcp">
<UniqueIdentifier>{79ebfd9f-45cb-4a3b-8c73-73f9d9fe7984}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW\port.c">
@ -193,9 +184,6 @@
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\freertos\iot_threads_freertos.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\abstractions\platform\freertos</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\freertos_plus_tcp\iot_secure_sockets.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets\freertos_plus_tcp</Filter>
</ClCompile>
<ClCompile Include="DemoTasks\SimpleMQTTExamples.c">
<Filter>DemoTasks</Filter>
</ClCompile>
@ -331,17 +319,5 @@
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\platform\include\platform\iot_threads.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\abstractions\platform\include\platform</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\include\iot_secure_sockets.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\include\iot_secure_sockets_config_defaults.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\abstractions\secure_sockets\include\iot_secure_sockets_wrapper_metrics.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\abstractions\secure_sockets\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\FreeRTOS-IoT-Libraries\c_sdk\standard\common\include\private\iot_lib_init.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\common\include\private</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -25,12 +25,12 @@
/**
* @file iot_network_freertos.h
* @brief Declares the network stack functions specified in aws_iot_network.h for
* Amazon FreeRTOS Secure Sockets.
* @brief Declares the network stack functions specified in iot_network.h for
* FreeRTOS+TCP.
*/
#ifndef _IOT_NETWORK_AFR_H_
#define _IOT_NETWORK_AFR_H_
#ifndef _IOT_NETWORK_FREERTOS_H_
#define _IOT_NETWORK_FREERTOS_H_
/* Standard includes. */
#include <stdbool.h>
@ -38,29 +38,26 @@
/* Platform network include. */
#include "platform/iot_network.h"
/* Amazon FreeRTOS Secure Sockets include. */
#include "iot_secure_sockets.h"
/**
* @brief Represents a network connection that uses Amazon FreeRTOS Secure Sockets.
* @brief Represents a network connection that uses FreeRTOS+TCP sockets.
*
* This is an incomplete type. In application code, only pointers to this type
* should be used.
*/
typedef struct _networkConnection IotNetworkConnectionAfr_t;
typedef struct _networkConnection IotNetworkConnectionFreeRTOS_t;
/**
* @brief Provides a default value for an #IotNetworkConnectionAfr_t.
* @brief Provides a default value for an #IotNetworkConnectionFreeRTOS_t.
*
* All instances of #IotNetworkConnectionAfr_t should be initialized with
* All instances of #IotNetworkConnectionFreeRTOS_t should be initialized with
* this constant.
*
* @warning Failing to initialize an #IotNetworkConnectionAfr_t with this
* @warning Failing to initialize an #IotNetworkConnectionFreeRTOS_t with this
* initializer may result in undefined behavior!
* @note This initializer may change at any time in future versions, but its
* name will remain the same.
*/
#define IOT_NETWORK_CONNECTION_AFR_INITIALIZER { 0 }
#define IOT_NETWORK_CONNECTION_FREERTOS_INITIALIZER { 0 }
/**
* @brief Generic initializer for an #IotNetworkServerInfo_t.
@ -68,7 +65,7 @@ typedef struct _networkConnection IotNetworkConnectionAfr_t;
* @note This initializer may change at any time in future versions, but its
* name will remain the same.
*/
#define IOT_NETWORK_SERVER_INFO_AFR_INITIALIZER { 0 }
#define IOT_NETWORK_SERVER_INFO_FREERTOS_INITIALIZER { 0 }
/**
* @brief Generic initializer for an #IotNetworkCredentials_t.
@ -76,57 +73,57 @@ typedef struct _networkConnection IotNetworkConnectionAfr_t;
* @note This initializer may change at any time in future versions, but its
* name will remain the same.
*/
#define IOT_NETWORK_CREDENTIALS_AFR_INITIALIZER { 0 }
#define IOT_NETWORK_CREDENTIALS_FREERTOS_INITIALIZER { 0 }
/**
* @brief Provides a pointer to an #IotNetworkInterface_t that uses the functions
* declared in this file.
*/
#define IOT_NETWORK_INTERFACE_AFR ( &( IotNetworkAfr ) )
#define IOT_NETWORK_INTERFACE_FREERTOS ( &( IotNetworkFreeRTOS ) )
/**
* @brief An implementation of #IotNetworkInterface_t::create for Amazon FreeRTOS
* Secure Sockets.
* @brief An implementation of #IotNetworkInterface_t::create for FreeRTOS+TCP
* sockets.
*/
IotNetworkError_t IotNetworkAfr_Create( void * pConnectionInfo,
void * pCredentialInfo,
void ** const pConnection );
IotNetworkError_t IotNetworkFreeRTOS_Create( void * pConnectionInfo,
void * pCredentialInfo,
void ** const pConnection );
/**
* @brief An implementation of #IotNetworkInterface_t::setReceiveCallback for
* Amazon FreeRTOS Secure Sockets.
* FreeRTOS+TCP sockets.
*/
IotNetworkError_t IotNetworkAfr_SetReceiveCallback( void * pConnection,
IotNetworkReceiveCallback_t receiveCallback,
void * pContext );
IotNetworkError_t IotNetworkFreeRTOS_SetReceiveCallback( void * pConnection,
IotNetworkReceiveCallback_t receiveCallback,
void * pContext );
/**
* @brief An implementation of #IotNetworkInterface_t::send for Amazon FreeRTOS
* Secure Sockets.
* @brief An implementation of #IotNetworkInterface_t::send for FreeRTOS+TCP
* sockets.
*/
size_t IotNetworkAfr_Send( void * pConnection,
const uint8_t * pMessage,
size_t messageLength );
size_t IotNetworkFreeRTOS_Send( void * pConnection,
const uint8_t * pMessage,
size_t messageLength );
/**
* @brief An implementation of #IotNetworkInterface_t::receive for Amazon FreeRTOS
* Secure Sockets.
* @brief An implementation of #IotNetworkInterface_t::receive for FreeRTOS+TCP
* sockets.
*/
size_t IotNetworkAfr_Receive( void * pConnection,
uint8_t * pBuffer,
size_t bytesRequested );
size_t IotNetworkFreeRTOS_Receive( void * pConnection,
uint8_t * pBuffer,
size_t bytesRequested );
/**
* @brief An implementation of #IotNetworkInterface_t::close for Amazon FreeRTOS
* Secure Sockets.
* @brief An implementation of #IotNetworkInterface_t::close for FreeRTOS+TCP
* sockets.
*/
IotNetworkError_t IotNetworkAfr_Close( void * pConnection );
IotNetworkError_t IotNetworkFreeRTOS_Close( void * pConnection );
/**
* @brief An implementation of #IotNetworkInterface_t::destroy for Amazon FreeRTOS
* Secure Sockets.
* @brief An implementation of #IotNetworkInterface_t::destroy for FreeRTOS+TCP
* sockets.
*/
IotNetworkError_t IotNetworkAfr_Destroy( void * pConnection );
IotNetworkError_t IotNetworkFreeRTOS_Destroy( void * pConnection );
/**
* @cond DOXYGEN_IGNORE
@ -134,7 +131,7 @@ IotNetworkError_t IotNetworkAfr_Destroy( void * pConnection );
*
* Declaration of a network interface struct using the functions in this file.
*/
extern const IotNetworkInterface_t IotNetworkAfr;
extern const IotNetworkInterface_t IotNetworkFreeRTOS;
/** @endcond */
#endif /* ifndef _IOT_NETWORK_AFR_H_ */
#endif /* ifndef _IOT_NETWORK_FREERTOS_H_ */

View File

@ -1,72 +0,0 @@
/*
* Amazon FreeRTOS Secure Sockets V1.1.5
* Copyright (C) 2018 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.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
/**
* @file iot_secure_sockets_config_defaults.h
* @brief Ensures that the required sockets configuration options are supplied
* and the optional ones are set to sane values if the user does not supply.
*/
#ifndef AWS_INC_SECURE_SOCKETS_CONFIG_DEFAULTS_H_
#define AWS_INC_SECURE_SOCKETS_CONFIG_DEFAULTS_H_
/**
* @brief Byte order of the target MCU must be defined.
*
* Valid values are pdLITTLE_ENDIAN and pdBIG_ENDIAN.
*/
#ifndef socketsconfigBYTE_ORDER
#error "socketsconfigBYTE_ORDER must be defined."
#endif
/**
* @brief Default socket send timeout.
*
* The user can change the send timeout for a socket using the SOCKETS_SetSockOpt API
* with the SOCKETS_SO_SNDTIMEO option.
*/
#ifndef socketsconfigDEFAULT_SEND_TIMEOUT
#define socketsconfigDEFAULT_SEND_TIMEOUT ( 10000 )
#endif
/**
* @brief Default socket receive timeout.
*
* The user can change the receive timeout for a socket using the SOCKETS_SetSockOpt API
* with the SOCKETS_SO_RCVTIMEO option.
*/
#ifndef socketsconfigDEFAULT_RECV_TIMEOUT
#define socketsconfigDEFAULT_RECV_TIMEOUT ( 10000 )
#endif
/**
* @brief By default, metrics of secure socket is disabled.
*
*/
#ifndef AWS_IOT_SECURE_SOCKETS_METRICS_ENABLED
#define AWS_IOT_SECURE_SOCKETS_METRICS_ENABLED ( 0 )
#endif
#endif /* AWS_INC_SECURE_SOCKETS_CONFIG_DEFAULTS_H_ */

View File

@ -1,43 +0,0 @@
/*
* Amazon FreeRTOS Secure Sockets V1.1.5
* Copyright (C) 2018 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.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
#ifndef _AWS_SECURE_SOCKETS_WRAPPER_METRICS_
#define _AWS_SECURE_SOCKETS_WRAPPER_METRICS_
/* This file redefines Secure Sockets functions to be called through a wrapper macro,
* but only if metrics is enabled explicitly. */
#if AWS_IOT_SECURE_SOCKETS_METRICS_ENABLED == 1
/* This macro is included in aws_secure_socket.c and aws_secure_socket_wrapper_metrics.c.
* It will prevent the redefine in those source files. */
#ifndef _SECURE_SOCKETS_WRAPPER_NOT_REDEFINE
#define SOCKETS_Init Sockets_MetricsInit
#define SOCKETS_Connect Sockets_MetricsConnect
#define SOCKETS_Shutdown Sockets_MetricsShutdown
#endif
#endif
#endif /* ifndef _AWS_SECURE_SOCKETS_WRAPPER_METRICS_ */

View File

@ -1,33 +0,0 @@
/*
* Amazon FreeRTOS Common V1.0.0
* Copyright (C) 2018 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.
*
* http://aws.amazon.com/freertos
* http://www.FreeRTOS.org
*/
#ifndef _AWS_LIB_INIT_H_
#define _AWS_LIB_INIT_H_
#include "FreeRTOS.h"
#define lib_initDECLARE_LIB_INIT( f ) extern BaseType_t f( void )
#endif /* _AWS_LIB_INIT_H_ */