ustream-ssl: add support for using a fd instead of ustream as backing
[project/ustream-ssl.git] / ustream-ssl.h
index 77877885e43103c0e86224e6f6b2a427cf79ef2c..fe545f48961661e7034442c8f6c700ded9bd3d66 100644 (file)
@@ -25,6 +25,7 @@ struct ustream_ssl {
        struct ustream stream;
        struct ustream *conn;
        struct uloop_timeout error_timer;
+       struct uloop_fd fd;
 
        void (*notify_connected)(struct ustream_ssl *us);
        void (*notify_error)(struct ustream_ssl *us, int error, const char *str);
@@ -42,30 +43,40 @@ struct ustream_ssl {
 
        bool valid_cert;
        bool valid_cn;
+       bool require_validation;
 };
 
 struct ustream_ssl_ctx;
 
-struct ustream_ssl_ops {
+typedef void (*ustream_ssl_debug_cb)(void *priv, int level, const char *msg);
 
+struct ustream_ssl_ops {
        struct ustream_ssl_ctx *(*context_new)(bool server);
        int (*context_set_crt_file)(struct ustream_ssl_ctx *ctx, const char *file);
        int (*context_set_key_file)(struct ustream_ssl_ctx *ctx, const char *file);
        int (*context_add_ca_crt_file)(struct ustream_ssl_ctx *ctx, const char *file);
        void (*context_free)(struct ustream_ssl_ctx *ctx);
 
+       int (*init_fd)(struct ustream_ssl *us, int fd, struct ustream_ssl_ctx *ctx, bool server);
        int (*init)(struct ustream_ssl *us, struct ustream *conn, struct ustream_ssl_ctx *ctx, bool server);
        int (*set_peer_cn)(struct ustream_ssl *conn, const char *name);
+
+       int (*context_set_ciphers)(struct ustream_ssl_ctx *ctx, const char *ciphers);
+       void (*context_set_debug)(struct ustream_ssl_ctx *ctx, int level, ustream_ssl_debug_cb cb, void *cb_priv);
+       int (*context_set_require_validation)(struct ustream_ssl_ctx *ctx, bool require);
 };
 
 extern const struct ustream_ssl_ops ustream_ssl_ops;
 
-#define ustream_ssl_context_new                        ustream_ssl_ops.context_new
-#define ustream_ssl_context_set_crt_file       ustream_ssl_ops.context_set_crt_file
-#define ustream_ssl_context_set_key_file       ustream_ssl_ops.context_set_key_file
-#define ustream_ssl_context_add_ca_crt_file    ustream_ssl_ops.context_add_ca_crt_file
-#define ustream_ssl_context_free               ustream_ssl_ops.context_free
-#define ustream_ssl_init                       ustream_ssl_ops.init
-#define ustream_ssl_set_peer_cn                        ustream_ssl_ops.set_peer_cn
+#define ustream_ssl_context_new                                ustream_ssl_ops.context_new
+#define ustream_ssl_context_set_crt_file               ustream_ssl_ops.context_set_crt_file
+#define ustream_ssl_context_set_key_file               ustream_ssl_ops.context_set_key_file
+#define ustream_ssl_context_add_ca_crt_file            ustream_ssl_ops.context_add_ca_crt_file
+#define ustream_ssl_context_set_ciphers                        ustream_ssl_ops.context_set_ciphers
+#define ustream_ssl_context_set_debug                  ustream_ssl_ops.context_set_debug
+#define ustream_ssl_context_set_require_validation     ustream_ssl_ops.context_set_require_validation
+#define ustream_ssl_context_free                       ustream_ssl_ops.context_free
+#define ustream_ssl_init                               ustream_ssl_ops.init
+#define ustream_ssl_set_peer_cn                                ustream_ssl_ops.set_peer_cn
 
 #endif