summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-09-17 21:47:24 +0000
committerache <ache@FreeBSD.org>1995-09-17 21:47:24 +0000
commitb6cff6618d68d8f077b8041b582ff3309b8e5a83 (patch)
tree2a2d231ee591477bd241ab7f5d64b714ffcb1d66
parent56c45001bbf30f6cdffe2e303a7cadee491849d4 (diff)
downloadFreeBSD-src-b6cff6618d68d8f077b8041b582ff3309b8e5a83.zip
FreeBSD-src-b6cff6618d68d8f077b8041b582ff3309b8e5a83.tar.gz
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.
-rw-r--r--sbin/startslip/startslip.112
-rw-r--r--sbin/startslip/startslip.c52
2 files changed, 52 insertions, 12 deletions
diff --git a/sbin/startslip/startslip.1 b/sbin/startslip/startslip.1
index 4ecd526..6d02e58 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.<device>.pid -compact
diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c
index 0fcc2a2..8704355 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 @@ restart:
*/
down(3);
}
- signal(SIGHUP, SIG_IGN);
- hup = 0;
if (wfd) {
printd("fclose, ");
fclose(wfd);
@@ -233,8 +241,7 @@ restart:
wfd = NULL;
fd = -1;
sleep(5);
- }
- if (fd >= 0) {
+ } else if (fd >= 0) {
printd("close, ");
close(fd);
uu_unlock(dvname);
@@ -281,7 +288,6 @@ restart:
}
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 @@ restart:
}
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);
@@ -451,6 +468,16 @@ sighup()
}
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);
}
OpenPOWER on IntegriCloud