Index: uspace/app/netstart/self_test.c
===================================================================
--- uspace/app/netstart/self_test.c	(revision c9256c5f5e299d763ed535094644b95f59066b88)
+++ uspace/app/netstart/self_test.c	(revision c9256c5f5e299d763ed535094644b95f59066b88)
@@ -0,0 +1,334 @@
+/*
+ * 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 self-tests implementation.
+ *
+ */
+
+#include <errno.h>
+#include <malloc.h>
+#include <stdio.h>
+
+#include <net_checksum.h>
+#include <adt/int_map.h>
+#include <adt/char_map.h>
+#include <adt/generic_char_map.h>
+#include <adt/measured_strings.h>
+#include <adt/dynamic_fifo.h>
+
+#include "self_test.h"
+
+/** Test the statement, compare the result and evaluate.
+ *
+ * @param[in] statement The statement to test.
+ * @param[in] result    The expected result.
+ *
+ */
+#define TEST(statement, result) \
+	do { \
+		printf("\n\t%s == %s", #statement, #result); \
+		if ((statement) != (result)) { \
+			printf("\tfailed\n"); \
+			fprintf(stderr, "\nNetwork self-test failed\n"); \
+			return EINVAL; \
+		} else \
+			printf("\tOK"); \
+	} while (0)
+
+#define XMALLOC(var, type) \
+	do { \
+		(var) = (type *) malloc(sizeof(type)); \
+		if ((var) == NULL) { \
+			fprintf(stderr, "\nMemory allocation error\n"); \
+			return ENOMEM; \
+		} \
+	} while (0)
+
+GENERIC_CHAR_MAP_DECLARE(int_char_map, int);
+GENERIC_CHAR_MAP_IMPLEMENT(int_char_map, int);
+
+GENERIC_FIELD_DECLARE(int_field, int);
+GENERIC_FIELD_IMPLEMENT(int_field, int);
+
+INT_MAP_DECLARE(int_map, int);
+INT_MAP_IMPLEMENT(int_map, int);
+
+/** Self-test start function.
+ *
+ * Run all self-tests.
+ *
+ * @returns EOK on success.
+ * @returns The first error occurred.
+ *
+ */
+int self_test(void)
+{
+	printf("Running networking self-tests\n");
+	
+	printf("\nChar map test");
+	char_map_t cm;
+	
+	TEST(char_map_update(&cm, "ucho", 0, 3), EINVAL);
+	TEST(char_map_initialize(&cm), EOK);
+	TEST(char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_find(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_add(&cm, "bla", 0, 1), EOK);
+	TEST(char_map_find(&cm, "bla", 0), 1);
+	TEST(char_map_add(&cm, "bla", 0, 10), EEXISTS);
+	TEST(char_map_update(&cm, "bla", 0, 2), EOK);
+	TEST(char_map_find(&cm, "bla", 0), 2);
+	TEST(char_map_update(&cm, "ucho", 0, 2), EOK);
+	TEST(char_map_exclude(&cm, "bla", 0), 2);
+	TEST(char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_find(&cm, "ucho", 0), 2);
+	TEST(char_map_update(&cm, "ucho", 0, 3), EOK);
+	TEST(char_map_find(&cm, "ucho", 0), 3);
+	TEST(char_map_add(&cm, "blabla", 0, 5), EOK);
+	TEST(char_map_find(&cm, "blabla", 0), 5);
+	TEST(char_map_add(&cm, "bla", 0, 6), EOK);
+	TEST(char_map_find(&cm, "bla", 0), 6);
+	TEST(char_map_exclude(&cm, "bla", 0), 6);
+	TEST(char_map_find(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_find(&cm, "blabla", 0), 5);
+	TEST(char_map_add(&cm, "auto", 0, 7), EOK);
+	TEST(char_map_find(&cm, "auto", 0), 7);
+	TEST(char_map_add(&cm, "kara", 0, 8), EOK);
+	TEST(char_map_find(&cm, "kara", 0), 8);
+	TEST(char_map_add(&cm, "nic", 0, 9), EOK);
+	TEST(char_map_find(&cm, "nic", 0), 9);
+	TEST(char_map_find(&cm, "blabla", 0), 5);
+	TEST(char_map_add(&cm, "micnicnic", 5, 9), EOK);
+	TEST(char_map_find(&cm, "micni", 0), 9);
+	TEST(char_map_find(&cm, "micnicn", 5), 9);
+	TEST(char_map_add(&cm, "\x10\x0\x2\x2", 4, 15), EOK);
+	TEST(char_map_find(&cm, "\x10\x0\x2\x2", 4), 15);
+	
+	TEST((char_map_destroy(&cm), EOK), EOK);
+	TEST(char_map_update(&cm, "ucho", 0, 3), EINVAL);
+	
+	printf("\nCRC computation test");
+	uint32_t value;
+	
+	TEST(value = ~compute_crc32(~0, "123456789", 8 * 9), 0xcbf43926);
+	TEST(value = ~compute_crc32(~0, "1", 8), 0x83dcefb7);
+	TEST(value = ~compute_crc32(~0, "12", 8 * 2), 0x4f5344cd);
+	TEST(value = ~compute_crc32(~0, "123", 8 * 3), 0x884863d2);
+	TEST(value = ~compute_crc32(~0, "1234", 8 * 4), 0x9be3e0a3);
+	TEST(value = ~compute_crc32(~0, "12345678", 8 * 8), 0x9ae0daaf);
+	TEST(value = ~compute_crc32(~0, "ahoj pane", 8 * 9), 0x5fc3d706);
+	
+	printf("\nDynamic fifo test");
+	dyn_fifo_t fifo;
+	
+	TEST(dyn_fifo_push(&fifo, 1, 0), EINVAL);
+	TEST(dyn_fifo_initialize(&fifo, 1), EOK);
+	TEST(dyn_fifo_push(&fifo, 1, 0), EOK);
+	TEST(dyn_fifo_pop(&fifo), 1);
+	TEST(dyn_fifo_pop(&fifo), ENOENT);
+	TEST(dyn_fifo_push(&fifo, 2, 1), EOK);
+	TEST(dyn_fifo_push(&fifo, 3, 1), ENOMEM);
+	TEST(dyn_fifo_push(&fifo, 3, 0), EOK);
+	TEST(dyn_fifo_pop(&fifo), 2);
+	TEST(dyn_fifo_pop(&fifo), 3);
+	TEST(dyn_fifo_push(&fifo, 4, 2), EOK);
+	TEST(dyn_fifo_push(&fifo, 5, 2), EOK);
+	TEST(dyn_fifo_push(&fifo, 6, 2), ENOMEM);
+	TEST(dyn_fifo_push(&fifo, 6, 5), EOK);
+	TEST(dyn_fifo_push(&fifo, 7, 5), EOK);
+	TEST(dyn_fifo_pop(&fifo), 4);
+	TEST(dyn_fifo_pop(&fifo), 5);
+	TEST(dyn_fifo_push(&fifo, 8, 5), EOK);
+	TEST(dyn_fifo_push(&fifo, 9, 5), EOK);
+	TEST(dyn_fifo_push(&fifo, 10, 6), EOK);
+	TEST(dyn_fifo_push(&fifo, 11, 6), EOK);
+	TEST(dyn_fifo_pop(&fifo), 6);
+	TEST(dyn_fifo_pop(&fifo), 7);
+	TEST(dyn_fifo_push(&fifo, 12, 6), EOK);
+	TEST(dyn_fifo_push(&fifo, 13, 6), EOK);
+	TEST(dyn_fifo_push(&fifo, 14, 6), ENOMEM);
+	TEST(dyn_fifo_push(&fifo, 14, 8), EOK);
+	TEST(dyn_fifo_pop(&fifo), 8);
+	TEST(dyn_fifo_pop(&fifo), 9);
+	TEST(dyn_fifo_pop(&fifo), 10);
+	TEST(dyn_fifo_pop(&fifo), 11);
+	TEST(dyn_fifo_pop(&fifo), 12);
+	TEST(dyn_fifo_pop(&fifo), 13);
+	TEST(dyn_fifo_pop(&fifo), 14);
+	TEST(dyn_fifo_destroy(&fifo), EOK);
+	TEST(dyn_fifo_push(&fifo, 1, 0), EINVAL);
+	
+	printf("\nGeneric char map test");
+	
+	int *x;
+	int *y;
+	int *z;
+	int *u;
+	int *v;
+	int *w;
+	
+	XMALLOC(x, int);
+	XMALLOC(y, int);
+	XMALLOC(z, int);
+	XMALLOC(u, int);
+	XMALLOC(v, int);
+	XMALLOC(w, int);
+	
+	int_char_map_t icm;
+	icm.magic = 0;
+	
+	TEST(int_char_map_add(&icm, "ucho", 0, z), EINVAL);
+	TEST(int_char_map_initialize(&icm), EOK);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), NULL);
+	TEST(int_char_map_add(&icm, "bla", 0, x), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), x);
+	TEST(int_char_map_add(&icm, "bla", 0, y), EEXISTS);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST(int_char_map_add(&icm, "blabla", 0, v), EOK);
+	TEST(int_char_map_find(&icm, "blabla", 0), v);
+	TEST(int_char_map_add(&icm, "bla", 0, w), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), w);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), NULL);
+	TEST(int_char_map_find(&icm, "blabla", 0), v);
+	TEST(int_char_map_add(&icm, "auto", 0, u), EOK);
+	TEST(int_char_map_find(&icm, "auto", 0), u);
+	TEST((int_char_map_destroy(&icm), EOK), EOK);
+	TEST(int_char_map_add(&icm, "ucho", 0, z), EINVAL);
+	
+	printf("\nGeneric field test");
+	
+	XMALLOC(x, int);
+	XMALLOC(y, int);
+	XMALLOC(z, int);
+	XMALLOC(u, int);
+	XMALLOC(v, int);
+	XMALLOC(w, int);
+	
+	int_field_t gf;
+	gf.magic = 0;
+	
+	TEST(int_field_add(&gf, x), EINVAL);
+	TEST(int_field_count(&gf), -1);
+	TEST(int_field_initialize(&gf), EOK);
+	TEST(int_field_count(&gf), 0);
+	TEST(int_field_get_index(&gf, 1), NULL);
+	TEST(int_field_add(&gf, x), 0);
+	TEST(int_field_get_index(&gf, 0), x);
+	TEST((int_field_exclude_index(&gf, 0), EOK), EOK);
+	TEST(int_field_get_index(&gf, 0), NULL);
+	TEST(int_field_add(&gf, y), 1);
+	TEST(int_field_get_index(&gf, 1), y);
+	TEST(int_field_add(&gf, z), 2);
+	TEST(int_field_get_index(&gf, 2), z);
+	TEST(int_field_get_index(&gf, 1), y);
+	TEST(int_field_count(&gf), 3);
+	TEST(int_field_add(&gf, u), 3);
+	TEST(int_field_get_index(&gf, 3), u);
+	TEST(int_field_add(&gf, v), 4);
+	TEST(int_field_get_index(&gf, 4), v);
+	TEST(int_field_add(&gf, w), 5);
+	TEST(int_field_get_index(&gf, 5), w);
+	TEST(int_field_count(&gf), 6);
+	TEST((int_field_exclude_index(&gf, 1), EOK), EOK);
+	TEST(int_field_get_index(&gf, 1), NULL);
+	TEST(int_field_get_index(&gf, 3), u);
+	TEST((int_field_exclude_index(&gf, 7), EOK), EOK);
+	TEST(int_field_get_index(&gf, 3), u);
+	TEST(int_field_get_index(&gf, 5), w);
+	TEST((int_field_exclude_index(&gf, 4), EOK), EOK);
+	TEST(int_field_get_index(&gf, 4), NULL);
+	TEST((int_field_destroy(&gf), EOK), EOK);
+	TEST(int_field_count(&gf), -1);
+	
+	printf("\nInt map test");
+	
+	XMALLOC(x, int);
+	XMALLOC(y, int);
+	XMALLOC(z, int);
+	XMALLOC(u, int);
+	XMALLOC(v, int);
+	XMALLOC(w, int);
+	
+	int_map_t im;
+	im.magic = 0;
+	
+	TEST(int_map_add(&im, 1, x), EINVAL);
+	TEST(int_map_count(&im), -1);
+	TEST(int_map_initialize(&im), EOK);
+	TEST(int_map_count(&im), 0);
+	TEST(int_map_find(&im, 1), NULL);
+	TEST(int_map_add(&im, 1, x), 0);
+	TEST(int_map_find(&im, 1), x);
+	TEST((int_map_exclude(&im, 1), EOK), EOK);
+	TEST(int_map_find(&im, 1), NULL);
+	TEST(int_map_add(&im, 1, y), 1);
+	TEST(int_map_find(&im, 1), y);
+	TEST(int_map_add(&im, 4, z), 2);
+	TEST(int_map_get_index(&im, 2), z);
+	TEST(int_map_find(&im, 4), z);
+	TEST(int_map_find(&im, 1), y);
+	TEST(int_map_count(&im), 3);
+	TEST(int_map_add(&im, 2, u), 3);
+	TEST(int_map_find(&im, 2), u);
+	TEST(int_map_add(&im, 3, v), 4);
+	TEST(int_map_find(&im, 3), v);
+	TEST(int_map_get_index(&im, 4), v);
+	TEST(int_map_add(&im, 6, w), 5);
+	TEST(int_map_find(&im, 6), w);
+	TEST(int_map_count(&im), 6);
+	TEST((int_map_exclude(&im, 1), EOK), EOK);
+	TEST(int_map_find(&im, 1), NULL);
+	TEST(int_map_find(&im, 2), u);
+	TEST((int_map_exclude(&im, 7), EOK), EOK);
+	TEST(int_map_find(&im, 2), u);
+	TEST(int_map_find(&im, 6), w);
+	TEST((int_map_exclude_index(&im, 4), EOK), EOK);
+	TEST(int_map_get_index(&im, 4), NULL);
+	TEST(int_map_find(&im, 3), NULL);
+	TEST((int_map_destroy(&im), EOK), EOK);
+	TEST(int_map_count(&im), -1);
+	
+	printf("\nMeasured strings test");
+	
+	measured_string_ref string =
+	    measured_string_create_bulk("I am a measured string!", 0);
+	printf("\n%x, %s at %x of %d\n", string, string->value, string->value,
+	    string->length);
+	
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/app/netstart/self_test.h
===================================================================
--- uspace/app/netstart/self_test.h	(revision c9256c5f5e299d763ed535094644b95f59066b88)
+++ uspace/app/netstart/self_test.h	(revision c9256c5f5e299d763ed535094644b95f59066b88)
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * @{
+ */
+
+#ifndef __SELF_TEST_H__
+#define __SELF_TEST_H__
+
+extern int self_test(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/packet/include/net_byteorder.h
===================================================================
--- uspace/lib/packet/include/net_byteorder.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ 	(revision )
@@ -1,71 +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 net
- *  @{
- */
-
-/** @file
- *  Host - network byte order manipulation functions.
- */
-
-#ifndef __NET_BYTEORDER_H__
-#define __NET_BYTEORDER_H__
-
-#include <byteorder.h>
-#include <sys/types.h>
-
-
-/** Converts the given short number (16 bit) from the host byte order to the network byte order (big endian).
- *  @param[in] number The number in the host byte order to be converted.
- *  @returns The number in the network byte order.
- */
-#define htons(number)		host2uint16_t_be(number)
-
-/** Converts the given long number (32 bit) from the host byte order to the network byte order (big endian).
- *  @param[in] number The number in the host byte order to be converted.
- *  @returns The number in the network byte order.
- */
-#define htonl(number)		host2uint32_t_be(number)
-
-/** Converts the given short number (16 bit) from the network byte order (big endian) to the host byte order.
- *  @param[in] number The number in the network byte order to be converted.
- *  @returns The number in the host byte order.
- */
-#define ntohs(number) 	uint16_t_be2host(number)
-
-/** Converts the given long number (32 bit) from the network byte order (big endian) to the host byte order.
- *  @param[in] number The number in the network byte order to be converted.
- *  @returns The number in the host byte order.
- */
-#define ntohl(number)		uint32_t_be2host(number)
-
-#endif
-
-/** @}
- */
Index: uspace/lib/packet/include/net_err.h
===================================================================
--- uspace/lib/packet/include/net_err.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ 	(revision )
@@ -1,99 +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 net
- * @{
- */
-
-/** @file
- * Common error processing codes and routines.
- */
-
-#ifndef __NET_ERR_H__
-#define __NET_ERR_H__
-
-#include <errno.h>
-
-#ifdef CONFIG_DEBUG
-	#include <stdio.h>
-	#include <str_error.h>
-#endif
-
-/** An actual stored error code.
- *
- */
-#define ERROR_CODE  error_check_return_value
-
-/** An error processing routines declaration.
- *
- * This has to be declared in the block where the error processing
- * is desired.
- *
- */
-#define ERROR_DECLARE  int ERROR_CODE
-
-/** Store the value as an error code and checks if an error occurred.
- *
- * @param[in] value The value to be checked. May be a function call.
- * @return False if the value indicates success (EOK).
- * @return True otherwise.
- *
- */
-#ifdef CONFIG_DEBUG
-
-#define ERROR_OCCURRED(value) \
-	(((ERROR_CODE = (value)) != EOK) \
-	&& ({ \
-		fprintf(stderr, "libsocket error at %s:%d (%s)\n", \
-		__FILE__, __LINE__, str_error(ERROR_CODE)); \
-		1; \
-	}))
-
-#else
-
-#define ERROR_OCCURRED(value)  ((ERROR_CODE = (value)) != EOK)
-
-#endif
-
-/** Error propagation
- *
- * Check if an error occurred and immediately exit the actual
- * function returning the error code.
- *
- * @param[in] value The value to be checked. May be a function call.
- *
- */
-
-#define ERROR_PROPAGATE(value) \
-	if (ERROR_OCCURRED(value)) \
-		return ERROR_CODE
-
-#endif
-
-/** @}
- */
Index: uspace/lib/packet/include/socket_errno.h
===================================================================
--- uspace/lib/packet/include/socket_errno.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ 	(revision )
@@ -1,136 +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 net
- *  @{
- */
-
-/** @file
- *  Socket error codes.
- *  Based on BSD.
- */
-
-#ifndef __NET_SOCKET_ERR_H__
-#define __NET_SOCKET_ERR_H__
-
-#include <errno.h>
-
-/** @name Socket error codes definitions
- */
-/*@{*/
-
-////#define EINTR			(-10004)
-////#define EBADF			(-10009)
-//#define EACCES			(-10013)
-//#define EFAULT			(-10014)
-////#define EINVAL			(-10022)
-////#define EMFILE			(-10024)
-//#define EWOULDBLOCK		(-10035)
-
-/** An API function is called while another blocking function is in progress.
- */
-#define EINPROGRESS		(-10036)
-
-//#define EALREADY		(-10037)
-
-/** The socket identifier is not valid.
- */
-#define ENOTSOCK		(-10038)
-
-/** The destination address required.
- */
-#define EDESTADDRREQ	(-10039)
-
-//#define EMSGSIZE		(-10040)
-//#define EPROTOTYPE		(-10041)
-//#define ENOPROTOOPT		(-10042)
-
-/** Protocol is not supported.
- */
-#define EPROTONOSUPPORT	(-10043)
-
-/** Socket type is not supported.
- */
-#define ESOCKTNOSUPPORT	(-10044)
-
-//#define EOPNOTSUPP		(-10045)
-
-/** Protocol family is not supported.
- */
-#define EPFNOSUPPORT	(-10046)
-
-/** Address family is not supported.
- */
-#define EAFNOSUPPORT	(-10047)
-
-/** Address is already in use.
- */
-#define EADDRINUSE		(-10048)
-
-//#define EADDRNOTAVAIL	(-10049)
-/* May be reported at any time if the implementation detects an underlying failure.
- */
-//#define ENETDOWN		(-10050)
-//#define ENETUNREACH		(-10051)
-//#define ENETRESET		(-10052)
-//#define ECONNABORTED	(-10053)
-//#define ECONNRESET		(-10054)
-//#define ENOBUFS			(-10055)
-//#define EISCONN			(-10056)
-
-/** The socket is not connected or bound.
- */
-#define ENOTCONN		(-10057)
-
-//#define ESHUTDOWN		(-10058)
-//#define ETOOMANYREFS	(-10059)
-//#define ETIMEDOUT		(-10060)
-//#define ECONNREFUSED	(-10061)
-//#define ELOOP			(-10062)
-////#define ENAMETOOLONG	(-10063)
-//#define EHOSTDOWN		(-10064)
-//#define EHOSTUNREACH	(-10065)
-//#define HOST_NOT_FOUND	(-11001)
-
-/** The requested operation was not performed.
- *  Try again later.
- */
-#define TRY_AGAIN		(-11002)
-
-//#define NO_RECOVERY		(-11003)
-
-/** No data.
- */
-#define NO_DATA			(-11004)
-
-/*@}*/
-
-#endif
-
-/** @}
- */
Index: uspace/lib/usbhid/include/usb/hid/hid_report_items.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ uspace/lib/usbhid/include/usb/hid/hid_report_items.h	(revision c9256c5f5e299d763ed535094644b95f59066b88)
@@ -27,84 +27,326 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
 /** @file
- * @brief USB HID parser.
- */
-#ifndef LIBUSBHID_HID_REPORT_ITEMS_H_
-#define LIBUSBHID_HID_REPORT_ITEMS_H_
+ * @brief USB HID Report descriptor item tags.
+ */
+#ifndef LIBUSB_HID_REPORT_ITEMS_H_
+#define LIBUSB_HID_REPORT_ITEMS_H_
 
 #include <stdint.h>
 
-/**
+/*---------------------------------------------------------------------------*/
+/*
  * Item prefix
  */
+
+/** Returns size of item data in bytes */
 #define USB_HID_ITEM_SIZE(data) 	((uint8_t)(data & 0x3))
+
+/** Returns item tag */
 #define USB_HID_ITEM_TAG(data) 		((uint8_t)((data & 0xF0) >> 4))
+
+/** Returns class of item tag */
 #define USB_HID_ITEM_TAG_CLASS(data)	((uint8_t)((data & 0xC) >> 2))
+
+/** Returns if the item is the short item or long item. Long items are not
+ * supported. */
 #define USB_HID_ITEM_IS_LONG(data)	(data == 0xFE)
 
-
-/**
+/*---------------------------------------------------------------------------*/
+/*
  * Extended usage macros
  */
+
+/** Recognizes if the given usage is extended (contains also usage page).  */
 #define USB_HID_IS_EXTENDED_USAGE(usage)	((usage & 0xFFFF0000) != 0)
+
+/** Cuts usage page of the extended usage. */
 #define USB_HID_EXTENDED_USAGE_PAGE(usage)	((usage & 0xFFFF0000) >> 16)
+
+/** Cuts usage of the extended usage */
 #define USB_HID_EXTENDED_USAGE(usage)		(usage & 0xFFFF)
 
-/**
+/*---------------------------------------------------------------------------*/
+/*
  * Input/Output/Feature Item flags
  */
-/** Constant (1) / Variable (0) */
+/** 
+ * Indicates whether the item is data (0) or a constant (1) value. Data
+ * indicates the item is defining report fields that contain modifiable device
+ * data. Constant indicates the item is a static read-only field in a report
+ * and cannot be modified (written) by the host.
+ */
 #define USB_HID_ITEM_FLAG_CONSTANT(flags) 	((flags & 0x1) == 0x1)
-/** Variable (1) / Array (0) */
+
+/**
+ * Indicates whether the item creates variable (1) or array (0) data fields in
+ * reports. 
+ */
 #define USB_HID_ITEM_FLAG_VARIABLE(flags) 	((flags & 0x2) == 0x2)
-/** Absolute / Relative*/
+
+/**
+ * Indicates whether the data is absolute (0) (based on a fixed origin) or
+ * relative (1) (indicating the change in value from the last report). Mouse
+ * devices usually provide relative data, while tablets usually provide
+ * absolute data.
+ */
 #define USB_HID_ITEM_FLAG_RELATIVE(flags) 	((flags & 0x4) == 0x4)
-/** Wrap / No Wrap */
+
+/**
+ * Indicates whether the data “rolls over” when reaching either the extreme
+ * high or low value. For example, a dial that can spin freely 360 degrees
+ * might output values from 0 to 10. If Wrap is indicated, the next value
+ * reported after passing the 10 position in the increasing direction would be
+ * 0.
+ */
 #define USB_HID_ITEM_FLAG_WRAP(flags)		((flags & 0x8) == 0x8)
+
+/**
+ * Indicates whether the raw data from the device has been processed in some
+ * way, and no longer represents a linear relationship between what is
+ * measured and the data that is reported.
+ */
 #define USB_HID_ITEM_FLAG_LINEAR(flags)		((flags & 0x10) == 0x10)
+
+/**
+ * Indicates whether the control has a preferred state to which it will return
+ * when the user is not physically interacting with the control. Push buttons
+ * (as opposed to toggle buttons) and self- centering joysticks are examples.
+ */
 #define USB_HID_ITEM_FLAG_PREFERRED(flags)	((flags & 0x20) == 0x20)
+
+/**
+ * Indicates whether the control has a state in which it is not sending
+ * meaningful data. One possible use of the null state is for controls that
+ * require the user to physically interact with the control in order for it to
+ * report useful data.
+ */
 #define USB_HID_ITEM_FLAG_POSITION(flags)	((flags & 0x40) == 0x40)
+
+/**
+ * Indicates whether the Feature or Output control's value should be changed
+ * by the host or not.  Volatile output can change with or without host
+ * interaction. To avoid synchronization problems, volatile controls should be
+ * relative whenever possible.
+ */
 #define USB_HID_ITEM_FLAG_VOLATILE(flags)	((flags & 0x80) == 0x80)
+
+/**
+ * Indicates that the control emits a fixed-size stream of bytes. The contents
+ * of the data field are determined by the application. The contents of the
+ * buffer are not interpreted as a single numeric quantity. Report data
+ * defined by a Buffered Bytes item must be aligned on an 8-bit boundary.
+ */
 #define USB_HID_ITEM_FLAG_BUFFERED(flags)	((flags & 0x100) == 0x100)
 
+/*---------------------------------------------------------------------------*/
+
 /* MAIN ITEMS */
-#define USB_HID_TAG_CLASS_MAIN				0x0
-#define USB_HID_REPORT_TAG_INPUT			0x8
-#define USB_HID_REPORT_TAG_OUTPUT			0x9
-#define USB_HID_REPORT_TAG_FEATURE			0xB
+
+/**
+ * Main items are used to either define or group certain types of data fields
+ * within a Report descriptor.
+ */
+#define USB_HID_TAG_CLASS_MAIN			0x0
+
+/**
+ * An Input item describes information about the data provided by one or more
+ * physical controls. An application can use this information to interpret the
+ * data provided by the device. All data fields defined in a single item share
+ * an identical data format.
+ */
+#define USB_HID_REPORT_TAG_INPUT		0x8
+
+/**
+ * The Output item is used to define an output data field in a report. This
+ * item is similar to an Input item except it describes data sent to the
+ * device—for example, LED states.
+ */
+#define USB_HID_REPORT_TAG_OUTPUT		0x9
+
+/**
+ * Feature items describe device configuration information that can be sent to
+ * the device.
+ */
+#define USB_HID_REPORT_TAG_FEATURE		0xB
+
+/**
+ * A Collection item identifies a relationship between two or more data
+ * (Input, Output, or Feature.) 
+ */
 #define USB_HID_REPORT_TAG_COLLECTION		0xA
+
+/**
+ * While the Collection item opens a collection of data, the End Collection
+ * item closes a collection.
+ */
 #define USB_HID_REPORT_TAG_END_COLLECTION	0xC
 
+/*---------------------------------------------------------------------------*/
+
 /* GLOBAL ITEMS */
-#define USB_HID_TAG_CLASS_GLOBAL			0x1
+
+/**
+ * Global items describe rather than define data from a control.
+ */
+#define USB_HID_TAG_CLASS_GLOBAL		0x1
+
+/**
+ * Unsigned integer specifying the current Usage Page. Since a usage are 32
+ * bit values, Usage Page items can be used to conserve space in a report
+ * descriptor by setting the high order 16 bits of a subsequent usages. Any
+ * usage that follows which is defines 16 bits or less is interpreted as a
+ * Usage ID and concatenated with the Usage Page to form a 32 bit Usage.
+ */
 #define USB_HID_REPORT_TAG_USAGE_PAGE		0x0
+
+/** 
+ * Extent value in logical units. This is the minimum value that a variable
+ * or array item will report. For example, a mouse reporting x position values
+ * from 0 to 128 would have a Logical Minimum of 0 and a Logical Maximum of
+ * 128.
+ */
 #define USB_HID_REPORT_TAG_LOGICAL_MINIMUM	0x1
+
+/** 
+ * Extent value in logical units. This is the maximum value that a variable
+ * or array item will report.
+ */
 #define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM	0x2
-#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 0x3
-#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 0x4
+
+/** 
+ * Minimum value for the physical extent of a variable item. This represents
+ * the Logical Minimum with units applied to it.
+ */
+#define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 	0x3
+
+/** 
+ * Maximum value for the physical extent of a variable item.
+ */
+#define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 	0x4
+
+/** 
+ * Value of the unit exponent in base 10. See the table later in this section
+ * for more information.
+ */
 #define USB_HID_REPORT_TAG_UNIT_EXPONENT	0x5
-#define USB_HID_REPORT_TAG_UNIT				0x6
+
+/** 
+ * Unit values.
+ */
+#define USB_HID_REPORT_TAG_UNIT			0x6
+
+/** 
+ * Unsigned integer specifying the size of the report fields in bits. This
+ * allows the parser to build an item map for the report handler to use.
+ */
 #define USB_HID_REPORT_TAG_REPORT_SIZE		0x7
+
+/** 
+ * Unsigned value that specifies the Report ID. If a Report ID tag is used
+ * anywhere in Report descriptor, all data reports for the device are preceded
+ * by a single byte ID field. All items succeeding the first Report ID tag but
+ * preceding a second Report ID tag are included in a report prefixed by a
+ * 1-byte ID. All items succeeding the second but preceding a third Report ID
+ * tag are included in a second report prefixed by a second ID, and so on.
+ */
 #define USB_HID_REPORT_TAG_REPORT_ID		0x8
+
+/** 
+ * Unsigned integer specifying the number of data fields for the item;
+ * determines how many fields are included in the report for this particular
+ * item (and consequently how many bits are added to the report).
+ */
 #define USB_HID_REPORT_TAG_REPORT_COUNT		0x9
-#define USB_HID_REPORT_TAG_PUSH				0xA
-#define USB_HID_REPORT_TAG_POP				0xB
-
+
+/** 
+ * Places a copy of the global item state table on the stack.
+ */
+#define USB_HID_REPORT_TAG_PUSH			0xA
+
+/** 
+ * Replaces the item state table with the top structure from the stack.
+ */
+#define USB_HID_REPORT_TAG_POP			0xB
+
+/*---------------------------------------------------------------------------*/
 
 /* LOCAL ITEMS */
-#define USB_HID_TAG_CLASS_LOCAL					0x2
-#define USB_HID_REPORT_TAG_USAGE				0x0
-#define USB_HID_REPORT_TAG_USAGE_MINIMUM		0x1
-#define USB_HID_REPORT_TAG_USAGE_MAXIMUM		0x2
-#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX		0x3
+
+/**
+ * Local item tags define characteristics of controls. These items do not
+ * carry over to the next Main item. If a Main item defines more than one
+ * control, it may be preceded by several similar Local item tags. For
+ * example, an Input item may have several Usage tags associated with it, one
+ * for each control.
+ */
+#define USB_HID_TAG_CLASS_LOCAL			0x2
+
+/**
+ * Usage index for an item usage; represents a suggested usage for the item or
+ * collection. In the case where an item represents multiple controls, a Usage
+ * tag may suggest a usage for every variable or element in an array.
+ */
+#define USB_HID_REPORT_TAG_USAGE		0x0
+
+/**
+ * Defines the starting usage associated with an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_USAGE_MINIMUM	0x1
+
+/**
+ * Defines the ending usage associated with an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_USAGE_MAXIMUM	0x2
+
+/**
+ * Determines the body part used for a control. Index points to a designator
+ * in the Physical descriptor.
+ */
+#define USB_HID_REPORT_TAG_DESIGNATOR_INDEX	0x3
+
+/**
+ * Defines the index of the starting designator associated with an array or
+ * bitmap.
+ */
 #define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM	0x4
+
+/**
+ * Defines the index of the ending designator associated with an array or
+ * bitmap.
+ */
 #define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM	0x5
-#define USB_HID_REPORT_TAG_STRING_INDEX			0x7
-#define USB_HID_REPORT_TAG_STRING_MINIMUM		0x8
-#define USB_HID_REPORT_TAG_STRING_MAXIMUM		0x9
-#define USB_HID_REPORT_TAG_DELIMITER			0xA
+
+/**
+ * String index for a String descriptor; allows a string to be associated with
+ * a particular item or control.
+ */
+#define USB_HID_REPORT_TAG_STRING_INDEX		0x7
+
+/**
+ * Specifies the first string index when assigning a group of sequential
+ * strings to controls in an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_STRING_MINIMUM	0x8
+
+/**
+ * Specifies the last string index when assigning a group of sequential
+ * strings to controls in an array or bitmap.
+ */
+#define USB_HID_REPORT_TAG_STRING_MAXIMUM	0x9
+
+/**
+ * Defines the beginning or end of a set of local items (1 = open set, 0 =
+ * close set).
+ *
+ * Usages other than the first (most preferred) usage defined are not
+ * accessible by system software.
+ */
+#define USB_HID_REPORT_TAG_DELIMITER		0xA
+
+/*---------------------------------------------------------------------------*/
 
 #endif
Index: uspace/lib/usbhid/include/usb/hid/hiddescriptor.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ uspace/lib/usbhid/include/usb/hid/hiddescriptor.h	(revision c9256c5f5e299d763ed535094644b95f59066b88)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
@@ -33,6 +33,6 @@
  * USB HID report descriptor and report data parser
  */
-#ifndef LIBUSBHID_HIDDESCRIPTOR_H_
-#define LIBUSBHID_HIDDESCRIPTOR_H_
+#ifndef LIBUSB_HIDDESCRIPTOR_H_
+#define LIBUSB_HIDDESCRIPTOR_H_
 
 #include <stdint.h>
@@ -42,41 +42,43 @@
 #include <usb/hid/hidtypes.h>
 
-
-/*
- * Descriptor parser functions
- */
-
-/** */
 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 
                                     const uint8_t *data, size_t size);
 
-/** */
 void usb_hid_free_report(usb_hid_report_t *report);
 
-/** */
 void usb_hid_descriptor_print(usb_hid_report_t *report);
 
+int usb_hid_report_init(usb_hid_report_t *report);
 
-int usb_hid_report_init(usb_hid_report_t *report);
 int usb_hid_report_append_fields(usb_hid_report_t *report, 
                                  usb_hid_report_item_t *report_item);
 
 usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
+
 int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
 int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
 int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
+
 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
                              usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path);
 
 void usb_hid_descriptor_print_list(link_t *head);
+
 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item);
+
 void usb_hid_free_report_list(link_t *head);
+
 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item);
+
 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
 
 usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path);
+
+
 #endif
 /**
Index: uspace/lib/usbhid/include/usb/hid/hidpath.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ uspace/lib/usbhid/include/usb/hid/hidpath.h	(revision c9256c5f5e299d763ed535094644b95f59066b88)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
@@ -33,6 +33,6 @@
  * USB HID report descriptor and report data parser
  */
-#ifndef LIBUSBHID_HIDPATH_H_
-#define LIBUSBHID_HIDPATH_H_
+#ifndef LIBUSB_HIDPATH_H_
+#define LIBUSB_HIDPATH_H_
 
 #include <usb/hid/hidparser.h>
@@ -40,73 +40,97 @@
 #include <adt/list.h>
 
+
+/*---------------------------------------------------------------------------*/
 /**
- * Description of path of usage pages and usages in report descriptor
+ * Flags of usage paths comparison modes.
+ *
  */
-/** Wanted usage path must be exactly the same as the searched one */
+/** Wanted usage path must be exactly the same as the searched one.
+ * This option cannot be combined with the others. 
+ */
 #define USB_HID_PATH_COMPARE_STRICT		0
-/** Wanted usage path must be the suffix in the searched one */
+
+/**
+ * Wanted usage path must be the suffix in the searched one.
+ */
 #define USB_HID_PATH_COMPARE_END		1
-/** */
+
+/** 
+ * Only usage page are compared along the usage path. 
+ * This option can be combined with others. 
+ */
 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY	2
-/** Searched usage page must be prefix of the other one */
+
+/** 
+ * Searched usage page must be prefix of the other one.
+ */
 #define USB_HID_PATH_COMPARE_BEGIN		4
-/** Searched couple of usage page and usage can be anywhere in usage path */
+
+/** 
+ * Searched couple of usage page and usage can be anywhere in usage path.
+ * This option is deprecated.
+ */
 #define USB_HID_PATH_COMPARE_ANYWHERE		8
 
-
-/** Collection usage path structure */
+/*----------------------------------------------------------------------------*/
+/** 
+ * Item of usage path structure. Last item of linked list describes one item
+ * in report, the others describe superior Collection tags. Usage and Usage
+ * page of report item can be changed due to data in report. 
+ */
 typedef struct {
-	/** */
+	/** Usage page of report item. Zero when usage page can be changed. */
 	uint32_t usage_page;
-	/** */	
+	/** Usage of report item. Zero when usage can be changed. */	
 	uint32_t usage;
 
+	/** Attribute of Collection tag in report descriptor*/
 	uint8_t flags;
-	/** */
+
+	/** Linked list structure*/
 	link_t link;
 } usb_hid_report_usage_path_t;
 
-/** */
+
+/*---------------------------------------------------------------------------*/
+/** 
+ * USB HID usage path structure.
+ * */
 typedef struct {
-	/** */	
+	/** Length of usage path */	
 	int depth;	
+
+	/** Report id. Zero is reserved and means that report id is not used. */
 	uint8_t report_id;
 	
-	/** */	
+	/** Linked list structure. */	
 	link_t link; /* list */
 
-	link_t head; /* head of list of usage paths */
+	/** Head of the list of usage path items. */
+	link_t head;
 
 } usb_hid_report_path_t;
 
-/** */
+/*---------------------------------------------------------------------------*/
 usb_hid_report_path_t *usb_hid_report_path(void);
 
-/** */
 void usb_hid_report_path_free(usb_hid_report_path_t *path);
 
-/** */
 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, 
                                       uint8_t report_id);
 
-/** */
 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
                                     int32_t usage_page, int32_t usage);
 
-/** */
 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
 
-/** */
 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
 
-/** */
 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
                                   int32_t tag, int32_t data);
 
-/** */
 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 
                                       usb_hid_report_path_t *path, int flags);
 
-/** */
 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
 
Index: uspace/lib/usbhid/include/usb/hid/hidtypes.h
===================================================================
--- uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision e8f826b3c79eec54dedbbc97e3d25b05e5c2c8a2)
+++ uspace/lib/usbhid/include/usb/hid/hidtypes.h	(revision c9256c5f5e299d763ed535094644b95f59066b88)
@@ -27,22 +27,51 @@
  */
 
-/** @addtogroup libusbhid
+/** @addtogroup libusb
  * @{
  */
 /** @file
- * USB HID report descriptor and report data parser
- */
-#ifndef LIBUSBHID_HIDTYPES_H_
-#define LIBUSBHID_HIDTYPES_H_
+ * Basic data structures for USB HID Report descriptor and report parser.
+ */
+#ifndef LIBUSB_HIDTYPES_H_
+#define LIBUSB_HIDTYPES_H_
 
 #include <stdint.h>
 #include <adt/list.h>
 
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Maximum amount of specified usages for one report item
+ */
 #define USB_HID_MAX_USAGES	0xffff
 
-#define USB_HID_UINT32_TO_INT32(x, size)	((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1)))
-#define USB_HID_INT32_TO_UINT32(x, size)	(((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
-
-
+/**
+ * Converts integer from unsigned two's complement format format to signed
+ * one.
+ *
+ * @param x Number to convert
+ * @param size Length of the unsigned number in bites
+ * @return signed int
+ */
+#define USB_HID_UINT32_TO_INT32(x, size)	\
+	((((x) & (1 << ((size) - 1))) != 0) ?   \
+	 -(~((x) - 1) & ((1 << size) - 1)) : (x))
+
+/**
+ * Convert integer from signed format to unsigned. If number is negative the
+ * two's complement format is used.
+ *
+ * @param x Number to convert
+ * @param size Length of result number in bites
+ * @return unsigned int
+ */
+#define USB_HID_INT32_TO_UINT32(x, size)	\
+	(((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
+
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Report type
+ */
 typedef enum {
 	USB_HID_REPORT_TYPE_INPUT = 1,
@@ -51,62 +80,124 @@
 } usb_hid_report_type_t;
 
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Description of all reports described in one report descriptor.
+ */
 typedef struct {
-	/** */
+	/** Count of available reports. */
 	int report_count;
-	link_t reports;		/** list of usb_hid_report_description_t */
-
+
+	/** Head of linked list of description of reports. */
+	link_t reports;
+
+	/** Head of linked list of all used usage/collection paths. */
 	link_t collection_paths;
+
+	/** Length of list of usage paths. */
 	int collection_paths_count;
 
+	/** Flag whether report ids are used. */
 	int use_report_ids;
+
+	/** Report id of last parsed report. */
 	uint8_t last_report_id;
 	
 } usb_hid_report_t;
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Description of one concrete report
+ */
 typedef struct {
+	/** Report id. Zero when no report id is used. */
 	uint8_t report_id;
+
+	/** Type of report */
 	usb_hid_report_type_t type;
 
+	/** Bit length of the report */
 	size_t bit_length;
+
+	/** Number of items in report */
 	size_t item_length;
 	
-	link_t report_items;	/** list of report items (fields) */
-
+	/** Linked list of report items in report */
+	link_t report_items;
+
+	/** Linked list of descriptions. */
 	link_t link;
 } usb_hid_report_description_t;
-
+/*---------------------------------------------------------------------------*/
+
+/**
+ * Description of one field/item in report 
+ */
 typedef struct {
-
+	/** Bit offset of the field */
 	int offset;
+
+	/** Bit size of the field */
 	size_t size;
 
+	/** Usage page. Zero when usage page can be changed. */
 	uint16_t usage_page;
+
+	/** Usage. Zero when usage can be changed. */
 	uint16_t usage;
 
+	/** Item's attributes */
 	uint8_t item_flags;
+
+	/** Usage/Collection path of the field. */
 	usb_hid_report_path_t *collection_path;
 
+	/** 
+	 * The lowest valid logical value (value with the device operates)
+	 */
 	int32_t logical_minimum;
+
+	/**
+	 * The greatest valid logical value
+	 */
 	int32_t logical_maximum;
+
+	/**
+	 * The lowest valid physical value (value with the system operates)
+	 */
 	int32_t physical_minimum;
+
+	/** The greatest valid physical value */
 	int32_t physical_maximum;
+
+	/** The lowest valid usage index */
 	int32_t usage_minimum;
+
+	/** The greatest valid usage index */
 	int32_t usage_maximum;
+	
+	/** Unit of the value */
 	uint32_t unit;
+
+	/** Unit exponent */
 	uint32_t unit_exponent;
 
+	/** Array of possible usages */
 	uint32_t *usages;
+
+	/** Size of the array of usages */
 	size_t usages_count;
 
+	/** Parsed value */
 	int32_t value;
 
+	/** List to another report items */
 	link_t link;
 } usb_hid_report_field_t;
 
-
-
-/**
- * state table
+/*---------------------------------------------------------------------------*/
+
+/**
+ * State table for report descriptor parsing
  */
 typedef struct {
@@ -114,73 +205,84 @@
 	int32_t id;
 	
-	/** */
+	/** Extended usage page */
 	uint16_t extended_usage_page;
+
+	/** Array of usages specified for this item */
 	uint32_t usages[USB_HID_MAX_USAGES];
+	
+	/** Length of usages array */
 	int usages_count;
 
-	/** */
+	/** Usage page*/
 	uint32_t usage_page;
 
-	/** */	
+	/** Minimum valid usage index */	
 	int32_t usage_minimum;
-	/** */	
+	
+	/** Maximum valid usage index */	
 	int32_t usage_maximum;
-	/** */	
+	
+	/** Minimum valid logical value */	
 	int32_t logical_minimum;
-	/** */	
+	
+	/** Maximum valid logical value */	
 	int32_t logical_maximum;
-	/** */	
+
+	/** Length of the items in bits*/	
 	int32_t size;
-	/** */	
+
+	/** COunt of items*/	
 	int32_t count;
-	/** */	
+
+	/**  Bit offset of the item in report */	
 	size_t offset;
-	/** */	
+
+	/** Unit exponent */	
 	int32_t unit_exponent;
-	/** */	
+	/** Unit of the value */	
 	int32_t unit;
 
-	/** */
+	/** String index */
 	uint32_t string_index;
-	/** */	
+
+	/** Minimum valid string index */	
 	uint32_t string_minimum;
-	/** */	
+
+	/** Maximum valid string index */	
 	uint32_t string_maximum;
-	/** */	
+
+	/** The designator index */	
 	uint32_t designator_index;
-	/** */	
+
+	/** Minimum valid designator value*/	
 	uint32_t designator_minimum;
-	/** */	
+
+	/** Maximum valid designator value*/	
 	uint32_t designator_maximum;
-	/** */	
+
+	/** Minimal valid physical value*/	
 	int32_t physical_minimum;
-	/** */	
+
+	/** Maximal valid physical value */	
 	int32_t physical_maximum;
 
-	/** */	
+	/** Items attributes*/	
 	uint8_t item_flags;
 
+	/** Report type */
 	usb_hid_report_type_t type;
 
 	/** current collection path*/	
 	usb_hid_report_path_t *usage_path;
-	/** */	
+
+	/** Unused*/	
 	link_t link;
 
 	int in_delimiter;
 } usb_hid_report_item_t;
-
-/** HID parser callbacks for IN items. */
-typedef struct {
-	/** Callback for keyboard.
-	 *
-	 * @param key_codes Array of pressed key (including modifiers).
-	 * @param count Length of @p key_codes.
-	 * @param arg Custom argument.
-	 */
-	void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg);
-} usb_hid_report_in_callbacks_t;
-
-
+/*---------------------------------------------------------------------------*/
+/**
+ * Enum of the keyboard modifiers 
+ */
 typedef enum {
 	USB_HID_MOD_LCTRL = 0x01,
@@ -206,4 +308,6 @@
 	USB_HID_MOD_RGUI
 };
+/*---------------------------------------------------------------------------*/
+
 
 #endif
