2011-10-13 04:31:07 +02:00
|
|
|
/*
|
|
|
|
* tcp.c
|
|
|
|
*
|
|
|
|
* Created on: 29.09.2011
|
|
|
|
* Author: Oliver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <thread.h>
|
|
|
|
#include <string.h>
|
2012-01-24 03:19:11 +01:00
|
|
|
#include <stdlib.h>
|
2011-10-13 04:31:07 +02:00
|
|
|
|
2012-01-24 03:19:11 +01:00
|
|
|
#include "vtimer.h"
|
2012-01-30 22:44:38 +01:00
|
|
|
#include "tcp_timer.h"
|
2012-02-02 02:41:39 +01:00
|
|
|
#include "tcp_hc.h"
|
2011-10-13 04:31:07 +02:00
|
|
|
#include "tcp.h"
|
|
|
|
#include "in.h"
|
|
|
|
#include "socket.h"
|
|
|
|
#include "sys/net/net_help/net_help.h"
|
2011-11-25 01:31:54 +01:00
|
|
|
#include "sys/net/net_help/msg_help.h"
|
2012-02-03 03:11:30 +01:00
|
|
|
#include "sys/net/sixlowpan/sixlowpan.h"
|
2011-10-13 04:31:07 +02:00
|
|
|
|
2011-11-02 02:55:38 +01:00
|
|
|
void printTCPHeader(tcp_hdr_t *tcp_header)
|
2011-11-01 05:47:28 +01:00
|
|
|
{
|
|
|
|
printf("\nBEGIN: TCP HEADER\n");
|
|
|
|
printf("ack_nr: %lu\n", tcp_header->ack_nr);
|
|
|
|
printf("checksum: %i\n", tcp_header->checksum);
|
|
|
|
printf("dataOffset_reserved: %i\n", tcp_header->dataOffset_reserved);
|
|
|
|
printf("dst_port: %i\n", tcp_header->dst_port);
|
|
|
|
printf("reserved_flags: %i\n", tcp_header->reserved_flags);
|
|
|
|
printf("seq_nr: %lu\n", tcp_header->seq_nr);
|
|
|
|
printf("src_port: %i\n", tcp_header->src_port);
|
|
|
|
printf("urg_pointer: %i\n", tcp_header->urg_pointer);
|
|
|
|
printf("window: %i\n", tcp_header->window);
|
|
|
|
printf("END: TCP HEADER\n");
|
|
|
|
}
|
2011-10-13 04:31:07 +02:00
|
|
|
|
|
|
|
void printArrayRange_tcp(uint8_t *udp_header, uint16_t len)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
printf("-------------MEMORY-------------\n");
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
printf("%#x ", *(udp_header+i));
|
|
|
|
}
|
|
|
|
printf("-------------MEMORY-------------\n");
|
|
|
|
}
|
|
|
|
|
2011-10-28 04:37:12 +02:00
|
|
|
uint16_t tcp_csum(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header)
|
|
|
|
{
|
2011-10-13 04:31:07 +02:00
|
|
|
uint16_t sum;
|
|
|
|
uint16_t len = ipv6_header->length;
|
|
|
|
|
|
|
|
sum = len + IPPROTO_TCP;
|
|
|
|
sum = csum(sum, (uint8_t *)&ipv6_header->srcaddr, 2 * sizeof(ipv6_addr_t));
|
2011-11-01 05:47:28 +01:00
|
|
|
sum = csum(sum, (uint8_t *)tcp_header, len);
|
2011-10-13 04:31:07 +02:00
|
|
|
return (sum == 0) ? 0xffff : HTONS(sum);
|
2011-10-28 04:37:12 +02:00
|
|
|
}
|
2011-10-13 04:31:07 +02:00
|
|
|
|
2011-11-25 01:31:54 +01:00
|
|
|
uint8_t handle_payload(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket, uint8_t *payload)
|
|
|
|
{
|
2012-02-02 02:41:39 +01:00
|
|
|
msg_t m_send_tcp, m_recv_tcp;
|
2011-11-25 01:31:54 +01:00
|
|
|
uint8_t tcp_payload_len = ipv6_header->length-TCP_HDR_LEN;
|
|
|
|
uint8_t acknowledged_bytes = 0;
|
2012-01-25 03:38:22 +01:00
|
|
|
if (tcp_payload_len > tcp_socket->socket_values.tcp_control.rcv_wnd)
|
2011-11-25 01:31:54 +01:00
|
|
|
{
|
2012-01-30 22:44:38 +01:00
|
|
|
mutex_lock(&tcp_socket->tcp_buffer_mutex);
|
2012-01-25 03:38:22 +01:00
|
|
|
memcpy(tcp_socket->tcp_input_buffer, payload, tcp_socket->socket_values.tcp_control.rcv_wnd);
|
|
|
|
acknowledged_bytes = tcp_socket->socket_values.tcp_control.rcv_wnd;
|
|
|
|
tcp_socket->socket_values.tcp_control.rcv_wnd = 0;
|
|
|
|
tcp_socket->tcp_input_buffer_end = tcp_socket->tcp_input_buffer_end + tcp_socket->socket_values.tcp_control.rcv_wnd;
|
2012-01-30 22:44:38 +01:00
|
|
|
mutex_unlock(&tcp_socket->tcp_buffer_mutex, 0);
|
2011-11-25 01:31:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 22:44:38 +01:00
|
|
|
mutex_lock(&tcp_socket->tcp_buffer_mutex);
|
2011-11-25 01:31:54 +01:00
|
|
|
memcpy(tcp_socket->tcp_input_buffer, payload, tcp_payload_len);
|
2012-01-25 03:38:22 +01:00
|
|
|
tcp_socket->socket_values.tcp_control.rcv_wnd = tcp_socket->socket_values.tcp_control.rcv_wnd - tcp_payload_len;
|
2011-11-25 01:31:54 +01:00
|
|
|
acknowledged_bytes = tcp_payload_len;
|
|
|
|
tcp_socket->tcp_input_buffer_end = tcp_socket->tcp_input_buffer_end + tcp_payload_len;
|
2012-01-30 22:44:38 +01:00
|
|
|
mutex_unlock(&tcp_socket->tcp_buffer_mutex, 0);
|
2011-11-25 01:31:54 +01:00
|
|
|
}
|
2012-02-02 02:41:39 +01:00
|
|
|
if (thread_getstatus(tcp_socket->recv_pid) == STATUS_RECEIVE_BLOCKED)
|
|
|
|
{
|
|
|
|
net_msg_send_recv(&m_send_tcp, &m_recv_tcp, tcp_socket->recv_pid, UNDEFINED);
|
|
|
|
}
|
|
|
|
|
2011-11-25 01:31:54 +01:00
|
|
|
return acknowledged_bytes;
|
|
|
|
}
|
|
|
|
|
2011-11-08 02:14:58 +01:00
|
|
|
void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket)
|
|
|
|
{
|
|
|
|
msg_t m_recv_tcp, m_send_tcp;
|
2012-01-30 22:44:38 +01:00
|
|
|
uint8_t target_pid;
|
2011-11-25 01:31:54 +01:00
|
|
|
|
2012-01-25 03:38:22 +01:00
|
|
|
if (tcp_socket->socket_values.tcp_control.state == LAST_ACK)
|
2012-01-30 22:44:38 +01:00
|
|
|
{
|
|
|
|
target_pid = tcp_socket->recv_pid;
|
|
|
|
close_socket(tcp_socket);
|
|
|
|
msg_send(&m_send_tcp, target_pid, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (tcp_socket->socket_values.tcp_control.state == CLOSING)
|
2012-01-03 02:16:43 +01:00
|
|
|
{
|
2012-01-27 02:54:59 +01:00
|
|
|
msg_send(&m_send_tcp, tcp_socket->recv_pid, 0);
|
2012-01-30 22:44:38 +01:00
|
|
|
msg_send(&m_send_tcp, tcp_socket->send_pid, 0);
|
2012-01-03 02:16:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// TODO: Find better way of handling queued sockets ACK packets
|
2012-01-30 22:44:38 +01:00
|
|
|
else if (getWaitingConnectionSocket(tcp_socket->socket_id, ipv6_header, tcp_header) != NULL)
|
2011-11-08 02:14:58 +01:00
|
|
|
{
|
2012-01-28 16:15:09 +01:00
|
|
|
printf("sending ACK to queued socket!\n");
|
2011-12-26 02:59:58 +01:00
|
|
|
m_send_tcp.content.ptr = (char*)tcp_header;
|
2012-01-27 02:54:59 +01:00
|
|
|
net_msg_send_recv(&m_send_tcp, &m_recv_tcp, tcp_socket->recv_pid, TCP_ACK);
|
2011-12-27 05:31:52 +01:00
|
|
|
return;
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
2012-01-25 03:38:22 +01:00
|
|
|
else if (tcp_socket->socket_values.tcp_control.state == ESTABLISHED)
|
2012-01-03 02:16:43 +01:00
|
|
|
{
|
2012-01-27 02:54:59 +01:00
|
|
|
m_send_tcp.content.ptr = (char*)tcp_header;
|
|
|
|
net_msg_send(&m_send_tcp, tcp_socket->send_pid, 0, TCP_ACK);
|
2012-01-03 02:16:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("NO WAY OF HANDLING THIS ACK!\n");
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void handle_tcp_rst_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_tcp_syn_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket)
|
|
|
|
{
|
|
|
|
msg_t m_send_tcp;
|
2012-01-25 03:38:22 +01:00
|
|
|
if (tcp_socket->socket_values.tcp_control.state == LISTEN)
|
2011-11-08 02:14:58 +01:00
|
|
|
{
|
2012-01-28 16:15:09 +01:00
|
|
|
socket_internal_t *new_socket = new_tcp_queued_socket(ipv6_header, tcp_header);
|
2011-11-08 02:14:58 +01:00
|
|
|
if (new_socket != NULL)
|
|
|
|
{
|
2012-02-05 00:33:55 +01:00
|
|
|
update_tcp_hc_context(true, new_socket, tcp_header);
|
2011-11-08 02:14:58 +01:00
|
|
|
// notify socket function accept(..) that a new connection request has arrived
|
|
|
|
// No need to wait for an answer because the server accept() function isnt reading from anything other than the queued sockets
|
2012-01-30 22:44:38 +01:00
|
|
|
net_msg_send(&m_send_tcp, tcp_socket->recv_pid, 0, TCP_SYN);
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Dropped TCP SYN Message because an error occured while requesting a new queued socket!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-25 01:31:54 +01:00
|
|
|
printf("Dropped TCP SYN Message because socket was not in state LISTEN!");
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_tcp_syn_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket)
|
|
|
|
{
|
2012-01-24 03:19:11 +01:00
|
|
|
msg_t m_send_tcp;
|
2012-01-25 03:38:22 +01:00
|
|
|
if (tcp_socket->socket_values.tcp_control.state == SYN_SENT)
|
2011-11-08 02:14:58 +01:00
|
|
|
{
|
2011-12-26 02:59:58 +01:00
|
|
|
m_send_tcp.content.ptr = (char*) tcp_header;
|
2012-01-27 02:54:59 +01:00
|
|
|
net_msg_send(&m_send_tcp, tcp_socket->recv_pid, 0, TCP_SYN_ACK);
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Socket not in state SYN_SENT, dropping SYN-ACK-packet!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void handle_tcp_fin_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket)
|
|
|
|
{
|
2012-01-03 02:16:43 +01:00
|
|
|
msg_t m_send;
|
2012-01-25 03:38:22 +01:00
|
|
|
socket_t *current_tcp_socket = &tcp_socket->socket_values;
|
2012-01-03 02:16:43 +01:00
|
|
|
uint8_t send_buffer[BUFFER_SIZE];
|
|
|
|
ipv6_hdr_t *temp_ipv6_header = ((ipv6_hdr_t*)(&send_buffer));
|
|
|
|
tcp_hdr_t *current_tcp_packet = ((tcp_hdr_t*)(&send_buffer[IPV6_HDR_LEN]));
|
2012-01-25 03:38:22 +01:00
|
|
|
|
|
|
|
set_tcp_cb(¤t_tcp_socket->tcp_control, tcp_header->seq_nr+1, current_tcp_socket->tcp_control.send_wnd, tcp_header->ack_nr,
|
2012-01-30 22:44:38 +01:00
|
|
|
tcp_header->ack_nr, tcp_header->window);
|
2012-01-25 03:38:22 +01:00
|
|
|
|
2012-01-30 22:44:38 +01:00
|
|
|
if (current_tcp_socket->tcp_control.state == FIN_WAIT_1)
|
|
|
|
{
|
|
|
|
current_tcp_socket->tcp_control.state = CLOSING;
|
2012-01-03 02:16:43 +01:00
|
|
|
|
2012-02-05 00:33:55 +01:00
|
|
|
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_FIN_ACK, 0);
|
2012-01-30 22:44:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current_tcp_socket->tcp_control.state = LAST_ACK;
|
|
|
|
|
2012-02-05 00:33:55 +01:00
|
|
|
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_FIN_ACK, 0);
|
2012-01-30 22:44:38 +01:00
|
|
|
}
|
|
|
|
net_msg_send(&m_send, tcp_socket->recv_pid, 0, CLOSE_CONN);
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void handle_tcp_fin_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket)
|
|
|
|
{
|
2012-01-03 02:16:43 +01:00
|
|
|
msg_t m_send;
|
2012-01-25 03:38:22 +01:00
|
|
|
socket_t *current_tcp_socket = &tcp_socket->socket_values;
|
2012-01-03 02:16:43 +01:00
|
|
|
uint8_t send_buffer[BUFFER_SIZE];
|
|
|
|
ipv6_hdr_t *temp_ipv6_header = ((ipv6_hdr_t*)(&send_buffer));
|
|
|
|
tcp_hdr_t *current_tcp_packet = ((tcp_hdr_t*)(&send_buffer[IPV6_HDR_LEN]));
|
2012-01-25 03:38:22 +01:00
|
|
|
|
|
|
|
current_tcp_socket->tcp_control.state = CLOSED;
|
|
|
|
|
|
|
|
set_tcp_cb(¤t_tcp_socket->tcp_control, tcp_header->seq_nr+1, current_tcp_socket->tcp_control.send_wnd, tcp_header->ack_nr,
|
|
|
|
tcp_header->ack_nr, tcp_header->window);
|
|
|
|
|
2012-02-05 00:33:55 +01:00
|
|
|
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_ACK, 0);
|
2012-01-03 02:16:43 +01:00
|
|
|
|
2012-01-30 22:44:38 +01:00
|
|
|
msg_send(&m_send, tcp_socket->send_pid, 0);
|
2012-01-27 02:54:59 +01:00
|
|
|
msg_send(&m_send, tcp_socket->recv_pid, 0);
|
2011-11-08 02:14:58 +01:00
|
|
|
}
|
|
|
|
|
2011-11-11 03:41:08 +01:00
|
|
|
void handle_tcp_no_flags_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header, socket_internal_t *tcp_socket, uint8_t *payload)
|
|
|
|
{
|
2011-11-25 01:31:54 +01:00
|
|
|
uint8_t tcp_payload_len = ipv6_header->length-TCP_HDR_LEN, read_bytes = 0;
|
2012-01-25 03:38:22 +01:00
|
|
|
socket_t *current_tcp_socket = &tcp_socket->socket_values;
|
2011-11-25 01:31:54 +01:00
|
|
|
uint8_t send_buffer[BUFFER_SIZE];
|
|
|
|
ipv6_hdr_t *temp_ipv6_header = ((ipv6_hdr_t*)(&send_buffer));
|
|
|
|
tcp_hdr_t *current_tcp_packet = ((tcp_hdr_t*)(&send_buffer[IPV6_HDR_LEN]));
|
|
|
|
|
|
|
|
if (tcp_payload_len > 0)
|
|
|
|
{
|
|
|
|
read_bytes = handle_payload(ipv6_header, tcp_header, tcp_socket, payload);
|
2012-01-28 01:55:21 +01:00
|
|
|
|
2011-11-25 01:31:54 +01:00
|
|
|
// Refresh TCP status values
|
2012-01-25 03:38:22 +01:00
|
|
|
current_tcp_socket->tcp_control.state = ESTABLISHED;
|
|
|
|
|
|
|
|
set_tcp_cb(¤t_tcp_socket->tcp_control,
|
2012-01-28 01:55:21 +01:00
|
|
|
tcp_header->seq_nr + read_bytes,
|
2012-01-25 03:38:22 +01:00
|
|
|
current_tcp_socket->tcp_control.rcv_wnd,
|
|
|
|
current_tcp_socket->tcp_control.send_nxt,
|
|
|
|
current_tcp_socket->tcp_control.send_una,
|
|
|
|
current_tcp_socket->tcp_control.send_wnd);
|
2012-01-28 01:55:21 +01:00
|
|
|
// Send packet
|
2012-02-05 00:33:55 +01:00
|
|
|
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_ACK, 0);
|
2011-11-25 01:31:54 +01:00
|
|
|
}
|
2011-11-11 03:41:08 +01:00
|
|
|
}
|
|
|
|
|
2011-10-13 04:31:07 +02:00
|
|
|
void tcp_packet_handler (void)
|
|
|
|
{
|
2011-11-08 02:14:58 +01:00
|
|
|
msg_t m_recv_ip, m_send_ip;
|
2011-11-01 21:04:28 +01:00
|
|
|
ipv6_hdr_t *ipv6_header;
|
|
|
|
tcp_hdr_t *tcp_header;
|
2011-10-13 04:31:07 +02:00
|
|
|
uint8_t *payload;
|
|
|
|
socket_internal_t *tcp_socket = NULL;
|
|
|
|
uint16_t chksum;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2012-01-24 03:19:11 +01:00
|
|
|
msg_receive(&m_recv_ip);
|
2011-12-26 02:59:58 +01:00
|
|
|
|
|
|
|
ipv6_header = ((ipv6_hdr_t*)m_recv_ip.content.ptr);
|
|
|
|
tcp_header = ((tcp_hdr_t*)(m_recv_ip.content.ptr + IPV6_HDR_LEN));
|
|
|
|
payload = (uint8_t*)(m_recv_ip.content.ptr + IPV6_HDR_LEN + TCP_HDR_LEN);
|
|
|
|
|
2012-02-03 03:11:30 +01:00
|
|
|
|
|
|
|
#ifdef TCP_HC
|
|
|
|
tcp_socket = decompress_tcp_packet(ipv6_header);
|
|
|
|
#else
|
2011-11-25 01:31:54 +01:00
|
|
|
tcp_socket = get_tcp_socket(ipv6_header, tcp_header);
|
2012-02-03 03:11:30 +01:00
|
|
|
#endif
|
|
|
|
chksum = tcp_csum(ipv6_header, tcp_header);
|
2012-02-02 02:41:39 +01:00
|
|
|
print_tcp_status(INC_PACKET, ipv6_header, tcp_header, &tcp_socket->socket_values);
|
2012-01-25 03:38:22 +01:00
|
|
|
|
2011-10-28 04:37:12 +02:00
|
|
|
if ((chksum == 0xffff) && (tcp_socket != NULL))
|
2011-10-13 04:31:07 +02:00
|
|
|
{
|
2012-02-02 02:41:39 +01:00
|
|
|
#ifdef TCP_HC
|
2012-02-05 00:33:55 +01:00
|
|
|
update_tcp_hc_context(true, tcp_socket, tcp_header);
|
2012-02-02 02:41:39 +01:00
|
|
|
#endif
|
2011-10-28 04:37:12 +02:00
|
|
|
// Remove reserved bits from tcp flags field
|
2011-11-01 05:47:28 +01:00
|
|
|
uint8_t tcp_flags = tcp_header->reserved_flags & REMOVE_RESERVED;
|
2011-10-13 04:31:07 +02:00
|
|
|
|
2011-11-25 01:31:54 +01:00
|
|
|
// TODO: URG Flag and PSH flag are currently being ignored
|
2011-10-28 04:37:12 +02:00
|
|
|
switch (tcp_flags)
|
2011-10-13 04:31:07 +02:00
|
|
|
{
|
2011-10-28 04:37:12 +02:00
|
|
|
case TCP_ACK:
|
|
|
|
{
|
|
|
|
// only ACK Bit set
|
2011-11-08 02:14:58 +01:00
|
|
|
handle_tcp_ack_packet(ipv6_header, tcp_header, tcp_socket);
|
2011-10-28 04:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TCP_RST:
|
|
|
|
{
|
2011-11-01 05:47:28 +01:00
|
|
|
printf("RST Bit set!\n");
|
2011-10-28 04:37:12 +02:00
|
|
|
// only RST Bit set
|
2011-11-08 02:14:58 +01:00
|
|
|
handle_tcp_rst_packet(ipv6_header, tcp_header, tcp_socket);
|
2011-10-28 04:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TCP_SYN:
|
|
|
|
{
|
|
|
|
// only SYN Bit set, look for matching, listening socket and request new queued socket
|
2011-11-01 05:47:28 +01:00
|
|
|
printf("SYN Bit set!\n");
|
2011-11-08 02:14:58 +01:00
|
|
|
handle_tcp_syn_packet(ipv6_header, tcp_header, tcp_socket);
|
2011-10-28 04:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TCP_SYN_ACK:
|
2011-10-13 04:31:07 +02:00
|
|
|
{
|
2011-10-28 04:37:12 +02:00
|
|
|
// only SYN and ACK Bit set, complete three way handshake when socket in state SYN_SENT
|
2011-11-08 02:14:58 +01:00
|
|
|
handle_tcp_syn_ack_packet(ipv6_header, tcp_header, tcp_socket);
|
2011-10-28 04:37:12 +02:00
|
|
|
break;
|
2011-10-13 04:31:07 +02:00
|
|
|
}
|
2011-10-28 04:37:12 +02:00
|
|
|
case TCP_FIN:
|
2011-10-13 04:31:07 +02:00
|
|
|
{
|
2011-11-01 05:47:28 +01:00
|
|
|
printf("FIN Bit set!\n");
|
2011-10-28 04:37:12 +02:00
|
|
|
// only FIN Bit set
|
2011-11-08 02:14:58 +01:00
|
|
|
handle_tcp_fin_packet(ipv6_header, tcp_header, tcp_socket);
|
2011-10-28 04:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TCP_FIN_ACK:
|
|
|
|
{
|
2011-11-01 05:47:28 +01:00
|
|
|
printf("FIN ACK Bit set!\n");
|
2011-10-28 04:37:12 +02:00
|
|
|
// only FIN and ACK Bit set
|
2011-11-08 02:14:58 +01:00
|
|
|
handle_tcp_fin_ack_packet(ipv6_header, tcp_header, tcp_socket);
|
2011-10-28 04:37:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2012-01-28 16:15:09 +01:00
|
|
|
// printf("DEFAULT!\n");
|
2011-11-11 03:41:08 +01:00
|
|
|
handle_tcp_no_flags_packet(ipv6_header, tcp_header, tcp_socket, payload);
|
2011-10-13 04:31:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Wrong checksum (%x) or no corresponding socket found!\n", chksum);
|
|
|
|
}
|
2012-01-28 01:55:21 +01:00
|
|
|
|
2012-01-24 03:19:11 +01:00
|
|
|
msg_reply(&m_recv_ip, &m_send_ip);
|
2011-10-13 04:31:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|