diff --git a/examples/CK_RX65N_CCRX/CKRX65N_RYZ014A_RYZ024A.PNG b/examples/CK_RX65N_CCRX/CKRX65N_RYZ014A_RYZ024A.PNG new file mode 100644 index 00000000..6215cb03 Binary files /dev/null and b/examples/CK_RX65N_CCRX/CKRX65N_RYZ014A_RYZ024A.PNG differ diff --git a/examples/CK_RX65N_CCRX/README.md b/examples/CK_RX65N_CCRX/README.md index d6c417a5..e4e149e7 100644 --- a/examples/CK_RX65N_CCRX/README.md +++ b/examples/CK_RX65N_CCRX/README.md @@ -5,22 +5,26 @@ An adapter is the device or software used to connect the application using the E An adapter can be a cellular modem, a WiFi adapter, an Ethernet adapter, a WinSock software layer, a BSD software layer or other type of device or software. The EWF API is described in the Doxygen documentation generated out of the common code. The source files of the EWF are located in the \src directory at the root of this repository. -The current set of examples use the CK-RX65N board evaluation board and a ryz014a modem. +The current set of examples use the CK-RX65N board evaluation board and a ryz014a/ryz024a modem. ## Prerequisites + - Get the evaluation board [CK-RX65N](https://www.renesas.com/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/ck-rx65n-cloud-kit-based-rx65n-mcu-group). - A PC running [Renesas e2studio IDE](https://www.renesas.com/software-tool/e-studio). - Introduce compiler [cc-rx](https://www.renesas.com/software-tool/cc-compiler-package-rx-family) 3.0.5 or later. +- Introduce [RDP](https://www.renesas.com/software-tool/rx-driver-package) v1.37 or later. - If you don't have an Azure subscription, [create one for free](https://azure.microsoft.com/free/) before you begin. - Internet connectivity for your PC. +- Place it directly under the cloned project drive to shorten the path. Also shorten the project name (e.g c:\embedded-wireless-flamework -> c:\ewf-xxxx) ## Prepare Azure Resources Follow steps in [README_NETX_AZURE.md](README_NETX_AZURE.md) to create Azure resources that will be used to run the examples in the next steps of this document. -# Getting started - RYZ014A +# Getting started - RYZ014A/RYZ024A To get started with the examples, please follow these steps: -1. Acquire the necessary hardware and software: the Evaluation Kit CK-RX65N board, a Renesas RYZ014A PMOD, e2-studio with latest FIT modules, openssl, J-Link RTT viewer, Azure IoT Explorer. -2. Connect to RYZ014A PMOD to CK-RX65N board on PMOD2 connector. Connect Host PC via USB cable to USB Debug pin (J14) and another USB cable to USB-Serial pin (J20). Also connect micro USB cable to RYZ014A micro USB pin. +1. Acquire the necessary hardware and software: the Evaluation Kit CK-RX65N board, a Renesas RYZ014A/RYZ024A PMOD, e2-studio with latest FIT modules, openssl, J-Link RTT viewer, Azure IoT Explorer. +2. Connect to RYZ014A PMOD to CK-RX65N board on PMOD1 connector. Connect Host PC via USB cable to USB Debug pin (J14) and another USB cable to USB-Serial pin (J20). Also connect micro USB cable to RYZ014A/RYZ024A micro USB pin. +![Connection diagram of CK-RX65N and RYZ014A/RYZ024A](CKRX65N_RYZ014A_RYZ024A.PNG) 3. Review and edit as necessary the files ewf.config.h and ewf_example.config.h in the different examples. Edit these files to match your configuration. Specially edit the variables EWF_CONFIG_SIM_PIN, EWF_CONFIG_IOT_HUB_HOSTNAME, EWF_CONFIG_IOT_HUB_DEVICEID. 4. Start e2 studio and create a workspace in \examples\CK_RX65N_CCRX cloud kit, import all the ryz014a examples into the workspace and build all examples. 5. Open Terminal at com port connection from the board and set it to 115200 8N1. @@ -69,7 +73,7 @@ Device posistioning service (ENABLE_DPS_SAMPLE) part of the examples is not test # Examples using Azure RTOS NetX Duo PPP with EWF (Modem in Data mode) 1. Acquire the necessary hardware and software: the Cloud Kit CK-RX65N, a Renesas RYZ024A PMOD, e2-studio. -2. Connect to RYZ024A PMOD to CK-RX65N board on PMOD2 connector. Connect Host PC via USB cable to USB +2. Connect to RYZ024A PMOD to CK-RX65N board on PMOD1 connector. Connect Host PC via USB cable to USB Debug pin (J14) and another USB cable to USB-Serial pin (J20). Also connect micro USB cable to RYZ024A micro USB pin. 3. Open the ewf_netx_duo_ppp_ryz024a project in e2studio and edit the ewf_example.config.h to update EWF_CONFIG_SIM_PIN and EWF_CONFIG_SIM_APN. diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.cproject b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.cproject index 32ea97f0..a6e1eca3 100644 --- a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.cproject +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.cproject @@ -1621,49 +1621,15 @@ - - - - - - - - - - - - - - + - - - - - + + - - - - - - - - - - - - - - - - - - diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.project b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.project index 481ab030..2911c194 100644 --- a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.project +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/.project @@ -7,7 +7,6 @@ com.renesas.smc.ui.pgsupport.SCContentBuilder - @@ -41,6 +40,306 @@ PARENT-3-PROJECT_LOC/src + + + 1677587651444 + ewf + 14 + + org.eclipse.ui.ide.notFilterMatcher + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_gnss.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_http.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_types.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_ntp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_internet.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_nvm.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_urc.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_ids.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_message.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_tokenizer.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf.h + + + + + SMC_GENERATED_LOC diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.rcpc b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.rcpc index 91cd6efc..39d15c26 100644 --- a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.rcpc +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.rcpc @@ -22,8 +22,6 @@ ..\..\..\src\ewf_adapter_api_http.h ..\..\..\src\ewf_adapter_api_info.c ..\..\..\src\ewf_adapter_api_info.h - ..\..\..\src\ewf_adapter_api_lora.c - ..\..\..\src\ewf_adapter_api_lora.h ..\..\..\src\ewf_adapter_api_modem.c ..\..\..\src\ewf_adapter_api_modem.h ..\..\..\src\ewf_adapter_api_modem_general.c @@ -50,50 +48,8 @@ ..\..\..\src\ewf_adapter_api_tls_basic.h ..\..\..\src\ewf_adapter_api_udp.c ..\..\..\src\ewf_adapter_api_udp.h - ..\..\..\src\ewf_adapter_api_wifi_ap.c - ..\..\..\src\ewf_adapter_api_wifi_ap.h ..\..\..\src\ewf_adapter_api_wifi_station.c ..\..\..\src\ewf_adapter_api_wifi_station.h - ..\..\..\src\ewf_adapter_bsd_sockets.c - ..\..\..\src\ewf_adapter_bsd_sockets.h - ..\..\..\src\ewf_adapter_espressif_common.c - ..\..\..\src\ewf_adapter_espressif_common.h - ..\..\..\src\ewf_adapter_espressif_common_control.c - ..\..\..\src\ewf_adapter_espressif_common_info.c - ..\..\..\src\ewf_adapter_espressif_common_internet.c - ..\..\..\src\ewf_adapter_espressif_common_urc.c - ..\..\..\src\ewf_adapter_espressif_common_wifi_station.c - ..\..\..\src\ewf_adapter_espressif_esp8266.c - ..\..\..\src\ewf_adapter_espressif_esp8266.h - ..\..\..\src\ewf_adapter_espressif_esp8285.c - ..\..\..\src\ewf_adapter_espressif_esp8285.h - ..\..\..\src\ewf_adapter_espressif_wroom_02.c - ..\..\..\src\ewf_adapter_espressif_wroom_02.h - ..\..\..\src\ewf_adapter_mxchip_common.c - ..\..\..\src\ewf_adapter_mxchip_common.h - ..\..\..\src\ewf_adapter_mxchip_common_control.c - ..\..\..\src\ewf_adapter_mxchip_common_info.c - ..\..\..\src\ewf_adapter_mxchip_common_internet.c - ..\..\..\src\ewf_adapter_mxchip_common_tokenizer.c - ..\..\..\src\ewf_adapter_mxchip_common_urc.c - ..\..\..\src\ewf_adapter_mxchip_common_wifi_station.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.h - ..\..\..\src\ewf_adapter_quectel_bg95.c - ..\..\..\src\ewf_adapter_quectel_bg95.h - ..\..\..\src\ewf_adapter_quectel_bg96.c - ..\..\..\src\ewf_adapter_quectel_bg96.h - ..\..\..\src\ewf_adapter_quectel_common.c - ..\..\..\src\ewf_adapter_quectel_common.h - ..\..\..\src\ewf_adapter_quectel_common_context.c - ..\..\..\src\ewf_adapter_quectel_common_control.c - ..\..\..\src\ewf_adapter_quectel_common_info.c - ..\..\..\src\ewf_adapter_quectel_common_internet.c - ..\..\..\src\ewf_adapter_quectel_common_mqtt_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tls_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tokenizer.c - ..\..\..\src\ewf_adapter_quectel_common_ufs.c - ..\..\..\src\ewf_adapter_quectel_common_urc.c ..\..\..\src\ewf_adapter_renesas_common.c ..\..\..\src\ewf_adapter_renesas_common.h ..\..\..\src\ewf_adapter_renesas_common_control.c @@ -107,120 +63,26 @@ ..\..\..\src\ewf_adapter_renesas_ryz014.h ..\..\..\src\ewf_adapter_renesas_ryz024a.c ..\..\..\src\ewf_adapter_renesas_ryz024a.h - ..\..\..\src\ewf_adapter_seeed_lora_e5.c - ..\..\..\src\ewf_adapter_seeed_lora_e5.h ..\..\..\src\ewf_adapter_sequans.c ..\..\..\src\ewf_adapter_sequans.h - ..\..\..\src\ewf_adapter_simcom_common.c - ..\..\..\src\ewf_adapter_simcom_common.h - ..\..\..\src\ewf_adapter_simcom_common_control.c - ..\..\..\src\ewf_adapter_simcom_common_info.c - ..\..\..\src\ewf_adapter_simcom_common_urc.c - ..\..\..\src\ewf_adapter_simcom_sim7000.c - ..\..\..\src\ewf_adapter_simcom_sim7000.h - ..\..\..\src\ewf_adapter_simcom_sim868.c - ..\..\..\src\ewf_adapter_simcom_sim868.h - ..\..\..\src\ewf_adapter_simcom_sim900.c - ..\..\..\src\ewf_adapter_simcom_sim900.h - ..\..\..\src\ewf_adapter_thales_common.c - ..\..\..\src\ewf_adapter_thales_common.h - ..\..\..\src\ewf_adapter_thales_common_context.c - ..\..\..\src\ewf_adapter_thales_common_control.c - ..\..\..\src\ewf_adapter_thales_common_ffs.c - ..\..\..\src\ewf_adapter_thales_common_info.c - ..\..\..\src\ewf_adapter_thales_common_internet.c - ..\..\..\src\ewf_adapter_thales_common_tokenizer.c - ..\..\..\src\ewf_adapter_thales_common_urc.c - ..\..\..\src\ewf_adapter_thales_exs82_w.c - ..\..\..\src\ewf_adapter_thales_exs82_w.h - ..\..\..\src\ewf_adapter_winsock2.c - ..\..\..\src\ewf_adapter_winsock2.h ..\..\..\src\ewf_allocator.c ..\..\..\src\ewf_allocator.h - ..\..\..\src\ewf_allocator_c_heap.c - ..\..\..\src\ewf_allocator_c_heap.h - ..\..\..\src\ewf_allocator_memory_pool.c - ..\..\..\src\ewf_allocator_memory_pool.h - ..\..\..\src\ewf_allocator_netx.c - ..\..\..\src\ewf_allocator_netx.h ..\..\..\src\ewf_allocator_threadx.c ..\..\..\src\ewf_allocator_threadx.h ..\..\..\src\ewf_ids.h ..\..\..\src\ewf_interface.c ..\..\..\src\ewf_interface.h - ..\..\..\src\ewf_interface_linux_serial.c - ..\..\..\src\ewf_interface_lpc_uart.c - ..\..\..\src\ewf_interface_lpc_uart.h - ..\..\..\src\ewf_interface_microchip_pic_uart.c - ..\..\..\src\ewf_interface_microchip_pic_uart.h - ..\..\..\src\ewf_interface_microchip_sam_uart.c - ..\..\..\src\ewf_interface_microchip_sam_uart.h - ..\..\..\src\ewf_interface_ra_uart.c - ..\..\..\src\ewf_interface_ra_uart.h ..\..\..\src\ewf_interface_rx_uart.c ..\..\..\src\ewf_interface_rx_uart.h - ..\..\..\src\ewf_interface_stm32_uart.c - ..\..\..\src\ewf_interface_stm32_uart.h - ..\..\..\src\ewf_interface_win32_com.c - ..\..\..\src\ewf_interface_win32_com.h ..\..\..\src\ewf_lib.c ..\..\..\src\ewf_lib.h ..\..\..\src\ewf_message.h ..\..\..\src\ewf_middleware_netxduo.c ..\..\..\src\ewf_middleware_netxduo.h - ..\..\..\src\ewf_netxduo_ppp.c - ..\..\..\src\ewf_netxduo_ppp.h ..\..\..\src\ewf_platform.h - ..\..\..\src\ewf_platform_bare_metal.c - ..\..\..\src\ewf_platform_bare_metal.h - ..\..\..\src\ewf_platform_freertos.c - ..\..\..\src\ewf_platform_freertos.h - ..\..\..\src\ewf_platform_pthread.c - ..\..\..\src\ewf_platform_pthread.h ..\..\..\src\ewf_platform_threadx.c ..\..\..\src\ewf_platform_threadx.h - ..\..\..\src\ewf_platform_win32.c - ..\..\..\src\ewf_platform_win32.h ..\..\..\src\ewf_tokenizer.h - - ..\..\..\src\examples\ewf_example_azure_iot_pnp_provisioning.c - ..\..\..\src\examples\ewf_example_azure_iot_provisioning.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg95.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg96.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz014.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz024a.c - ..\..\..\src\examples\ewf_example_certs_basic_winsock2.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.h - ..\..\..\src\examples\ewf_example_netx_duo_test.c - ..\..\..\src\examples\ewf_example_netx_duo_test.h - ..\..\..\src\examples\ewf_example_telemetry.c - ..\..\..\src\examples\ewf_example_telemetry_basic.c - - - ..\..\..\src\test\ewf_adapter_bsd_sockets_test.c - ..\..\..\src\test\ewf_adapter_espressif_common_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8266_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8285_test.c - ..\..\..\src\test\ewf_adapter_espressif_wroom_02_test.c - ..\..\..\src\test\ewf_adapter_mxchip_common_test.c - ..\..\..\src\test\ewf_adapter_mxchip_emw3080b_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg95_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg96_test.c - ..\..\..\src\test\ewf_adapter_quectel_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz014_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz024a_test.c - ..\..\..\src\test\ewf_adapter_simcom_common_test.c - ..\..\..\src\test\ewf_adapter_simcom_sim7000_test.c - ..\..\..\src\test\ewf_adapter_test.c - ..\..\..\src\test\ewf_adapter_test.h - ..\..\..\src\test\ewf_adapter_thales_common_test.c - ..\..\..\src\test\ewf_adapter_thales_exs82_w_test.c - ..\..\..\src\test\ewf_adapter_winsock2_test.c - @@ -461,6 +323,8 @@ src\demo_printf.c src\demo_printf.h src\ewf.config.h + src\ewf_cellular_config.h + src\ewf_cellular_private.h src\ewf_example.config.h src\hardware_setup.c src\hardware_setup.h @@ -634,421 +498,150 @@ - - - - trash\2023-02-13-15-54-13\src\rtos_config\azurertos_object_init.c - trash\2023-02-13-15-54-13\src\rtos_config\azurertos_object_init.h - - - - trash\2023-02-13-15-54-13\src\smc_gen\general\r_cg_hardware_setup.c - trash\2023-02-13-15-54-13\src\smc_gen\general\r_cg_macrodriver.h - trash\2023-02-13-15-54-13\src\smc_gen\general\r_cg_userdefine.h - trash\2023-02-13-15-54-13\src\smc_gen\general\r_smc_cgc.c - trash\2023-02-13-15-54-13\src\smc_gen\general\r_smc_cgc.h - trash\2023-02-13-15-54-13\src\smc_gen\general\r_smc_cgc_user.c - trash\2023-02-13-15-54-13\src\smc_gen\general\r_smc_entry.h - trash\2023-02-13-15-54-13\src\smc_gen\general\r_smc_interrupt.c - trash\2023-02-13-15-54-13\src\smc_gen\general\r_smc_interrupt.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\platform.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\readme.txt - - - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_config_reference.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_interrupt_config_reference.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\board\user\r_bsp.h - - - - - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\dbsct.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\fsp_common_api.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\lowlvl.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\lowlvl.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\lowsrc.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\lowsrc.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\mcu_locks.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_common.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_common.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_cpu.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_locking.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_fsp_error.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_rtos.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_rx_compiler.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\r_typedefs.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\resetprg.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\sbrk.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\all\sbrk.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_info.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_locks.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts_private.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_cpu.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_locking.h - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.c - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_bsp\mcu\rx65n\register_access\ccrx\iodefine.h - - - - - - - trash\2023-02-13-15-54-13\src\smc_gen\r_byteq\r_byteq_if.h - trash\2023-02-13-15-54-13\src\smc_gen\r_byteq\readme.txt - - trash\2023-02-13-15-54-13\src\smc_gen\r_byteq\src\r_byteq.c - trash\2023-02-13-15-54-13\src\smc_gen\r_byteq\src\r_byteq_private.h - - - - trash\2023-02-13-15-54-13\src\smc_gen\r_cmt_rx\r_cmt_rx_if.h - trash\2023-02-13-15-54-13\src\smc_gen\r_cmt_rx\readme.txt - - trash\2023-02-13-15-54-13\src\smc_gen\r_cmt_rx\src\r_cmt_rx.c - - - - trash\2023-02-13-15-54-13\src\smc_gen\r_config\r_bsp_config.h - trash\2023-02-13-15-54-13\src\smc_gen\r_config\r_bsp_config_readme.txt - trash\2023-02-13-15-54-13\src\smc_gen\r_config\r_bsp_interrupt_config.h - trash\2023-02-13-15-54-13\src\smc_gen\r_config\r_byteq_config.h - trash\2023-02-13-15-54-13\src\smc_gen\r_config\r_cmt_rx_config.h - trash\2023-02-13-15-54-13\src\smc_gen\r_config\r_sci_rx_config.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_pincfg\Pin.c - trash\2023-02-13-15-54-13\src\smc_gen\r_pincfg\Pin.h - trash\2023-02-13-15-54-13\src\smc_gen\r_pincfg\r_pinset.h - trash\2023-02-13-15-54-13\src\smc_gen\r_pincfg\r_sci_rx_pinset.c - trash\2023-02-13-15-54-13\src\smc_gen\r_pincfg\r_sci_rx_pinset.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\r_sci_rx_if.h - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\readme.txt - - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx.c - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.c - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.h - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.c - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.h - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx_platform.h - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\r_sci_rx_private.h - - - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n.c - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_data.c - trash\2023-02-13-15-54-13\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_private.h - - - - - - - - - - - trash\2023-02-13-16-01-26\src\rtos_config\azurertos_object_init.c - trash\2023-02-13-16-01-26\src\rtos_config\azurertos_object_init.h - - - - trash\2023-02-13-16-01-26\src\smc_gen\general\r_cg_hardware_setup.c - trash\2023-02-13-16-01-26\src\smc_gen\general\r_cg_macrodriver.h - trash\2023-02-13-16-01-26\src\smc_gen\general\r_cg_userdefine.h - trash\2023-02-13-16-01-26\src\smc_gen\general\r_smc_cgc.c - trash\2023-02-13-16-01-26\src\smc_gen\general\r_smc_cgc.h - trash\2023-02-13-16-01-26\src\smc_gen\general\r_smc_cgc_user.c - trash\2023-02-13-16-01-26\src\smc_gen\general\r_smc_entry.h - trash\2023-02-13-16-01-26\src\smc_gen\general\r_smc_interrupt.c - trash\2023-02-13-16-01-26\src\smc_gen\general\r_smc_interrupt.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\platform.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\readme.txt - - - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_config_reference.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_interrupt_config_reference.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\board\user\r_bsp.h - - - - - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\dbsct.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\fsp_common_api.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\lowlvl.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\lowlvl.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\lowsrc.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\lowsrc.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\mcu_locks.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_common.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_common.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_cpu.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_locking.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_fsp_error.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_rtos.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_rx_compiler.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\r_typedefs.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\resetprg.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\sbrk.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\all\sbrk.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_info.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_locks.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts_private.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_cpu.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_locking.h - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.c - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_bsp\mcu\rx65n\register_access\ccrx\iodefine.h - - - - - - - trash\2023-02-13-16-01-26\src\smc_gen\r_byteq\r_byteq_if.h - trash\2023-02-13-16-01-26\src\smc_gen\r_byteq\readme.txt - - trash\2023-02-13-16-01-26\src\smc_gen\r_byteq\src\r_byteq.c - trash\2023-02-13-16-01-26\src\smc_gen\r_byteq\src\r_byteq_private.h - - - - trash\2023-02-13-16-01-26\src\smc_gen\r_cmt_rx\r_cmt_rx_if.h - trash\2023-02-13-16-01-26\src\smc_gen\r_cmt_rx\readme.txt - - trash\2023-02-13-16-01-26\src\smc_gen\r_cmt_rx\src\r_cmt_rx.c - - - - trash\2023-02-13-16-01-26\src\smc_gen\r_config\r_bsp_config.h - trash\2023-02-13-16-01-26\src\smc_gen\r_config\r_bsp_config_readme.txt - trash\2023-02-13-16-01-26\src\smc_gen\r_config\r_bsp_interrupt_config.h - trash\2023-02-13-16-01-26\src\smc_gen\r_config\r_byteq_config.h - trash\2023-02-13-16-01-26\src\smc_gen\r_config\r_cmt_rx_config.h - trash\2023-02-13-16-01-26\src\smc_gen\r_config\r_sci_rx_config.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_pincfg\Pin.c - trash\2023-02-13-16-01-26\src\smc_gen\r_pincfg\Pin.h - trash\2023-02-13-16-01-26\src\smc_gen\r_pincfg\r_pinset.h - trash\2023-02-13-16-01-26\src\smc_gen\r_pincfg\r_sci_rx_pinset.c - trash\2023-02-13-16-01-26\src\smc_gen\r_pincfg\r_sci_rx_pinset.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\r_sci_rx_if.h - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\readme.txt - - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx.c - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.c - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.h - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.c - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.h - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx_platform.h - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\r_sci_rx_private.h - - - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n.c - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_data.c - trash\2023-02-13-16-01-26\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_private.h - - - - + + + + trash\2023-03-10-13-56-08\libs\threadx\tx_user.h - + - trash\2023-02-13-21-21-22\libs\threadx\tx_user.h + trash\2023-03-10-14-05-53\libs\threadx\tx_user.h - trash\2023-02-13-21-21-22\src\rtos_config\azurertos_object_init.c - trash\2023-02-13-21-21-22\src\rtos_config\azurertos_object_init.h + trash\2023-03-10-14-05-53\src\rtos_config\azurertos_object_init.c + trash\2023-03-10-14-05-53\src\rtos_config\azurertos_object_init.h - trash\2023-02-13-21-21-22\src\smc_gen\general\r_cg_hardware_setup.c - trash\2023-02-13-21-21-22\src\smc_gen\general\r_cg_macrodriver.h - trash\2023-02-13-21-21-22\src\smc_gen\general\r_cg_userdefine.h - trash\2023-02-13-21-21-22\src\smc_gen\general\r_smc_cgc.c - trash\2023-02-13-21-21-22\src\smc_gen\general\r_smc_cgc.h - trash\2023-02-13-21-21-22\src\smc_gen\general\r_smc_cgc_user.c - trash\2023-02-13-21-21-22\src\smc_gen\general\r_smc_entry.h - trash\2023-02-13-21-21-22\src\smc_gen\general\r_smc_interrupt.c - trash\2023-02-13-21-21-22\src\smc_gen\general\r_smc_interrupt.h + trash\2023-03-10-14-05-53\src\smc_gen\general\r_cg_hardware_setup.c + trash\2023-03-10-14-05-53\src\smc_gen\general\r_cg_macrodriver.h + trash\2023-03-10-14-05-53\src\smc_gen\general\r_cg_userdefine.h + trash\2023-03-10-14-05-53\src\smc_gen\general\r_smc_cgc.c + trash\2023-03-10-14-05-53\src\smc_gen\general\r_smc_cgc.h + trash\2023-03-10-14-05-53\src\smc_gen\general\r_smc_cgc_user.c + trash\2023-03-10-14-05-53\src\smc_gen\general\r_smc_entry.h + trash\2023-03-10-14-05-53\src\smc_gen\general\r_smc_interrupt.c + trash\2023-03-10-14-05-53\src\smc_gen\general\r_smc_interrupt.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\platform.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\readme.txt + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\platform.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\readme.txt - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_config_reference.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_interrupt_config_reference.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\board\generic_rx65n\hwsetup.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_config_reference.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\board\generic_rx65n\r_bsp_interrupt_config_reference.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\board\user\r_bsp.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\board\user\r_bsp.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\dbsct.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\fsp_common_api.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\lowlvl.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\lowlvl.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\lowsrc.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\lowsrc.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\mcu_locks.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_common.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_common.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_cpu.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_locking.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_fsp_error.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_rtos.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_rx_compiler.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\r_typedefs.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\resetprg.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\sbrk.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\all\sbrk.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\dbsct.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\fsp_common_api.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\lowlvl.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\lowlvl.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\lowsrc.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\lowsrc.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\mcu_locks.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_common.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_common.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_cpu.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_interrupts.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_locking.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_mcu_startup.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_bsp_software_interrupt.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_fsp_error.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_rtos.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_rx_compiler.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_rx_intrinsic_functions.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\r_typedefs.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\resetprg.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\sbrk.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\all\sbrk.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_info.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_locks.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts_private.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_cpu.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_locking.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.c - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_clocks.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_info.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_init.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_interrupts.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_locks.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\mcu_mapped_interrupts_private.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_cpu.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\r_bsp_locking.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.c + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\vecttbl.h - trash\2023-02-13-21-21-22\src\smc_gen\r_bsp\mcu\rx65n\register_access\ccrx\iodefine.h + trash\2023-03-10-14-05-53\src\smc_gen\r_bsp\mcu\rx65n\register_access\ccrx\iodefine.h - trash\2023-02-13-21-21-22\src\smc_gen\r_byteq\r_byteq_if.h - trash\2023-02-13-21-21-22\src\smc_gen\r_byteq\readme.txt + trash\2023-03-10-14-05-53\src\smc_gen\r_byteq\r_byteq_if.h + trash\2023-03-10-14-05-53\src\smc_gen\r_byteq\readme.txt - trash\2023-02-13-21-21-22\src\smc_gen\r_byteq\src\r_byteq.c - trash\2023-02-13-21-21-22\src\smc_gen\r_byteq\src\r_byteq_private.h + trash\2023-03-10-14-05-53\src\smc_gen\r_byteq\src\r_byteq.c + trash\2023-03-10-14-05-53\src\smc_gen\r_byteq\src\r_byteq_private.h - trash\2023-02-13-21-21-22\src\smc_gen\r_cmt_rx\r_cmt_rx_if.h - trash\2023-02-13-21-21-22\src\smc_gen\r_cmt_rx\readme.txt + trash\2023-03-10-14-05-53\src\smc_gen\r_cmt_rx\r_cmt_rx_if.h + trash\2023-03-10-14-05-53\src\smc_gen\r_cmt_rx\readme.txt - trash\2023-02-13-21-21-22\src\smc_gen\r_cmt_rx\src\r_cmt_rx.c + trash\2023-03-10-14-05-53\src\smc_gen\r_cmt_rx\src\r_cmt_rx.c - trash\2023-02-13-21-21-22\src\smc_gen\r_config\r_bsp_config.h - trash\2023-02-13-21-21-22\src\smc_gen\r_config\r_bsp_config_readme.txt - trash\2023-02-13-21-21-22\src\smc_gen\r_config\r_bsp_interrupt_config.h - trash\2023-02-13-21-21-22\src\smc_gen\r_config\r_byteq_config.h - trash\2023-02-13-21-21-22\src\smc_gen\r_config\r_cmt_rx_config.h - trash\2023-02-13-21-21-22\src\smc_gen\r_config\r_sci_rx_config.h + trash\2023-03-10-14-05-53\src\smc_gen\r_config\r_bsp_config.h + trash\2023-03-10-14-05-53\src\smc_gen\r_config\r_bsp_config_readme.txt + trash\2023-03-10-14-05-53\src\smc_gen\r_config\r_bsp_interrupt_config.h + trash\2023-03-10-14-05-53\src\smc_gen\r_config\r_byteq_config.h + trash\2023-03-10-14-05-53\src\smc_gen\r_config\r_cmt_rx_config.h + trash\2023-03-10-14-05-53\src\smc_gen\r_config\r_sci_rx_config.h - trash\2023-02-13-21-21-22\src\smc_gen\r_pincfg\Pin.c - trash\2023-02-13-21-21-22\src\smc_gen\r_pincfg\Pin.h - trash\2023-02-13-21-21-22\src\smc_gen\r_pincfg\r_pinset.h - trash\2023-02-13-21-21-22\src\smc_gen\r_pincfg\r_sci_rx_pinset.c - trash\2023-02-13-21-21-22\src\smc_gen\r_pincfg\r_sci_rx_pinset.h + trash\2023-03-10-14-05-53\src\smc_gen\r_pincfg\Pin.c + trash\2023-03-10-14-05-53\src\smc_gen\r_pincfg\Pin.h + trash\2023-03-10-14-05-53\src\smc_gen\r_pincfg\r_pinset.h + trash\2023-03-10-14-05-53\src\smc_gen\r_pincfg\r_sci_rx_pinset.c + trash\2023-03-10-14-05-53\src\smc_gen\r_pincfg\r_sci_rx_pinset.h - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\r_sci_rx_if.h - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\readme.txt + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\r_sci_rx_if.h + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\readme.txt - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx.c - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.c - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.h - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.c - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.h - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx_platform.h - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\r_sci_rx_private.h + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx.c + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.c + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx_dmaca.h + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.c + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx_dtc.h + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx_platform.h + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\r_sci_rx_private.h - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n.c - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_data.c - trash\2023-02-13-21-21-22\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_private.h + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n.c + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_data.c + trash\2023-03-10-14-05-53\src\smc_gen\r_sci_rx\src\targets\rx65n\r_sci_rx65n_private.h @@ -1066,28 +659,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -1103,16 +696,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -1409,236 +1002,73 @@ HardwareDebug\r_sci_rx65n_data.obj HardwareDebug\ewf_info_tx_ryz014.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\ewf" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\ewf\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_config\" - "C:\t-comms\comms_framework\src" - "C:\t-comms\comms_framework\src\examples" - "C:\t-comms\comms_framework\src\test" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_skeleton\" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\utility\low_power" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\ewf" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\ewf\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_config\" + "C:\embedded0310_2\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\examples" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\test" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_skeleton\" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\utility\low_power" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" TX_INCLUDE_USER_DEFINE_FILE NX_ENABLE_TCPIP_OFFLOAD NX_ENABLE_INTERFACE_CAPABILITY diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.scfg b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.scfg index f4b1bd8c..c36a4b12 100644 --- a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.scfg +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/ewf_info_tx_ryz014.scfg @@ -497,14 +497,14 @@ - - + + - + @@ -622,7 +622,7 @@ - + @@ -634,7 +634,7 @@ - + @@ -716,10 +716,10 @@ - - - - + + + + @@ -761,13 +761,13 @@ - + - + @@ -826,26 +826,26 @@ - + - + - + - + diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_cellular_config.h b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_cellular_config.h new file mode 100644 index 00000000..42d6d9a6 --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_cellular_config.h @@ -0,0 +1,105 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_config.h + * Description : Cellular-related config files such as pmod terminal and APN. + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_CONFIG_H +#define EWF_CELLULAR_CONFIG_H + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ + + +/* Specify uart ch used for communication with cellular module */ +#define EWF_CELLULAR_CFG_UART_SCI_CH (6) + +/* Specify the port and pin of the RTS terminal */ +#define EWF_CELLULAR_CFG_RTS_PORT 0 +#define EWF_CELLULAR_CFG_RTS_PIN 2 + +/* Specify the port and pin of the RESET terminal */ +#define EWF_CELLULAR_CFG_RESET_PORT 5 +#define EWF_CELLULAR_CFG_RESET_PIN 5 + + +/* Changes the output format of the reset signal sent to the Cellular module. */ +/* 1: active high 0: active low */ +#define EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC (1) + +/* Sets the RTS pin control method of the Cellular module. */ +/* 0: The CTS pin is controlled by hardware flow control, and the RTS pin is controlled by this FIT module through GPIO. */ +/* 1: The RTS pin is controlled by hardware flow control, and the CTS pin is controlled by this FIT module through GPIO. */ +#define EWF_CELLULAR_CFG_CTS_SW_CTRL (0) //unused + +/* Specify the port and pin of the CTC */ +#define EWF_CELLULAR_CFG_CTS_PORT 2 //unused +#define EWF_CELLULAR_CFG_CTS_PIN 2 //unused + + +/* Specifies the pin function control register (PFS) setting value */ +/* to select the peripheral function of the MCU pin used to control the RTS pin of */ +/* the Cellular module. Set this option to match the pin to be used. */ +/* This option takes effect when EWF_CELLULAR_CFG_CTS_SW_CTRL is set to 1. */ +#define EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU //unused + +/* Specify IRQ terminal for RING terminal */ +#define EWF_CELLULAR_CFG_IRQ_NUM (4) //unused + +/* The SIM PIN for the modem */ +#define EWF_CONFIG_SIM_PIN ("0000") + +/* The SIM operator APN */ +#define EWF_CONFIG_SIM_APN ("globaldata.iot") + +/* The modem context ID used */ +#define EWF_CONFIG_CONTEXT_ID (1) +/* Board dependent settings; please use the value for each setting listed below depending on the board you use. + +Preprocessors that define board dependent settings and the corresponding values to be set are as follows: +Confirmed board number 1, +EWF_CELLULAR_CFG_UART_SCI_CH 6, +EWF_CELLULAR_CFG_RTS_PORT 0, +EWF_CELLULAR_CFG_RTS_PIN 2, +EWF_CELLULAR_CFG_RESET_PORT 5, +EWF_CELLULAR_CFG_RESET_PIN 5, +EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC 1, +EWF_CELLULAR_CFG_CTS_SW_CTRL 0, +EWF_CELLULAR_CFG_CTS_PORT 2, +EWF_CELLULAR_CFG_CTS_PIN 2, +EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU, +EWF_CELLULAR_CFG_IRQ_NUM 4, +EWF_CONFIG_SIM_PIN "0000", +EWF_CONFIG_SIM_APN "globaldata.iot", +EWF_CONFIG_CONTEXT_ID 1 + +where the confirmed board numbers listed in the first row above are as follows: +1: CK-RX65N (PMOD1), +In the above preprocessor list, please use one of the values listed on the right side. +On the right side, each column corresponds to each confirmed board number. + +Note: +Please supply power source to USB(CN4) port on RYZ014A/RYZ024A-PMOD. +E2 emulator supplying power to RYZ014A/RYZ024A-PMOD may result in insufficient power source. +The E2 emulator can provide 200mA, but RYZ014A/RYZ024A needs more current while connecting to the network. + +*/ +#endif /* EWF_CELLULAR_CONFIG_H */ diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_cellular_private.h b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_cellular_private.h new file mode 100644 index 00000000..d4c7c4bb --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_cellular_private.h @@ -0,0 +1,169 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_private.h + * Description : Macro for controlling the pmod terminal + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_PRIVATE_H_ +#define EWF_CELLULAR_PRIVATE_H_ + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ +#include "r_sci_rx_if.h" +#include "r_sci_rx_pinset.h" +#include "ewf_cellular_config.h" + + +/* PDR port macros. */ +#define EWF_CELLULAR_SET_PDR(x, y) (EWF_CELLULAR_SET_PDR_PREPROC(x, y)) +/* Set the port direction. */ +#define EWF_CELLULAR_SET_PDR_PREPROC(x, y) ((PORT ## x .PDR.BIT.B ## y)) + +/* PODR port macros. */ +#define EWF_CELLULAR_SET_PODR(x, y) (EWF_CELLULAR_SET_PODR_PREPROC(x, y)) +/* Set the port I/O. */ +#define EWF_CELLULAR_SET_PODR_PREPROC(x, y) ((PORT ## x .PODR.BIT.B ## y)) + +#define EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT (1) + +/* Changes the output format of the reset signal sent to the Cellular module. */ +#if EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC == 1 +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (1) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (0) +#else +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (0) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (1) +#endif + + +#ifndef EWF_CELLULAR_CFG_UART_SCI_CH +#error "Error! Need to define EWF_CELLULAR_CFG_UART_SCI_CH in ewf_cellular_config.h" +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (0) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI0() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI0()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH0) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH0_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH0_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (1) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI1() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI1()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH1) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH1_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH1_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (2) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI2() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI2()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH2) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH2_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH2_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (3) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI3() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI3()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH3) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH3_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH3_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (4) +/* Store R_SCI_PinSet_SCI4() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI4()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH4) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH4_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH4_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (5) +/* Store R_SCI_PinSet_SCI5() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI5()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH5) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH5_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH5_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (6) +/* Store R_SCI_PinSet_SCI6() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI6()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH6) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH6_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH6_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (7) +/* Store R_SCI_PinSet_SCI7() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI7()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH7) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH7_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH7_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (8) +/* Store R_SCI_PinSet_SCI8() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI8()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH8) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH8_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH8_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (9) +/* Store R_SCI_PinSet_SCI9() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI9()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH9) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH9_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH9_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (10) +/* Store R_SCI_PinSet_SCI10() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI10()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH10) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH10_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH10_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (11) +/* Store R_SCI_PinSet_SCI11() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI11()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH11) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH11_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH11_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (12) +/* Store R_SCI_PinSet_SCI12() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI12()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH12) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH12_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH12_RX_BUFSIZ) +#else +#error "Error! Invalid setting for EWF_CELLULAR_UART_SCI_CH in ewf_cellular_config.h" +#endif /* EWF_CELLULAR_CFG_UART_SCI_CH */ + + +#if R_SCI_CFG_TX_BUFSIZE < (1500) +#error "The SCI send buffer size is too small." +#endif +#if R_SCI_CFG_RX_BUFSIZE < (1500) +#error "The SCI receive buffer size is too small." +#endif + +#endif /* EWF_CELLULAR_PRIVATE_H_ */ diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_example.config.h b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_example.config.h index 54f0b5fe..7f077bea 100644 --- a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_example.config.h +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/ewf_example.config.h @@ -35,20 +35,6 @@ extern "C" { /** @} *** group_example_configuration_allocator */ -/** - * @defgroup group_example_configuration_modem Modem configuration - * @brief Modem configuration settings used in examples - * @{ - */ - -/** @brief The SIM PIN for the modem */ -#define EWF_CONFIG_SIM_PIN ("0000") - -/** @brief The modem context ID used */ -#define EWF_CONFIG_CONTEXT_ID (1) - -/** @} *** group_example_configuration_modem */ - /** * @defgroup group_example_configuration_iot_hub IoT Hub configuration * @brief IoT Hub configuration settings used in examples @@ -63,6 +49,37 @@ extern "C" { /** @} *** group_example_configuration_iot_hub */ +/** + * @defgroup group_example_configuration_telemetry + * @brief Telemetry example configuration + * @{ + */ + +/** @brief The size of the buffer used to hold the IoT Hub username */ +#define EWF_CONFIG_TELEMETRY_USERNAME_LENGTH (256) + +/** @brief The size of the buffer used to hold the IoT Hub client ID */ +#define EWF_CONFIG_TELEMETRY_CLIENT_ID_LENGTH (64) + +/** @brief The size of the buffer used to hold the IoT Hub topic length */ +#define EWF_CONFIG_TELEMETRY_TOPIC_LENGTH (256) + +/** @brief The number of minutes to run the telemetry loop, 0 means to run forever */ +#define EWF_CONFIG_TELEMETRY_LOOP_MINUTES (60) + +/** @} */ + +/** + * @defgroup group_example_configuration_netx_duo NetX Duo driver configuration + * @brief NetX Duo Driver configuration settings used in middleware driver + * @{ + */ + +/* MTU size should be equal to the modems maximum socket send size */ +#define EWF_CONFIG_ADAPTER_MTU (1460) + +/** @} */ + /************************************************************************//** * @} ****************************************************************************/ diff --git a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/main.c b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/main.c index 20b552c4..6610482c 100644 --- a/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/main.c +++ b/examples/CK_RX65N_CCRX/ewf_info_tx_ryz014/src/main.c @@ -34,6 +34,8 @@ #include "ewf_example.config.h" +#include "ewf_cellular_private.h" + /* Modem might take some minutes to attach and register to the network. Time out value in seconds */ #define EWF_ADAPTER_RENESAS_NETWORK_REGISTER_TIMEOUT (1200) @@ -99,10 +101,10 @@ void ewf_info_thread_entry(ULONG parameter) // Release the RYZ014A from reset - PORTA.PODR.BIT.B1= 1; - PORTA.PDR.BIT.B1= 1; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_ON; + EWF_CELLULAR_SET_PDR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT; tx_thread_sleep (100); - PORTA.PODR.BIT.B1= 0; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_OFF; EWF_LOG("Waiting for the module to Power Reset!\r\n"); ewf_platform_sleep(300); EWF_LOG("Ready\r\n"); diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject index eabcbfc6..53ee6c08 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject @@ -1656,50 +1656,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.project b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.project index d38ce2ae..acbe0195 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.project +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.project @@ -7,7 +7,6 @@ com.renesas.smc.ui.pgsupport.SCContentBuilder - @@ -41,6 +40,306 @@ PARENT-3-PROJECT_LOC/src + + + 1678020325791 + ewf + 14 + + org.eclipse.ui.ide.notFilterMatcher + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_gnss.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_http.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_types.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_ntp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_internet.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_nvm.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_urc.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-ewf_adapter_renesas_common.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-ewf_adapter_renesas_ryz014.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_ids.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_message.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_tokenizer.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf.h + + + + + SMC_GENERATED_LOC diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch index 58f82f39..d9f3593e 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch @@ -29,7 +29,7 @@ - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.rcpc b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.rcpc index 495ad334..9ef12676 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.rcpc +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.rcpc @@ -19,8 +19,6 @@ ..\..\..\src\ewf_adapter_api_http.h ..\..\..\src\ewf_adapter_api_info.c ..\..\..\src\ewf_adapter_api_info.h - ..\..\..\src\ewf_adapter_api_lora.c - ..\..\..\src\ewf_adapter_api_lora.h ..\..\..\src\ewf_adapter_api_modem.c ..\..\..\src\ewf_adapter_api_modem.h ..\..\..\src\ewf_adapter_api_modem_general.c @@ -47,50 +45,8 @@ ..\..\..\src\ewf_adapter_api_tls_basic.h ..\..\..\src\ewf_adapter_api_udp.c ..\..\..\src\ewf_adapter_api_udp.h - ..\..\..\src\ewf_adapter_api_wifi_ap.c - ..\..\..\src\ewf_adapter_api_wifi_ap.h ..\..\..\src\ewf_adapter_api_wifi_station.c ..\..\..\src\ewf_adapter_api_wifi_station.h - ..\..\..\src\ewf_adapter_bsd_sockets.c - ..\..\..\src\ewf_adapter_bsd_sockets.h - ..\..\..\src\ewf_adapter_espressif_common.c - ..\..\..\src\ewf_adapter_espressif_common.h - ..\..\..\src\ewf_adapter_espressif_common_control.c - ..\..\..\src\ewf_adapter_espressif_common_info.c - ..\..\..\src\ewf_adapter_espressif_common_internet.c - ..\..\..\src\ewf_adapter_espressif_common_urc.c - ..\..\..\src\ewf_adapter_espressif_common_wifi_station.c - ..\..\..\src\ewf_adapter_espressif_esp8266.c - ..\..\..\src\ewf_adapter_espressif_esp8266.h - ..\..\..\src\ewf_adapter_espressif_esp8285.c - ..\..\..\src\ewf_adapter_espressif_esp8285.h - ..\..\..\src\ewf_adapter_espressif_wroom_02.c - ..\..\..\src\ewf_adapter_espressif_wroom_02.h - ..\..\..\src\ewf_adapter_mxchip_common.c - ..\..\..\src\ewf_adapter_mxchip_common.h - ..\..\..\src\ewf_adapter_mxchip_common_control.c - ..\..\..\src\ewf_adapter_mxchip_common_info.c - ..\..\..\src\ewf_adapter_mxchip_common_internet.c - ..\..\..\src\ewf_adapter_mxchip_common_tokenizer.c - ..\..\..\src\ewf_adapter_mxchip_common_urc.c - ..\..\..\src\ewf_adapter_mxchip_common_wifi_station.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.h - ..\..\..\src\ewf_adapter_quectel_bg95.c - ..\..\..\src\ewf_adapter_quectel_bg95.h - ..\..\..\src\ewf_adapter_quectel_bg96.c - ..\..\..\src\ewf_adapter_quectel_bg96.h - ..\..\..\src\ewf_adapter_quectel_common.c - ..\..\..\src\ewf_adapter_quectel_common.h - ..\..\..\src\ewf_adapter_quectel_common_context.c - ..\..\..\src\ewf_adapter_quectel_common_control.c - ..\..\..\src\ewf_adapter_quectel_common_info.c - ..\..\..\src\ewf_adapter_quectel_common_internet.c - ..\..\..\src\ewf_adapter_quectel_common_mqtt_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tls_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tokenizer.c - ..\..\..\src\ewf_adapter_quectel_common_ufs.c - ..\..\..\src\ewf_adapter_quectel_common_urc.c ..\..\..\src\ewf_adapter_renesas_common.c ..\..\..\src\ewf_adapter_renesas_common.h ..\..\..\src\ewf_adapter_renesas_common_control.c @@ -104,120 +60,26 @@ ..\..\..\src\ewf_adapter_renesas_ryz014.h ..\..\..\src\ewf_adapter_renesas_ryz024a.c ..\..\..\src\ewf_adapter_renesas_ryz024a.h - ..\..\..\src\ewf_adapter_seeed_lora_e5.c - ..\..\..\src\ewf_adapter_seeed_lora_e5.h ..\..\..\src\ewf_adapter_sequans.c ..\..\..\src\ewf_adapter_sequans.h - ..\..\..\src\ewf_adapter_simcom_common.c - ..\..\..\src\ewf_adapter_simcom_common.h - ..\..\..\src\ewf_adapter_simcom_common_control.c - ..\..\..\src\ewf_adapter_simcom_common_info.c - ..\..\..\src\ewf_adapter_simcom_common_urc.c - ..\..\..\src\ewf_adapter_simcom_sim7000.c - ..\..\..\src\ewf_adapter_simcom_sim7000.h - ..\..\..\src\ewf_adapter_simcom_sim868.c - ..\..\..\src\ewf_adapter_simcom_sim868.h - ..\..\..\src\ewf_adapter_simcom_sim900.c - ..\..\..\src\ewf_adapter_simcom_sim900.h - ..\..\..\src\ewf_adapter_thales_common.c - ..\..\..\src\ewf_adapter_thales_common.h - ..\..\..\src\ewf_adapter_thales_common_context.c - ..\..\..\src\ewf_adapter_thales_common_control.c - ..\..\..\src\ewf_adapter_thales_common_ffs.c - ..\..\..\src\ewf_adapter_thales_common_info.c - ..\..\..\src\ewf_adapter_thales_common_internet.c - ..\..\..\src\ewf_adapter_thales_common_tokenizer.c - ..\..\..\src\ewf_adapter_thales_common_urc.c - ..\..\..\src\ewf_adapter_thales_exs82_w.c - ..\..\..\src\ewf_adapter_thales_exs82_w.h - ..\..\..\src\ewf_adapter_winsock2.c - ..\..\..\src\ewf_adapter_winsock2.h ..\..\..\src\ewf_allocator.c ..\..\..\src\ewf_allocator.h - ..\..\..\src\ewf_allocator_c_heap.c - ..\..\..\src\ewf_allocator_c_heap.h - ..\..\..\src\ewf_allocator_memory_pool.c - ..\..\..\src\ewf_allocator_memory_pool.h - ..\..\..\src\ewf_allocator_netx.c - ..\..\..\src\ewf_allocator_netx.h ..\..\..\src\ewf_allocator_threadx.c ..\..\..\src\ewf_allocator_threadx.h ..\..\..\src\ewf_ids.h ..\..\..\src\ewf_interface.c ..\..\..\src\ewf_interface.h - ..\..\..\src\ewf_interface_linux_serial.c - ..\..\..\src\ewf_interface_lpc_uart.c - ..\..\..\src\ewf_interface_lpc_uart.h - ..\..\..\src\ewf_interface_microchip_pic_uart.c - ..\..\..\src\ewf_interface_microchip_pic_uart.h - ..\..\..\src\ewf_interface_microchip_sam_uart.c - ..\..\..\src\ewf_interface_microchip_sam_uart.h - ..\..\..\src\ewf_interface_ra_uart.c - ..\..\..\src\ewf_interface_ra_uart.h ..\..\..\src\ewf_interface_rx_uart.c ..\..\..\src\ewf_interface_rx_uart.h - ..\..\..\src\ewf_interface_stm32_uart.c - ..\..\..\src\ewf_interface_stm32_uart.h - ..\..\..\src\ewf_interface_win32_com.c - ..\..\..\src\ewf_interface_win32_com.h ..\..\..\src\ewf_lib.c ..\..\..\src\ewf_lib.h ..\..\..\src\ewf_message.h ..\..\..\src\ewf_middleware_netxduo.c ..\..\..\src\ewf_middleware_netxduo.h - ..\..\..\src\ewf_netxduo_ppp.c - ..\..\..\src\ewf_netxduo_ppp.h ..\..\..\src\ewf_platform.h - ..\..\..\src\ewf_platform_bare_metal.c - ..\..\..\src\ewf_platform_bare_metal.h - ..\..\..\src\ewf_platform_freertos.c - ..\..\..\src\ewf_platform_freertos.h - ..\..\..\src\ewf_platform_pthread.c - ..\..\..\src\ewf_platform_pthread.h ..\..\..\src\ewf_platform_threadx.c ..\..\..\src\ewf_platform_threadx.h - ..\..\..\src\ewf_platform_win32.c - ..\..\..\src\ewf_platform_win32.h ..\..\..\src\ewf_tokenizer.h - - ..\..\..\src\examples\ewf_example_azure_iot_pnp_provisioning.c - ..\..\..\src\examples\ewf_example_azure_iot_provisioning.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg95.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg96.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz014.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz024a.c - ..\..\..\src\examples\ewf_example_certs_basic_winsock2.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.h - ..\..\..\src\examples\ewf_example_netx_duo_test.c - ..\..\..\src\examples\ewf_example_netx_duo_test.h - ..\..\..\src\examples\ewf_example_telemetry.c - ..\..\..\src\examples\ewf_example_telemetry_basic.c - - - ..\..\..\src\test\ewf_adapter_bsd_sockets_test.c - ..\..\..\src\test\ewf_adapter_espressif_common_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8266_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8285_test.c - ..\..\..\src\test\ewf_adapter_espressif_wroom_02_test.c - ..\..\..\src\test\ewf_adapter_mxchip_common_test.c - ..\..\..\src\test\ewf_adapter_mxchip_emw3080b_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg95_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg96_test.c - ..\..\..\src\test\ewf_adapter_quectel_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz014_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz024a_test.c - ..\..\..\src\test\ewf_adapter_simcom_common_test.c - ..\..\..\src\test\ewf_adapter_simcom_sim7000_test.c - ..\..\..\src\test\ewf_adapter_test.c - ..\..\..\src\test\ewf_adapter_test.h - ..\..\..\src\test\ewf_adapter_thales_common_test.c - ..\..\..\src\test\ewf_adapter_thales_exs82_w_test.c - ..\..\..\src\test\ewf_adapter_winsock2_test.c - @@ -2145,6 +2007,8 @@ src\demo_printf.c src\demo_printf.h src\ewf.config.h + src\ewf_cellular_config.h + src\ewf_cellular_private.h src\ewf_example.config.h src\hardware_setup.c src\hardware_setup.h @@ -2328,6 +2192,21 @@ + + + + + trash\2023-03-10-14-12-40\libs\filex\fx_user.h + + + trash\2023-03-10-14-12-40\libs\netxduo\nx_user.h + + + trash\2023-03-10-14-12-40\libs\threadx\tx_user.h + + + + R5F565NEHxFB @@ -2337,55 +2216,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2401,16 +2280,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -3907,163 +3786,66 @@ HardwareDebug\r_sci_rx65n_data.obj HardwareDebug\ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\ewf" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\ewf\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_config\" - "C:\t-comms\comms_framework\src" - "C:\t-comms\comms_framework\src\examples" - "C:\t-comms\comms_framework\src\test" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_skeleton\" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\utility\low_power" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure-sdk-for-c\sdk\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc\configs\RTOS_BASE" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\deps\flatcc\include" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\cloud" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\dhcp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\dns" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\http" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\mqtt" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\nat" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\smtp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\snmp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\sntp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\web" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\crypto_libraries\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\nx_secure\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\nx_secure\ports" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\utility\iperf" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex\ports\generic\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\ewf" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\ewf\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_config\" + "C:\embedded0310_2\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\examples" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\test" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_skeleton\" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\utility\low_power" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure-sdk-for-c\sdk\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc\configs\RTOS_BASE" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\deps\flatcc\include" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\cloud" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\dhcp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\dns" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\http" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\mqtt" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\nat" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\smtp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\snmp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\sntp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\web" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\crypto_libraries\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\nx_secure\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\nx_secure\ports" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\utility\iperf" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex\ports\generic\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" NX_INCLUDE_USER_DEFINE_FILE TX_INCLUDE_USER_DEFINE_FILE NX_ENABLE_TCPIP_OFFLOAD diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg index c75ad260..bcc84a75 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg @@ -497,14 +497,14 @@ - - + + - + @@ -622,7 +622,7 @@ - + @@ -803,7 +803,7 @@ - + @@ -827,7 +827,7 @@ - + @@ -876,11 +876,11 @@ - + - + @@ -958,10 +958,10 @@ - - - - + + + + @@ -1003,13 +1003,13 @@ - + - + @@ -1068,26 +1068,26 @@ - + - + - + - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_config.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_config.h new file mode 100644 index 00000000..42d6d9a6 --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_config.h @@ -0,0 +1,105 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_config.h + * Description : Cellular-related config files such as pmod terminal and APN. + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_CONFIG_H +#define EWF_CELLULAR_CONFIG_H + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ + + +/* Specify uart ch used for communication with cellular module */ +#define EWF_CELLULAR_CFG_UART_SCI_CH (6) + +/* Specify the port and pin of the RTS terminal */ +#define EWF_CELLULAR_CFG_RTS_PORT 0 +#define EWF_CELLULAR_CFG_RTS_PIN 2 + +/* Specify the port and pin of the RESET terminal */ +#define EWF_CELLULAR_CFG_RESET_PORT 5 +#define EWF_CELLULAR_CFG_RESET_PIN 5 + + +/* Changes the output format of the reset signal sent to the Cellular module. */ +/* 1: active high 0: active low */ +#define EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC (1) + +/* Sets the RTS pin control method of the Cellular module. */ +/* 0: The CTS pin is controlled by hardware flow control, and the RTS pin is controlled by this FIT module through GPIO. */ +/* 1: The RTS pin is controlled by hardware flow control, and the CTS pin is controlled by this FIT module through GPIO. */ +#define EWF_CELLULAR_CFG_CTS_SW_CTRL (0) //unused + +/* Specify the port and pin of the CTC */ +#define EWF_CELLULAR_CFG_CTS_PORT 2 //unused +#define EWF_CELLULAR_CFG_CTS_PIN 2 //unused + + +/* Specifies the pin function control register (PFS) setting value */ +/* to select the peripheral function of the MCU pin used to control the RTS pin of */ +/* the Cellular module. Set this option to match the pin to be used. */ +/* This option takes effect when EWF_CELLULAR_CFG_CTS_SW_CTRL is set to 1. */ +#define EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU //unused + +/* Specify IRQ terminal for RING terminal */ +#define EWF_CELLULAR_CFG_IRQ_NUM (4) //unused + +/* The SIM PIN for the modem */ +#define EWF_CONFIG_SIM_PIN ("0000") + +/* The SIM operator APN */ +#define EWF_CONFIG_SIM_APN ("globaldata.iot") + +/* The modem context ID used */ +#define EWF_CONFIG_CONTEXT_ID (1) +/* Board dependent settings; please use the value for each setting listed below depending on the board you use. + +Preprocessors that define board dependent settings and the corresponding values to be set are as follows: +Confirmed board number 1, +EWF_CELLULAR_CFG_UART_SCI_CH 6, +EWF_CELLULAR_CFG_RTS_PORT 0, +EWF_CELLULAR_CFG_RTS_PIN 2, +EWF_CELLULAR_CFG_RESET_PORT 5, +EWF_CELLULAR_CFG_RESET_PIN 5, +EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC 1, +EWF_CELLULAR_CFG_CTS_SW_CTRL 0, +EWF_CELLULAR_CFG_CTS_PORT 2, +EWF_CELLULAR_CFG_CTS_PIN 2, +EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU, +EWF_CELLULAR_CFG_IRQ_NUM 4, +EWF_CONFIG_SIM_PIN "0000", +EWF_CONFIG_SIM_APN "globaldata.iot", +EWF_CONFIG_CONTEXT_ID 1 + +where the confirmed board numbers listed in the first row above are as follows: +1: CK-RX65N (PMOD1), +In the above preprocessor list, please use one of the values listed on the right side. +On the right side, each column corresponds to each confirmed board number. + +Note: +Please supply power source to USB(CN4) port on RYZ014A/RYZ024A-PMOD. +E2 emulator supplying power to RYZ014A/RYZ024A-PMOD may result in insufficient power source. +The E2 emulator can provide 200mA, but RYZ014A/RYZ024A needs more current while connecting to the network. + +*/ +#endif /* EWF_CELLULAR_CONFIG_H */ diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_private.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_private.h new file mode 100644 index 00000000..d4c7c4bb --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_private.h @@ -0,0 +1,169 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_private.h + * Description : Macro for controlling the pmod terminal + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_PRIVATE_H_ +#define EWF_CELLULAR_PRIVATE_H_ + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ +#include "r_sci_rx_if.h" +#include "r_sci_rx_pinset.h" +#include "ewf_cellular_config.h" + + +/* PDR port macros. */ +#define EWF_CELLULAR_SET_PDR(x, y) (EWF_CELLULAR_SET_PDR_PREPROC(x, y)) +/* Set the port direction. */ +#define EWF_CELLULAR_SET_PDR_PREPROC(x, y) ((PORT ## x .PDR.BIT.B ## y)) + +/* PODR port macros. */ +#define EWF_CELLULAR_SET_PODR(x, y) (EWF_CELLULAR_SET_PODR_PREPROC(x, y)) +/* Set the port I/O. */ +#define EWF_CELLULAR_SET_PODR_PREPROC(x, y) ((PORT ## x .PODR.BIT.B ## y)) + +#define EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT (1) + +/* Changes the output format of the reset signal sent to the Cellular module. */ +#if EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC == 1 +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (1) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (0) +#else +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (0) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (1) +#endif + + +#ifndef EWF_CELLULAR_CFG_UART_SCI_CH +#error "Error! Need to define EWF_CELLULAR_CFG_UART_SCI_CH in ewf_cellular_config.h" +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (0) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI0() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI0()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH0) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH0_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH0_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (1) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI1() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI1()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH1) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH1_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH1_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (2) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI2() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI2()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH2) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH2_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH2_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (3) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI3() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI3()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH3) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH3_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH3_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (4) +/* Store R_SCI_PinSet_SCI4() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI4()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH4) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH4_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH4_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (5) +/* Store R_SCI_PinSet_SCI5() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI5()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH5) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH5_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH5_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (6) +/* Store R_SCI_PinSet_SCI6() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI6()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH6) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH6_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH6_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (7) +/* Store R_SCI_PinSet_SCI7() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI7()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH7) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH7_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH7_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (8) +/* Store R_SCI_PinSet_SCI8() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI8()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH8) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH8_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH8_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (9) +/* Store R_SCI_PinSet_SCI9() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI9()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH9) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH9_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH9_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (10) +/* Store R_SCI_PinSet_SCI10() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI10()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH10) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH10_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH10_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (11) +/* Store R_SCI_PinSet_SCI11() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI11()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH11) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH11_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH11_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (12) +/* Store R_SCI_PinSet_SCI12() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI12()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH12) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH12_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH12_RX_BUFSIZ) +#else +#error "Error! Invalid setting for EWF_CELLULAR_UART_SCI_CH in ewf_cellular_config.h" +#endif /* EWF_CELLULAR_CFG_UART_SCI_CH */ + + +#if R_SCI_CFG_TX_BUFSIZE < (1500) +#error "The SCI send buffer size is too small." +#endif +#if R_SCI_CFG_RX_BUFSIZE < (1500) +#error "The SCI receive buffer size is too small." +#endif + +#endif /* EWF_CELLULAR_PRIVATE_H_ */ diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h index 8fd9bba6..bdc7e66b 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h @@ -35,23 +35,6 @@ extern "C" { /** @} *** group_example_configuration_allocator */ -/** - * @defgroup group_example_configuration_modem Modem configuration - * @brief Modem configuration settings used in examples - * @{ - */ - -/** @brief The SIM PIN for the modem */ -#define EWF_CONFIG_SIM_PIN ("0000") - -/** @brief The SIM operator APN */ -#define EWF_CONFIG_SIM_APN ("globaldata.iot") - -/** @brief The modem context ID used */ -#define EWF_CONFIG_CONTEXT_ID (1) - -/** @} *** group_example_configuration_modem */ - /** * @defgroup group_example_configuration_iot_hub IoT Hub configuration * @brief IoT Hub configuration settings used in examples diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c index f05e09d5..c2394079 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c @@ -52,6 +52,8 @@ Includes , "Project Includes" #include "ewf_example.config.h" +#include "ewf_cellular_private.h" + /* Modem might take some minutes to attach and register to the network. Time out value in seconds */ #define EWF_ADAPTER_RENESAS_NETWORK_REGISTER_TIMEOUT (1200) @@ -150,10 +152,10 @@ void application_thread_entry(ULONG entry_input) // Release the RYZ014A from reset - PORTA.PODR.BIT.B1= 1; - PORTA.PDR.BIT.B1= 1; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_ON; + EWF_CELLULAR_SET_PDR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT; tx_thread_sleep (200); - PORTA.PODR.BIT.B1= 0; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_OFF; printf("Waiting for the module to Power Reset!\r\n"); ewf_platform_sleep(300); printf("Ready\r\n"); diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject index cbf0771b..70ccc899 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject @@ -1652,40 +1652,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.project b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.project index ff0bdb51..5012517f 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.project +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.project @@ -7,7 +7,6 @@ com.renesas.smc.ui.pgsupport.SCContentBuilder - @@ -41,6 +40,306 @@ PARENT-3-PROJECT_LOC/src + + + 1677591875226 + ewf + 14 + + org.eclipse.ui.ide.notFilterMatcher + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_gnss.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_http.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_types.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_ntp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_internet.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_nvm.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_urc.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_ids.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_message.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_tokenizer.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf.h + + + + + SMC_GENERATED_LOC diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch index 0733566f..43c26ac7 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch @@ -30,7 +30,7 @@ - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.rcpc b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.rcpc index ea0b82d5..5435b631 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.rcpc +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.rcpc @@ -19,8 +19,6 @@ ..\..\..\src\ewf_adapter_api_http.h ..\..\..\src\ewf_adapter_api_info.c ..\..\..\src\ewf_adapter_api_info.h - ..\..\..\src\ewf_adapter_api_lora.c - ..\..\..\src\ewf_adapter_api_lora.h ..\..\..\src\ewf_adapter_api_modem.c ..\..\..\src\ewf_adapter_api_modem.h ..\..\..\src\ewf_adapter_api_modem_general.c @@ -47,50 +45,8 @@ ..\..\..\src\ewf_adapter_api_tls_basic.h ..\..\..\src\ewf_adapter_api_udp.c ..\..\..\src\ewf_adapter_api_udp.h - ..\..\..\src\ewf_adapter_api_wifi_ap.c - ..\..\..\src\ewf_adapter_api_wifi_ap.h ..\..\..\src\ewf_adapter_api_wifi_station.c ..\..\..\src\ewf_adapter_api_wifi_station.h - ..\..\..\src\ewf_adapter_bsd_sockets.c - ..\..\..\src\ewf_adapter_bsd_sockets.h - ..\..\..\src\ewf_adapter_espressif_common.c - ..\..\..\src\ewf_adapter_espressif_common.h - ..\..\..\src\ewf_adapter_espressif_common_control.c - ..\..\..\src\ewf_adapter_espressif_common_info.c - ..\..\..\src\ewf_adapter_espressif_common_internet.c - ..\..\..\src\ewf_adapter_espressif_common_urc.c - ..\..\..\src\ewf_adapter_espressif_common_wifi_station.c - ..\..\..\src\ewf_adapter_espressif_esp8266.c - ..\..\..\src\ewf_adapter_espressif_esp8266.h - ..\..\..\src\ewf_adapter_espressif_esp8285.c - ..\..\..\src\ewf_adapter_espressif_esp8285.h - ..\..\..\src\ewf_adapter_espressif_wroom_02.c - ..\..\..\src\ewf_adapter_espressif_wroom_02.h - ..\..\..\src\ewf_adapter_mxchip_common.c - ..\..\..\src\ewf_adapter_mxchip_common.h - ..\..\..\src\ewf_adapter_mxchip_common_control.c - ..\..\..\src\ewf_adapter_mxchip_common_info.c - ..\..\..\src\ewf_adapter_mxchip_common_internet.c - ..\..\..\src\ewf_adapter_mxchip_common_tokenizer.c - ..\..\..\src\ewf_adapter_mxchip_common_urc.c - ..\..\..\src\ewf_adapter_mxchip_common_wifi_station.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.h - ..\..\..\src\ewf_adapter_quectel_bg95.c - ..\..\..\src\ewf_adapter_quectel_bg95.h - ..\..\..\src\ewf_adapter_quectel_bg96.c - ..\..\..\src\ewf_adapter_quectel_bg96.h - ..\..\..\src\ewf_adapter_quectel_common.c - ..\..\..\src\ewf_adapter_quectel_common.h - ..\..\..\src\ewf_adapter_quectel_common_context.c - ..\..\..\src\ewf_adapter_quectel_common_control.c - ..\..\..\src\ewf_adapter_quectel_common_info.c - ..\..\..\src\ewf_adapter_quectel_common_internet.c - ..\..\..\src\ewf_adapter_quectel_common_mqtt_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tls_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tokenizer.c - ..\..\..\src\ewf_adapter_quectel_common_ufs.c - ..\..\..\src\ewf_adapter_quectel_common_urc.c ..\..\..\src\ewf_adapter_renesas_common.c ..\..\..\src\ewf_adapter_renesas_common.h ..\..\..\src\ewf_adapter_renesas_common_control.c @@ -104,120 +60,26 @@ ..\..\..\src\ewf_adapter_renesas_ryz014.h ..\..\..\src\ewf_adapter_renesas_ryz024a.c ..\..\..\src\ewf_adapter_renesas_ryz024a.h - ..\..\..\src\ewf_adapter_seeed_lora_e5.c - ..\..\..\src\ewf_adapter_seeed_lora_e5.h ..\..\..\src\ewf_adapter_sequans.c ..\..\..\src\ewf_adapter_sequans.h - ..\..\..\src\ewf_adapter_simcom_common.c - ..\..\..\src\ewf_adapter_simcom_common.h - ..\..\..\src\ewf_adapter_simcom_common_control.c - ..\..\..\src\ewf_adapter_simcom_common_info.c - ..\..\..\src\ewf_adapter_simcom_common_urc.c - ..\..\..\src\ewf_adapter_simcom_sim7000.c - ..\..\..\src\ewf_adapter_simcom_sim7000.h - ..\..\..\src\ewf_adapter_simcom_sim868.c - ..\..\..\src\ewf_adapter_simcom_sim868.h - ..\..\..\src\ewf_adapter_simcom_sim900.c - ..\..\..\src\ewf_adapter_simcom_sim900.h - ..\..\..\src\ewf_adapter_thales_common.c - ..\..\..\src\ewf_adapter_thales_common.h - ..\..\..\src\ewf_adapter_thales_common_context.c - ..\..\..\src\ewf_adapter_thales_common_control.c - ..\..\..\src\ewf_adapter_thales_common_ffs.c - ..\..\..\src\ewf_adapter_thales_common_info.c - ..\..\..\src\ewf_adapter_thales_common_internet.c - ..\..\..\src\ewf_adapter_thales_common_tokenizer.c - ..\..\..\src\ewf_adapter_thales_common_urc.c - ..\..\..\src\ewf_adapter_thales_exs82_w.c - ..\..\..\src\ewf_adapter_thales_exs82_w.h - ..\..\..\src\ewf_adapter_winsock2.c - ..\..\..\src\ewf_adapter_winsock2.h ..\..\..\src\ewf_allocator.c ..\..\..\src\ewf_allocator.h - ..\..\..\src\ewf_allocator_c_heap.c - ..\..\..\src\ewf_allocator_c_heap.h - ..\..\..\src\ewf_allocator_memory_pool.c - ..\..\..\src\ewf_allocator_memory_pool.h - ..\..\..\src\ewf_allocator_netx.c - ..\..\..\src\ewf_allocator_netx.h ..\..\..\src\ewf_allocator_threadx.c ..\..\..\src\ewf_allocator_threadx.h ..\..\..\src\ewf_ids.h ..\..\..\src\ewf_interface.c ..\..\..\src\ewf_interface.h - ..\..\..\src\ewf_interface_linux_serial.c - ..\..\..\src\ewf_interface_lpc_uart.c - ..\..\..\src\ewf_interface_lpc_uart.h - ..\..\..\src\ewf_interface_microchip_pic_uart.c - ..\..\..\src\ewf_interface_microchip_pic_uart.h - ..\..\..\src\ewf_interface_microchip_sam_uart.c - ..\..\..\src\ewf_interface_microchip_sam_uart.h - ..\..\..\src\ewf_interface_ra_uart.c - ..\..\..\src\ewf_interface_ra_uart.h ..\..\..\src\ewf_interface_rx_uart.c ..\..\..\src\ewf_interface_rx_uart.h - ..\..\..\src\ewf_interface_stm32_uart.c - ..\..\..\src\ewf_interface_stm32_uart.h - ..\..\..\src\ewf_interface_win32_com.c - ..\..\..\src\ewf_interface_win32_com.h ..\..\..\src\ewf_lib.c ..\..\..\src\ewf_lib.h ..\..\..\src\ewf_message.h ..\..\..\src\ewf_middleware_netxduo.c ..\..\..\src\ewf_middleware_netxduo.h - ..\..\..\src\ewf_netxduo_ppp.c - ..\..\..\src\ewf_netxduo_ppp.h ..\..\..\src\ewf_platform.h - ..\..\..\src\ewf_platform_bare_metal.c - ..\..\..\src\ewf_platform_bare_metal.h - ..\..\..\src\ewf_platform_freertos.c - ..\..\..\src\ewf_platform_freertos.h - ..\..\..\src\ewf_platform_pthread.c - ..\..\..\src\ewf_platform_pthread.h ..\..\..\src\ewf_platform_threadx.c ..\..\..\src\ewf_platform_threadx.h - ..\..\..\src\ewf_platform_win32.c - ..\..\..\src\ewf_platform_win32.h ..\..\..\src\ewf_tokenizer.h - - ..\..\..\src\examples\ewf_example_azure_iot_pnp_provisioning.c - ..\..\..\src\examples\ewf_example_azure_iot_provisioning.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg95.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg96.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz014.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz024a.c - ..\..\..\src\examples\ewf_example_certs_basic_winsock2.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.h - ..\..\..\src\examples\ewf_example_netx_duo_test.c - ..\..\..\src\examples\ewf_example_netx_duo_test.h - ..\..\..\src\examples\ewf_example_telemetry.c - ..\..\..\src\examples\ewf_example_telemetry_basic.c - - - ..\..\..\src\test\ewf_adapter_bsd_sockets_test.c - ..\..\..\src\test\ewf_adapter_espressif_common_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8266_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8285_test.c - ..\..\..\src\test\ewf_adapter_espressif_wroom_02_test.c - ..\..\..\src\test\ewf_adapter_mxchip_common_test.c - ..\..\..\src\test\ewf_adapter_mxchip_emw3080b_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg95_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg96_test.c - ..\..\..\src\test\ewf_adapter_quectel_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz014_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz024a_test.c - ..\..\..\src\test\ewf_adapter_simcom_common_test.c - ..\..\..\src\test\ewf_adapter_simcom_sim7000_test.c - ..\..\..\src\test\ewf_adapter_test.c - ..\..\..\src\test\ewf_adapter_test.h - ..\..\..\src\test\ewf_adapter_thales_common_test.c - ..\..\..\src\test\ewf_adapter_thales_exs82_w_test.c - ..\..\..\src\test\ewf_adapter_winsock2_test.c - @@ -2145,6 +2007,8 @@ src\demo_printf.c src\demo_printf.h src\ewf.config.h + src\ewf_cellular_config.h + src\ewf_cellular_private.h src\ewf_example.config.h src\hardware_setup.c src\hardware_setup.h @@ -2328,6 +2192,21 @@ + + + + + trash\2023-03-10-14-28-51\libs\filex\fx_user.h + + + trash\2023-03-10-14-28-51\libs\netxduo\nx_user.h + + + trash\2023-03-10-14-28-51\libs\threadx\tx_user.h + + + + R5F565NEHxFB @@ -2337,55 +2216,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2402,16 +2281,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -3908,159 +3787,62 @@ HardwareDebug\sample_azure_iot_embedded_sdk.obj HardwareDebug\sample_azure_iot_embedded_sdk_connect.obj - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4080,395 +3862,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4483,60 +3925,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4551,60 +3993,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4619,60 +4061,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4687,60 +4129,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4755,60 +4197,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4823,60 +4265,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4891,60 +4333,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4959,60 +4401,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5027,60 +4469,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5095,60 +4537,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5163,60 +4605,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5231,60 +4673,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5299,60 +4741,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5367,60 +4809,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5435,60 +4877,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5503,60 +4945,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5571,60 +5013,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5639,60 +5081,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5707,60 +5149,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5775,60 +5217,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5843,60 +5285,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5911,60 +5353,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5979,60 +5421,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6047,60 +5489,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6115,60 +5557,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6183,60 +5625,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6251,60 +5693,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6319,60 +5761,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6392,55 +5834,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6455,60 +5897,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6523,60 +5965,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6596,55 +6038,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6659,60 +6101,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6727,60 +6169,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6795,60 +6237,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6868,191 +6310,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7067,60 +6373,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7135,60 +6441,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7203,60 +6509,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7271,60 +6577,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7339,60 +6645,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7407,60 +6713,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7475,60 +6781,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7543,60 +6849,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7616,55 +6922,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7679,60 +6985,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7747,60 +7053,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7815,60 +7121,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7883,60 +7189,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7951,60 +7257,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8019,60 +7325,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8087,60 +7393,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8155,60 +7461,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8223,60 +7529,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8291,60 +7597,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8359,60 +7665,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8427,60 +7733,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8495,60 +7801,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8563,60 +7869,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8631,60 +7937,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8699,60 +8005,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8767,60 +8073,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8835,60 +8141,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8903,60 +8209,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8971,60 +8277,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9039,60 +8345,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9107,60 +8413,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9175,60 +8481,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9243,60 +8549,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9311,60 +8617,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9379,60 +8685,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9447,60 +8753,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9520,55 +8826,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9583,60 +8889,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9651,60 +8957,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9719,60 +9025,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9787,60 +9093,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9855,60 +9161,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9923,60 +9229,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9991,60 +9297,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10059,60 +9365,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10127,60 +9433,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10195,60 +9501,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10263,60 +9569,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10331,60 +9637,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10399,60 +9705,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10467,60 +9773,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10535,60 +9841,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10603,60 +9909,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10671,60 +9977,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10739,60 +10045,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10807,60 +10113,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10875,60 +10181,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10943,60 +10249,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11011,60 +10317,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11079,60 +10385,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11147,60 +10453,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11215,60 +10521,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11283,60 +10589,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11351,60 +10657,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11419,60 +10725,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11487,60 +10793,60 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11555,19372 +10861,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -30936,65 +10930,65 @@ - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\ewf" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\ewf\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_config\" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_skeleton\" - "C:\t-comms\comms_framework\src" - "C:\t-comms\comms_framework\src\examples" - "C:\t-comms\comms_framework\src\test" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\utility\low_power" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure-sdk-for-c\sdk\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc\configs\RTOS_BASE" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\deps\flatcc\include" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\cloud" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\dhcp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\dns" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\http" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\mqtt" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\nat" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\smtp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\snmp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\sntp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\web" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\crypto_libraries\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\nx_secure\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\nx_secure\ports" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\utility\iperf" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex\ports\generic\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\ewf" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\ewf\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_config\" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_skeleton\" + "C:\embedded0310_2\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\examples" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\test" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\utility\low_power" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure-sdk-for-c\sdk\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc\configs\RTOS_BASE" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\deps\flatcc\include" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\cloud" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\dhcp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\dns" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\http" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\mqtt" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\nat" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\smtp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\snmp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\sntp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\web" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\crypto_libraries\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\nx_secure\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\nx_secure\ports" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\utility\iperf" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex\ports\generic\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" NX_ENABLE_TCPIP_OFFLOAD NX_ENABLE_INTERFACE_CAPABILITY NX_DNS_CLIENT_USER_CREATE_PACKET_POOL diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg index ddffaa9d..e438bfd1 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg @@ -497,14 +497,14 @@ - - + + - + @@ -655,10 +655,10 @@ - - - - + + + + @@ -700,13 +700,13 @@ - + - + @@ -765,26 +765,26 @@ - + - + - + - + @@ -925,7 +925,7 @@ - + @@ -970,7 +970,7 @@ - + @@ -994,7 +994,7 @@ - + @@ -1043,11 +1043,11 @@ - + - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_cellular_config.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_cellular_config.h new file mode 100644 index 00000000..42d6d9a6 --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_cellular_config.h @@ -0,0 +1,105 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_config.h + * Description : Cellular-related config files such as pmod terminal and APN. + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_CONFIG_H +#define EWF_CELLULAR_CONFIG_H + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ + + +/* Specify uart ch used for communication with cellular module */ +#define EWF_CELLULAR_CFG_UART_SCI_CH (6) + +/* Specify the port and pin of the RTS terminal */ +#define EWF_CELLULAR_CFG_RTS_PORT 0 +#define EWF_CELLULAR_CFG_RTS_PIN 2 + +/* Specify the port and pin of the RESET terminal */ +#define EWF_CELLULAR_CFG_RESET_PORT 5 +#define EWF_CELLULAR_CFG_RESET_PIN 5 + + +/* Changes the output format of the reset signal sent to the Cellular module. */ +/* 1: active high 0: active low */ +#define EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC (1) + +/* Sets the RTS pin control method of the Cellular module. */ +/* 0: The CTS pin is controlled by hardware flow control, and the RTS pin is controlled by this FIT module through GPIO. */ +/* 1: The RTS pin is controlled by hardware flow control, and the CTS pin is controlled by this FIT module through GPIO. */ +#define EWF_CELLULAR_CFG_CTS_SW_CTRL (0) //unused + +/* Specify the port and pin of the CTC */ +#define EWF_CELLULAR_CFG_CTS_PORT 2 //unused +#define EWF_CELLULAR_CFG_CTS_PIN 2 //unused + + +/* Specifies the pin function control register (PFS) setting value */ +/* to select the peripheral function of the MCU pin used to control the RTS pin of */ +/* the Cellular module. Set this option to match the pin to be used. */ +/* This option takes effect when EWF_CELLULAR_CFG_CTS_SW_CTRL is set to 1. */ +#define EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU //unused + +/* Specify IRQ terminal for RING terminal */ +#define EWF_CELLULAR_CFG_IRQ_NUM (4) //unused + +/* The SIM PIN for the modem */ +#define EWF_CONFIG_SIM_PIN ("0000") + +/* The SIM operator APN */ +#define EWF_CONFIG_SIM_APN ("globaldata.iot") + +/* The modem context ID used */ +#define EWF_CONFIG_CONTEXT_ID (1) +/* Board dependent settings; please use the value for each setting listed below depending on the board you use. + +Preprocessors that define board dependent settings and the corresponding values to be set are as follows: +Confirmed board number 1, +EWF_CELLULAR_CFG_UART_SCI_CH 6, +EWF_CELLULAR_CFG_RTS_PORT 0, +EWF_CELLULAR_CFG_RTS_PIN 2, +EWF_CELLULAR_CFG_RESET_PORT 5, +EWF_CELLULAR_CFG_RESET_PIN 5, +EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC 1, +EWF_CELLULAR_CFG_CTS_SW_CTRL 0, +EWF_CELLULAR_CFG_CTS_PORT 2, +EWF_CELLULAR_CFG_CTS_PIN 2, +EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU, +EWF_CELLULAR_CFG_IRQ_NUM 4, +EWF_CONFIG_SIM_PIN "0000", +EWF_CONFIG_SIM_APN "globaldata.iot", +EWF_CONFIG_CONTEXT_ID 1 + +where the confirmed board numbers listed in the first row above are as follows: +1: CK-RX65N (PMOD1), +In the above preprocessor list, please use one of the values listed on the right side. +On the right side, each column corresponds to each confirmed board number. + +Note: +Please supply power source to USB(CN4) port on RYZ014A/RYZ024A-PMOD. +E2 emulator supplying power to RYZ014A/RYZ024A-PMOD may result in insufficient power source. +The E2 emulator can provide 200mA, but RYZ014A/RYZ024A needs more current while connecting to the network. + +*/ +#endif /* EWF_CELLULAR_CONFIG_H */ diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_cellular_private.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_cellular_private.h new file mode 100644 index 00000000..d4c7c4bb --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_cellular_private.h @@ -0,0 +1,169 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_private.h + * Description : Macro for controlling the pmod terminal + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_PRIVATE_H_ +#define EWF_CELLULAR_PRIVATE_H_ + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ +#include "r_sci_rx_if.h" +#include "r_sci_rx_pinset.h" +#include "ewf_cellular_config.h" + + +/* PDR port macros. */ +#define EWF_CELLULAR_SET_PDR(x, y) (EWF_CELLULAR_SET_PDR_PREPROC(x, y)) +/* Set the port direction. */ +#define EWF_CELLULAR_SET_PDR_PREPROC(x, y) ((PORT ## x .PDR.BIT.B ## y)) + +/* PODR port macros. */ +#define EWF_CELLULAR_SET_PODR(x, y) (EWF_CELLULAR_SET_PODR_PREPROC(x, y)) +/* Set the port I/O. */ +#define EWF_CELLULAR_SET_PODR_PREPROC(x, y) ((PORT ## x .PODR.BIT.B ## y)) + +#define EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT (1) + +/* Changes the output format of the reset signal sent to the Cellular module. */ +#if EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC == 1 +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (1) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (0) +#else +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (0) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (1) +#endif + + +#ifndef EWF_CELLULAR_CFG_UART_SCI_CH +#error "Error! Need to define EWF_CELLULAR_CFG_UART_SCI_CH in ewf_cellular_config.h" +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (0) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI0() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI0()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH0) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH0_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH0_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (1) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI1() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI1()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH1) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH1_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH1_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (2) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI2() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI2()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH2) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH2_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH2_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (3) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI3() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI3()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH3) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH3_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH3_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (4) +/* Store R_SCI_PinSet_SCI4() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI4()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH4) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH4_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH4_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (5) +/* Store R_SCI_PinSet_SCI5() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI5()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH5) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH5_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH5_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (6) +/* Store R_SCI_PinSet_SCI6() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI6()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH6) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH6_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH6_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (7) +/* Store R_SCI_PinSet_SCI7() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI7()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH7) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH7_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH7_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (8) +/* Store R_SCI_PinSet_SCI8() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI8()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH8) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH8_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH8_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (9) +/* Store R_SCI_PinSet_SCI9() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI9()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH9) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH9_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH9_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (10) +/* Store R_SCI_PinSet_SCI10() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI10()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH10) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH10_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH10_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (11) +/* Store R_SCI_PinSet_SCI11() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI11()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH11) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH11_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH11_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (12) +/* Store R_SCI_PinSet_SCI12() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI12()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH12) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH12_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH12_RX_BUFSIZ) +#else +#error "Error! Invalid setting for EWF_CELLULAR_UART_SCI_CH in ewf_cellular_config.h" +#endif /* EWF_CELLULAR_CFG_UART_SCI_CH */ + + +#if R_SCI_CFG_TX_BUFSIZE < (1500) +#error "The SCI send buffer size is too small." +#endif +#if R_SCI_CFG_RX_BUFSIZE < (1500) +#error "The SCI receive buffer size is too small." +#endif + +#endif /* EWF_CELLULAR_PRIVATE_H_ */ diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_example.config.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_example.config.h index 9726ba12..2a08db61 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_example.config.h +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/ewf_example.config.h @@ -35,23 +35,6 @@ extern "C" { /** @} *** group_example_configuration_allocator */ -/** - * @defgroup group_example_configuration_modem Modem configuration - * @brief Modem configuration settings used in examples - * @{ - */ - -/** @brief The SIM PIN for the modem */ -#define EWF_CONFIG_SIM_PIN ("0000") - -/** @brief The SIM operator APN */ -#define EWF_CONFIG_SIM_APN ("globaldata.iot") - -/** @brief The modem context ID used */ -#define EWF_CONFIG_CONTEXT_ID (1) - -/** @} *** group_example_configuration_modem */ - /** * @defgroup group_example_configuration_iot_hub IoT Hub configuration * @brief IoT Hub configuration settings used in examples diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/rtos_skeleton/application_thread_entry.c b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/rtos_skeleton/application_thread_entry.c index 7540ac33..6b1cde27 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/rtos_skeleton/application_thread_entry.c +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/src/rtos_skeleton/application_thread_entry.c @@ -49,6 +49,8 @@ Includes , "Project Includes" #include "ewf_example.config.h" +#include "ewf_cellular_private.h" + /* Modem might take some minutes to attach and register to the network. Time out value in seconds */ #define EWF_ADAPTER_RENESAS_NETWORK_REGISTER_TIMEOUT (1200) @@ -153,10 +155,10 @@ void application_thread_entry(ULONG entry_input) // Release the RYZ014A from reset - PORTA.PODR.BIT.B1= 1; - PORTA.PDR.BIT.B1= 1; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_ON; + EWF_CELLULAR_SET_PDR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT; tx_thread_sleep (200); - PORTA.PODR.BIT.B1= 0; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_OFF; printf("Waiting for the module to Power Reset!\r\n"); ewf_platform_sleep(300); printf("Ready\r\n"); diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.cproject b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.cproject index 0daa69fc..e9ab0ef8 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.cproject +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.cproject @@ -1656,42 +1656,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.project b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.project index 008065b2..793b280a 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.project +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/.project @@ -7,7 +7,6 @@ com.renesas.smc.ui.pgsupport.SCContentBuilder - @@ -41,6 +40,362 @@ PARENT-3-PROJECT_LOC/src + + + 1677586370931 + ewf + 14 + + org.eclipse.ui.ide.notFilterMatcher + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_control.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_dtls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-ewf_adapter_api_gnss.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_http.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_info.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_general.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_network_service.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-ewf_adapter_api_modem_network_service.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_packet_domain.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sim_utility.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_sms.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem_types.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_modem.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_mqtt.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_ntp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tcp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls_basic.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_tls.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_udp.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_api_wifi_station.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_control.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_info.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_internet.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_mqtt_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_nvm.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_tls_basic.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common_urc.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_common.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz014.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_renesas_ryz024a.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter_sequans.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_adapter.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_allocator.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_ids.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_message.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_tokenizer.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface_rx_uart.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_interface.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_lib.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_message.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_middleware_netxduo.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.c + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform_threadx.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_platform.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf_tokenizer.h + + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-true-false-ewf.h + + + + + SMC_GENERATED_LOC diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014 HardwareDebug.launch b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014 HardwareDebug.launch index 96c579b7..fa94d45b 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014 HardwareDebug.launch +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014 HardwareDebug.launch @@ -29,7 +29,7 @@ - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.rcpc b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.rcpc index deae8174..397418ea 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.rcpc +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.rcpc @@ -19,8 +19,6 @@ ..\..\..\src\ewf_adapter_api_http.h ..\..\..\src\ewf_adapter_api_info.c ..\..\..\src\ewf_adapter_api_info.h - ..\..\..\src\ewf_adapter_api_lora.c - ..\..\..\src\ewf_adapter_api_lora.h ..\..\..\src\ewf_adapter_api_modem.c ..\..\..\src\ewf_adapter_api_modem.h ..\..\..\src\ewf_adapter_api_modem_general.c @@ -47,50 +45,8 @@ ..\..\..\src\ewf_adapter_api_tls_basic.h ..\..\..\src\ewf_adapter_api_udp.c ..\..\..\src\ewf_adapter_api_udp.h - ..\..\..\src\ewf_adapter_api_wifi_ap.c - ..\..\..\src\ewf_adapter_api_wifi_ap.h ..\..\..\src\ewf_adapter_api_wifi_station.c ..\..\..\src\ewf_adapter_api_wifi_station.h - ..\..\..\src\ewf_adapter_bsd_sockets.c - ..\..\..\src\ewf_adapter_bsd_sockets.h - ..\..\..\src\ewf_adapter_espressif_common.c - ..\..\..\src\ewf_adapter_espressif_common.h - ..\..\..\src\ewf_adapter_espressif_common_control.c - ..\..\..\src\ewf_adapter_espressif_common_info.c - ..\..\..\src\ewf_adapter_espressif_common_internet.c - ..\..\..\src\ewf_adapter_espressif_common_urc.c - ..\..\..\src\ewf_adapter_espressif_common_wifi_station.c - ..\..\..\src\ewf_adapter_espressif_esp8266.c - ..\..\..\src\ewf_adapter_espressif_esp8266.h - ..\..\..\src\ewf_adapter_espressif_esp8285.c - ..\..\..\src\ewf_adapter_espressif_esp8285.h - ..\..\..\src\ewf_adapter_espressif_wroom_02.c - ..\..\..\src\ewf_adapter_espressif_wroom_02.h - ..\..\..\src\ewf_adapter_mxchip_common.c - ..\..\..\src\ewf_adapter_mxchip_common.h - ..\..\..\src\ewf_adapter_mxchip_common_control.c - ..\..\..\src\ewf_adapter_mxchip_common_info.c - ..\..\..\src\ewf_adapter_mxchip_common_internet.c - ..\..\..\src\ewf_adapter_mxchip_common_tokenizer.c - ..\..\..\src\ewf_adapter_mxchip_common_urc.c - ..\..\..\src\ewf_adapter_mxchip_common_wifi_station.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.c - ..\..\..\src\ewf_adapter_mxchip_emw3080b.h - ..\..\..\src\ewf_adapter_quectel_bg95.c - ..\..\..\src\ewf_adapter_quectel_bg95.h - ..\..\..\src\ewf_adapter_quectel_bg96.c - ..\..\..\src\ewf_adapter_quectel_bg96.h - ..\..\..\src\ewf_adapter_quectel_common.c - ..\..\..\src\ewf_adapter_quectel_common.h - ..\..\..\src\ewf_adapter_quectel_common_context.c - ..\..\..\src\ewf_adapter_quectel_common_control.c - ..\..\..\src\ewf_adapter_quectel_common_info.c - ..\..\..\src\ewf_adapter_quectel_common_internet.c - ..\..\..\src\ewf_adapter_quectel_common_mqtt_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tls_basic.c - ..\..\..\src\ewf_adapter_quectel_common_tokenizer.c - ..\..\..\src\ewf_adapter_quectel_common_ufs.c - ..\..\..\src\ewf_adapter_quectel_common_urc.c ..\..\..\src\ewf_adapter_renesas_common.c ..\..\..\src\ewf_adapter_renesas_common.h ..\..\..\src\ewf_adapter_renesas_common_control.c @@ -104,120 +60,26 @@ ..\..\..\src\ewf_adapter_renesas_ryz014.h ..\..\..\src\ewf_adapter_renesas_ryz024a.c ..\..\..\src\ewf_adapter_renesas_ryz024a.h - ..\..\..\src\ewf_adapter_seeed_lora_e5.c - ..\..\..\src\ewf_adapter_seeed_lora_e5.h ..\..\..\src\ewf_adapter_sequans.c ..\..\..\src\ewf_adapter_sequans.h - ..\..\..\src\ewf_adapter_simcom_common.c - ..\..\..\src\ewf_adapter_simcom_common.h - ..\..\..\src\ewf_adapter_simcom_common_control.c - ..\..\..\src\ewf_adapter_simcom_common_info.c - ..\..\..\src\ewf_adapter_simcom_common_urc.c - ..\..\..\src\ewf_adapter_simcom_sim7000.c - ..\..\..\src\ewf_adapter_simcom_sim7000.h - ..\..\..\src\ewf_adapter_simcom_sim868.c - ..\..\..\src\ewf_adapter_simcom_sim868.h - ..\..\..\src\ewf_adapter_simcom_sim900.c - ..\..\..\src\ewf_adapter_simcom_sim900.h - ..\..\..\src\ewf_adapter_thales_common.c - ..\..\..\src\ewf_adapter_thales_common.h - ..\..\..\src\ewf_adapter_thales_common_context.c - ..\..\..\src\ewf_adapter_thales_common_control.c - ..\..\..\src\ewf_adapter_thales_common_ffs.c - ..\..\..\src\ewf_adapter_thales_common_info.c - ..\..\..\src\ewf_adapter_thales_common_internet.c - ..\..\..\src\ewf_adapter_thales_common_tokenizer.c - ..\..\..\src\ewf_adapter_thales_common_urc.c - ..\..\..\src\ewf_adapter_thales_exs82_w.c - ..\..\..\src\ewf_adapter_thales_exs82_w.h - ..\..\..\src\ewf_adapter_winsock2.c - ..\..\..\src\ewf_adapter_winsock2.h ..\..\..\src\ewf_allocator.c ..\..\..\src\ewf_allocator.h - ..\..\..\src\ewf_allocator_c_heap.c - ..\..\..\src\ewf_allocator_c_heap.h - ..\..\..\src\ewf_allocator_memory_pool.c - ..\..\..\src\ewf_allocator_memory_pool.h - ..\..\..\src\ewf_allocator_netx.c - ..\..\..\src\ewf_allocator_netx.h ..\..\..\src\ewf_allocator_threadx.c ..\..\..\src\ewf_allocator_threadx.h ..\..\..\src\ewf_ids.h ..\..\..\src\ewf_interface.c ..\..\..\src\ewf_interface.h - ..\..\..\src\ewf_interface_linux_serial.c - ..\..\..\src\ewf_interface_lpc_uart.c - ..\..\..\src\ewf_interface_lpc_uart.h - ..\..\..\src\ewf_interface_microchip_pic_uart.c - ..\..\..\src\ewf_interface_microchip_pic_uart.h - ..\..\..\src\ewf_interface_microchip_sam_uart.c - ..\..\..\src\ewf_interface_microchip_sam_uart.h - ..\..\..\src\ewf_interface_ra_uart.c - ..\..\..\src\ewf_interface_ra_uart.h ..\..\..\src\ewf_interface_rx_uart.c ..\..\..\src\ewf_interface_rx_uart.h - ..\..\..\src\ewf_interface_stm32_uart.c - ..\..\..\src\ewf_interface_stm32_uart.h - ..\..\..\src\ewf_interface_win32_com.c - ..\..\..\src\ewf_interface_win32_com.h ..\..\..\src\ewf_lib.c ..\..\..\src\ewf_lib.h ..\..\..\src\ewf_message.h ..\..\..\src\ewf_middleware_netxduo.c ..\..\..\src\ewf_middleware_netxduo.h - ..\..\..\src\ewf_netxduo_ppp.c - ..\..\..\src\ewf_netxduo_ppp.h ..\..\..\src\ewf_platform.h - ..\..\..\src\ewf_platform_bare_metal.c - ..\..\..\src\ewf_platform_bare_metal.h - ..\..\..\src\ewf_platform_freertos.c - ..\..\..\src\ewf_platform_freertos.h - ..\..\..\src\ewf_platform_pthread.c - ..\..\..\src\ewf_platform_pthread.h ..\..\..\src\ewf_platform_threadx.c ..\..\..\src\ewf_platform_threadx.h - ..\..\..\src\ewf_platform_win32.c - ..\..\..\src\ewf_platform_win32.h ..\..\..\src\ewf_tokenizer.h - - ..\..\..\src\examples\ewf_example_azure_iot_pnp_provisioning.c - ..\..\..\src\examples\ewf_example_azure_iot_provisioning.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg95.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_bg96.c - ..\..\..\src\examples\ewf_example_certs_basic_quectel_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_common.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz014.c - ..\..\..\src\examples\ewf_example_certs_basic_renesas_ryz024a.c - ..\..\..\src\examples\ewf_example_certs_basic_winsock2.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.c - ..\..\..\src\examples\ewf_example_netx_duo_ppp_test.h - ..\..\..\src\examples\ewf_example_netx_duo_test.c - ..\..\..\src\examples\ewf_example_netx_duo_test.h - ..\..\..\src\examples\ewf_example_telemetry.c - ..\..\..\src\examples\ewf_example_telemetry_basic.c - - - ..\..\..\src\test\ewf_adapter_bsd_sockets_test.c - ..\..\..\src\test\ewf_adapter_espressif_common_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8266_test.c - ..\..\..\src\test\ewf_adapter_espressif_esp8285_test.c - ..\..\..\src\test\ewf_adapter_espressif_wroom_02_test.c - ..\..\..\src\test\ewf_adapter_mxchip_common_test.c - ..\..\..\src\test\ewf_adapter_mxchip_emw3080b_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg95_test.c - ..\..\..\src\test\ewf_adapter_quectel_bg96_test.c - ..\..\..\src\test\ewf_adapter_quectel_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_common_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz014_test.c - ..\..\..\src\test\ewf_adapter_renesas_ryz024a_test.c - ..\..\..\src\test\ewf_adapter_simcom_common_test.c - ..\..\..\src\test\ewf_adapter_simcom_sim7000_test.c - ..\..\..\src\test\ewf_adapter_test.c - ..\..\..\src\test\ewf_adapter_test.h - ..\..\..\src\test\ewf_adapter_thales_common_test.c - ..\..\..\src\test\ewf_adapter_thales_exs82_w_test.c - ..\..\..\src\test\ewf_adapter_winsock2_test.c - @@ -2145,6 +2007,8 @@ src\demo_printf.c src\demo_printf.h src\ewf.config.h + src\ewf_cellular_config.h + src\ewf_cellular_private.h src\ewf_example.config.h src\hardware_setup.c src\hardware_setup.h @@ -2333,6 +2197,21 @@ + + + + + trash\2023-03-10-14-43-29\libs\filex\fx_user.h + + + trash\2023-03-10-14-43-29\libs\netxduo\nx_user.h + + + trash\2023-03-10-14-43-29\libs\threadx\tx_user.h + + + + R5F565NEHxFB @@ -2342,53 +2221,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2405,16 +2284,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -3914,161 +3793,64 @@ HardwareDebug\nx_secure_verify_mac.obj HardwareDebug\nxe_secure_tls_session_packet_pool_set.obj - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_config\" - "C:\t-comms\comms_framework\src" - "C:\t-comms\comms_framework\src\examples" - "C:\t-comms\comms_framework\src\test" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\rtos_skeleton\" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\threadx\utility\low_power" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure-sdk-for-c\sdk\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc\configs\RTOS_BASE" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\deps\flatcc\include" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\cloud" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\dhcp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\dns" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\http" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\mqtt" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\nat" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\smtp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\snmp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\sntp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\addons\web" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\crypto_libraries\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\nx_secure\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\nx_secure\ports" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo_addons\utility\iperf" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo\ports\rxv2\ccrx\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\netxduo\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex\common\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\libs\filex\ports\generic\inc" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\general" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_pincfg" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_bsp" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_config" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_cmt_rx\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_byteq\src" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx" - "${ProjDirPath}\..\..\..\..\..\Users\bhnaphad\e2_studio\CK-RX65N-CCRX\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_config\" + "C:\embedded0310_2\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\examples" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\ewf\test" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\rtos_skeleton\" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\threadx\utility\low_power" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure-sdk-for-c\sdk\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\inc\configs\RTOS_BASE" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\azure_iot\azure_iot_security_module\iot-security-module-core\deps\flatcc\include" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\cloud" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\dhcp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\dns" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\http" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\mqtt" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\nat" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\smtp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\snmp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\sntp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\addons\web" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\crypto_libraries\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\nx_secure\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\nx_secure\ports" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo_addons\utility\iperf" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo\ports\rxv2\ccrx\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\netxduo\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex\common\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\libs\filex\ports\generic\inc" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\general" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_pincfg" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_bsp" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_config" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_cmt_rx\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_byteq\src" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx" + "${ProjDirPath}\..\..\..\..\w32\${ProjName}\src\smc_gen\r_sci_rx\src" NX_INCLUDE_USER_DEFINE_FILE TX_INCLUDE_USER_DEFINE_FILE NX_ENABLE_TCPIP_OFFLOAD diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.scfg b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.scfg index 53032eba..fe417837 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.scfg +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014.scfg @@ -497,14 +497,14 @@ - - + + - + @@ -655,10 +655,10 @@ - - - - + + + + @@ -700,13 +700,13 @@ - + - + @@ -765,26 +765,26 @@ - + - + - + - + @@ -925,11 +925,11 @@ - + - + @@ -974,7 +974,7 @@ - + @@ -1155,7 +1155,7 @@ - + @@ -1204,7 +1204,7 @@ - + diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_cellular_config.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_cellular_config.h new file mode 100644 index 00000000..42d6d9a6 --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_cellular_config.h @@ -0,0 +1,105 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_config.h + * Description : Cellular-related config files such as pmod terminal and APN. + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_CONFIG_H +#define EWF_CELLULAR_CONFIG_H + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ + + +/* Specify uart ch used for communication with cellular module */ +#define EWF_CELLULAR_CFG_UART_SCI_CH (6) + +/* Specify the port and pin of the RTS terminal */ +#define EWF_CELLULAR_CFG_RTS_PORT 0 +#define EWF_CELLULAR_CFG_RTS_PIN 2 + +/* Specify the port and pin of the RESET terminal */ +#define EWF_CELLULAR_CFG_RESET_PORT 5 +#define EWF_CELLULAR_CFG_RESET_PIN 5 + + +/* Changes the output format of the reset signal sent to the Cellular module. */ +/* 1: active high 0: active low */ +#define EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC (1) + +/* Sets the RTS pin control method of the Cellular module. */ +/* 0: The CTS pin is controlled by hardware flow control, and the RTS pin is controlled by this FIT module through GPIO. */ +/* 1: The RTS pin is controlled by hardware flow control, and the CTS pin is controlled by this FIT module through GPIO. */ +#define EWF_CELLULAR_CFG_CTS_SW_CTRL (0) //unused + +/* Specify the port and pin of the CTC */ +#define EWF_CELLULAR_CFG_CTS_PORT 2 //unused +#define EWF_CELLULAR_CFG_CTS_PIN 2 //unused + + +/* Specifies the pin function control register (PFS) setting value */ +/* to select the peripheral function of the MCU pin used to control the RTS pin of */ +/* the Cellular module. Set this option to match the pin to be used. */ +/* This option takes effect when EWF_CELLULAR_CFG_CTS_SW_CTRL is set to 1. */ +#define EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU //unused + +/* Specify IRQ terminal for RING terminal */ +#define EWF_CELLULAR_CFG_IRQ_NUM (4) //unused + +/* The SIM PIN for the modem */ +#define EWF_CONFIG_SIM_PIN ("0000") + +/* The SIM operator APN */ +#define EWF_CONFIG_SIM_APN ("globaldata.iot") + +/* The modem context ID used */ +#define EWF_CONFIG_CONTEXT_ID (1) +/* Board dependent settings; please use the value for each setting listed below depending on the board you use. + +Preprocessors that define board dependent settings and the corresponding values to be set are as follows: +Confirmed board number 1, +EWF_CELLULAR_CFG_UART_SCI_CH 6, +EWF_CELLULAR_CFG_RTS_PORT 0, +EWF_CELLULAR_CFG_RTS_PIN 2, +EWF_CELLULAR_CFG_RESET_PORT 5, +EWF_CELLULAR_CFG_RESET_PIN 5, +EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC 1, +EWF_CELLULAR_CFG_CTS_SW_CTRL 0, +EWF_CELLULAR_CFG_CTS_PORT 2, +EWF_CELLULAR_CFG_CTS_PIN 2, +EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU, +EWF_CELLULAR_CFG_IRQ_NUM 4, +EWF_CONFIG_SIM_PIN "0000", +EWF_CONFIG_SIM_APN "globaldata.iot", +EWF_CONFIG_CONTEXT_ID 1 + +where the confirmed board numbers listed in the first row above are as follows: +1: CK-RX65N (PMOD1), +In the above preprocessor list, please use one of the values listed on the right side. +On the right side, each column corresponds to each confirmed board number. + +Note: +Please supply power source to USB(CN4) port on RYZ014A/RYZ024A-PMOD. +E2 emulator supplying power to RYZ014A/RYZ024A-PMOD may result in insufficient power source. +The E2 emulator can provide 200mA, but RYZ014A/RYZ024A needs more current while connecting to the network. + +*/ +#endif /* EWF_CELLULAR_CONFIG_H */ diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_cellular_private.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_cellular_private.h new file mode 100644 index 00000000..d4c7c4bb --- /dev/null +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_cellular_private.h @@ -0,0 +1,169 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_private.h + * Description : Macro for controlling the pmod terminal + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_PRIVATE_H_ +#define EWF_CELLULAR_PRIVATE_H_ + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ +#include "r_sci_rx_if.h" +#include "r_sci_rx_pinset.h" +#include "ewf_cellular_config.h" + + +/* PDR port macros. */ +#define EWF_CELLULAR_SET_PDR(x, y) (EWF_CELLULAR_SET_PDR_PREPROC(x, y)) +/* Set the port direction. */ +#define EWF_CELLULAR_SET_PDR_PREPROC(x, y) ((PORT ## x .PDR.BIT.B ## y)) + +/* PODR port macros. */ +#define EWF_CELLULAR_SET_PODR(x, y) (EWF_CELLULAR_SET_PODR_PREPROC(x, y)) +/* Set the port I/O. */ +#define EWF_CELLULAR_SET_PODR_PREPROC(x, y) ((PORT ## x .PODR.BIT.B ## y)) + +#define EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT (1) + +/* Changes the output format of the reset signal sent to the Cellular module. */ +#if EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC == 1 +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (1) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (0) +#else +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (0) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (1) +#endif + + +#ifndef EWF_CELLULAR_CFG_UART_SCI_CH +#error "Error! Need to define EWF_CELLULAR_CFG_UART_SCI_CH in ewf_cellular_config.h" +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (0) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI0() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI0()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH0) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH0_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH0_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (1) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI1() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI1()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH1) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH1_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH1_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (2) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI2() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI2()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH2) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH2_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH2_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (3) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI3() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI3()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH3) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH3_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH3_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (4) +/* Store R_SCI_PinSet_SCI4() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI4()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH4) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH4_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH4_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (5) +/* Store R_SCI_PinSet_SCI5() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI5()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH5) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH5_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH5_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (6) +/* Store R_SCI_PinSet_SCI6() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI6()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH6) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH6_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH6_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (7) +/* Store R_SCI_PinSet_SCI7() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI7()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH7) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH7_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH7_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (8) +/* Store R_SCI_PinSet_SCI8() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI8()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH8) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH8_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH8_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (9) +/* Store R_SCI_PinSet_SCI9() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI9()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH9) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH9_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH9_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (10) +/* Store R_SCI_PinSet_SCI10() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI10()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH10) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH10_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH10_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (11) +/* Store R_SCI_PinSet_SCI11() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI11()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH11) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH11_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH11_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (12) +/* Store R_SCI_PinSet_SCI12() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI12()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH12) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH12_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH12_RX_BUFSIZ) +#else +#error "Error! Invalid setting for EWF_CELLULAR_UART_SCI_CH in ewf_cellular_config.h" +#endif /* EWF_CELLULAR_CFG_UART_SCI_CH */ + + +#if R_SCI_CFG_TX_BUFSIZE < (1500) +#error "The SCI send buffer size is too small." +#endif +#if R_SCI_CFG_RX_BUFSIZE < (1500) +#error "The SCI receive buffer size is too small." +#endif + +#endif /* EWF_CELLULAR_PRIVATE_H_ */ diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_example.config.h b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_example.config.h index 8fd9bba6..bdc7e66b 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_example.config.h +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/ewf_example.config.h @@ -35,23 +35,6 @@ extern "C" { /** @} *** group_example_configuration_allocator */ -/** - * @defgroup group_example_configuration_modem Modem configuration - * @brief Modem configuration settings used in examples - * @{ - */ - -/** @brief The SIM PIN for the modem */ -#define EWF_CONFIG_SIM_PIN ("0000") - -/** @brief The SIM operator APN */ -#define EWF_CONFIG_SIM_APN ("globaldata.iot") - -/** @brief The modem context ID used */ -#define EWF_CONFIG_CONTEXT_ID (1) - -/** @} *** group_example_configuration_modem */ - /** * @defgroup group_example_configuration_iot_hub IoT Hub configuration * @brief IoT Hub configuration settings used in examples diff --git a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/rtos_skeleton/application_thread_entry.c b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/rtos_skeleton/application_thread_entry.c index bd402d71..1cc34f50 100644 --- a/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/rtos_skeleton/application_thread_entry.c +++ b/examples/CK_RX65N_CCRX/ewf_netx_duo_azure_sdk_pnp_temp_controller_ryz014/src/rtos_skeleton/application_thread_entry.c @@ -52,6 +52,8 @@ Includes , "Project Includes" #include "ewf_example.config.h" +#include "ewf_cellular_private.h" + /* Modem might take some minutes to attach and register to the network. Time out value in seconds */ #define EWF_ADAPTER_RENESAS_NETWORK_REGISTER_TIMEOUT (1200) @@ -150,10 +152,10 @@ void application_thread_entry(ULONG entry_input) // Release the RYZ014A from reset - PORTA.PODR.BIT.B1= 1; - PORTA.PDR.BIT.B1= 1; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_ON; + EWF_CELLULAR_SET_PDR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT; tx_thread_sleep (200); - PORTA.PODR.BIT.B1= 0; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_OFF; printf("Waiting for the module to Power Reset!\r\n"); ewf_platform_sleep(300); printf("Ready\r\n"); diff --git a/examples/CK_RX65N_GCCRX/CKRX65N_RYZ014A_RYZ024A.PNG b/examples/CK_RX65N_GCCRX/CKRX65N_RYZ014A_RYZ024A.PNG new file mode 100644 index 00000000..6215cb03 Binary files /dev/null and b/examples/CK_RX65N_GCCRX/CKRX65N_RYZ014A_RYZ024A.PNG differ diff --git a/examples/CK_RX65N_GCCRX/README.md b/examples/CK_RX65N_GCCRX/README.md index 8b7af29e..c84da359 100644 --- a/examples/CK_RX65N_GCCRX/README.md +++ b/examples/CK_RX65N_GCCRX/README.md @@ -5,21 +5,26 @@ An adapter is the device or software used to connect the application using the E An adapter can be a cellular modem, a WiFi adapter, an Ethernet adapter, a WinSock software layer, a BSD software layer or other type of device or software. The EWF API is described in the Doxygen documentation generated out of the common code. The source files of the EWF are located in the \src directory at the root of this repository. -The current set of examples use the CK-RX65N board evaluation board and a ryz014a modem. +The current set of examples use the CK-RX65N board evaluation board and a ryz014a/ryz024a modem. ## Prerequisites -- A PC running Renesas e2studio IDE. +- Get the evaluation board [CK-RX65N](https://www.renesas.com/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/ck-rx65n-cloud-kit-based-rx65n-mcu-group). +- A PC running [Renesas e2studio IDE](https://www.renesas.com/software-tool/e-studio). +- Introduce compiler Gcc for renesas rx 8.3.0.202202 or later. +- Introduce [RDP](https://www.renesas.com/software-tool/rx-driver-package) v1.37 or later. - If you don't have an Azure subscription, [create one for free](https://azure.microsoft.com/free/) before you begin. - Internet connectivity for your PC. +- Place it directly under the cloned project drive to shorten the path. Also shorten the project name (e.g c:\embedded-wireless-flamework -> c:\ewf-xxxx) ## Prepare Azure Resources Follow steps in [README_NETX_AZURE.md](README_NETX_AZURE.md) to create Azure resources that will be used to run the examples in the next steps of this document. -# Getting started - RYZ014A +# Getting started - RYZ014A/RYZ024A To get started with the examples, please follow these steps: -1. Acquire the necessary hardware and software: the Evaluation Kit CK-RX65N board, a Renesas RYZ014A PMOD, e2-studio with latest FIT modules, openssl, J-Link RTT viewer, Azure IoT Explorer. -2. Connect to RYZ014A PMOD to CK-RX65N board on PMOD2 connector. Connect Host PC via USB cable to USB Debug pin (J14) and another USB cable to USB-Serial pin (J20). Also connect micro USB cable to RYZ014A micro USB pin. +1. Acquire the necessary hardware and software: the Evaluation Kit CK-RX65N board, a Renesas RYZ014A/RYZ024A PMOD, e2-studio with latest FIT modules, openssl, J-Link RTT viewer, Azure IoT Explorer. +2. Connect to RYZ014A PMOD to CK-RX65N board on PMOD1 connector. Connect Host PC via USB cable to USB Debug pin (J14) and another USB cable to USB-Serial pin (J20). Also connect micro USB cable to RYZ014A/RYZ024A micro USB pin. +![Connection diagram of CK-RX65N and RYZ014A/RYZ024A](CKRX65N_RYZ014A_RYZ024A.PNG) 3. Review and edit as necessary the files ewf.config.h and ewf_example.config.h in the different examples. Edit these files to match your configuration. Specially edit the variables EWF_CONFIG_SIM_PIN, EWF_CONFIG_IOT_HUB_HOSTNAME, EWF_CONFIG_IOT_HUB_DEVICEID. 4. Start e2 studio and create a workspace in \examples\CK_RX65N_GCCRX cloud kit, import all the ryz014a examples into the workspace and build all examples. 5. Open Terminal at com port connection from the board and set it to 115200 8N1. @@ -68,7 +73,7 @@ Device posistioning service (ENABLE_DPS_SAMPLE) part of the examples is not test # Examples using Azure RTOS NetX Duo PPP with EWF (Modem in Data mode) 1. Acquire the necessary hardware and software: the Cloud Kit CK-RX65N, a Renesas RYZ024A PMOD, e2-studio. -2. Connect to RYZ024A PMOD to CK-RX65N board on PMOD2 connector. Connect Host PC via USB cable to USB +2. Connect to RYZ024A PMOD to CK-RX65N board on PMOD1 connector. Connect Host PC via USB cable to USB Debug pin (J14) and another USB cable to USB-Serial pin (J20). Also connect micro USB cable to RYZ024A micro USB pin. 3. Open the ewf_netx_duo_ppp_ryz024a project in e2studio and edit the ewf_example.config.h to update EWF_CONFIG_SIM_PIN and EWF_CONFIG_SIM_APN. diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/.cproject b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/.cproject index 6e65dde2..18162b39 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/.cproject +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/.cproject @@ -51,10 +51,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - + + @@ -679,7 +633,7 @@ - + @@ -689,8 +643,19 @@ + + + + + + + + + + + - + @@ -722,10 +687,10 @@ - - - - + + + + @@ -767,39 +732,91 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -918,10 +935,56 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/CMakeLists.txt b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/CMakeLists.txt index de815c28..adfcb669 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/CMakeLists.txt +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/CMakeLists.txt @@ -202,6 +202,7 @@ target_sources(${PROJECT_NAME} # Add the Common/inc directory to the project include list target_include_directories(${PROJECT_NAME} + SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc ) diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/inc/tx_api.h b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/inc/tx_api.h index af384662..9974c977 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/inc/tx_api.h +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/inc/tx_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* tx_api.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -86,6 +86,14 @@ /* optimized the definition of */ /* TX_TIMER_TICKS_PER_SECOND, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Scott Larson Modified comment(s), */ +/* update patch number, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Scott Larson Modified comment(s), */ +/* add extension macros, */ +/* update EPK typedef, */ +/* update version numbers, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -112,6 +120,9 @@ extern "C" { #include "tx_port.h" +#if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY)) +#include "tx_execution_profile.h" +#endif /* Define basic constants for the ThreadX kernel. */ @@ -121,8 +132,8 @@ extern "C" { #define AZURE_RTOS_THREADX #define THREADX_MAJOR_VERSION 6 -#define THREADX_MINOR_VERSION 1 -#define THREADX_PATCH_VERSION 11 +#define THREADX_MINOR_VERSION 2 +#define THREADX_PATCH_VERSION 0 /* Define the following symbol for backward compatibility */ #define EL_PRODUCT_THREADX @@ -220,6 +231,76 @@ extern "C" { #define TX_FEATURE_NOT_ENABLED ((UINT) 0xFF) +#ifdef TX_64_BIT + +#ifndef TX_THREAD_EXTENSION_PTR_SET +#define TX_THREAD_EXTENSION_PTR_SET(a, b) { \ + TX_THREAD *thread_ptr; \ + thread_ptr = (TX_THREAD *) (a); \ + (thread_ptr -> tx_thread_extension_ptr) = (VOID *)(b); \ + } +#endif /* TX_THREAD_EXTENSION_PTR_SET */ + +#ifndef TX_THREAD_EXTENSION_PTR_GET +#define TX_THREAD_EXTENSION_PTR_GET(a, b, c) { \ + TX_PARAMETER_NOT_USED(c); \ + TX_THREAD *thread_ptr; \ + thread_ptr = tx_thread_identify(); \ + while(1)\ + { \ + if (thread_ptr -> tx_thread_extension_ptr) \ + { \ + (a) = (b *)(thread_ptr -> tx_thread_extension_ptr); \ + break; \ + } \ + tx_thread_sleep(1); \ + } \ + } +#endif /* TX_THREAD_EXTENSION_PTR_GET */ + +#ifndef TX_TIMER_EXTENSION_PTR_SET +#define TX_TIMER_EXTENSION_PTR_SET(a, b) { \ + TX_TIMER *timer_ptr; \ + timer_ptr = (TX_TIMER *) (a); \ + (timer_ptr -> tx_timer_internal.tx_timer_internal_extension_ptr) = (VOID *)(b); \ + } +#endif /* TX_TIMER_EXTENSION_PTR_SET */ + +#ifndef TX_TIMER_EXTENSION_PTR_GET +#define TX_TIMER_EXTENSION_PTR_GET(a, b, c) { \ + TX_PARAMETER_NOT_USED(c); \ + if (!_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr) \ + return; \ + (a) = (b *)(_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr); \ + } +#endif /* TX_TIMER_EXTENSION_PTR_GET */ + +#else /* not 64 bit */ + +#ifndef TX_THREAD_EXTENSION_PTR_SET +#define TX_THREAD_EXTENSION_PTR_SET(a, b) +#endif /* TX_THREAD_EXTENSION_PTR_SET */ + +#ifndef TX_THREAD_EXTENSION_PTR_GET +#define TX_THREAD_EXTENSION_PTR_GET(a, b, c) { \ + (a) = (b *)(c); \ + } +#endif /* TX_THREAD_EXTENSION_PTR_GET */ + +#ifndef TX_TIMER_EXTENSION_PTR_SET +#define TX_TIMER_EXTENSION_PTR_SET(a, b) +#endif /* TX_TIMER_EXTENSION_PTR_SET */ + +#ifndef TX_TIMER_EXTENSION_PTR_GET +#define TX_TIMER_EXTENSION_PTR_GET(a, b, c) { \ + (a) = (b *)(c); \ + } +#endif /* TX_TIMER_EXTENSION_PTR_GET */ + +#endif /* TX_64_BIT */ + + + /* Define the common timer tick reference for use by other middleware components. The default value is 10ms, but may be replaced by a port specific version in tx_port.h or by the user as a compilation option. */ @@ -526,8 +607,8 @@ typedef struct TX_THREAD_STRUCT For Azure RTOS 6, user shall use TX_EXECUTION_PROFILE_ENABLE instead of TX_ENABLE_EXECUTION_CHANGE_NOTIFY, and SHALL NOT add variables to TX_THREAD_EXTENSION_3. */ #if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY)) - unsigned long long tx_thread_execution_time_total; - unsigned long long tx_thread_execution_time_last_start; + EXECUTION_TIME tx_thread_execution_time_total; + EXECUTION_TIME_SOURCE_TYPE tx_thread_execution_time_last_start; #endif /* Define suspension sequence number. This is used to ensure suspension is still valid when diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_event_flags_get.c b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_event_flags_get.c index aba42c6b..3cc62178 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_event_flags_get.c +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_event_flags_get.c @@ -36,7 +36,7 @@ /* FUNCTION RELEASE */ /* */ /* _tx_event_flags_get PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -79,6 +79,9 @@ /* 04-25-2022 Scott Larson Modified comment(s), */ /* handle 0 flags case, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Scott Larson Modified comment(s), always */ +/* return actual flags, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _tx_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags, @@ -125,6 +128,9 @@ UINT interrupted_set_request; /* Pickup current flags. */ current_flags = group_ptr -> tx_event_flags_group_current; + /* Return the actual event flags and apply delayed clearing. */ + *actual_flags_ptr = current_flags & ~group_ptr -> tx_event_flags_group_delayed_clear; + /* Apply the event flag option mask. */ and_request = (get_option & TX_AND); @@ -158,9 +164,6 @@ UINT interrupted_set_request; if (flags_satisfied != ((ULONG) 0)) { - /* Return the actual event flags that satisfied the request. */ - *actual_flags_ptr = current_flags; - /* Pickup the clear bit. */ clear_request = (get_option & TX_EVENT_FLAGS_CLEAR_MASK); @@ -221,9 +224,6 @@ UINT interrupted_set_request; /* Yes, this request can be handled immediately. */ - /* Return the actual event flags that satisfied the request. */ - *actual_flags_ptr = current_flags; - /* Pickup the clear bit. */ clear_request = (get_option & TX_EVENT_FLAGS_CLEAR_MASK); @@ -274,7 +274,7 @@ UINT interrupted_set_request; #endif else { - + /* flags_satisfied is 0. */ /* Determine if the request specifies suspension. */ if (wait_option != TX_NO_WAIT) { diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_trace_object_register.c b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_trace_object_register.c index da2dafcf..f76de2f4 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_trace_object_register.c +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/common/src/tx_trace_object_register.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _tx_trace_object_register PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -69,9 +69,12 @@ /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 05-19-2020 William E. Lamie Initial Version 6.0 */ -/* 09-30-2020 Yuxin Zhou Modified comment(s), */ +/* 05-19-2020 William E. Lamie Initial Version 6.0 */ +/* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Scott Larson Modified comment(s), */ +/* check for null name, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID _tx_trace_object_register(UCHAR object_type, VOID *object_ptr, CHAR *object_name, ULONG parameter_1, ULONG parameter_2) @@ -223,6 +226,12 @@ TX_TRACE_OBJECT_ENTRY *entry_ptr; work_ptr = TX_CHAR_TO_UCHAR_POINTER_CONVERT(object_name); work_ptr = TX_UCHAR_POINTER_ADD(work_ptr, i); + /* Determine if object_name (work_ptr) is null. */ + if (work_ptr == TX_NULL) + { + break; + } + /* Copy a character of the name. */ entry_ptr -> tx_trace_object_entry_name[i] = (UCHAR) *work_ptr; diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt index 5756c421..fce987a3 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt @@ -27,7 +27,8 @@ initialization code. The ThreadX demonstration for the RXv2 utilizes CMT0 as a periodic timer interrupt source. The CMT0 interrupt is typically setup for 10ms periodic interrupts and the -interrupt priority level is set to level 7. You may change any of the timer +interrupt priority level is set to level 5 with the symbol CMT_RX_CFG_IPR in +r_cmt_rx_config.h of Renesas CMT timer module(r_cmt_rx). You may change any of the timer parameters as needed. Increasing the timer interrupt frequency increases the overhead of the timer handling code on the system. @@ -41,12 +42,12 @@ sections in your linker control file. 4. Context Switch, Register Usage and Stack Frames -The RXv2 port for ThreadX uses the first software interrupt, SWINT, i.e., interrupt #17, -to perform context switch. This ISR is thus reserved when using ThreadX and the SWINT -should not be manipulated in any way by the application. The port will setup the -interrupt within _tx_initialize_low_level and the compiler will automatically install -the necessary interrupt vector. As such no additional initialization is necessary by the -application. +The RXv2 port for ThreadX uses the first software interrupt, SWINT, i.e., interrupt #27, +to perform context switch with the interrupt priority level 1. This ISR is thus reserved +when using ThreadX and the SWINT should not be manipulated in any way by the application. +The port will setup the interrupt within _tx_initialize_low_level and the compiler will +automatically install the necessary interrupt vector. As such no additional initialization +is necessary by the application. The following defines the saved context stack frame used by the ThreadX port. The state of the CPU registers at the time of a context switch is saved on the running @@ -99,17 +100,17 @@ is included. Timer processign is performed by calling __tx_timer_interrupt(). This should usually be done from within the callback of a periodic timer with a period of 100Hz. In the sample projects -a Renesas Fit CMT periodic timer module (rx_cmt) is used as the timer source. +a Renesas Fit CMT periodic timer module (r_cmt_rx) is used as the timer source. 7. Interrupt Handling Interrupt handling is unaffected by the ThreadX port as such user interrupts can be written according to the toolchain's documentation. It is recommended not to use interrupt -priority 15 as this is the priority of the context switch interrupt. However using interrupt -priority 15 won't cause any negative side effectd but doing so may may slightly reduce +priority 1 as this is the priority of the context switch interrupt. However using interrupt +priority 1 won't cause any negative side effects but doing so may slightly reduce performance. Please refer to the toolchain documentation for additional details on how to -define interupt service routines. +define interrupt service routines. 8. Execution Profiling diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/utility/low_power/low_power.md b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/utility/low_power/low_power.md index 8be714a3..ed25ccd6 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/utility/low_power/low_power.md +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/libs/threadx/utility/low_power/low_power.md @@ -8,25 +8,209 @@ ms.topic: article ms.service: rtos --- -# Low Power APIs +# ThreadX Low Power Utilities -## Summary of Low Power APIs +These low power utilities are intended to maintain ThreadX timers and the internal tick count while the processor is in a low-power/sleep state. The terms "low power" and "sleep" are used interchangeably throughout this document. -There are additional API functions available for low power, as follows: +The low power utilities may be used with any ThreadX port except SMP. -- ***tx_low_power_enter*** - *Enter low power mode* -- ***tx_low_power_exit*** - *Exit low power mode* -- ***tx_time_increment*** - *Increment ThreadX timers by specific amount* -- ***tx_timer_get_next*** - *Get next ThreadX timer expiration* +## Installation of Low Power Utilities + +The ThreadX low power utilities are comprised of two files: + + - [tx_low_power.c](tx_low_power.c) + - [tx_low_power.h](tx_low_power.h) + +These files can be built with the ThreadX library or built in the user application. + +## Detailed Description + +By default, ThreadX spins in an idle loop in the scheduler when there are no threads ready to run. It may be desireable to put the processor in a low power state while idle. Functions ```tx_low_power_enter``` and ```tx_low_power_exit``` are designed to enter and exit low power mode, respectively. + +The ```tx_low_power_enter``` and ```tx_low_power_exit``` functions manage the ThreadX timers and invoke optional macros that the user must define in order to configure the hardware for low power mode. These macros are discussed in a section below. + +For convenience, the Cortex-M and RX ports have calls to the low power APIs already integrated into their schedulers. If symbol **TX_LOW_POWER** is defined, functions ```tx_low_power_enter``` and ```tx_low_power_exit``` are called in the scheduler idle loop. It is assumed that the processor will exit sleep mode and resume execution in the idle loop (or in an interrupt and then return to the idle loop). For processors that exhibit different behavior (such as waking from sleep at the reset vector), these low power functions may need to be called elsewhere. + +### Low Power Timer and Tick-less Low Power Mode + +If accurate timekeeping is not desired while in low power mode, macros **TX_LOW_POWER_TIMER_SETUP** and **TX_LOW_POWER_TICKLESS** do not need to be defined. The internal ThreadX tick count will not reflect the time spent in low power mode. + +If **TX_LOW_POWER_TIMER_SETUP** is defined, there are two use cases for timekeeping in low power operation: +1. Keep track of elapsed time in low power mode only when ThreadX timers are active. If there are ThreadX timers active, the elapsed time while in low power mode must be measured, thus a low power hardware timer is required (this timer can be configured in **TX_LOW_POWER_TIMER_SETUP**). If there are no ThreadX timers active when entering low power mode, then no hardware timer needs to keep track of elapsed time. This is "tick-less" operation. To enable this feature, the symbol **TX_LOW_POWER_TICKLESS** must be defined. The internal ThreadX tick count will not reflect the time spent in low power mode when no ThreadX timers are active. +2. Always keep track of time in low power mode. This is necessary to keep the internal ThreadX tick count accurate. In this case, **TX_LOW_POWER_TICKLESS** must *not* be defined, as a hardware timer will always be needed in low power mode to measure elapsed time. The hardware timer is intended to be configured in **TX_LOW_POWER_TIMER_SETUP**. + +> Example 1: No low power timer is in use (**TX_LOW_POWER_TIMER_SETUP** is *not* defined). There is a ThreadX timer with 50 ticks remaining. The internal ThreadX tick count is 1000. The processor goes into low power mode for some length of time. After exiting low power mode, the ThreadX timer still has 50 ticks remaining. The internal ThreadX tick count is 1000. + +> Example 2: A low power timer is available (**TX_LOW_POWER_TIMER_SETUP** is defined). **TX_LOW_POWER_TICKLESS** is defined. There is a ThreadX timer A with 50 ticks remaining and another ThreadX timer B with 20 ticks remaining. The internal ThreadX tick count is 1000. The processor goes into low power mode for 20 ticks. Upon exiting low power mode, the ThreadX timer A will have 30 ticks remaining. The expiration function for ThreadX timer B will be executed. The internal ThreadX tick count is 1020. +After executing for some time, the internal ThreadX tick count is 2000 and there are no ThreadX timers active. The processor goes into low power mode for some length of time. After exiting low power mode, the internal ThreadX tick count is 2000. + +> Example 3: A low power timer is always used (**TX_LOW_POWER_TIMER_SETUP** is defined and **TX_LOW_POWER_TICKLESS** is *not* defined). The internal ThreadX tick count is 1000 and there are no ThreadX timers active. The processor goes into low power mode for some length of time. Upon exiting low power mode, it is determined that the processor was in low power mode for 20 ticks. The internal ThreadX tick count is updated to 1020. ---- ## User-defined Macros -- **TX_LOW_POWER_TIMER_SETUP** - an optional macro to a user routine that sets up a low power clock. To set up a low power timer or operate ticklessly in low power mode, this must be defined. This is called in **tx_low_power_enter**. -- **TX_LOW_POWER_TICKLESS** - an optional define to operate ticklessly in low power mode. Symbol **TX_LOW_POWER_TIMER_SETUP** must also be defined. With this defined, there is no need to set up a low power timer to keep track of time. ThreadX will not maintain/update the internal tick count during or after exiting low power mode. -- **TX_LOW_POWER_USER_ENTER** - an optional macro to a user routine that configures the processor for entering low power mode (e.g. turn off peripherals and select a sleep mode). This is called in **tx_low_power_enter**. -- **TX_LOW_POWER_USER_EXIT** - an optional macro to a user routine that configures the processor for exiting low power mode (e.g. turn on peripherals). This is called in **tx_low_power_exit**. -- **TX_LOW_POWER_USER_TIMER_ADJUST** - an optional user macro to determine how much time has elapsed while in low power mode (in units of ThreadX ticks). This is called in **tx_low_power_exit** to get the number of ticks needed to adjust the ThreadX timers. +The following macros invoke functions that the user may want to define/implement. + +### Summary of user-defined macros + + - ```TX_LOW_POWER_TIMER_SETUP``` - *set up low power timer* + - ```TX_LOW_POWER_USER_ENTER``` - *configure processor to enter low power mode* + - ```TX_LOW_POWER_USER_EXIT``` - *configure processor to exit low power mode* + - ```TX_LOW_POWER_USER_TIMER_ADJUST``` - *return the number of ticks the processor was in low power mode* + +--- + +### TX_LOW_POWER_TIMER_SETUP +```c +VOID TX_LOW_POWER_TIMER_SETUP(ULONG tx_low_power_next_expiration); +``` + +### Input parameters + +- *tx_low_power_next_expiration* - the number of ticks to configure the low power timer. + +### Return values + +- *none* + +**TX_LOW_POWER_TIMER_SETUP** is a macro invoking user-defined function that sets up a low power timer. To set up a low power timer or operate ticklessly in low power mode, this symbol must be defined. This macro is called in ```tx_low_power_enter```. If **TX_LOW_POWER_TICKLESS** is not defined and there are no timers active, the *tx_low_power_next_expiration* parameter will be set to 0xFFFFFFFF. + +> Note: The number of ThreadX ticks is the input to this function. The frequency of a ThreadX timer tick is defined in **TX_TIMER_TICKS_PER_SECOND** (typically defined in file tx_api.h, tx_user.h, or tx_port.h). + +> Note: do not put the processor to sleep in this macro. + +### Optional Define + +- **TX_LOW_POWER_TICKLESS** - an optional define to operate ticklessly in low power mode only if no ThreadX timers are active. With symbol **TX_LOW_POWER_TICKLESS** defined, if there are no ThreadX timers active, **TX_LOW_POWER_TIMER_SETUP** will not be called in ```tx_low_power_enter```. ThreadX will not maintain/update the internal tick count during or after exiting low power mode. Symbol **TX_LOW_POWER_TIMER_SETUP** must also be defined if defining **TX_LOW_POWER_TICKLESS**. + +### Example + +```c +/* Low power timer function prototype. */ +void low_power_timer_config(ULONG ticks); + +/* Define the TX_LOW_POWER_TIMER_SETUP macro. */ +#define TX_LOW_POWER_TIMER_SETUP low_power_timer_config + +void low_power_timer_config(ULONG ticks) +{ + /* Insert code here to configure a hardware timer + to wake the processor from sleep after + ticks/TX_TIMER_TICKS_PER_SECOND seconds. */ +} +``` + +--- + +### TX_LOW_POWER_USER_ENTER +A macro invoking a user-defined function that configures the processor for entering low power mode (e.g. turn off peripherals and select a sleep mode). This macro is called in ```tx_low_power_enter```. + +### Input parameters + +- *none* + +### Return values + +- *none* + +### Example + +```c +/* Low power enter function prototype. */ +void low_power_enter(void); + +/* Define the TX_LOW_POWER_USER_ENTER macro. */ +#define TX_LOW_POWER_USER_ENTER low_power_enter + +void low_power_enter(void) +{ + /* Insert code here to configure the processor to enter low power mode. */ +} +``` +--- + +### TX_LOW_POWER_USER_EXIT +A macro invoking a user-defined function that configures the processor for exiting low power mode (e.g. turn on peripherals). This is called in ```tx_low_power_exit```. + +### Input parameters + +- *none* + +### Return values + +- *none* + +### Example + +```c +/* Low power exit function prototype. */ +void low_power_exit(void); + +/* Define the TX_LOW_POWER_USER_EXIT macro. */ +#define TX_LOW_POWER_USER_EXIT low_power_exit + +void low_power_exit(void) +{ + /* Insert code here to configure the processor to exit low power mode. */ +} +``` + +--- + +### TX_LOW_POWER_USER_TIMER_ADJUST + +```c +ULONG TX_LOW_POWER_USER_TIMER_ADJUST(VOID); +``` + +A macro invoking a user-defined function to determine how much time has elapsed while in low power mode (in units of ThreadX ticks). This is called in ```tx_low_power_exit``` and returns the number of ticks needed to adjust the ThreadX timers. + +When exiting low power mode, there are two possibilities: + 1. The processor slept for the entire time the timer was configured to sleep. + 2. The processor was awakened early. + +### Input parameters + +- *none* + +### Return values + +- *tx_low_power_adjust_ticks* + +### Example + +```c +/* Low power timer adjust function prototype. */ +ULONG low_power_timer_adjust(void); + +/* Define the TX_LOW_POWER_USER_TIMER_ADJUST macro. */ +#define TX_LOW_POWER_USER_TIMER_ADJUST low_power_timer_adjust + +ULONG low_power_timer_adjust(void) +{ + ULONG actual_ticks_slept; + ULONG elapsed_time_in_ms; + + /* Insert code here to read timer registers to determine + how long the processor actually slept. */ + elapsed_time_in_ms = read_timer_register(); + + /* Convert elapsed time to ThreadX ticks. */ + actual_ticks_slept = elapsed_time_in_ms / (1000/TX_TIMER_TICKS_PER_SECOND); + + return(actual_ticks_slept); +} +``` + +--- + +## Summary of Low Power APIs + +- ```tx_low_power_enter``` - *Enter low power mode* +- ```tx_low_power_exit``` - *Exit low power mode* +- ```tx_time_increment``` - *Increment ThreadX timers by specific amount* +- ```tx_timer_get_next``` - *Get next ThreadX timer expiration* + +--- ## tx_low_power_enter @@ -40,26 +224,24 @@ VOID tx_low_power_enter(VOID); ### Description -This service enters low power mode. -For keeping track of time while in low power mode, there are two possibilities: +This service enters low power mode. The macros **TX_LOW_POWER_TIMER_SETUP** and **TX_LOW_POWER_USER_ENTER** are called in this function to allow the user to configure a low power timer and configure the hardware for low power mode. -1. A ThreadX timer is active. Function **tx_timer_get_next** returns **TX_TRUE**. Note that in this situation, a low power clock must be used in order to wake up the CPU for the next ThreadX timer expiration. Therefore an alternative clock must be programmed. Program the hardware timer source such that the next timer interrupt is equal to: *tx_low_power_next_expiration \* tick_frequency*. The *tick_frequency* is application-specific and typically set up in **tx_low_level_initialize**. +For keeping track of time while in low power mode, there are two possibilities: -2. There are no ThreadX timers active. Function **tx_timer_get_next** returns **TX_FALSE**. - 1. The application may choose not to keep the ThreadX internal - tick count updated (define **TX_LOW_POWER_TICKLESS**), therefore there is no need - to set up a low power clock. +1. A ThreadX timer is active. Function ```tx_timer_get_next``` returns **TX_TRUE**. Note that in this situation, a low power clock must be used in order to wake up the CPU for the next ThreadX timer expiration. Therefore a low power timer/clock must be programmed. Program the hardware timer source such that the next timer interrupt is equal to: *tx_low_power_next_expiration \* tick_frequency*. The *tick_frequency* is application-specific and typically set up in ```tx_low_level_initialize```. - 2. The application still needs to keep the ThreadX tick up-to-date. In this case - a low power clock needs to be set up. +2. There are no ThreadX timers active. Function ```tx_timer_get_next``` returns *TX_FALSE*. + 1. The application may choose **not** to keep the ThreadX internal + tick count updated (define **TX_LOW_POWER_TICKLESS**), therefore there is no need to set up a low power clock. + 2. The application still needs to keep the ThreadX tick up-to-date. In this case a low power clock needs to be configured. ### Input parameters -- **none** +- *none* ### Return values -- **none** +- *none* ### Allowed from @@ -67,7 +249,7 @@ Internal ThreadX code, application ### Example -ARM assembly +ARM Cortex-M assembly ```c #ifdef TX_LOW_POWER PUSH {r0-r3} @@ -106,15 +288,15 @@ VOID tx_low_power_exit(VOID); ### Description -This service exits low power mode. +This service exits low power mode. Macro **TX_LOW_POWER_USER_EXIT** is called in this function to allow the user to configure the hardware to exit low power mode. Macro **TX_LOW_POWER_USER_TIMER_ADJUST** is called in this function to determine how long the processor actually slept. ### Input parameters -- **none** +- *none* ### Return values -- **none** +- *none* ### Allowed from @@ -150,7 +332,7 @@ Internal ThreadX code, application ## tx_time_increment -This function increments the current time by a specified value. The value was derived by the application by calling the **tx_timer_get_next** function prior to this call, which was right before the processor was put in low power mode. +This function increments the current time by a specified value. The value was derived by the application by calling the ```tx_timer_get_next``` function prior to this call, which was right before the processor was put in low power mode. ### Prototype @@ -160,15 +342,15 @@ VOID tx_time_increment(ULONG time_increment); ### Description -This function increments the current time by a specified value. The value was derived by the application by calling the **tx_timer_get_next** function prior to this call, which was right before the processor was put in low power mode. +This function increments the current time by a specified value. The value was derived by the application by calling the ```tx_timer_get_next``` function prior to this call, which was right before the processor was put in low power mode. ### Input parameters -- **time_increment** Number of ThreadX ticks to increment time and timers. +- *time_increment* - Number of ThreadX ticks to increment time and timers. ### Return values -- **none** +- *none* ### Allowed from @@ -176,7 +358,7 @@ Internal ThreadX code, application ### Example -From **tx_low_power_exit**: +From ```tx_low_power_exit```: ```c /* Call the low-power timer driver code to obtain the amount of time (in ticks) @@ -213,16 +395,16 @@ ULONG tx_timer_get_next(ULONG *next_timer_tick_ptr); ### Description -This service gets the next ThreadX timer expiration, in ticks. +This service gets the next ThreadX timer expiration, in ticks. ### Input parameters -- **next_timer_tick_ptr** pointer to hold number of ticks +- *next_timer_tick_ptr* - pointer to hold number of ticks ### Return values -- **TX_TRUE** (1) At least one timer is active. -- **TX_FALSE** (0) No timers are currently active. +- *TX_TRUE* (1) At least one timer is active. +- *TX_FALSE* (0) No timers are currently active. ### Allowed from @@ -230,7 +412,7 @@ Internal ThreadX code, application ### Example -From **tx_low_power_enter**: +From ```tx_low_power_enter```: ```c ULONG tx_low_power_next_expiration; /* The next timer expiration (units of ThreadX timer ticks). */ diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_cellular_config.h b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_cellular_config.h new file mode 100644 index 00000000..42d6d9a6 --- /dev/null +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_cellular_config.h @@ -0,0 +1,105 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_config.h + * Description : Cellular-related config files such as pmod terminal and APN. + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_CONFIG_H +#define EWF_CELLULAR_CONFIG_H + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ + + +/* Specify uart ch used for communication with cellular module */ +#define EWF_CELLULAR_CFG_UART_SCI_CH (6) + +/* Specify the port and pin of the RTS terminal */ +#define EWF_CELLULAR_CFG_RTS_PORT 0 +#define EWF_CELLULAR_CFG_RTS_PIN 2 + +/* Specify the port and pin of the RESET terminal */ +#define EWF_CELLULAR_CFG_RESET_PORT 5 +#define EWF_CELLULAR_CFG_RESET_PIN 5 + + +/* Changes the output format of the reset signal sent to the Cellular module. */ +/* 1: active high 0: active low */ +#define EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC (1) + +/* Sets the RTS pin control method of the Cellular module. */ +/* 0: The CTS pin is controlled by hardware flow control, and the RTS pin is controlled by this FIT module through GPIO. */ +/* 1: The RTS pin is controlled by hardware flow control, and the CTS pin is controlled by this FIT module through GPIO. */ +#define EWF_CELLULAR_CFG_CTS_SW_CTRL (0) //unused + +/* Specify the port and pin of the CTC */ +#define EWF_CELLULAR_CFG_CTS_PORT 2 //unused +#define EWF_CELLULAR_CFG_CTS_PIN 2 //unused + + +/* Specifies the pin function control register (PFS) setting value */ +/* to select the peripheral function of the MCU pin used to control the RTS pin of */ +/* the Cellular module. Set this option to match the pin to be used. */ +/* This option takes effect when EWF_CELLULAR_CFG_CTS_SW_CTRL is set to 1. */ +#define EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU //unused + +/* Specify IRQ terminal for RING terminal */ +#define EWF_CELLULAR_CFG_IRQ_NUM (4) //unused + +/* The SIM PIN for the modem */ +#define EWF_CONFIG_SIM_PIN ("0000") + +/* The SIM operator APN */ +#define EWF_CONFIG_SIM_APN ("globaldata.iot") + +/* The modem context ID used */ +#define EWF_CONFIG_CONTEXT_ID (1) +/* Board dependent settings; please use the value for each setting listed below depending on the board you use. + +Preprocessors that define board dependent settings and the corresponding values to be set are as follows: +Confirmed board number 1, +EWF_CELLULAR_CFG_UART_SCI_CH 6, +EWF_CELLULAR_CFG_RTS_PORT 0, +EWF_CELLULAR_CFG_RTS_PIN 2, +EWF_CELLULAR_CFG_RESET_PORT 5, +EWF_CELLULAR_CFG_RESET_PIN 5, +EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC 1, +EWF_CELLULAR_CFG_CTS_SW_CTRL 0, +EWF_CELLULAR_CFG_CTS_PORT 2, +EWF_CELLULAR_CFG_CTS_PIN 2, +EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU, +EWF_CELLULAR_CFG_IRQ_NUM 4, +EWF_CONFIG_SIM_PIN "0000", +EWF_CONFIG_SIM_APN "globaldata.iot", +EWF_CONFIG_CONTEXT_ID 1 + +where the confirmed board numbers listed in the first row above are as follows: +1: CK-RX65N (PMOD1), +In the above preprocessor list, please use one of the values listed on the right side. +On the right side, each column corresponds to each confirmed board number. + +Note: +Please supply power source to USB(CN4) port on RYZ014A/RYZ024A-PMOD. +E2 emulator supplying power to RYZ014A/RYZ024A-PMOD may result in insufficient power source. +The E2 emulator can provide 200mA, but RYZ014A/RYZ024A needs more current while connecting to the network. + +*/ +#endif /* EWF_CELLULAR_CONFIG_H */ diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_cellular_private.h b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_cellular_private.h new file mode 100644 index 00000000..d4c7c4bb --- /dev/null +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_cellular_private.h @@ -0,0 +1,169 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_private.h + * Description : Macro for controlling the pmod terminal + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_PRIVATE_H_ +#define EWF_CELLULAR_PRIVATE_H_ + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ +#include "r_sci_rx_if.h" +#include "r_sci_rx_pinset.h" +#include "ewf_cellular_config.h" + + +/* PDR port macros. */ +#define EWF_CELLULAR_SET_PDR(x, y) (EWF_CELLULAR_SET_PDR_PREPROC(x, y)) +/* Set the port direction. */ +#define EWF_CELLULAR_SET_PDR_PREPROC(x, y) ((PORT ## x .PDR.BIT.B ## y)) + +/* PODR port macros. */ +#define EWF_CELLULAR_SET_PODR(x, y) (EWF_CELLULAR_SET_PODR_PREPROC(x, y)) +/* Set the port I/O. */ +#define EWF_CELLULAR_SET_PODR_PREPROC(x, y) ((PORT ## x .PODR.BIT.B ## y)) + +#define EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT (1) + +/* Changes the output format of the reset signal sent to the Cellular module. */ +#if EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC == 1 +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (1) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (0) +#else +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (0) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (1) +#endif + + +#ifndef EWF_CELLULAR_CFG_UART_SCI_CH +#error "Error! Need to define EWF_CELLULAR_CFG_UART_SCI_CH in ewf_cellular_config.h" +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (0) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI0() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI0()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH0) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH0_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH0_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (1) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI1() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI1()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH1) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH1_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH1_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (2) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI2() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI2()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH2) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH2_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH2_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (3) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI3() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI3()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH3) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH3_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH3_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (4) +/* Store R_SCI_PinSet_SCI4() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI4()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH4) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH4_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH4_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (5) +/* Store R_SCI_PinSet_SCI5() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI5()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH5) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH5_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH5_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (6) +/* Store R_SCI_PinSet_SCI6() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI6()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH6) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH6_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH6_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (7) +/* Store R_SCI_PinSet_SCI7() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI7()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH7) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH7_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH7_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (8) +/* Store R_SCI_PinSet_SCI8() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI8()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH8) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH8_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH8_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (9) +/* Store R_SCI_PinSet_SCI9() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI9()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH9) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH9_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH9_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (10) +/* Store R_SCI_PinSet_SCI10() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI10()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH10) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH10_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH10_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (11) +/* Store R_SCI_PinSet_SCI11() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI11()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH11) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH11_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH11_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (12) +/* Store R_SCI_PinSet_SCI12() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI12()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH12) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH12_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH12_RX_BUFSIZ) +#else +#error "Error! Invalid setting for EWF_CELLULAR_UART_SCI_CH in ewf_cellular_config.h" +#endif /* EWF_CELLULAR_CFG_UART_SCI_CH */ + + +#if R_SCI_CFG_TX_BUFSIZE < (1500) +#error "The SCI send buffer size is too small." +#endif +#if R_SCI_CFG_RX_BUFSIZE < (1500) +#error "The SCI receive buffer size is too small." +#endif + +#endif /* EWF_CELLULAR_PRIVATE_H_ */ diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_example.config.h b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_example.config.h index 54f0b5fe..7f077bea 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_example.config.h +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/ewf_example.config.h @@ -35,20 +35,6 @@ extern "C" { /** @} *** group_example_configuration_allocator */ -/** - * @defgroup group_example_configuration_modem Modem configuration - * @brief Modem configuration settings used in examples - * @{ - */ - -/** @brief The SIM PIN for the modem */ -#define EWF_CONFIG_SIM_PIN ("0000") - -/** @brief The modem context ID used */ -#define EWF_CONFIG_CONTEXT_ID (1) - -/** @} *** group_example_configuration_modem */ - /** * @defgroup group_example_configuration_iot_hub IoT Hub configuration * @brief IoT Hub configuration settings used in examples @@ -63,6 +49,37 @@ extern "C" { /** @} *** group_example_configuration_iot_hub */ +/** + * @defgroup group_example_configuration_telemetry + * @brief Telemetry example configuration + * @{ + */ + +/** @brief The size of the buffer used to hold the IoT Hub username */ +#define EWF_CONFIG_TELEMETRY_USERNAME_LENGTH (256) + +/** @brief The size of the buffer used to hold the IoT Hub client ID */ +#define EWF_CONFIG_TELEMETRY_CLIENT_ID_LENGTH (64) + +/** @brief The size of the buffer used to hold the IoT Hub topic length */ +#define EWF_CONFIG_TELEMETRY_TOPIC_LENGTH (256) + +/** @brief The number of minutes to run the telemetry loop, 0 means to run forever */ +#define EWF_CONFIG_TELEMETRY_LOOP_MINUTES (60) + +/** @} */ + +/** + * @defgroup group_example_configuration_netx_duo NetX Duo driver configuration + * @brief NetX Duo Driver configuration settings used in middleware driver + * @{ + */ + +/* MTU size should be equal to the modems maximum socket send size */ +#define EWF_CONFIG_ADAPTER_MTU (1460) + +/** @} */ + /************************************************************************//** * @} ****************************************************************************/ diff --git a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/main.c b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/main.c index 6a5e2ae5..c854d0e6 100644 --- a/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/main.c +++ b/examples/CK_RX65N_GCCRX/ewf_info_tx_ryz014/src/main.c @@ -44,6 +44,7 @@ #include "ewf_example.config.h" +#include "ewf_cellular_private.h" /* Modem might take some minutes to attach and register to the network. Time out value in seconds */ #define EWF_ADAPTER_RENESAS_NETWORK_REGISTER_TIMEOUT (1200) @@ -109,10 +110,10 @@ void ewf_info_thread_entry(ULONG parameter) // Release the RYZ014A from reset - PORTA.PODR.BIT.B1= 1; - PORTA.PDR.BIT.B1= 1; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_ON; + EWF_CELLULAR_SET_PDR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT; tx_thread_sleep (100); - PORTA.PODR.BIT.B1= 0; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_OFF; EWF_LOG("Waiting for the module to Power Reset!\r\n"); ewf_platform_sleep(300); EWF_LOG("Ready\r\n"); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject index d14c1316..57c69939 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/.cproject @@ -50,6 +50,21 @@ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch index 155bfdeb..370f4e0d 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014 HardwareDebug.launch @@ -29,7 +29,7 @@ - + diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg index 1dcda3ff..a18e39b5 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014.scfg @@ -7,7 +7,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - + + + - - + + + + + + + + + + + + + + + + + @@ -678,12 +693,8 @@ - - - - - - + + @@ -840,11 +851,31 @@ + + + + + + + + + + + + + + + + + + + + - + @@ -854,8 +885,19 @@ + + + + + + + + + + + - + @@ -887,10 +929,10 @@ - - - - + + + + @@ -932,39 +974,91 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -1083,74 +1177,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h index ae36f6b0..590688ab 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/inc/fx_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* fx_api.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -74,6 +74,12 @@ /* 04-25-2022 William E. Lamie Modified comment(s), and */ /* updated product constants, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 William E. Lamie Modified comment(s), and */ +/* updated product constants, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Xiuwen Cai Modified comment(s), and */ +/* updated product constants, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -122,8 +128,8 @@ extern "C" { #define AZURE_RTOS_FILEX #define FILEX_MAJOR_VERSION 6 -#define FILEX_MINOR_VERSION 1 -#define FILEX_PATCH_VERSION 11 +#define FILEX_MINOR_VERSION 2 +#define FILEX_PATCH_VERSION 0 /* Define the following symbols for backward compatibility */ #define EL_PRODUCT_FILEX diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c index 32833fac..934ef88a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_directory_free_search.c @@ -39,7 +39,7 @@ /* FUNCTION RELEASE */ /* */ /* _fx_directory_free_search PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -82,6 +82,10 @@ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 William E. Lamie Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Bhupendra Naphade Modified comment(s), */ +/* updated available cluster */ +/* check for sub directory, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _fx_directory_free_search(FX_MEDIA *media_ptr, FX_DIR_ENTRY *directory_ptr, FX_DIR_ENTRY *entry_ptr) @@ -434,7 +438,7 @@ FX_INT_SAVE_AREA /* Not enough empty entries were found. If the specified directory is a sub-directory, attempt to allocate another cluster to it. */ - if (((search_dir_ptr) || (media_ptr -> fx_media_32_bit_FAT)) && (media_ptr -> fx_media_available_clusters > clusters_needed)) + if (((search_dir_ptr) || (media_ptr -> fx_media_32_bit_FAT)) && (media_ptr -> fx_media_available_clusters >= clusters_needed)) { /* Search for the additional clusters we need. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c index e9df0006..d335d9f7 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_apply_logs.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _fx_fault_tolerant_apply_logs PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -81,6 +81,9 @@ /* 09-30-2020 William E. Lamie Modified comment(s), verified */ /* memcpy usage, */ /* resulting in version 6.1 */ +/* 10-31-2022 Tiejun Zhou Modified comment(s), fixed */ +/* overflow in log size check, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _fx_fault_tolerant_apply_logs(FX_MEDIA *media_ptr) @@ -215,7 +218,7 @@ ULONG tail_cluster; copy_size = log_len - FX_FAULT_TOLERANT_DIR_LOG_ENTRY_SIZE; - if ((copy_offset + copy_size) > media_ptr -> fx_media_memory_size) + if (((ULONG64)copy_offset + (ULONG64)copy_size) > (ULONG64)(media_ptr -> fx_media_memory_size)) { return(FX_FILE_CORRUPT); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c index 92cb001c..70a7cb4c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_cleanup_FAT_chain.c @@ -29,12 +29,94 @@ #ifdef FX_ENABLE_FAULT_TOLERANT + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _fx_utility_FAT_entry_multiple_sectors_check PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Tiejun Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function checks whether the FAT entry spans multiple sectors. */ +/* It is only possible when the file system is FAT12. */ +/* */ +/* INPUT */ +/* */ +/* media_ptr Media control block pointer */ +/* cluster Cluster entry number */ +/* */ +/* OUTPUT */ +/* */ +/* FX_TRUE FAT entry spans two sectors */ +/* FX_FALSE FAT entry in one sector */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* _fx_fault_tolerant_cleanup_FAT_chain */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Tiejun Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +static UINT _fx_utility_FAT_entry_multiple_sectors_check(FX_MEDIA *media_ptr, ULONG cluster) +{ +ULONG byte_offset; +ULONG FAT_sector; + + /* Check FAT format. */ + if (!media_ptr -> fx_media_12_bit_FAT) + { + + /* Not FAT12. The FAT entry will be in one sector. */ + return(FX_FALSE); + } + + /* File system is FAT12. */ + /* Calculate the byte offset to the cluster entry. */ + byte_offset = (((ULONG)cluster << 1) + cluster) >> 1; + + /* Calculate the FAT sector the requested FAT entry resides in. */ + FAT_sector = (byte_offset / media_ptr -> fx_media_bytes_per_sector) + + (ULONG)media_ptr -> fx_media_reserved_sectors; + + /* Now calculate the byte offset into this FAT sector. */ + byte_offset = byte_offset - + ((FAT_sector - (ULONG)media_ptr -> fx_media_reserved_sectors) * + media_ptr -> fx_media_bytes_per_sector); + + /* Determine if we are now past the end of the FAT buffer in memory. */ + if (byte_offset == (ULONG)(media_ptr -> fx_media_bytes_per_sector - 1)) + { + + /* Yes, we are past the end of the FAT buffer. */ + return(FX_TRUE); + } + else + { + + /* No, we are not past the end of the FAT buffer. */ + return(FX_FALSE); + } +} + /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _fx_fault_tolerant_cleanup_FAT_chain PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -72,6 +154,8 @@ /* _fx_utility_FAT_flush Flush written FAT entries */ /* _fx_fault_tolerant_calculate_checksum Compute Checksum of data */ /* _fx_fault_tolerant_write_log_file Write log file */ +/* _fx_utility_FAT_entry_multiple_sectors_check */ +/* Check sectors for FAT entry */ /* */ /* CALLED BY */ /* */ @@ -85,6 +169,10 @@ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 William E. Lamie Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Tiejun Zhou Modified comment(s), */ +/* fixed FAT entry span two */ +/* sectors for FAT12, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _fx_fault_tolerant_cleanup_FAT_chain(FX_MEDIA *media_ptr, UINT operation) @@ -123,7 +211,7 @@ ULONG last_FAT_sector; /* At this point, the head_cluster points to the cluster chain that is to be removed. */ - /* Tail cluster points to the back of the origianl FAT chain where the new chain is attached to. + /* Tail cluster points to the back of the origianal FAT chain where the new chain is attached to. The remove process terminates once this cluster is encountered. */ tail_cluster = _fx_utility_32_unsigned_read((UCHAR *)&FAT_chain -> fx_fault_tolerant_FAT_chain_insertion_back); @@ -133,7 +221,7 @@ ULONG last_FAT_sector; return(FX_SUCCESS); } - /* To opimize the deletion process of a long FAT chain, the deletion is done in sessions. During one session, + /* To optimize the deletion process of a long FAT chain, the deletion is done in sessions. During one session, a set of FAT entries are removed. If one session is interrupted, after restart the deletion process resumes and picks up from where it left. @@ -173,6 +261,16 @@ ULONG last_FAT_sector; /* Cache the FAT list. */ cache_ptr[cache_count++] = current_cluster; + /* Check whether FAT entry spans multiple sectors. */ + if (_fx_utility_FAT_entry_multiple_sectors_check(media_ptr, current_cluster)) + { + if (head_cluster == next_session || next_session == FX_FREE_CLUSTER) + { + next_session = next_cluster; + } + break; + } + /* Move to next cluster. */ current_cluster = next_cluster; } while ((next_cluster >= FX_FAT_ENTRY_START) && @@ -288,5 +386,4 @@ ULONG last_FAT_sector; return(FX_SUCCESS); } -#endif /* FX_ENABLE_FAULT_TOLERANT */ - +#endif /* FX_ENABLE_FAULT_TOLERANT */ \ No newline at end of file diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c index f229ad9c..ce6d8a89 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_fault_tolerant_enable.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _fx_fault_tolerant_enable PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -46,7 +46,7 @@ /* previous write operation failed, and appropriate action now must */ /* be taken to restore the integrity of the file system. Once the */ /* recovery effort is completed, the file system is properly restored. */ -/* An empty log file indicates the previous write operaiton was */ +/* An empty log file indicates the previous write operation was */ /* successfully completed and no action needs to be taken at this */ /* point. If the file system does not have a log file, or the */ /* checksum is not valid, it is an indication either the file system */ @@ -86,6 +86,10 @@ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 William E. Lamie Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Tiejun Zhou Modified comment(s), */ +/* fixed memory buffer when */ +/* cache is disabled, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _fx_fault_tolerant_enable(FX_MEDIA *media_ptr, VOID *memory_buffer, UINT memory_size) @@ -143,11 +147,13 @@ ULONG bytes_per_cluster; values of zero, endian issues are not important. */ /* Force update the available cluster. */ +#ifndef FX_DISABLE_CACHE /* Invalidate the current logical sector cache. */ _fx_utility_logical_sector_flush(media_ptr, ((ULONG64) 1), (ULONG64) (media_ptr -> fx_media_total_sectors), FX_TRUE); /* Reset the memory pointer. */ media_ptr -> fx_media_memory_buffer = media_ptr -> fx_media_sector_cache[0].fx_cached_sector_memory_buffer; +#endif /* FX_DISABLE_CACHE */ /* Reset the available cluster. */ media_ptr -> fx_media_available_clusters = 0; @@ -155,6 +161,7 @@ ULONG bytes_per_cluster; /* Loop through all FAT sectors in the primary FAT. The first two entries are examined in this loop, but they are always unavailable. */ cluster_number = 0; +#ifndef FX_DISABLE_CACHE for (i = 0; i < media_ptr -> fx_media_sectors_per_FAT; i = i + media_ptr -> fx_media_sector_cache_size) { @@ -169,6 +176,18 @@ ULONG bytes_per_cluster; { FAT_read_sectors = media_ptr -> fx_media_sector_cache_size; } +#else + /* Reset the buffer sector. */ + media_ptr -> fx_media_memory_buffer_sector = (ULONG64)-1; + for (i = 0; i < media_ptr -> fx_media_sectors_per_FAT; i++) + { + + /* Calculate the starting next FAT sector. */ + FAT_sector = media_ptr -> fx_media_reserved_sectors + i; + + /* Calculate how many sectors to read. */ + FAT_read_sectors = 1; +#endif /* FX_DISABLE_CACHE */ /* Read the FAT sectors directly from the driver. */ media_ptr -> fx_media_driver_request = FX_DRIVER_READ; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c index 183d6158..da33b465 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_media_open.c @@ -36,7 +36,7 @@ /* FUNCTION RELEASE */ /* */ /* _fx_media_open PORTABLE C */ -/* 6.1.10 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -132,6 +132,10 @@ /* 01-31-2022 William E. Lamie Modified comment(s), fixed */ /* errors without cache, */ /* resulting in version 6.1.10 */ +/* 10-31-2022 Tiejun Zhou Modified comment(s), */ +/* fixed memory buffer when */ +/* cache is disabled, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _fx_media_open(FX_MEDIA *media_ptr, CHAR *media_name, @@ -340,13 +344,8 @@ FX_INT_SAVE_AREA /* Pickup the additional info sector number. This will only be used in FAT32 situations. */ additional_info_sector = _fx_utility_16_unsigned_read(&media_ptr -> fx_media_driver_buffer[48]); -#ifndef FX_DISABLE_CACHE - /* Determine how many logical sectors can be cached with user's supplied - buffer area - there must be at least enough for one sector! */ - media_ptr -> fx_media_sector_cache_size = memory_size / media_ptr -> fx_media_bytes_per_sector; - /* Is there at least one? */ - if (media_ptr -> fx_media_sector_cache_size == 0) + if (memory_size < media_ptr -> fx_media_bytes_per_sector) { /* Build the "uninitialize" I/O driver request. */ @@ -363,6 +362,11 @@ FX_INT_SAVE_AREA return(FX_BUFFER_ERROR); } +#ifndef FX_DISABLE_CACHE + /* Determine how many logical sectors can be cached with user's supplied + buffer area - there must be at least enough for one sector! */ + media_ptr -> fx_media_sector_cache_size = memory_size / media_ptr -> fx_media_bytes_per_sector; + /* If trace is enabled, register this object. */ FX_TRACE_OBJECT_REGISTER(FX_TRACE_OBJECT_TYPE_MEDIA, media_ptr, media_name, FX_MAX_FAT_CACHE, media_ptr -> fx_media_sector_cache_size) @@ -654,6 +658,7 @@ FX_INT_SAVE_AREA (media_ptr -> fx_media_sector_cache_list_ptr) -> fx_cached_sector_valid = FX_FALSE; #else buffer_ptr = media_ptr -> fx_media_memory_buffer; + media_ptr -> fx_media_memory_buffer_sector = (ULONG64)-1; #endif /* FX_DISABLE_CACHE */ /* Read the FAT32 additional information sector from the device. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c index 1f28693b..2cb2f391 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_partition_offset_calculate.c @@ -37,6 +37,22 @@ typedef struct FX_MEDIA_PARTITION_STRUCT ULONG fx_media_part_size; } FX_MEDIA_PARTITION; +/* Define internal partition constants. */ + +#ifndef FX_MAX_PARTITION_COUNT +#define FX_MAX_PARTITION_COUNT 16 +#endif /* FX_MAX_PARTITION_COUNT */ + +#define FX_PARTITION_TABLE_OFFSET 446 +#define FX_PARTITION_ENTRY_SIZE 16 +#define FX_PARTITION_TYPE_OFFSET 4 +#define FX_PARTITION_LBA_OFFSET 8 +#define FX_PARTITION_SECTORS_OFFSET 12 + +#define FX_PARTITION_TYPE_FREE 0x00 +#define FX_PARTITION_TYPE_EXTENDED 0x05 +#define FX_PARTITION_TYPE_EXTENDED_LBA 0x0F + /* Define function prototypes for the partition table parsing application utility. */ @@ -45,7 +61,8 @@ UINT _fx_partition_offset_calculate(void *partition_sector, UINT partition, ULONG *partition_start, ULONG *partition_size); UINT _fx_utility_partition_get(FX_MEDIA_PARTITION *partition_table, UINT *count, ULONG sector, UCHAR *sector_buffer); - +UINT _fx_partition_offset_calculate_extended(FX_MEDIA *media_ptr, void *partition_sector, UINT partition, + ULONG *partition_start, ULONG *partition_size); /**************************************************************************/ /* */ @@ -343,3 +360,324 @@ ULONG base_sector, value; return(FX_SUCCESS); } +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _fx_partition_offset_calculate_extended PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Xiuwen Cai, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function calculates the sector offset to the specified */ +/* partition. The buffer containing the partition table is also */ +/* supplied to this function. If the buffer supplied is a boot */ +/* record (which could be the case in non-partition systems), this */ +/* function returns an offset of zero, the total sectors, and a */ +/* successful status indicating that the buffer supplied is the boot */ +/* record. Otherwise, if a partition is found, this function returns */ +/* the sector offset to its boot record along with a successful */ +/* status. If the specified partition is not found or the buffer is */ +/* not a partition table or boot record, this function returns an */ +/* error. */ +/* */ +/* Note: Empty partitions have a FX_NOT_FOUND return code. */ +/* Use partition index 0 to 3 for primary partition and index 4 to */ +/* FX_MAX_PARTITION_COUNT for extended partition. */ +/* */ +/* INPUT */ +/* */ +/* media_ptr Media control block pointer */ +/* partition_sector Pointer to buffer containing */ +/* either the partition table */ +/* or the boot sector */ +/* partition Desired partition */ +/* partition_start Return partition start */ +/* partition_size Return partition size */ +/* */ +/* OUTPUT */ +/* */ +/* return status */ +/* */ +/* CALLS */ +/* */ +/* _fx_utility_16_unsigned_read Read a USHORT from memory */ +/* _fx_utility_32_unsigned_read Read a ULONG from memory */ +/* _fx_utility_64_unsigned_read Read a ULONG64 from memory */ +/* Media driver */ +/* */ +/* CALLED BY */ +/* */ +/* Application Driver */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Xiuwen Cai Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +UINT _fx_partition_offset_calculate_extended(FX_MEDIA *media_ptr, void *partition_sector, UINT partition, + ULONG *partition_start, ULONG *partition_size) +{ + +ULONG64 total_sectors; +UCHAR *partition_sector_ptr; +UCHAR partition_type; +UINT i; +ULONG base_sector; +ULONG base_sector_extended; + + + /* Setup working pointer. */ + partition_sector_ptr = partition_sector; + + /* Check for a real boot sector instead of a partition table. */ + if ((partition_sector_ptr[0] == 0xe9) || ((partition_sector_ptr[0] == 0xeb) && (partition_sector_ptr[2] == 0x90))) + { + + /* Yes, a real boot sector could be present. */ + + /* See if there are good values for sectors per FAT. */ + if (partition_sector_ptr[0x16] || partition_sector_ptr[0x17] || partition_sector_ptr[0x24] || partition_sector_ptr[0x25] || partition_sector_ptr[0x26] || partition_sector_ptr[0x27]) + { + + /* There are values for sectors per FAT. */ + + /* Get the total sectors, FAT12/16. */ + total_sectors = _fx_utility_16_unsigned_read(&partition_sector_ptr[FX_SECTORS]); + + if (total_sectors == 0) + { + + /* Get the total sectors, FAT32. */ + total_sectors = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_HUGE_SECTORS]); + } + + /* Determine if there is a total sector count. */ + if (total_sectors) + { + + if (partition_start != FX_NULL) + { + /* Return an offset of 0, size of boot record, and a successful status. */ + *partition_start = 0; + } + + /* Determine if the total sectors is required. */ + if (partition_size != FX_NULL) + { + + /* Return the total sectors. */ + *partition_size = (ULONG)(total_sectors & 0xFFFFFFFF); + } + + /* Return success! */ + return(FX_SUCCESS); + } + } +#ifdef FX_ENABLE_EXFAT + /* See if there are good values for sectors per exFAT. */ + else if (partition_sector_ptr[0x0b] == 0 && partition_sector_ptr[0x0c] == 0) + { + /* There are values for sectors per exFAT. */ + + /* Calculate the total sectors. */ + total_sectors = _fx_utility_64_unsigned_read(&partition_sector_ptr[FX_EF_VOLUME_LENGTH]); + + /* Determine if there is a total sector count. */ + if (total_sectors) + { + + if (partition_start != FX_NULL) + { + /* Return an offset of 0, size of boot record, and a successful status. */ + *partition_start = 0; + } + + /* Determine if the total sectors is required. */ + if (partition_size != FX_NULL) + { + + if (total_sectors > 0xFFFFFFFF) + { + + /* Overflow. Just return not found. */ + return(FX_NOT_FOUND); + } + + /* Return the total sectors. */ + *partition_size = (ULONG)(total_sectors & 0xFFFFFFFF); + } + + /* Return success! */ + return(FX_SUCCESS); + } + } +#endif /* FX_ENABLE_EXFAT */ + } + + /* Check signature to make sure the buffer is valid. */ + if ((partition_sector_ptr[510] != FX_SIG_BYTE_1) || (partition_sector_ptr[511] != FX_SIG_BYTE_2)) + { + + /* Invalid, return an error. */ + return(FX_NOT_FOUND); + } + + /* Not bootable, look for specific partition. */ + + /* Check if primary partitions are addressed. */ + if (partition < 4) + { + + /* Get partition type. */ + partition_type = partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + partition * FX_PARTITION_ENTRY_SIZE + FX_PARTITION_TYPE_OFFSET]; + + /* Check if there is a vaild partition. */ + if (partition_type != FX_PARTITION_TYPE_FREE) + { + + /* Return the partition starting sector, if non-NULL. */ + if (partition_start != FX_NULL) + { + *partition_start = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + partition * FX_PARTITION_ENTRY_SIZE + FX_PARTITION_LBA_OFFSET]); + } + + /* Return the partition size, if non-NULL. */ + if (partition_size != FX_NULL) + { + *partition_size = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + partition * FX_PARTITION_ENTRY_SIZE + FX_PARTITION_SECTORS_OFFSET]); + } + + /* Return success! */ + return(FX_SUCCESS); + } + else + { + + /* Not partition here. */ + return(FX_NOT_FOUND); + } + } + + /* Check for invalid parameter. */ + if (partition > FX_MAX_PARTITION_COUNT) + { + + /* Return error. */ + return(FX_NOT_FOUND); + } + + base_sector = 0; + + /* Loop to find the extended partition table. */ + for(i = FX_PARTITION_TABLE_OFFSET; i <= FX_PARTITION_TABLE_OFFSET + 3 * FX_PARTITION_ENTRY_SIZE; i += FX_PARTITION_ENTRY_SIZE) + { + + /* Get partition type. */ + partition_type = partition_sector_ptr[i + FX_PARTITION_TYPE_OFFSET]; + if (partition_type == FX_PARTITION_TYPE_EXTENDED || partition_type == FX_PARTITION_TYPE_EXTENDED_LBA) + { + base_sector = _fx_utility_32_unsigned_read(&partition_sector_ptr[i + FX_PARTITION_LBA_OFFSET]); + break; + } + } + + if (base_sector == 0) + { + + /* No extended partition. */ + return(FX_NOT_FOUND); + } + + base_sector_extended = base_sector; + + for (i = 4; i <= partition; i++) + { + + /* Read the partition sector from the device. Build the read sector + command. */ + media_ptr -> fx_media_driver_request = FX_DRIVER_READ; + media_ptr -> fx_media_driver_status = FX_IO_ERROR; + media_ptr -> fx_media_driver_buffer = partition_sector_ptr; + media_ptr -> fx_media_driver_logical_sector = base_sector; + media_ptr -> fx_media_driver_sectors = 1; + media_ptr -> fx_media_driver_sector_type = FX_UNKNOWN_SECTOR; + media_ptr -> fx_media_hidden_sectors = 0; + + /* Invoke the driver to read the sector. */ + (media_ptr -> fx_media_driver_entry) (media_ptr); + + /* Determine if the sector was read correctly. */ + if (media_ptr -> fx_media_driver_status != FX_SUCCESS) + { + + /* Return error. */ + return(FX_IO_ERROR); + } + + /* Check signature to make sure the sector is valid. */ + if ((partition_sector_ptr[510] != FX_SIG_BYTE_1) || (partition_sector_ptr[511] != FX_SIG_BYTE_2)) + { + + /* Invalid, return an error. */ + return(FX_NOT_FOUND); + } + + /* Determine if this is the desired partition. */ + if (i == partition) + { + + /* Get partition type. */ + partition_type = partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_TYPE_OFFSET]; + if (partition_type != FX_PARTITION_TYPE_FREE) + { + + /* Return the partition starting sector, if non-NULL. */ + if (partition_start != FX_NULL) + { + *partition_start = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_LBA_OFFSET]) + base_sector; + } + + /* Return the partition size, if non-NULL. */ + if (partition_size != FX_NULL) + { + *partition_size = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_SECTORS_OFFSET]); + } + + /* Return success! */ + return(FX_SUCCESS); + } + else + { + /* Not partition here. */ + return(FX_NOT_FOUND); + } + } + else + { + + /* Get partition type. */ + partition_type = partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_ENTRY_SIZE + FX_PARTITION_TYPE_OFFSET]; + if (partition_type == FX_PARTITION_TYPE_EXTENDED || partition_type == FX_PARTITION_TYPE_EXTENDED_LBA) + { + + /* Update sector number for next partition table. */ + base_sector = _fx_utility_32_unsigned_read(&partition_sector_ptr[FX_PARTITION_TABLE_OFFSET + FX_PARTITION_ENTRY_SIZE + FX_PARTITION_LBA_OFFSET]) + base_sector_extended; + } + else + { + /* No valid partition, get out of the loop. */ + break; + } + } + + } + + /* Return error. */ + return(FX_NOT_FOUND); +} \ No newline at end of file diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c index 5a10df7a..496c3a03 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_FAT_entry_read.c @@ -38,7 +38,7 @@ /* FUNCTION RELEASE */ /* */ /* _fx_utility_FAT_entry_read PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -80,6 +80,9 @@ /* added conditional to */ /* disable fat entry refresh, */ /* resulting in version 6.1 */ +/* 10-31-2022 Tiejun Zhou Modified comment(s), and */ +/* fixed compiler warning, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _fx_utility_FAT_entry_read(FX_MEDIA *media_ptr, ULONG cluster, ULONG *entry_ptr) @@ -91,7 +94,9 @@ UCHAR *FAT_ptr; UINT entry, index; UINT status; FX_FAT_CACHE_ENTRY *cache_entry_ptr; +#ifndef FX_DISABLE_FAT_ENTRY_REFRESH FX_FAT_CACHE_ENTRY temp_cache_entry; +#endif /* FX_DISABLE_FAT_ENTRY_REFRESH */ #ifdef FX_ENABLE_FAULT_TOLERANT diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c index 0b831684..54140c57 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/common/src/fx_utility_logical_sector_read.c @@ -38,7 +38,7 @@ /* FUNCTION RELEASE */ /* */ /* _fx_utility_logical_sector_read PORTABLE C */ -/* 6.1.6 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -96,6 +96,10 @@ /* updated check for logical */ /* sector value, */ /* resulting in version 6.1.6 */ +/* 10-31-2022 Tiejun Zhou Modified comment(s), */ +/* fixed memory buffer when */ +/* cache is disabled, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _fx_utility_logical_sector_read(FX_MEDIA *media_ptr, ULONG64 logical_sector, @@ -342,6 +346,24 @@ UINT status; #else if ((logical_sector == media_ptr -> fx_media_memory_buffer_sector) && (sectors == 1) && (buffer_ptr == media_ptr -> fx_media_memory_buffer)) { +#ifdef FX_ENABLE_FAULT_TOLERANT + if (media_ptr -> fx_media_fault_tolerant_enabled && + (media_ptr -> fx_media_fault_tolerant_state & FX_FAULT_TOLERANT_STATE_STARTED) && + (sector_type == FX_DIRECTORY_SECTOR)) + { + + /* Read sector from log file. */ + status = _fx_fault_tolerant_read_directory_sector(media_ptr, logical_sector, buffer_ptr, 1); + + /* Check for successful completion. */ + if (status) + { + + /* Return the error status. */ + return(status); + } + } +#endif /* FX_ENABLE_FAULT_TOLERANT */ return(FX_SUCCESS); } #endif @@ -456,6 +478,24 @@ UINT status; if ((media_ptr -> fx_media_driver_status == FX_SUCCESS) && (sectors == 1) && (buffer_ptr == media_ptr -> fx_media_memory_buffer)) { media_ptr -> fx_media_memory_buffer_sector = logical_sector; +#ifdef FX_ENABLE_FAULT_TOLERANT + if (media_ptr -> fx_media_fault_tolerant_enabled && + (media_ptr -> fx_media_fault_tolerant_state & FX_FAULT_TOLERANT_STATE_STARTED) && + (sector_type == FX_DIRECTORY_SECTOR)) + { + + /* Read sector from log file. */ + status = _fx_fault_tolerant_read_directory_sector(media_ptr, logical_sector, buffer_ptr, 1); + + /* Check for successful completion. */ + if (status) + { + + /* Return the error status. */ + return(status); + } + } +#endif /* FX_ENABLE_FAULT_TOLERANT */ return(FX_SUCCESS); } #endif /* FX_DISABLE_CACHE */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h index 3c8c9e08..6832c408 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/filex/ports/generic/inc/fx_port.h @@ -213,7 +213,7 @@ typedef unsigned long long ULONG64; #ifdef FX_SYSTEM_INIT CHAR _fx_version_id[] = - "Copyright (c) Microsoft Corporation. All rights reserved. * FileX Generic Version 6.1.11 *"; + "Copyright (c) Microsoft Corporation. All rights reserved. * FileX Generic Version 6.2.0 *"; #else extern CHAR _fx_version_id[]; #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt index ae1796d7..21cf3dda 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/CMakeLists.txt @@ -25,6 +25,7 @@ target_sources(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/src/nx_arp_static_entry_create.c ${CMAKE_CURRENT_LIST_DIR}/src/nx_arp_static_entry_delete.c ${CMAKE_CURRENT_LIST_DIR}/src/nx_arp_static_entry_delete_internal.c + ${CMAKE_CURRENT_LIST_DIR}/src/nx_http_proxy_client.c ${CMAKE_CURRENT_LIST_DIR}/src/nx_icmp_cleanup.c ${CMAKE_CURRENT_LIST_DIR}/src/nx_icmp_enable.c ${CMAKE_CURRENT_LIST_DIR}/src/nx_icmp_info_get.c diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h index 7bdb81f8..9b20cf8c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_api.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -88,6 +88,15 @@ /* added internal ip address */ /* change notification, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* updated product constants, */ +/* fixed compiler errors when */ +/* TX_SAFETY_CRITICAL is */ +/* enabled, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -112,12 +121,15 @@ extern "C" { /* Bypass ThreadX API error checking for internal NetX calls. */ +#include "tx_port.h" #ifdef NX_SOURCE_CODE +#ifndef TX_SAFETY_CRITICAL #ifndef TX_DISABLE_ERROR_CHECKING #define TX_DISABLE_ERROR_CHECKING #endif #endif +#endif @@ -500,8 +512,8 @@ VOID _nx_trace_event_update(TX_TRACE_BUFFER_ENTRY *event, ULONG timestamp, ULONG /* Define basic constants for the NetX TCP/IP Stack. */ #define AZURE_RTOS_NETXDUO #define NETXDUO_MAJOR_VERSION 6 -#define NETXDUO_MINOR_VERSION 1 -#define NETXDUO_PATCH_VERSION 11 +#define NETXDUO_MINOR_VERSION 2 +#define NETXDUO_PATCH_VERSION 0 /* Define the following symbols for backward compatibility */ #define EL_PRODUCT_NETXDUO @@ -1201,6 +1213,22 @@ typedef struct NX_IPV6_DEFAULT_ROUTER_ENTRY_STRUCT #define NX_MAX_LISTEN_REQUESTS 10 #endif +/* Define the max length of username and password for HTTP Proxy authentication. */ + +/* Define the max length of username. */ +#ifndef NX_HTTP_PROXY_MAX_USERNAME +#define NX_HTTP_PROXY_MAX_USERNAME 20 +#endif + +/* Define the max length of password. */ +#ifndef NX_HTTP_PROXY_MAX_PASSWORD +#define NX_HTTP_PROXY_MAX_PASSWORD 20 +#endif + +/* NX_HTTP_PROXY_MAX_AUTHENTICATION is the max length of base64 of "name:password", + 1 bytes for an extra conversion if needed, 2 bytes for pad if needed, 1 byte for null terminator and four byte alignment. */ +#define NX_HTTP_PROXY_MAX_AUTHENTICATION (((((NX_HTTP_PROXY_MAX_USERNAME + NX_HTTP_PROXY_MAX_PASSWORD + 1 ) * 4 / 3) + 1 + 2 + 1) / 4 + 1) * 4) + /* Define the IP status checking/return bits. */ @@ -1934,9 +1962,22 @@ typedef struct NX_TCP_SOCKET_STRUCT /* Define whether or not TCP socket is in fast recovery procedure. */ UCHAR nx_tcp_socket_fast_recovery; +#ifdef NX_ENABLE_HTTP_PROXY + + /* Define the state of HTTP Proxy connection. */ + UCHAR nx_tcp_socket_http_proxy_state; + + /* Define the packet to store HTTP response header. */ + NX_PACKET *nx_tcp_socket_http_proxy_header_packet; + + /* Define the IP and port for original server. */ + NXD_ADDRESS nx_tcp_socket_original_server_ip; + UINT nx_tcp_socket_original_server_port; +#else /* Reserved to four bytes alignment. */ /*lint -esym(768,NX_TCP_SOCKET_STRUCT::nx_tcp_socket_reserved) suppress member not referenced. It is reserved for future use. */ UCHAR nx_tcp_socket_reserved; +#endif /* NX_ENABLE_HTTP_PROXY */ /* Define the entry that this TCP socket belongs to. */ struct NX_IP_STRUCT @@ -2806,6 +2847,21 @@ typedef struct NX_IP_STRUCT NX_TCP_LISTEN *nx_ip_tcp_active_listen_requests; +#ifdef NX_ENABLE_HTTP_PROXY + /* Define the IP address of HTTP proxy server. */ + NXD_ADDRESS nx_ip_http_proxy_ip_address; + + /* Define the port of HTTP proxy server. */ + USHORT nx_ip_http_proxy_port; + + /* Define the flag indicating the HTTP proxy is enabled. */ + USHORT nx_ip_http_proxy_enable; + + /* Define the buffer for HTTP proxy authentication. */ + UCHAR nx_ip_http_proxy_authentication[NX_HTTP_PROXY_MAX_AUTHENTICATION]; + UINT nx_ip_http_proxy_authentication_length; +#endif /* NX_ENABLE_HTTP_PROXY */ + /* Define a flag indicating the IP fast timer has been created */ UINT nx_ip_fast_periodic_timer_created; @@ -3257,6 +3313,7 @@ typedef struct NX_IP_DRIVER_STRUCT /* APIs for others. */ #define nx_system_initialize _nx_system_initialize +#define nx_http_proxy_client_enable _nx_http_proxy_client_enable #else @@ -3444,6 +3501,7 @@ typedef struct NX_IP_DRIVER_STRUCT /* APIs for others. */ #define nx_system_initialize _nx_system_initialize +#define nx_http_proxy_client_enable _nxe_http_proxy_client_enable #endif @@ -3781,6 +3839,8 @@ UINT nxd_udp_packet_info_extract(NX_PACKET *packet_ptr, NXD_ADDRESS *ip_address, /* APIs for others. */ VOID nx_system_initialize(VOID); +UINT nx_http_proxy_client_enable(NX_IP *ip_ptr, NXD_ADDRESS *proxy_server_ip, UINT proxy_server_port, + UCHAR *username, UINT username_length, UCHAR *password, UINT password_length); /* Define several function prototypes for exclusive use by NetX I/O drivers. These routines are used by NetX drivers to report received packets to NetX. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_http_proxy_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_http_proxy_client.h new file mode 100644 index 00000000..78566d46 --- /dev/null +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_http_proxy_client.h @@ -0,0 +1,89 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* */ +/* This software is licensed under the Microsoft Software License */ +/* Terms for Microsoft Azure RTOS. Full text of the license can be */ +/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ +/* and in the root directory of this software. */ +/* */ +/**************************************************************************/ + + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** NetX Component */ +/** */ +/** HTTP Proxy Protocol */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + +/**************************************************************************/ +/* */ +/* APPLICATION INTERFACE DEFINITION RELEASE */ +/* */ +/* nx_http_proxy_client.h PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Wenhui Xie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file defines the Hypertext Transfer Protocol(HTTP) Proxy */ +/* component, including all data types and external references. */ +/* It is assumed that nx_api.h and nx_port.h have already been */ +/* included. */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Wenhui Xie Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ + +#ifndef NX_HTTP_PROXY_CLIENT_H +#define NX_HTTP_PROXY_CLIENT_H + +/* Determine if a C++ compiler is being used. If so, ensure that standard + C is used to process the API information. */ + + +#ifdef __cplusplus + +/* Yes, C++ compiler is present. Use standard C. */ +extern "C" { + +#endif + +#include "nx_api.h" + +/* Define the states for HTTP Proxy connection. */ +#define NX_HTTP_PROXY_STATE_INIT 0 +#define NX_HTTP_PROXY_STATE_WAITING 1 +#define NX_HTTP_PROXY_STATE_CONNECTING 2 +#define NX_HTTP_PROXY_STATE_CONNECTED 3 + +/* Define HTTP Proxy function prototypes. */ +UINT _nx_http_proxy_client_enable(NX_IP *ip_ptr, NXD_ADDRESS *proxy_server_ip, UINT proxy_server_port, + UCHAR *username, UINT username_length, UCHAR *password, UINT password_length); +VOID _nx_http_proxy_client_initialize(NX_TCP_SOCKET *socket_ptr, NXD_ADDRESS **server_ip, UINT *server_port); +UINT _nx_http_proxy_client_connect(NX_TCP_SOCKET *socket_ptr); +UINT _nx_http_proxy_client_connect_response_process(NX_TCP_SOCKET *socket_ptr); +VOID _nx_http_proxy_client_cleanup(NX_TCP_SOCKET *socket_ptr); + +/* Define error checking shells for API services. These are only referenced by the + application. */ +UINT _nxe_http_proxy_client_enable(NX_IP *ip_ptr, NXD_ADDRESS *proxy_server_ip, UINT proxy_server_port, + UCHAR *username, UINT username_length, UCHAR *password, UINT password_length); + +/* Determine if a C++ compiler is being used. If so, complete the standard + C conditional started above. */ +#ifdef __cplusplus + } +#endif + +#endif /* NX_HTTP_PROXY_CLIENT_H */ \ No newline at end of file diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h index 6e0441fc..15b2e196 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/inc/nx_icmpv6.h @@ -212,7 +212,7 @@ typedef struct NX_ICMPV6_OPTION_STRUCT /* Size of the option. */ UCHAR nx_icmpv6_option_length; - /* Option data. */ + /* Option data. This field is used to retrieve starting address of option. The size is decided by option length. */ USHORT nx_icmpv6_option_data; } NX_ICMPV6_OPTION; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c index 523eedc2..acfd9452 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_na.c @@ -238,7 +238,7 @@ UINT i; /*lint -e{927} suppress cast of pointer to pointer, since it is necessary */ /*lint -e{644} suppress variable might not be initialized, since "nd_entry" was initialized in _nx_nd_cache_find_entry. */ lla = (USHORT *)nd_entry -> nx_nd_cache_mac_addr; - if ((new_lla[0] == lla[0]) && (new_lla[1] == lla[1]) && (new_lla[2] == lla[2])) + if ((new_lla[0] == lla[0]) && (new_lla[1] == lla[1]) && (new_lla[2] == lla[2])) /* lgtm[cpp/overflow-buffer] */ { /* No change in LLA. */ @@ -391,8 +391,8 @@ UINT i; /*lint -e{927} suppress cast of pointer to pointer, since it is necessary */ lla = (USHORT *)nd_entry -> nx_nd_cache_mac_addr; lla[0] = new_lla[0]; - lla[1] = new_lla[1]; - lla[2] = new_lla[2]; + lla[1] = new_lla[1]; /* lgtm[cpp/overflow-buffer] */ + lla[2] = new_lla[2]; /* lgtm[cpp/overflow-buffer] */ } if (nd_ptr -> nx_icmpv6_nd_flag & 0x40000000) /* S bit is set, force cache entry to REACHABLE */ { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c index c35cd22d..9cdc06f1 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ns.c @@ -285,7 +285,7 @@ ULONG dest_address[4]; mac_lsw = ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[2]) << 24) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[3]) << 16) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[4]) << 8) | nd_entry -> nx_nd_cache_mac_addr[5]; new_msw = ((ULONG)(new_mac[0]) << 8) | (new_mac[1]); - new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; + new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; /* lgtm[cpp/overflow-buffer] */ if ((mac_msw != new_msw) || (mac_lsw != new_lsw)) /* If the new MAC is different from what we have in the table. */ { @@ -410,12 +410,12 @@ ULONG dest_address[4]; mac_addr = &option_ptr -> nx_icmpv6_option_data; mac_addr[0] = (USHORT)(interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_msw); - mac_addr[1] = (USHORT)((interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); - mac_addr[2] = (USHORT)(interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF); + mac_addr[1] = (USHORT)((interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); /* lgtm[cpp/overflow-buffer] */ + mac_addr[2] = (USHORT)(interface_addr -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF); /* lgtm[cpp/overflow-buffer] */ NX_CHANGE_USHORT_ENDIAN(mac_addr[0]); - NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); - NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); + NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); /* lgtm[cpp/overflow-buffer] */ + NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); /* lgtm[cpp/overflow-buffer] */ #ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM compute_checksum = 0; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c index fd3dc7ce..423576a1 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_ra.c @@ -455,7 +455,7 @@ UINT interface_index; mac_lsw = ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[2]) << 24) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[3]) << 16) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[4]) << 8) | nd_entry -> nx_nd_cache_mac_addr[5]; new_msw = ((ULONG)(new_mac[0]) << 8) | (new_mac[1]); - new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; + new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; /* lgtm[cpp/overflow-buffer] */ if ((mac_msw != new_msw) || (mac_lsw != new_lsw)) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c index 920d22a5..8c42db68 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_process_redirect.c @@ -303,7 +303,7 @@ NX_IPV6_DESTINATION_ENTRY *dest_entry_ptr; new_msw = ((ULONG)(new_mac[0]) << 8) | (new_mac[1]); mac_lsw = ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[2]) << 24) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[3]) << 16) | ((ULONG)(nd_entry -> nx_nd_cache_mac_addr[4]) << 8) | nd_entry -> nx_nd_cache_mac_addr[5]; - new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; + new_lsw = ((ULONG)(new_mac[2]) << 24) | ((ULONG)(new_mac[3]) << 16) | ((ULONG)(new_mac[4]) << 8) | new_mac[5]; /* lgtm[cpp/overflow-buffer] */ if ((mac_msw != new_msw) || (mac_lsw != new_lsw)) /* If the new MAC is different. */ { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c index 903d3329..0c2a32e1 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_ns.c @@ -226,13 +226,13 @@ NX_IP_DRIVER driver_request; /* Fill in the source MAC address */ mac_addr = &nd_options -> nx_icmpv6_option_data; mac_addr[0] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_msw); - mac_addr[1] = (USHORT)((outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); - mac_addr[2] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF); + mac_addr[1] = (USHORT)((outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); /* lgtm[cpp/overflow-buffer] */ + mac_addr[2] = (USHORT)(outgoing_address -> nxd_ipv6_address_attached -> nx_interface_physical_address_lsw & 0x0000FFFF); /* lgtm[cpp/overflow-buffer] */ /* Byte swapping. */ NX_CHANGE_USHORT_ENDIAN(mac_addr[0]); - NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); - NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); + NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); /* lgtm[cpp/overflow-buffer] */ + NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); /* lgtm[cpp/overflow-buffer] */ } #ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c index 7ff18deb..eb3f0ae9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_icmpv6_send_rs.c @@ -164,13 +164,13 @@ NX_ICMPV6_OPTION *rs_options; /* Fill in the source mac address. */ mac_addr = &rs_options -> nx_icmpv6_option_data; mac_addr[0] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_msw); - mac_addr[1] = (USHORT)((ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); - mac_addr[2] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0x0000FFFF); + mac_addr[1] = (USHORT)((ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0xFFFF0000) >> 16); /* lgtm[cpp/overflow-buffer] */ + mac_addr[2] = (USHORT)(ip_ptr -> nx_ip_interface[if_index].nx_interface_physical_address_lsw & 0x0000FFFF); /* lgtm[cpp/overflow-buffer] */ /* Byte swapping. */ NX_CHANGE_USHORT_ENDIAN(mac_addr[0]); - NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); - NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); + NX_CHANGE_USHORT_ENDIAN(mac_addr[1]); /* lgtm[cpp/overflow-buffer] */ + NX_CHANGE_USHORT_ENDIAN(mac_addr[2]); /* lgtm[cpp/overflow-buffer] */ #ifdef NX_DISABLE_ICMPV6_TX_CHECKSUM compute_checksum = 0; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c index 68567c88..deeea5d4 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_md5.c @@ -242,7 +242,7 @@ ULONG needed_fill_bytes; /* Copy the appropriate portion of the input buffer into the internal buffer of the context. */ - memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, needed_fill_bytes); /* Use case of memcpy is verified. */ + memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, needed_fill_bytes); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ /* Process the 64-byte (512 bit) buffer. */ _nx_md5_process_buffer(context, context -> nx_md5_buffer); @@ -273,7 +273,7 @@ ULONG needed_fill_bytes; /* Save the remaining bytes in the internal buffer after any remaining bytes that it is processed later. */ - memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, input_length); /* Use case of memcpy is verified. */ + memcpy((void *) &(context -> nx_md5_buffer[current_bytes]), (void *) input_ptr, input_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } /* Return success. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c index fd34c8aa..103d5cab 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_adjust.c @@ -154,7 +154,7 @@ NX_PACKET *work_ptr; } /* Firstly, append the overflowing data to the new packet.. */ - memcpy(work_ptr -> nx_packet_prepend_ptr, data_start, append_size); /* Use case of memcpy is verified. */ + memcpy(work_ptr -> nx_packet_prepend_ptr, data_start, append_size); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ work_ptr -> nx_packet_append_ptr = (UCHAR *)((ALIGN_TYPE)work_ptr -> nx_packet_prepend_ptr + append_size); /* Secondly, calculate the shift data size. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c index 20b66dd1..b7318941 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_append.c @@ -265,7 +265,7 @@ NX_PACKET *work_ptr; /* Working packet pointer */ #endif /* NX_DISABLE_PACKET_CHAIN */ /* Copy the data into the current packet buffer. */ - memcpy(work_ptr -> nx_packet_append_ptr, source_ptr, copy_size); /* Use case of memcpy is verified. */ + memcpy(work_ptr -> nx_packet_append_ptr, source_ptr, copy_size); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ /* Adjust the remaining data size. */ data_size = data_size - copy_size; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c index 813448af..9a892d57 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_extract_offset.c @@ -187,7 +187,7 @@ NX_PACKET *working_packet_ptr; } /* Copy data from this packet. */ - memcpy(destination_ptr, source_ptr, bytes_to_copy); /* Use case of memcpy is verified. */ + memcpy(destination_ptr, source_ptr, bytes_to_copy); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ /* Update the pointers. */ destination_ptr += bytes_to_copy; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c index 97a8afde..75a419a0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_packet_data_retrieve.c @@ -103,7 +103,7 @@ ULONG bytes_to_copy; /* Copy data to destination. */ /* Note: The buffer size must be not less than packet_ptr -> nx_packet_length. */ - memcpy(destination_ptr, packet_ptr -> nx_packet_prepend_ptr, bytes_to_copy); /* Use case of memcpy is verified. The buffer is provided by user. */ + memcpy(destination_ptr, packet_ptr -> nx_packet_prepend_ptr, bytes_to_copy); /* Use case of memcpy is verified. The buffer is provided by user. lgtm[cpp/banned-api-usage-required-any] */ remaining_bytes -= bytes_to_copy; destination_ptr += bytes_to_copy; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c index 3270d683..544f8e79 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_block_cleanup.c @@ -28,13 +28,16 @@ #include "nx_api.h" #include "nx_tcp.h" #include "nx_ipv6.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_block_cleanup PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -53,7 +56,7 @@ /* */ /* CALLS */ /* */ -/* None */ +/* _nx_http_proxy_client_cleanup Clean up HTTP Proxy */ /* */ /* CALLED BY */ /* */ @@ -70,6 +73,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_tcp_socket_block_cleanup(NX_TCP_SOCKET *socket_ptr) @@ -109,6 +115,15 @@ VOID _nx_tcp_socket_block_cleanup(NX_TCP_SOCKET *socket_ptr) /* Client socket, return to a CLOSED state. */ socket_ptr -> nx_tcp_socket_state = NX_TCP_CLOSED; + +#ifdef NX_ENABLE_HTTP_PROXY + if (socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) + { + + /* Clean up the HTTP Proxy. */ + _nx_http_proxy_client_cleanup(socket_ptr); + } +#endif /* NX_ENABLE_HTTP_PROXY */ } else { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c index 526493df..cf7500c3 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_connection_reset.c @@ -35,7 +35,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_connection_reset PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -81,6 +81,10 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* corrected the logic of */ +/* flushing receive queue. */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID _nx_tcp_socket_connection_reset(NX_TCP_SOCKET *socket_ptr) @@ -103,15 +107,6 @@ UINT saved_state; _nx_tcp_socket_transmit_queue_flush(socket_ptr); } - /* Check for queued receive packets and if found they need - to be released. */ - if (socket_ptr -> nx_tcp_socket_receive_queue_count) - { - - /* Release all received packets. */ - _nx_tcp_socket_receive_queue_flush(socket_ptr); - } - /* Clear all receive thread suspensions on this socket. */ while (socket_ptr -> nx_tcp_socket_receive_suspension_list) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c index bac9f4b6..00b7945b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_packet_process.c @@ -28,6 +28,9 @@ #include "nx_api.h" #include "nx_tcp.h" #include "nx_packet.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ /**************************************************************************/ @@ -35,7 +38,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_packet_process PORTABLE C */ -/* 6.1.10 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -71,6 +74,9 @@ /* _nx_tcp_socket_state_transmit_check Check for transmit ability */ /* (nx_tcp_urgent_data_callback) Application urgent callback */ /* function */ +/* _nx_http_proxy_client_connect_response_process */ +/* Process HTTP Proxy CONNECT */ +/* response */ /* */ /* CALLED BY */ /* */ @@ -90,6 +96,9 @@ /* fixed unsigned integers */ /* comparison, */ /* resulting in version 6.1.10 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_tcp_socket_packet_process(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr) @@ -458,6 +467,19 @@ ULONG tcpip_offload; break; } +#ifdef NX_ENABLE_HTTP_PROXY + + /* Check if HTTP Proxy is started and waiting for the response form the HTTP Proxy server. */ + if ((socket_ptr -> nx_tcp_socket_state == NX_TCP_ESTABLISHED) && + (socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) && + (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_CONNECTING)) + { + + /* Receive and process the response. */ + _nx_http_proxy_client_connect_response_process(socket_ptr); + } +#endif /* NX_ENABLE_HTTP_PROXY */ + /* Check for an URG (urgent) bit set. */ /*lint -e{644} suppress variable might not be initialized, since "tcp_header_copy" was initialized. */ if (tcp_header_copy.nx_tcp_header_word_3 & NX_TCP_URG_BIT) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c index 031d7868..e23023d0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_data_check.c @@ -27,6 +27,9 @@ #include "nx_packet.h" #include "nx_ip.h" #include "nx_tcp.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ /**************************************************************************/ @@ -34,7 +37,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_state_data_trim PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -69,6 +72,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_tcp_socket_state_data_trim(NX_PACKET *packet_ptr, ULONG amount) @@ -276,7 +282,7 @@ ULONG work_length; /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_state_data_check PORTABLE C */ -/* 6.1.10 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -324,6 +330,9 @@ ULONG work_length; /* fixed unsigned integers */ /* comparison, */ /* resulting in version 6.1.10 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_tcp_socket_state_data_check(NX_TCP_SOCKET *socket_ptr, NX_PACKET *packet_ptr) @@ -1091,7 +1100,11 @@ NX_IP *ip_ptr; packet is already queued. */ /* Any packets for receiving? */ - while (acked_packets && socket_ptr -> nx_tcp_socket_receive_suspension_list) + while (acked_packets && socket_ptr -> nx_tcp_socket_receive_suspension_list +#ifdef NX_ENABLE_HTTP_PROXY + && (socket_ptr -> nx_tcp_socket_http_proxy_state != NX_HTTP_PROXY_STATE_CONNECTING) +#endif /* NX_ENABLE_HTTP_PROXY */ + ) { /* Setup a pointer to the first queued packet. */ @@ -1171,13 +1184,22 @@ NX_IP *ip_ptr; #endif /* NX_ENABLE_TCPIP_OFFLOAD */ ) { - /* Determine if there is a socket receive notification function specified. */ - if (socket_ptr -> nx_tcp_receive_callback) + +#ifdef NX_ENABLE_HTTP_PROXY + + /* If HTTP Proxy is connecting, the data is the response from HTTP Proxy server, don't need to notify application. */ + if (socket_ptr -> nx_tcp_socket_http_proxy_state != NX_HTTP_PROXY_STATE_CONNECTING) +#endif /* NX_ENABLE_HTTP_PROXY */ { - /* Yes, notification is requested. Call the application's receive notification - function for this socket. */ - (socket_ptr -> nx_tcp_receive_callback)(socket_ptr); + /* Determine if there is a socket receive notification function specified. */ + if (socket_ptr -> nx_tcp_receive_callback) + { + + /* Yes, notification is requested. Call the application's receive notification + function for this socket. */ + (socket_ptr -> nx_tcp_receive_callback)(socket_ptr); + } } #ifdef NX_TCP_ACK_EVERY_N_PACKETS diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c index 4cae6a85..082dee63 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_established.c @@ -28,6 +28,9 @@ #include "nx_api.h" #include "nx_ip.h" #include "nx_tcp.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ /**************************************************************************/ @@ -35,7 +38,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_state_established PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -74,6 +77,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_tcp_socket_state_established(NX_TCP_SOCKET *socket_ptr) @@ -127,14 +133,28 @@ NX_IP *ip_ptr; /* Send ACK message. */ _nx_tcp_packet_send_ack(socket_ptr, socket_ptr -> nx_tcp_socket_tx_sequence); - /* If given, call the application's disconnect callback function - for disconnect. */ - if (socket_ptr -> nx_tcp_disconnect_callback) +#ifdef NX_ENABLE_HTTP_PROXY + if ((ip_ptr -> nx_ip_http_proxy_enable) && + (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_CONNECTING)) { - /* Call the application's disconnect handling function. It is - responsible for calling the socket disconnect function. */ - (socket_ptr -> nx_tcp_disconnect_callback)(socket_ptr); + /* If received FIN before HTTP Proxy connection established, disconnect the TCP connection + and don't notify the application. */ + _nx_tcp_socket_disconnect(socket_ptr, NX_NO_WAIT); + } + else +#endif /* NX_ENABLE_HTTP_PROXY */ + { + + /* If given, call the application's disconnect callback function + for disconnect. */ + if (socket_ptr -> nx_tcp_disconnect_callback) + { + + /* Call the application's disconnect handling function. It is + responsible for calling the socket disconnect function. */ + (socket_ptr -> nx_tcp_disconnect_callback)(socket_ptr); + } } } } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c index 2ff220f0..97426200 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_syn_sent.c @@ -27,6 +27,9 @@ #include "nx_api.h" #include "nx_tcp.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ /**************************************************************************/ @@ -34,7 +37,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_state_syn_sent PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -62,6 +65,7 @@ /* _nx_tcp_packet_send_syn Send SYN packet */ /* _nx_tcp_packet_send_rst Send RST packet */ /* _nx_tcp_socket_thread_resume Resume suspended thread */ +/* _nx_http_proxy_client_connect Connect with HTTP Proxy */ /* */ /* CALLED BY */ /* */ @@ -74,6 +78,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tcp_header_ptr, NX_PACKET *packet_ptr) @@ -185,17 +192,6 @@ VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tc /* Clear the socket timeout. */ socket_ptr -> nx_tcp_socket_timeout = 0; -#ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT - - /* Is a connection completion callback registered with the TCP socket? */ - if (socket_ptr -> nx_tcp_establish_notify) - { - - /* Call the application's establish callback function. */ - (socket_ptr -> nx_tcp_establish_notify)(socket_ptr); - } -#endif - #ifdef NX_ENABLE_TCP_KEEPALIVE /* Is the keepalive feature enabled on this socket? */ if (socket_ptr -> nx_tcp_socket_keepalive_enabled) @@ -206,12 +202,37 @@ VOID _nx_tcp_socket_state_syn_sent(NX_TCP_SOCKET *socket_ptr, NX_TCP_HEADER *tc } #endif - /* Determine if we need to wake a thread suspended on the connection. */ - if (socket_ptr -> nx_tcp_socket_connect_suspended_thread) +#ifdef NX_ENABLE_HTTP_PROXY + + /* Check if the HTTP Proxy is started and waiting for TCP socket connection. */ + if ((socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) && + (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_WAITING)) { - /* Resume the suspended thread. */ - _nx_tcp_socket_thread_resume(&(socket_ptr -> nx_tcp_socket_connect_suspended_thread), NX_SUCCESS); + /* TCP connection established, start the HTTP Proxy connection. */ + _nx_http_proxy_client_connect(socket_ptr); + } + else +#endif /* NX_ENABLE_HTTP_PROXY */ + { +#ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT + + /* Is a connection completion callback registered with the TCP socket? */ + if (socket_ptr -> nx_tcp_establish_notify) + { + + /* Call the application's establish callback function. */ + (socket_ptr -> nx_tcp_establish_notify)(socket_ptr); + } +#endif + + /* Determine if we need to wake a thread suspended on the connection. */ + if (socket_ptr -> nx_tcp_socket_connect_suspended_thread) + { + + /* Resume the suspended thread. */ + _nx_tcp_socket_thread_resume(&(socket_ptr -> nx_tcp_socket_connect_suspended_thread), NX_SUCCESS); + } } } else if ((tcp_header_ptr -> nx_tcp_header_word_3 & NX_TCP_SYN_BIT) && diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c index e52bc6e3..63f534ed 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_tcp_socket_state_wait.c @@ -27,6 +27,9 @@ #include "nx_api.h" #include "nx_tcp.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ /**************************************************************************/ @@ -34,7 +37,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_state_wait PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -69,6 +72,9 @@ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_tcp_socket_state_wait(NX_TCP_SOCKET *socket_ptr, UINT desired_state, ULONG wait_option) @@ -93,8 +99,16 @@ UINT _nx_tcp_socket_state_wait(NX_TCP_SOCKET *socket_ptr, UINT desired_state, U if (socket_ptr -> nx_tcp_socket_state == desired_state) { - /* The desired state is present, return success! */ - return(NX_SUCCESS); +#ifdef NX_ENABLE_HTTP_PROXY + if ((desired_state != NX_TCP_ESTABLISHED) || + (!socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_http_proxy_enable) || + (!socket_ptr -> nx_tcp_socket_client_type) || + (socket_ptr -> nx_tcp_socket_http_proxy_state == NX_HTTP_PROXY_STATE_CONNECTED)) +#endif /* NX_ENABLE_HTTP_PROXY */ + { + /* The desired state is present, return success! */ + return(NX_SUCCESS); + } } /* Check to see if there is more time to wait. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c index 036430ae..00e76dab 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nx_utility.c @@ -318,7 +318,7 @@ UINT size; /* FUNCTION RELEASE */ /* */ /* _nx_utility_base64_encode PORTABLE C */ -/* 6.1.6 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -353,6 +353,9 @@ UINT size; /* DATE NAME DESCRIPTION */ /* */ /* 04-02-2021 Yuxin Zhou Initial Version 6.1.6 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), */ +/* improved the internal logic,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_utility_base64_encode(UCHAR *name, UINT name_size, UCHAR *base64name, UINT base64name_size, UINT *bytes_copied) @@ -360,6 +363,7 @@ UINT _nx_utility_base64_encode(UCHAR *name, UINT name_size, UCHAR *base64name, U UINT pad; UINT i, j; UINT step; +UINT input_name_size = name_size; /* Check for invalid input pointers. */ @@ -422,7 +426,16 @@ UINT step; { /* Use last 2 bits of name character and first 4 bits of next name character for index. */ - base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0x3) << 4) | (((UCHAR)name[i + 1]) >> 4)]; + if ((i + 1) < input_name_size) + { + base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0x3) << 4) | (((UCHAR)name[i + 1]) >> 4)]; + } + else + { + + /* If no more name character, pad with zero. */ + base64name[j++] = (UCHAR)_nx_utility_base64_array[(((UCHAR)name[i]) & 0x3) << 4]; + } i++; step++; } @@ -430,7 +443,16 @@ UINT step; { /* Use last 4 bits of name character and first 2 bits of next name character for index. */ - base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0xF) << 2) | (((UCHAR)name[i + 1]) >> 6)]; + if ((i + 1) < input_name_size) + { + base64name[j++] = (UCHAR)_nx_utility_base64_array[((((UCHAR)name[i]) & 0xF) << 2) | (((UCHAR)name[i + 1]) >> 6)]; + } + else + { + + /* If no more name character, pad with zero. */ + base64name[j++] = (UCHAR)_nx_utility_base64_array[(((UCHAR)name[i]) & 0xF) << 2]; + } i++; step++; } @@ -444,12 +466,6 @@ UINT step; } } - /* Determine if the index needs to be advanced. */ - if (step != 3) - { - i++; - } - /* Now add the PAD characters. */ while (pad--) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c index a2df3662..2cf3bc3a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/common/src/nxd_tcp_client_socket_connect.c @@ -31,6 +31,9 @@ #include "nx_ipv6.h" #include "nx_ipv4.h" #include "nx_ip.h" +#ifdef NX_ENABLE_HTTP_PROXY +#include "nx_http_proxy_client.h" +#endif /* NX_ENABLE_HTTP_PROXY */ #ifdef NX_ENABLE_TCPIP_OFFLOAD @@ -188,7 +191,7 @@ NX_IP *ip_ptr; /* FUNCTION RELEASE */ /* */ /* _nxd_tcp_client_socket_connect PORTABLE C */ -/* 6.1.8 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -218,6 +221,7 @@ NX_IP *ip_ptr; /* interface. */ /* tx_mutex_get Obtain protection */ /* tx_mutex_put Release protection */ +/* _nx_http_proxy_client_initialize Initialize the HTTP Proxy */ /* */ /* CALLED BY */ /* */ @@ -233,6 +237,9 @@ NX_IP *ip_ptr; /* 08-02-2021 Yuxin Zhou Modified comment(s), and */ /* supported TCP/IP offload, */ /* resulting in version 6.1.8 */ +/* 10-31-2022 Wenhui Xie Modified comment(s), and */ +/* supported HTTP Proxy, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nxd_tcp_client_socket_connect(NX_TCP_SOCKET *socket_ptr, @@ -256,6 +263,15 @@ ULONG ip_address_log = 0; /* Setup IP pointer. */ ip_ptr = socket_ptr -> nx_tcp_socket_ip_ptr; +#ifdef NX_ENABLE_HTTP_PROXY + if (ip_ptr -> nx_ip_http_proxy_enable) + { + + /* Initialize the HTTP Proxy info and replace the peer IP and port with HTTP proxy server's IP and port. */ + _nx_http_proxy_client_initialize(socket_ptr, &server_ip, &server_port); + } +#endif /* NX_ENABLE_HTTP_PROXY */ + /* Make sure the server IP address is accesible. */ #ifndef NX_DISABLE_IPV4 if (server_ip -> nxd_ip_version == NX_IP_VERSION_V4) @@ -477,6 +493,15 @@ ULONG ip_address_log = 0; _nx_tcp_packet_send_syn(socket_ptr, (socket_ptr -> nx_tcp_socket_tx_sequence - 1)); } +#ifdef NX_ENABLE_HTTP_PROXY + if (ip_ptr -> nx_ip_http_proxy_enable) + { + + /* Set HTTP Proxy state as waiting for TCP connection. */ + socket_ptr -> nx_tcp_socket_http_proxy_state = NX_HTTP_PROXY_STATE_WAITING; + } +#endif /* NX_ENABLE_HTTP_PROXY */ + /* Optionally suspend the thread. If timeout occurs, return a connection timeout status. If immediate response is selected, return a connection in progress status. Only on a real connection should success be returned. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h index 28351191..c2420740 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/nx_user.h @@ -869,5 +869,71 @@ #define NX_ENABLE_TCPIP_OFFLOAD #endif +/* Defined, the secure settings */ +#define USE_NX_SECURE_TLS_DISABLE_TLS_1_1 0 +#if USE_NX_SECURE_TLS_DISABLE_TLS_1_1 +#define NX_SECURE_TLS_DISABLE_TLS_1_1 +#endif + +/* Defined, the DNS settings */ +#define USE_NX_DNS_CLIENT_USER_CREATE_PACKET_POOL 0 +#if USE_NX_DNS_CLIENT_USER_CREATE_PACKET_POOL +#define NX_DNS_CLIENT_USER_CREATE_PACKET_POOL +#endif + +#define USE_NX_DNS_CLIENT_CLEAR_QUEUE 0 +#if USE_NX_DNS_CLIENT_CLEAR_QUEUE +#define NX_DNS_CLIENT_CLEAR_QUEUE +#endif + +/* Defined, the MQTT settings */ +#define USE_NXD_MQTT_PING_TIMEOUT_DELAY 0 +#if USE_NXD_MQTT_PING_TIMEOUT_DELAY +#define NXD_MQTT_PING_TIMEOUT_DELAY 500 +#endif + +#define USE_NXD_MQTT_SOCKET_TIMEOUT 0 +#if USE_NXD_MQTT_SOCKET_TIMEOUT +#define NXD_MQTT_SOCKET_TIMEOUT 0 +#endif + +/* Defined, the SNTP settings */ +#define USE_NX_SNTP_CLIENT_MIN_SERVER_STRATUM 0 +#if USE_NX_SNTP_CLIENT_MIN_SERVER_STRATUM +#define NX_SNTP_CLIENT_MIN_SERVER_STRATUM 3 +#endif + +#define USE_NX_SNTP_CLIENT_MAX_ROOT_DISPERSION 0 +#if USE_NX_SNTP_CLIENT_MAX_ROOT_DISPERSION +#define NX_SNTP_CLIENT_MAX_ROOT_DISPERSION 0 +#endif + +#define USE_NX_SNTP_CURRENT_YEAR 0 +#if USE_NX_SNTP_CURRENT_YEAR +#define NX_SNTP_CURRENT_YEAR 2022 +#endif + +/* Defined, the Azure IoT Security Module settings */ +#define USE_NX_AZURE_DISABLE_IOT_SECURITY_MODULE 0 +#if USE_NX_AZURE_DISABLE_IOT_SECURITY_MODULE +#define NX_AZURE_DISABLE_IOT_SECURITY_MODULE +#endif + +/* Defined, the Azure Device Update settings */ +#define USE_NX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT 0 +#if USE_NX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT +#define NX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT 0 +#endif + +/* Defined, the device information for Azure IoT */ +#define USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_VENDOR 0 +#if USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_VENDOR +#define NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_VENDOR 4 +#endif + +#define USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_TYPE 0 +#if USE_NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_TYPE +#define NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_DEVICE_TYPE "RX65N-RSK" +#endif #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h index c00c758c..97b364ac 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo/ports/rxv2/gnu/inc/nx_port.h @@ -204,7 +204,7 @@ #ifdef NX_SYSTEM_INIT CHAR _nx_version_id[] = - "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Duo RXv2/GNU Version 6.1.11 *"; + "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Duo RXv2/GNU Version 6.2.0 *"; #else extern CHAR _nx_version_id[]; #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md index e96df1a0..5ae42406 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/CHANGELOG.md @@ -1,5 +1,10 @@ # Release History +## 1.3.2 (2022-07-07) + +### Other Changes + - Removed unreachable code in `az_http_policy_retry.c`. + ## 1.3.1 (2022-04-05) ### Bugs Fixed diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md index 3d21d9d4..21f6af93 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/README.md @@ -202,6 +202,11 @@ The following CMake options are available for adding/removing project features. This option can be set to any of the next values:
- No_value: default value is used and no_platform library is used.
- "POSIX": Provides implementation for Linux and Mac systems.
- "WIN32": Provides platform implementation for Windows based system
- "CUSTOM": Tells cmake to use an specific implementation provided by user. When setting this option, user must provide an implementation library and set option `AZ_CUSTOM_PLATFORM_IMPL_NAME` with the name of the library (i.e. -DAZ_PLATFORM_IMPL=CUSTOM -DAZ_CUSTOM_PLATFORM_IMPL_NAME=user_platform_lib). cmake will look for this library to link az_core No_value + +ADDRESS_SANITIZER +This option enables asan (address sanitizer). This works on Windows and Linux and will catch memory errors at runtime. This option may also work on other platforms supporting address sanitizer. Do not use this option in production as asan is not a hardening tool and can leak layout information and defeat ASLR. +OFF + - ``Samples``: Storage Samples are built by default using the default PAL and HTTP adapter (see [running samples](#running-samples)). This means that running samples without building an HTTP transport adapter would throw errors like: diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake index e573dc97..1dcf3e99 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/cmake-modules/AddAzureSDKforC.cmake @@ -17,7 +17,7 @@ include(FetchContent) FetchContent_Declare(azuresdkforc GIT_REPOSITORY https://github.com/Azure/azure-sdk-for-c.git - GIT_TAG 1.3.1) + GIT_TAG 1.3.2) FetchContent_GetProperties(azuresdkforc) if(NOT azuresdkforc_POPULATED) FetchContent_Populate(azuresdkforc) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h index d31a5bfe..a8391237 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/az_version.h @@ -17,7 +17,7 @@ /// The version in string format used for telemetry following the `semver.org` standard /// (https://semver.org). -#define AZ_SDK_VERSION_STRING "1.3.1" +#define AZ_SDK_VERSION_STRING "1.3.2" /// Major numeric identifier. #define AZ_SDK_VERSION_MAJOR 1 @@ -26,7 +26,7 @@ #define AZ_SDK_VERSION_MINOR 3 /// Patch numeric identifier. -#define AZ_SDK_VERSION_PATCH 1 +#define AZ_SDK_VERSION_PATCH 2 /// Optional pre-release identifier. SDK is in a pre-release state when present. #define AZ_SDK_VERSION_PRERELEASE diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h index 151cec55..6433ac14 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_config_internal.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines internal constants. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_CONFIG_INTERNAL_H #define _az_CONFIG_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h index 081ebc19..b6032e8b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_credentials_internal.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines internals used by credentials. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_CREDENTIALS_INTERNAL_H #define _az_CREDENTIALS_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h index 4bdbed00..d5df4693 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_http_internal.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines internals used by http. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_HTTP_INTERNAL_H #define _az_HTTP_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h index c38f0bcd..562b0450 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_log_internal.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines internals used by log. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_LOG_INTERNAL_H #define _az_LOG_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h index 33459a2d..e542d733 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_precondition_internal.h @@ -27,6 +27,11 @@ * code (or adding option -DPRECONDITIONS=OFF with cmake), all of the Azure SDK * precondition checking will be excluding making the binary code smaller and faster. We * recommend doing this before you ship your code. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. */ #ifndef _az_PRECONDITION_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h index 41105343..d0cec399 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_retry_internal.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines internals used by retry. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_RETRY_INTERNAL_H #define _az_RETRY_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h index 792b323e..d3f23c60 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/inc/azure/core/internal/az_span_internal.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines internals used by span. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_SPAN_INTERNAL_H #define _az_SPAN_INTERNAL_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h index 2c323dd0..e0e04ae5 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_hex_private.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines private implementation used by hex. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_HEX_PRIVATE_H #define _az_HEX_PRIVATE_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h index e8fd5a21..3744f9b2 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_header_validation_private.h @@ -7,6 +7,10 @@ * @brief This header defines a bit array that is used to validate whenever or not an ASCII char is * valid within an http header name. * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. */ #ifndef _az_HTTP_HEADER_VALIDATION_PRIVATE_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h index eb53d498..eb7babd1 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_logging_private.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines private implementation used by http logging. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_HTTP_POLICY_LOGGING_PRIVATE_H #define _az_HTTP_POLICY_LOGGING_PRIVATE_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c index f897b820..64fd9e67 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_policy_retry.c @@ -220,6 +220,4 @@ AZ_NODISCARD az_result az_http_pipeline_policy_retry( } } } - - return result; } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h index 63dd531c..482eb959 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_http_private.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines private implementation used by http. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_HTTP_PRIVATE_H #define _az_HTTP_PRIVATE_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h index ef2ef72e..db19e163 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_json_private.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines private implementation used by json. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_JSON_PRIVATE_H #define _az_JSON_PRIVATE_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h index 40229579..0e46251a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure-sdk-for-c/sdk/src/azure/core/az_span_private.h @@ -1,6 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +/** + * @file + * + * @brief Defines private implementation used by span. + * + * @note You MUST NOT use any symbols (macros, functions, structures, enums, etc.) + * prefixed with an underscore ('_') directly in your application code. These symbols + * are part of Azure SDK's internal implementation; we do not document these symbols + * and they are subject to change in future versions of the SDK which would break your code. + */ + #ifndef _az_SPAN_PRIVATE_H #define _az_SPAN_PRIVATE_H diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist index d873124e..aeba666c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/configs/RTOS_BASE.dist @@ -4,7 +4,7 @@ CONF_DEFINE_BASE(${g_core_config_path} base_dist.cmake) # DIST: overwrite configuration for specific distribution set(SECURITY_MODULE_VERSION_MAJOR 3) set(SECURITY_MODULE_VERSION_MINOR 5) -set(SECURITY_MODULE_VERSION_PATCH 2) +set(SECURITY_MODULE_VERSION_PATCH 4) set(ASC_COMPONENT_CONFIGURATION OFF) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h index 3ca55fbc..87384977 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/L4_BASE/asc_config.h @@ -21,13 +21,13 @@ extern "C" { /******************** * Core configuration *********************/ -/* Based on 2021.09.28-3.5.1 core tag */ +/* Based on 2022.07.19-3.5.3 core tag */ /* ID and version */ #define ASC_SECURITY_MODULE_ID "defender-iot-micro-agent" #define SECURITY_MODULE_VERSION_MAJOR 3 #define SECURITY_MODULE_VERSION_MINOR 5 -#define SECURITY_MODULE_VERSION_PATCH 2 +#define SECURITY_MODULE_VERSION_PATCH 4 #ifndef SECURITY_MODULE_VERSION_MAJOR #define SECURITY_MODULE_VERSION_MAJOR 0 #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h index f3e8a248..de0fdc6f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE/asc_config.h @@ -21,13 +21,13 @@ extern "C" { /******************** * Core configuration *********************/ -/* Based on 2021.09.28-3.5.1 core tag */ +/* Based on 2022.07.19-3.5.3 core tag */ /* ID and version */ #define ASC_SECURITY_MODULE_ID "defender-iot-micro-agent" #define SECURITY_MODULE_VERSION_MAJOR 3 #define SECURITY_MODULE_VERSION_MINOR 5 -#define SECURITY_MODULE_VERSION_PATCH 2 +#define SECURITY_MODULE_VERSION_PATCH 4 #ifndef SECURITY_MODULE_VERSION_MAJOR #define SECURITY_MODULE_VERSION_MAJOR 0 #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h index 96e7a7e8..8fdaa8db 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/inc/configs/RTOS_BASE_UT/asc_config.h @@ -21,13 +21,13 @@ extern "C" { /******************** * Core configuration *********************/ -/* Based on 2021.09.28-3.5.1 core tag */ +/* Based on 2022.07.19-3.5.3 core tag */ /* ID and version */ #define ASC_SECURITY_MODULE_ID "defender-iot-micro-agent" #define SECURITY_MODULE_VERSION_MAJOR 3 #define SECURITY_MODULE_VERSION_MINOR 5 -#define SECURITY_MODULE_VERSION_PATCH 2 +#define SECURITY_MODULE_VERSION_PATCH 4 #ifndef SECURITY_MODULE_VERSION_MAJOR #define SECURITY_MODULE_VERSION_MAJOR 0 #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in index 6f15cf84..e66d358f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/configs/asc_config.h.in @@ -1,7 +1,7 @@ /******************** * Core configuration *********************/ -/* Based on 2021.09.28-3.5.1 core tag */ +/* Based on 2022.07.19-3.5.3 core tag */ /* ID and version */ #cmakedefine ASC_SECURITY_MODULE_ID "@ASC_SECURITY_MODULE_ID@" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h index 71015e4e..06ca4a0b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_alloc.h @@ -1,6 +1,5 @@ #ifndef FLATCC_ALLOC_H #define FLATCC_ALLOC_H -#include #ifdef __cplusplus extern "C" { @@ -46,6 +45,7 @@ extern "C" { #include +#include /* ASC Disable memory allocation usage */ #ifdef ASC_SERIALIZER_USE_CUSTOM_ALLOCATOR #define FLATCC_ALLOC(n) NULL diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h index aff55ee5..69026e4e 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_emitter.h @@ -1,6 +1,5 @@ #ifndef FLATCC_EMITTER_H #define FLATCC_EMITTER_H -#include #ifdef __cplusplus extern "C" { @@ -20,6 +19,8 @@ extern "C" { #include #include +#include + #include "flatcc/flatcc_types.h" #include "flatcc/flatcc_iov.h" #include "flatcc/flatcc_alloc.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h index 0592f313..c07b7bce 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/flatcc_endian.h @@ -97,11 +97,11 @@ extern "C" { /* flatcc/portable/pendian.h sets LITTLE/BIG flags if possible, and always defines le16toh. */ #ifndef flatbuffers_is_native_pe -#if defined(__LITTLE_ENDIAN__) || FLATBUFFERS_LITTLEENDIAN +#if (__LITTLE_ENDIAN__==1) || FLATBUFFERS_LITTLEENDIAN #undef FLATBUFFERS_LITTLEENDIAN #define FLATBUFFERS_LITTLEENDIAN 1 #define flatbuffers_is_native_pe() (FLATBUFFERS_PROTOCOL_IS_LE) -#elif defined(__BIG_ENDIAN__) || (defined(FLATBUFFERS_LITTLEENDIAN) && !FLATBUFFERS_LITTLEENDIAN) +#elif (__BIG_ENDIAN__==1) || (defined(FLATBUFFERS_LITTLEENDIAN) && !FLATBUFFERS_LITTLEENDIAN) #undef FLATBUFFERS_LITTLEENDIAN #define FLATBUFFERS_LITTLEENDIAN 0 #define flatbuffers_is_native_pe() (FLATBUFFERS_PROTOCOL_IS_BE) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h index 122ba8e2..3b174ba0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian.h @@ -131,7 +131,7 @@ extern "C" { /* Assume it goes for all. */ #if !defined(le16toh) -#if defined(__LITTLE_ENDIAN__) +#if (__LITTLE_ENDIAN__==1) #define le16toh(v) (v) #define le32toh(v) (v) @@ -149,7 +149,7 @@ extern "C" { #define htobe32(v) bswap32(v) #define htobe64(v) bswap64(v) -#elif defined(__BIG_ENDIAN__) +#elif (__BIG_ENDIAN__==1) #define le16toh(v) bswap16(v) #define le32toh(v) bswap32(v) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h index f5ec75c5..5b8bf054 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/include/flatcc/portable/pendian_detect.h @@ -33,11 +33,11 @@ extern "C" { #ifdef __BYTE_ORDER__ -#if defined(__LITTLE_ENDIAN__) && __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ +#if (__LITTLE_ENDIAN__ == 1) && __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ #error __LITTLE_ENDIAN__ inconsistent with __BYTE_ORDER__ #endif -#if defined(__BIG_ENDIAN__) && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ +#if (__BIG_ENDIAN__ == 1) && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ #error __BIG_ENDIAN__ inconsistent with __BYTE_ORDER__ #endif @@ -45,7 +45,7 @@ extern "C" { #if \ - defined(__LITTLE_ENDIAN__) || \ + (__LITTLE_ENDIAN__ == 1) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \ defined(__ARMEL__) || defined(__THUMBEL__) || \ defined(__AARCH64EL__) || \ @@ -64,7 +64,7 @@ extern "C" { #endif #if \ - defined (__BIG_ENDIAN__) || \ + (__BIG_ENDIAN__ == 1) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __ORDER_BIG_ENDIAN) || \ defined(__ARMEB__) || defined(THUMBEB__) || defined (__AARCH64EB__) || \ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || \ @@ -107,7 +107,7 @@ extern "C" { #endif #endif /* __BYTE_ORDER__ */ -#if defined(__LITTLE_ENDIAN__) && defined(__BIG_ENDIAN__) +#if (__LITTLE_ENDIAN__ == 1) && (__BIG_ENDIAN__ == 1) #error conflicting definitions of __LITTLE_ENDIAN__ and __BIG_ENDIAN__ #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c index c64db798..fe89d234 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/deps/flatcc/src/runtime/emitter.c @@ -1,7 +1,7 @@ -#include - #include +#include + #ifdef ASC_SERIALIZER_USE_CUSTOM_ALLOCATOR #include "asc_security_core/serializer/page_allocator.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h index c3c55125..4ac97c76 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector.h @@ -11,11 +11,12 @@ #ifndef COLLECTOR_H #define COLLECTOR_H -#include #include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/component_info.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h index 7d10c475..a2683b4f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collector_collection.h @@ -11,10 +11,11 @@ #ifndef IOTSECURITY_COLLECTOR_COLLECTION_H #define IOTSECURITY_COLLECTOR_COLLECTION_H -#include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/collector.h" #include "asc_security_core/utils/collection/list.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h index b753fda1..f1e400ce 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/collectors_info.h @@ -11,10 +11,11 @@ #ifndef _COLLECTORS_INFO_H_ #define _COLLECTORS_INFO_H_ -#include #include +#include + #define COLLECTORS_INFO_SIZE COLLECTORS_COUNT typedef struct { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h index 164e73a9..1218e9c2 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/component_info.h @@ -11,10 +11,11 @@ #ifndef __COMPONENT_INFO_H__ #define __COMPONENT_INFO_H__ -#include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/components_factory_enum.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h index cfdbccf8..a9757951 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory.h @@ -11,11 +11,11 @@ #ifndef __COMPONENTS_FACTORY_H__ #define __COMPONENTS_FACTORY_H__ -#include #include #include +#include #include "asc_security_core/logger.h" #include "asc_security_core/utils/string_utils.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h index 79a7c50f..3328cdc2 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/components_factory_type.h @@ -11,10 +11,11 @@ #ifndef __COMPONENTS_FACTORY__TYPE_H__ #define __COMPONENTS_FACTORY__TYPE_H__ -#include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/component_info.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h index ec0f4cc8..96b8d97b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/core.h @@ -11,11 +11,12 @@ #ifndef CORE_H #define CORE_H -#include #include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/collector_collection.h" #include "asc_security_core/model/security_message.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h index 8adde4bc..ac0ea9c0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/logger.h @@ -11,6 +11,12 @@ #ifndef LOGGER_H #define LOGGER_H + +#include +#include +#include +#include + #include #define LOG_LEVEL_NOTSET 0 @@ -34,11 +40,6 @@ #define logger_set_timestamp(_s) #define logger_get_system_log_level() (LOG_LEVEL_NOTSET) #else - #include - #include - #include - #include - #include "asc_security_core/utils/macros.h" #include "asc_security_core/component_id.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h index 82b2e871..99602774 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/network_activity.h @@ -11,10 +11,11 @@ #ifndef OBJECT_NETWORK_ACTIVITY_H #define OBJECT_NETWORK_ACTIVITY_H -#include #include +#include + #include "asc_security_core/model/objects/transport_protocol.h" #include "asc_security_core/utils/collection/collection.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h index 1688a237..4ac54bf3 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/objects/system_information.h @@ -11,10 +11,11 @@ #ifndef OBJECT_SYSTEM_INFORMATION_H #define OBJECT_SYSTEM_INFORMATION_H -#include #include +#include + #include "asc_security_core/utils/collection/collection.h" typedef struct system_information_t { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h index 285fbb77..fb340441 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/model/security_message.h @@ -11,11 +11,12 @@ #ifndef SECURITY_MESSAGE_H #define SECURITY_MESSAGE_H -#include #include #include +#include + #include "asc_security_core/asc_result.h" typedef struct { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h index 17b0c4e9..0cbbfa29 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_def.h @@ -11,10 +11,11 @@ #ifndef OBJECT_POOL_DEF_H #define OBJECT_POOL_DEF_H -#include #include +#include + #include "asc_security_core/utils/collection/stack.h" typedef struct { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h index 08969400..40fbf1ff 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_dynamic.h @@ -11,10 +11,11 @@ #ifndef OBJECT_POOL_DYNAMIC_H #define OBJECT_POOL_DYNAMIC_H -#include #include +#include + #include "asc_security_core/object_pool_def.h" /* Pay your attention, that this implementation is not thread safe. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h index 911cfab9..9b1c8922 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/object_pool_static.h @@ -12,10 +12,11 @@ #ifndef OBJECT_POOL_STATIC_H #define OBJECT_POOL_STATIC_H -#include #include +#include + #include "asc_security_core/object_pool_def.h" /* Pay your attention, that this implementation is not thread safe. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h index 77578ee0..e5b7539b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer.h @@ -11,11 +11,12 @@ #ifndef SERIALIZER_H #define SERIALIZER_H -#include #include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/model/objects/objects.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h index d94dafb1..2d1255be 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/serializer/page_allocator.h @@ -11,10 +11,11 @@ #ifndef PAGE_ALLOCATOR_H #define PAGE_ALLOCATOR_H -#include #include +#include + #ifdef ASC_COLLECTOR_PROCESS_ENABLED #include "asc_security_core/model/objects/process.h" #define COLLECTOR_PROCESS_SIZE (ASC_COLLECTOR_PROCESS_IN_CACHE * sizeof(process_t)) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h index f2e021da..f9dc46c9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/bit_vector.h @@ -12,10 +12,10 @@ #ifndef __BIT_VECTOR_H__ #define __BIT_VECTOR_H__ -#include - #include +#include + #define __BV_VEC_IND(index) (index>>3) #define __BV_VEC_SHIFT(index) (index & 0x07) #define __BV_CEIL_DIV8(x) ((x>>3)+(!!(x & 0x07))) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h index 4ed2a56d..76cca0ad 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashset.h @@ -11,10 +11,11 @@ #ifndef HASHSET_H #define HASHSET_H -#include #include +#include + #include "asc_security_core/utils/collection/collection.h" /** diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h index f7374915..665f9c5f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/hashtable.h @@ -11,12 +11,13 @@ #ifndef __HASHTABLE_H__ #define __HASHTABLE_H__ -#include #include #include #include +#include + #include "asc_security_core/utils/collection/collection.h" /* Pay your attention, that this implementation is not thread safe. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h index 970b8eac..8e65b23c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/linked_list.h @@ -11,13 +11,15 @@ #ifndef LINKED_LIST_H #define LINKED_LIST_H -#include -#include "asc_security_core/utils/collection/collection.h" #include #include #include +#include + +#include "asc_security_core/utils/collection/collection.h" + #define LINKED_LIST_DECLARATIONS(type) \ typedef void (*linked_list_##type##_deinit_function)(type *item);\ typedef void (*linked_list_##type##_action)(type *item, void *context);\ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h index 69b56177..fd850258 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/list.h @@ -11,11 +11,12 @@ #ifndef __LIST_H__ #define __LIST_H__ -#include #include #include +#include + #include "asc_security_core/utils/collection/collection.h" /* Pay your attention, that this implementation is not thread safe. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h index dba22c91..116093e9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/collection/stack.h @@ -11,11 +11,12 @@ #ifndef STACK_H #define STACK_H -#include #include #include +#include + #include "asc_security_core/utils/collection/collection.h" /* Pay your attention, that this implementation is not thread safe. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h index ba73c6a4..c3473e90 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/iconv.h @@ -11,10 +11,11 @@ #ifndef ICONV_H #define ICONV_H -#include #include +#include + typedef struct { int code; char *string; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h index 33417d59..fb09d95a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ievent_loop.h @@ -11,10 +11,11 @@ #ifndef _IEVENT_LOOP_H_ #define _IEVENT_LOOP_H_ -#include #include +#include + #define EVENT_LOOP_DEFAULT_MAX_COUNT_RUN_UNTIL 100 /** diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h index 5332c42a..cf277f4b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/ifile.h @@ -11,12 +11,13 @@ #ifndef __IFILE_H__ #define __IFILE_H__ -#include #include #include #include +#include + #include "asc_security_core/asc_result.h" #include "asc_security_core/utils/istream.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h index 3308af39..62d9beab 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/irand.h @@ -11,10 +11,11 @@ #ifndef IRAND_H #define IRAND_H -#include #include +#include + /** * @brief Initialize the seed for rand generator. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h index 309c3c40..480bcb2f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/istream.h @@ -11,12 +11,13 @@ #ifndef __ISTREAM_H__ #define __ISTREAM_H__ -#include #include #include #include +#include + #include "asc_security_core/asc_result.h" /** diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h index 26b91fed..87cbc2f5 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/itime.h @@ -11,10 +11,11 @@ #ifndef ITIME_H #define ITIME_H -#include #include +#include + #define SEC_MIN (60) #define SEC_HOUR (SEC_MIN * 60) #define SEC_DAY (SEC_HOUR * 24) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h index a3cac6f6..7a61b3d5 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/string_utils.h @@ -11,11 +11,12 @@ #ifndef STRING_UTILS_H #define STRING_UTILS_H -#include #include #include +#include + #include "asc_security_core/asc_result.h" /** diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h index 268f8c46..ab6d7803 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/inc/asc_security_core/utils/uuid.h @@ -11,10 +11,10 @@ #ifndef IUUID_H #define IUUID_H -#include #include +#include /** * @brief Generate a binary uuid diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c index 21a518e6..9c927764 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collector_collection.c @@ -8,11 +8,12 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include #include #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/object_pool.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c index f41e966e..bbbd64c9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors/collector_heartbeat.c @@ -8,10 +8,10 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/components_manager.h" #include "asc_security_core/core.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c index 2a42f0e5..35192f9a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/collectors_info.c @@ -8,11 +8,11 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/object_pool.h" #include "asc_security_core/collectors_info.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c index cfb4dc8f..8371594b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_factory.c @@ -8,10 +8,11 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include #include +#include + #include "asc_security_core/components_factory_declarations.h" #include "asc_security_core/components_manager.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c index 839e269d..c2900b3c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/components_manager.c @@ -8,12 +8,12 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include #include #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/utils/string_utils.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c index 3bc97c6a..5a6be1cb 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/core.c @@ -8,12 +8,12 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include #include #include +#include + #include "asc_security_core/components_manager.h" #include "asc_security_core/logger.h" #include "asc_security_core/object_pool.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c index f53690a2..a9a99b33 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/logger.c @@ -8,14 +8,15 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ +#include +#include +#include + #include #include "asc_security_core/components_manager.h" // #define ASC_TIME_H_SUPPORT #if ASC_LOG_LEVEL != LOG_LEVEL_NOTSET -#include -#include -#include #ifdef ASC_TIME_H_SUPPORT #include diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c index e30ad63b..29cc2646 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/collector.c @@ -8,11 +8,11 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include #include +#include + #include "asc_security_core/utils/itime.h" #include "asc_security_core/logger.h" #include "asc_security_core/components_manager.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c index 6760cbfc..880bf5d4 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/model/security_message.c @@ -8,13 +8,12 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ - -#include - #include #include #include +#include + #include "asc_security_core/model/security_message.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c index 0f4a85ea..6f886aac 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/object_pool_static.c @@ -9,12 +9,11 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ - -#include - #include #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/object_pool_static.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c index 8b920a7b..a5f8c83f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/extensions/custom_builder_allocator.c @@ -8,10 +8,10 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/serializer/custom_builder_allocator.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c index 382fb59e..3d5ee06a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.c @@ -8,10 +8,10 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/model/schema/message_builder.h" #include "asc_security_core/utils/uuid.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h index 8bfb34db..2915c008 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/serializer/serializer_private.h @@ -11,11 +11,12 @@ #ifndef SERIALIZER_PRIVATE_H #define SERIALIZER_PRIVATE_H -#include #include #include +#include + #include "flatcc/flatcc_builder.h" #include "asc_security_core/utils/collection/collection.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c index ebe9840b..ed9cbdcb 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/bit_vector.c @@ -8,12 +8,11 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ - -#include - #include #include +#include + #include "asc_security_core/utils/collection/bit_vector.h" bool __bit_vector_set(char bit_vector[], int index, bool bit, int size) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c index aef1efe4..2bf330b8 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/hashtable.c @@ -8,11 +8,10 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ +#include #include -#include - #include #include #include diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c index 8eb6c225..d7b94015 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/collection/stack.c @@ -8,12 +8,11 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ - -#include - #include #include +#include + #include "asc_security_core/utils/collection/stack.h" collection_item_t *stack_pop(stack_collection_t *stack) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c index f5a55fa7..f93f6717 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/event_loop_be.c @@ -9,12 +9,12 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include #include #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/object_pool.h" #include "asc_security_core/utils/collection/list.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c index 4a304cb5..c50ea0a2 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/iconv.c @@ -8,14 +8,13 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ - -#include - #include #include #include #include +#include + #include "asc_security_core/utils/string_utils.h" #include "asc_security_core/utils/iconv.h" #include "asc_security_core/utils/string_utils.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c index 37ec8161..51170665 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/string_utils.c @@ -8,13 +8,13 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ -#include - #include #include #include #include +#include + #include "asc_security_core/logger.h" #include "asc_security_core/utils/string_utils.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c index f6b379d8..f0812046 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/iot-security-module-core/src/utils/uuid.c @@ -8,14 +8,13 @@ /* and in the root directory of this software. */ /* */ /*******************************************************************************/ - -#include - #include #include #include #include +#include + #include "asc_security_core/utils/irand.h" #include "asc_security_core/utils/uuid.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c index f2b4f0c5..9acc642d 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/nx_azure_iot_security_module.c @@ -8,12 +8,11 @@ /* and in the root directory of this software. */ /* */ /**************************************************************************/ - -#include - #include #include +#include + #include "nx_azure_iot_hub_client.h" #include "nx_azure_iot_security_module.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c index 3f0f4168..5dcd82bf 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/model/objects/object_network_activity_ext.c @@ -8,11 +8,10 @@ /* and in the root directory of this software. */ /* */ /**************************************************************************/ +#include #include -#include - #include "nx_api.h" #include "nx_ip.h" #include "nx_ipv6.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c index 2a30d7cf..7fbe0e43 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/azure_iot_security_module/src/utils/itime.c @@ -8,11 +8,10 @@ /* and in the root directory of this software. */ /* */ /**************************************************************************/ +#include #include -#include - #include "asc_security_core/utils/itime.h" static unix_time_callback_t _time_callback = NULL; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/README.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/README.md deleted file mode 100644 index be8207a5..00000000 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/README.md +++ /dev/null @@ -1,124 +0,0 @@ -# Azure IoT Middleware for Azure RTOS - -Azure IoT Middleware for Azure RTOS is a platform specific library that acts as a binding layer between the Azure RTOS and the [Azure SDK for Embedded C](https://github.com/Azure/azure-sdk-for-c/tree/master/sdk/docs/iot). Goals of this layer are following: - -* Expose smart client interfaces (IoTHub_Client, DeviceProvisioning_Client) for the customers, to be consumed in their application. -* Orchestrate the interaction between Embedded C SDK and platform. -* Provide Azure RTOS platform initialization. -* [IoT Plug and Play](https://docs.microsoft.com/azure/iot-develop/overview-iot-plug-and-play) support. -* Security capabilities. -* Resource limitation aware. -* Protocol support. - -## Getting Started - -Azure IoT Middleware for Azure RTOS stays as an addon for the Azure RTOS NetXDuo. It facilitates the MQTT and TLS stacks that have been provided in the NetXDuo. - -![diagram](./img/diagram.png) - -### Build - -The Azure IoT Middleware for Azure RTOS is built as part of the NetXDuo. Make sure you have defined the following *marcos* when building it: - -Module | Marcos | -| --- | --- | -| Azure IoT Middleware for Azure RTOS | `NX_ENABLE_EXTENDED_NOTIFY_SUPPORT`
`NX_SECURE_ENABLE`
`NXD_MQTT_CLOUD_ENABLE` -| Azure Defender for IoT security module | `NX_ENABLE_IP_PACKET_FILTER` - -**NOTE:** Azure Defender for IoT security module is enabled by default. You can define `NX_AZURE_DISABLE_IOT_SECURITY_MODULE` to disable it. [Learn more](#azure-defender-for-iot-security-module). - -Follow [this example](/ports/cortex_m7/iar/inc/nx_port.h) to see how to define these *marcos* in the header file. - -### Samples - -For complete samples on how to get started on different devices with Azure IoT Middleware for Azure RTOS, see the following samples: - -Manufacturer | Device | Samples | -| --- | --- | --- | -| Microchip | [ATSAME54-XPRO](https://www.microchip.com/developmenttools/productdetails/atsame54-xpro) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/Microchip/ATSAME54-XPRO) • [IAR](https://aka.ms/azrtos-sample/e54-iar) • [MPLAB](https://aka.ms/azrtos-sample/e54-mplab) -| MXCHIP | [AZ3166](https://aka.ms/iot-devkit) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/MXChip/AZ3166) -| NXP | [MIMXRT1060-EVK](https://www.nxp.com/design/development-boards/i-mx-evaluation-and-development-boards/mimxrt1060-evk-i-mx-rt1060-evaluation-kit:MIMXRT1060-EVK) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/NXP/MIMXRT1060-EVK) • [IAR](https://aka.ms/azrtos-sample/rt1060-iar) • [MCUXpresso](https://aka.ms/azrtos-sample/rt1060-mcuxpresso) -| STMicroelectronics | [STM32F746GDISCOVERY](https://www.st.com/en/evaluation-tools/32f746gdiscovery.html) | [IAR](https://aka.ms/azrtos-sample/f746g-iar) • [STM32Cube](https://aka.ms/azrtos-sample/f746g-cubeide) -| STMicroelectronics | [B-L4S5I-IOT01](https://www.st.com/en/evaluation-tools/b-l4s5i-iot01a.html) / [B-L475E-IOT01](https://www.st.com/en/evaluation-tools/b-l475e-iot01a.html) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/STMicroelectronics/STM32L4_L4%2B) • [IAR](https://aka.ms/azrtos-sample/l4s5-iar) • [STM32Cube](https://aka.ms/azrtos-sample/l4s5-cubeide) -| Renesas | [RX65N-RSK-2MB](https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/rx65n-2mb-starter-kit-plus-renesas-starter-kit-rx65n-2mb) | [GCC/CMake](https://github.com/azure-rtos/getting-started/tree/master/Renesas/RSK_RX65N_2MB) • [IAR](https://aka.ms/azrtos-samples/rx65n-rsk-2mb-iar) • [E2Studio CCRX](https://aka.ms/azrtos-samples/rx65n-rsk-2mb-ccrx) • [E2Studio GNURX](https://aka.ms/azrtos-samples/rx65n-rsk-2mb-gnurx) -| Renesas | [RX65N-Cloud-Kit](https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/rx65n-cloud-kit-renesas-rx65n-cloud-kit) | [E2Studio CCRX](https://aka.ms/azrtos-samples/rx65n-ck-ccrx) • [E2Studio GNURX](https://aka.ms/azrtos-samples/rx65n-ck-gnurx) - -## Features - -Basic features provided by [Azure SDK for Embedded C](https://github.com/Azure/azure-sdk-for-c/tree/master/sdk/docs/iot): -* Connect to IoTHub via MQTT. -* APIs following the IoT Plug and Play convention to implement Telemetry, Commands, Properties and Components defined in a DTDL model. -* Send device to cloud (D2C) message. -* Receive cloud to device (C2D) message. -* Device Twins. -* Receive direct method. -* Authentication: SAS Token. - -Enhanced features provided in middleware: -* Authentication: X.509 client certificate. -* Device Provisioning Service. -* JSON parser. - -## Azure Defender for IoT - -The [Azure Defender for IoT](https://docs.microsoft.com/azure/defender-for-iot/iot-security-azure-rtos) provides a comprehensive security solution for Azure RTOS devices. The middleware ships with the ASC for IoT Security Module built-in and enabled by default to detect common threats and potential malicious activities. - -### Opt-out - -To disable (opt-out) the module for your application, you can choose one of these two options: -* Define `NX_AZURE_DISABLE_IOT_SECURITY_MODULE` in NetXDuo header file such as [`nx_port.h`](/ports/cortex_m7/iar/inc/nx_port.h) when building the middleware. -* Call [`UINT nx_azure_iot_security_module_disable(NX_AZURE_IOT *nx_azure_iot_ptr)`](https://docs.microsoft.com/azure/defender-for-iot/azure-rtos-security-module-api#disable-azure-iot-security-module) in your application code. - -### Data collection - -By enabling the module, it analyzes inbound and outbound network activity on IPv4 and IPv6 supported protocols: -* TCP -* UDP -* ICMP - -And with below data collected: -* Local and remote address -* Local and remote port -* Bytes in -* Bytes out - -### Resource requirements: - -ASC for IoT module leverages existing Azure RTOS resources, and sends security messages in the background, without interfering with the user application, using the same connection to the IoT Hub. - -The extra resource it will take on device and connection: - -**Memory Footprint** (using default config - 4 unique monitored connection in IPv4 in an hour): -Toolchain | RAM | ROM | -| --- | --- | --- | -| IAR Embedded Workbench (iccarm) | 4Kb | 10Kb -| GUN ARM Embedded Toolchain (arm-gcc) | 4Kb | 13Kb - -**Additional Connection**: -Connection Type | RAM | Network | -| --- | --- | --- | -| IPv4 | 52bytes | 36bytes -| IPv6 | 200bytes | 60bytes - -So the total additional connection traffic will be: -*Total (in bytes) = Metadata (e.g. 300 bytes) + IPv4 Connections * 36 + IPv6 Connections * 60* - -Learn [here](https://docs.microsoft.com/en-us/azure/defender-for-iot) for more information about Azure Defender for IoT. - -## APIs - -* [nx_azure_iot](./azure_rtos_iot.md) -* [nx_azure_iot_hub_client](./azure_rtos_iot_hub_client.md) -* [nx_azure_iot_hub_client_properties](./azure_rtos_iot_hub_client_properties.md) -* [nx_azure_iot_provisioning_client](./azure_rtos_iot_provisioning_client.md) -* [nx_azure_iot_json](./azure_rtos_iot_json.md) -* [nx_azure_iot_security_module](../azure_iot_security_module/docs/nx_azure_iot_security_module.md) - -## Need Help? - -* File an issue via [Github Issues](https://github.com/azure-rtos/netxduo/issues/new/choose). -* Check [previous questions](https://stackoverflow.com/questions/tagged/azure-rtos+netxduo) or ask new ones on StackOverflow using the [azure-rtos](https://stackoverflow.com/questions/tagged/azure-rtos) and [netxduo](https://stackoverflow.com/questions/tagged/netxduo) tags. - -## Licensing - -View [Licensing](https://github.com/azure-rtos/netxduo#licensing) of Azure RTOS NetXDuo. diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md index 5323cbf6..67144460 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/azure_rtos_iot_hub_client.md @@ -11,6 +11,7 @@ * [nx_azure_iot_hub_client_trusted_cert_add](#nx_azure_iot_hub_client_trusted_cert_add) * [nx_azure_iot_hub_client_device_cert_set](#nx_azure_iot_hub_client_device_cert_set) * [nx_azure_iot_hub_client_symmetric_key_set](#nx_azure_iot_hub_client_symmetric_key_set) +* [nx_azure_iot_hub_client_websocket_enable](#nx_azure_iot_hub_client_websocket_enable) * [nx_azure_iot_hub_client_connect](#nx_azure_iot_hub_client_connect) * [nx_azure_iot_hub_client_disconnect](#nx_azure_iot_hub_client_disconnect) * [nx_azure_iot_hub_client_connection_status_callback_set](#nx_azure_iot_hub_client_connection_status_callback_set) @@ -328,6 +329,39 @@ Threads
+#### **nx_azure_iot_hub_client_websocket_enable** +*** +
Enables MQTT over WebSocket to connect to IoT Hub
+ +**Prototype** +```c +UINT nx_azure_iot_hub_client_websocket_enable(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr); +``` +**Description** + +

This routine enables MQTT over WebSocket to connect to the Azure IoT Hub.

+ +**Parameters** + +| Name | Description | +| - |:-| +| hub_client_ptr [in] | A pointer to a `NX_AZURE_IOT_HUB_CLIENT` | + + +**Return Values** +* NX_AZURE_IOT_SUCCESS Successful if MQTT over Websocket is enabled. +* NX_AZURE_IOT_INVALID_PARAMETER Fail to enable MQTT over WebSocket due to invalid parameter. + +**Allowed From** + +Threads + +**Example** + +**See Also** + +
+ #### **nx_azure_iot_hub_client_connect** ***
Connects to IoT Hub
diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/img/iothub_configuration.png b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/img/iothub_configuration.png deleted file mode 100644 index 4ffeb0ad..00000000 Binary files a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/docs/img/iothub_configuration.png and /dev/null differ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c index a58a44b4..06bfcf68 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.c @@ -10,14 +10,15 @@ /**************************************************************************/ /* Version: 6.1 */ +#include +#include + -#include "nx_azure_iot.h" #ifndef NX_AZURE_DISABLE_IOT_SECURITY_MODULE #include "nx_azure_iot_security_module.h" #endif /* NX_AZURE_DISABLE_IOT_SECURITY_MODULE */ -#include -#include +#include "nx_azure_iot.h" #include "azure/core/internal/az_log_internal.h" diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h index 24feea38..beee5e74 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot.h @@ -142,6 +142,7 @@ UINT nx_azure_iot_log(UCHAR *type_ptr, UINT type_len, UCHAR *msg_ptr, UINT msg_l #define NX_AZURE_IOT_EMPTY_JSON 0x20016 #define NX_AZURE_IOT_SAS_TOKEN_EXPIRED 0x20017 +#define NX_AZURE_IOT_NO_MORE_ENTRIES 0x20018 /* Resource type managed by AZ_IOT. */ #define NX_AZURE_IOT_RESOURCE_IOT_HUB 0x1 diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c index 534381a3..c10323da 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.c @@ -50,6 +50,8 @@ static UCHAR _nx_azure_iot_hub_client_user_agent[] = NX_AZURE_IOT_HUB_CLIENT_USE #define NX_AZURE_IOT_HUB_CLIENT_COMPONENT_STRING "$.sub" +#define NX_AZURE_IOT_HUB_CLIENT_WEB_SOCKET_PATH "/$iothub/websocket" + static VOID nx_azure_iot_hub_client_received_message_cleanup(NX_AZURE_IOT_HUB_CLIENT_RECEIVE_MESSAGE *message); static UINT nx_azure_iot_hub_client_cloud_message_sub_unsub(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr, UINT is_subscribe); @@ -351,6 +353,25 @@ ULONG index; } #endif /* NX_AZURE_IOT_HUB_CLIENT_USER_AGENT_UPDATE */ +#ifdef NXD_MQTT_OVER_WEBSOCKET +UINT nx_azure_iot_hub_client_websocket_enable(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr) +{ +NX_AZURE_IOT_RESOURCE *resource_ptr; + + if (hub_client_ptr == NX_NULL) + { + LogError(LogLiteralArgs("IoTHub WebSocket enable fail: INVALID POINTER")); + return(NX_AZURE_IOT_INVALID_PARAMETER); + } + + /* Set resource pointer. */ + resource_ptr = &(hub_client_ptr -> nx_azure_iot_hub_client_resource); + + return(nxd_mqtt_client_websocket_set(&(resource_ptr -> resource_mqtt), (UCHAR *)resource_ptr -> resource_hostname, resource_ptr -> resource_hostname_length, + (UCHAR *)NX_AZURE_IOT_HUB_CLIENT_WEB_SOCKET_PATH, sizeof(NX_AZURE_IOT_HUB_CLIENT_WEB_SOCKET_PATH) - 1)); +} +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + UINT nx_azure_iot_hub_client_connect(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr, UINT clean_session, UINT wait_option) { @@ -364,6 +385,7 @@ VOID *buffer_context; UINT buffer_length; ULONG expiry_time_secs; az_result core_result; +UINT server_port; /* Check for invalid input pointers. */ if ((hub_client_ptr == NX_NULL) || (hub_client_ptr -> nx_azure_iot_ptr == NX_NULL)) @@ -530,8 +552,21 @@ az_result core_result; /* Release the mutex. */ tx_mutex_put(hub_client_ptr -> nx_azure_iot_ptr -> nx_azure_iot_mutex_ptr); +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (mqtt_client_ptr -> nxd_mqtt_client_use_websocket == NX_TRUE) + { + server_port = NXD_MQTT_OVER_WEBSOCKET_TLS_PORT; + } + else + { + server_port = NXD_MQTT_TLS_PORT; + } +#else + server_port = NXD_MQTT_TLS_PORT; +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /* Start MQTT connection. */ - status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, NXD_MQTT_TLS_PORT, + status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, server_port, nx_azure_iot_mqtt_tls_setup, NX_AZURE_IOT_MQTT_KEEP_ALIVE, clean_session, wait_option); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h index bbac0862..4ff16d59 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client.h @@ -279,6 +279,21 @@ UINT nx_azure_iot_hub_client_component_add(NX_AZURE_IOT_HUB_CLIENT *hub_client_p const UCHAR *component_name_ptr, USHORT component_name_length); +#ifdef NXD_MQTT_OVER_WEBSOCKET +/** + * @brief Enable using MQTT over WebSocket to connect to IoTHub. + * + * @param[in] hub_client_ptr A pointer to a #NX_AZURE_IOT_HUB_CLIENT. + * @return A `UINT` with the result of the API. + * @retval #NX_AZURE_IOT_SUCCESS Successful if MQTT over WebSocket is enabled. + * @retval #NX_AZURE_IOT_INVALID_PARAMETER Fail to enable C2D message receiving due to invalid parameter. + * @retval NXD_MQTT_NOT_CONNECTED Fail to enable C2D message receiving due to MQTT not connected. + * @retval NXD_MQTT_PACKET_POOL_FAILURE Fail to enable C2D message receiving due to no available packet in pool. + * @retval NXD_MQTT_COMMUNICATION_FAILURE Fail to enable C2D message receiving due to TCP/TLS error. + */ +UINT nx_azure_iot_hub_client_websocket_enable(NX_AZURE_IOT_HUB_CLIENT *hub_client_ptr); +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /** * @brief Connect to IoT Hub. * diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c index b8ed4ef3..cd1740aa 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_hub_client_properties.c @@ -187,7 +187,7 @@ UINT system_component; return(NX_AZURE_IOT_INVALID_PARAMETER); } - component_name = az_span_create((UCHAR *)component_name_pptr, (INT)*component_name_length_ptr); + component_name = az_span_create((UCHAR *)*component_name_pptr, (INT)*component_name_length_ptr); core_message_type = (message_type == NX_AZURE_IOT_HUB_PROPERTIES) ? AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_GET_RESPONSE : AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_WRITABLE_UPDATED; core_property_type = (property_type == NX_AZURE_IOT_HUB_CLIENT_PROPERTY_REPORTED_FROM_DEVICE) ? AZ_IOT_HUB_CLIENT_PROPERTY_REPORTED_FROM_DEVICE : diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c index 381be453..9cc94f97 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.c @@ -33,6 +33,8 @@ #define NX_AZURE_IOT_PROVISIONING_CLIENT_PAYLOAD_END "}" #define NX_AZURE_IOT_PROVISIONING_CLIENT_POLICY_NAME "registration" +#define NX_AZURE_IOT_PROVISIONING_CLIENT_WEB_SOCKET_PATH "/$iothub/websocket" + /* Set the default retry to Provisioning service. */ #ifndef NX_AZURE_IOT_PROVISIONING_CLIENT_DEFAULT_RETRY #define NX_AZURE_IOT_PROVISIONING_CLIENT_DEFAULT_RETRY (3) @@ -134,6 +136,7 @@ UINT status; NXD_ADDRESS server_address; NXD_MQTT_CLIENT *mqtt_client_ptr; NX_AZURE_IOT_RESOURCE *resource_ptr; +UINT server_port; /* Resolve the host name. */ status = nxd_dns_host_by_name_get(prov_client_ptr -> nx_azure_iot_ptr -> nx_azure_iot_dns_ptr, @@ -161,8 +164,21 @@ NX_AZURE_IOT_RESOURCE *resource_ptr; return(status); } +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (mqtt_client_ptr -> nxd_mqtt_client_use_websocket == NX_TRUE) + { + server_port = NXD_MQTT_OVER_WEBSOCKET_TLS_PORT; + } + else + { + server_port = NXD_MQTT_TLS_PORT; + } +#else + server_port = NXD_MQTT_TLS_PORT; +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /* Start MQTT connection. */ - status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, NXD_MQTT_TLS_PORT, + status = nxd_mqtt_client_secure_connect(mqtt_client_ptr, &server_address, server_port, nx_azure_iot_mqtt_tls_setup, NX_AZURE_IOT_MQTT_KEEP_ALIVE, NX_FALSE, wait_option); @@ -1091,6 +1107,24 @@ NX_AZURE_IOT_RESOURCE *resource_ptr; } } +#ifdef NXD_MQTT_OVER_WEBSOCKET +UINT nx_azure_iot_provisioning_client_websocket_enable(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr) +{ +NX_AZURE_IOT_RESOURCE *resource_ptr; + + if (prov_client_ptr == NX_NULL) + { + LogError(LogLiteralArgs("IoTProvisioning client WebSocket enable fail: INVALID POINTER")); + return(NX_AZURE_IOT_INVALID_PARAMETER); + } + + /* Set resource pointer. */ + resource_ptr = &(prov_client_ptr -> nx_azure_iot_provisioning_client_resource); + + return(nxd_mqtt_client_websocket_set(&(resource_ptr -> resource_mqtt), (UCHAR *)resource_ptr -> resource_hostname, resource_ptr -> resource_hostname_length, + (UCHAR *)NX_AZURE_IOT_PROVISIONING_CLIENT_WEB_SOCKET_PATH, sizeof(NX_AZURE_IOT_PROVISIONING_CLIENT_WEB_SOCKET_PATH) - 1)); +} +#endif /* NXD_MQTT_OVER_WEBSOCKET */ static VOID nx_azure_iot_provisioning_client_event_process(NX_AZURE_IOT *nx_azure_iot_ptr, ULONG common_events, ULONG module_own_events) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h index 65630bfe..01d88dbc 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/azure_iot/nx_azure_iot_provisioning_client.h @@ -200,6 +200,18 @@ UINT nx_azure_iot_provisioning_client_device_cert_set(NX_AZURE_IOT_PROVISIONING_ UINT nx_azure_iot_provisioning_client_symmetric_key_set(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr, const UCHAR *symmetric_key, UINT symmetric_key_length); +#ifdef NXD_MQTT_OVER_WEBSOCKET +/** + * @brief Enable using MQTT over WebSocket to register device to Azure IoT Provisioning service. + * + * @param[in] prov_client_ptr A pointer to a #NX_AZURE_IOT_PROVISIONING_CLIENT. + * @return A `UINT` with the result of the API. + * @retval #NX_AZURE_IOT_SUCCESS Successful if MQTT over WebSocket is enabled. + * @retval #NX_AZURE_IOT_INVALID_PARAMETER Fail to enable MQTT over WebSocket due to invalid parameter. + */ +UINT nx_azure_iot_provisioning_client_websocket_enable(NX_AZURE_IOT_PROVISIONING_CLIENT *prov_client_ptr); +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /** * @brief Register device to Azure IoT Provisioning service. * @details This routine registers device to Azure IoT Provisioning service. diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c index 750c2762..e7131477 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcp_client.c @@ -154,7 +154,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_create PORTABLE C */ -/* 6.1.10 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -210,6 +210,10 @@ UINT status; /* 01-31-2022 Yuxin Zhou Modified comment(s), supported*/ /* multiple client instances, */ /* resulting in version 6.1.10 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), cleaned */ +/* up error check logic, and */ +/* properly terminated thread, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dhcp_create(NX_DHCP *dhcp_ptr, NX_IP *ip_ptr, CHAR *name_ptr) @@ -327,16 +331,8 @@ UINT label_length = 0; } /* Create the pool and check the status */ - status = nx_packet_pool_create(&dhcp_ptr -> nx_dhcp_pool, "NetX DHCP Client", NX_DHCP_PACKET_PAYLOAD, - dhcp_ptr -> nx_dhcp_pool_area, NX_DHCP_PACKET_POOL_SIZE); - - /* Determine if it was successful. */ - if (status != NX_SUCCESS) - { - - /* No, return error status. */ - return(status); - } + nx_packet_pool_create(&dhcp_ptr -> nx_dhcp_pool, "NetX DHCP Client", NX_DHCP_PACKET_PAYLOAD, + dhcp_ptr -> nx_dhcp_pool_area, NX_DHCP_PACKET_POOL_SIZE); /* Set an internal packet pool pointer to the newly created packet pool. */ dhcp_ptr -> nx_dhcp_packet_pool_ptr = &dhcp_ptr -> nx_dhcp_pool; @@ -350,39 +346,11 @@ UINT label_length = 0; #endif /* NX_DHCP_CLIENT_USER_CREATE_PACKET_POOL */ /* Create the Socket and check the status */ - status = nx_udp_socket_create(ip_ptr, &(dhcp_ptr -> nx_dhcp_socket), "NetX DHCP Client", - NX_DHCP_TYPE_OF_SERVICE, NX_DHCP_FRAGMENT_OPTION, NX_DHCP_TIME_TO_LIVE, NX_DHCP_QUEUE_DEPTH); - - /* Was the socket creation successful? */ - if (status != NX_SUCCESS) - { - -#ifndef NX_DHCP_CLIENT_USER_CREATE_PACKET_POOL - /* Delete the packet pool. */ - nx_packet_pool_delete(dhcp_ptr -> nx_dhcp_packet_pool_ptr); -#endif - - /* No, return error status. */ - return(status); - } - + nx_udp_socket_create(ip_ptr, &(dhcp_ptr -> nx_dhcp_socket), "NetX DHCP Client", + NX_DHCP_TYPE_OF_SERVICE, NX_DHCP_FRAGMENT_OPTION, NX_DHCP_TIME_TO_LIVE, NX_DHCP_QUEUE_DEPTH); /* Set the UDP socket receive callback function. */ - status = nx_udp_socket_receive_notify(&(dhcp_ptr -> nx_dhcp_socket), _nx_dhcp_udp_receive_notify); - - /* Check status. */ - if (status != NX_SUCCESS) - { - - -#ifndef NX_DHCP_CLIENT_USER_CREATE_PACKET_POOL - /* Delete the packet pool. */ - nx_packet_pool_delete(dhcp_ptr -> nx_dhcp_packet_pool_ptr); -#endif - - /* Delete the UDP socket. */ - nx_udp_socket_delete(&(dhcp_ptr -> nx_dhcp_socket)); - } + nx_udp_socket_receive_notify(&(dhcp_ptr -> nx_dhcp_socket), _nx_dhcp_udp_receive_notify); dhcp_ptr -> nx_dhcp_socket.nx_udp_socket_reserved_ptr = (VOID*)dhcp_ptr; @@ -468,6 +436,9 @@ UINT label_length = 0; if (status != TX_SUCCESS) { + /* First put the thread into TERMINATE state. */ + tx_thread_terminate(&(dhcp_ptr -> nx_dhcp_thread)); + /* Delete the thread. */ tx_thread_delete(&(dhcp_ptr -> nx_dhcp_thread)); @@ -1173,7 +1144,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_interface_reinitialize PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1219,6 +1190,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dhcp_interface_reinitialize(NX_DHCP *dhcp_ptr, UINT iface_index) @@ -1250,10 +1224,10 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; { /* Get the IP address. */ - status = nx_ip_interface_address_get(dhcp_ptr -> nx_dhcp_ip_ptr, iface_index, &ip_address, &network_mask); + nx_ip_interface_address_get(dhcp_ptr -> nx_dhcp_ip_ptr, iface_index, &ip_address, &network_mask); /* Check if the IP address is set by DHCP. */ - if ((status == NX_SUCCESS) && (ip_address == interface_record -> nx_dhcp_ip_address)) + if (ip_address == interface_record -> nx_dhcp_ip_address) { /* Clear the IP address. */ @@ -2352,7 +2326,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_interface_decline PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2392,13 +2366,15 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dhcp_interface_decline(NX_DHCP *dhcp_ptr, UINT iface_index) { UINT status; -UINT original_state; NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; @@ -2426,9 +2402,6 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; return(NX_DHCP_NOT_BOUND); } - /* Get the original state. */ - original_state = interface_record -> nx_dhcp_state; - /* Send the decline DHCP request. */ _nx_dhcp_send_request_internal(dhcp_ptr, interface_record, NX_DHCP_TYPE_DHCPDECLINE); @@ -2444,25 +2417,20 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; /* Set the retransmission interval. */ interface_record -> nx_dhcp_rtr_interval = 0; - /* Check if the state is changed. */ - if (original_state != interface_record -> nx_dhcp_state) + /* Determine if the application has specified a routine for DHCP state change notification. */ + if (dhcp_ptr -> nx_dhcp_state_change_callback) { - /* Determine if the application has specified a routine for DHCP state change notification. */ - if (dhcp_ptr -> nx_dhcp_state_change_callback) - { - - /* Yes, call the application's state change notify function with the new state. */ - (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state); - } + /* Yes, call the application's state change notify function with the new state. */ + (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state); + } - /* Determine if the application has specified a routine for DHCP interface state change notification. */ - if (dhcp_ptr -> nx_dhcp_interface_state_change_callback) - { + /* Determine if the application has specified a routine for DHCP interface state change notification. */ + if (dhcp_ptr -> nx_dhcp_interface_state_change_callback) + { - /* Yes, call the application's state change notify function with the new state. */ - (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state); - } + /* Yes, call the application's state change notify function with the new state. */ + (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state); } /* Release the DHCP mutex. */ @@ -2680,7 +2648,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_interface_release PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2721,13 +2689,16 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dhcp_interface_release(NX_DHCP *dhcp_ptr, UINT iface_index) { UINT i; -UINT status, original_state; +UINT status; NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; @@ -2758,34 +2729,26 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; return(NX_DHCP_NOT_BOUND); } - /* Get the original state. */ - original_state = interface_record -> nx_dhcp_state; - /* Send the release DHCP request. */ _nx_dhcp_send_request_internal(dhcp_ptr, interface_record, NX_DHCP_TYPE_DHCPRELEASE); - /* Reinitialize DHCP. */ + /* Reinitialize DHCP. Note: the state is changed to NX_DHCP_STATE_NOT_STARTED in this function. */ _nx_dhcp_interface_reinitialize(dhcp_ptr, iface_index); - /* Check if the state is changed. */ - if (original_state != interface_record -> nx_dhcp_state) + /* Determine if the application has specified a routine for DHCP state change notification. */ + if (dhcp_ptr -> nx_dhcp_state_change_callback) { - /* Determine if the application has specified a routine for DHCP state change notification. */ - if (dhcp_ptr -> nx_dhcp_state_change_callback) - { - - /* Yes, call the application's state change notify function with the new state. */ - (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state); - } + /* Yes, call the application's state change notify function with the new state. */ + (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state); + } - /* Determine if the application has specified a routine for DHCP interface state change notification. */ - if (dhcp_ptr -> nx_dhcp_interface_state_change_callback) - { + /* Determine if the application has specified a routine for DHCP interface state change notification. */ + if (dhcp_ptr -> nx_dhcp_interface_state_change_callback) + { - /* Yes, call the application's state change notify function with the new state. */ - (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state); - } + /* Yes, call the application's state change notify function with the new state. */ + (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record -> nx_dhcp_state); } /* Check if other interfaces are running DHCP. */ @@ -2805,20 +2768,15 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; return(NX_SUCCESS); } } - - /* Has DHCP stopped on all interfaces? */ - if (i == NX_DHCP_CLIENT_MAX_RECORDS) - { - - /* Yes, stop DHCP Thread. */ - tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread)); + + /* Yes, stop DHCP Thread. */ + tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread)); - /* Deactivate DHCP Timer. */ - tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer)); + /* Deactivate DHCP Timer. */ + tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer)); - /* Unbind UDP socket. */ - nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket)); - } + /* Unbind UDP socket. */ + nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket)); /* Release the DHCP mutex. */ tx_mutex_put(&(dhcp_ptr -> nx_dhcp_mutex)); @@ -4061,7 +4019,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_interface_stop PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4107,6 +4065,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dhcp_interface_stop(NX_DHCP *dhcp_ptr, UINT iface_index) @@ -4114,7 +4075,6 @@ UINT _nx_dhcp_interface_stop(NX_DHCP *dhcp_ptr, UINT iface_index) UINT i; UINT status; -UINT original_state; NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; @@ -4133,9 +4093,6 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; return(status); } - /* Get the original state. */ - original_state = interface_record -> nx_dhcp_state; - /* Determine if DHCP is started. */ if (interface_record -> nx_dhcp_state == NX_DHCP_STATE_NOT_STARTED) { @@ -4150,25 +4107,20 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; /* Set the state to NX_DHCP_STATE_NOT_STARTED. */ interface_record -> nx_dhcp_state = NX_DHCP_STATE_NOT_STARTED; - /* Check if the state is changed. */ - if (original_state != interface_record -> nx_dhcp_state) + /* Determine if the application has specified a routine for DHCP state change notification. */ + if (dhcp_ptr -> nx_dhcp_state_change_callback) { - /* Determine if the application has specified a routine for DHCP state change notification. */ - if (dhcp_ptr -> nx_dhcp_state_change_callback) - { - - /* Yes, call the application's state change notify function with the new state. */ - (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state); - } + /* Yes, call the application's state change notify function with the new state. */ + (dhcp_ptr -> nx_dhcp_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_state); + } - /* Determine if the application has specified a routine for DHCP interface state change notification. */ - if (dhcp_ptr -> nx_dhcp_interface_state_change_callback) - { + /* Determine if the application has specified a routine for DHCP interface state change notification. */ + if (dhcp_ptr -> nx_dhcp_interface_state_change_callback) + { - /* Yes, call the application's state change notify function with the new state. */ - (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record->nx_dhcp_state); - } + /* Yes, call the application's state change notify function with the new state. */ + (dhcp_ptr -> nx_dhcp_interface_state_change_callback)(dhcp_ptr, interface_record -> nx_dhcp_interface_index, interface_record->nx_dhcp_state); } /* Check if other interfaces are running DHCP. */ @@ -4188,20 +4140,15 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; return(NX_SUCCESS); } } - - /* Has DHCP stopped on all interfaces? */ - if (i == NX_DHCP_CLIENT_MAX_RECORDS) - { - /* Yes, stop DHCP Thread. */ - tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread)); + /* Yes, stop DHCP Thread. */ + tx_thread_suspend(&(dhcp_ptr -> nx_dhcp_thread)); - /* Deactivate DHCP Timer. */ - tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer)); + /* Deactivate DHCP Timer. */ + tx_timer_deactivate(&(dhcp_ptr -> nx_dhcp_timer)); - /* Unbind UDP socket. */ - nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket)); - } + /* Unbind UDP socket. */ + nx_udp_socket_unbind(&(dhcp_ptr -> nx_dhcp_socket)); /* Release the DHCP mutex. */ tx_mutex_put(&(dhcp_ptr->nx_dhcp_mutex)); @@ -5290,7 +5237,7 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_packet_process PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5340,6 +5287,9 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID _nx_dhcp_packet_process(NX_DHCP *dhcp_ptr, NX_DHCP_INTERFACE_RECORD *interface_record, NX_PACKET *packet_ptr) @@ -5407,20 +5357,7 @@ ULONG probing_delay; /* Initialize the offset to the beginning of the packet buffer. */ offset = 0; status = nx_packet_data_extract_offset(packet_ptr, offset, (VOID *)new_packet_ptr -> nx_packet_prepend_ptr, (packet_ptr) -> nx_packet_length, &bytes_copied); - - /* Check status. */ - if ((status != NX_SUCCESS) || (bytes_copied == 0)) - { - - /* Release the allocated packet we'll never send. */ - nx_packet_release(new_packet_ptr); - - /* Release the original packet. */ - nx_packet_release(packet_ptr); - - /* Error extracting packet buffer, return error status. */ - return; - } + NX_ASSERT((status == NX_SUCCESS) && (bytes_copied > 0)); /* Update the new packet with the bytes copied. For chained packets, this will reflect the total 'datagram' length. */ @@ -5503,10 +5440,6 @@ ULONG probing_delay; /* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */ interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout); - /* Check if the timeout is zero. */ - if (interface_record -> nx_dhcp_timeout == 0) - interface_record -> nx_dhcp_timeout = 1; - /* Update the state to Requesting state. */ interface_record -> nx_dhcp_state = NX_DHCP_STATE_REQUESTING; } @@ -5624,10 +5557,6 @@ ULONG probing_delay; /* Use the minimum value, Wait one second to begain in INIT state and forms a DHCP Discovery message. */ interface_record -> nx_dhcp_timeout = NX_IP_PERIODIC_RATE; interface_record -> nx_dhcp_rtr_interval = 0; - - /* Check if the timeout is less than 1 second. */ - if (interface_record -> nx_dhcp_timeout < NX_IP_PERIODIC_RATE) - interface_record -> nx_dhcp_timeout = NX_IP_PERIODIC_RATE; } } break; @@ -5820,7 +5749,7 @@ ULONG probing_delay; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_timeout_process PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5864,6 +5793,9 @@ ULONG probing_delay; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID _nx_dhcp_timeout_process(NX_DHCP *dhcp_ptr) @@ -5979,10 +5911,6 @@ NX_IP *ip_ptr; /* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */ interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout); - /* Check if the timeout is zero. */ - if (interface_record -> nx_dhcp_timeout == 0) - interface_record -> nx_dhcp_timeout = 1; - break; } @@ -6006,10 +5934,6 @@ NX_IP *ip_ptr; /* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */ interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout); - /* Check if the timeout is zero. */ - if (interface_record -> nx_dhcp_timeout == 0) - interface_record -> nx_dhcp_timeout = 1; - break; } @@ -6033,10 +5957,6 @@ NX_IP *ip_ptr; /* This will modify the timeout by up to +/- 1 second as recommended by RFC 2131, Section 4.1, Page 24. */ interface_record -> nx_dhcp_timeout = _nx_dhcp_add_randomize(interface_record -> nx_dhcp_timeout); - /* Check if the timeout is zero. */ - if (interface_record -> nx_dhcp_timeout == 0) - interface_record -> nx_dhcp_timeout = 1; - break; } @@ -6604,7 +6524,7 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_send_request_internal PORTABLE C */ -/* 6.1.8 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6664,6 +6584,10 @@ NX_DHCP_INTERFACE_RECORD *interface_record = NX_NULL; /* adding additional request */ /* option in parameter request,*/ /* resulting in version 6.1.8 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), corrected*/ +/* the logic of adding server */ +/* identifier option, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static UINT _nx_dhcp_send_request_internal(NX_DHCP *dhcp_ptr, NX_DHCP_INTERFACE_RECORD *interface_record, UINT dhcp_message_type) @@ -6882,7 +6806,8 @@ UINT name_length; /* Should add server ID if not renewing. */ if ((interface_record -> nx_dhcp_state != NX_DHCP_STATE_RENEWING) && (interface_record -> nx_dhcp_state != NX_DHCP_STATE_REBINDING) && - (interface_record -> nx_dhcp_server_ip != NX_BOOTP_BC_ADDRESS) + (interface_record -> nx_dhcp_server_ip != NX_BOOTP_BC_ADDRESS) && + (interface_record -> nx_dhcp_server_ip != NX_BOOTP_NO_ADDRESS) ) { @@ -7067,7 +6992,7 @@ UINT name_length; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_client_send_with_zero_source_address PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -7108,6 +7033,12 @@ UINT name_length; /* 04-25-2022 Yuxin Zhou Modified comment(s), and */ /* set the IP header pointer, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* and solve inconformity with */ +/* udp socket send and ip */ +/* header add, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static UINT _nx_dhcp_client_send_with_zero_source_address(NX_DHCP *dhcp_ptr, UINT iface_index, NX_PACKET *packet_ptr) @@ -7119,7 +7050,9 @@ NX_UDP_HEADER *udp_header_ptr; NX_IPV4_HEADER *ip_header_ptr; NX_INTERFACE *interface_ptr; ULONG ip_src_addr, ip_dest_addr; -UINT compute_checksum; +#if defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) +UINT compute_checksum = 1; +#endif /* defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) */ ULONG checksum; ULONG val; NX_IP_DRIVER driver_request; @@ -7187,18 +7120,16 @@ NX_IP_DRIVER driver_request; #ifdef NX_DISABLE_UDP_TX_CHECKSUM compute_checksum = 0; -#else /* NX_DISABLE_UDP_TX_CHECKSUM */ - compute_checksum = 1; #endif /* NX_DISABLE_UDP_TX_CHECKSUM */ #ifdef NX_ENABLE_INTERFACE_CAPABILITY if (interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_UDP_TX_CHECKSUM) compute_checksum = 0; - else - compute_checksum = 1; #endif /* NX_ENABLE_INTERFACE_CAPABILITY */ +#if defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) if (compute_checksum) +#endif /* defined(NX_DISABLE_UDP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) */ { /* Yes, we need to compute the UDP checksum. */ checksum = _nx_ip_checksum_compute(packet_ptr, @@ -7267,18 +7198,19 @@ NX_IP_DRIVER driver_request; #ifdef NX_DISABLE_IP_TX_CHECKSUM compute_checksum = 0; -#else /* NX_DISABLE_IP_TX_CHECKSUM */ +#elif defined(NX_ENABLE_INTERFACE_CAPABILITY) + /* Re-initialize the value back to the default initial value (i.e. 1) */ compute_checksum = 1; -#endif /* NX_DISABLE_IP_TX_CHECKSUM */ +#endif /* defined(NX_DISABLE_IP_TX_CHECKSUM) */ #ifdef NX_ENABLE_INTERFACE_CAPABILITY if (packet_ptr -> nx_packet_address.nx_packet_interface_ptr -> nx_interface_capability_flag & NX_INTERFACE_CAPABILITY_IPV4_TX_CHECKSUM) compute_checksum = 0; - else - compute_checksum = 1; #endif /* NX_ENABLE_INTERFACE_CAPABILITY */ +#if defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) if (compute_checksum) +#endif /* defined(NX_DISABLE_IP_TX_CHECKSUM) || defined(NX_ENABLE_INTERFACE_CAPABILITY) */ { checksum = _nx_ip_checksum_compute(packet_ptr, NX_IP_VERSION_V4, 20, NULL, NULL); @@ -7690,7 +7622,7 @@ ULONG value; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_get_option_value PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -7730,6 +7662,9 @@ ULONG value; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static UINT _nx_dhcp_get_option_value(UCHAR *bootp_message, UINT option, ULONG *value, UINT length) @@ -7744,46 +7679,44 @@ UINT option_length; option_message = &bootp_message[NX_BOOTP_OFFSET_OPTIONS]; option_length = length - NX_BOOTP_OFFSET_OPTIONS; - /* Find the option. */ - if ((option != NX_DHCP_OPTION_PAD) && (option != NX_DHCP_OPTION_END)) - { + /* There is no need to check whether the option is PAD or END here since no caller will pass these 2 options + and for denfensive purpose, the function below could check them and guarantee appropriate behaviour */ + + /* Search the buffer for the option. */ + data = _nx_dhcp_search_buffer(option_message, option, option_length); - /* Search the buffer for the option. */ - data = _nx_dhcp_search_buffer(option_message, option, option_length); + /* Check to see if the option was found. */ + if (data != NX_NULL) + { - /* Check to see if the option was found. */ - if (data != NX_NULL) + /* Check for the proper size. */ + if (*data > 4) { - /* Check for the proper size. */ - if (*data > 4) + /* Check for the gateway option. */ + if (option == NX_DHCP_OPTION_GATEWAYS) { - /* Check for the gateway option. */ - if (option == NX_DHCP_OPTION_GATEWAYS) - { - - /* Pickup the first gateway address. */ - *value = _nx_dhcp_get_data(data + 1, 4); + /* Pickup the first gateway address. */ + *value = _nx_dhcp_get_data(data + 1, 4); - /* For now, just disregard any additional gateway addresses. */ - return(NX_SUCCESS); - } - else - { - - /* Invalid size, return error. */ - return(NX_SIZE_ERROR); - } + /* For now, just disregard any additional gateway addresses. */ + return(NX_SUCCESS); } else { - /* Get the actual value. */ - *value = _nx_dhcp_get_data(data + 1, *data); - return(NX_SUCCESS); + /* Invalid size, return error. */ + return(NX_SIZE_ERROR); } } + else + { + + /* Get the actual value. */ + *value = _nx_dhcp_get_data(data + 1, *data); + return(NX_SUCCESS); + } } /* Return an error if not found. */ @@ -7992,7 +7925,7 @@ static UINT _nx_dhcp_add_option_parameter_request(NX_DHCP *dhcp_ptr, UCHAR *boo /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_add_randomize PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -8026,6 +7959,9 @@ static UINT _nx_dhcp_add_option_parameter_request(NX_DHCP *dhcp_ptr, UCHAR *boo /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static ULONG _nx_dhcp_add_randomize(ULONG timeout) @@ -8048,7 +7984,7 @@ ULONG adjustment; if (timeout > (NX_IP_PERIODIC_RATE - adjustment)) timeout -= (ULONG)(NX_IP_PERIODIC_RATE - adjustment); else - timeout = 0; + timeout = 1; /* Set 1 here since the minmum tick for timeout shall be larger than 0 */ } else { @@ -8206,7 +8142,7 @@ static ULONG _nx_dhcp_update_renewal_timeout(ULONG timeout) /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_search_buffer PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -8246,6 +8182,9 @@ static ULONG _nx_dhcp_update_renewal_timeout(ULONG timeout) /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static UCHAR *_nx_dhcp_search_buffer(UCHAR *option_message, UINT option, UINT length) @@ -8262,9 +8201,14 @@ UINT size; /* Search as long as there are valid options. */ while (i < length - 1) { + /* Jump out when it reaches END option */ + if (*data == NX_DHCP_OPTION_END) + { + break; + } /* Simply skip any padding */ - if (*data == NX_DHCP_OPTION_PAD) + else if (*data == NX_DHCP_OPTION_PAD) { data++; @@ -8372,7 +8316,7 @@ ULONG value = 0; /* FUNCTION RELEASE */ /* */ /* _nx_dhcp_store_data PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -8410,41 +8354,18 @@ ULONG value = 0; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static VOID _nx_dhcp_store_data(UCHAR *data, UINT size, ULONG value) { - - /* Make sure that data is left justified. */ - switch (size) - { - - case 1: - - value <<= 24; - break; - - case 2: - - value <<= 16; - break; - - case 3: - - value <<= 8; - break; - - default: - break; - } - /* Store the value. */ while (size-- > 0) { - - *data = (UCHAR) ((value >> 24) & 0xff); - data++; - value <<= 8; + *(data + size) = (UCHAR)(value & 0xff); + value >>= 8; } } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c index 26da0207..e88bf550 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.c @@ -8315,7 +8315,7 @@ UCHAR original_state; /* FUNCTION RELEASE */ /* */ /* _nx_dhcpv6_send_request PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -8374,6 +8374,9 @@ UCHAR original_state; /* verified memcpy use cases, */ /* fixed compiler warnings, */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), supported*/ +/* adding user options, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dhcpv6_send_request(NX_DHCPV6 *dhcpv6_ptr) @@ -8387,6 +8390,8 @@ UINT index; NX_INTERFACE *interface_ptr; NXD_IPV6_ADDRESS *ipv6_address; ULONG available_payload; +UCHAR *user_option_ptr; +UINT user_option_length; /* Initialize local variables. */ @@ -9020,12 +9025,37 @@ ULONG available_payload; } } + /* Add any user supplied options to the buffer. */ + if (dhcpv6_ptr -> nx_dhcpv6_user_option_add) + { + + /* Set the pointer for adding user option. */ + user_option_ptr = buffer + index; + + /* Calculate the available length for user options. */ + user_option_length = (UINT)(packet_ptr -> nx_packet_data_end - user_option_ptr); + + /* Add the specific DHCP option user wanted. */ + if (dhcpv6_ptr -> nx_dhcpv6_user_option_add(dhcpv6_ptr, dhcpv6_ptr -> nx_dhcpv6_client_interface_index, dhcpv6_ptr -> nx_dhcpv6_message_hdr.nx_message_type, user_option_ptr, &user_option_length) == NX_TRUE) + { + + /* Update the index to include the user options. */ + index += user_option_length; + } + else + { + + /* Invalid user options. Release the packet. */ + nx_packet_release(packet_ptr); + return(NX_DHCPV6_UNKNOWN_OPTION); + } + } + /* Setup the packet pointers. */ packet_ptr -> nx_packet_length = index; packet_ptr -> nx_packet_append_ptr = packet_ptr -> nx_packet_prepend_ptr + index; - /* Select Client Source address: 1. When a client sends a DHCP message to the All_DHCP_Relay_Agents_and_Servers address, the client must use a link-local address assigned to the interface for which it @@ -12082,6 +12112,124 @@ UINT _nx_dhcpv6_update_retransmit_info(NX_DHCPV6 *dhcpv6_ptr) } +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nxe_dhcpv6_user_option_add_callback_set PORTABLE C */ +/* 6.1.12 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function performs error checking on the user option add */ +/* callback set service. */ +/* */ +/* INPUT */ +/* */ +/* dhcpv6_ptr Pointer to DHCPv6 instance */ +/* dhcpv6_user_option_add Pointer to application's */ +/* option add function */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* _nx_dhcpv6_user_option_add_callback_set Actual user option callback */ +/* set service */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 07-29-2022 Yuxin Zhou Initial Version 6.1.12 */ +/* */ +/**************************************************************************/ +UINT _nxe_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, + UCHAR *user_option_ptr, UINT *user_option_length)) +{ + +UINT status; + + /* Check for invalid input. */ + if ((dhcpv6_ptr == NX_NULL) || (dhcpv6_user_option_add == NX_NULL)) + { + return(NX_PTR_ERROR); + } + + /* Call actual DHCPv6 user option callback set service. */ + status = _nx_dhcpv6_user_option_add_callback_set(dhcpv6_ptr, dhcpv6_user_option_add); + + /* Return status. */ + return(status); +} + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nx_dhcpv6_user_option_add_callback_set PORTABLE C */ +/* 6.1.12 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function sets the user option add callback. */ +/* */ +/* INPUT */ +/* */ +/* dhcpv6_ptr Pointer to DHCPv6 instance */ +/* dhcpv6_user_option_add Pointer to application's */ +/* option add function */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 07-29-2022 Yuxin Zhou Initial Version 6.1.12 */ +/* */ +/**************************************************************************/ +UINT _nx_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, + UCHAR *user_option_ptr, UINT *user_option_length)) +{ + + /* Obtain DHCPv6 Client protection mutex. */ + tx_mutex_get(&(dhcpv6_ptr -> nx_dhcpv6_client_mutex), TX_WAIT_FOREVER); + + /* Set the callback. */ + dhcpv6_ptr -> nx_dhcpv6_user_option_add = dhcpv6_user_option_add; + + /* Release the mutex. */ + tx_mutex_put(&(dhcpv6_ptr -> nx_dhcpv6_client_mutex)); + + /* Return a successful status. */ + return(NX_SUCCESS); +} + + #if !defined (NX_DISABLE_IPV6_DAD) && defined (NX_ENABLE_IPV6_ADDRESS_CHANGE_NOTIFY) /**************************************************************************/ /* */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h index c9626666..56c1dda6 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dhcp/nxd_dhcpv6_client.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nxd_dhcpv6_client.h PORTABLE C */ -/* 6.1.9 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -49,6 +49,9 @@ /* 10-15-2021 Yuxin Zhou Modified comment(s), included */ /* necessary header file, */ /* resulting in version 6.1.9 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), supported*/ +/* adding user options, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ @@ -757,6 +760,9 @@ typedef struct NX_DHCPV6_STRUCT option the status is referring to e.g. IA Address. */ VOID (*nx_dhcpv6_server_error_handler)(struct NX_DHCPV6_STRUCT *dhcpv6_ptr, UINT op_code, UINT status_code, UINT message_type); + /* Define the callback function for adding specific DHCPv6 user option. */ + UINT (*nx_dhcpv6_user_option_add)(struct NX_DHCPV6_STRUCT *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length); + } NX_DHCPV6; @@ -833,6 +839,7 @@ typedef struct NX_DHCPV6_CLIENT_RECORD_STRUCT #define nx_dhcpv6_stop _nx_dhcpv6_stop #define nx_dhcpv6_suspend _nx_dhcpv6_suspend #define nx_dhcpv6_resume _nx_dhcpv6_resume +#define nx_dhcpv6_user_option_add_callback_set _nx_dhcpv6_user_option_add_callback_set #ifdef NX_DHCPV6_CLIENT_RESTORE_STATE #define nx_dhcpv6_client_get_record _nx_dhcpv6_client_get_record #define nx_dhcpv6_client_restore_record _nx_dhcpv6_client_restore_record @@ -876,6 +883,7 @@ typedef struct NX_DHCPV6_CLIENT_RECORD_STRUCT #define nx_dhcpv6_stop _nxe_dhcpv6_stop #define nx_dhcpv6_suspend _nxe_dhcpv6_suspend #define nx_dhcpv6_resume _nxe_dhcpv6_resume +#define nx_dhcpv6_user_option_add_callback_set _nxe_dhcpv6_user_option_add_callback_set #ifdef NX_DHCPV6_CLIENT_RESTORE_STATE #define nx_dhcpv6_client_get_record _nxe_dhcpv6_client_get_record #define nx_dhcpv6_client_restore_record _nxe_dhcpv6_client_restore_record @@ -920,6 +928,7 @@ UINT nx_dhcpv6_start(NX_DHCPV6 *dhcpv6_ptr); UINT nx_dhcpv6_stop(NX_DHCPV6 *dhcpv6_ptr); UINT nx_dhcpv6_suspend(NX_DHCPV6 *dhcpv6_ptr); UINT nx_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr); +UINT nx_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length)); #ifdef NX_DHCPV6_CLIENT_RESTORE_STATE UINT nx_dhcpv6_client_get_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr); UINT nx_dhcpv6_client_restore_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr, ULONG time_elapsed); @@ -999,7 +1008,9 @@ UINT _nx_dhcpv6_stop(NX_DHCPV6 *dhcpv6_ptr); UINT _nxe_dhcpv6_suspend(NX_DHCPV6 *dhcpv6_ptr); UINT _nx_dhcpv6_suspend(NX_DHCPV6 *dhcpv6_ptr); UINT _nxe_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr); -UINT _nx_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr); +UINT _nx_dhcpv6_resume(NX_DHCPV6 *dhcpv6_ptr); +UINT _nxe_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length)); +UINT _nx_dhcpv6_user_option_add_callback_set(NX_DHCPV6 *dhcpv6_ptr, UINT (*dhcpv6_user_option_add)(NX_DHCPV6 *dhcpv6_ptr, UINT interface_index, UINT message_type, UCHAR *user_option_ptr, UINT *user_option_length)); #ifdef NX_DHCPV6_CLIENT_RESTORE_STATE UINT _nxe_dhcpv6_client_get_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr); UINT _nx_dhcpv6_client_get_record(NX_DHCPV6 *dhcpv6_ptr, NX_DHCPV6_CLIENT_RECORD *client_record_ptr); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c index f96a9228..dc4cded7 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/dns/nxd_dns.c @@ -192,7 +192,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dns_create PORTABLE C */ -/* 6.1.4 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -233,6 +233,9 @@ UINT status; /* 02-02-2021 Yuxin Zhou Modified comment(s), and */ /* randomized the source port, */ /* resulting in version 6.1.4 */ +/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dns_create(NX_DNS *dns_ptr, NX_IP *ip_ptr, UCHAR *domain_name) @@ -261,22 +264,8 @@ UINT status; #endif /* Create the DNS UDP socket. */ - status = nx_udp_socket_create(ip_ptr, &(dns_ptr -> nx_dns_socket), "DNS Socket", - NX_DNS_TYPE_OF_SERVICE, NX_DNS_FRAGMENT_OPTION, NX_DNS_TIME_TO_LIVE, NX_DNS_QUEUE_DEPTH); - - /* Check status of socket create. */ - if (status != NX_SUCCESS) - { - -#ifndef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL - - /* Delete the packet pool. */ - nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr); -#endif - - /* Return the NetX error. */ - return(status); - } + nx_udp_socket_create(ip_ptr, &(dns_ptr -> nx_dns_socket), "DNS Socket", + NX_DNS_TYPE_OF_SERVICE, NX_DNS_FRAGMENT_OPTION, NX_DNS_TIME_TO_LIVE, NX_DNS_QUEUE_DEPTH); /* Create a DNS mutex for multi-thread access protection. */ status = tx_mutex_create(&dns_ptr -> nx_dns_mutex, "DNS Mutex", TX_NO_INHERIT); @@ -539,7 +528,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_dns_delete PORTABLE C */ -/* 6.1.4 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -576,6 +565,10 @@ UINT status; /* 02-02-2021 Yuxin Zhou Modified comment(s), and */ /* randomized the source port, */ /* resulting in version 6.1.4 */ +/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s), */ +/* removed error checking for */ +/* nx_packet_pool_delete, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dns_delete(NX_DNS *dns_ptr) @@ -596,13 +589,8 @@ UINT status; #ifndef NX_DNS_CLIENT_USER_CREATE_PACKET_POOL /* Delete the DNS packet pool. */ - status = nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr); + nx_packet_pool_delete(dns_ptr -> nx_dns_packet_pool_ptr); - if (status != NX_SUCCESS) - { - /* Return the packet pool delete error. */ - return status; - } #endif /* Delete the DNS mutex. */ @@ -770,7 +758,7 @@ NXD_ADDRESS dns_server_address; /* FUNCTION RELEASE */ /* */ /* _nxde_dns_server_add PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -804,6 +792,9 @@ NXD_ADDRESS dns_server_address; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */ +/* simplified some branches, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nxde_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *server_address) @@ -826,14 +817,6 @@ UINT status; return NX_DNS_PARAM_ERROR; } - /* Check for an invalid address type. */ - if ((server_address -> nxd_ip_version != NX_IP_VERSION_V4) && - (server_address -> nxd_ip_version != NX_IP_VERSION_V6)) - { - - return NX_DNS_INVALID_ADDRESS_TYPE; - } - /* Check if the server address is unspecified (::). */ if (server_address -> nxd_ip_version == NX_IP_VERSION_V6) { @@ -869,6 +852,10 @@ UINT status; return NX_DNS_INVALID_ADDRESS_TYPE; #endif /* NX_DISABLE_IPV4 */ } + else + { + return NX_DNS_INVALID_ADDRESS_TYPE; + } /* Check for appropriate caller. */ NX_THREADS_ONLY_CALLER_CHECKING @@ -937,7 +924,7 @@ UINT _nxd_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *dns_server_address) /* FUNCTION RELEASE */ /* */ /* _nx_dns_server_add_internal PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -972,6 +959,9 @@ UINT _nxd_dns_server_add(NX_DNS *dns_ptr, NXD_ADDRESS *dns_server_address) /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */ +/* simplified branches, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_dns_server_add_internal(NX_DNS *dns_ptr, NXD_ADDRESS *server_address) @@ -1004,15 +994,17 @@ UINT i; #ifndef NX_DISABLE_IPV4 /* Is there a match? */ - if ((server_address -> nxd_ip_version == NX_IP_VERSION_V4) && - (dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4)) + if (server_address -> nxd_ip_version == NX_IP_VERSION_V4) { + if (dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4) + { - /* Error, release the mutex and return. */ - tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); + /* Error, release the mutex and return. */ + tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); - /* Yes, no need to add to the table, just return the 'error' status. */ - return NX_DNS_DUPLICATE_ENTRY; + /* Yes, no need to add to the table, just return the 'error' status. */ + return NX_DNS_DUPLICATE_ENTRY; + } } #else /* Error, release the mutex and return. */ @@ -1028,16 +1020,18 @@ UINT i; #ifdef FEATURE_NX_IPV6 /* Is there a match? */ - if ((server_address -> nxd_ip_version == NX_IP_VERSION_V6) && - CHECK_IPV6_ADDRESSES_SAME(&dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v6[0], - &(server_address -> nxd_ip_address.v6[0]))) + if (server_address -> nxd_ip_version == NX_IP_VERSION_V6) { + if (CHECK_IPV6_ADDRESSES_SAME(&dns_ptr -> nx_dns_server_ip_array[i].nxd_ip_address.v6[0], + &(server_address -> nxd_ip_address.v6[0]))) + { - /* Error, release the mutex and return. */ - tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); + /* Error, release the mutex and return. */ + tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); - /* Yes, no need to add to the table, just return the 'error' status. */ - return NX_DNS_DUPLICATE_ENTRY; + /* Yes, no need to add to the table, just return the 'error' status. */ + return NX_DNS_DUPLICATE_ENTRY; + } } #else /* Error, release the mutex and return. */ @@ -1244,7 +1238,7 @@ NXD_ADDRESS dns_server_address; /* FUNCTION RELEASE */ /* */ /* _nxde_dns_server_remove PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1279,6 +1273,10 @@ NXD_ADDRESS dns_server_address; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */ +/* simplified check for */ +/* invalid address types, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nxde_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address) @@ -1292,14 +1290,6 @@ UINT status; return(NX_PTR_ERROR); } - /* Check for an invalid address type. */ - if ((server_address -> nxd_ip_version != NX_IP_VERSION_V4) && - (server_address -> nxd_ip_version != NX_IP_VERSION_V6)) - { - - return NX_DNS_INVALID_ADDRESS_TYPE; - } - /* Check if the server address is unspecified (::). */ if (server_address -> nxd_ip_version == NX_IP_VERSION_V6) { @@ -1335,6 +1325,10 @@ UINT status; return NX_DNS_INVALID_ADDRESS_TYPE; #endif /* NX_DISABLE_IPV4 */ } + else + { + return NX_DNS_INVALID_ADDRESS_TYPE; + } /* Check for appropriate caller. */ NX_THREADS_ONLY_CALLER_CHECKING @@ -1406,7 +1400,7 @@ UINT _nxd_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address) /* FUNCTION RELEASE */ /* */ /* _nx_dns_server_remove_internal PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1444,6 +1438,9 @@ UINT _nxd_dns_server_remove(NX_DNS *dns_ptr, NXD_ADDRESS *server_address) /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Jidesh Veeramachaneni Modified comment(s) and */ +/* removed null IP checks, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static UINT _nx_dns_server_remove_internal(NX_DNS *dns_ptr, NXD_ADDRESS *server_address) @@ -1488,50 +1485,24 @@ UINT found_match; } #else { - /* Check for a null address. */ - if (!CHECK_UNSPECIFIED_ADDRESS(&DNSserver_array[i].nxd_ip_address.v6[0])) + /* Determine if this entry matches the specified DNS server. */ + if (CHECK_IPV6_ADDRESSES_SAME(&DNSserver_array[i].nxd_ip_address.v6[0], &(server_address -> nxd_ip_address.v6[0]))) { - /* No null; Determine if this entry matches the specified DNS server. */ - if (CHECK_IPV6_ADDRESSES_SAME(&DNSserver_array[i].nxd_ip_address.v6[0], &(server_address -> nxd_ip_address.v6[0]))) - { - - found_match = NX_TRUE; - break; - } - } - /* Check for a null address. */ - else - { - - /* Error, release the mutex and return. */ - tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); - return NX_DNS_BAD_ADDRESS_ERROR; + found_match = NX_TRUE; + break; } } #endif else if (DNSserver_array[i].nxd_ip_version == NX_IP_VERSION_V4) #ifndef NX_DISABLE_IPV4 { - - /* Check for a null address. */ - if (DNSserver_array[i].nxd_ip_address.v4 != IP_ADDRESS(0, 0, 0, 0)) + /* Determine if this entry matches the specified DNS server. */ + if (DNSserver_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4) { - - /* Determine if this entry matches the specified DNS server. */ - if (DNSserver_array[i].nxd_ip_address.v4 == server_address -> nxd_ip_address.v4) - { - found_match = NX_TRUE; - break; - } - } - else - { - - /* Error, release the mutex and return. */ - tx_mutex_put(&(dns_ptr -> nx_dns_mutex)); - return NX_DNS_INVALID_ADDRESS_TYPE; + found_match = NX_TRUE; + break; } } #else diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c index d8b4bbad..c015ebec 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.c @@ -41,10 +41,9 @@ #endif #ifdef NX_HTTP_DIGEST_ENABLE -/* Define the default nonce, used only for MD5 authentication. For security reasons, this ASCII value should - change over time. */ -CHAR _nx_http_server_nonce[] = "a4b8c8d7e0f6a7b2c3d2e4f5a4b7c5d2e7f"; +/* Use for mapping random nonces to printable characters. */ +static CHAR _nx_http_server_base64_array[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #endif /* Define date strings. */ @@ -1539,7 +1538,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_http_server_delete PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1561,9 +1560,8 @@ UINT status; /* CALLS */ /* */ /* nx_tcp_socket_delete Delete the HTTP server socket */ -/* nx_tcp_socket_disconnect Disconnect HTTP server socket */ -/* nx_tcp_socket_unaccept Unaccept HTTP server connect */ -/* nx_tcp_socket_unlisten Unlisten on the HTTP port */ +/* _nx_http_server_disconnect Disconnect HTTP server socket */ +/* nx_tcp_server_socket_unlisten Unlisten on the HTTP port */ /* tx_thread_delete Delete the HTTP server thread */ /* tx_thread_suspend Suspend the HTTP server thread*/ /* tx_thread_terminate Terminate the HTTP server */ @@ -1580,6 +1578,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_http_server_delete(NX_HTTP_SERVER *http_server_ptr) @@ -1590,10 +1591,7 @@ UINT _nx_http_server_delete(NX_HTTP_SERVER *http_server_ptr) http_server_ptr -> nx_http_server_id = 0; /* Disconnect the TCP socket. */ - nx_tcp_socket_disconnect(&(http_server_ptr -> nx_http_server_socket), NX_HTTP_SERVER_TIMEOUT_DISCONNECT); - - /* Unaccept any remaining connection on the TCP socket. */ - nx_tcp_server_socket_unaccept(&(http_server_ptr -> nx_http_server_socket)); + _nx_http_server_disconnect(http_server_ptr, NX_HTTP_SERVER_TIMEOUT_DISCONNECT); /* Delete the TCP socket. */ nx_tcp_socket_delete(&(http_server_ptr -> nx_http_server_socket)); @@ -2247,7 +2245,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_http_server_stop PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2268,6 +2266,8 @@ UINT status; /* */ /* CALLS */ /* */ +/* _nx_http_server_disconnect Disconnect HTTP server socket */ +/* nx_tcp_server_socket_unlisten Unlisten on the HTTP port */ /* tx_thread_suspend Suspend the HTTP server thread*/ /* */ /* CALLED BY */ @@ -2281,20 +2281,91 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_http_server_stop(NX_HTTP_SERVER *http_server_ptr) { /* Disconnect the TCP socket. */ - nx_tcp_socket_disconnect(&(http_server_ptr -> nx_http_server_socket), NX_NO_WAIT); - - /* Unaccept any remaining connection on the TCP socket. */ - nx_tcp_server_socket_unaccept(&(http_server_ptr -> nx_http_server_socket)); + _nx_http_server_disconnect(http_server_ptr, NX_NO_WAIT); /* Unlisten on the HTTP server port. */ nx_tcp_server_socket_unlisten(http_server_ptr -> nx_http_server_ip_ptr, NX_HTTP_SERVER_PORT); + /* Suspend the HTTP server thread. */ + tx_thread_suspend(&(http_server_ptr -> nx_http_server_thread)); + + /* Return successful completion. */ + return(NX_SUCCESS); +} + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nx_http_server_disconnect PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function disconnects the HTTP server socket. */ +/* */ +/* */ +/* INPUT */ +/* */ +/* http_server_ptr Pointer to HTTP server */ +/* wait_option Wait option */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* nx_tcp_socket_disconnect Disconnect HTTP server socket */ +/* nx_tcp_socket_unaccept Unaccept HTTP server connect */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +UINT _nx_http_server_disconnect(NX_HTTP_SERVER *http_server_ptr, UINT wait_option) +{ + +#ifdef NX_HTTP_DIGEST_ENABLE +UINT i; + + /* Once the nonce has been accepted, set the state as invalid. */ + for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++) + { + if (http_server_ptr -> nx_http_server_nonces[i].nonce_state == NX_HTTP_SERVER_NONCE_ACCEPTED) + { + http_server_ptr -> nx_http_server_nonces[i].nonce_state = NX_HTTP_SERVER_NONCE_INVALID; + break; + } + } +#endif /* NX_HTTP_DIGEST_ENABLE */ + + /* Disconnect the TCP socket. */ + nx_tcp_socket_disconnect(&(http_server_ptr -> nx_http_server_socket), wait_option); + + /* Unaccept any remaining connection on the TCP socket. */ + nx_tcp_server_socket_unaccept(&(http_server_ptr -> nx_http_server_socket)); + /* Return successful completion. */ return(NX_SUCCESS); } @@ -2829,7 +2900,7 @@ NX_HTTP_SERVER *server_ptr; /* FUNCTION RELEASE */ /* */ /* _nx_http_server_thread_entry PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2857,10 +2928,9 @@ NX_HTTP_SERVER *server_ptr; /* _nx_http_server_response_send Send HTTP Server response */ /* nx_packet_release Release request packet */ /* nx_tcp_server_socket_accept Accept HTTP client connect */ -/* nx_tcp_socket_disconnect Disconnect from HTTP client */ +/* _nx_http_server_disconnect Disconnect HTTP server socket */ /* nx_tcp_server_socket_relisten Relisten for another HTTP */ /* client connection */ -/* nx_tcp_server_socket_unaccept Unaccept HTTP client connect */ /* tx_thread_preemption_change Disable/restore preemption */ /* tx_thread_suspend Self suspend HTTP thread */ /* */ @@ -2875,6 +2945,9 @@ NX_HTTP_SERVER *server_ptr; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_http_server_thread_entry(ULONG http_server) @@ -2960,10 +3033,7 @@ UINT loop_endlessly = NX_TRUE; } /* Disconnect from the current connection. */ - nx_tcp_socket_disconnect(&(server_ptr -> nx_http_server_socket), NX_HTTP_SERVER_TIMEOUT_DISCONNECT); - - /* Unaccept the connection. */ - nx_tcp_server_socket_unaccept(&(server_ptr -> nx_http_server_socket)); + _nx_http_server_disconnect(server_ptr, NX_HTTP_SERVER_TIMEOUT_DISCONNECT); /* Relisten on the HTTP Server port. */ nx_tcp_server_socket_relisten(server_ptr -> nx_http_server_ip_ptr, NX_HTTP_SERVER_PORT, @@ -3087,10 +3157,7 @@ UINT loop_endlessly = NX_TRUE; nx_packet_release(packet_ptr); /* Disconnect from the current connection. */ - nx_tcp_socket_disconnect(&(server_ptr -> nx_http_server_socket), NX_HTTP_SERVER_TIMEOUT_DISCONNECT); - - /* Unaccept the connection. */ - nx_tcp_server_socket_unaccept(&(server_ptr -> nx_http_server_socket)); + _nx_http_server_disconnect(server_ptr, NX_HTTP_SERVER_TIMEOUT_DISCONNECT); /* Relisten on the HTTP Server port. */ nx_tcp_server_socket_relisten(server_ptr -> nx_http_server_ip_ptr, NX_HTTP_SERVER_PORT, @@ -4701,7 +4768,7 @@ NX_PACKET *packet_ptr; /* FUNCTION RELEASE */ /* */ /* _nx_http_server_basic_authenticate PORTABLE C */ -/* 6.1.6 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4754,6 +4821,10 @@ NX_PACKET *packet_ptr; /* improved the logic of */ /* parsing base64, */ /* resulting in version 6.1.6 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), fixed */ +/* the issue of processing */ +/* empty password, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_http_server_basic_authenticate(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT realm_length, UINT *auth_request_present) @@ -4835,7 +4906,9 @@ UINT authorization_decoded_size; } /* Determine if we have a match. */ - if (match && (i == authorization_decoded_size) && (authorization_decoded[i] == (CHAR) NX_NULL)) + if (match && (i == authorization_decoded_size) && + (authorization_decoded[i] == (CHAR) NX_NULL) && + (password_ptr[j] == (CHAR) NX_NULL)) { /* Yes, we have successful authorization!! */ @@ -5707,12 +5780,106 @@ UINT temp_name_length; } #ifdef NX_HTTP_DIGEST_ENABLE +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nx_http_server_nonce_allocate PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function allocate a new nonce for digest authentication. */ +/* */ +/* INPUT */ +/* */ +/* server_ptr HTTP Server pointer */ +/* nonce_ptr Allocated nonce pointer */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* tx_time_get Get system time */ +/* */ +/* CALLED BY */ +/* */ +/* _nx_http_server_digest_authenticate Digest authentication */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +UINT _nx_http_server_nonce_allocate(NX_HTTP_SERVER *server_ptr, NX_HTTP_SERVER_NONCE **nonce_ptr) +{ +UINT i; +UCHAR random_value; +NX_HTTP_SERVER_NONCE *nonces_list = server_ptr -> nx_http_server_nonces; + + + /* Search if there is free entry for new nonce. */ + for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++) + { + if (nonces_list[i].nonce_state == NX_HTTP_SERVER_NONCE_INVALID) + { + *nonce_ptr = &(nonces_list[i]); + break; + } + } + + if (i == NX_HTTP_SERVER_NONCE_MAX) + { + + /* If no free entry, check the timeout of allocated nonces. */ + for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++) + { + if (nonces_list[i].nonce_state == NX_HTTP_SERVER_NONCE_VALID) + { + if (tx_time_get() > nonces_list[i].nonce_timestamp + NX_HTTP_SERVER_NONCE_TIMEOUT) + { + + /* If this nonce is timed out, free up this entry for new nonce. */ + *nonce_ptr = &(nonces_list[i]); + break; + } + } + } + + /* If no entry can be allocated, return error. */ + if (i == NX_HTTP_SERVER_NONCE_MAX) + { + return(NX_NOT_FOUND); + } + } + + /* Generate new nonce for digest authentication. */ + for (i = 0; i < NX_HTTP_SERVER_NONCE_SIZE; i++) + { + random_value = (UCHAR)NX_RAND() % (sizeof(_nx_http_server_base64_array) - 1); + (*nonce_ptr) -> nonce_buffer[i] = (UCHAR)_nx_http_server_base64_array[random_value]; + } + + /* Reset the timestamp and state for the new nonce. */ + (*nonce_ptr) -> nonce_timestamp = tx_time_get(); + (*nonce_ptr) -> nonce_state = NX_HTTP_SERVER_NONCE_VALID; + + return(NX_SUCCESS); +} + /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_http_server_digest_authenticate PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5763,6 +5930,9 @@ UINT temp_name_length; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_http_server_digest_authenticate(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, UINT name_length, CHAR *password_ptr, UINT password_length, CHAR *realm_ptr, UINT realm_length, UINT *auth_request_present) @@ -5779,6 +5949,8 @@ UINT status, status1, callback_status; CHAR crlf[2] = {13,10}; CHAR authorization_nc[NX_HTTP_MAX_RESOURCE + 1]; CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; +NX_HTTP_SERVER_NONCE *nonce_ptr = NX_NULL; + /* Default to no authentication request detected. */ *auth_request_present = NX_FALSE; @@ -5787,7 +5959,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; status = NX_HTTP_DIGEST_AUTHENTICATE; /* Is the authorization request present? */ - if (_nx_http_server_retrieve_digest_authorization(packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce)) + if (_nx_http_server_retrieve_digest_authorization(server_ptr, packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce, &nonce_ptr)) { /* Yes, an authorization request is present. */ @@ -5822,7 +5994,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; /* Calculate what the MD5 should be. */ - _nx_http_server_digest_response_calculate(server_ptr, name_ptr, name_length, realm_ptr, realm_length, password_ptr, password_length, _nx_http_server_nonce, method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response); + _nx_http_server_digest_response_calculate(server_ptr, name_ptr, name_length, realm_ptr, realm_length, password_ptr, password_length, (CHAR *)(nonce_ptr -> nonce_buffer), method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response); /* Determine if the calculated response is the same as the received response. */ i = 0; @@ -5840,6 +6012,17 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; /* Otherwise, look at next character. */ i++; } + + /* If the response is authenticated, mark the nonce as accepted. */ + if (status == NX_SUCCESS) + { + nonce_ptr -> nonce_state = NX_HTTP_SERVER_NONCE_ACCEPTED; + } + else + { + nonce_ptr -> nonce_state = NX_HTTP_SERVER_NONCE_INVALID; + } + /* If digest authenticate callback function returns non-success value, the request is considered unauthenticated. */ if(callback_status != NX_SUCCESS) @@ -5850,6 +6033,24 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; if (status == NX_HTTP_DIGEST_AUTHENTICATE) { + /* Allocate a new nonce for digest authentication. */ + status1 = _nx_http_server_nonce_allocate(server_ptr, &nonce_ptr); + + /* Determine if an error occurred in the packet allocation. */ + if (status1) + { + + /* Send response back to HTTP Client. */ + _nx_http_server_response_send(server_ptr, NX_HTTP_STATUS_INTERNAL_ERROR, sizeof(NX_HTTP_STATUS_INTERNAL_ERROR) - 1, + "NetX HTTP Server Internal Error", sizeof("NetX HTTP Server Internal Error") - 1, NX_NULL, 0); + + /* Indicate an allocation error occurred. */ + server_ptr -> nx_http_server_allocation_errors++; + + /* Return the internal NetX error. */ + return(status1); + } + /* We need authorization so build the HTTP 401 Unauthorized message to send to the server. */ /* Allocate a packet for sending the response back. */ @@ -5926,7 +6127,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER); /* Place the nonce string into the buffer. */ - nx_packet_data_append(packet_ptr, _nx_http_server_nonce, sizeof(_nx_http_server_nonce) - 1, + nx_packet_data_append(packet_ptr, nonce_ptr -> nonce_buffer, NX_HTTP_SERVER_NONCE_SIZE, server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER); /* Insert the double quote. */ @@ -5941,6 +6142,14 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; nx_packet_data_append(packet_ptr, crlf, 2, server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER); + /* Set Content-Length as 0. */ + nx_packet_data_append(packet_ptr, "Content-Length: 0", 17, + server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER); + + /* Place the into the buffer. */ + nx_packet_data_append(packet_ptr, crlf, 2, + server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER); + /* Place another into the buffer to signal end of FULL HTTP response. */ nx_packet_data_append(packet_ptr, crlf, 2, server_ptr -> nx_http_server_packet_pool_ptr, NX_WAIT_FOREVER); @@ -5970,7 +6179,7 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; /* FUNCTION RELEASE */ /* */ /* _nx_http_server_digest_response_calculate PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6016,6 +6225,9 @@ CHAR authorization_cnonce[NX_HTTP_MAX_RESOURCE + 1]; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_http_server_digest_response_calculate(NX_HTTP_SERVER *server_ptr, CHAR *username, UINT username_length, CHAR *realm, UINT realm_length, CHAR *password, UINT password_length, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result) @@ -6026,14 +6238,12 @@ CHAR ha1_string[NX_HTTP_MAX_ASCII_MD5 + 1]; CHAR ha2_string[NX_HTTP_MAX_ASCII_MD5 + 1]; UINT method_length; UINT uri_length; -UINT nonce_length; UINT nc_length; UINT cnonce_length; /* Check string length. */ if (_nx_utility_string_length_check(method, &method_length, 7) || _nx_utility_string_length_check(uri, &uri_length, NX_HTTP_MAX_RESOURCE) || - _nx_utility_string_length_check(nonce, &nonce_length, sizeof(_nx_http_server_nonce) - 1) || _nx_utility_string_length_check(nc, &nc_length, NX_HTTP_MAX_RESOURCE) || _nx_utility_string_length_check(cnonce, &cnonce_length, NX_HTTP_MAX_RESOURCE)) { @@ -6067,7 +6277,7 @@ UINT cnonce_length; _nx_md5_initialize(&(server_ptr -> nx_http_server_md5data)); _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) ha1_string, sizeof(ha1_string) - 1); _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) ":", 1); - _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) nonce, nonce_length); + _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) nonce, NX_HTTP_SERVER_NONCE_SIZE); /* Start of Internet Explorer bug work-around. */ _nx_md5_update(&(server_ptr -> nx_http_server_md5data), (unsigned char *) ":", 1); @@ -6092,7 +6302,7 @@ UINT cnonce_length; /* FUNCTION RELEASE */ /* */ /* _nx_http_server_retrieve_digest_authorization PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6104,11 +6314,13 @@ UINT cnonce_length; /* */ /* INPUT */ /* */ +/* server_ptr HTTP Server pointer */ /* packet_ptr Request packet pointer */ /* response Digest response pointer */ /* uri URI from response pointer */ /* nc Nonce count string */ /* cnonce Client nonce string */ +/* nonce_ptr Server nonce pointer */ /* */ /* OUTPUT */ /* */ @@ -6131,15 +6343,20 @@ UINT cnonce_length; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ -UINT _nx_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce) +UINT _nx_http_server_retrieve_digest_authorization(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_HTTP_SERVER_NONCE **nonce_ptr) { UINT length; UINT found; CHAR *buffer_ptr; CHAR *saved_buffer_ptr; +UCHAR *nonce_buffer; +UINT i; /* Set the found flag to false. */ @@ -6259,6 +6476,86 @@ CHAR *saved_buffer_ptr; /* Save current buffer pointer, so each parameter search always starts from here. */ saved_buffer_ptr = buffer_ptr; + while (((buffer_ptr + 6) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0)) + { + + /* Check for the uri token. */ + if (((*(buffer_ptr) == 'n') || (*(buffer_ptr) == 'N')) && + ((*(buffer_ptr+1) == 'o') || (*(buffer_ptr+1) == 'O')) && + ((*(buffer_ptr+2) == 'n') || (*(buffer_ptr+2) == 'N')) && + ((*(buffer_ptr+3) == 'c') || (*(buffer_ptr+3) == 'C')) && + ((*(buffer_ptr+4) == 'e') || (*(buffer_ptr+4) == 'E')) && + (*(buffer_ptr+5) == '=')) + { + + /* Move the pointer up to the actual nonce string. */ + buffer_ptr = buffer_ptr + 6; + found = NX_TRUE; + + break; + } + + /* Move the pointer up to the next character. */ + buffer_ptr++; + } + + /* Check if nonce is found. */ + if (!found) + { + return(0); + } + + /* Now remove any extra blanks and quotes. */ + while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && ((*buffer_ptr == ' ') || (*buffer_ptr == (CHAR) 0x22))) + { + + /* Move the pointer up one character. */ + buffer_ptr++; + } + + /* Now pickup the nonce string. */ + length = 0; + nonce_buffer = (UCHAR *)buffer_ptr; + while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0) && (*buffer_ptr != ' ') && (*buffer_ptr != (CHAR) 13)) + { + + /* Determine if the ending quote is present. */ + if (*buffer_ptr == (CHAR) 0x22) + { + break; + } + + /* Increase the length. */ + length++; + buffer_ptr++; + } + + /* Check the nonce size. */ + if (length != NX_HTTP_SERVER_NONCE_SIZE) + { + return(0); + } + + /* Check if the nonce is valid. */ + for (i = 0; i < NX_HTTP_SERVER_NONCE_MAX; i++) + { + if ((server_ptr -> nx_http_server_nonces[i].nonce_state != NX_HTTP_SERVER_NONCE_INVALID) && + (memcmp(server_ptr -> nx_http_server_nonces[i].nonce_buffer, nonce_buffer, NX_HTTP_SERVER_NONCE_SIZE) == 0)) /* Use case of memcmp is verified. */ + { + *nonce_ptr = &(server_ptr -> nx_http_server_nonces[i]); + break; + } + } + + /* If the nonca is invalid, just return. */ + if (i == NX_HTTP_SERVER_NONCE_MAX) + { + return(0); + } + + /* Get saved buffer pointer. */ + buffer_ptr = saved_buffer_ptr; + /* Now look for the nc in the digest response. */ while (((buffer_ptr+3) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0)) { @@ -6318,9 +6615,9 @@ CHAR *saved_buffer_ptr; if (((*buffer_ptr == 'c') || (*buffer_ptr == 'C')) && ((*(buffer_ptr+1) == 'n') || (*(buffer_ptr+1) == 'N')) && ((*(buffer_ptr+2) == 'o') || (*(buffer_ptr+2) == 'O')) && - ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+2) == 'N')) && - ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+2) == 'C')) && - ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+2) == 'E')) && + ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+3) == 'N')) && + ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+4) == 'C')) && + ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+5) == 'E')) && (*(buffer_ptr+6) == '=')) { @@ -6425,11 +6722,11 @@ CHAR *saved_buffer_ptr; if (((*buffer_ptr == 'r') || (*buffer_ptr == 'R')) && ((*(buffer_ptr+1) == 'e') || (*(buffer_ptr+1) == 'E')) && ((*(buffer_ptr+2) == 's') || (*(buffer_ptr+2) == 'S')) && - ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+2) == 'P')) && - ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+2) == 'O')) && - ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+2) == 'N')) && - ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+2) == 'S')) && - ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+2) == 'E')) && + ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+3) == 'P')) && + ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+4) == 'O')) && + ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+5) == 'N')) && + ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+6) == 'S')) && + ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+7) == 'E')) && (*(buffer_ptr+8) == '=')) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h index ffa237b6..ffe9b0e9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/http/nxd_http_server.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nxd_http_server.h PORTABLE C */ -/* 6.1.8 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -53,6 +53,10 @@ /* improved the logic of */ /* converting number to string,*/ /* resulting in version 6.1.8 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ +/* */ /* */ /**************************************************************************/ @@ -180,6 +184,24 @@ extern "C" { #define NX_HTTP_SERVER_RETRY_SHIFT 1 /* Every retry is twice as long */ #endif +#ifndef NX_HTTP_SERVER_NONCE_SIZE +#define NX_HTTP_SERVER_NONCE_SIZE 32 /* The size of nonce for digest authtentication */ +#endif + +#ifndef NX_HTTP_SERVER_NONCE_MAX +#define NX_HTTP_SERVER_NONCE_MAX 2 /* The size of nonce for digest authtentication */ +#endif + +#ifndef NX_HTTP_SERVER_NONCE_TIMEOUT +#define NX_HTTP_SERVER_NONCE_TIMEOUT (10 * NX_IP_PERIODIC_RATE) +#endif + +/* Define the state of the nonce. */ + +#define NX_HTTP_SERVER_NONCE_INVALID 0 +#define NX_HTTP_SERVER_NONCE_VALID 1 +#define NX_HTTP_SERVER_NONCE_ACCEPTED 2 + /* NX_HTTP_MAX_STRING is base64 of "name:password" and plus 1 if an extra conversion is needed and plus 2 pad if needed. */ #define NX_HTTP_MAX_STRING ((NX_HTTP_MAX_NAME + NX_HTTP_MAX_PASSWORD + 1) * 4 / 3 + 1 + 2) @@ -311,6 +333,17 @@ typedef struct NX_HTTP_SERVER_DATE_STRUCT UCHAR nx_http_server_weekday; /* Weekday */ } NX_HTTP_SERVER_DATE; + +/* Define the nonce structure. */ + +typedef struct NX_HTTP_SERVER_NONCE_STRUCT +{ + UINT nonce_state; /* The state of the nonce */ + UINT nonce_timestamp; /* The time when the nonce is created */ + UCHAR nonce_buffer[NX_HTTP_SERVER_NONCE_SIZE]; /* Nonce for digest authetication */ +} NX_HTTP_SERVER_NONCE; + + /* Define the multipart context data structure. */ typedef struct NX_HTTP_SERVER_MULTIPART_STRUCT @@ -369,6 +402,8 @@ typedef struct NX_HTTP_SERVER_STRUCT TX_THREAD nx_http_server_thread; /* HTTP server thread */ #ifdef NX_HTTP_DIGEST_ENABLE NX_MD5 nx_http_server_md5data; /* HTTP server MD5 work area */ + NX_HTTP_SERVER_NONCE + nx_http_server_nonces[NX_HTTP_SERVER_NONCE_MAX];/* Nonce for digest authetication */ #endif /* NX_HTTP_DIGEST_ENABLE */ #ifdef NX_HTTP_MULTIPART_ENABLE @@ -583,12 +618,14 @@ UINT _nx_http_server_retrieve_resource(NX_PACKET *packet_ptr, CHAR *desti UINT _nx_http_server_calculate_content_offset(NX_PACKET *packet_ptr); UINT _nx_http_server_type_get(NX_HTTP_SERVER *server_ptr, CHAR *name, CHAR *http_type_string); UINT _nx_http_server_type_get_extended(NX_HTTP_SERVER *server_ptr, CHAR *name, UINT name_length, CHAR *http_type_string, UINT http_type_string_max_size); +UINT _nx_http_server_disconnect(NX_HTTP_SERVER *http_server_ptr, UINT wait_option); #ifdef NX_HTTP_DIGEST_ENABLE UINT _nx_http_server_digest_authenticate(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, UINT name_length, CHAR *password_ptr, UINT password_length, CHAR *realm_ptr, UINT realm_length, UINT *auth_request_present); VOID _nx_http_server_digest_response_calculate(NX_HTTP_SERVER *server_ptr, CHAR *username, UINT username_length, CHAR *realm, UINT realm_length, CHAR *password, UINT password_length, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result); -UINT _nx_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce); +UINT _nx_http_server_retrieve_digest_authorization(NX_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_HTTP_SERVER_NONCE **nonce_ptr); VOID _nx_http_server_hex_ascii_convert(CHAR *source, UINT source_length, CHAR *destination); +UINT _nx_http_server_nonce_allocate(NX_HTTP_SERVER *server_ptr, NX_HTTP_SERVER_NONCE **nonce_ptr); #endif #ifdef NX_HTTP_MULTIPART_ENABLE diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c index fd296441..015e6750 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.c @@ -52,7 +52,9 @@ static UINT _nxd_mqtt_client_create_internal(NXD_MQTT_CLIENT *client_ptr, CHAR * CHAR *client_id, UINT client_id_length, NX_IP *ip_ptr, NX_PACKET_POOL *pool_ptr, VOID *stack_ptr, ULONG stack_size, UINT mqtt_thread_priority); -static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr); +static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option); +static UINT _nxd_mqtt_packet_send(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT wait_option); +static UINT _nxd_mqtt_packet_receive(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, UINT wait_option); static UINT _nxd_mqtt_copy_transmit_packet(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, NX_PACKET **new_packet_ptr, USHORT packet_id, UCHAR set_duplicate_flag, UINT wait_option); static VOID _nxd_mqtt_release_transmit_packet(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, NX_PACKET *previous_packet_ptr); @@ -246,7 +248,7 @@ ULONG bytes_copied; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_sub_unsub PORTABLE C */ -/* 6.1.2 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -282,8 +284,7 @@ ULONG bytes_copied; /* _nxd_mqtt_client_set_fixed_header */ /* _nxd_mqtt_client_append_message */ /* tx_mutex_put */ -/* nx_tcp_socket_send */ -/* nx_secure_tls_session_send */ +/* _nxd_mqtt_packet_send */ /* nx_packet_release */ /* _nxd_mqtt_copy_transmit_packet */ /* */ @@ -302,6 +303,12 @@ ULONG bytes_copied; /* 11-09-2020 Yuxin Zhou Modified comment(s), and */ /* added packet id parameter, */ /* resulting in version 6.1.2 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nxd_mqtt_client_sub_unsub(NXD_MQTT_CLIENT *client_ptr, UINT op, @@ -332,7 +339,7 @@ UCHAR temp_data[2]; return(NXD_MQTT_NOT_CONNECTED); } - status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr); + status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, NX_WAIT_FOREVER); if (status) { tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); @@ -461,19 +468,7 @@ UCHAR temp_data[2]; tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); /* Ready to send the connect message to the server. */ -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, NX_WAIT_FOREVER); - } - else - { - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER); - } -#else - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER); -#endif /* NX_SECURE_ENABLE */ - + status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, NX_WAIT_FOREVER); if (status) { @@ -492,7 +487,7 @@ UCHAR temp_data[2]; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_packet_allocate PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -539,45 +534,202 @@ UCHAR temp_data[2]; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ -static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr) +static UINT _nxd_mqtt_packet_allocate(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, ULONG wait_option) { UINT status = NXD_MQTT_SUCCESS; +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + + /* Use WebSocket packet allocate since it is able to count for WebSocket-related header space */ + status = nx_websocket_client_packet_allocate(&(client_ptr -> nxd_mqtt_client_websocket), packet_ptr, wait_option); + } + else +#endif /* NXD_MQTT_OVER_WEBSOCKET */ #ifdef NX_SECURE_ENABLE if (client_ptr -> nxd_mqtt_client_use_tls) { /* Use TLS packet allocate. The TLS packet allocate is able to count for TLS-related header space including crypto initial vector area. */ status = nx_secure_tls_packet_allocate(&client_ptr -> nxd_mqtt_tls_session, client_ptr -> nxd_mqtt_client_packet_pool_ptr, - packet_ptr, TX_WAIT_FOREVER); + packet_ptr, wait_option); } /* Allocate a packet */ else { -#endif +#endif /* NX_SECURE_ENABLE */ if (client_ptr -> nxd_mqtt_client_socket.nx_tcp_socket_connect_ip.nxd_ip_version == NX_IP_VERSION_V4) { status = nx_packet_allocate(client_ptr -> nxd_mqtt_client_packet_pool_ptr, packet_ptr, NX_IPv4_TCP_PACKET, - TX_WAIT_FOREVER); + wait_option); } else { status = nx_packet_allocate(client_ptr -> nxd_mqtt_client_packet_pool_ptr, packet_ptr, NX_IPv6_TCP_PACKET, - TX_WAIT_FOREVER); + wait_option); } #ifdef NX_SECURE_ENABLE } -#endif +#endif /* NX_SECURE_ENABLE */ if (status != NX_SUCCESS) { return(NXD_MQTT_PACKET_POOL_FAILURE); } + return(NXD_MQTT_SUCCESS); } +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nxd_mqtt_packet_send PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function sends out a packet. */ +/* */ +/* */ +/* INPUT */ +/* */ +/* client_ptr Pointer to MQTT Client */ +/* packet_ptr Pointer to packet */ +/* wait_option Timeout value */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* nx_websocket_client_send */ +/* nx_secure_tls_session_send */ +/* nx_tcp_socket_send */ +/* */ +/* CALLED BY */ +/* */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Bo Chen Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +static UINT _nxd_mqtt_packet_send(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT wait_option) +{ +UINT status = NXD_MQTT_SUCCESS; + +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + status = nx_websocket_client_send(&(client_ptr -> nxd_mqtt_client_websocket), packet_ptr, NX_WEBSOCKET_OPCODE_BINARY_FRAME, NX_TRUE, wait_option); + } + else +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + +#ifdef NX_SECURE_ENABLE + if (client_ptr -> nxd_mqtt_client_use_tls) + { + status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option); + } + else +#endif /* NX_SECURE_ENABLE */ + { + status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); + } + + return(status); +} + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nxd_mqtt_packet_receive PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function receives a packet. */ +/* */ +/* */ +/* INPUT */ +/* */ +/* client_ptr Pointer to MQTT Client */ +/* packet_ptr Pointer to packet */ +/* wait_option Timeout value */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* nx_websocket_client_receive */ +/* nx_secure_tls_session_receive */ +/* nx_tcp_socket_receive */ +/* */ +/* CALLED BY */ +/* */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Bo Chen Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +static UINT _nxd_mqtt_packet_receive(NXD_MQTT_CLIENT *client_ptr, NX_PACKET **packet_ptr, UINT wait_option) +{ +UINT status = NXD_MQTT_SUCCESS; +#ifdef NXD_MQTT_OVER_WEBSOCKET +UINT op_code = 0; +#endif /* NXD_MQTT_OVER_WEBSOCKET*/ + +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + status = nx_websocket_client_receive(&(client_ptr -> nxd_mqtt_client_websocket), packet_ptr, &op_code, wait_option); + if ((status == NX_SUCCESS) && (op_code != NX_WEBSOCKET_OPCODE_BINARY_FRAME)) + { + return(NX_INVALID_PACKET); + } + } + else +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + +#ifdef NX_SECURE_ENABLE + if (client_ptr -> nxd_mqtt_client_use_tls) + { + status = nx_secure_tls_session_receive(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option); + } + else +#endif /* NX_SECURE_ENABLE */ + { + status = nx_tcp_socket_receive(&(client_ptr -> nxd_mqtt_client_socket), packet_ptr, wait_option); + } + + return(status); +} + /**************************************************************************/ /* */ /* FUNCTION RELEASE */ @@ -1194,7 +1346,7 @@ ULONG bytes_copied; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_process_publish PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1219,7 +1371,7 @@ ULONG bytes_copied; /* [receive_notify] User supplied receive */ /* callback function */ /* _nxd_mqtt_packet_allocate */ -/* nx_tcp_socket_send */ +/* _nxd_mqtt_packet_send */ /* nx_packet_release */ /* nx_secure_tls_session_send */ /* _nxd_mqtt_process_publish_packet */ @@ -1237,6 +1389,9 @@ ULONG bytes_copied; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static UINT _nxd_mqtt_process_publish(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr) @@ -1372,7 +1527,7 @@ ULONG bytes_copied; /* Send out proper ACKs for QoS 1 and 2 messages. */ /* Allocate a new packet so we can send out a response. */ - status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr); + status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, NX_WAIT_FOREVER); if (status) { /* Packet allocation fails. */ @@ -1422,19 +1577,9 @@ ULONG bytes_copied; } tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, NX_WAIT_FOREVER); - } - else - { - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER); - } -#else - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER); -#endif /* NX_SECURE_ENABLE */ + /* Send packet to server. */ + status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, NX_WAIT_FOREVER); tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, TX_WAIT_FOREVER); if (status) @@ -1458,7 +1603,7 @@ ULONG bytes_copied; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_process_publish_response PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1482,8 +1627,7 @@ ULONG bytes_copied; /* [nxd_mqtt_client_receive_notify] User supplied publish */ /* callback function */ /* _nxd_mqtt_release_transmit_packet */ -/* nx_tcp_socket_send */ -/* nx_secure_tls_session_send */ +/* _nxd_mqtt_packet_send */ /* */ /* */ /* CALLED BY */ @@ -1498,6 +1642,9 @@ ULONG bytes_copied; /* 09-30-2020 Yuxin Zhou Modified comment(s), and */ /* added ack receive notify, */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static UINT _nxd_mqtt_process_publish_response(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr) @@ -1573,7 +1720,7 @@ USHORT transmit_packet_id; /* Send PUBCOMP */ /* Allocate a packet to send the response. */ - ret = _nxd_mqtt_packet_allocate(client_ptr, &response_packet); + ret = _nxd_mqtt_packet_allocate(client_ptr, &response_packet, NX_WAIT_FOREVER); if (ret) { return(1); @@ -1600,19 +1747,8 @@ USHORT transmit_packet_id; tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - ret = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), response_packet, NX_WAIT_FOREVER); - } - else - { - ret = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, response_packet, NX_WAIT_FOREVER); - } -#else - ret = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, response_packet, NX_WAIT_FOREVER); - -#endif /* NX_SECURE_ENABLE */ + /* Send packet to server. */ + ret = _nxd_mqtt_packet_send(client_ptr, response_packet, NX_WAIT_FOREVER); tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, TX_WAIT_FOREVER); @@ -2008,7 +2144,7 @@ UCHAR fixed_header; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_packet_receive_process PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2049,6 +2185,9 @@ UCHAR fixed_header; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static VOID _nxd_mqtt_packet_receive_process(NXD_MQTT_CLIENT *client_ptr) @@ -2070,22 +2209,11 @@ ULONG packet_length; tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); /* Make a receive call. */ -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_receive(&(client_ptr -> nxd_mqtt_tls_session), &packet_ptr, NX_NO_WAIT); - } - else - { - status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, NX_NO_WAIT); - } -#else - status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, NX_NO_WAIT); -#endif /* NX_SECURE_ENABLE */ + status = _nxd_mqtt_packet_receive(client_ptr, &packet_ptr, NX_NO_WAIT); if (status != NX_SUCCESS) { - if (status != NX_NO_PACKET) + if ((status != NX_NO_PACKET) && (status != NX_CONTINUE)) { /* Network issue. Close the MQTT session. */ @@ -2286,7 +2414,7 @@ ULONG packet_length; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_tcp_establish_process PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2320,6 +2448,9 @@ ULONG packet_length; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static VOID _nxd_mqtt_tcp_establish_process(NXD_MQTT_CLIENT *client_ptr) @@ -2357,6 +2488,36 @@ UINT status; } #endif /* NX_SECURE_ENABLE */ +#ifdef NXD_MQTT_OVER_WEBSOCKET + + /* If using websocket, start websocket connection. */ + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + status = nx_websocket_client_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_client_socket), + client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length, + client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length, + (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1, + NX_NO_WAIT); + + if (status != NX_IN_PROGRESS) + { + + /* End connection. */ + _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT); + + /* Check callback function. */ + if (client_ptr -> nxd_mqtt_connect_notify) + { + client_ptr -> nxd_mqtt_connect_notify(client_ptr, status, client_ptr -> nxd_mqtt_connect_context); + } + + return; + } + + return; + } +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /* Start to send MQTT connect packet. */ status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT); @@ -2382,7 +2543,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_tls_establish_process PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2416,6 +2577,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static VOID _nxd_mqtt_tls_establish_process(NXD_MQTT_CLIENT *client_ptr) @@ -2429,29 +2593,40 @@ UINT status; { /* TLS session established. */ - client_ptr -> nxd_mqtt_tls_in_progress= NX_FALSE; + client_ptr -> nxd_mqtt_tls_in_progress = NX_FALSE; - /* Start to send MQTT connect packet. */ - status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT); +#ifdef NXD_MQTT_OVER_WEBSOCKET - /* Check status. */ - if (status) + /* If using websocket, start websocket connection. */ + if (client_ptr -> nxd_mqtt_client_use_websocket) { + status = nx_websocket_client_secure_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_tls_session), + client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length, + client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length, + (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1, + NX_NO_WAIT); - /* End connection. */ - _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT); - - /* Check callback function. */ - if (client_ptr -> nxd_mqtt_connect_notify) + if (status == NX_IN_PROGRESS) { - client_ptr -> nxd_mqtt_connect_notify(client_ptr, status, client_ptr -> nxd_mqtt_connect_context); + return; } } + else +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + { + + /* Start to send MQTT connect packet. */ + status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT); + } } - else if (status != NX_CONTINUE) + else if (status == NX_CONTINUE) { + return; + } - /* Error. */ + /* Check status. */ + if (status) + { /* End connection. */ _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT); @@ -2545,7 +2720,7 @@ UCHAR len[2]; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_connection_end PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2583,6 +2758,9 @@ UCHAR len[2]; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option) @@ -2597,6 +2775,13 @@ VOID _nxd_mqtt_client_connection_end(NXD_MQTT_CLIENT *client_ptr, ULONG wait_opt /* Release the mutex. */ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + nx_websocket_client_disconnect(&(client_ptr -> nxd_mqtt_client_websocket), wait_option); + } +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + #ifdef NX_SECURE_ENABLE if (client_ptr -> nxd_mqtt_client_use_tls) { @@ -3113,7 +3298,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_create_internal PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3160,6 +3345,9 @@ UINT status; /* 09-30-2020 Yuxin Zhou Modified comment(s), and */ /* corrected mqtt client state,*/ /* resulting in version 6.1 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ static UINT _nxd_mqtt_client_create_internal(NXD_MQTT_CLIENT *client_ptr, CHAR *client_name, @@ -3167,7 +3355,9 @@ static UINT _nxd_mqtt_client_create_internal(NXD_MQTT_CLIENT *client_ptr, CHAR * NX_IP *ip_ptr, NX_PACKET_POOL *pool_ptr, VOID *stack_ptr, ULONG stack_size, UINT mqtt_thread_priority) { +#ifndef NXD_MQTT_CLOUD_ENABLE UINT status; +#endif /* NXD_MQTT_CLOUD_ENABLE */ #ifdef NXD_MQTT_CLOUD_ENABLE NX_PARAMETER_NOT_USED(stack_ptr); @@ -3229,26 +3419,10 @@ UINT status; client_ptr -> nxd_mqtt_client_name = client_name; /* Create the socket. */ - status = nx_tcp_socket_create(client_ptr -> nxd_mqtt_client_ip_ptr, &(client_ptr -> nxd_mqtt_client_socket), client_ptr -> nxd_mqtt_client_name, - NX_IP_NORMAL, NX_DONT_FRAGMENT, 0x80, NXD_MQTT_CLIENT_SOCKET_WINDOW_SIZE, - NX_NULL, _mqtt_client_disconnect_callback); - - /* Determine if an error occurred. */ - if (status != NX_SUCCESS) - { -#ifndef NXD_MQTT_CLOUD_ENABLE - /* Delete the mutex. */ - tx_mutex_delete(&client_ptr -> nxd_mqtt_protection); - - /* Delete the event flags. */ - tx_event_flags_delete(&(client_ptr -> nxd_mqtt_events)); - - /* Delete the thread. */ - tx_thread_delete(&(client_ptr -> nxd_mqtt_thread)); -#endif /* NXD_MQTT_CLOUD_ENABLE */ + nx_tcp_socket_create(client_ptr -> nxd_mqtt_client_ip_ptr, &(client_ptr -> nxd_mqtt_client_socket), client_ptr -> nxd_mqtt_client_name, + NX_IP_NORMAL, NX_DONT_FRAGMENT, 0x80, NXD_MQTT_CLIENT_SOCKET_WINDOW_SIZE, + NX_NULL, _mqtt_client_disconnect_callback); - return(NXD_MQTT_INTERNAL_ERROR); - } /* Record the client_ptr in the socket structure. */ client_ptr -> nxd_mqtt_client_socket.nx_tcp_socket_reserved_ptr = (VOID *)client_ptr; @@ -3581,7 +3755,7 @@ UINT _nxde_mqtt_client_login_set(NXD_MQTT_CLIENT *client_ptr, /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_retransmit_message PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3605,8 +3779,7 @@ UINT _nxde_mqtt_client_login_set(NXD_MQTT_CLIENT *client_ptr, /* */ /* tx_mutex_get */ /* tx_mutex_put */ -/* nx_secure_tls_session_send */ -/* nx_tcp_socket_send */ +/* _nxd_mqtt_packet_send */ /* nx_packet_release */ /* tx_time_get */ /* nx_packet_copy */ @@ -3622,6 +3795,9 @@ UINT _nxde_mqtt_client_login_set(NXD_MQTT_CLIENT *client_ptr, /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static UINT _nxd_mqtt_client_retransmit_message(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option) @@ -3653,20 +3829,8 @@ UCHAR fixed_header; /* Release the mutex. */ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); - /* Send the packet. */ -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option); - } - else - { - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); - } -#else - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); - -#endif /* NX_SECURE_ENABLE */ + /* Send packet to server. */ + status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, wait_option); if (status) { @@ -3701,7 +3865,7 @@ UCHAR fixed_header; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_connect PORTABLE C */ -/* 6.1.8 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -3768,6 +3932,12 @@ UCHAR fixed_header; /* corrected the logic for */ /* non-blocking mode, */ /* resulting in version 6.1.8 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), and */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nxd_mqtt_client_connect(NXD_MQTT_CLIENT *client_ptr, NXD_ADDRESS *server_ip, UINT server_port, @@ -3818,6 +3988,7 @@ UINT old_priority; nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session)); } #endif /* NX_SECURE_ENABLE */ + tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); return(NXD_MQTT_INVALID_STATE); } @@ -3840,20 +4011,8 @@ UINT old_priority; client_ptr -> nxd_mqtt_ping_timeout = NXD_MQTT_PING_TIMEOUT_DELAY; /* Create timer */ - status = tx_timer_create(&(client_ptr -> nxd_mqtt_timer), "MQTT Timer", _nxd_mqtt_periodic_timer_entry, (ULONG)client_ptr, - client_ptr -> nxd_mqtt_timer_value, client_ptr -> nxd_mqtt_timer_value, TX_AUTO_ACTIVATE); - if (status) - { -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session)); - } -#endif /* NX_SECURE_ENABLE */ - - tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); - return(NXD_MQTT_INTERNAL_ERROR); - } + tx_timer_create(&(client_ptr -> nxd_mqtt_timer), "MQTT Timer", _nxd_mqtt_periodic_timer_entry, (ULONG)client_ptr, + client_ptr -> nxd_mqtt_timer_value, client_ptr -> nxd_mqtt_timer_value, TX_AUTO_ACTIVATE); } else { @@ -3867,49 +4026,41 @@ UINT old_priority; /* Set TCP connection establish notify for non-blocking mode. */ if (wait_option == 0) { - status = nx_tcp_socket_establish_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_tcp_establish_notify); + nx_tcp_socket_establish_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_tcp_establish_notify); - /* Check status. */ - if (status != NX_SUCCESS) + /* Set the receive callback. */ + nx_tcp_socket_receive_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_receive_callback); + +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) { -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session)); - } -#endif /* NX_SECURE_ENABLE */ - tx_timer_delete(&(client_ptr -> nxd_mqtt_timer)); - tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); - return(status); - } - /* Set the receive callback. */ - nx_tcp_socket_receive_notify(&client_ptr -> nxd_mqtt_client_socket, _nxd_mqtt_receive_callback); + /* Set the websocket connection callback. */ + nx_websocket_client_connection_status_callback_set(&client_ptr -> nxd_mqtt_client_websocket, client_ptr, _nxd_mqtt_client_websocket_connection_status_callback); + } +#endif /* NXD_MQTT_OVER_WEBSOCKET */ } else { /* Clean receive callback. */ client_ptr -> nxd_mqtt_client_socket.nx_tcp_receive_callback = NX_NULL; + +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + + /* Clean the websocket connection callback. */ + nx_websocket_client_connection_status_callback_set(&client_ptr -> nxd_mqtt_client_websocket, NX_NULL, NX_NULL); + } +#endif /* NXD_MQTT_OVER_WEBSOCKET */ } /* Release mutex */ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); /* First attempt to bind the client socket. */ - status = nx_tcp_client_socket_bind(&(client_ptr -> nxd_mqtt_client_socket), NX_ANY_PORT, wait_option); - - if (status != NX_SUCCESS) - { -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - nx_secure_tls_session_delete(&(client_ptr -> nxd_mqtt_tls_session)); - } -#endif /* NX_SECURE_ENABLE */ - tx_timer_delete(&(client_ptr -> nxd_mqtt_timer)); - return(NXD_MQTT_INTERNAL_ERROR); - } + nx_tcp_client_socket_bind(&(client_ptr -> nxd_mqtt_client_socket), NX_ANY_PORT, wait_option); /* Obtain the mutex. */ tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, NX_WAIT_FOREVER); @@ -3946,7 +4097,7 @@ UINT old_priority; } /* Just return for non-blocking mode. */ - if ((status == NX_IN_PROGRESS) || (wait_option == 0)) + if (wait_option == 0) { return(NX_IN_PROGRESS); } @@ -3982,6 +4133,43 @@ UINT old_priority; } #endif /* NX_SECURE_ENABLE */ +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { +#ifdef NX_SECURE_ENABLE + if (client_ptr -> nxd_mqtt_client_use_tls) + { + status = nx_websocket_client_secure_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_tls_session), + client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length, + client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length, + (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1, + wait_option); + } + else +#endif /* NX_SECURE_ENABLE */ + { + status = nx_websocket_client_connect(&(client_ptr -> nxd_mqtt_client_websocket), &(client_ptr -> nxd_mqtt_client_socket), + client_ptr -> nxd_mqtt_client_websocket_host, client_ptr -> nxd_mqtt_client_websocket_host_length, + client_ptr -> nxd_mqtt_client_websocket_uri_path, client_ptr -> nxd_mqtt_client_websocket_uri_path_length, + (UCHAR *)NXD_MQTT_OVER_WEBSOCKET_PROTOCOL, sizeof(NXD_MQTT_OVER_WEBSOCKET_PROTOCOL) - 1, + wait_option); + } + + if (status != NX_SUCCESS) + { + + /* Revert thread priority. */ + tx_thread_priority_change(tx_thread_identify(), old_priority, &old_priority); + + /* End connection. */ + _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT); + + return(NXD_MQTT_CONNECT_FAILURE); + } + } + +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /* Start to send connect packet. */ status = _nxd_mqtt_client_connect_packet_send(client_ptr, wait_option); @@ -3993,22 +4181,11 @@ UINT old_priority; /* End connection. */ _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT); - return(NXD_MQTT_CONNECT_FAILURE); } -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_receive(&(client_ptr -> nxd_mqtt_tls_session), &packet_ptr, wait_option); - } - else - { - status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, wait_option); - } -#else - status = nx_tcp_socket_receive(&client_ptr -> nxd_mqtt_client_socket, &packet_ptr, wait_option); -#endif /* NX_SECURE_ENABLE */ + /* Call a receive. */ + status = _nxd_mqtt_packet_receive(client_ptr, &packet_ptr, wait_option); /* Revert thread priority. */ tx_thread_priority_change(tx_thread_identify(), old_priority, &old_priority); @@ -4044,7 +4221,7 @@ UINT old_priority; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_connect_packet_send PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4069,13 +4246,12 @@ UINT old_priority; /* CALLS */ /* */ /* nx_packet_release */ -/* nx_tcp_socket_send */ -/* nx_secure_tls_session_send */ /* _nxd_mqtt_packet_allocate */ /* _nxd_mqtt_release_transmit_packet */ /* _nxd_mqtt_client_connection_end */ /* _nxd_mqtt_client_set_fixed_header */ /* _nxd_mqtt_client_append_message */ +/* _nxd_mqtt_packet_send */ /* */ /* CALLED BY */ /* */ @@ -4090,6 +4266,12 @@ UINT old_priority; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nxd_mqtt_client_connect_packet_send(NXD_MQTT_CLIENT *client_ptr, ULONG wait_option) @@ -4167,10 +4349,10 @@ UINT keepalive = (client_ptr -> nxd_mqtt_keepalive/NX_IP_PERIODI return(NXD_MQTT_INTERNAL_ERROR); } - status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr); + status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, wait_option); + if (status) { - return(status); } @@ -4182,21 +4364,18 @@ UINT keepalive = (client_ptr -> nxd_mqtt_keepalive/NX_IP_PERIODI if (ret) { - /* Release the packet. */ nx_packet_release(packet_ptr); - return(NXD_MQTT_PACKET_POOL_FAILURE); } - + + /* Fill in protocol name. */ ret = _nxd_mqtt_client_append_message(client_ptr, packet_ptr, "MQTT", 4, wait_option); if (ret) { - /* Release the packet. */ nx_packet_release(packet_ptr); - return(NXD_MQTT_PACKET_POOL_FAILURE); } @@ -4263,19 +4442,7 @@ UINT keepalive = (client_ptr -> nxd_mqtt_keepalive/NX_IP_PERIODI } /* Ready to send the connect message to the server. */ -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option); - } - else - { - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); - } -#else - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); - -#endif /* NX_SECURE_ENABLE */ + status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, wait_option); if (status) { @@ -4383,7 +4550,7 @@ UINT ret; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_delete PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4420,6 +4587,9 @@ UINT ret; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr) @@ -4452,6 +4622,14 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr) nx_cloud_delete(&(client_ptr -> nxd_mqtt_client_cloud)); #endif /* NXD_MQTT_CLOUD_ENABLE */ +#ifdef NXD_MQTT_OVER_WEBSOCKET + if (client_ptr -> nxd_mqtt_client_use_websocket) + { + nx_websocket_client_delete(&client_ptr -> nxd_mqtt_client_websocket); + client_ptr -> nxd_mqtt_client_use_websocket = NX_FALSE; + } +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + return(NXD_MQTT_SUCCESS); } @@ -4460,7 +4638,7 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr) /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_publish_packet_send PORTABLE C */ -/* 6.1.8 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4486,10 +4664,9 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr) /* */ /* tx_mutex_get */ /* tx_mutex_put */ -/* nx_tcp_socket_send */ -/* nx_secure_tls_session_send */ /* nx_packet_release */ /* _nxd_mqtt_copy_transmit_packet */ +/* _nxd_mqtt_packet_send */ /* */ /* CALLED BY */ /* */ @@ -4506,6 +4683,9 @@ UINT _nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr) /* supported maximum transmit */ /* queue depth, */ /* resulting in version 6.1.8 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nxd_mqtt_client_publish_packet_send(NXD_MQTT_CLIENT *client_ptr, NX_PACKET *packet_ptr, @@ -4571,19 +4751,7 @@ UINT ret = NXD_MQTT_SUCCESS; tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); /* Ready to send the connect message to the server. */ -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, wait_option); - } - else - { - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); - } -#else - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, wait_option); - -#endif /* NX_SECURE_ENABLE */ + status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, wait_option); if (status) { @@ -4598,7 +4766,7 @@ UINT ret = NXD_MQTT_SUCCESS; /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_client_publish PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4647,6 +4815,9 @@ UINT ret = NXD_MQTT_SUCCESS; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nxd_mqtt_client_publish(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name, UINT topic_name_length, @@ -4672,7 +4843,7 @@ UINT ret = NXD_MQTT_SUCCESS; return(NXD_MQTT_NOT_CONNECTED); } - status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr); + status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, wait_option); if (status != NXD_MQTT_SUCCESS) { @@ -4925,7 +5096,7 @@ UINT _nxd_mqtt_client_unsubscribe(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name, /* FUNCTION RELEASE */ /* */ /* _nxd_mqtt_send_simple_message PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4951,8 +5122,7 @@ UINT _nxd_mqtt_client_unsubscribe(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name, /* tx_mutex_get */ /* _nxd_mqtt_packet_allocate */ /* tx_mutex_put */ -/* nx_tcp_socket_send */ -/* nx_secure_tls_session_send */ +/* _nxd_mqtt_packet_send */ /* nx_packet_release */ /* */ /* CALLED BY */ @@ -4967,6 +5137,12 @@ UINT _nxd_mqtt_client_unsubscribe(NXD_MQTT_CLIENT *client_ptr, CHAR *topic_name, /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Spencer McDonough Modified comment(s), */ +/* improved internal logic, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Bo Chen Modified comment(s), improved */ +/* the logic of sending packet,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ static UINT _nxd_mqtt_send_simple_message(NXD_MQTT_CLIENT *client_ptr, UCHAR header_value) @@ -4977,7 +5153,7 @@ UINT status; UINT status_mutex; UCHAR *byte; - status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr); + status = _nxd_mqtt_packet_allocate(client_ptr, &packet_ptr, NX_WAIT_FOREVER); if (status) { return(NXD_MQTT_INTERNAL_ERROR); @@ -5002,20 +5178,9 @@ UCHAR *byte; /* Release MQTT protection before making NetX/TLS calls. */ tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); -#ifdef NX_SECURE_ENABLE - if (client_ptr -> nxd_mqtt_client_use_tls) - { - status = nx_secure_tls_session_send(&(client_ptr -> nxd_mqtt_tls_session), packet_ptr, NX_WAIT_FOREVER); - } - else - { - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER); - } -#else - status = nx_tcp_socket_send(&client_ptr -> nxd_mqtt_client_socket, packet_ptr, NX_WAIT_FOREVER); - -#endif /* NX_SECURE_ENABLE */ + /* Send packet to server. */ + status = _nxd_mqtt_packet_send(client_ptr, packet_ptr, NX_WAIT_FOREVER); status_mutex = tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, NX_WAIT_FOREVER); if (status) @@ -6202,3 +6367,207 @@ UINT status; return(NXD_MQTT_SUCCESS); } #endif /* NXD_MQTT_CLOUD_ENABLE */ + +#ifdef NXD_MQTT_OVER_WEBSOCKET +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nxd_mqtt_client_websocket_connection_status_callback */ +/* PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function is the websocket connection status callback. */ +/* */ +/* INPUT */ +/* */ +/* websocket_client_ptr Pointer to websocket client */ +/* context Pointer to MQTT client */ +/* status Websocket connection status */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* _nxd_mqtt_client_connect_packet_send */ +/* _nxd_mqtt_client_connection_end */ +/* */ +/* CALLED BY */ +/* */ +/* _nxd_mqtt_client_event_process */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +VOID _nxd_mqtt_client_websocket_connection_status_callback(NX_WEBSOCKET_CLIENT *websocket_client_ptr, VOID *context, UINT status) +{ +NXD_MQTT_CLIENT *client_ptr = (NXD_MQTT_CLIENT *)context; + + + NX_PARAMETER_NOT_USED(websocket_client_ptr); + + if (status == NX_SUCCESS) + { + + /* Start to send MQTT connect packet. */ + status = _nxd_mqtt_client_connect_packet_send(client_ptr, NX_NO_WAIT); + } + + /* If an error occurs. */ + if (status) + { + + /* End connection. */ + _nxd_mqtt_client_connection_end(client_ptr, NX_NO_WAIT); + + /* Check callback function. */ + if (client_ptr -> nxd_mqtt_connect_notify) + { + client_ptr -> nxd_mqtt_connect_notify(client_ptr, status, client_ptr -> nxd_mqtt_connect_context); + } + } +} + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nxd_mqtt_client_websocket_set PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function sets the websocket. */ +/* */ +/* INPUT */ +/* */ +/* client_ptr Pointer to MQTT Client */ +/* host Host used by the client */ +/* host_length Length of host, in bytes */ +/* uri_path URI path used by the client */ +/* uri_path_length Length of uri path, in bytes */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +UINT _nxd_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length) +{ +UINT status; + + /* Obtain the mutex. */ + status = tx_mutex_get(client_ptr -> nxd_mqtt_client_mutex_ptr, NX_WAIT_FOREVER); + + if (status != TX_SUCCESS) + { + return(NXD_MQTT_MUTEX_FAILURE); + } + + /* Set the host info. */ + client_ptr -> nxd_mqtt_client_websocket_host = host; + client_ptr -> nxd_mqtt_client_websocket_host_length = host_length; + client_ptr -> nxd_mqtt_client_websocket_uri_path = uri_path; + client_ptr -> nxd_mqtt_client_websocket_uri_path_length = uri_path_length; + + /* Create WebSocket. */ + status = nx_websocket_client_create(&client_ptr -> nxd_mqtt_client_websocket, (UCHAR *)"", + client_ptr -> nxd_mqtt_client_ip_ptr, + client_ptr -> nxd_mqtt_client_packet_pool_ptr); + + /* Check status. */ + if (status) + { + tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); + return(status); + } + + client_ptr -> nxd_mqtt_client_use_websocket = NX_TRUE; + + tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr); + return(NXD_MQTT_SUCCESS); +} + + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nxde_mqtt_client_websocket_set PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function checks for errors in setting MQTT client websocket. */ +/* */ +/* INPUT */ +/* */ +/* client_ptr Pointer to MQTT Client */ +/* host Host used by the client */ +/* host_length Length of host, in bytes */ +/* uri_path URI path used by the client */ +/* uri_path_length Length of uri path, in bytes */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* _nxd_mqtt_client_websocket_set */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +UINT _nxde_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length) +{ + + /* Validate the parameters. */ + if ((client_ptr == NX_NULL) || (host == NX_NULL) || (host_length == 0) || + (uri_path == NX_NULL) || (uri_path_length == 0)) + { + return(NX_PTR_ERROR); + } + + return(_nxd_mqtt_client_websocket_set(client_ptr, host, host_length, uri_path, uri_path_length)); +} +#endif /* NXD_MQTT_OVER_WEBSOCKET */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h index e35c3a2f..9327a779 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/mqtt/nxd_mqtt_client.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nxd_mqtt_client.h PORTABLE C */ -/* 6.1.9 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -55,6 +55,9 @@ /* 10-15-2021 Yuxin Zhou Modified comment(s), included */ /* necessary header file, */ /* resulting in version 6.1.9 */ +/* 10-31-2022 Bo Chen Modified comment(s), supported*/ +/* mqtt over websocket, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -87,11 +90,18 @@ extern "C" { #endif /* NX_SECURE_ENABLE */ #endif /* NXD_MQTT_REQUIRE_TLS */ +#ifdef NXD_MQTT_OVER_WEBSOCKET +#include "nx_websocket_client.h" +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + /* Defined, MQTT transmit queue depth is enabled. It must be positive integer. */ /* #define NXD_MQTT_MAXIMUM_TRANSMIT_QUEUE_DEPTH 20 */ +/* Define MQTT protocol for websocket. */ +#define NXD_MQTT_OVER_WEBSOCKET_PROTOCOL "mqtt" + /* Define memcpy, memset and memcmp functions used internal. */ #ifndef NXD_MQTT_SECURE_MEMCPY #define NXD_MQTT_SECURE_MEMCPY memcpy @@ -159,6 +169,9 @@ extern "C" { /* Define the default MQTT TLS (secure) port number */ #define NXD_MQTT_TLS_PORT 8883 +/* Define the default MQTT TLS (secure) over WebSocket port number */ +#define NXD_MQTT_OVER_WEBSOCKET_TLS_PORT 443 + #define MQTT_PROTOCOL_LEVEL 4 @@ -368,6 +381,14 @@ typedef struct NXD_MQTT_CLIENT_STRUCT NX_SECURE_TLS_SESSION nxd_mqtt_tls_session; UINT nxd_mqtt_tls_in_progress; #endif +#ifdef NXD_MQTT_OVER_WEBSOCKET + UINT nxd_mqtt_client_use_websocket; + NX_WEBSOCKET_CLIENT nxd_mqtt_client_websocket; + UCHAR *nxd_mqtt_client_websocket_host; + UINT nxd_mqtt_client_websocket_host_length; + UCHAR *nxd_mqtt_client_websocket_uri_path; + UINT nxd_mqtt_client_websocket_uri_path_length; +#endif /* NXD_MQTT_OVER_WEBSOCKET */ } NXD_MQTT_CLIENT; @@ -396,6 +417,9 @@ typedef struct NXD_MQTT_CLIENT_STRUCT #define nxd_mqtt_client_receive_notify_set _nxd_mqtt_client_receive_notify_set #define nxd_mqtt_client_message_get _nxd_mqtt_client_message_get #define nxd_mqtt_client_disconnect_notify_set _nxd_mqtt_client_disconnect_notify_set +#ifdef NXD_MQTT_OVER_WEBSOCKET +#define nxd_mqtt_client_websocket_set _nxd_mqtt_client_websocket_set +#endif /* NXD_MQTT_OVER_WEBSOCKET */ #else /* if !NXD_MQTT_CLIENT_SOURCE_CODE */ #define nxd_mqtt_client_create _nxde_mqtt_client_create @@ -411,6 +435,9 @@ typedef struct NXD_MQTT_CLIENT_STRUCT #define nxd_mqtt_client_receive_notify_set _nxde_mqtt_client_receive_notify_set #define nxd_mqtt_client_message_get _nxde_mqtt_client_message_get #define nxd_mqtt_client_disconnect_notify_set _nxde_mqtt_client_disconnect_notify_set +#ifdef NXD_MQTT_OVER_WEBSOCKET +#define nxd_mqtt_client_websocket_set _nxde_mqtt_client_websocket_set +#endif /* NXD_MQTT_OVER_WEBSOCKET */ #endif /* NX_DISABLE_ERROR_CHECKING */ @@ -444,6 +471,9 @@ UINT nxd_mqtt_client_disconnect(NXD_MQTT_CLIENT *client_ptr); UINT nxd_mqtt_client_delete(NXD_MQTT_CLIENT *client_ptr); UINT nxd_mqtt_client_disconnect_notify_set(NXD_MQTT_CLIENT *client_ptr, VOID (*disconnect_notify)(NXD_MQTT_CLIENT *)); +#ifdef NXD_MQTT_OVER_WEBSOCKET +UINT nxd_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length); +#endif /* NXD_MQTT_OVER_WEBSOCKET */ #else /* ifdef NXD_MQTT_CLIENT_SOURCE_CODE */ @@ -517,6 +547,12 @@ UINT _nxde_mqtt_client_secure_connect(NXD_MQTT_CLIENT *client_ptr, NXD_ADDRESS * UINT keepalive, UINT clean_session, ULONG timeout); #endif /* NX_SECURE_ENABLE */ +#ifdef NXD_MQTT_OVER_WEBSOCKET +UINT _nxd_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length); +UINT _nxde_mqtt_client_websocket_set(NXD_MQTT_CLIENT *client_ptr, UCHAR *host, UINT host_length, UCHAR *uri_path, UINT uri_path_length); +VOID _nxd_mqtt_client_websocket_connection_status_callback(NX_WEBSOCKET_CLIENT *websocket_client_ptr, VOID *context, UINT status); +#endif /* NXD_MQTT_OVER_WEBSOCKET */ + #endif /* ifndef NXD_MQTT_CLIENT_SOURCE_CODE */ #ifdef NXD_MQTT_CLOUD_ENABLE diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c index a7660db5..c9453b36 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/snmp/nxd_snmp.c @@ -15145,7 +15145,7 @@ UCHAR encoding_started; /* FUNCTION RELEASE */ /* */ /* _nx_snmp_utility_object_data_get PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -15182,6 +15182,9 @@ UCHAR encoding_started; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* fixed compiler warnings, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_snmp_utility_object_data_get(UCHAR *buffer_ptr, NX_SNMP_OBJECT_DATA *object_data, INT buffer_length) @@ -15189,9 +15192,9 @@ UINT _nx_snmp_utility_object_data_get(UCHAR *buffer_ptr, NX_SNMP_OBJECT_DATA *o UINT i; -UINT length; +UINT length = 0; LONG data; -UINT total; +UINT total = 0; CHAR byte; LONG temp = 0; USHORT tlv_type, tlv_tag_class; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c index 7bc1a313..c275ea54 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/sntp/nxd_sntp_client.c @@ -2432,7 +2432,7 @@ NX_SNTP_TIME local_time; /* FUNCTION RELEASE */ /* */ /* _nx_sntp_client_receive_time_update PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2480,6 +2480,9 @@ NX_SNTP_TIME local_time; /* added support for disabling */ /* message check, */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* corrected the port check, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_sntp_client_receive_time_update(NX_SNTP_CLIENT *client_ptr, ULONG timeout) @@ -2521,7 +2524,7 @@ NXD_ADDRESS source_ip_address, destination_ip_address; sender_port = (UINT)udp_header_ptr -> nx_udp_header_word_0 >> NX_SHIFT_BY_16; /* Check if this is the server port the Client expects. */ - if (sender_port != NX_SNTP_CLIENT_UDP_PORT) + if (sender_port != NX_SNTP_SERVER_UDP_PORT) { /* No, reject the packet. */ @@ -4846,7 +4849,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_sntp_client_utility_display_date_time PORTABLE C */ -/* 6.1.8 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4893,6 +4896,9 @@ UINT status; /* improved the logic of */ /* converting number to string,*/ /* resulting in version 6.1.8 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), fixed */ +/* the typo of August string, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_sntp_client_utility_display_date_time(NX_SNTP_CLIENT *client_ptr, CHAR *buffer, UINT length) @@ -4903,7 +4909,7 @@ UINT offset; UINT return_length; NX_SNTP_DATE_TIME DisplayTime; const CHAR *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aud", "Sep", "Oct", "Nov", "Dec"}; + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; #ifndef NX_SNTP_CURRENT_YEAR diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c index 9169e82a..409d2d72 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_tcpserver.c @@ -352,7 +352,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_tcpserver_tls_setup PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -436,6 +436,10 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* corrected the index of the */ +/* remote certificate list, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ @@ -530,7 +534,7 @@ UINT status; for(cert_count = 0; cert_count < remote_certs_num; ++cert_count) { /* Allocate a remote certificate from the provided array. */ - status = nx_secure_tls_remote_certificate_allocate(tls_session, remote_certificates[i], + status = nx_secure_tls_remote_certificate_allocate(tls_session, remote_certificates[cert_count], session_cert_buffer, session_cert_buffer_size); if(status != NX_SUCCESS) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c index 2ef47e89..d5becc3c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_client.c @@ -2614,7 +2614,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_web_http_client_request_packet_send PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -2651,6 +2651,9 @@ UINT status; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), fixed */ +/* the invalid release issue, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_web_http_client_request_packet_send(NX_WEB_HTTP_CLIENT *client_ptr, NX_PACKET *packet_ptr, UINT more_data, ULONG wait_option) @@ -2693,9 +2696,6 @@ UINT length = packet_ptr -> nx_packet_length; /* No, send was not successful. */ - /* Release the packet. */ - nx_packet_release(packet_ptr); - /* Disconnect and unbind the socket. */ _nx_web_http_client_error_exit(client_ptr, wait_option); @@ -5824,7 +5824,7 @@ UINT header_size; /* FUNCTION RELEASE */ /* */ /* _nx_web_http_client_put_packet PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5863,6 +5863,9 @@ UINT header_size; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), fixed */ +/* the invalid release issue, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_web_http_client_put_packet(NX_WEB_HTTP_CLIENT *client_ptr, NX_PACKET *packet_ptr, ULONG wait_option) @@ -5943,9 +5946,6 @@ UINT status; { /* No, send was not successful. */ - - /* Release the packet. */ - nx_packet_release(packet_ptr); /* Disconnect and unbind the socket. */ _nx_web_http_client_error_exit(client_ptr, wait_option); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c index 588569f2..7e2c5837 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.c @@ -47,10 +47,9 @@ #endif /* NX_WEB_HTTP_SERVER_OMIT_CONTENT_LENGTH */ #ifdef NX_WEB_HTTP_DIGEST_ENABLE -/* Define the default nonce, used only for MD5 authentication. For security reasons, this ASCII value should - change over time. */ -CHAR _nx_web_http_server_nonce[] = "a4b8c8d7e0f6a7b2c3d2e4f5a4b7c5d2e7f"; +/* Use for mapping random nonces to printable characters. */ +static CHAR _nx_web_http_server_base64_array[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #endif /* Define date strings. */ @@ -3116,7 +3115,7 @@ NX_WEB_HTTP_SERVER *server_ptr; /* */ /* FUNCTION RELEASE */ /* */ -/* _nx_web_http_server_connection_present PORTABLE C */ +/* _nx_web_http_server_receive_data PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ @@ -5153,7 +5152,7 @@ NX_PACKET *packet_ptr; /* FUNCTION RELEASE */ /* */ /* _nx_web_http_server_basic_authenticate PORTABLE C */ -/* 6.1.6 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -5208,6 +5207,10 @@ NX_PACKET *packet_ptr; /* improved the logic of */ /* parsing base64, */ /* resulting in version 6.1.6 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), fixed */ +/* the issue of processing */ +/* empty password, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_web_http_server_basic_authenticate(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT *auth_request_present) @@ -5290,7 +5293,9 @@ UINT authorization_decoded_size; } /* Determine if we have a match. */ - if (match && (i == authorization_decoded_size) && (authorization_decoded[i] == (CHAR) NX_NULL)) + if (match && (i == authorization_decoded_size) && + (authorization_decoded[i] == (CHAR) NX_NULL) && + (password_ptr[j] == (CHAR) NX_NULL)) { /* Yes, we have successful authorization!! */ @@ -6254,13 +6259,110 @@ UINT temp_name_length; return(NX_WEB_HTTP_EXTENSION_MIME_DEFAULT); } + #ifdef NX_WEB_HTTP_DIGEST_ENABLE + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nx_web_http_server_nonce_allocate PORTABLE C */ +/* 6.2.0 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function allocate a new nonce for digest authentication. */ +/* */ +/* INPUT */ +/* */ +/* server_ptr HTTP Server pointer */ +/* nonce_ptr Allocated nonce pointer */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* tx_time_get Get system time */ +/* */ +/* CALLED BY */ +/* */ +/* _nx_web_http_server_digest_authenticate */ +/* Digest authentication */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 10-31-2022 Yuxin Zhou Initial Version 6.2.0 */ +/* */ +/**************************************************************************/ +UINT _nx_web_http_server_nonce_allocate(NX_WEB_HTTP_SERVER *server_ptr, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr) +{ +UINT i; +UCHAR random_value; +NX_WEB_HTTP_SERVER_NONCE *nonces_list = server_ptr -> nx_web_http_server_nonces; + + + /* Search if there is free entry for new nonce. */ + for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++) + { + if (nonces_list[i].nonce_state == NX_WEB_HTTP_SERVER_NONCE_INVALID) + { + *nonce_ptr = &(nonces_list[i]); + break; + } + } + + if (i == NX_WEB_HTTP_SERVER_NONCE_MAX) + { + + /* If no free entry, check the timeout of allocated nonces. */ + for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++) + { + if (nonces_list[i].nonce_state == NX_WEB_HTTP_SERVER_NONCE_VALID) + { + if (tx_time_get() > nonces_list[i].nonce_timestamp + NX_WEB_HTTP_SERVER_NONCE_TIMEOUT) + { + + /* If this nonce is timed out, free up this entry for new nonce. */ + *nonce_ptr = &(nonces_list[i]); + break; + } + } + } + + /* If no entry can be allocated, return error. */ + if (i == NX_WEB_HTTP_SERVER_NONCE_MAX) + { + return(NX_NOT_FOUND); + } + } + + /* Generate new nonce for digest authentication. */ + for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_SIZE; i++) + { + random_value = (UCHAR)NX_RAND() % (sizeof(_nx_web_http_server_base64_array) - 1); + (*nonce_ptr) -> nonce_buffer[i] = (UCHAR)_nx_web_http_server_base64_array[random_value]; + } + + /* Reset the timestamp and state for the new nonce. */ + (*nonce_ptr) -> nonce_timestamp = tx_time_get(); + (*nonce_ptr) -> nonce_state = NX_WEB_HTTP_SERVER_NONCE_VALID; + + return(NX_SUCCESS); +} + /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_web_http_server_digest_authenticate PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6312,6 +6414,9 @@ UINT temp_name_length; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_web_http_server_digest_authenticate(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT *auth_request_present) @@ -6329,6 +6434,7 @@ CHAR crlf[2] = {13,10}; CHAR authorization_nc[NX_WEB_HTTP_MAX_RESOURCE + 1]; CHAR authorization_cnonce[NX_WEB_HTTP_MAX_RESOURCE + 1]; UINT realm_length; +NX_WEB_HTTP_SERVER_NONCE *nonce_ptr = NX_NULL; /* Default to no authentication request detected. */ *auth_request_present = NX_FALSE; @@ -6337,7 +6443,7 @@ UINT realm_length; status = NX_WEB_HTTP_DIGEST_AUTHENTICATE; /* Is the authorization request present? */ - if (_nx_web_http_server_retrieve_digest_authorization(packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce)) + if (_nx_web_http_server_retrieve_digest_authorization(server_ptr, packet_ptr, authorization_response, authorization_uri, authorization_nc, authorization_cnonce, &nonce_ptr)) { /* Yes, an authorization request is present. */ @@ -6371,7 +6477,7 @@ UINT realm_length; } /* Calculate what the MD5 should be. */ - _nx_web_http_server_digest_response_calculate(server_ptr, name_ptr, realm_ptr, password_ptr, _nx_web_http_server_nonce, method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response); + _nx_web_http_server_digest_response_calculate(server_ptr, name_ptr, realm_ptr, password_ptr, (CHAR *)(nonce_ptr -> nonce_buffer), method, authorization_uri, authorization_nc, authorization_cnonce, calculated_response); /* Determine if the calculated response is the same as the received response. */ i = 0; @@ -6389,6 +6495,32 @@ UINT realm_length; /* Otherwise, look at next character. */ i++; } + + /* If the response is authenticated, mark the nonce as accepted. */ + if (status == NX_SUCCESS) + { + + /* If another session uses the same nonce, don't accept it. */ + if (nonce_ptr -> nonce_state == NX_WEB_HTTP_SERVER_NONCE_ACCEPTED) + { + if (nonce_ptr -> nonce_session_ptr != server_ptr -> nx_web_http_server_current_session_ptr) + { + status = NX_WEB_HTTP_DIGEST_AUTHENTICATE; + } + } + else + { + + /* Update nonce state and set the session pointer for mapping in disconnection. */ + nonce_ptr -> nonce_state = NX_WEB_HTTP_SERVER_NONCE_ACCEPTED; + nonce_ptr -> nonce_session_ptr = server_ptr -> nx_web_http_server_current_session_ptr; + } + } + else + { + nonce_ptr -> nonce_state = NX_WEB_HTTP_SERVER_NONCE_INVALID; + } + /* If digest authenticate callback function returns non-success value, the request is considered unauthenticated. */ if(callback_status != NX_SUCCESS) @@ -6399,6 +6531,24 @@ UINT realm_length; if (status == NX_WEB_HTTP_DIGEST_AUTHENTICATE) { + /* Allocate a new nonce for digest authentication. */ + status1 = _nx_web_http_server_nonce_allocate(server_ptr, &nonce_ptr); + + /* Determine if an error occurred in the packet allocation. */ + if (status1) + { + + /* Send response back to HTTP Client. */ + _nx_web_http_server_response_send(server_ptr, NX_WEB_HTTP_STATUS_INTERNAL_ERROR, sizeof(NX_WEB_HTTP_STATUS_INTERNAL_ERROR) - 1, + "NetX HTTP Server Internal Error", sizeof("NetX HTTP Server Internal Error") - 1, NX_NULL, 0); + + /* Indicate an allocation error occurred. */ + server_ptr -> nx_web_http_server_allocation_errors++; + + /* Return the internal NetX error. */ + return(status1); + } + /* We need authorization so build the HTTP 401 Unauthorized message to send to the server. */ /* Check string length. */ @@ -6481,7 +6631,7 @@ UINT realm_length; server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER); /* Place the nonce string into the buffer. */ - nx_packet_data_append(packet_ptr, _nx_web_http_server_nonce, sizeof(_nx_web_http_server_nonce) - 1, + nx_packet_data_append(packet_ptr, nonce_ptr -> nonce_buffer, NX_WEB_HTTP_SERVER_NONCE_SIZE, server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER); /* Insert the double quote. */ @@ -6496,6 +6646,14 @@ UINT realm_length; nx_packet_data_append(packet_ptr, crlf, 2, server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER); + /* Set Content-Length as 0. */ + nx_packet_data_append(packet_ptr, "Content-Length: 0", 17, + server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER); + + /* Place the into the buffer. */ + nx_packet_data_append(packet_ptr, crlf, 2, + server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER); + /* Place another into the buffer to signal end of FULL HTTP response. */ nx_packet_data_append(packet_ptr, crlf, 2, server_ptr -> nx_web_http_server_packet_pool_ptr, NX_WAIT_FOREVER); @@ -6525,7 +6683,7 @@ UINT realm_length; /* FUNCTION RELEASE */ /* */ /* _nx_web_http_server_digest_response_calculate PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6572,6 +6730,9 @@ UINT realm_length; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_web_http_server_digest_response_calculate(NX_WEB_HTTP_SERVER *server_ptr, CHAR *username, CHAR *realm, CHAR *password, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result) @@ -6585,7 +6746,6 @@ UINT password_length; UINT realm_length; UINT method_length; UINT uri_length; -UINT nonce_length; UINT nc_length; UINT cnonce_length; @@ -6595,7 +6755,6 @@ UINT cnonce_length; _nx_utility_string_length_check(realm, &realm_length, NX_MAX_STRING_LENGTH) || _nx_utility_string_length_check(method, &method_length, 7) || _nx_utility_string_length_check(uri, &uri_length, NX_WEB_HTTP_MAX_RESOURCE) || - _nx_utility_string_length_check(nonce, &nonce_length, sizeof(_nx_web_http_server_nonce) - 1) || _nx_utility_string_length_check(nc, &nc_length, NX_WEB_HTTP_MAX_RESOURCE) || _nx_utility_string_length_check(cnonce, &cnonce_length, NX_WEB_HTTP_MAX_RESOURCE)) { @@ -6629,7 +6788,7 @@ UINT cnonce_length; _nx_md5_initialize(&(server_ptr -> nx_web_http_server_md5data)); _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) ha1_string, sizeof(ha1_string) - 1); _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) ":", 1); - _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) nonce, nonce_length); + _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) nonce, NX_WEB_HTTP_SERVER_NONCE_SIZE); /* Start of Internet Explorer bug work-around. */ _nx_md5_update(&(server_ptr -> nx_web_http_server_md5data), (unsigned char *) ":", 1); @@ -6654,7 +6813,7 @@ UINT cnonce_length; /* FUNCTION RELEASE */ /* */ /* _nx_web_http_server_retrieve_digest_authorization PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -6666,11 +6825,13 @@ UINT cnonce_length; /* */ /* INPUT */ /* */ +/* server_ptr HTTP Server pointer */ /* packet_ptr Request packet pointer */ /* response Digest response pointer */ /* uri URI from response pointer */ /* nc Nonce count string */ /* cnonce Client nonce string */ +/* nonce_ptr Server nonce pointer */ /* */ /* OUTPUT */ /* */ @@ -6694,15 +6855,20 @@ UINT cnonce_length; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ -UINT _nx_web_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce) +UINT _nx_web_http_server_retrieve_digest_authorization(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr) { UINT length; UINT found; CHAR *buffer_ptr; CHAR *saved_buffer_ptr; +UCHAR *nonce_buffer; +UINT i; /* Set the found flag to false. */ @@ -6822,6 +6988,86 @@ CHAR *saved_buffer_ptr; /* Save current buffer pointer, so each parameter search always starts from here. */ saved_buffer_ptr = buffer_ptr; + while (((buffer_ptr + 6) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0)) + { + + /* Check for the uri token. */ + if (((*(buffer_ptr) == 'n') || (*(buffer_ptr) == 'N')) && + ((*(buffer_ptr+1) == 'o') || (*(buffer_ptr+1) == 'O')) && + ((*(buffer_ptr+2) == 'n') || (*(buffer_ptr+2) == 'N')) && + ((*(buffer_ptr+3) == 'c') || (*(buffer_ptr+3) == 'C')) && + ((*(buffer_ptr+4) == 'e') || (*(buffer_ptr+4) == 'E')) && + (*(buffer_ptr+5) == '=')) + { + + /* Move the pointer up to the actual nonce string. */ + buffer_ptr = buffer_ptr + 6; + found = NX_TRUE; + + break; + } + + /* Move the pointer up to the next character. */ + buffer_ptr++; + } + + /* Check if nonce is found. */ + if (!found) + { + return(0); + } + + /* Now remove any extra blanks and quotes. */ + while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && ((*buffer_ptr == ' ') || (*buffer_ptr == (CHAR) 0x22))) + { + + /* Move the pointer up one character. */ + buffer_ptr++; + } + + /* Now pickup the nonce string. */ + length = 0; + nonce_buffer = (UCHAR *)buffer_ptr; + while ((buffer_ptr < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0) && (*buffer_ptr != ' ') && (*buffer_ptr != (CHAR) 13)) + { + + /* Determine if the ending quote is present. */ + if (*buffer_ptr == (CHAR) 0x22) + { + break; + } + + /* Increase the length. */ + length++; + buffer_ptr++; + } + + /* Check the nonce size. */ + if (length != NX_WEB_HTTP_SERVER_NONCE_SIZE) + { + return(0); + } + + /* Check if the nonce is valid. */ + for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++) + { + if ((server_ptr -> nx_web_http_server_nonces[i].nonce_state != NX_WEB_HTTP_SERVER_NONCE_INVALID) && + (memcmp(server_ptr -> nx_web_http_server_nonces[i].nonce_buffer, nonce_buffer, NX_WEB_HTTP_SERVER_NONCE_SIZE) == 0)) /* Use case of memcmp is verified. */ + { + *nonce_ptr = &(server_ptr -> nx_web_http_server_nonces[i]); + break; + } + } + + /* If the nonca is invalid, just return. */ + if (i == NX_WEB_HTTP_SERVER_NONCE_MAX) + { + return(0); + } + + /* Get saved buffer pointer. */ + buffer_ptr = saved_buffer_ptr; + /* Now look for the nc in the digest response. */ while (((buffer_ptr+3) < (CHAR *) packet_ptr -> nx_packet_append_ptr) && (*buffer_ptr != (CHAR) 0)) { @@ -6881,9 +7127,9 @@ CHAR *saved_buffer_ptr; if (((*buffer_ptr == 'c') || (*buffer_ptr == 'C')) && ((*(buffer_ptr+1) == 'n') || (*(buffer_ptr+1) == 'N')) && ((*(buffer_ptr+2) == 'o') || (*(buffer_ptr+2) == 'O')) && - ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+2) == 'N')) && - ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+2) == 'C')) && - ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+2) == 'E')) && + ((*(buffer_ptr+3) == 'n') || (*(buffer_ptr+3) == 'N')) && + ((*(buffer_ptr+4) == 'c') || (*(buffer_ptr+4) == 'C')) && + ((*(buffer_ptr+5) == 'e') || (*(buffer_ptr+5) == 'E')) && (*(buffer_ptr+6) == '=')) { @@ -6988,11 +7234,11 @@ CHAR *saved_buffer_ptr; if (((*buffer_ptr == 'r') || (*buffer_ptr == 'R')) && ((*(buffer_ptr+1) == 'e') || (*(buffer_ptr+1) == 'E')) && ((*(buffer_ptr+2) == 's') || (*(buffer_ptr+2) == 'S')) && - ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+2) == 'P')) && - ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+2) == 'O')) && - ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+2) == 'N')) && - ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+2) == 'S')) && - ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+2) == 'E')) && + ((*(buffer_ptr+3) == 'p') || (*(buffer_ptr+3) == 'P')) && + ((*(buffer_ptr+4) == 'o') || (*(buffer_ptr+4) == 'O')) && + ((*(buffer_ptr+5) == 'n') || (*(buffer_ptr+5) == 'N')) && + ((*(buffer_ptr+6) == 's') || (*(buffer_ptr+6) == 'S')) && + ((*(buffer_ptr+7) == 'e') || (*(buffer_ptr+7) == 'E')) && (*(buffer_ptr+8) == '=')) { @@ -10761,7 +11007,7 @@ NX_TCP_SOCKET *tcp_socket; /* FUNCTION RELEASE */ /* */ /* _nx_web_http_server_connection_disconnect PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -10798,6 +11044,9 @@ NX_TCP_SOCKET *tcp_socket; /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ VOID _nx_web_http_server_connection_disconnect(NX_WEB_HTTP_SERVER *server_ptr, NX_TCP_SESSION *session_ptr, UINT wait_option) @@ -10805,13 +11054,30 @@ VOID _nx_web_http_server_connection_disconnect(NX_WEB_HTTP_SERVER *server_ptr, N NX_TCP_SOCKET *tcp_socket; #ifdef NX_WEB_HTTPS_ENABLE NX_SECURE_TLS_SESSION *tls_session; -#endif +#endif /* NX_WEB_HTTPS_ENABLE */ +#ifdef NX_WEB_HTTP_DIGEST_ENABLE +UINT i; +#endif /* NX_WEB_HTTP_DIGEST_ENABLE */ #ifndef NX_WEB_HTTPS_ENABLE NX_PARAMETER_NOT_USED(server_ptr); NX_PARAMETER_NOT_USED(wait_option); #endif /* NX_WEB_HTTPS_ENABLE */ +#ifdef NX_WEB_HTTP_DIGEST_ENABLE + + /* Once the nonce has been accepted, set the state as invalid. */ + for (i = 0; i < NX_WEB_HTTP_SERVER_NONCE_MAX; i++) + { + if ((server_ptr -> nx_web_http_server_nonces[i].nonce_state == NX_WEB_HTTP_SERVER_NONCE_ACCEPTED) && + (server_ptr -> nx_web_http_server_nonces[i].nonce_session_ptr == session_ptr)) + { + server_ptr -> nx_web_http_server_nonces[i].nonce_state = NX_WEB_HTTP_SERVER_NONCE_INVALID; + break; + } + } +#endif /* NX_WEB_HTTP_DIGEST_ENABLE */ + tcp_socket = &(session_ptr -> nx_tcp_session_socket); #ifdef NX_WEB_HTTPS_ENABLE diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h index 12bcbbfc..ae2c0bc4 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/addons/web/nx_web_http_server.h @@ -27,7 +27,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_web_http_server.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -60,6 +60,9 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), and */ /* supported ECC configuration,*/ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yuxin Zhou Modified comment(s), and */ +/* supported random nonce, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -175,6 +178,24 @@ extern "C" { #define NX_WEB_HTTP_SERVER_RETRY_SHIFT 1 /* Every retry is twice as long */ #endif +#ifndef NX_WEB_HTTP_SERVER_NONCE_MAX +#define NX_WEB_HTTP_SERVER_NONCE_MAX (NX_WEB_HTTP_SERVER_SESSION_MAX << 1) +#endif + +#ifndef NX_WEB_HTTP_SERVER_NONCE_SIZE +#define NX_WEB_HTTP_SERVER_NONCE_SIZE 32 +#endif + +#ifndef NX_WEB_HTTP_SERVER_NONCE_TIMEOUT +#define NX_WEB_HTTP_SERVER_NONCE_TIMEOUT (10 * NX_IP_PERIODIC_RATE) +#endif + +/* Define the state of the nonce. */ + +#define NX_WEB_HTTP_SERVER_NONCE_INVALID 0 +#define NX_WEB_HTTP_SERVER_NONCE_VALID 1 +#define NX_WEB_HTTP_SERVER_NONCE_ACCEPTED 2 + /* Define HTTP Server request types. */ #define NX_WEB_HTTP_SERVER_UNKNOWN_REQUEST 0 @@ -225,6 +246,16 @@ typedef struct NX_WEB_HTTP_SERVER_DATE_STRUCT UCHAR nx_web_http_server_weekday; /* Weekday */ } NX_WEB_HTTP_SERVER_DATE; +/* Define the nonce structure. */ + +typedef struct NX_WEB_HTTP_SERVER_NONCE_STRUCT +{ + UINT nonce_state; /* The state of the nonce */ + ULONG nonce_timestamp; /* The time when the nonce is created */ + NX_TCP_SESSION *nonce_session_ptr; /* The session accepted with this nonce */ + UCHAR nonce_buffer[NX_WEB_HTTP_SERVER_NONCE_SIZE]; /* Nonce for digest authetication */ +} NX_WEB_HTTP_SERVER_NONCE; + /* Define the multipart context data structure. */ typedef struct NX_WEB_HTTP_SERVER_MULTIPART_STRUCT @@ -290,6 +321,9 @@ typedef struct NX_WEB_HTTP_SERVER_STRUCT #ifdef NX_WEB_HTTP_DIGEST_ENABLE NX_MD5 nx_web_http_server_md5data; /* HTTP server MD5 work area */ + NX_WEB_HTTP_SERVER_NONCE + nx_web_http_server_nonces[NX_WEB_HTTP_SERVER_NONCE_MAX]; + /* Nonce for digest authetication */ #endif /* NX_WEB_HTTP_DIGEST_ENABLE */ #ifdef NX_WEB_HTTP_MULTIPART_ENABLE @@ -566,7 +600,6 @@ UINT _nx_web_http_server_authentication_check_set(NX_WEB_HTTP_SERVER *htt /* Define internal HTTP Server functions. */ -VOID _nx_web_http_server_connection_present(NX_TCP_SOCKET *socket_ptr, UINT port); UINT _nx_web_http_server_get_client_request(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET **packet_ptr); VOID _nx_web_http_server_get_process(NX_WEB_HTTP_SERVER *server_ptr, UINT request_type, NX_PACKET *packet_ptr); VOID _nx_web_http_server_put_process(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr); @@ -591,8 +624,9 @@ VOID _nx_web_http_server_connection_disconnect(NX_WEB_HTTP_SERVER *server #ifdef NX_WEB_HTTP_DIGEST_ENABLE UINT _nx_web_http_server_digest_authenticate(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *name_ptr, CHAR *password_ptr, CHAR *realm_ptr, UINT *auth_request_present); VOID _nx_web_http_server_digest_response_calculate(NX_WEB_HTTP_SERVER *server_ptr, CHAR *username, CHAR *realm, CHAR *password, CHAR *nonce, CHAR *method, CHAR *uri, CHAR *nc, CHAR *cnonce, CHAR *result); -UINT _nx_web_http_server_retrieve_digest_authorization(NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce); +UINT _nx_web_http_server_retrieve_digest_authorization(NX_WEB_HTTP_SERVER *server_ptr, NX_PACKET *packet_ptr, CHAR *response, CHAR *uri, CHAR *nc, CHAR *cnonce, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr); VOID _nx_web_http_server_hex_ascii_convert(CHAR *source, UINT source_length, CHAR *destination); +UINT _nx_web_http_server_nonce_allocate(NX_WEB_HTTP_SERVER *server_ptr, NX_WEB_HTTP_SERVER_NONCE **nonce_ptr); #endif #ifdef NX_WEB_HTTP_MULTIPART_ENABLE diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h index b35f6d4c..213bdcd1 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_const.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* nx_crypto_const.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -50,6 +50,9 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), added */ /* x25519 and x448 curves, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* EC curve type macro, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -213,6 +216,11 @@ extern "C" { #define NX_CRYPTO_EC_POINT_ANSIX962_COMPRESSED_PRIME 1 #define NX_CRYPTO_EC_POINT_ANSIX962_COMPRESSED_CHAR2 2 +/* Elliptic curve type definitions. */ +#define NX_CRYPTO_EC_CURVE_TYPE_EXPLICIT_PRIME 1 +#define NX_CRYPTO_EC_CURVE_TYPE_EXPLICIT_CHAR2 2 +#define NX_CRYPTO_EC_CURVE_TYPE_NAMED_CURVE 3 + /* Define crypto ICV bits size. */ #define NX_CRYPTO_AUTHENTICATION_ICV_TRUNC_BITS 96 diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h index aea5c89c..0a372cb9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/inc/nx_crypto_ec.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_crypto_ec.h PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -50,6 +50,9 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), */ /* added x25519 curve, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* added x448 curve, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ @@ -632,12 +635,14 @@ UINT _nx_crypto_method_ec_secp521r1_operation(UINT op, #ifdef NX_CRYPTO_ENABLE_CURVE25519_448 extern NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519; +extern NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x448; + VOID _nx_crypto_ec_cswap(UINT swap, NX_CRYPTO_HUGE_NUMBER *h1, NX_CRYPTO_HUGE_NUMBER *h2); -VOID _nx_crypto_ec_x25519_multiple(NX_CRYPTO_EC *curve, - NX_CRYPTO_EC_POINT *u, - NX_CRYPTO_HUGE_NUMBER *k, - NX_CRYPTO_EC_POINT *r, - HN_UBASE *scratch); +VOID _nx_crypto_ec_x25519_448_multiple(NX_CRYPTO_EC *curve, + NX_CRYPTO_EC_POINT *u, + NX_CRYPTO_HUGE_NUMBER *k, + NX_CRYPTO_EC_POINT *r, + HN_UBASE *scratch); UINT _nx_crypto_method_ec_x25519_operation(UINT op, VOID *handle, struct NX_CRYPTO_METHOD_STRUCT *method, @@ -648,11 +653,21 @@ UINT _nx_crypto_method_ec_x25519_operation(UINT op, VOID *crypto_metadata, ULONG crypto_metadata_size, VOID *packet_ptr, VOID (*nx_crypto_hw_process_callback)(VOID *, UINT)); -UINT _nx_crypto_ec_key_pair_generation_x25519(NX_CRYPTO_EC *curve, - NX_CRYPTO_EC_POINT *g, - NX_CRYPTO_HUGE_NUMBER *private_key, - NX_CRYPTO_EC_POINT *public_key, - HN_UBASE *scratch); +UINT _nx_crypto_method_ec_x448_operation(UINT op, + VOID *handle, + struct NX_CRYPTO_METHOD_STRUCT *method, + UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, + UCHAR *input, ULONG input_length_in_byte, + UCHAR *iv_ptr, + UCHAR *output, ULONG output_length_in_byte, + VOID *crypto_metadata, ULONG crypto_metadata_size, + VOID *packet_ptr, + VOID (*nx_crypto_hw_process_callback)(VOID *, UINT)); +UINT _nx_crypto_ec_key_pair_generation_x25519_448(NX_CRYPTO_EC *curve, + NX_CRYPTO_EC_POINT *g, + NX_CRYPTO_HUGE_NUMBER *private_key, + NX_CRYPTO_EC_POINT *public_key, + HN_UBASE *scratch); UINT _nx_crypto_ec_extract_fixed_size_le(NX_CRYPTO_HUGE_NUMBER *number, UCHAR *byte_stream, UINT byte_stream_size); #endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c index 371022e3..16b4ae9f 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_aes.c @@ -2167,7 +2167,7 @@ UINT status; /* FUNCTION RELEASE */ /* */ /* _nx_crypto_method_aes_ccm_operation PORTABLE C */ -/* 6.1 */ +/* 6.x */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -2215,6 +2215,9 @@ UINT status; /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* xx-xx-xxxx Tiejun Zhou Modified comment(s), and */ +/* fixed compiler warnings, */ +/* resulting in version 6.x */ /* */ /**************************************************************************/ NX_CRYPTO_KEEP UINT _nx_crypto_method_aes_ccm_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ @@ -2278,7 +2281,7 @@ UINT status; break; } - if (input_length_in_byte < (method -> nx_crypto_ICV_size_in_bits >> 3) || + if (input_length_in_byte < (ULONG)(method -> nx_crypto_ICV_size_in_bits >> 3) || output_length_in_byte < input_length_in_byte - (method -> nx_crypto_ICV_size_in_bits >> 3)) { status = NX_CRYPTO_INVALID_BUFFER_SIZE; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c index cdd90127..530b777e 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ec.c @@ -4402,6 +4402,36 @@ static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x25519_h[] = HN_ULONG_TO_UBASE(0x00000008) }; +/* x448 */ +static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x448_p[] = +{ + + /* p = ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff */ + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF), + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF), + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF), + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFE), + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF), + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF), + HN_ULONG_TO_UBASE(0xFFFFFFFF), HN_ULONG_TO_UBASE(0xFFFFFFFF), +}; + +static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x448_gx[] = +{ + + /* U(P) = 5 */ + HN_ULONG_TO_UBASE(0x00000005) +}; + + +static NX_CRYPTO_CONST HN_UBASE _nx_crypto_ec_x448_h[] = +{ + + /* h = 04 */ + HN_ULONG_TO_UBASE(0x00000004) +}; + + NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519 = { "x25519", @@ -4440,23 +4470,67 @@ NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519 = (NX_CRYPTO_EC_FIXED_POINTS *)NX_CRYPTO_NULL, NX_CRYPTO_NULL, NX_CRYPTO_NULL, - _nx_crypto_ec_x25519_multiple, + _nx_crypto_ec_x25519_448_multiple, + NX_CRYPTO_NULL +}; + +NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x448 = +{ + "x448", + NX_CRYPTO_EC_X448, + 5, + 448, + { + .fp = + { + (HN_UBASE *)_nx_crypto_ec_x448_p, + sizeof(_nx_crypto_ec_x448_p) >> HN_SIZE_SHIFT, + sizeof(_nx_crypto_ec_x448_p), + (UINT)NX_CRYPTO_FALSE + } + }, + {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u}, + {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u}, + { + NX_CRYPTO_EC_POINT_AFFINE, + { + (HN_UBASE *)_nx_crypto_ec_x448_gx, + sizeof(_nx_crypto_ec_x448_gx) >> HN_SIZE_SHIFT, + sizeof(_nx_crypto_ec_x448_gx), + (UINT)NX_CRYPTO_FALSE + }, + {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u}, + {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u} + }, + {(HN_UBASE *)NX_CRYPTO_NULL, 0u, 0u, 0u}, + { + (HN_UBASE *)_nx_crypto_ec_x448_h, + sizeof(_nx_crypto_ec_x448_h) >> HN_SIZE_SHIFT, + sizeof(_nx_crypto_ec_x448_h), + (UINT)NX_CRYPTO_FALSE + }, + (NX_CRYPTO_EC_FIXED_POINTS *)NX_CRYPTO_NULL, + NX_CRYPTO_NULL, + NX_CRYPTO_NULL, + _nx_crypto_ec_x25519_448_multiple, NX_CRYPTO_NULL }; + /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ -/* _nx_crypto_ec_x25519_multiple PORTABLE C */ -/* 6.1.11 */ +/* _nx_crypto_ec_x25519_448_multiple PORTABLE C */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ -/* This function performs the scalar multiplication on X25519 curve. */ +/* This function performs the scalar multiplication on X25519 and X448 */ +/* curves. */ /* */ /* INPUT */ /* */ @@ -4494,13 +4568,16 @@ NX_CRYPTO_CONST NX_CRYPTO_EC _nx_crypto_ec_x25519 = /* DATE NAME DESCRIPTION */ /* */ /* 04-25-2022 Yuxin Zhou Initial Version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* added x448 curve, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ -NX_CRYPTO_KEEP VOID _nx_crypto_ec_x25519_multiple(NX_CRYPTO_EC* curve, - NX_CRYPTO_EC_POINT* u, - NX_CRYPTO_HUGE_NUMBER* k, - NX_CRYPTO_EC_POINT* r, - HN_UBASE* scratch) +NX_CRYPTO_KEEP VOID _nx_crypto_ec_x25519_448_multiple(NX_CRYPTO_EC* curve, + NX_CRYPTO_EC_POINT* u, + NX_CRYPTO_HUGE_NUMBER* k, + NX_CRYPTO_EC_POINT* r, + HN_UBASE* scratch) { NX_CRYPTO_HUGE_NUMBER k_2; NX_CRYPTO_HUGE_NUMBER x_1; @@ -4513,33 +4590,55 @@ NX_CRYPTO_HUGE_NUMBER t_2; INT t; UINT k_t; UINT swap; +UINT clen; +ULONG a24; HN_UBASE* k_buf; + clen = (curve -> nx_crypto_ec_bits + 7) >> 3; - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&k_2, scratch, 32); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_1, scratch, 32); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_2, scratch, 64); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_2, scratch, 64); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_3, scratch, 64); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_3, scratch, 64); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_1, scratch, 64); - NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_2, scratch, 64); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&k_2, scratch, clen); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_1, scratch, clen); + clen = clen << 1; + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_2, scratch, clen); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_2, scratch, clen); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&x_3, scratch, clen); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&z_3, scratch, clen); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_1, scratch, clen); + NX_CRYPTO_HUGE_NUMBER_INITIALIZE(&t_2, scratch, clen); NX_CRYPTO_HUGE_NUMBER_COPY(&k_2, k); NX_CRYPTO_HUGE_NUMBER_COPY(&x_1, &u -> nx_crypto_ec_point_x); - x_1.nx_crypto_huge_number_data[7] &= 0x7FFFFFFF; + + if (curve -> nx_crypto_ec_id == NX_CRYPTO_EC_X25519) + { + /* x25519 */ + x_1.nx_crypto_huge_number_data[7] &= 0x7FFFFFFF; + + k_buf = k_2.nx_crypto_huge_number_data; + + k_buf[0] &= 0xFFFFFFF8; + k_buf[7] &= 0x7FFFFFFF; + k_buf[7] |= 0x40000000; + a24 = 121665; + } + else + { + /* x448 */ + + k_buf = k_2.nx_crypto_huge_number_data; + + k_buf[0] &= 0xFFFFFFFC; + k_buf[13] |= 0x80000000; + a24 = 39081; + } + NX_CRYPTO_HUGE_NUMBER_SET_DIGIT(&x_2, 1); NX_CRYPTO_HUGE_NUMBER_COPY(&x_3, &x_1); NX_CRYPTO_HUGE_NUMBER_SET_DIGIT(&z_3, 1); - k_buf = k_2.nx_crypto_huge_number_data; - - k_buf[0] &= 0xFFFFFFF8; - k_buf[7] &= 0x7FFFFFFF; - k_buf[7] |= 0x40000000; swap = 0; - for (t = 254; t >= 0; t--) + for (t = (INT)(curve -> nx_crypto_ec_bits - 1); t >= 0; t--) { k_t = 1 & (k_buf[t >> 5] >> (t & 31)); swap ^= k_t; @@ -4550,6 +4649,7 @@ HN_UBASE* k_buf; /* A = x_2 + z_2 */ NX_CRYPTO_HUGE_NUMBER_COPY(&t_1, &x_2); _nx_crypto_huge_number_add(&t_1, &z_2); + _nx_crypto_huge_number_modulus(&t_1, &curve->nx_crypto_ec_field.fp); /* B = x_2 - z_2 */ _nx_crypto_huge_number_subtract(&x_2, &z_2); @@ -4572,6 +4672,7 @@ HN_UBASE* k_buf; /* t_2 = DA + CB */ NX_CRYPTO_HUGE_NUMBER_COPY(&t_2, &z_2); _nx_crypto_huge_number_add(&t_2, &z_3); + _nx_crypto_huge_number_modulus(&t_2, &curve->nx_crypto_ec_field.fp); /* z_3 = DA - CB */ _nx_crypto_huge_number_subtract(&z_3, &z_2); @@ -4605,7 +4706,7 @@ HN_UBASE* k_buf; _nx_crypto_huge_number_modulus(&x_2, &curve -> nx_crypto_ec_field.fp); /* z_2 = E * (AA + a24 * E) */ - _nx_crypto_huge_number_multiply_digit(&t_2, 121665, &t_1); + _nx_crypto_huge_number_multiply_digit(&t_2, a24, &t_1); _nx_crypto_huge_number_add(&t_1, &z_2); _nx_crypto_huge_number_modulus(&t_1, &curve -> nx_crypto_ec_field.fp); @@ -4656,7 +4757,7 @@ HN_UBASE* k_buf; /* */ /* CALLED BY */ /* */ -/* _nx_crypto_ec_x25519_multiple Scalar multiplication */ +/* _nx_crypto_ec_x25519_448_multiple Scalar multiplication */ /* */ /* RELEASE HISTORY */ /* */ @@ -4779,8 +4880,93 @@ NX_CRYPTO_KEEP UINT _nx_crypto_method_ec_x25519_operation(UINT op, /* */ /* FUNCTION RELEASE */ /* */ -/* _nx_crypto_ec_key_pair_generation_x25519 PORTABLE C */ -/* 6.1.11 */ +/* _nx_crypto_method_ec_x448_operation PORTABLE C */ +/* 6.1.12 */ +/* AUTHOR */ +/* */ +/* Yuxin Zhou, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This function returns the x448 curve. */ +/* */ +/* INPUT */ +/* */ +/* op Operation */ +/* handle Crypto handle */ +/* method Cryption Method Object */ +/* key Encryption Key */ +/* key_size_in_bits Key size in bits */ +/* input Input data */ +/* input_length_in_byte Input data size */ +/* iv_ptr Initial vector */ +/* output Output buffer */ +/* output_length_in_byte Output buffer size */ +/* crypto_metadata Metadata area */ +/* crypto_metadata_size Metadata area size */ +/* packet_ptr Pointer to packet */ +/* nx_crypto_hw_process_callback Callback function pointer */ +/* */ +/* OUTPUT */ +/* */ +/* status Completion status */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 07-29-2022 Yuxin Zhou Initial Version 6.1.12 */ +/* */ +/**************************************************************************/ +NX_CRYPTO_KEEP UINT _nx_crypto_method_ec_x448_operation(UINT op, + VOID *handle, + struct NX_CRYPTO_METHOD_STRUCT *method, + UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, + UCHAR *input, ULONG input_length_in_byte, + UCHAR *iv_ptr, + UCHAR *output, ULONG output_length_in_byte, + VOID *crypto_metadata, ULONG crypto_metadata_size, + VOID *packet_ptr, + VOID (*nx_crypto_hw_process_callback)(VOID *, UINT)) +{ + NX_CRYPTO_PARAMETER_NOT_USED(handle); + NX_CRYPTO_PARAMETER_NOT_USED(method); + NX_CRYPTO_PARAMETER_NOT_USED(key); + NX_CRYPTO_PARAMETER_NOT_USED(key_size_in_bits); + NX_CRYPTO_PARAMETER_NOT_USED(input); + NX_CRYPTO_PARAMETER_NOT_USED(input_length_in_byte); + NX_CRYPTO_PARAMETER_NOT_USED(iv_ptr); + NX_CRYPTO_PARAMETER_NOT_USED(output); + NX_CRYPTO_PARAMETER_NOT_USED(output_length_in_byte); + NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata); + NX_CRYPTO_PARAMETER_NOT_USED(crypto_metadata_size); + NX_CRYPTO_PARAMETER_NOT_USED(packet_ptr); + NX_CRYPTO_PARAMETER_NOT_USED(nx_crypto_hw_process_callback); + + if (op != NX_CRYPTO_EC_CURVE_GET) + { + return(NX_CRYPTO_NOT_SUCCESSFUL); + } + + *((NX_CRYPTO_EC **)output) = (NX_CRYPTO_EC *)&_nx_crypto_ec_x448; + + return(NX_CRYPTO_SUCCESS); +} + +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* _nx_crypto_ec_key_pair_generation_x25519_448 PORTABLE C */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -4815,13 +5001,16 @@ NX_CRYPTO_KEEP UINT _nx_crypto_method_ec_x25519_operation(UINT op, /* DATE NAME DESCRIPTION */ /* */ /* 04-25-2022 Yuxin Zhou Initial Version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* added x448 curve, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ -NX_CRYPTO_KEEP UINT _nx_crypto_ec_key_pair_generation_x25519(NX_CRYPTO_EC *curve, - NX_CRYPTO_EC_POINT *g, - NX_CRYPTO_HUGE_NUMBER *private_key, - NX_CRYPTO_EC_POINT *public_key, - HN_UBASE *scratch) +NX_CRYPTO_KEEP UINT _nx_crypto_ec_key_pair_generation_x25519_448(NX_CRYPTO_EC *curve, + NX_CRYPTO_EC_POINT *g, + NX_CRYPTO_HUGE_NUMBER *private_key, + NX_CRYPTO_EC_POINT *public_key, + HN_UBASE *scratch) { UINT status; UINT buffer_size = (curve -> nx_crypto_ec_bits + 7) >> 3; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c index 38ccdef6..36826cde 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_ecdh.c @@ -968,7 +968,7 @@ NX_CRYPTO_EC *curve; /* FUNCTION RELEASE */ /* */ /* _nx_crypto_ecdh_setup_x25519_448 PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ @@ -1012,6 +1012,9 @@ NX_CRYPTO_EC *curve; /* DATE NAME DESCRIPTION */ /* */ /* 04-25-2022 Yuxin Zhou Initial Version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* added x448 curve, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ NX_CRYPTO_KEEP UINT _nx_crypto_ecdh_setup_x25519_448(NX_CRYPTO_ECDH *ecdh_ptr, @@ -1051,8 +1054,8 @@ NX_CRYPTO_EC_POINT public_key; sizeof(ecdh_ptr -> nx_crypto_ecdh_private_key_buffer)); /* Generate Key Pair. */ - status = _nx_crypto_ec_key_pair_generation_x25519(curve, &curve -> nx_crypto_ec_g, &private_key, - &public_key, scratch_buf_ptr); + status = _nx_crypto_ec_key_pair_generation_x25519_448(curve, &curve -> nx_crypto_ec_g, &private_key, + &public_key, scratch_buf_ptr); if (status) { return(status); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c index b253ce8e..730c0dfb 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_generic_ciphersuites.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* nx_crypto_generic_ciphersuites PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -69,6 +69,11 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), added */ /* x25519 and x448 curves, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* added x448 curves, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -94,6 +99,7 @@ extern NX_CRYPTO_METHOD crypto_method_ec_secp256; extern NX_CRYPTO_METHOD crypto_method_ec_secp384; extern NX_CRYPTO_METHOD crypto_method_ec_secp521; extern NX_CRYPTO_METHOD crypto_method_ec_x25519; +extern NX_CRYPTO_METHOD crypto_method_ec_x448; extern NX_CRYPTO_METHOD crypto_method_md5; extern NX_CRYPTO_METHOD crypto_method_sha1; extern NX_CRYPTO_METHOD crypto_method_sha224; @@ -111,6 +117,7 @@ extern NX_CRYPTO_METHOD crypto_method_hmac; /* Ciphersuite table without ECC. */ /* Lookup table used to map ciphersuites to cryptographic routines. */ +/* For TLS Web servers, define NX_SECURE_ENABLE_AEAD_CIPHER to allow web browsers to connect using AES_128_GCM cipher suites. */ NX_SECURE_TLS_CIPHERSUITE_INFO _nx_crypto_ciphersuite_lookup_table[] = { /* Ciphersuite, public cipher, public_auth, session cipher & cipher mode, iv size, key size, hash method, hash size, TLS PRF */ @@ -214,6 +221,7 @@ const UINT _nx_crypto_ciphersuite_lookup_table_tls_1_3_size = sizeof(_nx_crypto_ /* Ciphersuite table with ECC. */ /* Lookup table used to map ciphersuites to cryptographic routines. */ /* Ciphersuites are negotiated IN ORDER - top priority first. Ciphersuites lower in the list are considered less secure. */ +/* For TLS Web servers, define NX_SECURE_ENABLE_AEAD_CIPHER to allow web browsers to connect using AES_128_GCM cipher suites. */ NX_SECURE_TLS_CIPHERSUITE_INFO _nx_crypto_ciphersuite_lookup_table_ecc[] = { /* Ciphersuite, public cipher, public_auth, session cipher & cipher mode, iv size, key size, hash method, hash size, TLS PRF */ @@ -290,6 +298,7 @@ const USHORT nx_crypto_ecc_supported_groups[] = (USHORT)NX_CRYPTO_EC_SECP256R1, #ifdef NX_CRYPTO_ENABLE_CURVE25519_448 (USHORT)NX_CRYPTO_EC_X25519, + (USHORT)NX_CRYPTO_EC_X448, #endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */ (USHORT)NX_CRYPTO_EC_SECP384R1, (USHORT)NX_CRYPTO_EC_SECP521R1, @@ -300,6 +309,7 @@ const NX_CRYPTO_METHOD *nx_crypto_ecc_curves[] = &crypto_method_ec_secp256, #ifdef NX_CRYPTO_ENABLE_CURVE25519_448 &crypto_method_ec_x25519, + &crypto_method_ec_x448, #endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */ &crypto_method_ec_secp384, &crypto_method_ec_secp521, @@ -610,6 +620,7 @@ const NX_CRYPTO_METHOD *supported_crypto[] = &crypto_method_ec_secp256, #ifdef NX_CRYPTO_ENABLE_CURVE25519_448 &crypto_method_ec_x25519, + &crypto_method_ec_x448, #endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */ &crypto_method_ec_secp384, &crypto_method_ec_secp521, diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c index 0aa7dc79..bd3731ad 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/crypto_libraries/src/nx_crypto_methods.c @@ -51,7 +51,7 @@ /* FUNCTION RELEASE */ /* */ /* nx_crypto_methods PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -91,6 +91,9 @@ /* obsolete DES/3DES, */ /* added x25519 curve, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* added x448 curve, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ @@ -533,6 +536,21 @@ NX_CRYPTO_METHOD crypto_method_ec_x25519 = NX_CRYPTO_NULL, /* Cleanup routine, not used. */ _nx_crypto_method_ec_x25519_operation, /* Operation */ }; + +/* Declare a placeholder for EC x448. */ +NX_CRYPTO_METHOD crypto_method_ec_x448 = +{ + NX_CRYPTO_EC_X448, /* EC placeholder */ + 448, /* Key size in bits */ + 0, /* IV size in bits */ + 0, /* ICV size in bits, not used. */ + 0, /* Block size in bytes. */ + 0, /* Metadata size in bytes */ + NX_CRYPTO_NULL, /* Initialization routine. */ + NX_CRYPTO_NULL, /* Cleanup routine, not used. */ + _nx_crypto_method_ec_x448_operation, /* Operation */ +}; + #endif /* NX_CRYPTO_ENABLE_CURVE25519_448 */ /* Declare the public NULL cipher (not to be confused with the NULL methods above). This diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h index 858267de..419690bd 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* nx_secure_tls.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -85,6 +85,22 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), and */ /* enabled AEAD for TLS 1.3, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* updated product constants, */ +/* fixed compiler errors when */ +/* TX_SAFETY_CRITICAL is */ +/* enabled, increased default */ +/* pre-master sec size for PSK,*/ +/* updated alert message for */ +/* downgrade protection, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), and added*/ +/* custom secret generation, */ +/* fixed renegotiation when */ +/* receiving in non-block mode,*/ +/* added function to set packet*/ +/* pool, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -105,11 +121,14 @@ extern "C" { #endif /* Include the ThreadX and port-specific data type file. */ +#include "tx_port.h" #ifdef NX_SECURE_SOURCE_CODE +#ifndef TX_SAFETY_CRITICAL #ifndef TX_DISABLE_ERROR_CHECKING #define TX_DISABLE_ERROR_CHECKING #endif +#endif #ifndef NX_DISABLE_ERROR_CHECKING #define NX_DISABLE_ERROR_CHECKING #endif @@ -144,8 +163,8 @@ extern "C" { #define AZURE_RTOS_NETX_SECURE #define NETX_SECURE_MAJOR_VERSION 6 -#define NETX_SECURE_MINOR_VERSION 1 -#define NETX_SECURE_PATCH_VERSION 11 +#define NETX_SECURE_MINOR_VERSION 2 +#define NETX_SECURE_PATCH_VERSION 0 /* The following symbols are defined for backward compatibility reasons. */ #define EL_PRODUCT_NETX_SECURE @@ -289,6 +308,7 @@ extern "C" { #define NX_SECURE_TLS_RECORD_OVERFLOW 0x151 /* Received a TLSCiphertext record that had a length too long. */ #define NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED 0x152 /* Received a fragmented handshake message - take appropriate action at a higher level of the state machine. */ #define NX_SECURE_TLS_TRANSMIT_LOCKED 0x153 /* Another thread is transmitting. */ +#define NX_SECURE_TLS_DOWNGRADE_DETECTED 0x154 /* Detected an inappropriate TLS version downgrade by TLS 1.3 client. */ /* NX_CONTINUE is a symbol defined in NetX Duo 5.10. For backward compatibility, this symbol is defined here */ #if ((__NETXDUO_MAJOR_VERSION__ == 5) && (__NETXDUO_MINOR_VERSION__ == 9)) @@ -648,17 +668,11 @@ typedef struct NX_SECURE_VERSIONS_LIST_STRUCT #define NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENT_FINISHED (3) #define NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED (4) -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE -#ifndef NX_SECURE_TLS_PREMASTER_SIZE -#define NX_SECURE_TLS_PREMASTER_SIZE (68) /* The pre-master secret should be at least 66 bytes for ECDH/ECDHE with secp521r1. */ -#endif -#else /* !NX_SECURE_ENABLE_ECC_CIPHERSUITE */ -#ifndef NX_SECURE_TLS_PREMASTER_SIZE -#define NX_SECURE_TLS_PREMASTER_SIZE (48) /* The pre-master secret is 48 bytes, except for PSK ciphersuites for which it may be more. */ -#endif -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ #define NX_SECURE_TLS_RSA_PREMASTER_SIZE (48) /* The size of RSA encrypted pre-master secret. */ +#define NX_SECURE_TLS_EC_PREMASTER_SIZE (68) /* The size of pre-master secret for EC. */ +#ifndef NX_SECURE_TLS_MASTER_SIZE #define NX_SECURE_TLS_MASTER_SIZE (48) /* The master secret is also 48 bytes. */ +#endif #define NX_SECURE_TLS_MAX_KEY_SIZE (32) /* Maximum size of a session key in bytes. */ #define NX_SECURE_TLS_MAX_IV_SIZE (16) /* Maximum size of a session initialization vector in bytes. */ #define NX_SECURE_TLS_SESSION_ID_SIZE (256) /* Maximum size of a session ID value used for renegotiation in bytes. */ @@ -699,7 +713,9 @@ typedef struct NX_SECURE_VERSIONS_LIST_STRUCT * get the actual key values. We need to size the key material according to the maximum amount of * key material needed by any of the supported ciphersuites, times 2 because there are separate keys for * client and server. */ +#ifndef NX_SECURE_TLS_KEY_MATERIAL_SIZE #define NX_SECURE_TLS_KEY_MATERIAL_SIZE (2 * (NX_SECURE_TLS_MAX_HASH_SIZE + NX_SECURE_TLS_MAX_KEY_SIZE + NX_SECURE_TLS_MAX_IV_SIZE)) +#endif /* PSK-specific defines. If PSK is disabled, don't bring PSK types into the build. */ #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || (NX_SECURE_TLS_TLS_1_3_ENABLED) @@ -722,6 +738,9 @@ typedef struct NX_SECURE_VERSIONS_LIST_STRUCT #define NX_SECURE_TLS_MAX_PSK_NONCE_SIZE (255) #endif +/* The pre-master secret size should be at least (2 * NX_SECURE_TLS_MAX_PSK_SIZE + 4) bytes for PSK cipher suites. */ +#define NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK (2 * NX_SECURE_TLS_MAX_PSK_SIZE + 4) + /* This structure holds the data for Pre-Shared Keys (PSKs) for use with the TLS PSK ciphersuites. The actual keys are generated from this data as part of the TLS handshake, but the user must provide this seed and @@ -777,6 +796,28 @@ typedef struct NX_SECURE_TLS_PSK_STORE_STRUCT #endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) */ +#ifndef NX_SECURE_TLS_PREMASTER_SIZE + +#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE +#define NX_SECURE_TLS_MIN_PREMASTER_SIZE NX_SECURE_TLS_EC_PREMASTER_SIZE /* The pre-master secret should be at least 66 bytes for ECDH/ECDHE with secp521r1. */ +#else +#define NX_SECURE_TLS_MIN_PREMASTER_SIZE NX_SECURE_TLS_RSA_PREMASTER_SIZE /* The pre-master secret should be at least 48 bytes. */ +#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ + +#if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) + +#if NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK > NX_SECURE_TLS_MIN_PREMASTER_SIZE +#define NX_SECURE_TLS_PREMASTER_SIZE NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK /* The pre-master secret should be at least NX_SECURE_TLS_MIN_PREMASTER_SIZE_PSK bytes for PSK cipher suites. */ +#else +#define NX_SECURE_TLS_PREMASTER_SIZE NX_SECURE_TLS_MIN_PREMASTER_SIZE +#endif + +#else +#define NX_SECURE_TLS_PREMASTER_SIZE NX_SECURE_TLS_MIN_PREMASTER_SIZE +#endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || (NX_SECURE_TLS_TLS_1_3_ENABLED) */ + +#endif + /* TLS Ciphersuite lookup table. Contains all pertinent information for ciphersuites used in TLS operations. * The lookup is based on the first field, which will contain the defined TLS value for the ciphersuite. */ typedef struct NX_SECURE_TLS_CIPHERSUITE_INFO_STRUCT @@ -834,13 +875,13 @@ typedef struct NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA_STRUCT USHORT nx_secure_tls_ecdhe_private_key_length; /* Private key for ECDHE. */ - UCHAR nx_secure_tls_ecdhe_private_key[NX_SECURE_TLS_PREMASTER_SIZE]; + UCHAR nx_secure_tls_ecdhe_private_key[NX_SECURE_TLS_EC_PREMASTER_SIZE]; /* Length of the public key. */ USHORT nx_secure_tls_ecdhe_public_key_length; /* Public key for ECDHE. */ - UCHAR nx_secure_tls_ecdhe_public_key[4 * NX_SECURE_TLS_PREMASTER_SIZE]; + UCHAR nx_secure_tls_ecdhe_public_key[4 * NX_SECURE_TLS_EC_PREMASTER_SIZE]; } NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA; @@ -1232,6 +1273,9 @@ typedef struct NX_SECURE_TLS_SESSION_STRUCT /* Flag to enable/disable session renegotiation at application's choosing. */ USHORT nx_secure_tls_renegotation_enabled; + + /* Flag to indicate that the local host initiated the renegotiation. */ + USHORT nx_secure_tls_local_initiated_renegotiation; #endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ #ifndef NX_SECURE_TLS_SERVER_DISABLED @@ -1339,6 +1383,54 @@ typedef struct NX_SECURE_TLS_SESSION_STRUCT UINT nx_secure_tls_signature_algorithm; #endif + + /* Functions that can be replaced to implement custom key generation. */ + UINT (*nx_secure_generate_premaster_secret)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT session_type, USHORT *received_remote_credentials, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, VOID *tls_ecc_curves); + UINT (*nx_secure_generate_master_secret)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, + const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + UCHAR *pre_master_sec, UINT pre_master_sec_size, UCHAR *master_sec, + VOID *prf_metadata, ULONG prf_metadata_size); + UINT (*nx_secure_generate_session_keys)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, + const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + UCHAR *master_sec, VOID *prf_metadata, ULONG prf_metadata_size); + UINT (*nx_secure_session_keys_set)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + UINT key_material_data_size, UINT is_client, UCHAR *session_cipher_initialized, + VOID *session_cipher_metadata, VOID **session_cipher_handler, ULONG session_cipher_metadata_size); +#ifndef NX_SECURE_TLS_CLIENT_DISABLED + UINT(*nx_secure_process_server_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_CRYPTO *tls_crypto_table, + USHORT protocol_version, UCHAR *packet_buffer, UINT message_length, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves); + UINT(*nx_secure_generate_client_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size); +#endif +#ifndef NX_SECURE_TLS_SERVER_DISABLED + UINT(*nx_secure_process_client_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, + UCHAR *packet_buffer, UINT message_length, USHORT *received_remote_credentials, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves); + UINT(*nx_secure_generate_server_key_exchange)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3, + NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves); +#endif + UINT (*nx_secure_verify_mac)(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, UCHAR *mac_secret, ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE], + UCHAR *header_data, USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length, + VOID *hash_mac_metadata, ULONG hash_mac_metadata_size); + UINT (*nx_secure_remote_certificate_verify)(NX_SECURE_X509_CERTIFICATE_STORE *store, + NX_SECURE_X509_CERT *certificate, ULONG current_time); + UINT (*nx_secure_trusted_certificate_add)(NX_SECURE_X509_CERTIFICATE_STORE *store, + NX_SECURE_X509_CERT *certificate); } NX_SECURE_TLS_SESSION; /* TLS record types. */ @@ -1421,11 +1513,11 @@ UINT _nx_secure_tls_handshake_hash_init(NX_SECURE_TLS_SESSION *tls_session); UINT _nx_secure_tls_handshake_hash_update(NX_SECURE_TLS_SESSION *tls_session, UCHAR *data, UINT length); UINT _nx_secure_tls_handshake_process(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option); -UINT _nx_secure_tls_hash_record(NX_SECURE_TLS_SESSION *tls_session, +UINT _nx_secure_tls_hash_record(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE], UCHAR *header, UINT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT length, UCHAR *record_hash, UINT *hash_length, - UCHAR *mac_secret); + UCHAR *mac_secret, VOID *metadata, ULONG metadata_size); UINT _nx_secure_tls_key_material_init(NX_SECURE_TLS_KEY_MATERIAL *key_material); VOID _nx_secure_tls_map_error_to_alert(UINT error_number, UINT *alert_number, UINT *alert_level); @@ -1534,10 +1626,15 @@ UINT _nx_secure_tls_session_receive_records(NX_SECURE_TLS_SESSION *tls_session, UINT _nx_secure_tls_verify_mac(NX_SECURE_TLS_SESSION *tls_session, UCHAR *header_data, USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length); #ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE -UINT _nx_secure_tls_ecc_generate_keys(NX_SECURE_TLS_SESSION *tls_session, UINT ecc_named_curve, USHORT sign_key, - UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data); -UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_SESSION *tls_session, - USHORT named_curve, const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority); +UINT _nx_secure_tls_ecc_generate_keys(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3, + NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash, + NX_SECURE_TLS_ECC *tls_ecc_curves, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT ecc_named_curve, USHORT sign_key, + UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size); +UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_ECC *tls_ecc, USHORT named_curve, + const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority); UINT _nx_secure_tls_proc_clienthello_sec_sa_extension(NX_SECURE_TLS_SESSION *tls_session, NX_SECURE_TLS_HELLO_EXTENSION *exts, UINT num_extensions, @@ -1607,6 +1704,8 @@ UINT _nx_secure_tls_session_delete(NX_SECURE_TLS_SESSION *tls_session); UINT _nx_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option); UINT _nx_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr, UCHAR *buffer_ptr, ULONG buffer_size); +UINT _nx_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session, + NX_PACKET_POOL *packet_pool); UINT _nx_secure_tls_session_protocol_version_override(NX_SECURE_TLS_SESSION *tls_session, USHORT protocol_version); UINT _nx_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr, @@ -1640,7 +1739,7 @@ UINT _nx_secure_tls_packet_allocate(NX_SECURE_TLS_SESSION *tls_session, NX_PACKE #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) UINT _nx_secure_tls_psk_add(NX_SECURE_TLS_SESSION *tls_session, UCHAR *pre_shared_key, UINT psk_length, UCHAR *psk_identity, UINT identity_length, UCHAR *hint, UINT hint_length); -UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_SESSION *tls_session, UCHAR **psk_data, UINT *psk_length, +UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_CREDENTIALS *tls_credentials, UCHAR **psk_data, UINT *psk_length, UCHAR *psk_identity_hint, UINT identity_length, UINT *psk_store_index); UINT _nx_secure_tls_client_psk_set(NX_SECURE_TLS_SESSION *tls_session, UCHAR *pre_shared_key, UINT psk_length, UCHAR *psk_identity, UINT identity_length, UCHAR *hint, UINT hint_length); @@ -1699,6 +1798,8 @@ UINT _nxe_secure_tls_session_delete(NX_SECURE_TLS_SESSION *tls_session); UINT _nxe_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option); UINT _nxe_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr, UCHAR *buffer_ptr, ULONG buffer_size); +UINT _nxe_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session, + NX_PACKET_POOL *packet_pool); UINT _nxe_secure_tls_session_protocol_version_override(NX_SECURE_TLS_SESSION *tls_session, USHORT protocol_version); UINT _nxe_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr, @@ -1738,6 +1839,52 @@ UINT _nxe_secure_tls_client_psk_set(NX_SECURE_TLS_SESSION *tls_session, UCHAR *p UCHAR *psk_identity, UINT identity_length, UCHAR *hint, UINT hint_length); #endif +UINT _nx_secure_process_server_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_CRYPTO *tls_crypto_table, + USHORT protocol_version, UCHAR *packet_buffer, UINT message_length, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves); +UINT _nx_secure_process_client_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, + UCHAR *packet_buffer, UINT message_length, USHORT *received_remote_credentials, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves); +UINT _nx_secure_generate_premaster_secret(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT session_type, USHORT *received_remote_credentials, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, VOID *tls_ecc_curves); +UINT _nx_secure_generate_client_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size); +UINT _nx_secure_generate_server_key_exchange(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3, + NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash, + NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, NX_SECURE_TLS_CREDENTIALS *tls_credentials, + UCHAR *data_buffer, ULONG buffer_length, ULONG *output_size, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size, VOID *tls_ecc_curves); +UINT _nx_secure_generate_master_secret(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, + const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + UCHAR *pre_master_sec, UINT pre_master_sec_size, UCHAR *master_sec, + VOID *prf_metadata, ULONG prf_metadata_size); +UINT _nx_secure_generate_session_keys(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, + const NX_CRYPTO_METHOD *session_prf_method, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + UCHAR *master_sec, VOID *prf_metadata, ULONG prf_metadata_size); +UINT _nx_secure_session_keys_set(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + UINT key_material_data_size, UINT is_client, UCHAR *session_cipher_initialized, + VOID *session_cipher_metadata, VOID **session_cipher_handler, ULONG session_cipher_metadata_size); +UINT _nx_secure_verify_mac(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, UCHAR *mac_secret, ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE], + UCHAR *header_data, USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length, + VOID *hash_mac_metadata, ULONG hash_mac_metadata_size); +UINT _nx_secure_remote_certificate_verify(NX_SECURE_X509_CERTIFICATE_STORE *store, + NX_SECURE_X509_CERT *certificate, ULONG current_time); +UINT _nx_secure_trusted_certificate_add(NX_SECURE_X509_CERTIFICATE_STORE *store, + NX_SECURE_X509_CERT *certificate); +#ifdef NX_SECURE_CUSTOM_SECRET_GENERATION +UINT nx_secure_custom_secret_generation_init(NX_SECURE_TLS_SESSION *tls_session); +#endif + /* TLS component data declarations follow. */ /* Determine if the initialization function of this component is including diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h index ab180e1b..0aa62ca0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_tls_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_secure_tls_api.h PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -44,6 +44,9 @@ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), and added*/ +/* API to set packet pool, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -94,6 +97,7 @@ extern "C" { #define nx_secure_tls_session_delete _nx_secure_tls_session_delete #define nx_secure_tls_session_end _nx_secure_tls_session_end #define nx_secure_tls_session_packet_buffer_set _nx_secure_tls_session_packet_buffer_set +#define nx_secure_tls_session_packet_pool_set _nx_secure_tls_session_packet_pool_set #define nx_secure_tls_session_protocol_version_override _nx_secure_tls_session_protocol_version_override #define nx_secure_tls_session_receive _nx_secure_tls_session_receive #define nx_secure_tls_session_renegotiate _nx_secure_tls_session_renegotiate @@ -136,6 +140,7 @@ extern "C" { #define nx_secure_tls_session_delete _nxe_secure_tls_session_delete #define nx_secure_tls_session_end _nxe_secure_tls_session_end #define nx_secure_tls_session_packet_buffer_set _nxe_secure_tls_session_packet_buffer_set +#define nx_secure_tls_session_packet_pool_set _nxe_secure_tls_session_packet_pool_set #define nx_secure_tls_session_protocol_version_override _nxe_secure_tls_session_protocol_version_override #define nx_secure_tls_session_receive _nxe_secure_tls_session_receive #define nx_secure_tls_session_renegotiate _nxe_secure_tls_session_renegotiate @@ -218,6 +223,8 @@ UINT nx_secure_tls_session_delete(NX_SECURE_TLS_SESSION *tls_session); UINT nx_secure_tls_session_end(NX_SECURE_TLS_SESSION *tls_session, UINT wait_option); UINT nx_secure_tls_session_packet_buffer_set(NX_SECURE_TLS_SESSION *session_ptr, UCHAR *buffer_ptr, ULONG buffer_size); +UINT nx_secure_tls_session_packet_pool_set(NX_SECURE_TLS_SESSION *tls_session, + NX_PACKET_POOL *packet_pool); UINT nx_secure_tls_session_protocol_version_override(NX_SECURE_TLS_SESSION *tls_session, USHORT protocol_version); UINT nx_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr, diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h index 36712225..7b1c66d6 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_user_sample.h @@ -26,7 +26,7 @@ /* PORT SPECIFIC C INFORMATION RELEASE */ /* */ /* nx_secure_user.h PORTABLE C */ -/* 6.1.9 */ +/* 6.2.0 */ /* */ /* AUTHOR */ /* */ @@ -55,6 +55,9 @@ /* initiated renegotiation for */ /* TLS server instances, */ /* resulting in version 6.1.9 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* macro to custom secret size,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -259,12 +262,24 @@ #define NX_SECURE_TLS_MINIMUM_MESSAGE_BUFFER_SIZE 4000 */ -/* NX_SECURE_TLS_PREMASTER_SIZE defines the sie of pre-master secret. +/* NX_SECURE_TLS_PREMASTER_SIZE defines the size of pre-master secret. The default value is 48. */ /* #define NX_SECURE_TLS_PREMASTER_SIZE 48 */ +/* NX_SECURE_TLS_MASTER_SIZE defines the size of master secret. + The default value is 48. */ +/* + #define NX_SECURE_TLS_MASTER_SIZE 48 +*/ + +/* NX_SECURE_TLS_KEY_MATERIAL_SIZE defines the size of key material. + The default value is (2 * (NX_SECURE_TLS_MAX_HASH_SIZE + NX_SECURE_TLS_MAX_KEY_SIZE + NX_SECURE_TLS_MAX_IV_SIZE)). */ +/* + #define NX_SECURE_TLS_KEY_MATERIAL_SIZE (2 * (NX_SECURE_TLS_MAX_HASH_SIZE + NX_SECURE_TLS_MAX_KEY_SIZE + NX_SECURE_TLS_MAX_IV_SIZE)) +*/ + /* NX_SECURE_TLS_CLIENT_DISABLED disables TLS server. By default TLS server is enabled. */ /* #define NX_SECURE_TLS_SERVER_DISABLED @@ -300,8 +315,14 @@ vulnerability. */ /* #define NX_SECURE_TLS_DISABLE_CLIENT_INITIATED_RENEGOTIATION - */ +*/ +/* NX_SECURE_CUSTOM_SECRET_GENERATION enables the user to pass pointers of customized secret generation functions to + TLS in the user defined nx_secure_custom_secret_generation_init function. This will allow TLS to use customized + secret generation functions. */ +/* + #define NX_SECURE_CUSTOM_SECRET_GENERATION +*/ /* NX_SECURE_X509_DISABLE_CRL disables X509 Certificate Revocation List check. By default this feature is enabled. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h index 1825dd60..a0189ed8 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/inc/nx_secure_x509.h @@ -26,7 +26,7 @@ /* COMPONENT DEFINITION RELEASE */ /* */ /* nx_secure_x509.h PORTABLE C */ -/* 6.1.10 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -55,6 +55,10 @@ /* ignored public key in EC */ /* private key, */ /* resulting in version 6.1.10 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* checked expiration for all */ +/* the certs in the chain, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ @@ -936,7 +940,7 @@ UINT _nx_secure_x509_certificate_verify(NX_SECURE_X509_CERTIFICATE_STORE *store, /* Verify a given certificate chain to see if the end-entity certificate can be traced through the chain to a trust anchor. */ UINT _nx_secure_x509_certificate_chain_verify(NX_SECURE_X509_CERTIFICATE_STORE *store, - NX_SECURE_X509_CERT *certificate); + NX_SECURE_X509_CERT *certificate, ULONG current_time); /* Parse an OID string, returning an internally-used constant (defined above) for use in other parsing. */ VOID _nx_secure_x509_oid_parse(const UCHAR *oid, ULONG length, UINT *oid_value); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h index 8d4237a1..32b23984 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/ports/nx_secure_port.h @@ -69,7 +69,7 @@ #ifdef NX_SECURE_SYSTEM_INIT CHAR _nx_secure_version_id[] = - "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Secure Generic Version G6.1.11 *"; + "Copyright (c) Microsoft Corporation. All rights reserved. * NetX Secure Generic Version G6.2.0 *"; #else extern CHAR _nx_secure_version_id[]; #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c index 8d7697e7..54bc4595 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_client_handshake.c @@ -32,7 +32,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_dtls_client_handshake PORTABLE C */ -/* 6.1.10 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -72,7 +72,6 @@ /* _nx_secure_tls_generate_premaster_secret */ /* Generate premaster secret */ /* _nx_secure_tls_handshake_hash_update Update Finished hash */ -/* _nx_secure_tls_map_error_to_alert Map internal error to alert */ /* _nx_secure_tls_process_certificate_request */ /* Process certificate request */ /* _nx_secure_tls_process_finished Process Finished message */ @@ -81,7 +80,6 @@ /* _nx_secure_tls_process_server_key_exchange */ /* Process ServerKeyExchange */ /* _nx_secure_tls_process_serverhello Process ServerHello */ -/* _nx_secure_tls_send_alert Send DTLS alert */ /* _nx_secure_tls_send_certificate Send DTLS certificate */ /* _nx_secure_tls_send_certificate_verify */ /* Send certificate verify */ @@ -118,6 +116,9 @@ /* 01-31-2022 Timothy Stapko Modified comment(s), */ /* fixed out-of-order handling,*/ /* resulting in version 6.1.10 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* removed duplicated alert, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_dtls_client_handshake(NX_SECURE_DTLS_SESSION *dtls_session, UCHAR *packet_buffer, @@ -131,9 +132,6 @@ UINT message_length; UCHAR *data_start = NX_NULL; NX_PACKET *send_packet = NX_NULL; NX_PACKET_POOL *packet_pool; -UINT error_number; -UINT alert_number; -UINT alert_level; UINT message_seq; UINT fragment_offset; UINT fragment_length; @@ -362,24 +360,8 @@ NX_SECURE_TLS_SESSION *tls_session; /* Check for errors in processing messages. */ if (status != NX_SECURE_TLS_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - } - return(error_number); + return(status); } /* Now take any actions based on state set in the message processing. */ @@ -593,29 +575,11 @@ NX_SECURE_TLS_SESSION *tls_session; } /* If we have an error at this point, we have experienced a problem in sending - handshake messages, which is some type of internal issue. Send an alert - back to the remote host indicating the error. */ + handshake messages, which is some type of internal issue. */ if (status != NX_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - } - - return(error_number); + return(status); } /* Advance the buffer pointer past the fragment. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c index 24fd00ae..d3cc68b0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_send_record.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_dtls_send_record PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -86,6 +86,9 @@ /* verified memcpy use cases, */ /* released packet securely, */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* checked seq number overflow,*/ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_dtls_send_record(NX_SECURE_DTLS_SESSION *dtls_session, NX_PACKET *send_packet, @@ -169,6 +172,14 @@ UCHAR epoch_seq_num[8]; { /* Check for overflow of the 32-bit number. */ tls_session -> nx_secure_tls_local_sequence_number[1]++; + + if (tls_session -> nx_secure_tls_local_sequence_number[1] == 0) + { + + /* Check for overflow of the 64-bit unsigned number. As it should not reach here + in practical, we return a general error to prevent overflow theoretically. */ + return(NX_NOT_SUCCESSFUL); + } } tls_session -> nx_secure_tls_local_sequence_number[0]++; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c index 2c7fe168..b1f2482d 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_server_handshake.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_dtls_server_handshake PORTABLE C */ -/* 6.1.10 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -73,11 +73,9 @@ /* _nx_secure_tls_generate_keys Generate session keys */ /* _nx_secure_tls_handshake_hash_init Initialize Finished hash */ /* _nx_secure_tls_handshake_hash_update Update Finished hash */ -/* _nx_secure_tls_map_error_to_alert Map internal error to alert */ /* _nx_secure_tls_process_client_key_exchange */ /* Process key exchange */ /* _nx_secure_tls_process_finished Process Finished message */ -/* _nx_secure_tls_send_alert Send TLS alert */ /* _nx_secure_tls_send_certificate Send TLS certificate */ /* _nx_secure_tls_send_changecipherspec Send ChangeCipherSpec */ /* _nx_secure_tls_send_finished Send Finished message */ @@ -118,6 +116,9 @@ /* 01-31-2022 Timothy Stapko Modified comment(s), */ /* fixed out-of-order handling,*/ /* resulting in version 6.1.10 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* removed duplicated alert, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_dtls_server_handshake(NX_SECURE_DTLS_SESSION *dtls_session, UCHAR *packet_buffer, @@ -135,10 +136,7 @@ NX_PACKET *send_packet; NX_PACKET_POOL *packet_pool; UCHAR *packet_start; NX_SECURE_TLS_SESSION *tls_session; -UINT error_number; -UINT alert_number; -UINT alert_level; -UCHAR *fragment_buffer; +UCHAR *fragment_buffer; /* Basic state machine for handshake: @@ -361,22 +359,8 @@ UCHAR *fragment_buffer; /* Check for errors in processing messages. */ if (status != NX_SECURE_TLS_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - - _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - return(error_number); + return(status); } /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them, @@ -619,32 +603,6 @@ UCHAR *fragment_buffer; } - /* If we have an error at this point, we have experienced a problem in sending - handshake messages, which is some type of internal issue. Send an alert - back to the remote host indicating the error. */ - if (status != NX_SUCCESS) - { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_dtls_packet_allocate(dtls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - _nx_secure_dtls_send_record(dtls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - } - - return(error_number); - } - return(status); #else /* TLS Server disabled. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c index 1f35e4b0..c9bafa71 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_cache.c @@ -30,7 +30,7 @@ /* FUNCTION RELEASE */ /* */ /* nx_secure_dtls_session_cache_delete PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -66,6 +66,10 @@ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* fixed compiler errors when */ +/* IPv4 is disabled, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID nx_secure_dtls_session_cache_delete(NX_SECURE_DTLS_SERVER *dtls_server, NXD_ADDRESS *ip_address, UINT remote_port, UINT local_port) @@ -95,6 +99,7 @@ UINT i; { continue; } +#ifndef NX_DISABLE_IPV4 if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4) { if (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != @@ -103,13 +108,18 @@ UINT i; continue; } } +#endif /* !NX_DISABLE_IPV4 */ + #ifdef FEATURE_NX_IPV6 - else if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) || - (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) || - (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) || - (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3])) + if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6) { - continue; + if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) || + (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) || + (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) || + (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3])) + { + continue; + } } #endif /* FEATURE_NX_IPV6 */ @@ -225,7 +235,7 @@ UINT i; /* FUNCTION RELEASE */ /* */ /* nx_secure_dtls_session_cache_find PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -263,6 +273,10 @@ UINT i; /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* fixed compiler errors when */ +/* IPv4 is disabled, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT nx_secure_dtls_session_cache_find(NX_SECURE_DTLS_SERVER *dtls_server, NX_SECURE_DTLS_SESSION **dtls_session, NXD_ADDRESS *ip_address, UINT remote_port, UINT local_port) @@ -301,6 +315,7 @@ UINT i; } /* Check actual remote IP address value. */ +#ifndef NX_DISABLE_IPV4 if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4) { if (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 == @@ -315,19 +330,24 @@ UINT i; return(NX_SUCCESS); } } +#endif /* !NX_DISABLE_IPV4 */ + #ifdef FEATURE_NX_IPV6 - else if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] == ip_address -> nxd_ip_address.v6[0]) && - (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] == ip_address -> nxd_ip_address.v6[1]) && - (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] == ip_address -> nxd_ip_address.v6[2]) && - (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] == ip_address -> nxd_ip_address.v6[3])) + if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6) { + if ((session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] == ip_address -> nxd_ip_address.v6[0]) && + (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] == ip_address -> nxd_ip_address.v6[1]) && + (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] == ip_address -> nxd_ip_address.v6[2]) && + (session_array[i].nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] == ip_address -> nxd_ip_address.v6[3])) + { - /* Release the protection. */ - tx_mutex_put(&_nx_secure_tls_protection); + /* Release the protection. */ + tx_mutex_put(&_nx_secure_tls_protection); - /* Return the session. */ - *dtls_session = &session_array[i]; - return(NX_SUCCESS); + /* Return the session. */ + *dtls_session = &session_array[i]; + return(NX_SUCCESS); + } } #endif /* FEATURE_NX_IPV6 */ } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c index 128c454e..b3899282 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_receive.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_dtls_session_receive PORTABLE C */ -/* 6.1.10 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -82,7 +82,11 @@ /* resulting in version 6.1 */ /* 01-31-2022 Timothy Stapko Modified comment(s), */ /* fixed out-of-order handling,*/ -/* resulting in version 6.1.10 */ +/* resulting in version 6.1.10 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* fixed compiler errors when */ +/* IPv4 is disabled, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_dtls_session_receive(NX_SECURE_DTLS_SESSION *dtls_session, @@ -230,6 +234,7 @@ UINT source_port; } else { +#ifndef NX_DISABLE_IPV4 if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == NX_IP_VERSION_V4) { @@ -239,8 +244,10 @@ UINT source_port; status = NX_CONTINUE; } } +#endif /* !NX_DISABLE_IPV4 */ + #ifdef FEATURE_NX_IPV6 - else if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == NX_IP_VERSION_V6) + if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_version == NX_IP_VERSION_V6) { /* Compare the IPv6 address. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c index 07a5837b..01de1eeb 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_dtls_session_send.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_dtls_session_send PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -69,6 +69,10 @@ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* verified memcpy use cases, */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* fixed compiler errors when */ +/* IPv4 is disabled, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_dtls_session_send(NX_SECURE_DTLS_SESSION *dtls_session, NX_PACKET *packet_ptr, @@ -98,32 +102,41 @@ UINT status; /* IP address and port don't match - probably caller error. */ return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH); } - else if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4) + else { - if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != ip_address -> nxd_ip_address.v4) +#ifndef NX_DISABLE_IPV4 + if (ip_address -> nxd_ip_version == NX_IP_VERSION_V4) { + if (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v4 != ip_address -> nxd_ip_address.v4) + { - /* Release the protection. */ - tx_mutex_put(&_nx_secure_tls_protection); + /* Release the protection. */ + tx_mutex_put(&_nx_secure_tls_protection); - /* IP address and port don't match - probably caller error. */ - return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH); + /* IP address and port don't match - probably caller error. */ + return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH); + } } - } -#ifdef FEATURE_NX_IPV6 - else if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) || - (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) || - (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) || - (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3])) - { +#endif /* !NX_DISABLE_IPV4 */ - /* Release the protection. */ - tx_mutex_put(&_nx_secure_tls_protection); - - /* IP address and port don't match - probably caller error. */ - return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH); - } +#ifdef FEATURE_NX_IPV6 + if (ip_address -> nxd_ip_version == NX_IP_VERSION_V6) + { + if ((dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[0] != ip_address -> nxd_ip_address.v6[0]) || + (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[1] != ip_address -> nxd_ip_address.v6[1]) || + (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[2] != ip_address -> nxd_ip_address.v6[2]) || + (dtls_session -> nx_secure_dtls_remote_ip_address.nxd_ip_address.v6[3] != ip_address -> nxd_ip_address.v6[3])) + { + + /* Release the protection. */ + tx_mutex_put(&_nx_secure_tls_protection); + + /* IP address and port don't match - probably caller error. */ + return(NX_SECURE_TLS_SEND_ADDRESS_MISMATCH); + } + } #endif /* FEATURE_NX_IPV6 */ + } status = _nx_secure_dtls_send_record(dtls_session, packet_ptr, NX_SECURE_TLS_APPLICATION_DATA, NX_WAIT_FOREVER); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c index 0c2e7dcd..9e39bd63 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_client_handshake.c @@ -30,7 +30,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_1_3_client_handshake PORTABLE C */ -/* 6.1.4 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -116,6 +116,10 @@ /* support for fragmented TLS */ /* Handshake messages, */ /* resulting in version 6.1.4 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* updated alert message for */ +/* downgrade protection, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ @@ -155,9 +159,6 @@ UINT packet_buffer_length = data_length; UCHAR *packet_start; NX_PACKET *send_packet = NX_NULL; NX_PACKET_POOL *packet_pool; -UINT error_number; -UINT alert_number; -UINT alert_level; const NX_CRYPTO_METHOD *method_ptr = NX_NULL; const UCHAR *server_random; @@ -286,7 +287,7 @@ const UCHAR *server_random; if (NX_SECURE_MEMCMP(&(tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random[24]), server_random, 8) == 0) { - status = NX_SECURE_TLS_UNKNOWN_TLS_VERSION; + status = NX_SECURE_TLS_DOWNGRADE_DETECTED; } else { @@ -387,29 +388,8 @@ const UCHAR *server_random; /* Check for errors in processing messages. */ if (status != NX_SECURE_TLS_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - - if (status != NX_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - } - } - return(error_number); + return(status); } /* Now take any actions based on state set in the message processing. */ @@ -687,34 +667,11 @@ const UCHAR *server_random; } /* If we have an error at this point, we have experienced a problem in sending - handshake messages, which is some type of internal issue. Send an alert - back to the remote host indicating the error. */ + handshake messages, which is some type of internal issue. */ if (status != NX_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - - if (status != NX_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - } - } - - return(error_number); + return(status); } /* Advance the buffer pointer past the message. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c index 49abb961..5f5fa50e 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_crypto_init.c @@ -33,7 +33,7 @@ extern NX_SECURE_TLS_ECC _nx_secure_tls_ecc_info; /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_1_3_crypto_init PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -71,6 +71,9 @@ extern NX_SECURE_TLS_ECC _nx_secure_tls_ecc_info; /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) @@ -103,17 +106,24 @@ NX_SECURE_TLS_ECC *ecc_info; ecdhe_data = &tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i]; /* Save off the curve ID so we can select the server's chosen key/curve later. */ - ecdhe_data->nx_secure_tls_ecdhe_named_curve = ecc_info -> nx_secure_tls_ecc_supported_groups[i]; + ecdhe_data -> nx_secure_tls_ecdhe_named_curve = ecc_info -> nx_secure_tls_ecc_supported_groups[i]; /* Output the public key to our handshake data structure - we need the length of that buffer. */ - length = sizeof(ecdhe_data->nx_secure_tls_ecdhe_public_key); + length = sizeof(ecdhe_data -> nx_secure_tls_ecdhe_public_key); /* Generate ECC keys and store in our TLS session. */ - status = _nx_secure_tls_ecc_generate_keys(tls_session, ecdhe_data -> nx_secure_tls_ecdhe_named_curve, NX_FALSE, - ecdhe_data->nx_secure_tls_ecdhe_public_key, &length, ecdhe_data); + status = _nx_secure_tls_ecc_generate_keys(tls_session -> nx_secure_tls_session_ciphersuite, tls_session -> nx_secure_tls_protocol_version, + tls_session -> nx_secure_tls_1_3, tls_session -> nx_secure_tls_crypto_table, + &tls_session -> nx_secure_tls_handshake_hash, ecc_info, &tls_session -> nx_secure_tls_key_material, + &tls_session -> nx_secure_tls_credentials, ecdhe_data -> nx_secure_tls_ecdhe_named_curve, NX_FALSE, + ecdhe_data -> nx_secure_tls_ecdhe_public_key, &length, ecdhe_data, + tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, + tls_session -> nx_secure_public_auth_metadata_size); /* Set the actual length of the generated key. */ - ecdhe_data->nx_secure_tls_ecdhe_public_key_length = (USHORT)length; + ecdhe_data -> nx_secure_tls_ecdhe_public_key_length = (USHORT)length; if (status != NX_SUCCESS) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c index 03d4aa8b..60aaaeca 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_1_3_server_handshake.c @@ -30,8 +30,8 @@ /* */ /* FUNCTION RELEASE */ /* */ -/* _nx_secure_tls_server_handshake PORTABLE C */ -/* 6.1.4 */ +/* _nx_secure_tls_1_3_server_handshake PORTABLE C */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -59,7 +59,6 @@ /* _nx_secure_tls_generate_keys Generate session keys */ /* _nx_secure_tls_handshake_hash_init Initialize Finished hash */ /* _nx_secure_tls_handshake_hash_update Update Finished hash */ -/* _nx_secure_tls_map_error_to_alert Map internal error to alert */ /* _nx_secure_tls_packet_allocate Allocate internal TLS packet */ /* _nx_secure_tls_process_client_key_exchange */ /* Process ClientKeyExchange */ @@ -69,7 +68,6 @@ /* Process handshake header */ /* _nx_secure_tls_process_remote_certificate */ /* Process server certificate */ -/* _nx_secure_tls_send_alert Send TLS alert */ /* _nx_secure_tls_send_certificate Send TLS certificate */ /* _nx_secure_tls_send_certificate_request */ /* Send TLS CertificateRequest */ @@ -107,6 +105,13 @@ /* support for fragmented TLS */ /* Handshake messages, */ /* resulting in version 6.1.4 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* removed duplicated alert, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* fixed handling of multiple */ +/* handshake messages, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) @@ -121,9 +126,6 @@ UINT message_length; NX_PACKET *send_packet; NX_PACKET_POOL *packet_pool; UCHAR *packet_start; -UINT error_number; -UINT alert_number; -UINT alert_level; NX_SECURE_TLS_SERVER_STATE old_server_state; /* Basic state machine for handshake: @@ -179,242 +181,177 @@ NX_SECURE_TLS_SERVER_STATE old_server_state; client) and provide key confirmation and handshake integrity. */ - - /* Save a pointer to the start of our packet for the hash that happens below. */ - packet_start = packet_buffer; - - header_bytes = data_length; - - status = _nx_secure_tls_process_handshake_header(packet_buffer, &message_type, &header_bytes, &message_length); - - if (status != NX_SECURE_TLS_SUCCESS) + /* Loop through multiple messages in a single record. This can happen if the remote host + packs multiple handshake messages into a single TLS record. */ + while (data_length > 0) { - return(status); - } - /* Check for fragmented message. */ - if((message_length + header_bytes) > data_length) - { - /* Incomplete message! A single message is fragmented across several records. We need to obtain the next fragment. */ - tls_session -> nx_secure_tls_handshake_record_expected_length = message_length + header_bytes; - - tls_session -> nx_secure_tls_handshake_record_fragment_state = NX_SECURE_TLS_HANDSHAKE_RECEIVED_FRAGMENT; + /* Save a pointer to the start of our packet for the hash that happens below. */ + packet_start = packet_buffer; - return(NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED); - } + header_bytes = data_length; - /* Advance the buffer pointer past the handshake header. */ - packet_buffer += header_bytes; + status = _nx_secure_tls_process_handshake_header(packet_buffer, &message_type, &header_bytes, &message_length); - /* Get reference to the packet pool so we can allocate a packet for all send operations. */ - packet_pool = tls_session -> nx_secure_tls_packet_pool; - - /* Process the message itself information from the header. */ - status = NX_SECURE_TLS_SUCCESS; - switch (message_type) - { - case NX_SECURE_TLS_CLIENT_HELLO: - old_server_state = tls_session -> nx_secure_tls_server_state; - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_IDLE; - - /* Client is establishing a TLS session with our server. */ - status = _nx_secure_tls_process_clienthello(tls_session, packet_buffer, message_length); - - if(status != NX_SUCCESS) + if (status != NX_SECURE_TLS_SUCCESS) { - break; - } - - if (tls_session -> nx_secure_tls_1_3 == NX_FALSE) - { - - /* Negotiate a version of TLS prior to TLS 1.3. */ - return(NX_SUCCESS); + return(status); } - if (old_server_state == NX_SECURE_TLS_SERVER_STATE_IDLE) + /* Check for fragmented message. */ + if((message_length + header_bytes) > data_length) { - - /* Initialize the handshake hash - we should have chosen a ciphersuite, so we can - * initialize the hash state now using the chosen hash. */ - _nx_secure_tls_handshake_hash_init(tls_session); - } + /* Incomplete message! A single message is fragmented across several records. We need to obtain the next fragment. */ + tls_session -> nx_secure_tls_handshake_record_expected_length = message_length + header_bytes; - if (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY) - { - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_SEND_HELLO; - } - break; -#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY - case NX_SECURE_TLS_CERTIFICATE_MSG: - /* Client sent certificate message (in response to a request from us. Process it now. */ - status = _nx_secure_tls_process_remote_certificate(tls_session, packet_buffer, message_length, data_length); + tls_session -> nx_secure_tls_handshake_record_fragment_state = NX_SECURE_TLS_HANDSHAKE_RECEIVED_FRAGMENT; - /* If client sends an empty Certificate message, server should abort the handshake with a "certificate_required" alert. */ - if (status == NX_SECURE_TLS_EMPTY_REMOTE_CERTIFICATE_RECEIVED) - { - status = NX_SECURE_TLS_CERTIFICATE_REQUIRED; + return(NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED); } - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE; - break; - case NX_SECURE_TLS_CERTIFICATE_VERIFY: - /* Client has responded to a certificate request with a CertificateVerify message. */ - status = _nx_secure_tls_process_certificate_verify(tls_session, packet_buffer, message_length); + /* Advance the buffer pointer past the handshake header. */ + packet_buffer += header_bytes; - if(status == NX_SUCCESS) - { - /* If remote certificate verification was a success, we have received credentials - from the remote host and may now pass Finished message processing once received. */ - tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; - } + /* Get reference to the packet pool so we can allocate a packet for all send operations. */ + packet_pool = tls_session -> nx_secure_tls_packet_pool; - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY; - break; -#endif /* NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY */ - case NX_SECURE_TLS_FINISHED: + /* Reduce total length by the size of this message. */ + data_length -= (message_length + header_bytes); - /* Save the transcript hash to this point for processing Finished. */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE); - if(status != NX_SUCCESS) + /* Process the message itself information from the header. */ + status = NX_SECURE_TLS_SUCCESS; + switch (message_type) { - break; - } + case NX_SECURE_TLS_CLIENT_HELLO: + old_server_state = tls_session -> nx_secure_tls_server_state; + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_IDLE; - /* Final handshake message from the client, process it (verify the client handshake hash). */ - status = _nx_secure_tls_process_finished(tls_session, packet_buffer, message_length); - if(status != NX_SUCCESS) - { - break; - } + /* Client is establishing a TLS session with our server. */ + status = _nx_secure_tls_process_clienthello(tls_session, packet_buffer, message_length); - /* Save the transcript hash to this point for key generation - Server Finished was processed so save it. */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENT_FINISHED, NX_TRUE); - if(status != NX_SUCCESS) - { - break; - } - - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE; - break; -/* Invalid message types in tls 1.3. - case NX_SECURE_TLS_CLIENT_KEY_EXCHANGE: - case NX_SECURE_TLS_HELLO_VERIFY_REQUEST: - case NX_SECURE_TLS_HELLO_REQUEST: - case NX_SECURE_TLS_SERVER_HELLO: - case NX_SECURE_TLS_SERVER_KEY_EXCHANGE: - case NX_SECURE_TLS_CERTIFICATE_REQUEST: - case NX_SECURE_TLS_SERVER_HELLO_DONE: - case NX_SECURE_TLS_CERTIFICATE_URL: - case NX_SECURE_TLS_CERTIFICATE_STATUS: -*/ - default: - /* The message received was not a valid TLS server handshake message, send alert and return. */ - status = NX_SECURE_TLS_HANDSHAKE_FAILURE; - break; - } - - /* Check for errors in processing messages. */ - if (status != NX_SECURE_TLS_SUCCESS) - { - /* If we encountered an error in message processing set the state to the error condition. */ - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_ERROR; - } - else - { - /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them, - we do not worry about them here because these are only messages received from the client at this point. - Hashes include the handshake layer header but not the record layer header. */ - _nx_secure_tls_handshake_hash_update(tls_session, packet_start, (UINT)(message_length + header_bytes)); - if((message_type == NX_SECURE_TLS_CLIENT_HELLO) && (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY)) - { - /* Save the transcript hash for ClientHello - ClientHello was processed so we now have a ciphersuite and know what - our hash method is. */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENTHELLO, NX_TRUE); if(status != NX_SUCCESS) { - return status; + break; } - } - } - /* Now take any actions based on state set in the message processing. */ - switch (tls_session -> nx_secure_tls_server_state) - { - case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO: - /* We have received and processed a client hello. Now respond to the client appropriately. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + if (tls_session -> nx_secure_tls_1_3 == NX_FALSE) + { - if (status != NX_SUCCESS) - { - break; - } + /* Negotiate a version of TLS prior to TLS 1.3. */ + return(NX_SUCCESS); + } - status = _nx_secure_tls_send_serverhello(tls_session, send_packet); + if (old_server_state == NX_SECURE_TLS_SERVER_STATE_IDLE) + { + + /* Initialize the handshake hash - we should have chosen a ciphersuite, so we can + * initialize the hash state now using the chosen hash. */ + _nx_secure_tls_handshake_hash_init(tls_session); + } - if (status != NX_SUCCESS) - { + if (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY) + { + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_SEND_HELLO; + } break; - } +#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY + case NX_SECURE_TLS_CERTIFICATE_MSG: + /* Client sent certificate message (in response to a request from us. Process it now. */ + status = _nx_secure_tls_process_remote_certificate(tls_session, packet_buffer, message_length, data_length); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option); + /* If client sends an empty Certificate message, server should abort the handshake with a "certificate_required" alert. */ + if (status == NX_SECURE_TLS_EMPTY_REMOTE_CERTIFICATE_RECEIVED) + { + status = NX_SECURE_TLS_CERTIFICATE_REQUIRED; + } - if (status != NX_SUCCESS) - { + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE; break; - } + case NX_SECURE_TLS_CERTIFICATE_VERIFY: + /* Client has responded to a certificate request with a CertificateVerify message. */ + status = _nx_secure_tls_process_certificate_verify(tls_session, packet_buffer, message_length); + if(status == NX_SUCCESS) + { + /* If remote certificate verification was a success, we have received credentials + from the remote host and may now pass Finished message processing once received. */ + tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; + } - /* Save the transcript hash to this point for key generation - ServerHello was sent so use it. */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVERHELLO, NX_TRUE); - if(status != NX_SUCCESS) - { + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY; break; - } - - NX_ASSERT(tls_session -> nx_secure_tls_session_ciphersuite != NX_NULL); - +#endif /* NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY */ + case NX_SECURE_TLS_FINISHED: - /* In TLS 1.3, we now have enough information to generate the handshake encryption keys and start encrypting messages. */ - /* Generate TLS 1.3 keys and secrets for the handshake. */ - status = _nx_secure_tls_1_3_generate_handshake_keys(tls_session); - if(status != NX_SUCCESS) - { - break; - } + /* Save the transcript hash to this point for processing Finished. */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE); + if(status != NX_SUCCESS) + { + break; + } - /* Now turn on encryption. We have generated the handshake keys so the rest of the handshake is encrypted. */ - tls_session -> nx_secure_tls_local_session_active = 1; - tls_session -> nx_secure_tls_remote_session_active = 1; + /* Final handshake message from the client, process it (verify the client handshake hash). */ + status = _nx_secure_tls_process_finished(tls_session, packet_buffer, message_length); + if(status != NX_SUCCESS) + { + break; + } - /* Send encrypted server extensions (if any) here. */ - - /* We have now started the encrypted TLS 1.3 handshake. Send encrypted extensions now. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + /* Save the transcript hash to this point for key generation - Server Finished was processed so save it. */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENT_FINISHED, NX_TRUE); + if(status != NX_SUCCESS) + { + break; + } - if (status != NX_SUCCESS) - { + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE; + break; +/* Invalid message types in tls 1.3. + case NX_SECURE_TLS_CLIENT_KEY_EXCHANGE: + case NX_SECURE_TLS_HELLO_VERIFY_REQUEST: + case NX_SECURE_TLS_HELLO_REQUEST: + case NX_SECURE_TLS_SERVER_HELLO: + case NX_SECURE_TLS_SERVER_KEY_EXCHANGE: + case NX_SECURE_TLS_CERTIFICATE_REQUEST: + case NX_SECURE_TLS_SERVER_HELLO_DONE: + case NX_SECURE_TLS_CERTIFICATE_URL: + case NX_SECURE_TLS_CERTIFICATE_STATUS: +*/ + default: + /* The message received was not a valid TLS server handshake message, send alert and return. */ + status = NX_SECURE_TLS_HANDSHAKE_FAILURE; break; } - status = _nx_secure_tls_send_encrypted_extensions(tls_session, send_packet); - - if (status != NX_SUCCESS) + /* Check for errors in processing messages. */ + if (status != NX_SECURE_TLS_SUCCESS) { - break; + /* If we encountered an error in message processing set the state to the error condition. */ + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_ERROR; } - - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_ENCRYPTED_EXTENSIONS, wait_option); - if (status != NX_SUCCESS) + else { - break; + /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them, + we do not worry about them here because these are only messages received from the client at this point. + Hashes include the handshake layer header but not the record layer header. */ + _nx_secure_tls_handshake_hash_update(tls_session, packet_start, (UINT)(message_length + header_bytes)); + if((message_type == NX_SECURE_TLS_CLIENT_HELLO) && (tls_session -> nx_secure_tls_server_state != NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY)) + { + /* Save the transcript hash for ClientHello - ClientHello was processed so we now have a ciphersuite and know what + our hash method is. */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CLIENTHELLO, NX_TRUE); + if(status != NX_SUCCESS) + { + return status; + } + } } -#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY - /* Application has requested that we request and verify the remote Client certificate. */ - if (tls_session -> nx_secure_tls_verify_client_certificate) + /* Now take any actions based on state set in the message processing. */ + switch (tls_session -> nx_secure_tls_server_state) { - /* Allocate a packet for our certificate request message. */ + case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO: + /* We have received and processed a client hello. Now respond to the client appropriately. */ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); if (status != NX_SUCCESS) @@ -422,52 +359,46 @@ NX_SECURE_TLS_SERVER_STATE old_server_state; break; } - /* Populate our packet with the desired message (CertificateRequest). */ - status = _nx_secure_tls_send_certificate_request(tls_session, send_packet); - NX_ASSERT(status == NX_SUCCESS); + status = _nx_secure_tls_send_serverhello(tls_session, send_packet); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_REQUEST, wait_option); if (status != NX_SUCCESS) { break; } - } - else -#endif - { - /* Server is not expecting credentials, so indicate that we have received the client's credentials - to pass Finished processing. */ - tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; - } -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - /* For PSK ciphersuites, don't send the certificate message. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm != NX_CRYPTO_KEY_EXCHANGE_PSK && - tls_session->nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data_size == 0) - { -#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option); if (status != NX_SUCCESS) { break; } - _nx_secure_tls_send_certificate(tls_session, send_packet, wait_option); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_MSG, wait_option); - if (status != NX_SUCCESS) + + /* Save the transcript hash to this point for key generation - ServerHello was sent so use it. */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVERHELLO, NX_TRUE); + if(status != NX_SUCCESS) { break; } - /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE); + NX_ASSERT(tls_session -> nx_secure_tls_session_ciphersuite != NX_NULL); + + + /* In TLS 1.3, we now have enough information to generate the handshake encryption keys and start encrypting messages. */ + /* Generate TLS 1.3 keys and secrets for the handshake. */ + status = _nx_secure_tls_1_3_generate_handshake_keys(tls_session); if(status != NX_SUCCESS) { break; } + /* Now turn on encryption. We have generated the handshake keys so the rest of the handshake is encrypted. */ + tls_session -> nx_secure_tls_local_session_active = 1; + tls_session -> nx_secure_tls_remote_session_active = 1; + /* Send encrypted server extensions (if any) here. */ + + /* We have now started the encrypted TLS 1.3 handshake. Send encrypted extensions now. */ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); if (status != NX_SUCCESS) @@ -475,170 +406,228 @@ NX_SECURE_TLS_SERVER_STATE old_server_state; break; } - _nx_secure_tls_send_certificate_verify(tls_session, send_packet); + status = _nx_secure_tls_send_encrypted_extensions(tls_session, send_packet); + if (status != NX_SUCCESS) + { + break; + } - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_VERIFY, wait_option); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_ENCRYPTED_EXTENSIONS, wait_option); if (status != NX_SUCCESS) { break; } +#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY + /* Application has requested that we request and verify the remote Client certificate. */ + if (tls_session -> nx_secure_tls_verify_client_certificate) + { + /* Allocate a packet for our certificate request message. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + + if (status != NX_SUCCESS) + { + break; + } + + /* Populate our packet with the desired message (CertificateRequest). */ + status = _nx_secure_tls_send_certificate_request(tls_session, send_packet); + NX_ASSERT(status == NX_SUCCESS); + + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_REQUEST, wait_option); + if (status != NX_SUCCESS) + { + break; + } + } + else +#endif + { + /* Server is not expecting credentials, so indicate that we have received the client's credentials + to pass Finished processing. */ + tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; + } #ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - } -#endif + /* For PSK ciphersuites, don't send the certificate message. */ + if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm != NX_CRYPTO_KEY_EXCHANGE_PSK && + tls_session->nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data_size == 0) + { +#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - /* Save the transcript hash to this point for generating Finished. */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE); - if(status != NX_SUCCESS) - { - break; - } + if (status != NX_SUCCESS) + { + break; + } - /* We have completed sending everything from the server side and generated our session keys, now send the Finished. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - if (status != NX_SUCCESS) - { - break; - } + _nx_secure_tls_send_certificate(tls_session, send_packet, wait_option); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_MSG, wait_option); + if (status != NX_SUCCESS) + { + break; + } - /* Populate the packet with our Finished Message. */ - _nx_secure_tls_send_finished(tls_session, send_packet); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_FINISHED, wait_option); - if(status != NX_SUCCESS) - { - break; - } + /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE); + if(status != NX_SUCCESS) + { + break; + } - /* Save the finished message now - overwrite previous hash. */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE); - if(status != NX_SUCCESS) - { - break; - } - /* Re-generate TLS 1.3 keys and secrets including the Server Finished message for the application data session. */ - status = _nx_secure_tls_1_3_generate_session_keys(tls_session); - if(status != NX_SUCCESS) - { - break; - } + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - /* In TLS 1.3, the server sends everything in a single flight - ServerHello through Finished, so - * no need to go into the other states. */ + if (status != NX_SUCCESS) + { + break; + } - /* Now switch to the session keys for our local session since we have sent the Server Finished message. */ - status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_LOCAL); - if(status != NX_SUCCESS) - { - break; - } + _nx_secure_tls_send_certificate_verify(tls_session, send_packet); - /* We still need to process the Client responses - certificate (if needed), and Finished. */ - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_SENT; - break; - case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY: - /* We have received and processed a client hello retry requst. Now respond to the client appropriately. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_VERIFY, wait_option); + if (status != NX_SUCCESS) + { + break; + } - if (status != NX_SUCCESS) - { - break; - } - status = _nx_secure_tls_send_serverhello(tls_session, send_packet); +#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES + } +#endif - if (status != NX_SUCCESS) - { - break; - } + /* Save the transcript hash to this point for generating Finished. */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE); + if(status != NX_SUCCESS) + { + break; + } + + /* We have completed sending everything from the server side and generated our session keys, now send the Finished. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + if (status != NX_SUCCESS) + { + break; + } + + /* Populate the packet with our Finished Message. */ + _nx_secure_tls_send_finished(tls_session, send_packet); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_FINISHED, wait_option); + if(status != NX_SUCCESS) + { + break; + } + + /* Save the finished message now - overwrite previous hash. */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_SERVER_FINISHED, NX_TRUE); + if(status != NX_SUCCESS) + { + break; + } + + /* Re-generate TLS 1.3 keys and secrets including the Server Finished message for the application data session. */ + status = _nx_secure_tls_1_3_generate_session_keys(tls_session); + if(status != NX_SUCCESS) + { + break; + } + + /* In TLS 1.3, the server sends everything in a single flight - ServerHello through Finished, so + * no need to go into the other states. */ + + /* Now switch to the session keys for our local session since we have sent the Server Finished message. */ + status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_LOCAL); + if(status != NX_SUCCESS) + { + break; + } + + /* We still need to process the Client responses - certificate (if needed), and Finished. */ + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_SENT; - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option); - break; - case NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE: - - /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */ - status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE); - break; - case NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY: - /* We processed the certificate above, do nothing. */ - break; - case NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE: - - /* Now switch to the session keys for our remote session since we have processed the Finished from the Client. */ - status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_REMOTE); - if(status != NX_SUCCESS) - { break; - } + case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY: + /* We have received and processed a client hello retry requst. Now respond to the client appropriately. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - /* Post-Auth server messages (if any) are sent here. */ + if (status != NX_SUCCESS) + { + break; + } - /* For session resumption, send a NewSessionTicket message to allow for resumption PSK to be generated. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - if (status != NX_SUCCESS) - { + status = _nx_secure_tls_send_serverhello(tls_session, send_packet); + + if (status != NX_SUCCESS) + { + break; + } + + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option); break; - } + case NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE: - /* Populate the packet with our NewSessionTicket Message. */ - status = _nx_secure_tls_send_newsessionticket(tls_session, send_packet); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_NEW_SESSION_TICKET, wait_option); - if(status != NX_SUCCESS) - { + /* Save the transcript hash up to the certificate for the CertificateVerify (next message to send). */ + status = _nx_secure_tls_1_3_transcript_hash_save(tls_session, NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE, NX_TRUE); break; - } + case NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY: + /* We processed the certificate above, do nothing. */ + break; + case NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE: - /* If we get here, the Client Finished was processed without errors and the handshake is complete. */ - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED; - break; -/* case NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE: // tls 1.3: No CLIENT_KEY_EXCHANGE message! - */ - default: /* NX_SECURE_TLS_SERVER_STATE_ERROR */ - /* Default is to break out of the switch because either we encountered an error or - we are in an invalid state. DO NOT change the value of "status" here because - we need its value in the alert processing below. NOTE: we should never - get to this branch with status == NX_SUCCESS because the state will only - be set to NX_SECURE_TLS_SERVER_STATE_ERROR if status indicates an error. */ - NX_ASSERT(status != NX_SUCCESS); - break; - } - - - /* If we have an error at this point, we have experienced a problem in processing or sending - handshake messages, which is some type of internal issue. Send an alert - back to the remote host indicating the error. */ - if (status != NX_SUCCESS) - { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); + /* Now switch to the session keys for our remote session since we have processed the Finished from the Client. */ + status = _nx_secure_tls_1_3_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_REMOTE); + if(status != NX_SUCCESS) + { + break; + } - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); + /* Post-Auth server messages (if any) are sent here. */ - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); + /* For session resumption, send a NewSessionTicket message to allow for resumption PSK to be generated. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + if (status != NX_SUCCESS) + { + break; + } + + /* Populate the packet with our NewSessionTicket Message. */ + status = _nx_secure_tls_send_newsessionticket(tls_session, send_packet); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_NEW_SESSION_TICKET, wait_option); + if(status != NX_SUCCESS) + { + break; + } - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); + /* If we get here, the Client Finished was processed without errors and the handshake is complete. */ + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED; + break; +/* case NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE: // tls 1.3: No CLIENT_KEY_EXCHANGE message! + */ + default: /* NX_SECURE_TLS_SERVER_STATE_ERROR */ + /* Default is to break out of the switch because either we encountered an error or + we are in an invalid state. DO NOT change the value of "status" here because + we need its value in the alert processing below. NOTE: we should never + get to this branch with status == NX_SUCCESS because the state will only + be set to NX_SECURE_TLS_SERVER_STATE_ERROR if status indicates an error. */ + NX_ASSERT(status != NX_SUCCESS); + break; + } - if (status == NX_SUCCESS) + /* If we have an error at this point, we have experienced a problem in sending + handshake messages, which is some type of internal issue. */ + if (status != NX_SUCCESS) { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - if (status != NX_SECURE_TLS_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - } + return(status); } - return(error_number); - } + /* Advance the buffer pointer past the message. */ + packet_buffer += message_length; + } /* End while. */ - return(status); + return(NX_SUCCESS); #else /* TLS Server disabled. */ /* We don't use the parameters since this is an error case. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c index 58c7b97b..46832915 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_client_handshake.c @@ -30,7 +30,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_client_handshake PORTABLE C */ -/* 6.1.5 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -60,7 +60,6 @@ /* _nx_secure_tls_generate_premaster_secret */ /* Generate premaster secret */ /* _nx_secure_tls_handshake_hash_update Update Finished hash */ -/* _nx_secure_tls_map_error_to_alert Map internal error to alert */ /* _nx_secure_tls_packet_allocate Allocate internal TLS packet */ /* _nx_secure_tls_process_certificate_request */ /* Process certificate request */ @@ -74,7 +73,6 @@ /* _nx_secure_tls_process_serverhello Process ServerHello */ /* _nx_secure_tls_remote_certificate_free_all */ /* Free all remote certificates */ -/* _nx_secure_tls_send_alert Send TLS alert */ /* _nx_secure_tls_send_certificate Send TLS certificate */ /* _nx_secure_tls_send_certificate_verify */ /* Send certificate verify */ @@ -118,6 +116,9 @@ /* 03-02-2021 Timothy Stapko Modified comment(s), */ /* fixed compiler warnings, */ /* resulting in version 6.1.5 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* removed duplicated alert, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_client_handshake(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, @@ -133,9 +134,6 @@ UINT packet_buffer_length = data_length; UCHAR *packet_start; NX_PACKET *send_packet = NX_NULL; NX_PACKET_POOL *packet_pool; -UINT error_number; -UINT alert_number; -UINT alert_level; const NX_CRYPTO_METHOD *method_ptr = NX_NULL; @@ -311,29 +309,8 @@ const NX_CRYPTO_METHOD /* Check for errors in processing messages. */ if (status != NX_SECURE_TLS_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - - if (status != NX_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - } - } - return(error_number); + return(status); } /* Now take any actions based on state set in the message processing. */ @@ -594,34 +571,11 @@ const NX_CRYPTO_METHOD } /* If we have an error at this point, we have experienced a problem in sending - handshake messages, which is some type of internal issue. Send an alert - back to the remote host indicating the error. */ + handshake messages, which is some type of internal issue. */ if (status != NX_SUCCESS) { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); - - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) - { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - - if (status != NX_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - } - } - - return(error_number); + return(status); } /* Advance the buffer pointer past the message. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c index 9472a06e..5d2e1e23 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_ecc_generate_keys.c @@ -47,7 +47,7 @@ static const UCHAR _NX_CRYPTO_DER_OID_SHA_512[] = {0x30, 0x51, 0x30, 0x0d, /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_ecc_generate_keys PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -68,12 +68,23 @@ static const UCHAR _NX_CRYPTO_DER_OID_SHA_512[] = {0x30, 0x51, 0x30, 0x0d, /* */ /* INPUT */ /* */ -/* tls_session TLS control block */ +/* ciphersuite Selected cipher suite */ +/* protocol_version Selected TLS version */ +/* tls_1_3 Whether TLS 1.3 is chosen */ +/* tls_crypto_table TLS crypto methods */ +/* tls_handshake_hash Metadata for handshake hash */ +/* tls_ecc_curves ECC curves */ +/* tls_key_material TLS key material */ +/* tls_credentials TLS credentials */ /* ecc_named_curve IANA ECC curve identifier */ /* sign_key True/False generate signature */ /* public_key Signed ECC public key */ /* public_key_size Size of public key */ /* ecc_data ECC data (incl. private key) */ +/* public_cipher_metadata Metadata for public cipher */ +/* public_cipher_metadata_size Size of public cipher metadata*/ +/* public_auth_metadata Metadata for public auth */ +/* public_auth_metadata_size Size of public auth metadata */ /* */ /* OUTPUT */ /* */ @@ -99,10 +110,18 @@ static const UCHAR _NX_CRYPTO_DER_OID_SHA_512[] = {0x30, 0x51, 0x30, 0x0d, /* 04-25-2022 Yuxin Zhou Modified comment(s), removed */ /* internal unreachable logic, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ -UINT _nx_secure_tls_ecc_generate_keys(NX_SECURE_TLS_SESSION *tls_session, UINT ecc_named_curve, USHORT sign_key, - UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data) +UINT _nx_secure_tls_ecc_generate_keys(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, USHORT protocol_version, UCHAR tls_1_3, + NX_SECURE_TLS_CRYPTO *tls_crypto_table, NX_SECURE_TLS_HANDSHAKE_HASH *tls_handshake_hash, + NX_SECURE_TLS_ECC *tls_ecc_curves, NX_SECURE_TLS_KEY_MATERIAL *tls_key_material, + NX_SECURE_TLS_CREDENTIALS *tls_credentials, UINT ecc_named_curve, USHORT sign_key, + UCHAR *public_key, UINT *public_key_size, NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_data, + VOID *public_cipher_metadata, ULONG public_cipher_metadata_size, + VOID *public_auth_metadata, ULONG public_auth_metadata_size) { UINT length; UINT output_size; @@ -125,24 +144,27 @@ NX_SECURE_EC_PRIVATE_KEY *ec_privkey; NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; USHORT signature_algorithm_id; +#if !(NX_SECURE_TLS_TLS_1_0_ENABLED) && !(NX_SECURE_TLS_TLS_1_1_ENABLED) + NX_PARAMETER_NOT_USED(protocol_version); +#endif + +#if !(NX_SECURE_TLS_TLS_1_3_ENABLED) || (!(NX_SECURE_TLS_TLS_1_0_ENABLED) && !(NX_SECURE_TLS_TLS_1_1_ENABLED)) + NX_PARAMETER_NOT_USED(tls_1_3); + NX_PARAMETER_NOT_USED(tls_crypto_table); +#endif + #if (NX_SECURE_TLS_TLS_1_3_ENABLED) - if(tls_session->nx_secure_tls_1_3) + if(tls_1_3) { - ecdhe_method = tls_session->nx_secure_tls_crypto_table->nx_secure_tls_ecdhe_method; + ecdhe_method = tls_crypto_table -> nx_secure_tls_ecdhe_method; } else #endif { - if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) - { - - /* Likely internal error since at this point ciphersuite negotiation was theoretically completed. */ - return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); - } /* Generate ECDHE key pair using ECDHE crypto method. */ - ecdhe_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher; + ecdhe_method = ciphersuite -> nx_secure_tls_public_cipher; } /* Make sure we have a method to use. */ @@ -152,10 +174,10 @@ USHORT signature_algorithm_id; } /* Set the curve we are using. */ - ecc_data->nx_secure_tls_ecdhe_named_curve = ecc_named_curve; + ecc_data -> nx_secure_tls_ecdhe_named_curve = ecc_named_curve; /* Find out which named curve the we are using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)ecc_named_curve, &curve_method, NX_NULL); + status = _nx_secure_tls_find_curve_method(tls_ecc_curves, (USHORT)ecc_named_curve, &curve_method, NX_NULL); if(status != NX_SUCCESS) { return(status); @@ -167,8 +189,8 @@ USHORT signature_algorithm_id; NX_NULL, 0, &handler, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size); + public_cipher_metadata, + public_cipher_metadata_size); if(status != NX_CRYPTO_SUCCESS) { return(status); @@ -179,8 +201,8 @@ USHORT signature_algorithm_id; (NX_CRYPTO_METHOD*)ecdhe_method, NX_NULL, 0, (UCHAR *)curve_method, sizeof(NX_CRYPTO_METHOD *), NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, + public_cipher_metadata, + public_cipher_metadata_size, NX_NULL, NX_NULL); if (status != NX_CRYPTO_SUCCESS) { @@ -194,7 +216,7 @@ USHORT signature_algorithm_id; *public_key_size = 0; #if (NX_SECURE_TLS_TLS_1_3_ENABLED) - if(!tls_session->nx_secure_tls_1_3) + if(!tls_1_3) #endif { /* ECCurveType: named_curve (3). */ @@ -210,7 +232,7 @@ USHORT signature_algorithm_id; /* Generate the key pair and output the public key. */ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) - if(tls_session->nx_secure_tls_1_3) + if(tls_1_3) { extended_output.nx_crypto_extended_output_data = &public_key[length]; extended_output.nx_crypto_extended_output_length_in_byte = output_size - length; @@ -227,8 +249,8 @@ USHORT signature_algorithm_id; NX_NULL, 0, NX_NULL, (UCHAR *)&extended_output, sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, + public_cipher_metadata, + public_cipher_metadata_size, NX_NULL, NX_NULL); if (status != NX_CRYPTO_SUCCESS) { @@ -236,7 +258,7 @@ USHORT signature_algorithm_id; } #if (NX_SECURE_TLS_TLS_1_3_ENABLED) - if(!tls_session->nx_secure_tls_1_3) + if(!tls_1_3) #endif { /* Put the length into the buffer before the key data. */ @@ -257,8 +279,8 @@ USHORT signature_algorithm_id; NX_NULL, 0, NX_NULL, (UCHAR *)&extended_output, sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, + public_cipher_metadata, + public_cipher_metadata_size, NX_NULL, NX_NULL); if (status != NX_CRYPTO_SUCCESS) { @@ -271,7 +293,7 @@ USHORT signature_algorithm_id; /* Cleanup the ECC crypto state. */ if (ecdhe_method -> nx_crypto_cleanup) { - status = ecdhe_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area); + status = ecdhe_method -> nx_crypto_cleanup(public_cipher_metadata); if(status != NX_CRYPTO_SUCCESS) { return(status); @@ -282,14 +304,14 @@ USHORT signature_algorithm_id; if(sign_key == NX_TRUE) { /* Get the local certificate. */ - if (tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate != NX_NULL) + if (tls_credentials -> nx_secure_tls_active_certificate != NX_NULL) { - certificate = tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate; + certificate = tls_credentials -> nx_secure_tls_active_certificate; } else { /* Get reference to local device certificate. NX_NULL is passed for name to get default entry. */ - status = _nx_secure_x509_local_device_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, + status = _nx_secure_x509_local_device_certificate_get(&tls_credentials -> nx_secure_tls_certificate_store, NX_NULL, &certificate); if (status != NX_SUCCESS) { @@ -321,18 +343,18 @@ USHORT signature_algorithm_id; #if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) #ifdef NX_SECURE_ENABLE_DTLS if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)) + (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || + protocol_version == NX_SECURE_DTLS_VERSION_1_0)) #else if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) + (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) #endif /* NX_SECURE_ENABLE_DTLS */ { /* TLS 1.0 and TLS 1.1 use MD5 + SHA1 hash for RSA signatures. */ - hash_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method; + hash_method = tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method; } else #endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ @@ -350,8 +372,8 @@ USHORT signature_algorithm_id; NX_NULL, 0, &handler, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size); + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size); if(status != NX_CRYPTO_SUCCESS) { @@ -371,8 +393,8 @@ USHORT signature_algorithm_id; NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -391,13 +413,13 @@ USHORT signature_algorithm_id; (NX_CRYPTO_METHOD*)hash_method, NX_NULL, 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, + tls_key_material -> nx_secure_tls_client_random, 32, NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -411,13 +433,13 @@ USHORT signature_algorithm_id; (NX_CRYPTO_METHOD*)hash_method, NX_NULL, 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, + tls_key_material -> nx_secure_tls_server_random, 32, NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -436,8 +458,8 @@ USHORT signature_algorithm_id; NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -456,8 +478,8 @@ USHORT signature_algorithm_id; NX_NULL, hash, hash_length, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -468,7 +490,7 @@ USHORT signature_algorithm_id; if (hash_method -> nx_crypto_cleanup) { - status = hash_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch); + status = hash_method -> nx_crypto_cleanup(tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch); if(status != NX_CRYPTO_SUCCESS) { @@ -480,16 +502,16 @@ USHORT signature_algorithm_id; #if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) #ifdef NX_SECURE_ENABLE_DTLS if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)) + (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || + protocol_version == NX_SECURE_DTLS_VERSION_1_0)) #else if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) + (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) #endif /* NX_SECURE_ENABLE_DTLS */ { - hash_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method;; + hash_method = tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method;; /* Calculate the hash: SHA(ClientHello.random + ServerHello.random + ServerKeyExchange.params); */ @@ -499,8 +521,8 @@ USHORT signature_algorithm_id; NX_NULL, 0, &handler, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size); + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size); if(status != NX_CRYPTO_SUCCESS) { @@ -520,8 +542,8 @@ USHORT signature_algorithm_id; NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -540,13 +562,13 @@ USHORT signature_algorithm_id; (NX_CRYPTO_METHOD*)hash_method, NX_NULL, 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, + tls_key_material -> nx_secure_tls_client_random, 32, NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -560,13 +582,13 @@ USHORT signature_algorithm_id; (NX_CRYPTO_METHOD*)hash_method, NX_NULL, 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, + tls_key_material -> nx_secure_tls_server_random, 32, NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -585,8 +607,8 @@ USHORT signature_algorithm_id; NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -605,8 +627,8 @@ USHORT signature_algorithm_id; NX_NULL, &hash[16], hash_method -> nx_crypto_ICV_size_in_bits >> 3, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch, + tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch_size, NX_NULL, NX_NULL); @@ -617,7 +639,7 @@ USHORT signature_algorithm_id; if (hash_method -> nx_crypto_cleanup) { - status = hash_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch); + status = hash_method -> nx_crypto_cleanup(tls_handshake_hash -> nx_secure_tls_handshake_hash_scratch); if(status != NX_CRYPTO_SUCCESS) { @@ -630,12 +652,12 @@ USHORT signature_algorithm_id; #if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) #ifdef NX_SECURE_ENABLE_DTLS - if (tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 && - tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1 && - tls_session -> nx_secure_tls_protocol_version != NX_SECURE_DTLS_VERSION_1_0) + if (protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 && + protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1 && + protocol_version != NX_SECURE_DTLS_VERSION_1_0) #else - if (tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 && - tls_session -> nx_secure_tls_protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1) + if (protocol_version != NX_SECURE_TLS_VERSION_TLS_1_0 && + protocol_version != NX_SECURE_TLS_VERSION_TLS_1_1) #endif /* NX_SECURE_ENABLE_DTLS */ #endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ { @@ -647,7 +669,7 @@ USHORT signature_algorithm_id; } /* Sign the hash. */ - auth_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth; + auth_method = ciphersuite -> nx_secure_tls_public_auth; if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && (auth_method -> nx_crypto_algorithm == NX_CRYPTO_DIGITAL_SIGNATURE_RSA || auth_method -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA)) @@ -662,13 +684,13 @@ USHORT signature_algorithm_id; #if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) #ifdef NX_SECURE_ENABLE_DTLS if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)) + (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || + protocol_version == NX_SECURE_DTLS_VERSION_1_0)) #else if ((ecc_data -> nx_secure_tls_ecdhe_signature_algorithm & 0xFF) == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) + (protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) #endif /* NX_SECURE_ENABLE_DTLS */ { hash_length += hash_method -> nx_crypto_ICV_size_in_bits >> 3; @@ -741,8 +763,8 @@ USHORT signature_algorithm_id; (UCHAR *)certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus, (NX_CRYPTO_KEY_SIZE)(certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus_length << 3), &handler, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size); + public_auth_metadata, + public_auth_metadata_size); if (status != NX_CRYPTO_SUCCESS) { return(status); @@ -761,8 +783,8 @@ USHORT signature_algorithm_id; NX_NULL, &public_key[length], signature_length, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, + public_auth_metadata, + public_auth_metadata_size, NX_NULL, NX_NULL); if (status != NX_CRYPTO_SUCCESS) { @@ -774,7 +796,7 @@ USHORT signature_algorithm_id; if (auth_method -> nx_crypto_cleanup) { - status = auth_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area); + status = auth_method -> nx_crypto_cleanup(public_auth_metadata); if(status != NX_CRYPTO_SUCCESS) { @@ -789,7 +811,7 @@ USHORT signature_algorithm_id; ec_pubkey = &certificate -> nx_secure_x509_public_key.ec_public_key; /* Find out which named curve the local certificate is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); + status = _nx_secure_tls_find_curve_method(tls_ecc_curves, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); if(status != NX_SUCCESS) { return(status); @@ -801,8 +823,8 @@ USHORT signature_algorithm_id; (UCHAR *)ec_pubkey -> nx_secure_ec_public_key, (NX_CRYPTO_KEY_SIZE)(ec_pubkey -> nx_secure_ec_public_key_length << 3), &handler, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size); + public_auth_metadata, + public_auth_metadata_size); if (status != NX_CRYPTO_SUCCESS) { return(status); @@ -817,8 +839,8 @@ USHORT signature_algorithm_id; (NX_CRYPTO_METHOD*)auth_method, NX_NULL, 0, (UCHAR *)curve_method_cert, sizeof(NX_CRYPTO_METHOD *), NX_NULL, NX_NULL, 0, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, + public_auth_metadata, + public_auth_metadata_size, NX_NULL, NX_NULL); if (status != NX_CRYPTO_SUCCESS) { @@ -837,8 +859,8 @@ USHORT signature_algorithm_id; hash_method -> nx_crypto_ICV_size_in_bits >> 3, NX_NULL, (UCHAR *)&extended_output, sizeof(extended_output), - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, + public_auth_metadata, + public_auth_metadata_size, NX_NULL, NX_NULL); if (status != NX_CRYPTO_SUCCESS) { @@ -847,7 +869,7 @@ USHORT signature_algorithm_id; if (auth_method -> nx_crypto_cleanup) { - status = auth_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area); + status = auth_method -> nx_crypto_cleanup(public_auth_metadata); if(status != NX_CRYPTO_SUCCESS) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c index 6618adeb..b1173266 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_find_curve_method.c @@ -31,7 +31,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_find_curve_method PORTABLE C */ -/* 6.1.6 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -87,21 +87,24 @@ /* 04-02-2021 Timothy Stapko Modified comment(s), added */ /* ECC curve table in X509, */ /* resulting in version 6.1.6 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ -UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_SESSION *tls_session, - USHORT named_curve, const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority) +UINT _nx_secure_tls_find_curve_method(NX_SECURE_TLS_ECC *tls_ecc, USHORT named_curve, + const NX_CRYPTO_METHOD **curve_method, UINT *curve_priority) { USHORT i; *curve_method = NX_NULL; /* Find out the curve method for the named curve. */ - for (i = 0; i < tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_supported_groups_count; i++) + for (i = 0; i < tls_ecc -> nx_secure_tls_ecc_supported_groups_count; i++) { - if (named_curve == tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_supported_groups[i]) + if (named_curve == tls_ecc -> nx_secure_tls_ecc_supported_groups[i]) { - *curve_method = tls_session -> nx_secure_tls_ecc.nx_secure_tls_ecc_curves[i]; + *curve_method = tls_ecc -> nx_secure_tls_ecc_curves[i]; /* The index in the supported list is the curve priority: lower value == higher priority. */ if(curve_priority != NX_NULL) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c index 99ec5388..4961b2cb 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_finished_hash_generate.c @@ -136,7 +136,7 @@ UINT hash_size = 0; #endif /* NX_SECURE_ENABLE_DTLS */ { /* Copy over the handshake hash state into scratch space to do the intermediate calculation. */ - NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, + NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, /* lgtm[cpp/banned-api-usage-required-any] */ tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata, tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata_size); /* Use case of memcpy is verified. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c index 6666c335..df5939b6 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_keys.c @@ -27,15 +27,13 @@ #include "nx_secure_dtls.h" #endif /* NX_SECURE_ENABLE_DTLS */ -/* This local static buffer needs to be large enough to hold both the server random and the client random. */ -static UCHAR _nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE + NX_SECURE_TLS_RANDOM_SIZE]; /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_generate_keys PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -57,8 +55,8 @@ static UCHAR _nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE + NX_SECUR /* */ /* CALLS */ /* */ -/* [nx_crypto_init] Initialize crypto */ -/* [nx_crypto_operation] Crypto operation */ +/* [nx_secure_generate_master_secret] Generate master secrets */ +/* [nx_secure_generate_session_keys] Generate session keys */ /* */ /* CALLED BY */ /* */ @@ -75,6 +73,9 @@ static UCHAR _nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE + NX_SECUR /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* verified memcpy use cases, */ /* resulting in version 6.1 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_generate_keys(NX_SECURE_TLS_SESSION *tls_session) @@ -82,27 +83,14 @@ UINT _nx_secure_tls_generate_keys(NX_SECURE_TLS_SESSION *tls_session) UCHAR *pre_master_sec; UINT pre_master_sec_size; UCHAR *master_sec; -UCHAR *key_block; /* Maximum ciphersuite key size - AES_256_CBC_SHA, 2x32 byte keys + 2x20 byte MAC secrets + 2x16 IVs. */ -UINT key_block_size; -UINT key_size; -UINT hash_size; -UINT iv_size; UINT status; -const NX_CRYPTO_METHOD *session_cipher_method = NX_NULL; const NX_CRYPTO_METHOD *session_prf_method = NX_NULL; const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite; -VOID *handler = NX_NULL; /* Generate the session keys using the parameters obtained in the handshake. By this point all the information needed to generate the TLS session key material should have been gathered and stored in the TLS socket structure. */ - key_block_size = 0; - - /* Working pointer into our new key material block since we are generating new keys. */ - key_block = tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data; - - /* Generate the Master Secret from the Pre-Master Secret. From the RFC (TLS 1.1, TLS 1.2): @@ -122,241 +110,60 @@ VOID *handler = NX_NULL; return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); } - /* Get our session cipher method so we can get key sizes. */ - session_cipher_method = ciphersuite -> nx_secure_tls_session_cipher; - - /* The generation of key material is different between RSA and DH. */ - if (ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE - || ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE - || ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - || ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK -#endif -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE - || ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE -#endif - ) - { - pre_master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret; - pre_master_sec_size = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size; - master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_master_secret; + pre_master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret; + pre_master_sec_size = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size; + master_sec = tls_session -> nx_secure_tls_key_material.nx_secure_tls_master_secret; - /* Concatenate random values to feed into PRF. */ - NX_SECURE_MEMCPY(_nx_secure_tls_gen_keys_random, tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, - NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */ - NX_SECURE_MEMCPY(&_nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE], - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */ - /* Generate the master secret using the pre-master secret, the defined TLS label, and the concatenated - random values. */ #if (NX_SECURE_TLS_TLS_1_2_ENABLED) #ifdef NX_SECURE_ENABLE_DTLS - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_2) + if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2 || + tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_2) #else - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2) + if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2) #endif /* NX_SECURE_ENABLE_DTLS */ - { - /* For TLS 1.2, the PRF is defined by the ciphersuite. However, if we are using an older ciphersuite, - * default to the TLS 1.2 default PRF, which uses SHA-256-HMAC. */ - session_prf_method = ciphersuite -> nx_secure_tls_prf; - } + { + /* For TLS 1.2, the PRF is defined by the ciphersuite. However, if we are using an older ciphersuite, + * default to the TLS 1.2 default PRF, which uses SHA-256-HMAC. */ + session_prf_method = ciphersuite -> nx_secure_tls_prf; + } #endif #if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) #ifdef NX_SECURE_ENABLE_DTLS - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0) + if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || + tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0) #else - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1) + if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || + tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1) #endif /* NX_SECURE_ENABLE_DTLS */ - { - /* TLS 1.0 and TLS 1.1 use the same PRF. */ - session_prf_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_prf_1_method; - } -#endif - /* If we don't have a PRF method, the version is wrong! */ - if (session_prf_method == NX_NULL) - { -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random)); -#endif /* NX_SECURE_KEY_CLEAR */ - - return(NX_SECURE_TLS_PROTOCOL_VERSION_CHANGED); - } - - /* Use the PRF to generate the master secret. */ - if (session_prf_method -> nx_crypto_init != NX_NULL) - { - status = session_prf_method -> nx_crypto_init((NX_CRYPTO_METHOD*)session_prf_method, - pre_master_sec, (NX_CRYPTO_KEY_SIZE)pre_master_sec_size, - &handler, - tls_session -> nx_secure_tls_prf_metadata_area, - tls_session -> nx_secure_tls_prf_metadata_size); - - if(status != NX_CRYPTO_SUCCESS) - { -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random)); -#endif /* NX_SECURE_KEY_CLEAR */ - - return(status); - } - } - - if (session_prf_method -> nx_crypto_operation != NX_NULL) - { - status = session_prf_method -> nx_crypto_operation(NX_CRYPTO_PRF, - handler, - (NX_CRYPTO_METHOD*)session_prf_method, - (UCHAR *)"master secret", - 13, - _nx_secure_tls_gen_keys_random, - 64, - NX_NULL, - master_sec, - 48, - tls_session -> nx_secure_tls_prf_metadata_area, - tls_session -> nx_secure_tls_prf_metadata_size, - NX_NULL, - NX_NULL); - -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random)); -#endif /* NX_SECURE_KEY_CLEAR */ - - if(status != NX_CRYPTO_SUCCESS) - { - /* Secrets cleared above. */ - return(status); - } - } - - if (session_prf_method -> nx_crypto_cleanup) - { - status = session_prf_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_prf_metadata_area); - - if(status != NX_CRYPTO_SUCCESS) - { - /* All secrets cleared above. */ - return(status); - } - } - } - else { - /* The chosen cipher is not supported. Likely an internal error since negotiation has already finished. */ - return(NX_SECURE_TLS_UNSUPPORTED_CIPHER); + /* TLS 1.0 and TLS 1.1 use the same PRF. */ + session_prf_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_prf_1_method; } +#endif - /* Clear out the Pre-Master Secret (we don't need it anymore and keeping it in memory is dangerous). */ -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(pre_master_sec, 0x0, sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret)); -#endif /* NX_SECURE_KEY_CLEAR */ - - /* Lookup ciphersuite data for key size. We need 2 keys for each session. */ - key_size = session_cipher_method -> nx_crypto_key_size_in_bits >> 3; - - /* Lookup ciphersuite data for hash size - used for the MAC secret. */ - hash_size = ciphersuite -> nx_secure_tls_hash_size; - - /* Lookup initialization vector size. */ - iv_size = session_cipher_method -> nx_crypto_IV_size_in_bits >> 3; - - /* Now calculate block size. Need client and server for each key, hash, and iv. Note that - key size and iv size may be zero depending on the ciphersuite, particularly when using - the NULL ciphers. */ - key_block_size = 2 * (key_size + hash_size + iv_size); - - /* Now generate keys from the master secret we obtained above. */ - /* From the RFC (TLS 1.1): - To generate the key material, compute - - key_block = PRF(SecurityParameters.master_secret, - "key expansion", - SecurityParameters.server_random + - SecurityParameters.client_random); - - until enough output has been generated. Then the key_block is - partitioned as follows: - - client_write_MAC_secret[SecurityParameters.hash_size] - server_write_MAC_secret[SecurityParameters.hash_size] - client_write_key[SecurityParameters.key_material_length] - server_write_key[SecurityParameters.key_material_length] - */ - - /* The order of the randoms is reversed from that used for the master secret - when generating the key block. */ - NX_SECURE_MEMCPY(_nx_secure_tls_gen_keys_random, tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, - NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */ - NX_SECURE_MEMCPY(&_nx_secure_tls_gen_keys_random[NX_SECURE_TLS_RANDOM_SIZE], - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */ + status = tls_session -> nx_secure_generate_master_secret(ciphersuite, tls_session -> nx_secure_tls_protocol_version, session_prf_method, + &tls_session -> nx_secure_tls_key_material, pre_master_sec, pre_master_sec_size, + master_sec, tls_session -> nx_secure_tls_prf_metadata_area, + tls_session -> nx_secure_tls_prf_metadata_size); - /* Key expansion uses the PRF to generate a block of key material from the master secret (generated - above) and the client and server random values transmitted during the initial hello negotiation. */ - if (session_prf_method -> nx_crypto_init != NX_NULL) + if (status != NX_SECURE_TLS_SUCCESS) { - status = session_prf_method -> nx_crypto_init((NX_CRYPTO_METHOD*)session_prf_method, - master_sec, 48, - &handler, - tls_session -> nx_secure_tls_prf_metadata_area, - tls_session -> nx_secure_tls_prf_metadata_size); - - if(status != NX_CRYPTO_SUCCESS) - { -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random)); -#endif /* NX_SECURE_KEY_CLEAR */ - return(status); - } + return(status); } - if (session_prf_method -> nx_crypto_operation != NX_NULL) - { - status = session_prf_method -> nx_crypto_operation(NX_CRYPTO_PRF, - handler, - (NX_CRYPTO_METHOD*)session_prf_method, - (UCHAR *)"key expansion", - 13, - _nx_secure_tls_gen_keys_random, - 64, - NX_NULL, - key_block, - key_block_size, - tls_session -> nx_secure_tls_prf_metadata_area, - tls_session -> nx_secure_tls_prf_metadata_size, - NX_NULL, - NX_NULL); - + /* Clear out the Pre-Master Secret (we don't need it anymore and keeping it in memory is dangerous). */ #ifdef NX_SECURE_KEY_CLEAR - /* We now have a key block, clear our temporary secrets buffer. */ - NX_SECURE_MEMSET(_nx_secure_tls_gen_keys_random, 0, sizeof(_nx_secure_tls_gen_keys_random)); + NX_SECURE_MEMSET(pre_master_sec, 0x0, sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret)); #endif /* NX_SECURE_KEY_CLEAR */ - if(status != NX_CRYPTO_SUCCESS) - { - /* Secrets cleared above. */ - return(status); - } - } - - if (session_prf_method -> nx_crypto_cleanup) - { - status = session_prf_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_prf_metadata_area); - - if(status != NX_CRYPTO_SUCCESS) - { - /* Secrets cleared above. */ - return(status); - } - } - return(NX_SECURE_TLS_SUCCESS); + status = tls_session -> nx_secure_generate_session_keys(ciphersuite, tls_session -> nx_secure_tls_protocol_version, session_prf_method, + &tls_session -> nx_secure_tls_key_material, master_sec, tls_session -> nx_secure_tls_prf_metadata_area, + tls_session -> nx_secure_tls_prf_metadata_size); + return(status); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c index 54b2dbf4..f1140aca 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_generate_premaster_secret.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_generate_premaster_secret PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -51,10 +51,8 @@ /* */ /* CALLS */ /* */ -/* _nx_secure_tls_psk_find Find PSK from store */ -/* _nx_secure_tls_find_curve_method Find named curve used */ -/* [nx_crypto_init] Initialize crypto */ -/* [nx_crypto_operation] Crypto operation */ +/* _nx_secure_tls_protocol_version_get Get current TLS version to use*/ +/* [nx_secure_generate_premaster_secret] Generate pre-master secret */ /* */ /* CALLED BY */ /* */ @@ -75,27 +73,15 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), removed */ /* internal unreachable logic, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_generate_premaster_secret(NX_SECURE_TLS_SESSION *tls_session, UINT id) { -UINT *buffer_ptr; -UINT i; -UINT status = NX_SECURE_TLS_SUCCESS; -USHORT protocol_version; -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES -UCHAR *psk_data; -UINT psk_length; -UINT index; -#endif -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE -NX_SECURE_X509_CERT *server_certificate; -const NX_CRYPTO_METHOD *curve_method_cert; -const NX_CRYPTO_METHOD *ecdh_method; -NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; -VOID *handler = NX_NULL; -NX_CRYPTO_EXTENDED_OUTPUT extended_output; -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ +UINT status; +USHORT protocol_version; if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) { @@ -104,211 +90,23 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); } -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE) - { - - return(NX_SECURE_TLS_SUCCESS); - } - else if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH) - { - /* Get reference to remote server certificate so we can find out the named curve. */ - status = _nx_secure_x509_remote_endpoint_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, - &server_certificate); - if (status) - { - /* No certificate found, error! */ - return(NX_SECURE_TLS_CERTIFICATE_NOT_FOUND); - } - - ec_pubkey = &server_certificate -> nx_secure_x509_public_key.ec_public_key; - - /* Find out which named curve the remote certificate is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_pubkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); - - if(status != NX_SUCCESS) - { - return(status); - } - - ecdh_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher; - if (ecdh_method -> nx_crypto_operation == NX_NULL) - { - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - } - - if (ecdh_method -> nx_crypto_init != NX_NULL) - { - status = ecdh_method -> nx_crypto_init((NX_CRYPTO_METHOD*)ecdh_method, - NX_NULL, - 0, - &handler, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_EC_CURVE_SET, handler, - (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0, - (UCHAR *)curve_method_cert, sizeof(NX_CRYPTO_METHOD *), NX_NULL, - NX_NULL, 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - /* Store public key in the nx_secure_tls_new_key_material_data. */ - extended_output.nx_crypto_extended_output_data = &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[1]; - extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data) - 1; - extended_output.nx_crypto_extended_output_actual_size = 0; - status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_DH_SETUP, handler, - (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0, - NX_NULL, 0, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[0] = (UCHAR)extended_output.nx_crypto_extended_output_actual_size; - - extended_output.nx_crypto_extended_output_data = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret; - extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret); - extended_output.nx_crypto_extended_output_actual_size = 0; - status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_DH_CALCULATE, handler, - (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0, - (UCHAR *)ec_pubkey -> nx_secure_ec_public_key, - ec_pubkey -> nx_secure_ec_public_key_length, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = extended_output.nx_crypto_extended_output_actual_size; - - if (ecdh_method -> nx_crypto_cleanup) - { - status = ecdh_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - return(NX_SECURE_TLS_SUCCESS); - } -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ - -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - /* Check for PSK ciphersuites. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK) - { - /* Now, using the identity as a key, find the PSK in our PSK store. */ - if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER) - { - /* Server just uses its PSK. */ - psk_data = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data; - psk_length = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data_size; - } - else - { - /* Client has to search for the PSK based on the identity hint. */ - status = _nx_secure_tls_psk_find(tls_session, &psk_data, &psk_length, tls_session -> nx_secure_tls_credentials.nx_secure_tls_remote_psk_id, - tls_session -> nx_secure_tls_credentials.nx_secure_tls_remote_psk_id_size, NX_NULL); - - if (status != NX_SUCCESS) - { - return(status); - } - } - - /* From RFC 4279: - The premaster secret is formed as follows: if the PSK is N octets - long, concatenate a uint16 with the value N, N zero octets, a second - uint16 with the value N, and the PSK itself. - | 2 | | 2 | | - | N | 0 | N | PSK | - */ - index = 0; - - if ((2 + psk_length + 2 + psk_length) > sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret)) - { - - /* No more PSK space. */ - return(NX_SECURE_TLS_NO_MORE_PSK_SPACE); - } - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[0] = (UCHAR)(psk_length >> 8); - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[1] = (UCHAR)psk_length; - index += 2; - - NX_SECURE_MEMSET(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[index], 0, psk_length); - index += psk_length; - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[index] = (UCHAR)(psk_length >> 8); - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[index + 1] = (UCHAR)psk_length; - index += 2; - - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[index], psk_data, psk_length); /* Use case of memcpy is verified. */ - index += psk_length; - - /* Save the pre-master secret size for later use. */ - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = 2 + psk_length + 2 + psk_length; - - /* We are using PSK for our credentials and now that we have generated keys we can consider the - remote host's credentials to have been received. */ - tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; - - return(NX_SECURE_TLS_SUCCESS); - } -#endif + _nx_secure_tls_protocol_version_get(tls_session, &protocol_version, id); -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE - /* When using ECJ-PAKE ciphersuite, pre-master secret is already generated. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE) - { - /* If using EC-JPAKE, credentials are passed differently - if we get here credentials should be OK. */ - tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; +#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE + status = tls_session -> nx_secure_generate_premaster_secret(tls_session -> nx_secure_tls_session_ciphersuite, protocol_version, + &tls_session -> nx_secure_tls_key_material, &tls_session -> nx_secure_tls_credentials, + tls_session -> nx_secure_tls_socket_type, + &tls_session -> nx_secure_tls_received_remote_credentials, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, &tls_session -> nx_secure_tls_ecc); +#else + status = tls_session -> nx_secure_generate_premaster_secret(tls_session -> nx_secure_tls_session_ciphersuite, protocol_version, + &tls_session -> nx_secure_tls_key_material, &tls_session -> nx_secure_tls_credentials, + tls_session -> nx_secure_tls_socket_type, + &tls_session -> nx_secure_tls_received_remote_credentials, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, NX_NULL); - return(NX_SECURE_TLS_SUCCESS); - } #endif - /* Generate the Pre-Master Secret that is used to generate the key material - used in the session. For TLS 1.1, the secret consists of two bytes - representing the highest protocol version the client supports, followed - by 46 random bytes. */ - buffer_ptr = (UINT *)tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret; - - /* Generate 48 bytes of random data, fill in the version afterwards. */ - for (i = 0; i < 12; i++) - { - /* Fill with 12 ULONG randoms, then fix first two bytes to protocol version after. */ - *(buffer_ptr + i) = (UINT)NX_RAND(); - } - - /* First two bytes are newest version supported by client . */ - _nx_secure_tls_protocol_version_get(tls_session, &protocol_version, id); - buffer_ptr[0] = ((ULONG)protocol_version << 16) | (buffer_ptr[0] & 0x0000FFFF); - NX_CHANGE_ULONG_ENDIAN(buffer_ptr[0]); - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = 48; - return(status); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_hash_record.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_hash_record.c index 4b90e9db..fba0e278 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_hash_record.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_hash_record.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_hash_record PORTABLE C */ -/* 6.1.7 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -76,22 +76,23 @@ /* 06-02-2021 Timothy Stapko Modified comment(s), */ /* fixed compiler warning, */ /* resulting in version 6.1.7 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* adjusted parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ -UINT _nx_secure_tls_hash_record(NX_SECURE_TLS_SESSION *tls_session, +UINT _nx_secure_tls_hash_record(const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite, ULONG sequence_num[NX_SECURE_TLS_SEQUENCE_NUMBER_SIZE], UCHAR *header, UINT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT length, UCHAR *record_hash, UINT *hash_length, - UCHAR *mac_secret) + UCHAR *mac_secret, VOID *metadata, ULONG metadata_size) { -UINT hash_size; -UINT status = NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE; -const NX_CRYPTO_METHOD *authentication_method; -UCHAR adjusted_sequence_num[8]; -VOID *metadata; -UINT metadata_size; -VOID *handler = NX_NULL; -ULONG current_length; +UINT hash_size; +UINT status = NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE; +const NX_CRYPTO_METHOD *authentication_method; +UCHAR adjusted_sequence_num[8]; +VOID *handler = NX_NULL; +ULONG current_length; NX_PARAMETER_NOT_USED(header_length); @@ -105,20 +106,11 @@ ULONG current_length; */ - if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) - { - - /* Likely internal error since at this point ciphersuite negotiation was theoretically completed. */ - return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); - } - /* Get our authentication method from the ciphersuite. */ - authentication_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_hash; - metadata = tls_session -> nx_secure_hash_mac_metadata_area; - metadata_size = tls_session -> nx_secure_hash_mac_metadata_size; + authentication_method = ciphersuite -> nx_secure_tls_hash; /* Get the hash size and MAC secret for our current session. */ - hash_size = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_hash_size; + hash_size = ciphersuite -> nx_secure_tls_hash_size; /* Correct the endianness of our sequence number before hashing. */ adjusted_sequence_num[0] = (UCHAR)(sequence_num[1] >> 24); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_key_material_init.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_key_material_init.c index 7ea0483a..8c28ceb5 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_key_material_init.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_key_material_init.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_key_material_init PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -61,31 +61,16 @@ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* cleared all key material, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_key_material_init(NX_SECURE_TLS_KEY_MATERIAL *key_material) { - /* Clear out key blocks individually - we may need to keep some key data - * around in the future for things like session re-negotiation/resumption. */ - - NX_SECURE_MEMSET(key_material -> nx_secure_tls_client_random, 0, NX_SECURE_TLS_RANDOM_SIZE); - - NX_SECURE_MEMSET(key_material -> nx_secure_tls_server_random, 0, NX_SECURE_TLS_RANDOM_SIZE); - - NX_SECURE_MEMSET(key_material -> nx_secure_tls_pre_master_secret, 0, NX_SECURE_TLS_PREMASTER_SIZE); - key_material -> nx_secure_tls_pre_master_secret_size = 0; - - NX_SECURE_MEMSET(key_material -> nx_secure_tls_master_secret, 0, NX_SECURE_TLS_MASTER_SIZE); - - NX_SECURE_MEMSET(key_material -> nx_secure_tls_key_material_data, 0, NX_SECURE_TLS_KEY_MATERIAL_SIZE); - NX_SECURE_MEMSET(key_material -> nx_secure_tls_new_key_material_data, 0, NX_SECURE_TLS_KEY_MATERIAL_SIZE); - -#if(NX_SECURE_TLS_TLS_1_3_ENABLED) - NX_SECURE_MEMSET(&key_material->nx_secure_tls_key_secrets, 0, sizeof(NX_SECURE_TLS_KEY_SECRETS)); - NX_SECURE_MEMSET(key_material->nx_secure_tls_ecc_key_data, 0, sizeof(key_material->nx_secure_tls_ecc_key_data)); - key_material->nx_secure_tls_handshake_cache_length = 0; -#endif + /* Clear out the entire key material. */ + NX_SECURE_MEMSET(key_material, 0, sizeof(NX_SECURE_TLS_KEY_MATERIAL)); return(NX_SECURE_TLS_SUCCESS); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_map_error_to_alert.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_map_error_to_alert.c index c0a10559..bf2a69a8 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_map_error_to_alert.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_map_error_to_alert.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_map_error_to_alert PORTABLE C */ -/* 6.1.6 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -55,11 +55,7 @@ /* */ /* CALLED BY */ /* */ -/* _nx_secure_dtls_client_handshake DTLS client state machine */ -/* _nx_secure_dtls_server_handshake DTLS server state machine */ /* _nx_secure_dtls_session_receive Receive DTLS data */ -/* _nx_secure_tls_client_handshake TLS client state machine */ -/* _nx_secure_tls_server_handshake TLS server state machine */ /* _nx_secure_tls_session_receive_records */ /* Receive TLS records */ /* */ @@ -74,6 +70,10 @@ /* 04-02-2021 Timothy Stapko Modified comment(s), */ /* updated X.509 return value, */ /* resulting in version 6.1.6 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* updated alert message for */ +/* downgrade protection, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID _nx_secure_tls_map_error_to_alert(UINT error_number, UINT *alert_number, UINT *alert_level) @@ -176,6 +176,7 @@ VOID _nx_secure_tls_map_error_to_alert(UINT error_number, UINT *alert_number, UI case NX_SECURE_TLS_BAD_COMPRESSION_METHOD: /* Deliberate fall-through. */ case NX_SECURE_TLS_1_3_UNKNOWN_CIPHERSUITE: case NX_SECURE_TLS_BAD_SERVERHELLO_KEYSHARE: + case NX_SECURE_TLS_DOWNGRADE_DETECTED: *alert_number = NX_SECURE_TLS_ALERT_ILLEGAL_PARAMETER; *alert_level = NX_SECURE_TLS_ALERT_LEVEL_FATAL; break; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_request.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_request.c index b5650647..c89c400b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_request.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_request.c @@ -33,7 +33,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_certificate_request PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -71,6 +71,9 @@ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), improved */ +/* buffer length verification, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_certificate_request(NX_SECURE_TLS_SESSION *tls_session, @@ -181,6 +184,11 @@ UINT extension_type; if (tls_session -> nx_secure_tls_1_3) { + if (message_length < 1 || (UINT)packet_buffer[0] + 3 > message_length) + { + return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); + } + /* Skip certificate request context. */ length = length + 1 + packet_buffer[length]; @@ -225,7 +233,7 @@ UINT extension_type; length += 1; /* Make sure what we extracted makes sense. */ - if (cert_types_length > message_length) + if (cert_types_length + 1 > message_length) { return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); } @@ -259,6 +267,11 @@ UINT extension_type; if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2) #endif /* NX_SECURE_ENABLE_DTLS */ { + if (length + 2 > message_length) + { + return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); + } + /* Extract the count of algorithms from the incoming data. */ sign_algs_length = (UINT)((packet_buffer[length] << 8) + packet_buffer[length + 1]); length = length + 2; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_verify.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_verify.c index 2fc792da..3e5e4e49 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_verify.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_certificate_verify.c @@ -39,7 +39,7 @@ static const UCHAR _NX_SECURE_OID_SHA256[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09 /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_certificate_verify PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -94,6 +94,9 @@ static const UCHAR _NX_SECURE_OID_SHA256[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09 /* 04-25-2022 Yuxin Zhou Modified comment(s), */ /* removed unnecessary code, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_certificate_verify(NX_SECURE_TLS_SESSION *tls_session, @@ -222,7 +225,7 @@ NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; - The content to be signed */ - UCHAR *transcript_hash = tls_session->nx_secure_tls_key_material.nx_secure_tls_transcript_hashes[NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE]; + UCHAR *transcript_hash = tls_session -> nx_secure_tls_key_material.nx_secure_tls_transcript_hashes[NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE]; /* Set octet padding bytes. */ NX_SECURE_MEMSET(&handshake_hash[0], 0x20, 64); @@ -357,7 +360,7 @@ NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; /* Generate a hash of all sent and received handshake messages to this point (not a Finished hash!). */ /* Copy over the handshake hash state into a local structure to do the intermediate calculation. */ - NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, + NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, /* lgtm[cpp/banned-api-usage-required-any] */ tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata, tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata_size); /* Use case of memcpy is verified. */ @@ -478,7 +481,7 @@ NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; /* Something failed in the hash calculation. */ #ifdef NX_SECURE_KEY_CLEAR NX_SECURE_MEMSET(handshake_hash, 0, sizeof(handshake_hash)); -#endif /* NX_SECURE_KEY_CLEAR */ +#endif /* NX_SECURE_KEY_CLEAR */ return(status); } } @@ -768,7 +771,7 @@ NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; ec_pubkey = &client_certificate -> nx_secure_x509_public_key.ec_public_key; /* Find out which named curve the remote certificate is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_pubkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); + status = _nx_secure_tls_find_curve_method(&tls_session -> nx_secure_tls_ecc, (USHORT)(ec_pubkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); if (status != NX_SUCCESS) { @@ -858,7 +861,7 @@ NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; #ifdef NX_SECURE_KEY_CLEAR NX_SECURE_MEMSET(handshake_hash, 0, sizeof(handshake_hash)); NX_SECURE_MEMSET(_nx_secure_decrypted_signature, 0, sizeof(_nx_secure_decrypted_signature)); -#endif /* NX_SECURE_KEY_CLEAR */ +#endif /* NX_SECURE_KEY_CLEAR */ return(status); } } @@ -867,7 +870,7 @@ NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; #endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ else { - /* Unknown or unsupported public-key operation. + /* Unknown or unsupported public-key operation. No secrets to clear. */ return(NX_SECURE_TLS_UNSUPPORTED_PUBLIC_CIPHER); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_client_key_exchange.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_client_key_exchange.c index aa5e2823..08bbba10 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_client_key_exchange.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_client_key_exchange.c @@ -24,14 +24,12 @@ #include "nx_secure_tls.h" -static UCHAR _nx_secure_client_padded_pre_master[600]; - /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_client_key_exchange PORTABLE C */ -/* 6.1.7 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -56,15 +54,8 @@ static UCHAR _nx_secure_client_padded_pre_master[600]; /* */ /* CALLS */ /* */ -/* _nx_secure_tls_generate_premaster_secret */ -/* Generate the shared secret */ -/* used to generate keys later */ -/* _nx_secure_x509_local_device_certificate_get */ -/* Get the local certificate */ -/* for its keys */ -/* _nx_secure_tls_find_curve_method Find named curve used */ -/* [nx_crypto_init] Initialize crypto */ -/* [nx_crypto_operation] Crypto operation */ +/* [nx_secure_process_client_key_exchange] */ +/* Process ClientKeyExchange */ /* */ /* CALLED BY */ /* */ @@ -84,33 +75,21 @@ static UCHAR _nx_secure_client_padded_pre_master[600]; /* supported hardware EC */ /* private key, */ /* resulting in version 6.1.7 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), improved */ +/* buffer length verification, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_client_key_exchange(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, UINT message_length, UINT id) { -USHORT length; -UINT status; -UCHAR *encrypted_pre_master_secret; -const NX_CRYPTO_METHOD *public_cipher_method; -NX_SECURE_X509_CERT *local_certificate; -UINT user_defined_key; -VOID *handler = NX_NULL; -UCHAR rand_byte; -UINT i; -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE -NX_SECURE_EC_PRIVATE_KEY *ec_privkey; -NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecdhe_data; -NX_CRYPTO_EXTENDED_OUTPUT extended_output; -const NX_CRYPTO_METHOD *curve_method; -const NX_CRYPTO_METHOD *ecdh_method; -UCHAR *private_key; -UINT private_key_length; -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ +#ifndef NX_SECURE_TLS_SERVER_DISABLED +UINT status; -#ifndef NX_SECURE_ENABLE_PSK_CIPHERSUITES NX_PARAMETER_NOT_USED(id); -#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) { @@ -119,444 +98,42 @@ UINT private_key_length; return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); } +#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE /* Process key material. The contents of the handshake record differ according to the ciphersuite chosen in the Client/Server Hello negotiation. */ + status = tls_session -> nx_secure_process_client_key_exchange(tls_session -> nx_secure_tls_session_ciphersuite, tls_session -> nx_secure_tls_protocol_version, + packet_buffer, message_length, &tls_session -> nx_secure_tls_received_remote_credentials, &tls_session -> nx_secure_tls_key_material, + &tls_session -> nx_secure_tls_credentials, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, + tls_session -> nx_secure_public_auth_metadata_size, + &tls_session -> nx_secure_tls_ecc); -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE - /* Check for ECJ-PAKE ciphersuites and generate the pre-master-secret. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE) - { - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = 32; - - public_cipher_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth; - status = public_cipher_method -> nx_crypto_operation(NX_CRYPTO_ECJPAKE_CLIENT_KEY_EXCHANGE_PROCESS, - tls_session -> nx_secure_public_auth_handler, - (NX_CRYPTO_METHOD*)public_cipher_method, - NX_NULL, 0, - packet_buffer, - message_length, - NX_NULL, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - if (status) - { - return(status); - } - - if (public_cipher_method -> nx_crypto_cleanup) - { - status = public_cipher_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area); - - if (status) - { - return(status); - } - } - } - else -#endif - { - -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - /* Check for PSK ciphersuites and generate the pre-master-secret. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK) - { - status = _nx_secure_tls_generate_premaster_secret(tls_session, id); +#else - if (status != NX_SUCCESS) - { - return(status); - } - } - else + /* Process key material. The contents of the handshake record differ according to the + ciphersuite chosen in the Client/Server Hello negotiation. */ + status = tls_session -> nx_secure_process_client_key_exchange(tls_session -> nx_secure_tls_session_ciphersuite, tls_session -> nx_secure_tls_protocol_version, + packet_buffer, message_length, &tls_session -> nx_secure_tls_received_remote_credentials, &tls_session -> nx_secure_tls_key_material, + &tls_session -> nx_secure_tls_credentials, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, + tls_session -> nx_secure_public_auth_metadata_size, + NX_NULL); #endif -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH || - tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE) - { - length = packet_buffer[0]; - - if (length > message_length) - { - /* The public key length is larger than the header indicated. */ - return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); - } - - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH) - { - /* Get the local certificate. */ - if (tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate != NX_NULL) - { - local_certificate = tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate; - } - else - { - /* Get reference to local device certificate. NX_NULL is passed for name to get default entry. */ - status = _nx_secure_x509_local_device_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, - NX_NULL, &local_certificate); - if (status != NX_SUCCESS) - { - local_certificate = NX_NULL; - } - } - - if (local_certificate == NX_NULL) - { - /* No certificate found, error! */ - return(NX_SECURE_TLS_CERTIFICATE_NOT_FOUND); - } - - ec_privkey = &local_certificate -> nx_secure_x509_private_key.ec_private_key; - - /* Find out which named curve the local certificate is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method, NX_NULL); - - if(status != NX_SUCCESS) - { - return(status); - } - - private_key = (UCHAR *)ec_privkey -> nx_secure_ec_private_key; - private_key_length = ec_privkey -> nx_secure_ec_private_key_length; - } - else - { - ecdhe_data = (NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *)tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data; - - /* Find out which named curve the we are using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)ecdhe_data -> nx_secure_tls_ecdhe_named_curve, &curve_method, NX_NULL); - - if(status != NX_SUCCESS) - { - return(status); - } - - private_key = ecdhe_data -> nx_secure_tls_ecdhe_private_key; - private_key_length = ecdhe_data -> nx_secure_tls_ecdhe_private_key_length; - } - - if (curve_method == NX_NULL) - { - /* No named curve is selected. */ - return(NX_SECURE_TLS_UNSUPPORTED_ECC_CURVE); - } - - ecdh_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher; - if (ecdh_method -> nx_crypto_operation == NX_NULL) - { - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - } - - if (ecdh_method -> nx_crypto_init != NX_NULL) - { - status = ecdh_method -> nx_crypto_init((NX_CRYPTO_METHOD*)ecdh_method, - NX_NULL, - 0, - &handler, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_EC_CURVE_SET, handler, - (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0, - (UCHAR *)curve_method, sizeof(NX_CRYPTO_METHOD *), NX_NULL, - NX_NULL, 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - /* Import the private key to the ECDH context. */ - status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_DH_KEY_PAIR_IMPORT, handler, - (NX_CRYPTO_METHOD*)ecdh_method, - private_key, private_key_length << 3, - NX_NULL, 0, NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - extended_output.nx_crypto_extended_output_data = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret; - extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret); - extended_output.nx_crypto_extended_output_actual_size = 0; - status = ecdh_method -> nx_crypto_operation(NX_CRYPTO_DH_CALCULATE, handler, - (NX_CRYPTO_METHOD*)ecdh_method, NX_NULL, 0, - &packet_buffer[1], - length, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = extended_output.nx_crypto_extended_output_actual_size; - - if (ecdh_method -> nx_crypto_cleanup) - { - status = ecdh_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - } - else -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ - { /* Certificate-based authentication. */ - /* Get pre-master-secret length. */ - length = (USHORT)((packet_buffer[0] << 8) + (USHORT)packet_buffer[1]); - packet_buffer += 2; + return(status); - if (length > message_length) - { - /* The payload is larger than the header indicated. */ - return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); - } - - /* Pointer to the encrypted pre-master secret in our packet buffer. */ - encrypted_pre_master_secret = &packet_buffer[0]; - - - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_ciphersuite == TLS_NULL_WITH_NULL_NULL) - { - /* Special case - NULL ciphersuite. No keys are generated. */ - if (length > sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret)) - { - length = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret); - } - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret, encrypted_pre_master_secret, length); /* Use case of memcpy is verified. */ - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = length; - } - - /* Get reference to local device certificate. NX_NULL is passed for name to get default entry. */ - status = _nx_secure_x509_local_device_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, - NX_NULL, &local_certificate); - - if (status) - { - /* No certificate found, error! */ - return(NX_SECURE_TLS_CERTIFICATE_NOT_FOUND); - } - - /* Get the public cipher method pointer for this session. */ - public_cipher_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher; - - /* Check for user-defined key types. */ - user_defined_key = NX_FALSE; - if (((local_certificate -> nx_secure_x509_private_key_type & NX_SECURE_X509_KEY_TYPE_USER_DEFINED_MASK) != 0x0) || - ( local_certificate -> nx_secure_x509_private_key_type == NX_SECURE_X509_KEY_TYPE_HARDWARE)) - { - user_defined_key = NX_TRUE; - } - - /* See if we are using RSA. Separate from other methods (e.g. ECC, DH) for proper handling of padding. */ - if (public_cipher_method -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA && - local_certificate -> nx_secure_x509_public_algorithm == NX_SECURE_TLS_X509_TYPE_RSA) - { - /* Check for user-defined keys. */ - if (user_defined_key) - { - /* A user-defined key is passed directly into the crypto routine. */ - status = public_cipher_method -> nx_crypto_operation(local_certificate -> nx_secure_x509_private_key_type, - NX_NULL, - (NX_CRYPTO_METHOD*)public_cipher_method, - (UCHAR *)local_certificate -> nx_secure_x509_private_key.user_key.key_data, - (NX_CRYPTO_KEY_SIZE)(local_certificate -> nx_secure_x509_private_key.user_key.key_length), - encrypted_pre_master_secret, - length, - NX_NULL, - _nx_secure_client_padded_pre_master, - sizeof(_nx_secure_client_padded_pre_master), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - else - { - /* Generic RSA operation, use pre-parsed RSA key data. */ - if (public_cipher_method -> nx_crypto_init != NX_NULL) - { - /* Initialize the crypto method with public key. */ - status = public_cipher_method -> nx_crypto_init((NX_CRYPTO_METHOD*)public_cipher_method, - (UCHAR *)local_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus, - (NX_CRYPTO_KEY_SIZE)(local_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus_length << 3), - &handler, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - if (public_cipher_method -> nx_crypto_operation != NX_NULL) - { - - - /* Check for P and Q in the private key. If they are present, we can use them to - speed up RSA using the Chinese Remainder Theorem version of the algorithm. */ - if (local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_prime_p != NX_NULL && - local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_prime_q != NX_NULL) - { - - - status = public_cipher_method -> nx_crypto_operation(NX_CRYPTO_SET_PRIME_P, - handler, - (NX_CRYPTO_METHOD*)public_cipher_method, - NX_NULL, - 0, - (VOID *)local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_prime_p, - local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_prime_p_length, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = public_cipher_method -> nx_crypto_operation(NX_CRYPTO_SET_PRIME_Q, - handler, - (NX_CRYPTO_METHOD*)public_cipher_method, - NX_NULL, - 0, - (VOID *)local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_prime_q, - local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_prime_q_length, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - } - - /* Decrypt the pre-master-secret using the private key provided by the user - and place the result in the session key material space in our socket. */ - status = public_cipher_method -> nx_crypto_operation(NX_CRYPTO_DECRYPT, - handler, - (NX_CRYPTO_METHOD*)public_cipher_method, - (UCHAR *)local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_exponent, - (NX_CRYPTO_KEY_SIZE)(local_certificate -> nx_secure_x509_private_key.rsa_private_key.nx_secure_rsa_private_exponent_length << 3), - encrypted_pre_master_secret, - length, - NX_NULL, - _nx_secure_client_padded_pre_master, - sizeof(_nx_secure_client_padded_pre_master), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - } - - if (public_cipher_method -> nx_crypto_cleanup) - { - status = public_cipher_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area); - - if(status != NX_CRYPTO_SUCCESS) - { -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0, sizeof(_nx_secure_client_padded_pre_master)); -#endif /* NX_SECURE_KEY_CLEAR */ - - return(status); - } - } - } - - /* Check padding - first 2 bytes should be 0x00, 0x02 for PKCS#1 padding. A 0x00 byte should immediately - precede the data. */ - if (_nx_secure_client_padded_pre_master[0] != 0x00 || - _nx_secure_client_padded_pre_master[1] != 0x02 || - _nx_secure_client_padded_pre_master[length - NX_SECURE_TLS_RSA_PREMASTER_SIZE - 1] != 0x00) - { - - /* Invalid padding. To avoid Bleichenbacher's attack, use random numbers to - generate premaster secret and continue the operation (which will be properly - taken care of later in _nx_secure_tls_process_finished()). - - This is described in RFC 5246, section 7.4.7.1, page 58-59. */ - - /* Generate premaster secret using random numbers. */ - for (i = 0; i < NX_SECURE_TLS_RSA_PREMASTER_SIZE; ++i) - { - - /* PKCS#1 padding must be random, but CANNOT be 0. */ - do - { - rand_byte = (UCHAR)NX_RAND(); - } while (rand_byte == 0); - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret[i] = rand_byte; - } - } - else - { +#else - /* Extract the 48 bytes of the actual pre-master secret from the data we just decrypted, stripping the padding, which - comes at the beginning of the decrypted block (the pre-master secret is the last 48 bytes. */ - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret, - &_nx_secure_client_padded_pre_master[length - NX_SECURE_TLS_RSA_PREMASTER_SIZE], NX_SECURE_TLS_RSA_PREMASTER_SIZE); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = NX_SECURE_TLS_RSA_PREMASTER_SIZE; - } /* End RSA-specific section. */ - else - { - /* Unknown or invalid public cipher. */ - return(NX_SECURE_TLS_UNSUPPORTED_PUBLIC_CIPHER); - } - } - } -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0, sizeof(_nx_secure_client_padded_pre_master)); -#endif /* NX_SECURE_KEY_CLEAR */ + NX_PARAMETER_NOT_USED(packet_buffer); + NX_PARAMETER_NOT_USED(message_length); + NX_PARAMETER_NOT_USED(id); -#ifdef NX_SECURE_TLS_SERVER_DISABLED /* If TLS Server is disabled and we have processed a ClientKeyExchange, something is wrong... */ tls_session -> nx_secure_tls_client_state = NX_SECURE_TLS_CLIENT_STATE_ERROR; return(NX_SECURE_TLS_INVALID_STATE); -#else - return(NX_SUCCESS); + #endif } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello.c index 783a7740..c677f1b7 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello.c @@ -36,7 +36,7 @@ static UINT _nx_secure_tls_check_ciphersuite(const NX_SECURE_TLS_CIPHERSUITE_INF /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_clienthello PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -99,6 +99,9 @@ static UINT _nx_secure_tls_check_ciphersuite(const NX_SECURE_TLS_CIPHERSUITE_INF /* the bug of processing */ /* extensions, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), fixed */ +/* TLS 1.3 version negotiation,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_clienthello(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, @@ -130,6 +133,7 @@ NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecdhe_data; #endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) USHORT tls_1_3 = tls_session -> nx_secure_tls_1_3; +USHORT no_extension = NX_FALSE; #endif /* Structure of ClientHello: @@ -249,7 +253,7 @@ USHORT tls_1_3 = tls_session -> nx_secure_tls_1_3 tls_session -> nx_secure_tls_protocol_version = protocol_version; /* Save off the random value for key generation later. */ - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, &packet_buffer[length], NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, &packet_buffer[length], NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ length += NX_SECURE_TLS_RANDOM_SIZE; /* Extract the session ID if there is one. */ @@ -265,7 +269,7 @@ USHORT tls_1_3 = tls_session -> nx_secure_tls_1_3 tls_session -> nx_secure_tls_session_id_length = session_id_length; if (session_id_length > 0) { - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_session_id, &packet_buffer[length], session_id_length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_session_id, &packet_buffer[length], session_id_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ length += session_id_length; } @@ -361,12 +365,41 @@ USHORT tls_1_3 = tls_session -> nx_secure_tls_1_3 else { num_extensions = 0; +#if (NX_SECURE_TLS_TLS_1_3_ENABLED) + no_extension = NX_TRUE; +#endif } } else { num_extensions = 0; +#if (NX_SECURE_TLS_TLS_1_3_ENABLED) + no_extension = NX_TRUE; +#endif + } + +#if (NX_SECURE_TLS_TLS_1_3_ENABLED) + if ((tls_session -> nx_secure_tls_1_3) && (no_extension == NX_TRUE)) + { + + /* Negotiate a version of TLS prior to TLS 1.3. */ + if (tls_session -> nx_secure_tls_protocol_version_override == 0) + { + tls_session -> nx_secure_tls_1_3 = NX_FALSE; +#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) + tls_session -> nx_secure_tls_renegotation_enabled = NX_TRUE; +#endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ + + return(NX_SUCCESS); + } + else + { + + /* Protocol version is overridden to TLS 1.3. */ + return(NX_SECURE_TLS_UNSUPPORTED_TLS_VERSION); + } } +#endif #if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) if ((tls_session -> nx_secure_tls_renegotiation_handshake) && (!tls_session -> nx_secure_tls_secure_renegotiation_verified)) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello_extensions.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello_extensions.c index c4301fd7..91922c58 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello_extensions.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_clienthello_extensions.c @@ -24,7 +24,7 @@ #include "nx_secure_tls.h" -#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) +#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) static UINT _nx_secure_tls_proc_clienthello_sec_reneg_extension(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, UINT extension_length); @@ -157,12 +157,12 @@ USHORT supported_version = tls_session -> nx_secure_tls_protocol_version; if((offset + extension_length) > message_length) { return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); - } + } /* Parse the extension. */ switch (extension_id) { -#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) +#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) case NX_SECURE_TLS_EXTENSION_SECURE_RENEGOTIATION: status = _nx_secure_tls_proc_clienthello_sec_reneg_extension(tls_session, &packet_buffer[offset], @@ -177,7 +177,7 @@ USHORT supported_version = tls_session -> nx_secure_tls_protocol_version; #if (NX_SECURE_TLS_TLS_1_3_ENABLED) && !defined(NX_SECURE_TLS_SERVER_DISABLED) case NX_SECURE_TLS_EXTENSION_KEY_SHARE: - if(tls_session->nx_secure_tls_1_3) + if(tls_session -> nx_secure_tls_1_3) { /* If TLS 1.3, process the key share extension. */ status = _nx_secure_tls_proc_clienthello_keyshare_extension(tls_session, @@ -192,7 +192,7 @@ USHORT supported_version = tls_session -> nx_secure_tls_protocol_version; /* TLS 1.2 and earlier: ignore extension. */ break; case NX_SECURE_TLS_EXTENSION_SUPPORTED_VERSIONS: - if(tls_session->nx_secure_tls_1_3) + if(tls_session -> nx_secure_tls_1_3) { /* Process the TLS 1.3 supported_versions extension. */ @@ -211,7 +211,7 @@ USHORT supported_version = tls_session -> nx_secure_tls_protocol_version; break; #ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES case NX_SECURE_TLS_EXTENSION_PRE_SHARED_KEY: - if(tls_session->nx_secure_tls_1_3) + if(tls_session -> nx_secure_tls_1_3) { /* Process the TLS 1.3 PSK extension. */ @@ -258,7 +258,7 @@ USHORT supported_version = tls_session -> nx_secure_tls_protocol_version; } #if (NX_SECURE_TLS_TLS_1_3_ENABLED) && !defined(NX_SECURE_TLS_SERVER_DISABLED) - if((tls_session->nx_secure_tls_1_3) && (supported_version != NX_SECURE_TLS_VERSION_TLS_1_3)) + if((tls_session -> nx_secure_tls_1_3) && (supported_version != NX_SECURE_TLS_VERSION_TLS_1_3)) { /* Negotiate a version of TLS prior to TLS 1.3. */ @@ -333,7 +333,7 @@ USHORT supported_version = tls_session -> nx_secure_tls_protocol_version; /* resulting in version 6.1.9 */ /* */ /**************************************************************************/ -#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) +#if !defined(NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION) static UINT _nx_secure_tls_proc_clienthello_sec_reneg_extension(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, UINT extension_length) @@ -445,7 +445,7 @@ INT compare_value; /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_proc_clienthello_sec_sa_extension PORTABLE C */ -/* 6.1.9 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -492,6 +492,9 @@ INT compare_value; /* TLS 1.3 and disabling TLS */ /* server, */ /* resulting in version 6.1.9 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE @@ -531,7 +534,7 @@ UCHAR expected_signature = 0; if (cert_curve) { - status = _nx_secure_tls_find_curve_method(tls_session, cert_curve, &curve_method, NX_NULL); + status = _nx_secure_tls_find_curve_method(&tls_session -> nx_secure_tls_ecc, cert_curve, &curve_method, NX_NULL); if (status == NX_SUCCESS && curve_method != NX_NULL) { *cert_curve_supported = NX_TRUE; @@ -544,7 +547,7 @@ UCHAR expected_signature = 0; { expected_signature = NX_SECURE_TLS_SIGNATURE_ALGORITHM_ECDSA; } - else if (cert->nx_secure_x509_public_algorithm == NX_SECURE_TLS_X509_TYPE_RSA) + else if (cert -> nx_secure_x509_public_algorithm == NX_SECURE_TLS_X509_TYPE_RSA) { expected_signature = NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA; } @@ -574,7 +577,7 @@ UCHAR expected_signature = 0; { group = (USHORT)((groups[j] << 8) + groups[j + 1]); - status = _nx_secure_tls_find_curve_method(tls_session, group, &curve_method, &new_curve_priority); + status = _nx_secure_tls_find_curve_method(&tls_session -> nx_secure_tls_ecc, group, &curve_method, &new_curve_priority); if ((status == NX_CRYTPO_MISSING_ECC_CURVE) || (new_curve_priority > curve_priority)) { @@ -602,7 +605,7 @@ UCHAR expected_signature = 0; for (k = 0; k < ecc_info -> nx_secure_tls_ecc_supported_groups_count; k++) { /* Find the matching group in the keys we generated and saved. */ - if(group == tls_session->nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[k].nx_secure_tls_ecdhe_named_curve) + if(group == tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[k].nx_secure_tls_ecdhe_named_curve) { /* Store selected ECDHE key data index. */ @@ -636,7 +639,7 @@ UCHAR expected_signature = 0; exts[i].nx_secure_tls_extension_data_length); signature_algorithm_exist = NX_TRUE; } - else + else #endif #if (NX_SECURE_TLS_TLS_1_2_ENABLED) if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_2) @@ -691,8 +694,8 @@ UCHAR expected_signature = 0; } #if (NX_SECURE_TLS_TLS_1_3_ENABLED) && !defined(NX_SECURE_TLS_SERVER_DISABLED) - /* RFC8446 4.2.3: If a server is authenticating via a certificate and - the client has not sent a "signature_algorithms" extension, + /* RFC8446 4.2.3: If a server is authenticating via a certificate and + the client has not sent a "signature_algorithms" extension, then the server MUST abort the handshake with a "missing_extension" alert. */ if ((cert != NX_NULL) && (tls_session -> nx_secure_tls_1_3)) { @@ -718,7 +721,7 @@ UCHAR expected_signature = 0; /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_proc_clienthello_keyshare_extension PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -761,6 +764,9 @@ UCHAR expected_signature = 0; /* 04-25-2022 Yuxin Zhou Modified comment(s), removed */ /* public key format checking, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) && !defined(NX_SECURE_TLS_SERVER_DISABLED) @@ -778,7 +784,7 @@ USHORT key_share_length; USHORT key_group; USHORT key_length; NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecc_key_data; -UCHAR *pubkey; +UCHAR *pubkey = NX_NULL; UCHAR *private_key; UINT private_key_length; NX_CRYPTO_EXTENDED_OUTPUT extended_output; @@ -820,12 +826,12 @@ NX_SECURE_TLS_ECC *ecc_info; /* Get the key share length. */ key_share_length = (USHORT)((packet_buffer[offset] << 8) + packet_buffer[offset + 1]); offset = (USHORT)(offset + 2); - + if(offset + key_share_length > extension_length) { return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); } - + /* Loop through the list of keys looking for a supported group. */ while(offset < extension_length && ecc_key_data == NX_NULL) { @@ -854,10 +860,10 @@ NX_SECURE_TLS_ECC *ecc_info; for (i = 0; i < ecc_info -> nx_secure_tls_ecc_supported_groups_count; i++) { /* Find the matching group in the keys we generated and saved. */ - if(key_group == tls_session->nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i].nx_secure_tls_ecdhe_named_curve) + if(key_group == tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i].nx_secure_tls_ecdhe_named_curve) { /* Got a matching key/curve combo, get a pointer to the selected key data. */ - ecc_key_data = &tls_session->nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i]; + ecc_key_data = &tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i]; /* Extract the remote public key from our packet. */ pubkey = &packet_buffer[offset]; @@ -881,7 +887,7 @@ NX_SECURE_TLS_ECC *ecc_info; } /* Get the curve method to initialize the remote public key data. */ - _nx_secure_tls_find_curve_method(tls_session, key_group, &curve_method, NX_NULL); + _nx_secure_tls_find_curve_method(&tls_session -> nx_secure_tls_ecc, key_group, &curve_method, NX_NULL); if (curve_method == NX_NULL) { @@ -926,8 +932,8 @@ NX_SECURE_TLS_ECC *ecc_info; } /* Import the private key to the ECDH context. */ - private_key = &ecc_key_data->nx_secure_tls_ecdhe_private_key[0]; - private_key_length = ecc_key_data->nx_secure_tls_ecdhe_private_key_length; + private_key = &ecc_key_data -> nx_secure_tls_ecdhe_private_key[0]; + private_key_length = ecc_key_data -> nx_secure_tls_ecdhe_private_key_length; status = ecdhe_method -> nx_crypto_operation(NX_CRYPTO_DH_KEY_PAIR_IMPORT, handler, (NX_CRYPTO_METHOD*)ecdhe_method, @@ -1349,7 +1355,7 @@ static UINT _nx_secure_tls_process_clienthello_psk_extension(NX_SECURE_TLS_SESSI USHORT extension_length, const UCHAR *client_hello_buffer, UINT client_hello_length) { UINT list_length; -UCHAR *psk_data; +UCHAR *psk_data = NX_NULL; UINT psk_length; UCHAR binder_len; UINT psk_index; @@ -1440,7 +1446,7 @@ NX_SECURE_TLS_PSK_STORE *psk_store; } /* Get our PSK store for easy access. */ - psk_store = tls_session->nx_secure_tls_credentials.nx_secure_tls_psk_store; + psk_store = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store; binder_total = 0; psk_index = 0; @@ -1470,7 +1476,7 @@ NX_SECURE_TLS_PSK_STORE *psk_store; age = (UINT)((packet_buffer[offset] << 24) + (packet_buffer[offset + 1] << 16) + (packet_buffer[offset + 2] << 8) + packet_buffer[offset + 3]); offset += 4; - + /* Only support external PSKs (no session resumption). */ if(age != 0) { @@ -1545,7 +1551,7 @@ NX_SECURE_TLS_PSK_STORE *psk_store; { return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); } - + /* Subtract the binder length and field from the total. */ binder_total--; binder_total -= binder_len; @@ -1642,8 +1648,8 @@ NX_SECURE_TLS_PSK_STORE *psk_store; } /* Make sure the Client PSK is initialized for later key generation. */ - NX_SECURE_MEMCPY(tls_session->nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data, psk_data, psk_length); /* Use case of memcpy is verified. */ - tls_session->nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data_size = psk_length; + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data, psk_data, psk_length); /* Use case of memcpy is verified. */ + tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_data_size = psk_length; return(NX_SUCCESS); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_finished.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_finished.c index 9e896255..751bb6ca 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_finished.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_finished.c @@ -157,7 +157,7 @@ UINT is_server; #ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION /* If we are doing secure renegotiation as per RFC 5746, we need to save off the generated verify data now. For TLS 1.0-1.2 this is 12 bytes. If SSLv3 is ever used, it will be 36 bytes. */ - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_remote_verify_data, generated_hash, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_remote_verify_data, generated_hash, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ #endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ /* The finished verify data is always 12 bytes (*except for SSLv3) - compare to see if the Finished hash matches the recevied hash. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_record.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_record.c index 8d9a204a..60a440d2 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_record.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_record.c @@ -31,7 +31,7 @@ static VOID _nx_secure_tls_packet_trim(NX_PACKET *packet_ptr); /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_record PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -97,6 +97,11 @@ static VOID _nx_secure_tls_packet_trim(NX_PACKET *packet_ptr); /* 04-25-2022 Yuxin Zhou Modified comment(s), */ /* removed unnecessary code, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* checked seq number overflow,*/ +/* improved buffer length */ +/* verification, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_record(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *packet_ptr, @@ -323,6 +328,14 @@ NX_PACKET *decrypted_packet; { /* Check for overflow of the 32-bit unsigned number. */ tls_session -> nx_secure_tls_remote_sequence_number[1]++; + + if (tls_session -> nx_secure_tls_remote_sequence_number[1] == 0) + { + + /* Check for overflow of the 64-bit unsigned number. As it should not reach here + in practical, we return a general error to prevent overflow theoretically. */ + return(NX_NOT_SUCCESSFUL); + } } tls_session -> nx_secure_tls_remote_sequence_number[0]++; } @@ -440,6 +453,13 @@ NX_PACKET *decrypted_packet; break; case NX_SECURE_TLS_ALERT: + + if (message_length < 2) + { + status = NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH; + break; + } + /* We have received an alert. Check what the alert was and take appropriate action. */ /* The alert level is the first octet in the alert. The alert number is the second. */ if(packet_data[0] == NX_SECURE_TLS_ALERT_LEVEL_FATAL) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_remote_certificate.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_remote_certificate.c index 185098ef..32d29886 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_remote_certificate.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_remote_certificate.c @@ -230,7 +230,7 @@ ULONG cert_buf_size; /* Copy the certificate from the packet buffer into our allocated certificate space. */ certificate -> nx_secure_x509_certificate_raw_data_length = cert_length; - NX_SECURE_MEMCPY(certificate -> nx_secure_x509_certificate_raw_data, &packet_buffer[length], cert_length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(certificate -> nx_secure_x509_certificate_raw_data, &packet_buffer[length], cert_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } length += cert_length; @@ -376,7 +376,7 @@ ULONG cert_buf_size; /* Copy the certificate data to the end of the certificate buffer or use an allocated certificate. */ certificate -> nx_secure_x509_certificate_raw_data_length = endpoint_length; - NX_SECURE_MEMCPY(certificate->nx_secure_x509_certificate_raw_data, endpoint_raw_ptr, endpoint_length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(certificate->nx_secure_x509_certificate_raw_data, endpoint_raw_ptr, endpoint_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ /* Release the protection. */ tx_mutex_put(&_nx_secure_tls_protection); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_server_key_exchange.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_server_key_exchange.c index a964b4bd..ce577bb0 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_server_key_exchange.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_server_key_exchange.c @@ -24,21 +24,13 @@ #include "nx_secure_tls.h" -#ifdef NX_SECURE_ENABLE_DTLS -#include "nx_secure_dtls.h" -#endif /* NX_SECURE_ENABLE_DTLS */ - -#if defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) && !defined(NX_SECURE_TLS_CLIENT_DISABLED) -static UCHAR hash[64]; /* We concatenate MD5 and SHA-1 hashes into this buffer, OR SHA-256, SHA-384, SHA512. */ -static UCHAR decrypted_signature[512]; -#endif /* defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) && !defined(NX_SECURE_TLS_CLIENT_DISABLED) */ /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_server_key_exchange PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -87,6 +79,12 @@ static UCHAR decrypted_signature[512]; /* 04-25-2022 Yuxin Zhou Modified comment(s), */ /* removed unnecessary code, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), improved */ +/* buffer length verification, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_server_key_exchange(NX_SECURE_TLS_SESSION *tls_session, @@ -94,46 +92,11 @@ UINT _nx_secure_tls_process_server_key_exchange(NX_SECURE_TLS_SESSION *tls_sessi { #if !defined(NX_SECURE_TLS_CLIENT_DISABLED) - -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES -USHORT length; -#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ +UINT status; #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || \ (defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE)) -UINT status; const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite; #endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) */ -#if defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) -const NX_CRYPTO_METHOD *curve_method; -const NX_CRYPTO_METHOD *curve_method_cert; -const NX_CRYPTO_METHOD *ecdhe_method; -const NX_CRYPTO_METHOD *hash_method; -const NX_CRYPTO_METHOD *auth_method; -VOID *handler = NX_NULL; -UCHAR pubkey_length; -UCHAR *pubkey; -USHORT signature_length; -NX_SECURE_X509_CERT *server_certificate; -NX_SECURE_X509_CRYPTO *crypto_methods; -UINT sig_oid_length; -const UCHAR *sig_oid; -UINT decrypted_hash_length; -const UCHAR *decrypted_hash; -UINT compare_result; -NX_SECURE_EC_PUBLIC_KEY *ec_pubkey; -NX_CRYPTO_EXTENDED_OUTPUT extended_output; -UCHAR *current_buffer; -UCHAR hash_algorithm; -UCHAR signature_algorithm; -USHORT signature_algorithm_id; -#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) -UINT i; -#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ -#endif /* defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) */ - - NX_PARAMETER_NOT_USED(tls_session); - NX_PARAMETER_NOT_USED(packet_buffer); - NX_PARAMETER_NOT_USED(message_length); #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || \ (defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE)) @@ -147,73 +110,6 @@ UINT i; } #endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) */ -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - /* Check for PSK ciphersuites. */ - if (ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK) - { - /* Get identity hint length. */ - length = (USHORT)((packet_buffer[0] << 8) + (USHORT)packet_buffer[1]); - packet_buffer += 2; - - if (length > message_length || length > NX_SECURE_TLS_MAX_PSK_ID_SIZE) - { - /* The payload is larger than the header indicated. */ - return(NX_SECURE_TLS_INCORRECT_MESSAGE_LENGTH); - } - - /* Extract the identity hint and save in the TLS Session. Then when pre-master is generated - in client_handshake, we can do the right thing... */ - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_credentials.nx_secure_tls_remote_psk_id, &packet_buffer[0], length); /* Use case of memcpy is verified. */ - tls_session -> nx_secure_tls_credentials.nx_secure_tls_remote_psk_id_size = length; - - return(NX_SECURE_TLS_SUCCESS); - } -#endif - -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE - /* Check for ECJ-PAKE ciphersuites. */ - if (ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE) - { - /* Make sure curve type is named_curve (3). */ - if (packet_buffer[0] != 3) - { - return(NX_SECURE_TLS_UNSUPPORTED_ECC_FORMAT); - } - - /* Only secp256r1 (23) is supported. */ - if (packet_buffer[1] != 0 || packet_buffer[2] != 23) - { - return(NX_SECURE_TLS_UNSUPPORTED_ECC_CURVE); - } - - packet_buffer += 3; - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = 32; - - status = ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_operation(NX_CRYPTO_ECJPAKE_SERVER_KEY_EXCHANGE_PROCESS, - tls_session -> nx_secure_public_auth_handler, - (NX_CRYPTO_METHOD*)ciphersuite -> nx_secure_tls_public_auth, - NX_NULL, 0, - packet_buffer, - message_length, - NX_NULL, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - if (status) - { - return(status); - } - - if (ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_cleanup) - { - status = ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area); - } - - return(status); - } -#endif #if defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) @@ -226,693 +122,32 @@ UINT i; tls_session -> nx_secure_tls_client_state = NX_SECURE_TLS_CLIENT_STATE_SERVER_KEY_EXCHANGE; - /* Make sure curve type is named_curve (3). */ - if (packet_buffer[0] != 3) - { - return(NX_SECURE_TLS_UNSUPPORTED_ECC_FORMAT); - } - - /* Find out which named curve the server is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)((packet_buffer[1] << 8) + packet_buffer[2]), &curve_method, NX_NULL); - - if (status != NX_SUCCESS) - { - - /* The remote server is using an unsupported curve. */ - return(NX_SECURE_TLS_UNSUPPORTED_ECC_CURVE); - } - - current_buffer = &packet_buffer[3]; - - /* Get reference to remote server certificate so we can get the public key for signature verification. */ - status = _nx_secure_x509_remote_endpoint_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, - &server_certificate); - if (status) - { - /* No certificate found, error! */ - return(NX_SECURE_TLS_CERTIFICATE_NOT_FOUND); - } - - pubkey_length = current_buffer[0]; - pubkey = ¤t_buffer[1]; - - current_buffer += pubkey_length + 1; - -#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) -#ifdef NX_SECURE_ENABLE_DTLS - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0) -#else - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1) -#endif /* NX_SECURE_ENABLE_DTLS */ - { - hash_algorithm = NX_SECURE_TLS_HASH_ALGORITHM_SHA1; - if (server_certificate -> nx_secure_x509_public_algorithm == NX_SECURE_TLS_X509_TYPE_EC) - { - signature_algorithm = NX_SECURE_TLS_SIGNATURE_ALGORITHM_ECDSA; - } - else - { - signature_algorithm = NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA; - } - } - else -#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ - { - hash_algorithm = current_buffer[0]; - signature_algorithm = current_buffer[1]; - current_buffer += 2; - } - - /* Find out the hash algorithm used for the signature. */ - /* Map signature algorithm to internal ID. */ - _nx_secure_tls_get_signature_algorithm_id(((UINT)(hash_algorithm << 8) + signature_algorithm), - &signature_algorithm_id); - - /* Get the cypto method. */ - status = _nx_secure_x509_find_certificate_methods(server_certificate, - signature_algorithm_id, - &crypto_methods); - if (status) - { - return(NX_SECURE_TLS_UNSUPPORTED_SIGNATURE_ALGORITHM); - } - -#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) -#ifdef NX_SECURE_ENABLE_DTLS - if (signature_algorithm == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)) -#else - if (signature_algorithm == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) -#endif /* NX_SECURE_ENABLE_DTLS */ - { - - /* TLS 1.0 and TLS 1.1 use MD5 + SHA1 hash for RSA signatures. */ - hash_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method; - } - else -#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ - { - hash_method = crypto_methods -> nx_secure_x509_hash_method; - } - - - /* Calculate the hash: SHA(ClientHello.random + ServerHello.random + - ServerKeyExchange.params); */ - if (hash_method -> nx_crypto_init) - { - status = hash_method -> nx_crypto_init((NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - &handler, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - if (hash_method -> nx_crypto_operation != NX_NULL) - { - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_INITIALIZE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - NX_NULL, - 0, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - else - { - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_UPDATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, - 32, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_UPDATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, - 32, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_UPDATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - packet_buffer, - (ULONG)(4 + pubkey_length), - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_CALCULATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - NX_NULL, - 0, - NX_NULL, - hash, - hash_method -> nx_crypto_ICV_size_in_bits >> 3, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - if (hash_method -> nx_crypto_cleanup) - { - status = hash_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - handler = NX_NULL; - -#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) -#ifdef NX_SECURE_ENABLE_DTLS - if (signature_algorithm == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0)) -#else - if (signature_algorithm == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1)) -#endif /* NX_SECURE_ENABLE_DTLS */ - { - hash_method = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method;; - - /* Calculate the hash: SHA(ClientHello.random + ServerHello.random + - ServerKeyExchange.params); */ - if (hash_method -> nx_crypto_init) - { - status = hash_method -> nx_crypto_init((NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - &handler, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - if (hash_method -> nx_crypto_operation != NX_NULL) - { - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_INITIALIZE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - NX_NULL, - 0, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - else - { - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_UPDATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, - 32, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_UPDATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, - 32, - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_UPDATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - packet_buffer, - (ULONG)(4 + pubkey_length), - NX_NULL, - NX_NULL, - 0, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - status = hash_method -> nx_crypto_operation(NX_CRYPTO_HASH_CALCULATE, - handler, - (NX_CRYPTO_METHOD*)hash_method, - NX_NULL, - 0, - NX_NULL, - 0, - NX_NULL, - &hash[16], - hash_method -> nx_crypto_ICV_size_in_bits >> 3, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, - tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch_size, - NX_NULL, - NX_NULL); - - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - if (hash_method -> nx_crypto_cleanup) - { - status = hash_method -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch); - - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - handler = NX_NULL; - } -#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ - - signature_length = (USHORT)((current_buffer[0] << 8) + current_buffer[1]); - current_buffer += 2; - - /* Verify the signature. */ - auth_method = ciphersuite -> nx_secure_tls_public_auth; - - if (signature_algorithm == NX_SECURE_TLS_SIGNATURE_ALGORITHM_RSA && - (auth_method -> nx_crypto_algorithm == NX_CRYPTO_DIGITAL_SIGNATURE_RSA || - auth_method -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA)) - { - /* Verify the RSA signature. */ - - if (auth_method -> nx_crypto_init != NX_NULL) - { - /* Initialize the crypto method with public key. */ - status = auth_method -> nx_crypto_init((NX_CRYPTO_METHOD*)auth_method, - (UCHAR *)server_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus, - (NX_CRYPTO_KEY_SIZE)(server_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus_length << 3), - &handler, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - if (auth_method -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_RSA) - { - status = auth_method -> nx_crypto_operation(NX_CRYPTO_DECRYPT, - handler, - (NX_CRYPTO_METHOD*)auth_method, - (UCHAR *)server_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_exponent, - (NX_CRYPTO_KEY_SIZE)(server_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_exponent_length << 3), - current_buffer, - signature_length, - NX_NULL, - decrypted_signature, - sizeof(decrypted_signature), - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } + } - if (auth_method -> nx_crypto_cleanup) - { - status = auth_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - handler = NX_NULL; + status = tls_session -> nx_secure_process_server_key_exchange(tls_session -> nx_secure_tls_session_ciphersuite, tls_session -> nx_secure_tls_crypto_table, + tls_session -> nx_secure_tls_protocol_version, packet_buffer, message_length, + &tls_session -> nx_secure_tls_key_material, &tls_session -> nx_secure_tls_credentials, + &tls_session -> nx_secure_tls_handshake_hash, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, tls_session -> nx_secure_public_auth_metadata_size, + &tls_session -> nx_secure_tls_ecc); -#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) -#ifdef NX_SECURE_ENABLE_DTLS - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_DTLS_VERSION_1_0) #else - if (tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_0 || - tls_session -> nx_secure_tls_protocol_version == NX_SECURE_TLS_VERSION_TLS_1_1) -#endif /* NX_SECURE_ENABLE_DTLS */ - { - if (signature_length < 39) - { - return(NX_SECURE_TLS_SIGNATURE_VERIFICATION_ERROR); - } - - /* Block type is 0x00, 0x01 for signatures */ - if (decrypted_signature[0] != 0x0 && decrypted_signature[1] != 0x1) - { - /* Unknown block type. */ - return(NX_SECURE_TLS_PADDING_CHECK_FAILED); - } - - /* Check padding. */ - for (i = 2; i < (UINT)(signature_length - 37); ++i) - { - if (decrypted_signature[i] != (UCHAR)0xFF) - { - /* Bad padding value. */ - return(NX_SECURE_TLS_PADDING_CHECK_FAILED); - } - } - - /* Make sure we actually saw a NULL byte. */ - if (decrypted_signature[i] != 0x00) - { - return(NX_SECURE_TLS_PADDING_CHECK_FAILED); - } - - decrypted_hash = &decrypted_signature[i + 1]; - decrypted_hash_length = 36; - } - else -#endif /* NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED */ - { - /* Decode the decrypted signature. */ - status = _nx_secure_x509_pkcs7_decode(decrypted_signature, signature_length, &sig_oid, &sig_oid_length, - &decrypted_hash, &decrypted_hash_length); - if (status != NX_SUCCESS) - { - return(NX_SECURE_TLS_SIGNATURE_VERIFICATION_ERROR); - } - - if (decrypted_hash_length != (hash_method -> nx_crypto_ICV_size_in_bits >> 3)) - { - return(NX_SECURE_TLS_SIGNATURE_VERIFICATION_ERROR); - } - } - - /* Compare generated hash with decrypted hash. */ - compare_result = (UINT)NX_SECURE_MEMCMP(hash, decrypted_hash, decrypted_hash_length); - -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(hash, 0, sizeof(hash)); - NX_SECURE_MEMSET(decrypted_signature, 0, sizeof(decrypted_signature)); -#endif /* NX_SECURE_KEY_CLEAR */ - - if (compare_result != 0) - { - return(NX_SECURE_TLS_SIGNATURE_VERIFICATION_ERROR); - } - } - else if (signature_algorithm == NX_SECURE_TLS_SIGNATURE_ALGORITHM_ECDSA && - auth_method -> nx_crypto_algorithm == NX_CRYPTO_DIGITAL_SIGNATURE_ECDSA) - { - /* Verify the ECDSA signature. */ - - ec_pubkey = &server_certificate -> nx_secure_x509_public_key.ec_public_key; - - /* Find out which named curve the remote certificate is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_pubkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); - - if(status != NX_SUCCESS) - { - - /* The remote certificate is using an unsupported curve. */ - return(NX_SECURE_TLS_UNSUPPORTED_ECC_CURVE); - } - - if (auth_method -> nx_crypto_init != NX_NULL) - { - status = auth_method -> nx_crypto_init((NX_CRYPTO_METHOD*)auth_method, - (UCHAR *)ec_pubkey -> nx_secure_ec_public_key, - (NX_CRYPTO_KEY_SIZE)(ec_pubkey -> nx_secure_ec_public_key_length << 3), - &handler, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - if (auth_method -> nx_crypto_operation == NX_NULL) - { - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - } - - status = auth_method -> nx_crypto_operation(NX_CRYPTO_EC_CURVE_SET, handler, - (NX_CRYPTO_METHOD*)auth_method, NX_NULL, 0, - (UCHAR *)curve_method_cert, sizeof(NX_CRYPTO_METHOD *), NX_NULL, - NX_NULL, 0, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - if (packet_buffer + message_length < current_buffer + signature_length) - { - return(NX_SECURE_TLS_SIGNATURE_VERIFICATION_ERROR); - } - - status = auth_method -> nx_crypto_operation(NX_CRYPTO_VERIFY, handler, - (NX_CRYPTO_METHOD*)auth_method, - (UCHAR *)ec_pubkey -> nx_secure_ec_public_key, - (NX_CRYPTO_KEY_SIZE)(ec_pubkey -> nx_secure_ec_public_key_length << 3), - hash, - hash_method -> nx_crypto_ICV_size_in_bits >> 3, - NX_NULL, - current_buffer, - signature_length, - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - - if (status == NX_CRYPTO_AUTHENTICATION_FAILED) - { - return(NX_SECURE_TLS_SIGNATURE_VERIFICATION_ERROR); - } - - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - if (auth_method -> nx_crypto_cleanup) - { - status = auth_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_auth_metadata_area); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - } - else - { - /* The signature hash algorithm used by the server is not supported. */ - return(NX_SECURE_TLS_UNSUPPORTED_SIGNATURE_ALGORITHM); - } - - ecdhe_method = ciphersuite -> nx_secure_tls_public_cipher; - if (ecdhe_method -> nx_crypto_operation == NX_NULL) - { - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - } - - if (ecdhe_method -> nx_crypto_init != NX_NULL) - { - status = ecdhe_method -> nx_crypto_init((NX_CRYPTO_METHOD*)ecdhe_method, - NX_NULL, - 0, - &handler, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size); - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } - } - - status = ecdhe_method -> nx_crypto_operation(NX_CRYPTO_EC_CURVE_SET, handler, - (NX_CRYPTO_METHOD*)ecdhe_method, NX_NULL, 0, - (UCHAR *)curve_method, sizeof(NX_CRYPTO_METHOD *), NX_NULL, - NX_NULL, 0, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - /* Store public key in the nx_secure_tls_new_key_material_data. */ - extended_output.nx_crypto_extended_output_data = &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[1]; - extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data) - 1; - extended_output.nx_crypto_extended_output_actual_size = 0; - status = ecdhe_method -> nx_crypto_operation(NX_CRYPTO_DH_SETUP, handler, - (NX_CRYPTO_METHOD*)ecdhe_method, NX_NULL, 0, - NX_NULL, 0, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - /* Store the length in the first octet. */ - tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[0] = (UCHAR)extended_output.nx_crypto_extended_output_actual_size; - - extended_output.nx_crypto_extended_output_data = tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret; - extended_output.nx_crypto_extended_output_length_in_byte = sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret); - extended_output.nx_crypto_extended_output_actual_size = 0; - status = ecdhe_method -> nx_crypto_operation(NX_CRYPTO_DH_CALCULATE, handler, - (NX_CRYPTO_METHOD*)ecdhe_method, NX_NULL, 0, - pubkey, pubkey_length, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret_size = extended_output.nx_crypto_extended_output_actual_size; - - if (ecdhe_method -> nx_crypto_cleanup) - { - status = ecdhe_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area); - } - - return(status); - } + status = tls_session -> nx_secure_process_server_key_exchange(tls_session -> nx_secure_tls_session_ciphersuite, tls_session -> nx_secure_tls_crypto_table, + tls_session -> nx_secure_tls_protocol_version, packet_buffer, message_length, + &tls_session -> nx_secure_tls_key_material, &tls_session -> nx_secure_tls_credentials, + &tls_session -> nx_secure_tls_handshake_hash, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, tls_session -> nx_secure_public_auth_metadata_size, + NX_NULL); #endif /* defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) */ - /* No server key exchange should be received by the current cipher suite. */ - return(NX_SECURE_TLS_UNEXPECTED_MESSAGE); + return(status); #else /* !define(NX_SECURE_TLS_CLIENT_DISABLED) */ - /* If Client TLS is disabled and we recieve a server key exchange, error! */ + /* If Client TLS is disabled and we recieve a server key exchange, error! */ NX_PARAMETER_NOT_USED(tls_session); NX_PARAMETER_NOT_USED(packet_buffer); NX_PARAMETER_NOT_USED(message_length); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello.c index 1f4930a0..5d36b39d 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello.c @@ -32,7 +32,7 @@ extern const UCHAR _nx_secure_tls_hello_retry_request_random[32]; /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_process_serverhello PORTABLE C */ -/* 6.1.9 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -81,6 +81,9 @@ extern const UCHAR _nx_secure_tls_hello_retry_request_random[32]; /* 10-15-2021 Timothy Stapko Modified comment(s), fixed */ /* TLS 1.3 compilation issue, */ /* resulting in version 6.1.9 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), fixed */ +/* TLS 1.3 version negotiation,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_process_serverhello(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, @@ -97,6 +100,7 @@ NX_SECURE_TLS_HELLO_EXTENSION extension_data[NX_SECURE_TLS_HELLO_EXTENSI UINT num_extensions; #if (NX_SECURE_TLS_TLS_1_3_ENABLED) USHORT tls_1_3 = tls_session -> nx_secure_tls_1_3; +USHORT no_extension = NX_FALSE; NX_SECURE_TLS_SERVER_STATE old_client_state = tls_session -> nx_secure_tls_client_state; tls_session -> nx_secure_tls_client_state = NX_SECURE_TLS_CLIENT_STATE_IDLE; @@ -163,7 +167,7 @@ NX_SECURE_TLS_SERVER_STATE old_client_state = tls_session -> nx_secur { /* Set the Server random data, used in key generation. First 4 bytes is GMT time. */ - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random[0], &packet_buffer[length], NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random[0], &packet_buffer[length], NX_SECURE_TLS_RANDOM_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } length += NX_SECURE_TLS_RANDOM_SIZE; @@ -179,7 +183,7 @@ NX_SECURE_TLS_SERVER_STATE old_client_state = tls_session -> nx_secur /* Session ID follows. */ if (tls_session -> nx_secure_tls_session_id_length > 0) { - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_session_id, &packet_buffer[length], tls_session -> nx_secure_tls_session_id_length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_session_id, &packet_buffer[length], tls_session -> nx_secure_tls_session_id_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ length += tls_session -> nx_secure_tls_session_id_length; } @@ -258,7 +262,41 @@ NX_SECURE_TLS_SERVER_STATE old_client_state = tls_session -> nx_secur } } } +#if (NX_SECURE_TLS_TLS_1_3_ENABLED) + else + { + no_extension = NX_TRUE; + } +#endif + } +#if (NX_SECURE_TLS_TLS_1_3_ENABLED) + else + { + no_extension = NX_TRUE; + } + + if ((tls_session -> nx_secure_tls_1_3) && (no_extension == NX_TRUE)) + { + + /* Server negotiates a version of TLS prior to TLS 1.3. */ + if (tls_session -> nx_secure_tls_protocol_version_override == 0) + { + tls_session -> nx_secure_tls_1_3 = NX_FALSE; +#ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION + tls_session -> nx_secure_tls_renegotation_enabled = NX_TRUE; +#endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ + + return(NX_SUCCESS); + } + else + { + + /* Protocol version is overridden to TLS 1.3. */ + return(NX_SECURE_TLS_UNSUPPORTED_TLS_VERSION); + } + } +#endif #ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION #ifdef NX_SECURE_TLS_REQUIRE_RENEGOTIATION_EXT diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello_extensions.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello_extensions.c index 35d6ce82..b2b28a38 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello_extensions.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_process_serverhello_extensions.c @@ -185,7 +185,7 @@ USHORT supported_version = tls_session -> nx_secu #ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE case NX_SECURE_TLS_EXTENSION_KEY_SHARE: - if(tls_session->nx_secure_tls_1_3) + if (tls_session -> nx_secure_tls_1_3) { /* Process the TLS 1.3 key share extension. */ status = _nx_secure_tls_proc_serverhello_keyshare_extension(tls_session, &packet_buffer[offset], &extension_length, message_length - offset); @@ -209,7 +209,7 @@ USHORT supported_version = tls_session -> nx_secu break; #endif case NX_SECURE_TLS_EXTENSION_SUPPORTED_VERSIONS: - if(tls_session->nx_secure_tls_1_3) + if (tls_session -> nx_secure_tls_1_3) { /* Process the TLS 1.3 supported_versions extension. */ @@ -242,7 +242,7 @@ USHORT supported_version = tls_session -> nx_secu } /* Store the pointer of cookie. */ - /* Note: Cookie data is stored in ServerHello packet buffer. This buffer should not be released + /* Note: Cookie data is stored in ServerHello packet buffer. This buffer should not be released or overwrote before Cookie is copied to ClientHello. */ if (tls_session -> nx_secure_tls_1_3) { @@ -340,7 +340,7 @@ USHORT supported_version = tls_session -> nx_secu #endif /* NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE */ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) - if(tls_session->nx_secure_tls_1_3) + if (tls_session -> nx_secure_tls_1_3) { if (supported_version != NX_SECURE_TLS_VERSION_TLS_1_3) { @@ -373,14 +373,14 @@ USHORT supported_version = tls_session -> nx_secu #endif return(status); -#else - /* If Client TLS is disabled and we recieve a server key exchange, error! */ +#else + /* If Client TLS is disabled and we recieve a server key exchange, error! */ NX_PARAMETER_NOT_USED(tls_session); NX_PARAMETER_NOT_USED(packet_buffer); NX_PARAMETER_NOT_USED(message_length); NX_PARAMETER_NOT_USED(extensions); NX_PARAMETER_NOT_USED(num_extensions); - + return(NX_SECURE_TLS_UNEXPECTED_MESSAGE); #endif } @@ -762,7 +762,7 @@ INT compare_value; /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_proc_serverhello_keyshare_extension PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -802,6 +802,9 @@ INT compare_value; /* 04-25-2022 Yuxin Zhou Modified comment(s), removed */ /* public key format checking, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) @@ -860,7 +863,7 @@ NX_SECURE_TLS_ECC *ecc_info; for (i = 0; i < ecc_info -> nx_secure_tls_ecc_supported_groups_count; i++) { /* Find the matchin group in the keys we generated and saved. */ - if(key_group != tls_session->nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i].nx_secure_tls_ecdhe_named_curve) + if (key_group != tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data[i].nx_secure_tls_ecdhe_named_curve) { continue; } @@ -876,7 +879,7 @@ NX_SECURE_TLS_ECC *ecc_info; } /* Got a matching key/curve combo, get a pointer to the selected key data. */ - ecc_key_data = tls_session->nx_secure_tls_key_material.nx_secure_tls_ecc_key_data; + ecc_key_data = tls_session -> nx_secure_tls_key_material.nx_secure_tls_ecc_key_data; if (*extension_length < 4) { @@ -895,7 +898,7 @@ NX_SECURE_TLS_ECC *ecc_info; pubkey = &packet_buffer[offset]; /* Get the curve method to initialize the remote public key data. */ - _nx_secure_tls_find_curve_method(tls_session, key_group, &curve_method, NX_NULL); + _nx_secure_tls_find_curve_method(&tls_session -> nx_secure_tls_ecc, key_group, &curve_method, NX_NULL); if (curve_method == NX_NULL) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_add.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_add.c index 165acfd0..ad26b412 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_add.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_add.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_psk_add PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -72,6 +72,9 @@ /* buffer length verification, */ /* verified memcpy use cases, */ /* resulting in version 6.1 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* fixed PSK size verification,*/ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) @@ -89,8 +92,8 @@ UINT current_index; /* Make sure we have space to add the PSK and its identity data. */ if ((current_index + 1) < NX_SECURE_TLS_MAX_PSK_KEYS && - psk_length < NX_SECURE_TLS_MAX_PSK_SIZE && - identity_length < NX_SECURE_TLS_MAX_PSK_ID_SIZE && + psk_length <= NX_SECURE_TLS_MAX_PSK_SIZE && + identity_length <= NX_SECURE_TLS_MAX_PSK_ID_SIZE && hint_length <= NX_SECURE_TLS_MAX_PSK_ID_SIZE) { /* Save off the PSK and its length. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_find.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_find.c index fabdda8f..608704b7 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_find.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_psk_find.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_psk_find PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -42,7 +42,7 @@ /* */ /* INPUT */ /* */ -/* tls_session Pointer to TLS Session */ +/* tls_credentials TLS credentials */ /* psk_data Pointer to PSK data */ /* psk_length Length of PSK data */ /* psk_identity_hint PSK identity hint data */ @@ -60,8 +60,7 @@ /* */ /* CALLED BY */ /* */ -/* _nx_secure_tls_generate_premaster_secret */ -/* Generate the shared secret */ +/* _nx_secure_generate_premaster_secret Generate the shared secret */ /* used to generate keys later */ /* */ /* RELEASE HISTORY */ @@ -71,10 +70,13 @@ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) -UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_SESSION *tls_session, UCHAR **psk_data, UINT *psk_length, +UINT _nx_secure_tls_psk_find(NX_SECURE_TLS_CREDENTIALS *tls_credentials, UCHAR **psk_data, UINT *psk_length, UCHAR *psk_identity_hint, UINT identity_length, UINT *psk_store_index) { UINT psk_list_size; @@ -84,20 +86,20 @@ UINT i; /* Get the protection. */ tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - psk_list_size = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_count; + psk_list_size = tls_credentials -> nx_secure_tls_psk_count; if ((psk_identity_hint[0] == 0) && (psk_list_size > 0)) { /* No hint from server. Return the first associated PSK. */ - *psk_data = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data; - *psk_length = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_data_size; + *psk_data = tls_credentials -> nx_secure_tls_psk_store[0].nx_secure_tls_psk_data; + *psk_length = tls_credentials -> nx_secure_tls_psk_store[0].nx_secure_tls_psk_data_size; if(psk_store_index != NX_NULL) { *psk_store_index = 0; - } - + } + /* Release the protection. */ tx_mutex_put(&_nx_secure_tls_protection); @@ -108,21 +110,21 @@ UINT i; for (i = 0; i < psk_list_size; ++i) { /* Save off the PSK and its length. */ - compare_val = (UINT)NX_SECURE_MEMCMP(tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint, psk_identity_hint, identity_length); + compare_val = (UINT)NX_SECURE_MEMCMP(tls_credentials -> nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint, psk_identity_hint, identity_length); /* See if the identity matched, and the length is the same (without the length, we could have a matching prefix which could be a possible attack vector... */ - if (compare_val == 0 && identity_length == tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint_size) + if (compare_val == 0 && identity_length == tls_credentials -> nx_secure_tls_psk_store[i].nx_secure_tls_psk_id_hint_size) { /* Found a matching identity, return the associated PSK. */ - *psk_data = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_data; - *psk_length = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[i].nx_secure_tls_psk_data_size; + *psk_data = tls_credentials -> nx_secure_tls_psk_store[i].nx_secure_tls_psk_data; + *psk_length = tls_credentials -> nx_secure_tls_psk_store[i].nx_secure_tls_psk_data_size; if(psk_store_index != NX_NULL) { *psk_store_index = i; } - + /* Release the protection. */ tx_mutex_put(&_nx_secure_tls_protection); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_decrypt.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_decrypt.c index 15c38aa3..b0d040db 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_decrypt.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_decrypt.c @@ -872,7 +872,7 @@ UINT original_offset = offset; if (session_cipher_method -> nx_crypto_operation == NX_NULL) { - NX_SECURE_MEMCPY(output, input, length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(output, input, length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } else { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_encrypt.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_encrypt.c index 17c4125d..799b7b3d 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_encrypt.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_record_payload_encrypt.c @@ -203,7 +203,7 @@ UCHAR *icv_ptr = NX_NULL; { /* New IV is the last encrypted block of the output. */ - NX_SECURE_MEMCPY(iv, ¤t_packet -> nx_packet_prepend_ptr[current_length + data_offset - iv_size], + NX_SECURE_MEMCPY(iv, ¤t_packet -> nx_packet_prepend_ptr[current_length + data_offset - iv_size], /* lgtm[cpp/banned-api-usage-required-any] */ iv_size); /* Use case of memcpy is verified. */ } } @@ -260,7 +260,7 @@ UCHAR *icv_ptr = NX_NULL; */ /* Offset for remainder bytes is rounded_length + data_offset. */ - NX_SECURE_MEMCPY(&_nx_secure_tls_record_block_buffer[0], + NX_SECURE_MEMCPY(&_nx_secure_tls_record_block_buffer[0], /* lgtm[cpp/banned-api-usage-required-any] */ ¤t_packet -> nx_packet_prepend_ptr[rounded_length + data_offset], remainder_length); /* Use case of memcpy is verified. */ copy_length = (ULONG)(current_packet -> nx_packet_next -> nx_packet_append_ptr - @@ -269,7 +269,7 @@ UCHAR *icv_ptr = NX_NULL; { copy_length = (ULONG)(block_size - remainder_length); } - NX_SECURE_MEMCPY(&_nx_secure_tls_record_block_buffer[remainder_length], + NX_SECURE_MEMCPY(&_nx_secure_tls_record_block_buffer[remainder_length], /* lgtm[cpp/banned-api-usage-required-any] */ current_packet -> nx_packet_next -> nx_packet_prepend_ptr, copy_length); /* Use case of memcpy is verified. */ @@ -298,9 +298,9 @@ UCHAR *icv_ptr = NX_NULL; } /* Copy data from temporary buffer back into packets. */ - NX_SECURE_MEMCPY(¤t_packet -> nx_packet_prepend_ptr[rounded_length + data_offset], + NX_SECURE_MEMCPY(¤t_packet -> nx_packet_prepend_ptr[rounded_length + data_offset], /* lgtm[cpp/banned-api-usage-required-any] */ &_nx_secure_tls_record_block_buffer[0], remainder_length); /* Use case of memcpy is verified. */ - NX_SECURE_MEMCPY(current_packet -> nx_packet_next -> nx_packet_prepend_ptr, + NX_SECURE_MEMCPY(current_packet -> nx_packet_next -> nx_packet_prepend_ptr, /* lgtm[cpp/banned-api-usage-required-any] */ &_nx_secure_tls_record_block_buffer[remainder_length], copy_length); /* Use case of memcpy is verified. */ @@ -309,7 +309,7 @@ UCHAR *icv_ptr = NX_NULL; { /* New IV is the last encrypted block of the output. */ - NX_SECURE_MEMCPY(iv, &_nx_secure_tls_record_block_buffer, iv_size); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(iv, &_nx_secure_tls_record_block_buffer, iv_size); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } #ifdef NX_SECURE_KEY_CLEAR @@ -655,7 +655,7 @@ UINT message_length; /* IV size is equal to the AES block size. Copy our IV into our data buffer at the head of the payload. */ - NX_SECURE_MEMCPY(send_packet -> nx_packet_prepend_ptr, iv, iv_size); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(send_packet -> nx_packet_prepend_ptr, iv, iv_size); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ *data_offset = iv_size; } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_free.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_free.c index 55711a0a..d8c06c31 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_free.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_free.c @@ -100,7 +100,7 @@ NX_SECURE_X509_CERT *certificate; status = _nx_secure_x509_certificate_list_find(&list_head, name, 0, &certificate); /* Now status can only be NX_SECURE_X509_CERTIFICATE_NOT_FOUND or NX_SECURE_X509_SUCCESS as - “&list_head” and “&certificate” are not NULL. + "&list_head" and "&certificate" are not NULL. Translate X.509 return values into TLS return values. */ if (status == NX_SECURE_X509_CERTIFICATE_NOT_FOUND) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_verify.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_verify.c index c8be7f1b..e0ed984d 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_verify.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_remote_certificate_verify.c @@ -30,7 +30,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_remote_certificate_verify PORTABLE C */ -/* 6.1.10 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -53,11 +53,9 @@ /* */ /* CALLS */ /* */ -/* _nx_secure_x509_certificate_chain_verify */ -/* Verify cert against stores */ -/* _nx_secure_x509_expiration_check Verify expiration of cert */ /* _nx_secure_x509_remote_endpoint_certificate_get */ /* Get remote host certificate */ +/* [nx_secure_remote_certificate_verify] Verify the remote certificate */ /* [nx_secure_tls_session_certificate_callback] */ /* Session certificate callback */ /* [nx_secure_tls_session_time_function] Session time callback */ @@ -81,6 +79,13 @@ /* improved code coverage */ /* results, */ /* resulting in version 6.1.10 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* checked expiration for all */ +/* the certs in the chain, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_remote_certificate_verify(NX_SECURE_TLS_SESSION *tls_session) @@ -123,44 +128,15 @@ ULONG current_time; { /* Get the current time from our callback. */ current_time = tls_session -> nx_secure_tls_session_time_function(); - - /* Check the remote certificate against the current time. */ - status = _nx_secure_x509_expiration_check(remote_certificate, current_time); - - if (status != NX_SUCCESS) - { - return(status); - } } /* Now verify our remote certificate chain. If the certificate can be linked to an issuer in the trusted store through an issuer chain, this function will return NX_SUCCESS. */ - status = _nx_secure_x509_certificate_chain_verify(store, remote_certificate); + status = tls_session -> nx_secure_remote_certificate_verify(store, remote_certificate, current_time); if (status != NX_SUCCESS) { - - /* Translate some X.509 return values into TLS return values. NX_SECURE_X509_CERTIFICATE_NOT_FOUND is removed - as _nx_secure_x509_certificate_chain_verify() will not return this value. */ - switch (status) - { - case NX_SECURE_X509_UNSUPPORTED_PUBLIC_CIPHER: - return(NX_SECURE_TLS_UNSUPPORTED_PUBLIC_CIPHER); - case NX_SECURE_X509_UNKNOWN_CERT_SIG_ALGORITHM: - return(NX_SECURE_TLS_UNKNOWN_CERT_SIG_ALGORITHM); - case NX_SECURE_X509_CERTIFICATE_SIG_CHECK_FAILED: - return(NX_SECURE_TLS_CERTIFICATE_SIG_CHECK_FAILED); -#ifndef NX_SECURE_ALLOW_SELF_SIGNED_CERTIFICATES - case NX_SECURE_X509_INVALID_SELF_SIGNED_CERT: - return(NX_SECURE_TLS_INVALID_SELF_SIGNED_CERT); -#endif - case NX_SECURE_X509_ISSUER_CERTIFICATE_NOT_FOUND: - return(NX_SECURE_TLS_ISSUER_CERTIFICATE_NOT_FOUND); - case NX_SECURE_X509_MISSING_CRYPTO_ROUTINE: - return(NX_SECURE_TLS_MISSING_CRYPTO_ROUTINE); - default: - return(status); - } + return(status); } /* Now, see if the application has defined a callback to check additional certificate information. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_certificate_verify.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_certificate_verify.c index 54cafd44..ff7e068e 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_certificate_verify.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_certificate_verify.c @@ -40,7 +40,7 @@ static const UCHAR _NX_SECURE_OID_SHA256[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09 /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_send_certificate_verify PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -101,6 +101,9 @@ static const UCHAR _NX_SECURE_OID_SHA256[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09 /* 04-25-2022 Zhen Kong Modified comment(s), removed */ /* unreachable code and branch,*/ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* updated parameters list, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_send_certificate_verify(NX_SECURE_TLS_SESSION *tls_session, @@ -236,7 +239,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; } #if (NX_SECURE_TLS_TLS_1_3_ENABLED) - if(tls_session->nx_secure_tls_1_3) + if(tls_session -> nx_secure_tls_1_3) { /* TLS 1.3 certificate verify uses a different scheme. The signature is calculated over a concatenation of the following (RFC 8446): @@ -246,7 +249,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; - The content to be signed */ - UCHAR *transcript_hash = tls_session->nx_secure_tls_key_material.nx_secure_tls_transcript_hashes[NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE]; + UCHAR *transcript_hash = tls_session -> nx_secure_tls_key_material.nx_secure_tls_transcript_hashes[NX_SECURE_TLS_TRANSCRIPT_IDX_CERTIFICATE]; /* Set octet padding bytes. */ NX_SECURE_MEMSET(&handshake_hash[0], 0x20, 64); @@ -377,7 +380,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; /* Generate a hash of all sent and received handshake messages to this point (not a Finished hash!). */ /* Copy over the handshake hash state into a local structure to do the intermediate calculation. */ - NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, + NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, /* lgtm[cpp/banned-api-usage-required-any] */ tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata, tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata_size); /* Use case of memcpy is verified. */ @@ -407,7 +410,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; if (status != NX_CRYPTO_SUCCESS) { return(status); - } + } } #endif @@ -457,7 +460,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; if (status != NX_CRYPTO_SUCCESS) { return(status); - } + } NX_SECURE_HASH_METADATA_CLONE(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_scratch, tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha1_metadata, @@ -489,7 +492,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; if (status != NX_CRYPTO_SUCCESS) { return(status); - } + } } #endif @@ -574,10 +577,10 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; working_ptr = &_nx_secure_padded_signature[data_size - signature_length]; /* Copy in the DER encoding. */ - NX_SECURE_MEMCPY(&working_ptr[0], _NX_SECURE_OID_SHA256, 19); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&working_ptr[0], _NX_SECURE_OID_SHA256, 19); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ /* Now put the data into the padded buffer - must be at the end. */ - NX_SECURE_MEMCPY(&working_ptr[19], handshake_hash, 32); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&working_ptr[19], handshake_hash, 32); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } #endif @@ -618,7 +621,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; #endif #ifdef NX_SECURE_KEY_CLEAR - /* At this point, the handshake_hash has been copied into _nx_secure_padded_signature and + /* At this point, the handshake_hash has been copied into _nx_secure_padded_signature and is no longer needed so we can clear it here. */ NX_SECURE_MEMSET(handshake_hash, 0, sizeof(handshake_hash)); #endif /* NX_SECURE_KEY_CLEAR */ @@ -655,9 +658,9 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; { #ifdef NX_SECURE_KEY_CLEAR NX_SECURE_MEMSET(_nx_secure_padded_signature, 0, sizeof(_nx_secure_padded_signature)); -#endif /* NX_SECURE_KEY_CLEAR */ +#endif /* NX_SECURE_KEY_CLEAR */ return(status); - } + } } else { @@ -677,9 +680,9 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; { #ifdef NX_SECURE_KEY_CLEAR NX_SECURE_MEMSET(_nx_secure_padded_signature, 0, sizeof(_nx_secure_padded_signature)); -#endif /* NX_SECURE_KEY_CLEAR */ +#endif /* NX_SECURE_KEY_CLEAR */ return(status); - } + } } if (public_cipher_method -> nx_crypto_operation != NX_NULL) @@ -703,9 +706,9 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; { #ifdef NX_SECURE_KEY_CLEAR NX_SECURE_MEMSET(_nx_secure_padded_signature, 0, sizeof(_nx_secure_padded_signature)); -#endif /* NX_SECURE_KEY_CLEAR */ +#endif /* NX_SECURE_KEY_CLEAR */ return(status); - } + } } if (public_cipher_method -> nx_crypto_cleanup) @@ -716,9 +719,9 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; { #ifdef NX_SECURE_KEY_CLEAR NX_SECURE_MEMSET(_nx_secure_padded_signature, 0, sizeof(_nx_secure_padded_signature)); -#endif /* NX_SECURE_KEY_CLEAR */ +#endif /* NX_SECURE_KEY_CLEAR */ return(status); - } + } } } @@ -799,7 +802,7 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; ec_pubkey = &local_certificate -> nx_secure_x509_public_key.ec_public_key; /* Find out which named curve the local certificate is using. */ - status = _nx_secure_tls_find_curve_method(tls_session, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); + status = _nx_secure_tls_find_curve_method(&tls_session -> nx_secure_tls_ecc, (USHORT)(ec_privkey -> nx_secure_ec_named_curve), &curve_method_cert, NX_NULL); #ifdef NX_SECURE_KEY_CLEAR if(status != NX_SUCCESS || curve_method_cert == NX_NULL) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_client_key_exchange.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_client_key_exchange.c index 63c636dc..5828f905 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_client_key_exchange.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_client_key_exchange.c @@ -25,14 +25,12 @@ #include "nx_secure_tls.h" -static UCHAR _nx_secure_client_padded_pre_master[600]; - /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_send_client_key_exchange PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -55,10 +53,8 @@ static UCHAR _nx_secure_client_padded_pre_master[600]; /* */ /* CALLS */ /* */ -/* _nx_secure_x509_remote_endpoint_certificate_get */ -/* Get cert for remote host */ -/* [nx_crypto_operation] Public-key ciphers */ -/* [nx_crypto_init] Initialize Crypto Method */ +/* [nx_secure_generate_client_key_exchange] */ +/* Generate ClientKeyExchange */ /* _nx_secure_tls_remote_certificate_free_all */ /* Free all remote certificates */ /* */ @@ -80,35 +76,18 @@ static UCHAR _nx_secure_client_padded_pre_master[600]; /* size and then improved code */ /* coverage, resulting in */ /* version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_send_client_key_exchange(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *send_packet) { -UINT status; -UINT data_size; -UCHAR *encrypted_data_ptr; -UCHAR *packet_buffer; -UCHAR rand_byte; -UINT i; -const NX_CRYPTO_METHOD *public_cipher_method; -NX_SECURE_X509_CERT *remote_certificate; -VOID *handler = NX_NULL; -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE -NX_CRYPTO_EXTENDED_OUTPUT extended_output; -#endif /* NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE */ - - /* Send a ClientKeyExchange message. - * Structure: - * | 2 | | - * | Length | Encrypted Pre-Master Secret | - * - * ECDHE ephemeral key structure: - * | 2 | | - * | Length | EC Diffie-Hellman Client Params | - */ - - packet_buffer = send_packet -> nx_packet_append_ptr; +#if !defined(NX_SECURE_TLS_CLIENT_DISABLED) +UINT status; +ULONG data_size = 0; +ULONG buffer_length; if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) { @@ -117,218 +96,30 @@ NX_CRYPTO_EXTENDED_OUTPUT extended_output; return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); } -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDH || - tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE) - { - data_size = (UINT)(1 + tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[0]); - - if ((data_size > sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data)) || - (data_size > ((ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(send_packet -> nx_packet_append_ptr)))) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); - /* Packet buffer too small. */ - return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL); - } - - NX_SECURE_MEMCPY(packet_buffer, tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data, data_size); /* Use case of memcpy is verified. */ - } - else -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ + buffer_length = (ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(send_packet -> nx_packet_append_ptr); + + status = tls_session -> nx_secure_generate_client_key_exchange(tls_session -> nx_secure_tls_session_ciphersuite, + &tls_session -> nx_secure_tls_key_material, &tls_session -> nx_secure_tls_credentials, + send_packet -> nx_packet_append_ptr, + buffer_length, + &data_size, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, + tls_session -> nx_secure_public_auth_metadata_size); + if (status) { - - /* Pointer to the output encrypted pre-master secret. */ - encrypted_data_ptr = &packet_buffer[2]; - -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - /* Check for PSK ciphersuites. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK) - { - if ((tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_id_hint_size > - sizeof(tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_id_hint)) || - (tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_id_hint_size > - (((ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(send_packet -> nx_packet_append_ptr)) - 2))) - { - - /* Packet buffer too small. */ - return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL); - } - - /* Send the PSK Identity string to the remote server along with its length. */ - NX_SECURE_MEMCPY(encrypted_data_ptr, tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_id, - tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_id_size); /* Use case of memcpy is verified. */ - - /* Make sure our size is correct. */ - data_size = tls_session -> nx_secure_tls_credentials.nx_secure_tls_client_psk.nx_secure_tls_psk_id_size; - - /* Put the length into our outgoing packet buffer. */ - packet_buffer[0] = (UCHAR)((data_size & 0xFF00) >> 8); - packet_buffer[1] = (UCHAR)(data_size & 0x00FF); - - data_size += 2; - } - else -#endif -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE) - { - data_size = 0; - public_cipher_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth; - - extended_output.nx_crypto_extended_output_data = packet_buffer; - extended_output.nx_crypto_extended_output_length_in_byte = - (ULONG)send_packet -> nx_packet_data_end - (ULONG)packet_buffer; - extended_output.nx_crypto_extended_output_actual_size = 0; - status = public_cipher_method -> nx_crypto_operation(NX_CRYPTO_ECJPAKE_CLIENT_KEY_EXCHANGE_GENERATE, - tls_session -> nx_secure_public_auth_handler, - (NX_CRYPTO_METHOD*)public_cipher_method, - NX_NULL, 0, - NX_NULL, 0, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - if (status) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); - return(status); - } - - data_size += extended_output.nx_crypto_extended_output_actual_size; - } - else -#endif - { - - /* Extract the data to be verified from the remote certificate processed earlier. */ - status = _nx_secure_x509_remote_endpoint_certificate_get(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, - &remote_certificate); - - if (status) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); - - /* No certificate found, error! */ - return(NX_SECURE_TLS_NO_CERT_SPACE_ALLOCATED); - } - - /* Get the public cipher method from the ciphersuite. */ - public_cipher_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher; - - /* If using RSA, the length is equal to the key size. */ - data_size = remote_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus_length; - - /* check data_size */ - if ((data_size < NX_SECURE_TLS_RSA_PREMASTER_SIZE + 1) || - (((ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(send_packet -> nx_packet_append_ptr)) < (2u + data_size))) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); - - /* Invalid certificate modulus length. */ - return(NX_SECURE_TLS_INVALID_CERTIFICATE); - } - - /* PKCS#1 v1.5 padding. The scheme is to start with the block type (0x00, 0x02 for PKCS#1) - then pad with non-zero bytes (random is cryptographically more secure), followed with - a single 0 byte right before the payload, which comes at the end of the RSA block. */ - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0x0, sizeof(_nx_secure_client_padded_pre_master)); - _nx_secure_client_padded_pre_master[1] = 0x2; /* Block type is 0x00, 0x02 */ - for (i = 2; i < (data_size - NX_SECURE_TLS_RSA_PREMASTER_SIZE - 1); ++i) - { - /* PKCS#1 padding must be random, but CANNOT be 0. */ - do - { - rand_byte = (UCHAR)NX_RAND(); - } while (rand_byte == 0); - _nx_secure_client_padded_pre_master[i] = rand_byte; - } - - /* Now put the pre-master data into the padded buffer - must be at the end. */ - NX_SECURE_MEMCPY(&_nx_secure_client_padded_pre_master[data_size - NX_SECURE_TLS_RSA_PREMASTER_SIZE], - tls_session -> nx_secure_tls_key_material.nx_secure_tls_pre_master_secret, NX_SECURE_TLS_RSA_PREMASTER_SIZE); /* Use case of memcpy is verified. */ - - if (public_cipher_method -> nx_crypto_init != NX_NULL) - { - /* Initialize the crypto method with public key. */ - status = public_cipher_method -> nx_crypto_init((NX_CRYPTO_METHOD*)public_cipher_method, - (UCHAR *)remote_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus, - (NX_CRYPTO_KEY_SIZE)(remote_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_modulus_length << 3), - &handler, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size); - - if(status != NX_CRYPTO_SUCCESS) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0, sizeof(_nx_secure_client_padded_pre_master)); -#endif /* NX_SECURE_KEY_CLEAR */ - - return(status); - } - } - - if (public_cipher_method -> nx_crypto_operation != NX_NULL) - { - /* Now encrypt the pre-master secret using the public key provided by the remote host - and place the result in the outgoing packet buffer. */ - status = public_cipher_method -> nx_crypto_operation(NX_CRYPTO_DECRYPT, - handler, - (NX_CRYPTO_METHOD*)public_cipher_method, - (UCHAR *)remote_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_exponent, - (NX_CRYPTO_KEY_SIZE)(remote_certificate -> nx_secure_x509_public_key.rsa_public_key.nx_secure_rsa_public_exponent_length << 3), - _nx_secure_client_padded_pre_master, - data_size, - NX_NULL, - encrypted_data_ptr, - data_size, - tls_session -> nx_secure_public_cipher_metadata_area, - tls_session -> nx_secure_public_cipher_metadata_size, - NX_NULL, NX_NULL); - - if(status != NX_CRYPTO_SUCCESS) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0, sizeof(_nx_secure_client_padded_pre_master)); -#endif /* NX_SECURE_KEY_CLEAR */ - - return(status); - } - } - - if (public_cipher_method -> nx_crypto_cleanup) - { - status = public_cipher_method -> nx_crypto_cleanup(tls_session -> nx_secure_public_cipher_metadata_area); - - if(status != NX_CRYPTO_SUCCESS) - { - _nx_secure_tls_remote_certificate_free_all(tls_session); -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0, sizeof(_nx_secure_client_padded_pre_master)); -#endif /* NX_SECURE_KEY_CLEAR */ - - return(status); - } - } - - /* Put the length into our outgoing packet buffer. */ - packet_buffer[0] = (UCHAR)((data_size & 0xFF00) >> 8); - packet_buffer[1] = (UCHAR)(data_size & 0x00FF); - - data_size += 2; - } + _nx_secure_tls_remote_certificate_free_all(tls_session); + return(status); } - /* Let the caller know how many bytes we wrote. +2 for the length we just added. */ send_packet -> nx_packet_append_ptr = send_packet -> nx_packet_append_ptr + data_size; send_packet -> nx_packet_length = send_packet -> nx_packet_length + data_size; -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_nx_secure_client_padded_pre_master, 0, sizeof(_nx_secure_client_padded_pre_master)); -#endif /* NX_SECURE_KEY_CLEAR */ - return(NX_SECURE_TLS_SUCCESS); +#else + NX_PARAMETER_NOT_USED(tls_session); + NX_PARAMETER_NOT_USED(send_packet); + return(NX_SECURE_TLS_INVALID_STATE); +#endif } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello.c index 67c99d29..5c834c0c 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello.c @@ -177,7 +177,7 @@ ULONG extension_length, total_extensions_length; gmt_time = tls_session -> nx_secure_tls_session_time_function(); } NX_CHANGE_ULONG_ENDIAN(gmt_time); - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, (UCHAR *)&gmt_time, sizeof(gmt_time)); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, (UCHAR *)&gmt_time, sizeof(gmt_time)); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) if (tls_session -> nx_secure_tls_client_state == NX_SECURE_TLS_CLIENT_STATE_HELLO_RETRY) @@ -200,7 +200,7 @@ ULONG extension_length, total_extensions_length; } /* Copy the random data into the packet. */ - NX_SECURE_MEMCPY(&packet_buffer[length], tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, + NX_SECURE_MEMCPY(&packet_buffer[length], tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random, /* lgtm[cpp/banned-api-usage-required-any] */ sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random)); /* Use case of memcpy is verified. */ } length += sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_random); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c index 08657fdc..bb1c19d4 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_clienthello_extensions.c @@ -34,10 +34,12 @@ static UINT _nx_secure_tls_send_clienthello_sig_extension(NX_SECURE_TLS_SESSION UCHAR *packet_buffer, ULONG *packet_offset, USHORT *extension_length, ULONG available_size); +#ifndef NX_SECURE_TLS_SNI_EXTENSION_DISABLED static UINT _nx_secure_tls_send_clienthello_sni_extension(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, ULONG *packet_offset, USHORT *extension_length, ULONG available_size); +#endif #ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE static UINT _nx_secure_tls_send_clienthello_sec_spf_extensions(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, ULONG *packet_offset, @@ -1430,7 +1432,7 @@ UINT data_length; offset += 2; /* Write the name into the packet. */ - NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_sni_extension_server_name -> nx_secure_x509_dns_name, data_length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_sni_extension_server_name -> nx_secure_x509_dns_name, data_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ offset += data_length; /* Return the amount of data we wrote. */ @@ -1605,7 +1607,7 @@ UINT data_length; offset++; /* Copy the verify data into the packet. */ - NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_local_verify_data, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_local_verify_data, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ offset += NX_SECURE_TLS_FINISHED_HASH_SIZE; } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_finished.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_finished.c index 22695b83..b9ef2293 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_finished.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_finished.c @@ -119,7 +119,7 @@ UINT is_server; #ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION /* If we are doing secure renegotiation as per RFC 5746, we need to save off the generated verify data now. For TLS 1.0-1.2 this is 12 bytes. If SSLv3 is ever used, it will be 36 bytes. */ - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_local_verify_data, send_packet -> nx_packet_append_ptr, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_local_verify_data, send_packet -> nx_packet_append_ptr, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ #endif /* The finished verify data is always 12 bytes for TLS 1.2 and earlier. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_handshake_record.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_handshake_record.c index 6576f020..17eba189 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_handshake_record.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_handshake_record.c @@ -138,7 +138,7 @@ UINT buffer_offset; if (handshake_type == NX_SECURE_TLS_CLIENT_HELLO) #endif /* (NX_SECURE_TLS_TLS_1_3_ENABLED) */ { - NX_SECURE_MEMCPY(&tls_session->nx_secure_tls_key_material.nx_secure_tls_handshake_cache[buffer_offset], + NX_SECURE_MEMCPY(&tls_session->nx_secure_tls_key_material.nx_secure_tls_handshake_cache[buffer_offset], /* lgtm[cpp/banned-api-usage-required-any] */ current_packet -> nx_packet_prepend_ptr, (UINT)length); /* Use case of memcpy is verified. */ /* Advance the length. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_record.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_record.c index 3a47e59f..a825cfcc 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_record.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_record.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_send_record PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -93,6 +93,9 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), */ /* improved internal logic, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* checked seq number overflow,*/ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_send_record(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *send_packet, @@ -318,6 +321,14 @@ NX_PACKET *current_packet; { /* Check for overflow of the 32-bit number. */ tls_session -> nx_secure_tls_local_sequence_number[1]++; + + if (tls_session -> nx_secure_tls_local_sequence_number[1] == 0) + { + + /* Check for overflow of the 64-bit unsigned number. As it should not reach here + in practical, we return a general error to prevent overflow theoretically. */ + return(NX_NOT_SUCCESSFUL); + } } tls_session -> nx_secure_tls_local_sequence_number[0]++; } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_server_key_exchange.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_server_key_exchange.c index deb981c4..d1208452 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_server_key_exchange.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_server_key_exchange.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_send_server_key_exchange PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -51,9 +51,8 @@ /* */ /* CALLS */ /* */ -/* _nx_secure_tlx_ecc_generate_keys Generate keys for ECC exchange*/ -/* [nx_crypto_init] Initialize Crypto Method */ -/* [nx_crypto_operation] Crypto operation */ +/* [nx_secure_generate_server_key_exchange] */ +/* Generate ServerKeyExchange */ /* */ /* CALLED BY */ /* */ @@ -68,35 +67,21 @@ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* verified memcpy use cases, */ /* resulting in version 6.1 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_send_server_key_exchange(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET *send_packet) { -UINT length; +#ifndef NX_SECURE_TLS_SERVER_DISABLED +ULONG length; const NX_SECURE_TLS_CIPHERSUITE_INFO *ciphersuite; -#if defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) UINT status; -#endif /* defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) */ +VOID *tls_ecc_curves = NX_NULL; +UCHAR tls_1_3 = 0; -#if defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) -UCHAR *packet_buffer; -#endif /* defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) || defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) || defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) */ - -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES -USHORT identity_length; -UCHAR *identity; -#endif - -#if defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) -USHORT named_curve; -NX_CRYPTO_METHOD *crypto_method; -NX_CRYPTO_EXTENDED_OUTPUT extended_output; -#endif /* defined(NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) */ - -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE -NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecdhe_data; -#endif /* Build up the server key exchange message. Structure: @@ -114,112 +99,30 @@ NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecdhe_data; length = 0; - /* In the future, any Diffie-Hellman-based ciphersuites will populate this message with key - data. RSA ciphersuites do not use this message. */ - -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - - /* Get a pointer to fill our packet. */ - packet_buffer = send_packet -> nx_packet_append_ptr; - - /* Check for PSK ciphersuites. */ - if (ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK) - { - /* If PSK is being used, the server sends an identity value to the client so - the client can respond with the appropriate PSK. */ - - /* Get identity hint and length. */ - identity = tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_id_hint; - identity_length = (USHORT)tls_session -> nx_secure_tls_credentials.nx_secure_tls_psk_store[0].nx_secure_tls_psk_id_hint_size; - - if ((identity_length + 2u) > ((ULONG)(send_packet -> nx_packet_data_end) - (ULONG)packet_buffer)) - { - - /* Packet buffer too small. */ - return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL); - } - - /* Use identity hint length for key data length. */ - packet_buffer[length] = (UCHAR)((identity_length & 0xFF00) >> 8); - packet_buffer[length + 1] = (UCHAR)(identity_length & 0x00FF); - length = (USHORT)(length + 2); - - /* Extract the identity hint and put it into the packet buffer. */ - NX_SECURE_MEMCPY(&packet_buffer[length], identity, identity_length); /* Use case of memcpy is verified. */ - - /* Advance our total length. */ - length = (USHORT)(length + identity_length); - } +#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE + tls_ecc_curves = &tls_session -> nx_secure_tls_ecc; #endif -#ifdef NX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE - - /* Check for ECJ-PAKE ciphersuites. */ - if (ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECJPAKE) - { - - /* Get a pointer to fill our packet. */ - packet_buffer = send_packet -> nx_packet_append_ptr; - - if (((ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(&packet_buffer[length])) < 3) - { - - /* Packet buffer too small. */ - return(NX_SECURE_TLS_PACKET_BUFFER_TOO_SMALL); - } - - /* ECCurveType: named_curve (3). */ - packet_buffer[length] = 3; - length += 1; - - /* NamedCurve: secp256r1 (23) */ - named_curve = (USHORT)NX_CRYPTO_EC_SECP256R1; - packet_buffer[length] = (UCHAR)((named_curve >> 8) & 0xFF); - packet_buffer[length + 1] = (UCHAR)(named_curve & 0xFF); - length += 2; - - extended_output.nx_crypto_extended_output_data = &packet_buffer[length]; - extended_output.nx_crypto_extended_output_length_in_byte = - (ULONG)send_packet -> nx_packet_data_end - (ULONG)&packet_buffer[length]; - extended_output.nx_crypto_extended_output_actual_size = 0; - - crypto_method = (NX_CRYPTO_METHOD*)ciphersuite -> nx_secure_tls_public_auth; - status = crypto_method -> nx_crypto_operation(NX_CRYPTO_ECJPAKE_SERVER_KEY_EXCHANGE_GENERATE, - &tls_session -> nx_secure_public_auth_handler, - crypto_method, - NX_NULL, 0, - NX_NULL, 0, NX_NULL, - (UCHAR *)&extended_output, - sizeof(extended_output), - tls_session -> nx_secure_public_auth_metadata_area, - tls_session -> nx_secure_public_auth_metadata_size, - NX_NULL, NX_NULL); - if (status) - { - return(status); - } - length += extended_output.nx_crypto_extended_output_actual_size; - } +#if (NX_SECURE_TLS_TLS_1_3_ENABLED) + tls_1_3 = tls_session -> nx_secure_tls_1_3; #endif -#ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE - /* Check for ECDHE ciphersuites. */ - if (ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE) + status = tls_session -> nx_secure_generate_server_key_exchange(ciphersuite, tls_session -> nx_secure_tls_protocol_version, tls_1_3, + tls_session -> nx_secure_tls_crypto_table, &tls_session -> nx_secure_tls_handshake_hash, + &tls_session -> nx_secure_tls_key_material, &tls_session -> nx_secure_tls_credentials, + send_packet -> nx_packet_append_ptr, + (ULONG)(send_packet -> nx_packet_data_end) - (ULONG)(send_packet -> nx_packet_append_ptr), + &length, tls_session -> nx_secure_public_cipher_metadata_area, + tls_session -> nx_secure_public_cipher_metadata_size, + tls_session -> nx_secure_public_auth_metadata_area, + tls_session -> nx_secure_public_auth_metadata_size, + tls_ecc_curves); + + if (status) { - ecdhe_data = (NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *)tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data; - packet_buffer = send_packet -> nx_packet_append_ptr; - length = (UINT)(send_packet->nx_packet_data_end - send_packet->nx_packet_append_ptr); - - status = _nx_secure_tls_ecc_generate_keys(tls_session, ecdhe_data -> nx_secure_tls_ecdhe_named_curve, NX_TRUE, - packet_buffer, &length, ecdhe_data); - - if (status != NX_SUCCESS) - { - return(status); - } + return(status); } -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ /* Finally, we have a complete length and can adjust our packet accordingly. */ @@ -227,5 +130,10 @@ NX_SECURE_TLS_ECDHE_HANDSHAKE_DATA *ecdhe_data; send_packet -> nx_packet_length = send_packet -> nx_packet_length + length; return(NX_SECURE_TLS_SUCCESS); +#else + NX_PARAMETER_NOT_USED(tls_session); + NX_PARAMETER_NOT_USED(send_packet); + return(NX_SECURE_TLS_INVALID_STATE); +#endif } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello.c index ca860af7..8ab3a460 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello.c @@ -140,7 +140,7 @@ UINT status; } NX_CHANGE_ULONG_ENDIAN(gmt_time); - NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, (UCHAR *)&gmt_time, sizeof(gmt_time)); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, (UCHAR *)&gmt_time, sizeof(gmt_time)); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ #if (NX_SECURE_TLS_TLS_1_3_ENABLED) if (tls_session -> nx_secure_tls_server_state == NX_SECURE_TLS_SERVER_STATE_SEND_HELLO_RETRY) @@ -193,7 +193,7 @@ UINT status; } /* Copy the random data into the packet. */ - NX_SECURE_MEMCPY(&packet_buffer[length], tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, + NX_SECURE_MEMCPY(&packet_buffer[length], tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random, /* lgtm[cpp/banned-api-usage-required-any] */ sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random)); /* Use case of memcpy is verified. */ length += sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_random); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c index 08ce5aab..0339c209 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_send_serverhello_extensions.c @@ -365,9 +365,9 @@ UINT data_length; offset++; /* Copy the verify data into the packet. */ - NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_remote_verify_data, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_remote_verify_data, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ offset += NX_SECURE_TLS_FINISHED_HASH_SIZE; - NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_local_verify_data, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(&packet_buffer[offset], tls_session -> nx_secure_tls_local_verify_data, NX_SECURE_TLS_FINISHED_HASH_SIZE); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ offset += NX_SECURE_TLS_FINISHED_HASH_SIZE; } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_server_handshake.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_server_handshake.c index 4e0cd935..6a747bea 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_server_handshake.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_server_handshake.c @@ -31,7 +31,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_server_handshake PORTABLE C */ -/* 6.1.4 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -59,7 +59,6 @@ /* _nx_secure_tls_generate_keys Generate session keys */ /* _nx_secure_tls_handshake_hash_init Initialize Finished hash */ /* _nx_secure_tls_handshake_hash_update Update Finished hash */ -/* _nx_secure_tls_map_error_to_alert Map internal error to alert */ /* _nx_secure_tls_packet_allocate Allocate internal TLS packet */ /* _nx_secure_tls_process_client_key_exchange */ /* Process ClientKeyExchange */ @@ -69,7 +68,6 @@ /* Process handshake header */ /* _nx_secure_tls_process_remote_certificate */ /* Process server certificate */ -/* _nx_secure_tls_send_alert Send TLS alert */ /* _nx_secure_tls_send_certificate Send TLS certificate */ /* _nx_secure_tls_send_certificate_request */ /* Send TLS CertificateRequest */ @@ -107,6 +105,13 @@ /* support for fragmented TLS */ /* Handshake messages, */ /* resulting in version 6.1.4 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), */ +/* removed duplicated alert, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* fixed handling of multiple */ +/* handshake messages, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_server_handshake(NX_SECURE_TLS_SESSION *tls_session, UCHAR *packet_buffer, @@ -121,9 +126,6 @@ UINT message_length; NX_PACKET *send_packet; NX_PACKET_POOL *packet_pool; UCHAR *packet_start; -UINT error_number; -UINT alert_number; -UINT alert_level; const NX_CRYPTO_METHOD *method_ptr = NX_NULL; /* Basic state machine for handshake: @@ -132,151 +134,131 @@ const NX_CRYPTO_METHOD *method_ptr = NX_NULL; * 3. Follow up with whatever actions are needed. */ - /* Save a pointer to the start of our packet for the hash that happens below. */ - packet_start = packet_buffer; - - header_bytes = data_length; - - status = _nx_secure_tls_process_handshake_header(packet_buffer, &message_type, &header_bytes, &message_length); - - if (status != NX_SECURE_TLS_SUCCESS) + /* Loop through multiple messages in a single record. This can happen if the remote host + packs multiple handshake messages into a single TLS record. */ + while (data_length > 0) { - return(status); - } - /* Check for fragmented message. */ - if((message_length + header_bytes) > data_length) - { - /* Incomplete message! A single message is fragmented across several records. We need to obtain the next fragment. */ - tls_session -> nx_secure_tls_handshake_record_expected_length = message_length + header_bytes; + /* Save a pointer to the start of our packet for the hash that happens below. */ + packet_start = packet_buffer; - tls_session -> nx_secure_tls_handshake_record_fragment_state = NX_SECURE_TLS_HANDSHAKE_RECEIVED_FRAGMENT; + header_bytes = data_length; - return(NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED); - } + status = _nx_secure_tls_process_handshake_header(packet_buffer, &message_type, &header_bytes, &message_length); - /* Advance the buffer pointer past the handshake header. */ - packet_buffer += header_bytes; + if (status != NX_SECURE_TLS_SUCCESS) + { + return(status); + } - /* Get reference to the packet pool so we can allocate a packet for all send operations. */ - packet_pool = tls_session -> nx_secure_tls_packet_pool; + /* Check for fragmented message. */ + if((message_length + header_bytes) > data_length) + { + /* Incomplete message! A single message is fragmented across several records. We need to obtain the next fragment. */ + tls_session -> nx_secure_tls_handshake_record_expected_length = message_length + header_bytes; - /* We need to hash all of the handshake messages that we receive and send. If this message is a ClientHello, - then we need to initialize the hashes (TLS 1.1 uses both MD5 and SHA-1). The final hash is generated - in the "Finished" message. */ - if (message_type == NX_SECURE_TLS_CLIENT_HELLO) - { - /* Initialize the handshake hashes used for the Finished message. */ - _nx_secure_tls_handshake_hash_init(tls_session); - } + tls_session -> nx_secure_tls_handshake_record_fragment_state = NX_SECURE_TLS_HANDSHAKE_RECEIVED_FRAGMENT; - /* Process the message itself information from the header. */ - status = NX_SECURE_TLS_SUCCESS; - switch (message_type) - { - case NX_SECURE_TLS_CLIENT_HELLO: - /* Client is establishing a TLS session with our server. */ - status = _nx_secure_tls_process_clienthello(tls_session, packet_buffer, message_length); - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_SEND_HELLO; - break; -#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY - case NX_SECURE_TLS_CERTIFICATE_MSG: - /* Client sent certificate message (in response to a request from us. Process it now. */ - status = _nx_secure_tls_process_remote_certificate(tls_session, packet_buffer, message_length, data_length); - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE; - break; - case NX_SECURE_TLS_CERTIFICATE_VERIFY: - /* Client has responded to a certificate request with a CertificateVerify message. */ - status = _nx_secure_tls_process_certificate_verify(tls_session, packet_buffer, message_length); - - if(status == NX_SUCCESS) - { - /* If remote certificate verification was a success, we have received credentials - from the remote host and may now pass Finished message processing once received. */ - tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; + return(NX_SECURE_TLS_HANDSHAKE_FRAGMENT_RECEIVED); } - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY; - break; -#endif /* NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY */ - case NX_SECURE_TLS_CLIENT_KEY_EXCHANGE: - /* Received a client key exchange message, meaning it is time to generate keys if we can. */ - status = _nx_secure_tls_process_client_key_exchange(tls_session, packet_buffer, message_length, NX_SECURE_TLS); - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE; + /* Advance the buffer pointer past the handshake header. */ + packet_buffer += header_bytes; - if (status == NX_SECURE_TLS_SUCCESS) - { - /* Generate our key material from the data collected thus far and put it all into our - socket structure. */ - status = _nx_secure_tls_generate_keys(tls_session); - } - break; - case NX_SECURE_TLS_FINISHED: - /* Final handshake message from the client, process it (verify the client handshake hash). */ - status = _nx_secure_tls_process_finished(tls_session, packet_buffer, message_length); - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE; - break; - case NX_SECURE_TLS_HELLO_VERIFY_REQUEST: - case NX_SECURE_TLS_HELLO_REQUEST: - case NX_SECURE_TLS_SERVER_HELLO: - case NX_SECURE_TLS_SERVER_KEY_EXCHANGE: - case NX_SECURE_TLS_CERTIFICATE_REQUEST: - case NX_SECURE_TLS_SERVER_HELLO_DONE: - case NX_SECURE_TLS_CERTIFICATE_URL: - case NX_SECURE_TLS_CERTIFICATE_STATUS: - default: - /* The message received was not a valid TLS server handshake message, send alert and return. */ - status = NX_SECURE_TLS_UNEXPECTED_MESSAGE; - break; - } - - /* Check for errors in processing messages. */ - if (status != NX_SECURE_TLS_SUCCESS) - { - /* If we encountered an error in message processing set the state to the error condition. */ - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_ERROR; - } - else - { - /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them, - we do not worry about them here because these are only messages received from the client at this point. - Hashes include the handshake layer header but not the record layer header. */ - _nx_secure_tls_handshake_hash_update(tls_session, packet_start, (UINT)(message_length + header_bytes)); - } - - /* Now take any actions based on state set in the message processing. */ - switch (tls_session -> nx_secure_tls_server_state) - { - case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO: - /* We have received and processed a client hello. Now respond to the client appropriately. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + /* Get reference to the packet pool so we can allocate a packet for all send operations. */ + packet_pool = tls_session -> nx_secure_tls_packet_pool; - if (status != NX_SUCCESS) + /* We need to hash all of the handshake messages that we receive and send. If this message is a ClientHello, + then we need to initialize the hashes (TLS 1.1 uses both MD5 and SHA-1). The final hash is generated + in the "Finished" message. */ + if (message_type == NX_SECURE_TLS_CLIENT_HELLO) { - break; + /* Initialize the handshake hashes used for the Finished message. */ + _nx_secure_tls_handshake_hash_init(tls_session); } - status = _nx_secure_tls_send_serverhello(tls_session, send_packet); + /* Reduce total length by the size of this message. */ + data_length -= (message_length + header_bytes); - if (status != NX_SUCCESS) + /* Process the message itself information from the header. */ + status = NX_SECURE_TLS_SUCCESS; + switch (message_type) { + case NX_SECURE_TLS_CLIENT_HELLO: + /* Client is establishing a TLS session with our server. */ + status = _nx_secure_tls_process_clienthello(tls_session, packet_buffer, message_length); + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_SEND_HELLO; break; - } +#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY + case NX_SECURE_TLS_CERTIFICATE_MSG: + /* Client sent certificate message (in response to a request from us. Process it now. */ + status = _nx_secure_tls_process_remote_certificate(tls_session, packet_buffer, message_length, data_length); + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE; + break; + case NX_SECURE_TLS_CERTIFICATE_VERIFY: + /* Client has responded to a certificate request with a CertificateVerify message. */ + status = _nx_secure_tls_process_certificate_verify(tls_session, packet_buffer, message_length); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option); + if(status == NX_SUCCESS) + { + /* If remote certificate verification was a success, we have received credentials + from the remote host and may now pass Finished message processing once received. */ + tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; + } - if (status != NX_SUCCESS) - { + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY; + break; +#endif /* NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY */ + case NX_SECURE_TLS_CLIENT_KEY_EXCHANGE: + /* Received a client key exchange message, meaning it is time to generate keys if we can. */ + status = _nx_secure_tls_process_client_key_exchange(tls_session, packet_buffer, message_length, NX_SECURE_TLS); + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE; + + if (status == NX_SECURE_TLS_SUCCESS) + { + /* Generate our key material from the data collected thus far and put it all into our + socket structure. */ + status = _nx_secure_tls_generate_keys(tls_session); + } + break; + case NX_SECURE_TLS_FINISHED: + /* Final handshake message from the client, process it (verify the client handshake hash). */ + status = _nx_secure_tls_process_finished(tls_session, packet_buffer, message_length); + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE; + break; + case NX_SECURE_TLS_HELLO_VERIFY_REQUEST: + case NX_SECURE_TLS_HELLO_REQUEST: + case NX_SECURE_TLS_SERVER_HELLO: + case NX_SECURE_TLS_SERVER_KEY_EXCHANGE: + case NX_SECURE_TLS_CERTIFICATE_REQUEST: + case NX_SECURE_TLS_SERVER_HELLO_DONE: + case NX_SECURE_TLS_CERTIFICATE_URL: + case NX_SECURE_TLS_CERTIFICATE_STATUS: + default: + /* The message received was not a valid TLS server handshake message, send alert and return. */ + status = NX_SECURE_TLS_UNEXPECTED_MESSAGE; break; } - NX_ASSERT(tls_session -> nx_secure_tls_session_ciphersuite != NX_NULL); + /* Check for errors in processing messages. */ + if (status != NX_SECURE_TLS_SUCCESS) + { + /* If we encountered an error in message processing set the state to the error condition. */ + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_ERROR; + } + else + { + /* Hash this handshake message. We do not hash HelloRequest messages, but since only the server will send them, + we do not worry about them here because these are only messages received from the client at this point. + Hashes include the handshake layer header but not the record layer header. */ + _nx_secure_tls_handshake_hash_update(tls_session, packet_start, (UINT)(message_length + header_bytes)); + } -#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - /* For PSK ciphersuites, don't send the certificate message. */ - if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm != NX_CRYPTO_KEY_EXCHANGE_PSK) + /* Now take any actions based on state set in the message processing. */ + switch (tls_session -> nx_secure_tls_server_state) { -#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ + case NX_SECURE_TLS_SERVER_STATE_SEND_HELLO: + /* We have received and processed a client hello. Now respond to the client appropriately. */ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); if (status != NX_SUCCESS) @@ -284,55 +266,108 @@ const NX_CRYPTO_METHOD *method_ptr = NX_NULL; break; } - _nx_secure_tls_send_certificate(tls_session, send_packet, wait_option); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_MSG, wait_option); + status = _nx_secure_tls_send_serverhello(tls_session, send_packet); + + if (status != NX_SUCCESS) + { + break; + } + + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO, wait_option); + if (status != NX_SUCCESS) { break; } + NX_ASSERT(tls_session -> nx_secure_tls_session_ciphersuite != NX_NULL); + #ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - } + /* For PSK ciphersuites, don't send the certificate message. */ + if (tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm != NX_CRYPTO_KEY_EXCHANGE_PSK) + { +#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + + if (status != NX_SUCCESS) + { + break; + } + + _nx_secure_tls_send_certificate(tls_session, send_packet, wait_option); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_MSG, wait_option); + if (status != NX_SUCCESS) + { + break; + } + +#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES + } #endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ #if defined(NX_SECURE_ENABLE_ECC_CIPHERSUITE) || defined(NX_SECURE_ENABLE_PSK_CIPHERSUITES) - if (NX_FALSE + if (NX_FALSE #ifdef NX_SECURE_ENABLE_ECC_CIPHERSUITE - || tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE + || tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_cipher -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_ECDHE #endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE */ #ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES - || tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK + || tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_public_auth -> nx_crypto_algorithm == NX_CRYPTO_KEY_EXCHANGE_PSK #endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ - ) - { - /* PSK and ECDHE ciphersuites use the ServerKeyExchange message to send cryptographic information. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - - if (status != NX_SUCCESS) + ) { - break; + /* PSK and ECDHE ciphersuites use the ServerKeyExchange message to send cryptographic information. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + + if (status != NX_SUCCESS) + { + break; + } + + /* This is a PSK ciphersuite so we always send a ServerKeyExchange message. */ + status = _nx_secure_tls_send_server_key_exchange(tls_session, send_packet); + if (status != NX_SUCCESS) + { + break; + } + + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_KEY_EXCHANGE, wait_option); + if (status != NX_SUCCESS) + { + break; + } } +#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE || NX_CRYPTO_KEY_EXCHANGE_PSK */ - /* This is a PSK ciphersuite so we always send a ServerKeyExchange message. */ - status = _nx_secure_tls_send_server_key_exchange(tls_session, send_packet); - if (status != NX_SUCCESS) +#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY + /* Application has requested that we request and verify the remote Client certificate. */ + if (tls_session -> nx_secure_tls_verify_client_certificate) { - break; + /* Allocate a packet for our certificate request message. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + + if (status != NX_SUCCESS) + { + break; + } + + /* Populate our packet with the desired message (CertificateRequest). */ + status = _nx_secure_tls_send_certificate_request(tls_session, send_packet); + NX_ASSERT(status == NX_SUCCESS); + + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_REQUEST, wait_option); + if (status != NX_SUCCESS) + { + break; + } } - - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_KEY_EXCHANGE, wait_option); - if (status != NX_SUCCESS) + else +#endif { - break; + /* Server is not expecting credentials, so indicate that we have received the client's credentials + to pass Finished processing. */ + tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; } - } -#endif /* NX_SECURE_ENABLE_ECC_CIPHERSUITE || NX_CRYPTO_KEY_EXCHANGE_PSK */ - -#ifdef NX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY - /* Application has requested that we request and verify the remote Client certificate. */ - if (tls_session -> nx_secure_tls_verify_client_certificate) - { - /* Allocate a packet for our certificate request message. */ + /* Allocate a new packet for the ServerHelloDone. */ status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); if (status != NX_SUCCESS) @@ -340,193 +375,148 @@ const NX_CRYPTO_METHOD *method_ptr = NX_NULL; break; } - /* Populate our packet with the desired message (CertificateRequest). */ - status = _nx_secure_tls_send_certificate_request(tls_session, send_packet); - NX_ASSERT(status == NX_SUCCESS); + /* Server hello done message is 0 bytes, but it still has a TLS header so don't modify the length here. */ + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO_DONE, wait_option); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_CERTIFICATE_REQUEST, wait_option); if (status != NX_SUCCESS) { break; } - } - else -#endif - { - /* Server is not expecting credentials, so indicate that we have received the client's credentials - to pass Finished processing. */ - tls_session -> nx_secure_tls_received_remote_credentials = NX_TRUE; - } - /* Allocate a new packet for the ServerHelloDone. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - if (status != NX_SUCCESS) - { - break; - } - /* Server hello done message is 0 bytes, but it still has a TLS header so don't modify the length here. */ - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_SERVER_HELLO_DONE, wait_option); + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_SENT; - if (status != NX_SUCCESS) - { break; - } - - - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HELLO_SENT; - - break; - case NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE: - /* We processed the certificate above, do nothing. */ - break; - case NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY: - /* We processed the certificate above, do nothing. */ - break; - case NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE: - break; - case NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE: + case NX_SECURE_TLS_SERVER_STATE_CLIENT_CERTIFICATE: + /* We processed the certificate above, do nothing. */ + break; + case NX_SECURE_TLS_SERVER_STATE_CERTIFICATE_VERIFY: + /* We processed the certificate above, do nothing. */ + break; + case NX_SECURE_TLS_SERVER_STATE_KEY_EXCHANGE: + break; + case NX_SECURE_TLS_SERVER_STATE_FINISH_HANDSHAKE: - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); + /* Release the protection before suspending on nx_packet_allocate. */ + tx_mutex_put(&_nx_secure_tls_protection); - /* We have received everything we need to complete the handshake and keys have been - * generated above. Now end the handshake with a ChangeCipherSpec (indicating following - * messages are encrypted) and the encrypted Finished message. */ + /* We have received everything we need to complete the handshake and keys have been + * generated above. Now end the handshake with a ChangeCipherSpec (indicating following + * messages are encrypted) and the encrypted Finished message. */ - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); + status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); + /* Get the protection after nx_packet_allocate. */ + tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - if (status != NX_SUCCESS) - { - break; - } + if (status != NX_SUCCESS) + { + break; + } - _nx_secure_tls_send_changecipherspec(tls_session, send_packet); + _nx_secure_tls_send_changecipherspec(tls_session, send_packet); - /* ChangeCipherSpec is NOT a handshake message, so send as a normal TLS record. */ - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_CHANGE_CIPHER_SPEC, wait_option); + /* ChangeCipherSpec is NOT a handshake message, so send as a normal TLS record. */ + status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_CHANGE_CIPHER_SPEC, wait_option); - if (status != NX_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - break; - } + if (status != NX_SUCCESS) + { + nx_secure_tls_packet_release(send_packet); + break; + } - /* Reset the sequence number now that we are starting a new session. */ - NX_SECURE_MEMSET(tls_session -> nx_secure_tls_local_sequence_number, 0, sizeof(tls_session -> nx_secure_tls_local_sequence_number)); + /* Reset the sequence number now that we are starting a new session. */ + NX_SECURE_MEMSET(tls_session -> nx_secure_tls_local_sequence_number, 0, sizeof(tls_session -> nx_secure_tls_local_sequence_number)); - /* The local session is now active since we sent the changecipherspec message. - NOTE: Do not set the keys until after the changecipherspec message has been passed to the send record - routine - this call causes encryption and hashing to happen on records. ChangeCipherSpec should be the last - un-encrypted/un-hashed record sent. For a renegotiation handshake, CCS is the last message encrypted using - the original session keys. */ + /* The local session is now active since we sent the changecipherspec message. + NOTE: Do not set the keys until after the changecipherspec message has been passed to the send record + routine - this call causes encryption and hashing to happen on records. ChangeCipherSpec should be the last + un-encrypted/un-hashed record sent. For a renegotiation handshake, CCS is the last message encrypted using + the original session keys. */ - /* Set our local session keys since we sent a CCS message. */ - status = _nx_secure_tls_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_LOCAL); + /* Set our local session keys since we sent a CCS message. */ + status = _nx_secure_tls_session_keys_set(tls_session, NX_SECURE_TLS_KEY_SET_LOCAL); - if (status != NX_SUCCESS) - { - break; - } + if (status != NX_SUCCESS) + { + break; + } - /* We processed the incoming finished message above, so now we can send our own finished message. */ - status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); - if (status != NX_SUCCESS) - { - break; - } + /* We processed the incoming finished message above, so now we can send our own finished message. */ + status = _nx_secure_tls_allocate_handshake_packet(tls_session, packet_pool, &send_packet, wait_option); + if (status != NX_SUCCESS) + { + break; + } - _nx_secure_tls_send_finished(tls_session, send_packet); - status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_FINISHED, wait_option); + _nx_secure_tls_send_finished(tls_session, send_packet); + status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_FINISHED, wait_option); - /* For server, cleanup hash handler after sent the finished message to server. */ + /* For server, cleanup hash handler after sent the finished message to server. */ #if (NX_SECURE_TLS_TLS_1_2_ENABLED) - method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha256_method; + method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha256_method; - if (method_ptr -> nx_crypto_cleanup != NX_NULL) - { - temp_status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata); - if(temp_status != NX_CRYPTO_SUCCESS) + if (method_ptr -> nx_crypto_cleanup != NX_NULL) { - status = temp_status; - } + temp_status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha256_metadata); + if(temp_status != NX_CRYPTO_SUCCESS) + { + status = temp_status; + } - } + } #endif /* (NX_SECURE_TLS_TLS_1_2_ENABLED) */ #if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) - method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method; - if (method_ptr != NX_NULL && method_ptr -> nx_crypto_cleanup != NX_NULL) - { - temp_status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_md5_metadata); - if(temp_status != NX_CRYPTO_SUCCESS) + method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_md5_method; + if (method_ptr != NX_NULL && method_ptr -> nx_crypto_cleanup != NX_NULL) { - status = temp_status; - } + temp_status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_md5_metadata); + if(temp_status != NX_CRYPTO_SUCCESS) + { + status = temp_status; + } - } + } - method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method; - if (method_ptr != NX_NULL && method_ptr -> nx_crypto_cleanup != NX_NULL) - { - temp_status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha1_metadata); - if(temp_status != NX_CRYPTO_SUCCESS) + method_ptr = tls_session -> nx_secure_tls_crypto_table -> nx_secure_tls_handshake_hash_sha1_method; + if (method_ptr != NX_NULL && method_ptr -> nx_crypto_cleanup != NX_NULL) { - status = temp_status; - } + temp_status = method_ptr -> nx_crypto_cleanup(tls_session -> nx_secure_tls_handshake_hash.nx_secure_tls_handshake_hash_sha1_metadata); + if(temp_status != NX_CRYPTO_SUCCESS) + { + status = temp_status; + } - } + } #endif /* (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) */ - tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED; - - break; - default: /* NX_SECURE_TLS_SERVER_STATE_ERROR */ - /* Default is to break out of the switch because either we encountered an error or - we are in an invalid state. DO NOT change the value of "status" here because - we need its value in the alert processing below. NOTE: we should never - get to this branch with status == NX_SUCCESS because the state will only - be set to NX_SECURE_TLS_SERVER_STATE_ERROR if status indicates an error. */ - NX_ASSERT(status != NX_SUCCESS); - break; - } - - - /* If we have an error at this point, we have experienced a problem in processing or sending - handshake messages, which is some type of internal issue. Send an alert - back to the remote host indicating the error. */ - if (status != NX_SUCCESS) - { - /* Get our alert number and level from our status. */ - error_number = status; - _nx_secure_tls_map_error_to_alert(error_number, &alert_number, &alert_level); - - /* Release the protection before suspending on nx_packet_allocate. */ - tx_mutex_put(&_nx_secure_tls_protection); - - status = _nx_secure_tls_packet_allocate(tls_session, packet_pool, &send_packet, wait_option); + tls_session -> nx_secure_tls_server_state = NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED; - /* Get the protection after nx_packet_allocate. */ - tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - - if (status == NX_SUCCESS) + break; + default: /* NX_SECURE_TLS_SERVER_STATE_ERROR */ + /* Default is to break out of the switch because either we encountered an error or + we are in an invalid state. DO NOT change the value of "status" here because + we need its value in the alert processing below. NOTE: we should never + get to this branch with status == NX_SUCCESS because the state will only + be set to NX_SECURE_TLS_SERVER_STATE_ERROR if status indicates an error. */ + NX_ASSERT(status != NX_SUCCESS); + break; + } + + /* If we have an error at this point, we have experienced a problem in sending + handshake messages, which is some type of internal issue. */ + if (status != NX_SUCCESS) { - _nx_secure_tls_send_alert(tls_session, send_packet, (UCHAR)alert_number, (UCHAR)alert_level); - status = _nx_secure_tls_send_record(tls_session, send_packet, NX_SECURE_TLS_ALERT, wait_option); - if (status != NX_SECURE_TLS_SUCCESS) - { - nx_secure_tls_packet_release(send_packet); - } + return(status); } + + /* Advance the buffer pointer past the message. */ + packet_buffer += message_length; + } /* End while. */ - return(error_number); - } - - return(status); + return(NX_SUCCESS); #else /* TLS Server disabled. */ /* We don't use the parameters since this is an error case. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_create_ext.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_create_ext.c index 6ce0fc2e..ded70287 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_create_ext.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_create_ext.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_create_ext PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -89,6 +89,9 @@ /* added null pointer checking,*/ /* removed unused code, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), and added*/ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -967,6 +970,33 @@ ULONG metadata_size_sha256 = 0; } #endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ + /* Set the secret generation functions to the default implementation. */ + tls_session -> nx_secure_generate_premaster_secret = _nx_secure_generate_premaster_secret; + tls_session -> nx_secure_generate_master_secret = _nx_secure_generate_master_secret; + tls_session -> nx_secure_generate_session_keys = _nx_secure_generate_session_keys; + tls_session -> nx_secure_session_keys_set = _nx_secure_session_keys_set; +#ifndef NX_SECURE_TLS_CLIENT_DISABLED + tls_session -> nx_secure_process_server_key_exchange = _nx_secure_process_server_key_exchange; + tls_session -> nx_secure_generate_client_key_exchange = _nx_secure_generate_client_key_exchange; +#endif +#ifndef NX_SECURE_TLS_SERVER_DISABLED + tls_session -> nx_secure_process_client_key_exchange = _nx_secure_process_client_key_exchange; + tls_session -> nx_secure_generate_server_key_exchange = _nx_secure_generate_server_key_exchange; +#endif + tls_session -> nx_secure_verify_mac = _nx_secure_verify_mac; + tls_session -> nx_secure_remote_certificate_verify = _nx_secure_remote_certificate_verify; + tls_session -> nx_secure_trusted_certificate_add = _nx_secure_trusted_certificate_add; + +#ifdef NX_SECURE_CUSTOM_SECRET_GENERATION + + /* Customized secret generation functions can be set by the user in nx_secure_custom_secret_generation_init. */ + status = nx_secure_custom_secret_generation_init(tls_session); + if (status != NX_SUCCESS) + { + return(status); + } +#endif + /* Set ID to check initialization status. */ tls_session -> nx_secure_tls_id = NX_SECURE_TLS_ID; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_keys_set.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_keys_set.c index 3fcef0cc..e99072d8 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_keys_set.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_keys_set.c @@ -30,7 +30,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_keys_set PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -57,7 +57,7 @@ /* */ /* CALLS */ /* */ -/* [nx_crypto_init] Initialize crypto */ +/* [nx_secure_session_keys_set] Set session keys */ /* */ /* CALLED BY */ /* */ @@ -82,23 +82,16 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), and */ /* improved internal logic, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #define NX_SECURE_SOURCE_CODE UINT _nx_secure_tls_session_keys_set(NX_SECURE_TLS_SESSION *tls_session, USHORT key_set) { -UINT status; -UCHAR *key_block; /* Maximum ciphersuite key size - AES_256_CBC_SHA, 2x32 byte keys + 2x20 byte MAC secrets + 2x16 IVs. */ -UINT key_size; -UINT hash_size; -UINT iv_size; -UINT key_offset; -UINT is_client; -const NX_CRYPTO_METHOD *session_cipher_method = NX_NULL; - - /* The key material should have already been generated by nx_secure_tls_generate_keys once all - * key generation data was available. This simply switches the appropriate key data over to the active - * key block */ +UINT status; +UINT is_client; if (key_set == NX_SECURE_TLS_KEY_SET_LOCAL) { @@ -109,9 +102,6 @@ const NX_CRYPTO_METHOD *session_cipher_method = NX_NULL; tls_session -> nx_secure_tls_remote_session_active = 1; } - /* Working pointers into our key material blocks. */ - key_block = tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data; - /* See if we are setting server or client keys. */ if ((key_set == NX_SECURE_TLS_KEY_SET_REMOTE && tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_CLIENT) || (key_set == NX_SECURE_TLS_KEY_SET_LOCAL && tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER)) @@ -126,7 +116,6 @@ const NX_CRYPTO_METHOD *session_cipher_method = NX_NULL; } - if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) { @@ -134,149 +123,24 @@ const NX_CRYPTO_METHOD *session_cipher_method = NX_NULL; return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); } - /* Get our session cipher method so we can get key sizes. */ - session_cipher_method = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_session_cipher; - - /* Lookup ciphersuite data for key size. We need 2 keys for each session. */ - key_size = session_cipher_method -> nx_crypto_key_size_in_bits >> 3; - - /* Lookup ciphersuite data for hash size - used for the MAC secret. */ - hash_size = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_hash_size; - - /* Lookup initialization vector size. */ - iv_size = session_cipher_method -> nx_crypto_IV_size_in_bits >> 3; - - /* Partition the key block into our keys and secrets following the TLS spec.*/ - key_offset = 0; - - if (((hash_size + key_size + iv_size) << 1) > sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data)) - { - - /* No space for key material data. */ - return(NX_SECURE_TLS_CRYPTO_KEYS_TOO_LARGE); - } - - /* First, the mac secrets. Check for non-zero in the (unlikely) event we are using a NULL hash. */ - if (hash_size > 0) - { - - /* Copy new client mac secret over if setting client keys. */ - if (is_client) - { - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data[key_offset], - &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[key_offset], hash_size); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_write_mac_secret = key_block + key_offset; - key_offset += hash_size; - - /* Copy new server mac secret if setting server keys. */ - if (!is_client) - { - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data[key_offset], - &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[key_offset], hash_size); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_write_mac_secret = key_block + key_offset; - key_offset += hash_size; - } - - /* Now the keys. Check for non-zero size in the event we are using a NULL cipher (usually for debugging). */ - if (key_size > 0) - { - /* Copy new client session key if setting client keys. */ - if (is_client) - { - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data[key_offset], - &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[key_offset], key_size); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_write_key = key_block + key_offset; - key_offset += key_size; - - /* Copy new server session key if setting server keys. */ - if (!is_client) - { - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data[key_offset], - &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[key_offset], key_size); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_write_key = key_block + key_offset; - key_offset += key_size; - } - - /* Finally, the IVs. Many ciphers don't use IV's so the iv_size is often zero. */ - if (iv_size > 0) + /* Set client or server write key. */ + if (is_client) { - /* Copy new client IV if setting client keys. */ - if (is_client) - { - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data[key_offset], - &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[key_offset], iv_size); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_iv = key_block + key_offset; - key_offset += iv_size; - - /* Copy new server IV if setting server keys. */ - if (!is_client) - { - NX_SECURE_MEMCPY(&tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data[key_offset], - &tls_session -> nx_secure_tls_key_material.nx_secure_tls_new_key_material_data[key_offset], iv_size); /* Use case of memcpy is verified. */ - } - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_iv = key_block + key_offset; + status = tls_session -> nx_secure_session_keys_set(tls_session -> nx_secure_tls_session_ciphersuite, &tls_session -> nx_secure_tls_key_material, + sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data), + is_client, &tls_session -> nx_secure_tls_session_cipher_client_initialized, + tls_session -> nx_secure_session_cipher_metadata_area_client, &tls_session -> nx_secure_session_cipher_handler_client, + tls_session -> nx_secure_session_cipher_metadata_size); } - - /* Initialize the crypto method used in the session cipher. */ - if (session_cipher_method -> nx_crypto_init != NULL) + else { - /* Set client write key. */ - if (is_client) - { - if (tls_session -> nx_secure_tls_session_cipher_client_initialized && session_cipher_method -> nx_crypto_cleanup) - { - status = session_cipher_method -> nx_crypto_cleanup(tls_session -> nx_secure_session_cipher_metadata_area_client); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - tls_session -> nx_secure_tls_session_cipher_client_initialized = 0; - } - - status = session_cipher_method -> nx_crypto_init((NX_CRYPTO_METHOD*)session_cipher_method, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_client_write_key, - session_cipher_method -> nx_crypto_key_size_in_bits, - &tls_session -> nx_secure_session_cipher_handler_client, - tls_session -> nx_secure_session_cipher_metadata_area_client, - tls_session -> nx_secure_session_cipher_metadata_size); - - tls_session -> nx_secure_tls_session_cipher_client_initialized = 1; - } - else - { - if (tls_session -> nx_secure_tls_session_cipher_server_initialized && session_cipher_method -> nx_crypto_cleanup) - { - status = session_cipher_method -> nx_crypto_cleanup(tls_session -> nx_secure_session_cipher_metadata_area_server); - if (status != NX_CRYPTO_SUCCESS) - { - return(status); - } - - tls_session -> nx_secure_tls_session_cipher_server_initialized = 0; - } - - /* Set server write key. */ - status = session_cipher_method -> nx_crypto_init((NX_CRYPTO_METHOD*)session_cipher_method, - tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_write_key, - session_cipher_method -> nx_crypto_key_size_in_bits, - &tls_session -> nx_secure_session_cipher_handler_server, - tls_session -> nx_secure_session_cipher_metadata_area_server, - tls_session -> nx_secure_session_cipher_metadata_size); - - tls_session -> nx_secure_tls_session_cipher_server_initialized = 1; - } - if(status != NX_CRYPTO_SUCCESS) - { - return(status); - } + status = tls_session -> nx_secure_session_keys_set(tls_session -> nx_secure_tls_session_ciphersuite, &tls_session -> nx_secure_tls_key_material, + sizeof(tls_session -> nx_secure_tls_key_material.nx_secure_tls_key_material_data), + is_client, &tls_session -> nx_secure_tls_session_cipher_server_initialized, + tls_session -> nx_secure_session_cipher_metadata_area_server, &tls_session -> nx_secure_session_cipher_handler_server, + tls_session -> nx_secure_session_cipher_metadata_size); } - return(NX_SECURE_TLS_SUCCESS); + return(status); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_receive.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_receive.c index 64b01486..d6fc28e9 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_receive.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_receive.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_receive PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -73,15 +73,16 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), added */ /* conditional TLS 1.3 build, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), and */ +/* fixed renegotiation when */ +/* receiving in non-block mode,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_session_receive(NX_SECURE_TLS_SESSION *tls_session, NX_PACKET **packet_ptr_ptr, ULONG wait_option) { UINT status; -#ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION -UINT local_initiated_renegotiation = NX_FALSE; -#endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ /* Session receive logic: * 1. Receive incoming packets @@ -93,24 +94,6 @@ UINT local_initiated_renegotiation = NX_FALSE; */ -#ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION -#ifndef NX_SECURE_TLS_CLIENT_DISABLED - if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_CLIENT && - tls_session -> nx_secure_tls_client_state == NX_SECURE_TLS_CLIENT_STATE_RENEGOTIATING) - { - local_initiated_renegotiation = NX_TRUE; - } -#endif - -#ifndef NX_SECURE_TLS_SERVER_DISABLED - if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER && - tls_session -> nx_secure_tls_server_state == NX_SECURE_TLS_SERVER_STATE_HELLO_REQUEST) - { - local_initiated_renegotiation = NX_TRUE; - } -#endif -#endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ - /* Try receiving records from the remote host. */ status = _nx_secure_tls_session_receive_records(tls_session, packet_ptr_ptr, wait_option); @@ -120,9 +103,6 @@ UINT local_initiated_renegotiation = NX_FALSE; if (status == NX_SUCCESS && tls_session -> nx_secure_tls_renegotiation_handshake) { - /* Clear flag to prevent infinite recursion. */ - tls_session -> nx_secure_tls_renegotiation_handshake = NX_FALSE; - /* Process the handshake. */ status = _nx_secure_tls_handshake_process(tls_session, wait_option); @@ -131,13 +111,17 @@ UINT local_initiated_renegotiation = NX_FALSE; return(status); } + /* Clear flag to prevent infinite recursion. */ + tls_session -> nx_secure_tls_renegotiation_handshake = NX_FALSE; + /* If this renegotiation was initiated by us, don't receive additional data as that will be up to the application. */ - if (!local_initiated_renegotiation) + if (!tls_session -> nx_secure_tls_local_initiated_renegotiation) { /* Handle any data that followed the re-negotiation handshake. */ status = _nx_secure_tls_session_receive_records(tls_session, packet_ptr_ptr, wait_option); } + tls_session -> nx_secure_tls_local_initiated_renegotiation = NX_FALSE; } else #endif /* NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_renegotiate.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_renegotiate.c index 9b8ef28a..8cebba4e 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_renegotiate.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_renegotiate.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_renegotiate PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -97,6 +97,10 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), changed */ /* an error to assert, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), and */ +/* fixed renegotiation when */ +/* receiving in non-block mode,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ #ifndef NX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION @@ -154,6 +158,7 @@ NX_PACKET *send_packet; /* This is a renegotiation handshake so indicate that to the stack. */ tls_session -> nx_secure_tls_client_state = NX_SECURE_TLS_CLIENT_STATE_RENEGOTIATING; + tls_session -> nx_secure_tls_local_initiated_renegotiation = NX_TRUE; /* On a session resumption free all certificates for the new session. * SESSION RESUMPTION: if session resumption is enabled, don't free!! @@ -211,6 +216,12 @@ NX_PACKET *send_packet; { nx_secure_tls_packet_release(incoming_packet); } + + if (tls_session -> nx_secure_tls_client_state == NX_SECURE_TLS_CLIENT_STATE_HANDSHAKE_FINISHED) + { + tls_session -> nx_secure_tls_local_initiated_renegotiation = NX_FALSE; + tls_session -> nx_secure_tls_renegotiation_handshake = NX_FALSE; + } } #endif @@ -240,6 +251,8 @@ NX_PACKET *send_packet; status = _nx_secure_tls_send_hellorequest(tls_session, send_packet); NX_ASSERT(status == NX_SUCCESS); + tls_session -> nx_secure_tls_local_initiated_renegotiation = NX_TRUE; + /* Send the HelloRequest to kick things off. */ status = _nx_secure_tls_send_handshake_record(tls_session, send_packet, NX_SECURE_TLS_HELLO_REQUEST, wait_option); @@ -279,6 +292,12 @@ NX_PACKET *send_packet; { nx_secure_tls_packet_release(incoming_packet); } + + if (tls_session -> nx_secure_tls_server_state == NX_SECURE_TLS_SERVER_STATE_HANDSHAKE_FINISHED) + { + tls_session -> nx_secure_tls_local_initiated_renegotiation = NX_FALSE; + tls_session -> nx_secure_tls_renegotiation_handshake = NX_FALSE; + } } #endif diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_reset.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_reset.c index 6b715565..f825ff03 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_reset.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_reset.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_reset PORTABLE C */ -/* 6.1.9 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -78,6 +78,10 @@ /* option to disable client */ /* initiated renegotiation, */ /* resulting in version 6.1.9 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), and */ +/* fixed renegotiation when */ +/* receiving in non-block mode,*/ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_session_reset(NX_SECURE_TLS_SESSION *session_ptr) @@ -169,6 +173,7 @@ UINT temp_status; session_ptr -> nx_secure_tls_renegotiation_handshake = NX_FALSE; session_ptr -> nx_secure_tls_secure_renegotiation_verified = NX_FALSE; session_ptr -> nx_secure_tls_server_renegotiation_requested = NX_FALSE; + session_ptr -> nx_secure_tls_local_initiated_renegotiation = NX_FALSE; #endif /* Flag to indicate when credentials have been received from the remote host. */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_parse.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_parse.c index 4f2b4cff..f2b04f11 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_parse.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_parse.c @@ -132,7 +132,7 @@ UINT offset; } /* Name and lengths check out, save off the name data. */ - NX_SECURE_MEMCPY(dns_name -> nx_secure_x509_dns_name, &data_ptr[offset], dns_name -> nx_secure_x509_dns_name_length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(dns_name -> nx_secure_x509_dns_name, &data_ptr[offset], dns_name -> nx_secure_x509_dns_name_length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ /* Success! */ return(NX_SUCCESS); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_set.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_set.c index 4deb657b..bf2c148a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_set.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_sni_extension_set.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_sni_extension_set PORTABLE C */ -/* 6.1 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -66,15 +66,25 @@ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), */ +/* fix compile error, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_session_sni_extension_set(NX_SECURE_TLS_SESSION *tls_session, NX_SECURE_X509_DNS_NAME *dns_name) { +#ifndef NX_SECURE_TLS_SNI_EXTENSION_DISABLED /* Set the pointer to the SNI DNS name so it can be sent in the ClientHello. */ tls_session -> nx_secure_tls_sni_extension_server_name = dns_name; return(NX_SUCCESS); +#else + NX_PARAMETER_NOT_USED(tls_session); + NX_PARAMETER_NOT_USED(dns_name); + + return(NX_NOT_ENABLED); +#endif } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_start.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_start.c index 79588270..d9108921 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_start.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_session_start.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_session_start PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -80,6 +80,9 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), removed */ /* internal unreachable logic, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom packet pool support, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_session_start(NX_SECURE_TLS_SESSION *tls_session, NX_TCP_SOCKET *tcp_socket, @@ -94,8 +97,11 @@ NX_PACKET *send_packet; /* Get the protection. */ tx_mutex_get(&_nx_secure_tls_protection, TX_WAIT_FOREVER); - /* Assign the packet pool from which TLS will allocate internal message packets. */ - tls_session -> nx_secure_tls_packet_pool = tcp_socket -> nx_tcp_socket_ip_ptr -> nx_ip_default_packet_pool; + if (!tls_session -> nx_secure_tls_packet_pool) + { + /* Assign the packet pool from which TLS will allocate internal message packets. */ + tls_session -> nx_secure_tls_packet_pool = tcp_socket -> nx_tcp_socket_ip_ptr -> nx_ip_default_packet_pool; + } /* Assign the TCP socket to the TLS session. */ tls_session -> nx_secure_tls_tcp_socket = tcp_socket; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_trusted_certificate_add.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_trusted_certificate_add.c index cfa2990b..bf6f5166 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_trusted_certificate_add.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_trusted_certificate_add.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_trusted_certificate_add PORTABLE C */ -/* 6.1.6 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -58,8 +58,8 @@ /* */ /* tx_mutex_get Get protection mutex */ /* tx_mutex_put Put protection mutex */ -/* _nx_secure_x509_store_certificate_add Add certificate to trusted */ -/* store */ +/* [nx_secure_trusted_certificate_add] Add certificate to trusted */ +/* store */ /* */ /* CALLED BY */ /* */ @@ -75,6 +75,9 @@ /* 04-02-2021 Timothy Stapko Modified comment(s), */ /* updated X.509 return value, */ /* resulting in version 6.1.6 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_trusted_certificate_add(NX_SECURE_TLS_SESSION *tls_session, @@ -101,19 +104,11 @@ UINT status; /* Add the certificate to the TLS session credentials X509 store. */ - status = _nx_secure_x509_store_certificate_add(certificate, &tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, - NX_SECURE_X509_CERT_LOCATION_TRUSTED); - + status = tls_session -> nx_secure_trusted_certificate_add(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store, certificate); /* Release the protection. */ tx_mutex_put(&_nx_secure_tls_protection); - /* Translate some X.509 return values into TLS return values. */ - if (status == NX_SECURE_X509_CERT_ID_DUPLICATE) - { - return(NX_SECURE_TLS_CERT_ID_DUPLICATE); - } - return(status); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_verify_mac.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_verify_mac.c index 5d3a7f77..509d98cd 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_verify_mac.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_tls_verify_mac.c @@ -24,15 +24,12 @@ #include "nx_secure_tls.h" -static UCHAR _generated_hash[NX_SECURE_TLS_MAX_HASH_SIZE]; -static UCHAR _received_hash[NX_SECURE_TLS_MAX_HASH_SIZE]; - /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_verify_mac PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -60,7 +57,7 @@ static UCHAR _received_hash[NX_SECURE_TLS_MAX_HASH_SIZE]; /* */ /* CALLS */ /* */ -/* _nx_secure_tls_hash_record Generate payload data hash */ +/* [nx_secure_verify_mac] Verify record MAC checksum */ /* */ /* CALLED BY */ /* */ @@ -79,18 +76,19 @@ static UCHAR _received_hash[NX_SECURE_TLS_MAX_HASH_SIZE]; /* 04-25-2022 Yuxin Zhou Modified comment(s), and */ /* reorganized internal logic, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* checked seq number overflow,*/ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Yanwu Cai Modified comment(s), added */ +/* custom secret generation, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_verify_mac(NX_SECURE_TLS_SESSION *tls_session, UCHAR *header_data, USHORT header_length, NX_PACKET *packet_ptr, ULONG offset, UINT *length) { UCHAR *mac_secret; -USHORT hash_size; -INT compare_result; -USHORT data_length; -UINT hash_length; -UCHAR header[6]; -ULONG bytes_copied; +UINT status; if (tls_session -> nx_secure_tls_session_ciphersuite == NX_NULL) { @@ -99,9 +97,6 @@ ULONG bytes_copied; return(NX_SECURE_TLS_UNKNOWN_CIPHERSUITE); } - /* Get the hash size and MAC secret for our current session. */ - hash_size = tls_session -> nx_secure_tls_session_ciphersuite -> nx_secure_tls_hash_size; - /* Select our proper MAC secret for hashing. */ if (tls_session -> nx_secure_tls_socket_type == NX_SECURE_TLS_SESSION_TYPE_SERVER) { @@ -114,102 +109,9 @@ ULONG bytes_copied; mac_secret = tls_session -> nx_secure_tls_key_material.nx_secure_tls_server_write_mac_secret; } - /* Check for 0-length records. With nothing to hash, don't continue to hash generation. */ - if (hash_size >= *length) - { - - if (header_data[0] == (UCHAR)(NX_SECURE_TLS_APPLICATION_DATA) && - *length == hash_size) - { - /* BEAST attack mitigation. In TLS 1.0 and SSLv3, the implicit IV enables the BEAST - attack. Some implementations counter the attack by sending an empty record which - has the effect of resetting the IVs. We normally don't allow empty records since there - is no data to hash, but in this case we want to allow it. */ - *length = 0; - - /* Increment the sequence number. */ - if ((tls_session -> nx_secure_tls_remote_sequence_number[0] + 1) == 0) - { - /* Check for overflow of the 32-bit unsigned number. */ - tls_session -> nx_secure_tls_remote_sequence_number[1]++; - } - tls_session -> nx_secure_tls_remote_sequence_number[0]++; - - return(NX_SUCCESS); - } - - /* The record data was smaller than the selected hash... Error. */ - return(NX_SECURE_TLS_HASH_MAC_VERIFY_FAILURE); - } - - /* Adjust our length so we only hash the record data, not the hash as well. */ - data_length = (USHORT)(*length - hash_size); - - /* Copy the header data into our local buffer so we can change it if we need to. */ - if (header_length > sizeof(header)) - { - return(NX_SECURE_TLS_HASH_MAC_VERIFY_FAILURE); - } - NX_SECURE_MEMCPY(header, header_data, header_length); /* Use case of memcpy is verified. */ - - /* Adjust the length in the header to match the length of the data before the hash was added. */ - header[3] = (UCHAR)((data_length >> 8) & 0x00FF); - header[4] = (UCHAR)(data_length & 0x00FF); - - /* Generate the hash on the plaintext data. */ - _nx_secure_tls_hash_record(tls_session, tls_session -> nx_secure_tls_remote_sequence_number, header, header_length, - packet_ptr, offset, data_length, _generated_hash, &hash_length, mac_secret); - - /* Increment the sequence number. */ - if ((tls_session -> nx_secure_tls_remote_sequence_number[0] + 1) == 0) - { - /* Check for overflow of the 32-bit unsigned number. */ - tls_session -> nx_secure_tls_remote_sequence_number[1]++; - } - tls_session -> nx_secure_tls_remote_sequence_number[0]++; - - if (hash_size == 0) - { - - /* For ciphersuite without explict hash, just return success. */ - return(NX_SECURE_TLS_SUCCESS); - } - - /* Now, compare the hash we generated to the one we received. */ - if (nx_packet_data_extract_offset(packet_ptr, - offset + data_length, - _received_hash, hash_size, &bytes_copied)) - - { - - /* The record data was smaller than the selected hash... Error. */ - return(NX_SECURE_TLS_PADDING_CHECK_FAILED); - } - - if (bytes_copied != hash_size) - { - - /* The record data was smaller than the selected hash... Error. */ - return(NX_SECURE_TLS_PADDING_CHECK_FAILED); - } - - compare_result = NX_SECURE_MEMCMP(_received_hash, _generated_hash, hash_size); - -#ifdef NX_SECURE_KEY_CLEAR - NX_SECURE_MEMSET(_generated_hash, 0, sizeof(_generated_hash)); -#endif /* NX_SECURE_KEY_CLEAR */ - - /* Before we return, adjust our data size so the caller will only see data, not the hash. */ - *length = data_length; - - /* If the hashes match, we are all good. Otherwise we have a problem. */ - if (compare_result == 0) - { - return(NX_SECURE_TLS_SUCCESS); - } - else - { - return(NX_SECURE_TLS_HASH_MAC_VERIFY_FAILURE); - } + status = tls_session -> nx_secure_verify_mac(tls_session -> nx_secure_tls_session_ciphersuite, mac_secret, tls_session -> nx_secure_tls_remote_sequence_number, + header_data, header_length, packet_ptr, offset, length, + tls_session -> nx_secure_hash_mac_metadata_area, tls_session -> nx_secure_hash_mac_metadata_size); + return(status); } diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_chain_verify.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_chain_verify.c index 4979d84e..9af44600 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_chain_verify.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_chain_verify.c @@ -29,7 +29,7 @@ /* FUNCTION RELEASE */ /* */ /* _nx_secure_x509_certificate_chain_verify PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -76,10 +76,14 @@ /* 04-25-2022 Yuxin Zhou Modified comment(s), and */ /* reorganized internal logic, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* checked expiration for all */ +/* the certs in the chain, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_x509_certificate_chain_verify(NX_SECURE_X509_CERTIFICATE_STORE *store, - NX_SECURE_X509_CERT *certificate) + NX_SECURE_X509_CERT *certificate, ULONG current_time) { UINT status; NX_SECURE_X509_CERT *current_certificate; @@ -101,7 +105,15 @@ INT compare_result; { /* Check the certificate expiration against the current time. */ + if (current_time != 0) + { + status = _nx_secure_x509_expiration_check(current_certificate, current_time); + if (status != NX_SECURE_X509_SUCCESS) + { + return(status); + } + } /* See if the certificate is self-signed or not. */ compare_result = _nx_secure_x509_distinguished_name_compare(¤t_certificate -> nx_secure_x509_distinguished_name, diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_initialize.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_initialize.c index d130ea02..5c88f3c8 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_initialize.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_certificate_initialize.c @@ -141,7 +141,7 @@ NX_SECURE_EC_PRIVATE_KEY *ec_key; /* Use the caller-supplied buffer for the certificate. */ certificate -> nx_secure_x509_certificate_raw_buffer_size = buffer_size; certificate -> nx_secure_x509_certificate_raw_data = raw_data_buffer; - NX_SECURE_MEMCPY(certificate -> nx_secure_x509_certificate_raw_data, certificate_data, length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(certificate -> nx_secure_x509_certificate_raw_data, certificate_data, length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ } /* Parse the DER-encoded X509 certificate to extract the public key data. diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_crl_revocation_check.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_crl_revocation_check.c index a2fe4e8c..fd713ffd 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_crl_revocation_check.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_crl_revocation_check.c @@ -35,7 +35,7 @@ static UINT _nx_secure_x509_crl_parse_entry(const UCHAR *buffer, ULONG length, U /* FUNCTION RELEASE */ /* */ /* _nx_secure_x509_crl_revocation_check PORTABLE C */ -/* 6.1.11 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ @@ -97,6 +97,10 @@ static UINT _nx_secure_x509_crl_parse_entry(const UCHAR *buffer, ULONG length, U /* modified to improve code */ /* coverage result, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Yuxin Zhou Modified comment(s), and */ +/* checked expiration for all */ +/* the certs in the chain, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ UINT _nx_secure_x509_crl_revocation_check(const UCHAR *crl_data, UINT crl_length, @@ -146,7 +150,7 @@ UINT serial_number_length; } /* Now, check that the issuer is valid. */ - status = _nx_secure_x509_certificate_chain_verify(store, issuer_certificate); + status = _nx_secure_x509_certificate_chain_verify(store, issuer_certificate, 0); if (status != NX_SECURE_X509_SUCCESS) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_dns_name_initialize.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_dns_name_initialize.c index 9d1571d2..e4397a73 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_dns_name_initialize.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/netxduo_addons/nx_secure/src/nx_secure_x509_dns_name_initialize.c @@ -85,7 +85,7 @@ UINT _nx_secure_x509_dns_name_initialize(NX_SECURE_X509_DNS_NAME *dns_name, } /* Copy the name string into the entry structure. */ - NX_SECURE_MEMCPY(dns_name -> nx_secure_x509_dns_name, name_string, length); /* Use case of memcpy is verified. */ + NX_SECURE_MEMCPY(dns_name -> nx_secure_x509_dns_name, name_string, length); /* Use case of memcpy is verified. lgtm[cpp/banned-api-usage-required-any] */ dns_name -> nx_secure_x509_dns_name_length = length; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/CMakeLists.txt b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/CMakeLists.txt index de815c28..adfcb669 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/CMakeLists.txt +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/CMakeLists.txt @@ -202,6 +202,7 @@ target_sources(${PROJECT_NAME} # Add the Common/inc directory to the project include list target_include_directories(${PROJECT_NAME} + SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc ) diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/inc/tx_api.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/inc/tx_api.h index af384662..9974c977 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/inc/tx_api.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/inc/tx_api.h @@ -26,7 +26,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* tx_api.h PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -86,6 +86,14 @@ /* optimized the definition of */ /* TX_TIMER_TICKS_PER_SECOND, */ /* resulting in version 6.1.11 */ +/* 07-29-2022 Scott Larson Modified comment(s), */ +/* update patch number, */ +/* resulting in version 6.1.12 */ +/* 10-31-2022 Scott Larson Modified comment(s), */ +/* add extension macros, */ +/* update EPK typedef, */ +/* update version numbers, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ @@ -112,6 +120,9 @@ extern "C" { #include "tx_port.h" +#if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY)) +#include "tx_execution_profile.h" +#endif /* Define basic constants for the ThreadX kernel. */ @@ -121,8 +132,8 @@ extern "C" { #define AZURE_RTOS_THREADX #define THREADX_MAJOR_VERSION 6 -#define THREADX_MINOR_VERSION 1 -#define THREADX_PATCH_VERSION 11 +#define THREADX_MINOR_VERSION 2 +#define THREADX_PATCH_VERSION 0 /* Define the following symbol for backward compatibility */ #define EL_PRODUCT_THREADX @@ -220,6 +231,76 @@ extern "C" { #define TX_FEATURE_NOT_ENABLED ((UINT) 0xFF) +#ifdef TX_64_BIT + +#ifndef TX_THREAD_EXTENSION_PTR_SET +#define TX_THREAD_EXTENSION_PTR_SET(a, b) { \ + TX_THREAD *thread_ptr; \ + thread_ptr = (TX_THREAD *) (a); \ + (thread_ptr -> tx_thread_extension_ptr) = (VOID *)(b); \ + } +#endif /* TX_THREAD_EXTENSION_PTR_SET */ + +#ifndef TX_THREAD_EXTENSION_PTR_GET +#define TX_THREAD_EXTENSION_PTR_GET(a, b, c) { \ + TX_PARAMETER_NOT_USED(c); \ + TX_THREAD *thread_ptr; \ + thread_ptr = tx_thread_identify(); \ + while(1)\ + { \ + if (thread_ptr -> tx_thread_extension_ptr) \ + { \ + (a) = (b *)(thread_ptr -> tx_thread_extension_ptr); \ + break; \ + } \ + tx_thread_sleep(1); \ + } \ + } +#endif /* TX_THREAD_EXTENSION_PTR_GET */ + +#ifndef TX_TIMER_EXTENSION_PTR_SET +#define TX_TIMER_EXTENSION_PTR_SET(a, b) { \ + TX_TIMER *timer_ptr; \ + timer_ptr = (TX_TIMER *) (a); \ + (timer_ptr -> tx_timer_internal.tx_timer_internal_extension_ptr) = (VOID *)(b); \ + } +#endif /* TX_TIMER_EXTENSION_PTR_SET */ + +#ifndef TX_TIMER_EXTENSION_PTR_GET +#define TX_TIMER_EXTENSION_PTR_GET(a, b, c) { \ + TX_PARAMETER_NOT_USED(c); \ + if (!_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr) \ + return; \ + (a) = (b *)(_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr); \ + } +#endif /* TX_TIMER_EXTENSION_PTR_GET */ + +#else /* not 64 bit */ + +#ifndef TX_THREAD_EXTENSION_PTR_SET +#define TX_THREAD_EXTENSION_PTR_SET(a, b) +#endif /* TX_THREAD_EXTENSION_PTR_SET */ + +#ifndef TX_THREAD_EXTENSION_PTR_GET +#define TX_THREAD_EXTENSION_PTR_GET(a, b, c) { \ + (a) = (b *)(c); \ + } +#endif /* TX_THREAD_EXTENSION_PTR_GET */ + +#ifndef TX_TIMER_EXTENSION_PTR_SET +#define TX_TIMER_EXTENSION_PTR_SET(a, b) +#endif /* TX_TIMER_EXTENSION_PTR_SET */ + +#ifndef TX_TIMER_EXTENSION_PTR_GET +#define TX_TIMER_EXTENSION_PTR_GET(a, b, c) { \ + (a) = (b *)(c); \ + } +#endif /* TX_TIMER_EXTENSION_PTR_GET */ + +#endif /* TX_64_BIT */ + + + /* Define the common timer tick reference for use by other middleware components. The default value is 10ms, but may be replaced by a port specific version in tx_port.h or by the user as a compilation option. */ @@ -526,8 +607,8 @@ typedef struct TX_THREAD_STRUCT For Azure RTOS 6, user shall use TX_EXECUTION_PROFILE_ENABLE instead of TX_ENABLE_EXECUTION_CHANGE_NOTIFY, and SHALL NOT add variables to TX_THREAD_EXTENSION_3. */ #if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY)) - unsigned long long tx_thread_execution_time_total; - unsigned long long tx_thread_execution_time_last_start; + EXECUTION_TIME tx_thread_execution_time_total; + EXECUTION_TIME_SOURCE_TYPE tx_thread_execution_time_last_start; #endif /* Define suspension sequence number. This is used to ensure suspension is still valid when diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_event_flags_get.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_event_flags_get.c index aba42c6b..3cc62178 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_event_flags_get.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_event_flags_get.c @@ -36,7 +36,7 @@ /* FUNCTION RELEASE */ /* */ /* _tx_event_flags_get PORTABLE C */ -/* 6.1.11 */ +/* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -79,6 +79,9 @@ /* 04-25-2022 Scott Larson Modified comment(s), */ /* handle 0 flags case, */ /* resulting in version 6.1.11 */ +/* 10-31-2022 Scott Larson Modified comment(s), always */ +/* return actual flags, */ +/* resulting in version 6.2.0 */ /* */ /**************************************************************************/ UINT _tx_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags, @@ -125,6 +128,9 @@ UINT interrupted_set_request; /* Pickup current flags. */ current_flags = group_ptr -> tx_event_flags_group_current; + /* Return the actual event flags and apply delayed clearing. */ + *actual_flags_ptr = current_flags & ~group_ptr -> tx_event_flags_group_delayed_clear; + /* Apply the event flag option mask. */ and_request = (get_option & TX_AND); @@ -158,9 +164,6 @@ UINT interrupted_set_request; if (flags_satisfied != ((ULONG) 0)) { - /* Return the actual event flags that satisfied the request. */ - *actual_flags_ptr = current_flags; - /* Pickup the clear bit. */ clear_request = (get_option & TX_EVENT_FLAGS_CLEAR_MASK); @@ -221,9 +224,6 @@ UINT interrupted_set_request; /* Yes, this request can be handled immediately. */ - /* Return the actual event flags that satisfied the request. */ - *actual_flags_ptr = current_flags; - /* Pickup the clear bit. */ clear_request = (get_option & TX_EVENT_FLAGS_CLEAR_MASK); @@ -274,7 +274,7 @@ UINT interrupted_set_request; #endif else { - + /* flags_satisfied is 0. */ /* Determine if the request specifies suspension. */ if (wait_option != TX_NO_WAIT) { diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_trace_object_register.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_trace_object_register.c index da2dafcf..f76de2f4 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_trace_object_register.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/common/src/tx_trace_object_register.c @@ -34,7 +34,7 @@ /* FUNCTION RELEASE */ /* */ /* _tx_trace_object_register PORTABLE C */ -/* 6.1 */ +/* 6.1.12 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -69,9 +69,12 @@ /* */ /* DATE NAME DESCRIPTION */ /* */ -/* 05-19-2020 William E. Lamie Initial Version 6.0 */ -/* 09-30-2020 Yuxin Zhou Modified comment(s), */ +/* 05-19-2020 William E. Lamie Initial Version 6.0 */ +/* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ +/* 07-29-2022 Scott Larson Modified comment(s), */ +/* check for null name, */ +/* resulting in version 6.1.12 */ /* */ /**************************************************************************/ VOID _tx_trace_object_register(UCHAR object_type, VOID *object_ptr, CHAR *object_name, ULONG parameter_1, ULONG parameter_2) @@ -223,6 +226,12 @@ TX_TRACE_OBJECT_ENTRY *entry_ptr; work_ptr = TX_CHAR_TO_UCHAR_POINTER_CONVERT(object_name); work_ptr = TX_UCHAR_POINTER_ADD(work_ptr, i); + /* Determine if object_name (work_ptr) is null. */ + if (work_ptr == TX_NULL) + { + break; + } + /* Copy a character of the name. */ entry_ptr -> tx_trace_object_entry_name[i] = (UCHAR) *work_ptr; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt index 5756c421..fce987a3 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/ports/rxv2/gnu/readme_threadx.txt @@ -27,7 +27,8 @@ initialization code. The ThreadX demonstration for the RXv2 utilizes CMT0 as a periodic timer interrupt source. The CMT0 interrupt is typically setup for 10ms periodic interrupts and the -interrupt priority level is set to level 7. You may change any of the timer +interrupt priority level is set to level 5 with the symbol CMT_RX_CFG_IPR in +r_cmt_rx_config.h of Renesas CMT timer module(r_cmt_rx). You may change any of the timer parameters as needed. Increasing the timer interrupt frequency increases the overhead of the timer handling code on the system. @@ -41,12 +42,12 @@ sections in your linker control file. 4. Context Switch, Register Usage and Stack Frames -The RXv2 port for ThreadX uses the first software interrupt, SWINT, i.e., interrupt #17, -to perform context switch. This ISR is thus reserved when using ThreadX and the SWINT -should not be manipulated in any way by the application. The port will setup the -interrupt within _tx_initialize_low_level and the compiler will automatically install -the necessary interrupt vector. As such no additional initialization is necessary by the -application. +The RXv2 port for ThreadX uses the first software interrupt, SWINT, i.e., interrupt #27, +to perform context switch with the interrupt priority level 1. This ISR is thus reserved +when using ThreadX and the SWINT should not be manipulated in any way by the application. +The port will setup the interrupt within _tx_initialize_low_level and the compiler will +automatically install the necessary interrupt vector. As such no additional initialization +is necessary by the application. The following defines the saved context stack frame used by the ThreadX port. The state of the CPU registers at the time of a context switch is saved on the running @@ -99,17 +100,17 @@ is included. Timer processign is performed by calling __tx_timer_interrupt(). This should usually be done from within the callback of a periodic timer with a period of 100Hz. In the sample projects -a Renesas Fit CMT periodic timer module (rx_cmt) is used as the timer source. +a Renesas Fit CMT periodic timer module (r_cmt_rx) is used as the timer source. 7. Interrupt Handling Interrupt handling is unaffected by the ThreadX port as such user interrupts can be written according to the toolchain's documentation. It is recommended not to use interrupt -priority 15 as this is the priority of the context switch interrupt. However using interrupt -priority 15 won't cause any negative side effectd but doing so may may slightly reduce +priority 1 as this is the priority of the context switch interrupt. However using interrupt +priority 1 won't cause any negative side effects but doing so may slightly reduce performance. Please refer to the toolchain documentation for additional details on how to -define interupt service routines. +define interrupt service routines. 8. Execution Profiling diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/utility/low_power/low_power.md b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/utility/low_power/low_power.md index 8be714a3..ed25ccd6 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/utility/low_power/low_power.md +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/libs/threadx/utility/low_power/low_power.md @@ -8,25 +8,209 @@ ms.topic: article ms.service: rtos --- -# Low Power APIs +# ThreadX Low Power Utilities -## Summary of Low Power APIs +These low power utilities are intended to maintain ThreadX timers and the internal tick count while the processor is in a low-power/sleep state. The terms "low power" and "sleep" are used interchangeably throughout this document. -There are additional API functions available for low power, as follows: +The low power utilities may be used with any ThreadX port except SMP. -- ***tx_low_power_enter*** - *Enter low power mode* -- ***tx_low_power_exit*** - *Exit low power mode* -- ***tx_time_increment*** - *Increment ThreadX timers by specific amount* -- ***tx_timer_get_next*** - *Get next ThreadX timer expiration* +## Installation of Low Power Utilities + +The ThreadX low power utilities are comprised of two files: + + - [tx_low_power.c](tx_low_power.c) + - [tx_low_power.h](tx_low_power.h) + +These files can be built with the ThreadX library or built in the user application. + +## Detailed Description + +By default, ThreadX spins in an idle loop in the scheduler when there are no threads ready to run. It may be desireable to put the processor in a low power state while idle. Functions ```tx_low_power_enter``` and ```tx_low_power_exit``` are designed to enter and exit low power mode, respectively. + +The ```tx_low_power_enter``` and ```tx_low_power_exit``` functions manage the ThreadX timers and invoke optional macros that the user must define in order to configure the hardware for low power mode. These macros are discussed in a section below. + +For convenience, the Cortex-M and RX ports have calls to the low power APIs already integrated into their schedulers. If symbol **TX_LOW_POWER** is defined, functions ```tx_low_power_enter``` and ```tx_low_power_exit``` are called in the scheduler idle loop. It is assumed that the processor will exit sleep mode and resume execution in the idle loop (or in an interrupt and then return to the idle loop). For processors that exhibit different behavior (such as waking from sleep at the reset vector), these low power functions may need to be called elsewhere. + +### Low Power Timer and Tick-less Low Power Mode + +If accurate timekeeping is not desired while in low power mode, macros **TX_LOW_POWER_TIMER_SETUP** and **TX_LOW_POWER_TICKLESS** do not need to be defined. The internal ThreadX tick count will not reflect the time spent in low power mode. + +If **TX_LOW_POWER_TIMER_SETUP** is defined, there are two use cases for timekeeping in low power operation: +1. Keep track of elapsed time in low power mode only when ThreadX timers are active. If there are ThreadX timers active, the elapsed time while in low power mode must be measured, thus a low power hardware timer is required (this timer can be configured in **TX_LOW_POWER_TIMER_SETUP**). If there are no ThreadX timers active when entering low power mode, then no hardware timer needs to keep track of elapsed time. This is "tick-less" operation. To enable this feature, the symbol **TX_LOW_POWER_TICKLESS** must be defined. The internal ThreadX tick count will not reflect the time spent in low power mode when no ThreadX timers are active. +2. Always keep track of time in low power mode. This is necessary to keep the internal ThreadX tick count accurate. In this case, **TX_LOW_POWER_TICKLESS** must *not* be defined, as a hardware timer will always be needed in low power mode to measure elapsed time. The hardware timer is intended to be configured in **TX_LOW_POWER_TIMER_SETUP**. + +> Example 1: No low power timer is in use (**TX_LOW_POWER_TIMER_SETUP** is *not* defined). There is a ThreadX timer with 50 ticks remaining. The internal ThreadX tick count is 1000. The processor goes into low power mode for some length of time. After exiting low power mode, the ThreadX timer still has 50 ticks remaining. The internal ThreadX tick count is 1000. + +> Example 2: A low power timer is available (**TX_LOW_POWER_TIMER_SETUP** is defined). **TX_LOW_POWER_TICKLESS** is defined. There is a ThreadX timer A with 50 ticks remaining and another ThreadX timer B with 20 ticks remaining. The internal ThreadX tick count is 1000. The processor goes into low power mode for 20 ticks. Upon exiting low power mode, the ThreadX timer A will have 30 ticks remaining. The expiration function for ThreadX timer B will be executed. The internal ThreadX tick count is 1020. +After executing for some time, the internal ThreadX tick count is 2000 and there are no ThreadX timers active. The processor goes into low power mode for some length of time. After exiting low power mode, the internal ThreadX tick count is 2000. + +> Example 3: A low power timer is always used (**TX_LOW_POWER_TIMER_SETUP** is defined and **TX_LOW_POWER_TICKLESS** is *not* defined). The internal ThreadX tick count is 1000 and there are no ThreadX timers active. The processor goes into low power mode for some length of time. Upon exiting low power mode, it is determined that the processor was in low power mode for 20 ticks. The internal ThreadX tick count is updated to 1020. ---- ## User-defined Macros -- **TX_LOW_POWER_TIMER_SETUP** - an optional macro to a user routine that sets up a low power clock. To set up a low power timer or operate ticklessly in low power mode, this must be defined. This is called in **tx_low_power_enter**. -- **TX_LOW_POWER_TICKLESS** - an optional define to operate ticklessly in low power mode. Symbol **TX_LOW_POWER_TIMER_SETUP** must also be defined. With this defined, there is no need to set up a low power timer to keep track of time. ThreadX will not maintain/update the internal tick count during or after exiting low power mode. -- **TX_LOW_POWER_USER_ENTER** - an optional macro to a user routine that configures the processor for entering low power mode (e.g. turn off peripherals and select a sleep mode). This is called in **tx_low_power_enter**. -- **TX_LOW_POWER_USER_EXIT** - an optional macro to a user routine that configures the processor for exiting low power mode (e.g. turn on peripherals). This is called in **tx_low_power_exit**. -- **TX_LOW_POWER_USER_TIMER_ADJUST** - an optional user macro to determine how much time has elapsed while in low power mode (in units of ThreadX ticks). This is called in **tx_low_power_exit** to get the number of ticks needed to adjust the ThreadX timers. +The following macros invoke functions that the user may want to define/implement. + +### Summary of user-defined macros + + - ```TX_LOW_POWER_TIMER_SETUP``` - *set up low power timer* + - ```TX_LOW_POWER_USER_ENTER``` - *configure processor to enter low power mode* + - ```TX_LOW_POWER_USER_EXIT``` - *configure processor to exit low power mode* + - ```TX_LOW_POWER_USER_TIMER_ADJUST``` - *return the number of ticks the processor was in low power mode* + +--- + +### TX_LOW_POWER_TIMER_SETUP +```c +VOID TX_LOW_POWER_TIMER_SETUP(ULONG tx_low_power_next_expiration); +``` + +### Input parameters + +- *tx_low_power_next_expiration* - the number of ticks to configure the low power timer. + +### Return values + +- *none* + +**TX_LOW_POWER_TIMER_SETUP** is a macro invoking user-defined function that sets up a low power timer. To set up a low power timer or operate ticklessly in low power mode, this symbol must be defined. This macro is called in ```tx_low_power_enter```. If **TX_LOW_POWER_TICKLESS** is not defined and there are no timers active, the *tx_low_power_next_expiration* parameter will be set to 0xFFFFFFFF. + +> Note: The number of ThreadX ticks is the input to this function. The frequency of a ThreadX timer tick is defined in **TX_TIMER_TICKS_PER_SECOND** (typically defined in file tx_api.h, tx_user.h, or tx_port.h). + +> Note: do not put the processor to sleep in this macro. + +### Optional Define + +- **TX_LOW_POWER_TICKLESS** - an optional define to operate ticklessly in low power mode only if no ThreadX timers are active. With symbol **TX_LOW_POWER_TICKLESS** defined, if there are no ThreadX timers active, **TX_LOW_POWER_TIMER_SETUP** will not be called in ```tx_low_power_enter```. ThreadX will not maintain/update the internal tick count during or after exiting low power mode. Symbol **TX_LOW_POWER_TIMER_SETUP** must also be defined if defining **TX_LOW_POWER_TICKLESS**. + +### Example + +```c +/* Low power timer function prototype. */ +void low_power_timer_config(ULONG ticks); + +/* Define the TX_LOW_POWER_TIMER_SETUP macro. */ +#define TX_LOW_POWER_TIMER_SETUP low_power_timer_config + +void low_power_timer_config(ULONG ticks) +{ + /* Insert code here to configure a hardware timer + to wake the processor from sleep after + ticks/TX_TIMER_TICKS_PER_SECOND seconds. */ +} +``` + +--- + +### TX_LOW_POWER_USER_ENTER +A macro invoking a user-defined function that configures the processor for entering low power mode (e.g. turn off peripherals and select a sleep mode). This macro is called in ```tx_low_power_enter```. + +### Input parameters + +- *none* + +### Return values + +- *none* + +### Example + +```c +/* Low power enter function prototype. */ +void low_power_enter(void); + +/* Define the TX_LOW_POWER_USER_ENTER macro. */ +#define TX_LOW_POWER_USER_ENTER low_power_enter + +void low_power_enter(void) +{ + /* Insert code here to configure the processor to enter low power mode. */ +} +``` +--- + +### TX_LOW_POWER_USER_EXIT +A macro invoking a user-defined function that configures the processor for exiting low power mode (e.g. turn on peripherals). This is called in ```tx_low_power_exit```. + +### Input parameters + +- *none* + +### Return values + +- *none* + +### Example + +```c +/* Low power exit function prototype. */ +void low_power_exit(void); + +/* Define the TX_LOW_POWER_USER_EXIT macro. */ +#define TX_LOW_POWER_USER_EXIT low_power_exit + +void low_power_exit(void) +{ + /* Insert code here to configure the processor to exit low power mode. */ +} +``` + +--- + +### TX_LOW_POWER_USER_TIMER_ADJUST + +```c +ULONG TX_LOW_POWER_USER_TIMER_ADJUST(VOID); +``` + +A macro invoking a user-defined function to determine how much time has elapsed while in low power mode (in units of ThreadX ticks). This is called in ```tx_low_power_exit``` and returns the number of ticks needed to adjust the ThreadX timers. + +When exiting low power mode, there are two possibilities: + 1. The processor slept for the entire time the timer was configured to sleep. + 2. The processor was awakened early. + +### Input parameters + +- *none* + +### Return values + +- *tx_low_power_adjust_ticks* + +### Example + +```c +/* Low power timer adjust function prototype. */ +ULONG low_power_timer_adjust(void); + +/* Define the TX_LOW_POWER_USER_TIMER_ADJUST macro. */ +#define TX_LOW_POWER_USER_TIMER_ADJUST low_power_timer_adjust + +ULONG low_power_timer_adjust(void) +{ + ULONG actual_ticks_slept; + ULONG elapsed_time_in_ms; + + /* Insert code here to read timer registers to determine + how long the processor actually slept. */ + elapsed_time_in_ms = read_timer_register(); + + /* Convert elapsed time to ThreadX ticks. */ + actual_ticks_slept = elapsed_time_in_ms / (1000/TX_TIMER_TICKS_PER_SECOND); + + return(actual_ticks_slept); +} +``` + +--- + +## Summary of Low Power APIs + +- ```tx_low_power_enter``` - *Enter low power mode* +- ```tx_low_power_exit``` - *Exit low power mode* +- ```tx_time_increment``` - *Increment ThreadX timers by specific amount* +- ```tx_timer_get_next``` - *Get next ThreadX timer expiration* + +--- ## tx_low_power_enter @@ -40,26 +224,24 @@ VOID tx_low_power_enter(VOID); ### Description -This service enters low power mode. -For keeping track of time while in low power mode, there are two possibilities: +This service enters low power mode. The macros **TX_LOW_POWER_TIMER_SETUP** and **TX_LOW_POWER_USER_ENTER** are called in this function to allow the user to configure a low power timer and configure the hardware for low power mode. -1. A ThreadX timer is active. Function **tx_timer_get_next** returns **TX_TRUE**. Note that in this situation, a low power clock must be used in order to wake up the CPU for the next ThreadX timer expiration. Therefore an alternative clock must be programmed. Program the hardware timer source such that the next timer interrupt is equal to: *tx_low_power_next_expiration \* tick_frequency*. The *tick_frequency* is application-specific and typically set up in **tx_low_level_initialize**. +For keeping track of time while in low power mode, there are two possibilities: -2. There are no ThreadX timers active. Function **tx_timer_get_next** returns **TX_FALSE**. - 1. The application may choose not to keep the ThreadX internal - tick count updated (define **TX_LOW_POWER_TICKLESS**), therefore there is no need - to set up a low power clock. +1. A ThreadX timer is active. Function ```tx_timer_get_next``` returns **TX_TRUE**. Note that in this situation, a low power clock must be used in order to wake up the CPU for the next ThreadX timer expiration. Therefore a low power timer/clock must be programmed. Program the hardware timer source such that the next timer interrupt is equal to: *tx_low_power_next_expiration \* tick_frequency*. The *tick_frequency* is application-specific and typically set up in ```tx_low_level_initialize```. - 2. The application still needs to keep the ThreadX tick up-to-date. In this case - a low power clock needs to be set up. +2. There are no ThreadX timers active. Function ```tx_timer_get_next``` returns *TX_FALSE*. + 1. The application may choose **not** to keep the ThreadX internal + tick count updated (define **TX_LOW_POWER_TICKLESS**), therefore there is no need to set up a low power clock. + 2. The application still needs to keep the ThreadX tick up-to-date. In this case a low power clock needs to be configured. ### Input parameters -- **none** +- *none* ### Return values -- **none** +- *none* ### Allowed from @@ -67,7 +249,7 @@ Internal ThreadX code, application ### Example -ARM assembly +ARM Cortex-M assembly ```c #ifdef TX_LOW_POWER PUSH {r0-r3} @@ -106,15 +288,15 @@ VOID tx_low_power_exit(VOID); ### Description -This service exits low power mode. +This service exits low power mode. Macro **TX_LOW_POWER_USER_EXIT** is called in this function to allow the user to configure the hardware to exit low power mode. Macro **TX_LOW_POWER_USER_TIMER_ADJUST** is called in this function to determine how long the processor actually slept. ### Input parameters -- **none** +- *none* ### Return values -- **none** +- *none* ### Allowed from @@ -150,7 +332,7 @@ Internal ThreadX code, application ## tx_time_increment -This function increments the current time by a specified value. The value was derived by the application by calling the **tx_timer_get_next** function prior to this call, which was right before the processor was put in low power mode. +This function increments the current time by a specified value. The value was derived by the application by calling the ```tx_timer_get_next``` function prior to this call, which was right before the processor was put in low power mode. ### Prototype @@ -160,15 +342,15 @@ VOID tx_time_increment(ULONG time_increment); ### Description -This function increments the current time by a specified value. The value was derived by the application by calling the **tx_timer_get_next** function prior to this call, which was right before the processor was put in low power mode. +This function increments the current time by a specified value. The value was derived by the application by calling the ```tx_timer_get_next``` function prior to this call, which was right before the processor was put in low power mode. ### Input parameters -- **time_increment** Number of ThreadX ticks to increment time and timers. +- *time_increment* - Number of ThreadX ticks to increment time and timers. ### Return values -- **none** +- *none* ### Allowed from @@ -176,7 +358,7 @@ Internal ThreadX code, application ### Example -From **tx_low_power_exit**: +From ```tx_low_power_exit```: ```c /* Call the low-power timer driver code to obtain the amount of time (in ticks) @@ -213,16 +395,16 @@ ULONG tx_timer_get_next(ULONG *next_timer_tick_ptr); ### Description -This service gets the next ThreadX timer expiration, in ticks. +This service gets the next ThreadX timer expiration, in ticks. ### Input parameters -- **next_timer_tick_ptr** pointer to hold number of ticks +- *next_timer_tick_ptr* - pointer to hold number of ticks ### Return values -- **TX_TRUE** (1) At least one timer is active. -- **TX_FALSE** (0) No timers are currently active. +- *TX_TRUE* (1) At least one timer is active. +- *TX_FALSE* (0) No timers are currently active. ### Allowed from @@ -230,7 +412,7 @@ Internal ThreadX code, application ### Example -From **tx_low_power_enter**: +From ```tx_low_power_enter```: ```c ULONG tx_low_power_next_expiration; /* The next timer expiration (units of ThreadX timer ticks). */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_config.h new file mode 100644 index 00000000..42d6d9a6 --- /dev/null +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_config.h @@ -0,0 +1,105 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_config.h + * Description : Cellular-related config files such as pmod terminal and APN. + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_CONFIG_H +#define EWF_CELLULAR_CONFIG_H + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ + + +/* Specify uart ch used for communication with cellular module */ +#define EWF_CELLULAR_CFG_UART_SCI_CH (6) + +/* Specify the port and pin of the RTS terminal */ +#define EWF_CELLULAR_CFG_RTS_PORT 0 +#define EWF_CELLULAR_CFG_RTS_PIN 2 + +/* Specify the port and pin of the RESET terminal */ +#define EWF_CELLULAR_CFG_RESET_PORT 5 +#define EWF_CELLULAR_CFG_RESET_PIN 5 + + +/* Changes the output format of the reset signal sent to the Cellular module. */ +/* 1: active high 0: active low */ +#define EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC (1) + +/* Sets the RTS pin control method of the Cellular module. */ +/* 0: The CTS pin is controlled by hardware flow control, and the RTS pin is controlled by this FIT module through GPIO. */ +/* 1: The RTS pin is controlled by hardware flow control, and the CTS pin is controlled by this FIT module through GPIO. */ +#define EWF_CELLULAR_CFG_CTS_SW_CTRL (0) //unused + +/* Specify the port and pin of the CTC */ +#define EWF_CELLULAR_CFG_CTS_PORT 2 //unused +#define EWF_CELLULAR_CFG_CTS_PIN 2 //unused + + +/* Specifies the pin function control register (PFS) setting value */ +/* to select the peripheral function of the MCU pin used to control the RTS pin of */ +/* the Cellular module. Set this option to match the pin to be used. */ +/* This option takes effect when EWF_CELLULAR_CFG_CTS_SW_CTRL is set to 1. */ +#define EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU //unused + +/* Specify IRQ terminal for RING terminal */ +#define EWF_CELLULAR_CFG_IRQ_NUM (4) //unused + +/* The SIM PIN for the modem */ +#define EWF_CONFIG_SIM_PIN ("0000") + +/* The SIM operator APN */ +#define EWF_CONFIG_SIM_APN ("globaldata.iot") + +/* The modem context ID used */ +#define EWF_CONFIG_CONTEXT_ID (1) +/* Board dependent settings; please use the value for each setting listed below depending on the board you use. + +Preprocessors that define board dependent settings and the corresponding values to be set are as follows: +Confirmed board number 1, +EWF_CELLULAR_CFG_UART_SCI_CH 6, +EWF_CELLULAR_CFG_RTS_PORT 0, +EWF_CELLULAR_CFG_RTS_PIN 2, +EWF_CELLULAR_CFG_RESET_PORT 5, +EWF_CELLULAR_CFG_RESET_PIN 5, +EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC 1, +EWF_CELLULAR_CFG_CTS_SW_CTRL 0, +EWF_CELLULAR_CFG_CTS_PORT 2, +EWF_CELLULAR_CFG_CTS_PIN 2, +EWF_CELLULAR_CFG_PFS_SET_VALUE 0x0BU, +EWF_CELLULAR_CFG_IRQ_NUM 4, +EWF_CONFIG_SIM_PIN "0000", +EWF_CONFIG_SIM_APN "globaldata.iot", +EWF_CONFIG_CONTEXT_ID 1 + +where the confirmed board numbers listed in the first row above are as follows: +1: CK-RX65N (PMOD1), +In the above preprocessor list, please use one of the values listed on the right side. +On the right side, each column corresponds to each confirmed board number. + +Note: +Please supply power source to USB(CN4) port on RYZ014A/RYZ024A-PMOD. +E2 emulator supplying power to RYZ014A/RYZ024A-PMOD may result in insufficient power source. +The E2 emulator can provide 200mA, but RYZ014A/RYZ024A needs more current while connecting to the network. + +*/ +#endif /* EWF_CELLULAR_CONFIG_H */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_private.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_private.h new file mode 100644 index 00000000..d4c7c4bb --- /dev/null +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_cellular_private.h @@ -0,0 +1,169 @@ +/********************************************************************************************************************** + * DISCLAIMER + * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No + * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all + * applicable laws, including copyright laws. + * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING + * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM + * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES + * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO + * THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of + * this software. By using this software, you agree to the additional terms and conditions found by accessing the + * following link: + * http://www.renesas.com/disclaimer + * + * Copyright (C) 2022 Renesas Electronics Corporation. All rights reserved. + *********************************************************************************************************************/ +/********************************************************************************************************************** + * File Name : ewf_cellular_private.h + * Description : Macro for controlling the pmod terminal + *********************************************************************************************************************/ + +#ifndef EWF_CELLULAR_PRIVATE_H_ +#define EWF_CELLULAR_PRIVATE_H_ + +/********************************************************************************************************************** + * Includes , "Project Includes" + *********************************************************************************************************************/ +#include "r_sci_rx_if.h" +#include "r_sci_rx_pinset.h" +#include "ewf_cellular_config.h" + + +/* PDR port macros. */ +#define EWF_CELLULAR_SET_PDR(x, y) (EWF_CELLULAR_SET_PDR_PREPROC(x, y)) +/* Set the port direction. */ +#define EWF_CELLULAR_SET_PDR_PREPROC(x, y) ((PORT ## x .PDR.BIT.B ## y)) + +/* PODR port macros. */ +#define EWF_CELLULAR_SET_PODR(x, y) (EWF_CELLULAR_SET_PODR_PREPROC(x, y)) +/* Set the port I/O. */ +#define EWF_CELLULAR_SET_PODR_PREPROC(x, y) ((PORT ## x .PODR.BIT.B ## y)) + +#define EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT (1) + +/* Changes the output format of the reset signal sent to the Cellular module. */ +#if EWF_CELLULAR_CFG_RESET_SIGNAL_LOGIC == 1 +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (1) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (0) +#else +#define EWF_CELLULAR_CFG_RESET_SIGNAL_ON (0) +#define EWF_CELLULAR_CFG_RESET_SIGNAL_OFF (1) +#endif + + +#ifndef EWF_CELLULAR_CFG_UART_SCI_CH +#error "Error! Need to define EWF_CELLULAR_CFG_UART_SCI_CH in ewf_cellular_config.h" +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (0) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI0() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI0()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH0) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH0_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH0_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (1) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI1() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI1()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH1) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH1_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH1_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (2) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI2() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI2()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH2) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH2_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH2_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (3) +#if defined(__CCRX__) || defined(__ICCRX__) || defined(__RX__) +/* Store R_SCI_PinSet_SCI3() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI3()) +#elif defined(__CCRL__) || defined(__ICCRL78__) || defined(__RL) +/* Emptying R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() +#endif +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH3) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH3_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH3_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (4) +/* Store R_SCI_PinSet_SCI4() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI4()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH4) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH4_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH4_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (5) +/* Store R_SCI_PinSet_SCI5() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI5()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH5) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH5_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH5_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (6) +/* Store R_SCI_PinSet_SCI6() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI6()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH6) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH6_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH6_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (7) +/* Store R_SCI_PinSet_SCI7() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI7()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH7) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH7_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH7_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (8) +/* Store R_SCI_PinSet_SCI8() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI8()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH8) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH8_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH8_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (9) +/* Store R_SCI_PinSet_SCI9() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI9()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH9) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH9_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH9_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (10) +/* Store R_SCI_PinSet_SCI10() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI10()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH10) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH10_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH10_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (11) +/* Store R_SCI_PinSet_SCI11() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI11()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH11) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH11_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH11_RX_BUFSIZ) +#elif EWF_CELLULAR_CFG_UART_SCI_CH == (12) +/* Store R_SCI_PinSet_SCI12() in R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() */ +#define R_SCI_CFG_PINSET_EWF_CELLULAR_SERIAL() (R_SCI_PinSet_SCI12()) +#define R_SCI_CFG_EWF_CELLULAR_SERIAL_CH (SCI_CH12) +#define R_SCI_CFG_TX_BUFSIZE (SCI_CFG_CH12_TX_BUFSIZ) +#define R_SCI_CFG_RX_BUFSIZE (SCI_CFG_CH12_RX_BUFSIZ) +#else +#error "Error! Invalid setting for EWF_CELLULAR_UART_SCI_CH in ewf_cellular_config.h" +#endif /* EWF_CELLULAR_CFG_UART_SCI_CH */ + + +#if R_SCI_CFG_TX_BUFSIZE < (1500) +#error "The SCI send buffer size is too small." +#endif +#if R_SCI_CFG_RX_BUFSIZE < (1500) +#error "The SCI receive buffer size is too small." +#endif + +#endif /* EWF_CELLULAR_PRIVATE_H_ */ diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h index e9944be1..bdc7e66b 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/ewf_example.config.h @@ -35,23 +35,6 @@ extern "C" { /** @} *** group_example_configuration_allocator */ -/** - * @defgroup group_example_configuration_modem Modem configuration - * @brief Modem configuration settings used in examples - * @{ - */ - -/** @brief The SIM PIN for the modem */ -#define EWF_CONFIG_SIM_PIN ("0000") - -/** @brief The SIM operator APN */ -#define EWF_CONFIG_SIM_APN ("internet.telekom") - -/** @brief The modem context ID used */ -#define EWF_CONFIG_CONTEXT_ID (1) - -/** @} *** group_example_configuration_modem */ - /** * @defgroup group_example_configuration_iot_hub IoT Hub configuration * @brief IoT Hub configuration settings used in examples diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/linker_script.ld b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/linker_script.ld index 90dbd2cd..80f0bb85 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/linker_script.ld +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/linker_script.ld @@ -149,15 +149,15 @@ SECTIONS { KEEP(*(.ofs8)) } > OFS -.r_bsp_NULL : + .r_bsp_NULL : { . += 0x100; "_r_bsp_NULL_end" = .; - } >RAM + } >RAM AT>RAM .r_bsp_istack BLOCK(0x4) (NOLOAD) : { KEEP(*(.r_bsp_istack)) - } >RAM + } >RAM AT>RAM .istack : { "_istack" = .; @@ -165,7 +165,7 @@ SECTIONS .r_bsp_ustack BLOCK(0x4) (NOLOAD) : { KEEP(*(.r_bsp_ustack)) - } >RAM + } >RAM AT>RAM .ustack : { "_ustack" = .; diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c index 370bc2d9..f1f2124a 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_pnp_ryz014/src/rtos_skeleton/application_thread_entry.c @@ -72,6 +72,8 @@ Includes , "Project Includes" #include "ewf_example.config.h" +#include "ewf_cellular_private.h" + /* Modem might take some minutes to attach and register to the network. Time out value in seconds */ #define EWF_ADAPTER_RENESAS_NETWORK_REGISTER_TIMEOUT (1200) @@ -169,10 +171,10 @@ void application_thread_entry(ULONG entry_input) // Release the RYZ014A from reset - PORTA.PODR.BIT.B1= 1; - PORTA.PDR.BIT.B1= 1; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_ON; + EWF_CELLULAR_SET_PDR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_PIN_DIRECTION_MODE_OUTPUT; tx_thread_sleep (200); - PORTA.PODR.BIT.B1= 0; + EWF_CELLULAR_SET_PODR(EWF_CELLULAR_CFG_RESET_PORT, EWF_CELLULAR_CFG_RESET_PIN) = EWF_CELLULAR_CFG_RESET_SIGNAL_OFF; printf("Waiting for the module to Power Reset!\r\n"); ewf_platform_sleep(300); printf("Ready\r\n"); diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject index df3d2d7c..dc873946 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/.cproject @@ -50,6 +50,21 @@ @@ -132,7 +131,6 @@ - diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch index 911cfd87..257133de 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014 HardwareDebug.launch @@ -29,7 +29,7 @@ - + diff --git a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg index 07e7c3f0..0ccdf646 100644 --- a/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg +++ b/examples/CK_RX65N_GCCRX/ewf_netx_duo_azure_iot_embedded_sdk_ryz014/ewf_netx_duo_azure_iot_embedded_sdk_ryz014.scfg @@ -7,17 +7,17 @@
-