From 5448c8fa39a637a2971c03f94835460bac3a3727 Mon Sep 17 00:00:00 2001 From: Jakub Zimnol Date: Thu, 7 Sep 2023 16:03:41 +0200 Subject: [PATCH] Anjay-esp-idf 0.0.1 --- .gitignore | 3 + .gitmodules | 7 + CHANGELOG.md | 7 + CMakeLists.txt | 59 ++ Kconfig | 357 ++++++++ LICENSE | 202 +++++ README.md | 7 + config/anjay/anjay_config.h | 754 ++++++++++++++++ config/avsystem/coap/avs_coap_config.h | 183 ++++ config/avsystem/commons/avs_commons_config.h | 879 +++++++++++++++++++ config/avsystem/commons/lwip-posix-compat.h | 53 ++ deps/FreeRTOS-Cellular-Interface | 1 + deps/anjay | 1 + 13 files changed, 2513 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CHANGELOG.md create mode 100644 CMakeLists.txt create mode 100644 Kconfig create mode 100644 LICENSE create mode 100644 README.md create mode 100644 config/anjay/anjay_config.h create mode 100644 config/avsystem/coap/avs_coap_config.h create mode 100644 config/avsystem/commons/avs_commons_config.h create mode 100644 config/avsystem/commons/lwip-posix-compat.h create mode 160000 deps/FreeRTOS-Cellular-Interface create mode 160000 deps/anjay diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..399cf84 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +.vscode +__pycache__ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..74c85d2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,7 @@ +[submodule "deps/anjay"] + path = deps/anjay + url = https://github.com/AVSystem/Anjay.git +[submodule "deps/FreeRTOS-Cellular-Interface"] + path = deps/FreeRTOS-Cellular-Interface + url = https://github.com/AVSystem/FreeRTOS-Cellular-Interface.git + branch = esp32-client-v1.2.0 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0512e90 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## 0.0.1 (September 7th, 2023) + +### Features + - Initialized repository with `Anjay` and `FreeRTOS-Cellular-Interface` submodules + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..939652b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,59 @@ +# Copyright 2023 AVSystem +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +file(GLOB_RECURSE ANJAY_SOURCES + "deps/anjay/src/*.c" + "deps/anjay/deps/avs_coap/src/*.c" + "deps/anjay/deps/avs_commons/src/*.c") + +idf_component_register(SRCS + ${ANJAY_SOURCES} + INCLUDE_DIRS + "config" + "deps/anjay/include_public" + "deps/anjay/deps/avs_coap/include_public" + "deps/anjay/deps/avs_commons/include_public" + PRIV_INCLUDE_DIRS + "deps/anjay/src" + "deps/anjay/deps/avs_coap/src" + "deps/anjay/deps/avs_commons/src" + PRIV_REQUIRES + idf::mbedtls) + +if (CONFIG_ANJAY_ESP_IDF_WITH_BG96_SUPPORT) + file(GLOB_RECURSE FREERTOS_CELLULAR_LIBRARY_SOURCES + "deps/FreeRTOS-Cellular-Interface/source/*.c" + "deps/FreeRTOS-Cellular-Interface/modules/bg96/*.c" + "deps/FreeRTOS-Cellular-Interface/modules/cellular_platform.c") + add_library(freertos_cellular_library MODULE ${FREERTOS_CELLULAR_LIBRARY_SOURCES}) + target_include_directories(freertos_cellular_library PRIVATE + "deps/FreeRTOS-Cellular-Interface/source/include/private" + "deps/FreeRTOS-Cellular-Interface/modules/bg96") + target_include_directories(freertos_cellular_library PUBLIC + "deps/FreeRTOS-Cellular-Interface/source/include" + "deps/FreeRTOS-Cellular-Interface/source/include/common" + "deps/FreeRTOS-Cellular-Interface/source/logging" + "deps/FreeRTOS-Cellular-Interface/source/cellular_network_transport" + "deps/FreeRTOS-Cellular-Interface/source/interface" + "deps/FreeRTOS-Cellular-Interface/modules") + target_link_libraries(freertos_cellular_library PRIVATE ${COMPONENT_LIB}) +endif() + +# NOTE: avs_coap contains some assertions that check if allocated memory +# follows alignment requirements. malloc() on ESP-IDF aligns everything +# to 4 bytes, even though alignof(max_align_t) == alignof(int64_t) +# == alignof(long double) == 8. This is just GCC being overly cautious, +# the maximum hardware-imposed alignment on ESP32 is actually 4 bytes. +# We disable assertions within anjay to work around that. +target_compile_definitions(${COMPONENT_TARGET} PRIVATE "NDEBUG") diff --git a/Kconfig b/Kconfig new file mode 100644 index 0000000..909665d --- /dev/null +++ b/Kconfig @@ -0,0 +1,357 @@ +# Copyright 2023 AVSystem +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +menu "Anjay library configuration" + +menuconfig ANJAY_ESP_IDF_WITH_BG96_SUPPORT + bool "Enable support for external BG96 module" + default n + +if ANJAY_ESP_IDF_WITH_BG96_SUPPORT + menu "BG96 module configuration" + + config ANJAY_BG96_UART_PORT_NUMBER + int "UART port number" + default 0 + + config ANJAY_BG96_TX_PIN + int "UART Tx pin" + default 0 + + config ANJAY_BG96_RX_PIN + int "UART Rx pin" + default 0 + endmenu + + choice ANJAY_CELLULAR_PDN_AUTH_TYPE + prompt "PDN authentication type" + default ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE + + config ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE + bool "No authentication" + + config ANJAY_CELLULAR_PDN_AUTH_TYPE_PAP + bool "PAP" + + config ANJAY_CELLULAR_PDN_AUTH_TYPE_CHAP + bool "CHAP" + + config ANJAY_CELLULAR_PDN_AUTH_TYPE_PAP_OR_CHAP + bool "PAP or CHAP" + endchoice + + config ANJAY_CELLULAR_APN + string "APN name" + default "Cellular APN" + + config ANJAY_CELLULAR_PDN_USERNAME + string "PDN username" if !ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE + default "" + + config ANJAY_CELLULAR_PDN_PASSWORD + string "PDN password" if !ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE + default "" +endif + +menuconfig ANJAY_LIBRARY_WITH_LOGS + bool "Enable logging in Anjay, avs_commons and avs_coap" + default y + help + If this flag is disabled, no logging is compiled into the binary at all. + + config ANJAY_WITH_LOGS + bool "Enable logging in Anjay." + default y + depends on ANJAY_LIBRARY_WITH_LOGS + + config WITH_AVS_COAP_LOGS + bool "Enable logging in avs_coap." + default y + depends on ANJAY_LIBRARY_WITH_LOGS + + config AVS_COMMONS_WITH_INTERNAL_LOGS + bool "Enable logging in avs_commons." + default y + depends on ANJAY_LIBRARY_WITH_LOGS + + menuconfig ANJAY_LIBRARY_WITH_TRACE_LOGS + bool "Enable TRACE-level logs in Anjay, avs_commons and avs_coap." + default y + depends on ANJAY_LIBRARY_WITH_LOGS + + config ANJAY_WITH_TRACE_LOGS + bool "Enable TRACE-level logs in Anjay." + default y + depends on ANJAY_LIBRARY_WITH_TRACE_LOGS && ANJAY_WITH_LOGS + + config WITH_AVS_COAP_TRACE_LOGS + bool "Enable TRACE-level logs in avs_coap." + default y + depends on ANJAY_LIBRARY_WITH_TRACE_LOGS && WITH_AVS_COAP_LOGS + + config AVS_COMMONS_WITH_INTERNAL_TRACE + bool "Enable TRACE-level logs in avs_commons." + default y + depends on ANJAY_LIBRARY_WITH_TRACE_LOGS && AVS_COMMONS_WITH_INTERNAL_LOGS + + config ANJAY_WITH_MICRO_LOGS + bool "Enable the \"micro logs\" feature." + default n + help + Replaces all occurrences of the AVS_DISPOSABLE_LOG() macro with single + space strings. This is intended to reduce the size of the compiled code, by + stripping it of almost all log string data. + + Note that this setting will propagate both to avs_commons components + themselves (as all its internal logs make use of AVS_DISPOSABLE_LOG()) + and the user code that uses it. + depends on ANJAY_LIBRARY_WITH_LOGS + +config ANJAY_WITH_ACCESS_CONTROL + bool "Enable core support for Access Control mechanisms." + default n + help + Requires separate implementation of the Access Control object itself. + Either the implementation available as part of + ANJAY_WITH_MODULE_ACCESS_CONTROL, or a custom application-provided one + may be used. + +config ANJAY_WITH_ATTR_STORAGE + bool "Enable attr_storage module" + default y + +config ANJAY_WITH_DOWNLOADER + bool "Enable support for the anjay_download() API." + default y + +config ANJAY_WITH_COAP_DOWNLOAD + bool "Enable support for CoAP(S) downloads." + default y + depends on ANJAY_WITH_DOWNLOADER + +config ANJAY_WITH_HTTP_DOWNLOAD + bool "Enable support for HTTP(S) downloads." + default n + depends on ANJAY_WITH_DOWNLOADER + +config ANJAY_WITH_BOOTSTRAP + bool "Enable support for the LwM2M Bootstrap Interface." + default y + +config ANJAY_WITH_DISCOVER + bool "Enable support for the LwM2M Discover operation." + default y + +config ANJAY_WITH_OBSERVE + bool "Enable support for the LwM2M Information Reporting interface." + default y + help + Information Reporting interface includes Observe and Notify operations + +config ANJAY_WITH_OBSERVE_PERSISTENCE + bool "Enable support for observation persistence" + default n + depends on ANJAY_WITH_OBSERVE + +config ANJAY_WITH_NET_STATS + bool "Enable support for measuring amount of LwM2M traffic." + default n + +config ANJAY_WITH_COMMUNICATION_TIMESTAMP_API + bool "Enable support for communication timestamp API." + default n + help + Enable anjay_get_server_last_registration_time(), + anjay_get_server_next_update_time() and + anjay_get_server_last_communication_time() functions. + +config ANJAY_WITH_OBSERVATION_STATUS + bool "Enable support for the anjay_resource_observation_status() API." + default y + +config ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER + int "Maximum number of listed servers that observe a given Resource." + default 0 + depends on ANJAY_WITH_OBSERVATION_STATUS + help + Maximum number of servers observing a given Resource listed by + anjay_resource_observation_status() function. + +config ANJAY_WITH_THREAD_SAFETY + bool "Enable guarding of all accesses to anjay_t with a mutex." + default y + +if !ANJAY_ESP_IDF_WITH_BG96_SUPPORT + config ANJAY_WITH_EVENT_LOOP + bool "Enable standard implementation of an event loop" + default y +endif + +config ANJAY_WITH_LWM2M11 + bool "Enable support for features new to LwM2M protocol version 1.1." + default y + +config ANJAY_WITH_SEND + bool "Enable support for the LwM2M Send operation." + default y + depends on ANJAY_WITH_LWM2M11 + help + Requires either SENML_JSON or CBOR format to be enabled + + +config ANJAY_WITHOUT_QUEUE_MODE_AUTOCLOSE + bool "Disable automatic closing of server connection sockets after MAX_TRANSMIT_WAIT of inactivity." + default n + +config ANJAY_WITH_LEGACY_CONTENT_FORMAT_SUPPORT + bool "Enable support for legacy CoAP Content-Format values" + default n + help + Enable support for legacy CoAP Content-Format numerical values 1541-1543 that + have been used before final LwM2M TS 1.0. + +config ANJAY_WITH_LWM2M_JSON + bool "Enable support for JSON format as specified in LwM2M TS 1.0." + default n + +config ANJAY_WITHOUT_TLV + bool "Disable support for TLV format as specified in LwM2M TS 1.0." + default n + +config ANJAY_WITHOUT_PLAINTEXT + bool "Disable support for Plain Text format as specified in LwM2M TS 1.0. and 1.1" + default n + +config ANJAY_WITHOUT_DEREGISTER + bool "Disable use of the Deregister message." + default n + +if ANJAY_ESP_IDF_WITH_BG96_SUPPORT + config ANJAY_WITHOUT_IP_STICKINESS + bool "Disable support for \"IP stickiness\"" + default y + help + "IP stickiness" is a preference of the same IP address when reconnecting to + a server using a domain name. +endif + +config ANJAY_WITH_SENML_JSON + bool "Enable support for SenML JSON format, as specified in LwM2M TS 1.1." + default y + depends on ANJAY_WITH_LWM2M11 + +config ANJAY_WITH_CBOR + bool "Enable support for CBOR and SenML CBOR formats, as specified in LwM2M TS 1.1." + default y + depends on ANJAY_WITH_LWM2M11 + + +config ANJAY_WITH_CON_ATTR + bool "Enable support for custom \"con\" attribute that controls Confirmable notifications." + default n + depends on ANJAY_WITH_OBSERVE + +config ANJAY_WITH_SECURITY_STRUCTURED + bool "Enable support for handling security credentials in the data model using structured avs_crypto types." + default n + +config ANJAY_MAX_PK_OR_IDENTITY_SIZE + int "Maximum size of the \"Public Key or Identity\"" + default 256 + help + Maximum size in bytes supported for the \"Public Key or Identity\" resource + in the LwM2M Security object. + +config ANJAY_MAX_SECRET_KEY_SIZE + int "Maximum size of the \"Secret Key\"" + default 128 + help + Maximum size in bytes supported for the \"Secret Key\" resource in the LwM2M + Security Object. + +config ANJAY_MAX_DOUBLE_STRING_SIZE + int "Maximum length supported for stringified floating-point values." + default 64 + help + Used when parsing plaintext and SenML JSON content formats - when parsing a + floating-point value, any string of length equal or greater than this setting + will automatically be considered invalid, even if it could in theory be + parsed as a valid number. + +config ANJAY_MAX_URI_SEGMENT_SIZE + int "Maximum length supported for a single Uri-Path or Location-Path segment." + default 64 + help + When handling incoming CoAP messages, any Uri-Path or Location-Path option of + length equal or greater than this setting will be considered invalid. + +config ANJAY_MAX_URI_QUERY_SEGMENT_SIZE + int "Maximum length supported for a single Uri-Query segment." + default 64 + help + When handling incoming CoAP messages, any Uri-Query option of length equal or + greater than this setting will be considered invalid. + +config ANJAY_DTLS_SESSION_BUFFER_SIZE + int "DTLS buffer size" + default 1024 + help + Size of buffer allocated for storing DTLS session state when connection is + not in use (e.g. during queue mode operation). + +config ANJAY_WITH_MODULE_ACCESS_CONTROL + bool "Enable access control module" + default n + depends on ANJAY_WITH_ACCESS_CONTROL + +config ANJAY_WITH_MODULE_SECURITY + bool "Enable security module" + default y + + +config ANJAY_WITH_MODULE_SERVER + bool "Enable server module" + default y + +config ANJAY_WITH_MODULE_FW_UPDATE + bool "Enable fw_update module" + default y + depends on ANJAY_WITH_DOWNLOADER + +config ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE + bool "Enable advanced_fw_update module" + default n + depends on ANJAY_WITH_DOWNLOADER + +config ANJAY_WITHOUT_MODULE_FW_UPDATE_PUSH_MODE + bool "Disable support for PUSH mode Firmware Update." + depends on ANJAY_WITH_MODULE_FW_UPDATE + +config ANJAY_WITH_MODULE_IPSO_OBJECTS + bool "Enable IPSO objects implementation" + default y + + +config ANJAY_WITH_MODULE_FACTORY_PROVISIONING + bool "Enable factory provisioning module" + default n + depends on ANJAY_WITH_CBOR + +if !ANJAY_ESP_IDF_WITH_BG96_SUPPORT + config AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET + bool "Enables the default implementation of avs_net TCP and UDP sockets" + default y +endif + +endmenu diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3c504f2 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Anjay-esp-idf [](http://www.avsystem.com/) + +Anjay LwM2M library component for `esp-idf` environment. + +More information on Anjay can be found here: [Anjay Github](https://github.com/AVSystem/Anjay). + +An example of usage can be found here: [Anjay esp32 Client](https://github.com/AVSystem/Anjay-esp32-client). diff --git a/config/anjay/anjay_config.h b/config/anjay/anjay_config.h new file mode 100644 index 0000000..a09737d --- /dev/null +++ b/config/anjay/anjay_config.h @@ -0,0 +1,754 @@ +/* + * Copyright 2023 AVSystem + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANJAY_CONFIG_H +#define ANJAY_CONFIG_H + +#include + +/** + * @file anjay_config.h + * + * Anjay library configuration. + * + * The preferred way to compile Anjay is to use CMake, in which case this file + * will be generated automatically by CMake. + * + * However, to provide compatibility with various build systems used especially + * by embedded platforms, it is alternatively supported to compile Anjay by + * other means, in which case this file will need to be provided manually. + * + * NOTE: To compile this library without using CMake, you need to + * configure avs_commons and avs_coap first. Please refer to documentation in + * the avs_commons_config.h and avs_coap_config.h files (provided + * in the repositories as avs_commons_config.h.in and + * avs_coap_config.h.in, respectively) for details. + * + * Anjay requires the following avs_coap options to be enabled: + * + * - @c WITH_AVS_COAP_UDP + * - @c WITH_AVS_COAP_STREAMING_API + * - @c WITH_AVS_COAP_BLOCK is highly recommended + * - @c WITH_AVS_COAP_OBSERVE (if @c ANJAY_WITH_OBSERVE is enabled) + * - @c WITH_AVS_COAP_OSCORE (if @c ANJAY_WITH_COAP_OSCORE is enabled, available + * only as a commercial feature) + * + * Anjay requires the following avs_commons components to be + * enabled: + * + * - All components required by avs_coap, see avs_coap_config.h + * - @c avs_algorithm + * - @c avs_stream + * - @c avs_url + * - @c avs_persistence is highly recommended + * - @c avs_http (if @c ANJAY_WITH_HTTP_DOWNLOAD is enabled) + * - @c avs_rbtree (if @c ANJAY_WITH_OBSERVE or + * @c ANJAY_WITH_MODULE_ACCESS_CONTROL is enabled) + * + * In the repository, this file is provided as anjay_config.h.in, + * intended to be processed by CMake. If editing this file manually, please copy + * or rename it to anjay_config.h and for each of the + * \#cmakedefine directives, please either replace it with regular + * \#define to enable it, or comment it out to disable. You may also need + * to replace variables wrapped in \@ signs with concrete values. Please + * refer to the comments above each of the specific definition for details. + * + * If you are editing a file previously generated by CMake, these + * \#cmakedefines will be already replaced by either \#define or + * commented out \#undef directives. + */ + +/** + * Enable logging in Anjay. + * + * If this flag is disabled, no logging is compiled into the binary at all. + */ +#ifdef CONFIG_ANJAY_WITH_LOGS +# define ANJAY_WITH_LOGS +#endif // CONFIG_ANJAY_WITH_LOGS + +/** + * Enable TRACE-level logs in Anjay. + * + * Only meaningful if ANJAY_WITH_LOGS is enabled. + */ +#ifdef CONFIG_ANJAY_WITH_TRACE_LOGS +# define ANJAY_WITH_TRACE_LOGS +#endif // CONFIG_ANJAY_WITH_TRACE_LOGS + +/** + * Enable core support for Access Control mechanisms. + * + * Requires separate implementation of the Access Control object itself. + * Either the implementation available as part of + * ANJAY_WITH_MODULE_ACCESS_CONTROL, or a custom application-provided one + * may be used. + */ +#ifdef CONFIG_ANJAY_WITH_ACCESS_CONTROL +# define ANJAY_WITH_ACCESS_CONTROL +#endif // CONFIG_ANJAY_WITH_ACCESS_CONTROL + +/** + * Enable automatic attribute storage. + * + * Requires AVS_COMMONS_WITH_AVS_PERSISTENCE to be enabled in avs_commons + * configuration. + */ +#ifdef CONFIG_ANJAY_WITH_ATTR_STORAGE +# define ANJAY_WITH_ATTR_STORAGE +#endif // CONFIG_ANJAY_WITH_ATTR_STORAGE + +/** + * Enable support for the anjay_download() API. + */ +#ifdef CONFIG_ANJAY_WITH_DOWNLOADER +# define ANJAY_WITH_DOWNLOADER +#endif // CONFIG_ANJAY_WITH_DOWNLOADER + +/** + * Enable support for CoAP(S) downloads. + * + * Only meaningful if ANJAY_WITH_DOWNLOADER is enabled. + */ +#ifdef CONFIG_ANJAY_WITH_COAP_DOWNLOAD +# define ANJAY_WITH_COAP_DOWNLOAD +#endif // CONFIG_ANJAY_WITH_COAP_DOWNLOAD + +/** + * Enable support for HTTP(S) downloads. + * + * Only meaningful if ANJAY_WITH_DOWNLOADER is enabled. + */ +#ifdef CONFIG_ANJAY_WITH_HTTP_DOWNLOAD +# define ANJAY_WITH_HTTP_DOWNLOAD +#endif // CONFIG_ANJAY_WITH_HTTP_DOWNLOAD + +/** + * Enable support for the LwM2M Bootstrap Interface. + */ +#ifdef CONFIG_ANJAY_WITH_BOOTSTRAP +# define ANJAY_WITH_BOOTSTRAP +#endif // CONFIG_ANJAY_WITH_BOOTSTRAP + +/** + * Enable support for the LwM2M Discover operation. + * + * Note that it is required for full compliance with the LwM2M protocol. + */ +#ifdef CONFIG_ANJAY_WITH_DISCOVER +# define ANJAY_WITH_DISCOVER +#endif // CONFIG_ANJAY_WITH_DISCOVER + +/** + * Enable support for the LwM2M Information Reporting interface (Observe and + * Notify operations). + * + * Requires WITH_AVS_COAP_OBSERVE to be enabled in avs_coap + * configuration. + * + * Note that it is required for full compliance with the LwM2M protocol. + */ +#ifdef CONFIG_ANJAY_WITH_OBSERVE +# define ANJAY_WITH_OBSERVE +#endif // CONFIG_ANJAY_WITH_OBSERVE + +/** + * Enable support for measuring amount of LwM2M traffic + * (anjay_get_tx_bytes(), anjay_get_rx_bytes(), + * anjay_get_num_incoming_retransmissions() and + * anjay_get_num_outgoing_retransmissions() APIs. + */ +#ifdef CONFIG_ANJAY_WITH_NET_STATS +# define ANJAY_WITH_NET_STATS +#endif // CONFIG_ANJAY_WITH_NET_STATS + +/** + * Enable support for communication timestamp + * (anjay_get_server_last_registration_time() + * anjay_get_server_next_update_time() and + * anjay_get_server_last_communication_time()) APIs. + */ +#ifdef CONFIG_ANJAY_WITH_COMMUNICATION_TIMESTAMP_API +# define ANJAY_WITH_COMMUNICATION_TIMESTAMP_API +#endif // CONFIG_ANJAY_WITH_COMMUNICATION_TIMESTAMP_API + +/** + * Enable support for the anjay_resource_observation_status() API. + */ +#ifdef CONFIG_ANJAY_WITH_OBSERVATION_STATUS +# define ANJAY_WITH_OBSERVATION_STATUS +#endif // CONFIG_ANJAY_WITH_OBSERVATION_STATUS + +/** + * Maximum number of servers observing a given Resource listed by + * anjay_resource_observation_status() function. + * + * Only meaningful if ANJAY_WITH_OBSERVATION_STATUS is enabled. + */ +#define ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER \ + (CONFIG_ANJAY_MAX_OBSERVATION_SERVERS_REPORTED_NUMBER) + +/** + * Enable guarding of all accesses to anjay_t with a mutex. + */ +#ifdef CONFIG_ANJAY_WITH_THREAD_SAFETY +# define ANJAY_WITH_THREAD_SAFETY +#endif // CONFIG_ANJAY_WITH_THREAD_SAFETY + +/** + * Enable standard implementation of an event loop. + * + * Requires C11 stdatomic.h header to be available, and either a platform + * that provides a BSD-compatible socket API, or a compatibility layer file (see + * AVS_COMMONS_POSIX_COMPAT_HEADER in avs_commons_config.h). This + * is designed to best work with the defalt implementation of avs_net sockets + * (see AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET), but alternative socket + * implementations can also be used. + * + * The event loop is most useful when thread safety features + * (@ref ANJAY_WITH_THREAD_SAFETY and AVS_COMMONS_SCHED_THREAD_SAFE) are + * enabled as well, but this is not a hard requirement. See the documentation + * for anjay_event_loop_run() for details. + */ +#ifdef CONFIG_ANJAY_WITH_EVENT_LOOP +# define ANJAY_WITH_EVENT_LOOP +#endif // CONFIG_ANJAY_WITH_EVENT_LOOP + +/** + * Enable support for features new to LwM2M protocol version 1.1. + */ +#ifdef CONFIG_ANJAY_WITH_LWM2M11 +# define ANJAY_WITH_LWM2M11 +#endif // CONFIG_ANJAY_WITH_LWM2M11 + +/** + * Enable support for OSCORE-based security for LwM2M connections. + * + * Requires ANJAY_WITH_LWM2M11 to be enabled, and + * WITH_AVS_COAP_OSCORE to be enabled in avs_coap configuration. + * + * IMPORTANT: Only available as part of the OSCORE commercial feature. Ignored + * in the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_COAP_OSCORE +# define ANJAY_WITH_COAP_OSCORE +#endif // CONFIG_ANJAY_WITH_COAP_OSCORE + +/** + * Enable support for the LwM2M Send operation. + * + * Requires ANJAY_WITH_LWM2M11 and either ANJAY_WITH_SENML_JSON or + * ANJAY_WITH_CBOR to be enabled. + */ +#ifdef CONFIG_ANJAY_WITH_SEND +# define ANJAY_WITH_SEND +#endif // CONFIG_ANJAY_WITH_SEND + +/** + * Enable support for the SMS binding and the SMS trigger mechanism. + * + * Requires WITH_AVS_COAP_UDP to be enabled in avs_coap configuration. + * + * IMPORTANT: Only available as part of the SMS commercial feature. Ignored in + * the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_SMS +# define ANJAY_WITH_SMS +#endif // CONFIG_ANJAY_WITH_SMS + +/** + * Enable support for sending and receiving multipart SMS messages. + * + * Requires ANJAY_WITH_SMS to be enabled. + * + * IMPORTANT: Only available as part of the SMS commercial feature. Ignored in + * the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_SMS_MULTIPART +# define ANJAY_WITH_SMS_MULTIPART +#endif // CONFIG_ANJAY_WITH_SMS_MULTIPART + +/** + * Enable support for Non-IP Data Delivery. + * + * Requires ANJAY_WITH_LWM2M11 to be enabled, and + * WITH_AVS_COAP_UDP to be enabled in avs_coap configuration. + * + * IMPORTANT: Only available as a commercial feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_WITH_NIDD +# define ANJAY_WITH_NIDD +#endif // CONFIG_ANJAY_WITH_NIDD + +/** + * Enable support for core state persistence + * (anjay_new_from_core_persistence() and + * anjay_delete_with_core_persistence() APIs). + * + * Requires ANJAY_WITH_OBSERVE to be enabled, + * AVS_COMMONS_WITH_AVS_PERSISTENCE to be enabled in avs_commons, and + * WITH_AVS_COAP_OBSERVE_PERSISTENCE to be enabled in avs_coap + * configuration. + * + * IMPORTANT: Only available as a commercial feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_WITH_CORE_PERSISTENCE +# define ANJAY_WITH_CORE_PERSISTENCE +#endif // CONFIG_ANJAY_WITH_CORE_PERSISTENCE + +/** + * Disable automatic closing of server connection sockets after + * MAX_TRANSMIT_WAIT of inactivity. + */ +#ifdef CONFIG_ANJAY_WITHOUT_QUEUE_MODE_AUTOCLOSE +# define ANJAY_WITHOUT_QUEUE_MODE_AUTOCLOSE +#endif // CONFIG_ANJAY_WITHOUT_QUEUE_MODE_AUTOCLOSE + +/** + * Enable support for CoAP Content-Format numerical values 1541-1544 that have + * been used before final LwM2M TS 1.0. + */ +#ifdef CONFIG_ANJAY_WITH_LEGACY_CONTENT_FORMAT_SUPPORT +# define ANJAY_WITH_LEGACY_CONTENT_FORMAT_SUPPORT +#endif // CONFIG_ANJAY_WITH_LEGACY_CONTENT_FORMAT_SUPPORT + +/** + * Enable support for JSON format as specified in LwM2M TS 1.0. + * + * NOTE: Anjay is only capable of generating this format, there is no parsing + * support regardless of the state of this option. + */ +#ifdef CONFIG_ANJAY_WITH_LWM2M_JSON +# define ANJAY_WITH_LWM2M_JSON +#endif // CONFIG_ANJAY_WITH_LWM2M_JSON + +/** + * Disable support for TLV format as specified in LwM2M TS 1.0. + * + * NOTE: LwM2M Client using LwM2M 1.0 MUST support this format. It may be + * disabled if LwM2M 1.1 is used and SenML JSON or SenML CBOR is enabled. + */ +#ifdef CONFIG_ANJAY_WITHOUT_TLV +# define ANJAY_WITHOUT_TLV +#endif // CONFIG_ANJAY_WITHOUT_TLV + +/** + * Disable support for Plain Text format as specified in LwM2M TS 1.0 and 1.1. + * + * NOTE: LwM2M Client SHOULD support this format. It may be disabled to reduce + * library size if LwM2M Server is configured to not use it in requests. + */ +#ifdef CONFIG_ANJAY_WITHOUT_PLAINTEXT +# define ANJAY_WITHOUT_PLAINTEXT +#endif // CONFIG_ANJAY_WITHOUT_PLAINTEXT + +/** + * Disable use of the Deregister message. + */ +#ifdef CONFIG_ANJAY_WITHOUT_DEREGISTER +# define ANJAY_WITHOUT_DEREGISTER +#endif // CONFIG_ANJAY_WITHOUT_DEREGISTER + +/** + * Disable support for "IP stickiness", i.e. preference of the same IP address + * when reconnecting to a server using a domain name. + */ +#if defined(CONFIG_ANJAY_WITHOUT_IP_STICKINESS) +# define ANJAY_WITHOUT_IP_STICKINESS +#endif // defined(CONFIG_ANJAY_WITHOUT_IP_STICKINESS) + +/** + * Enable support for SenML JSON format, as specified in LwM2M TS 1.1. + * + * NOTE: As opposed to ANJAY_WITH_LWM2M_JSON, both generating and parsing + * is supported. + * + * Requires ANJAY_WITH_LWM2M11 to be enabled. + */ +#ifdef CONFIG_ANJAY_WITH_SENML_JSON +# define ANJAY_WITH_SENML_JSON +#endif // CONFIG_ANJAY_WITH_SENML_JSON + +/** + * Enable support for CBOR and SenML CBOR formats, as specified in LwM2M TS 1.1. + * + * Requires ANJAY_WITH_LWM2M11 to be enabled. + */ +#ifdef CONFIG_ANJAY_WITH_CBOR +# define ANJAY_WITH_CBOR +#endif // CONFIG_ANJAY_WITH_CBOR + +/** + * Enable support for Enrollment over Secure Transport. + * + * Requires ANJAY_WITH_BOOTSTRAP to be enabled. + * + * IMPORTANT: Only available as part of the EST commercial feature. Ignored in + * the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_EST +# define ANJAY_WITH_EST +#endif // CONFIG_ANJAY_WITH_EST + +/** + * Enable support for hardware security engine in the EST subsystem. + * + * Requires ANJAY_WITH_EST to be enabled in Anjay configuration and + * AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE to be enabled in avs_commons + * configuration. + * + * IMPORTANT: Only available in commercial versions that include both the EST + * and HSM features. Ignored in versions distributed without these features. + */ +#ifdef CONFIG_ANJAY_WITH_EST_ENGINE_SUPPORT +# define ANJAY_WITH_EST_ENGINE_SUPPORT +#endif // CONFIG_ANJAY_WITH_EST_ENGINE_SUPPORT + +/** + * Enable support for the Confirmable Notification attribute, as specified in + * LwM2M TS 1.2. + * + * Before TS 1.2, this has been supported in Anjay as a custom extension, and + * thus it is available independently from TS 1.2 support itself, including in + * the open source version. + * + * Requires ANJAY_WITH_OBSERVE to be enabled. + */ +#ifdef CONFIG_ANJAY_WITH_CON_ATTR +# define ANJAY_WITH_CON_ATTR +#endif // CONFIG_ANJAY_WITH_CON_ATTR + +/** + * Enable support for handling security credentials in the data model using + * structured avs_crypto types. + * + * If the security module is also enabled (see @ref + * ANJAY_WITH_MODULE_SECURITY), it also enables support for passing these + * credentials through such structured types when adding Security object + * instances via the @ref anjay_security_instance_t structure. + */ +#ifdef CONFIG_ANJAY_WITH_SECURITY_STRUCTURED +# define ANJAY_WITH_SECURITY_STRUCTURED +#endif // CONFIG_ANJAY_WITH_SECURITY_STRUCTURED + +/** + * Maximum size in bytes supported for the "Public Key or Identity" resource in + * the LwM2M Security object. + * + * If editing this file manually, 256 shall be + * replaced with a positive integer literal. + * + * The default value defined in CMake build scripts is 2048. + * Minimal suggested setting for low-resource builds is 256. + */ +#define ANJAY_MAX_PK_OR_IDENTITY_SIZE (CONFIG_ANJAY_MAX_PK_OR_IDENTITY_SIZE) + +/** + * Maximum size in bytes supported for the "Secret Key" resource in the LwM2M + * Security Object. + * + * If editing this file manually, 128 shall be replaced + * with a positive integer literal. + * + * The default value defined in CMake build scripts is 256. + * Minimal suggested setting for low-resource builds is 128. + */ +#define ANJAY_MAX_SECRET_KEY_SIZE (CONFIG_ANJAY_MAX_SECRET_KEY_SIZE) + +/** + * Maximum length supported for stringified floating-point values. + * + * Used when parsing plaintext and SenML JSON content formats - when parsing a + * floating-point value, any string of length equal or greater than this setting + * will automatically be considered invalid, even if it could in theory be + * parsed as a valid number. + * + * If editing this file manually, 64 shall be + * replaced with a positive integer literal. + * + * The default value defined in CMake build scripts is 512. + * Minimal suggested setting for low-resource builds is 64. + */ +#define ANJAY_MAX_DOUBLE_STRING_SIZE (CONFIG_ANJAY_MAX_DOUBLE_STRING_SIZE) + +/** + * Maximum length supported for a single Uri-Path or Location-Path segment. + * + * When handling incoming CoAP messages, any Uri-Path or Location-Path option of + * length equal or greater than this setting will be considered invalid. + * + * If editing this file manually, 64 shall be + * replaced with a positive integer literal. + * + * The default value defined in CMake build scripts is 256. + * Minimal suggested setting for low-resource builds is 64. + */ +#define ANJAY_MAX_URI_SEGMENT_SIZE (CONFIG_ANJAY_MAX_URI_SEGMENT_SIZE) + +/** + * Maximum length supported for a single Uri-Query segment. + * + * When handling incoming CoAP messages, any Uri-Query option of length equal or + * greater than this setting will be considered invalid. + * + * If editing this file manually, 64 shall be + * replaced with a positive integer literal. + * + * The default value defined in CMake build scripts is 256. + * Minimal suggested setting for low-resource builds is 64. + */ +#define ANJAY_MAX_URI_QUERY_SEGMENT_SIZE \ + (CONFIG_ANJAY_MAX_URI_QUERY_SEGMENT_SIZE) + +/** + * Size of buffer allocated for storing DTLS session state when connection is + * not in use (e.g. during queue mode operation). + * + * If editing this file manually, 1024 shall be + * replaced with a positive integer literal. The default value defined in CMake + * build scripts is 1024. + */ +#define ANJAY_DTLS_SESSION_BUFFER_SIZE (CONFIG_ANJAY_DTLS_SESSION_BUFFER_SIZE) + +/** + * Value of Content-Format used in Send messages. Only a few specific values are + * supported: + * + * - @c AVS_COAP_FORMAT_NONE means no default value is used and Anjay will + * decide the format based on the what is available. + * - @c AVS_COAP_FORMAT_OMA_LWM2M_CBOR Anjay will generate a Send message in + * LwM2M CBOR format. + * - @c AVS_COAP_FORMAT_SENML_CBOR Anjay will generate a Send message in SenML + * CBOR format. + * - @c AVS_COAP_FORMAT_SENML_JSON Anjay will generate a Send message in SenML + * JSON format. + * + * Note that to use a specific format it must be available during compilation. + * + * The default value defined in CMake build scripts is + * AVS_COAP_FORMAT_NONE. + */ +#define ANJAY_DEFAULT_SEND_FORMAT AVS_COAP_FORMAT_NONE + +/** + * Optional Anjay modules. + */ +/**@{*/ +/** + * Enable access_control module (implementation of the Access Control object). + * + * Requires ANJAY_WITH_ACCESS_CONTROL to be enabled. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_ACCESS_CONTROL +# define ANJAY_WITH_MODULE_ACCESS_CONTROL +#endif // CONFIG_ANJAY_WITH_MODULE_ACCESS_CONTROL + +/** + * Enable security module (implementation of the LwM2M Security object). + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_SECURITY +# define ANJAY_WITH_MODULE_SECURITY +#endif // CONFIG_ANJAY_WITH_MODULE_SECURITY + +/** + * Enable support for hardware security engine in the security module. + * + * This feature allows security credentials provisioned into the LwM2M Security + * object to be automatically moved into a hardware security module. + * + * Requires ANJAY_WITH_MODULE_SECURITY to be enabled in Anjay + * configuration, and at least one of + * AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE or + * AVS_COMMONS_WITH_AVS_CRYPTO_PSK_ENGINE to be enabled in avs_commons + * configuration. + * + * IMPORTANT: Only available as part of the HSM support commercial feature. + * Ignored in versions distributed without this feature. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_SECURITY_ENGINE_SUPPORT +# define ANJAY_WITH_MODULE_SECURITY_ENGINE_SUPPORT +#endif // CONFIG_ANJAY_WITH_MODULE_SECURITY_ENGINE_SUPPORT + +/** + * Enable server module (implementation of the LwM2M Server object). + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_SERVER +# define ANJAY_WITH_MODULE_SERVER +#endif // CONFIG_ANJAY_WITH_MODULE_SERVER + +/** + * Enable fw_update module (implementation of the Firmware Update object). + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_FW_UPDATE +# define ANJAY_WITH_MODULE_FW_UPDATE +#endif // CONFIG_ANJAY_WITH_MODULE_FW_UPDATE + +/** + * Enable advanced_fw_update module (implementation of the 33629 custom + * Advanced Firmware Update object). + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE +# define ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE +#endif // CONFIG_ANJAY_WITH_MODULE_ADVANCED_FW_UPDATE + +/** + * Disable support for PUSH mode Firmware Update. + * + * Only meaningful if ANJAY_WITH_MODULE_FW_UPDATE is enabled. Requires + * ANJAY_WITH_DOWNLOADER to be enabled. + */ +#ifdef CONFIG_ANJAY_WITHOUT_MODULE_FW_UPDATE_PUSH_MODE +# define ANJAY_WITHOUT_MODULE_FW_UPDATE_PUSH_MODE +#endif // CONFIG_ANJAY_WITHOUT_MODULE_FW_UPDATE_PUSH_MODE + +/** + * Enables ipso_objects module (generic implementation of the following kinds of + * the basic sensor and three axis sensor IPSO objects). + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_IPSO_OBJECTS +# define ANJAY_WITH_MODULE_IPSO_OBJECTS +#endif // CONFIG_ANJAY_WITH_MODULE_IPSO_OBJECTS + +/** + * Enable at_sms module (implementation of an SMS driver for AT modem devices). + * + * Requires ANJAY_WITH_SMS to be enabled and the operating system to + * support the POSIX poll() function. + * + * IMPORTANT: Only available as part of the SMS commercial feature. Ignored in + * the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_AT_SMS +# define ANJAY_WITH_MODULE_AT_SMS +#endif // CONFIG_ANJAY_WITH_MODULE_AT_SMS + +/** + * Enable bg96_nidd module (implementation of NB-IoT-based NIDD driver for + * Quectel BG96). + * + * Requires ANJAY_WITH_NIDD to be enabled. + * + * IMPORTANT: Only available as part of the NIDD commercial feature. Ignored + * in the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_BG96_NIDD +# define ANJAY_WITH_MODULE_BG96_NIDD +#endif // CONFIG_ANJAY_WITH_MODULE_BG96_NIDD + +/** + * Enable bootstrapper module (loader for bootstrap information formatted as per + * the "Storage of LwM2M Bootstrap Information on the Smartcard" appendix to the + * LwM2M TS). + * + * Requires ANJAY_WITH_BOOTSTRAP to be enabled and + * AVS_COMMONS_WITH_AVS_PERSISTENCE to be enabled in avs_commons + * configuration. + * + * IMPORTANT: Only available with the bootstrapper feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_BOOTSTRAPPER +# define ANJAY_WITH_MODULE_BOOTSTRAPPER +#endif // CONFIG_ANJAY_WITH_MODULE_BOOTSTRAPPER + +/** + * Enable the SIM bootstrap module, which enables reading the SIM bootstrap + * information from a smartcard, which can then be passed through to the + * bootstrapper module. + * + * Requires ANJAY_WITH_MODULE_BOOTSTRAPPER to be enabled. + * + * IMPORTANT: Only available with the bootstrapper feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_SIM_BOOTSTRAP +# define ANJAY_WITH_MODULE_SIM_BOOTSTRAP +#endif // CONFIG_ANJAY_WITH_MODULE_SIM_BOOTSTRAP + +/** + * Forced ID of the file to read the SIM bootstrap information from. + * + * If not defined (default), the bootstrap information file will be discovered + * through the ODF file, as mandated by the specification. + * + * Requires ANJAY_WITH_MODULE_BOOTSTRAPPER to be enabled. At most one of + * ANJAY_MODULE_SIM_BOOTSTRAP_HARDCODED_FILE_ID and + * ANJAY_MODULE_SIM_BOOTSTRAP_DATA_OID_OVERRIDE_HEX may be defined at the + * same time. + * + * IMPORTANT: Only available with the bootstrapper feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_MODULE_SIM_BOOTSTRAP_DISCOVERY_MODE_HARDCODED +# define ANJAY_MODULE_SIM_BOOTSTRAP_HARDCODED_FILE_ID \ + (CONFIG_ANJAY_MODULE_SIM_BOOTSTRAP_FILE_ID) +#endif // CONFIG_ANJAY_MODULE_SIM_BOOTSTRAP_DISCOVERY_MODE_HARDCODED + +/** + * Overridden OID of the SIM bootstrap information to look for in the DODF file, + * expressed as a hexlified DER representation (without the header). + * + * This is the hexlified expected value of the 'id' field within the 'OidDO' + * sequence in the DODF file (please refer to the PKCS #15 document for more + * information). + * + * If not defined, the default value of "672b0901", which corresponds to + * OID 2.23.43.9.1 {joint-iso-itu-t(2) international-organizations(23) wap(43) + * oma-lwm2m(9) lwm2m-bootstrap(1)}, will be used. + * + * No other values than the default are valid according to the specification, + * but some SIM cards are known to use other non-standard values, e.g. + * "0604672b0901" - including a superfluous nested BER-TLV header, as + * erroneously illustrated in the EF(DODF-bootstrap) file coding example in + * LwM2M TS 1.2 and earlier (fixed in LwM2M TS 1.2.1) - which is interpreted as + * OID 0.6.4.103.43.9.1 (note that it is invalid as the 0.6 tree does not exist + * in the repository as of writing this note). + * + * Requires ANJAY_WITH_MODULE_BOOTSTRAPPER to be enabled. At most one of + * ANJAY_MODULE_SIM_BOOTSTRAP_HARDCODED_FILE_ID and + * ANJAY_MODULE_SIM_BOOTSTRAP_DATA_OID_OVERRIDE_HEX may be defined at the + * same time. + * + * IMPORTANT: Only available with the bootstrapper feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_MODULE_SIM_BOOTSTRAP_DISCOVERY_MODE_ODF +# define ANJAY_MODULE_SIM_BOOTSTRAP_DATA_OID_OVERRIDE_HEX \ + CONFIG_ANJAY_MODULE_SIM_BOOTSTRAP_OID +#endif // CONFIG_ANJAY_MODULE_SIM_BOOTSTRAP_DISCOVERY_MODE_ODF + +/** + * Enable factory provisioning module. Data provided during provisioning uses + * SenML CBOR format. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_FACTORY_PROVISIONING +# define ANJAY_WITH_MODULE_FACTORY_PROVISIONING +#endif // CONFIG_ANJAY_WITH_MODULE_FACTORY_PROVISIONING + +/** + * Enable oscore module (implementation of the OSCORE object). + * + * IMPORTANT: Only available as part of the OSCORE commercial feature. Ignored + * in the open source version. + */ +#ifdef CONFIG_ANJAY_WITH_MODULE_OSCORE +# define ANJAY_WITH_MODULE_OSCORE +#endif // CONFIG_ANJAY_WITH_MODULE_OSCORE +/**@}*/ + +#endif // ANJAY_CONFIG_H diff --git a/config/avsystem/coap/avs_coap_config.h b/config/avsystem/coap/avs_coap_config.h new file mode 100644 index 0000000..52a3c5a --- /dev/null +++ b/config/avsystem/coap/avs_coap_config.h @@ -0,0 +1,183 @@ +/* + * Copyright 2023 AVSystem + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Licensed under the AVSystem-5-clause License. + * See the attached LICENSE file for details. + */ + +#ifndef AVS_COAP_CONFIG_H +#define AVS_COAP_CONFIG_H + +#include + +/** + * @file avs_coap_config.h + * + * avs_coap library configuration. + * + * The preferred way to compile avs_coap is to use CMake, in which case this + * file will be generated automatically by CMake. + * + * However, to provide compatibility with various build systems used especially + * by embedded platforms, it is alternatively supported to compile avs_coap by + * other means, in which case this file will need to be provided manually. + * + * NOTE: To compile this library without using CMake, you need to + * configure avs_commons first. Please refer to documentation in the + * avs_commons_config.h file (provided in the repository as + * avs_commons_config.h.in) for details. + * + * avs_coap requires the following avs_commons components to be + * enabled: + * + * - @c avs_buffer + * - @c avs_compat_threading + * - @c avs_list + * - @c avs_net + * - @c avs_sched + * - @c avs_stream + * - @c avs_utils + * - @c avs_log (if @c WITH_AVS_COAP_LOGS is enabled) + * - @c avs_persistence (if @c WITH_AVS_COAP_OBSERVE_PERSISTENCE is enabled) + * - @c avs_crypto (if @c WITH_AVS_COAP_OSCORE is enabled) + * + * In the repository, this file is provided as avs_coap_config.h.in, + * intended to be processed by CMake. If editing this file manually, please copy + * or rename it to avs_coap_config.h and for each of the + * \#cmakedefine directives, please either replace it with regular + * \#define to enable it, or comment it out to disable. You may also need + * to replace variables wrapped in \@ signs with concrete values. Please + * refer to the comments above each of the specific definition for details. + * + * If you are editing a file previously generated by CMake, these + * \#cmakedefines will be already replaced by either \#define or + * commented out \#undef directives. + */ + +/** + * Enable support for block-wise transfers (RFC 7959). + * + * If this flag is disabled, attempting to send a message bigger than the + * internal buffer will fail; incoming messages may still carry BLOCK1 or BLOCK2 + * options, but they will not be interpreted by the library in any way. + */ +#define WITH_AVS_COAP_BLOCK + +/** + * Enable support for observations (RFC 7641). + */ +#ifdef CONFIG_ANJAY_WITH_OBSERVE +# define WITH_AVS_COAP_OBSERVE +#endif // CONFIG_ANJAY_WITH_OBSERVE + +/** + * Enable support for observation persistence (avs_coap_observe_persist() + * and avs_coap_observe_restore() calls). + * + * Only meaningful WITH_AVS_COAP_OBSERVE is enabled. + */ +#ifdef CONFIG_ANJAY_WITH_OBSERVE_PERSISTENCE +# define WITH_AVS_COAP_OBSERVE_PERSISTENCE +#endif // CONFIG_ANJAY_WITH_OBSERVE_PERSISTENCE + +/** + * Enable support for the streaming API + */ +#define WITH_AVS_COAP_STREAMING_API + +/** + * Enable support for UDP transport. + * + * NOTE: Enabling at least one transport is necessary for the library to be + * useful. + */ +#define WITH_AVS_COAP_UDP + +/** + * Enable support for TCP transport (RFC 8323). + * + * NOTE: Enabling at least one transport is necessary for the library to be + * useful. + */ +#define WITH_AVS_COAP_TCP + +/** + * Enable support for OSCORE (RFC 8613). + * + * IMPORTANT: Only available with the OSCORE feature. Ignored in the open + * source version. + */ +#ifdef CONFIG_ANJAY_WITH_COAP_OSCORE +# define WITH_AVS_COAP_OSCORE +#endif // CONFIG_ANJAY_WITH_COAP_OSCORE + +/** + * Use OSCORE version from draft-ietf-core-object-security-08 instead of the + * final version (RFC 8613). + * + * Only meaningful if WITH_AVS_COAP_OSCORE is enabled. + * + * IMPORTANT: Only available with the OSCORE feature. Ignored in the open + * source version. + */ +/* #undef WITH_AVS_COAP_OSCORE_DRAFT_8 */ + +/** + * Maximum number of notification tokens stored to match Reset responses to. + * + * Only meaningful if WITH_AVS_COAP_OBSERVE and WITH_AVS_COAP_UDP + * are enabled. + * + * If editing this file manually, 4 shall be + * replaced with a positive integer literal. The default value defined in CMake + * build scripts is 4. + */ +#define AVS_COAP_UDP_NOTIFY_CACHE_SIZE 4 + +/** + * Enable sending diagnostic payload in error responses. + */ +#define WITH_AVS_COAP_DIAGNOSTIC_MESSAGES + +/** + * Enable logging in avs_coap. + * + * If this flag is disabled, no logging is compiled into the binary at all. + */ +#ifdef CONFIG_WITH_AVS_COAP_LOGS +# define WITH_AVS_COAP_LOGS +#endif // CONFIG_WITH_AVS_COAP_LOGS + +/** + * Enable TRACE-level logs in avs_coap. + * + * Only meaningful if WITH_AVS_COAP_LOGS is enabled. + */ +#ifdef CONFIG_WITH_AVS_COAP_TRACE_LOGS +# define WITH_AVS_COAP_TRACE_LOGS +#endif // CONFIG_WITH_AVS_COAP_TRACE_LOGS + +/** + * Enable poisoning of unwanted symbols when compiling avs_coap. + * + * Requires a compiler that supports \#pragma GCC poison. + * + * This is mostly useful during development, to ensure that avs_commons do not + * attempt to call functions considered harmful in this library, such as printf. + * This is not guaranteed to work as intended on every platform. + */ +/* #undef WITH_AVS_COAP_POISONING */ + +#endif // AVS_COAP_CONFIG_H diff --git a/config/avsystem/commons/avs_commons_config.h b/config/avsystem/commons/avs_commons_config.h new file mode 100644 index 0000000..9633c8a --- /dev/null +++ b/config/avsystem/commons/avs_commons_config.h @@ -0,0 +1,879 @@ +/* + * Copyright 2023 AVSystem + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVS_COMMONS_CONFIG_H +#define AVS_COMMONS_CONFIG_H + +#include + +/** + * @file avs_commons_config.h + * + * avs_commons library configuration. + * + * The preferred way to compile avs_commons is to use CMake, in which case this + * file will be generated automatically by CMake. + * + * However, to provide compatibility with various build systems used especially + * by embedded platforms, it is alternatively supported to compile avs_commons + * by other means, in which case this file will need to be provided manually. + * + * In the repository, this file is provided as avs_commons_config.h.in, + * intended to be processed by CMake. If editing this file manually, please copy + * or rename it to avs_commons_config.h and for each of the + * #cmakedefine directives, please either replace it with regular + * #define to enable it, or comment it out to disable. You may also need + * to replace variables wrapped in @ signs with concrete values. Please + * refer to the comments above each of the specific definition for details. + * + * If you are editing a file previously generated by CMake, these + * #cmakedefines will be already replaced by either #define or + * commented out #undef directives. + */ + +/** + * Options that describe capabilities of the build environment. + * + * NOTE: If you leave some of these macros undefined, even though the given + * feature is actually available in the system, avs_commons will attempt to use + * its own substitutes, which may be incompatible with the definition in the + * system and lead to undefined behaviour. + */ +/**@{*/ +/** + * Is the target platform big-endian? + * + * If undefined, little-endian is assumed. Mixed-endian architectures are not + * supported. + * + * Affects avs_convert_be*() and avs_[hn]to[hn]*() calls in + * avs_utils and, by extension, avs_persistence. + */ +/* #undef AVS_COMMONS_BIG_ENDIAN */ + +/** + * Is GNU __builtin_add_overflow() extension available? + * + * Affects time handling functions in avs_utils. If disabled, software overflow + * checking will be compiled. Note that this software overflow checking code + * relies on U2 representation of signed integers. + */ +#define AVS_COMMONS_HAVE_BUILTIN_ADD_OVERFLOW + +/** + * Is GNU __builtin_mul_overflow() extension available? + * + * Affects time handling functions in avs_utils. If disabled, software overflow + * checking will be compiled. Note that this software overflow checking code + * relies on U2 representation of signed integers. + */ +#define AVS_COMMONS_HAVE_BUILTIN_MUL_OVERFLOW + +/** + * Is net/if.h available in the system? + * + * NOTE: If the header is indeed available, but this option is not defined, the + * IF_NAMESIZE macro will be defined publicly by avs_commons + * headers, which may conflict with system definitions. + */ +/* #undef AVS_COMMONS_HAVE_NET_IF_H */ + +/** + * Are GNU diagnostic pragmas (#pragma GCC diagnostic push/pop/ignored) + * available? + * + * If defined, those pragmas will be used to suppress compiler warnings for some + * code known to generate them and cannot be improved in a more robust way, e.g. + * for code that is known to generate warnings from within system headers. + */ +#define AVS_COMMONS_HAVE_PRAGMA_DIAGNOSTIC + +/** + * Are GNU visibility pragmas (#pragma GCC visibility push/pop) available? + * + * Meaningful mostly if avs_commons will be directly or indirectly linked into + * a shared library. Causes all symbols except those declared in public headers + * to be hidden, i.e. not exported outside the shared library. If not defined, + * default compiler visibility settings will be used, but you still may use + * compiler flags and linker version scripts to replicate this manually if + * needed. + */ +#define AVS_COMMONS_HAVE_VISIBILITY + +/** + * Specify an optional compatibility header that allows use of POSIX-specific + * code that is not compliant with POSIX enough to be compiled directly. + * + * This header, if specified, will be included only by the following components, + * which may be enabled or disabled depending on state of the referenced flags: + * - avs_compat_threading implementation based on POSIX Threads + * (@ref AVS_COMMONS_COMPAT_THREADING_WITH_PTHREAD) + * - default avs_net socket implementation + * (@ref AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET) + * - avs_unit (@ref AVS_COMMONS_WITH_AVS_UNIT) + * - default implementation of avs_time routines + * (@ref AVS_COMMONS_UTILS_WITH_POSIX_AVS_TIME) + * + * Compatibility headers for lwIP and Microsoft Windows are provided with the + * library (see the compat directory). + * + * If this macro is not defined, the afore-mentioned components, if enabled, + * will use system headers directly, assuming they are POSIX-compliant. + * + * If this macro is enabled, the specified file will be included through an + * #include AVS_COMMONS_POSIX_COMPAT_HEADER statement. Thus, if editing + * this file manually, avsystem/commons/lwip-posix-compat.h shall be + * replaced with a path to such file. + */ +#define AVS_COMMONS_POSIX_COMPAT_HEADER "avsystem/commons/lwip-posix-compat.h" + +/** + * Set if printf implementation doesn't support 64-bit format specifiers. + * If defined, custom implementation of conversion is used in + * @c AVS_UINT64_AS_STRING instead of using @c snprintf . + */ +/* #undef AVS_COMMONS_WITHOUT_64BIT_FORMAT_SPECIFIERS */ + +/** + * Set if printf implementation doesn't support floating-point numbers. + * If defined, custom implementation of conversion is used in + * @c AVS_DOUBLE_AS_STRING instead of using @c snprintf . This might increase + * compatibility with some embedded libc implementations that do not provide + * this functionality. + * + * NOTE: In order to keep the custom implementation small in code size, it is + * not intended to be 100% accurate. Rounding errors may occur - according to + * empirical checks, they show up around the 16th significant decimal digit. + */ +/* #undef AVS_COMMONS_WITHOUT_FLOAT_FORMAT_SPECIFIERS */ +/**@}*/ + +/** + * Enable poisoning of unwanted symbols when compiling avs_commons. + * + * Requires a compiler that supports #pragma GCC poison. + * + * This is mostly useful during development, to ensure that avs_commons do not + * attempt to call functions considered harmful in this library, such as printf. + * This is not guaranteed to work as intended on every platform, e.g. on macOS + * it is known to generate false positives due to different dependencies between + * system headers. + */ +/* #undef AVS_COMMONS_WITH_POISONING */ + +/** + * Options that control compilation of avs_commons components. + * + * Each of the configuration options below enables, if defined, one of the core + * components of the avs_commons library. + * + * NOTE: Enabling avs_unit will cause an object file with an implementation of + * main() to be generated. + */ +/**@{*/ +#define AVS_COMMONS_WITH_AVS_ALGORITHM +#define AVS_COMMONS_WITH_AVS_BUFFER +#define AVS_COMMONS_WITH_AVS_COMPAT_THREADING +#define AVS_COMMONS_WITH_AVS_CRYPTO +#ifdef CONFIG_ANJAY_WITH_HTTP_DOWNLOAD +# define AVS_COMMONS_WITH_AVS_HTTP +#endif // CONFIG_ANJAY_WITH_HTTP_DOWNLOAD +#define AVS_COMMONS_WITH_AVS_LIST +#define AVS_COMMONS_WITH_AVS_LOG +#define AVS_COMMONS_WITH_AVS_NET +#if defined(CONFIG_ANJAY_WITH_CORE_PERSISTENCE) \ + || defined(CONFIG_ANJAY_WITH_ATTR_STORAGE) \ + || defined(CONFIG_ANJAY_WITH_MODULE_BOOTSTRAPPER) \ + || defined(AVS_COMMONS_NET_WITH_TLS_SESSION_PERSISTENCE) +# define AVS_COMMONS_WITH_AVS_PERSISTENCE +#endif // defined(CONFIG_ANJAY_WITH_CORE_PERSISTENCE) || + // defined(CONFIG_ANJAY_WITH_ATTR_STORAGE) || + // defined(CONFIG_ANJAY_WITH_MODULE_BOOTSTRAPPER) || + // defined(AVS_COMMONS_NET_WITH_TLS_SESSION_PERSISTENCE) +/* #undef AVS_COMMONS_WITH_AVS_RBTREE */ +#if defined(CONFIG_ANJAY_WITH_OBSERVE) \ + || defined(CONFIG_ANJAY_WITH_MODULE_ACCESS_CONTROL) +# define AVS_COMMONS_WITH_AVS_SORTED_SET +#endif // defined(CONFIG_ANJAY_WITH_OBSERVE) + // || defined(CONFIG_ANJAY_WITH_MODULE_ACCESS_CONTROL) +#define AVS_COMMONS_WITH_AVS_SCHED +#define AVS_COMMONS_WITH_AVS_STREAM +/* #undef AVS_COMMONS_WITH_AVS_UNIT */ +#define AVS_COMMONS_WITH_AVS_URL +#define AVS_COMMONS_WITH_AVS_UTILS +/* #undef AVS_COMMONS_WITH_AVS_VECTOR */ +/**@}*/ + +/** + * Options that control compilation of avs_compat_threading implementations. + * + * If CMake is not used, in the typical scenario at most one of the following + * implementations may be enabled at the same time. If none is enabled, the + * relevant symbols will need to be provided by the user, if used. + * + * These are meaningful only if AVS_COMMONS_WITH_AVS_COMPAT_THREADING is + * defined. + */ +/**@{*/ +/** + * Enable implementation based on spinlocks. + * + * This implementation is usually very inefficient, and requires C11 stdatomic.h + * header to be available. + */ +/* #undef AVS_COMMONS_COMPAT_THREADING_WITH_ATOMIC_SPINLOCK */ + +/** + * Enable implementation based on the POSIX Threads library. + * + * This implementation is preferred over the spinlock-based one, but the POSIX + * Threads library is normally available only in UNIX-like environments. + */ +#define AVS_COMMONS_COMPAT_THREADING_WITH_PTHREAD + +/** + * Is the pthread_condattr_setclock() function available? + * + * This flag only makes sense when + * AVS_COMMONS_COMPAT_THREADING_WITH_PTHREAD is enabled. + * + * If this flag is disabled, or if CLOCK_MONOTONIC macro is not + * available, the avs_condvar_wait() will internally use the real-time + * clock instead of the monotonic clock. Time values will be converted so that + * this change does not affect API usage. + */ +/* #undef AVS_COMMONS_COMPAT_THREADING_PTHREAD_HAVE_PTHREAD_CONDATTR_SETCLOCK */ +/**@}*/ + +/** + * Options that control compilation of code depending on TLS backend library. + * + * If CMake is not used, in the typical scenario at most one of the following + * DTLS backends may be enabled at the same time. If none is enabled, + * functionalities that depends on cryptography will be disabled. + * + * Affects avs_crypto, avs_net, and avs_stream (for the MD5 implementation). + * + * mbed TLS is the main development backend, and is preferred as such. OpenSSL + * backend supports most functionality as well, but is not as thoroughly tested. + * TinyDTLS support is only rudimentary. + */ +/**@{*/ +#ifdef CONFIG_MBEDTLS_TLS_ENABLED +# define AVS_COMMONS_WITH_MBEDTLS +#endif // CONFIG_MBEDTLS_TLS_ENABLED +/* #undef AVS_COMMONS_WITH_OPENSSL */ +/* #undef AVS_COMMONS_WITH_TINYDTLS */ + +/** + * Enable support for custom TLS socket implementation. + * + * If enabled, the user needs to provide their own implementations of + * _avs_net_create_ssl_socket(), _avs_net_create_dtls_socket(), + * _avs_net_initialize_global_ssl_state() and + * _avs_net_cleanup_global_ssl_state(). + */ +/* #undef AVS_COMMONS_WITH_CUSTOM_TLS */ +/**@}*/ + +/** + * Options related to avs_crypto. + */ +/**@{*/ +/** + * Enable AEAD and HKDF support in avs_crypto. Requires MbedTLS in version at + * least 2.14.0, OpenSSL in version at least 1.1.0, or custom implementation in + * case of AVS_COMMONS_WITH_CUSTOM_TLS. + */ +#if defined(CONFIG_ANJAY_WITH_COAP_OSCORE) || defined(CONFIG_ANJAY_WITH_EST) +# define AVS_COMMONS_WITH_AVS_CRYPTO_ADVANCED_FEATURES +#endif // defined(CONFIG_ANJAY_WITH_COAP_OSCORE) || + // defined(CONFIG_ANJAY_WITH_EST) + +/** + * If the TLS backend is either mbed TLS or OpenSSL, enables APIs related to + * public-key cryptography. + * + * Public-key cryptography is not currently supported with TinyDTLS. + * + * It also enables support for X.509 certificates in avs_net, if that module is + * also enabled. + */ +#define AVS_COMMONS_WITH_AVS_CRYPTO_PKI + +/** + * If the TLS backend is either mbed TLS, OpenSSL or TinyDTLS, enables support + * of pre-shared key security. + * + * PSK is the only supported security mode for the TinyDTLS backend, so this + * option MUST be enabled to utilize it. + * + * It also enables support for pre-shared key security in avs_net, if that + * module is also enabled. + */ +#define AVS_COMMONS_WITH_AVS_CRYPTO_PSK + +/** + * Enables usage of Valgrind API to suppress some of the false positives + * generated by the OpenSSL backend. + */ +/* #undef AVS_COMMONS_WITH_AVS_CRYPTO_VALGRIND */ + +/** + * Enables high-level support for hardware-based PKI security, i.e. loading, + * generating and managing key pairs and certificates via external engines. + * + * Requires @ref AVS_COMMONS_WITH_AVS_CRYPTO_PKI to be enabled. + * + * An actual implementation is required to use this feature. You may provide + * your own, or use one of the default ones that come with the HSM engine + * commercial feature (see @ref AVS_COMMONS_WITH_MBEDTLS_PKCS11_ENGINE, + * @ref AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE and + * @ref AVS_COMMONS_WITH_OPENSSL_PKCS11_ENGINE). + * + * The functions that need to be provided in case of a custom implementation: + * - avs_crypto_pki_engine_certificate_rm() + * - avs_crypto_pki_engine_certificate_store() + * - avs_crypto_pki_engine_key_gen() + * - avs_crypto_pki_engine_key_rm() + * - avs_crypto_pki_engine_key_store() + * - When targeting the Mbed TLS backend: + * - _avs_crypto_mbedtls_engine_initialize_global_state() + * - _avs_crypto_mbedtls_engine_cleanup_global_state() + * - _avs_crypto_mbedtls_engine_append_cert() + * - _avs_crypto_mbedtls_engine_append_crl() + * - _avs_crypto_mbedtls_engine_load_private_key() + * - When targeting the OpenSSL backend: + * - _avs_crypto_openssl_engine_initialize_global_state() + * - _avs_crypto_openssl_engine_cleanup_global_state() + * - _avs_crypto_openssl_engine_load_certs() + * - _avs_crypto_openssl_engine_load_crls() + * - _avs_crypto_openssl_engine_load_private_key() + * + * External PKI engines are NOT supported in the TinyDTLS backend. + */ +/* #undef AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE */ + +/** + * Enables high-level support for hardware-based PSK security, i.e. loading + * and managing PSK keys and identities via external engine. + * + * Requires @ref AVS_COMMONS_WITH_AVS_CRYPTO_PKI to be enabled. + * + * An actual implementation is required to use this feature. You may provide + * your own, or use the default PSA-based one that comes with the HSM engine + * commercial feature (see @ref AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE). + * + * The functions that need to be provided in case of a custom implementation: + * - avs_crypto_psk_engine_identity_store() + * - avs_crypto_psk_engine_identity_rm() + * - avs_crypto_psk_engine_key_store() + * - avs_crypto_psk_engine_key_rm() + * - When targeting the Mbed TLS backend: + * - _avs_crypto_mbedtls_engine_initialize_global_state() + * - _avs_crypto_mbedtls_engine_cleanup_global_state() + * - _avs_crypto_mbedtls_engine_load_psk_key() + * + * External PSK engines are NOT supported in the OpenSSL and TinyDTLS backend. + */ +/* #undef AVS_COMMONS_WITH_AVS_CRYPTO_PSK_ENGINE */ + +/** + * Enables the default implementation of avs_crypto engine, based on Mbed TLS + * and PKCS#11. + * + * Requires @ref AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE to be enabled. + * + * NOTE: Query string format for this engine is a subset of the PKCS#11 URI + * scheme (see RFC 7512), modelled after the format accepted by libp11 OpenSSL + * engine. + * + * NOTE: The unit tests for this feature depend on SoftHSM and pkcs11-tool. + * These must be installed for the tests to pass. + * + * IMPORTANT: Only available as part of the HSM support commercial feature. + * Ignored in the open source version. + */ +/* #undef AVS_COMMONS_WITH_MBEDTLS_PKCS11_ENGINE */ + +/** + * Enables the default implementation of avs_crypto engine, based on Mbed TLS + * and Platform Security Architecture (PSA). + * + * Requires @ref AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE or + * @ref AVS_COMMONS_WITH_AVS_CRYPTO_PSK_ENGINE to be enabled. + * + * NOTE: Query string format for this engine is: + * + *
+ * kid=[,lifetime=]|uid=
+ * 
+ * + * The values are parsed using strtoull() with base=0, so may be in decimal, + * 0-prefixed octal or 0x-prefixed hexadecimal. On key generation and + * certificate storage, the specified lifetime will be used, or lifetime 1 + * (default persistent storage) will be used if not. On key or certificate use, + * the lifetime of the actual key will be verified if present on the query + * string and the key will be rejected if different. + * + * Certificates are stored as PSA_KEY_TYPE_RAW_DATA key entries containing + * X.509 DER data. Alternatively, the PSA Protected Storage API can be used if + * @ref AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE is enabled, by + * using the uid=... syntax. + * + * IMPORTANT: Only available as part of the HSM support commercial feature. + * Ignored in the open source version. + */ +/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE */ + +/** + * Enables support for the PSA Protected Storage API in the PSA-based avs_crypto + * engine. + * + * Requires @ref AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE to be enabled. + * + * IMPORTANT: Only available as part of the HSM support commercial feature. + * Ignored in the open source version. + */ +/* #undef AVS_COMMONS_WITH_MBEDTLS_PSA_ENGINE_PROTECTED_STORAGE */ + +/** + * Is the dlsym() function available? + * + * This is currently only used if @ref AVS_COMMONS_WITH_MBEDTLS_PKCS11_ENGINE is + * enabled. If enabled, the PKCS#11 module is loaded dynamically from a library + * specified by the PKCS11_MODULE_PATH environment variable. If disabled, + * a function with the following signature, realizing the PKCS#11 + * C_GetFunctionList method, must be provided manually: + * + *
+ * CK_RV _avs_crypto_mbedtls_pkcs11_get_function_list(CK_FUNCTION_LIST_PTR_PTR);
+ * 
+ */ +/* #undef AVS_COMMONS_HAVE_DLSYM */ + +/** + * Enables the default implementation of avs_crypto engine, based on OpenSSL and + * PKCS#11. + * + * Requires @ref AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE to be enabled. + * + * NOTE: Query string format for this engine is a subset of the PKCS#11 URI + * scheme (see RFC 7512), modelled after the format accepted by libp11 OpenSSL + * engine. + * + * NOTE: The unit tests for this feature depend on SoftHSM and pkcs11-tool. + * These must be installed for the tests to pass. + * + * IMPORTANT: Only available as part of the HSM support commercial feature. + * Ignored in the open source version. + */ +/* #undef AVS_COMMONS_WITH_OPENSSL_PKCS11_ENGINE */ +/**@}*/ + +/** + * Enable support for HTTP content compression in avs_http. + * + * Requires linking with zlib. + */ +/* #undef AVS_COMMONS_HTTP_WITH_ZLIB */ + +/** + * Options related to avs_log and logging support within avs_commons. + */ +/**@{*/ +/* clang-format off */ +/** + * Size, in bytes, of the avs_log buffer. + * + * Log messages that would (including the level, module name and code location) + * otherwise be longer than this value minus one (for the terminating null + * character) will be truncated. + * + * NOTE: This macro MUST be defined if avs_log is enabled. + * + * If editing this file manually, 512 shall + * be replaced with a positive integer literal. The default value defined in + * CMake build scripts is 512. + */ +#define AVS_COMMONS_LOG_MAX_LINE_LENGTH 512 +/* clang-format on */ + +/** + * Configures avs_log to use a synchronized global buffer instead of allocating + * a buffer on the stack when constructing log messages. + * + * Requires avs_compat_threading to be enabled. + * + * Enabling this option would reduce the stack space required to use avs_log, at + * the expense of global storage and the complexity of using a mutex. + */ +#define AVS_COMMONS_LOG_USE_GLOBAL_BUFFER + +/** + * Provides a default avs_log handler that prints log messages on stderr. + * + * Disabling this option will cause logs to be discarded by default, until a + * custom log handler is set using avs_log_set_handler(). + */ +#define AVS_COMMONS_LOG_WITH_DEFAULT_HANDLER + +/** + * Enables the "micro logs" feature. + * + * Replaces all occurrences of the AVS_DISPOSABLE_LOG() macro with single + * space strings. This is intended to reduce the size of the compiled code, by + * stripping it of almost all log string data. + * + * Note that this setting will propagate both to avs_commons components + * themselves (as all its internal logs make use of AVS_DISPOSABLE_LOG()) + * and the user code that uses it. + */ +#ifdef CONFIG_ANJAY_WITH_MICRO_LOGS +# define AVS_COMMONS_WITH_MICRO_LOGS +#endif // CONFIG_ANJAY_WITH_MICRO_LOGS + +/** + * Enables logging inside avs_commons. + * + * Requires @ref AVS_COMMONS_WITH_AVS_LOG to be enabled. + * + * If this macro is not defined at avs_commons compile time, calls to avs_log + * will not be generated inside avs_commons components. + */ +#ifdef CONFIG_AVS_COMMONS_WITH_INTERNAL_LOGS +# define AVS_COMMONS_WITH_INTERNAL_LOGS +#endif // CONFIG_AVS_COMMONS_WITH_INTERNAL_LOGS + +/** + * Enables TRACE-level logs inside avs_commons. + * + * Only meaningful if AVS_COMMONS_WITH_INTERNAL_LOGS is enabled. + * + * If this macro is not defined at avs_commons compile time, calls to avs_log + * with the level set to TRACE will not be generated inside avs_commons + * components. + */ +#ifdef CONFIG_AVS_COMMONS_WITH_INTERNAL_TRACE +# define AVS_COMMONS_WITH_INTERNAL_TRACE +#endif // CONFIG_AVS_COMMONS_WITH_INTERNAL_TRACE + +/** + * Enables external implementation of logger subsystem with provided header. + * + * Default logger implementation can be found in avs_log_impl.h + */ +/* #undef AVS_COMMONS_WITH_EXTERNAL_LOGGER_HEADER */ + +/** + * If specified, the process of checking if avs_log should be written out + * takes place in compile time. + * + * Specify an optional header with a list of modules for which log level + * is set. If a log level for specific module is not set, the DEFAULT level + * will be taken into account. Value of the default logging level is set to + * DEBUG, but can be overwritten in this header file with AVS_LOG_LEVEL_DEFAULT + * define. Messages with lower level than the one set will be removed during + * compile time. Possible values match @ref avs_log_level_t. + * + * That file should contain C preprocesor defines in the: + * - "#define AVS_LOG_LEVEL_FOR_MODULE_ " format, + * where is the module name and is allowed logging level + * - "#define AVS_LOG_LEVEL_DEFAULT " format, where is the + * allowed logging level + * + * Example file content: + * + * + * #ifndef AVS_COMMONS_EXTERNAL_LOG_LEVELS_H + * #define AVS_COMMONS_EXTERNAL_LOG_LEVELS_H + * + * // global log level value + * #define AVS_LOG_LEVEL_DEFAULT INFO + * + * //for "coap" messages only WARNING and ERROR messages will be present + * #define AVS_LOG_LEVEL_FOR_MODULE_coap WARNING + * + * //logs are disable for "net" module + * #define AVS_LOG_LEVEL_FOR_MODULE_net QUIET + * + * #endif + * + */ +/* #undef AVS_COMMONS_WITH_EXTERNAL_LOG_LEVELS_HEADER */ + +/** + * Disable log level check in runtime. Allows to save at least 1.3kB of memory. + * + * The macros avs_log_set_level and avs_log_set_default_level + * will not be available. + * + */ +/* #undef AVS_COMMONS_WITHOUT_LOG_CHECK_IN_RUNTIME */ +/**@}*/ + +/** + * Options related to avs_net. + */ +/**@{*/ +/** + * Enables support for IPv4 connectivity. + * + * At least one of AVS_COMMONS_NET_WITH_IPV4 and AVS_COMMONS_NET_WITH_IPV6 + * MUST be defined if avs_net is enabled. + */ +#define AVS_COMMONS_NET_WITH_IPV4 + +/** + * Enables support for IPv6 connectivity. + * + * At least one of AVS_COMMONS_NET_WITH_IPV4 and AVS_COMMONS_NET_WITH_IPV6 + * MUST be defined if avs_net is enabled. + */ +#ifdef CONFIG_LWIP_IPV6 +# define AVS_COMMONS_NET_WITH_IPV6 +#endif // CONFIG_LWIP_IPV6 + +/** + * If the TLS backend is set to OpenSSL, enables support for DTLS. + * + * DTLS is always enabled for the mbed TLS and TinyDTLS backends. + */ +/* #undef AVS_COMMONS_NET_WITH_DTLS */ + +/** + * Enables debug logs generated by mbed TLS. + * + * An avs_log-backed handler, logging for the "mbedtls" module on the TRACE + * level, is installed using mbedtls_ssl_conf_dbg() for each (D)TLS + * socket created if this option is enabled. + */ +/* #undef AVS_COMMONS_NET_WITH_MBEDTLS_LOGS */ + +/** + * Enables the default implementation of avs_net TCP and UDP sockets. + * + * Requires either a UNIX-like operating environment, or a compatibility layer + * with a high degree of compatibility with standard BSD sockets with an + * appropriate compatibility header (see @ref AVS_COMMONS_POSIX_COMPAT_HEADER) - + * lwIP and Winsock are currently supported for this scenario. + */ +#if defined(CONFIG_AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET) +# define AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET +#endif // defined(CONFIG_AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET) + +/** + * Enables support for logging socket communication to file. + * + * If this option is enabled, avs_net_socket_debug() can be used to enable + * logging all communication to a file called DEBUG.log. If disabled, + * avs_net_socket_debug() will always return an error. + */ +/* #undef AVS_COMMONS_NET_WITH_SOCKET_LOG */ + +/** + * If the TLS backend is either mbed TLS or OpenSSL, enables support for (D)TLS + * session persistence. + * + * Session persistence is not currently supported for the TinyDTLS backend. + */ +#define AVS_COMMONS_NET_WITH_TLS_SESSION_PERSISTENCE +/**@}*/ + +/** + * Options related to avs_net's default implementation of TCP and UDP sockets. + * + * These options make sense only when @ref AVS_COMMONS_NET_WITH_POSIX_AVS_SOCKET + * is enabled. They describe capabilities of the Unix-like environment in which + * the library is built. + * + * Note that if @ref AVS_COMMONS_POSIX_COMPAT_HEADER is defined, it might + * redefine these flags independently of the settings in this file. + */ +/**@{*/ +/** + * Is the gai_strerror() function available? + * + * Enabling this flag will provide more detailed log messages in case that + * getaddrinfo() fails. If this flag is disabled, numeric error codes + * values will be logged. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_GAI_STRERROR */ + +/** + * Is the getifaddrs() function available? + * + * Disabling this flag will cause avs_net_socket_interface_name() to use + * a less optimal implementation based on the SIOCGIFCONF ioctl. + * + * If SIOCGIFCONF is not defined, either, then + * avs_net_socket_interface_name() will always return an error. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_GETIFADDRS */ + +/** + * Is the getnameinfo() function available? + * + * Disabling this flag will cause avs_net_socket_receive_from(), + * avs_net_socket_accept(), + * avs_net_resolved_endpoint_get_host_port(), + * avs_net_resolved_endpoint_get_host() and + * avs_net_resolve_host_simple() to use a custom reimplementation of + * getnameinfo() based on inet_ntop(). + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_GETNAMEINFO */ + +/** + * Is the IN6_IS_ADDR_V4MAPPED macro available and usable? + * + * Disabling this flag will cause a custom code that compares IPv6 addresses + * with the ::ffff:0.0.0.0/32 mask to be used instead. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_IN6_IS_ADDR_V4MAPPED */ + +/** + * Should be defined if IPv4-mapped IPv6 addresses (::ffff:0.0.0.0/32) + * are NOT supported by the underlying platform. + * + * Enabling this flag will prevent avs_net from using IPv4-mapped IPv6 addresses + * and instead re-open and re-bind the socket if a connection to an IPv4 address + * is requested on a previously created IPv6 socket. + * + * This may result in otherwise redundant socket(), bind() and + * close() system calls to be performed, but may be necessary for + * interoperability with some platforms. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_WITHOUT_IN6_V4MAPPED_SUPPORT */ + +/** + * Is the inet_ntop() function available? + * + * Disabling this flag will cause an internal implementation of this function + * adapted from BIND 4.9.4 to be used instead. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_INET_NTOP */ + +/** + * Is the poll() function available? + * + * Disabling this flag will cause a less robust code based on select() to + * be used instead. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_POLL */ + +/** + * Is the recvmsg() function available? + * + * Disabling this flag will cause recvfrom() to be used instead. Note + * that for UDP sockets, this will cause false positives for datagram truncation + * detection (AVS_EMSGSIZE) to be reported when the received message is + * exactly the size of the buffer. + */ +/* #undef AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_RECVMSG */ +/**@}*/ + +/** + * Enable thread safety in avs_sched. + * + * Makes all scheduler accesses synchronized and thread-safe, at the cost of + * requiring avs_compat_threading to be enabled, and higher resource usage. + */ +#ifdef CONFIG_ANJAY_WITH_THREAD_SAFETY +# define AVS_COMMONS_SCHED_THREAD_SAFE +#endif // CONFIG_ANJAY_WITH_THREAD_SAFETY + +/** + * Enable support for file I/O in avs_stream. + * + * Disabling this flag will cause the functions declared in + * avs_stream_file.h to not be defined. + */ +#define AVS_COMMONS_STREAM_WITH_FILE + +/** + * Enable usage of backtrace() and backtrace_symbols() when + * reporting assertion failures from avs_unit. + * + * Requires the afore-mentioned GNU-specific functions to be available. + * + * If this flag is disabled, stack traces will not be displayed with assertion + * failures. + */ +/* #undef AVS_COMMONS_UNIT_POSIX_HAVE_BACKTRACE */ + +/** + * Options related to avs_utils. + */ +/**@{*/ +/** + * Enable the default implementation of avs_time_real_now() and + * avs_time_monotonic_now(). + * + * Requires an operating environment that supports a clock_gettime() call + * compatible with POSIX. + */ +#define AVS_COMMONS_UTILS_WITH_POSIX_AVS_TIME + +/** + * Enable the default implementation of avs_malloc(), avs_free(), avs_calloc() + * and avs_realloc() that forwards to system malloc(), free(), calloc() and + * realloc() calls. + * + * You might disable this option if for any reason you need to use a custom + * allocator. + */ +#define AVS_COMMONS_UTILS_WITH_STANDARD_ALLOCATOR + +/** + * Enable the alternate implementation of avs_malloc(), avs_free(), avs_calloc() + * and avs_realloc() that uses system malloc(), free() and realloc() calls, but + * includes additional fixup code that ensures proper alignment to + * AVS_ALIGNOF(avs_max_align_t) (usually 8 bytes on common platforms). + * + * AVS_COMMONS_UTILS_WITH_STANDARD_ALLOCATOR and + * AVS_COMMONS_UTILS_WITH_ALIGNFIX_ALLOCATOR cannot be enabled at the + * same time. + * + * NOTE: This implementation is only intended for platforms where the system + * allocator does not properly conform to the alignment requirements. + * + * It comes with an additional runtime costs: + * + * - AVS_ALIGNOF(avs_max_align_t) bytes (usually 8) of additional + * overhead for each allocated memory block + * - Additional memmove() for every realloc() that returned a block that is not + * properly aligned + * - avs_calloc() is implemented as avs_malloc() followed by an explicit + * memset(); this may be suboptimal on some platforms + * + * If these costs are unacceptable for you, you may want to consider fixing, + * replacing or reconfiguring your system allocator for conformance, or + * implementing a custom one instead. + * + * Please note that some code in avs_commons and dependent projects (e.g. Anjay) + * may include runtime assertions for proper memory alignment that will be + * triggered when using a non-conformant standard allocator. Such allocators are + * relatively common in embedded SDKs. This "alignfix" allocator is intended to + * work around these issues. On some platforms (e.g. x86) those alignment issues + * may not actually cause any problems - so you may want to consider disabling + * runtime assertions instead. Please carefully examine your target platform's + * alignment requirements and behavior of misaligned memory accesses (including + * 64-bit data types such as int64_t and double) before doing so. + */ +/* #undef AVS_COMMONS_UTILS_WITH_ALIGNFIX_ALLOCATOR */ +/**@}*/ + +#endif /* AVS_COMMONS_CONFIG_H */ diff --git a/config/avsystem/commons/lwip-posix-compat.h b/config/avsystem/commons/lwip-posix-compat.h new file mode 100644 index 0000000..d839267 --- /dev/null +++ b/config/avsystem/commons/lwip-posix-compat.h @@ -0,0 +1,53 @@ +/* + * Copyright 2023 AVSystem + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef COMPAT_H +#define COMPAT_H + +/* + * Example implementation of a AVS_COMMONS_POSIX_COMPAT_HEADER file required for + * non-POSIX platforms that use LwIP 1.4.1. + * + * Contains all types/macros/symbols not defined in core C that are required + * to compile avs_commons library. + */ + +#include "lwipopts.h" + +/* Provides htons/ntohs/htonl/ntohl */ +#include "lwip/inet.h" + +/* Provides e.g. LWIP_VERSION_* macros used in net_impl.c */ +#include "lwip/init.h" + +/* + * Provides: + * - POSIX-compatible socket API, socklen_t, + * - fcntl, F_GETFL, F_SETFL, O_NONBLOCK, + * - select, struct fd_set, FD_SET, FD_CLEAR, FD_ISSET + */ +#include "lwip/sockets.h" + +/* Provides getaddrinfo/freeaddrinfo/struct addrinfo */ +#include "lwip/netdb.h" + +#if LWIP_VERSION_MAJOR >= 2 +# define AVS_COMMONS_NET_POSIX_AVS_SOCKET_HAVE_INET_NTOP +#endif // LWIP_VERSION_MAJOR >= 2 + +typedef int sockfd_t; + +#endif /* COMPAT_H */ diff --git a/deps/FreeRTOS-Cellular-Interface b/deps/FreeRTOS-Cellular-Interface new file mode 160000 index 0000000..dc12cba --- /dev/null +++ b/deps/FreeRTOS-Cellular-Interface @@ -0,0 +1 @@ +Subproject commit dc12cbaac53e78c88bf7690524ec21a850c49d1b diff --git a/deps/anjay b/deps/anjay new file mode 160000 index 0000000..0acafc4 --- /dev/null +++ b/deps/anjay @@ -0,0 +1 @@ +Subproject commit 0acafc41f108527853416f541ea7a1363127d15c