source: mod_gnutls/src/gnutls_cache.h @ 41f9bcb

asynciodebian/masterproxy-ticket
Last change on this file since 41f9bcb was ded2291, checked in by Fiona Klute <fiona.klute@…>, 3 years ago

Switch generic cache store/fetch function pointers to constant functions

Using socache takes care of the different cache types, so this layer
of abstraction is no longer needed. Add a currently unused mgs_cache_t
parameter to allow for multiple mod_gnutls caches in the future.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[14548b9]1/*
[04e6e65]2 *  Copyright 2004-2005 Paul Querna
3 *  Copyright 2014 Nikos Mavrogiannopoulos
[a85de63]4 *  Copyright 2015-2018 Fiona Klute
[04e6e65]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>
[de1ceab]30#include <ap_socache.h>
[04e6e65]31
[14548b9]32/** Name of the mod_gnutls cache access mutex, for use with Apache's
33 * `Mutex` directive */
[c005645]34#define MGS_CACHE_MUTEX_NAME "gnutls-cache"
35
[04e6e65]36/**
[14548b9]37 * Initialize the internal cache configuration structure. This
38 * function is called after the configuration file(s) have been
39 * parsed.
[104e881]40 *
[de1ceab]41 * @param pconf configuration memory pool
42 * @param ptemp temporary memory pool
[104e881]43 * @param s default server of the Apache configuration, head of the
44 * server list
45 * @param sc mod_gnutls data associated with `s`
[04e6e65]46 */
[de1ceab]47int mgs_cache_post_config(apr_pool_t *pconf, apr_pool_t *ptemp,
48                          server_rec *s, mgs_srvconf_rec *sc);
[04e6e65]49
50/**
[104e881]51 * (Re-)Initialize the cache in a child process after forking.
52 *
53 * @param p child memory pool provided by Apache
54 * @param s default server of the Apache configuration, head of the
55 * server list
56 * @param sc mod_gnutls data associated with `s`
[04e6e65]57 */
58int mgs_cache_child_init(apr_pool_t *p, server_rec *s, mgs_srvconf_rec *sc);
59
60/**
[104e881]61 * Set up caching for the given TLS session.
[14548b9]62 *
63 * @param ctxt mod_gnutls session context
[104e881]64 *
[14548b9]65 * @return 0
[04e6e65]66 */
67int mgs_cache_session_init(mgs_handle_t *ctxt);
68
69
70
71/**
[14548b9]72 * Convert a `time_t` into a null terminated string in a format
[104e881]73 * compatible with OpenSSL's `ASN1_TIME_print()`.
[0831437]74 *
[04e6e65]75 * @param t time_t time
[0831437]76 * @param str Location to store the time string
[14548b9]77 * @param strsize The maximum length that can be stored in `str`
[104e881]78 *
[14548b9]79 * @return `str`
[04e6e65]80 */
81char *mgs_time2sz(time_t t, char *str, int strsize);
82
[14548b9]83/**
[ded2291]84 * Store function for the mod_gnutls object caches.
[14548b9]85 *
[ded2291]86 * @param cache the cache to store the entry in
[14548b9]87 * @param s server associated with the cache entry
88 * @param key key for the cache entry
89 * @param data data to be cached
90 * @param expiry expiration time
[104e881]91 *
92 * @return `-1` on error, `0` on success
[6b4136c]93 */
[ded2291]94int mgs_cache_store(mgs_cache_t cache, server_rec *server, gnutls_datum_t key,
95                    gnutls_datum_t data, apr_time_t expiry);
96
[14548b9]97/**
[ded2291]98 * Fetch function for the mod_gnutls object caches.
[104e881]99 *
100 * *Warning*: The `data` element of the returned `gnutls_datum_t` is
101 * allocated using `gnutls_malloc()` for compatibility with the GnuTLS
102 * session caching API, and must be released using `gnutls_free()`.
[14548b9]103 *
[ded2291]104 * @param cache the cache to fetch from
105 *
[a85de63]106 * @param server server context for the request
107 *
[14548b9]108 * @param key key for the cache entry to be fetched
[104e881]109 *
[a85de63]110 * @param pool pool to allocate the response and other temporary
111 * memory from
112 *
[14548b9]113 * @return the requested cache entry, or `{NULL, 0}`
114 */
[ded2291]115gnutls_datum_t mgs_cache_fetch(mgs_cache_t cache, server_rec *server,
116                               gnutls_datum_t key, apr_pool_t *pool);
117
[14548b9]118/**
119 * Internal cache configuration structure
120 */
[e809fb3]121struct mgs_cache {
[de1ceab]122    /** Socache provider to use for this cache */
123    const ap_socache_provider_t *prov;
124    /** The actual socache instance */
125    ap_socache_instance_t *socache;
[14548b9]126    /** Mutex for cache access (used only if the cache type is not
[aa68232]127     * thread-safe) */
128    apr_global_mutex_t *mutex;
[e809fb3]129};
[6b4136c]130
[04e6e65]131#endif /** __MOD_GNUTLS_CACHE_H__ */
Note: See TracBrowser for help on using the repository browser.