From 0ff56f284d1807e037b1f650607502114c5d4547 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 1 Mar 2021 12:21:45 +0100 Subject: [PATCH] sys/net/app/cord: Support the addition of extra registration arguments --- sys/include/net/cord/config.h | 16 ++++++++++++++++ .../application_layer/cord/common/cord_common.c | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/sys/include/net/cord/config.h b/sys/include/net/cord/config.h index 56ed8b3e96..b6f7a47ba6 100644 --- a/sys/include/net/cord/config.h +++ b/sys/include/net/cord/config.h @@ -91,6 +91,22 @@ extern "C" { #endif /** @} */ +/** + * @brief Extra query parameters added during registration + * + * Must be suitable for constructing a static array out of them. + * + * Example: + * + * ``` + * CFLAGS += '-DCONFIG_CORD_EXTRAARGS="proxy=on","et=tag:riot-os.org,2020:board"' + * ``` + */ +#ifdef DOXYGEN +#define CONFIG_CORD_EXTRAARGS +#endif +/** @} */ + #ifdef __cplusplus } #endif diff --git a/sys/net/application_layer/cord/common/cord_common.c b/sys/net/application_layer/cord/common/cord_common.c index 73815f5e28..63985eab59 100644 --- a/sys/net/application_layer/cord/common/cord_common.c +++ b/sys/net/application_layer/cord/common/cord_common.c @@ -79,5 +79,15 @@ int cord_common_add_qstring(coap_pkt_t *pkt) } #endif +#ifdef CONFIG_CORD_EXTRAARGS + static const char *extra[] = { CONFIG_CORD_EXTRAARGS }; + for (unsigned i = 0; i < ARRAY_SIZE(extra); ++i) { + res = coap_opt_add_uri_query(pkt, extra[i], NULL); + if (res < 0) { + return res; + } + } +#endif + return 0; }