Commit Graph

35 Commits (000c005ceed37605a3c146459acdf605ec90919e)

Author SHA1 Message Date
Soren Ptak 6b513cb1a2
Use MbedTLS 3.5.1 and Add TLS 1.3 Support to WinSim Demos (#1135)
* Bump up to MBed-TLS V3.5.1, make changes to Visual Studio Projects to account for this.
* Update MBedTLS Transport files to call psa_crypto_init() if the MBEDTLS_PSA_CRYPTO_C is set.
* Add WIN32_LEAN_AND_MEAN to the corePKCS11_MQTT_Mutual_Auth_Windows_Simulator demo. Add in a check for MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET when making a TLS handshake.
* Change transport interface files from using void * to mbedtls_pk_context * instead per changes in the MbedTLS API.
* Changes to Fleet Provisioning Demo and Demo Setup to use ECDSA keys
* Remove non-32 bit configs from various VisualStudio Projects. Enforce all projects using WIN32_LEAN_AND_MEAN as well as winsock2.h
1 year ago
Tony Josi 10269777fa
Update TCP socket wrappers to use debug logging level from config files (#1091) 1 year ago
Soren Ptak 3a2f6646f0
Use CI-CD-Github-Actions for spelling and formatting, add in the bot formatting action, update the CI-CD workflow files. Fix incorrect spelling and formatting on files. (#1083)
* Use new version of CI-CD Actions,  checkout@v3 instead of checkout@v2 on all jobs
* Use cSpell spell check, and use ubuntu-20.04 for formatting check
* Add in bot formatting action
* Update freertos_demo.yml and freertos_plus_demo.yml files to increase github log readability
* Add in a Qemu demo onto the workflows.
1 year ago
Monika Singh 301ed5881b
Merging IPv6 demo changes to main (#1028)
* Add IPv6 Demo (#937)

* Add demo changes

* Update kernel and library paths

* Update main.c

* Run uncrustify

* Fix spell checker

* CI check file headers update

* Add IPv6/v4 UDP echo server with zero copy/non-zero copy versions

* Add VS proj file changes to include the UDP echo sample code

* readme update

---------

Co-authored-by: Tony Josi <tonyjosi@amazon.com>

* Update Backward Compatibility Flag (#954)

* Update Backward Compatibility Flag

* Update FreeRTOS_GetUDPPayloadBuffer_ByIPType

* Update FreeRTOS_IPStart to FreeRTOS_IPInit_Multi

* Update Application APIs

* Remove ipconfigCOMPATIBLE_WITH_SINGLE

* Update Static Lib files (#956)

* Update Static Lib files

* making vApplicationIPNetworkEventHook backward compatible in demos

* Update CI check file headers

---------

Co-authored-by: Tony Josi <tonyjosi@amazon.com>

* Add WinPCap NetworkInterface Changes (#958)

* Update winpcap network interface

* Run uncrustify

* Update function to include NetworkInterface_t parameters

* Adding compatibility for xApplicationDNSQueryHook with latest dev branch for old demos (#957)

* adding compatibility for xApplicationDNSQueryHook with latest dev branch

* adding tcp echo server source

* removing unused sub demos

* fix build issues (#969)

* Update demo to latest +TCP dev/IPv6_integration (#978)

* remove macro namings

* rename sin_addr to sin_address.ulIP_IPv4 for ipv6 demo

* replace in6addr_any with FreeRTOS_in6addr_any

* replace mainCREATE_UDP_ECHO_SERVER_TASK with mainCREATE_UDP_ECHO_TASKS_SINGLE

* handle removal of sin_addr macro to sin_address.ulIP_IPv4

* updating +TCP repo to latest dev/IPv6_integration

* minor update to more clear code

* more sin_addr to sin_address.ulIP_IPv4 replacements

* fix makefiles for qemu and posix demos

* review feedback changes

* Update FreeRTOS-Plus-TCP for RC2

* Change from PR (#994)

* Update FreeRTOS-Plus-TCP for RC2

* Update copyright

* Ignore WinPCap for files header check failure.

* Update checker

* Update manifest

* Point manifest to latest commit

* Fix Spell-checker

* Update doxygen

* Update xApplicationDHCPHook for backward compatibility  (#999)

* Update xApplicationDHCPHook for backward compatability

* Update IPv6

* Update VisualStudio Static Project files

* Update pxEndPoint error (#1002)

* Update IPv6 demo ReadMe (#1004)

* Update ReadMe

* Update setup requirement

* Update UDP demo info

* Update comment

* TCP demo changes post build separation (#1011)

* adding sin_family to dest adddr for FreeRTOS_sendto

* updating FreeRTOS_bind to input sin_family post build separation changes

* updating FreeRTOS_connect to input sin_family post build separation changes

* minor fix

* updating copyright year

* updating file headers

* updating +TCP submodule

* updating file headers

* updating file headers

* updating manifest file to have latest +TCP submodule hash

* Fix issue with posix demo while running with ipconfigIPv4_BACKWARD_COMPATIBLE enabled for +TCP stack (#1027)

* Update the submodule pointer to IPv6 main

* Update manifest with latest TCP commit

* Update file checker exception

* Ignore Visual studio project file from file header checker

---------

Co-authored-by: Tony Josi <tonyjosi@amazon.com>
2 years ago
chinglee-iot c040a8d7e3
Cellular transport return socket closed when remote disconnected (#922)
* Update the return value if socket is closed by remote
2 years ago
jasonpcarroll 6f7f9fd9ed [AUTO][RELEASE]: Bump file header version to "202212.00" 2 years ago
Paul Bartell b66a75936f mbedtls-pkcs11: Separate mbedtls rng pkcs11 callback into separate file 2 years ago
Paul Bartell 0ca1ec8861 Fix memory leak in transport_mbedtls_pkcs11.c 2 years ago
ActoryOu e85b49ad18
Add error handling on Socket_t in transport layer. (#887)
* Set tcpSocket to SOCKETS_INVALID_SOCKET when any error occurred in TLS_FreeRTOS_Connect.

* Initialize Socket_t to NULL.
2 years ago
jasonpcarroll b9f2248c5b [AUTO][RELEASE]: Bump file header version to "202211.00" 2 years ago
Soren Ptak 8424589ed1
FreeRTOS Windows Simulator Build Changes and LTS 2.0 Update (#872)
* Update mbedtls to version v3.2.1

* Adjust include paths for github workflow

* Update FreeRTOS+TCP to v3.1.0

* Add initial VS project files for Kernel, +TCP, and mbedtls

* winpcap: Consolidate to a single copy of WinPcap

* Downgrade library projects to VS 2019. Add heap_4 to kernel.

* Remove *.vcxproj.user files and add to gitignore

* Disable unwanted kernel config options

* Update FreeRTOS+TCP and Kernel include paths

* Update FreeRTOS+TCP Windows Minimal sln

* Remove .suo and .vcxproj.user files

* Update mbedtls transport implementations for mbedtls v3.2.1

* Fix typo in mbedtls_freertos_port.c

* Update vcxproj files for +TCP, Kernel, Mbedtls

* Fix typo in name WindowSimulator -> WindowsSimulator

* Add wpcap lib to FreeRTOS+TCP.vcxproj

* Update FreeRTOS+TCP Minimal Demo for Windows Simulator

* Mask MSVC string function warnings

Aad _CRT_SECURE_NO_WARNINGS preprocessor definition.

* Move projects to their own directories to make VisualStudio happy

* mbedtls_freertos_port.c: Fix formatting?

* Add coreHTTP, Logging libs. Adjust dependencies

* Disable FreeRTOS Kernel malloc failed hook

* Update coreHTTP Plaintext demo

* Rename / relocate transport interface implementations

* Remove old VS project files

* Remove extra core_http_config.h files

* Remove extra FreeRTOSConfig.h files

* Remove extra FreeRTOSIPConfig.h files

* Remove old mbedtls_config.h files

* Remove old FreeRTOSConfig and core_http_config files

* Update HTTP Mutual Auth Demo build files

* Fix transport_plaintext.h include name

* Update HTTP_Plaintext demo build files

* Update CoreHTTP_S3_Download VS project files

* Update HTTP_S3_Upload demo build files

* Update CoreHTTP_S3_Download_Multithreaded demo build files

* Add GithubActions builds for FreeRTOS+ CoreHTTP Demos

* Update S3DownloadHTTPExample.c to be compatible with mbedtls 3.x

* Update GithubActions FreeRTOS+ config file

* Combine core_pkcs11_config.h files into a single one

* Add corePKCS11 VS project file

* Update corePKCS11 WinSim demo project and build files

* Update corePKCS11 library to version 3.5.0

* Modifiying demos to build using static libraries

* Adding a header file

* Two more demos

* Update corePKCS11 demo code and auto-format

* Downgrade corePKCS11 library build file to v142 / VS 2019

* Speed up CI builds with selective submodule initialization

* Separate corePKCS11 demo into it's own job.

* Remove WIN32.vcxproj and WIN32.vcxproj.filters files

* Remove old configuration header files

Partially reverts 73829ced60

* Revert unwanted coreHTTP demo changes

* Changing include paths for demos

* Adding an include

* MQTT WoflSSL Demo update

* wolfSSL Demo changes

* Config changes for MQTT Demos

* Initial Device Defender demo update.

* Initial Device Shadow demo update.

* Update mbedtls_transport_pkcs11 for Mbedtls 3.x

* Update corePKCS11 MQTT Mutual Auth demo

* Add a default definition of SdkLog

* Update CorePKCS11 + MQTT Mutual Auth demo sln name

* Build all configs of coreHTTP demos

* Update coreSNTP Demo build files.

* Update coreSNTP Demo sln name

* Update FreeRTOS+TCP Posix demo

* Update FreeRTOS+TCP Qemu ARM MPS2 AN385 Demo

* Update FreeRTOS+TCP Demo Github Actions builds

* Update Fleet Provisioning WinSim Demo build files

* Remove mbedtls_pk_info_t references from mbedtls_pk_pkcs11.h

* Restore / update the FreeRTOS+TCP Minimal WinSim demo

* Initial Jobs demo update.

* Fix jobs demo build.

* Initial OTA over HTTP demo update.

* Initial OTA over MQTT demo update.

* Ota_Over_Mqtt_Demo build fix.

* OTA over MQTT demo fix.

* Update HTTP demo solution file name for CI.

* Update Github actions workflow to old HTTP demo names.

* Update coreSTNP demo to old solution name.

* Fix defender demo / fix mbedtls config to use threading alt.

* Add MBEDTLS_CONFIG_FILE definition to each config

* Fix config file name.

* MQTT Mutual auth fixes.

* Fix job demo.

* Device shadow demo fixes.

* Fix coreSNTP demo not setting alt threading functions for mbedtls.

* Enable Static allocation, Add default hooks for FreeRTOS Kernel and +TCP

* Add xPlatformIsNetworkUp platform function to FreeRTOS+TCP hooks

* Enable runtime statistics in the Windows Simualator Kernel config

* Revert "Fix coreSNTP demo not setting alt threading functions for mbedtls."

This reverts commit 9069707519.

* Revert mbedtls threading related config changes

* Add xPlatformIsNetworkUp function prototype

* Remove boileplate FreeRTOS kernel and +tcp hooks

* Refactor device defender demo for clarity

* Add wait loop calling xPlatformIsNetworkUp

* Add missing vPlatformInitLogging function

* Add vPlatformInitLogging and vLoggingPrintf defitions to logging headers

* Updating the FreeRTOS_Plus_CLI_with_Trace_Windows_Simulator

* Updating the FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator demo

* Updates to the FreeRTOS_Plus_WolfSSL_Windows_Simulator demo

* Fixing wrong include path

* Upating FreeRTOS_Plus_WolfSSL_FIPS_Ready_Windows_Simulator demo

* Update coreMQTT WinSim demos to print start and end condition.

* Modifiying repos updated as part of the CLI demo GitHub workflow

* Removing duplicate functions from the FreeRTOS_Plus_TCP_Minimal_Windows_Simulator demo

* Updated FreeRTOS_Plus_TCP_UDP_Mode_CLI_Windows_Simulator demo

* Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator Demo to call the static function that creates task

* Fix log message using unitialized string in MQTT Multitask demo.

* Fixing a broken extern function

* Fixing a typo extern function name

* Added a reference to coreHTTP

* Fixing a pre-processor issue in the OTA_Over_Http_Demo

* Updating the MQTT_Mutual_Auth_Demo_with_BG96 demo

* Updating the MQTT_Mutual_Auth_Demo_with_HL7802 demo

* Changes to the MQTT_Mutual_Auth_Demo_with_SARA_R4 demo

* Fix demos for CI.

* Adding the source path to the CBMC proofs for FreeRTOS+TCP

* Spell check fixes, adding words to lexicons

* Fixing a typo

* Add arg to skip prompt in setup script.

* Update paths of script to be relative to the file.

* Changing manifest.yml file to point to corePKCS11 3.5.0

* Added CI markers to cellular demos.

* Fix cellular demo flow.

* Fix celullar demos.

* Initial TCP sockets wrapper rework - will break things.

* First cellular demo fix for new sockets wrapper.

* Minor fix to cellular sockets wrapper.

* Fix mbedtls bio using FreeRTOS Plus TCP call.

* Clean up BG96 demo project files.

* Update HL7802 demo.

* Fix SARA R4 demo for new sockets wrapper.

* Fix Device Defender, Device Shadow, and Fleet PRovisioning.

* Fix Jobs demo.

* Fix OTA over HTTP demo.

* Fix OTA over MQTT demo.

* Fix HTTP mutual auth demo.

* Fix OTA over MQTT demo endianness.

* Fix OTA over HTTP demo endianness.

* Fix HTTP Plaintext demo.

* Fix HTTP S3 download demo.

* Fix plaintext transport

* Fix OTA demos.

* Fix OTA demos.

* Fix OTA HTTP demo.

* Fix HTTP S3 Download multithreaded demo.

* Fix HTTP S3 Upload demo

* Fix corePKCS11 Mutual Auth demo.

* Updating MQTT_Mutual_Auth

* Update pkcs11 setup script.

* Updating the MQTT_Basic_TLS Demo

* Organize PKCS11 demos project.

* Updating MQTT_Keep_Alive demo

* Clean up SNTP demo.

* Updated MQTT_Multitask demo

* Updated MQTT_Plain_Text

* Updating the MQTT_Serializer Demo

* Updating corePKCS11_MQTT_Mutual_Auth_Windows_Simulator

* Updating coreSNTP_Windows_Simulator

* Clean up demo projects.

* Add markers to PKCS11 mutual auth demo.

* Fix Fleet Provisioning demo script.

* Fix SNTP demo solution.

* Fix coreSNTP project files.

* Fix Fleet Provisiong script.

* Fix fleet provisioning script.

* Fix demo config template.

* Fleet provisioning demo markers.

* Updating MQTT_Mutual_Auth_wolfSSL demo and the transport_wolfSSL file

* Fixing FreeRTOS_Plus_TCP_Echo_POSIX

* Fixing CLI and Trace Demos

* Fixing TCP_ECHO_POSIX demo

* Adding a word to the lexicon

* Remove unneeded files.

* Update github workflows to use Ubuntu 20.04.

* Change OTA demo target names to RTOSDemo for OTAE2E tests.

* Fixing Headers

* Updating headers

* Two more headers

* Adding words to the lexicon

* Whitepsace

* Ignore mbedtls config file for header check.

* Removing FreeRTOS Header from the mbedtls_config_v3.2.1.h file

* Fix bug in lPKCS11PkMbedtlsCloseSessionAndFree. Add doxygen api docs.

* Update lexicon.txt

* Fix spelling

* Apply suggestions from code review

Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>

* Add return code comment for p11_ecdsa_ctx_init

* Rename WindowsSimulator folder to VisualStudio_StaticProjects.

* Remove references to coroutines

* Fix mbedtls_pk_pkcs11.c

* Update to LTS 2.0 submodule pointers (#880)

* Update submodule pointers to LTS 2.0

* Initial coreMQTT 2.1.1 update.

* Update AWS demos for coreMQTT 2.1.1

* Fix deprecated macro for coreMQTT demos.

* Fix keep alive demo.

* Fix plaintext demo.

* Fix MQTT wolfSSL demo.

* Fix MQTT PKCS11 demo.

* Remove duplicate functions.

* Fix Mutual auth demos for Cellular.

* Fix OTA demos.

* Fix header of plaintext demo config.

* Set writev to NULL for OTA demos.

* Fix mbedlts config for OTA demos.

* Fix spelling.

Co-authored-by: Jason Carroll <czjaso@amazon.com>

* Removing blank line

* Fix jobs demo race condition.

* Fix race condition from WinPCap network interface.

* Update lexicon.

Co-authored-by: Paul Bartell <pbartell@amazon.com>
Co-authored-by: Jason Carroll <czjaso@amazon.com>
Co-authored-by: Paul Bartell <paul.bartell@gmail.com>
Co-authored-by: jasonpcarroll <23126711+jasonpcarroll@users.noreply.github.com>
2 years ago
chinglee-iot 0fc242b7db
Update transport interface for compatibility (#844)
Update transport interface for compatibility

* Update the network transport that using socket wrapper to depend on socket wrapper only.
* AT command timeout should not be changed for cellular socket buffer access mode.
* mbedTLS config include using MBEDTLS_CONFIG_FILE macro.
* Remove strnlen usage in using_mbedtls_pkcs11.
2 years ago
ActoryOu 9b27a5de4e
Return error if invalid input detected in transport layer (Send/Recv) (#773)
* return error if invalid input detected in transport layer
3 years ago
johnrhen 43defa566c
Apply release changes to main branch (#759)
* Update History.txt and README.md for December release (#744)

* Update History.txt and README.md for release

* Bump mbedtls submodule to v2.28.0 (#745)

* Patch project files for mbedtls (#751)

* Apply group 1 patches

* Apply patches for group 2

* Update project files for mbedTLS new version

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

* Fix warnings in projects

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

* Fix warnings in HTTP_S3_Download demo

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>

* Update changelog and history for corePKCS11 update (#752)

* Update submodule pointer and manifest.yml for corePKCS11 (#754)

* Update readme and history.txt to show that Sigv4 is a newly added library (#756)

* Revert update to v143 of VS toolset (#757)

* [AUTO][RELEASE]: Bump file header version to "202112.00"

* Update file headers to satisfy core checks

Co-authored-by: Muneeb Ahmed <54290492+muneebahmed10@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: johnrhen <johnrhen@users.noreply.github.com>
3 years ago
johnrhen b1b3a0a3e9
Add variable PKCS11 label support to using_mbedtls_pkcs11 (#723)
The previous "using_mbedtls_pkcs11.c" implementation requires using the device key and device certificate stored under the labels "pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS" and "pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS".

This commit updates the NetworkCredentials to include fields for pClientCertLabel and pPrivateKeyLabel, so other labels can be used with PKCS11. This matches the behavior seen in the CSDK.

This commit also updates the "pkcs11_mqtt_mutual_auth_demo" to set the newly-added NetworkCredentials fields.
3 years ago
andysun2015 426ad44c05
Remove using_mbedtls folder and move its content to the parent folder (#717)
Move the contents of FreeRTOS/FreeRTOS-Plus/Source/Application-Protocols/network_transport/using_mbedtls/
to its parent folder i.e. FreeRTOS/FreeRTOS-Plus/Source/Application-Protocols/network_transport/.
This removes one unnecessary folder in the hierarchy.
3 years ago
aggarg ecd1a8f9f1 [AUTO][RELEASE]: Bump file header version to "202111.00" 3 years ago
andysun2015 a6dfca9829
Update file header and cellular lib commit (#704) 3 years ago
andysun2015 957fb26dbe
Add cellular library submodule path and demo (#695)
* [Cellular] Add cellulr lib submodule and demo app

* [Cellular] Fix memory violation in transport layer and add using LoggingPrintf

* Update FreeRTOS Cellular Interface

* Change the mbedtls usage in FreeRTOS-Plus

* [Cellular] Fix missing spell

* [Cellular] Add manifest.yml

* Fix missing spell

* Update manifest.yml

* [Cellular] Add integration test

* Modify the demo log level to LOG_INFO

* Update cellular interface

* The modification of the folder structure for cellular library

* Rename the naming of demo

* Adjust the location of using_mbedtls and socket_wrapper

* Adjust project setting for relocating using_mbedtls and socket_wrapper

* Turn off PSM mode

* Add start marker for CI validation.

* The modification for mbedtls platform send/recv function for cellular

* Change the project file due to the changes of mbedtls platform send/recv function for cellular

* Fix missing newline and remove unused file

* Add missing configuration.

* Make cellular and freertos tcp plus use the same transport implementation

* Add comment for the macro MBEDTLS_SSL_SEND and MBEDTLS_SSL_RECV

* Make changes from the github comment.
3 years ago
Gaurav-Aggarwal-AWS 226c987b1a
Remove non-ASCII characters (#701)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
3 years ago
tianmc1 176f1cae02 [AUTO][RELEASE]: Bump file header version to "202107.00" 4 years ago
Oscar Michael Abrina 63d38b846e
Remove redundant mbedtls error sources (#654)
Since `mbedtls_error.c` is already part of the mbedTLS submodule, the duplicate files are removed from this repository.

Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
4 years ago
Archit Aggarwal 971a6e1d22
Merge FreeRTOS 202104.00 to main (#585) 4 years ago
TakayukiMatsuo 1e2f99a11b
Add feature to set credentials using buffer in MQTT_Mutual_Auth_wolfSSL demo (#522)
* Add feature to set credentials using buffer
* Change instructions for giving credential data via buffer
4 years ago
Carl Lundin a78cb45d12
Minor changes to wolfSSL MQTT demo files (#493)
* Clean up demo config for wolfSSL mutual auth. 
* Add comment about picking the correct ROOT CA.
* uncrustify using_wolfSSL.c and some other code style changes.
* Apply suggestions from code review

Co-authored-by: Archit Aggarwal <architag@amazon.com>
4 years ago
TakayukiMatsuo dfdf2ddf1f
Add MQTT_Mutual_Auth_wolfSSL demo (#464)
Add a demo that shows MQTT over TLS mutual authentication connection and communication with a broken when using wolfSSL as the TLS library.
4 years ago
Marc-Antoine Lalonde 52c9756f21
Call taskYIELD after calling FreeRTOS_send in Plaintext_FreeRTOS_send (#491)
FreeRTOS_send adds the packet to be sent to the IP task's queue for
later processing. The packet is sent later by the IP task. When
FreeRTOS is used in collaborative mode (i.e. configUSE_PREEMPTION is 0),
the Plaintext_FreeRTOS_send function returns without actually sending
the packet as the IP task never gets a chance to run.

The fact that Plaintext_FreeRTOS_send returns without actually sending
the packet causes an issue in the MQTT_Connect which expects the CONNECT
packet to be actually sent and waits for CONNACK.

This commit adds a taskYIELD call after calling FreeRTOS_send to ensure
that the IP task gets a chance to run and send the packet before the
Plaintext_FreeRTOS_send function returns.
4 years ago
Joseph Julicher da9b9a800d [AUTO][RELEASE]: Bump file header version to "202012.00" 4 years ago
Oscar Michael Abrina f23752164b
Map errors from FreeRTOS+TCP to mbedTLS and make read non-blocking when requesting start of frame (#452)
From the FreeRTOS documentation, pdFREERTOS_ERRNO_ENOSPC means that timeout occurred before any data could be sent or received.
- In the plaintext transport-interface implementation, we would directly return `-pdFREERTOS_ERRNO_ENOSPC`. However, an error like this can occur when the TCP buffer is full, so this ought to be retriable. Libraries that consume the transport interface interpret a return value of 0 to mean that send/recv can be invoked again to get the data. As such, we should appropriately set the return value as 0 when the status is `-pdFREERTOS_ERRNO_ENOSPC`.
- In the mbedTLS port, we would directly return whatever `FreeRTOS_send` or `FreeRTOS_recv` returns. However, sometimes, the return value can be an error. In such cases, we ought to map an error from FreeRTOS+TCP to an equivalent error in mbedTLS. In the case of `-pdFREERTOS_ERRNO_ENOSPC`, we map that to `MBEDTLS_ERR_SSL_TIMEOUT`. When the mbedTLS transport-interface send/recv wrapper sees that value, it appropriately returns 0, so that the library can retry the send/recv. I've verified that when the mbedTLS port returns an error, that same error is returned by `mbedtls_ssl_write` & `mbedtls_ssl_read`.
- The TCP socket may have a receive block time.  If bytesToRecv is greater than 1 then a frame is likely already part way through reception and blocking to wait for the desired number of bytes to be available is the
most efficient thing to do.  If bytesToRecv is 1 then this may be a speculative call to read to find the start of a new frame, in which case blocking is not desirable as it could block an entire protocol agent task for the duration of the read block time and therefore negatively impact performance.  So if bytesToRecv is 1 then don't call recv unless it is known that bytes are already available.

Co-authored-by: abhidixi11 <44424462+abhidixi11@users.noreply.github.com>
Co-authored-by: RichardBarry <3073890+RichardBarry@users.noreply.github.com>
4 years ago
Oscar Michael Abrina 1c2c671e7a
Update comments about NetworkContext definition (#461)
Small change that simply specifies why the NetworkContext must be defined by each compilation unit along with details on how to include it to your project.

Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
4 years ago
Carl Lundin 492ac6edb2
Move corePKCS11 forward and update to latest core_pkcs11.h (#441)
* Move corePKCS11 forward.
* Update licenses.
* strip NULL terminator.
* Add threading_alt.h
* Use github link.

Co-authored-by: Cobus van Eeden <35851496+cobusve@users.noreply.github.com>
4 years ago
Oscar Michael Abrina 73b0d1b259
Support multiple transports in the same compilation unit (#434)
By removing the definition of the NetworkContext struct in the header file, we allow the application to define it. This allows an application writer to use multiple transports in the same compilation unit. That way, multiple .c files do not have to be created for each transport.
4 years ago
Archit Aggarwal 6debf6a2c0
Add #ifndef guards for SdkLog definition to fix conflicting definitions (#403) 4 years ago
Archit Aggarwal 21878bd619
Allow overriding default definitions of logging macros (#384)
* Update logging_stack.h file to avoid use of __FUNCTION__ macro

* Revert to use __FUNCTION__ instead of __FILE__

* Fix comment about metadata format

* Fix incorrect mapping of SdkLog function

* Fix typo causing LOG_METADATA_ARGS to be undefined

* Fix another bug with SdkLog macro definition

* Fix formatting

* Move mapping of SdkLog to vLoggingPrintf from logging_stack to config files

* Remove dependency of LIBRARY_LOG_NAME on LIBRARY_METADATA_* macros

* Minor improvements

Co-authored-by: Gary Wicker <14828980+gkwicker@users.noreply.github.com>
Co-authored-by: RichardBarry <3073890+RichardBarry@users.noreply.github.com>
4 years ago
Oscar Michael Abrina 01e59a036c
Restructure platform directory (#382)
This updates the platform and logging directory and moves it to the following places:
FreeRTOS\FreeRTOS-Plus\Source\Utilities
FreeRTOS\FreeRTOS-Plus\Source\Application-Protocols\network_transport\freertos_plus_tcp

Project files are updated to follow suite. All updated demos are tested to work as expected.
4 years ago