Merge pull request #347 from OlegHahm/destiny_fixes
UDP reception, stack sizes and typos
This commit is contained in:
commit
d0e6eb89a9
@ -66,7 +66,7 @@ int destiny_init_transport_layer(void)
|
|||||||
PRIORITY_MAIN, CREATE_STACKTEST,
|
PRIORITY_MAIN, CREATE_STACKTEST,
|
||||||
tcp_packet_handler, "tcp_packet_handler");
|
tcp_packet_handler, "tcp_packet_handler");
|
||||||
|
|
||||||
if (udp_thread_pid < 0) {
|
if (tcp_thread_pid < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
payload = (uint8_t *)(m_recv.content.ptr + IPV6_HDR_LEN + UDP_HDR_LEN);
|
||||||
|
|
||||||
memset(buf, 0, 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);
|
memcpy(&from->sin6_addr, &ipv6_header->srcaddr, 16);
|
||||||
from->sin6_family = AF_INET6;
|
from->sin6_family = AF_INET6;
|
||||||
from->sin6_flowinfo = 0;
|
from->sin6_flowinfo = 0;
|
||||||
from->sin6_port = udp_header->src_port;
|
from->sin6_port = NTOHS(udp_header->src_port);
|
||||||
*fromlen = sizeof(sockaddr6_t);
|
*fromlen = sizeof(sockaddr6_t);
|
||||||
|
|
||||||
msg_reply(&m_recv, &m_send);
|
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
|
#ifdef DESTINY_WITH_TCP
|
||||||
else if (is_tcp_socket(s)) {
|
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,
|
ipv6_sendto(&to->sin6_addr, IPPROTO_UDP,
|
||||||
(uint8_t *)(current_udp_packet),
|
(uint8_t *)(current_udp_packet),
|
||||||
NTOHS(current_udp_packet->length));
|
NTOHS(current_udp_packet->length));
|
||||||
return current_udp_packet->length;
|
return NTOHS(current_udp_packet->length);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "tcp_timer.h"
|
#include "tcp_timer.h"
|
||||||
|
|
||||||
|
char tcp_timer_stack[TCP_TIMER_STACKSIZE];
|
||||||
|
|
||||||
void handle_synchro_timeout(socket_internal_t *current_socket)
|
void handle_synchro_timeout(socket_internal_t *current_socket)
|
||||||
{
|
{
|
||||||
@ -154,6 +155,7 @@ void tcp_general_timer(void)
|
|||||||
while (1) {
|
while (1) {
|
||||||
inc_global_variables();
|
inc_global_variables();
|
||||||
check_sockets();
|
check_sockets();
|
||||||
|
vtimer_remove(&tcp_vtimer);
|
||||||
vtimer_set_wakeup(&tcp_vtimer, interval, thread_getpid());
|
vtimer_set_wakeup(&tcp_vtimer, interval, thread_getpid());
|
||||||
thread_sleep();
|
thread_sleep();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,4 @@
|
|||||||
|
|
||||||
void tcp_general_timer(void);
|
void tcp_general_timer(void);
|
||||||
|
|
||||||
char tcp_timer_stack[TCP_TIMER_STACKSIZE];
|
|
||||||
|
|
||||||
#endif /* TCP_TIMER_H_ */
|
#endif /* TCP_TIMER_H_ */
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
#include "ipv6.h"
|
#include "ipv6.h"
|
||||||
#include "destiny/types.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);
|
uint16_t udp_csum(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header);
|
||||||
void udp_packet_handler(void);
|
void udp_packet_handler(void);
|
||||||
|
|||||||
@ -118,6 +118,7 @@ static int set_timeout(vtimer_t *timeout, long useconds, void *args)
|
|||||||
interval.seconds = useconds / 1000000;
|
interval.seconds = useconds / 1000000;
|
||||||
interval.microseconds = (useconds % 1000000) * 1000;
|
interval.microseconds = (useconds % 1000000) * 1000;
|
||||||
|
|
||||||
|
vtimer_remove(timeout);
|
||||||
return vtimer_set_msg(timeout, interval, sending_slot_pid, args);
|
return vtimer_set_msg(timeout, interval, sending_slot_pid, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user