2011-09-28 16:29:01 +02:00
|
|
|
/*
|
|
|
|
* destiny.c
|
|
|
|
*
|
|
|
|
* Created on: 03.09.2011
|
|
|
|
* Author: Oliver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <thread.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2012-02-05 00:33:55 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <vtimer.h>
|
2011-09-28 16:29:01 +02:00
|
|
|
#include "udp.h"
|
2011-10-13 04:31:07 +02:00
|
|
|
#include "tcp.h"
|
2011-09-28 16:29:01 +02:00
|
|
|
#include "socket.h"
|
2012-01-24 03:19:11 +01:00
|
|
|
#include "tcp_timer.h"
|
|
|
|
#include "destiny.h"
|
2011-09-28 16:29:01 +02:00
|
|
|
|
|
|
|
void init_transport_layer(void)
|
|
|
|
{
|
2012-02-14 21:28:51 +01:00
|
|
|
printf("Initializing transport layer packages. Size of socket_type: %u\n", sizeof(socket_internal_t));
|
2011-09-28 16:29:01 +02:00
|
|
|
// SOCKETS
|
2011-10-13 04:31:07 +02:00
|
|
|
memset(sockets, 0, MAX_SOCKETS*sizeof(socket_internal_t));
|
2011-09-28 16:29:01 +02:00
|
|
|
|
|
|
|
// UDP
|
2011-10-13 04:31:07 +02:00
|
|
|
int udp_thread_pid = thread_create(udp_stack_buffer, UDP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, udp_packet_handler, "udp_packet_handler");
|
2011-12-26 02:59:58 +01:00
|
|
|
set_udp_packet_handler_pid(udp_thread_pid);
|
2011-09-28 16:29:01 +02:00
|
|
|
|
|
|
|
// TCP
|
2012-02-05 00:33:55 +01:00
|
|
|
srand(vtimer_now().microseconds);
|
2012-02-07 04:24:00 +01:00
|
|
|
#ifdef TCP_HC
|
2012-02-05 00:33:55 +01:00
|
|
|
global_context_counter = rand();
|
2012-02-07 04:24:00 +01:00
|
|
|
#endif
|
2012-02-05 00:33:55 +01:00
|
|
|
global_sequence_counter = rand();
|
|
|
|
|
2011-10-13 04:31:07 +02:00
|
|
|
int tcp_thread_pid = thread_create(tcp_stack_buffer, TCP_STACK_SIZE, PRIORITY_MAIN, CREATE_STACKTEST, tcp_packet_handler, "tcp_packet_handler");
|
2011-12-26 02:59:58 +01:00
|
|
|
set_tcp_packet_handler_pid(tcp_thread_pid);
|
2012-01-30 22:44:38 +01:00
|
|
|
|
2012-02-01 21:07:57 +01:00
|
|
|
thread_create(tcp_timer_stack, TCP_TIMER_STACKSIZE, PRIORITY_MAIN+1, CREATE_STACKTEST, tcp_general_timer, "tcp_general_timer");
|
2012-01-24 03:19:11 +01:00
|
|
|
|
2011-09-28 16:29:01 +02:00
|
|
|
}
|