Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/c/Makefile	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -101,4 +101,5 @@
 	generic/net/inet.c \
 	generic/net/modules.c \
+	generic/net/packet.c \
 	generic/net/socket_client.c \
 	generic/net/socket_parse.c \
Index: uspace/lib/c/generic/net/packet.c
===================================================================
--- uspace/lib/c/generic/net/packet.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
+++ uspace/lib/c/generic/net/packet.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -0,0 +1,424 @@
+/*
+ * 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 libc
+ *  @{
+ */
+
+/** @file
+ *  Packet map and queue implementation.
+ *  This file has to be compiled with both the packet server and the client.
+ */
+
+#include <malloc.h>
+#include <mem.h>
+#include <fibril_synch.h>
+#include <unistd.h>
+#include <errno.h>
+#include <err.h>
+
+#include <sys/mman.h>
+
+#include <adt/generic_field.h>
+#include <net/packet.h>
+#include <net/packet_header.h>
+
+/** Packet map page size. */
+#define PACKET_MAP_SIZE	100
+
+/** Returns the packet map page index.
+ * @param[in] packet_id The packet identifier.
+ */
+#define PACKET_MAP_PAGE(packet_id)	(((packet_id) - 1) / PACKET_MAP_SIZE)
+
+/** Returns the packet index in the corresponding packet map page.
+ *  @param[in] packet_id The packet identifier.
+ */
+#define PACKET_MAP_INDEX(packet_id)	(((packet_id) - 1) % PACKET_MAP_SIZE)
+
+/** Type definition of the packet map page. */
+typedef packet_t packet_map_t[PACKET_MAP_SIZE];
+
+/** Type definition of the packet map page pointer. */
+typedef packet_map_t * packet_map_ref;
+
+/** Packet map.
+ * Maps packet identifiers to the packet references.
+ * @see generic_field.h
+ */
+GENERIC_FIELD_DECLARE(gpm, packet_map_t);
+
+/** Packet map global data. */
+static struct {
+	/** Safety lock. */
+	fibril_rwlock_t lock;
+	/** Packet map. */
+	gpm_t packet_map;
+} pm_globals;
+
+GENERIC_FIELD_IMPLEMENT(gpm, packet_map_t);
+
+/** Initializes the packet map.
+ *
+ * @returns		EOK on success.
+ * @returns		ENOMEM if there is not enough memory left.
+ */
+int pm_init(void)
+{
+	ERROR_DECLARE;
+
+	fibril_rwlock_initialize(&pm_globals.lock);
+	fibril_rwlock_write_lock(&pm_globals.lock);
+	ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map));
+	fibril_rwlock_write_unlock(&pm_globals.lock);
+	return EOK;
+}
+
+/** Finds the packet mapping.
+ *
+ * @param[in] packet_id	The packet identifier to be found.
+ * @returns		The found packet reference.
+ * @returns		NULL if the mapping does not exist.
+ */
+packet_t pm_find(packet_id_t packet_id)
+{
+	packet_map_ref map;
+	packet_t packet;
+
+	if (!packet_id)
+		return NULL;
+
+	fibril_rwlock_read_lock(&pm_globals.lock);
+	if (packet_id > PACKET_MAP_SIZE * gpm_count(&pm_globals.packet_map)) {
+		fibril_rwlock_read_unlock(&pm_globals.lock);
+		return NULL;
+	}
+	map = gpm_get_index(&pm_globals.packet_map, PACKET_MAP_PAGE(packet_id));
+	if (!map) {
+		fibril_rwlock_read_unlock(&pm_globals.lock);
+		return NULL;
+	}
+	packet = (*map) [PACKET_MAP_INDEX(packet_id)];
+	fibril_rwlock_read_unlock(&pm_globals.lock);
+	return packet;
+}
+
+/** Adds the packet mapping.
+ *
+ * @param[in] packet	The packet to be remembered.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the packet is not valid.
+ * @returns		EINVAL if the packet map is not initialized.
+ * @returns		ENOMEM if there is not enough memory left.
+ */
+int pm_add(packet_t packet)
+{
+	ERROR_DECLARE;
+
+	packet_map_ref map;
+
+	if (!packet_is_valid(packet))
+		return EINVAL;
+
+	fibril_rwlock_write_lock(&pm_globals.lock);
+
+	if (PACKET_MAP_PAGE(packet->packet_id) <
+	    gpm_count(&pm_globals.packet_map)) {
+		map = gpm_get_index(&pm_globals.packet_map,
+		    PACKET_MAP_PAGE(packet->packet_id));
+	} else {
+		do {
+			map = (packet_map_ref) malloc(sizeof(packet_map_t));
+			if (!map) {
+				fibril_rwlock_write_unlock(&pm_globals.lock);
+				return ENOMEM;
+			}
+			bzero(map, sizeof(packet_map_t));
+			if ((ERROR_CODE =
+			    gpm_add(&pm_globals.packet_map, map)) < 0) {
+				fibril_rwlock_write_unlock(&pm_globals.lock);
+				free(map);
+				return ERROR_CODE;
+			}
+		} while (PACKET_MAP_PAGE(packet->packet_id) >=
+		    gpm_count(&pm_globals.packet_map));
+	}
+
+	(*map) [PACKET_MAP_INDEX(packet->packet_id)] = packet;
+	fibril_rwlock_write_unlock(&pm_globals.lock);
+	return EOK;
+}
+
+/** Releases the packet map. */
+void pm_destroy(void)
+{
+	int count;
+	int index;
+	packet_map_ref map;
+	packet_t packet;
+
+	fibril_rwlock_write_lock(&pm_globals.lock);
+	count = gpm_count(&pm_globals.packet_map);
+	while (count > 0) {
+		map = gpm_get_index(&pm_globals.packet_map, count - 1);
+		for (index = PACKET_MAP_SIZE - 1; index >= 0; --index) {
+			packet = (*map)[index];
+			if (packet_is_valid(packet))
+				munmap(packet, packet->length);
+		}
+	}
+	gpm_destroy(&pm_globals.packet_map);
+	// leave locked
+}
+
+/** Add packet to the sorted queue.
+ *
+ * The queue is sorted in the ascending order.
+ * The packet is inserted right before the packets of the same order value.
+ *
+ * @param[in,out] first	The first packet of the queue. Sets the first packet of
+ *			the queue. The original first packet may be shifted by
+ *			the new packet.
+ * @param[in] packet	The packet to be added.
+ * @param[in] order	The packet order value.
+ * @param[in] metric	The metric value of the packet.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the first parameter is NULL.
+ * @returns		EINVAL if the packet is not valid.
+ */
+int pq_add(packet_t * first, packet_t packet, size_t order, size_t metric)
+{
+	packet_t item;
+
+	if (!first || !packet_is_valid(packet))
+		return EINVAL;
+
+	pq_set_order(packet, order, metric);
+	if (packet_is_valid(*first)) {
+		item = * first;
+		do {
+			if (item->order < order) {
+				if (item->next) {
+					item = pm_find(item->next);
+				} else {
+					item->next = packet->packet_id;
+					packet->previous = item->packet_id;
+					return EOK;
+				}
+			} else {
+				packet->previous = item->previous;
+				packet->next = item->packet_id;
+				item->previous = packet->packet_id;
+				item = pm_find(packet->previous);
+				if (item)
+					item->next = packet->packet_id;
+				else
+					*first = packet;
+				return EOK;
+			}
+		} while (packet_is_valid(item));
+	}
+	*first = packet;
+	return EOK;
+}
+
+/** Finds the packet with the given order.
+ *
+ * @param[in] first	The first packet of the queue.
+ * @param[in] order	The packet order value.
+ * @returns		The packet with the given order.
+ * @returns		NULL if the first packet is not valid.
+ * @returns		NULL if the packet is not found.
+ */
+packet_t pq_find(packet_t packet, size_t order)
+{
+	packet_t item;
+
+	if (!packet_is_valid(packet))
+		return NULL;
+
+	item = packet;
+	do {
+		if (item->order == order)
+			return item;
+
+		item = pm_find(item->next);
+	} while (item && (item != packet) && packet_is_valid(item));
+
+	return NULL;
+}
+
+/** Inserts packet after the given one.
+ *
+ * @param[in] packet	The packet in the queue.
+ * @param[in] new_packet The new packet to be inserted.
+ * @returns		EOK on success.
+ * @returns		EINVAL if etiher of the packets is invalid.
+ */
+int pq_insert_after(packet_t packet, packet_t new_packet)
+{
+	packet_t item;
+
+	if (!packet_is_valid(packet) || !packet_is_valid(new_packet))
+		return EINVAL;
+
+	new_packet->previous = packet->packet_id;
+	new_packet->next = packet->next;
+	item = pm_find(packet->next);
+	if (item)
+		item->previous = new_packet->packet_id;
+	packet->next = new_packet->packet_id;
+
+	return EOK;
+}
+
+/** Detach the packet from the queue.
+ *
+ * @param[in] packet	The packet to be detached.
+ * @returns		The next packet in the queue. If the packet is the first
+ *			one of the queue, this becomes the new first one.
+ * @returns		NULL if there is no packet left.
+ * @returns		NULL if the packet is not valid.
+ */
+packet_t pq_detach(packet_t packet)
+{
+	packet_t next;
+	packet_t previous;
+
+	if (!packet_is_valid(packet))
+		return NULL;
+
+	next = pm_find(packet->next);
+	if (next) {
+		next->previous = packet->previous;
+		previous = pm_find(next->previous);
+		if (previous)
+			previous->next = next->packet_id;
+	}
+	packet->previous = 0;
+	packet->next = 0;
+	return next;
+}
+
+/** Sets the packet order and metric attributes.
+ *
+ * @param[in] packeti	The packet to be set.
+ * @param[in] order	The packet order value.
+ * @param[in] metric	The metric value of the packet.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the packet is invalid.
+ */
+int pq_set_order(packet_t packet, size_t order, size_t metric)
+{
+	if (!packet_is_valid(packet))
+		return EINVAL;
+
+	packet->order = order;
+	packet->metric = metric;
+	return EOK;
+}
+
+/** Sets the packet order and metric attributes.
+ *
+ * @param[in] packet	The packet to be set.
+ * @param[out] order	The packet order value.
+ * @param[out] metric	The metric value of the packet.
+ * @returns		EOK on success.
+ * @returns		EINVAL if the packet is invalid.
+ */
+int pq_get_order(packet_t packet, size_t *order, size_t *metric)
+{
+	if (!packet_is_valid(packet))
+		return EINVAL;
+
+	if (order)
+		*order = packet->order;
+
+	if (metric)
+		*metric = packet->metric;
+
+	return EOK;
+}
+
+/** Releases the whole queue.
+ *
+ * Detaches all packets of the queue and calls the packet_release() for each of
+ * them.
+ *
+ * @param[in] first	The first packet of the queue.
+ * @param[in] packet_release The releasing function called for each of the
+ *			packets after its detachment.
+ */
+void pq_destroy(packet_t first, void (*packet_release)(packet_t packet))
+{
+	packet_t actual;
+	packet_t next;
+
+	actual = first;
+	while (packet_is_valid(actual)) {
+		next = pm_find(actual->next);
+		actual->next = 0;
+		actual->previous = 0;
+		if(packet_release)
+			packet_release(actual);
+		actual = next;
+	}
+}
+
+/** Returns the next packet in the queue.
+ *
+ * @param[in] packet	The packet queue member.
+ * @returns		The next packet in the queue.
+ * @returns		NULL if there is no next packet.
+ * @returns		NULL if the packet is not valid.
+ */
+packet_t pq_next(packet_t packet)
+{
+	if (!packet_is_valid(packet))
+		return NULL;
+
+	return pm_find(packet->next);
+}
+
+/** Returns the previous packet in the queue.
+ *
+ * @param[in] packet	The packet queue member.
+ * @returns		The previous packet in the queue.
+ * @returns		NULL if there is no previous packet.
+ * @returns		NULL if the packet is not valid.
+ */
+packet_t pq_previous(packet_t packet)
+{
+	if (!packet_is_valid(packet))
+		return NULL;
+
+	return pm_find(packet->previous);
+}
+
+/** @}
+ */
Index: uspace/lib/c/include/net/packet.h
===================================================================
--- uspace/lib/c/include/net/packet.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
+++ uspace/lib/c/include/net/packet.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -0,0 +1,101 @@
+/*
+ * 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 libc 
+ *  @{
+ */
+
+/** @file
+ *  Packet map and queue.
+ */
+
+#ifndef LIBC_PACKET_H_
+#define LIBC_PACKET_H_
+
+/** Packet identifier type.
+ * Value zero is used as an invalid identifier.
+ */
+typedef int packet_id_t;
+
+/** Type definition of the packet.
+ * @see packet
+ */
+typedef struct packet * packet_t;
+
+/** Type definition of the packet pointer.
+ * @see packet
+ */
+typedef packet_t * packet_ref;
+
+/** Type definition of the packet dimension.
+ * @see packet_dimension
+ */
+typedef struct packet_dimension	packet_dimension_t;
+
+/** Type definition of the packet dimension pointer.
+ * @see packet_dimension
+ */
+typedef packet_dimension_t * packet_dimension_ref;
+
+/** Packet dimension. */
+struct packet_dimension {
+	/** Reserved packet prefix length. */
+	size_t prefix;
+	/** Maximal packet content length. */
+	size_t content;
+	/** Reserved packet suffix length. */
+	size_t suffix;
+	/** Maximal packet address length. */
+	size_t addr_len;
+};
+
+/** @name Packet management system interface
+ */
+/*@{*/
+
+extern packet_t pm_find(packet_id_t);
+extern int pm_add(packet_t);
+extern int pm_init(void);
+extern void pm_destroy(void);
+
+extern int pq_add(packet_t *, packet_t, size_t, size_t);
+extern packet_t pq_find(packet_t, size_t);
+extern int pq_insert_after(packet_t, packet_t);
+extern packet_t pq_detach(packet_t);
+extern int pq_set_order(packet_t, size_t, size_t);
+extern int pq_get_order(packet_t, size_t *, size_t *);
+extern void pq_destroy(packet_t, void (*)(packet_t));
+extern packet_t pq_next(packet_t);
+extern packet_t pq_previous(packet_t);
+
+/*@}*/
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/net/packet_header.h
===================================================================
--- uspace/lib/c/include/net/packet_header.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
+++ uspace/lib/c/include/net/packet_header.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -0,0 +1,138 @@
+/*
+ * 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 libc 
+ *  @{
+ */
+
+/** @file
+ * Packet header.
+ */
+
+#ifndef LIBC_PACKET_HEADER_H_
+#define LIBC_PACKET_HEADER_H_
+
+#include <net/packet.h>
+
+/** Returns the actual packet data length.
+ * @param[in] header	The packet header.
+ */
+#define PACKET_DATA_LENGTH(header) \
+	((header)->data_end - (header)->data_start)
+
+/** Returns the maximum packet address length.
+ * @param[in] header	The packet header.
+ */
+#define PACKET_MAX_ADDRESS_LENGTH(header) \
+	((header)->dest_addr - (header)->src_addr)
+
+/** Returns the minimum packet suffix.
+ *  @param[in] header	The packet header.
+ */
+#define PACKET_MIN_SUFFIX(header) \
+	((header)->length - (header)->data_start - (header)->max_content)
+
+/** Packet integrity check magic value. */
+#define PACKET_MAGIC_VALUE	0x11227788
+
+/** Packet header. */
+struct packet {
+	/** Packet identifier. */
+	packet_id_t packet_id;
+
+	/**
+	 * Packet queue sorting value.
+	 * The packet queue is sorted the ascending order.
+	 */
+	size_t order;
+
+	/** Packet metric. */
+	size_t metric;
+	/** Previous packet in the queue. */
+	packet_id_t previous;
+	/** Next packet in the queue. */
+	packet_id_t next;
+
+	/**
+	 * Total length of the packet.
+	 * Contains the header, the addresses and the data of the packet.
+	 * Corresponds to the mapped sharable memory block.
+	 */
+	size_t length;
+
+	/** Stored source and destination addresses length. */
+	size_t addr_len;
+
+	/**
+	 * Souce address offset in bytes from the beginning of the packet
+	 * header.
+	 */
+	size_t src_addr;
+
+	/**
+	 * Destination address offset in bytes from the beginning of the packet
+	 * header.
+	 */
+	size_t dest_addr;
+
+	/** Reserved data prefix length in bytes. */
+	size_t max_prefix;
+	/** Reserved content length in bytes. */
+	size_t max_content;
+
+	/**
+	 * Actual data start offset in bytes from the beginning of the packet
+	 * header.
+	 */
+	size_t data_start;
+
+	/**
+	 * Actual data end offset in bytes from the beginning of the packet
+	 * header.
+	 */
+	size_t data_end;
+
+	/** Integrity check magic value. */
+	int magic_value;
+};
+
+/** Returns whether the packet is valid.
+ * @param[in] packet	The packet to be checked.
+ * @returns		True if the packet is not NULL and the magic value is
+ *			correct.
+ * @returns		False otherwise.
+ */
+static inline int packet_is_valid(const packet_t packet)
+{
+	return packet && (packet->magic_value == PACKET_MAGIC_VALUE);
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/generic/packet_client.c
===================================================================
--- uspace/lib/net/generic/packet_client.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/generic/packet_client.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -44,6 +44,6 @@
 
 #include <net_messages.h>
-#include <packet/packet.h>
-#include <packet/packet_header.h>
+#include <net/packet.h>
+#include <net/packet_header.h>
 
 int packet_copy_data(packet_t packet, const void * data, size_t length)
Index: uspace/lib/net/generic/packet_remote.c
===================================================================
--- uspace/lib/net/generic/packet_remote.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/generic/packet_remote.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -47,6 +47,6 @@
 #include <packet_remote.h>
 
-#include <packet/packet.h>
-#include <packet/packet_header.h>
+#include <net/packet.h>
+#include <net/packet_header.h>
 
 /** Obtain the packet from the packet server as the shared memory block.
Index: uspace/lib/net/generic/socket_core.c
===================================================================
--- uspace/lib/net/generic/socket_core.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/generic/socket_core.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -46,5 +46,5 @@
 #include <adt/dynamic_fifo.h>
 #include <adt/int_map.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <packet_remote.h>
Index: uspace/lib/net/il/ip_client.c
===================================================================
--- uspace/lib/net/il/ip_client.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/il/ip_client.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -43,5 +43,5 @@
 #include <ip_header.h>
 
-#include <packet/packet.h>
+#include <net/packet.h>
 
 size_t ip_client_header_length(packet_t packet){
Index: uspace/lib/net/include/icmp_client.h
===================================================================
--- uspace/lib/net/include/icmp_client.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/icmp_client.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -39,5 +39,5 @@
 
 #include <icmp_codes.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** Processes the received packet prefixed with an ICMP header.
Index: uspace/lib/net/include/icmp_interface.h
===================================================================
--- uspace/lib/net/include/icmp_interface.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/icmp_interface.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -39,5 +39,5 @@
 #include <net_device.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <net/inet.h>
 #include <ip_codes.h>
Index: uspace/lib/net/include/il_interface.h
===================================================================
--- uspace/lib/net/include/il_interface.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/il_interface.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #include <net_messages.h>
 #include <net_device.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <il_messages.h>
Index: uspace/lib/net/include/ip_client.h
===================================================================
--- uspace/lib/net/include/ip_client.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/ip_client.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -41,5 +41,5 @@
 #include <sys/types.h>
 
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <ip_codes.h>
 #include <ip_interface.h>
Index: uspace/lib/net/include/ip_interface.h
===================================================================
--- uspace/lib/net/include/ip_interface.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/ip_interface.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -39,5 +39,5 @@
 
 #include <net_device.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 
 #include <net/in.h>
Index: uspace/lib/net/include/netif_local.h
===================================================================
--- uspace/lib/net/include/netif_local.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/netif_local.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -48,5 +48,5 @@
 #include <adt/measured_strings.h>
 #include <net_device.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** Network interface device specific data.
Index: uspace/lib/net/include/nil_interface.h
===================================================================
--- uspace/lib/net/include/nil_interface.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/nil_interface.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -41,5 +41,5 @@
 #include <net_messages.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <nil_messages.h>
 #include <net_device.h>
Index: uspace/lib/net/include/packet_client.h
===================================================================
--- uspace/lib/net/include/packet_client.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/packet_client.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #define __NET_PACKET_CLIENT_H__
 
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** @name Packet client interface
Index: uspace/lib/net/include/packet_remote.h
===================================================================
--- uspace/lib/net/include/packet_remote.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/packet_remote.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -34,5 +34,5 @@
 #define __NET_PACKET_REMOTE_H__
 
-#include <packet/packet.h>
+#include <net/packet.h>
 
 extern int packet_translate_remote(int, packet_ref, packet_id_t);
Index: uspace/lib/net/include/tl_common.h
===================================================================
--- uspace/lib/net/include/tl_common.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/tl_common.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -39,6 +39,5 @@
 
 #include <net/socket_codes.h>
-
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <net_device.h>
 #include <net/inet.h>
Index: uspace/lib/net/include/tl_interface.h
===================================================================
--- uspace/lib/net/include/tl_interface.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/include/tl_interface.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -43,5 +43,5 @@
 #include <net_messages.h>
 #include <net_device.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <tl_messages.h>
Index: uspace/lib/net/netif/netif_local.c
===================================================================
--- uspace/lib/net/netif/netif_local.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/netif/netif_local.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -46,5 +46,5 @@
 #include <net_messages.h>
 #include <net/modules.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <packet/packet_server.h>
Index: uspace/lib/net/netif/netif_nil_bundle.c
===================================================================
--- uspace/lib/net/netif/netif_nil_bundle.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/netif/netif_nil_bundle.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -40,5 +40,5 @@
 #include <ipc/net.h>
 
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <netif_nil_bundle.h>
 #include <netif_local.h>
Index: uspace/lib/net/netif/netif_remote.c
===================================================================
--- uspace/lib/net/netif/netif_remote.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/netif/netif_remote.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -39,5 +39,5 @@
 #include <net/modules.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <net_device.h>
Index: uspace/lib/net/nil/nil_remote.c
===================================================================
--- uspace/lib/net/nil/nil_remote.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/nil/nil_remote.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -39,5 +39,5 @@
 #include <net_device.h>
 #include <nil_interface.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <nil_messages.h>
Index: uspace/lib/net/tl/icmp_client.c
===================================================================
--- uspace/lib/net/tl/icmp_client.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/tl/icmp_client.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #include <icmp_codes.h>
 #include <icmp_client.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <icmp_header.h>
Index: uspace/lib/net/tl/tl_common.c
===================================================================
--- uspace/lib/net/tl/tl_common.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/net/tl/tl_common.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #include <err.h>
 
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <packet_remote.h>
Index: uspace/lib/socket/Makefile
===================================================================
--- uspace/lib/socket/Makefile	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/socket/Makefile	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -35,6 +35,5 @@
 	generic/icmp_common.c \
 	generic/icmp_api.c \
-	packet/packet.c \
-	packet/packet_server.c 
+	packet/packet_server.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/socket/include/icmp_api.h
===================================================================
--- uspace/lib/socket/include/icmp_api.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/socket/include/icmp_api.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -44,5 +44,5 @@
 #include <net_device.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <ip_codes.h>
 #include <icmp_codes.h>
Index: uspace/lib/socket/include/net_messages.h
===================================================================
--- uspace/lib/socket/include/net_messages.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/socket/include/net_messages.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -44,5 +44,5 @@
 #include <net_device.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** @name Networking specific message arguments definitions
Index: pace/lib/socket/include/packet/packet.h
===================================================================
--- uspace/lib/socket/include/packet/packet.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ 	(revision )
@@ -1,196 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup packet
- *  @{
- */
-
-/** @file
- *  Packet map and queue.
- */
-
-#ifndef __NET_PACKET_H__
-#define __NET_PACKET_H__
-
-/** Packet identifier type.
- *  Value zero (0) is used as an invalid identifier.
- */
-typedef int	packet_id_t;
-
-/** Type definition of the packet.
- *  @see packet
- */
-typedef struct packet *	packet_t;
-
-/** Type definition of the packet pointer.
- *  @see packet
- */
-typedef packet_t *		packet_ref;
-
-/** Type definition of the packet dimension.
- *  @see packet_dimension
- */
-typedef struct packet_dimension	packet_dimension_t;
-
-/** Type definition of the packet dimension pointer.
- *  @see packet_dimension
- */
-typedef packet_dimension_t *	packet_dimension_ref;
-
-/** Packet dimension.
- */
-struct packet_dimension{
-	/** Reserved packet prefix length.
-	 */
-	size_t prefix;
-	/** Maximal packet content length.
-	 */
-	size_t content;
-	/** Reserved packet suffix length.
-	 */
-	size_t suffix;
-	/** Maximal packet address length.
-	 */
-	size_t addr_len;
-};
-
-/** @name Packet management system interface
- */
-/*@{*/
-
-/** Finds the packet mapping.
- *  @param[in] packet_id The packet identifier to be found.
- *  @returns The found packet reference.
- *  @returns NULL if the mapping does not exist.
- */
-extern packet_t pm_find(packet_id_t packet_id);
-
-/** Adds the packet mapping.
- *  @param[in] packet The packet to be remembered.
- *  @returns EOK on success.
- *  @returns EINVAL if the packet is not valid.
- *  @returns EINVAL if the packet map is not initialized.
- *  @returns ENOMEM if there is not enough memory left.
- */
-extern int pm_add(packet_t packet);
-
-/** Initializes the packet map.
- *  @returns EOK on success.
- *  @returns ENOMEM if there is not enough memory left.
- */
-extern int pm_init(void);
-
-/** Releases the packet map.
- */
-extern void pm_destroy(void);
-
-/** Add packet to the sorted queue.
- *  The queue is sorted in the ascending order.
- *  The packet is inserted right before the packets of the same order value.
- *  @param[in,out] first The first packet of the queue. Sets the first packet of the queue. The original first packet may be shifted by the new packet.
- *  @param[in] packet The packet to be added.
- *  @param[in] order The packet order value.
- *  @param[in] metric The metric value of the packet.
- *  @returns EOK on success.
- *  @returns EINVAL if the first parameter is NULL.
- *  @returns EINVAL if the packet is not valid.
- */
-extern int pq_add(packet_t * first, packet_t packet, size_t order, size_t metric);
-
-/** Finds the packet with the given order.
- *  @param[in] first The first packet of the queue.
- *  @param[in] order The packet order value.
- *  @returns The packet with the given order.
- *  @returns NULL if the first packet is not valid.
- *  @returns NULL if the packet is not found.
- */
-extern packet_t pq_find(packet_t first, size_t order);
-
-/** Inserts packet after the given one.
- *  @param[in] packet The packet in the queue.
- *  @param[in] new_packet The new packet to be inserted.
- *  @returns EOK on success.
- *  @returns EINVAL if etiher of the packets is invalid.
- */
-extern int pq_insert_after(packet_t packet, packet_t new_packet);
-
-/** Detach the packet from the queue.
- *  @param[in] packet The packet to be detached.
- *  @returns The next packet in the queue. If the packet is the first one of the queue, this becomes the new first one.
- *  @returns NULL if there is no packet left.
- *  @returns NULL if the packet is not valid.
- */
-extern packet_t pq_detach(packet_t packet);
-
-/** Sets the packet order and metric attributes.
- *  @param[in] packet The packet to be set.
- *  @param[in] order The packet order value.
- *  @param[in] metric The metric value of the packet.
- *  @returns EOK on success.
- *  @returns EINVAL if the packet is invalid..
- */
-extern int pq_set_order(packet_t packet, size_t order, size_t metric);
-
-/** Sets the packet order and metric attributes.
- *  @param[in] packet The packet to be set.
- *  @param[out] order The packet order value.
- *  @param[out] metric The metric value of the packet.
- *  @returns EOK on success.
- *  @returns EINVAL if the packet is invalid..
- */
-extern int pq_get_order(packet_t packet, size_t * order, size_t * metric);
-
-/** Releases the whole queue.
- *  Detaches all packets of the queue and calls the packet_release() for each of them.
- *  @param[in] first The first packet of the queue.
- *  @param[in] packet_release The releasing function called for each of the packets after its detachment.
- */
-extern void pq_destroy(packet_t first, void (*packet_release)(packet_t packet));
-
-/** Returns the next packet in the queue.
- *  @param[in] packet The packet queue member.
- *  @returns The next packet in the queue.
- *  @returns NULL if there is no next packet.
- *  @returns NULL if the packet is not valid.
- */
-extern packet_t pq_next(packet_t packet);
-
-/** Returns the previous packet in the queue.
- *  @param[in] packet The packet queue member.
- *  @returns The previous packet in the queue.
- *  @returns NULL if there is no previous packet.
- *  @returns NULL if the packet is not valid.
- */
-extern packet_t pq_previous(packet_t packet);
-
-/*@}*/
-
-#endif
-
-/** @}
- */
Index: pace/lib/socket/include/packet/packet_header.h
===================================================================
--- uspace/lib/socket/include/packet/packet_header.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ 	(revision )
@@ -1,123 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup packet
- *  @{
- */
-
-/** @file
- *  Packet header.
- */
-
-#ifndef __NET_PACKET_HEADER_H__
-#define __NET_PACKET_HEADER_H__
-
-#include <packet/packet.h>
-
-/** Returns the actual packet data length.
- *  @param[in] header The packet header.
- */
-#define PACKET_DATA_LENGTH(header)		((header)->data_end - (header)->data_start)
-
-/** Returns the maximum packet address length.
- *  @param[in] header The packet header.
- */
-#define PACKET_MAX_ADDRESS_LENGTH(header)		((header)->dest_addr - (header)->src_addr)
-
-/** Returns the minimum packet suffix.
- *  @param[in] header The packet header.
- */
-#define PACKET_MIN_SUFFIX(header)		((header)->length - (header)->data_start - (header)->max_content)
-
-/** Packet integrity check magic value.
- */
-#define PACKET_MAGIC_VALUE	0x11227788
-
-/** Packet header.
- */
-struct packet{
-	/** Packet identifier.
-	 */
-	packet_id_t packet_id;
-	/** Packet queue sorting value.
-	 *  The packet queue is sorted the ascending order.
-	 */
-	size_t order;
-	/** Packet metric.
-	 */
-	size_t metric;
-	/** Previous packet in the queue.
-	 */
-	packet_id_t previous;
-	/** Next packet in the queue.
-	 */
-	packet_id_t next;
-	/** Total length of the packet.
-	 *  Contains the header, the addresses and the data of the packet.
-	 *  Corresponds to the mapped sharable memory block.
-	 */
-	size_t length;
-	/** Stored source and destination addresses length.
-	 */
-	size_t addr_len;
-	/** Souce address offset in bytes from the beginning of the packet header.
-	 */
-	size_t src_addr;
-	/** Destination address offset in bytes from the beginning of the packet header.
-	 */
-	size_t dest_addr;
-	/** Reserved data prefix length in bytes.
-	 */
-	size_t max_prefix;
-	/** Reserved content length in bytes.
-	 */
-	size_t max_content;
-	/** Actual data start offset in bytes from the beginning of the packet header.
-	 */
-	size_t data_start;
-	/** Actual data end offset in bytes from the beginning of the packet header.
-	 */
-	size_t data_end;
-	/** Integrity check magic value.
-	 */
-	int magic_value;
-};
-
-/** Returns whether the packet is valid.
- *  @param[in] packet The packet to be checked.
- *  @returns true if the packet is not NULL and the magic value is correct.
- *  @returns false otherwise.
- */
-static inline int packet_is_valid(const packet_t packet){
-	return packet && (packet->magic_value == PACKET_MAGIC_VALUE);
-}
-
-#endif
-
-/** @}
- */
Index: uspace/lib/socket/include/packet/packet_local.h
===================================================================
--- uspace/lib/socket/include/packet/packet_local.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/socket/include/packet/packet_local.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -37,5 +37,5 @@
 #define __NET_PACKET_LOCAL_H__
 
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** @name Packet local interface
Index: uspace/lib/socket/include/socket_core.h
===================================================================
--- uspace/lib/socket/include/socket_core.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/socket/include/socket_core.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #include <adt/dynamic_fifo.h>
 #include <adt/int_map.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** Initial size of the received packet queue.
Index: pace/lib/socket/packet/packet.c
===================================================================
--- uspace/lib/socket/packet/packet.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ 	(revision )
@@ -1,330 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup packet
- *  @{
- */
-
-/** @file
- *  Packet map and queue implementation.
- *  This file has to be compiled with both the packet server and the client.
- */
-
-#include <malloc.h>
-#include <mem.h>
-#include <fibril_synch.h>
-#include <unistd.h>
-#include <errno.h>
-#include <err.h>
-
-#include <sys/mman.h>
-
-#include <adt/generic_field.h>
-#include <packet/packet.h>
-#include <packet/packet_header.h>
-
-/** Packet map page size.
- */
-#define PACKET_MAP_SIZE	100
-
-/** Returns the packet map page index.
- *  @param[in] packet_id The packet identifier.
- */
-#define PACKET_MAP_PAGE(packet_id)	(((packet_id) - 1) / PACKET_MAP_SIZE)
-
-/** Returns the packet index in the corresponding packet map page.
- *  @param[in] packet_id The packet identifier.
- */
-#define PACKET_MAP_INDEX(packet_id)	(((packet_id) - 1) % PACKET_MAP_SIZE)
-
-/** Type definition of the packet map page.
- */
-typedef packet_t packet_map_t[PACKET_MAP_SIZE];
-/** Type definition of the packet map page pointer.
- */
-typedef packet_map_t * packet_map_ref;
-
-/** Packet map.
- *  Maps packet identifiers to the packet references.
- *  @see generic_field.h
- */
-GENERIC_FIELD_DECLARE(gpm, packet_map_t);
-
-/** Releases the packet.
- *  @param[in] packet The packet to be released.
- *  @returns EOK on success.
- *  @returns EINVAL if the packet is not valid.
- */
-int packet_destroy(packet_t packet);
-
-/** Packet map global data.
- */
-static struct{
-	/** Safety lock.
-	 */
-	fibril_rwlock_t lock;
-	/** Packet map.
-	 */
-	gpm_t packet_map;
-} pm_globals;
-
-GENERIC_FIELD_IMPLEMENT(gpm, packet_map_t);
-
-int packet_destroy(packet_t packet){
-	if(! packet_is_valid(packet)){
-		return EINVAL;
-	}
-	return munmap(packet, packet->length);
-}
-
-int pm_init(void){
-	ERROR_DECLARE;
-
-	fibril_rwlock_initialize(&pm_globals.lock);
-	fibril_rwlock_write_lock(&pm_globals.lock);
-	ERROR_PROPAGATE(gpm_initialize(&pm_globals.packet_map));
-	fibril_rwlock_write_unlock(&pm_globals.lock);
-	return EOK;
-}
-
-packet_t pm_find(packet_id_t packet_id){
-	packet_map_ref map;
-	packet_t packet;
-
-	if(! packet_id){
-		return NULL;
-	}
-	fibril_rwlock_read_lock(&pm_globals.lock);
-	if(packet_id > PACKET_MAP_SIZE * gpm_count(&pm_globals.packet_map)){
-		fibril_rwlock_read_unlock(&pm_globals.lock);
-		return NULL;
-	}
-	map = gpm_get_index(&pm_globals.packet_map, PACKET_MAP_PAGE(packet_id));
-	if(! map){
-		fibril_rwlock_read_unlock(&pm_globals.lock);
-		return NULL;
-	}
-	packet = (*map)[PACKET_MAP_INDEX(packet_id)];
-	fibril_rwlock_read_unlock(&pm_globals.lock);
-	return packet;
-}
-
-int pm_add(packet_t packet){
-	ERROR_DECLARE;
-
-	packet_map_ref map;
-
-	if(! packet_is_valid(packet)){
-		return EINVAL;
-	}
-	fibril_rwlock_write_lock(&pm_globals.lock);
-	if(PACKET_MAP_PAGE(packet->packet_id) < gpm_count(&pm_globals.packet_map)){
-		map = gpm_get_index(&pm_globals.packet_map, PACKET_MAP_PAGE(packet->packet_id));
-	}else{
-		do{
-			map = (packet_map_ref) malloc(sizeof(packet_map_t));
-			if(! map){
-				fibril_rwlock_write_unlock(&pm_globals.lock);
-				return ENOMEM;
-			}
-			bzero(map, sizeof(packet_map_t));
-			if((ERROR_CODE = gpm_add(&pm_globals.packet_map, map)) < 0){
-				fibril_rwlock_write_unlock(&pm_globals.lock);
-				free(map);
-				return ERROR_CODE;
-			}
-		}while(PACKET_MAP_PAGE(packet->packet_id) >= gpm_count(&pm_globals.packet_map));
-	}
-	(*map)[PACKET_MAP_INDEX(packet->packet_id)] = packet;
-	fibril_rwlock_write_unlock(&pm_globals.lock);
-	return EOK;
-}
-
-void pm_destroy(void){
-	int count;
-	int index;
-	packet_map_ref map;
-	packet_t packet;
-
-	fibril_rwlock_write_lock(&pm_globals.lock);
-	count = gpm_count(&pm_globals.packet_map);
-	while(count > 0){
-		map = gpm_get_index(&pm_globals.packet_map, count - 1);
-		for(index = PACKET_MAP_SIZE - 1; index >= 0; -- index){
-			packet = (*map)[index];
-			if(packet_is_valid(packet)){
-				munmap(packet, packet->length);
-			}
-		}
-	}
-	gpm_destroy(&pm_globals.packet_map);
-	// leave locked
-}
-
-int pq_add(packet_t * first, packet_t packet, size_t order, size_t metric){
-	packet_t item;
-
-	if((! first) || (! packet_is_valid(packet))){
-		return EINVAL;
-	}
-	pq_set_order(packet, order, metric);
-	if(packet_is_valid(*first)){
-		item = * first;
-		do{
-			if(item->order < order){
-				if(item->next){
-					item = pm_find(item->next);
-				}else{
-					item->next = packet->packet_id;
-					packet->previous = item->packet_id;
-					return EOK;
-				}
-			}else{
-				packet->previous = item->previous;
-				packet->next = item->packet_id;
-				item->previous = packet->packet_id;
-				item = pm_find(packet->previous);
-				if(item){
-					item->next = packet->packet_id;
-				}else{
-					*first = packet;
-				}
-				return EOK;
-			}
-		}while(packet_is_valid(item));
-	}
-	*first = packet;
-	return EOK;
-}
-
-packet_t pq_find(packet_t packet, size_t order){
-	packet_t item;
-
-	if(! packet_is_valid(packet)){
-		return NULL;
-	}
-	item = packet;
-	do{
-		if(item->order == order){
-			return item;
-		}
-		item = pm_find(item->next);
-	}while(item && (item != packet) && packet_is_valid(item));
-	return NULL;
-}
-
-int pq_insert_after(packet_t packet, packet_t new_packet){
-	packet_t item;
-
-	if(!(packet_is_valid(packet) && packet_is_valid(new_packet))){
-		return EINVAL;
-	}
-	new_packet->previous = packet->packet_id;
-	new_packet->next = packet->next;
-	item = pm_find(packet->next);
-	if(item){
-		item->previous = new_packet->packet_id;
-	}
-	packet->next = new_packet->packet_id;
-	return EOK;
-}
-
-packet_t pq_detach(packet_t packet){
-	packet_t next;
-	packet_t previous;
-
-	if(! packet_is_valid(packet)){
-		return NULL;
-	}
-	next = pm_find(packet->next);
-	if(next){
-		next->previous = packet->previous;
-		previous = pm_find(next->previous);
-		if(previous){
-			previous->next = next->packet_id;
-		}
-	}
-	packet->previous = 0;
-	packet->next = 0;
-	return next;
-}
-
-int pq_set_order(packet_t packet, size_t order, size_t metric){
-	if(! packet_is_valid(packet)){
-		return EINVAL;
-	}
-	packet->order = order;
-	packet->metric = metric;
-	return EOK;
-}
-
-int pq_get_order(packet_t packet, size_t * order, size_t * metric){
-	if(! packet_is_valid(packet)){
-		return EINVAL;
-	}
-	if(order){
-		*order = packet->order;
-	}
-	if(metric){
-		*metric = packet->metric;
-	}
-	return EOK;
-}
-
-void pq_destroy(packet_t first, void (*packet_release)(packet_t packet)){
-	packet_t actual;
-	packet_t next;
-
-	actual = first;
-	while(packet_is_valid(actual)){
-		next = pm_find(actual->next);
-		actual->next = 0;
-		actual->previous = 0;
-		if(packet_release){
-			packet_release(actual);
-		}
-		actual = next;
-	}
-}
-
-packet_t pq_next(packet_t packet){
-	if(! packet_is_valid(packet)){
-		return NULL;
-	}
-	return pm_find(packet->next);
-}
-
-packet_t pq_previous(packet_t packet){
-	if(! packet_is_valid(packet)){
-		return NULL;
-	}
-	return pm_find(packet->previous);
-}
-
-/** @}
- */
Index: uspace/lib/socket/packet/packet_server.c
===================================================================
--- uspace/lib/socket/packet/packet_server.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/lib/socket/packet/packet_server.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -46,10 +46,10 @@
 #include <ipc/ipc.h>
 #include <ipc/packet.h>
+#include <net/packet.h>
+#include <net/packet_header.h>
+#include <packet/packet_server.h>
 
 #include <net_messages.h>
-#include <packet/packet.h>
 #include <packet/packet_local.h>
-#include <packet/packet_header.h>
-#include <packet/packet_server.h>
 
 #define FREE_QUEUES_COUNT	7
Index: uspace/srv/hw/netif/dp8390/dp8390.c
===================================================================
--- uspace/srv/hw/netif/dp8390/dp8390.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/hw/netif/dp8390/dp8390.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -38,5 +38,5 @@
 
 #include <netif_local.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 
Index: uspace/srv/hw/netif/dp8390/dp8390.h
===================================================================
--- uspace/srv/hw/netif/dp8390/dp8390.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/hw/netif/dp8390/dp8390.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -36,5 +36,5 @@
 #define __NET_NETIF_DP8390_H__
 
-#include <packet/packet.h>
+#include <net/packet.h>
 
 #include "dp8390_port.h"
Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/il/arp/arp.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -55,5 +55,5 @@
 #include <protocol_map.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_client.h>
 #include <packet_remote.h>
Index: uspace/srv/net/il/arp/arp_module.c
===================================================================
--- uspace/srv/net/il/arp/arp_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/il/arp/arp_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -47,5 +47,5 @@
 #include <net/modules.h>
 #include <net_interface.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <il_local.h>
 
Index: uspace/srv/net/il/ip/ip_module.c
===================================================================
--- uspace/srv/net/il/ip/ip_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/il/ip/ip_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -46,5 +46,5 @@
 #include <net/modules.h>
 #include <net_interface.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <il_local.h>
 
Index: uspace/srv/net/net/net.c
===================================================================
--- uspace/srv/net/net/net.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/net/net.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -54,5 +54,5 @@
 #include <adt/measured_strings.h>
 #include <adt/module_map.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <il_messages.h>
 #include <netif_remote.h>
Index: uspace/srv/net/net/net.h
===================================================================
--- uspace/srv/net/net/net.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/net/net.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -46,5 +46,5 @@
 #include <adt/measured_strings.h>
 #include <adt/module_map.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 
 /** @name Modules definitions
Index: uspace/srv/net/nil/eth/eth_module.c
===================================================================
--- uspace/srv/net/nil/eth/eth_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/nil/eth/eth_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #include <net/modules.h>
 #include <net_interface.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <nil_local.h>
 
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -52,5 +52,5 @@
 #include <il_interface.h>
 #include <adt/measured_strings.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <packet_remote.h>
 #include <nil_local.h>
Index: uspace/srv/net/nil/nildummy/nildummy_module.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/nil/nildummy/nildummy_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 #include <net/modules.h>
 #include <net_interface.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <nil_local.h>
 
Index: uspace/srv/net/tl/icmp/icmp_module.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/tl/icmp/icmp_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 
 #include <net/modules.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <net_interface.h>
 #include <tl_local.h>
Index: uspace/srv/net/tl/tcp/tcp.h
===================================================================
--- uspace/srv/net/tl/tcp/tcp.h	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/tl/tcp/tcp.h	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -40,5 +40,5 @@
 #include <fibril_synch.h>
 
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <net_device.h>
 #include <socket_core.h>
Index: uspace/srv/net/tl/tcp/tcp_module.c
===================================================================
--- uspace/srv/net/tl/tcp/tcp_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/tl/tcp/tcp_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -47,5 +47,5 @@
 #include <net/modules.h>
 
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <net_interface.h>
 #include <ip_interface.h>
Index: uspace/srv/net/tl/udp/udp_module.c
===================================================================
--- uspace/srv/net/tl/udp/udp_module.c	(revision 0a866eebd91749e0380adb6b7af11e95a433af59)
+++ uspace/srv/net/tl/udp/udp_module.c	(revision c69d327931c88d2878c9d58f4aa911edd6e873ea)
@@ -45,5 +45,5 @@
 
 #include <net/modules.h>
-#include <packet/packet.h>
+#include <net/packet.h>
 #include <net_interface.h>
 #include <tl_local.h>
