MEDIUM: init: convert all trivial registration calls to initcalls
This switches explicit calls to various trivial registration methods for
keywords, muxes or protocols from constructors to INITCALL1 at stage
STG_REGISTER. All these calls have in common to consume a single pointer
and return void. Doing this removes 26 constructors. The following calls
were addressed :
- acl_register_keywords
- bind_register_keywords
- cfg_register_keywords
- cli_register_kw
- flt_register_keywords
- http_req_keywords_register
- http_res_keywords_register
- protocol_register
- register_mux_proto
- sample_register_convs
- sample_register_fetches
- srv_register_keywords
- tcp_req_conn_keywords_register
- tcp_req_cont_keywords_register
- tcp_req_sess_keywords_register
- tcp_res_cont_keywords_register
- flt_register_keywords
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index c7951c5..2692668 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -36,6 +36,7 @@
#include <common/config.h>
#include <common/debug.h>
#include <common/errors.h>
+#include <common/initcall.h>
#include <common/mini-clist.h>
#include <common/standard.h>
#include <common/namespace.h>
@@ -90,6 +91,8 @@
.nb_listeners = 0,
};
+INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
+
/* Note: must not be declared <const> as its list will be overwritten */
static struct protocol proto_tcpv6 = {
.name = "tcpv6",
@@ -113,6 +116,8 @@
.nb_listeners = 0,
};
+INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv6);
+
/* Default TCP parameters, got by opening a temporary TCP socket. */
#ifdef TCP_MAXSEG
static THREAD_LOCAL int default_tcp_maxseg = -1;
@@ -1913,6 +1918,8 @@
{ /* END */ },
}};
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
/************************************************************************/
/* All supported bind keywords must be declared here. */
/************************************************************************/
@@ -1960,6 +1967,8 @@
{ NULL, NULL, 0 },
}};
+INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
+
static struct srv_kw_list srv_kws = { "TCP", { }, {
#ifdef TCP_USER_TIMEOUT
{ "tcp-ut", srv_parse_tcp_ut, 1, 1 }, /* set TCP user timeout on server */
@@ -1967,6 +1976,8 @@
{ NULL, NULL, 0 },
}};
+INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws);
+
static struct action_kw_list tcp_req_conn_actions = {ILH, {
{ "silent-drop", tcp_parse_silent_drop },
{ "set-src", tcp_parse_set_src_dst },
@@ -1976,6 +1987,8 @@
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_req_conn_keywords_register, &tcp_req_conn_actions);
+
static struct action_kw_list tcp_req_sess_actions = {ILH, {
{ "silent-drop", tcp_parse_silent_drop },
{ "set-src", tcp_parse_set_src_dst },
@@ -1985,16 +1998,22 @@
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_actions);
+
static struct action_kw_list tcp_req_cont_actions = {ILH, {
{ "silent-drop", tcp_parse_silent_drop },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_actions);
+
static struct action_kw_list tcp_res_cont_actions = {ILH, {
{ "silent-drop", tcp_parse_silent_drop },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_cont_actions);
+
static struct action_kw_list http_req_actions = {ILH, {
{ "silent-drop", tcp_parse_silent_drop },
{ "set-src", tcp_parse_set_src_dst },
@@ -2004,28 +2023,18 @@
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions);
+
static struct action_kw_list http_res_actions = {ILH, {
{ "silent-drop", tcp_parse_silent_drop },
{ /* END */ }
}};
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions);
__attribute__((constructor))
static void __tcp_protocol_init(void)
{
- protocol_register(&proto_tcpv4);
- protocol_register(&proto_tcpv6);
- sample_register_fetches(&sample_fetch_keywords);
- bind_register_keywords(&bind_kws);
- srv_register_keywords(&srv_kws);
- tcp_req_conn_keywords_register(&tcp_req_conn_actions);
- tcp_req_sess_keywords_register(&tcp_req_sess_actions);
- tcp_req_cont_keywords_register(&tcp_req_cont_actions);
- tcp_res_cont_keywords_register(&tcp_res_cont_actions);
- http_req_keywords_register(&http_req_actions);
- http_res_keywords_register(&http_res_actions);
-
-
hap_register_build_opts("Built with transparent proxy support using:"
#if defined(IP_TRANSPARENT)
" IP_TRANSPARENT"