/contrib/bind9/lib/dns/dlz.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 653 lines · 364 code · 98 blank · 191 comment · 122 complexity · 1a6a7c40ef1460220891bcdc8e068f19 MD5 · raw file

  1. /*
  2. * Portions Copyright (C) 2005, 2007, 2009-2012 Internet Systems Consortium, Inc. ("ISC")
  3. * Portions Copyright (C) 1999-2001 Internet Software Consortium.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. * PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /*
  18. * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
  19. *
  20. * Permission to use, copy, modify, and distribute this software for any
  21. * purpose with or without fee is hereby granted, provided that the
  22. * above copyright notice and this permission notice appear in all
  23. * copies.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET
  26. * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  28. * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  29. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  30. * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  31. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
  32. * USE OR PERFORMANCE OF THIS SOFTWARE.
  33. *
  34. * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
  35. * conceived and contributed by Rob Butler.
  36. *
  37. * Permission to use, copy, modify, and distribute this software for any
  38. * purpose with or without fee is hereby granted, provided that the
  39. * above copyright notice and this permission notice appear in all
  40. * copies.
  41. *
  42. * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
  43. * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  44. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  45. * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  46. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  47. * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  48. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
  49. * USE OR PERFORMANCE OF THIS SOFTWARE.
  50. */
  51. /* $Id$ */
  52. /*! \file */
  53. /***
  54. *** Imports
  55. ***/
  56. #include <config.h>
  57. #include <dns/fixedname.h>
  58. #include <dns/log.h>
  59. #include <dns/master.h>
  60. #include <dns/dlz.h>
  61. #include <dns/ssu.h>
  62. #include <dns/zone.h>
  63. #include <isc/buffer.h>
  64. #include <isc/magic.h>
  65. #include <isc/mem.h>
  66. #include <isc/once.h>
  67. #include <isc/rwlock.h>
  68. #include <isc/string.h>
  69. #include <isc/util.h>
  70. /***
  71. *** Supported DLZ DB Implementations Registry
  72. ***/
  73. static ISC_LIST(dns_dlzimplementation_t) dlz_implementations;
  74. static isc_rwlock_t dlz_implock;
  75. static isc_once_t once = ISC_ONCE_INIT;
  76. static void
  77. dlz_initialize(void) {
  78. RUNTIME_CHECK(isc_rwlock_init(&dlz_implock, 0, 0) == ISC_R_SUCCESS);
  79. ISC_LIST_INIT(dlz_implementations);
  80. }
  81. /*%
  82. * Searches the dlz_implementations list for a driver matching name.
  83. */
  84. static inline dns_dlzimplementation_t *
  85. dlz_impfind(const char *name) {
  86. dns_dlzimplementation_t *imp;
  87. for (imp = ISC_LIST_HEAD(dlz_implementations);
  88. imp != NULL;
  89. imp = ISC_LIST_NEXT(imp, link))
  90. if (strcasecmp(name, imp->name) == 0)
  91. return (imp);
  92. return (NULL);
  93. }
  94. /***
  95. *** Basic DLZ Methods
  96. ***/
  97. isc_result_t
  98. dns_dlzallowzonexfr(dns_view_t *view, dns_name_t *name,
  99. isc_sockaddr_t *clientaddr, dns_db_t **dbp)
  100. {
  101. isc_result_t result;
  102. dns_dlzallowzonexfr_t allowzonexfr;
  103. dns_dlzdb_t *dlzdatabase;
  104. /*
  105. * Performs checks to make sure data is as we expect it to be.
  106. */
  107. REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
  108. REQUIRE(name != NULL);
  109. REQUIRE(dbp != NULL && *dbp == NULL);
  110. /* ask driver if the zone is supported */
  111. dlzdatabase = view->dlzdatabase;
  112. allowzonexfr = dlzdatabase->implementation->methods->allowzonexfr;
  113. result = (*allowzonexfr)(dlzdatabase->implementation->driverarg,
  114. dlzdatabase->dbdata, dlzdatabase->mctx,
  115. view->rdclass, name, clientaddr, dbp);
  116. if (result == ISC_R_NOTIMPLEMENTED)
  117. return (ISC_R_NOTFOUND);
  118. return (result);
  119. }
  120. isc_result_t
  121. dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
  122. unsigned int argc, char *argv[], dns_dlzdb_t **dbp)
  123. {
  124. dns_dlzimplementation_t *impinfo;
  125. isc_result_t result;
  126. /*
  127. * initialize the dlz_implementations list, this is guaranteed
  128. * to only really happen once.
  129. */
  130. RUNTIME_CHECK(isc_once_do(&once, dlz_initialize) == ISC_R_SUCCESS);
  131. /*
  132. * Performs checks to make sure data is as we expect it to be.
  133. */
  134. REQUIRE(dbp != NULL && *dbp == NULL);
  135. REQUIRE(dlzname != NULL);
  136. REQUIRE(drivername != NULL);
  137. REQUIRE(mctx != NULL);
  138. /* write log message */
  139. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  140. DNS_LOGMODULE_DLZ, ISC_LOG_INFO,
  141. "Loading '%s' using driver %s", dlzname, drivername);
  142. /* lock the dlz_implementations list so we can search it. */
  143. RWLOCK(&dlz_implock, isc_rwlocktype_read);
  144. /* search for the driver implementation */
  145. impinfo = dlz_impfind(drivername);
  146. if (impinfo == NULL) {
  147. RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
  148. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  149. DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
  150. "unsupported DLZ database driver '%s'."
  151. " %s not loaded.",
  152. drivername, dlzname);
  153. return (ISC_R_NOTFOUND);
  154. }
  155. /* Allocate memory to hold the DLZ database driver */
  156. (*dbp) = isc_mem_get(mctx, sizeof(dns_dlzdb_t));
  157. if ((*dbp) == NULL) {
  158. RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
  159. return (ISC_R_NOMEMORY);
  160. }
  161. /* Make sure memory region is set to all 0's */
  162. memset((*dbp), 0, sizeof(dns_dlzdb_t));
  163. (*dbp)->implementation = impinfo;
  164. /* Create a new database using implementation 'drivername'. */
  165. result = ((impinfo->methods->create)(mctx, dlzname, argc, argv,
  166. impinfo->driverarg,
  167. &(*dbp)->dbdata));
  168. /* mark the DLZ driver as valid */
  169. if (result == ISC_R_SUCCESS) {
  170. RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
  171. (*dbp)->magic = DNS_DLZ_MAGIC;
  172. isc_mem_attach(mctx, &(*dbp)->mctx);
  173. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  174. DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
  175. "DLZ driver loaded successfully.");
  176. return (ISC_R_SUCCESS);
  177. } else {
  178. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  179. DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
  180. "DLZ driver failed to load.");
  181. }
  182. /* impinfo->methods->create failed. */
  183. RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
  184. isc_mem_put(mctx, (*dbp), sizeof(dns_dlzdb_t));
  185. return (result);
  186. }
  187. void
  188. dns_dlzdestroy(dns_dlzdb_t **dbp) {
  189. isc_mem_t *mctx;
  190. dns_dlzdestroy_t destroy;
  191. /* Write debugging message to log */
  192. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  193. DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
  194. "Unloading DLZ driver.");
  195. /*
  196. * Perform checks to make sure data is as we expect it to be.
  197. */
  198. REQUIRE(dbp != NULL && DNS_DLZ_VALID(*dbp));
  199. #ifdef BIND9
  200. if ((*dbp)->ssutable != NULL) {
  201. dns_ssutable_detach(&(*dbp)->ssutable);
  202. }
  203. #endif
  204. /* call the drivers destroy method */
  205. if ((*dbp) != NULL) {
  206. mctx = (*dbp)->mctx;
  207. destroy = (*dbp)->implementation->methods->destroy;
  208. (*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata);
  209. /* return memory */
  210. isc_mem_put(mctx, (*dbp), sizeof(dns_dlzdb_t));
  211. isc_mem_detach(&mctx);
  212. }
  213. *dbp = NULL;
  214. }
  215. isc_result_t
  216. dns_dlzfindzone(dns_view_t *view, dns_name_t *name, unsigned int minlabels,
  217. dns_db_t **dbp)
  218. {
  219. dns_fixedname_t fname;
  220. dns_name_t *zonename;
  221. unsigned int namelabels;
  222. unsigned int i;
  223. isc_result_t result;
  224. dns_dlzfindzone_t findzone;
  225. dns_dlzdb_t *dlzdatabase;
  226. /*
  227. * Performs checks to make sure data is as we expect it to be.
  228. */
  229. REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
  230. REQUIRE(name != NULL);
  231. REQUIRE(dbp != NULL && *dbp == NULL);
  232. /* setup a "fixed" dns name */
  233. dns_fixedname_init(&fname);
  234. zonename = dns_fixedname_name(&fname);
  235. /* count the number of labels in the name */
  236. namelabels = dns_name_countlabels(name);
  237. /*
  238. * loop through starting with the longest domain name and
  239. * trying shorter names portions of the name until we find a
  240. * match, have an error, or are below the 'minlabels'
  241. * threshold. minlabels is 0, if the standard database didn't
  242. * have a zone name match. Otherwise minlabels is the number
  243. * of labels in that name. We need to beat that for a
  244. * "better" match for the DLZ database to be authoritative
  245. * instead of the standard database.
  246. */
  247. for (i = namelabels; i > minlabels && i > 1; i--) {
  248. if (i == namelabels) {
  249. result = dns_name_copy(name, zonename, NULL);
  250. if (result != ISC_R_SUCCESS)
  251. return (result);
  252. } else
  253. dns_name_split(name, i, NULL, zonename);
  254. /* ask SDLZ driver if the zone is supported */
  255. dlzdatabase = view->dlzdatabase;
  256. findzone = dlzdatabase->implementation->methods->findzone;
  257. result = (*findzone)(dlzdatabase->implementation->driverarg,
  258. dlzdatabase->dbdata, dlzdatabase->mctx,
  259. view->rdclass, zonename, dbp);
  260. if (result != ISC_R_NOTFOUND)
  261. return (result);
  262. }
  263. return (ISC_R_NOTFOUND);
  264. }
  265. /*%
  266. * Registers a DLZ driver. This basically just adds the dlz
  267. * driver to the list of available drivers in the dlz_implementations list.
  268. */
  269. isc_result_t
  270. dns_dlzregister(const char *drivername, const dns_dlzmethods_t *methods,
  271. void *driverarg, isc_mem_t *mctx,
  272. dns_dlzimplementation_t **dlzimp)
  273. {
  274. dns_dlzimplementation_t *dlz_imp;
  275. /* Write debugging message to log */
  276. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  277. DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
  278. "Registering DLZ driver '%s'", drivername);
  279. /*
  280. * Performs checks to make sure data is as we expect it to be.
  281. */
  282. REQUIRE(drivername != NULL);
  283. REQUIRE(methods != NULL);
  284. REQUIRE(methods->create != NULL);
  285. REQUIRE(methods->destroy != NULL);
  286. REQUIRE(methods->findzone != NULL);
  287. REQUIRE(mctx != NULL);
  288. REQUIRE(dlzimp != NULL && *dlzimp == NULL);
  289. /*
  290. * initialize the dlz_implementations list, this is guaranteed
  291. * to only really happen once.
  292. */
  293. RUNTIME_CHECK(isc_once_do(&once, dlz_initialize) == ISC_R_SUCCESS);
  294. /* lock the dlz_implementations list so we can modify it. */
  295. RWLOCK(&dlz_implock, isc_rwlocktype_write);
  296. /*
  297. * check that another already registered driver isn't using
  298. * the same name
  299. */
  300. dlz_imp = dlz_impfind(drivername);
  301. if (dlz_imp != NULL) {
  302. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  303. DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
  304. "DLZ Driver '%s' already registered",
  305. drivername);
  306. RWUNLOCK(&dlz_implock, isc_rwlocktype_write);
  307. return (ISC_R_EXISTS);
  308. }
  309. /*
  310. * Allocate memory for a dlz_implementation object. Error if
  311. * we cannot.
  312. */
  313. dlz_imp = isc_mem_get(mctx, sizeof(dns_dlzimplementation_t));
  314. if (dlz_imp == NULL) {
  315. RWUNLOCK(&dlz_implock, isc_rwlocktype_write);
  316. return (ISC_R_NOMEMORY);
  317. }
  318. /* Make sure memory region is set to all 0's */
  319. memset(dlz_imp, 0, sizeof(dns_dlzimplementation_t));
  320. /* Store the data passed into this method */
  321. dlz_imp->name = drivername;
  322. dlz_imp->methods = methods;
  323. dlz_imp->mctx = NULL;
  324. dlz_imp->driverarg = driverarg;
  325. /* attach the new dlz_implementation object to a memory context */
  326. isc_mem_attach(mctx, &dlz_imp->mctx);
  327. /*
  328. * prepare the dlz_implementation object to be put in a list,
  329. * and append it to the list
  330. */
  331. ISC_LINK_INIT(dlz_imp, link);
  332. ISC_LIST_APPEND(dlz_implementations, dlz_imp, link);
  333. /* Unlock the dlz_implementations list. */
  334. RWUNLOCK(&dlz_implock, isc_rwlocktype_write);
  335. /* Pass back the dlz_implementation that we created. */
  336. *dlzimp = dlz_imp;
  337. return (ISC_R_SUCCESS);
  338. }
  339. /*%
  340. * Helper function for dns_dlzstrtoargv().
  341. * Pardon the gratuitous recursion.
  342. */
  343. static isc_result_t
  344. dns_dlzstrtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
  345. char ***argvp, unsigned int n)
  346. {
  347. isc_result_t result;
  348. restart:
  349. /* Discard leading whitespace. */
  350. while (*s == ' ' || *s == '\t')
  351. s++;
  352. if (*s == '\0') {
  353. /* We have reached the end of the string. */
  354. *argcp = n;
  355. *argvp = isc_mem_get(mctx, n * sizeof(char *));
  356. if (*argvp == NULL)
  357. return (ISC_R_NOMEMORY);
  358. } else {
  359. char *p = s;
  360. while (*p != ' ' && *p != '\t' && *p != '\0' && *p != '{') {
  361. if (*p == '\n') {
  362. *p = ' ';
  363. goto restart;
  364. }
  365. p++;
  366. }
  367. /* do "grouping", items between { and } are one arg */
  368. if (*p == '{') {
  369. char *t = p;
  370. /*
  371. * shift all characters to left by 1 to get rid of '{'
  372. */
  373. while (*t != '\0') {
  374. t++;
  375. *(t-1) = *t;
  376. }
  377. while (*p != '\0' && *p != '}') {
  378. p++;
  379. }
  380. /* get rid of '}' character */
  381. if (*p == '}') {
  382. *p = '\0';
  383. p++;
  384. }
  385. /* normal case, no "grouping" */
  386. } else if (*p != '\0')
  387. *p++ = '\0';
  388. result = dns_dlzstrtoargvsub(mctx, p, argcp, argvp, n + 1);
  389. if (result != ISC_R_SUCCESS)
  390. return (result);
  391. (*argvp)[n] = s;
  392. }
  393. return (ISC_R_SUCCESS);
  394. }
  395. /*%
  396. * Tokenize the string "s" into whitespace-separated words,
  397. * return the number of words in '*argcp' and an array
  398. * of pointers to the words in '*argvp'. The caller
  399. * must free the array using isc_mem_put(). The string
  400. * is modified in-place.
  401. */
  402. isc_result_t
  403. dns_dlzstrtoargv(isc_mem_t *mctx, char *s,
  404. unsigned int *argcp, char ***argvp)
  405. {
  406. return(dns_dlzstrtoargvsub(mctx, s, argcp, argvp, 0));
  407. }
  408. /*%
  409. * Unregisters a DLZ driver. This basically just removes the dlz
  410. * driver from the list of available drivers in the dlz_implementations list.
  411. */
  412. void
  413. dns_dlzunregister(dns_dlzimplementation_t **dlzimp) {
  414. dns_dlzimplementation_t *dlz_imp;
  415. isc_mem_t *mctx;
  416. /* Write debugging message to log */
  417. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  418. DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
  419. "Unregistering DLZ driver.");
  420. /*
  421. * Performs checks to make sure data is as we expect it to be.
  422. */
  423. REQUIRE(dlzimp != NULL && *dlzimp != NULL);
  424. /*
  425. * initialize the dlz_implementations list, this is guaranteed
  426. * to only really happen once.
  427. */
  428. RUNTIME_CHECK(isc_once_do(&once, dlz_initialize) == ISC_R_SUCCESS);
  429. dlz_imp = *dlzimp;
  430. /* lock the dlz_implementations list so we can modify it. */
  431. RWLOCK(&dlz_implock, isc_rwlocktype_write);
  432. /* remove the dlz_implementation object from the list */
  433. ISC_LIST_UNLINK(dlz_implementations, dlz_imp, link);
  434. mctx = dlz_imp->mctx;
  435. /*
  436. * Return the memory back to the available memory pool and
  437. * remove it from the memory context.
  438. */
  439. isc_mem_put(mctx, dlz_imp, sizeof(dns_dlzimplementation_t));
  440. isc_mem_detach(&mctx);
  441. /* Unlock the dlz_implementations list. */
  442. RWUNLOCK(&dlz_implock, isc_rwlocktype_write);
  443. }
  444. #ifdef BIND9
  445. /*
  446. * Create a writeable DLZ zone. This can be called by DLZ drivers
  447. * during configure() to create a zone that can be updated. The zone
  448. * type is set to dns_zone_dlz, which is equivalent to a master zone
  449. *
  450. * This function uses a callback setup in dns_dlzconfigure() to call
  451. * into the server zone code to setup the remaining pieces of server
  452. * specific functionality on the zone
  453. */
  454. isc_result_t
  455. dns_dlz_writeablezone(dns_view_t *view, const char *zone_name) {
  456. dns_zone_t *zone = NULL;
  457. dns_zone_t *dupzone = NULL;
  458. isc_result_t result;
  459. isc_buffer_t buffer;
  460. dns_fixedname_t fixorigin;
  461. dns_name_t *origin;
  462. dns_dlzdb_t *dlzdatabase;
  463. REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
  464. dlzdatabase = view->dlzdatabase;
  465. REQUIRE(dlzdatabase->configure_callback != NULL);
  466. isc_buffer_init(&buffer, zone_name, strlen(zone_name));
  467. isc_buffer_add(&buffer, strlen(zone_name));
  468. dns_fixedname_init(&fixorigin);
  469. result = dns_name_fromtext(dns_fixedname_name(&fixorigin),
  470. &buffer, dns_rootname, 0, NULL);
  471. if (result != ISC_R_SUCCESS)
  472. goto cleanup;
  473. origin = dns_fixedname_name(&fixorigin);
  474. /* See if the zone already exists */
  475. result = dns_view_findzone(view, origin, &dupzone);
  476. if (result == ISC_R_SUCCESS) {
  477. dns_zone_detach(&dupzone);
  478. result = ISC_R_EXISTS;
  479. goto cleanup;
  480. }
  481. INSIST(dupzone == NULL);
  482. /* Create it */
  483. result = dns_zone_create(&zone, view->mctx);
  484. if (result != ISC_R_SUCCESS)
  485. goto cleanup;
  486. result = dns_zone_setorigin(zone, origin);
  487. if (result != ISC_R_SUCCESS)
  488. goto cleanup;
  489. dns_zone_setview(zone, view);
  490. dns_zone_setadded(zone, ISC_TRUE);
  491. if (dlzdatabase->ssutable == NULL) {
  492. result = dns_ssutable_createdlz(dlzdatabase->mctx,
  493. &dlzdatabase->ssutable,
  494. view->dlzdatabase);
  495. if (result != ISC_R_SUCCESS)
  496. goto cleanup;
  497. }
  498. dns_zone_setssutable(zone, dlzdatabase->ssutable);
  499. result = dlzdatabase->configure_callback(view, zone);
  500. if (result != ISC_R_SUCCESS)
  501. goto cleanup;
  502. /*
  503. * Add the zone to its view in the new view list.
  504. */
  505. result = dns_view_addzone(view, zone);
  506. cleanup:
  507. if (zone != NULL)
  508. dns_zone_detach(&zone);
  509. return (result);
  510. }
  511. #endif
  512. /*%
  513. * Configure a DLZ driver. This is optional, and if supplied gives
  514. * the backend an opportunity to configure parameters related to DLZ.
  515. */
  516. isc_result_t
  517. dns_dlzconfigure(dns_view_t *view, isc_result_t (*callback)(dns_view_t *,
  518. dns_zone_t *))
  519. {
  520. dns_dlzimplementation_t *impl;
  521. dns_dlzdb_t *dlzdatabase;
  522. isc_result_t result;
  523. REQUIRE(view != NULL);
  524. REQUIRE(DNS_DLZ_VALID(view->dlzdatabase));
  525. REQUIRE(view->dlzdatabase->implementation != NULL);
  526. dlzdatabase = view->dlzdatabase;
  527. impl = dlzdatabase->implementation;
  528. if (impl->methods->configure == NULL)
  529. return (ISC_R_SUCCESS);
  530. dlzdatabase->configure_callback = callback;
  531. result = impl->methods->configure(impl->driverarg,
  532. dlzdatabase->dbdata, view);
  533. return (result);
  534. }
  535. isc_boolean_t
  536. dns_dlz_ssumatch(dns_dlzdb_t *dlzdatabase,
  537. dns_name_t *signer, dns_name_t *name, isc_netaddr_t *tcpaddr,
  538. dns_rdatatype_t type, const dst_key_t *key)
  539. {
  540. dns_dlzimplementation_t *impl;
  541. isc_boolean_t r;
  542. REQUIRE(dlzdatabase != NULL);
  543. REQUIRE(dlzdatabase->implementation != NULL);
  544. REQUIRE(dlzdatabase->implementation->methods != NULL);
  545. impl = dlzdatabase->implementation;
  546. if (impl->methods->ssumatch == NULL) {
  547. isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
  548. DNS_LOGMODULE_DLZ, ISC_LOG_INFO,
  549. "No ssumatch method for DLZ database");
  550. return (ISC_FALSE);
  551. }
  552. r = impl->methods->ssumatch(signer, name, tcpaddr, type, key,
  553. impl->driverarg, dlzdatabase->dbdata);
  554. return (r);
  555. }