• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ustream-ssl/ustream-ssl.h

  1 /*
  2  * ustream-ssl - library for SSL over ustream
  3  *
  4  * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
  5  *
  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.
  9  *
 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.
 17  */
 18 
 19 #ifndef __USTREAM_SSL_H
 20 #define __USTREAM_SSL_H
 21 
 22 #include <libubox/ustream.h>
 23 
 24 struct ustream_ssl {
 25         struct ustream stream;
 26         struct ustream *conn;
 27         struct uloop_timeout error_timer;
 28         struct uloop_fd fd;
 29 
 30         /* freeing the stream from these callbacks is allowed */
 31         void (*notify_connected)(struct ustream_ssl *us);
 32         void (*notify_error)(struct ustream_ssl *us, int error, const char *str);
 33         void (*notify_verify_error)(struct ustream_ssl *us, int error, const char *str);
 34 
 35         struct ustream_ssl_ctx *ctx;
 36         void *ssl;
 37 
 38         char *peer_cn;
 39         const char *server_name;
 40 
 41         int error;
 42         int pending_write;
 43         bool connected;
 44         bool server;
 45 
 46         bool valid_cert;
 47         bool valid_cn;
 48         bool require_validation;
 49 };
 50 
 51 struct ustream_ssl_ctx;
 52 
 53 typedef void (*ustream_ssl_debug_cb)(void *priv, int level, const char *msg);
 54 
 55 struct ustream_ssl_ops {
 56         struct ustream_ssl_ctx *(*context_new)(bool server);
 57         int (*context_set_crt_file)(struct ustream_ssl_ctx *ctx, const char *file);
 58         int (*context_set_key_file)(struct ustream_ssl_ctx *ctx, const char *file);
 59         int (*context_add_ca_crt_file)(struct ustream_ssl_ctx *ctx, const char *file);
 60         void (*context_free)(struct ustream_ssl_ctx *ctx);
 61 
 62         int (*init_fd)(struct ustream_ssl *us, int fd, struct ustream_ssl_ctx *ctx, bool server);
 63         int (*init)(struct ustream_ssl *us, struct ustream *conn, struct ustream_ssl_ctx *ctx, bool server);
 64         int (*set_peer_cn)(struct ustream_ssl *conn, const char *name);
 65 
 66         int (*context_set_ciphers)(struct ustream_ssl_ctx *ctx, const char *ciphers);
 67         void (*context_set_debug)(struct ustream_ssl_ctx *ctx, int level, ustream_ssl_debug_cb cb, void *cb_priv);
 68         int (*context_set_require_validation)(struct ustream_ssl_ctx *ctx, bool require);
 69 };
 70 
 71 extern const struct ustream_ssl_ops ustream_ssl_ops;
 72 
 73 #define ustream_ssl_context_new                         ustream_ssl_ops.context_new
 74 #define ustream_ssl_context_set_crt_file                ustream_ssl_ops.context_set_crt_file
 75 #define ustream_ssl_context_set_key_file                ustream_ssl_ops.context_set_key_file
 76 #define ustream_ssl_context_add_ca_crt_file             ustream_ssl_ops.context_add_ca_crt_file
 77 #define ustream_ssl_context_set_ciphers                 ustream_ssl_ops.context_set_ciphers
 78 #define ustream_ssl_context_set_debug                   ustream_ssl_ops.context_set_debug
 79 #define ustream_ssl_context_set_require_validation      ustream_ssl_ops.context_set_require_validation
 80 #define ustream_ssl_context_free                        ustream_ssl_ops.context_free
 81 #define ustream_ssl_init                                ustream_ssl_ops.init
 82 #define ustream_ssl_set_peer_cn                         ustream_ssl_ops.set_peer_cn
 83 
 84 #endif
 85 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt