const BIO_METHOD *BIO_f_tap(void) { static BIO_METHOD *tap = NULL; if (tap == NULL) { tap = BIO_meth_new(BIO_TYPE_START | BIO_TYPE_FILTER, "tap"); if (tap != NULL) { BIO_meth_set_write_ex(tap, tap_write_ex); BIO_meth_set_read_ex(tap, tap_read_ex); BIO_meth_set_puts(tap, tap_puts); BIO_meth_set_gets(tap, tap_gets); BIO_meth_set_ctrl(tap, tap_ctrl); BIO_meth_set_create(tap, tap_new); BIO_meth_set_destroy(tap, tap_free); BIO_meth_set_callback_ctrl(tap, tap_callback_ctrl); } } return tap; }
BIO_METHOD* BIO_s_rdp_tls(void) { static BIO_METHOD* bio_methods = NULL; if (bio_methods == NULL) { if (!(bio_methods = BIO_meth_new(BIO_TYPE_RDP_TLS, "RdpTls"))) return NULL; BIO_meth_set_write(bio_methods, bio_rdp_tls_write); BIO_meth_set_read(bio_methods, bio_rdp_tls_read); BIO_meth_set_puts(bio_methods, bio_rdp_tls_puts); BIO_meth_set_gets(bio_methods, bio_rdp_tls_gets); BIO_meth_set_ctrl(bio_methods, bio_rdp_tls_ctrl); BIO_meth_set_create(bio_methods, bio_rdp_tls_new); BIO_meth_set_destroy(bio_methods, bio_rdp_tls_free); BIO_meth_set_callback_ctrl(bio_methods, bio_rdp_tls_callback_ctrl); } return bio_methods; }
static BIO_METHOD * my_BIO_s_socket(void) { if (!my_bio_methods) { BIO_METHOD *biom = (BIO_METHOD *) BIO_s_socket(); #ifdef HAVE_BIO_METH_NEW int my_bio_index; my_bio_index = BIO_get_new_index(); if (my_bio_index == -1) return NULL; my_bio_methods = BIO_meth_new(my_bio_index, "PostgreSQL backend socket"); if (!my_bio_methods) return NULL; if (!BIO_meth_set_write(my_bio_methods, my_sock_write) || !BIO_meth_set_read(my_bio_methods, my_sock_read) || !BIO_meth_set_gets(my_bio_methods, BIO_meth_get_gets(biom)) || !BIO_meth_set_puts(my_bio_methods, BIO_meth_get_puts(biom)) || !BIO_meth_set_ctrl(my_bio_methods, BIO_meth_get_ctrl(biom)) || !BIO_meth_set_create(my_bio_methods, BIO_meth_get_create(biom)) || !BIO_meth_set_destroy(my_bio_methods, BIO_meth_get_destroy(biom)) || !BIO_meth_set_callback_ctrl(my_bio_methods, BIO_meth_get_callback_ctrl(biom))) { BIO_meth_free(my_bio_methods); my_bio_methods = NULL; return NULL; } #else my_bio_methods = malloc(sizeof(BIO_METHOD)); if (!my_bio_methods) return NULL; memcpy(my_bio_methods, biom, sizeof(BIO_METHOD)); my_bio_methods->bread = my_sock_read; my_bio_methods->bwrite = my_sock_write; #endif } return my_bio_methods; }
/** returns a custom tls_mbuf BIO. */ BIO_METHOD* tls_BIO_mbuf(void) { #if OPENSSL_VERSION_NUMBER < 0x010100000L return &tls_mbuf_method; #else if(tls_mbuf_method != NULL) { return tls_mbuf_method; } tls_mbuf_method = BIO_meth_new(BIO_TYPE_TLS_MBUF, "sr_tls_mbuf"); if(tls_mbuf_method==NULL) { LM_ERR("cannot get a new bio method structure\n"); return NULL; } BIO_meth_set_write(tls_mbuf_method, tls_bio_mbuf_write); BIO_meth_set_read(tls_mbuf_method, tls_bio_mbuf_read); BIO_meth_set_puts(tls_mbuf_method, tls_bio_mbuf_puts); BIO_meth_set_gets(tls_mbuf_method, NULL); BIO_meth_set_ctrl(tls_mbuf_method, tls_bio_mbuf_ctrl); BIO_meth_set_create(tls_mbuf_method, tls_bio_mbuf_new); BIO_meth_set_destroy(tls_mbuf_method, tls_bio_mbuf_free); BIO_meth_set_callback_ctrl(tls_mbuf_method, NULL); return tls_mbuf_method; #endif }