Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 75b9c3d212f00dc65be3fb483d603337b0f43e5e)
+++ boot/Makefile.common	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
@@ -106,4 +106,5 @@
 	$(USPACE_PATH)/srv/fs/ext2fs/ext2fs \
 	$(USPACE_PATH)/srv/hid/remcons/remcons \
+	$(USPACE_PATH)/srv/net/dnsres/dnsres \
 	$(USPACE_PATH)/srv/net/ethip/ethip \
 	$(USPACE_PATH)/srv/net/inetsrv/inetsrv \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 75b9c3d212f00dc65be3fb483d603337b0f43e5e)
+++ uspace/Makefile	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
@@ -76,4 +76,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 d23d9119be96383551c90916c62b0c4d1ef5493c)
+++ uspace/srv/net/dnsres/Makefile	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
@@ -0,0 +1,35 @@
+#
+# 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 = \
+	dnsres.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/net/dnsres/dns_msg.h
===================================================================
--- uspace/srv/net/dnsres/dns_msg.h	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
+++ uspace/srv/net/dnsres/dns_msg.h	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
@@ -0,0 +1,99 @@
+/*
+ * 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 <bool.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 {
+	/** 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;
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/net/dnsres/dns_std.h
===================================================================
--- uspace/srv/net/dnsres/dns_std.h	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
+++ uspace/srv/net/dnsres/dns_std.h	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
@@ -0,0 +1,137 @@
+/*
+ * 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 {
+	uint16_t id;
+	uint16_t opbits;
+	uint16_t qd_count;
+	uint16_t an_count;
+	uint16_t ns_count;
+	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,
+	QPB_OPCODE_h	= 14,
+	QPB_OPCODE_l	= 11,
+	QPB_AA		= 10,
+	QPB_TC		= 9,
+	QPB_RD		= 8,
+	QPB_RA		= 7,
+	QPB_Z_h		= 6,
+	QPB_Z_l		= 4,
+	QPB_RCODE_h	= 3,
+	QPB_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/dnsres.c
===================================================================
--- uspace/srv/net/dnsres/dnsres.c	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
+++ uspace/srv/net/dnsres/dnsres.c	(revision d23d9119be96383551c90916c62b0c4d1ef5493c)
@@ -0,0 +1,41 @@
+/*
+ * 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 <stdio.h>
+#include <errno.h>
+
+#include "dns_msg.h"
+#include "dns_std.h"
+
+#define NAME  "dnsres"
+
+int main(int argc, char *argv[])
+{
+	printf("%s: DNS Resolution Service\n", NAME);
+	return 0;
+}
