From de33fcd31bff81c7b3a9c8437372d877f621e11c Mon Sep 17 00:00:00 2001 From: Martin Lenders Date: Fri, 20 Sep 2013 14:29:00 +0200 Subject: [PATCH] Refactor destiny.h --- sys/net/destiny/Makefile | 2 +- sys/net/destiny/destiny.c | 21 +++++++++++++++++---- sys/net/destiny/destiny.h | 13 ------------- sys/net/destiny/include/destiny.h | 13 +++++++++++++ 4 files changed, 31 insertions(+), 18 deletions(-) delete mode 100644 sys/net/destiny/destiny.h create mode 100644 sys/net/destiny/include/destiny.h diff --git a/sys/net/destiny/Makefile b/sys/net/destiny/Makefile index e771aa3e96..54c9d5a440 100644 --- a/sys/net/destiny/Makefile +++ b/sys/net/destiny/Makefile @@ -1,4 +1,4 @@ MODULE:=$(shell basename $(CURDIR)) -INCLUDES = -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/net/destiny -I$(RIOTBASE)/sys/net/sixlowpan/include -I$(RIOTBASE)/sys/net/net_help/ -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/drivers/cc110x +INCLUDES = -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/net/destiny/include -I$(RIOTBASE)/sys/net/sixlowpan/include -I$(RIOTBASE)/sys/net/net_help/ -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/drivers/cc110x include $(RIOTBASE)/Makefile.base diff --git a/sys/net/destiny/destiny.c b/sys/net/destiny/destiny.c index d5cfd44c0c..8d5c9b03a3 100644 --- a/sys/net/destiny/destiny.c +++ b/sys/net/destiny/destiny.c @@ -29,7 +29,7 @@ char tcp_stack_buffer[TCP_STACK_SIZE]; char udp_stack_buffer[UDP_STACK_SIZE]; -void init_transport_layer(void) +int destiny_init_transport_layer(void) { printf("Initializing transport layer packages. Size of socket_type: %u\n", sizeof(socket_internal_t)); @@ -39,7 +39,12 @@ void init_transport_layer(void) /* UDP */ int udp_thread_pid = thread_create(udp_stack_buffer, UDP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, - udp_packet_handler,"udp_packet_handler"); + udp_packet_handler, "udp_packet_handler"); + + if (udp_thread_pid < 0) { + return -1; + } + ipv6_register_next_header_handler(IPV6_PROTO_NUM_UDP, udp_thread_pid); /* TCP */ @@ -55,9 +60,17 @@ void init_transport_layer(void) int tcp_thread_pid = thread_create(tcp_stack_buffer, TCP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, tcp_packet_handler, "tcp_packet_handler"); + + if (udp_thread_pid < 0) { + return -1; + } + ipv6_register_next_header_handler(IPV6_PROTO_NUM_TCP, tcp_thread_pid); - thread_create(tcp_timer_stack, TCP_TIMER_STACKSIZE, PRIORITY_MAIN + 1, - CREATE_STACKTEST, tcp_general_timer, "tcp_general_timer"); + if (thread_create(tcp_timer_stack, TCP_TIMER_STACKSIZE, PRIORITY_MAIN + 1, + CREATE_STACKTEST, tcp_general_timer, "tcp_general_timer") < 0) { + return -1; + } + return 0; } diff --git a/sys/net/destiny/destiny.h b/sys/net/destiny/destiny.h deleted file mode 100644 index d3f5690638..0000000000 --- a/sys/net/destiny/destiny.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * destiny.h - * - * Created on: 03.09.2011 - * Author: Oliver - */ - -#ifndef DESTINY_H_ -#define DESTINY_H_ - -void init_transport_layer(void); - -#endif /* DESTINY_H_ */ diff --git a/sys/net/destiny/include/destiny.h b/sys/net/destiny/include/destiny.h new file mode 100644 index 0000000000..5e0af7fac6 --- /dev/null +++ b/sys/net/destiny/include/destiny.h @@ -0,0 +1,13 @@ +/* + * destiny.h + * + * Created on: 03.09.2011 + * Author: Oliver + */ + +#ifndef DESTINY_H +#define DESTINY_H + +int destiny_init_transport_layer(void); + +#endif /* DESTINY_H */