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.
This commit is contained in:
Andrey A. Chernov 1995-09-17 21:47:24 +00:00
parent ae91233946
commit 3cfd1dbc21
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10860
2 changed files with 52 additions and 12 deletions

View file

@ -53,6 +53,8 @@
.Op Fl t Ar script_timeout .Op Fl t Ar script_timeout
.Op Fl W Ar maxtries .Op Fl W Ar maxtries
.Op Fl w Ar retry_pause .Op Fl w Ar retry_pause
.Op Fl K Ar keepalive
.Op Fl O Ar outfill
.Ar device user passwd .Ar device user passwd
.Sh DESCRIPTION .Sh DESCRIPTION
.Pp .Pp
@ -160,6 +162,16 @@ Dial sequence number (see
passed via passed via
.Dv LINE .Dv LINE
environment variable. 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 .El
.Sh FILES .Sh FILES
.Bl -tag -width /var/run/startslip.<device>.pid -compact .Bl -tag -width /var/run/startslip.<device>.pid -compact

View file

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 #ifndef lint
@ -108,10 +108,10 @@ main(argc, argv)
extern int optind; extern int optind;
char *cp, **ap; char *cp, **ap;
int ch, disc; int ch, disc;
void sighup(), sigterm(); void sighup(), sigterm(), sigurg();
FILE *wfd = NULL; FILE *wfd = NULL;
char *dialerstring = 0, buf[BUFSIZ]; char *dialerstring = 0, buf[BUFSIZ];
int unitnum; int unitnum, keepal = 0, outfill = 0;
char unitname[32]; char unitname[32];
char *username, *password; char *username, *password;
char *upscript = NULL, *downscript = NULL; char *upscript = NULL, *downscript = NULL;
@ -120,7 +120,7 @@ main(argc, argv)
pid_t pid; pid_t pid;
struct termios t; 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) { switch (ch) {
case 'd': case 'd':
debug = 1; debug = 1;
@ -160,6 +160,12 @@ main(argc, argv)
case 'h': case 'h':
flowcontrol = FC_HW; flowcontrol = FC_HW;
break; break;
case 'K':
keepal = atoi(optarg);
break;
case 'O':
outfill = atoi(optarg);
break;
case '?': case '?':
default: default:
usage(); usage();
@ -191,6 +197,7 @@ main(argc, argv)
if (debug) if (debug)
setbuf(stdout, NULL); setbuf(stdout, NULL);
signal(SIGTERM, sigterm);
if ((dvname = strrchr(devicename, '/')) == NULL) if ((dvname = strrchr(devicename, '/')) == NULL)
dvname = devicename; dvname = devicename;
else else
@ -206,8 +213,11 @@ main(argc, argv)
sleep(5); /* allow down script to be completed */ sleep(5); /* allow down script to be completed */
} else } else
restart: restart:
signal(SIGHUP, SIG_IGN);
signal(SIGURG, SIG_IGN);
hup = 0;
if (logged_in) { if (logged_in) {
sprintf(buf, "LINE=%d %s %s down &", sprintf(buf, "LINE=%d %s %s down",
diali ? (dialc - 1) % diali : 0, diali ? (dialc - 1) % diali : 0,
downscript ? downscript : "/sbin/ifconfig" , unitname); downscript ? downscript : "/sbin/ifconfig" , unitname);
(void) system(buf); (void) system(buf);
@ -223,8 +233,6 @@ main(argc, argv)
*/ */
down(3); down(3);
} }
signal(SIGHUP, SIG_IGN);
hup = 0;
if (wfd) { if (wfd) {
printd("fclose, "); printd("fclose, ");
fclose(wfd); fclose(wfd);
@ -233,8 +241,7 @@ main(argc, argv)
wfd = NULL; wfd = NULL;
fd = -1; fd = -1;
sleep(5); sleep(5);
} } else if (fd >= 0) {
if (fd >= 0) {
printd("close, "); printd("close, ");
close(fd); close(fd);
uu_unlock(dvname); uu_unlock(dvname);
@ -281,7 +288,6 @@ main(argc, argv)
} }
printd(" %d", fd); printd(" %d", fd);
signal(SIGHUP, sighup); signal(SIGHUP, sighup);
signal(SIGTERM, sigterm);
if (debug) { if (debug) {
if (ioctl(fd, TIOCGETD, &disc) < 0) if (ioctl(fd, TIOCGETD, &disc) < 0)
syslog(LOG_ERR, "ioctl(TIOCSETD): %m"); syslog(LOG_ERR, "ioctl(TIOCSETD): %m");
@ -422,11 +428,22 @@ main(argc, argv)
} }
sprintf(unitname, "sl%d", unitnum); sprintf(unitname, "sl%d", unitnum);
sprintf(buf, "LINE=%d %s %s up &", sprintf(buf, "LINE=%d %s %s up",
diali ? (dialc - 1) % diali : 0, diali ? (dialc - 1) % diali : 0,
upscript ? upscript : "/sbin/ifconfig" , unitname); upscript ? upscript : "/sbin/ifconfig" , unitname);
(void) system(buf); (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"); printd(", ready\n");
if (!first) if (!first)
syslog(LOG_INFO, "reconnected on %s (%d tries).\n", unitname, tries); syslog(LOG_INFO, "reconnected on %s (%d tries).\n", unitname, tries);
@ -450,6 +467,16 @@ sighup()
hup = 1; hup = 1;
} }
void
sigurg()
{
printd("urg\n");
if (hup == 0 && logged_in)
syslog(LOG_INFO, "dead line signal\n");
hup = 1;
}
void void
sigterm() sigterm()
{ {
@ -547,6 +574,7 @@ usage()
(void)fprintf(stderr, "\ (void)fprintf(stderr, "\
usage: startslip [-d] [-b speed] [-s string1 [-s string2 [...]]] [-A annexname]\n\ usage: startslip [-d] [-b speed] [-s string1 [-s string2 [...]]] [-A annexname]\n\
[-h] [-l] [-U upscript] [-D downscript] [-t script_timeout]\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); exit(1);
} }