Lines Matching refs:lctx
110 isc_result_t (*openfile)(dns_loadctx_t *lctx,
112 isc_result_t (*load)(dns_loadctx_t *lctx);
163 #define DNS_LCTX_VALID(lctx) ISC_MAGIC_VALID(lctx, DNS_LCTX_MAGIC)
168 openfile_text(dns_loadctx_t *lctx, const char *master_file);
171 openfile_raw(dns_loadctx_t *lctx, const char *master_file);
174 load_text(dns_loadctx_t *lctx);
177 load_raw(dns_loadctx_t *lctx);
180 pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t *lctx);
201 task_send(dns_loadctx_t *lctx);
204 loadctx_destroy(dns_loadctx_t *lctx);
215 if (MANYERRS(lctx, result)) { \
216 SETRESULT(lctx, result); \
225 if (MANYERRS(lctx, result)) { \
226 SETRESULT(lctx, result); \
237 result = commit(callbacks, lctx, ¤t_list, \
239 if (MANYERRS(lctx, result)) { \
240 SETRESULT(lctx, result); \
243 result = commit(callbacks, lctx, &glue_list, \
245 if (MANYERRS(lctx, result)) { \
246 SETRESULT(lctx, result); \
266 GETTOKEN(lctx->lex, 0, &token, ISC_TRUE); \
268 isc_lex_ungettoken(lctx->lex, &token); \
270 if (MANYERRS(lctx, result)) { \
271 SETRESULT(lctx, result); \
280 #define MANYERRS(lctx, result) \
283 ((lctx)->options & DNS_MASTER_MANYERRORS) != 0)
285 #define SETRESULT(lctx, r) \
287 if ((lctx)->result == ISC_R_SUCCESS) \
288 (lctx)->result = r; \
404 dns_loadctx_t *lctx;
408 lctx = *lctxp;
409 REQUIRE(DNS_LCTX_VALID(lctx));
411 LOCK(&lctx->lock);
412 INSIST(lctx->references > 0);
413 lctx->references--;
414 if (lctx->references == 0)
416 UNLOCK(&lctx->lock);
419 loadctx_destroy(lctx);
440 loadctx_destroy(dns_loadctx_t *lctx) {
444 REQUIRE(DNS_LCTX_VALID(lctx));
446 lctx->magic = 0;
447 if (lctx->inc != NULL)
448 incctx_destroy(lctx->mctx, lctx->inc);
450 if (lctx->f != NULL) {
451 result = isc_stdio_close(lctx->f);
460 if (lctx->lex != NULL && !lctx->keep_lex)
461 isc_lex_destroy(&lctx->lex);
463 if (lctx->task != NULL)
464 isc_task_detach(&lctx->task);
465 DESTROYLOCK(&lctx->lock);
467 isc_mem_attach(lctx->mctx, &mctx);
468 isc_mem_detach(&lctx->mctx);
469 isc_mem_put(mctx, lctx, sizeof(*lctx));
515 dns_loadctx_t *lctx;
531 lctx = isc_mem_get(mctx, sizeof(*lctx));
532 if (lctx == NULL)
534 result = isc_mutex_init(&lctx->lock);
536 isc_mem_put(mctx, lctx, sizeof(*lctx));
540 lctx->inc = NULL;
541 result = incctx_create(mctx, origin, &lctx->inc);
545 lctx->format = format;
550 lctx->openfile = openfile_text;
551 lctx->load = load_text;
554 lctx->openfile = openfile_raw;
555 lctx->load = load_raw;
560 lctx->lex = lex;
561 lctx->keep_lex = ISC_TRUE;
563 lctx->lex = NULL;
564 result = isc_lex_create(mctx, TOKENSIZ, &lctx->lex);
567 lctx->keep_lex = ISC_FALSE;
573 isc_lex_setspecials(lctx->lex, specials);
574 isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE);
577 lctx->ttl_known = ISC_FALSE;
578 lctx->ttl = 0;
579 lctx->default_ttl_known = ISC_FALSE;
580 lctx->default_ttl = 0;
581 lctx->warn_1035 = ISC_TRUE; /* XXX Argument? */
582 lctx->warn_tcr = ISC_TRUE; /* XXX Argument? */
583 lctx->warn_sigexpired = ISC_TRUE; /* XXX Argument? */
584 lctx->options = options;
585 lctx->seen_include = ISC_FALSE;
586 lctx->zclass = zclass;
587 lctx->resign = resign;
588 lctx->result = ISC_R_SUCCESS;
590 dns_fixedname_init(&lctx->fixed_top);
591 lctx->top = dns_fixedname_name(&lctx->fixed_top);
593 dns_name_fromregion(lctx->top, &r);
595 lctx->f = NULL;
596 lctx->first = ISC_TRUE;
598 lctx->loop_cnt = (done != NULL) ? 100 : 0;
599 lctx->callbacks = callbacks;
600 lctx->task = NULL;
602 isc_task_attach(task, &lctx->task);
603 lctx->done = done;
604 lctx->done_arg = done_arg;
605 lctx->canceled = ISC_FALSE;
606 lctx->mctx = NULL;
607 isc_mem_attach(mctx, &lctx->mctx);
608 lctx->references = 1; /* Implicit attach. */
609 lctx->magic = DNS_LCTX_MAGIC;
610 *lctxp = lctx;
614 incctx_destroy(mctx, lctx->inc);
616 isc_mem_put(mctx, lctx, sizeof(*lctx));
704 openfile_text(dns_loadctx_t *lctx, const char *master_file) {
705 return (isc_lex_openfile(lctx->lex, master_file));
709 openfile_raw(dns_loadctx_t *lctx, const char *master_file) {
712 result = isc_stdio_open(master_file, "rb", &lctx->f);
723 generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs,
745 ictx = lctx->inc;
746 callbacks = lctx->callbacks;
751 target_mem = isc_mem_get(lctx->mctx, target_size);
752 rhsbuf = isc_mem_get(lctx->mctx, DNS_MASTER_BUFSZ);
753 lhsbuf = isc_mem_get(lctx->mctx, DNS_MASTER_BUFSZ);
793 if (lctx->zclass == dns_rdataclass_in ||
794 lctx->zclass == dns_rdataclass_ch ||
795 lctx->zclass == dns_rdataclass_hs)
824 if ((lctx->options & DNS_MASTER_ZONE) != 0 &&
825 (lctx->options & DNS_MASTER_SLAVE) == 0 &&
826 !dns_name_issubdomain(owner, lctx->top))
844 result = isc_lex_openbuffer(lctx->lex, &buffer);
849 result = dns_rdata_fromtext(&rdata, lctx->zclass, type,
850 lctx->lex, ictx->origin, 0,
851 lctx->mctx, &target, callbacks);
852 RUNTIME_CHECK(isc_lex_close(lctx->lex) == ISC_R_SUCCESS);
858 rdatalist.rdclass = lctx->zclass;
859 rdatalist.ttl = lctx->ttl;
862 result = commit(callbacks, lctx, &head, owner, source, line);
884 isc_mem_put(lctx->mctx, target_mem, target_size);
886 isc_mem_put(lctx->mctx, lhsbuf, DNS_MASTER_BUFSZ);
888 isc_mem_put(lctx->mctx, rhsbuf, DNS_MASTER_BUFSZ);
909 check_ns(dns_loadctx_t *lctx, isc_token_t *token, const char *source,
916 if ((lctx->options & DNS_MASTER_FATALNS) != 0)
917 callback = lctx->callbacks->error;
919 callback = lctx->callbacks->warn;
925 tmp = isc_mem_strdup(lctx->mctx, DNS_AS_STR(*token));
938 (*callback)(lctx->callbacks, "%s:%lu: NS record '%s' "
942 isc_mem_free(lctx->mctx, tmp);
964 load_text(dns_loadctx_t *lctx) {
1014 REQUIRE(DNS_LCTX_VALID(lctx));
1015 callbacks = lctx->callbacks;
1016 mctx = lctx->mctx;
1017 ictx = lctx->inc;
1036 if ((lctx->options & DNS_MASTER_CHECKNAMES) != 0)
1038 if ((lctx->options & DNS_MASTER_CHECKNAMESFAIL) != 0)
1040 if ((lctx->options & DNS_MASTER_CHECKMX) != 0)
1042 if ((lctx->options & DNS_MASTER_CHECKMXFAIL) != 0)
1044 source = isc_lex_getsourcename(lctx->lex);
1047 line = isc_lex_getsourceline(lctx->lex);
1048 GETTOKEN(lctx->lex, ISC_LEXOPT_INITIALWS | ISC_LEXOPT_QSTRING,
1050 line = isc_lex_getsourceline(lctx->lex);
1054 WARNUNEXPECTEDEOF(lctx->lex);
1058 lctx->inc = ictx->parent;
1060 incctx_destroy(lctx->mctx, ictx);
1061 RUNTIME_CHECK(isc_lex_close(lctx->lex) == ISC_R_SUCCESS);
1062 line = isc_lex_getsourceline(lctx->lex);
1063 source = isc_lex_getsourcename(lctx->lex);
1064 ictx = lctx->inc;
1097 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1101 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1104 &lctx->ttl);
1105 if (MANYERRS(lctx, result)) {
1106 SETRESULT(lctx, result);
1107 lctx->ttl = 0;
1110 limit_ttl(callbacks, source, line, &lctx->ttl);
1111 lctx->default_ttl = lctx->ttl;
1112 lctx->default_ttl_known = ISC_TRUE;
1118 if ((lctx->options & DNS_MASTER_NOINCLUDE)
1137 GETTOKEN(lctx->lex, ISC_LEXOPT_QSTRING, &token,
1147 GETTOKEN(lctx->lex, 0, &token, ISC_TRUE);
1152 WARNUNEXPECTEDEOF(lctx->lex);
1153 isc_lex_ungettoken(lctx->lex, &token);
1158 ictx->origin, lctx);
1159 if (MANYERRS(lctx, result)) {
1160 SETRESULT(lctx, result);
1167 ictx = lctx->inc;
1169 isc_lex_getsourcename(lctx->lex);
1170 line = isc_lex_getsourceline(lctx->lex);
1184 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1188 if (MANYERRS(lctx, result)) {
1189 SETRESULT(lctx, result);
1227 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1235 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1244 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1248 GETTOKEN(lctx->lex, 0, &token,
1253 &lctx->ttl)
1256 &lctx->ttl);
1257 lctx->ttl_known = ISC_TRUE;
1259 GETTOKEN(lctx->lex, 0, &token,
1267 GETTOKEN(lctx->lex, 0, &token,
1277 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1283 if (!lctx->ttl_known &&
1284 !lctx->default_ttl_known) {
1289 if (MANYERRS(lctx, result)) {
1290 SETRESULT(lctx, result);
1291 lctx->ttl = 0;
1295 lctx->default_ttl_known) {
1296 lctx->ttl = lctx->default_ttl;
1303 if (rdclass != 0 && rdclass != lctx->zclass) {
1306 result = generate(lctx, range, lhs, gtype, rhs,
1308 if (MANYERRS(lctx, result)) {
1309 SETRESULT(lctx, result);
1322 if (MANYERRS(lctx, result)) {
1323 SETRESULT(lctx, result);
1346 if (MANYERRS(lctx, result)) {
1347 SETRESULT(lctx, result);
1371 result = pushfile(include_file, new_name, lctx);
1372 if (MANYERRS(lctx, result)) {
1373 SETRESULT(lctx, result);
1380 ictx = lctx->inc;
1381 source = isc_lex_getsourcename(lctx->lex);
1382 line = isc_lex_getsourceline(lctx->lex);
1399 result = commit(callbacks, lctx, &glue_list,
1402 if (MANYERRS(lctx, result)) {
1403 SETRESULT(lctx, result);
1435 result = commit(callbacks, lctx,
1440 if (MANYERRS(lctx, result)) {
1441 SETRESULT(lctx, result);
1460 if ((lctx->options & DNS_MASTER_CHECKWILDCARD)
1466 if ((lctx->options & DNS_MASTER_ZONE) != 0 &&
1467 (lctx->options & DNS_MASTER_SLAVE) == 0 &&
1468 !dns_name_issubdomain(new_name, lctx->top))
1489 if (MANYERRS(lctx, result)) {
1490 SETRESULT(lctx, result);
1509 GETTOKEN(lctx->lex, 0, &token, initialws);
1518 WARNUNEXPECTEDEOF(lctx->lex);
1520 isc_lex_ungettoken(lctx->lex, &token);
1529 if (MANYERRS(lctx, result)) {
1530 SETRESULT(lctx, result);
1557 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1560 if (dns_ttl_fromtext(&token.value.as_textregion, &lctx->ttl)
1562 limit_ttl(callbacks, source, line, &lctx->ttl);
1564 lctx->ttl_known = ISC_TRUE;
1565 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1572 if (MANYERRS(lctx, result)) {
1573 SETRESULT(lctx, result);
1584 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1590 if (MANYERRS(lctx, result)) {
1591 SETRESULT(lctx, result);
1606 if (MANYERRS(lctx, result)) {
1607 SETRESULT(lctx, result);
1618 if (rdclass != 0 && rdclass != lctx->zclass) {
1623 dns_rdataclass_format(lctx->zclass, classname2,
1631 if (MANYERRS(lctx, result)) {
1632 SETRESULT(lctx, result);
1646 if ((lctx->options & DNS_MASTER_ZONE) != 0 &&
1647 (lctx->options & DNS_MASTER_SLAVE) == 0 &&
1659 if (MANYERRS(lctx, result)) {
1660 SETRESULT(lctx, result);
1684 lctx->zclass == dns_rdataclass_in &&
1685 (lctx->options & DNS_MASTER_CHECKNS) != 0) {
1687 GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
1688 result = check_ns(lctx, &token, source, line);
1689 isc_lex_ungettoken(lctx->lex, &token);
1690 if ((lctx->options & DNS_MASTER_FATALNS) != 0) {
1691 if (MANYERRS(lctx, result)) {
1692 SETRESULT(lctx, result);
1702 if ((lctx->options & DNS_MASTER_CHECKNAMES) != 0) {
1708 ok = dns_rdata_checkowner(name, lctx->zclass, type,
1716 if ((lctx->options & DNS_MASTER_CHECKNAMESFAIL) != 0) {
1721 if (MANYERRS(lctx, result)) {
1722 SETRESULT(lctx, result);
1744 result = dns_rdata_fromtext(&rdata[rdcount], lctx->zclass,
1745 type, lctx->lex, ictx->origin,
1746 options, lctx->mctx, &target,
1748 if (MANYERRS(lctx, result)) {
1749 SETRESULT(lctx, result);
1760 (lctx->options & DNS_MASTER_ZONE) != 0 &&
1761 dns_name_compare(ictx->current, lctx->top) != 0) {
1769 if (MANYERRS(lctx, result)) {
1770 SETRESULT(lctx, result);
1785 if (!lctx->ttl_known && !lctx->default_ttl_known) {
1791 lctx->ttl = dns_soa_getminimum(&rdata[rdcount]);
1792 limit_ttl(callbacks, source, line, &lctx->ttl);
1793 lctx->default_ttl = lctx->ttl;
1794 lctx->default_ttl_known = ISC_TRUE;
1795 } else if ((lctx->options & DNS_MASTER_HINT) != 0) {
1799 lctx->ttl = 0;
1800 lctx->default_ttl = lctx->ttl;
1801 lctx->default_ttl_known = ISC_TRUE;
1808 if (MANYERRS(lctx, result)) {
1809 SETRESULT(lctx, result);
1810 lctx->ttl = 0;
1815 } else if (!explicit_ttl && lctx->default_ttl_known) {
1816 lctx->ttl = lctx->default_ttl;
1817 } else if (!explicit_ttl && lctx->warn_1035) {
1822 lctx->warn_1035 = ISC_FALSE;
1825 if (type == dns_rdatatype_rrsig && lctx->warn_sigexpired) {
1835 lctx->warn_sigexpired = ISC_FALSE;
1840 lctx->warn_tcr && (lctx->options & DNS_MASTER_ZONE) != 0 &&
1841 (lctx->options & DNS_MASTER_SLAVE) == 0) {
1844 lctx->warn_tcr = ISC_FALSE;
1847 if ((lctx->options & DNS_MASTER_AGETTL) != 0) {
1852 if (lctx->ttl < ttl_offset)
1854 lctx->ttl -= ttl_offset;
1892 this->rdclass = lctx->zclass;
1893 this->ttl = lctx->ttl;
1900 } else if (this->ttl != lctx->ttl) {
1905 lctx->ttl = this->ttl;
1923 } while (!done && (lctx->loop_cnt == 0 || loop_cnt++ < lctx->loop_cnt));
1928 result = commit(callbacks, lctx, ¤t_list, ictx->current,
1930 if (MANYERRS(lctx, result)) {
1931 SETRESULT(lctx, result);
1934 result = commit(callbacks, lctx, &glue_list, ictx->glue,
1936 if (MANYERRS(lctx, result)) {
1937 SETRESULT(lctx, result);
1942 INSIST(lctx->done != NULL && lctx->task != NULL);
1944 } else if (result == ISC_R_SUCCESS && lctx->result != ISC_R_SUCCESS) {
1945 result = lctx->result;
1946 } else if (result == ISC_R_SUCCESS && lctx->seen_include)
1982 pushfile(const char *master_file, dns_name_t *origin, dns_loadctx_t *lctx) {
1990 REQUIRE(DNS_LCTX_VALID(lctx));
1992 ictx = lctx->inc;
1993 lctx->seen_include = ISC_TRUE;
1995 result = incctx_create(lctx->mctx, origin, &new);
2015 result = (lctx->openfile)(lctx, master_file);
2019 lctx->inc = new;
2024 incctx_destroy(lctx->mctx, new);
2048 load_raw(dns_loadctx_t *lctx) {
2058 isc_mem_t *mctx = lctx->mctx;
2066 REQUIRE(DNS_LCTX_VALID(lctx));
2067 callbacks = lctx->callbacks;
2070 if (lctx->first) {
2079 result = isc_stdio_read(&header, 1, hdrlen, lctx->f, NULL);
2107 lctx->first = ISC_FALSE;
2137 (lctx->loop_cnt == 0 || loop_cnt < lctx->loop_cnt);
2150 lctx->f, NULL);
2197 lctx->f, NULL);
2216 sizeof(namelen), lctx->f);
2226 lctx->f);
2264 result = commit(callbacks, lctx, &head, name,
2284 sizeof(rdlen), lctx->f);
2291 rdlen, lctx->f);
2325 result = commit(callbacks, lctx, &head, name, NULL, 0);
2337 INSIST(lctx->done != NULL && lctx->task != NULL);
2339 } else if (result == ISC_R_SUCCESS && lctx->result != ISC_R_SUCCESS)
2340 result = lctx->result;
2383 dns_loadctx_t *lctx = NULL;
2388 &lctx);
2392 result = (lctx->openfile)(lctx, master_file);
2396 result = (lctx->load)(lctx);
2400 dns_loadctx_detach(&lctx);
2439 dns_loadctx_t *lctx = NULL;
2447 &lctx);
2451 result = (lctx->openfile)(lctx, master_file);
2455 result = task_send(lctx);
2457 dns_loadctx_attach(lctx, lctxp);
2462 dns_loadctx_detach(&lctx);
2472 dns_loadctx_t *lctx = NULL;
2478 NULL, &lctx);
2482 result = isc_lex_openstream(lctx->lex, stream);
2486 result = (lctx->load)(lctx);
2490 if (lctx != NULL)
2491 dns_loadctx_detach(&lctx);
2503 dns_loadctx_t *lctx = NULL;
2511 done_arg, NULL, &lctx);
2515 result = isc_lex_openstream(lctx->lex, stream);
2519 result = task_send(lctx);
2521 dns_loadctx_attach(lctx, lctxp);
2526 if (lctx != NULL)
2527 dns_loadctx_detach(&lctx);
2538 dns_loadctx_t *lctx = NULL;
2544 NULL, &lctx);
2548 result = isc_lex_openbuffer(lctx->lex, buffer);
2552 result = (lctx->load)(lctx);
2556 dns_loadctx_detach(&lctx);
2569 dns_loadctx_t *lctx = NULL;
2577 done_arg, NULL, &lctx);
2581 result = isc_lex_openbuffer(lctx->lex, buffer);
2585 result = task_send(lctx);
2587 dns_loadctx_attach(lctx, lctxp);
2592 dns_loadctx_detach(&lctx);
2603 dns_loadctx_t *lctx = NULL;
2609 lex, &lctx);
2613 result = (lctx->load)(lctx);
2616 dns_loadctx_detach(&lctx);
2629 dns_loadctx_t *lctx = NULL;
2637 done_arg, lex, &lctx);
2641 result = task_send(lctx);
2643 dns_loadctx_attach(lctx, lctxp);
2647 dns_loadctx_detach(&lctx);
2793 commit(dns_rdatacallbacks_t *callbacks, dns_loadctx_t *lctx,
2817 (lctx->options & DNS_MASTER_RESIGN) != 0) {
2820 dataset.resign = resign_fromlist(this, lctx->resign);
2839 if (MANYERRS(lctx, result))
2840 SETRESULT(lctx, result);
2887 dns_loadctx_t *lctx;
2890 lctx = event->ev_arg;
2891 REQUIRE(DNS_LCTX_VALID(lctx));
2893 if (lctx->canceled)
2896 result = (lctx->load)(lctx);
2898 event->ev_arg = lctx;
2901 (lctx->done)(lctx->done_arg, result);
2903 dns_loadctx_detach(&lctx);
2908 task_send(dns_loadctx_t *lctx) {
2911 event = isc_event_allocate(lctx->mctx, NULL,
2913 load_quantum, lctx, sizeof(*event));
2916 isc_task_send(lctx->task, &event);
2921 dns_loadctx_cancel(dns_loadctx_t *lctx) {
2922 REQUIRE(DNS_LCTX_VALID(lctx));
2924 LOCK(&lctx->lock);
2925 lctx->canceled = ISC_TRUE;
2926 UNLOCK(&lctx->lock);