* success, -1 on failure. */
static int bio_filter_out_flush(BIO *bio)
{
- bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)(bio->ptr);
+ bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)BIO_get_data(bio);
apr_bucket *e;
AP_DEBUG_ASSERT(APR_BRIGADE_EMPTY(outctx->bb));
static int bio_filter_create(BIO *bio)
{
- bio->shutdown = 1;
- bio->init = 1;
+ BIO_set_shutdown(bio, 1);
+ BIO_set_init(bio, 1);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ /* No setter method for OpenSSL 1.1.0 available,
+ * but I can't find any functional use of the
+ * "num" field there either.
+ */
bio->num = -1;
- bio->ptr = NULL;
+#endif
+ BIO_set_data(bio, NULL);
return 1;
}
static int bio_filter_out_read(BIO *bio, char *out, int outl)
{
/* this is never called */
- bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)(bio->ptr);
+ bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, outctx->c,
"BUG: %s() should not be called", "bio_filter_out_read");
AP_DEBUG_ASSERT(0);
static int bio_filter_out_write(BIO *bio, const char *in, int inl)
{
- bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)(bio->ptr);
+ bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)BIO_get_data(bio);
apr_bucket *e;
int need_flush;
static long bio_filter_out_ctrl(BIO *bio, int cmd, long num, void *ptr)
{
long ret = 1;
- bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)(bio->ptr);
+ bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)BIO_get_data(bio);
switch (cmd) {
case BIO_CTRL_RESET:
ret = 0;
break;
case BIO_CTRL_GET_CLOSE:
- ret = (long)bio->shutdown;
+ ret = (long)BIO_get_shutdown(bio);
break;
case BIO_CTRL_SET_CLOSE:
- bio->shutdown = (int)num;
+ BIO_set_shutdown(bio, (int)num);
break;
case BIO_CTRL_FLUSH:
ret = bio_filter_out_flush(bio);
static int bio_filter_out_gets(BIO *bio, char *buf, int size)
{
/* this is never called */
- bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)(bio->ptr);
+ bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, outctx->c,
"BUG: %s() should not be called", "bio_filter_out_gets");
AP_DEBUG_ASSERT(0);
static int bio_filter_out_puts(BIO *bio, const char *str)
{
/* this is never called */
- bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)(bio->ptr);
+ bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, outctx->c,
"BUG: %s() should not be called", "bio_filter_out_puts");
AP_DEBUG_ASSERT(0);
return -1;
}
-static BIO_METHOD bio_filter_out_method = {
- BIO_TYPE_MEM,
- "APR output filter",
- bio_filter_out_write,
- bio_filter_out_read, /* read is never called */
- bio_filter_out_puts, /* puts is never called */
- bio_filter_out_gets, /* gets is never called */
- bio_filter_out_ctrl,
- bio_filter_create,
- bio_filter_destroy,
- NULL
-};
-
typedef struct {
int length;
char *value;
static int bio_filter_in_read(BIO *bio, char *in, int inlen)
{
apr_size_t inl = inlen;
- bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)(bio->ptr);
+ bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)BIO_get_data(bio);
apr_read_type_e block = inctx->block;
inctx->rc = APR_SUCCESS;
static int bio_filter_in_write(BIO *bio, const char *in, int inl)
{
- bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)(bio->ptr);
+ bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, inctx->f->c,
"BUG: %s() should not be called", "bio_filter_in_write");
AP_DEBUG_ASSERT(0);
static int bio_filter_in_puts(BIO *bio, const char *str)
{
- bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)(bio->ptr);
+ bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, inctx->f->c,
"BUG: %s() should not be called", "bio_filter_in_puts");
AP_DEBUG_ASSERT(0);
static int bio_filter_in_gets(BIO *bio, char *buf, int size)
{
- bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)(bio->ptr);
+ bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, inctx->f->c,
"BUG: %s() should not be called", "bio_filter_in_gets");
AP_DEBUG_ASSERT(0);
static long bio_filter_in_ctrl(BIO *bio, int cmd, long num, void *ptr)
{
- bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)(bio->ptr);
+ bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)BIO_get_data(bio);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, inctx->f->c,
"BUG: %s() should not be called", "bio_filter_in_ctrl");
AP_DEBUG_ASSERT(0);
return -1;
}
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+
+static BIO_METHOD bio_filter_out_method = {
+ BIO_TYPE_MEM,
+ "APR output filter",
+ bio_filter_out_write,
+ bio_filter_out_read, /* read is never called */
+ bio_filter_out_puts, /* puts is never called */
+ bio_filter_out_gets, /* gets is never called */
+ bio_filter_out_ctrl,
+ bio_filter_create,
+ bio_filter_destroy,
+ NULL
+};
+
static BIO_METHOD bio_filter_in_method = {
BIO_TYPE_MEM,
"APR input filter",
NULL
};
+#else
+
+static BIO_METHOD *bio_filter_out_method = NULL;
+static BIO_METHOD *bio_filter_in_method = NULL;
+
+void init_bio_methods(void)
+{
+ bio_filter_out_method = BIO_meth_new(BIO_TYPE_MEM, "APR output filter");
+ BIO_meth_set_write(bio_filter_out_method, &bio_filter_out_write);
+ BIO_meth_set_read(bio_filter_out_method, &bio_filter_out_read); /* read is never called */
+ BIO_meth_set_puts(bio_filter_out_method, &bio_filter_out_puts); /* puts is never called */
+ BIO_meth_set_gets(bio_filter_out_method, &bio_filter_out_gets); /* gets is never called */
+ BIO_meth_set_ctrl(bio_filter_out_method, &bio_filter_out_ctrl);
+ BIO_meth_set_create(bio_filter_out_method, &bio_filter_create);
+ BIO_meth_set_destroy(bio_filter_out_method, &bio_filter_destroy);
+
+ bio_filter_in_method = BIO_meth_new(BIO_TYPE_MEM, "APR input filter");
+ BIO_meth_set_write(bio_filter_in_method, &bio_filter_in_write); /* write is never called */
+ BIO_meth_set_read(bio_filter_in_method, &bio_filter_in_read);
+ BIO_meth_set_puts(bio_filter_in_method, &bio_filter_in_puts); /* puts is never called */
+ BIO_meth_set_gets(bio_filter_in_method, &bio_filter_in_gets); /* gets is never called */
+ BIO_meth_set_ctrl(bio_filter_in_method, &bio_filter_in_ctrl); /* ctrl is never called */
+ BIO_meth_set_create(bio_filter_in_method, &bio_filter_create);
+ BIO_meth_set_destroy(bio_filter_in_method, &bio_filter_destroy);
+}
+
+void free_bio_methods(void)
+{
+ BIO_meth_free(bio_filter_out_method);
+ BIO_meth_free(bio_filter_in_method);
+}
+#endif
static apr_status_t ssl_io_input_read(bio_filter_in_ctx_t *inctx,
char *buf,
return APR_EGENERAL;
}
- outctx = (bio_filter_out_ctx_t *)filter_ctx->pbioWrite->ptr;
+ outctx = (bio_filter_out_ctx_t *)BIO_get_data(filter_ctx->pbioWrite);
res = SSL_write(filter_ctx->pssl, (unsigned char *)data, len);
if (res < 0) {
if ((n = SSL_accept(filter_ctx->pssl)) <= 0) {
bio_filter_in_ctx_t *inctx = (bio_filter_in_ctx_t *)
- (filter_ctx->pbioRead->ptr);
+ BIO_get_data(filter_ctx->pbioRead);
bio_filter_out_ctx_t *outctx = (bio_filter_out_ctx_t *)
- (filter_ctx->pbioWrite->ptr);
+ BIO_get_data(filter_ctx->pbioWrite);
apr_status_t rc = inctx->rc ? inctx->rc : outctx->rc ;
ssl_err = SSL_get_error(filter_ctx->pssl, n);
return ap_pass_brigade(f->next, bb);
}
- inctx = (bio_filter_in_ctx_t *)filter_ctx->pbioRead->ptr;
- outctx = (bio_filter_out_ctx_t *)filter_ctx->pbioWrite->ptr;
+ inctx = (bio_filter_in_ctx_t *)BIO_get_data(filter_ctx->pbioRead);
+ outctx = (bio_filter_out_ctx_t *)BIO_get_data(filter_ctx->pbioWrite);
/* When we are the writer, we must initialize the inctx
* mode so that we block for any required ssl input, because
filter_ctx->pInputFilter = ap_add_input_filter(ssl_io_filter, inctx, r, c);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
filter_ctx->pbioRead = BIO_new(&bio_filter_in_method);
- filter_ctx->pbioRead->ptr = (void *)inctx;
+#else
+ filter_ctx->pbioRead = BIO_new(bio_filter_in_method);
+#endif
+ BIO_set_data(filter_ctx->pbioRead, (void *)inctx);
inctx->ssl = ssl;
inctx->bio_out = filter_ctx->pbioWrite;
filter_ctx->pOutputFilter = ap_add_output_filter(ssl_io_filter,
filter_ctx, r, c);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
filter_ctx->pbioWrite = BIO_new(&bio_filter_out_method);
- filter_ctx->pbioWrite->ptr = (void *)bio_filter_out_ctx_new(filter_ctx, c);
+#else
+ filter_ctx->pbioWrite = BIO_new(bio_filter_out_method);
+#endif
+ BIO_set_data(filter_ctx->pbioWrite, (void *)bio_filter_out_ctx_new(filter_ctx, c));
/* write is non blocking for the benefit of async mpm */
if (c->cs) {