Skip to content

Commit

Permalink
Merge pull request #1508 from cgundogan/transport_layer_refactoring
Browse files Browse the repository at this point in the history
transport_layer: Splitting UDP and TCP
  • Loading branch information
OlegHahm committed Sep 11, 2014
2 parents 70ec73b + 710c7e6 commit 2186350
Show file tree
Hide file tree
Showing 41 changed files with 1,896 additions and 1,613 deletions.
17 changes: 15 additions & 2 deletions Makefile.dep
Expand Up @@ -4,11 +4,24 @@ endif

ifneq (,$(filter pnet,$(USEMODULE)))
USEMODULE += posix
USEMODULE += destiny
USEMODULE += socket_base
USEMODULE += net_help
endif

ifneq (,$(filter destiny,$(USEMODULE)))
ifneq (,$(filter transport_layer,$(USEMODULE)))
USEMODULE += tcp
USEMODULE += udp
endif

ifneq (,$(filter udp,$(USEMODULE)))
USEMODULE += socket_base
endif

ifneq (,$(filter tcp,$(USEMODULE)))
USEMODULE += socket_base
endif

ifneq (,$(filter socket_base,$(USEMODULE)))
USEMODULE += sixlowpan
USEMODULE += net_help
USEMODULE += vtimer
Expand Down
1 change: 1 addition & 0 deletions Makefile.pseudomodules
@@ -1 +1,2 @@
PSEUDOMODULES += defaulttransceiver
PSEUDOMODULES += transport_layer
3 changes: 1 addition & 2 deletions examples/rpl_udp/Makefile
Expand Up @@ -54,11 +54,10 @@ BOARD_BLACKLIST := arduino-due mbed_lpc1768 msb-430 pttu udoo qemu-i386 stm32f0d

USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += posix
USEMODULE += ps
USEMODULE += vtimer
USEMODULE += defaulttransceiver
USEMODULE += rpl
USEMODULE += destiny
USEMODULE += udp

include $(RIOTBASE)/Makefile.include
2 changes: 1 addition & 1 deletion examples/rpl_udp/main.c
Expand Up @@ -25,7 +25,7 @@
#include "shell.h"
#include "shell_commands.h"
#include "board_uart0.h"
#include "destiny.h"
#include "udp.h"

#include "rpl_udp.h"

Expand Down
4 changes: 2 additions & 2 deletions examples/rpl_udp/rpl.c
Expand Up @@ -24,7 +24,7 @@
#include "thread.h"
#include "net_if.h"
#include "sixlowpan.h"
#include "destiny.h"
#include "udp.h"
#include "rpl.h"
#include "rpl/rpl_dodag.h"
#include "rpl_udp.h"
Expand Down Expand Up @@ -122,7 +122,7 @@ void rpl_udp_init(int argc, char **argv)
msg_send_receive(&m, &m, transceiver_pid);
printf("Channel set to %u\n", RADIO_CHANNEL);

puts("Destiny initialized");
puts("Transport Layer initialized");
/* start transceiver watchdog */
}

Expand Down
20 changes: 10 additions & 10 deletions examples/rpl_udp/udp.c
Expand Up @@ -26,7 +26,7 @@

#include "thread.h"

#include "destiny/socket.h"
#include "socket_base/socket.h"

#include "net_help.h"

Expand Down Expand Up @@ -63,7 +63,7 @@ static void *init_udp_server(void *arg)
char buffer_main[UDP_BUFFER_SIZE];
int32_t recsize;
uint32_t fromlen;
int sock = destiny_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
int sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);

memset(&sa, 0, sizeof(sa));

Expand All @@ -72,14 +72,14 @@ static void *init_udp_server(void *arg)

fromlen = sizeof(sa);

if (-1 == destiny_socket_bind(sock, &sa, sizeof(sa))) {
if (-1 == socket_base_bind(sock, &sa, sizeof(sa))) {
printf("Error bind failed!\n");
destiny_socket_close(sock);
socket_base_close(sock);
return NULL;
}

while (1) {
recsize = destiny_socket_recvfrom(sock, (void *)buffer_main, UDP_BUFFER_SIZE, 0,
&sa, &fromlen);
recsize = socket_base_recvfrom(sock, (void *)buffer_main, UDP_BUFFER_SIZE, 0, &sa, &fromlen);

if (recsize < 0) {
printf("ERROR: recsize < 0!\n");
Expand All @@ -88,7 +88,7 @@ static void *init_udp_server(void *arg)
printf("UDP packet received, payload: %s\n", buffer_main);
}

destiny_socket_close(sock);
socket_base_close(sock);

return NULL;
}
Expand All @@ -113,7 +113,7 @@ void udp_send(int argc, char **argv)
strncpy(text, argv[2], sizeof(text));
text[sizeof(text) - 1] = 0;

sock = destiny_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);

if (-1 == sock) {
printf("Error Creating Socket!");
Expand All @@ -133,7 +133,7 @@ void udp_send(int argc, char **argv)
memcpy(&sa.sin6_addr, &ipaddr, 16);
sa.sin6_port = HTONS(SERVER_PORT);

bytes_sent = destiny_socket_sendto(sock, (char *)text,
bytes_sent = socket_base_sendto(sock, (char *)text,
strlen(text) + 1, 0, &sa,
sizeof(sa));

Expand All @@ -146,5 +146,5 @@ void udp_send(int argc, char **argv)
&ipaddr));
}

destiny_socket_close(sock);
socket_base_close(sock);
}
2 changes: 1 addition & 1 deletion pkg/libcoap/0001-Add-RIOT-Makefile.patch
Expand Up @@ -15,7 +15,7 @@ index 0000000..f90baa1
+++ b/Makefile
@@ -0,0 +1,5 @@
+MODULE:=$(shell basename $(CURDIR))
+INCLUDES += -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/cpu/arm_common/include -I$(RIOTBASE)/sys/net/destiny/include -I$(RIOTBASE)/sys/net/sixlowpan/include/ -I$(RIOTBASE)/sys/net/ieee802154/include -I$(RIOTBASE)/sys/net/net_help -I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include
+INCLUDES += -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/cpu/arm_common/include -I$(RIOTBASE)/sys/net/transport_layer/include -I$(RIOTBASE)/sys/net/sixlowpan/include/ -I$(RIOTBASE)/sys/net/ieee802154/include -I$(RIOTBASE)/sys/net/net_help -I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include
+CFLAGS += -DWITH_POSIX
+
+include $(RIOTBASE)/Makefile.base
Expand Down
4 changes: 2 additions & 2 deletions pkg/oonf_api/0001-add-RIOT-support.patch
Expand Up @@ -359,7 +359,7 @@ index 78fd5b4..cfba7a9 100644
#endif

+#ifdef RIOT
+#include "destiny/socket.h"
+#include "transport_layer/socket.h"
+#define INET_ADDRSTRLEN (16)
+#define INET6_ADDRSTRLEN (48)
+#endif
Expand Down Expand Up @@ -466,7 +466,7 @@ index 4b3e04d..6b52f72 100644
#include <stdio.h>
#include <stdlib.h>
+#ifdef RIOT
+#include "destiny/socket.h"
+#include "transport_layer/socket.h"
+#include "inet_ntop.h"
+#else
#include <sys/socket.h>
Expand Down
14 changes: 12 additions & 2 deletions sys/Makefile
Expand Up @@ -46,8 +46,18 @@ endif
ifneq (,$(filter net_if,$(USEMODULE)))
DIRS += net/link_layer/net_if
endif
ifneq (,$(filter destiny,$(USEMODULE)))
DIRS += net/transport_layer/destiny
ifneq (,$(filter transport_layer,$(USEMODULE)))
USEMODULE += udp
USEMODULE += tcp
endif
ifneq (,$(filter socket_base,$(USEMODULE)))
DIRS += net/transport_layer/socket_base
endif
ifneq (,$(filter udp,$(USEMODULE)))
DIRS += net/transport_layer/udp
endif
ifneq (,$(filter tcp,$(USEMODULE)))
DIRS += net/transport_layer/tcp
endif
ifneq (,$(filter net_help,$(USEMODULE)))
DIRS += net/crosslayer/net_help
Expand Down
11 changes: 10 additions & 1 deletion sys/Makefile.include
@@ -1,4 +1,13 @@
ifneq (,$(filter destiny,$(USEMODULE)))
ifneq (,$(filter transport_layer,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif
ifneq (,$(filter socket_base,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif
ifneq (,$(filter tcp,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif
ifneq (,$(filter udp,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
endif
ifneq (,$(filter net_help,$(USEMODULE)))
Expand Down
19 changes: 14 additions & 5 deletions sys/auto_init/auto_init.c
Expand Up @@ -55,8 +55,12 @@
#include "sixlowpan.h"
#endif

#ifdef MODULE_DESTINY
#include "destiny.h"
#ifdef MODULE_UDP
#include "udp.h"
#endif

#ifdef MODULE_TCP
#include "tcp.h"
#endif

#ifdef MODULE_NET_IF
Expand Down Expand Up @@ -180,8 +184,13 @@ void auto_init(void)
extern void profiling_init(void);
profiling_init();
#endif
#ifdef MODULE_DESTINY
DEBUG("Auto init transport layer [destiny] module.\n");
destiny_init_transport_layer();
#ifdef MODULE_UDP
DEBUG("Auto init transport layer module: [udp].\n");
udp_init_transport_layer();
#endif

#ifdef MODULE_TCP
DEBUG("Auto init transport layer module: [tcp].\n");
tcp_init_transport_layer();
#endif
}
27 changes: 10 additions & 17 deletions sys/net/include/destiny.h → sys/net/include/socket_base.h
@@ -1,5 +1,5 @@
/**
* destiny.h - Wraps all API types, constants and functions of the transport
* socket_base.h - Wraps all API types, constants and functions of the transport
* layer implementation.
*
* Copyright (C) 2013 INRIA.
Expand All @@ -10,9 +10,9 @@
*/

/**
* @defgroup destiny DESTiny - Transport layer implementation
* @defgroup socket_base Transport layer implementation
* @ingroup net
* @brief DESTiny module implements the transport layer. This includes
* @brief This module implements the transport layer. This includes
* 6LoWPAN UDP header compression and (experimental) 6LoWPAN TCP header
* compression.
* @see <a href="http://tools.ietf.org/html/rfc6282#section-4.3">
Expand All @@ -25,23 +25,16 @@
* </a>
* @{
* @file
* @brief destiny functions
* @brief transport_layer functions
* @author Oliver Gesch <oliver.gesch@googlemail.com>
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
*/

#ifndef DESTINY_H
#define DESTINY_H
#ifndef SOCKET_BASE_H
#define SOCKET_BASE_H

#include "destiny/in.h"
#include "destiny/socket.h"
#include "destiny/types.h"
#include "socket_base/in.h"
#include "socket_base/socket.h"
#include "socket_base/types.h"

/**
* Initializes transport layer.
*
* @return 0 on success, other else.
*/
int destiny_init_transport_layer(void);

#endif /* DESTINY_H */
#endif /* SOCKET_BASE_H */
16 changes: 12 additions & 4 deletions sys/net/include/destiny/in.h → sys/net/include/socket_base/in.h
@@ -1,5 +1,13 @@
/*
* Copyright (C) 2014 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.
*/

/**
* destiny/in.h - Constants defined by the internet system, per RFC 790,
* socket_base/in.h - Constants defined by the internet system, per RFC 790,
* September 1981, and numerous additions, inspired by
* netinet/in.h definitions.
* @{
Expand All @@ -18,8 +26,8 @@
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
*/

#ifndef DESTINY_IN_H
#define DESTINY_IN_H
#ifndef SOCKET_BASE_IN_H
#define SOCKET_BASE_IN_H

/*
* Protocols (RFC 1700) TODO: may be deleted due to some double definition
Expand Down Expand Up @@ -141,4 +149,4 @@

#define IN_LOOPBACKNET (127) ///< official!

#endif /* DESTINY_IN_H */
#endif /* SOCKET_BASE_IN_H */

0 comments on commit 2186350

Please sign in to comment.