From a99e1622024ca41e3c3222d8dcb624f7d85af690 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 29 Oct 2024 10:43:12 -0400 Subject: [PATCH] MT#61352 use "introspection" to manage config Make it so that options only need to be managed in one place, and all code operating on the list of them is streamlined Change-Id: Ia53b15910ec8973635e61cad1b43eff8d536a577 --- daemon/cli.c | 121 +++++++++---------- daemon/main.c | 147 +++++++++-------------- include/main.h | 311 +++++++++++++++++++++++++++++-------------------- 3 files changed, 297 insertions(+), 282 deletions(-) diff --git a/daemon/cli.c b/daemon/cli.c index 9094ee06a..2d9ee46a9 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -290,31 +290,20 @@ static void cli_incoming_params_start(str *instr, struct cli_writer *cw) { log_level_names[i], g_atomic_int_get(&initial_rtpe_config.common.log_levels[i])); - cw->cw_printf(cw, "table = %d\nmax-sessions = %d\ntimeout = %d\nsilent-timeout = %d\n" - "final-timeout = %d\noffer-timeout = %d\n" - "delete-delay = %d\nredis-expires = %d\ntos = %d\ncontrol-tos = %d\ngraphite-interval = %d\nredis-num-threads = %d\n" - "homer-protocol = %d\nhomer-id = %d\nno-fallback = %d\nport-min = %d\nport-max = %d\nredis = %s:%d/%d\n" - "redis-write = %s:%d/%d\nno-redis-required = %d\nnum-threads = %d\nxmlrpc-format = %d\nlog_format = %d\n" - "redis_allowed_errors = %d\nredis_disable_time = %d\nredis_cmd_timeout = %d\nredis_connect_timeout = %d\n" - "max-cpu = %.1f\n" - "max-load = %.2f\n" - "max-bandwidth = %" PRIu64 "\n" - "max-recv-iters = %d\n", - initial_rtpe_config.kernel_table, initial_rtpe_config.max_sessions, - initial_rtpe_config.timeout, initial_rtpe_config.silent_timeout, initial_rtpe_config.final_timeout, - initial_rtpe_config.offer_timeout, initial_rtpe_config.delete_delay, - initial_rtpe_config.redis_expires_secs, initial_rtpe_config.default_tos, initial_rtpe_config.control_tos, - initial_rtpe_config.graphite_interval, initial_rtpe_config.redis_num_threads, initial_rtpe_config.homer_protocol, - initial_rtpe_config.homer_id, initial_rtpe_config.no_fallback, initial_rtpe_config.port_min, initial_rtpe_config.port_max, - sockaddr_print_buf(&initial_rtpe_config.redis_ep.address), initial_rtpe_config.redis_ep.port, initial_rtpe_config.redis_db, - sockaddr_print_buf(&initial_rtpe_config.redis_write_ep.address), initial_rtpe_config.redis_write_ep.port, - initial_rtpe_config.redis_write_db, initial_rtpe_config.no_redis_required, initial_rtpe_config.num_threads, - initial_rtpe_config.fmt, initial_rtpe_config.log_format, initial_rtpe_config.redis_allowed_errors, - initial_rtpe_config.redis_disable_time, initial_rtpe_config.redis_cmd_timeout, initial_rtpe_config.redis_connect_timeout, +#define X(s) cw->cw_printf(cw, #s " = %d\n", initial_rtpe_config.s); +RTPE_CONFIG_INT_PARAMS +RTPE_CONFIG_BOOL_PARAMS +RTPE_CONFIG_ENUM_PARAMS +#undef X + +#define X(s) cw->cw_printf(cw, #s " = %" PRIu64" \n", initial_rtpe_config.s); +RTPE_CONFIG_UINT64_PARAMS +#undef X + + cw->cw_printf(cw, "[max-cpu = %.1f]\n" + "[max-load = %.2f]\n", (double) initial_rtpe_config.cpu_limit / 100, - (double) initial_rtpe_config.load_limit / 100, - initial_rtpe_config.bw_limit, - initial_rtpe_config.max_recv_iters); + (double) initial_rtpe_config.load_limit / 100); for (__auto_type s = initial_rtpe_config.interfaces.head; s ; s = s->next) { ifa = s->data; @@ -326,15 +315,22 @@ static void cli_incoming_params_start(str *instr, struct cli_writer *cw) { cw->cw_printf(cw,"keyspace[%d] = %d \n", count, GPOINTER_TO_UINT(s->data)); ++count; } - cw->cw_printf(cw, "b2b_url = %s\nredis-auth = %s\nredis-write-auth = %s\nrecording-dir = %s\nrecording-method = %s\n" - "recording-format = %s\niptables-chain = %s\n", initial_rtpe_config.b2b_url, initial_rtpe_config.redis_auth, - initial_rtpe_config.redis_write_auth, initial_rtpe_config.spooldir, initial_rtpe_config.rec_method, - initial_rtpe_config.rec_format, initial_rtpe_config.iptables_chain); - cli_endpoints_print(cw, &initial_rtpe_config.tcp_listen_ep, "listen-tcp"); - cli_endpoints_print(cw, &initial_rtpe_config.udp_listen_ep, "listen-udp"); - cli_endpoints_print(cw, &initial_rtpe_config.ng_listen_ep, "listen-ng"); - cli_endpoints_print(cw, &initial_rtpe_config.cli_listen_ep, "listen-cli"); - cli_endpoints_print(cw, &initial_rtpe_config.ng_tcp_listen_ep, "listen-tcp-ng"); + +#define X(s) cw->cw_printf(cw, #s " = %s\n", initial_rtpe_config.s); +RTPE_CONFIG_CHARP_PARAMS +#undef X + +#define X(s) cw->cw_printf(cw, #s " = " STR_FORMAT "\n", STR_FMT(&initial_rtpe_config.s)); +RTPE_CONFIG_STR_PARAMS +#undef X + +#define X(s) cw->cw_printf(cw, #s " = %s\n", endpoint_print_buf(&initial_rtpe_config.s)); +RTPE_CONFIG_ENDPOINT_PARAMS +#undef X + +#define X(s) cli_endpoints_print(cw, &initial_rtpe_config.s, #s); +RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS +#undef X } static void cli_incoming_params_current(str *instr, struct cli_writer *cw) { @@ -346,28 +342,20 @@ static void cli_incoming_params_current(str *instr, struct cli_writer *cw) { log_level_names[i], g_atomic_int_get(&rtpe_config.common.log_levels[i])); - cw->cw_printf(cw, "table = %d\nmax-sessions = %d\ntimeout = %d\nsilent-timeout = %d\n" - "final-timeout = %d\noffer-timeout = %d\n" - "delete-delay = %d\nredis-expires = %d\ntos = %d\ncontrol-tos = %d\ngraphite-interval = %d\nredis-num-threads = %d\n" - "homer-protocol = %d\nhomer-id = %d\nno-fallback = %d\nport-min = %d\nport-max = %d\nredis-db = %d\n" - "redis-write-db = %d\nno-redis-required = %d\nnum-threads = %d\nxmlrpc-format = %d\nlog_format = %d\n" - "redis_allowed_errors = %d\nredis_disable_time = %d\nredis_cmd_timeout = %d\nredis_connect_timeout = %d\n" - "max-cpu = %.1f\n" - "max-load = %.2f\n" - "max-bw = %" PRIu64 "\n" - "max-recv-iters = %d\n", - rtpe_config.kernel_table, rtpe_config.max_sessions, rtpe_config.timeout, - rtpe_config.silent_timeout, rtpe_config.final_timeout, rtpe_config.offer_timeout, - rtpe_config.delete_delay, rtpe_config.redis_expires_secs, rtpe_config.default_tos, - rtpe_config.control_tos, rtpe_config.graphite_interval, rtpe_config.redis_num_threads, rtpe_config.homer_protocol, - rtpe_config.homer_id, rtpe_config.no_fallback, rtpe_config.port_min, rtpe_config.port_max, - rtpe_config.redis_db, rtpe_config.redis_write_db, rtpe_config.no_redis_required, - rtpe_config.num_threads, rtpe_config.fmt, rtpe_config.log_format, rtpe_config.redis_allowed_errors, - rtpe_config.redis_disable_time, rtpe_config.redis_cmd_timeout, rtpe_config.redis_connect_timeout, +#define X(s) cw->cw_printf(cw, #s " = %d\n", rtpe_config.s); +RTPE_CONFIG_INT_PARAMS +RTPE_CONFIG_BOOL_PARAMS +RTPE_CONFIG_ENUM_PARAMS +#undef X + +#define X(s) cw->cw_printf(cw, #s " = %" PRIu64" \n", rtpe_config.s); +RTPE_CONFIG_UINT64_PARAMS +#undef X + + cw->cw_printf(cw, "[max-cpu = %.1f]\n" + "[max-load = %.2f]\n", (double) rtpe_config.cpu_limit / 100, - (double) rtpe_config.load_limit / 100, - rtpe_config.bw_limit, - rtpe_config.max_recv_iters); + (double) rtpe_config.load_limit / 100); for (__auto_type c = rtpe_config.interfaces.head; c ; c = c->next) { ifa = c->data; @@ -379,15 +367,22 @@ static void cli_incoming_params_current(str *instr, struct cli_writer *cw) { cw->cw_printf(cw,"keyspace[%d] = %d \n", count, GPOINTER_TO_UINT(c->data)); ++count; } - cw->cw_printf(cw, "b2b_url = %s\nredis-auth = %s\nredis-write-auth = %s\nrecording-dir = %s\nrecording-method = %s\n" - "recording-format = %s\niptables-chain = %s\n", rtpe_config.b2b_url, rtpe_config.redis_auth, - rtpe_config.redis_write_auth, rtpe_config.spooldir, rtpe_config.rec_method, - rtpe_config.rec_format, rtpe_config.iptables_chain); - cli_endpoints_print(cw, &rtpe_config.tcp_listen_ep, "listen-tcp"); - cli_endpoints_print(cw, &rtpe_config.udp_listen_ep, "listen-udp"); - cli_endpoints_print(cw, &rtpe_config.ng_listen_ep, "listen-ng"); - cli_endpoints_print(cw, &rtpe_config.cli_listen_ep, "listen-cli"); - cli_endpoints_print(cw, &rtpe_config.ng_tcp_listen_ep, "listen-tcp-ng"); + +#define X(s) cw->cw_printf(cw, #s " = %s\n", rtpe_config.s); +RTPE_CONFIG_CHARP_PARAMS +#undef X + +#define X(s) cw->cw_printf(cw, #s " = " STR_FORMAT "\n", STR_FMT(&rtpe_config.s)); +RTPE_CONFIG_STR_PARAMS +#undef X + +#define X(s) cw->cw_printf(cw, #s " = %s\n", endpoint_print_buf(&rtpe_config.s)); +RTPE_CONFIG_ENDPOINT_PARAMS +#undef X + +#define X(s) cli_endpoints_print(cw, &rtpe_config.s, #s); +RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS +#undef X } #define int_diff_print(struct_member, option_string) \ diff --git a/daemon/main.c b/daemon/main.c index b260b4ec8..54f17f58c 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -432,6 +432,11 @@ static void endpoint_list_dup(GQueue *out, const GQueue *in) { for (GList *l = in->head; l; l = l->next) g_queue_push_tail(out, endpoint_dup(l->data)); } +static void endpoint_list_free(GQueue *q) { + endpoint_t *ep; + while ((ep = g_queue_pop_head(q))) + g_slice_free1(sizeof(*ep), ep); +} static void parse_listen_list(GQueue *out, char **epv, const char *option) { if (!epv) return; @@ -1120,67 +1125,26 @@ static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) { g_queue_push_tail(&ini_rtpe_cfg->redis_subscribed_keyspaces, GINT_TO_POINTER(num)); } - ini_rtpe_cfg->kernel_table = rtpe_config.kernel_table; - ini_rtpe_cfg->max_sessions = rtpe_config.max_sessions; - ini_rtpe_cfg->cpu_limit = rtpe_config.cpu_limit; - ini_rtpe_cfg->load_limit = rtpe_config.load_limit; - ini_rtpe_cfg->bw_limit = rtpe_config.bw_limit; - ini_rtpe_cfg->timeout = rtpe_config.timeout; - ini_rtpe_cfg->silent_timeout = rtpe_config.silent_timeout; - ini_rtpe_cfg->offer_timeout = rtpe_config.offer_timeout; - ini_rtpe_cfg->final_timeout = rtpe_config.final_timeout; - ini_rtpe_cfg->delete_delay = rtpe_config.delete_delay; - ini_rtpe_cfg->redis_expires_secs = rtpe_config.redis_expires_secs; - ini_rtpe_cfg->default_tos = rtpe_config.default_tos; - ini_rtpe_cfg->control_tos = rtpe_config.control_tos; - ini_rtpe_cfg->graphite_interval = rtpe_config.graphite_interval; - ini_rtpe_cfg->graphite_timeout= rtpe_config.graphite_timeout; - ini_rtpe_cfg->redis_num_threads = rtpe_config.redis_num_threads; - ini_rtpe_cfg->homer_protocol = rtpe_config.homer_protocol; - ini_rtpe_cfg->homer_id = rtpe_config.homer_id; - ini_rtpe_cfg->homer_ng_capt_proto = rtpe_config.homer_ng_capt_proto; - ini_rtpe_cfg->no_fallback = rtpe_config.no_fallback; - ini_rtpe_cfg->port_min = rtpe_config.port_min; - ini_rtpe_cfg->port_max = rtpe_config.port_max; - ini_rtpe_cfg->redis_db = rtpe_config.redis_db; - ini_rtpe_cfg->redis_write_db = rtpe_config.redis_write_db; - ini_rtpe_cfg->no_redis_required = rtpe_config.no_redis_required; - ini_rtpe_cfg->num_threads = rtpe_config.num_threads; - ini_rtpe_cfg->media_num_threads = rtpe_config.media_num_threads; - ini_rtpe_cfg->fmt = rtpe_config.fmt; - ini_rtpe_cfg->log_format = rtpe_config.log_format; - ini_rtpe_cfg->redis_allowed_errors = rtpe_config.redis_allowed_errors; - ini_rtpe_cfg->redis_disable_time = rtpe_config.redis_disable_time; - ini_rtpe_cfg->redis_cmd_timeout = rtpe_config.redis_cmd_timeout; - ini_rtpe_cfg->redis_connect_timeout = rtpe_config.redis_connect_timeout; - ini_rtpe_cfg->redis_delete_async = rtpe_config.redis_delete_async; - ini_rtpe_cfg->redis_delete_async_interval = rtpe_config.redis_delete_async_interval; +#define X(s) ini_rtpe_cfg->s = rtpe_config.s; +RTPE_CONFIG_INT_PARAMS +RTPE_CONFIG_UINT64_PARAMS +RTPE_CONFIG_BOOL_PARAMS +RTPE_CONFIG_ENDPOINT_PARAMS +RTPE_CONFIG_ENUM_PARAMS +#undef X + +#define X(s) ini_rtpe_cfg->s = g_strdup(rtpe_config.s); +RTPE_CONFIG_CHARP_PARAMS +#undef X + memcpy(&ini_rtpe_cfg->common.log_levels, &rtpe_config.common.log_levels, sizeof(ini_rtpe_cfg->common.log_levels)); - ini_rtpe_cfg->graphite_ep = rtpe_config.graphite_ep; - endpoint_list_dup(&ini_rtpe_cfg->tcp_listen_ep, &rtpe_config.tcp_listen_ep); - endpoint_list_dup(&ini_rtpe_cfg->udp_listen_ep, &rtpe_config.udp_listen_ep); - endpoint_list_dup(&ini_rtpe_cfg->ng_listen_ep, &rtpe_config.ng_listen_ep); - endpoint_list_dup(&ini_rtpe_cfg->ng_tcp_listen_ep, &rtpe_config.ng_tcp_listen_ep); - endpoint_list_dup(&ini_rtpe_cfg->cli_listen_ep, &rtpe_config.cli_listen_ep); - ini_rtpe_cfg->redis_ep = rtpe_config.redis_ep; - ini_rtpe_cfg->redis_write_ep = rtpe_config.redis_write_ep; - ini_rtpe_cfg->homer_ep = rtpe_config.homer_ep; - ini_rtpe_cfg->endpoint_learning = rtpe_config.endpoint_learning; - - ini_rtpe_cfg->b2b_url = g_strdup(rtpe_config.b2b_url); - ini_rtpe_cfg->redis_auth = g_strdup(rtpe_config.redis_auth); - ini_rtpe_cfg->redis_write_auth = g_strdup(rtpe_config.redis_write_auth); - ini_rtpe_cfg->spooldir = g_strdup(rtpe_config.spooldir); - ini_rtpe_cfg->iptables_chain = g_strdup(rtpe_config.iptables_chain); - ini_rtpe_cfg->rec_method = g_strdup(rtpe_config.rec_method); - ini_rtpe_cfg->rec_format = g_strdup(rtpe_config.rec_format); - - ini_rtpe_cfg->jb_length = rtpe_config.jb_length; - ini_rtpe_cfg->jb_clock_drift = rtpe_config.jb_clock_drift; - ini_rtpe_cfg->rtcp_interval = rtpe_config.rtcp_interval; - - ini_rtpe_cfg->max_recv_iters = rtpe_config.max_recv_iters; +#define X(s) endpoint_list_dup(&ini_rtpe_cfg->s, &rtpe_config.s); +RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS +#undef X + + ini_rtpe_cfg->silence_detect_double = rtpe_config.silence_detect_double; + ini_rtpe_cfg->silence_detect_int = rtpe_config.silence_detect_int; } static void free_config_interfaces(struct intf_config *i) { @@ -1195,13 +1159,21 @@ static void unfill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) { g_queue_clear(&ini_rtpe_cfg->redis_subscribed_keyspaces); // free g_strdup - g_free(ini_rtpe_cfg->b2b_url); - g_free(ini_rtpe_cfg->redis_auth); - g_free(ini_rtpe_cfg->redis_write_auth); - g_free(ini_rtpe_cfg->spooldir); - g_free(ini_rtpe_cfg->iptables_chain); - g_free(ini_rtpe_cfg->rec_method); - g_free(ini_rtpe_cfg->rec_format); +#define X(s) g_free(ini_rtpe_cfg->s); +RTPE_CONFIG_CHARP_PARAMS +#undef X + +#define X(x) g_free(ini_rtpe_cfg->x.s); +RTPE_CONFIG_STR_PARAMS +#undef X + +#define X(s) endpoint_list_free(&ini_rtpe_cfg->s); +RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS +#undef X + +#define X(s) g_strfreev(ini_rtpe_cfg->s); +RTPE_CONFIG_CHARPP_PARAMS +#undef X } static void options_free(void) { @@ -1210,34 +1182,21 @@ static void options_free(void) { g_queue_clear(&rtpe_config.redis_subscribed_keyspaces); // free config options - g_free(rtpe_config.b2b_url); - g_free(rtpe_config.spooldir); - g_free(rtpe_config.rec_method); - g_free(rtpe_config.rec_format); - g_free(rtpe_config.iptables_chain); - g_free(rtpe_config.scheduling); - g_free(rtpe_config.idle_scheduling); - g_free(rtpe_config.mysql_host); - g_free(rtpe_config.mysql_user); - g_free(rtpe_config.mysql_pass); - g_free(rtpe_config.mysql_query); - g_free(rtpe_config.dtls_ciphers); - g_strfreev(rtpe_config.http_ifs); - g_strfreev(rtpe_config.https_ifs); - g_free(rtpe_config.https_cert); - g_free(rtpe_config.https_key); - g_free(rtpe_config.software_id); - if (rtpe_config.cn_payload.s) - g_free(rtpe_config.cn_payload.s); - if (rtpe_config.dtx_cn_params.s) - g_free(rtpe_config.dtx_cn_params.s); - g_free(rtpe_config.mqtt_user); - g_free(rtpe_config.mqtt_pass); - g_free(rtpe_config.mqtt_cafile); - g_free(rtpe_config.mqtt_certfile); - g_free(rtpe_config.mqtt_keyfile); - g_free(rtpe_config.mqtt_publish_topic); - g_free(rtpe_config.janus_secret); +#define X(s) g_free(rtpe_config.s); +RTPE_CONFIG_CHARP_PARAMS +#undef X + +#define X(x) g_free(rtpe_config.x.s); +RTPE_CONFIG_STR_PARAMS +#undef X + +#define X(s) endpoint_list_free(&rtpe_config.s); +RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS +#undef X + +#define X(s) g_strfreev(rtpe_config.s); +RTPE_CONFIG_CHARPP_PARAMS +#undef X // free common config options config_load_free(&rtpe_config.common); diff --git a/include/main.h b/include/main.h index 22139598b..ae3cdc87d 100644 --- a/include/main.h +++ b/include/main.h @@ -32,23 +32,198 @@ enum endpoint_learning { #define MAX_RECV_ITERS 50 #endif +#define RTPE_CONFIG_INT_PARAMS \ + X(kernel_table) \ + X(max_sessions) \ + X(timeout) \ + X(silent_timeout) \ + X(final_timeout) \ + X(offer_timeout) \ + X(delete_delay) \ + X(redis_expires_secs) \ + X(default_tos) \ + X(control_tos) \ + X(graphite_interval) \ + X(graphite_timeout) \ + X(redis_num_threads) \ + X(homer_protocol) \ + X(homer_id) \ + X(homer_ng_capt_proto) \ + X(port_min) \ + X(port_max) \ + X(redis_db) \ + X(redis_write_db) \ + X(redis_allowed_errors) \ + X(redis_disable_time) \ + X(redis_cmd_timeout) \ + X(redis_connect_timeout) \ + X(redis_delete_async) \ + X(redis_delete_async_interval) \ + X(num_threads) \ + X(media_num_threads) \ + X(codec_num_threads) \ + X(nftables_family) \ + X(load_limit) \ + X(cpu_limit) \ + X(priority) \ + X(idle_priority) \ + X(mysql_port) \ + X(dtmf_digit_delay) \ + X(jb_length) \ + X(dtls_rsa_key_size) \ + X(dtls_mtu) \ + X(http_threads) \ + X(dtx_delay) \ + X(max_dtx) \ + X(dtx_buffer) \ + X(dtx_lag) \ + X(dtx_shift) \ + X(amr_cn_dtx) \ + X(kernel_player) \ + X(kernel_player_media) \ + X(audio_buffer_length) \ + X(audio_buffer_delay) \ + X(mqtt_port) \ + X(mqtt_keepalive) \ + X(mqtt_publish_qos) \ + X(mqtt_publish_interval) \ + X(rtcp_interval) \ + X(cpu_affinity) \ + X(max_recv_iters) + +#define RTPE_CONFIG_UINT64_PARAMS \ + X(bw_limit) + +#define RTPE_CONFIG_BOOL_PARAMS \ + X(homer_rtcp_off) \ + X(homer_ng_on) \ + X(no_fallback) \ + X(reject_invalid_sdp) \ + X(save_interface_ports) \ + X(no_redis_required) \ + X(active_switchover) \ + X(rec_egress) \ + X(nftables_append) \ + X(log_keys) \ + X(dtmf_via_ng) \ + X(dtmf_no_suppress) \ + X(dtmf_no_log_injects) \ + X(jb_clock_drift) \ + X(player_cache) \ + X(poller_per_thread) \ + X(measure_rtp) + +#define RTPE_CONFIG_CHARP_PARAMS \ + X(b2b_url) \ + X(redis_auth) \ + X(redis_write_auth) \ + X(spooldir) \ + X(rec_method) \ + X(rec_format) \ + X(iptables_chain) \ + X(nftables_chain) \ + X(nftables_base_chain) \ + X(scheduling) \ + X(idle_scheduling) \ + X(mysql_host) \ + X(mysql_user) \ + X(mysql_pass) \ + X(mysql_query) \ + X(dtls_ciphers) \ + X(https_cert) \ + X(https_key) \ + X(software_id) \ + X(mqtt_host) \ + X(mqtt_tls_alpn) \ + X(mqtt_id) \ + X(mqtt_user) \ + X(mqtt_pass) \ + X(mqtt_cafile) \ + X(mqtt_capath) \ + X(mqtt_certfile) \ + X(mqtt_keyfile) \ + X(mqtt_publish_topic) \ + X(janus_secret) + +#define RTPE_CONFIG_ENDPOINT_PARAMS \ + X(graphite_ep) \ + X(redis_ep) \ + X(redis_write_ep) \ + X(homer_ep) \ + X(dtmf_udp_ep) + +#define RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS \ + X(tcp_listen_ep) \ + X(udp_listen_ep) \ + X(ng_listen_ep) \ + X(ng_tcp_listen_ep) \ + X(cli_listen_ep) + +#define RTPE_CONFIG_STR_PARAMS \ + X(dtx_cn_params) \ + X(cn_payload) \ + X(vsc_start_rec) \ + X(vsc_stop_rec) \ + X(vsc_start_stop_rec) \ + X(vsc_pause_rec) \ + X(vsc_pause_resume_rec) \ + X(vsc_start_pause_resume_rec) + +#define RTPE_CONFIG_CHARPP_PARAMS \ + X(http_ifs) \ + X(https_ifs) + +// these are not automatically included in rtpe_config due to different types +#define RTPE_CONFIG_ENUM_PARAMS \ + X(control_pmtu) \ + X(fmt) \ + X(log_format) \ + X(redis_format) \ + X(endpoint_learning) \ + X(dtls_cert_cipher) \ + X(dtls_signature) \ + X(use_audio_player) \ + X(mqtt_publish_scope) \ + X(mos) + struct rtpengine_config { rwlock_t keyspaces_lock; struct rtpengine_common_config common; - int kernel_table; - int max_sessions; - int timeout; - int silent_timeout; - int final_timeout; - int offer_timeout; - int delete_delay; +#define X(s) int s; +RTPE_CONFIG_INT_PARAMS +#undef X + +#define X(s) uint64_t s; +RTPE_CONFIG_UINT64_PARAMS +#undef X + +#define X(s) gboolean s; +RTPE_CONFIG_BOOL_PARAMS +#undef X + +#define X(s) char *s; +RTPE_CONFIG_CHARP_PARAMS +#undef X + +#define X(s) endpoint_t s; +RTPE_CONFIG_ENDPOINT_PARAMS +#undef X + +#define X(s) GQueue s; +RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS +#undef X + +#define X(s) str s; +RTPE_CONFIG_STR_PARAMS +#undef X + +#define X(s) char **s; +RTPE_CONFIG_CHARPP_PARAMS +#undef X + GQueue redis_subscribed_keyspaces; - int redis_expires_secs; - char *b2b_url; - int default_tos; - int control_tos; enum { PMTU_DISC_DEFAULT = 0, PMTU_DISC_WANT, @@ -56,133 +231,30 @@ struct rtpengine_config { } control_pmtu; enum xmlrpc_format fmt; enum log_format log_format; - endpoint_t graphite_ep; - int graphite_interval; - int graphite_timeout; - int redis_num_threads; intf_config_q interfaces; - GQueue tcp_listen_ep; - GQueue udp_listen_ep; - GQueue ng_listen_ep; - GQueue ng_tcp_listen_ep; - GQueue cli_listen_ep; - endpoint_t redis_ep; - endpoint_t redis_write_ep; - endpoint_t homer_ep; - int homer_protocol; - int homer_id; - int homer_ng_capt_proto; - gboolean homer_rtcp_off; - gboolean homer_ng_on; - gboolean no_fallback; - gboolean reject_invalid_sdp; - gboolean save_interface_ports; - int port_min; - int port_max; - int redis_db; - int redis_write_db; - gboolean no_redis_required; - int redis_allowed_errors; - int redis_disable_time; - int redis_cmd_timeout; - int redis_connect_timeout; - int redis_delete_async; - int redis_delete_async_interval; - char *redis_auth; - char *redis_write_auth; enum { REDIS_FORMAT_BENCODE = 0, REDIS_FORMAT_JSON, __REDIS_FORMAT_MAX } redis_format; - gboolean active_switchover; - int num_threads; - int media_num_threads; - int codec_num_threads; - char *spooldir; - char *rec_method; - char *rec_format; - gboolean rec_egress; - char *iptables_chain; - char *nftables_chain; - char *nftables_base_chain; - gboolean nftables_append; - int nftables_family; - int load_limit; - int cpu_limit; - uint64_t bw_limit; - char *scheduling; - int priority; - char *idle_scheduling; - int idle_priority; - gboolean log_keys; - char *mysql_host; - int mysql_port; - char *mysql_user; - char *mysql_pass; - char *mysql_query; - endpoint_t dtmf_udp_ep; - gboolean dtmf_via_ng; - gboolean dtmf_no_suppress; - int dtmf_digit_delay; - gboolean dtmf_no_log_injects; enum endpoint_learning endpoint_learning; - int jb_length; - gboolean jb_clock_drift; enum { DCC_EC_PRIME256v1 = 0, DCC_RSA, } dtls_cert_cipher; - int dtls_rsa_key_size; - int dtls_mtu; - char *dtls_ciphers; enum { DSIG_SHA256 = 0, DSIG_SHA1, } dtls_signature; - char **http_ifs; - char **https_ifs; - char *https_cert; - char *https_key; - int http_threads; - int dtx_delay; - int max_dtx; - int dtx_buffer; - int dtx_lag; - int dtx_shift; - str dtx_cn_params; - int amr_cn_dtx; double silence_detect_double; uint32_t silence_detect_int; - str cn_payload; - gboolean player_cache; - int kernel_player; - int kernel_player_media; - int audio_buffer_length; - int audio_buffer_delay; enum { UAP_ON_DEMAND = 0, UAP_PLAY_MEDIA, UAP_TRANSCODING, UAP_ALWAYS, } use_audio_player; - char *software_id; - gboolean poller_per_thread; - char *mqtt_host; - int mqtt_port; - char *mqtt_tls_alpn; - char *mqtt_id; - int mqtt_keepalive; - char *mqtt_user; - char *mqtt_pass; - char *mqtt_cafile; - char *mqtt_capath; - char *mqtt_certfile; - char *mqtt_keyfile; - int mqtt_publish_qos; - char *mqtt_publish_topic; - int mqtt_publish_interval; enum { MPS_NONE = -1, MPS_GLOBAL = 0, @@ -194,17 +266,6 @@ struct rtpengine_config { MOS_CQ = 0, MOS_LQ, } mos; - gboolean measure_rtp; - int rtcp_interval; - int cpu_affinity; - char *janus_secret; - int max_recv_iters; - str vsc_start_rec; - str vsc_stop_rec; - str vsc_start_stop_rec; - str vsc_pause_rec; - str vsc_pause_resume_rec; - str vsc_start_pause_resume_rec; };