xref: /freebsd/contrib/ntp/sntp/libevent/openssl-compat.h (revision a466cc55373fc3cf86837f09da729535b57e69a1)
1*a466cc55SCy Schubert #ifndef OPENSSL_COMPAT_H
2*a466cc55SCy Schubert #define OPENSSL_COMPAT_H
3*a466cc55SCy Schubert 
4*a466cc55SCy Schubert #include <openssl/bio.h>
5*a466cc55SCy Schubert #include "util-internal.h"
6*a466cc55SCy Schubert 
7*a466cc55SCy Schubert #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
8*a466cc55SCy Schubert 	(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
9*a466cc55SCy Schubert 
BIO_meth_new(int type,const char * name)10*a466cc55SCy Schubert static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
11*a466cc55SCy Schubert {
12*a466cc55SCy Schubert 	BIO_METHOD *biom = calloc(1, sizeof(BIO_METHOD));
13*a466cc55SCy Schubert 
14*a466cc55SCy Schubert 	if (biom != NULL) {
15*a466cc55SCy Schubert 		biom->type = type;
16*a466cc55SCy Schubert 		biom->name = name;
17*a466cc55SCy Schubert 	}
18*a466cc55SCy Schubert 	return biom;
19*a466cc55SCy Schubert }
20*a466cc55SCy Schubert 
21*a466cc55SCy Schubert #define BIO_meth_set_write(b, f) (b)->bwrite = (f)
22*a466cc55SCy Schubert #define BIO_meth_set_read(b, f) (b)->bread = (f)
23*a466cc55SCy Schubert #define BIO_meth_set_puts(b, f) (b)->bputs = (f)
24*a466cc55SCy Schubert #define BIO_meth_set_ctrl(b, f) (b)->ctrl = (f)
25*a466cc55SCy Schubert #define BIO_meth_set_create(b, f) (b)->create = (f)
26*a466cc55SCy Schubert #define BIO_meth_set_destroy(b, f) (b)->destroy = (f)
27*a466cc55SCy Schubert 
28*a466cc55SCy Schubert #define BIO_set_init(b, val) (b)->init = (val)
29*a466cc55SCy Schubert #define BIO_set_data(b, val) (b)->ptr = (val)
30*a466cc55SCy Schubert #define BIO_set_shutdown(b, val) (b)->shutdown = (val)
31*a466cc55SCy Schubert #define BIO_get_init(b) (b)->init
32*a466cc55SCy Schubert #define BIO_get_data(b) (b)->ptr
33*a466cc55SCy Schubert #define BIO_get_shutdown(b) (b)->shutdown
34*a466cc55SCy Schubert 
35*a466cc55SCy Schubert #define TLS_method SSLv23_method
36*a466cc55SCy Schubert 
37*a466cc55SCy Schubert #define X509_getm_notBefore X509_get_notBefore
38*a466cc55SCy Schubert #define X509_getm_notAfter X509_get_notAfter
39*a466cc55SCy Schubert 
40*a466cc55SCy Schubert #endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
41*a466cc55SCy Schubert 	(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
42*a466cc55SCy Schubert 
43*a466cc55SCy Schubert #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L
44*a466cc55SCy Schubert #define BIO_get_init(b) (b)->init
45*a466cc55SCy Schubert #endif
46*a466cc55SCy Schubert 
47*a466cc55SCy Schubert #endif /* OPENSSL_COMPAT_H */
48