From 4f243c52eabefe709d78560ce7f1d502d737a999 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Fri, 10 Jul 2020 16:32:37 +0200 Subject: [PATCH] pkg/emb6: remove deprecated package Deprecation was noted in 7cf1bab2e6d049dbdf63a67de58fd5f23b380922 --- CODEOWNERS | 1 - makefiles/pseudomodules.inc.mk | 1 - pkg/emb6/Makefile | 31 -- pkg/emb6/Makefile.dep | 24 -- pkg/emb6/Makefile.include | 35 -- pkg/emb6/contrib/Makefile | 3 - pkg/emb6/contrib/board_conf.c | 37 -- pkg/emb6/contrib/netdev/Makefile | 3 - pkg/emb6/contrib/netdev/emb6_netdev.c | 217 ------------ pkg/emb6/contrib/sock/udp/Makefile | 3 - pkg/emb6/contrib/sock/udp/emb6_sock_udp.c | 325 ------------------ pkg/emb6/contrib/target.c | 216 ------------ pkg/emb6/doc.txt | 14 - pkg/emb6/include/board_conf.h | 45 --- pkg/emb6/include/emb6/netdev.h | 56 --- pkg/emb6/include/sock_types.h | 69 ---- .../patches/0001-Add-RIOT-Makefiles.patch | Bin 3708 -> 0 bytes ...Rename-colliding-files-and-functions.patch | Bin 40001 -> 0 bytes ...e-event-type-for-RIOT-s-sock_.-_send.patch | Bin 1695 -> 0 bytes tests/emb6/Makefile | 38 -- tests/emb6/Makefile.ci | 21 -- tests/emb6/common.c | 57 --- tests/emb6/common.h | 79 ----- tests/emb6/main.c | 108 ------ tests/emb6/ping.c | 137 -------- tests/emb6/udp.c | 162 --------- 26 files changed, 1682 deletions(-) delete mode 100644 pkg/emb6/Makefile delete mode 100644 pkg/emb6/Makefile.dep delete mode 100644 pkg/emb6/Makefile.include delete mode 100644 pkg/emb6/contrib/Makefile delete mode 100644 pkg/emb6/contrib/board_conf.c delete mode 100644 pkg/emb6/contrib/netdev/Makefile delete mode 100644 pkg/emb6/contrib/netdev/emb6_netdev.c delete mode 100644 pkg/emb6/contrib/sock/udp/Makefile delete mode 100644 pkg/emb6/contrib/sock/udp/emb6_sock_udp.c delete mode 100644 pkg/emb6/contrib/target.c delete mode 100644 pkg/emb6/doc.txt delete mode 100644 pkg/emb6/include/board_conf.h delete mode 100644 pkg/emb6/include/emb6/netdev.h delete mode 100644 pkg/emb6/include/sock_types.h delete mode 100644 pkg/emb6/patches/0001-Add-RIOT-Makefiles.patch delete mode 100644 pkg/emb6/patches/0002-Rename-colliding-files-and-functions.patch delete mode 100644 pkg/emb6/patches/0003-Provide-event-type-for-RIOT-s-sock_.-_send.patch delete mode 100644 tests/emb6/Makefile delete mode 100644 tests/emb6/Makefile.ci delete mode 100644 tests/emb6/common.c delete mode 100644 tests/emb6/common.h delete mode 100644 tests/emb6/main.c delete mode 100644 tests/emb6/ping.c delete mode 100644 tests/emb6/udp.c diff --git a/CODEOWNERS b/CODEOWNERS index 0ef20a1d49..7986045e8b 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -129,7 +129,6 @@ /tests/ @smlng @leandrolanzieri @aabadie @MichelRottleuthner @fjmolinas /tests/candev/ @wosym -/tests/emb6* @miri64 /tests/gnrc* @miri64 /tests/lwip* @miri64 /tests/slip/ @miri64 diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index fa6f4cdc9a..be3ef61738 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -19,7 +19,6 @@ PSEUDOMODULES += crypto_% # crypto_aes or crypto_3des PSEUDOMODULES += devfs_% PSEUDOMODULES += dhcpv6_% PSEUDOMODULES += ecc_% -PSEUDOMODULES += emb6_router PSEUDOMODULES += event_% PSEUDOMODULES += fmt_% PSEUDOMODULES += gnrc_dhcpv6_% diff --git a/pkg/emb6/Makefile b/pkg/emb6/Makefile deleted file mode 100644 index 95e133e5f8..0000000000 --- a/pkg/emb6/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -PKG_NAME=emb6 -PKG_URL=https://github.com/hso-esk/emb6.git -PKG_VERSION=14e4a3cfff01644e078870e14e16a1fe60dcc895 -PKG_LICENSE=BSD-3-Clause - -include $(RIOTBASE)/pkg/pkg.mk - -# GCC 7.x fails on (intentional) fallthrough, thus disable implicit-fallthrough. -CFLAGS += -Wno-implicit-fallthrough -CFLAGS += -Wno-strict-aliasing -CFLAGS += -Wno-old-style-definition -CFLAGS += -Wno-strict-prototypes - -# Collect all chosen sub-modules but not the pseudo-modules and the ones -# implemented in ./contrib/ -EMB6_SUBMODULES:=$(filter-out emb6_contrib \ - emb6_netdev \ - emb6_router \ - emb6_sock_%,$(filter emb6_%,$(USEMODULE))) - -all: $(EMB6_SUBMODULES) - "$(MAKE)" -C $(PKG_SOURCE_DIR) - -# Rule for all submodules -emb6_%: - "$(MAKE)" -C $(dir $(shell grep -lR "MODULE.*=.*\<$@\>" $(PKG_SOURCE_DIR))) - -ifeq (llvm,$(TOOLCHAIN)) - CFLAGS += -Wno-tautological-compare - CFLAGS += -Wno-parentheses-equality -endif diff --git a/pkg/emb6/Makefile.dep b/pkg/emb6/Makefile.dep deleted file mode 100644 index bd033e4534..0000000000 --- a/pkg/emb6/Makefile.dep +++ /dev/null @@ -1,24 +0,0 @@ -ifneq (,$(filter emb6_sock_%,$(USEMODULE))) - USEMODULE += core_mbox - USEMODULE += emb6_sock -endif - -ifneq (,$(filter emb6_%,$(USEMODULE))) - USEMODULE += emb6 -endif - -ifneq (,$(filter emb6,$(USEMODULE))) - USEPKG += emb6 - USEMODULE += emb6_bsp - USEMODULE += emb6_common - USEMODULE += emb6_contrib - USEMODULE += emb6_ipv6 - USEMODULE += emb6_ipv6_multicast - USEMODULE += emb6_llsec - USEMODULE += emb6_mac - USEMODULE += emb6_netdev - USEMODULE += emb6_rpl - USEMODULE += emb6_sicslowpan - USEMODULE += emb6_utils - USEMODULE += xtimer -endif diff --git a/pkg/emb6/Makefile.include b/pkg/emb6/Makefile.include deleted file mode 100644 index 04e7bdf431..0000000000 --- a/pkg/emb6/Makefile.include +++ /dev/null @@ -1,35 +0,0 @@ -PKG_BUILDDIR ?= $(PKGDIRBASE)/emb6 -EMB6_DIR := $(PKG_BUILDDIR) -EMB6_CONTRIB := $(RIOTBASE)/pkg/emb6/contrib - -INCLUDES += -I$(PKG_BUILDDIR)/target -INCLUDES += -I$(RIOTBASE)/pkg/emb6/include -INCLUDES += -I$(EMB6_DIR)/emb6 -INCLUDES += -I$(EMB6_DIR)/emb6/inc/net/ipv6 -INCLUDES += -I$(EMB6_DIR)/emb6/inc/net/ipv6/multicast -INCLUDES += -I$(EMB6_DIR)/emb6/inc/mac/llsec -INCLUDES += -I$(EMB6_DIR)/emb6/inc/mac -INCLUDES += -I$(EMB6_DIR)/emb6/inc/net/rpl -INCLUDES += -I$(EMB6_DIR)/emb6/inc/net/sicslowpan -INCLUDES += -I$(EMB6_DIR)/emb6/inc/tport -INCLUDES += -I$(EMB6_DIR)/utils/inc - -CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wno-type-limits -CFLAGS += -Wno-sign-compare -Wno-missing-field-initializers - -ifeq (,$(filter emb6_router,$(USEMODULE))) - CFLAGS += -DEMB6_CONF_ROUTER=FALSE -endif - -ifneq (,$(filter emb6_contrib,$(USEMODULE))) - DIRS += $(EMB6_CONTRIB) -endif - -ifneq (,$(filter emb6_netdev,$(USEMODULE))) - DIRS += $(EMB6_CONTRIB)/netdev -endif - -ifneq (,$(filter emb6_sock_udp,$(USEMODULE))) - DIRS += $(EMB6_CONTRIB)/sock/udp - CFLAGS += -DSOCK_HAS_IPV6 -endif diff --git a/pkg/emb6/contrib/Makefile b/pkg/emb6/contrib/Makefile deleted file mode 100644 index 600b0c807b..0000000000 --- a/pkg/emb6/contrib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = emb6_contrib - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/emb6/contrib/board_conf.c b/pkg/emb6/contrib/board_conf.c deleted file mode 100644 index d63ba134f1..0000000000 --- a/pkg/emb6/contrib/board_conf.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include "emb6/netdev.h" - -#include "etimer.h" -#include "board_conf.h" - -#define ENABLE_DEBUG (0) -#include "debug.h" - -uint8_t board_conf(s_ns_t *ps_nStack) -{ - if (ps_nStack != NULL) { - ps_nStack->inif = &emb6_netdev_driver; - etimer_init(); - return ps_nStack->inif->init(ps_nStack); - } - else { - DEBUG("Network stack pointer is NULL"); - return 0; - } -} - -/** @} */ diff --git a/pkg/emb6/contrib/netdev/Makefile b/pkg/emb6/contrib/netdev/Makefile deleted file mode 100644 index e8dd709650..0000000000 --- a/pkg/emb6/contrib/netdev/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = emb6_netdev - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/emb6/contrib/netdev/emb6_netdev.c b/pkg/emb6/contrib/netdev/emb6_netdev.c deleted file mode 100644 index ded613a650..0000000000 --- a/pkg/emb6/contrib/netdev/emb6_netdev.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include -#include -#include - -#include "msg.h" -#include "net/netdev.h" - -#include "evproc.h" -#include "emb6.h" -#include "linkaddr.h" -#include "packetbuf.h" - -#define ENABLE_DEBUG (0) -#include "debug.h" - -extern uip_lladdr_t uip_lladdr; - -static netdev_t *_dev = NULL; -static s_nsLowMac_t *_lowmac = NULL; -static int8_t _rssi_base_value = -100; -static uint8_t _last_rssi; - -static int8_t _netdev_init(s_ns_t *p_ns); -static int8_t _netdev_send(const void *pr_payload, uint8_t c_len); -static int8_t _netdev_on(void); -static int8_t _netdev_off(void); -static void _netdev_set_txpower(int8_t power); -static int8_t _netdev_get_txpower(void); -static void _netdev_set_sensitivity(int8_t sens); -static int8_t _netdev_get_sensitivity(void); -static int8_t _netdev_get_rssi(void); -static void _netdev_set_promisc(uint8_t c_on_off); - -const s_nsIf_t emb6_netdev_driver = { - .name = "netdev", - .init = &_netdev_init, - .send = &_netdev_send, - .on = &_netdev_on, - .off = &_netdev_off, - .set_txpower = &_netdev_set_txpower, - .get_txpower = &_netdev_get_txpower, - .set_sensitivity = &_netdev_set_sensitivity, - .get_sensitivity = &_netdev_get_sensitivity, - .get_rssi = &_netdev_get_rssi, - .ant_div = NULL, - .ant_rf_switch = NULL, - .set_promisc = &_netdev_set_promisc, -}; - -static void _get_recv_pkt(void) -{ - char *dataptr; - struct netdev_radio_rx_info rx_info; - int8_t len; - - packetbuf_clear(); - - dataptr = packetbuf_dataptr(); - len = _dev->driver->recv(_dev, dataptr, PACKETBUF_SIZE, &rx_info); - _last_rssi = rx_info.rssi; - - if ((len > 0) && (_lowmac != NULL)) { - packetbuf_set_datalen(len); - _lowmac->input(); - } -} - -static void _event_cb(netdev_t *dev, netdev_event_t event) -{ - if (event == NETDEV_EVENT_ISR) { - /* EVENT_TYPE_PCK_LL is supposed to be used by drivers, so use it - * (though NETDEV_EVENT_ISR technically doesn't only signify - * incoming packets) */ - evproc_putEvent(E_EVPROC_HEAD, EVENT_TYPE_PCK_LL, NULL); - } - else { - switch (event) { - case NETDEV_EVENT_RX_COMPLETE: { - _get_recv_pkt(); - } - break; - default: - break; - } - } -} - -static void _emb6_netdev_callback(c_event_t c_event, p_data_t p_data) -{ - (void)p_data; - if (c_event == EVENT_TYPE_PCK_LL) { - _dev->driver->isr(_dev); - } -} - -static void _configure_netdev(void) -{ - /* Enable RX-complete interrupts */ - static const netopt_enable_t enable = NETOPT_ENABLE; - int res = _dev->driver->set(_dev, NETOPT_RX_END_IRQ, &enable, sizeof(enable)); - if (res < 0) { - DEBUG("emb6: enable NETOPT_RX_END_IRQ failed: %d\n", res); - } -} - -int emb6_netdev_setup(netdev_t *dev) -{ - if (_dev == NULL) { - _dev = dev; - return 0; - } - return -1; -} - -static int8_t _netdev_init(s_ns_t *p_ns) -{ - if ((_dev != NULL) && (p_ns != NULL) && (p_ns->lmac != NULL)) { - _dev->event_callback = _event_cb; - _dev->driver->get(_dev, NETOPT_ADDRESS_LONG, &mac_phy_config.mac_address, - sizeof(mac_phy_config.mac_address)); - memcpy(&uip_lladdr, mac_phy_config.mac_address, - sizeof(mac_phy_config.mac_address)); - _dev->driver->get(_dev, NETOPT_NID, &mac_phy_config.pan_id, - sizeof(mac_phy_config.pan_id)); - _configure_netdev(); - linkaddr_set_node_addr((linkaddr_t *)&uip_lladdr); - _lowmac = p_ns->lmac; - evproc_regCallback(EVENT_TYPE_PCK_LL, _emb6_netdev_callback); - return 1; - } - return 0; -} - -static int8_t _netdev_send(const void *pr_payload, uint8_t c_len) -{ - if (_dev != NULL) { - iolist_t iolist = { - .iol_base = (void *)pr_payload, - .iol_len = c_len, - }; - if (_dev->driver->send(_dev, &iolist) < 0) { - DEBUG("Error on send\n"); - return RADIO_TX_ERR; - } - DEBUG("Packet of length %u was transmitted\n", (unsigned)c_len); - return RADIO_TX_OK; - } - DEBUG("Device was not initialized\n"); - return RADIO_TX_ERR; -} - -static int8_t _netdev_on(void) -{ - /* TODO: turn netdev on */ - return 1; -} - -static int8_t _netdev_off(void) -{ - /* TODO: turn netdev off */ - return 1; -} - -static void _netdev_set_txpower(int8_t power) -{ - int16_t pwr = power; - - _dev->driver->set(_dev, NETOPT_TX_POWER, &pwr, sizeof(pwr)); -} - -static int8_t _netdev_get_txpower(void) -{ - int16_t power = 0; - - _dev->driver->get(_dev, NETOPT_TX_POWER, &power, sizeof(power)); - return (int8_t)power; -} - -static void _netdev_set_sensitivity(int8_t sens) -{ - /* TODO: set sensitivity */ -} - -static int8_t _netdev_get_sensitivity(void) -{ - /* TODO: get sensitivity */ - return 0; -} - -static int8_t _netdev_get_rssi(void) -{ - return (int8_t)(_rssi_base_value + 1.03 * _last_rssi); -} - -static void _netdev_set_promisc(uint8_t c_on_off) -{ - netopt_enable_t en = (c_on_off) ? NETOPT_ENABLE : NETOPT_DISABLE; - - _dev->driver->set(_dev, NETOPT_PROMISCUOUSMODE, &en, sizeof(en)); -} - -/** @} */ diff --git a/pkg/emb6/contrib/sock/udp/Makefile b/pkg/emb6/contrib/sock/udp/Makefile deleted file mode 100644 index d38d86d7ac..0000000000 --- a/pkg/emb6/contrib/sock/udp/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE := emb6_sock_udp - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c b/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c deleted file mode 100644 index 433b1d813d..0000000000 --- a/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include -#include -#include - -#include "byteorder.h" -#include "evproc.h" -#include "msg.h" -#include "mutex.h" -#include "net/af.h" -#include "net/sock/udp.h" -#include "net/ipv6/hdr.h" -#include "sched.h" -#include "uip.h" -#include "xtimer.h" - -#define _MSG_TYPE_CLOSE (0x4123) -#define _MSG_TYPE_TIMEOUT (0x4124) -#define _MSG_TYPE_RCV (0x4125) - -/* struct to describe a sendto command for emb6 thread */ -typedef struct { - mutex_t block; - struct udp_socket *sock; - const sock_udp_ep_t *remote; - int res; - const void *data; - size_t len; -} _send_cmd_t; - -extern uint16_t uip_slen; - -static bool send_registered = false; - -static void _timeout_callback(void *arg); -static void _input_callback(struct udp_socket *c, void *ptr, - const uip_ipaddr_t *src_addr, uint16_t src_port, - const uip_ipaddr_t *dst_addr, uint16_t dst_port, - const uint8_t *data, uint16_t datalen); -static void _output_callback(c_event_t c_event, p_data_t p_data); - -static int _reg(struct udp_socket *c, void *ptr, udp_socket_input_callback_t cb, - const sock_udp_ep_t *local, const sock_udp_ep_t *remote) -{ - if (((local != NULL) && (local->family != AF_INET6)) || - ((remote != NULL) && (remote->family != AF_INET6))) { - return -EAFNOSUPPORT; - } - if (udp_socket_register(c, ptr, cb) < 0) { - return -ENOMEM; - } - if (local != NULL) { - if (udp_socket_bind(c, local->port) < 0) { - udp_socket_close(c); - return -EADDRINUSE; - } - } - if (remote != NULL) { - /* check of return value not necessary, since neither c nor - * c->udp_conn is NULL (only error case) at this point */ - udp_socket_connect(c, (uip_ipaddr_t *)&remote->addr, remote->port); - } - return 0; -} - -int sock_udp_create(sock_udp_t *sock, const sock_udp_ep_t *local, - const sock_udp_ep_t *remote, uint16_t flags) -{ - int res; - - (void)flags; - assert((sock != NULL)); - assert((remote == NULL) || (remote->port != 0)); - if (sock->sock.input_callback != NULL) { - sock_udp_close(sock); - } - mutex_init(&sock->mutex); - mutex_lock(&sock->mutex); - mbox_init(&sock->mbox, sock->mbox_queue, SOCK_MBOX_SIZE); - atomic_init(&sock->receivers, 0); - if ((res = _reg(&sock->sock, sock, _input_callback, local, remote)) < 0) { - sock->sock.input_callback = NULL; - } - mutex_unlock(&sock->mutex); - return res; -} - -void sock_udp_close(sock_udp_t *sock) -{ - assert(sock != NULL); - if (sock->sock.input_callback != NULL) { - while (atomic_fetch_sub(&sock->receivers, 1) > 0) { - msg_t msg = { .type = _MSG_TYPE_CLOSE }; - mbox_put(&sock->mbox, &msg); - } - mutex_lock(&sock->mutex); - udp_socket_close(&sock->sock); - sock->sock.input_callback = NULL; - mutex_unlock(&sock->mutex); - } -} - -int sock_udp_get_local(sock_udp_t *sock, sock_udp_ep_t *ep) -{ - assert((sock != NULL) && (ep != NULL)); - if ((sock->sock.input_callback != NULL) && - (sock->sock.udp_conn->lport != 0)) { - mutex_lock(&sock->mutex); - /* local UDP endpoints do not have addresses in emb6 */ - memset(&ep->addr, 0, sizeof(ipv6_addr_t)); - ep->port = ntohs(sock->sock.udp_conn->lport); - mutex_unlock(&sock->mutex); - return sizeof(ipv6_addr_t); - } - return -EADDRNOTAVAIL; -} - -int sock_udp_get_remote(sock_udp_t *sock, sock_udp_ep_t *ep) -{ - assert((sock != NULL) && (ep != NULL)); - if ((sock->sock.input_callback != NULL) && - (sock->sock.udp_conn->rport != 0)) { - mutex_lock(&sock->mutex); - memcpy(&ep->addr, &sock->sock.udp_conn->ripaddr, sizeof(ipv6_addr_t)); - ep->port = ntohs(sock->sock.udp_conn->rport); - mutex_unlock(&sock->mutex); - return sizeof(ipv6_addr_t); - } - return -ENOTCONN; -} - -int sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len, - uint32_t timeout, sock_udp_ep_t *remote) -{ - xtimer_t timeout_timer; - int blocking = BLOCKING; - int res = -EIO; - msg_t msg; - - assert((sock != NULL) && (data != NULL) && (max_len > 0)); - if (sock->sock.input_callback == NULL) { - return -EADDRNOTAVAIL; - } - if (timeout == 0) { - blocking = NON_BLOCKING; - } - else if (timeout != SOCK_NO_TIMEOUT) { - timeout_timer.callback = _timeout_callback; - timeout_timer.arg = &sock->mbox; - xtimer_set(&timeout_timer, timeout); - } - atomic_fetch_add(&sock->receivers, 1); - if (_mbox_get(&sock->mbox, &msg, blocking) == 0) { - /* do not need to remove xtimer, since we only get here in non-blocking - * mode (timeout > 0) */ - return -EAGAIN; - } - switch (msg.type) { - case _MSG_TYPE_CLOSE: - res = -EADDRNOTAVAIL; - break; - case _MSG_TYPE_TIMEOUT: - res = -ETIMEDOUT; - break; - case _MSG_TYPE_RCV: - mutex_lock(&sock->mutex); - if (max_len < sock->recv_info.datalen) { - res = -ENOBUFS; - mutex_unlock(&sock->mutex); - break; - } - memcpy(data, sock->recv_info.data, sock->recv_info.datalen); - if (remote != NULL) { - remote->family = AF_INET6; - remote->netif = SOCK_ADDR_ANY_NETIF; - memcpy(&remote->addr, sock->recv_info.src, sizeof(ipv6_addr_t)); - remote->port = sock->recv_info.src_port; - } - res = (int)sock->recv_info.datalen; - mutex_unlock(&sock->mutex); - break; - } - atomic_fetch_sub(&sock->receivers, 1); - return res; -} - -int sock_udp_send(sock_udp_t *sock, const void *data, size_t len, - const sock_udp_ep_t *remote) -{ - struct udp_socket tmp; - _send_cmd_t send_cmd = { .block = MUTEX_INIT, - .remote = remote, - .data = data, - .len = len }; - - assert((sock != NULL) || (remote != NULL)); - assert((len == 0) || (data != NULL)); /* (len != 0) => (data != NULL) */ - /* we want the send in the uip thread (which udp_socket_send does not offer) - * so we need to do it manually */ - if (!send_registered) { - if (evproc_regCallback(EVENT_TYPE_SOCK_SEND, _output_callback) != E_SUCCESS) { - return -ENOMEM; - } - else { - send_registered = true; - } - } - if ((len > (UIP_BUFSIZE - (UIP_LLH_LEN + UIP_IPUDPH_LEN))) || - (len > UINT16_MAX)) { - return -ENOMEM; - } - if (remote != NULL) { - if (remote->family != AF_INET6) { - return -EAFNOSUPPORT; - } - if (remote->port == 0) { - return -EINVAL; - } - send_cmd.remote = remote; - } - else if (sock->sock.udp_conn->rport == 0) { - return -ENOTCONN; - } - /* cppcheck-suppress nullPointerRedundantCheck - * (reason: remote == NULL implies that sock != NULL (see assert at start of - * function) * that's why it is okay in the if-statement above to check - * sock->... without checking (sock != NULL) first => this check afterwards - * isn't redundant) */ - if (sock == NULL) { - int res; - if ((res = _reg(&tmp, NULL, NULL, NULL, NULL)) < 0) { - return res; - } - send_cmd.sock = &tmp; - } - else { - send_cmd.sock = &sock->sock; - } - mutex_lock(&send_cmd.block); - /* change to emb6 thread context */ - if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_SOCK_SEND, &send_cmd) == E_SUCCESS) { - /* block thread until data was sent */ - mutex_lock(&send_cmd.block); - } - else { - /* most likely error: event queue was full */ - send_cmd.res = -ENOMEM; - } - if (send_cmd.sock == &tmp) { - udp_socket_close(&tmp); - } - mutex_unlock(&send_cmd.block); - - return send_cmd.res; -} - -static void _timeout_callback(void *arg) -{ - msg_t msg = { .type = _MSG_TYPE_TIMEOUT }; - mbox_t *mbox = arg; - - /* should be safe, because otherwise if mbox were filled this callback is - * senseless */ - mbox_try_put(mbox, &msg); -} - -static void _input_callback(struct udp_socket *c, void *ptr, - const uip_ipaddr_t *src_addr, uint16_t src_port, - const uip_ipaddr_t *dst_addr, uint16_t dst_port, - const uint8_t *data, uint16_t datalen) -{ - msg_t msg = { .type = _MSG_TYPE_RCV }; - sock_udp_t *sock = ptr; - - (void)dst_addr; - (void)dst_port; - mutex_lock(&sock->mutex); - sock->recv_info.src_port = src_port; - sock->recv_info.src = (const ipv6_addr_t *)src_addr; - sock->recv_info.data = data; - sock->recv_info.datalen = datalen - sizeof(ipv6_hdr_t); - mutex_unlock(&sock->mutex); - mbox_put(&sock->mbox, &msg); -} - -static void _output_callback(c_event_t c_event, p_data_t p_data) -{ - - if ((c_event != EVENT_TYPE_SOCK_SEND) || (p_data == NULL)) { - return; - } - - _send_cmd_t *send_cmd = (_send_cmd_t *)p_data; - - if (send_cmd->remote != NULL) { - /* send_cmd->len was previously checked */ - send_cmd->res = udp_socket_sendto(send_cmd->sock, send_cmd->data, - (uint16_t)send_cmd->len, - (uip_ipaddr_t *)&send_cmd->remote->addr, - send_cmd->remote->port); - } - else { - /* send_cmd->len was previously checked */ - send_cmd->res = udp_socket_send(send_cmd->sock, send_cmd->data, - (uint16_t)send_cmd->len); - } - send_cmd->res = (send_cmd->res < 0) ? -EHOSTUNREACH : send_cmd->res; - /* notify notify waiting thread */ - mutex_unlock(&send_cmd->block); -} -/** @} */ diff --git a/pkg/emb6/contrib/target.c b/pkg/emb6/contrib/target.c deleted file mode 100644 index c3c1ed3fba..0000000000 --- a/pkg/emb6/contrib/target.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include - -#include "cpu.h" -#include "led.h" -#include "mutex.h" -#include "periph/gpio.h" -#include "periph/hwrng.h" -#ifdef MODULE_RANDOM -#include "random.h" -#endif -#include "xtimer.h" - -#include "target.h" -#include "bsp.h" - -static mutex_t critical_mutex = MUTEX_INIT; - -void hal_enterCritical(void) -{ - mutex_lock(&critical_mutex); -} - -void hal_exitCritical(void) -{ - mutex_unlock(&critical_mutex); -} - -int8_t hal_init(void) -{ - /* Should have happened long before emb6 started, so nothing to do */ - return 1; -} - -uint8_t hal_getrand(void) -{ -#if defined(MODULE_PERIPH_HWRNG) - uint8_t res; - hwrng_read((char *)&res, sizeof(res)); - return res; -#elif defined(MODULE_RANDOM) - return (uint8_t)(random_uint32() % UINT8_MAX); -#else - return 4; /* keeping the meme alive ;-) */ -#endif -} - -void hal_ledOn(uint16_t ui_led) -{ - switch (ui_led) { - case E_BSP_LED_RED: - LED0_ON; - break; - case E_BSP_LED_YELLOW: - LED1_ON; - break; - case E_BSP_LED_GREEN: - LED2_ON; - break; - default: - break; - } -} - -void hal_ledOff(uint16_t ui_led) -{ - switch (ui_led) { - case E_BSP_LED_RED: - LED0_OFF; - break; - case E_BSP_LED_YELLOW: - LED1_OFF; - break; - case E_BSP_LED_GREEN: - LED2_OFF; - break; - default: - break; - } -} - -uint8_t hal_extIntInit(en_targetExtInt_t e_extInt, pfn_intCallb_t pfn_intCallback) -{ - /* RIOT does this in netdev initialization so nothing to do here. */ - return 0; -} - -void hal_delay_us(uint32_t i_delay) -{ - xtimer_usleep(i_delay); -} - -uint8_t hal_gpioPinInit(uint8_t c_pin, uint8_t c_dir, uint8_t c_initState) -{ - /* Only used in board init code => not needed */ - (void)c_pin; - (void)c_dir; - (void)c_initState; - return 0; -} - -void *hal_ctrlPinInit(en_targetExtPin_t e_pinType) -{ - (void)e_pinType; - return NULL; -} - -void hal_pinSet(void *p_pin) -{ - /* Only used in board/driver-related code code => not needed */ -} - -void hal_pinClr(void *p_pin) -{ - /* Only used in board/driver-related code code => not needed */ -} - -uint8_t hal_pinGet(void *p_pin) -{ - /* Only used in board/driver-related code code => not needed */ - return 0; -} - -void *hal_spiInit(void) -{ - /* Only used in board/driver-related code code => not needed */ - return 0; -} - -/*----------------------------------------------------------------------------*/ -/** \brief This function selects slave with which we will work - * \param p_spi Pointer to spi description entity - * \param action true or false - * - * \return 0 if failed, 1 id ok - */ -/*---------------------------------------------------------------------------*/ -uint8_t hal_spiSlaveSel(void *p_spi, bool action) -{ - /* Only used in board/driver-related code code => not needed */ - return 0; -} - -uint8_t hal_spiTransceive( uint8_t *txData, uint8_t *p_reg) -{ - /* Only used in board/driver-related code code => not needed */ - return 0; -} - -uint8_t hal_spiRead(uint8_t *p_reg, uint16_t i_length) -{ - /* Only used in board/driver-related code code => not needed */ - return 0; -} - - -/*----------------------------------------------------------------------------*/ -/** \brief This function writes a new value via given SPI interface - * registers. - * - * - * \param value Pointer to a value. - * \param i_length Length of a data to be received - */ -/*----------------------------------------------------------------------------*/ -void hal_spiWrite(uint8_t *value, uint16_t i_length) -{ - /* Only used in board/driver-related code code => not needed */ -} - -void hal_watchdogReset(void) -{ - /* WDT and tick-less scheduling don't make much sense */ -} - -void hal_watchdogStart(void) -{ - /* WDT and tick-less scheduling don't make much sense */ -} - -void hal_watchdogStop(void) -{ - /* WDT and tick-less scheduling don't make much sense */ -} - -clock_time_t hal_getTick(void) -{ - return (clock_time_t)xtimer_now_usec(); -} - -clock_time_t hal_getSec(void) -{ - return (clock_time_t)xtimer_now_usec() / US_PER_SEC; -} - - -clock_time_t hal_getTRes(void) -{ - return US_PER_SEC; -} - -/** @} */ diff --git a/pkg/emb6/doc.txt b/pkg/emb6/doc.txt deleted file mode 100644 index 644009a801..0000000000 --- a/pkg/emb6/doc.txt +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @defgroup pkg_emb6 emb6 network stack - * @ingroup pkg - * @ingroup net - * @brief emb6 network stack - * @see https://github.com/hso-esk/emb6/blob/14e4a3cfff01644e078870e14e16a1fe60dcc895/doc/pdf/emb6.pdf - * - * @deprecated Based on very old version of `emb6` and the package is - * basically unmaintained; will be removed after the 2020.07 - * release. - * - * emb6 is a fork of Contiki's uIP network stack without its usage of - * proto-threads. It uses periodic event polling instead. - */ diff --git a/pkg/emb6/include/board_conf.h b/pkg/emb6/include/board_conf.h deleted file mode 100644 index 5480583e5b..0000000000 --- a/pkg/emb6/include/board_conf.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -/** - * @addtogroup pkg_emb6 - * @brief - * @{ - * - * @file - * @brief "Board" configuration for emb6 - * - * @author Martine Lenders - */ - -#ifndef BOARD_CONF_H -#define BOARD_CONF_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "emb6.h" - -/** - * @brief emb6 board configuration function - * - * @param[in] ps_nStack pointer to global netstack struct - * - * @return success 1 - * @return failure 0 - */ -uint8_t board_conf(s_ns_t *ps_nStack); - -#ifdef __cplusplus -} -#endif - -#endif /* BOARD_CONF_H */ -/** @} */ -/** @} */ diff --git a/pkg/emb6/include/emb6/netdev.h b/pkg/emb6/include/emb6/netdev.h deleted file mode 100644 index 8bc87c6ec8..0000000000 --- a/pkg/emb6/include/emb6/netdev.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @defgroup pkg_emb6_netdev netdev wrapper for emb6 - * @ingroup pkg_emb6 - * @brief - * @{ - * - * @file - * @brief - * - * @author Martine Lenders - */ -#ifndef EMB6_NETDEV_H -#define EMB6_NETDEV_H - -#include "net/netdev.h" - -#include "emb6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The emb6 network interface. - * - * @note emb6 only supports one network interface. - * - * This variable is used by @ref board_conf() to set the interface for the - * stack. - */ -extern const s_nsIf_t emb6_netdev_driver; - -/** - * @brief Setup a network device as the emb6 interface. - * - * @param[in] dev The network device for the interface - * - * @return 0 on success. - * @return <= 0 on error. - */ -int emb6_netdev_setup(netdev_t *dev); - -#ifdef __cplusplus -} -#endif - -#endif /* EMB6_NETDEV_H */ -/** @} */ diff --git a/pkg/emb6/include/sock_types.h b/pkg/emb6/include/sock_types.h deleted file mode 100644 index 9240e78329..0000000000 --- a/pkg/emb6/include/sock_types.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @defgroup pkg_emb6_sock emb6-specific implementation of the sock API - * @ingroup pkg_emb6 - * @brief - * @{ - * - * @file - * @brief - * - * @author Martine Lenders - */ -#ifndef SOCK_TYPES_H -#define SOCK_TYPES_H - -#include - -#include "mbox.h" -#include "mutex.h" -#include "net/ipv6/addr.h" - -#include "uip.h" -#include "udp-socket.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Size for struct sock_udp::mbox_queue - */ -#ifndef SOCK_MBOX_SIZE -#define SOCK_MBOX_SIZE (2) -#endif - -#ifndef SOCK_HAS_IPV6 -#error "emb6 only runs with IPv6 support" -#endif - -/** - * @brief @ref net_sock_udp definition for emb6 - */ -struct sock_udp { - struct udp_socket sock; /**< emb6 internal socket */ - mutex_t mutex; /**< mutex for the connection */ - mbox_t mbox; /**< mbox for receiving */ - msg_t mbox_queue[SOCK_MBOX_SIZE]; /**< queue for mbox */ - atomic_int receivers; /**< current number of recv calls */ - struct { - const ipv6_addr_t *src; /**< source address */ - const void *data; /**< data of received packet */ - size_t datalen; /**< length of received packet data */ - uint16_t src_port; /**< source port */ - } recv_info; /**< info on received packet */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* SOCK_TYPES_H */ -/** @} */ diff --git a/pkg/emb6/patches/0001-Add-RIOT-Makefiles.patch b/pkg/emb6/patches/0001-Add-RIOT-Makefiles.patch deleted file mode 100644 index 6854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u?) z%7nLWJyM2WUfd2VW<>HX^rQolmD$Fb?XsA{#zu<&$pzC$nxJu#+2|%Ye@4G1+Cr)y z*gcSEq>1|(?%+>jkRl>MMeJ?nMN_1vERTQExsV`QFxHGMo{10(OG;}rHbg-v?H5~Z zaAE#T&-ej0i^w+aS?&QX3TmX*25mg2g>A{+SGm|AvgywZNFC6qg#+BV zej4x_7EL+YygaQFx4c4SAY*o=2`+7r*_H*f4TYw#XweAdwQodg$$p&{eq&D^CY;2YxDW#-UnG|@n+i6`XUGXjbJGxPBWedu1KYbih)J(e zFBOwX#XPwt4`@ws0HTA0Lb*u#3+c@n%~@A~%*-1b=@VPT+DFTOGo?nlF3+FQs`bud zTA8786`iH?O_+5e8PiGU!3&hD)r1J2kYkL~kG0Q~a9FapD8EG_uB5L>uV<$?&EGUTFF16>(zz zb&=U6LCP652)7`;?aEHjEde?U&m6qH$J<0bon1|US#T!#1Lj&*ikyjs*;WZhvLd&oiY%*4PdE}!PxvU*pU^7=LlOpq5IIBV==9{AlG@Ia|1j})RqXzYn=w>03 Wyh1D}Lw&DWReOz^)2X%g_Wm30gRNo! diff --git a/pkg/emb6/patches/0003-Provide-event-type-for-RIOT-s-sock_.-_send.patch b/pkg/emb6/patches/0003-Provide-event-type-for-RIOT-s-sock_.-_send.patch deleted file mode 100644 index 552871c820c91c3e7f72a2b034c9af4c937046d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1695 zcmb`HZF8DH5Xax&r`VakXc9yYP!uQam>APKMWtdoeH`Y5C86QL0@`Gz{q9}Rs7ahm zGE+uHj=SIP|9`u8o~1FM%7xhyO`|b0bW<}MoHx-ob=7ZZEsjlW`)w0j2*Wf12j`%+ zfb&lE0gZE&ofD=5Ly;9>f?#3dW0u2lEW)T8uSVr)HCo5TTXrT2?7(>z)<84h9A|`4 z4N$d?-t06rkhsb@a~89o=oKCKW}i%Z??G4eA7E$cGV~E}iAe#)?HnOUGnfp<)7LrV zsdw$xkKCMsF(%70gGCWWxe_Lxg3Ec9di5*#0}YTQiC(G@gb{*wC6Y_@YoJ4zf2+QXK`H(R`3<8kl%dh~U>>VN8wrtb8M-FFAQp>5RQ`?D8Jd-lM7$pXh3 z*seXcta6d`%(R?w?}O{~M`tgIWYZeUg1-zHyz((9Yi~#DXguoQ3(s#jF9#GwIfhZX zDj`;S**0sc3X;ids#dwV2Uj__%OhNKi^Ja#dhy(Vx$v&BSi|?_RXO?qWZVN4-aMQ? zLD*P)N1;?&8v=ERhdK2^L=Y-$Kf;VjdlYR<-@&vu7>8O2yflu906}?9l+6W^xFy_1 z*Z9;LymMEs+th@UI~Lt3E3uuqvoq_B+fFTKZUT?U$|$8TwRm)AXNDezOZ3aVX7Xb( zj@uhwjHX*8R7&W%+U;JtND9m#4OX`1)aRgN80-{`1F`V3be~m^>E=4pi|HHZh9{rh z-ic+Mo=_P-NWR+4yWEH3CX7V{A}&Rg5 - */ - -#include - -#include "common.h" - -size_t hex2ints(uint8_t *out, const char *in) -{ - bool upper = true; - size_t out_size = 0; - - while (*in != '\0') { - char c; - if ((*in >= '0') && (*in <= '9')) { - c = '0'; - } - else if ((*in >= 'a') && (*in <= 'f')) { - c = 'a' - 10; - } - else if ((*in >= 'A') && (*in <= 'F')) { - c = 'A' - 10; - } - else { - in++; - continue; - } - if (upper) { - *out = (char)(*in - c) << 4; - } - else { - *out |= (char)(*in - c); - out++; - out_size++; - } - upper = !upper; - in++; - } - if (!upper) { - out_size++; - } - return out_size; -} - -/** @} */ diff --git a/tests/emb6/common.h b/tests/emb6/common.h deleted file mode 100644 index 178aa5adb0..0000000000 --- a/tests/emb6/common.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2016 Martine Lenders - * - * 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. - */ - -/** - * @ingroup tests - * @{ - * - * @file - * @brief Definitions for tests/emb6/ - * - * @author Martine Lenders - */ -#ifndef COMMON_H -#define COMMON_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Application configuration - * @{ - */ -#define SOCK_INBUF_SIZE (256) -#define SERVER_MSG_QUEUE_SIZE (8) -#define SERVER_BUFFER_SIZE (64) -/** - * @} - */ - -/** - * @brief Converts hex string to byte array. - * - * @param[out] out Resulting byte array - * @param[in] in `\0` terminated string. Non-hex characters (all except 0-9, a-f, A-F) - * will be ignored. - * - * @return Length of @p out. - */ -size_t hex2ints(uint8_t *out, const char *in); - -/** - * @brief Ping shell command - * - * @param[in] argc number of arguments - * @param[in] argv array of arguments - * - * @return 0 on success - * @return other on error - */ -int ping_cmd(int argc, char **argv); - -#ifdef MODULE_EMB6_SOCK_UDP -/** - * @brief UDP IP shell command - * - * @param[in] argc number of arguments - * @param[in] argv array of arguments - * - * @return 0 on success - * @return other on error - */ -int udp_cmd(int argc, char **argv); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* COMMON_H */ -/** @} */ diff --git a/tests/emb6/main.c b/tests/emb6/main.c deleted file mode 100644 index adeee367c2..0000000000 --- a/tests/emb6/main.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2015 Martine Lenders - * - * 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. - */ - -/** - * @ingroup examples - * @{ - * - * @file - * @brief Test for raw IPv6 connections - * - * @author Martine Lenders - * - * This test application tests the emb6_conn_ip module. - * - * @} - */ - -#include -#include - -#include "at86rf2xx.h" -#include "at86rf2xx_params.h" -#include "common.h" -#include "emb6.h" -#include "emb6/netdev.h" -#include "uip-ds6.h" -#include "net/ipv6/addr.h" -#include "shell.h" -#include "thread.h" -#include "xtimer.h" - -#define EMB6_STACKSIZE (THREAD_STACKSIZE_DEFAULT) -#define EMB6_PRIO (THREAD_PRIORITY_MAIN - 3) -#define EMB6_DELAY (500) - -static at86rf2xx_t at86rf2xx; -static s_ns_t emb6 = { - .hc = &sicslowpan_driver, - .llsec = &nullsec_driver, - .hmac = &nullmac_driver, - .lmac = &sicslowmac_driver, - .frame = &framer_802154, - .c_configured = 1, -}; -static char emb6_stack[EMB6_STACKSIZE]; - -static int ifconfig(int argc, char **argv) -{ - (void)argc; - (void)argv; - char addrstr[IPV6_ADDR_MAX_STR_LEN]; - printf("0: "); - for (int i = 0; i < UIP_DS6_ADDR_NB; i++) { - if (uip_ds6_if.addr_list[i].isused) { - printf("inet6 %s\n", - ipv6_addr_to_str(addrstr, - (ipv6_addr_t *)&uip_ds6_if.addr_list[i].ipaddr, - sizeof(addrstr))); - if (i != 0) { - printf(" "); - } - } - } - puts(""); - return 0; -} - -static void *_emb6_thread(void *args) -{ - (void)args; - - emb6_process(500); /* never stops */ - return NULL; -} - -static const shell_command_t shell_commands[] = { - { "ping6", "Send pings and receive pongs", ping_cmd }, -#ifdef MODULE_EMB6_SOCK_UDP - { "udp", "Send UDP messages and listen for messages on UDP port", udp_cmd }, -#endif - { "ifconfig", "Shows assigned IPv6 addresses", ifconfig }, - { NULL, NULL, NULL } -}; - -static char line_buf[SHELL_DEFAULT_BUFSIZE]; - -int main(void) -{ - netdev_t *netdev = (netdev_t *)&at86rf2xx; - - puts("RIOT emb6 test application"); - - at86rf2xx_setup(&at86rf2xx, at86rf2xx_params); - netdev->driver->init((netdev_t *)&at86rf2xx); - emb6_netdev_setup(netdev); - emb6_init(&emb6); - thread_create(emb6_stack, sizeof(emb6_stack), EMB6_PRIO, - THREAD_CREATE_STACKTEST, _emb6_thread, NULL, "emb6"); - shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); - - /* should be never reached */ - return 0; -} diff --git a/tests/emb6/ping.c b/tests/emb6/ping.c deleted file mode 100644 index e83f9d64e6..0000000000 --- a/tests/emb6/ping.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -/** - * @ingroup examples - * @{ - * - * @file - * @brief Demonstrating the sending and receiving of UDP data over POSIX sockets. - * - * @author Martine Lenders - * - * @} - */ - -#include -#include -#include -#include -#include - -#include "byteorder.h" -#include "net/icmpv6.h" -#include "net/ipv6.h" -#include "xtimer.h" - -#include "uip.h" -#include "uip-icmp6.h" - -#include "common.h" - -#define ECHO_ID (0xd1e9) - -static struct uip_icmp6_echo_reply_notification recv_ntfy = { NULL, NULL }; -static uint16_t seq = 0; -static atomic_int received = ATOMIC_VAR_INIT(0); -static atomic_int num = ATOMIC_VAR_INIT(0); - -static bool _waiting = true; - -static inline icmpv6_echo_t *uip_icmp_buf(void) -{ - return ((icmpv6_echo_t *)&uip_buf[uip_l2_l3_hdr_len]); -} - -static inline int max_len(void) -{ - return UIP_BUFSIZE - (((uint8_t *)uip_icmp_buf()) - uip_buf) - - sizeof(icmpv6_echo_t); -} - -static int ping_send(const uip_ipaddr_t *dst, int payload_len) -{ - int len = payload_len; - icmpv6_echo_t *ping = uip_icmp_buf(); - - ping->id = byteorder_htons(ECHO_ID); - - if (payload_len > max_len()) { - puts("Payload too long for buffer."); - return -1; - } - - for (network_uint16_t *payload = (network_uint16_t *)(ping + 1); - len >= 0; - payload++, len -= 2) { - *payload = byteorder_htons(seq); - } - - ping->seq = byteorder_htons(seq++); - - uip_icmp6_send((const uip_ipaddr_t *)dst, ICMPV6_ECHO_REQ, 0, - payload_len + (sizeof(icmpv6_echo_t) - sizeof(icmpv6_hdr_t))); - - return 0; -} - -static void handle_reply(uip_ipaddr_t *source, uint8_t ttl, uint8_t *data, - uint16_t datalen) -{ - char addr_str[IPV6_ADDR_MAX_STR_LEN]; - icmpv6_echo_t *ping = (icmpv6_echo_t *)data; - - _waiting = false; - - ipv6_addr_to_str(addr_str, (ipv6_addr_t *)source, sizeof(addr_str)); - - atomic_fetch_add(&received, 1); - printf("%" PRIu16 " bytes from %s: icmp_seq=%" PRIu16 " ttl=%u quota=%i/%i\n", - datalen, addr_str, byteorder_ntohs(ping->seq), (unsigned)ttl, - atomic_load(&received), atomic_load(&num)); -} - -void usage(char *cmd) -{ - printf("usage: %s [] []\n", cmd); -} - -int ping_cmd(int argc, char **argv) -{ - ipv6_addr_t dst; - int payload_len, _num; - - if ((argc < 2) || (ipv6_addr_from_str(&dst, argv[1]) == NULL)) { - usage(argv[0]); - return 1; - } - if ((argc < 3) || ((_num = atoi(argv[2])) == 0)) { - _num = 3; - } - if ((argc < 4) || ((payload_len = atoi(argv[3])) == 0)) { - payload_len = 16; - } - atomic_store(&num, _num); - atomic_store(&received, 0); - seq = 0; - if (recv_ntfy.callback == NULL) { - uip_icmp6_echo_reply_callback_add(&recv_ntfy, handle_reply); - } - for (uint16_t i = 0; i < _num; i++) { - _waiting = true; - ping_send((uip_ipaddr_t *)&dst, payload_len); - xtimer_usleep(1000000); - if (_waiting) { - puts("Timeout"); - } - } - - return 0; -} - -/** @} */ diff --git a/tests/emb6/udp.c b/tests/emb6/udp.c deleted file mode 100644 index 10930fcd9c..0000000000 --- a/tests/emb6/udp.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -/** - * @ingroup examples - * @{ - * - * @file - * @brief Demonstrating the sending and receiving of UDP data over POSIX sockets. - * - * @author Martine Lenders - * - * @} - */ - -#include -#include -#include - -#include "common.h" -#include "od.h" -#include "net/af.h" -#include "net/sock/udp.h" -#include "net/ipv6.h" -#include "thread.h" -#include "xtimer.h" - -#ifdef MODULE_EMB6_SOCK_UDP -static char sock_inbuf[SOCK_INBUF_SIZE]; -static bool server_running; -static sock_udp_t server_sock; -static char server_stack[THREAD_STACKSIZE_DEFAULT]; - -static void *_server_thread(void *args) -{ - int res; - - /* parse port */ - uint16_t port = atoi(args); - const sock_udp_ep_t server_addr = { .family = AF_INET6, - .port = port }; - if ((res = sock_udp_create(&server_sock, &server_addr, NULL, 0)) < 0) { - printf("Unable to open UDP server on port %" PRIu16 " (error code %d)\n", - port, -res); - return NULL; - } - server_running = true; - printf("Success: started UDP server on port %" PRIu16 "\n", port); - while (1) { - sock_udp_ep_t client_addr; - - if ((res = sock_udp_recv(&server_sock, sock_inbuf, sizeof(sock_inbuf), - SOCK_NO_TIMEOUT, &client_addr)) < 0) { - puts("Error on receive"); - } - else if (res == 0) { - puts("No data received"); - } - else { - char addrstr[IPV6_ADDR_MAX_STR_LEN]; - printf("Received from [%s]:%" PRIu16 ":\n", - ipv6_addr_to_str(addrstr, (ipv6_addr_t *)&client_addr.addr, - sizeof(addrstr)), client_addr.port); - od_hex_dump(sock_inbuf, res, 0); - } - } - return NULL; -} - -static int udp_send(char *addr_str, char *port_str, char *data, unsigned int num, - unsigned int delay) -{ - uint8_t byte_data[strlen(data) / 2]; - sock_udp_ep_t dst = { .family = AF_INET6 }; - size_t data_len; - - /* parse destination address */ - if (ipv6_addr_from_str((ipv6_addr_t *)&dst.addr, addr_str) == NULL) { - puts("Error: unable to parse destination address"); - return 1; - } - /* parse port */ - dst.port = atoi(port_str); - data_len = hex2ints(byte_data, data); - for (unsigned int i = 0; i < num; i++) { - if (sock_udp_send(NULL, byte_data, data_len, &dst) < 0) { - puts("could not send"); - } - else { - printf("Success: send %u byte to [%s]:%" PRIu16 ")\n", - (unsigned)data_len, addr_str, dst.port); - } - xtimer_usleep(delay); - } - return 0; -} - -static int udp_start_server(char *port_str) -{ - if (thread_create(server_stack, sizeof(server_stack), THREAD_PRIORITY_MAIN - 1, - THREAD_CREATE_STACKTEST, _server_thread, port_str, - "UDP server") <= KERNEL_PID_UNDEF) { - return 1; - } - return 0; -} - -int udp_cmd(int argc, char **argv) -{ - if (argc < 2) { - printf("usage: %s [send|server]\n", argv[0]); - return 1; - } - - if (strcmp(argv[1], "send") == 0) { - uint32_t num = 1; - uint32_t delay = 1000000; - if (argc < 5) { - printf("usage: %s send [ []]\n", - argv[0]); - return 1; - } - if (argc > 5) { - num = atoi(argv[5]); - } - if (argc > 6) { - delay = atoi(argv[6]); - } - return udp_send(argv[2], argv[3], argv[4], num, delay); - } - else if (strcmp(argv[1], "server") == 0) { - if (argc < 3) { - printf("usage: %s server [start|stop]\n", argv[0]); - return 1; - } - if (strcmp(argv[2], "start") == 0) { - if (argc < 4) { - printf("usage %s server start \n", argv[0]); - return 1; - } - return udp_start_server(argv[3]); - } - else { - puts("error: invalid command"); - return 1; - } - } - else { - puts("error: invalid command"); - return 1; - } -} -#else -typedef int dont_be_pedantic; -#endif - -/** @} */