Qsmtp  0.30dev
Macros | Functions
ssl_timeoutio.c File Reference

SSL encoding and decoding functions for network I/O. More...

#include <ssl_timeoutio.h>
#include <tls.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <openssl/err.h>

Macros

#define ndelay_on(fd)   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK)
 
#define ndelay_off(fd)   (void) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK)
 

Functions

static int ssl_timeoutio (int(*func)(), time_t t, char *buf, const int len)
 
int ssl_timeoutaccept (time_t t)
 accept the request for SSL More...
 
int ssl_timeoutconn (time_t t)
 establish SSL protocol to remote host More...
 
int ssl_timeoutrehandshake (time_t t)
 do a new SSL handshake More...
 
int ssl_timeoutread (time_t t, char *buf, const int len)
 
int ssl_timeoutwrite (time_t t, const char *buf, const int len)
 

Detailed Description

SSL encoding and decoding functions for network I/O.

Function Documentation

int ssl_timeoutaccept ( time_t  t)

accept the request for SSL

Parameters
ttimeout in seconds
Returns
if the call was successful
Return values
0the call was successful
<0error code
int ssl_timeoutconn ( time_t  t)

establish SSL protocol to remote host

Parameters
ttimeout in seconds
Returns
if the call was successful
Return values
0the call was successful
<0error code
static int ssl_timeoutio ( int(*)()  func,
time_t  t,
char *  buf,
const int  len 
)
static

call SSL function for given data buffer

Parameters
funcOpenSSL function to call
ttimeout
bufdata buffer
lenlength of buf
Returns
if call to func was successful
Return values
>0the call was successful
<0error code
-EPROTOthere was a SSL-level protocol error

This function never returns 0.

int ssl_timeoutrehandshake ( time_t  t)

do a new SSL handshake

Parameters
ttimeout in seconds
Returns
if handshake was successful
Return values
>0handshake was successful
<0error code
int ssl_timeoutwrite ( time_t  t,
const char *  buf,
const int  len 
)
inline

write data SSL encrypted to network

Parameters
ttimeout
bufdata to send
lenlength of buf
Returns
return code of SSL_write