- (process rec nil ttl)))
-
-(export 'zone-parse-host)
-(defun zone-parse-host (f zname)
- "Parse a host name F: if F ends in a dot then it's considered absolute;
- otherwise it's relative to ZNAME."
- (setf f (stringify f))
- (cond ((string= f "@") (stringify zname))
- ((and (plusp (length f))
- (char= (char f (1- (length f))) #\.))
- (string-downcase (subseq f 0 (1- (length f)))))
- (t (string-downcase (concatenate 'string f "."
- (stringify zname))))))
-(defun default-rev-zone (base bytes)
- "Return the default reverse-zone name for the given BASE address and number
- of fixed leading BYTES."
- (join-strings #\. (collecting ()
- (loop for i from (- 3 bytes) downto 0
- do (collect (ipaddr-byte base i)))
- (collect "in-addr.arpa"))))
-
-(defun zone-name-from-net (net &optional bytes)
- "Given a NET, and maybe the BYTES to use, convert to the appropriate
- subdomain of in-addr.arpa."
- (let ((ipn (net-get-as-ipnet net)))
- (with-ipnet (net mask) ipn
- (unless bytes
- (setf bytes (- 4 (ipnet-changeable-bytes mask))))
- (join-strings #\.
- (append (loop
- for i from (- 4 bytes) below 4
- collect (logand #xff (ash net (* -8 i))))
- (list "in-addr.arpa"))))))
-
-(defun zone-net-from-name (name)
- "Given a NAME in the in-addr.arpa space, convert it to an ipnet."
- (let* ((name (string-downcase (stringify name)))
- (len (length name))
- (suffix ".in-addr.arpa")
- (sufflen (length suffix))
- (addr 0)
- (n 0)
- (end (- len sufflen)))
- (unless (and (> len sufflen)
- (string= name suffix :start1 end))
- (error "`~A' not in ~A." name suffix))
- (loop
- with start = 0
- for dot = (position #\. name :start start :end end)
- for byte = (parse-integer name
- :start start
- :end (or dot end))
- do (setf addr (logior addr (ash byte (* 8 n))))
- (incf n)
- when (>= n 4)
- do (error "Can't deduce network from ~A." name)
- while dot
- do (setf start (1+ dot)))
- (setf addr (ash addr (* 8 (- 4 n))))
- (make-ipnet addr (* 8 n))))
-
-(defun zone-parse-net (net name)
- "Given a NET, and the NAME of a domain to guess from if NET is null, return
- the ipnet for the network."
- (if net
- (net-get-as-ipnet net)
- (zone-net-from-name name)))
-
-(defun zone-cidr-delg-default-name (ipn bytes)
- "Given a delegated net IPN and the parent's number of changing BYTES,
- return the default deletate zone prefix."
- (with-ipnet (net mask) ipn
- (join-strings #\.
- (reverse
- (loop
- for i from (1- bytes) downto 0
- until (zerop (logand mask (ash #xff (* 8 i))))
- collect (logand #xff (ash net (* -8 i))))))))
-
-;;;--------------------------------------------------------------------------
-;;; Serial numbering.