Index: uspace/srv/net/tl/tl_common.c
===================================================================
--- uspace/srv/net/tl/tl_common.c	(revision 91478aae14d21fad32ae117b2ac0b0fd52f11394)
+++ uspace/srv/net/tl/tl_common.c	(revision 858fc9083f1f538a864233e8551633863fb17e0b)
@@ -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;
 }
 
