Index: uspace/lib/net/Makefile
===================================================================
--- uspace/lib/net/Makefile	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/Makefile	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# 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.
+#
+
+USPACE_PREFIX = ../..
+EXTRA_CFLAGS = -Iinclude -I$(LIBSOCKET_PREFIX)/include
+LIBRARY = libnet
+
+SOURCES = \
+	generic/net_remote.c \
+	generic/net_checksum.c \
+	generic/packet_remote.c \
+	adt/module_map.c \
+	netif/netif.c \
+	netif/netif_standalone.c \
+	netif/netif_nil_bundle.c \
+	nil/nil_remote.c \
+	il/ip_remote.c \
+	il/ip_client.c \
+	il/arp_remote.c \
+	tl/icmp_remote.c \
+	tl/icmp_client.c \
+	tl/tl_common.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/net/adt/module_map.c
===================================================================
--- uspace/lib/net/adt/module_map.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/adt/module_map.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,108 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Character string to module map implementation.
+ */
+
+#include <malloc.h>
+#include <task.h>
+#include <unistd.h>
+
+#include <ipc/services.h>
+
+#include <net_err.h>
+#include <net_modules.h>
+
+#include <adt/generic_char_map.h>
+#include <adt/module_map.h>
+
+GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t)
+
+int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t connect_module){
+	ERROR_DECLARE;
+
+	module_ref tmp_module;
+
+	tmp_module = (module_ref) malloc(sizeof(module_t));
+	if(! tmp_module){
+		return ENOMEM;
+	}
+	tmp_module->task_id = task_id;
+	tmp_module->phone = 0;
+	tmp_module->usage = 0;
+	tmp_module->name = name;
+	tmp_module->filename = filename;
+	tmp_module->service = service;
+	tmp_module->connect_module = connect_module;
+	if(ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, tmp_module))){
+		free(tmp_module);
+		return ERROR_CODE;
+	}
+	if(module){
+		*module = tmp_module;
+	}
+	return EOK;
+}
+
+module_ref get_running_module(modules_ref modules, char * name){
+	module_ref module;
+
+	module = modules_find(modules, name, 0);
+	if(! module){
+		return NULL;
+	}
+	if(! module->task_id){
+		module->task_id = spawn(module->filename);
+		if(! module->task_id){
+			return NULL;
+		}
+	}
+	if(! module->phone){
+		module->phone = module->connect_module(module->service);
+	}
+	return module;
+}
+
+task_id_t spawn(const char * fname){
+	const char * argv[2];
+	task_id_t res;
+
+	argv[0] = fname;
+	argv[1] = NULL;
+	res = task_spawn(fname, argv);
+
+	return res;
+}
+
+/** @}
+ */
Index: uspace/lib/net/generic/net_checksum.c
===================================================================
--- uspace/lib/net/generic/net_checksum.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/generic/net_checksum.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,171 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  General CRC and checksum computation implementation.
+ */
+
+#include <sys/types.h>
+
+#include <net_checksum.h>
+
+/** Big-endian encoding CRC divider.
+ */
+#define CRC_DIVIDER_BE	0x04C11DB7
+
+/** Little-endian encoding CRC divider.
+ */
+#define CRC_DIVIDER_LE	0xEDB88320
+
+uint16_t compact_checksum(uint32_t sum){
+	// shorten to the 16 bits
+	while(sum >> 16){
+		sum = (sum &0xFFFF) + (sum >> 16);
+	}
+
+	return (uint16_t) sum;
+}
+
+uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length){
+	size_t index;
+
+	// sum all the 16 bit fields
+	for(index = 0; index + 1 < length; index += 2){
+		seed += (data[index] << 8) + data[index + 1];
+	}
+
+	// last odd byte with zero padding
+	if(index + 1 == length){
+		seed += data[index] << 8;
+	}
+
+	return seed;
+}
+
+uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length){
+	size_t index;
+
+	// process full bytes
+	while(length >= 8){
+		// add the data
+		seed ^= (*data) << 24;
+		// for each added bit
+		for(index = 0; index < 8; ++ index){
+			// if the first bit is set
+			if(seed &0x80000000){
+				// shift and divide the checksum
+				seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
+			}else{
+				// shift otherwise
+				seed <<= 1;
+			}
+		}
+		// move to the next byte
+		++ data;
+		length -= 8;
+	}
+
+	// process the odd bits
+	if(length > 0){
+		// add the data with zero padding
+		seed ^= ((*data) &(0xFF << (8 - length))) << 24;
+		// for each added bit
+		for(index = 0; index < length; ++ index){
+			// if the first bit is set
+			if(seed &0x80000000){
+				// shift and divide the checksum
+				seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE);
+			}else{
+				// shift otherwise
+				seed <<= 1;
+			}
+		}
+	}
+
+	return seed;
+}
+
+uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length){
+	size_t index;
+
+	// process full bytes
+	while(length >= 8){
+		// add the data
+		seed ^= (*data);
+		// for each added bit
+		for(index = 0; index < 8; ++ index){
+			// if the last bit is set
+			if(seed &1){
+				// shift and divide the checksum
+				seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
+			}else{
+				// shift otherwise
+				seed >>= 1;
+			}
+		}
+		// move to the next byte
+		++ data;
+		length -= 8;
+	}
+
+	// process the odd bits
+	if(length > 0){
+		// add the data with zero padding
+		seed ^= (*data) >> (8 - length);
+		for(index = 0; index < length; ++ index){
+			// if the last bit is set
+			if(seed &1){
+				// shift and divide the checksum
+				seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE);
+			}else{
+				// shift otherwise
+				seed >>= 1;
+			}
+		}
+	}
+
+	return seed;
+}
+
+uint16_t flip_checksum(uint16_t checksum){
+	// flip, zero is returned as 0xFFFF (not flipped)
+	checksum = ~ checksum;
+	return checksum ? checksum : IP_CHECKSUM_ZERO;
+}
+
+uint16_t ip_checksum(uint8_t * data, size_t length){
+	// compute, compact and flip the data checksum
+	return flip_checksum(compact_checksum(compute_checksum(0, data, length)));
+}
+
+/** @}
+ */
Index: uspace/lib/net/generic/net_remote.c
===================================================================
--- uspace/lib/net/generic/net_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/generic/net_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,71 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Networking interface implementation for standalone remote modules.
+ *  @see net_interface.h
+ */
+
+#include <ipc/services.h>
+
+#include <malloc.h>
+
+#include <net_messages.h>
+#include <net_modules.h>
+#include <net_device.h>
+#include <net_interface.h>
+#include <adt/measured_strings.h>
+#include <net_net_messages.h>
+
+int net_connect_module(services_t service){
+	return connect_to_service(SERVICE_NETWORKING);
+}
+
+void net_free_settings(measured_string_ref settings, char * data){
+	if(settings){
+		free(settings);
+	}
+	if(data){
+		free(data);
+	}
+}
+
+int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data){
+	return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, * configuration, count, configuration, data);
+}
+
+int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data){
+	return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, device_id, 0, * configuration, count, configuration, data);
+}
+
+/** @}
+ */
Index: uspace/lib/net/generic/packet_remote.c
===================================================================
--- uspace/lib/net/generic/packet_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/generic/packet_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,143 @@
+/*
+ * 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 packet
+ *  @{
+ */
+
+/** @file
+ *  Packet client interface implementation for standalone remote modules.
+ *  @see packet_client.h
+ */
+
+#include <async.h>
+#include <errno.h>
+#include <ipc/ipc.h>
+#include <sys/mman.h>
+
+#include <net_err.h>
+#include <net_messages.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <packet/packet_header.h>
+#include <packet/packet_messages.h>
+
+/** Obtains the packet from the packet server as the shared memory block.
+ *  Creates the local packet mapping as well.
+ *  @param[in] phone The packet server module phone.
+ *  @param[out] packet The packet reference pointer to store the received packet reference.
+ *  @param[in] packet_id The packet identifier.
+ *  @param[in] size The packet total size in bytes.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the pm_add() function.
+ *  @returns Other error codes as defined for the async_share_in_start() function.
+ */
+int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size);
+
+int packet_translate(int phone, packet_ref packet, packet_id_t packet_id){
+	ERROR_DECLARE;
+
+	ipcarg_t size;
+	packet_t next;
+
+	if(! packet){
+		return EINVAL;
+	}
+	*packet = pm_find(packet_id);
+	if(!(*packet)){
+		ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
+		ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
+	}
+	if((** packet).next){
+		return packet_translate(phone, &next, (** packet).next);
+	}else return EOK;
+}
+
+int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
+	ERROR_DECLARE;
+
+	aid_t message;
+	ipc_call_t answer;
+	ipcarg_t result;
+
+	message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
+	*packet = (packet_t) as_get_mappable_page(size);
+	if(ERROR_OCCURRED(async_share_in_start_0_0(phone, * packet, size))
+		|| ERROR_OCCURRED(pm_add(*packet))){
+		munmap(*packet, size);
+		async_wait_for(message, NULL);
+		return ERROR_CODE;
+	}
+	async_wait_for(message, &result);
+	return result;
+}
+
+packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){
+	ERROR_DECLARE;
+
+	ipcarg_t packet_id;
+	ipcarg_t size;
+	packet_t packet;
+
+	if(ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))){
+		return NULL;
+	}
+	packet = pm_find(packet_id);
+	if(! packet){
+		if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
+			return NULL;
+		}
+	}
+	return packet;
+}
+
+packet_t packet_get_1(int phone, size_t content){
+	ERROR_DECLARE;
+
+	ipcarg_t packet_id;
+	ipcarg_t size;
+	packet_t packet;
+
+	if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){
+		return NULL;
+	}
+	packet = pm_find(packet_id);
+	if(! packet){
+		if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
+			return NULL;
+		}
+	}
+	return packet;
+}
+
+void pq_release(int phone, packet_id_t packet_id){
+	async_msg_1(phone, NET_PACKET_RELEASE, packet_id);
+}
+
+/** @}
+ */
Index: uspace/lib/net/il/arp_remote.c
===================================================================
--- uspace/lib/net/il/arp_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/il/arp_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,94 @@
+/*
+ * 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 arp
+ *  @{
+ */
+
+/** @file
+ *  ARP interface implementation for standalone remote modules.
+ *  @see arp_interface.h
+ */
+
+#include <async.h>
+#include <errno.h>
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+
+#include <net_messages.h>
+#include <net_modules.h>
+#include <net_device.h>
+#include <arp_interface.h>
+#include <adt/measured_strings.h>
+#include <arp_messages.h>
+
+int arp_connect_module(services_t service){
+	if(service != SERVICE_ARP){
+		return EINVAL;
+	}
+	return connect_to_service(SERVICE_ARP);
+}
+
+int arp_clean_cache_req(int arp_phone){
+	return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
+}
+
+int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){
+	aid_t message_id;
+	ipcarg_t result;
+
+	message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, (ipcarg_t) device_id, protocol, NULL);
+	measured_strings_send(arp_phone, address, 1);
+	async_wait_for(message_id, &result);
+	return (int) result;
+}
+
+int arp_clear_device_req(int arp_phone, device_id_t device_id){
+	return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id);
+}
+
+int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
+	aid_t message_id;
+	ipcarg_t result;
+
+	message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL);
+	measured_strings_send(arp_phone, address, 1);
+	async_wait_for(message_id, &result);
+	return (int) result;
+}
+
+task_id_t arp_task_get_id(void){
+	return 0;
+}
+
+int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
+	return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data);
+}
+
+/** @}
+ */
Index: uspace/lib/net/il/ip_client.c
===================================================================
--- uspace/lib/net/il/ip_client.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/il/ip_client.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,184 @@
+/*
+ * 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 ip
+ *  @{
+ */
+
+/** @file
+ *  IP client interface implementation.
+ *  @see ip_client.h
+ */
+
+#include <errno.h>
+#include <sys/types.h>
+
+#include <ip_client.h>
+#include <socket_errno.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <ip_header.h>
+
+size_t ip_client_header_length(packet_t packet){
+	ip_header_ref header;
+
+	header = (ip_header_ref) packet_get_data(packet);
+	if((! header)
+		|| (packet_get_data_length(packet) < sizeof(ip_header_t))){
+		return 0;
+	}
+	return IP_HEADER_LENGTH(header);
+}
+
+int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, ip_pseudo_header_ref * header, size_t * headerlen){
+	ipv4_pseudo_header_ref header_in;
+	struct sockaddr_in * address_in;
+
+	if(!(header && headerlen)){
+		return EBADMEM;
+	}
+	if(!(src && dest && (srclen > 0) && ((size_t) srclen >= sizeof(struct sockaddr)) && (srclen == destlen) && (src->sa_family == dest->sa_family))){
+		return EINVAL;
+	}
+
+	switch(src->sa_family){
+		case AF_INET:
+			if(srclen != sizeof(struct sockaddr_in)){
+				return EINVAL;
+			}
+			*headerlen = sizeof(*header_in);
+			header_in = (ipv4_pseudo_header_ref) malloc(*headerlen);
+			if(! header_in){
+				return ENOMEM;
+			}
+			bzero(header_in, * headerlen);
+			address_in = (struct sockaddr_in *) dest;
+			header_in->destination_address = address_in->sin_addr.s_addr;
+			address_in = (struct sockaddr_in *) src;
+			header_in->source_address = address_in->sin_addr.s_addr;
+			header_in->protocol = protocol;
+			header_in->data_length = htons(data_length);
+			*header = (ip_pseudo_header_ref) header_in;
+			return EOK;
+		// TODO IPv6
+/*		case AF_INET6:
+			if(addrlen != sizeof(struct sockaddr_in6)){
+				return EINVAL;
+			}
+			address_in6 = (struct sockaddr_in6 *) addr;
+			return EOK;
+*/		default:
+			return EAFNOSUPPORT;
+	}
+}
+
+int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length){
+	ip_header_ref header;
+	uint8_t * data;
+	size_t padding;
+
+	// compute the padding if IP options are set
+	// multiple of 4 bytes
+	padding =  ipopt_length % 4;
+	if(padding){
+		padding = 4 - padding;
+		ipopt_length += padding;
+	}
+
+	// prefix the header
+	data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding);
+	if(! data){
+		return ENOMEM;
+	}
+
+	// add the padding
+	while(padding --){
+		data[sizeof(ip_header_t) + padding] = IPOPT_NOOP;
+	}
+
+	// set the header
+	header = (ip_header_ref) data;
+	header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length);
+	header->ttl = (ttl ? ttl : IPDEFTTL); //(((ttl) <= MAXTTL) ? ttl : MAXTTL) : IPDEFTTL;
+	header->tos = tos;
+	header->protocol = protocol;
+
+	if(dont_fragment){
+		header->flags = IPFLAG_DONT_FRAGMENT;
+	}
+	return EOK;
+}
+
+int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length){
+	ip_header_ref header;
+
+	header = (ip_header_ref) packet_get_data(packet);
+	if((! header)
+		|| (packet_get_data_length(packet) < sizeof(ip_header_t))){
+		return ENOMEM;
+	}
+
+	if(protocol){
+		*protocol = header->protocol;
+	}
+	if(ttl){
+		*ttl = header->ttl;
+	}
+	if(tos){
+		*tos = header->tos;
+	}
+	if(dont_fragment){
+		*dont_fragment = header->flags &IPFLAG_DONT_FRAGMENT;
+	}
+	if(ipopt_length){
+		*ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t);
+		return sizeof(ip_header_t);
+	}else{
+		return IP_HEADER_LENGTH(header);
+	}
+}
+
+int ip_client_set_pseudo_header_data_length(ip_pseudo_header_ref header, size_t headerlen, size_t data_length){
+	ipv4_pseudo_header_ref header_in;
+
+	if(! header){
+		return EBADMEM;
+	}
+
+	if(headerlen == sizeof(ipv4_pseudo_header_t)){
+		header_in = (ipv4_pseudo_header_ref) header;
+		header_in->data_length = htons(data_length);
+		return EOK;
+	// TODO IPv6
+	}else{
+		return EINVAL;
+	}
+}
+
+/** @}
+ */
Index: uspace/lib/net/il/ip_remote.c
===================================================================
--- uspace/lib/net/il/ip_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/il/ip_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,117 @@
+/*
+ * 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 ip
+ *  @{
+ */
+
+/** @file
+ *  IP interface implementation for standalone remote modules.
+ *  @see ip_interface.h
+ *  @see il_interface.h
+ */
+
+#include <ipc/services.h>
+
+#include <net_messages.h>
+#include <net_modules.h>
+#include <net_device.h>
+#include <inet.h>
+#include <ip_interface.h>
+#include <packet/packet_client.h>
+#include <il_messages.h>
+#include <ip_messages.h>
+
+int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){
+	return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr, (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr);
+}
+
+int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg){
+	return (int) bind_service(service, (ipcarg_t) protocol, me, service, receiver);
+}
+
+int ip_connect_module(services_t service){
+	return connect_to_service(SERVICE_IP);
+}
+
+int ip_device_req(int ip_phone, device_id_t device_id, services_t service){
+	return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service);
+}
+
+int ip_get_route_req(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref * header, size_t * headerlen){
+	aid_t message_id;
+	ipcarg_t result;
+	ipc_call_t answer;
+
+	if(!(destination && (addrlen > 0))){
+		return EINVAL;
+	}
+	if(!(device_id && header && headerlen)){
+		return EBADMEM;
+	}
+
+	*header = NULL;
+	message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE, (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)){
+		*header = (ip_pseudo_header_ref) malloc(*headerlen);
+		if(*header){
+			if(async_data_read_start(ip_phone, * header, * headerlen) != EOK){
+				free(*header);
+			}
+		}
+	}
+	async_wait_for(message_id, &result);
+
+	if((result != EOK) && (*header)){
+		free(*header);
+	}else{
+		*device_id = IPC_GET_DEVICE(&answer);
+	}
+	return (int) result;
+}
+
+int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){
+	return generic_packet_size_req(ip_phone, NET_IL_PACKET_SPACE, device_id, packet_dimension);
+}
+
+int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
+	return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id, packet_get_id(packet), target, error);
+}
+
+int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){
+	return generic_send_msg(ip_phone, NET_IL_SEND, device_id, packet_get_id(packet), sender, error);
+}
+
+int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){
+	return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr);
+}
+
+/** @}
+ */
Index: uspace/lib/net/include/adt/module_map.h
===================================================================
--- uspace/lib/net/include/adt/module_map.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/adt/module_map.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,123 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Character string to module map.
+ */
+
+#ifndef __NET_MODULES_MAP_H__
+#define __NET_MODULES_MAP_H__
+
+#include <task.h>
+
+#include <ipc/services.h>
+
+#include <net_modules.h>
+
+#include <adt/generic_char_map.h>
+
+/** Type definition of the module structure.
+ *  @see module_struct
+ */
+typedef struct module_struct	module_t;
+
+/** Type definition of the module structure pointer.
+ *  @see module_struct
+ */
+typedef module_t *				module_ref;
+
+/** Module map.
+ *  Sorted by module names.
+ *  @see generic_char_map.h
+ */
+GENERIC_CHAR_MAP_DECLARE(modules, module_t)
+
+/** Module structure.
+ */
+struct	module_struct{
+	/** Module task identifier if running.
+	 */
+	task_id_t task_id;
+	/** Module service identifier.
+	 */
+	services_t service;
+	/** Module phone if running and connected.
+	 */
+	int phone;
+	/** Usage counter.
+	 */
+	int usage;
+	/** Module name.
+	 */
+	const char * name;
+	/** Module full path filename.
+	 */
+	const char * filename;
+	/** Connecting function.
+	 */
+	connect_module_t * connect_module;
+};
+
+/** Adds module to the module map.
+ *  @param[out] module The module structure added.
+ *  @param[in] modules The module map.
+ *  @param[in] name The module name.
+ *  @param[in] filename The full path filename.
+ *  @param[in] service The module service.
+ *  @param[in] task_id The module current task identifier. Zero (0) means not running.
+ *  @param[in] connect_module The module connecting function.
+ *  @returns EOK on success.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module);
+
+/** Searches and returns the specified module.
+ *  If the module is not running, the module filaname is spawned.
+ *  If the module is not connected, the connect_function is called.
+ *  @param[in] modules The module map.
+ *  @param[in] name The module name.
+ *  @returns The running module found. It does not have to be connected.
+ *  @returns NULL if there is no such module.
+ */
+module_ref get_running_module(modules_ref modules, char * name);
+
+/** Starts the given module.
+ *  @param[in] fname The module full or relative path filename.
+ *  @returns The new module task identifier on success.
+ *  @returns 0 if there is no such module.
+ */
+task_id_t spawn(const char * fname);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/arp_interface.h
===================================================================
--- uspace/lib/net/include/arp_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/arp_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,128 @@
+/*
+ * 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 arp
+ *  @{
+ */
+
+/** @file
+ *  ARP module interface.
+ *  The same interface is used for standalone remote modules as well as for bundle modules.
+ *  The standalone remote modules have to be compiled with the arp_remote.c source file.
+ *  The bundle modules with the arp.c source file.
+ */
+
+#ifndef __NET_ARP_INTERFACE_H__
+#define __NET_ARP_INTERFACE_H__
+
+#include <adt/measured_strings.h>
+#include <net_device.h>
+
+/** @name ARP module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Registers the new device and the requesting protocol service.
+ *  Connects to the network interface layer service.
+ *  Determines the device broadcast address, its address lengths and packet size.
+ *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
+ *  @param[in] device_id The new device identifier.
+ *  @param[in] protocol The requesting protocol service.
+ *  @param[in] netif The underlying device network interface layer service.
+ *  @param[in] address The local requesting protocol address of the device.
+ *  @returns EOK on success.
+ *  @returns EEXIST if the device is already used.
+ *  @returns ENOMEM if there is not enough memory left.
+ *  @returns ENOENT if the network interface service is not known.
+ *  @returns EREFUSED if the network interface service is not responding.
+ *  @returns Other error codes as defined for the nil_packet_get_size() function.
+ *  @returns Other error codes as defined for the nil_get_addr() function.
+ *  @returns Other error codes as defined for the nil_get_broadcast_addr() function.
+ */
+extern int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address);
+
+/** Translates the given protocol address to the network interface address.
+ *  Broadcasts the ARP request if the mapping is not found.
+ *  Allocates and returns the needed memory block as the data parameter.
+ *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] protocol The requesting protocol service.
+ *  @param[in] address The local requesting protocol address.
+ *  @param[out] translation The translation of the local protocol address.
+ *  @param[out] data The allocated raw translation data container.
+ *  @returns EOK on success.
+ *  @returns EINVAL if the address parameter is NULL.
+ *  @returns EBADMEM if the translation or the data parameters are NULL.
+ *  @returns ENOENT if the mapping is not found.
+ */
+extern int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data);
+
+/** Clears the device cache.
+ *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @returns EOK on success.
+ *  @returns ENOENT if the device is not found.
+ */
+extern int arp_clear_device_req(int arp_phone, device_id_t device_id);
+
+/** Clears the given protocol address from the cache.
+ *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] protocol The requesting protocol service.
+ *  @param[in] address The protocol address to be cleared.
+ *  @returns EOK on success.
+ *  @returns ENOENT if the mapping is not found.
+ */
+extern int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address);
+
+/** Cleans the cache.
+ *  @param[in] arp_phone The ARP module phone used for (semi)remote calls.
+ *  @returns EOK on success.
+ */
+extern int arp_clean_cache_req(int arp_phone);
+
+/** Connects to the ARP module.
+ *  @param service The ARP module service. Ignored parameter.
+ *  @returns The ARP module phone on success.
+ *  @returns 0 if called by the bundle module.
+ */
+extern int arp_connect_module(services_t service);
+
+/** Returns the ARP task identifier.
+ *  @returns The current task identifier if called by the bundle module.
+ *  @returns 0 if called by the remote module.
+ */
+extern task_id_t arp_task_get_id(void);
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/arp_messages.h
===================================================================
--- uspace/lib/net/include/arp_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/arp_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,85 @@
+/*
+ * 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 arp
+ *  @{
+ */
+
+/** @file
+ *  ARP module messages.
+ *  @see arp_interface.h
+ */
+
+#ifndef __NET_ARP_MESSAGES__
+#define __NET_ARP_MESSAGES__
+
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+
+/** ARP module messages.
+ */
+typedef enum{
+	/** Clean cache message.
+	 *  @see arp_clean_cache()
+	 */
+	NET_ARP_CLEAN_CACHE = NET_ARP_FIRST,
+	/** Clear address cache message.
+	 *  @see arp_clear_address_msg()
+	 */
+	NET_ARP_CLEAR_ADDRESS,
+	/** Clear device cache message.
+	 *  @see arp_clear_device_req()
+	 */
+	NET_ARP_CLEAR_DEVICE,
+	/** New device message.
+	 *  @see arp_device_req()
+	 */
+	NET_ARP_DEVICE,
+	/** Address translation message.
+	 *  @see arp_translate_req()
+	 */
+	NET_ARP_TRANSLATE
+} arp_messages;
+
+/** @name ARP specific message parameters definitions
+ */
+/*@{*/
+
+/** Returns the protocol service message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define ARP_GET_NETIF(call) \
+	({services_t service = (services_t) IPC_GET_ARG2(*call); service;})
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/ethernet_lsap.h
===================================================================
--- uspace/lib/net/include/ethernet_lsap.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/ethernet_lsap.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,137 @@
+/*
+ * 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 eth
+ *  @{
+ */
+
+/** @file
+ *  Link service access point identifiers.
+ */
+
+#ifndef __NET_ETHERNET_LSAP_H__
+#define __NET_ETHERNET_LSAP_H__
+
+#include <sys/types.h>
+
+/** Ethernet LSAP type definition.
+ */
+typedef uint8_t	eth_lsap_t;
+
+/** @name Ethernet LSAP values definitions
+ */
+/*@{*/
+
+/** Null LSAP LSAP identifier.
+ */
+#define ETH_LSAP_NULL	0x00
+/** Individual LLC Sublayer Management Function LSAP identifier.
+ */
+#define ETH_LSAP_ISLMF	0x02
+/** Group LLC Sublayer Management Function LSAP identifier.
+ */
+#define ETH_LSAP_GSLMI	0x03
+/** IBM SNA Path Control (individual) LSAP identifier.
+ */
+#define ETH_LSAP_ISNA	0x04
+/** IBM SNA Path Control (group) LSAP identifier.
+ */
+#define ETH_LSAP_GSNA	0x05
+/** ARPANET Internet Protocol (IP) LSAP identifier.
+ */
+#define ETH_LSAP_IP	0x06
+/** SNA LSAP identifier.
+ */
+#define ETH_LSAP_SNA	0x08
+/** SNA LSAP identifier.
+ */
+#define ETH_LSAP_SNA2	0x0C
+/** PROWAY (IEC955) Network Management &Initialization LSAP identifier.
+ */
+#define ETH_LSAP_PROWAY_NMI	0x0E
+/** Texas Instruments LSAP identifier.
+ */
+#define ETH_LSAP_TI	0x18
+/** IEEE 802.1 Bridge Spanning Tree Protocol LSAP identifier.
+ */
+#define ETH_LSAP_BRIDGE	0x42
+/** EIA RS-511 Manufacturing Message Service LSAP identifier.
+ */
+#define ETH_LSAP_EIS	0x4E
+/** ISO 8208 (X.25 over IEEE 802.2 Type 2 LLC) LSAP identifier.
+ */
+#define ETH_LSAP_ISO8208	0x7E
+/** Xerox Network Systems (XNS) LSAP identifier.
+ */
+#define ETH_LSAP_XNS	0x80
+/** Nestar LSAP identifier.
+ */
+#define ETH_LSAP_NESTAR	0x86
+/** PROWAY (IEC 955) Active Station List Maintenance LSAP identifier.
+ */
+#define ETH_LSAP_PROWAY_ASLM	0x8E
+/** ARPANET Address Resolution Protocol (ARP) LSAP identifier.
+ */
+#define ETH_LSAP_ARP	0x98
+/** Banyan VINES LSAP identifier.
+ */
+#define ETH_LSAP_VINES	0xBC
+/** SubNetwork Access Protocol (SNAP) LSAP identifier.
+ */
+#define ETH_LSAP_SNAP	0xAA
+/** Novell NetWare LSAP identifier.
+ */
+#define ETH_LSAP_NETWARE	0xE0
+/** IBM NetBIOS LSAP identifier.
+ */
+#define ETH_LSAP_NETBIOS	0xF0
+/** IBM LAN Management (individual) LSAP identifier.
+ */
+#define ETH_LSAP_ILAN	0xF4
+/** IBM LAN Management (group) LSAP identifier.
+ */
+#define ETH_LSAP_GLAN	0xF5
+/** IBM Remote Program Load (RPL) LSAP identifier.
+ */
+#define ETH_LSAP_RPL	0xF8
+/** Ungermann-Bass LSAP identifier.
+ */
+#define ETH_LSAP_UB	0xFA
+/** ISO Network Layer Protocol LSAP identifier.
+ */
+#define ETH_LSAP_ISONLP	0xFE
+/** Global LSAP LSAP identifier.
+ */
+#define ETH_LSAP_GLSAP	0xFF
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/ethernet_protocols.h
===================================================================
--- uspace/lib/net/include/ethernet_protocols.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/ethernet_protocols.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,1012 @@
+/*
+ * 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 eth
+ *  @{
+ */
+
+/** @file
+ *  Ethernet protocol numbers according to the on-line IANA - Ethernet numbers - <http://www.iana.org/assignments/ethernet-numbers>, cited January 17 2009.
+ */
+
+#ifndef __NET_ETHERNET_PROTOCOLS_H__
+#define __NET_ETHERNET_PROTOCOLS_H__
+
+#include <sys/types.h>
+
+/** Ethernet protocol type definition.
+ */
+typedef uint16_t	eth_type_t;
+
+/** @name Ethernet protocols definitions
+ */
+/*@{*/
+
+/** Ethernet minimal protocol number.
+ *  According to the IEEE 802.3 specification.
+ */
+#define ETH_MIN_PROTO	0x0600 /*1536*/
+
+/** Ethernet loopback packet protocol type.
+ */
+#define ETH_P_LOOP		0x0060
+
+/** XEROX PUP (see 0A00) ethernet protocol type.
+ */
+#define ETH_P_PUP		0x0200
+
+/** PUP Addr Trans (see 0A01) ethernet protocol type.
+ */
+#define ETH_P_PUPAT		0x0201
+
+/** Nixdorf ethernet protocol type.
+ */
+#define ETH_P_Nixdorf		0x0400
+
+/** XEROX NS IDP ethernet protocol type.
+ */
+#define ETH_P_XEROX_NS_IDP		0x0600
+
+/** DLOG ethernet protocol type.
+ */
+#define ETH_P_DLOG		0x0660
+
+/** DLOG ethernet protocol type.
+ */
+#define ETH_P_DLOG2		0x0661
+
+/** Internet IP (IPv4) ethernet protocol type.
+ */
+#define ETH_P_IP		0x0800
+
+/** X.75 Internet ethernet protocol type.
+ */
+#define ETH_P_X_75		0x0801
+
+/** NBS Internet ethernet protocol type.
+ */
+#define ETH_P_NBS		0x0802
+
+/** ECMA Internet ethernet protocol type.
+ */
+#define ETH_P_ECMA		0x0803
+
+/** Chaosnet ethernet protocol type.
+ */
+#define ETH_P_Chaosnet		0x0804
+
+/** X.25 Level 3 ethernet protocol type.
+ */
+#define ETH_P_X25		0x0805
+
+/** ARP ethernet protocol type.
+ */
+#define ETH_P_ARP		0x0806
+
+/** XNS Compatability ethernet protocol type.
+ */
+#define ETH_P_XNS_Compatability		0x0807
+
+/** Frame Relay ARP ethernet protocol type.
+ */
+#define ETH_P_Frame_Relay_ARP		0x0808
+
+/** Symbolics Private ethernet protocol type.
+ */
+#define ETH_P_Symbolics_Private		0x081C
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MIN		0x0888
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MAX		0x088A
+
+/** Ungermann-Bass net debugr ethernet protocol type.
+ */
+#define ETH_P_Ungermann_Bass_net_debugr		0x0900
+
+/** Xerox IEEE802.3 PUP ethernet protocol type.
+ */
+#define ETH_P_IEEEPUP		0x0A00
+
+/** PUP Addr Trans ethernet protocol type.
+ */
+#define ETH_P_IEEEPUPAT		0x0A01
+
+/** Banyan VINES ethernet protocol type.
+ */
+#define ETH_P_Banyan_VINES		0x0BAD
+
+/** VINES Loopback ethernet protocol type.
+ */
+#define ETH_P_VINES_Loopback		0x0BAE
+
+/** VINES Echo ethernet protocol type.
+ */
+#define ETH_P_VINES_Echo		0x0BAF
+
+/** Berkeley Trailer nego ethernet protocol type.
+ */
+#define ETH_P_Berkeley_Trailer_nego		0x1000
+
+/** Berkeley Trailer encap/IP ethernet protocol type.
+ */
+#define ETH_P_Berkeley_Trailer_encapIP_MIN		0x1001
+
+/** Berkeley Trailer encap/IP ethernet protocol type.
+ */
+#define ETH_P_Berkeley_Trailer_encapIP_MAX		0x100F
+
+/** Valid Systems ethernet protocol type.
+ */
+#define ETH_P_Valid_Systems		0x1600
+
+/** PCS Basic Block Protocol ethernet protocol type.
+ */
+#define ETH_P_PCS_Basic_Block_Protocol		0x4242
+
+/** BBN Simnet ethernet protocol type.
+ */
+#define ETH_P_BBN_Simnet		0x5208
+
+/** DEC Unassigned (Exp.) ethernet protocol type.
+ */
+#define ETH_P_DEC		0x6000
+
+/** DEC MOP Dump/Load ethernet protocol type.
+ */
+#define ETH_P_DNA_DL		0x6001
+
+/** DEC MOP Remote Console ethernet protocol type.
+ */
+#define ETH_P_DNA_RC		0x6002
+
+/** DEC DECNET Phase IV Route ethernet protocol type.
+ */
+#define ETH_P_DNA_RT		0x6003
+
+/** DEC LAT ethernet protocol type.
+ */
+#define ETH_P_LAT		0x6004
+
+/** DEC Diagnostic Protocol ethernet protocol type.
+ */
+#define ETH_P_DIAG		0x6005
+
+/** DEC Customer Protocol ethernet protocol type.
+ */
+#define ETH_P_CUST		0x6006
+
+/** DEC LAVC, SCA ethernet protocol type.
+ */
+#define ETH_P_SCA		0x6007
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MIN		0x6008
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MAX		0x6009
+
+/** Com Corporation ethernet protocol type.
+ */
+#define ETH_P_Com_Corporation_MIN		0x6010
+
+/** Com Corporation ethernet protocol type.
+ */
+#define ETH_P_Com_Corporation_MAX		0x6014
+
+/** Trans Ether Bridging ethernet protocol type.
+ */
+#define ETH_P_Trans_Ether_Bridging		0x6558
+
+/** Raw Frame Relay ethernet protocol type.
+ */
+#define ETH_P_Raw_Frame_Relay		0x6559
+
+/** Ungermann-Bass download ethernet protocol type.
+ */
+#define ETH_P_Ungermann_Bass_download		0x7000
+
+/** Ungermann-Bass dia/loop ethernet protocol type.
+ */
+#define ETH_P_Ungermann_Bass_dialoop		0x7002
+
+/** LRT ethernet protocol type.
+ */
+#define ETH_P_LRT_MIN		0x7020
+
+/** LRT ethernet protocol type.
+ */
+#define ETH_P_LRT_MAX		0x7029
+
+/** Proteon ethernet protocol type.
+ */
+#define ETH_P_Proteon		0x7030
+
+/** Cabletron ethernet protocol type.
+ */
+#define ETH_P_Cabletron		0x7034
+
+/** Cronus VLN ethernet protocol type.
+ */
+#define ETH_P_Cronus_VLN		0x8003
+
+/** Cronus Direct ethernet protocol type.
+ */
+#define ETH_P_Cronus_Direct		0x8004
+
+/** HP Probe ethernet protocol type.
+ */
+#define ETH_P_HP_Probe		0x8005
+
+/** Nestar ethernet protocol type.
+ */
+#define ETH_P_Nestar		0x8006
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T		0x8008
+
+/** Excelan ethernet protocol type.
+ */
+#define ETH_P_Excelan		0x8010
+
+/** SGI diagnostics ethernet protocol type.
+ */
+#define ETH_P_SGI_diagnostics		0x8013
+
+/** SGI network games ethernet protocol type.
+ */
+#define ETH_P_SGI_network_games		0x8014
+
+/** SGI reserved ethernet protocol type.
+ */
+#define ETH_P_SGI_reserved		0x8015
+
+/** SGI bounce server ethernet protocol type.
+ */
+#define ETH_P_SGI_bounce_server		0x8016
+
+/** Apollo Domain ethernet protocol type.
+ */
+#define ETH_P_Apollo_Domain		0x8019
+
+/** Tymshare ethernet protocol type.
+ */
+#define ETH_P_Tymshare		0x802E
+
+/** Tigan, Inc. ethernet protocol type.
+ */
+#define ETH_P_Tigan		0x802F
+
+/** Reverse ARP ethernet protocol type.
+ */
+#define ETH_P_RARP		0x8035
+
+/** Aeonic Systems ethernet protocol type.
+ */
+#define ETH_P_Aeonic_Systems		0x8036
+
+/** DEC LANBridge ethernet protocol type.
+ */
+#define ETH_P_DEC_LANBridge		0x8038
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MIN1		0x8039
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MAX2		0x803C
+
+/** DEC Ethernet Encryption ethernet protocol type.
+ */
+#define ETH_P_DEC_Ethernet_Encryption		0x803D
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned		0x803E
+
+/** DEC LAN Traffic Monitor ethernet protocol type.
+ */
+#define ETH_P_DEC_LAN_Traffic_Monitor		0x803F
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MIN3		0x8040
+
+/** DEC Unassigned ethernet protocol type.
+ */
+#define ETH_P_DEC_Unassigned_MAX3		0x8042
+
+/** Planning Research Corp. ethernet protocol type.
+ */
+#define ETH_P_Planning_Research_Corp		0x8044
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T2		0x8046
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T3		0x8047
+
+/** ExperData ethernet protocol type.
+ */
+#define ETH_P_ExperData		0x8049
+
+/** Stanford V Kernel exp. ethernet protocol type.
+ */
+#define ETH_P_Stanford_V_Kernel_exp		0x805B
+
+/** Stanford V Kernel prod. ethernet protocol type.
+ */
+#define ETH_P_Stanford_V_Kernel_prod		0x805C
+
+/** Evans &Sutherland ethernet protocol type.
+ */
+#define ETH_P_Evans_Sutherland		0x805D
+
+/** Little Machines ethernet protocol type.
+ */
+#define ETH_P_Little_Machines		0x8060
+
+/** Counterpoint Computers ethernet protocol type.
+ */
+#define ETH_P_Counterpoint_Computers		0x8062
+
+/** Univ. of Mass. @ Amherst ethernet protocol type.
+ */
+#define ETH_P_Univ_of_Mass		0x8065
+
+/** Univ. of Mass. @ Amherst ethernet protocol type.
+ */
+#define ETH_P_Univ_of_Mass2		0x8066
+
+/** Veeco Integrated Auto. ethernet protocol type.
+ */
+#define ETH_P_Veeco_Integrated_Auto		0x8067
+
+/** General Dynamics ethernet protocol type.
+ */
+#define ETH_P_General_Dynamics		0x8068
+
+/** AT&T ethernet protocol type.
+ */
+#define ETH_P_AT_T4		0x8069
+
+/** Autophon ethernet protocol type.
+ */
+#define ETH_P_Autophon		0x806A
+
+/** ComDesign ethernet protocol type.
+ */
+#define ETH_P_ComDesign		0x806C
+
+/** Computgraphic Corp. ethernet protocol type.
+ */
+#define ETH_P_Computgraphic_Corp		0x806D
+
+/** Landmark Graphics Corp. ethernet protocol type.
+ */
+#define ETH_P_Landmark_Graphics_Corp_MIN		0x806E
+
+/** Landmark Graphics Corp. ethernet protocol type.
+ */
+#define ETH_P_Landmark_Graphics_Corp_MAX		0x8077
+
+/** Matra ethernet protocol type.
+ */
+#define ETH_P_Matra		0x807A
+
+/** Dansk Data Elektronik ethernet protocol type.
+ */
+#define ETH_P_Dansk_Data_Elektronik		0x807B
+
+/** Merit Internodal ethernet protocol type.
+ */
+#define ETH_P_Merit_Internodal		0x807C
+
+/** Vitalink Communications ethernet protocol type.
+ */
+#define ETH_P_Vitalink_Communications_MIN		0x807D
+
+/** Vitalink Communications ethernet protocol type.
+ */
+#define ETH_P_Vitalink_Communications_MAX		0x807F
+
+/** Vitalink TransLAN III ethernet protocol type.
+ */
+#define ETH_P_Vitalink_TransLAN_III		0x8080
+
+/** Counterpoint Computers ethernet protocol type.
+ */
+#define ETH_P_Counterpoint_Computers_MIN		0x8081
+
+/** Counterpoint Computers ethernet protocol type.
+ */
+#define ETH_P_Counterpoint_Computers_MAX		0x8083
+
+/** Appletalk ethernet protocol type.
+ */
+#define ETH_P_ATALK		0x809B
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MIN		0x809C
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MAX		0x809E
+
+/** Spider Systems Ltd. ethernet protocol type.
+ */
+#define ETH_P_Spider_Systems_Ltd		0x809F
+
+/** Nixdorf Computers ethernet protocol type.
+ */
+#define ETH_P_Nixdorf_Computers		0x80A3
+
+/** Siemens Gammasonics Inc. ethernet protocol type.
+ */
+#define ETH_P_Siemens_Gammasonics_Inc_MIN		0x80A4
+
+/** Siemens Gammasonics Inc. ethernet protocol type.
+ */
+#define ETH_P_Siemens_Gammasonics_Inc_MAX		0x80B3
+
+/** DCA Data Exchange Cluster ethernet protocol type.
+ */
+#define ETH_P_DCA_Data_Exchange_Cluster_MIN		0x80C0
+
+/** DCA Data Exchange Cluster ethernet protocol type.
+ */
+#define ETH_P_DCA_Data_Exchange_Cluster_MAX		0x80C3
+
+/** Banyan Systems ethernet protocol type.
+ */
+#define ETH_P_Banyan_Systems		0x80C4
+
+/** Banyan Systems ethernet protocol type.
+ */
+#define ETH_P_Banyan_Systems2		0x80C5
+
+/** Pacer Software ethernet protocol type.
+ */
+#define ETH_P_Pacer_Software		0x80C6
+
+/** Applitek Corporation ethernet protocol type.
+ */
+#define ETH_P_Applitek_Corporation		0x80C7
+
+/** Intergraph Corporation ethernet protocol type.
+ */
+#define ETH_P_Intergraph_Corporation_MIN		0x80C8
+
+/** Intergraph Corporation ethernet protocol type.
+ */
+#define ETH_P_Intergraph_Corporation_MAX		0x80CC
+
+/** Harris Corporation ethernet protocol type.
+ */
+#define ETH_P_Harris_Corporation_MIN		0x80CD
+
+/** Harris Corporation ethernet protocol type.
+ */
+#define ETH_P_Harris_Corporation_MAX		0x80CE
+
+/** Taylor Instrument ethernet protocol type.
+ */
+#define ETH_P_Taylor_Instrument_MIN		0x80CF
+
+/** Taylor Instrument ethernet protocol type.
+ */
+#define ETH_P_Taylor_Instrument_MAX		0x80D2
+
+/** Rosemount Corporation ethernet protocol type.
+ */
+#define ETH_P_Rosemount_Corporation_MIN		0x80D3
+
+/** Rosemount Corporation ethernet protocol type.
+ */
+#define ETH_P_Rosemount_Corporation_MAX		0x80D4
+
+/** IBM SNA Service on Ether ethernet protocol type.
+ */
+#define ETH_P_IBM_SNA_Service_on_Ether		0x80D5
+
+/** Varian Associates ethernet protocol type.
+ */
+#define ETH_P_Varian_Associates		0x80DD
+
+/** Integrated Solutions TRFS ethernet protocol type.
+ */
+#define ETH_P_Integrated_Solutions_TRFS_MIN		0x80DE
+
+/** Integrated Solutions TRFS ethernet protocol type.
+ */
+#define ETH_P_Integrated_Solutions_TRFS_MAX		0x80DF
+
+/** Allen-Bradley ethernet protocol type.
+ */
+#define ETH_P_Allen_Bradley_MIN		0x80E0
+
+/** Allen-Bradley ethernet protocol type.
+ */
+#define ETH_P_Allen_Bradley_MAX		0x80E3
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MIN2		0x80E4
+
+/** Datability ethernet protocol type.
+ */
+#define ETH_P_Datability_MAX2		0x80F0
+
+/** Retix ethernet protocol type.
+ */
+#define ETH_P_Retix		0x80F2
+
+/** AppleTalk AARP (Kinetics) ethernet protocol type.
+ */
+#define ETH_P_AARP		0x80F3
+
+/** Kinetics ethernet protocol type.
+ */
+#define ETH_P_Kinetics_MIN		0x80F4
+
+/** Kinetics ethernet protocol type.
+ */
+#define ETH_P_Kinetics_MAX		0x80F5
+
+/** Apollo Computer ethernet protocol type.
+ */
+#define ETH_P_Apollo_Computer		0x80F7
+
+/** Wellfleet Communications ethernet protocol type.
+ */
+#define ETH_P_Wellfleet_Communications		0x80FF
+
+/** IEEE 802.1Q VLAN-tagged frames (initially Wellfleet) ethernet protocol type.
+ */
+#define ETH_P_8021Q		0x8100
+
+/** Wellfleet Communications ethernet protocol type.
+ */
+#define ETH_P_Wellfleet_Communications_MIN		0x8101
+
+/** Wellfleet Communications ethernet protocol type.
+ */
+#define ETH_P_Wellfleet_Communications_MAX		0x8103
+
+/** Symbolics Private ethernet protocol type.
+ */
+#define ETH_P_Symbolics_Private_MIN		0x8107
+
+/** Symbolics Private ethernet protocol type.
+ */
+#define ETH_P_Symbolics_Private_MAX		0x8109
+
+/** Hayes Microcomputers ethernet protocol type.
+ */
+#define ETH_P_Hayes_Microcomputers		0x8130
+
+/** VG Laboratory Systems ethernet protocol type.
+ */
+#define ETH_P_VG_Laboratory_Systems		0x8131
+
+/** Bridge Communications ethernet protocol type.
+ */
+#define ETH_P_Bridge_Communications_MIN		0x8132
+
+/** Bridge Communications ethernet protocol type.
+ */
+#define ETH_P_Bridge_Communications_MAX		0x8136
+
+/** Novell, Inc. ethernet protocol type.
+ */
+#define ETH_P_Novell_Inc_MIN		0x8137
+
+/** Novell, Inc. ethernet protocol type.
+ */
+#define ETH_P_Novell_Inc_MAX		0x8138
+
+/** KTI ethernet protocol type.
+ */
+#define ETH_P_KTI_MIN		0x8139
+
+/** KTI ethernet protocol type.
+ */
+#define ETH_P_KTI_MAX		0x813D
+
+/** Logicraft ethernet protocol type.
+ */
+#define ETH_P_Logicraft		0x8148
+
+/** Network Computing Devices ethernet protocol type.
+ */
+#define ETH_P_Network_Computing_Devices		0x8149
+
+/** Alpha Micro ethernet protocol type.
+ */
+#define ETH_P_Alpha_Micro		0x814A
+
+/** SNMP ethernet protocol type.
+ */
+#define ETH_P_SNMP		0x814C
+
+/** BIIN ethernet protocol type.
+ */
+#define ETH_P_BIIN		0x814D
+
+/** BIIN ethernet protocol type.
+ */
+#define ETH_P_BIIN2		0x814E
+
+/** Technically Elite Concept ethernet protocol type.
+ */
+#define ETH_P_Technically_Elite_Concept		0x814F
+
+/** Rational Corp ethernet protocol type.
+ */
+#define ETH_P_Rational_Corp		0x8150
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MIN		0x8151
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MAX		0x8153
+
+/** Computer Protocol Pty Ltd ethernet protocol type.
+ */
+#define ETH_P_Computer_Protocol_Pty_Ltd_MIN		0x815C
+
+/** Computer Protocol Pty Ltd ethernet protocol type.
+ */
+#define ETH_P_Computer_Protocol_Pty_Ltd_MAX		0x815E
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MIN		0x8164
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MAX		0x8166
+
+/** XTP ethernet protocol type.
+ */
+#define ETH_P_XTP		0x817D
+
+/** SGI/Time Warner prop. ethernet protocol type.
+ */
+#define ETH_P_SGITime_Warner_prop		0x817E
+
+/** HIPPI-FP encapsulation ethernet protocol type.
+ */
+#define ETH_P_HIPPI_FP_encapsulation		0x8180
+
+/** STP, HIPPI-ST ethernet protocol type.
+ */
+#define ETH_P_STP_HIPPI_ST		0x8181
+
+/** Reserved for HIPPI-6400 ethernet protocol type.
+ */
+#define ETH_P_Reserved_for_HIPPI_6400		0x8182
+
+/** Reserved for HIPPI-6400 ethernet protocol type.
+ */
+#define ETH_P_Reserved_for_HIPPI_64002		0x8183
+
+/** Silicon Graphics prop. ethernet protocol type.
+ */
+#define ETH_P_Silicon_Graphics_prop_MIN		0x8184
+
+/** Silicon Graphics prop. ethernet protocol type.
+ */
+#define ETH_P_Silicon_Graphics_prop_MAX		0x818C
+
+/** Motorola Computer ethernet protocol type.
+ */
+#define ETH_P_Motorola_Computer		0x818D
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MIN2		0x819A
+
+/** Qualcomm ethernet protocol type.
+ */
+#define ETH_P_Qualcomm_MAX2		0x81A3
+
+/** ARAI Bunkichi ethernet protocol type.
+ */
+#define ETH_P_ARAI_Bunkichi		0x81A4
+
+/** RAD Network Devices ethernet protocol type.
+ */
+#define ETH_P_RAD_Network_Devices_MIN		0x81A5
+
+/** RAD Network Devices ethernet protocol type.
+ */
+#define ETH_P_RAD_Network_Devices_MAX		0x81AE
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MIN2		0x81B7
+
+/** Xyplex ethernet protocol type.
+ */
+#define ETH_P_Xyplex_MAX2		0x81B9
+
+/** Apricot Computers ethernet protocol type.
+ */
+#define ETH_P_Apricot_Computers_MIN		0x81CC
+
+/** Apricot Computers ethernet protocol type.
+ */
+#define ETH_P_Apricot_Computers_MAX		0x81D5
+
+/** Artisoft ethernet protocol type.
+ */
+#define ETH_P_Artisoft_MIN		0x81D6
+
+/** Artisoft ethernet protocol type.
+ */
+#define ETH_P_Artisoft_MAX		0x81DD
+
+/** Polygon ethernet protocol type.
+ */
+#define ETH_P_Polygon_MIN		0x81E6
+
+/** Polygon ethernet protocol type.
+ */
+#define ETH_P_Polygon_MAX		0x81EF
+
+/** Comsat Labs ethernet protocol type.
+ */
+#define ETH_P_Comsat_Labs_MIN		0x81F0
+
+/** Comsat Labs ethernet protocol type.
+ */
+#define ETH_P_Comsat_Labs_MAX		0x81F2
+
+/** SAIC ethernet protocol type.
+ */
+#define ETH_P_SAIC_MIN		0x81F3
+
+/** SAIC ethernet protocol type.
+ */
+#define ETH_P_SAIC_MAX		0x81F5
+
+/** VG Analytical ethernet protocol type.
+ */
+#define ETH_P_VG_Analytical_MIN		0x81F6
+
+/** VG Analytical ethernet protocol type.
+ */
+#define ETH_P_VG_Analytical_MAX		0x81F8
+
+/** Quantum Software ethernet protocol type.
+ */
+#define ETH_P_Quantum_Software_MIN		0x8203
+
+/** Quantum Software ethernet protocol type.
+ */
+#define ETH_P_Quantum_Software_MAX		0x8205
+
+/** Ascom Banking Systems ethernet protocol type.
+ */
+#define ETH_P_Ascom_Banking_Systems_MIN		0x8221
+
+/** Ascom Banking Systems ethernet protocol type.
+ */
+#define ETH_P_Ascom_Banking_Systems_MAX		0x8222
+
+/** Advanced Encryption Syste ethernet protocol type.
+ */
+#define ETH_P_Advanced_Encryption_Syste_MIN		0x823E
+
+/** Advanced Encryption Syste ethernet protocol type.
+ */
+#define ETH_P_Advanced_Encryption_Syste_MAX		0x8240
+
+/** Athena Programming ethernet protocol type.
+ */
+#define ETH_P_Athena_Programming_MIN		0x827F
+
+/** Athena Programming ethernet protocol type.
+ */
+#define ETH_P_Athena_Programming_MAX		0x8282
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MIN2		0x8263
+
+/** Charles River Data System ethernet protocol type.
+ */
+#define ETH_P_Charles_River_Data_System_MAX2		0x826A
+
+/** Inst Ind Info Tech ethernet protocol type.
+ */
+#define ETH_P_Inst_Ind_Info_Tech_MIN		0x829A
+
+/** Inst Ind Info Tech ethernet protocol type.
+ */
+#define ETH_P_Inst_Ind_Info_Tech_MAX		0x829B
+
+/** Taurus Controls ethernet protocol type.
+ */
+#define ETH_P_Taurus_Controls_MIN		0x829C
+
+/** Taurus Controls ethernet protocol type.
+ */
+#define ETH_P_Taurus_Controls_MAX		0x82AB
+
+/** Walker Richer &Quinn ethernet protocol type.
+ */
+#define ETH_P_Walker_Richer_Quinn_MIN		0x82AC
+
+/** Walker Richer &Quinn ethernet protocol type.
+ */
+#define ETH_P_Walker_Richer_Quinn_MAX		0x8693
+
+/** Idea Courier ethernet protocol type.
+ */
+#define ETH_P_Idea_Courier_MIN		0x8694
+
+/** Idea Courier ethernet protocol type.
+ */
+#define ETH_P_Idea_Courier_MAX		0x869D
+
+/** Computer Network Tech ethernet protocol type.
+ */
+#define ETH_P_Computer_Network_Tech_MIN		0x869E
+
+/** Computer Network Tech ethernet protocol type.
+ */
+#define ETH_P_Computer_Network_Tech_MAX		0x86A1
+
+/** Gateway Communications ethernet protocol type.
+ */
+#define ETH_P_Gateway_Communications_MIN		0x86A3
+
+/** Gateway Communications ethernet protocol type.
+ */
+#define ETH_P_Gateway_Communications_MAX		0x86AC
+
+/** SECTRA ethernet protocol type.
+ */
+#define ETH_P_SECTRA		0x86DB
+
+/** Delta Controls ethernet protocol type.
+ */
+#define ETH_P_Delta_Controls		0x86DE
+
+/** IPv6 ethernet protocol type.
+ */
+#define ETH_P_IPV6		0x86DD
+
+/** ATOMIC ethernet protocol type.
+ */
+#define ETH_P_ATOMIC		0x86DF
+
+/** Landis &Gyr Powers ethernet protocol type.
+ */
+#define ETH_P_Landis_Gyr_Powers_MIN		0x86E0
+
+/** Landis &Gyr Powers ethernet protocol type.
+ */
+#define ETH_P_Landis_Gyr_Powers_MAX		0x86EF
+
+/** Motorola ethernet protocol type.
+ */
+#define ETH_P_Motorola_MIN		0x8700
+
+/** Motorola ethernet protocol type.
+ */
+#define ETH_P_Motorola_MAX		0x8710
+
+/** TCP/IP Compression ethernet protocol type.
+ */
+#define ETH_P_TCPIP_Compression		0x876B
+
+/** IP Autonomous Systems ethernet protocol type.
+ */
+#define ETH_P_IP_Autonomous_Systems		0x876C
+
+/** Secure Data ethernet protocol type.
+ */
+#define ETH_P_Secure_Data		0x876D
+
+/** PPP ethernet protocol type.
+ */
+#define ETH_P_PPP		0x880B
+
+/** MPLS ethernet protocol type.
+ */
+#define ETH_P_MPLS_UC		0x8847
+
+/** MPLS with upstream-assigned label ethernet protocol type.
+ */
+#define ETH_P_MPLS_MC		0x8848
+
+/** Invisible Software ethernet protocol type.
+ */
+#define ETH_P_Invisible_Software_MIN		0x8A96
+
+/** Invisible Software ethernet protocol type.
+ */
+#define ETH_P_Invisible_Software_MAX		0x8A97
+
+/** PPPoE Discovery Stage ethernet protocol type.
+ */
+#define ETH_P_PPP_DISC		0x8863
+
+/** PPPoE Session Stage ethernet protocol type.
+ */
+#define ETH_P_PPP_SES		0x8864
+
+/** Loopback ethernet protocol type.
+ */
+#define ETH_P_Loopback		0x9000
+
+/** Com(Bridge) XNS Sys Mgmt ethernet protocol type.
+ */
+#define ETH_P_Com_XNS_Sys_Mgmt		0x9001
+
+/** Com(Bridge) TCP-IP Sys ethernet protocol type.
+ */
+#define ETH_P_Com_TCP_IP_Sys		0x9002
+
+/** Com(Bridge) loop detect ethernet protocol type.
+ */
+#define ETH_P_Com_loop_detect		0x9003
+
+/** BBN VITAL-LanBridge cache ethernet protocol type.
+ */
+#define ETH_P_BBN_VITAL_LanBridge_cache		0xFF00
+
+/** ISC Bunker Ramo ethernet protocol type.
+ */
+#define ETH_P_ISC_Bunker_Ramo_MIN		0xFF00
+
+/** ISC Bunker Ramo ethernet protocol type.
+ */
+#define ETH_P_ISC_Bunker_Ramo_MAX		0xFF0F
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/icmp_client.h
===================================================================
--- uspace/lib/net/include/icmp_client.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/icmp_client.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,63 @@
+/*
+ * 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 icmp
+ *  @{
+ */
+
+/** @file
+ *  ICMP client interface.
+ */
+
+#ifndef __NET_ICMP_CLIENT_H__
+#define __NET_ICMP_CLIENT_H__
+
+#include <icmp_codes.h>
+#include <packet/packet.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 (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/icmp_header.h
===================================================================
--- uspace/lib/net/include/icmp_header.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/icmp_header.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,133 @@
+/*
+ * 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 icmp
+ *  @{
+ */
+
+/** @file
+ *  ICMP header definition.
+ *  Based on the RFC~792.
+ */
+
+#ifndef __NET_ICMP_HEADER_H__
+#define __NET_ICMP_HEADER_H__
+
+#include <sys/types.h>
+
+#include <in.h>
+#include <icmp_codes.h>
+
+/** ICMP header size in bytes.
+ */
+#define ICMP_HEADER_SIZE			sizeof(icmp_header_t)
+
+/** Type definition of the echo specific data.
+ *  @see icmp_echo
+ */
+typedef struct icmp_echo	icmp_echo_t;
+
+/** Type definition of the echo specific data pointer.
+ *  @see icmp_echo
+ */
+typedef icmp_echo_t *		icmp_echo_ref;
+
+/** Echo specific data.
+ */
+struct icmp_echo{
+	/** Message idintifier.
+	 */
+	icmp_param_t identifier;
+	/** Message sequence number.
+	 */
+	icmp_param_t sequence_number;
+} __attribute__ ((packed));
+
+/** Type definition of the internet control message header.
+ *  @see icmp_header
+ */
+typedef struct icmp_header	icmp_header_t;
+
+/** Type definition of the internet control message header pointer.
+ *  @see icmp_header
+ */
+typedef icmp_header_t *		icmp_header_ref;
+
+/** Internet control message header.
+ */
+struct icmp_header{
+	/** The type of the message.
+	 */
+	uint8_t type;
+	/** The error code for the datagram reported by the ICMP message.
+	 *  The interpretation is dependent on the message type.
+	 */
+	uint8_t code;
+	/** The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type.
+     *  For computing the checksum, the checksum field should be zero.
+	 *  If the checksum does not match the contents, the datagram is discarded.
+	 */
+	uint16_t checksum;
+	/** Message specific data.
+	 */
+	union{
+		/** Echo specific data.
+		 */
+		icmp_echo_t  echo;
+		/** Proposed gateway value.
+		 */
+		in_addr_t gateway;
+		/** Fragmentation needed specific data.
+		 */
+		struct{
+			/** Reserved field.
+			 *  Must be zero.
+			 */
+			icmp_param_t reserved;
+			/** Proposed MTU.
+			 */
+			icmp_param_t mtu;
+		} frag;
+		/** Parameter problem specific data.
+		 */
+		struct{
+			/** Problem pointer.
+			 */
+			icmp_param_t pointer;
+			/** Reserved field.
+			 *  Must be zero.
+			 */
+			icmp_param_t reserved;
+		} param;
+	} un;
+} __attribute__ ((packed));
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/icmp_interface.h
===================================================================
--- uspace/lib/net/include/icmp_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/icmp_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,113 @@
+/*
+ * 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 icmp
+ *  @{
+ */
+
+/** @file
+ *  ICMP module interface.
+ *  The same interface is used for standalone remote modules as well as for bundle modules.
+ *  The standalone remote modules have to be compiled with the icmp_remote.c source file.
+ *  The bundle modules with the icmp.c source file.
+ */
+
+#ifndef __NET_ICMP_INTERFACE_H__
+#define __NET_ICMP_INTERFACE_H__
+
+#include <sys/types.h>
+
+#include <net_device.h>
+#include <adt/measured_strings.h>
+#include <packet/packet.h>
+#include <inet.h>
+#include <ip_codes.h>
+#include <socket_codes.h>
+#include <icmp_codes.h>
+#include <icmp_common.h>
+
+/** @name ICMP module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Sends the Destination Unreachable error notification packet.
+ *  Beginning of the packet is sent as the notification packet data.
+ *  The source and the destination addresses should be set in the original packet.
+ *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
+ *  @param[in] code The error specific code.
+ *  @param[in] mtu The error MTU value.
+ *  @param[in] packet The original packet.
+ *  @returns EOK on success.
+ *  @returns EPERM if the ICMP error notifications are disabled.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+extern int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet);
+
+/** Sends the Source Quench error notification packet.
+ *  Beginning of the packet is sent as the notification packet data.
+ *  The source and the destination addresses should be set in the original packet.
+ *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
+ *  @param[in] packet The original packet.
+ *  @returns EOK on success.
+ *  @returns EPERM if the ICMP error notifications are disabled.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+extern int icmp_source_quench_msg(int icmp_phone, packet_t packet);
+
+/** Sends the Time Exceeded error notification packet.
+ *  Beginning of the packet is sent as the notification packet data.
+ *  The source and the destination addresses should be set in the original packet.
+ *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
+ *  @param[in] code The error specific code.
+ *  @param[in] packet The original packet.
+ *  @returns EOK on success.
+ *  @returns EPERM if the ICMP error notifications are disabled.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+extern int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet);
+
+/** Sends the Parameter Problem error notification packet.
+ *  Beginning of the packet is sent as the notification packet data.
+ *  The source and the destination addresses should be set in the original packet.
+ *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
+ *  @param[in] code The error specific code.
+ *  @param[in] pointer The problematic parameter offset.
+ *  @param[in] packet The original packet.
+ *  @returns EOK on success.
+ *  @returns EPERM if the ICMP error notifications are disabled.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+extern int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet);
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/il_interface.h
===================================================================
--- uspace/lib/net/include/il_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/il_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,94 @@
+/*
+ * 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 net_il
+ *  @{
+ */
+
+/** @file
+ *  Internetwork layer module interface for the underlying network interface layer.
+ *  This interface is always called by the standalone remote modules.
+ */
+
+#ifndef __NET_IL_INTERFACE_H__
+#define __NET_IL_INTERFACE_H__
+
+#include <async.h>
+
+#include <ipc/services.h>
+
+#include <net_messages.h>
+#include <net_device.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <il_messages.h>
+
+/** @name Internetwork layer module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Notifies the internetwork layer modules about the device state change.
+ *  @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] state The new device state.
+ *  @param[in] target The target internetwork module service to be delivered to.
+ *  @returns EOK on success.
+ */
+static inline int il_device_state_msg(int il_phone, device_id_t device_id, device_state_t state, services_t target){
+	return generic_device_state_msg(il_phone, NET_IL_DEVICE_STATE, device_id, state, target);
+}
+
+/** Notifies the internetwork layer modules about the received packet/s.
+ *  @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The received packet or the received packet queue.
+ *  @param[in] target The target internetwork module service to be delivered to.
+ *  @returns EOK on success.
+ */
+inline static int il_received_msg(int il_phone, device_id_t device_id, packet_t packet, services_t target){
+	return generic_received_msg(il_phone, NET_IL_RECEIVED, device_id, packet_get_id(packet), target, 0);
+}
+
+/** Notifies the internetwork layer modules about the mtu change.
+ *  @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] mtu The new mtu value.
+ *  @param[in] target The target internetwork module service to be delivered to.
+ *  @returns EOK on success.
+ */
+inline static int il_mtu_changed_msg(int il_phone, device_id_t device_id, size_t mtu, services_t target){
+	return generic_device_state_msg(il_phone, NET_IL_MTU_CHANGED, device_id, (int) mtu, target);
+}
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/il_messages.h
===================================================================
--- uspace/lib/net/include/il_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/il_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,92 @@
+/*
+ * 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 net_il
+ *  @{
+ */
+
+/** @file
+ *  Internetwork layer modules messages.
+ *  @see il_interface.h
+ *  @see ip_interface.h
+ */
+
+#ifndef __NET_IL_MESSAGES_H__
+#define __NET_IL_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+/** Internet layer modules messages.
+ */
+typedef enum{
+	/** New device message.
+	 *  @see ip_device_req()
+	 */
+	NET_IL_DEVICE = NET_IL_FIRST,
+	/** Device state changed message.
+	 *  @see il_device_state_msg()
+	 */
+	NET_IL_DEVICE_STATE,
+	/** Device MTU changed message.
+	 *  @see il_mtu_changed_msg()
+	 */
+	NET_IL_MTU_CHANGED,
+	/** Packet size message.
+	 *  @see il_packet_size_req()
+	 */
+	NET_IL_PACKET_SPACE,
+	/** Packet received message.
+	 *  @see il_received_msg()
+	 */
+	NET_IL_RECEIVED,
+	/** Packet send message.
+	 *  @see il_send_msg()
+	 */
+	NET_IL_SEND
+} il_messages;
+
+/** @name Internetwork layer specific message parameters definitions
+ */
+/*@{*/
+
+/** Returns the protocol number message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IL_GET_PROTO(call)		(int) IPC_GET_ARG1(*call)
+
+/** Returns the registering service message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IL_GET_SERVICE(call)	(services_t) IPC_GET_ARG2(*call)
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/il_standalone.h
===================================================================
--- uspace/lib/net/include/il_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/il_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * 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 il_standalone
+ *  @{
+ */
+
+#ifndef __IL_STANDALONE_H__
+#define __IL_STANDALONE_H__
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+extern int il_module_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, int *answer_count);
+extern int il_module_start(async_client_conn_t client_connection);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/ip_client.h
===================================================================
--- uspace/lib/net/include/ip_client.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/ip_client.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,116 @@
+/*
+ * 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 ip
+ *  @{
+ */
+
+/** @file
+ *  IP client interface.
+ */
+
+#ifndef __NET_IP_CLIENT_H__
+#define __NET_IP_CLIENT_H__
+
+#include <sys/types.h>
+
+#include <packet/packet.h>
+#include <ip_codes.h>
+#include <ip_interface.h>
+#include <socket_codes.h>
+
+/** Prepares the packet to be transfered via IP.
+ *  The IP header is prefixed.
+ *  @param[in,out] packet The packet to be prepared.
+ *  @param[in] protocol The transport protocol.
+ *  @param[in] ttl The time to live counter. The IPDEFTTL is set if zero (0).
+ *  @param[in] tos The type of service.
+ *  @param[in] dont_fragment The value indicating whether fragmentation is disabled.
+ *  @param[in] ipopt_length The prefixed IP options length in bytes.
+ *  @returns EOK on success.
+ *  @returns ENOMEM if there is not enough memory left in the packet.
+ */
+extern int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length);
+
+/** Processes the received IP packet.
+ *  Fills set header fields.
+ *  Returns the prefixed IP header length.
+ *  @param[in] packet The received packet.
+ *  @param[out] protocol The transport protocol. May be NULL if not desired.
+ *  @param[out] ttl The time to live counter. May be NULL if not desired.
+ *  @param[out] tos The type of service. May be NULL if not desired.
+ *  @param[out] dont_fragment The value indicating whether the fragmentation is disabled. May be NULL if not desired.
+ *  @param[out] ipopt_length The IP options length in bytes. May be NULL if not desired.
+ *  @returns The prefixed IP header length in bytes on success.
+ *  @returns ENOMEM if the packet is too short to contain the IP header.
+ */
+extern int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length);
+
+/** Returns the IP header length.
+ *  @param[in] packet The packet.
+ *  @returns The IP header length in bytes.
+ *  @returns Zero (0) if there is no IP header.
+ */
+extern size_t ip_client_header_length(packet_t packet);
+
+/** Updates the IPv4 pseudo header data length field.
+ *  @param[in,out] header The IPv4 pseudo header to be updated.
+ *  @param[in] headerlen The length of the IP pseudo header in bytes.
+ *  @param[in] data_length The data length to be set.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the header parameter is NULL.
+ *  @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length.
+ */
+extern int ip_client_set_pseudo_header_data_length(ip_pseudo_header_ref header, size_t headerlen, size_t data_length);
+
+/** Constructs the IPv4 pseudo header.
+ *  @param[in] protocol The transport protocol.
+ *  @param[in] src The source address.
+ *  @param[in] srclen The source address length.
+ *  @param[in] dest The destination address.
+ *  @param[in] destlen The destination address length.
+ *  @param[in] data_length The data length to be set.
+ *  @param[out] header The constructed IPv4 pseudo header.
+ *  @param[out] headerlen The length of the IP pseudo header in bytes.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the header and/or the headerlen parameter is NULL.
+ *  @returns EINVAL if the source address and/or the destination address parameter is NULL.
+ *  @returns EINVAL if the source address length is less than struct sockaddr length.
+ *  @returns EINVAL if the source address length differs from the destination address length.
+ *  @returns EINVAL if the source address family differs from the destination family.
+ *  @returns EAFNOSUPPORT if the address family is not supported.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+extern int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, ip_pseudo_header_ref * header, size_t * headerlen);
+
+// TODO ipopt manipulation
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/ip_header.h
===================================================================
--- uspace/lib/net/include/ip_header.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/ip_header.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,282 @@
+/*
+ * 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 ip
+ *  @{
+ */
+
+/** @file
+ *  IP header and options definitions.
+ *  Based on the RFC~791.
+ */
+
+#ifndef __NET_IP_HEADER_H__
+#define __NET_IP_HEADER_H__
+
+#include <byteorder.h>
+#include <sys/types.h>
+
+/** 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)
+
+/** Returns the fragment offest low bits.
+ *  @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))
+
+/** 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)
+
+/** 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))))
+
+/** 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))
+
+/** Returns the actual IP header length in bytes.
+ *  @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
+ */
+/*@{*/
+
+/** 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)
+
+/** Last fragment flag value.
+ *  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)
+
+/** More fragments flag value.
+ *  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;
+
+/** Type definition of the internet header pointer.
+ *  @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;
+
+/** Type definition of the internet option header pointer.
+ *  @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;
+
+/** Type definition of the internet version 4 pseudo header pointer.
+ *  @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{
+#ifdef ARCH_IS_BIG_ENDIAN
+	/** 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
+	/** 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
+	/** 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
+	/** 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{
+	/** 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
+	/** 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
+	/** 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{
+	/** 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));
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/ip_interface.h
===================================================================
--- uspace/lib/net/include/ip_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/ip_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,173 @@
+/*
+ * 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 ip
+ *  @{
+ */
+
+/** @file
+ *  IP module interface.
+ *  The same interface is used for standalone remote modules as well as for bundle modules.
+ *  The standalone remote modules have to be compiled with the ip_remote.c source file.
+ *  The bundle modules with the ip.c source file.
+ */
+
+#ifndef __NET_IP_INTERFACE_H__
+#define __NET_IP_INTERFACE_H__
+
+#include <async.h>
+#include <ipc/services.h>
+
+#include <net_device.h>
+#include <packet/packet.h>
+
+#include <in.h>
+#include <ip_codes.h>
+#include <socket_codes.h>
+
+/** @name IP module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Type definition of the internet pseudo header pointer.
+ */
+typedef void *		ip_pseudo_header_ref;
+
+/** 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.
+ */
+typedef int	(*tl_received_msg_t)(device_id_t device_id, packet_t packet, services_t receiver, services_t error);
+
+/** 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.
+ *  @param[in] tl_received_msg The message processing function. Used if bundled together.
+ *  @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, tl_received_msg_t tl_received_msg);
+
+/** Registers the new device.
+ *  Registers itself as the ip packet receiver.
+ *  If the device uses ARP registers also the new ARP device.
+ *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
+ *  @param[in] device_id The new device identifier.
+ *  @param[in] netif The underlying device network interface layer service.
+ *  @returns EOK on success.
+ *  @returns ENOMEM if there is not enough memory left.
+ *  @returns EINVAL if the device configuration is invalid.
+ *  @returns ENOTSUP if the device uses IPv6.
+ *  @returns ENOTSUP if the device uses DHCP.
+ *  @returns Other error codes as defined for the net_get_device_conf_req() function.
+ *  @returns Other error codes as defined for the arp_device_req() function.
+ */
+extern int ip_device_req(int ip_phone, device_id_t device_id, services_t netif);
+
+/** Sends the packet queue.
+ *  The packets may get fragmented if needed.
+ *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The packet fragments as a~packet queue. All the packets have to have the same destination address.
+ *  @param[in] sender The sending module service.
+ *  @param[in] error The packet error reporting service. Prefixes the received packet.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the generic_send_msg() function.
+ */
+extern int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error);
+
+/** Connects to the IP module.
+ *  @param service The IP module service. Ignored parameter.
+ *  @returns The IP module phone on success.
+ *  @returns 0 if called by the bundle module.
+ */
+extern int ip_connect_module(services_t service);
+
+/** Adds a route to the device routing table.
+ *  The target network is routed using this device.
+ *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] address The target network address.
+ *  @param[in] netmask The target network mask.
+ *  @param[in] gateway The target network gateway. Not used if zero.
+ */
+extern int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway);
+
+/** Sets the default gateway.
+ *  This gateway is used if no other route is found.
+ *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] gateway The default gateway.
+ */
+extern int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway);
+
+/** Returns the device packet dimension for sending.
+ *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] packet_dimension The packet dimension.
+ *  @returns EOK on success.
+ *  @returns ENOENT if there is no such device.
+ *  @returns Other error codes as defined for the generic_packet_size_req() function.
+ */
+extern int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension);
+
+/** Notifies the IP module about the received error notification packet.
+ *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The received packet or the received packet queue.
+ *  @param[in] target The target internetwork module service to be delivered to.
+ *  @param[in] error The packet error reporting service. Prefixes the received packet.
+ *  @returns EOK on success.
+ */
+extern int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error);
+
+/** Returns 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.
+ *  @param[in] protocol The transport protocol.
+ *  @param[in] destination The destination address.
+ *  @param[in] addrlen The destination address length.
+ *  @param[out] device_id The device identifier.
+ *  @param[out] header The constructed IP pseudo header.
+ *  @param[out] headerlen The IP pseudo header length.
+ */
+extern int ip_get_route_req(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref * header, size_t * headerlen);
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/ip_messages.h
===================================================================
--- uspace/lib/net/include/ip_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/ip_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,106 @@
+/*
+ * 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 ip
+ *  @{
+ */
+
+/** @file
+ *  IP module messages.
+ *  @see ip_interface.h
+ */
+
+#ifndef __NET_IP_MESSAGES_H__
+#define __NET_IP_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+#include <in.h>
+#include <ip_codes.h>
+
+/** IP module messages.
+ */
+typedef enum{
+	/** Adds the routing entry.
+	 *  @see ip_add_route()
+	 */
+	NET_IP_ADD_ROUTE = NET_IP_FIRST,
+	/** Gets the actual route information.
+	 *  @see ip_get_route()
+	 */
+	NET_IP_GET_ROUTE,
+	/** Processes the received error notification.
+	 *  @see ip_received_error_msg()
+	 */
+	NET_IP_RECEIVED_ERROR,
+	/** Sets the default gateway.
+	 *  @see ip_set_default_gateway()
+	 */
+	NET_IP_SET_GATEWAY
+} ip_messages;
+
+/** @name IP specific message parameters definitions
+ */
+/*@{*/
+
+/** Returns the address message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IP_GET_ADDRESS(call) \
+	({in_addr_t addr; addr.s_addr = IPC_GET_ARG3(*call); addr;})
+
+/** Returns the gateway message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IP_GET_GATEWAY(call) \
+	({in_addr_t addr; addr.s_addr = IPC_GET_ARG2(*call); addr;})
+
+/** Sets the header length in the message answer.
+ *  @param[out] answer The message answer structure.
+ */
+#define IP_SET_HEADERLEN(answer, value) \
+	{ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(*answer, argument);}
+
+/** Returns the network mask message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IP_GET_NETMASK(call) \
+	({in_addr_t addr; addr.s_addr = IPC_GET_ARG4(*call); addr;})
+
+/** Returns the protocol message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IP_GET_PROTOCOL(call) \
+	({ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); protocol;})
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/net_checksum.h
===================================================================
--- uspace/lib/net/include/net_checksum.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/net_checksum.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,113 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  General CRC and checksum computation.
+ */
+
+#ifndef __NET_CHECKSUM_H__
+#define __NET_CHECKSUM_H__
+
+#include <byteorder.h>
+
+#include <sys/types.h>
+
+/** IP checksum value for computed zero checksum.
+ *  Zero is returned as 0xFFFF (not flipped)
+ */
+#define IP_CHECKSUM_ZERO			0xFFFFu
+
+/**	Computes CRC32 value.
+ *  @param[in] seed Initial value. Often used as 0 or ~0.
+ *  @param[in] data Pointer to the beginning of data to process.
+ *  @param[in] length Length of the data in bits.
+ *  @returns The computed CRC32 of the length bits of the data.
+ */
+#ifdef ARCH_IS_BIG_ENDIAN
+	#define compute_crc32(seed, data, length)	compute_crc32_be(seed, (uint8_t *) data, length)
+#else
+	#define compute_crc32(seed, data, length)	compute_crc32_le(seed, (uint8_t *) data, length)
+#endif
+
+/**	Computes CRC32 value in the little-endian environment.
+ *  @param[in] seed Initial value. Often used as 0 or ~0.
+ *  @param[in] data Pointer to the beginning of data to process.
+ *  @param[in] length Length of the data in bits.
+ *  @returns The computed CRC32 of the length bits of the data.
+ */
+extern uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length);
+
+/**	Computes CRC32 value in the big-endian environment.
+ *  @param[in] seed Initial value. Often used as 0 or ~0.
+ *  @param[in] data Pointer to the beginning of data to process.
+ *  @param[in] length Length of the data in bits.
+ *  @returns The computed CRC32 of the length bits of the data.
+ */
+extern uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length);
+
+/** Computes sum of the 2 byte fields.
+ *  Padds one zero (0) byte if odd.
+ *  @param[in] seed Initial value. Often used as 0 or ~0.
+ *  @param[in] data Pointer to the beginning of data to process.
+ *  @param[in] length Length of the data in bytes.
+ *  @returns The computed checksum of the length bytes of the data.
+ */
+extern uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length);
+
+/** Compacts the computed checksum to the 16 bit number adding the carries.
+ *  @param[in] sum Computed checksum.
+ *  @returns Compacted computed checksum to the 16 bits.
+ */
+extern uint16_t compact_checksum(uint32_t sum);
+
+/** Returns or flips the checksum if zero.
+ *  @param[in] checksum The computed checksum.
+ *  @returns The internet protocol header checksum.
+ *  @returns 0xFFFF if the computed checksum is zero.
+ */
+extern uint16_t flip_checksum(uint16_t checksum);
+
+/** Computes the ip header checksum.
+ *  To compute the checksum of a new packet, the checksum header field must be zero.
+ *  To check the checksum of a received packet, the checksum may be left set.
+ *  The zero (0) value will be returned in this case if valid.
+ *  @param[in] data The header data.
+ *  @param[in] length The header length in bytes.
+ *  @returns The internet protocol header checksum.
+ *  @returns 0xFFFF if the computed checksum is zero.
+ */
+extern uint16_t ip_checksum(uint8_t * data, size_t length);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/net_hardware.h
===================================================================
--- uspace/lib/net/include/net_hardware.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/net_hardware.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,195 @@
+/*
+ * 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 net_nil
+ *  @{
+ */
+
+/** @file
+ *  Hardware types according to the on-line IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009.
+ */
+
+#ifndef __NET_HW_TYPES_H__
+#define __NET_HW_TYPES_H__
+
+#include <sys/types.h>
+
+/** Network interface layer type type definition.
+ */
+typedef uint8_t	hw_type_t;
+
+/** @name Network interface layer types definitions
+ */
+/*@{*/
+
+/** Ethernet (10Mb) hardware type.
+ */
+#define HW_ETHER		1
+
+/** Experimental Ethernet (3Mb) hardware type.
+ */
+#define HW_EETHER		2
+
+/** Amateur Radio AX.25 hardware type.
+ */
+#define HW_AX25		3
+
+/** Proteon ProNET Token Ring hardware type.
+ */
+#define HW_PRONET		4
+
+/** Chaos hardware type.
+ */
+#define HW_CHAOS		5
+
+/** IEEE 802 Networks hardware type.
+ */
+#define HW_IEEE802		6
+
+/** ARCNET hardware type.
+ */
+#define HW_ARCNET		7
+
+/** Hyperchannel hardware type.
+ */
+#define HW_Hyperchannel		8
+
+/** Lanstar hardware type.
+ */
+#define HW_Lanstar		9
+
+/** Autonet Short Address hardware type.
+ */
+#define HW_ASA		10
+
+/** LocalTalk hardware type.
+ */
+#define HW_LocalTalk		11
+
+/** LocalNet (IBM PCNet or SYTEK LocalNET) hardware type.
+ */
+#define HW_LocalNet		12
+
+/** Ultra link hardware type.
+ */
+#define HW_Ultra_link		13
+
+/** SMDS hardware type.
+ */
+#define HW_SMDS		14
+
+/** Frame Relay DLCI hardware type.
+ */
+#define HW_DLCI		15
+
+/** Asynchronous Transmission Mode (ATM) hardware type.
+ */
+#define HW_ATM		16
+
+/** HDLC hardware type.
+ */
+#define HW_HDLC		17
+
+/** Fibre Channel hardware type.
+ */
+#define HW_Fibre_Channel		18
+
+/** Asynchronous Transmission Mode (ATM) hardware type.
+ */
+#define HW_ATM2		19
+
+/** Serial Line hardware type.
+ */
+#define HW_Serial_Line		20
+
+/** Asynchronous Transmission Mode (ATM) hardware type.
+ */
+#define HW_ATM3		21
+
+/** MIL-STD-188-220 hardware type.
+ */
+#define HW_MIL_STD_188_220		22
+
+/** Metricom hardware type.
+ */
+#define HW_METRICOM		23
+
+/** IEEE 1394.1995 hardware type.
+ */
+#define HW_IEEE1394		24
+
+/** MAPOS hardware type.
+ */
+#define HW_MAPOS		25
+
+/** Twinaxial hardware type.
+ */
+#define HW_Twinaxial		26
+
+/** EUI-64 hardware type.
+ */
+#define HW_EUI64		27
+
+/** HIPARP hardware type.
+ */
+#define HW_HIPARP		28
+
+/** IP and ARP over ISO 7816-3 hardware type.
+ */
+#define HW_ISO_7816_3		29
+
+/** ARPSec hardware type.
+ */
+#define HW_ARPSec		30
+
+/** IPsec tunnel hardware type.
+ */
+#define HW_IPsec_tunnel		31
+
+/** InfiniBand (TM) hardware type.
+ */
+#define HW_INFINIBAND		32
+
+/** TIA-102 Project 25 Common Air Interface (CAI) hardware type.
+ */
+#define HW_CAI		33
+
+/** Wiegand Interface hardware type.
+ */
+#define HW_Wiegand		34
+
+/** Pure IP hardware type.
+ */
+#define HW_Pure_IP		35
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/net_interface.h
===================================================================
--- uspace/lib/net/include/net_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/net_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,103 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Networking module interface.
+ *  The same interface is used for standalone remote modules as well as for bundle modules.
+ *  The standalone remote modules have to be compiled with the net_remote.c source file.
+ *  The bundle networking module is compiled with the net_bundle.c source file and the choosen bundle module implementation source files.
+ */
+
+#ifndef __NET_NET_INTERFACE_H__
+#define __NET_NET_INTERFACE_H__
+
+#include <ipc/services.h>
+
+#include <net_device.h>
+#include <adt/measured_strings.h>
+
+/** @name Networking module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Returns the device specific configuration.
+ *  Returns the global configuration if the device specific is not found.
+ *  The configuration names are read and the appropriate settings are set instead.
+ *  Call net_free_settings() function to release the returned configuration.
+ *  @param[in] net_phone The networking module phone.
+ *  @param[in] device_id The device identifier.
+ *  @param[in,out] configuration The requested device configuration. The names are read and the appropriate settings are set instead.
+ *  @param[in] count The configuration entries count.
+ *  @param[in,out] data The configuration and settings data.
+ *  @returns EOK on success.
+ *  @returns EINVAL if the configuration is NULL.
+ *  @returns EINVAL if the count is zero (0).
+ *  @returns Other error codes as defined for the generic_translate_req() function.
+ */
+extern int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data);
+
+/** Returns the global configuration.
+ *  The configuration names are read and the appropriate settings are set instead.
+ *  Call net_free_settings() function to release the returned configuration.
+ *  @param[in] net_phone The networking module phone.
+ *  @param[in,out] configuration The requested configuration. The names are read and the appropriate settings are set instead.
+ *  @param[in] count The configuration entries count.
+ *  @param[in,out] data The configuration and settings data.
+ *  @returns EOK on success.
+ *  @returns EINVAL if the configuration is NULL.
+ *  @returns EINVAL if the count is zero (0).
+ *  @returns Other error codes as defined for the generic_translate_req() function.
+ */
+extern int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data);
+
+/** Frees the received settings.
+ *  @param[in] settings The received settings.
+ *  @param[in] data The received settings data.
+ *  @see net_get_device_conf_req()
+ *  @see net_get_conf_req()
+ */
+extern void net_free_settings(measured_string_ref settings, char * data);
+
+/** Connects to the networking module.
+ *  @param service The networking module service. Ignored parameter.
+ *  @returns The networking module phone on success.
+ *  @returns 0 if called by the bundle module.
+ */
+extern int net_connect_module(services_t service);
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/net_net_messages.h
===================================================================
--- uspace/lib/net/include/net_net_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/net_net_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,64 @@
+/*
+ * 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 net
+ *  @{
+ */
+
+/** @file
+ *  Networking subsystem central module messages.
+ *  @see net_interface.h
+ */
+
+#ifndef __NET_NET_MESSAGES_H__
+#define __NET_NET_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+
+/** Networking subsystem central module messages.
+ */
+typedef enum{
+	/** Returns the general configuration
+	 *  @see net_get_conf_req()
+	 */
+	NET_NET_GET_CONF = NET_FIRST,
+	/** Returns the device specific configuration
+	 *  @see net_get_device_conf_req()
+	 */
+	NET_NET_GET_DEVICE_CONF,
+	/** Starts the networking stack.
+	 */
+	NET_NET_STARTUP,
+} net_messages;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/netif.h
===================================================================
--- uspace/lib/net/include/netif.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/netif.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,161 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Network interface module skeleton.
+ *  The skeleton has to be part of each network interface module.
+ *  The skeleton can be also part of the module bundled with the network interface layer.
+ */
+
+#ifndef __NET_NETIF_H__
+#define __NET_NETIF_H__
+
+#include <async.h>
+#include <fibril_synch.h>
+
+#include <ipc/ipc.h>
+
+#include <net_err.h>
+#include <net_device.h>
+#include <packet/packet.h>
+
+/** Network interface module skeleton global data.
+ */
+typedef struct netif_globals	netif_globals_t;
+
+/** Type definition of the device specific data.
+ *  @see netif_device
+ */
+typedef struct netif_device	device_t;
+
+/** Type definition of the device specific data pointer.
+ *  @see netif_device
+ */
+typedef device_t *			device_ref;
+
+/** Device map.
+ *  Maps device identifiers to the network interface device specific data.
+ *  @see device.h
+ */
+DEVICE_MAP_DECLARE(device_map, device_t);
+
+/** Network interface device specific data.
+ */
+struct	netif_device{
+	/** Device identifier.
+	 */
+	device_id_t device_id;
+	/** Receiving network interface layer phone.
+	 */
+	int nil_phone;
+	/** Actual device state.
+	 */
+	device_state_t state;
+	/** Driver specific data.
+	 */
+	void * specific;
+};
+
+/** Network interface module skeleton global data.
+ */
+struct	netif_globals{
+	/** Networking module phone.
+	 */
+	int net_phone;
+	/**	Device map.
+	 */
+	device_map_t device_map;
+	/** Safety lock.
+	 */
+	fibril_rwlock_t lock;
+};
+
+extern netif_globals_t netif_globals;
+
+/**	Finds the device specific data.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] device The device specific data.
+ *  @returns EOK on success.
+ *  @returns ENOENT if device is not found.
+ *  @returns EPERM if the device is not initialized.
+ */
+extern int find_device(device_id_t device_id, device_ref * device);
+
+/** Clears the usage statistics.
+ *  @param[in] stats The usage statistics.
+ */
+extern void null_device_stats(device_stats_ref stats);
+
+// prepared for future optimalizations
+/** Releases the given packet.
+ *  @param[in] packet_id The packet identifier.
+ */
+extern void netif_pq_release(packet_id_t packet_id);
+
+/** Allocates new packet to handle the given content size.
+ *  @param[in] content The minimum content size.
+ *  @returns The allocated packet.
+ *  @returns NULL if there is an error.
+ */
+extern packet_t netif_packet_get_1(size_t content);
+
+/** Processes the netif module messages.
+ *  @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 ENOTSUP if the message is not known.
+ *  @returns Other error codes as defined for each specific module message function.
+ *  @see netif_interface.h
+ *  @see IS_NET_NETIF_MESSAGE()
+ */
+extern int netif_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
+
+/** Initializes the netif module.
+ *  The function has to be defined in each module.
+ *  @param[in] net_client_connection The client connection functio to be registered.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for each specific module message function.
+ */
+extern int netif_init_module(async_client_conn_t client_connection);
+
+/** Starts and maintains the netif module until terminated.
+ *  @returns EOK after the module is terminated.
+ */
+extern int netif_run_module(void);
+
+#endif
+
+/** @}
+ */
+
Index: uspace/lib/net/include/netif_interface.h
===================================================================
--- uspace/lib/net/include/netif_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/netif_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,129 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Network interface module interface.
+ *  The same interface is used for standalone remote modules as well as for bundle network interface layer modules.
+ *  The standalone remote modules have to be compiled with the netif_remote.c source file.
+ *  The bundle network interface layer modules are compiled with the netif_nil_bundle.c source file and the choosen network interface layer implementation source file.
+ */
+
+#ifndef __NET_NETIF_INTERFACE_H__
+#define __NET_NETIF_INTERFACE_H__
+
+#include <ipc/services.h>
+
+#include <net_messages.h>
+#include <adt/measured_strings.h>
+#include <packet/packet.h>
+#include <net_device.h>
+
+/** @name Network interface module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Returns 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.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the address parameter is NULL.
+ *  @returns ENOENT if there no such device.
+ *  @returns Other error codes as defined for the netif_get_addr_message() function.
+ */
+extern int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data);
+
+/** Probes 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.
+ *  @returns EOK on success.
+ *  @returns Other errro codes as defined for the netif_probe_message().
+ */
+extern int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io);
+
+/** Sends 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.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the generic_send_msg() function.
+ */
+extern int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender);
+
+/** Starts the device.
+ *  @param[in] netif_phone The network interface phone.
+ *  @param[in] device_id The device identifier.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the netif_start_message() function.
+ */
+extern int netif_start_req(int netif_phone, device_id_t device_id);
+
+/** Stops the device.
+ *  @param[in] netif_phone The network interface phone.
+ *  @param[in] device_id The device identifier.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the netif_stop_message() function.
+ */
+extern int netif_stop_req(int netif_phone, device_id_t device_id);
+
+/** Returns 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.
+ *  @returns EOK on success.
+ */
+extern int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats);
+
+/** Creates bidirectional connection with the network interface module and registers the message receiver.
+ *  @param[in] service The network interface module service.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] me The requesting module service.
+ *  @param[in] receiver The message receiver.
+ *  @returns The phone of the needed service.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the bind_service() function.
+ */
+extern int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver);
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/netif_messages.h
===================================================================
--- uspace/lib/net/include/netif_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/netif_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,95 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Network interface common module messages.
+ *  @see netif_interface.h
+ */
+
+#ifndef __NET_NETIF_MESSAGES_H__
+#define __NET_NETIF_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+
+/** Network interface common module messages.
+ */
+typedef enum {
+	/** Probe device message.
+	 *  @see netif_probe_req()
+	 */
+	NET_NETIF_PROBE = NET_NETIF_FIRST,
+	/** Send packet message.
+	 *  @see netif_send_msg()
+	 */
+	NET_NETIF_SEND,
+	/** Start device message.
+	 *  @see netif_start_req()
+	 */
+	NET_NETIF_START,
+	/** Get device usage statistics message.
+	 *  @see netif_stats_req()
+	 */
+	NET_NETIF_STATS,
+	/** Stop device message.
+	 *  @see netif_stop_req()
+	 */
+	NET_NETIF_STOP,
+	/** Get device address message.
+	 *  @see netif_get_addr_req()
+	 */
+	NET_NETIF_GET_ADDR,
+} netif_messages;
+
+/** @name Network interface specific message parameters definitions
+ */
+/*@{*/
+
+/** Returns the interrupt number message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define NETIF_GET_IRQ(call) \
+	({int irq = (int) IPC_GET_ARG2(*call); irq;})
+
+/** Returns the input/output address message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define NETIF_GET_IO(call) \
+	({int io = (int) IPC_GET_ARG3(*call); io;})
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/netif_module.h
===================================================================
--- uspace/lib/net/include/netif_module.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/netif_module.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,125 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Network interface module interface.
+ *  The interface has to be implemented by each network interface module.
+ *  The interface is used by the network interface module skeleton.
+ */
+
+#ifndef __NET_NETIF_MODULE_H__
+#define __NET_NETIF_MODULE_H__
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+
+#include <adt/measured_strings.h>
+#include <packet/packet.h>
+#include <net_device.h>
+
+/** Initializes the specific module.
+ */
+extern int netif_initialize(void);
+
+/** Probes the existence of the device.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] irq The device interrupt number.
+ *  @param[in] io The device input/output address.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns 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);
+
+/** Sends the packet queue.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The packet queue.
+ *  @param[in] sender The sending module service.
+ *  @returns EOK on success.
+ *  @returns EFORWARD if the device is not active (in the NETIF_ACTIVE state).
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the specific module message implementation.
+ */
+extern int netif_send_message(device_id_t device_id, packet_t packet, services_t sender);
+
+/** Starts the device.
+ *  @param[in] device The device structure.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the specific module message implementation.
+ */
+extern int netif_start_message(device_ref device);
+
+/** Stops the device.
+ *  @param[in] device The device structure.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the specific module message implementation.
+ */
+extern int netif_stop_message(device_ref device);
+
+/** Returns the device local hardware address.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] address The device local hardware address.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the address parameter is NULL.
+ *  @returns ENOENT if there no such device.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the specific module message implementation.
+ */
+extern int netif_get_addr_message(device_id_t device_id, measured_string_ref address);
+
+/** Processes the netif driver specific message.
+ *  This function is called for uncommon messages received by the netif skeleton.
+ *  @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 ENOTSUP if the message is not known.
+ *  @returns Other error codes as defined for the specific module message implementation.
+ */
+extern int netif_specific_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
+
+/** Returns the device usage statistics.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] stats The device usage statistics.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the find_device() function.
+ *  @returns Other error codes as defined for the specific module message implementation.
+ */
+extern int netif_get_device_stats(device_id_t device_id, device_stats_ref stats);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/netif_nil_bundle.h
===================================================================
--- uspace/lib/net/include/netif_nil_bundle.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/netif_nil_bundle.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * 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 netif_standalone
+ *  @{
+ */
+
+#ifndef __NETIF_NIL_BUNDLE_H__
+#define __NETIF_NIL_BUNDLE_H__
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+extern int netif_nil_module_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, int *answer_count);
+extern int netif_nil_module_start(async_client_conn_t client_connection);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/netif_standalone.h
===================================================================
--- uspace/lib/net/include/netif_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/netif_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * 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 netif_standalone
+ *  @{
+ */
+
+#ifndef __NETIF_STANDALONE_H__
+#define __NETIF_STANDALONE_H__
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+extern int netif_module_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, int *answer_count);
+extern int netif_module_start(async_client_conn_t client_connection);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/nil_interface.h
===================================================================
--- uspace/lib/net/include/nil_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/nil_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,157 @@
+/*
+ * 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 net_nil
+ *  @{
+ */
+
+/** @file
+ *  Network interface layer module interface.
+ *  The same interface is used for standalone remote device modules as well as for bundle device modules.
+ *  The standalone remote device modules have to be compiled with the nil_remote.c source file.
+ *  The bundle device modules with the appropriate network interface layer source file (eth.c etc.).
+ *  The upper layers cannot be bundled with the network interface layer.
+ */
+
+#ifndef __NET_NIL_INTERFACE_H__
+#define __NET_NIL_INTERFACE_H__
+
+#include <async.h>
+#include <errno.h>
+
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+#include <adt/measured_strings.h>
+#include <packet/packet.h>
+#include <nil_messages.h>
+#include <net_device.h>
+
+/** @name Network interface layer module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Returns the device local hardware address.
+ *  @param[in] nil_phone The network interface layer phone.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] address The device local hardware address.
+ *  @param[out] data The address data.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the address parameter and/or the data parameter is NULL.
+ *  @returns ENOENT if there no such device.
+ *  @returns Other error codes as defined for the generic_get_addr_req() function.
+ */
+#define nil_get_addr_req(nil_phone, device_id, address, data)	\
+	generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data)
+
+/** Returns the device broadcast hardware address.
+ *  @param[in] nil_phone The network interface layer phone.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] address The device broadcast hardware address.
+ *  @param[out] data The address data.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the address parameter is NULL.
+ *  @returns ENOENT if there no such device.
+ *  @returns Other error codes as defined for the generic_get_addr_req() function.
+ */
+#define nil_get_broadcast_addr_req(nil_phone, device_id, address, data)	\
+	generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data)
+
+/** Sends the packet queue.
+ *  @param[in] nil_phone The network interface layer phone.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The packet queue.
+ *  @param[in] sender The sending module service.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the generic_send_msg() function.
+ */
+#define nil_send_msg(nil_phone, device_id, packet, sender)	\
+	generic_send_msg(nil_phone, NET_NIL_SEND, device_id, packet_get_id(packet), sender, 0)
+
+/** Returns the device packet dimension for sending.
+ *  @param[in] nil_phone The network interface layer phone.
+ *  @param[in] device_id The device identifier.
+ *  @param[out] packet_dimension The packet dimensions.
+ *  @returns EOK on success.
+ *  @returns ENOENT if there is no such device.
+ *  @returns Other error codes as defined for the generic_packet_size_req() function.
+ */
+#define nil_packet_size_req(nil_phone, device_id, packet_dimension)	\
+	generic_packet_size_req(nil_phone, NET_NIL_PACKET_SPACE, device_id, packet_dimension)
+
+/** Registers new device or updates the MTU of an existing one.
+ *  @param[in] nil_phone The network interface layer phone.
+ *  @param[in] device_id The new device identifier.
+ *  @param[in] mtu The device maximum transmission unit.
+ *  @param[in] netif_service The device driver service.
+ *  @returns EOK on success.
+ *  @returns EEXIST if the device with the different service exists.
+ *  @returns ENOMEM if there is not enough memory left.
+ *  @returns Other error codes as defined for the generic_device_req() function.
+ */
+#define nil_device_req(nil_phone, device_id, mtu, netif_service)	\
+	generic_device_req(nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service)
+
+/** Notifies 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.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for each specific module device state function.
+ */
+extern int nil_device_state_msg(int nil_phone, device_id_t device_id, int state);
+
+/** Passes the packet queue to the network interface layer.
+ *  Processes and redistributes 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.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for each specific module received function.
+ */
+extern int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target);
+
+/** Creates bidirectional connection with the network interface layer module and registers the message receiver.
+ *  @param[in] service The network interface layer module service.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] me The requesting module service.
+ *  @param[in] receiver The message receiver.
+ *  @returns The phone of the needed service.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the bind_service() function.
+ */
+#define	nil_bind_service(service, device_id, me, receiver)	\
+	bind_service(service, device_id, me, 0, receiver);
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/nil_messages.h
===================================================================
--- uspace/lib/net/include/nil_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/nil_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,92 @@
+/*
+ * 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 net_nil
+ *  @{
+ */
+
+/** @file
+ *  Network interface layer module messages.
+ *  @see nil_interface.h
+ */
+
+#ifndef __NET_NIL_MESSAGES_H__
+#define __NET_NIL_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+
+/**  Network interface layer module messages.
+ */
+typedef enum {
+	/** New device or update MTU message.
+	 *  @see nil_device_req()
+	 */
+	NET_NIL_DEVICE = NET_NIL_FIRST,
+	/** New device state message.
+	 *  @see nil_device_state_msg()
+	 */
+	NET_NIL_DEVICE_STATE,
+	/** Received packet queue message.
+	 *  @see nil_received_msg()
+	 */
+	NET_NIL_RECEIVED,
+	/** Send packet queue message.
+	 *  @see nil_send_msg()
+	 */
+	NET_NIL_SEND,
+	/** Packet size message.
+	 *  @see nil_packet_size_req()
+	 */
+	NET_NIL_PACKET_SPACE,
+	/** Device local hardware address message.
+	 *  @see nil_get_addr()
+	 */
+	NET_NIL_ADDR,
+	/** Device broadcast hardware address message.
+	 *  @see nil_get_broadcast_addr()
+	 */
+	NET_NIL_BROADCAST_ADDR,
+} nil_messages;
+
+/** @name Network interface layer specific message parameters definitions
+ */
+/*@{*/
+
+/** Returns the protocol service message parameter.
+ */
+#define NIL_GET_PROTO(call) \
+	({services_t service = (services_t) IPC_GET_ARG2(*call); service;})
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/nil_module.h
===================================================================
--- uspace/lib/net/include/nil_module.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/nil_module.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,67 @@
+/*
+ * 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 net_nil
+ *  @{
+ */
+
+/** @file
+ *  Network interface layer modules common skeleton.
+ *  All network interface layer modules have to implement this interface.
+ */
+
+#ifndef __NET_NIL_MODULE_H__
+#define __NET_NIL_MODULE_H__
+
+#include <ipc/ipc.h>
+
+/** Module initialization.
+ *  Is called by the module_start() function.
+ *  @param[in] net_phone The networking moduel phone.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for each specific module initialize function.
+ */
+extern int nil_initialize(int net_phone);
+
+/** Message processing function.
+ *  @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 ENOTSUP if the message is not known.
+ *  @returns Other error codes as defined for each specific module message function.
+ *  @see nil_interface.h
+ *  @see IS_NET_NIL_MESSAGE()
+ */
+extern int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/nil_standalone.h
===================================================================
--- uspace/lib/net/include/nil_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/nil_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * 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 nil_standalone
+ *  @{
+ */
+
+#ifndef __NIL_STANDALONE_H__
+#define __NIL_STANDALONE_H__
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+extern int nil_module_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, int *answer_count);
+extern int nil_module_start(async_client_conn_t client_connection);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/protocol_map.h
===================================================================
--- uspace/lib/net/include/protocol_map.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/protocol_map.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,142 @@
+/*
+ * 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 net_nil
+ *  @{
+ */
+
+/** @file
+ *  Internetwork layer services - network interface layer service type translation.
+ */
+
+#ifndef __NET_PROTOCOL_MAP_H__
+#define __NET_PROTOCOL_MAP_H__
+
+#include <ipc/services.h>
+
+#include <ethernet_lsap.h>
+#include <ethernet_protocols.h>
+#include <net_hardware.h>
+
+/** Maps the internetwork layer service to the network interface layer type.
+ *  @param[in] nil Network interface layer service.
+ *  @param[in] il Internetwork layer service.
+ *  @returns Network interface layer type of the internetworking layer service.
+ *  @returns 0 if mapping is not found.
+ */
+static inline eth_type_t protocol_map(services_t nil, services_t il){
+	switch(nil){
+		case SERVICE_ETHERNET:
+		case SERVICE_DP8390:
+			switch(il){
+				case SERVICE_IP:
+					return ETH_P_IP;
+				case SERVICE_ARP:
+					return ETH_P_ARP;
+				default:
+					return 0;
+			}
+		default:
+			return 0;
+	}
+}
+
+/** Maps the network interface layer type to the internetwork layer service.
+ *  @param[in] nil Network interface layer service.
+ *  @param[in] protocol Network interface layer type.
+ *  @returns Internetwork layer service of the network interface layer type.
+ *  @returns 0 if mapping is not found.
+ */
+static inline services_t protocol_unmap(services_t nil, int protocol){
+	switch(nil){
+		case SERVICE_ETHERNET:
+		case SERVICE_DP8390:
+			switch(protocol){
+				case ETH_P_IP:
+					return SERVICE_IP;
+				case ETH_P_ARP:
+					return SERVICE_ARP;
+				default:
+					return 0;
+			}
+		default:
+			return 0;
+	}
+}
+
+/** Maps the link service access point identifier to the Ethernet protocol identifier.
+ *  @param[in] lsap Link service access point identifier.
+ *  @returns Ethernet protocol identifier of the link service access point identifier.
+ *  @returns ETH_LSAP_NULL if mapping is not found.
+ */
+static inline eth_type_t lsap_map(eth_lsap_t lsap){
+	switch(lsap){
+		case ETH_LSAP_IP:
+			return ETH_P_IP;
+		case ETH_LSAP_ARP:
+			return ETH_P_ARP;
+		default:
+			return ETH_LSAP_NULL;
+	}
+}
+
+/** Maps the Ethernet protocol identifier to the link service access point identifier.
+ *  @param[in] ethertype Ethernet protocol identifier.
+ *  @returns Link service access point identifier.
+ *  @returns 0 if mapping is not found.
+ */
+static inline eth_lsap_t lsap_unmap(eth_type_t ethertype){
+	switch(ethertype){
+		case ETH_P_IP:
+			return ETH_LSAP_IP;
+		case ETH_P_ARP:
+			return ETH_LSAP_ARP;
+		default:
+			return 0;
+	}
+}
+
+/** Maps the network interface layer services to the hardware types.
+ *  @param[in] nil The network interface service.
+ *  @returns The hardware type of the network interface service.
+ *  @returns 0 if mapping is not found.
+ */
+static inline hw_type_t hardware_map(services_t nil){
+	switch(nil){
+		case SERVICE_ETHERNET:
+		case SERVICE_DP8390:
+			return HW_ETHER;
+		default:
+			return 0;
+	}
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/tl_common.h
===================================================================
--- uspace/lib/net/include/tl_common.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/tl_common.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2008 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 net_tl
+ *  @{
+ */
+
+/** @file
+ *  Transport layer common functions.
+ */
+
+#ifndef __NET_TL_COMMON_H__
+#define __NET_TL_COMMON_H__
+
+#include <packet/packet.h>
+#include <net_device.h>
+#include <inet.h>
+#include <socket_codes.h>
+
+/** Device packet dimensions.
+ *  Maps devices to the packet dimensions.
+ *  @see device.h
+ */
+DEVICE_MAP_DECLARE(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.
+ */
+extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port);
+
+/** Gets IP packet dimensions.
+ *  Tries to search a cache and queries the IP module if not found.
+ *  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.
+ *  @returns EOK on success.
+ *  @returns EBADMEM if the packet_dimension parameter is NULL.
+ *  @return ENOMEM if there is not enough memory left.
+ *  @returns EINVAL if the packet_dimensions cache is not valid.
+ *  @returns Other codes as defined for the ip_packet_size_req() function.
+ */
+extern int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension);
+
+/** Updates IP device packet dimensions cache.
+ *  @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/include/tl_interface.h
===================================================================
--- uspace/lib/net/include/tl_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/tl_interface.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,71 @@
+/*
+ * 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 net_tl
+ *  @{
+ */
+
+/** @file
+ *  Transport layer module interface for the underlying internetwork layer.
+ */
+
+#ifndef __NET_TL_INTERFACE_H__
+#define __NET_TL_INTERFACE_H__
+
+#include <async.h>
+#include <ipc/services.h>
+
+#include <net_messages.h>
+#include <net_device.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <tl_messages.h>
+
+/** @name Transport layer module interface
+ *  This interface is used by other modules.
+ */
+/*@{*/
+
+/** Notifies the remote transport layer modules about the received packet/s.
+ *  @param[in] tl_phone The transport layer module phone used for remote calls.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] packet The received packet or the received packet queue. The packet queue is used to carry a~fragmented datagram. The first packet contains the headers, the others contain only data.
+ *  @param[in] target The target transport layer module service to be delivered to.
+ *  @param[in] error The packet error reporting service. Prefixes the received packet.
+ *  @returns EOK on success.
+ */
+inline static int tl_received_msg(int tl_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
+	return generic_received_msg(tl_phone, NET_TL_RECEIVED, device_id, packet_get_id(packet), target, error);
+}
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/tl_messages.h
===================================================================
--- uspace/lib/net/include/tl_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/tl_messages.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,57 @@
+/*
+ * 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 net_tl
+ *  @{
+ */
+
+/** @file
+ *  Transport layer modules messages.
+ *  @see tl_interface.h
+ */
+
+#ifndef __NET_TL_MESSAGES_H__
+#define __NET_TL_MESSAGES_H__
+
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+
+/** Transport layer modules messages.
+ */
+typedef enum{
+	/** Packet received message.
+	 *  @see tl_received_msg()
+	 */
+	NET_TL_RECEIVED = NET_TL_FIRST
+} tl_messages;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/tl_standalone.h
===================================================================
--- uspace/lib/net/include/tl_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/include/tl_standalone.h	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * 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 tl_standalone
+ *  @{
+ */
+
+#ifndef __TL_STANDALONE_H__
+#define __TL_STANDALONE_H__
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+extern int tl_module_message(ipc_callid_t callid, ipc_call_t *call,
+    ipc_call_t *answer, int *answer_count);
+extern int tl_module_start(async_client_conn_t client_connection);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/netif/netif.c
===================================================================
--- uspace/lib/net/netif/netif.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/netif/netif.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,281 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Network interface module skeleton implementation.
+ *  @see netif.h
+ */
+
+#include <async.h>
+#include <mem.h>
+#include <fibril_synch.h>
+#include <stdio.h>
+
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+
+#include <net_err.h>
+#include <net_messages.h>
+#include <net_modules.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <adt/measured_strings.h>
+#include <net_device.h>
+#include <netif_interface.h>
+#include <nil_interface.h>
+#include <netif.h>
+#include <netif_messages.h>
+#include <netif_module.h>
+
+DEVICE_MAP_IMPLEMENT(device_map, device_t)
+
+/** Network interface global data.
+ */
+netif_globals_t netif_globals;
+
+int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io){
+	int result;
+
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	result = netif_probe_message(device_id, irq, io);
+	fibril_rwlock_write_unlock(&netif_globals.lock);
+	return result;
+}
+
+int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender){
+	int result;
+
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	result = netif_send_message(device_id, packet, sender);
+	fibril_rwlock_write_unlock(&netif_globals.lock);
+	return result;
+}
+
+int netif_start_req(int netif_phone, device_id_t device_id){
+	ERROR_DECLARE;
+
+	device_ref device;
+	int result;
+	int phone;
+
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	if(ERROR_OCCURRED(find_device(device_id, &device))){
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		return ERROR_CODE;
+	}
+	result = netif_start_message(device);
+	if(result > NETIF_NULL){
+		phone = device->nil_phone;
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		nil_device_state_msg(phone, device_id, result);
+		return EOK;
+	}else{
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+	}
+	return result;
+}
+
+int netif_stop_req(int netif_phone, device_id_t device_id){
+	ERROR_DECLARE;
+
+	device_ref device;
+	int result;
+	int phone;
+
+	fibril_rwlock_write_lock(&netif_globals.lock);
+	if(ERROR_OCCURRED(find_device(device_id, &device))){
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		return ERROR_CODE;
+	}
+	result = netif_stop_message(device);
+	if(result > NETIF_NULL){
+		phone = device->nil_phone;
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		nil_device_state_msg(phone, device_id, result);
+		return EOK;
+	}else{
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+	}
+	return result;
+}
+
+int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){
+	int res;
+
+	fibril_rwlock_read_lock(&netif_globals.lock);
+	res = netif_get_device_stats(device_id, stats);
+	fibril_rwlock_read_unlock(&netif_globals.lock);
+	return res;
+}
+
+int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data){
+	ERROR_DECLARE;
+
+	measured_string_t translation;
+
+	if(!(address && data)){
+		return EBADMEM;
+	}
+	fibril_rwlock_read_lock(&netif_globals.lock);
+	if(! ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))){
+		*address = measured_string_copy(&translation);
+		ERROR_CODE = (*address) ? EOK : ENOMEM;
+	}
+	fibril_rwlock_read_unlock(&netif_globals.lock);
+	*data = (** address).value;
+	return ERROR_CODE;
+}
+
+int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){
+	return EOK;
+}
+
+int find_device(device_id_t device_id, device_ref * device){
+	if(! device){
+		return EBADMEM;
+	}
+	*device = device_map_find(&netif_globals.device_map, device_id);
+	if(! * device){
+		return ENOENT;
+	}
+	if((** device).state == NETIF_NULL) return EPERM;
+	return EOK;
+}
+
+void null_device_stats(device_stats_ref stats){
+	bzero(stats, sizeof(device_stats_t));
+}
+
+/** Registers the device notification receiver, the network interface layer module.
+ *  @param[in] device_id The device identifier.
+ *  @param[in] phone The network interface layer module phone.
+ *  @returns EOK on success.
+ *  @returns ENOENT if there is no such device.
+ *  @returns ELIMIT if there is another module registered.
+ */
+static int register_message(device_id_t device_id, int phone){
+	ERROR_DECLARE;
+
+	device_ref device;
+
+	ERROR_PROPAGATE(find_device(device_id, &device));
+	if(device->nil_phone > 0){
+		return ELIMIT;
+	}
+	device->nil_phone = phone;
+	printf("New receiver of the device %d registered:\n\tphone\t= %d\n", device->device_id, device->nil_phone);
+	return EOK;
+}
+
+int netif_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	ERROR_DECLARE;
+
+	size_t length;
+	device_stats_t stats;
+	packet_t packet;
+	measured_string_t address;
+
+//	printf("message %d - %d\n", IPC_GET_METHOD(*call), NET_NETIF_FIRST);
+	*answer_count = 0;
+	switch(IPC_GET_METHOD(*call)){
+		case IPC_M_PHONE_HUNGUP:
+			return EOK;
+		case NET_NETIF_PROBE:
+			return netif_probe_req(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(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(netif_globals.net_phone, &packet, IPC_GET_PACKET(call)));
+			return netif_send_msg(0, IPC_GET_DEVICE(call), packet, IPC_GET_SENDER(call));
+		case NET_NETIF_START:
+			return netif_start_req(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;
+		case NET_NETIF_STOP:
+			return netif_stop_req(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 ERROR_CODE;
+	}
+	return netif_specific_message(callid, call, answer, answer_count);
+}
+
+int netif_init_module(async_client_conn_t client_connection){
+	ERROR_DECLARE;
+
+	async_set_client_connection(client_connection);
+	netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
+	device_map_initialize(&netif_globals.device_map);
+	ERROR_PROPAGATE(pm_init());
+	fibril_rwlock_initialize(&netif_globals.lock);
+	if(ERROR_OCCURRED(netif_initialize())){
+		pm_destroy();
+		return ERROR_CODE;
+	}
+	return EOK;
+}
+
+int netif_run_module(void){
+	async_manager();
+
+	pm_destroy();
+	return EOK;
+}
+
+void netif_pq_release(packet_id_t packet_id){
+	pq_release(netif_globals.net_phone, packet_id);
+}
+
+packet_t netif_packet_get_1(size_t content){
+	return packet_get_1(netif_globals.net_phone, content);
+}
+
+/** @}
+ */
Index: uspace/lib/net/netif/netif_nil_bundle.c
===================================================================
--- uspace/lib/net/netif/netif_nil_bundle.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/netif/netif_nil_bundle.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,82 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Wrapper for the bundled network interface and network interface layer module.
+ *  Distributes messages and initializes both module parts.
+ */
+
+#include <async.h>
+#include <ipc/ipc.h>
+
+#include <net_messages.h>
+#include <packet/packet.h>
+#include <nil_module.h>
+#include <netif_nil_bundle.h>
+#include <netif.h>
+
+/** Distributes the messages between the module parts.
+ *  @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 ENOTSUP if the message is not known.
+ *  @returns Other error codes as defined for each specific module message function.
+ */
+int netif_nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	if(IS_NET_NIL_MESSAGE(call) || (IPC_GET_METHOD(*call) == IPC_M_CONNECT_TO_ME)){
+		return nil_message(callid, call, answer, answer_count);
+	}else{
+		return netif_message(callid, call, answer, answer_count);
+	}
+}
+
+/** Starts the bundle network interface module.
+ *  Initializes the client connection serving function, initializes both module parts, 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 each specific module message function.
+ */
+int netif_nil_module_start(async_client_conn_t client_connection){
+	ERROR_DECLARE;
+
+	ERROR_PROPAGATE(netif_init_module(client_connection));
+	if(ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))){
+		pm_destroy();
+		return ERROR_CODE;
+	}
+	return netif_run_module();
+}
+
+/** @}
+ */
Index: uspace/lib/net/netif/netif_standalone.c
===================================================================
--- uspace/lib/net/netif/netif_standalone.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/netif/netif_standalone.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,70 @@
+/*
+ * 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 netif
+ *  @{
+ */
+
+/** @file
+ *  Wrapper for the standalone network interface module.
+ */
+
+#include <async.h>
+#include <ipc/ipc.h>
+
+#include <netif.h>
+#include <netif_standalone.h>
+
+/** Delegates the messages to the netif_message() function.
+ *  @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 ENOTSUP if the message is not known.
+ *  @returns Other error codes as defined for each specific module message function.
+ */
+int netif_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	return netif_message(callid, call, answer, answer_count);
+}
+
+/** Starts the network interface 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 each specific module message function.
+ */
+int netif_module_start(async_client_conn_t client_connection){
+	ERROR_DECLARE;
+
+	ERROR_PROPAGATE(netif_init_module(client_connection));
+	return netif_run_module();
+}
+
+/** @}
+ */
Index: uspace/lib/net/nil/nil_remote.c
===================================================================
--- uspace/lib/net/nil/nil_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/nil/nil_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,54 @@
+/*
+ * 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 net_nil
+ *  @{
+ */
+
+/** @file
+ *  Network interface layer interface implementation for standalone remote modules.
+ *  @see nil_interface.h
+ */
+
+#include <net_messages.h>
+#include <net_device.h>
+#include <nil_interface.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <nil_messages.h>
+
+int nil_device_state_msg(int nil_phone, device_id_t device_id, int state){
+	return generic_device_state_msg(nil_phone, NET_NIL_DEVICE_STATE, device_id, state, 0);
+}
+
+int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target){
+	return generic_received_msg(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 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/tl/icmp_client.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,86 @@
+/*
+ * 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 icmp
+ *  @{
+ */
+
+/** @file
+ *  ICMP client interface implementation.
+ *  @see icmp_client.h
+ */
+
+#ifdef CONFIG_DEBUG
+	#include <stdio.h>
+#endif
+
+#include <errno.h>
+#include <sys/types.h>
+
+#include <icmp_codes.h>
+#include <icmp_client.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <icmp_header.h>
+
+int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){
+	icmp_header_ref header;
+
+	header = (icmp_header_ref) packet_get_data(packet);
+	if((! header)
+		|| (packet_get_data_length(packet) < sizeof(icmp_header_t))){
+		return 0;
+	}
+	if(type){
+		*type = header->type;
+	}
+	if(code){
+		*code = header->code;
+	}
+	if(pointer){
+		*pointer = header->un.param.pointer;
+	}
+	if(mtu){
+		*mtu = header->un.frag.mtu;
+	}
+	// remove debug dump
+#ifdef CONFIG_DEBUG
+	printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet));
+#endif
+	return 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: uspace/lib/net/tl/icmp_remote.c
===================================================================
--- uspace/lib/net/tl/icmp_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/tl/icmp_remote.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,71 @@
+/*
+ * 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 icmp
+ *  @{
+ */
+
+/** @file
+ *  ICMP interface implementation for standalone remote modules.
+ *  @see icmp_interface.h
+ */
+
+#include <async.h>
+#include <errno.h>
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <sys/types.h>
+
+#include <net_messages.h>
+#include <net_modules.h>
+#include <icmp_interface.h>
+#include <packet/packet_client.h>
+#include <icmp_messages.h>
+
+int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet){
+	async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu);
+	return EOK;
+}
+
+int icmp_source_quench_msg(int icmp_phone, packet_t packet){
+	async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, (ipcarg_t) packet_get_id(packet));
+	return EOK;
+}
+
+int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet){
+	async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet));
+	return EOK;
+}
+
+int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet){
+	async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer);
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/net/tl/tl_common.c
===================================================================
--- uspace/lib/net/tl/tl_common.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
+++ uspace/lib/net/tl/tl_common.c	(revision 849ed54afbef3ad0ec3af831e93a1353f9eaaf0f)
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2008 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 net_tl
+ *  @{
+ */
+
+/** @file
+ *  Transport layer common functions implementation.
+ *  @see tl_common.h
+ */
+
+#include <async.h>
+#include <ipc/services.h>
+
+#include <net_err.h>
+#include <packet/packet.h>
+#include <packet/packet_client.h>
+#include <net_device.h>
+#include <icmp_interface.h>
+#include <in.h>
+#include <in6.h>
+#include <inet.h>
+#include <ip_interface.h>
+#include <socket_codes.h>
+#include <socket_errno.h>
+#include <tl_common.h>
+
+DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
+
+int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port){
+	const struct sockaddr_in * address_in;
+	const struct sockaddr_in6 * address_in6;
+
+	if((addrlen <= 0) || ((size_t) addrlen < sizeof(struct sockaddr))){
+		return EINVAL;
+	}
+	switch(addr->sa_family){
+		case AF_INET:
+			if(addrlen != sizeof(struct sockaddr_in)){
+				return EINVAL;
+			}
+			address_in = (struct sockaddr_in *) addr;
+			*port = ntohs(address_in->sin_port);
+			break;
+		case AF_INET6:
+			if(addrlen != sizeof(struct sockaddr_in6)){
+				return EINVAL;
+			}
+			address_in6 = (struct sockaddr_in6 *) addr;
+			*port = ntohs(address_in6->sin6_port);
+			break;
+		default:
+			return EAFNOSUPPORT;
+	}
+	return EOK;
+}
+
+int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension){
+	ERROR_DECLARE;
+
+	if(! packet_dimension){
+		return EBADMEM;
+	}
+
+	*packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
+	if(! * packet_dimension){
+		// ask for and remember them if not found
+		*packet_dimension = malloc(sizeof(** packet_dimension));
+		if(! * packet_dimension){
+			return ENOMEM;
+		}
+		if(ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, * packet_dimension))){
+			free(*packet_dimension);
+			return ERROR_CODE;
+		}
+		ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, * packet_dimension);
+		if(ERROR_CODE < 0){
+			free(*packet_dimension);
+			return ERROR_CODE;
+		}
+	}
+	return EOK;
+}
+
+int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content){
+	packet_dimension_ref packet_dimension;
+
+	packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
+	if(! packet_dimension){
+		return ENOENT;
+	}
+	packet_dimension->content = content;
+	if(device_id != DEVICE_INVALID_ID){
+		packet_dimension = packet_dimensions_find(packet_dimensions, DEVICE_INVALID_ID);
+		if(packet_dimension){
+			if(packet_dimension->content >= content){
+				packet_dimension->content = content;
+			}else{
+				packet_dimensions_exclude(packet_dimensions, DEVICE_INVALID_ID);
+			}
+		}
+	}
+	return EOK;
+}
+
+int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port){
+	struct sockaddr_in * address_in;
+	struct sockaddr_in6 * address_in6;
+	size_t length;
+
+	if(addrlen < 0){
+		return EINVAL;
+	}
+	length = (size_t) addrlen;
+	if(length < sizeof(struct sockaddr)){
+		return EINVAL;
+	}
+	switch(addr->sa_family){
+		case AF_INET:
+			if(length != sizeof(struct sockaddr_in)){
+				return EINVAL;
+			}
+			address_in = (struct sockaddr_in *) addr;
+			address_in->sin_port = htons(port);
+			return EOK;
+		case AF_INET6:
+			if(length != sizeof(struct sockaddr_in6)){
+				return EINVAL;
+			}
+			address_in6 = (struct sockaddr_in6 *) addr;
+			address_in6->sin6_port = htons(port);
+			return EOK;
+		default:
+			return EAFNOSUPPORT;
+	}
+}
+
+int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error){
+	packet_t next;
+	uint8_t * src;
+	int length;
+
+	// detach the first packet and release the others
+	next = pq_detach(packet);
+	if(next){
+		pq_release(packet_phone, packet_get_id(next));
+	}
+	length = packet_get_addr(packet, &src, NULL);
+	if((length > 0)
+		&& (! error)
+		&& (icmp_phone >= 0)
+	// set both addresses to the source one (avoids the source address deletion before setting the destination one)
+		&& (packet_set_addr(packet, src, src, (size_t) length) == EOK)){
+		return EOK;
+	}else{
+		pq_release(packet_phone, packet_get_id(packet));
+	}
+	return ENOENT;
+}
+
+int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen){
+	ERROR_DECLARE;
+
+	ipc_callid_t callid;
+	size_t length;
+	void * data;
+
+	if(! dimension){
+		return EINVAL;
+	}
+	// get the data length
+	if(! async_data_write_receive(&callid, &length)){
+		return EINVAL;
+	}
+	// get a new packet
+	*packet = packet_get_4(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
+	if(! packet){
+		return ENOMEM;
+	}
+	// allocate space in the packet
+	data = packet_suffix(*packet, length);
+	if(! data){
+		pq_release(packet_phone, packet_get_id(*packet));
+		return ENOMEM;
+	}
+	// read the data into the packet
+	if(ERROR_OCCURRED(async_data_write_finalize(callid, data, length))
+	// set the packet destination address
+		|| ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){
+		pq_release(packet_phone, packet_get_id(*packet));
+		return ERROR_CODE;
+	}
+	return (int) length;
+}
+
+/** @}
+ */
