Index: pace/app/netstart/self_test.c
===================================================================
--- uspace/app/netstart/self_test.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ 	(revision )
@@ -1,334 +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
- * 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: pace/app/netstart/self_test.h
===================================================================
--- uspace/app/netstart/self_test.h	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ 	(revision )
@@ -1,41 +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
- * @{
- */
-
-#ifndef __SELF_TEST_H__
-#define __SELF_TEST_H__
-
-extern int self_test(void);
-
-#endif
-
-/** @}
- */
Index: pace/lib/packet/include/netdb.h
===================================================================
--- uspace/lib/packet/include/netdb.h	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ 	(revision )
@@ -1,109 +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 netdb
- *  @{
- */
-
-/** @file
- *  Structures and interfaces according to the BSD netdb.h file.
- */
-
-#ifndef __NET_NETDB_H__
-#define __NET_NETDB_H__
-
-#include <sys/types.h>
-
-/** Structure returned by network data base library.
- *  All addresses are supplied in host order, and returned in network order (suitable for use in system calls).
- */
-struct	hostent {
-	/** Official host name.
-	 */
-	char * h_name;
-	/** Alias list.
-	 */
-	char **	h_aliases;
-	/** Host address type.
-	 */
-	int h_addrtype;
-	/** Address length.
-	 */
-	int h_length;
-	/** List of addresses from name server.
-	 */
-	char **	h_addr_list;
-	/** Address, for backward compatiblity.
-	 */
-#define	h_addr	h_addr_list[0]
-};
-
-/** @name Host entry address types definitions.
- */
-/*@{*/
-
-/** Authoritative Answer Host not found address type.
- */
-#define	HOST_NOT_FOUND	1
-
-/** Non-Authoritive Host not found, or SERVERFAIL address type.
- */
-#define	TRY_AGAIN	2
-
-/** Non recoverable errors, FORMERR, REFUSED, NOTIMP address type.
- */
-#define	NO_RECOVERY	3
-
-/** Valid name, no data record of requested type address type.
- */
-#define	NO_DATA		4
-
-/** No address, look for MX record address type.
- */
-#define	NO_ADDRESS	NO_DATA
-
-/*@}*/
-
-/** Returns host entry by the host address.
- *  @param[in] address The host address.
- *  @param[in] len The address length.
- *  @param[in] type The address type.
- *  @returns Host entry information.
- */
-//struct hostent *	gethostbyaddr(const void * address, int len, int type);
-
-/** Returns host entry by the host name.
- *  @param[in] name The host name.
- *  @returns Host entry information.
- */
-//struct hostent *	gethostbyname(const char * name);
-
-#endif
-
-/** @}
- */
Index: pace/lib/packet/include/tcp_codes.h
===================================================================
--- uspace/lib/packet/include/tcp_codes.h	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ 	(revision )
@@ -1,88 +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 tcp
- *  @{
- */
-
-/** @file
- *  TCP options definitions.
- */
-
-#ifndef __NET_TCP_CODES_H__
-#define __NET_TCP_CODES_H__
-
-/** End of list TCP option.
- */
-#define TCPOPT_END_OF_LIST				0x0
-
-/** No operation TCP option.
- */
-#define TCPOPT_NO_OPERATION				0x1
-
-/** Maximum segment size TCP option.
- */
-#define TCPOPT_MAX_SEGMENT_SIZE			0x2
-
-/** Maximum segment size TCP option length.
- */
-#define TCPOPT_MAX_SEGMENT_SIZE_LENGTH	4
-
-/** Window scale TCP option.
- */
-#define TCPOPT_WINDOW_SCALE				0x3
-
-/** Window scale TCP option length.
- */
-#define TCPOPT_WINDOW_SCALE_LENGTH		3
-
-/** Selective acknowledgement permitted TCP option.
- */
-#define TCPOPT_SACK_PERMITTED			0x4
-
-/** Selective acknowledgement permitted TCP option length.
- */
-#define TCPOPT_SACK_PERMITTED_LENGTH	2
-
-/** Selective acknowledgement TCP option.
- *  Has variable length.
- */
-#define TCPOPT_SACK						0x5
-
-/** Timestamp TCP option.
- */
-#define TCPOPT_TIMESTAMP				0x8
-
-/** Timestamp TCP option length.
- */
-#define TCPOPT_TIMESTAMP_LENGTH			10
-
-#endif
-
-/** @}
- */
Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/il/arp/arp.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -55,5 +55,5 @@
 #include <ipc/il.h>
 #include <byteorder.h>
-#include <err.h>
+#include <errno.h>
 
 #include <net/modules.h>
@@ -179,16 +179,20 @@
     measured_string_ref address)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	*proto = (arp_proto_ref) malloc(sizeof(arp_proto_t));
 	if (!*proto)
 		return ENOMEM;
+	
 	(*proto)->service = service;
 	(*proto)->addr = address;
 	(*proto)->addr_data = address->value;
-	if (ERROR_OCCURRED(arp_addr_initialize(&(*proto)->addresses))) {
+	
+	rc = arp_addr_initialize(&(*proto)->addresses);
+	if (rc != EOK) {
 		free(*proto);
-		return ERROR_CODE;
-	}
+		return rc;
+	}
+	
 	return EOK;
 }
@@ -214,10 +218,9 @@
     services_t protocol, measured_string_ref address)
 {
-	ERROR_DECLARE;
-
 	arp_device_ref device;
 	arp_proto_ref proto;
+	hw_type_t hardware;
 	int index;
-	hw_type_t hardware;
+	int rc;
 
 	fibril_rwlock_write_lock(&arp_globals.lock);
@@ -237,8 +240,8 @@
 			proto->addr_data = address->value;
 		} else {
-			if (ERROR_OCCURRED(arp_proto_create(&proto, protocol,
-			    address))) {
+			rc = arp_proto_create(&proto, protocol, address);
+			if (rc != EOK) {
 				fibril_rwlock_write_unlock(&arp_globals.lock);
-				return ERROR_CODE;
+				return rc;
 			}
 			index = arp_protos_add(&device->protos, proto->service,
@@ -265,10 +268,15 @@
 		device->hardware = hardware;
 		device->device_id = device_id;
-		if (ERROR_OCCURRED(arp_protos_initialize(&device->protos)) ||
-		    ERROR_OCCURRED(arp_proto_create(&proto, protocol,
-		    address))) {
+		rc = arp_protos_initialize(&device->protos);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			free(device);
-			return ERROR_CODE;
+			return rc;
+		}
+		rc = arp_proto_create(&proto, protocol, address);
+		if (rc != EOK) {
+			fibril_rwlock_write_unlock(&arp_globals.lock);
+			free(device);
+			return rc;
 		}
 		index = arp_protos_add(&device->protos, proto->service, proto);
@@ -293,25 +301,27 @@
 		
 		// get packet dimensions
-		if (ERROR_OCCURRED(nil_packet_size_req(device->phone, device_id,
-		    &device->packet_dimension))) {
+		rc = nil_packet_size_req(device->phone, device_id,
+		    &device->packet_dimension);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
+			return rc;
 		}
 		
 		// get hardware address
-		if (ERROR_OCCURRED(nil_get_addr_req(device->phone, device_id,
-		    &device->addr, &device->addr_data))) {
+		rc = nil_get_addr_req(device->phone, device_id, &device->addr,
+		    &device->addr_data);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
+			return rc;
 		}
 		
 		// get broadcast address
-		if (ERROR_OCCURRED(nil_get_broadcast_addr_req(device->phone,
-		    device_id, &device->broadcast_addr,
-		    &device->broadcast_data))) {
+		rc = nil_get_broadcast_addr_req(device->phone, device_id,
+		    &device->broadcast_addr, &device->broadcast_data);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			free(device->addr);
@@ -319,9 +329,10 @@
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
-		}
-		
-		if (ERROR_OCCURRED(arp_cache_add(&arp_globals.cache,
-		    device->device_id, device))) {
+			return rc;
+		}
+		
+		rc = arp_cache_add(&arp_globals.cache, device->device_id,
+		    device);
+		if (rc != EOK) {
 			fibril_rwlock_write_unlock(&arp_globals.lock);
 			free(device->addr);
@@ -331,5 +342,5 @@
 			arp_protos_destroy(&device->protos);
 			free(device);
-			return ERROR_CODE;
+			return rc;
 		}
 		printf("%s: Device registered (id: %d, type: 0x%x, service: %d,"
@@ -351,12 +362,13 @@
 int arp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	fibril_rwlock_initialize(&arp_globals.lock);
 	fibril_rwlock_write_lock(&arp_globals.lock);
 	arp_globals.client_connection = client_connection;
-	ERROR_PROPAGATE(arp_cache_initialize(&arp_globals.cache));
+	rc = arp_cache_initialize(&arp_globals.cache);
 	fibril_rwlock_write_unlock(&arp_globals.lock);
-	return EOK;
+	
+	return rc;
 }
 
@@ -406,6 +418,4 @@
 static int arp_receive_message(device_id_t device_id, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	arp_header_ref header;
@@ -417,4 +427,5 @@
 	uint8_t *des_hw;
 	uint8_t *des_proto;
+	int rc;
 
 	length = packet_get_data_length(packet);
@@ -467,7 +478,9 @@
 				return ENOMEM;
 
-			ERROR_PROPAGATE(arp_addr_add(&proto->addresses,
-			    (char *) src_proto, CONVERT_SIZE(uint8_t, char,
-			    header->protocol_length), hw_source));
+			rc = arp_addr_add(&proto->addresses, (char *) src_proto,
+			    CONVERT_SIZE(uint8_t, char,
+			    header->protocol_length), hw_source);
+			if (rc != EOK)
+				return rc;
 		}
 		if (ntohs(header->operation) == ARPOP_REQUEST) {
@@ -480,6 +493,10 @@
 			memcpy(des_hw, hw_source->value,
 			    header->hardware_length);
-			ERROR_PROPAGATE(packet_set_addr(packet, src_hw, des_hw,
-			    header->hardware_length));
+			
+			rc = packet_set_addr(packet, src_hw, des_hw,
+			    header->hardware_length);
+			if (rc != EOK)
+				return rc;
+			
 			nil_send_msg(device->phone, device_id, packet,
 			    SERVICE_ARP);
@@ -596,6 +613,4 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	measured_string_ref address;
 	measured_string_ref translation;
@@ -603,4 +618,5 @@
 	packet_t packet;
 	packet_t next;
+	int rc;
 	
 	*answer_count = 0;
@@ -610,14 +626,21 @@
 	
 	case NET_ARP_DEVICE:
-		ERROR_PROPAGATE(measured_strings_receive(&address, &data, 1));
-		if (ERROR_OCCURRED(arp_device_message(IPC_GET_DEVICE(call),
-		    IPC_GET_SERVICE(call), ARP_GET_NETIF(call), address))) {
+		rc = measured_strings_receive(&address, &data, 1);
+		if (rc != EOK)
+			return rc;
+		
+		rc = arp_device_message(IPC_GET_DEVICE(call),
+		    IPC_GET_SERVICE(call), ARP_GET_NETIF(call), address);
+		if (rc != EOK) {
 			free(address);
 			free(data);
 		}
-		return ERROR_CODE;
+		return rc;
 	
 	case NET_ARP_TRANSLATE:
-		ERROR_PROPAGATE(measured_strings_receive(&address, &data, 1));
+		rc = measured_strings_receive(&address, &data, 1);
+		if (rc != EOK)
+			return rc;
+		
 		fibril_rwlock_read_lock(&arp_globals.lock);
 		translation = arp_translate_message(IPC_GET_DEVICE(call),
@@ -629,7 +652,7 @@
 			return ENOENT;
 		}
-		ERROR_CODE = measured_strings_reply(translation, 1);
+		rc = measured_strings_reply(translation, 1);
 		fibril_rwlock_read_unlock(&arp_globals.lock);
-		return ERROR_CODE;
+		return rc;
 
 	case NET_ARP_CLEAR_DEVICE:
@@ -637,5 +660,8 @@
 
 	case NET_ARP_CLEAR_ADDRESS:
-		ERROR_PROPAGATE(measured_strings_receive(&address, &data, 1));
+		rc = measured_strings_receive(&address, &data, 1);
+		if (rc != EOK)
+			return rc;
+		
 		arp_clear_address_req(0, IPC_GET_DEVICE(call),
 		    IPC_GET_SERVICE(call), address);
@@ -652,21 +678,22 @@
 	
 	case NET_IL_RECEIVED:
-		if (ERROR_NONE(packet_translate_remote(arp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			fibril_rwlock_read_lock(&arp_globals.lock);
-			do {
-				next = pq_detach(packet);
-				ERROR_CODE =
-				    arp_receive_message(IPC_GET_DEVICE(call),
-				    packet);
-				if (ERROR_CODE != 1) {
-					pq_release_remote(arp_globals.net_phone,
-					    packet_get_id(packet));
-				}
-				packet = next;
-			} while (packet);
-			fibril_rwlock_read_unlock(&arp_globals.lock);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(arp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		
+		fibril_rwlock_read_lock(&arp_globals.lock);
+		do {
+			next = pq_detach(packet);
+			rc = arp_receive_message(IPC_GET_DEVICE(call), packet);
+			if (rc != 1) {
+				pq_release_remote(arp_globals.net_phone,
+				    packet_get_id(packet));
+			}
+			packet = next;
+		} while (packet);
+		fibril_rwlock_read_unlock(&arp_globals.lock);
+		
+		return EOK;
 	
 	case NET_IL_MTU_CHANGED:
@@ -727,9 +754,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(il_module_start_standalone(il_client_connection));
-	return EOK;
+	rc = il_module_start_standalone(il_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/il/arp/arp_module.c
===================================================================
--- uspace/srv/net/il/arp/arp_module.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/il/arp/arp_module.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -41,5 +41,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -66,21 +66,27 @@
 int il_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	arp_globals.net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(arp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_ARP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	rc = arp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_ARP, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/il/ip/ip.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -41,5 +41,4 @@
 #include <async.h>
 #include <errno.h>
-#include <err.h>
 #include <fibril_synch.h>
 #include <stdio.h>
@@ -254,5 +253,5 @@
 int ip_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	fibril_rwlock_initialize(&ip_globals.lock);
@@ -265,13 +264,22 @@
 	ip_globals.gateway.gateway.s_addr = 0;
 	ip_globals.gateway.netif = NULL;
-	ERROR_PROPAGATE(ip_netifs_initialize(&ip_globals.netifs));
-	ERROR_PROPAGATE(ip_protos_initialize(&ip_globals.protos));
 	ip_globals.client_connection = client_connection;
-	ERROR_PROPAGATE(modules_initialize(&ip_globals.modules));
-	ERROR_PROPAGATE(add_module(NULL, &ip_globals.modules, ARP_NAME,
-	    ARP_FILENAME, SERVICE_ARP, 0, arp_connect_module));
+	
+	rc = ip_netifs_initialize(&ip_globals.netifs);
+	if (rc != EOK)
+		goto out;
+	rc = ip_protos_initialize(&ip_globals.protos);
+	if (rc != EOK)
+		goto out;
+	rc = modules_initialize(&ip_globals.modules);
+	if (rc != EOK)
+		goto out;
+	rc = add_module(NULL, &ip_globals.modules, ARP_NAME, ARP_FILENAME,
+	    SERVICE_ARP, 0, arp_connect_module);
+
+out:
 	fibril_rwlock_write_unlock(&ip_globals.lock);
 
-	return EOK;
+	return rc;
 }
 
@@ -302,6 +310,4 @@
 static int ip_netif_initialize(ip_netif_ref ip_netif)
 {
-	ERROR_DECLARE;
-
 	measured_string_t names[] = {
 		{
@@ -342,7 +348,8 @@
 	char *data;
 	measured_string_t address;
-	int index;
 	ip_route_ref route;
 	in_addr_t gateway;
+	int index;
+	int rc;
 
 	ip_netif->arp = NULL;
@@ -354,6 +361,9 @@
 
 	// get configuration
-	ERROR_PROPAGATE(net_get_device_conf_req(ip_globals.net_phone,
-	    ip_netif->device_id, &configuration, count, &data));
+	rc = net_get_device_conf_req(ip_globals.net_phone, ip_netif->device_id,
+	    &configuration, count, &data);
+	if (rc != EOK)
+		return rc;
+	
 	if (configuration) {
 		if (configuration[0].value)
@@ -383,10 +393,9 @@
 				return index;
 			}
-			if (ERROR_OCCURRED(inet_pton(AF_INET,
-			    configuration[2].value,
-			    (uint8_t *) &route->address.s_addr)) ||
-			    ERROR_OCCURRED(inet_pton(AF_INET,
-			    configuration[3].value,
-			    (uint8_t *) &route->netmask.s_addr)) ||
+			
+			if ((inet_pton(AF_INET, configuration[2].value,
+			    (uint8_t *) &route->address.s_addr) != EOK) ||
+			    (inet_pton(AF_INET, configuration[3].value,
+			    (uint8_t *) &route->netmask.s_addr) != EOK) ||
 			    (inet_pton(AF_INET, configuration[4].value,
 			    (uint8_t *) &gateway.s_addr) == EINVAL) ||
@@ -434,7 +443,10 @@
 			address.value = (char *) &route->address.s_addr;
 			address.length = CONVERT_SIZE(in_addr_t, char, 1);
-			ERROR_PROPAGATE(arp_device_req(ip_netif->arp->phone,
+			
+			rc = arp_device_req(ip_netif->arp->phone,
 			    ip_netif->device_id, SERVICE_IP, ip_netif->service,
-			    &address));
+			    &address);
+			if (rc != EOK)
+				return rc;
 		} else {
 			ip_netif->arp = 0;
@@ -443,6 +455,9 @@
 
 	// get packet dimensions
-	ERROR_PROPAGATE(nil_packet_size_req(ip_netif->phone,
-	    ip_netif->device_id, &ip_netif->packet_dimension));
+	rc = nil_packet_size_req(ip_netif->phone, ip_netif->device_id,
+	    &ip_netif->packet_dimension);
+	if (rc != EOK)
+		return rc;
+	
 	if (ip_netif->packet_dimension.content < IP_MIN_CONTENT) {
 		printf("Maximum transmission unit %d bytes is too small, at "
@@ -610,6 +625,4 @@
     measured_string_ref destination)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	ip_header_ref header;
@@ -617,4 +630,5 @@
 	ip_header_ref middle_header;
 	packet_t next;
+	int rc;
 
 	length = packet_get_data_length(packet);
@@ -624,10 +638,12 @@
 	header = (ip_header_ref) packet_get_data(packet);
 	if (destination) {
-		ERROR_PROPAGATE(packet_set_addr(packet, NULL,
-		    (uint8_t *) destination->value,
-		    CONVERT_SIZE(char, uint8_t, destination->length)));
+		rc = packet_set_addr(packet, NULL, (uint8_t *) destination->value,
+		    CONVERT_SIZE(char, uint8_t, destination->length));
 	} else {
-		ERROR_PROPAGATE(packet_set_addr(packet, NULL, NULL, 0));
-	}
+		rc = packet_set_addr(packet, NULL, NULL, 0);
+	}
+	if (rc != EOK)
+		return rc;
+	
 	header->version = IPV4;
 	header->fragment_offset_high = 0;
@@ -669,10 +685,11 @@
 			    IP_HEADER_CHECKSUM(middle_header);
 			if (destination) {
-				if (ERROR_OCCURRED(packet_set_addr(next, NULL,
+				rc = packet_set_addr(next, NULL,
 				    (uint8_t *) destination->value,
 				    CONVERT_SIZE(char, uint8_t,
-				    destination->length)))) {
+				    destination->length));
+				if (rc != EOK) {
 				    	free(last_header);
-					return ERROR_CODE;
+					return rc;
 				}
 			}
@@ -699,11 +716,11 @@
 		    IP_HEADER_CHECKSUM(middle_header);
 		if (destination) {
-			if (ERROR_OCCURRED(packet_set_addr(next, NULL,
+			rc = packet_set_addr(next, NULL,
 			    (uint8_t *) destination->value,
-			    CONVERT_SIZE(char, uint8_t,
-			    destination->length)))) {
+			    CONVERT_SIZE(char, uint8_t, destination->length));
+			if (rc != EOK) {
 				free(last_header);
-				return ERROR_CODE;
-			    }
+				return rc;
+			}
 		}
 		length += packet_get_data_length(next);
@@ -741,8 +758,7 @@
     const struct sockaddr *src, const struct sockaddr *dest, socklen_t addrlen)
 {
-	ERROR_DECLARE;
-
 	void *data;
 	size_t offset;
+	int rc;
 
 	data = packet_suffix(new_packet, length);
@@ -752,5 +768,9 @@
 	memcpy(data, ((void *) header) + IP_TOTAL_LENGTH(header) - length,
 	    length);
-	ERROR_PROPAGATE(packet_trim(packet, 0, length));
+	
+	rc = packet_trim(packet, 0, length);
+	if (rc != EOK)
+		return rc;
+	
 	header->total_length = htons(IP_TOTAL_LENGTH(header) - length);
 	new_header->total_length = htons(IP_HEADER_LENGTH(new_header) + length);
@@ -761,6 +781,9 @@
 	    IP_COMPUTE_FRAGMENT_OFFSET_LOW(offset);
 	new_header->header_checksum = IP_HEADER_CHECKSUM(new_header);
-	ERROR_PROPAGATE(packet_set_addr(new_packet, (const uint8_t *) src,
-	    (const uint8_t *) dest, addrlen));
+	
+	rc = packet_set_addr(new_packet, (const uint8_t *) src,
+	    (const uint8_t *) dest, addrlen);
+	if (rc != EOK)
+		return rc;
 
 	return pq_insert_after(packet, new_packet);
@@ -796,6 +819,4 @@
     socklen_t addr_len)
 {
-	ERROR_DECLARE;
-
 	packet_t new_packet;
 	ip_header_ref header;
@@ -806,4 +827,5 @@
 	socklen_t addrlen;
 	int result;
+	int rc;
 
 	result = packet_get_addr(packet, (uint8_t **) &src, (uint8_t **) &dest);
@@ -839,20 +861,20 @@
 
 	// trim the unused space
-	if (ERROR_OCCURRED(packet_trim(new_packet, 0,
-	    IP_HEADER_LENGTH(header) - IP_HEADER_LENGTH(last_header)))) {
-		return ip_release_and_return(packet, ERROR_CODE);
-	}
+	rc = packet_trim(new_packet, 0,
+	    IP_HEADER_LENGTH(header) - IP_HEADER_LENGTH(last_header));
+	if (rc != EOK)
+		return ip_release_and_return(packet, rc);
 
 	// biggest multiple of 8 lower than content
 	// TODO even fragmentation?
 	length = length & ~0x7;
-	if (ERROR_OCCURRED(ip_fragment_packet_data(packet, new_packet, header,
-	    last_header,
+	
+	rc = ip_fragment_packet_data(packet, new_packet, header, last_header,
 	    ((IP_HEADER_DATA_LENGTH(header) -
 	    ((length - IP_HEADER_LENGTH(header)) & ~0x7)) %
-	    ((length - IP_HEADER_LENGTH(last_header)) & ~0x7)), src, dest,
-	    addrlen))) {
-		return ip_release_and_return(packet, ERROR_CODE);
-	}
+	    ((length - IP_HEADER_LENGTH(last_header)) & ~0x7)),
+	    src, dest, addrlen);
+	if (rc != EOK)
+		return ip_release_and_return(packet, rc);
 
 	// mark the first as fragmented
@@ -872,10 +894,10 @@
 			return ip_release_and_return(packet, ENOMEM);
 
-		if (ERROR_OCCURRED(ip_fragment_packet_data(packet, new_packet,
-		    header, middle_header,
-		    (length - IP_HEADER_LENGTH(middle_header)) & ~0x7, src,
-		    dest, addrlen))) {
-			return ip_release_and_return(packet, ERROR_CODE);
-		}
+		rc = ip_fragment_packet_data(packet, new_packet, header,
+		    middle_header,
+		    (length - IP_HEADER_LENGTH(middle_header)) & ~0x7,
+		    src, dest, addrlen);
+		if (rc != EOK)
+			return ip_release_and_return(packet, rc);
 	}
 
@@ -974,10 +996,9 @@
     in_addr_t *src, in_addr_t dest, services_t error)
 {
-	ERROR_DECLARE;
-
 	measured_string_t destination;
 	measured_string_ref translation;
 	char *data;
 	int phone;
+	int rc;
 
 	// get destination hardware address
@@ -987,10 +1008,10 @@
 		destination.length = CONVERT_SIZE(dest.s_addr, char, 1);
 
-		if (ERROR_OCCURRED(arp_translate_req(netif->arp->phone,
-		    netif->device_id, SERVICE_IP, &destination, &translation,
-		    &data))) {
+		rc = arp_translate_req(netif->arp->phone, netif->device_id,
+		    SERVICE_IP, &destination, &translation, &data);
+		if (rc != EOK) {
 			pq_release_remote(ip_globals.net_phone,
 			    packet_get_id(packet));
-			return ERROR_CODE;
+			return rc;
 		}
 
@@ -1014,5 +1035,6 @@
 	}
 
-	if (ERROR_OCCURRED(ip_prepare_packet(src, dest, packet, translation))) {
+	rc = ip_prepare_packet(src, dest, packet, translation);
+	if (rc != EOK) {
 		pq_release_remote(ip_globals.net_phone, packet_get_id(packet));
 	} else {
@@ -1032,5 +1054,5 @@
 	}
 
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1158,9 +1180,8 @@
 ip_device_req_local(int il_phone, device_id_t device_id, services_t netif)
 {
-	ERROR_DECLARE;
-
 	ip_netif_ref ip_netif;
 	ip_route_ref route;
 	int index;
+	int rc;
 
 	ip_netif = (ip_netif_ref) malloc(sizeof(ip_netif_t));
@@ -1168,7 +1189,8 @@
 		return ENOMEM;
 
-	if (ERROR_OCCURRED(ip_routes_initialize(&ip_netif->routes))) {
+	rc = ip_routes_initialize(&ip_netif->routes);
+	if (rc != EOK) {
 		free(ip_netif);
-		return ERROR_CODE;
+		return rc;
 	}
 
@@ -1178,9 +1200,11 @@
 
 	fibril_rwlock_write_lock(&ip_globals.netifs_lock);
-	if (ERROR_OCCURRED(ip_netif_initialize(ip_netif))) {
+
+	rc = ip_netif_initialize(ip_netif);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&ip_globals.netifs_lock);
 		ip_routes_destroy(&ip_netif->routes);
 		free(ip_netif);
-		return ERROR_CODE;
+		return rc;
 	}
 	if (ip_netif->arp)
@@ -1226,6 +1250,4 @@
     services_t sender, services_t error)
 {
-	ERROR_DECLARE;
-
 	int addrlen;
 	ip_netif_ref netif;
@@ -1236,4 +1258,5 @@
 	in_addr_t *src;
 	int phone;
+	int rc;
 
 	// addresses in the host byte order
@@ -1323,8 +1346,8 @@
 	}
 
-	ERROR_CODE = ip_send_route(packet, netif, route, src, *dest, error);
+	rc = ip_send_route(packet, netif, route, src, *dest, error);
 	fibril_rwlock_read_unlock(&ip_globals.netifs_lock);
 
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1431,6 +1454,4 @@
     services_t error)
 {
-	ERROR_DECLARE;
-
 	ip_proto_ref proto;
 	int phone;
@@ -1442,4 +1463,5 @@
 	struct sockaddr_in dest_in;
 	socklen_t addrlen;
+	int rc;
 
 	if ((header->flags & IPFLAG_MORE_FRAGMENTS) ||
@@ -1467,15 +1489,16 @@
 	}
 
-	if (ERROR_OCCURRED(packet_set_addr(packet, (uint8_t *) src,
-	    (uint8_t *) dest, addrlen))) {
-		return ip_release_and_return(packet, ERROR_CODE);
-	}
+	rc = packet_set_addr(packet, (uint8_t *) src, (uint8_t *) dest,
+	    addrlen);
+	if (rc != EOK)
+		return ip_release_and_return(packet, rc);
 
 	// trim padding if present
 	if (!error &&
 	    (IP_TOTAL_LENGTH(header) < packet_get_data_length(packet))) {
-		if (ERROR_OCCURRED(packet_trim(packet, 0,
-		    packet_get_data_length(packet) - IP_TOTAL_LENGTH(header))))
-			return ip_release_and_return(packet, ERROR_CODE);
+		rc = packet_trim(packet, 0,
+		    packet_get_data_length(packet) - IP_TOTAL_LENGTH(header));
+		if (rc != EOK)
+			return ip_release_and_return(packet, rc);
 	}
 
@@ -1498,12 +1521,12 @@
 		received_msg = proto->received_msg;
 		fibril_rwlock_read_unlock(&ip_globals.protos_lock);
-		ERROR_CODE = received_msg(device_id, packet, service, error);
+		rc = received_msg(device_id, packet, service, error);
 	} else {
-		ERROR_CODE = tl_received_msg(proto->phone, device_id, packet,
+		rc = tl_received_msg(proto->phone, device_id, packet,
 		    proto->service, error);
 		fibril_rwlock_read_unlock(&ip_globals.protos_lock);
 	}
 
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -1532,6 +1555,4 @@
 ip_process_packet(device_id_t device_id, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	ip_header_ref header;
 	in_addr_t dest;
@@ -1541,4 +1562,5 @@
 	struct sockaddr_in addr_in;
 	socklen_t addrlen;
+	int rc;
 
 	header = (ip_header_ref) packet_get_data(packet);
@@ -1585,6 +1607,7 @@
 	}
 
-	ERROR_PROPAGATE(packet_set_addr(packet, NULL, (uint8_t *) &addr,
-	    addrlen));
+	rc = packet_set_addr(packet, NULL, (uint8_t *) &addr, addrlen);
+	if (rc != EOK)
+		return rc;
 
 	route = ip_find_route(dest);
@@ -1867,6 +1890,4 @@
     int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	packet_t packet;
 	struct sockaddr *addr;
@@ -1878,4 +1899,5 @@
 	size_t headerlen;
 	device_id_t device_id;
+	int rc;
 	
 	*answer_count = 0;
@@ -1893,6 +1915,8 @@
 	
 	case NET_IL_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(ip_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return ip_send_msg_local(0, IPC_GET_DEVICE(call), packet, 0,
 		    IPC_GET_ERROR(call));
@@ -1903,11 +1927,15 @@
 	
 	case NET_IL_RECEIVED:
-		ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(ip_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return ip_receive_message(IPC_GET_DEVICE(call), packet);
 	
 	case NET_IP_RECEIVED_ERROR:
-		ERROR_PROPAGATE(packet_translate_remote(ip_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(ip_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return ip_received_error_msg_local(0, IPC_GET_DEVICE(call),
 		    packet, IPC_GET_TARGET(call), IPC_GET_ERROR(call));
@@ -1923,22 +1951,31 @@
 
 	case NET_IP_GET_ROUTE:
-		ERROR_PROPAGATE(data_receive((void **) &addr, &addrlen));
-		ERROR_PROPAGATE(ip_get_route_req_local(0, IP_GET_PROTOCOL(call),
-		    addr, (socklen_t) addrlen, &device_id, &header,
-		    &headerlen));
+		rc = data_receive((void **) &addr, &addrlen);
+		if (rc != EOK)
+			return rc;
+		
+		rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(call), addr,
+		    (socklen_t) addrlen, &device_id, &header, &headerlen);
+		if (rc != EOK)
+			return rc;
+		
 		IPC_SET_DEVICE(answer, device_id);
 		IP_SET_HEADERLEN(answer, headerlen);
 		
 		*answer_count = 2;
-			
-		if (ERROR_NONE(data_reply(&headerlen, sizeof(headerlen))))
-			ERROR_CODE = data_reply(header, headerlen);
+		
+		rc = data_reply(&headerlen, sizeof(headerlen));
+		if (rc == EOK)
+			rc = data_reply(header, headerlen);
 			
 		free(header);
-		return ERROR_CODE;
+		return rc;
 	
 	case NET_IL_PACKET_SPACE:
-		ERROR_PROPAGATE(ip_packet_size_message(IPC_GET_DEVICE(call),
-		    &addrlen, &prefix, &content, &suffix));
+		rc = ip_packet_size_message(IPC_GET_DEVICE(call), &addrlen,
+		    &prefix, &content, &suffix);
+		if (rc != EOK)
+			return rc;
+		
 		IPC_SET_ADDR(answer, addrlen);
 		IPC_SET_PREFIX(answer, prefix);
@@ -2005,9 +2042,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(il_module_start_standalone(il_client_connection));
-	return EOK;
+	rc = il_module_start_standalone(il_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/il/ip/ip_module.c
===================================================================
--- uspace/srv/net/il/ip/ip_module.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/il/ip/ip_module.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -44,5 +44,5 @@
 #include <ipc/ipc.h>
 #include <ipc/services.h>
-#include <err.h>
+#include <errno.h>
 
 #include <net/modules.h>
@@ -66,21 +66,27 @@
 int il_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	ip_globals.net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
+
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(ip_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_IP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = ip_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_IP, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/netif/lo/lo.c
===================================================================
--- uspace/srv/net/netif/lo/lo.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/netif/lo/lo.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -37,5 +37,4 @@
 #include <async.h>
 #include <errno.h>
-#include <err.h>
 #include <stdio.h>
 #include <str.h>
@@ -83,11 +82,12 @@
 int netif_get_device_stats(device_id_t device_id, device_stats_ref stats)
 {
-	ERROR_DECLARE;
-
 	netif_device_t *device;
+	int rc;
 
 	if (!stats)
 		return EBADMEM;
-	ERROR_PROPAGATE(find_device(device_id, &device));
+	rc = find_device(device_id, &device);
+	if (rc != EOK)
+		return rc;
 	memcpy(stats, (device_stats_ref) device->specific,
 	    sizeof(device_stats_t));
@@ -164,10 +164,11 @@
 int netif_probe_message(device_id_t device_id, int irq, uintptr_t io)
 {
-	ERROR_DECLARE;
-
 	netif_device_t *device;
+	int rc;
 
 	// create a new device
-	ERROR_PROPAGATE(create(device_id, &device));
+	rc = create(device_id, &device);
+	if (rc != EOK)
+		return rc;
 	// print the settings
 	printf("%s: Device created (id: %d)\n", NAME, device->device_id);
@@ -177,12 +178,13 @@
 int netif_send_message(device_id_t device_id, packet_t packet, services_t sender)
 {
-	ERROR_DECLARE;
-
 	netif_device_t *device;
 	size_t length;
 	packet_t next;
 	int phone;
-
-	ERROR_PROPAGATE(find_device(device_id, &device));
+	int rc;
+
+	rc = find_device(device_id, &device);
+	if (rc != EOK)
+		return EOK;
 	if (device->state != NETIF_ACTIVE) {
 		netif_pq_release(packet_get_id(packet));
@@ -259,9 +261,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(netif_module_start(netif_client_connection));
-	return EOK;
+	rc = netif_module_start(netif_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/nil/eth/eth.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -42,5 +42,5 @@
 #include <byteorder.h>
 #include <str.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -196,5 +196,5 @@
 int nil_initialize(int net_phone)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	fibril_rwlock_initialize(&eth_globals.devices_lock);
@@ -208,12 +208,14 @@
 	    CONVERT_SIZE(uint8_t, char, ETH_ADDR));
 	if (!eth_globals.broadcast_addr) {
-		ERROR_CODE = ENOMEM;
+		rc = ENOMEM;
 		goto out;
 	}
-	if (ERROR_OCCURRED(eth_devices_initialize(&eth_globals.devices))) {
+	rc = eth_devices_initialize(&eth_globals.devices);
+	if (rc != EOK) {
 		free(eth_globals.broadcast_addr);
 		goto out;
 	}
-	if (ERROR_OCCURRED(eth_protos_initialize(&eth_globals.protos))) {
+	rc = eth_protos_initialize(&eth_globals.protos);
+	if (rc != EOK) {
 		free(eth_globals.broadcast_addr);
 		eth_devices_destroy(&eth_globals.devices);
@@ -223,5 +225,5 @@
 	fibril_rwlock_write_unlock(&eth_globals.devices_lock);
 	
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -234,7 +236,6 @@
 static void eth_receiver(ipc_callid_t iid, ipc_call_t *icall)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	while (true) {
@@ -246,11 +247,11 @@
 			break;
 		case NET_NIL_RECEIVED:
-			if (ERROR_NONE(packet_translate_remote(
-			    eth_globals.net_phone, &packet,
-			    IPC_GET_PACKET(icall)))) {
-				ERROR_CODE = nil_received_msg_local(0,
+			rc = packet_translate_remote(eth_globals.net_phone,
+			    &packet, IPC_GET_PACKET(icall));
+			if (rc == EOK) {
+				rc = nil_received_msg_local(0,
 				    IPC_GET_DEVICE(icall), packet, 0);
 			}
-			ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
+			ipc_answer_0(iid, (ipcarg_t) rc);
 			break;
 		default:
@@ -282,6 +283,4 @@
 eth_device_message(device_id_t device_id, services_t service, size_t mtu)
 {
-	ERROR_DECLARE;
-
 	eth_device_ref device;
 	int index;
@@ -300,4 +299,5 @@
 	char *data;
 	eth_proto_ref proto;
+	int rc;
 
 	fibril_rwlock_write_lock(&eth_globals.devices_lock);
@@ -351,9 +351,10 @@
 
 	configuration = &names[0];
-	if (ERROR_OCCURRED(net_get_device_conf_req(eth_globals.net_phone,
-	    device->device_id, &configuration, count, &data))) {
+	rc = net_get_device_conf_req(eth_globals.net_phone, device->device_id,
+	    &configuration, count, &data);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&eth_globals.devices_lock);
 		free(device);
-		return ERROR_CODE;
+		return rc;
 	}
 	if (configuration) {
@@ -387,9 +388,10 @@
 	
 	// get hardware address
-	if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id,
-	    &device->addr, &device->addr_data))) {
+	rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
+	    &device->addr_data);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&eth_globals.devices_lock);
 		free(device);
-		return ERROR_CODE;
+		return rc;
 	}
 	
@@ -429,6 +431,4 @@
 static eth_proto_ref eth_process_packet(int flags, packet_t packet)
 {
-	ERROR_DECLARE;
-
 	eth_header_snap_ref header;
 	size_t length;
@@ -437,5 +437,6 @@
 	size_t suffix;
 	eth_fcs_ref fcs;
-	uint8_t * data;
+	uint8_t *data;
+	int rc;
 
 	length = packet_get_data_length(packet);
@@ -488,14 +489,17 @@
 	
 	if (IS_DUMMY(flags)) {
-		if ((~compute_crc32(~0U, data, length * 8)) != ntohl(*fcs))
+		if (~compute_crc32(~0U, data, length * 8) != ntohl(*fcs))
 			return NULL;
 		suffix += sizeof(eth_fcs_t);
 	}
 	
-	if (ERROR_OCCURRED(packet_set_addr(packet,
-	    header->header.source_address, header->header.destination_address,
-	    ETH_ADDR)) || ERROR_OCCURRED(packet_trim(packet, prefix, suffix))) {
+	rc = packet_set_addr(packet, header->header.source_address,
+	    header->header.destination_address, ETH_ADDR);
+	if (rc != EOK)
 		return NULL;
-	}
+
+	rc = packet_trim(packet, prefix, suffix);
+	if (rc != EOK)
+		return NULL;
 	
 	return eth_protos_find(&eth_globals.protos, type);
@@ -781,10 +785,9 @@
 eth_send_message(device_id_t device_id, packet_t packet, services_t sender)
 {
-	ERROR_DECLARE;
-
 	eth_device_ref device;
 	packet_t next;
 	packet_t tmp;
 	int ethertype;
+	int rc;
 
 	ethertype = htons(protocol_map(SERVICE_ETHERNET, sender));
@@ -804,6 +807,7 @@
 	next = packet;
 	do {
-		if (ERROR_OCCURRED(eth_prepare_packet(device->flags, next,
-		    (uint8_t *) device->addr->value, ethertype, device->mtu))) {
+		rc = eth_prepare_packet(device->flags, next,
+		    (uint8_t *) device->addr->value, ethertype, device->mtu);
+		if (rc != EOK) {
 			// release invalid packet
 			tmp = pq_detach(next);
@@ -832,6 +836,4 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	measured_string_ref address;
 	packet_t packet;
@@ -840,4 +842,5 @@
 	size_t suffix;
 	size_t content;
+	int rc;
 	
 	*answer_count = 0;
@@ -850,11 +853,15 @@
 		    IPC_GET_SERVICE(call), IPC_GET_MTU(call));
 	case NET_NIL_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(eth_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(eth_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return eth_send_message(IPC_GET_DEVICE(call), packet,
 		    IPC_GET_SERVICE(call));
 	case NET_NIL_PACKET_SPACE:
-		ERROR_PROPAGATE(eth_packet_space_message(IPC_GET_DEVICE(call),
-		    &addrlen, &prefix, &content, &suffix));
+		rc = eth_packet_space_message(IPC_GET_DEVICE(call), &addrlen,
+		    &prefix, &content, &suffix);
+		if (rc != EOK)
+			return rc;
 		IPC_SET_ADDR(answer, addrlen);
 		IPC_SET_PREFIX(answer, prefix);
@@ -864,10 +871,14 @@
 		return EOK;
 	case NET_NIL_ADDR:
-		ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
-		    ETH_LOCAL_ADDR, &address));
+		rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_LOCAL_ADDR,
+		    &address);
+		if (rc != EOK)
+			return rc;
 		return measured_strings_reply(address, 1);
 	case NET_NIL_BROADCAST_ADDR:
-		ERROR_PROPAGATE(eth_addr_message(IPC_GET_DEVICE(call),
-		    ETH_BROADCAST_ADDR, &address));
+		rc = eth_addr_message(IPC_GET_DEVICE(call), ETH_BROADCAST_ADDR,
+		    &address);
+		if (rc != EOK)
+			return EOK;
 		return measured_strings_reply(address, 1);
 	case IPC_M_CONNECT_TO_ME:
@@ -923,9 +934,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));
-	return EOK;
+	rc = nil_module_start_standalone(nil_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/nil/eth/eth_module.c
===================================================================
--- uspace/srv/net/nil/eth/eth_module.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/nil/eth/eth_module.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -40,5 +40,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -52,21 +52,27 @@
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	int net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
+
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(nil_initialize(net_phone)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_ETHERNET, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = nil_initialize(net_phone);
+	if (rc != EOK)
+		goto out;
+
+	rc = REGISTER_ME(SERVICE_ETHERNET, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <str.h>
-#include <err.h>
 #include <ipc/ipc.h>
 #include <ipc/net.h>
@@ -82,5 +81,5 @@
 int nil_initialize(int net_phone)
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	fibril_rwlock_initialize(&nildummy_globals.devices_lock);
@@ -91,10 +90,10 @@
 	nildummy_globals.net_phone = net_phone;
 	nildummy_globals.proto.phone = 0;
-	ERROR_CODE = nildummy_devices_initialize(&nildummy_globals.devices);
+	rc = nildummy_devices_initialize(&nildummy_globals.devices);
 	
 	fibril_rwlock_write_unlock(&nildummy_globals.protos_lock);
 	fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
 	
-	return ERROR_CODE;
+	return rc;
 }
 
@@ -107,24 +106,23 @@
 static void nildummy_receiver(ipc_callid_t iid, ipc_call_t *icall)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	while (true) {
 		switch (IPC_GET_METHOD(*icall)) {
 		case NET_NIL_DEVICE_STATE:
-			ERROR_CODE = nil_device_state_msg_local(0,
+			rc = nil_device_state_msg_local(0,
 			    IPC_GET_DEVICE(icall), IPC_GET_STATE(icall));
-			ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
+			ipc_answer_0(iid, (ipcarg_t) rc);
 			break;
 		
 		case NET_NIL_RECEIVED:
-			if (ERROR_NONE(packet_translate_remote(
-			    nildummy_globals.net_phone, &packet,
-			    IPC_GET_PACKET(icall)))) {
-				ERROR_CODE = nil_received_msg_local(0,
+			rc = packet_translate_remote(nildummy_globals.net_phone,
+			    &packet, IPC_GET_PACKET(icall));
+			if (rc == EOK) {
+				rc = nil_received_msg_local(0,
 				    IPC_GET_DEVICE(icall), packet, 0);
 			}
-			ipc_answer_0(iid, (ipcarg_t) ERROR_CODE);
+			ipc_answer_0(iid, (ipcarg_t) rc);
 			break;
 		
@@ -155,8 +153,7 @@
 nildummy_device_message(device_id_t device_id, services_t service, size_t mtu)
 {
-	ERROR_DECLARE;
-
 	nildummy_device_ref device;
 	int index;
+	int rc;
 
 	fibril_rwlock_write_lock(&nildummy_globals.devices_lock);
@@ -216,9 +213,10 @@
 	
 	// get hardware address
-	if (ERROR_OCCURRED(netif_get_addr_req(device->phone, device->device_id,
-	    &device->addr, &device->addr_data))) {
+	rc = netif_get_addr_req(device->phone, device->device_id, &device->addr,
+	    &device->addr_data);
+	if (rc != EOK) {
 		fibril_rwlock_write_unlock(&nildummy_globals.devices_lock);
 		free(device);
-		return ERROR_CODE;
+		return rc;
 	}
 	
@@ -380,6 +378,4 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-	
 	measured_string_ref address;
 	packet_t packet;
@@ -388,4 +384,5 @@
 	size_t suffix;
 	size_t content;
+	int rc;
 	
 	*answer_count = 0;
@@ -399,13 +396,16 @@
 	
 	case NET_NIL_SEND:
-		ERROR_PROPAGATE(packet_translate_remote(
-		    nildummy_globals.net_phone, &packet, IPC_GET_PACKET(call)));
+		rc = packet_translate_remote(nildummy_globals.net_phone,
+		    &packet, IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
 		return nildummy_send_message(IPC_GET_DEVICE(call), packet,
 		    IPC_GET_SERVICE(call));
 	
 	case NET_NIL_PACKET_SPACE:
-		ERROR_PROPAGATE(nildummy_packet_space_message(
-		    IPC_GET_DEVICE(call), &addrlen, &prefix, &content,
-		    &suffix));
+		rc = nildummy_packet_space_message(IPC_GET_DEVICE(call),
+		    &addrlen, &prefix, &content, &suffix);
+		if (rc != EOK)
+			return rc;
 		IPC_SET_ADDR(answer, addrlen);
 		IPC_SET_PREFIX(answer, prefix);
@@ -416,11 +416,13 @@
 	
 	case NET_NIL_ADDR:
-		ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call),
-		    &address));
+		rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address);
+		if (rc != EOK)
+			return rc;
 		return measured_strings_reply(address, 1);
 	
 	case NET_NIL_BROADCAST_ADDR:
-		ERROR_PROPAGATE(nildummy_addr_message(IPC_GET_DEVICE(call),
-		    &address));
+		rc = nildummy_addr_message(IPC_GET_DEVICE(call), &address);
+		if (rc != EOK)
+			return rc;
 		return measured_strings_reply(address, 1);
 	
@@ -476,9 +478,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(nil_module_start_standalone(nil_client_connection));
-	return EOK;
+	rc = nil_module_start_standalone(nil_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/nil/nildummy/nildummy.h
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.h	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/nil/nildummy/nildummy.h	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -62,5 +62,5 @@
  * @see nildummy_proto
  */
-typedef struct nildummy_proto	nildummy_proto_t;
+typedef struct nildummy_proto nildummy_proto_t;
 
 /** Type definition of the dummy nil protocol specific data pointer.
@@ -100,5 +100,5 @@
 
 /** Dummy nil global data. */
-struct	nildummy_globals {
+struct nildummy_globals {
 	/** Networking module phone. */
 	int net_phone;
Index: uspace/srv/net/nil/nildummy/nildummy_module.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy_module.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/nil/nildummy/nildummy_module.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -38,5 +38,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 
 #include <ipc/ipc.h>
@@ -52,21 +52,28 @@
 int nil_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
+	ipcarg_t phonehash;
+	int rc;
 	
 	async_set_client_connection(client_connection);
 	int net_phone = net_connect_module();
-	ERROR_PROPAGATE(pm_init());
 	
-	ipcarg_t phonehash;
-	if (ERROR_OCCURRED(nil_initialize(net_phone)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_NILDUMMY, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	
+	rc = nil_initialize(net_phone);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_NILDUMMY, &phonehash);
+	if (rc != EOK)
+		goto out;
 	
 	async_manager();
-	
+
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
Index: uspace/srv/net/tl/icmp/icmp.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/tl/icmp/icmp.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -54,5 +54,4 @@
 #include <byteorder.h>
 #include <errno.h>
-#include <err.h>
 
 #include <net/socket_codes.h>
@@ -161,5 +160,5 @@
     int dont_fragment)
 {
-	ERROR_DECLARE;
+	int rc;
 
 	// do not send an error if disabled
@@ -172,8 +171,9 @@
 	header->checksum = ICMP_CHECKSUM(header,
 	    packet_get_data_length(packet));
-	if (ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_ICMP, ttl,
-	    tos, dont_fragment, 0))) {
-		return icmp_release_and_return(packet, ERROR_CODE);
-	}
+	
+	rc = ip_client_prepare_packet(packet, IPPROTO_ICMP, ttl, tos,
+	    dont_fragment, 0);
+	if (rc != EOK)
+		return icmp_release_and_return(packet, rc);
 
 	return ip_send_msg(icmp_globals.ip_phone, -1, packet, SERVICE_ICMP,
@@ -249,6 +249,4 @@
     const struct sockaddr * addr, socklen_t addrlen)
 {
-	ERROR_DECLARE;
-
 	icmp_header_ref header;
 	packet_t packet;
@@ -257,6 +255,6 @@
 	icmp_reply_ref reply;
 	int reply_key;
-	int result;
 	int index;
+	int rc;
 
 	if (addrlen <= 0)
@@ -265,6 +263,8 @@
 	length = (size_t) addrlen;
 	// TODO do not ask all the time
-	ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1,
-	    &icmp_globals.packet_dimension));
+	rc = ip_packet_size_req(icmp_globals.ip_phone, -1,
+	    &icmp_globals.packet_dimension);
+	if (rc != EOK)
+		return rc;
 
 	packet = packet_get_4_remote(icmp_globals.net_phone, size,
@@ -277,8 +277,7 @@
 	// prepare the requesting packet
 	// set the destination address
-	if (ERROR_OCCURRED(packet_set_addr(packet, NULL, (const uint8_t *) addr,
-	    length))) {
-		return icmp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = packet_set_addr(packet, NULL, (const uint8_t *) addr, length);
+	if (rc != EOK)
+		return icmp_release_and_return(packet, rc);
 
 	// allocate space in the packet
@@ -329,11 +328,8 @@
 	// wait for the reply
 	// timeout in microseconds
-	if (ERROR_OCCURRED(fibril_condvar_wait_timeout(&reply->condvar,
-	    &reply->mutex, timeout * 1000))) {
-		result = ERROR_CODE;
-	} else {
-		// read the result
-		result = reply->result;
-	}
+	rc = fibril_condvar_wait_timeout(&reply->condvar, &reply->mutex,
+	    timeout * 1000);
+	if (rc == EOK)
+		rc = reply->result;
 
 	// drop the reply mutex before locking the globals again
@@ -344,5 +340,5 @@
 	icmp_replies_exclude_index(&icmp_globals.replies, index);
 
-	return result;
+	return rc;
 }
 
@@ -413,6 +409,4 @@
 int icmp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	measured_string_t names[] = {
 		{
@@ -428,4 +422,5 @@
 	size_t count = sizeof(names) / sizeof(measured_string_t);
 	char *data;
+	int rc;
 
 	fibril_rwlock_initialize(&icmp_globals.lock);
@@ -433,11 +428,19 @@
 	icmp_replies_initialize(&icmp_globals.replies);
 	icmp_echo_data_initialize(&icmp_globals.echo_data);
+	
 	icmp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_ICMP,
 	    SERVICE_ICMP, client_connection);
-	if (icmp_globals.ip_phone < 0)
+	if (icmp_globals.ip_phone < 0) {
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
 		return icmp_globals.ip_phone;
-
-	ERROR_PROPAGATE(ip_packet_size_req(icmp_globals.ip_phone, -1,
-	    &icmp_globals.packet_dimension));
+	}
+	
+	rc = ip_packet_size_req(icmp_globals.ip_phone, -1,
+	    &icmp_globals.packet_dimension);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
+		return rc;
+	}
+
 	icmp_globals.packet_dimension.prefix += ICMP_HEADER_SIZE;
 	icmp_globals.packet_dimension.content -= ICMP_HEADER_SIZE;
@@ -448,6 +451,11 @@
 	// get configuration
 	configuration = &names[0];
-	ERROR_PROPAGATE(net_get_conf_req(icmp_globals.net_phone, &configuration,
-	    count, &data));
+	rc = net_get_conf_req(icmp_globals.net_phone, &configuration, count,
+	    &data);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&icmp_globals.lock);
+		return rc;
+	}
+	
 	if (configuration) {
 		if (configuration[0].value) {
@@ -519,6 +527,4 @@
 static int icmp_process_packet(packet_t packet, services_t error)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	uint8_t *src;
@@ -529,4 +535,5 @@
 	icmp_type_t type;
 	icmp_code_t code;
+	int rc;
 
 	switch (error) {
@@ -541,5 +548,7 @@
 		length = (size_t) result;
 		// remove the error header
-		ERROR_PROPAGATE(packet_trim(packet, length, 0));
+		rc = packet_trim(packet, length, 0);
+		if (rc != EOK)
+			return rc;
 		break;
 	default:
@@ -549,5 +558,7 @@
 	// get rid of the ip header
 	length = ip_client_header_length(packet);
-	ERROR_PROPAGATE(packet_trim(packet, length, 0));
+	rc = packet_trim(packet, length, 0);
+	if (rc != EOK)
+		return rc;
 
 	length = packet_get_data_length(packet);
@@ -582,5 +593,5 @@
 	switch (header->type) {
 	case ICMP_ECHOREPLY:
-		if (error) 
+		if (error)
 			icmp_process_echo_reply(packet, header, type, code);
 		else
@@ -654,8 +665,9 @@
     services_t receiver, services_t error)
 {
-	ERROR_DECLARE;
-
-	if (ERROR_OCCURRED(icmp_process_packet(packet, error)))
-		return icmp_release_and_return(packet, ERROR_CODE);
+	int rc;
+
+	rc = icmp_process_packet(packet, error);
+	if (rc != EOK)
+		return icmp_release_and_return(packet, rc);
 
 	return EOK;
@@ -682,37 +694,35 @@
 static int icmp_process_message(ipc_call_t *call)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_ICMP_DEST_UNREACH:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_destination_unreachable_msg_local(0,
-			    ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_destination_unreachable_msg_local(0,
+		    ICMP_GET_CODE(call), ICMP_GET_MTU(call), packet);
 	case NET_ICMP_SOURCE_QUENCH:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_source_quench_msg_local(0, packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_source_quench_msg_local(0, packet);
 	case NET_ICMP_TIME_EXCEEDED:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_time_exceeded_msg_local(0,
-			    ICMP_GET_CODE(call), packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_time_exceeded_msg_local(0, ICMP_GET_CODE(call),
+		    packet);
 	case NET_ICMP_PARAMETERPROB:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = icmp_parameter_problem_msg_local(0,
-			    ICMP_GET_CODE(call), ICMP_GET_POINTER(call),
-			    packet);
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_parameter_problem_msg_local(0, ICMP_GET_CODE(call),
+		    ICMP_GET_POINTER(call), packet);
 	default:
 		return ENOTSUP;
@@ -757,5 +767,5 @@
 			break;
 		}
-	} while(icmp_echo_data_find(&icmp_globals.echo_data, index) != NULL);
+	} while (icmp_echo_data_find(&icmp_globals.echo_data, index) != NULL);
 
 	echo_data->identifier = index;
@@ -779,6 +789,4 @@
 static int icmp_process_client_messages(ipc_callid_t callid, ipc_call_t call)
 {
-	ERROR_DECLARE;
-
 	bool keep_on_going = true;
 	ipc_call_t answer;
@@ -788,5 +796,5 @@
 	ipc_callid_t data_callid;
 	icmp_echo_ref echo_data;
-	int res;
+	int rc = EOK;
 
 	/*
@@ -794,5 +802,4 @@
 	 *  - Answer the first NET_ICMP_INIT call.
 	 */
-	res = EOK;
 	answer_count = 0;
 
@@ -803,14 +810,14 @@
 	// assign a new identifier
 	fibril_rwlock_write_lock(&icmp_globals.lock);
-	res = icmp_bind_free_id(echo_data);
+	rc = icmp_bind_free_id(echo_data);
 	fibril_rwlock_write_unlock(&icmp_globals.lock);
-	if (res < 0) {
+	if (rc < 0) {
 		free(echo_data);
-		return res;
+		return rc;
 	}
 
 	while (keep_on_going) {
 		// answer the call
-		answer_call(callid, res, &answer, answer_count);
+		answer_call(callid, rc, &answer, answer_count);
 
 		// refresh data
@@ -824,10 +831,10 @@
 		case IPC_M_PHONE_HUNGUP:
 			keep_on_going = false;
-			res = EHANGUP;
+			rc = EHANGUP;
 			break;
 		
 		case NET_ICMP_ECHO:
 			if (!async_data_write_receive(&data_callid, &length)) {
-				res = EINVAL;
+				rc = EINVAL;
 				break;
 			}
@@ -835,17 +842,17 @@
 			addr = malloc(length);
 			if (!addr) {
-				res = ENOMEM;
+				rc = ENOMEM;
 				break;
 			}
 			
-			if (ERROR_OCCURRED(async_data_write_finalize(
-			    data_callid, addr, length))) {
+			rc = async_data_write_finalize(data_callid, addr,
+			    length);
+			if (rc != EOK) {
 				free(addr);
-				res = ERROR_CODE;
 				break;
 			}
 
 			fibril_rwlock_write_lock(&icmp_globals.lock);
-			res = icmp_echo(echo_data->identifier,
+			rc = icmp_echo(echo_data->identifier,
 			    echo_data->sequence_number, ICMP_GET_SIZE(call),
 			    ICMP_GET_TIMEOUT(call), ICMP_GET_TTL(call),
@@ -864,5 +871,5 @@
 
 		default:
-			res = icmp_process_message(&call);
+			rc = icmp_process_message(&call);
 		}
 
@@ -874,5 +881,5 @@
 	fibril_rwlock_write_unlock(&icmp_globals.lock);
 
-	return res;
+	return rc;
 }
 
@@ -894,18 +901,16 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	*answer_count = 0;
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_TL_RECEIVED:
-		if (ERROR_NONE(packet_translate_remote(icmp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE =
-			    icmp_received_msg_local(IPC_GET_DEVICE(call),
-			    packet, SERVICE_ICMP, IPC_GET_ERROR(call));
-		}
-		return ERROR_CODE;
+		rc = packet_translate_remote(icmp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return icmp_received_msg_local(IPC_GET_DEVICE(call), packet,
+		    SERVICE_ICMP, IPC_GET_ERROR(call));
 	
 	case NET_ICMP_INIT:
@@ -970,9 +975,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	ERROR_PROPAGATE(tl_module_start_standalone(tl_client_connection));
-	return EOK;
+	rc = tl_module_start_standalone(tl_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/tl/icmp/icmp_module.c
===================================================================
--- uspace/srv/net/tl/icmp/icmp_module.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/tl/icmp/icmp_module.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -43,5 +43,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 #include <ipc/ipc.h>
 #include <ipc/services.h>
@@ -58,7 +58,6 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	ipcarg_t phonehash;
+	int rc;
 
 	async_set_client_connection(client_connection);
@@ -67,15 +66,21 @@
 		return icmp_globals.net_phone;
 
-	ERROR_PROPAGATE(pm_init());
-	if (ERROR_OCCURRED(icmp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_ICMP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	rc = pm_init();
+	if (rc != EOK)
+		return rc;
+	
+	rc = icmp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+
+	rc = REGISTER_ME(SERVICE_ICMP, &phonehash);
+	if (rc != EOK)
+		goto out;
 
 	async_manager();
 
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
@@ -89,3 +94,2 @@
 /** @}
  */
-
Index: uspace/srv/net/tl/udp/udp.c
===================================================================
--- uspace/srv/net/tl/udp/udp.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/tl/udp/udp.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -51,5 +51,4 @@
 #include <adt/dynamic_fifo.h>
 #include <errno.h>
-#include <err.h>
 
 #include <net/socket_codes.h>
@@ -103,6 +102,4 @@
 int udp_initialize(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	measured_string_t names[] = {
 		{
@@ -118,4 +115,5 @@
 	size_t count = sizeof(names) / sizeof(measured_string_t);
 	char *data;
+	int rc;
 
 	fibril_rwlock_initialize(&udp_globals.lock);
@@ -124,18 +122,33 @@
 	udp_globals.icmp_phone = icmp_connect_module(SERVICE_ICMP,
 	    ICMP_CONNECT_TIMEOUT);
+	
 	udp_globals.ip_phone = ip_bind_service(SERVICE_IP, IPPROTO_UDP,
 	    SERVICE_UDP, client_connection);
-	if (udp_globals.ip_phone < 0)
+	if (udp_globals.ip_phone < 0) {
+		fibril_rwlock_write_unlock(&udp_globals.lock);
 		return udp_globals.ip_phone;
+	}
 
 	// read default packet dimensions
-	ERROR_PROPAGATE(ip_packet_size_req(udp_globals.ip_phone, -1,
-	    &udp_globals.packet_dimension));
-	ERROR_PROPAGATE(socket_ports_initialize(&udp_globals.sockets));
-	if (ERROR_OCCURRED(packet_dimensions_initialize(
-	    &udp_globals.dimensions))) {
+	rc = ip_packet_size_req(udp_globals.ip_phone, -1,
+	    &udp_globals.packet_dimension);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
+	rc = socket_ports_initialize(&udp_globals.sockets);
+	if (rc != EOK) {
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
+	rc = packet_dimensions_initialize(&udp_globals.dimensions);
+	if (rc != EOK) {
 		socket_ports_destroy(&udp_globals.sockets);
-		return ERROR_CODE;
-	}
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
 	udp_globals.packet_dimension.prefix += sizeof(udp_header_t);
 	udp_globals.packet_dimension.content -= sizeof(udp_header_t);
@@ -147,6 +160,12 @@
 	// get configuration
 	configuration = &names[0];
-	ERROR_PROPAGATE(net_get_conf_req(udp_globals.net_phone, &configuration,
-	    count, &data));
+	rc = net_get_conf_req(udp_globals.net_phone, &configuration, count,
+	    &data);
+	if (rc != EOK) {
+		socket_ports_destroy(&udp_globals.sockets);
+		fibril_rwlock_write_unlock(&udp_globals.lock);
+		return rc;
+	}
+	
 	if (configuration) {
 		if (configuration[0].value)
@@ -201,6 +220,4 @@
 udp_process_packet(device_id_t device_id, packet_t packet, services_t error)
 {
-	ERROR_DECLARE;
-
 	size_t length;
 	size_t offset;
@@ -219,4 +236,5 @@
 	struct sockaddr *dest;
 	packet_dimension_ref packet_dimension;
+	int rc;
 
 	switch (error) {
@@ -232,7 +250,7 @@
 			return udp_release_and_return(packet, result);
 		length = (size_t) result;
-		if (ERROR_OCCURRED(packet_trim(packet, length, 0)))
-			return udp_release_and_return(packet,
-			    ERROR_CODE);
+		rc = packet_trim(packet, length, 0);
+		if (rc != EOK)
+			return udp_release_and_return(packet, rc);
 		break;
 	default:
@@ -253,6 +271,7 @@
 
 	// trim all but UDP header
-	if (ERROR_OCCURRED(packet_trim(packet, offset, 0)))
-		return udp_release_and_return(packet, ERROR_CODE);
+	rc = packet_trim(packet, offset, 0);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 
 	// get udp header
@@ -284,9 +303,9 @@
 		if (result <= 0)
 			return udp_release_and_return(packet, result);
-
-		if (ERROR_OCCURRED(ip_client_get_pseudo_header(IPPROTO_UDP,
-		    src, result, dest, result, total_length, &ip_header,
-		    &length))) {
-			return udp_release_and_return(packet, ERROR_CODE);
+		
+		rc = ip_client_get_pseudo_header(IPPROTO_UDP, src, result, dest,
+		    result, total_length, &ip_header, &length);
+		if (rc != EOK) {
+			return udp_release_and_return(packet, rc);
 		} else {
 			checksum = compute_checksum(0, ip_header, length);
@@ -307,9 +326,7 @@
 
 		if (total_length < length) {
-			if (ERROR_OCCURRED(packet_trim(next_packet, 0,
-			    length - total_length))) {
-				return udp_release_and_return(packet,
-				    ERROR_CODE);
-			}
+			rc = packet_trim(next_packet, 0, length - total_length);
+			if (rc != EOK)
+				return udp_release_and_return(packet, rc);
 
 			// add partial checksum if set
@@ -360,10 +377,13 @@
 
 	// queue the received packet
-	if (ERROR_OCCURRED(dyn_fifo_push(&socket->received,
-	    packet_get_id(packet), SOCKET_MAX_RECEIVED_SIZE)) ||
-	    ERROR_OCCURRED(tl_get_ip_packet_dimension(udp_globals.ip_phone,
-	    &udp_globals.dimensions, device_id, &packet_dimension))) {
-		return udp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = dyn_fifo_push(&socket->received, packet_get_id(packet),
+	    SOCKET_MAX_RECEIVED_SIZE);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
+		
+	rc = tl_get_ip_packet_dimension(udp_globals.ip_phone,
+	    &udp_globals.dimensions, device_id, &packet_dimension);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 
 	// notify the destination socket
@@ -436,6 +456,4 @@
     size_t *data_fragment_size, int flags)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	packet_t packet;
@@ -451,6 +469,9 @@
 	device_id_t device_id;
 	packet_dimension_ref packet_dimension;
-
-	ERROR_PROPAGATE(tl_get_address_port(addr, addrlen, &dest_port));
+	int rc;
+	
+	rc = tl_get_address_port(addr, addrlen, &dest_port);
+	if (rc != EOK)
+		return rc;
 
 	socket = socket_cores_find(local_sockets, socket_id);
@@ -460,44 +481,30 @@
 	if ((socket->port <= 0) && udp_globals.autobinding) {
 		// bind the socket to a random free port if not bound
-//		do {
-			// try to find a free port
-//			fibril_rwlock_read_unlock(&udp_globals.lock);
-//			fibril_rwlock_write_lock(&udp_globals.lock);
-			// might be changed in the meantime
-//			if (socket->port <= 0) {
-				if (ERROR_OCCURRED(socket_bind_free_port(
-				    &udp_globals.sockets, socket,
-				    UDP_FREE_PORTS_START, UDP_FREE_PORTS_END,
-				    udp_globals.last_used_port))) {
-//					fibril_rwlock_write_unlock(
-//					    &udp_globals.lock);
-//					fibril_rwlock_read_lock(
-//					    &udp_globals.lock);
-					return ERROR_CODE;
-				}
-				// set the next port as the search starting port
-				// number
-				udp_globals.last_used_port = socket->port;
-//			}
-//			fibril_rwlock_write_unlock(&udp_globals.lock);
-//			fibril_rwlock_read_lock(&udp_globals.lock);
-			// might be changed in the meantime
-//		} while (socket->port <= 0);
+		rc = socket_bind_free_port(&udp_globals.sockets, socket,
+		    UDP_FREE_PORTS_START, UDP_FREE_PORTS_END,
+		    udp_globals.last_used_port);
+		if (rc != EOK)
+			return rc;
+		// set the next port as the search starting port number
+		udp_globals.last_used_port = socket->port;
 	}
 
 	if (udp_globals.checksum_computing) {
-		if (ERROR_OCCURRED(ip_get_route_req(udp_globals.ip_phone,
-		    IPPROTO_UDP, addr, addrlen, &device_id, &ip_header,
-		    &headerlen))) {
-			return udp_release_and_return(packet, ERROR_CODE);
-		}
+		rc = ip_get_route_req(udp_globals.ip_phone, IPPROTO_UDP, addr,
+		    addrlen, &device_id, &ip_header, &headerlen);
+		if (rc != EOK)
+			return rc;
 		// get the device packet dimension
-//		ERROR_PROPAGATE(tl_get_ip_packet_dimension(udp_globals.ip_phone,
-//		    &udp_globals.dimensions, device_id, &packet_dimension));
+//		rc = tl_get_ip_packet_dimension(udp_globals.ip_phone,
+//		    &udp_globals.dimensions, device_id, &packet_dimension);
+//		if (rc != EOK)
+//			return rc;
 	}
 //	} else {
 		// do not ask all the time
-		ERROR_PROPAGATE(ip_packet_size_req(udp_globals.ip_phone, -1,
-		    &udp_globals.packet_dimension));
+		rc = ip_packet_size_req(udp_globals.ip_phone, -1,
+		    &udp_globals.packet_dimension);
+		if (rc != EOK)
+			return rc;
 		packet_dimension = &udp_globals.packet_dimension;
 //	}
@@ -529,6 +536,7 @@
 			return udp_release_and_return(packet, result);
 
-		if (ERROR_OCCURRED(pq_add(&packet, next_packet, index, 0)))
-			return udp_release_and_return(packet, ERROR_CODE);
+		rc = pq_add(&packet, next_packet, index, 0);
+		if (rc != EOK)
+			return udp_release_and_return(packet, rc);
 
 		total_length += (size_t) result;
@@ -547,8 +555,9 @@
 	if (udp_globals.checksum_computing) {
 		// update the pseudo header
-		if (ERROR_OCCURRED(ip_client_set_pseudo_header_data_length(
-		    ip_header, headerlen, total_length + UDP_HEADER_SIZE))) {
+		rc = ip_client_set_pseudo_header_data_length(ip_header,
+		    headerlen, total_length + UDP_HEADER_SIZE);
+		if (rc != EOK) {
 			free(ip_header);
-			return udp_release_and_return(packet, ERROR_CODE);
+			return udp_release_and_return(packet, rc);
 		}
 
@@ -565,11 +574,12 @@
 
 	// prepare the first packet fragment
-	if (ERROR_OCCURRED(ip_client_prepare_packet(packet, IPPROTO_UDP, 0, 0,
-	    0, 0))) {
-		return udp_release_and_return(packet, ERROR_CODE);
-	}
+	rc = ip_client_prepare_packet(packet, IPPROTO_UDP, 0, 0, 0, 0);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
+
+	/* Release the UDP global lock on success. */
+	fibril_rwlock_write_unlock(&udp_globals.lock);
 
 	// send the packet
-	fibril_rwlock_write_unlock(&udp_globals.lock);
 	ip_send_msg(udp_globals.ip_phone, device_id, packet, SERVICE_UDP, 0);
 
@@ -600,6 +610,4 @@
     size_t *addrlen)
 {
-	ERROR_DECLARE;
-
 	socket_core_ref socket;
 	int packet_id;
@@ -610,4 +618,5 @@
 	uint8_t *data;
 	int result;
+	int rc;
 
 	// find the socket
@@ -617,43 +626,42 @@
 
 	// get the next received packet
-	packet_id = dyn_fifo_value(&socket->received);
+	packet_id = dyn_fifo_pop(&socket->received);
 	if (packet_id < 0)
 		return NO_DATA;
-
-	ERROR_PROPAGATE(packet_translate_remote(udp_globals.net_phone, &packet,
-	    packet_id));
+	
+	rc = packet_translate_remote(udp_globals.net_phone, &packet, packet_id);
+	if (rc != EOK)
+		return rc;
 
 	// get udp header
 	data = packet_get_data(packet);
-	if (!data) {
-		pq_release_remote(udp_globals.net_phone, packet_id);
-		return NO_DATA;
-	}
+	if (!data)
+		return udp_release_and_return(packet, NO_DATA);
 	header = (udp_header_ref) data;
 
 	// set the source address port
 	result = packet_get_addr(packet, (uint8_t **) &addr, NULL);
-	if (ERROR_OCCURRED(tl_set_address_port(addr, result,
-	    ntohs(header->source_port)))) {
-		pq_release_remote(udp_globals.net_phone, packet_id);
-		return ERROR_CODE;
-	}
+	rc = tl_set_address_port(addr, result, ntohs(header->source_port));
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 	*addrlen = (size_t) result;
 
 	// send the source address
-	ERROR_PROPAGATE(data_reply(addr, *addrlen));
+	rc = data_reply(addr, *addrlen);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 
 	// trim the header
-	ERROR_PROPAGATE(packet_trim(packet, UDP_HEADER_SIZE, 0));
+	rc = packet_trim(packet, UDP_HEADER_SIZE, 0);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
 
 	// reply the packets
-	ERROR_PROPAGATE(socket_reply_packets(packet, &length));
-
-	// release the packet
-	dyn_fifo_pop(&socket->received);
-	pq_release_remote(udp_globals.net_phone, packet_get_id(packet));
-
-	// return the total length
-	return (int) length;
+	rc = socket_reply_packets(packet, &length);
+	if (rc != EOK)
+		return udp_release_and_return(packet, rc);
+
+	// release the packet and return the total length
+	return udp_release_and_return(packet, (int) length);
 }
 
@@ -826,7 +834,6 @@
     ipc_call_t *answer, int *answer_count)
 {
-	ERROR_DECLARE;
-
 	packet_t packet;
+	int rc;
 
 	*answer_count = 0;
@@ -834,11 +841,10 @@
 	switch (IPC_GET_METHOD(*call)) {
 	case NET_TL_RECEIVED:
-		if (ERROR_NONE(packet_translate_remote(udp_globals.net_phone,
-		    &packet, IPC_GET_PACKET(call)))) {
-			ERROR_CODE = udp_received_msg(IPC_GET_DEVICE(call),
-			    packet, SERVICE_UDP, IPC_GET_ERROR(call));
-		}
-		return ERROR_CODE;
-	
+		rc = packet_translate_remote(udp_globals.net_phone, &packet,
+		    IPC_GET_PACKET(call));
+		if (rc != EOK)
+			return rc;
+		return udp_received_msg(IPC_GET_DEVICE(call), packet,
+		    SERVICE_UDP, IPC_GET_ERROR(call));
 	case IPC_M_CONNECT_TO_ME:
 		return udp_process_client_messages(callid, * call);
@@ -850,7 +856,6 @@
 /** Default thread for new connections.
  *
- *  @param[in] iid	The initial message identifier.
- *  @param[in] icall	The initial message call structure.
- *
+ * @param[in] iid	The initial message identifier.
+ * @param[in] icall	The initial message call structure.
  */
 static void tl_client_connection(ipc_callid_t iid, ipc_call_t * icall)
@@ -898,11 +903,9 @@
 int main(int argc, char *argv[])
 {
-	ERROR_DECLARE;
+	int rc;
 	
 	/* Start the module */
-	if (ERROR_OCCURRED(tl_module_start_standalone(tl_client_connection)))
-		return ERROR_CODE;
-	
-	return EOK;
+	rc = tl_module_start_standalone(tl_client_connection);
+	return rc;
 }
 
Index: uspace/srv/net/tl/udp/udp_module.c
===================================================================
--- uspace/srv/net/tl/udp/udp_module.c	(revision a66e299372bdb43d55e8f9e08081d47accc2dbdf)
+++ uspace/srv/net/tl/udp/udp_module.c	(revision 60898b690649d9e809606e6d12c17b2fb77db316)
@@ -44,5 +44,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <err.h>
+#include <errno.h>
 #include <ipc/ipc.h>
 #include <ipc/services.h>
@@ -59,7 +59,6 @@
 int tl_module_start_standalone(async_client_conn_t client_connection)
 {
-	ERROR_DECLARE;
-
 	ipcarg_t phonehash;
+	int rc;
 
 	async_set_client_connection(client_connection);
@@ -67,16 +66,22 @@
 	if (udp_globals.net_phone < 0)
 		return udp_globals.net_phone;
-
-	ERROR_PROPAGATE(pm_init());
-	if (ERROR_OCCURRED(udp_initialize(client_connection)) ||
-	    ERROR_OCCURRED(REGISTER_ME(SERVICE_UDP, &phonehash))) {
-		pm_destroy();
-		return ERROR_CODE;
-	}
+	
+	rc = pm_init();
+	if (rc != EOK)
+		return EOK;
+		
+	rc = udp_initialize(client_connection);
+	if (rc != EOK)
+		goto out;
+	
+	rc = REGISTER_ME(SERVICE_UDP, &phonehash);
+	if (rc != EOK)
+		goto out;
 
 	async_manager();
 
+out:
 	pm_destroy();
-	return EOK;
+	return rc;
 }
 
