From b3162f86e7d66fac816d2c57c544cd0eb29ab20c Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 20 Nov 2013 15:12:19 +0100 Subject: [PATCH 1/6] convert into host byte order in UDP reception --- sys/net/destiny/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/net/destiny/socket.c b/sys/net/destiny/socket.c index b22d88102e..e19f249110 100644 --- a/sys/net/destiny/socket.c +++ b/sys/net/destiny/socket.c @@ -972,15 +972,15 @@ int32_t destiny_socket_recvfrom(int s, void *buf, uint32_t len, int flags, payload = (uint8_t *)(m_recv.content.ptr + IPV6_HDR_LEN + UDP_HDR_LEN); memset(buf, 0, len); - memcpy(buf, payload, udp_header->length - UDP_HDR_LEN); + memcpy(buf, payload, NTOHS(udp_header->length) - UDP_HDR_LEN); memcpy(&from->sin6_addr, &ipv6_header->srcaddr, 16); from->sin6_family = AF_INET6; from->sin6_flowinfo = 0; - from->sin6_port = udp_header->src_port; + from->sin6_port = NTOHS(udp_header->src_port); *fromlen = sizeof(sockaddr6_t); msg_reply(&m_recv, &m_send); - return udp_header->length - UDP_HDR_LEN; + return NTOHS(udp_header->length) - UDP_HDR_LEN; } else if (is_tcp_socket(s)) { return destiny_socket_recv(s, buf, len, flags); From f7da9e7b4748631e36f7d2e8c44f8d2c8832307b Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Wed, 20 Nov 2013 23:57:05 +0100 Subject: [PATCH 2/6] udp_packet_handler uses printf, stack must be bigger --- sys/net/destiny/udp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/destiny/udp.h b/sys/net/destiny/udp.h index 5eab7c460e..46f046e968 100644 --- a/sys/net/destiny/udp.h +++ b/sys/net/destiny/udp.h @@ -21,7 +21,7 @@ #include "ipv6.h" #include "destiny/types.h" -#define UDP_STACK_SIZE KERNEL_CONF_STACKSIZE_DEFAULT +#define UDP_STACK_SIZE KERNEL_CONF_STACKSIZE_MAIN uint16_t udp_csum(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header); void udp_packet_handler(void); From 561531f64cc8d1ff83d1d544554188dbe4d66d56 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Thu, 21 Nov 2013 00:04:41 +0100 Subject: [PATCH 3/6] fix copy&paste typo --- sys/net/destiny/destiny.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/destiny/destiny.c b/sys/net/destiny/destiny.c index 976a87ac73..c38bab9cc0 100644 --- a/sys/net/destiny/destiny.c +++ b/sys/net/destiny/destiny.c @@ -63,7 +63,7 @@ int destiny_init_transport_layer(void) PRIORITY_MAIN, CREATE_STACKTEST, tcp_packet_handler, "tcp_packet_handler"); - if (udp_thread_pid < 0) { + if (tcp_thread_pid < 0) { return -1; } From 479443eae0176241653ff253aedf6474beb6fd54 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Thu, 21 Nov 2013 00:06:49 +0100 Subject: [PATCH 4/6] moved stack from header to C file --- sys/net/destiny/tcp_timer.c | 1 + sys/net/destiny/tcp_timer.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/net/destiny/tcp_timer.c b/sys/net/destiny/tcp_timer.c index 6be9f2b0f5..77bd60c0ce 100644 --- a/sys/net/destiny/tcp_timer.c +++ b/sys/net/destiny/tcp_timer.c @@ -31,6 +31,7 @@ #include "tcp_timer.h" +char tcp_timer_stack[TCP_TIMER_STACKSIZE]; void handle_synchro_timeout(socket_internal_t *current_socket) { diff --git a/sys/net/destiny/tcp_timer.h b/sys/net/destiny/tcp_timer.h index 7c7b986695..2c0bdcdcf1 100644 --- a/sys/net/destiny/tcp_timer.h +++ b/sys/net/destiny/tcp_timer.h @@ -28,6 +28,4 @@ void tcp_general_timer(void); -char tcp_timer_stack[TCP_TIMER_STACKSIZE]; - #endif /* TCP_TIMER_H_ */ From 28624aa37bda1c0cd59ec783bdfb77b68bcd5b66 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Sat, 23 Nov 2013 18:29:09 +0100 Subject: [PATCH 5/6] another NTOHS was missing... --- sys/net/destiny/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/destiny/socket.c b/sys/net/destiny/socket.c index e19f249110..aa9985f201 100644 --- a/sys/net/destiny/socket.c +++ b/sys/net/destiny/socket.c @@ -1019,7 +1019,7 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags, ipv6_sendto(&to->sin6_addr, IPPROTO_UDP, (uint8_t *)(current_udp_packet), NTOHS(current_udp_packet->length)); - return current_udp_packet->length; + return NTOHS(current_udp_packet->length); } else { return -1; From cf9309029cda5b34297fd80108bc6e9de661ccd4 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Fri, 22 Nov 2013 23:44:50 +0100 Subject: [PATCH 6/6] remove vtimer object before (re)scheduling it --- sys/net/destiny/tcp_timer.c | 1 + sys/net/sixlowpan/flowcontrol.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/net/destiny/tcp_timer.c b/sys/net/destiny/tcp_timer.c index 77bd60c0ce..8c81ae8460 100644 --- a/sys/net/destiny/tcp_timer.c +++ b/sys/net/destiny/tcp_timer.c @@ -154,6 +154,7 @@ void tcp_general_timer(void) while (1) { inc_global_variables(); check_sockets(); + vtimer_remove(&tcp_vtimer); vtimer_set_wakeup(&tcp_vtimer, interval, thread_getpid()); thread_sleep(); } diff --git a/sys/net/sixlowpan/flowcontrol.c b/sys/net/sixlowpan/flowcontrol.c index 15f7cf74ae..55a4db1329 100644 --- a/sys/net/sixlowpan/flowcontrol.c +++ b/sys/net/sixlowpan/flowcontrol.c @@ -118,6 +118,7 @@ static int set_timeout(vtimer_t *timeout, long useconds, void *args) interval.seconds = useconds / 1000000; interval.microseconds = (useconds % 1000000) * 1000; + vtimer_remove(timeout); return vtimer_set_msg(timeout, interval, sending_slot_pid, args); }