From 7fc47fb1fd67ca9212681c6ffdaa77fe0f2e7332 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 11 May 2020 17:28:33 +0000 Subject: Move the record layer callbacks into a struct. This makes the code more readable, requires less code churn when adding a new callback and is likely to avoid bugs due to function argument ordering. ok beck@ inoguchi@ tb@ --- src/lib/libssl/tls13_lib.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/lib/libssl/tls13_lib.c') diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index d3e4050c1e..f096fe633e 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_lib.c,v 1.41 2020/05/10 16:56:11 jsing Exp $ */ +/* $OpenBSD: tls13_lib.c,v 1.42 2020/05/11 17:28:33 jsing Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * Copyright (c) 2019 Bob Beck @@ -332,6 +332,14 @@ tls13_phh_received_cb(void *cb_arg, CBS *cbs) return ret; } +static const struct tls13_record_layer_callbacks rl_callbacks = { + .wire_read = tls13_legacy_wire_read_cb, + .wire_write = tls13_legacy_wire_write_cb, + .alert_recv = tls13_alert_received_cb, + .phh_recv = tls13_phh_received_cb, + .phh_sent = tls13_phh_done_cb, +}; + struct tls13_ctx * tls13_ctx_new(int mode) { @@ -342,9 +350,7 @@ tls13_ctx_new(int mode) ctx->mode = mode; - if ((ctx->rl = tls13_record_layer_new(tls13_legacy_wire_read_cb, - tls13_legacy_wire_write_cb, tls13_alert_received_cb, - tls13_phh_received_cb, tls13_phh_done_cb, ctx)) == NULL) + if ((ctx->rl = tls13_record_layer_new(&rl_callbacks, ctx)) == NULL) goto err; ctx->handshake_message_sent_cb = tls13_legacy_handshake_message_sent_cb; -- cgit v1.2.3-55-g6feb