chiark / gitweb /
Merge branch 'master' of git+ssh://metalzone.distorted.org.uk/~mdw/public-git/zone
authorMark Wooding <mdw@distorted.org.uk>
Sat, 23 Dec 2006 14:54:24 +0000 (14:54 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 23 Dec 2006 14:54:24 +0000 (14:54 +0000)
1  2 
net.lisp

diff --combined net.lisp
index 08efe56ed2b9fd18f4052ed1d832da6c9b751f41,40882de85e951a068ccef59f4d2f5064ce1a1b30..61b5978fbfeb00d992b7162db24bf517d157b1c2
+++ b/net.lisp
@@@ -34,7 -34,7 +34,7 @@@
             #:ipnet-pretty #:ipnet-string #:ipnet-broadcast #:ipnet-hosts
             #:ipnet-host #:ipaddr-networkp #:ipnet-subnetp
             #:ipnet-changeable-bytes
 -         #:host-find# #:host-create #:defhost #:parse-ipaddr
 +         #:host-find #:host-create #:defhost #:parse-ipaddr
             #:resolve-hostname #:canonify-hostname
             #:net #:net-find #:net-get-as-ipnet #:net-create #:defnet
             #:net-next-host #:net-host))
@@@ -75,8 -75,7 +75,7 @@@
     `stringify'.  The START and END arguments may be used to parse out a
     substring."
    (setf str (stringify str))
-   (unless end
-     (setf end (length str)))
+   (setf-default end (length str))
    (let ((addr 0) (noct 0))
      (loop
        (let* ((pos (position #\. str :start start :end end))
  (defun string-ipnet (str &key (start 0) (end nil))
    "Parse an IP-network from the string STR."
    (setf str (stringify str))
-   (unless end (setf end (length str)))
+   (setf-default end (length str))
    (let ((sl (position #\/ str :start start :end end)))
      (if sl
        (make-ipnet (parse-ipaddr (subseq str start sl))
  (defun resolve-hostname (name)
    "Resolve a hostname to an IP address using the DNS, or return nil."
    #+cmu (let ((he (ext:lookup-host-entry name)))
-         (and he
-              (ext:host-entry-addr he)))
-   #-cmu nil
- )
+         (and he (ext:host-entry-addr he)))
+   #+clisp (let ((he (ext:resolve-host-ipaddr name)))
+           (and he (string-ipaddr (car (ext:hostent-addr-list he)))))
+   #+ecl (nth-value 2 (ext:lookup-host-entry name))
+   #-(or cmu clisp ecl) nil)
  
  (defun canonify-hostname (name)
    "Resolve a hostname to canonical form using the DNS, or return nil."
    #+cmu (let ((he (ext:lookup-host-entry name)))
-         (and he
-              (ext:host-entry-name he)))
-   #-cmu nil)
+         (and he (ext:host-entry-name he)))
+   #+clisp (let ((he (ext:resolve-host-ipaddr name)))
+           (and he (ext:hostent-name he)))
+   #+ecl (nth-value 0 (ext:lookup-host-entry name))
+   #-(or cmu clisp ecl) name)
  
  ;;;--------------------------------------------------------------------------
  ;;; Host names and specifiers.