- return(FAIL);
- }
-
-#ifdef DN11
-
-/***
- * dnopn(ph, flds, dev) dial remote machine
- * char *ph;
- * char *flds[];
- * struct Devices *dev;
- *
- * return codes:
- * file descriptor - succeeded
- * FAIL - failed
- */
-
-dnopn(ph, flds, dev)
-char *ph;
-char *flds[];
-struct Devices *dev;
-{
- char dcname[20], dnname[20], phone[MAXPH+2], c = 0;
-#ifdef SYSIII
- struct termio ttbuf;
-#endif
- int dnf, dcf;
- int nw, lt, pid, status;
- unsigned timelim;
-
- sprintf(dnname, "/dev/%s", dev->D_calldev);
- errno = 0;
-
- if (setjmp(Sjbuf)) {
- logent(dnname, "CAN'T OPEN");
- DEBUG(4, "%s Open timed out\n", dnname);
- return(CF_NODEV);
- }
- signal(SIGALRM, alarmtr);
- getnextfd();
- alarm(10);
- dnf = open(dnname, 1);
- alarm(0);
- next_fd = -1;
- if (dnf < 0 && errno == EACCES) {
- logent(dnname, "CAN'T OPEN");
- logent("DEVICE", "NO");
- return(CF_NODEV);
- }
- /* rti!trt: avoid passing acu file descriptor to children */
- fioclex(dnf);
-
- sprintf(dcname, "/dev/%s", dev->D_line);
- sprintf(phone, "%s%s", ph, ACULAST);
- DEBUG(4, "dc - %s, ", dcname);
- DEBUG(4, "acu - %s\n", dnname);
- pid = 0;
- if (setjmp(Sjbuf)) {
- logent("DIALUP DN write", "TIMEOUT");
- if (pid)
- kill(pid, 9);
- delock(dev->D_line);
- if (dnf)
- close(dnf);
- return(FAIL);
- }
- signal(SIGALRM, alarmtr);
- timelim = 5 * strlen(phone);
- alarm(timelim < 30 ? 30 : timelim);
- if ((pid = fork()) == 0) {
- sleep(2);
- fclose(stdin);
- fclose(stdout);
-#ifdef TIOCFLUSH
- ioctl(dnf, TIOCFLUSH, STBNULL);
-#endif
- nw = write(dnf, phone, lt = strlen(phone));
- if (nw != lt) {
- logent("DIALUP ACU write", "FAILED");
- exit(1);
- }
- DEBUG(4, "ACU write ok%s\n", "");
- exit(0);
- }
- /* open line - will return on carrier */
- /* RT needs a sleep here because it returns immediately from open */
-
-#if RT
- sleep(15);
-#endif
-
- getnextfd();
- errno = 0;
- dcf = open(dcname, 2);
- next_fd = -1;
- if (dcf < 0 && errno == EACCES)
- logent(dcname, "CAN'T OPEN");
- DEBUG(4, "dcf is %d\n", dcf);
- if (dcf < 0) {
- logent("DIALUP LINE open", "FAILED");
- alarm(0);
- kill(pid, 9);
- close(dnf);
- delock(dev->D_line);
- return(FAIL);
- }
- /* brl-bmd.351 (Doug Kingston) says the next ioctl is unneeded . */
-/* ioctl(dcf, TIOCHPCL, STBNULL);*/
- while ((nw = wait(<)) != pid && nw != -1)
- ;
-#ifdef SYSIII
- ioctl(dcf, TCGETA, &ttbuf);
- if(!(ttbuf.c_cflag & HUPCL)) {
- ttbuf.c_cflag |= HUPCL;
- ioctl(dcf, TCSETA, &ttbuf);
- }
-#endif
- alarm(0);
- fflush(stdout);
- fixline(dcf, dev->D_speed);
- DEBUG(4, "Fork Stat %o\n", lt);
- if (lt != 0) {
- close(dcf);
- if (dnf)
- close(dnf);
- delock(dev->D_line);
- return(FAIL);
- }
- return(dcf);
-}
-
-/***
- * dncls() close dn type call unit
- *
- * return codes: None
- */
-dncls(fd)
-register int fd;
-{
- if (fd > 0) {
- close(fd);
- sleep(5);
- delock(devSel);
- }
-}
-#endif DN11
-
-#ifdef DF02
-/***
- * df2opn(ph, flds, dev) dial remote machine
- * char *ph;
- * char *flds[];
- * struct Devices *dev;
- *
- * return codes:
- * file descriptor - succeeded
- * FAIL - failed
- *
- * Modified 9/28/81 by Bill Shannon (DEC)
- * Changed to use DEC DF02 or DF03 ACU
- */
-
-
-df2opn(ph, flds, dev)
-char *ph;
-char *flds[];
-struct Devices *dev;
-{
- char dcname[20], dnname[20], phone[MAXPH+2], c = 0;
-#ifdef SYSIII
- struct termio ttbuf;
-#endif
- int dcf, dnf;
- int nw, lt, pid, st, status;
- unsigned timelim;
-
- sprintf(dnname, "/dev/%s", dev->D_calldev);
- if (setjmp(Sjbuf)) {
- logent(dnname, "CAN'T OPEN");
- DEBUG(4, "%s Open timed out\n", dnname);
- return(CF_NODEV);
- }
- signal(SIGALRM, alarmtr);
- getnextfd();
- errno = 0;
- alarm(10);
- dnf = open(dnname, 2 );
- alarm(0);
- next_fd = -1;
- if (dnf < 0 && errno == EACCES) {
- logent(dnname, "CAN'T OPEN");
- delock(dev->D_line);
- logent("DEVICE", "NO");
- return(CF_NODEV);
- }
- /* rti!trt: avoid passing acu file descriptor to children */
- fioclex(dnf);
-
- sprintf(dcname, "/dev/%s", dev->D_line);
- fixline(dnf, dev->D_speed);
- sprintf(phone, "\02%s", ph);
- DEBUG(4, "dc - %s, ", dcname);
- DEBUG(4, "acu - %s\n", dnname);
- pid = 0;
- if (setjmp(Sjbuf)) {
- logent("DIALUP DN write", "TIMEOUT");
- if (pid)
- kill(pid, 9);
- delock(dev->D_line);
- if (dnf)
- close(dnf);
- return(FAIL);
- }
- signal(SIGALRM, alarmtr);
- timelim = 5 * strlen(phone);
- alarm(timelim < 30 ? 30 : timelim);
- if ((pid = fork()) == 0) {
- sleep(2);
- fclose(stdin);
- fclose(stdout);
-#ifdef TIOCFLUSH
- ioctl(dnf, TIOCFLUSH, STBNULL);
-#endif
- write(dnf, "\01", 1);
- sleep(1);
- nw = write(dnf, phone, lt = strlen(phone));
- if (nw != lt) {
- logent("DIALUP ACU write", "FAILED");
- exit(1);
- }
- DEBUG(4, "ACU write ok%s\n", "");
- exit(0);
- }
- /* open line - will return on carrier */
- /* RT needs a sleep here because it returns immediately from open */
-
-#if RT
- sleep(15);
-#endif
-
- if (read(dnf, &c, 1) != 1 || c != 'A')
- dcf = -1;
- else
- dcf = 0;
- DEBUG(4, "dcf is %d\n", dcf);
- if (dcf < 0) {
- logent("DIALUP LINE open", "FAILED");
- alarm(0);
- kill(pid, 9);
- close(dnf);
- delock(dev->D_line);
- return(FAIL);
- }
- dcf = dnf;
- dnf = 0;
- /* brl-bmd.351 (Doug Kingston) says the next ioctl is unneeded . */
-/* ioctl(dcf, TIOCHPCL, STBNULL);*/
- while ((nw = wait(<)) != pid && nw != -1)
- ;
-#ifdef SYSIII
- ioctl(dcf, TCGETA, &ttbuf);
- if(!(ttbuf.c_cflag & HUPCL)) {
- ttbuf.c_cflag |= HUPCL;
- ioctl(dcf, TCSETA, &ttbuf);
- }
-#endif
- alarm(0);
- fflush(stdout);
- fixline(dcf, dev->D_speed);
- DEBUG(4, "Fork Stat %o\n", lt);
- if (lt != 0) {
- close(dcf);
- if (dnf)
- close(dnf);
- delock(dev->D_line);
- return(FAIL);
- }
- return(dcf);
-}
-
-/*
- * df2cls() close the DF02/DF03 call unit
- *
- * return codes: none
- */
-
-df2cls(fd)
-register int fd;
-{
- if (fd > 0) {
- close(fd);
- sleep(5);
- delock(devSel);
- }
-}
-#endif DF02
-
-#ifdef HAYES
-/***
- * hysopn(telno, flds, dev) connect to hayes smartmodem
- * char *flds[], *dev[];
- *
- * return codes:
- * >0 - file number - ok
- * CF_DIAL,CF_DEVICE - failed
- */
-/*
- * Define HAYSTONE if you have touch tone dialing.
- */
-/*#define HAYSTONE */
-
-hysopn(telno, flds, dev)
-char *telno;
-char *flds[];
-struct Devices *dev;
-{
- int dh = -1;
- extern errno;
- char dcname[20];
-
- sprintf(dcname, "/dev/%s", dev->D_line);
- DEBUG(4, "dc - %s\n", dcname);
- if (setjmp(Sjbuf)) {
- DEBUG(1, "timeout hayes open %s\n", dcname);
- logent("hayes open", "TIMEOUT");
- if (dh >= 0)
- close(dh);
- delock(dev->D_line);
- return(CF_DIAL);
- }
- signal(SIGALRM, alarmtr);
- getnextfd();
- alarm(10);
- dh = open(dcname, 2); /* read/write */
- alarm(0);
-
- /* modem is open */
- next_fd = -1;
- if (dh >= 0) {
- fixline(dh, dev->D_speed);
-#ifdef HAYSTONE
- write(dh, "\rATDT", 5);
-#else
- write(dh, "\rATDP", 5);
-#endif
- write(dh, telno, strlen(telno));
- write(dh, "\r", 1);
-
- if (expect("CONNECT", dh) != 0) {
- logent("HSM no carrier", "FAILED");
- strcpy(devSel, dev->D_line);
- hyscls(dh);
- return(CF_DIAL);
- }
-
- }
- if (dh < 0) {
- DEBUG(4, "hayes failed\n", "");
- delock(dev->D_line);
- }
- DEBUG(4, "hayes ok\n", "");
- return(dh);
-}
-
-hyscls(fd)
-int fd;
-{
- char dcname[20];
- struct sgttyb hup, sav;
-
- if (fd > 0) {
- sprintf(dcname, "/dev/%s", devSel);
- DEBUG(4, "Hanging up fd = %d\n", fd);
-/*
- * code to drop DTR -- change to 0 baud then back to default.
- */
- gtty(fd, &hup);
- gtty(fd, &sav);
- hup.sg_ispeed = B0;
- hup.sg_ospeed = B0;
- stty(fd, &hup);
- sleep(2);
- stty(fd, &sav);
-/*
- * now raise DTR -- close the device & open it again.
- */
- sleep(2);
- close(fd);
- sleep(2);
- fd = open(dcname, 2);
-/*
- * Since we have a getty sleeping on this line, when it wakes up it sends
- * all kinds of garbage to the modem. Unfortunatly, the modem likes to
- * execute the previous command when it sees the garbage. The previous
- * command was to dial the phone, so let's make the last command reset
- * the modem.
- */
- sleep(2);
- write(fd, "\rATZ\r", 5);
- close(fd);
- delock(devSel);
- }
- }
-
-#endif HAYES
-
-#ifdef HAYESQ
-/*
- * New dialout routine to work with Hayes' SMART MODEM
- * 13-JUL-82, Mike Mitchell
- * Modified 23-MAR-83 to work with Tom Truscott's (rti!trt)
- * version of UUCP (ncsu!mcm)
- *
- * The modem should be set to NOT send any result codes to
- * the system (switch 3 up, 4 down). This end will figure out
- * what is wrong.
- *
- * I had lots of problems with the modem sending
- * result codes since I am using the same modem for both incomming and
- * outgoing calls. I'd occasionally miss the result code (getty would
- * grab it), and the connect would fail. Worse yet, the getty would
- * think the result code was a user name, and send garbage to it while
- * it was in the command state. I turned off ALL result codes, and hope
- * for the best. 99% of the time the modem is in the correct state.
- * Occassionally it doesn't connect, or the phone was busy, etc., and
- * uucico sits there trying to log in. It eventually times out, calling
- * clsacu() in the process, so it resets itself for the next attempt.
- */
-
-/*
- * Define HAYSTONE if touch-tone dialing is to be used. If it is not defined,
- * Pulse dialing is assumed.
- */
-/*#define HAYSTONE*/
-
-hysqopn(telno, flds, dev)
-char *telno, *flds[];
-struct Devices *dev;
-{
- char dcname[20], phone[MAXPH+10], c = 0;
-#ifdef SYSIII
- struct termio ttbuf;
-#endif
- int status, dnf;
- unsigned timelim;
-
- signal(SIGALRM, alarmtr);
- sprintf(dcname, "/dev/%s", dev->D_line);
-
- getnextfd();
- if (setjmp(Sjbuf)) {
- delock(dev->D_line);
- logent("DEVICE", "NO");
- DEBUG(4, "Open timed out %s", dcname);
- return(CF_NODEV);
- }
- alarm(10);
-
- if ((dnf = open(dcname, 2)) <= 0) {
- delock(dev->D_line);
- logent("DEVICE", "NO");
- DEBUG(4, "Can't open %s", dcname);
- return(CF_NODEV);
- }
-
- alarm(0);
- next_fd = -1;
- fixline(dnf, dev->D_speed);
- DEBUG(4, "Hayes port - %s, ", dcname);
-
-#ifdef HAYSTONE
- sprintf(phone, "\rATDT%s\r", telno);
-#else
- sprintf(phone, "\rATDP%s\r", telno);
-#endif
-
- write(dnf, phone, strlen(phone));
-
-/* calculate delay time for the other system to answer the phone.
- * Default is 15 seconds, add 2 seconds for each comma in the phone
- * number.
- */
- timelim = 150;
- while(*telno) {
- c = *telno++;
- if (c == ',')
- timelim += 20;
- else {
-#ifdef HAYSTONE
- timelim += 2; /* .2 seconds per tone */
- }
-#else
- if (c == '0') timelim += 10; /* .1 second per digit */
- else if (c > '0' && c <= '9')
- timelim += (c - '0');
- }
-#endif
- }
- alarm(timelim/10);
- if (setjmp(Sjbuf) == 0) {
- read(dnf, &c, 1);
- alarm(0);
- }
-
- return(dnf);
- }
-
-hysqcls(fd)
-int fd;
-{
- char dcname[20];
- struct sgttyb hup, sav;
-
- if (fd > 0) {
- sprintf(dcname, "/dev/%s", devSel);
- DEBUG(4, "Hanging up fd = %d\n", fd);
-/*
- * code to drop DTR -- change to 0 baud then back to default.
- */
- gtty(fd, &hup);
- gtty(fd, &sav);
- hup.sg_ispeed = B0;
- hup.sg_ospeed = B0;
- stty(fd, &hup);
- sleep(2);
- stty(fd, &sav);
-/*
- * now raise DTR -- close the device & open it again.
- */
- sleep(2);
- close(fd);
- sleep(2);
- fd = open(dcname, 2);
-/*
- * Since we have a getty sleeping on this line, when it wakes up it sends
- * all kinds of garbage to the modem. Unfortunatly, the modem likes to
- * execute the previous command when it sees the garbage. The previous
- * command was to dial the phone, so let's make the last command reset
- * the modem.
- */
- sleep(2);
- write(fd, "\rATZ\r", 5);
- close(fd);
- delock(devSel);
- }
- }
-
-#endif HAYESQ
-
-#ifdef VENTEL
-ventopn(telno, flds, dev)
-char *flds[], *telno;
-struct Devices *dev;
-{
- int dh;
- int i, ok = -1;
- char dcname[20];
-
- sprintf(dcname, "/dev/%s", dev->D_line);
- if (setjmp(Sjbuf)) {
- DEBUG(1, "timeout ventel open\n", "");
- logent("ventel open", "TIMEOUT");
- if (dh >= 0)
- close(dh);
- delock(dev->D_line);
- return(CF_NODEV);
- }
- signal(SIGALRM, alarmtr);
- getnextfd();
- alarm(10);
- dh = open(dcname, 2);
- next_fd = -1;
- if (dh < 0) {
- DEBUG(4,"%s\n", errno == 4 ? "no carrier" : "can't open modem");
- delock(dev->D_line);
- return(errno == 4 ? CF_DIAL : CF_NODEV);
- }
-
- /* modem is open */
- fixline(dh, dev->D_speed);
-
- /* translate - to % and = to & for VenTel */
- DEBUG(4, "calling %s -> ", telno);
- for (i = 0; i < strlen(telno); ++i) {
- switch(telno[i]) {
- case '-': /* delay */
- telno[i] = '%';
- break;
- case '=': /* await dial tone */
- telno[i] = '&';
- break;
- case '<':
- telno[i] = '%';
- break;
- }
- }
- DEBUG(4, "%s\n", telno);
- sleep(1);
- for(i = 0; i < 5; ++i) { /* make up to 5 tries */
- slowrite(dh, "\r\r");/* awake, thou lowly VenTel! */
-
- DEBUG(4, "wanted %s ", "$");
- ok = expect("$", dh);
- DEBUG(4, "got %s\n", ok ? "?" : "that");
- if (ok != 0)
- continue;
- slowrite(dh, "K"); /* "K" (enter number) command */
- DEBUG(4, "wanted %s ", "DIAL: ");
- ok = expect("DIAL: ", dh);
- DEBUG(4, "got %s\n", ok ? "?" : "that");
- if (ok == 0)
- break;
- }
-
- if (ok == 0) {
- slowrite(dh, telno); /* send telno, send \r */
- slowrite(dh, "\r");
- DEBUG(4, "wanted %s ", "ONLINE");
- ok = expect("ONLINE!", dh);
- DEBUG(4, "got %s\n", ok ? "?" : "that");
- }
- if (ok != 0) {
- if (dh > 2)
- close(dh);
- DEBUG(4, "venDial failed\n", "");
- return(CF_DIAL);
- } else
- DEBUG(4, "venDial ok\n", "");
- return(dh);