5 ;;; DNS zone generation
7 ;;; (c) 2005 Straylight/Edgeware
10 ;;;----- Licensing notice ---------------------------------------------------
12 ;;; This program is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
17 ;;; This program is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with this program; if not, write to the Free Software Foundation,
24 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ;;;--------------------------------------------------------------------------
31 #:mdw.base #:mdw.str #:collect #:safely
33 (:export #:soa #:mx #:zone #:zone-record #:zone-subdomain
34 #:*default-zone-source* #:*default-zone-refresh*
35 #:*default-zone-retry* #:*default-zone-expire*
36 #:*default-zone-min-ttl* #:*default-zone-ttl*
37 #:*default-mx-priority* #:*default-zone-admin*
39 #:*preferred-subnets* #:zone-preferred-subnet-p
40 #:preferred-subnet-case
41 #:zone-find #:zone-parse #:zone-write #:zone-create #:defzone
42 #:defrevzone #:zone-save #:zone-make-name
43 #:defzoneparse #:zone-parse-host
44 #:bind-hostname #:bind-record #:bind-format-record
45 #:bind-record-type #:bind-record-format-args
46 #:timespec-seconds #:make-zone-serial))
50 ;;;--------------------------------------------------------------------------
51 ;;; Various random utilities.
54 "Convert X to an integer in the most straightforward way."
57 (defun from-mixed-base (base val)
58 "BASE is a list of the ranges for the `digits' of a mixed-base
59 representation. Convert VAL, a list of digits, into an integer."
60 (do ((base base (cdr base))
61 (val (cdr val) (cdr val))
62 (a (car val) (+ (* a (car base)) (car val))))
63 ((or (null base) (null val)) a)))
65 (defun to-mixed-base (base val)
66 "BASE is a list of the ranges for the `digits' of a mixed-base
67 representation. Convert VAL, an integer, into a list of digits."
68 (let ((base (reverse base))
74 (multiple-value-bind (q r) (floor val (pop base))
78 (defun timespec-seconds (ts)
79 "Convert a timespec TS to seconds. A timespec may be a real count of
80 seconds, or a list (COUNT UNIT): UNIT may be any of a number of obvious
83 ((realp ts) (floor ts))
85 (error "Unknown timespec format ~A" ts))
87 (timespec-seconds (car ts)))
88 (t (+ (to-integer (* (car ts)
89 (case (intern (string-upcase
90 (stringify (cadr ts)))
92 ((s sec secs second seconds) 1)
93 ((m min mins minute minutes) 60)
94 ((h hr hrs hour hours) #.(* 60 60))
95 ((d dy dys day days) #.(* 24 60 60))
96 ((w wk wks week weeks) #.(* 7 24 60 60))
97 ((y yr yrs year years) #.(* 365 24 60 60))
98 (t (error "Unknown time unit ~A"
100 (timespec-seconds (cddr ts))))))
102 (defun hash-table-keys (ht)
103 "Return a list of the keys in hashtable HT."
105 (maphash (lambda (key val) (declare (ignore val)) (collect key)) ht)))
107 (defun iso-date (&optional time &key datep timep (sep #\ ))
108 "Construct a textual date or time in ISO format. The TIME is the universal
109 time to convert, which defaults to now; DATEP is whether to emit the date;
110 TIMEP is whether to emit the time, and SEP (default is space) is how to
113 (sec min hr day mon yr dow dstp tz)
114 (decode-universal-time (if (or (null time) (eq time :now))
117 (declare (ignore dow dstp tz))
118 (with-output-to-string (s)
120 (format s "~4,'0D-~2,'0D-~2,'0D" yr mon day)
124 (format s "~2,'0D:~2,'0D:~2,'0D" hr min sec)))))
126 ;;;--------------------------------------------------------------------------
129 (defstruct (soa (:predicate soap))
130 "Start-of-authority record information."
139 (defstruct (mx (:predicate mxp))
140 "Mail-exchange record information."
144 (defstruct (zone (:predicate zonep))
151 ;;;--------------------------------------------------------------------------
152 ;;; Zone defaults. It is intended that scripts override these.
155 (cffi:defcfun gethostname :int
159 (defvar *default-zone-source*
160 (let ((hn #+cmu (unix:unix-gethostname)
161 #+clisp (unix:get-host-name)
162 #+ecl (cffi:with-foreign-pointer-as-string (buffer 256 len)
163 (let ((rc (gethostname buffer len)))
165 (error "gethostname(2) failed (rc = ~A)." rc))))))
166 (and hn (concatenate 'string (canonify-hostname hn) ".")))
167 "The default zone source: the current host's name.")
169 (defvar *default-zone-refresh* (* 24 60 60)
170 "Default zone refresh interval: one day.")
172 (defvar *default-zone-admin* nil
173 "Default zone administrator's email address.")
175 (defvar *default-zone-retry* (* 60 60)
176 "Default znoe retry interval: one hour.")
178 (defvar *default-zone-expire* (* 14 24 60 60)
179 "Default zone expiry time: two weeks.")
181 (defvar *default-zone-min-ttl* (* 4 60 60)
182 "Default zone minimum TTL/negative TTL: four hours.")
184 (defvar *default-zone-ttl* (* 8 60 60)
185 "Default zone TTL (for records without explicit TTLs): 8 hours.")
187 (defvar *default-mx-priority* 50
188 "Default MX priority.")
190 ;;;--------------------------------------------------------------------------
191 ;;; Zone variables and structures.
193 (defvar *zones* (make-hash-table :test #'equal)
194 "Map of known zones.")
196 (defun zone-find (name)
197 "Find a zone given its NAME."
198 (gethash (string-downcase (stringify name)) *zones*))
200 (defun (setf zone-find) (zone name)
201 "Make the zone NAME map to ZONE."
202 (setf (gethash (string-downcase (stringify name)) *zones*) zone))
204 (defstruct (zone-record (:conc-name zr-))
212 (defstruct (zone-subdomain (:conc-name zs-))
213 "A subdomain. Slightly weird. Used internally by zone-process-records
214 below, and shouldn't escape."
219 (defvar *zone-output-path* *default-pathname-defaults*
220 "Pathname defaults to merge into output files.")
222 (defvar *preferred-subnets* nil
223 "Subnets to prefer when selecting defaults.")
225 ;;;--------------------------------------------------------------------------
226 ;;; Zone infrastructure.
228 (defun zone-file-name (zone type)
229 "Choose a file name for a given ZONE and TYPE."
230 (merge-pathnames (make-pathname :name (string-downcase zone)
231 :type (string-downcase type))
234 (defun zone-preferred-subnet-p (name)
235 "Answer whether NAME (a string or symbol) names a preferred subnet."
236 (member name *preferred-subnets* :test #'string-equal))
238 (defmacro preferred-subnet-case (&body clauses)
239 "CLAUSES have the form (SUBNETS . FORMS) -- evaluate the first FORMS whose
240 SUBNETS (a list or single symbol, not evaluated) are considered preferred
241 by zone-preferred-subnet-p. If SUBNETS is the symbol t then the clause
244 ,@(mapcar (lambda (clause)
245 (let ((subnets (car clause)))
246 (cons (cond ((eq subnets t)
249 `(or ,@(mapcar (lambda (subnet)
250 `(zone-preferred-subnet-p
254 `(zone-preferred-subnet-p ',subnets)))
258 (defun zone-process-records (rec ttl func)
259 "Sort out the list of records in REC, calling FUNC for each one. TTL is
260 the default time-to-live for records which don't specify one."
261 (labels ((sift (rec ttl)
262 (collecting (top sub)
268 (setf ttl (pop rec)))
270 (collect (make-zone-record :type r
275 (dolist (name (listify (car r)))
276 (collect (make-zone-subdomain :name name
281 (error "Unexpected record form ~A" (car r))))))))
282 (process (rec dom ttl)
283 (multiple-value-bind (top sub) (sift rec ttl)
284 (if (and dom (null top) sub)
285 (let ((preferred nil))
287 (when (some #'zone-preferred-subnet-p
288 (listify (zs-name s)))
291 (setf preferred (car sub)))
293 (process (zs-records preferred)
295 (zs-ttl preferred))))
298 (join-strings #\. (reverse dom))))))
300 (setf (zr-name zr) name)
303 (process (zs-records s)
304 (cons (zs-name s) dom)
306 (process rec nil ttl)))
308 (defun zone-parse-host (f zname)
309 "Parse a host name F: if F ends in a dot then it's considered absolute;
310 otherwise it's relative to ZNAME."
311 (setf f (stringify f))
312 (cond ((string= f "@") (stringify zname))
313 ((and (plusp (length f))
314 (char= (char f (1- (length f))) #\.))
315 (string-downcase (subseq f 0 (1- (length f)))))
316 (t (string-downcase (concatenate 'string f "."
317 (stringify zname))))))
318 (defun default-rev-zone (base bytes)
319 "Return the default reverse-zone name for the given BASE address and number
320 of fixed leading BYTES."
321 (join-strings #\. (collecting ()
322 (loop for i from (- 3 bytes) downto 0
323 do (collect (ipaddr-byte base i)))
324 (collect "in-addr.arpa"))))
326 (defun zone-name-from-net (net &optional bytes)
327 "Given a NET, and maybe the BYTES to use, convert to the appropriate
328 subdomain of in-addr.arpa."
329 (let ((ipn (net-get-as-ipnet net)))
330 (with-ipnet (net mask) ipn
332 (setf bytes (- 4 (ipnet-changeable-bytes mask))))
335 for i from (- 4 bytes) below 4
336 collect (logand #xff (ash net (* -8 i))))
337 (list "in-addr.arpa"))))))
339 (defun zone-net-from-name (name)
340 "Given a NAME in the in-addr.arpa space, convert it to an ipnet."
341 (let* ((name (string-downcase (stringify name)))
343 (suffix ".in-addr.arpa")
344 (sufflen (length suffix))
347 (end (- len sufflen)))
348 (unless (and (> len sufflen)
349 (string= name suffix :start1 end))
350 (error "`~A' not in ~A." name suffix))
353 for dot = (position #\. name :start start :end end)
354 for byte = (parse-integer name
357 do (setf addr (logior addr (ash byte (* 8 n))))
360 do (error "Can't deduce network from ~A." name)
362 do (setf start (1+ dot)))
363 (setf addr (ash addr (* 8 (- 4 n))))
364 (make-ipnet addr (* 8 n))))
366 (defun zone-parse-net (net name)
367 "Given a NET, and the NAME of a domain to guess from if NET is null, return
368 the ipnet for the network."
370 (net-get-as-ipnet net)
371 (zone-net-from-name name)))
373 (defun zone-cidr-delg-default-name (ipn bytes)
374 "Given a delegated net IPN and the parent's number of changing BYTES,
375 return the default deletate zone prefix."
376 (with-ipnet (net mask) ipn
380 for i from (1- bytes) downto 0
381 until (zerop (logand mask (ash #xff (* 8 i))))
382 collect (logand #xff (ash net (* -8 i))))))))
384 ;;;--------------------------------------------------------------------------
385 ;;; Serial numbering.
387 (defun make-zone-serial (name)
388 "Given a zone NAME, come up with a new serial number. This will (very
389 carefully) update a file ZONE.serial in the current directory."
390 (let* ((file (zone-file-name name :serial))
391 (last (with-open-file (in file
393 :if-does-not-exist nil)
396 (now (multiple-value-bind
397 (sec min hr dy mon yr dow dstp tz)
399 (declare (ignore sec min hr dow dstp tz))
401 (seq (cond ((not (equal now (cdr last))) 0)
402 ((< (car last) 99) (1+ (car last)))
403 (t (error "Run out of sequence numbers for ~A" name)))))
404 (safely-writing (out file)
406 ";; Serial number file for zone ~A~%~
407 ;; (LAST-SEQ DAY MONTH YEAR)~%~
411 (from-mixed-base '(100 100 100) (reverse (cons seq now)))))
413 ;;;--------------------------------------------------------------------------
414 ;;; Zone form parsing.
416 (defun zone-parse-head (head)
417 "Parse the HEAD of a zone form. This has the form
419 (NAME &key :source :admin :refresh :retry
420 :expire :min-ttl :ttl :serial)
422 though a singleton NAME needn't be a list. Returns the default TTL and an
423 soa structure representing the zone head."
427 (source *default-zone-source*)
428 (admin (or *default-zone-admin*
429 (format nil "hostmaster@~A" zname)))
430 (refresh *default-zone-refresh*)
431 (retry *default-zone-retry*)
432 (expire *default-zone-expire*)
433 (min-ttl *default-zone-min-ttl*)
435 (serial (make-zone-serial zname)))
438 (timespec-seconds ttl)
439 (make-soa :admin admin
440 :source (zone-parse-host source zname)
441 :refresh (timespec-seconds refresh)
442 :retry (timespec-seconds retry)
443 :expire (timespec-seconds expire)
444 :min-ttl (timespec-seconds min-ttl)
447 (defun zone-make-name (prefix zone-name)
448 (if (or (not prefix) (string= prefix "@"))
450 (let ((len (length prefix)))
451 (if (or (zerop len) (char/= (char prefix (1- len)) #\.))
452 (join-strings #\. (list prefix zone-name))
455 (defmacro defzoneparse (types (name data list
456 &key (prefix (gensym "PREFIX"))
457 (zname (gensym "ZNAME"))
458 (ttl (gensym "TTL")))
460 "Define a new zone record type (or TYPES -- a list of synonyms is
461 permitted). The arguments are as follows:
463 NAME The name of the record to be added.
465 DATA The content of the record to be added (a single object,
468 LIST A function to add a record to the zone. See below.
470 PREFIX The prefix tag used in the original form.
472 ZNAME The name of the zone being constructed.
474 TTL The TTL for this record.
476 You get to choose your own names for these. ZNAME, PREFIX and TTL are
477 optional: you don't have to accept them if you're not interested.
479 The LIST argument names a function to be bound in the body to add a new
480 low-level record to the zone. It has the prototype
482 (LIST &key :name :type :data :ttl :make-ptr-p)
484 These (except MAKE-PTR-P, which defaults to nil) default to the above
485 arguments (even if you didn't accept the arguments)."
486 (setf types (listify types))
487 (let* ((type (car types))
488 (func (intern (format nil "ZONE-PARSE/~:@(~A~)" type))))
489 (with-parsed-body (body decls doc) body
490 (with-gensyms (col tname ttype tttl tdata tmakeptrp i)
493 (setf (get ,i 'zone-parse) ',func))
494 (defun ,func (,prefix ,zname ,data ,ttl ,col)
497 (let ((,name (zone-make-name ,prefix ,zname)))
498 (flet ((,list (&key ((:name ,tname) ,name)
499 ((:type ,ttype) ,type)
500 ((:data ,tdata) ,data)
502 ((:make-ptr-p ,tmakeptrp) nil))
503 #+cmu (declare (optimize ext:inhibit-warnings))
504 (collect (make-zone-record :name ,tname
508 :make-ptr-p ,tmakeptrp)
513 (defun zone-parse-records (zone records)
514 (let ((zname (zone-name zone)))
515 (with-collection (rec)
516 (flet ((parse-record (zr)
517 (let ((func (or (get (zr-type zr) 'zone-parse)
518 (error "No parser for record ~A."
520 (name (and (zr-name zr) (stringify (zr-name zr)))))
527 (zone-process-records records
528 (zone-default-ttl zone)
530 (setf (zone-records zone) (nconc (zone-records zone) rec)))))
532 (defun zone-parse (zf)
533 "Parse a ZONE form. The syntax of a zone form is as follows:
536 ZONE-HEAD ZONE-RECORD*
539 ((NAME*) ZONE-RECORD*)
541 (multiple-value-bind (zname ttl soa) (zone-parse-head (car zf))
542 (let ((zone (make-zone :name zname
546 (zone-parse-records zone (cdr zf))
549 (defun zone-create (zf)
550 "Zone construction function. Given a zone form ZF, construct the zone and
551 add it to the table."
552 (let* ((zone (zone-parse zf))
553 (name (zone-name zone)))
554 (setf (zone-find name) zone)
557 (defmacro defzone (soa &rest zf)
558 "Zone definition macro."
559 `(zone-create '(,soa ,@zf)))
561 (defmacro defrevzone (head &rest zf)
562 "Define a reverse zone, with the correct name."
567 (when (and soa-args (integerp (car soa-args)))
568 (setf bytes (pop soa-args)))
569 `(zone-create '((,(zone-name-from-net net bytes) ,@soa-args) ,@zf)))))
571 ;;;--------------------------------------------------------------------------
572 ;;; Zone record parsers.
574 (defzoneparse :a (name data rec)
576 (rec :data (parse-ipaddr data) :make-ptr-p t))
578 (defzoneparse :svc (name data rec)
580 (rec :type :a :data (parse-ipaddr data)))
582 (defzoneparse :ptr (name data rec :zname zname)
584 (rec :data (zone-parse-host data zname)))
586 (defzoneparse :cname (name data rec :zname zname)
588 (rec :data (zone-parse-host data zname)))
590 (defzoneparse :mx (name data rec :zname zname)
591 ":mx ((HOST :prio INT :ip IPADDR)*)"
592 (dolist (mx (listify data))
594 (mxname &key (prio *default-mx-priority*) ip)
596 (let ((host (zone-parse-host mxname zname)))
597 (when ip (rec :name host :type :a :data (parse-ipaddr ip)))
598 (rec :data (cons host prio))))))
600 (defzoneparse :ns (name data rec :zname zname)
601 ":ns ((HOST :ip IPADDR)*)"
602 (dolist (ns (listify data))
606 (let ((host (zone-parse-host nsname zname)))
607 (when ip (rec :name host :type :a :data (parse-ipaddr ip)))
610 (defzoneparse :alias (name data rec :zname zname)
612 (dolist (a (listify data))
613 (rec :name (zone-parse-host a zname)
617 (defzoneparse :srv (name data rec :zname zname)
618 ":srv (((SERVICE &key :port) (PROVIDER &key :port :prio :weight :ip)*)*)"
620 (destructuring-bind (servopts &rest providers) srv
622 (service &key ((:port default-port)) (protocol :tcp))
625 (let ((serv (serv-by-name service protocol)))
626 (setf default-port (and serv (serv-port serv)))))
627 (let ((rname (format nil "~(_~A._~A~).~A" service protocol name)))
628 (dolist (prov providers)
633 (prio *default-mx-priority*)
637 (let ((host (zone-parse-host srvname zname)))
638 (when ip (rec :name host :type :a :data (parse-ipaddr ip)))
640 :data (list prio weight port host))))))))))
642 (defzoneparse :net (name data rec)
644 (dolist (net (listify data))
645 (let ((n (net-get-as-ipnet net)))
646 (rec :name (zone-parse-host "net" name)
649 (rec :name (zone-parse-host "mask" name)
651 :data (ipnet-mask n))
652 (rec :name (zone-parse-host "broadcast" name)
654 :data (ipnet-broadcast n)))))
656 (defzoneparse (:rev :reverse) (name data rec)
657 ":reverse ((NET :bytes BYTES) ZONE*)"
658 (setf data (listify data))
659 (destructuring-bind (net &key bytes) (listify (car data))
660 (setf net (zone-parse-net net name))
662 (setf bytes (ipnet-changeable-bytes (ipnet-mask net))))
663 (let ((seen (make-hash-table :test #'equal)))
664 (dolist (z (or (cdr data)
665 (hash-table-keys *zones*)))
666 (dolist (zr (zone-records (zone-find z)))
667 (when (and (eq (zr-type zr) :a)
669 (ipaddr-networkp (zr-data zr) net))
670 (let ((name (string-downcase
675 (collect (logand #xff (ash (zr-data zr)
678 (unless (gethash name seen)
679 (rec :name name :type :ptr
680 :ttl (zr-ttl zr) :data (zr-name zr))
681 (setf (gethash name seen) t)))))))))
683 (defzoneparse (:cidr-delegation :cidr) (name data rec :zname zname)
684 ":cidr-delegation ((NET :bytes BYTES) (TARGET-NET [TARGET-ZONE])*)"
685 (setf data (listify data))
686 (destructuring-bind (net &key bytes) (listify (car data))
687 (setf net (zone-parse-net net name))
689 (setf bytes (ipnet-changeable-bytes (ipnet-mask net))))
690 (dolist (map (or (cdr data) (list (list net))))
691 (destructuring-bind (tnet &optional tdom) (listify map)
692 (setf tnet (zone-parse-net tnet name))
693 (unless (ipnet-subnetp net tnet)
694 (error "~A is not a subnet of ~A."
698 (with-ipnet (net mask) tnet
702 (append (reverse (loop
703 for i from (1- bytes) downto 0
704 until (zerop (logand mask
707 collect (ldb (byte 8 (* i 8)) net)))
709 (setf tdom (string-downcase (stringify tdom)))
710 (dotimes (i (ipnet-hosts tnet))
712 (let* ((addr (ipnet-host tnet i))
713 (tail (join-strings #\.
715 for i from 0 below bytes
718 (ash addr (* 8 i)))))))
719 (rec :name (format nil "~A.~A" tail name)
721 :data (format nil "~A.~A" tail tdom)))))))))
723 ;;;--------------------------------------------------------------------------
724 ;;; Zone file output.
726 (defgeneric zone-write (format zone stream)
727 (:documentation "Write ZONE's records to STREAM in the specified FORMAT."))
729 (defvar *writing-zone* nil
730 "The zone currently being written.")
732 (defvar *zone-output-stream* nil
733 "Stream to write zone data on.")
735 (defmethod zone-write :around (format zone stream)
736 (let ((*writing-zone* zone)
737 (*zone-output-stream* stream))
740 (defun zone-save (zones &key (format :bind))
741 "Write the named ZONES to files. If no zones are given, write all the
744 (setf zones (hash-table-keys *zones*)))
747 (let ((zz (zone-find z)))
749 (error "Unknown zone `~A'." z))
750 (let ((stream (safely-open-output-stream safe
751 (zone-file-name z :zone))))
752 (zone-write format zz stream))))))
754 ;;;--------------------------------------------------------------------------
755 ;;; Bind format output.
757 (defun bind-hostname (hostname)
760 (let* ((h (string-downcase (stringify hostname)))
762 (r (string-downcase (zone-name *writing-zone*)))
764 (cond ((string= r h) "@")
766 (char= (char h (- hl rl 1)) #\.)
767 (string= h r :start1 (- hl rl)))
768 (subseq h 0 (- hl rl 1)))
769 (t (concatenate 'string h "."))))))
771 (defmethod zone-write ((format (eql :bind)) zone stream)
773 ;;; Zone file `~(~A~)'
779 (iso-date :now :datep t :timep t)
780 (zone-default-ttl zone))
781 (let* ((soa (zone-soa zone))
782 (admin (let* ((name (soa-admin soa))
783 (at (position #\@ name))
784 (copy (format nil "~(~A~)." name)))
786 (setf (char copy at) #\.))
789 ~A~30TIN SOA~40T~A ~A (
791 ~45T~10D~60T ;refresh
794 ~45T~10D )~60T ;min-ttl~2%"
795 (bind-hostname (zone-name zone))
796 (bind-hostname (soa-source soa))
803 (dolist (zr (zone-records zone))
804 (bind-record (zr-type zr) zr)))
806 (defgeneric bind-record (type zr))
808 (defun bind-format-record (name ttl type format args)
809 (format *zone-output-stream*
810 "~A~20T~@[~8D~]~30TIN ~A~40T~?~%"
812 (and (/= ttl (zone-default-ttl *writing-zone*))
814 (string-upcase (symbol-name type))
817 (defmethod bind-record (type zr)
818 (destructuring-bind (format &rest args)
819 (bind-record-format-args type (zr-data zr))
820 (bind-format-record (zr-name zr)
822 (bind-record-type type)
825 (defgeneric bind-record-type (type)
826 (:method (type) type))
828 (defgeneric bind-record-format-args (type data)
829 (:method ((type (eql :a)) data) (list "~A" (ipaddr-string data)))
830 (:method ((type (eql :ptr)) data) (list "~A" (bind-hostname data)))
831 (:method ((type (eql :cname)) data) (list "~A" (bind-hostname data)))
832 (:method ((type (eql :ns)) data) (list "~A" (bind-hostname data)))
833 (:method ((type (eql :mx)) data)
834 (list "~2D ~A" (cdr data) (bind-hostname (car data))))
835 (:method ((type (eql :srv)) data)
836 (destructuring-bind (prio weight port host) data
837 (list "~2D ~5D ~5D ~A" prio weight port (bind-hostname host))))
838 (:method ((type (eql :txt)) data) (list "~S" (stringify data))))
840 ;;;----- That's all, folks --------------------------------------------------