From bc1bf38c85aa63e552e4f4486992e83727be51b6 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 5 Aug 2020 17:13:38 +0200 Subject: [PATCH 01/14] pkg/openwsn: add openwsn_sock_udp module --- pkg/openwsn/Makefile | 5 +- pkg/openwsn/Makefile.dep | 18 + pkg/openwsn/Makefile.include | 14 + ...-openstack-04-TRAN-add-blocking-sock.patch | 563 ++++++++++++++++++ sys/Makefile.dep | 7 +- 5 files changed, 605 insertions(+), 2 deletions(-) create mode 100644 pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch diff --git a/pkg/openwsn/Makefile b/pkg/openwsn/Makefile index 953c5c3e9c43..8a1cdba12eb1 100644 --- a/pkg/openwsn/Makefile +++ b/pkg/openwsn/Makefile @@ -1,6 +1,6 @@ PKG_NAME=openwsn PKG_URL=https://github.com/openwsn-berkeley/openwsn-fw.git -PKG_VERSION=028db872c0c60f756e16880a0c86d6282e421c71 +PKG_VERSION=a49f5a34304daa8c013772ca1705f3d7da1e1514 PKG_LICENSE=BSD-3-Clause include $(RIOTBASE)/pkg/pkg.mk @@ -13,6 +13,9 @@ IGNORE_MODULES := openwsn_leds \ openwsn_iee802154e_security \ openwsn_radio \ openwsn_riotos \ + openwsn_sock_udp \ + openwsn_sock \ + openwsn_sock_async \ openwsn_serial \ openwsn_sctimer \ openwsn_sctimer_rtt \ diff --git a/pkg/openwsn/Makefile.dep b/pkg/openwsn/Makefile.dep index 4eadbd0246d8..dd32316e4858 100644 --- a/pkg/openwsn/Makefile.dep +++ b/pkg/openwsn/Makefile.dep @@ -43,6 +43,10 @@ ifneq (,$(filter openwsn_cjoin,$(USEMODULE))) USEMODULE += openwsn_crypto endif +ifneq (,$(filter openwsn_opencoap,$(USEMODULE))) + USEMODULE += openwsn_sock_async +endif + ifneq (,$(filter openwsn_crypto,$(USEMODULE))) USEMODULE += crypto_3des USEMODULE += cipher_modes @@ -99,5 +103,19 @@ ifneq (,$(filter openwsn_debugpins,$(USEMODULE))) FEATURES_REQUIRED += periph_gpio_irq endif +ifneq (,$(filter sock_udp,$(USEMODULE))) + USEMODULE += openwsn_sock_udp +endif + +ifneq (,$(filter openwsn_sock%,$(USEMODULE))) + USEMODULE += openwsn_sock + USEMODULE += core_mbox + USEMODULE += ztimer_usec +endif + +ifneq (,$(filter openwsn_sock_async,$(USEMODULE))) + USEMODULE += sock_async +endif + # This port currently requires setting ISR_STACKSIZE FEATURES_BLACKLIST += arch_esp32 arch_esp8266 arch_riscv arch_avr8 diff --git a/pkg/openwsn/Makefile.include b/pkg/openwsn/Makefile.include index 471d9bb67b48..517ce7d6a3b6 100644 --- a/pkg/openwsn/Makefile.include +++ b/pkg/openwsn/Makefile.include @@ -4,6 +4,9 @@ PSEUDOMODULES += openwsn_serial \ openwsn_icmpv6_echo \ openwsn_iee802154e_security \ openwsn_leds \ + openwsn_sock \ + openwsn_sock_async \ + openwsn_sock_udp \ openwsn_scheduler \ openwsn_sctimer \ openwsn_sctimer_rtt \ @@ -72,6 +75,17 @@ ifneq (,$(filter openwsn_adaptive_msf,$(USEMODULE))) CFLAGS += -DOPENWSN_ADAPTIVE_MSF endif +ifneq (,$(filter openwsn_sock%,$(USEMODULE))) + CFLAGS += -DSOCK_HAS_IPV6 + ifneq (,$(filter openwsn_sock_async,$(USEMODULE))) + CFLAGS += -DSOCK_HAS_ASYNC + endif + ifneq (,$(filter sock_async_event,$(USEMODULE))) + # Needed only if using event and not simple callbacks + CFLAGS += -DSOCK_HAS_ASYNC_CTX + endif +endif + # In OpenWSN the ISR stack is shared with the network stack. OpenWSN stack is # 2Kb, this means that the ISR stack in OpenWSN might have up to 2Kb available. # To keep the same marging increase the ISR stack to 2Kb as well. In practice diff --git a/pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch b/pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch new file mode 100644 index 000000000000..bda4bffc5075 --- /dev/null +++ b/pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch @@ -0,0 +1,563 @@ +From 2cfcbafc9b2d00f7e47873e96027611c0fde8f99 Mon Sep 17 00:00:00 2001 +From: Francisco Molina +Date: Fri, 21 Aug 2020 09:11:48 +0200 +Subject: [PATCH 10/10] openstack/04-TRAN: add blocking sock + +--- + inc/opendefs.h | 3 +- + kernel/scheduler.h | 2 +- + openapps/uecho/uecho.c | 9 +- + .../uexpiration_monitor/uexpiration_monitor.c | 9 +- + openapps/uinject/uinject.c | 9 +- + openstack/04-TRAN/sock.c | 194 ++++++++++++++---- + openstack/04-TRAN/sock.h | 3 + + openstack/04-TRAN/sock_types.h | 31 ++- + openstack/openstack.c | 6 +- + openweb/opencoap/coap.h | 10 +- + 10 files changed, 220 insertions(+), 56 deletions(-) + +diff --git a/inc/opendefs.h b/inc/opendefs.h +index 29076b5c..6a263ca0 100644 +--- a/inc/opendefs.h ++++ b/inc/opendefs.h +@@ -17,7 +17,8 @@ + #include "config.h" + #include "toolchain_defs.h" + #include "board_info.h" +-#include "af.h" ++#include "net/af.h" ++// #include "af.h" + + + //=========================== define ========================================== +diff --git a/kernel/scheduler.h b/kernel/scheduler.h +index 5ef302a3..51b6d9cb 100644 +--- a/kernel/scheduler.h ++++ b/kernel/scheduler.h +@@ -55,7 +55,7 @@ uint8_t scheduler_debug_get_TasksCur(void); + uint8_t scheduler_debug_get_TasksMax(void); + #endif + +-#include "openos/scheduler_types.h" ++#include "scheduler_types.h" + + /** + \} +diff --git a/openapps/uecho/uecho.c b/openapps/uecho/uecho.c +index 4c4a6ec8..036ccfa3 100644 +--- a/openapps/uecho/uecho.c ++++ b/openapps/uecho/uecho.c +@@ -4,12 +4,17 @@ + + #include "opendefs.h" + #include "uecho.h" +-#include "sock.h" +-#include "async.h" ++// #include "sock.h" ++// #include "async.h" + #include "openqueue.h" + #include "openserial.h" + #include "packetfunctions.h" + ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" ++ + //=========================== variables ======================================= + + sock_udp_t uecho_sock; +diff --git a/openapps/uexpiration_monitor/uexpiration_monitor.c b/openapps/uexpiration_monitor/uexpiration_monitor.c +index 37155c25..c67e31dd 100644 +--- a/openapps/uexpiration_monitor/uexpiration_monitor.c ++++ b/openapps/uexpiration_monitor/uexpiration_monitor.c +@@ -4,8 +4,8 @@ + + #include "opendefs.h" + #include "uexpiration_monitor.h" +-#include "sock.h" +-#include "async.h" ++// #include "sock.h" ++// #include "async.h" + #include "openserial.h" + #include "packetfunctions.h" + +@@ -13,6 +13,11 @@ + #include "iphc.h" + #endif + ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" ++ + //=========================== variables ======================================= + + static sock_udp_t _sock; +diff --git a/openapps/uinject/uinject.c b/openapps/uinject/uinject.c +index 499d6633..08d9bbe6 100644 +--- a/openapps/uinject/uinject.c ++++ b/openapps/uinject/uinject.c +@@ -4,8 +4,8 @@ + + #include "opendefs.h" + #include "uinject.h" +-#include "sock.h" +-#include "async.h" ++// #include "sock.h" ++// #include "async.h" + #include "openserial.h" + #include "packetfunctions.h" + #include "scheduler.h" +@@ -15,6 +15,11 @@ + #include "idmanager.h" + #include "openrandom.h" + ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" ++ + #include "msf.h" + + //=========================== defines ========================================= +diff --git a/openstack/04-TRAN/sock.c b/openstack/04-TRAN/sock.c +index 689a4cb2..0f0d39c2 100644 +--- a/openstack/04-TRAN/sock.c ++++ b/openstack/04-TRAN/sock.c +@@ -3,8 +3,8 @@ + #if defined(OPENWSN_UDP_C) + + #include "opendefs.h" +-#include "sock.h" +-#include "af.h" ++#include "opentimers.h" ++// #include "sock.h" + #include "errno.h" + #include "packetfunctions.h" + #include "openqueue.h" +@@ -14,12 +14,30 @@ + #include "scheduler.h" + #include "openserial.h" + +-// ============================ defines ======================================== ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" ++#include "openwsn_log.h" ++#ifdef MODULE_ZTIMER ++#include "ztimer.h" ++#endif /* MODULE_ZTIMER */ ++ ++//============================ defines ======================================== ++ ++#ifdef MODULE_OPENWSN ++#define _MSG_TYPE_RECV_PKT (0x1601) ++#ifdef MODULE_ZTIMER ++#define _TIMEOUT_MAGIC (0xF38A0B63U) ++#define _TIMEOUT_MSG_TYPE (0x8474) ++#endif /* MODULE_ZTIMER */ ++#endif /* MODULE_OPENWSN */ + +-sock_udp_t* udp_socket_list; ++//=========================== variables ======================================= + +-// =========================== variables ======================================= +-// =========================== prototypes ====================================== ++static sock_udp_t *_udp_socket_list; ++ ++//=========================== prototypes ====================================== + + static bool _sock_valid_af(uint8_t af); + +@@ -29,10 +47,14 @@ static void _sock_get_local_addr(open_addr_t* local); + + static void _sock_transmit_internal(void); + ++#ifdef MODULE_ZTIMER ++static void _timeout_cb(void *arg); ++#endif ++ + // ============================= public ======================================== + + void sock_udp_init(void) { +- udp_socket_list = NULL; ++ _udp_socket_list = NULL; + } + + int sock_udp_create(sock_udp_t* sock, const sock_udp_ep_t* local, const sock_udp_ep_t* remote, uint16_t flags) { +@@ -42,10 +64,14 @@ int sock_udp_create(sock_udp_t* sock, const sock_udp_ep_t* local, const sock_udp + return -EINVAL; + } + ++#ifdef MODULE_OPENWSN ++ mbox_init(&sock->mbox, sock->mbox_queue, OPENWSN_SOCK_MBOX_SIZE); ++#endif ++ + memset(&sock->gen_sock.local, 0, sizeof(sock_udp_ep_t)); + + if (local != NULL) { +- current = udp_socket_list; ++ current = _udp_socket_list; + + while (current != NULL) { + if (current->gen_sock.local.port == local->port) { +@@ -73,10 +99,13 @@ int sock_udp_create(sock_udp_t* sock, const sock_udp_ep_t* local, const sock_udp + } + + sock->gen_sock.flags = flags; ++ ++#ifdef SOCK_HAS_ASYNC + sock->async_cb = NULL; ++#endif + +- sock->next = udp_socket_list; +- udp_socket_list = sock; ++ sock->next = _udp_socket_list; ++ _udp_socket_list = sock; + + return 0; + } +@@ -144,21 +173,21 @@ int sock_udp_send(sock_udp_t* sock, const void* data, size_t len, const sock_udp + + memcpy(pkt->payload, data, len); + +- scheduler_push_task(_sock_transmit_internal, TASKPRIO_UDP); +- + pkt->l4_payload = pkt->payload; + pkt->l4_length = pkt->length; + ++ scheduler_push_task(_sock_transmit_internal, TASKPRIO_UDP); ++ + return len; + } + + void sock_udp_close(sock_udp_t* sock) { +- sock_udp_t* temp = udp_socket_list; +- sock_udp_t* prev = udp_socket_list; ++ sock_udp_t* temp = _udp_socket_list; ++ sock_udp_t* prev = _udp_socket_list; + + /* check if head is the socket to be closed */ + if (temp != NULL && temp == sock) { +- udp_socket_list = temp->next; ++ _udp_socket_list = temp->next; + + return; + } +@@ -201,28 +230,69 @@ int sock_udp_get_remote(sock_udp_t* sock, sock_udp_ep_t* ep) { + int sock_udp_recv(sock_udp_t* sock, void* data, size_t max_len, uint32_t timeout, sock_udp_ep_t* remote) { + uint16_t bytes_to_copy; + sock_udp_ep_t ep; ++ OpenQueueEntry_t *pkt = NULL; ++ ++#ifdef MODULE_OPENWSN ++ msg_t msg; ++#ifdef MODULE_ZTIMER ++ ztimer_t timer; ++ ++ if ((timeout != SOCK_NO_TIMEOUT) && (timeout != 0)) { ++ timer.callback = _timeout_cb; ++ timer.arg = &sock->mbox; ++ ztimer_set(ZTIMER_USEC, &timer, timeout); ++ } ++#endif /* MODULE_ZTIMER */ ++ if (timeout != 0) { ++ mbox_get(&sock->mbox, &msg); ++ } ++ else { ++ if (!mbox_try_get(&sock->mbox, &msg)) { ++ return -EAGAIN; ++ } ++ } ++#ifdef MODULE_ZTIMER ++ ztimer_remove(ZTIMER_USEC, &timer); ++#endif /* MODULE_ZTIMER */ ++ switch (msg.type) { ++ case _MSG_TYPE_RECV_PKT: ++ pkt = msg.content.ptr; ++ break; ++#ifdef MODULE_ZTIMER ++ case _TIMEOUT_MSG_TYPE: ++ if (msg.content.value == _TIMEOUT_MAGIC) { ++ return -ETIMEDOUT; ++ } ++#endif /* MODULE_ZTIMER */ ++ /* Falls Through. */ ++ default: ++ return -EINVAL; ++ } ++#else /* MODULE_OPENWSN */ ++ pkt = sock->txrx; ++#endif /* MODULE_OPENWSN */ + +- if (sock->txrx == NULL) { ++ if (pkt == NULL) { + return -EINVAL; + } + +- if (max_len >= sock->txrx->l4_length) { +- bytes_to_copy = sock->txrx->l4_length; ++ if (max_len >= pkt->l4_length) { ++ bytes_to_copy = pkt->l4_length; + } else { + bytes_to_copy = max_len; + } + + if (remote != NULL) { + ep.family = AF_INET6; +- ep.port = sock->txrx->l4_sourcePortORicmpv6Type; +- memcpy(&ep.addr, sock->txrx->l3_sourceAdd.addr_128b, LENGTH_ADDR128b); ++ ep.port = pkt->l4_sourcePortORicmpv6Type; ++ memcpy(&ep.addr, pkt->l3_sourceAdd.addr_128b, LENGTH_ADDR128b); + memcpy(remote, &ep, sizeof(sock_udp_ep_t)); + } + + memset(data, 0, max_len); +- memcpy(data, sock->txrx->l4_payload, bytes_to_copy); ++ memcpy(data, pkt->l4_payload, bytes_to_copy); + +- openqueue_freePacketBuffer(sock->txrx); ++ openqueue_freePacketBuffer(pkt); + + return bytes_to_copy; + } +@@ -239,16 +309,26 @@ void sock_receive_internal(void) { + return; + } + +- current = udp_socket_list; +- ++ current = _udp_socket_list; + while (current != NULL) { + if (current->gen_sock.local.port == pkt->l4_destination_port && +- current->async_cb != NULL && +- idmanager_isMyAddress(&pkt->l3_destinationAdd)) +- { +- ++ idmanager_isMyAddress(&pkt->l3_destinationAdd)) { ++#ifdef MODULE_OPENWSN ++ msg_t msg; ++ msg.type = _MSG_TYPE_RECV_PKT; ++ msg.content.ptr = pkt; ++ int ret = mbox_try_put(¤t->mbox, &msg); ++ if (ret < 1) { ++ LOG_RIOT_DEBUG("openwsn_sock: dropped message to %p (was full)\n", (void*) ¤t->mbox); ++ } ++#else /* MODULE_OPENWSN */ + current->txrx = pkt; +- current->async_cb(current, SOCK_ASYNC_MSG_RECV, NULL); ++#endif /* MODULE_OPENWSN */ ++#ifdef SOCK_HAS_ASYNC ++ if (current->async_cb != NULL) { ++ current->async_cb(current, SOCK_ASYNC_MSG_RECV, NULL); ++ } ++#endif /* SOCK_HAS_ASYNC */ + break; + } + +@@ -262,8 +342,9 @@ void sock_receive_internal(void) { + } + + void sock_senddone_internal(OpenQueueEntry_t* msg, owerror_t error) { +- OpenQueueEntry_t* pkt; +- sock_udp_t* current; ++#ifdef SOCK_HAS_ASYNC ++ OpenQueueEntry_t *pkt; ++ sock_udp_t *current; + + pkt = openqueue_getPacketByComponent(COMPONENT_UDP); + +@@ -273,30 +354,46 @@ void sock_senddone_internal(OpenQueueEntry_t* msg, owerror_t error) { + return; + } + +- current = udp_socket_list; ++ current = _udp_socket_list; + + while (current != NULL) { + if (current->gen_sock.local.port == pkt->l4_sourcePortORicmpv6Type && +- current->async_cb != NULL) +- { ++ current->async_cb != NULL ) { ++#ifdef MODULE_OPENWSN ++ /* In RIOT we can't know what message was sent... */ ++#else + current->txrx = pkt; ++#endif /* MODULE_OPENWSN */ + current->async_cb(current, SOCK_ASYNC_MSG_SENT, &error); + break; + } + + current = current->next; + } +-} +- +-void sock_udp_set_cb(sock_udp_t* sock, sock_udp_cb_t cb, void* cb_arg) { +- sock->async_cb = cb; +- sock->async_cb_arg = cb_arg; ++#else /* SOCK_HAS_ASYNC */ ++ (void) msg; ++ (void) error; ++#endif /*SOCK_HAS_ASYNC */ + } + + // ============================= private ======================================= + +-void _sock_transmit_internal(void) { +- OpenQueueEntry_t* pkt; ++#ifdef MODULE_ZTIMER ++static void _timeout_cb(void *arg) ++{ ++ msg_t timeout_msg = { .sender_pid = KERNEL_PID_UNDEF, ++ .type = _TIMEOUT_MSG_TYPE, ++ .content = { .value = _TIMEOUT_MAGIC } }; ++ mbox_t *mbox = arg; ++ ++ /* should be safe, because otherwise if mbox were filled this callback is ++ * senseless */ ++ mbox_try_put(mbox, &timeout_msg); ++} ++#endif /* MODULE_ZTIMER */ ++ ++static void _sock_transmit_internal(void) { ++ OpenQueueEntry_t *pkt; + + pkt = openqueue_getPacketByComponent(COMPONENT_SOCK_TO_UDP); + +@@ -347,4 +444,19 @@ static bool _sock_valid_addr(sock_udp_ep_t* ep) { + return TRUE; + } + ++#ifdef SOCK_HAS_ASYNC ++void sock_udp_set_cb(sock_udp_t *sock, sock_udp_cb_t cb, void *cb_arg) ++{ ++ sock->async_cb = cb; ++ sock->async_cb_arg = cb_arg; ++} ++ ++#ifdef SOCK_HAS_ASYNC_CTX ++sock_async_ctx_t *sock_udp_get_async_ctx(sock_udp_t *sock) ++{ ++ return &sock->async_ctx; ++} ++#endif /* SOCK_HAS_ASYNC_CTX*/ ++#endif /* SOCK_HAS_ASYNC */ ++ + #endif +diff --git a/openstack/04-TRAN/sock.h b/openstack/04-TRAN/sock.h +index 8eb6a79d..f8fbdf6d 100644 +--- a/openstack/04-TRAN/sock.h ++++ b/openstack/04-TRAN/sock.h +@@ -2,7 +2,10 @@ + #define OPENWSN_SOCK_H + + #include "opendefs.h" ++ ++#ifdef SOCK_HAS_ASYNC + #include "async_types.h" ++#endif + + /** + * @brief A Common IP-based transport layer endpoint +diff --git a/openstack/04-TRAN/sock_types.h b/openstack/04-TRAN/sock_types.h +index 9d6bb0ef..9d7d79f1 100644 +--- a/openstack/04-TRAN/sock_types.h ++++ b/openstack/04-TRAN/sock_types.h +@@ -1,7 +1,22 @@ + #ifndef OPENWSN_SOCK_TYPES_H + #define OPENWSN_SOCK_TYPES_H + +-#include "sock.h" ++// #include "sock.h" ++ ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" ++#include "opendefs.h" ++#include "mbox.h" ++ ++#ifndef CONFIG_OPENWSN_SOCK_MBOX_SIZE_EXP ++#define CONFIG_OPENWSN_SOCK_MBOX_SIZE_EXP (3) ++#endif ++ ++#ifndef OPENWSN_SOCK_MBOX_SIZE ++#define OPENWSN_SOCK_MBOX_SIZE (1 << CONFIG_OPENWSN_SOCK_MBOX_SIZE_EXP) ++#endif + + struct _socket { + sock_udp_ep_t local; /**< local end-point */ +@@ -12,10 +27,20 @@ struct _socket { + typedef struct _socket socket_t; + + struct sock_udp { +- socket_t gen_sock; /**< Generic socket */ ++#ifdef MODULE_SOCK_ASYNC_EVENT ++ sock_async_ctx_t async_ctx; /**< asynchronous event context */ ++#endif ++#ifdef SOCK_HAS_ASYNC + sock_udp_cb_t async_cb; /**< asynchronous callback */ +- OpenQueueEntry_t* txrx; + void* async_cb_arg; ++#endif ++#ifdef MODULE_OPENWSN ++ mbox_t mbox; /**< @ref core_mbox target for the sock */ ++ msg_t mbox_queue[OPENWSN_SOCK_MBOX_SIZE]; /**< queue for gnrc_sock_reg_t::mbox */ ++#else /* MODULE_OPENWSN */ ++ OpenQueueEntry_t* txrx; ++#endif /* MODULE_OPENWSN */ ++ socket_t gen_sock; /**< Generic socket */ + struct sock_udp *next; + }; + +diff --git a/openstack/openstack.c b/openstack/openstack.c +index c220b8ff..6223ee52 100644 +--- a/openstack/openstack.c ++++ b/openstack/openstack.c +@@ -34,7 +34,11 @@ + #include "icmpv6echo.h" + #include "icmpv6rpl.h" + //-- 04-TRAN +-#include "sock.h" ++// #include "sock.h" ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" + + //===== application-layer + #include "openweb.h" +diff --git a/openweb/opencoap/coap.h b/openweb/opencoap/coap.h +index c7305a4e..924d4814 100644 +--- a/openweb/opencoap/coap.h ++++ b/openweb/opencoap/coap.h +@@ -9,9 +9,13 @@ + */ + + #include "config.h" +-#include "sock.h" +-#include "async.h" ++// #include "sock.h" ++// #include "async.h" + ++#ifdef SOCK_HAS_ASYNC ++#include "net/sock/async.h" ++#endif ++#include "net/sock/udp.h" + //=========================== define ========================================== + + // IPv6 addresses of servers on the Internet +@@ -166,7 +170,7 @@ typedef struct { + uint8_t commonIV[AES_CCM_16_64_128_IV_LEN]; + uint8_t idContext[OSCOAP_MAX_ID_LEN]; + uint8_t idContextLen; +- // sender context ++ // sender context + uint8_t senderID[OSCOAP_MAX_ID_LEN]; + uint8_t senderIDLen; + uint8_t senderKey[AES_CCM_16_64_128_KEY_LEN]; +-- +2.28.0 + diff --git a/sys/Makefile.dep b/sys/Makefile.dep index e96a15b89b58..93b21f415f73 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -805,12 +805,17 @@ endif ifneq (,$(filter gcoap,$(USEMODULE))) USEMODULE += nanocoap - USEMODULE += sock_async USEMODULE += sock_async_event USEMODULE += sock_udp USEMODULE += sock_util USEMODULE += event_callback USEMODULE += event_timeout +ifneq (,$(filter gnrc%,$(USEMODULE))) + USEMODULE += gnrc_sock_async +endif +ifneq (,$(filter openwsn%,$(USEMODULE))) + USEMODULE += openwsn_sock_udp +endif endif ifneq (,$(filter luid,$(USEMODULE))) From 41d34144e92c53929456403ddd402494410650cf Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 7 Aug 2020 16:02:57 +0200 Subject: [PATCH 02/14] sys/shell/commands/sc_openwsn: update components --- sys/shell/commands/sc_openwsn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/shell/commands/sc_openwsn.c b/sys/shell/commands/sc_openwsn.c index 70841af929a0..37c67c49d334 100644 --- a/sys/shell/commands/sc_openwsn.c +++ b/sys/shell/commands/sc_openwsn.c @@ -72,7 +72,9 @@ static const struct { { "icmpv6echo", COMPONENT_ICMPv6ECHO }, { "icmpv6router", COMPONENT_ICMPv6ROUTER }, { "icmpv6rpl", COMPONENT_ICMPv6RPL }, - { "udp", COMPONENT_OPENUDP }, + { "udp", COMPONENT_UDP }, + { "sock-udp", COMPONENT_SOCK_TO_UDP }, + { "udp-sock", COMPONENT_UDP_TO_SOCK }, { "coap", COMPONENT_OPENCOAP }, { "cjoin", COMPONENT_CJOIN }, { "oscore", COMPONENT_OSCORE }, From afeeb5b56511c63419863e091d3d2896e557e976 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 7 Aug 2020 16:03:10 +0200 Subject: [PATCH 03/14] tests/pkg_openwsn: adapt to sock api --- tests/pkg_openwsn/Makefile | 4 +- tests/pkg_openwsn/main.c | 35 +--------- tests/pkg_openwsn/udp.c | 140 +++++++++++++++++++++---------------- 3 files changed, 83 insertions(+), 96 deletions(-) diff --git a/tests/pkg_openwsn/Makefile b/tests/pkg_openwsn/Makefile index b81ad1463cca..2cfdc031b82b 100644 --- a/tests/pkg_openwsn/Makefile +++ b/tests/pkg_openwsn/Makefile @@ -34,6 +34,7 @@ BOARD_WHITELIST = \ # OpenWSN Modules USEPKG += openwsn USEMODULE += openwsn_openstack +USEMODULE += sock_udp # Optional OpenWSN Modules ## Enable Constrained Join Protocol (CoJP) @@ -43,7 +44,7 @@ USEMODULE += openwsn_6lo_frag ## Enable link layer security # USEMODULE += openwsn_iee802154e_security ## Enable MSF dynamic slot allocation -# USEMODULE += openwsn_adaptive_msf +# USEMODULE += openwsn_adaptive_msf ## Optional Module, but required for root nodes # USEMODULE += openwsn_serial @@ -80,6 +81,7 @@ USEMODULE += ps USEMODULE += od_string USEMODULE += shell USEMODULE += shell_commands + # ztimer is used instead of xtimer because it's a dependency of some # OpenWSN modules. USEMODULE += ztimer_usec diff --git a/tests/pkg_openwsn/main.c b/tests/pkg_openwsn/main.c index 42ea781d05aa..2597279214c9 100644 --- a/tests/pkg_openwsn/main.c +++ b/tests/pkg_openwsn/main.c @@ -21,41 +21,10 @@ #include #include -#include "od.h" #include "shell.h" -#include "opendefs.h" -#include "04-TRAN/udp.h" -#include "cross-layers/openqueue.h" - -udp_resource_desc_t uinject_vars; - -void uinject_sendDone(OpenQueueEntry_t *msg, owerror_t error) -{ - (void)error; - - printf("msg.l2_sendDoneError: %x\n", msg->l2_sendDoneError); - openqueue_freePacketBuffer(msg); - puts("Send success"); -} - -void uinject_receive(OpenQueueEntry_t *pkt) -{ - printf("Received %i bytes on port %i\n", (int)pkt->length, - pkt->l4_destination_port); - od_hex_dump(pkt->payload, pkt->length, OD_WIDTH_DEFAULT); - openqueue_freePacketBuffer(pkt); -} - -void uinject_init(void) -{ - uinject_vars.port = WKP_UDP_INJECT; - uinject_vars.callbackReceive = &uinject_receive; - uinject_vars.callbackSendDone = &uinject_sendDone; - openudp_register(&uinject_vars); -} - extern int udp_cmd(int argc, char **argv); +extern void udp_cli_init(void); static const shell_command_t shell_commands[] = { { "udp", "Send data over UDP and listen on UDP ports", udp_cmd }, @@ -69,7 +38,7 @@ int main(void) printf("You are running RIOT on a(n) %s board.\n", RIOT_BOARD); printf("This board features a(n) %s MCU.\n", RIOT_MCU); - uinject_init(); + udp_cli_init(); char line_buf[SHELL_DEFAULT_BUFSIZE]; shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); diff --git a/tests/pkg_openwsn/udp.c b/tests/pkg_openwsn/udp.c index c54e40d829dc..8b45007496ad 100644 --- a/tests/pkg_openwsn/udp.c +++ b/tests/pkg_openwsn/udp.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2015 Freie Universität Berlin * Copyright (C) 2018 Hamburg University of Applied Sciences + * Copyright (C) 2020 Inria * * 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 @@ -15,6 +16,7 @@ * * @author Martine Lenders * @author Peter Kietzmann + * @author Francisco Molina * @} */ @@ -25,32 +27,63 @@ #include "ztimer.h" #include "net/ipv6.h" +#include "net/sock/udp.h" +#include "od.h" #include "opendefs.h" -#include "scheduler.h" #include "02a-MAClow/IEEE802154E.h" #include "03b-IPv6/icmpv6rpl.h" -#include "04-TRAN/udp.h" -#include "cross-layers/openqueue.h" + #include "cross-layers/idmanager.h" #include "cross-layers/packetfunctions.h" -extern udp_resource_desc_t uinject_vars; extern idmanager_vars_t idmanager_vars; -extern openudp_vars_t openudp_vars; -static uint16_t counter = 0; +static sock_udp_t _sock_udp; + +void _sock_udp_handler(sock_udp_t *sock, sock_async_flags_t type, void *arg) +{ + char buf[50]; + + if (type & SOCK_ASYNC_MSG_RECV) { + sock_udp_ep_t remote; + int16_t res; + + if ((res = sock_udp_recv(sock, buf, sizeof(buf), 0, &remote)) >= 0) { + printf("Received %i bytes on port %i\n", res, remote.port); + od_hex_dump(buf, res, OD_WIDTH_DEFAULT); + } + } + + if (type & SOCK_ASYNC_MSG_SENT) { + if (*((uint8_t *)arg) == E_FAIL) { + puts("Failed to Send"); + } + else { + puts("Send Success"); + } + } +} + +void udp_cli_init(void) +{ + memset(&_sock_udp, 0, sizeof(sock_udp_t)); + sock_udp_ep_t local; -OpenQueueEntry_t *pkt; + local.family = AF_INET6; + local.netif = SOCK_ADDR_ANY_NETIF; + local.port = WKP_UDP_ECHO; -void push_pkt_cb(void){ - owerror_t ret = openudp_send(pkt); - if (ret == E_FAIL) { - puts("could not send"); - openqueue_freePacketBuffer(pkt); + if (sock_udp_create(&_sock_udp, &local, NULL, 0) < 0) { + puts("Could not create socket\n"); + return; } + + sock_udp_set_cb(&_sock_udp, _sock_udp_handler, NULL); } +#include "errno.h" + static int udp_send(char *addr_str, char *port_str, char *data, unsigned int num, unsigned int delay) { @@ -59,7 +92,6 @@ static int udp_send(char *addr_str, char *port_str, char *data, ipv6_addr_t addr; data_len = strlen(data); - uint8_t asnArray[data_len]; /* parse destination address */ if (ipv6_addr_from_str(&addr, addr_str) == NULL) { @@ -74,54 +106,40 @@ static int udp_send(char *addr_str, char *port_str, char *data, /* don't run if not in synch */ if (ieee154e_isSynch() == FALSE) { - puts("Error: Node not in sync, exit"); + puts("Error: node is not synchronized, exit"); return 1; } /* don't run on dagroot */ if (idmanager_getIsDAGroot()) { - puts("Error: Node is DAGROOT, exit"); + puts("Error: node is DAGROOT, exit"); return 1; } bool foundNeighbor = icmpv6rpl_getPreferredParentEui64(&parentNeighbor); if (foundNeighbor==FALSE) { - puts("Error: No preferred parent EUI64, exit"); + puts("Error: no preferred parent EUI64, exit"); return 1; } - /* get a free packet buffer */ - pkt = openqueue_getFreePacketBuffer(COMPONENT_UINJECT); - if (pkt == NULL) { - puts("Error: could not create packet buffer, exit"); - return 1; - } + sock_udp_ep_t remote; + remote.family = AF_INET6; + remote.port = atoi(port_str); + memcpy(&remote.addr.ipv6[0], &addr.u8[0], sizeof(addr.u8)); - pkt->owner = COMPONENT_UINJECT; - pkt->creator = COMPONENT_UINJECT; - pkt->l4_protocol = IANA_UDP; - pkt->l4_destination_port = atoi(port_str); - pkt->l4_sourcePortORicmpv6Type = uinject_vars.port; - pkt->l3_destinationAdd.type = ADDR_128B; - memcpy(&pkt->l3_destinationAdd.addr_128b[0], (void *)&addr, 16); - /* add payload */ - packetfunctions_reserveHeader(&pkt, data_len); - memcpy(&pkt->payload[0], data, data_len); - - packetfunctions_reserveHeader(&pkt, sizeof(uint16_t)); - pkt->payload[1] = (uint8_t)((counter & 0xff00) >> 8); - pkt->payload[0] = (uint8_t)(counter & 0x00ff); - counter++; - - packetfunctions_reserveHeader(&pkt, sizeof(asn_t)); - ieee154e_getAsn(asnArray); - pkt->payload[0] = asnArray[0]; - pkt->payload[1] = asnArray[1]; - pkt->payload[2] = asnArray[2]; - pkt->payload[3] = asnArray[3]; - pkt->payload[4] = asnArray[4]; - - scheduler_push_task(push_pkt_cb, TASKPRIO_COAP); + int res = sock_udp_send(&_sock_udp, data, data_len, &remote); + if(res == -EINVAL) { + puts("Error: EINVAL"); + } + else if(res == -EAFNOSUPPORT) { + puts("Error: EAFNOSUPPORT"); + } + else if(res == -ENOMEM) { + puts("Error: ENOMEM"); + } + else if(res == -ENOBUFS) { + puts("Error: ENOBUFS"); + } ztimer_sleep(ZTIMER_USEC, delay); } @@ -140,11 +158,11 @@ int udp_cmd(int argc, char **argv) uint32_t delay = 1000000LU; /* don't send as root */ if (idmanager_vars.isDAGroot) { - puts("Error: Node is root, exit"); + puts("Error: node is root, exit"); return 1; } if (argc < 5) { - printf("usage: %s send [ []]\n", + printf("Usage: %s send [ []]\n", argv[0]); return 1; } @@ -158,35 +176,33 @@ int udp_cmd(int argc, char **argv) } else if (strcmp(argv[1], "server") == 0) { if (argc < 3) { - printf("usage: %s server [start|list]\n", argv[0]); + printf("Usage: %s server [start|show]\n", argv[0]); return 1; } if (strcmp(argv[2], "start") == 0) { if (argc < 4) { - printf("usage %s server start \n", argv[0]); + printf("Usage %s server start \n", argv[0]); return 1; } uint16_t port = atoi(argv[3]); - uinject_vars.port = port; + sock_udp_ep_t local; + sock_udp_get_local(&_sock_udp, &local); + local.port = port; printf("Set UDP server port to %" PRIu16 "\n", port); return 0; } - else if (strcmp(argv[2], "list") == 0) { - udp_resource_desc_t* resource = openudp_vars.resources; - printf("Open UDP Ports: "); - while (NULL != resource) { - printf("%i ", resource->port); - resource = resource->next; - } - puts(""); + else if (strcmp(argv[2], "show") == 0) { + sock_udp_ep_t local; + sock_udp_get_local(&_sock_udp, &local); + printf("Udp port: %i\n", local.port); } else { - puts("error: invalid command"); + puts("Error: invalid command"); return 1; } } else { - puts("error: invalid command"); + puts("Error: invalid command"); return 1; } From 4add2200fc7466148456e65fb7f3c3759750f9dc Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 21 Aug 2020 12:14:23 +0200 Subject: [PATCH 04/14] Makefile.dep: fix sock_async deps --- sys/Makefile.dep | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index 93b21f415f73..d85342d2fc91 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -772,6 +772,15 @@ ifneq (,$(filter sock_async_event,$(USEMODULE))) USEMODULE += event endif +ifneq (,$(filter sock_async,$(USEMODULE))) + ifneq (,$(filter gnrc%,$(USEMODULE))) + USEMODULE += gnrc_sock_async + endif + ifneq (,$(filter openwsn%,$(USEMODULE))) + USEMODULE += openwsn_sock_async + endif +endif + ifneq (,$(filter sock_dns,$(USEMODULE))) USEMODULE += sock_udp USEMODULE += sock_util From b92681cae91106a6910e4a3ebdedf06b0943e85e Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 26 Aug 2020 16:20:56 +0200 Subject: [PATCH 05/14] pkg/openwsn: add ipv6 as openwsn shell dependency --- pkg/openwsn/Makefile.dep | 1 - tests/pkg_openwsn/Makefile | 1 - 2 files changed, 2 deletions(-) diff --git a/pkg/openwsn/Makefile.dep b/pkg/openwsn/Makefile.dep index dd32316e4858..0a502c454601 100644 --- a/pkg/openwsn/Makefile.dep +++ b/pkg/openwsn/Makefile.dep @@ -15,7 +15,6 @@ ifneq (,$(filter openwsn_openstack,$(USEMODULE))) USEMODULE += openwsn_scheduler DEFAULT_MODULE += auto_init_openwsn - endif ifneq (,$(filter openwsn_scheduler,$(USEMODULE))) diff --git a/tests/pkg_openwsn/Makefile b/tests/pkg_openwsn/Makefile index 2cfdc031b82b..5b203b04c478 100644 --- a/tests/pkg_openwsn/Makefile +++ b/tests/pkg_openwsn/Makefile @@ -76,7 +76,6 @@ endif # export OPENWSN_LOG_LEVEL ?= LOG_ERROR ## Test application Modules -USEMODULE += ipv6_addr USEMODULE += ps USEMODULE += od_string USEMODULE += shell From ad1480915110058ad8cba017e2d2dcddadab1a81 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 26 Oct 2020 17:42:23 +0100 Subject: [PATCH 06/14] sys/Makefile.dep: add openwsn shell_commands missing dependency --- sys/Makefile.dep | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index d85342d2fc91..c6eed4f2bde3 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -552,6 +552,7 @@ ifneq (,$(filter shell_commands,$(USEMODULE))) endif ifneq (,$(filter openwsn_%,$(USEMODULE))) USEMODULE += netif + USEMODULE += ipv6_addr endif endif From e7ebd996d14276d9e2247953e71d7a8422c5d212 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Wed, 28 Oct 2020 12:23:05 +0100 Subject: [PATCH 07/14] sys/Makefile.dep: add netif missing dep --- sys/Makefile.dep | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/Makefile.dep b/sys/Makefile.dep index c6eed4f2bde3..000a5826b330 100644 --- a/sys/Makefile.dep +++ b/sys/Makefile.dep @@ -67,6 +67,10 @@ ifneq (,$(filter base64url,$(USEMODULE))) USEMODULE += base64 endif +ifneq (,$(filter netif,$(USEMODULE))) + USEMODULE += fmt +endif + ifneq (,$(filter auto_init_gnrc_netif,$(USEMODULE))) USEMODULE += gnrc_netif_init_devs endif From 555d75abdb0008f5d3faad39c91779ead3a9f468 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 2 Nov 2020 14:02:48 +0100 Subject: [PATCH 08/14] fixup! tests/pkg_openwsn: adapt to sock api --- tests/pkg_openwsn/udp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/pkg_openwsn/udp.c b/tests/pkg_openwsn/udp.c index 8b45007496ad..b16b4fad0672 100644 --- a/tests/pkg_openwsn/udp.c +++ b/tests/pkg_openwsn/udp.c @@ -20,6 +20,7 @@ * @} */ +#include #include #include #include @@ -75,15 +76,13 @@ void udp_cli_init(void) local.port = WKP_UDP_ECHO; if (sock_udp_create(&_sock_udp, &local, NULL, 0) < 0) { - puts("Could not create socket\n"); + puts("Could not create socket"); return; } sock_udp_set_cb(&_sock_udp, _sock_udp_handler, NULL); } -#include "errno.h" - static int udp_send(char *addr_str, char *port_str, char *data, unsigned int num, unsigned int delay) { From b974369aca7b3e62e7314a392bfec0f14cfd4802 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 2 Nov 2020 14:03:12 +0100 Subject: [PATCH 09/14] fixup! pkg/openwsn: add openwsn_sock_udp module --- pkg/openwsn/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/openwsn/Makefile b/pkg/openwsn/Makefile index 8a1cdba12eb1..ed422b98ba4b 100644 --- a/pkg/openwsn/Makefile +++ b/pkg/openwsn/Makefile @@ -13,9 +13,9 @@ IGNORE_MODULES := openwsn_leds \ openwsn_iee802154e_security \ openwsn_radio \ openwsn_riotos \ - openwsn_sock_udp \ openwsn_sock \ openwsn_sock_async \ + openwsn_sock_udp \ openwsn_serial \ openwsn_sctimer \ openwsn_sctimer_rtt \ From c2cd22ef69e93c30dbc13a5dbb220e8b1ad5d8c5 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 30 Oct 2020 16:00:06 +0100 Subject: [PATCH 10/14] fixup! pkg/openwsn: add openwsn_sock_udp module --- pkg/openwsn/Makefile | 5 +- pkg/openwsn/Makefile.dep | 14 +-- pkg/openwsn/Makefile.include | 28 +----- ...clude-RIOT-OpenWSN-board-definitions.patch | 4 +- ...penserial-rename-include-for-RIOT-Op.patch | 6 +- ...Chigh-neighbors.c-expose-neighbors_v.patch | 5 +- ...heduler-use-thread-flags-restore-irq.patch | 19 ++-- ...hain_defs.h-comment-out-conflict-ISR.patch | 4 +- ...nstack-openstack-dont-init-idmanager.patch | 6 +- ...007-openstack-openapps-add-debugging.patch | 6 +- ...penserial-add-flag-to-echo-badcrc-fr.patch | 9 +- ...g-skip-checking-board-unused-in-RIOT.patch | 6 +- .../0010-inc-config.h-use-kerneldefines.patch | 88 +++++++++++++++++++ ...openstack-04-TRAN-add-blocking-sock.patch} | 20 +---- 14 files changed, 136 insertions(+), 84 deletions(-) create mode 100644 pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch rename pkg/openwsn/patches/{0010-openstack-04-TRAN-add-blocking-sock.patch => 0011-openstack-04-TRAN-add-blocking-sock.patch} (95%) diff --git a/pkg/openwsn/Makefile b/pkg/openwsn/Makefile index ed422b98ba4b..7e627ba639b9 100644 --- a/pkg/openwsn/Makefile +++ b/pkg/openwsn/Makefile @@ -45,14 +45,13 @@ OPENWSN_PATH_openapps = openapps OPENWSN_PATH_openweb = openweb OPENWSN_PATH_drivers = drivers/common OPENWSN_PATH_crypto = drivers/common/crypto -OPENWSN_PATH_openos = kernel/openos OPENWSN_PATH_cjoin = openapps/cjoin -OPENWSN_PATH_opencoap = openweb/opencoap +OPENWSN_PATH_coap = openweb/opencoap OPENWSN_PATH_mac_low = openstack/02a-MAClow OPENWSN_PATH_mac_high = openstack/02b-MAChigh OPENWSN_PATH_iphc = openstack/03a-IPHC OPENWSN_PATH_ipv6 = openstack/03b-IPv6 -OPENWSN_PATH_transport = openstack/04-TRAN +OPENWSN_PATH_udp = openstack/04-TRAN OPENWSN_PATH_crosslayers = openstack/cross-layers all: $(OPENWSN_MODULES) diff --git a/pkg/openwsn/Makefile.dep b/pkg/openwsn/Makefile.dep index 0a502c454601..1a022a6235c5 100644 --- a/pkg/openwsn/Makefile.dep +++ b/pkg/openwsn/Makefile.dep @@ -3,7 +3,7 @@ ifneq (,$(filter openwsn_openstack,$(USEMODULE))) USEMODULE += openwsn_ipv6 USEMODULE += openwsn_mac_low USEMODULE += openwsn_mac_high - USEMODULE += openwsn_transport + USEMODULE += openwsn_udp USEMODULE += openwsn_crosslayers USEMODULE += openwsn_drivers @@ -18,13 +18,7 @@ ifneq (,$(filter openwsn_openstack,$(USEMODULE))) endif ifneq (,$(filter openwsn_scheduler,$(USEMODULE))) - ifeq (,$(filter openwsn_openos,$(USEMODULE))) - USEMODULE += openwsn_riotos - endif -endif - -ifneq (,$(filter openwsn_openos,$(USEMODULE))) - USEMODULE += core_thread_flags + USEMODULE += openwsn_riotos endif ifneq (,$(filter openwsn_riotos,$(USEMODULE))) @@ -38,11 +32,11 @@ ifneq (,$(filter openwsn_ipv6,$(USEMODULE))) endif ifneq (,$(filter openwsn_cjoin,$(USEMODULE))) - USEMODULE += openwsn_opencoap + USEMODULE += openwsn_coap USEMODULE += openwsn_crypto endif -ifneq (,$(filter openwsn_opencoap,$(USEMODULE))) +ifneq (,$(filter openwsn_coap,$(USEMODULE))) USEMODULE += openwsn_sock_async endif diff --git a/pkg/openwsn/Makefile.include b/pkg/openwsn/Makefile.include index 517ce7d6a3b6..67633a79651d 100644 --- a/pkg/openwsn/Makefile.include +++ b/pkg/openwsn/Makefile.include @@ -45,34 +45,8 @@ ifneq (,$(filter openwsn_riotos,$(USEMODULE))) endif # Set OpenWSN configurations flags, see $(PKG_SOURCE_DIR)/openwsn-fw/inc/config.h - ifneq (,$(filter openwsn_cjoin,$(USEMODULE))) - CFLAGS += -DOPENWSN_CJOIN_C - CFLAGS += -DBOARD_CRYPTOENGINE_ENABLED -endif - -ifneq (,$(filter openwsn_transport,$(USEMODULE))) - CFLAGS += -DOPENWSN_UDP_C -endif - -ifneq (,$(filter openwsn_opencoap,$(USEMODULE))) - CFLAGS += -DOPENWSN_COAP_C -endif - -ifneq (,$(filter openwsn_6lo_frag,$(USEMODULE))) - CFLAGS += -DOPENWSN_6LO_FRAGMENTATION_C -endif - -ifneq (,$(filter openwsn_icmpv6_echo,$(USEMODULE))) - CFLAGS += -DOPENWSN_ICMPV6ECHO_C -endif - -ifneq (,$(filter openwsn_iee802154e_security,$(USEMODULE))) - CFLAGS += -DOPENWSN_IEEE802154E_SECURITY_C -endif - -ifneq (,$(filter openwsn_adaptive_msf,$(USEMODULE))) - CFLAGS += -DOPENWSN_ADAPTIVE_MSF + CFLAGS += -DBOARD_CRYPTOENGINE_ENABLED=1 endif ifneq (,$(filter openwsn_sock%,$(USEMODULE))) diff --git a/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch b/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch index 190cba7ac486..27496d0b049b 100644 --- a/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch +++ b/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch @@ -1,7 +1,7 @@ -From c8a38150ba7c8e1c4f04b65b50d8bf6f6d6881ff Mon Sep 17 00:00:00 2001 +From 0cda51f792937d14cbce660fbea38637bdfce731 Mon Sep 17 00:00:00 2001 From: PeterKietzmann Date: Thu, 8 Feb 2018 10:23:00 +0100 -Subject: [PATCH 1/9] bsp-kernel: include RIOT-OpenWSN board definitions +Subject: [PATCH 01/10] bsp-kernel: include RIOT-OpenWSN board definitions --- bsp/boards/radio.h | 2 +- diff --git a/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch b/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch index 64faa230b7bb..f9177a1428d0 100644 --- a/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch +++ b/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch @@ -1,7 +1,7 @@ -From 744194e510063e665ffaaf829a20e45494d0ebe8 Mon Sep 17 00:00:00 2001 +From 788ae94d214d512c5ff739fc85e1e89976e072e4 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 10 Feb 2020 15:05:07 +0100 -Subject: [PATCH 2/9] drivers/common/openserial: rename include for +Subject: [PATCH 02/10] drivers/common/openserial: rename include for RIOT-OpenWSN uart --- @@ -9,7 +9,7 @@ Subject: [PATCH 2/9] drivers/common/openserial: rename include for 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/common/openserial.c b/drivers/common/openserial.c -index ac3b8f5c..f0dcb19e 100644 +index 53205fbf..8a082722 100644 --- a/drivers/common/openserial.c +++ b/drivers/common/openserial.c @@ -20,7 +20,7 @@ diff --git a/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch b/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch index 325ac93e6841..db069382f99e 100644 --- a/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch +++ b/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch @@ -1,7 +1,8 @@ -From 0a1426c01092118bc875fdc46d2dae296188b163 Mon Sep 17 00:00:00 2001 +From a4733aba4a333cc5717d1b7d510c2a243ea216c3 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 27 Mar 2020 10:15:43 +0100 -Subject: [PATCH 3/9] openstack/02b-MAChigh/neighbors.c: expose neighbors_vars +Subject: [PATCH 03/10] openstack/02b-MAChigh/neighbors.c: expose + neighbors_vars --- openstack/02b-MAChigh/neighbors.c | 2 +- diff --git a/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch b/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch index 2eb7f6fe33e2..3309512be1fa 100644 --- a/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch +++ b/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch @@ -1,7 +1,7 @@ -From 219e01c2b9fb779e3682a24d361a8a9b672b551a Mon Sep 17 00:00:00 2001 +From 5630298719fb089c36250ad8bb7b4a5fe803a795 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Sun, 29 Mar 2020 12:11:53 +0200 -Subject: [PATCH 4/9] kernel/openos/scheduler: use thread flags, restore +Subject: [PATCH 04/10] kernel/openos/scheduler: use thread flags, restore irq_state Use thread_flags_wait_any to pause the scheduler. Set flag in @@ -10,8 +10,8 @@ scheduler_push_task to trigger new task handling. squash! kernel/openos/scheduler: use thread flags --- kernel/openos/scheduler.c | 13 ++++++++++++- - kernel/scheduler.h | 2 +- - 2 files changed, 13 insertions(+), 2 deletions(-) + kernel/scheduler.h | 4 ++-- + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/openos/scheduler.c b/kernel/openos/scheduler.c index f52f35d4..41be092f 100644 @@ -60,7 +60,7 @@ index f52f35d4..41be092f 100644 diff --git a/kernel/scheduler.h b/kernel/scheduler.h -index dd035a22..51b6d9cb 100644 +index e44f7956..51b6d9cb 100644 --- a/kernel/scheduler.h +++ b/kernel/scheduler.h @@ -47,7 +47,7 @@ typedef void (*task_cbt)(void); @@ -72,6 +72,15 @@ index dd035a22..51b6d9cb 100644 void scheduler_push_task(task_cbt task_cb, task_prio_t prio); #if SCHEDULER_DEBUG_ENABLE +@@ -55,7 +55,7 @@ uint8_t scheduler_debug_get_TasksCur(void); + uint8_t scheduler_debug_get_TasksMax(void); + #endif + +-#include "openos/scheduler_types.h" ++#include "scheduler_types.h" + + /** + \} -- 2.28.0 diff --git a/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch b/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch index 991f86ce7905..fa6924473fef 100644 --- a/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch +++ b/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch @@ -1,7 +1,7 @@ -From 611a5841893b6f60b9cfa9389c5a9c99599bc651 Mon Sep 17 00:00:00 2001 +From 22399443a4382d1ae5f0234516bf5690688d03f9 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 2 Apr 2020 16:04:29 +0200 -Subject: [PATCH 5/9] bsp/boards/toolchain_defs.h: comment out conflict ISR +Subject: [PATCH 05/10] bsp/boards/toolchain_defs.h: comment out conflict ISR definitions The ISR definition conflicts with AVR ISR definitions. diff --git a/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch b/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch index cf8224fcb077..6532303c2d95 100644 --- a/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch +++ b/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch @@ -1,7 +1,7 @@ -From 085704291c846d225abe8f24d01c1ba4d855b87a Mon Sep 17 00:00:00 2001 +From 3a6c00dcf2ae76ce47e0d6c70bbc3a60f8b6e930 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 15 May 2020 13:45:02 +0200 -Subject: [PATCH 6/9] openstack/openstack: dont init idmanager +Subject: [PATCH 06/10] openstack/openstack: dont init idmanager Dont initiate idmanager in OpenWSN but in RIOT to allow overriding default short address. @@ -10,7 +10,7 @@ default short address. 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openstack/openstack.c b/openstack/openstack.c -index 172bc317..dce1496a 100644 +index 10920319..c220b8ff 100644 --- a/openstack/openstack.c +++ b/openstack/openstack.c @@ -59,7 +59,7 @@ void openstack_init(void) { diff --git a/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch b/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch index 6b25fc3f9b9c..c7367091597c 100644 --- a/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch +++ b/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch @@ -1,7 +1,7 @@ -From ede0403eb8774674e2194d30f573fa31b07b9d8a Mon Sep 17 00:00:00 2001 +From 6c87c5ab22a266951db6e23f2aafa1f57cf01f8e Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 27 Mar 2020 10:18:16 +0100 -Subject: [PATCH 7/9] openstack/openapps: add debugging +Subject: [PATCH 07/10] openstack/openapps: add debugging Debugging info that can be also be obtained through ifconfig in tests/openwsn. @@ -86,7 +86,7 @@ index 1e040dee..6431cbf7 100644 outcome = coap_send( pkt, diff --git a/openstack/02a-MAClow/IEEE802154E.c b/openstack/02a-MAClow/IEEE802154E.c -index 76e7ee56..83de4296 100644 +index 8e51a7e8..e8e3eb90 100644 --- a/openstack/02a-MAClow/IEEE802154E.c +++ b/openstack/02a-MAClow/IEEE802154E.c @@ -19,6 +19,8 @@ diff --git a/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch b/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch index 7f6b8b9ade92..22d88f8d50dd 100644 --- a/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch +++ b/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch @@ -1,17 +1,18 @@ -From a66e2713eb76a1c8b555760f73ce7418312b58d6 Mon Sep 17 00:00:00 2001 +From 8dbb98b51d8450fc2d9a586c9194d8c987beaf71 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 4 Jun 2020 15:39:07 +0200 -Subject: [PATCH 8/9] drivers/common/openserial: add flag to echo badcrc frames +Subject: [PATCH 08/10] drivers/common/openserial: add flag to echo badcrc + frames --- drivers/common/openserial.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/common/openserial.c b/drivers/common/openserial.c -index f0dcb19e..2fc2c858 100644 +index 8a082722..d0b7dfbb 100644 --- a/drivers/common/openserial.c +++ b/drivers/common/openserial.c -@@ -733,9 +733,13 @@ port_INLINE void inputHdlcClose(void) { +@@ -748,9 +748,13 @@ port_INLINE void inputHdlcClose(void) { openserial_vars.inputBufFillLevel -= 2; } else { // the CRC is incorrect diff --git a/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch b/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch index 45aebc9f6e6e..9e9ec2f8247a 100644 --- a/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch +++ b/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch @@ -1,14 +1,14 @@ -From cee779033fb652a7e39a1cc03ef4b7a80e6b6f86 Mon Sep 17 00:00:00 2001 +From a9f6a485f6d8fa6112927871a47e7a715426302b Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 24 Jul 2020 15:42:05 +0200 -Subject: [PATCH 9/9] inc/check_config: skip checking board, unused in RIOT +Subject: [PATCH 09/10] inc/check_config: skip checking board, unused in RIOT --- inc/check_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/check_config.h b/inc/check_config.h -index f50b9e7c..68aea646 100644 +index d2f4c967..a1c03d03 100644 --- a/inc/check_config.h +++ b/inc/check_config.h @@ -17,7 +17,7 @@ diff --git a/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch b/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch new file mode 100644 index 000000000000..59fd899215a7 --- /dev/null +++ b/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch @@ -0,0 +1,88 @@ +From 5c8ff27f648047d8a64eae9748241e4a7aecf84d Mon Sep 17 00:00:00 2001 +From: Francisco Molina +Date: Fri, 30 Oct 2020 15:40:17 +0100 +Subject: [PATCH 10/10] inc/config.h: use kerneldefines + +--- + inc/config.h | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/inc/config.h b/inc/config.h +index 3d483431..0392a7f4 100644 +--- a/inc/config.h ++++ b/inc/config.h +@@ -1,6 +1,8 @@ + #ifndef OPENWSN_CONFIG_H + #define OPENWSN_CONFIG_H + ++#include "kernel_defines.h" ++ + // =========================== Debugging ============================ + + /** +@@ -197,7 +199,7 @@ + * + */ + #ifndef OPENWSN_CJOIN_C +-#define OPENWSN_CJOIN_C (0) ++#define OPENWSN_CJOIN_C IS_USED(MODULE_OPENWSN_CJOIN) + #endif + + // ======================= OpenWeb configuration ======================= +@@ -211,7 +213,7 @@ + * + */ + #ifndef OPENWSN_COAP_C +-#define OPENWSN_COAP_C (0) ++#define OPENWSN_COAP_C IS_USED(MODULE_OPENWSN_COAP) + #endif + + +@@ -224,7 +226,7 @@ + * + */ + #ifndef OPENWSN_UDP_C +-#define OPENWSN_UDP_C (0) ++#define OPENWSN_UDP_C IS_USED(MODULE_OPENWSN_UDP) + #endif + + /** +@@ -239,7 +241,7 @@ + * + */ + #ifndef OPENWSN_6LO_FRAGMENTATION_C +-#define OPENWSN_6LO_FRAGMENTATION_C (0) ++#define OPENWSN_6LO_FRAGMENTATION_C IS_USED(MODULE_OPENWSN_6LO_FRAGMENTATION) + #endif + + #if OPENWSN_6LO_FRAGMENTATION_C +@@ -257,7 +259,7 @@ + * Enables the icmpv6 echo (ping) functionality + */ + #ifndef OPENWSN_ICMPV6ECHO_C +-#define OPENWSN_ICMPV6ECHO_C (0) ++#define OPENWSN_ICMPV6ECHO_C IS_USED(MODULE_OPENWSN_ICMPV6_ECHO) + #endif + + +@@ -269,7 +271,7 @@ + * Requires: OPENWSN_CJOIN_C, OPENWSN_COAP_C, OPENWSN_UDP_C + */ + #ifndef OPENWSN_IEEE802154E_SECURITY_C +-#define OPENWSN_IEEE802154E_SECURITY_C (0) ++#define OPENWSN_IEEE802154E_SECURITY_C IS_USED(OPENWSN_IEEE802154E_SECURITY) + #endif + + +@@ -318,7 +320,7 @@ + * - MSF_LIM_NUMCELLSUSED_LOW: if cell usage is below this value, trigger 6P to remove a single cell to the selected parent + */ + #ifndef ADAPTIVE_MSF +-#define ADAPTIVE_MSF (0) ++#define ADAPTIVE_MSF IS_USED(MODULE_OPENWSN_ADAPTIVE_MSF) + #endif + + #if ADAPTIVE_MSF +-- +2.28.0 + diff --git a/pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch b/pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch similarity index 95% rename from pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch rename to pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch index bda4bffc5075..b63fffab8a82 100644 --- a/pkg/openwsn/patches/0010-openstack-04-TRAN-add-blocking-sock.patch +++ b/pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch @@ -1,11 +1,10 @@ -From 2cfcbafc9b2d00f7e47873e96027611c0fde8f99 Mon Sep 17 00:00:00 2001 +From 3e7c8eb5af1121e19ab80768a7483f50f6658bc7 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 21 Aug 2020 09:11:48 +0200 -Subject: [PATCH 10/10] openstack/04-TRAN: add blocking sock +Subject: [PATCH 11/11] openstack/04-TRAN: add blocking sock --- inc/opendefs.h | 3 +- - kernel/scheduler.h | 2 +- openapps/uecho/uecho.c | 9 +- .../uexpiration_monitor/uexpiration_monitor.c | 9 +- openapps/uinject/uinject.c | 9 +- @@ -14,7 +13,7 @@ Subject: [PATCH 10/10] openstack/04-TRAN: add blocking sock openstack/04-TRAN/sock_types.h | 31 ++- openstack/openstack.c | 6 +- openweb/opencoap/coap.h | 10 +- - 10 files changed, 220 insertions(+), 56 deletions(-) + 9 files changed, 219 insertions(+), 55 deletions(-) diff --git a/inc/opendefs.h b/inc/opendefs.h index 29076b5c..6a263ca0 100644 @@ -30,19 +29,6 @@ index 29076b5c..6a263ca0 100644 //=========================== define ========================================== -diff --git a/kernel/scheduler.h b/kernel/scheduler.h -index 5ef302a3..51b6d9cb 100644 ---- a/kernel/scheduler.h -+++ b/kernel/scheduler.h -@@ -55,7 +55,7 @@ uint8_t scheduler_debug_get_TasksCur(void); - uint8_t scheduler_debug_get_TasksMax(void); - #endif - --#include "openos/scheduler_types.h" -+#include "scheduler_types.h" - - /** - \} diff --git a/openapps/uecho/uecho.c b/openapps/uecho/uecho.c index 4c4a6ec8..036ccfa3 100644 --- a/openapps/uecho/uecho.c From 494735a80b719c35ee9caafbcf00bfd62433341c Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 30 Oct 2020 16:15:04 +0100 Subject: [PATCH 11/14] fixup! fixup! pkg/openwsn: add openwsn_sock_udp module --- pkg/openwsn/Makefile.include | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/openwsn/Makefile.include b/pkg/openwsn/Makefile.include index 67633a79651d..931b8f974b96 100644 --- a/pkg/openwsn/Makefile.include +++ b/pkg/openwsn/Makefile.include @@ -35,10 +35,6 @@ INCLUDES += -I$(PKGDIRBASE)/openwsn \ -I$(PKGDIRBASE)/openwsn/openweb/opencoap \ -I$(RIOTBASE)/pkg/openwsn/include \ -ifneq (,$(filter openwsn_openos,$(USEMODULE))) - INCLUDES += -I$(PKGDIRBASE)/openwsn/kernel/openos -endif - ifneq (,$(filter openwsn_riotos,$(USEMODULE))) INCLUDES += -I$(RIOTBASE)/pkg/openwsn/scheduler DIRS += $(RIOTBASE)/pkg/openwsn/scheduler From ba9a4b081ec67677e17b8bce982381d625c16462 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 2 Nov 2020 14:10:19 +0100 Subject: [PATCH 12/14] fixup! fixup! fixup! pkg/openwsn: add openwsn_sock_udp module --- pkg/openwsn/Makefile.dep | 5 ++-- .../0010-inc-config.h-use-kerneldefines.patch | 26 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pkg/openwsn/Makefile.dep b/pkg/openwsn/Makefile.dep index 1a022a6235c5..a730c4921d59 100644 --- a/pkg/openwsn/Makefile.dep +++ b/pkg/openwsn/Makefile.dep @@ -3,9 +3,7 @@ ifneq (,$(filter openwsn_openstack,$(USEMODULE))) USEMODULE += openwsn_ipv6 USEMODULE += openwsn_mac_low USEMODULE += openwsn_mac_high - USEMODULE += openwsn_udp USEMODULE += openwsn_crosslayers - USEMODULE += openwsn_drivers USEMODULE += openwsn_sctimer USEMODULE += openwsn_radio @@ -32,6 +30,8 @@ ifneq (,$(filter openwsn_ipv6,$(USEMODULE))) endif ifneq (,$(filter openwsn_cjoin,$(USEMODULE))) + USEMODULE += sock_async + # The implementation of sock_udp used by openwsn_coap is asynchronous USEMODULE += openwsn_coap USEMODULE += openwsn_crypto endif @@ -97,6 +97,7 @@ ifneq (,$(filter openwsn_debugpins,$(USEMODULE))) endif ifneq (,$(filter sock_udp,$(USEMODULE))) + USEMODULE += openwsn_udp USEMODULE += openwsn_sock_udp endif diff --git a/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch b/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch index 59fd899215a7..57736ff11e9d 100644 --- a/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch +++ b/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch @@ -14,11 +14,11 @@ index 3d483431..0392a7f4 100644 @@ -1,6 +1,8 @@ #ifndef OPENWSN_CONFIG_H #define OPENWSN_CONFIG_H - + +#include "kernel_defines.h" + // =========================== Debugging ============================ - + /** @@ -197,7 +199,7 @@ * @@ -27,7 +27,7 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_CJOIN_C (0) +#define OPENWSN_CJOIN_C IS_USED(MODULE_OPENWSN_CJOIN) #endif - + // ======================= OpenWeb configuration ======================= @@ -211,7 +213,7 @@ * @@ -36,8 +36,8 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_COAP_C (0) +#define OPENWSN_COAP_C IS_USED(MODULE_OPENWSN_COAP) #endif - - + + @@ -224,7 +226,7 @@ * */ @@ -45,7 +45,7 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_UDP_C (0) +#define OPENWSN_UDP_C IS_USED(MODULE_OPENWSN_UDP) #endif - + /** @@ -239,7 +241,7 @@ * @@ -54,7 +54,7 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_6LO_FRAGMENTATION_C (0) +#define OPENWSN_6LO_FRAGMENTATION_C IS_USED(MODULE_OPENWSN_6LO_FRAGMENTATION) #endif - + #if OPENWSN_6LO_FRAGMENTATION_C @@ -257,7 +259,7 @@ * Enables the icmpv6 echo (ping) functionality @@ -63,8 +63,8 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_ICMPV6ECHO_C (0) +#define OPENWSN_ICMPV6ECHO_C IS_USED(MODULE_OPENWSN_ICMPV6_ECHO) #endif - - + + @@ -269,7 +271,7 @@ * Requires: OPENWSN_CJOIN_C, OPENWSN_COAP_C, OPENWSN_UDP_C */ @@ -72,8 +72,8 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_IEEE802154E_SECURITY_C (0) +#define OPENWSN_IEEE802154E_SECURITY_C IS_USED(OPENWSN_IEEE802154E_SECURITY) #endif - - + + @@ -318,7 +320,7 @@ * - MSF_LIM_NUMCELLSUSED_LOW: if cell usage is below this value, trigger 6P to remove a single cell to the selected parent */ @@ -81,8 +81,8 @@ index 3d483431..0392a7f4 100644 -#define ADAPTIVE_MSF (0) +#define ADAPTIVE_MSF IS_USED(MODULE_OPENWSN_ADAPTIVE_MSF) #endif - + #if ADAPTIVE_MSF --- +-- 2.28.0 From a940050b7517e5048a9a34ef414334200be00096 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 2 Nov 2020 14:13:26 +0100 Subject: [PATCH 13/14] fixup! fixup! tests/pkg_openwsn: adapt to sock api --- tests/pkg_openwsn/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pkg_openwsn/Makefile b/tests/pkg_openwsn/Makefile index 5b203b04c478..5efe3402d8ae 100644 --- a/tests/pkg_openwsn/Makefile +++ b/tests/pkg_openwsn/Makefile @@ -35,6 +35,7 @@ BOARD_WHITELIST = \ USEPKG += openwsn USEMODULE += openwsn_openstack USEMODULE += sock_udp +USEMODULE += sock_async # Optional OpenWSN Modules ## Enable Constrained Join Protocol (CoJP) From f153008724a884acc5437e014e58d01040bc0ab7 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 2 Nov 2020 15:09:01 +0100 Subject: [PATCH 14/14] fixup! fixup! fixup! pkg/openwsn: add openwsn_sock_udp module --- pkg/openwsn/Makefile | 2 +- ...clude-RIOT-OpenWSN-board-definitions.patch | 4 +-- ...penserial-rename-include-for-RIOT-Op.patch | 4 +-- ...Chigh-neighbors.c-expose-neighbors_v.patch | 4 +-- ...heduler-use-thread-flags-restore-irq.patch | 4 +-- ...hain_defs.h-comment-out-conflict-ISR.patch | 4 +-- ...nstack-openstack-dont-init-idmanager.patch | 4 +-- ...007-openstack-openapps-add-debugging.patch | 4 +-- ...penserial-add-flag-to-echo-badcrc-fr.patch | 4 +-- ...g-skip-checking-board-unused-in-RIOT.patch | 4 +-- .../0010-inc-config.h-use-kerneldefines.patch | 32 +++++++++---------- ...-openstack-04-TRAN-add-blocking-sock.patch | 2 +- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/pkg/openwsn/Makefile b/pkg/openwsn/Makefile index 7e627ba639b9..426704c7d8c6 100644 --- a/pkg/openwsn/Makefile +++ b/pkg/openwsn/Makefile @@ -1,6 +1,6 @@ PKG_NAME=openwsn PKG_URL=https://github.com/openwsn-berkeley/openwsn-fw.git -PKG_VERSION=a49f5a34304daa8c013772ca1705f3d7da1e1514 +PKG_VERSION=e2958a031ad50a6f3eeca3a98ad1ae85aa773a48 PKG_LICENSE=BSD-3-Clause include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch b/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch index 27496d0b049b..e38c6dcc6b02 100644 --- a/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch +++ b/pkg/openwsn/patches/0001-bsp-kernel-include-RIOT-OpenWSN-board-definitions.patch @@ -1,7 +1,7 @@ -From 0cda51f792937d14cbce660fbea38637bdfce731 Mon Sep 17 00:00:00 2001 +From 2d29cff11033b519d7cbf8ee1cc18bef4f2ba0e2 Mon Sep 17 00:00:00 2001 From: PeterKietzmann Date: Thu, 8 Feb 2018 10:23:00 +0100 -Subject: [PATCH 01/10] bsp-kernel: include RIOT-OpenWSN board definitions +Subject: [PATCH 01/11] bsp-kernel: include RIOT-OpenWSN board definitions --- bsp/boards/radio.h | 2 +- diff --git a/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch b/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch index f9177a1428d0..ddbe1d1e7cfb 100644 --- a/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch +++ b/pkg/openwsn/patches/0002-drivers-common-openserial-rename-include-for-RIOT-Op.patch @@ -1,7 +1,7 @@ -From 788ae94d214d512c5ff739fc85e1e89976e072e4 Mon Sep 17 00:00:00 2001 +From efb9d31bbbfcb64876278077faf5d53892c29d2f Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Mon, 10 Feb 2020 15:05:07 +0100 -Subject: [PATCH 02/10] drivers/common/openserial: rename include for +Subject: [PATCH 02/11] drivers/common/openserial: rename include for RIOT-OpenWSN uart --- diff --git a/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch b/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch index db069382f99e..d72bb8d90e89 100644 --- a/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch +++ b/pkg/openwsn/patches/0003-openstack-02b-MAChigh-neighbors.c-expose-neighbors_v.patch @@ -1,7 +1,7 @@ -From a4733aba4a333cc5717d1b7d510c2a243ea216c3 Mon Sep 17 00:00:00 2001 +From fa749c96d40ea17a6cdf9bb7200f15624f81449f Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 27 Mar 2020 10:15:43 +0100 -Subject: [PATCH 03/10] openstack/02b-MAChigh/neighbors.c: expose +Subject: [PATCH 03/11] openstack/02b-MAChigh/neighbors.c: expose neighbors_vars --- diff --git a/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch b/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch index 3309512be1fa..4e6de232c300 100644 --- a/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch +++ b/pkg/openwsn/patches/0004-kernel-openos-scheduler-use-thread-flags-restore-irq.patch @@ -1,7 +1,7 @@ -From 5630298719fb089c36250ad8bb7b4a5fe803a795 Mon Sep 17 00:00:00 2001 +From cce174546a58a0d0dc170bc641f89ab86f38547c Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Sun, 29 Mar 2020 12:11:53 +0200 -Subject: [PATCH 04/10] kernel/openos/scheduler: use thread flags, restore +Subject: [PATCH 04/11] kernel/openos/scheduler: use thread flags, restore irq_state Use thread_flags_wait_any to pause the scheduler. Set flag in diff --git a/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch b/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch index fa6924473fef..f0d3d0a14279 100644 --- a/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch +++ b/pkg/openwsn/patches/0005-bsp-boards-toolchain_defs.h-comment-out-conflict-ISR.patch @@ -1,7 +1,7 @@ -From 22399443a4382d1ae5f0234516bf5690688d03f9 Mon Sep 17 00:00:00 2001 +From 9a0c7499639d096800d22b31fd81db384c7205c5 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 2 Apr 2020 16:04:29 +0200 -Subject: [PATCH 05/10] bsp/boards/toolchain_defs.h: comment out conflict ISR +Subject: [PATCH 05/11] bsp/boards/toolchain_defs.h: comment out conflict ISR definitions The ISR definition conflicts with AVR ISR definitions. diff --git a/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch b/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch index 6532303c2d95..ebe1ad05a441 100644 --- a/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch +++ b/pkg/openwsn/patches/0006-openstack-openstack-dont-init-idmanager.patch @@ -1,7 +1,7 @@ -From 3a6c00dcf2ae76ce47e0d6c70bbc3a60f8b6e930 Mon Sep 17 00:00:00 2001 +From 0aac1d530e20b0773775e40fa81694f20fcaa443 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 15 May 2020 13:45:02 +0200 -Subject: [PATCH 06/10] openstack/openstack: dont init idmanager +Subject: [PATCH 06/11] openstack/openstack: dont init idmanager Dont initiate idmanager in OpenWSN but in RIOT to allow overriding default short address. diff --git a/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch b/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch index c7367091597c..fdcdbff2fb40 100644 --- a/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch +++ b/pkg/openwsn/patches/0007-openstack-openapps-add-debugging.patch @@ -1,7 +1,7 @@ -From 6c87c5ab22a266951db6e23f2aafa1f57cf01f8e Mon Sep 17 00:00:00 2001 +From cce2ccd31b931d1b739e05e124af709e56359a59 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 27 Mar 2020 10:18:16 +0100 -Subject: [PATCH 07/10] openstack/openapps: add debugging +Subject: [PATCH 07/11] openstack/openapps: add debugging Debugging info that can be also be obtained through ifconfig in tests/openwsn. diff --git a/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch b/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch index 22d88f8d50dd..431925938e80 100644 --- a/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch +++ b/pkg/openwsn/patches/0008-drivers-common-openserial-add-flag-to-echo-badcrc-fr.patch @@ -1,7 +1,7 @@ -From 8dbb98b51d8450fc2d9a586c9194d8c987beaf71 Mon Sep 17 00:00:00 2001 +From 7e947bc6a84bfbeec42f586352107f77cd4d997f Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 4 Jun 2020 15:39:07 +0200 -Subject: [PATCH 08/10] drivers/common/openserial: add flag to echo badcrc +Subject: [PATCH 08/11] drivers/common/openserial: add flag to echo badcrc frames --- diff --git a/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch b/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch index 9e9ec2f8247a..f98b0634f559 100644 --- a/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch +++ b/pkg/openwsn/patches/0009-inc-check_config-skip-checking-board-unused-in-RIOT.patch @@ -1,7 +1,7 @@ -From a9f6a485f6d8fa6112927871a47e7a715426302b Mon Sep 17 00:00:00 2001 +From 02e03cdd5e136d7907feb317eb8d4ccee9c472a3 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 24 Jul 2020 15:42:05 +0200 -Subject: [PATCH 09/10] inc/check_config: skip checking board, unused in RIOT +Subject: [PATCH 09/11] inc/check_config: skip checking board, unused in RIOT --- inc/check_config.h | 2 +- diff --git a/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch b/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch index 57736ff11e9d..fce0b57828cb 100644 --- a/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch +++ b/pkg/openwsn/patches/0010-inc-config.h-use-kerneldefines.patch @@ -1,24 +1,24 @@ -From 5c8ff27f648047d8a64eae9748241e4a7aecf84d Mon Sep 17 00:00:00 2001 +From f972dcfd8b8b8ec180bde87b12ab362c917e608f Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 30 Oct 2020 15:40:17 +0100 -Subject: [PATCH 10/10] inc/config.h: use kerneldefines +Subject: [PATCH 10/11] inc/config.h: use kerneldefines --- inc/config.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/inc/config.h b/inc/config.h -index 3d483431..0392a7f4 100644 +index 8d2f0e74..fd215d28 100644 --- a/inc/config.h +++ b/inc/config.h @@ -1,6 +1,8 @@ #ifndef OPENWSN_CONFIG_H #define OPENWSN_CONFIG_H - + +#include "kernel_defines.h" + // =========================== Debugging ============================ - + /** @@ -197,7 +199,7 @@ * @@ -27,7 +27,7 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_CJOIN_C (0) +#define OPENWSN_CJOIN_C IS_USED(MODULE_OPENWSN_CJOIN) #endif - + // ======================= OpenWeb configuration ======================= @@ -211,7 +213,7 @@ * @@ -36,8 +36,8 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_COAP_C (0) +#define OPENWSN_COAP_C IS_USED(MODULE_OPENWSN_COAP) #endif - - + + @@ -224,7 +226,7 @@ * */ @@ -45,7 +45,7 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_UDP_C (0) +#define OPENWSN_UDP_C IS_USED(MODULE_OPENWSN_UDP) #endif - + /** @@ -239,7 +241,7 @@ * @@ -54,7 +54,7 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_6LO_FRAGMENTATION_C (0) +#define OPENWSN_6LO_FRAGMENTATION_C IS_USED(MODULE_OPENWSN_6LO_FRAGMENTATION) #endif - + #if OPENWSN_6LO_FRAGMENTATION_C @@ -257,7 +259,7 @@ * Enables the icmpv6 echo (ping) functionality @@ -63,8 +63,8 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_ICMPV6ECHO_C (0) +#define OPENWSN_ICMPV6ECHO_C IS_USED(MODULE_OPENWSN_ICMPV6_ECHO) #endif - - + + @@ -269,7 +271,7 @@ * Requires: OPENWSN_CJOIN_C, OPENWSN_COAP_C, OPENWSN_UDP_C */ @@ -72,8 +72,8 @@ index 3d483431..0392a7f4 100644 -#define OPENWSN_IEEE802154E_SECURITY_C (0) +#define OPENWSN_IEEE802154E_SECURITY_C IS_USED(OPENWSN_IEEE802154E_SECURITY) #endif - - + + @@ -318,7 +320,7 @@ * - MSF_LIM_NUMCELLSUSED_LOW: if cell usage is below this value, trigger 6P to remove a single cell to the selected parent */ @@ -81,8 +81,8 @@ index 3d483431..0392a7f4 100644 -#define ADAPTIVE_MSF (0) +#define ADAPTIVE_MSF IS_USED(MODULE_OPENWSN_ADAPTIVE_MSF) #endif - + #if ADAPTIVE_MSF --- +-- 2.28.0 diff --git a/pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch b/pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch index b63fffab8a82..fcc407e05a79 100644 --- a/pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch +++ b/pkg/openwsn/patches/0011-openstack-04-TRAN-add-blocking-sock.patch @@ -1,4 +1,4 @@ -From 3e7c8eb5af1121e19ab80768a7483f50f6658bc7 Mon Sep 17 00:00:00 2001 +From b6f162170d10ea75c25bfb2060cc2561e19c62f3 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 21 Aug 2020 09:11:48 +0200 Subject: [PATCH 11/11] openstack/04-TRAN: add blocking sock