Index: uspace/lib/c/include/net/icmp_codes.h
===================================================================
--- uspace/lib/c/include/net/icmp_codes.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/c/include/net/icmp_codes.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -42,6 +42,4 @@
 #define LIBC_ICMP_CODES_H_
 
-#include <sys/types.h>
-
 /** ICMP type type definition. */
 typedef uint8_t icmp_type_t;
Index: uspace/lib/net/Makefile
===================================================================
--- uspace/lib/net/Makefile	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/Makefile	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -38,4 +38,5 @@
 	generic/packet_client.c \
 	generic/packet_remote.c \
+	generic/socket_core.c \
 	adt/module_map.c \
 	netif/netif_local.c \
@@ -47,5 +48,4 @@
 	tl/icmp_remote.c \
 	tl/icmp_client.c \
-	tl/socket_core.c \
 	tl/tl_common.c
 
Index: uspace/lib/net/generic/socket_core.c
===================================================================
--- uspace/lib/net/generic/socket_core.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
+++ uspace/lib/net/generic/socket_core.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -0,0 +1,700 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libnet
+ * @{
+ */
+
+/** @file
+ * Socket common core implementation.
+ */
+
+#include <socket_core.h>
+#include <packet_client.h>
+#include <packet_remote.h>
+
+#include <net/socket_codes.h>
+#include <net/in.h>
+#include <net/inet.h>
+#include <net/packet.h>
+#include <net/modules.h>
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <err.h>
+
+#include <adt/dynamic_fifo.h>
+#include <adt/int_map.h>
+
+/**
+ * Maximum number of random attempts to find a new socket identifier before
+ * switching to the sequence.
+ */
+#define SOCKET_ID_TRIES	100
+
+/** Bound port sockets.*/
+struct socket_port {
+	/** The bound sockets map. */
+	socket_port_map_t map;
+	/** The bound sockets count. */
+	int count;
+};
+
+INT_MAP_IMPLEMENT(socket_cores, socket_core_t);
+
+GENERIC_CHAR_MAP_IMPLEMENT(socket_port_map, socket_core_ref);
+
+INT_MAP_IMPLEMENT(socket_ports, socket_port_t);
+
+/** Destroys the socket.
+ *
+ * If the socket is bound, the port is released.
+ * Releases all buffered packets, calls the release function and removes the
+ * socket from the local sockets.
+ *
+ * @param[in] packet_phone The packet server phone to release buffered packets.
+ * @param[in] socket	The socket to be destroyed.
+ * @param[in,out] local_sockets The local sockets to be updated.
+ * @param[in,out] global_sockets The global sockets to be updated.
+ * @param[in] socket_release The client release callback function.
+ */
+static void
+socket_destroy_core(int packet_phone, socket_core_ref socket,
+    socket_cores_ref local_sockets, socket_ports_ref global_sockets,
+    void (* socket_release)(socket_core_ref socket))
+{
+	int packet_id;
+
+	// if bound
+	if (socket->port) {
+		// release the port
+		socket_port_release(global_sockets, socket);
+	}
+	
+	// release all received packets
+	while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)
+		pq_release_remote(packet_phone, packet_id);
+
+	dyn_fifo_destroy(&socket->received);
+	dyn_fifo_destroy(&socket->accepted);
+
+	if (socket_release)
+		socket_release(socket);
+
+	socket_cores_exclude(local_sockets, socket->socket_id);
+}
+
+/** Destroys local sockets.
+ *
+ * Releases all buffered packets and calls the release function for each of the
+ * sockets.
+ *
+ * @param[in] packet_phone The packet server phone to release buffered packets.
+ * @param[in] local_sockets The local sockets to be destroyed.
+ * @param[in,out] global_sockets The global sockets to be updated.
+ * @param[in] socket_release The client release callback function.
+ */
+void
+socket_cores_release(int packet_phone, socket_cores_ref local_sockets,
+    socket_ports_ref global_sockets,
+    void (* socket_release)(socket_core_ref socket))
+{
+	int index;
+
+	if (!socket_cores_is_valid(local_sockets))
+		return;
+
+	local_sockets->magic = 0;
+
+	for (index = 0; index < local_sockets->next; ++index) {
+		if (socket_cores_item_is_valid(&local_sockets->items[index])) {
+			local_sockets->items[index].magic = 0;
+
+			if (local_sockets->items[index].value) {
+				socket_destroy_core(packet_phone,
+				    local_sockets->items[index].value,
+				    local_sockets, global_sockets,
+				    socket_release);
+				free(local_sockets->items[index].value);
+				local_sockets->items[index].value = NULL;
+			}
+		}
+	}
+
+	free(local_sockets->items);
+}
+
+/** Adds the socket to a socket port.
+ *
+ * @param[in,out] socket_port The socket port structure.
+ * @param[in] socket	The socket to be added.
+ * @param[in] key	The socket key identifier.
+ * @param[in] key_length The socket key length.
+ * @returns		EOK on success.
+ * @returns		ENOMEM if there is not enough memory left.
+ */
+static int
+socket_port_add_core(socket_port_ref socket_port, socket_core_ref socket,
+    const char *key, size_t key_length)
+{
+	ERROR_DECLARE;
+
+	socket_core_ref *socket_ref;
+
+	// create a wrapper
+	socket_ref = malloc(sizeof(*socket_ref));
+	if (!socket_ref)
+		return ENOMEM;
+
+	*socket_ref = socket;
+	// add the wrapper
+	if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key,
+	    key_length, socket_ref))) {
+		free(socket_ref);
+		return ERROR_CODE;
+	}
+	
+	++socket_port->count;
+	socket->key = key;
+	socket->key_length = key_length;
+	
+	return EOK;
+}
+
+/** Binds the socket to the port.
+ *
+ * The SOCKET_MAP_KEY_LISTENING key identifier is used.
+ *
+ * @param[in] global_sockets The global sockets to be updated.
+ * @param[in] socket	The socket to be added.
+ * @param[in] port	The port number to be bound to.
+ * @returns		EOK on success.
+ * @returns		ENOMEM if there is not enough memory left.
+ * @returns		Other error codes as defined for the
+ *			 socket_ports_add() function.
+ */
+static int
+socket_bind_insert(socket_ports_ref global_sockets, socket_core_ref socket,
+    int port)
+{
+	ERROR_DECLARE;
+
+	socket_port_ref socket_port;
+
+	// create a wrapper
+	socket_port = malloc(sizeof(*socket_port));
+	if (!socket_port)
+		return ENOMEM;
+
+	socket_port->count = 0;
+	if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) ||
+	    ERROR_OCCURRED(socket_port_add_core(socket_port, socket,
+	    SOCKET_MAP_KEY_LISTENING, 0))) {
+		socket_port_map_destroy(&socket_port->map);
+		free(socket_port);
+		return ERROR_CODE;
+	}
+	
+	// register the incomming port
+	ERROR_CODE = socket_ports_add(global_sockets, port, socket_port);
+	if (ERROR_CODE < 0) {
+		socket_port_map_destroy(&socket_port->map);
+		free(socket_port);
+		return ERROR_CODE;
+	}
+	
+	socket->port = port;
+	return EOK;
+}
+
+/** Binds the socket to the port.
+ *
+ * The address port is used if set, a free port is used if not.
+ *
+ * @param[in] local_sockets The local sockets to be searched.
+ * @param[in,out] global_sockets The global sockets to be updated.
+ * @param[in] socket_id	The new socket identifier.
+ * @param[in] addr	The address to be bound to.
+ * @param[in] addrlen	The address length.
+ * @param[in] free_ports_start The minimum free port.
+ * @param[in] free_ports_end The maximum free port.
+ * @param[in] last_used_port The last used free port.
+ * @returns		EOK on success.
+ * @returns		ENOTSOCK if the socket was not found.
+ * @returns		EAFNOSUPPORT if the address family is not supported.
+ * @returns		EADDRINUSE if the port is already in use.
+ * @returns		Other error codes as defined for the
+ *			socket_bind_free_port() function.
+ * @returns		Other error codes as defined for the
+ *			socket_bind_insert() function.
+ */
+int
+socket_bind(socket_cores_ref local_sockets, socket_ports_ref global_sockets,
+    int socket_id, void *addr, size_t addrlen, int free_ports_start,
+    int free_ports_end, int last_used_port)
+{
+	socket_core_ref socket;
+	socket_port_ref socket_port;
+	struct sockaddr *address;
+	struct sockaddr_in *address_in;
+
+	if (addrlen < sizeof(struct sockaddr))
+		return EINVAL;
+
+	address = (struct sockaddr *) addr;
+	switch (address->sa_family) {
+	case AF_INET:
+		if (addrlen != sizeof(struct sockaddr_in))
+			return EINVAL;
+		
+		address_in = (struct sockaddr_in *) addr;
+		// find the socket
+		socket = socket_cores_find(local_sockets, socket_id);
+		if (!socket)
+			return ENOTSOCK;
+		
+		// bind a free port?
+		if (address_in->sin_port <= 0)
+			return socket_bind_free_port(global_sockets, socket,
+			     free_ports_start, free_ports_end, last_used_port);
+		
+		// try to find the port
+		socket_port = socket_ports_find(global_sockets,
+		    ntohs(address_in->sin_port));
+		if (socket_port) {
+			// already used
+			return EADDRINUSE;
+		}
+		
+		// if bound
+		if (socket->port) {
+			// release the port
+			socket_port_release(global_sockets, socket);
+		}
+		socket->port = -1;
+		
+		return socket_bind_insert(global_sockets, socket,
+		    ntohs(address_in->sin_port));
+		
+	case AF_INET6:
+		// TODO IPv6
+		break;
+	}
+	
+	return EAFNOSUPPORT;
+}
+
+/** Binds the socket to a free port.
+ *
+ * The first free port is used.
+ *
+ * @param[in,out] global_sockets The global sockets to be updated.
+ * @param[in,out] socket The socket to be bound.
+ * @param[in] free_ports_start The minimum free port.
+ * @param[in] free_ports_end The maximum free port.
+ * @param[in] last_used_port The last used free port.
+ * @returns		EOK on success.
+ * @returns		ENOTCONN if no free port was found.
+ * @returns		Other error codes as defined for the
+ *			socket_bind_insert() function.
+ */
+int
+socket_bind_free_port(socket_ports_ref global_sockets, socket_core_ref socket,
+    int free_ports_start, int free_ports_end, int last_used_port)
+{
+	int index;
+
+	// from the last used one
+	index = last_used_port;
+	
+	do {
+		++index;
+		
+		// til the range end
+		if (index >= free_ports_end) {
+			// start from the range beginning
+			index = free_ports_start - 1;
+			do {
+				++index;
+				// til the last used one
+				if (index >= last_used_port) {
+					// none found
+					return ENOTCONN;
+				}
+			} while (socket_ports_find(global_sockets, index));
+			
+			// found, break immediately
+			break;
+		}
+		
+	} while (socket_ports_find(global_sockets, index));
+	
+	return socket_bind_insert(global_sockets, socket, index);
+}
+
+/** Tries to find a new free socket identifier.
+ *
+ * @param[in] local_sockets The local sockets to be searched.
+ * @param[in] positive	A value indicating whether a positive identifier is
+ *			requested. A negative identifier is requested if set to
+ *			false.
+ * @returns		The new socket identifier.
+ * @returns		ELIMIT if there is no socket identifier available.
+ */
+static int socket_generate_new_id(socket_cores_ref local_sockets, int positive)
+{
+	int socket_id;
+	int count;
+
+	count = 0;
+//	socket_id = socket_globals.last_id;
+	do {
+		if (count < SOCKET_ID_TRIES) {
+			socket_id = rand() % INT_MAX;
+			++count;
+		} else if (count == SOCKET_ID_TRIES) {
+			socket_id = 1;
+			++count;
+		// only this branch for last_id
+		} else {
+			if (socket_id < INT_MAX) {
+				++ socket_id;
+/*			} else if(socket_globals.last_id) {
+*				socket_globals.last_id = 0;
+*				socket_id = 1;
+*/			} else {
+				return ELIMIT;
+			}
+		}
+	} while (socket_cores_find(local_sockets,
+	    ((positive ? 1 : -1) * socket_id)));
+	
+//	last_id = socket_id
+	return socket_id;
+}
+
+/** Creates a new socket.
+ *
+ * @param[in,out] local_sockets The local sockets to be updated.
+ * @param[in] app_phone	The application phone.
+ * @param[in] specific_data The socket specific data.
+ * @param[in,out] socket_id The new socket identifier. A new identifier is
+ *			chosen if set to zero or negative. A negative identifier
+ *			is chosen if set to negative.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the socket_id parameter is NULL.
+ * @returns		ENOMEM if there is not enough memory left.
+ */
+int
+socket_create(socket_cores_ref local_sockets, int app_phone,
+    void *specific_data, int *socket_id)
+{
+	ERROR_DECLARE;
+
+	socket_core_ref socket;
+	int res;
+	int positive;
+
+	if (!socket_id)
+		return EINVAL;
+	
+	// store the socket
+	if (*socket_id <= 0) {
+		positive = (*socket_id == 0);
+		*socket_id = socket_generate_new_id(local_sockets, positive);
+		if (*socket_id <= 0)
+			return *socket_id;
+		if (!positive)
+			*socket_id *= -1;
+	} else if(socket_cores_find(local_sockets, *socket_id)) {
+		return EEXIST;
+	}
+	
+	socket = (socket_core_ref) malloc(sizeof(*socket));
+	if (!socket)
+		return ENOMEM;
+	
+	// initialize
+	socket->phone = app_phone;
+	socket->port = -1;
+	socket->key = NULL;
+	socket->key_length = 0;
+	socket->specific_data = specific_data;
+	if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,
+	    SOCKET_INITIAL_RECEIVED_SIZE))) {
+		free(socket);
+		return ERROR_CODE;
+	}
+	if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted,
+	    SOCKET_INITIAL_ACCEPTED_SIZE))) {
+		dyn_fifo_destroy(&socket->received);
+		free(socket);
+		return ERROR_CODE;
+	}
+	socket->socket_id = *socket_id;
+	res = socket_cores_add(local_sockets, socket->socket_id, socket);
+	if (res < 0) {
+		dyn_fifo_destroy(&socket->received);
+		dyn_fifo_destroy(&socket->accepted);
+		free(socket);
+		return res;
+	}
+	
+	return EOK;
+}
+
+/** Destroys the socket.
+ *
+ * If the socket is bound, the port is released.
+ * Releases all buffered packets, calls the release function and removes the
+ * socket from the local sockets.
+ *
+ * @param[in] packet_phone The packet server phone to release buffered packets.
+ * @param[in] socket_id	The socket identifier.
+ * @param[in,out] local_sockets The local sockets to be updated.
+ * @param[in,out] global_sockets The global sockets to be updated.
+ * @param[in] socket_release The client release callback function.
+ * @returns		EOK on success.
+ * @returns		ENOTSOCK if the socket is not found.
+ */
+int
+socket_destroy(int packet_phone, int socket_id, socket_cores_ref local_sockets,
+    socket_ports_ref global_sockets,
+    void (*socket_release)(socket_core_ref socket))
+{
+	socket_core_ref socket;
+	int accepted_id;
+
+	// find the socket
+	socket = socket_cores_find(local_sockets, socket_id);
+	if (!socket)
+		return ENOTSOCK;
+	
+	// destroy all accepted sockets
+	while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0)
+		socket_destroy(packet_phone, accepted_id, local_sockets,
+		    global_sockets, socket_release);
+	
+	socket_destroy_core(packet_phone, socket, local_sockets, global_sockets,
+	    socket_release);
+	
+	return EOK;
+}
+
+/** Replies the packet or the packet queue data to the application via the
+ * socket.
+ *
+ * Uses the current message processing fibril.
+ *
+ * @param[in] packet	The packet to be transfered.
+ * @param[out] length	The total data length.
+ * @returns		EOK on success.
+ * @returns		EBADMEM if the length parameter is NULL.
+ * @returns		ENOMEM if there is not enough memory left.
+ * @returns		Other error codes as defined for the data_reply()
+ *			function.
+ */
+int socket_reply_packets(packet_t packet, size_t *length)
+{
+	ERROR_DECLARE;
+
+	packet_t next_packet;
+	size_t fragments;
+	size_t *lengths;
+	size_t index;
+
+	if (!length)
+		return EBADMEM;
+
+	next_packet = pq_next(packet);
+	if (!next_packet) {
+		// write all if only one fragment
+		ERROR_PROPAGATE(data_reply(packet_get_data(packet),
+		    packet_get_data_length(packet)));
+		// store the total length
+		*length = packet_get_data_length(packet);
+	} else {
+		// count the packet fragments
+		fragments = 1;
+		next_packet = pq_next(packet);
+		while ((next_packet = pq_next(next_packet)))
+			++fragments;
+		
+		// compute and store the fragment lengths
+		lengths = (size_t *) malloc(sizeof(size_t) * fragments +
+		    sizeof(size_t));
+		if (!lengths)
+			return ENOMEM;
+		
+		lengths[0] = packet_get_data_length(packet);
+		lengths[fragments] = lengths[0];
+		next_packet = pq_next(packet);
+		
+		for (index = 1; index < fragments; ++index) {
+			lengths[index] = packet_get_data_length(next_packet);
+			lengths[fragments] += lengths[index];
+			next_packet = pq_next(packet);
+		}
+		
+		// write the fragment lengths
+		if (ERROR_OCCURRED(data_reply(lengths,
+		    sizeof(int) * (fragments + 1)))) {
+			free(lengths);
+			return ERROR_CODE;
+		}
+		next_packet = packet;
+		
+		// write the fragments
+		for (index = 0; index < fragments; ++index) {
+			ERROR_CODE = data_reply(packet_get_data(next_packet),
+			    lengths[index]);
+			if (ERROR_OCCURRED(ERROR_CODE)) {
+				free(lengths);
+				return ERROR_CODE;
+			}
+			next_packet = pq_next(next_packet);
+		}
+		
+		// store the total length
+		*length = lengths[fragments];
+		free(lengths);
+	}
+	
+	return EOK;
+}
+
+/** Finds the bound port socket.
+ *
+ * @param[in] global_sockets The global sockets to be searched.
+ * @param[in] port	The port number.
+ * @param[in] key	The socket key identifier.
+ * @param[in] key_length The socket key length.
+ * @returns		The found socket.
+ * @returns		NULL if no socket was found.
+ */
+socket_core_ref
+socket_port_find(socket_ports_ref global_sockets, int port, const char *key,
+    size_t key_length)
+{
+	socket_port_ref socket_port;
+	socket_core_ref *socket_ref;
+
+	socket_port = socket_ports_find(global_sockets, port);
+	if (socket_port && (socket_port->count > 0)) {
+		socket_ref = socket_port_map_find(&socket_port->map, key,
+		    key_length);
+		if (socket_ref)
+			return *socket_ref;
+	}
+	
+	return NULL;
+}
+
+/** Releases the socket port.
+ *
+ * If the socket is bound the port entry is released.
+ * If there are no more port entries the port is release.
+ *
+ * @param[in] global_sockets The global sockets to be updated.
+ * @param[in] socket	The socket to be unbound.
+ */
+void
+socket_port_release(socket_ports_ref global_sockets, socket_core_ref socket)
+{
+	socket_port_ref socket_port;
+	socket_core_ref *socket_ref;
+
+	if (!socket->port)
+		return;
+	
+	// find ports
+	socket_port = socket_ports_find(global_sockets, socket->port);
+	if (socket_port) {
+		// find the socket
+		socket_ref = socket_port_map_find(&socket_port->map,
+		    socket->key, socket->key_length);
+		
+		if (socket_ref) {
+			--socket_port->count;
+			
+			// release if empty
+			if (socket_port->count <= 0) {
+				// destroy the map
+				socket_port_map_destroy(&socket_port->map);
+				// release the port
+				socket_ports_exclude(global_sockets,
+				    socket->port);
+			} else {
+				// remove
+				socket_port_map_exclude(&socket_port->map,
+				    socket->key, socket->key_length);
+			}
+		}
+	}
+	
+	socket->port = 0;
+	socket->key = NULL;
+	socket->key_length = 0;
+}
+
+/** Adds the socket to an already bound port.
+ *
+ * @param[in] global_sockets The global sockets to be updated.
+ * @param[in] port	The port number to be bound to.
+ * @param[in] socket	The socket to be added.
+ * @param[in] key	The socket key identifier.
+ * @param[in] key_length The socket key length.
+ * @returns		EOK on success.
+ * @returns		ENOENT if the port is not already used.
+ * @returns		Other error codes as defined for the
+ *			socket_port_add_core() function.
+ */
+int
+socket_port_add(socket_ports_ref global_sockets, int port,
+    socket_core_ref socket, const char *key, size_t key_length)
+{
+	ERROR_DECLARE;
+
+	socket_port_ref socket_port;
+
+	// find ports
+	socket_port = socket_ports_find(global_sockets, port);
+	if (!socket_port)
+		return ENOENT;
+	
+	// add the socket
+	ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key,
+	    key_length));
+	
+	socket->port = port;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/net/il/ip_remote.c
===================================================================
--- uspace/lib/net/il/ip_remote.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/il/ip_remote.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libnet
+/** @addtogroup ip
  * @{
  */
@@ -72,16 +72,4 @@
 }
 
-/** Creates bidirectional connection with the ip module service and registers
- * the message receiver.
- *
- * @param[in] service	The IP module service.
- * @param[in] protocol	The transport layer protocol.
- * @param[in] me	The requesting module service.
- * @param[in] receiver	The message receiver. Used for remote connection.
- * @returns		The phone of the needed service.
- * @returns		EOK on success.
- * @returns		Other error codes as defined for the bind_service()
- *			function.
- */
 int ip_bind_service(services_t service, int protocol, services_t me,
     async_client_conn_t receiver)
@@ -91,9 +79,4 @@
 }
 
-/** Connects to the IP module.
- *
- * @param service	The IP module service. Ignored parameter.
- * @returns		The IP module phone on success.
- */
 int ip_connect_module(services_t service)
 {
@@ -127,6 +110,5 @@
 }
 
-/** Return the device identifier and the IP pseudo header based on the
- * destination address.
+/** Return the device identifier and the IP pseudo header based on the destination address.
  *
  * @param[in]  ip_phone    The IP module phone used for (semi)remote calls.
@@ -155,11 +137,10 @@
 	    (ipcarg_t) protocol, &answer);
 	
-	if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) &&
-	    (async_data_read_start(ip_phone, headerlen,
-	    sizeof(*headerlen)) == EOK) && (*headerlen > 0)) {
+	if ((async_data_write_start(ip_phone, destination, addrlen) == EOK)
+	    && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK)
+	    && (*headerlen > 0)) {
 		*header = malloc(*headerlen);
 		if (*header) {
-			if (async_data_read_start(ip_phone, *header,
-			    *headerlen) != EOK)
+			if (async_data_read_start(ip_phone, *header, *headerlen) != EOK)
 				free(*header);
 		}
@@ -192,6 +173,6 @@
     packet_dimension_ref packet_dimension)
 {
-	return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE,
-	    device_id, packet_dimension);
+	return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id,
+	    packet_dimension);
 }
 
Index: uspace/lib/net/include/icmp_client.h
===================================================================
--- uspace/lib/net/include/icmp_client.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/icmp_client.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,21 +27,34 @@
  */
 
-/** @addtogroup libnet
- * @{
+/** @addtogroup icmp
+ *  @{
  */
 
 /** @file
- * ICMP client interface.
+ *  ICMP client interface.
  */
 
-#ifndef LIBNET_ICMP_CLIENT_H_
-#define LIBNET_ICMP_CLIENT_H_
+#ifndef __NET_ICMP_CLIENT_H__
+#define __NET_ICMP_CLIENT_H__
 
 #include <net/icmp_codes.h>
 #include <net/packet.h>
 
-extern int icmp_client_process_packet(packet_t, icmp_type_t *, icmp_code_t *,
-    icmp_param_t *, icmp_param_t *);
-extern size_t icmp_client_header_length(packet_t);
+/** Processes the received packet prefixed with an ICMP header.
+ *  @param[in] packet The received packet.
+ *  @param[out] type The ICMP header type.
+ *  @param[out] code The ICMP header code.
+ *  @param[out] pointer The ICMP header pointer.
+ *  @param[out] mtu The ICMP header MTU.
+ *  @returns The ICMP header length.
+ *  @returns Zero (0) if the packet contains no data.
+ */
+extern int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu);
+
+/** Returns the ICMP header length.
+ *  @param[in] packet The packet.
+ *  @returns The ICMP header length in bytes.
+ */
+extern size_t icmp_client_header_length(packet_t packet);
 
 #endif
Index: uspace/lib/net/include/il_local.h
===================================================================
--- uspace/lib/net/include/il_local.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/il_local.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,42 +27,16 @@
  */
 
-/** @addtogroup libnet 
- * @{
+/** @addtogroup il_local
+ *  @{
  */
 
-#ifndef LIBNET_IL_LOCAL_H_
-#define LIBNET_IL_LOCAL_H_
+#ifndef __IL_LOCAL_H__
+#define __IL_LOCAL_H__
 
 #include <ipc/ipc.h>
 #include <async.h>
 
-/** Processes the Internet layer module message.
- *
- * @param[in]		callid The message identifier.
- * @param[in]		call The message parameters.
- * @param[out]		answer The message answer parameters.
- * @param[out]		answer_count The last parameter for the actual answer in
- *			the answer parameter.
- * @returns		EOK on success.
- * @returns		Other error codes as defined for the arp_message()
- *			function.
- */
 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
     ipc_call_t *answer, int *answer_count);
-
-/** Starts the Internet layer module.
- *
- * Initializes the client connection servicing function, initializes the module,
- * registers the module service and starts the async manager, processing IPC
- * messages in an infinite loop.
- *
- * @param[in] client_connection The client connection processing function. The
- *			module skeleton propagates its own one.
- * @returns		EOK on successful module termination.
- * @returns		Other error codes as defined for the arp_initialize()
- *			function.
- * @returns		Other error codes as defined for the REGISTER_ME() macro
- *			function.
- */
 extern int il_module_start_standalone(async_client_conn_t client_connection);
 
Index: uspace/lib/net/include/ip_header.h
===================================================================
--- uspace/lib/net/include/ip_header.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/ip_header.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,15 +27,15 @@
  */
 
-/** @addtogroup libnet 
- * @{
+/** @addtogroup ip
+ *  @{
  */
 
 /** @file
- * IP header and options definitions.
- * Based on the RFC 791.
- */
-
-#ifndef LIBNET_IP_HEADER_H_
-#define LIBNET_IP_HEADER_H_
+ *  IP header and options definitions.
+ *  Based on the RFC~791.
+ */
+
+#ifndef __NET_IP_HEADER_H__
+#define __NET_IP_HEADER_H__
 
 #include <byteorder.h>
@@ -43,172 +43,235 @@
 
 /** Returns the fragment offest high bits.
- * @param[in] length The prefixed data total length.
- */
-#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) \
-	((((length) / 8U) & 0x1f00) >> 8)
+ *  @param[in] length The prefixed data total length.
+ */
+#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8)
 
 /** Returns the fragment offest low bits.
- * @param[in] length The prefixed data total length.
- */
-#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) \
-	(((length) / 8U) & 0xff)
+ *  @param[in] length The prefixed data total length.
+ */
+#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF)
 
 /** Returns the IP header length.
- * @param[in] length The IP header length in bytes.
- */
-#define IP_COMPUTE_HEADER_LENGTH(length) \
-	((uint8_t) ((length) / 4U))
+ *  @param[in] length The IP header length in bytes.
+ */
+#define IP_COMPUTE_HEADER_LENGTH(length)		((uint8_t) ((length) / 4u))
 
 /** Returns the fragment offest.
- * @param[in] header The IP packet header.
- */
-#define IP_FRAGMENT_OFFSET(header) \
-	((((header)->fragment_offset_high << 8) + \
-	    (header)->fragment_offset_low) * 8U)
+ *  @param[in] header The IP packet header.
+ */
+#define IP_FRAGMENT_OFFSET(header) ((((header)->fragment_offset_high << 8) + (header)->fragment_offset_low) * 8u)
 
 /** Returns the IP packet header checksum.
  *  @param[in] header The IP packet header.
  */
-#define IP_HEADER_CHECKSUM(header) \
-	(htons(ip_checksum((uint8_t *) (header), IP_HEADER_LENGTH(header))))
+#define IP_HEADER_CHECKSUM(header)	(htons(ip_checksum((uint8_t *)(header), IP_HEADER_LENGTH(header))))
 
 /** Returns the actual IP packet data length.
- * @param[in] header The IP packet header.
- */
-#define IP_HEADER_DATA_LENGTH(header) \
-	(IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
+ *  @param[in] header The IP packet header.
+ */
+#define IP_HEADER_DATA_LENGTH(header)	(IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
 
 /** Returns the actual IP header length in bytes.
- * @param[in] header The IP packet header.
- */
-#define IP_HEADER_LENGTH(header) \
-	((header)->header_length * 4U)
+ *  @param[in] header The IP packet header.
+ */
+#define IP_HEADER_LENGTH(header)		((header)->header_length * 4u)
 
 /** Returns the actual IP packet total length.
- * @param[in] header The IP packet header.
- */
-#define IP_TOTAL_LENGTH(header) \
-	ntohs((header)->total_length)
-
-/** @name IP flags definitions */
+ *  @param[in] header The IP packet header.
+ */
+#define IP_TOTAL_LENGTH(header)		ntohs((header)->total_length)
+
+/** @name IP flags definitions
+ */
 /*@{*/
 
-/** Fragment flag field shift. */
-#define IPFLAG_FRAGMENT_SHIFT	1
-
-/** Fragmented flag field shift. */
-#define IPFLAG_FRAGMENTED_SHIFT	0
+/** Fragment flag field shift.
+ */
+#define IPFLAG_FRAGMENT_SHIFT		1
+
+/** Fragmented flag field shift.
+ */
+#define IPFLAG_FRAGMENTED_SHIFT		0
 
 /** Don't fragment flag value.
- * Permits the packet fragmentation.
- */
-#define IPFLAG_DONT_FRAGMENT	(0x1 << IPFLAG_FRAGMENT_SHIFT)
+ *  Permits the packet fragmentation.
+ */
+#define IPFLAG_DONT_FRAGMENT		(0x1 << IPFLAG_FRAGMENT_SHIFT)
 
 /** Last fragment flag value.
- * Indicates the last packet fragment.
- */
-#define IPFLAG_LAST_FRAGMENT	(0x0 << IPFLAG_FRAGMENTED_SHIFT)
+ *  Indicates the last packet fragment.
+ */
+#define IPFLAG_LAST_FRAGMENT		(0x0 << IPFLAG_FRAGMENTED_SHIFT)
 
 /** May fragment flag value.
- * Allows the packet fragmentation.
- */
-#define IPFLAG_MAY_FRAGMENT	(0x0 << IPFLAG_FRAGMENT_SHIFT)
+ *  Allows the packet fragmentation.
+ */
+#define IPFLAG_MAY_FRAGMENT			(0x0 << IPFLAG_FRAGMENT_SHIFT)
 
 /** More fragments flag value.
- * Indicates that more packet fragments follow.
- */
-#define IPFLAG_MORE_FRAGMENTS	(0x1 << IPFLAG_FRAGMENTED_SHIFT)
+ *  Indicates that more packet fragments follow.
+ */
+#define IPFLAG_MORE_FRAGMENTS		(0x1 << IPFLAG_FRAGMENTED_SHIFT)
 
 /*@}*/
 
 /** Type definition of the internet header.
- * @see ip_header
- */
-typedef struct ip_header ip_header_t;
+ *  @see ip_header
+ */
+typedef struct ip_header	ip_header_t;
 
 /** Type definition of the internet header pointer.
- * @see ip_header
- */
-typedef ip_header_t *ip_header_ref;
+ *  @see ip_header
+ */
+typedef ip_header_t *		ip_header_ref;
 
 /** Type definition of the internet option header.
- * @see ip_header
- */
-typedef struct ip_option ip_option_t;
+ *  @see ip_header
+ */
+typedef struct ip_option	ip_option_t;
 
 /** Type definition of the internet option header pointer.
- * @see ip_header
- */
-typedef ip_option_t *ip_option_ref;
+ *  @see ip_header
+ */
+typedef ip_option_t *		ip_option_ref;
 
 /** Type definition of the internet version 4 pseudo header.
- * @see ipv4_pseudo_header
- */
-typedef struct ipv4_pseudo_header ipv4_pseudo_header_t;
+ *  @see ipv4_pseudo_header
+ */
+typedef struct ipv4_pseudo_header	ipv4_pseudo_header_t;
 
 /** Type definition of the internet version 4 pseudo header pointer.
- * @see ipv4_pseudo_header
- */
-typedef ipv4_pseudo_header_t *ipv4_pseudo_header_ref;
+ *  @see ipv4_pseudo_header
+ */
+typedef ipv4_pseudo_header_t *		ipv4_pseudo_header_ref;
 
 /** Internet header.
- *
- * The variable options should be included after the header itself and
- * indicated by the increased header length value.
- */
-struct ip_header {
+ *  The variable options should be included after the header itself and indicated by the increased header length value.
+ */
+struct ip_header{
 #ifdef ARCH_IS_BIG_ENDIAN
-	uint8_t version : 4;
-	uint8_t header_length : 4;
+	/** The Version field indicates the format of the internet header.
+	 */
+	uint8_t version:4;
+	/** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
+	 *  Note that the minimum value for a~correct header is~5.
+	 */
+	uint8_t header_length:4;
 #else
-	uint8_t header_length : 4;
-	uint8_t version : 4;
-#endif
-
+	/** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
+	 *  Note that the minimum value for a~correct header is~5.
+	 */
+	uint8_t header_length:4;
+	/** The Version field indicates the format of the internet header.
+	 */
+	uint8_t version:4;
+#endif
+	/** The Type of Service provides an indication of the abstract parameters of the quality of service desired.
+	 *  These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network.
+	 *  Several networks offer service precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a~certain precedence at time of high load).
+	 *  The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput.
+	 */
 	uint8_t tos;
+	/** Total Length is the length of the datagram, measured in octets, including internet header and data.
+	 *  This field allows the length of a~datagram to be up to 65,535~octets.
+	 */
 	uint16_t total_length;
+	/** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram.
+	 */
 	uint16_t identification;
-
 #ifdef ARCH_IS_BIG_ENDIAN
-	uint8_t flags : 3;
-	uint8_t fragment_offset_high : 5;
+	/** Various control flags.
+	 */
+	uint8_t flags:3;
+	/** This field indicates where in the datagram this fragment belongs.
+	 *  High bits.
+	 */
+	uint8_t fragment_offset_high:5;
 #else
-	uint8_t fragment_offset_high : 5;
-	uint8_t flags : 3;
-#endif
-
+	/** This field indicates where in the datagram this fragment belongs.
+	 *  High bits.
+	 */
+	uint8_t fragment_offset_high:5;
+	/** Various control flags.
+	 */
+	uint8_t flags:3;
+#endif
+	/** This field indicates where in the datagram this fragment belongs.
+	 *  Low bits.
+	 */
 	uint8_t fragment_offset_low;
+	/** This field indicates the maximum time the datagram is allowed to remain in the internet system.
+	 *  If this field contains the value zero, then the datagram must be destroyed.
+	 *  This field is modified in internet header processing.
+	 *  The time is measured in units of seconds, but since every module that processes a~datagram must decrease the TTL by at least one even if it process the datagram in less than a~second, the TTL must be thought of only as an upper bound on the time a~datagram may exist.
+	 *  The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.
+	 */
 	uint8_t ttl;
+	/** This field indicates the next level protocol used in the data portion of the internet datagram.
+	 */
 	uint8_t protocol;
+	/** A checksum of the header only.
+	 *  Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.
+	 *  The checksum algorithm is: The checksum field is the 16~bit one's complement of the one's complement sum of all 16~bit words in the header.
+	 *  For purposes of computing the checksum, the value of the checksum field is zero.
+	 */
 	uint16_t header_checksum;
+	/** The source address.
+	 */
 	uint32_t source_address;
+	/** The destination address.
+	 */
 	uint32_t destination_address;
 } __attribute__ ((packed));
 
 /** Internet option header.
- *
- * Only type field is always valid.
- * Other fields' validity depends on the option type.
- */
-struct ip_option {
+ *  Only type field is always valid.
+ *  Other fields' validity depends on the option type.
+ */
+struct ip_option{
+	/** A single octet of option-type.
+	 */
 	uint8_t type;
+	/** An option length octet.
+	 */
 	uint8_t length;
+	/** A~pointer.
+	 */
 	uint8_t pointer;
-
 #ifdef ARCH_IS_BIG_ENDIAN
-	uint8_t overflow : 4;
-	uint8_t flags : 4;
+	/** The number of IP modules that cannot register timestamps due to lack of space.
+	 */
+	uint8_t overflow:4;
+	/** Various internet timestamp control flags.
+	 */
+	uint8_t flags:4;
 #else
-	uint8_t flags : 4;
-	uint8_t overflow : 4;
+	/** Various internet timestamp control flags.
+	 */
+	uint8_t flags:4;
+	/** The number of IP modules that cannot register timestamps due to lack of space.
+	 */
+	uint8_t overflow:4;
 #endif
 } __attribute__ ((packed));
 
-/** Internet version 4 pseudo header. */
-struct ipv4_pseudo_header {
+/** Internet version 4 pseudo header.
+ */
+struct ipv4_pseudo_header{
+	/** The source address.
+	 */
 	uint32_t source_address;
+	/** The destination address.
+	 */
 	uint32_t destination_address;
+	/** Reserved byte.
+	 *  Must be zero.
+	 */
 	uint8_t reserved;
+	/** This field indicates the next level protocol used in the data portion of the internet datagram.
+	 */
 	uint8_t protocol;
+	/** Data length is the length of the datagram, measured in octets.
+	 */
 	uint16_t data_length;
 } __attribute__ ((packed));
Index: uspace/lib/net/include/ip_interface.h
===================================================================
--- uspace/lib/net/include/ip_interface.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/ip_interface.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,10 +27,10 @@
  */
 
-/** @addtogroup libnet 
- * @{
+/** @addtogroup ip
+ *  @{
  */
 
-#ifndef LIBNET_IP_INTERFACE_H_
-#define LIBNET_IP_INTERFACE_H_
+#ifndef __NET_IP_INTERFACE_H__
+#define __NET_IP_INTERFACE_H__
 
 #include <net/socket_codes.h>
@@ -55,24 +55,34 @@
 
 /** @name IP module interface
- * This interface is used by other modules.
+ *  This interface is used by other modules.
  */
 /*@{*/
 
 /** The transport layer notification function type definition.
- *
- * Notifies the transport layer modules about the received packet/s.
- *
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The received packet or the received packet queue.
- * @param[in] receiver	The receiving module service.
- * @param[in] error	The packet error reporting service. Prefixes the
- *			received packet.
- * @returns		EOK on success.
+ *  Notifies the transport layer modules about the received packet/s.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The received packet or the received packet queue.
+ *  @param[in] receiver The receiving module service.
+ *  @param[in] error The packet error reporting service. Prefixes the received packet.
+ *  @returns EOK on success.
  */
-typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t packet,
-    services_t receiver, services_t error);
+typedef int	(*tl_received_msg_t)(device_id_t device_id, packet_t packet, services_t receiver, services_t error);
 
-extern int ip_bind_service(services_t, int, services_t, async_client_conn_t);
-extern int ip_connect_module(services_t);
+/** Creates bidirectional connection with the ip module service and registers the message receiver.
+ *  @param[in] service The IP module service.
+ *  @param[in] protocol The transport layer protocol.
+ *  @param[in] me The requesting module service.
+ *  @param[in] receiver The message receiver. Used for remote connection.
+ *  @returns The phone of the needed service.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the bind_service() function.
+ */
+extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver);
+
+/** Connects to the IP module.
+ *  @param service The IP module service. Ignored parameter.
+ *  @returns The IP module phone on success.
+ */
+extern int ip_connect_module(services_t service);
 
 /*@}*/
Index: uspace/lib/net/include/ip_remote.h
===================================================================
--- uspace/lib/net/include/ip_remote.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/ip_remote.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,10 +27,10 @@
  */
 
-/** @addtogroup libnet
+/** @addtogroup ip
  * @{
  */
 
-#ifndef LIBNET_IP_REMOTE_H_
-#define LIBNET_IP_REMOTE_H_
+#ifndef __NET_IP_REMOTE_H__
+#define __NET_IP_REMOTE_H__
 
 #include <ipc/services.h>
Index: uspace/lib/net/include/netif_interface.h
===================================================================
--- uspace/lib/net/include/netif_interface.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/netif_interface.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,10 +27,10 @@
  */
 
-/** @addtogroup libnet
+/** @addtogroup netif
  * @{
  */
 
-#ifndef LIBNET_NETIF_INTERFACE_H_
-#define LIBNET_NETIF_INTERFACE_H_
+#ifndef __NET_NETIF_INTERFACE_H__
+#define __NET_NETIF_INTERFACE_H__
 
 #include <netif_remote.h>
Index: uspace/lib/net/include/netif_local.h
===================================================================
--- uspace/lib/net/include/netif_local.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/netif_local.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libnet
+/** @addtogroup netif
  * @{
  */
@@ -36,6 +36,6 @@
  */
 
-#ifndef NET_NETIF_LOCAL_H_
-#define NET_NETIF_LOCAL_H_
+#ifndef __NET_NETIF_LOCAL_H__
+#define __NET_NETIF_LOCAL_H__
 
 #include <async.h>
@@ -43,4 +43,5 @@
 #include <ipc/ipc.h>
 #include <ipc/services.h>
+#include <err.h>
 
 #include <adt/measured_strings.h>
@@ -48,5 +49,7 @@
 #include <net/packet.h>
 
-/** Network interface device specific data. */
+/** Network interface device specific data.
+ *
+ */
 typedef struct {
 	device_id_t device_id;  /**< Device identifier. */
@@ -64,5 +67,7 @@
 DEVICE_MAP_DECLARE(netif_device_map, netif_device_t);
 
-/** Network interface module skeleton global data. */
+/** Network interface module skeleton global data.
+ *
+ */
 typedef struct {
 	int net_phone;                  /**< Networking module phone. */
@@ -76,4 +81,5 @@
  *
  * This function has to be implemented in user code.
+ *
  */
 extern int netif_initialize(void);
@@ -83,13 +89,13 @@
  * This has to be implemented in user code.
  *
- * @param[in] device_id	The device identifier.
- * @param[in] irq	The device interrupt number.
- * @param[in] io	The device input/output address.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ * @param[in] device_id The device identifier.
+ * @param[in] irq       The device interrupt number.
+ * @param[in] io        The device input/output address.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io);
@@ -99,15 +105,14 @@
  * This has to be implemented in user code.
  *
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The packet queue.
- * @param[in] sender	The sending module service.
- *
- * @return		EOK on success.
- * @return		EFORWARD if the device is not active (in the
- *			NETIF_ACTIVE state).
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ * @param[in] device_id The device identifier.
+ * @param[in] packet    The packet queue.
+ * @param[in] sender    The sending module service.
+ *
+ * @return EOK on success.
+ * @return EFORWARD if the device is not active (in the NETIF_ACTIVE state).
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_send_message(device_id_t device_id, packet_t packet,
@@ -118,11 +123,11 @@
  * This has to be implemented in user code.
  *
- * @param[in] device	The device structure.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ * @param[in] device The device structure.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_start_message(netif_device_t *device);
@@ -132,11 +137,11 @@
  * This has to be implemented in user code.
  *
- * @param[in] device	The device structure.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ * @param[in] device The device structure.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_stop_message(netif_device_t *device);
@@ -146,14 +151,14 @@
  * This has to be implemented in user code.
  *
- * @param[in] device_id	The device identifier.
- * @param[out] address	The device local hardware address.
- *
- * @return		EOK on success.
- * @return		EBADMEM if the address parameter is NULL.
- * @return		ENOENT if there no such device.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ * @param[in]  device_id The device identifier.
+ * @param[out] address   The device local hardware address.
+ *
+ * @return EOK on success.
+ * @return EBADMEM if the address parameter is NULL.
+ * @return ENOENT if there no such device.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_get_addr_message(device_id_t device_id,
@@ -165,14 +170,15 @@
  * skeleton. This has to be implemented in user code.
  *
- * @param[in] callid	The message identifier.
- * @param[in] call	The message parameters.
- * @param[out] answer	The message answer parameters.
+ * @param[in]  callid       The message identifier.
+ * @param[in]  call         The message parameters.
+ * @param[out] answer       The message answer parameters.
  * @param[out] answer_count The last parameter for the actual answer in
- *			the answer parameter.
- *
- * @return		EOK on success.
- * @return		ENOTSUP if the message is not known.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ *                          the answer parameter.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
@@ -183,12 +189,12 @@
  * This has to be implemented in user code.
  *
- * @param[in] device_id	The device identifier.
- * @param[out] stats	The device usage statistics.
- *
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the specific module
- *			message implementation.
+ * @param[in]  device_id The device identifier.
+ * @param[out] stats     The device usage statistics.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the specific module message
+ *         implementation.
+ *
  */
 extern int netif_get_device_stats(device_id_t device_id,
Index: uspace/lib/net/include/netif_remote.h
===================================================================
--- uspace/lib/net/include/netif_remote.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/netif_remote.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,17 +27,14 @@
  */
 
-/** @addtogroup libnet
+/** @addtogroup netif
  * @{
  */
 
-#ifndef LIBNET_NETIF_REMOTE_H_
-#define LIBNET_NETIF_REMOTE_H_
+#ifndef __NET_NETIF_REMOTE_H__
+#define __NET_NETIF_REMOTE_H__
 
-#include <async.h>
 #include <ipc/services.h>
 #include <adt/measured_strings.h>
-
 #include <net/device.h>
-#include <net/packet.h>
 
 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_ref *,
Index: uspace/lib/net/include/nil_interface.h
===================================================================
--- uspace/lib/net/include/nil_interface.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/nil_interface.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,10 +27,10 @@
  */
 
-/** @addtogroup libnet
- * @{
+/** @addtogroup net_nil
+ *  @{
  */
 
-#ifndef LIBNET_NIL_INTERFACE_H_
-#define LIBNET_NIL_INTERFACE_H_
+#ifndef __NET_NIL_INTERFACE_H__
+#define __NET_NIL_INTERFACE_H__
 
 #include <async.h>
@@ -47,6 +47,6 @@
 
 #define nil_packet_size_req(nil_phone, device_id, packet_dimension) \
-	generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, \
-	    device_id, packet_dimension)
+	generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, device_id, \
+	    packet_dimension)
 
 #define nil_get_addr_req(nil_phone, device_id, address, data) \
Index: uspace/lib/net/include/nil_local.h
===================================================================
--- uspace/lib/net/include/nil_local.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/nil_local.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,6 +27,6 @@
  */
 
-/** @addtogroup libnet
- * @{
+/** @addtogroup net_nil
+ *  @{
  */
 
@@ -36,6 +36,6 @@
  */
 
-#ifndef LIBNET_NIL_LOCAL_H_
-#define LIBNET_NIL_LOCAL_H_
+#ifndef __NET_NIL_LOCAL_H__
+#define __NET_NIL_LOCAL_H__
 
 #include <ipc/ipc.h>
@@ -45,88 +45,38 @@
  * Is called by the module_start() function.
  *
- * @param[in] net_phone	The networking moduel phone.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			initialize function.
+ * @param[in] net_phone The networking moduel phone.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for each specific module initialize function.
+ *
  */
 extern int nil_initialize(int);
 
-/** Notify the network interface layer about the device state change.
- *
- * @param[in] nil_phone	The network interface layer phone.
- * @param[in] device_id	The device identifier.
- * @param[in] state	The new device state.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			device state function.
- */
 extern int nil_device_state_msg_local(int, device_id_t, int);
-
-
-/** Pass the packet queue to the network interface layer.
- *
- * Process and redistribute the received packet queue to the registered
- * upper layers.
- *
- * @param[in] nil_phone	The network interface layer phone.
- * @param[in] device_id	The source device identifier.
- * @param[in] packet	The received packet or the received packet queue.
- * @param target	The target service. Ignored parameter.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- * 			received function.
- */
 extern int nil_received_msg_local(int, device_id_t, packet_t, services_t);
 
 /** Message processing function.
  *
- * @param[in] name	Module name.
- * @param[in] callid	The message identifier.
- * @param[in] call	The message parameters.
- * @param[out] answer	The message answer parameters.
- * @param[out] answer_count The last parameter for the actual answer in the
- *			answer parameter.
- * @return		EOK on success.
- * @return		ENOTSUP if the message is not known.
- * @return		Other error codes as defined for each specific module
- *			message function.
+ * @param[in]  name         Module name.
+ * @param[in]  callid       The message identifier.
+ * @param[in]  call         The message parameters.
+ * @param[out] answer       The message answer parameters.
+ * @param[out] answer_count The last parameter for the actual answer
+ *                          in the answer parameter.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for each specific
+ *         module message function.
  *
  * @see nil_interface.h
  * @see IS_NET_NIL_MESSAGE()
+ *
  */
-extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *,
-    ipc_call_t *, int *);
+extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *,
+    int *);
 
-/** Pass the parameters to the module specific nil_message() function.
- *
- * @param[in] name	Module name.
- * @param[in] callid	The message identifier.
- * @param[in] call	The message parameters.
- * @param[out] answer	The message answer parameters.
- * @param[out] answer_count The last parameter for the actual answer in the
- *			answer parameter.
- * @return		EOK on success.
- * @return		ENOTSUP if the message is not known.
- * @return		Other error codes as defined for each specific module
- *			message function.
- */
 extern int nil_module_message_standalone(const char *, ipc_callid_t,
     ipc_call_t *, ipc_call_t *, int *);
-
-/** Start the standalone nil layer module.
- *
- * Initialize the client connection serving function, initialize
- * the module, register the module service and start the async
- * manager, processing IPC messages in an infinite loop.
- *
- * @param[in] client_connection The client connection processing function.
- *			The module skeleton propagates its own one.
- * @return		EOK on success.
- * @return		Other error codes as defined for the pm_init() function.
- * @return		Other error codes as defined for the nil_initialize()
- *			function.
- * @return		Other error codes as defined for the REGISTER_ME() macro
- *			function.
- */
 extern int nil_module_start_standalone(async_client_conn_t);
 
Index: uspace/lib/net/include/tl_common.h
===================================================================
--- uspace/lib/net/include/tl_common.h	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/include/tl_common.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,16 +27,14 @@
  */
 
-/** @addtogroup libnet 
- * @{
+/** @addtogroup net_tl
+ *  @{
  */
 
 /** @file
- * Transport layer common functions.
+ *  Transport layer common functions.
  */
 
-#ifndef LIBNET_TL_COMMON_H_
-#define LIBNET_TL_COMMON_H_
-
-#include <ipc/services.h>
+#ifndef __NET_TL_COMMON_H__
+#define __NET_TL_COMMON_H__
 
 #include <net/socket_codes.h>
@@ -46,6 +44,6 @@
 
 /** Device packet dimensions.
- * Maps devices to the packet dimensions.
- * @see device.h
+ *  Maps devices to the packet dimensions.
+ *  @see device.h
  */
 DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t);
@@ -53,11 +51,61 @@
 extern int tl_get_ip_packet_dimension(int, packet_dimensions_ref,
     device_id_t, packet_dimension_ref *);
-extern int tl_get_address_port(const struct sockaddr *, int, uint16_t *);
-extern int tl_update_ip_packet_dimension(packet_dimensions_ref, device_id_t,
-    size_t);
-extern int tl_set_address_port(struct sockaddr *, int, uint16_t);
-extern int tl_prepare_icmp_packet(int, int, packet_t, services_t);
-extern int tl_socket_read_packet_data(int, packet_ref, size_t,
-    const packet_dimension_ref, const struct sockaddr *, socklen_t);
+
+/** Gets the address port.
+ *  Supports AF_INET and AF_INET6 address families.
+ *  @param[in,out] addr The address to be updated.
+ *  @param[in] addrlen The address length.
+ *  @param[out] port The set port.
+ *  @returns EOK on success.
+ *  @returns EINVAL if the address length does not match the address family.
+ *  @returns EAFNOSUPPORT if the address family is not supported.
+ */
+extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port);
+
+/** Updates IP device packet dimensions cache.
+ *  @param[in,out] packet_dimensions The packet dimensions cache.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] content The new maximum content size.
+ *  @returns EOK on success.
+ *  @returns ENOENT if the packet dimension is not cached.
+ */
+extern int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content);
+
+/** Sets the address port.
+ *  Supports AF_INET and AF_INET6 address families.
+ *  @param[in,out] addr The address to be updated.
+ *  @param[in] addrlen The address length.
+ *  @param[in] port The port to be set.
+ *  @returns EOK on success.
+ *  @returns EINVAL if the address length does not match the address family.
+ *  @returns EAFNOSUPPORT if the address family is not supported.
+ */
+extern int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port);
+
+/** Prepares the packet for ICMP error notification.
+ *  Keeps the first packet and releases all the others.
+ *  Releases all the packets on error.
+ *  @param[in] packet_phone The packet server module phone.
+ *  @param[in] icmp_phone The ICMP module phone.
+ *  @param[in] packet The packet to be send.
+ *  @param[in] error The packet error reporting service. Prefixes the received packet.
+ *  @returns EOK on success.
+ *  @returns ENOENT if no packet may be sent.
+ */
+extern 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.
+ *  @param[in] packet_phone The packet server module phone.
+ *  @param[out] packet The new created packet.
+ *  @param[in] prefix Reserved packet data prefix length.
+ *  @param[in] dimension The packet dimension.
+ *  @param[in] addr The destination address.
+ *  @param[in] addrlen The address length.
+ *  @returns Number of bytes received.
+ *  @returns EINVAL if the client does not send data.
+ *  @returns ENOMEM if there is not enough memory left.
+ *  @returns Other error codes as defined for the async_data_read_finalize() function.
+ */
+extern 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/lib/net/netif/netif_local.c
===================================================================
--- uspace/lib/net/netif/netif_local.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/netif/netif_local.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libnet 
+/** @addtogroup netif
  * @{
  */
@@ -58,5 +58,6 @@
 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
 
-/** Network interface global data. */
+/** Network interface global data.
+ */
 netif_globals_t netif_globals;
 
@@ -64,13 +65,13 @@
  *
  * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] irq	The device interrupt number.
- * @param[in] io	The device input/output address.
- * @return		EOK on success.
- * @return		Other error codes as defined for the
- *			netif_probe_message().
- */
-int
-netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
+ * @param[in] device_id   The device identifier.
+ * @param[in] irq         The device interrupt number.
+ * @param[in] io          The device input/output address.
+ *
+ * @return EOK on success.
+ * @return Other errro codes as defined for the netif_probe_message().
+ *
+ */
+int netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
 {
 	fibril_rwlock_write_lock(&netif_globals.lock);
@@ -84,10 +85,11 @@
  *
  * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The packet queue.
- * @param[in] sender	The sending module service.
- * @return		EOK on success.
- * @return		Other error codes as defined for the generic_send_msg()
- *			function.
+ * @param[in] device_id   The device identifier.
+ * @param[in] packet      The packet queue.
+ * @param[in] sender      The sending module service.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the generic_send_msg() function.
+ *
  */
 int netif_send_msg_local(int netif_phone, device_id_t device_id,
@@ -104,10 +106,10 @@
  *
  * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_start_message() function.
+ * @param[in] device_id   The device identifier.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the netif_start_message() function.
+ *
  */
 int netif_start_req_local(int netif_phone, device_id_t device_id)
@@ -139,10 +141,10 @@
  *
  * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_stop_message() function.
+ * @param[in] device_id   The device identifier.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the find_device() function.
+ * @return Other error codes as defined for the netif_stop_message() function.
+ *
  */
 int netif_stop_req_local(int netif_phone, device_id_t device_id)
@@ -173,8 +175,10 @@
 /** Return the device usage statistics.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] stats	The device usage statistics.
- * @return EOK on success.
+ * @param[in]  netif_phone The network interface phone.
+ * @param[in]  device_id   The device identifier.
+ * @param[out] stats       The device usage statistics.
+ *
+ * @return EOK on success.
+ *
  */
 int netif_stats_req_local(int netif_phone, device_id_t device_id,
@@ -190,13 +194,15 @@
 /** Return the device local hardware address.
  *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] address	The device local hardware address.
- * @param[out] data	The address data.
- * @return		EOK on success.
- * @return		EBADMEM if the address parameter is NULL.
- * @return		ENOENT if there no such device.
- * @return		Other error codes as defined for the
- *			netif_get_addr_message() function.
+ * @param[in]  netif_phone The network interface phone.
+ * @param[in]  device_id   The device identifier.
+ * @param[out] address     The device local hardware address.
+ * @param[out] data        The address data.
+ *
+ * @return EOK on success.
+ * @return EBADMEM if the address parameter is NULL.
+ * @return ENOENT if there no such device.
+ * @return Other error codes as defined for the netif_get_addr_message()
+ *         function.
+ *
  */
 int netif_get_addr_req_local(int netif_phone, device_id_t device_id,
@@ -205,5 +211,5 @@
 	ERROR_DECLARE;
 	
-	if (!address || !data)
+	if ((!address) || (!data))
 		return EBADMEM;
 	
@@ -225,9 +231,11 @@
 /** Find the device specific data.
  *
- * @param[in] device_id	The device identifier.
- * @param[out] device	The device specific data.
- * @return		EOK on success.
- * @return		ENOENT if device is not found.
- * @return		EPERM if the device is not initialized.
+ * @param[in]  device_id The device identifier.
+ * @param[out] device    The device specific data.
+ *
+ * @return EOK on success.
+ * @return ENOENT if device is not found.
+ * @return EPERM if the device is not initialized.
+ *
  */
 int find_device(device_id_t device_id, netif_device_t **device)
@@ -248,5 +256,6 @@
 /** Clear the usage statistics.
  *
- * @param[in] stats	The usage statistics.
+ * @param[in] stats The usage statistics.
+ *
  */
 void null_device_stats(device_stats_ref stats)
@@ -257,8 +266,11 @@
 /** Initialize the netif module.
  *
- * @param[in] client_connection The client connection functio to be registered.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			message function.
+ *  @param[in] client_connection The client connection functio to be
+ *                               registered.
+ *
+ *  @return EOK on success.
+ *  @return Other error codes as defined for each specific module
+ *          message function.
+ *
  */
 int netif_init_module(async_client_conn_t client_connection)
@@ -286,5 +298,6 @@
  * Prepared for future optimization.
  *
- * @param[in] packet_id	The packet identifier.
+ * @param[in] packet_id The packet identifier.
+ *
  */
 void netif_pq_release(packet_id_t packet_id)
@@ -295,7 +308,8 @@
 /** Allocate new packet to handle the given content size.
  *
- * @param[in] content	The minimum content size.
- * @return		The allocated packet.
- * @return		NULL if there is an error.
+ * @param[in] content The minimum content size.
+ *
+ * @return The allocated packet.
+ * @return NULL if there is an error.
  *
  */
@@ -305,13 +319,14 @@
 }
 
-/** Register the device notification receiver, the network interface layer
- * module.
- *
- * @param[in] name	Module name.
- * @param[in] device_id	The device identifier.
- * @param[in] phone	The network interface layer module phone.
- * @return		EOK on success.
- * @return		ENOENT if there is no such device.
- * @return		ELIMIT if there is another module registered.
+/** Register the device notification receiver, the network interface layer module.
+ *
+ * @param[in] name      Module name.
+ * @param[in] device_id The device identifier.
+ * @param[in] phone     The network interface layer module phone.
+ *
+ * @return EOK on success.
+ * @return ENOENT if there is no such device.
+ * @return ELIMIT if there is another module registered.
+ *
  */
 static int register_message(const char *name, device_id_t device_id, int phone)
@@ -332,14 +347,14 @@
 /** Process the netif module messages.
  *
- * @param[in] name 	Module name.
- * @param[in] callid	The message identifier.
- * @param[in] call	The message parameters.
- * @param[out] answer	The message answer parameters.
- * @param[out] answer_count The last parameter for the actual answer in the
- *			answer parameter.
- * @return		EOK on success.
- * @return		ENOTSUP if the message is not known.
- * @return		Other error codes as defined for each specific module
- *			message function.
+ * @param[in]  name         Module name.
+ * @param[in]  callid       The message identifier.
+ * @param[in]  call         The message parameters.
+ * @param[out] answer       The message answer parameters.
+ * @param[out] answer_count The last parameter for the actual answer
+ *                          in the answer parameter.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for each specific module message function.
  *
  * @see IS_NET_NETIF_MESSAGE()
@@ -358,58 +373,45 @@
 	*answer_count = 0;
 	switch (IPC_GET_METHOD(*call)) {
-	case IPC_M_PHONE_HUNGUP:
-		return EOK;
-	
-	case NET_NETIF_PROBE:
-		return netif_probe_req_local(0, IPC_GET_DEVICE(call),
-		    NETIF_GET_IRQ(call), NETIF_GET_IO(call));
-		    
-	case IPC_M_CONNECT_TO_ME:
-		fibril_rwlock_write_lock(&netif_globals.lock);
-		ERROR_CODE = register_message(name, IPC_GET_DEVICE(call),
-		    IPC_GET_PHONE(call));
-		fibril_rwlock_write_unlock(&netif_globals.lock);
-		return ERROR_CODE;
-		
-	case NET_NETIF_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
-		return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
-		    IPC_GET_SENDER(call));
-		    
-	case NET_NETIF_START:
-		return netif_start_req_local(0, IPC_GET_DEVICE(call));
-		
-	case NET_NETIF_STATS:
-		fibril_rwlock_read_lock(&netif_globals.lock);
-
-		if (ERROR_OCCURRED(async_data_read_receive(&callid, &length))) {
+		case IPC_M_PHONE_HUNGUP:
+			return EOK;
+		case NET_NETIF_PROBE:
+			return netif_probe_req_local(0, IPC_GET_DEVICE(call),
+			    NETIF_GET_IRQ(call), NETIF_GET_IO(call));
+		case IPC_M_CONNECT_TO_ME:
+			fibril_rwlock_write_lock(&netif_globals.lock);
+			ERROR_CODE = register_message(name, IPC_GET_DEVICE(call),
+			    IPC_GET_PHONE(call));
+			fibril_rwlock_write_unlock(&netif_globals.lock);
+			return ERROR_CODE;
+		case NET_NETIF_SEND:
+			ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone,
+			    &packet, IPC_GET_PACKET(call)));
+			return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
+			    IPC_GET_SENDER(call));
+		case NET_NETIF_START:
+			return netif_start_req_local(0, IPC_GET_DEVICE(call));
+		case NET_NETIF_STATS:
+			fibril_rwlock_read_lock(&netif_globals.lock);
+			if (!ERROR_OCCURRED(async_data_read_receive(&callid, &length))) {
+				if (length < sizeof(device_stats_t))
+					ERROR_CODE = EOVERFLOW;
+				else {
+					if (!ERROR_OCCURRED(netif_get_device_stats(
+					    IPC_GET_DEVICE(call), &stats)))
+						ERROR_CODE = async_data_read_finalize(callid, &stats,
+						    sizeof(device_stats_t));
+				}
+			}
 			fibril_rwlock_read_unlock(&netif_globals.lock);
 			return ERROR_CODE;
-		}
-		if (length < sizeof(device_stats_t)) {
+		case NET_NETIF_STOP:
+			return netif_stop_req_local(0, IPC_GET_DEVICE(call));
+		case NET_NETIF_GET_ADDR:
+			fibril_rwlock_read_lock(&netif_globals.lock);
+			if (!ERROR_OCCURRED(netif_get_addr_message(IPC_GET_DEVICE(call),
+			    &address)))
+				ERROR_CODE = measured_strings_reply(&address, 1);
 			fibril_rwlock_read_unlock(&netif_globals.lock);
-			return EOVERFLOW;
-		}
-
-		if (ERROR_NONE(netif_get_device_stats(IPC_GET_DEVICE(call),
-		    &stats))) {
-			ERROR_CODE = async_data_read_finalize(callid, &stats,
-			    sizeof(device_stats_t));
-		}
-
-		fibril_rwlock_read_unlock(&netif_globals.lock);
-		return ERROR_CODE;
-
-	case NET_NETIF_STOP:
-		return netif_stop_req_local(0, IPC_GET_DEVICE(call));
-		
-	case NET_NETIF_GET_ADDR:
-		fibril_rwlock_read_lock(&netif_globals.lock);
-		if (ERROR_NONE(netif_get_addr_message(IPC_GET_DEVICE(call),
-		    &address)))
-			ERROR_CODE = measured_strings_reply(&address, 1);
-		fibril_rwlock_read_unlock(&netif_globals.lock);
-		return ERROR_CODE;
+			return ERROR_CODE;
 	}
 	
@@ -419,13 +421,16 @@
 /** Start the network interface module.
  *
- * Initialize the client connection serving function, initialize the module,
- * registers the module service and start the async manager, processing IPC
- * messages in an infinite loop.
- *
- * @param[in] client_connection The client connection processing function.
- *			The module skeleton propagates its own one.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			message function.
+ * Initialize the client connection serving function, initialize
+ * the module, registers the module service and start the async
+ * manager, processing IPC messages in an infinite loop.
+ *
+ * @param[in] client_connection The client connection processing
+ *                              function. The module skeleton propagates
+ *                              its own one.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for each specific module message
+ *         function.
+ *
  */
 int netif_module_start_standalone(async_client_conn_t client_connection)
Index: uspace/lib/net/netif/netif_remote.c
===================================================================
--- uspace/lib/net/netif/netif_remote.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/netif/netif_remote.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libnet 
+/** @addtogroup netif
  * @{
  */
@@ -35,8 +35,4 @@
  */
 
-#include <netif_remote.h>
-#include <packet_client.h>
-#include <generic.h>
-
 #include <ipc/services.h>
 #include <ipc/netif.h>
@@ -45,18 +41,9 @@
 #include <adt/measured_strings.h>
 #include <net/packet.h>
+#include <packet_client.h>
 #include <net/device.h>
+#include <netif_remote.h>
+#include <generic.h>
 
-/** Return the device local hardware address.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] address	The device local hardware address.
- * @param[out] data	The address data.
- * @return		EOK on success.
- * @return		EBADMEM if the address parameter is NULL.
- * @return		ENOENT if there no such device.
- * @return		Other error codes as defined for the
- *			netif_get_addr_message() function.
- */
 int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
     measured_string_ref *address, char **data)
@@ -66,32 +53,10 @@
 }
 
-/** Probe the existence of the device.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] irq	The device interrupt number.
- * @param[in] io	The device input/output address.
- * @return		EOK on success.
- * @return		Other error codes as defined for the
- *			netif_probe_message().
- */
-int
-netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
+int netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
 {
 	return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io);
 }
 
-/** Send the packet queue.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[in] packet	The packet queue.
- * @param[in] sender	The sending module service.
- * @return		EOK on success.
- * @return		Other error codes as defined for the generic_send_msg()
- *			function.
- */
-int
-netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t packet,
+int netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t packet,
     services_t sender)
 {
@@ -100,14 +65,4 @@
 }
 
-/** Start the device.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_start_message() function.
- */
 int netif_start_req_remote(int netif_phone, device_id_t device_id)
 {
@@ -115,14 +70,4 @@
 }
 
-/** Stop the device.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @return		EOK on success.
- * @return		Other error codes as defined for the find_device()
- *			function.
- * @return		Other error codes as defined for the
- *			netif_stop_message() function.
- */
 int netif_stop_req_remote(int netif_phone, device_id_t device_id)
 {
@@ -130,11 +75,4 @@
 }
 
-/** Return the device usage statistics.
- *
- * @param[in] netif_phone The network interface phone.
- * @param[in] device_id	The device identifier.
- * @param[out] stats	The device usage statistics.
- * @return EOK on success.
- */
 int netif_stats_req_remote(int netif_phone, device_id_t device_id,
     device_stats_ref stats)
@@ -161,12 +99,11 @@
  * @param[in] receiver  The message receiver.
  *
- * @return		The phone of the needed service.
- * @return		EOK on success.
- * @return		Other error codes as defined for the bind_service()
- *			function.
+ * @return The phone of the needed service.
+ * @return EOK on success.
+ * @return Other error codes as defined for the bind_service() function.
+ *
  */
-int
-netif_bind_service_remote(services_t service, device_id_t device_id,
-    services_t me, async_client_conn_t receiver)
+int netif_bind_service_remote(services_t service, device_id_t device_id, services_t me,
+    async_client_conn_t receiver)
 {
 	return bind_service(service, device_id, me, 0, receiver);
Index: uspace/lib/net/nil/nil_remote.c
===================================================================
--- uspace/lib/net/nil/nil_remote.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/nil/nil_remote.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libnet
+/** @addtogroup net_nil
  * @{
  */
@@ -47,10 +47,12 @@
 /** Notify the network interface layer about the device state change.
  *
- * @param[in] nil_phone	The network interface layer phone.
- * @param[in] device_id	The device identifier.
- * @param[in] state	The new device state.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- *			device state function.
+ * @param[in] nil_phone The network interface layer phone.
+ * @param[in] device_id The device identifier.
+ * @param[in] state     The new device state.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for each specific module device
+ *         state function.
+ *
  */
 int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state)
@@ -65,17 +67,19 @@
  * upper layers.
  *
- * @param[in] nil_phone	The network interface layer phone.
- * @param[in] device_id	The source device identifier.
- * @param[in] packet	The received packet or the received packet queue.
- * @param target	The target service. Ignored parameter.
- * @return		EOK on success.
- * @return		Other error codes as defined for each specific module
- * 			received function.
+ * @param[in] nil_phone The network interface layer phone.
+ * @param[in] device_id The source device identifier.
+ * @param[in] packet    The received packet or the received packet queue.
+ * @param     target    The target service. Ignored parameter.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for each specific module
+ *         received function.
+ *
  */
 int nil_received_msg_remote(int nil_phone, device_id_t device_id,
     packet_t packet, services_t target)
 {
-	return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED,
-	    device_id, packet_get_id(packet), target, 0);
+	return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED, device_id,
+	    packet_get_id(packet), target, 0);
 }
 
Index: uspace/lib/net/tl/icmp_client.c
===================================================================
--- uspace/lib/net/tl/icmp_client.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/tl/icmp_client.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,19 +27,15 @@
  */
 
-/** @addtogroup libnet
- * @{
+/** @addtogroup icmp
+ *  @{
  */
 
 /** @file
- * ICMP client interface implementation.
- * @see icmp_client.h
+ *  ICMP client interface implementation.
+ *  @see icmp_client.h
  */
 
-#include <icmp_client.h>
-#include <icmp_header.h>
-#include <packet_client.h>
-
 #ifdef CONFIG_DEBUG
-#include <stdio.h>
+	#include <stdio.h>
 #endif
 
@@ -48,55 +44,40 @@
 
 #include <net/icmp_codes.h>
+#include <icmp_client.h>
 #include <net/packet.h>
+#include <packet_client.h>
+#include <icmp_header.h>
 
-/** Processes the received packet prefixed with an ICMP header.
- *
- * @param[in] packet	The received packet.
- * @param[out] type	The ICMP header type.
- * @param[out] code	The ICMP header code.
- * @param[out] pointer	The ICMP header pointer.
- * @param[out] mtu	The ICMP header MTU.
- * @returns		The ICMP header length.
- * @returns		Zero if the packet contains no data.
- */
-int
-icmp_client_process_packet(packet_t packet, icmp_type_t *type,
-    icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu)
-{
+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))) {
+	if((! header)
+		|| (packet_get_data_length(packet) < sizeof(icmp_header_t))){
 		return 0;
 	}
-
-	if (type)
+	if(type){
 		*type = header->type;
-	if (code)
+	}
+	if(code){
 		*code = header->code;
-	if (pointer)
+	}
+	if(pointer){
 		*pointer = header->un.param.pointer;
-	if (mtu)
+	}
+	if(mtu){
 		*mtu = header->un.frag.mtu;
-
+	}
 	// remove debug dump
 #ifdef CONFIG_DEBUG
-	printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,
-	    packet_get_id(packet));
+	printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet));
 #endif
 	return sizeof(icmp_header_t);
 }
 
-/** Returns the ICMP header length.
- *
- * @param[in] packet	The packet.
- * @returns		The ICMP header length in bytes.
- */
-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);
 }
Index: pace/lib/net/tl/socket_core.c
===================================================================
--- uspace/lib/net/tl/socket_core.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ 	(revision )
@@ -1,700 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libnet
- * @{
- */
-
-/** @file
- * Socket common core implementation.
- */
-
-#include <socket_core.h>
-#include <packet_client.h>
-#include <packet_remote.h>
-
-#include <net/socket_codes.h>
-#include <net/in.h>
-#include <net/inet.h>
-#include <net/packet.h>
-#include <net/modules.h>
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <err.h>
-
-#include <adt/dynamic_fifo.h>
-#include <adt/int_map.h>
-
-/**
- * Maximum number of random attempts to find a new socket identifier before
- * switching to the sequence.
- */
-#define SOCKET_ID_TRIES	100
-
-/** Bound port sockets.*/
-struct socket_port {
-	/** The bound sockets map. */
-	socket_port_map_t map;
-	/** The bound sockets count. */
-	int count;
-};
-
-INT_MAP_IMPLEMENT(socket_cores, socket_core_t);
-
-GENERIC_CHAR_MAP_IMPLEMENT(socket_port_map, socket_core_ref);
-
-INT_MAP_IMPLEMENT(socket_ports, socket_port_t);
-
-/** Destroys the socket.
- *
- * If the socket is bound, the port is released.
- * Releases all buffered packets, calls the release function and removes the
- * socket from the local sockets.
- *
- * @param[in] packet_phone The packet server phone to release buffered packets.
- * @param[in] socket	The socket to be destroyed.
- * @param[in,out] local_sockets The local sockets to be updated.
- * @param[in,out] global_sockets The global sockets to be updated.
- * @param[in] socket_release The client release callback function.
- */
-static void
-socket_destroy_core(int packet_phone, socket_core_ref socket,
-    socket_cores_ref local_sockets, socket_ports_ref global_sockets,
-    void (* socket_release)(socket_core_ref socket))
-{
-	int packet_id;
-
-	// if bound
-	if (socket->port) {
-		// release the port
-		socket_port_release(global_sockets, socket);
-	}
-	
-	// release all received packets
-	while ((packet_id = dyn_fifo_pop(&socket->received)) >= 0)
-		pq_release_remote(packet_phone, packet_id);
-
-	dyn_fifo_destroy(&socket->received);
-	dyn_fifo_destroy(&socket->accepted);
-
-	if (socket_release)
-		socket_release(socket);
-
-	socket_cores_exclude(local_sockets, socket->socket_id);
-}
-
-/** Destroys local sockets.
- *
- * Releases all buffered packets and calls the release function for each of the
- * sockets.
- *
- * @param[in] packet_phone The packet server phone to release buffered packets.
- * @param[in] local_sockets The local sockets to be destroyed.
- * @param[in,out] global_sockets The global sockets to be updated.
- * @param[in] socket_release The client release callback function.
- */
-void
-socket_cores_release(int packet_phone, socket_cores_ref local_sockets,
-    socket_ports_ref global_sockets,
-    void (* socket_release)(socket_core_ref socket))
-{
-	int index;
-
-	if (!socket_cores_is_valid(local_sockets))
-		return;
-
-	local_sockets->magic = 0;
-
-	for (index = 0; index < local_sockets->next; ++index) {
-		if (socket_cores_item_is_valid(&local_sockets->items[index])) {
-			local_sockets->items[index].magic = 0;
-
-			if (local_sockets->items[index].value) {
-				socket_destroy_core(packet_phone,
-				    local_sockets->items[index].value,
-				    local_sockets, global_sockets,
-				    socket_release);
-				free(local_sockets->items[index].value);
-				local_sockets->items[index].value = NULL;
-			}
-		}
-	}
-
-	free(local_sockets->items);
-}
-
-/** Adds the socket to a socket port.
- *
- * @param[in,out] socket_port The socket port structure.
- * @param[in] socket	The socket to be added.
- * @param[in] key	The socket key identifier.
- * @param[in] key_length The socket key length.
- * @returns		EOK on success.
- * @returns		ENOMEM if there is not enough memory left.
- */
-static int
-socket_port_add_core(socket_port_ref socket_port, socket_core_ref socket,
-    const char *key, size_t key_length)
-{
-	ERROR_DECLARE;
-
-	socket_core_ref *socket_ref;
-
-	// create a wrapper
-	socket_ref = malloc(sizeof(*socket_ref));
-	if (!socket_ref)
-		return ENOMEM;
-
-	*socket_ref = socket;
-	// add the wrapper
-	if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key,
-	    key_length, socket_ref))) {
-		free(socket_ref);
-		return ERROR_CODE;
-	}
-	
-	++socket_port->count;
-	socket->key = key;
-	socket->key_length = key_length;
-	
-	return EOK;
-}
-
-/** Binds the socket to the port.
- *
- * The SOCKET_MAP_KEY_LISTENING key identifier is used.
- *
- * @param[in] global_sockets The global sockets to be updated.
- * @param[in] socket	The socket to be added.
- * @param[in] port	The port number to be bound to.
- * @returns		EOK on success.
- * @returns		ENOMEM if there is not enough memory left.
- * @returns		Other error codes as defined for the
- *			 socket_ports_add() function.
- */
-static int
-socket_bind_insert(socket_ports_ref global_sockets, socket_core_ref socket,
-    int port)
-{
-	ERROR_DECLARE;
-
-	socket_port_ref socket_port;
-
-	// create a wrapper
-	socket_port = malloc(sizeof(*socket_port));
-	if (!socket_port)
-		return ENOMEM;
-
-	socket_port->count = 0;
-	if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) ||
-	    ERROR_OCCURRED(socket_port_add_core(socket_port, socket,
-	    SOCKET_MAP_KEY_LISTENING, 0))) {
-		socket_port_map_destroy(&socket_port->map);
-		free(socket_port);
-		return ERROR_CODE;
-	}
-	
-	// register the incomming port
-	ERROR_CODE = socket_ports_add(global_sockets, port, socket_port);
-	if (ERROR_CODE < 0) {
-		socket_port_map_destroy(&socket_port->map);
-		free(socket_port);
-		return ERROR_CODE;
-	}
-	
-	socket->port = port;
-	return EOK;
-}
-
-/** Binds the socket to the port.
- *
- * The address port is used if set, a free port is used if not.
- *
- * @param[in] local_sockets The local sockets to be searched.
- * @param[in,out] global_sockets The global sockets to be updated.
- * @param[in] socket_id	The new socket identifier.
- * @param[in] addr	The address to be bound to.
- * @param[in] addrlen	The address length.
- * @param[in] free_ports_start The minimum free port.
- * @param[in] free_ports_end The maximum free port.
- * @param[in] last_used_port The last used free port.
- * @returns		EOK on success.
- * @returns		ENOTSOCK if the socket was not found.
- * @returns		EAFNOSUPPORT if the address family is not supported.
- * @returns		EADDRINUSE if the port is already in use.
- * @returns		Other error codes as defined for the
- *			socket_bind_free_port() function.
- * @returns		Other error codes as defined for the
- *			socket_bind_insert() function.
- */
-int
-socket_bind(socket_cores_ref local_sockets, socket_ports_ref global_sockets,
-    int socket_id, void *addr, size_t addrlen, int free_ports_start,
-    int free_ports_end, int last_used_port)
-{
-	socket_core_ref socket;
-	socket_port_ref socket_port;
-	struct sockaddr *address;
-	struct sockaddr_in *address_in;
-
-	if (addrlen < sizeof(struct sockaddr))
-		return EINVAL;
-
-	address = (struct sockaddr *) addr;
-	switch (address->sa_family) {
-	case AF_INET:
-		if (addrlen != sizeof(struct sockaddr_in))
-			return EINVAL;
-		
-		address_in = (struct sockaddr_in *) addr;
-		// find the socket
-		socket = socket_cores_find(local_sockets, socket_id);
-		if (!socket)
-			return ENOTSOCK;
-		
-		// bind a free port?
-		if (address_in->sin_port <= 0)
-			return socket_bind_free_port(global_sockets, socket,
-			     free_ports_start, free_ports_end, last_used_port);
-		
-		// try to find the port
-		socket_port = socket_ports_find(global_sockets,
-		    ntohs(address_in->sin_port));
-		if (socket_port) {
-			// already used
-			return EADDRINUSE;
-		}
-		
-		// if bound
-		if (socket->port) {
-			// release the port
-			socket_port_release(global_sockets, socket);
-		}
-		socket->port = -1;
-		
-		return socket_bind_insert(global_sockets, socket,
-		    ntohs(address_in->sin_port));
-		
-	case AF_INET6:
-		// TODO IPv6
-		break;
-	}
-	
-	return EAFNOSUPPORT;
-}
-
-/** Binds the socket to a free port.
- *
- * The first free port is used.
- *
- * @param[in,out] global_sockets The global sockets to be updated.
- * @param[in,out] socket The socket to be bound.
- * @param[in] free_ports_start The minimum free port.
- * @param[in] free_ports_end The maximum free port.
- * @param[in] last_used_port The last used free port.
- * @returns		EOK on success.
- * @returns		ENOTCONN if no free port was found.
- * @returns		Other error codes as defined for the
- *			socket_bind_insert() function.
- */
-int
-socket_bind_free_port(socket_ports_ref global_sockets, socket_core_ref socket,
-    int free_ports_start, int free_ports_end, int last_used_port)
-{
-	int index;
-
-	// from the last used one
-	index = last_used_port;
-	
-	do {
-		++index;
-		
-		// til the range end
-		if (index >= free_ports_end) {
-			// start from the range beginning
-			index = free_ports_start - 1;
-			do {
-				++index;
-				// til the last used one
-				if (index >= last_used_port) {
-					// none found
-					return ENOTCONN;
-				}
-			} while (socket_ports_find(global_sockets, index));
-			
-			// found, break immediately
-			break;
-		}
-		
-	} while (socket_ports_find(global_sockets, index));
-	
-	return socket_bind_insert(global_sockets, socket, index);
-}
-
-/** Tries to find a new free socket identifier.
- *
- * @param[in] local_sockets The local sockets to be searched.
- * @param[in] positive	A value indicating whether a positive identifier is
- *			requested. A negative identifier is requested if set to
- *			false.
- * @returns		The new socket identifier.
- * @returns		ELIMIT if there is no socket identifier available.
- */
-static int socket_generate_new_id(socket_cores_ref local_sockets, int positive)
-{
-	int socket_id;
-	int count;
-
-	count = 0;
-//	socket_id = socket_globals.last_id;
-	do {
-		if (count < SOCKET_ID_TRIES) {
-			socket_id = rand() % INT_MAX;
-			++count;
-		} else if (count == SOCKET_ID_TRIES) {
-			socket_id = 1;
-			++count;
-		// only this branch for last_id
-		} else {
-			if (socket_id < INT_MAX) {
-				++ socket_id;
-/*			} else if(socket_globals.last_id) {
-*				socket_globals.last_id = 0;
-*				socket_id = 1;
-*/			} else {
-				return ELIMIT;
-			}
-		}
-	} while (socket_cores_find(local_sockets,
-	    ((positive ? 1 : -1) * socket_id)));
-	
-//	last_id = socket_id
-	return socket_id;
-}
-
-/** Creates a new socket.
- *
- * @param[in,out] local_sockets The local sockets to be updated.
- * @param[in] app_phone	The application phone.
- * @param[in] specific_data The socket specific data.
- * @param[in,out] socket_id The new socket identifier. A new identifier is
- *			chosen if set to zero or negative. A negative identifier
- *			is chosen if set to negative.
- * @returns		EOK on success.
- * @returns		EINVAL if the socket_id parameter is NULL.
- * @returns		ENOMEM if there is not enough memory left.
- */
-int
-socket_create(socket_cores_ref local_sockets, int app_phone,
-    void *specific_data, int *socket_id)
-{
-	ERROR_DECLARE;
-
-	socket_core_ref socket;
-	int res;
-	int positive;
-
-	if (!socket_id)
-		return EINVAL;
-	
-	// store the socket
-	if (*socket_id <= 0) {
-		positive = (*socket_id == 0);
-		*socket_id = socket_generate_new_id(local_sockets, positive);
-		if (*socket_id <= 0)
-			return *socket_id;
-		if (!positive)
-			*socket_id *= -1;
-	} else if(socket_cores_find(local_sockets, *socket_id)) {
-		return EEXIST;
-	}
-	
-	socket = (socket_core_ref) malloc(sizeof(*socket));
-	if (!socket)
-		return ENOMEM;
-	
-	// initialize
-	socket->phone = app_phone;
-	socket->port = -1;
-	socket->key = NULL;
-	socket->key_length = 0;
-	socket->specific_data = specific_data;
-	if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,
-	    SOCKET_INITIAL_RECEIVED_SIZE))) {
-		free(socket);
-		return ERROR_CODE;
-	}
-	if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted,
-	    SOCKET_INITIAL_ACCEPTED_SIZE))) {
-		dyn_fifo_destroy(&socket->received);
-		free(socket);
-		return ERROR_CODE;
-	}
-	socket->socket_id = *socket_id;
-	res = socket_cores_add(local_sockets, socket->socket_id, socket);
-	if (res < 0) {
-		dyn_fifo_destroy(&socket->received);
-		dyn_fifo_destroy(&socket->accepted);
-		free(socket);
-		return res;
-	}
-	
-	return EOK;
-}
-
-/** Destroys the socket.
- *
- * If the socket is bound, the port is released.
- * Releases all buffered packets, calls the release function and removes the
- * socket from the local sockets.
- *
- * @param[in] packet_phone The packet server phone to release buffered packets.
- * @param[in] socket_id	The socket identifier.
- * @param[in,out] local_sockets The local sockets to be updated.
- * @param[in,out] global_sockets The global sockets to be updated.
- * @param[in] socket_release The client release callback function.
- * @returns		EOK on success.
- * @returns		ENOTSOCK if the socket is not found.
- */
-int
-socket_destroy(int packet_phone, int socket_id, socket_cores_ref local_sockets,
-    socket_ports_ref global_sockets,
-    void (*socket_release)(socket_core_ref socket))
-{
-	socket_core_ref socket;
-	int accepted_id;
-
-	// find the socket
-	socket = socket_cores_find(local_sockets, socket_id);
-	if (!socket)
-		return ENOTSOCK;
-	
-	// destroy all accepted sockets
-	while ((accepted_id = dyn_fifo_pop(&socket->accepted)) >= 0)
-		socket_destroy(packet_phone, accepted_id, local_sockets,
-		    global_sockets, socket_release);
-	
-	socket_destroy_core(packet_phone, socket, local_sockets, global_sockets,
-	    socket_release);
-	
-	return EOK;
-}
-
-/** Replies the packet or the packet queue data to the application via the
- * socket.
- *
- * Uses the current message processing fibril.
- *
- * @param[in] packet	The packet to be transfered.
- * @param[out] length	The total data length.
- * @returns		EOK on success.
- * @returns		EBADMEM if the length parameter is NULL.
- * @returns		ENOMEM if there is not enough memory left.
- * @returns		Other error codes as defined for the data_reply()
- *			function.
- */
-int socket_reply_packets(packet_t packet, size_t *length)
-{
-	ERROR_DECLARE;
-
-	packet_t next_packet;
-	size_t fragments;
-	size_t *lengths;
-	size_t index;
-
-	if (!length)
-		return EBADMEM;
-
-	next_packet = pq_next(packet);
-	if (!next_packet) {
-		// write all if only one fragment
-		ERROR_PROPAGATE(data_reply(packet_get_data(packet),
-		    packet_get_data_length(packet)));
-		// store the total length
-		*length = packet_get_data_length(packet);
-	} else {
-		// count the packet fragments
-		fragments = 1;
-		next_packet = pq_next(packet);
-		while ((next_packet = pq_next(next_packet)))
-			++fragments;
-		
-		// compute and store the fragment lengths
-		lengths = (size_t *) malloc(sizeof(size_t) * fragments +
-		    sizeof(size_t));
-		if (!lengths)
-			return ENOMEM;
-		
-		lengths[0] = packet_get_data_length(packet);
-		lengths[fragments] = lengths[0];
-		next_packet = pq_next(packet);
-		
-		for (index = 1; index < fragments; ++index) {
-			lengths[index] = packet_get_data_length(next_packet);
-			lengths[fragments] += lengths[index];
-			next_packet = pq_next(packet);
-		}
-		
-		// write the fragment lengths
-		if (ERROR_OCCURRED(data_reply(lengths,
-		    sizeof(int) * (fragments + 1)))) {
-			free(lengths);
-			return ERROR_CODE;
-		}
-		next_packet = packet;
-		
-		// write the fragments
-		for (index = 0; index < fragments; ++index) {
-			ERROR_CODE = data_reply(packet_get_data(next_packet),
-			    lengths[index]);
-			if (ERROR_OCCURRED(ERROR_CODE)) {
-				free(lengths);
-				return ERROR_CODE;
-			}
-			next_packet = pq_next(next_packet);
-		}
-		
-		// store the total length
-		*length = lengths[fragments];
-		free(lengths);
-	}
-	
-	return EOK;
-}
-
-/** Finds the bound port socket.
- *
- * @param[in] global_sockets The global sockets to be searched.
- * @param[in] port	The port number.
- * @param[in] key	The socket key identifier.
- * @param[in] key_length The socket key length.
- * @returns		The found socket.
- * @returns		NULL if no socket was found.
- */
-socket_core_ref
-socket_port_find(socket_ports_ref global_sockets, int port, const char *key,
-    size_t key_length)
-{
-	socket_port_ref socket_port;
-	socket_core_ref *socket_ref;
-
-	socket_port = socket_ports_find(global_sockets, port);
-	if (socket_port && (socket_port->count > 0)) {
-		socket_ref = socket_port_map_find(&socket_port->map, key,
-		    key_length);
-		if (socket_ref)
-			return *socket_ref;
-	}
-	
-	return NULL;
-}
-
-/** Releases the socket port.
- *
- * If the socket is bound the port entry is released.
- * If there are no more port entries the port is release.
- *
- * @param[in] global_sockets The global sockets to be updated.
- * @param[in] socket	The socket to be unbound.
- */
-void
-socket_port_release(socket_ports_ref global_sockets, socket_core_ref socket)
-{
-	socket_port_ref socket_port;
-	socket_core_ref *socket_ref;
-
-	if (!socket->port)
-		return;
-	
-	// find ports
-	socket_port = socket_ports_find(global_sockets, socket->port);
-	if (socket_port) {
-		// find the socket
-		socket_ref = socket_port_map_find(&socket_port->map,
-		    socket->key, socket->key_length);
-		
-		if (socket_ref) {
-			--socket_port->count;
-			
-			// release if empty
-			if (socket_port->count <= 0) {
-				// destroy the map
-				socket_port_map_destroy(&socket_port->map);
-				// release the port
-				socket_ports_exclude(global_sockets,
-				    socket->port);
-			} else {
-				// remove
-				socket_port_map_exclude(&socket_port->map,
-				    socket->key, socket->key_length);
-			}
-		}
-	}
-	
-	socket->port = 0;
-	socket->key = NULL;
-	socket->key_length = 0;
-}
-
-/** Adds the socket to an already bound port.
- *
- * @param[in] global_sockets The global sockets to be updated.
- * @param[in] port	The port number to be bound to.
- * @param[in] socket	The socket to be added.
- * @param[in] key	The socket key identifier.
- * @param[in] key_length The socket key length.
- * @returns		EOK on success.
- * @returns		ENOENT if the port is not already used.
- * @returns		Other error codes as defined for the
- *			socket_port_add_core() function.
- */
-int
-socket_port_add(socket_ports_ref global_sockets, int port,
-    socket_core_ref socket, const char *key, size_t key_length)
-{
-	ERROR_DECLARE;
-
-	socket_port_ref socket_port;
-
-	// find ports
-	socket_port = socket_ports_find(global_sockets, port);
-	if (!socket_port)
-		return ENOENT;
-	
-	// add the socket
-	ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key,
-	    key_length));
-	
-	socket->port = port;
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/net/tl/tl_common.c
===================================================================
--- uspace/lib/net/tl/tl_common.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/lib/net/tl/tl_common.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -27,47 +27,34 @@
  */
 
-/** @addtogroup libnet 
- * @{
+/** @addtogroup net_tl
+ *  @{
  */
 
 /** @file
- * Transport layer common functions implementation.
- * @see tl_common.h
- */
-
-#include <tl_common.h>
+ *  Transport layer common functions implementation.
+ *  @see tl_common.h
+ */
+
+#include <net/socket_codes.h>
+#include <net/in.h>
+#include <net/in6.h>
+#include <net/inet.h>
+#include <async.h>
+#include <ipc/services.h>
+#include <errno.h>
+#include <err.h>
+
+#include <net/packet.h>
 #include <packet_client.h>
 #include <packet_remote.h>
+#include <net/device.h>
 #include <icmp_interface.h>
 #include <ip_remote.h>
 #include <ip_interface.h>
 #include <tl_interface.h>
-
-#include <net/socket_codes.h>
-#include <net/in.h>
-#include <net/in6.h>
-#include <net/inet.h>
-#include <net/device.h>
-#include <net/packet.h>
-
-#include <async.h>
-#include <ipc/services.h>
-#include <errno.h>
-#include <err.h>
+#include <tl_common.h>
 
 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
 
-/** Gets the address port.
- *
- * Supports AF_INET and AF_INET6 address families.
- *
- * @param[in,out] addr	The address to be updated.
- * @param[in] addrlen	The address length.
- * @param[out] port	The set port.
- * @returns		EOK on success.
- * @returns		EINVAL if the address length does not match the address
- *			family.
- * @returns		EAFNOSUPPORT if the address family is not supported.
- */
 int
 tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port)
@@ -87,13 +74,11 @@
 		*port = ntohs(address_in->sin_port);
 		break;
-	
 	case AF_INET6:
 		if (addrlen != sizeof(struct sockaddr_in6))
-			return EINVAL;
+				return EINVAL;
 
 		address_in6 = (struct sockaddr_in6 *) addr;
 		*port = ntohs(address_in6->sin6_port);
 		break;
-	
 	default:
 		return EAFNOSUPPORT;
@@ -108,17 +93,17 @@
  * The reply is cached then.
  *
- * @param[in] ip_phone	The IP moduel phone for (semi)remote calls.
- * @param[in] packet_dimensions The packet dimensions cache.
- * @param[in] device_id	The device identifier.
- * @param[out] packet_dimension The IP packet dimensions.
- * @return		EOK on success.
- * @return		EBADMEM if the packet_dimension parameter is NULL.
- * @return		ENOMEM if there is not enough memory left.
- * @return		EINVAL if the packet_dimensions cache is not valid.
- * @return		Other codes as defined for the ip_packet_size_req()
- *			function.
- */
-int
-tl_get_ip_packet_dimension(int ip_phone,
+ * @param[in]  ip_phone          The IP moduel phone for (semi)remote calls.
+ * @param[in]  packet_dimensions The packet dimensions cache.
+ * @param[in]  device_id         The device identifier.
+ * @param[out] packet_dimension  The IP packet dimensions.
+ *
+ * @return EOK on success.
+ * @return EBADMEM if the packet_dimension parameter is NULL.
+ * @return ENOMEM if there is not enough memory left.
+ * @return EINVAL if the packet_dimensions cache is not valid.
+ * @return 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)
@@ -154,12 +139,4 @@
 }
 
-/** Updates IP device packet dimensions cache.
- *
- * @param[in,out] packet_dimensions The packet dimensions cache.
- * @param[in] device_id	The device identifier.
- * @param[in] content	The new maximum content size.
- * @returns		EOK on success.
- * @return		ENOENT if the packet dimension is not cached.
- */
 int
 tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions,
@@ -171,5 +148,4 @@
 	if (!packet_dimension)
 		return ENOENT;
-
 	packet_dimension->content = content;
 
@@ -184,4 +160,5 @@
 				packet_dimensions_exclude(packet_dimensions,
 				    DEVICE_INVALID_ID);
+
 		}
 	}
@@ -190,16 +167,4 @@
 }
 
-/** Sets the address port.
- *
- * Supports AF_INET and AF_INET6 address families.
- *
- * @param[in,out] addr	The address to be updated.
- * @param[in] addrlen	The address length.
- * @param[in] port	The port to be set.
- * @returns		EOK on success.
- * @returns		EINVAL if the address length does not match the address
- *			family.
- * @returns		EAFNOSUPPORT if the address family is not supported.
- */
 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port)
 {
@@ -222,5 +187,4 @@
 		address_in->sin_port = htons(port);
 		return EOK;
-	
 	case AF_INET6:
 		if (length != sizeof(struct sockaddr_in6))
@@ -229,5 +193,4 @@
 		address_in6->sin6_port = htons(port);
 		return EOK;
-	
 	default:
 		return EAFNOSUPPORT;
@@ -235,17 +198,4 @@
 }
 
-/** Prepares the packet for ICMP error notification.
- *
- * Keeps the first packet and releases all the others.
- * Releases all the packets on error.
- *
- * @param[in] packet_phone The packet server module phone.
- * @param[in] icmp_phone The ICMP module phone.
- * @param[in] packet	The packet to be send.
- * @param[in] error	The packet error reporting service. Prefixes the
- *			received packet.
- * @returns		EOK on success.
- * @returns		ENOENT if no packet may be sent.
- */
 int
 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet,
@@ -273,18 +223,4 @@
 }
 
-/** Receives data from the socket into a packet.
- *
- * @param[in] packet_phone The packet server module phone.
- * @param[out] packet	The new created packet.
- * @param[in] prefix	Reserved packet data prefix length.
- * @param[in] dimension	The packet dimension.
- * @param[in] addr	The destination address.
- * @param[in] addrlen	The address length.
- * @returns		Number of bytes received.
- * @returns		EINVAL if the client does not send data.
- * @returns		ENOMEM if there is not enough memory left.
- * @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,
Index: uspace/lib/packet/include/netdb.h
===================================================================
--- uspace/lib/packet/include/netdb.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
+++ uspace/lib/packet/include/netdb.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup netdb
+ *  @{
+ */
+
+/** @file
+ *  Structures and interfaces according to the BSD netdb.h file.
+ */
+
+#ifndef __NET_NETDB_H__
+#define __NET_NETDB_H__
+
+#include <sys/types.h>
+
+/** Structure returned by network data base library.
+ *  All addresses are supplied in host order, and returned in network order (suitable for use in system calls).
+ */
+struct	hostent {
+	/** Official host name.
+	 */
+	char * h_name;
+	/** Alias list.
+	 */
+	char **	h_aliases;
+	/** Host address type.
+	 */
+	int h_addrtype;
+	/** Address length.
+	 */
+	int h_length;
+	/** List of addresses from name server.
+	 */
+	char **	h_addr_list;
+	/** Address, for backward compatiblity.
+	 */
+#define	h_addr	h_addr_list[0]
+};
+
+/** @name Host entry address types definitions.
+ */
+/*@{*/
+
+/** Authoritative Answer Host not found address type.
+ */
+#define	HOST_NOT_FOUND	1
+
+/** Non-Authoritive Host not found, or SERVERFAIL address type.
+ */
+#define	TRY_AGAIN	2
+
+/** Non recoverable errors, FORMERR, REFUSED, NOTIMP address type.
+ */
+#define	NO_RECOVERY	3
+
+/** Valid name, no data record of requested type address type.
+ */
+#define	NO_DATA		4
+
+/** No address, look for MX record address type.
+ */
+#define	NO_ADDRESS	NO_DATA
+
+/*@}*/
+
+/** Returns host entry by the host address.
+ *  @param[in] address The host address.
+ *  @param[in] len The address length.
+ *  @param[in] type The address type.
+ *  @returns Host entry information.
+ */
+//struct hostent *	gethostbyaddr(const void * address, int len, int type);
+
+/** Returns host entry by the host name.
+ *  @param[in] name The host name.
+ *  @returns Host entry information.
+ */
+//struct hostent *	gethostbyname(const char * name);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/packet/include/tcp_codes.h
===================================================================
--- uspace/lib/packet/include/tcp_codes.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
+++ uspace/lib/packet/include/tcp_codes.h	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup tcp
+ *  @{
+ */
+
+/** @file
+ *  TCP options definitions.
+ */
+
+#ifndef __NET_TCP_CODES_H__
+#define __NET_TCP_CODES_H__
+
+/** End of list TCP option.
+ */
+#define TCPOPT_END_OF_LIST				0x0
+
+/** No operation TCP option.
+ */
+#define TCPOPT_NO_OPERATION				0x1
+
+/** Maximum segment size TCP option.
+ */
+#define TCPOPT_MAX_SEGMENT_SIZE			0x2
+
+/** Maximum segment size TCP option length.
+ */
+#define TCPOPT_MAX_SEGMENT_SIZE_LENGTH	4
+
+/** Window scale TCP option.
+ */
+#define TCPOPT_WINDOW_SCALE				0x3
+
+/** Window scale TCP option length.
+ */
+#define TCPOPT_WINDOW_SCALE_LENGTH		3
+
+/** Selective acknowledgement permitted TCP option.
+ */
+#define TCPOPT_SACK_PERMITTED			0x4
+
+/** Selective acknowledgement permitted TCP option length.
+ */
+#define TCPOPT_SACK_PERMITTED_LENGTH	2
+
+/** Selective acknowledgement TCP option.
+ *  Has variable length.
+ */
+#define TCPOPT_SACK						0x5
+
+/** Timestamp TCP option.
+ */
+#define TCPOPT_TIMESTAMP				0x8
+
+/** Timestamp TCP option length.
+ */
+#define TCPOPT_TIMESTAMP_LENGTH			10
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/il/arp/arp_module.c
===================================================================
--- uspace/srv/net/il/arp/arp_module.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/srv/net/il/arp/arp_module.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -57,8 +57,23 @@
 extern arp_globals_t	arp_globals;
 
+/** Processes the ARP message.
+ *  @param[in] callid The message identifier.
+ *  @param[in] call The message parameters.
+ *  @param[out] answer The message answer parameters.
+ *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the arp_message() function.
+ */
 int il_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
 	return arp_message_standalone(callid, call, answer, answer_count);
 }
 
+/** Starts the ARP module.
+ *  Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
+ *  @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
+ *  @returns EOK on successful module termination.
+ *  @returns Other error codes as defined for the arp_initialize() function.
+ *  @returns Other error codes as defined for the REGISTER_ME() macro function.
+ */
 int il_module_start_standalone(async_client_conn_t client_connection){
 	ERROR_DECLARE;
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/srv/net/il/ip/ip.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -67,5 +67,4 @@
 #include <ip_client.h>
 #include <ip_interface.h>
-#include <ip_header.h>
 #include <net_interface.h>
 #include <nil_interface.h>
@@ -78,4 +77,5 @@
 
 #include "ip.h"
+#include "ip_header.h"
 #include "ip_module.h"
 #include "ip_local.h"
Index: uspace/srv/net/il/ip/ip_module.c
===================================================================
--- uspace/srv/net/il/ip/ip_module.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/srv/net/il/ip/ip_module.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -56,8 +56,23 @@
 extern ip_globals_t ip_globals;
 
+/** Processes the IP message.
+ *  @param[in] callid The message identifier.
+ *  @param[in] call The message parameters.
+ *  @param[out] answer The message answer parameters.
+ *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the ip_message() function.
+ */
 int il_module_message_standalone(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
 	return ip_message_standalone(callid, call, answer, answer_count);
 }
 
+/** Starts the IP module.
+ *  Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
+ *  @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
+ *  @returns EOK on successful module termination.
+ *  @returns Other error codes as defined for the ip_initialize() function.
+ *  @returns Other error codes as defined for the REGISTER_ME() macro function.
+ */
 int il_module_start_standalone(async_client_conn_t client_connection){
 	ERROR_DECLARE;
Index: uspace/srv/net/nil/eth/eth_module.c
===================================================================
--- uspace/srv/net/nil/eth/eth_module.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/srv/net/nil/eth/eth_module.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -50,4 +50,12 @@
 #include "eth.h"
 
+/** Starts the Ethernet module.
+ *  Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
+ *  @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the pm_init() function.
+ *  @returns Other error codes as defined for the nil_initialize() function.
+ *  @returns Other error codes as defined for the REGISTER_ME() macro function.
+ */
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
@@ -71,4 +79,19 @@
 }
 
+/** Pass the parameters to the module specific nil_message() function.
+ *
+ * @param[in]  name         Module name.
+ * @param[in]  callid       The message identifier.
+ * @param[in]  call         The message parameters.
+ * @param[out] answer       The message answer parameters.
+ * @param[out] answer_count The last parameter for the actual answer
+ *                          in the answer parameter.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for each
+ *         specific module message function.
+ *
+ */
 int nil_module_message_standalone(const char *name, ipc_callid_t callid, ipc_call_t *call,
     ipc_call_t *answer, int *answer_count)
Index: uspace/srv/net/nil/nildummy/nildummy_module.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 1b11576d37f42974be6406260fc3bcf888c2e19d)
+++ uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 58b833c28450decc06c7a346badd4976170e6cda)
@@ -50,4 +50,20 @@
 #include "nildummy.h"
 
+/** Start the dummy nil module.
+ *
+ * Initialize the client connection serving function, initialize
+ * the module, register the module service and start the async
+ * manager, processing IPC messages in an infinite loop.
+ *
+ * @param[in] client_connection The client connection processing
+ *                              function. The module skeleton propagates
+ *                              its own one.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for the pm_init() function.
+ * @return Other error codes as defined for the nil_initialize() function.
+ * @return Other error codes as defined for the REGISTER_ME() macro function.
+ *
+ */
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
@@ -71,4 +87,19 @@
 }
 
+/** Pass the parameters to the module specific nil_message() function.
+ *
+ * @param[in]  name         Module name.
+ * @param[in]  callid       The message identifier.
+ * @param[in]  call         The message parameters.
+ * @param[out] answer       The message answer parameters.
+ * @param[out] answer_count The last parameter for the actual answer
+ *                          in the answer parameter.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for each specific
+ *          module message function.
+ *
+ */
 int nil_module_message_standalone(const char *name, ipc_callid_t callid,
     ipc_call_t *call, ipc_call_t *answer, int *answer_count)
