Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -102,5 +102,5 @@
  *  @returns The computed checksum.
  */
-#define ICMP_CHECKSUM( header, length )		htons( ip_checksum(( uint8_t * ) ( header ), ( length )))
+#define ICMP_CHECKSUM(header, length)		htons(ip_checksum((uint8_t *) (header), (length)))
 
 /** An echo request datagrams pattern.
@@ -113,5 +113,5 @@
  *  @returns The computed ICMP reply data key.
  */
-#define ICMP_GET_REPLY_KEY( id, sequence )	((( id ) << 16 ) | ( sequence & 0xFFFF ))
+#define ICMP_GET_REPLY_KEY(id, sequence)	(((id) << 16) | (sequence &0xFFFF))
 
 /** Processes the received ICMP packet.
@@ -125,5 +125,5 @@
  *  @returns Other error codes as defined for the icmp_process_packet() function.
  */
-int	icmp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error );
+int icmp_received_msg(device_id_t device_id, packet_t packet, services_t receiver, services_t error);
 
 /** Processes the received ICMP packet.
@@ -140,5 +140,5 @@
  *  @returns Other error codes as defined for the ip_client_process_packet() function.
  */
-int	icmp_process_packet( packet_t packet, services_t error );
+int icmp_process_packet(packet_t packet, services_t error);
 
 /** Processes the client messages.
@@ -151,5 +151,5 @@
  *  @see icmp_api.h
  */
-int icmp_process_client_messages( ipc_callid_t callid, ipc_call_t call );
+int icmp_process_client_messages(ipc_callid_t callid, ipc_call_t call);
 
 /** Processes the generic client messages.
@@ -164,5 +164,5 @@
  *  @see icmp_interface.h
  */
-int	icmp_process_message( ipc_call_t * call );
+int icmp_process_message(ipc_call_t * call);
 
 /** Releases the packet and returns the result.
@@ -171,5 +171,5 @@
  *  @returns The result parameter.
  */
-int	icmp_release_and_return( packet_t packet, int result );
+int icmp_release_and_return(packet_t packet, int result);
 
 /** Requests an echo message.
@@ -192,5 +192,5 @@
  *  @returns EPARTY if there was an internal error.
  */
-int	icmp_echo( icmp_param_t id, icmp_param_t sequence, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen );
+int icmp_echo(icmp_param_t id, icmp_param_t sequence, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen);
 
 /** Prepares the ICMP error packet.
@@ -201,5 +201,5 @@
  *  @returns NULL on errors.
  */
-icmp_header_ref	icmp_prepare_packet( packet_t packet );
+icmp_header_ref icmp_prepare_packet(packet_t packet);
 
 /** Sends the ICMP message.
@@ -218,5 +218,5 @@
  *  @returns EPERM if the error message is not allowed.
  */
-int	icmp_send_packet( icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header, services_t error, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment );
+int icmp_send_packet(icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header, services_t error, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment);
 
 /** Tries to set the pending reply result as the received message type.
@@ -230,5 +230,5 @@
  *  @returns EOK.
  */
-int	icmp_process_echo_reply( packet_t packet, icmp_header_ref header, icmp_type_t type, icmp_code_t code );
+int icmp_process_echo_reply(packet_t packet, icmp_header_ref header, icmp_type_t type, icmp_code_t code);
 
 /** Assigns a new identifier for the connection.
@@ -239,5 +239,5 @@
  *  @returns ENOTCONN if no free identifier have been found.
  */
-int	icmp_bind_free_id( icmp_echo_ref echo_data );
+int icmp_bind_free_id(icmp_echo_ref echo_data);
 
 /** ICMP global data.
@@ -245,20 +245,20 @@
 icmp_globals_t	icmp_globals;
 
-INT_MAP_IMPLEMENT( icmp_replies, icmp_reply_t );
-
-INT_MAP_IMPLEMENT( icmp_echo_data, icmp_echo_t );
-
-int icmp_echo_msg( int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen ){
-	icmp_echo_ref	echo_data;
-	int				res;
-
-	fibril_rwlock_write_lock( & icmp_globals.lock );
+INT_MAP_IMPLEMENT(icmp_replies, icmp_reply_t);
+
+INT_MAP_IMPLEMENT(icmp_echo_data, icmp_echo_t);
+
+int icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen){
+	icmp_echo_ref echo_data;
+	int res;
+
+	fibril_rwlock_write_lock(&icmp_globals.lock);
 	// use the phone as the echo data index
-	echo_data = icmp_echo_data_find( & icmp_globals.echo_data, icmp_phone );
-	if( ! echo_data ){
+	echo_data = icmp_echo_data_find(&icmp_globals.echo_data, icmp_phone);
+	if(! echo_data){
 		res = ENOENT;
 	}else{
-		res = icmp_echo( echo_data->identifier, echo_data->sequence_number, size, timeout, ttl, tos, dont_fragment, addr, addrlen );
-		if( echo_data->sequence_number < MAX_UINT16 ){
+		res = icmp_echo(echo_data->identifier, echo_data->sequence_number, size, timeout, ttl, tos, dont_fragment, addr, addrlen);
+		if(echo_data->sequence_number < MAX_UINT16){
 			++ echo_data->sequence_number;
 		}else{
@@ -266,83 +266,85 @@
 		}
 	}
-	fibril_rwlock_write_unlock( & icmp_globals.lock );
+	fibril_rwlock_write_unlock(&icmp_globals.lock);
 	return res;
 }
 
-int icmp_echo( icmp_param_t id, icmp_param_t sequence, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen ){
+int icmp_echo(icmp_param_t id, icmp_param_t sequence, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen){
 	ERROR_DECLARE;
 
-	icmp_header_ref	header;
-	packet_t		packet;
-	size_t			length;
-	uint8_t *		data;
-	icmp_reply_ref			reply;
-	int				reply_key;
-	int				result;
-	int				index;
-
-	if( addrlen <= 0 ){
+	icmp_header_ref header;
+	packet_t packet;
+	size_t length;
+	uint8_t * data;
+	icmp_reply_ref reply;
+	int reply_key;
+	int result;
+	int index;
+
+	if(addrlen <= 0){
 		return EINVAL;
 	}
-	length = ( size_t ) addrlen;
+	length = (size_t) addrlen;
 	// TODO do not ask all the time
-	ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.packet_dimension ));
-	packet = packet_get_4( icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix );
-	if( ! packet ) return ENOMEM;
+	ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1, &icmp_globals.packet_dimension));
+	packet = packet_get_4(icmp_globals.net_phone, size, icmp_globals.packet_dimension.addr_len, ICMP_HEADER_SIZE + icmp_globals.packet_dimension.prefix, icmp_globals.packet_dimension.suffix);
+	if(! packet){
+		return ENOMEM;
+	}
 
 	// prepare the requesting packet
 	// set the destination address
-	if( ERROR_OCCURRED( packet_set_addr( packet, NULL, ( const uint8_t * ) addr, length ))){
-		return icmp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(packet_set_addr(packet, NULL, (const uint8_t *) addr, length))){
+		return icmp_release_and_return(packet, ERROR_CODE);
 	}
 	// allocate space in the packet
-	data = ( uint8_t * ) packet_suffix( packet, size );
-	if( ! data ){
-		return icmp_release_and_return( packet, ENOMEM );
+	data = (uint8_t *) packet_suffix(packet, size);
+	if(! data){
+		return icmp_release_and_return(packet, ENOMEM);
 	}
 	// fill the data
 	length = 0;
-	while( size > length + sizeof( ICMP_ECHO_TEXT )){
-		memcpy( data + length, ICMP_ECHO_TEXT, sizeof( ICMP_ECHO_TEXT ));
-		length += sizeof( ICMP_ECHO_TEXT );
-	}
-	memcpy( data + length, ICMP_ECHO_TEXT, size - length );
+	while(size > length + sizeof(ICMP_ECHO_TEXT)){
+		memcpy(data + length, ICMP_ECHO_TEXT, sizeof(ICMP_ECHO_TEXT));
+		length += sizeof(ICMP_ECHO_TEXT);
+	}
+	memcpy(data + length, ICMP_ECHO_TEXT, size - length);
 	// prefix the header
-	header = PACKET_PREFIX( packet, icmp_header_t );
-	if( ! header ){
-		return icmp_release_and_return( packet, ENOMEM );
-	}
-	bzero( header, sizeof( * header ));
+	header = PACKET_PREFIX(packet, icmp_header_t);
+	if(! header){
+		return icmp_release_and_return(packet, ENOMEM);
+	}
+	bzero(header, sizeof(*header));
 	header->un.echo.identifier = id;
 	header->un.echo.sequence_number = sequence;
 
 	// prepare the reply structure
-	reply = malloc( sizeof( * reply ));
-	if( ! reply ){
-		return icmp_release_and_return( packet, ENOMEM );
-	}
-	fibril_mutex_initialize( & reply->mutex );
-	fibril_mutex_lock( & reply->mutex );
-	fibril_condvar_initialize( & reply->condvar );
-	reply_key = ICMP_GET_REPLY_KEY( header->un.echo.identifier, header->un.echo.sequence_number );
-	index = icmp_replies_add( & icmp_globals.replies, reply_key, reply );
-	if( index < 0 ){
-		free( reply );
-		return icmp_release_and_return( packet, index );
+	reply = malloc(sizeof(*reply));
+	if(! reply){
+		return icmp_release_and_return(packet, ENOMEM);
+	}
+	fibril_mutex_initialize(&reply->mutex);
+	fibril_mutex_lock(&reply->mutex);
+	fibril_condvar_initialize(&reply->condvar);
+	reply_key = ICMP_GET_REPLY_KEY(header->un.echo.identifier, header->un.echo.sequence_number);
+	index = icmp_replies_add(&icmp_globals.replies, reply_key, reply);
+	if(index < 0){
+		free(reply);
+		return icmp_release_and_return(packet, index);
 	}
 
 	// unlock the globals and wait for a reply
-	fibril_rwlock_write_unlock( & icmp_globals.lock );
+	fibril_rwlock_write_unlock(&icmp_globals.lock);
 
 	// send the request
-	icmp_send_packet( ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment );
+	icmp_send_packet(ICMP_ECHO, 0, packet, header, 0, ttl, tos, dont_fragment);
 
 	// wait for a reply
 	// timeout in microseconds
-	if( ERROR_OCCURRED( fibril_condvar_wait_timeout( & reply->condvar, & reply->mutex, timeout * 1000 ))){
+	if(ERROR_OCCURRED(fibril_condvar_wait_timeout(&reply->condvar, &reply->mutex, timeout * 1000))){
 		result = ERROR_CODE;
 
 		// lock the globals again and clean up
-		fibril_rwlock_write_lock( & icmp_globals.lock );
+		fibril_rwlock_write_lock(&icmp_globals.lock);
 	}else{
 		// read the result
@@ -350,110 +352,118 @@
 
 		// release the reply structure
-		fibril_mutex_unlock( & reply->mutex );
+		fibril_mutex_unlock(&reply->mutex);
 	}
 
 	// destroy the reply structure
-	icmp_replies_exclude_index( & icmp_globals.replies, index );
+	icmp_replies_exclude_index(&icmp_globals.replies, index);
 	return result;
 }
 
-int icmp_destination_unreachable_msg( int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet ){
-	icmp_header_ref	header;
-
-	header = icmp_prepare_packet( packet );
-	if( ! header ){
-		return icmp_release_and_return( packet, ENOMEM );
-	}
-	if( mtu ){
+int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet){
+	icmp_header_ref header;
+
+	header = icmp_prepare_packet(packet);
+	if(! header){
+		return icmp_release_and_return(packet, ENOMEM);
+	}
+	if(mtu){
 		header->un.frag.mtu = mtu;
 	}
-	return icmp_send_packet( ICMP_DEST_UNREACH, code, packet, header, SERVICE_ICMP, 0, 0, 0 );
-}
-
-int icmp_source_quench_msg( int icmp_phone, packet_t packet ){
-	icmp_header_ref	header;
-
-	header = icmp_prepare_packet( packet );
-	if( ! header ){
-		return icmp_release_and_return( packet, ENOMEM );
-	}
-	return icmp_send_packet( ICMP_SOURCE_QUENCH, 0, packet, header, SERVICE_ICMP, 0, 0, 0 );
-}
-
-int icmp_time_exceeded_msg( int icmp_phone, icmp_code_t code, packet_t packet ){
-	icmp_header_ref	header;
-
-	header = icmp_prepare_packet( packet );
-	if( ! header ){
-		return icmp_release_and_return( packet, ENOMEM );
-	}
-	return icmp_send_packet( ICMP_TIME_EXCEEDED, code, packet, header, SERVICE_ICMP, 0, 0, 0 );
-}
-
-int icmp_parameter_problem_msg( int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet ){
-	icmp_header_ref	header;
-
-	header = icmp_prepare_packet( packet );
-	if( ! header ){
-		return icmp_release_and_return( packet, ENOMEM );
+	return icmp_send_packet(ICMP_DEST_UNREACH, code, packet, header, SERVICE_ICMP, 0, 0, 0);
+}
+
+int icmp_source_quench_msg(int icmp_phone, packet_t packet){
+	icmp_header_ref header;
+
+	header = icmp_prepare_packet(packet);
+	if(! header){
+		return icmp_release_and_return(packet, ENOMEM);
+	}
+	return icmp_send_packet(ICMP_SOURCE_QUENCH, 0, packet, header, SERVICE_ICMP, 0, 0, 0);
+}
+
+int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet){
+	icmp_header_ref header;
+
+	header = icmp_prepare_packet(packet);
+	if(! header){
+		return icmp_release_and_return(packet, ENOMEM);
+	}
+	return icmp_send_packet(ICMP_TIME_EXCEEDED, code, packet, header, SERVICE_ICMP, 0, 0, 0);
+}
+
+int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet){
+	icmp_header_ref header;
+
+	header = icmp_prepare_packet(packet);
+	if(! header){
+		return icmp_release_and_return(packet, ENOMEM);
 	}
 	header->un.param.pointer = pointer;
-	return icmp_send_packet( ICMP_PARAMETERPROB, code, packet, header, SERVICE_ICMP, 0, 0, 0 );
-}
-
-icmp_header_ref icmp_prepare_packet( packet_t packet ){
-	icmp_header_ref	header;
-	size_t			header_length;
-	size_t			total_length;
-
-	total_length = packet_get_data_length( packet );
-	if( total_length <= 0 ) return NULL;
-	header_length = ip_client_header_length( packet );
-	if( header_length <= 0 ) return NULL;
+	return icmp_send_packet(ICMP_PARAMETERPROB, code, packet, header, SERVICE_ICMP, 0, 0, 0);
+}
+
+icmp_header_ref icmp_prepare_packet(packet_t packet){
+	icmp_header_ref header;
+	size_t header_length;
+	size_t total_length;
+
+	total_length = packet_get_data_length(packet);
+	if(total_length <= 0){
+		return NULL;
+	}
+	header_length = ip_client_header_length(packet);
+	if(header_length <= 0){
+		return NULL;
+	}
 	// truncate if longer than 64 bits (without the IP header)
-	if(( total_length > header_length + ICMP_KEEP_LENGTH )
-	&& ( packet_trim( packet, 0, total_length - header_length - ICMP_KEEP_LENGTH ) != EOK )){
+	if((total_length > header_length + ICMP_KEEP_LENGTH)
+		&& (packet_trim(packet, 0, total_length - header_length - ICMP_KEEP_LENGTH) != EOK)){
 		return NULL;
 	}
-	header = PACKET_PREFIX( packet, icmp_header_t );
-	if( ! header ) return NULL;
-	bzero( header, sizeof( * header ));
+	header = PACKET_PREFIX(packet, icmp_header_t);
+	if(! header){
+		return NULL;
+	}
+	bzero(header, sizeof(*header));
 	return header;
 }
 
-int icmp_send_packet( icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header, services_t error, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment ){
+int icmp_send_packet(icmp_type_t type, icmp_code_t code, packet_t packet, icmp_header_ref header, services_t error, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment){
 	ERROR_DECLARE;
 
 	// do not send an error if disabled
-	if( error && ( ! icmp_globals.error_reporting )){
-		return icmp_release_and_return( packet, EPERM );
+	if(error && (! icmp_globals.error_reporting)){
+		return icmp_release_and_return(packet, EPERM);
 	}
 	header->type = type;
 	header->code = code;
 	header->checksum = 0;
-	header->checksum = ICMP_CHECKSUM( header, packet_get_data_length( packet ));
-	if( ERROR_OCCURRED( ip_client_prepare_packet( packet, IPPROTO_ICMP, ttl, tos, dont_fragment, 0 ))){
-		return icmp_release_and_return( packet, ERROR_CODE );
-	}
-	return ip_send_msg( icmp_globals.ip_phone, -1, packet, SERVICE_ICMP, error );
-}
-
-int icmp_connect_module( services_t service, suseconds_t timeout ){
-	icmp_echo_ref	echo_data;
-	icmp_param_t	id;
-	int				index;
-
-	echo_data = ( icmp_echo_ref ) malloc( sizeof( * echo_data ));
-	if( ! echo_data ) return ENOMEM;
+	header->checksum = ICMP_CHECKSUM(header, packet_get_data_length(packet));
+	if(ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_ICMP, ttl, tos, dont_fragment, 0))){
+		return icmp_release_and_return(packet, ERROR_CODE);
+	}
+	return ip_send_msg(icmp_globals.ip_phone, -1, packet, SERVICE_ICMP, error);
+}
+
+int icmp_connect_module(services_t service, suseconds_t timeout){
+	icmp_echo_ref echo_data;
+	icmp_param_t id;
+	int index;
+
+	echo_data = (icmp_echo_ref) malloc(sizeof(*echo_data));
+	if(! echo_data){
+		return ENOMEM;
+	}
 	// assign a new identifier
-	fibril_rwlock_write_lock( & icmp_globals.lock );
-	index = icmp_bind_free_id( echo_data );
-	if( index < 0 ){
-		free( echo_data );
-		fibril_rwlock_write_unlock( & icmp_globals.lock );
+	fibril_rwlock_write_lock(&icmp_globals.lock);
+	index = icmp_bind_free_id(echo_data);
+	if(index < 0){
+		free(echo_data);
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
 		return index;
 	}else{
 		id = echo_data->identifier;
-		fibril_rwlock_write_unlock( & icmp_globals.lock );
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
 		// return the echo data identifier as the ICMP phone
 		return id;
@@ -461,21 +471,21 @@
 }
 
-int icmp_initialize( async_client_conn_t client_connection ){
+int icmp_initialize(async_client_conn_t client_connection){
 	ERROR_DECLARE;
 
-	measured_string_t	names[] = {{ str_dup("ICMP_ERROR_REPORTING"), 20 }, { str_dup("ICMP_ECHO_REPLYING"), 18 }};
-	measured_string_ref	configuration;
-	size_t				count = sizeof( names ) / sizeof( measured_string_t );
-	char *				data;
-
-	fibril_rwlock_initialize( & icmp_globals.lock );
-	fibril_rwlock_write_lock( & icmp_globals.lock );
-	icmp_replies_initialize( & icmp_globals.replies );
-	icmp_echo_data_initialize( & icmp_globals.echo_data );
-	icmp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP, client_connection, icmp_received_msg );
-	if( icmp_globals.ip_phone < 0 ){
+	measured_string_t names[] = {{str_dup("ICMP_ERROR_REPORTING"), 20}, {str_dup("ICMP_ECHO_REPLYING"), 18}};
+	measured_string_ref configuration;
+	size_t count = sizeof(names) / sizeof(measured_string_t);
+	char * data;
+
+	fibril_rwlock_initialize(&icmp_globals.lock);
+	fibril_rwlock_write_lock(&icmp_globals.lock);
+	icmp_replies_initialize(&icmp_globals.replies);
+	icmp_echo_data_initialize(&icmp_globals.echo_data);
+	icmp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_ICMP, SERVICE_ICMP, client_connection, icmp_received_msg);
+	if(icmp_globals.ip_phone < 0){
 		return icmp_globals.ip_phone;
 	}
-	ERROR_PROPAGATE( ip_packet_size_req( icmp_globals.ip_phone, -1, & icmp_globals.packet_dimension ));
+	ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1, &icmp_globals.packet_dimension));
 	icmp_globals.packet_dimension.prefix += ICMP_HEADER_SIZE;
 	icmp_globals.packet_dimension.content -= ICMP_HEADER_SIZE;
@@ -483,24 +493,24 @@
 	icmp_globals.error_reporting = NET_DEFAULT_ICMP_ERROR_REPORTING;
 	icmp_globals.echo_replying = NET_DEFAULT_ICMP_ECHO_REPLYING;
-	configuration = & names[ 0 ];
-	ERROR_PROPAGATE( net_get_conf_req( icmp_globals.net_phone, & configuration, count, & data ));
-	if( configuration ){
-		if( configuration[ 0 ].value ){
-			icmp_globals.error_reporting = ( configuration[ 0 ].value[ 0 ] == 'y' );
+	configuration = &names[0];
+	ERROR_PROPAGATE(net_get_conf_req(icmp_globals.net_phone, &configuration, count, &data));
+	if(configuration){
+		if(configuration[0].value){
+			icmp_globals.error_reporting = (configuration[0].value[0] == 'y');
 		}
-		if( configuration[ 1 ].value ){
-			icmp_globals.echo_replying = ( configuration[ 1 ].value[ 0 ] == 'y' );
+		if(configuration[1].value){
+			icmp_globals.echo_replying = (configuration[1].value[0] == 'y');
 		}
-		net_free_settings( configuration, data );
-	}
-	fibril_rwlock_write_unlock( & icmp_globals.lock );
+		net_free_settings(configuration, data);
+	}
+	fibril_rwlock_write_unlock(&icmp_globals.lock);
 	return EOK;
 }
 
-int	icmp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ){
+int icmp_received_msg(device_id_t device_id, packet_t packet, services_t receiver, services_t error){
 	ERROR_DECLARE;
 
-	if( ERROR_OCCURRED( icmp_process_packet( packet, error ))){
-		return icmp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(icmp_process_packet(packet, error))){
+		return icmp_release_and_return(packet, ERROR_CODE);
 	}
 
@@ -508,25 +518,27 @@
 }
 
-int icmp_process_packet( packet_t packet, services_t error ){
+int icmp_process_packet(packet_t packet, services_t error){
 	ERROR_DECLARE;
 
-	size_t			length;
-	uint8_t *		src;
-	int				addrlen;
-	int				result;
-	void *			data;
-	icmp_header_ref	header;
-	icmp_type_t		type;
-	icmp_code_t		code;
-
-	if( error ){
-		switch( error ){
+	size_t length;
+	uint8_t * src;
+	int addrlen;
+	int result;
+	void * data;
+	icmp_header_ref header;
+	icmp_type_t type;
+	icmp_code_t code;
+
+	if(error){
+		switch(error){
 			case SERVICE_ICMP:
 				// process error
-				result = icmp_client_process_packet( packet, & type, & code, NULL, NULL );
-				if( result < 0 ) return result;
-				length = ( size_t ) result;
+				result = icmp_client_process_packet(packet, &type, &code, NULL, NULL);
+				if(result < 0){
+					return result;
+				}
+				length = (size_t) result;
 				// remove the error header
-				ERROR_PROPAGATE( packet_trim( packet, length, 0 ));
+				ERROR_PROPAGATE(packet_trim(packet, length, 0));
 				break;
 			default:
@@ -535,21 +547,27 @@
 	}
 	// get rid of the ip header
-	length = ip_client_header_length( packet );
-	ERROR_PROPAGATE( packet_trim( packet, length, 0 ));
-
-	length = packet_get_data_length( packet );
-	if( length <= 0 ) return EINVAL;
-	if( length < ICMP_HEADER_SIZE) return EINVAL;
-	data = packet_get_data( packet );
-	if( ! data ) return EINVAL;
+	length = ip_client_header_length(packet);
+	ERROR_PROPAGATE(packet_trim(packet, length, 0));
+
+	length = packet_get_data_length(packet);
+	if(length <= 0){
+		return EINVAL;
+	}
+	if(length < ICMP_HEADER_SIZE){
+		return EINVAL;
+	}
+	data = packet_get_data(packet);
+	if(! data){
+		return EINVAL;
+	}
 	// get icmp header
-	header = ( icmp_header_ref ) data;
+	header = (icmp_header_ref) data;
 	// checksum
-	if( header->checksum ){
-		while( ICMP_CHECKSUM( header, length ) != IP_CHECKSUM_ZERO ){
+	if(header->checksum){
+		while(ICMP_CHECKSUM(header, length) != IP_CHECKSUM_ZERO){
 			// set the original message type on error notification
 			// type swap observed in Qemu
-			if( error ){
-				switch( header->type ){
+			if(error){
+				switch(header->type){
 					case ICMP_ECHOREPLY:
 						header->type = ICMP_ECHO;
@@ -560,22 +578,22 @@
 		}
 	}
-	switch( header->type ){
+	switch(header->type){
 		case ICMP_ECHOREPLY:
-			if( error ){
-				return icmp_process_echo_reply( packet, header, type, code );
+			if(error){
+				return icmp_process_echo_reply(packet, header, type, code);
 			}else{
-				return icmp_process_echo_reply( packet, header, ICMP_ECHO, 0 );
+				return icmp_process_echo_reply(packet, header, ICMP_ECHO, 0);
 			}
 		case ICMP_ECHO:
-			if( error ){
-				return icmp_process_echo_reply( packet, header, type, code );
+			if(error){
+				return icmp_process_echo_reply(packet, header, type, code);
 			// do not send a reply if disabled
-			}else if( icmp_globals.echo_replying ){
-				addrlen = packet_get_addr( packet, & src, NULL );
-				if(( addrlen > 0 )
+			}else if(icmp_globals.echo_replying){
+				addrlen = packet_get_addr(packet, &src, NULL);
+				if((addrlen > 0)
 				// set both addresses to the source one (avoids the source address deletion before setting the destination one)
-				&& ( packet_set_addr( packet, src, src, ( size_t ) addrlen ) == EOK )){
+					&& (packet_set_addr(packet, src, src, (size_t) addrlen) == EOK)){
 					// send the reply
-					icmp_send_packet( ICMP_ECHOREPLY, 0, packet, header, 0, 0, 0, 0 );
+					icmp_send_packet(ICMP_ECHOREPLY, 0, packet, header, 0, 0, 0, 0);
 					return EOK;
 				}else{
@@ -597,5 +615,5 @@
 		case ICMP_SKIP:
 		case ICMP_PHOTURIS:
-			ip_received_error_msg( icmp_globals.ip_phone, -1, packet, SERVICE_IP, SERVICE_ICMP );
+			ip_received_error_msg(icmp_globals.ip_phone, -1, packet, SERVICE_IP, SERVICE_ICMP);
 			return EOK;
 		default:
@@ -604,59 +622,59 @@
 }
 
-int icmp_process_echo_reply( packet_t packet, icmp_header_ref header, icmp_type_t type, icmp_code_t code ){
-	int				reply_key;
-	icmp_reply_ref	reply;
+int icmp_process_echo_reply(packet_t packet, icmp_header_ref header, icmp_type_t type, icmp_code_t code){
+	int reply_key;
+	icmp_reply_ref reply;
 
 	// compute the reply key
-	reply_key = ICMP_GET_REPLY_KEY( header->un.echo.identifier, header->un.echo.sequence_number );
-	pq_release( icmp_globals.net_phone, packet_get_id( packet ));
+	reply_key = ICMP_GET_REPLY_KEY(header->un.echo.identifier, header->un.echo.sequence_number);
+	pq_release(icmp_globals.net_phone, packet_get_id(packet));
 	// lock the globals
-	fibril_rwlock_write_lock( & icmp_globals.lock );
+	fibril_rwlock_write_lock(&icmp_globals.lock);
 	// find the pending reply
-	reply = icmp_replies_find( & icmp_globals.replies, reply_key );
-	if( reply ){
+	reply = icmp_replies_find(&icmp_globals.replies, reply_key);
+	if(reply){
 		// set the result
 		reply->result = type;
 		// notify the main fibril
-		fibril_condvar_signal( & reply->condvar );
+		fibril_condvar_signal(&reply->condvar);
 	}else{
 		// unlock only if no reply
-		fibril_rwlock_write_unlock( & icmp_globals.lock );
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
 	}
 	return EOK;
 }
 
-int icmp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+int icmp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
 	ERROR_DECLARE;
 
-	packet_t			packet;
-
-	* answer_count = 0;
-	switch( IPC_GET_METHOD( * call )){
+	packet_t packet;
+
+	*answer_count = 0;
+	switch(IPC_GET_METHOD(*call)){
 		case NET_TL_RECEIVED:
-			if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = icmp_received_msg( IPC_GET_DEVICE( call ), packet, SERVICE_ICMP, IPC_GET_ERROR( call ));
+			if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = icmp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_ICMP, IPC_GET_ERROR(call));
 			}
 			return ERROR_CODE;
 		case NET_ICMP_INIT:
-			return icmp_process_client_messages( callid, * call );
+			return icmp_process_client_messages(callid, * call);
 		default:
-			return icmp_process_message( call );
+			return icmp_process_message(call);
 	}
 	return ENOTSUP;
 }
 
-int icmp_process_client_messages( ipc_callid_t callid, ipc_call_t call ){
+int icmp_process_client_messages(ipc_callid_t callid, ipc_call_t call){
 	ERROR_DECLARE;
 
-	bool					keep_on_going = true;
+	bool keep_on_going = true;
 //	fibril_rwlock_t			lock;
-	ipc_call_t				answer;
-	int						answer_count;
-	size_t					length;
-	struct sockaddr *		addr;
-	ipc_callid_t			data_callid;
-	icmp_echo_ref			echo_data;
-	int						res;
+	ipc_call_t answer;
+	int answer_count;
+	size_t length;
+	struct sockaddr * addr;
+	ipc_callid_t data_callid;
+	icmp_echo_ref echo_data;
+	int res;
 
 	/*
@@ -667,31 +685,33 @@
 	answer_count = 0;
 
-//	fibril_rwlock_initialize( & lock );
-
-	echo_data = ( icmp_echo_ref ) malloc( sizeof( * echo_data ));
-	if( ! echo_data ) return ENOMEM;
+//	fibril_rwlock_initialize(&lock);
+
+	echo_data = (icmp_echo_ref) malloc(sizeof(*echo_data));
+	if(! echo_data){
+		return ENOMEM;
+	}
 
 	// assign a new identifier
-	fibril_rwlock_write_lock( & icmp_globals.lock );
-	res = icmp_bind_free_id( echo_data );
-	fibril_rwlock_write_unlock( & icmp_globals.lock );
-	if( res < 0 ){
-		free( echo_data );
+	fibril_rwlock_write_lock(&icmp_globals.lock);
+	res = icmp_bind_free_id(echo_data);
+	fibril_rwlock_write_unlock(&icmp_globals.lock);
+	if(res < 0){
+		free(echo_data);
 		return res;
 	}
 
-	while( keep_on_going ){
+	while(keep_on_going){
 
 		// answer the call
-		answer_call( callid, res, & answer, answer_count );
+		answer_call(callid, res, &answer, answer_count);
 
 		// refresh data
-		refresh_answer( & answer, & answer_count );
+		refresh_answer(&answer, &answer_count);
 
 		// get the next call
-		callid = async_get_call( & call );
+		callid = async_get_call(&call);
 
 		// process the call
-		switch( IPC_GET_METHOD( call )){
+		switch(IPC_GET_METHOD(call)){
 			case IPC_M_PHONE_HUNGUP:
 				keep_on_going = false;
@@ -699,18 +719,18 @@
 				break;
 			case NET_ICMP_ECHO:
-//				fibril_rwlock_write_lock( & lock );
-				if( ! async_data_write_receive( & data_callid, & length )){
+//				fibril_rwlock_write_lock(&lock);
+				if(! async_data_write_receive(&data_callid, &length)){
 					res = EINVAL;
 				}else{
-					addr = malloc( length );
-					if( ! addr ){
+					addr = malloc(length);
+					if(! addr){
 						res = ENOMEM;
 					}else{
-						if( ! ERROR_OCCURRED( async_data_write_finalize( data_callid, addr, length ))){
-							fibril_rwlock_write_lock( & icmp_globals.lock );
-							res = icmp_echo( echo_data->identifier, echo_data->sequence_number, ICMP_GET_SIZE( call ), ICMP_GET_TIMEOUT( call ), ICMP_GET_TTL( call ), ICMP_GET_TOS( call ), ICMP_GET_DONT_FRAGMENT( call ), addr, ( socklen_t ) length );
-							fibril_rwlock_write_unlock( & icmp_globals.lock );
-							free( addr );
-							if( echo_data->sequence_number < MAX_UINT16 ){
+						if(! ERROR_OCCURRED(async_data_write_finalize(data_callid, addr, length))){
+							fibril_rwlock_write_lock(&icmp_globals.lock);
+							res = icmp_echo(echo_data->identifier, echo_data->sequence_number, ICMP_GET_SIZE(call), ICMP_GET_TIMEOUT(call), ICMP_GET_TTL(call), ICMP_GET_TOS(call), ICMP_GET_DONT_FRAGMENT(call), addr, (socklen_t) length);
+							fibril_rwlock_write_unlock(&icmp_globals.lock);
+							free(addr);
+							if(echo_data->sequence_number < MAX_UINT16){
 								++ echo_data->sequence_number;
 							}else{
@@ -722,42 +742,42 @@
 					}
 				}
-//				fibril_rwlock_write_unlock( & lock );
+//				fibril_rwlock_write_unlock(&lock);
 				break;
 			default:
-				res = icmp_process_message( & call );
+				res = icmp_process_message(&call);
 		}
 	}
 
 	// release the identifier
-	fibril_rwlock_write_lock( & icmp_globals.lock );
-	icmp_echo_data_exclude( & icmp_globals.echo_data, echo_data->identifier );
-	fibril_rwlock_write_unlock( & icmp_globals.lock );
+	fibril_rwlock_write_lock(&icmp_globals.lock);
+	icmp_echo_data_exclude(&icmp_globals.echo_data, echo_data->identifier);
+	fibril_rwlock_write_unlock(&icmp_globals.lock);
 	return res;
 }
 
-int icmp_process_message( ipc_call_t * call ){
+int icmp_process_message(ipc_call_t * call){
 	ERROR_DECLARE;
 
-	packet_t	packet;
-
-	switch( IPC_GET_METHOD( * call )){
+	packet_t packet;
+
+	switch(IPC_GET_METHOD(*call)){
 		case NET_ICMP_DEST_UNREACH:
-			if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = icmp_destination_unreachable_msg( 0, ICMP_GET_CODE( call ), ICMP_GET_MTU( call ), packet );
+			if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = icmp_destination_unreachable_msg(0, ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet);
 			}
 			return ERROR_CODE;
 		case NET_ICMP_SOURCE_QUENCH:
-			if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = icmp_source_quench_msg( 0, packet );
+			if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = icmp_source_quench_msg(0, packet);
 			}
 			return ERROR_CODE;
 		case NET_ICMP_TIME_EXCEEDED:
-			if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = icmp_time_exceeded_msg( 0, ICMP_GET_CODE( call ), packet );
+			if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = icmp_time_exceeded_msg(0, ICMP_GET_CODE(call), packet);
 			}
 			return ERROR_CODE;
 		case NET_ICMP_PARAMETERPROB:
-			if( ! ERROR_OCCURRED( packet_translate( icmp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = icmp_parameter_problem_msg( 0, ICMP_GET_CODE( call ), ICMP_GET_POINTER( call ), packet );
+			if(! ERROR_OCCURRED(packet_translate(icmp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = icmp_parameter_problem_msg(0, ICMP_GET_CODE(call), ICMP_GET_POINTER(call), packet);
 			}
 			return ERROR_CODE;
@@ -767,13 +787,15 @@
 }
 
-int	icmp_release_and_return( packet_t packet, int result ){
-	pq_release( icmp_globals.net_phone, packet_get_id( packet ));
+int icmp_release_and_return(packet_t packet, int result){
+	pq_release(icmp_globals.net_phone, packet_get_id(packet));
 	return result;
 }
 
-int icmp_bind_free_id( icmp_echo_ref echo_data ){
-	icmp_param_t	index;
-
-	if( ! echo_data ) return EBADMEM;
+int icmp_bind_free_id(icmp_echo_ref echo_data){
+	icmp_param_t index;
+
+	if(! echo_data){
+		return EBADMEM;
+	}
 	// from the last used one
 	index = icmp_globals.last_used_id;
@@ -781,5 +803,5 @@
 		++ index;
 		// til the range end
-		if( index >= ICMP_FREE_IDS_END ){
+		if(index >= ICMP_FREE_IDS_END){
 			// start from the range beginning
 			index = ICMP_FREE_IDS_START - 1;
@@ -787,16 +809,16 @@
 				++ index;
 				// til the last used one
-				if( index >= icmp_globals.last_used_id ){
+				if(index >= icmp_globals.last_used_id){
 					// none found
 					return ENOTCONN;
 				}
-			}while( icmp_echo_data_find( & icmp_globals.echo_data, index ) != NULL );
+			}while(icmp_echo_data_find(&icmp_globals.echo_data, index) != NULL);
 			// found, break immediately
 			break;
 		}
-	}while( icmp_echo_data_find( & icmp_globals.echo_data, index ) != NULL );
+	}while(icmp_echo_data_find(&icmp_globals.echo_data, index) != NULL);
 	echo_data->identifier = index;
 	echo_data->sequence_number = 0;
-	return icmp_echo_data_add( & icmp_globals.echo_data, index, echo_data );
+	return icmp_echo_data_add(&icmp_globals.echo_data, index, echo_data);
 }
 
Index: uspace/srv/net/tl/icmp/icmp.h
===================================================================
--- uspace/srv/net/tl/icmp/icmp.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -66,5 +66,5 @@
  *  Receiving fibril sets the associated reply with the return value and signals the event.
  */
-INT_MAP_DECLARE( icmp_replies, icmp_reply_t );
+INT_MAP_DECLARE(icmp_replies, icmp_reply_t);
 
 /** Echo specific data map.
@@ -72,5 +72,5 @@
  *  The identifier is used in the future semi-remote calls instead of the ICMP phone.
  */
-INT_MAP_DECLARE( icmp_echo_data, icmp_echo_t );
+INT_MAP_DECLARE(icmp_echo_data, icmp_echo_t);
 
 /** ICMP reply data.
@@ -79,11 +79,11 @@
 	/** Reply result.
 	 */
-	int					result;
+	int result;
 	/** Safety lock.
 	 */
-	fibril_mutex_t		mutex;
+	fibril_mutex_t mutex;
 	/** Received or timeouted reply signaling.
 	 */
-	fibril_condvar_t	condvar;
+	fibril_condvar_t condvar;
 };
 
@@ -93,29 +93,29 @@
 	/** IP module phone.
 	 */
-	int				ip_phone;
+	int ip_phone;
 	/** Packet dimension.
 	 */
-	packet_dimension_t	packet_dimension;
+	packet_dimension_t packet_dimension;
 	/** Networking module phone.
 	 */
-	int				net_phone;
+	int net_phone;
 	/** Indicates whether ICMP error reporting is enabled.
 	 */
-	int				error_reporting;
+	int error_reporting;
 	/** Indicates whether ICMP echo replying (ping) is enabled.
 	 */
-	int				echo_replying;
+	int echo_replying;
 	/** The last used identifier number.
 	 */
-	icmp_param_t	last_used_id;
+	icmp_param_t last_used_id;
 	/** The budled modules assigned echo specific data.
 	 */
-	icmp_echo_data_t	echo_data;
+	icmp_echo_data_t echo_data;
 	/** Echo timeout locks.
 	 */
-	icmp_replies_t	replies;
+	icmp_replies_t replies;
 	/** Safety lock.
 	 */
-	fibril_rwlock_t	lock;
+	fibril_rwlock_t lock;
 };
 
Index: uspace/srv/net/tl/icmp/icmp_api.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_api.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_api.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -52,18 +52,18 @@
 #include "icmp_messages.h"
 
-int icmp_echo_msg( int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen ){
-	aid_t			message_id;
-	ipcarg_t		result;
+int icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen){
+	aid_t message_id;
+	ipcarg_t result;
 
-	if( addrlen <= 0 ){
+	if(addrlen <= 0){
 		return EINVAL;
 	}
-	message_id = async_send_5( icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, tos, ( ipcarg_t ) dont_fragment, NULL );
+	message_id = async_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, tos, (ipcarg_t) dont_fragment, NULL);
 	// send the address
-	async_data_write_start( icmp_phone, addr, ( size_t ) addrlen );
+	async_data_write_start(icmp_phone, addr, (size_t) addrlen);
 	// timeout version may cause inconsistency - there is also an inner timer
-	// return async_wait_timeout( message_id, & result, timeout );
-	async_wait_for( message_id, & result );
-	return ( int ) result;
+	// return async_wait_timeout(message_id, &result, timeout);
+	async_wait_for(message_id, &result);
+	return (int) result;
 }
 
Index: uspace/srv/net/tl/icmp/icmp_client.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_client.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_client.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -49,26 +49,34 @@
 #include "icmp_header.h"
 
-int	icmp_client_process_packet( packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu ){
-	icmp_header_ref	header;
+int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){
+	icmp_header_ref header;
 
-	header = ( icmp_header_ref ) packet_get_data( packet );
-	if(( ! header )
-	|| ( packet_get_data_length( packet ) < sizeof( icmp_header_t ))){
+	header = (icmp_header_ref) packet_get_data(packet);
+	if((! header)
+		|| (packet_get_data_length(packet) < sizeof(icmp_header_t))){
 		return 0;
 	}
-	if( type ) * type = header->type;
-	if( code ) * code = header->code;
-	if( pointer ) * pointer = header->un.param.pointer;
-	if( mtu ) * mtu = header->un.frag.mtu;
+	if(type){
+		*type = header->type;
+	}
+	if(code){
+		*code = header->code;
+	}
+	if(pointer){
+		*pointer = header->un.param.pointer;
+	}
+	if(mtu){
+		*mtu = header->un.frag.mtu;
+	}
 	// remove debug dump
-//	printf( "ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id( packet ));
-	return sizeof( icmp_header_t );
+//	printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet));
+	return sizeof(icmp_header_t);
 }
 
-size_t icmp_client_header_length( packet_t packet ){
-	if( packet_get_data_length( packet ) < sizeof( icmp_header_t )){
+size_t icmp_client_header_length(packet_t packet){
+	if(packet_get_data_length(packet) < sizeof(icmp_header_t)){
 		return 0;
 	}
-	return sizeof( icmp_header_t );
+	return sizeof(icmp_header_t);
 }
 
Index: uspace/srv/net/tl/icmp/icmp_common.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_common.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_common.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -45,10 +45,10 @@
 #include "icmp_messages.h"
 
-int icmp_connect_module( services_t service, suseconds_t timeout ){
-	int	phone;
+int icmp_connect_module(services_t service, suseconds_t timeout){
+	int phone;
 
-	phone = connect_to_service_timeout( SERVICE_ICMP, timeout );
-	if( phone >= 0 ){
-		async_req_0_0( phone, NET_ICMP_INIT );
+	phone = connect_to_service_timeout(SERVICE_ICMP, timeout);
+	if(phone >= 0){
+		async_req_0_0(phone, NET_ICMP_INIT);
 	}
 	return phone;
Index: uspace/srv/net/tl/icmp/icmp_header.h
===================================================================
--- uspace/srv/net/tl/icmp/icmp_header.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_header.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -46,5 +46,5 @@
 /** ICMP header size in bytes.
  */
-#define ICMP_HEADER_SIZE			sizeof( icmp_header_t )
+#define ICMP_HEADER_SIZE			sizeof(icmp_header_t)
 
 /** Type definition of the echo specific data.
@@ -63,8 +63,8 @@
 	/** Message idintifier.
 	 */
-	icmp_param_t	identifier;
+	icmp_param_t identifier;
 	/** Message sequence number.
 	 */
-	icmp_param_t	sequence_number;
+	icmp_param_t sequence_number;
 } __attribute__ ((packed));
 
@@ -84,14 +84,14 @@
 	/** The type of the message.
 	 */
-	uint8_t	type;
+	uint8_t type;
 	/** The error code for the datagram reported by the ICMP message.
 	 *  The interpretation is dependent on the message type.
 	 */
-	uint8_t	code;
+	uint8_t code;
 	/** The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type.
      *  For computing the checksum, the checksum field should be zero.
 	 *  If the checksum does not match the contents, the datagram is discarded.
 	 */
-	uint16_t	checksum;
+	uint16_t checksum;
 	/** Message specific data.
 	 */
@@ -99,8 +99,8 @@
 		/** Echo specific data.
 		 */
-		icmp_echo_t 		echo;
+		icmp_echo_t  echo;
 		/** Proposed gateway value.
 		 */
-		in_addr_t			gateway;
+		in_addr_t gateway;
 		/** Fragmentation needed specific data.
 		 */
@@ -109,8 +109,8 @@
 			 *  Must be zero.
 			 */
-			icmp_param_t	reserved;
+			icmp_param_t reserved;
 			/** Proposed MTU.
 			 */
-			icmp_param_t	mtu;
+			icmp_param_t mtu;
 		} frag;
 		/** Parameter problem specific data.
@@ -119,9 +119,9 @@
 			/** Problem pointer.
 			 */
-			icmp_param_t	pointer;
+			icmp_param_t pointer;
 			/** Reserved field.
 			 *  Must be zero.
 			 */
-			icmp_param_t	reserved;
+			icmp_param_t reserved;
 		} param;
 	} un;
Index: uspace/srv/net/tl/icmp/icmp_messages.h
===================================================================
--- uspace/srv/net/tl/icmp/icmp_messages.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_messages.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -82,40 +82,40 @@
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_CODE( call )		( icmp_code_t ) IPC_GET_ARG1( * call )
+#define ICMP_GET_CODE(call)		(icmp_code_t) IPC_GET_ARG1(*call)
 
 /** Returns the ICMP link MTU message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_MTU( call )		( icmp_param_t ) IPC_GET_ARG3( * call )
+#define ICMP_GET_MTU(call)		(icmp_param_t) IPC_GET_ARG3(*call)
 
 /** Returns the pointer message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_POINTER( call )		( icmp_param_t ) IPC_GET_ARG3( * call )
+#define ICMP_GET_POINTER(call)		(icmp_param_t) IPC_GET_ARG3(*call)
 
 /** Returns the size message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_SIZE( call )	( size_t ) IPC_GET_ARG1( call )
+#define ICMP_GET_SIZE(call)	(size_t) IPC_GET_ARG1(call)
 
 /** Returns the timeout message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_TIMEOUT( call )	(( suseconds_t ) IPC_GET_ARG2( call ))
+#define ICMP_GET_TIMEOUT(call)	((suseconds_t) IPC_GET_ARG2(call))
 
 /** Returns the time to live message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_TTL( call )	( ip_ttl_t ) IPC_GET_ARG3( call )
+#define ICMP_GET_TTL(call)	(ip_ttl_t) IPC_GET_ARG3(call)
 
 /** Returns the type of service message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_TOS( call )	( ip_tos_t ) IPC_GET_ARG4( call )
+#define ICMP_GET_TOS(call)	(ip_tos_t) IPC_GET_ARG4(call)
 
 /** Returns the dont fragment message parameter.
  *  @param[in] call The message call structure.
  */
-#define ICMP_GET_DONT_FRAGMENT( call )		( int ) IPC_GET_ARG5( call )
+#define ICMP_GET_DONT_FRAGMENT(call)		(int) IPC_GET_ARG5(call)
 
 /*@}*/
Index: uspace/srv/net/tl/icmp/icmp_module.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_module.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_module.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -61,5 +61,5 @@
  *  @see NAME
  */
-void	module_print_name( void );
+void module_print_name(void);
 
 /** Starts the ICMP module.
@@ -70,5 +70,5 @@
  *  @returns Other error codes as defined for the REGISTER_ME() macro function.
  */
-int	module_start( async_client_conn_t client_connection );
+int module_start(async_client_conn_t client_connection);
 
 /** Processes the ICMP message.
@@ -80,5 +80,5 @@
  *  @returns Other error codes as defined for the icmp_message() function.
  */
-int	module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
 
 /** ICMP module global data.
@@ -86,21 +86,21 @@
 extern icmp_globals_t	icmp_globals;
 
-void module_print_name( void ){
-	printf( "%s", NAME );
+void module_print_name(void){
+	printf("%s", NAME);
 }
 
-int module_start( async_client_conn_t client_connection ){
+int module_start(async_client_conn_t client_connection){
 	ERROR_DECLARE;
 
-	ipcarg_t	phonehash;
+	ipcarg_t phonehash;
 
-	async_set_client_connection( client_connection );
-	icmp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
-	if( icmp_globals.net_phone < 0 ){
+	async_set_client_connection(client_connection);
+	icmp_globals.net_phone = net_connect_module(SERVICE_NETWORKING);
+	if(icmp_globals.net_phone < 0){
 		return icmp_globals.net_phone;
 	}
-	ERROR_PROPAGATE( pm_init());
-	if( ERROR_OCCURRED( icmp_initialize( client_connection ))
-	|| ERROR_OCCURRED( REGISTER_ME( SERVICE_ICMP, & phonehash ))){
+	ERROR_PROPAGATE(pm_init());
+	if(ERROR_OCCURRED(icmp_initialize(client_connection))
+		|| ERROR_OCCURRED(REGISTER_ME(SERVICE_ICMP, &phonehash))){
 		pm_destroy();
 		return ERROR_CODE;
@@ -113,6 +113,6 @@
 }
 
-int	module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
-	return icmp_message( callid, call, answer, answer_count );
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	return icmp_message(callid, call, answer, answer_count);
 }
 
Index: uspace/srv/net/tl/icmp/icmp_module.h
===================================================================
--- uspace/srv/net/tl/icmp/icmp_module.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_module.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -47,5 +47,5 @@
  *  @returns ENOMEM if there is not enough memory left.
  */
-int	icmp_initialize( async_client_conn_t client_connection );
+int icmp_initialize(async_client_conn_t client_connection);
 
 /** Processes the ICMP message.
@@ -59,5 +59,5 @@
  *  @see IS_NET_ICMP_MESSAGE()
  */
-int	icmp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+int icmp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
 
 #endif
Index: uspace/srv/net/tl/icmp/icmp_remote.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_remote.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/icmp/icmp_remote.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -53,21 +53,21 @@
 #include "icmp_messages.h"
 
-int icmp_destination_unreachable_msg( int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet ){
-	async_msg_3( icmp_phone, NET_ICMP_DEST_UNREACH, ( ipcarg_t ) code, ( ipcarg_t ) packet_get_id( packet ), ( ipcarg_t ) mtu );
+int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet){
+	async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu);
 	return EOK;
 }
 
-int icmp_source_quench_msg( int icmp_phone, packet_t packet ){
-	async_msg_2( icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, ( ipcarg_t ) packet_get_id( packet ));
+int icmp_source_quench_msg(int icmp_phone, packet_t packet){
+	async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, (ipcarg_t) packet_get_id(packet));
 	return EOK;
 }
 
-int icmp_time_exceeded_msg( int icmp_phone, icmp_code_t code, packet_t packet ){
-	async_msg_2( icmp_phone, NET_ICMP_TIME_EXCEEDED, ( ipcarg_t ) code, ( ipcarg_t ) packet_get_id( packet ));
+int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet){
+	async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet));
 	return EOK;
 }
 
-int icmp_parameter_problem_msg( int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet ){
-	async_msg_3( icmp_phone, NET_ICMP_PARAMETERPROB, ( ipcarg_t ) code, ( ipcarg_t ) packet_get_id( packet ), ( ipcarg_t ) pointer );
+int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet){
+	async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer);
 	return EOK;
 }
Index: uspace/srv/net/tl/tcp/tcp.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tcp/tcp.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -123,5 +123,5 @@
  *  @param[in] higher_equal The last value in the interval.
  */
-#define IS_IN_INTERVAL_OVERFLOW( lower, value, higher_equal )	(((( lower ) < ( value )) && ((( value ) <= ( higher_equal )) || (( higher_equal ) < ( lower )))) || ((( value ) <= ( higher_equal )) && (( higher_equal ) < ( lower ))))
+#define IS_IN_INTERVAL_OVERFLOW(lower, value, higher_equal)	((((lower) < (value)) && (((value) <= (higher_equal)) || ((higher_equal) < (lower)))) || (((value) <= (higher_equal)) && ((higher_equal) < (lower))))
 
 /** Type definition of the TCP timeout.
@@ -142,29 +142,29 @@
 	/** TCP global data are going to be read only.
 	 */
-	int					globals_read_only;
+	int globals_read_only;
 	/** Socket port.
 	 */
-	int					port;
+	int port;
 	/** Local sockets.
 	 */
-	socket_cores_ref	local_sockets;
+	socket_cores_ref local_sockets;
 	/** Socket identifier.
 	 */
-	int					socket_id;
+	int socket_id;
 	/** Socket state.
 	 */
-	tcp_socket_state_t	state;
+	tcp_socket_state_t state;
 	/** Sent packet sequence number.
 	 */
-	int					sequence_number;
+	int sequence_number;
 	/** Timeout in microseconds.
 	 */
-	suseconds_t			timeout;
+	suseconds_t timeout;
 	/** Port map key.
 	 */
-	char *				key;
+	char * key;
 	/** Port map key length.
 	 */
-	size_t				key_length;
+	size_t key_length;
 };
 
@@ -174,38 +174,38 @@
  *  @return The result parameter.
  */
-int	tcp_release_and_return( packet_t packet, int result );
-
-void	tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize );
-int	tcp_prepare_timeout( int ( * timeout_function )( void * tcp_timeout_t ), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only );
-void	tcp_free_socket_data( socket_core_ref socket );
-int	tcp_timeout( void * data );
-int	tcp_release_after_timeout( void * data );
-int	tcp_process_packet( device_id_t device_id, packet_t packet, services_t error );
-int	tcp_connect_core( socket_core_ref socket, socket_cores_ref local_sockets, struct sockaddr * addr, socklen_t addrlen );
-int	tcp_queue_prepare_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length );
-int	tcp_queue_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length );
-packet_t	tcp_get_packets_to_send( socket_core_ref socket, tcp_socket_data_ref socket_data );
-void	tcp_send_packets( device_id_t device_id, packet_t packet );
-void	tcp_process_acknowledgement( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header );
-packet_t	tcp_send_prepare_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number );
-packet_t	tcp_prepare_copy( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number );
-void	tcp_retransmit_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number );
-int	tcp_create_notification_packet( packet_t * packet, socket_core_ref socket, tcp_socket_data_ref socket_data, int synchronize, int finalize );
-void	tcp_refresh_socket_data( tcp_socket_data_ref socket_data );
-void	tcp_initialize_socket_data( tcp_socket_data_ref socket_data );
-int	tcp_process_listen( socket_core_ref listening_socket, tcp_socket_data_ref listening_socket_data, tcp_header_ref header, packet_t packet, struct sockaddr * src, struct sockaddr * dest, size_t addrlen );
-int	tcp_process_syn_sent( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet );
-int	tcp_process_syn_received( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet );
-int	tcp_process_established( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet, int fragments, size_t total_length );
-int	tcp_queue_received_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, int fragments, size_t total_length );
-
-int	tcp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error );
-int	tcp_process_client_messages( ipc_callid_t callid, ipc_call_t call );
-int	tcp_listen_message( socket_cores_ref local_sockets, int socket_id, int backlog );
-int	tcp_connect_message( socket_cores_ref local_sockets, int socket_id, struct sockaddr * addr, socklen_t addrlen );
-int	tcp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen );
-int	tcp_send_message( socket_cores_ref local_sockets, int socket_id, int fragments, size_t * data_fragment_size, int flags );
-int	tcp_accept_message( socket_cores_ref local_sockets, int socket_id, int new_socket_id, size_t * data_fragment_size, size_t * addrlen );
-int tcp_close_message( socket_cores_ref local_sockets, int socket_id );
+int tcp_release_and_return(packet_t packet, int result);
+
+void tcp_prepare_operation_header(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize);
+int tcp_prepare_timeout(int (*timeout_function)(void * tcp_timeout_t), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only);
+void tcp_free_socket_data(socket_core_ref socket);
+int tcp_timeout(void * data);
+int tcp_release_after_timeout(void * data);
+int tcp_process_packet(device_id_t device_id, packet_t packet, services_t error);
+int tcp_connect_core(socket_core_ref socket, socket_cores_ref local_sockets, struct sockaddr * addr, socklen_t addrlen);
+int tcp_queue_prepare_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length);
+int tcp_queue_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length);
+packet_t tcp_get_packets_to_send(socket_core_ref socket, tcp_socket_data_ref socket_data);
+void tcp_send_packets(device_id_t device_id, packet_t packet);
+void tcp_process_acknowledgement(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header);
+packet_t tcp_send_prepare_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number);
+packet_t tcp_prepare_copy(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number);
+void tcp_retransmit_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number);
+int tcp_create_notification_packet(packet_t * packet, socket_core_ref socket, tcp_socket_data_ref socket_data, int synchronize, int finalize);
+void tcp_refresh_socket_data(tcp_socket_data_ref socket_data);
+void tcp_initialize_socket_data(tcp_socket_data_ref socket_data);
+int tcp_process_listen(socket_core_ref listening_socket, tcp_socket_data_ref listening_socket_data, tcp_header_ref header, packet_t packet, struct sockaddr * src, struct sockaddr * dest, size_t addrlen);
+int tcp_process_syn_sent(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet);
+int tcp_process_syn_received(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet);
+int tcp_process_established(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet, int fragments, size_t total_length);
+int tcp_queue_received_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, int fragments, size_t total_length);
+
+int tcp_received_msg(device_id_t device_id, packet_t packet, services_t receiver, services_t error);
+int tcp_process_client_messages(ipc_callid_t callid, ipc_call_t call);
+int tcp_listen_message(socket_cores_ref local_sockets, int socket_id, int backlog);
+int tcp_connect_message(socket_cores_ref local_sockets, int socket_id, struct sockaddr * addr, socklen_t addrlen);
+int tcp_recvfrom_message(socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen);
+int tcp_send_message(socket_cores_ref local_sockets, int socket_id, int fragments, size_t * data_fragment_size, int flags);
+int tcp_accept_message(socket_cores_ref local_sockets, int socket_id, int new_socket_id, size_t * data_fragment_size, size_t * addrlen);
+int tcp_close_message(socket_cores_ref local_sockets, int socket_id);
 
 /** TCP global data.
@@ -213,131 +213,133 @@
 tcp_globals_t	tcp_globals;
 
-int tcp_initialize( async_client_conn_t client_connection ){
+int tcp_initialize(async_client_conn_t client_connection){
 	ERROR_DECLARE;
 
-	assert( client_connection );
-	fibril_rwlock_initialize( & tcp_globals.lock );
-	fibril_rwlock_write_lock( & tcp_globals.lock );
-	tcp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP, ICMP_CONNECT_TIMEOUT );
-	tcp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_TCP, SERVICE_TCP, client_connection, tcp_received_msg );
-	if( tcp_globals.ip_phone < 0 ){
+	assert(client_connection);
+	fibril_rwlock_initialize(&tcp_globals.lock);
+	fibril_rwlock_write_lock(&tcp_globals.lock);
+	tcp_globals.icmp_phone = icmp_connect_module(SERVICE_ICMP, ICMP_CONNECT_TIMEOUT);
+	tcp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_TCP, SERVICE_TCP, client_connection, tcp_received_msg);
+	if(tcp_globals.ip_phone < 0){
 		return tcp_globals.ip_phone;
 	}
-	ERROR_PROPAGATE( socket_ports_initialize( & tcp_globals.sockets ));
-	if( ERROR_OCCURRED( packet_dimensions_initialize( & tcp_globals.dimensions ))){
-		socket_ports_destroy( & tcp_globals.sockets );
+	ERROR_PROPAGATE(socket_ports_initialize(&tcp_globals.sockets));
+	if(ERROR_OCCURRED(packet_dimensions_initialize(&tcp_globals.dimensions))){
+		socket_ports_destroy(&tcp_globals.sockets);
 		return ERROR_CODE;
 	}
 	tcp_globals.last_used_port = TCP_FREE_PORTS_START - 1;
-	fibril_rwlock_write_unlock( & tcp_globals.lock );
+	fibril_rwlock_write_unlock(&tcp_globals.lock);
 	return EOK;
 }
 
-int	tcp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ){
+int tcp_received_msg(device_id_t device_id, packet_t packet, services_t receiver, services_t error){
 	ERROR_DECLARE;
 
-	if( receiver != SERVICE_TCP ) return EREFUSED;
-	fibril_rwlock_write_lock( & tcp_globals.lock );
-	if( ERROR_OCCURRED( tcp_process_packet( device_id, packet, error ))){
-		fibril_rwlock_write_unlock( & tcp_globals.lock );
-	}
-	printf( "receive %d \n", ERROR_CODE );
+	if(receiver != SERVICE_TCP){
+		return EREFUSED;
+	}
+	fibril_rwlock_write_lock(&tcp_globals.lock);
+	if(ERROR_OCCURRED(tcp_process_packet(device_id, packet, error))){
+		fibril_rwlock_write_unlock(&tcp_globals.lock);
+	}
+	printf("receive %d \n", ERROR_CODE);
 
 	return ERROR_CODE;
 }
 
-int tcp_process_packet( device_id_t device_id, packet_t packet, services_t error ){
+int tcp_process_packet(device_id_t device_id, packet_t packet, services_t error){
 	ERROR_DECLARE;
 
-	size_t				length;
-	size_t				offset;
-	int					result;
-	tcp_header_ref		header;
-	socket_core_ref 	socket;
-	tcp_socket_data_ref	socket_data;
-	packet_t			next_packet;
-	size_t				total_length;
-	uint32_t			checksum;
-	int					fragments;
-	icmp_type_t			type;
-	icmp_code_t			code;
-	struct sockaddr *	src;
-	struct sockaddr *	dest;
-	size_t				addrlen;
-
-	printf( "p1 \n" );
-	if( error ){
-		switch( error ){
+	size_t length;
+	size_t offset;
+	int result;
+	tcp_header_ref header;
+	socket_core_ref  socket;
+	tcp_socket_data_ref socket_data;
+	packet_t next_packet;
+	size_t total_length;
+	uint32_t checksum;
+	int fragments;
+	icmp_type_t type;
+	icmp_code_t code;
+	struct sockaddr * src;
+	struct sockaddr * dest;
+	size_t addrlen;
+
+	printf("p1 \n");
+	if(error){
+		switch(error){
 			case SERVICE_ICMP:
 				// process error
-				result = icmp_client_process_packet( packet, & type, & code, NULL, NULL );
-				if( result < 0 ){
-					return tcp_release_and_return( packet, result );
-				}
-				length = ( size_t ) result;
-				if( ERROR_OCCURRED( packet_trim( packet, length, 0 ))){
-					return tcp_release_and_return( packet, ERROR_CODE );
+				result = icmp_client_process_packet(packet, &type, &code, NULL, NULL);
+				if(result < 0){
+					return tcp_release_and_return(packet, result);
+				}
+				length = (size_t) result;
+				if(ERROR_OCCURRED(packet_trim(packet, length, 0))){
+					return tcp_release_and_return(packet, ERROR_CODE);
 				}
 				break;
 			default:
-				return tcp_release_and_return( packet, ENOTSUP );
+				return tcp_release_and_return(packet, ENOTSUP);
 		}
 	}
 
 	// TODO process received ipopts?
-	result = ip_client_process_packet( packet, NULL, NULL, NULL, NULL, NULL );
-//	printf("ip len %d\n", result );
-	if( result < 0 ){
-		return tcp_release_and_return( packet, result );
-	}
-	offset = ( size_t ) result;
-
-	length = packet_get_data_length( packet );
-//	printf("packet len %d\n", length );
-	if( length <= 0 ){
-		return tcp_release_and_return( packet, EINVAL );
-	}
-	if( length < TCP_HEADER_SIZE + offset ){
-		return tcp_release_and_return( packet, NO_DATA );
+	result = ip_client_process_packet(packet, NULL, NULL, NULL, NULL, NULL);
+//	printf("ip len %d\n", result);
+	if(result < 0){
+		return tcp_release_and_return(packet, result);
+	}
+	offset = (size_t) result;
+
+	length = packet_get_data_length(packet);
+//	printf("packet len %d\n", length);
+	if(length <= 0){
+		return tcp_release_and_return(packet, EINVAL);
+	}
+	if(length < TCP_HEADER_SIZE + offset){
+		return tcp_release_and_return(packet, NO_DATA);
 	}
 
 	// trim all but TCP header
-	if( ERROR_OCCURRED( packet_trim( packet, offset, 0 ))){
-		return tcp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(packet_trim(packet, offset, 0))){
+		return tcp_release_and_return(packet, ERROR_CODE);
 	}
 
 	// get tcp header
-	header = ( tcp_header_ref ) packet_get_data( packet );
-	if( ! header ){
-		return tcp_release_and_return( packet, NO_DATA );
-	}
-//	printf( "header len %d, port %d \n", TCP_HEADER_LENGTH( header ), ntohs( header->destination_port ));
-
-	result = packet_get_addr( packet, ( uint8_t ** ) & src, ( uint8_t ** ) & dest );
-	if( result <= 0 ){
-		return tcp_release_and_return( packet, result );
-	}
-	addrlen = ( size_t ) result;
-
-	if( ERROR_OCCURRED( tl_set_address_port( src, addrlen, ntohs( header->source_port )))){
-		return tcp_release_and_return( packet, ERROR_CODE );
+	header = (tcp_header_ref) packet_get_data(packet);
+	if(! header){
+		return tcp_release_and_return(packet, NO_DATA);
+	}
+//	printf("header len %d, port %d \n", TCP_HEADER_LENGTH(header), ntohs(header->destination_port));
+
+	result = packet_get_addr(packet, (uint8_t **) &src, (uint8_t **) &dest);
+	if(result <= 0){
+		return tcp_release_and_return(packet, result);
+	}
+	addrlen = (size_t) result;
+
+	if(ERROR_OCCURRED(tl_set_address_port(src, addrlen, ntohs(header->source_port)))){
+		return tcp_release_and_return(packet, ERROR_CODE);
 	}
 
 	// find the destination socket
-	socket = socket_port_find( & tcp_globals.sockets, ntohs( header->destination_port ), ( const char * ) src, addrlen );
-	if( ! socket ){
+	socket = socket_port_find(&tcp_globals.sockets, ntohs(header->destination_port), (const char *) src, addrlen);
+	if(! socket){
 //		printf("listening?\n");
 		// find the listening destination socket
-		socket = socket_port_find( & tcp_globals.sockets, ntohs( header->destination_port ), SOCKET_MAP_KEY_LISTENING, 0 );
-		if( ! socket ){
-			if( tl_prepare_icmp_packet( tcp_globals.net_phone, tcp_globals.icmp_phone, packet, error ) == EOK ){
-				icmp_destination_unreachable_msg( tcp_globals.icmp_phone, ICMP_PORT_UNREACH, 0, packet );
+		socket = socket_port_find(&tcp_globals.sockets, ntohs(header->destination_port), SOCKET_MAP_KEY_LISTENING, 0);
+		if(! socket){
+			if(tl_prepare_icmp_packet(tcp_globals.net_phone, tcp_globals.icmp_phone, packet, error) == EOK){
+				icmp_destination_unreachable_msg(tcp_globals.icmp_phone, ICMP_PORT_UNREACH, 0, packet);
 			}
 			return EADDRNOTAVAIL;
 		}
 	}
-	printf("socket id %d\n", socket->socket_id );
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-	assert( socket_data );
+	printf("socket id %d\n", socket->socket_id);
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
+	assert(socket_data);
 
 	// some data received, clear the timeout counter
@@ -351,41 +353,41 @@
 	do{
 		++ fragments;
-		length = packet_get_data_length( next_packet );
-		if( length <= 0 ){
-			return tcp_release_and_return( packet, NO_DATA );
+		length = packet_get_data_length(next_packet);
+		if(length <= 0){
+			return tcp_release_and_return(packet, NO_DATA);
 		}
 		total_length += length;
 		// add partial checksum if set
-		if( ! error ){
-			checksum = compute_checksum( checksum, packet_get_data( packet ), packet_get_data_length( packet ));
-		}
-	}while(( next_packet = pq_next( next_packet )));
-//	printf( "fragments %d of %d bytes\n", fragments, total_length );
+		if(! error){
+			checksum = compute_checksum(checksum, packet_get_data(packet), packet_get_data_length(packet));
+		}
+	}while((next_packet = pq_next(next_packet)));
+//	printf("fragments %d of %d bytes\n", fragments, total_length);
 
 //	printf("lock?\n");
-	fibril_rwlock_write_lock( socket_data->local_lock );
+	fibril_rwlock_write_lock(socket_data->local_lock);
 //	printf("locked\n");
-	if( ! error ){
-		if( socket_data->state == TCP_SOCKET_LISTEN ){
-			if( socket_data->pseudo_header ){
-				free( socket_data->pseudo_header );
+	if(! error){
+		if(socket_data->state == TCP_SOCKET_LISTEN){
+			if(socket_data->pseudo_header){
+				free(socket_data->pseudo_header);
 				socket_data->pseudo_header = NULL;
 				socket_data->headerlen = 0;
 			}
-			if( ERROR_OCCURRED( ip_client_get_pseudo_header( IPPROTO_TCP, src, addrlen, dest, addrlen, total_length, & socket_data->pseudo_header, & socket_data->headerlen ))){
-				fibril_rwlock_write_unlock( socket_data->local_lock );
-				return tcp_release_and_return( packet, ERROR_CODE );
-			}
-		}else if( ERROR_OCCURRED( ip_client_set_pseudo_header_data_length( socket_data->pseudo_header, socket_data->headerlen, total_length ))){
-			fibril_rwlock_write_unlock( socket_data->local_lock );
-			return tcp_release_and_return( packet, ERROR_CODE );
-		}
-		checksum = compute_checksum( checksum, socket_data->pseudo_header, socket_data->headerlen );
-		if( flip_checksum( compact_checksum( checksum )) != IP_CHECKSUM_ZERO ){
-			printf( "checksum err %x -> %x\n", header->checksum, flip_checksum( compact_checksum( checksum )));
-			fibril_rwlock_write_unlock( socket_data->local_lock );
-			if( ! ERROR_OCCURRED( tl_prepare_icmp_packet( tcp_globals.net_phone, tcp_globals.icmp_phone, packet, error ))){
+			if(ERROR_OCCURRED(ip_client_get_pseudo_header(IPPROTO_TCP, src, addrlen, dest, addrlen, total_length, &socket_data->pseudo_header, &socket_data->headerlen))){
+				fibril_rwlock_write_unlock(socket_data->local_lock);
+				return tcp_release_and_return(packet, ERROR_CODE);
+			}
+		}else if(ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(socket_data->pseudo_header, socket_data->headerlen, total_length))){
+			fibril_rwlock_write_unlock(socket_data->local_lock);
+			return tcp_release_and_return(packet, ERROR_CODE);
+		}
+		checksum = compute_checksum(checksum, socket_data->pseudo_header, socket_data->headerlen);
+		if(flip_checksum(compact_checksum(checksum)) != IP_CHECKSUM_ZERO){
+			printf("checksum err %x -> %x\n", header->checksum, flip_checksum(compact_checksum(checksum)));
+			fibril_rwlock_write_unlock(socket_data->local_lock);
+			if(! ERROR_OCCURRED(tl_prepare_icmp_packet(tcp_globals.net_phone, tcp_globals.icmp_phone, packet, error))){
 				// checksum error ICMP
-				icmp_parameter_problem_msg( tcp_globals.icmp_phone, ICMP_PARAM_POINTER, (( size_t ) (( void * ) & header->checksum )) - (( size_t ) (( void * ) header )), packet );
+				icmp_parameter_problem_msg(tcp_globals.icmp_phone, ICMP_PARAM_POINTER, ((size_t) ((void *) &header->checksum)) - ((size_t) ((void *) header)), packet);
 			}
 			return EINVAL;
@@ -393,17 +395,17 @@
 	}
 
-	fibril_rwlock_read_unlock( & tcp_globals.lock );
+	fibril_rwlock_read_unlock(&tcp_globals.lock);
 
 	// TODO error reporting/handling
-//	printf( "st %d\n", socket_data->state );
-	switch( socket_data->state ){
+//	printf("st %d\n", socket_data->state);
+	switch(socket_data->state){
 		case TCP_SOCKET_LISTEN:
-			ERROR_CODE = tcp_process_listen( socket, socket_data, header, packet, src, dest, addrlen );
+			ERROR_CODE = tcp_process_listen(socket, socket_data, header, packet, src, dest, addrlen);
 			break;
 		case TCP_SOCKET_SYN_RECEIVED:
-			ERROR_CODE = tcp_process_syn_received( socket, socket_data, header, packet );
+			ERROR_CODE = tcp_process_syn_received(socket, socket_data, header, packet);
 			break;
 		case TCP_SOCKET_SYN_SENT:
-			ERROR_CODE = tcp_process_syn_sent( socket, socket_data, header, packet );
+			ERROR_CODE = tcp_process_syn_sent(socket, socket_data, header, packet);
 			break;
 		case TCP_SOCKET_FIN_WAIT_1:
@@ -416,81 +418,81 @@
 			// ack releasing the socket gets processed later
 		case TCP_SOCKET_ESTABLISHED:
-			ERROR_CODE = tcp_process_established( socket, socket_data, header, packet, fragments, total_length );
+			ERROR_CODE = tcp_process_established(socket, socket_data, header, packet, fragments, total_length);
 			break;
 		default:
-			pq_release( tcp_globals.net_phone, packet_get_id( packet ));
-	}
-
-	if( ERROR_CODE != EOK ){
-		printf( "process %d\n", ERROR_CODE );
-		fibril_rwlock_write_unlock( socket_data->local_lock );
+			pq_release(tcp_globals.net_phone, packet_get_id(packet));
+	}
+
+	if(ERROR_CODE != EOK){
+		printf("process %d\n", ERROR_CODE);
+		fibril_rwlock_write_unlock(socket_data->local_lock);
 	}
 	return EOK;
 }
 
-int tcp_process_established( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet, int fragments, size_t total_length ){
+int tcp_process_established(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet, int fragments, size_t total_length){
 	ERROR_DECLARE;
 
-	packet_t	next_packet;
-	packet_t	tmp_packet;
-	uint32_t	old_incoming;
-	size_t		order;
-	uint32_t	sequence_number;
-	size_t		length;
-	size_t		offset;
-	uint32_t	new_sequence_number;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	assert( header );
-	assert( packet );
-
-	new_sequence_number = ntohl( header->sequence_number );
+	packet_t next_packet;
+	packet_t tmp_packet;
+	uint32_t old_incoming;
+	size_t order;
+	uint32_t sequence_number;
+	size_t length;
+	size_t offset;
+	uint32_t new_sequence_number;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	assert(header);
+	assert(packet);
+
+	new_sequence_number = ntohl(header->sequence_number);
 	old_incoming = socket_data->next_incoming;
 
-	if( header->finalize ){
+	if(header->finalize){
 		socket_data->fin_incoming = new_sequence_number;
 	}
 
-//	printf( "pe %d < %d <= %d\n", new_sequence_number, socket_data->next_incoming, new_sequence_number + total_length );
+//	printf("pe %d < %d <= %d\n", new_sequence_number, socket_data->next_incoming, new_sequence_number + total_length);
 	// trim begining if containing expected data
-	if( IS_IN_INTERVAL_OVERFLOW( new_sequence_number, socket_data->next_incoming, new_sequence_number + total_length )){
+	if(IS_IN_INTERVAL_OVERFLOW(new_sequence_number, socket_data->next_incoming, new_sequence_number + total_length)){
 		// get the acknowledged offset
-		if( socket_data->next_incoming < new_sequence_number ){
+		if(socket_data->next_incoming < new_sequence_number){
 			offset = new_sequence_number - socket_data->next_incoming;
 		}else{
 			offset = socket_data->next_incoming - new_sequence_number;
 		}
-//		printf( "offset %d\n", offset );
+//		printf("offset %d\n", offset);
 		new_sequence_number += offset;
 		total_length -= offset;
-		length = packet_get_data_length( packet );
+		length = packet_get_data_length(packet);
 		// trim the acknowledged data
-		while( length <= offset ){
+		while(length <= offset){
 			// release the acknowledged packets
-			next_packet = pq_next( packet );
-			pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+			next_packet = pq_next(packet);
+			pq_release(tcp_globals.net_phone, packet_get_id(packet));
 			packet = next_packet;
 			offset -= length;
-			length = packet_get_data_length( packet );
-		}
-		if(( offset > 0 )
-		&& ( ERROR_OCCURRED( packet_trim( packet, offset, 0 )))){
-			return tcp_release_and_return( packet, ERROR_CODE );
-		}
-		assert( new_sequence_number == socket_data->next_incoming );
+			length = packet_get_data_length(packet);
+		}
+		if((offset > 0)
+			&& (ERROR_OCCURRED(packet_trim(packet, offset, 0)))){
+			return tcp_release_and_return(packet, ERROR_CODE);
+		}
+		assert(new_sequence_number == socket_data->next_incoming);
 	}
 
 	// release if overflowing the window
-//	if( IS_IN_INTERVAL_OVERFLOW( socket_data->next_incoming + socket_data->window, new_sequence_number, new_sequence_number + total_length )){
-//		return tcp_release_and_return( packet, EOVERFLOW );
+//	if(IS_IN_INTERVAL_OVERFLOW(socket_data->next_incoming + socket_data->window, new_sequence_number, new_sequence_number + total_length)){
+//		return tcp_release_and_return(packet, EOVERFLOW);
 //	}
 
 /*
 	// trim end if overflowing the window
-	if( IS_IN_INTERVAL_OVERFLOW( new_sequence_number, socket_data->next_incoming + socket_data->window, new_sequence_number + total_length )){
+	if(IS_IN_INTERVAL_OVERFLOW(new_sequence_number, socket_data->next_incoming + socket_data->window, new_sequence_number + total_length)){
 		// get the allowed data length
-		if( socket_data->next_incoming + socket_data->window < new_sequence_number ){
+		if(socket_data->next_incoming + socket_data->window < new_sequence_number){
 			offset = new_sequence_number - socket_data->next_incoming + socket_data->window;
 		}else{
@@ -499,10 +501,10 @@
 		next_packet = packet;
 		// trim the overflowing data
-		while( next_packet && ( offset > 0 )){
-			length = packet_get_data_length( packet );
-			if( length <= offset ){
-				next_packet = pq_next( next_packet );
-			}else if( ERROR_OCCURRED( packet_trim( next_packet, 0, length - offset ))){
-				return tcp_release_and_return( packet, ERROR_CODE );
+		while(next_packet && (offset > 0)){
+			length = packet_get_data_length(packet);
+			if(length <= offset){
+				next_packet = pq_next(next_packet);
+			}else if(ERROR_OCCURRED(packet_trim(next_packet, 0, length - offset))){
+				return tcp_release_and_return(packet, ERROR_CODE);
 			}
 			offset -= length;
@@ -510,28 +512,28 @@
 		}
 		// release the overflowing packets
-		next_packet = pq_next( next_packet );
-		if( next_packet ){
+		next_packet = pq_next(next_packet);
+		if(next_packet){
 			tmp_packet = next_packet;
-			next_packet = pq_next( next_packet );
-			pq_insert_after( tmp_packet, next_packet );
-			pq_release( tcp_globals.net_phone, packet_get_id( tmp_packet ));
-		}
-		assert( new_sequence_number + total_length == socket_data->next_incoming + socket_data->window );
+			next_packet = pq_next(next_packet);
+			pq_insert_after(tmp_packet, next_packet);
+			pq_release(tcp_globals.net_phone, packet_get_id(tmp_packet));
+		}
+		assert(new_sequence_number + total_length == socket_data->next_incoming + socket_data->window);
 	}
 */
 	// the expected one arrived?
-	if( new_sequence_number == socket_data->next_incoming ){
+	if(new_sequence_number == socket_data->next_incoming){
 		printf("expected\n");
 		// process acknowledgement
-		tcp_process_acknowledgement( socket, socket_data, header );
+		tcp_process_acknowledgement(socket, socket_data, header);
 
 		// remove the header
-		total_length -= TCP_HEADER_LENGTH( header );
-		if( ERROR_OCCURRED( packet_trim( packet, TCP_HEADER_LENGTH( header ), 0 ))){
-			return tcp_release_and_return( packet, ERROR_CODE );
-		}
-
-		if( total_length ){
-			ERROR_PROPAGATE( tcp_queue_received_packet( socket, socket_data, packet, fragments, total_length ));
+		total_length -= TCP_HEADER_LENGTH(header);
+		if(ERROR_OCCURRED(packet_trim(packet, TCP_HEADER_LENGTH(header), 0))){
+			return tcp_release_and_return(packet, ERROR_CODE);
+		}
+
+		if(total_length){
+			ERROR_PROPAGATE(tcp_queue_received_packet(socket, socket_data, packet, fragments, total_length));
 		}else{
 			total_length = 1;
@@ -539,52 +541,52 @@
 		socket_data->next_incoming = old_incoming + total_length;
 		packet = socket_data->incoming;
-		while( packet ){
-			if( ERROR_OCCURRED( pq_get_order( socket_data->incoming, & order, NULL ))){
+		while(packet){
+			if(ERROR_OCCURRED(pq_get_order(socket_data->incoming, &order, NULL))){
 				// remove the corrupted packet
-				next_packet = pq_detach( packet );
-				if( packet == socket_data->incoming ){
+				next_packet = pq_detach(packet);
+				if(packet == socket_data->incoming){
 					socket_data->incoming = next_packet;
 				}
-				pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+				pq_release(tcp_globals.net_phone, packet_get_id(packet));
 				packet = next_packet;
 				continue;
 			}
-			sequence_number = ( uint32_t ) order;
-			if( IS_IN_INTERVAL_OVERFLOW( sequence_number, old_incoming, socket_data->next_incoming )){
+			sequence_number = (uint32_t) order;
+			if(IS_IN_INTERVAL_OVERFLOW(sequence_number, old_incoming, socket_data->next_incoming)){
 				// move to the next
-				packet = pq_next( packet );
+				packet = pq_next(packet);
 			// coninual data?
-			}else if( IS_IN_INTERVAL_OVERFLOW( old_incoming, sequence_number, socket_data->next_incoming )){
+			}else if(IS_IN_INTERVAL_OVERFLOW(old_incoming, sequence_number, socket_data->next_incoming)){
 				// detach the packet
-				next_packet = pq_detach( packet );
-				if( packet == socket_data->incoming ){
+				next_packet = pq_detach(packet);
+				if(packet == socket_data->incoming){
 					socket_data->incoming = next_packet;
 				}
 				// get data length
-				length = packet_get_data_length( packet );
+				length = packet_get_data_length(packet);
 				new_sequence_number = sequence_number + length;
-				if( length <= 0 ){
+				if(length <= 0){
 					// remove the empty packet
-					pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+					pq_release(tcp_globals.net_phone, packet_get_id(packet));
 					packet = next_packet;
 					continue;
 				}
 				// exactly following
-				if( sequence_number == socket_data->next_incoming ){
+				if(sequence_number == socket_data->next_incoming){
 					// queue received data
-					ERROR_PROPAGATE( tcp_queue_received_packet( socket, socket_data, packet, 1, packet_get_data_length( packet )));
+					ERROR_PROPAGATE(tcp_queue_received_packet(socket, socket_data, packet, 1, packet_get_data_length(packet)));
 					socket_data->next_incoming = new_sequence_number;
 					packet = next_packet;
 					continue;
 				// at least partly following data?
-				}else if( IS_IN_INTERVAL_OVERFLOW( sequence_number, socket_data->next_incoming, new_sequence_number )){
-					if( socket_data->next_incoming < new_sequence_number ){
+				}else if(IS_IN_INTERVAL_OVERFLOW(sequence_number, socket_data->next_incoming, new_sequence_number)){
+					if(socket_data->next_incoming < new_sequence_number){
 						length = new_sequence_number - socket_data->next_incoming;
 					}else{
 						length = socket_data->next_incoming - new_sequence_number;
 					}
-					if( ! ERROR_OCCURRED( packet_trim( packet, length, 0 ))){
+					if(! ERROR_OCCURRED(packet_trim(packet, length, 0))){
 						// queue received data
-						ERROR_PROPAGATE( tcp_queue_received_packet( socket, socket_data, packet, 1, packet_get_data_length( packet )));
+						ERROR_PROPAGATE(tcp_queue_received_packet(socket, socket_data, packet, 1, packet_get_data_length(packet)));
 						socket_data->next_incoming = new_sequence_number;
 						packet = next_packet;
@@ -593,5 +595,5 @@
 				}
 				// remove the duplicit or corrupted packet
-				pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+				pq_release(tcp_globals.net_phone, packet_get_id(packet));
 				packet = next_packet;
 				continue;
@@ -600,29 +602,29 @@
 			}
 		}
-	}else if( IS_IN_INTERVAL( socket_data->next_incoming, new_sequence_number, socket_data->next_incoming + socket_data->window )){
+	}else if(IS_IN_INTERVAL(socket_data->next_incoming, new_sequence_number, socket_data->next_incoming + socket_data->window)){
 		printf("in window\n");
 		// process acknowledgement
-		tcp_process_acknowledgement( socket, socket_data, header );
+		tcp_process_acknowledgement(socket, socket_data, header);
 
 		// remove the header
-		total_length -= TCP_HEADER_LENGTH( header );
-		if( ERROR_OCCURRED( packet_trim( packet, TCP_HEADER_LENGTH( header ), 0 ))){
-			return tcp_release_and_return( packet, ERROR_CODE );
-		}
-
-		next_packet = pq_detach( packet );
-		length = packet_get_data_length( packet );
-		if( ERROR_OCCURRED( pq_add( & socket_data->incoming, packet, new_sequence_number, length ))){
+		total_length -= TCP_HEADER_LENGTH(header);
+		if(ERROR_OCCURRED(packet_trim(packet, TCP_HEADER_LENGTH(header), 0))){
+			return tcp_release_and_return(packet, ERROR_CODE);
+		}
+
+		next_packet = pq_detach(packet);
+		length = packet_get_data_length(packet);
+		if(ERROR_OCCURRED(pq_add(&socket_data->incoming, packet, new_sequence_number, length))){
 			// remove the corrupted packets
-			pq_release( tcp_globals.net_phone, packet_get_id( packet ));
-			pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
+			pq_release(tcp_globals.net_phone, packet_get_id(packet));
+			pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
 		}else{
-			while( next_packet ){
+			while(next_packet){
 				new_sequence_number += length;
-				tmp_packet = pq_detach( next_packet );
-				length = packet_get_data_length( next_packet );
-				if( ERROR_OCCURRED( pq_set_order( next_packet, new_sequence_number, length ))
-				|| ERROR_OCCURRED( pq_insert_after( packet, next_packet ))){
-					pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
+				tmp_packet = pq_detach(next_packet);
+				length = packet_get_data_length(next_packet);
+				if(ERROR_OCCURRED(pq_set_order(next_packet, new_sequence_number, length))
+					|| ERROR_OCCURRED(pq_insert_after(packet, next_packet))){
+					pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
 				}
 				next_packet = tmp_packet;
@@ -632,10 +634,10 @@
 		printf("unexpected\n");
 		// release duplicite or restricted
-		pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+		pq_release(tcp_globals.net_phone, packet_get_id(packet));
 	}
 
 	// change state according to the acknowledging incoming fin
-	if( IS_IN_INTERVAL_OVERFLOW( old_incoming, socket_data->fin_incoming, socket_data->next_incoming )){
-		switch( socket_data->state ){
+	if(IS_IN_INTERVAL_OVERFLOW(old_incoming, socket_data->fin_incoming, socket_data->next_incoming)){
+		switch(socket_data->state){
 			case TCP_SOCKET_FIN_WAIT_1:
 			case TCP_SOCKET_FIN_WAIT_2:
@@ -650,33 +652,33 @@
 	}
 
-	packet = tcp_get_packets_to_send( socket, socket_data );
-	if( ! packet ){
+	packet = tcp_get_packets_to_send(socket, socket_data);
+	if(! packet){
 		// create the notification packet
-		ERROR_PROPAGATE( tcp_create_notification_packet( & packet, socket, socket_data, 0, 0 ));
-		ERROR_PROPAGATE( tcp_queue_prepare_packet( socket, socket_data, packet, 1 ));
-		packet = tcp_send_prepare_packet( socket, socket_data, packet, 1, socket_data->last_outgoing + 1 );
-	}
-	fibril_rwlock_write_unlock( socket_data->local_lock );
+		ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket, socket_data, 0, 0));
+		ERROR_PROPAGATE(tcp_queue_prepare_packet(socket, socket_data, packet, 1));
+		packet = tcp_send_prepare_packet(socket, socket_data, packet, 1, socket_data->last_outgoing + 1);
+	}
+	fibril_rwlock_write_unlock(socket_data->local_lock);
 	// send the packet
-	tcp_send_packets( socket_data->device_id, packet );
+	tcp_send_packets(socket_data->device_id, packet);
 	return EOK;
 }
 
-int tcp_queue_received_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, int fragments, size_t total_length ){
+int tcp_queue_received_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, int fragments, size_t total_length){
 	ERROR_DECLARE;
 
-	packet_dimension_ref	packet_dimension;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	assert( packet );
-	assert( fragments >= 1 );
-	assert( socket_data->window > total_length );
+	packet_dimension_ref packet_dimension;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	assert(packet);
+	assert(fragments >= 1);
+	assert(socket_data->window > total_length);
 
 	// queue the received packet
-	if( ERROR_OCCURRED( dyn_fifo_push( & socket->received, packet_get_id( packet ), SOCKET_MAX_RECEIVED_SIZE ))
-	|| ERROR_OCCURRED( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension ))){
-		return tcp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(dyn_fifo_push(&socket->received, packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE))
+		|| ERROR_OCCURRED(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension))){
+		return tcp_release_and_return(packet, ERROR_CODE);
 	}
 
@@ -685,108 +687,108 @@
 
 	// notify the destination socket
-	async_msg_5( socket->phone, NET_SOCKET_RECEIVED, ( ipcarg_t ) socket->socket_id, (( packet_dimension->content < socket_data->data_fragment_size ) ? packet_dimension->content : socket_data->data_fragment_size ), 0, 0, ( ipcarg_t ) fragments );
+	async_msg_5(socket->phone, NET_SOCKET_RECEIVED, (ipcarg_t) socket->socket_id, ((packet_dimension->content < socket_data->data_fragment_size) ? packet_dimension->content : socket_data->data_fragment_size), 0, 0, (ipcarg_t) fragments);
 	return EOK;
 }
 
-int tcp_process_syn_sent( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet ){
+int tcp_process_syn_sent(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet){
 	ERROR_DECLARE;
 
-	packet_t	next_packet;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	assert( header );
-	assert( packet );
-
-	if( header->synchronize ){
+	packet_t next_packet;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	assert(header);
+	assert(packet);
+
+	if(header->synchronize){
 		// process acknowledgement
-		tcp_process_acknowledgement( socket, socket_data, header );
-
-		socket_data->next_incoming = ntohl( header->sequence_number ) + 1;
+		tcp_process_acknowledgement(socket, socket_data, header);
+
+		socket_data->next_incoming = ntohl(header->sequence_number) + 1;
 		// release additional packets
-		next_packet = pq_detach( packet );
-		if( next_packet ){
-			pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
+		next_packet = pq_detach(packet);
+		if(next_packet){
+			pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
 		}
 		// trim if longer than the header
-		if(( packet_get_data_length( packet ) > sizeof( * header ))
-		&& ERROR_OCCURRED( packet_trim( packet, 0, packet_get_data_length( packet ) - sizeof( * header )))){
-			return tcp_release_and_return( packet, ERROR_CODE );
-		}
-		tcp_prepare_operation_header( socket, socket_data, header, 0, 0 );
-		fibril_mutex_lock( & socket_data->operation.mutex );
-		socket_data->operation.result = tcp_queue_packet( socket, socket_data, packet, 1 );
-		if( socket_data->operation.result == EOK ){
+		if((packet_get_data_length(packet) > sizeof(*header))
+			&& ERROR_OCCURRED(packet_trim(packet, 0, packet_get_data_length(packet) - sizeof(*header)))){
+			return tcp_release_and_return(packet, ERROR_CODE);
+		}
+		tcp_prepare_operation_header(socket, socket_data, header, 0, 0);
+		fibril_mutex_lock(&socket_data->operation.mutex);
+		socket_data->operation.result = tcp_queue_packet(socket, socket_data, packet, 1);
+		if(socket_data->operation.result == EOK){
 			socket_data->state = TCP_SOCKET_ESTABLISHED;
-			packet = tcp_get_packets_to_send( socket, socket_data );
-			if( packet ){
-				fibril_rwlock_write_unlock( socket_data->local_lock );
+			packet = tcp_get_packets_to_send(socket, socket_data);
+			if(packet){
+				fibril_rwlock_write_unlock(socket_data->local_lock);
 				// send the packet
-				tcp_send_packets( socket_data->device_id, packet );
+				tcp_send_packets(socket_data->device_id, packet);
 				// signal the result
-				fibril_condvar_signal( & socket_data->operation.condvar );
-				fibril_mutex_unlock( & socket_data->operation.mutex );
+				fibril_condvar_signal(&socket_data->operation.condvar);
+				fibril_mutex_unlock(&socket_data->operation.mutex);
 				return EOK;
 			}
 		}
-		fibril_mutex_unlock( & socket_data->operation.mutex );
-	}
-	return tcp_release_and_return( packet, EINVAL );
-}
-
-int tcp_process_listen( socket_core_ref listening_socket, tcp_socket_data_ref listening_socket_data, tcp_header_ref header, packet_t packet, struct sockaddr * src, struct sockaddr * dest, size_t addrlen ){
+		fibril_mutex_unlock(&socket_data->operation.mutex);
+	}
+	return tcp_release_and_return(packet, EINVAL);
+}
+
+int tcp_process_listen(socket_core_ref listening_socket, tcp_socket_data_ref listening_socket_data, tcp_header_ref header, packet_t packet, struct sockaddr * src, struct sockaddr * dest, size_t addrlen){
 	ERROR_DECLARE;
 
-	packet_t			next_packet;
-	socket_core_ref		socket;
-	tcp_socket_data_ref	socket_data;
-	int					socket_id;
-	int					listening_socket_id = listening_socket->socket_id;
-	int					listening_port = listening_socket->port;
-
-	assert( listening_socket );
-	assert( listening_socket_data );
-	assert( listening_socket->specific_data == listening_socket_data );
-	assert( header );
-	assert( packet );
-
-//	printf( "syn %d\n", header->synchronize );
-	if( header->synchronize ){
-		socket_data = ( tcp_socket_data_ref ) malloc( sizeof( * socket_data ));
-		if( ! socket_data ){
-			return tcp_release_and_return( packet, ENOMEM );
+	packet_t next_packet;
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+	int socket_id;
+	int listening_socket_id = listening_socket->socket_id;
+	int listening_port = listening_socket->port;
+
+	assert(listening_socket);
+	assert(listening_socket_data);
+	assert(listening_socket->specific_data == listening_socket_data);
+	assert(header);
+	assert(packet);
+
+//	printf("syn %d\n", header->synchronize);
+	if(header->synchronize){
+		socket_data = (tcp_socket_data_ref) malloc(sizeof(*socket_data));
+		if(! socket_data){
+			return tcp_release_and_return(packet, ENOMEM);
 		}else{
-			tcp_initialize_socket_data( socket_data );
+			tcp_initialize_socket_data(socket_data);
 			socket_data->local_lock = listening_socket_data->local_lock;
 			socket_data->local_sockets = listening_socket_data->local_sockets;
 			socket_data->listening_socket_id = listening_socket->socket_id;
 
-			socket_data->next_incoming = ntohl( header->sequence_number );
-			socket_data->treshold = socket_data->next_incoming + ntohs( header->window );
+			socket_data->next_incoming = ntohl(header->sequence_number);
+			socket_data->treshold = socket_data->next_incoming + ntohs(header->window);
 
 			socket_data->addrlen = addrlen;
-			socket_data->addr = malloc( socket_data->addrlen );
-			if( ! socket_data->addr ){
-				free( socket_data );
-				return tcp_release_and_return( packet, ENOMEM );
-			}
-			memcpy( socket_data->addr, src, socket_data->addrlen );
-
-			socket_data->dest_port = ntohs( header->source_port );
-			if( ERROR_OCCURRED( tl_set_address_port( socket_data->addr, socket_data->addrlen, socket_data->dest_port ))){
-				free( socket_data->addr );
-				free( socket_data );
-				pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+			socket_data->addr = malloc(socket_data->addrlen);
+			if(! socket_data->addr){
+				free(socket_data);
+				return tcp_release_and_return(packet, ENOMEM);
+			}
+			memcpy(socket_data->addr, src, socket_data->addrlen);
+
+			socket_data->dest_port = ntohs(header->source_port);
+			if(ERROR_OCCURRED(tl_set_address_port(socket_data->addr, socket_data->addrlen, socket_data->dest_port))){
+				free(socket_data->addr);
+				free(socket_data);
+				pq_release(tcp_globals.net_phone, packet_get_id(packet));
 				return ERROR_CODE;
 			}
 
-//			printf( "addr %p\n", socket_data->addr, socket_data->addrlen );
+//			printf("addr %p\n", socket_data->addr, socket_data->addrlen);
 			// create a socket
 			socket_id = -1;
-			if( ERROR_OCCURRED( socket_create( socket_data->local_sockets, listening_socket->phone, socket_data, & socket_id ))){
-				free( socket_data->addr );
-				free( socket_data );
-				return tcp_release_and_return( packet, ERROR_CODE );
+			if(ERROR_OCCURRED(socket_create(socket_data->local_sockets, listening_socket->phone, socket_data, &socket_id))){
+				free(socket_data->addr);
+				free(socket_data);
+				return tcp_release_and_return(packet, ERROR_CODE);
 			}
 
@@ -797,112 +799,112 @@
 			listening_socket_data->headerlen = 0;
 
-			fibril_rwlock_write_unlock( socket_data->local_lock );
+			fibril_rwlock_write_unlock(socket_data->local_lock);
 //			printf("list lg\n");
-			fibril_rwlock_write_lock( & tcp_globals.lock );
+			fibril_rwlock_write_lock(&tcp_globals.lock);
 //			printf("list locked\n");
 			// find the destination socket
-			listening_socket = socket_port_find( & tcp_globals.sockets, listening_port, SOCKET_MAP_KEY_LISTENING, 0 );
-			if(( ! listening_socket ) || ( listening_socket->socket_id != listening_socket_id )){
-				fibril_rwlock_write_unlock( & tcp_globals.lock );
+			listening_socket = socket_port_find(&tcp_globals.sockets, listening_port, SOCKET_MAP_KEY_LISTENING, 0);
+			if((! listening_socket) || (listening_socket->socket_id != listening_socket_id)){
+				fibril_rwlock_write_unlock(&tcp_globals.lock);
 				// a shadow may remain until app hangs up
-				return tcp_release_and_return( packet, EOK/*ENOTSOCK*/ );
-			}
-//			printf("port %d\n", listening_socket->port );
-			listening_socket_data = ( tcp_socket_data_ref ) listening_socket->specific_data;
-			assert( listening_socket_data );
+				return tcp_release_and_return(packet, EOK/*ENOTSOCK*/);
+			}
+//			printf("port %d\n", listening_socket->port);
+			listening_socket_data = (tcp_socket_data_ref) listening_socket->specific_data;
+			assert(listening_socket_data);
 
 //			printf("list ll\n");
-			fibril_rwlock_write_lock( listening_socket_data->local_lock );
+			fibril_rwlock_write_lock(listening_socket_data->local_lock);
 //			printf("list locked\n");
 
-			socket = socket_cores_find( listening_socket_data->local_sockets, socket_id );
-			if( ! socket ){
+			socket = socket_cores_find(listening_socket_data->local_sockets, socket_id);
+			if(! socket){
 				// where is the socket?!?
-				fibril_rwlock_write_unlock( & tcp_globals.lock );
+				fibril_rwlock_write_unlock(&tcp_globals.lock);
 				return ENOTSOCK;
 			}
-			socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-			assert( socket_data );
+			socket_data = (tcp_socket_data_ref) socket->specific_data;
+			assert(socket_data);
 
 //			uint8_t * data = socket_data->addr;
-//			printf( "addr %d of %x %x %x %x-%x %x %x %x-%x %x %x %x-%x %x %x %x\n", socket_data->addrlen, data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ], data[ 10 ], data[ 11 ], data[ 12 ], data[ 13 ], data[ 14 ], data[ 15 ] );
-
-			ERROR_CODE = socket_port_add( & tcp_globals.sockets, listening_port, socket, ( const char * ) socket_data->addr, socket_data->addrlen );
-			assert( socket == socket_port_find( & tcp_globals.sockets, listening_port, ( const char * ) socket_data->addr, socket_data->addrlen ));
-			//ERROR_CODE = socket_bind_free_port( & tcp_globals.sockets, socket, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, tcp_globals.last_used_port );
+//			printf("addr %d of %x %x %x %x-%x %x %x %x-%x %x %x %x-%x %x %x %x\n", socket_data->addrlen, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]);
+
+			ERROR_CODE = socket_port_add(&tcp_globals.sockets, listening_port, socket, (const char *) socket_data->addr, socket_data->addrlen);
+			assert(socket == socket_port_find(&tcp_globals.sockets, listening_port, (const char *) socket_data->addr, socket_data->addrlen));
+			//ERROR_CODE = socket_bind_free_port(&tcp_globals.sockets, socket, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, tcp_globals.last_used_port);
 			//tcp_globals.last_used_port = socket->port;
-//			printf("bound %d\n", socket->port );
-			fibril_rwlock_write_unlock( & tcp_globals.lock );
-			if( ERROR_CODE != EOK ){
-				socket_destroy( tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, & tcp_globals.sockets, tcp_free_socket_data );
-				return tcp_release_and_return( packet, ERROR_CODE );
+//			printf("bound %d\n", socket->port);
+			fibril_rwlock_write_unlock(&tcp_globals.lock);
+			if(ERROR_CODE != EOK){
+				socket_destroy(tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, &tcp_globals.sockets, tcp_free_socket_data);
+				return tcp_release_and_return(packet, ERROR_CODE);
 			}
 
 			socket_data->state = TCP_SOCKET_LISTEN;
-			socket_data->next_incoming = ntohl( header->sequence_number ) + 1;
+			socket_data->next_incoming = ntohl(header->sequence_number) + 1;
 			// release additional packets
-			next_packet = pq_detach( packet );
-			if( next_packet ){
-				pq_release( tcp_globals.net_phone, packet_get_id( next_packet ));
+			next_packet = pq_detach(packet);
+			if(next_packet){
+				pq_release(tcp_globals.net_phone, packet_get_id(next_packet));
 			}
 			// trim if longer than the header
-			if(( packet_get_data_length( packet ) > sizeof( * header ))
-			&& ERROR_OCCURRED( packet_trim( packet, 0, packet_get_data_length( packet ) - sizeof( * header )))){
-				socket_destroy( tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, & tcp_globals.sockets, tcp_free_socket_data );
-				return tcp_release_and_return( packet, ERROR_CODE );
-			}
-			tcp_prepare_operation_header( socket, socket_data, header, 1, 0 );
-			if( ERROR_OCCURRED( tcp_queue_packet( socket, socket_data, packet, 1 ))){
-				socket_destroy( tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, & tcp_globals.sockets, tcp_free_socket_data );
+			if((packet_get_data_length(packet) > sizeof(*header))
+				&& ERROR_OCCURRED(packet_trim(packet, 0, packet_get_data_length(packet) - sizeof(*header)))){
+				socket_destroy(tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, &tcp_globals.sockets, tcp_free_socket_data);
+				return tcp_release_and_return(packet, ERROR_CODE);
+			}
+			tcp_prepare_operation_header(socket, socket_data, header, 1, 0);
+			if(ERROR_OCCURRED(tcp_queue_packet(socket, socket_data, packet, 1))){
+				socket_destroy(tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, &tcp_globals.sockets, tcp_free_socket_data);
 				return ERROR_CODE;
 			}
-			packet = tcp_get_packets_to_send( socket, socket_data );
-//			printf("send %d\n", packet_get_id( packet ));
-			if( ! packet ){
-				socket_destroy( tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, & tcp_globals.sockets, tcp_free_socket_data );
+			packet = tcp_get_packets_to_send(socket, socket_data);
+//			printf("send %d\n", packet_get_id(packet));
+			if(! packet){
+				socket_destroy(tcp_globals.net_phone, socket->socket_id, socket_data->local_sockets, &tcp_globals.sockets, tcp_free_socket_data);
 				return EINVAL;
 			}else{
 				socket_data->state = TCP_SOCKET_SYN_RECEIVED;
 //				printf("unlock\n");
-				fibril_rwlock_write_unlock( socket_data->local_lock );
+				fibril_rwlock_write_unlock(socket_data->local_lock);
 				// send the packet
-				tcp_send_packets( socket_data->device_id, packet );
+				tcp_send_packets(socket_data->device_id, packet);
 				return EOK;
 			}
 		}
 	}
-	return tcp_release_and_return( packet, EINVAL );
-}
-
-int	tcp_process_syn_received( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet ){
+	return tcp_release_and_return(packet, EINVAL);
+}
+
+int tcp_process_syn_received(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, packet_t packet){
 	ERROR_DECLARE;
 
-	socket_core_ref		listening_socket;
-	tcp_socket_data_ref	listening_socket_data;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	assert( header );
-	assert( packet );
+	socket_core_ref listening_socket;
+	tcp_socket_data_ref listening_socket_data;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	assert(header);
+	assert(packet);
 
 	printf("syn_rec\n");
-	if( header->acknowledge ){
+	if(header->acknowledge){
 		// process acknowledgement
-		tcp_process_acknowledgement( socket, socket_data, header );
-
-		socket_data->next_incoming = ntohl( header->sequence_number );// + 1;
-		pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+		tcp_process_acknowledgement(socket, socket_data, header);
+
+		socket_data->next_incoming = ntohl(header->sequence_number);// + 1;
+		pq_release(tcp_globals.net_phone, packet_get_id(packet));
 		socket_data->state = TCP_SOCKET_ESTABLISHED;
-		listening_socket = socket_cores_find( socket_data->local_sockets, socket_data->listening_socket_id );
-		if( listening_socket ){
-			listening_socket_data = ( tcp_socket_data_ref ) listening_socket->specific_data;
-			assert( listening_socket_data );
+		listening_socket = socket_cores_find(socket_data->local_sockets, socket_data->listening_socket_id);
+		if(listening_socket){
+			listening_socket_data = (tcp_socket_data_ref) listening_socket->specific_data;
+			assert(listening_socket_data);
 
 			// queue the received packet
-			if( ! ERROR_OCCURRED( dyn_fifo_push( & listening_socket->accepted, ( -1 * socket->socket_id ), listening_socket_data->backlog ))){
+			if(! ERROR_OCCURRED(dyn_fifo_push(&listening_socket->accepted, (-1 * socket->socket_id), listening_socket_data->backlog))){
 				// notify the destination socket
-				async_msg_5( socket->phone, NET_SOCKET_ACCEPTED, ( ipcarg_t ) listening_socket->socket_id, socket_data->data_fragment_size, TCP_HEADER_SIZE, 0, ( ipcarg_t ) socket->socket_id );
-				fibril_rwlock_write_unlock( socket_data->local_lock );
+				async_msg_5(socket->phone, NET_SOCKET_ACCEPTED, (ipcarg_t) listening_socket->socket_id, socket_data->data_fragment_size, TCP_HEADER_SIZE, 0, (ipcarg_t) socket->socket_id);
+				fibril_rwlock_write_unlock(socket_data->local_lock);
 				return EOK;
 			}
@@ -912,43 +914,43 @@
 
 		// create the notification packet
-		ERROR_PROPAGATE( tcp_create_notification_packet( & packet, socket, socket_data, 0, 1 ));
+		ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket, socket_data, 0, 1));
 
 		// send the packet
-		ERROR_PROPAGATE( tcp_queue_packet( socket, socket_data, packet, 1 ));
+		ERROR_PROPAGATE(tcp_queue_packet(socket, socket_data, packet, 1));
 
 		// flush packets
-		packet = tcp_get_packets_to_send( socket, socket_data );
-		fibril_rwlock_write_unlock( socket_data->local_lock );
-		if( packet ){
+		packet = tcp_get_packets_to_send(socket, socket_data);
+		fibril_rwlock_write_unlock(socket_data->local_lock);
+		if(packet){
 			// send the packet
-			tcp_send_packets( socket_data->device_id, packet );
+			tcp_send_packets(socket_data->device_id, packet);
 		}
 		return EOK;
 	}else{
-		return tcp_release_and_return( packet, EINVAL );
+		return tcp_release_and_return(packet, EINVAL);
 	}
 	return EINVAL;
 }
 
-void tcp_process_acknowledgement( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header ){
-	size_t		number;
-	size_t		length;
-	packet_t	packet;
-	packet_t	next;
-	packet_t	acknowledged = NULL;
-	uint32_t	old;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	assert( header );
-
-	if( header->acknowledge ){
-		number = ntohl( header->acknowledgement_number );
+void tcp_process_acknowledgement(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header){
+	size_t number;
+	size_t length;
+	packet_t packet;
+	packet_t next;
+	packet_t acknowledged = NULL;
+	uint32_t old;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	assert(header);
+
+	if(header->acknowledge){
+		number = ntohl(header->acknowledgement_number);
 		// if more data acknowledged
-		if( number != socket_data->expected ){
+		if(number != socket_data->expected){
 			old = socket_data->expected;
-			if( IS_IN_INTERVAL_OVERFLOW( old, socket_data->fin_outgoing, number )){
-				switch( socket_data->state ){
+			if(IS_IN_INTERVAL_OVERFLOW(old, socket_data->fin_outgoing, number)){
+				switch(socket_data->state){
 					case TCP_SOCKET_FIN_WAIT_1:
 						socket_data->state = TCP_SOCKET_FIN_WAIT_2;
@@ -957,5 +959,5 @@
 					case TCP_SOCKET_CLOSING:
 						// fin acknowledged - release the socket in another fibril
-						tcp_prepare_timeout( tcp_release_after_timeout, socket, socket_data, 0, TCP_SOCKET_TIME_WAIT, NET_DEFAULT_TCP_TIME_WAIT_TIMEOUT, true );
+						tcp_prepare_timeout(tcp_release_after_timeout, socket, socket_data, 0, TCP_SOCKET_TIME_WAIT, NET_DEFAULT_TCP_TIME_WAIT_TIMEOUT, true);
 						break;
 					default:
@@ -964,6 +966,6 @@
 			}
 			// update the treshold if higher than set
-			if( number + ntohs( header->window ) > socket_data->expected + socket_data->treshold ){
-				socket_data->treshold = number + ntohs( header->window ) - socket_data->expected;
+			if(number + ntohs(header->window) > socket_data->expected + socket_data->treshold){
+				socket_data->treshold = number + ntohs(header->window) - socket_data->expected;
 			}
 			// set new expected sequence number
@@ -971,65 +973,65 @@
 			socket_data->expected_count = 1;
 			packet = socket_data->outgoing;
-			while( pq_get_order( packet, & number, & length ) == EOK ){
-				if( IS_IN_INTERVAL_OVERFLOW(( uint32_t ) old, ( uint32_t )( number + length ), ( uint32_t ) socket_data->expected )){
-					next = pq_detach( packet );
-					if( packet == socket_data->outgoing ){
+			while(pq_get_order(packet, &number, &length) == EOK){
+				if(IS_IN_INTERVAL_OVERFLOW((uint32_t) old, (uint32_t)(number + length), (uint32_t) socket_data->expected)){
+					next = pq_detach(packet);
+					if(packet == socket_data->outgoing){
 						socket_data->outgoing = next;
 					}
 					// add to acknowledged or release
-					if( pq_add( & acknowledged, packet, 0, 0 ) != EOK ){
-						pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+					if(pq_add(&acknowledged, packet, 0, 0) != EOK){
+						pq_release(tcp_globals.net_phone, packet_get_id(packet));
 					}
 					packet = next;
-				}else if( old < socket_data->expected ){
+				}else if(old < socket_data->expected){
 					break;
 				}
 			}
 			// release acknowledged
-			if( acknowledged ){
-				pq_release( tcp_globals.net_phone, packet_get_id( acknowledged ));
+			if(acknowledged){
+				pq_release(tcp_globals.net_phone, packet_get_id(acknowledged));
 			}
 			return;
 		// if the same as the previous time
-		}else if( number == socket_data->expected ){
+		}else if(number == socket_data->expected){
 			// increase the counter
 			++ socket_data->expected_count;
-			if( socket_data->expected_count == TCP_FAST_RETRANSMIT_COUNT ){
+			if(socket_data->expected_count == TCP_FAST_RETRANSMIT_COUNT){
 				socket_data->expected_count = 1;
 				// TODO retransmit lock
-				//tcp_retransmit_packet( socket, socket_data, number );
-			}
-		}
-	}
-}
-
-int tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+				//tcp_retransmit_packet(socket, socket_data, number);
+			}
+		}
+	}
+}
+
+int tcp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
 	ERROR_DECLARE;
 
-	packet_t	packet;
-
-	assert( call );
-	assert( answer );
-	assert( answer_count );
-
-	* answer_count = 0;
-	switch( IPC_GET_METHOD( * call )){
+	packet_t packet;
+
+	assert(call);
+	assert(answer);
+	assert(answer_count);
+
+	*answer_count = 0;
+	switch(IPC_GET_METHOD(*call)){
 		case NET_TL_RECEIVED:
-			//fibril_rwlock_read_lock( & tcp_globals.lock );
-			if( ! ERROR_OCCURRED( packet_translate( tcp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = tcp_received_msg( IPC_GET_DEVICE( call ), packet, SERVICE_TCP, IPC_GET_ERROR( call ));
-			}
-			//fibril_rwlock_read_unlock( & tcp_globals.lock );
+			//fibril_rwlock_read_lock(&tcp_globals.lock);
+			if(! ERROR_OCCURRED(packet_translate(tcp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = tcp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_TCP, IPC_GET_ERROR(call));
+			}
+			//fibril_rwlock_read_unlock(&tcp_globals.lock);
 			return ERROR_CODE;
 		case IPC_M_CONNECT_TO_ME:
-			return tcp_process_client_messages( callid, * call );
+			return tcp_process_client_messages(callid, * call);
 	}
 	return ENOTSUP;
 }
 
-void tcp_refresh_socket_data( tcp_socket_data_ref socket_data ){
-	assert( socket_data );
-
-	bzero( socket_data, sizeof( * socket_data ));
+void tcp_refresh_socket_data(tcp_socket_data_ref socket_data){
+	assert(socket_data);
+
+	bzero(socket_data, sizeof(*socket_data));
 	socket_data->state = TCP_SOCKET_INITIAL;
 	socket_data->device_id = DEVICE_INVALID_ID;
@@ -1043,26 +1045,26 @@
 }
 
-void tcp_initialize_socket_data( tcp_socket_data_ref socket_data ){
-	assert( socket_data );
-
-	tcp_refresh_socket_data( socket_data );
-	fibril_mutex_initialize( & socket_data->operation.mutex );
-	fibril_condvar_initialize( & socket_data->operation.condvar );
+void tcp_initialize_socket_data(tcp_socket_data_ref socket_data){
+	assert(socket_data);
+
+	tcp_refresh_socket_data(socket_data);
+	fibril_mutex_initialize(&socket_data->operation.mutex);
+	fibril_condvar_initialize(&socket_data->operation.condvar);
 	socket_data->data_fragment_size = MAX_TCP_FRAGMENT_SIZE;
 }
 
-int tcp_process_client_messages( ipc_callid_t callid, ipc_call_t call ){
-	int						res;
-	bool					keep_on_going = true;
-	socket_cores_t			local_sockets;
-	int						app_phone = IPC_GET_PHONE( & call );
-	struct sockaddr *		addr;
-	size_t					addrlen;
-	fibril_rwlock_t			lock;
-	ipc_call_t				answer;
-	int						answer_count;
-	tcp_socket_data_ref		socket_data;
-	socket_core_ref			socket;
-	packet_dimension_ref	packet_dimension;
+int tcp_process_client_messages(ipc_callid_t callid, ipc_call_t call){
+	int res;
+	bool keep_on_going = true;
+	socket_cores_t local_sockets;
+	int app_phone = IPC_GET_PHONE(&call);
+	struct sockaddr * addr;
+	size_t addrlen;
+	fibril_rwlock_t lock;
+	ipc_call_t answer;
+	int answer_count;
+	tcp_socket_data_ref socket_data;
+	socket_core_ref socket;
+	packet_dimension_ref packet_dimension;
 
 	/*
@@ -1073,20 +1075,20 @@
 	answer_count = 0;
 
-	socket_cores_initialize( & local_sockets );
-	fibril_rwlock_initialize( & lock );
-
-	while( keep_on_going ){
+	socket_cores_initialize(&local_sockets);
+	fibril_rwlock_initialize(&lock);
+
+	while(keep_on_going){
 
 		// answer the call
-		answer_call( callid, res, & answer, answer_count );
+		answer_call(callid, res, &answer, answer_count);
 
 		// refresh data
-		refresh_answer( & answer, & answer_count );
+		refresh_answer(&answer, &answer_count);
 
 		// get the next call
-		callid = async_get_call( & call );
+		callid = async_get_call(&call);
 
 		// process the call
-		switch( IPC_GET_METHOD( call )){
+		switch(IPC_GET_METHOD(call)){
 			case IPC_M_PHONE_HUNGUP:
 				keep_on_going = false;
@@ -1094,88 +1096,88 @@
 				break;
 			case NET_SOCKET:
-				socket_data = ( tcp_socket_data_ref ) malloc( sizeof( * socket_data ));
-				if( ! socket_data ){
+				socket_data = (tcp_socket_data_ref) malloc(sizeof(*socket_data));
+				if(! socket_data){
 					res = ENOMEM;
 				}else{
-					tcp_initialize_socket_data( socket_data );
-					socket_data->local_lock = & lock;
-					socket_data->local_sockets = & local_sockets;
-					fibril_rwlock_write_lock( & lock );
-					* SOCKET_SET_SOCKET_ID( answer ) = SOCKET_GET_SOCKET_ID( call );
-					res = socket_create( & local_sockets, app_phone, socket_data, SOCKET_SET_SOCKET_ID( answer ));
-					fibril_rwlock_write_unlock( & lock );
-					if( res == EOK ){
-						if( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, DEVICE_INVALID_ID, & packet_dimension ) == EOK ){
-							* SOCKET_SET_DATA_FRAGMENT_SIZE( answer ) = (( packet_dimension->content < socket_data->data_fragment_size ) ? packet_dimension->content : socket_data->data_fragment_size );
+					tcp_initialize_socket_data(socket_data);
+					socket_data->local_lock = &lock;
+					socket_data->local_sockets = &local_sockets;
+					fibril_rwlock_write_lock(&lock);
+					*SOCKET_SET_SOCKET_ID(answer) = SOCKET_GET_SOCKET_ID(call);
+					res = socket_create(&local_sockets, app_phone, socket_data, SOCKET_SET_SOCKET_ID(answer));
+					fibril_rwlock_write_unlock(&lock);
+					if(res == EOK){
+						if(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){
+							*SOCKET_SET_DATA_FRAGMENT_SIZE(answer) = ((packet_dimension->content < socket_data->data_fragment_size) ? packet_dimension->content : socket_data->data_fragment_size);
 						}
-//						* SOCKET_SET_DATA_FRAGMENT_SIZE( answer ) = MAX_TCP_FRAGMENT_SIZE;
-						* SOCKET_SET_HEADER_SIZE( answer ) = TCP_HEADER_SIZE;
+//						*SOCKET_SET_DATA_FRAGMENT_SIZE(answer) = MAX_TCP_FRAGMENT_SIZE;
+						*SOCKET_SET_HEADER_SIZE(answer) = TCP_HEADER_SIZE;
 						answer_count = 3;
 					}else{
-						free( socket_data );
+						free(socket_data);
 					}
 				}
 				break;
 			case NET_SOCKET_BIND:
-				res = data_receive(( void ** ) & addr, & addrlen );
-				if( res == EOK ){
-					fibril_rwlock_write_lock( & tcp_globals.lock );
-					fibril_rwlock_write_lock( & lock );
-					res = socket_bind( & local_sockets, & tcp_globals.sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, tcp_globals.last_used_port );
-					if( res == EOK ){
-						socket = socket_cores_find( & local_sockets, SOCKET_GET_SOCKET_ID( call ));
-						if( socket ){
-							socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-							assert( socket_data );
+				res = data_receive((void **) &addr, &addrlen);
+				if(res == EOK){
+					fibril_rwlock_write_lock(&tcp_globals.lock);
+					fibril_rwlock_write_lock(&lock);
+					res = socket_bind(&local_sockets, &tcp_globals.sockets, SOCKET_GET_SOCKET_ID(call), addr, addrlen, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, tcp_globals.last_used_port);
+					if(res == EOK){
+						socket = socket_cores_find(&local_sockets, SOCKET_GET_SOCKET_ID(call));
+						if(socket){
+							socket_data = (tcp_socket_data_ref) socket->specific_data;
+							assert(socket_data);
 							socket_data->state = TCP_SOCKET_LISTEN;
 						}
 					}
-					fibril_rwlock_write_unlock( & lock );
-					fibril_rwlock_write_unlock( & tcp_globals.lock );
-					free( addr );
+					fibril_rwlock_write_unlock(&lock);
+					fibril_rwlock_write_unlock(&tcp_globals.lock);
+					free(addr);
 				}
 				break;
 			case NET_SOCKET_LISTEN:
-				fibril_rwlock_read_lock( & tcp_globals.lock );
-//				fibril_rwlock_write_lock( & tcp_globals.lock );
-				fibril_rwlock_write_lock( & lock );
-				res = tcp_listen_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_BACKLOG( call ));
-				fibril_rwlock_write_unlock( & lock );
-//				fibril_rwlock_write_unlock( & tcp_globals.lock );
-				fibril_rwlock_read_unlock( & tcp_globals.lock );
+				fibril_rwlock_read_lock(&tcp_globals.lock);
+//				fibril_rwlock_write_lock(&tcp_globals.lock);
+				fibril_rwlock_write_lock(&lock);
+				res = tcp_listen_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_BACKLOG(call));
+				fibril_rwlock_write_unlock(&lock);
+//				fibril_rwlock_write_unlock(&tcp_globals.lock);
+				fibril_rwlock_read_unlock(&tcp_globals.lock);
 				break;
 			case NET_SOCKET_CONNECT:
-				res = data_receive(( void ** ) & addr, & addrlen );
-				if( res == EOK ){
+				res = data_receive((void **) &addr, &addrlen);
+				if(res == EOK){
 					// the global lock may be released in the tcp_connect_message() function
-					fibril_rwlock_write_lock( & tcp_globals.lock );
-					fibril_rwlock_write_lock( & lock );
-					res = tcp_connect_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen );
-					if( res != EOK ){
-						fibril_rwlock_write_unlock( & lock );
-						fibril_rwlock_write_unlock( & tcp_globals.lock );
-						free( addr );
+					fibril_rwlock_write_lock(&tcp_globals.lock);
+					fibril_rwlock_write_lock(&lock);
+					res = tcp_connect_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), addr, addrlen);
+					if(res != EOK){
+						fibril_rwlock_write_unlock(&lock);
+						fibril_rwlock_write_unlock(&tcp_globals.lock);
+						free(addr);
 					}
 				}
 				break;
 			case NET_SOCKET_ACCEPT:
-				fibril_rwlock_read_lock( & tcp_globals.lock );
-				fibril_rwlock_write_lock( & lock );
-				res = tcp_accept_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_NEW_SOCKET_ID( call ), SOCKET_SET_DATA_FRAGMENT_SIZE( answer ), & addrlen );
-				fibril_rwlock_write_unlock( & lock );
-				fibril_rwlock_read_unlock( & tcp_globals.lock );
-				if( res > 0 ){
-					* SOCKET_SET_SOCKET_ID( answer ) = res;
-					* SOCKET_SET_ADDRESS_LENGTH( answer ) = addrlen;
+				fibril_rwlock_read_lock(&tcp_globals.lock);
+				fibril_rwlock_write_lock(&lock);
+				res = tcp_accept_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_NEW_SOCKET_ID(call), SOCKET_SET_DATA_FRAGMENT_SIZE(answer), &addrlen);
+				fibril_rwlock_write_unlock(&lock);
+				fibril_rwlock_read_unlock(&tcp_globals.lock);
+				if(res > 0){
+					*SOCKET_SET_SOCKET_ID(answer) = res;
+					*SOCKET_SET_ADDRESS_LENGTH(answer) = addrlen;
 					answer_count = 3;
 				}
 				break;
 			case NET_SOCKET_SEND:
-				fibril_rwlock_read_lock( & tcp_globals.lock );
-				fibril_rwlock_write_lock( & lock );
-				res = tcp_send_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_DATA_FRAGMENTS( call ), SOCKET_SET_DATA_FRAGMENT_SIZE( answer ), SOCKET_GET_FLAGS( call ));
-				if( res != EOK ){
-					fibril_rwlock_write_unlock( & lock );
-					fibril_rwlock_read_unlock( & tcp_globals.lock );
+				fibril_rwlock_read_lock(&tcp_globals.lock);
+				fibril_rwlock_write_lock(&lock);
+				res = tcp_send_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_DATA_FRAGMENTS(call), SOCKET_SET_DATA_FRAGMENT_SIZE(answer), SOCKET_GET_FLAGS(call));
+				if(res != EOK){
+					fibril_rwlock_write_unlock(&lock);
+					fibril_rwlock_read_unlock(&tcp_globals.lock);
 				}else{
 					answer_count = 2;
@@ -1183,26 +1185,26 @@
 				break;
 			case NET_SOCKET_SENDTO:
-				res = data_receive(( void ** ) & addr, & addrlen );
-				if( res == EOK ){
-					fibril_rwlock_read_lock( & tcp_globals.lock );
-					fibril_rwlock_write_lock( & lock );
-					res = tcp_send_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_DATA_FRAGMENTS( call ), SOCKET_SET_DATA_FRAGMENT_SIZE( answer ), SOCKET_GET_FLAGS( call ));
-					if( res != EOK ){
-						fibril_rwlock_write_unlock( & lock );
-						fibril_rwlock_read_unlock( & tcp_globals.lock );
+				res = data_receive((void **) &addr, &addrlen);
+				if(res == EOK){
+					fibril_rwlock_read_lock(&tcp_globals.lock);
+					fibril_rwlock_write_lock(&lock);
+					res = tcp_send_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_DATA_FRAGMENTS(call), SOCKET_SET_DATA_FRAGMENT_SIZE(answer), SOCKET_GET_FLAGS(call));
+					if(res != EOK){
+						fibril_rwlock_write_unlock(&lock);
+						fibril_rwlock_read_unlock(&tcp_globals.lock);
 					}else{
 						answer_count = 2;
 					}
-					free( addr );
+					free(addr);
 				}
 				break;
 			case NET_SOCKET_RECV:
-				fibril_rwlock_read_lock( & tcp_globals.lock );
-				fibril_rwlock_write_lock( & lock );
-				res = tcp_recvfrom_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_FLAGS( call ), NULL );
-				fibril_rwlock_write_unlock( & lock );
-				fibril_rwlock_read_unlock( & tcp_globals.lock );
-				if( res > 0 ){
-					* SOCKET_SET_READ_DATA_LENGTH( answer ) = res;
+				fibril_rwlock_read_lock(&tcp_globals.lock);
+				fibril_rwlock_write_lock(&lock);
+				res = tcp_recvfrom_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_FLAGS(call), NULL);
+				fibril_rwlock_write_unlock(&lock);
+				fibril_rwlock_read_unlock(&tcp_globals.lock);
+				if(res > 0){
+					*SOCKET_SET_READ_DATA_LENGTH(answer) = res;
 					answer_count = 1;
 					res = EOK;
@@ -1210,12 +1212,12 @@
 				break;
 			case NET_SOCKET_RECVFROM:
-				fibril_rwlock_read_lock( & tcp_globals.lock );
-				fibril_rwlock_write_lock( & lock );
-				res = tcp_recvfrom_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_FLAGS( call ), & addrlen );
-				fibril_rwlock_write_unlock( & lock );
-				fibril_rwlock_read_unlock( & tcp_globals.lock );
-				if( res > 0 ){
-					* SOCKET_SET_READ_DATA_LENGTH( answer ) = res;
-					* SOCKET_SET_ADDRESS_LENGTH( answer ) = addrlen;
+				fibril_rwlock_read_lock(&tcp_globals.lock);
+				fibril_rwlock_write_lock(&lock);
+				res = tcp_recvfrom_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_FLAGS(call), &addrlen);
+				fibril_rwlock_write_unlock(&lock);
+				fibril_rwlock_read_unlock(&tcp_globals.lock);
+				if(res > 0){
+					*SOCKET_SET_READ_DATA_LENGTH(answer) = res;
+					*SOCKET_SET_ADDRESS_LENGTH(answer) = addrlen;
 					answer_count = 3;
 					res = EOK;
@@ -1223,10 +1225,10 @@
 				break;
 			case NET_SOCKET_CLOSE:
-				fibril_rwlock_write_lock( & tcp_globals.lock );
-				fibril_rwlock_write_lock( & lock );
-				res = tcp_close_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ));
-				if( res != EOK ){
-					fibril_rwlock_write_unlock( & lock );
-					fibril_rwlock_write_unlock( & tcp_globals.lock );
+				fibril_rwlock_write_lock(&tcp_globals.lock);
+				fibril_rwlock_write_lock(&lock);
+				res = tcp_close_message(&local_sockets, SOCKET_GET_SOCKET_ID(call));
+				if(res != EOK){
+					fibril_rwlock_write_unlock(&lock);
+					fibril_rwlock_write_unlock(&tcp_globals.lock);
 				}
 				break;
@@ -1241,50 +1243,50 @@
 	printf("release\n");
 	// release all local sockets
-	socket_cores_release( tcp_globals.net_phone, & local_sockets, & tcp_globals.sockets, tcp_free_socket_data );
+	socket_cores_release(tcp_globals.net_phone, &local_sockets, &tcp_globals.sockets, tcp_free_socket_data);
 
 	return EOK;
 }
 
-int tcp_timeout( void * data ){
-	tcp_timeout_ref		timeout = data;
-	int					keep_write_lock = false;
-	socket_core_ref		socket;
-	tcp_socket_data_ref	socket_data;
-
-	assert( timeout );
+int tcp_timeout(void * data){
+	tcp_timeout_ref timeout = data;
+	int keep_write_lock = false;
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+
+	assert(timeout);
 
 	// sleep the given timeout
-	async_usleep( timeout->timeout );
+	async_usleep(timeout->timeout);
 	// lock the globals
-	if( timeout->globals_read_only ){
-		fibril_rwlock_read_lock( & tcp_globals.lock );
+	if(timeout->globals_read_only){
+		fibril_rwlock_read_lock(&tcp_globals.lock);
 	}else{
-		fibril_rwlock_write_lock( & tcp_globals.lock );
+		fibril_rwlock_write_lock(&tcp_globals.lock);
 	}
 	// find the pending operation socket
-	socket = socket_port_find( & tcp_globals.sockets, timeout->port, timeout->key, timeout->key_length );
-	if( socket && ( socket->socket_id == timeout->socket_id )){
-		socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-		assert( socket_data );
-		if( socket_data->local_sockets == timeout->local_sockets ){
-			fibril_rwlock_write_lock( socket_data->local_lock );
-			if( timeout->sequence_number ){
+	socket = socket_port_find(&tcp_globals.sockets, timeout->port, timeout->key, timeout->key_length);
+	if(socket && (socket->socket_id == timeout->socket_id)){
+		socket_data = (tcp_socket_data_ref) socket->specific_data;
+		assert(socket_data);
+		if(socket_data->local_sockets == timeout->local_sockets){
+			fibril_rwlock_write_lock(socket_data->local_lock);
+			if(timeout->sequence_number){
 				// increase the timeout counter;
 				++ socket_data->timeout_count;
-				if( socket_data->timeout_count == TCP_MAX_TIMEOUTS ){
+				if(socket_data->timeout_count == TCP_MAX_TIMEOUTS){
 					// TODO release as connection lost
-					//tcp_refresh_socket_data( socket_data );
+					//tcp_refresh_socket_data(socket_data);
 				}else{
 					// retransmit
-					tcp_retransmit_packet( socket, socket_data, timeout->sequence_number );
-				}
-				fibril_rwlock_write_unlock( socket_data->local_lock );
+					tcp_retransmit_packet(socket, socket_data, timeout->sequence_number);
+				}
+				fibril_rwlock_write_unlock(socket_data->local_lock);
 			}else{
-				fibril_mutex_lock( & socket_data->operation.mutex );
+				fibril_mutex_lock(&socket_data->operation.mutex);
 				// set the timeout operation result if state not changed
-				if( socket_data->state == timeout->state ){
+				if(socket_data->state == timeout->state){
 					socket_data->operation.result = ETIMEOUT;
 					// notify the main fibril
-					fibril_condvar_signal( & socket_data->operation.condvar );
+					fibril_condvar_signal(&socket_data->operation.condvar);
 					// keep the global write lock
 					keep_write_lock = true;
@@ -1292,91 +1294,95 @@
 					// operation is ok, do nothing
 					// unlocking from now on, so the unlock order does not matter...
-					fibril_rwlock_write_unlock( socket_data->local_lock );
-				}
-				fibril_mutex_unlock( & socket_data->operation.mutex );
+					fibril_rwlock_write_unlock(socket_data->local_lock);
+				}
+				fibril_mutex_unlock(&socket_data->operation.mutex);
 			}
 		}
 	}
 	// unlock only if no socket
-	if( timeout->globals_read_only ){
-		fibril_rwlock_read_unlock( & tcp_globals.lock );
-	}else if( ! keep_write_lock ){
+	if(timeout->globals_read_only){
+		fibril_rwlock_read_unlock(&tcp_globals.lock);
+	}else if(! keep_write_lock){
 		// release if not desired
-		fibril_rwlock_write_unlock( & tcp_globals.lock );
+		fibril_rwlock_write_unlock(&tcp_globals.lock);
 	}
 	// release the timeout structure
-	free( timeout );
+	free(timeout);
 	return EOK;
 }
 
-int tcp_release_after_timeout( void * data ){
-	tcp_timeout_ref		timeout = data;
-	socket_core_ref		socket;
-	tcp_socket_data_ref	socket_data;
-	fibril_rwlock_t *	local_lock;
-
-	assert( timeout );
+int tcp_release_after_timeout(void * data){
+	tcp_timeout_ref timeout = data;
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+	fibril_rwlock_t * local_lock;
+
+	assert(timeout);
 
 	// sleep the given timeout
-	async_usleep( timeout->timeout );
+	async_usleep(timeout->timeout);
 	// lock the globals
-	fibril_rwlock_write_lock( & tcp_globals.lock );
+	fibril_rwlock_write_lock(&tcp_globals.lock);
 	// find the pending operation socket
-	socket = socket_port_find( & tcp_globals.sockets, timeout->port, timeout->key, timeout->key_length );
-	if( socket && ( socket->socket_id == timeout->socket_id )){
-		socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-		assert( socket_data );
-		if( socket_data->local_sockets == timeout->local_sockets ){
+	socket = socket_port_find(&tcp_globals.sockets, timeout->port, timeout->key, timeout->key_length);
+	if(socket && (socket->socket_id == timeout->socket_id)){
+		socket_data = (tcp_socket_data_ref) socket->specific_data;
+		assert(socket_data);
+		if(socket_data->local_sockets == timeout->local_sockets){
 			local_lock = socket_data->local_lock;
-			fibril_rwlock_write_lock( local_lock );
-			socket_destroy( tcp_globals.net_phone, timeout->socket_id, timeout->local_sockets, & tcp_globals.sockets, tcp_free_socket_data );
-			fibril_rwlock_write_unlock( local_lock );
+			fibril_rwlock_write_lock(local_lock);
+			socket_destroy(tcp_globals.net_phone, timeout->socket_id, timeout->local_sockets, &tcp_globals.sockets, tcp_free_socket_data);
+			fibril_rwlock_write_unlock(local_lock);
 		}
 	}
 	// unlock the globals
-	fibril_rwlock_write_unlock( & tcp_globals.lock );
+	fibril_rwlock_write_unlock(&tcp_globals.lock);
 	// release the timeout structure
-	free( timeout );
+	free(timeout);
 	return EOK;
 }
 
-void tcp_retransmit_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number ){
-	packet_t	packet;
-	packet_t	copy;
-	size_t		data_length;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
+void tcp_retransmit_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number){
+	packet_t packet;
+	packet_t copy;
+	size_t data_length;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
 
 	// sent packet?
-	packet = pq_find( socket_data->outgoing, sequence_number );
-	printf("retransmit %d\n", packet_get_id( packet ));
-	if( packet ){
-		pq_get_order( packet, NULL, & data_length );
-		copy = tcp_prepare_copy( socket, socket_data, packet, data_length, sequence_number );
-		fibril_rwlock_write_unlock( socket_data->local_lock );
-//		printf( "r send %d\n", packet_get_id( packet ));
-		if( copy ){
-			tcp_send_packets( socket_data->device_id, copy );
+	packet = pq_find(socket_data->outgoing, sequence_number);
+	printf("retransmit %d\n", packet_get_id(packet));
+	if(packet){
+		pq_get_order(packet, NULL, &data_length);
+		copy = tcp_prepare_copy(socket, socket_data, packet, data_length, sequence_number);
+		fibril_rwlock_write_unlock(socket_data->local_lock);
+//		printf("r send %d\n", packet_get_id(packet));
+		if(copy){
+			tcp_send_packets(socket_data->device_id, copy);
 		}
 	}else{
-		fibril_rwlock_write_unlock( socket_data->local_lock );
-	}
-}
-
-int tcp_listen_message( socket_cores_ref local_sockets, int socket_id, int backlog ){
-	socket_core_ref		socket;
-	tcp_socket_data_ref	socket_data;
-
-	assert( local_sockets );
-
-	if( backlog < 0 ) return EINVAL;
+		fibril_rwlock_write_unlock(socket_data->local_lock);
+	}
+}
+
+int tcp_listen_message(socket_cores_ref local_sockets, int socket_id, int backlog){
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+
+	assert(local_sockets);
+
+	if(backlog < 0){
+		return EINVAL;
+	}
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
 	// get the socket specific data
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-	assert( socket_data );
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
+	assert(socket_data);
 	// set the backlog
 	socket_data->backlog = backlog;
@@ -1384,21 +1390,23 @@
 }
 
-int tcp_connect_message( socket_cores_ref local_sockets, int socket_id, struct sockaddr * addr, socklen_t addrlen ){
+int tcp_connect_message(socket_cores_ref local_sockets, int socket_id, struct sockaddr * addr, socklen_t addrlen){
 	ERROR_DECLARE;
 
-	socket_core_ref			socket;
-
-	assert( local_sockets );
-	assert( addr );
-	assert( addrlen > 0 );
+	socket_core_ref socket;
+
+	assert(local_sockets);
+	assert(addr);
+	assert(addrlen > 0);
 
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
-	if( ERROR_OCCURRED( tcp_connect_core( socket, local_sockets, addr, addrlen ))){
-		tcp_free_socket_data( socket );
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
+	if(ERROR_OCCURRED(tcp_connect_core(socket, local_sockets, addr, addrlen))){
+		tcp_free_socket_data(socket);
 		// unbind if bound
-		if( socket->port > 0 ){
-			socket_ports_exclude( & tcp_globals.sockets, socket->port );
+		if(socket->port > 0){
+			socket_ports_exclude(&tcp_globals.sockets, socket->port);
 			socket->port = 0;
 		}
@@ -1407,58 +1415,58 @@
 }
 
-int tcp_connect_core( socket_core_ref socket, socket_cores_ref local_sockets, struct sockaddr * addr, socklen_t addrlen ){
+int tcp_connect_core(socket_core_ref socket, socket_cores_ref local_sockets, struct sockaddr * addr, socklen_t addrlen){
 	ERROR_DECLARE;
 
-	tcp_socket_data_ref		socket_data;
-	packet_t				packet;
-
-	assert( socket );
-	assert( addr );
-	assert( addrlen > 0 );
+	tcp_socket_data_ref socket_data;
+	packet_t packet;
+
+	assert(socket);
+	assert(addr);
+	assert(addrlen > 0);
 
 	// get the socket specific data
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	if(( socket_data->state != TCP_SOCKET_INITIAL )
-	&& (( socket_data->state != TCP_SOCKET_LISTEN ) || ( socket->port <= 0 ))){
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	if((socket_data->state != TCP_SOCKET_INITIAL)
+		&& ((socket_data->state != TCP_SOCKET_LISTEN) || (socket->port <= 0))){
 		return EINVAL;
 	}
 	// get the destination port
-	ERROR_PROPAGATE( tl_get_address_port( addr, addrlen, & socket_data->dest_port ));
-	if( socket->port <= 0 ){
+	ERROR_PROPAGATE(tl_get_address_port(addr, addrlen, &socket_data->dest_port));
+	if(socket->port <= 0){
 		// try to find a free port
-		ERROR_PROPAGATE( socket_bind_free_port( & tcp_globals.sockets, socket, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, tcp_globals.last_used_port ));
+		ERROR_PROPAGATE(socket_bind_free_port(&tcp_globals.sockets, socket, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, tcp_globals.last_used_port));
 		// set the next port as the search starting port number
 		tcp_globals.last_used_port = socket->port;
 	}
-	ERROR_PROPAGATE( ip_get_route_req( tcp_globals.ip_phone, IPPROTO_TCP, addr, addrlen, & socket_data->device_id, & socket_data->pseudo_header, & socket_data->headerlen ));
+	ERROR_PROPAGATE(ip_get_route_req(tcp_globals.ip_phone, IPPROTO_TCP, addr, addrlen, &socket_data->device_id, &socket_data->pseudo_header, &socket_data->headerlen));
 
 	// create the notification packet
-	ERROR_PROPAGATE( tcp_create_notification_packet( & packet, socket, socket_data, 1, 0 ));
+	ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket, socket_data, 1, 0));
 
 	// unlock the globals and wait for an operation
-	fibril_rwlock_write_unlock( & tcp_globals.lock );
+	fibril_rwlock_write_unlock(&tcp_globals.lock);
 
 	socket_data->addr = addr;
 	socket_data->addrlen = addrlen;
 	// send the packet
-	if( ERROR_OCCURRED( tcp_queue_packet( socket, socket_data, packet, 1 ))
-	|| ERROR_OCCURRED( tcp_prepare_timeout( tcp_timeout, socket, socket_data, 0, TCP_SOCKET_INITIAL, NET_DEFAULT_TCP_INITIAL_TIMEOUT, false ))){
+	if(ERROR_OCCURRED(tcp_queue_packet(socket, socket_data, packet, 1))
+		|| ERROR_OCCURRED(tcp_prepare_timeout(tcp_timeout, socket, socket_data, 0, TCP_SOCKET_INITIAL, NET_DEFAULT_TCP_INITIAL_TIMEOUT, false))){
 		socket_data->addr = NULL;
 		socket_data->addrlen = 0;
-		fibril_rwlock_write_lock( & tcp_globals.lock );
+		fibril_rwlock_write_lock(&tcp_globals.lock);
 	}else{
-		packet = tcp_get_packets_to_send( socket, socket_data );
-		if( packet ){
-			fibril_mutex_lock( & socket_data->operation.mutex );
-			fibril_rwlock_write_unlock( socket_data->local_lock );
+		packet = tcp_get_packets_to_send(socket, socket_data);
+		if(packet){
+			fibril_mutex_lock(&socket_data->operation.mutex);
+			fibril_rwlock_write_unlock(socket_data->local_lock);
 			// send the packet
-			printf( "connecting %d\n", packet_get_id( packet ));
-			tcp_send_packets( socket_data->device_id, packet );
+			printf("connecting %d\n", packet_get_id(packet));
+			tcp_send_packets(socket_data->device_id, packet);
 			// wait for a reply
-			fibril_condvar_wait( & socket_data->operation.condvar, & socket_data->operation.mutex );
+			fibril_condvar_wait(&socket_data->operation.condvar, &socket_data->operation.mutex);
 			ERROR_CODE = socket_data->operation.result;
-			if( ERROR_CODE != EOK ){
+			if(ERROR_CODE != EOK){
 				socket_data->addr = NULL;
 				socket_data->addrlen = 0;
@@ -1471,5 +1479,5 @@
 	}
 
-	fibril_mutex_unlock( & socket_data->operation.mutex );
+	fibril_mutex_unlock(&socket_data->operation.mutex);
 
 	// return the result
@@ -1477,24 +1485,26 @@
 }
 
-int tcp_queue_prepare_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length ){
+int tcp_queue_prepare_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length){
 	ERROR_DECLARE;
 
-	tcp_header_ref	header;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
+	tcp_header_ref header;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
 
 	// get tcp header
-	header = ( tcp_header_ref ) packet_get_data( packet );
-	if( ! header ) return NO_DATA;
-	header->destination_port = htons( socket_data->dest_port );
-	header->source_port = htons( socket->port );
-	header->sequence_number = htonl( socket_data->next_outgoing );
-	if( ERROR_OCCURRED( packet_set_addr( packet, NULL, ( uint8_t * ) socket_data->addr, socket_data->addrlen ))){
-		return tcp_release_and_return( packet, EINVAL );
+	header = (tcp_header_ref) packet_get_data(packet);
+	if(! header){
+		return NO_DATA;
+	}
+	header->destination_port = htons(socket_data->dest_port);
+	header->source_port = htons(socket->port);
+	header->sequence_number = htonl(socket_data->next_outgoing);
+	if(ERROR_OCCURRED(packet_set_addr(packet, NULL, (uint8_t *) socket_data->addr, socket_data->addrlen))){
+		return tcp_release_and_return(packet, EINVAL);
 	}
 	// remember the outgoing FIN
-	if( header->finalize ){
+	if(header->finalize){
 		socket_data->fin_outgoing = socket_data->next_outgoing;
 	}
@@ -1502,15 +1512,15 @@
 }
 
-int	tcp_queue_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length ){
+int tcp_queue_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length){
 	ERROR_DECLARE;
 
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-
-	ERROR_PROPAGATE( tcp_queue_prepare_packet( socket, socket_data, packet, data_length ));
-
-	if( ERROR_OCCURRED( pq_add( & socket_data->outgoing, packet, socket_data->next_outgoing, data_length ))){
-		return tcp_release_and_return( packet, ERROR_CODE );
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+
+	ERROR_PROPAGATE(tcp_queue_prepare_packet(socket, socket_data, packet, data_length));
+
+	if(ERROR_OCCURRED(pq_add(&socket_data->outgoing, packet, socket_data->next_outgoing, data_length))){
+		return tcp_release_and_return(packet, ERROR_CODE);
 	}
 	socket_data->next_outgoing += data_length;
@@ -1518,39 +1528,39 @@
 }
 
-packet_t tcp_get_packets_to_send( socket_core_ref socket, tcp_socket_data_ref socket_data ){
+packet_t tcp_get_packets_to_send(socket_core_ref socket, tcp_socket_data_ref socket_data){
 	ERROR_DECLARE;
 
-	packet_t		packet;
-	packet_t		copy;
-	packet_t		sending = NULL;
-	packet_t		previous = NULL;
-	size_t			data_length;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-
-	packet = pq_find( socket_data->outgoing, socket_data->last_outgoing + 1 );
-	while( packet ){
-		pq_get_order( packet, NULL, & data_length );
+	packet_t packet;
+	packet_t copy;
+	packet_t sending = NULL;
+	packet_t previous = NULL;
+	size_t data_length;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+
+	packet = pq_find(socket_data->outgoing, socket_data->last_outgoing + 1);
+	while(packet){
+		pq_get_order(packet, NULL, &data_length);
 		// send only if fits into the window
 		// respecting the possible overflow
-		if( IS_IN_INTERVAL_OVERFLOW(( uint32_t ) socket_data->last_outgoing, ( uint32_t )( socket_data->last_outgoing + data_length ), ( uint32_t )( socket_data->expected + socket_data->treshold ))){
-			copy = tcp_prepare_copy( socket, socket_data, packet, data_length, socket_data->last_outgoing + 1 );
-			if( ! copy ){
+		if(IS_IN_INTERVAL_OVERFLOW((uint32_t) socket_data->last_outgoing, (uint32_t)(socket_data->last_outgoing + data_length), (uint32_t)(socket_data->expected + socket_data->treshold))){
+			copy = tcp_prepare_copy(socket, socket_data, packet, data_length, socket_data->last_outgoing + 1);
+			if(! copy){
 				return sending;
 			}
-			if( ! sending ){
+			if(! sending){
 				sending = copy;
 			}else{
-				if( ERROR_OCCURRED( pq_insert_after( previous, copy ))){
-					pq_release( tcp_globals.net_phone, packet_get_id( copy ));
+				if(ERROR_OCCURRED(pq_insert_after(previous, copy))){
+					pq_release(tcp_globals.net_phone, packet_get_id(copy));
 					return sending;
 				}
 			}
 			previous = copy;
-			packet = pq_next( packet );
+			packet = pq_next(packet);
 			// overflow occurred ?
-			if(( ! packet ) && ( socket_data->last_outgoing > socket_data->next_outgoing )){
+			if((! packet) && (socket_data->last_outgoing > socket_data->next_outgoing)){
 				printf("gpts overflow\n");
 				// continue from the beginning
@@ -1565,45 +1575,45 @@
 }
 
-packet_t tcp_send_prepare_packet( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number ){
+packet_t tcp_send_prepare_packet(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number){
 	ERROR_DECLARE;
 
-	tcp_header_ref	header;
-	uint32_t		checksum;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
+	tcp_header_ref header;
+	uint32_t checksum;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
 
 	// adjust the pseudo header
-	if( ERROR_OCCURRED( ip_client_set_pseudo_header_data_length( socket_data->pseudo_header, socket_data->headerlen, packet_get_data_length( packet )))){
-		pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+	if(ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(socket_data->pseudo_header, socket_data->headerlen, packet_get_data_length(packet)))){
+		pq_release(tcp_globals.net_phone, packet_get_id(packet));
 		return NULL;
 	}
 
 	// get the header
-	header = ( tcp_header_ref ) packet_get_data( packet );
-	if( ! header ){
-		pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+	header = (tcp_header_ref) packet_get_data(packet);
+	if(! header){
+		pq_release(tcp_globals.net_phone, packet_get_id(packet));
 		return NULL;
 	}
-	assert( ntohl( header->sequence_number ) == sequence_number );
+	assert(ntohl(header->sequence_number) == sequence_number);
 
 	// adjust the header
-	if( socket_data->next_incoming ){
-		header->acknowledgement_number = htonl( socket_data->next_incoming );
+	if(socket_data->next_incoming){
+		header->acknowledgement_number = htonl(socket_data->next_incoming);
 		header->acknowledge = 1;
 	}
-	header->window = htons( socket_data->window );
+	header->window = htons(socket_data->window);
 
 	// checksum
 	header->checksum = 0;
-	checksum = compute_checksum( 0, socket_data->pseudo_header, socket_data->headerlen );
-	checksum = compute_checksum( checksum, ( uint8_t * ) packet_get_data( packet ), packet_get_data_length( packet ));
-	header->checksum = htons( flip_checksum( compact_checksum( checksum )));
+	checksum = compute_checksum(0, socket_data->pseudo_header, socket_data->headerlen);
+	checksum = compute_checksum(checksum, (uint8_t *) packet_get_data(packet), packet_get_data_length(packet));
+	header->checksum = htons(flip_checksum(compact_checksum(checksum)));
 	// prepare the packet
-	if( ERROR_OCCURRED( ip_client_prepare_packet( packet, IPPROTO_TCP, 0, 0, 0, 0 ))
+	if(ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_TCP, 0, 0, 0, 0))
 	// prepare the timeout
-	|| ERROR_OCCURRED( tcp_prepare_timeout( tcp_timeout, socket, socket_data, sequence_number, socket_data->state, socket_data->timeout, true ))){
-		pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+		|| ERROR_OCCURRED(tcp_prepare_timeout(tcp_timeout, socket, socket_data, sequence_number, socket_data->state, socket_data->timeout, true))){
+		pq_release(tcp_globals.net_phone, packet_get_id(packet));
 		return NULL;
 	}
@@ -1611,54 +1621,58 @@
 }
 
-packet_t tcp_prepare_copy( socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number ){
-	packet_t		copy;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
+packet_t tcp_prepare_copy(socket_core_ref socket, tcp_socket_data_ref socket_data, packet_t packet, size_t data_length, size_t sequence_number){
+	packet_t copy;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
 
 	// make a copy of the packet
-	copy = packet_get_copy( tcp_globals.net_phone, packet );
-	if( ! copy ) return NULL;
-
-	return tcp_send_prepare_packet( socket, socket_data, copy, data_length, sequence_number );
-}
-
-void tcp_send_packets( device_id_t device_id, packet_t packet ){
-	packet_t	next;
-
-	while( packet ){
-		next = pq_detach( packet );
-		ip_send_msg( tcp_globals.ip_phone, device_id, packet, SERVICE_TCP, 0 );
+	copy = packet_get_copy(tcp_globals.net_phone, packet);
+	if(! copy){
+		return NULL;
+	}
+
+	return tcp_send_prepare_packet(socket, socket_data, copy, data_length, sequence_number);
+}
+
+void tcp_send_packets(device_id_t device_id, packet_t packet){
+	packet_t next;
+
+	while(packet){
+		next = pq_detach(packet);
+		ip_send_msg(tcp_globals.ip_phone, device_id, packet, SERVICE_TCP, 0);
 		packet = next;
 	}
 }
 
-void tcp_prepare_operation_header( socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize ){
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
-	assert( header );
-
-	bzero( header, sizeof( * header ));
-	header->source_port = htons( socket->port );
-	header->source_port = htons( socket_data->dest_port );
-	header->header_length = TCP_COMPUTE_HEADER_LENGTH( sizeof( * header ));
+void tcp_prepare_operation_header(socket_core_ref socket, tcp_socket_data_ref socket_data, tcp_header_ref header, int synchronize, int finalize){
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
+	assert(header);
+
+	bzero(header, sizeof(*header));
+	header->source_port = htons(socket->port);
+	header->source_port = htons(socket_data->dest_port);
+	header->header_length = TCP_COMPUTE_HEADER_LENGTH(sizeof(*header));
 	header->synchronize = synchronize;
 	header->finalize = finalize;
 }
 
-int tcp_prepare_timeout( int ( * timeout_function )( void * tcp_timeout_t ), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only ){
-	tcp_timeout_ref	operation_timeout;
-	fid_t			fibril;
-
-	assert( socket );
-	assert( socket_data );
-	assert( socket->specific_data == socket_data );
+int tcp_prepare_timeout(int (*timeout_function)(void * tcp_timeout_t), socket_core_ref socket, tcp_socket_data_ref socket_data, size_t sequence_number, tcp_socket_state_t state, suseconds_t timeout, int globals_read_only){
+	tcp_timeout_ref operation_timeout;
+	fid_t fibril;
+
+	assert(socket);
+	assert(socket_data);
+	assert(socket->specific_data == socket_data);
 
 	// prepare the timeout with key bundle structure
-	operation_timeout = malloc( sizeof( * operation_timeout ) + socket->key_length + 1 );
-	if( ! operation_timeout ) return ENOMEM;
-	bzero( operation_timeout, sizeof( * operation_timeout ));
+	operation_timeout = malloc(sizeof(*operation_timeout) + socket->key_length + 1);
+	if(! operation_timeout){
+		return ENOMEM;
+	}
+	bzero(operation_timeout, sizeof(*operation_timeout));
 	operation_timeout->globals_read_only = globals_read_only;
 	operation_timeout->port = socket->port;
@@ -1670,118 +1684,130 @@
 
 	// copy the key
-	operation_timeout->key = (( char * ) operation_timeout ) + sizeof( * operation_timeout );
+	operation_timeout->key = ((char *) operation_timeout) + sizeof(*operation_timeout);
 	operation_timeout->key_length = socket->key_length;
-	memcpy( operation_timeout->key, socket->key, socket->key_length );
-	operation_timeout->key[ operation_timeout->key_length ] = '\0';
+	memcpy(operation_timeout->key, socket->key, socket->key_length);
+	operation_timeout->key[operation_timeout->key_length] = '\0';
 
 	// prepare the timeouting thread
-	fibril = fibril_create( timeout_function, operation_timeout );
-	if( ! fibril ){
-		free( operation_timeout );
+	fibril = fibril_create(timeout_function, operation_timeout);
+	if(! fibril){
+		free(operation_timeout);
 		return EPARTY;
 	}
-//	fibril_mutex_lock( & socket_data->operation.mutex );
+//	fibril_mutex_lock(&socket_data->operation.mutex);
 	// start the timeouting fibril
-	fibril_add_ready( fibril );
+	fibril_add_ready(fibril);
 	//socket_data->state = state;
 	return EOK;
 }
 
-int tcp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen ){
+int tcp_recvfrom_message(socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen){
 	ERROR_DECLARE;
 
-	socket_core_ref		socket;
-	tcp_socket_data_ref	socket_data;
-	int					packet_id;
-	packet_t			packet;
-	size_t				length;
-
-	assert( local_sockets );
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+	int packet_id;
+	packet_t packet;
+	size_t length;
+
+	assert(local_sockets);
 
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
 	// get the socket specific data
-	if( ! socket->specific_data ) return NO_DATA;
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
+	if(! socket->specific_data){
+		return NO_DATA;
+	}
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
 
 	// check state
-	if(( socket_data->state != TCP_SOCKET_ESTABLISHED ) && ( socket_data->state != TCP_SOCKET_CLOSE_WAIT )){
+	if((socket_data->state != TCP_SOCKET_ESTABLISHED) && (socket_data->state != TCP_SOCKET_CLOSE_WAIT)){
 		return ENOTCONN;
 	}
 
 	// send the source address if desired
-	if( addrlen ){
-		ERROR_PROPAGATE( data_reply( socket_data->addr, socket_data->addrlen ));
-		* addrlen = socket_data->addrlen;
+	if(addrlen){
+		ERROR_PROPAGATE(data_reply(socket_data->addr, socket_data->addrlen));
+		*addrlen = socket_data->addrlen;
 	}
 
 	// get the next received packet
-	packet_id = dyn_fifo_value( & socket->received );
-	if( packet_id < 0 ) return NO_DATA;
-	ERROR_PROPAGATE( packet_translate( tcp_globals.net_phone, & packet, packet_id ));
+	packet_id = dyn_fifo_value(&socket->received);
+	if(packet_id < 0){
+		return NO_DATA;
+	}
+	ERROR_PROPAGATE(packet_translate(tcp_globals.net_phone, &packet, packet_id));
 
 	// reply the packets
-	ERROR_PROPAGATE( socket_reply_packets( packet, & length ));
+	ERROR_PROPAGATE(socket_reply_packets(packet, &length));
 
 	// release the packet
-	dyn_fifo_pop( & socket->received );
-	pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+	dyn_fifo_pop(&socket->received);
+	pq_release(tcp_globals.net_phone, packet_get_id(packet));
 	// return the total length
-	return ( int ) length;
-}
-
-int tcp_send_message( socket_cores_ref local_sockets, int socket_id, int fragments, size_t * data_fragment_size, int flags ){
+	return (int) length;
+}
+
+int tcp_send_message(socket_cores_ref local_sockets, int socket_id, int fragments, size_t * data_fragment_size, int flags){
 	ERROR_DECLARE;
 
-	socket_core_ref			socket;
-	tcp_socket_data_ref		socket_data;
-	packet_dimension_ref	packet_dimension;
-	packet_t				packet;
-	size_t					total_length;
-	tcp_header_ref			header;
-	int						index;
-	int						result;
-
-	assert( local_sockets );
-	assert( data_fragment_size );
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+	packet_dimension_ref packet_dimension;
+	packet_t packet;
+	size_t total_length;
+	tcp_header_ref header;
+	int index;
+	int result;
+
+	assert(local_sockets);
+	assert(data_fragment_size);
 
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
 	// get the socket specific data
-	if( ! socket->specific_data ) return NO_DATA;
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
+	if(! socket->specific_data){
+		return NO_DATA;
+	}
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
 
 	// check state
-	if(( socket_data->state != TCP_SOCKET_ESTABLISHED ) && ( socket_data->state != TCP_SOCKET_CLOSE_WAIT )){
+	if((socket_data->state != TCP_SOCKET_ESTABLISHED) && (socket_data->state != TCP_SOCKET_CLOSE_WAIT)){
 		return ENOTCONN;
 	}
 
-	ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension ));
-
-	* data_fragment_size = (( packet_dimension->content < socket_data->data_fragment_size ) ? packet_dimension->content : socket_data->data_fragment_size );
-
-	for( index = 0; index < fragments; ++ index ){
+	ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension));
+
+	*data_fragment_size = ((packet_dimension->content < socket_data->data_fragment_size) ? packet_dimension->content : socket_data->data_fragment_size);
+
+	for(index = 0; index < fragments; ++ index){
 		// read the data fragment
-		result = tl_socket_read_packet_data( tcp_globals.net_phone, & packet, TCP_HEADER_SIZE, packet_dimension, socket_data->addr, socket_data->addrlen );
-		if( result < 0 ) return result;
-		total_length = ( size_t ) result;
+		result = tl_socket_read_packet_data(tcp_globals.net_phone, &packet, TCP_HEADER_SIZE, packet_dimension, socket_data->addr, socket_data->addrlen);
+		if(result < 0){
+			return result;
+		}
+		total_length = (size_t) result;
 		// prefix the tcp header
-		header = PACKET_PREFIX( packet, tcp_header_t );
-		if( ! header ){
-			return tcp_release_and_return( packet, ENOMEM );
-		}
-		tcp_prepare_operation_header( socket, socket_data, header, 0, 0 );
-		ERROR_PROPAGATE( tcp_queue_packet( socket, socket_data, packet, 0 ));
+		header = PACKET_PREFIX(packet, tcp_header_t);
+		if(! header){
+			return tcp_release_and_return(packet, ENOMEM);
+		}
+		tcp_prepare_operation_header(socket, socket_data, header, 0, 0);
+		ERROR_PROPAGATE(tcp_queue_packet(socket, socket_data, packet, 0));
 	}
 
 	// flush packets
-	packet = tcp_get_packets_to_send( socket, socket_data );
-	fibril_rwlock_write_unlock( socket_data->local_lock );
-	fibril_rwlock_read_unlock( & tcp_globals.lock );
-	if( packet ){
+	packet = tcp_get_packets_to_send(socket, socket_data);
+	fibril_rwlock_write_unlock(socket_data->local_lock);
+	fibril_rwlock_read_unlock(&tcp_globals.lock);
+	if(packet){
 		// send the packet
-		tcp_send_packets( socket_data->device_id, packet );
+		tcp_send_packets(socket_data->device_id, packet);
 	}
 
@@ -1789,20 +1815,22 @@
 }
 
-int tcp_close_message( socket_cores_ref local_sockets, int socket_id ){
+int tcp_close_message(socket_cores_ref local_sockets, int socket_id){
 	ERROR_DECLARE;
 
-	socket_core_ref			socket;
-	tcp_socket_data_ref		socket_data;
-	packet_t				packet;
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+	packet_t packet;
 
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
 	// get the socket specific data
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-	assert( socket_data );
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
+	assert(socket_data);
 
 	// check state
-	switch( socket_data->state ){
+	switch(socket_data->state){
 		case TCP_SOCKET_ESTABLISHED:
 			socket_data->state = TCP_SOCKET_FIN_WAIT_1;
@@ -1814,7 +1842,7 @@
 		default:
 			// just destroy
-			if( ! ERROR_OCCURRED( socket_destroy( tcp_globals.net_phone, socket_id, local_sockets, & tcp_globals.sockets, tcp_free_socket_data ))){
-				fibril_rwlock_write_unlock( socket_data->local_lock );
-				fibril_rwlock_write_unlock( & tcp_globals.lock );
+			if(! ERROR_OCCURRED(socket_destroy(tcp_globals.net_phone, socket_id, local_sockets, &tcp_globals.sockets, tcp_free_socket_data))){
+				fibril_rwlock_write_unlock(socket_data->local_lock);
+				fibril_rwlock_write_unlock(&tcp_globals.lock);
 			}
 			return ERROR_CODE;
@@ -1824,109 +1852,117 @@
 
 	// create the notification packet
-	ERROR_PROPAGATE( tcp_create_notification_packet( & packet, socket, socket_data, 0, 1 ));
+	ERROR_PROPAGATE(tcp_create_notification_packet(&packet, socket, socket_data, 0, 1));
 
 	// send the packet
-	ERROR_PROPAGATE( tcp_queue_packet( socket, socket_data, packet, 1 ));
+	ERROR_PROPAGATE(tcp_queue_packet(socket, socket_data, packet, 1));
 
 	// flush packets
-	packet = tcp_get_packets_to_send( socket, socket_data );
-	fibril_rwlock_write_unlock( socket_data->local_lock );
-	fibril_rwlock_write_unlock( & tcp_globals.lock );
-	if( packet ){
+	packet = tcp_get_packets_to_send(socket, socket_data);
+	fibril_rwlock_write_unlock(socket_data->local_lock);
+	fibril_rwlock_write_unlock(&tcp_globals.lock);
+	if(packet){
 		// send the packet
-		tcp_send_packets( socket_data->device_id, packet );
+		tcp_send_packets(socket_data->device_id, packet);
 	}
 	return EOK;
 }
 
-int tcp_create_notification_packet( packet_t * packet, socket_core_ref socket, tcp_socket_data_ref socket_data, int synchronize, int finalize ){
+int tcp_create_notification_packet(packet_t * packet, socket_core_ref socket, tcp_socket_data_ref socket_data, int synchronize, int finalize){
 	ERROR_DECLARE;
 
-	packet_dimension_ref	packet_dimension;
-	tcp_header_ref			header;
-
-	assert( packet );
+	packet_dimension_ref packet_dimension;
+	tcp_header_ref header;
+
+	assert(packet);
 
 	// get the device packet dimension
-	ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension ));
+	ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension));
 	// get a new packet
-	* packet = packet_get_4( tcp_globals.net_phone, TCP_HEADER_SIZE, packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix );
-	if( ! * packet ) return ENOMEM;
+	*packet = packet_get_4(tcp_globals.net_phone, TCP_HEADER_SIZE, packet_dimension->addr_len, packet_dimension->prefix, packet_dimension->suffix);
+	if(! * packet){
+		return ENOMEM;
+	}
 	// allocate space in the packet
-	header = PACKET_SUFFIX( * packet, tcp_header_t );
-	if( ! header ){
-		tcp_release_and_return( * packet, ENOMEM );
-	}
-
-	tcp_prepare_operation_header( socket, socket_data, header, synchronize, finalize );
+	header = PACKET_SUFFIX(*packet, tcp_header_t);
+	if(! header){
+		tcp_release_and_return(*packet, ENOMEM);
+	}
+
+	tcp_prepare_operation_header(socket, socket_data, header, synchronize, finalize);
 	return EOK;
 }
 
-int tcp_accept_message( socket_cores_ref local_sockets, int socket_id, int new_socket_id, size_t * data_fragment_size, size_t * addrlen ){
+int tcp_accept_message(socket_cores_ref local_sockets, int socket_id, int new_socket_id, size_t * data_fragment_size, size_t * addrlen){
 	ERROR_DECLARE;
 
-	socket_core_ref		accepted;
-	socket_core_ref		socket;
-	tcp_socket_data_ref	socket_data;
-	packet_dimension_ref	packet_dimension;
-
-	assert( local_sockets );
-	assert( data_fragment_size );
-	assert( addrlen );
+	socket_core_ref accepted;
+	socket_core_ref socket;
+	tcp_socket_data_ref socket_data;
+	packet_dimension_ref packet_dimension;
+
+	assert(local_sockets);
+	assert(data_fragment_size);
+	assert(addrlen);
 
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
 	// get the socket specific data
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-	assert( socket_data );
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
+	assert(socket_data);
 
 	// check state
-	if( socket_data->state != TCP_SOCKET_LISTEN ){
+	if(socket_data->state != TCP_SOCKET_LISTEN){
 		return EINVAL;
 	}
 
 	do{
-		socket_id = dyn_fifo_value( & socket->accepted );
-		if( socket_id < 0 ) return ENOTSOCK;
+		socket_id = dyn_fifo_value(&socket->accepted);
+		if(socket_id < 0){
+			return ENOTSOCK;
+		}
 		socket_id *= -1;
 
-		accepted = socket_cores_find( local_sockets, socket_id );
-		if( ! accepted ) return ENOTSOCK;
+		accepted = socket_cores_find(local_sockets, socket_id);
+		if(! accepted){
+			return ENOTSOCK;
+		}
 		// get the socket specific data
-		socket_data = ( tcp_socket_data_ref ) accepted->specific_data;
-		assert( socket_data );
+		socket_data = (tcp_socket_data_ref) accepted->specific_data;
+		assert(socket_data);
 		// TODO can it be in another state?
-		if( socket_data->state == TCP_SOCKET_ESTABLISHED ){
-			ERROR_PROPAGATE( data_reply( socket_data->addr, socket_data->addrlen ));
-			ERROR_PROPAGATE( tl_get_ip_packet_dimension( tcp_globals.ip_phone, & tcp_globals.dimensions, socket_data->device_id, & packet_dimension ));
-			* addrlen = socket_data->addrlen;
-			* data_fragment_size = (( packet_dimension->content < socket_data->data_fragment_size ) ? packet_dimension->content : socket_data->data_fragment_size );
-			if( new_socket_id > 0 ){
-				ERROR_PROPAGATE( socket_cores_update( local_sockets, accepted->socket_id, new_socket_id ));
+		if(socket_data->state == TCP_SOCKET_ESTABLISHED){
+			ERROR_PROPAGATE(data_reply(socket_data->addr, socket_data->addrlen));
+			ERROR_PROPAGATE(tl_get_ip_packet_dimension(tcp_globals.ip_phone, &tcp_globals.dimensions, socket_data->device_id, &packet_dimension));
+			*addrlen = socket_data->addrlen;
+			*data_fragment_size = ((packet_dimension->content < socket_data->data_fragment_size) ? packet_dimension->content : socket_data->data_fragment_size);
+			if(new_socket_id > 0){
+				ERROR_PROPAGATE(socket_cores_update(local_sockets, accepted->socket_id, new_socket_id));
 				accepted->socket_id = new_socket_id;
 			}
 		}
-		dyn_fifo_pop( & socket->accepted );
-	}while( socket_data->state != TCP_SOCKET_ESTABLISHED );
-	printf("ret accept %d\n", accepted->socket_id );
+		dyn_fifo_pop(&socket->accepted);
+	}while(socket_data->state != TCP_SOCKET_ESTABLISHED);
+	printf("ret accept %d\n", accepted->socket_id);
 	return accepted->socket_id;
 }
 
-void tcp_free_socket_data( socket_core_ref socket ){
-	tcp_socket_data_ref		socket_data;
-
-	assert( socket );
-
-	printf( "destroy_socket %d\n", socket->socket_id );
+void tcp_free_socket_data(socket_core_ref socket){
+	tcp_socket_data_ref socket_data;
+
+	assert(socket);
+
+	printf("destroy_socket %d\n", socket->socket_id);
 
 	// get the socket specific data
-	socket_data = ( tcp_socket_data_ref ) socket->specific_data;
-	assert( socket_data );
+	socket_data = (tcp_socket_data_ref) socket->specific_data;
+	assert(socket_data);
 	//free the pseudo header
-	if( socket_data->pseudo_header ){
-		if( socket_data->headerlen ){
+	if(socket_data->pseudo_header){
+		if(socket_data->headerlen){
 			printf("d pseudo\n");
-			free( socket_data->pseudo_header );
+			free(socket_data->pseudo_header);
 			socket_data->headerlen = 0;
 		}
@@ -1935,8 +1971,8 @@
 	socket_data->headerlen = 0;
 	// free the address
-	if( socket_data->addr ){
-		if( socket_data->addrlen ){
+	if(socket_data->addr){
+		if(socket_data->addrlen){
 			printf("d addr\n");
-			free( socket_data->addr );
+			free(socket_data->addr);
 			socket_data->addrlen = 0;
 		}
@@ -1946,6 +1982,6 @@
 }
 
-int	tcp_release_and_return( packet_t packet, int result ){
-	pq_release( tcp_globals.net_phone, packet_get_id( packet ));
+int tcp_release_and_return(packet_t packet, int result){
+	pq_release(tcp_globals.net_phone, packet_get_id(packet));
 	return result;
 }
Index: uspace/srv/net/tl/tcp/tcp.h
===================================================================
--- uspace/srv/net/tl/tcp/tcp.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tcp/tcp.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -150,11 +150,11 @@
 	/** Operation result.
 	 */
-	int					result;
+	int result;
 	/** Safety lock.
 	 */
-	fibril_mutex_t		mutex;
+	fibril_mutex_t mutex;
 	/** Operation result signaling.
 	 */
-	fibril_condvar_t	condvar;
+	fibril_condvar_t condvar;
 };
 
@@ -164,16 +164,16 @@
 	/** TCP socket state.
 	 */
-	tcp_socket_state_t	state;
+	tcp_socket_state_t state;
 	/** Data fragment size.
 	 *  Sending optimalization.
 	 */
-	size_t			data_fragment_size;
+	size_t data_fragment_size;
 	/** Device identifier.
 	 */
-	device_id_t		device_id;
+	device_id_t device_id;
 	/** Listening backlog.
 	 *  The maximal number of connected but not yet accepted sockets.
 	 */
-	int				backlog;
+	int backlog;
 //	/** Segment size.
 //	 */
@@ -182,41 +182,41 @@
 	 *  Set if this socket is an accepted one.
 	 */
-	int				listening_socket_id;
+	int listening_socket_id;
 	/** Treshold size in bytes.
 	 */
-	size_t			treshold;
+	size_t treshold;
 	/** Window size in bytes.
 	 */
-	size_t			window;
+	size_t window;
 	/** Acknowledgement timeout.
 	 */
-	suseconds_t		timeout;
+	suseconds_t timeout;
 	/** Last acknowledged byte.
 	 */
-	uint32_t		acknowledged;
+	uint32_t acknowledged;
 	/** Next incoming sequence number.
 	 */
-	uint32_t		next_incoming;
+	uint32_t next_incoming;
 	/** Incoming FIN.
 	 */
-	uint32_t		fin_incoming;
+	uint32_t fin_incoming;
 	/** Next outgoing sequence number.
 	 */
-	uint32_t		next_outgoing;
+	uint32_t next_outgoing;
 	/** Last outgoing sequence number.
 	 */
-	uint32_t		last_outgoing;
+	uint32_t last_outgoing;
 	/** Outgoing FIN.
 	 */
-	uint32_t		fin_outgoing;
+	uint32_t fin_outgoing;
 	/** Expected sequence number by the remote host.
 	 *  The sequence number the other host expects.
 	 *  The notification is sent only upon a packet reecival.
 	 */
-	uint32_t		expected;
+	uint32_t expected;
 	/** Expected sequence number counter.
 	 *  Counts the number of received notifications for the same sequence number.
 	 */
-	int				expected_count;
+	int expected_count;
 	/** Incoming packet queue.
 	 *  Packets are buffered until received in the right order.
@@ -225,5 +225,5 @@
 	 *  Packets metric is set as their data length.
 	 */
-	packet_t		incoming;
+	packet_t incoming;
 	/** Outgoing packet queue.
 	 *  Packets are buffered until acknowledged by the remote host in the right order.
@@ -232,23 +232,23 @@
 	 *  Packets metric is set as their data length.
 	 */
-	packet_t		outgoing;
+	packet_t outgoing;
 	/** IP pseudo header.
 	 */
-	ip_pseudo_header_ref	pseudo_header;
+	ip_pseudo_header_ref pseudo_header;
 	/** IP pseudo header length.
 	 */
-	size_t			headerlen;
+	size_t headerlen;
 	/** Remote host address.
 	 */
-	struct sockaddr *	addr;
+	struct sockaddr * addr;
 	/** Remote host address length.
 	 */
-	socklen_t			addrlen;
+	socklen_t addrlen;
 	/** Remote host port.
 	 */
-	uint16_t			dest_port;
+	uint16_t dest_port;
 	/** Parent local sockets.
 	 */
-	socket_cores_ref	local_sockets;
+	socket_cores_ref local_sockets;
 	/** Local sockets safety lock.
 	 *  May be locked for writing while holding the global lock for reading when changing the local sockets only.
@@ -258,12 +258,12 @@
 	 *  @see tcp_globals:lock
 	 */
-	fibril_rwlock_t *	local_lock;
+	fibril_rwlock_t * local_lock;
 	/** Pending operation data.
 	 */
-	tcp_operation_t		operation;
+	tcp_operation_t operation;
 	/** Timeouts in a row counter.
 	 *  If TCP_MAX_TIMEOUTS is reached, the connection is lost.
 	 */
-	int					timeout_count;
+	int timeout_count;
 };
 
@@ -273,24 +273,24 @@
 	/** Networking module phone.
 	 */
-	int				net_phone;
+	int net_phone;
 	/** IP module phone.
 	 */
-	int				ip_phone;
+	int ip_phone;
 	/** ICMP module phone.
 	 */
-	int				icmp_phone;
+	int icmp_phone;
 	/** Last used free port.
 	 */
-	int				last_used_port;
+	int last_used_port;
 	/** Active sockets.
 	 */
-	socket_ports_t	sockets;
+	socket_ports_t sockets;
 	/** Device packet dimensions.
 	 */
-	packet_dimensions_t	dimensions;
+	packet_dimensions_t dimensions;
 	/** Safety lock.
 	 *  Write lock is used only for adding or removing socket ports.
 	 */
-	fibril_rwlock_t	lock;
+	fibril_rwlock_t lock;
 };
 
Index: uspace/srv/net/tl/tcp/tcp_header.h
===================================================================
--- uspace/srv/net/tl/tcp/tcp_header.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tcp/tcp_header.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -43,15 +43,15 @@
 /** TCP header size in bytes.
  */
-#define TCP_HEADER_SIZE			sizeof( tcp_header_t )
+#define TCP_HEADER_SIZE			sizeof(tcp_header_t)
 
 /** Returns the actual TCP header length in bytes.
  *  @param[in] header The TCP packet header.
  */
-#define TCP_HEADER_LENGTH( header )		(( header )->header_length * 4u )
+#define TCP_HEADER_LENGTH(header)		((header)->header_length * 4u)
 
 /** Returns the TCP header length.
  *  @param[in] length The TCP header length in bytes.
  */
-#define TCP_COMPUTE_HEADER_LENGTH( length )		(( uint8_t ) (( length ) / 4u ))
+#define TCP_COMPUTE_HEADER_LENGTH(length)		((uint8_t) ((length) / 4u))
 
 /** Type definition of the transmission datagram header.
@@ -90,17 +90,17 @@
 	/** The source port number.
 	 */
-	uint16_t	source_port;
+	uint16_t source_port;
 	/** The destination port number.
 	 */
-	uint16_t	destination_port;
+	uint16_t destination_port;
 	/** The sequence number of the first data octet in this segment (except when SYN is present).
 	 *  If SYN is present the sequence number is the initial sequence number (ISN) and the first data octet is ISN+1.
 	 */
-	uint32_t	sequence_number;
+	uint32_t sequence_number;
 	/** If the ACK control bit is set this field contains the value of the next sequence number the sender of the segment is expecting to receive.
 	 *  Once a~connection is established this is always sent.
 	 *  @see acknowledge
 	 */
-	uint32_t	acknowledgement_number;
+	uint32_t acknowledgement_number;
 #ifdef ARCH_IS_BIG_ENDIAN
 	/** The number of 32~bit words in the TCP Header.
@@ -108,19 +108,19 @@
 	 *  The TCP header (even one including options) is an integral number of 32~bits long.
 	 */
-	uint8_t	header_length:4;
+	uint8_t header_length:4;
 	/** Four bits reserved for future use.
 	 *  Must be zero.
 	 */
-	uint8_t	reserved1:4;
+	uint8_t reserved1:4;
 #else
 	/** Four bits reserved for future use.
 	 *  Must be zero.
 	 */
-	uint8_t	reserved1:4;
+	uint8_t reserved1:4;
 	/** The number of 32~bit words in the TCP Header.
 	 *  This indicates where the data begins.
 	 *  The TCP header (even one including options) is an integral number of 32~bits long.
 	 */
-	uint8_t	header_length:4;
+	uint8_t header_length:4;
 #endif
 #ifdef ARCH_IS_BIG_ENDIAN
@@ -128,55 +128,55 @@
 	 *  Must be zero.
 	 */
-	uint8_t	reserved2:2;
+	uint8_t reserved2:2;
 	/** Urgent Pointer field significant.
 	 *  @see tcp_header:urgent_pointer
 	 */
-	uint8_t	urgent:1;
+	uint8_t urgent:1;
 	/** Acknowledgment field significant
 	 *  @see tcp_header:acknowledgement_number
 	 */
-	uint8_t	acknowledge:1;
+	uint8_t acknowledge:1;
 	/** Push function.
 	 */
-	uint8_t	push:1;
+	uint8_t push:1;
 	/** Reset the connection.
 	 */
-	uint8_t	reset:1;
+	uint8_t reset:1;
 	/** Synchronize the sequence numbers.
 	 */
-	uint8_t	synchronize:1;
+	uint8_t synchronize:1;
 	/** No more data from the sender.
 	 */
-	uint8_t	finalize:1;
+	uint8_t finalize:1;
 #else
 	/** No more data from the sender.
 	 */
-	uint8_t	finalize:1;
+	uint8_t finalize:1;
 	/** Synchronize the sequence numbers.
 	 */
-	uint8_t	synchronize:1;
+	uint8_t synchronize:1;
 	/** Reset the connection.
 	 */
-	uint8_t	reset:1;
+	uint8_t reset:1;
 	/** Push function.
 	 */
-	uint8_t	push:1;
+	uint8_t push:1;
 	/** Acknowledgment field significant.
 	 *  @see tcp_header:acknowledgement_number
 	 */
-	uint8_t	acknowledge:1;
+	uint8_t acknowledge:1;
 	/** Urgent Pointer field significant.
 	 *  @see tcp_header:urgent_pointer
 	 */
-	uint8_t	urgent:1;
+	uint8_t urgent:1;
 	/** Two bits reserved for future use.
 	 *  Must be zero.
 	 */
-	uint8_t	reserved2:2;
+	uint8_t reserved2:2;
 #endif
 	/** The number of data octets beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept.
 	 *  @see tcp_header:acknowledge
 	 */
-	uint16_t	window;
+	uint16_t window;
 	/** The checksum field is the 16~bit one's complement of the one's complement sum of all 16~bit words in the header and text.
 	 *  If a~segment contains an odd number of header and text octets to be checksummed, the last octet is padded on the right with zeros to form a~16~bit word for checksum purposes.
@@ -188,5 +188,5 @@
 	 *  If the computed checksum is zero, it is transmitted as all ones (the equivalent in one's complement arithmetic).
 	 */
-	uint16_t	checksum;
+	uint16_t checksum;
 	/** This field communicates the current value of the urgent pointer as a~positive offset from the sequence number in this segment.
 	 *  The urgent pointer points to the sequence number of the octet following the urgent data.
@@ -194,5 +194,5 @@
 	 *  @see tcp_header:urgent
 	 */
-	uint16_t	urgent_pointer;
+	uint16_t urgent_pointer;
 } __attribute__ ((packed));
 
@@ -202,8 +202,8 @@
 	/** Option type.
 	 */
-	uint8_t		type;
+	uint8_t type;
 	/** Option length.
 	 */
-	uint8_t		length;
+	uint8_t length;
 };
 
@@ -215,8 +215,8 @@
 	 *  @see TCPOPT_MAX_SEGMENT_SIZE_LENGTH
 	 */
-	tcp_option_t	option;
+	tcp_option_t option;
 	/** Maximum segment size in bytes.
 	 */
-	uint16_t		max_segment_size;
+	uint16_t max_segment_size;
 } __attribute__ ((packed));
 
Index: uspace/srv/net/tl/tcp/tcp_module.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp_module.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tcp/tcp_module.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -63,5 +63,5 @@
  *  @see NAME
  */
-void	module_print_name( void );
+void module_print_name(void);
 
 /** Starts the TCP module.
@@ -72,5 +72,5 @@
  *  @returns Other error codes as defined for the REGISTER_ME() macro function.
  */
-int	module_start( async_client_conn_t client_connection );
+int module_start(async_client_conn_t client_connection);
 
 /** Processes the TCP message.
@@ -82,5 +82,5 @@
  *  @returns Other error codes as defined for the tcp_message() function.
  */
-int	module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
 
 /** TCP module global data.
@@ -88,18 +88,18 @@
 extern tcp_globals_t	tcp_globals;
 
-void module_print_name( void ){
-	printf( "%s", NAME );
+void module_print_name(void){
+	printf("%s", NAME);
 }
 
-int module_start( async_client_conn_t client_connection ){
+int module_start(async_client_conn_t client_connection){
 	ERROR_DECLARE;
 
-	ipcarg_t	phonehash;
+	ipcarg_t phonehash;
 
-	async_set_client_connection( client_connection );
-	tcp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
-	ERROR_PROPAGATE( pm_init());
-	if( ERROR_OCCURRED( tcp_initialize( client_connection ))
-	|| ERROR_OCCURRED( REGISTER_ME( SERVICE_TCP, & phonehash ))){
+	async_set_client_connection(client_connection);
+	tcp_globals.net_phone = net_connect_module(SERVICE_NETWORKING);
+	ERROR_PROPAGATE(pm_init());
+	if(ERROR_OCCURRED(tcp_initialize(client_connection))
+		|| ERROR_OCCURRED(REGISTER_ME(SERVICE_TCP, &phonehash))){
 		pm_destroy();
 		return ERROR_CODE;
@@ -112,6 +112,6 @@
 }
 
-int	module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
-	return tcp_message( callid, call, answer, answer_count );
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	return tcp_message(callid, call, answer, answer_count);
 }
 
Index: uspace/srv/net/tl/tcp/tcp_module.h
===================================================================
--- uspace/srv/net/tl/tcp/tcp_module.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tcp/tcp_module.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -47,5 +47,5 @@
  *  @returns ENOMEM if there is not enough memory left.
  */
-int	tcp_initialize( async_client_conn_t client_connection );
+int tcp_initialize(async_client_conn_t client_connection);
 
 /** Processes the TCP message.
@@ -59,5 +59,5 @@
  *  @see IS_NET_TCP_MESSAGE()
  */
-int	tcp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+int tcp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
 
 #endif
Index: uspace/srv/net/tl/tl_common.c
===================================================================
--- uspace/srv/net/tl/tl_common.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tl_common.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -55,21 +55,27 @@
 #include "tl_common.h"
 
-DEVICE_MAP_IMPLEMENT( packet_dimensions, packet_dimension_t );
-
-int tl_get_address_port( const struct sockaddr * addr, int addrlen, uint16_t * port ){
-	const struct sockaddr_in *	address_in;
-	const struct sockaddr_in6 *	address_in6;
-
-	if(( addrlen <= 0 ) || (( size_t ) addrlen < sizeof( struct sockaddr ))) return EINVAL;
-	switch( addr->sa_family ){
+DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
+
+int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port){
+	const struct sockaddr_in * address_in;
+	const struct sockaddr_in6 * address_in6;
+
+	if((addrlen <= 0) || ((size_t) addrlen < sizeof(struct sockaddr))){
+		return EINVAL;
+	}
+	switch(addr->sa_family){
 		case AF_INET:
-			if( addrlen != sizeof( struct sockaddr_in )) return EINVAL;
-			address_in = ( struct sockaddr_in * ) addr;
-			* port = ntohs( address_in->sin_port );
+			if(addrlen != sizeof(struct sockaddr_in)){
+				return EINVAL;
+			}
+			address_in = (struct sockaddr_in *) addr;
+			*port = ntohs(address_in->sin_port);
 			break;
 		case AF_INET6:
-			if( addrlen != sizeof( struct sockaddr_in6 )) return EINVAL;
-			address_in6 = ( struct sockaddr_in6 * ) addr;
-			* port = ntohs( address_in6->sin6_port );
+			if(addrlen != sizeof(struct sockaddr_in6)){
+				return EINVAL;
+			}
+			address_in6 = (struct sockaddr_in6 *) addr;
+			*port = ntohs(address_in6->sin6_port);
 			break;
 		default:
@@ -79,21 +85,25 @@
 }
 
-int tl_get_ip_packet_dimension( int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension ){
+int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension){
 	ERROR_DECLARE;
 
-	if( ! packet_dimension ) return EBADMEM;
-
-	* packet_dimension = packet_dimensions_find( packet_dimensions, device_id );
-	if( ! * packet_dimension ){
+	if(! packet_dimension){
+		return EBADMEM;
+	}
+
+	*packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
+	if(! * packet_dimension){
 		// ask for and remember them if not found
-		* packet_dimension = malloc( sizeof( ** packet_dimension ));
-		if( ! * packet_dimension ) return ENOMEM;
-		if( ERROR_OCCURRED( ip_packet_size_req( ip_phone, device_id, * packet_dimension ))){
-			free( * packet_dimension );
+		*packet_dimension = malloc(sizeof(** packet_dimension));
+		if(! * packet_dimension){
+			return ENOMEM;
+		}
+		if(ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, * packet_dimension))){
+			free(*packet_dimension);
 			return ERROR_CODE;
 		}
-		ERROR_CODE = packet_dimensions_add( packet_dimensions, device_id, * packet_dimension );
-		if( ERROR_CODE < 0 ){
-			free( * packet_dimension );
+		ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, * packet_dimension);
+		if(ERROR_CODE < 0){
+			free(*packet_dimension);
 			return ERROR_CODE;
 		}
@@ -102,17 +112,19 @@
 }
 
-int tl_update_ip_packet_dimension( packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content ){
-	packet_dimension_ref	packet_dimension;
-
-	packet_dimension = packet_dimensions_find( packet_dimensions, device_id );
-	if( ! packet_dimension ) return ENOENT;
+int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content){
+	packet_dimension_ref packet_dimension;
+
+	packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
+	if(! packet_dimension){
+		return ENOENT;
+	}
 	packet_dimension->content = content;
-	if( device_id != DEVICE_INVALID_ID ){
-		packet_dimension = packet_dimensions_find( packet_dimensions, DEVICE_INVALID_ID );
-		if( packet_dimension ){
-			if( packet_dimension->content >= content ){
+	if(device_id != DEVICE_INVALID_ID){
+		packet_dimension = packet_dimensions_find(packet_dimensions, DEVICE_INVALID_ID);
+		if(packet_dimension){
+			if(packet_dimension->content >= content){
 				packet_dimension->content = content;
 			}else{
-				packet_dimensions_exclude( packet_dimensions, DEVICE_INVALID_ID );
+				packet_dimensions_exclude(packet_dimensions, DEVICE_INVALID_ID);
 			}
 		}
@@ -121,22 +133,30 @@
 }
 
-int tl_set_address_port( struct sockaddr * addr, int addrlen, uint16_t port ){
-	struct sockaddr_in *	address_in;
-	struct sockaddr_in6 *	address_in6;
-	size_t					length;
-
-	if( addrlen < 0 ) return EINVAL;
-	length = ( size_t ) addrlen;
-	if( length < sizeof( struct sockaddr )) return EINVAL;
-	switch( addr->sa_family ){
+int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port){
+	struct sockaddr_in * address_in;
+	struct sockaddr_in6 * address_in6;
+	size_t length;
+
+	if(addrlen < 0){
+		return EINVAL;
+	}
+	length = (size_t) addrlen;
+	if(length < sizeof(struct sockaddr)){
+		return EINVAL;
+	}
+	switch(addr->sa_family){
 		case AF_INET:
-			if( length != sizeof( struct sockaddr_in )) return EINVAL;
-			address_in = ( struct sockaddr_in * ) addr;
-			address_in->sin_port = htons( port );
+			if(length != sizeof(struct sockaddr_in)){
+				return EINVAL;
+			}
+			address_in = (struct sockaddr_in *) addr;
+			address_in->sin_port = htons(port);
 			return EOK;
 		case AF_INET6:
-			if( length != sizeof( struct sockaddr_in6 )) return EINVAL;
-			address_in6 = ( struct sockaddr_in6 * ) addr;
-			address_in6->sin6_port = htons( port );
+			if(length != sizeof(struct sockaddr_in6)){
+				return EINVAL;
+			}
+			address_in6 = (struct sockaddr_in6 *) addr;
+			address_in6->sin6_port = htons(port);
 			return EOK;
 		default:
@@ -145,54 +165,60 @@
 }
 
-int tl_prepare_icmp_packet( int packet_phone, int icmp_phone, packet_t packet, services_t error ){
-	packet_t	next;
-	uint8_t *	src;
-	int			length;
+int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error){
+	packet_t next;
+	uint8_t * src;
+	int length;
 
 	// detach the first packet and release the others
-	next = pq_detach( packet );
-	if( next ){
-		pq_release( packet_phone, packet_get_id( next ));
-	}
-	length = packet_get_addr( packet, & src, NULL );
-	if(( length > 0 )
-	&& ( ! error )
-	&& ( icmp_phone >= 0 )
+	next = pq_detach(packet);
+	if(next){
+		pq_release(packet_phone, packet_get_id(next));
+	}
+	length = packet_get_addr(packet, &src, NULL);
+	if((length > 0)
+		&& (! error)
+		&& (icmp_phone >= 0)
 	// set both addresses to the source one (avoids the source address deletion before setting the destination one)
-	&& ( packet_set_addr( packet, src, src, ( size_t ) length ) == EOK )){
+		&& (packet_set_addr(packet, src, src, (size_t) length) == EOK)){
 		return EOK;
 	}else{
-		pq_release( packet_phone, packet_get_id( packet ));
+		pq_release(packet_phone, packet_get_id(packet));
 	}
 	return ENOENT;
 }
 
-int tl_socket_read_packet_data( int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen ){
+int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen){
 	ERROR_DECLARE;
 
-	ipc_callid_t	callid;
-	size_t			length;
-	void *			data;
-
-	if( ! dimension ) return EINVAL;
+	ipc_callid_t callid;
+	size_t length;
+	void * data;
+
+	if(! dimension){
+		return EINVAL;
+	}
 	// get the data length
-	if( ! async_data_write_receive( & callid, & length )) return EINVAL;
+	if(! async_data_write_receive(&callid, &length)){
+		return EINVAL;
+	}
 	// get a new packet
-	* packet = packet_get_4( packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix );
-	if( ! packet ) return ENOMEM;
+	*packet = packet_get_4(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
+	if(! packet){
+		return ENOMEM;
+	}
 	// allocate space in the packet
-	data = packet_suffix( * packet, length );
-	if( ! data ){
-		pq_release( packet_phone, packet_get_id( * packet ));
+	data = packet_suffix(*packet, length);
+	if(! data){
+		pq_release(packet_phone, packet_get_id(*packet));
 		return ENOMEM;
 	}
 	// read the data into the packet
-	if( ERROR_OCCURRED( async_data_write_finalize( callid, data, length ))
+	if(ERROR_OCCURRED(async_data_write_finalize(callid, data, length))
 	// set the packet destination address
-	|| ERROR_OCCURRED( packet_set_addr( * packet, NULL, ( uint8_t * ) addr, addrlen ))){
-		pq_release( packet_phone, packet_get_id( * packet ));
+		|| ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){
+		pq_release(packet_phone, packet_get_id(*packet));
 		return ERROR_CODE;
 	}
-	return ( int ) length;
+	return (int) length;
 }
 
Index: uspace/srv/net/tl/tl_common.h
===================================================================
--- uspace/srv/net/tl/tl_common.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/tl_common.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -48,5 +48,5 @@
  *  @see device.h
  */
-DEVICE_MAP_DECLARE( packet_dimensions, packet_dimension_t );
+DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t);
 
 /** Gets the address port.
@@ -59,5 +59,5 @@
  *  @returns EAFNOSUPPORT if the address family is not supported.
  */
-int	tl_get_address_port( const struct sockaddr * addr, int addrlen, uint16_t * port );
+int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port);
 
 /** Gets IP packet dimensions.
@@ -74,5 +74,5 @@
  *  @returns Other codes as defined for the ip_packet_size_req() function.
  */
-int	tl_get_ip_packet_dimension( int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension );
+int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension);
 
 /** Updates IP device packet dimensions cache.
@@ -83,5 +83,5 @@
  *  @returns ENOENT if the packet dimension is not cached.
  */
-int	tl_update_ip_packet_dimension( packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content );
+int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content);
 
 /** Sets the address port.
@@ -94,5 +94,5 @@
  *  @returns EAFNOSUPPORT if the address family is not supported.
  */
-int	tl_set_address_port( struct sockaddr * addr, int addrlen, uint16_t port );
+int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port);
 
 /** Prepares the packet for ICMP error notification.
@@ -106,5 +106,5 @@
  *  @returns ENOENT if no packet may be sent.
  */
-int	tl_prepare_icmp_packet( int packet_phone, int icmp_phone, packet_t packet, services_t error );
+int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error);
 
 /** Receives data from the socket into a packet.
@@ -120,5 +120,5 @@
  *  @returns Other error codes as defined for the async_data_read_finalize() function.
  */
-int	tl_socket_read_packet_data( int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen );
+int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen);
 
 #endif
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/udp/udp.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -104,5 +104,5 @@
  *  @returns Other error codes as defined for the udp_process_packet() function.
  */
-int	udp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error );
+int udp_received_msg(device_id_t device_id, packet_t packet, services_t receiver, services_t error);
 
 /** Processes the received UDP packet queue.
@@ -121,5 +121,5 @@
  *  @returns Other error codes as defined for the ip_client_process_packet() function.
  */
-int udp_process_packet( device_id_t device_id, packet_t packet, services_t error );
+int udp_process_packet(device_id_t device_id, packet_t packet, services_t error);
 
 /** Releases the packet and returns the result.
@@ -128,5 +128,5 @@
  *  @return The result parameter.
  */
-int	udp_release_and_return( packet_t packet, int result );
+int udp_release_and_return(packet_t packet, int result);
 
 /** @name Socket messages processing functions
@@ -141,5 +141,5 @@
  *  @see socket.h
  */
-int udp_process_client_messages( ipc_callid_t callid, ipc_call_t call );
+int udp_process_client_messages(ipc_callid_t callid, ipc_call_t call);
 
 /** Sends data from the socket to the remote address.
@@ -164,5 +164,5 @@
  *  @returns Other error codes as defined for the ip_send_msg() function.
  */
-int udp_sendto_message( socket_cores_ref local_sockets, int socket_id, const struct sockaddr * addr, socklen_t addrlen, int fragments, size_t * data_fragment_size, int flags );
+int udp_sendto_message(socket_cores_ref local_sockets, int socket_id, const struct sockaddr * addr, socklen_t addrlen, int fragments, size_t * data_fragment_size, int flags);
 
 /** Receives data to the socket.
@@ -181,5 +181,5 @@
  *  @returns Other error codes as defined for the data_reply() function.
  */
-int	udp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen );
+int udp_recvfrom_message(socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen);
 
 /*@}*/
@@ -189,54 +189,54 @@
 udp_globals_t	udp_globals;
 
-int udp_initialize( async_client_conn_t client_connection ){
+int udp_initialize(async_client_conn_t client_connection){
 	ERROR_DECLARE;
 
-	measured_string_t	names[] = {{ str_dup("UDP_CHECKSUM_COMPUTING"), 22 }, { str_dup("UDP_AUTOBINDING"), 15 }};
-	measured_string_ref	configuration;
-	size_t				count = sizeof( names ) / sizeof( measured_string_t );
-	char *				data;
-
-	fibril_rwlock_initialize( & udp_globals.lock );
-	fibril_rwlock_write_lock( & udp_globals.lock );
-	udp_globals.icmp_phone = icmp_connect_module( SERVICE_ICMP, ICMP_CONNECT_TIMEOUT );
-	udp_globals.ip_phone = ip_bind_service( SERVICE_IP, IPPROTO_UDP, SERVICE_UDP, client_connection, udp_received_msg );
-	if( udp_globals.ip_phone < 0 ){
+	measured_string_t names[] = {{str_dup("UDP_CHECKSUM_COMPUTING"), 22}, {str_dup("UDP_AUTOBINDING"), 15}};
+	measured_string_ref configuration;
+	size_t count = sizeof(names) / sizeof(measured_string_t);
+	char * data;
+
+	fibril_rwlock_initialize(&udp_globals.lock);
+	fibril_rwlock_write_lock(&udp_globals.lock);
+	udp_globals.icmp_phone = icmp_connect_module(SERVICE_ICMP, ICMP_CONNECT_TIMEOUT);
+	udp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_UDP, SERVICE_UDP, client_connection, udp_received_msg);
+	if(udp_globals.ip_phone < 0){
 		return udp_globals.ip_phone;
 	}
 	// read default packet dimensions
-	ERROR_PROPAGATE( ip_packet_size_req( udp_globals.ip_phone, -1, & udp_globals.packet_dimension ));
-	ERROR_PROPAGATE( socket_ports_initialize( & udp_globals.sockets ));
-	if( ERROR_OCCURRED( packet_dimensions_initialize( & udp_globals.dimensions ))){
-		socket_ports_destroy( & udp_globals.sockets );
+	ERROR_PROPAGATE(ip_packet_size_req(udp_globals.ip_phone, -1, &udp_globals.packet_dimension));
+	ERROR_PROPAGATE(socket_ports_initialize(&udp_globals.sockets));
+	if(ERROR_OCCURRED(packet_dimensions_initialize(&udp_globals.dimensions))){
+		socket_ports_destroy(&udp_globals.sockets);
 		return ERROR_CODE;
 	}
-	udp_globals.packet_dimension.prefix += sizeof( udp_header_t );
-	udp_globals.packet_dimension.content -= sizeof( udp_header_t );
+	udp_globals.packet_dimension.prefix += sizeof(udp_header_t);
+	udp_globals.packet_dimension.content -= sizeof(udp_header_t);
 	udp_globals.last_used_port = UDP_FREE_PORTS_START - 1;
 	// get configuration
 	udp_globals.checksum_computing = NET_DEFAULT_UDP_CHECKSUM_COMPUTING;
 	udp_globals.autobinding = NET_DEFAULT_UDP_AUTOBINDING;
-	configuration = & names[ 0 ];
-	ERROR_PROPAGATE( net_get_conf_req( udp_globals.net_phone, & configuration, count, & data ));
-	if( configuration ){
-		if( configuration[ 0 ].value ){
-			udp_globals.checksum_computing = ( configuration[ 0 ].value[ 0 ] == 'y' );
-		}
-		if( configuration[ 1 ].value ){
-			udp_globals.autobinding = ( configuration[ 1 ].value[ 0 ] == 'y' );
-		}
-		net_free_settings( configuration, data );
-	}
-	fibril_rwlock_write_unlock( & udp_globals.lock );
+	configuration = &names[0];
+	ERROR_PROPAGATE(net_get_conf_req(udp_globals.net_phone, &configuration, count, &data));
+	if(configuration){
+		if(configuration[0].value){
+			udp_globals.checksum_computing = (configuration[0].value[0] == 'y');
+		}
+		if(configuration[1].value){
+			udp_globals.autobinding = (configuration[1].value[0] == 'y');
+		}
+		net_free_settings(configuration, data);
+	}
+	fibril_rwlock_write_unlock(&udp_globals.lock);
 	return EOK;
 }
 
-int	udp_received_msg( device_id_t device_id, packet_t packet, services_t receiver, services_t error ){
-	int	result;
-
-	fibril_rwlock_write_lock( & udp_globals.lock );
-	result = udp_process_packet( device_id, packet, error );
-	if( result != EOK ){
-		fibril_rwlock_write_unlock( & udp_globals.lock );
+int udp_received_msg(device_id_t device_id, packet_t packet, services_t receiver, services_t error){
+	int result;
+
+	fibril_rwlock_write_lock(&udp_globals.lock);
+	result = udp_process_packet(device_id, packet, error);
+	if(result != EOK){
+		fibril_rwlock_write_unlock(&udp_globals.lock);
 	}
 
@@ -244,73 +244,73 @@
 }
 
-int udp_process_packet( device_id_t device_id, packet_t packet, services_t error ){
+int udp_process_packet(device_id_t device_id, packet_t packet, services_t error){
 	ERROR_DECLARE;
 
-	size_t			length;
-	size_t			offset;
-	int				result;
-	udp_header_ref	header;
-	socket_core_ref	socket;
-	packet_t		next_packet;
-	size_t			total_length;
-	uint32_t		checksum;
-	int				fragments;
-	packet_t		tmp_packet;
-	icmp_type_t		type;
-	icmp_code_t		code;
-	ip_pseudo_header_ref	ip_header;
-	struct sockaddr *		src;
-	struct sockaddr *		dest;
-	packet_dimension_ref	packet_dimension;
-
-	if( error ){
-		switch( error ){
+	size_t length;
+	size_t offset;
+	int result;
+	udp_header_ref header;
+	socket_core_ref socket;
+	packet_t next_packet;
+	size_t total_length;
+	uint32_t checksum;
+	int fragments;
+	packet_t tmp_packet;
+	icmp_type_t type;
+	icmp_code_t code;
+	ip_pseudo_header_ref ip_header;
+	struct sockaddr * src;
+	struct sockaddr * dest;
+	packet_dimension_ref packet_dimension;
+
+	if(error){
+		switch(error){
 			case SERVICE_ICMP:
 				// ignore error
-				// length = icmp_client_header_length( packet );
+				// length = icmp_client_header_length(packet);
 				// process error
-				result = icmp_client_process_packet( packet, & type, & code, NULL, NULL );
-				if( result < 0 ){
-					return udp_release_and_return( packet, result );
+				result = icmp_client_process_packet(packet, &type, &code, NULL, NULL);
+				if(result < 0){
+					return udp_release_and_return(packet, result);
 				}
-				length = ( size_t ) result;
-				if( ERROR_OCCURRED( packet_trim( packet, length, 0 ))){
-					return udp_release_and_return( packet, ERROR_CODE );
+				length = (size_t) result;
+				if(ERROR_OCCURRED(packet_trim(packet, length, 0))){
+					return udp_release_and_return(packet, ERROR_CODE);
 				}
 				break;
 			default:
-				return udp_release_and_return( packet, ENOTSUP );
+				return udp_release_and_return(packet, ENOTSUP);
 		}
 	}
 	// TODO process received ipopts?
-	result = ip_client_process_packet( packet, NULL, NULL, NULL, NULL, NULL );
-	if( result < 0 ){
-		return udp_release_and_return( packet, result );
-	}
-	offset = ( size_t ) result;
-
-	length = packet_get_data_length( packet );
-	if( length <= 0 ){
-		return udp_release_and_return( packet, EINVAL );
-	}
-	if( length < UDP_HEADER_SIZE + offset ){
-		return udp_release_and_return( packet, NO_DATA );
+	result = ip_client_process_packet(packet, NULL, NULL, NULL, NULL, NULL);
+	if(result < 0){
+		return udp_release_and_return(packet, result);
+	}
+	offset = (size_t) result;
+
+	length = packet_get_data_length(packet);
+	if(length <= 0){
+		return udp_release_and_return(packet, EINVAL);
+	}
+	if(length < UDP_HEADER_SIZE + offset){
+		return udp_release_and_return(packet, NO_DATA);
 	}
 
 	// trim all but UDP header
-	if( ERROR_OCCURRED( packet_trim( packet, offset, 0 ))){
-		return udp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(packet_trim(packet, offset, 0))){
+		return udp_release_and_return(packet, ERROR_CODE);
 	}
 
 	// get udp header
-	header = ( udp_header_ref ) packet_get_data( packet );
-	if( ! header ){
-		return udp_release_and_return( packet, NO_DATA );
+	header = (udp_header_ref) packet_get_data(packet);
+	if(! header){
+		return udp_release_and_return(packet, NO_DATA);
 	}
 	// find the destination socket
-	socket = socket_port_find( & udp_globals.sockets, ntohs( header->destination_port ), SOCKET_MAP_KEY_LISTENING, 0 );
-	if( ! socket ){
-		if( tl_prepare_icmp_packet( udp_globals.net_phone, udp_globals.icmp_phone, packet, error ) == EOK ){
-			icmp_destination_unreachable_msg( udp_globals.icmp_phone, ICMP_PORT_UNREACH, 0, packet );
+	socket = socket_port_find(&udp_globals.sockets, ntohs(header->destination_port), SOCKET_MAP_KEY_LISTENING, 0);
+	if(! socket){
+		if(tl_prepare_icmp_packet(udp_globals.net_phone, udp_globals.icmp_phone, packet, error) == EOK){
+			icmp_destination_unreachable_msg(udp_globals.icmp_phone, ICMP_PORT_UNREACH, 0, packet);
 		}
 		return EADDRNOTAVAIL;
@@ -320,17 +320,17 @@
 	next_packet = packet;
 	fragments = 0;
-	total_length = ntohs( header->total_length );
+	total_length = ntohs(header->total_length);
 	// compute header checksum if set
-	if( header->checksum && ( ! error )){
-		result = packet_get_addr( packet, ( uint8_t ** ) & src, ( uint8_t ** ) & dest );
-		if( result <= 0 ){
-			return udp_release_and_return( packet, result );
-		}
-		if( ERROR_OCCURRED( ip_client_get_pseudo_header( IPPROTO_UDP, src, result, dest, result, total_length, & ip_header, & length ))){
-			return udp_release_and_return( packet, ERROR_CODE );
+	if(header->checksum && (! error)){
+		result = packet_get_addr(packet, (uint8_t **) &src, (uint8_t **) &dest);
+		if(result <= 0){
+			return udp_release_and_return(packet, result);
+		}
+		if(ERROR_OCCURRED(ip_client_get_pseudo_header(IPPROTO_UDP, src, result, dest, result, total_length, &ip_header, &length))){
+			return udp_release_and_return(packet, ERROR_CODE);
 		}else{
-			checksum = compute_checksum( 0, ip_header, length );
+			checksum = compute_checksum(0, ip_header, length);
 			// the udp header checksum will be added with the first fragment later
-			free( ip_header );
+			free(ip_header);
 		}
 	}else{
@@ -341,21 +341,21 @@
 	do{
 		++ fragments;
-		length = packet_get_data_length( next_packet );
-		if( length <= 0 ){
-			return udp_release_and_return( packet, NO_DATA );
-		}
-		if( total_length < length ){
-			if( ERROR_OCCURRED( packet_trim( next_packet, 0, length - total_length ))){
-				return udp_release_and_return( packet, ERROR_CODE );
+		length = packet_get_data_length(next_packet);
+		if(length <= 0){
+			return udp_release_and_return(packet, NO_DATA);
+		}
+		if(total_length < length){
+			if(ERROR_OCCURRED(packet_trim(next_packet, 0, length - total_length))){
+				return udp_release_and_return(packet, ERROR_CODE);
 			}
 			// add partial checksum if set
-			if( header->checksum ){
-				checksum = compute_checksum( checksum, packet_get_data( packet ), packet_get_data_length( packet ));
+			if(header->checksum){
+				checksum = compute_checksum(checksum, packet_get_data(packet), packet_get_data_length(packet));
 			}
 			// relese the rest of the packet fragments
-			tmp_packet = pq_next( next_packet );
-			while( tmp_packet ){
-				next_packet = pq_detach( tmp_packet );
-				pq_release( udp_globals.net_phone, packet_get_id( tmp_packet ));
+			tmp_packet = pq_next(next_packet);
+			while(tmp_packet){
+				next_packet = pq_detach(tmp_packet);
+				pq_release(udp_globals.net_phone, packet_get_id(tmp_packet));
 				tmp_packet = next_packet;
 			}
@@ -365,15 +365,15 @@
 		total_length -= length;
 		// add partial checksum if set
-		if( header->checksum ){
-			checksum = compute_checksum( checksum, packet_get_data( packet ), packet_get_data_length( packet ));
-		}
-	}while(( next_packet = pq_next( next_packet )) && ( total_length > 0 ));
+		if(header->checksum){
+			checksum = compute_checksum(checksum, packet_get_data(packet), packet_get_data_length(packet));
+		}
+	}while((next_packet = pq_next(next_packet)) && (total_length > 0));
 
 	// check checksum
-	if( header->checksum ){
-		if( flip_checksum( compact_checksum( checksum )) != IP_CHECKSUM_ZERO ){
-			if( tl_prepare_icmp_packet( udp_globals.net_phone, udp_globals.icmp_phone, packet, error ) == EOK ){
+	if(header->checksum){
+		if(flip_checksum(compact_checksum(checksum)) != IP_CHECKSUM_ZERO){
+			if(tl_prepare_icmp_packet(udp_globals.net_phone, udp_globals.icmp_phone, packet, error) == EOK){
 				// checksum error ICMP
-				icmp_parameter_problem_msg( udp_globals.icmp_phone, ICMP_PARAM_POINTER, (( size_t ) (( void * ) & header->checksum )) - (( size_t ) (( void * ) header )), packet );
+				icmp_parameter_problem_msg(udp_globals.icmp_phone, ICMP_PARAM_POINTER, ((size_t) ((void *) &header->checksum)) - ((size_t) ((void *) header)), packet);
 			}
 			return EINVAL;
@@ -382,44 +382,44 @@
 
 	// queue the received packet
-	if( ERROR_OCCURRED( dyn_fifo_push( & socket->received, packet_get_id( packet ), SOCKET_MAX_RECEIVED_SIZE ))
-	|| ERROR_OCCURRED( tl_get_ip_packet_dimension( udp_globals.ip_phone, & udp_globals.dimensions, device_id, & packet_dimension ))){
-		return udp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(dyn_fifo_push(&socket->received, packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE))
+		|| ERROR_OCCURRED(tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, device_id, &packet_dimension))){
+		return udp_release_and_return(packet, ERROR_CODE);
 	}
 
 	// notify the destination socket
-	fibril_rwlock_write_unlock( & udp_globals.lock );
-	async_msg_5( socket->phone, NET_SOCKET_RECEIVED, ( ipcarg_t ) socket->socket_id, packet_dimension->content, 0, 0, ( ipcarg_t ) fragments );
+	fibril_rwlock_write_unlock(&udp_globals.lock);
+	async_msg_5(socket->phone, NET_SOCKET_RECEIVED, (ipcarg_t) socket->socket_id, packet_dimension->content, 0, 0, (ipcarg_t) fragments);
 	return EOK;
 }
 
-int udp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
+int udp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
 	ERROR_DECLARE;
 
-	packet_t	packet;
-
-	* answer_count = 0;
-	switch( IPC_GET_METHOD( * call )){
+	packet_t packet;
+
+	*answer_count = 0;
+	switch(IPC_GET_METHOD(*call)){
 		case NET_TL_RECEIVED:
-			if( ! ERROR_OCCURRED( packet_translate( udp_globals.net_phone, & packet, IPC_GET_PACKET( call )))){
-				ERROR_CODE = udp_received_msg( IPC_GET_DEVICE( call ), packet, SERVICE_UDP, IPC_GET_ERROR( call ));
+			if(! ERROR_OCCURRED(packet_translate(udp_globals.net_phone, &packet, IPC_GET_PACKET(call)))){
+				ERROR_CODE = udp_received_msg(IPC_GET_DEVICE(call), packet, SERVICE_UDP, IPC_GET_ERROR(call));
 			}
 			return ERROR_CODE;
 		case IPC_M_CONNECT_TO_ME:
-			return udp_process_client_messages( callid, * call );
+			return udp_process_client_messages(callid, * call);
 	}
 	return ENOTSUP;
 }
 
-int udp_process_client_messages( ipc_callid_t callid, ipc_call_t call ){
-	int						res;
-	bool					keep_on_going = true;
-	socket_cores_t			local_sockets;
-	int						app_phone = IPC_GET_PHONE( & call );
-	struct sockaddr *		addr;
-	size_t					addrlen;
-	fibril_rwlock_t			lock;
-	ipc_call_t				answer;
-	int						answer_count;
-	packet_dimension_ref	packet_dimension;
+int udp_process_client_messages(ipc_callid_t callid, ipc_call_t call){
+	int res;
+	bool keep_on_going = true;
+	socket_cores_t local_sockets;
+	int app_phone = IPC_GET_PHONE(&call);
+	struct sockaddr * addr;
+	size_t addrlen;
+	fibril_rwlock_t lock;
+	ipc_call_t answer;
+	int answer_count;
+	packet_dimension_ref packet_dimension;
 
 	/*
@@ -432,20 +432,20 @@
 	// The client connection is only in one fibril and therefore no additional locks are needed.
 
-	socket_cores_initialize( & local_sockets );
-	fibril_rwlock_initialize( & lock );
-
-	while( keep_on_going ){
+	socket_cores_initialize(&local_sockets);
+	fibril_rwlock_initialize(&lock);
+
+	while(keep_on_going){
 
 		// answer the call
-		answer_call( callid, res, & answer, answer_count );
+		answer_call(callid, res, &answer, answer_count);
 
 		// refresh data
-		refresh_answer( & answer, & answer_count );
+		refresh_answer(&answer, &answer_count);
 
 		// get the next call
-		callid = async_get_call( & call );
+		callid = async_get_call(&call);
 
 		// process the call
-		switch( IPC_GET_METHOD( call )){
+		switch(IPC_GET_METHOD(call)){
 			case IPC_M_PHONE_HUNGUP:
 				keep_on_going = false;
@@ -453,52 +453,52 @@
 				break;
 			case NET_SOCKET:
-				fibril_rwlock_write_lock( & lock );
-				* SOCKET_SET_SOCKET_ID( answer ) = SOCKET_GET_SOCKET_ID( call );
-				res = socket_create( & local_sockets, app_phone, NULL, SOCKET_SET_SOCKET_ID( answer ));
-				fibril_rwlock_write_unlock( & lock );
-				if( res == EOK ){
-					if( tl_get_ip_packet_dimension( udp_globals.ip_phone, & udp_globals.dimensions, DEVICE_INVALID_ID, & packet_dimension ) == EOK ){
-						* SOCKET_SET_DATA_FRAGMENT_SIZE( answer ) = packet_dimension->content;
+				fibril_rwlock_write_lock(&lock);
+				*SOCKET_SET_SOCKET_ID(answer) = SOCKET_GET_SOCKET_ID(call);
+				res = socket_create(&local_sockets, app_phone, NULL, SOCKET_SET_SOCKET_ID(answer));
+				fibril_rwlock_write_unlock(&lock);
+				if(res == EOK){
+					if(tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, DEVICE_INVALID_ID, &packet_dimension) == EOK){
+						*SOCKET_SET_DATA_FRAGMENT_SIZE(answer) = packet_dimension->content;
 					}
-//					* SOCKET_SET_DATA_FRAGMENT_SIZE( answer ) = MAX_UDP_FRAGMENT_SIZE;
-					* SOCKET_SET_HEADER_SIZE( answer ) = UDP_HEADER_SIZE;
+//					*SOCKET_SET_DATA_FRAGMENT_SIZE(answer) = MAX_UDP_FRAGMENT_SIZE;
+					*SOCKET_SET_HEADER_SIZE(answer) = UDP_HEADER_SIZE;
 					answer_count = 3;
 				}
 				break;
 			case NET_SOCKET_BIND:
-				res = data_receive(( void ** ) & addr, & addrlen );
-				if( res == EOK ){
-					fibril_rwlock_read_lock( & lock );
-					fibril_rwlock_write_lock( & udp_globals.lock );
-					res = socket_bind( & local_sockets, & udp_globals.sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port );
-					fibril_rwlock_write_unlock( & udp_globals.lock );
-					fibril_rwlock_read_unlock( & lock );
-					free( addr );
+				res = data_receive((void **) &addr, &addrlen);
+				if(res == EOK){
+					fibril_rwlock_read_lock(&lock);
+					fibril_rwlock_write_lock(&udp_globals.lock);
+					res = socket_bind(&local_sockets, &udp_globals.sockets, SOCKET_GET_SOCKET_ID(call), addr, addrlen, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port);
+					fibril_rwlock_write_unlock(&udp_globals.lock);
+					fibril_rwlock_read_unlock(&lock);
+					free(addr);
 				}
 				break;
 			case NET_SOCKET_SENDTO:
-				res = data_receive(( void ** ) & addr, & addrlen );
-				if( res == EOK ){
-					fibril_rwlock_read_lock( & lock );
-					fibril_rwlock_write_lock( & udp_globals.lock );
-					res = udp_sendto_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), addr, addrlen, SOCKET_GET_DATA_FRAGMENTS( call ), SOCKET_SET_DATA_FRAGMENT_SIZE( answer ), SOCKET_GET_FLAGS( call ));
-					if( res != EOK ){
-						fibril_rwlock_write_unlock( & udp_globals.lock );
+				res = data_receive((void **) &addr, &addrlen);
+				if(res == EOK){
+					fibril_rwlock_read_lock(&lock);
+					fibril_rwlock_write_lock(&udp_globals.lock);
+					res = udp_sendto_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), addr, addrlen, SOCKET_GET_DATA_FRAGMENTS(call), SOCKET_SET_DATA_FRAGMENT_SIZE(answer), SOCKET_GET_FLAGS(call));
+					if(res != EOK){
+						fibril_rwlock_write_unlock(&udp_globals.lock);
 					}else{
 						answer_count = 2;
 					}
-					fibril_rwlock_read_unlock( & lock );
-					free( addr );
+					fibril_rwlock_read_unlock(&lock);
+					free(addr);
 				}
 				break;
 			case NET_SOCKET_RECVFROM:
-				fibril_rwlock_read_lock( & lock );
-				fibril_rwlock_write_lock( & udp_globals.lock );
-				res = udp_recvfrom_message( & local_sockets, SOCKET_GET_SOCKET_ID( call ), SOCKET_GET_FLAGS( call ), & addrlen );
-				fibril_rwlock_write_unlock( & udp_globals.lock );
-				fibril_rwlock_read_unlock( & lock );
-				if( res > 0 ){
-					* SOCKET_SET_READ_DATA_LENGTH( answer ) = res;
-					* SOCKET_SET_ADDRESS_LENGTH( answer ) = addrlen;
+				fibril_rwlock_read_lock(&lock);
+				fibril_rwlock_write_lock(&udp_globals.lock);
+				res = udp_recvfrom_message(&local_sockets, SOCKET_GET_SOCKET_ID(call), SOCKET_GET_FLAGS(call), &addrlen);
+				fibril_rwlock_write_unlock(&udp_globals.lock);
+				fibril_rwlock_read_unlock(&lock);
+				if(res > 0){
+					*SOCKET_SET_READ_DATA_LENGTH(answer) = res;
+					*SOCKET_SET_ADDRESS_LENGTH(answer) = addrlen;
 					answer_count = 3;
 					res = EOK;
@@ -506,9 +506,9 @@
 				break;
 			case NET_SOCKET_CLOSE:
-				fibril_rwlock_write_lock( & lock );
-				fibril_rwlock_write_lock( & udp_globals.lock );
-				res = socket_destroy( udp_globals.net_phone, SOCKET_GET_SOCKET_ID( call ), & local_sockets, & udp_globals.sockets, NULL );
-				fibril_rwlock_write_unlock( & udp_globals.lock );
-				fibril_rwlock_write_unlock( & lock );
+				fibril_rwlock_write_lock(&lock);
+				fibril_rwlock_write_lock(&udp_globals.lock);
+				res = socket_destroy(udp_globals.net_phone, SOCKET_GET_SOCKET_ID(call), &local_sockets, &udp_globals.sockets, NULL);
+				fibril_rwlock_write_unlock(&udp_globals.lock);
+				fibril_rwlock_write_unlock(&lock);
 				break;
 			case NET_SOCKET_GETSOCKOPT:
@@ -521,42 +521,44 @@
 
 	// release all local sockets
-	socket_cores_release( udp_globals.net_phone, & local_sockets, & udp_globals.sockets, NULL );
+	socket_cores_release(udp_globals.net_phone, &local_sockets, &udp_globals.sockets, NULL);
 
 	return res;
 }
 
-int udp_sendto_message( socket_cores_ref local_sockets, int socket_id, const struct sockaddr * addr, socklen_t addrlen, int fragments, size_t * data_fragment_size, int flags ){
+int udp_sendto_message(socket_cores_ref local_sockets, int socket_id, const struct sockaddr * addr, socklen_t addrlen, int fragments, size_t * data_fragment_size, int flags){
 	ERROR_DECLARE;
 
-	socket_core_ref			socket;
-	packet_t				packet;
-	packet_t				next_packet;
-	udp_header_ref			header;
-	int						index;
-	size_t					total_length;
-	int						result;
-	uint16_t				dest_port;
-	uint32_t				checksum;
-	ip_pseudo_header_ref	ip_header;
-	size_t					headerlen;
-	device_id_t				device_id;
-	packet_dimension_ref	packet_dimension;
-
-	ERROR_PROPAGATE( tl_get_address_port( addr, addrlen, & dest_port ));
-
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
-
-	if(( socket->port <= 0 ) && udp_globals.autobinding ){
+	socket_core_ref socket;
+	packet_t packet;
+	packet_t next_packet;
+	udp_header_ref header;
+	int index;
+	size_t total_length;
+	int result;
+	uint16_t dest_port;
+	uint32_t checksum;
+	ip_pseudo_header_ref ip_header;
+	size_t headerlen;
+	device_id_t device_id;
+	packet_dimension_ref packet_dimension;
+
+	ERROR_PROPAGATE(tl_get_address_port(addr, addrlen, &dest_port));
+
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
+
+	if((socket->port <= 0) && udp_globals.autobinding){
 		// bind the socket to a random free port if not bound
 //		do{
 			// try to find a free port
-//			fibril_rwlock_read_unlock( & udp_globals.lock );
-//			fibril_rwlock_write_lock( & udp_globals.lock );
+//			fibril_rwlock_read_unlock(&udp_globals.lock);
+//			fibril_rwlock_write_lock(&udp_globals.lock);
 			// might be changed in the meantime
-//			if( socket->port <= 0 ){
-				if( ERROR_OCCURRED( socket_bind_free_port( & udp_globals.sockets, socket, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port ))){
-//					fibril_rwlock_write_unlock( & udp_globals.lock );
-//					fibril_rwlock_read_lock( & udp_globals.lock );
+//			if(socket->port <= 0){
+				if(ERROR_OCCURRED(socket_bind_free_port(&udp_globals.sockets, socket, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, udp_globals.last_used_port))){
+//					fibril_rwlock_write_unlock(&udp_globals.lock);
+//					fibril_rwlock_read_lock(&udp_globals.lock);
 					return ERROR_CODE;
 				}
@@ -564,133 +566,139 @@
 				udp_globals.last_used_port = socket->port;
 //			}
-//			fibril_rwlock_write_unlock( & udp_globals.lock );
-//			fibril_rwlock_read_lock( & udp_globals.lock );
+//			fibril_rwlock_write_unlock(&udp_globals.lock);
+//			fibril_rwlock_read_lock(&udp_globals.lock);
 			// might be changed in the meantime
-//		}while( socket->port <= 0 );
-	}
-
-	if( udp_globals.checksum_computing ){
-		if( ERROR_OCCURRED( ip_get_route_req( udp_globals.ip_phone, IPPROTO_UDP, addr, addrlen, & device_id, & ip_header, & headerlen ))){
-			return udp_release_and_return( packet, ERROR_CODE );
+//		}while(socket->port <= 0);
+	}
+
+	if(udp_globals.checksum_computing){
+		if(ERROR_OCCURRED(ip_get_route_req(udp_globals.ip_phone, IPPROTO_UDP, addr, addrlen, &device_id, &ip_header, &headerlen))){
+			return udp_release_and_return(packet, ERROR_CODE);
 		}
 		// get the device packet dimension
-//		ERROR_PROPAGATE( tl_get_ip_packet_dimension( udp_globals.ip_phone, & udp_globals.dimensions, device_id, & packet_dimension ));
+//		ERROR_PROPAGATE(tl_get_ip_packet_dimension(udp_globals.ip_phone, &udp_globals.dimensions, device_id, &packet_dimension));
 	}
 //	}else{
 		// do not ask all the time
-		ERROR_PROPAGATE( ip_packet_size_req( udp_globals.ip_phone, -1, & udp_globals.packet_dimension ));
-		packet_dimension = & udp_globals.packet_dimension;
+		ERROR_PROPAGATE(ip_packet_size_req(udp_globals.ip_phone, -1, &udp_globals.packet_dimension));
+		packet_dimension = &udp_globals.packet_dimension;
 //	}
 
 	// read the first packet fragment
-	result = tl_socket_read_packet_data( udp_globals.net_phone, & packet, UDP_HEADER_SIZE, packet_dimension, addr, addrlen );
-	if( result < 0 ) return result;
-	total_length = ( size_t ) result;
-	if( udp_globals.checksum_computing ){
-		checksum = compute_checksum( 0, packet_get_data( packet ), packet_get_data_length( packet ));
+	result = tl_socket_read_packet_data(udp_globals.net_phone, &packet, UDP_HEADER_SIZE, packet_dimension, addr, addrlen);
+	if(result < 0){
+		return result;
+	}
+	total_length = (size_t) result;
+	if(udp_globals.checksum_computing){
+		checksum = compute_checksum(0, packet_get_data(packet), packet_get_data_length(packet));
 	}else{
 		checksum = 0;
 	}
 	// prefix the udp header
-	header = PACKET_PREFIX( packet, udp_header_t );
-	if( ! header ){
-		return udp_release_and_return( packet, ENOMEM );
-	}
-	bzero( header, sizeof( * header ));
+	header = PACKET_PREFIX(packet, udp_header_t);
+	if(! header){
+		return udp_release_and_return(packet, ENOMEM);
+	}
+	bzero(header, sizeof(*header));
 	// read the rest of the packet fragments
-	for( index = 1; index < fragments; ++ index ){
-		result = tl_socket_read_packet_data( udp_globals.net_phone, & next_packet, 0, packet_dimension, addr, addrlen );
-		if( result < 0 ){
-			return udp_release_and_return( packet, result );
-		}
-		if( ERROR_OCCURRED( pq_add( & packet, next_packet, index, 0 ))){
-			return udp_release_and_return( packet, ERROR_CODE );
-		}
-		total_length += ( size_t ) result;
-		if( udp_globals.checksum_computing ){
-			checksum = compute_checksum( checksum, packet_get_data( next_packet ), packet_get_data_length( next_packet ));
+	for(index = 1; index < fragments; ++ index){
+		result = tl_socket_read_packet_data(udp_globals.net_phone, &next_packet, 0, packet_dimension, addr, addrlen);
+		if(result < 0){
+			return udp_release_and_return(packet, result);
+		}
+		if(ERROR_OCCURRED(pq_add(&packet, next_packet, index, 0))){
+			return udp_release_and_return(packet, ERROR_CODE);
+		}
+		total_length += (size_t) result;
+		if(udp_globals.checksum_computing){
+			checksum = compute_checksum(checksum, packet_get_data(next_packet), packet_get_data_length(next_packet));
 		}
 	}
 	// set the udp header
-	header->source_port = htons(( socket->port > 0 ) ? socket->port : 0 );
-	header->destination_port = htons( dest_port );
-	header->total_length = htons( total_length + sizeof( * header ));
+	header->source_port = htons((socket->port > 0) ? socket->port : 0);
+	header->destination_port = htons(dest_port);
+	header->total_length = htons(total_length + sizeof(*header));
 	header->checksum = 0;
-	if( udp_globals.checksum_computing ){
+	if(udp_globals.checksum_computing){
 		// update the pseudo header
-		if( ERROR_OCCURRED( ip_client_set_pseudo_header_data_length( ip_header, headerlen, total_length + UDP_HEADER_SIZE ))){
-			free( ip_header );
-			return udp_release_and_return( packet, ERROR_CODE );
+		if(ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(ip_header, headerlen, total_length + UDP_HEADER_SIZE))){
+			free(ip_header);
+			return udp_release_and_return(packet, ERROR_CODE);
 		}
 		// finish the checksum computation
-		checksum = compute_checksum( checksum, ip_header, headerlen );
-		checksum = compute_checksum( checksum, ( uint8_t * ) header, sizeof( * header ));
-		header->checksum = htons( flip_checksum( compact_checksum( checksum )));
-		free( ip_header );
+		checksum = compute_checksum(checksum, ip_header, headerlen);
+		checksum = compute_checksum(checksum, (uint8_t *) header, sizeof(*header));
+		header->checksum = htons(flip_checksum(compact_checksum(checksum)));
+		free(ip_header);
 	}else{
 		device_id = DEVICE_INVALID_ID;
 	}
 	// prepare the first packet fragment
-	if( ERROR_OCCURRED( ip_client_prepare_packet( packet, IPPROTO_UDP, 0, 0, 0, 0 ))){
-		return udp_release_and_return( packet, ERROR_CODE );
+	if(ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_UDP, 0, 0, 0, 0))){
+		return udp_release_and_return(packet, ERROR_CODE);
 	}
 	// send the packet
-	fibril_rwlock_write_unlock( & udp_globals.lock );
-	ip_send_msg( udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0 );
+	fibril_rwlock_write_unlock(&udp_globals.lock);
+	ip_send_msg(udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0);
 	return EOK;
 }
 
-int udp_recvfrom_message( socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen ){
+int udp_recvfrom_message(socket_cores_ref local_sockets, int socket_id, int flags, size_t * addrlen){
 	ERROR_DECLARE;
 
-	socket_core_ref	socket;
-	int				packet_id;
-	packet_t		packet;
-	udp_header_ref	header;
-	struct sockaddr *	addr;
-	size_t			length;
-	uint8_t *		data;
-	int				result;
+	socket_core_ref socket;
+	int packet_id;
+	packet_t packet;
+	udp_header_ref header;
+	struct sockaddr * addr;
+	size_t length;
+	uint8_t * data;
+	int result;
 
 	// find the socket
-	socket = socket_cores_find( local_sockets, socket_id );
-	if( ! socket ) return ENOTSOCK;
+	socket = socket_cores_find(local_sockets, socket_id);
+	if(! socket){
+		return ENOTSOCK;
+	}
 	// get the next received packet
-	packet_id = dyn_fifo_value( & socket->received );
-	if( packet_id < 0 ) return NO_DATA;
-	ERROR_PROPAGATE( packet_translate( udp_globals.net_phone, & packet, packet_id ));
+	packet_id = dyn_fifo_value(&socket->received);
+	if(packet_id < 0){
+		return NO_DATA;
+	}
+	ERROR_PROPAGATE(packet_translate(udp_globals.net_phone, &packet, packet_id));
 	// get udp header
-	data = packet_get_data( packet );
-	if( ! data ){
-		pq_release( udp_globals.net_phone, packet_id );
+	data = packet_get_data(packet);
+	if(! data){
+		pq_release(udp_globals.net_phone, packet_id);
 		return NO_DATA;
 	}
-	header = ( udp_header_ref ) data;
+	header = (udp_header_ref) data;
 
 	// set the source address port
-	result = packet_get_addr( packet, ( uint8_t ** ) & addr, NULL );
-	if( ERROR_OCCURRED( tl_set_address_port( addr, result, ntohs( header->source_port )))){
-		pq_release( udp_globals.net_phone, packet_id );
+	result = packet_get_addr(packet, (uint8_t **) &addr, NULL);
+	if(ERROR_OCCURRED(tl_set_address_port(addr, result, ntohs(header->source_port)))){
+		pq_release(udp_globals.net_phone, packet_id);
 		return ERROR_CODE;
 	}
-	* addrlen = ( size_t ) result;
+	*addrlen = (size_t) result;
 	// send the source address
-	ERROR_PROPAGATE( data_reply( addr, * addrlen ));
+	ERROR_PROPAGATE(data_reply(addr, * addrlen));
 
 	// trim the header
-	ERROR_PROPAGATE( packet_trim( packet, UDP_HEADER_SIZE, 0 ));
+	ERROR_PROPAGATE(packet_trim(packet, UDP_HEADER_SIZE, 0));
 
 	// reply the packets
-	ERROR_PROPAGATE( socket_reply_packets( packet, & length ));
+	ERROR_PROPAGATE(socket_reply_packets(packet, &length));
 
 	// release the packet
-	dyn_fifo_pop( & socket->received );
-	pq_release( udp_globals.net_phone, packet_get_id( packet ));
+	dyn_fifo_pop(&socket->received);
+	pq_release(udp_globals.net_phone, packet_get_id(packet));
 	// return the total length
-	return ( int ) length;
+	return (int) length;
 }
 
-int	udp_release_and_return( packet_t packet, int result ){
-	pq_release( udp_globals.net_phone, packet_get_id( packet ));
+int udp_release_and_return(packet_t packet, int result){
+	pq_release(udp_globals.net_phone, packet_get_id(packet));
 	return result;
 }
Index: uspace/srv/net/tl/udp/udp.h
===================================================================
--- uspace/srv/net/tl/udp/udp.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/udp/udp.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -54,32 +54,32 @@
 	/** Networking module phone.
 	 */
-	int				net_phone;
+	int net_phone;
 	/** IP module phone.
 	 */
-	int				ip_phone;
+	int ip_phone;
 	/** ICMP module phone.
 	 */
-	int				icmp_phone;
+	int icmp_phone;
 	/** Packet dimension.
 	 */
-	packet_dimension_t	packet_dimension;
+	packet_dimension_t packet_dimension;
 	/** Indicates whether UDP checksum computing is enabled.
 	 */
-	int				checksum_computing;
+	int checksum_computing;
 	/** Indicates whether UDP autobnding on send is enabled.
 	 */
-	int				autobinding;
+	int autobinding;
 	/** Last used free port.
 	 */
-	int				last_used_port;
+	int last_used_port;
 	/** Active sockets.
 	 */
-	socket_ports_t	sockets;
+	socket_ports_t sockets;
 	/** Device packet dimensions.
 	 */
-	packet_dimensions_t	dimensions;
+	packet_dimensions_t dimensions;
 	/** Safety lock.
 	 */
-	fibril_rwlock_t	lock;
+	fibril_rwlock_t lock;
 };
 
Index: uspace/srv/net/tl/udp/udp_header.h
===================================================================
--- uspace/srv/net/tl/udp/udp_header.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/udp/udp_header.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -43,5 +43,5 @@
 /** UDP header size in bytes.
  */
-#define UDP_HEADER_SIZE			sizeof( udp_header_t )
+#define UDP_HEADER_SIZE			sizeof(udp_header_t)
 
 /** Type definition of the user datagram header.
@@ -61,12 +61,12 @@
 	 *  If not used, a value of zero is inserted.
 	 */
-	uint16_t	source_port;
+	uint16_t source_port;
 	/** Destination port has a meaning within the context of a particular internet destination address.
 	 */
-	uint16_t	destination_port;
+	uint16_t destination_port;
 	/** Length is the length in octets of this user datagram including this header and the data.
 	 *  This means the minimum value of the length is eight.
 	 */
-	uint16_t	total_length;
+	uint16_t total_length;
 	/** Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets.
 	 *  The pseudo header conceptually prefixed to the UDP header contains the source address, the destination address, the protocol, and the UDP length.
@@ -75,5 +75,5 @@
 	 *  An all zero transmitted checksum value means that the transmitter generated no checksum (for debugging or for higher level protocols that don't care).
 	 */
-	uint16_t	checksum;
+	uint16_t checksum;
 } __attribute__ ((packed));
 
Index: uspace/srv/net/tl/udp/udp_module.c
===================================================================
--- uspace/srv/net/tl/udp/udp_module.c	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/udp/udp_module.c	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -61,5 +61,5 @@
  *  @see NAME
  */
-void	module_print_name( void );
+void module_print_name(void);
 
 /** Starts the UDP module.
@@ -70,5 +70,5 @@
  *  @returns Other error codes as defined for the REGISTER_ME() macro function.
  */
-int	module_start( async_client_conn_t client_connection );
+int module_start(async_client_conn_t client_connection);
 
 /** Processes the UDP message.
@@ -80,5 +80,5 @@
  *  @returns Other error codes as defined for the udp_message() function.
  */
-int	module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
 
 /** UDP module global data.
@@ -86,21 +86,21 @@
 extern udp_globals_t	udp_globals;
 
-void module_print_name( void ){
-	printf( "%s", NAME );
+void module_print_name(void){
+	printf("%s", NAME);
 }
 
-int module_start( async_client_conn_t client_connection ){
+int module_start(async_client_conn_t client_connection){
 	ERROR_DECLARE;
 
-	ipcarg_t	phonehash;
+	ipcarg_t phonehash;
 
-	async_set_client_connection( client_connection );
-	udp_globals.net_phone = net_connect_module( SERVICE_NETWORKING );
-	if( udp_globals.net_phone < 0 ){
+	async_set_client_connection(client_connection);
+	udp_globals.net_phone = net_connect_module(SERVICE_NETWORKING);
+	if(udp_globals.net_phone < 0){
 		return udp_globals.net_phone;
 	}
-	ERROR_PROPAGATE( pm_init());
-	if( ERROR_OCCURRED( udp_initialize( client_connection ))
-	|| ERROR_OCCURRED( REGISTER_ME( SERVICE_UDP, & phonehash ))){
+	ERROR_PROPAGATE(pm_init());
+	if(ERROR_OCCURRED(udp_initialize(client_connection))
+		|| ERROR_OCCURRED(REGISTER_ME(SERVICE_UDP, &phonehash))){
 		pm_destroy();
 		return ERROR_CODE;
@@ -113,6 +113,6 @@
 }
 
-int	module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
-	return udp_message( callid, call, answer, answer_count );
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	return udp_message(callid, call, answer, answer_count);
 }
 
Index: uspace/srv/net/tl/udp/udp_module.h
===================================================================
--- uspace/srv/net/tl/udp/udp_module.h	(revision aa85487c600b0fee35e8be1a6edd9b5b1a9a0646)
+++ uspace/srv/net/tl/udp/udp_module.h	(revision aadf01ebd2c032bc8dd43a6e06ae5715e6c2710f)
@@ -47,5 +47,5 @@
  *  @returns ENOMEM if there is not enough memory left.
  */
-int	udp_initialize( async_client_conn_t client_connection );
+int udp_initialize(async_client_conn_t client_connection);
 
 /** Processes the UDP message.
@@ -59,5 +59,5 @@
  *  @see IS_NET_UDP_MESSAGE()
  */
-int	udp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
+int udp_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
 
 #endif
