zone: New record type :svc creates A records without PTR records.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 15 Jun 2007 14:15:27 +0000 (15:15 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 15 Jun 2007 14:15:27 +0000 (15:15 +0100)
The :svc record type inserts an A record into the zone without inserting
a matching PTR record into the reverse zone(s).  This is useful for
service role addresses.

To make this work, we add a new slot make-ptr-p to zone records which is
used to label those A records which are eligible to be turned into
PTRs.  This mechanism is, I hope, considerably simpler than the old
defsubp system.

zone.lisp

index 0ea9360..74ecf58 100644 (file)
--- a/zone.lisp
+++ b/zone.lisp
   (name '<unnamed>)
   ttl
   type
+  (make-ptr-p nil)
   data)
 
 (defstruct (zone-subdomain (:conc-name zs-))
    The LIST argument names a function to be bound in the body to add a new
    low-level record to the zone.  It has the prototype
 
-     (LIST &key :name :type :data :ttl)
+     (LIST &key :name :type :data :ttl :make-ptr-p)
 
-   These default to the above arguments (even if you didn't accept the
-   arguments)."
+   These (except MAKE-PTR-P, which defaults to nil) default to the above
+   arguments (even if you didn't accept the arguments)."
   (setf types (listify types))
   (let* ((type (car types))
         (func (intern (format nil "ZONE-PARSE/~:@(~A~)" type))))
     (with-parsed-body (body decls doc) body
-      (with-gensyms (col tname ttype tttl tdata i)
+      (with-gensyms (col tname ttype tttl tdata tmakeptrp i)
        `(progn
           (dolist (,i ',types)
             (setf (get ,i 'zone-parse) ',func))
               (flet ((,list (&key ((:name ,tname) ,name)
                                   ((:type ,ttype) ,type)
                                   ((:data ,tdata) ,data)
-                                  ((:ttl ,tttl) ,ttl))
+                                  ((:ttl ,tttl) ,ttl)
+                                  ((:make-ptr-p ,tmakeptrp) nil))
                        (collect (make-zone-record :name ,tname
                                                   :type ,ttype
                                                   :data ,tdata
-                                                  :ttl ,tttl)
+                                                  :ttl ,tttl
+                                                  :make-ptr-p ,tmakeptrp)
                                 ,col)))
                 ,@body)))
          ',type)))))
 
 (defzoneparse :a (name data rec)
   ":a IPADDR"
-  (rec :data (parse-ipaddr data)))
+  (rec :data (parse-ipaddr data) :make-ptr-p t))
+
+(defzoneparse :svc (name data rec)
+  ":svc IPADDR"
+  (rec :type :a :data (parse-ipaddr data)))
 
 (defzoneparse :ptr (name data rec :zname zname)
   ":ptr HOST"
                     (hash-table-keys *zones*)))
        (dolist (zr (zone-records (zone-find z)))
          (when (and (eq (zr-type zr) :a)
+                    (zr-make-ptr-p zr)
                     (ipaddr-networkp (zr-data zr) net))
            (let ((name (string-downcase
                         (join-strings