From 8709226555830aa06f77ce3f297948c7a3334484 Mon Sep 17 00:00:00 2001 From: Stelian Ionescu Date: Tue, 8 May 2007 00:59:03 +0200 Subject: [PATCH] Added ENSURE-ADDRESS and SOCKADDRP. Signed-off-by: Stelian Ionescu --- sockets/address.lisp | 15 +++++++++++++++ sockets/pkgdcl.lisp | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sockets/address.lisp b/sockets/address.lisp index d102b3e..e146701 100644 --- a/sockets/address.lisp +++ b/sockets/address.lisp @@ -262,6 +262,10 @@ ((ignore-errors (coercef name 'ipv6-array)) (make-instance 'ipv6addr :name name)) (t (error 'invalid-address :address name :type :unknown)))) + +(defun ensure-address (addr) + (if (sockaddrp addr) addr + (make-address addr))) ;;; ;;; Well-known addresses @@ -301,6 +305,17 @@ ;;; ;; General predicates +(defgeneric sockaddrp (address) + (:documentation "Returns T if ADDRESS is a socket address.")) + +(defmethod sockaddrp ((address sockaddr)) + (declare (ignore address)) + t) + +(defmethod sockaddrp (address) + (declare (ignore address)) + nil) + (defgeneric ipv4-address-p (address) (:documentation "Returns T if ADDRESS is an IPv4 address object.")) diff --git a/sockets/pkgdcl.lisp b/sockets/pkgdcl.lisp index bb1718c..9974f6f 100644 --- a/sockets/pkgdcl.lisp +++ b/sockets/pkgdcl.lisp @@ -46,7 +46,8 @@ ;; addresses #:sockaddr #:inetaddr #:ipv4addr #:ipv6addr #:localaddr - #:make-address #:sockaddr= #:sockaddr->presentation #:copy-sockaddr + #:make-address #:ensure-address + #:sockaddr= #:sockaddr->presentation #:copy-sockaddr #:name #:abstract-p ;; well-known addresses and important values @@ -58,6 +59,7 @@ #:+ipv6-site-local-all-routers+ ;; address predicates + #:sockaddrp #:ipv4-address-p #:ipv6-address-p #:local-address-p #:inetaddr-unspecified-p #:inetaddr-loopback-p #:inetaddr-multicast-p #:inetaddr-unicast-p -- 2.11.4.GIT