Merge pull request #347 from OlegHahm/destiny_fixes

UDP reception, stack sizes and typos
This commit is contained in:
Oleg Hahm 2013-12-04 02:29:08 -08:00
commit d0e6eb89a9
6 changed files with 9 additions and 8 deletions

View File

@ -66,7 +66,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;
}

View File

@ -999,15 +999,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;
}
#ifdef DESTINY_WITH_TCP
else if (is_tcp_socket(s)) {
@ -1051,7 +1051,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;

View File

@ -32,6 +32,7 @@
#include "tcp_timer.h"
char tcp_timer_stack[TCP_TIMER_STACKSIZE];
void handle_synchro_timeout(socket_internal_t *current_socket)
{
@ -154,6 +155,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();
}

View File

@ -28,6 +28,4 @@
void tcp_general_timer(void);
char tcp_timer_stack[TCP_TIMER_STACKSIZE];
#endif /* TCP_TIMER_H_ */

View File

@ -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);

View File

@ -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);
}