Date: Mon, 27 Mar 1995 00:39:27 -0800 From: Tom Gray - DCA <dcasba@rain.org> To: freebsd-hackers@FreeBSD.org Subject: Patches for tip - part 3 Message-ID: <199503270839.AAA12832@coyote.rain.org>
next in thread | raw e-mail | index | archive | help
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 3 (of 3)." # Contents: patches.tip.2 # Wrapped by john@grudunza on Mon Mar 27 00:09:39 1995 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'patches.tip.2' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patches.tip.2'\" else echo shar: Extracting \"'patches.tip.2'\" \(51555 characters\) sed "s/^X//" >'patches.tip.2' <<'END_OF_FILE' Xdiff -r -c ./libacu/multitech.c libacu/multitech.c X*** ./libacu/multitech.c Sun Mar 26 18:47:09 1995 X--- libacu/multitech.c Fri Mar 24 00:25:15 1995 X*************** X*** 0 **** X--- 1,402 ---- X+ /* X+ * Copyright (c) 1986, 1993 X+ * The Regents of the University of California. All rights reserved. X+ * X+ * Redistribution and use in source and binary forms, with or without X+ * modification, are permitted provided that the following conditions X+ * are met: X+ * 1. Redistributions of source code must retain the above copyright X+ * notice, this list of conditions and the following disclaimer. X+ * 2. Redistributions in binary form must reproduce the above copyright X+ * notice, this list of conditions and the following disclaimer in the X+ * documentation and/or other materials provided with the distribution. X+ * 3. All advertising materials mentioning features or use of this software X+ * must display the following acknowledgement: X+ * This product includes software developed by the University of X+ * California, Berkeley and its contributors. X+ * 4. Neither the name of the University nor the names of its contributors X+ * may be used to endorse or promote products derived from this software X+ * without specific prior written permission. X+ * X+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X+ * SUCH DAMAGE. X+ */ X+ X+ #ifndef lint X+ static char sccsid[] = "@(#)multitech.c 8.1 (Berkeley) 6/6/93"; X+ #endif /* not lint */ X+ X+ /* X+ * Routines for calling up on a Courier modem. X+ * Derived from Hayes driver. X+ */ X+ #include "tipconf.h" X+ #include "tip.h" X+ #include "acucommon.h" X+ X+ #include <stdio.h> X+ X+ /* #define DEBUG /**/ X+ #define MAXRETRY 5 X+ /* X+ Configuration X+ */ X+ static CONST char *dial_command = "ATDT"; X+ static CONST char *hangup_command = "ATH\r"; X+ static CONST char *echo_off_command = "ATE0\r"; X+ static CONST char *reset_command = "\rATZ\r"; X+ static CONST char *init_string = "AT$BA0$SB38400&E1&E4&E13&E15Q0V1X4E0S0=0\r"; X+ static CONST char *escape_sequence = "+++"; /* return to command escape sequence */ X+ static CONST int lock_baud = 1; X+ static CONST unsigned int intercharacter_delay = 20; X+ static CONST unsigned int intercommand_delay = 250; X+ static CONST unsigned int escape_guard_time = 250; X+ static CONST unsigned int reset_delay = 2000; X+ X+ /* X+ Forward declarations X+ */ X+ void multitech_write (int fd, CONST char *cp, int n); X+ void multitech_write_str (int fd, CONST char *cp); X+ void multitech_disconnect (); X+ void acu_nap (unsigned int how_long); X+ static void sigALRM (); X+ static int multitechsync (); X+ static int multitech_swallow (register char *match); X+ X+ /* X+ Global vars X+ */ X+ static int timeout = 0; X+ static int connected = 0; X+ static jmp_buf timeoutbuf, intbuf; X+ X+ int multitech_dialer (register char *num, char *acu) X+ { X+ register char *cp; X+ #if ACULOG X+ char line [80]; X+ #endif X+ static int multitech_connect(), multitech_swallow(); X+ X+ if (lock_baud) X+ { X+ int i; X+ if ((i = speed(number(value(BAUDRATE)))) == NULL) X+ return 0; X+ ttysetup (i); X+ } X+ X+ if (boolean(value(VERBOSE))) X+ printf("Using \"%s\"\n", acu); X+ X+ acu_hupcl (); X+ X+ /* X+ * Get in synch. X+ */ X+ if (!multitechsync()) { X+ badsynch: X+ printf("can't synchronize with multitech\n"); X+ #if ACULOG X+ logent(value(HOST), num, "multitech", "can't synch up"); X+ #endif X+ return (0); X+ } X+ acu_nap (intercommand_delay); X+ X+ multitech_write_str (FD, echo_off_command); /* turn off echoing */ X+ X+ sleep(1); X+ X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ multitech_verbose_read(); X+ #endif X+ X+ acu_flush (); X+ X+ acu_nap (intercommand_delay); X+ multitech_write_str (FD, init_string); X+ X+ if (!multitech_swallow ("\r\nOK\r\n")) X+ goto badsynch; X+ X+ fflush (stdout); X+ X+ acu_nap (intercommand_delay); X+ multitech_write_str (FD, dial_command); X+ X+ for (cp = num; *cp; cp++) X+ if (*cp == '=') X+ *cp = ','; X+ X+ multitech_write_str (FD, num); X+ X+ multitech_write_str (FD, "\r"); X+ X+ connected = multitech_connect(); X+ X+ #if ACULOG X+ if (timeout) { X+ sprintf(line, "%d second dial timeout", X+ number(value(DIALTIMEOUT))); X+ logent(value(HOST), num, "multitech", line); X+ } X+ #endif X+ if (timeout) X+ multitech_disconnect (); X+ return (connected); X+ } X+ X+ void multitech_disconnect () X+ { X+ int okay, retries; X+ for (retries = okay = 0; retries < 3 && !okay; retries++) X+ { X+ /* first hang up the modem*/ X+ ioctl (FD, TIOCCDTR, 0); X+ acu_nap (escape_guard_time); X+ ioctl (FD, TIOCSDTR, 0); X+ acu_nap (escape_guard_time); X+ /* X+ * If not strapped for DTR control, try to get command mode. X+ */ X+ acu_nap (escape_guard_time); X+ multitech_write_str (FD, escape_sequence); X+ acu_nap (escape_guard_time); X+ multitech_write_str (FD, hangup_command); X+ okay = multitech_swallow ("\r\nOK\r\n"); X+ } X+ if (!okay) X+ { X+ #if ACULOG X+ logent(value(HOST), "", "multitech", "can't hang up modem"); X+ #endif X+ if (boolean(value(VERBOSE))) X+ printf("hang up failed\n"); X+ } X+ close (FD); X+ } X+ X+ void multitech_abort () X+ { X+ multitech_write_str (FD, "\r"); /* send anything to abort the call */ X+ multitech_disconnect (); X+ } X+ X+ static void sigALRM () X+ { X+ (void) printf("\07timeout waiting for reply\n"); X+ timeout = 1; X+ longjmp(timeoutbuf, 1); X+ } X+ X+ static int multitech_swallow (register char *match) X+ { X+ sig_t f; X+ char c; X+ X+ f = signal(SIGALRM, sigALRM); X+ timeout = 0; X+ do { X+ if (*match =='\0') { X+ signal(SIGALRM, f); X+ return (1); X+ } X+ if (setjmp(timeoutbuf)) { X+ signal(SIGALRM, f); X+ return (0); X+ } X+ alarm(number(value(DIALTIMEOUT))); X+ read(FD, &c, 1); X+ alarm(0); X+ c &= 0177; X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ putchar(c); X+ #endif X+ } while (c == *match++); X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ fflush (stdout); X+ #endif X+ signal(SIGALRM, SIG_DFL); X+ return (0); X+ } X+ X+ static struct baud_msg { X+ char *msg; X+ int baud; X+ } baud_msg[] = { X+ "", B300, X+ " 1200", B1200, X+ " 2400", B2400, X+ " 9600", B9600, X+ " 9600/ARQ", B9600, X+ 0, 0, X+ }; X+ X+ static int multitech_connect () X+ { X+ char c; X+ int nc, nl, n; X+ char dialer_buf[64]; X+ struct baud_msg *bm; X+ sig_t f; X+ X+ if (multitech_swallow("\r\n") == 0) X+ return (0); X+ f = signal(SIGALRM, sigALRM); X+ again: X+ nc = 0; nl = sizeof(dialer_buf)-1; X+ bzero(dialer_buf, sizeof(dialer_buf)); X+ timeout = 0; X+ for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { X+ if (setjmp(timeoutbuf)) X+ break; X+ alarm(number(value(DIALTIMEOUT))); X+ n = read(FD, &c, 1); X+ alarm(0); X+ if (n <= 0) X+ break; X+ c &= 0x7f; X+ if (c == '\r') { X+ if (multitech_swallow("\n") == 0) X+ break; X+ if (!dialer_buf[0]) X+ goto again; X+ if (strcmp(dialer_buf, "RINGING") == 0 && X+ boolean(value(VERBOSE))) { X+ #ifdef DEBUG X+ printf("%s\r\n", dialer_buf); X+ #endif X+ goto again; X+ } X+ if (strncmp(dialer_buf, "CONNECT", X+ sizeof("CONNECT")-1) != 0) X+ break; X+ if (lock_baud) { X+ signal(SIGALRM, f); X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ printf("%s\r\n", dialer_buf); X+ #endif X+ return (1); X+ } X+ for (bm = baud_msg ; bm->msg ; bm++) X+ if (strcmp(bm->msg, dialer_buf+sizeof("CONNECT")-1) == 0) { X+ if (!acu_setspeed (bm->baud)) X+ goto error; X+ signal(SIGALRM, f); X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ printf("%s\r\n", dialer_buf); X+ #endif X+ return (1); X+ } X+ break; X+ } X+ dialer_buf[nc] = c; X+ } X+ error1: X+ printf("%s\r\n", dialer_buf); X+ error: X+ signal(SIGALRM, f); X+ return (0); X+ } X+ X+ /* X+ * This convoluted piece of code attempts to get X+ * the multitech in sync. X+ */ X+ static int multitechsync () X+ { X+ int already = 0; X+ int len; X+ char buf[40]; X+ X+ while (already++ < MAXRETRY) { X+ acu_nap (intercommand_delay); X+ ioctl (FD, TIOCFLUSH, 0); /* flush any clutter */ X+ multitech_write_str (FD, reset_command); /* reset modem */ X+ bzero(buf, sizeof(buf)); X+ acu_nap (reset_delay); X+ ioctl (FD, FIONREAD, &len); X+ if (len) { X+ len = read(FD, buf, sizeof(buf)); X+ #ifdef DEBUG X+ buf [len] = '\0'; X+ printf("multitechsync: (\"%s\")\n\r", buf); X+ #endif X+ if (index(buf, '0') || X+ (index(buf, 'O') && index(buf, 'K'))) X+ return(1); X+ } X+ /* X+ * If not strapped for DTR control, X+ * try to get command mode. X+ */ X+ acu_nap (escape_guard_time); X+ multitech_write_str (FD, escape_sequence); X+ acu_nap (escape_guard_time); X+ multitech_write_str (FD, hangup_command); X+ /* X+ * Toggle DTR to force anyone off that might have left X+ * the modem connected. X+ */ X+ acu_nap (escape_guard_time); X+ ioctl (FD, TIOCCDTR, 0); X+ acu_nap (escape_guard_time); X+ ioctl (FD, TIOCSDTR, 0); X+ } X+ acu_nap (intercommand_delay); X+ multitech_write_str (FD, reset_command); X+ return (0); X+ } X+ X+ void multitech_write_str (int fd, const char *cp) X+ { X+ #ifdef DEBUG X+ printf ("multitech: sending %s\n", cp); X+ #endif X+ multitech_write (fd, cp, strlen (cp)); X+ } X+ X+ void multitech_write (int fd, const char *cp, int n) X+ { X+ acu_flush (); X+ acu_nap (intercharacter_delay); X+ for ( ; n-- ; cp++) { X+ write (fd, cp, 1); X+ acu_flush (); X+ acu_nap (intercharacter_delay); X+ } X+ } X+ X+ #ifdef DEBUG X+ multitech_verbose_read() X+ { X+ int n = 0; X+ char buf[BUFSIZ]; X+ X+ if (ioctl(FD, FIONREAD, &n) < 0) X+ return; X+ if (n <= 0) X+ return; X+ if (read(FD, buf, n) != n) X+ return; X+ write(1, buf, n); X+ } X+ #endif X+ X+ /* end of multitech.c */ Xdiff -r -c ./libacu/t3000.c libacu/t3000.c X*** ./libacu/t3000.c Sun Mar 26 18:47:00 1995 X--- libacu/t3000.c Fri Mar 24 00:25:34 1995 X*************** X*** 39,45 **** X--- 39,47 ---- X * Routines for calling up on a Telebit T3000 modem. X * Derived from Courier driver. X */ X+ #include "tipconf.h" X #include "tip.h" X+ #include "acucommon.h" X #include <stdio.h> X X #define MAXRETRY 5 X*************** X*** 55,61 **** X char *acu; X { X register char *cp; X! #ifdef ACULOG X char line[80]; X #endif X static int t3000_connect(), t3000_swallow(); X--- 57,63 ---- X char *acu; X { X register char *cp; X! #if ACULOG X char line[80]; X #endif X static int t3000_connect(), t3000_swallow(); X*************** X*** 63,76 **** X if (boolean(value(VERBOSE))) X printf("Using \"%s\"\n", acu); X X! ioctl(FD, TIOCHPCL, 0); X /* X * Get in synch. X */ X if (!t3000_sync()) { X badsynch: X printf("can't synchronize with t3000\n"); X! #ifdef ACULOG X logent(value(HOST), num, "t3000", "can't synch up"); X #endif X return (0); X--- 65,78 ---- X if (boolean(value(VERBOSE))) X printf("Using \"%s\"\n", acu); X X! acu_hupcl (); X /* X * Get in synch. X */ X if (!t3000_sync()) { X badsynch: X printf("can't synchronize with t3000\n"); X! #if ACULOG X logent(value(HOST), num, "t3000", "can't synch up"); X #endif X return (0); X*************** X*** 93,99 **** X t3000_write(FD, num, strlen(num)); X t3000_write(FD, "\r", 1); X connected = t3000_connect(); X! #ifdef ACULOG X if (timeout) { X sprintf(line, "%d second dial timeout", X number(value(DIALTIMEOUT))); X--- 95,101 ---- X t3000_write(FD, num, strlen(num)); X t3000_write(FD, "\r", 1); X connected = t3000_connect(); X! #if ACULOG X if (timeout) { X sprintf(line, "%d second dial timeout", X number(value(DIALTIMEOUT))); X*************** X*** 195,201 **** X { X char c; X int nc, nl, n; X- struct sgttyb sb; X char dialer_buf[64]; X struct tbaud_msg *bm; X sig_t f; X--- 197,202 ---- X*************** X*** 234,258 **** X for (bm = tbaud_msg ; bm->msg ; bm++) X if (strcmp(bm->msg, X dialer_buf+sizeof("CONNECT")-1) == 0) { X! if (ioctl(FD, TIOCGETP, &sb) < 0) { X! perror("TIOCGETP"); X goto error; X- } X- sb.sg_ispeed = sb.sg_ospeed = bm->baud; X- if (ioctl(FD, TIOCSETP, &sb) < 0) { X- if (bm->baud2) { X- sb.sg_ispeed = X- sb.sg_ospeed = X- bm->baud2; X- if (ioctl(FD, X- TIOCSETP, X- &sb) >= 0) X- goto isok; X- } X- perror("TIOCSETP"); X- goto error; X- } X- isok: X signal(SIGALRM, f); X #ifdef DEBUG X if (boolean(value(VERBOSE))) X--- 235,242 ---- X for (bm = tbaud_msg ; bm->msg ; bm++) X if (strcmp(bm->msg, X dialer_buf+sizeof("CONNECT")-1) == 0) { X! if (!(acu_setspeed (bm->baud) || (bm->baud2 && acu_setspeed (bm->baud2)))) X goto error; X signal(SIGALRM, f); X #ifdef DEBUG X if (boolean(value(VERBOSE))) X*************** X*** 329,347 **** X char *cp; X int n; X { X- struct sgttyb sb; X- X #ifdef notdef X if (boolean(value(VERBOSE))) X write(1, cp, n); X #endif X! ioctl(fd, TIOCGETP, &sb); X! ioctl(fd, TIOCSETP, &sb); X t3000_nap(); X for ( ; n-- ; cp++) { X write(fd, cp, 1); X! ioctl(fd, TIOCGETP, &sb); X! ioctl(fd, TIOCSETP, &sb); X t3000_nap(); X } X } X--- 313,327 ---- X char *cp; X int n; X { X #ifdef notdef X if (boolean(value(VERBOSE))) X write(1, cp, n); X #endif X! acu_flush (); X t3000_nap(); X for ( ; n-- ; cp++) { X write(fd, cp, 1); X! acu_flush (); X t3000_nap(); X } X } X*************** X*** 362,408 **** X } X #endif X X- /* X- * Code stolen from /usr/src/lib/libc/gen/sleep.c X- */ X- #define mask(s) (1<<((s)-1)) X- #define setvec(vec, a) \ X- vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0 X- X- static napms = 50; /* Give the t3000 50 milliseconds between characters */ X- X- static int ringring; X- X t3000_nap() X { X! X! static void t3000_napx(); X! int omask; X! struct itimerval itv, oitv; X! register struct itimerval *itp = &itv; X! struct sigvec vec, ovec; X! X! timerclear(&itp->it_interval); X! timerclear(&itp->it_value); X! if (setitimer(ITIMER_REAL, itp, &oitv) < 0) X! return; X! setvec(ovec, SIG_DFL); X! omask = sigblock(mask(SIGALRM)); X! itp->it_value.tv_sec = napms/1000; X! itp->it_value.tv_usec = ((napms%1000)*1000); X! setvec(vec, t3000_napx); X! ringring = 0; X! (void) sigvec(SIGALRM, &vec, &ovec); X! (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0); X! while (!ringring) X! sigpause(omask &~ mask(SIGALRM)); X! (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0); X! (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0); X! (void) sigsetmask(omask); X } X X! static void X! t3000_napx() X! { X! ringring = 1; X! } X--- 342,350 ---- X } X #endif X X t3000_nap() X { X! acu_nap (50); X } X X! /* end of t3000.c */ Xdiff -r -c ./libacu/tod.c libacu/tod.c X*** ./libacu/tod.c Sun Mar 26 18:47:08 1995 X--- libacu/tod.c Sat Mar 25 18:06:00 1995 X*************** X*** 0 **** X--- 1,107 ---- X+ /* X+ * tod.c -- time of day pseudo-class implementation X+ * X+ * Copyright (c) 1995 John H. Poplett X+ * All rights reserved. X+ * X+ * Redistribution and use in source and binary forms, with or without X+ * modification, are permitted provided that the following conditions X+ * are met: X+ * 1. Redistributions of source code must retain the above copyright X+ * notice immediately at the beginning of the file, without modification, X+ * this list of conditions, and the following disclaimer. X+ * 2. Redistributions in binary form must reproduce the above copyright X+ * notice, this list of conditions and the following disclaimer in the X+ * documentation and/or other materials provided with the distribution. X+ * 3. Absolutely no warranty of function or purpose is made by the author X+ * John H. Poplett. X+ * 4. This work was done expressly for inclusion into FreeBSD. Other use X+ * is allowed if this notation is included. X+ * 5. Modifications may be freely made to this file if the above conditions X+ * are met. X+ * X+ */ X+ X+ #include <sys/types.h> X+ #include <sys/time.h> X+ X+ #include <assert.h> X+ #include <stdio.h> X+ X+ #include "tod.h" X+ X+ #define USP 1000000 X+ X+ int tod_cmp (const struct timeval *a, const struct timeval *b) X+ { X+ int rc; X+ assert (a->tv_usec <= USP); X+ assert (b->tv_usec <= USP); X+ rc = a->tv_sec - b->tv_sec; X+ if (rc == 0) X+ rc = a->tv_usec - b->tv_usec; X+ return rc; X+ } X+ X+ /* X+ TOD < command X+ */ X+ int tod_lt (const struct timeval *a, const struct timeval *b) X+ { X+ return tod_cmp (a, b) < 0; X+ } X+ X+ int tod_gt (const struct timeval *a, const struct timeval *b) X+ { X+ return tod_cmp (a, b) > 0; X+ } X+ X+ int tod_lte (const struct timeval *a, const struct timeval *b) X+ { X+ return tod_cmp (a, b) <= 0; X+ } X+ X+ int tod_gte (const struct timeval *a, const struct timeval *b) X+ { X+ return tod_cmp (a, b) >= 0; X+ } X+ X+ int tod_eq (const struct timeval *a, const struct timeval *b) X+ { X+ return tod_cmp (a, b) == 0; X+ } X+ X+ /* X+ TOD += command X+ */ X+ void tod_addto (struct timeval *a, const struct timeval *b) X+ { X+ a->tv_usec += b->tv_usec; X+ a->tv_sec += b->tv_sec + a->tv_usec / USP; X+ a->tv_usec %= USP; X+ } X+ X+ /* X+ TOD -= command X+ */ X+ void tod_subfrom (struct timeval *a, struct timeval b) X+ { X+ assert (a->tv_usec <= USP); X+ assert (b.tv_usec <= USP); X+ if (b.tv_usec > a->tv_usec) X+ { X+ a->tv_usec += USP; X+ a->tv_sec -= 1; X+ } X+ a->tv_usec -= b.tv_usec; X+ a->tv_sec -= b.tv_sec; X+ } X+ X+ void tod_gettime (struct timeval *tp) X+ { X+ gettimeofday (tp, NULL); X+ tp->tv_sec += tp->tv_usec / USP; X+ tp->tv_usec %= USP; X+ } X+ X+ /* end of tod.c */ Xdiff -r -c ./libacu/tod.h libacu/tod.h X*** ./libacu/tod.h Sun Mar 26 18:47:09 1995 X--- libacu/tod.h Tue Mar 14 23:13:42 1995 X*************** X*** 0 **** X--- 1,9 ---- X+ int tod_cmp (const struct timeval *a, const struct timeval *b); X+ int tod_lt (const struct timeval *a, const struct timeval *b) ; X+ int tod_gt (const struct timeval *a, const struct timeval *b); X+ int tod_lte (const struct timeval *a, const struct timeval *b); X+ int tod_gte (const struct timeval *a, const struct timeval *b); X+ int tod_eq (const struct timeval *a, const struct timeval *b); X+ void tod_addto (struct timeval *a, const struct timeval *b); X+ void tod_subfrom (struct timeval *a, struct timeval b); X+ void tod_gettime (struct timeval *tp); Xdiff -r -c ./libacu/unidialer.c libacu/unidialer.c X*** ./libacu/unidialer.c Sun Mar 26 18:47:09 1995 X--- libacu/unidialer.c Sun Mar 26 12:30:04 1995 X*************** X*** 0 **** X--- 1,800 ---- X+ /* X+ * Copyright (c) 1986, 1993 X+ * The Regents of the University of California. All rights reserved. X+ * X+ * Redistribution and use in source and binary forms, with or without X+ * modification, are permitted provided that the following conditions X+ * are met: X+ * 1. Redistributions of source code must retain the above copyright X+ * notice, this list of conditions and the following disclaimer. X+ * 2. Redistributions in binary form must reproduce the above copyright X+ * notice, this list of conditions and the following disclaimer in the X+ * documentation and/or other materials provided with the distribution. X+ * 3. All advertising materials mentioning features or use of this software X+ * must display the following acknowledgement: X+ * This product includes software developed by the University of X+ * California, Berkeley and its contributors. X+ * 4. Neither the name of the University nor the names of its contributors X+ * may be used to endorse or promote products derived from this software X+ * without specific prior written permission. X+ * X+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X+ * SUCH DAMAGE. X+ */ X+ X+ #ifndef lint X+ static char sccsid[] = "@(#)unidialer.c 8.1 (Berkeley) 6/6/93"; X+ #endif /* not lint */ X+ X+ /* X+ * Generalized routines for calling up on a Hayes AT command set based modem. X+ * Control variables are pulled out of a modem caps-style database to X+ * configure the driver for a particular modem. X+ */ X+ #include "tipconf.h" X+ #include "tip.h" X+ #include "pathnames.h" X+ X+ #include <sys/times.h> X+ #include <assert.h> X+ #include <stdio.h> X+ #include <stdlib.h> X+ X+ #include "acucommon.h" X+ #include "tod.h" X+ X+ /* #define DEBUG /**/ X+ #define MAXRETRY 5 X+ X+ typedef enum X+ { X+ mpt_notype, mpt_string, mpt_number, mpt_boolean X+ } modem_parm_type_t; X+ X+ typedef struct { X+ modem_parm_type_t modem_parm_type; X+ const char *name; X+ union { X+ char **string; X+ unsigned int *number; X+ } value; X+ union { X+ char *string; X+ unsigned int number; X+ } default_value; X+ } modem_parm_t; X+ X+ /* X+ Configuration X+ */ X+ static char modem_name [80]; X+ static char *dial_command; X+ static char *hangup_command; X+ static char *echo_off_command; X+ static char *reset_command; X+ static char *init_string; X+ static char *escape_sequence; X+ static int hw_flow_control; X+ static int lock_baud; X+ static unsigned int intercharacter_delay; X+ static unsigned int intercommand_delay; X+ static unsigned int escape_guard_time; X+ static unsigned int reset_delay; X+ X+ static int unidialer_dialer (register char *num, char *acu); X+ static void unidialer_disconnect (); X+ static void unidialer_abort (); X+ X+ static acu_t unidialer = X+ { X+ modem_name, X+ unidialer_dialer, X+ unidialer_disconnect, X+ unidialer_abort X+ }; X+ X+ /* X+ Table of parameters kept in modem database X+ */ X+ modem_parm_t modem_parms [] = { X+ { mpt_string, "dial_command", &dial_command, "ATDT%s\r" }, X+ { mpt_string, "hangup_command", &hangup_command, "ATH\r", }, X+ { mpt_string, "echo_off_command", &echo_off_command, "ATE0\r" }, X+ { mpt_string, "reset_command", &reset_command, "ATZ\r" }, X+ { mpt_string, "init_string", &init_string, "AT&F\r", }, X+ { mpt_string, "escape_sequence", &escape_sequence, "+++" }, X+ { mpt_boolean, "hw_flow_control", (char **)&hw_flow_control, NULL }, X+ { mpt_boolean, "lock_baud", (char **)&lock_baud, NULL }, X+ { mpt_number, "intercharacter_delay", (char **)&intercharacter_delay, (char *)50 }, X+ { mpt_number, "intercommand_delay", (char **)&intercommand_delay, (char *)300 }, X+ { mpt_number, "escape_guard_time", (char **)&escape_guard_time, (char *)300 }, X+ { mpt_number, "reset_delay", (char **)&reset_delay, (char *)3000 }, X+ { mpt_notype, NULL, NULL, NULL } X+ }; X+ X+ /* X+ Forward declarations X+ */ X+ static void unidialer_verbose_read (); X+ static void unidialer_modem_cmd (int fd, CONST char *cmd); X+ static void unidialer_write (int fd, CONST char *cp, int n); X+ static void unidialer_write_str (int fd, CONST char *cp); X+ static void unidialer_disconnect (); X+ static void sigALRM (); X+ static int unidialersync (); X+ static int unidialer_swallow (register char *match); X+ X+ /* X+ Global vars X+ */ X+ static int timeout = 0; X+ static int connected = 0; X+ static jmp_buf timeoutbuf, intbuf; X+ X+ #define cgetflag(f) (cgetcap(bp, f, ':') != NULL) X+ X+ #ifdef DEBUG X+ X+ #define print_str(x) printf (#x " = %s\n", x) X+ #define print_num(x) printf (#x " = %d\n", x) X+ X+ void dumpmodemparms (char *modem) X+ { X+ printf ("modem parms for %s\n", modem); X+ print_str (dial_command); X+ print_str (hangup_command); X+ print_str (echo_off_command); X+ print_str (reset_command); X+ print_str (init_string); X+ print_str (escape_sequence); X+ print_num (lock_baud); X+ print_num (intercharacter_delay); X+ print_num (intercommand_delay); X+ print_num (escape_guard_time); X+ print_num (reset_delay); X+ printf ("\n"); X+ } X+ #endif X+ X+ static int getmodemparms (const char *modem) X+ { X+ char *bp, *db_array [3], *modempath; X+ int ndx, stat; X+ modem_parm_t *mpp; X+ X+ modempath = getenv ("MODEMS"); X+ X+ ndx = 0; X+ X+ if (modempath != NULL) X+ db_array [ndx++] = modempath; X+ X+ db_array [ndx++] = _PATH_MODEMS; X+ db_array [ndx] = NULL; X+ X+ if ((stat = cgetent (&bp, db_array, (char *)modem)) < 0) { X+ switch (stat) { X+ case -1: X+ fprintf (stderr, "tip: unknown modem %s\n", modem); X+ break; X+ case -2: X+ fprintf (stderr, "tip: can't open modem description file\n"); X+ break; X+ case -3: X+ fprintf (stderr, "tip: possible reference loop in modem description file\n"); X+ break; X+ } X+ return 0; X+ } X+ for (mpp = modem_parms; mpp->name; mpp++) X+ { X+ switch (mpp->modem_parm_type) X+ { X+ case mpt_string: X+ if (cgetstr (bp, (char *)mpp->name, mpp->value.string) == -1) X+ *mpp->value.string = mpp->default_value.string; X+ break; X+ X+ case mpt_number: X+ { X+ long l; X+ if (cgetnum (bp, (char *)mpp->name, &l) == -1) X+ *mpp->value.number = mpp->default_value.number; X+ else X+ *mpp->value.number = (unsigned int)l; X+ } X+ break; X+ X+ case mpt_boolean: X+ *mpp->value.number = cgetflag ((char *)mpp->name); X+ break; X+ } X+ } X+ strncpy (modem_name, modem, sizeof (modem_name) - 1); X+ modem_name [sizeof (modem_name) - 1] = '\0'; X+ return 1; X+ } X+ X+ /* X+ */ X+ acu_t* unidialer_getmodem (const char *modem_name) X+ { X+ acu_t* rc = NOACU; X+ if (getmodemparms (modem_name)) X+ rc = &unidialer; X+ return rc; X+ } X+ X+ static int unidialer_modem_ready () X+ { X+ #ifdef TIOCMGET X+ int state; X+ ioctl (FD, TIOCMGET, &state); X+ return (state & TIOCM_DSR) ? 1 : 0; X+ #else X+ return (1); X+ #endif X+ } X+ X+ static int unidialer_waitfor_modem_ready (int ms) X+ { X+ #ifdef TIOCMGET X+ int count; X+ for (count = 0; count < ms; count += 100) X+ { X+ if (unidialer_modem_ready ()) X+ { X+ #ifdef DEBUG X+ printf ("unidialer_waitfor_modem_ready: modem ready.\n"); X+ #endif X+ break; X+ } X+ acu_nap (100); X+ } X+ return (count < ms); X+ #else X+ acu_nap (250); X+ return (1); X+ #endif X+ } X+ X+ int unidialer_tty_clocal (int flag) X+ { X+ #if HAVE_TERMIOS X+ struct termios t; X+ tcgetattr (FD, &t); X+ if (flag) X+ t.c_cflag |= CLOCAL; X+ else X+ t.c_cflag &= ~CLOCAL; X+ tcsetattr (FD, TCSANOW, &t); X+ #elif defined(TIOCMSET) X+ int state; X+ /* X+ Don't have CLOCAL so raise CD in software to X+ get the same effect. X+ */ X+ ioctl (FD, TIOCMGET, &state); X+ if (flag) X+ state |= TIOCM_CD; X+ else X+ state &= ~TIOCM_CD; X+ ioctl (FD, TIOCMSET, &state); X+ #endif X+ } X+ X+ int unidialer_get_modem_response (char *buf, int bufsz, int response_timeout) X+ { X+ sig_t f; X+ char c, *p = buf, *lid = buf + bufsz - 1; X+ int state; X+ X+ assert (bufsz > 0); X+ X+ f = signal (SIGALRM, sigALRM); X+ X+ timeout = 0; X+ X+ if (setjmp (timeoutbuf)) { X+ signal (SIGALRM, f); X+ *p = '\0'; X+ #ifdef DEBUG X+ printf ("get_response: timeout buf=%s, state=%d\n", buf, state); X+ #endif X+ return (0); X+ } X+ X+ ualarm (response_timeout * 1000, 0); X+ X+ state = 0; X+ X+ while (1) X+ { X+ switch (state) X+ { X+ case 0: X+ if (read (FD, &c, 1) == 1) X+ { X+ if (c == '\r') X+ { X+ ++state; X+ } X+ else X+ { X+ #ifdef DEBUG X+ printf ("get_response: unexpected char %s.\n", ctrl (c)); X+ #endif X+ } X+ } X+ break; X+ X+ case 1: X+ if (read (FD, &c, 1) == 1) X+ { X+ if (c == '\n') X+ { X+ #ifdef DEBUG X+ printf ("get_response: <CRLF> encountered.\n", buf); X+ #endif X+ ++state; X+ } X+ else X+ { X+ state = 0; X+ #ifdef DEBUG X+ printf ("get_response: unexpected char %s.\n", ctrl (c)); X+ #endif X+ } X+ } X+ break; X+ X+ case 2: X+ if (read (FD, &c, 1) == 1) X+ { X+ if (c == '\r') X+ ++state; X+ else if (c >= ' ' && p < lid) X+ *p++ = c; X+ } X+ break; X+ X+ case 3: X+ if (read (FD, &c, 1) == 1) X+ { X+ if (c == '\n') X+ { X+ signal (SIGALRM, f); X+ /* ualarm (0, 0); */ X+ alarm (0); X+ *p = '\0'; X+ #ifdef DEBUG X+ printf ("get_response: %s\n", buf); X+ #endif X+ return (1); X+ } X+ else X+ { X+ state = 0; X+ p = buf; X+ } X+ } X+ break; X+ } X+ } X+ } X+ X+ int unidialer_get_okay (int ms) X+ { X+ int okay; X+ char buf [BUFSIZ]; X+ okay = unidialer_get_modem_response (buf, sizeof (buf), ms) && X+ strcmp (buf, "OK") == 0; X+ return okay; X+ } X+ X+ static int unidialer_dialer (register char *num, char *acu) X+ { X+ register char *cp; X+ char dial_string [80]; X+ #if ACULOG X+ char line [80]; X+ #endif X+ static int unidialer_connect(), unidialer_swallow(); X+ X+ #ifdef DEBUG X+ dumpmodemparms (modem_name); X+ #endif X+ X+ if (lock_baud) { X+ int i; X+ if ((i = speed(number(value(BAUDRATE)))) == NULL) X+ return 0; X+ ttysetup (i); X+ } X+ X+ if (boolean(value(VERBOSE))) X+ printf("Using \"%s\"\n", acu); X+ X+ acu_hupcl (); X+ X+ /* X+ * Get in synch. X+ */ X+ if (!unidialersync()) { X+ badsynch: X+ printf("tip: can't synchronize with %s\n", modem_name); X+ #if ACULOG X+ logent(value(HOST), num, modem_name, "can't synch up"); X+ #endif X+ return (0); X+ } X+ X+ unidialer_modem_cmd (FD, echo_off_command); /* turn off echoing */ X+ X+ sleep(1); X+ X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ unidialer_verbose_read(); X+ #endif X+ X+ acu_flush (); /* flush any clutter */ X+ X+ unidialer_modem_cmd (FD, init_string); X+ X+ if (!unidialer_get_okay (250)) X+ goto badsynch; X+ X+ fflush (stdout); X+ X+ for (cp = num; *cp; cp++) X+ if (*cp == '=') X+ *cp = ','; X+ X+ (void) sprintf (dial_string, dial_command, num); X+ X+ unidialer_modem_cmd (FD, dial_string); X+ X+ connected = unidialer_connect (); X+ X+ if (connected && hw_flow_control) { X+ acu_hw_flow_control (hw_flow_control); X+ } X+ X+ #if ACULOG X+ if (timeout) { X+ sprintf(line, "%d second dial timeout", X+ number(value(DIALTIMEOUT))); X+ logent(value(HOST), num, modem_name, line); X+ } X+ #endif X+ X+ if (timeout) X+ unidialer_disconnect (); X+ X+ return (connected); X+ } X+ X+ static void unidialer_disconnect () X+ { X+ int okay, retries; X+ X+ acu_flush (); /* flush any clutter */ X+ X+ unidialer_tty_clocal (TRUE); X+ X+ /* first hang up the modem*/ X+ ioctl (FD, TIOCCDTR, 0); X+ acu_nap (250); X+ ioctl (FD, TIOCSDTR, 0); X+ X+ /* X+ * If AT&D2, then dropping DTR *should* just hangup the modem. But X+ * some modems reset anyway; also, the modem may be programmed to reset X+ * anyway with AT&D3. Play it safe and wait for the full reset time before X+ * proceeding. X+ */ X+ acu_nap (reset_delay); X+ X+ if (!unidialer_waitfor_modem_ready (reset_delay)) X+ { X+ #ifdef DEBUG X+ printf ("unidialer_disconnect: warning CTS low.\r\n"); X+ #endif X+ } X+ X+ /* X+ * If not strapped for DTR control, try to get command mode. X+ */ X+ for (retries = okay = 0; retries < MAXRETRY && !okay; retries++) X+ { X+ int timeout_value; X+ /* flush any clutter */ X+ if (!acu_flush ()) X+ { X+ #ifdef DEBUG X+ printf ("unidialer_disconnect: warning flush failed.\r\n"); X+ #endif X+ } X+ timeout_value = escape_guard_time; X+ timeout_value += (timeout_value * retries / MAXRETRY); X+ acu_nap (timeout_value); X+ acu_flush (); /* flush any clutter */ X+ unidialer_modem_cmd (FD, escape_sequence); X+ acu_nap (timeout_value); X+ unidialer_modem_cmd (FD, hangup_command); X+ okay = unidialer_get_okay (250); X+ } X+ if (!okay) X+ { X+ #if ACULOG X+ logent(value(HOST), "", modem_name, "can't hang up modem"); X+ #endif X+ if (boolean(value(VERBOSE))) X+ printf("hang up failed\n"); X+ } X+ (void) acu_flush (); X+ close (FD); X+ } X+ X+ static void unidialer_abort () X+ { X+ unidialer_write_str (FD, "\r"); /* send anything to abort the call */ X+ unidialer_disconnect (); X+ } X+ X+ static void sigALRM () X+ { X+ (void) printf("\07timeout waiting for reply\n"); X+ timeout = 1; X+ longjmp(timeoutbuf, 1); X+ } X+ X+ static int unidialer_swallow (register char *match) X+ { X+ sig_t f; X+ char c; X+ X+ f = signal(SIGALRM, sigALRM); X+ X+ timeout = 0; X+ X+ if (setjmp(timeoutbuf)) { X+ signal(SIGALRM, f); X+ return (0); X+ } X+ X+ alarm(number(value(DIALTIMEOUT))); X+ X+ do { X+ if (*match =='\0') { X+ signal(SIGALRM, f); X+ alarm (0); X+ return (1); X+ } X+ do { X+ read (FD, &c, 1); X+ } while (c == '\0'); X+ c &= 0177; X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ { X+ /* putchar(c); */ X+ printf (ctrl (c)); X+ } X+ #endif X+ } while (c == *match++); X+ signal(SIGALRM, SIG_DFL); X+ alarm(0); X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ fflush (stdout); X+ #endif X+ return (0); X+ } X+ X+ static struct baud_msg { X+ char *msg; X+ int baud; X+ } baud_msg[] = { X+ "", B300, X+ " 1200", B1200, X+ " 2400", B2400, X+ " 9600", B9600, X+ " 9600/ARQ", B9600, X+ 0, 0, X+ }; X+ X+ static int unidialer_connect () X+ { X+ char c; X+ int nc, nl, n; X+ char dialer_buf[64]; X+ struct baud_msg *bm; X+ sig_t f; X+ X+ if (unidialer_swallow("\r\n") == 0) X+ return (0); X+ f = signal(SIGALRM, sigALRM); X+ again: X+ nc = 0; nl = sizeof(dialer_buf)-1; X+ bzero(dialer_buf, sizeof(dialer_buf)); X+ timeout = 0; X+ for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { X+ if (setjmp(timeoutbuf)) X+ break; X+ alarm(number(value(DIALTIMEOUT))); X+ n = read(FD, &c, 1); X+ alarm(0); X+ if (n <= 0) X+ break; X+ c &= 0x7f; X+ if (c == '\r') { X+ if (unidialer_swallow("\n") == 0) X+ break; X+ if (!dialer_buf[0]) X+ goto again; X+ if (strcmp(dialer_buf, "RINGING") == 0 && X+ boolean(value(VERBOSE))) { X+ #ifdef DEBUG X+ printf("%s\r\n", dialer_buf); X+ #endif X+ goto again; X+ } X+ if (strncmp(dialer_buf, "CONNECT", X+ sizeof("CONNECT")-1) != 0) X+ break; X+ if (lock_baud) { X+ signal(SIGALRM, f); X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ printf("%s\r\n", dialer_buf); X+ #endif X+ return (1); X+ } X+ for (bm = baud_msg ; bm->msg ; bm++) X+ if (strcmp(bm->msg, dialer_buf+sizeof("CONNECT")-1) == 0) { X+ if (!acu_setspeed (bm->baud)) X+ goto error; X+ signal(SIGALRM, f); X+ #ifdef DEBUG X+ if (boolean(value(VERBOSE))) X+ printf("%s\r\n", dialer_buf); X+ #endif X+ return (1); X+ } X+ break; X+ } X+ dialer_buf[nc] = c; X+ } X+ error1: X+ printf("%s\r\n", dialer_buf); X+ error: X+ signal(SIGALRM, f); X+ return (0); X+ } X+ X+ /* X+ * This convoluted piece of code attempts to get X+ * the unidialer in sync. X+ */ X+ static int unidialersync () X+ { X+ int already = 0; X+ int len; X+ char buf[40]; X+ X+ while (already++ < MAXRETRY) { X+ acu_nap (intercommand_delay); X+ acu_flush (); /* flush any clutter */ X+ unidialer_write_str (FD, reset_command); /* reset modem */ X+ bzero(buf, sizeof(buf)); X+ acu_nap (reset_delay); X+ ioctl (FD, FIONREAD, &len); X+ if (len) { X+ len = read(FD, buf, sizeof(buf)); X+ #ifdef DEBUG X+ buf [len] = '\0'; X+ printf("unidialersync (%s): (\"%s\")\n\r", modem_name, buf); X+ #endif X+ if (index(buf, '0') || X+ (index(buf, 'O') && index(buf, 'K'))) X+ return(1); X+ } X+ /* X+ * If not strapped for DTR control, X+ * try to get command mode. X+ */ X+ acu_nap (escape_guard_time); X+ unidialer_write_str (FD, escape_sequence); X+ acu_nap (escape_guard_time); X+ unidialer_write_str (FD, hangup_command); X+ /* X+ * Toggle DTR to force anyone off that might have left X+ * the modem connected. X+ */ X+ acu_nap (escape_guard_time); X+ ioctl (FD, TIOCCDTR, 0); X+ acu_nap (1000); X+ ioctl (FD, TIOCSDTR, 0); X+ } X+ acu_nap (intercommand_delay); X+ unidialer_write_str (FD, reset_command); X+ return (0); X+ } X+ X+ /* X+ Send commands to modem; impose delay between commands. X+ */ X+ static void unidialer_modem_cmd (int fd, const char *cmd) X+ { X+ static struct timeval oldt = { 0, 0 }; X+ struct timeval newt; X+ tod_gettime (&newt); X+ if (tod_lt (&newt, &oldt)) X+ { X+ unsigned int naptime; X+ tod_subfrom (&oldt, newt); X+ naptime = oldt.tv_sec * 1000 + oldt.tv_usec / 1000; X+ if (naptime > intercommand_delay) X+ { X+ #ifdef DEBUG X+ printf ("unidialer_modem_cmd: suspicious naptime (%u ms)\r\n", naptime); X+ #endif X+ naptime = intercommand_delay; X+ } X+ #ifdef DEBUG X+ printf ("unidialer_modem_cmd: delaying %u ms\r\n", naptime); X+ #endif X+ acu_nap (naptime); X+ } X+ unidialer_write_str (fd, cmd); X+ tod_gettime (&oldt); X+ newt.tv_sec = 0; X+ newt.tv_usec = intercommand_delay; X+ tod_addto (&oldt, &newt); X+ } X+ X+ static void unidialer_write_str (int fd, const char *cp) X+ { X+ #ifdef DEBUG X+ printf ("unidialer (%s): sending %s\n", modem_name, cp); X+ #endif X+ unidialer_write (fd, cp, strlen (cp)); X+ } X+ X+ static void unidialer_write (int fd, const char *cp, int n) X+ { X+ acu_nap (intercharacter_delay); X+ for ( ; n-- ; cp++) { X+ write (fd, cp, 1); X+ acu_nap (intercharacter_delay); X+ } X+ } X+ X+ #ifdef DEBUG X+ static void unidialer_verbose_read() X+ { X+ int n = 0; X+ char buf[BUFSIZ]; X+ X+ if (ioctl(FD, FIONREAD, &n) < 0) X+ return; X+ if (n <= 0) X+ return; X+ if (read(FD, buf, n) != n) X+ return; X+ write(1, buf, n); X+ } X+ #endif X+ X+ /* end of unidialer.c */ Xdiff -r -c ./libacu/v3451.c libacu/v3451.c X*** ./libacu/v3451.c Sun Mar 26 18:47:00 1995 X--- libacu/v3451.c Fri Mar 24 00:26:34 1995 X*************** X*** 38,43 **** X--- 38,44 ---- X /* X * Routines for calling up on a Vadic 3451 Modem X */ X+ #include "tipconf.h" X #include "tip.h" X X static jmp_buf Sjbuf; X*************** X*** 50,56 **** X int ok; X int slow = number(value(BAUDRATE)) < 1200, rw = 2; X char phone[50]; X! #ifdef ACULOG X char line[80]; X #endif X static int expect(); X--- 51,57 ---- X int ok; X int slow = number(value(BAUDRATE)) < 1200, rw = 2; X char phone[50]; X! #if ACULOG X char line[80]; X #endif X static int expect(); X*************** X*** 65,81 **** X vawrite("\005\r", 2 + slow); X if (!expect("READY")) { X printf("can't synchronize with vadic 3451\n"); X! #ifdef ACULOG X logent(value(HOST), num, "vadic", "can't synch up"); X #endif X return (0); X } X! ioctl(FD, TIOCHPCL, 0); X sleep(1); X vawrite("D\r", 2 + slow); X if (!expect("NUMBER?")) { X printf("Vadic will not accept dial command\n"); X! #ifdef ACULOG X logent(value(HOST), num, "vadic", "will not accept dial"); X #endif X return (0); X--- 66,82 ---- X vawrite("\005\r", 2 + slow); X if (!expect("READY")) { X printf("can't synchronize with vadic 3451\n"); X! #if ACULOG X logent(value(HOST), num, "vadic", "can't synch up"); X #endif X return (0); X } X! acu_hupcl (); X sleep(1); X vawrite("D\r", 2 + slow); X if (!expect("NUMBER?")) { X printf("Vadic will not accept dial command\n"); X! #if ACULOG X logent(value(HOST), num, "vadic", "will not accept dial"); X #endif X return (0); X*************** X*** 85,91 **** X vawrite(phone, 1 + slow); X if (!expect(phone)) { X printf("Vadic will not accept phone number\n"); X! #ifdef ACULOG X logent(value(HOST), num, "vadic", "will not accept number"); X #endif X return (0); X--- 86,92 ---- X vawrite(phone, 1 + slow); X if (!expect(phone)) { X printf("Vadic will not accept phone number\n"); X! #if ACULOG X logent(value(HOST), num, "vadic", "will not accept number"); X #endif X return (0); X*************** X*** 100,106 **** X vawrite("\r", 1 + slow); X if (!expect("DIALING:")) { X printf("Vadic failed to dial\n"); X! #ifdef ACULOG X logent(value(HOST), num, "vadic", "failed to dial"); X #endif X return (0); X--- 101,107 ---- X vawrite("\r", 1 + slow); X if (!expect("DIALING:")) { X printf("Vadic failed to dial\n"); X! #if ACULOG X logent(value(HOST), num, "vadic", "failed to dial"); X #endif X return (0); X*************** X*** 111,117 **** X signal(SIGINT, func); X if (!ok) { X printf("call failed\n"); X! #ifdef ACULOG X logent(value(HOST), num, "vadic", "call failed"); X #endif X return (0); X--- 112,118 ---- X signal(SIGINT, func); X if (!ok) { X printf("call failed\n"); X! #if ACULOG X logent(value(HOST), num, "vadic", "call failed"); X #endif X return (0); Xdiff -r -c ./libacu/v831.c libacu/v831.c X*** ./libacu/v831.c Sun Mar 26 18:47:00 1995 X--- libacu/v831.c Thu Mar 16 08:02:03 1995 X*************** X*** 38,43 **** X--- 38,44 ---- X /* X * Routines for dialing up on Vadic 831 X */ X+ #include "tipconf.h" X #include "tip.h" X X int v831_abort(); X*************** X*** 127,144 **** X */ X v831_disconnect() X { X- struct sgttyb cntrl; X- X sleep(2); X #ifdef DEBUG X printf("[disconnect: FD=%d]\n", FD); X #endif X if (FD > 0) { X ioctl(FD, TIOCCDTR, 0); X! ioctl(FD, TIOCGETP, &cntrl); X! cntrl.sg_ispeed = cntrl.sg_ospeed = 0; X! ioctl(FD, TIOCSETP, &cntrl); X! ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); X } X close(FD); X } X--- 128,141 ---- X */ X v831_disconnect() X { X sleep(2); X #ifdef DEBUG X printf("[disconnect: FD=%d]\n", FD); X #endif X if (FD > 0) { X ioctl(FD, TIOCCDTR, 0); X! acu_setspeec (0); X! ioctl(FD, TIOCNXCL, 0); X } X close(FD); X } X*************** X*** 153,159 **** X if (child > 0) X kill(child, SIGKILL); X if (AC > 0) X! ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL); X close(AC); X if (FD > 0) X ioctl(FD, TIOCCDTR, 0); X--- 150,156 ---- X if (child > 0) X kill(child, SIGKILL); X if (AC > 0) X! ioctl(FD, TIOCNXCL, 0); X close(AC); X if (FD > 0) X ioctl(FD, TIOCCDTR, 0); X*************** X*** 185,191 **** X char *acu; X { X register struct vaconfig *vp; X- struct sgttyb cntrl; X char c; X int i, two = 2; X static char *sanitize(); X--- 182,187 ---- X*************** X*** 203,212 **** X--- 199,225 ---- X printf("Unable to locate dialer (%s)\n", acu); X return ('K'); X } X+ { X+ #if HAVE_TERMIOS X+ struct termios termios; X+ tcgetattr (AC, &termios); X+ termios.c_iflag = 0; X+ #ifndef _POSIX_SOURCE X+ termios.c_lflag = (PENDIN|ECHOKE|ECHOE); X+ #else X+ termios.c_lflag = (PENDIN|ECHOE); X+ #endif X+ termios.c_cflag = (CLOCAL|HUPCL|CREAD|CS8); X+ termios.c_ispeed = termios.c_ospeed = B2400; X+ tcsetattr (AC, TCSANOW, &termios); X+ #else /* HAVE_TERMIOS */ X+ struct sgttyb cntrl; X ioctl(AC, TIOCGETP, &cntrl); X cntrl.sg_ispeed = cntrl.sg_ospeed = B2400; X cntrl.sg_flags = RAW | EVENP | ODDP; X ioctl(AC, TIOCSETP, &cntrl); X+ #endif X+ } X ioctl(AC, TIOCFLUSH, &two); X pc(STX); X pc(vp->vc_rack); Xdiff -r -c ./libacu/ventel.c libacu/ventel.c X*** ./libacu/ventel.c Sun Mar 26 18:47:00 1995 X--- libacu/ventel.c Fri Mar 24 00:26:49 1995 X*************** X*** 39,44 **** X--- 39,45 ---- X * Routines for calling up on a Ventel Modem X * The Ventel is expected to be strapped for local echo (just like uucp) X */ X+ #include "tipconf.h" X #include "tip.h" X X #define MAXRETRY 5 X*************** X*** 72,78 **** X */ X if (!vensync(FD)) { X printf("can't synchronize with ventel\n"); X! #ifdef ACULOG X logent(value(HOST), num, "ventel", "can't synch up"); X #endif X return (0); X--- 73,79 ---- X */ X if (!vensync(FD)) { X printf("can't synchronize with ventel\n"); X! #if ACULOG X logent(value(HOST), num, "ventel", "can't synch up"); X #endif X return (0); X*************** X*** 80,86 **** X if (boolean(value(VERBOSE))) X printf("\ndialing..."); X fflush(stdout); X! ioctl(FD, TIOCHPCL, 0); X echo("#k$\r$\n$D$I$A$L$:$ "); X for (cp = num; *cp; cp++) { X delay(1, 10); X--- 81,87 ---- X if (boolean(value(VERBOSE))) X printf("\ndialing..."); X fflush(stdout); X! acu_hupcl (); X echo("#k$\r$\n$D$I$A$L$:$ "); X for (cp = num; *cp; cp++) { X delay(1, 10); X*************** X*** 91,98 **** X gobble('\n', line); X if (gobble('\n', line)) X connected = gobble('!', line); X! ioctl(FD, TIOCFLUSH); X! #ifdef ACULOG X if (timeout) { X sprintf(line, "%d second dial timeout", X number(value(DIALTIMEOUT))); X--- 92,99 ---- X gobble('\n', line); X if (gobble('\n', line)) X connected = gobble('!', line); X! acu_flush (); X! #if ACULOG X if (timeout) { X sprintf(line, "%d second dial timeout", X number(value(DIALTIMEOUT))); XOnly in .: patches Xdiff -r -c ./tip/Makefile tip/Makefile X*** ./tip/Makefile Sun Mar 26 18:47:03 1995 X--- tip/Makefile Sat Mar 25 21:03:39 1995 X*************** X*** 6,50 **** X # mode 6?? X # /var/log/aculog ACU accounting file, owned by ${OWNER} and X # mode 6?? {if ACULOG defined} X- # Presently supports: X- # BIZCOMP X- # DEC DF02-AC, DF03-AC X- # DEC DN-11/Able Quadracall X- # HAYES and Hayes emulators X- # USR COURIER (2400 baud) X- # VENTEL 212+ X- # VADIC 831 RS232 adaptor X- # VADIC 3451 X- # TELEBIT T3000 X- # X- # Configuration defines: X- # DF02, DF03, DN11 ACU's supported X- # BIZ1031, BIZ1022, VENTEL, V831, V3451, HAYES, COURIER, T3000 X- # ACULOG turn on tip logging of ACU use X- # PRISTINE no phone #'s put in ACU log file X- # CONNECT worthless command X- # DEFBR default baud rate to make connection at X- # DEFFS default frame size for FTP buffering of X- # writes on local side X- # BUFSIZ buffer sizing from stdio, must be fed X- # explicitly to remcap.c if not 1024 X- # CONNECT enable ~C command (connect pgm to remote) X X! PROG= tip X! CFLAGS+=-I${.CURDIR} \ X! -DDEFBR=1200 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE -DCONNECT \ X! -DV831 -DVENTEL -DHAYES -DCOURIER -DT3000 X! .PATH: ${.CURDIR}/aculib X! BINOWN= uucp X! BINGRP= dialer X BINMODE=4510 X! SRCS= acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \ X! remote.c tip.c tipout.c uucplock.c value.c vars.c \ X! biz22.c courier.c df.c dn11.c hayes.c t3000.c v3451.c v831.c ventel.c X! X! # -- acutab is configuration dependent, and so depends on the Makefile X! # -- remote.o depends on the Makefile because of DEFBR and DEFFS X! # -- log.o depends on the Makefile because of ACULOG X! acutab.o log.o remote.o: Makefile X! X .include <bsd.prog.mk> X--- 6,24 ---- X # mode 6?? X # /var/log/aculog ACU accounting file, owned by ${OWNER} and X # mode 6?? {if ACULOG defined} X X! CFLAGS+=-g X! LIBACU=../libacu/libacu.a X! BINDIR=/usr/bin X! BINOWN=uucp X! BINGRP=dialer X BINMODE=4510 X! LDADD+=$(LIBACU) X! LINKS=${BINDIR}/tip X! MAN1=tip.1 X! MAN5=modems.5 X! SRCS=acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \ X! remote.c tip.c tipout.c uucplock.c value.c vars.c X! PROG=tip X! $(OBJS): tipconf.h X .include <bsd.prog.mk> Xdiff -r -c ./tip/acu.c tip/acu.c X*** ./tip/acu.c Sun Mar 26 18:47:02 1995 X--- tip/acu.c Thu Mar 23 07:44:51 1995 X*************** X*** 35,42 **** X--- 35,47 ---- X static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93"; X #endif /* not lint */ X X+ #include "tipconf.h" X #include "tip.h" X X+ #if UNIDIALER X+ acu_t* unidialer_getmodem (const char *modem_name); X+ #endif X+ X static acu_t *acu = NOACU; X static int conflag; X static void acuabort(); X*************** X*** 192,196 **** X--- 197,206 ---- X for (p = acutable; p->acu_name != '\0'; p++) X if (!strcmp(s, p->acu_name)) X return (p); X+ X+ #if UNIDIALER X+ return unidialer_getmodem (s); X+ #else X return (NOACU); X+ #endif X } Xdiff -r -c ./tip/acutab.c tip/acutab.c X*** ./tip/acutab.c Sun Mar 26 18:47:02 1995 X--- tip/acutab.c Sat Mar 25 16:13:37 1995 X*************** X*** 35,54 **** X static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93"; X #endif /* not lint */ X X #include "tip.h" X X! extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(), X! biz31f_dialer(), biz31_disconnect(), biz31_abort(), X biz31w_dialer(), X! biz22f_dialer(), biz22_disconnect(), biz22_abort(), X biz22w_dialer(), X! ven_dialer(), ven_disconnect(), ven_abort(), X! hay_dialer(), hay_disconnect(), hay_abort(), X! cour_dialer(), cour_disconnect(), cour_abort(), X! t3000_dialer(), t3000_disconnect(), t3000_abort(), X! v3451_dialer(), v3451_disconnect(), v3451_abort(), X! v831_dialer(), v831_disconnect(), v831_abort(), X! dn_dialer(), dn_disconnect(), dn_abort(); X X acu_t acutable[] = { X #if BIZ1031 X--- 35,68 ---- X static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93"; X #endif /* not lint */ X X+ #include "tipconf.h" X #include "tip.h" X X! extern int df02_dialer(), df03_dialer(), X! biz31f_dialer(), X biz31w_dialer(), X! biz22f_dialer(), X biz22w_dialer(), X! ven_dialer(), X! hay_dialer(), X! cour_dialer(), X! multitech_dialer(), X! t3000_dialer(), X! v3451_dialer(), X! v831_dialer(), X! dn_dialer(); X! X! extern void df_disconnect(), df_abort(), X! biz31_disconnect(), biz31_abort(), X! biz22_disconnect(), biz22_abort(), X! ven_disconnect(), ven_abort(), X! hay_disconnect(), hay_abort(), X! cour_disconnect(), cour_abort(), X! multitech_disconnect(), multitech_abort(), X! t3000_disconnect(), t3000_abort(), X! v3451_disconnect(), v3451_abort(), X! v831_disconnect(), v831_abort(), X! dn_disconnect(), dn_abort(); X X acu_t acutable[] = { X #if BIZ1031 X*************** X*** 68,93 **** X #if DN11 X "dn11", dn_dialer, dn_disconnect, dn_abort, X #endif X! #ifdef VENTEL X "ventel",ven_dialer, ven_disconnect, ven_abort, X #endif X! #ifdef HAYES X "hayes",hay_dialer, hay_disconnect, hay_abort, X #endif X! #ifdef COURIER X "courier",cour_dialer, cour_disconnect, cour_abort, X #endif X! #ifdef T3000 X "t3000",t3000_dialer, t3000_disconnect, t3000_abort, X #endif X! #ifdef V3451 X! #ifndef V831 X "vadic",v3451_dialer, v3451_disconnect, v3451_abort, X #endif X "v3451",v3451_dialer, v3451_disconnect, v3451_abort, X #endif X! #ifdef V831 X! #ifndef V3451 X "vadic",v831_dialer, v831_disconnect, v831_abort, X #endif X "v831",v831_dialer, v831_disconnect, v831_abort, X--- 82,110 ---- X #if DN11 X "dn11", dn_dialer, dn_disconnect, dn_abort, X #endif X! #if VENTEL X "ventel",ven_dialer, ven_disconnect, ven_abort, X #endif X! #if HAYES X "hayes",hay_dialer, hay_disconnect, hay_abort, X #endif X! #if COURIER X "courier",cour_dialer, cour_disconnect, cour_abort, X #endif X! #if MULTITECH X! "multitech",multitech_dialer, multitech_disconnect, multitech_abort, X! #endif X! #if T3000 X "t3000",t3000_dialer, t3000_disconnect, t3000_abort, X #endif X! #if V3451 X! #if !V831 X "vadic",v3451_dialer, v3451_disconnect, v3451_abort, X #endif X "v3451",v3451_dialer, v3451_disconnect, v3451_abort, X #endif X! #if V831 X! #if !V3451 X "vadic",v831_dialer, v831_disconnect, v831_abort, X #endif X "v831",v831_dialer, v831_disconnect, v831_abort, END_OF_FILE if test 51555 -ne `wc -c <'patches.tip.2'`; then echo shar: \"'patches.tip.2'\" unpacked with wrong size! fi # end of 'patches.tip.2' fi echo shar: End of archive 3 \(of 3\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503270839.AAA12832>