From 226b9fa383213bf99d9986d1d28053682289af05 Mon Sep 17 00:00:00 2001 From: Hauke Petersen <hauke.petersen@fu-berlin.de> Date: Mon, 15 Oct 2018 10:44:32 +0200 Subject: [PATCH] net/rdcli_simple: rename to cord_epsim --- Makefile.dep | 9 ++- examples/rdcli_simple/Makefile | 2 +- makefiles/pseudomodules.inc.mk | 2 +- sys/Makefile | 2 +- sys/auto_init/auto_init.c | 8 +-- sys/include/net/cord/epsim.h | 68 +++++++++++++++++++ sys/include/net/rdcli_simple.h | 61 ----------------- sys/net/application_layer/cord/epsim/Makefile | 8 +-- .../epsim/{rdcli_simple.c => cord_epsim.c} | 23 +++---- ...e_standalone.c => cord_epsim_standalone.c} | 16 +++-- 10 files changed, 103 insertions(+), 96 deletions(-) create mode 100644 sys/include/net/cord/epsim.h delete mode 100644 sys/include/net/rdcli_simple.h rename sys/net/application_layer/cord/epsim/{rdcli_simple.c => cord_epsim.c} (74%) rename sys/net/application_layer/cord/epsim/{rdcli_simple_standalone.c => cord_epsim_standalone.c} (77%) diff --git a/Makefile.dep b/Makefile.dep index 943e6f4fb5..8aac8bf941 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -749,14 +749,14 @@ ifneq (,$(filter skald,$(USEMODULE))) USEMODULE += random endif -ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE))) - USEMODULE += rdcli_simple +ifneq (,$(filter cord_epsim_standalone,$(USEMODULE))) + USEMODULE += cord_epsim USEMODULE += xtimer endif -ifneq (,$(filter rdcli_simple,$(USEMODULE))) +ifneq (,$(filter cord_epsim,$(USEMODULE))) USEMODULE += cord_common - USEMODULE += fmt + USEMODULE += gcoap endif ifneq (,$(filter rdcli_standalone,$(USEMODULE))) @@ -776,7 +776,6 @@ endif ifneq (,$(filter cord_common,$(USEMODULE))) USEMODULE += fmt - USEMODULE += gcoap USEMODULE += luid endif diff --git a/examples/rdcli_simple/Makefile b/examples/rdcli_simple/Makefile index d2d95afa10..cf10e75118 100644 --- a/examples/rdcli_simple/Makefile +++ b/examples/rdcli_simple/Makefile @@ -20,7 +20,7 @@ USEMODULE += auto_init_gnrc_netif USEMODULE += gnrc_ipv6_default # Run the simple CoRE resource directory -USEMODULE += rdcli_simple_standalone +USEMODULE += cord_epsim_standalone # Include the shell for testing purposes USEMODULE += shell diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 8c13111f20..edae194676 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -5,6 +5,7 @@ PSEUDOMODULES += can_pm PSEUDOMODULES += can_raw PSEUDOMODULES += ccn-lite-utils PSEUDOMODULES += conn_can_isotp_multi +PSEUDOMODULES += cord_epsim_standalone PSEUDOMODULES += core_% PSEUDOMODULES += ecc_% PSEUDOMODULES += emb6_router @@ -53,7 +54,6 @@ PSEUDOMODULES += printf_float PSEUDOMODULES += prng PSEUDOMODULES += prng_% PSEUDOMODULES += rdcli_standalone -PSEUDOMODULES += rdcli_simple_standalone PSEUDOMODULES += saul_adc PSEUDOMODULES += saul_default PSEUDOMODULES += saul_gpio diff --git a/sys/Makefile b/sys/Makefile index 5cefa1c6e1..5d9342643d 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -130,7 +130,7 @@ endif ifneq (,$(filter cord_common,$(USEMODULE))) DIRS += net/application_layer/cord/common endif -ifneq (,$(filter rdcli_simple,$(USEMODULE))) +ifneq (,$(filter cord_epsim,$(USEMODULE))) DIRS += net/application_layer/cord/epsim endif ifneq (,$(filter rdcli,$(USEMODULE))) diff --git a/sys/auto_init/auto_init.c b/sys/auto_init/auto_init.c index ed815aa8ba..7e00e1ac44 100644 --- a/sys/auto_init/auto_init.c +++ b/sys/auto_init/auto_init.c @@ -168,10 +168,10 @@ void auto_init(void) extern void rdcli_standalone_run(void); rdcli_standalone_run(); #endif -#ifdef MODULE_RDCLI_SIMPLE_STANDALONE - DEBUG("Auto init rdcli_simple module\n"); - extern void rdcli_simple_run(void); - rdcli_simple_run(); +#ifdef MODULE_CORD_EPSIM_STANDALONE + DEBUG("Auto init cord_epsim module\n"); + extern void cord_epsim_run(void); + cord_epsim_run(); #endif #ifdef MODULE_ASYMCUTE DEBUG("Auto init Asymcute\n"); diff --git a/sys/include/net/cord/epsim.h b/sys/include/net/cord/epsim.h new file mode 100644 index 0000000000..ef4050a16a --- /dev/null +++ b/sys/include/net/cord/epsim.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2017-2018 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 net_cord_epsim CoRE RD Simple Registration Endpoint + * @ingroup net_cord + * @brief CoRE Resource Directory endpoint using the simple registration + * procedure + * @{ + * + * @file + * @brief Interface for the CoRE RD simple registration endpoint + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef NET_CORD_EPSIM_H +#define NET_CORD_EPSIM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Error codes used by the cord_epsim implementation + */ +enum { + CORD_EPSIM_OK = 0, /**< all good */ + CORD_EPSIM_NOADDR = -1, /**< on address conversion errors */ + CORD_EPSIM_ERROR = -2, /**< on other errors */ +}; + +/** + * @brief Initiate the node registration by sending an empty CoAP POST message + * to the RD server's /.well-known/core resource + * + * @return CORD_EPSIM_OK on success + * @return CORD_EPSIM_NOADDR if conversion of RD address fails + * @return CORD_EPSIM_ERROR if something goes wrong preparing or sending the + * initial request + */ +int cord_epsim_register(void); + +#if defined(MODULE_CORD_EPSIM_STANDALONE) || defined(DOXYGEN) +/** + * @brief Spawn a new thread that registers the node and updates the + * registration with all responding RDs using the simple registration + * process + * + * @note Only available with the `cord_epsim_standalone` module compiled in + * + * @warning This function must only be called once (typically during system + * initialization) + */ +void cord_epsim_run(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* NET_CORD_EPSIM_H */ +/** @} */ diff --git a/sys/include/net/rdcli_simple.h b/sys/include/net/rdcli_simple.h deleted file mode 100644 index 8614f8f004..0000000000 --- a/sys/include/net/rdcli_simple.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2017-2018 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 net_rdcli_simple CoRE RD Simple Client - * @ingroup net - * @brief CoAP-based CoRE Resource Directory client supporting the simple - * registration only - * @{ - * - * @file - * @brief Interface for a simple CoRE RD registration - * - * @author Hauke Petersen <hauke.petersen@fu-berlin.de> - */ - -#ifndef NET_RDCLI_SIMPLE_H -#define NET_RDCLI_SIMPLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Error codes used by the rdcli_simple implementation - */ -enum { - RDCLI_SIMPLE_OK = 0, /**< all good */ - RDCLI_SIMPLE_NOADDR = -1, /**< on address conversion errors */ - RDCLI_SIMPLE_ERROR = -2, /**< on other errors */ -}; - -/** - * @brief Initiate the node registration by sending an empty CoAP POST message - * to the RD server's /.well-known/core resource - * - * @return RDCLI_SIMPLE_OK on success - * @return RDCLI_SIMPLE_NOADDR if conversion of RD address fails - * @return RDCLI_SIMPLE_ERROR if something goes wrong preparing or sending the - * initial request - */ -int rdcli_simple_register(void); - -/** - * @brief Spawn a new thread that registers the node and updates the - * registration with all responding RDs using the simple registration - * process - */ -void rdcli_simple_run(void); - -#ifdef __cplusplus -} -#endif - -#endif /* NET_RDCLI_SIMPLE_H */ -/** @} */ diff --git a/sys/net/application_layer/cord/epsim/Makefile b/sys/net/application_layer/cord/epsim/Makefile index db17736b3c..75aa88acb9 100644 --- a/sys/net/application_layer/cord/epsim/Makefile +++ b/sys/net/application_layer/cord/epsim/Makefile @@ -1,9 +1,9 @@ -MODULE = rdcli_simple +MODULE = cord_epsim -SRC = rdcli_simple.c +SRC = cord_epsim.c -ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE))) - SRC += rdcli_simple_standalone.c +ifneq (,$(filter cord_epsim_standalone,$(USEMODULE))) + SRC += cord_epsim_standalone.c endif include $(RIOTBASE)/Makefile.base diff --git a/sys/net/application_layer/cord/epsim/rdcli_simple.c b/sys/net/application_layer/cord/epsim/cord_epsim.c similarity index 74% rename from sys/net/application_layer/cord/epsim/rdcli_simple.c rename to sys/net/application_layer/cord/epsim/cord_epsim.c index f85642cca2..b9b6a8d810 100644 --- a/sys/net/application_layer/cord/epsim/rdcli_simple.c +++ b/sys/net/application_layer/cord/epsim/cord_epsim.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 Freie Universität Berlin + * Copyright (C) 2017-2018 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 @@ -7,11 +7,11 @@ */ /** - * @ingroup net_rdcli_simple + * @ingroup net_cord_epsim * @{ * * @file - * @brief Simplified CoAP resource directory client implementation + * @brief CoRE RD simple registration endpoint implementation * * @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @@ -20,11 +20,10 @@ #include <string.h> -#include "fmt.h" #include "net/gcoap.h" +#include "net/cord/epsim.h" #include "net/cord/config.h" #include "net/cord/common.h" -#include "net/rdcli_simple.h" #include "net/ipv6/addr.h" #define BUFSIZE (128U) @@ -34,7 +33,7 @@ static coap_pkt_t pkt; static uint8_t buf[BUFSIZE]; -int rdcli_simple_register(void) +int cord_epsim_register(void) { sock_udp_ep_t remote = { .family = AF_INET6, @@ -44,26 +43,26 @@ int rdcli_simple_register(void) /* parse RD server address */ if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr.ipv6, - RDCLI_SERVER_ADDR) == NULL) { - return RDCLI_SIMPLE_NOADDR; + CORD_SERVER_ADDR) == NULL) { + return CORD_EPSIM_NOADDR; } /* build the initial CON packet */ if (gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_POST, "/.well-known/core") < 0) { - return RDCLI_SIMPLE_ERROR; + return CORD_EPSIM_ERROR; } /* make packet confirmable */ coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON); /* add Uri-Query options */ if (cord_common_add_qstring(&pkt) < 0) { - return RDCLI_SIMPLE_ERROR; + return CORD_EPSIM_ERROR; } /* finish, we don't have any payload */ ssize_t len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE); if (gcoap_req_send2(buf, len, &remote, NULL) == 0) { - return RDCLI_SIMPLE_ERROR; + return CORD_EPSIM_ERROR; } - return RDCLI_SIMPLE_OK; + return CORD_EPSIM_OK; } diff --git a/sys/net/application_layer/cord/epsim/rdcli_simple_standalone.c b/sys/net/application_layer/cord/epsim/cord_epsim_standalone.c similarity index 77% rename from sys/net/application_layer/cord/epsim/rdcli_simple_standalone.c rename to sys/net/application_layer/cord/epsim/cord_epsim_standalone.c index 4245b13b01..98f0eaa662 100644 --- a/sys/net/application_layer/cord/epsim/rdcli_simple_standalone.c +++ b/sys/net/application_layer/cord/epsim/cord_epsim_standalone.c @@ -7,11 +7,11 @@ */ /** - * @ingroup net_rdcli_simple + * @ingroup net_cord_epsim * @{ * * @file - * @brief Standalone extension for the simple RD registration client + * @brief Standalone extension for the simple RD registration endpoint * * @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @@ -21,12 +21,12 @@ #include "log.h" #include "thread.h" #include "xtimer.h" +#include "net/cord/epsim.h" #include "net/cord/config.h" -#include "net/rdcli_simple.h" #define STACKSIZE (THREAD_STACKSIZE_DEFAULT) #define PRIO (THREAD_PRIORITY_MAIN - 1) -#define TNAME "rdcli_simple" +#define TNAME "cord_epsim" static char _stack[STACKSIZE]; @@ -38,10 +38,10 @@ static void *reg_runner(void *arg) xtimer_sleep(CORD_STARTUP_DELAY); while (1) { - if (rdcli_simple_register() != RDCLI_SIMPLE_OK) { + if (cord_epsim_register() != CORD_EPSIM_OK) { /* if this fails once, it will always fail, so we might as well * quit now */ - LOG_ERROR("[rdcli_simple] error: unable to send registration\n"); + LOG_ERROR("[cord_epsim] error: unable to send registration\n"); break; } xtimer_sleep(CORD_UPDATE_INTERVAL); @@ -50,7 +50,9 @@ static void *reg_runner(void *arg) return NULL; } -void rdcli_simple_run(void) +#ifdef MODULE_CORD_EPSIM_STANDALONE +void cord_epsim_run(void) { thread_create(_stack, sizeof(_stack), PRIO, 0, reg_runner, NULL, TNAME); } +#endif -- GitLab