Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for tinydtls and wakaama #1855

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -1807,3 +1807,50 @@ apps/testing/crypto/hmac.c
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

apps/crypto/tinydtls
======================
/*******************************************************************************
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Olaf Bergmann (TZI) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
* Contributors:
* Olaf Bergmann - initial API and implementation
* Hauke Mehrtens - memory optimization, ECC integration
*******************************************************************************/

apps/netutils/wakaama
=====================
*Eclipse Distribution License - v 1.0*

Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Eclipse Foundation, Inc. nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions crypto/tinydtls/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/tinydtls
/*.tar.gz
92 changes: 92 additions & 0 deletions crypto/tinydtls/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# ##############################################################################
# apps/crypto/tinydtls/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################

if(CONFIG_CRYPTO_TINYDTLS)

if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/tinydtls)
FetchContent_Declare(
tinydtls
DOWNLOAD_NAME "${CONFIG_TINYDTLS_VERSION}.tar.gz"
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
URL "https://github.com/eclipse/tinydtls/archive/${CONFIG_TINYDTLS_VERSION}.tar.gz"
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/tinydtls
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/crypto/tinydtls/tinydtls
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

FetchContent_GetProperties(tinydtls)

if(NOT tinydtls_POPULATED)
FetchContent_Populate(tinydtls)
endif()
endif()

add_subdirectory(tinydtls)

target_compile_definitions(
tinydtls
PRIVATE HAVE_ARPA_INET_H
HAVE_ASSERT_H
HAVE_FCNTL_H
HAVE_GETRANDOM
HAVE_INTTYPES_H
HAVE_MEMSET
HAVE_NETDB_H
HAVE_NETINET_IN_H
HAVE_RANDOM
HAVE_SELECT
HAVE_SOCKET
HAVE_STDDEF_H
HAVE_STDINT_H
HAVE_STDLIB_H
HAVE_STRDUP
HAVE_STRERROR
HAVE_STRINGS_H
HAVE_STRING_H
HAVE_STRNLEN
HAVE_SYS_SOCKET_H
HAVE_SYS_STAT_H
HAVE_SYS_TIME_H
HAVE_SYS_TYPES_H
HAVE_TIME_H
HAVE_UNISTD_H
HAVE_VPRINTF
HAVE_SNPRINTF)

target_compile_options(tinydtls PRIVATE -Wno-unused -Wno-inline)

# TODO: this should be function in nuttx/cmake/nuttx_add_library.cmake
set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES tinydtls)
nuttx_add_library_internal(tinydtls)

# allow #include "tinydtls/xxx.h"
target_include_directories(tinydtls PUBLIC .)

endif()
19 changes: 19 additions & 0 deletions crypto/tinydtls/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config CRYPTO_TINYDTLS
bool "Eclipse Tinydtls"
default n
depends on ALLOW_ECLIPSE_COMPONENTS
---help---
Enable Eclipse tinydtls - a minimal library for DTLS.

if CRYPTO_TINYDTLS

config TINYDTLS_VERSION
string "Tinydtls version"
default "ba830a390642d057fcf21bbb6bd57546d12e584c"

endif # CRYPTO_TINYDTLS
2 changes: 2 additions & 0 deletions netutils/wakaama/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/wakaama
/*.tar.gz
98 changes: 98 additions & 0 deletions netutils/wakaama/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# ##############################################################################
# apps/netutils/wakaama/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you 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.
#
# ##############################################################################

if(CONFIG_NETUTILS_WAKAAMA)

if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/wakaama)
FetchContent_Declare(
wakaama
DOWNLOAD_NAME "${CONFIG_WAKAAMA_VERSION}.tar.gz"
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
URL "https://github.com/eclipse/wakaama/archive/${CONFIG_WAKAAMA_VERSION}.tar.gz"
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/wakaama
BINARY_DIR
${CMAKE_BINARY_DIR}/apps/netutils/wakaama/wakaama
CONFIGURE_COMMAND
""
BUILD_COMMAND
""
INSTALL_COMMAND
""
TEST_COMMAND
""
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)

FetchContent_GetProperties(wakaama)

if(NOT wakaama_POPULATED)
FetchContent_Populate(wakaama)
endif()
endif()

include(wakaama/wakaama.cmake)

set(WAKAAMA_OPTIONS -Wno-format -Wno-type-limits -Wno-cast-align
-Wno-unused-but-set-variable)
set(WAKAAMA_DEFINITIONS)

if(CONFIG_ENDIAN_BIG)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_BIG_ENDIAN)
else()
list(APPEND WAKAAMA_DEFINITIONS LWM2M_LITTLE_ENDIAN)
endif()

if(CONFIG_WAKAAMA_CLIENT_MODE)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_CLIENT_MODE)
endif()

if(CONFIG_WAKAAMA_SERVER_MODE)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_SERVER_MODE)
endif()

if(CONFIG_WAKAAMA_BOOTSTRAP)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_BOOTSTRAP)
endif()

if(CONFIG_WAKAAMA_BOOTSTRAP_SERVER_MODE)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_BOOTSTRAP_SERVER_MODE)
endif()

if(CONFIG_WAKAAMA_JSON)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_SUPPORT_JSON)
endif()

if(CONFIG_WAKAAMA_SENML_JSON)
list(APPEND WAKAAMA_DEFINITIONS LWM2M_SUPPORT_SENML_JSON)
endif()

list(APPEND WAKAAMA_DEFINITIONS
LWM2M_COAP_DEFAULT_BLOCK_SIZE=${CONFIG_WAKAAMA_COAP_DEFAULT_BLOCK_SIZE})

nuttx_add_library(wakaama)
target_include_directories(wakaama PUBLIC wakaama/include)
target_compile_options(wakaama PUBLIC ${WAKAAMA_OPTIONS})
target_compile_definitions(wakaama PUBLIC ${WAKAAMA_DEFINITIONS})
target_sources_wakaama(wakaama)

include(examples.cmake)

endif()
83 changes: 83 additions & 0 deletions netutils/wakaama/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config NETUTILS_WAKAAMA
bool "Eclipse Wakaama"
default n
depends on ALLOW_ECLIPSE_COMPONENTS
---help---
Enable Eclipse Wakaama (formerly liblwm2m) - an implementation
of LWM2M protocol.

if NETUTILS_WAKAAMA

config WAKAAMA_VERSION
string "Wakaama version"
default "514659414c792f8c252782af63551b6d09704a7b"

config WAKAAMA_COAP_DEFAULT_BLOCK_SIZE
int "Wakaama LWM2M COAP default block size"
default 1024

config WAKAAMA_CLIENT_MODE
bool "Wakaama client mode"
default n

config WAKAAMA_SERVER_MODE
bool "Wakaama server mode"
default n

config WAKAAMA_BOOTSTRAP
bool "Wakaama bootstrap"
default n

config WAKAAMA_OLD_CONTENT_FORMAT_SUPPORT
bool "Wakaama old content format support"
default n

config WAKAAMA_TLV
bool "Wakaama TLV support"
default n

config WAKAAMA_JSON
bool "Wakaama JSON support"
default n

config WAKAAMA_SENML_JSON
bool "Wakaama SenML JSON support"
default n

menuconfig WAKAAMA_EXAMPLES
bool "Wakaama examples"

if WAKAAMA_EXAMPLES

if WAKAAMA_CLIENT_MODE

choice
prompt "Wakaama clinet example"
default WAKAAMA_EXAMPLE_CLIENT_LIGHT

config WAKAAMA_EXAMPLE_CLIENT_LIGHT
bool "Wakaama light client example"

config WAKAAMA_EXAMPLE_CLIENT
bool "Wakaama client example"

config WAKAAMA_EXAMPLE_CLIENT_DTLS
bool "Wakaama client DTLS example"
depends on CRYPTO_TINYDTLS

endchoice # "Wakaama clinet example"

config WAKAAMA_EXAMPLE_CLIENT_STACKSIZE
int "Wakaama client example stack size"
default 8192

endif # WAKAAMA_CLIENT_MODE

endif # WAKAAMA_EXAMPLES

endif # NETUTILS_WAKAAMA
Loading
Loading