Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ HelenOS.config	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -534,4 +534,7 @@
 ! CONFIG_WRITE_CORE_FILES (n/y)
 
+% Bundle netif/nil network layer
+! CONFIG_NETIF_NIL_BUNDLE (n/y)
+
 % Strip binaries
 ! CONFIG_STRIP_BINARIES (n/y)
Index: uspace/lib/c/generic/net/socket_client.c
===================================================================
--- uspace/lib/c/generic/net/socket_client.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/c/generic/net/socket_client.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -27,5 +27,5 @@
  */
 
-/** @addtogroup libc
+/** @addtogroup libc 
  *  @{
  */
@@ -177,5 +177,12 @@
 //	.last_id = 0,
 	.sockets = NULL,
-	.lock = FIBRIL_RWLOCK_INITIALIZER(socket_globals.lock)
+	.lock = {
+		.readers = 0,
+		.writers = 0,
+		.waiters = {
+			.prev = &socket_globals.lock.waiters,	/* XXX */
+			.next = &socket_globals.lock.waiters	/* XXX */
+		}
+	}
 };
 
@@ -509,14 +516,14 @@
 /** Sends message to the socket parent module with specified data.
  *
- * @param[in] socket_id	Socket identifier.
- * @param[in] message	The action message.
- * @param[in] arg2	The second message parameter.
- * @param[in] data	The data to be sent.
- * @param[in] datalength The data length.
- * @returns		EOK on success.
- * @returns		ENOTSOCK if the socket is not found.
- * @returns		EBADMEM if the data parameter is NULL.
- * @returns		NO_DATA if the datalength parameter is zero (0).
- * @returns		Other error codes as defined for the spcific message.
+ *  @param[in] socket_id Socket identifier.
+ *  @param[in] message	The action message.
+ *  @param[in] arg2	The second message parameter.
+ *  @param[in] data	The data to be sent.
+ *  @param[in] datalength The data length.
+ *  @returns		EOK on success.
+ *  @returns		ENOTSOCK if the socket is not found.
+ *  @returns		EBADMEM if the data parameter is NULL.
+ *  @returns		NO_DATA if the datalength parameter is zero (0).
+ *  @returns		Other error codes as defined for the spcific message.
  */
 static int
@@ -798,20 +805,20 @@
 /** Sends data via the socket to the remote address.
  *
- * Binds the socket to a free port if not already connected/bound.
- *
- * @param[in] message	The action message.
- * @param[in] socket_id Socket identifier.
- * @param[in] data	The data to be sent.
- * @param[in] datalength The data length.
- * @param[in] flags	Various send flags.
- * @param[in] toaddr	The destination address. May be NULL for connected
+ *  Binds the socket to a free port if not already connected/bound.
+ *
+ *  @param[in] message	The action message.
+ *  @param[in] socket_id Socket identifier.
+ *  @param[in] data	The data to be sent.
+ *  @param[in] datalength The data length.
+ *  @param[in] flags	Various send flags.
+ *  @param[in] toaddr	The destination address. May be NULL for connected
  *			sockets.
- * @param[in] addrlen	The address length. Used only if toaddr is not NULL.
- * @returns		EOK on success.
- * @returns		ENOTSOCK if the socket is not found.
- * @returns		EBADMEM if the data or toaddr parameter is NULL.
- * @returns		NO_DATA if the datalength or the addrlen parameter is
+ *  @param[in] addrlen	The address length. Used only if toaddr is not NULL.
+ *  @returns		EOK on success.
+ *  @returns		ENOTSOCK if the socket is not found.
+ *  @returns		EBADMEM if the data or toaddr parameter is NULL.
+ *  @returns		NO_DATA if the datalength or the addrlen parameter is
  *			zero (0).
- * @returns		Other error codes as defined for the NET_SOCKET_SENDTO
+ *  @returns		Other error codes as defined for the NET_SOCKET_SENDTO
  *			message.
  */
@@ -959,18 +966,18 @@
 /** Receives data via the socket.
  *
- * @param[in] message	The action message.
- * @param[in] socket_id	Socket identifier.
- * @param[out] data	The data buffer to be filled.
- * @param[in] datalength The data length.
- * @param[in] flags	Various receive flags.
- * @param[out] fromaddr	The source address. May be NULL for connected sockets.
- * @param[in,out] addrlen The address length. The maximum address length is
+ *  @param[in] message	The action message.
+ *  @param[in] socket_id Socket identifier.
+ *  @param[out] data	The data buffer to be filled.
+ *  @param[in] datalength The data length.
+ *  @param[in] flags	Various receive flags.
+ *  @param[out] fromaddr The source address. May be NULL for connected sockets.
+ *  @param[in,out] addrlen The address length. The maximum address length is
  *			read. The actual address length is set. Used only if
  *			fromaddr is not NULL.
- * @returns		EOK on success.
- * @returns		ENOTSOCK if the socket is not found.
- * @returns		EBADMEM if the data parameter is NULL.
- * @returns		NO_DATA if the datalength or addrlen parameter is zero.
- * @returns		Other error codes as defined for the spcific message.
+ *  @returns		EOK on success.
+ *  @returns		ENOTSOCK if the socket is not found.
+ *  @returns		EBADMEM if the data parameter is NULL.
+ *  @returns		NO_DATA if the datalength or addrlen parameter is zero.
+ *  @returns		Other error codes as defined for the spcific message.
  */
 static int
Index: uspace/lib/c/include/fibril_synch.h
===================================================================
--- uspace/lib/c/include/fibril_synch.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/c/include/fibril_synch.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -47,6 +47,6 @@
 } fibril_mutex_t;
 
-#define FIBRIL_MUTEX_INITIALIZER(name) \
-	{ \
+#define FIBRIL_MUTEX_INITIALIZE(name) \
+	fibril_mutex_t name = {	\
 		.counter = 1, \
 		.waiters = { \
@@ -55,7 +55,4 @@
 		} \
 	}
-	
-#define FIBRIL_MUTEX_INITIALIZE(name) \
-	fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name) 
 
 typedef struct {
@@ -65,6 +62,6 @@
 } fibril_rwlock_t;
 
-#define FIBRIL_RWLOCK_INITIALIZER(name) \
-	{ \
+#define FIBRIL_RWLOCK_INITIALIZE(name) \
+	fibril_rwlock_t name = { \
 		.readers = 0, \
 		.writers = 0, \
@@ -75,13 +72,10 @@
 	}
 
-#define FIBRIL_RWLOCK_INITIALIZE(name) \
-	fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name)
-
 typedef struct {
 	link_t waiters;
 } fibril_condvar_t;
 
-#define FIBRIL_CONDVAR_INITIALIZER(name) \
-	{ \
+#define FIBRIL_CONDVAR_INITIALIZE(name) \
+	fibril_condvar_t name = { \
 		.waiters = { \
 			.next = &name.waiters, \
@@ -89,7 +83,4 @@
 		} \
 	}
-
-#define FIBRIL_CONDVAR_INITIALIZE(name) \
-	fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name)
 
 extern void fibril_mutex_initialize(fibril_mutex_t *);
Index: uspace/lib/net/Makefile
===================================================================
--- uspace/lib/net/Makefile	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/Makefile	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -41,4 +41,5 @@
 	netif/netif_local.c \
 	netif/netif_remote.c \
+	netif/netif_nil_bundle.c \
 	nil/nil_remote.c \
 	il/ip_remote.c \
Index: uspace/lib/net/include/arp_interface.h
===================================================================
--- uspace/lib/net/include/arp_interface.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/include/arp_interface.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -104,8 +104,10 @@
  *  @param service The ARP module service. Ignored parameter.
  *  @returns The ARP module phone on success.
+ *  @returns 0 if called by the bundle module.
  */
 extern int arp_connect_module(services_t service);
 
 /** Returns the ARP task identifier.
+ *  @returns The current task identifier if called by the bundle module.
  *  @returns 0 if called by the remote module.
  */
Index: uspace/lib/net/include/ip_interface.h
===================================================================
--- uspace/lib/net/include/ip_interface.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/include/ip_interface.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -44,4 +44,18 @@
 #include <ip_codes.h>
 
+#ifdef CONFIG_IL_TL_BUNDLE
+
+#include <ip_local.h>
+
+#define ip_received_error_msg  ip_received_error_msg_local
+#define ip_set_gateway_req     ip_set_gateway_req_local
+#define ip_packet_size_req     ip_packet_size_req_local
+#define ip_device_req          ip_device_req_local
+#define ip_add_route_req       ip_add_route_req_local
+#define ip_send_msg            ip_send_msg_local
+#define ip_get_route_req       ip_get_route_req_local
+
+#else
+
 #include <ip_remote.h>
 
@@ -53,4 +67,6 @@
 #define ip_send_msg            ip_send_msg_remote
 #define ip_get_route_req       ip_get_route_req_remote
+
+#endif
 
 /** @name IP module interface
@@ -84,4 +100,5 @@
  *  @param service The IP module service. Ignored parameter.
  *  @returns The IP module phone on success.
+ *  @returns 0 if called by the bundle module.
  */
 extern int ip_connect_module(services_t service);
Index: uspace/lib/net/include/net_interface.h
===================================================================
--- uspace/lib/net/include/net_interface.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/include/net_interface.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -85,4 +85,5 @@
  *  @param service The networking module service. Ignored parameter.
  *  @returns The networking module phone on success.
+ *  @returns 0 if called by the bundle module.
  */
 extern int net_connect_module(services_t service);
Index: uspace/lib/net/include/netif_interface.h
===================================================================
--- uspace/lib/net/include/netif_interface.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/include/netif_interface.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -34,4 +34,22 @@
 #define __NET_NETIF_INTERFACE_H__
 
+#ifdef CONFIG_NETIF_NIL_BUNDLE
+
+#include <netif_local.h>
+#include <netif_nil_bundle.h>
+#include <packet/packet_server.h>
+
+#define netif_module_message    netif_nil_module_message
+#define netif_module_start      netif_nil_module_start
+#define netif_get_addr_req      netif_get_addr_req_local
+#define netif_probe_req         netif_probe_req_local
+#define netif_send_msg          netif_send_msg_local
+#define netif_start_req         netif_start_req_local
+#define netif_stop_req          netif_stop_req_local
+#define netif_stats_req         netif_stats_req_local
+#define netif_bind_service      netif_bind_service_local
+
+#else /* CONFIG_NETIF_NIL_BUNDLE */
+
 #include <netif_remote.h>
 #include <packet_client.h>
@@ -47,4 +65,6 @@
 #define netif_bind_service      netif_bind_service_remote
 
+#endif /* CONFIG_NETIF_NIL_BUNDLE */
+
 #endif
 
Index: uspace/lib/net/include/netif_local.h
===================================================================
--- uspace/lib/net/include/netif_local.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/include/netif_local.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -34,4 +34,5 @@
  * Network interface module skeleton.
  * The skeleton has to be part of each network interface module.
+ * The skeleton can be also part of the module bundled with the network interface layer.
  */
 
Index: uspace/lib/net/include/netif_nil_bundle.h
===================================================================
--- uspace/lib/net/include/netif_nil_bundle.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
+++ uspace/lib/net/include/netif_nil_bundle.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup netif_standalone
+ *  @{
+ */
+
+#ifndef __NETIF_NIL_BUNDLE_H__
+#define __NETIF_NIL_BUNDLE_H__
+
+#include <ipc/ipc.h>
+#include <async.h>
+
+extern int netif_nil_module_message(const char *, ipc_callid_t, ipc_call_t *,
+    ipc_call_t *, int *);
+extern int netif_nil_module_start(async_client_conn_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/net/include/nil_interface.h
===================================================================
--- uspace/lib/net/include/nil_interface.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/include/nil_interface.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -68,4 +68,14 @@
 
 
+#ifdef CONFIG_NETIF_NIL_BUNDLE
+
+#include <nil_local.h>
+#include <packet/packet_server.h>
+
+#define nil_device_state_msg  nil_device_state_msg_local
+#define nil_received_msg      nil_received_msg_local
+
+#else /* CONFIG_NETIF_NIL_BUNDLE */
+
 #include <nil_remote.h>
 #include <packet/packet_server.h>
@@ -74,4 +84,6 @@
 #define nil_received_msg      nil_received_msg_remote
 
+#endif /* CONFIG_NETIF_NIL_BUNDLE */
+
 #endif
 
Index: uspace/lib/net/netif/netif_nil_bundle.c
===================================================================
--- uspace/lib/net/netif/netif_nil_bundle.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
+++ uspace/lib/net/netif/netif_nil_bundle.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup netif
+ *  @{
+ */
+
+/** @file
+ *  Wrapper for the bundled network interface and network interface layer module.
+ *  Distributes messages and initializes both module parts.
+ */
+
+#include <async.h>
+#include <ipc/ipc.h>
+#include <ipc/net.h>
+
+#include <net/packet.h>
+#include <netif_nil_bundle.h>
+#include <netif_local.h>
+#include <nil_local.h>
+
+/** Distribute the messages between the module parts.
+ *
+ * @param[in]  name         Module name.
+ * @param[in]  callid       The message identifier.
+ * @param[in]  call         The message parameters.
+ * @param[out] answer       The message answer parameters.
+ * @param[out] answer_count The last parameter for the actual
+ *                          answer in the answer parameter.
+ *
+ * @return EOK on success.
+ * @return ENOTSUP if the message is not known.
+ * @return Other error codes as defined for each specific module message function.
+ *
+ */
+int netif_nil_module_message(const char *name, ipc_callid_t callid,
+    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
+{
+	if ((IS_NET_NIL_MESSAGE(call))
+	    || (IPC_GET_METHOD(*call) == IPC_M_CONNECT_TO_ME))
+		return nil_message_standalone(name, callid, call, answer,
+		    answer_count);
+	else
+		return netif_module_message_standalone(name, callid, call, answer,
+		    answer_count);
+}
+
+/** Start the bundle network interface module.
+ *
+ * Initialize the client connection serving function, initialize
+ * both module parts, register the module service and start the
+ * async manager, processing IPC messages in an infinite loop.
+ *
+ * @param[in] client_connection The client connection processing
+ *                              function. The module skeleton propagates
+ *                              its own one.
+ *
+ * @return EOK on success.
+ * @return Other error codes as defined for each specific module message
+ *         function.
+ *
+ */
+int netif_nil_module_start(async_client_conn_t client_connection)
+{
+	ERROR_DECLARE;
+	
+	ERROR_PROPAGATE(netif_init_module(client_connection));
+	if (ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))) {
+		pm_destroy();
+		return ERROR_CODE;
+	}
+	
+	async_manager();
+	
+	pm_destroy();
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/net/tl/tl_common.c
===================================================================
--- uspace/lib/net/tl/tl_common.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/net/tl/tl_common.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -50,4 +50,5 @@
 #include <net_device.h>
 #include <icmp_interface.h>
+#include <ip_local.h>
 #include <ip_remote.h>
 #include <ip_interface.h>
Index: uspace/lib/socket/include/icmp_common.h
===================================================================
--- uspace/lib/socket/include/icmp_common.h	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/socket/include/icmp_common.h	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -50,4 +50,5 @@
  *  @param[in] timeout The connection timeout in microseconds. No timeout if set to zero (0).
  *  @returns The ICMP module phone on success.
+ *  @returns The ICMP socket identifier if called by the bundle module.
  *  @returns ETIMEOUT if the connection timeouted.
  */
Index: uspace/lib/socket/packet/packet_server.c
===================================================================
--- uspace/lib/socket/packet/packet_server.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/lib/socket/packet/packet_server.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -85,5 +85,11 @@
 	unsigned int count;
 } ps_globals = {
-	.lock = FIBRIL_MUTEX_INITIALIZER(ps_globals.lock),
+	.lock = {
+		.counter = 1,
+		.waiters = {
+			.prev = &ps_globals.lock.waiters,
+			.next = &ps_globals.lock.waiters,
+		}
+	},
 	.free = {NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 	.sizes = {PAGE_SIZE, PAGE_SIZE * 2, PAGE_SIZE * 4, PAGE_SIZE * 8, PAGE_SIZE * 16, PAGE_SIZE * 32, PAGE_SIZE * 64},
Index: uspace/srv/net/il/ip/ip.c
===================================================================
--- uspace/srv/net/il/ip/ip.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/srv/net/il/ip/ip.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -623,4 +623,8 @@
 int ip_connect_module(services_t service){
 	return EOK;
+}
+
+int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t received_msg){
+	return ip_register(protocol, me, 0, received_msg);
 }
 
Index: uspace/srv/net/net/net_bundle.c
===================================================================
--- uspace/srv/net/net/net_bundle.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
+++ uspace/srv/net/net/net_bundle.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -0,0 +1,135 @@
+/*
+ * 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
+ *  Wrapper for the bundled networking and TCP/IP stact modules.
+ *  Distributes messages and initializes all module parts.
+ */
+
+#include <str.h>
+
+#include <ipc/ipc.h>
+
+#include "../messages.h"
+
+#include "../include/ip_interface.h"
+
+#include "../structures/measured_strings.h"
+#include "../structures/module_map.h"
+#include "../structures/packet/packet_server.h"
+
+#include "../il/arp/arp_module.h"
+#include "../il/ip/ip_module.h"
+#include "../tl/icmp/icmp_module.h"
+#include "../tl/udp/udp_module.h"
+#include "../tl/tcp/tcp_module.h"
+
+#include "net.h"
+
+/** Networking module global data.
+ */
+extern net_globals_t	net_globals;
+
+/** Initializes the networking module for the chosen subsystem build type.
+ *  @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
+ *  @returns EOK on success.
+ *  @returns ENOMEM if there is not enough memory left.
+ */
+int net_initialize_build(async_client_conn_t client_connection){
+	ERROR_DECLARE;
+
+	ipcarg_t phonehash;
+
+	ERROR_PROPAGATE(REGISTER_ME(SERVICE_IP, &phonehash));
+	ERROR_PROPAGATE(add_module(NULL, &net_globals.modules, IP_NAME, IP_FILENAME, SERVICE_IP, task_get_id(), ip_connect_module));
+	ERROR_PROPAGATE(ip_initialize(client_connection));
+	ERROR_PROPAGATE(REGISTER_ME(SERVICE_ARP, &phonehash));
+	ERROR_PROPAGATE(arp_initialize(client_connection));
+	ERROR_PROPAGATE(REGISTER_ME(SERVICE_ICMP, &phonehash));
+	ERROR_PROPAGATE(icmp_initialize(client_connection));
+	ERROR_PROPAGATE(REGISTER_ME(SERVICE_UDP, &phonehash));
+	ERROR_PROPAGATE(udp_initialize(client_connection));
+	ERROR_PROPAGATE(REGISTER_ME(SERVICE_TCP, &phonehash));
+	ERROR_PROPAGATE(tcp_initialize(client_connection));
+	return EOK;
+}
+
+/** Processes the module message.
+ *  Distributes the message to the right bundled module.
+ *  @param[in] callid The message identifier.
+ *  @param[in] call The message parameters.
+ *  @param[out] answer The message answer parameters.
+ *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
+ *  @returns EOK on success.
+ *  @returns ENOTSUP if the message is not known.
+ *  @returns Other error codes as defined for each bundled module message function.
+ */
+int net_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	if((IPC_GET_METHOD(*call) == IPC_M_CONNECT_TO_ME)
+		|| IS_NET_IL_MESSAGE(call)
+		|| IS_NET_TL_MESSAGE(call)
+		|| IS_NET_SOCKET_MESSAGE(call)){
+		switch(IPC_GET_TARGET(call)){
+			case SERVICE_IP:
+				return ip_message(callid, call, answer, answer_count);
+			case SERVICE_ARP:
+				return arp_message(callid, call, answer, answer_count);
+			case SERVICE_ICMP:
+				return icmp_message(callid, call, answer, answer_count);
+			case SERVICE_UDP:
+				return udp_message(callid, call, answer, answer_count);
+			case SERVICE_TCP:
+				return tcp_message(callid, call, answer, answer_count);
+			default:
+				return EINVAL;
+		}
+	}else if(IS_NET_IP_MESSAGE(call)){
+		return ip_message(callid, call, answer, answer_count);
+	}else if(IS_NET_ARP_MESSAGE(call)){
+		return arp_message(callid, call, answer, answer_count);
+	}else if(IS_NET_ICMP_MESSAGE(call)){
+		return icmp_message(callid, call, answer, answer_count);
+	}else if(IS_NET_UDP_MESSAGE(call)){
+		return udp_message(callid, call, answer, answer_count);
+	}else if(IS_NET_TCP_MESSAGE(call)){
+		return tcp_message(callid, call, answer, answer_count);
+	}else{
+		if(IS_NET_PACKET_MESSAGE(call)){
+			return packet_server_message(callid, call, answer, answer_count);
+		}else{
+			return net_message(callid, call, answer, answer_count);
+		}
+	}
+}
+
+/** @}
+ */
Index: uspace/srv/net/net/net_standalone.c
===================================================================
--- uspace/srv/net/net/net_standalone.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/srv/net/net/net_standalone.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -94,5 +94,6 @@
  * @return EOK on success.
  * @return ENOTSUP if the message is not known.
- * @return Other error codes.
+ * @return Other error codes as defined for each bundled module
+ *         message function.
  *
  */
Index: uspace/srv/net/nil/eth/eth.c
===================================================================
--- uspace/srv/net/nil/eth/eth.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/srv/net/nil/eth/eth.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -788,4 +788,6 @@
 }
 
+#ifndef CONFIG_NETIF_NIL_BUNDLE
+
 /** Default thread for new connections.
  *
@@ -837,4 +839,6 @@
 }
 
+#endif /* CONFIG_NETIF_NIL_BUNDLE */
+
 /** @}
  */
Index: uspace/srv/net/nil/nildummy/nildummy.c
===================================================================
--- uspace/srv/net/nil/nildummy/nildummy.c	(revision b278b4e488fac57504e4a018c35951206373c032)
+++ uspace/srv/net/nil/nildummy/nildummy.c	(revision ae97283472fc2d5817a40291d04f4a8dfae12fb0)
@@ -410,4 +410,6 @@
 }
 
+#ifndef CONFIG_NETIF_NIL_BUNDLE
+
 /** Default thread for new connections.
  *
@@ -459,4 +461,6 @@
 }
 
+#endif /* CONFIG_NETIF_NIL_BUNDLE */
+
 /** @}
  */
