5cc4d15ca2c4766686b9a3fa578c3a5523bb3423
[project/ustream-ssl.git] / ustream-ssl.h
1 #ifndef __USTREAM_SSL_H
2 #define __USTREAM_SSL_H
3
4 struct ustream_ssl {
5         struct ustream stream;
6         struct ustream *conn;
7         struct uloop_timeout error_timer;
8
9         void (*notify_connected)(struct ustream_ssl *us);
10         void (*notify_error)(struct ustream_ssl *us, int error, const char *str);
11
12         void *ctx;
13         void *ssl;
14
15         int error;
16         bool connected;
17         bool server;
18 };
19
20 struct ustream_ssl_ops {
21         void *(*context_new)(bool server);
22         int (*context_set_crt_file)(void *ctx, const char *file);
23         int (*context_set_key_file)(void *ctx, const char *file);
24         void (*context_free)(void *ctx);
25
26         int (*init)(struct ustream_ssl *us, struct ustream *conn, void *ctx, bool server);
27 };
28
29 extern const struct ustream_ssl_ops ustream_ssl_ops;
30
31 #define ustream_ssl_context_new                 ustream_ssl_ops.context_new
32 #define ustream_ssl_context_set_crt_file        ustream_ssl_ops.context_set_crt_file
33 #define ustream_ssl_context_set_key_file        ustream_ssl_ops.context_set_key_file
34 #define ustream_ssl_context_free                ustream_ssl_ops.context_free
35 #define ustream_ssl_init                        ustream_ssl_ops.init
36
37 #endif