]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1467. [func] $GENERATES now supports optional class and ttl.
authorMark Andrews <marka@isc.org>
Thu, 17 Apr 2003 11:31:02 +0000 (11:31 +0000)
committerMark Andrews <marka@isc.org>
Thu, 17 Apr 2003 11:31:02 +0000 (11:31 +0000)
CHANGES
doc/arm/Bv9ARM-book.xml
lib/dns/master.c

diff --git a/CHANGES b/CHANGES
index c4c09bae9f137851f5fb447d73b8509909fd9e9b..e0e6a7fe41abea6c9029254a0aa2438044abd20c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+1467.  [func]          $GENERATES now supports optional class and ttl.
+                       
 1466.  [bug]           lwresd configuration errors resulted in memory
                        and lock leaks.  [RT #5228]
                        
index f0d13f63263eb622f378dfa07f69a0f53dc2c096..f43713f8d02074e1d1cbf1c8d0317721edd2728b 100644 (file)
@@ -2,7 +2,7 @@
 <!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>
@@ -5440,7 +5440,7 @@ This could be construed as a deviation from RFC 1035, a feature, or both.
 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
@@ -5491,6 +5491,22 @@ the name.</para>
 <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
@@ -5505,6 +5521,7 @@ similarly to lhs.</para></entry>
       </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>
index a1541a72200998779c443ef474b1ed8c8bbdc16e..7e291be95d190d13acf44eeac36ced0caf34a698 100644 (file)
@@ -15,7 +15,7 @@
  * 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>
 
@@ -869,6 +869,8 @@ load(dns_loadctx_t *lctx) {
        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;
@@ -1059,24 +1061,6 @@ load(dns_loadctx_t *lctx) {
                                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.
                                 */
@@ -1088,7 +1072,7 @@ load(dns_loadctx_t *lctx) {
                                        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));
@@ -1103,8 +1087,35 @@ load(dns_loadctx_t *lctx) {
                                        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) {
@@ -1118,6 +1129,29 @@ load(dns_loadctx_t *lctx) {
                                        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)) {
@@ -1405,8 +1439,7 @@ load(dns_loadctx_t *lctx) {
                 * 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));