Merge pull request #10163 from haukepetersen/opt_cord_restructuring
net/rdcli*: restructure and rename RD related modules
This commit is contained in:
commit
266f7ee342
22
Makefile.dep
22
Makefile.dep
@ -749,34 +749,32 @@ 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)))
|
||||
USEMODULE += rdcli_common
|
||||
USEMODULE += fmt
|
||||
ifneq (,$(filter cord_epsim,$(USEMODULE)))
|
||||
USEMODULE += cord_common
|
||||
USEMODULE += gcoap
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rdcli_standalone,$(USEMODULE)))
|
||||
USEMODULE += rdcli
|
||||
ifneq (,$(filter cord_ep_standalone,$(USEMODULE)))
|
||||
USEMODULE += cord_ep
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rdcli,$(USEMODULE)))
|
||||
USEMODULE += rdcli_common
|
||||
ifneq (,$(filter cord_ep,$(USEMODULE)))
|
||||
USEMODULE += cord_common
|
||||
USEMODULE += core_thread_flags
|
||||
USEMODULE += gcoap
|
||||
USEMODULE += fmt
|
||||
ifneq (,$(filter shell_commands,$(USEMODULE)))
|
||||
USEMODULE += sock_util
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rdcli_common,$(USEMODULE)))
|
||||
ifneq (,$(filter cord_common,$(USEMODULE)))
|
||||
USEMODULE += fmt
|
||||
USEMODULE += gcoap
|
||||
USEMODULE += luid
|
||||
endif
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# name of your application
|
||||
APPLICATION = rdcli
|
||||
APPLICATION = cord_ep
|
||||
|
||||
# If no BOARD is found in the environment, use this default:
|
||||
BOARD ?= native
|
||||
@ -19,7 +19,7 @@ USEMODULE += auto_init_gnrc_netif
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
USEMODULE += gnrc_icmpv6_echo
|
||||
|
||||
USEMODULE += rdcli_standalone
|
||||
USEMODULE += cord_ep_standalone
|
||||
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
@ -32,7 +32,7 @@ USEMODULE += fmt
|
||||
CFLAGS += -DDEVELHELP
|
||||
|
||||
# For debugging and demonstration purposes, we limit the lifetime to 60s
|
||||
CFLAGS += -DRDCLI_LT=60
|
||||
CFLAGS += -DCORD_LT=60
|
||||
|
||||
# Change this to 0 show compiler invocation lines by default:
|
||||
QUIET ?= 1
|
||||
25
examples/cord_ep/README.md
Normal file
25
examples/cord_ep/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
CoRE Resource Directory: Endpoint Example
|
||||
=========================================
|
||||
|
||||
This example application demonstrates the usage of RIOT's Resource Directory
|
||||
(RD) endpoint module, called `cord_ep`. This module supports the registration,
|
||||
update, and removal procedures as defined in
|
||||
[draft-ietf-core-resource-directory-15](https://tools.ietf.org/html/draft-ietf-core-resource-directory-15).
|
||||
|
||||
Usage
|
||||
=====
|
||||
The examples includes a shell command that you can use to interact with a given
|
||||
RD, called `cord_ep`. Simply use that shell command without parameters for
|
||||
more information on its usage.
|
||||
|
||||
Some connection parameters are configured statically during compile time,
|
||||
namely the lifetime (`CORD_LT`) and the node's endpoint name (`CORD_EP`). You
|
||||
can change these values at compile time by overriding their defines using
|
||||
command line arguments:
|
||||
```
|
||||
CFLAGS="-DCORD_EP=\\\"your_ep_name_here\\\"" make all
|
||||
```
|
||||
or by setting their values in the application's Makefile:
|
||||
```
|
||||
CFLAGS += "-DCORD_EP=\"MyNewEpName\""
|
||||
```
|
||||
@ -11,7 +11,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief CoRE Resource Directory client (rdcli) example application
|
||||
* @brief CoRE Resource Directory endpoint (cord_ep) example
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
@ -24,24 +24,24 @@
|
||||
#include "shell.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/gcoap.h"
|
||||
#include "net/rdcli_common.h"
|
||||
#include "net/rdcli_standalone.h"
|
||||
#include "net/cord/common.h"
|
||||
#include "net/cord/ep_standalone.h"
|
||||
|
||||
#define MAIN_QUEUE_SIZE (8)
|
||||
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
|
||||
|
||||
/* we will use a custom event handler for dumping rdcli_standalone events */
|
||||
static void _on_rdcli_event(rdcli_standalone_event_t event)
|
||||
/* we will use a custom event handler for dumping cord_ep events */
|
||||
static void _on_ep_event(cord_ep_standalone_event_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case RDCLI_REGISTERED:
|
||||
puts("rdcli event: now registered with a RD");
|
||||
case CORD_EP_REGISTERED:
|
||||
puts("RD endpoint event: now registered with a RD");
|
||||
break;
|
||||
case RDCLI_DEREGISTERED:
|
||||
puts("rdcli event: dropped client registration");
|
||||
case CORD_EP_DEREGISTERED:
|
||||
puts("RD endpoint event: dropped client registration");
|
||||
break;
|
||||
case RDCLI_UPDATED:
|
||||
puts("rdcli event: successfully updated client registration");
|
||||
case CORD_EP_UPDATED:
|
||||
puts("RD endpoint event: successfully updated client registration");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -94,12 +94,12 @@ int main(void)
|
||||
/* setup CoAP resources */
|
||||
gcoap_register_listener(&_listener);
|
||||
|
||||
/* register event callback with rdcli_standalone */
|
||||
rdcli_standalone_reg_cb(_on_rdcli_event);
|
||||
/* register event callback with cord_ep_standalone */
|
||||
cord_ep_standalone_reg_cb(_on_ep_event);
|
||||
|
||||
puts("Client information:");
|
||||
printf(" ep: %s\n", rdcli_common_get_ep());
|
||||
printf(" lt: %is\n", (int)RDCLI_LT);
|
||||
printf(" ep: %s\n", cord_common_get_ep());
|
||||
printf(" lt: %is\n", (int)CORD_LT);
|
||||
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
@ -1,5 +1,5 @@
|
||||
# name of your application
|
||||
APPLICATION = rdcli_simple
|
||||
APPLICATION = cord_epsim
|
||||
|
||||
# If no BOARD is found in the environment, use this default:
|
||||
BOARD ?= native
|
||||
@ -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
|
||||
@ -40,8 +40,8 @@ RD_LT ?= 60
|
||||
RD_ADDR ?= \"ff02::1\"
|
||||
RD_PORT ?= 5683
|
||||
|
||||
CFLAGS += -DRDCLI_LT=$(RD_LT)
|
||||
CFLAGS += -DRDCLI_SERVER_ADDR=$(RD_ADDR)
|
||||
CFLAGS += -DRDCLI_SERVER_PORT=$(RD_PORT)
|
||||
CFLAGS += -DCORD_LT=$(RD_LT)
|
||||
CFLAGS += -DCORD_SERVER_ADDR=$(RD_ADDR)
|
||||
CFLAGS += -DCORD_SERVER_PORT=$(RD_PORT)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
@ -1,15 +1,15 @@
|
||||
CoRE Resource Directory: Simple Registration Example
|
||||
====================================================
|
||||
CoRE Resource Directory: Simple Endpoint Example
|
||||
================================================
|
||||
|
||||
This example shows how a node can register with a CoRE resource directory using
|
||||
the simple registration process as described in
|
||||
draft-ietf-core-resource-directory-11, section 5.3.2.
|
||||
the simple registration procedure as described in
|
||||
draft-ietf-core-resource-directory-15, section 5.3.1.
|
||||
|
||||
The registration process needs an endpoint name as well as a lifetime for the
|
||||
registry entry. You can edit these values by overriding `RDCLI_EP` and
|
||||
`RDCLI_LT`:
|
||||
registry entry. These are statically defined during compile time and you can
|
||||
edit these values by overriding `CORD_EP` and `CORD_LT`:
|
||||
```
|
||||
CFLAGS="-DRDCLI_LT=\"7200\" -DRDCLI_EP=\"MyNode\"" make all
|
||||
CFLAGS="-DCORD_LT=\"7200\" -DCORD_EP=\"MyNode\"" make all
|
||||
```
|
||||
|
||||
Per default, the node is looking for the CoRE RD at the all nodes link-local
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
#include "shell.h"
|
||||
#include "net/gcoap.h"
|
||||
#include "net/rdcli_common.h"
|
||||
#include "net/cord/common.h"
|
||||
|
||||
#define BUFSIZE (64U)
|
||||
|
||||
@ -68,17 +68,17 @@ int main(void)
|
||||
|
||||
/* fill riot info */
|
||||
sprintf(riot_info, "{\"ep\":\"%s\",\"lt\":%u}",
|
||||
rdcli_common_get_ep(), RDCLI_LT);
|
||||
cord_common_get_ep(), CORD_LT);
|
||||
|
||||
/* register resource handlers with gcoap */
|
||||
gcoap_register_listener(&listener);
|
||||
|
||||
/* print RD client information */
|
||||
puts("RD client information:");
|
||||
printf(" RD addr: %s\n", RDCLI_SERVER_ADDR);
|
||||
printf(" RD port: %u\n", (unsigned)RDCLI_SERVER_PORT);
|
||||
printf(" ep: %s\n", rdcli_common_get_ep());
|
||||
printf(" lt: %is\n", (int)RDCLI_LT);
|
||||
printf(" RD addr: %s\n", CORD_SERVER_ADDR);
|
||||
printf(" RD port: %u\n", (unsigned)CORD_SERVER_PORT);
|
||||
printf(" ep: %s\n", cord_common_get_ep());
|
||||
printf(" lt: %is\n", (int)CORD_LT);
|
||||
|
||||
/* run the shell */
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
@ -1,20 +0,0 @@
|
||||
CoRE Resource Directory Client Example
|
||||
======================================
|
||||
This example application demonstrates the usage of RIOT's Resource Directory
|
||||
(RD) client module, called `rdcli`. This module supports the registration,
|
||||
update, and removal processes as defined in the
|
||||
[Resource Directory Draft](https://tools.ietf.org/html/draft-ietf-core-resource-directory-14).
|
||||
|
||||
Usage
|
||||
=====
|
||||
The examples includes a shell command that you can use to interact with a given
|
||||
RD server, called `rdcli`. Simply use that shell command without parameters for
|
||||
more information on its usage.
|
||||
|
||||
Some connection parameters are configured statically during compile time,
|
||||
namely the lifetime (`RDCLI_LT`) and the node's endpoint name (`RDCLI_EP`). You
|
||||
can change these values during command line by overriding these values in the
|
||||
application's Makefile, e.g. add
|
||||
```
|
||||
CFLAGS += "-DRDCLI_EP=\"MyNewEpName\""
|
||||
```
|
||||
@ -5,6 +5,8 @@ PSEUDOMODULES += can_pm
|
||||
PSEUDOMODULES += can_raw
|
||||
PSEUDOMODULES += ccn-lite-utils
|
||||
PSEUDOMODULES += conn_can_isotp_multi
|
||||
PSEUDOMODULES += cord_ep_standalone
|
||||
PSEUDOMODULES += cord_epsim_standalone
|
||||
PSEUDOMODULES += core_%
|
||||
PSEUDOMODULES += ecc_%
|
||||
PSEUDOMODULES += emb6_router
|
||||
@ -52,8 +54,6 @@ PSEUDOMODULES += pktqueue
|
||||
PSEUDOMODULES += printf_float
|
||||
PSEUDOMODULES += prng
|
||||
PSEUDOMODULES += prng_%
|
||||
PSEUDOMODULES += rdcli_standalone
|
||||
PSEUDOMODULES += rdcli_simple_standalone
|
||||
PSEUDOMODULES += saul_adc
|
||||
PSEUDOMODULES += saul_default
|
||||
PSEUDOMODULES += saul_gpio
|
||||
|
||||
12
sys/Makefile
12
sys/Makefile
@ -127,14 +127,14 @@ endif
|
||||
ifneq (,$(filter skald,$(USEMODULE)))
|
||||
DIRS += net/skald
|
||||
endif
|
||||
ifneq (,$(filter rdcli_common,$(USEMODULE)))
|
||||
DIRS += net/application_layer/rdcli_common
|
||||
ifneq (,$(filter cord_common,$(USEMODULE)))
|
||||
DIRS += net/application_layer/cord/common
|
||||
endif
|
||||
ifneq (,$(filter rdcli_simple,$(USEMODULE)))
|
||||
DIRS += net/application_layer/rdcli_simple
|
||||
ifneq (,$(filter cord_epsim,$(USEMODULE)))
|
||||
DIRS += net/application_layer/cord/epsim
|
||||
endif
|
||||
ifneq (,$(filter rdcli,$(USEMODULE)))
|
||||
DIRS += net/application_layer/rdcli
|
||||
ifneq (,$(filter cord_ep,$(USEMODULE)))
|
||||
DIRS += net/application_layer/cord/ep
|
||||
endif
|
||||
|
||||
|
||||
|
||||
@ -158,20 +158,20 @@ void auto_init(void)
|
||||
DEBUG("Auto init Skald\n");
|
||||
skald_init();
|
||||
#endif
|
||||
#ifdef MODULE_RDCLI_COMMON
|
||||
DEBUG("Auto init rdcli_common module\n");
|
||||
extern void rdcli_common_init(void);
|
||||
rdcli_common_init();
|
||||
#ifdef MODULE_CORD_COMMON
|
||||
DEBUG("Auto init cord_common module\n");
|
||||
extern void cord_common_init(void);
|
||||
cord_common_init();
|
||||
#endif
|
||||
#ifdef MODULE_RDCLI_STANDALONE
|
||||
DEBUG("Auto init rdcli_standalone\n");
|
||||
extern void rdcli_standalone_run(void);
|
||||
rdcli_standalone_run();
|
||||
#ifdef MODULE_CORD_EP_STANDALONE
|
||||
DEBUG("Auto init cord_ep_standalone\n");
|
||||
extern void cord_ep_standalone_run(void);
|
||||
cord_ep_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");
|
||||
|
||||
@ -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,21 +7,21 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_rdcli_common CoRE RD Client Common
|
||||
* @ingroup net
|
||||
* @brief Shared functionality for CoRE Resource Directory clients
|
||||
* @defgroup net_cord_common CoRE RD Common
|
||||
* @ingroup net_cord
|
||||
* @brief Shared functionality for CoRE Resource Directory endpoints
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Shared CoRE RD client functions
|
||||
* @brief Shared CoRE RD endpoint functions
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NET_RDCLI_COMMON_H
|
||||
#define NET_RDCLI_COMMON_H
|
||||
#ifndef NET_CORD_COMMON_H
|
||||
#define NET_CORD_COMMON_H
|
||||
|
||||
#include "net/rdcli_config.h"
|
||||
#include "net/cord/config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -30,39 +30,39 @@ extern "C" {
|
||||
/**
|
||||
* @brief Export the local endpoint identifier
|
||||
*
|
||||
* @note Use rdcli_common_get_ep() for accessing the endpoint identifier
|
||||
* @note Use cord_common_get_ep() for accessing the endpoint identifier
|
||||
*/
|
||||
extern char rdcli_ep[];
|
||||
extern char cord_common_ep[];
|
||||
|
||||
/**
|
||||
* @brief Generate unique endpoint identifier (ep)
|
||||
*/
|
||||
void rdcli_common_init(void);
|
||||
void cord_common_init(void);
|
||||
|
||||
/**
|
||||
* @brief Get the local endpoint identifier
|
||||
*/
|
||||
static inline const char *rdcli_common_get_ep(void)
|
||||
static inline const char *cord_common_get_ep(void)
|
||||
{
|
||||
return (const char *)rdcli_ep;
|
||||
return (const char *)cord_common_ep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add selected query string options to a gcoap request
|
||||
*
|
||||
* This function adds:
|
||||
* - `ep` -> as extracted by rdcli_commont_get_ep()
|
||||
* - [optional] `lt` -> if defined by RDCLI_LT
|
||||
* - [optional] 'd' -> if defined by RDCLI_D
|
||||
* - `ep` -> as extracted by cord_common_get_ep()
|
||||
* - [optional] `lt` -> if defined by CORD_LT
|
||||
* - [optional] 'd' -> if defined by CORD_D
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return <0 on error
|
||||
*/
|
||||
int rdcli_common_add_qstring(coap_pkt_t *pkt);
|
||||
int cord_common_add_qstring(coap_pkt_t *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NET_RDCLI_COMMON_H */
|
||||
#endif /* NET_CORD_COMMON_H */
|
||||
/** @} */
|
||||
@ -7,21 +7,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_rdcli_config CoRE RD Client Configuration
|
||||
* @ingroup net
|
||||
* @brief Shared CoRE Resource Directory Client Configuration
|
||||
* @defgroup net_cord_config CoRE RD Endpoint and Lookup Client Configuration
|
||||
* @ingroup net_cord
|
||||
* @brief Configuration options for CoRE RD endpoints and lookup clients
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief CoRE RD Client static configuration default values
|
||||
* @brief (Default) configuration values for CoRE RD endpoints and lookup
|
||||
* clients
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NET_RDCLI_CONFIG_H
|
||||
#define NET_RDCLI_CONFIG_H
|
||||
|
||||
#include "net/ipv6/addr.h"
|
||||
#ifndef NET_CORD_CONFIG_H
|
||||
#define NET_CORD_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -30,49 +29,49 @@ extern "C" {
|
||||
/**
|
||||
* @brief Default lifetime in seconds (the default is 1 day)
|
||||
*/
|
||||
#ifndef RDCLI_LT
|
||||
#define RDCLI_LT (86400UL)
|
||||
#ifndef CORD_LT
|
||||
#define CORD_LT (86400UL)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Delay until the RD client starts to try registering (in seconds)
|
||||
*/
|
||||
#ifndef RDCLI_STARTUP_DELAY
|
||||
#define RDCLI_STARTUP_DELAY (3U)
|
||||
#ifndef CORD_STARTUP_DELAY
|
||||
#define CORD_STARTUP_DELAY (3U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default client update interval (default is 3/4 the lifetime)
|
||||
*/
|
||||
#ifndef RDCLI_UPDATE_INTERVAL
|
||||
#define RDCLI_UPDATE_INTERVAL ((RDCLI_LT / 4) * 3)
|
||||
#ifndef CORD_UPDATE_INTERVAL
|
||||
#define CORD_UPDATE_INTERVAL ((CORD_LT / 4) * 3)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Endpoint ID definition
|
||||
*
|
||||
* Per default, the endpoint ID (ep) is generated by concatenation of a user
|
||||
* defined prefix (RDCLI_EP_PREFIX) and a locally unique ID (luid) encoded in
|
||||
* defined prefix (CORD_EP_PREFIX) and a locally unique ID (luid) encoded in
|
||||
* hexadecimal formatting with the given length of characters
|
||||
* (RDCLI_EP_SUFFIX_LEN).
|
||||
* (CORD_EP_SUFFIX_LEN).
|
||||
*
|
||||
* Alternatively, the endpoint ID value can be defined at compile time by
|
||||
* assigning a string value to the RDCLI_ED macro.
|
||||
* assigning a string value to the CORD_ED macro.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef RDCLI_EP
|
||||
#ifndef CORD_EP
|
||||
/**
|
||||
* @brief Number of generated hexadecimal characters added to the ep
|
||||
*
|
||||
* @note Must be an even number
|
||||
*/
|
||||
#define RDCLI_EP_SUFFIX_LEN (16)
|
||||
#define CORD_EP_SUFFIX_LEN (16)
|
||||
|
||||
/**
|
||||
* @brief Default static prefix used for the generated ep
|
||||
*/
|
||||
#define RDCLI_EP_PREFIX "RIOT-"
|
||||
#define CORD_EP_PREFIX "RIOT-"
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
@ -80,20 +79,20 @@ extern "C" {
|
||||
* @brief Use ALL_NODES multicast address as default address when looking for
|
||||
* a RD server
|
||||
*/
|
||||
#ifndef RDCLI_SERVER_ADDR
|
||||
#define RDCLI_SERVER_ADDR "ff02::1"
|
||||
#ifndef CORD_SERVER_ADDR
|
||||
#define CORD_SERVER_ADDR "ff02::1"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Default Port to use when looking for RDs
|
||||
*/
|
||||
#ifndef RDCLI_SERVER_PORT
|
||||
#define RDCLI_SERVER_PORT COAP_PORT
|
||||
#ifndef CORD_SERVER_PORT
|
||||
#define CORD_SERVER_PORT COAP_PORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NET_RDCLI_CONFIG_H */
|
||||
#endif /* NET_CORD_CONFIG_H */
|
||||
/** @} */
|
||||
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_rdcli CoRE RD Endpoint Library
|
||||
* @ingroup net
|
||||
* @defgroup net_cord_ep CoRE RD Endpoint
|
||||
* @ingroup net_cord
|
||||
* @brief Library for using RIOT as CoRE Resource Directory endpoint
|
||||
*
|
||||
* This module implements a CoRE Resource Directory endpoint library, that
|
||||
@ -17,14 +17,10 @@
|
||||
* draft-ietf-core-resource-directory-15.
|
||||
* @see https://tools.ietf.org/html/draft-ietf-core-resource-directory-15
|
||||
*
|
||||
* @note As the name of this library (`rdcli`) can be misleading in
|
||||
* context of the RD draft (endpoint vs client), this library
|
||||
* will most likely undergo a name change in the near future...
|
||||
*
|
||||
* # Design Decisions
|
||||
* - all operations provided by this module are fully synchronous, meaning that
|
||||
* the functions will block until an operation is successful or will time out
|
||||
* - the implementation limits the client to be registered with a single RD at
|
||||
* - the implementation limits the endpoint to be registered with a single RD at
|
||||
* any point in time
|
||||
*
|
||||
* @{
|
||||
@ -35,8 +31,8 @@
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NET_RDCLI_H
|
||||
#define NET_RDCLI_H
|
||||
#ifndef NET_CORD_EP_H
|
||||
#define NET_CORD_EP_H
|
||||
|
||||
#include "net/sock/udp.h"
|
||||
|
||||
@ -48,11 +44,11 @@ extern "C" {
|
||||
* @brief Return values and error codes used by this module
|
||||
*/
|
||||
enum {
|
||||
RDCLI_OK = 0, /**< everything went as expected */
|
||||
RDCLI_TIMEOUT = -1, /**< no response from the network */
|
||||
RDCLI_ERR = -2, /**< internal error or invalid reply */
|
||||
RDCLI_NORD = -3, /**< not connected to an RD */
|
||||
RDCLI_OVERFLOW = -4, /**< internal buffers can not handle input */
|
||||
CORD_EP_OK = 0, /**< everything went as expected */
|
||||
CORD_EP_TIMEOUT = -1, /**< no response from the network */
|
||||
CORD_EP_ERR = -2, /**< internal error or invalid reply */
|
||||
CORD_EP_NORD = -3, /**< not connected to an RD */
|
||||
CORD_EP_OVERFLOW = -4, /**< internal buffers can not handle input */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -62,19 +58,19 @@ enum {
|
||||
* @param[out] regif the registration interface is written to this buffer
|
||||
* @param[in] maxlen size of @p regif
|
||||
*
|
||||
* @return RDCLI_OK on success
|
||||
* @return RDCLI_TIMEOUT if the discovery request times out
|
||||
* @return RDCLI_NORD if addressed endpoint is not a RD
|
||||
* @return RDCLI_ERR on any other internal error
|
||||
* @return CORD_EP_OK on success
|
||||
* @return CORD_EP_TIMEOUT if the discovery request times out
|
||||
* @return CORD_EP_NORD if addressed endpoint is not a RD
|
||||
* @return CORD_EP_ERR on any other internal error
|
||||
*/
|
||||
int rdcli_discover_regif(const sock_udp_ep_t *remote,
|
||||
int cord_ep_discover_regif(const sock_udp_ep_t *remote,
|
||||
char *regif, size_t maxlen);
|
||||
|
||||
/**
|
||||
* @brief Initiate the node registration by sending an empty push
|
||||
*
|
||||
* - if registration fails (e.g. timeout), we are not associated with any RD
|
||||
* anymore (even if we have been before we called rdcli_register)
|
||||
* anymore (even if we have been before we called cord_ep_register)
|
||||
*
|
||||
* @note In case a multicast address is given, the @p regif parameter MUST be
|
||||
* NULL. The first RD responding to the request will be chosen and all
|
||||
@ -84,40 +80,40 @@ int rdcli_discover_regif(const sock_udp_ep_t *remote,
|
||||
* @param[in] regif registration interface resource of the RD, it will be
|
||||
* discovered automatically when set to NULL
|
||||
*
|
||||
* @return RDCLI_OK on success
|
||||
* @return RDCLI_TIMEOUT on registration timeout
|
||||
* @return RDCLI_NORD if addressed endpoint is not a RD
|
||||
* @return RDCLI_OVERFLOW if @p regif does not fit into internal buffer
|
||||
* @return RDCLI_ERR on any other internal error
|
||||
* @return CORD_EP_OK on success
|
||||
* @return CORD_EP_TIMEOUT on registration timeout
|
||||
* @return CORD_EP_NORD if addressed endpoint is not a RD
|
||||
* @return CORD_EP_OVERFLOW if @p regif does not fit into internal buffer
|
||||
* @return CORD_EP_ERR on any other internal error
|
||||
*/
|
||||
int rdcli_register(const sock_udp_ep_t *remote, const char *regif);
|
||||
int cord_ep_register(const sock_udp_ep_t *remote, const char *regif);
|
||||
|
||||
/**
|
||||
* @brief Update our current entry at the RD
|
||||
*
|
||||
* @return RDCLI_OK on success
|
||||
* @return RDCLI_TIMEOUT if the update request times out
|
||||
* @return RDCLI_ERR on any other internal error
|
||||
* @return CORD_EP_OK on success
|
||||
* @return CORD_EP_TIMEOUT if the update request times out
|
||||
* @return CORD_EP_ERR on any other internal error
|
||||
*/
|
||||
int rdcli_update(void);
|
||||
int cord_ep_update(void);
|
||||
|
||||
/**
|
||||
* @brief Unregister from a given RD server
|
||||
*
|
||||
* @return RDCLI_OK on success
|
||||
* @return RDCLI_TIMEOUT if the remove request times out
|
||||
* @return RDCLI_ERR on any other internal error
|
||||
* @return CORD_EP_OK on success
|
||||
* @return CORD_EP_TIMEOUT if the remove request times out
|
||||
* @return CORD_EP_ERR on any other internal error
|
||||
*/
|
||||
int rdcli_remove(void);
|
||||
int cord_ep_remove(void);
|
||||
|
||||
/**
|
||||
* @brief Dump the current RD connection status to STDIO (for debugging)
|
||||
*/
|
||||
void rdcli_dump_status(void);
|
||||
void cord_ep_dump_status(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NET_RDCLI_H */
|
||||
#endif /* NET_CORD_EP_H */
|
||||
/** @} */
|
||||
88
sys/include/net/cord/ep_standalone.h
Normal file
88
sys/include/net/cord/ep_standalone.h
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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_ep_standalone CoRE RD Endpoint Standalone Extension
|
||||
* @ingroup net_cord_ep
|
||||
* @brief Run a CoRE Resource Directory endpoint standalone
|
||||
*
|
||||
* This sub-module enables a CoRE RD endpoint to manage is registration state
|
||||
* with a RD autonomously by periodically running the update procedure. This
|
||||
* is implemented by running a dedicated thread.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief CoRE Resource Directory endpoint standalone extension
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NET_CORD_EP_STANDALONE_H
|
||||
#define NET_CORD_EP_STANDALONE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Possible types of events triggered by the cord_ep_standalone module
|
||||
*/
|
||||
typedef enum {
|
||||
CORD_EP_REGISTERED,
|
||||
CORD_EP_DEREGISTERED,
|
||||
CORD_EP_UPDATED,
|
||||
} cord_ep_standalone_event_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function signature for RD endpoint state synchronization
|
||||
*
|
||||
* The registered callback function is executed in the context of the dedicated
|
||||
* standalone RD endpoint's thread.
|
||||
*
|
||||
* @param[in] t type of event
|
||||
*/
|
||||
typedef void(*cord_ep_standalone_cb_t)(cord_ep_standalone_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Spawn a new thread that takes care of sending periodic updates to an
|
||||
* active RD entry
|
||||
*
|
||||
* @warning This function must only be called once (typically during system
|
||||
* initialization)
|
||||
*/
|
||||
void cord_ep_standalone_run(void);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be notified about RD endpoint state changes
|
||||
*
|
||||
* Only a single callback can be active at any point in time, so setting a new
|
||||
* callback will override the existing one.
|
||||
*
|
||||
* @pre @p cb != NULL
|
||||
*
|
||||
* @param[in] cb callback to execute on RD endpoint state changes
|
||||
*/
|
||||
void cord_ep_standalone_reg_cb(cord_ep_standalone_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Signal the cord_ep thread about connection status change
|
||||
*
|
||||
* @note This function should not be called by a user, but it is called from
|
||||
* withing the cord_ep implementation
|
||||
*
|
||||
* @param[in] connected set to true if we are connected to a RD
|
||||
*/
|
||||
void cord_ep_standalone_signal(bool connected);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NET_CORD_EP_STANDALONE_H */
|
||||
/** @} */
|
||||
68
sys/include/net/cord/epsim.h
Normal file
68
sys/include/net/cord/epsim.h
Normal file
@ -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 */
|
||||
/** @} */
|
||||
@ -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 */
|
||||
/** @} */
|
||||
@ -1,90 +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_standalone CoRE RD Standalone Extension
|
||||
* @ingroup net_rdcli
|
||||
* @brief Run CoRE Resource Directory client in standalone configuration
|
||||
*
|
||||
* This sub-module enables the CoRE RD client to manage is registration state
|
||||
* with a server autonomously by periodically running the update procedure. This
|
||||
* is implemented by running a dedicated thread.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief CoRE Resource Directory client standalone extension
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*/
|
||||
|
||||
#ifndef NET_RDCLI_STANDALONE_H
|
||||
#define NET_RDCLI_STANDALONE_H
|
||||
|
||||
#include "net/sock/udp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Possible types of events triggered by the standalone rdcli module
|
||||
*/
|
||||
typedef enum {
|
||||
RDCLI_REGISTERED,
|
||||
RDCLI_DEREGISTERED,
|
||||
RDCLI_UPDATED,
|
||||
} rdcli_standalone_event_t;
|
||||
|
||||
/**
|
||||
* @brief Callback function signature for RD client state synchronization
|
||||
*
|
||||
* The registered callback function is executed in the context of the dedicated
|
||||
* standalone RD client's thread.
|
||||
*
|
||||
* @param[in] t type of event
|
||||
*/
|
||||
typedef void(*rdcli_standalone_cb_t)(rdcli_standalone_event_t event);
|
||||
|
||||
/**
|
||||
* @brief Spawn a new thread that takes care of sending periodic updates to an
|
||||
* active RD entry
|
||||
*
|
||||
* @note This function must only be called once (typically during system
|
||||
* initialization)
|
||||
*/
|
||||
void rdcli_standalone_run(void);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be notified about RD client state changes
|
||||
*
|
||||
* Only a single callback can be active at any point in time, so setting a new
|
||||
* callback will override the existing one.
|
||||
*
|
||||
* @pre @p cb != NULL
|
||||
*
|
||||
* @param[in] cb callback to execute on RD client state changes
|
||||
*/
|
||||
void rdcli_standalone_reg_cb(rdcli_standalone_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Signal the rdcli thread about connection status change
|
||||
*
|
||||
* @note This function should not be called by a user, but it is called from
|
||||
* withing the rdcli implementation
|
||||
*
|
||||
* @param[in] connected set to true if we are connected to a RD
|
||||
*/
|
||||
void rdcli_standalone_signal(bool connected);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NET_RDCLI_STANDALONE_H */
|
||||
/** @} */
|
||||
@ -1 +1,3 @@
|
||||
MODULE = cord_common
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_rdcli_common
|
||||
* @ingroup net_cord_common
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -22,50 +22,50 @@
|
||||
#include "luid.h"
|
||||
|
||||
#include "net/gcoap.h"
|
||||
#include "net/rdcli_common.h"
|
||||
#include "net/cord/common.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#ifdef RDCLI_EP
|
||||
#define BUFSIZE (sizeof(RDCLI_EP)) /* contains \0 termination char */
|
||||
#ifdef CORD_EP
|
||||
#define BUFSIZE (sizeof(CORD_EP)) /* contains \0 termination char */
|
||||
#else
|
||||
#define PREFIX_LEN (sizeof(RDCLI_EP_PREFIX)) /* contains \0 char */
|
||||
#define BUFSIZE (PREFIX_LEN + RDCLI_EP_SUFFIX_LEN)
|
||||
#define PREFIX_LEN (sizeof(CORD_EP_PREFIX)) /* contains \0 char */
|
||||
#define BUFSIZE (PREFIX_LEN + CORD_EP_SUFFIX_LEN)
|
||||
#endif
|
||||
|
||||
char rdcli_ep[BUFSIZE];
|
||||
char cord_common_ep[BUFSIZE];
|
||||
|
||||
void rdcli_common_init(void)
|
||||
void cord_common_init(void)
|
||||
{
|
||||
#ifdef RDCLI_EP
|
||||
memcpy(rdcli_ep, RDCLI_EP, BUFSIZE);
|
||||
#ifdef CORD_EP
|
||||
memcpy(cord_common_ep, CORD_EP, BUFSIZE);
|
||||
#else
|
||||
uint8_t luid[RDCLI_EP_SUFFIX_LEN / 2];
|
||||
uint8_t luid[CORD_EP_SUFFIX_LEN / 2];
|
||||
|
||||
if (PREFIX_LEN > 1) {
|
||||
memcpy(rdcli_ep, RDCLI_EP_PREFIX, (PREFIX_LEN - 1));
|
||||
memcpy(cord_common_ep, CORD_EP_PREFIX, (PREFIX_LEN - 1));
|
||||
}
|
||||
|
||||
luid_get(luid, sizeof(luid));
|
||||
fmt_bytes_hex(&rdcli_ep[PREFIX_LEN - 1], luid, sizeof(luid));
|
||||
rdcli_ep[BUFSIZE - 1] = '\0';
|
||||
fmt_bytes_hex(&cord_common_ep[PREFIX_LEN - 1], luid, sizeof(luid));
|
||||
cord_common_ep[BUFSIZE - 1] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
int rdcli_common_add_qstring(coap_pkt_t *pkt)
|
||||
int cord_common_add_qstring(coap_pkt_t *pkt)
|
||||
{
|
||||
/* extend the url with some query string options */
|
||||
int res = gcoap_add_qstring(pkt, "ep", rdcli_ep);
|
||||
int res = gcoap_add_qstring(pkt, "ep", cord_common_ep);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* [optional] set the lifetime parameter */
|
||||
#if RDCLI_LT
|
||||
#if CORD_LT
|
||||
char lt[11];
|
||||
lt[fmt_u32_dec(lt, RDCLI_LT)] = '\0';
|
||||
lt[fmt_u32_dec(lt, CORD_LT)] = '\0';
|
||||
res = gcoap_add_qstring(pkt, "lt", lt);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
@ -73,8 +73,8 @@ int rdcli_common_add_qstring(coap_pkt_t *pkt)
|
||||
#endif
|
||||
|
||||
/* [optional] set the domain parameter */
|
||||
#ifdef RDCLI_D
|
||||
res = gcoap_add_qstring(pkt, "d", RDCLI_D);
|
||||
#ifdef CORD_D
|
||||
res = gcoap_add_qstring(pkt, "d", CORD_D);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
65
sys/net/application_layer/cord/doc.txt
Normal file
65
sys/net/application_layer/cord/doc.txt
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 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 CoRE RD Endpoint and Lookup Client
|
||||
* @ingroup net
|
||||
* @brief Library for interacting as endpoint and lookup client with CoRE
|
||||
* Resource Directories
|
||||
*
|
||||
* # About
|
||||
* The `cord` ([Co]RE [R]esource [D]irectory) module provides endpoint and
|
||||
* lookup client functionality for interacting with CoRE Resource Directories
|
||||
* (RDs) as defined in `draft-ietf-core-resource-directory-15`.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/draft-ietf-core-resource-directory-15
|
||||
*
|
||||
* `draft-ietf-core-resource-directory-15` defines two types different roles for
|
||||
* nodes when interacting with a RD:
|
||||
* - `endpoint`: registers and manages entries at the RD
|
||||
* - `client`: performs different kind of lookups
|
||||
*
|
||||
* ```
|
||||
* Registration Lookup, Group
|
||||
* Interface Interfaces
|
||||
* +----+ | |
|
||||
* | EP |---- | |
|
||||
* +----+ ---- | |
|
||||
* --|- +------+ |
|
||||
* +----+ | ----| | | +--------+
|
||||
* | EP | ---------|-----| RD |----|-----| Client |
|
||||
* +----+ | ----| | | +--------+
|
||||
* --|- +------+ |
|
||||
* +----+ ---- | |
|
||||
* | EP |---- | |
|
||||
* +----+
|
||||
* ```
|
||||
* Figure copied form `draft-ietf-core-resource-directory-15`.
|
||||
*
|
||||
* @note In the context of this module, we refer to these roles as `endpoint
|
||||
* (ep)` and `lookup client (lc)`. This should hopefully prevent some
|
||||
* confusion in conjunction with the `client` and `server` roles as
|
||||
* defined by CoAP.
|
||||
*
|
||||
* # Structure
|
||||
*
|
||||
* This module is structured in a number of submodules with goal to reflect the
|
||||
* different roles described in `draft-ietf-core-resource-directory-15`:
|
||||
*
|
||||
* - `cord_ep`: standard endpoint implementation following the rules as
|
||||
* defined i.a. in sections 5.2, 5.3, A.1, and A.2
|
||||
* - `cord_epsim`: endpoint implementation following the simple registration
|
||||
* procedure as defined in section 5.3.1
|
||||
* - `cord_lc`: lookup client implementation for querying information from
|
||||
* an RD using the lookup and group interfaces (**NOT
|
||||
* YET IMPLEMENTED**)
|
||||
* - `cord_config`: header file collection (default) configuration values used
|
||||
* throughout this module
|
||||
* - `cord_common`: shared functionality used by the above submodules
|
||||
*
|
||||
*/
|
||||
9
sys/net/application_layer/cord/ep/Makefile
Normal file
9
sys/net/application_layer/cord/ep/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
MODULE = cord_ep
|
||||
|
||||
SRC = cord_ep.c
|
||||
|
||||
ifneq (,$(filter cord_ep_standalone,$(USEMODULE)))
|
||||
SRC += cord_ep_standalone.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_rdcli
|
||||
* @ingroup net_cord_ep
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief CoRE Resource Directory client implementation
|
||||
* @brief CoRE Resource Directory endpoint implementation
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
@ -20,18 +20,18 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "fmt.h"
|
||||
#include "mutex.h"
|
||||
#include "assert.h"
|
||||
#include "thread_flags.h"
|
||||
|
||||
#include "net/gcoap.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/rdcli.h"
|
||||
#include "net/rdcli_common.h"
|
||||
#include "net/rdcli_config.h"
|
||||
#include "net/cord/ep.h"
|
||||
#include "net/cord/common.h"
|
||||
#include "net/cord/config.h"
|
||||
|
||||
#ifdef MODULE_RDCLI_STANDALONE
|
||||
#include "net/rdcli_standalone.h"
|
||||
#ifdef MODULE_CORD_EP_STANDALONE
|
||||
#include "net/cord/ep_standalone.h"
|
||||
#endif
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
@ -68,16 +68,16 @@ static int _sync(void)
|
||||
thread_flags_t flags = thread_flags_wait_any(FLAG_MASK);
|
||||
|
||||
if (flags & FLAG_ERR) {
|
||||
return RDCLI_ERR;
|
||||
return CORD_EP_ERR;
|
||||
}
|
||||
else if (flags & FLAG_TIMEOUT) {
|
||||
return RDCLI_TIMEOUT;
|
||||
return CORD_EP_TIMEOUT;
|
||||
}
|
||||
else if (flags & FLAG_OVERFLOW) {
|
||||
return RDCLI_OVERFLOW;
|
||||
return CORD_EP_OVERFLOW;
|
||||
}
|
||||
else {
|
||||
return RDCLI_OK;
|
||||
return CORD_EP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -137,13 +137,13 @@ static int _update_remove(unsigned code, gcoap_resp_handler_t handle)
|
||||
coap_pkt_t pkt;
|
||||
|
||||
if (_rd_loc[0] == 0) {
|
||||
return RDCLI_NORD;
|
||||
return CORD_EP_NORD;
|
||||
}
|
||||
|
||||
/* build CoAP request packet */
|
||||
int res = gcoap_req_init(&pkt, buf, sizeof(buf), code, _rd_loc);
|
||||
if (res < 0) {
|
||||
return RDCLI_ERR;
|
||||
return CORD_EP_ERR;
|
||||
}
|
||||
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
|
||||
ssize_t pkt_len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
|
||||
@ -158,7 +158,7 @@ static int _update_remove(unsigned code, gcoap_resp_handler_t handle)
|
||||
static void _on_discover(unsigned req_state, coap_pkt_t *pdu,
|
||||
sock_udp_ep_t *remote)
|
||||
{
|
||||
thread_flags_t flag = RDCLI_NORD;
|
||||
thread_flags_t flag = CORD_EP_NORD;
|
||||
(void)remote;
|
||||
|
||||
if (req_state == GCOAP_MEMO_RESP) {
|
||||
@ -216,19 +216,19 @@ static int _discover_internal(const sock_udp_ep_t *remote,
|
||||
int res = gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_GET,
|
||||
"/.well-known/core");
|
||||
if (res < 0) {
|
||||
return RDCLI_ERR;
|
||||
return CORD_EP_ERR;
|
||||
}
|
||||
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
|
||||
gcoap_add_qstring(&pkt, "rt", "core.rd");
|
||||
size_t pkt_len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
|
||||
res = gcoap_req_send2(buf, pkt_len, remote, _on_discover);
|
||||
if (res < 0) {
|
||||
return RDCLI_ERR;
|
||||
return CORD_EP_ERR;
|
||||
}
|
||||
return _sync();
|
||||
}
|
||||
|
||||
int rdcli_discover_regif(const sock_udp_ep_t *remote, char *regif, size_t maxlen)
|
||||
int cord_ep_discover_regif(const sock_udp_ep_t *remote, char *regif, size_t maxlen)
|
||||
{
|
||||
assert(remote && regif);
|
||||
|
||||
@ -238,7 +238,7 @@ int rdcli_discover_regif(const sock_udp_ep_t *remote, char *regif, size_t maxlen
|
||||
return res;
|
||||
}
|
||||
|
||||
int rdcli_register(const sock_udp_ep_t *remote, const char *regif)
|
||||
int cord_ep_register(const sock_udp_ep_t *remote, const char *regif)
|
||||
{
|
||||
assert(remote);
|
||||
|
||||
@ -253,13 +253,13 @@ int rdcli_register(const sock_udp_ep_t *remote, const char *regif)
|
||||
* discovery for it first (see section 5.2) */
|
||||
if (regif == NULL) {
|
||||
retval = _discover_internal(remote, _rd_regif, sizeof(_rd_regif));
|
||||
if (retval != RDCLI_OK) {
|
||||
if (retval != CORD_EP_OK) {
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen(_rd_regif) >= sizeof(_rd_regif)) {
|
||||
retval = RDCLI_OVERFLOW;
|
||||
retval = CORD_EP_OVERFLOW;
|
||||
goto end;
|
||||
}
|
||||
strncpy(_rd_regif, regif, sizeof(_rd_regif));
|
||||
@ -268,18 +268,18 @@ int rdcli_register(const sock_udp_ep_t *remote, const char *regif)
|
||||
/* build and send CoAP POST request to the RD's registration interface */
|
||||
res = gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_POST, _rd_regif);
|
||||
if (res < 0) {
|
||||
retval = RDCLI_ERR;
|
||||
retval = CORD_EP_ERR;
|
||||
goto end;
|
||||
}
|
||||
/* set some packet options and write query string */
|
||||
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
|
||||
rdcli_common_add_qstring(&pkt);
|
||||
cord_common_add_qstring(&pkt);
|
||||
|
||||
/* add the resource description as payload */
|
||||
res = gcoap_get_resource_list(pkt.payload, pkt.payload_len,
|
||||
COAP_FORMAT_LINK);
|
||||
if (res < 0) {
|
||||
retval = RDCLI_ERR;
|
||||
retval = CORD_EP_ERR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -289,19 +289,19 @@ int rdcli_register(const sock_udp_ep_t *remote, const char *regif)
|
||||
/* send out the request */
|
||||
res = gcoap_req_send2(buf, pkt_len, remote, _on_register);
|
||||
if (res < 0) {
|
||||
retval = RDCLI_ERR;
|
||||
retval = CORD_EP_ERR;
|
||||
goto end;
|
||||
}
|
||||
retval = _sync();
|
||||
|
||||
end:
|
||||
/* if we encountered any error, we mark the client as not connected */
|
||||
if (retval != RDCLI_OK) {
|
||||
/* if we encountered any error, we mark the endpoint as not connected */
|
||||
if (retval != CORD_EP_OK) {
|
||||
_rd_loc[0] = '\0';
|
||||
}
|
||||
#ifdef MODULE_RDCLI_STANDALONE
|
||||
#ifdef MODULE_CORD_EP_STANDALONE
|
||||
else {
|
||||
rdcli_standalone_signal(true);
|
||||
cord_ep_standalone_signal(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -309,14 +309,14 @@ end:
|
||||
return retval;
|
||||
}
|
||||
|
||||
int rdcli_update(void)
|
||||
int cord_ep_update(void)
|
||||
{
|
||||
_lock();
|
||||
int res = _update_remove(COAP_METHOD_POST, _on_update);
|
||||
if (res != RDCLI_OK) {
|
||||
if (res != CORD_EP_OK) {
|
||||
/* in case we are not able to reach the RD, we drop the association */
|
||||
#ifdef MODULE_RDCLI_STANDALONE
|
||||
rdcli_standalone_signal(false);
|
||||
#ifdef MODULE_CORD_EP_STANDALONE
|
||||
cord_ep_standalone_signal(false);
|
||||
#endif
|
||||
_rd_loc[0] = '\0';
|
||||
}
|
||||
@ -324,25 +324,25 @@ int rdcli_update(void)
|
||||
return res;
|
||||
}
|
||||
|
||||
int rdcli_remove(void)
|
||||
int cord_ep_remove(void)
|
||||
{
|
||||
_lock();
|
||||
if (_rd_loc[0] == '\0') {
|
||||
mutex_unlock(&_mutex);
|
||||
return RDCLI_NORD;
|
||||
return CORD_EP_NORD;
|
||||
}
|
||||
#ifdef MODULE_RDCLI_STANDALONE
|
||||
rdcli_standalone_signal(false);
|
||||
#ifdef MODULE_CORD_EP_STANDALONE
|
||||
cord_ep_standalone_signal(false);
|
||||
#endif
|
||||
_update_remove(COAP_METHOD_DELETE, _on_remove);
|
||||
/* we actually do not care about the result, we drop the RD local RD entry
|
||||
* in any case */
|
||||
_rd_loc[0] = '\0';
|
||||
mutex_unlock(&_mutex);
|
||||
return RDCLI_OK;
|
||||
return CORD_EP_OK;
|
||||
}
|
||||
|
||||
void rdcli_dump_status(void)
|
||||
void cord_ep_dump_status(void)
|
||||
{
|
||||
puts("CoAP RD connection status:");
|
||||
|
||||
@ -355,8 +355,8 @@ void rdcli_dump_status(void)
|
||||
ipv6_addr_to_str(addr, (ipv6_addr_t *)&_rd_remote.addr, sizeof(addr));
|
||||
|
||||
printf("RD address: coap://[%s]:%i\n", addr, (int)_rd_remote.port);
|
||||
printf(" ep name: %s\n", rdcli_common_get_ep());
|
||||
printf(" lifetime: %is\n", (int)RDCLI_LT);
|
||||
printf(" ep name: %s\n", cord_common_get_ep());
|
||||
printf(" lifetime: %is\n", (int)CORD_LT);
|
||||
printf(" reg if: %s\n", _rd_regif);
|
||||
printf(" location: %s\n", _rd_loc);
|
||||
}
|
||||
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_rdcli_simple
|
||||
* @ingroup net_cord_ep_standalone
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Standalone extension for the simple RD registration client
|
||||
* @brief Standalone extension for the CoRE RD endpoint implementation
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
@ -24,9 +24,9 @@
|
||||
#include "assert.h"
|
||||
#include "thread.h"
|
||||
#include "xtimer.h"
|
||||
#include "net/rdcli.h"
|
||||
#include "net/rdcli_config.h"
|
||||
#include "net/rdcli_standalone.h"
|
||||
#include "net/cord/ep.h"
|
||||
#include "net/cord/config.h"
|
||||
#include "net/cord/ep_standalone.h"
|
||||
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
@ -34,11 +34,11 @@
|
||||
/* stack configuration */
|
||||
#define STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#define PRIO (THREAD_PRIORITY_MAIN - 1)
|
||||
#define TNAME "rdcli"
|
||||
#define TNAME "cord_ep"
|
||||
|
||||
#define UPDATE_TIMEOUT (0xe537)
|
||||
|
||||
#define TIMEOUT_US ((uint64_t)(RDCLI_UPDATE_INTERVAL * US_PER_SEC))
|
||||
#define TIMEOUT_US ((uint64_t)(CORD_UPDATE_INTERVAL * US_PER_SEC))
|
||||
|
||||
static char _stack[STACKSIZE];
|
||||
|
||||
@ -46,14 +46,14 @@ static xtimer_t _timer;
|
||||
static kernel_pid_t _runner_pid;
|
||||
static msg_t _msg;
|
||||
|
||||
static rdcli_standalone_cb_t _cb = NULL;
|
||||
static cord_ep_standalone_cb_t _cb = NULL;
|
||||
|
||||
static void _set_timer(void)
|
||||
{
|
||||
xtimer_set_msg64(&_timer, TIMEOUT_US, &_msg, _runner_pid);
|
||||
}
|
||||
|
||||
static void _notify(rdcli_standalone_event_t event)
|
||||
static void _notify(cord_ep_standalone_event_t event)
|
||||
{
|
||||
if (_cb) {
|
||||
_cb(event);
|
||||
@ -70,16 +70,14 @@ static void *_reg_runner(void *arg)
|
||||
_msg.type = UPDATE_TIMEOUT;
|
||||
|
||||
while (1) {
|
||||
DEBUG("rd stand: waiting for message\n");
|
||||
msg_receive(&in);
|
||||
if (in.type == UPDATE_TIMEOUT) {
|
||||
if (rdcli_update() == RDCLI_OK) {
|
||||
DEBUG("rd stand: update ok\n");
|
||||
if (cord_ep_update() == CORD_EP_OK) {
|
||||
_set_timer();
|
||||
_notify(RDCLI_UPDATED);
|
||||
_notify(CORD_EP_UPDATED);
|
||||
}
|
||||
else {
|
||||
_notify(RDCLI_DEREGISTERED);
|
||||
_notify(CORD_EP_DEREGISTERED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,25 +85,25 @@ static void *_reg_runner(void *arg)
|
||||
return NULL; /* should never be reached */
|
||||
}
|
||||
|
||||
void rdcli_standalone_run(void)
|
||||
void cord_ep_standalone_run(void)
|
||||
{
|
||||
thread_create(_stack, sizeof(_stack), PRIO, 0, _reg_runner, NULL, TNAME);
|
||||
}
|
||||
|
||||
void rdcli_standalone_signal(bool connected)
|
||||
void cord_ep_standalone_signal(bool connected)
|
||||
{
|
||||
/* clear timer in any case */
|
||||
xtimer_remove(&_timer);
|
||||
/* reset the update timer in case a connection was established or updated */
|
||||
if (connected) {
|
||||
_set_timer();
|
||||
_notify(RDCLI_REGISTERED);
|
||||
_notify(CORD_EP_REGISTERED);
|
||||
} else {
|
||||
_notify(RDCLI_DEREGISTERED);
|
||||
_notify(CORD_EP_DEREGISTERED);
|
||||
}
|
||||
}
|
||||
|
||||
void rdcli_standalone_reg_cb(rdcli_standalone_cb_t cb)
|
||||
void cord_ep_standalone_reg_cb(cord_ep_standalone_cb_t cb)
|
||||
{
|
||||
/* Note: we do not allow re-setting the callback (via passing cb := NULL),
|
||||
* as this would mean additional complexity for synchronizing the
|
||||
9
sys/net/application_layer/cord/epsim/Makefile
Normal file
9
sys/net/application_layer/cord/epsim/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
MODULE = cord_epsim
|
||||
|
||||
SRC = cord_epsim.c
|
||||
|
||||
ifneq (,$(filter cord_epsim_standalone,$(USEMODULE)))
|
||||
SRC += cord_epsim_standalone.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -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/rdcli_config.h"
|
||||
#include "net/rdcli_common.h"
|
||||
#include "net/rdcli_simple.h"
|
||||
#include "net/cord/epsim.h"
|
||||
#include "net/cord/config.h"
|
||||
#include "net/cord/common.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
#define BUFSIZE (128U)
|
||||
@ -34,36 +33,36 @@
|
||||
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,
|
||||
.netif = SOCK_ADDR_ANY_NETIF,
|
||||
.port = RDCLI_SERVER_PORT,
|
||||
.port = CORD_SERVER_PORT,
|
||||
};
|
||||
|
||||
/* 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 (rdcli_common_add_qstring(&pkt) < 0) {
|
||||
return RDCLI_SIMPLE_ERROR;
|
||||
if (cord_common_add_qstring(&pkt) < 0) {
|
||||
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;
|
||||
}
|
||||
@ -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/rdcli_config.h"
|
||||
#include "net/rdcli_simple.h"
|
||||
#include "net/cord/epsim.h"
|
||||
#include "net/cord/config.h"
|
||||
|
||||
#define STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#define PRIO (THREAD_PRIORITY_MAIN - 1)
|
||||
#define TNAME "rdcli_simple"
|
||||
#define TNAME "cord_epsim"
|
||||
|
||||
static char _stack[STACKSIZE];
|
||||
|
||||
@ -35,22 +35,24 @@ static void *reg_runner(void *arg)
|
||||
(void)arg;
|
||||
|
||||
/* wait some seconds to give the address configuration some time to settle */
|
||||
xtimer_sleep(RDCLI_STARTUP_DELAY);
|
||||
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(RDCLI_UPDATE_INTERVAL);
|
||||
xtimer_sleep(CORD_UPDATE_INTERVAL);
|
||||
}
|
||||
|
||||
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
|
||||
@ -1,7 +0,0 @@
|
||||
SRC = rdcli.c
|
||||
|
||||
ifneq (,$(filter rdcli_standalone,$(USEMODULE)))
|
||||
SRC += rdcli_standalone.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -1,7 +0,0 @@
|
||||
SRC = rdcli_simple.c
|
||||
|
||||
ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE)))
|
||||
SRC += rdcli_simple_standalone.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -66,8 +66,8 @@ endif
|
||||
ifneq (,$(filter conn_can,$(USEMODULE)))
|
||||
SRC += sc_can.c
|
||||
endif
|
||||
ifneq (,$(filter rdcli,$(USEMODULE)))
|
||||
SRC += sc_rdcli.c
|
||||
ifneq (,$(filter cord_ep,$(USEMODULE)))
|
||||
SRC += sc_cord_ep.c
|
||||
endif
|
||||
|
||||
ifneq (,$(filter periph_rtc,$(FEATURES_PROVIDED)))
|
||||
|
||||
@ -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
|
||||
@ -11,7 +11,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Shell commands for the rdcli module
|
||||
* @brief Shell commands for the cord_ep module
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
@ -21,11 +21,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "net/rdcli.h"
|
||||
#include "net/cord/ep.h"
|
||||
#include "net/nanocoap.h"
|
||||
#include "net/sock/util.h"
|
||||
#include "net/rdcli_config.h"
|
||||
#include "net/rdcli_common.h"
|
||||
#include "net/cord/config.h"
|
||||
|
||||
static int make_sock_ep(sock_udp_ep_t *ep, const char *addr)
|
||||
{
|
||||
@ -36,12 +35,12 @@ static int make_sock_ep(sock_udp_ep_t *ep, const char *addr)
|
||||
ep->family = AF_INET6;
|
||||
ep->netif = SOCK_ADDR_ANY_NETIF;
|
||||
if (ep->port == 0) {
|
||||
ep->port = RDCLI_SERVER_PORT;
|
||||
ep->port = CORD_SERVER_PORT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _rdcli_handler(int argc, char **argv)
|
||||
int _cord_ep_handler(int argc, char **argv)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -61,12 +60,12 @@ int _rdcli_handler(int argc, char **argv)
|
||||
regif = argv[3];
|
||||
}
|
||||
puts("Registering with RD now, this may take a short while...");
|
||||
if (rdcli_register(&remote, regif) != RDCLI_OK) {
|
||||
if (cord_ep_register(&remote, regif) != CORD_EP_OK) {
|
||||
puts("error: registration failed");
|
||||
}
|
||||
else {
|
||||
puts("registration successful\n");
|
||||
rdcli_dump_status();
|
||||
cord_ep_dump_status();
|
||||
}
|
||||
}
|
||||
else if ((argc > 1) && (strcmp(argv[1], "discover") == 0)) {
|
||||
@ -80,7 +79,7 @@ int _rdcli_handler(int argc, char **argv)
|
||||
printf("error: unable to parse address\n");
|
||||
return 1;
|
||||
}
|
||||
if (rdcli_discover_regif(&remote, regif, sizeof(regif)) == RDCLI_OK) {
|
||||
if (cord_ep_discover_regif(&remote, regif, sizeof(regif)) == CORD_EP_OK) {
|
||||
printf("the registration interface is '%s'\n", regif);
|
||||
}
|
||||
else {
|
||||
@ -88,14 +87,14 @@ int _rdcli_handler(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
else if ((argc > 1) && (strcmp(argv[1], "update") == 0)) {
|
||||
res = rdcli_update();
|
||||
if (res == RDCLI_OK) {
|
||||
res = cord_ep_update();
|
||||
if (res == CORD_EP_OK) {
|
||||
puts("RD update successful");
|
||||
}
|
||||
else if (res == RDCLI_NORD) {
|
||||
else if (res == CORD_EP_NORD) {
|
||||
puts("error: not associated with any RD");
|
||||
}
|
||||
else if (res == RDCLI_TIMEOUT) {
|
||||
else if (res == CORD_EP_TIMEOUT) {
|
||||
puts("error: unable to reach RD - dropped association");
|
||||
}
|
||||
else {
|
||||
@ -103,14 +102,14 @@ int _rdcli_handler(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
else if ((argc > 1) && (strcmp(argv[1], "remove") == 0)) {
|
||||
res = rdcli_remove();
|
||||
if (res == RDCLI_OK) {
|
||||
res = cord_ep_remove();
|
||||
if (res == CORD_EP_OK) {
|
||||
puts("node successfully removed from RD");
|
||||
}
|
||||
else if (res == RDCLI_NORD) {
|
||||
else if (res == CORD_EP_NORD) {
|
||||
puts("error: not associated with any RD");
|
||||
}
|
||||
else if (res == RDCLI_TIMEOUT) {
|
||||
else if (res == CORD_EP_TIMEOUT) {
|
||||
puts("error: unable to reach RD - remove association only locally");
|
||||
}
|
||||
else {
|
||||
@ -118,7 +117,7 @@ int _rdcli_handler(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
else if ((argc > 1) && (strcmp(argv[1], "info") == 0)) {
|
||||
rdcli_dump_status();
|
||||
cord_ep_dump_status();
|
||||
}
|
||||
else {
|
||||
printf("usage: %s <register|discover|update|remove|info>\n",
|
||||
@ -142,8 +142,8 @@ extern int _ls_handler(int argc, char **argv);
|
||||
extern int _can_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_RDCLI
|
||||
extern int _rdcli_handler(int argc, char **argv);
|
||||
#ifdef MODULE_CORD_EP
|
||||
extern int _cord_ep_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
const shell_command_t _shell_command_list[] = {
|
||||
@ -237,8 +237,8 @@ const shell_command_t _shell_command_list[] = {
|
||||
#ifdef MODULE_CONN_CAN
|
||||
{"can", "CAN commands", _can_handler},
|
||||
#endif
|
||||
#ifdef MODULE_RDCLI
|
||||
{"rdcli", "CoAP RD client commands", _rdcli_handler },
|
||||
#ifdef MODULE_CORD_EP
|
||||
{"cord_ep", "Resource directory endpoint commands", _cord_ep_handler },
|
||||
#endif
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user