[Openmcl-devel] Re: ipaddr-to-dotted
jdesoi at planetc.com
Thu Nov 21 19:49:03 EST 2002
The original discussion of ipaddr-to-dotted is below. I'm sure this
is fixed now (several releases ago), but I have not tested it.
>I don't know whether Portable Aserve still passes NIL here; John DeSoi
I have not looked into it. I would keep the redefined function until
we can verify that nil is no longer coming from the logging function.
John DeSoi, Ph.D.
Date: Sun, 7 Apr 2002 23:12:05 -0600 (MDT)
From: Gary Byers <gb at clozure.com>
To: John DeSoi <desoi at mac.com>
cc: <bug-openmcl at clozure.com>
Subject: Re: [bug-openmcl] Calling convention bug affect _inet_ntoa
The bug's in the interface translator (and/or the treatment of structure
arguments in foreign function calls.)
In Darwin, structure arguments are passed by value (as one or more words);
in Linux they're passed by reference.
In both OSes, a "struct ipaddr" is a structure whose length is exactly
4 bytes. The definition of the function _inet_ntoa
(in ccl::l1;l1-sockets.lisp) takes great care to pass the address of
this structure to #_inet_ntoa; under Darwin, #_inet_ntoa returns ...
a dotted string representation of that address (which isn't too interesting.)
There are also differences in how structure return values are returned:
under Darwin, structure return values whose size is 4 bytes or less
are returned by value; larger structures are returned in an invisible
1st argument reserved by the caller (like the rest of the world does
it.) This convention isn't yet handled correctly either.
I'm not sure how many other functions are affected by either of these
bugs. Until the general structure-passing issues are resolved,
conditionalizing _inet_ntoa seems like a reasonable workaround:
(defun _inet_ntoa (addr)
(rlet ((addrp :unsigned))
(setf (pref addrp :unsigned) addr)
(%setf-macptr p (#_inet_ntoa addrp))
(unless (%null-ptr-p p) (%get-cstring p)))))
(defun _inet_ntoa (addr)
(%setf-macptr p (external-call "_inet_ntoa"
(unless (%null-ptr-p p) (%get-cstring p))))
On Mon, 8 Apr 2002, John DeSoi wrote:
> It appears there is a bug in the socket function
> ccl:ipaddr-to-dotted. With portable allegroserve, I'm getting the
> wrong addresses in the log. For example with the client address
> 192.168.1.6, I get 0.6.252.8. I get the correct address using the
> function below from portable allegroserve.
> John DeSoi, Ph.D.
> (defun ipaddr-to-dotted (ipaddr &key values)
> (if (null ipaddr)
> (if values (values 0 0 0 0) "0.0.0.0")
> (let ((a (logand #xff (ash ipaddr -24)))
> (b (logand #xff (ash ipaddr -16)))
> (c (logand #xff (ash ipaddr -8)))
> (d (logand #xff ipaddr)))
> (if values
> (values a b c d)
> (format nil "~d.~d.~d.~d" a b c d)))))
> bug-openmcl mailing list
> bug-openmcl at clozure.com
Openmcl-devel mailing list
Openmcl-devel at clozure.com
More information about the Openmcl-devel