Browse code

tls: renamed tls hooks callbacks to highlight their purpose

Daniel-Constantin Mierla authored on 17/04/2020 10:57:26
Showing 5 changed files
... ...
@@ -330,7 +330,7 @@ static void ser_free(void *ptr, const char *fname, int fline)
330 330
 /*
331 331
  * Initialize TLS socket
332 332
  */
333
-int tls_h_init_si(struct socket_info *si)
333
+int tls_h_init_si_f(struct socket_info *si)
334 334
 {
335 335
 	int ret;
336 336
 	/*
... ...
@@ -620,7 +620,7 @@ int tls_pre_init(void)
620 620
  * tls mod pre-init function
621 621
  * - executed before any mod_init()
622 622
  */
623
-int tls_mod_pre_init_h(void)
623
+int tls_h_mod_pre_init_f(void)
624 624
 {
625 625
 	if(tls_mod_preinitialized==1) {
626 626
 		LM_DBG("already mod pre-initialized\n");
... ...
@@ -642,7 +642,7 @@ int tls_mod_pre_init_h(void)
642 642
 /*
643 643
  * First step of TLS initialization
644 644
  */
645
-int init_tls_h(void)
645
+int tls_h_mod_init_f(void)
646 646
 {
647 647
 	/*struct socket_info* si;*/
648 648
 	long ssl_version;
... ...
@@ -852,9 +852,9 @@ int tls_check_sockets(tls_domains_cfg_t* cfg)
852 852
 
853 853
 
854 854
 /*
855
- * TLS cleanup when SER exits
855
+ * TLS cleanup when application exits
856 856
  */
857
-void destroy_tls_h(void)
857
+void tls_h_mod_destroy_f(void)
858 858
 {
859 859
 	LM_DBG("tls module final tls destroy\n");
860 860
 	if(tls_mod_preinitialized > 0)
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * TLS module
3 3
  *
4 4
  * Copyright (C) 2005,2006 iptelorg GmbH
... ...
@@ -64,24 +64,24 @@ int tls_pre_init(void);
64 64
 /**
65 65
  * just once, prepare for init of all modules
66 66
  */
67
-int tls_mod_pre_init_h(void);
67
+int tls_h_mod_pre_init_f(void);
68 68
 
69 69
 /*
70 70
  * just once, initialize the tls subsystem after all mod inits
71 71
  */
72
-int init_tls_h(void);
72
+int tls_h_mod_init_f(void);
73 73
 
74 74
 
75 75
 /*
76
- * just once before cleanup 
76
+ * just once before final cleanup
77 77
  */
78
-void destroy_tls_h(void);
78
+void tls_h_mod_destroy_f(void);
79 79
 
80 80
 
81 81
 /*
82
- * for each socket 
82
+ * for each socket
83 83
  */
84
-int tls_h_init_si(struct socket_info *si);
84
+int tls_h_init_si_f(struct socket_info *si);
85 85
 
86 86
 /*
87 87
  * Make sure that all server domains in the configuration have corresponding
... ...
@@ -268,15 +268,15 @@ struct module_exports exports = {
268 268
 
269 269
 
270 270
 static struct tls_hooks tls_h = {
271
-	tls_read_f,
272
-	tls_encode_f,
273
-	tls_h_tcpconn_init,
274
-	tls_h_tcpconn_clean,
275
-	tls_h_close,
276
-	tls_h_init_si,
277
-	init_tls_h,
278
-	destroy_tls_h,
279
-	tls_mod_pre_init_h,
271
+	tls_h_read_f,
272
+	tls_h_encode_f,
273
+	tls_h_tcpconn_init_f,
274
+	tls_h_tcpconn_clean_f,
275
+	tls_h_tcpconn_close_f,
276
+	tls_h_init_si_f,
277
+	tls_h_mod_init_f,
278
+	tls_h_mod_destroy_f,
279
+	tls_h_mod_pre_init_f,
280 280
 };
281 281
 
282 282
 
... ...
@@ -396,7 +396,7 @@ static int mod_init(void)
396 396
 	}
397 397
 	return 0;
398 398
 error:
399
-	destroy_tls_h();
399
+	tls_h_mod_destroy_f();
400 400
 	return -1;
401 401
 }
402 402
 
... ...
@@ -627,7 +627,7 @@ err:
627 627
  * @param sock - socket (unused for now).
628 628
  * @return  0 on success, < 0 on error.
629 629
  */
630
-int tls_h_tcpconn_init(struct tcp_connection *c, int sock)
630
+int tls_h_tcpconn_init_f(struct tcp_connection *c, int sock)
631 631
 {
632 632
 	c->type = PROTO_TLS;
633 633
 	c->rcv.proto = PROTO_TLS;
... ...
@@ -640,7 +640,7 @@ int tls_h_tcpconn_init(struct tcp_connection *c, int sock)
640 640
 
641 641
 /** clean the extra data upon connection shut down.
642 642
  */
643
-void tls_h_tcpconn_clean(struct tcp_connection *c)
643
+void tls_h_tcpconn_clean_f(struct tcp_connection *c)
644 644
 {
645 645
 	struct tls_extra_data* extra;
646 646
 	/*
... ...
@@ -668,7 +668,7 @@ void tls_h_tcpconn_clean(struct tcp_connection *c)
668 668
 
669 669
 /** perform one-way shutdown, do not wait for notify from the remote peer.
670 670
  */
671
-void tls_h_close(struct tcp_connection *c, int fd)
671
+void tls_h_tcpconn_close_f(struct tcp_connection *c, int fd)
672 672
 {
673 673
 	unsigned char wr_buf[TLS_WR_MBUF_SZ];
674 674
 	struct tls_mbuf rd, wr;
... ...
@@ -740,7 +740,7 @@ typedef int (*tcp_low_level_send_t)(int fd, struct tcp_connection *c,
740 740
  *                     the message.
741 741
  * @return *plen on success (>=0), < 0 on error.
742 742
  */
743
-int tls_encode_f(struct tcp_connection *c,
743
+int tls_h_encode_f(struct tcp_connection *c,
744 744
 						const char** pbuf, unsigned int* plen,
745 745
 						const char** rest_buf, unsigned int* rest_len,
746 746
 						snd_flags_t* send_flags)
... ...
@@ -991,7 +991,7 @@ ssl_eof:
991 991
  *         tcp connection flags and might set c->state and r->error on
992 992
  *         EOF or error).
993 993
  */
994
-int tls_read_f(struct tcp_connection* c, int* flags)
994
+int tls_h_read_f(struct tcp_connection* c, int* flags)
995 995
 {
996 996
 	struct tcp_req* r;
997 997
 	int bytes_free, bytes_read, read_size, ssl_error, ssl_read;
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * TLS module - main server part
3
- * 
3
+ *
4 4
  * Copyright (C) 2005-2010 iptelorg GmbH
5 5
  *
6 6
  * This file is part of Kamailio, a free SIP server.
... ...
@@ -55,8 +55,8 @@ struct tls_extra_data {
55 55
 	tls_domains_cfg_t* cfg; /* Configuration used for this connection */
56 56
 	SSL* ssl;               /* SSL context used for the connection */
57 57
 	BIO* rwbio;             /* bio used for read/write
58
-							   (openssl code might add buffering BIOs so
59
-							    it's better to remember our original BIO) */
58
+							 * (openssl code might add buffering BIOs so
59
+							 * it's better to remember our original BIO) */
60 60
 	tls_ct_q* ct_wq;
61 61
 	struct tls_rd_buf* enc_rd_buf;
62 62
 	unsigned int flags;
... ...
@@ -69,26 +69,25 @@ struct tls_extra_data {
69 69
 
70 70
 
71 71
 /*
72
- * Called when new tcp connection is accepted 
72
+ * Called when new tcp connection is accepted
73 73
  */
74
-int tls_h_tcpconn_init(struct tcp_connection *c, int sock);
74
+int tls_h_tcpconn_init_f(struct tcp_connection *c, int sock);
75 75
 
76 76
 /*
77
- * clean the extra data upon connection shut down 
77
+ * clean the extra data upon connection shut down
78 78
  */
79
-void tls_h_tcpconn_clean(struct tcp_connection *c);
79
+void tls_h_tcpconn_clean_f(struct tcp_connection *c);
80 80
 
81 81
 /*
82
- * shut down the TLS connection 
82
+ * shut down the TLS connection
83 83
  */
84
-void tls_h_close(struct tcp_connection *c, int fd);
84
+void tls_h_tcpconn_close_f(struct tcp_connection *c, int fd);
85 85
 
86
-int tls_encode_f(struct tcp_connection *c,
87
-					const char ** pbuf, unsigned int* plen,
88
-						const char** rest_buf, unsigned int* rest_len,
89
-						snd_flags_t* send_flags) ;
86
+int tls_h_encode_f(struct tcp_connection *c, const char ** pbuf,
87
+		unsigned int* plen, const char** rest_buf, unsigned int* rest_len,
88
+		snd_flags_t* send_flags) ;
90 89
 
91
-int tls_read_f(struct tcp_connection *c, int* flags);
90
+int tls_h_read_f(struct tcp_connection *c, int* flags);
92 91
 
93 92
 int tls_h_fix_read_conn(struct tcp_connection *c);
94 93