Index: uspace/app/dnscfg/meson.build
===================================================================
--- uspace/app/dnscfg/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/dnscfg/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2013 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('dnscfg.c')
Index: uspace/app/dnsres/meson.build
===================================================================
--- uspace/app/dnsres/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/dnsres/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2013 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('dnsres.c')
Index: uspace/app/inet/meson.build
===================================================================
--- uspace/app/inet/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/inet/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2012 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('inet.c')
Index: uspace/app/netecho/meson.build
===================================================================
--- uspace/app/netecho/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/netecho/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2016 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('comm.c', 'netecho.c')
Index: uspace/app/nterm/meson.build
===================================================================
--- uspace/app/nterm/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/nterm/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2012 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('conn.c', 'nterm.c')
Index: uspace/app/ping/meson.build
===================================================================
--- uspace/app/ping/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/ping/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2012 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('ping.c')
Index: uspace/app/websrv/meson.build
===================================================================
--- uspace/app/websrv/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/app/websrv/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2010 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('websrv.c')
Index: pace/lib/c/generic/dhcp.c
===================================================================
--- uspace/lib/c/generic/dhcp.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/dnsr.c
===================================================================
--- uspace/lib/c/generic/dnsr.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet.c
===================================================================
--- uspace/lib/c/generic/inet.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/addr.c
===================================================================
--- uspace/lib/c/generic/inet/addr.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/endpoint.c
===================================================================
--- uspace/lib/c/generic/inet/endpoint.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/host.c
===================================================================
--- uspace/lib/c/generic/inet/host.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/hostname.c
===================================================================
--- uspace/lib/c/generic/inet/hostname.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/hostport.c
===================================================================
--- uspace/lib/c/generic/inet/hostport.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/tcp.c
===================================================================
--- uspace/lib/c/generic/inet/tcp.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inet/udp.c
===================================================================
--- uspace/lib/c/generic/inet/udp.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inetcfg.c
===================================================================
--- uspace/lib/c/generic/inetcfg.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/inetping.c
===================================================================
--- uspace/lib/c/generic/inetping.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/iplink.c
===================================================================
--- uspace/lib/c/generic/iplink.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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: pace/lib/c/generic/iplink_srv.c
===================================================================
--- uspace/lib/c/generic/iplink_srv.c	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(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;
-}
-
-/** @}
- */
Index: pace/lib/c/include/inet/addr.h
===================================================================
--- uspace/lib/c/include/inet/addr.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,133 +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
- */
-
-#ifndef _LIBC_INET_ADDR_H_
-#define _LIBC_INET_ADDR_H_
-
-#include <errno.h>
-#include <stdint.h>
-
-typedef uint32_t addr32_t;
-typedef uint8_t addr48_t[6];
-typedef uint8_t addr128_t[16];
-
-typedef enum {
-	/** Any IP protocol version */
-	ip_any,
-	/** IPv4 */
-	ip_v4,
-	/** IPv6 */
-	ip_v6
-} ip_ver_t;
-
-/** Node address */
-typedef struct {
-	/** IP version */
-	ip_ver_t version;
-	union {
-		addr32_t addr;
-		addr128_t addr6;
-	};
-} inet_addr_t;
-
-/** Network address */
-typedef struct {
-	/** IP version */
-	ip_ver_t version;
-
-	/** Address */
-	union {
-		addr32_t addr;
-		addr128_t addr6;
-	};
-
-	/** Number of valid bits */
-	uint8_t prefix;
-} inet_naddr_t;
-
-extern const addr32_t addr32_broadcast_all_hosts;
-extern const addr48_t addr48_broadcast;
-
-extern void addr48(const addr48_t, addr48_t);
-extern void addr128(const addr128_t, addr128_t);
-
-extern int addr48_compare(const addr48_t, const addr48_t);
-extern int addr128_compare(const addr128_t, const addr128_t);
-
-extern void addr48_solicited_node(const addr128_t, addr48_t);
-
-extern void host2addr128_t_be(const addr128_t, addr128_t);
-extern void addr128_t_be2host(const addr128_t, addr128_t);
-
-extern void inet_addr(inet_addr_t *, uint8_t, uint8_t, uint8_t, uint8_t);
-extern void inet_naddr(inet_naddr_t *, uint8_t, uint8_t, uint8_t, uint8_t,
-    uint8_t);
-
-extern void inet_addr6(inet_addr_t *, uint16_t, uint16_t, uint16_t, uint16_t,
-    uint16_t, uint16_t, uint16_t, uint16_t);
-extern void inet_naddr6(inet_naddr_t *, uint16_t, uint16_t, uint16_t, uint16_t,
-    uint16_t, uint16_t, uint16_t, uint16_t, uint8_t);
-
-extern void inet_naddr_addr(const inet_naddr_t *, inet_addr_t *);
-extern void inet_addr_naddr(const inet_addr_t *, uint8_t, inet_naddr_t *);
-
-extern void inet_addr_any(inet_addr_t *);
-extern void inet_naddr_any(inet_naddr_t *);
-
-extern int inet_addr_compare(const inet_addr_t *, const inet_addr_t *);
-extern int inet_addr_is_any(const inet_addr_t *);
-
-extern int inet_naddr_compare(const inet_naddr_t *, const inet_addr_t *);
-extern int inet_naddr_compare_mask(const inet_naddr_t *, const inet_addr_t *);
-
-extern errno_t inet_addr_parse(const char *, inet_addr_t *, char **);
-extern errno_t inet_naddr_parse(const char *, inet_naddr_t *, char **);
-
-extern errno_t inet_addr_format(const inet_addr_t *, char **);
-extern errno_t inet_naddr_format(const inet_naddr_t *, char **);
-
-extern ip_ver_t inet_addr_get(const inet_addr_t *, addr32_t *, addr128_t *);
-extern ip_ver_t inet_naddr_get(const inet_naddr_t *, addr32_t *, addr128_t *,
-    uint8_t *);
-
-extern void inet_addr_set(addr32_t, inet_addr_t *);
-extern void inet_naddr_set(addr32_t, uint8_t, inet_naddr_t *);
-
-extern void inet_addr_set6(addr128_t, inet_addr_t *);
-extern void inet_naddr_set6(addr128_t, uint8_t, inet_naddr_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/dhcp.h
===================================================================
--- uspace/lib/c/include/inet/dhcp.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,48 +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
- */
-
-#ifndef _LIBC_INET_DHCP_H_
-#define _LIBC_INET_DHCP_H_
-
-#include <types/common.h>
-
-extern errno_t dhcp_init(void);
-extern errno_t dhcp_link_add(sysarg_t);
-extern errno_t dhcp_link_remove(sysarg_t);
-extern errno_t dhcp_discover(sysarg_t);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/dnsr.h
===================================================================
--- uspace/lib/c/include/inet/dnsr.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,61 +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
- */
-
-#ifndef _LIBC_INET_DNSR_H_
-#define _LIBC_INET_DNSR_H_
-
-#include <inet/inet.h>
-#include <inet/addr.h>
-
-enum {
-	DNSR_NAME_MAX_SIZE = 255
-};
-
-typedef struct {
-	/** Host canonical name */
-	char *cname;
-	/** Host address */
-	inet_addr_t addr;
-} dnsr_hostinfo_t;
-
-extern errno_t dnsr_init(void);
-extern errno_t dnsr_name2host(const char *, dnsr_hostinfo_t **, ip_ver_t);
-extern void dnsr_hostinfo_destroy(dnsr_hostinfo_t *);
-extern errno_t dnsr_get_srvaddr(inet_addr_t *);
-extern errno_t dnsr_set_srvaddr(inet_addr_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/endpoint.h
===================================================================
--- uspace/lib/c/include/inet/endpoint.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,86 +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
- */
-
-#ifndef _LIBC_INET_ENDPOINT_H_
-#define _LIBC_INET_ENDPOINT_H_
-
-#include <stdint.h>
-#include <inet/addr.h>
-#include <loc.h>
-
-/** Internet port number ranges
- *
- * Port number ranges per RFC 6335 section 6 (Port Number Ranges.
- * Technically port zero is a system port. But since it is reserved,
- * we will use it as a special value denoting no port is specified
- * and we will exclude it from the system port range to disallow
- * ever assigning it.
- */
-enum inet_port_ranges {
-	/** Special value meaning no specific port */
-	inet_port_any = 0,
-	/** Lowest system port (a.k.a. well known port) */
-	inet_port_sys_lo = 1,
-	/** Highest system port (a.k.a. well known port) */
-	inet_port_sys_hi = 1023,
-	/** Lowest user port (a.k.a. registered port) */
-	inet_port_user_lo = 1024,
-	/** Highest user port (a.k.a. registered port) */
-	inet_port_user_hi = 49151,
-	/** Lowest dynamic port (a.k.a. private or ephemeral port) */
-	inet_port_dyn_lo = 49152,
-	/** Highest dynamic port (a.k.a. private or ephemeral port) */
-	inet_port_dyn_hi = 65535
-};
-
-/** Internet endpoint (address-port pair), a.k.a. socket */
-typedef struct {
-	inet_addr_t addr;
-	uint16_t port;
-} inet_ep_t;
-
-/** Internet endpoint pair */
-typedef struct {
-	service_id_t local_link;
-	inet_ep_t local;
-	inet_ep_t remote;
-} inet_ep2_t;
-
-extern void inet_ep_init(inet_ep_t *);
-extern void inet_ep2_init(inet_ep2_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/host.h
===================================================================
--- uspace/lib/c/include/inet/host.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,52 +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
- */
-
-#ifndef _LIBC_INET_HOST_H_
-#define _LIBC_INET_HOST_H_
-
-#include <inet/addr.h>
-#include <inet/endpoint.h>
-#include <types/inet/hostport.h>
-
-extern errno_t inet_host_parse(const char *, inet_host_t **, char **);
-extern errno_t inet_host_format(inet_host_t *, char **);
-extern void inet_host_destroy(inet_host_t *);
-extern errno_t inet_host_lookup_one(inet_host_t *, ip_ver_t, inet_addr_t *);
-extern errno_t inet_host_plookup_one(const char *, ip_ver_t, inet_addr_t *,
-    char **, const char **);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/hostname.h
===================================================================
--- uspace/lib/c/include/inet/hostname.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,43 +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
- */
-
-#ifndef _LIBC_INET_HOSTNAME_H_
-#define _LIBC_INET_HOSTNAME_H_
-
-extern errno_t inet_hostname_parse(const char *, char **, char **);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/hostport.h
===================================================================
--- uspace/lib/c/include/inet/hostport.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,52 +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
- */
-
-#ifndef _LIBC_INET_HOSTPORT_H_
-#define _LIBC_INET_HOSTPORT_H_
-
-#include <inet/addr.h>
-#include <inet/endpoint.h>
-#include <types/inet/hostport.h>
-
-extern errno_t inet_hostport_parse(const char *, inet_hostport_t **, char **);
-extern errno_t inet_hostport_format(inet_hostport_t *, char **);
-extern void inet_hostport_destroy(inet_hostport_t *);
-extern errno_t inet_hostport_lookup_one(inet_hostport_t *, ip_ver_t, inet_ep_t *);
-extern errno_t inet_hostport_plookup_one(const char *, ip_ver_t, inet_ep_t *,
-    char **, const char **);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/inet.h
===================================================================
--- uspace/lib/c/include/inet/inet.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,50 +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
- */
-
-#ifndef _LIBC_INET_INET_H_
-#define _LIBC_INET_INET_H_
-
-#include <inet/addr.h>
-#include <ipc/loc.h>
-#include <stdint.h>
-#include <types/inet.h>
-
-extern errno_t inet_init(uint8_t, inet_ev_ops_t *);
-extern errno_t inet_send(inet_dgram_t *, uint8_t, inet_df_t);
-extern errno_t inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/inetcfg.h
===================================================================
--- uspace/lib/c/include/inet/inetcfg.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,62 +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
- */
-
-#ifndef _LIBC_INET_INETCFG_H_
-#define _LIBC_INET_INETCFG_H_
-
-#include <inet/inet.h>
-#include <stddef.h>
-#include <types/inetcfg.h>
-
-extern errno_t inetcfg_init(void);
-extern errno_t inetcfg_addr_create_static(const char *, inet_naddr_t *, sysarg_t, sysarg_t *);
-extern errno_t inetcfg_addr_delete(sysarg_t);
-extern errno_t inetcfg_addr_get(sysarg_t, inet_addr_info_t *);
-extern errno_t inetcfg_addr_get_id(const char *, sysarg_t, sysarg_t *);
-extern errno_t inetcfg_get_addr_list(sysarg_t **, size_t *);
-extern errno_t inetcfg_get_link_list(sysarg_t **, size_t *);
-extern errno_t inetcfg_get_sroute_list(sysarg_t **, size_t *);
-extern errno_t inetcfg_link_add(sysarg_t);
-extern errno_t inetcfg_link_get(sysarg_t, inet_link_info_t *);
-extern errno_t inetcfg_link_remove(sysarg_t);
-extern errno_t inetcfg_sroute_get(sysarg_t, inet_sroute_info_t *);
-extern errno_t inetcfg_sroute_get_id(const char *, sysarg_t *);
-extern errno_t inetcfg_sroute_create(const char *, inet_naddr_t *, inet_addr_t *,
-    sysarg_t *);
-extern errno_t inetcfg_sroute_delete(sysarg_t);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/inetping.h
===================================================================
--- uspace/lib/c/include/inet/inetping.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,52 +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
- */
-
-#ifndef _LIBC_INET_INETPING_H_
-#define _LIBC_INET_INETPING_H_
-
-#include <inet/inet.h>
-#include <types/inetping.h>
-
-typedef struct inetping_ev_ops {
-	errno_t (*recv)(inetping_sdu_t *);
-} inetping_ev_ops_t;
-
-extern errno_t inetping_init(inetping_ev_ops_t *);
-extern errno_t inetping_send(inetping_sdu_t *);
-extern errno_t inetping_get_srcaddr(const inet_addr_t *, inet_addr_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/iplink.h
===================================================================
--- uspace/lib/c/include/inet/iplink.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,98 +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
- */
-
-#ifndef _LIBC_INET_IPLINK_H_
-#define _LIBC_INET_IPLINK_H_
-
-#include <async.h>
-#include <inet/addr.h>
-
-struct iplink_ev_ops;
-
-typedef struct {
-	async_sess_t *sess;
-	struct iplink_ev_ops *ev_ops;
-	void *arg;
-} iplink_t;
-
-/** IPv4 link Service Data Unit */
-typedef struct {
-	/** Local source address */
-	addr32_t src;
-	/** Local destination address */
-	addr32_t dest;
-	/** Serialized IP packet */
-	void *data;
-	/** Size of @c data in bytes */
-	size_t size;
-} iplink_sdu_t;
-
-/** IPv6 link Service Data Unit */
-typedef struct {
-	/** Local MAC destination address */
-	addr48_t dest;
-	/** Serialized IP packet */
-	void *data;
-	/** Size of @c data in bytes */
-	size_t size;
-} iplink_sdu6_t;
-
-/** Internet link receive Service Data Unit */
-typedef struct {
-	/** Serialized datagram */
-	void *data;
-	/** Size of @c data in bytes */
-	size_t size;
-} iplink_recv_sdu_t;
-
-typedef struct iplink_ev_ops {
-	errno_t (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
-	errno_t (*change_addr)(iplink_t *, addr48_t);
-} iplink_ev_ops_t;
-
-extern errno_t iplink_open(async_sess_t *, iplink_ev_ops_t *, void *, iplink_t **);
-extern void iplink_close(iplink_t *);
-extern errno_t iplink_send(iplink_t *, iplink_sdu_t *);
-extern errno_t iplink_send6(iplink_t *, iplink_sdu6_t *);
-extern errno_t iplink_addr_add(iplink_t *, inet_addr_t *);
-extern errno_t iplink_addr_remove(iplink_t *, inet_addr_t *);
-extern errno_t iplink_get_mtu(iplink_t *, size_t *);
-extern errno_t iplink_get_mac48(iplink_t *, addr48_t *);
-extern errno_t iplink_set_mac48(iplink_t *, addr48_t);
-extern void *iplink_get_userptr(iplink_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/iplink_srv.h
===================================================================
--- uspace/lib/c/include/inet/iplink_srv.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,75 +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
- */
-
-#ifndef _LIBC_INET_IPLINK_SRV_H_
-#define _LIBC_INET_IPLINK_SRV_H_
-
-#include <async.h>
-#include <fibril_synch.h>
-#include <stdbool.h>
-#include <inet/addr.h>
-#include <inet/iplink.h>
-
-struct iplink_ops;
-
-typedef struct {
-	fibril_mutex_t lock;
-	bool connected;
-	struct iplink_ops *ops;
-	void *arg;
-	async_sess_t *client_sess;
-} iplink_srv_t;
-
-typedef struct iplink_ops {
-	errno_t (*open)(iplink_srv_t *);
-	errno_t (*close)(iplink_srv_t *);
-	errno_t (*send)(iplink_srv_t *, iplink_sdu_t *);
-	errno_t (*send6)(iplink_srv_t *, iplink_sdu6_t *);
-	errno_t (*get_mtu)(iplink_srv_t *, size_t *);
-	errno_t (*get_mac48)(iplink_srv_t *, addr48_t *);
-	errno_t (*set_mac48)(iplink_srv_t *, addr48_t *);
-	errno_t (*addr_add)(iplink_srv_t *, inet_addr_t *);
-	errno_t (*addr_remove)(iplink_srv_t *, inet_addr_t *);
-} iplink_ops_t;
-
-extern void iplink_srv_init(iplink_srv_t *);
-
-extern errno_t iplink_conn(ipc_call_t *, void *);
-extern errno_t iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t);
-extern errno_t iplink_ev_change_addr(iplink_srv_t *, addr48_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/tcp.h
===================================================================
--- uspace/lib/c/include/inet/tcp.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,123 +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
- */
-
-#ifndef _LIBC_INET_TCP_H_
-#define _LIBC_INET_TCP_H_
-
-#include <fibril_synch.h>
-#include <inet/addr.h>
-#include <inet/endpoint.h>
-#include <inet/inet.h>
-
-/** TCP connection */
-typedef struct {
-	fibril_mutex_t lock;
-	fibril_condvar_t cv;
-	struct tcp *tcp;
-	link_t ltcp;
-	sysarg_t id;
-	struct tcp_cb *cb;
-	void *cb_arg;
-	/** Some received data available in TCP server */
-	bool data_avail;
-	bool connected;
-	bool conn_failed;
-	bool conn_reset;
-} tcp_conn_t;
-
-/** TCP connection listener */
-typedef struct {
-	struct tcp *tcp;
-	link_t ltcp;
-	sysarg_t id;
-	struct tcp_listen_cb *lcb;
-	void *lcb_arg;
-	struct tcp_cb *cb;
-	void *cb_arg;
-} tcp_listener_t;
-
-/** TCP connection callbacks */
-typedef struct tcp_cb {
-	void (*connected)(tcp_conn_t *);
-	void (*conn_failed)(tcp_conn_t *);
-	void (*conn_reset)(tcp_conn_t *);
-	void (*data_avail)(tcp_conn_t *);
-	void (*urg_data)(tcp_conn_t *);
-} tcp_cb_t;
-
-/** TCP listener callbacks */
-typedef struct tcp_listen_cb {
-	void (*new_conn)(tcp_listener_t *, tcp_conn_t *);
-} tcp_listen_cb_t;
-
-/** TCP service */
-typedef struct tcp {
-	/** TCP session */
-	async_sess_t *sess;
-	/** List of connections */
-	list_t conn; /* of tcp_conn_t */
-	/** List of listeners */
-	list_t listener; /* of tcp_listener_t */
-	/** TCP service lock */
-	fibril_mutex_t lock;
-	/** For waiting on cb_done */
-	fibril_condvar_t cv;
-	/** Set to @a true when callback connection handler has terminated */
-	bool cb_done;
-} tcp_t;
-
-extern errno_t tcp_create(tcp_t **);
-extern void tcp_destroy(tcp_t *);
-extern errno_t tcp_conn_create(tcp_t *, inet_ep2_t *, tcp_cb_t *, void *,
-    tcp_conn_t **);
-extern void tcp_conn_destroy(tcp_conn_t *);
-extern void *tcp_conn_userptr(tcp_conn_t *);
-extern errno_t tcp_listener_create(tcp_t *, inet_ep_t *, tcp_listen_cb_t *, void *,
-    tcp_cb_t *, void *, tcp_listener_t **);
-extern void tcp_listener_destroy(tcp_listener_t *);
-extern void *tcp_listener_userptr(tcp_listener_t *);
-
-extern errno_t tcp_conn_wait_connected(tcp_conn_t *);
-extern errno_t tcp_conn_send(tcp_conn_t *, const void *, size_t);
-extern errno_t tcp_conn_send_fin(tcp_conn_t *);
-extern errno_t tcp_conn_push(tcp_conn_t *);
-extern errno_t tcp_conn_reset(tcp_conn_t *);
-
-extern errno_t tcp_conn_recv(tcp_conn_t *, void *, size_t, size_t *);
-extern errno_t tcp_conn_recv_wait(tcp_conn_t *, void *, size_t, size_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/inet/udp.h
===================================================================
--- uspace/lib/c/include/inet/udp.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,110 +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
- */
-
-#ifndef _LIBC_INET_UDP_H_
-#define _LIBC_INET_UDP_H_
-
-#include <async.h>
-#include <fibril_synch.h>
-#include <inet/addr.h>
-#include <inet/endpoint.h>
-#include <inet/inet.h>
-#include <stdbool.h>
-
-/** UDP link state */
-typedef enum {
-	udp_ls_down,
-	udp_ls_up
-} udp_link_state_t;
-
-/** UDP received message */
-typedef struct {
-	struct udp *udp;
-	sysarg_t assoc_id;
-	size_t size;
-	inet_ep_t remote_ep;
-} udp_rmsg_t;
-
-/** UDP received error */
-typedef struct {
-} udp_rerr_t;
-
-/** UDP association */
-typedef struct {
-	struct udp *udp;
-	link_t ludp;
-	sysarg_t id;
-	struct udp_cb *cb;
-	void *cb_arg;
-} udp_assoc_t;
-
-/** UDP callbacks */
-typedef struct udp_cb {
-	void (*recv_msg)(udp_assoc_t *, udp_rmsg_t *);
-	void (*recv_err)(udp_assoc_t *, udp_rerr_t *);
-	void (*link_state)(udp_assoc_t *, udp_link_state_t);
-} udp_cb_t;
-
-/** UDP service */
-typedef struct udp {
-	/** UDP session */
-	async_sess_t *sess;
-	/** List of associations */
-	list_t assoc; /* of udp_assoc_t */
-	/** UDP service lock */
-	fibril_mutex_t lock;
-	/** For waiting on cb_done */
-	fibril_condvar_t cv;
-	/** Set to @a true when callback connection handler has terminated */
-	bool cb_done;
-} udp_t;
-
-extern errno_t udp_create(udp_t **);
-extern void udp_destroy(udp_t *);
-extern errno_t udp_assoc_create(udp_t *, inet_ep2_t *, udp_cb_t *, void *,
-    udp_assoc_t **);
-extern errno_t udp_assoc_set_nolocal(udp_assoc_t *);
-extern void udp_assoc_destroy(udp_assoc_t *);
-extern errno_t udp_assoc_send_msg(udp_assoc_t *, inet_ep_t *, void *, size_t);
-extern void *udp_assoc_userptr(udp_assoc_t *);
-extern size_t udp_rmsg_size(udp_rmsg_t *);
-extern errno_t udp_rmsg_read(udp_rmsg_t *, size_t, void *, size_t);
-extern void udp_rmsg_remote_ep(udp_rmsg_t *, inet_ep_t *);
-extern uint8_t udp_rerr_type(udp_rerr_t *);
-extern uint8_t udp_rerr_code(udp_rerr_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/ipc/dhcp.h
===================================================================
--- uspace/lib/c/include/ipc/dhcp.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,51 +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 libcipc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IPC_DHCP_H_
-#define _LIBC_IPC_DHCP_H_
-
-#include <ipc/common.h>
-
-/** DHCP service requests */
-typedef enum {
-	DHCP_LINK_ADD = IPC_FIRST_USER_METHOD,
-	DHCP_LINK_REMOVE,
-	DHCP_DISCOVER
-} dhcp_request_t;
-
-#endif
-
-/**
- * @}
- */
Index: pace/lib/c/include/ipc/dnsr.h
===================================================================
--- uspace/lib/c/include/ipc/dnsr.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,47 +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 libcipc
- * @{
- */
-
-#ifndef _LIBC_IPC_DNSR_H_
-#define _LIBC_IPC_DNSR_H_
-
-#include <ipc/common.h>
-
-typedef enum {
-	DNSR_NAME2HOST = IPC_FIRST_USER_METHOD,
-	DNSR_GET_SRVADDR,
-	DNSR_SET_SRVADDR
-} dnsr_request_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/ipc/inet.h
===================================================================
--- uspace/lib/c/include/ipc/inet.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,86 +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 libcipc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IPC_INET_H_
-#define _LIBC_IPC_INET_H_
-
-#include <ipc/common.h>
-
-/** Requests on Inet default port */
-typedef enum {
-	INET_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
-	INET_GET_SRCADDR,
-	INET_SEND,
-	INET_SET_PROTO
-} inet_request_t;
-
-/** Events on Inet default port */
-typedef enum {
-	INET_EV_RECV = IPC_FIRST_USER_METHOD
-} inet_event_t;
-
-/** Requests on Inet configuration port */
-typedef enum {
-	INETCFG_ADDR_CREATE_STATIC = IPC_FIRST_USER_METHOD,
-	INETCFG_ADDR_DELETE,
-	INETCFG_ADDR_GET,
-	INETCFG_ADDR_GET_ID,
-	INETCFG_GET_ADDR_LIST,
-	INETCFG_GET_LINK_LIST,
-	INETCFG_GET_SROUTE_LIST,
-	INETCFG_LINK_ADD,
-	INETCFG_LINK_GET,
-	INETCFG_LINK_REMOVE,
-	INETCFG_SROUTE_CREATE,
-	INETCFG_SROUTE_DELETE,
-	INETCFG_SROUTE_GET,
-	INETCFG_SROUTE_GET_ID
-} inetcfg_request_t;
-
-/** Events on Inet ping port */
-typedef enum {
-	INETPING_EV_RECV = IPC_FIRST_USER_METHOD
-} inetping_event_t;
-
-/** Requests on Inet ping port */
-typedef enum {
-	INETPING_SEND = IPC_FIRST_USER_METHOD,
-	INETPING_GET_SRCADDR
-} inetping_request_t;
-
-#endif
-
-/**
- * @}
- */
Index: pace/lib/c/include/ipc/iplink.h
===================================================================
--- uspace/lib/c/include/ipc/iplink.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,59 +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 libcipc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IPC_IPLINK_H_
-#define _LIBC_IPC_IPLINK_H_
-
-#include <ipc/common.h>
-
-typedef enum {
-	IPLINK_GET_MTU = IPC_FIRST_USER_METHOD,
-	IPLINK_GET_MAC48,
-	IPLINK_SET_MAC48,
-	IPLINK_SEND,
-	IPLINK_SEND6,
-	IPLINK_ADDR_ADD,
-	IPLINK_ADDR_REMOVE
-} iplink_request_t;
-
-typedef enum {
-	IPLINK_EV_RECV = IPC_FIRST_USER_METHOD,
-	IPLINK_EV_CHANGE_ADDR,
-} iplink_event_t;
-
-#endif
-
-/**
- * @}
- */
Index: pace/lib/c/include/ipc/tcp.h
===================================================================
--- uspace/lib/c/include/ipc/tcp.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,66 +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 libcipc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IPC_TCP_H_
-#define _LIBC_IPC_TCP_H_
-
-#include <ipc/common.h>
-
-typedef enum {
-	TCP_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
-	TCP_CONN_CREATE,
-	TCP_CONN_DESTROY,
-	TCP_LISTENER_CREATE,
-	TCP_LISTENER_DESTROY,
-	TCP_CONN_SEND,
-	TCP_CONN_SEND_FIN,
-	TCP_CONN_PUSH,
-	TCP_CONN_RESET,
-	TCP_CONN_RECV,
-	TCP_CONN_RECV_WAIT
-} tcp_request_t;
-
-typedef enum {
-	TCP_EV_CONNECTED = IPC_FIRST_USER_METHOD,
-	TCP_EV_CONN_FAILED,
-	TCP_EV_CONN_RESET,
-	TCP_EV_DATA,
-	TCP_EV_URG_DATA,
-	TCP_EV_NEW_CONN
-} tcp_event_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/ipc/udp.h
===================================================================
--- uspace/lib/c/include/ipc/udp.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,58 +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 libcipc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IPC_UDP_H_
-#define _LIBC_IPC_UDP_H_
-
-#include <ipc/common.h>
-
-typedef enum {
-	UDP_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
-	UDP_ASSOC_CREATE,
-	UDP_ASSOC_DESTROY,
-	UDP_ASSOC_SET_NOLOCAL,
-	UDP_ASSOC_SEND_MSG,
-	UDP_RMSG_INFO,
-	UDP_RMSG_READ,
-	UDP_RMSG_DISCARD
-} udp_request_t;
-
-typedef enum {
-	UDP_EV_DATA = IPC_FIRST_USER_METHOD
-} udp_event_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/types/inet.h
===================================================================
--- uspace/lib/c/include/types/inet.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,66 +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
- */
-
-#ifndef _LIBC_TYPES_INET_H_
-#define _LIBC_TYPES_INET_H_
-
-#include <inet/addr.h>
-#include <ipc/loc.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#define INET_TTL_MAX 255
-
-typedef struct {
-	/** Local IP link service ID (optional) */
-	service_id_t iplink;
-	inet_addr_t src;
-	inet_addr_t dest;
-	uint8_t tos;
-	void *data;
-	size_t size;
-} inet_dgram_t;
-
-typedef struct {
-	errno_t (*recv)(inet_dgram_t *);
-} inet_ev_ops_t;
-
-typedef enum {
-	INET_DF = 1
-} inet_df_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/types/inet/host.h
===================================================================
--- uspace/lib/c/include/types/inet/host.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,67 +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
- */
-
-#ifndef _LIBC_TYPES_INET_HOST_H_
-#define _LIBC_TYPES_INET_HOST_H_
-
-#include <inet/addr.h>
-
-typedef enum {
-	/** Host name */
-	inet_host_name,
-	/** Host address */
-	inet_host_addr
-} inet_host_form_t;
-
-/** Internet host:port specification
- *
- * As in RFC 1738 Uniform Resouce Locators (URL) and RFC 2732 Format for
- * literal IPv6 Addresses in URLs
- */
-typedef struct {
-	/** Host form */
-	inet_host_form_t hform;
-
-	union {
-		/** Host name */
-		char *name;
-		/** Host address */
-		inet_addr_t addr;
-	} host;
-} inet_host_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/types/inet/hostport.h
===================================================================
--- uspace/lib/c/include/types/inet/hostport.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,65 +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
- */
-
-#ifndef _LIBC_TYPES_INET_HOSTPORT_H_
-#define _LIBC_TYPES_INET_HOSTPORT_H_
-
-#include <inet/addr.h>
-#include <stdint.h>
-#include <types/inet/host.h>
-
-/** Internet host:port specification
- *
- * As in RFC 1738 Uniform Resouce Locators (URL) and RFC 2732 Format for
- * literal IPv6 Addresses in URLs
- */
-typedef struct {
-	/** Host form */
-	inet_host_form_t hform;
-
-	union {
-		/** Host name */
-		char *name;
-		/** Host address */
-		inet_addr_t addr;
-	} host;
-
-	/** Port number of 0 if omitted */
-	uint16_t port;
-} inet_hostport_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/types/inetcfg.h
===================================================================
--- uspace/lib/c/include/types/inetcfg.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,74 +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
- */
-
-#ifndef _LIBC_TYPES_INETCFG_H_
-#define _LIBC_TYPES_INETCFG_H_
-
-#include <inet/inet.h>
-#include <stddef.h>
-
-/** Address object info */
-typedef struct {
-	/** Network address */
-	inet_naddr_t naddr;
-	/** Link service ID */
-	sysarg_t ilink;
-	/** Address object name */
-	char *name;
-} inet_addr_info_t;
-
-/** IP link info */
-typedef struct {
-	/** Link service name */
-	char *name;
-	/** Default MTU */
-	size_t def_mtu;
-	/** Link layer address */
-	addr48_t mac_addr;
-} inet_link_info_t;
-
-/** Static route info */
-typedef struct {
-	/** Destination network address */
-	inet_naddr_t dest;
-	/** Router address */
-	inet_addr_t router;
-	/** Static route name */
-	char *name;
-} inet_sroute_info_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/types/inetping.h
===================================================================
--- uspace/lib/c/include/types/inetping.h	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ 	(revision )
@@ -1,55 +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
- * @brief
- */
-
-#ifndef _LIBC_TYPES_INETPING_H_
-#define _LIBC_TYPES_INETPING_H_
-
-#include <inet/addr.h>
-#include <stddef.h>
-#include <stdint.h>
-
-typedef struct {
-	inet_addr_t src;
-	inet_addr_t dest;
-	uint16_t seq_no;
-	void *data;
-	size_t size;
-} inetping_sdu_t;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/lib/c/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -78,6 +78,4 @@
 	'generic/device/led_dev.c',
 	'generic/dirent.c',
-	'generic/dhcp.c',
-	'generic/dnsr.c',
 	'generic/dlfcn.c',
 	'generic/elf/elf.c',
@@ -100,14 +98,4 @@
 	'generic/task.c',
 	'generic/imath.c',
-	'generic/inet/addr.c',
-	'generic/inet/endpoint.c',
-	'generic/inet/host.c',
-	'generic/inet/hostname.c',
-	'generic/inet/hostport.c',
-	'generic/inet/tcp.c',
-	'generic/inet/udp.c',
-	'generic/inet.c',
-	'generic/inetcfg.c',
-	'generic/inetping.c',
 	'generic/io/asprintf.c',
 	'generic/io/input.c',
@@ -131,6 +119,4 @@
 	'generic/io/console.c',
 	'generic/io/table.c',
-	'generic/iplink.c',
-	'generic/iplink_srv.c',
 	'generic/irc.c',
 	'generic/irq.c',
Index: uspace/lib/drv/meson.build
===================================================================
--- uspace/lib/drv/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/lib/drv/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -28,5 +28,5 @@
 #
 
-deps = [ 'pcm' ]
+deps = [ 'inet', 'pcm' ]
 private_includes += include_directories('generic/private')
 src = files(
Index: uspace/lib/http/meson.build
===================================================================
--- uspace/lib/http/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/lib/http/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,3 +1,4 @@
 #
+# Copyright (c) 2021 Jiri Svoboda
 # Copyright (c) 2013 Martin Sucha
 # All rights reserved.
@@ -27,4 +28,5 @@
 #
 
+deps = [ 'inet' ]
 src = files(
 	'src/http.c',
Index: uspace/lib/inet/doc/doxygroups.h
===================================================================
--- uspace/lib/inet/doc/doxygroups.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/doc/doxygroups.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,3 @@
+/** @addtogroup libinet libinet
+ * @ingroup libs
+ */
Index: uspace/lib/inet/include/inet/addr.h
===================================================================
--- uspace/lib/inet/include/inet/addr.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/addr.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,133 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_ADDR_H_
+#define _LIBC_INET_ADDR_H_
+
+#include <errno.h>
+#include <stdint.h>
+
+typedef uint32_t addr32_t;
+typedef uint8_t addr48_t[6];
+typedef uint8_t addr128_t[16];
+
+typedef enum {
+	/** Any IP protocol version */
+	ip_any,
+	/** IPv4 */
+	ip_v4,
+	/** IPv6 */
+	ip_v6
+} ip_ver_t;
+
+/** Node address */
+typedef struct {
+	/** IP version */
+	ip_ver_t version;
+	union {
+		addr32_t addr;
+		addr128_t addr6;
+	};
+} inet_addr_t;
+
+/** Network address */
+typedef struct {
+	/** IP version */
+	ip_ver_t version;
+
+	/** Address */
+	union {
+		addr32_t addr;
+		addr128_t addr6;
+	};
+
+	/** Number of valid bits */
+	uint8_t prefix;
+} inet_naddr_t;
+
+extern const addr32_t addr32_broadcast_all_hosts;
+extern const addr48_t addr48_broadcast;
+
+extern void addr48(const addr48_t, addr48_t);
+extern void addr128(const addr128_t, addr128_t);
+
+extern int addr48_compare(const addr48_t, const addr48_t);
+extern int addr128_compare(const addr128_t, const addr128_t);
+
+extern void addr48_solicited_node(const addr128_t, addr48_t);
+
+extern void host2addr128_t_be(const addr128_t, addr128_t);
+extern void addr128_t_be2host(const addr128_t, addr128_t);
+
+extern void inet_addr(inet_addr_t *, uint8_t, uint8_t, uint8_t, uint8_t);
+extern void inet_naddr(inet_naddr_t *, uint8_t, uint8_t, uint8_t, uint8_t,
+    uint8_t);
+
+extern void inet_addr6(inet_addr_t *, uint16_t, uint16_t, uint16_t, uint16_t,
+    uint16_t, uint16_t, uint16_t, uint16_t);
+extern void inet_naddr6(inet_naddr_t *, uint16_t, uint16_t, uint16_t, uint16_t,
+    uint16_t, uint16_t, uint16_t, uint16_t, uint8_t);
+
+extern void inet_naddr_addr(const inet_naddr_t *, inet_addr_t *);
+extern void inet_addr_naddr(const inet_addr_t *, uint8_t, inet_naddr_t *);
+
+extern void inet_addr_any(inet_addr_t *);
+extern void inet_naddr_any(inet_naddr_t *);
+
+extern int inet_addr_compare(const inet_addr_t *, const inet_addr_t *);
+extern int inet_addr_is_any(const inet_addr_t *);
+
+extern int inet_naddr_compare(const inet_naddr_t *, const inet_addr_t *);
+extern int inet_naddr_compare_mask(const inet_naddr_t *, const inet_addr_t *);
+
+extern errno_t inet_addr_parse(const char *, inet_addr_t *, char **);
+extern errno_t inet_naddr_parse(const char *, inet_naddr_t *, char **);
+
+extern errno_t inet_addr_format(const inet_addr_t *, char **);
+extern errno_t inet_naddr_format(const inet_naddr_t *, char **);
+
+extern ip_ver_t inet_addr_get(const inet_addr_t *, addr32_t *, addr128_t *);
+extern ip_ver_t inet_naddr_get(const inet_naddr_t *, addr32_t *, addr128_t *,
+    uint8_t *);
+
+extern void inet_addr_set(addr32_t, inet_addr_t *);
+extern void inet_naddr_set(addr32_t, uint8_t, inet_naddr_t *);
+
+extern void inet_addr_set6(addr128_t, inet_addr_t *);
+extern void inet_naddr_set6(addr128_t, uint8_t, inet_naddr_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/dhcp.h
===================================================================
--- uspace/lib/inet/include/inet/dhcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/dhcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,48 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_DHCP_H_
+#define _LIBC_INET_DHCP_H_
+
+#include <types/common.h>
+
+extern errno_t dhcp_init(void);
+extern errno_t dhcp_link_add(sysarg_t);
+extern errno_t dhcp_link_remove(sysarg_t);
+extern errno_t dhcp_discover(sysarg_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/dnsr.h
===================================================================
--- uspace/lib/inet/include/inet/dnsr.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/dnsr.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,61 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_DNSR_H_
+#define _LIBC_INET_DNSR_H_
+
+#include <inet/inet.h>
+#include <inet/addr.h>
+
+enum {
+	DNSR_NAME_MAX_SIZE = 255
+};
+
+typedef struct {
+	/** Host canonical name */
+	char *cname;
+	/** Host address */
+	inet_addr_t addr;
+} dnsr_hostinfo_t;
+
+extern errno_t dnsr_init(void);
+extern errno_t dnsr_name2host(const char *, dnsr_hostinfo_t **, ip_ver_t);
+extern void dnsr_hostinfo_destroy(dnsr_hostinfo_t *);
+extern errno_t dnsr_get_srvaddr(inet_addr_t *);
+extern errno_t dnsr_set_srvaddr(inet_addr_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/endpoint.h
===================================================================
--- uspace/lib/inet/include/inet/endpoint.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/endpoint.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,86 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_ENDPOINT_H_
+#define _LIBC_INET_ENDPOINT_H_
+
+#include <stdint.h>
+#include <inet/addr.h>
+#include <loc.h>
+
+/** Internet port number ranges
+ *
+ * Port number ranges per RFC 6335 section 6 (Port Number Ranges.
+ * Technically port zero is a system port. But since it is reserved,
+ * we will use it as a special value denoting no port is specified
+ * and we will exclude it from the system port range to disallow
+ * ever assigning it.
+ */
+enum inet_port_ranges {
+	/** Special value meaning no specific port */
+	inet_port_any = 0,
+	/** Lowest system port (a.k.a. well known port) */
+	inet_port_sys_lo = 1,
+	/** Highest system port (a.k.a. well known port) */
+	inet_port_sys_hi = 1023,
+	/** Lowest user port (a.k.a. registered port) */
+	inet_port_user_lo = 1024,
+	/** Highest user port (a.k.a. registered port) */
+	inet_port_user_hi = 49151,
+	/** Lowest dynamic port (a.k.a. private or ephemeral port) */
+	inet_port_dyn_lo = 49152,
+	/** Highest dynamic port (a.k.a. private or ephemeral port) */
+	inet_port_dyn_hi = 65535
+};
+
+/** Internet endpoint (address-port pair), a.k.a. socket */
+typedef struct {
+	inet_addr_t addr;
+	uint16_t port;
+} inet_ep_t;
+
+/** Internet endpoint pair */
+typedef struct {
+	service_id_t local_link;
+	inet_ep_t local;
+	inet_ep_t remote;
+} inet_ep2_t;
+
+extern void inet_ep_init(inet_ep_t *);
+extern void inet_ep2_init(inet_ep2_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/host.h
===================================================================
--- uspace/lib/inet/include/inet/host.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/host.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,52 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_HOST_H_
+#define _LIBC_INET_HOST_H_
+
+#include <inet/addr.h>
+#include <inet/endpoint.h>
+#include <types/inet/hostport.h>
+
+extern errno_t inet_host_parse(const char *, inet_host_t **, char **);
+extern errno_t inet_host_format(inet_host_t *, char **);
+extern void inet_host_destroy(inet_host_t *);
+extern errno_t inet_host_lookup_one(inet_host_t *, ip_ver_t, inet_addr_t *);
+extern errno_t inet_host_plookup_one(const char *, ip_ver_t, inet_addr_t *,
+    char **, const char **);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/hostname.h
===================================================================
--- uspace/lib/inet/include/inet/hostname.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/hostname.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,43 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_HOSTNAME_H_
+#define _LIBC_INET_HOSTNAME_H_
+
+extern errno_t inet_hostname_parse(const char *, char **, char **);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/hostport.h
===================================================================
--- uspace/lib/inet/include/inet/hostport.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/hostport.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,52 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_HOSTPORT_H_
+#define _LIBC_INET_HOSTPORT_H_
+
+#include <inet/addr.h>
+#include <inet/endpoint.h>
+#include <types/inet/hostport.h>
+
+extern errno_t inet_hostport_parse(const char *, inet_hostport_t **, char **);
+extern errno_t inet_hostport_format(inet_hostport_t *, char **);
+extern void inet_hostport_destroy(inet_hostport_t *);
+extern errno_t inet_hostport_lookup_one(inet_hostport_t *, ip_ver_t, inet_ep_t *);
+extern errno_t inet_hostport_plookup_one(const char *, ip_ver_t, inet_ep_t *,
+    char **, const char **);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/inet.h
===================================================================
--- uspace/lib/inet/include/inet/inet.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/inet.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,50 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_INET_H_
+#define _LIBC_INET_INET_H_
+
+#include <inet/addr.h>
+#include <ipc/loc.h>
+#include <stdint.h>
+#include <types/inet.h>
+
+extern errno_t inet_init(uint8_t, inet_ev_ops_t *);
+extern errno_t inet_send(inet_dgram_t *, uint8_t, inet_df_t);
+extern errno_t inet_get_srcaddr(inet_addr_t *, uint8_t, inet_addr_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/inetcfg.h
===================================================================
--- uspace/lib/inet/include/inet/inetcfg.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/inetcfg.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,62 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_INETCFG_H_
+#define _LIBC_INET_INETCFG_H_
+
+#include <inet/inet.h>
+#include <stddef.h>
+#include <types/inetcfg.h>
+
+extern errno_t inetcfg_init(void);
+extern errno_t inetcfg_addr_create_static(const char *, inet_naddr_t *, sysarg_t, sysarg_t *);
+extern errno_t inetcfg_addr_delete(sysarg_t);
+extern errno_t inetcfg_addr_get(sysarg_t, inet_addr_info_t *);
+extern errno_t inetcfg_addr_get_id(const char *, sysarg_t, sysarg_t *);
+extern errno_t inetcfg_get_addr_list(sysarg_t **, size_t *);
+extern errno_t inetcfg_get_link_list(sysarg_t **, size_t *);
+extern errno_t inetcfg_get_sroute_list(sysarg_t **, size_t *);
+extern errno_t inetcfg_link_add(sysarg_t);
+extern errno_t inetcfg_link_get(sysarg_t, inet_link_info_t *);
+extern errno_t inetcfg_link_remove(sysarg_t);
+extern errno_t inetcfg_sroute_get(sysarg_t, inet_sroute_info_t *);
+extern errno_t inetcfg_sroute_get_id(const char *, sysarg_t *);
+extern errno_t inetcfg_sroute_create(const char *, inet_naddr_t *, inet_addr_t *,
+    sysarg_t *);
+extern errno_t inetcfg_sroute_delete(sysarg_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/inetping.h
===================================================================
--- uspace/lib/inet/include/inet/inetping.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/inetping.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,52 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_INETPING_H_
+#define _LIBC_INET_INETPING_H_
+
+#include <inet/inet.h>
+#include <types/inetping.h>
+
+typedef struct inetping_ev_ops {
+	errno_t (*recv)(inetping_sdu_t *);
+} inetping_ev_ops_t;
+
+extern errno_t inetping_init(inetping_ev_ops_t *);
+extern errno_t inetping_send(inetping_sdu_t *);
+extern errno_t inetping_get_srcaddr(const inet_addr_t *, inet_addr_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/iplink.h
===================================================================
--- uspace/lib/inet/include/inet/iplink.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/iplink.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,98 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_IPLINK_H_
+#define _LIBC_INET_IPLINK_H_
+
+#include <async.h>
+#include <inet/addr.h>
+
+struct iplink_ev_ops;
+
+typedef struct {
+	async_sess_t *sess;
+	struct iplink_ev_ops *ev_ops;
+	void *arg;
+} iplink_t;
+
+/** IPv4 link Service Data Unit */
+typedef struct {
+	/** Local source address */
+	addr32_t src;
+	/** Local destination address */
+	addr32_t dest;
+	/** Serialized IP packet */
+	void *data;
+	/** Size of @c data in bytes */
+	size_t size;
+} iplink_sdu_t;
+
+/** IPv6 link Service Data Unit */
+typedef struct {
+	/** Local MAC destination address */
+	addr48_t dest;
+	/** Serialized IP packet */
+	void *data;
+	/** Size of @c data in bytes */
+	size_t size;
+} iplink_sdu6_t;
+
+/** Internet link receive Service Data Unit */
+typedef struct {
+	/** Serialized datagram */
+	void *data;
+	/** Size of @c data in bytes */
+	size_t size;
+} iplink_recv_sdu_t;
+
+typedef struct iplink_ev_ops {
+	errno_t (*recv)(iplink_t *, iplink_recv_sdu_t *, ip_ver_t);
+	errno_t (*change_addr)(iplink_t *, addr48_t);
+} iplink_ev_ops_t;
+
+extern errno_t iplink_open(async_sess_t *, iplink_ev_ops_t *, void *, iplink_t **);
+extern void iplink_close(iplink_t *);
+extern errno_t iplink_send(iplink_t *, iplink_sdu_t *);
+extern errno_t iplink_send6(iplink_t *, iplink_sdu6_t *);
+extern errno_t iplink_addr_add(iplink_t *, inet_addr_t *);
+extern errno_t iplink_addr_remove(iplink_t *, inet_addr_t *);
+extern errno_t iplink_get_mtu(iplink_t *, size_t *);
+extern errno_t iplink_get_mac48(iplink_t *, addr48_t *);
+extern errno_t iplink_set_mac48(iplink_t *, addr48_t);
+extern void *iplink_get_userptr(iplink_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/iplink_srv.h
===================================================================
--- uspace/lib/inet/include/inet/iplink_srv.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/iplink_srv.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,75 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_IPLINK_SRV_H_
+#define _LIBC_INET_IPLINK_SRV_H_
+
+#include <async.h>
+#include <fibril_synch.h>
+#include <stdbool.h>
+#include <inet/addr.h>
+#include <inet/iplink.h>
+
+struct iplink_ops;
+
+typedef struct {
+	fibril_mutex_t lock;
+	bool connected;
+	struct iplink_ops *ops;
+	void *arg;
+	async_sess_t *client_sess;
+} iplink_srv_t;
+
+typedef struct iplink_ops {
+	errno_t (*open)(iplink_srv_t *);
+	errno_t (*close)(iplink_srv_t *);
+	errno_t (*send)(iplink_srv_t *, iplink_sdu_t *);
+	errno_t (*send6)(iplink_srv_t *, iplink_sdu6_t *);
+	errno_t (*get_mtu)(iplink_srv_t *, size_t *);
+	errno_t (*get_mac48)(iplink_srv_t *, addr48_t *);
+	errno_t (*set_mac48)(iplink_srv_t *, addr48_t *);
+	errno_t (*addr_add)(iplink_srv_t *, inet_addr_t *);
+	errno_t (*addr_remove)(iplink_srv_t *, inet_addr_t *);
+} iplink_ops_t;
+
+extern void iplink_srv_init(iplink_srv_t *);
+
+extern errno_t iplink_conn(ipc_call_t *, void *);
+extern errno_t iplink_ev_recv(iplink_srv_t *, iplink_recv_sdu_t *, ip_ver_t);
+extern errno_t iplink_ev_change_addr(iplink_srv_t *, addr48_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/tcp.h
===================================================================
--- uspace/lib/inet/include/inet/tcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/tcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,123 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_TCP_H_
+#define _LIBC_INET_TCP_H_
+
+#include <fibril_synch.h>
+#include <inet/addr.h>
+#include <inet/endpoint.h>
+#include <inet/inet.h>
+
+/** TCP connection */
+typedef struct {
+	fibril_mutex_t lock;
+	fibril_condvar_t cv;
+	struct tcp *tcp;
+	link_t ltcp;
+	sysarg_t id;
+	struct tcp_cb *cb;
+	void *cb_arg;
+	/** Some received data available in TCP server */
+	bool data_avail;
+	bool connected;
+	bool conn_failed;
+	bool conn_reset;
+} tcp_conn_t;
+
+/** TCP connection listener */
+typedef struct {
+	struct tcp *tcp;
+	link_t ltcp;
+	sysarg_t id;
+	struct tcp_listen_cb *lcb;
+	void *lcb_arg;
+	struct tcp_cb *cb;
+	void *cb_arg;
+} tcp_listener_t;
+
+/** TCP connection callbacks */
+typedef struct tcp_cb {
+	void (*connected)(tcp_conn_t *);
+	void (*conn_failed)(tcp_conn_t *);
+	void (*conn_reset)(tcp_conn_t *);
+	void (*data_avail)(tcp_conn_t *);
+	void (*urg_data)(tcp_conn_t *);
+} tcp_cb_t;
+
+/** TCP listener callbacks */
+typedef struct tcp_listen_cb {
+	void (*new_conn)(tcp_listener_t *, tcp_conn_t *);
+} tcp_listen_cb_t;
+
+/** TCP service */
+typedef struct tcp {
+	/** TCP session */
+	async_sess_t *sess;
+	/** List of connections */
+	list_t conn; /* of tcp_conn_t */
+	/** List of listeners */
+	list_t listener; /* of tcp_listener_t */
+	/** TCP service lock */
+	fibril_mutex_t lock;
+	/** For waiting on cb_done */
+	fibril_condvar_t cv;
+	/** Set to @a true when callback connection handler has terminated */
+	bool cb_done;
+} tcp_t;
+
+extern errno_t tcp_create(tcp_t **);
+extern void tcp_destroy(tcp_t *);
+extern errno_t tcp_conn_create(tcp_t *, inet_ep2_t *, tcp_cb_t *, void *,
+    tcp_conn_t **);
+extern void tcp_conn_destroy(tcp_conn_t *);
+extern void *tcp_conn_userptr(tcp_conn_t *);
+extern errno_t tcp_listener_create(tcp_t *, inet_ep_t *, tcp_listen_cb_t *, void *,
+    tcp_cb_t *, void *, tcp_listener_t **);
+extern void tcp_listener_destroy(tcp_listener_t *);
+extern void *tcp_listener_userptr(tcp_listener_t *);
+
+extern errno_t tcp_conn_wait_connected(tcp_conn_t *);
+extern errno_t tcp_conn_send(tcp_conn_t *, const void *, size_t);
+extern errno_t tcp_conn_send_fin(tcp_conn_t *);
+extern errno_t tcp_conn_push(tcp_conn_t *);
+extern errno_t tcp_conn_reset(tcp_conn_t *);
+
+extern errno_t tcp_conn_recv(tcp_conn_t *, void *, size_t, size_t *);
+extern errno_t tcp_conn_recv_wait(tcp_conn_t *, void *, size_t, size_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/inet/udp.h
===================================================================
--- uspace/lib/inet/include/inet/udp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/inet/udp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,110 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_INET_UDP_H_
+#define _LIBC_INET_UDP_H_
+
+#include <async.h>
+#include <fibril_synch.h>
+#include <inet/addr.h>
+#include <inet/endpoint.h>
+#include <inet/inet.h>
+#include <stdbool.h>
+
+/** UDP link state */
+typedef enum {
+	udp_ls_down,
+	udp_ls_up
+} udp_link_state_t;
+
+/** UDP received message */
+typedef struct {
+	struct udp *udp;
+	sysarg_t assoc_id;
+	size_t size;
+	inet_ep_t remote_ep;
+} udp_rmsg_t;
+
+/** UDP received error */
+typedef struct {
+} udp_rerr_t;
+
+/** UDP association */
+typedef struct {
+	struct udp *udp;
+	link_t ludp;
+	sysarg_t id;
+	struct udp_cb *cb;
+	void *cb_arg;
+} udp_assoc_t;
+
+/** UDP callbacks */
+typedef struct udp_cb {
+	void (*recv_msg)(udp_assoc_t *, udp_rmsg_t *);
+	void (*recv_err)(udp_assoc_t *, udp_rerr_t *);
+	void (*link_state)(udp_assoc_t *, udp_link_state_t);
+} udp_cb_t;
+
+/** UDP service */
+typedef struct udp {
+	/** UDP session */
+	async_sess_t *sess;
+	/** List of associations */
+	list_t assoc; /* of udp_assoc_t */
+	/** UDP service lock */
+	fibril_mutex_t lock;
+	/** For waiting on cb_done */
+	fibril_condvar_t cv;
+	/** Set to @a true when callback connection handler has terminated */
+	bool cb_done;
+} udp_t;
+
+extern errno_t udp_create(udp_t **);
+extern void udp_destroy(udp_t *);
+extern errno_t udp_assoc_create(udp_t *, inet_ep2_t *, udp_cb_t *, void *,
+    udp_assoc_t **);
+extern errno_t udp_assoc_set_nolocal(udp_assoc_t *);
+extern void udp_assoc_destroy(udp_assoc_t *);
+extern errno_t udp_assoc_send_msg(udp_assoc_t *, inet_ep_t *, void *, size_t);
+extern void *udp_assoc_userptr(udp_assoc_t *);
+extern size_t udp_rmsg_size(udp_rmsg_t *);
+extern errno_t udp_rmsg_read(udp_rmsg_t *, size_t, void *, size_t);
+extern void udp_rmsg_remote_ep(udp_rmsg_t *, inet_ep_t *);
+extern uint8_t udp_rerr_type(udp_rerr_t *);
+extern uint8_t udp_rerr_code(udp_rerr_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/ipc/dhcp.h
===================================================================
--- uspace/lib/inet/include/ipc/dhcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/ipc/dhcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,51 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_IPC_DHCP_H_
+#define _LIBC_IPC_DHCP_H_
+
+#include <ipc/common.h>
+
+/** DHCP service requests */
+typedef enum {
+	DHCP_LINK_ADD = IPC_FIRST_USER_METHOD,
+	DHCP_LINK_REMOVE,
+	DHCP_DISCOVER
+} dhcp_request_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/inet/include/ipc/dnsr.h
===================================================================
--- uspace/lib/inet/include/ipc/dnsr.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/ipc/dnsr.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,47 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+
+#ifndef _LIBC_IPC_DNSR_H_
+#define _LIBC_IPC_DNSR_H_
+
+#include <ipc/common.h>
+
+typedef enum {
+	DNSR_NAME2HOST = IPC_FIRST_USER_METHOD,
+	DNSR_GET_SRVADDR,
+	DNSR_SET_SRVADDR
+} dnsr_request_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/ipc/inet.h
===================================================================
--- uspace/lib/inet/include/ipc/inet.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/ipc/inet.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,86 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_IPC_INET_H_
+#define _LIBC_IPC_INET_H_
+
+#include <ipc/common.h>
+
+/** Requests on Inet default port */
+typedef enum {
+	INET_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
+	INET_GET_SRCADDR,
+	INET_SEND,
+	INET_SET_PROTO
+} inet_request_t;
+
+/** Events on Inet default port */
+typedef enum {
+	INET_EV_RECV = IPC_FIRST_USER_METHOD
+} inet_event_t;
+
+/** Requests on Inet configuration port */
+typedef enum {
+	INETCFG_ADDR_CREATE_STATIC = IPC_FIRST_USER_METHOD,
+	INETCFG_ADDR_DELETE,
+	INETCFG_ADDR_GET,
+	INETCFG_ADDR_GET_ID,
+	INETCFG_GET_ADDR_LIST,
+	INETCFG_GET_LINK_LIST,
+	INETCFG_GET_SROUTE_LIST,
+	INETCFG_LINK_ADD,
+	INETCFG_LINK_GET,
+	INETCFG_LINK_REMOVE,
+	INETCFG_SROUTE_CREATE,
+	INETCFG_SROUTE_DELETE,
+	INETCFG_SROUTE_GET,
+	INETCFG_SROUTE_GET_ID
+} inetcfg_request_t;
+
+/** Events on Inet ping port */
+typedef enum {
+	INETPING_EV_RECV = IPC_FIRST_USER_METHOD
+} inetping_event_t;
+
+/** Requests on Inet ping port */
+typedef enum {
+	INETPING_SEND = IPC_FIRST_USER_METHOD,
+	INETPING_GET_SRCADDR
+} inetping_request_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/inet/include/ipc/iplink.h
===================================================================
--- uspace/lib/inet/include/ipc/iplink.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/ipc/iplink.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,59 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_IPC_IPLINK_H_
+#define _LIBC_IPC_IPLINK_H_
+
+#include <ipc/common.h>
+
+typedef enum {
+	IPLINK_GET_MTU = IPC_FIRST_USER_METHOD,
+	IPLINK_GET_MAC48,
+	IPLINK_SET_MAC48,
+	IPLINK_SEND,
+	IPLINK_SEND6,
+	IPLINK_ADDR_ADD,
+	IPLINK_ADDR_REMOVE
+} iplink_request_t;
+
+typedef enum {
+	IPLINK_EV_RECV = IPC_FIRST_USER_METHOD,
+	IPLINK_EV_CHANGE_ADDR,
+} iplink_event_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/inet/include/ipc/tcp.h
===================================================================
--- uspace/lib/inet/include/ipc/tcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/ipc/tcp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,66 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_IPC_TCP_H_
+#define _LIBC_IPC_TCP_H_
+
+#include <ipc/common.h>
+
+typedef enum {
+	TCP_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
+	TCP_CONN_CREATE,
+	TCP_CONN_DESTROY,
+	TCP_LISTENER_CREATE,
+	TCP_LISTENER_DESTROY,
+	TCP_CONN_SEND,
+	TCP_CONN_SEND_FIN,
+	TCP_CONN_PUSH,
+	TCP_CONN_RESET,
+	TCP_CONN_RECV,
+	TCP_CONN_RECV_WAIT
+} tcp_request_t;
+
+typedef enum {
+	TCP_EV_CONNECTED = IPC_FIRST_USER_METHOD,
+	TCP_EV_CONN_FAILED,
+	TCP_EV_CONN_RESET,
+	TCP_EV_DATA,
+	TCP_EV_URG_DATA,
+	TCP_EV_NEW_CONN
+} tcp_event_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/ipc/udp.h
===================================================================
--- uspace/lib/inet/include/ipc/udp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/ipc/udp.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,58 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_IPC_UDP_H_
+#define _LIBC_IPC_UDP_H_
+
+#include <ipc/common.h>
+
+typedef enum {
+	UDP_CALLBACK_CREATE = IPC_FIRST_USER_METHOD,
+	UDP_ASSOC_CREATE,
+	UDP_ASSOC_DESTROY,
+	UDP_ASSOC_SET_NOLOCAL,
+	UDP_ASSOC_SEND_MSG,
+	UDP_RMSG_INFO,
+	UDP_RMSG_READ,
+	UDP_RMSG_DISCARD
+} udp_request_t;
+
+typedef enum {
+	UDP_EV_DATA = IPC_FIRST_USER_METHOD
+} udp_event_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/types/inet.h
===================================================================
--- uspace/lib/inet/include/types/inet.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/types/inet.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,66 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_TYPES_INET_H_
+#define _LIBC_TYPES_INET_H_
+
+#include <inet/addr.h>
+#include <ipc/loc.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#define INET_TTL_MAX 255
+
+typedef struct {
+	/** Local IP link service ID (optional) */
+	service_id_t iplink;
+	inet_addr_t src;
+	inet_addr_t dest;
+	uint8_t tos;
+	void *data;
+	size_t size;
+} inet_dgram_t;
+
+typedef struct {
+	errno_t (*recv)(inet_dgram_t *);
+} inet_ev_ops_t;
+
+typedef enum {
+	INET_DF = 1
+} inet_df_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/types/inet/host.h
===================================================================
--- uspace/lib/inet/include/types/inet/host.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/types/inet/host.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,67 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_TYPES_INET_HOST_H_
+#define _LIBC_TYPES_INET_HOST_H_
+
+#include <inet/addr.h>
+
+typedef enum {
+	/** Host name */
+	inet_host_name,
+	/** Host address */
+	inet_host_addr
+} inet_host_form_t;
+
+/** Internet host:port specification
+ *
+ * As in RFC 1738 Uniform Resouce Locators (URL) and RFC 2732 Format for
+ * literal IPv6 Addresses in URLs
+ */
+typedef struct {
+	/** Host form */
+	inet_host_form_t hform;
+
+	union {
+		/** Host name */
+		char *name;
+		/** Host address */
+		inet_addr_t addr;
+	} host;
+} inet_host_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/types/inet/hostport.h
===================================================================
--- uspace/lib/inet/include/types/inet/hostport.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/types/inet/hostport.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,65 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_TYPES_INET_HOSTPORT_H_
+#define _LIBC_TYPES_INET_HOSTPORT_H_
+
+#include <inet/addr.h>
+#include <stdint.h>
+#include <types/inet/host.h>
+
+/** Internet host:port specification
+ *
+ * As in RFC 1738 Uniform Resouce Locators (URL) and RFC 2732 Format for
+ * literal IPv6 Addresses in URLs
+ */
+typedef struct {
+	/** Host form */
+	inet_host_form_t hform;
+
+	union {
+		/** Host name */
+		char *name;
+		/** Host address */
+		inet_addr_t addr;
+	} host;
+
+	/** Port number of 0 if omitted */
+	uint16_t port;
+} inet_hostport_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/types/inetcfg.h
===================================================================
--- uspace/lib/inet/include/types/inetcfg.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/types/inetcfg.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,74 @@
+/*
+ * 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
+ */
+
+#ifndef _LIBC_TYPES_INETCFG_H_
+#define _LIBC_TYPES_INETCFG_H_
+
+#include <inet/inet.h>
+#include <stddef.h>
+
+/** Address object info */
+typedef struct {
+	/** Network address */
+	inet_naddr_t naddr;
+	/** Link service ID */
+	sysarg_t ilink;
+	/** Address object name */
+	char *name;
+} inet_addr_info_t;
+
+/** IP link info */
+typedef struct {
+	/** Link service name */
+	char *name;
+	/** Default MTU */
+	size_t def_mtu;
+	/** Link layer address */
+	addr48_t mac_addr;
+} inet_link_info_t;
+
+/** Static route info */
+typedef struct {
+	/** Destination network address */
+	inet_naddr_t dest;
+	/** Router address */
+	inet_addr_t router;
+	/** Static route name */
+	char *name;
+} inet_sroute_info_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/include/types/inetping.h
===================================================================
--- uspace/lib/inet/include/types/inetping.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/include/types/inetping.h	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * @brief
+ */
+
+#ifndef _LIBC_TYPES_INETPING_H_
+#define _LIBC_TYPES_INETPING_H_
+
+#include <inet/addr.h>
+#include <stddef.h>
+#include <stdint.h>
+
+typedef struct {
+	inet_addr_t src;
+	inet_addr_t dest;
+	uint16_t seq_no;
+	void *data;
+	size_t size;
+} inetping_sdu_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/inet/meson.build
===================================================================
--- uspace/lib/inet/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,44 @@
+#
+# Copyright (c) 2021 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.
+#
+
+src = files(
+	'src/addr.c',
+	'src/dhcp.c',
+	'src/dnsr.c',
+	'src/endpoint.c',
+	'src/host.c',
+	'src/hostname.c',
+	'src/hostport.c',
+	'src/inet.c',
+	'src/inetcfg.c',
+	'src/inetping.c',
+	'src/iplink.c',
+	'src/iplink_srv.c',
+	'src/tcp.c',
+	'src/udp.c',
+)
Index: uspace/lib/inet/src/addr.c
===================================================================
--- uspace/lib/inet/src/addr.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/addr.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,735 @@
+/*
+ * 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/inet/src/dhcp.c
===================================================================
--- uspace/lib/inet/src/dhcp.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/dhcp.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,97 @@
+/*
+ * 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/inet/src/dnsr.c
===================================================================
--- uspace/lib/inet/src/dnsr.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/dnsr.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,195 @@
+/*
+ * 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/inet/src/endpoint.c
===================================================================
--- uspace/lib/inet/src/endpoint.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/endpoint.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,61 @@
+/*
+ * 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/inet/src/host.c
===================================================================
--- uspace/lib/inet/src/host.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/host.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,245 @@
+/*
+ * 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/inet/src/hostname.c
===================================================================
--- uspace/lib/inet/src/hostname.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/hostname.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,108 @@
+/*
+ * 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/inet/src/hostport.c
===================================================================
--- uspace/lib/inet/src/hostport.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/hostport.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,302 @@
+/*
+ * 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/inet/src/inet.c
===================================================================
--- uspace/lib/inet/src/inet.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/inet.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,258 @@
+/*
+ * 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/inet/src/inetcfg.c
===================================================================
--- uspace/lib/inet/src/inetcfg.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/inetcfg.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,465 @@
+/*
+ * 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/inet/src/inetping.c
===================================================================
--- uspace/lib/inet/src/inetping.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/inetping.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,231 @@
+/*
+ * 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/inet/src/iplink.c
===================================================================
--- uspace/lib/inet/src/iplink.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/iplink.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,308 @@
+/*
+ * 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/inet/src/iplink_srv.c
===================================================================
--- uspace/lib/inet/src/iplink_srv.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/iplink_srv.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,351 @@
+/*
+ * 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;
+}
+
+/** @}
+ */
Index: uspace/lib/inet/src/tcp.c
===================================================================
--- uspace/lib/inet/src/tcp.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/tcp.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,875 @@
+/*
+ * 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/inet/src/udp.c
===================================================================
--- uspace/lib/inet/src/udp.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
+++ uspace/lib/inet/src/udp.c	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -0,0 +1,524 @@
+/*
+ * 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/meson.build
===================================================================
--- uspace/lib/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/lib/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -50,4 +50,6 @@
 libs = [
 	'c',
+
+	'inet',
 
 	'block',
Index: uspace/lib/nettl/meson.build
===================================================================
--- uspace/lib/nettl/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/lib/nettl/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2015 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,4 +27,5 @@
 #
 
+deps = [ 'inet' ]
 src = files(
 	'src/amap.c',
Index: uspace/srv/hid/remcons/meson.build
===================================================================
--- uspace/srv/hid/remcons/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/hid/remcons/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,3 +1,4 @@
 #
+# Copyright (c) 2021 Jiri Svoboda
 # Copyright (c) 2012 Vojtech Horky
 # All rights reserved.
@@ -27,3 +28,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('remcons.c', 'user.c')
Index: uspace/srv/hid/rfb/meson.build
===================================================================
--- uspace/srv/hid/rfb/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/hid/rfb/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,3 +1,4 @@
 #
+# Copyright (c) 2021 Jiri Svoboda
 # Copyright (c) 2013 Martin Sucha
 # All rights reserved.
@@ -27,4 +28,4 @@
 #
 
-deps = [ 'ipcgfx', 'ddev' ]
+deps = [ 'inet', 'ipcgfx', 'ddev' ]
 src = files('main.c', 'rfb.c')
Index: uspace/srv/net/dhcp/meson.build
===================================================================
--- uspace/srv/net/dhcp/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/net/dhcp/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2013 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,4 +27,5 @@
 #
 
+deps = [ 'inet' ]
 src = files(
 	'dhcp.c',
Index: uspace/srv/net/dnsrsrv/meson.build
===================================================================
--- uspace/srv/net/dnsrsrv/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/net/dnsrsrv/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2012 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,4 +27,5 @@
 #
 
+deps = [ 'inet' ]
 src = files(
 	'dns_msg.c',
Index: uspace/srv/net/inetsrv/meson.build
===================================================================
--- uspace/srv/net/inetsrv/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/net/inetsrv/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2012 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,4 +27,5 @@
 #
 
+deps = [ 'inet' ]
 src = files(
 	'addrobj.c',
Index: uspace/srv/net/loopip/meson.build
===================================================================
--- uspace/srv/net/loopip/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/net/loopip/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2012 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('loopip.c')
Index: uspace/srv/net/nconfsrv/meson.build
===================================================================
--- uspace/srv/net/nconfsrv/meson.build	(revision 923bb331744a3cf807459524040e34243096fc5f)
+++ uspace/srv/net/nconfsrv/meson.build	(revision ec7902df3bea37028cfd215b507c5248f4e054dd)
@@ -1,4 +1,4 @@
 #
-# Copyright (c) 2013 Jiri Svoboda
+# Copyright (c) 2021 Jiri Svoboda
 # All rights reserved.
 #
@@ -27,3 +27,4 @@
 #
 
+deps = [ 'inet' ]
 src = files('iplink.c', 'nconfsrv.c')
