LCOV - code coverage report
Current view: top level - dns/python - pydnspp.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 280 308 90.9 %
Date: 2012-05-15 Functions: 15 15 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 202 460 43.9 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : 
      16                 :            : // We want a lot of different parts of the DNS API in the python
      17                 :            : // module, but not one big 10000-line file.
      18                 :            : // So we split it up in several 'mini-modules'
      19                 :            : // These would be the same as a single module, except for
      20                 :            : // the init function, which has to be modified to a unique
      21                 :            : // name initModulePart_<name>, and return true/false instead of
      22                 :            : // NULL/*mod
      23                 :            : //
      24                 :            : // The big init function is split up into a separate initModulePart function
      25                 :            : // for each class we add.
      26                 :            : 
      27                 :            : #define PY_SSIZE_T_CLEAN
      28                 :            : #include <Python.h>
      29                 :            : #include <structmember.h>
      30                 :            : 
      31                 :            : #include <dns/message.h>
      32                 :            : #include <dns/opcode.h>
      33                 :            : #include <dns/tsig.h>
      34                 :            : #include <util/python/pycppwrapper_util.h>
      35                 :            : 
      36                 :            : #include "pydnspp_common.h"
      37                 :            : 
      38                 :            : #include "edns_python.h"
      39                 :            : #include "message_python.h"
      40                 :            : #include "messagerenderer_python.h"
      41                 :            : #include "name_python.h"
      42                 :            : #include "nsec3hash_python.h"
      43                 :            : #include "opcode_python.h"
      44                 :            : #include "pydnspp_common.h"
      45                 :            : #include "pydnspp_towire.h"
      46                 :            : #include "question_python.h"
      47                 :            : #include "rcode_python.h"
      48                 :            : #include "rdata_python.h"
      49                 :            : #include "rrclass_python.h"
      50                 :            : #include "rrset_python.h"
      51                 :            : #include "rrttl_python.h"
      52                 :            : #include "rrtype_python.h"
      53                 :            : #include "serial_python.h"
      54                 :            : #include "tsigerror_python.h"
      55                 :            : #include "tsigkey_python.h"
      56                 :            : #include "tsig_python.h"
      57                 :            : #include "tsig_rdata_python.h"
      58                 :            : #include "tsigrecord_python.h"
      59                 :            : 
      60                 :            : using namespace isc::dns;
      61                 :            : using namespace isc::dns::python;
      62                 :            : using namespace isc::util::python;
      63                 :            : 
      64                 :            : namespace {
      65                 :            : 
      66                 :            : bool
      67                 :            : initModulePart_EDNS(PyObject* mod) {
      68                 :            :     // We initialize the static description object with PyType_Ready(),
      69                 :            :     // then add it to the module. This is not just a check! (leaving
      70                 :            :     // this out results in segmentation faults)
      71                 :            :     //
      72                 :            :     // After the type has been initialized, we initialize any exceptions
      73                 :            :     // that are defined in the wrapper for this class, and add constants
      74                 :            :     // to the type, if any
      75                 :            : 
      76         [ +  - ]:         29 :     if (PyType_Ready(&edns_type) < 0) {
      77                 :            :         return (false);
      78                 :            :     }
      79                 :         29 :     Py_INCREF(&edns_type);
      80                 :         29 :     void* p = &edns_type;
      81                 :         29 :     PyModule_AddObject(mod, "EDNS", static_cast<PyObject*>(p));
      82                 :            : 
      83                 :            :     addClassVariable(edns_type, "SUPPORTED_VERSION",
      84                 :         29 :                      Py_BuildValue("B", EDNS::SUPPORTED_VERSION));
      85                 :            : 
      86                 :            :     return (true);
      87                 :            : }
      88                 :            : 
      89                 :            : bool
      90                 :         29 : initModulePart_Message(PyObject* mod) {
      91         [ +  - ]:         29 :     if (PyType_Ready(&message_type) < 0) {
      92                 :            :         return (false);
      93                 :            :     }
      94                 :         29 :     void* p = &message_type;
      95         [ +  - ]:         29 :     if (PyModule_AddObject(mod, "Message", static_cast<PyObject*>(p)) < 0) {
      96                 :            :         return (false);
      97                 :            :     }
      98                 :         29 :     Py_INCREF(&message_type);
      99                 :            : 
     100                 :            :     try {
     101                 :            :         //
     102                 :            :         // Constant class variables
     103                 :            :         //
     104                 :            : 
     105                 :            :         // Parse mode
     106                 :            :         installClassVariable(message_type, "PARSE",
     107 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::PARSE));
     108                 :            :         installClassVariable(message_type, "RENDER",
     109 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::RENDER));
     110                 :            : 
     111                 :            :         // Parse options
     112                 :            :         installClassVariable(message_type, "PARSE_DEFAULT",
     113 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::PARSE_DEFAULT));
     114                 :            :         installClassVariable(message_type, "PRESERVE_ORDER",
     115 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::PRESERVE_ORDER));
     116                 :            : 
     117                 :            :         // Header flags
     118                 :            :         installClassVariable(message_type, "HEADERFLAG_QR",
     119 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_QR));
     120                 :            :         installClassVariable(message_type, "HEADERFLAG_AA",
     121 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_AA));
     122                 :            :         installClassVariable(message_type, "HEADERFLAG_TC",
     123 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_TC));
     124                 :            :         installClassVariable(message_type, "HEADERFLAG_RD",
     125 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_RD));
     126                 :            :         installClassVariable(message_type, "HEADERFLAG_RA",
     127 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_RA));
     128                 :            :         installClassVariable(message_type, "HEADERFLAG_AD",
     129 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_AD));
     130                 :            :         installClassVariable(message_type, "HEADERFLAG_CD",
     131 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::HEADERFLAG_CD));
     132                 :            : 
     133                 :            :         // Sections
     134                 :            :         installClassVariable(message_type, "SECTION_QUESTION",
     135 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::SECTION_QUESTION));
     136                 :            :         installClassVariable(message_type, "SECTION_ANSWER",
     137 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::SECTION_ANSWER));
     138                 :            :         installClassVariable(message_type, "SECTION_AUTHORITY",
     139 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::SECTION_AUTHORITY));
     140                 :            :         installClassVariable(message_type, "SECTION_ADDITIONAL",
     141 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::SECTION_ADDITIONAL));
     142                 :            : 
     143                 :            :         // Protocol constant
     144                 :            :         installClassVariable(message_type, "DEFAULT_MAX_UDPSIZE",
     145 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", Message::DEFAULT_MAX_UDPSIZE));
     146                 :            : 
     147                 :            :         /* Class-specific exceptions */
     148                 :            :         po_MessageTooShort =
     149         [ +  - ]:         29 :             PyErr_NewException("pydnspp.MessageTooShort", NULL, NULL);
     150         [ +  - ]:         29 :         PyObjectContainer(po_MessageTooShort).installToModule(
     151 [ +  - ][ +  - ]:         29 :             mod, "MessageTooShort");
     152                 :            :         po_InvalidMessageSection =
     153         [ +  - ]:         29 :             PyErr_NewException("pydnspp.InvalidMessageSection", NULL, NULL);
     154         [ +  - ]:         29 :         PyObjectContainer(po_InvalidMessageSection).installToModule(
     155 [ +  - ][ +  - ]:         29 :             mod, "InvalidMessageSection");
     156                 :            :         po_InvalidMessageOperation =
     157         [ +  - ]:         29 :             PyErr_NewException("pydnspp.InvalidMessageOperation", NULL, NULL);
     158         [ +  - ]:         29 :         PyObjectContainer(po_InvalidMessageOperation).installToModule(
     159 [ +  - ][ +  - ]:         29 :             mod, "InvalidMessageOperation");
     160                 :            :         po_InvalidMessageUDPSize =
     161         [ +  - ]:         29 :             PyErr_NewException("pydnspp.InvalidMessageUDPSize", NULL, NULL);
     162         [ +  - ]:         29 :         PyObjectContainer(po_InvalidMessageUDPSize).installToModule(
     163 [ +  - ][ +  - ]:         29 :             mod, "InvalidMessageUDPSize");
     164                 :            :         po_DNSMessageBADVERS =
     165         [ +  - ]:         29 :             PyErr_NewException("pydnspp.DNSMessageBADVERS", NULL, NULL);
     166         [ +  - ]:         29 :         PyObjectContainer(po_DNSMessageBADVERS).installToModule(
     167 [ +  - ][ +  - ]:         29 :             mod, "DNSMessageBADVERS");
     168                 :            :         po_UnknownNSEC3HashAlgorithm =
     169         [ +  - ]:         29 :             PyErr_NewException("pydnspp.UnknownNSEC3HashAlgorithm", NULL, NULL);
     170         [ +  - ]:         29 :         PyObjectContainer(po_UnknownNSEC3HashAlgorithm).installToModule(
     171 [ +  - ][ +  - ]:         29 :             mod, "UnknownNSEC3HashAlgorithm");
     172                 :          0 :     } catch (const std::exception& ex) {
     173                 :            :         const std::string ex_what =
     174                 :            :             "Unexpected failure in Message initialization: " +
     175 [ #  # ][ #  # ]:          0 :             std::string(ex.what());
     176         [ #  # ]:          0 :         PyErr_SetString(po_IscException, ex_what.c_str());
     177                 :            :         return (false);
     178         [ #  # ]:          0 :     } catch (...) {
     179                 :            :         PyErr_SetString(PyExc_SystemError,
     180         [ #  # ]:          0 :                         "Unexpected failure in Message initialization");
     181                 :            :         return (false);
     182                 :            :     }
     183                 :            : 
     184                 :            :     return (true);
     185                 :            : }
     186                 :            : 
     187                 :            : bool
     188                 :            : initModulePart_MessageRenderer(PyObject* mod) {
     189         [ +  - ]:         29 :     if (PyType_Ready(&messagerenderer_type) < 0) {
     190                 :            :         return (false);
     191                 :            :     }
     192                 :         29 :     Py_INCREF(&messagerenderer_type);
     193                 :            : 
     194                 :            :     addClassVariable(messagerenderer_type, "CASE_INSENSITIVE",
     195                 :         29 :                      Py_BuildValue("I", MessageRenderer::CASE_INSENSITIVE));
     196                 :            :     addClassVariable(messagerenderer_type, "CASE_SENSITIVE",
     197                 :         29 :                      Py_BuildValue("I", MessageRenderer::CASE_SENSITIVE));
     198                 :            : 
     199                 :            :     PyModule_AddObject(mod, "MessageRenderer",
     200                 :         29 :                        reinterpret_cast<PyObject*>(&messagerenderer_type));
     201                 :            : 
     202                 :            :     return (true);
     203                 :            : }
     204                 :            : 
     205                 :            : bool
     206                 :         29 : initModulePart_Name(PyObject* mod) {
     207                 :            : 
     208                 :            :     //
     209                 :            :     // NameComparisonResult
     210                 :            :     //
     211         [ +  - ]:         29 :     if (PyType_Ready(&name_comparison_result_type) < 0) {
     212                 :            :         return (false);
     213                 :            :     }
     214                 :         29 :     Py_INCREF(&name_comparison_result_type);
     215                 :            : 
     216                 :            :     // Add the enums to the module
     217                 :            :     po_NameRelation = Py_BuildValue("{i:s,i:s,i:s,i:s}",
     218                 :            :         NameComparisonResult::SUPERDOMAIN, "SUPERDOMAIN",
     219                 :            :         NameComparisonResult::SUBDOMAIN, "SUBDOMAIN",
     220                 :            :         NameComparisonResult::EQUAL, "EQUAL",
     221                 :         29 :         NameComparisonResult::COMMONANCESTOR, "COMMONANCESTOR");
     222                 :            :     addClassVariable(name_comparison_result_type, "NameRelation",
     223                 :         29 :                      po_NameRelation);
     224                 :            : 
     225                 :            :     PyModule_AddObject(mod, "NameComparisonResult",
     226                 :         29 :         reinterpret_cast<PyObject*>(&name_comparison_result_type));
     227                 :            : 
     228                 :            :     //
     229                 :            :     // Name
     230                 :            :     //
     231                 :            : 
     232         [ +  - ]:         29 :     if (PyType_Ready(&name_type) < 0) {
     233                 :            :         return (false);
     234                 :            :     }
     235                 :         29 :     Py_INCREF(&name_type);
     236                 :            : 
     237                 :            :     // Add the constants to the module
     238                 :            :     addClassVariable(name_type, "MAX_WIRE",
     239                 :         29 :                      Py_BuildValue("I", Name::MAX_WIRE));
     240                 :            :     addClassVariable(name_type, "MAX_LABELS",
     241                 :         29 :                      Py_BuildValue("I", Name::MAX_LABELS));
     242                 :            :     addClassVariable(name_type, "MAX_LABELLEN",
     243                 :         29 :                      Py_BuildValue("I", Name::MAX_LABELLEN));
     244                 :            :     addClassVariable(name_type, "MAX_COMPRESS_POINTER",
     245                 :         29 :                      Py_BuildValue("I", Name::MAX_COMPRESS_POINTER));
     246                 :            :     addClassVariable(name_type, "COMPRESS_POINTER_MARK8",
     247                 :         29 :                      Py_BuildValue("I", Name::COMPRESS_POINTER_MARK8));
     248                 :            :     addClassVariable(name_type, "COMPRESS_POINTER_MARK16",
     249                 :         29 :                      Py_BuildValue("I", Name::COMPRESS_POINTER_MARK16));
     250                 :            : 
     251                 :            :     addClassVariable(name_type, "ROOT_NAME",
     252                 :         29 :                      createNameObject(Name::ROOT_NAME()));
     253                 :            : 
     254                 :            :     PyModule_AddObject(mod, "Name",
     255                 :         29 :                        reinterpret_cast<PyObject*>(&name_type));
     256                 :            : 
     257                 :            : 
     258                 :            :     // Add the exceptions to the module
     259                 :         29 :     po_EmptyLabel = PyErr_NewException("pydnspp.EmptyLabel", NULL, NULL);
     260                 :         29 :     PyModule_AddObject(mod, "EmptyLabel", po_EmptyLabel);
     261                 :            : 
     262                 :         29 :     po_TooLongName = PyErr_NewException("pydnspp.TooLongName", NULL, NULL);
     263                 :         29 :     PyModule_AddObject(mod, "TooLongName", po_TooLongName);
     264                 :            : 
     265                 :         29 :     po_TooLongLabel = PyErr_NewException("pydnspp.TooLongLabel", NULL, NULL);
     266                 :         29 :     PyModule_AddObject(mod, "TooLongLabel", po_TooLongLabel);
     267                 :            : 
     268                 :         29 :     po_BadLabelType = PyErr_NewException("pydnspp.BadLabelType", NULL, NULL);
     269                 :         29 :     PyModule_AddObject(mod, "BadLabelType", po_BadLabelType);
     270                 :            : 
     271                 :         29 :     po_BadEscape = PyErr_NewException("pydnspp.BadEscape", NULL, NULL);
     272                 :         29 :     PyModule_AddObject(mod, "BadEscape", po_BadEscape);
     273                 :            : 
     274                 :         29 :     po_IncompleteName = PyErr_NewException("pydnspp.IncompleteName", NULL, NULL);
     275                 :         29 :     PyModule_AddObject(mod, "IncompleteName", po_IncompleteName);
     276                 :            : 
     277                 :            :     po_InvalidBufferPosition =
     278                 :         29 :         PyErr_NewException("pydnspp.InvalidBufferPosition", NULL, NULL);
     279                 :         29 :     PyModule_AddObject(mod, "InvalidBufferPosition", po_InvalidBufferPosition);
     280                 :            : 
     281                 :            :     // This one could have gone into the message_python.cc file, but is
     282                 :            :     // already needed here.
     283                 :            :     po_DNSMessageFORMERR = PyErr_NewException("pydnspp.DNSMessageFORMERR",
     284                 :         29 :                                               NULL, NULL);
     285                 :         29 :     PyModule_AddObject(mod, "DNSMessageFORMERR", po_DNSMessageFORMERR);
     286                 :            : 
     287                 :         29 :     return (true);
     288                 :            : }
     289                 :            : 
     290                 :            : bool
     291                 :         29 : initModulePart_Opcode(PyObject* mod) {
     292         [ +  - ]:         29 :     if (PyType_Ready(&opcode_type) < 0) {
     293                 :            :         return (false);
     294                 :            :     }
     295                 :         29 :     Py_INCREF(&opcode_type);
     296                 :         29 :     void* p = &opcode_type;
     297         [ -  + ]:         29 :     if (PyModule_AddObject(mod, "Opcode", static_cast<PyObject*>(p)) != 0) {
     298         [ #  # ]:          0 :         Py_DECREF(&opcode_type);
     299                 :            :         return (false);
     300                 :            :     }
     301                 :            : 
     302                 :            :     addClassVariable(opcode_type, "QUERY_CODE",
     303                 :         29 :                      Py_BuildValue("h", Opcode::QUERY_CODE));
     304                 :            :     addClassVariable(opcode_type, "IQUERY_CODE",
     305                 :         29 :                      Py_BuildValue("h", Opcode::IQUERY_CODE));
     306                 :            :     addClassVariable(opcode_type, "STATUS_CODE",
     307                 :         29 :                      Py_BuildValue("h", Opcode::STATUS_CODE));
     308                 :            :     addClassVariable(opcode_type, "RESERVED3_CODE",
     309                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED3_CODE));
     310                 :            :     addClassVariable(opcode_type, "NOTIFY_CODE",
     311                 :         29 :                      Py_BuildValue("h", Opcode::NOTIFY_CODE));
     312                 :            :     addClassVariable(opcode_type, "UPDATE_CODE",
     313                 :         29 :                      Py_BuildValue("h", Opcode::UPDATE_CODE));
     314                 :            :     addClassVariable(opcode_type, "RESERVED6_CODE",
     315                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED6_CODE));
     316                 :            :     addClassVariable(opcode_type, "RESERVED7_CODE",
     317                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED7_CODE));
     318                 :            :     addClassVariable(opcode_type, "RESERVED8_CODE",
     319                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED8_CODE));
     320                 :            :     addClassVariable(opcode_type, "RESERVED9_CODE",
     321                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED9_CODE));
     322                 :            :     addClassVariable(opcode_type, "RESERVED10_CODE",
     323                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED10_CODE));
     324                 :            :     addClassVariable(opcode_type, "RESERVED11_CODE",
     325                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED11_CODE));
     326                 :            :     addClassVariable(opcode_type, "RESERVED12_CODE",
     327                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED12_CODE));
     328                 :            :     addClassVariable(opcode_type, "RESERVED13_CODE",
     329                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED13_CODE));
     330                 :            :     addClassVariable(opcode_type, "RESERVED14_CODE",
     331                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED14_CODE));
     332                 :            :     addClassVariable(opcode_type, "RESERVED15_CODE",
     333                 :         29 :                      Py_BuildValue("h", Opcode::RESERVED15_CODE));
     334                 :            : 
     335                 :         29 :     return (true);
     336                 :            : }
     337                 :            : 
     338                 :            : bool
     339                 :            : initModulePart_Question(PyObject* mod) {
     340         [ +  - ]:         29 :     if (PyType_Ready(&question_type) < 0) {
     341                 :            :         return (false);
     342                 :            :     }
     343                 :         29 :     Py_INCREF(&question_type);
     344                 :            :     PyModule_AddObject(mod, "Question",
     345                 :         29 :                        reinterpret_cast<PyObject*>(&question_type));
     346                 :            : 
     347                 :            :     return (true);
     348                 :            : }
     349                 :            : 
     350                 :            : bool
     351                 :         29 : initModulePart_Rcode(PyObject* mod) {
     352         [ +  - ]:         29 :     if (PyType_Ready(&rcode_type) < 0) {
     353                 :            :         return (false);
     354                 :            :     }
     355                 :         29 :     Py_INCREF(&rcode_type);
     356                 :         29 :     void* p = &rcode_type;
     357         [ -  + ]:         29 :     if (PyModule_AddObject(mod, "Rcode", static_cast<PyObject*>(p)) != 0) {
     358         [ #  # ]:          0 :         Py_DECREF(&rcode_type);
     359                 :            :         return (false);
     360                 :            :     }
     361                 :            : 
     362                 :            :     addClassVariable(rcode_type, "NOERROR_CODE",
     363                 :         29 :                      Py_BuildValue("h", Rcode::NOERROR_CODE));
     364                 :            :     addClassVariable(rcode_type, "FORMERR_CODE",
     365                 :         29 :                      Py_BuildValue("h", Rcode::FORMERR_CODE));
     366                 :            :     addClassVariable(rcode_type, "SERVFAIL_CODE",
     367                 :         29 :                      Py_BuildValue("h", Rcode::SERVFAIL_CODE));
     368                 :            :     addClassVariable(rcode_type, "NXDOMAIN_CODE",
     369                 :         29 :                      Py_BuildValue("h", Rcode::NXDOMAIN_CODE));
     370                 :            :     addClassVariable(rcode_type, "NOTIMP_CODE",
     371                 :         29 :                      Py_BuildValue("h", Rcode::NOTIMP_CODE));
     372                 :            :     addClassVariable(rcode_type, "REFUSED_CODE",
     373                 :         29 :                      Py_BuildValue("h", Rcode::REFUSED_CODE));
     374                 :            :     addClassVariable(rcode_type, "YXDOMAIN_CODE",
     375                 :         29 :                      Py_BuildValue("h", Rcode::YXDOMAIN_CODE));
     376                 :            :     addClassVariable(rcode_type, "YXRRSET_CODE",
     377                 :         29 :                      Py_BuildValue("h", Rcode::YXRRSET_CODE));
     378                 :            :     addClassVariable(rcode_type, "NXRRSET_CODE",
     379                 :         29 :                      Py_BuildValue("h", Rcode::NXRRSET_CODE));
     380                 :            :     addClassVariable(rcode_type, "NOTAUTH_CODE",
     381                 :         29 :                      Py_BuildValue("h", Rcode::NOTAUTH_CODE));
     382                 :            :     addClassVariable(rcode_type, "NOTZONE_CODE",
     383                 :         29 :                      Py_BuildValue("h", Rcode::NOTZONE_CODE));
     384                 :            :     addClassVariable(rcode_type, "RESERVED11_CODE",
     385                 :         29 :                      Py_BuildValue("h", Rcode::RESERVED11_CODE));
     386                 :            :     addClassVariable(rcode_type, "RESERVED12_CODE",
     387                 :         29 :                      Py_BuildValue("h", Rcode::RESERVED12_CODE));
     388                 :            :     addClassVariable(rcode_type, "RESERVED13_CODE",
     389                 :         29 :                      Py_BuildValue("h", Rcode::RESERVED13_CODE));
     390                 :            :     addClassVariable(rcode_type, "RESERVED14_CODE",
     391                 :         29 :                      Py_BuildValue("h", Rcode::RESERVED14_CODE));
     392                 :            :     addClassVariable(rcode_type, "RESERVED15_CODE",
     393                 :         29 :                      Py_BuildValue("h", Rcode::RESERVED15_CODE));
     394                 :            :     addClassVariable(rcode_type, "BADVERS_CODE",
     395                 :         29 :                      Py_BuildValue("h", Rcode::BADVERS_CODE));
     396                 :            : 
     397                 :         29 :     return (true);
     398                 :            : }
     399                 :            : 
     400                 :            : bool
     401                 :         29 : initModulePart_Rdata(PyObject* mod) {
     402         [ +  - ]:         29 :     if (PyType_Ready(&rdata_type) < 0) {
     403                 :            :         return (false);
     404                 :            :     }
     405                 :         29 :     Py_INCREF(&rdata_type);
     406                 :            :     PyModule_AddObject(mod, "Rdata",
     407                 :         29 :                        reinterpret_cast<PyObject*>(&rdata_type));
     408                 :            : 
     409                 :            :     // Add the exceptions to the class
     410                 :            :     po_InvalidRdataLength = PyErr_NewException("pydnspp.InvalidRdataLength",
     411                 :         29 :                                                NULL, NULL);
     412                 :         29 :     PyModule_AddObject(mod, "InvalidRdataLength", po_InvalidRdataLength);
     413                 :            : 
     414                 :            :     po_InvalidRdataText = PyErr_NewException("pydnspp.InvalidRdataText",
     415                 :         29 :                                              NULL, NULL);
     416                 :         29 :     PyModule_AddObject(mod, "InvalidRdataText", po_InvalidRdataText);
     417                 :            : 
     418                 :            :     po_CharStringTooLong = PyErr_NewException("pydnspp.CharStringTooLong",
     419                 :         29 :                                               NULL, NULL);
     420                 :         29 :     PyModule_AddObject(mod, "CharStringTooLong", po_CharStringTooLong);
     421                 :            : 
     422                 :            : 
     423                 :         29 :     return (true);
     424                 :            : }
     425                 :            : 
     426                 :            : bool
     427                 :         29 : initModulePart_RRClass(PyObject* mod) {
     428                 :            :     po_InvalidRRClass = PyErr_NewException("pydnspp.InvalidRRClass",
     429                 :         29 :                                            NULL, NULL);
     430                 :         29 :     Py_INCREF(po_InvalidRRClass);
     431                 :         29 :     PyModule_AddObject(mod, "InvalidRRClass", po_InvalidRRClass);
     432                 :            :     po_IncompleteRRClass = PyErr_NewException("pydnspp.IncompleteRRClass",
     433                 :         29 :                                               NULL, NULL);
     434                 :         29 :     Py_INCREF(po_IncompleteRRClass);
     435                 :         29 :     PyModule_AddObject(mod, "IncompleteRRClass", po_IncompleteRRClass);
     436                 :            : 
     437         [ +  - ]:         29 :     if (PyType_Ready(&rrclass_type) < 0) {
     438                 :            :         return (false);
     439                 :            :     }
     440                 :         29 :     Py_INCREF(&rrclass_type);
     441                 :            :     PyModule_AddObject(mod, "RRClass",
     442                 :         29 :                        reinterpret_cast<PyObject*>(&rrclass_type));
     443                 :            : 
     444                 :         29 :     return (true);
     445                 :            : }
     446                 :            : 
     447                 :            : bool
     448                 :            : initModulePart_RRset(PyObject* mod) {
     449                 :         29 :     po_EmptyRRset = PyErr_NewException("pydnspp.EmptyRRset", NULL, NULL);
     450                 :         29 :     PyModule_AddObject(mod, "EmptyRRset", po_EmptyRRset);
     451                 :            : 
     452                 :            :     // NameComparisonResult
     453         [ +  - ]:         29 :     if (PyType_Ready(&rrset_type) < 0) {
     454                 :            :         return (false);
     455                 :            :     }
     456                 :         29 :     Py_INCREF(&rrset_type);
     457                 :            :     PyModule_AddObject(mod, "RRset",
     458                 :         29 :                        reinterpret_cast<PyObject*>(&rrset_type));
     459                 :            : 
     460                 :            :     return (true);
     461                 :            : }
     462                 :            : 
     463                 :            : bool
     464                 :         29 : initModulePart_RRTTL(PyObject* mod) {
     465                 :         29 :     po_InvalidRRTTL = PyErr_NewException("pydnspp.InvalidRRTTL", NULL, NULL);
     466                 :         29 :     PyModule_AddObject(mod, "InvalidRRTTL", po_InvalidRRTTL);
     467                 :            :     po_IncompleteRRTTL = PyErr_NewException("pydnspp.IncompleteRRTTL",
     468                 :         29 :                                             NULL, NULL);
     469                 :         29 :     PyModule_AddObject(mod, "IncompleteRRTTL", po_IncompleteRRTTL);
     470                 :            : 
     471         [ +  - ]:         29 :     if (PyType_Ready(&rrttl_type) < 0) {
     472                 :            :         return (false);
     473                 :            :     }
     474                 :         29 :     Py_INCREF(&rrttl_type);
     475                 :            :     PyModule_AddObject(mod, "RRTTL",
     476                 :         29 :                        reinterpret_cast<PyObject*>(&rrttl_type));
     477                 :            : 
     478                 :         29 :     return (true);
     479                 :            : }
     480                 :            : 
     481                 :            : bool
     482                 :         29 : initModulePart_RRType(PyObject* mod) {
     483                 :            :     // Add the exceptions to the module
     484                 :         29 :     po_InvalidRRType = PyErr_NewException("pydnspp.InvalidRRType", NULL, NULL);
     485                 :         29 :     PyModule_AddObject(mod, "InvalidRRType", po_InvalidRRType);
     486                 :            :     po_IncompleteRRType = PyErr_NewException("pydnspp.IncompleteRRType",
     487                 :         29 :                                              NULL, NULL);
     488                 :         29 :     PyModule_AddObject(mod, "IncompleteRRType", po_IncompleteRRType);
     489                 :            : 
     490         [ +  - ]:         29 :     if (PyType_Ready(&rrtype_type) < 0) {
     491                 :            :         return (false);
     492                 :            :     }
     493                 :         29 :     Py_INCREF(&rrtype_type);
     494                 :            :     PyModule_AddObject(mod, "RRType",
     495                 :         29 :                        reinterpret_cast<PyObject*>(&rrtype_type));
     496                 :            : 
     497                 :         29 :     return (true);
     498                 :            : }
     499                 :            : 
     500                 :            : bool
     501                 :            : initModulePart_Serial(PyObject* mod) {
     502         [ +  - ]:         29 :     if (PyType_Ready(&serial_type) < 0) {
     503                 :            :         return (false);
     504                 :            :     }
     505                 :         29 :     Py_INCREF(&serial_type);
     506                 :            :     PyModule_AddObject(mod, "Serial",
     507                 :         29 :                        reinterpret_cast<PyObject*>(&serial_type));
     508                 :            : 
     509                 :            :     return (true);
     510                 :            : }
     511                 :            : 
     512                 :            : bool
     513                 :         29 : initModulePart_TSIGError(PyObject* mod) {
     514         [ +  - ]:         29 :     if (PyType_Ready(&tsigerror_type) < 0) {
     515                 :            :         return (false);
     516                 :            :     }
     517                 :         29 :     void* p = &tsigerror_type;
     518         [ +  - ]:         29 :     if (PyModule_AddObject(mod, "TSIGError", static_cast<PyObject*>(p)) < 0) {
     519                 :            :         return (false);
     520                 :            :     }
     521                 :         29 :     Py_INCREF(&tsigerror_type);
     522                 :            : 
     523                 :            :     try {
     524                 :            :         // Constant class variables
     525                 :            :         // Error codes (bare values)
     526                 :            :         installClassVariable(tsigerror_type, "BAD_SIG_CODE",
     527 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("H", TSIGError::BAD_SIG_CODE));
     528                 :            :         installClassVariable(tsigerror_type, "BAD_KEY_CODE",
     529 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("H", TSIGError::BAD_KEY_CODE));
     530                 :            :         installClassVariable(tsigerror_type, "BAD_TIME_CODE",
     531 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("H", TSIGError::BAD_TIME_CODE));
     532                 :            : 
     533                 :            :         // Error codes (constant objects)
     534                 :            :         installClassVariable(tsigerror_type, "NOERROR",
     535 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::NOERROR()));
                 [ +  - ]
     536                 :            :         installClassVariable(tsigerror_type, "FORMERR",
     537 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::FORMERR()));
                 [ +  - ]
     538                 :            :         installClassVariable(tsigerror_type, "SERVFAIL",
     539 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::SERVFAIL()));
                 [ +  - ]
     540                 :            :         installClassVariable(tsigerror_type, "NXDOMAIN",
     541 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::NXDOMAIN()));
                 [ +  - ]
     542                 :            :         installClassVariable(tsigerror_type, "NOTIMP",
     543 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::NOTIMP()));
                 [ +  - ]
     544                 :            :         installClassVariable(tsigerror_type, "REFUSED",
     545 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::REFUSED()));
                 [ +  - ]
     546                 :            :         installClassVariable(tsigerror_type, "YXDOMAIN",
     547 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::YXDOMAIN()));
                 [ +  - ]
     548                 :            :         installClassVariable(tsigerror_type, "YXRRSET",
     549 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::YXRRSET()));
                 [ +  - ]
     550                 :            :         installClassVariable(tsigerror_type, "NXRRSET",
     551 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::NXRRSET()));
                 [ +  - ]
     552                 :            :         installClassVariable(tsigerror_type, "NOTAUTH",
     553 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::NOTAUTH()));
                 [ +  - ]
     554                 :            :         installClassVariable(tsigerror_type, "NOTZONE",
     555 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::NOTZONE()));
                 [ +  - ]
     556                 :            :         installClassVariable(tsigerror_type, "RESERVED11",
     557 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::RESERVED11()));
                 [ +  - ]
     558                 :            :         installClassVariable(tsigerror_type, "RESERVED12",
     559 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::RESERVED12()));
                 [ +  - ]
     560                 :            :         installClassVariable(tsigerror_type, "RESERVED13",
     561 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::RESERVED13()));
                 [ +  - ]
     562                 :            :         installClassVariable(tsigerror_type, "RESERVED14",
     563 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::RESERVED14()));
                 [ +  - ]
     564                 :            :         installClassVariable(tsigerror_type, "RESERVED15",
     565 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::RESERVED15()));
                 [ +  - ]
     566                 :            :         installClassVariable(tsigerror_type, "BAD_SIG",
     567 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::BAD_SIG()));
     568                 :            :         installClassVariable(tsigerror_type, "BAD_KEY",
     569 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::BAD_KEY()));
     570                 :            :         installClassVariable(tsigerror_type, "BAD_TIME",
     571 [ +  - ][ +  - ]:         29 :                              createTSIGErrorObject(TSIGError::BAD_TIME()));
     572                 :          0 :     } catch (const std::exception& ex) {
     573                 :            :         const std::string ex_what =
     574                 :            :             "Unexpected failure in TSIGError initialization: " +
     575 [ #  # ][ #  # ]:          0 :             std::string(ex.what());
     576         [ #  # ]:          0 :         PyErr_SetString(po_IscException, ex_what.c_str());
     577                 :            :         return (false);
     578         [ #  # ]:          0 :     } catch (...) {
     579                 :            :         PyErr_SetString(PyExc_SystemError,
     580         [ #  # ]:          0 :                         "Unexpected failure in TSIGError initialization");
     581                 :            :         return (false);
     582                 :            :     }
     583                 :            : 
     584                 :            :     return (true);
     585                 :            : }
     586                 :            : 
     587                 :            : bool
     588                 :         29 : initModulePart_TSIGKey(PyObject* mod) {
     589         [ +  - ]:         29 :     if (PyType_Ready(&tsigkey_type) < 0) {
     590                 :            :         return (false);
     591                 :            :     }
     592                 :         29 :     void* p = &tsigkey_type;
     593         [ +  - ]:         29 :     if (PyModule_AddObject(mod, "TSIGKey", static_cast<PyObject*>(p)) != 0) {
     594                 :            :         return (false);
     595                 :            :     }
     596                 :         29 :     Py_INCREF(&tsigkey_type);
     597                 :            : 
     598                 :            :     try {
     599                 :            :         // Constant class variables
     600                 :            :         installClassVariable(tsigkey_type, "HMACMD5_NAME",
     601 [ +  - ][ +  - ]:         29 :                              createNameObject(TSIGKey::HMACMD5_NAME()));
                 [ +  - ]
     602                 :            :         installClassVariable(tsigkey_type, "HMACSHA1_NAME",
     603 [ +  - ][ +  - ]:         29 :                              createNameObject(TSIGKey::HMACSHA1_NAME()));
                 [ +  - ]
     604                 :            :         installClassVariable(tsigkey_type, "HMACSHA256_NAME",
     605 [ +  - ][ +  - ]:         29 :                              createNameObject(TSIGKey::HMACSHA256_NAME()));
                 [ +  - ]
     606                 :            :         installClassVariable(tsigkey_type, "HMACSHA224_NAME",
     607 [ +  - ][ +  - ]:         29 :                              createNameObject(TSIGKey::HMACSHA224_NAME()));
                 [ +  - ]
     608                 :            :         installClassVariable(tsigkey_type, "HMACSHA384_NAME",
     609 [ +  - ][ +  - ]:         29 :                              createNameObject(TSIGKey::HMACSHA384_NAME()));
                 [ +  - ]
     610                 :            :         installClassVariable(tsigkey_type, "HMACSHA512_NAME",
     611 [ +  - ][ +  - ]:         29 :                              createNameObject(TSIGKey::HMACSHA512_NAME()));
                 [ +  - ]
     612                 :          0 :     } catch (const std::exception& ex) {
     613                 :            :         const std::string ex_what =
     614                 :            :             "Unexpected failure in TSIGKey initialization: " +
     615 [ #  # ][ #  # ]:          0 :             std::string(ex.what());
     616         [ #  # ]:          0 :         PyErr_SetString(po_IscException, ex_what.c_str());
     617                 :            :         return (false);
     618         [ #  # ]:          0 :     } catch (...) {
     619                 :            :         PyErr_SetString(PyExc_SystemError,
     620         [ #  # ]:          0 :                         "Unexpected failure in TSIGKey initialization");
     621                 :            :         return (false);
     622                 :            :     }
     623                 :            : 
     624                 :            :     return (true);
     625                 :            : }
     626                 :            : 
     627                 :            : bool
     628                 :         29 : initModulePart_TSIGKeyRing(PyObject* mod) {
     629         [ +  - ]:         29 :     if (PyType_Ready(&tsigkeyring_type) < 0) {
     630                 :            :         return (false);
     631                 :            :     }
     632                 :         29 :     Py_INCREF(&tsigkeyring_type);
     633                 :         29 :     void* p = &tsigkeyring_type;
     634         [ -  + ]:         29 :     if (PyModule_AddObject(mod, "TSIGKeyRing",
     635                 :         29 :                            static_cast<PyObject*>(p)) != 0) {
     636         [ #  # ]:          0 :         Py_DECREF(&tsigkeyring_type);
     637                 :            :         return (false);
     638                 :            :     }
     639                 :            : 
     640                 :            :     addClassVariable(tsigkeyring_type, "SUCCESS",
     641                 :         29 :                      Py_BuildValue("I", TSIGKeyRing::SUCCESS));
     642                 :            :     addClassVariable(tsigkeyring_type, "EXIST",
     643                 :         29 :                      Py_BuildValue("I", TSIGKeyRing::EXIST));
     644                 :            :     addClassVariable(tsigkeyring_type, "NOTFOUND",
     645                 :         29 :                      Py_BuildValue("I", TSIGKeyRing::NOTFOUND));
     646                 :            : 
     647                 :         29 :     return (true);
     648                 :            : }
     649                 :            : 
     650                 :            : bool
     651                 :         29 : initModulePart_TSIGContext(PyObject* mod) {
     652         [ +  - ]:         29 :     if (PyType_Ready(&tsigcontext_type) < 0) {
     653                 :            :         return (false);
     654                 :            :     }
     655                 :         29 :     void* p = &tsigcontext_type;
     656         [ +  - ]:         29 :     if (PyModule_AddObject(mod, "TSIGContext",
     657                 :         29 :                            static_cast<PyObject*>(p)) < 0) {
     658                 :            :         return (false);
     659                 :            :     }
     660                 :         29 :     Py_INCREF(&tsigcontext_type);
     661                 :            : 
     662                 :            :     try {
     663                 :            :         // Class specific exceptions
     664                 :            :         po_TSIGContextError = PyErr_NewException("pydnspp.TSIGContextError",
     665         [ +  - ]:         29 :                                                  po_IscException, NULL);
     666         [ +  - ]:         29 :         PyObjectContainer(po_TSIGContextError).installToModule(
     667 [ +  - ][ +  - ]:         29 :             mod, "TSIGContextError");
     668                 :            : 
     669                 :            :         // Constant class variables
     670                 :            :         installClassVariable(tsigcontext_type, "STATE_INIT",
     671 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", TSIGContext::INIT));
     672                 :            :         installClassVariable(tsigcontext_type, "STATE_SENT_REQUEST",
     673 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", TSIGContext::SENT_REQUEST));
     674                 :            :         installClassVariable(tsigcontext_type, "STATE_RECEIVED_REQUEST",
     675 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", TSIGContext::RECEIVED_REQUEST));
     676                 :            :         installClassVariable(tsigcontext_type, "STATE_SENT_RESPONSE",
     677 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", TSIGContext::SENT_RESPONSE));
     678                 :            :         installClassVariable(tsigcontext_type, "STATE_VERIFIED_RESPONSE",
     679                 :            :                              Py_BuildValue("I",
     680 [ +  - ][ +  - ]:         29 :                                            TSIGContext::VERIFIED_RESPONSE));
     681                 :            : 
     682                 :            :         installClassVariable(tsigcontext_type, "DEFAULT_FUDGE",
     683 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("H", TSIGContext::DEFAULT_FUDGE));
     684                 :          0 :     } catch (const std::exception& ex) {
     685                 :            :         const std::string ex_what =
     686                 :            :             "Unexpected failure in TSIGContext initialization: " +
     687 [ #  # ][ #  # ]:          0 :             std::string(ex.what());
     688         [ #  # ]:          0 :         PyErr_SetString(po_IscException, ex_what.c_str());
     689                 :            :         return (false);
     690         [ #  # ]:          0 :     } catch (...) {
     691                 :            :         PyErr_SetString(PyExc_SystemError,
     692         [ #  # ]:          0 :                         "Unexpected failure in TSIGContext initialization");
     693                 :            :         return (false);
     694                 :            :     }
     695                 :            : 
     696                 :            :     return (true);
     697                 :            : }
     698                 :            : 
     699                 :            : bool
     700                 :            : initModulePart_TSIG(PyObject* mod) {
     701         [ +  - ]:         29 :     if (PyType_Ready(&tsig_type) < 0) {
     702                 :            :         return (false);
     703                 :            :     }
     704                 :         29 :     void* p = &tsig_type;
     705         [ +  - ]:         29 :     if (PyModule_AddObject(mod, "TSIG", static_cast<PyObject*>(p)) < 0) {
     706                 :            :         return (false);
     707                 :            :     }
     708                 :         29 :     Py_INCREF(&tsig_type);
     709                 :            : 
     710                 :            :     return (true);
     711                 :            : }
     712                 :            : 
     713                 :            : bool
     714                 :         29 : initModulePart_TSIGRecord(PyObject* mod) {
     715         [ +  - ]:         29 :     if (PyType_Ready(&tsigrecord_type) < 0) {
     716                 :            :         return (false);
     717                 :            :     }
     718                 :         29 :     void* p = &tsigrecord_type;
     719         [ +  - ]:         29 :     if (PyModule_AddObject(mod, "TSIGRecord", static_cast<PyObject*>(p)) < 0) {
     720                 :            :         return (false);
     721                 :            :     }
     722                 :         29 :     Py_INCREF(&tsigrecord_type);
     723                 :            : 
     724                 :            :     try {
     725                 :            :         // Constant class variables
     726                 :            :         installClassVariable(tsigrecord_type, "TSIG_TTL",
     727 [ +  - ][ +  - ]:         29 :                              Py_BuildValue("I", 0));
     728                 :          0 :     } catch (const std::exception& ex) {
     729                 :            :         const std::string ex_what =
     730                 :            :             "Unexpected failure in TSIGRecord initialization: " +
     731 [ #  # ][ #  # ]:          0 :             std::string(ex.what());
     732         [ #  # ]:          0 :         PyErr_SetString(po_IscException, ex_what.c_str());
     733                 :            :         return (false);
     734         [ #  # ]:          0 :     } catch (...) {
     735                 :            :         PyErr_SetString(PyExc_SystemError,
     736         [ #  # ]:          0 :                         "Unexpected failure in TSIGRecord initialization");
     737                 :            :         return (false);
     738                 :            :     }
     739                 :            : 
     740                 :            :     return (true);
     741                 :            : }
     742                 :            : 
     743                 :            : PyModuleDef pydnspp = {
     744                 :            :     { PyObject_HEAD_INIT(NULL) NULL, 0, NULL},
     745                 :            :     "pydnspp",
     746                 :            :     "Python bindings for the classes in the isc::dns namespace.\n\n"
     747                 :            :     "These bindings match the original C++ API as closely as possible, "
     748                 :            :     "but are not complete. Some classes are unnecessary (InputBuffer "
     749                 :            :     "and OutputBuffer for instance), and others may be necessary, but "
     750                 :            :     "were not up to now.",
     751                 :            :     -1,
     752                 :            :     NULL,
     753                 :            :     NULL,
     754                 :            :     NULL,
     755                 :            :     NULL,
     756                 :            :     NULL
     757                 :            : };
     758                 :            : }
     759                 :            : 
     760                 :            : PyMODINIT_FUNC
     761                 :         29 : PyInit_pydnspp(void) {
     762                 :         29 :     PyObject* mod = PyModule_Create(&pydnspp);
     763         [ +  - ]:         29 :     if (mod == NULL) {
     764                 :            :         return (NULL);
     765                 :            :     }
     766                 :            : 
     767                 :            :     // Add the exceptions to the class
     768                 :         29 :     po_IscException = PyErr_NewException("pydnspp.IscException", NULL, NULL);
     769                 :         29 :     PyModule_AddObject(mod, "IscException", po_IscException);
     770                 :            : 
     771                 :            :     po_InvalidParameter = PyErr_NewException("pydnspp.InvalidParameter",
     772                 :         29 :                                              NULL, NULL);
     773                 :         29 :     PyModule_AddObject(mod, "InvalidParameter", po_InvalidParameter);
     774                 :            : 
     775                 :            :     // for each part included above, we call its specific initializer
     776                 :            : 
     777         [ +  - ]:         29 :     if (!initModulePart_Name(mod)) {
     778                 :            :         return (NULL);
     779                 :            :     }
     780                 :            : 
     781         [ +  - ]:         29 :     if (!initModulePart_MessageRenderer(mod)) {
     782                 :            :         return (NULL);
     783                 :            :     }
     784                 :            : 
     785         [ +  - ]:         29 :     if (!initModulePart_NSEC3Hash(mod)) {
     786                 :            :         return (NULL);
     787                 :            :     }
     788                 :            : 
     789         [ +  - ]:         29 :     if (!initModulePart_RRClass(mod)) {
     790                 :            :         return (NULL);
     791                 :            :     }
     792                 :            : 
     793         [ +  - ]:         29 :     if (!initModulePart_RRType(mod)) {
     794                 :            :         return (NULL);
     795                 :            :     }
     796                 :            : 
     797         [ +  - ]:         29 :     if (!initModulePart_RRTTL(mod)) {
     798                 :            :         return (NULL);
     799                 :            :     }
     800                 :            : 
     801         [ +  - ]:         29 :     if (!initModulePart_Rdata(mod)) {
     802                 :            :         return (NULL);
     803                 :            :     }
     804                 :            : 
     805         [ +  - ]:         29 :     if (!initModulePart_RRset(mod)) {
     806                 :            :         return (NULL);
     807                 :            :     }
     808                 :            : 
     809         [ +  - ]:         29 :     if (!initModulePart_Question(mod)) {
     810                 :            :         return (NULL);
     811                 :            :     }
     812                 :            : 
     813         [ +  - ]:         29 :     if (!initModulePart_Opcode(mod)) {
     814                 :            :         return (NULL);
     815                 :            :     }
     816                 :            : 
     817         [ +  - ]:         29 :     if (!initModulePart_Rcode(mod)) {
     818                 :            :         return (NULL);
     819                 :            :     }
     820                 :            : 
     821         [ +  - ]:         29 :     if (!initModulePart_Message(mod)) {
     822                 :            :         return (NULL);
     823                 :            :     }
     824                 :            : 
     825         [ +  - ]:         29 :     if (!initModulePart_EDNS(mod)) {
     826                 :            :         return (NULL);
     827                 :            :     }
     828                 :            : 
     829         [ +  - ]:         29 :     if (!initModulePart_Serial(mod)) {
     830                 :            :         return (NULL);
     831                 :            :     }
     832                 :            : 
     833         [ +  - ]:         29 :     if (!initModulePart_TSIGKey(mod)) {
     834                 :            :         return (NULL);
     835                 :            :     }
     836                 :            : 
     837         [ +  - ]:         29 :     if (!initModulePart_TSIGKeyRing(mod)) {
     838                 :            :         return (NULL);
     839                 :            :     }
     840                 :            : 
     841         [ +  - ]:         29 :     if (!initModulePart_TSIG(mod)) {
     842                 :            :         return (NULL);
     843                 :            :     }
     844                 :            : 
     845         [ +  - ]:         29 :     if (!initModulePart_TSIGError(mod)) {
     846                 :            :         return (NULL);
     847                 :            :     }
     848                 :            : 
     849         [ +  - ]:         29 :     if (!initModulePart_TSIGRecord(mod)) {
     850                 :            :         return (NULL);
     851                 :            :     }
     852                 :            : 
     853         [ +  - ]:         29 :     if (!initModulePart_TSIGContext(mod)) {
     854                 :            :         return (NULL);
     855                 :            :     }
     856                 :            : 
     857                 :         29 :     return (mod);
     858                 :         29 : }

Generated by: LCOV version 1.9