Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ boot/Makefile.common	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -112,4 +112,5 @@
 	$(USPACE_PATH)/srv/hid/remcons/remcons \
 	$(USPACE_PATH)/srv/hid/isdv4_tablet/isdv4_tablet \
+	$(USPACE_PATH)/srv/net/dnsres/dnsres \
 	$(USPACE_PATH)/srv/net/ethip/ethip \
 	$(USPACE_PATH)/srv/net/inetsrv/inetsrv \
Index: kernel/arch/amd64/include/arch/debugger.h
===================================================================
--- kernel/arch/amd64/include/arch/debugger.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ kernel/arch/amd64/include/arch/debugger.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2006 Ondrej Palkovsky
+ * 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 amd64debug
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_amd64_DEBUGGER_H_
+#define KERN_amd64_DEBUGGER_H_
+
+#include <typedefs.h>
+
+#define BKPOINTS_MAX  4
+
+/* Flags that are passed to breakpoint_add function */
+#define BKPOINT_INSTR       0x1U
+#define BKPOINT_WRITE       0x2U
+#define BKPOINT_READ_WRITE  0x4U
+
+#define BKPOINT_CHECK_ZERO  0x8U
+
+
+extern void debugger_init(void);
+extern int breakpoint_add(const void *, const unsigned int, int);
+extern void breakpoint_del(int);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/arm32/include/arch/mach/testarm/testarm.h
===================================================================
--- kernel/arch/arm32/include/arch/mach/testarm/testarm.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ kernel/arch/arm32/include/arch/mach/testarm/testarm.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2007 Michal Kebrt
+ * Copyright (c) 2009 Vineeth Pillai
+ * 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 arm32gxemul GXemul
+ *  @brief GXemul machine specific parts.
+ *  @ingroup arm32
+ * @{
+ */
+/** @file
+ *  @brief GXemul peripheries drivers declarations.
+ */
+
+#ifndef KERN_arm32_testarm_H_
+#define KERN_arm32_testarm_H_
+
+#include <arch/machine_func.h>
+
+/** Size of GXemul IRQ number range (starting from 0) */
+#define GXEMUL_IRQ_COUNT	32
+#define GXEMUL_KBD_IRQ		2
+#define GXEMUL_TIMER_IRQ	4
+
+/** Timer frequency */
+#define GXEMUL_TIMER_FREQ  100
+
+#define GXEMUL_KBD_ADDRESS   0x10000000
+#define GXEMUL_MP_ADDRESS    0x11000000
+#define GXEMUL_FB_ADDRESS    0x12000000
+#define GXEMUL_RTC_ADDRESS   0x15000000
+#define GXEMUL_IRQC_ADDRESS  0x16000000
+
+extern void *gxemul_kbd;
+extern void *gxemul_rtc;
+extern void *gxemul_irqc;
+
+#define GXEMUL_HALT_OFFSET        0x010
+#define GXEMUL_RTC_FREQ_OFFSET    0x100
+#define GXEMUL_MP_MEMSIZE_OFFSET  0x090
+#define GXEMUL_RTC_ACK_OFFSET     0x110
+
+extern void gxemul_init(void);
+extern void gxemul_output_init(void);
+extern void gxemul_input_init(void);
+extern void gxemul_timer_irq_start(void);
+extern void gxemul_cpu_halt(void);
+extern void gxemul_irq_exception(unsigned int, istate_t *);
+extern void gxemul_get_memory_extents(uintptr_t *, size_t *);
+extern void gxemul_frame_init(void);
+extern size_t gxemul_get_irq_count(void);
+extern const char *gxemul_get_platform_name(void);
+
+extern struct arm_machine_ops gxemul_machine_ops;
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ia32/include/arch/debugger.h
===================================================================
--- kernel/arch/ia32/include/arch/debugger.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ kernel/arch/ia32/include/arch/debugger.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,1 @@
+../../amd64/include/debugger.h
Index: kernel/genarch/include/genarch/fb/logo-196x66.h
===================================================================
--- kernel/genarch/include/genarch/fb/logo-196x66.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ kernel/genarch/include/genarch/fb/logo-196x66.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2008 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 genarch
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_LOGO_196X66_H_
+#define KERN_LOGO_196X66_H_
+
+#define LOGO_WIDTH   196
+#define LOGO_HEIGHT  66
+#define LOGO_COLOR   0xffffff
+
+#include <typedefs.h>
+
+extern uint32_t fb_logo[LOGO_WIDTH * LOGO_HEIGHT];
+
+#endif
+
+/** @}
+ */
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/Makefile	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -82,4 +82,5 @@
 	srv/devman \
 	srv/loader \
+	srv/net/dnsres \
 	srv/net/ethip \
 	srv/net/inetsrv \
Index: uspace/srv/net/dnsres/Makefile
===================================================================
--- uspace/srv/net/dnsres/Makefile	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/Makefile	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+BINARY = dnsres
+
+SOURCES = \
+	dns_msg.c \
+	dnsres.c \
+	query.c \
+	transport.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/net/dnsres/dns_msg.c
===================================================================
--- uspace/srv/net/dnsres/dns_msg.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/dns_msg.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,210 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <bitops.h>
+#include <byteorder.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <str.h>
+
+#include "dns_msg.h"
+#include "dns_std.h"
+
+#define NAME  "dnsres"
+
+#include <stdio.h>
+static int dns_name_encode(char *name, uint8_t *buf, size_t buf_size,
+    size_t *act_size)
+{
+	size_t off;
+	wchar_t c;
+	size_t lsize;
+	size_t pi, di;
+
+	pi = 0;
+	di = 1;
+	off = 0;
+
+	printf("dns_name_encode(name='%s', buf=%p, buf_size=%zu, act_size=%p\n",
+	    name, buf, buf_size, act_size);
+	lsize = 0;
+	while (true) {
+		printf("off=%zu\n", off);
+		c = str_decode(name, &off, STR_NO_LIMIT);
+		printf("c=%d\n", (int)c);
+		if (c > 127) {
+			/* Non-ASCII character */
+			printf("non-ascii character\n");
+			return EINVAL;
+		}
+
+		if (c == '.' || c == '\0') {
+			/* Empty string, starting with period or two consecutive periods. */
+			if (lsize == 0) {
+				printf("empty token\n");
+				return EINVAL;
+			}
+
+			if (lsize > DNS_LABEL_MAX_SIZE) {
+				/* Label too long */
+				printf("label too long\n");
+				return EINVAL;
+			}
+
+			if (buf != NULL && pi < buf_size)
+				buf[pi] = (uint8_t)lsize;
+
+			lsize = 0;
+			pi = di;
+			++di;
+
+			if (c == '\0')
+				break;
+		} else {
+			if (buf != NULL && di < buf_size)
+				buf[di] = c;
+			++di;
+			++lsize;
+		}
+	}
+
+	if (buf != NULL && pi < buf_size)
+		buf[pi] = 0;
+
+	*act_size = di;
+	return EOK;
+}
+
+static void dns_uint16_t_encode(uint16_t w, uint8_t *buf, size_t buf_size)
+{
+	if (buf != NULL && buf_size >= 1)
+		buf[0] = w >> 8;
+
+	if (buf != NULL && buf_size >= 2)
+		buf[1] = w & 0xff;
+}
+
+static int dns_question_encode(dns_question_t *question, uint8_t *buf,
+    size_t buf_size, size_t *act_size)
+{
+	size_t name_size;
+	size_t di;
+	int rc;
+
+	rc = dns_name_encode(question->qname, buf, buf_size, &name_size);
+	if (rc != EOK)
+		return rc;
+
+	printf("name_size=%zu\n", name_size);
+
+	*act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t);
+	printf("act_size=%zu\n", *act_size);
+	if (buf == NULL)
+		return EOK;
+
+	di = name_size;
+
+	dns_uint16_t_encode(question->qtype, buf + di, buf_size - di);
+	di += sizeof(uint16_t);
+
+	dns_uint16_t_encode(question->qclass, buf + di, buf_size - di);
+	di += sizeof(uint16_t);
+
+	return EOK;
+}
+
+int dns_message_encode(dns_message_t *msg, void **rdata, size_t *rsize)
+{
+	uint8_t *data;
+	size_t size;
+	dns_header_t hdr;
+	size_t q_size;
+	size_t di;
+	int rc;
+
+	hdr.id = host2uint16_t_be(msg->id);
+
+	hdr.opbits = host2uint16_t_be(
+	    (msg->qr << OPB_QR) |
+	    (msg->opcode << OPB_OPCODE_l) |
+	    (msg->aa ? BIT_V(uint16_t, OPB_AA) : 0) |
+	    (msg->tc ? BIT_V(uint16_t, OPB_TC) : 0) |
+	    (msg->rd ? BIT_V(uint16_t, OPB_RD) : 0) |
+	    (msg->ra ? BIT_V(uint16_t, OPB_RA) : 0) |
+	    msg->rcode
+	);
+
+	hdr.qd_count = host2uint16_t_be(list_count(&msg->question));
+	hdr.an_count = 0;
+	hdr.ns_count = 0;
+	hdr.ar_count = 0;
+
+	size = sizeof(dns_header_t);
+	printf("dns header size=%zu\n", size);
+
+	list_foreach(msg->question, link) {
+		dns_question_t *q = list_get_instance(link, dns_question_t, msg);
+		rc = dns_question_encode(q, NULL, 0, &q_size);
+		if (rc != EOK)
+			return rc;
+
+		printf("q_size=%zu\n", q_size);
+		size += q_size;
+	}
+
+	data = calloc(1, size);
+	if (data == NULL)
+		return ENOMEM;
+
+	memcpy(data, &hdr, sizeof(dns_header_t));
+	di = sizeof(dns_header_t);
+
+	list_foreach(msg->question, link) {
+		dns_question_t *q = list_get_instance(link, dns_question_t, msg);
+		rc = dns_question_encode(q, data + di, size - di, &q_size);
+		assert(rc == EOK);
+
+		di += q_size;
+	}
+
+	printf("-> size=%zu, di=%zu\n", size, di);
+	*rdata = data;
+	*rsize = size;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/dns_msg.h
===================================================================
--- uspace/srv/net/dnsres/dns_msg.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/dns_msg.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef DNS_MSG_H
+#define DNS_MSG_H
+
+#include <adt/list.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include "dns_std.h"
+#include "dns_type.h"
+
+extern int dns_message_encode(dns_message_t *, void **, size_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/dns_std.h
===================================================================
--- uspace/srv/net/dnsres/dns_std.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/dns_std.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,143 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file DNS Standard definitions.
+ *
+ * From RFC 1035 Domain Names - Implementation and Specification
+ */
+
+#ifndef DNS_STD_H
+#define DNS_STD_H
+
+#include <stdint.h>
+
+/** From 2.3.4. Size Limits */
+enum dns_limits {
+	DNS_LABEL_MAX_SIZE	= 63,
+	DNS_NAME_MAX_SIZE	= 255,
+	DNS_UDP_MSG_MAX_SIZE	= 512
+};
+
+typedef enum dns_qtype {
+	DTYPE_A		= 1,
+	DTYPE_NS	= 2,
+	DTYPE_MD	= 3,
+	DTYPE_MF	= 4,
+	DTYPE_CNAME	= 5,
+	DTYPE_SOA	= 6,
+	DTYPE_MB	= 7,
+	DTYPE_MG	= 8,
+	DTYPE_MR	= 9,
+	DTYPE_NULL	= 10,
+	DTYPE_WKS	= 11,
+	DTYPE_PTR	= 12,
+	DTYPE_HINFO	= 13,
+	DTYPE_MINFO	= 14,
+	DTYPE_MX	= 15,
+	DTYPE_TXT	= 16,
+	DQTYPE_AXFR	= 252,
+	DQTYPE_MAILB	= 253,
+	DQTYPE_MAILA	= 254,
+	DQTYPE_ALL	= 255
+} dns_type_t, dns_qtype_t;
+
+typedef enum dns_qclass {
+	/** Internet */
+	DC_IN		= 1,
+	/** CSNET */
+	DC_CS		= 2,
+	/** CHAOS */
+	DC_CH		= 3,
+	/** Hesiod */
+	DC_HS		= 4,
+	/** Any class */
+	DQC_ANY		= 255
+} dns_class_t, dns_qclass_t;
+
+typedef struct {
+	/** Identifier assigned by the query originator */
+	uint16_t id;
+	/** QR, Opcode, AA, TC,RD, RA, Z, Rcode */
+	uint16_t opbits;
+	/** Number of entries in query section */
+	uint16_t qd_count;
+	/** Number of RRs in the answer section */
+	uint16_t an_count;
+	/** Number of name server RRs in the authority records section */
+	uint16_t ns_count;
+	/** Number of RRs in the additional records section */
+	uint16_t ar_count;
+} dns_header_t;
+
+/** Bits in dns_header_t.opbits.
+ *
+ * Note that bit numbers in RFC 1035 are reversed (0 is the most significant)
+ * but we use the standard notation (0 is the least significant).
+ */
+enum dns_opbits {
+	OPB_QR 		= 15,
+	OPB_OPCODE_h	= 14,
+	OPB_OPCODE_l	= 11,
+	OPB_AA		= 10,
+	OPB_TC		= 9,
+	OPB_RD		= 8,
+	OPB_RA		= 7,
+	OPB_Z_h		= 6,
+	OPB_Z_l		= 4,
+	OPB_RCODE_h	= 3,
+	OPB_RCODE_l	= 0
+};
+
+typedef enum dns_query_response {
+	QR_QUERY	= 0,
+	QR_RESPONSE	= 1
+} dns_query_response_t;
+
+typedef enum dns_opcode {
+	OPC_QUERY	= 0,
+	OPC_IQUERY	= 1,
+	OPC_STATUS	= 2
+} dns_opcode_t;
+
+typedef enum dns_rcode {
+	RC_OK		= 0,
+	RC_FMT_ERR	= 1,
+	RC_SRV_FAIL	= 2,
+	RC_NAME_ERR	= 3,
+	RC_NOT_IMPL	= 4,
+	RC_REFUSED	= 5
+} dns_rcode_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/dns_type.h
===================================================================
--- uspace/srv/net/dnsres/dns_type.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/dns_type.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,104 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef DNS_TYPE_H
+#define DNS_TYPE_H
+
+#include <adt/list.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include "dns_std.h"
+
+/** Unencoded DNS message */
+typedef struct {
+	/** Identifier */
+	uint16_t id;
+	/** Query or Response */
+	dns_query_response_t qr;
+	/** Opcode */
+	dns_opcode_t opcode;
+	/** Authoritative Answer */
+	bool aa;
+	/** TrunCation */
+	bool tc;
+	/** Recursion Desired */
+	bool rd;
+	/** Recursion Available */
+	bool ra;
+	/** Response Code */
+	dns_rcode_t rcode;
+
+	list_t question; /* of dns_question_t */
+	list_t answer; /* of dns_rr_t */
+	list_t authority; /* of dns_rr_t */
+	list_t additional; /* of dns_rr_t */
+} dns_message_t;
+
+/** Unencoded DNS message question section */
+typedef struct {
+	link_t msg;
+	/** Domain name in text format (dot notation) */
+	char *qname;
+	/** Query type */
+	dns_qtype_t qtype;
+	/** Query class */
+	dns_qclass_t qclass;
+} dns_question_t;
+
+/** Unencoded DNS resource record */
+typedef struct {
+	/** Domain name */
+	char *name;
+	/** RR type */
+	dns_type_t rtype;
+	/** Class of data */
+	dns_class_t rclass;
+	/** Time to live */
+	uint32_t ttl;
+
+	/** Resource data */
+	void *rdata;
+	/** Number of bytes in @c *rdata */
+	size_t rdata_size;
+} dns_rr_t;
+
+/** Host information */
+typedef struct {
+} dns_host_info_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/dnsres.c
===================================================================
--- uspace/srv/net/dnsres/dnsres.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/dnsres.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,58 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "dns_msg.h"
+#include "dns_std.h"
+#include "query.h"
+
+#define NAME  "dnsres"
+
+int main(int argc, char *argv[])
+{
+	dns_host_info_t hinfo;
+	int rc;
+
+	printf("%s: DNS Resolution Service\n", NAME);
+	rc = dns_name2host("helenos.org", &hinfo);
+	printf("dns_name2host() -> rc = %d\n", rc);
+
+	return 0;
+}
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/query.c
===================================================================
--- uspace/srv/net/dnsres/query.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/query.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,78 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <errno.h>
+#include <mem.h>
+
+#include "dns_std.h"
+#include "dns_type.h"
+#include "query.h"
+#include "transport.h"
+
+static uint16_t msg_id;
+
+int dns_name2host(const char *name, dns_host_info_t *info)
+{
+	dns_message_t msg;
+	dns_message_t *amsg;
+	dns_question_t question;
+	int rc;
+
+	question.qname = (char *)name;
+	question.qtype = DTYPE_A;
+	question.qclass = DC_IN;
+
+	memset(&msg, 0, sizeof(msg));
+
+	list_initialize(&msg.question);
+	list_append(&question.msg, &msg.question);
+
+	msg.id = msg_id++;
+	msg.qr = QR_QUERY;
+	msg.opcode = OPC_QUERY;
+	msg.aa = false;
+	msg.tc = false;
+	msg.rd = true;
+	msg.ra = false;
+
+	rc = dns_request(&msg, &amsg);
+	if (rc != EOK)
+		return rc;
+
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/query.h
===================================================================
--- uspace/srv/net/dnsres/query.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/query.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,46 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef QUERY_H
+#define QUERY_H
+
+#include "dns_type.h"
+
+extern int dns_name2host(const char *, dns_host_info_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/transport.c
===================================================================
--- uspace/srv/net/dnsres/transport.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/transport.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,104 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <errno.h>
+#include <net/in.h>
+#include <net/inet.h>
+#include <net/socket.h>
+#include <stdlib.h>
+
+#include "dns_msg.h"
+#include "dns_type.h"
+#include "transport.h"
+
+#include <stdio.h>
+int dns_request(dns_message_t *req, dns_message_t **rresp)
+{
+	dns_message_t *resp;
+	int rc;
+	void *req_data;
+	size_t req_size;
+	struct sockaddr_in addr;
+	struct sockaddr_in laddr;
+	int fd;
+
+	addr.sin_family = AF_INET;
+	addr.sin_port = htons(53);
+	addr.sin_addr.s_addr = htonl((10 << 24) | (0 << 16) | (0 << 8) | 138);
+
+	laddr.sin_family = AF_INET;
+	laddr.sin_port = htons(12345);
+	laddr.sin_addr.s_addr = INADDR_ANY;
+
+	req_data = NULL;
+	fd = -1;
+
+	rc = dns_message_encode(req, &req_data, &req_size);
+	if (rc != EOK)
+		goto error;
+
+	fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+	if (fd < 0) {
+		rc = EIO;
+		goto error;
+	}
+
+	rc = bind(fd, (struct sockaddr *)&laddr, sizeof(laddr));
+	if (rc != EOK)
+		goto error;
+
+	printf("fd=%d req_data=%p, req_size=%zu\n", fd, req_data, req_size);
+	rc = sendto(fd, req_data, req_size, 0, (struct sockaddr *)&addr,
+	    sizeof(addr));
+	if (rc != EOK)
+		goto error;
+
+	closesocket(fd);
+	free(req_data);
+
+	resp = NULL;
+	*rresp = resp;
+	return EOK;
+
+error:
+	if (req_data != NULL)
+		free(req_data);
+	if (fd >= 0)
+		closesocket(fd);
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/transport.h
===================================================================
--- uspace/srv/net/dnsres/transport.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
+++ uspace/srv/net/dnsres/transport.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -0,0 +1,46 @@
+/*
+ * 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 dnsres
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef TRANSPORT_H
+#define TRANSPORT_H
+
+#include "dns_type.h"
+
+extern int dns_request(dns_message_t *, dns_message_t **);
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/inetsrv/addrobj.c
===================================================================
--- uspace/srv/net/inetsrv/addrobj.c	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/inetsrv/addrobj.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -221,5 +221,5 @@
 
 	lsrc_addr.ipv4 = addr->naddr.ipv4;
-	ldest_addr = &dgram->dest;
+	ldest_addr = ldest;
 
 	return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest_addr, dgram,
Index: uspace/srv/net/inetsrv/inetsrv.c
===================================================================
--- uspace/srv/net/inetsrv/inetsrv.c	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/inetsrv/inetsrv.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -98,5 +98,17 @@
 	}
 	
-	rc = inet_link_discovery_start();
+	inet_sroute_t *sroute = inet_sroute_new();
+	if (sroute == NULL) {
+		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed creating default route (%d).", rc);
+		return ENOMEM;
+	}
+
+	sroute->dest.ipv4 = 0;
+	sroute->dest.bits = 0;
+	sroute->router.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 1;
+	sroute->name = str_dup("default");
+	inet_sroute_add(sroute);
+
+       	rc = inet_link_discovery_start();
 	if (rc != EOK)
 		return EEXIST;
Index: uspace/srv/net/udp/assoc.c
===================================================================
--- uspace/srv/net/udp/assoc.c	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/udp/assoc.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -279,7 +279,13 @@
 
 	fibril_mutex_lock(&assoc->lock);
-	while (list_empty(&assoc->rcv_queue)) {
+	while (list_empty(&assoc->rcv_queue) && !assoc->reset) {
 		log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting");
 		fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock);
+	}
+
+	if (assoc->reset) {
+		log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset");
+		fibril_mutex_unlock(&assoc->lock);
+		return ECONNABORTED;
 	}
 
@@ -323,4 +329,17 @@
 }
 
+/** Reset association.
+ *
+ * This causes any pendingreceive operations to return immediately with
+ * UDP_ERESET.
+ */
+void udp_assoc_reset(udp_assoc_t *assoc)
+{
+	fibril_mutex_lock(&assoc->lock);
+	assoc->reset = true;
+	fibril_condvar_broadcast(&assoc->rcv_queue_cv);
+	fibril_mutex_unlock(&assoc->lock);
+}
+
 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp,
     udp_msg_t *msg)
Index: uspace/srv/net/udp/assoc.h
===================================================================
--- uspace/srv/net/udp/assoc.h	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/udp/assoc.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -51,5 +51,5 @@
 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *);
 extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *);
-
+extern void udp_assoc_reset(udp_assoc_t *);
 
 #endif
Index: uspace/srv/net/udp/sock.c
===================================================================
--- uspace/srv/net/udp/sock.c	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/udp/sock.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -537,5 +537,5 @@
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()");
 	int socket_id = SOCKET_GET_SOCKET_ID(call);
-	
+
 	socket_core_t *sock_core =
 	    socket_cores_find(&client->sockets, socket_id);
@@ -544,17 +544,28 @@
 		return;
 	}
-	
+
 	udp_sockdata_t *socket =
 	    (udp_sockdata_t *) sock_core->specific_data;
 	fibril_mutex_lock(&socket->lock);
-	
+
+	fibril_mutex_lock(&socket->recv_buffer_lock);
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - set socket->sock_core = NULL");
+	socket->sock_core = NULL;
+	fibril_mutex_unlock(&socket->recv_buffer_lock);
+
+	udp_uc_reset(socket->assoc);
+
 	int rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,
 	    udp_free_sock_data);
 	if (rc != EOK) {
+		log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - socket_destroy failed");
 		fibril_mutex_unlock(&socket->lock);
 		async_answer_0(callid, rc);
 		return;
 	}
-	
+
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv");
+	fibril_condvar_broadcast(&socket->recv_buffer_cv);
+
 	fibril_mutex_unlock(&socket->lock);
 	async_answer_0(callid, EOK);
@@ -582,8 +593,9 @@
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril()");
 
+	fibril_mutex_lock(&sock->recv_buffer_lock);
+
 	while (true) {
 		log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()");
-		fibril_mutex_lock(&sock->recv_buffer_lock);
-		while (sock->recv_buffer_used != 0) {
+		while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) {
 			fibril_condvar_wait(&sock->recv_buffer_cv,
 			    &sock->recv_buffer_lock);
@@ -594,10 +606,16 @@
 		    UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock);
 		sock->recv_error = urc;
+
+		log_msg(LOG_DEFAULT, LVL_DEBUG, "[] udp_uc_receive -> %d", urc);
+
+		if (sock->sock_core != NULL)
+			udp_sock_notify_data(sock->sock_core);
+
 		
 		udp_sock_notify_data(sock->sock_core);
 		
 		if (urc != UDP_EOK) {
+			log_msg(LOG_DEFAULT, LVL_DEBUG, "[] urc != UDP_EOK, break");
 			fibril_condvar_broadcast(&sock->recv_buffer_cv);
-			fibril_mutex_unlock(&sock->recv_buffer_lock);
 			break;
 		}
@@ -606,9 +624,12 @@
 		
 		sock->recv_buffer_used = rcvd;
-		fibril_mutex_unlock(&sock->recv_buffer_lock);
 		fibril_condvar_broadcast(&sock->recv_buffer_cv);
 	}
 
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop");
+	fibril_mutex_unlock(&sock->recv_buffer_lock);
 	udp_uc_destroy(sock->assoc);
+
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() terminated");
 
 	return 0;
Index: uspace/srv/net/udp/ucall.c
===================================================================
--- uspace/srv/net/udp/ucall.c	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/udp/ucall.c	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -113,5 +113,12 @@
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: udp_uc_receive()", assoc->name);
 	rc = udp_assoc_recv(assoc, &msg, fsock);
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv -> %d", rc);
 	switch (rc) {
+	case EOK:
+		break;
+	case ECONNABORTED:
+		return UDP_ERESET;
+	default:
+		assert(false);
 	}
 
@@ -133,6 +140,12 @@
 {
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_destroy()");
+	udp_assoc_reset(assoc);
 	udp_assoc_remove(assoc);
 	udp_assoc_delete(assoc);
+}
+
+void udp_uc_reset(udp_assoc_t *assoc)
+{
+	udp_assoc_reset(assoc);
 }
 
Index: uspace/srv/net/udp/ucall.h
===================================================================
--- uspace/srv/net/udp/ucall.h	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/udp/ucall.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -49,4 +49,5 @@
 extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *);
 extern void udp_uc_destroy(udp_assoc_t *);
+extern void udp_uc_reset(udp_assoc_t *);
 
 #endif
Index: uspace/srv/net/udp/udp_type.h
===================================================================
--- uspace/srv/net/udp/udp_type.h	(revision 289cb7dde5a430de83c0f30f460de47fb564b1fd)
+++ uspace/srv/net/udp/udp_type.h	(revision 25eec4ef881169ce578448db432876964eb8d2f4)
@@ -51,5 +51,7 @@
 	UDP_EUNSPEC,
 	/* No route to destination */
-	UDP_ENOROUTE
+	UDP_ENOROUTE,
+	/** Association reset by user */
+	UDP_ERESET
 } udp_error_t;
 
@@ -119,4 +121,7 @@
 	udp_sockpair_t ident;
 
+	/** True if association was reset by user */
+	bool reset;
+
 	/** True if association was deleted by user */
 	bool deleted;
