From fa1d8b4eaa12da11e341239b31833395b52bcbba Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Wed, 13 May 2020 15:46:10 +0200 Subject: [PATCH] REORG: ssl: move ckch_inst functions to src/ssl_ckch.c Move ckch_inst_new() and ckch_inst_free() to src/ssl_ckch.c --- src/ssl_ckch.c | 39 +++++++++++++++++++++++++++++++++++++++ src/ssl_sock.c | 37 ------------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/ssl_ckch.c b/src/ssl_ckch.c index 1a5de31ac..072cd3c18 100644 --- a/src/ssl_ckch.c +++ b/src/ssl_ckch.c @@ -871,3 +871,42 @@ end: return NULL; } + +/******************** ckch_inst functions ******************************/ + +/* unlink a ckch_inst, free all SNIs, free the ckch_inst */ +/* The caller must use the lock of the bind_conf if used with inserted SNIs */ +void ckch_inst_free(struct ckch_inst *inst) +{ + struct sni_ctx *sni, *sni_s; + + if (inst == NULL) + return; + + list_for_each_entry_safe(sni, sni_s, &inst->sni_ctx, by_ckch_inst) { + SSL_CTX_free(sni->ctx); + LIST_DEL(&sni->by_ckch_inst); + ebmb_delete(&sni->name); + free(sni); + } + LIST_DEL(&inst->by_ckchs); + LIST_DEL(&inst->by_crtlist_entry); + free(inst); +} + +/* Alloc and init a ckch_inst */ +struct ckch_inst *ckch_inst_new() +{ + struct ckch_inst *ckch_inst; + + ckch_inst = calloc(1, sizeof *ckch_inst); + if (!ckch_inst) + return NULL; + + LIST_INIT(&ckch_inst->sni_ctx); + LIST_INIT(&ckch_inst->by_ckchs); + LIST_INIT(&ckch_inst->by_crtlist_entry); + + return ckch_inst; +} + diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 792fca860..43ba750ae 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -2692,43 +2692,6 @@ int ssl_sock_load_global_dh_param_from_file(const char *filename) } #endif -/* unlink a ckch_inst, free all SNIs, free the ckch_inst */ -/* The caller must use the lock of the bind_conf if used with inserted SNIs */ -void ckch_inst_free(struct ckch_inst *inst) -{ - struct sni_ctx *sni, *sni_s; - - if (inst == NULL) - return; - - list_for_each_entry_safe(sni, sni_s, &inst->sni_ctx, by_ckch_inst) { - SSL_CTX_free(sni->ctx); - LIST_DEL(&sni->by_ckch_inst); - ebmb_delete(&sni->name); - free(sni); - } - LIST_DEL(&inst->by_ckchs); - LIST_DEL(&inst->by_crtlist_entry); - free(inst); -} - -/* Alloc and init a ckch_inst */ -struct ckch_inst *ckch_inst_new() -{ - struct ckch_inst *ckch_inst; - - ckch_inst = calloc(1, sizeof *ckch_inst); - if (!ckch_inst) - return NULL; - - LIST_INIT(&ckch_inst->sni_ctx); - LIST_INIT(&ckch_inst->by_ckchs); - LIST_INIT(&ckch_inst->by_crtlist_entry); - - return ckch_inst; -} - - /* This function allocates a sni_ctx and adds it to the ckch_inst */ static int ckch_inst_add_cert_sni(SSL_CTX *ctx, struct ckch_inst *ckch_inst, struct bind_conf *s, struct ssl_bind_conf *conf,