finder_inc.cc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. namespace {
  2. const char* const ZoneFinder_doc = "\
  3. The base class to search a zone for RRsets.\n\
  4. \n\
  5. The ZoneFinder class is a wrapper for the c++ base class for representing an\n\
  6. object that performs DNS lookups in a specific zone accessible via a\n\
  7. data source. In general, different types of data sources (in-memory,\n\
  8. database-based, etc) define their own derived c++ classes of ZoneFinder,\n\
  9. implementing ways to retrieve the required data through the common\n\
  10. interfaces declared in the base class. Each concrete ZoneFinder object\n\
  11. is therefore (conceptually) associated with a specific zone of one\n\
  12. specific data source instance.\n\
  13. \n\
  14. The origin name and the RR class of the associated zone are available\n\
  15. via the get_origin() and get_class() methods, respectively.\n\
  16. \n\
  17. The most important method of this class is find(), which performs the\n\
  18. lookup for a given domain and type. See the description of the method\n\
  19. for details.\n\
  20. \n\
  21. It's not clear whether we should request that a zone finder form a\n\
  22. \"transaction\", that is, whether to ensure the finder is not\n\
  23. susceptible to changes made by someone else than the creator of the\n\
  24. finder. If we don't request that, for example, two different lookup\n\
  25. results for the same name and type can be different if other threads\n\
  26. or programs make updates to the zone between the lookups. We should\n\
  27. revisit this point as we gain more experiences.\n\
  28. \n\
  29. ";
  30. const char* const ZoneFinder_getOrigin_doc = "\
  31. get_origin() -> isc.dns.Name\n\
  32. \n\
  33. Return the origin name of the zone.\n\
  34. \n\
  35. ";
  36. const char* const ZoneFinder_getClass_doc = "\
  37. get_class() -> isc.dns.RRClass\n\
  38. \n\
  39. Return the RR class of the zone.\n\
  40. \n\
  41. ";
  42. // Main changes from the C++ doxygen version:
  43. // - Return type: use tuple instead of the dedicated FindResult type
  44. // - NULL->None
  45. // - exceptions
  46. const char* const ZoneFinder_find_doc = "\
  47. find(name, type, options=FIND_DEFAULT) -> (integer, RRset, integer)\n\
  48. \n\
  49. Search the zone for a given pair of domain name and RR type.\n\
  50. \n\
  51. Each derived version of this method searches the underlying backend\n\
  52. for the data that best matches the given name and type. This method is\n\
  53. expected to be \"intelligent\", and identifies the best possible\n\
  54. answer for the search key. Specifically,\n\
  55. \n\
  56. - If the search name belongs under a zone cut, it returns the code of\n\
  57. DELEGATION and the NS RRset at the zone cut.\n\
  58. - If there is no matching name, it returns the code of NXDOMAIN.\n\
  59. - If there is a matching name but no RRset of the search type, it\n\
  60. returns the code of NXRRSET. This case includes the search name\n\
  61. matches an empty node of the zone.\n\
  62. - If there is a CNAME RR of the searched name but there is no RR of\n\
  63. the searched type of the name (so this type is different from\n\
  64. CNAME), it returns the code of CNAME and that CNAME RR. Note that if\n\
  65. the searched RR type is CNAME, it is considered a successful match,\n\
  66. and the code of SUCCESS will be returned.\n\
  67. - If the search name matches a delegation point of DNAME, it returns\n\
  68. the code of DNAME and that DNAME RR.\n\
  69. \n\
  70. No RRset will be returned in the NXDOMAIN and NXRRSET cases (the\n\
  71. second element of the tuple will be None), unless DNSSEC data are\n\
  72. required. See below for the cases with DNSSEC.\n\
  73. \n\
  74. The third element of the returned tuple provides supplemental\n\
  75. information about the search result in the form of a bitmask (called\n\
  76. \"flags\"). Such information may be useful for the caller if the\n\
  77. caller wants to collect additional DNSSEC proofs based on the search\n\
  78. result.\n\
  79. \n\
  80. The options parameter specifies customized behavior of the search.\n\
  81. Their semantics is as follows (they are or bit-field):\n\
  82. \n\
  83. - FIND_GLUE_OK Allow search under a zone cut. By default the search\n\
  84. will stop once it encounters a zone cut. If this option is specified\n\
  85. it remembers information about the highest zone cut and continues\n\
  86. the search until it finds an exact match for the given name or it\n\
  87. detects there is no exact match. If an exact match is found, RRsets\n\
  88. for that name are searched just like the normal case; otherwise, if\n\
  89. the search has encountered a zone cut, DELEGATION with the\n\
  90. information of the highest zone cut will be returned.\n\
  91. - FIND_DNSSEC Request that DNSSEC data (like NSEC, RRSIGs) are\n\
  92. returned with the answer. It is allowed for the data source to\n\
  93. include them even when not requested.\n\
  94. - NO_WILDCARD Do not try wildcard matching. This option is of no use\n\
  95. for normal lookups; it's intended to be used to get a DNSSEC proof\n\
  96. of the non existence of any matching wildcard or non existence of an\n\
  97. exact match when a wildcard match is found.\n\
  98. \n\
  99. In general, name is expected to be included in the zone, that is, it\n\
  100. should be equal to or a subdomain of the zone origin. Otherwise this\n\
  101. method will return NXDOMAIN with an empty RRset. But such a case\n\
  102. should rather be considered a caller's bug.\n\
  103. \n\
  104. Note: For this reason it's probably better to throw an exception than\n\
  105. returning NXDOMAIN. This point should be revisited in a near future\n\
  106. version. In any case applications shouldn't call this method for an\n\
  107. out-of-zone name.\n\
  108. \n\
  109. DNSSEC considerations: The result when DNSSEC data are required can be\n\
  110. very complicated, especially if it involves negative result or\n\
  111. wildcard match. Specifically, if an application calls this method for\n\
  112. DNS query processing with DNSSEC data, and if the search result code\n\
  113. is either NXDOMAIN or NXRRRSET, and/or RESULT_WILDCARD\n\
  114. flag is set in the returned flags value,\n\
  115. then the application will need to find additional NSEC or NSEC3\n\
  116. records for supplemental proofs. This method helps the application for\n\
  117. such post search processing.\n\
  118. \n\
  119. First, it tells the application whether the zone is signed with NSEC\n\
  120. or NSEC3 via the RESULT_NSEC_SIGNED and RESULT_NSEC3_SIGNED flags\n\
  121. in the returned flags value. Any sanely signed zone\n\
  122. should be signed with either (and only one) of these two types of RRs;\n\
  123. however, the application should expect that the zone could be broken\n\
  124. and these methods could both return false. But this method should\n\
  125. ensure that not both of these methods return true.\n\
  126. \n\
  127. In case it's signed with NSEC3, there is no further information\n\
  128. returned from this method.\n\
  129. \n\
  130. In case it's signed with NSEC, this method will possibly return a\n\
  131. related NSEC RRset in the second element of the tuple. What kind of\n\
  132. NSEC is returned depends on the result code (NXDOMAIN or NXRRSET) and\n\
  133. on whether it's a wildcard match:\n\
  134. \n\
  135. - In case of NXDOMAIN, the returned NSEC covers the queried domain\n\
  136. that proves that the query name does not exist in the zone. Note\n\
  137. that this does not necessarily prove it doesn't even match a\n\
  138. wildcard (even if the result of NXDOMAIN can only happen when\n\
  139. there's no matching wildcard either). It is caller's responsibility\n\
  140. to provide a proof that there is no matching wildcard if that proof\n\
  141. is necessary.\n\
  142. - In case of NXRRSET, we need to consider the following cases\n\
  143. referring to Section 3.1.3 of RFC4035:\n\
  144. \n\
  145. 1. (Normal) no data: there is a matching non-wildcard name with a\n\
  146. different RR type. This is the \"No Data\" case of the RFC.\n\
  147. 2. (Normal) empty non terminal: there is no matching (exact or\n\
  148. wildcard) name, but there is a subdomain with an RR of the query\n\
  149. name. This is one case of \"Name Error\" of the RFC.\n\
  150. 3. Wildcard empty non terminal: similar to 2, but the empty name is\n\
  151. a wildcard, and matches the query name by wildcard expansion. This\n\
  152. is a special case of \"Name Error\" of the RFC.\n\
  153. 4. Wildcard no data: there is no exact match name, but there is a\n\
  154. wildcard name that matches the query name with a different type of RR.\n\
  155. This is the \"Wildcard No Data\" case of the RFC.\n\
  156. \n\
  157. In case 1, find() returns NSEC of the matching name.\n\
  158. \n\
  159. In case 2, find() will return NSEC for the interval where the empty\n\
  160. nonterminal lives. The end of the interval is the subdomain causing\n\
  161. existence of the empty nonterminal (if there's sub.x.example.com, and\n\
  162. no record in x.example.com, then x.example.com exists implicitly - is\n\
  163. the empty nonterminal and sub.x.example.com is the subdomain causing\n\
  164. it). Note that this NSEC proves not only the existence of empty non\n\
  165. terminal name but also the non existence of possibly matching wildcard\n\
  166. name, because there can be no better wildcard match than the exact\n\
  167. matching empty name.\n\
  168. \n\
  169. In case 3, find() will return NSEC for the interval where the wildcard\n\
  170. empty nonterminal lives. Cases 2 and 3 are especially complicated and\n\
  171. confusing. See the examples below.\n\
  172. \n\
  173. In case 4, find() will return NSEC of the matching wildcard name.\n\
  174. \n\
  175. Examples: if zone \"example.com\" has the following record:\n\
  176. \n\
  177. a.example.com. NSEC a.b.example.com.\n\
  178. \n\
  179. a call to find() for \"b.example.com.\" with the FIND_DNSSEC option\n\
  180. will result in NXRRSET, and this NSEC will be returned.\n\
  181. Likewise, if zone \"example.org\" has the following record,\n\
  182. \n\
  183. a.example.org. NSEC x.*.b.example.org.\n\
  184. \n\
  185. a call to find() for \"y.b.example.org\" with FIND_DNSSEC will\n\
  186. result in NXRRSET and this NSEC; RESULT_WILDCARD bit is set in the\n\
  187. returned flags.\n\
  188. \n\
  189. This method raises an isc.datasrc.Error exception if there is an\n\
  190. internal error in the datasource.\n\
  191. \n\
  192. Parameters:\n\
  193. name The domain name to be searched for.\n\
  194. type The RR type to be searched for.\n\
  195. options The search options.\n\
  196. \n\
  197. Return Value(s): A tuple of a result code (integer), an RRset object\n\
  198. and flags bitmask (integer).\n\
  199. ";
  200. const char* const ZoneFinder_findAll_doc = "\
  201. find_all(isc.dns.Name, options=FIND_DEFAULT) ->\n\
  202. (integer, RRset, integer) | (integer, [RRset], integer)\
  203. \n\
  204. Finds all RRsets in the given name.\n\
  205. \n\
  206. This function works almost exactly in the same way as the find one.\n\
  207. The only difference is, when the lookup is successful (eg. the code is\n\
  208. SUCCESS), all the RRsets residing in the named node are returned in the\n\
  209. second element of the returned tuple. All\n\
  210. the other (unsuccessful) cases are handled the same, including\n\
  211. returning delegations, NSEC/NSEC3 availability and NSEC proofs,\n\
  212. wildcard information etc. The options parameter works the same way and\n\
  213. it should conform to the same exception restrictions.\n\
  214. \n\
  215. Parameters:\n\
  216. name The domain name to be searched for.\n\
  217. options The search options.\n\
  218. \n\
  219. Return Value(s): A tuple of a result code (integer), an either\n\
  220. RRset object or a list of RRsets, and flags (integer).\n\
  221. In the second element a single RRset is returned for cases where the\n\
  222. result is some kind of delegation, CNAME or similar; in other cases\n\
  223. a list of RRsets is returned, containing all the results.\n\
  224. ";
  225. const char* const ZoneFinder_find_previous_name_doc = "\
  226. find_previous_name(isc.dns.Name) -> isc.dns.Name\n\
  227. \n\
  228. Gets the previous name in the DNSSEC order. This can be used\n\
  229. to find the correct NSEC records for proving nonexistence\n\
  230. of domains.\n\
  231. \n\
  232. This method does not include under-zone-cut data (glue data).\n\
  233. \n\
  234. Raises isc.datasrc.NotImplemented in case the data source backend\n\
  235. doesn't support DNSSEC or there is no previous in the zone (NSEC\n\
  236. records might be missing in the DB, the queried name is less or\n\
  237. equal to the apex).\n\
  238. \n\
  239. Raises isc.datasrc.Error for low-level or internal datasource errors\n\
  240. (like broken connection to database, wrong data living there).\n\
  241. ";
  242. } // unnamed namespace