Skip to content

Update KISSPORT default handling #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 34 additions & 29 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4547,38 +4545,38 @@ 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 {
// 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.
// 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);
}
}

/*
Expand Down Expand Up @@ -5357,6 +5355,13 @@ 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
// 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 */


Expand Down