1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

net: destiny: renamed internal TCP enums

Rationale: LISTEN was used in MSP430-Lib for the USART.
This commit is contained in:
Oleg Hahm 2014-03-17 19:36:30 +01:00
parent a427cce09b
commit 5e4a9c0e94
4 changed files with 51 additions and 51 deletions

View File

@ -294,7 +294,7 @@ int destiny_socket(int domain, int type, int protocol)
current_socket->domain = domain;
current_socket->type = type;
current_socket->protocol = protocol;
current_socket->tcp_control.state = CLOSED;
current_socket->tcp_control.state = TCP_CLOSED;
return sockets[i - 1].socket_id;
}
}
@ -338,15 +338,15 @@ socket_internal_t *get_tcp_socket(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header
while (i < MAX_SOCKETS + 1) {
current_socket = get_socket(i);
/* Check for matching 4 touple, ESTABLISHED connection */
/* Check for matching 4 touple, TCP_ESTABLISHED connection */
if (is_tcp_socket(i) && is_four_touple(current_socket, ipv6_header,
tcp_header)) {
return current_socket;
}
/* Sockets in LISTEN and SYN_RCVD state should only be tested on local TCP values */
/* Sockets in TCP_LISTEN and TCP_SYN_RCVD state should only be tested on local TCP values */
else if (is_tcp_socket(i) &&
((current_socket->socket_values.tcp_control.state == LISTEN) ||
(current_socket->socket_values.tcp_control.state == SYN_RCVD)) &&
((current_socket->socket_values.tcp_control.state == TCP_LISTEN) ||
(current_socket->socket_values.tcp_control.state == TCP_SYN_RCVD)) &&
(current_socket->socket_values.local_address.sin6_addr.uint8[15] ==
ipv6_header->destaddr.uint8[15]) &&
(current_socket->socket_values.local_address.sin6_port ==
@ -556,7 +556,7 @@ int destiny_socket_connect(int socket, sockaddr6_t *addr, uint32_t addrlen)
mutex_lock(&global_sequence_clunter_mutex);
current_tcp_socket->tcp_control.send_iss = global_sequence_counter;
mutex_unlock(&global_sequence_clunter_mutex);
current_tcp_socket->tcp_control.state = SYN_SENT;
current_tcp_socket->tcp_control.state = TCP_SYN_SENT;
#ifdef TCP_HC
/* Choosing random number Context ID */
@ -675,7 +675,7 @@ int destiny_socket_connect(int socket, sockaddr6_t *addr, uint32_t addrlen)
#endif
}
current_tcp_socket->tcp_control.state = ESTABLISHED;
current_tcp_socket->tcp_control.state = TCP_ESTABLISHED;
current_int_tcp_socket->recv_pid = 255;
@ -737,8 +737,8 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
current_int_tcp_socket = get_socket(s);
current_tcp_socket = &current_int_tcp_socket->socket_values;
/* Check for ESTABLISHED STATE */
if (current_tcp_socket->tcp_control.state != ESTABLISHED) {
/* Check for TCP_ESTABLISHED STATE */
if (current_tcp_socket->tcp_control.state != TCP_ESTABLISHED) {
return -1;
}
@ -1054,8 +1054,8 @@ int destiny_socket_close(int s)
return -1;
}
/* Check for ESTABLISHED STATE */
if (current_socket->socket_values.tcp_control.state != ESTABLISHED) {
/* Check for TCP_ESTABLISHED STATE */
if (current_socket->socket_values.tcp_control.state != TCP_ESTABLISHED) {
close_socket(current_socket);
return 0;
}
@ -1064,7 +1064,7 @@ int destiny_socket_close(int s)
/* Refresh local TCP socket information */
current_socket->socket_values.tcp_control.send_una++;
current_socket->socket_values.tcp_control.state = FIN_WAIT_1;
current_socket->socket_values.tcp_control.state = TCP_FIN_WAIT_1;
#ifdef TCP_HC
current_socket->socket_values.tcp_control.tcp_context.hc_type =
COMPRESSED_HEADER;
@ -1174,9 +1174,9 @@ int destiny_socket_listen(int s, int backlog)
{
(void) backlog;
if (is_tcp_socket(s) && get_socket(s)->socket_values.tcp_control.state == CLOSED) {
if (is_tcp_socket(s) && get_socket(s)->socket_values.tcp_control.state == TCP_CLOSED) {
socket_internal_t *current_socket = get_socket(s);
current_socket->socket_values.tcp_control.state = LISTEN;
current_socket->socket_values.tcp_control.state = TCP_LISTEN;
return 0;
}
else {
@ -1197,13 +1197,13 @@ socket_internal_t *get_waiting_connection_socket(int socket,
/* Connection establishment ACK, Check for 4 touple and state */
if ((ipv6_header != NULL) && (tcp_header != NULL)) {
if (is_four_touple(current_socket, ipv6_header, tcp_header) &&
(current_socket->socket_values.tcp_control.state == SYN_RCVD)) {
(current_socket->socket_values.tcp_control.state == TCP_SYN_RCVD)) {
return current_socket;
}
}
/* Connection establishment SYN ACK, check only for port and state */
else {
if ((current_socket->socket_values.tcp_control.state == SYN_RCVD) &&
if ((current_socket->socket_values.tcp_control.state == TCP_SYN_RCVD) &&
(current_socket->socket_values.local_address.sin6_port ==
listening_socket->socket_values.local_address.sin6_port)) {
return current_socket;
@ -1252,8 +1252,8 @@ int handle_new_tcp_connection(socket_internal_t *current_queued_int_socket,
msg_receive(&msg_recv_client_ack);
if (msg_recv_client_ack.type == TCP_TIMEOUT) {
/* Set status of internal socket back to LISTEN */
server_socket->socket_values.tcp_control.state = LISTEN;
/* Set status of internal socket back to TCP_LISTEN */
server_socket->socket_values.tcp_control.state = TCP_LISTEN;
close_socket(current_queued_int_socket);
return -1;
@ -1282,10 +1282,10 @@ int handle_new_tcp_connection(socket_internal_t *current_queued_int_socket,
#endif
/* Update connection status information */
current_queued_socket->tcp_control.state = ESTABLISHED;
current_queued_socket->tcp_control.state = TCP_ESTABLISHED;
/* Set status of internal socket back to LISTEN */
server_socket->socket_values.tcp_control.state = LISTEN;
/* Set status of internal socket back to TCP_LISTEN */
server_socket->socket_values.tcp_control.state = TCP_LISTEN;
/* send a reply to the TCP handler after processing every information from
* the TCP ACK packet */
@ -1309,7 +1309,7 @@ int destiny_socket_accept(int s, sockaddr6_t *addr, uint32_t *addrlen)
socket_internal_t *server_socket = get_socket(s);
if (is_tcp_socket(s) && (server_socket->socket_values.tcp_control.state == LISTEN)) {
if (is_tcp_socket(s) && (server_socket->socket_values.tcp_control.state == TCP_LISTEN)) {
socket_internal_t *current_queued_socket =
get_waiting_connection_socket(s, NULL, NULL);
@ -1371,7 +1371,7 @@ socket_internal_t *new_tcp_queued_socket(ipv6_hdr_t *ipv6_header,
current_queued_socket->socket_values.tcp_control.send_iss =
global_sequence_counter;
mutex_unlock(&global_sequence_clunter_mutex);
current_queued_socket->socket_values.tcp_control.state = SYN_RCVD;
current_queued_socket->socket_values.tcp_control.state = TCP_SYN_RCVD;
set_tcp_cb(&current_queued_socket->socket_values.tcp_control,
tcp_header->seq_nr + 1, DESTINY_SOCKET_STATIC_WINDOW,
current_queued_socket->socket_values.tcp_control.send_iss,

View File

@ -116,13 +116,13 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
msg_t m_recv_tcp, m_send_tcp;
uint8_t target_pid;
if (tcp_socket->socket_values.tcp_control.state == LAST_ACK) {
if (tcp_socket->socket_values.tcp_control.state == TCP_LAST_ACK) {
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) {
else if (tcp_socket->socket_values.tcp_control.state == TCP_CLOSING) {
msg_send(&m_send_tcp, tcp_socket->recv_pid, 0);
msg_send(&m_send_tcp, tcp_socket->send_pid, 0);
return;
@ -133,7 +133,7 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
net_msg_send_recv(&m_send_tcp, &m_recv_tcp, tcp_socket->recv_pid, TCP_ACK);
return;
}
else if (tcp_socket->socket_values.tcp_control.state == ESTABLISHED) {
else if (tcp_socket->socket_values.tcp_control.state == TCP_ESTABLISHED) {
if (check_tcp_consistency(&tcp_socket->socket_values, tcp_header) == PACKET_OK) {
m_send_tcp.content.ptr = (char *)tcp_header;
net_msg_send(&m_send_tcp, tcp_socket->send_pid, 0, TCP_ACK);
@ -159,7 +159,7 @@ void handle_tcp_syn_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
{
msg_t m_send_tcp;
if (tcp_socket->socket_values.tcp_control.state == LISTEN) {
if (tcp_socket->socket_values.tcp_control.state == TCP_LISTEN) {
socket_internal_t *new_socket = new_tcp_queued_socket(ipv6_header,
tcp_header);
@ -179,7 +179,7 @@ void handle_tcp_syn_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
}
}
else {
printf("Dropped TCP SYN Message because socket was not in state LISTEN!");
printf("Dropped TCP SYN Message because socket was not in state TCP_LISTEN!");
}
}
@ -190,12 +190,12 @@ void handle_tcp_syn_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
msg_t m_send_tcp;
if (tcp_socket->socket_values.tcp_control.state == SYN_SENT) {
if (tcp_socket->socket_values.tcp_control.state == TCP_SYN_SENT) {
m_send_tcp.content.ptr = (char *) tcp_header;
net_msg_send(&m_send_tcp, tcp_socket->recv_pid, 0, TCP_SYN_ACK);
}
else {
printf("Socket not in state SYN_SENT, dropping SYN-ACK-packet!");
printf("Socket not in state TCP_SYN_SENT, dropping SYN-ACK-packet!");
}
}
@ -218,13 +218,13 @@ void handle_tcp_fin_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
current_tcp_socket->tcp_control.tcp_context.hc_type = COMPRESSED_HEADER;
#endif
if (current_tcp_socket->tcp_control.state == FIN_WAIT_1) {
current_tcp_socket->tcp_control.state = CLOSING;
if (current_tcp_socket->tcp_control.state == TCP_FIN_WAIT_1) {
current_tcp_socket->tcp_control.state = TCP_CLOSING;
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_FIN_ACK, 0);
}
else {
current_tcp_socket->tcp_control.state = LAST_ACK;
current_tcp_socket->tcp_control.state = TCP_LAST_ACK;
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_FIN_ACK, 0);
}
@ -243,7 +243,7 @@ void handle_tcp_fin_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
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]));
current_tcp_socket->tcp_control.state = CLOSED;
current_tcp_socket->tcp_control.state = TCP_CLOSED;
set_tcp_cb(&current_tcp_socket->tcp_control, tcp_header->seq_nr + 1,
current_tcp_socket->tcp_control.send_wnd, tcp_header->ack_nr,
@ -274,7 +274,7 @@ void handle_tcp_no_flags_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
read_bytes = handle_payload(ipv6_header, tcp_header, tcp_socket, payload);
/* Refresh TCP status values */
current_tcp_socket->tcp_control.state = ESTABLISHED;
current_tcp_socket->tcp_control.state = TCP_ESTABLISHED;
set_tcp_cb(&current_tcp_socket->tcp_control,
tcp_header->seq_nr + read_bytes,
@ -357,7 +357,7 @@ void tcp_packet_handler(void)
case TCP_SYN_ACK: {
/* only SYN and ACK Bit set, complete three way handshake
* when socket in state SYN_SENT */
* when socket in state TCP_SYN_SENT */
handle_tcp_syn_ack_packet(ipv6_header, tcp_header, tcp_socket);
break;
}

View File

@ -37,18 +37,18 @@ enum tcp_flags {
};
enum tcp_states {
CLOSED = 0,
LISTEN = 1,
SYN_SENT = 2,
SYN_RCVD = 3,
ESTABLISHED = 4,
FIN_WAIT_1 = 5,
FIN_WAIT_2 = 6,
CLOSE_WAIT = 7,
CLOSING = 8,
LAST_ACK = 9,
TIME_WAIT = 10,
UNKNOWN = 11
TCP_CLOSED = 0,
TCP_LISTEN = 1,
TCP_SYN_SENT = 2,
TCP_SYN_RCVD = 3,
TCP_ESTABLISHED = 4,
TCP_FIN_WAIT_1 = 5,
TCP_FIN_WAIT_2 = 6,
TCP_CLOSE_WAIT = 7,
TCP_CLOSING = 8,
TCP_LAST_ACK = 9,
TCP_TIME_WAIT = 10,
TCP_UNKNOWN = 11
};
enum tcp_codes {

View File

@ -103,17 +103,17 @@ void check_sockets(void)
if (is_tcp_socket(i)) {
switch (current_socket->socket_values.tcp_control.state) {
case ESTABLISHED: {
case TCP_ESTABLISHED: {
handle_established(current_socket);
break;
}
case SYN_SENT: {
case TCP_SYN_SENT: {
handle_synchro_timeout(current_socket);
break;
}
case SYN_RCVD: {
case TCP_SYN_RCVD: {
handle_synchro_timeout(current_socket);
break;
}