Index: uspace/lib/c/generic/dhcp.c
===================================================================
--- uspace/lib/c/generic/dhcp.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/*
- * Copyright (c) 2013 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#include <async.h>
-#include <assert.h>
-#include <errno.h>
-#include <inet/dhcp.h>
-#include <ipc/dhcp.h>
-#include <ipc/services.h>
-#include <loc.h>
-#include <stdlib.h>
-
-static async_sess_t *dhcp_sess = NULL;
-
-errno_t dhcp_init(void)
-{
-	service_id_t dhcp_svc;
-	errno_t rc;
-
-	assert(dhcp_sess == NULL);
-
-	rc = loc_service_get_id(SERVICE_NAME_DHCP, &dhcp_svc,
-	    IPC_FLAG_BLOCKING);
-	if (rc != EOK)
-		return ENOENT;
-
-	dhcp_sess = loc_service_connect(dhcp_svc, INTERFACE_DHCP,
-	    IPC_FLAG_BLOCKING);
-	if (dhcp_sess == NULL)
-		return ENOENT;
-
-	return EOK;
-}
-
-errno_t dhcp_link_add(sysarg_t link_id)
-{
-	async_exch_t *exch = async_exchange_begin(dhcp_sess);
-
-	errno_t rc = async_req_1_0(exch, DHCP_LINK_ADD, link_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t dhcp_link_remove(sysarg_t link_id)
-{
-	async_exch_t *exch = async_exchange_begin(dhcp_sess);
-
-	errno_t rc = async_req_1_0(exch, DHCP_LINK_REMOVE, link_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t dhcp_discover(sysarg_t link_id)
-{
-	async_exch_t *exch = async_exchange_begin(dhcp_sess);
-
-	errno_t rc = async_req_1_0(exch, DHCP_DISCOVER, link_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/dnsr.c
===================================================================
--- uspace/lib/c/generic/dnsr.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,195 +1,0 @@
-/*
- * Copyright (c) 2013 Jiri Svoboda
- * 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.
- */
-
-#include <async.h>
-#include <assert.h>
-#include <errno.h>
-#include <fibril_synch.h>
-#include <inet/dnsr.h>
-#include <ipc/dnsr.h>
-#include <ipc/services.h>
-#include <loc.h>
-#include <stdlib.h>
-#include <str.h>
-
-static FIBRIL_MUTEX_INITIALIZE(dnsr_sess_mutex);
-
-static async_sess_t *dnsr_sess = NULL;
-
-static async_exch_t *dnsr_exchange_begin(void)
-{
-	fibril_mutex_lock(&dnsr_sess_mutex);
-
-	if (dnsr_sess == NULL) {
-		service_id_t dnsr_svc;
-
-		(void) loc_service_get_id(SERVICE_NAME_DNSR, &dnsr_svc,
-		    IPC_FLAG_BLOCKING);
-
-		dnsr_sess = loc_service_connect(dnsr_svc, INTERFACE_DNSR,
-		    IPC_FLAG_BLOCKING);
-	}
-
-	async_sess_t *sess = dnsr_sess;
-	fibril_mutex_unlock(&dnsr_sess_mutex);
-
-	return async_exchange_begin(sess);
-}
-
-static void dnsr_exchange_end(async_exch_t *exch)
-{
-	async_exchange_end(exch);
-}
-
-errno_t dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo, ip_ver_t ver)
-{
-	async_exch_t *exch = dnsr_exchange_begin();
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, DNSR_NAME2HOST, (sysarg_t) ver,
-	    &answer);
-
-	errno_t rc = async_data_write_start(exch, name, str_size(name));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	dnsr_hostinfo_t *info = calloc(1, sizeof(dnsr_hostinfo_t));
-	if (info == NULL)
-		return ENOMEM;
-
-	ipc_call_t answer_addr;
-	aid_t req_addr = async_data_read(exch, &info->addr,
-	    sizeof(inet_addr_t), &answer_addr);
-
-	errno_t retval_addr;
-	async_wait_for(req_addr, &retval_addr);
-
-	if (retval_addr != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		free(info);
-		return retval_addr;
-	}
-
-	ipc_call_t answer_cname;
-	char cname_buf[DNSR_NAME_MAX_SIZE + 1];
-	aid_t req_cname = async_data_read(exch, cname_buf, DNSR_NAME_MAX_SIZE,
-	    &answer_cname);
-
-	dnsr_exchange_end(exch);
-
-	errno_t retval_cname;
-	async_wait_for(req_cname, &retval_cname);
-
-	if (retval_cname != EOK) {
-		async_forget(req);
-		free(info);
-		return retval_cname;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	if (retval != EOK) {
-		async_forget(req);
-		free(info);
-		return retval;
-	}
-
-	size_t act_size = ipc_get_arg2(&answer_cname);
-	assert(act_size <= DNSR_NAME_MAX_SIZE);
-
-	cname_buf[act_size] = '\0';
-
-	info->cname = str_dup(cname_buf);
-
-	if (info->cname == NULL) {
-		free(info);
-		return ENOMEM;
-	}
-
-	*rinfo = info;
-	return EOK;
-}
-
-void dnsr_hostinfo_destroy(dnsr_hostinfo_t *info)
-{
-	if (info == NULL)
-		return;
-
-	free(info->cname);
-	free(info);
-}
-
-errno_t dnsr_get_srvaddr(inet_addr_t *srvaddr)
-{
-	async_exch_t *exch = dnsr_exchange_begin();
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, DNSR_GET_SRVADDR, &answer);
-	errno_t rc = async_data_read_start(exch, srvaddr, sizeof(inet_addr_t));
-
-	loc_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t dnsr_set_srvaddr(inet_addr_t *srvaddr)
-{
-	async_exch_t *exch = dnsr_exchange_begin();
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, DNSR_SET_SRVADDR, &answer);
-	errno_t rc = async_data_write_start(exch, srvaddr, sizeof(inet_addr_t));
-
-	loc_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet.c
===================================================================
--- uspace/lib/c/generic/inet.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,258 +1,0 @@
-/*
- * Copyright (c) 2013 Jiri Svoboda
- * 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.
- */
-
-#include <async.h>
-#include <assert.h>
-#include <errno.h>
-#include <inet/inet.h>
-#include <ipc/inet.h>
-#include <ipc/services.h>
-#include <loc.h>
-#include <stdlib.h>
-
-static void inet_cb_conn(ipc_call_t *icall, void *arg);
-
-static async_sess_t *inet_sess = NULL;
-static inet_ev_ops_t *inet_ev_ops = NULL;
-static uint8_t inet_protocol = 0;
-
-static errno_t inet_callback_create(void)
-{
-	async_exch_t *exch = async_exchange_begin(inet_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer);
-
-	port_id_t port;
-	errno_t rc = async_create_callback_port(exch, INTERFACE_INET_CB, 0, 0,
-	    inet_cb_conn, NULL, &port);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK)
-		return rc;
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-static errno_t inet_set_proto(uint8_t protocol)
-{
-	async_exch_t *exch = async_exchange_begin(inet_sess);
-	errno_t rc = async_req_1_0(exch, INET_SET_PROTO, protocol);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t inet_init(uint8_t protocol, inet_ev_ops_t *ev_ops)
-{
-	service_id_t inet_svc;
-	errno_t rc;
-
-	assert(inet_sess == NULL);
-	assert(inet_ev_ops == NULL);
-	assert(inet_protocol == 0);
-
-	rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc,
-	    IPC_FLAG_BLOCKING);
-	if (rc != EOK)
-		return ENOENT;
-
-	inet_sess = loc_service_connect(inet_svc, INTERFACE_INET,
-	    IPC_FLAG_BLOCKING);
-	if (inet_sess == NULL)
-		return ENOENT;
-
-	if (inet_set_proto(protocol) != EOK) {
-		async_hangup(inet_sess);
-		inet_sess = NULL;
-		return EIO;
-	}
-
-	if (inet_callback_create() != EOK) {
-		async_hangup(inet_sess);
-		inet_sess = NULL;
-		return EIO;
-	}
-
-	inet_protocol = protocol;
-	inet_ev_ops = ev_ops;
-
-	return EOK;
-}
-
-errno_t inet_send(inet_dgram_t *dgram, uint8_t ttl, inet_df_t df)
-{
-	async_exch_t *exch = async_exchange_begin(inet_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_4(exch, INET_SEND, dgram->iplink, dgram->tos,
-	    ttl, df, &answer);
-
-	errno_t rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, &dgram->dest, sizeof(inet_addr_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, dgram->data, dgram->size);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local)
-{
-	async_exch_t *exch = async_exchange_begin(inet_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INET_GET_SRCADDR, tos, &answer);
-
-	errno_t rc = async_data_write_start(exch, remote, sizeof(inet_addr_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_read_start(exch, local, sizeof(inet_addr_t));
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-static void inet_ev_recv(ipc_call_t *icall)
-{
-	inet_dgram_t dgram;
-
-	dgram.tos = ipc_get_arg1(icall);
-	dgram.iplink = ipc_get_arg2(icall);
-
-	ipc_call_t call;
-	size_t size;
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	if (size != sizeof(inet_addr_t)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	errno_t rc = async_data_write_finalize(&call, &dgram.src, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	if (size != sizeof(inet_addr_t)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	rc = async_data_write_finalize(&call, &dgram.dest, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, &dgram.size);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = inet_ev_ops->recv(&dgram);
-	free(dgram.data);
-	async_answer_0(icall, rc);
-}
-
-static void inet_cb_conn(ipc_call_t *icall, void *arg)
-{
-	while (true) {
-		ipc_call_t call;
-		async_get_call(&call);
-
-		if (!ipc_get_imethod(&call)) {
-			async_answer_0(&call, EOK);
-			return;
-		}
-
-		switch (ipc_get_imethod(&call)) {
-		case INET_EV_RECV:
-			inet_ev_recv(&call);
-			break;
-		default:
-			async_answer_0(&call, ENOTSUP);
-		}
-	}
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/addr.c
===================================================================
--- uspace/lib/c/generic/inet/addr.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,735 +1,0 @@
-/*
- * Copyright (c) 2013 Jiri Svoboda
- * Copyright (c) 2013 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 libc
- * @{
- */
-/** @file Internet address parsing and formatting.
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <inet/addr.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <bitops.h>
-#include <inttypes.h>
-#include <str.h>
-
-#define INET_PREFIXSTRSIZE  5
-
-#define INET6_ADDRSTRLEN (8 * 4 + 7 + 1)
-
-#if !(defined(__BE__) ^ defined(__LE__))
-#error The architecture must be either big-endian or little-endian.
-#endif
-
-const addr32_t addr32_broadcast_all_hosts = 0xffffffff;
-
-const addr48_t addr48_broadcast = {
-	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-static const addr48_t inet_addr48_solicited_node = {
-	0x33, 0x33, 0xff, 0, 0, 0
-};
-
-static const inet_addr_t inet_addr_any_addr = {
-	.version = ip_v4,
-	.addr = 0
-};
-
-static const inet_addr_t inet_addr_any_addr6 = {
-	.version = ip_v6,
-	.addr6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
-};
-
-void addr48(const addr48_t src, addr48_t dst)
-{
-	memcpy(dst, src, 6);
-}
-
-void addr128(const addr128_t src, addr128_t dst)
-{
-	memcpy(dst, src, 16);
-}
-
-/** Compare addr48.
- *
- * @return Non-zero if equal, zero if not equal.
- */
-int addr48_compare(const addr48_t a, const addr48_t b)
-{
-	return memcmp(a, b, 6) == 0;
-}
-
-/** Compare addr128.
- *
- * @return Non-zero if equal, zero if not equal.
- */
-int addr128_compare(const addr128_t a, const addr128_t b)
-{
-	return memcmp(a, b, 16) == 0;
-}
-
-/** Compute solicited node MAC multicast address from target IPv6 address
- *
- * @param ip  Target IPv6 address
- * @param mac Solicited MAC address to be assigned
- *
- */
-void addr48_solicited_node(const addr128_t ip, addr48_t mac)
-{
-	memcpy(mac, inet_addr48_solicited_node, 3);
-	memcpy(mac + 3, ip + 13, 3);
-}
-
-void host2addr128_t_be(const addr128_t host, addr128_t be)
-{
-	memcpy(be, host, 16);
-}
-
-void addr128_t_be2host(const addr128_t be, addr128_t host)
-{
-	memcpy(host, be, 16);
-}
-
-void inet_addr(inet_addr_t *addr, uint8_t a, uint8_t b, uint8_t c, uint8_t d)
-{
-	addr->version = ip_v4;
-	addr->addr = ((addr32_t) a << 24) | ((addr32_t) b << 16) |
-	    ((addr32_t) c << 8) | ((addr32_t) d);
-}
-
-void inet_naddr(inet_naddr_t *naddr, uint8_t a, uint8_t b, uint8_t c, uint8_t d,
-    uint8_t prefix)
-{
-	naddr->version = ip_v4;
-	naddr->addr = ((addr32_t) a << 24) | ((addr32_t) b << 16) |
-	    ((addr32_t) c << 8) | ((addr32_t) d);
-	naddr->prefix = prefix;
-}
-
-void inet_addr6(inet_addr_t *addr, uint16_t a, uint16_t b, uint16_t c,
-    uint16_t d, uint16_t e, uint16_t f, uint16_t g, uint16_t h)
-{
-	addr->version = ip_v6;
-	addr->addr6[0] = (a >> 8) & 0xff;
-	addr->addr6[1] = a & 0xff;
-	addr->addr6[2] = (b >> 8) & 0xff;
-	addr->addr6[3] = b & 0xff;
-	addr->addr6[4] = (c >> 8) & 0xff;
-	addr->addr6[5] = c & 0xff;
-	addr->addr6[6] = (d >> 8) & 0xff;
-	addr->addr6[7] = d & 0xff;
-	addr->addr6[8] = (e >> 8) & 0xff;
-	addr->addr6[9] = e & 0xff;
-	addr->addr6[10] = (f >> 8) & 0xff;
-	addr->addr6[11] = f & 0xff;
-	addr->addr6[12] = (g >> 8) & 0xff;
-	addr->addr6[13] = g & 0xff;
-	addr->addr6[14] = (h >> 8) & 0xff;
-	addr->addr6[15] = h & 0xff;
-}
-
-void inet_naddr6(inet_naddr_t *naddr, uint16_t a, uint16_t b, uint16_t c,
-    uint16_t d, uint16_t e, uint16_t f, uint16_t g, uint16_t h, uint8_t prefix)
-{
-	naddr->version = ip_v6;
-	naddr->addr6[0] = (a >> 8) & 0xff;
-	naddr->addr6[1] = a & 0xff;
-	naddr->addr6[2] = (b >> 8) & 0xff;
-	naddr->addr6[3] = b & 0xff;
-	naddr->addr6[4] = (c >> 8) & 0xff;
-	naddr->addr6[5] = c & 0xff;
-	naddr->addr6[6] = (d >> 8) & 0xff;
-	naddr->addr6[7] = d & 0xff;
-	naddr->addr6[8] = (e >> 8) & 0xff;
-	naddr->addr6[9] = e & 0xff;
-	naddr->addr6[10] = (f >> 8) & 0xff;
-	naddr->addr6[11] = f & 0xff;
-	naddr->addr6[12] = (g >> 8) & 0xff;
-	naddr->addr6[13] = g & 0xff;
-	naddr->addr6[14] = (h >> 8) & 0xff;
-	naddr->addr6[15] = h & 0xff;
-	naddr->prefix = prefix;
-}
-
-void inet_naddr_addr(const inet_naddr_t *naddr, inet_addr_t *addr)
-{
-	addr->version = naddr->version;
-	memcpy(addr->addr6, naddr->addr6, 16);
-}
-
-void inet_addr_naddr(const inet_addr_t *addr, uint8_t prefix,
-    inet_naddr_t *naddr)
-{
-	naddr->version = addr->version;
-	memcpy(naddr->addr6, addr->addr6, 16);
-	naddr->prefix = prefix;
-}
-
-void inet_addr_any(inet_addr_t *addr)
-{
-	addr->version = ip_any;
-	memset(addr->addr6, 0, 16);
-}
-
-void inet_naddr_any(inet_naddr_t *naddr)
-{
-	naddr->version = ip_any;
-	memset(naddr->addr6, 0, 16);
-	naddr->prefix = 0;
-}
-
-int inet_addr_compare(const inet_addr_t *a, const inet_addr_t *b)
-{
-	if (a->version != b->version)
-		return 0;
-
-	switch (a->version) {
-	case ip_v4:
-		return (a->addr == b->addr);
-	case ip_v6:
-		return addr128_compare(a->addr6, b->addr6);
-	default:
-		return 0;
-	}
-}
-
-int inet_addr_is_any(const inet_addr_t *addr)
-{
-	return ((addr->version == ip_any) ||
-	    (inet_addr_compare(addr, &inet_addr_any_addr)) ||
-	    (inet_addr_compare(addr, &inet_addr_any_addr6)));
-}
-
-int inet_naddr_compare(const inet_naddr_t *naddr, const inet_addr_t *addr)
-{
-	if (naddr->version != addr->version)
-		return 0;
-
-	switch (naddr->version) {
-	case ip_v4:
-		return (naddr->addr == addr->addr);
-	case ip_v6:
-		return addr128_compare(naddr->addr6, addr->addr6);
-	default:
-		return 0;
-	}
-}
-
-int inet_naddr_compare_mask(const inet_naddr_t *naddr, const inet_addr_t *addr)
-{
-	if (naddr->version != addr->version)
-		return 0;
-
-	switch (naddr->version) {
-	case ip_v4:
-		if (naddr->prefix > 32)
-			return 0;
-
-		addr32_t mask =
-		    BIT_RANGE(addr32_t, 31, 31 - (naddr->prefix - 1));
-		return ((naddr->addr & mask) == (addr->addr & mask));
-	case ip_v6:
-		if (naddr->prefix > 128)
-			return 0;
-
-		size_t pos = 0;
-		for (size_t i = 0; i < 16; i++) {
-			/* Further bits do not matter */
-			if (naddr->prefix < pos)
-				break;
-
-			if (naddr->prefix - pos > 8) {
-				/* Comparison without masking */
-				if (naddr->addr6[i] != addr->addr6[i])
-					return 0;
-			} else {
-				/* Comparison with masking */
-				uint8_t mask =
-				    BIT_RANGE(uint8_t, 8, 8 - (naddr->prefix - pos - 1));
-				if ((naddr->addr6[i] & mask) != (addr->addr6[i] & mask))
-					return 0;
-			}
-
-			pos += 8;
-		}
-
-		return 1;
-	default:
-		return 0;
-	}
-}
-
-static errno_t inet_addr_parse_v4(const char *str, inet_addr_t *raddr,
-    int *prefix, char **endptr)
-{
-	uint32_t a = 0;
-	uint8_t b;
-	char *cur = (char *)str;
-	size_t i = 0;
-
-	while (i < 4) {
-		errno_t rc = str_uint8_t(cur, (const char **)&cur, 10, false, &b);
-		if (rc != EOK)
-			return rc;
-
-		a = (a << 8) + b;
-
-		i++;
-
-		if (*cur != '.')
-			break;
-
-		if (i < 4)
-			cur++;
-	}
-
-	if (prefix != NULL) {
-		if (*cur != '/')
-			return EINVAL;
-		cur++;
-
-		*prefix = strtoul(cur, &cur, 10);
-		if (*prefix > 32)
-			return EINVAL;
-	}
-
-	if (i != 4)
-		return EINVAL;
-
-	if (endptr == NULL && *cur != '\0')
-		return EINVAL;
-
-	raddr->version = ip_v4;
-	raddr->addr = a;
-
-	if (endptr != NULL)
-		*endptr = cur;
-
-	return EOK;
-}
-
-static errno_t inet_addr_parse_v6(const char *str, inet_addr_t *raddr, int *prefix,
-    char **endptr)
-{
-	uint8_t data[16];
-	int explicit_groups;
-
-	memset(data, 0, 16);
-
-	const char *cur = str;
-	size_t i = 0;
-	size_t wildcard_pos = (size_t) -1;
-	size_t wildcard_size = 0;
-
-	/* Handle initial wildcard */
-	if ((str[0] == ':') && (str[1] == ':')) {
-		cur = str + 2;
-		wildcard_pos = 0;
-		wildcard_size = 16;
-	}
-
-	while (i < 16) {
-		uint16_t bioctet;
-		const char *gend;
-		errno_t rc = str_uint16_t(cur, &gend, 16, false, &bioctet);
-		if (rc != EOK)
-			break;
-
-		data[i] = (bioctet >> 8) & 0xff;
-		data[i + 1] = bioctet & 0xff;
-
-		if (wildcard_pos != (size_t) -1) {
-			if (wildcard_size < 2)
-				return EINVAL;
-
-			wildcard_size -= 2;
-		}
-
-		i += 2;
-
-		if (*gend != ':') {
-			cur = gend;
-			break;
-		}
-
-		if (i < 16) {
-			/* Handle wildcard */
-			if (gend[1] == ':') {
-				if (wildcard_pos != (size_t) -1)
-					return EINVAL;
-
-				wildcard_pos = i;
-				wildcard_size = 16 - i;
-				cur = gend + 2;
-			}
-		}
-	}
-
-	/* Number of explicitly specified groups */
-	explicit_groups = i;
-
-	if (prefix != NULL) {
-		if (*cur != '/')
-			return EINVAL;
-		cur++;
-
-		*prefix = strtoul(cur, (char **)&cur, 10);
-		if (*prefix > 128)
-			return EINVAL;
-	}
-
-	if (endptr == NULL && *cur != '\0')
-		return EINVAL;
-
-	/* Create wildcard positions */
-	if ((wildcard_pos != (size_t) -1) && (wildcard_size > 0)) {
-		size_t wildcard_shift = 16 - wildcard_size;
-
-		for (i = wildcard_pos + wildcard_shift; i > wildcard_pos; i--) {
-			size_t j = i - 1;
-			data[j + wildcard_size] = data[j];
-			data[j] = 0;
-		}
-	} else {
-		/* Verify that all groups have been specified */
-		if (explicit_groups != 16)
-			return EINVAL;
-	}
-
-	raddr->version = ip_v6;
-	memcpy(raddr->addr6, data, 16);
-	if (endptr != NULL)
-		*endptr = (char *)cur;
-	return EOK;
-}
-
-/** Parse node address.
- *
- * Will fail if @a text contains extra characters at the and and @a endptr
- * is @c NULL.
- *
- * @param text Network address in common notation.
- * @param addr Place to store node address.
- * @param endptr Place to store pointer to next character oc @c NULL
- *
- * @return EOK on success, EINVAL if input is not in valid format.
- *
- */
-errno_t inet_addr_parse(const char *text, inet_addr_t *addr, char **endptr)
-{
-	errno_t rc;
-
-	rc = inet_addr_parse_v4(text, addr, NULL, endptr);
-	if (rc == EOK)
-		return EOK;
-
-	rc = inet_addr_parse_v6(text, addr, NULL, endptr);
-	if (rc == EOK)
-		return EOK;
-
-	return EINVAL;
-}
-
-/** Parse network address.
- *
- * Will fail if @a text contains extra characters at the and and @a endptr
- * is @c NULL.
- *
- * @param text  Network address in common notation.
- * @param naddr Place to store network address.
- * @param endptr Place to store pointer to next character oc @c NULL
- *
- * @return EOK on success, EINVAL if input is not in valid format.
- *
- */
-errno_t inet_naddr_parse(const char *text, inet_naddr_t *naddr, char **endptr)
-{
-	errno_t rc;
-	inet_addr_t addr;
-	int prefix;
-
-	rc = inet_addr_parse_v4(text, &addr, &prefix, endptr);
-	if (rc == EOK) {
-		inet_addr_naddr(&addr, prefix, naddr);
-		return EOK;
-	}
-
-	rc = inet_addr_parse_v6(text, &addr, &prefix, endptr);
-	if (rc == EOK) {
-		inet_addr_naddr(&addr, prefix, naddr);
-		return EOK;
-	}
-
-	return EINVAL;
-}
-
-static errno_t inet_addr_format_v4(addr32_t addr, char **bufp)
-{
-	int rc;
-
-	rc = asprintf(bufp, "%u.%u.%u.%u", (addr >> 24) & 0xff,
-	    (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
-	if (rc < 0)
-		return ENOMEM;
-
-	return EOK;
-}
-
-static errno_t inet_addr_format_v6(const addr128_t addr, char **bufp)
-{
-	*bufp = (char *) malloc(INET6_ADDRSTRLEN);
-	if (*bufp == NULL)
-		return ENOMEM;
-
-	/* Find the longest zero subsequence */
-
-	uint16_t zeroes[8];
-	uint16_t bioctets[8];
-
-	for (size_t i = 8; i > 0; i--) {
-		size_t j = i - 1;
-
-		bioctets[j] = (addr[j << 1] << 8) | addr[(j << 1) + 1];
-
-		if (bioctets[j] == 0) {
-			zeroes[j] = 1;
-			if (j < 7)
-				zeroes[j] += zeroes[j + 1];
-		} else
-			zeroes[j] = 0;
-	}
-
-	size_t wildcard_pos = (size_t) -1;
-	size_t wildcard_size = 0;
-
-	for (size_t i = 0; i < 8; i++) {
-		if (zeroes[i] > wildcard_size) {
-			wildcard_pos = i;
-			wildcard_size = zeroes[i];
-		}
-	}
-
-	char *cur = *bufp;
-	size_t rest = INET6_ADDRSTRLEN;
-	bool tail_zero = false;
-	int ret;
-
-	for (size_t i = 0; i < 8; i++) {
-		if ((i == wildcard_pos) && (wildcard_size > 1)) {
-			ret = snprintf(cur, rest, ":");
-			i += wildcard_size - 1;
-			tail_zero = true;
-		} else if (i == 0) {
-			ret = snprintf(cur, rest, "%" PRIx16, bioctets[i]);
-			tail_zero = false;
-		} else {
-			ret = snprintf(cur, rest, ":%" PRIx16, bioctets[i]);
-			tail_zero = false;
-		}
-
-		if (ret < 0)
-			return EINVAL;
-
-		cur += ret;
-		rest -= ret;
-	}
-
-	if (tail_zero)
-		(void) snprintf(cur, rest, ":");
-
-	return EOK;
-}
-
-/** Format node address.
- *
- * @param addr Node address.
- * @param bufp Place to store pointer to formatted string.
- *
- * @return EOK on success.
- * @return ENOMEM if out of memory.
- * @return ENOTSUP on unsupported address family.
- *
- */
-errno_t inet_addr_format(const inet_addr_t *addr, char **bufp)
-{
-	errno_t rc;
-	int ret;
-
-	rc = ENOTSUP;
-
-	switch (addr->version) {
-	case ip_any:
-		ret = asprintf(bufp, "none");
-		if (ret < 0)
-			return ENOMEM;
-		rc = EOK;
-		break;
-	case ip_v4:
-		rc = inet_addr_format_v4(addr->addr, bufp);
-		break;
-	case ip_v6:
-		rc = inet_addr_format_v6(addr->addr6, bufp);
-		break;
-	}
-
-	return rc;
-}
-
-/** Format network address.
- *
- * @param naddr Network address.
- * @param bufp  Place to store pointer to formatted string.
- *
- * @return EOK on success.
- * @return ENOMEM if out of memory.
- * @return ENOTSUP on unsupported address family.
- *
- */
-errno_t inet_naddr_format(const inet_naddr_t *naddr, char **bufp)
-{
-	errno_t rc;
-	int ret;
-	char *astr;
-
-	rc = ENOTSUP;
-
-	switch (naddr->version) {
-	case ip_any:
-		ret = asprintf(bufp, "none");
-		if (ret < 0)
-			return ENOMEM;
-		rc = EOK;
-		break;
-	case ip_v4:
-		rc = inet_addr_format_v4(naddr->addr, &astr);
-		if (rc != EOK)
-			return ENOMEM;
-
-		ret = asprintf(bufp, "%s/%" PRIu8, astr, naddr->prefix);
-		if (ret < 0) {
-			free(astr);
-			return ENOMEM;
-		}
-
-		rc = EOK;
-		break;
-	case ip_v6:
-		rc = inet_addr_format_v6(naddr->addr6, &astr);
-		if (rc != EOK)
-			return ENOMEM;
-
-		ret = asprintf(bufp, "%s/%" PRIu8, astr, naddr->prefix);
-		if (ret < 0) {
-			free(astr);
-			return ENOMEM;
-		}
-
-		rc = EOK;
-		break;
-	}
-
-	return rc;
-}
-
-ip_ver_t inet_addr_get(const inet_addr_t *addr, addr32_t *v4, addr128_t *v6)
-{
-	switch (addr->version) {
-	case ip_v4:
-		if (v4 != NULL)
-			*v4 = addr->addr;
-		break;
-	case ip_v6:
-		if (v6 != NULL)
-			memcpy(*v6, addr->addr6, 16);
-		break;
-	default:
-		assert(false);
-		break;
-	}
-
-	return addr->version;
-}
-
-ip_ver_t inet_naddr_get(const inet_naddr_t *naddr, addr32_t *v4, addr128_t *v6,
-    uint8_t *prefix)
-{
-	switch (naddr->version) {
-	case ip_v4:
-		if (v4 != NULL)
-			*v4 = naddr->addr;
-		if (prefix != NULL)
-			*prefix = naddr->prefix;
-		break;
-	case ip_v6:
-		if (v6 != NULL)
-			memcpy(*v6, naddr->addr6, 16);
-		if (prefix != NULL)
-			*prefix = naddr->prefix;
-		break;
-	default:
-		assert(false);
-		break;
-	}
-
-	return naddr->version;
-}
-
-void inet_addr_set(addr32_t v4, inet_addr_t *addr)
-{
-	addr->version = ip_v4;
-	addr->addr = v4;
-}
-
-void inet_naddr_set(addr32_t v4, uint8_t prefix, inet_naddr_t *naddr)
-{
-	naddr->version = ip_v4;
-	naddr->addr = v4;
-	naddr->prefix = prefix;
-}
-
-void inet_addr_set6(addr128_t v6, inet_addr_t *addr)
-{
-	addr->version = ip_v6;
-	memcpy(addr->addr6, v6, 16);
-}
-
-void inet_naddr_set6(addr128_t v6, uint8_t prefix, inet_naddr_t *naddr)
-{
-	naddr->version = ip_v6;
-	memcpy(naddr->addr6, v6, 16);
-	naddr->prefix = prefix;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/endpoint.c
===================================================================
--- uspace/lib/c/generic/inet/endpoint.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- * Copyright (c) 2015 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file Internet endpoint
- */
-
-#include <inet/endpoint.h>
-#include <mem.h>
-
-/** Initialize endpoint structure.
- *
- * Sets any address, any port number.
- *
- * @param ep Endpoint
- */
-void inet_ep_init(inet_ep_t *ep)
-{
-	memset(ep, 0, sizeof(*ep));
-}
-
-/** Initialize endpoint pair structure.
- *
- * Sets any address, any port number for both local and remote sides.
- *
- * @param ep2 Endpoint pair
- */
-void inet_ep2_init(inet_ep2_t *ep2)
-{
-	memset(ep2, 0, sizeof(*ep2));
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/host.c
===================================================================
--- uspace/lib/c/generic/inet/host.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,245 +1,0 @@
-/*
- * Copyright (c) 2016 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file Internet host specification
- *
- * Either a host name or an address.
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <inet/addr.h>
-#include <inet/dnsr.h>
-#include <inet/host.h>
-#include <inet/hostname.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <str.h>
-
-/** Parse host string.
- *
- * @param str Host string
- * @param rhost Place to store pointer to new host structure
- * @param endptr Place to store pointer to next character in string or @c NULL
- *
- * @return EOK on success. EINVAL if @a str does not start with a valid
- *         host specification or if @a endptr is @c NULL and @a str contains
- *         extra characters at the end. ENOMEM if out of memory
- */
-errno_t inet_host_parse(const char *str, inet_host_t **rhost,
-    char **endptr)
-{
-	inet_host_t *host;
-	inet_addr_t addr;
-	char *name;
-	char *aend;
-	errno_t rc;
-
-	host = calloc(1, sizeof(inet_host_t));
-	if (host == NULL)
-		return ENOMEM;
-
-	/* Try address */
-	rc = inet_addr_parse(str, &addr, &aend);
-	if (rc == EOK) {
-		host->hform = inet_host_addr;
-		host->host.addr = addr;
-		goto have_host;
-	}
-
-	/* Try <hostname> */
-	rc = inet_hostname_parse(str, &name, &aend);
-	if (rc == EOK) {
-		host->hform = inet_host_name;
-		host->host.name = name;
-		goto have_host;
-	}
-
-	free(host);
-	return EINVAL;
-
-have_host:
-	if (*aend != '\0' && endptr == NULL) {
-		/* Extra characters */
-		free(host);
-		return EINVAL;
-	}
-
-	*rhost = host;
-	if (endptr != NULL)
-		*endptr = (char *)aend;
-	return EOK;
-}
-
-/** Convert host structure to string representation.
- *
- * @param host Host structure
- * @param rstr Place to store pointer to new string
- * @return EOK on success, ENOMEM if out of memory
- */
-errno_t inet_host_format(inet_host_t *host, char **rstr)
-{
-	errno_t rc;
-	char *str = NULL;
-
-	switch (host->hform) {
-	case inet_host_addr:
-		rc = inet_addr_format(&host->host.addr, &str);
-		if (rc != EOK) {
-			assert(rc == ENOMEM);
-			return ENOMEM;
-		}
-
-		break;
-	case inet_host_name:
-		str = str_dup(host->host.name);
-		if (str == NULL)
-			return ENOMEM;
-		break;
-	}
-
-	*rstr = str;
-	return EOK;
-}
-
-/** Destroy host structure.
- *
- * @param host Host structure or @c NULL
- */
-void inet_host_destroy(inet_host_t *host)
-{
-	if (host == NULL)
-		return;
-
-	switch (host->hform) {
-	case inet_host_addr:
-		break;
-	case inet_host_name:
-		free(host->host.name);
-		break;
-	}
-
-	free(host);
-}
-
-/** Look up first address corresponding to host.
- *
- * If host contains a host name, name resolution is performed.
- *
- * @param host Host structure
- * @param version Desired IP version (ip_any to get any version)
- * @param addr Place to store address
- *
- * @reutrn EOK on success, ENOENT on resolurion failure
- */
-errno_t inet_host_lookup_one(inet_host_t *host, ip_ver_t version, inet_addr_t *addr)
-{
-	dnsr_hostinfo_t *hinfo = NULL;
-	errno_t rc;
-
-	switch (host->hform) {
-	case inet_host_addr:
-		*addr = host->host.addr;
-		break;
-	case inet_host_name:
-		rc = dnsr_name2host(host->host.name, &hinfo, version);
-		if (rc != EOK) {
-			dnsr_hostinfo_destroy(hinfo);
-			return ENOENT;
-		}
-
-		*addr = hinfo->addr;
-		dnsr_hostinfo_destroy(hinfo);
-		break;
-	}
-
-	return EOK;
-}
-
-/** Look up first address corresponding to host string.
- *
- * If host contains a host name, name resolution is performed.
- *
- * @param str Host string
- * @param version Desired IP version (ip_any to get any version)
- * @param addr Place to store address
- * @param endptr Place to store pointer to next character in string or @c NULL
- * @param errmsg Place to store pointer to error message (no need to free it)
- *               or @c NULL
- *
- * @return EOK on success. EINVAL if @a str has incorrect format or if
- *         @a endptr is @c NULL and @a str contains extra characters at
- *         the end. ENOENT if host was not found during resolution,
- *         ENOMEM if out of memory
- */
-errno_t inet_host_plookup_one(const char *str, ip_ver_t version, inet_addr_t *addr,
-    char **endptr, const char **errmsg)
-{
-	inet_host_t *host = NULL;
-	char *eptr;
-	errno_t rc;
-
-	rc = inet_host_parse(str, &host, endptr != NULL ? &eptr : NULL);
-	if (rc != EOK) {
-		switch (rc) {
-		case EINVAL:
-			if (errmsg != NULL)
-				*errmsg = "Invalid format";
-			goto error;
-		case ENOMEM:
-			if (errmsg != NULL)
-				*errmsg = "Out of memory";
-			goto error;
-		default:
-			assert(false);
-		}
-	}
-
-	rc = inet_host_lookup_one(host, version, addr);
-	if (rc != EOK) {
-		/* XXX Distinguish between 'not found' and other error */
-		rc = ENOENT;
-		if (errmsg != NULL)
-			*errmsg = "Name resolution failed";
-		goto error;
-	}
-
-	inet_host_destroy(host);
-	if (endptr != NULL)
-		*endptr = eptr;
-	return EOK;
-error:
-	inet_host_destroy(host);
-	return rc;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/hostname.c
===================================================================
--- uspace/lib/c/generic/inet/hostname.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,108 +1,0 @@
-/*
- * Copyright (c) 2016 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file Internet host name
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <inet/hostname.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <str.h>
-
-/** Parse host name
- *
- * Determine whether string begins with a valid host name and where that
- * host name ends.
- *
- * Currntly accepting names per 'host' definition in RFC 1738
- * (Uniform Resource Locators) - generic URI syntax not accepted.
- *
- * @param str String containing host name
- * @param rname Place to store pointer to new string containing just the
- *              host name or @c NULL if not interested
- * @param endptr Place to store pointer to next character in string or @c NULL
- *               if no extra characters in the string are allowed
- *
- * @return EOK on success. EINVAL if @a str does not start with a valid
- *         host name or if @a endptr is @c NULL and @a str contains
- *         extra characters at the end. ENOMEM if out of memory
- */
-errno_t inet_hostname_parse(const char *str, char **rname, char **endptr)
-{
-	const char *c;
-	const char *dstart = NULL;
-	char *name;
-
-	c = str;
-	while (isalnum(*c)) {
-		/* Domain label */
-		dstart = c;
-
-		do {
-			++c;
-		} while (isalnum(*c) || *c == '-');
-
-		/* Domain separator? */
-		if (*c != '.' || !isalnum(c[1]))
-			break;
-
-		++c;
-	}
-
-	/*
-	 * Last domain label must not start with a digit (to distinguish from
-	 * IPv4 address)
-	 */
-	if (dstart == NULL || !isalpha(*dstart))
-		return EINVAL;
-
-	/* If endptr is null, check that entire string matched */
-	if (endptr == NULL && *c != '\0')
-		return EINVAL;
-
-	if (endptr != NULL)
-		*endptr = (char *)c;
-
-	if (rname != NULL) {
-		name = str_ndup(str, c - str);
-		if (name == NULL)
-			return ENOMEM;
-
-		*rname = name;
-	}
-
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/hostport.c
===================================================================
--- uspace/lib/c/generic/inet/hostport.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,302 +1,0 @@
-/*
- * Copyright (c) 2016 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file Internet host:port specification
- *
- * As in RFC 1738 Uniform Resouce Locators (URL) and RFC 2732 Format for
- * literal IPv6 Addresses in URLs
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <inet/addr.h>
-#include <inet/dnsr.h>
-#include <inet/endpoint.h>
-#include <inet/hostname.h>
-#include <inet/hostport.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <str.h>
-
-/** Parse host:port string.
- *
- * @param str Host:port string
- * @param rhp Place to store pointer to new hostport structure
- * @param endptr Place to store pointer to next character in string or @c NULL
- *
- * @return EOK on success. EINVAL if @a str does not start with a valid
- *         host:port or if @a endptr is @c NULL and @a str contains
- *         extra characters at the end. ENOMEM if out of memory
- */
-errno_t inet_hostport_parse(const char *str, inet_hostport_t **rhp,
-    char **endptr)
-{
-	inet_hostport_t *hp;
-	inet_addr_t addr;
-	uint16_t port;
-	char *name;
-	char *aend;
-	const char *pend;
-	errno_t rc;
-
-	hp = calloc(1, sizeof(inet_hostport_t));
-	if (hp == NULL)
-		return ENOMEM;
-
-	if (str[0] == '[') {
-		/* Try [<ip-addr-literal>] */
-		rc = inet_addr_parse(str + 1, &addr, &aend);
-		if (rc == EOK) {
-			if (*aend == ']') {
-				hp->hform = inet_host_addr;
-				hp->host.addr = addr;
-				++aend;
-			}
-			goto have_host;
-		}
-	}
-
-	/* Try <ipv4-addr> */
-	rc = inet_addr_parse(str, &addr, &aend);
-	if (rc == EOK) {
-		hp->hform = inet_host_addr;
-		hp->host.addr = addr;
-		goto have_host;
-	}
-
-	/* Try <hostname> */
-	rc = inet_hostname_parse(str, &name, &aend);
-	if (rc == EOK) {
-		hp->hform = inet_host_name;
-		hp->host.name = name;
-		goto have_host;
-	}
-
-	free(hp);
-	return EINVAL;
-
-have_host:
-	if (*aend == ':') {
-		/* Port number */
-		rc = str_uint16_t(aend + 1, &pend, 10, false, &port);
-		if (rc != EOK) {
-			free(hp);
-			return EINVAL;
-		}
-	} else {
-		/* Port number omitted */
-		port = 0;
-		pend = aend;
-	}
-
-	hp->port = port;
-
-	if (*pend != '\0' && endptr == NULL) {
-		/* Extra characters */
-		free(hp);
-		return EINVAL;
-	}
-
-	*rhp = hp;
-	if (endptr != NULL)
-		*endptr = (char *)pend;
-	return EOK;
-}
-
-/** Convert host:port to string representation.
- *
- * @param hp Host:port structure
- * @param rstr Place to store pointer to new string
- * @return EOK on success, ENOMEM if out of memory
- */
-errno_t inet_hostport_format(inet_hostport_t *hp, char **rstr)
-{
-	errno_t rc;
-	int ret;
-	char *astr, *str;
-	char *hstr = NULL;
-
-	switch (hp->hform) {
-	case inet_host_addr:
-		rc = inet_addr_format(&hp->host.addr, &astr);
-		if (rc != EOK) {
-			assert(rc == ENOMEM);
-			return ENOMEM;
-		}
-
-		if (hp->host.addr.version != ip_v4) {
-			hstr = astr;
-		} else {
-			ret = asprintf(&hstr, "[%s]", astr);
-			if (ret < 0) {
-				free(astr);
-				return ENOMEM;
-			}
-
-			free(astr);
-		}
-
-		break;
-	case inet_host_name:
-		hstr = str_dup(hp->host.name);
-		if (hstr == NULL)
-			return ENOMEM;
-		break;
-	}
-
-	ret = asprintf(&str, "%s:%u", hstr, hp->port);
-	if (ret < 0)
-		return ENOMEM;
-
-	free(hstr);
-	*rstr = str;
-	return EOK;
-}
-
-/** Destroy host:port structure.
- *
- * @param hp Host:port or @c NULL
- */
-void inet_hostport_destroy(inet_hostport_t *hp)
-{
-	if (hp == NULL)
-		return;
-
-	switch (hp->hform) {
-	case inet_host_addr:
-		break;
-	case inet_host_name:
-		free(hp->host.name);
-		break;
-	}
-
-	free(hp);
-}
-
-/** Look up first endpoint corresponding to host:port.
- *
- * If host:port contains a host name, name resolution is performed.
- *
- * @param hp Host:port structure
- * @param version Desired IP version (ip_any to get any version)
- * @param ep Place to store endpoint
- *
- * @return EOK on success, ENOENT on resolution failure
- */
-errno_t inet_hostport_lookup_one(inet_hostport_t *hp, ip_ver_t version,
-    inet_ep_t *ep)
-{
-	dnsr_hostinfo_t *hinfo = NULL;
-	errno_t rc;
-
-	inet_ep_init(ep);
-
-	switch (hp->hform) {
-	case inet_host_addr:
-		ep->addr = hp->host.addr;
-		break;
-	case inet_host_name:
-		rc = dnsr_name2host(hp->host.name, &hinfo, ip_any);
-		if (rc != EOK) {
-			dnsr_hostinfo_destroy(hinfo);
-			return ENOENT;
-		}
-
-		ep->addr = hinfo->addr;
-		dnsr_hostinfo_destroy(hinfo);
-		break;
-	}
-
-	ep->port = hp->port;
-	return EOK;
-}
-
-/** Look up first endpoint corresponding to host:port string.
- *
- * If host:port contains a host name, name resolution is performed.
- *
- * @param str Host:port string
- * @param version Desired IP version (ip_any to get any version)
- * @param ep Place to store endpoint
- * @param endptr Place to store pointer to next character in string or @c NULL
- * @param errmsg Place to store pointer to error message (no need to free it)
- *               or @c NULL
- *
- * @return EOK on success. EINVAL if @a str has incorrect format or if
- *         @a endptr is @c NULL and @a str contains extra characters at
- *         the end. ENOENT if host was not found during resolution,
- *         ENOMEM if out of memory
- */
-errno_t inet_hostport_plookup_one(const char *str, ip_ver_t version, inet_ep_t *ep,
-    char **endptr, const char **errmsg)
-{
-	inet_hostport_t *hp = NULL;
-	char *eptr;
-	errno_t rc;
-
-	rc = inet_hostport_parse(str, &hp, endptr != NULL ? &eptr : NULL);
-	if (rc != EOK) {
-		switch (rc) {
-		case EINVAL:
-			if (errmsg != NULL)
-				*errmsg = "Invalid format";
-			goto error;
-		case ENOMEM:
-			if (errmsg != NULL)
-				*errmsg = "Out of memory";
-			goto error;
-		case EOK:
-			break;
-		default:
-			assert(false);
-		}
-	}
-
-	rc = inet_hostport_lookup_one(hp, version, ep);
-	if (rc != EOK) {
-		/* XXX Distinguish between 'not found' and other error */
-		rc = ENOENT;
-		if (errmsg != NULL)
-			*errmsg = "Name resolution failed";
-		goto error;
-	}
-
-	inet_hostport_destroy(hp);
-	if (endptr != NULL)
-		*endptr = eptr;
-	return EOK;
-error:
-	inet_hostport_destroy(hp);
-	return rc;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/tcp.c
===================================================================
--- uspace/lib/c/generic/inet/tcp.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,875 +1,0 @@
-/*
- * Copyright (c) 2015 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file TCP API
- */
-
-#include <errno.h>
-#include <fibril.h>
-#include <inet/endpoint.h>
-#include <inet/tcp.h>
-#include <ipc/services.h>
-#include <ipc/tcp.h>
-#include <stdlib.h>
-
-static void tcp_cb_conn(ipc_call_t *, void *);
-static errno_t tcp_conn_fibril(void *);
-
-/** Incoming TCP connection info
- *
- * Used to pass information about incoming TCP connection to the connection
- * fibril
- */
-typedef struct {
-	/** Listener who received the connection */
-	tcp_listener_t *lst;
-	/** Incoming connection */
-	tcp_conn_t *conn;
-} tcp_in_conn_t;
-
-/** Create callback connection from TCP service.
- *
- * @param tcp TCP service
- * @return EOK on success or an error code
- */
-static errno_t tcp_callback_create(tcp_t *tcp)
-{
-	async_exch_t *exch = async_exchange_begin(tcp->sess);
-
-	aid_t req = async_send_0(exch, TCP_CALLBACK_CREATE, NULL);
-
-	port_id_t port;
-	errno_t rc = async_create_callback_port(exch, INTERFACE_TCP_CB, 0, 0,
-	    tcp_cb_conn, tcp, &port);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK)
-		return rc;
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-/** Create TCP client instance.
- *
- * @param  rtcp Place to store pointer to new TCP client
- * @return EOK on success, ENOMEM if out of memory, EIO if service
- *         cannot be contacted
- */
-errno_t tcp_create(tcp_t **rtcp)
-{
-	tcp_t *tcp;
-	service_id_t tcp_svcid;
-	errno_t rc;
-
-	tcp = calloc(1, sizeof(tcp_t));
-	if (tcp == NULL) {
-		rc = ENOMEM;
-		goto error;
-	}
-
-	list_initialize(&tcp->conn);
-	list_initialize(&tcp->listener);
-	fibril_mutex_initialize(&tcp->lock);
-	fibril_condvar_initialize(&tcp->cv);
-
-	rc = loc_service_get_id(SERVICE_NAME_TCP, &tcp_svcid,
-	    IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		rc = EIO;
-		goto error;
-	}
-
-	tcp->sess = loc_service_connect(tcp_svcid, INTERFACE_TCP,
-	    IPC_FLAG_BLOCKING);
-	if (tcp->sess == NULL) {
-		rc = EIO;
-		goto error;
-	}
-
-	rc = tcp_callback_create(tcp);
-	if (rc != EOK) {
-		rc = EIO;
-		goto error;
-	}
-
-	*rtcp = tcp;
-	return EOK;
-error:
-	free(tcp);
-	return rc;
-}
-
-/** Destroy TCP client instance.
- *
- * @param tcp TCP client
- */
-void tcp_destroy(tcp_t *tcp)
-{
-	if (tcp == NULL)
-		return;
-
-	async_hangup(tcp->sess);
-
-	fibril_mutex_lock(&tcp->lock);
-	while (!tcp->cb_done)
-		fibril_condvar_wait(&tcp->cv, &tcp->lock);
-	fibril_mutex_unlock(&tcp->lock);
-
-	free(tcp);
-}
-
-/** Create new TCP connection
- *
- * @param tcp   TCP client instance
- * @param id    Connection ID
- * @param cb    Callbacks
- * @param arg   Callback argument
- * @param rconn Place to store pointer to new connection
- *
- * @return EOK on success, ENOMEM if out of memory
- */
-static errno_t tcp_conn_new(tcp_t *tcp, sysarg_t id, tcp_cb_t *cb, void *arg,
-    tcp_conn_t **rconn)
-{
-	tcp_conn_t *conn;
-
-	conn = calloc(1, sizeof(tcp_conn_t));
-	if (conn == NULL)
-		return ENOMEM;
-
-	conn->data_avail = false;
-	fibril_mutex_initialize(&conn->lock);
-	fibril_condvar_initialize(&conn->cv);
-
-	conn->tcp = tcp;
-	conn->id = id;
-	conn->cb = cb;
-	conn->cb_arg = arg;
-
-	list_append(&conn->ltcp, &tcp->conn);
-	*rconn = conn;
-
-	return EOK;
-}
-
-/** Create new TCP connection.
- *
- * Open a connection to the specified destination. This function returns
- * even before the connection is established (or not). When the connection
- * is established, @a cb->connected is called. If the connection fails,
- * @a cb->conn_failed is called. Alternatively, the caller can call
- * @c tcp_conn_wait_connected() to wait for connection to complete or fail.
- * Other callbacks are available to monitor the changes in connection state.
- *
- * @a epp must specify the remote address and port. Both local address and
- * port are optional. If local address is not specified, address selection
- * will take place. If local port number is not specified, a suitable
- * free dynamic port number will be allocated.
- *
- * @param tcp   TCP client
- * @param epp   Internet endpoint pair
- * @param cb    Callbacks
- * @param arg   Argument to callbacks
- * @param rconn Place to store pointer to new connection
- *
- * @return EOK on success or an error code.
- */
-errno_t tcp_conn_create(tcp_t *tcp, inet_ep2_t *epp, tcp_cb_t *cb, void *arg,
-    tcp_conn_t **rconn)
-{
-	async_exch_t *exch;
-	ipc_call_t answer;
-	sysarg_t conn_id;
-
-	exch = async_exchange_begin(tcp->sess);
-	aid_t req = async_send_0(exch, TCP_CONN_CREATE, &answer);
-	errno_t rc = async_data_write_start(exch, (void *)epp,
-	    sizeof(inet_ep2_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		errno_t rc_orig;
-		async_wait_for(req, &rc_orig);
-		if (rc_orig != EOK)
-			rc = rc_orig;
-		goto error;
-	}
-
-	async_wait_for(req, &rc);
-	if (rc != EOK)
-		goto error;
-
-	conn_id = ipc_get_arg1(&answer);
-
-	rc = tcp_conn_new(tcp, conn_id, cb, arg, rconn);
-	if (rc != EOK)
-		return rc;
-
-	return EOK;
-error:
-	return (errno_t) rc;
-}
-
-/** Destroy TCP connection.
- *
- * Destroy TCP connection. The caller should destroy all connections
- * he created before destroying the TCP client and before terminating.
- *
- * @param conn TCP connection
- */
-void tcp_conn_destroy(tcp_conn_t *conn)
-{
-	async_exch_t *exch;
-
-	if (conn == NULL)
-		return;
-
-	list_remove(&conn->ltcp);
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	errno_t rc = async_req_1_0(exch, TCP_CONN_DESTROY, conn->id);
-	async_exchange_end(exch);
-
-	free(conn);
-	(void) rc;
-}
-
-/** Get connection based on its ID.
- *
- * @param tcp   TCP client
- * @param id    Connection ID
- * @param rconn Place to store pointer to connection
- *
- * @return EOK on success, EINVAL if no connection with the given ID exists
- */
-static errno_t tcp_conn_get(tcp_t *tcp, sysarg_t id, tcp_conn_t **rconn)
-{
-	list_foreach(tcp->conn, ltcp, tcp_conn_t, conn) {
-		if (conn->id == id) {
-			*rconn = conn;
-			return EOK;
-		}
-	}
-
-	return EINVAL;
-}
-
-/** Get the user/callback argument for a connection.
- *
- * @param conn TCP connection
- * @return User argument associated with connection
- */
-void *tcp_conn_userptr(tcp_conn_t *conn)
-{
-	return conn->cb_arg;
-}
-
-/** Create a TCP connection listener.
- *
- * A listener listens for connections on the set of endpoints specified
- * by @a ep. Each time a new incoming connection is established,
- * @a lcb->new_conn is called (and passed @a larg). Also, the new connection
- * will have callbacks set to @a cb and argument to @a arg.
- *
- * @a ep must specify a valid port number. @a ep may specify an address
- * or link to listen on. If it does not, the listener will listen on
- * all links/addresses.
- *
- * @param tcp  TCP client
- * @param ep   Internet endpoint
- * @param lcb  Listener callbacks
- * @param larg Listener callback argument
- * @param cb   Connection callbacks for every new connection
- * @param arg  Connection argument for every new connection
- * @param rlst Place to store pointer to new listener
- *
- * @return EOK on success or an error code
- */
-errno_t tcp_listener_create(tcp_t *tcp, inet_ep_t *ep, tcp_listen_cb_t *lcb,
-    void *larg, tcp_cb_t *cb, void *arg, tcp_listener_t **rlst)
-{
-	async_exch_t *exch;
-	tcp_listener_t *lst;
-	ipc_call_t answer;
-
-	lst = calloc(1, sizeof(tcp_listener_t));
-	if (lst == NULL)
-		return ENOMEM;
-
-	exch = async_exchange_begin(tcp->sess);
-	aid_t req = async_send_0(exch, TCP_LISTENER_CREATE, &answer);
-	errno_t rc = async_data_write_start(exch, (void *)ep,
-	    sizeof(inet_ep_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		errno_t rc_orig;
-		async_wait_for(req, &rc_orig);
-		if (rc_orig != EOK)
-			rc = rc_orig;
-		goto error;
-	}
-
-	async_wait_for(req, &rc);
-	if (rc != EOK)
-		goto error;
-
-	lst->tcp = tcp;
-	lst->id = ipc_get_arg1(&answer);
-	lst->lcb = lcb;
-	lst->lcb_arg = larg;
-	lst->cb = cb;
-	lst->cb_arg = arg;
-
-	list_append(&lst->ltcp, &tcp->listener);
-	*rlst = lst;
-
-	return EOK;
-error:
-	free(lst);
-	return (errno_t) rc;
-}
-
-/** Destroy TCP connection listener.
- *
- * @param lst Listener
- */
-void tcp_listener_destroy(tcp_listener_t *lst)
-{
-	async_exch_t *exch;
-
-	if (lst == NULL)
-		return;
-
-	list_remove(&lst->ltcp);
-
-	exch = async_exchange_begin(lst->tcp->sess);
-	errno_t rc = async_req_1_0(exch, TCP_LISTENER_DESTROY, lst->id);
-	async_exchange_end(exch);
-
-	free(lst);
-	(void) rc;
-}
-
-/** Get TCP connection listener based on its ID.
- *
- * @param tcp TCP client
- * @param id  Listener ID
- * @param rlst Place to store pointer to listener
- *
- * @return EOK on success, EINVAL if no listener with the given ID is found
- */
-static errno_t tcp_listener_get(tcp_t *tcp, sysarg_t id, tcp_listener_t **rlst)
-{
-	list_foreach(tcp->listener, ltcp, tcp_listener_t, lst) {
-		if (lst->id == id) {
-			*rlst = lst;
-			return EOK;
-		}
-	}
-
-	return EINVAL;
-}
-
-/** Get callback/user argument associated with listener.
- *
- * @param lst Listener
- * @return Callback/user argument
- */
-void *tcp_listener_userptr(tcp_listener_t *lst)
-{
-	return lst->lcb_arg;
-}
-
-/** Wait until connection is either established or connection fails.
- *
- * Can be called after calling tcp_conn_create() to block until connection
- * either completes or fails. If the connection fails, EIO is returned.
- * In this case the connection still exists, but is in a failed
- * state.
- *
- * @param conn Connection
- * @return EOK if connection is established, EIO otherwise
- */
-errno_t tcp_conn_wait_connected(tcp_conn_t *conn)
-{
-	fibril_mutex_lock(&conn->lock);
-	while (!conn->connected && !conn->conn_failed && !conn->conn_reset)
-		fibril_condvar_wait(&conn->cv, &conn->lock);
-
-	if (conn->connected) {
-		fibril_mutex_unlock(&conn->lock);
-		return EOK;
-	} else {
-		assert(conn->conn_failed || conn->conn_reset);
-		fibril_mutex_unlock(&conn->lock);
-		return EIO;
-	}
-}
-
-/** Send data over TCP connection.
- *
- * @param conn  Connection
- * @param data  Data
- * @param bytes Data size in bytes
- *
- * @return EOK on success or an error code
- */
-errno_t tcp_conn_send(tcp_conn_t *conn, const void *data, size_t bytes)
-{
-	async_exch_t *exch;
-	errno_t rc;
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	aid_t req = async_send_1(exch, TCP_CONN_SEND, conn->id, NULL);
-	rc = async_data_write_start(exch, data, bytes);
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	async_wait_for(req, &rc);
-	return rc;
-}
-
-/** Send FIN.
- *
- * Send FIN, indicating no more data will be send over the connection.
- *
- * @param conn Connection
- * @return EOK on success or an error code
- */
-errno_t tcp_conn_send_fin(tcp_conn_t *conn)
-{
-	async_exch_t *exch;
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	errno_t rc = async_req_1_0(exch, TCP_CONN_SEND_FIN, conn->id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-/** Push connection.
- *
- * @param conn Connection
- * @return EOK on success or an error code
- */
-errno_t tcp_conn_push(tcp_conn_t *conn)
-{
-	async_exch_t *exch;
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	errno_t rc = async_req_1_0(exch, TCP_CONN_PUSH, conn->id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-/** Reset connection.
- *
- * @param conn Connection
- * @return EOK on success or an error code
- */
-errno_t tcp_conn_reset(tcp_conn_t *conn)
-{
-	async_exch_t *exch;
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	errno_t rc = async_req_1_0(exch, TCP_CONN_RESET, conn->id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-/** Read received data from connection without blocking.
- *
- * If any received data is pending on the connection, up to @a bsize bytes
- * are copied to @a buf and the acutal number is stored in @a *nrecv.
- * The entire buffer of @a bsize bytes is filled except when less data
- * is currently available or FIN is received. EOK is returned.
- *
- * If no received data is pending, returns EAGAIN.
- *
- * @param conn Connection
- * @param buf  Buffer
- * @param bsize Buffer size
- * @param nrecv Place to store actual number of received bytes
- *
- * @return EOK on success, EAGAIN if no received data is pending, or other
- *         error code in case of other error
- */
-errno_t tcp_conn_recv(tcp_conn_t *conn, void *buf, size_t bsize, size_t *nrecv)
-{
-	async_exch_t *exch;
-	ipc_call_t answer;
-
-	fibril_mutex_lock(&conn->lock);
-	if (!conn->data_avail) {
-		fibril_mutex_unlock(&conn->lock);
-		return EAGAIN;
-	}
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	aid_t req = async_send_1(exch, TCP_CONN_RECV, conn->id, &answer);
-	errno_t rc = async_data_read_start(exch, buf, bsize);
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		fibril_mutex_unlock(&conn->lock);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-	if (retval != EOK) {
-		fibril_mutex_unlock(&conn->lock);
-		return retval;
-	}
-
-	*nrecv = ipc_get_arg1(&answer);
-	fibril_mutex_unlock(&conn->lock);
-	return EOK;
-}
-
-/** Read received data from connection with blocking.
- *
- * Wait for @a bsize bytes of data to be received and copy them to
- * @a buf. Less data may be returned if FIN is received on the connection.
- * The actual If any received data is written to @a *nrecv and EOK
- * is returned on success.
- *
- * @param conn Connection
- * @param buf  Buffer
- * @param bsize Buffer size
- * @param nrecv Place to store actual number of received bytes
- *
- * @return EOK on success or an error code
- */
-errno_t tcp_conn_recv_wait(tcp_conn_t *conn, void *buf, size_t bsize,
-    size_t *nrecv)
-{
-	async_exch_t *exch;
-	ipc_call_t answer;
-
-again:
-	fibril_mutex_lock(&conn->lock);
-	while (!conn->data_avail) {
-		fibril_condvar_wait(&conn->cv, &conn->lock);
-	}
-
-	exch = async_exchange_begin(conn->tcp->sess);
-	aid_t req = async_send_1(exch, TCP_CONN_RECV_WAIT, conn->id, &answer);
-	errno_t rc = async_data_read_start(exch, buf, bsize);
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		if (rc == EAGAIN) {
-			conn->data_avail = false;
-			fibril_mutex_unlock(&conn->lock);
-			goto again;
-		}
-		fibril_mutex_unlock(&conn->lock);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-	if (retval != EOK) {
-		if (rc == EAGAIN) {
-			conn->data_avail = false;
-		}
-		fibril_mutex_unlock(&conn->lock);
-		return retval;
-	}
-
-	*nrecv = ipc_get_arg1(&answer);
-	fibril_mutex_unlock(&conn->lock);
-	return EOK;
-}
-
-/** Connection established event.
- *
- * @param tcp   TCP client
- * @param icall Call data
- *
- */
-static void tcp_ev_connected(tcp_t *tcp, ipc_call_t *icall)
-{
-	tcp_conn_t *conn;
-	sysarg_t conn_id;
-	errno_t rc;
-
-	conn_id = ipc_get_arg1(icall);
-
-	rc = tcp_conn_get(tcp, conn_id, &conn);
-	if (rc != EOK) {
-		async_answer_0(icall, ENOENT);
-		return;
-	}
-
-	fibril_mutex_lock(&conn->lock);
-	conn->connected = true;
-	fibril_condvar_broadcast(&conn->cv);
-	fibril_mutex_unlock(&conn->lock);
-
-	async_answer_0(icall, EOK);
-}
-
-/** Connection failed event.
- *
- * @param tcp   TCP client
- * @param icall Call data
- *
- */
-static void tcp_ev_conn_failed(tcp_t *tcp, ipc_call_t *icall)
-{
-	tcp_conn_t *conn;
-	sysarg_t conn_id;
-	errno_t rc;
-
-	conn_id = ipc_get_arg1(icall);
-
-	rc = tcp_conn_get(tcp, conn_id, &conn);
-	if (rc != EOK) {
-		async_answer_0(icall, ENOENT);
-		return;
-	}
-
-	fibril_mutex_lock(&conn->lock);
-	conn->conn_failed = true;
-	fibril_condvar_broadcast(&conn->cv);
-	fibril_mutex_unlock(&conn->lock);
-
-	async_answer_0(icall, EOK);
-}
-
-/** Connection reset event.
- *
- * @param tcp   TCP client
- * @param icall Call data
- *
- */
-static void tcp_ev_conn_reset(tcp_t *tcp, ipc_call_t *icall)
-{
-	tcp_conn_t *conn;
-	sysarg_t conn_id;
-	errno_t rc;
-
-	conn_id = ipc_get_arg1(icall);
-
-	rc = tcp_conn_get(tcp, conn_id, &conn);
-	if (rc != EOK) {
-		async_answer_0(icall, ENOENT);
-		return;
-	}
-
-	fibril_mutex_lock(&conn->lock);
-	conn->conn_reset = true;
-	fibril_condvar_broadcast(&conn->cv);
-	fibril_mutex_unlock(&conn->lock);
-
-	async_answer_0(icall, EOK);
-}
-
-/** Data available event.
- *
- * @param tcp   TCP client
- * @param icall Call data
- *
- */
-static void tcp_ev_data(tcp_t *tcp, ipc_call_t *icall)
-{
-	tcp_conn_t *conn;
-	sysarg_t conn_id;
-	errno_t rc;
-
-	conn_id = ipc_get_arg1(icall);
-
-	rc = tcp_conn_get(tcp, conn_id, &conn);
-	if (rc != EOK) {
-		async_answer_0(icall, ENOENT);
-		return;
-	}
-
-	conn->data_avail = true;
-	fibril_condvar_broadcast(&conn->cv);
-
-	if (conn->cb != NULL && conn->cb->data_avail != NULL)
-		conn->cb->data_avail(conn);
-
-	async_answer_0(icall, EOK);
-}
-
-/** Urgent data event.
- *
- * @param tcp   TCP client
- * @param icall Call data
- *
- */
-static void tcp_ev_urg_data(tcp_t *tcp, ipc_call_t *icall)
-{
-	async_answer_0(icall, ENOTSUP);
-}
-
-/** New connection event.
- *
- * @param tcp   TCP client
- * @param icall Call data
- *
- */
-static void tcp_ev_new_conn(tcp_t *tcp, ipc_call_t *icall)
-{
-	tcp_listener_t *lst;
-	tcp_conn_t *conn;
-	sysarg_t lst_id;
-	sysarg_t conn_id;
-	fid_t fid;
-	tcp_in_conn_t *cinfo;
-	errno_t rc;
-
-	lst_id = ipc_get_arg1(icall);
-	conn_id = ipc_get_arg2(icall);
-
-	rc = tcp_listener_get(tcp, lst_id, &lst);
-	if (rc != EOK) {
-		async_answer_0(icall, ENOENT);
-		return;
-	}
-
-	rc = tcp_conn_new(tcp, conn_id, lst->cb, lst->cb_arg, &conn);
-	if (rc != EOK) {
-		async_answer_0(icall, ENOMEM);
-		return;
-	}
-
-	if (lst->lcb != NULL && lst->lcb->new_conn != NULL) {
-		cinfo = calloc(1, sizeof(tcp_in_conn_t));
-		if (cinfo == NULL) {
-			async_answer_0(icall, ENOMEM);
-			return;
-		}
-
-		cinfo->lst = lst;
-		cinfo->conn = conn;
-
-		fid = fibril_create(tcp_conn_fibril, cinfo);
-		if (fid == 0) {
-			async_answer_0(icall, ENOMEM);
-		}
-
-		fibril_add_ready(fid);
-	}
-
-	async_answer_0(icall, EOK);
-}
-
-/** Callback connection handler.
- *
- * @param icall Connect call data
- * @param arg   Argument, TCP client
- *
- */
-static void tcp_cb_conn(ipc_call_t *icall, void *arg)
-{
-	tcp_t *tcp = (tcp_t *)arg;
-
-	while (true) {
-		ipc_call_t call;
-		async_get_call(&call);
-
-		if (!ipc_get_imethod(&call)) {
-			/* Hangup */
-			async_answer_0(&call, EOK);
-			goto out;
-		}
-
-		switch (ipc_get_imethod(&call)) {
-		case TCP_EV_CONNECTED:
-			tcp_ev_connected(tcp, &call);
-			break;
-		case TCP_EV_CONN_FAILED:
-			tcp_ev_conn_failed(tcp, &call);
-			break;
-		case TCP_EV_CONN_RESET:
-			tcp_ev_conn_reset(tcp, &call);
-			break;
-		case TCP_EV_DATA:
-			tcp_ev_data(tcp, &call);
-			break;
-		case TCP_EV_URG_DATA:
-			tcp_ev_urg_data(tcp, &call);
-			break;
-		case TCP_EV_NEW_CONN:
-			tcp_ev_new_conn(tcp, &call);
-			break;
-		default:
-			async_answer_0(&call, ENOTSUP);
-			break;
-		}
-	}
-
-out:
-	fibril_mutex_lock(&tcp->lock);
-	tcp->cb_done = true;
-	fibril_mutex_unlock(&tcp->lock);
-	fibril_condvar_broadcast(&tcp->cv);
-}
-
-/** Fibril for handling incoming TCP connection in background.
- *
- * @param arg Argument, incoming connection information (@c tcp_in_conn_t)
- */
-static errno_t tcp_conn_fibril(void *arg)
-{
-	tcp_in_conn_t *cinfo = (tcp_in_conn_t *)arg;
-
-	cinfo->lst->lcb->new_conn(cinfo->lst, cinfo->conn);
-	tcp_conn_destroy(cinfo->conn);
-
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inet/udp.c
===================================================================
--- uspace/lib/c/generic/inet/udp.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,524 +1,0 @@
-/*
- * Copyright (c) 2015 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file UDP API
- */
-
-#include <errno.h>
-#include <inet/endpoint.h>
-#include <inet/udp.h>
-#include <ipc/services.h>
-#include <ipc/udp.h>
-#include <loc.h>
-#include <stdlib.h>
-
-static void udp_cb_conn(ipc_call_t *, void *);
-
-/** Create callback connection from UDP service.
- *
- * @param udp UDP service
- * @return EOK on success or an error code
- */
-static errno_t udp_callback_create(udp_t *udp)
-{
-	async_exch_t *exch = async_exchange_begin(udp->sess);
-
-	aid_t req = async_send_0(exch, UDP_CALLBACK_CREATE, NULL);
-
-	port_id_t port;
-	errno_t rc = async_create_callback_port(exch, INTERFACE_UDP_CB, 0, 0,
-	    udp_cb_conn, udp, &port);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK)
-		return rc;
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-/** Create UDP client instance.
- *
- * @param  rudp Place to store pointer to new UDP client
- * @return EOK on success, ENOMEM if out of memory, EIO if service
- *         cannot be contacted
- */
-errno_t udp_create(udp_t **rudp)
-{
-	udp_t *udp;
-	service_id_t udp_svcid;
-	errno_t rc;
-
-	udp = calloc(1, sizeof(udp_t));
-	if (udp == NULL) {
-		rc = ENOMEM;
-		goto error;
-	}
-
-	list_initialize(&udp->assoc);
-	fibril_mutex_initialize(&udp->lock);
-	fibril_condvar_initialize(&udp->cv);
-
-	rc = loc_service_get_id(SERVICE_NAME_UDP, &udp_svcid,
-	    IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		rc = EIO;
-		goto error;
-	}
-
-	udp->sess = loc_service_connect(udp_svcid, INTERFACE_UDP,
-	    IPC_FLAG_BLOCKING);
-	if (udp->sess == NULL) {
-		rc = EIO;
-		goto error;
-	}
-
-	rc = udp_callback_create(udp);
-	if (rc != EOK) {
-		rc = EIO;
-		goto error;
-	}
-
-	*rudp = udp;
-	return EOK;
-error:
-	free(udp);
-	return rc;
-}
-
-/** Destroy UDP client instance.
- *
- * @param udp UDP client
- */
-void udp_destroy(udp_t *udp)
-{
-	if (udp == NULL)
-		return;
-
-	async_hangup(udp->sess);
-
-	fibril_mutex_lock(&udp->lock);
-	while (!udp->cb_done)
-		fibril_condvar_wait(&udp->cv, &udp->lock);
-	fibril_mutex_unlock(&udp->lock);
-
-	free(udp);
-}
-
-/** Create new UDP association.
- *
- * Create a UDP association that allows sending and receiving messages.
- *
- * @a epp may specify remote address and port, in which case only messages
- * from that remote endpoint will be received. Also, that remote endpoint
- * is used as default when @c NULL is passed as destination to
- * udp_assoc_send_msg.
- *
- * @a epp may specify a local link or address. If it does not, the association
- * will listen on all local links/addresses. If @a epp does not specify
- * a local port number, a free dynamic port number will be allocated.
- *
- * The caller is informed about incoming data by invoking @a cb->recv_msg
- *
- * @param udp    UDP client
- * @param epp    Internet endpoint pair
- * @param cb     Callbacks
- * @param arg    Argument to callbacks
- * @param rassoc Place to store pointer to new association
- *
- * @return EOK on success or an error code.
- */
-errno_t udp_assoc_create(udp_t *udp, inet_ep2_t *epp, udp_cb_t *cb, void *arg,
-    udp_assoc_t **rassoc)
-{
-	async_exch_t *exch;
-	udp_assoc_t *assoc;
-	ipc_call_t answer;
-
-	assoc = calloc(1, sizeof(udp_assoc_t));
-	if (assoc == NULL)
-		return ENOMEM;
-
-	exch = async_exchange_begin(udp->sess);
-	aid_t req = async_send_0(exch, UDP_ASSOC_CREATE, &answer);
-	errno_t rc = async_data_write_start(exch, (void *)epp,
-	    sizeof(inet_ep2_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		errno_t rc_orig;
-		async_wait_for(req, &rc_orig);
-		if (rc_orig != EOK)
-			rc = rc_orig;
-		goto error;
-	}
-
-	async_wait_for(req, &rc);
-	if (rc != EOK)
-		goto error;
-
-	assoc->udp = udp;
-	assoc->id = ipc_get_arg1(&answer);
-	assoc->cb = cb;
-	assoc->cb_arg = arg;
-
-	list_append(&assoc->ludp, &udp->assoc);
-	*rassoc = assoc;
-
-	return EOK;
-error:
-	free(assoc);
-	return (errno_t) rc;
-}
-
-/** Destroy UDP association.
- *
- * Destroy UDP association. The caller should destroy all associations
- * he created before destroying the UDP client and before terminating.
- *
- * @param assoc UDP association
- */
-void udp_assoc_destroy(udp_assoc_t *assoc)
-{
-	async_exch_t *exch;
-
-	if (assoc == NULL)
-		return;
-
-	list_remove(&assoc->ludp);
-
-	exch = async_exchange_begin(assoc->udp->sess);
-	errno_t rc = async_req_1_0(exch, UDP_ASSOC_DESTROY, assoc->id);
-	async_exchange_end(exch);
-
-	free(assoc);
-	(void) rc;
-}
-
-/** Set UDP association sending messages with no local address
- *
- * @param assoc Association
- * @param flags Flags
- */
-errno_t udp_assoc_set_nolocal(udp_assoc_t *assoc)
-{
-	async_exch_t *exch;
-
-	exch = async_exchange_begin(assoc->udp->sess);
-	errno_t rc = async_req_1_0(exch, UDP_ASSOC_SET_NOLOCAL, assoc->id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-/** Send message via UDP association.
- *
- * @param assoc Association
- * @param dest	Destination endpoint or @c NULL to use association's remote ep.
- * @param data	Message data
- * @param bytes Message size in bytes
- *
- * @return EOK on success or an error code
- */
-errno_t udp_assoc_send_msg(udp_assoc_t *assoc, inet_ep_t *dest, void *data,
-    size_t bytes)
-{
-	async_exch_t *exch;
-
-	exch = async_exchange_begin(assoc->udp->sess);
-	aid_t req = async_send_1(exch, UDP_ASSOC_SEND_MSG, assoc->id, NULL);
-
-	errno_t rc = async_data_write_start(exch, (void *)dest,
-	    sizeof(inet_ep_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, data, bytes);
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	async_wait_for(req, &rc);
-	return rc;
-}
-
-/** Get the user/callback argument for an association.
- *
- * @param assoc UDP association
- * @return User argument associated with association
- */
-void *udp_assoc_userptr(udp_assoc_t *assoc)
-{
-	return assoc->cb_arg;
-}
-
-/** Get size of received message in bytes.
- *
- * Assuming jumbo messages can be received, the caller first needs to determine
- * the size of the received message by calling this function, then they can
- * read the message piece-wise using udp_rmsg_read().
- *
- * @param rmsg Received message
- * @return Size of received message in bytes
- */
-size_t udp_rmsg_size(udp_rmsg_t *rmsg)
-{
-	return rmsg->size;
-}
-
-/** Read part of received message.
- *
- * @param rmsg  Received message
- * @param off   Start offset
- * @param buf   Buffer for storing data
- * @param bsize Buffer size
- *
- * @return EOK on success or an error code.
- */
-errno_t udp_rmsg_read(udp_rmsg_t *rmsg, size_t off, void *buf, size_t bsize)
-{
-	async_exch_t *exch;
-	ipc_call_t answer;
-
-	exch = async_exchange_begin(rmsg->udp->sess);
-	aid_t req = async_send_1(exch, UDP_RMSG_READ, off, &answer);
-	errno_t rc = async_data_read_start(exch, buf, bsize);
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-	if (retval != EOK) {
-		return retval;
-	}
-
-	return EOK;
-}
-
-/** Get remote endpoint of received message.
- *
- * Place the remote endpoint (the one from which the message was supposedly
- * sent) to @a ep.
- *
- * @param rmsg Received message
- * @param ep   Place to store remote endpoint
- */
-void udp_rmsg_remote_ep(udp_rmsg_t *rmsg, inet_ep_t *ep)
-{
-	*ep = rmsg->remote_ep;
-}
-
-/** Get type of received ICMP error message.
- *
- * @param rerr Received error message
- * @return Error message type
- */
-uint8_t udp_rerr_type(udp_rerr_t *rerr)
-{
-	return 0;
-}
-
-/** Get code of received ICMP error message.
- *
- * @param rerr Received error message
- * @return Error message code
- */
-uint8_t udp_rerr_code(udp_rerr_t *rerr)
-{
-	return 0;
-}
-
-/** Get information about the next received message from UDP service.
- *
- * @param udp  UDP client
- * @param rmsg Place to store message information
- *
- * @return EOK on success or an error code
- */
-static errno_t udp_rmsg_info(udp_t *udp, udp_rmsg_t *rmsg)
-{
-	async_exch_t *exch;
-	inet_ep_t ep;
-	ipc_call_t answer;
-
-	exch = async_exchange_begin(udp->sess);
-	aid_t req = async_send_0(exch, UDP_RMSG_INFO, &answer);
-	errno_t rc = async_data_read_start(exch, &ep, sizeof(inet_ep_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-	if (retval != EOK)
-		return retval;
-
-	rmsg->udp = udp;
-	rmsg->assoc_id = ipc_get_arg1(&answer);
-	rmsg->size = ipc_get_arg2(&answer);
-	rmsg->remote_ep = ep;
-	return EOK;
-}
-
-/** Discard next received message in UDP service.
- *
- * @param udp UDP client
- * @return EOK on success or an error code
- */
-static errno_t udp_rmsg_discard(udp_t *udp)
-{
-	async_exch_t *exch;
-
-	exch = async_exchange_begin(udp->sess);
-	errno_t rc = async_req_0_0(exch, UDP_RMSG_DISCARD);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-/** Get association based on its ID.
- *
- * @param udp    UDP client
- * @param id     Association ID
- * @param rassoc Place to store pointer to association
- *
- * @return EOK on success, EINVAL if no association with the given ID exists
- */
-static errno_t udp_assoc_get(udp_t *udp, sysarg_t id, udp_assoc_t **rassoc)
-{
-	list_foreach(udp->assoc, ludp, udp_assoc_t, assoc) {
-		if (assoc->id == id) {
-			*rassoc = assoc;
-			return EOK;
-		}
-	}
-
-	return EINVAL;
-}
-
-/** Handle 'data' event, i.e. some message(s) arrived.
- *
- * For each received message, get information about it, call @c recv_msg
- * callback and discard it.
- *
- * @param udp   UDP client
- * @param icall IPC message
- *
- */
-static void udp_ev_data(udp_t *udp, ipc_call_t *icall)
-{
-	udp_rmsg_t rmsg;
-	udp_assoc_t *assoc;
-	errno_t rc;
-
-	while (true) {
-		rc = udp_rmsg_info(udp, &rmsg);
-		if (rc != EOK) {
-			break;
-		}
-
-		rc = udp_assoc_get(udp, rmsg.assoc_id, &assoc);
-		if (rc != EOK) {
-			continue;
-		}
-
-		if (assoc->cb != NULL && assoc->cb->recv_msg != NULL)
-			assoc->cb->recv_msg(assoc, &rmsg);
-
-		rc = udp_rmsg_discard(udp);
-		if (rc != EOK) {
-			break;
-		}
-	}
-
-	async_answer_0(icall, EOK);
-}
-
-/** UDP service callback connection.
- *
- * @param icall Connect message
- * @param arg   Argument, UDP client
- *
- */
-static void udp_cb_conn(ipc_call_t *icall, void *arg)
-{
-	udp_t *udp = (udp_t *)arg;
-
-	while (true) {
-		ipc_call_t call;
-		async_get_call(&call);
-
-		if (!ipc_get_imethod(&call)) {
-			/* Hangup */
-			async_answer_0(&call, EOK);
-			goto out;
-		}
-
-		switch (ipc_get_imethod(&call)) {
-		case UDP_EV_DATA:
-			udp_ev_data(udp, &call);
-			break;
-		default:
-			async_answer_0(&call, ENOTSUP);
-			break;
-		}
-	}
-
-out:
-	fibril_mutex_lock(&udp->lock);
-	udp->cb_done = true;
-	fibril_mutex_unlock(&udp->lock);
-	fibril_condvar_broadcast(&udp->cv);
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inetcfg.c
===================================================================
--- uspace/lib/c/generic/inetcfg.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,465 +1,0 @@
-/*
- * Copyright (c) 2012 Jiri Svoboda
- * 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.
- */
-
-#include <async.h>
-#include <assert.h>
-#include <errno.h>
-#include <inet/inetcfg.h>
-#include <ipc/inet.h>
-#include <ipc/services.h>
-#include <loc.h>
-#include <stdlib.h>
-#include <str.h>
-
-static async_sess_t *inetcfg_sess = NULL;
-
-static errno_t inetcfg_get_ids_once(sysarg_t method, sysarg_t arg1,
-    sysarg_t *id_buf, size_t buf_size, size_t *act_size)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, method, arg1, &answer);
-	errno_t rc = async_data_read_start(exch, id_buf, buf_size);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	if (retval != EOK) {
-		return retval;
-	}
-
-	*act_size = ipc_get_arg1(&answer);
-	return EOK;
-}
-
-/** Get list of IDs.
- *
- * Returns an allocated array of service IDs.
- *
- * @param method	IPC method
- * @param arg1		IPC argument 1
- * @param data		Place to store pointer to array of IDs
- * @param count		Place to store number of IDs
- * @return 		EOK on success or an error code
- */
-static errno_t inetcfg_get_ids_internal(sysarg_t method, sysarg_t arg1,
-    sysarg_t **data, size_t *count)
-{
-	*data = NULL;
-	*count = 0;
-
-	size_t act_size = 0;
-	errno_t rc = inetcfg_get_ids_once(method, arg1, NULL, 0,
-	    &act_size);
-	if (rc != EOK)
-		return rc;
-
-	size_t alloc_size = act_size;
-	service_id_t *ids = malloc(alloc_size);
-	if (ids == NULL)
-		return ENOMEM;
-
-	while (true) {
-		rc = inetcfg_get_ids_once(method, arg1, ids, alloc_size,
-		    &act_size);
-		if (rc != EOK)
-			return rc;
-
-		if (act_size <= alloc_size)
-			break;
-
-		alloc_size = act_size;
-		service_id_t *tmp = realloc(ids, alloc_size);
-		if (tmp == NULL) {
-			free(ids);
-			return ENOMEM;
-		}
-		ids = tmp;
-	}
-
-	*count = act_size / sizeof(sysarg_t);
-	*data = ids;
-	return EOK;
-}
-
-errno_t inetcfg_init(void)
-{
-	service_id_t inet_svc;
-	errno_t rc;
-
-	assert(inetcfg_sess == NULL);
-
-	rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc,
-	    IPC_FLAG_BLOCKING);
-	if (rc != EOK)
-		return ENOENT;
-
-	inetcfg_sess = loc_service_connect(inet_svc, INTERFACE_INETCFG,
-	    IPC_FLAG_BLOCKING);
-	if (inetcfg_sess == NULL)
-		return ENOENT;
-
-	return EOK;
-}
-
-errno_t inetcfg_addr_create_static(const char *name, inet_naddr_t *naddr,
-    sysarg_t link_id, sysarg_t *addr_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INETCFG_ADDR_CREATE_STATIC, link_id,
-	    &answer);
-
-	errno_t rc = async_data_write_start(exch, naddr, sizeof(inet_naddr_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, name, str_size(name));
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	*addr_id = ipc_get_arg1(&answer);
-
-	return retval;
-}
-
-errno_t inetcfg_addr_delete(sysarg_t addr_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	errno_t rc = async_req_1_0(exch, INETCFG_ADDR_DELETE, addr_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t inetcfg_addr_get(sysarg_t addr_id, inet_addr_info_t *ainfo)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INETCFG_ADDR_GET, addr_id, &answer);
-
-	ipc_call_t answer_naddr;
-	aid_t req_naddr = async_data_read(exch, &ainfo->naddr,
-	    sizeof(inet_naddr_t), &answer_naddr);
-
-	errno_t retval_naddr;
-	async_wait_for(req_naddr, &retval_naddr);
-
-	if (retval_naddr != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return retval_naddr;
-	}
-
-	ipc_call_t answer_name;
-	char name_buf[LOC_NAME_MAXLEN + 1];
-	aid_t req_name = async_data_read(exch, name_buf, LOC_NAME_MAXLEN,
-	    &answer_name);
-
-	async_exchange_end(exch);
-
-	errno_t retval_name;
-	async_wait_for(req_name, &retval_name);
-
-	if (retval_name != EOK) {
-		async_forget(req);
-		return retval_name;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	if (retval != EOK)
-		return retval;
-
-	size_t act_size = ipc_get_arg2(&answer_name);
-	assert(act_size <= LOC_NAME_MAXLEN);
-
-	name_buf[act_size] = '\0';
-
-	ainfo->ilink = ipc_get_arg1(&answer);
-	ainfo->name = str_dup(name_buf);
-
-	return EOK;
-}
-
-errno_t inetcfg_addr_get_id(const char *name, sysarg_t link_id, sysarg_t *addr_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INETCFG_ADDR_GET_ID, link_id, &answer);
-	errno_t retval = async_data_write_start(exch, name, str_size(name));
-
-	async_exchange_end(exch);
-
-	if (retval != EOK) {
-		async_forget(req);
-		return retval;
-	}
-
-	async_wait_for(req, &retval);
-	*addr_id = ipc_get_arg1(&answer);
-
-	return retval;
-}
-
-errno_t inetcfg_get_addr_list(sysarg_t **addrs, size_t *count)
-{
-	return inetcfg_get_ids_internal(INETCFG_GET_ADDR_LIST,
-	    0, addrs, count);
-}
-
-errno_t inetcfg_get_link_list(sysarg_t **links, size_t *count)
-{
-	return inetcfg_get_ids_internal(INETCFG_GET_LINK_LIST,
-	    0, links, count);
-}
-
-errno_t inetcfg_get_sroute_list(sysarg_t **sroutes, size_t *count)
-{
-	return inetcfg_get_ids_internal(INETCFG_GET_SROUTE_LIST,
-	    0, sroutes, count);
-}
-
-errno_t inetcfg_link_add(sysarg_t link_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	errno_t rc = async_req_1_0(exch, INETCFG_LINK_ADD, link_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t inetcfg_link_get(sysarg_t link_id, inet_link_info_t *linfo)
-{
-	ipc_call_t dreply;
-	errno_t dretval;
-	size_t act_size;
-	char name_buf[LOC_NAME_MAXLEN + 1];
-
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer);
-	aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply);
-	errno_t rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(addr48_t));
-	async_wait_for(dreq, &dretval);
-
-	async_exchange_end(exch);
-
-	if (dretval != EOK || rc != EOK) {
-		async_forget(req);
-		return dretval;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	if (retval != EOK)
-		return retval;
-
-	act_size = ipc_get_arg2(&dreply);
-	assert(act_size <= LOC_NAME_MAXLEN);
-	name_buf[act_size] = '\0';
-
-	linfo->name = str_dup(name_buf);
-	linfo->def_mtu = ipc_get_arg1(&answer);
-
-	return EOK;
-}
-
-errno_t inetcfg_link_remove(sysarg_t link_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	errno_t rc = async_req_1_0(exch, INETCFG_LINK_REMOVE, link_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t inetcfg_sroute_create(const char *name, inet_naddr_t *dest,
-    inet_addr_t *router, sysarg_t *sroute_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, INETCFG_SROUTE_CREATE, &answer);
-
-	errno_t rc = async_data_write_start(exch, dest, sizeof(inet_naddr_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, router, sizeof(inet_addr_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, name, str_size(name));
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	*sroute_id = ipc_get_arg1(&answer);
-
-	return retval;
-}
-
-errno_t inetcfg_sroute_delete(sysarg_t sroute_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	errno_t rc = async_req_1_0(exch, INETCFG_SROUTE_DELETE, sroute_id);
-	async_exchange_end(exch);
-
-	return rc;
-}
-
-errno_t inetcfg_sroute_get(sysarg_t sroute_id, inet_sroute_info_t *srinfo)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INETCFG_SROUTE_GET, sroute_id, &answer);
-
-	ipc_call_t answer_dest;
-	aid_t req_dest = async_data_read(exch, &srinfo->dest,
-	    sizeof(inet_naddr_t), &answer_dest);
-
-	errno_t retval_dest;
-	async_wait_for(req_dest, &retval_dest);
-
-	if (retval_dest != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return retval_dest;
-	}
-
-	ipc_call_t answer_router;
-	aid_t req_router = async_data_read(exch, &srinfo->router,
-	    sizeof(inet_addr_t), &answer_router);
-
-	errno_t retval_router;
-	async_wait_for(req_router, &retval_router);
-
-	if (retval_router != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return retval_router;
-	}
-
-	ipc_call_t answer_name;
-	char name_buf[LOC_NAME_MAXLEN + 1];
-	aid_t req_name = async_data_read(exch, name_buf, LOC_NAME_MAXLEN,
-	    &answer_name);
-
-	async_exchange_end(exch);
-
-	errno_t retval_name;
-	async_wait_for(req_name, &retval_name);
-
-	if (retval_name != EOK) {
-		async_forget(req);
-		return retval_name;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	if (retval != EOK)
-		return retval;
-
-	size_t act_size = ipc_get_arg2(&answer_name);
-	assert(act_size <= LOC_NAME_MAXLEN);
-
-	name_buf[act_size] = '\0';
-
-	srinfo->name = str_dup(name_buf);
-
-	return EOK;
-}
-
-errno_t inetcfg_sroute_get_id(const char *name, sysarg_t *sroute_id)
-{
-	async_exch_t *exch = async_exchange_begin(inetcfg_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, INETCFG_SROUTE_GET_ID, &answer);
-	errno_t retval = async_data_write_start(exch, name, str_size(name));
-
-	async_exchange_end(exch);
-
-	if (retval != EOK) {
-		async_forget(req);
-		return retval;
-	}
-
-	async_wait_for(req, &retval);
-	*sroute_id = ipc_get_arg1(&answer);
-
-	return retval;
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/inetping.c
===================================================================
--- uspace/lib/c/generic/inetping.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,231 +1,0 @@
-/*
- * Copyright (c) 2013 Jiri Svoboda
- * Copyright (c) 2013 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.
- */
-
-#include <async.h>
-#include <assert.h>
-#include <errno.h>
-#include <inet/inetping.h>
-#include <ipc/inet.h>
-#include <ipc/services.h>
-#include <loc.h>
-#include <stdlib.h>
-#include <str.h>
-
-static void inetping_cb_conn(ipc_call_t *, void *);
-static void inetping_ev_recv(ipc_call_t *);
-
-static async_sess_t *inetping_sess = NULL;
-static inetping_ev_ops_t *inetping_ev_ops;
-
-errno_t inetping_init(inetping_ev_ops_t *ev_ops)
-{
-	service_id_t inetping_svc;
-	errno_t rc;
-
-	assert(inetping_sess == NULL);
-
-	inetping_ev_ops = ev_ops;
-
-	rc = loc_service_get_id(SERVICE_NAME_INET, &inetping_svc,
-	    IPC_FLAG_BLOCKING);
-	if (rc != EOK)
-		return ENOENT;
-
-	inetping_sess = loc_service_connect(inetping_svc, INTERFACE_INETPING,
-	    IPC_FLAG_BLOCKING);
-	if (inetping_sess == NULL)
-		return ENOENT;
-
-	async_exch_t *exch = async_exchange_begin(inetping_sess);
-
-	port_id_t port;
-	rc = async_create_callback_port(exch, INTERFACE_INETPING_CB, 0, 0,
-	    inetping_cb_conn, NULL, &port);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_hangup(inetping_sess);
-		inetping_sess = NULL;
-		return rc;
-	}
-
-	return EOK;
-}
-
-errno_t inetping_send(inetping_sdu_t *sdu)
-{
-	async_exch_t *exch = async_exchange_begin(inetping_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, INETPING_SEND, sdu->seq_no, &answer);
-
-	errno_t rc = async_data_write_start(exch, &sdu->src, sizeof(sdu->src));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, &sdu->dest, sizeof(sdu->dest));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, sdu->data, sdu->size);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t inetping_get_srcaddr(const inet_addr_t *remote, inet_addr_t *local)
-{
-	async_exch_t *exch = async_exchange_begin(inetping_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, INETPING_GET_SRCADDR, &answer);
-
-	errno_t rc = async_data_write_start(exch, remote, sizeof(*remote));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	ipc_call_t answer_local;
-	aid_t req_local = async_data_read(exch, local, sizeof(*local),
-	    &answer_local);
-
-	async_exchange_end(exch);
-
-	errno_t retval_local;
-	async_wait_for(req_local, &retval_local);
-
-	if (retval_local != EOK) {
-		async_forget(req);
-		return retval_local;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-static void inetping_ev_recv(ipc_call_t *icall)
-{
-	inetping_sdu_t sdu;
-
-	sdu.seq_no = ipc_get_arg1(icall);
-
-	ipc_call_t call;
-	size_t size;
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-		return;
-	}
-
-	if (size != sizeof(sdu.src)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	errno_t rc = async_data_write_finalize(&call, &sdu.src, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-		return;
-	}
-
-	if (size != sizeof(sdu.dest)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	rc = async_data_write_finalize(&call, &sdu.dest, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = inetping_ev_ops->recv(&sdu);
-	free(sdu.data);
-	async_answer_0(icall, rc);
-}
-
-static void inetping_cb_conn(ipc_call_t *icall, void *arg)
-{
-	while (true) {
-		ipc_call_t call;
-		async_get_call(&call);
-
-		if (!ipc_get_imethod(&call)) {
-			async_answer_0(&call, EOK);
-			return;
-		}
-
-		switch (ipc_get_imethod(&call)) {
-		case INETPING_EV_RECV:
-			inetping_ev_recv(&call);
-			break;
-		default:
-			async_answer_0(&call, ENOTSUP);
-		}
-	}
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/iplink.c
===================================================================
--- uspace/lib/c/generic/iplink.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,308 +1,0 @@
-/*
- * Copyright (c) 2012 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/**
- * @file
- * @brief IP link client stub
- */
-
-#include <async.h>
-#include <assert.h>
-#include <errno.h>
-#include <inet/iplink.h>
-#include <inet/addr.h>
-#include <ipc/iplink.h>
-#include <ipc/services.h>
-#include <loc.h>
-#include <stdlib.h>
-
-static void iplink_cb_conn(ipc_call_t *icall, void *arg);
-
-errno_t iplink_open(async_sess_t *sess, iplink_ev_ops_t *ev_ops, void *arg,
-    iplink_t **riplink)
-{
-	iplink_t *iplink = calloc(1, sizeof(iplink_t));
-	if (iplink == NULL)
-		return ENOMEM;
-
-	iplink->sess = sess;
-	iplink->ev_ops = ev_ops;
-	iplink->arg = arg;
-
-	async_exch_t *exch = async_exchange_begin(sess);
-
-	port_id_t port;
-	errno_t rc = async_create_callback_port(exch, INTERFACE_IPLINK_CB, 0, 0,
-	    iplink_cb_conn, iplink, &port);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK)
-		goto error;
-
-	*riplink = iplink;
-	return EOK;
-
-error:
-	if (iplink != NULL)
-		free(iplink);
-
-	return rc;
-}
-
-void iplink_close(iplink_t *iplink)
-{
-	/* XXX Synchronize with iplink_cb_conn */
-	free(iplink);
-}
-
-errno_t iplink_send(iplink_t *iplink, iplink_sdu_t *sdu)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_2(exch, IPLINK_SEND, (sysarg_t) sdu->src,
-	    (sysarg_t) sdu->dest, &answer);
-
-	errno_t rc = async_data_write_start(exch, sdu->data, sdu->size);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t iplink_send6(iplink_t *iplink, iplink_sdu6_t *sdu)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, IPLINK_SEND6, &answer);
-
-	errno_t rc = async_data_write_start(exch, &sdu->dest, sizeof(addr48_t));
-	if (rc != EOK) {
-		async_exchange_end(exch);
-		async_forget(req);
-		return rc;
-	}
-
-	rc = async_data_write_start(exch, sdu->data, sdu->size);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t iplink_get_mtu(iplink_t *iplink, size_t *rmtu)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	sysarg_t mtu;
-	errno_t rc = async_req_0_1(exch, IPLINK_GET_MTU, &mtu);
-
-	async_exchange_end(exch);
-
-	if (rc != EOK)
-		return rc;
-
-	*rmtu = mtu;
-	return EOK;
-}
-
-errno_t iplink_get_mac48(iplink_t *iplink, addr48_t *mac)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
-
-	errno_t rc = async_data_read_start(exch, mac, sizeof(addr48_t));
-
-	loc_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t iplink_set_mac48(iplink_t *iplink, addr48_t mac)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer);
-
-	errno_t rc = async_data_read_start(exch, mac, sizeof(addr48_t));
-
-	loc_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t iplink_addr_add(iplink_t *iplink, inet_addr_t *addr)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, IPLINK_ADDR_ADD, &answer);
-
-	errno_t rc = async_data_write_start(exch, addr, sizeof(inet_addr_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-errno_t iplink_addr_remove(iplink_t *iplink, inet_addr_t *addr)
-{
-	async_exch_t *exch = async_exchange_begin(iplink->sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, IPLINK_ADDR_REMOVE, &answer);
-
-	errno_t rc = async_data_write_start(exch, addr, sizeof(inet_addr_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-
-	return retval;
-}
-
-void *iplink_get_userptr(iplink_t *iplink)
-{
-	return iplink->arg;
-}
-
-static void iplink_ev_recv(iplink_t *iplink, ipc_call_t *icall)
-{
-	iplink_recv_sdu_t sdu;
-
-	ip_ver_t ver = ipc_get_arg1(icall);
-
-	errno_t rc = async_data_write_accept(&sdu.data, false, 0, 0, 0,
-	    &sdu.size);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = iplink->ev_ops->recv(iplink, &sdu, ver);
-	free(sdu.data);
-	async_answer_0(icall, rc);
-}
-
-static void iplink_ev_change_addr(iplink_t *iplink, ipc_call_t *icall)
-{
-	addr48_t *addr;
-	size_t size;
-
-	errno_t rc = async_data_write_accept((void **) &addr, false,
-	    sizeof(addr48_t), sizeof(addr48_t), 0, &size);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = iplink->ev_ops->change_addr(iplink, *addr);
-	free(addr);
-	async_answer_0(icall, EOK);
-}
-
-static void iplink_cb_conn(ipc_call_t *icall, void *arg)
-{
-	iplink_t *iplink = (iplink_t *) arg;
-
-	while (true) {
-		ipc_call_t call;
-		async_get_call(&call);
-
-		if (!ipc_get_imethod(&call)) {
-			async_answer_0(&call, EOK);
-			return;
-		}
-
-		switch (ipc_get_imethod(&call)) {
-		case IPLINK_EV_RECV:
-			iplink_ev_recv(iplink, &call);
-			break;
-		case IPLINK_EV_CHANGE_ADDR:
-			iplink_ev_change_addr(iplink, &call);
-			break;
-		default:
-			async_answer_0(&call, ENOTSUP);
-		}
-	}
-}
-
-/** @}
- */
Index: uspace/lib/c/generic/iplink_srv.c
===================================================================
--- uspace/lib/c/generic/iplink_srv.c	(revision 36795edf59b53d3f30384d83e6a8042eec3ea891)
+++ 	(revision )
@@ -1,351 +1,0 @@
-/*
- * Copyright (c) 2012 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/**
- * @file
- * @brief IP link server stub
- */
-
-#include <errno.h>
-#include <ipc/iplink.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <inet/addr.h>
-#include <inet/iplink_srv.h>
-
-static void iplink_get_mtu_srv(iplink_srv_t *srv, ipc_call_t *call)
-{
-	size_t mtu;
-	errno_t rc = srv->ops->get_mtu(srv, &mtu);
-	async_answer_1(call, rc, mtu);
-}
-
-static void iplink_get_mac48_srv(iplink_srv_t *srv, ipc_call_t *icall)
-{
-	addr48_t mac;
-	errno_t rc = srv->ops->get_mac48(srv, &mac);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	ipc_call_t call;
-	size_t size;
-	if (!async_data_read_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-		return;
-	}
-
-	if (size != sizeof(addr48_t)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	rc = async_data_read_finalize(&call, &mac, size);
-	if (rc != EOK)
-		async_answer_0(&call, rc);
-
-	async_answer_0(icall, rc);
-}
-
-static void iplink_set_mac48_srv(iplink_srv_t *srv, ipc_call_t *icall)
-{
-	errno_t rc;
-	size_t size;
-	addr48_t mac;
-
-	ipc_call_t call;
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-	}
-
-	rc = srv->ops->set_mac48(srv, &mac);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = async_data_read_finalize(&call, &mac, sizeof(addr48_t));
-	if (rc != EOK)
-		async_answer_0(&call, rc);
-
-	async_answer_0(icall, rc);
-}
-
-static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_call_t *icall)
-{
-	ipc_call_t call;
-	size_t size;
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-		return;
-	}
-
-	if (size != sizeof(inet_addr_t)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	inet_addr_t addr;
-	errno_t rc = async_data_write_finalize(&call, &addr, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-	}
-
-	rc = srv->ops->addr_add(srv, &addr);
-	async_answer_0(icall, rc);
-}
-
-static void iplink_addr_remove_srv(iplink_srv_t *srv, ipc_call_t *icall)
-{
-	ipc_call_t call;
-	size_t size;
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-		return;
-	}
-
-	if (size != sizeof(inet_addr_t)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	inet_addr_t addr;
-	errno_t rc = async_data_write_finalize(&call, &addr, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-	}
-
-	rc = srv->ops->addr_remove(srv, &addr);
-	async_answer_0(icall, rc);
-}
-
-static void iplink_send_srv(iplink_srv_t *srv, ipc_call_t *icall)
-{
-	iplink_sdu_t sdu;
-
-	sdu.src = ipc_get_arg1(icall);
-	sdu.dest = ipc_get_arg2(icall);
-
-	errno_t rc = async_data_write_accept(&sdu.data, false, 0, 0, 0,
-	    &sdu.size);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = srv->ops->send(srv, &sdu);
-	free(sdu.data);
-	async_answer_0(icall, rc);
-}
-
-static void iplink_send6_srv(iplink_srv_t *srv, ipc_call_t *icall)
-{
-	iplink_sdu6_t sdu;
-
-	ipc_call_t call;
-	size_t size;
-	if (!async_data_write_receive(&call, &size)) {
-		async_answer_0(&call, EREFUSED);
-		async_answer_0(icall, EREFUSED);
-		return;
-	}
-
-	if (size != sizeof(addr48_t)) {
-		async_answer_0(&call, EINVAL);
-		async_answer_0(icall, EINVAL);
-		return;
-	}
-
-	errno_t rc = async_data_write_finalize(&call, &sdu.dest, size);
-	if (rc != EOK) {
-		async_answer_0(&call, rc);
-		async_answer_0(icall, rc);
-	}
-
-	rc = async_data_write_accept(&sdu.data, false, 0, 0, 0,
-	    &sdu.size);
-	if (rc != EOK) {
-		async_answer_0(icall, rc);
-		return;
-	}
-
-	rc = srv->ops->send6(srv, &sdu);
-	free(sdu.data);
-	async_answer_0(icall, rc);
-}
-
-void iplink_srv_init(iplink_srv_t *srv)
-{
-	fibril_mutex_initialize(&srv->lock);
-	srv->connected = false;
-	srv->ops = NULL;
-	srv->arg = NULL;
-	srv->client_sess = NULL;
-}
-
-errno_t iplink_conn(ipc_call_t *icall, void *arg)
-{
-	iplink_srv_t *srv = (iplink_srv_t *) arg;
-	errno_t rc;
-
-	fibril_mutex_lock(&srv->lock);
-	if (srv->connected) {
-		fibril_mutex_unlock(&srv->lock);
-		async_answer_0(icall, EBUSY);
-		return EBUSY;
-	}
-
-	srv->connected = true;
-	fibril_mutex_unlock(&srv->lock);
-
-	/* Accept the connection */
-	async_accept_0(icall);
-
-	async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
-	if (sess == NULL)
-		return ENOMEM;
-
-	srv->client_sess = sess;
-
-	rc = srv->ops->open(srv);
-	if (rc != EOK)
-		return rc;
-
-	while (true) {
-		ipc_call_t call;
-		async_get_call(&call);
-		sysarg_t method = ipc_get_imethod(&call);
-
-		if (!method) {
-			/* The other side has hung up */
-			fibril_mutex_lock(&srv->lock);
-			srv->connected = false;
-			fibril_mutex_unlock(&srv->lock);
-			async_answer_0(&call, EOK);
-			break;
-		}
-
-		switch (method) {
-		case IPLINK_GET_MTU:
-			iplink_get_mtu_srv(srv, &call);
-			break;
-		case IPLINK_GET_MAC48:
-			iplink_get_mac48_srv(srv, &call);
-			break;
-		case IPLINK_SET_MAC48:
-			iplink_set_mac48_srv(srv, &call);
-			break;
-		case IPLINK_SEND:
-			iplink_send_srv(srv, &call);
-			break;
-		case IPLINK_SEND6:
-			iplink_send6_srv(srv, &call);
-			break;
-		case IPLINK_ADDR_ADD:
-			iplink_addr_add_srv(srv, &call);
-			break;
-		case IPLINK_ADDR_REMOVE:
-			iplink_addr_remove_srv(srv, &call);
-			break;
-		default:
-			async_answer_0(&call, EINVAL);
-		}
-	}
-
-	return srv->ops->close(srv);
-}
-
-/* XXX Version should be part of @a sdu */
-errno_t iplink_ev_recv(iplink_srv_t *srv, iplink_recv_sdu_t *sdu, ip_ver_t ver)
-{
-	if (srv->client_sess == NULL)
-		return EIO;
-
-	async_exch_t *exch = async_exchange_begin(srv->client_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_1(exch, IPLINK_EV_RECV, (sysarg_t)ver,
-	    &answer);
-
-	errno_t rc = async_data_write_start(exch, sdu->data, sdu->size);
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-	if (retval != EOK)
-		return retval;
-
-	return EOK;
-}
-
-errno_t iplink_ev_change_addr(iplink_srv_t *srv, addr48_t *addr)
-{
-	if (srv->client_sess == NULL)
-		return EIO;
-
-	async_exch_t *exch = async_exchange_begin(srv->client_sess);
-
-	ipc_call_t answer;
-	aid_t req = async_send_0(exch, IPLINK_EV_CHANGE_ADDR, &answer);
-
-	errno_t rc = async_data_write_start(exch, addr, sizeof(addr48_t));
-	async_exchange_end(exch);
-
-	if (rc != EOK) {
-		async_forget(req);
-		return rc;
-	}
-
-	errno_t retval;
-	async_wait_for(req, &retval);
-	if (retval != EOK)
-		return retval;
-
-	return EOK;
-}
-
-/** @}
- */
