blob: a09c38c4b74d80002bad4b617a31ccb03ea58a86 [file] [log] [blame]
Emeric Brun3e541d12012-09-03 11:14:36 +02001/*
2 * shctx.h - shared context management functions for SSL
3 *
4 * Copyright (C) 2011-2012 EXCELIANCE
5 *
6 * Author: Emeric Brun - emeric@exceliance.fr
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef SHCTX_H
15#define SHCTX_H
16#include <openssl/ssl.h>
17#include <stdint.h>
18
Emeric Brunaf9619d2012-11-28 18:47:52 +010019#ifndef SHSESS_BLOCK_MIN_SIZE
20#define SHSESS_BLOCK_MIN_SIZE 128
Emeric Brun3e541d12012-09-03 11:14:36 +020021#endif
22
23#ifndef SHSESS_MAX_DATA_LEN
Emeric Brunaf9619d2012-11-28 18:47:52 +010024#define SHSESS_MAX_DATA_LEN 4096
Emeric Brun3e541d12012-09-03 11:14:36 +020025#endif
26
27#ifndef SHCTX_DEFAULT_SIZE
28#define SHCTX_DEFAULT_SIZE 20000
29#endif
30
Emeric Brun786991e2012-11-26 18:37:12 +010031#ifndef SHCTX_APPNAME
32#define SHCTX_APPNAME "haproxy"
33#endif
34
Emeric Brun3e541d12012-09-03 11:14:36 +020035/* Allocate shared memory context.
Emeric Brunaf9619d2012-11-28 18:47:52 +010036 * <size> is the number of allocated blocks into cache (default 128 bytes)
37 * A block is large enough to contain a classic session (without client cert)
38 * If <size> is set less or equal to 0, SHCTX_DEFAULT_SIZE is used.
39 * Set <use_shared_memory> to 1 to use a mapped shared memory instead
40 * of private. (ignored if compiled with USE_PRIVATE_CACHE=1).
41 * Returns: -1 on alloc failure, <size> if it performs context alloc,
42 * and 0 if cache is already allocated.
43 */
Emeric Brun4b3091e2012-09-24 15:48:52 +020044int shared_context_init(int size, int use_shared_memory);
Emeric Brun3e541d12012-09-03 11:14:36 +020045
46/* Set shared cache callbacks on an ssl context.
47 * Set session cache mode to server and disable openssl internal cache.
48 * Shared context MUST be firstly initialized */
49void shared_context_set_cache(SSL_CTX *ctx);
50
51#endif /* SHCTX_H */
52