BIND 10 master, updated. 4973e638d354d8b56dcadf71123ef23c15662021 [master] Merge branch 'trac1870'

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 8 21:10:31 UTC 2012


The branch, master has been updated
       via  4973e638d354d8b56dcadf71123ef23c15662021 (commit)
       via  0d4a6b6be1e6ba8b3b5681b5c3be7c86d56c076f (commit)
       via  686eb4e9edb4adee0cee357762fe9448fb0cb6bd (commit)
       via  274eddb40bacdf8d5933058e33b7d469cb9258c2 (commit)
       via  f00da76cb77226e6a6b7487f6c5c0bc62d0c3f48 (commit)
       via  75ee32436fa5bae4a8f15e25e587d94bf41a59fd (commit)
       via  ef8ecac02aa21192fb4af8d573daa11b09b3685a (commit)
       via  8f7c28971b48c4ee0ab89a3f88d84c4b6fed8185 (commit)
       via  5bc38109a4c2775a2a2a8389023836facfe8400d (commit)
       via  27e2b20fc709884a145df81553504bfc90b8d539 (commit)
       via  805fda7d95ada6af81f17fca2816b3a1fe4a3008 (commit)
       via  370861e432e88669b2382954b15dbecf1672e032 (commit)
      from  d41d8af0c726bb923a48948feb6a8f4f6775ea3e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4973e638d354d8b56dcadf71123ef23c15662021
Merge: d41d8af 0d4a6b6
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Oct 8 14:02:58 2012 -0700

    [master] Merge branch 'trac1870'

-----------------------------------------------------------------------

Summary of changes:
 configure.ac                            |    1 -
 NEWS => examples/AUTHORS                |    0
 COPYING => examples/COPYING             |    8 +-
 NEWS => examples/ChangeLog              |    0
 examples/INSTALL                        |    9 +++
 examples/Makefile.am                    |    4 +
 NEWS => examples/NEWS                   |    0
 examples/README                         |   32 ++++++++
 examples/configure.ac                   |   28 +++++++
 {src/bin => examples}/host/.gitignore   |    0
 examples/host/Makefile.am               |    6 ++
 {src/bin => examples}/host/README       |    0
 {src/bin => examples}/host/b10-host.xml |    0
 {src/bin => examples}/host/host.cc      |    0
 examples/m4/ax_boost_include.m4         |   64 ++++++++++++++++
 examples/m4/ax_isc_bind10.m4            |  122 +++++++++++++++++++++++++++++++
 src/bin/Makefile.am                     |    2 +-
 src/bin/host/Makefile.am                |   37 ----------
 src/lib/dns/Makefile.am                 |    2 +-
 src/lib/util/Makefile.am                |    3 +
 20 files changed, 271 insertions(+), 47 deletions(-)
 copy NEWS => examples/AUTHORS (100%)
 copy COPYING => examples/COPYING (68%)
 copy NEWS => examples/ChangeLog (100%)
 create mode 100644 examples/INSTALL
 create mode 100644 examples/Makefile.am
 copy NEWS => examples/NEWS (100%)
 create mode 100644 examples/README
 create mode 100644 examples/configure.ac
 rename {src/bin => examples}/host/.gitignore (100%)
 create mode 100644 examples/host/Makefile.am
 rename {src/bin => examples}/host/README (100%)
 rename {src/bin => examples}/host/b10-host.xml (100%)
 rename {src/bin => examples}/host/host.cc (100%)
 create mode 100644 examples/m4/ax_boost_include.m4
 create mode 100644 examples/m4/ax_isc_bind10.m4
 delete mode 100644 src/bin/host/Makefile.am

-----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index c6a2f01..c54161e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1099,7 +1099,6 @@ AC_CONFIG_FILES([Makefile
                  src/bin/dbutil/Makefile
                  src/bin/dbutil/tests/Makefile
                  src/bin/dbutil/tests/testdata/Makefile
-                 src/bin/host/Makefile
                  src/bin/loadzone/Makefile
                  src/bin/loadzone/tests/correct/Makefile
                  src/bin/loadzone/tests/error/Makefile
diff --git a/examples/AUTHORS b/examples/AUTHORS
new file mode 100644
index 0000000..e69de29
diff --git a/examples/COPYING b/examples/COPYING
new file mode 100644
index 0000000..f3febbe
--- /dev/null
+++ b/examples/COPYING
@@ -0,0 +1,13 @@
+Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/examples/ChangeLog b/examples/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/examples/INSTALL b/examples/INSTALL
new file mode 100644
index 0000000..43436c2
--- /dev/null
+++ b/examples/INSTALL
@@ -0,0 +1,9 @@
+If using git (not the tarball), build the "configure" file:
+    autoreconf --install
+
+To then build from source:
+    ./configure
+    make
+
+You may have to specify the location of BIND 10 header files and
+library objects.  See configure options by ./configure --help.
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
index 0000000..ef437eb
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,4 @@
+SUBDIRS = host
+
+# Make sure macros under m4 will be included
+ACLOCAL_AMFLAGS = -I m4
diff --git a/examples/NEWS b/examples/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000..12dbbba
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,32 @@
+This is the top directory for sample programs that can be developed
+using public BIND 10 libraries outside of the BIND 10 project.  It's
+intended to be built with installed BIND 10 header files and library
+objects, so it's not a target of the main build tree, and does not
+refer to any other part of the BIND 10 source tree that contains
+this directory.
+
+On the top (sub) directory (where this README file is stored), we
+provide a sample configure.ac and Makefile.am files for GNU automake
+environments with helper autoconf macros to detect the available and
+location of BIND 10 header files and library objects.
+
+You can use the configure.ac and Makefile.am files with macros under
+the "m4" subdirectory as a template for your own project.  The key is
+to call the AX_ISC_BIND10 function (as the sample configure.ac does)
+from your configure.ac.  Then it will check the availability of
+necessary stuff and set some corresponding AC variables.  You can then
+use the resulting variables in your Makefile.in or Makefile.ac.
+
+If you use automake, don't forget adding the following line to the top
+level Makefile.am:
+
+ACLOCAL_AMFLAGS = -I m4
+
+This is necessary to incorporate the helper macro definitions.
+
+If you don't use automake but autoconf, make sure to add the following
+to the configure.ac file:
+
+sinclude(m4/ax_boost_include.m4)
+sinclude(m4/ax_isc_bind10.m4)
+(and same for other m4 files as they are added under m4/)
diff --git a/examples/configure.ac b/examples/configure.ac
new file mode 100644
index 0000000..9379687
--- /dev/null
+++ b/examples/configure.ac
@@ -0,0 +1,28 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.59])
+AC_INIT(bind10-examples, 20120817, bind10-dev at isc.org)
+AC_CONFIG_SRCDIR([README])
+AM_INIT_AUTOMAKE
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
+AC_PROG_CXX
+AC_LANG([C++])
+
+# Checks for BIND 10 headers and libraries
+AX_ISC_BIND10
+
+# For the example host program, we require the BIND 10 DNS library
+if test "x$BIND10_DNS_LIB" = "x"; then
+   AC_MSG_ERROR([unable to find BIND 10 DNS library needed to build 'host'])
+fi
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+
+AC_CONFIG_FILES([Makefile
+                 host/Makefile])
+
+AC_OUTPUT
diff --git a/examples/host/.gitignore b/examples/host/.gitignore
new file mode 100644
index 0000000..01ef357
--- /dev/null
+++ b/examples/host/.gitignore
@@ -0,0 +1,2 @@
+/b10-host
+/b10-host.1
diff --git a/examples/host/Makefile.am b/examples/host/Makefile.am
new file mode 100644
index 0000000..dbd57a2
--- /dev/null
+++ b/examples/host/Makefile.am
@@ -0,0 +1,6 @@
+AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(BIND10_CPPFLAGS)
+
+bin_PROGRAMS = b10-host
+b10_host_SOURCES = host.cc
+b10_host_LDFLAGS = ${BIND10_LDFLAGS}
+b10_host_LDADD = ${BIND10_DNS_LIB}
diff --git a/examples/host/README b/examples/host/README
new file mode 100644
index 0000000..5cc4068
--- /dev/null
+++ b/examples/host/README
@@ -0,0 +1,4 @@
+Rewriting host(1) in C++ from scratch using BIND 10's libdns++.
+
+The bugs and incompatibilities are listed in the manual page
+and in the source code.
diff --git a/examples/host/b10-host.xml b/examples/host/b10-host.xml
new file mode 100644
index 0000000..a17ef67
--- /dev/null
+++ b/examples/host/b10-host.xml
@@ -0,0 +1,196 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+               "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
+	       [<!ENTITY mdash "—">]>
+<!--
+ - Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+ -
+ - Permission to use, copy, modify, and/or distribute this software for any
+ - purpose with or without fee is hereby granted, provided that the above
+ - copyright notice and this permission notice appear in all copies.
+ -
+ - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ - AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ - PERFORMANCE OF THIS SOFTWARE.
+-->
+
+<!-- $Id$ -->
+<refentry>
+
+  <refentryinfo>
+    <date>May 4, 2011</date>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>b10-host</refentrytitle>
+    <manvolnum>1</manvolnum>
+    <refmiscinfo>BIND10</refmiscinfo>
+  </refmeta>
+
+  <refnamediv>
+    <refname>b10-host</refname>
+    <refpurpose>DNS lookup utility</refpurpose>
+  </refnamediv>
+
+  <docinfo>
+    <copyright>
+      <year>2011</year>
+      <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
+    </copyright>
+  </docinfo>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>b10-host</command>
+      <arg><option>-a</option></arg>
+      <arg><option>-c <replaceable>class</replaceable></option></arg>
+      <arg><option>-d</option></arg>
+      <arg><option>-p <replaceable>port</replaceable></option></arg>
+      <arg><option>-r</option></arg>
+      <arg><option>-t <replaceable>type</replaceable></option></arg>
+      <arg><option>-v</option></arg>
+      <arg><replaceable>name</replaceable></arg>
+      <arg><option><replaceable>server</replaceable></option></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>DESCRIPTION</title>
+    <para>
+      The <command>b10-host</command> utility does DNS lookups.
+      Its initial goal is to be a
+      <citerefentry><refentrytitle>host</refentrytitle>
+        <manvolnum>1</manvolnum></citerefentry>
+      clone, but also add a few features useful for BIND 10 development
+      testing.
+    </para>
+
+    <para>
+      By default, it looks up the A, AAAA, and MX record sets for the
+      <replaceable>name</replaceable>.
+      Optionally, you may select a name server to query against by adding
+      the <replaceable>server</replaceable> argument.
+    </para>
+  </refsect1>
+
+  <refsect1>
+    <title>OPTIONS</title>
+
+    <para>The arguments are as follows:</para>
+
+    <variablelist>
+
+      <varlistentry>
+        <term><option>-a</option></term>
+        <listitem><para>
+          Enable verbose mode and do a query for type ANY.
+          (If the <option>-t</option> option is also set, then the
+          ANY query is not done, but it still uses verbose mode.)
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>-c <replaceable>class</replaceable></option></term>
+        <listitem><para>
+          Define the class for the query.
+          The default is IN (Internet).
+<!-- TODO: bug if class is unknown causes seg fault and possible core dump -->
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>-d</option></term>
+        <listitem><para>
+	  Enable verbose output mode, including elapsed time in
+	  milliseconds.
+          Verbose mode shows the header, question, answer, authority,
+          and additional sections (if provided).
+          (Same as <option>-v</option>.)
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>-p <replaceable>port</replaceable></option></term>
+        <listitem><para>
+          Select an alternative port for the query.
+          This may be a number or a service name.
+          The default is 53 (domain).
+          This is not a standard feature of
+          <citerefentry><refentrytitle>host</refentrytitle>
+            <manvolnum>1</manvolnum></citerefentry>.
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>-r</option></term>
+        <listitem><para>
+          Disable recursive processing by not setting the
+          Recursion Desired flag in the query.
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>-t <replaceable>type</replaceable></option></term>
+        <listitem><para>
+          Select a specific resource record type for the query.
+          By default, it looks up the A, AAAA, and MX record sets.
+<!-- TODO: bug if class is unknown causes seg fault and possible core dump -->
+          (This overrides the <option>-a</option> option.)
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>-v</option></term>
+        <listitem><para>
+	  Same as <option>-d</option> option.
+        </para></listitem>
+      </varlistentry>
+
+    </variablelist>
+
+  </refsect1>
+
+  <refsect1>
+    <title>COMPATIBILITY / BUGS</title>
+    <para>
+      <command>b10-host</command> does not do reverse lookups by
+      default yet (by detecting if name is a IPv4 or IPv6 address).
+    </para>
+
+    <para>
+      Unknown <option>-c</option> class or <option>-t</option> type
+      causes <command>b10-host</command> to Abort.
+    </para>
+
+    <para>
+      Not all types are supported yet for formatting.
+      Not all switches are supported yet.
+    </para>
+
+    <para>
+      It doesn't use <filename>/etc/resolv.conf</filename> at this time.
+      The default name server used is 127.0.0.1.
+    </para>
+
+    <para>
+      <option>-p</option> is not a standard feature.
+    </para>
+  </refsect1>
+
+  <refsect1>
+    <title>HISTORY</title>
+    <para>
+      The C++ version of <command>b10-host</command> was started in
+      October 2009 by Jeremy C. Reed of ISC.
+      Its usage and output were based on the standard <command>host</command>
+      command.
+    </para>
+  </refsect1>
+</refentry><!--
+ - Local variables:
+ - mode: sgml
+ - End:
+-->
diff --git a/examples/host/host.cc b/examples/host/host.cc
new file mode 100644
index 0000000..a5c6522
--- /dev/null
+++ b/examples/host/host.cc
@@ -0,0 +1,253 @@
+// Copyright (C) 2010-2011  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+// host rewritten in C++ using BIND 10 DNS library
+
+#include <arpa/inet.h>
+#include <netdb.h>          // for getaddrinfo
+#include <sys/time.h>       // for gettimeofday
+#include <sys/socket.h>     // networking functions and definitions on FreeBSD
+
+#include <unistd.h>
+
+#include <string>
+#include <iostream>
+
+#include <util/buffer.h>
+
+#include <dns/name.h>
+#include <dns/message.h>
+#include <dns/messagerenderer.h>
+#include <dns/opcode.h>
+#include <dns/rcode.h>
+#include <dns/rrclass.h>
+#include <dns/rrtype.h>
+#include <dns/rrset.h>
+#include <dns/message.h>
+
+using namespace std;
+using namespace isc::dns;
+using namespace isc::util;
+
+namespace {
+char* dns_type = NULL;    // not set, so A, AAAA, MX
+const char* server = "127.0.0.1";
+const char* server_port = "53";
+const char* dns_class  = "IN";
+bool verbose = false;
+bool dns_any = false;
+int first_time = 1;
+bool recursive_bit = true;
+struct timeval before_time, after_time;
+
+int
+host_lookup(const char* const name, const char* const dns_class,
+            const char* const type, bool any) {
+
+    Message msg(Message::RENDER);
+
+    msg.setQid(0); // does this matter?
+
+    // TODO: add switch for this
+    msg.setOpcode(Opcode::QUERY());
+    msg.setRcode(Rcode::NOERROR());
+    if (recursive_bit) {
+        msg.setHeaderFlag(Message::HEADERFLAG_RD); // set recursive bit
+    }
+
+    msg.addQuestion(Question(Name(name),
+                             RRClass(dns_class),
+                             any ? RRType::ANY() : RRType(type)));  // if NULL then:
+
+    MessageRenderer renderer;
+    msg.toWire(renderer);
+
+    struct addrinfo hints, *res;
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_DGRAM;
+    hints.ai_flags = 0; // not using AI_NUMERICHOST in case to bootstrap
+    if (getaddrinfo(server, server_port, &hints, &res) != 0) {
+        cerr << "address/port conversion for " << server << ":"
+             << server_port << " failed" << endl;
+        return (1);
+    }
+
+    if (verbose) {
+        cout << "Trying \"" << name << "\"\n";
+    }
+
+    if (verbose && first_time) {
+        // this is only output the first time
+        first_time = 0;
+        cout << "Using domain server:\n";
+        cout << "Name: " << server << "\n";
+        // TODO: I guess I have to do a lookup to get that address and aliases
+        // too
+        //cout << "Address: " << address << "\n" ; // "#" << port << "\n";
+        //cout << "Aliases: " << server << "\n";
+    }
+
+    int s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+
+    if (s < 0) {
+        cerr << "failed to open socket" << endl;
+        return (1);
+    }
+
+    if (verbose) {
+        gettimeofday(&before_time, NULL);
+    }
+
+    sendto(s, renderer.getData(), renderer.getLength(), 0, res->ai_addr,
+           res->ai_addrlen);
+
+    struct sockaddr_storage ss;
+    struct sockaddr* sa;
+    socklen_t sa_len;
+
+    sa_len = sizeof(ss);
+    sa = static_cast<struct sockaddr*>((void*)&ss);
+
+    char recvbuf[4096];
+    int cc;
+    if ((cc = recvfrom(s, recvbuf, sizeof(recvbuf), 0, sa, &sa_len)) > 0) {
+        try {
+            Message rmsg(Message::PARSE);
+            InputBuffer ibuffer(recvbuf, cc);
+
+            rmsg.fromWire(ibuffer);
+            if (!verbose) {
+                string description = "";
+                for (RRsetIterator it =
+                         rmsg.beginSection(Message::SECTION_ANSWER);
+                     it != rmsg.endSection(Message::SECTION_ANSWER);
+                     ++it) {
+
+                      if ((*it)->getType() == RRType::A()) {
+                          description = "has address";
+                      }
+                      else if ((*it)->getType() == RRType::AAAA()) {
+                          description = "has IPv6 address";
+                      }
+                      else if ((*it)->getType() == RRType::MX()) {
+                          description = "mail is handled by";
+                      }
+                      else if ((*it)->getType() == RRType::TXT()) {
+                          description = "descriptive text";
+                      }
+
+                      RdataIteratorPtr rit = (*it)->getRdataIterator();
+                      for (; !rit->isLast(); rit->next()) {
+                          // instead of using my name, maybe use returned label?
+                          cout << name << " "  << description << " " <<
+                              (*rit).getCurrent().toText() << endl;
+                      }
+                  }
+            } else {
+                gettimeofday(&after_time, NULL);
+
+                // HEADER and QUESTION, ANSWER, AUTHORITY, and ADDITIONAL
+                std::cout << rmsg.toText() << std::endl;
+
+                if (before_time.tv_usec > after_time.tv_usec) {
+                    after_time.tv_usec += 1000000;
+                    --after_time.tv_sec;
+                }
+
+                int elapsed_time =
+                    (after_time.tv_sec - before_time.tv_sec)
+                    + ((after_time.tv_usec - before_time.tv_usec))/1000;
+
+                // TODO: if NXDOMAIN, host(1) doesn't show HEADER
+                // Host hsdjkfhksjhdfkj not found: 3(NXDOMAIN)
+                // TODO: test if NXDOMAIN
+
+                std::cout << "Received " << cc <<
+                    " bytes in " << elapsed_time << " ms\n";
+                // TODO: " bytes from 127.0.0.1#53 in 0 ms
+
+            } //verbose
+/*
+TODO: handle InvalidRRClass
+TODO: handle invalid type exception
+        } catch (InvalidType ivt) {
+            std::cerr << "invalid type:" << ivt.what();
+*/
+        } catch (const exception& ex) {
+            std::cerr << "parse failed for " <<
+                string(name) << "/" << type << ": " << ex.what() << std::endl;
+        } catch (...) {
+            std::cerr << "parse failed for " << string(name) << "/" << type;
+        }
+    }
+
+    freeaddrinfo(res);
+
+    return (0);
+} // host_lookup()
+}
+
+int
+main(int argc, char* argv[]) {
+    int c;
+
+    while ((c = getopt(argc, argv, "ac:dp:rt:v")) != -1)
+        switch (c) {
+        case 'a':
+            dns_any = true;
+            verbose = true;
+            break;
+        case 'c':
+            dns_class = optarg;
+            break;
+	// p for port is a non-standard switch
+        case 'p':
+            server_port = optarg;
+            break;
+        case 'r':
+            recursive_bit = false;
+            break;
+        case 't':
+            dns_type = optarg;
+            break;
+        case 'd':
+            // drop through to v, because debug and verbose are equivalent
+        case 'v':
+            verbose = true;
+            break;
+    }
+    argc -= optind;
+    argv += optind;
+
+    if (argc < 1) {
+        cout << "Usage: host [-adrv] [-c class] [-p port] [-t type] hostname [server]\n";
+        exit(1);
+    }
+
+    if (argc >= 2) {
+      server = argv[1];
+    }
+
+    if (dns_type == NULL) {
+        host_lookup(argv[0], dns_class, "A", dns_any);
+        // TODO: don't do next if A doesn't exist
+        host_lookup(argv[0], dns_class, "AAAA", dns_any);
+        host_lookup(argv[0], dns_class, "MX", dns_any);
+    } else {
+        // -t overrides -a, regardless of order
+        host_lookup(argv[0], dns_class, dns_type, false);
+    }
+    return (0);
+}
diff --git a/examples/m4/ax_boost_include.m4 b/examples/m4/ax_boost_include.m4
new file mode 100644
index 0000000..e41614d
--- /dev/null
+++ b/examples/m4/ax_boost_include.m4
@@ -0,0 +1,64 @@
+dnl @synopsis AX_BOOST_INCLUDE
+dnl
+dnl Test for the Boost C++ header files
+dnl
+dnl If no path to the installed boost header files is given via the
+dnl --with-boost-include option,  the macro searchs under
+dnl /usr/local /usr/pkg /opt /opt/local directories.
+dnl
+dnl This macro calls:
+dnl
+dnl   AC_SUBST(BOOST_CPPFLAGS)
+dnl
+
+AC_DEFUN([AX_BOOST_INCLUDE], [
+AC_LANG_SAVE
+AC_LANG([C++])
+
+#
+# Configure Boost header path
+#
+# If explicitly specified, use it.
+AC_ARG_WITH([boost-include],
+  AS_HELP_STRING([--with-boost-include=PATH],
+    [specify exact directory for Boost headers]),
+    [boost_include_path="$withval"])
+# If not specified, try some common paths.
+if test -z "$with_boost_include"; then
+	boostdirs="/usr/local /usr/pkg /opt /opt/local"
+	for d in $boostdirs
+	do
+		if test -f $d/include/boost/shared_ptr.hpp; then
+			boost_include_path=$d/include
+			break
+		fi
+	done
+fi
+CPPFLAGS_SAVES="$CPPFLAGS"
+if test "${boost_include_path}" ; then
+	BOOST_CPPFLAGS="-I${boost_include_path}"
+	CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+fi
+# Make sure some commonly used headers are available
+AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/bind.hpp boost/function.hpp],,
+  AC_MSG_ERROR([Missing required Boost header files.]))
+
+# Detect whether Boost tries to use threads by default, and, if not,
+# make it sure explicitly.  In some systems the automatic detection
+# may depend on preceding header files, and if inconsistency happens
+# it could lead to a critical disruption.
+AC_MSG_CHECKING([whether Boost tries to use threads])
+AC_TRY_COMPILE([
+#include <boost/config.hpp>
+#ifdef BOOST_HAS_THREADS
+#error "boost will use threads"
+#endif],,
+[AC_MSG_RESULT(no)
+ CPPFLAGS_BOOST_THREADCONF="-DBOOST_DISABLE_THREADS=1"],
+[AC_MSG_RESULT(yes)])
+
+CPPFLAGS="$CPPFLAGS_SAVES $CPPFLAGS_BOOST_THREADCONF"
+AC_SUBST(BOOST_CPPFLAGS)
+
+AC_LANG_RESTORE
+])dnl AX_BOOST_INCLUDE
diff --git a/examples/m4/ax_isc_bind10.m4 b/examples/m4/ax_isc_bind10.m4
new file mode 100644
index 0000000..63e028c
--- /dev/null
+++ b/examples/m4/ax_isc_bind10.m4
@@ -0,0 +1,122 @@
+dnl @synopsis AX_BIND10
+dnl
+dnl @summary figure out how to build C++ programs using ISC BIND 10 libraries
+dnl
+dnl If no path to the installed BIND 10 header files or libraries is given
+dnl via the --with-bind10-include  or --with-bind10-lib option, the macro
+dnl searchs under /usr/local/{include, lib}, /usr/pkg/{include, lib},
+dnl /opt/{include, lib}, /opt/local/{include, lib} directories, respectively.
+dnl
+dnl This macro calls:
+dnl
+dnl   AC_SUBST(BIND10_CPPFLAGS)
+dnl   AC_SUBST(BIND10_LDFLAGS)
+dnl   AC_SUBST(BIND10_COMMON_LIB)
+dnl   AC_SUBST(BIND10_DNS_LIB)
+dnl
+dnl If this macro finds CPPFLAGS, LDFLAGS or COMMON_LIB unavailable, it treats
+dnl that as a fatal error.
+dnl Checks for other BIND 10 module libraries are option, as not all
+dnl applications need all libraries.  The main configure.ac can handle any
+dnl missing library as fatal by checking whether the corresponding
+dnl BIND10_xxx_LIB is defined.
+
+AC_DEFUN([AX_ISC_BIND10], [
+AC_REQUIRE([AX_BOOST_INCLUDE])
+AC_LANG_SAVE
+AC_LANG([C++])
+
+# Check for BIND10 common headers
+
+AC_ARG_WITH(bind10-include,
+  AS_HELP_STRING([--with-bind10-include=PATH],
+  [specify a path to BIND 10 header files]),
+    bind10_inc_path="$withval", bind10_inc_path="no")
+# If not specified, try some common paths.
+if test "$bind10_inc_path" = "no"; then
+   for d in /usr/local /usr/pkg /opt /opt/local
+   do
+	if test -f $d/include/util/buffer.h; then
+	   bind10_inc_path=$d
+	   break
+	fi
+   done
+fi
+CPPFLAGS_SAVES="$CPPFLAGS"
+if test "${bind10_inc_path}" != "no"; then
+   BIND10_CPPFLAGS="-I${bind10_inc_path}"
+   CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS"
+fi
+AC_CHECK_HEADERS([util/buffer.h],,
+  AC_MSG_ERROR([Missing a commonly used BIND 10 header files]))
+CPPFLAGS="$CPPFLAGS_SAVES"
+AC_SUBST(BIND10_CPPFLAGS)
+
+# Check for BIND10 libraries
+CPPFLAGS_SAVED="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $BIND10_CPPFLAGS"
+
+AC_ARG_WITH(bind10-lib,
+  AS_HELP_STRING([--with-bind10-lib=PATH],
+  [specify a path to BIND 10 library files]),
+    bind10_lib_path="$withval", bind10_lib_path="no")
+if test $bind10_lib_path != "no"; then
+   bind10_lib_dirs=$bind10_lib_path
+else
+   # If not specified, try some common paths.
+   bind10_lib_dirs="/usr/local/lib /usr/pkg/lib /opt/lib /opt/local/lib"
+fi
+
+# make sure we have buildable libraries
+AC_MSG_CHECKING([for BIND 10 common library])
+BIND10_COMMON_LIB="-lb10-util -lb10-exceptions"
+LDFLAGS="$LDFLAGS $BIND10_LDFLAGS"
+LIBS="$LIBS $BIND10_COMMON_LIB"
+for d in $bind10_lib_dirs
+do
+  LDFLAGS_SAVED="$LDFLAGS"
+  LDFLAGS="$LDFLAGS -L$d"
+  AC_TRY_LINK([
+#include <util/buffer.h>
+],[
+isc::util::OutputBuffer buffer(0);
+], [BIND10_LDFLAGS="-L${d}"])
+  if test "x$BIND10_LDFLAGS" != "x"; then
+     break
+  fi
+  LDFLAGS="$LDFLAGS_SAVED"
+done
+if test "x$BIND10_LDFLAGS" != "x"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+  AC_MSG_ERROR([unable to find required BIND 10 libraries])
+fi
+
+# restore LIBS once at this point
+LIBS="$LIBS_SAVES"
+
+AC_SUBST(BIND10_LDFLAGS)
+AC_SUBST(BIND10_COMMON_LIB)
+
+# Check per-module BIND 10 libraries
+
+# DNS library
+AC_MSG_CHECKING([for BIND 10 DNS library])
+LIBS="$LIBS $BIND10_COMMON_LIB -lb10-dns++"
+AC_TRY_LINK([
+#include <dns/rrtype.h>
+],[
+isc::dns::RRType rrtype(1);
+], [BIND10_DNS_LIB="-lb10-dns++"
+    AC_MSG_RESULT(yes)],
+   [AC_MSG_RESULT(no)])
+LIBS="$LIBS_SAVES"
+AC_SUBST(BIND10_DNS_LIB)
+
+# Restore other flags
+CPPFLAGS="$CPPFLAGS_SAVED"
+LDFLAGS="$LDFLAGS_SAVES"
+
+AC_LANG_RESTORE
+])dnl AX_ISC_BIND10
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 7af44f9..0b4c1ae 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = bind10 bindctl cfgmgr ddns loadzone msgq host cmdctl auth xfrin \
+SUBDIRS = bind10 bindctl cfgmgr ddns loadzone msgq cmdctl auth xfrin \
 	xfrout usermgr zonemgr stats tests resolver sockcreator dhcp4 dhcp6 \
 	dbutil sysinfo
 
diff --git a/src/bin/host/.gitignore b/src/bin/host/.gitignore
deleted file mode 100644
index 01ef357..0000000
--- a/src/bin/host/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/b10-host
-/b10-host.1
diff --git a/src/bin/host/Makefile.am b/src/bin/host/Makefile.am
deleted file mode 100644
index 42ef954..0000000
--- a/src/bin/host/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
-AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
-AM_CPPFLAGS += $(BOOST_INCLUDES)
-
-AM_CXXFLAGS = $(B10_CXXFLAGS)
-
-if USE_STATIC_LINK
-AM_LDFLAGS = -static
-endif
-
-CLEANFILES = *.gcno *.gcda
-
-bin_PROGRAMS = b10-host
-b10_host_SOURCES = host.cc
-b10_host_LDADD = $(top_builddir)/src/lib/dns/libb10-dns++.la
-b10_host_LDADD += $(top_builddir)/src/lib/util/libb10-util.la
-b10_host_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
-
-man_MANS = b10-host.1
-DISTCLEANFILES = $(man_MANS)
-EXTRA_DIST = $(man_MANS) b10-host.xml
-
-.PHONY: man
-if GENERATE_DOCS
-
-man: b10-host.1
-
-b10-host.1: b10-host.xml
-	@XSLTPROC@ --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/b10-host.xml
-
-else
-
-$(man_MANS):
-	@echo Man generation disabled.  Creating dummy $@.  Configure with --enable-generate-docs to enable it.
-	@echo Man generation disabled.  Remove this file, configure with --enable-generate-docs, and rebuild BIND 10 > $@
-
-endif
diff --git a/src/bin/host/README b/src/bin/host/README
deleted file mode 100644
index 5cc4068..0000000
--- a/src/bin/host/README
+++ /dev/null
@@ -1,4 +0,0 @@
-Rewriting host(1) in C++ from scratch using BIND 10's libdns++.
-
-The bugs and incompatibilities are listed in the manual page
-and in the source code.
diff --git a/src/bin/host/b10-host.xml b/src/bin/host/b10-host.xml
deleted file mode 100644
index a17ef67..0000000
--- a/src/bin/host/b10-host.xml
+++ /dev/null
@@ -1,196 +0,0 @@
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
-               "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
-	       [<!ENTITY mdash "—">]>
-<!--
- - Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
- -
- - Permission to use, copy, modify, and/or distribute this software for any
- - purpose with or without fee is hereby granted, provided that the above
- - copyright notice and this permission notice appear in all copies.
- -
- - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- - AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- - PERFORMANCE OF THIS SOFTWARE.
--->
-
-<!-- $Id$ -->
-<refentry>
-
-  <refentryinfo>
-    <date>May 4, 2011</date>
-  </refentryinfo>
-
-  <refmeta>
-    <refentrytitle>b10-host</refentrytitle>
-    <manvolnum>1</manvolnum>
-    <refmiscinfo>BIND10</refmiscinfo>
-  </refmeta>
-
-  <refnamediv>
-    <refname>b10-host</refname>
-    <refpurpose>DNS lookup utility</refpurpose>
-  </refnamediv>
-
-  <docinfo>
-    <copyright>
-      <year>2011</year>
-      <holder>Internet Systems Consortium, Inc. ("ISC")</holder>
-    </copyright>
-  </docinfo>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>b10-host</command>
-      <arg><option>-a</option></arg>
-      <arg><option>-c <replaceable>class</replaceable></option></arg>
-      <arg><option>-d</option></arg>
-      <arg><option>-p <replaceable>port</replaceable></option></arg>
-      <arg><option>-r</option></arg>
-      <arg><option>-t <replaceable>type</replaceable></option></arg>
-      <arg><option>-v</option></arg>
-      <arg><replaceable>name</replaceable></arg>
-      <arg><option><replaceable>server</replaceable></option></arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title>DESCRIPTION</title>
-    <para>
-      The <command>b10-host</command> utility does DNS lookups.
-      Its initial goal is to be a
-      <citerefentry><refentrytitle>host</refentrytitle>
-        <manvolnum>1</manvolnum></citerefentry>
-      clone, but also add a few features useful for BIND 10 development
-      testing.
-    </para>
-
-    <para>
-      By default, it looks up the A, AAAA, and MX record sets for the
-      <replaceable>name</replaceable>.
-      Optionally, you may select a name server to query against by adding
-      the <replaceable>server</replaceable> argument.
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title>OPTIONS</title>
-
-    <para>The arguments are as follows:</para>
-
-    <variablelist>
-
-      <varlistentry>
-        <term><option>-a</option></term>
-        <listitem><para>
-          Enable verbose mode and do a query for type ANY.
-          (If the <option>-t</option> option is also set, then the
-          ANY query is not done, but it still uses verbose mode.)
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-c <replaceable>class</replaceable></option></term>
-        <listitem><para>
-          Define the class for the query.
-          The default is IN (Internet).
-<!-- TODO: bug if class is unknown causes seg fault and possible core dump -->
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-d</option></term>
-        <listitem><para>
-	  Enable verbose output mode, including elapsed time in
-	  milliseconds.
-          Verbose mode shows the header, question, answer, authority,
-          and additional sections (if provided).
-          (Same as <option>-v</option>.)
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-p <replaceable>port</replaceable></option></term>
-        <listitem><para>
-          Select an alternative port for the query.
-          This may be a number or a service name.
-          The default is 53 (domain).
-          This is not a standard feature of
-          <citerefentry><refentrytitle>host</refentrytitle>
-            <manvolnum>1</manvolnum></citerefentry>.
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-r</option></term>
-        <listitem><para>
-          Disable recursive processing by not setting the
-          Recursion Desired flag in the query.
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-t <replaceable>type</replaceable></option></term>
-        <listitem><para>
-          Select a specific resource record type for the query.
-          By default, it looks up the A, AAAA, and MX record sets.
-<!-- TODO: bug if class is unknown causes seg fault and possible core dump -->
-          (This overrides the <option>-a</option> option.)
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-v</option></term>
-        <listitem><para>
-	  Same as <option>-d</option> option.
-        </para></listitem>
-      </varlistentry>
-
-    </variablelist>
-
-  </refsect1>
-
-  <refsect1>
-    <title>COMPATIBILITY / BUGS</title>
-    <para>
-      <command>b10-host</command> does not do reverse lookups by
-      default yet (by detecting if name is a IPv4 or IPv6 address).
-    </para>
-
-    <para>
-      Unknown <option>-c</option> class or <option>-t</option> type
-      causes <command>b10-host</command> to Abort.
-    </para>
-
-    <para>
-      Not all types are supported yet for formatting.
-      Not all switches are supported yet.
-    </para>
-
-    <para>
-      It doesn't use <filename>/etc/resolv.conf</filename> at this time.
-      The default name server used is 127.0.0.1.
-    </para>
-
-    <para>
-      <option>-p</option> is not a standard feature.
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title>HISTORY</title>
-    <para>
-      The C++ version of <command>b10-host</command> was started in
-      October 2009 by Jeremy C. Reed of ISC.
-      Its usage and output were based on the standard <command>host</command>
-      command.
-    </para>
-  </refsect1>
-</refentry><!--
- - Local variables:
- - mode: sgml
- - End:
--->
diff --git a/src/bin/host/host.cc b/src/bin/host/host.cc
deleted file mode 100644
index a5c6522..0000000
--- a/src/bin/host/host.cc
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright (C) 2010-2011  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-// host rewritten in C++ using BIND 10 DNS library
-
-#include <arpa/inet.h>
-#include <netdb.h>          // for getaddrinfo
-#include <sys/time.h>       // for gettimeofday
-#include <sys/socket.h>     // networking functions and definitions on FreeBSD
-
-#include <unistd.h>
-
-#include <string>
-#include <iostream>
-
-#include <util/buffer.h>
-
-#include <dns/name.h>
-#include <dns/message.h>
-#include <dns/messagerenderer.h>
-#include <dns/opcode.h>
-#include <dns/rcode.h>
-#include <dns/rrclass.h>
-#include <dns/rrtype.h>
-#include <dns/rrset.h>
-#include <dns/message.h>
-
-using namespace std;
-using namespace isc::dns;
-using namespace isc::util;
-
-namespace {
-char* dns_type = NULL;    // not set, so A, AAAA, MX
-const char* server = "127.0.0.1";
-const char* server_port = "53";
-const char* dns_class  = "IN";
-bool verbose = false;
-bool dns_any = false;
-int first_time = 1;
-bool recursive_bit = true;
-struct timeval before_time, after_time;
-
-int
-host_lookup(const char* const name, const char* const dns_class,
-            const char* const type, bool any) {
-
-    Message msg(Message::RENDER);
-
-    msg.setQid(0); // does this matter?
-
-    // TODO: add switch for this
-    msg.setOpcode(Opcode::QUERY());
-    msg.setRcode(Rcode::NOERROR());
-    if (recursive_bit) {
-        msg.setHeaderFlag(Message::HEADERFLAG_RD); // set recursive bit
-    }
-
-    msg.addQuestion(Question(Name(name),
-                             RRClass(dns_class),
-                             any ? RRType::ANY() : RRType(type)));  // if NULL then:
-
-    MessageRenderer renderer;
-    msg.toWire(renderer);
-
-    struct addrinfo hints, *res;
-    memset(&hints, 0, sizeof(hints));
-    hints.ai_family = AF_UNSPEC;
-    hints.ai_socktype = SOCK_DGRAM;
-    hints.ai_flags = 0; // not using AI_NUMERICHOST in case to bootstrap
-    if (getaddrinfo(server, server_port, &hints, &res) != 0) {
-        cerr << "address/port conversion for " << server << ":"
-             << server_port << " failed" << endl;
-        return (1);
-    }
-
-    if (verbose) {
-        cout << "Trying \"" << name << "\"\n";
-    }
-
-    if (verbose && first_time) {
-        // this is only output the first time
-        first_time = 0;
-        cout << "Using domain server:\n";
-        cout << "Name: " << server << "\n";
-        // TODO: I guess I have to do a lookup to get that address and aliases
-        // too
-        //cout << "Address: " << address << "\n" ; // "#" << port << "\n";
-        //cout << "Aliases: " << server << "\n";
-    }
-
-    int s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
-
-    if (s < 0) {
-        cerr << "failed to open socket" << endl;
-        return (1);
-    }
-
-    if (verbose) {
-        gettimeofday(&before_time, NULL);
-    }
-
-    sendto(s, renderer.getData(), renderer.getLength(), 0, res->ai_addr,
-           res->ai_addrlen);
-
-    struct sockaddr_storage ss;
-    struct sockaddr* sa;
-    socklen_t sa_len;
-
-    sa_len = sizeof(ss);
-    sa = static_cast<struct sockaddr*>((void*)&ss);
-
-    char recvbuf[4096];
-    int cc;
-    if ((cc = recvfrom(s, recvbuf, sizeof(recvbuf), 0, sa, &sa_len)) > 0) {
-        try {
-            Message rmsg(Message::PARSE);
-            InputBuffer ibuffer(recvbuf, cc);
-
-            rmsg.fromWire(ibuffer);
-            if (!verbose) {
-                string description = "";
-                for (RRsetIterator it =
-                         rmsg.beginSection(Message::SECTION_ANSWER);
-                     it != rmsg.endSection(Message::SECTION_ANSWER);
-                     ++it) {
-
-                      if ((*it)->getType() == RRType::A()) {
-                          description = "has address";
-                      }
-                      else if ((*it)->getType() == RRType::AAAA()) {
-                          description = "has IPv6 address";
-                      }
-                      else if ((*it)->getType() == RRType::MX()) {
-                          description = "mail is handled by";
-                      }
-                      else if ((*it)->getType() == RRType::TXT()) {
-                          description = "descriptive text";
-                      }
-
-                      RdataIteratorPtr rit = (*it)->getRdataIterator();
-                      for (; !rit->isLast(); rit->next()) {
-                          // instead of using my name, maybe use returned label?
-                          cout << name << " "  << description << " " <<
-                              (*rit).getCurrent().toText() << endl;
-                      }
-                  }
-            } else {
-                gettimeofday(&after_time, NULL);
-
-                // HEADER and QUESTION, ANSWER, AUTHORITY, and ADDITIONAL
-                std::cout << rmsg.toText() << std::endl;
-
-                if (before_time.tv_usec > after_time.tv_usec) {
-                    after_time.tv_usec += 1000000;
-                    --after_time.tv_sec;
-                }
-
-                int elapsed_time =
-                    (after_time.tv_sec - before_time.tv_sec)
-                    + ((after_time.tv_usec - before_time.tv_usec))/1000;
-
-                // TODO: if NXDOMAIN, host(1) doesn't show HEADER
-                // Host hsdjkfhksjhdfkj not found: 3(NXDOMAIN)
-                // TODO: test if NXDOMAIN
-
-                std::cout << "Received " << cc <<
-                    " bytes in " << elapsed_time << " ms\n";
-                // TODO: " bytes from 127.0.0.1#53 in 0 ms
-
-            } //verbose
-/*
-TODO: handle InvalidRRClass
-TODO: handle invalid type exception
-        } catch (InvalidType ivt) {
-            std::cerr << "invalid type:" << ivt.what();
-*/
-        } catch (const exception& ex) {
-            std::cerr << "parse failed for " <<
-                string(name) << "/" << type << ": " << ex.what() << std::endl;
-        } catch (...) {
-            std::cerr << "parse failed for " << string(name) << "/" << type;
-        }
-    }
-
-    freeaddrinfo(res);
-
-    return (0);
-} // host_lookup()
-}
-
-int
-main(int argc, char* argv[]) {
-    int c;
-
-    while ((c = getopt(argc, argv, "ac:dp:rt:v")) != -1)
-        switch (c) {
-        case 'a':
-            dns_any = true;
-            verbose = true;
-            break;
-        case 'c':
-            dns_class = optarg;
-            break;
-	// p for port is a non-standard switch
-        case 'p':
-            server_port = optarg;
-            break;
-        case 'r':
-            recursive_bit = false;
-            break;
-        case 't':
-            dns_type = optarg;
-            break;
-        case 'd':
-            // drop through to v, because debug and verbose are equivalent
-        case 'v':
-            verbose = true;
-            break;
-    }
-    argc -= optind;
-    argv += optind;
-
-    if (argc < 1) {
-        cout << "Usage: host [-adrv] [-c class] [-p port] [-t type] hostname [server]\n";
-        exit(1);
-    }
-
-    if (argc >= 2) {
-      server = argv[1];
-    }
-
-    if (dns_type == NULL) {
-        host_lookup(argv[0], dns_class, "A", dns_any);
-        // TODO: don't do next if A doesn't exist
-        host_lookup(argv[0], dns_class, "AAAA", dns_any);
-        host_lookup(argv[0], dns_class, "MX", dns_any);
-    } else {
-        // -t overrides -a, regardless of order
-        host_lookup(argv[0], dns_class, dns_type, false);
-    }
-    return (0);
-}
diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am
index 38809e0..40cb943 100644
--- a/src/lib/dns/Makefile.am
+++ b/src/lib/dns/Makefile.am
@@ -149,11 +149,11 @@ libdns___include_HEADERS = \
 	messagerenderer.h \
 	name.h \
 	question.h \
+	opcode.h \
 	rcode.h \
 	rdata.h \
 	rrparamregistry.h \
 	rrset.h \
-	rrsetlist.h \
 	rrttl.h \
 	tsigkey.h
 # Purposely not installing these headers:
diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am
index fe1b327..13f8f7b 100644
--- a/src/lib/util/Makefile.am
+++ b/src/lib/util/Makefile.am
@@ -33,3 +33,6 @@ EXTRA_DIST = python/pycppwrapper_util.h
 
 libb10_util_la_LIBADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
 CLEANFILES = *.gcno *.gcda
+
+libb10_util_includedir = $(includedir)/$(PACKAGE_NAME)/util
+libb10_util_include_HEADERS = buffer.h



More information about the bind10-changes mailing list