From 973ae30e7c4f7a1afb385dd3d8eeea178f981445 Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Mon, 8 Jul 2024 13:24:39 +0200 Subject: fix deprecated prototypes --- src/tls_timeoutio.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/tls_timeoutio.c') diff --git a/src/tls_timeoutio.c b/src/tls_timeoutio.c index e97c858..c8c2138 100644 --- a/src/tls_timeoutio.c +++ b/src/tls_timeoutio.c @@ -2,14 +2,20 @@ #include "tls_timeoutio.h" #include "error.h" -#include "logmsg.h" #include "ndelay.h" #include "select.h" #include "now.h" -#include "ucspissl.h" -int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, int len) +#define CALLBACK_ADAPTER(func) \ + static int func##_adapter(SSL *ssl, void *buf, int len) \ + { \ + (void)buf; \ + (void)len; \ + return func(ssl); \ + } + +int tls_timeoutio(int (*fun)(SSL *, void *, int), int t, int rfd, int wfd, SSL *ssl, char *buf, int len) { int n; const datetime_sec end = (datetime_sec)t + now(); @@ -18,7 +24,7 @@ int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, in fd_set fds; struct timeval tv; - const int r = buf ? fun(ssl, buf, len) : fun(ssl); + const int r = fun(ssl, buf, len); if (r > 0) return r; t = end - now(); @@ -46,13 +52,15 @@ int tls_timeoutio(int (*fun)(), int t, int rfd, int wfd, SSL *ssl, char *buf, in return -1; } +CALLBACK_ADAPTER(SSL_accept); + int tls_timeoutaccept(int t, int rfd, int wfd, SSL *ssl) { int r; /* if connection is established, keep NDELAY */ if (ndelay_on(rfd) == -1 || ndelay_on(wfd) == -1) return -1; - r = tls_timeoutio(SSL_accept, t, rfd, wfd, ssl, NULL, 0); + r = tls_timeoutio(SSL_accept_adapter, t, rfd, wfd, ssl, NULL, 0); if (r <= 0) { ndelay_off(rfd); @@ -64,13 +72,15 @@ int tls_timeoutaccept(int t, int rfd, int wfd, SSL *ssl) return r; } +CALLBACK_ADAPTER(SSL_connect); + int tls_timeoutconn(int t, int rfd, int wfd, SSL *ssl) { int r; /* if connection is established, keep NDELAY */ if (ndelay_on(rfd) == -1 || ndelay_on(wfd) == -1) return -1; - r = tls_timeoutio(SSL_connect, t, rfd, wfd, ssl, NULL, 0); + r = tls_timeoutio(SSL_connect_adapter, t, rfd, wfd, ssl, NULL, 0); if (r <= 0) { ndelay_off(rfd); @@ -82,19 +92,21 @@ int tls_timeoutconn(int t, int rfd, int wfd, SSL *ssl) return r; } +CALLBACK_ADAPTER(SSL_do_handshake); + int tls_timeoutrehandshake(int t, int rfd, int wfd, SSL *ssl) { int r; SSL_renegotiate(ssl); - r = tls_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); + r = tls_timeoutio(SSL_do_handshake_adapter, t, rfd, wfd, ssl, NULL, 0); if (r <= 0) return r; if (SSL_get_state(ssl) & SSL_ST_CONNECT) return -2; /* now a macro in ssl.h */ /* this is for the client only */ SSL_set_connect_state(ssl); - return tls_timeoutio(SSL_do_handshake, t, rfd, wfd, ssl, NULL, 0); + return tls_timeoutio(SSL_do_handshake_adapter, t, rfd, wfd, ssl, NULL, 0); } int tls_timeoutread(int t, int rfd, int wfd, SSL *ssl, char *buf, int len) @@ -107,5 +119,5 @@ int tls_timeoutread(int t, int rfd, int wfd, SSL *ssl, char *buf, int len) int tls_timeoutwrite(int t, int rfd, int wfd, SSL *ssl, char *buf, int len) { if (!buf) return 0; - return tls_timeoutio(SSL_write, t, rfd, wfd, ssl, buf, len); + return tls_timeoutio((int (*)(SSL *, void *, int))SSL_write, t, rfd, wfd, ssl, buf, len); } -- cgit v1.2.3