summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ax25ipd/ax25ipd.c11
-rw-r--r--ax25ipd/ax25ipd.conf8
-rw-r--r--ax25ipd/ax25ipd.conf.516
-rw-r--r--ax25ipd/ax25ipd.h1
-rw-r--r--ax25ipd/io.c26
5 files changed, 59 insertions, 3 deletions
diff --git a/ax25ipd/ax25ipd.c b/ax25ipd/ax25ipd.c
index d906724..2151238 100644
--- a/ax25ipd/ax25ipd.c
+++ b/ax25ipd/ax25ipd.c
@@ -144,6 +144,17 @@ int main(int argc, char **argv)
}
}
+ /* we need to close stdin, stdout, stderr: because otherwise
+ * scripting like ttyname=$(ax25ipd | tail -1) does not work
+ */
+ if (!isatty(1)) {
+ fflush(stdout);
+ fflush(stderr);
+ close(0);
+ close(1);
+ close(2);
+ }
+
/* and let the games begin */
io_start();
diff --git a/ax25ipd/ax25ipd.conf b/ax25ipd/ax25ipd.conf
index af28d32..e098dd1 100644
--- a/ax25ipd/ax25ipd.conf
+++ b/ax25ipd/ax25ipd.conf
@@ -41,11 +41,17 @@ mode tnc
# make sure you set a mycall above, or say axparms foobar -setcall te1st
# note: the device will be up when you assign an ip address
# _after_ starting ax25rtd (which initializes the device), start ax25d
-# with bpqether or pty, you do not need to care abt the speed
+# with bpqether or pty, you do not need to care about the speed
# tun/tap: as descriped in /usr/src/linux/Documentatioa/networking/tuntap.txt,
# make a device # like this:
# crw-r--r-- 1 root root 10, 200 Nov 26 13:32 tun
# with the command mknod /dev/net/tun c 10 200
+# As serial port, you could assign physical ports like ttyS0 or ptys.
+# ax25ipd supports BSD-style pseudo-terminals as well as the Unix98 pty's.
+# If the tty argument is "/dev/ptmx", then Unix98 behaviour
+# will automaticaly take effekt. With Unix98 pty's, the slave tty name
+# could not be forseen. That's why kissattach will print the corresponding
+# slave pty name as a separate line on stdout.
#
#device ampr
device /dev/ttyp0
diff --git a/ax25ipd/ax25ipd.conf.5 b/ax25ipd/ax25ipd.conf.5
index 364c148..8887488 100644
--- a/ax25ipd/ax25ipd.conf.5
+++ b/ax25ipd/ax25ipd.conf.5
@@ -90,7 +90,7 @@ mode tnc
.br
# _after_ starting ax25rtd (which initializes the device), start ax25d
.br
-# with bpqether or pty, you do not need to care abt the speed
+# with bpqether or pty, you do not need to care about the speed
.br
# tun/tap: as descriped in /usr/src/linux/Documentatioa/networking/tuntap.txt,
.br
@@ -100,7 +100,19 @@ mode tnc
.br
# with the command mknod /dev/net/tun c 10 200
.br
-#
+# As serial port, you could assign physical ports like ttyS0 or ptys.
+.br
+# ax25ipd supports BSD-style pseudo-terminals as well as the Unix98 pty's.
+.br
+# If the tty argument is "/dev/ptmx", then Unix98 behaviour
+.br
+# will automaticaly take effekt. With Unix98 pty's, the slave tty name
+.br
+# could not be forseen. That's why kissattach will print the corresponding
+.br
+# slave pty name as a separate line on stdout.
+.br
+#
.br
#device ampr
.br
diff --git a/ax25ipd/ax25ipd.h b/ax25ipd/ax25ipd.h
index fac25fc..d88173a 100644
--- a/ax25ipd/ax25ipd.h
+++ b/ax25ipd/ax25ipd.h
@@ -54,6 +54,7 @@
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
+#define __USE_XOPEN
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff --git a/ax25ipd/io.c b/ax25ipd/io.c
index 8bcb4a5..92217fc 100644
--- a/ax25ipd/io.c
+++ b/ax25ipd/io.c
@@ -143,6 +143,9 @@ void io_init()
void io_open()
{
int baudrate;
+ int i_am_unix98_pty_master = 0; /* unix98 ptmx support */
+ char *namepts = NULL; /* name of the unix98 pts slave, which
+ * the client has to use */
if (ip_mode) {
sock = socket(AF_INET, SOCK_RAW, IPPROTO_AX25);
@@ -189,6 +192,9 @@ void io_open()
}
}
+ if (!strcmp("/dev/ptmx", ttydevice))
+ i_am_unix98_pty_master = 1;
+
ttyfd = ((ttyfd_bpq = (strchr(ttydevice, '/') ? 0 : 1)) ? open_ethertap(ttydevice) : open(ttydevice, O_RDWR, 0));
if (ttyfd < 0) {
perror("opening tty device");
@@ -198,6 +204,20 @@ void io_open()
perror("setting non-blocking I/O on tty device");
exit(1);
}
+
+ if (i_am_unix98_pty_master) {
+ /* get name of pts-device */
+ if ((namepts = ptsname(ttyfd)) == NULL) {
+ perror("Cannot get name of pts-device.");
+ exit(1);
+ }
+ /* unlock pts-device */
+ if (unlockpt(ttyfd) == -1) {
+ perror("Cannot unlock pts-device.");
+ exit(1);
+ }
+ }
+
if (ttyfd_bpq) {
set_bpq_dev_call_and_up(ttydevice);
goto behind_normal_tty;
@@ -293,6 +313,12 @@ void io_open()
if (digi)
send_params();
+ if (i_am_unix98_pty_master) {
+ /* Users await the slave pty to be referenced in the last line */
+ printf("Awaiting client connects on\n%s\n", namepts);
+ syslog(LOG_INFO, "Bound to master pty /dev/ptmx with slave pty %s\n", namepts);
+ }
+
behind_normal_tty:
last_bc_time = 0; /* force immediate id */