122416Sdist /* 2*35492Sbostic * Copyright (c) 1983 The Regents of the University of California. 3*35492Sbostic * All rights reserved. 4*35492Sbostic * 5*35492Sbostic * Redistribution and use in source and binary forms are permitted 6*35492Sbostic * provided that the above copyright notice and this paragraph are 7*35492Sbostic * duplicated in all such forms and that any documentation, 8*35492Sbostic * advertising materials, and other materials related to such 9*35492Sbostic * distribution and use acknowledge that the software was developed 10*35492Sbostic * by the University of California, Berkeley. The name of the 11*35492Sbostic * University may not be used to endorse or promote products derived 12*35492Sbostic * from this software without specific prior written permission. 13*35492Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*35492Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*35492Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1622416Sdist */ 1722416Sdist 1813278Ssam #ifndef lint 19*35492Sbostic static char sccsid[] = "@(#)df.c 5.2 (Berkeley) 09/13/88"; 20*35492Sbostic #endif /* not lint */ 2113278Ssam 223690Sroot /* 234480Ssam * Dial the DF02-AC or DF03-AC 243690Sroot */ 253690Sroot 263690Sroot #include "tip.h" 273690Sroot 2813278Ssam static jmp_buf Sjbuf; 293690Sroot static timeout(); 303690Sroot 314480Ssam df02_dialer(num, acu) 324962Ssam char *num, *acu; 333690Sroot { 3413278Ssam 355134Ssam return (df_dialer(num, acu, 0)); 364480Ssam } 374480Ssam 384480Ssam df03_dialer(num, acu) 394962Ssam char *num, *acu; 404480Ssam { 4113278Ssam 425134Ssam return (df_dialer(num, acu, 1)); 434480Ssam } 444480Ssam 454480Ssam df_dialer(num, acu, df03) 464962Ssam char *num, *acu; 474962Ssam int df03; 484480Ssam { 493690Sroot register int f = FD; 504480Ssam struct sgttyb buf; 5113278Ssam int speed = 0, rw = 2; 5213278Ssam char c = '\0'; 533690Sroot 543690Sroot ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */ 553690Sroot if (setjmp(Sjbuf)) { 563690Sroot printf("connection timed out\r\n"); 573690Sroot df_disconnect(); 585134Ssam return (0); 593690Sroot } 603690Sroot if (boolean(value(VERBOSE))) 613690Sroot printf("\ndialing..."); 623690Sroot fflush(stdout); 634480Ssam #ifdef TIOCMSET 644480Ssam if (df03) { 6513278Ssam int st = TIOCM_ST; /* secondary Transmit flag */ 6613278Ssam 674480Ssam ioctl(f, TIOCGETP, &buf); 684480Ssam if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */ 694480Ssam speed = buf.sg_ospeed; 704480Ssam buf.sg_ospeed = buf.sg_ispeed = B1200; 714480Ssam ioctl(f, TIOCSETP, &buf); 724480Ssam ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ 734480Ssam } else 744480Ssam ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ 754480Ssam } 764480Ssam #endif 773690Sroot signal(SIGALRM, timeout); 783690Sroot alarm(5 * strlen(num) + 10); 7913278Ssam ioctl(f, TIOCFLUSH, &rw); 803690Sroot write(f, "\001", 1); 814480Ssam sleep(1); 823690Sroot write(f, "\002", 1); 833690Sroot write(f, num, strlen(num)); 8413278Ssam read(f, &c, 1); 854480Ssam #ifdef TIOCMSET 864480Ssam if (df03 && speed) { 874480Ssam buf.sg_ispeed = buf.sg_ospeed = speed; 884480Ssam ioctl(f, TIOCSETP, &buf); 894480Ssam } 904480Ssam #endif 915134Ssam return (c == 'A'); 923690Sroot } 933690Sroot 943690Sroot df_disconnect() 953690Sroot { 9613278Ssam int rw = 2; 9713278Ssam 983690Sroot write(FD, "\001", 1); 993690Sroot sleep(1); 10013278Ssam ioctl(FD, TIOCFLUSH, &rw); 1013690Sroot } 1023690Sroot 1033690Sroot 1043690Sroot df_abort() 1053690Sroot { 10613278Ssam 10713278Ssam df_disconnect(); 1083690Sroot } 1093690Sroot 1103690Sroot 1113690Sroot static 1123690Sroot timeout() 1133690Sroot { 11413278Ssam 1153690Sroot longjmp(Sjbuf, 1); 1163690Sroot } 117