diff options
author | Paul Querna | 2004-09-27 20:00:52 +0000 |
---|---|---|
committer | Paul Querna | 2004-09-27 20:00:52 +0000 |
commit | 2e1222695cd6c9b6d9a797bd5383e7618c3eea85 (patch) | |
tree | d52e5b19980fad23c3b7fe941d3bafd50d4d812e | |
parent | 7e2b223a9e00d4cc7cd60a198e50c366c64c610a (diff) |
rename structures.
properly prefix all non-static functions with mod_gnutls_
fix build for GnuTLS 1.0.X. (redefine the changed structure names)
-rw-r--r-- | include/mod_gnutls.h | 38 | ||||
-rw-r--r-- | src/gnutls_io.c | 10 | ||||
-rw-r--r-- | src/mod_gnutls.c | 89 |
3 files changed, 79 insertions, 58 deletions
diff --git a/include/mod_gnutls.h b/include/mod_gnutls.h index 70e641f..b1abd52 100644 --- a/include/mod_gnutls.h +++ b/include/mod_gnutls.h | |||
@@ -40,6 +40,21 @@ module AP_MODULE_DECLARE_DATA gnutls_module; | |||
40 | #define GNUTLS_ENABLED_TRUE 1 | 40 | #define GNUTLS_ENABLED_TRUE 1 |
41 | 41 | ||
42 | 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 | |||
43 | typedef struct | 58 | typedef struct |
44 | { | 59 | { |
45 | gnutls_certificate_credentials_t certs; | 60 | gnutls_certificate_credentials_t certs; |
@@ -52,19 +67,18 @@ typedef struct | |||
52 | int macs[16]; | 67 | int macs[16]; |
53 | int protocol[16]; | 68 | int protocol[16]; |
54 | int compression[16]; | 69 | int compression[16]; |
55 | } gnutls_srvconf_rec; | 70 | } mod_gnutls_srvconf_rec; |
56 | 71 | ||
57 | typedef struct gnutls_handle_t gnutls_handle_t; | 72 | typedef struct |
58 | struct gnutls_handle_t | ||
59 | { | 73 | { |
60 | gnutls_srvconf_rec *sc; | 74 | mod_gnutls_srvconf_rec *sc; |
61 | gnutls_session_t session; | 75 | gnutls_session_t session; |
62 | ap_filter_t *input_filter; | 76 | ap_filter_t *input_filter; |
63 | apr_bucket_brigade *input_bb; | 77 | apr_bucket_brigade *input_bb; |
64 | apr_read_type_e input_block; | 78 | apr_read_type_e input_block; |
65 | int status; | 79 | int status; |
66 | int non_https; | 80 | int non_https; |
67 | }; | 81 | } mod_gnutls_handle_t; |
68 | 82 | ||
69 | /** Functions in gnutls_io.c **/ | 83 | /** Functions in gnutls_io.c **/ |
70 | 84 | ||
@@ -79,9 +93,10 @@ struct gnutls_handle_t | |||
79 | * @return result status | 93 | * @return result status |
80 | */ | 94 | */ |
81 | apr_status_t mod_gnutls_filter_input(ap_filter_t * f, | 95 | apr_status_t mod_gnutls_filter_input(ap_filter_t * f, |
82 | apr_bucket_brigade * bb, | 96 | apr_bucket_brigade * bb, |
83 | ap_input_mode_t mode, | 97 | ap_input_mode_t mode, |
84 | apr_read_type_e block, apr_off_t readbytes); | 98 | apr_read_type_e block, |
99 | apr_off_t readbytes); | ||
85 | 100 | ||
86 | /** | 101 | /** |
87 | * mod_gnutls_filter_output will filter the encrypt | 102 | * mod_gnutls_filter_output will filter the encrypt |
@@ -91,7 +106,8 @@ apr_status_t mod_gnutls_filter_input(ap_filter_t * f, | |||
91 | * @param bb the bucket brigade, where to store the result to | 106 | * @param bb the bucket brigade, where to store the result to |
92 | * @return result status | 107 | * @return result status |
93 | */ | 108 | */ |
94 | apr_status_t mod_gnutls_filter_output(ap_filter_t * f, apr_bucket_brigade * bb); | 109 | apr_status_t mod_gnutls_filter_output(ap_filter_t * f, |
110 | apr_bucket_brigade * bb); | ||
95 | 111 | ||
96 | 112 | ||
97 | /** | 113 | /** |
@@ -104,7 +120,7 @@ apr_status_t mod_gnutls_filter_output(ap_filter_t * f, apr_bucket_brigade * bb); | |||
104 | * @return size length of the data stored in buffer | 120 | * @return size length of the data stored in buffer |
105 | */ | 121 | */ |
106 | ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr, | 122 | ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr, |
107 | void *buffer, size_t len); | 123 | void *buffer, size_t len); |
108 | 124 | ||
109 | /** | 125 | /** |
110 | * mod_gnutls_transport_write is called from GnuTLS to | 126 | * mod_gnutls_transport_write is called from GnuTLS to |
@@ -116,7 +132,7 @@ ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr, | |||
116 | * @return size length of the data written | 132 | * @return size length of the data written |
117 | */ | 133 | */ |
118 | ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr, | 134 | ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr, |
119 | const void *buffer, size_t len); | 135 | const void *buffer, size_t len); |
120 | 136 | ||
121 | 137 | ||
122 | #endif /* __mod_gnutls_h_inc */ | 138 | #endif /* __mod_gnutls_h_inc */ |
diff --git a/src/gnutls_io.c b/src/gnutls_io.c index 6b0a15b..1cb14a3 100644 --- a/src/gnutls_io.c +++ b/src/gnutls_io.c | |||
@@ -28,9 +28,9 @@ apr_status_t mod_gnutls_filter_input(ap_filter_t * f, | |||
28 | apr_read_type_e block, | 28 | apr_read_type_e block, |
29 | apr_off_t readbytes) | 29 | apr_off_t readbytes) |
30 | { | 30 | { |
31 | apr_bucket* b; | 31 | apr_bucket *b; |
32 | apr_status_t status = APR_SUCCESS; | 32 | apr_status_t status = APR_SUCCESS; |
33 | gnutls_handle_t *ctxt = (gnutls_handle_t *) f->ctx; | 33 | mod_gnutls_handle_t *ctxt = (mod_gnutls_handle_t *) f->ctx; |
34 | 34 | ||
35 | if (f->c->aborted) { | 35 | if (f->c->aborted) { |
36 | apr_bucket *bucket = apr_bucket_eos_create(f->c->bucket_alloc); | 36 | apr_bucket *bucket = apr_bucket_eos_create(f->c->bucket_alloc); |
@@ -61,7 +61,7 @@ apr_status_t mod_gnutls_filter_output(ap_filter_t * f, | |||
61 | int ret, i; | 61 | int ret, i; |
62 | const char *buf = 0; | 62 | const char *buf = 0; |
63 | apr_size_t bytes = 0; | 63 | apr_size_t bytes = 0; |
64 | gnutls_handle_t *ctxt = (gnutls_handle_t *) f->ctx; | 64 | mod_gnutls_handle_t *ctxt = (mod_gnutls_handle_t *) f->ctx; |
65 | apr_status_t status = APR_SUCCESS; | 65 | apr_status_t status = APR_SUCCESS; |
66 | apr_read_type_e rblock = APR_NONBLOCK_READ; | 66 | apr_read_type_e rblock = APR_NONBLOCK_READ; |
67 | 67 | ||
@@ -256,7 +256,7 @@ static apr_status_t brigade_consume(apr_bucket_brigade * bb, | |||
256 | ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr, | 256 | ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr, |
257 | void *buffer, size_t len) | 257 | void *buffer, size_t len) |
258 | { | 258 | { |
259 | gnutls_handle_t *ctxt = ptr; | 259 | mod_gnutls_handle_t *ctxt = ptr; |
260 | apr_status_t rc; | 260 | apr_status_t rc; |
261 | apr_size_t in = len; | 261 | apr_size_t in = len; |
262 | /* If Len = 0, we don't do anything. */ | 262 | /* If Len = 0, we don't do anything. */ |
@@ -295,7 +295,7 @@ ssize_t mod_gnutls_transport_read(gnutls_transport_ptr_t ptr, | |||
295 | ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr, | 295 | ssize_t mod_gnutls_transport_write(gnutls_transport_ptr_t ptr, |
296 | const void *buffer, size_t len) | 296 | const void *buffer, size_t len) |
297 | { | 297 | { |
298 | gnutls_handle_t *ctxt = ptr; | 298 | mod_gnutls_handle_t *ctxt = ptr; |
299 | 299 | ||
300 | // apr_bucket *bucket = apr_bucket_transient_create(in, inl, | 300 | // apr_bucket *bucket = apr_bucket_transient_create(in, inl, |
301 | // outctx->bb-> | 301 | // outctx->bb-> |
diff --git a/src/mod_gnutls.c b/src/mod_gnutls.c index 14bf319..c34da5a 100644 --- a/src/mod_gnutls.c +++ b/src/mod_gnutls.c | |||
@@ -21,14 +21,14 @@ | |||
21 | GCRY_THREAD_OPTION_PTHREAD_IMPL; | 21 | GCRY_THREAD_OPTION_PTHREAD_IMPL; |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | static apr_status_t gnutls_cleanup_pre_config(void *data) | 24 | static apr_status_t mod_gnutls_cleanup_pre_config(void *data) |
25 | { | 25 | { |
26 | gnutls_global_deinit(); | 26 | gnutls_global_deinit(); |
27 | return APR_SUCCESS; | 27 | return APR_SUCCESS; |
28 | } | 28 | } |
29 | 29 | ||
30 | static int gnutls_hook_pre_config(apr_pool_t * pconf, | 30 | static int mod_gnutls_hook_pre_config(apr_pool_t * pconf, |
31 | apr_pool_t * plog, apr_pool_t * ptemp) | 31 | apr_pool_t * plog, apr_pool_t * ptemp) |
32 | { | 32 | { |
33 | 33 | ||
34 | #if APR_HAS_THREADS | 34 | #if APR_HAS_THREADS |
@@ -37,7 +37,7 @@ static int gnutls_hook_pre_config(apr_pool_t * pconf, | |||
37 | 37 | ||
38 | gnutls_global_init(); | 38 | gnutls_global_init(); |
39 | 39 | ||
40 | apr_pool_cleanup_register(pconf, NULL, gnutls_cleanup_pre_config, | 40 | apr_pool_cleanup_register(pconf, NULL, mod_gnutls_cleanup_pre_config, |
41 | apr_pool_cleanup_null); | 41 | apr_pool_cleanup_null); |
42 | 42 | ||
43 | return OK; | 43 | return OK; |
@@ -46,11 +46,11 @@ static int gnutls_hook_pre_config(apr_pool_t * pconf, | |||
46 | #define DH_BITS 1024 | 46 | #define DH_BITS 1024 |
47 | #define RSA_BITS 512 | 47 | #define RSA_BITS 512 |
48 | 48 | ||
49 | static int gnutls_hook_post_config(apr_pool_t * p, apr_pool_t * plog, | 49 | static int mod_gnutls_hook_post_config(apr_pool_t * p, apr_pool_t * plog, |
50 | apr_pool_t * ptemp, | 50 | apr_pool_t * ptemp, |
51 | server_rec * base_server) | 51 | server_rec * base_server) |
52 | { | 52 | { |
53 | gnutls_srvconf_rec *sc; | 53 | mod_gnutls_srvconf_rec *sc; |
54 | server_rec *s; | 54 | server_rec *s; |
55 | gnutls_dh_params_t dh_params; | 55 | gnutls_dh_params_t dh_params; |
56 | gnutls_rsa_params_t rsa_params; | 56 | gnutls_rsa_params_t rsa_params; |
@@ -63,8 +63,8 @@ static int gnutls_hook_post_config(apr_pool_t * p, apr_pool_t * plog, | |||
63 | // gnutls_rsa_params_generate2(rsa_params, RSA_BITS); | 63 | // gnutls_rsa_params_generate2(rsa_params, RSA_BITS); |
64 | 64 | ||
65 | for (s = base_server; s; s = s->next) { | 65 | for (s = base_server; s; s = s->next) { |
66 | sc = (gnutls_srvconf_rec *) ap_get_module_config(s->module_config, | 66 | sc = (mod_gnutls_srvconf_rec *) ap_get_module_config(s->module_config, |
67 | &gnutls_module); | 67 | &gnutls_module); |
68 | if (sc->cert_file != NULL && sc->key_file != NULL) { | 68 | if (sc->cert_file != NULL && sc->key_file != NULL) { |
69 | gnutls_certificate_set_x509_key_file(sc->certs, sc->cert_file, | 69 | gnutls_certificate_set_x509_key_file(sc->certs, sc->cert_file, |
70 | sc->key_file, | 70 | sc->key_file, |
@@ -84,11 +84,12 @@ static int gnutls_hook_post_config(apr_pool_t * p, apr_pool_t * plog, | |||
84 | return OK; | 84 | return OK; |
85 | } | 85 | } |
86 | 86 | ||
87 | static const char *gnutls_hook_http_method(const request_rec * r) | 87 | static const char *mod_gnutls_hook_http_method(const request_rec * r) |
88 | { | 88 | { |
89 | gnutls_srvconf_rec *sc = | 89 | mod_gnutls_srvconf_rec *sc = |
90 | (gnutls_srvconf_rec *) ap_get_module_config(r->server->module_config, | 90 | (mod_gnutls_srvconf_rec *) ap_get_module_config(r->server-> |
91 | &gnutls_module); | 91 | module_config, |
92 | &gnutls_module); | ||
92 | 93 | ||
93 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { | 94 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { |
94 | return NULL; | 95 | return NULL; |
@@ -97,11 +98,12 @@ static const char *gnutls_hook_http_method(const request_rec * r) | |||
97 | return "https"; | 98 | return "https"; |
98 | } | 99 | } |
99 | 100 | ||
100 | static apr_port_t gnutls_hook_default_port(const request_rec * r) | 101 | static apr_port_t mod_gnutls_hook_default_port(const request_rec * r) |
101 | { | 102 | { |
102 | gnutls_srvconf_rec *sc = | 103 | mod_gnutls_srvconf_rec *sc = |
103 | (gnutls_srvconf_rec *) ap_get_module_config(r->server->module_config, | 104 | (mod_gnutls_srvconf_rec *) ap_get_module_config(r->server-> |
104 | &gnutls_module); | 105 | module_config, |
106 | &gnutls_module); | ||
105 | 107 | ||
106 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { | 108 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { |
107 | return 0; | 109 | return 0; |
@@ -110,13 +112,13 @@ static apr_port_t gnutls_hook_default_port(const request_rec * r) | |||
110 | return 443; | 112 | return 443; |
111 | } | 113 | } |
112 | 114 | ||
113 | static int gnutls_hook_pre_connection(conn_rec * c, void *csd) | 115 | static int mod_gnutls_hook_pre_connection(conn_rec * c, void *csd) |
114 | { | 116 | { |
115 | gnutls_handle_t *ctxt; | 117 | mod_gnutls_handle_t *ctxt; |
116 | gnutls_srvconf_rec *sc = | 118 | mod_gnutls_srvconf_rec *sc = |
117 | (gnutls_srvconf_rec *) ap_get_module_config(c->base_server-> | 119 | (mod_gnutls_srvconf_rec *) ap_get_module_config(c->base_server-> |
118 | module_config, | 120 | module_config, |
119 | &gnutls_module); | 121 | &gnutls_module); |
120 | 122 | ||
121 | if (!(sc && (sc->enabled == GNUTLS_ENABLED_TRUE))) { | 123 | if (!(sc && (sc->enabled == GNUTLS_ENABLED_TRUE))) { |
122 | return DECLINED; | 124 | return DECLINED; |
@@ -160,10 +162,10 @@ static int gnutls_hook_pre_connection(conn_rec * c, void *csd) | |||
160 | static const char *gnutls_set_cert_file(cmd_parms * parms, void *dummy, | 162 | static const char *gnutls_set_cert_file(cmd_parms * parms, void *dummy, |
161 | const char *arg) | 163 | const char *arg) |
162 | { | 164 | { |
163 | gnutls_srvconf_rec *sc = | 165 | mod_gnutls_srvconf_rec *sc = |
164 | (gnutls_srvconf_rec *) ap_get_module_config(parms->server-> | 166 | (mod_gnutls_srvconf_rec *) ap_get_module_config(parms->server-> |
165 | module_config, | 167 | module_config, |
166 | &gnutls_module); | 168 | &gnutls_module); |
167 | sc->cert_file = apr_pstrdup(parms->pool, arg); | 169 | sc->cert_file = apr_pstrdup(parms->pool, arg); |
168 | return NULL; | 170 | return NULL; |
169 | } | 171 | } |
@@ -171,10 +173,10 @@ static const char *gnutls_set_cert_file(cmd_parms * parms, void *dummy, | |||
171 | static const char *gnutls_set_key_file(cmd_parms * parms, void *dummy, | 173 | static const char *gnutls_set_key_file(cmd_parms * parms, void *dummy, |
172 | const char *arg) | 174 | const char *arg) |
173 | { | 175 | { |
174 | gnutls_srvconf_rec *sc = | 176 | mod_gnutls_srvconf_rec *sc = |
175 | (gnutls_srvconf_rec *) ap_get_module_config(parms->server-> | 177 | (mod_gnutls_srvconf_rec *) ap_get_module_config(parms->server-> |
176 | module_config, | 178 | module_config, |
177 | &gnutls_module); | 179 | &gnutls_module); |
178 | sc->key_file = apr_pstrdup(parms->pool, arg); | 180 | sc->key_file = apr_pstrdup(parms->pool, arg); |
179 | return NULL; | 181 | return NULL; |
180 | } | 182 | } |
@@ -182,10 +184,10 @@ static const char *gnutls_set_key_file(cmd_parms * parms, void *dummy, | |||
182 | static const char *gnutls_set_enabled(cmd_parms * parms, void *dummy, | 184 | static const char *gnutls_set_enabled(cmd_parms * parms, void *dummy, |
183 | const char *arg) | 185 | const char *arg) |
184 | { | 186 | { |
185 | gnutls_srvconf_rec *sc = | 187 | mod_gnutls_srvconf_rec *sc = |
186 | (gnutls_srvconf_rec *) ap_get_module_config(parms->server-> | 188 | (mod_gnutls_srvconf_rec *) ap_get_module_config(parms->server-> |
187 | module_config, | 189 | module_config, |
188 | &gnutls_module); | 190 | &gnutls_module); |
189 | if (!strcasecmp(arg, "On")) { | 191 | if (!strcasecmp(arg, "On")) { |
190 | sc->enabled = GNUTLS_ENABLED_TRUE; | 192 | sc->enabled = GNUTLS_ENABLED_TRUE; |
191 | } | 193 | } |
@@ -224,13 +226,16 @@ static const command_rec gnutls_cmds[] = { | |||
224 | 226 | ||
225 | static void gnutls_hooks(apr_pool_t * p) | 227 | static void gnutls_hooks(apr_pool_t * p) |
226 | { | 228 | { |
227 | ap_hook_pre_connection(gnutls_hook_pre_connection, NULL, NULL, | 229 | ap_hook_pre_connection(mod_gnutls_hook_pre_connection, NULL, NULL, |
228 | APR_HOOK_MIDDLE); | 230 | APR_HOOK_MIDDLE); |
229 | ap_hook_post_config(gnutls_hook_post_config, NULL, NULL, APR_HOOK_MIDDLE); | 231 | ap_hook_post_config(mod_gnutls_hook_post_config, NULL, NULL, |
230 | ap_hook_http_method(gnutls_hook_http_method, NULL, NULL, APR_HOOK_MIDDLE); | 232 | APR_HOOK_MIDDLE); |
231 | ap_hook_default_port(gnutls_hook_default_port, NULL, NULL, | 233 | ap_hook_http_method(mod_gnutls_hook_http_method, NULL, NULL, |
234 | APR_HOOK_MIDDLE); | ||
235 | ap_hook_default_port(mod_gnutls_hook_default_port, NULL, NULL, | ||
232 | APR_HOOK_MIDDLE); | 236 | APR_HOOK_MIDDLE); |
233 | ap_hook_pre_config(gnutls_hook_pre_config, NULL, NULL, APR_HOOK_MIDDLE); | 237 | ap_hook_pre_config(mod_gnutls_hook_pre_config, NULL, NULL, |
238 | APR_HOOK_MIDDLE); | ||
234 | 239 | ||
235 | /* TODO: HTTP Upgrade Filter */ | 240 | /* TODO: HTTP Upgrade Filter */ |
236 | /* ap_register_output_filter ("UPGRADE_FILTER", | 241 | /* ap_register_output_filter ("UPGRADE_FILTER", |
@@ -247,7 +252,7 @@ static void gnutls_hooks(apr_pool_t * p) | |||
247 | static void *gnutls_config_server_create(apr_pool_t * p, server_rec * s) | 252 | static void *gnutls_config_server_create(apr_pool_t * p, server_rec * s) |
248 | { | 253 | { |
249 | int i; | 254 | int i; |
250 | gnutls_srvconf_rec *sc = apr_pcalloc(p, sizeof(*sc)); | 255 | mod_gnutls_srvconf_rec *sc = apr_pcalloc(p, sizeof(*sc)); |
251 | 256 | ||
252 | sc->enabled = GNUTLS_ENABLED_FALSE; | 257 | sc->enabled = GNUTLS_ENABLED_FALSE; |
253 | 258 | ||