Topic: wolfSSL support C-function recvmsg() ?

Hello,

I was wondering if wolfSSL support SSL equivalent call similar to C-function recvmsg()?

Thanks,
K Han

Share

Re: wolfSSL support C-function recvmsg() ?

Hi khan92,

The equivalent API call in wolfSSL is defined in <wolfssl-root>/wolfssl/ssl.h:

WOLFSSL_API int  wolfSSL_read(WOLFSSL*, void*, int);

For simple examples that demonstrate this API in use please see our example client/server here:

https://github.com/wolfSSL/wolfssl-exam … rver-tls.c
https://github.com/wolfSSL/wolfssl-exam … ient-tls.c

Regards,

Kaleb

Re: wolfSSL support C-function recvmsg() ?

Kaleb J. Himes,

Thank you for the reply.
I am aware of wolfSSL_read is equivalent to C-function read().
wolfSSL uses the underlying C-function read() and write() for SSL/TLS and readfrom() and writeto() for DTLS.

However, I am looking for the equivalent of readmsg() C-function. Maybe I will try to ask this question in a different way: is there anyway that I am able to retrieve the msghdr struct in wolfSSL, in which that struct is retrieved from calling C-function recvmsg().

My impression from reading SSL manual is that wolfSSL has supported 2 out of 3 C-function that receives a message from a socket, which are recv() and recvfrom() (linux manpage https://linux.die.net/man/2/recvmsg).

Thank you for your time. I appreciate your help.

KHan

Share

Re: wolfSSL support C-function recvmsg() ?

Hi khan92,

My apologies, I will also try to be clearer:

wolfSSL takes every effort to support any operating system and environment. We also make an effort to provide functionality that will allow any OS/environ we do not currently support, to be ported somewhat easily. To facilitate this portability, by default wolfSSL uses what is called a Custom In/Out Callback function(CustomIOCallback). The call chain is like this:

wolfSSL_read ->wolfSSL_read_internal -> ReceiveData -> (various paths) -> GetInputData -> Receive -> CustomIOCallback

You can register any custom IO callback you want to with the API's:

wolfSSL_SetIORecv(ctx, <your custom Receive function name here>);                                           
wolfSSL_SetIOSend(ctx, <your custom Send function name here>);

So to have wolfSSL_read be the equivalent of ANY input functionality, you write your custom IO receive callback to use the desired input functionality. In this case you desire wolfSSL_read to use a custom callback that calls readmsg() instead of some other input function.

I just opened a PR yesterday with example client and servers where wolfSSL_read actually reads out of a file and wolfSSL_write writes to a file. The client and server perform a TLS connection through the file system instead of using sockets. These examples are currently in a PR but should soon be merged. Please feel free to use them as a guide for your work.

https://github.com/wolfSSL/wolfssl-examples/pull/34


Warmest Regards,

Kaleb