Got a couple more (hopefully easy) questions.

1. What type do I use?  The LDAP example uses ( 100 | 0x400 ).  I know 0x400
is BIO_TYPE_SOURCE_SINK, but is 100 just a magic number pulled out of a
hat?  What magic number can I pull out of my hat for mine and how do I
ensure it doesn't conflict with others (or does it not matter)?

2. Which callbacks can be left out?  bss_fd.c sets the callback for "gets"
to NULL, and the LDAP example implements it but it returns -1.  So "gets"
must be an optional callback, right?

(Creating a custom BIO could be so easy if there was a short tutorial to
answer some of these simple questions.)

Phillip

On Mon, Apr 12, 2010 at 10:27 AM, Phillip Hellewell <ssh...@gmail.com>wrote:

> Thanks for the example.  Yeah, my best idea so far was to look at existing
> examples, such as bss_mem.c.  One question I still have is which of the
> BIO_CTRL_* commands does my ctrl function need to handle?  bss_mem.c handles
> about a dozen of them, but the example you gave me only handles
> BIO_CTRL_FLUSH, so is that the only one I'm required to handle?
>
> Phillip
>
>
> On Mon, Apr 12, 2010 at 10:15 AM, Howard Chu <h...@highlandsun.com> wrote:
>
>> Phillip Hellewell wrote:
>>
>>> Hi all,
>>>
>>> How do I implement my own BIO?  Do I just create a function that returns
>>> a
>>> BIO_METHOD* with pointers to my custom functions?  Is there any
>>> documentation
>>> on how to do this?
>>>
>>> I searched the mailing list and found that this question has been asked
>>> before
>>> but no one ever responds.  The lack of documentation and responses leads
>>> me to
>>> believe that the BIO interface is not really meant to be used for
>>> user-defined
>>> I/O.
>>>
>>> 1999: http://marc.info/?l=ssl-users&m=91639275613495&w=2
>>> <http://marc.info/?l=ssl-users&m=91639275613495&w=2>
>>> 2005: http://marc.info/?l=openssl-users&m=110624296809686&w=2
>>> <http://marc.info/?l=openssl-users&m=110624296809686&w=2>
>>> 2008: http://marc.info/?l=openssl-dev&m=122959672906832&w=2
>>> <http://marc.info/?l=openssl-dev&m=122959672906832&w=2>
>>>
>>> Please, at least will someone respond with one of the following:
>>> 1. "No, don't even try to do it.  You're not supposed to."
>>> 2. "Yes, you can do it but no one is going to help you.  Just look at
>>> some of
>>> the files in crypto/bio/ and see if you can figure it out."
>>>
>>
>> Some things are probably too easy to justify the time it takes to respond.
>> In this case, define a BIO_METHOD struct with your handlers and just use it.
>>
>> One example is in OpenLDAP's libldap/tls_o.c.
>>
>>
>> http://www.openldap.org/devel/cvsweb.cgi/~checkout~/libraries/libldap/tls_o.c?rev=1.16<http://www.openldap.org/devel/cvsweb.cgi/%7Echeckout%7E/libraries/libldap/tls_o.c?rev=1.16>
>>
>> --
>>  -- Howard Chu
>>  CTO, Symas Corp.           http://www.symas.com
>>  Director, Highland Sun     http://highlandsun.com/hyc/
>>  Chief Architect, OpenLDAP  http://www.openldap.org/project/
>>
>
>

Reply via email to