source: mod_gnutls/include/mod_gnutls.h @ 2e12226

asynciodebian/masterdebian/stretch-backportsjessie-backportsmainmsvaproxy-ticketupstream
Last change on this file since 2e12226 was 2e12226, checked in by Paul Querna <chip@…>, 18 years ago

rename structures.
properly prefix all non-static functions with mod_gnutls_
fix build for GnuTLS 1.0.X. (redefine the changed structure names)

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/* ====================================================================
2 *  Copyright 2004 Paul Querna
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 *
16 */
17
18#ifndef __mod_gnutls_h_inc
19#define __mod_gnutls_h_inc
20
21#include "httpd.h"
22#include "http_config.h"
23#include "http_protocol.h"
24#include "http_connection.h"
25#include "http_core.h"
26#include "http_log.h"
27#include "apr_buckets.h"
28#include "apr_strings.h"
29#include "apr_tables.h"
30
31#include <gcrypt.h>
32#include <gnutls/gnutls.h>
33
34module AP_MODULE_DECLARE_DATA gnutls_module;
35
36#define GNUTLS_OUTPUT_FILTER_NAME "gnutls_output_filter"
37#define GNUTLS_INPUT_FILTER_NAME "gnutls_input_filter"
38
39#define GNUTLS_ENABLED_FALSE 0
40#define GNUTLS_ENABLED_TRUE  1
41
42
43/**
44 * GnuTLS changed the names of several structures between 1.0.X and 1.1.X
45 * This is just a simple hack so we can compile with both versions.
46 * There is a full list in <gnutls/compat.h>, But I am just
47 * doing this for a few types we use.
48 */
49#ifndef gnutls_certificate_credentials_t
50#define gnutls_certificate_credentials_t    gnutls_certificate_credentials
51#define gnutls_anon_server_credentials_t    gnutls_anon_server_credentials
52#define gnutls_session_t                    gnutls_session
53#define gnutls_transport_ptr_t              gnutls_transport_ptr
54#define gnutls_dh_params_t                  gnutls_dh_params
55#define gnutls_rsa_params_t                 gnutls_rsa_params
56#endif
57
58typedef struct
59{
60    gnutls_certificate_credentials_t certs;
61    gnutls_anon_server_credentials_t anoncred;
62    char *key_file;
63    char *cert_file;
64    int enabled;
65    int ciphers[16];
66    int key_exchange[16];
67    int macs[16];
68    int protocol[16];
69    int compression[16];
70} mod_gnutls_srvconf_rec;
71
72typedef struct
73{
74    mod_gnutls_srvconf_rec *sc;
75    gnutls_session_t session;
76    ap_filter_t *input_filter;
77    apr_bucket_brigade *input_bb;
78    apr_read_type_e input_block;
79    int status;
80    int non_https;
81} mod_gnutls_handle_t;
82
83/** Functions in gnutls_io.c **/
84
85/**
86 * mod_gnutls_filter_input will filter the input data
87 * by decrypting it using GnuTLS and passes it cleartext.
88 *
89 * @param f     the filter info record
90 * @param bb    the bucket brigade, where to store the result to
91 * @param mode  what shall we read?
92 * @param block a block index we shall read from?
93 * @return result status
94 */
95apr_status_t mod_gnutls_filter_input(ap_filter_t * f,
96                                     apr_bucket_brigade * bb,
97                                     ap_input_mode_t mode,
98                                     apr_read_type_e block,
99                                     apr_off_t readbytes);
100
101/**
102 * mod_gnutls_filter_output will filter the encrypt
103 * the incoming bucket using GnuTLS and passes it onto the next filter.
104 *
105 * @param f     the filter info record
106 * @param bb    the bucket brigade, where to store the result to
107 * @return result status
108 */
109apr_status_t mod_gnutls_filter_output(ap_filter_t * f,
110                                      apr_bucket_brigade * bb);
111
112
113/**
114 * mod_gnutls_transport_read is called from GnuTLS to provide encrypted
115 * data from the client.
116 *
117 * @param ptr     pointer to the filter context
118 * @param buffer  place to put data
119 * @param len     maximum size
120 * @return size   length of the data stored in buffer
121 */
122ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr,
123                                  void *buffer, size_t len);
124
125/**
126 * mod_gnutls_transport_write is called from GnuTLS to
127 * write data to the client.
128 *
129 * @param ptr     pointer to the filter context
130 * @param buffer  buffer to write to the client
131 * @param len     size of the buffer
132 * @return size   length of the data written
133 */
134ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr,
135                                   const void *buffer, size_t len);
136
137
138#endif /*  __mod_gnutls_h_inc */
Note: See TracBrowser for help on using the repository browser.