Enforce coding conventions in destiny via astyle

dev/timer
Martin Lenders 10 years ago
parent 4825ec21b9
commit 6b999dc7bf

@ -1,5 +1,5 @@
/**
* Destiny transpor layer implementation
* Destiny transport layer implementation
*
* Copyright (C) 2013 INRIA.
*
@ -7,10 +7,10 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file destiny.c
* @brief transpor layer functions
* @brief transpor layer functions
* @author Oliver Gesch <oliver.gesch@googlemail.com>
* @}
*/

@ -7,7 +7,7 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file socket.c
* @brief functions for BSD socket API
@ -63,7 +63,7 @@ void print_tcp_flags(tcp_hdr_t *tcp_header)
{
printf("FLAGS: ");
switch(tcp_header->reserved_flags) {
switch (tcp_header->reserved_flags) {
case TCP_ACK: {
printf("ACK ");
break;
@ -109,7 +109,7 @@ void print_tcp_cb(tcp_cb_t *cb)
vtimer_now(&now);
printf("Send_ISS: %" PRIu32 "\nSend_UNA: %" PRIu32 "\nSend_NXT: %" PRIu32 "\nSend_WND: %u\n",
cb->send_iss, cb->send_una, cb->send_nxt, cb->send_wnd);
printf("Rcv_IRS: %" PRIu32 "\nRcv_NXT: %" PRIu32 "\nRcv_WND: %u\n",
printf("Rcv_IRS: %" PRIu32 "\nRcv_NXT: %" PRIu32 "\nRcv_WND: %u\n",
cb->rcv_irs, cb->rcv_nxt, cb->rcv_wnd);
printf("Time difference: %" PRIu32 ", No_of_retries: %u, State: %u\n\n",
timex_sub(now, cb->last_packet_time).microseconds, cb->no_of_retries, cb->state);
@ -121,9 +121,9 @@ void print_tcp_status(int in_or_out, ipv6_hdr_t *ipv6_header,
char addr_str[IPV6_MAX_ADDR_STR_LEN];
printf("--- %s TCP packet: ---\n",
(in_or_out == INC_PACKET ? "Incoming" : "Outgoing"));
printf("IPv6 Source: %s\n",
printf("IPv6 Source: %s\n",
ipv6_addr_to_str(addr_str, &ipv6_header->srcaddr));
printf("IPv6 Dest: %s\n",
printf("IPv6 Dest: %s\n",
ipv6_addr_to_str(addr_str, &ipv6_header->destaddr));
printf("TCP Length: %x\n", ipv6_header->length - TCP_HDR_LEN);
printf("Source Port: %x, Dest. Port: %x\n",
@ -148,8 +148,8 @@ void print_socket(socket_t *current_socket)
current_socket->domain,
current_socket->type,
current_socket->protocol);
printf("Local address: %s\n",
ipv6_addr_to_str(addr_str,
printf("Local address: %s\n",
ipv6_addr_to_str(addr_str,
&current_socket->local_address.sin6_addr));
printf("Foreign address: %s\n",
ipv6_addr_to_str(addr_str,
@ -210,10 +210,10 @@ void close_socket(socket_internal_t *current_socket)
bool isUDPSocket(uint8_t s)
{
if ((exists_socket(s)) &&
(get_socket(s)->socket_values.domain == PF_INET6) &&
(get_socket(s)->socket_values.type == SOCK_DGRAM) &&
((get_socket(s)->socket_values.protocol == IPPROTO_UDP) ||
(get_socket(s)->socket_values.protocol == 0))) {
(get_socket(s)->socket_values.domain == PF_INET6) &&
(get_socket(s)->socket_values.type == SOCK_DGRAM) &&
((get_socket(s)->socket_values.protocol == IPPROTO_UDP) ||
(get_socket(s)->socket_values.protocol == 0))) {
return true;
}
else {
@ -224,10 +224,10 @@ bool isUDPSocket(uint8_t s)
bool is_tcp_socket(int s)
{
if ((exists_socket(s)) &&
(get_socket(s)->socket_values.domain == PF_INET6) &&
(get_socket(s)->socket_values.type == SOCK_STREAM) &&
((get_socket(s)->socket_values.protocol == IPPROTO_TCP) ||
(get_socket(s)->socket_values.protocol == 0))) {
(get_socket(s)->socket_values.domain == PF_INET6) &&
(get_socket(s)->socket_values.type == SOCK_STREAM) &&
((get_socket(s)->socket_values.protocol == IPPROTO_TCP) ||
(get_socket(s)->socket_values.protocol == 0))) {
return true;
}
else {
@ -245,7 +245,7 @@ int bind_udp_socket(int s, sockaddr6_t *name, int namelen, uint8_t pid)
for (i = 1; i < MAX_SOCKETS + 1; i++) {
if (isUDPSocket(i) &&
(get_socket(i)->socket_values.local_address.sin6_port == name->sin6_port)) {
(get_socket(i)->socket_values.local_address.sin6_port == name->sin6_port)) {
return -1;
}
}
@ -265,7 +265,7 @@ int bind_tcp_socket(int s, sockaddr6_t *name, int namelen, uint8_t pid)
for (i = 1; i < MAX_SOCKETS + 1; i++) {
if (is_tcp_socket(i) &&
(get_socket(i)->socket_values.local_address.sin6_port == name->sin6_port)) {
(get_socket(i)->socket_values.local_address.sin6_port == name->sin6_port)) {
return -1;
}
}
@ -304,8 +304,8 @@ socket_internal_t *get_udp_socket(ipv6_hdr_t *ipv6_header, udp_hdr_t *udp_header
while (i < MAX_SOCKETS + 1) {
if (isUDPSocket(i) &&
(get_socket(i)->socket_values.local_address.sin6_port ==
udp_header->dst_port)) {
(get_socket(i)->socket_values.local_address.sin6_port ==
udp_header->dst_port)) {
return get_socket(i);
}
@ -339,20 +339,20 @@ socket_internal_t *get_tcp_socket(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header
/* Check for matching 4 touple, ESTABLISHED connection */
if (is_tcp_socket(i) && is_four_touple(current_socket, ipv6_header,
tcp_header)) {
tcp_header)) {
return current_socket;
}
/* Sockets in LISTEN and 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.local_address.sin6_addr.uint8[15] ==
ipv6_header->destaddr.uint8[15]) &&
(current_socket->socket_values.local_address.sin6_port ==
tcp_header->dst_port) &&
(current_socket->socket_values.foreign_address.sin6_addr.uint8[15] ==
0x00) &&
(current_socket->socket_values.foreign_address.sin6_port == 0)) {
((current_socket->socket_values.tcp_control.state == LISTEN) ||
(current_socket->socket_values.tcp_control.state == 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 ==
tcp_header->dst_port) &&
(current_socket->socket_values.foreign_address.sin6_addr.uint8[15] ==
0x00) &&
(current_socket->socket_values.foreign_address.sin6_port == 0)) {
listening_socket = current_socket;
}
@ -371,7 +371,7 @@ uint16_t get_free_source_port(uint8_t protocol)
/* Remember biggest ephemeral port number used so far and add 1 */
for (i = 0; i < MAX_SOCKETS; i++) {
if ((sockets[i].socket_values.protocol == protocol) &&
(sockets[i].socket_values.local_address.sin6_port > biggest_port)) {
(sockets[i].socket_values.local_address.sin6_port > biggest_port)) {
biggest_port = sockets[i].socket_values.local_address.sin6_port;
}
}
@ -380,7 +380,7 @@ uint16_t get_free_source_port(uint8_t protocol)
}
void set_socket_address(sockaddr6_t *sockaddr, uint8_t sin6_family,
uint16_t sin6_port, uint32_t sin6_flowinfo, ipv6_addr_t *sin6_addr)
uint16_t sin6_port, uint32_t sin6_flowinfo, ipv6_addr_t *sin6_addr)
{
sockaddr->sin6_family = sin6_family;
sockaddr->sin6_port = sin6_port;
@ -449,7 +449,7 @@ void switch_tcp_packet_byte_order(tcp_hdr_t *current_tcp_packet)
}
int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
ipv6_hdr_t *temp_ipv6_header, uint8_t flags, uint8_t payload_length)
ipv6_hdr_t *temp_ipv6_header, uint8_t flags, uint8_t payload_length)
{
socket_t *current_tcp_socket = &current_socket->socket_values;
uint8_t header_length = TCP_HDR_LEN / 4;
@ -462,7 +462,7 @@ int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
current_mss_option.len = sizeof(tcp_mss_option_t);
current_mss_option.mss = DESTINY_SOCKET_STATIC_MSS;
memcpy(((uint8_t *)current_tcp_packet) + TCP_HDR_LEN,
&current_mss_option, sizeof(tcp_mss_option_t));
&current_mss_option, sizeof(tcp_mss_option_t));
}
set_tcp_packet(current_tcp_packet, current_tcp_socket->local_address.sin6_port,
@ -474,9 +474,9 @@ int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
/* Fill IPv6 Header */
memcpy(&(temp_ipv6_header->destaddr),
&current_tcp_socket->foreign_address.sin6_addr, 16);
&current_tcp_socket->foreign_address.sin6_addr, 16);
memcpy(&(temp_ipv6_header->srcaddr),
&current_tcp_socket->local_address.sin6_addr, 16);
&current_tcp_socket->local_address.sin6_addr, 16);
temp_ipv6_header->length = header_length * 4 + payload_length;
current_tcp_packet->checksum = ~tcp_csum(temp_ipv6_header, current_tcp_packet);
@ -495,7 +495,7 @@ int send_tcp(socket_internal_t *current_socket, tcp_hdr_t *current_tcp_packet,
}
ipv6_sendto(&current_tcp_socket->foreign_address.sin6_addr,
IPPROTO_TCP, (uint8_t *)(current_tcp_packet),
IPPROTO_TCP, (uint8_t *)(current_tcp_packet),
compressed_size);
return 1;
#else
@ -621,7 +621,7 @@ int destiny_socket_connect(int socket, sockaddr6_t *addr, uint32_t addrlen)
/* Got SYN ACK from Server */
/* Refresh foreign TCP socket information */
if ((tcp_header->dataOffset_reserved * 4 > TCP_HDR_LEN) &&
(*(((uint8_t *)tcp_header) + TCP_HDR_LEN) == TCP_MSS_OPTION)) {
(*(((uint8_t *)tcp_header) + TCP_HDR_LEN) == TCP_MSS_OPTION)) {
current_tcp_socket->tcp_control.mss =
*((uint16_t *)(((uint8_t *)tcp_header) + TCP_HDR_LEN + 2));
}
@ -694,14 +694,14 @@ void calculate_rto(tcp_cb_t *tcp_control, long current_time)
srtt = rtt;
rttvar = 0.5 * rtt;
rto = rtt + (((4 * rttvar) < TCP_TIMER_RESOLUTION) ?
(TCP_TIMER_RESOLUTION) : (4 * rttvar));
(TCP_TIMER_RESOLUTION) : (4 * rttvar));
}
else {
/* every other calculation */
srtt = (1 - TCP_ALPHA) * srtt + TCP_ALPHA * rtt;
rttvar = (1 - TCP_BETA) * rttvar + TCP_BETA * abs(srtt - rtt);
rto = srtt + (((4 * rttvar) < TCP_TIMER_RESOLUTION) ?
(TCP_TIMER_RESOLUTION) : (4 * rttvar));
(TCP_TIMER_RESOLUTION) : (4 * rttvar));
}
if (rto < SECOND) {
@ -757,7 +757,7 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
while (recv_msg.type != TCP_ACK) {
/* Add packet data */
if (current_tcp_socket->tcp_control.send_wnd >
current_tcp_socket->tcp_control.mss) {
current_tcp_socket->tcp_control.mss) {
/* Window size > Maximum Segment Size */
if ((len - total_sent_bytes) > current_tcp_socket->tcp_control.mss) {
memcpy(&send_buffer[IPV6_HDR_LEN + TCP_HDR_LEN], buf,
@ -792,7 +792,7 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
current_tcp_socket->tcp_control.send_wnd -= sent_bytes;
if (send_tcp(current_int_tcp_socket, current_tcp_packet,
temp_ipv6_header, 0, sent_bytes) != 1) {
temp_ipv6_header, 0, sent_bytes) != 1) {
/* Error while sending tcp data */
current_tcp_socket->tcp_control.send_nxt -= sent_bytes;
current_tcp_socket->tcp_control.send_wnd += sent_bytes;
@ -800,7 +800,7 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
memcpy(&current_tcp_socket->tcp_control.tcp_context,
&saved_tcp_context, sizeof(tcp_hc_context_t));
current_tcp_socket->tcp_control.tcp_context.hc_type =
COMPRESSED_HEADER;
COMPRESSED_HEADER;
#endif
printf("Error while sending, returning to application thread!\n");
return -1;
@ -808,10 +808,10 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
/* Remember current time */
current_tcp_socket->tcp_control.last_packet_time.microseconds =
hwtimer_now();
hwtimer_now();
net_msg_receive(&recv_msg);
switch(recv_msg.type) {
switch (recv_msg.type) {
case TCP_ACK: {
if (current_tcp_socket->tcp_control.no_of_retries == 0) {
calculate_rto(&current_tcp_socket->tcp_control,
@ -821,26 +821,26 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
tcp_hdr_t *tcp_header = ((tcp_hdr_t *)(recv_msg.content.ptr));
if ((current_tcp_socket->tcp_control.send_nxt ==
tcp_header->ack_nr) && (total_sent_bytes == len)) {
tcp_header->ack_nr) && (total_sent_bytes == len)) {
current_tcp_socket->tcp_control.send_una = tcp_header->ack_nr;
current_tcp_socket->tcp_control.send_nxt = tcp_header->ack_nr;
current_tcp_socket->tcp_control.send_wnd = tcp_header->window;
/* Got ACK for every sent byte */
#ifdef TCP_HC
current_tcp_socket->tcp_control.tcp_context.hc_type =
COMPRESSED_HEADER;
COMPRESSED_HEADER;
#endif
return sent_bytes;
}
else if ((current_tcp_socket->tcp_control.send_nxt ==
tcp_header->ack_nr) && (total_sent_bytes != len)) {
tcp_header->ack_nr) && (total_sent_bytes != len)) {
current_tcp_socket->tcp_control.send_una = tcp_header->ack_nr;
current_tcp_socket->tcp_control.send_nxt = tcp_header->ack_nr;
current_tcp_socket->tcp_control.send_wnd = tcp_header->window;
/* Got ACK for every sent byte */
#ifdef TCP_HC
current_tcp_socket->tcp_control.tcp_context.hc_type =
COMPRESSED_HEADER;
COMPRESSED_HEADER;
#endif
break;
}
@ -862,7 +862,7 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
memcpy(&current_tcp_socket->tcp_control.tcp_context,
$&saved_tcp_context, sizeof(tcp_hc_context_t));
current_tcp_socket->tcp_control.tcp_context.hc_type =
MOSTLY_COMPRESSED_HEADER;
MOSTLY_COMPRESSED_HEADER;
#endif
break;
}
@ -874,7 +874,7 @@ int32_t destiny_socket_send(int s, const void *buf, uint32_t len, int flags)
memcpy(&current_tcp_socket->tcp_control.tcp_context,
&saved_tcp_context, sizeof(tcp_hc_context_t));
current_tcp_socket->tcp_control.tcp_context.hc_type =
COMPRESSED_HEADER;
COMPRESSED_HEADER;
#endif
return -1;
break;
@ -995,7 +995,7 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags,
sockaddr6_t *to, uint32_t tolen)
{
if (isUDPSocket(s) &&
(get_socket(s)->socket_values.foreign_address.sin6_port == 0)) {
(get_socket(s)->socket_values.foreign_address.sin6_port == 0)) {
uint8_t send_buffer[BUFFER_SIZE];
ipv6_hdr_t *temp_ipv6_header = ((ipv6_hdr_t *)(&send_buffer));
@ -1014,9 +1014,9 @@ int32_t destiny_socket_sendto(int s, const void *buf, uint32_t len, int flags,
temp_ipv6_header->length = UDP_HDR_LEN + len;
current_udp_packet->checksum = ~udp_csum(temp_ipv6_header,
current_udp_packet);
current_udp_packet);
ipv6_sendto(&to->sin6_addr, IPPROTO_UDP,
ipv6_sendto(&to->sin6_addr, IPPROTO_UDP,
(uint8_t *)(current_udp_packet),
current_udp_packet->length);
return current_udp_packet->length;
@ -1082,7 +1082,7 @@ int destiny_socket_bind(int s, sockaddr6_t *addr, int addrlen)
if (exists_socket(s)) {
socket_t *current_socket = &get_socket(s)->socket_values;
switch(current_socket->domain) {
switch (current_socket->domain) {
case (PF_INET): {
/* Not provided */
return -1;
@ -1090,7 +1090,7 @@ int destiny_socket_bind(int s, sockaddr6_t *addr, int addrlen)
}
case (PF_INET6): {
switch(current_socket->type) {
switch (current_socket->type) {
/* TCP */
case (SOCK_STREAM): {
if ((current_socket->protocol == 0) ||
@ -1172,8 +1172,8 @@ int destiny_socket_listen(int s, int backlog)
}
socket_internal_t *get_waiting_connection_socket(int socket,
ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header)
ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header)
{
int i;
socket_internal_t *current_socket, *listening_socket = get_socket(socket);
@ -1184,15 +1184,15 @@ 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 == 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) &&
(current_socket->socket_values.local_address.sin6_port ==
listening_socket->socket_values.local_address.sin6_port)) {
(current_socket->socket_values.local_address.sin6_port ==
listening_socket->socket_values.local_address.sin6_port)) {
return current_socket;
}
}
@ -1320,7 +1320,7 @@ int destiny_socket_accept(int s, sockaddr6_t *addr, uint32_t *addrlen)
}
socket_internal_t *new_tcp_queued_socket(ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header)
tcp_hdr_t *tcp_header)
{
int queued_socket_id;
@ -1339,7 +1339,7 @@ socket_internal_t *new_tcp_queued_socket(ipv6_hdr_t *ipv6_header,
/* Foreign TCP information */
if ((tcp_header->dataOffset_reserved * 4 > TCP_HDR_LEN) &&
(*(((uint8_t *)tcp_header) + TCP_HDR_LEN) == TCP_MSS_OPTION)) {
(*(((uint8_t *)tcp_header) + TCP_HDR_LEN) == TCP_MSS_OPTION)) {
current_queued_socket->socket_values.tcp_control.mss =
*((uint16_t *)(((uint8_t *)tcp_header) + TCP_HDR_LEN + 2));
}

@ -72,8 +72,8 @@ typedef struct __attribute__((packed)) {
extern socket_internal_t sockets[MAX_SOCKETS];
socket_internal_t *get_waiting_connection_socket(int socket,
ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header);
ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header);
void close_socket(socket_internal_t *current_socket);
socket_internal_t *get_socket(int s);
socket_internal_t *get_udp_socket(ipv6_hdr_t *ipv6_header,
@ -81,7 +81,7 @@ socket_internal_t *get_udp_socket(ipv6_hdr_t *ipv6_header,
socket_internal_t *get_tcp_socket(ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header);
socket_internal_t *new_tcp_queued_socket(ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header);
tcp_hdr_t *tcp_header);
void print_tcp_status(int in_or_out, ipv6_hdr_t *ipv6_header,
tcp_hdr_t *tcp_header, socket_t *tcp_socket);
void set_tcp_cb(tcp_cb_t *tcp_control, uint32_t rcv_nxt, uint16_t rcv_wnd,

@ -1,5 +1,5 @@
/**
* Destiny TCP implementation
* Destiny TCP implementation
*
* Copyright (C) 2013 INRIA.
*
@ -7,10 +7,10 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file tcp.c
* @brief TCP implementation
* @brief TCP implementation
* @author Oliver Gesch <oliver.gesch@googlemail.com>
* @}
*/
@ -87,7 +87,7 @@ uint8_t handle_payload(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
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;
tcp_socket->socket_values.tcp_control.rcv_wnd;
mutex_unlock(&tcp_socket->tcp_buffer_mutex);
}
else {
@ -97,7 +97,7 @@ uint8_t handle_payload(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
tcp_socket->socket_values.tcp_control.rcv_wnd - tcp_payload_len;
acknowledged_bytes = tcp_payload_len;
tcp_socket->tcp_input_buffer_end = tcp_socket->tcp_input_buffer_end +
tcp_payload_len;
tcp_payload_len;
mutex_unlock(&tcp_socket->tcp_buffer_mutex);
}
@ -155,7 +155,7 @@ void handle_tcp_syn_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
if (tcp_socket->socket_values.tcp_control.state == LISTEN) {
socket_internal_t *new_socket = new_tcp_queued_socket(ipv6_header,
tcp_header);
tcp_header);
if (new_socket != NULL) {
#ifdef TCP_HC
@ -312,7 +312,7 @@ void tcp_packet_handler(void)
chksum = tcp_csum(ipv6_header, tcp_header);
payload = (uint8_t *)(m_recv_ip.content.ptr + IPV6_HDR_LEN +
tcp_header->dataOffset_reserved * 4);
tcp_header->dataOffset_reserved * 4);
if ((chksum == 0xffff) && (tcp_socket != NULL)) {
#ifdef TCP_HC
@ -321,7 +321,7 @@ void tcp_packet_handler(void)
/* Remove reserved bits from tcp flags field */
uint8_t tcp_flags = tcp_header->reserved_flags & REMOVE_RESERVED;
switch(tcp_flags) {
switch (tcp_flags) {
case TCP_ACK: {
/* only ACK Bit set */
handle_tcp_ack_packet(ipv6_header, tcp_header, tcp_socket);

@ -7,7 +7,7 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file tcp.c
* @brief TCP data structs and prototypes

@ -1,5 +1,5 @@
/**
* Destiny TCP header compression
* Destiny TCP header compression
*
* Copyright (C) 2013 INRIA.
*
@ -7,10 +7,10 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file tcp_hc.c
* @brief TCP HC
* @brief TCP HC
* @author Oliver Gesch <oliver.gesch@googlemail.com>
* @}
*/
@ -32,7 +32,7 @@
#ifdef TCP_HC
socket_internal_t *get_tcp_socket_by_context(ipv6_hdr_t *current_ipv6_header,
uint16_t current_context)
uint16_t current_context)
{
socket_internal_t *temp_socket;
@ -40,12 +40,12 @@ socket_internal_t *get_tcp_socket_by_context(ipv6_hdr_t *current_ipv6_header,
temp_socket = get_socket(i);
if ((temp_socket != NULL) &&
ipv6_addr_is_equal(&temp_socket->socket_values.foreign_address.sin6_addr,
&current_ipv6_header->srcaddr) &&
ipv6_addr_is_equal(&temp_socket->socket_values.local_address.sin6_addr,
&current_ipv6_header->destaddr) &&
(temp_socket->socket_values.tcp_control.tcp_context.context_id ==
current_context)) {
ipv6_addr_is_equal(&temp_socket->socket_values.foreign_address.sin6_addr,
&current_ipv6_header->srcaddr) &&
ipv6_addr_is_equal(&temp_socket->socket_values.local_address.sin6_addr,
&current_ipv6_header->destaddr) &&
(temp_socket->socket_values.tcp_control.tcp_context.context_id ==
current_context)) {
return temp_socket;
}
}
@ -103,7 +103,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket,
/* Return correct header length (+3) */
packet_size = ((((tcp_hdr_t *)(current_tcp_packet + 3))->dataOffset_reserved) * 4) + 3 +
payload_length;
payload_length;
/* Update the tcp context fields */
update_tcp_hc_context(false, current_socket, (tcp_hdr_t *)(current_tcp_packet + 3));
@ -150,7 +150,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket,
/* If the 24 most significant bits haven't changed from previous
* packet, don't transmit them */
else if ((full_tcp_header.seq_nr & 0xFFFFFF00) == (tcp_context->seq_snd &
0xFFFFFF00)) {
0xFFFFFF00)) {
/* Seq = (0|1) */
tcp_hc_header |= 0x0400;
@ -188,7 +188,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket,
/*| Acknowledgment number handling |*/
/*----------------------------------*/
if ((IS_TCP_ACK(full_tcp_header.reserved_flags) &&
(tcp_cb->tcp_context.ack_snd == full_tcp_header.ack_nr))) {
(tcp_cb->tcp_context.ack_snd == full_tcp_header.ack_nr))) {
tcp_context->ack_snd = tcp_context->seq_rcv;
}
@ -198,7 +198,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket,
/* If the 24 most significant bits haven't changed from previous packet,
* don't transmit them */
else if ((full_tcp_header.ack_nr & 0xFFFFFF00) == (tcp_context->ack_snd &
0xFFFFFF00)) {
0xFFFFFF00)) {
/* Ack = (0|1) */
tcp_hc_header |= 0x0100;
@ -211,7 +211,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket,
/* If the 16 most significant bits haven't changed from previous packet,
* don't transmit them */
else if ((full_tcp_header.ack_nr & 0xFFFF0000) == (tcp_context->ack_snd &
0xFFFF0000)) {
0xFFFF0000)) {
/* Ack = (1|0) */
tcp_hc_header |= 0x0200;
@ -254,7 +254,7 @@ uint16_t compress_tcp_packet(socket_internal_t *current_socket,
/* If the 8 less significant bits haven't changed from previous packet,
* don't transmit them */
else if ((full_tcp_header.window & 0x00FF) == (tcp_context->wnd_snd &
0x00FF)) {
0x00FF)) {
/* Wnd = (1|0) */
tcp_hc_header |= 0x0080;
@ -415,10 +415,10 @@ socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header)
/* Full header TCP segment */
if (*(((uint8_t *)temp_ipv6_header) + IPV6_HDR_LEN) == 0x01) {
switch_tcp_packet_byte_order(((tcp_hdr_t *)(((uint8_t *)temp_ipv6_header) +
IPV6_HDR_LEN + 3)));
IPV6_HDR_LEN + 3)));
current_socket = get_tcp_socket(temp_ipv6_header,
((tcp_hdr_t *)(((uint8_t *)temp_ipv6_header) +
IPV6_HDR_LEN + 3)));
IPV6_HDR_LEN + 3)));
if (current_socket != NULL) {
if (current_socket->socket_values.tcp_control.state == LISTEN) {
@ -459,11 +459,11 @@ socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header)
uint8_t header_type = UNDEFINED;
if (BITSET(tcp_hc_header, 15) && !BITSET(tcp_hc_header, 14) &&
!BITSET(tcp_hc_header, 13)) {
!BITSET(tcp_hc_header, 13)) {
header_type = MOSTLY_COMPRESSED_HEADER;
}
else if (BITSET(tcp_hc_header, 15) && BITSET(tcp_hc_header, 14) &&
!BITSET(tcp_hc_header, 13)) {
!BITSET(tcp_hc_header, 13)) {
header_type = COMPRESSED_HEADER;
}
@ -624,7 +624,7 @@ socket_internal_t *decompress_tcp_packet(ipv6_hdr_t *temp_ipv6_header)
/* Copy TCP uncompressed header in front of payload */
memcpy(((uint8_t *)temp_ipv6_header) + IPV6_HDR_LEN, &full_tcp_header,
TCP_HDR_LEN);
TCP_HDR_LEN);
/* Set IPV6 header length */
temp_ipv6_header->length = temp_ipv6_header->length - packet_size +

@ -1,5 +1,5 @@
/**
* Destiny TCP timer implementation
* Destiny TCP timer implementation
*
* Copyright (C) 2013 INRIA.
*
@ -7,10 +7,10 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file tcp_timer.c
* @brief TCP timer
* @brief TCP timer
* @author Oliver Gesch <oliver.gesch@googlemail.com>
* @}
*/
@ -41,21 +41,21 @@ void handle_synchro_timeout(socket_internal_t *current_socket)
vtimer_now(&now);
if ((current_socket->socket_values.tcp_control.no_of_retries == 0) &&
(timex_sub(now,
current_socket->socket_values.tcp_control.last_packet_time).microseconds >
TCP_SYN_INITIAL_TIMEOUT)) {
(timex_sub(now,
current_socket->socket_values.tcp_control.last_packet_time).microseconds >
TCP_SYN_INITIAL_TIMEOUT)) {
current_socket->socket_values.tcp_control.no_of_retries++;
net_msg_send(&send, current_socket->recv_pid, 0, TCP_RETRY);
}
else if ((current_socket->socket_values.tcp_control.no_of_retries > 0) &&
(timex_sub(now,
current_socket->socket_values.tcp_control.last_packet_time).microseconds >
(current_socket->socket_values.tcp_control.no_of_retries *
TCP_SYN_TIMEOUT + TCP_SYN_INITIAL_TIMEOUT))) {
(timex_sub(now,
current_socket->socket_values.tcp_control.last_packet_time).microseconds >
(current_socket->socket_values.tcp_control.no_of_retries *
TCP_SYN_TIMEOUT + TCP_SYN_INITIAL_TIMEOUT))) {
current_socket->socket_values.tcp_control.no_of_retries++;
if (current_socket->socket_values.tcp_control.no_of_retries >
TCP_MAX_SYN_RETRIES) {
TCP_MAX_SYN_RETRIES) {
net_msg_send(&send, current_socket->recv_pid, 0, TCP_TIMEOUT);
}
else {
@ -77,10 +77,10 @@ void handle_established(socket_internal_t *current_socket)
uint8_t i;
if ((current_socket->socket_values.tcp_control.send_nxt >
current_socket->socket_values.tcp_control.send_una) &&
(thread_getstatus(current_socket->send_pid) == STATUS_RECEIVE_BLOCKED)) {
current_socket->socket_values.tcp_control.send_una) &&
(thread_getstatus(current_socket->send_pid) == STATUS_RECEIVE_BLOCKED)) {
for (i = 0; i < current_socket->socket_values.tcp_control.no_of_retries;
i++) {
i++) {
current_timeout *= 2;
}
@ -91,7 +91,7 @@ void handle_established(socket_internal_t *current_socket)
net_msg_send(&send, current_socket->send_pid, 0, TCP_TIMEOUT);
}
else if (timex_sub(now, current_socket->socket_values.tcp_control.last_packet_time).microseconds >
current_timeout) {
current_timeout) {
current_socket->socket_values.tcp_control.no_of_retries++;
net_msg_send(&send, current_socket->send_pid, 0, TCP_RETRY);
}
@ -107,7 +107,7 @@ void check_sockets(void)
current_socket = get_socket(i);
if (is_tcp_socket(i)) {
switch(current_socket->socket_values.tcp_control.state) {
switch (current_socket->socket_values.tcp_control.state) {
case ESTABLISHED: {
handle_established(current_socket);
break;

@ -1,5 +1,5 @@
/**
* Destiny UDP implementation
* Destiny UDP implementation
*
* Copyright (C) 2013 INRIA.
*
@ -7,10 +7,10 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file udp.c
* @brief UDP implementation
* @brief UDP implementation
* @author Oliver Gesch <oliver.gesch@googlemail.com>
* @}
*/

@ -7,7 +7,7 @@
* Public License. See the file LICENSE in the top level directory for more
* details.
*
* @ingroup destiny
* @ingroup destiny
* @{
* @file udp.c
* @brief UDP data structs and prototypes

Loading…
Cancel
Save