<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
-<!-- File: $Id: Bv9ARM-book.xml,v 1.221 2003/03/10 18:30:36 marka Exp $ -->
+<!-- File: $Id: Bv9ARM-book.xml,v 1.222 2003/04/17 11:31:01 marka Exp $ -->
<book>
<title>BIND 9 Administrator Reference Manual</title>
with undefined TTLs. Valid TTLs are of the range 0-2147483647 seconds.</para>
<para><command>$TTL</command> is defined in RFC 2308.</para></sect3></sect2>
<sect2><title><acronym>BIND</acronym> Master File Extension: the <command>$GENERATE</command> Directive</title>
- <para>Syntax: <command>$GENERATE</command> <replaceable>range</replaceable> <replaceable>lhs</replaceable> <replaceable>type</replaceable> <replaceable>rhs</replaceable> <optional> <replaceable>comment</replaceable> </optional></para>
+ <para>Syntax: <command>$GENERATE</command> <replaceable>range</replaceable> <replaceable>lhs</replaceable> <optional><replaceable>ttl</replaceable></optional> <optional><replaceable>class</replaceable></optional> <replaceable>type</replaceable> <replaceable>rhs</replaceable> <optional> <replaceable>comment</replaceable> </optional></para>
<para><command>$GENERATE</command> is used to create a series of
resource records that only differ from each other by an iterator. <command>$GENERATE</command> can
be used to easily generate the sets of records required to support
<para>For compatibility with earlier versions <command>$$</command> is still
recognised a indicating a literal $ in the output.</para></entry>
</row>
+ <row rowsep = "0">
+ <entry colname = "1"><para><command>ttl</command></para></entry>
+ <entry colname = "2"><para><command>ttl</command> specifies the
+ ttl of the generated records. If not specified this will be
+ inherited using the normal ttl inhertance rules.</para>
+ <para><command>class</command> and <command>ttl</command> can be
+ entered in either order.</para></entry>
+ </row>
+ <row rowsep = "0">
+ <entry colname = "1"><para><command>class</command></para></entry>
+ <entry colname = "2"><para><command>class</command> specifies the
+ class of the generated records. This must match the zone class if
+ it is specified.</para>
+ <para><command>class</command> and <command>ttl</command> can be
+ entered in either order.</para></entry>
+ </row>
<row rowsep = "0">
<entry colname = "1"><para><command>type</command></para></entry>
<entry colname = "2"><para>At present the only supported types are
</tgroup></informaltable>
<para>The <command>$GENERATE</command> directive is a <acronym>BIND</acronym> extension
and not part of the standard zone file format.</para>
+ <para>BIND 8 does not support the optional TTL and CLASS fields.</para>
</sect2>
</sect1>
</chapter>
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: master.c,v 1.144 2003/04/17 05:40:45 marka Exp $ */
+/* $Id: master.c,v 1.145 2003/04/17 11:31:02 marka Exp $ */
#include <config.h>
unsigned long line = 0;
isc_boolean_t explicit_ttl;
isc_stdtime_t now;
+ char classname1[DNS_RDATACLASS_FORMATSIZE];
+ char classname2[DNS_RDATACLASS_FORMATSIZE];
REQUIRE(DNS_LCTX_VALID(lctx));
callbacks = lctx->callbacks;
continue;
} else if (strcasecmp(DNS_AS_STR(token),
"$GENERATE") == 0) {
- /*
- * Use default ttl if known otherwise
- * inherit or error.
- */
- if (!lctx->ttl_known &&
- !lctx->default_ttl_known) {
- (*callbacks->error)(callbacks,
- "%s: %s:%lu: no TTL specified",
- "dns_master_load", source, line);
- result = DNS_R_NOTTL;
- if (MANYERRS(lctx, result)) {
- SETRESULT(lctx, result);
- lctx->ttl = 0;
- } else if (result != ISC_R_SUCCESS)
- goto insist_and_cleanup;
- } else if (lctx->default_ttl_known) {
- lctx->ttl = lctx->default_ttl;
- }
/*
* Lazy cleanup.
*/
isc_mem_free(mctx, gtype);
if (rhs != NULL)
isc_mem_free(mctx, rhs);
- /* range */
+ /* RANGE */
GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
range = isc_mem_strdup(mctx,
DNS_AS_STR(token));
result = ISC_R_NOMEMORY;
goto log_and_cleanup;
}
- /* TYPE */
+ rdclass = 0;
+ explicit_ttl = ISC_FALSE;
+ /* CLASS? */
GETTOKEN(lctx->lex, 0, &token, ISC_FALSE);
+ if (dns_rdataclass_fromtext(&rdclass,
+ &token.value.as_textregion)
+ == ISC_R_SUCCESS) {
+ GETTOKEN(lctx->lex, 0, &token,
+ ISC_FALSE);
+ }
+ /* TTL? */
+ if (dns_ttl_fromtext(&token.value.as_textregion,
+ &lctx->ttl)
+ == ISC_R_SUCCESS) {
+ limit_ttl(callbacks, source, line,
+ &lctx->ttl);
+ lctx->ttl_known = ISC_TRUE;
+ explicit_ttl = ISC_TRUE;
+ GETTOKEN(lctx->lex, 0, &token,
+ ISC_FALSE);
+ }
+ /* CLASS? */
+ if (rdclass == 0 &&
+ dns_rdataclass_fromtext(&rdclass,
+ &token.value.as_textregion)
+ == ISC_R_SUCCESS)
+ GETTOKEN(lctx->lex, 0, &token,
+ ISC_FALSE);
+ /* TYPE */
gtype = isc_mem_strdup(mctx,
DNS_AS_STR(token));
if (gtype == NULL) {
result = ISC_R_NOMEMORY;
goto log_and_cleanup;
}
+ if (!lctx->ttl_known &&
+ !lctx->default_ttl_known) {
+ (*callbacks->error)(callbacks,
+ "%s: %s:%lu: no TTL specified",
+ "dns_master_load", source, line);
+ result = DNS_R_NOTTL;
+ if (MANYERRS(lctx, result)) {
+ SETRESULT(lctx, result);
+ lctx->ttl = 0;
+ } else if (result != ISC_R_SUCCESS)
+ goto insist_and_cleanup;
+ } else if (!explicit_ttl &&
+ lctx->default_ttl_known) {
+ lctx->ttl = lctx->default_ttl;
+ }
+ /*
+ * If the class specified does not match the
+ * zone's class print out a error message and
+ * exit.
+ */
+ if (rdclass != 0 && rdclass != lctx->zclass) {
+ goto bad_class;
+ }
result = generate(lctx, range, lhs, gtype, rhs,
source, line);
if (MANYERRS(lctx, result)) {
* print out a error message and exit.
*/
if (rdclass != 0 && rdclass != lctx->zclass) {
- char classname1[DNS_RDATACLASS_FORMATSIZE];
- char classname2[DNS_RDATACLASS_FORMATSIZE];
+ bad_class:
dns_rdataclass_format(rdclass, classname1,
sizeof(classname1));