libevent 2.2.1
Event notification library
Loading...
Searching...
No Matches
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
39extern "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
79#define BUFFEREVENT_SSL_BATCH_WRITE 2
80
81#if defined(EVENT__HAVE_OPENSSL) || defined(EVENT__HAVE_MBEDTLS)
88EVENT2_EXPORT_SYMBOL
89ev_uint64_t bufferevent_ssl_get_flags(struct bufferevent *bev);
96EVENT2_EXPORT_SYMBOL
97ev_uint64_t bufferevent_ssl_set_flags(struct bufferevent *bev, ev_uint64_t flags);
104EVENT2_EXPORT_SYMBOL
105ev_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. */
111struct ssl_st;
112
124EVENT2_EXPORT_SYMBOL
125struct bufferevent *
127 struct bufferevent *underlying,
128 struct ssl_st *ssl,
129 enum bufferevent_ssl_state state,
130 int options);
131
142EVENT2_EXPORT_SYMBOL
143struct bufferevent *
146 struct ssl_st *ssl,
147 enum bufferevent_ssl_state state,
148 int options);
149
157EVENT2_EXPORT_SYMBOL
166EVENT2_EXPORT_SYMBOL
168 int allow_dirty_shutdown);
169
171EVENT2_EXPORT_SYMBOL
172struct ssl_st *
174
176EVENT2_EXPORT_SYMBOL
178
180EVENT2_EXPORT_SYMBOL
182
183#endif
184#if defined(EVENT__HAVE_MBEDTLS) || defined(EVENT_IN_DOXYGEN_)
185struct mbedtls_ssl_context;
186struct mbedtls_ssl_config;
187typedef struct mbedtls_ssl_context mbedtls_dyncontext;
188
200EVENT2_EXPORT_SYMBOL
201struct bufferevent *
203 struct bufferevent *underlying,
204 mbedtls_dyncontext *ssl,
205 enum bufferevent_ssl_state state,
206 int options);
207
218EVENT2_EXPORT_SYMBOL
219struct bufferevent *
222 mbedtls_dyncontext *ssl,
223 enum bufferevent_ssl_state state,
224 int options);
225
233EVENT2_EXPORT_SYMBOL
242EVENT2_EXPORT_SYMBOL
244 int allow_dirty_shutdown);
245
247EVENT2_EXPORT_SYMBOL
248struct mbedtls_ssl_context *
250
252EVENT2_EXPORT_SYMBOL
254
256EVENT2_EXPORT_SYMBOL
258
260EVENT2_EXPORT_SYMBOL
261mbedtls_dyncontext *
262bufferevent_mbedtls_dyncontext_new(struct mbedtls_ssl_config *conf);
263
265EVENT2_EXPORT_SYMBOL
266void
267bufferevent_mbedtls_dyncontext_free(mbedtls_dyncontext *ctx);
268
269#endif
270
271#ifdef __cplusplus
272}
273#endif
274
275#endif /* EVENT2_BUFFEREVENT_SSL_H_INCLUDED_ */
Functions for buffering data for network sending or receiving.
EVENT2_EXPORT_SYMBOL struct mbedtls_ssl_context * bufferevent_mbedtls_get_ssl(struct bufferevent *bufev)
Return the underlying mbedtls SSL * object for an SSL bufferevent.
EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_openssl_error(struct bufferevent *bev)
Return the most recent OpenSSL error reported on an SSL bufferevent.
EVENT2_EXPORT_SYMBOL struct ssl_st * bufferevent_openssl_get_ssl(struct bufferevent *bufev)
Return the underlying openssl SSL * object for an SSL bufferevent.
EVENT2_EXPORT_SYMBOL int bufferevent_ssl_renegotiate(struct bufferevent *bev)
Tells a bufferevent to begin SSL renegotiation.
EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_get_allow_dirty_shutdown(struct bufferevent *bev)
Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.
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.
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.
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.
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_ssl_state
The state of an SSL object to be used when creating a new SSL bufferevent.
Definition bufferevent_ssl.h:46
EVENT2_EXPORT_SYMBOL unsigned long bufferevent_get_mbedtls_error(struct bufferevent *bev)
Return the most recent MbedTLS error reported on an SSL bufferevent.
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.
EVENT2_EXPORT_SYMBOL int bufferevent_openssl_get_allow_dirty_shutdown(struct bufferevent *bev)
Get value of the BUFFEREVENT_SSL_DIRTY_SHUTDOWN flag.
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.
EVENT2_EXPORT_SYMBOL int bufferevent_mbedtls_renegotiate(struct bufferevent *bev)
Tells a bufferevent to begin SSL renegotiation.
EVENT2_EXPORT_SYMBOL void bufferevent_mbedtls_dyncontext_free(mbedtls_dyncontext *ctx)
Deallocate heap-based MbedTLS context.
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.
An opaque type for handling buffered IO.
Definition bufferevent.h:116
Structure to hold information and state for a Libevent dispatch loop.
Definition event.h:221
Common convenience functions for cross-platform portability and related socket manipulations.
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition util.h:325