Skip to content

Commit

Permalink
Merge #18515 #19331
Browse files Browse the repository at this point in the history
18515: libschc: initial import as package r=miri64 a=miri64



19331: pkg/tinydtls: Adjust defaults r=miri64 a=chrysn

### Contribution description

This adjusts two defaults in tinydtls:

* Default verbosity is set to warning. At the info level, this module produces way more output (several lines per new connection, and even per message) than is common in RIOT.
* If gcoap is used, the buffer size is adjusted to the gcoap buffer size plus overhead. Otherwise, CoAP-over-DTLS works fine until one happens to request larger resources.

### Testing procedure

* Run examples/gcoap_dtls
* Send a CoAP request from outside, eg. with `aiocoap-client 'coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/.well-known/core' --credentials testserver.json` (where testserver.json is `{"coaps://[fe80::3c63:beff:fe85:ca96%tapbr0]/*": {"dtls": {"psk": {"ascii": "secretPSK"}, "client-identity": {"ascii": "Client_identity"}}}}`).

Before, there are messages shown for every request; now there are none.

Modify `examples/gcoap/server.c` as follows:

```patch
diff --git a/examples/gcoap/server.c b/examples/gcoap/server.c
index bf2315cd01..28e1faac27 100644
--- a/examples/gcoap/server.c
+++ b/examples/gcoap/server.c
`@@` -68,7 +68,7 `@@` static const coap_resource_t _resources[] = {
 };
 
 static const char *_link_params[] = {
-    ";ct=0;rt=\"count\";obs",
+    ";ct=0;rt=\"count\";obs;looooooooooooooooooooooong-attribute=\"loooooooooooooooooooooooooooooong\"",
     NULL
 };
```

The request passes; without this patch, it is stuck in retransmissions until "Network error: Retransmissions exceeded".

### Issues/PRs references

This contributes to making #19289 usable with a minimum level of security. (That module fills up the gcoap buffer to the brim). While the module handles the verbosity as well as it can (occasionally admitting that it lost bytes of output), the previous verbosity produces an infinite stream of stdout data. (But the default should be quiet immaterial of that particular PR).

Co-authored-by: Martine Lenders <[email protected]>
Co-authored-by: chrysn <[email protected]>
  • Loading branch information
3 people authored Mar 2, 2023
3 parents a290d21 + 9459e29 + f2d5928 commit 0a44316
Show file tree
Hide file tree
Showing 20 changed files with 2,390 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
/drivers/include/periph/ptp.h @maribu

/pkg/cryptoauthlib/ @Einhornhool @PeterKietzmann
/pkg/libschc/ @bartmoons @miri64
/pkg/lua/ @jcarrano
/pkg/lwip/ @miri64
/pkg/gecko_sdk/ @basilfx
Expand Down Expand Up @@ -145,6 +146,7 @@
/tests/driver_dht/ @wosym
/tests/gnrc* @miri64
/tests/lwip* @miri64
/tests/pkg_libschc/ @miri64
/tests/slip/ @miri64
/tests/unittests @miri64
/tests/*/tests/*.py @miri64
Expand Down
1 change: 1 addition & 0 deletions pkg/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ rsource "libb2/Kconfig"
rsource "libcose/Kconfig"
rsource "libfixmath/Kconfig"
rsource "libhydrogen/Kconfig"
rsource "libschc/Kconfig"
rsource "littlefs2/Kconfig"
rsource "lorabasics/Kconfig"
rsource "lora-serialization/Kconfig"
Expand Down
39 changes: 39 additions & 0 deletions pkg/libschc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) 2022 Freie Universität Berlin
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
menuconfig KCONFIG_USEPKG_LIBSCHC
bool "Configure libSCHC"
depends on USEPKG_LIBSCHC
help
Configure libSCHC package via Kconfig.

if KCONFIG_USEPKG_LIBSCHC

config LIBSCHC_STATIC_MEMBUF_LEN
int "Static memory allocation buffer length"
default 1024
help
Length of the static memory buffer for fragment data allocation in reassembly buffer in
bytes.

config LIBSCHC_MBUF_POOL_SIZE
int "Maximum number of mbuf pool entries"
default 64
help
Maximum number of entries in the mbuf used for fragment reassembly.

config LIBSCHC_MAX_RX_CONNS
int "Maximum number of incoming connections"
default 1

config LIBSCHC_MAX_MTU_LEN
int "Maximum transfer unit of the underlying technology"
default 242

config LIBSCHC_DEBUG
bool "Enable debug output"

endif # KCONFIG_USEPKG_LIBSCHC
9 changes: 9 additions & 0 deletions pkg/libschc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PKG_NAME=libschc
PKG_URL=https://github.com/imec-idlab/libschc
PKG_VERSION=303e9f15bf69da5a68cda76796c76de353f44a88
PKG_LICENSE=GPL-v3.0

include $(RIOTBASE)/pkg/pkg.mk

all:
+$(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR) -f $(RIOTBASE)/Makefile.base
9 changes: 9 additions & 0 deletions pkg/libschc/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ifneq (,$(filter libschc_%,$(USEMODULE)))
USEPKG += libschc
endif

ifneq (,$(filter libschc,$(USEPKG)))
USEMODULE += libschc_udpv6
endif

FEATURES_BLACKLIST += arch_8bit arch_16bit arch_esp8266
12 changes: 12 additions & 0 deletions pkg/libschc/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CFLAGS += -Wno-enum-conversion
CFLAGS += -Wno-old-style-definition
CFLAGS += -Wno-sign-compare
CFLAGS += -Wno-strict-prototypes
CFLAGS += -Wno-unused-parameter
CFLAGS += -Wno-unused-variable

INCLUDES += -I$(RIOTBASE)/pkg/libschc/include
INCLUDES += -I$(PKGDIRBASE)/libschc

PSEUDOMODULES += libschc_coap
PSEUDOMODULES += libschc_udpv6
11 changes: 11 additions & 0 deletions pkg/libschc/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @defgroup pkg_libschc libSCHC
* @ingroup pkg
* @brief Provides support for Static Context Header Compression and Fragmentation (SCHC)
* @see https://github.com/imec-idlab/libschc
* @see [RFC 8724](https://datatracker.ietf.org/doc/html/rfc8724)
* @experimental
*
* libSCHC is a C implementation of Static Context Header Compression and
Fragmentation
*/
72 changes: 72 additions & 0 deletions pkg/libschc/include/libschc/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2022 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @defgroup pkg_libschc_config libSCHC compile-time configuration
* @ingroup pkg_libschc
* @ingroup config
* @brief Compile-time configuration for libSCHC
* @{
*
* @file
* @brief RIOT-side compile-time configuration for libSCHC
*
* @author Martine S. Lenders <[email protected]>
*/
#ifndef LIBSCHC_CONFIG_H
#define LIBSCHC_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Static memory buffer length
*
* Length of the static memory buffer for fragmentation in bytes.
*/
#ifndef CONFIG_LIBSCHC_STATIC_MEMBUF_LEN
#define CONFIG_LIBSCHC_STATIC_MEMBUF_LEN 1024
#endif

/**
* @brief Maximum number of mbuf pool entries
*
* Maximum number of entries in the mbuf used for fragment reassembly.
*/
#ifndef CONFIG_LIBSCHC_MBUF_POOL_SIZE
#define CONFIG_LIBSCHC_MBUF_POOL_SIZE 64
#endif

/**
* @brief Maximum number of incoming connections
*/
#ifndef CONFIG_LIBSCHC_MAX_RX_CONNS
#define CONFIG_LIBSCHC_MAX_RX_CONNS 1
#endif

/**
* @brief Maximum transfer unit of the underlying technology
*/
#ifndef CONFIG_LIBSCHC_MAX_MTU_LEN
#define CONFIG_LIBSCHC_MAX_MTU_LEN 242
#endif

/**
* @brief Enable debug output
*/
#ifndef CONFIG_LIBSCHC_DEBUG
#define CONFIG_LIBSCHC_DEBUG
#endif

#ifdef __cplusplus
}
#endif

#endif /* LIBSCHC_CONFIG_H */
/** @} */
37 changes: 37 additions & 0 deletions pkg/libschc/include/rules/rule_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2018 imec IDLab
* Copyright (C) 2022 Freie Universität Berlin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @internal
* @author boortmans <[email protected]>
* @author Martine S. Lenders <[email protected]>
*/
#ifndef RULES_RULE_CONFIG_H
#define RULES_RULE_CONFIG_H

#include "rules.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif /* RULES_RULE_CONFIG_H */
Loading

0 comments on commit 0a44316

Please sign in to comment.