*/
#ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.7 1994/04/18 04:06:26 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.9 1994/05/09 02:40:21 paulus Exp $";
#endif
#define SETSID
char devname[MAXPATHLEN] = "/dev/tty"; /* Device name */
int default_device = TRUE; /* use default device (stdin/out) */
-int fd; /* Device file descriptor */
+int fd = -1; /* Device file descriptor */
int s; /* Socket file descriptor */
int phase; /* where the link is at */
}
#endif /* TIOCSCTTY */
- /* set line speed, flow control, etc. */
- set_up_tty(fd);
-
/* run connection script */
if (connector) {
MAINDEBUG((LOG_INFO, "Connecting with <%s>", connector));
+ /* set line speed, flow control, etc.; set CLOCAL for now */
+ set_up_tty(fd, 1);
+
/* drop dtr to hang up in case modem is off hook */
if (!default_device && modem) {
setdtr(fd, FALSE);
sleep(1); /* give it time to set up its terminal */
}
+ /* set line speed, flow control, etc.; clear CLOCAL if modem option */
+ set_up_tty(fd, 0);
+
/* set up the serial device as a ppp interface */
establish_ppp();
/*
* set_up_tty: Set up the serial port on `fd' for 8 bits, no parity,
- * at the requested speed, etc.
+ * at the requested speed, etc. If `local' is true, set CLOCAL
+ * regardless of whether the modem option was specified.
*/
-set_up_tty(fd)
- int fd;
+set_up_tty(fd, local)
+ int fd, local;
{
#ifndef SGTTY
- int speed;
+ int speed, x;
struct termios tios;
if (tcgetattr(fd, &tios) < 0) {
#endif /* CRTSCTS */
tios.c_cflag |= CS8 | CREAD | HUPCL;
- if (!modem)
+ if (local || !modem)
tios.c_cflag |= CLOCAL;
tios.c_iflag = IGNBRK | IGNPAR;
tios.c_oflag = 0;
die(1);
}
+#ifdef ultrix
+ x = 0;
+ if (ioctl(fd, (crtscts || modem)? TIOCMODEM: TIOCNMODEM, &x) < 0)
+ syslog(LOG_WARNING, "TIOC(N)MODEM: %m");
+ if (ioctl(fd, (local || !modem)? TIOCNCAR: TIOCCAR) < 0)
+ syslog(LOG_WARNING, "TIOC(N)CAR: %m");
+#endif
+
#else /* SGTTY */
int speed;
struct sgttyb sgttyb;
if (modem)
setdtr(fd, FALSE);
- if (fcntl(fd, F_SETFL, initfdflags) < 0)
+ if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
syslog(LOG_WARNING, "fcntl(F_SETFL, fdflags): %m");
disestablish_ppp();
MAINDEBUG((LOG_DEBUG, "Alarm"));
+ if (callout == NULL)
+ return;
/*
* Get the first scheduled timeout and any that were scheduled
* for the same time as a list, and remove them all from callout