On Apr 1, 2005, at 4:37 AM, alok wrote:

Can someone exactly explain why one cannot typecast a bio( ) to a UNIX domain socket/IPC/fd?

I'll give this a shot.

Unix allows you to read() to and write() from stream-like objects such as files, pipes, character devices, and various kinds of sockets polymorphically because these are all maintained by the kernel. OpenSSL objects are all user-level, so you can't pass them to kernel calls.

Your options include:

* Write a kernel module that adds support for kernel-space BIO objects. This would be Hard and necessarily non-portable (and unrecommended), but I mention it because it's theoretically doable and it lets you manipulate a BIO through a file descriptor, which is what you asked about.

* Write your own polymorphic I/O library. Call UserRead() and UserWrite() ( or user_read() and user_write() -- season to taste) instead of read() and write(). If you use negative integers for I/O descriptors, then you could map kernel file descriptors into your I/O descriptor space, and have UserRead( fd ) map to read( fd ). I implemented polymorphic I/O in classic Mac OS, but since my application was in essence a Unix kernel, it was unavoidable. If you really need to have values that might refer to either a BIO or a file descriptor (without knowing which until runtime), then you will either do this or something functionally equivalent. Otherwise, Keep It Simple.

* Use the BIO read and write calls as previously described on this list and elsewhere.

Josh

--
Joshua Juran
Metamage Software Creations - Mac Software and Consulting
http://www.metamage.com/

               * Creation at the highest state of the art *



Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to