Browse Source

removed old dns-python example code
removed Boost.Python bindings
updated xfrin/xfrout tests for new python bindings


git-svn-id: svn://bind10.isc.org/svn/bind10/experiments/python-binding@2090 e5f2f494-b856-4b98-b285-d166d9295462

Jelte Jansen 15 years ago
parent
commit
2074ba324e

+ 0 - 47
configure.ac

@@ -247,52 +247,6 @@ AC_SUBST(BOOST_SYSTEM_LIB)
 
 # Check availability of the Boost Python library
 
-AC_MSG_CHECKING([for boost::python library])
-AC_ARG_WITH([boost-python],
-AC_HELP_STRING([--with-boost-python],
-  [specify whether to use the boost python library]),
-  [with_boost_python="$withval"], [with_boost_python="auto"])
-if test "$with_boost_python" != "no"; then
-	if test "$with_boost_python" != "auto" -a "X$PYTHON_LIB" = X; then
-		AC_MSG_ERROR([Boost.Python requested but python library is not available])
-	fi
-	LDFLAGS_SAVED="$LDFLAGS"
-	LIBS_SAVED="$LIBS"
-	CPPFLAGS_SAVED="$CPPFLAGS"
-	CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
-
-	for BOOST_TRY_LIB in boost_python boost_python-mt; do
-		LDFLAGS="$LDFLAGS_SAVED ${BOOST_LDFLAGS} ${PYTHON_LDFLAGS}"
-		LIBS="$LIBS_SAVED -l${BOOST_TRY_LIB} ${PYTHON_LIB}"
-		AC_TRY_LINK([#include <boost/python/module.hpp>
-	      using namespace boost::python;
-	      BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }],
-			[ return 0; ],
-			[ AC_MSG_RESULT(yes)
-			BOOST_PYTHON_LIB="-l${BOOST_TRY_LIB}"
-			],[])
-		if test "X${BOOST_PYTHON_LIB}" != X; then
-        		break
-		fi
-	done
-
-	LDFLAGS="$LDFLAGS_SAVED"
-	CPPFLAGS="$CPPFLAGS_SAVED"
-	LIBS="$LIBS_SAVED"
-fi
-
-if test "X${BOOST_PYTHON_LIB}" = X; then
-	AC_MSG_RESULT(no)
-	if test "$with_boost_python" = "yes"; then
-	   AC_MSG_ERROR([boost python library is requested but not found])
-	fi
-else
-	AC_DEFINE(HAVE_BOOST_PYTHON, 1, Define to 1 if boost python library is available)
-fi
-
-AM_CONDITIONAL(HAVE_BOOST_PYTHON, test "X${BOOST_PYTHON_LIB}" != X)
-AC_SUBST(BOOST_PYTHON_LIB)
-
 #
 # Check availability of gtest, which will be used for unit tests.
 #
@@ -408,7 +362,6 @@ AC_CONFIG_FILES([Makefile
                  src/lib/dns/tests/Makefile
                  src/lib/dns/python/Makefile
                  src/lib/dns/python/tests/Makefile
-                 src/lib/dns-python/Makefile
                  src/lib/exceptions/Makefile
                  src/lib/datasrc/Makefile
                  src/lib/datasrc/tests/Makefile

+ 1 - 5
src/bin/xfrin/tests/Makefile.am

@@ -1,16 +1,12 @@
 PYTESTS = xfrin_test.py
 EXTRA_DIST = $(PYTESTS)
 
-if HAVE_BOOST_PYTHON
-
 # later will have configure option to choose this, like: coverage run --branch
 PYCOVERAGE = $(PYTHON)
 # test using command-line arguments, so use check-local target instead of TESTS
 check-local:
 	for pytest in $(PYTESTS) ; do \
 	echo Running test: $$pytest ; \
-	env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python \
+	env PYTHONPATH=$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/bin/xfrin:$(abs_top_srcdir)/src/lib/python \
 	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
 	done
-
-endif

+ 2 - 2
src/bin/xfrin/tests/xfrin_test.py

@@ -65,12 +65,12 @@ class TestXfrinConnection(unittest.TestCase):
         self.assertRaises(Exception, self.conn._handle_xfrin_response)
 
     def test_response_without_end_soa(self):
-        self.conn._send_query(rr_type.AXFR())
+        self.conn._send_query(RRType.AXFR())
         self.conn.reply_data = self.conn.create_response_data(axfr_response1) 
         self.assertRaises(XfrinException, self.conn._handle_xfrin_response)
 
     def test_response(self):
-        self.conn._send_query(rr_type.AXFR())
+        self.conn._send_query(RRType.AXFR())
         self.conn.reply_data = self.conn.create_response_data(axfr_response1) 
         self.conn.reply_data += self.conn.create_response_data(axfr_response2) 
         self.conn._handle_xfrin_response()

+ 1 - 5
src/bin/xfrout/tests/Makefile.am

@@ -1,16 +1,12 @@
 PYTESTS = xfrout_test.py
 EXTRA_DIST = $(PYTESTS)
 
-if HAVE_BOOST_PYTHON
-
 # later will have configure option to choose this, like: coverage run --branch
 PYCOVERAGE = $(PYTHON)
 # test using command-line arguments, so use check-local target instead of TESTS
 check-local:
 	for pytest in $(PYTESTS) ; do \
 	echo Running test: $$pytest ; \
-	env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \
+	env PYTHONPATH=$(abs_top_builddir)/src/bin/xfrout:$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/xfr/.libs \
 	$(PYCOVERAGE) $(abs_srcdir)/$$pytest ; \
 	done
-
-endif

+ 23 - 25
src/bin/xfrout/tests/xfrout_test.py

@@ -19,7 +19,7 @@
 import unittest
 import os
 from isc.cc.session import *
-from bind10_dns import *
+from libdns_python import *
 from xfrout import *
 
 # our fake socket, where we can read and insert messages
@@ -46,8 +46,8 @@ class MySocket():
     
     def read_msg(self):
         sent_data = self.readsent()
-        get_msg = message(message_mode.PARSE)
-        get_msg.from_wire(input_buffer(bytes(sent_data[2:])))
+        get_msg = Message(Message.PARSE)
+        get_msg.from_wire(bytes(sent_data[2:]))
         return get_msg
     
     def clear_send(self):
@@ -69,15 +69,15 @@ class Dbserver:
 
 class TestXfroutSession(unittest.TestCase):
     def getmsg(self):
-        msg = message(message_mode.PARSE)
-        msg.from_wire(input_buffer(self.mdata))
+        msg = Message(Message.PARSE)
+        msg.from_wire(self.mdata)
         return msg
 
     def setUp(self):
         request = MySocket(socket.AF_INET,socket.SOCK_STREAM)
         self.xfrsess = MyXfroutSession(request, None, None)
         self.xfrsess.server = Dbserver()
-        self.mdata = b'\xd6=\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\x00\x00\xfc\x00\x01'
+        self.mdata = bytes(b'\xd6=\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\x00\x00\xfc\x00\x01')
         self.sock = MySocket(socket.AF_INET,socket.SOCK_STREAM)
         self.soa_record = (4, 3, 'example.com.', 'com.example.', 3600, 'SOA', None, 'master.example.com. admin.example.com. 1234 3600 1800 2419200 7200')
 
@@ -96,7 +96,7 @@ class TestXfroutSession(unittest.TestCase):
 
     def test_reply_xfrout_query_with_error_rcode(self):
         msg = self.getmsg()
-        self.xfrsess._reply_query_with_error_rcode(msg, self.sock, rcode(3))
+        self.xfrsess._reply_query_with_error_rcode(msg, self.sock, Rcode(3))
         get_msg = self.sock.read_msg()
         self.assertEqual(get_msg.get_rcode().to_text(), "NXDOMAIN") 
      
@@ -110,7 +110,7 @@ class TestXfroutSession(unittest.TestCase):
         self.assertEqual(msg.get_qid(), qid)
         self.assertEqual(msg.get_opcode(), opcode)
         self.assertEqual(msg.get_rcode(), rcode)
-        self.assertTrue(msg.get_header_flag(message_flag.AA()))
+        self.assertTrue(msg.get_header_flag(MessageFlag.AA()))
 
     def test_reply_query_with_format_error(self):
          
@@ -122,11 +122,10 @@ class TestXfroutSession(unittest.TestCase):
     def test_create_rrset_from_db_record(self):
         rrset = self.xfrsess._create_rrset_from_db_record(self.soa_record)
         self.assertEqual(rrset.get_name().to_text(), "example.com.")
-        self.assertEqual(rrset.get_class(), rr_class.IN())
+        self.assertEqual(rrset.get_class(), RRClass("IN"))
         self.assertEqual(rrset.get_type().to_text(), "SOA")
-        rdata_iter = rrset.get_rdata_iterator()
-        rdata_iter.first()
-        self.assertEqual(rdata_iter.get_current().to_text(), self.soa_record[7])
+        rdata = rrset.get_rdata()
+        self.assertEqual(rdata[0].to_text(), self.soa_record[7])
 
     def test_send_message_with_last_soa(self):
         rrset_soa = self.xfrsess._create_rrset_from_db_record(self.soa_record)
@@ -136,18 +135,17 @@ class TestXfroutSession(unittest.TestCase):
         self.xfrsess._send_message_with_last_soa(msg, self.sock, rrset_soa)
         get_msg = self.sock.read_msg()
 
-        self.assertEqual(get_msg.get_rr_count(section.QUESTION()), 1)
-        self.assertEqual(get_msg.get_rr_count(section.ANSWER()), 1)
-        self.assertEqual(get_msg.get_rr_count(section.AUTHORITY()), 0)
+        self.assertEqual(get_msg.get_rr_count(Section.QUESTION()), 1)
+        self.assertEqual(get_msg.get_rr_count(Section.ANSWER()), 1)
+        self.assertEqual(get_msg.get_rr_count(Section.AUTHORITY()), 0)
 
-        answer_rrset_iter = section_iter(get_msg, section.ANSWER())
-        answer = answer_rrset_iter.get_rrset()
+        #answer_rrset_iter = section_iter(get_msg, section.ANSWER())
+        answer = get_msg.get_section(Section.ANSWER())[0]#answer_rrset_iter.get_rrset()
         self.assertEqual(answer.get_name().to_text(), "example.com.")
-        self.assertEqual(answer.get_class(), rr_class.IN())
+        self.assertEqual(answer.get_class(), RRClass("IN"))
         self.assertEqual(answer.get_type().to_text(), "SOA")
-        rdata_iter = answer.get_rdata_iterator()
-        rdata_iter.first()
-        self.assertEqual(rdata_iter.get_current().to_text(), self.soa_record[7])
+        rdata = answer.get_rdata()
+        self.assertEqual(rdata[0].to_text(), self.soa_record[7])
 
     def test_get_message_len(self):
         msg = self.getmsg()
@@ -195,7 +193,7 @@ class TestXfroutSession(unittest.TestCase):
 
     def test_dns_xfrout_start_formerror(self):
         # formerror
-        self.xfrsess.dns_xfrout_start(self.sock, b"\xd6=\x00\x00\x00\x01\x00")
+        self.assertRaises(MessageTooShort, self.xfrsess.dns_xfrout_start, self.sock, b"\xd6=\x00\x00\x00\x01\x00")
         sent_data = self.sock.readsent()
         self.assertEqual(len(sent_data), 0)
     
@@ -205,7 +203,7 @@ class TestXfroutSession(unittest.TestCase):
     def test_dns_xfrout_start_notauth(self):
         self.xfrsess._get_query_zone_name = self.default
         def notauth(formpara):
-            return rcode.NOTAUTH()
+            return Rcode.NOTAUTH()
         self.xfrsess._check_xfrout_available = notauth
         self.xfrsess.dns_xfrout_start(self.sock, self.mdata)
         get_msg = self.sock.read_msg()
@@ -214,7 +212,7 @@ class TestXfroutSession(unittest.TestCase):
     def test_dns_xfrout_start_noerror(self):
         self.xfrsess._get_query_zone_name = self.default
         def noerror(form):
-            return rcode.NOERROR() 
+            return Rcode.NOERROR() 
         self.xfrsess._check_xfrout_available = noerror
         
         def myreply(msg, sock, zonename):
@@ -236,7 +234,7 @@ class TestXfroutSession(unittest.TestCase):
         sqlite3_ds.get_zone_datas = get_zone_datas
         self.xfrsess._reply_xfrout_query(self.getmsg(), self.sock, "example.com.")
         reply_msg = self.sock.read_msg()
-        self.assertEqual(reply_msg.get_rr_count(section.ANSWER()), 2)
+        self.assertEqual(reply_msg.get_rr_count(Section.ANSWER()), 2)
 
         # set event
         self.xfrsess.server._shutdown_event.set()

+ 1 - 1
src/bin/xfrout/xfrout.py.in

@@ -80,7 +80,7 @@ class XfroutSession(BaseRequestHandler):
         #TODO, need to add parseHeader() in case the message header is invalid 
         try:
             msg = Message(Message.PARSE)
-            msg.from_wire(mdata)
+            Message.from_wire(msg, mdata)
         except TmpException as err:
             if verbose_mode:
                 self.log_msg(str(err))

+ 0 - 15
src/lib/dns-python/Makefile.am

@@ -1,15 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
-if GCC_WERROR_OK
-AM_CPPFLAGS += -Werror
-endif
-
-pyexec_LTLIBRARIES = bind10_dns_noboost.la
-bind10_dns_noboost_la_SOURCES = cpp_binding.cc
-bind10_dns_noboost_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
-bind10_dns_noboost_la_LDFLAGS = $(PYTHON_LDFLAGS)
-# Python prefers .so, while some OSes (specifically MacOS) use a different
-# suffix for dynamic objects.  -module is necessary to work this around.
-bind10_dns_noboost_la_LDFLAGS += -module
-bind10_dns_noboost_la_LIBADD = $(top_builddir)/src/lib/dns/libdns.la
-bind10_dns_noboost_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
-bind10_dns_noboost_la_LIBADD += $(PYTHON_LIB)

+ 0 - 768
src/lib/dns-python/cpp_binding.cc

@@ -1,768 +0,0 @@
-// Copyright (C) 2010  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$
-
-/* isc::dns::Name Python bindings */
-
-#define PY_SSIZE_T_CLEAN
-
-#include "config.h"
-
-#include <Python.h>
-#include <structmember.h>
-
-#include <exceptions/exceptions.h>
-
-#include <dns/buffer.h>
-#include <dns/exceptions.h>
-#include <dns/name.h>
-#include <dns/messagerenderer.h>
-
-#include <cassert>
-
-using isc::OutOfRange;
-using isc::dns::DNSMessageFORMERR;
-using isc::dns::InvalidBufferPosition;
-using isc::dns::InputBuffer;
-using isc::dns::OutputBuffer;
-using isc::dns::EmptyLabel;
-using isc::dns::TooLongName;
-using isc::dns::TooLongLabel;
-using isc::dns::BadLabelType;
-using isc::dns::BadEscape;
-using isc::dns::IncompleteName;
-using isc::dns::NameComparisonResult;
-using isc::dns::Name;
-using isc::dns::MessageRenderer;
-
-static PyObject *cName_Exception;
-static PyObject *cName_Relation;
-static PyObject *cName_MAX_WIRE;
-static PyObject *cName_MAX_LABELS;
-static PyObject *cName_MAX_LABELLEN;
-static PyObject *cName_MAX_COMPRESS_POINTER;
-static PyObject *cName_COMPRESS_POINTER_MARK8;
-static PyObject *cName_COMPRESS_POINTER_MARK16;
-
-typedef struct {
-    PyObject_HEAD
-    NameComparisonResult *ncr;
-} cNCR;
-
-static void cNCR_dealloc(cNCR *self);
-static int cNCR_init(cNCR *self, PyObject *args);
-static PyObject *cNCR_getOrder(cNCR *self);
-static PyObject *cNCR_getCommonLabels(cNCR *self);
-static PyObject *cNCR_getRelation(cNCR *self);
-
-static PyMethodDef cNCR_Methods[] = {
-    { "getOrder", (PyCFunction)cNCR_getOrder, METH_NOARGS,
-      "Return the ordering of the comparison result" },
-    { "getCommonLabels", (PyCFunction)cNCR_getCommonLabels, METH_NOARGS,
-      "Return the number of common labels of the comparison result" },
-    { "getRelation", (PyCFunction)cNCR_getRelation, METH_NOARGS,
-      "Return the NameRelation of the comparison result" },
-    { NULL, NULL, 0, NULL }
-};
-
-static PyTypeObject cNCR_Type = {
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "bind10_dns_noboost.cNameComparisonResult", /* tp_name */
-    sizeof(cNCR),                       /* tp_basicsize */
-    0,                                  /* tp_itemsize */
-    (destructor)cNCR_dealloc,           /* tp_dealloc */
-    NULL,                               /* tp_print */
-    NULL,                               /* tp_getattr */
-    NULL,                               /* tp_setattr */
-    NULL,                               /* tp_reserved */
-    NULL,                               /* tp_repr */
-    NULL,                               /* tp_as_number */
-    NULL,                               /* tp_as_sequence */
-    NULL,                               /* tp_as_mapping */
-    NULL,                               /* tp_hash  */
-    NULL,                               /* tp_call */
-    NULL,                               /* tp_str */
-    NULL,                               /* tp_getattro */
-    NULL,                               /* tp_setattro */
-    NULL,                               /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
-    "C++ NameComparisonResult Object",  /* tp_doc */
-    NULL,                               /* tp_traverse */
-    NULL,                               /* tp_clear */
-    NULL,                               /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
-    NULL,                               /* tp_iter */
-    NULL,                               /* tp_iternext */
-    cNCR_Methods,                       /* tp_methods */
-    NULL,                               /* tp_members */
-    NULL,                               /* tp_getset */
-    NULL,                               /* tp_base */
-    NULL,                               /* tp_dict */
-    NULL,                               /* tp_descr_get */
-    NULL,                               /* tp_descr_set */
-    0,                                  /* tp_dictoffset */
-    (initproc)cNCR_init,                /* tp_init */
-    NULL,                               /* tp_alloc */
-    PyType_GenericNew,                  /* tp_new */
-    NULL,                               /* tp_free */
-    NULL,                               /* tp_is_gc */
-    NULL,                               /* tp_bases */
-    NULL,                               /* tp_mro */
-    NULL,                               /* tp_cache */
-    NULL,                               /* tp_subclasses */
-    NULL,                               /* tp_weaklist */
-    // Note: not sure if the following are correct.  Added them just to
-    // make the compiler happy.
-    NULL,                               /* tp_del */
-    0                                   /* tp_version_tag */
-};
-
-static void
-cNCR_dealloc(cNCR *self) {
-    if (self->ncr != NULL)
-        delete self->ncr;
-    self->ncr = NULL;
-    Py_TYPE(self)->tp_free(self);
-}
-
-static int
-cNCR_init(cNCR *self UNUSED_PARAM, PyObject *args UNUSED_PARAM) {
-    PyErr_SetString(PyExc_NotImplementedError,
-                    "cNameComparisonResult can't be built");
-    return -1;
-}
-
-static PyObject *
-cNCR_getOrder(cNCR *self) {
-    return Py_BuildValue("i", self->ncr->getOrder());
-}
-
-static PyObject *
-cNCR_getCommonLabels(cNCR *self) {
-    return Py_BuildValue("I", self->ncr->getCommonLabels());
-}
-
-static PyObject *
-cNCR_getRelation(cNCR *self) {
-    return Py_BuildValue("i", (int) self->ncr->getRelation());
-}
-
-typedef struct {
-    PyObject_HEAD
-    Name *name;
-    size_t position;
-} cName;
-
-static void cName_dealloc(cName *self);
-static int cName_init(cName *self, PyObject *args);
-static PyObject *cName_getLength(cName *self);
-static PyObject *cName_getLabelCount(cName *self);
-static PyObject *cName_toText(cName *self, PyObject *args);
-static PyObject *cName_toWire(cName *self, PyObject *args);
-static PyObject *cName_compare(cName *self, PyObject *args);
-static PyObject *cName_equals(cName *self, PyObject *args);
-static PyObject *cName_nequals(cName *self, PyObject *args);
-static PyObject *cName_richcmp(cName *n1, cName *n2, int op);
-static PyObject *cName_split(cName *self, PyObject *args);
-static PyObject *cName_concatenate(cName *self, PyObject *args);
-static PyObject *cName_downcase(cName *self);
-static PyObject *cName_isWildcard(cName *self);
-static PyObject *cName_getPosition(cName *self);
-static PyObject *cName_clone(cName *self, PyObject *args);
-
-static PyMethodDef cName_Methods[] = {
-    { "getLength", (PyCFunction)cName_getLength, METH_NOARGS,
-      "Return the length of the Name" },
-    { "getLabelCount", (PyCFunction)cName_getLabelCount, METH_NOARGS,
-      "Return the number of labels" },
-    { "toText", (PyCFunction)cName_toText, METH_VARARGS,
-      "Convert the Name to a string" },
-    { "toWire", (PyCFunction)cName_toWire, METH_VARARGS,
-      "Render the Name in the wire format" },
-    { "compare", (PyCFunction)cName_compare, METH_VARARGS,
-      "Compare two Names" },
-    { "equals", (PyCFunction)cName_equals, METH_VARARGS,
-      "Return true iff two Names are equal" },
-    { "nequals", (PyCFunction)cName_nequals, METH_VARARGS,
-      "Return true iff two Names are not equal" },
-    { "split", (PyCFunction)cName_split, METH_VARARGS,
-      "Extract a specified subpart of Name" },
-    { "concatenate", (PyCFunction)cName_concatenate, METH_VARARGS,
-      "Concatenate two Names" },
-    { "downcase", (PyCFunction)cName_downcase, METH_NOARGS,
-      "Downcase the calling object" },
-    { "isWildcard", (PyCFunction)cName_isWildcard, METH_NOARGS,
-      "Test if this is a wildcard Name" },
-    { "getPosition", (PyCFunction)cName_getPosition, METH_NOARGS,
-      "Return the end position in the wire buffer" },
-    { "clone", (PyCFunction)cName_clone, METH_NOARGS,
-      "Clone a Name" },
-    { NULL, NULL, 0, NULL }
-};
-
-static PyTypeObject cName_Type = {
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "bind10_dns_noboost.cName",         /* tp_name */
-    sizeof(cName),                      /* tp_basicsize */
-    0,                                  /* tp_itemsize */
-    (destructor)cName_dealloc,          /* tp_dealloc */
-    NULL,                               /* tp_print */
-    NULL,                               /* tp_getattr */
-    NULL,                               /* tp_setattr */
-    NULL,                               /* tp_reserved */
-    NULL,                               /* tp_repr */
-    NULL,                               /* tp_as_number */
-    NULL,                               /* tp_as_sequence */
-    NULL,                               /* tp_as_mapping */
-    NULL,                               /* tp_hash  */
-    NULL,                               /* tp_call */
-    NULL,                               /* tp_str */
-    NULL,                               /* tp_getattro */
-    NULL,                               /* tp_setattro */
-    NULL,                               /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,     /* tp_flags */
-    "C++ Name Object",                  /* tp_doc */
-    NULL,                               /* tp_traverse */
-    NULL,                               /* tp_clear */
-    (richcmpfunc)cName_richcmp,         /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
-    NULL,                               /* tp_iter */
-    NULL,                               /* tp_iternext */
-    cName_Methods,                      /* tp_methods */
-    NULL,                               /* tp_members */
-    NULL,                               /* tp_getset */
-    NULL,                               /* tp_base */
-    NULL,                               /* tp_dict */
-    NULL,                               /* tp_descr_get */
-    NULL,                               /* tp_descr_set */
-    0,                                  /* tp_dictoffset */
-    (initproc)cName_init,               /* tp_init */
-    NULL,                               /* tp_alloc */
-    PyType_GenericNew,                  /* tp_new */
-    NULL,                               /* tp_free */
-    NULL,                               /* tp_is_gc */
-    NULL,                               /* tp_bases */
-    NULL,                               /* tp_mro */
-    NULL,                               /* tp_cache */
-    NULL,                               /* tp_subclasses */
-    NULL,                               /* tp_weaklist */
-    // Note: not sure if the following are correct.  Added them just to
-    // make the compiler happy.
-    NULL,                               /* tp_del */
-    0                                   /* tp_version_tag */
-};
-
-static void
-cName_dealloc(cName *self) {
-    if (self->name != NULL)
-        delete self->name;
-    self->name = NULL;
-    Py_TYPE(self)->tp_free(self);
-}
-
-static int
-cName_init(cName *self, PyObject *args) {
-    const char *s;
-    PyObject *downcase = Py_False;
-
-    /* fromText */
-    if (PyArg_ParseTuple(args, "s|O!", &s, &PyBool_Type, &downcase)) {
-        try {
-            const std::string n(s);
-
-            self->name = new Name(n, downcase == Py_True);
-            self->position = 0;
-        } catch (EmptyLabel) {
-            PyErr_SetString(cName_Exception, "EmptyLabel");
-            return -1;
-        } catch (TooLongLabel) {
-            PyErr_SetString(cName_Exception, "TooLongLabel");
-            return -1;
-        } catch (BadLabelType) {
-            PyErr_SetString(cName_Exception, "BadLabelType");
-            return -1;
-        } catch (BadEscape) {
-            PyErr_SetString(cName_Exception, "BadEscape");
-            return -1;
-        } catch (TooLongName) {
-            PyErr_SetString(cName_Exception, "TooLongName");
-            return -1;
-        } catch (IncompleteName) {
-            PyErr_SetString(cName_Exception, "IncompleteName");
-            return -1;
-#ifdef CATCHMEMERR
-        } catch (std::bad_alloc) {
-            PyErr_NoMemory();
-            return -1;
-#endif
-        } catch (...) {
-            PyErr_SetString(cName_Exception, "Unexpected?!");
-            return -1;
-        }
-        return 0;
-    }
-    PyErr_Clear();
-
-    const char *b;
-    Py_ssize_t len;
-    unsigned int position;
-
-    /* fromWire */
-    if (PyArg_ParseTuple(args, "y#I|O!", &b, &len, &position,
-                         &PyBool_Type, &downcase)) {
-        try {
-            InputBuffer buffer(b, len);
-
-            buffer.setPosition(position);
-            self->name = new Name(buffer, downcase == Py_True);
-            self->position = buffer.getPosition();
-        } catch (InvalidBufferPosition) {
-            PyErr_SetString(cName_Exception,
-                            "InvalidBufferPosition");
-            return -1;
-        } catch (TooLongName) {
-            PyErr_SetString(cName_Exception, "TooLongName");
-            return -1;
-        } catch (BadLabelType) {
-            PyErr_SetString(cName_Exception, "BadLabelType");
-            return -1;
-        } catch (DNSMessageFORMERR) {
-            PyErr_SetString(cName_Exception, "DNSMessageFORMERR");
-            return -1;
-        } catch (IncompleteName) {
-            PyErr_SetString(cName_Exception, "IncompleteName");
-            return -1;
-#ifdef CATCHMEMERR
-        } catch (std::bad_alloc) {
-            PyErr_NoMemory();
-            return -1;
-#endif
-        } catch (...) {
-            PyErr_SetString(cName_Exception, "Unexpected?!");
-            return -1;
-        }
-        return 0;
-    }
-
-    PyErr_Clear();
-    PyErr_SetString(PyExc_TypeError,
-                    "fromText and fromWire Name constructors don't match");
-    return -1;
-}
-
-static PyObject *
-cName_getLength(cName *self) {
-    return Py_BuildValue("I", (unsigned int) self->name->getLength());
-}
-
-static PyObject *
-cName_getLabelCount(cName *self) {
-    return Py_BuildValue("I", self->name->getLabelCount());
-}
-
-static PyObject *
-cName_toText(cName *self, PyObject *args) {
-    PyObject *omit = Py_False;
-
-    if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &omit))
-        return NULL;
-
-    try {
-        std::string s = self->name->toText(omit == Py_True);
-
-        return Py_BuildValue("s", s.c_str());
-    } catch (BadLabelType) {
-        PyErr_SetString(cName_Exception, "BadLabelType");
-        return NULL;
-    }
-}
-
-static PyObject *
-cName_toWire(cName *self, PyObject *args) {
-    if (!PyArg_ParseTuple(args, ""))
-        return NULL;
-
-    OutputBuffer buffer(255);
-
-    self->name->toWire(buffer);
-    return Py_BuildValue("y#", buffer.getData(),
-                         (Py_ssize_t) buffer.getLength());
-}
-
-static PyObject *
-cName_compare(cName *self, PyObject *args) {
-    cName *other;
-
-    if (!PyArg_ParseTuple(args, "O!", &cName_Type, (PyObject **) &other))
-        return NULL;
-
-    cNCR *ret = PyObject_New(cNCR, &cNCR_Type);
-    if (ret != NULL) {
-        ret->ncr = new NameComparisonResult(
-            self->name->compare(*other->name));
-        if (ret->ncr == NULL) {
-            Py_DECREF(ret);
-            return NULL;
-        }
-    }
-    return (PyObject *) ret;
-}
-
-static PyObject *
-cName_equals(cName *self, PyObject *args) {
-    cName *other;
-
-    if (!PyArg_ParseTuple(args, "O!", &cName_Type, (PyObject **) &other))
-        return NULL;
-
-    if (self->name->equals(*other->name))
-        Py_RETURN_TRUE;
-    else
-        Py_RETURN_FALSE;
-}
-
-static PyObject *
-cName_nequals(cName *self, PyObject *args) {
-    cName *other;
-
-    if (!PyArg_ParseTuple(args, "O!", &cName_Type, (PyObject **) &other))
-        return NULL;
-
-    if (self->name->nequals(*other->name))
-        Py_RETURN_TRUE;
-    else
-        Py_RETURN_FALSE;
-}
-
-static PyObject *
-cName_richcmp(cName *n1, cName *n2, int op) {
-    bool c;
-
-    switch (op) {
-    case Py_LT:
-        c = n1->name->lthan(*n2->name);
-        break;
-    case Py_LE:
-        c = n1->name->leq(*n2->name);
-        break;
-    case Py_EQ:
-        c = n1->name->equals(*n2->name);
-        break;
-    case Py_NE:
-        c = n1->name->nequals(*n2->name);
-        break;
-    case Py_GT:
-        c = n1->name->gthan(*n2->name);
-        break;
-    case Py_GE:
-        c = n1->name->geq(*n2->name);
-        break;
-    default:
-        assert(0);              // XXX: should trigger an exception
-    }
-    if (c)
-        Py_RETURN_TRUE;
-    else
-        Py_RETURN_FALSE;
-}
-
-static PyObject *
-cName_split(cName *self, PyObject *args) {
-    unsigned int first, n;
-
-    if (!PyArg_ParseTuple(args, "II", &first, &n))
-        return NULL;
-
-    cName *ret = PyObject_New(cName, &cName_Type);
-    if (ret != NULL) {
-        ret->name = NULL;
-        try {
-            ret->name = new Name(self->name->split(first, n));
-        } catch(OutOfRange) {
-            PyErr_SetString(cName_Exception, "OutOfRange");
-        }
-        if (ret->name == NULL) {
-            Py_DECREF(ret);
-            return NULL;
-        }
-    }
-    return (PyObject *) ret;
-}
-
-static PyObject *
-cName_concatenate(cName *self, PyObject *args) {
-    cName *suffix;
-
-    if (!PyArg_ParseTuple(args, "O!", &cName_Type, (PyObject **) &suffix))
-        return NULL;
-
-    cName *ret = PyObject_New(cName, &cName_Type);
-    if (ret != NULL) {
-        ret->name = NULL;
-        try {
-            ret->name = new Name(
-                self->name->concatenate(*suffix->name));
-        } catch(TooLongName) {
-            PyErr_SetString(cName_Exception, "TooLongName");
-        }
-        if (ret->name == NULL) {
-            Py_DECREF(ret);
-            return NULL;
-        }
-    }
-    return (PyObject *) ret;
-}
-
-static PyObject *
-cName_downcase(cName *self) {
-    self->name->downcase();
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-cName_isWildcard(cName *self) {
-    if (self->name->isWildcard())
-        Py_RETURN_TRUE;
-    else
-        Py_RETURN_FALSE;
-}
-
-static PyObject *
-cName_getPosition(cName *self) {
-    return Py_BuildValue("I", (unsigned int) self->position);
-}
-
-static PyObject *
-cName_clone(cName *self, PyObject *args UNUSED_PARAM) {
-    cName *copy = PyObject_New(cName, &cName_Type);
-
-    if (copy != NULL) {
-        copy->name = new Name(*self->name);
-        if (copy->name == NULL) {
-            Py_DECREF(copy);
-            return NULL;
-        }
-    }
-    return (PyObject *) copy;
-}
-
-typedef struct {
-    PyObject_HEAD
-    MessageRenderer *mr;
-    OutputBuffer *buffer;
-} cMR;
-
-static void cMR_dealloc(cMR *self);
-static int cMR_init(cMR *self, PyObject *args);
-static PyObject *cMR_dump(cMR *self);
-static PyObject *cMR_writeData(cMR *self, PyObject *args);
-static PyObject *cMR_writeName(cMR *self, PyObject *args);
-
-static PyMethodDef cMR_Methods[] = {
-    { "dump", (PyCFunction)cMR_dump, METH_NOARGS,
-      "Return content of the MessageRenderer" },
-    { "writeData", (PyCFunction)cMR_writeData, METH_VARARGS,
-      "Write data into the MessageRenderer" },
-    { "writeName", (PyCFunction)cMR_writeName, METH_VARARGS,
-      "Write a Name into the MessageRenderer" },
-    { NULL, NULL, 0, NULL }
-};
-
-static PyTypeObject cMR_Type = {
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "bind10_dns_noboost.cMessageRenderer", /* tp_name */
-    sizeof(cMR),                        /* tp_basicsize */
-    0,                                  /* tp_itemsize */
-    (destructor)cMR_dealloc,            /* tp_dealloc */
-    NULL,                               /* tp_print */
-    NULL,                               /* tp_getattr */
-    NULL,                               /* tp_setattr */
-    NULL,                               /* tp_reserved */
-    NULL,                               /* tp_repr */
-    NULL,                               /* tp_as_number */
-    NULL,                               /* tp_as_sequence */
-    NULL,                               /* tp_as_mapping */
-    NULL,                               /* tp_hash  */
-    NULL,                               /* tp_call */
-    NULL,                               /* tp_str */
-    NULL,                               /* tp_getattro */
-    NULL,                               /* tp_setattro */
-    NULL,                               /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,     /* tp_flags */
-    "C++ MessageRenderer Object",       /* tp_doc */
-    NULL,                               /* tp_traverse */
-    NULL,                               /* tp_clear */
-    NULL,                               /* tp_richcompare */
-    0,                                  /* tp_weaklistoffset */
-    NULL,                               /* tp_iter */
-    NULL,                               /* tp_iternext */
-    cMR_Methods,                        /* tp_methods */
-    NULL,                               /* tp_members */
-    NULL,                               /* tp_getset */
-    NULL,                               /* tp_base */
-    NULL,                               /* tp_dict */
-    NULL,                               /* tp_descr_get */
-    NULL,                               /* tp_descr_set */
-    0,                                  /* tp_dictoffset */
-    (initproc)cMR_init,                 /* tp_init */
-    NULL,                               /* tp_alloc */
-    PyType_GenericNew,                  /* tp_new */
-    NULL,                               /* tp_free */
-    NULL,                               /* tp_is_gc */
-    NULL,                               /* tp_bases */
-    NULL,                               /* tp_mro */
-    NULL,                               /* tp_cache */
-    NULL,                               /* tp_subclasses */
-    NULL,                               /* tp_weaklist */
-    // Note: not sure if the following are correct.  Added them just to
-    // make the compiler happy.
-    NULL,                               /* tp_del */
-    0                                   /* tp_version_tag */
-};
-
-static void
-cMR_dealloc(cMR *self) {
-    if (self->mr != NULL)
-        delete self->mr;
-    self->mr = NULL;
-    if (self->buffer != NULL)
-        delete self->buffer;
-    self->buffer = NULL;
-    Py_TYPE(self)->tp_free(self);
-}
-
-static int
-cMR_init(cMR *self, PyObject *args) {
-    if (!PyArg_ParseTuple(args, ""))
-        return -1;
-
-    self->buffer = new OutputBuffer(1024);
-    if (self->buffer == NULL) {
-        (void) PyErr_NoMemory();
-        return -1;
-    }
-    self->mr = new MessageRenderer(*self->buffer);
-    if (self->mr == NULL) {
-        delete self->buffer;
-        self->buffer = NULL;
-        return -1;
-    }
-    return 0;
-}
-
-static PyObject *
-cMR_dump(cMR *self) {
-    return Py_BuildValue("y#", self->buffer->getData(),
-                         (Py_ssize_t) self->buffer->getLength());
-}
-
-static PyObject *
-cMR_writeData(cMR *self, PyObject *args) {
-    const char *b;
-    Py_ssize_t len;
-
-    if (!PyArg_ParseTuple(args, "y#", &b, &len))
-        return NULL;
-
-    self->buffer->writeData(b, len);
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-cMR_writeName(cMR *self, PyObject *args) {
-    cName *name;
-    PyObject *compress = Py_True;
-
-    if (!PyArg_ParseTuple(args, "O!|O!",
-                          &cName_Type, (PyObject **) &name,
-                          &PyBool_Type, &compress))
-        return NULL;
-
-    self->mr->writeName(*name->name, compress == Py_True);
-    Py_RETURN_NONE;
-}
-
-static PyModuleDef cName_Module = {
-    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL}, // XXX: ad hoc init values
-    "bind10_dns_noboost",                       /* m_name */
-    "Python bindings for C++ Name Module",      /* m_doc */
-    -1,                                 /* m_size */
-    NULL,                               /* m_methods */
-    NULL,                               /* m_reload */
-    NULL,                               /* m_traverse */
-    NULL,                               /* m_clear */
-    NULL,                               /* m_free */
-};
-
-PyMODINIT_FUNC
-PyInit_bind10_dns_noboost(void) {
-    if (PyType_Ready(&cName_Type) < 0)
-        return NULL;
-    if (PyType_Ready(&cNCR_Type) < 0)
-        return NULL;
-    if (PyType_Ready(&cMR_Type) < 0)
-        return NULL;
-
-    PyObject *mod;
-
-    mod = PyModule_Create(&cName_Module);
-    if (mod == NULL)
-        return NULL;
-
-    Py_INCREF(&cName_Type);
-    PyModule_AddObject(mod, "cName", (PyObject *) &cName_Type);
-    Py_INCREF(&cNCR_Type);
-    PyModule_AddObject(mod, "cNameComparisonResult",
-                       (PyObject *) &cNCR_Type);
-    Py_INCREF(&cMR_Type);
-    PyModule_AddObject(mod, "cMessageRenderer", (PyObject *) &cMR_Type);
-        
-    cName_Exception = PyErr_NewException("bind10_dns_noboost.DNSException", NULL,
-                                         NULL);
-    Py_INCREF(cName_Exception);
-    PyModule_AddObject(mod, "DNSException", cName_Exception);
-
-    cName_Relation = Py_BuildValue("{i:s,i:s,i:s,i:s}",
-                                   0, "SUPERDOMAIN",
-                                   1, "SUBDOMAIN",
-                                   2, "EQUAL",
-                                   3, "COMMONANCESTOR");
-    Py_INCREF(cName_Relation);
-    PyModule_AddObject(mod, "NameRelation", cName_Relation);
-
-    cName_MAX_WIRE = Py_BuildValue("I", 255U);
-    Py_INCREF(cName_MAX_WIRE);
-    PyModule_AddObject(mod, "MAX_WIRE", cName_MAX_WIRE);
-    cName_MAX_LABELS = Py_BuildValue("I", 128U);
-    Py_INCREF(cName_MAX_LABELS);
-    PyModule_AddObject(mod, "MAX_LABELS", cName_MAX_LABELS);
-    cName_MAX_LABELLEN = Py_BuildValue("I", 63U);
-    Py_INCREF(cName_MAX_LABELLEN);
-    PyModule_AddObject(mod, "MAX_LABELLEN", cName_MAX_LABELLEN);
-    cName_MAX_COMPRESS_POINTER = Py_BuildValue("I", 0x3fffU);
-    Py_INCREF(cName_MAX_COMPRESS_POINTER);
-    PyModule_AddObject(mod, "MAX_COMPRESS_POINTER",
-                       cName_MAX_COMPRESS_POINTER);
-    cName_COMPRESS_POINTER_MARK8 = Py_BuildValue("I", 0xc0U);
-    Py_INCREF(cName_COMPRESS_POINTER_MARK8);
-    PyModule_AddObject(mod, "COMPRESS_POINTER_MARK8",
-                       cName_COMPRESS_POINTER_MARK8);
-    cName_COMPRESS_POINTER_MARK16 = Py_BuildValue("I", 0xc000U);
-    Py_INCREF(cName_COMPRESS_POINTER_MARK16);
-    PyModule_AddObject(mod, "COMPRESS_POINTER_MARK16",
-                       cName_COMPRESS_POINTER_MARK16);
-
-    return mod;
-}

+ 0 - 49
src/lib/dns-python/dns.py

@@ -1,49 +0,0 @@
-"""Python C bindings"""
-
-import bind10_dns_noboost
-
-class Name(bind10_dns_noboost.cName):
-    """Python shadow class of cName"""
-
-    def __init__(self, *args):
-        """initializer"""
-        super(Name, self).__init__(*args)
-
-    def __len__(self):
-        """length"""
-        return self.getLength()
-
-    def __str__(self):
-        """string"""
-        return self.toText()
-
-    def __repr__(self):
-        """representation"""
-        return '<Name: ' + str(self) +'>'
-
-class MessageRenderer(bind10_dns_noboost.cMessageRenderer):
-    """Python shadow class of cMessageRenderer"""
-
-    def __init__(self):
-        """initializer"""
-        super(MessageRenderer, self).__init__()
-
-def fromText(text, downcase=False):
-    """fromText factory"""
-    return Name(text, downcase)
-
-def fromWire(wire, position, downcase=False):
-    """fromWire factory"""
-    n = Name(wire, position, downcase)
-    return (n, n.getPosition() - position)
-
-def compare(n1, n2):
-    """compare"""
-    ncr = n1.compare(n2)
-    return (ncr.getOrder(), \
-                ncr.getCommonLabels(), \
-                bind10_dns_noboost.NameRelation[ncr.getRelation()])
-
-def concatenate(n1, n2):
-    """concatenate"""
-    return n1.concatenate(n2)

+ 0 - 590
src/lib/dns-python/test.py

@@ -1,590 +0,0 @@
-"""Python tests"""
-
-from dns import *
-
-example = fromText("www.example.com")
-upper = fromText("WWW.EXAMPLE.COM")
-small = fromText("aaa.example.com")
-large = fromText("zzz.example.com")
-
-def f2b(name):
-    """file to binary"""
-    f = open(name)
-    rl = f.readlines()
-    f.close()
-    b = bytearray()
-    for l in rl:
-        if l[0] == '#':
-            continue
-        if l[-1] == '\n':
-            l = l[:-1]
-        b += bytearray().fromhex(l)
-    return bytes(b)
-
-def nflc():
-    """name Factory Lower Case"""
-    namestr = ''
-    labelcount = 0
-    for ch in range(0, bind10_dns_noboost.MAX_WIRE + 1):
-        if (ch < ord('A')) or (ch > ord('Z')):
-            ss = '%03d' % ch
-            namestr += '\\' + ss
-            labelcount += 1
-            if labelcount == bind10_dns_noboost.MAX_LABELLEN:
-                namestr += '.'
-                labelcount = 0
-    return Name(namestr)
-
-    
-
-def testFT():
-    """fromText"""
-    nl = []
-    nl.append(fromText("www.example.com"))
-    nl.append(fromText("www.example.com."))  # with a trailing dot
-    nl.append(fromText("wWw.exAmpLe.com"))   # mixed cases
-    nl.append(fromText("\\wWw.exAmpLe.com")) # escape with a backslash
-    # decimal representation for "WWW"
-    nl.append(fromText("\\087\\087\\087.example.com"))
-
-    for it in nl:
-        if it != example:
-            print('FAILED: (FT)',it,'!=',example)
-
-    # root names
-    if fromText("@") != fromText("."):
-        print('FAILED: (FT) root name')
-
-    # downcase
-    n = fromText("Www.eXample.coM", True)
-    if n.toWire() != example.toWire():
-        print('FAILED: (FT) downcase')
-
-    #
-    # Tests for bogus names.  These should trigger an exception.
-    #
-    # empty label cannot be followed by another label
-    try:
-        n = fromText(".a")
-        print('FAILED: (FT) .a')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'EmptyLabel':
-            print('FAILED: (FT) .a')
-    # duplicate period
-    try:
-        n = fromText("a..")
-        print('FAILED: (FT) a..')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'EmptyLabel':
-            print('FAILED: (FT) a..')
-    # label length must be < 64
-    try:
-        n = fromText("012345678901234567890123456789" +
-                     "012345678901234567890123456789" +
-                     "0123")
-        print('FAILED: (FT) TooLongLabel')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongLabel':
-            print('FAILED: (FT) TooLongLabel')
-    # now-unsupported bitstring labels
-    try:
-        n = fromText("\\[b11010000011101]")
-        print('FAILED: (FT) BadLabelType')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadLabelType':
-            print('FAILED: (FT) BadLabelType')
-    # label length must be < 64
-    try:
-        n = fromText("012345678901234567890123456789" +
-                     "012345678901234567890123456789" +
-                     "012\\x")
-        print('FAILED: (FT) TooLongLabel')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongLabel':
-            print('FAILED: (FT) TooLongLabel')
-    # but okay as long as resulting len < 64 even if the original string is
-    # "too long"
-    try:
-        n = fromText("012345678901234567890123456789" +
-                     "012345678901234567890123456789" +
-                     "01\\x")
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FT) too long')
-    # incomplete \DDD pattern (exactly 3 D's must appear)
-    try:
-        n = fromText("\\12abc")
-        print('FAILED: (FT) BadEscape')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadEscape':
-            print('FAILED: (FT) BadEscape')
-    # \DDD must not exceed 255
-    try:
-        n = fromText("\\256")
-        print('FAILED: (FT) BadEscape')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadEscape':
-            print('FAILED: (FT) BadEscape')
-    # Same tests for \111 as for \\x above
-    try:
-        n = fromText("012345678901234567890123456789" +
-                     "012345678901234567890123456789" +
-                     "012\\111")
-        print('FAILED: (FT) TooLongLabel')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongLabel':
-            print('FAILED: (FT) TooLongLabel')
-    try:
-        n = fromText("012345678901234567890123456789" +
-                     "012345678901234567890123456789" +
-                     "01\\111")
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FT) too long')
-    # A domain name must be 255 octets or less
-    try:
-        n = fromText("123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "1234")
-        print('FAILED: (FT) TooLongName')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongName':
-            print('FAILED: (FT) TooLongName')
-    # This is a possible longest name and should be accepted
-    try:
-        n = fromText("123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123456789.123456789.123456789.123456789.123456789." +
-                     "123")
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FT) longest')
-    # \DDD must consist of 3 digits
-    try:
-        n = fromText("\\12")
-        print('FAILED: (FT) IncompleteName')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'IncompleteName':
-            print('FAILED: (FT) IncompleteName')
-
-    # a name with the max number of labels.  should be constructed without
-    # an error, and its length should be the max value.
-    try:
-        n = fromText("0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." + # 40
-                     "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." + # 80
-                     "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." + # 120
-                     "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." + # 160
-                     "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." + # 200
-                     "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9." + # 240
-                     "0.1.2.3.4.5.6.")
-        if bind10_dns_noboost.MAX_LABELS != n.getLabelCount():
-            print('FAILED: (FT)',bind10_dns_noboost.MAX_LABELS,'!=',
-                  n.getLabelCount())
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FT) maxlabels')
-
-def testFW():
-    """fromWire"""
-    #
-    # test cases derived from BIND9 tests.
-    #
-    # normal case with a compression pointer
-    (n, _) = fromWire(f2b("testdata/name_fromWire1"), 25)
-    if n != fromText("vix.com"):
-        print('FAILED: (FW) n',n.toText(),'!=',"vix.com")
-    # bogus label character (looks like a local compression pointer)
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire2"), 25)
-        print('FAILED: (FW) BadLabelType')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadLabelType':
-            print('FAILED: (FW) BadLabelType')
-    # a bad compression pointer (too big)
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire3_1"), 25)
-        print('FAILED: (FW) BadPointer')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadPointer':
-            print('FAILED: (FW) BadPointer')
-    # forward reference
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire3_2"), 25)
-        print('FAILED: (FW) BadPointer')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadPointer':
-            print('FAILED: (FW) BadPointer')
-    # invalid name length
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire4"), 550)
-        print('FAILED: (FW) TooLongName')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongName':
-            print('FAILED: (FW) TooLongName')
-
-    # skip test for from Wire5.  It's for disabling decompression, but our
-    # implementation always allows it.
-
-    # bad pointer (too big)
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire6"), 25)
-        print('FAILED: (FW) BadPointer')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadPointer':
-            print('FAILED: (FW) BadPointer')
-    # input ends unexpectedly
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire7"), 25)
-        print('FAILED: (FW) IncompleteName')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'IncompleteName':
-            print('FAILED: (FW) IncompleteName')
-    # many hops of compression but valid.  should succeed
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire8"), 383)
-        if n != fromText("vix.com"):
-            print('FAILED: (FW) vix.com')
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FW) vix.com')
-
-    #
-    # Additional test cases
-    #
-
-    # large names, a long but valid one, and invalid (too long) one.
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire9"), 0)
-        if n.getLength() != bind10_dns_noboost.MAX_WIRE:
-            print('FAILED: (FW) ong but valid')
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FW) ong but valid')
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire10"), 0)
-        print('FAILED: (FW) TooLongName')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongName':
-            print('FAILED: (FW) TooLongName')
-
-    # A name with possible maximum number of labels; awkward but valid
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire11"), 0)
-        if n.getLabelCount() != bind10_dns_noboost.MAX_LABELS:
-            print('FAILED: (FW) maxlabels')
-    except bind10_dns_noboost.DNSException:
-        print('FAILED: (FW) maxlabels')
-
-    # Wire format including an invalid label length
-    try:
-        (n, _) = fromWire(f2b("testdata/name_fromWire12"), 0)
-        print('FAILED: (FW) BadLabelType')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'BadLabelType':
-            print('FAILED: (FW) BadLabelType')
-
-    # converting upper-case letters to down-case
-    (n, _) = fromWire(f2b("testdata/name_fromWire1"), 25, True)
-    if n.toText() != 'vix.com.':
-        print('FAILED: (FW) ',n.toText(),'!=','vix.com.')
-    if n.getLabelCount() != 3:
-        print('FAILED: (FW) ',n.getLabelCount(),'!= 3')
-
-def testTT():
-    """toText"""
-    # tests derived from BIND9
-    n = fromText("a.b.c.d")
-    if n.toText(True) != "a.b.c.d":
-        print('FAILED: (TT)',n.toText(True),'!= a.b.c.d')
-    n = fromText("a.\\\\[\\[.c.d")
-    if n.toText(True) != "a.\\\\[[.c.d":
-        print('FAILED: (TT)',n.toText(),'!= a.\\\\[[.c.d')
-    n = fromText("a.b.C.d")
-    if n.toText(False) != "a.b.C.d.":
-        print('FAILED: (TT)',n.toText(False),'!= a.b.C.d.')
-
-    # test omit_final_dot.  It's false by default.
-    n = fromText("a.b.c.d.")
-    if n.toText(True) != "a.b.c.d":
-        print('FAILED: (TT)',n.toText(True),'!= a.b.c.d')
-    n1 = fromText("a.b.")
-    n2 = fromText("a.b.")
-    if n1.toText(False) != n2.toText():
-        print('FAILED: (TT)',n1.toText(False))
-
-    # the root name is a special case: omit_final_dot will be ignored.
-    n = fromText(".")
-    if n.toText(True) != '.':
-        print('FAILED: (TT)',n.toText(True),' != ,')
-
-def testTW():
-    """toWire"""
-    data = "\x01\x61\x03\x76\x69\x78\x03\x63\x6f\x6d\x00"
-    n = fromText("a.vix.com.")
-    w = n.toWire()
-    if len(w) != len(data):
-        print('FAILED: (TW)',len(w),'!=',len(data))
-
-def testF():
-    """compare"""
-    n1 = fromText("c.d")
-    n2 = fromText("a.b.c.d")
-    t = compare(n1, n2)
-    if t[0] < 0:
-        tt = (-1, t[1], t[2])
-    elif t[0] > 0:
-        tt = (1, t[1],t[2])
-    else:
-        tt = (0, t[1],t[2])
-    if tt != (-1,3,'SUPERDOMAIN'):
-        print('FAILED: (F) ', tt)
-
-    n1 = fromText("a.b.c.d")
-    n2 = fromText("c.d")
-    t = compare(n1, n2)
-    if t[0] < 0:
-        tt = (-1, t[1], t[2])
-    elif t[0] > 0:
-        tt = (1, t[1],t[2])
-    else:
-        tt = (0, t[1],t[2])
-    if tt != (1, 3, 'SUBDOMAIN'):
-        print('FAILED: (F) ', tt)
-
-    n1 = fromText("a.b.c.d")
-    n2 = fromText("c.d.e.f")
-    t = compare(n1, n2)
-    if t[0] < 0:
-        tt = (-1, t[1], t[2])
-    elif t[0] > 0:
-        tt = (1, t[1],t[2])
-    else:
-        tt = (0, t[1],t[2])
-    if tt != (-1, 1, 'COMMONANCESTOR'):
-        print('FAILED: (F) ', tt)
-
-    n1 = fromText("a.b.c.d")
-    n2 = fromText("f.g.c.d")
-    t = compare(n1, n2)
-    if t[0] < 0:
-        tt = (-1, t[1], t[2])
-    elif t[0] > 0:
-        tt = (1, t[1],t[2])
-    else:
-        tt = (0, t[1],t[2])
-    if tt != (-1, 3, 'COMMONANCESTOR'):
-        print('FAILED: (F) ', tt)
-
-    n1 = fromText("a.b.c.d")
-    n2 = fromText("A.b.C.d.")
-    t = compare(n1, n2)
-    if t[0] < 0:
-        tt = (-1, t[1], t[2])
-    elif t[0] > 0:
-        tt = (1, t[1],t[2])
-    else:
-        tt = (0, t[1],t[2])
-    if tt != (0, 5, 'EQUAL'):
-        print('FAILED: (F) ', tt)
-
-def testE():
-    """equal"""
-    n = fromText("WWW.EXAMPLE.COM.")
-    if not (example == n):
-        print('FAILED: (E) 1')
-    if not example.equals(n):
-        print('FAILED: (E) 2')
-    n = fromText("www.example.org.")
-    if not (example != n):
-        print('FAILED: (E) 3')
-    if not example.nequals(n):
-        print('FAILED: (E) 4')
-
-def testIW():
-    """isWildcard"""
-    if not example.isWildcard() is False:
-        print('FAILED: (IW)',example.toText())
-    n = fromText("*.a.example.com")
-    if not n.isWildcard() is True:
-        print('FAILED: (IW)',n.toText())
-    n = fromText("a.*.example.com")
-    if not n.isWildcard() is False:
-        print('FAILED: (IW)',n.toText())
-
-def testC():
-    """concatenate"""
-    nc = fromText("aaa.www.example.com.")
-    n = fromText("aaa")
-    c = compare(nc, concatenate(n, example))
-    if c[2] != 'EQUAL':
-        print('FAILED: (C)',nc,'!=',n,'+',example)
-
-    n = fromText(".")
-    c = compare(example, concatenate(n, example))
-    if c[2] != 'EQUAL':
-        print('FAILED: (C)',example,'!=',n,'+',example)
-
-    c = compare(example, concatenate(example, n))
-    if c[2] != 'EQUAL':
-        print('FAILED: (C)',example,'!=',example,'+',n)
-
-    # concatenating two valid names would result in too long a name.
-    n1 = fromText("123456789.123456789.123456789.123456789.123456789." +
-                  "123456789.123456789.123456789.123456789.123456789." +
-                  "123456789.123456789.123456789.123456789.123456789.")
-    n2 = fromText("123456789.123456789.123456789.123456789.123456789." +
-                  "123456789.123456789.123456789.123456789.123456789." +
-                  "1234.");
-    try:
-        n = concatenate(n1, n2)
-        print('FAILED: (C) toolong')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'TooLongName':
-            print('FAILED: (C) TooLongName')
-
-def testS():
-    """split"""
-    # normal cases with or without explicitly specifying the trailing dot.
-    n = fromText("example.com.")
-    ns = example.split(1, 2)
-    if n != ns:
-        print('FAILED: (S)',n,'!=',ns)
-    ns = example.split(1, 3)
-    if n != ns:
-        print('FAILED: (S)',n,'!=',ns)
-    # edge cases: only the first or last label.
-    n = fromText("www.")
-    ns = example.split(0, 1)
-    if n != ns:
-        print('FAILED: (S)',n,'!=',ns)
-    n = fromText(".")
-    ns = example.split(3, 1)
-    if n != ns:
-        print('FAILED: (S)',n,'!=',ns)
-    # invalid range: an exception should be thrown.
-    try:
-        n = example.split(1, 0)
-        print('FAILED: (S) OutOfRange')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'OutOfRange':
-            print('FAILED: (S) OutOfRange')
-    try:
-        n = example.split(2, 3)
-        print('FAILED: (S) OutOfRange')
-    except bind10_dns_noboost.DNSException as e:
-        if str(e) != 'OutOfRange':
-            print('FAILED: (S) OutOfRange')
-
-def testD():
-    """downcase"""
-    # usual case: all-upper case name to all-lower case
-    upper.downcase()
-    if upper.toWire() != example.toWire():
-        print('FAILED: (D) upper')
-    # confirm that non upper-case characters are intact
-    n1 = nflc()
-    n2 = nflc()
-    n1.downcase()
-    if n1.toWire() != n2.toWire():
-        print('FAILED: (D) nameFactoryLowerCase')
-
-def testLE():
-    """leq"""
-    if not (small <= large) or \
-            not (small <= small) or \
-            large <= small:
-        print('FAILED: (LE)')
-
-def testGE():
-    """geq"""
-    if not (large >= small) or \
-            not (large >= large) or \
-            small >= large:
-        print('FAILED: (GE)')
-
-def testLT():
-    """lthan"""
-    if not (small < large) or \
-            small < small or \
-            large < small:
-        print('FAILED: (LT)')
-
-def testGT():
-    """gthan"""
-    if not (large > small) or \
-            large > large or \
-            small > large:
-        print('FAILED: (GT)')
-
-def testWN():
-    """writeName"""
-    data = f2b("testdata/name_toWire1")
-    mr = MessageRenderer()
-    n = fromText("a.example.com.")
-    mr.writeName(n)
-    n = fromText("b.example.com.")
-    mr.writeName(n)
-    n = fromText("a.example.org.")
-    mr.writeName(n)
-    if mr.dump() != data:
-        print('FAILED: (WN)',mr.dump(),'!=',data)
-
-    # toWireInLargeBuffer
-    pad = b'\x00' * 0x3fff
-    data = f2b("testdata/name_toWire2")
-    mr = MessageRenderer()
-    mr.writeData(pad)
-    n = fromText("a.example.com.")
-    mr.writeName(n)
-    n = fromText("a.example.com.")
-    mr.writeName(n)
-    n = fromText("b.example.com.")
-    mr.writeName(n)
-    d = mr.dump()[0x3fff :]
-    if d != data:
-        print('FAILED: (WN) LB',d,'!=',data)
-
-    # toWireWithUncompressed
-    data = f2b("testdata/name_toWire3")
-    mr = MessageRenderer()
-    n = fromText("a.example.com.")
-    mr.writeName(n)
-    n = fromText("b.example.com.")
-    mr.writeName(n, False)
-    n = fromText("b.example.com.")
-    mr.writeName(n)
-    if mr.dump() != data:
-        print('FAILED: (WN) UC',mr.dump(),'!=',data)
-
-    # toWireCaseCompress
-    data = f2b("testdata/name_toWire1")
-    mr = MessageRenderer()
-    n = fromText("a.example.com.")
-    mr.writeName(n)
-    # this should match the first name in terms of compression:
-    n = fromText("b.exAmple.CoM.")
-    mr.writeName(n)
-    n = fromText("a.example.org.")
-    mr.writeName(n)
-    if mr.dump() != data:
-        print('FAILED: (WN) CC',mr.dump(),'!=',data)
-
-def testAll():
-    """All"""
-    testFT()
-    testFW()
-    testTT()
-    testTW()
-    testF()
-    testE()
-    testIW()
-    testC()
-    testS()
-    testD()
-    testLE()
-    testGE()
-    testLT()
-    testGT()
-    testWN()
-
-testAll()
-print("PASSED")

+ 20 - 20
src/lib/dns/Makefile.am

@@ -79,26 +79,26 @@ libdns_la_SOURCES += question.h question.cc
 libdns_la_SOURCES += sha1.h sha1.cc
 libdns_la_SOURCES += tsig.h tsig.cc
 
-if HAVE_BOOST_PYTHON
-# This is a loadable module for python scripts, so we use the prefix "pyexec"
-# to make sure the object files will be installed in the appropriate place
-# for this purpose.
-pyexec_LTLIBRARIES = bind10_dns.la
-bind10_dns_la_SOURCES = python_dns.cc
-bind10_dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
-if GCC_WERROR_OK
-# XXX: Boost.Python triggers strict aliasing violation, so if we use -Werror
-# we need to suppress the warnings.
-bind10_dns_la_CPPFLAGS += -fno-strict-aliasing
-endif
-bind10_dns_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
-# Python prefers .so, while some OSes (specifically MacOS) use a different
-# suffix for dynamic objects.  -module is necessary to work this around.
-bind10_dns_la_LDFLAGS += -module
-bind10_dns_la_LIBADD = $(top_builddir)/src/lib/dns/libdns.la
-bind10_dns_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
-bind10_dns_la_LIBADD += $(BOOST_PYTHON_LIB) $(PYTHON_LIB)
-endif
+#if HAVE_BOOST_PYTHON
+## This is a loadable module for python scripts, so we use the prefix "pyexec"
+## to make sure the object files will be installed in the appropriate place
+## for this purpose.
+#pyexec_LTLIBRARIES = bind10_dns.la
+#bind10_dns_la_SOURCES = python_dns.cc
+#bind10_dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
+#if GCC_WERROR_OK
+## XXX: Boost.Python triggers strict aliasing violation, so if we use -Werror
+## we need to suppress the warnings.
+#bind10_dns_la_CPPFLAGS += -fno-strict-aliasing
+#endif
+#bind10_dns_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
+## Python prefers .so, while some OSes (specifically MacOS) use a different
+## suffix for dynamic objects.  -module is necessary to work this around.
+#bind10_dns_la_LDFLAGS += -module
+#bind10_dns_la_LIBADD = $(top_builddir)/src/lib/dns/libdns.la
+#bind10_dns_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+#bind10_dns_la_LIBADD += $(BOOST_PYTHON_LIB) $(PYTHON_LIB)
+#endif
 
 nodist_libdns_la_SOURCES = rdataclass.cc rrclass.h rrtype.h rrparamregistry.cc
 

+ 0 - 628
src/lib/dns/python_dns.cc

@@ -1,628 +0,0 @@
-// Copyright (C) 2009  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: message_python.cc 2010-03-08 18:44:00 feng $
-
-#include <boost/python.hpp>
-#include <boost/python/class.hpp>
-#include <boost/python/module.hpp>
-#include <boost/python/def.hpp>
-#include <boost/python/exception_translator.hpp>
-#include <boost/python/return_internal_reference.hpp>
-#include <boost/python/copy_const_reference.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <cassert>
-
-#include <exceptions/exceptions.h>
-
-#include <dns/buffer.h>
-#include <dns/name.h>
-#include <dns/messagerenderer.h>
-#include <dns/rrtype.h>
-#include <dns/rrclass.h>
-#include <dns/rrttl.h>
-#include <dns/rrset.h>
-#include <dns/rdata.h>
-#include <dns/rdataclass.h>
-#include <dns/rrsetlist.h>
-#include <dns/question.h>
-#include <dns/message.h>
-
-using namespace isc::dns;
-using namespace boost::python;
-
-#define DEFINE_EXCEPTION_TRANSLATOR(ex) \
-  void ex##_translator(const Exception &x){ PyErr_SetString(PyExc_UserWarning, x.what()); }
-
-#define REGISTER_EXCEPTION(ex) register_exception_translator<ex>(&ex##_translator)
-
-namespace
-{
-        using isc::Exception;
-        using isc::OutOfRange;
-        using isc::Unexpected;
-
-        DEFINE_EXCEPTION_TRANSLATOR(Exception)
-        DEFINE_EXCEPTION_TRANSLATOR(OutOfRange)
-        DEFINE_EXCEPTION_TRANSLATOR(Unexpected)
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidBufferPosition)
-        DEFINE_EXCEPTION_TRANSLATOR(EmptyLabel)
-        DEFINE_EXCEPTION_TRANSLATOR(TooLongName)
-        DEFINE_EXCEPTION_TRANSLATOR(TooLongLabel)
-        DEFINE_EXCEPTION_TRANSLATOR(BadLabelType)
-        DEFINE_EXCEPTION_TRANSLATOR(BadEscape)
-        DEFINE_EXCEPTION_TRANSLATOR(IncompleteName)
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidRRType)
-        DEFINE_EXCEPTION_TRANSLATOR(IncompleteRRType)
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidRRClass)
-        DEFINE_EXCEPTION_TRANSLATOR(IncompleteRRClass)
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidRRTTL)
-        DEFINE_EXCEPTION_TRANSLATOR(IncompleteRRTTL)
-        DEFINE_EXCEPTION_TRANSLATOR(EmptyRRset)
-        DEFINE_EXCEPTION_TRANSLATOR(DuplicateRRset)
-
-        using isc::dns::rdata::InvalidRdataLength;
-        using isc::dns::rdata::InvalidRdataText;
-        using isc::dns::rdata::CharStringTooLong;
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidRdataLength)
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidRdataText)
-        DEFINE_EXCEPTION_TRANSLATOR(CharStringTooLong)
-
-        DEFINE_EXCEPTION_TRANSLATOR(MessageTooShort);
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidMessageSection);
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidMessageOperation);
-        DEFINE_EXCEPTION_TRANSLATOR(InvalidMessageUDPSize);
-
-
-        class PyInputBuffer : public InputBuffer
-        {
-            public:
-            PyInputBuffer(object bytes) : InputBuffer(0,0)
-            {
-                if (PyBytes_Check(bytes.ptr())) {
-                    Py_ssize_t len = 0;
-                    PyBytes_AsStringAndSize(bytes.ptr(), (char **)&data_, &len);
-                    assert(len >= 0);
-                    len_ = len;
-                }
-            }
-        };
-
-        class PyOutputBuffer : public OutputBuffer
-        {
-        public:
-            PyOutputBuffer(size_t len) : OutputBuffer(len){}
-            object getBytes() const
-            {
-                PyObject *bytes = PyBytes_FromStringAndSize((char *)getData(), getLength());
-                return object(handle<>(bytes));
-            }
-
-            void writeBytes(object bytes)
-            {
-                if (PyBytes_Check(bytes.ptr()))
-                {
-                    uint8_t *raw_data = NULL;
-                    Py_ssize_t raw_data_len = 0;
-                    PyBytes_AsStringAndSize(bytes.ptr(), (char **)&raw_data,
-                                            &raw_data_len);
-                    assert(raw_data_len >= 0);
-                    writeData(raw_data, raw_data_len);
-
-                }
-            }
-
-
-    };
-
-    class PyMessageRenderer : public MessageRenderer
-    {
-        public:
-            PyMessageRenderer(OutputBuffer &buffer) : MessageRenderer(buffer){}
-            object getBytes() const
-            {
-                PyObject *bytes = PyBytes_FromStringAndSize((char *)getData(), getLength());
-                return object(handle<>(bytes));
-            }
-
-            void writeBytes(object bytes)
-            {
-                if (PyBytes_Check(bytes.ptr()))
-                {
-                    uint8_t *raw_data = NULL;
-                    Py_ssize_t raw_data_len = 0;
-                    PyBytes_AsStringAndSize(bytes.ptr(), (char **)&raw_data,
-                                            &raw_data_len);
-                    assert(raw_data_len >= 0);
-                    writeData(raw_data, raw_data_len);
-                }
-            }
-
-    };
-
-    class RRsetList_iterator_wrapper
-    {
-        public:
-            RRsetList_iterator_wrapper(const RRsetList& list) : cur_(list.begin()), end_(list.end()){}
-            RRsetPtr Next()
-            {
-                if(cur_ == end_) 
-                {
-                    PyErr_SetObject(PyExc_StopIteration, Py_None);
-                    throw_error_already_set();
-                }
-
-                RRsetPtr rrset = *cur_;
-                ++cur_;
-                return rrset;
-            }
-
-            static RRsetList_iterator_wrapper create(RRsetList &list)
-            {
-                return RRsetList_iterator_wrapper(list);
-            }
-
-        private:
-            RRsetList::const_iterator cur_;
-            RRsetList::const_iterator end_;
-    };
-
-    class Question_iterator_wrapper
-    {
-        public:
-            Question_iterator_wrapper(const Message &message) : cur_(message.beginQuestion()), end_(message.endQuestion()){}
-            QuestionPtr getQuestion() const { return *cur_;}
-            bool isLast() {return cur_ == end_;}
-            void next(){ ++cur_;}
-        private:
-            QuestionIterator cur_;
-            QuestionIterator end_;
-    };
-   
-    class Section_iterator_wrapper
-    {
-        public:
-            Section_iterator_wrapper(const Message &message, const Section &section) : cur_(message.beginSection(section)), end_(message.endSection(section)){}
-            RRsetPtr getRRset() const { return *cur_;}
-            bool isLast() {return cur_ == end_;}
-            void next(){ ++cur_;}
-
-        private:
-            RRsetIterator cur_;
-            RRsetIterator end_;
-    };
-
- 
-    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(write_name_overloads, writeName, 1, 2)
-    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(to_text_overloads, toText, 0, 1)
-    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(find_rrset_overloads, findRRset, 1, 2)
-    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(add_rrset_overloads, addRRset, 2, 3)
-}
-     
-BOOST_PYTHON_MODULE(bind10_dns)
-{
-    REGISTER_EXCEPTION(Exception);
-    REGISTER_EXCEPTION(OutOfRange);
-    REGISTER_EXCEPTION(Unexpected);
-    REGISTER_EXCEPTION(InvalidBufferPosition);
-    REGISTER_EXCEPTION(EmptyLabel);
-    REGISTER_EXCEPTION(TooLongName);
-    REGISTER_EXCEPTION(TooLongLabel);
-    REGISTER_EXCEPTION(BadLabelType);
-    REGISTER_EXCEPTION(BadEscape);
-    REGISTER_EXCEPTION(IncompleteName);
-    REGISTER_EXCEPTION(InvalidRRClass);
-    REGISTER_EXCEPTION(IncompleteRRClass);
-    REGISTER_EXCEPTION(InvalidRRTTL);
-    REGISTER_EXCEPTION(IncompleteRRTTL);
-    REGISTER_EXCEPTION(EmptyRRset);
-    REGISTER_EXCEPTION(InvalidRdataLength);
-    REGISTER_EXCEPTION(InvalidRdataText);
-    REGISTER_EXCEPTION(CharStringTooLong);
-    REGISTER_EXCEPTION(DuplicateRRset);
-    REGISTER_EXCEPTION(MessageTooShort);
-    REGISTER_EXCEPTION(InvalidMessageSection);
-    REGISTER_EXCEPTION(InvalidMessageOperation);
-    REGISTER_EXCEPTION(InvalidMessageUDPSize);
-
-
-    class_<InputBuffer>("cpp_input_buffer", init<const void *, size_t>())
-       .def("get_length", &InputBuffer::getLength)
-       .def("get_position", &InputBuffer::getPosition)
-       .def("set_position", &InputBuffer::setPosition)
-       .def("read_uint8", &InputBuffer::readUint8)
-       .def("read_uint16", &InputBuffer::readUint16)
-       .def("read_uint32", &InputBuffer::readUint32)
-       .def("read_data", &InputBuffer::readData);
-
-    class_<PyInputBuffer, bases<InputBuffer> >("input_buffer", init<object>());
-
-    class_<OutputBuffer>("cpp_output_buffer", init<size_t>())
-        .def("get_capacity", &OutputBuffer::getCapacity)
-        .def("get_length", &OutputBuffer::getLength)
-        .def("skip", &OutputBuffer::skip)
-        .def("clear", &OutputBuffer::clear)
-        .def("write_uint8", &OutputBuffer::writeUint8)
-        .def("write_uint16", &OutputBuffer::writeUint16)
-        .def("write_uint16_at", &OutputBuffer::writeUint16At)
-        .def("write_uint32", &OutputBuffer::writeUint32);
-
-
-    class_<PyOutputBuffer, bases<OutputBuffer> >("output_buffer", init<size_t>())
-        .def("get_data", &PyOutputBuffer::getBytes)
-        .def("write_data", &PyOutputBuffer::writeBytes);
-
-
-    enum_<NameComparisonResult::NameRelation>("name_relation")
-        .value("SUPER_DOMAIN", NameComparisonResult::SUPERDOMAIN)
-        .value("SUB_DOMAIN", NameComparisonResult::SUBDOMAIN)
-        .value("EQUAL", NameComparisonResult::EQUAL)
-        .value("COMMAON_ANCESTOR", NameComparisonResult::COMMONANCESTOR);
-
-    class_<NameComparisonResult>("name_comparison_result", init<int, unsigned int, NameComparisonResult::NameRelation>())
-        .def("get_order", &NameComparisonResult::getOrder)
-        .def("get_common_labels", &NameComparisonResult::getCommonLabels)
-        .def("get_relation", &NameComparisonResult::getRelation);
-
-    class_<MessageRenderer>("cpp_message_render", init<OutputBuffer &>())
-        .def("get_Length", &MessageRenderer::getLength)
-        .def("skip", &MessageRenderer::skip)
-        .def("clear", &MessageRenderer::clear)
-        .def("write_uint8", &MessageRenderer::writeUint8)
-        .def("write_uint16", &MessageRenderer::writeUint16)
-        .def("write_uint16_at", &MessageRenderer::writeUint16At)
-        .def("write_uint32", &MessageRenderer::writeUint32)
-        .def("write_name", &MessageRenderer::writeName, write_name_overloads(args("name", "compress")));
-
-
-   class_<PyMessageRenderer, bases<MessageRenderer> >("message_render", init<OutputBuffer &>())
-        .def("get_data", &PyMessageRenderer::getBytes)
-        .def("write_data", &PyMessageRenderer::writeBytes);
-
-   class_<Name>("name", init<const std::string &, optional<bool> >())
-       .def(init<InputBuffer &, optional<bool> >())
-       .def("at", &Name::at)
-       .def("get_lenght", &Name::getLength)
-       .def("get_label_count", &Name::getLabelCount)
-       .def("to_text", &Name::toText, to_text_overloads())
-       .def("to_wire", (void (Name::*)(MessageRenderer &)const)&Name::toWire)
-       .def("to_wire", (void (Name::*)(OutputBuffer&)const)&Name::toWire)
-       .def("compare", &Name::compare)
-       .def("split", &Name::split)
-       .def("concatenate", &Name::concatenate)
-       .def("downcase", &Name::downcase, return_value_policy<reference_existing_object>())       
-       .def("is_wildcard", &Name::isWildcard)
-       .def(self == self)
-       .def(self != self)
-       .def(self < self)
-       .def(self <= self)
-       .def(self > self)
-       .def(self >= self);
-
-   class_<RRType>("rr_type", init<uint16_t>())
-       .def(init<const std::string &>())
-       .def(init<InputBuffer &>())
-       .def("to_text", &RRType::toText)
-       .def("to_wire", (void (RRType::*)(MessageRenderer &)const)&RRType::toWire)
-       .def("to_wire", (void (RRType::*)(OutputBuffer &)const )&RRType::toWire)
-       .def("get_code", &RRType::getCode)
-       .def(self == self)
-       .def(self != self)
-       .def(self < self)
-       .def("DNAME", &RRType::DNAME, return_value_policy<copy_const_reference>())
-       .staticmethod("DNAME")
-       .def("MX", &RRType::MX, return_value_policy<copy_const_reference>())
-       .staticmethod("MX")
-       .def("DNSKEY", &RRType::DNSKEY, return_value_policy<copy_const_reference>())
-       .staticmethod("DNSKEY")
-       .def("TXT", &RRType::TXT, return_value_policy<copy_const_reference>())
-       .staticmethod("TXT")
-       .def("RRSIG", &RRType::RRSIG, return_value_policy<copy_const_reference>())
-       .staticmethod("RRSIG")
-       .def("NSEC", &RRType::NSEC, return_value_policy<copy_const_reference>())
-       .staticmethod("NSEC")
-       .def("AAAA", &RRType::AAAA, return_value_policy<copy_const_reference>())
-       .staticmethod("AAAA")
-       .def("DS", &RRType::DS, return_value_policy<copy_const_reference>())
-       .staticmethod("DS")
-       .def("OPT", &RRType::OPT, return_value_policy<copy_const_reference>())
-       .staticmethod("OPT")
-       .def("A", &RRType::A, return_value_policy<copy_const_reference>())
-       .staticmethod("A")
-       .def("NS", &RRType::NS, return_value_policy<copy_const_reference>())
-       .staticmethod("NS")
-       .def("CNAME", &RRType::CNAME, return_value_policy<copy_const_reference>())
-       .staticmethod("CNAME")
-       .def("SOA", &RRType::SOA, return_value_policy<copy_const_reference>())
-       .staticmethod("SOA")
-       .def("IXFR", &RRType::IXFR, return_value_policy<copy_const_reference>())
-       .staticmethod("IXFR")
-       .def("AXFR", &RRType::AXFR, return_value_policy<copy_const_reference>())
-       .staticmethod("AXFR")
-       .def("ANY", &RRType::ANY, return_value_policy<copy_const_reference>())
-       .staticmethod("ANY");
-
-   class_<RRClass>("rr_class", init<uint16_t>())
-       .def(init<const std::string &>())
-       .def(init<InputBuffer &>())
-       .def("to_text", &RRClass::toText)
-       .def("to_wire", (void (RRClass::*)(MessageRenderer &)const)&RRClass::toWire)
-       .def("to_wire", (void (RRClass::*)(OutputBuffer&)const)&RRClass::toWire)
-       .def("get_code", &RRClass::getCode)
-       .def(self == self)
-       .def(self != self)
-       .def(self < self)
-       .def("IN", &RRClass::IN, return_value_policy<copy_const_reference>())
-       .staticmethod("IN")
-       .def("CH", &RRClass::CH, return_value_policy<copy_const_reference>())
-       .staticmethod("CH")
-       .def("HS", &RRClass::HS, return_value_policy<copy_const_reference>())
-       .staticmethod("HS")
-       .def("NONE", &RRClass::NONE, return_value_policy<copy_const_reference>())
-       .staticmethod("NONE")
-       .def("ANY", &RRClass::ANY, return_value_policy<copy_const_reference>())
-       .staticmethod("ANY");
-
-    class_<RRTTL>("rr_ttl", init<uint32_t>())
-       .def(init<const std::string &>())
-       .def(init<InputBuffer &>())
-       .def("to_text", &RRTTL::toText)
-       .def("to_wire", (void (RRTTL::*)(MessageRenderer &)const)&RRTTL::toWire)
-       .def("to_wire", (void (RRTTL::*)(OutputBuffer&)const)&RRTTL::toWire)
-       .def("get_value", &RRTTL::getValue)
-       .def(self == self)
-       .def(self != self)
-       .def(self < self)
-       .def(self <= self)
-       .def(self > self)
-       .def(self >= self);
-
-    using isc::dns::rdata::Rdata;
-    class_<Rdata, boost::shared_ptr<Rdata>, boost::noncopyable>("abstract_rdata", no_init)
-        .def("to_text", &Rdata::toText)
-        .def("to_wire", (void (Rdata::*)(OutputBuffer &)const )&Rdata::toWire)
-        .def("to_wire", (void (Rdata::*)(MessageRenderer &)const)&Rdata::toWire)
-        .def("compare", &Rdata::compare);
-
-    using isc::dns::rdata::generic::Generic;
-    class_<Generic, bases<Rdata> >("rdata", init<const std::string &>())
-        .def(init<InputBuffer &, size_t>())
-        .def("to_text", &Generic::toText)
-        .def("to_wire", (void(Generic:: *)(OutputBuffer &)const)&Generic::toWire)
-        .def("to_wire", (void(Generic:: *)(MessageRenderer &)const)&Generic::toWire)
-        .def("compare", &Generic::compare);
-
-    using isc::dns::rdata::ch::A;
-    class_<A, bases<Rdata> >("a_rdata", init<const std::string &>()).def(init<InputBuffer &, size_t>())
-        .def("to_text", &A::toText)
-        .def("to_wire", (void(A:: *)(OutputBuffer &)const)&A::toWire)
-        .def("to_wire", (void(A:: *)(MessageRenderer &)const)&A::toWire)
-        .def("compare", &A::compare);
-
-
-
-    def("create_rdata", (rdata::RdataPtr (*)(const RRType &, const RRClass &, const std::string &))rdata::createRdata);
-    def("create_rdata", (rdata::RdataPtr (*)(const RRType &, const RRClass &, InputBuffer &, size_t))rdata::createRdata);
-    def("create_rdata", (rdata::RdataPtr (*)(const RRType &, const RRClass &, const Rdata &))rdata::createRdata);
-    
-    class_<AbstractRRset, boost::noncopyable>("abstract_rrset", no_init)
-        .def("get_rdata_count", &AbstractRRset::getRdataCount)
-        .def("get_name", &AbstractRRset::getName, return_internal_reference<>())
-        .def("get_class", &AbstractRRset::getClass, return_internal_reference<>())
-        .def("get_type", &AbstractRRset::getType, return_internal_reference<>())
-        .def("get_ttl", &AbstractRRset::getTTL, return_internal_reference<>())
-        .def("set_name", &AbstractRRset::setName)
-        .def("set_ttl", &AbstractRRset::setTTL)
-        .def("to_text", &AbstractRRset::toText)
-        .def("to_wire", (unsigned int (AbstractRRset::*)(MessageRenderer &)const)&AbstractRRset::toWire) 
-        .def("to_wire", (unsigned int (AbstractRRset::*)(OutputBuffer&)const)&AbstractRRset::toWire) 
-        .def("add_rdata", (void (AbstractRRset::*)(rdata::ConstRdataPtr))&AbstractRRset::addRdata)
-        .def("add_rdata", (void (AbstractRRset::*)(const rdata::Rdata &))&AbstractRRset::addRdata)
-        .def("get_rdata_iterator", &AbstractRRset::getRdataIterator);
-    
-    class_<RdataIterator, boost::shared_ptr<RdataIterator>, boost::noncopyable>("rdata_iter",no_init)
-        .def("first", &RdataIterator::first)
-        .def("next", &RdataIterator::next)
-        .def("get_current", &RdataIterator::getCurrent, return_internal_reference<>())
-        .def("is_last", &RdataIterator::isLast);
-    
-    class_<BasicRRset, bases<AbstractRRset>, boost::noncopyable>("basic_rrset", init<const Name &, const RRClass &, const RRType &, const RRTTL &>())
-        .def("get_rdata_count", &BasicRRset::getRdataCount)
-        .def("get_name", &BasicRRset::getName, return_internal_reference<>())
-        .def("get_class", &BasicRRset::getClass, return_internal_reference<>())
-        .def("get_type", &BasicRRset::getType, return_internal_reference<>())
-        .def("get_ttl", &BasicRRset::getTTL, return_internal_reference<>())
-        .def("set_name", &BasicRRset::setName)
-        .def("set_ttl", &BasicRRset::setTTL)
-        .def("to_text", &BasicRRset::toText)
-        .def("to_wire", (unsigned int (BasicRRset::*)(MessageRenderer &)const)&BasicRRset::toWire) 
-        .def("to_wire", (unsigned int (BasicRRset::*)(OutputBuffer&)const)&BasicRRset::toWire)
-        .def("add_rdata", (void (BasicRRset::*)(rdata::ConstRdataPtr))&BasicRRset::addRdata)
-        .def("add_rdata", (void (BasicRRset::*)(const rdata::Rdata &))&BasicRRset::addRdata)
-        .def("get_rdata_iterator", &BasicRRset::getRdataIterator);
-
-    class_<RRset, boost::shared_ptr<RRset>, bases<BasicRRset>, boost::noncopyable>("rrset", init<const Name&, const RRClass &, const RRType &, const RRTTL &>())
-        .def("set_name", &RRset::setName)
-        .def("set_ttl", &RRset::setTTL)
-        .def("add_rrsig", (void (RRset::*)(const rdata::RdataPtr))&RRset::addRRsig)
-        .def("add_rrsig", (void (RRset::*)(AbstractRRset &))&RRset::addRRsig)
-        .def("add_rrsig", (void (RRset::*)(RRsetPtr))&RRset::addRRsig)
-        .def("remove_rrsig", &RRset::removeRRsig)
-        .def("get_rrsig", &RRset::getRRsig);
-   
-    class_<RRsetList, boost::noncopyable>("rrset_list", init<>())
-        .def("add_rrset", &RRsetList::addRRset)
-        .def("find_rrset", &RRsetList::findRRset) 
-        .def("__iter__", &RRsetList_iterator_wrapper::create)
-        .def("__len__", &RRsetList::size);
-
-
-    class_<Question, boost::shared_ptr<Question> >("question", init<InputBuffer &>())
-        .def(init<const Name &, const RRClass &, const RRType &>())
-        .def("get_name", &Question::getName, return_internal_reference<>())
-        .def("get_type", &Question::getType, return_internal_reference<>())
-        .def("get_class", &Question::getClass, return_internal_reference<>())
-        .def("to_text", &Question::toText)
-        .def("to_wire", (unsigned int(Question::*)(MessageRenderer &)const)&Question::toWire)
-        .def("to_wire", (unsigned int (Question::*)(OutputBuffer&)const)&Question::toWire);
-
-   class_<MessageFlag>("message_flag", no_init)
-        .def("get_bit", &MessageFlag::getBit)
-        .def("QR", &MessageFlag::QR, return_value_policy<copy_const_reference>())
-        .staticmethod("QR")
-        .def("AA", &MessageFlag::AA, return_value_policy<copy_const_reference>())
-        .staticmethod("AA")
-        .def("TC", &MessageFlag::TC, return_value_policy<copy_const_reference>())
-        .staticmethod("TC")
-        .def("RD", &MessageFlag::RD, return_value_policy<copy_const_reference>())
-        .staticmethod("RD")
-        .def("RA", &MessageFlag::RA, return_value_policy<copy_const_reference>())
-        .staticmethod("RA")
-        .def("AD", &MessageFlag::AD, return_value_policy<copy_const_reference>())
-        .staticmethod("AD")
-        .def("CD", &MessageFlag::CD, return_value_policy<copy_const_reference>())
-        .staticmethod("CD");
-      
-       class_<Opcode>("op_code", no_init)
-        .def("get_code", &Opcode::getCode)
-        .def(self == self)
-        .def("to_text", &Opcode::toText)
-        .def("QUERY", &Opcode::QUERY, return_value_policy<copy_const_reference>())
-        .staticmethod("QUERY")
-        .def("IQUERY", &Opcode::IQUERY, return_value_policy<copy_const_reference>())
-        .staticmethod("IQUERY")
-        .def("STATUS", &Opcode::STATUS, return_value_policy<copy_const_reference>())
-        .staticmethod("STATUS")
-        .def("RESERVED3", &Opcode::RESERVED3, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED3")
-        .def("NOTIFY", &Opcode::NOTIFY, return_value_policy<copy_const_reference>())
-        .staticmethod("NOTIFY")
-        .def("UPDATE", &Opcode::UPDATE, return_value_policy<copy_const_reference>())
-        .staticmethod("UPDATE")
-        .def("RESERVED6", &Opcode::RESERVED6, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED6")
-        .def("RESERVED7", &Opcode::RESERVED7, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED7")
-        .def("RESERVED8", &Opcode::RESERVED8, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED8")
-        .def("RESERVED9", &Opcode::RESERVED9, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED9")
-        .def("RESERVED10", &Opcode::RESERVED10, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED10")
-        .def("RESERVED11", &Opcode::RESERVED11, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED11")
-        .def("RESERVED12", &Opcode::RESERVED12, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED12")
-        .def("RESERVED13", &Opcode::RESERVED13, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED13")
-        .def("RESERVED14", &Opcode::RESERVED14, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED14")
-        .def("RESERVED15", &Opcode::RESERVED15, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED15");
-      
-    class_<Rcode>("rcode", init<uint16_t>())
-        .def("get_code", &Rcode::getCode)
-        .def(self == self)
-        .def("to_text", &Rcode::toText)
-        .def("NOERROR", &Rcode::NOERROR, return_value_policy<copy_const_reference>())
-        .staticmethod("NOERROR")
-        .def("FORMERR", &Rcode::FORMERR, return_value_policy<copy_const_reference>())
-        .staticmethod("FORMERR")
-        .def("SERVFAIL", &Rcode::SERVFAIL, return_value_policy<copy_const_reference>())
-        .staticmethod("SERVFAIL")
-        .def("NXDOMAIN", &Rcode::NXDOMAIN, return_value_policy<copy_const_reference>())
-        .staticmethod("NXDOMAIN")
-        .def("NOTIMP", &Rcode::NOTIMP, return_value_policy<copy_const_reference>())
-        .staticmethod("NOTIMP")
-        .def("REFUSED", &Rcode::REFUSED, return_value_policy<copy_const_reference>())
-        .staticmethod("REFUSED")
-        .def("YXDOMAIN", &Rcode::YXDOMAIN, return_value_policy<copy_const_reference>())
-        .staticmethod("YXDOMAIN")
-        .def("YXRRSET", &Rcode::YXRRSET, return_value_policy<copy_const_reference>())
-        .staticmethod("YXRRSET")
-        .def("NXRRSET", &Rcode::NXRRSET, return_value_policy<copy_const_reference>())
-        .staticmethod("NXRRSET")
-        .def("NOTAUTH", &Rcode::NOTAUTH, return_value_policy<copy_const_reference>())
-        .staticmethod("NOTAUTH")
-        .def("NOTZONE", &Rcode::NOTZONE, return_value_policy<copy_const_reference>())
-        .staticmethod("NOTZONE")
-        .def("RESERVED11", &Rcode::RESERVED11, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED11")
-        .def("RESERVED12", &Rcode::RESERVED12, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED12")
-        .def("RESERVED13", &Rcode::RESERVED13, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED13")
-        .def("RESERVED14", &Rcode::RESERVED14, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED14")
-        .def("RESERVED15", &Rcode::RESERVED15, return_value_policy<copy_const_reference>())
-        .staticmethod("RESERVED15")
-        .def("BADVERS", &Rcode::BADVERS, return_value_policy<copy_const_reference>())
-        .staticmethod("BADVERS");
-      
-    class_<Section>("section", no_init)
-        .def("get_code", &Section::getCode)
-        .def(self == self)
-        .def(self != self)
-        .def("QUESTION", &Section::QUESTION, return_value_policy<copy_const_reference>())
-        .staticmethod("QUESTION")
-        .def("ANSWER", &Section::ANSWER, return_value_policy<copy_const_reference>())
-        .staticmethod("ANSWER")
-        .def("AUTHORITY", &Section::AUTHORITY, return_value_policy<copy_const_reference>())
-        .staticmethod("AUTHORITY")
-        .def("ADDITIONAL", &Section::ADDITIONAL, return_value_policy<copy_const_reference>())
-        .staticmethod("ADDITIONAL");
-
-    enum_<Message::Mode>("message_mode")
-        .value("PARSE", Message::PARSE)
-        .value("RENDER", Message::RENDER);
-
-    class_<Message, boost::noncopyable>("message", init<Message::Mode>())
-        .def("get_header_flag", &Message::getHeaderFlag)
-        .def("set_header_flag", &Message::setHeaderFlag)
-        .def("clear_header_flag", &Message::clearHeaderFlag)
-        .def("is_dnsssec_supported", &Message::isDNSSECSupported)
-        .def("set_dnssec_supported", &Message::setDNSSECSupported)
-        .def("parse_header", &Message::parseHeader)
-        .def("get_udp_size", &Message::getUDPSize)
-        .def("set_udp_size", &Message::setUDPSize)
-        .def("get_qid", &Message::getQid)
-        .def("set_qid", &Message::setQid)
-        .def("get_rcode", &Message::getRcode, return_internal_reference<>())
-        .def("set_rcode", &Message::setRcode)
-        .def("get_opcode", &Message::getOpcode, return_internal_reference<>())
-        .def("set_opcode", &Message::setOpcode, with_custodian_and_ward<1,2>())
-        .def("to_text", &Message::toText)
-        .def("get_rr_count", &Message::getRRCount)
-        .def("add_question", (void (Message:: *)(QuestionPtr))&Message::addQuestion)
-        .def("add_question", (void (Message:: *)(const Question&))&Message::addQuestion)
-        //.def("remove_question", &Message::removeQuestion)
-        .def("add_rrset", &Message::addRRset, add_rrset_overloads(args("section","rrset","sign")))
-        //.def("remove_rrset", &Message::removeRRset)
-        .def("clear", &Message::clear)
-        .def("make_response", &Message::makeResponse)
-        .def("to_wire", &Message::toWire)
-        .def("from_wire", &Message::fromWire);
-
-    class_<Question_iterator_wrapper>("question_iter", init<const Message &>())
-        .def("get_question", &Question_iterator_wrapper::getQuestion)
-        .def("is_last", &Question_iterator_wrapper::isLast)
-        .def("next", &Question_iterator_wrapper::next);
-
-    class_<Section_iterator_wrapper>("section_iter", init<const Message &, const Section &>())
-        .def("get_rrset", &Section_iterator_wrapper::getRRset)
-        .def("is_last", &Section_iterator_wrapper::isLast)
-        .def("next", &Section_iterator_wrapper::next);
-}
-