diff --git a/Makefile.dep b/Makefile.dep index 6654a948fb..7aef140320 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -55,14 +55,6 @@ ifneq (,$(filter gnrc_%,$(filter-out gnrc_netapi gnrc_netreg gnrc_netif% gnrc_pk USEMODULE += gnrc endif -ifneq (,$(filter gnrc_conn_%,$(USEMODULE))) - USEMODULE += gnrc_conn -endif - -ifneq (,$(filter gnrc_conn_udp,$(USEMODULE))) - USEMODULE += gnrc_udp -endif - ifneq (,$(filter gnrc_sock_%,$(USEMODULE))) USEMODULE += gnrc_sock endif @@ -412,18 +404,6 @@ ifneq (,$(filter lwip_udplite,$(USEMODULE))) USEMODULE += lwip_udp endif -ifneq (,$(filter lwip_conn_%,$(USEMODULE))) - USEMODULE += lwip_conn -endif - -ifneq (,$(filter lwip_conn_ip,$(USEMODULE))) - USEMODULE += lwip_raw -endif - -ifneq (,$(filter lwip_conn_udp,$(USEMODULE))) - USEMODULE += lwip_udp -endif - ifneq (,$(filter lwip_sock_%,$(USEMODULE))) USEMODULE += lwip_sock endif @@ -495,22 +475,6 @@ ifneq (,$(filter oonf_common,$(USEMODULE))) USEMODULE += posix_sockets endif -ifneq (,$(filter %_conn_ip,$(USEMODULE))) - USEMODULE += conn_ip -endif - -ifneq (,$(filter %_conn_tcp,$(USEMODULE))) - USEMODULE += conn_tcp -endif - -ifneq (,$(filter %_conn_udp,$(USEMODULE))) - USEMODULE += conn_udp -endif - -ifneq (,$(filter conn_%,$(USEMODULE))) - USEMODULE += conn -endif - # if any log_* is used, also use LOG pseudomodule ifneq (,$(filter log_%,$(USEMODULE))) USEMODULE += log diff --git a/examples/microcoap_server/microcoap_sock.c b/examples/microcoap_server/microcoap_sock.c index 52e148627f..3c989de732 100644 --- a/examples/microcoap_server/microcoap_sock.c +++ b/examples/microcoap_server/microcoap_sock.c @@ -46,7 +46,7 @@ void microcoap_server_loop(void) rc = sock_udp_recv(&sock, (char *)_udp_buf, sizeof(_udp_buf), SOCK_NO_TIMEOUT, &remote); if (rc < 0) { - DEBUG("Error in conn_udp_recvfrom(). rc=%u\n", rc); + DEBUG("Error in sock_udp_recv(). rc=%u\n", rc); continue; } diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 0ecf459a02..d922c62116 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -1,8 +1,4 @@ PSEUDOMODULES += auto_init_gnrc_rpl -PSEUDOMODULES += conn -PSEUDOMODULES += conn_ip -PSEUDOMODULES += conn_tcp -PSEUDOMODULES += conn_udp PSEUDOMODULES += core_% PSEUDOMODULES += emb6_router PSEUDOMODULES += gnrc_ipv6_default diff --git a/pkg/emb6/Makefile.dep b/pkg/emb6/Makefile.dep index 9d1c709d44..bd033e4534 100644 --- a/pkg/emb6/Makefile.dep +++ b/pkg/emb6/Makefile.dep @@ -1,7 +1,3 @@ -ifneq (,$(filter emb6_conn_udp,$(USEMODULE))) - USEMODULE += emb6_sock -endif - ifneq (,$(filter emb6_sock_%,$(USEMODULE))) USEMODULE += core_mbox USEMODULE += emb6_sock diff --git a/pkg/emb6/Makefile.include b/pkg/emb6/Makefile.include index 34308ae713..ab9e85a0e4 100644 --- a/pkg/emb6/Makefile.include +++ b/pkg/emb6/Makefile.include @@ -22,10 +22,6 @@ ifneq (,$(filter emb6_contrib,$(USEMODULE))) DIRS += $(EMB6_CONTRIB) endif -ifneq (,$(filter emb6_conn_udp,$(USEMODULE))) - DIRS += $(EMB6_CONTRIB)/conn/udp -endif - ifneq (,$(filter emb6_ipv6,$(USEMODULE))) DIRS += $(EMB6_DIR)/emb6/src/net/ipv6 INCLUDES += -I$(EMB6_DIR)/emb6/inc/net/ipv6 diff --git a/pkg/emb6/contrib/conn/udp/Makefile b/pkg/emb6/contrib/conn/udp/Makefile deleted file mode 100644 index e5dbafaedd..0000000000 --- a/pkg/emb6/contrib/conn/udp/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = emb6_conn_udp - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/emb6/contrib/conn/udp/emb6_conn_udp.c b/pkg/emb6/contrib/conn/udp/emb6_conn_udp.c deleted file mode 100644 index c0661cb08e..0000000000 --- a/pkg/emb6/contrib/conn/udp/emb6_conn_udp.c +++ /dev/null @@ -1,245 +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 "evproc.h" -#include "msg.h" -#include "mutex.h" -#include "net/af.h" -#include "net/conn/udp.h" -#include "net/ipv6/hdr.h" -#include "sched.h" -#include "uip.h" - -#define _MSG_TYPE_CLOSE (0x4123) -#define _MSG_TYPE_RCV (0x4124) - -/* struct to describe a sendto command for emb6 thread */ -typedef struct { - struct udp_socket sock; - mutex_t mutex; - const void *data; - int res; - uint16_t data_len; -} _send_cmd_t; - -extern uint16_t uip_slen; - -static bool send_registered = false; - -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_and_bind(struct udp_socket *c, void *ptr, - udp_socket_input_callback_t cb, uint16_t port) -{ - if (udp_socket_register(c, ptr, cb) < 0) { - return -EMFILE; - } - if (udp_socket_bind(c, port) < 0) { - udp_socket_close(c); - return -EALREADY; - } - return 0; -} - -int conn_udp_create(conn_udp_t *conn, const void *addr, size_t addr_len, - int family, uint16_t port) -{ - int res; - - (void)addr; - (void)addr_len; - if (family != AF_INET6) { - return -EAFNOSUPPORT; - } - if (conn->sock.input_callback != NULL) { - return -EINVAL; - } - mutex_init(&conn->mutex); - mutex_lock(&conn->mutex); - if ((res = _reg_and_bind(&conn->sock, conn, _input_callback, port)) < 0) { - conn->sock.input_callback = NULL; - mutex_unlock(&conn->mutex); - return res; - } - conn->waiting_thread = KERNEL_PID_UNDEF; - mutex_unlock(&conn->mutex); - return 0; -} - -void conn_udp_close(conn_udp_t *conn) -{ - if (conn->sock.input_callback != NULL) { - mutex_lock(&conn->mutex); - if (conn->waiting_thread != KERNEL_PID_UNDEF) { - msg_t msg; - msg.type = _MSG_TYPE_CLOSE; - msg.content.ptr = conn; - mutex_unlock(&conn->mutex); - msg_send(&msg, conn->waiting_thread); - mutex_lock(&conn->mutex); - } - udp_socket_close(&conn->sock); - conn->sock.input_callback = NULL; - mutex_unlock(&conn->mutex); - } -} - -int conn_udp_getlocaladdr(conn_udp_t *conn, void *addr, uint16_t *port) -{ - if (conn->sock.input_callback != NULL) { - mutex_lock(&conn->mutex); - memset(addr, 0, sizeof(ipv6_addr_t)); - *port = ntohs(conn->sock.udp_conn->lport); - mutex_unlock(&conn->mutex); - return sizeof(ipv6_addr_t); - } - return -EBADF; -} - -int conn_udp_recvfrom(conn_udp_t *conn, void *data, size_t max_len, void *addr, - size_t *addr_len, uint16_t *port) -{ - int res = -EIO; - msg_t msg; - - if (conn->sock.input_callback == NULL) { - return -ENOTSOCK; - } - mutex_lock(&conn->mutex); - if (conn->waiting_thread != KERNEL_PID_UNDEF) { - mutex_unlock(&conn->mutex); - return -EALREADY; - } - conn->waiting_thread = sched_active_pid; - mutex_unlock(&conn->mutex); - msg_receive(&msg); - if (msg.type == _MSG_TYPE_CLOSE) { - conn->waiting_thread = KERNEL_PID_UNDEF; - return -EINTR; - } - else if (msg.type == _MSG_TYPE_RCV) { - mutex_lock(&conn->mutex); - if (msg.content.ptr == conn) { - if (max_len < conn->recv_info.datalen) { - conn->waiting_thread = KERNEL_PID_UNDEF; - mutex_unlock(&conn->mutex); - return -ENOBUFS; - } - memcpy(data, conn->recv_info.data, conn->recv_info.datalen); - memcpy(addr, conn->recv_info.src, sizeof(ipv6_addr_t)); - *addr_len = sizeof(ipv6_addr_t); - *port = conn->recv_info.src_port; - res = (int)conn->recv_info.datalen; - } - conn->waiting_thread = KERNEL_PID_UNDEF; - mutex_unlock(&conn->mutex); - } - return res; -} - -int conn_udp_sendto(const void *data, size_t len, const void *src, size_t src_len, - const void *dst, size_t dst_len, int family, uint16_t sport, - uint16_t dport) -{ - int res; - _send_cmd_t send_cmd; - - if (!send_registered) { - if (evproc_regCallback(EVENT_TYPE_CONN_SEND, _output_callback) != E_SUCCESS) { - return -EIO; - } - else { - send_registered = true; - } - } - mutex_init(&send_cmd.mutex); - if ((len > (UIP_BUFSIZE - (UIP_LLH_LEN + UIP_IPUDPH_LEN))) || - (len > UINT16_MAX)) { - return -EMSGSIZE; - } - if ((dst_len > sizeof(ipv6_addr_t)) || (family != AF_INET6)) { - return -EAFNOSUPPORT; - } - mutex_lock(&send_cmd.mutex); - send_cmd.data = data; - send_cmd.data_len = (uint16_t)len; - if ((res = _reg_and_bind(&send_cmd.sock, NULL, NULL, sport)) < 0) { - mutex_unlock(&send_cmd.mutex); - return res; - } - udp_socket_connect(&send_cmd.sock, (uip_ipaddr_t *)dst, dport); /* can't fail at this point */ - /* change to emb6 thread context */ - if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_CONN_SEND, &send_cmd) != E_SUCCESS) { - udp_socket_close(&send_cmd.sock); - mutex_unlock(&send_cmd.mutex); - return -EIO; - } - /* block thread until data was send */ - mutex_lock(&send_cmd.mutex); - udp_socket_close(&send_cmd.sock); - mutex_unlock(&send_cmd.mutex); - - return send_cmd.res; -} - -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) -{ - conn_udp_t *conn = ptr; - - (void)dst_addr; - (void)dst_port; - mutex_lock(&conn->mutex); - if (conn->waiting_thread != KERNEL_PID_UNDEF) { - msg_t msg; - conn->recv_info.src_port = src_port; - conn->recv_info.src = (const ipv6_addr_t *)src_addr; - conn->recv_info.data = data; - conn->recv_info.datalen = datalen - sizeof(ipv6_hdr_t); - msg.type = _MSG_TYPE_RCV; - msg.content.ptr = conn; - mutex_unlock(&conn->mutex); - msg_send(&msg, conn->waiting_thread); - } - else { - mutex_unlock(&conn->mutex); - } -} - -static void _output_callback(c_event_t c_event, p_data_t p_data) -{ - if ((c_event != EVENT_TYPE_CONN_SEND) || (p_data == NULL)) { - return; - } - - _send_cmd_t *send_cmd = (_send_cmd_t *)p_data; - - if ((send_cmd->res = udp_socket_send(&send_cmd->sock, send_cmd->data, send_cmd->data_len)) < 0) { - send_cmd->res = -EHOSTUNREACH; - } - mutex_unlock(&send_cmd->mutex); -} - -/** @} */ diff --git a/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c b/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c index e981444c18..20664c80b0 100644 --- a/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c +++ b/pkg/emb6/contrib/sock/udp/emb6_sock_udp.c @@ -213,7 +213,7 @@ int sock_udp_send(sock_udp_t *sock, const void *data, size_t len, /* 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_CONN_SEND, _output_callback) != E_SUCCESS) { + if (evproc_regCallback(EVENT_TYPE_SOCK_SEND, _output_callback) != E_SUCCESS) { return -ENOMEM; } else { @@ -253,7 +253,7 @@ int sock_udp_send(sock_udp_t *sock, const void *data, size_t len, } mutex_lock(&send_cmd.block); /* change to emb6 thread context */ - if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_CONN_SEND, &send_cmd) == E_SUCCESS) { + 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); } @@ -301,7 +301,7 @@ static void _input_callback(struct udp_socket *c, void *ptr, static void _output_callback(c_event_t c_event, p_data_t p_data) { - if ((c_event != EVENT_TYPE_CONN_SEND) || (p_data == NULL)) { + if ((c_event != EVENT_TYPE_SOCK_SEND) || (p_data == NULL)) { return; } diff --git a/pkg/emb6/include/emb6/conn/udp.h b/pkg/emb6/include/emb6/conn/udp.h deleted file mode 100644 index 07386f59f8..0000000000 --- a/pkg/emb6/include/emb6/conn/udp.h +++ /dev/null @@ -1,62 +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 emb6_conn_udp udp_conn wrapper for emb6 - * @ingroup emb6 - * @brief UDP conn for emb6 - * - * For this implementation to receive with an open connection only with one - * thread at once. If you use @ref conn_udp_recvfrom() with more than one thread - * simultaneously, it will return `-EALREADY`. - * - * @{ - * - * @file - * @brief UDP conn definitions - * - * @author Martine Lenders - */ -#ifndef EMB6_CONN_UDP_H -#define EMB6_CONN_UDP_H - -#include - -#include "kernel_types.h" -#include "mutex.h" -#include "net/ipv6/addr.h" - -#include "uip.h" -#include "udp-socket.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief @ref net_conn_udp definition for emb6 - */ -struct conn_udp { - struct udp_socket sock; /**< emb6 internal socket */ - mutex_t mutex; /**< mutex for the connection */ - kernel_pid_t waiting_thread; /**< thread waiting for an incoming packet - * on this connection */ - struct { - uint16_t src_port; /**< source port */ - const ipv6_addr_t *src; /**< source address */ - const void *data; /**< data of received packet */ - size_t datalen; /**< length of received packet data */ - } recv_info; /**< info on received packet */ -}; - -#ifdef __cplusplus -} -#endif - -#endif /* EMB6_CONN_UDP_H */ -/** @} */ diff --git a/pkg/emb6/patches/0004-Provide-event-type-for-RIOT-s-conn_.-_send.patch b/pkg/emb6/patches/0004-Provide-event-type-for-RIOT-s-conn_.-_send.patch index ba76384872..ecbad3b6d5 100644 Binary files a/pkg/emb6/patches/0004-Provide-event-type-for-RIOT-s-conn_.-_send.patch and b/pkg/emb6/patches/0004-Provide-event-type-for-RIOT-s-conn_.-_send.patch differ diff --git a/pkg/lwip/Makefile.include b/pkg/lwip/Makefile.include index a570711e61..2d6f97bb2c 100644 --- a/pkg/lwip/Makefile.include +++ b/pkg/lwip/Makefile.include @@ -1,15 +1,6 @@ INCLUDES += -I$(RIOTBASE)/pkg/lwip/include \ -I$(PKGDIRBASE)/lwip/src/include -ifneq (,$(filter lwip_conn,$(USEMODULE))) - DIRS += $(RIOTBASE)/pkg/lwip/contrib/conn -endif -ifneq (,$(filter lwip_conn_ip,$(USEMODULE))) - DIRS += $(RIOTBASE)/pkg/lwip/contrib/conn/ip -endif -ifneq (,$(filter lwip_conn_udp,$(USEMODULE))) - DIRS += $(RIOTBASE)/pkg/lwip/contrib/conn/udp -endif ifneq (,$(filter lwip_contrib,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/lwip/contrib endif diff --git a/pkg/lwip/contrib/conn/Makefile b/pkg/lwip/contrib/conn/Makefile deleted file mode 100644 index e89c126dda..0000000000 --- a/pkg/lwip/contrib/conn/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE := lwip_conn - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/lwip/contrib/conn/ip/Makefile b/pkg/lwip/contrib/conn/ip/Makefile deleted file mode 100644 index 0e758e17e1..0000000000 --- a/pkg/lwip/contrib/conn/ip/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE := lwip_conn_ip - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/lwip/contrib/conn/ip/lwip_conn_ip.c b/pkg/lwip/contrib/conn/ip/lwip_conn_ip.c deleted file mode 100644 index f30d93b1ee..0000000000 --- a/pkg/lwip/contrib/conn/ip/lwip_conn_ip.c +++ /dev/null @@ -1,73 +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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include -#include - -#include "net/ipv4/addr.h" -#include "net/ipv6/addr.h" -#include "net/conn/ip.h" - -#include "lwip/api.h" -#include "lwip/conn.h" - -int conn_ip_create(conn_ip_t *conn, const void *addr, size_t addr_len, int family, int proto) -{ - struct netconn *tmp; - int res; - - res = lwip_conn_create(&tmp, addr, addr_len, family, NETCONN_RAW, proto, 0); - if (res < 0) { - return res; - } - conn->lwip_conn = tmp; - - return res; -} - -void conn_ip_close(conn_ip_t *conn) -{ - assert(conn != NULL); - netconn_delete(conn->lwip_conn); -} - -int conn_ip_getlocaladdr(conn_ip_t *conn, void *addr) -{ - assert(conn != NULL); - return lwip_conn_getlocaladdr(conn->lwip_conn, addr, NULL); -} - -int conn_ip_recvfrom(conn_ip_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len) -{ - assert(conn != NULL); - return lwip_conn_recvfrom(conn->lwip_conn, data, max_len, addr, addr_len, NULL); -} - -int conn_ip_sendto(const void *data, size_t len, const void *src, size_t src_len, - void *dst, size_t dst_len, int family, int proto) -{ - struct netconn *tmp; - int res; - - res = lwip_conn_create(&tmp, src, src_len, family, NETCONN_RAW, proto, 0); - if (res < 0) { - return res; - } - res = lwip_conn_sendto(tmp, data, len, dst, dst_len, 0); - netconn_delete(tmp); - return res; -} - -/** @} */ diff --git a/pkg/lwip/contrib/conn/lwip_conn.c b/pkg/lwip/contrib/conn/lwip_conn.c deleted file mode 100644 index 589a0032cb..0000000000 --- a/pkg/lwip/contrib/conn/lwip_conn.c +++ /dev/null @@ -1,206 +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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include -#include - -#include "byteorder.h" -#include "net/af.h" -#include "net/ipv4/addr.h" -#include "net/ipv6/addr.h" -#include "net/conn.h" - -#include "lwip/api.h" -#include "lwip/opt.h" - -int lwip_conn_create(struct netconn **netconn, const void *addr, size_t addr_len, int family, - int type, int proto, uint16_t port) -{ - struct netconn *tmp; - int res = 0; - - switch (family) { -#if LWIP_IPV4 - case AF_INET: - if (addr_len != sizeof(ipv4_addr_t)) { - return -EINVAL; - } - break; -#endif -#if LWIP_IPV6 - case AF_INET6: - if (addr_len != sizeof(ipv6_addr_t)) { - return -EINVAL; - } - type |= NETCONN_TYPE_IPV6; - break; -#endif - default: - return -EAFNOSUPPORT; - } - if ((tmp = netconn_new_with_proto_and_callback(type, proto, NULL)) == NULL) { - return -ENOMEM; - } - switch (netconn_bind(tmp, (ip_addr_t *)addr, port)) { - case ERR_USE: - netconn_delete(tmp); - res = -EADDRINUSE; - break; - case ERR_VAL: - netconn_delete(tmp); - res = -EINVAL; - break; - default: - break; - } - *netconn = tmp; - return res; -} - -int lwip_conn_getlocaladdr(struct netconn *netconn, void *addr, uint16_t *port) -{ - uint16_t tmp; - - if (netconn_getaddr(netconn, addr, &tmp, 1) != ERR_OK) { - return -EOPNOTSUPP; - } - if (port != NULL) { - *port = tmp; - } -#if LWIP_IPV6 - if (netconn->type & NETCONN_TYPE_IPV6) { - return sizeof(ipv6_addr_t); - } -#endif -#if LWIP_IPV4 - return sizeof(ipv4_addr_t); -#else - return -EOPNOTSUPP; -#endif -} - -int lwip_conn_recvfrom(struct netconn *netconn, void *data, size_t max_len, void *addr, - size_t *addr_len, uint16_t *port) -{ - struct netbuf *buf; - size_t len = 0; - err_t res = 0; - uint8_t *data_ptr = data; - - if (netconn == NULL) { - return -ENOTSOCK; - } - if ((res = netconn_recv(netconn, &buf))) { - switch (res) { -#if LWIP_SO_RCVTIMEO - case ERR_TIMEOUT: - return -ETIMEDOUT; -#endif - case ERR_MEM: - return -ENOMEM; - default: - return -EIO; - } - } - len = buf->p->tot_len; - if (len > max_len) { - netbuf_delete(buf); - return -ENOBUFS; - } -#if LWIP_IPV6 - if (netconn->type & NETCONN_TYPE_IPV6) { - *addr_len = sizeof(ipv6_addr_t); - } - else { -#endif -#if LWIP_IPV4 - *addr_len = sizeof(ipv4_addr_t); -#else - netbuf_delete(buf); - return -EOPNOTSUPP; -#endif -#if LWIP_IPV6 - } -#endif - /* copy address */ - memcpy(addr, &buf->addr, *addr_len); - /* copy port */ - if (port != NULL) { - *port = buf->port; - } - /* copy data */ - for (struct pbuf *q = buf->p; q != NULL; q = q->next) { - memcpy(data_ptr, q->payload, q->len); - data_ptr += q->len; - } - - netbuf_delete(buf); - - return (int)len; -} - -int lwip_conn_sendto(struct netconn *netconn, const void *data, size_t len, - const void *addr, size_t addr_len, uint16_t port) -{ - struct netbuf *buf; - int res; - -#if LWIP_IPV6 - if (netconn->type & NETCONN_TYPE_IPV6) { - if (addr_len != sizeof(ipv6_addr_t)) { - return -EINVAL; - } - } - else { -#endif -#if LWIP_IPV4 - if (addr_len != sizeof(ipv4_addr_t)) { - return -EINVAL; - } -#endif -#if LWIP_IPV6 - } -#endif - buf = netbuf_new(); - if ((buf == NULL) || (netbuf_alloc(buf, len) == NULL)) { - netbuf_delete(buf); - return -ENOMEM; - } - if (netbuf_take(buf, data, len) != ERR_OK) { - netbuf_delete(buf); - return -ENOBUFS; - } - switch ((res = netconn_sendto(netconn, buf, addr, port))) { - case ERR_OK: - res = len; - break; - case ERR_RTE: - res = -EHOSTUNREACH; - break; - case ERR_VAL: - res = -EINVAL; - break; - case ERR_IF: - res = -EAFNOSUPPORT; - break; - default: - res = -EIO; - break; - } - netbuf_delete(buf); - return res; -} - -/** @} */ diff --git a/pkg/lwip/contrib/conn/udp/Makefile b/pkg/lwip/contrib/conn/udp/Makefile deleted file mode 100644 index 4ebff9f544..0000000000 --- a/pkg/lwip/contrib/conn/udp/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE := lwip_conn_udp - -include $(RIOTBASE)/Makefile.base diff --git a/pkg/lwip/contrib/conn/udp/lwip_conn_udp.c b/pkg/lwip/contrib/conn/udp/lwip_conn_udp.c deleted file mode 100644 index 1c37ed0a60..0000000000 --- a/pkg/lwip/contrib/conn/udp/lwip_conn_udp.c +++ /dev/null @@ -1,75 +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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include -#include - -#include "net/ipv4/addr.h" -#include "net/ipv6/addr.h" -#include "net/conn/udp.h" - -#include "lwip/api.h" -#include "lwip/conn.h" - -int conn_udp_create(conn_udp_t *conn, const void *addr, size_t addr_len, int family, uint16_t port) -{ - struct netconn *tmp; - int res; - - res = lwip_conn_create(&tmp, addr, addr_len, family, NETCONN_UDP, 0, port); - if (res < 0) { - return res; - } - conn->lwip_conn = tmp; - - return res; -} - -void conn_udp_close(conn_udp_t *conn) -{ - assert(conn != NULL); - netconn_delete(conn->lwip_conn); -} - -int conn_udp_getlocaladdr(conn_udp_t *conn, void *addr, uint16_t *port) -{ - assert(conn != NULL); - return lwip_conn_getlocaladdr(conn->lwip_conn, addr, port); -} - -int conn_udp_recvfrom(conn_udp_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, - uint16_t *port) -{ - assert(conn != NULL); - return lwip_conn_recvfrom(conn->lwip_conn, data, max_len, addr, addr_len, port); -} - -int conn_udp_sendto(const void *data, size_t len, const void *src, size_t src_len, - const void *dst, size_t dst_len, int family, uint16_t sport, - uint16_t dport) -{ - struct netconn *tmp; - int res; - - res = lwip_conn_create(&tmp, src, src_len, family, NETCONN_UDP, 0, sport); - if (res < 0) { - return res; - } - res = lwip_conn_sendto(tmp, data, len, dst, dst_len, dport); - netconn_delete(tmp); - return res; -} - -/** @} */ diff --git a/pkg/lwip/include/lwip/conn.h b/pkg/lwip/include/lwip/conn.h deleted file mode 100644 index 4f815cb62d..0000000000 --- a/pkg/lwip/include/lwip/conn.h +++ /dev/null @@ -1,93 +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. - */ - -/** - * @defgroup pkg_lwip_conn Connection type definitions for lwIP - * @ingroup pkg_lwip - * @{ - * - * @file - * - * @author Martine Lenders - */ -#ifndef LWIP_CONN_H -#define LWIP_CONN_H - -#include "lwip/api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Generic @ref net_conn object for lwIP (used internally) - */ -struct conn { - struct netconn *lwip_conn; /**< stack-internal connection object */ -}; - -/** - * @brief @ref net_conn_ip definition for lwIP - */ -struct conn_ip { - struct netconn *lwip_conn; /**< stack-internal connection object */ -}; - -/** - * @brief @ref net_conn_udp definition for lwIP - */ -struct conn_udp { - struct netconn *lwip_conn; /**< stack-internal connection object */ -}; - -/** - * @brief Internal consolidation functions - * @{ - */ -/** - * @brief consolidation function for @ref conn_ip_create() and @ref - * conn_udp_create() - * - * @internal - */ -int lwip_conn_create(struct netconn **netconn, const void *addr, size_t addr_len, - int family, int type, int proto, uint16_t port); - -/** - * @brief consolidation function for @ref conn_ip_getlocaladdr() and @ref - * conn_udp_getlocaladdr() - * - * @internal - */ -int lwip_conn_getlocaladdr(struct netconn *netconn, void *addr, uint16_t *port); - -/** - * @brief consolidation function for @ref conn_ip_recvfrom() and @ref - * conn_udp_recvfrom() - * - * @internal - */ -int lwip_conn_recvfrom(struct netconn *netconn, void *data, size_t max_len, - void *addr, size_t *addr_len, uint16_t *port); - -/** - * @brief consolidation function for @ref conn_ip_sendto() and @ref - * conn_udp_sendto() - * - * @internal - */ -int lwip_conn_sendto(struct netconn *netconn, const void *data, size_t len, - const void *addr, size_t addr_len, uint16_t port); -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_CONN_H */ -/** @} */ diff --git a/sys/include/net/conn.h b/sys/include/net/conn.h deleted file mode 100644 index 7ea944f3c0..0000000000 --- a/sys/include/net/conn.h +++ /dev/null @@ -1,105 +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. - */ - -/** - * @defgroup net_conn Application connection API - * @ingroup net - * @deprecated Please use @ref net_sock instead - * @brief Provides a minimal common API for applications to connect to the - * different network stacks. - * - * About - * ===== - * - * ~~~~~~~~~~~~~~~~~~~~~ - * +---------------+ - * | Application | - * +---------------+ - * ^ - * | - * v - * conn - * ^ - * | - * v - * +---------------+ - * | Network Stack | - * +---------------+ - * ~~~~~~~~~~~~~~~~~~~~~ - * - * This module provides a minimal set of functions to establish a connection using - * different types of connections. Together, they serve as a common API - * that connects application- and network stack code. - * - * Currently the following connection types are defined: - * - * * @ref conn_ip_t (net/conn/ip.h): raw IP connections - * * @ref conn_tcp_t (net/conn/tcp.h): TCP connections - * * @ref conn_udp_t (net/conn/udp.h): UDP connections - * - * Each network stack must implement at least one connection type. - * - * Note that there might be no relation between the different connection types. - * For simplicity and modularity this API doesn't put any restriction of the actual - * implementation of the type. For example, one implementation might choose - * to have all connection types have a common base class or use the raw IPv6 - * connection type to send e.g. UDP packets, while others will keep them - * completely separate from each other. - * - * How To Use - * ========== - * - * A RIOT application uses the functions provided by one or more of the connection types - * headers (for example @ref conn_udp_t), regardless of the network stack it uses. - * The network stack used under the bonnet is specified by including the appropriate - * module (for example USEMODULE += gnrc_conn_udp) - * - * This allows for network stack agnostic code on the application layer. - * The application code to establish a connection is always the same, allowing - * the network stack underneath to be switched simply by changing the USEMODULE - * definition in the application's Makefile. - * - * @{ - * - * @file - * @brief Application connection API definitions - * - * @author Martine Lenders - * @author Oliver Hahm - */ - -#ifndef NET_CONN_H -#define NET_CONN_H - -#include "net/conn/ip.h" -#include "net/conn/tcp.h" -#include "net/conn/udp.h" -#include "net/ipv6/addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Find the best matching source address for a given prefix - * - * @param[in] dst Pointer to the IPv6 address to find a match for - * Must not be NULL - * - * @return NULL if no matching address on any interface could be found - * @return pointer to an IPv6 address configured on an interface with the best - * match to @p dst - */ -ipv6_addr_t *conn_find_best_source(const ipv6_addr_t *dst); - -#ifdef __cplusplus -} -#endif - -#endif /* NET_CONN_H */ -/** @} */ diff --git a/sys/include/net/conn/ip.h b/sys/include/net/conn/ip.h deleted file mode 100644 index f3cfd697eb..0000000000 --- a/sys/include/net/conn/ip.h +++ /dev/null @@ -1,133 +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. - */ - -/** - * @defgroup net_conn_ip Raw IPv4/IPv6 connections - * @ingroup net_conn - * @deprecated Please use @ref net_sock_ip instead - * @brief Connection submodule for raw IPv4/IPv6 connections - * @{ - * - * @file - * @brief Raw IPv4/IPv6 connection definitions - * - * @author Martine Lenders - */ -#ifndef NET_CONN_IP_H -#define NET_CONN_IP_H - -#include -#include - -#ifdef MODULE_GNRC_CONN_IP -#include "net/gnrc/conn.h" -#endif - -#ifdef MODULE_LWIP_CONN_IP -#include "lwip/conn.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Forward declaration of @ref conn_ip_t to allow for external definition. - */ -struct conn_ip; - -/** - * @brief Implementation-specific type of a raw IPv4/IPv6 connection object - */ -typedef struct conn_ip conn_ip_t; - -/** - * @brief Creates a new raw IPv4/IPv6 connection object - * - * @param[out] conn Preallocated connection object. Must fill the size of the stack-specific - * connection desriptor. - * @param[in] addr The local IP address for @p conn. - * @param[in] addr_len Length of @p addr. Must be fitting for the @p family. - * @param[in] family The family of @p addr (see @ref net_af). - * @param[in] proto @ref net_protnum for the IPv6 packets to receive. - * - * @return 0 on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' bind() function specification. - */ -int conn_ip_create(conn_ip_t *conn, const void *addr, size_t addr_len, int family, int proto); - -/** - * @brief Closes a raw IPv4/IPv6 connection - * - * @param[in,out] conn A raw IPv4/IPv6 connection object. - */ -void conn_ip_close(conn_ip_t *conn); - -/** - * @brief Gets the local address of a raw IPv4/IPv6 connection - * - * @param[in] conn A raw IPv4/IPv6 connection object. - * @param[out] addr The local IP address. Must have space for any address of the connection's - * family. - * - * @return length of @p addr on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' getsockname() function - * specification. - */ -int conn_ip_getlocaladdr(conn_ip_t *conn, void *addr); - -/** - * @brief Receives a message over IPv4/IPv6 - * - * @param[in] conn A raw IPv4/IPv6 connection object. - * @param[out] data Pointer where the received data should be stored. - * @param[in] max_len Maximum space available at @p data. - * @param[out] addr NULL pointer or the sender's IP address. Must have space for any address - * of the connection's family. - * @param[out] addr_len Length of @p addr. Can be NULL if @p addr is NULL. - * - * @note Function may block. - * - * @return The number of bytes received on success. - * @return 0, if no received data is available, but everything is in order. - * @return any other negative number in case of an error. For portability, implementations should - * draw inspiration of the errno values from the POSIX' recv(), recvfrom(), or recvmsg() - * function specification. - */ -int conn_ip_recvfrom(conn_ip_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len); - -/** - * @brief Sends a message over IPv4/IPv6 - * - * @param[in] data Pointer where the received data should be stored. - * @param[in] len Maximum space available at @p data. - * @param[in] src The source address. May be NULL for all any interface address. - * @param[in] src_len Length of @p src. - * @param[in] dst The receiver's network address. - * @param[in] dst_len Length of @p dst. - * @param[in] family The family of @p src and @p dst (see @ref net_af). - * @param[in] proto @ref net_protnum for the IPv6 packets to set. - * - * @note Function may block. - * - * @return The number of bytes send on success. - * @return any other negative number in case of an error. For portability, implementations should - * draw inspiration of the errno values from the POSIX' send(), sendfrom(), or sendmsg() - * function specification. - */ -int conn_ip_sendto(const void *data, size_t len, const void *src, size_t src_len, - void *dst, size_t dst_len, int family, int proto); - -#ifdef __cplusplus -} -#endif - -#endif /* NET_CONN_IP_H */ -/** @} */ diff --git a/sys/include/net/conn/tcp.h b/sys/include/net/conn/tcp.h deleted file mode 100644 index c87e2ce40e..0000000000 --- a/sys/include/net/conn/tcp.h +++ /dev/null @@ -1,178 +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. - */ - -/** - * @defgroup net_conn_tcp TCP connections - * @ingroup net_conn - * @deprecated Please use @ref net_sock_tcp instead - * @brief Connection submodule for TCP connections - * @{ - * - * @file - * @brief TCP connection definitions - * - * @author Martine Lenders - */ -#ifndef NET_CONN_TCP_H -#define NET_CONN_TCP_H - -#include -#include - -#ifdef MODULE_GNRC_CONN_TCP -#include "net/gnrc/conn.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Forward declaration of @ref conn_tcp_t to allow for external definition. - */ -struct conn_tcp; - -/** - * @brief Implementation-specific type of a TCP connection object - */ -typedef struct conn_tcp conn_tcp_t; - -/** - * @brief Creates a new TCP connection object - * - * @param[out] conn Preallocated connection object. Must fill the size of the stack-specific - * connection desriptor. - * @param[in] addr The local network layer address for @p conn. - * @param[in] addr_len The length of @p addr. Must be fitting for the @p family. - * @param[in] family The family of @p addr (see @ref net_af). - * @param[in] port The local TCP port for @p conn. - * - * @return 0 on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' bind() function specification. - */ -int conn_tcp_create(conn_tcp_t *conn, const void *addr, size_t addr_len, int family, - uint16_t port); - -/** - * @brief Closes a TCP connection - * - * @param[in,out] conn A TCP connection object. - */ -void conn_tcp_close(conn_tcp_t *conn); - -/** - * @brief Gets the local address of a TCP connection - * - * @param[in] conn A TCP connection object. - * @param[out] addr The local network layer address. Must have space for any address of - * the connection's family. - * @param[out] port The local TCP port. - * - * @return length of @p addr on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' getsockname() function - * specification. - */ -int conn_tcp_getlocaladdr(conn_tcp_t *conn, void *addr, uint16_t *port); - -/** - * @brief Gets the address of the connected peer of a TCP connection - * - * @param[in] conn A TCP connection object. - * @param[out] addr The network layer address of the connected peer. Must have space for any - * address of the connection's family. - * @param[out] port The TCP port of the connected peer. - * - * @return length of @p addr on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' getpeername() function - * specification. - */ -int conn_tcp_getpeeraddr(conn_tcp_t *conn, void *addr, uint16_t *port); - -/** - * @brief Connects to a remote TCP peer - * - * @param[in] conn A TCP connection object. - * @param[in] addr The remote network layer address for @p conn. - * @param[in] addr_len Length of @p addr. - * @param[in] port The remote TCP port for @p conn. - * - * @return 0 on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' connect() function specification. - */ -int conn_tcp_connect(conn_tcp_t *conn, const void *addr, size_t addr_len, uint16_t port); - -/** - * @brief Marks connection to listen for a connection request by a remote TCP peer - * - * @param[in] conn A TCP connection object. - * @param[in] queue_len Maximum length of the queue for connection requests. - * An implementation may choose to silently adapt this value to its needs - * (setting it to a minimum or maximum value). Any negative number must be - * set at least to 0. - * - * @return 0 on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' listen() function specification. - */ -int conn_tcp_listen(conn_tcp_t *conn, int queue_len); - -/** - * @brief Receives and handles TCP connection requests from other peers - * - * @param[in] conn A TCP connection object. - * @param[out] out_conn A new TCP connection object for the established connection. - * - * @return 0 on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' accept() function specification. - */ -int conn_tcp_accept(conn_tcp_t *conn, conn_tcp_t *out_conn); - -/** - * @brief Receives a TCP message - * - * @param[in] conn A TCP connection object. - * @param[out] data Pointer where the received data should be stored. - * @param[in] max_len Maximum space available at @p data. - * - * @note Function may block. - * - * @return The number of bytes received on success. - * @return 0, if no received data is available, but everything is in order. - * @return any other negative number in case of an error. For portability, implementations should - * draw inspiration of the errno values from the POSIX' recv(), recvfrom(), or recvmsg() - * function specification. - */ -int conn_tcp_recv(conn_tcp_t *conn, void *data, size_t max_len); - -/** - * @brief Sends a TCP message - * - * @param[in] conn A TCP connection object. - * @param[in] data Pointer where the received data should be stored. - * @param[in] len Maximum space available at @p data. - * - * @note Function may block. - * - * @return The number of bytes send on success. - * @return any other negative number in case of an error. For portability, implementations should - * draw inspiration of the errno values from the POSIX' send(), sendfrom(), or sendmsg() - * function specification. - */ -int conn_tcp_send(conn_tcp_t *conn, const void *data, size_t len); - -#ifdef __cplusplus -} -#endif - -#endif /* NET_CONN_TCP_H */ -/** @} */ diff --git a/sys/include/net/conn/udp.h b/sys/include/net/conn/udp.h deleted file mode 100644 index eddaf4b378..0000000000 --- a/sys/include/net/conn/udp.h +++ /dev/null @@ -1,151 +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. - */ - -/** - * @defgroup net_conn_udp UDP connections - * @ingroup net_conn - * @deprecated Please use @ref net_sock_udp instead - * @brief Connection submodule for UDP connections - * @{ - * - * @file - * @brief UDP connection definitions - * - * @author Martine Lenders - */ -#ifndef NET_CONN_UDP_H -#define NET_CONN_UDP_H - -#include -#include - -#ifdef MODULE_GNRC_CONN_UDP -#include "net/gnrc/conn.h" -#endif - -#ifdef MODULE_LWIP_CONN_UDP -#include "lwip/conn.h" -#endif - -#ifdef MODULE_EMB6_CONN_UDP -#include "emb6/conn/udp.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Forward declaration of @ref conn_udp_t to allow for external definition. - */ -struct conn_udp; - -/** - * @brief Implementation-specific type of a UDP connection object - */ -typedef struct conn_udp conn_udp_t; - -/** - * @brief Creates a new UDP connection object - * - * @param[out] conn Preallocated connection object. Must fill the size of the stack-specific - * connection desriptor. - * @param[in] addr The local network layer address for @p conn. - * @param[in] addr_len The length of @p addr. Must be fitting for the @p family. - * @param[in] family The family of @p addr (see @ref net_af). - * @param[in] port The local UDP port for @p conn. - * - * @todo With @ref net_gnrc @ref conn_udp_recvfrom needs to be called from the - * same thread as for this function. This is undesired behavior and - * will be fixed in upcoming versions of RIOT. - * - * @return 0 on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' bind() function specification. - */ -int conn_udp_create(conn_udp_t *conn, const void *addr, size_t addr_len, int family, - uint16_t port); - -/** - * @brief Closes a UDP connection - * - * @param[in,out] conn A UDP connection object. - */ -void conn_udp_close(conn_udp_t *conn); - -/** - * @brief Gets the local address of a UDP connection - * - * @param[in] conn A UDP connection object. - * @param[out] addr The local network layer address. Must have space for any address of - * the connection's family. - * @param[out] port The local UDP port. - * - * @return length of @p addr on success. - * @return any other negative number in case of an error. For portability implementations should - * draw inspiration of the errno values from the POSIX' getsockname() function - * specification. - */ -int conn_udp_getlocaladdr(conn_udp_t *conn, void *addr, uint16_t *port); - -/** - * @brief Receives a UDP message - * - * @param[in] conn A UDP connection object. - * @param[out] data Pointer where the received data should be stored. - * @param[in] max_len Maximum space available at @p data. - * @param[out] addr NULL pointer or the sender's network layer address. Must have space - * for any address of the connection's family. - * @param[out] addr_len Length of @p addr. Can be NULL if @p addr is NULL. - * @param[out] port NULL pointer or the sender's UDP port. - * - * @note Function may block. - * - * @todo With @ref net_gnrc this function needs to be called from the same - * thread as @ref conn_udp_create. This is undesired behavior and will - * be fixed in upcoming versions of RIOT. - * - * @return The number of bytes received on success. - * @return 0, if no received data is available, but everything is in order. - * @return any other negative number in case of an error. For portability, implementations should - * draw inspiration of the errno values from the POSIX' recv(), recvfrom(), or recvmsg() - * function specification. - */ -int conn_udp_recvfrom(conn_udp_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, - uint16_t *port); - -/** - * @brief Sends a UDP message - * - * @param[in] data Pointer to the data to send. - * @param[in] len Length of the @p data to send. - * @param[in] src The source address. May be NULL for any interface address. - * @param[in] src_len Length of @p src. May be 0 if @p src is NULL - * @param[in] dst The receiver's network address. - * @param[in] dst_len Length of @p dst. - * @param[in] family The family of @p src and @p dst (see @ref net_af). - * @param[in] sport The source UDP port. - * @param[in] dport The receiver's UDP port. - * - * @note Function may block. - * - * @return The number of bytes sent on success. - * @return any other negative number in case of an error. For portability, implementations should - * draw inspiration of the errno values from the POSIX' send(), sendfrom(), or sendmsg() - * function specification. - */ -int conn_udp_sendto(const void *data, size_t len, const void *src, size_t src_len, - const void *dst, size_t dst_len, int family, uint16_t sport, - uint16_t dport); - -#ifdef __cplusplus -} -#endif - -#endif /* NET_CONN_UDP4_H */ -/** @} */ diff --git a/sys/include/net/gnrc/conn.h b/sys/include/net/gnrc/conn.h deleted file mode 100644 index 478f68c378..0000000000 --- a/sys/include/net/gnrc/conn.h +++ /dev/null @@ -1,131 +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. - */ - -/** - * @defgroup net_gnrc_conn GNRC-specific implementation of the connection API - * @ingroup net_gnrc - * @brief Provides an implementation of the @ref net_conn by the - * @ref net_gnrc - * - * @{ - * - * @file - * @brief GNRC-specific types and function definitions - * - * @author Martine Lenders - */ -#ifndef GNRC_CONN_H -#define GNRC_CONN_H - -#include -#include -#include "net/ipv6/addr.h" -#include "net/gnrc.h" -#include "sched.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Connection base class - * @internal - */ -typedef struct { - gnrc_nettype_t l3_type; /**< Network layer type of the connection */ - gnrc_nettype_t l4_type; /**< Transport layer type of the connection */ - gnrc_netreg_entry_t netreg_entry; /**< @p net_gnrc_netreg entry for the connection */ -} conn_t; - -/** - * @brief Raw connection type - * @internal - * @extends conn_t - */ -struct conn_ip { - gnrc_nettype_t l3_type; /**< Network layer type of the connection. */ - gnrc_nettype_t l4_type; /**< Transport layer type of the connection. - * Always GNRC_NETTYPE_UNDEF */ - gnrc_netreg_entry_t netreg_entry; /**< @p net_gnrc_netreg entry for the connection */ - uint8_t local_addr[sizeof(ipv6_addr_t)]; /**< local IP address */ - size_t local_addr_len; /**< length of struct conn_ip::local_addr */ -}; - -/** - * @brief UDP connection type - * @internal - * @extends conn_t - */ -struct conn_udp { - gnrc_nettype_t l3_type; /**< Network layer type of the connection. - * Always GNRC_NETTYPE_IPV6 */ - gnrc_nettype_t l4_type; /**< Transport layer type of the connection. - * Always GNRC_NETTYPE_UDP */ - gnrc_netreg_entry_t netreg_entry; /**< @p net_gnrc_netreg entry for the connection */ - uint8_t local_addr[sizeof(ipv6_addr_t)]; /**< local IP address */ - size_t local_addr_len; /**< length of struct conn_ip::local_addr */ -}; - -/** - * @brief Bind connection to demux context - * - * @internal - * - * @param[out] entry @ref net_gnrc_netreg entry. - * @param[in] type @ref net_gnrc_nettype. - * @param[in] demux_ctx demux context (port or proto) for the connection. - */ -static inline void gnrc_conn_reg(gnrc_netreg_entry_t *entry, gnrc_nettype_t type, - uint32_t demux_ctx) -{ - gnrc_netreg_entry_init_pid(entry, demux_ctx, sched_active_pid); - gnrc_netreg_register(type, entry); -} - -/** - * @brief Sets local address for a connection - * - * @internal - * - * @param[out] conn_addr Pointer to the local address on the connection. - * @param[in] addr An IPv6 address. - * - * @return true, if @p addr was a legal address (`::`, `::1` or an address assigned to any - * interface of this node) for the connection. - * @return false if @p addr was not a legal address for the connection. - */ -bool gnrc_conn6_set_local_addr(uint8_t *conn_addr, const ipv6_addr_t *addr); - -/** - * @brief Generic recvfrom - * - * @internal - * - * @param[in] conn Connection object. - * @param[out] data Pointer where the received data should be stored. - * @param[in] max_len Maximum space available at @p data. - * @param[out] addr NULL pointer or the sender's IP address. Must fit address of connection's - * family if not NULL. - * @param[out] addr_len Length of @p addr. May be NULL if @p addr is NULL. - * @param[out] port NULL pointer or the sender's port. - * - * @return The number of bytes received on success. - * @return 0, if no received data is available, but everything is in order. - * @return -ENOMEM, if received data was more than max_len. - * @returne -ETIMEDOUT, if more than 3 IPC messages were not @ref net_gnrc_netapi receive commands - * with the required headers in the packet - */ -int gnrc_conn_recvfrom(conn_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, - uint16_t *port); - -#ifdef __cplusplus -} -#endif - -#endif /* GNRC_CONN_H */ -/** @} */ diff --git a/sys/net/gnrc/Makefile b/sys/net/gnrc/Makefile index 601ada6ca0..05798bbbe1 100644 --- a/sys/net/gnrc/Makefile +++ b/sys/net/gnrc/Makefile @@ -1,12 +1,3 @@ -ifneq (,$(filter gnrc_conn,$(USEMODULE))) - DIRS += conn -endif -ifneq (,$(filter gnrc_conn_ip,$(USEMODULE))) - DIRS += conn/ip -endif -ifneq (,$(filter gnrc_conn_udp,$(USEMODULE))) - DIRS += conn/udp -endif ifneq (,$(filter gnrc_icmpv6,$(USEMODULE))) DIRS += network_layer/icmpv6 endif diff --git a/sys/net/gnrc/conn/Makefile b/sys/net/gnrc/conn/Makefile deleted file mode 100644 index a9b8d3687a..0000000000 --- a/sys/net/gnrc/conn/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = gnrc_conn - -include $(RIOTBASE)/Makefile.base diff --git a/sys/net/gnrc/conn/gnrc_conn.c b/sys/net/gnrc/conn/gnrc_conn.c deleted file mode 100644 index c2991ae5cf..0000000000 --- a/sys/net/gnrc/conn/gnrc_conn.c +++ /dev/null @@ -1,98 +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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - * @author Oliver Hahm - */ - -#include "net/conn.h" -#include "net/ipv6/hdr.h" -#include "net/gnrc/conn.h" -#include "net/gnrc/ipv6/hdr.h" -#include "net/gnrc/ipv6/netif.h" -#include "net/udp.h" - -int gnrc_conn_recvfrom(conn_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, - uint16_t *port) -{ - msg_t msg; - int timeout = 3; - while ((timeout--) > 0) { - gnrc_pktsnip_t *pkt, *l3hdr; - size_t size = 0; - msg_receive(&msg); - switch (msg.type) { - case GNRC_NETAPI_MSG_TYPE_RCV: - pkt = msg.content.ptr; - if (pkt->size > max_len) { - return -ENOMEM; - } - l3hdr = gnrc_pktsnip_search_type(pkt, conn->l3_type); - if (l3hdr == NULL) { - msg_send_to_self(&msg); /* requeue invalid messages */ - continue; - } -#if defined(MODULE_CONN_UDP) || defined(MODULE_CONN_TCP) - if ((conn->l4_type != GNRC_NETTYPE_UNDEF) && (port != NULL)) { - gnrc_pktsnip_t *l4hdr; - l4hdr = gnrc_pktsnip_search_type(pkt, conn->l4_type); - if (l4hdr == NULL) { - msg_send_to_self(&msg); /* requeue invalid messages */ - continue; - } - *port = byteorder_ntohs(((udp_hdr_t *)l4hdr->data)->src_port); - } -#endif /* defined(MODULE_CONN_UDP) */ - if (addr != NULL) { - memcpy(addr, &((ipv6_hdr_t *)l3hdr->data)->src, sizeof(ipv6_addr_t)); - *addr_len = sizeof(ipv6_addr_t); - } - memcpy(data, pkt->data, pkt->size); - size = pkt->size; - gnrc_pktbuf_release(pkt); - return (int)size; - default: - (void)port; - msg_send_to_self(&msg); /* requeue invalid messages */ - break; - } - } - return -ETIMEDOUT; -} - -#ifdef MODULE_GNRC_IPV6 -bool gnrc_conn6_set_local_addr(uint8_t *conn_addr, const ipv6_addr_t *addr) -{ - ipv6_addr_t *tmp; - if (!ipv6_addr_is_unspecified(addr) && - !ipv6_addr_is_loopback(addr) && - gnrc_ipv6_netif_find_by_addr(&tmp, addr) == KERNEL_PID_UNDEF) { - return false; - } - else if (ipv6_addr_is_loopback(addr) || ipv6_addr_is_unspecified(addr)) { - ipv6_addr_set_unspecified((ipv6_addr_t *)conn_addr); - } - else { - memcpy(conn_addr, addr, sizeof(ipv6_addr_t)); - } - return true; -} - -ipv6_addr_t *conn_find_best_source(const ipv6_addr_t *dst) -{ - ipv6_addr_t *local = NULL; - gnrc_ipv6_netif_find_by_prefix(&local, dst); - return local; -} -#endif - -/** @} */ diff --git a/sys/net/gnrc/conn/ip/Makefile b/sys/net/gnrc/conn/ip/Makefile deleted file mode 100644 index bf3473a0b1..0000000000 --- a/sys/net/gnrc/conn/ip/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = gnrc_conn_ip - -include $(RIOTBASE)/Makefile.base diff --git a/sys/net/gnrc/conn/ip/gnrc_conn_ip.c b/sys/net/gnrc/conn/ip/gnrc_conn_ip.c deleted file mode 100644 index d616f3b013..0000000000 --- a/sys/net/gnrc/conn/ip/gnrc_conn_ip.c +++ /dev/null @@ -1,128 +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. - */ - -/** - * @{ - * - * @file - * @author Martine Lenders - */ - -#include -#include "net/af.h" -#include "net/gnrc/conn.h" -#include "net/gnrc/ipv6.h" - -#include "net/conn/ip.h" - -int conn_ip_create(conn_ip_t *conn, const void *addr, size_t addr_len, int family, int proto) -{ - switch (family) { -#ifdef MODULE_GNRC_IPV6 - case AF_INET6: - if (addr_len != sizeof(ipv6_addr_t)) { - return -EINVAL; - } - if (gnrc_conn6_set_local_addr(conn->local_addr, addr)) { - conn->l3_type = GNRC_NETTYPE_IPV6; - conn->local_addr_len = addr_len; - conn_ip_close(conn); /* unregister possibly registered netreg entry */ - gnrc_conn_reg(&conn->netreg_entry, conn->l3_type, (uint32_t)proto); - } - else { - return -EADDRNOTAVAIL; - } - break; -#endif - default: - (void)addr; - (void)addr_len; - (void)proto; - return -EAFNOSUPPORT; - } - conn->l4_type = GNRC_NETTYPE_UNDEF; - return 0; -} - -void conn_ip_close(conn_ip_t *conn) -{ - assert(conn->l4_type == GNRC_NETTYPE_UNDEF); - if (conn->netreg_entry.target.pid != KERNEL_PID_UNDEF) { - gnrc_netreg_unregister(conn->l3_type, &conn->netreg_entry); - } -} - -int conn_ip_getlocaladdr(conn_ip_t *conn, void *addr) -{ - assert(conn->l4_type == GNRC_NETTYPE_UNDEF); - memcpy(addr, &conn->local_addr, conn->local_addr_len); - return conn->local_addr_len; -} - -int conn_ip_recvfrom(conn_ip_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len) -{ - assert(conn->l4_type == GNRC_NETTYPE_UNDEF); - switch (conn->l3_type) { -#ifdef MODULE_GNRC_IPV6 - case GNRC_NETTYPE_IPV6: - return gnrc_conn_recvfrom((conn_t *)conn, data, max_len, addr, addr_len, NULL); -#endif - default: - (void)data; - (void)max_len; - (void)addr; - (void)addr_len; - return -EBADF; - } -} - -int conn_ip_sendto(const void *data, size_t len, const void *src, size_t src_len, - void *dst, size_t dst_len, int family, int proto) -{ - gnrc_pktsnip_t *pkt, *hdr = NULL; - gnrc_nettype_t l3_type; - - pkt = gnrc_pktbuf_add(NULL, (void *)data, len, GNRC_NETTYPE_UNDEF); /* data will only be copied */ - - switch (family) { -#ifdef MODULE_GNRC_IPV6 - case AF_INET6: - if (((src != NULL) && (src_len != sizeof(ipv6_addr_t))) || - (dst_len != sizeof(ipv6_addr_t)) || - (((unsigned)proto) > 256U)) { - gnrc_pktbuf_release(pkt); - return -EINVAL; - } - /* addr will only be copied */ - hdr = gnrc_ipv6_hdr_build(pkt, src, dst); - if (hdr == NULL) { - gnrc_pktbuf_release(pkt); - return -ENOMEM; - } - /* set next header to connection's proto */ - ipv6_hdr_t *ipv6_hdr = hdr->data; - ipv6_hdr->nh = (uint8_t)proto; - pkt = hdr; - l3_type = GNRC_NETTYPE_IPV6; - break; -#endif /* MODULE_GNRC_IPV6 */ - default: - (void)src; - (void)src_len; - (void)dst; - (void)dst_len; - (void)proto; - (void)hdr; - gnrc_pktbuf_release(pkt); - return -EAFNOSUPPORT; - } - - gnrc_netapi_dispatch_send(l3_type, GNRC_NETREG_DEMUX_CTX_ALL, pkt); - - return len; -} diff --git a/sys/net/gnrc/conn/udp/Makefile b/sys/net/gnrc/conn/udp/Makefile deleted file mode 100644 index ed44cc6afd..0000000000 --- a/sys/net/gnrc/conn/udp/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = gnrc_conn_udp - -include $(RIOTBASE)/Makefile.base diff --git a/sys/net/gnrc/conn/udp/gnrc_conn_udp.c b/sys/net/gnrc/conn/udp/gnrc_conn_udp.c deleted file mode 100644 index 7d9b010582..0000000000 --- a/sys/net/gnrc/conn/udp/gnrc_conn_udp.c +++ /dev/null @@ -1,137 +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. - */ - -/** - * @{ - * - * @file - * @brief GNRC implementation of the udp interface defined by net/gnrc/udp.h - * - * @author Martine Lenders - */ - -#include -#include "net/af.h" -#include "net/gnrc/conn.h" -#include "net/gnrc/ipv6.h" -#include "net/gnrc/udp.h" - -#include "net/conn/udp.h" - -int conn_udp_create(conn_udp_t *conn, const void *addr, size_t addr_len, - int family, uint16_t port) -{ - conn->l4_type = GNRC_NETTYPE_UDP; - switch (family) { -#ifdef MODULE_GNRC_IPV6 - case AF_INET6: - if (addr_len != sizeof(ipv6_addr_t)) { - return -EINVAL; - } - if (gnrc_conn6_set_local_addr(conn->local_addr, addr)) { - conn->l3_type = GNRC_NETTYPE_IPV6; - conn->local_addr_len = addr_len; - conn_udp_close(conn); /* unregister possibly registered netreg entry */ - gnrc_conn_reg(&conn->netreg_entry, conn->l4_type, (uint32_t)port); - } - else { - return -EADDRNOTAVAIL; - } - break; -#endif - default: - (void)addr; - (void)addr_len; - (void)port; - return -EAFNOSUPPORT; - } - return 0; -} - -void conn_udp_close(conn_udp_t *conn) -{ - assert(conn->l4_type == GNRC_NETTYPE_UDP); - if (conn->netreg_entry.target.pid != KERNEL_PID_UNDEF) { - gnrc_netreg_unregister(GNRC_NETTYPE_UDP, &conn->netreg_entry); - conn->netreg_entry.target.pid = KERNEL_PID_UNDEF; - } -} - -int conn_udp_getlocaladdr(conn_udp_t *conn, void *addr, uint16_t *port) -{ - assert(conn->l4_type == GNRC_NETTYPE_UDP); - memcpy(addr, &conn->local_addr, conn->local_addr_len); - *port = (uint16_t)conn->netreg_entry.demux_ctx; - return conn->local_addr_len; -} - -int conn_udp_recvfrom(conn_udp_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, - uint16_t *port) -{ - assert(conn->l4_type == GNRC_NETTYPE_UDP); - switch (conn->l3_type) { -#ifdef MODULE_GNRC_IPV6 - case GNRC_NETTYPE_IPV6: - return gnrc_conn_recvfrom((conn_t *)conn, data, max_len, addr, addr_len, port); -#endif - default: - (void)data; - (void)max_len; - (void)addr; - (void)addr_len; - (void)port; - return -EBADF; - } -} - -int conn_udp_sendto(const void *data, size_t len, const void *src, size_t src_len, - const void *dst, size_t dst_len, int family, uint16_t sport, - uint16_t dport) -{ - gnrc_pktsnip_t *pkt, *hdr; - - pkt = gnrc_pktbuf_add(NULL, (void *)data, len, GNRC_NETTYPE_UNDEF); /* data will only be copied */ - hdr = gnrc_udp_hdr_build(pkt, sport, dport); - if (hdr == NULL) { - gnrc_pktbuf_release(pkt); - return -ENOMEM; - } - pkt = hdr; - switch (family) { -#ifdef MODULE_GNRC_IPV6 - case AF_INET6: - if (((src != NULL) && (src_len != sizeof(ipv6_addr_t))) || - (dst_len != sizeof(ipv6_addr_t))) { - gnrc_pktbuf_release(pkt); - return -EINVAL; - } - /* addr will only be copied */ - hdr = gnrc_ipv6_hdr_build(pkt, src, dst); - if (hdr == NULL) { - gnrc_pktbuf_release(pkt); - return -ENOMEM; - } - pkt = hdr; - break; -#endif /* MODULE_GNRC_IPV6 */ - default: - (void)hdr; - (void)src; - (void)src_len; - (void)dst; - (void)dst_len; - gnrc_pktbuf_release(pkt); - return -EAFNOSUPPORT; - } - - gnrc_netapi_dispatch_send(GNRC_NETTYPE_UDP, GNRC_NETREG_DEMUX_CTX_ALL, pkt); - - return len; -} - -/** @} */ diff --git a/tests/conn_ip/Makefile b/tests/conn_ip/Makefile deleted file mode 100644 index 766f2e8221..0000000000 --- a/tests/conn_ip/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -APPLICATION = conn_ip -include ../Makefile.tests_common - -BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo32-f031 nucleo32-f042 \ - nucleo32-l031 nucleo-f030 nucleo-f070 nucleo-f334 nucleo-l053 \ - stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 \ - z1 - -USEMODULE += gnrc_netdev_default -USEMODULE += auto_init_gnrc_netif -USEMODULE += gnrc_icmpv6_echo -USEMODULE += gnrc_ipv6_default -USEMODULE += gnrc_conn_ip -USEMODULE += od -USEMODULE += shell -USEMODULE += shell_commands -USEMODULE += ps - -include $(RIOTBASE)/Makefile.include - -test: - ./tests/01-run.py diff --git a/tests/conn_ip/ip.c b/tests/conn_ip/ip.c deleted file mode 100644 index 03614ba94f..0000000000 --- a/tests/conn_ip/ip.c +++ /dev/null @@ -1,202 +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 "od.h" -#include "net/af.h" -#include "net/conn/ip.h" -#include "net/ipv6.h" -#include "thread.h" -#include "xtimer.h" - -#define SERVER_MSG_QUEUE_SIZE (8) -#define SERVER_BUFFER_SIZE (64) - -static bool server_running; -static conn_ip_t server_conn; -static char server_buffer[SERVER_BUFFER_SIZE]; -static char server_stack[THREAD_STACKSIZE_DEFAULT]; -static msg_t server_msg_queue[SERVER_MSG_QUEUE_SIZE]; - -static void *_server_thread(void *args) -{ - ipv6_addr_t server_addr = IPV6_ADDR_UNSPECIFIED; - uint8_t protocol; - msg_init_queue(server_msg_queue, SERVER_MSG_QUEUE_SIZE); - /* parse protocol */ - protocol = (uint8_t)atoi((char *)args); - if (conn_ip_create(&server_conn, &server_addr, sizeof(server_addr), AF_INET6, protocol) < 0) { - return NULL; - } - server_running = true; - printf("Success: started IP server on protocol %" PRIu8 "\n", protocol); - while (1) { - int res; - ipv6_addr_t src; - size_t src_len = sizeof(ipv6_addr_t); - if ((res = conn_ip_recvfrom(&server_conn, server_buffer, sizeof(server_buffer), &src, - &src_len)) < 0) { - puts("Error on receive"); - } - else if (res == 0) { - puts("No data received"); - } - else { - od_hex_dump(server_buffer, res, 0); - } - } - return NULL; -} - - -static size_t _parse_data(uint8_t *out, const char *data) -{ - bool upper = true; - size_t out_size = 0; - while (*data != '\0') { - if ((*data >= '0') && (*data <= '9')) { - if (upper) { - *out = (char)(*data - '0') << 4; - } - else { - *out |= (char)(*data - '0'); - out++; - out_size++; - } - upper = !upper; - } - else if ((*data >= 'a') && (*data <= 'f')) { - if (upper) { - *out = (char)(*data - 'a' + 10) << 4; - } - else { - *out |= (char)(*data - 'a' + 10); - out++; - out_size++; - } - upper = !upper; - } - else if ((*data >= 'A') && (*data <= 'F')) { - if (upper) { - *out = (char)(*data - 'A' + 10) << 4; - } - else { - *out |= (char)(*data - 'A' + 10); - out++; - out_size++; - } - upper = !upper; - } - data++; - } - if (!upper) { - out_size++; - } - return out_size; -} - -static int ip_send(char *addr_str, char *port_str, char *data, unsigned int num, - unsigned int delay) -{ - ipv6_addr_t src = IPV6_ADDR_UNSPECIFIED, dst; - uint8_t protocol; - uint8_t byte_data[strlen(data) / 2]; - size_t data_len; - /* parse destination address */ - if (ipv6_addr_from_str(&dst, addr_str) == NULL) { - puts("Error: unable to parse destination address"); - return 1; - } - /* parse protocol */ - protocol = (uint8_t)atoi(port_str); - data_len = _parse_data(byte_data, data); - for (unsigned int i = 0; i < num; i++) { - if (conn_ip_sendto(byte_data, data_len, &src, sizeof(src), (struct sockaddr *)&dst, - sizeof(dst), AF_INET6, protocol) < 0) { - puts("could not send"); - } - else { - printf("Success: send %u byte to %s (next header: %" PRIu8 ")\n", - (unsigned)data_len, addr_str, protocol); - } - xtimer_usleep(delay); - } - return 0; -} - -static int ip_start_server(char *port_str) -{ - if (thread_create(server_stack, sizeof(server_stack), THREAD_PRIORITY_MAIN - 1, - THREAD_CREATE_STACKTEST, _server_thread, port_str, "IP server") <= KERNEL_PID_UNDEF) { - return 1; - } - return 0; -} - -int ip_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 = (uint32_t)atoi(argv[5]); - } - if (argc > 6) { - delay = (uint32_t)atoi(argv[6]); - } - return ip_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 ip_start_server(argv[3]); - } - else { - puts("error: invalid command"); - return 1; - } - } - else { - puts("error: invalid command"); - return 1; - } -} - -/** @} */ diff --git a/tests/conn_ip/main.c b/tests/conn_ip/main.c deleted file mode 100644 index 2d3aa5fda7..0000000000 --- a/tests/conn_ip/main.c +++ /dev/null @@ -1,47 +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 gnrc_conn_ip module. If you select protocol 58 you can also - * test if gnrc is able to deal with multiple subscribers to ICMPv6 (gnrc_icmpv6 and this - * application). - * - * @} - */ - -#include - -#include "msg.h" -#include "shell.h" - -extern int ip_cmd(int argc, char **argv); - -static const shell_command_t shell_commands[] = { - { "ip", "send hex over IP and listen for IP packets of certain type", ip_cmd }, - { NULL, NULL, NULL } -}; - -int main(void) -{ - puts("RIOT socket example application"); - /* start shell */ - puts("All up, running the shell now"); - char line_buf[SHELL_DEFAULT_BUFSIZE]; - shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); - - /* should be never reached */ - return 0; -}