]> git.ipfire.org Git - thirdparty/squid.git/blob - src/security/Session.h
merge from trunk-r14768
[thirdparty/squid.git] / src / security / Session.h
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 #ifndef SQUID_SRC_SECURITY_SESSION_H
10 #define SQUID_SRC_SECURITY_SESSION_H
11
12 #include "security/LockingPointer.h"
13
14 #include <memory>
15
16 #if USE_OPENSSL
17 #if HAVE_OPENSSL_SSL_H
18 #include <openssl/ssl.h>
19 #endif
20 #endif
21
22 #if USE_GNUTLS
23 #if HAVE_GNUTLS_GNUTLS_H
24 #include <gnutls/gnutls.h>
25 #endif
26 #endif
27
28 namespace Security {
29
30 #if USE_OPENSSL
31 typedef SSL* SessionPtr;
32 CtoCpp1(SSL_free, SSL *);
33 typedef LockingPointer<SSL, Security::SSL_free_cpp, CRYPTO_LOCK_SSL> SessionPointer;
34
35 #elif USE_GNUTLS
36 typedef gnutls_session_t SessionPtr;
37 // Locks can be implemented attaching locks counter to gnutls_session_t
38 // objects using the gnutls_session_set_ptr()/gnutls_session_get_ptr ()
39 // library functions
40 CtoCpp1(gnutls_deinit, gnutls_session_t);
41 typedef LockingPointer<struct gnutls_session_int, gnutls_deinit_cpp, -1> SessionPointer;
42
43 #else
44 // use void* so we can check against NULL
45 typedef void* SessionPtr;
46 CtoCpp1(xfree, SessionPtr);
47 typedef LockingPointer<void, xfree_cpp, -1> SessionPointer;
48
49 #endif
50
51 } // namespace Security
52
53 #endif /* SQUID_SRC_SECURITY_SESSION_H */
54