Skip to content

Commit

Permalink
tls: renamed tls hooks callbacks to highlight their purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 17, 2020
1 parent c68d783 commit c26f40b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 41 deletions.
10 changes: 5 additions & 5 deletions src/modules/tls/tls_init.c
Expand Up @@ -330,7 +330,7 @@ static void ser_free(void *ptr, const char *fname, int fline)
/*
* Initialize TLS socket
*/
int tls_h_init_si(struct socket_info *si)
int tls_h_init_si_f(struct socket_info *si)
{
int ret;
/*
Expand Down Expand Up @@ -620,7 +620,7 @@ int tls_pre_init(void)
* tls mod pre-init function
* - executed before any mod_init()
*/
int tls_mod_pre_init_h(void)
int tls_h_mod_pre_init_f(void)
{
if(tls_mod_preinitialized==1) {
LM_DBG("already mod pre-initialized\n");
Expand All @@ -642,7 +642,7 @@ int tls_mod_pre_init_h(void)
/*
* First step of TLS initialization
*/
int init_tls_h(void)
int tls_h_mod_init_f(void)
{
/*struct socket_info* si;*/
long ssl_version;
Expand Down Expand Up @@ -852,9 +852,9 @@ int tls_check_sockets(tls_domains_cfg_t* cfg)


/*
* TLS cleanup when SER exits
* TLS cleanup when application exits
*/
void destroy_tls_h(void)
void tls_h_mod_destroy_f(void)
{
LM_DBG("tls module final tls destroy\n");
if(tls_mod_preinitialized > 0)
Expand Down
14 changes: 7 additions & 7 deletions src/modules/tls/tls_init.h
@@ -1,4 +1,4 @@
/*
/*
* TLS module
*
* Copyright (C) 2005,2006 iptelorg GmbH
Expand Down Expand Up @@ -64,24 +64,24 @@ int tls_pre_init(void);
/**
* just once, prepare for init of all modules
*/
int tls_mod_pre_init_h(void);
int tls_h_mod_pre_init_f(void);

/*
* just once, initialize the tls subsystem after all mod inits
*/
int init_tls_h(void);
int tls_h_mod_init_f(void);


/*
* just once before cleanup
* just once before final cleanup
*/
void destroy_tls_h(void);
void tls_h_mod_destroy_f(void);


/*
* for each socket
* for each socket
*/
int tls_h_init_si(struct socket_info *si);
int tls_h_init_si_f(struct socket_info *si);

/*
* Make sure that all server domains in the configuration have corresponding
Expand Down
20 changes: 10 additions & 10 deletions src/modules/tls/tls_mod.c
Expand Up @@ -268,15 +268,15 @@ struct module_exports exports = {


static struct tls_hooks tls_h = {
tls_read_f,
tls_encode_f,
tls_h_tcpconn_init,
tls_h_tcpconn_clean,
tls_h_close,
tls_h_init_si,
init_tls_h,
destroy_tls_h,
tls_mod_pre_init_h,
tls_h_read_f,
tls_h_encode_f,
tls_h_tcpconn_init_f,
tls_h_tcpconn_clean_f,
tls_h_tcpconn_close_f,
tls_h_init_si_f,
tls_h_mod_init_f,
tls_h_mod_destroy_f,
tls_h_mod_pre_init_f,
};


Expand Down Expand Up @@ -396,7 +396,7 @@ static int mod_init(void)
}
return 0;
error:
destroy_tls_h();
tls_h_mod_destroy_f();
return -1;
}

Expand Down
10 changes: 5 additions & 5 deletions src/modules/tls/tls_server.c
Expand Up @@ -627,7 +627,7 @@ static int tls_shutdown(struct tcp_connection *c)
* @param sock - socket (unused for now).
* @return 0 on success, < 0 on error.
*/
int tls_h_tcpconn_init(struct tcp_connection *c, int sock)
int tls_h_tcpconn_init_f(struct tcp_connection *c, int sock)
{
c->type = PROTO_TLS;
c->rcv.proto = PROTO_TLS;
Expand All @@ -640,7 +640,7 @@ int tls_h_tcpconn_init(struct tcp_connection *c, int sock)

/** clean the extra data upon connection shut down.
*/
void tls_h_tcpconn_clean(struct tcp_connection *c)
void tls_h_tcpconn_clean_f(struct tcp_connection *c)
{
struct tls_extra_data* extra;
/*
Expand Down Expand Up @@ -668,7 +668,7 @@ void tls_h_tcpconn_clean(struct tcp_connection *c)

/** perform one-way shutdown, do not wait for notify from the remote peer.
*/
void tls_h_close(struct tcp_connection *c, int fd)
void tls_h_tcpconn_close_f(struct tcp_connection *c, int fd)
{
unsigned char wr_buf[TLS_WR_MBUF_SZ];
struct tls_mbuf rd, wr;
Expand Down Expand Up @@ -740,7 +740,7 @@ typedef int (*tcp_low_level_send_t)(int fd, struct tcp_connection *c,
* the message.
* @return *plen on success (>=0), < 0 on error.
*/
int tls_encode_f(struct tcp_connection *c,
int tls_h_encode_f(struct tcp_connection *c,
const char** pbuf, unsigned int* plen,
const char** rest_buf, unsigned int* rest_len,
snd_flags_t* send_flags)
Expand Down Expand Up @@ -991,7 +991,7 @@ int tls_encode_f(struct tcp_connection *c,
* tcp connection flags and might set c->state and r->error on
* EOF or error).
*/
int tls_read_f(struct tcp_connection* c, int* flags)
int tls_h_read_f(struct tcp_connection* c, int* flags)
{
struct tcp_req* r;
int bytes_free, bytes_read, read_size, ssl_error, ssl_read;
Expand Down
27 changes: 13 additions & 14 deletions src/modules/tls/tls_server.h
@@ -1,6 +1,6 @@
/*
* TLS module - main server part
*
*
* Copyright (C) 2005-2010 iptelorg GmbH
*
* This file is part of Kamailio, a free SIP server.
Expand Down Expand Up @@ -55,8 +55,8 @@ struct tls_extra_data {
tls_domains_cfg_t* cfg; /* Configuration used for this connection */
SSL* ssl; /* SSL context used for the connection */
BIO* rwbio; /* bio used for read/write
(openssl code might add buffering BIOs so
it's better to remember our original BIO) */
* (openssl code might add buffering BIOs so
* it's better to remember our original BIO) */
tls_ct_q* ct_wq;
struct tls_rd_buf* enc_rd_buf;
unsigned int flags;
Expand All @@ -69,26 +69,25 @@ struct tls_extra_data {


/*
* Called when new tcp connection is accepted
* Called when new tcp connection is accepted
*/
int tls_h_tcpconn_init(struct tcp_connection *c, int sock);
int tls_h_tcpconn_init_f(struct tcp_connection *c, int sock);

/*
* clean the extra data upon connection shut down
* clean the extra data upon connection shut down
*/
void tls_h_tcpconn_clean(struct tcp_connection *c);
void tls_h_tcpconn_clean_f(struct tcp_connection *c);

/*
* shut down the TLS connection
* shut down the TLS connection
*/
void tls_h_close(struct tcp_connection *c, int fd);
void tls_h_tcpconn_close_f(struct tcp_connection *c, int fd);

int tls_encode_f(struct tcp_connection *c,
const char ** pbuf, unsigned int* plen,
const char** rest_buf, unsigned int* rest_len,
snd_flags_t* send_flags) ;
int tls_h_encode_f(struct tcp_connection *c, const char ** pbuf,
unsigned int* plen, const char** rest_buf, unsigned int* rest_len,
snd_flags_t* send_flags) ;

int tls_read_f(struct tcp_connection *c, int* flags);
int tls_h_read_f(struct tcp_connection *c, int* flags);

int tls_h_fix_read_conn(struct tcp_connection *c);

Expand Down

0 comments on commit c26f40b

Please sign in to comment.