Add BIO_meth_set_callback_ctrl

Older versions of PostgreSQL use it.

Bug: 412269080
Change-Id: Icb3d4a211de241f764e146de262b91123d165b95
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78832
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
diff --git a/crypto/bio/bio.cc b/crypto/bio/bio.cc
index de56d21..f663882 100644
--- a/crypto/bio/bio.cc
+++ b/crypto/bio/bio.cc
@@ -625,6 +625,13 @@
   return 1;
 }
 
+int BIO_meth_set_callback_ctrl(BIO_METHOD *method,
+                               long (*callback_ctrl_func)(BIO *, int,
+                                                          BIO_info_cb *)) {
+  method->callback_ctrl = callback_ctrl_func;
+  return 1;
+}
+
 void BIO_set_data(BIO *bio, void *ptr) { bio->ptr = ptr; }
 
 void *BIO_get_data(BIO *bio) { return bio->ptr; }
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index ca5ee4e..f5c8dee 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -684,6 +684,11 @@
                                      long (*ctrl_func)(BIO *, int, long,
                                                        void *));
 
+// BIO_meth_set_callback_ctrl sets the implementation of |BIO_callback_ctrl| for
+// |method| and returns one.
+OPENSSL_EXPORT int BIO_meth_set_callback_ctrl(
+    BIO_METHOD *method, long (*callback_ctrl_func)(BIO *, int, BIO_info_cb *));
+
 // BIO_set_data sets custom data on |bio|. It may be retried with
 // |BIO_get_data|.
 //