BIND 10 trac871, updated. b8422db8e0120d3998b15581dddcbfe4efe91a68 [trac871] Revert "[trac871] unrelated cleanup: use unnamed namespace instead of file-scope static."

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Apr 29 08:47:53 UTC 2011


The branch, trac871 has been updated
       via  b8422db8e0120d3998b15581dddcbfe4efe91a68 (commit)
       via  da16cc776443e1414f779d7402996c6949934765 (commit)
      from  d6db622c5649e745fb3c64218e36c41545c47aed (commit)

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

- Log -----------------------------------------------------------------
commit b8422db8e0120d3998b15581dddcbfe4efe91a68
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri Apr 29 01:47:38 2011 -0700

    [trac871] Revert "[trac871] unrelated cleanup: use unnamed namespace instead of file-scope static."
    
    This was committed to the wrong branch.
    
    This reverts commit cce60befee1e0c25e20449b9242112cc0a777089.

commit da16cc776443e1414f779d7402996c6949934765
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Fri Apr 29 01:47:08 2011 -0700

    [trac871] Revert "[trac871] implemented a minimal set of python lib for TSIG: just allowing construction of TSIGContext and add another signature to Message.to_wire() to send a signed message."
    
    (this was committed to the wrong branch)
    
    This reverts commit d6db622c5649e745fb3c64218e36c41545c47aed.

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

Summary of changes:
 src/lib/dns/python/Makefile.am                  |    1 -
 src/lib/dns/python/message_python.cc            |  123 +++++++++---------
 src/lib/dns/python/pydnspp.cc                   |    5 -
 src/lib/dns/python/tests/Makefile.am            |    1 -
 src/lib/dns/python/tests/message_python_test.py |   35 -----
 src/lib/dns/python/tests/tsig_python_test.py    |   29 ----
 src/lib/dns/python/tsig_python.cc               |  157 -----------------------
 7 files changed, 59 insertions(+), 292 deletions(-)
 delete mode 100644 src/lib/dns/python/tests/tsig_python_test.py
 delete mode 100644 src/lib/dns/python/tsig_python.cc

-----------------------------------------------------------------------
diff --git a/src/lib/dns/python/Makefile.am b/src/lib/dns/python/Makefile.am
index 9162f4e..9d171cd 100644
--- a/src/lib/dns/python/Makefile.am
+++ b/src/lib/dns/python/Makefile.am
@@ -25,7 +25,6 @@ EXTRA_DIST += rrttl_python.cc
 EXTRA_DIST += rdata_python.cc
 EXTRA_DIST += rrtype_python.cc
 EXTRA_DIST += tsigkey_python.cc
-EXTRA_DIST += tsig_python.cc
 
 # Python prefers .so, while some OSes (specifically MacOS) use a different
 # suffix for dynamic objects.  -module is necessary to work this around.
diff --git a/src/lib/dns/python/message_python.cc b/src/lib/dns/python/message_python.cc
index e3cc53f..058312e 100644
--- a/src/lib/dns/python/message_python.cc
+++ b/src/lib/dns/python/message_python.cc
@@ -17,16 +17,15 @@
 using namespace isc::dns;
 using namespace isc::util;
 
-namespace {
 //
 // Declaration of the custom exceptions
 // Initialization and addition of these go in the initModulePart
 // function at the end of this file
 //
-PyObject* po_MessageTooShort;
-PyObject* po_InvalidMessageSection;
-PyObject* po_InvalidMessageOperation;
-PyObject* po_InvalidMessageUDPSize;
+static PyObject* po_MessageTooShort;
+static PyObject* po_InvalidMessageSection;
+static PyObject* po_InvalidMessageOperation;
+static PyObject* po_InvalidMessageUDPSize;
 
 //
 // Definition of the classes
@@ -37,6 +36,10 @@ PyObject* po_InvalidMessageUDPSize;
 // and a type description
 
 //
+// Section
+//
+
+//
 // Message
 //
 
@@ -52,36 +55,36 @@ public:
 //
 
 // General creation and destruction
-int Message_init(s_Message* self, PyObject* args);
-void Message_destroy(s_Message* self);
-
-PyObject* Message_getHeaderFlag(s_Message* self, PyObject* args);
-PyObject* Message_setHeaderFlag(s_Message* self, PyObject* args);
-PyObject* Message_getQid(s_Message* self);
-PyObject* Message_setQid(s_Message* self, PyObject* args);
-PyObject* Message_getRcode(s_Message* self);
-PyObject* Message_setRcode(s_Message* self, PyObject* args);
-PyObject* Message_getOpcode(s_Message* self);
-PyObject* Message_setOpcode(s_Message* self, PyObject* args);
-PyObject* Message_getEDNS(s_Message* self);
-PyObject* Message_setEDNS(s_Message* self, PyObject* args);
-PyObject* Message_getRRCount(s_Message* self, PyObject* args);
+static int Message_init(s_Message* self, PyObject* args);
+static void Message_destroy(s_Message* self);
+
+static PyObject* Message_getHeaderFlag(s_Message* self, PyObject* args);
+static PyObject* Message_setHeaderFlag(s_Message* self, PyObject* args);
+static PyObject* Message_getQid(s_Message* self);
+static PyObject* Message_setQid(s_Message* self, PyObject* args);
+static PyObject* Message_getRcode(s_Message* self);
+static PyObject* Message_setRcode(s_Message* self, PyObject* args);
+static PyObject* Message_getOpcode(s_Message* self);
+static PyObject* Message_setOpcode(s_Message* self, PyObject* args);
+static PyObject* Message_getEDNS(s_Message* self);
+static PyObject* Message_setEDNS(s_Message* self, PyObject* args);
+static PyObject* Message_getRRCount(s_Message* self, PyObject* args);
 // use direct iterators for these? (or simply lists for now?)
-PyObject* Message_getQuestion(s_Message* self);
-PyObject* Message_getSection(s_Message* self, PyObject* args);
+static PyObject* Message_getQuestion(s_Message* self);
+static PyObject* Message_getSection(s_Message* self, PyObject* args);
 //static PyObject* Message_beginQuestion(s_Message* self, PyObject* args);
 //static PyObject* Message_endQuestion(s_Message* self, PyObject* args);
 //static PyObject* Message_beginSection(s_Message* self, PyObject* args);
 //static PyObject* Message_endSection(s_Message* self, PyObject* args);
 
-PyObject* Message_addQuestion(s_Message* self, PyObject* args);
-PyObject* Message_addRRset(s_Message* self, PyObject* args);
-PyObject* Message_clear(s_Message* self, PyObject* args);
-PyObject* Message_makeResponse(s_Message* self);
-PyObject* Message_toText(s_Message* self);
-PyObject* Message_str(PyObject* self);
-PyObject* Message_toWire(s_Message* self, PyObject* args);
-PyObject* Message_fromWire(s_Message* self, PyObject* args);
+static PyObject* Message_addQuestion(s_Message* self, PyObject* args);
+static PyObject* Message_addRRset(s_Message* self, PyObject* args);
+static PyObject* Message_clear(s_Message* self, PyObject* args);
+static PyObject* Message_makeResponse(s_Message* self);
+static PyObject* Message_toText(s_Message* self);
+static PyObject* Message_str(PyObject* self);
+static PyObject* Message_toWire(s_Message* self, PyObject* args);
+static PyObject* Message_fromWire(s_Message* self, PyObject* args);
 
 // This list contains the actual set of functions we have in
 // python. Each entry has
@@ -89,7 +92,7 @@ PyObject* Message_fromWire(s_Message* self, PyObject* args);
 // 2. Our static function here
 // 3. Argument type
 // 4. Documentation
-PyMethodDef Message_methods[] = {
+static PyMethodDef Message_methods[] = {
     { "get_header_flag", reinterpret_cast<PyCFunction>(Message_getHeaderFlag),
       METH_VARARGS,
       "Return whether the specified header flag bit is set in the "
@@ -172,7 +175,7 @@ PyMethodDef Message_methods[] = {
 // This defines the complete type for reflection in python and
 // parsing of PyObject* to s_Message
 // Most of the functions are not actually implemented and NULL here.
-PyTypeObject message_type = {
+static PyTypeObject message_type = {
     PyVarObject_HEAD_INIT(NULL, 0)
     "pydnspp.Message",
     sizeof(s_Message),                  // tp_basicsize
@@ -222,7 +225,7 @@ PyTypeObject message_type = {
     0                                   // tp_version_tag
 };
 
-int
+static int
 Message_init(s_Message* self, PyObject* args) {
     int i;
 
@@ -245,14 +248,14 @@ Message_init(s_Message* self, PyObject* args) {
     return (-1);
 }
 
-void
+static void
 Message_destroy(s_Message* self) {
     delete self->message;
     self->message = NULL;
     Py_TYPE(self)->tp_free(self);
 }
 
-PyObject*
+static PyObject*
 Message_getHeaderFlag(s_Message* self, PyObject* args) {
     unsigned int messageflag;
     if (!PyArg_ParseTuple(args, "I", &messageflag)) {
@@ -270,7 +273,7 @@ Message_getHeaderFlag(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_setHeaderFlag(s_Message* self, PyObject* args) {
     long messageflag;
     PyObject *on = Py_True;
@@ -301,12 +304,12 @@ Message_setHeaderFlag(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_getQid(s_Message* self) {
     return (Py_BuildValue("I", self->message->getQid()));
 }
 
-PyObject*
+static PyObject*
 Message_setQid(s_Message* self, PyObject* args) {
     long id;
     if (!PyArg_ParseTuple(args, "l", &id)) {
@@ -330,7 +333,7 @@ Message_setQid(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_getRcode(s_Message* self) {
     s_Rcode* rcode;
 
@@ -353,7 +356,7 @@ Message_getRcode(s_Message* self) {
     return (rcode);
 }
 
-PyObject*
+static PyObject*
 Message_setRcode(s_Message* self, PyObject* args) {
     s_Rcode* rcode;
     if (!PyArg_ParseTuple(args, "O!", &rcode_type, &rcode)) {
@@ -368,7 +371,7 @@ Message_setRcode(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_getOpcode(s_Message* self) {
     s_Opcode* opcode;
 
@@ -391,7 +394,7 @@ Message_getOpcode(s_Message* self) {
     return (opcode);
 }
 
-PyObject*
+static PyObject*
 Message_setOpcode(s_Message* self, PyObject* args) {
     s_Opcode* opcode;
     if (!PyArg_ParseTuple(args, "O!", &opcode_type, &opcode)) {
@@ -406,7 +409,7 @@ Message_setOpcode(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_getEDNS(s_Message* self) {
     s_EDNS* edns;
     EDNS* edns_body;
@@ -426,7 +429,7 @@ Message_getEDNS(s_Message* self) {
     return (edns);
 }
 
-PyObject*
+static PyObject*
 Message_setEDNS(s_Message* self, PyObject* args) {
     s_EDNS* edns;
     if (!PyArg_ParseTuple(args, "O!", &edns_type, &edns)) {
@@ -441,7 +444,7 @@ Message_setEDNS(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_getRRCount(s_Message* self, PyObject* args) {
     unsigned int section;
     if (!PyArg_ParseTuple(args, "I", &section)) {
@@ -460,7 +463,7 @@ Message_getRRCount(s_Message* self, PyObject* args) {
 }
 
 // TODO use direct iterators for these? (or simply lists for now?)
-PyObject*
+static PyObject*
 Message_getQuestion(s_Message* self) {
     QuestionIterator qi, qi_end;
     try {
@@ -499,7 +502,7 @@ Message_getQuestion(s_Message* self) {
     return (list);
 }
 
-PyObject*
+static PyObject*
 Message_getSection(s_Message* self, PyObject* args) {
     unsigned int section;
     if (!PyArg_ParseTuple(args, "I", &section)) {
@@ -556,7 +559,7 @@ Message_getSection(s_Message* self, PyObject* args) {
 //static PyObject* Message_beginSection(s_Message* self, PyObject* args);
 //static PyObject* Message_endSection(s_Message* self, PyObject* args);
 //static PyObject* Message_addQuestion(s_Message* self, PyObject* args);
-PyObject*
+static PyObject*
 Message_addQuestion(s_Message* self, PyObject* args) {
     s_Question *question;
 
@@ -569,7 +572,7 @@ Message_addQuestion(s_Message* self, PyObject* args) {
     Py_RETURN_NONE;
 }
 
-PyObject*
+static PyObject*
 Message_addRRset(s_Message* self, PyObject* args) {
     PyObject *sign = Py_False;
     int section;
@@ -596,7 +599,7 @@ Message_addRRset(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_clear(s_Message* self, PyObject* args) {
     int i;
     if (PyArg_ParseTuple(args, "i", &i)) {
@@ -617,13 +620,13 @@ Message_clear(s_Message* self, PyObject* args) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_makeResponse(s_Message* self) {
     self->message->makeResponse();
     Py_RETURN_NONE;
 }
 
-PyObject*
+static PyObject*
 Message_toText(s_Message* self) {
     // Py_BuildValue makes python objects from native data
     try {
@@ -638,7 +641,7 @@ Message_toText(s_Message* self) {
     }
 }
 
-PyObject*
+static PyObject*
 Message_str(PyObject* self) {
     // Simply call the to_text method we already defined
     return (PyObject_CallMethod(self,
@@ -646,20 +649,13 @@ Message_str(PyObject* self) {
                                 const_cast<char*>("")));
 }
 
-PyObject*
+static PyObject*
 Message_toWire(s_Message* self, PyObject* args) {
     s_MessageRenderer* mr;
-    s_TSIGContext* tsig_ctx = NULL;
     
-    if (PyArg_ParseTuple(args, "O!|O!", &messagerenderer_type, &mr,
-                         &tsig_context_type, &tsig_ctx)) {
+    if (PyArg_ParseTuple(args, "O!", &messagerenderer_type, &mr)) {
         try {
-            if (tsig_ctx == NULL) {
-                self->message->toWire(*mr->messagerenderer);
-            } else {
-                self->message->toWire(*mr->messagerenderer,
-                                      *tsig_ctx->tsig_ctx);
-            }
+            self->message->toWire(*mr->messagerenderer);
             // If we return NULL it is seen as an error, so use this for
             // None returns
             Py_RETURN_NONE;
@@ -675,7 +671,7 @@ Message_toWire(s_Message* self, PyObject* args) {
     return (NULL);
 }
 
-PyObject*
+static PyObject*
 Message_fromWire(s_Message* self, PyObject* args) {
     const char* b;
     Py_ssize_t len;
@@ -769,4 +765,3 @@ initModulePart_Message(PyObject* mod) {
 
     return (true);
 }
-} // end of unnamed namespace
diff --git a/src/lib/dns/python/pydnspp.cc b/src/lib/dns/python/pydnspp.cc
index 2138198..27dbae6 100644
--- a/src/lib/dns/python/pydnspp.cc
+++ b/src/lib/dns/python/pydnspp.cc
@@ -56,7 +56,6 @@ static PyObject* po_DNSMessageBADVERS;
 #include <dns/python/question_python.cc>       // needs RRClass, RRType, RRTTL,
                                                // Name
 #include <dns/python/tsigkey_python.cc>        // needs Name
-#include <dns/python/tsig_python.cc>           // needs tsigkey
 #include <dns/python/opcode_python.cc>
 #include <dns/python/rcode_python.cc>
 #include <dns/python/edns_python.cc>           // needs Messagerenderer, Rcode
@@ -154,10 +153,6 @@ PyInit_pydnspp(void) {
         return (NULL);
     }
 
-    if (!initModulePart_TSIGContext(mod)) {
-        return (NULL);
-    }
-
     return (mod);
 }
 
diff --git a/src/lib/dns/python/tests/Makefile.am b/src/lib/dns/python/tests/Makefile.am
index 9ee98c7..184f06d 100644
--- a/src/lib/dns/python/tests/Makefile.am
+++ b/src/lib/dns/python/tests/Makefile.am
@@ -11,7 +11,6 @@ PYTESTS += rrclass_python_test.py
 PYTESTS += rrset_python_test.py
 PYTESTS += rrttl_python_test.py
 PYTESTS += rrtype_python_test.py
-PYTESTS += tsig_python_test.py
 PYTESTS += tsigkey_python_test.py
 
 EXTRA_DIST = $(PYTESTS)
diff --git a/src/lib/dns/python/tests/message_python_test.py b/src/lib/dns/python/tests/message_python_test.py
index 811ecf3..bccc596 100644
--- a/src/lib/dns/python/tests/message_python_test.py
+++ b/src/lib/dns/python/tests/message_python_test.py
@@ -62,12 +62,6 @@ def create_message():
     message_render.add_rrset(Message.SECTION_ANSWER, rrset)
     return message_render
 
-def strip_mutable_tsig_data(data):
-    # Unfortunately we cannot easily compare TSIG RR because we can't tweak
-    # current time.  As a work around this helper function strips off the time
-    # dependent part of TSIG RDATA, i.e., the MAC (assuming HMAC-MD5) and
-    # Time Signed.
-    return data[0:-32] + data[-26:-22] + data[-6:]
 
 class MessageTest(unittest.TestCase):
 
@@ -87,8 +81,6 @@ class MessageTest(unittest.TestCase):
 
         self.bogus_section = Message.SECTION_ADDITIONAL + 1
         self.bogus_below_section = Message.SECTION_QUESTION - 1
-        self.tsig_key = TSIGKey("www.example.com:SFuWd/q99SzF8Yzd1QbB9g==")
-        self.tsig_ctx = TSIGContext(self.tsig_key)
 
     def test_init(self):
         self.assertRaises(TypeError, Message, -1)
@@ -285,33 +277,6 @@ class MessageTest(unittest.TestCase):
         self.assertRaises(InvalidMessageOperation, self.r.to_wire,
                           MessageRenderer())
 
-    def __common_tsigquery_setup(self):
-        self.r.set_opcode(Opcode.QUERY())
-        self.r.set_rcode(Rcode.NOERROR())
-        self.r.set_header_flag(Message.HEADERFLAG_RD)
-        self.r.add_question(Question(Name("www.example.com"),
-                                     RRClass("IN"), RRType("A")))
-
-    def __common_tsig_checks(self, expected_file):
-        renderer = MessageRenderer()
-        self.r.to_wire(renderer, self.tsig_ctx)
-        actual_wire = strip_mutable_tsig_data(renderer.get_data())
-        expected_wire = strip_mutable_tsig_data(read_wire_data(expected_file))
-        self.assertEqual(expected_wire, actual_wire)
-
-    def test_to_wire_with_tsig(self):
-        self.r.set_qid(0x2d65)
-        self.__common_tsigquery_setup()
-        self.__common_tsig_checks("message_toWire2.wire")
-
-    def test_to_wire_with_edns_tsig(self):
-        self.r.set_qid(0x6cd)
-        self.__common_tsigquery_setup()
-        edns = EDNS()
-        edns.set_udp_size(4096)
-        self.r.set_edns(edns)
-        self.__common_tsig_checks("message_toWire3.wire")
-
     def test_to_text(self):
         message_render = create_message()
         
diff --git a/src/lib/dns/python/tests/tsig_python_test.py b/src/lib/dns/python/tests/tsig_python_test.py
deleted file mode 100644
index bffa0cf..0000000
--- a/src/lib/dns/python/tests/tsig_python_test.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2010  Internet Systems Consortium.
-#
-# Permission to use, copy, modify, and 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 INTERNET SYSTEMS CONSORTIUM
-# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
-# INTERNET SYSTEMS CONSORTIUM 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.
-
-import unittest
-from pydnspp import *
-
-class TSIGContextTest(unittest.TestCase):
-    tsig_key = TSIGKey('www.example.com:SFuWd/q99SzF8Yzd1QbB9g==')
-
-    def setUp(self):
-        # In the minimal implementation, we simply check constructing a
-        # TSIGContext doesn't cause any disruption.  We can add more tests
-        # later.
-        self.tsig_ctx = TSIGContext(self.tsig_key)
-
-if __name__ == '__main__':
-    unittest.main()
diff --git a/src/lib/dns/python/tsig_python.cc b/src/lib/dns/python/tsig_python.cc
deleted file mode 100644
index 2e6d986..0000000
--- a/src/lib/dns/python/tsig_python.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <dns/tsig.h>
-
-using namespace isc::dns;
-
-//
-// Definition of the classes
-//
-
-// For each class, we need a struct, a helper functions (init, destroy,
-// and static wrappers around the methods we export), a list of methods,
-// and a type description
-
-namespace {
-// The s_* Class simply covers one instantiation of the object
-
-class s_TSIGContext : public PyObject {
-public:
-    TSIGContext* tsig_ctx;
-};
-
-//
-// We declare the functions here, the definitions are below
-// the type definition of the object, since both can use the other
-//
-
-// General creation and destruction
-int TSIGContext_init(s_TSIGContext* self, PyObject* args);
-void TSIGContext_destroy(s_TSIGContext* self);
-
-// These are the functions we export
-// For a minimal support, we don't need them.
-
-// This list contains the actual set of functions we have in
-// python. Each entry has
-// 1. Python method name
-// 2. Our static function here
-// 3. Argument type
-// 4. Documentation
-PyMethodDef TSIGContext_methods[] = {
-    { NULL, NULL, 0, NULL }
-};
-
-// This defines the complete type for reflection in python and
-// parsing of PyObject* to s_EDNS
-// Most of the functions are not actually implemented and NULL here.
-PyTypeObject tsig_context_type = {
-    PyVarObject_HEAD_INIT(NULL, 0)
-    "libdns_python.TSIGContext",
-    sizeof(s_TSIGContext),              // tp_basicsize
-    0,                                  // tp_itemsize
-    (destructor)TSIGContext_destroy,    // 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
-    "The TSIGContext class maintains a context of a signed session of "
-    "DNS transactions by TSIG.",
-    NULL,                               // tp_traverse
-    NULL,                               // tp_clear
-    NULL,                               // tp_richcompare
-    0,                                  // tp_weaklistoffset
-    NULL,                               // tp_iter
-    NULL,                               // tp_iternext
-    TSIGContext_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)TSIGContext_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
-    NULL,                               // tp_del
-    0                                   // tp_version_tag
-};
-
-int
-TSIGContext_init(s_TSIGContext* self, PyObject* args) {
-    const s_TSIGKey* tsigkey_obj;
-
-    try {
-        if (PyArg_ParseTuple(args, "O!", &tsigkey_type, &tsigkey_obj)) {
-            self->tsig_ctx = new TSIGContext(*tsigkey_obj->tsigkey);
-            return (0);
-        }
-    } catch (...) {
-        PyErr_SetString(po_IscException, "Unexpected exception");
-        return (-1);
-    }
-
-    PyErr_Clear();
-    PyErr_SetString(PyExc_TypeError,
-                    "Invalid arguments to TSIGContext constructor");
-
-    return (-1);
-}
-
-void
-TSIGContext_destroy(s_TSIGContext* const self) {
-    delete self->tsig_ctx;
-    self->tsig_ctx = NULL;
-    Py_TYPE(self)->tp_free(self);
-}
-
-// Module Initialization, all statics are initialized here
-bool
-initModulePart_TSIGContext(PyObject* mod) {
-    // We initialize the static description object with PyType_Ready(),
-    // then add it to the module. This is not just a check! (leaving
-    // this out results in segmentation faults)
-    if (PyType_Ready(&tsig_context_type) < 0) {
-        return (false);
-    }
-    Py_INCREF(&tsig_context_type);
-    void* p = &tsig_context_type;
-    PyModule_AddObject(mod, "TSIGContext", static_cast<PyObject*>(p));
-
-    addClassVariable(tsig_context_type, "DEFAULT_FUDGE",
-                     Py_BuildValue("H", TSIGContext::DEFAULT_FUDGE));
-
-    return (true);
-}
-} // end of anonymous namespace




More information about the bind10-changes mailing list