2 * ustream-ssl - library for SSL over ustream
4 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef __USTREAM_SSL_H
20 #define __USTREAM_SSL_H
22 #include <libubox/ustream.h>
25 struct ustream stream
;
27 struct uloop_timeout error_timer
;
29 void (*notify_connected
)(struct ustream_ssl
*us
);
30 void (*notify_error
)(struct ustream_ssl
*us
, int error
, const char *str
);
31 void (*notify_verify_error
)(struct ustream_ssl
*us
, int error
, const char *str
);
33 struct ustream_ssl_ctx
*ctx
;
47 struct ustream_ssl_ctx
;
49 struct ustream_ssl_ops
{
51 struct ustream_ssl_ctx
*(*context_new
)(bool server
);
52 int (*context_set_crt_file
)(struct ustream_ssl_ctx
*ctx
, const char *file
);
53 int (*context_set_key_file
)(struct ustream_ssl_ctx
*ctx
, const char *file
);
54 int (*context_add_ca_crt_file
)(struct ustream_ssl_ctx
*ctx
, const char *file
);
55 void (*context_free
)(struct ustream_ssl_ctx
*ctx
);
57 int (*init
)(struct ustream_ssl
*us
, struct ustream
*conn
, struct ustream_ssl_ctx
*ctx
, bool server
);
58 int (*set_peer_cn
)(struct ustream_ssl
*conn
, const char *name
);
61 extern const struct ustream_ssl_ops ustream_ssl_ops
;
63 #define ustream_ssl_context_new ustream_ssl_ops.context_new
64 #define ustream_ssl_context_set_crt_file ustream_ssl_ops.context_set_crt_file
65 #define ustream_ssl_context_set_key_file ustream_ssl_ops.context_set_key_file
66 #define ustream_ssl_context_add_ca_crt_file ustream_ssl_ops.context_add_ca_crt_file
67 #define ustream_ssl_context_free ustream_ssl_ops.context_free
68 #define ustream_ssl_init ustream_ssl_ops.init
69 #define ustream_ssl_set_peer_cn ustream_ssl_ops.set_peer_cn