X-Git-Url: https://git.distorted.org.uk/~mdw/zone/blobdiff_plain/8db288376fc077c4d77a6e76f31b3b404f5ed2ad..5fbfaf497e92e9afb794768f0ed58790eaca545b:/net.lisp diff --git a/net.lisp b/net.lisp index 08efe56..28f10ef 100644 --- a/net.lisp +++ b/net.lisp @@ -13,12 +13,12 @@ ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. -;;; +;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. -;;; +;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -75,8 +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)) @@ -151,7 +150,7 @@ (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)) @@ -259,17 +258,20 @@ (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.