mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2025-12-16 01:44:30 +08:00
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:
@@ -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();
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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>
|
||||
@@ -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_ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,342 +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
|
||||
*/
|
||||
|
||||
/* Define _SECURE_SOCKETS_WRAPPER_NOT_REDEFINE to prevent secure sockets functions
|
||||
* from redefining in iot_secure_sockets_wrapper_metrics.h */
|
||||
#define _SECURE_SOCKETS_WRAPPER_NOT_REDEFINE
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "FreeRTOSIPConfig.h"
|
||||
#include "list.h"
|
||||
#include "semphr.h"
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_Sockets.h"
|
||||
#include "iot_secure_sockets.h"
|
||||
#include "task.h"
|
||||
|
||||
#undef _SECURE_SOCKETS_WRAPPER_NOT_REDEFINE
|
||||
|
||||
/* Internal context structure. */
|
||||
typedef struct SSOCKETContext
|
||||
{
|
||||
Socket_t xSocket;
|
||||
char * pcDestination;
|
||||
BaseType_t xSendFlags;
|
||||
BaseType_t xRecvFlags;
|
||||
BaseType_t xConnectAttempted;
|
||||
} SSOCKETContext_t, * SSOCKETContextPtr_t;
|
||||
|
||||
/*
|
||||
* Helper routines.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @brief Network send callback.
|
||||
*/
|
||||
static BaseType_t prvNetworkSend( void * pvContext,
|
||||
const unsigned char * pucData,
|
||||
size_t xDataLength )
|
||||
{
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) pvContext; /*lint !e9087 cast used for portability. */
|
||||
|
||||
return FreeRTOS_send( pxContext->xSocket, pucData, xDataLength, pxContext->xSendFlags );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* @brief Network receive callback.
|
||||
*/
|
||||
static BaseType_t prvNetworkRecv( void * pvContext,
|
||||
unsigned char * pucReceiveBuffer,
|
||||
size_t xReceiveLength )
|
||||
{
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) pvContext; /*lint !e9087 cast used for portability. */
|
||||
|
||||
return FreeRTOS_recv( pxContext->xSocket, pucReceiveBuffer, xReceiveLength, pxContext->xRecvFlags );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Interface routines.
|
||||
*/
|
||||
|
||||
int32_t SOCKETS_Close( Socket_t xSocket )
|
||||
{
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) xSocket; /*lint !e9087 cast used for portability. */
|
||||
int32_t lReturn;
|
||||
|
||||
if( ( xSocket != SOCKETS_INVALID_SOCKET ) && ( NULL != pxContext ) )
|
||||
{
|
||||
/* Clean-up destination string. */
|
||||
if( NULL != pxContext->pcDestination )
|
||||
{
|
||||
vPortFree( pxContext->pcDestination );
|
||||
}
|
||||
|
||||
/* Close the underlying socket handle. */
|
||||
( void ) FreeRTOS_closesocket( pxContext->xSocket );
|
||||
|
||||
/* Free the context. */
|
||||
vPortFree( pxContext );
|
||||
lReturn = SOCKETS_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
lReturn = SOCKETS_EINVAL;
|
||||
}
|
||||
|
||||
return lReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int32_t SOCKETS_Connect( Socket_t xSocket,
|
||||
SocketsSockaddr_t * pxAddress,
|
||||
Socklen_t xAddressLength )
|
||||
{
|
||||
int32_t lStatus = SOCKETS_ERROR_NONE;
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) xSocket; /*lint !e9087 cast used for portability. */
|
||||
struct freertos_sockaddr xTempAddress = { 0 };
|
||||
|
||||
if( ( pxContext != SOCKETS_INVALID_SOCKET ) && ( pxAddress != NULL ) )
|
||||
{
|
||||
/* A connection was attempted. If this function fails, then the socket is invalid and the user
|
||||
* must call SOCKETS_Close(), on this socket, and SOCKETS_Socket() to get a new socket. */
|
||||
pxContext->xConnectAttempted = pdTRUE;
|
||||
|
||||
/* Connect the wrapped socket. */
|
||||
xTempAddress.sin_addr = pxAddress->ulAddress;
|
||||
xTempAddress.sin_family = pxAddress->ucSocketDomain;
|
||||
xTempAddress.sin_len = ( uint8_t ) sizeof( xTempAddress );
|
||||
xTempAddress.sin_port = pxAddress->usPort;
|
||||
lStatus = FreeRTOS_connect( pxContext->xSocket, &xTempAddress, xAddressLength );
|
||||
}
|
||||
else
|
||||
{
|
||||
lStatus = SOCKETS_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
return lStatus;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
uint32_t SOCKETS_GetHostByName( const char * pcHostName )
|
||||
{
|
||||
return FreeRTOS_gethostbyname( pcHostName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int32_t SOCKETS_Recv( Socket_t xSocket,
|
||||
void * pvBuffer,
|
||||
size_t xBufferLength,
|
||||
uint32_t ulFlags )
|
||||
{
|
||||
int32_t lStatus = SOCKETS_SOCKET_ERROR;
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) xSocket; /*lint !e9087 cast used for portability. */
|
||||
|
||||
if( ( xSocket != SOCKETS_INVALID_SOCKET ) &&
|
||||
( pvBuffer != NULL ) )
|
||||
{
|
||||
pxContext->xRecvFlags = ( BaseType_t ) ulFlags;
|
||||
|
||||
/* Receive unencrypted. */
|
||||
lStatus = prvNetworkRecv( pxContext, pvBuffer, xBufferLength );
|
||||
}
|
||||
else
|
||||
{
|
||||
lStatus = SOCKETS_EINVAL;
|
||||
}
|
||||
|
||||
return lStatus;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int32_t SOCKETS_Send( Socket_t xSocket,
|
||||
const void * pvBuffer,
|
||||
size_t xDataLength,
|
||||
uint32_t ulFlags )
|
||||
{
|
||||
int32_t lStatus = SOCKETS_SOCKET_ERROR;
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) xSocket; /*lint !e9087 cast used for portability. */
|
||||
|
||||
if( ( xSocket != SOCKETS_INVALID_SOCKET ) &&
|
||||
( pvBuffer != NULL ) )
|
||||
{
|
||||
pxContext->xSendFlags = ( BaseType_t ) ulFlags;
|
||||
|
||||
/* Send unencrypted. */
|
||||
lStatus = prvNetworkSend( pxContext, pvBuffer, xDataLength );
|
||||
}
|
||||
else
|
||||
{
|
||||
lStatus = SOCKETS_EINVAL;
|
||||
}
|
||||
|
||||
return lStatus;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int32_t SOCKETS_SetSockOpt( Socket_t xSocket,
|
||||
int32_t lLevel,
|
||||
int32_t lOptionName,
|
||||
const void * pvOptionValue,
|
||||
size_t xOptionLength )
|
||||
{
|
||||
int32_t lStatus = SOCKETS_ERROR_NONE;
|
||||
TickType_t xTimeout;
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) xSocket; /*lint !e9087 cast used for portability. */
|
||||
|
||||
if( ( xSocket != SOCKETS_INVALID_SOCKET ) && ( xSocket != NULL ) )
|
||||
{
|
||||
switch( lOptionName )
|
||||
{
|
||||
case SOCKETS_SO_NONBLOCK:
|
||||
xTimeout = 0;
|
||||
|
||||
/* Non-blocking connect is not supported. Socket may be set to nonblocking
|
||||
* only after a connection is made. */
|
||||
if( pdTRUE == pxContext->xConnectAttempted )
|
||||
{
|
||||
lStatus = FreeRTOS_setsockopt( pxContext->xSocket,
|
||||
lLevel,
|
||||
SOCKETS_SO_RCVTIMEO,
|
||||
&xTimeout,
|
||||
sizeof( xTimeout ) );
|
||||
|
||||
if( lStatus == SOCKETS_ERROR_NONE )
|
||||
{
|
||||
lStatus = FreeRTOS_setsockopt( pxContext->xSocket,
|
||||
lLevel,
|
||||
SOCKETS_SO_SNDTIMEO,
|
||||
&xTimeout,
|
||||
sizeof( xTimeout ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lStatus = SOCKETS_EISCONN;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SOCKETS_SO_RCVTIMEO:
|
||||
case SOCKETS_SO_SNDTIMEO:
|
||||
/* Comply with Berkeley standard - a 0 timeout is wait forever. */
|
||||
xTimeout = *( ( const TickType_t * ) pvOptionValue ); /*lint !e9087 pvOptionValue passed should be of TickType_t */
|
||||
|
||||
if( xTimeout == 0U )
|
||||
{
|
||||
xTimeout = portMAX_DELAY;
|
||||
}
|
||||
|
||||
lStatus = FreeRTOS_setsockopt( pxContext->xSocket,
|
||||
lLevel,
|
||||
lOptionName,
|
||||
&xTimeout,
|
||||
xOptionLength );
|
||||
break;
|
||||
|
||||
default:
|
||||
lStatus = FreeRTOS_setsockopt( pxContext->xSocket,
|
||||
lLevel,
|
||||
lOptionName,
|
||||
pvOptionValue,
|
||||
xOptionLength );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lStatus = SOCKETS_EINVAL;
|
||||
}
|
||||
|
||||
return lStatus;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
int32_t SOCKETS_Shutdown( Socket_t xSocket,
|
||||
uint32_t ulHow )
|
||||
{
|
||||
int32_t lReturn;
|
||||
SSOCKETContextPtr_t pxContext = ( SSOCKETContextPtr_t ) xSocket; /*lint !e9087 cast used for portability. */
|
||||
|
||||
if( ( xSocket != SOCKETS_INVALID_SOCKET ) && ( xSocket != NULL ) )
|
||||
{
|
||||
lReturn = FreeRTOS_shutdown( pxContext->xSocket, ( BaseType_t ) ulHow );
|
||||
}
|
||||
else
|
||||
{
|
||||
lReturn = SOCKETS_EINVAL;
|
||||
}
|
||||
|
||||
return lReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
Socket_t SOCKETS_Socket( int32_t lDomain,
|
||||
int32_t lType,
|
||||
int32_t lProtocol )
|
||||
{
|
||||
SSOCKETContextPtr_t pxContext = NULL;
|
||||
Socket_t xSocket;
|
||||
|
||||
/* Ensure that only supported values are supplied. */
|
||||
configASSERT( lDomain == SOCKETS_AF_INET );
|
||||
configASSERT( lType == SOCKETS_SOCK_STREAM );
|
||||
configASSERT( lProtocol == SOCKETS_IPPROTO_TCP );
|
||||
|
||||
/* Create the wrapped socket. */
|
||||
xSocket = FreeRTOS_socket( lDomain, lType, lProtocol );
|
||||
|
||||
if( xSocket != FREERTOS_INVALID_SOCKET )
|
||||
{
|
||||
/* Allocate the internal context structure. */
|
||||
if( NULL == ( pxContext = pvPortMalloc( sizeof( SSOCKETContext_t ) ) ) )
|
||||
{
|
||||
/* Need to close socket. */
|
||||
( void ) FreeRTOS_closesocket( xSocket );
|
||||
pxContext = SOCKETS_INVALID_SOCKET;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset( pxContext, 0, sizeof( SSOCKETContext_t ) );
|
||||
pxContext->xSocket = xSocket;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pxContext = SOCKETS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
return pxContext;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t SOCKETS_Init( void )
|
||||
{
|
||||
/* Empty initialization for this port. */
|
||||
return pdPASS;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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_ */
|
||||
@@ -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_ */
|
||||
@@ -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_ */
|
||||
Reference in New Issue
Block a user