00001 /* 00002 * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 1. Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * 2. Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * 3. The name of the author may not be used to endorse or promote products 00013 * derived from this software without specific prior written permission. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00017 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00018 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00019 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00020 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00021 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00022 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00024 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 */ 00026 #ifndef _EVENT2_BUFFEREVENT_SSL_H_ 00027 #define _EVENT2_BUFFEREVENT_SSL_H_ 00028 00034 #include <event2/event-config.h> 00035 #include <event2/bufferevent.h> 00036 #include <event2/util.h> 00037 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 /* This is what openssl's SSL objects are underneath. */ 00043 struct ssl_st; 00044 00049 enum bufferevent_ssl_state { 00050 BUFFEREVENT_SSL_OPEN = 0, 00051 BUFFEREVENT_SSL_CONNECTING = 1, 00052 BUFFEREVENT_SSL_ACCEPTING = 2 00053 }; 00054 00055 #if defined(_EVENT_HAVE_OPENSSL) || defined(_EVENT_IN_DOXYGEN) 00056 00067 struct bufferevent * 00068 bufferevent_openssl_filter_new(struct event_base *base, 00069 struct bufferevent *underlying, 00070 struct ssl_st *ssl, 00071 enum bufferevent_ssl_state state, 00072 int options); 00073 00084 struct bufferevent * 00085 bufferevent_openssl_socket_new(struct event_base *base, 00086 evutil_socket_t fd, 00087 struct ssl_st *ssl, 00088 enum bufferevent_ssl_state state, 00089 int options); 00090 00092 struct ssl_st * 00093 bufferevent_openssl_get_ssl(struct bufferevent *bufev); 00094 00096 int bufferevent_ssl_renegotiate(struct bufferevent *bev); 00097 00099 unsigned long bufferevent_get_openssl_error(struct bufferevent *bev); 00100 00101 #endif 00102 00103 #ifdef __cplusplus 00104 } 00105 #endif 00106 00107 #endif /* _EVENT2_BUFFEREVENT_SSL_H_ */