Add custom BIO callback dispatching#10004
Open
julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
Open
Add custom BIO callback dispatching#10004julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
Conversation
Member
julek-wolfssl
commented
Mar 18, 2026
- Route BIO_ctrl_pending, BIO_reset, and BIO_get_mem_data through the custom method's ctrlCb when set, enabling fully custom BIO types to handle these operations.
- Add test_wolfSSL_BIO_custom_method that exercises a custom BIO with all callbacks (create, destroy, read, write, puts, gets, ctrl) and verifies each callback is invoked via bitfield tracking.
- Route BIO_ctrl_pending, BIO_reset, and BIO_get_mem_data through the custom method's ctrlCb when set, enabling fully custom BIO types to handle these operations. - Add test_wolfSSL_BIO_custom_method that exercises a custom BIO with all callbacks (create, destroy, read, write, puts, gets, ctrl) and verifies each callback is invoked via bitfield tracking.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for dispatching additional BIO operations (ctrl_pending, reset, get_mem_data) through a custom BIO method’s ctrlCb, and introduces a new API test exercising a fully-custom BIO method implementation.
Changes:
- Route
wolfSSL_BIO_ctrl_pending,wolfSSL_BIO_reset, andwolfSSL_BIO_get_mem_datathroughbio->method->ctrlCbwhen present. - Add
test_wolfSSL_BIO_custom_methodto validate callback invocation for a custom BIO method. - Register the new test in the ossl_bio test declarations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/api/test_ossl_bio.h | Registers the new custom BIO method test in the ossl_bio test group. |
| tests/api/test_ossl_bio.c | Adds a custom BIO implementation and a test validating callback dispatch and behavior. |
| src/bio.c | Dispatches pending/reset/get_mem_data to a custom method ctrlCb when configured. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+1307
to
+1308
| WOLFSSL_MSG("Calling custom BIO ctrl pending callback"); | ||
| return (size_t)bio->method->ctrlCb(bio, WOLFSSL_BIO_CTRL_PENDING, 0, NULL); |
Comment on lines
+1671
to
+1673
| /* free - should invoke destroyCb */ | ||
| BIO_free(bio); | ||
| BIO_meth_free(method); |
Comment on lines
+1585
to
+1599
| switch (cmd) { | ||
| case BIO_CTRL_PENDING: | ||
| return (long)data->len; | ||
| case BIO_CTRL_RESET: | ||
| data->len = 0; | ||
| return WOLFSSL_SUCCESS; | ||
| case BIO_CTRL_FLUSH: | ||
| return 1; | ||
| case BIO_CTRL_INFO: | ||
| if (parg != NULL) | ||
| *(char**)parg = data->buf; | ||
| return (long)data->len; | ||
| default: | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.