From eb949211af0a806183acbff37c6c5fccb35e6ec8 Mon Sep 17 00:00:00 2001 From: Brent Petit <bjpetit@users.noreply.github.com> Date: Sun, 25 Apr 2021 23:22:38 -0500 Subject: [PATCH 1/2] Update KISSPORT default handling - Do not require use of KISSPORT 0 to remove default setting from KISSPORT configuration - For existing config files with KISSPORT 0, warn that the setting is not needed and ignore --- src/config.c | 60 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/config.c b/src/config.c index a7ff62c5..529e38c1 100644 --- a/src/config.c +++ b/src/config.c @@ -857,8 +857,6 @@ void config_init (char *fname, struct audio_s *p_audio_config, p_misc_config->kiss_port[i] = 0; // entry not used. p_misc_config->kiss_chan[i] = -1; } - p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT; - p_misc_config->kiss_chan[0] = -1; // all channels. p_misc_config->enable_kiss_pt = 0; /* -p option */ p_misc_config->kiss_copy = 0; @@ -4537,6 +4535,13 @@ void config_init (char *fname, struct audio_s *p_audio_config, continue; } + if (tcp_port == 0) { + // If existing config files have KISSPORT 0, ignore it and move on + text_color_set(DW_COLOR_ERROR); + dw_printf ("Line %d: Warning: KISSPORT 0 setting no longer needed.\n", line); + continue; + } + t = split(NULL,0); if (t != NULL) { chan = atoi(t); @@ -4547,37 +4552,27 @@ void config_init (char *fname, struct audio_s *p_audio_config, } } - // "KISSPORT 0" is used to remove the default entry. - - if (tcp_port == 0) { - p_misc_config->kiss_port[0] = 0; // Should all be wiped out? - } - else { - - // Try to find an empty slot. - // A duplicate TCP port number will overwrite the previous value. + // Try to find an empty slot. + // A duplicate TCP port number will overwrite the previous value. - int slot = -1; - for (int i = 0; i < MAX_KISS_TCP_PORTS && slot == -1; i++) { - if (p_misc_config->kiss_port[i] == tcp_port) { - slot = i; - if ( ! (slot == 0 && tcp_port == DEFAULT_KISS_PORT)) { - text_color_set(DW_COLOR_ERROR); - dw_printf ("Line %d: Warning: Duplicate TCP port %d will overwrite previous value.\n", line, tcp_port); - } - } - else if (p_misc_config->kiss_port[i] == 0) { - slot = i; - } - } - if (slot >= 0) { - p_misc_config->kiss_port[slot] = tcp_port; - p_misc_config->kiss_chan[slot] = chan; - } - else { + int slot = -1; + for (int i = 0; i < MAX_KISS_TCP_PORTS && slot == -1; i++) { + if (p_misc_config->kiss_port[i] == tcp_port) { + slot = i; text_color_set(DW_COLOR_ERROR); - dw_printf ("Line %d: Too many KISSPORT commands.\n", line); + dw_printf ("Line %d: Warning: Duplicate TCP port %d will overwrite previous value.\n", line, tcp_port); } + else if (p_misc_config->kiss_port[i] == 0) { + slot = i; + } + } + if (slot >= 0) { + p_misc_config->kiss_port[slot] = tcp_port; + p_misc_config->kiss_chan[slot] = chan; + } + else { + text_color_set(DW_COLOR_ERROR); + dw_printf ("Line %d: Too many KISSPORT commands.\n", line); } } @@ -5357,6 +5352,11 @@ void config_init (char *fname, struct audio_s *p_audio_config, p_misc_config->maxv22 = p_misc_config->retry / 3; } + /* If no kiss port specified, add default to first slot */ + if (p_misc_config->kiss_port[0] == 0) { + p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT; + } + } /* end config_init */ From 2343dd8b8e264c48f9877243c01b73a31ab51e4a Mon Sep 17 00:00:00 2001 From: Brent Petit <bjpetit@users.noreply.github.com> Date: Mon, 26 Apr 2021 08:38:35 -0500 Subject: [PATCH 2/2] Update to fix using KISSPORT 0 to fully disable kiss ports This commit also removes the KISSPORT 0 warning from initial commit --- src/config.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/config.c b/src/config.c index 529e38c1..4a4accce 100644 --- a/src/config.c +++ b/src/config.c @@ -4535,13 +4535,6 @@ void config_init (char *fname, struct audio_s *p_audio_config, continue; } - if (tcp_port == 0) { - // If existing config files have KISSPORT 0, ignore it and move on - text_color_set(DW_COLOR_ERROR); - dw_printf ("Line %d: Warning: KISSPORT 0 setting no longer needed.\n", line); - continue; - } - t = split(NULL,0); if (t != NULL) { chan = atoi(t); @@ -4552,6 +4545,16 @@ void config_init (char *fname, struct audio_s *p_audio_config, } } + // KISSPORT == 0, if slot 0 still unset, disable setting of default + // Use kiss_chan == -2 to indicate default disabled + // Subsequent KISSPORT settings can still overwrite this slot + if (tcp_port == 0) { + if (p_misc_config->kiss_port[0] == 0) { + p_misc_config->kiss_chan[0] = -2; // Don't set default + } + continue; + } + // Try to find an empty slot. // A duplicate TCP port number will overwrite the previous value. @@ -5352,9 +5355,11 @@ void config_init (char *fname, struct audio_s *p_audio_config, p_misc_config->maxv22 = p_misc_config->retry / 3; } - /* If no kiss port specified, add default to first slot */ - if (p_misc_config->kiss_port[0] == 0) { + // If no kiss port specified, add default to first slot + // kiss_chan == -2 in slot 0 means a KISSPORT of 0 was set in config + if (p_misc_config->kiss_port[0] == 0 && p_misc_config->kiss_chan[0] != -2) { p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT; + p_misc_config->kiss_chan[0] = -1; } } /* end config_init */