William Lallemand | 24a7a75 | 2017-10-09 14:17:39 +0200 | [diff] [blame] | 1 | #ifndef __TYPES_SHCTX |
| 2 | #define __TYPES_SHCTX |
| 3 | |
| 4 | #include <openssl/ssl.h> /* shared session depend of openssl */ |
| 5 | |
| 6 | #ifndef SHSESS_BLOCK_MIN_SIZE |
| 7 | #define SHSESS_BLOCK_MIN_SIZE 128 |
| 8 | #endif |
| 9 | |
| 10 | #ifndef SHSESS_MAX_DATA_LEN |
| 11 | #define SHSESS_MAX_DATA_LEN 4096 |
| 12 | #endif |
| 13 | |
| 14 | #ifndef SHCTX_APPNAME |
| 15 | #define SHCTX_APPNAME "haproxy" |
| 16 | #endif |
| 17 | |
| 18 | #define SHCTX_E_ALLOC_CACHE -1 |
| 19 | #define SHCTX_E_INIT_LOCK -2 |
| 20 | |
| 21 | struct shared_session { |
| 22 | struct ebmb_node key; |
| 23 | unsigned char key_data[SSL_MAX_SSL_SESSION_ID_LENGTH]; |
| 24 | unsigned char data[SHSESS_BLOCK_MIN_SIZE]; |
| 25 | }; |
| 26 | |
| 27 | struct shared_block { |
| 28 | union { |
| 29 | struct shared_session session; |
| 30 | unsigned char data[sizeof(struct shared_session)]; |
| 31 | } data; |
| 32 | short int data_len; |
| 33 | struct shared_block *p; |
| 34 | struct shared_block *n; |
| 35 | }; |
| 36 | |
| 37 | struct shared_context { |
| 38 | #ifndef USE_PRIVATE_CACHE |
| 39 | #ifdef USE_PTHREAD_PSHARED |
| 40 | pthread_mutex_t mutex; |
| 41 | #else |
| 42 | unsigned int waiters; |
| 43 | #endif |
| 44 | #endif |
| 45 | struct shared_block active; |
| 46 | struct shared_block free; |
| 47 | }; |
| 48 | |
William Lallemand | 3f85c9a | 2017-10-09 16:30:50 +0200 | [diff] [blame^] | 49 | extern struct shared_context *ssl_shctx; |
William Lallemand | 24a7a75 | 2017-10-09 14:17:39 +0200 | [diff] [blame] | 50 | |
| 51 | #endif |