From 3cfd1dbc21aaf3cd056e0c6dff60c972e4bfeae8 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sun, 17 Sep 1995 21:47:24 +0000 Subject: [PATCH] Add new options: -K: set keepalive SLIP timeout -O: set outfill SLIP timeout Handle SIGURG from keepalive like SIGHUP now, i.e. reconnect. Back out background scription change, cause some synchro problems. --- sbin/startslip/startslip.1 | 12 +++++++++ sbin/startslip/startslip.c | 52 +++++++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/sbin/startslip/startslip.1 b/sbin/startslip/startslip.1 index 4ecd526a4f3b..6d02e5897189 100644 --- a/sbin/startslip/startslip.1 +++ b/sbin/startslip/startslip.1 @@ -53,6 +53,8 @@ .Op Fl t Ar script_timeout .Op Fl W Ar maxtries .Op Fl w Ar retry_pause +.Op Fl K Ar keepalive +.Op Fl O Ar outfill .Ar device user passwd .Sh DESCRIPTION .Pp @@ -160,6 +162,16 @@ Dial sequence number (see passed via .Dv LINE environment variable. +.It Fl K Ar keepalive +Set SLIP "keep alive" timeout in seconds. If FRAME_END not received in this +timeout, reconnect occurse. Active "out fill" timeout expected from other +side. +Default value is no timeout. +.It Fl O Ar outfill +Set SLIP "out fill" timeout in seconds. It cause at least one FRAME_END +will be sended during this timeout. +Needed for "keep alive" timeout on other side. +Default value is no timeout. .El .Sh FILES .Bl -tag -width /var/run/startslip..pid -compact diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c index 0fcc2a24e430..87043559520f 100644 --- a/sbin/startslip/startslip.c +++ b/sbin/startslip/startslip.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: startslip.c,v 1.12 1995/09/15 22:18:45 ache Exp $ + * $Id: startslip.c,v 1.13 1995/09/16 05:18:20 ache Exp $ */ #ifndef lint @@ -108,10 +108,10 @@ main(argc, argv) extern int optind; char *cp, **ap; int ch, disc; - void sighup(), sigterm(); + void sighup(), sigterm(), sigurg(); FILE *wfd = NULL; char *dialerstring = 0, buf[BUFSIZ]; - int unitnum; + int unitnum, keepal = 0, outfill = 0; char unitname[32]; char *username, *password; char *upscript = NULL, *downscript = NULL; @@ -120,7 +120,7 @@ main(argc, argv) pid_t pid; struct termios t; - while ((ch = getopt(argc, argv, "dhlb:s:t:w:A:U:D:W:")) != EOF) + while ((ch = getopt(argc, argv, "dhlb:s:t:w:A:U:D:W:K:O:")) != EOF) switch (ch) { case 'd': debug = 1; @@ -160,6 +160,12 @@ main(argc, argv) case 'h': flowcontrol = FC_HW; break; + case 'K': + keepal = atoi(optarg); + break; + case 'O': + outfill = atoi(optarg); + break; case '?': default: usage(); @@ -191,6 +197,7 @@ main(argc, argv) if (debug) setbuf(stdout, NULL); + signal(SIGTERM, sigterm); if ((dvname = strrchr(devicename, '/')) == NULL) dvname = devicename; else @@ -206,8 +213,11 @@ main(argc, argv) sleep(5); /* allow down script to be completed */ } else restart: + signal(SIGHUP, SIG_IGN); + signal(SIGURG, SIG_IGN); + hup = 0; if (logged_in) { - sprintf(buf, "LINE=%d %s %s down &", + sprintf(buf, "LINE=%d %s %s down", diali ? (dialc - 1) % diali : 0, downscript ? downscript : "/sbin/ifconfig" , unitname); (void) system(buf); @@ -223,8 +233,6 @@ main(argc, argv) */ down(3); } - signal(SIGHUP, SIG_IGN); - hup = 0; if (wfd) { printd("fclose, "); fclose(wfd); @@ -233,8 +241,7 @@ main(argc, argv) wfd = NULL; fd = -1; sleep(5); - } - if (fd >= 0) { + } else if (fd >= 0) { printd("close, "); close(fd); uu_unlock(dvname); @@ -281,7 +288,6 @@ main(argc, argv) } printd(" %d", fd); signal(SIGHUP, sighup); - signal(SIGTERM, sigterm); if (debug) { if (ioctl(fd, TIOCGETD, &disc) < 0) syslog(LOG_ERR, "ioctl(TIOCSETD): %m"); @@ -422,11 +428,22 @@ main(argc, argv) } sprintf(unitname, "sl%d", unitnum); - sprintf(buf, "LINE=%d %s %s up &", + sprintf(buf, "LINE=%d %s %s up", diali ? (dialc - 1) % diali : 0, upscript ? upscript : "/sbin/ifconfig" , unitname); (void) system(buf); + if (keepal > 0) { + signal(SIGURG, sigurg); + if (ioctl(fd, SLIOCSKEEPAL, &keepal) < 0) { + syslog(LOG_ERR, "ioctl(SLIOCSKEEPAL): %m"); + down(2); + } + } + if (outfill > 0 && ioctl(fd, SLIOCSOUTFILL, &outfill) < 0) { + syslog(LOG_ERR, "ioctl(SLIOCSOUTFILL): %m"); + down(2); + } printd(", ready\n"); if (!first) syslog(LOG_INFO, "reconnected on %s (%d tries).\n", unitname, tries); @@ -450,6 +467,16 @@ sighup() hup = 1; } +void +sigurg() +{ + + printd("urg\n"); + if (hup == 0 && logged_in) + syslog(LOG_INFO, "dead line signal\n"); + hup = 1; +} + void sigterm() { @@ -547,6 +574,7 @@ usage() (void)fprintf(stderr, "\ usage: startslip [-d] [-b speed] [-s string1 [-s string2 [...]]] [-A annexname]\n\ [-h] [-l] [-U upscript] [-D downscript] [-t script_timeout]\n\ - [-w retry_pause] [-W maxtries] device user passwd\n"); + [-w retry_pause] [-W maxtries] [-K keepalive] [-O outfill]\n\ + device user passwd\n"); exit(1); }