libevent  2.2.1
Event notification library
bufferevent_ssl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2012 Niels Provos and Nick Mathewson
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 #ifndef EVENT2_BUFFEREVENT_SSL_H_INCLUDED_
27 #define EVENT2_BUFFEREVENT_SSL_H_INCLUDED_
28 
33 #include <event2/visibility.h>
34 #include <event2/event-config.h>
35 #include <event2/bufferevent.h>
36 #include <event2/util.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
47  BUFFEREVENT_SSL_OPEN = 0,
48  BUFFEREVENT_SSL_CONNECTING = 1,
49  BUFFEREVENT_SSL_ACCEPTING = 2
50 };
51 
67 #define BUFFEREVENT_SSL_DIRTY_SHUTDOWN 1
68 
79 #define BUFFEREVENT_SSL_BATCH_WRITE 2
80 
81 #if defined(EVENT__HAVE_OPENSSL) || defined(EVENT__HAVE_MBEDTLS)
82 
88 EVENT2_EXPORT_SYMBOL
89 ev_uint64_t bufferevent_ssl_get_flags(struct bufferevent *bev);
96 EVENT2_EXPORT_SYMBOL
97 ev_uint64_t bufferevent_ssl_set_flags(struct bufferevent *bev, ev_uint64_t flags);
104 EVENT2_EXPORT_SYMBOL
105 ev_uint64_t bufferevent_ssl_clear_flags(struct bufferevent *bev, ev_uint64_t flags);
106 
107 #endif /* defined(EVENT__HAVE_OPENSSL) || defined(EVENT__HAVE_MBEDTLS) */
108 
109 #if defined(EVENT__HAVE_OPENSSL) || defined(EVENT_IN_DOXYGEN_)
110 /* This is what openssl's SSL objects are underneath. */
111 struct ssl_st;
112 
124 EVENT2_EXPORT_SYMBOL
125 struct bufferevent *
127  struct bufferevent *underlying,
128  struct ssl_st *ssl,
129  enum bufferevent_ssl_state state,
130  int options);
131 
142 EVENT2_EXPORT_SYMBOL
143 struct bufferevent *
145  evutil_socket_t fd,
146  struct ssl_st *ssl,
147  enum bufferevent_ssl_state state,
148  int options);
149 
157 EVENT2_EXPORT_SYMBOL
166 EVENT2_EXPORT_SYMBOL
168  int allow_dirty_shutdown);
169 
171 EVENT2_EXPORT_SYMBOL
172 struct ssl_st *
174 
176 EVENT2_EXPORT_SYMBOL
178 
180 EVENT2_EXPORT_SYMBOL
181 unsigned long bufferevent_get_openssl_error(struct bufferevent *bev);
182 
183 #endif
184 #if defined(EVENT__HAVE_MBEDTLS) || defined(EVENT_IN_DOXYGEN_)
185 struct mbedtls_ssl_context;
186 struct mbedtls_ssl_config;
187 typedef struct mbedtls_ssl_context mbedtls_dyncontext;
188 
200 EVENT2_EXPORT_SYMBOL
201 struct bufferevent *
203  struct bufferevent *underlying,
204  mbedtls_dyncontext *ssl,
205  enum bufferevent_ssl_state state,
206  int options);
207 
218 EVENT2_EXPORT_SYMBOL
219 struct bufferevent *
221  evutil_socket_t fd,
222  mbedtls_dyncontext *ssl,
223  enum bufferevent_ssl_state state,
224  int options);
225 
233 EVENT2_EXPORT_SYMBOL
242 EVENT2_EXPORT_SYMBOL
244  int allow_dirty_shutdown);
245 
247 EVENT2_EXPORT_SYMBOL
248 struct mbedtls_ssl_context *
250 
252 EVENT2_EXPORT_SYMBOL
254 
256 EVENT2_EXPORT_SYMBOL
257 unsigned long bufferevent_get_mbedtls_error(struct bufferevent *bev);
258 
260 EVENT2_EXPORT_SYMBOL
261 mbedtls_dyncontext *
262 bufferevent_mbedtls_dyncontext_new(struct mbedtls_ssl_config *conf);
263 
265 EVENT2_EXPORT_SYMBOL
266 void
267 bufferevent_mbedtls_dyncontext_free(mbedtls_dyncontext *ctx);
268 
269 #endif
270 
271 #ifdef __cplusplus
272 }
273 #endif
274 
275 #endif /* EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ */
bufferevent_mbedtls_get_ssl
EVENT2_EXPORT_SYMBOL struct mbedtls_ssl_context * bufferevent_mbedtls_get_ssl(struct bufferevent *bufev)
Return the underlying mbedtls SSL * object for an SSL bufferevent.
bufferevent_openssl_get_allow_dirty_shutdown
EVENT2_EXPORT_SYMBOL int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev)
Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.
bufferevent_get_mbedtls_error
EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_mbedtls_error(struct bufferevent *bev)
Return the most recent MbedTLS error reported on an SSL bufferevent.
bufferevent_mbedtls_get_allow_dirty_shutdown
EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_get_allow_dirty_shutdown(struct bufferevent *bev)
Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.
bufferevent_ssl_state
bufferevent_ssl_state
The state of an SSL object to be used when creating a new SSL bufferevent.
Definition: bufferevent_ssl.h:46
event_base
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:219
bufferevent_mbedtls_dyncontext_free
EVENT2_EXPORT_SYMBOL void bufferevent_mbedtls_dyncontext_free(mbedtls_dyncontext *ctx)
Deallocate heap-based MbedTLS context.
bufferevent_openssl_filter_new
EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_openssl_filter_new(struct event_base *base, struct bufferevent *underlying, struct ssl_st *ssl, enum bufferevent_ssl_state state, int options)
Create a new SSL bufferevent to send its data over another bufferevent.
bufferevent
An opaque type for handling buffered IO.
Definition: bufferevent.h:114
bufferevent_ssl_renegotiate
EVENT2_EXPORT_SYMBOL int bufferevent_ssl_renegotiate(struct bufferevent *bev)
Tells a bufferevent to begin SSL renegotiation.
bufferevent_mbedtls_filter_new
EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_mbedtls_filter_new(struct event_base *base, struct bufferevent *underlying, mbedtls_dyncontext *ssl, enum bufferevent_ssl_state state, int options)
Create a new SSL bufferevent to send its data over another bufferevent.
bufferevent_openssl_socket_new
EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_openssl_socket_new(struct event_base *base, evutil_socket_t fd, struct ssl_st *ssl, enum bufferevent_ssl_state state, int options)
Create a new SSL bufferevent to send its data over an SSL * on a socket.
bufferevent_mbedtls_socket_new
EVENT2_EXPORT_SYMBOL struct bufferevent * bufferevent_mbedtls_socket_new(struct event_base *base, evutil_socket_t fd, mbedtls_dyncontext *ssl, enum bufferevent_ssl_state state, int options)
Create a new SSL bufferevent to send its data over an SSL * on a socket.
bufferevent_mbedtls_set_allow_dirty_shutdown
EVENT2_EXPORT_SYMBOL void bufferevent_mbedtls_set_allow_dirty_shutdown(struct bufferevent *bev, int allow_dirty_shutdown)
Set value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.
bufferevent.h
Functions for buffering data for network sending or receiving.
bufferevent_openssl_set_allow_dirty_shutdown
EVENT2_EXPORT_SYMBOL void bufferevent_openssl_set_allow_dirty_shutdown(struct bufferevent *bev, int allow_dirty_shutdown)
Set value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.
bufferevent_mbedtls_renegotiate
EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_renegotiate(struct bufferevent *bev)
Tells a bufferevent to begin SSL renegotiation.
util.h
Common convenience functions for cross-platform portability and related socket manipulations.
bufferevent_mbedtls_dyncontext_new
EVENT2_EXPORT_SYMBOL mbedtls_dyncontext * bufferevent_mbedtls_dyncontext_new(struct mbedtls_ssl_config *conf)
Create a new heap-based MbedTLS context for use it in bufferevent_mbedtls_* functions.
bufferevent_get_openssl_error
EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_openssl_error(struct bufferevent *bev)
Return the most recent OpenSSL error reported on an SSL bufferevent.
bufferevent_openssl_get_ssl
EVENT2_EXPORT_SYMBOL struct ssl_st * bufferevent_openssl_get_ssl(struct bufferevent *bufev)
Return the underlying openssl SSL * object for an SSL bufferevent.
evutil_socket_t
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:325