source: mod_gnutls/src/gnutls_cache.h @ 154db29

debian/masterdebian/stretch-backportsproxy-ticketupstream mod_gnutls/0.8.1
Last change on this file since 154db29 was 104e881, checked in by Thomas Klute <thomas2.klute@…>, 4 years ago

General comment updates for Doxygen compatibility

Mostly /* */ vs. / */ changes so Doxygen does catch the correct
descriptions instead of e.g. license headers, plus some minor comment
updates.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[14548b9]1/*
[04e6e65]2 *  Copyright 2004-2005 Paul Querna
3 *  Copyright 2014 Nikos Mavrogiannopoulos
4 *  Copyright 2015-2016 Thomas Klute
5 *
6 *  Licensed under the Apache License, Version 2.0 (the "License");
7 *  you may not use this file except in compliance with the License.
8 *  You may obtain a copy of the License at
9 *
10 *      http://www.apache.org/licenses/LICENSE-2.0
11 *
12 *  Unless required by applicable law or agreed to in writing, software
13 *  distributed under the License is distributed on an "AS IS" BASIS,
14 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 *  See the License for the specific language governing permissions and
16 *  limitations under the License.
[14548b9]17 */
18
19/**
20 * @file
[04e6e65]21 *
[104e881]22 * Generic object cache for mod_gnutls.
[04e6e65]23 */
24
25#ifndef __MOD_GNUTLS_CACHE_H__
26#define __MOD_GNUTLS_CACHE_H__
27
28#include "mod_gnutls.h"
29#include <httpd.h>
30
[14548b9]31/** Name of the mod_gnutls cache access mutex, for use with Apache's
32 * `Mutex` directive */
[c005645]33#define MGS_CACHE_MUTEX_NAME "gnutls-cache"
34
[04e6e65]35/**
[14548b9]36 * Initialize the internal cache configuration structure. This
37 * function is called after the configuration file(s) have been
38 * parsed.
[104e881]39 *
40 * @param p configuration memory pool
41 * @param s default server of the Apache configuration, head of the
42 * server list
43 * @param sc mod_gnutls data associated with `s`
[04e6e65]44 */
45int mgs_cache_post_config(apr_pool_t *p, server_rec *s, mgs_srvconf_rec *sc);
46
47/**
[104e881]48 * (Re-)Initialize the cache in a child process after forking.
49 *
50 * @param p child memory pool provided by Apache
51 * @param s default server of the Apache configuration, head of the
52 * server list
53 * @param sc mod_gnutls data associated with `s`
[04e6e65]54 */
55int mgs_cache_child_init(apr_pool_t *p, server_rec *s, mgs_srvconf_rec *sc);
56
57/**
[104e881]58 * Set up caching for the given TLS session.
[14548b9]59 *
60 * @param ctxt mod_gnutls session context
[104e881]61 *
[14548b9]62 * @return 0
[04e6e65]63 */
64int mgs_cache_session_init(mgs_handle_t *ctxt);
65
66
67
68/**
[14548b9]69 * Convert a `time_t` into a null terminated string in a format
[104e881]70 * compatible with OpenSSL's `ASN1_TIME_print()`.
[0831437]71 *
[04e6e65]72 * @param t time_t time
[0831437]73 * @param str Location to store the time string
[14548b9]74 * @param strsize The maximum length that can be stored in `str`
[104e881]75 *
[14548b9]76 * @return `str`
[04e6e65]77 */
78char *mgs_time2sz(time_t t, char *str, int strsize);
79
[14548b9]80/**
[104e881]81 * Generic store function for the mod_gnutls object cache.
[14548b9]82 *
83 * @param s server associated with the cache entry
84 * @param key key for the cache entry
85 * @param data data to be cached
86 * @param expiry expiration time
[104e881]87 *
88 * @return `-1` on error, `0` on success
[6b4136c]89 */
[e809fb3]90typedef int (*cache_store_func)(server_rec *s, gnutls_datum_t key,
91                                gnutls_datum_t data, apr_time_t expiry);
[14548b9]92/**
[104e881]93 * Generic fetch function for the mod_gnutls object cache.
94 *
95 * *Warning*: The `data` element of the returned `gnutls_datum_t` is
96 * allocated using `gnutls_malloc()` for compatibility with the GnuTLS
97 * session caching API, and must be released using `gnutls_free()`.
[14548b9]98 *
99 * @param ctxt mod_gnutls session context for the request
100 * @param key key for the cache entry to be fetched
[104e881]101 *
[14548b9]102 * @return the requested cache entry, or `{NULL, 0}`
103 */
[e809fb3]104typedef gnutls_datum_t (*cache_fetch_func)(mgs_handle_t *ctxt,
105                                           gnutls_datum_t key);
[14548b9]106/**
107 * Internal cache configuration structure
108 */
[e809fb3]109struct mgs_cache {
[14548b9]110    /** Store function for this cache */
[e809fb3]111    cache_store_func store;
[14548b9]112    /** Fetch function for this cache */
[e809fb3]113    cache_fetch_func fetch;
[14548b9]114    /** Mutex for cache access (used only if the cache type is not
[aa68232]115     * thread-safe) */
116    apr_global_mutex_t *mutex;
[e809fb3]117};
[6b4136c]118
[04e6e65]119#endif /** __MOD_GNUTLS_CACHE_H__ */
Note: See TracBrowser for help on using the repository browser.