Skip to content

Commit d0eb822

Browse files
committed
Issue 635 - Multiple kiss pty and channel mapping.
1 parent 041f396 commit d0eb822

6 files changed

Lines changed: 275 additions & 88 deletions

File tree

src/config.c

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ void config_init (char *fname, struct audio_s *p_audio_config,
883883
p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT;
884884
p_misc_config->kiss_chan[0] = -1; // all channels.
885885

886-
p_misc_config->enable_kiss_pt = 0; /* -p option */
887886
p_misc_config->kiss_copy = 0;
888887

889888
p_misc_config->dns_sd_enabled = 1;
@@ -5063,6 +5062,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
50635062
// "KISSPORT 0" is used to remove the default entry.
50645063

50655064
if (tcp_port == 0) {
5065+
// FIXME: This is no longer correct after allowing multiple TCP ports.
50665066
p_misc_config->kiss_port[0] = 0; // Should all be wiped out?
50675067
}
50685068
else {
@@ -5095,6 +5095,72 @@ void config_init (char *fname, struct audio_s *p_audio_config,
50955095
}
50965096

50975097

5098+
/*
5099+
* KISSPTY [ chan ] - Add pseudo terminal for KISS client. Linux only feature.
5100+
* Modern applications generally allow KISS over TCP.
5101+
* This is here mostly for those who insist on using AX.25 for Linux.
5102+
* https://www.ardc.net/apply/grants/2021-grants/grant-fixing-the-linux-kernel-ax-25/
5103+
*/
5104+
5105+
// Originally, we could have a single KISS pty for client application use.
5106+
// This was activated by the -p command line option. There was no config file equivalent.
5107+
//
5108+
// The pty number can't be specified and is unpredictable so we create a
5109+
// symlink of /tmp/kisstnc.
5110+
//
5111+
// In version 1.9, we add the capability to have multiple pty interfaces and a
5112+
// specific channel can be specified for applications that don't know how to deal
5113+
// with multi-port TNCs.
5114+
//
5115+
// New config file item:
5116+
//
5117+
// KISSPTY
5118+
// Same as command line option -p. All channels. Symlink /tmp/kisstnc.
5119+
//
5120+
// KISSPTY n
5121+
// Frames received from channel n would go to client app with 4 bit kiss channel field set to 0.
5122+
// For KISS frames from client, the channel would be ignored, and it would be transmitted to channel n.
5123+
// symlink /tmp/kisstnc{n}
5124+
//
5125+
// e.g. PTYKISS 7 --> symlink /tmp/kisstnc7
5126+
//
5127+
// There is a maximum number of pty interfaces allowed.
5128+
// Edit kiss.h, increase number and rebuild, if you need more.
5129+
//
5130+
// The channel number, or lack of, may not be repeated.
5131+
// This would try to create multiple symlinks with the same name.
5132+
5133+
5134+
else if (strcasecmp(t, "KISSPTY") == 0) {
5135+
#if __WIN32__
5136+
text_color_set(DW_COLOR_ERROR);
5137+
dw_printf ("Line %d: KISSPTY is not available on Windows.\n", line);
5138+
#else
5139+
int chan = -1; // optional. default to all if not specified.
5140+
t = split(NULL,0);
5141+
if (t != NULL) {
5142+
chan = atoi(t);
5143+
if (chan < 0 || chan >= MAX_TOTAL_CHANS) {
5144+
text_color_set(DW_COLOR_ERROR);
5145+
dw_printf ("Line %d: Invalid channel %d for KISSPORT command. Must be in range 0 thru %d.\n", line, chan, MAX_TOTAL_CHANS-1);
5146+
continue;
5147+
}
5148+
}
5149+
5150+
// Add to list if maximum number not exceeded.
5151+
// FIXME: Don't allow duplicate channel number, including -1 for all.
5152+
5153+
if (p_misc_config->num_kiss_pty < MAX_KISS_PTY) {
5154+
p_misc_config->kiss_pty_chan[p_misc_config->num_kiss_pty++] = chan;
5155+
}
5156+
else {
5157+
text_color_set(DW_COLOR_ERROR);
5158+
dw_printf ("Line %d: Too many KISSPTY commands.\n", line);
5159+
}
5160+
#endif
5161+
}
5162+
5163+
50985164
/*
50995165
* TCP_WMEM n - Experiment for Issue 620. Set KISS TCP write buffer size.
51005166
*/
@@ -5186,8 +5252,8 @@ void config_init (char *fname, struct audio_s *p_audio_config,
51865252

51875253

51885254
/*
5189-
* DNSSD - Enable or disable (1/0) dns-sd, DNS Service Discovery announcements
5190-
* DNSSDNAME - Set DNS-SD service name, defaults to "Dire Wolf on <hostname>"
5255+
* DNSSD n - Enable or disable (1/0) dns-sd, DNS Service Discovery announcements
5256+
* DNSSDNAME x - Set DNS-SD service name, defaults to "Dire Wolf on <hostname>"
51915257
*/
51925258

51935259
else if (strcasecmp(t, "DNSSD") == 0) {

src/config.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ struct misc_config_s {
6060
// As an experiment, let's see if making the TCP send buffer larger helps.
6161

6262
int kiss_copy; /* Data from network KISS client is copied to all others. */
63-
int enable_kiss_pt; /* Enable pseudo terminal for KISS. */
64-
/* Want this to be off by default because it hangs */
65-
/* after a while if nothing is reading from other end. */
63+
64+
int num_kiss_pty; /* Number of pseudo terminals defined for KISS clients. Maximum MAX_KISS_PTY. */
65+
/* i.e. Number of elements used in following array. */
66+
67+
int kiss_pty_chan[MAX_KISS_PTY]; /* Normally -1 meaning convey all channels. */
68+
/* It is also possible to associate the pty with a single channel to appease */
69+
/* old applications that don't know how to deal with multi-port TNCs which */
70+
/* existed back in the 1990s. */
71+
72+
/* Frames received from channel n would go to client app with 4 bit kiss channel field set to 0. */ /* For KISS frames from client, the channel would be ignored, and it would be transmitted to channel n. */ /* symlink /tmp/kisstnc{n} */
73+
/* e.g. PTYKISS 7 --> symlink /tmp/kisstnc7 */
6674

6775
char kiss_serial_port[20];
6876
/* Serial port name for our end of the */

src/direwolf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,11 @@ int main (int argc, char *argv[])
328328

329329
text_color_set(DW_COLOR_INFO);
330330
//dw_printf ("Dire Wolf version %d.%d (%s) BETA TEST 1\n", MAJOR_VERSION, MINOR_VERSION, __DATE__);
331-
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "C", __DATE__);
331+
dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "D", __DATE__);
332332
// B = new -dq & tcp_wmem
333333
// C = AX.25 v2.2 improvements
334+
// D = KISSPTY config.
335+
// TBD? = AX.25 v2.2 negotiating status
334336
//dw_printf ("Dire Wolf Release %d.%d,%d, October 2025\n", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION);
335337

336338

@@ -977,8 +979,6 @@ int main (int argc, char *argv[])
977979
strlcpy (misc_config.log_path, l_opt_logdir, sizeof(misc_config.log_path));
978980
}
979981

980-
misc_config.enable_kiss_pt = enable_pseudo_terminal;
981-
982982
if (strlen(input_file) > 0) {
983983

984984
strlcpy (audio_config.adev[0].adevice_in, input_file, sizeof(audio_config.adev[0].adevice_in));
@@ -1183,8 +1183,10 @@ int main (int argc, char *argv[])
11831183

11841184
/*
11851185
* Create a pseudo terminal and KISS TNC emulator.
1186+
* In 1.9 we now have kisspty definitions in config file as well.
1187+
* Provide the -p option state to add to this.
11861188
*/
1187-
kisspt_init (&misc_config);
1189+
kisspt_init (&misc_config, enable_pseudo_terminal);
11881190
kissserial_init (&misc_config);
11891191
kiss_frame_init (&audio_config);
11901192

src/direwolf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
// Someone with very unusual requirements could increase this and
7373
// use only the AGW network protocol.
7474

75+
#define MAX_KISS_PTY 6 // Maximum number of KISS pty interfaces for client apps.
76+
// Increase and rebuild if not enough.
77+
78+
7579
/*
7680
* Maximum number of rigs.
7781
*/

0 commit comments

Comments
 (0)