diff options
author | jsing <> | 2021-08-30 19:25:43 +0000 |
---|---|---|
committer | jsing <> | 2021-08-30 19:25:43 +0000 |
commit | 8ee27bd27fc4d672032a04077ba395f9464a3681 (patch) | |
tree | 8e3bea79ab1dea102b95252a7e2c36c06522e41d /src/lib/libssl/ssl_lib.c | |
parent | 2260f3293f3a2c05fbb25d7e447add03b355e61d (diff) | |
download | openbsd-8ee27bd27fc4d672032a04077ba395f9464a3681.tar.gz openbsd-8ee27bd27fc4d672032a04077ba395f9464a3681.tar.bz2 openbsd-8ee27bd27fc4d672032a04077ba395f9464a3681.zip |
Clean up and simplify info and msg callbacks.
The info and msg callbacks result in duplication - both for code that
refers to the function pointers and for the call sites. Avoid this by
providing typedefs for the function pointers and pulling the calling
sequences into their own functions.
ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index bb4b700e0b..c5cc6d05fa 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.262 2021/07/01 17:53:39 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.263 2021/08/30 19:25:43 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1184,9 +1184,7 @@ SSL_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) | |||
1184 | { | 1184 | { |
1185 | switch (cmd) { | 1185 | switch (cmd) { |
1186 | case SSL_CTRL_SET_MSG_CALLBACK: | 1186 | case SSL_CTRL_SET_MSG_CALLBACK: |
1187 | s->internal->msg_callback = (void (*)(int write_p, int version, | 1187 | s->internal->msg_callback = (ssl_msg_callback_fn *)(fp); |
1188 | int content_type, const void *buf, size_t len, | ||
1189 | SSL *ssl, void *arg))(fp); | ||
1190 | return (1); | 1188 | return (1); |
1191 | 1189 | ||
1192 | default: | 1190 | default: |
@@ -1284,9 +1282,7 @@ SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) | |||
1284 | { | 1282 | { |
1285 | switch (cmd) { | 1283 | switch (cmd) { |
1286 | case SSL_CTRL_SET_MSG_CALLBACK: | 1284 | case SSL_CTRL_SET_MSG_CALLBACK: |
1287 | ctx->internal->msg_callback = (void (*)(int write_p, int version, | 1285 | ctx->internal->msg_callback = (ssl_msg_callback_fn *)fp; |
1288 | int content_type, const void *buf, size_t len, SSL *ssl, | ||
1289 | void *arg))(fp); | ||
1290 | return (1); | 1286 | return (1); |
1291 | 1287 | ||
1292 | default: | 1288 | default: |
@@ -2622,6 +2618,26 @@ ssl_clear_cipher_write_state(SSL *s) | |||
2622 | tls12_record_layer_clear_write_state(s->internal->rl); | 2618 | tls12_record_layer_clear_write_state(s->internal->rl); |
2623 | } | 2619 | } |
2624 | 2620 | ||
2621 | void | ||
2622 | ssl_info_callback(const SSL *s, int type, int value) | ||
2623 | { | ||
2624 | ssl_info_callback_fn *cb; | ||
2625 | |||
2626 | if ((cb = s->internal->info_callback) == NULL) | ||
2627 | cb = s->ctx->internal->info_callback; | ||
2628 | if (cb != NULL) | ||
2629 | cb(s, type, value); | ||
2630 | } | ||
2631 | |||
2632 | void | ||
2633 | ssl_msg_callback(SSL *s, int is_write, int content_type, | ||
2634 | const void *msg_buf, size_t msg_len) | ||
2635 | { | ||
2636 | if (s->internal->msg_callback != NULL) | ||
2637 | s->internal->msg_callback(is_write, s->version, content_type, | ||
2638 | msg_buf, msg_len, s, s->internal->msg_callback_arg); | ||
2639 | } | ||
2640 | |||
2625 | /* Fix this function so that it takes an optional type parameter */ | 2641 | /* Fix this function so that it takes an optional type parameter */ |
2626 | X509 * | 2642 | X509 * |
2627 | SSL_get_certificate(const SSL *s) | 2643 | SSL_get_certificate(const SSL *s) |