Topic: Feature Request: Add a free variable on the callback methods

Hello,

If I understand correctly, there isn't a way to pass a variable to the callback set by wolfSSL_SetIOSend / wolfSSL_SetIOReceive.

If possible, could you please add an extra parameter to the wolfSSL_SetIOSend / wolfSSL_SetIOReceive functions that will be passed to the callbacks?
It'll be easier to pass contexts, classes, etc...

Thanks
Nitay

Share

Re: Feature Request: Add a free variable on the callback methods

Hi Nitay,

wolfSSL embedded SSL does allow the user to set a context per WOLFSSL object.  From Section 5.1.2 of the wolfSSL Manual:

The user can set a context per wolfSSL object (session) with wolfSSL_SetIOWriteCtx() and wolfSSL_SetIOReadCtx(), as demonstrated at the bottom of io.c.  For example, if the user is using memory buffers, the context may be a pointer to a structure describing where and how to access the memory buffers.  The default case, with no user overrides, registers the socket as the context.

This context will then be passed to the I/O callbacks using the ctx parameter, where the I/O callbacks are prototyped by:

/* I/O callbacks */                                                             
typedef int (*CallbackIORecv)(WOLFSSL *ssl, char *buf, int sz, void *ctx);       
typedef int (*CallbackIOSend)(WOLFSSL *ssl, char *buf, int sz, void *ctx);

Best Regards,
Chris

Re: Feature Request: Add a free variable on the callback methods

Missed that! Thanks Chris!

Share