Date: Mon, 27 Mar 1995 00:33:28 -0800 From: Tom Gray - DCA <dcasba@rain.org> Message-ID: <199503270833.AAA12435@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 2 (of 3)."
# Contents: patches.tip.1
# 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.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'patches.tip.1'\"
else
echo shar: Extracting \"'patches.tip.1'\" \(48717 characters\)
sed "s/^X//" >'patches.tip.1' <<'END_OF_FILE'
Xdiff -r -c ./Makefile Makefile
X*** ./Makefile Sun Mar 26 18:47:10 1995
X--- Makefile Sun Feb 26 22:48:24 1995
X***************
X*** 0 ****
X--- 1,2 ----
X+ SUBDIR=libacu tip
X+ .include <bsd.subdir.mk>
Xdiff -r -c ./NEWS NEWS
X*** ./NEWS Sun Mar 26 18:47:10 1995
X--- NEWS Sun Mar 26 18:08:55 1995
X***************
X*** 0 ****
X--- 1,65 ----
X+ Sat Mar 25 16:06:31 PST 1995
X+
X+ hw_flow_control (boolean) capability added to modem configuration
X+ data base (/etc/modems).
X+
X+ Configurable unidialer driver compiled in by default. Builtin
X+ ACU drivers no longer compiled in by default.
X+
X+ All configuration details isolated in tipconf.h (with exception of
X+ pathnames.h).
X+
X+ Made corrections to and updated manual page for tip.
X+
X+ Conditional compilation of cu interface for systems that provide
X+ a separate cu implementation (e.g. FreeBSD).
X+
X+ Sat Mar 25 00:35:08 PST 1995
X+
X+ Corrected entry in man file to identify the lockfile dir as /var/spool/locks
X+ instead of /var/spool/uucp.
X+
X+ xfer and transfer in cmds.c use standard C runtime buffered output.
X+ Eliminates a bug: buffer overruns when FRAMESIZE > BUFSIZ.
X+
X+ Added xfer routine for doing cu style take commands.
X+
X+ Thu Mar 16 08:17:57 PST 1995
X+
X+ Added support for termios.
X+
X+ Renamed acunap.* to acucommon.*. Moved common acu routines
X+ to it. Modified acu drivers to use common routines.
X+
X+ Sat Mar 11 20:17:58 PST 1995
X+
X+ Default nap function uses select call in preference to
X+ usleep or old, handrolled code.
X+
X+ tip makefile does not create a link to cu by default.
X+
X+ Wed Mar 8 00:11:04 PST 1995
X+
X+ Reduced sleep time in finish () in cmds.c from 5 seconds to two.
X+
X+ Sat Mar 4 19:00:34 PST 1995
X+
X+ Added table-driven modem driver (unidialer) that fetches modem
X+ characteristics from a modem database ("/etc/modems").
X+
X+ Removed common "nap" code from individual ACU drivers into a
X+ separate module.
X+
X+ Added login script capability to remote database.
X+
X+ Sun Feb 26 23:07:56 PST 1995
X+
X+ Use HoneyDanber style locks by default (ASCII PIDs written to lock files).
X+
X+ Changed default uucp file lock directory to "/var/spool/locks"
X+ to be consistent with default build of Taylor uucp.
X+
X+ Reorganized build environment for tip into a master directory
X+ and two subdirectories. The master Makefile builds a library
X+ of ACU "drivers" in the directory libacu. Tip only links in
X+ drivers that it will actually use.
Xdiff -r -c ./TODO TODO
X*** ./TODO Sun Mar 26 18:47:02 1995
X--- TODO Sun Mar 26 18:07:45 1995
X***************
X*** 1,3 ****
X--- 1,23 ----
X+ x Fix "hangup failed" in unidialer
X+ x Genericize tty code and/or support termios
X+ x Fixup uucplock conventions for FreeBSD (including reference in tip man pages).
X+ Sanity check for ttys
X+ x Rename pathnames.h
X+ x Qualify on USR
X+ Use select call to merge tipin / tipout
X+
X+ x Finish table-driven modem driver
X+ x Move HAVE_USLEEP to pathhnames.h
X+ x Add variable for login and logout scripts (connect with Perl???)
X+ x redials / redial delay (see dial shell script)
X+
X+ Add debug log capabilities for table-driven modem driver (command mode modem I/Owith timestamps).
X+
X+ Use select in modem drivers.
X+ Consolidate consh()-derived code in cmds.c
X+ Screen-oriented command menu?
X+ Add external file-transfer protocol implementations to command menu (rz, sz, others?)
X+
X 1. Rethink protection glitches on REMOTE & PHONES
X files (setuid/setgid??).
X
Xdiff -r -c ./libacu/Makefile libacu/Makefile
X*** ./libacu/Makefile Sun Mar 26 18:47:08 1995
X--- libacu/Makefile Sat Mar 25 00:45:28 1995
X***************
X*** 0 ****
X--- 1,5 ----
X+ CFLAGS+= -g -I../tip
X+ SRCS=acucommon.c biz22.c courier.c df.c dn11.c hayes.c multitech.c t3000.c tod.c unidialer.c v3451.c v831.c ventel.c
X+ LIB=acu
X+ $(OBJS): ../tip/tipconf.h
X+ .include <bsd.lib.mk>
Xdiff -r -c ./libacu/RCS/unidialer.c,v libacu/RCS/unidialer.c,v
X*** ./libacu/RCS/unidialer.c,v Sun Mar 26 18:47:09 1995
X--- libacu/RCS/unidialer.c,v Sun Mar 26 11:42:27 1995
X***************
X*** 0 ****
X--- 1,1181 ----
X+ head 1.3;
X+ access;
X+ symbols;
X+ locks
X+ john:1.3; strict;
X+ comment @ * @;
X+
X+
X+ 1.3
X+ date 95.03.26.19.42.16; author john; state Exp;
X+ branches;
X+ next 1.2;
X+
X+ 1.2
X+ date 95.03.18.20.03.12; author john; state Exp;
X+ branches;
X+ next 1.1;
X+
X+ 1.1
X+ date 95.03.06.05.45.45; author john; state Exp;
X+ branches;
X+ next ;
X+
X+
X+ desc
X+ @A generalized driver for Hayes AT command type modems. Uses
X+ a modem database to configure itself for a particular modem.
X+ @
X+
X+
X+ 1.3
X+ log
X+ @Removed dead code.
X+ @
X+ text
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 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" },
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, "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 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 (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+ {
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, "%s%s\r", dial_command, num);
X+
X+ unidialer_modem_cmd (FD, dial_string);
X+
X+ connected = unidialer_connect ();
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 */
X+ @
X+
X+
X+ 1.2
X+ log
X+ @Renamed reference to pathnames.h to tipconf.h. Added unidialer_modem_ready (),
X+ unidialer_clocal () and unidialer_get_modem_response () functions. Removed
X+ time-of-day related code to separate module. Added support for termios
X+ tty interface. Hangup code tries to relieve the driver from modem control
X+ so read still works even if carrier drops away.
X+ @
X+ text
X+ @d45 1
X+ d55 1
X+ a55 1
X+ #define DEBUG /**/
X+ d235 1
X+ a235 1
X+ static int unidialer_modem_ready (int ms)
X+ d238 12
X+ a249 1
X+ int count, state;
X+ d252 1
X+ a252 2
X+ ioctl (FD, TIOCMGET, &state);
X+ if (state & TIOCM_DSR)
X+ d255 1
X+ a255 1
X+ printf ("unidialer_modem_ready: modem ready.\n");
X+ d314 1
X+ a314 2
X+ /* ualarm (timeout * 1000, 0); */
X+ alarm (10);
X+ d393 9
X+ d406 1
X+ a406 1
X+ #ifdef ACULOG
X+ d434 1
X+ a434 1
X+ #ifdef ACULOG
X+ d453 1
X+ a453 1
X+ if (!unidialer_swallow ("\r\nOK\r\n"))
X+ d468 1
X+ a468 1
X+ #ifdef ACULOG
X+ a481 42
X+ #if 0
X+ static void unidialer_disconnect ()
X+ {
X+ int okay, retries;
X+
X+ /* first hang up the modem*/
X+ ioctl (FD, TIOCCDTR, 0);
X+ acu_nap (1000);
X+ ioctl (FD, TIOCSDTR, 0);
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+ /*
X+ * If not strapped for DTR control, try to get command mode.
X+ */
X+ for (retries = okay = 0; retries < 3 && !okay; retries++)
X+ {
X+ acu_nap (escape_guard_time + retries * escape_guard_time / 2);
X+ unidialer_modem_cmd (FD, escape_sequence);
X+ acu_nap (escape_guard_time + retries * escape_guard_time / 2);
X+ acu_flush (); /* flush any clutter */
X+ unidialer_modem_cmd (FD, hangup_command);
X+ acu_nap (intercharacter_delay + retries * intercharacter_delay / 2);
X+ okay = unidialer_swallow ("\r\nOK\r\n");
X+ }
X+ if (!okay)
X+ {
X+ #ifdef 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+ acu_flush (); /* flush any clutter */
X+ close (FD);
X+ }
X+
X+ a494 7
X+ if (!unidialer_modem_ready (reset_delay))
X+ {
X+ #ifdef DEBUG
X+ printf ("unidialer_disconnect: warning CTS low.\r\n");
X+ #endif
X+ }
X+
X+ d501 1
X+ a501 1
X+ acu_nap (1000);
X+ d503 1
X+ a503 68
X+ /*
X+ * If not strapped for DTR control, try to get command mode.
X+ */
X+ for (retries = okay = 0; retries < 3 && !okay; retries++)
X+ {
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+ acu_nap (1000);
X+ unidialer_write_str (FD, escape_sequence);
X+ acu_nap (1000);
X+ unidialer_write_str (FD, hangup_command);
X+ #if 0
X+ acu_nap (1000);
X+
X+ /* okay = unidialer_swallow ("\r\nOK\r\n"); */
X+ {
X+ char *p;
X+ int n = 0;
X+ char buf [BUFSIZ];
X+ if (ioctl (FD, FIONREAD, &n) == 0 && n > 0 && read (FD, buf, n) == n)
X+ {
X+ #ifdef DEBUG
X+ write (1, buf, n);
X+ #endif
X+ if (index (buf, '0') || ((p = index (buf, 'O')) != NULL && *(p+1) == 'K'))
X+ okay = 1;
X+ }
X+ }
X+ #else
X+ {
X+ char buf [BUFSIZ];
X+ okay = unidialer_get_modem_response (buf, sizeof (buf), 250) &&
X+ strcmp (buf, "OK") == 0;
X+ }
X+ #endif
X+ }
X+ if (!okay)
X+ {
X+ #ifdef 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+ #endif
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+ if (!unidialer_modem_ready (reset_delay))
X+ a510 8
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 (1000);
X+
X+ /*
X+ d513 1
X+ a513 1
X+ for (retries = okay = 0; retries < 3 && !okay; retries++)
X+ d515 1
X+ d523 3
X+ a525 1
X+ acu_nap (escape_guard_time);
X+ d528 1
X+ a528 1
X+ acu_nap (escape_guard_time);
X+ d530 1
X+ a530 5
X+ {
X+ char buf [BUFSIZ];
X+ okay = unidialer_get_modem_response (buf, sizeof (buf), 250) &&
X+ strcmp (buf, "OK") == 0;
X+ }
X+ d534 1
X+ a534 1
X+ #ifdef ACULOG
X+ a556 37
X+ #if 0
X+ static int unidialer_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+ {
X+ /* putchar(c); */
X+ printf (ctrl (c));
X+ }
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+ #else
X+ d571 1
X+ a571 2
X+ /* alarm(number(value(DIALTIMEOUT))); */
X+ alarm(180); /*FIXME*/
X+ a598 1
X+ #endif
X+ @
X+
X+
X+ 1.1
X+ log
X+ @Initial revision
X+ @
X+ text
X+ @d43 1
X+ a44 2
X+ #include "pathnames.h"
X+ #include "acunap.h"
X+ d46 2
X+ d51 4
X+ a54 2
X+ #define CONST const
X+ /* #define DEBUG /**/
X+ d124 2
X+ a141 1
X+
X+ d234 149
X+ d386 1
X+ d407 1
X+ a407 1
X+ ioctl (FD, TIOCHPCL, 0);
X+ a419 1
X+ acu_nap (intercommand_delay);
X+ d421 1
X+ a421 1
X+ unidialer_write_str (FD, echo_off_command); /* turn off echoing */
X+ d430 1
X+ a430 1
X+ ioctl (FD, TIOCFLUSH, 0); /* flush any clutter */
X+ d432 1
X+ a432 2
X+ acu_nap (intercommand_delay);
X+ unidialer_write_str (FD, init_string);
X+ a438 3
X+ acu_nap (intercommand_delay);
X+ unidialer_write_str (FD, dial_command);
X+
X+ d443 1
X+ a443 1
X+ unidialer_write_str (FD, num);
X+ d445 1
X+ a445 1
X+ unidialer_write_str (FD, "\r");
X+ d447 1
X+ a447 1
X+ connected = unidialer_connect();
X+ d456 1
X+ d459 1
X+ d463 124
X+ d590 28
X+ d620 7
X+ a626 8
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+ d628 2
X+ a629 1
X+ unidialer_write_str (FD, escape_sequence);
X+ d631 6
X+ a636 2
X+ unidialer_write_str (FD, hangup_command);
X+ okay = unidialer_swallow ("\r\nOK\r\n");
X+ d646 1
X+ d663 1
X+ d686 4
X+ a689 1
X+ putchar(c);
X+ d699 45
X+ a760 1
X+ struct sgttyb sb;
X+ d806 1
X+ a806 2
X+ if (ioctl(FD, TIOCGETP, &sb) < 0) {
X+ perror("TIOCGETP");
X+ a807 6
X+ }
X+ sb.sg_ispeed = sb.sg_ospeed = bm->baud;
X+ if (ioctl(FD, TIOCSETP, &sb) < 0) {
X+ perror("TIOCSETP");
X+ goto error;
X+ }
X+ d838 1
X+ a838 1
X+ ioctl (FD, TIOCFLUSH, 0); /* flush any clutter */
X+ d867 1
X+ a867 1
X+ acu_nap (escape_guard_time);
X+ d875 32
X+ a916 3
X+ struct sgttyb sb;
X+ ioctl (fd, TIOCGETP, &sb);
X+ ioctl (fd, TIOCSETP, &sb);
X+ a919 2
X+ ioctl (fd, TIOCGETP, &sb);
X+ ioctl (fd, TIOCSETP, &sb);
X+ d925 1
X+ a925 1
X+ static unidialer_verbose_read()
X+ @
Xdiff -r -c ./libacu/acucommon.c libacu/acucommon.c
X*** ./libacu/acucommon.c Sun Mar 26 18:47:08 1995
X--- libacu/acucommon.c Sun Mar 26 12:10:52 1995
X***************
X*** 0 ****
X--- 1,190 ----
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[] = "@(#)acucommon.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+
X+ #if HAVE_SELECT
X+ #include <sys/types.h>
X+ #include <sys/times.h>
X+ #include <unistd.h>
X+
X+ void acu_nap (unsigned int how_long)
X+ {
X+ struct timeval t;
X+ t.tv_usec = (how_long % 1000) * 1000;
X+ t.tv_sec = how_long / 1000;
X+ (void) select (0, NULL, NULL, NULL, &t);
X+ }
X+
X+ #elif HAVE_USLEEP
X+ void acu_nap (unsigned int how_long)
X+ {
X+ (void) usleep (how_long * 1000);
X+ }
X+
X+ #else
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 int ringring;
X+
X+ static void acunap_napx()
X+ {
X+ ringring = 1;
X+ }
X+
X+ void acu_nap (unsigned int how_long)
X+ {
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 = how_long / 1000;
X+ itp->it_value.tv_usec = ((how_long % 1000) * 1000);
X+ setvec(vec, acunap_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+ #endif /* HAVE_USLEEP */
X+
X+ void acu_hw_flow_control (hw_flow_control)
X+ {
X+ #if HAVE_TERMIOS
X+ struct termios t;
X+ if (tcgetattr (FD, &t) == 0) {
X+ if (hw_flow_control)
X+ t.c_cflag |= CRTSCTS;
X+ else
X+ t.c_cflag &= ~CRTSCTS;
X+ tcsetattr (FD, TCSANOW, &t);
X+ }
X+ #endif /* HAVE_TERMIOS */
X+ }
X+
X+ int acu_flush ()
X+ {
X+ #ifdef TIOCFLUSH
X+ int flags = 0;
X+ return (ioctl (FD, TIOCFLUSH, &flags) == 0); /* flush any clutter */
X+ #elif !HAVE_TERMIOS
X+ struct sgttyb buf;
X+ return (ioctl (FD, TIOCGETP, &buf) == 0 && ioctl (FD, TIOCSETP, &buf) == 0);
X+ #endif
X+ }
X+
X+ int acu_getspeed ()
X+ {
X+ #if HAVE_TERMIOS
X+ struct termios term;
X+ tcgetattr (FD, &term);
X+ return (term.c_ospeed);
X+ #else /* HAVE_TERMIOS */
X+ struct sgttyb buf;
X+ ioctl (FD, TIOCGETP, &buf);
X+ return (buf.sg_ospeed);
X+ #endif
X+ }
X+
X+ int acu_setspeed (int speed)
X+ {
X+ int rc = 0;
X+ #if HAVE_TERMIOS
X+ struct termios term;
X+ if (tcgetattr (FD, &term) == 0) {
X+ #ifndef _POSIX_SOURCE
X+ cfsetspeed (&term, speed);
X+ #else
X+ cfsetispeed (&term, speed);
X+ cfsetospeed (&term, speed);
X+ #endif
X+ if (tcsetattr (FD, TCSANOW, &term) == 0)
X+ ++rc;
X+ }
X+ #else /* HAVE TERMIOS */
X+ struct sgttyb sb;
X+ if (ioctl(FD, TIOCGETP, &sb) < 0) {
X+ perror("TIOCGETP");
X+ }
X+ else {
X+ sb.sg_ispeed = sb.sg_ospeed = speed;
X+ if (ioctl(FD, TIOCSETP, &sb) < 0) {
X+ perror("TIOCSETP");
X+ }
X+ else
X+ ++rc;
X+ }
X+ #endif /* HAVE TERMIOS */
X+ return (rc);
X+ }
X+
X+ void acu_hupcl ()
X+ {
X+ #if HAVE_TERMIOS
X+ struct termios term;
X+ tcgetattr (FD, &term);
X+ term.c_cflag |= HUPCL;
X+ tcsetattr (FD, TCSANOW, &term);
X+ #elif defined(TIOCHPCL)
X+ ioctl(FD, TIOCHPCL, 0);
X+ #endif
X+ }
X+
X+ /* end of acucommon.c */
Xdiff -r -c ./libacu/acucommon.h libacu/acucommon.h
X*** ./libacu/acucommon.h Sun Mar 26 18:47:08 1995
X--- libacu/acucommon.h Sun Mar 26 12:09:50 1995
X***************
X*** 0 ****
X--- 1,6 ----
X+ void acu_nap (unsigned int how_long);
X+ void acu_hw_flow_control (int hw_flow_control);
X+ int acu_flush ();
X+ void acu_hupcl ();
X+ int acu_setspeed (int speed);
X+ /* end of acucommon.h */
Xdiff -r -c ./libacu/biz22.c libacu/biz22.c
X*** ./libacu/biz22.c Sun Mar 26 18:47:01 1995
X--- libacu/biz22.c Thu Mar 23 18:50:00 1995
X***************
X*** 35,40 ****
X--- 35,41 ----
X static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
X #endif /* not lint */
X
X+ #include "tipconf.h"
X #include "tip.h"
X
X #define DISCONNECT_CMD "\20\04" /* disconnection string */
X***************
X*** 88,94 ****
X * 1 \r success
X */
X connected = detect("1\r");
X! #ifdef ACULOG
X if (timeout) {
X char line[80];
X
X--- 89,95 ----
X * 1 \r success
X */
X connected = detect("1\r");
X! #if ACULOG
X if (timeout) {
X char line[80];
X
Xdiff -r -c ./libacu/biz31.c libacu/biz31.c
X*** ./libacu/biz31.c Sun Mar 26 18:47:00 1995
X--- libacu/biz31.c Thu Mar 23 18:50:06 1995
X***************
X*** 35,40 ****
X--- 35,41 ----
X static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93";
X #endif /* not lint */
X
X+ #include "tipconf.h"
X #include "tip.h"
X
X #define MAXRETRY 3 /* sync up retry count */
X***************
X*** 81,87 ****
X * ` CONNECTION\r\n^G' success
X */
X connected = detect(" ");
X! #ifdef ACULOG
X if (timeout) {
X char line[80];
X
X--- 82,88 ----
X * ` CONNECTION\r\n^G' success
X */
X connected = detect(" ");
X! #if ACULOG
X if (timeout) {
X char line[80];
X
Xdiff -r -c ./libacu/courier.c libacu/courier.c
X*** ./libacu/courier.c Sun Mar 26 18:47:00 1995
X--- libacu/courier.c Thu Mar 23 18:50:24 1995
X***************
X*** 39,45 ****
X--- 39,47 ----
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 #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 cour_connect(), cour_swallow();
X--- 57,63 ----
X char *acu;
X {
X register char *cp;
X! #if ACULOG
X char line[80];
X #endif
X static int cour_connect(), cour_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 (!coursync()) {
X badsynch:
X printf("can't synchronize with courier\n");
X! #ifdef ACULOG
X logent(value(HOST), num, "courier", "can't synch up");
X #endif
X return (0);
X--- 65,79 ----
X if (boolean(value(VERBOSE)))
X printf("Using \"%s\"\n", acu);
X
X! acu_hupcl ();
X!
X /*
X * Get in synch.
X */
X if (!coursync()) {
X badsynch:
X printf("can't synchronize with courier\n");
X! #if ACULOG
X logent(value(HOST), num, "courier", "can't synch up");
X #endif
X return (0);
X***************
X*** 93,99 ****
X cour_write(FD, num, strlen(num));
X cour_write(FD, "\r", 1);
X connected = cour_connect();
X! #ifdef ACULOG
X if (timeout) {
X sprintf(line, "%d second dial timeout",
X number(value(DIALTIMEOUT)));
X--- 96,102 ----
X cour_write(FD, num, strlen(num));
X cour_write(FD, "\r", 1);
X connected = cour_connect();
X! #if ACULOG
X if (timeout) {
X sprintf(line, "%d second dial timeout",
X number(value(DIALTIMEOUT)));
X***************
X*** 181,187 ****
X {
X char c;
X int nc, nl, n;
X- struct sgttyb sb;
X char dialer_buf[64];
X struct baud_msg *bm;
X sig_t f;
X--- 184,189 ----
X***************
X*** 220,234 ****
X for (bm = baud_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! perror("TIOCSETP");
X goto error;
X- }
X signal(SIGALRM, f);
X #ifdef DEBUG
X if (boolean(value(VERBOSE)))
X--- 222,229 ----
X for (bm = baud_msg ; bm->msg ; bm++)
X if (strcmp(bm->msg,
X 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***************
X*** 302,319 ****
X char *cp;
X int n;
X {
X- struct sgttyb sb;
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 cour_nap();
X for ( ; n-- ; cp++) {
X write(fd, cp, 1);
X! ioctl(fd, TIOCGETP, &sb);
X! ioctl(fd, TIOCSETP, &sb);
X cour_nap();
X }
X }
X--- 297,311 ----
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 cour_nap();
X for ( ; n-- ; cp++) {
X write(fd, cp, 1);
X! acu_flush ();
X cour_nap();
X }
X }
X***************
X*** 334,380 ****
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 courier 50 milliseconds between characters */
X-
X- static int ringring;
X-
X cour_nap()
X {
X!
X! static void cour_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, cour_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! cour_napx()
X! {
X! ringring = 1;
X! }
X--- 326,334 ----
X }
X #endif
X
X cour_nap()
X {
X! acu_nap (50);
X }
X
X! /* end of courier.c */
Xdiff -r -c ./libacu/df.c libacu/df.c
X*** ./libacu/df.c Sun Mar 26 18:47:00 1995
X--- libacu/df.c Thu Mar 16 07:39:51 1995
X***************
X*** 39,44 ****
X--- 39,45 ----
X * Dial the DF02-AC or DF03-AC
X */
X
X+ #include "tipconf.h"
X #include "tip.h"
X
X static jmp_buf Sjbuf;
X***************
X*** 63,73 ****
X int df03;
X {
X register int f = FD;
X- struct sgttyb buf;
X int speed = 0, rw = 2;
X char c = '\0';
X
X! ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
X if (setjmp(Sjbuf)) {
X printf("connection timed out\r\n");
X df_disconnect();
X--- 64,74 ----
X int df03;
X {
X register int f = FD;
X int speed = 0, rw = 2;
X char c = '\0';
X
X! acu_hupcl ();
X!
X if (setjmp(Sjbuf)) {
X printf("connection timed out\r\n");
X df_disconnect();
X***************
X*** 80,90 ****
X if (df03) {
X int st = TIOCM_ST; /* secondary Transmit flag */
X
X! ioctl(f, TIOCGETP, &buf);
X! if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
X! speed = buf.sg_ospeed;
X! buf.sg_ospeed = buf.sg_ispeed = B1200;
X! ioctl(f, TIOCSETP, &buf);
X ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
X } else
X ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
X--- 81,88 ----
X if (df03) {
X int st = TIOCM_ST; /* secondary Transmit flag */
X
X! if ((speed = acu_getspeed ()) != B1200) { /* must dial at 1200 baud */
X! acu_setspeed (B1200);
X ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
X } else
X ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
X***************
X*** 100,107 ****
X read(f, &c, 1);
X #ifdef TIOCMSET
X if (df03 && speed) {
X! buf.sg_ispeed = buf.sg_ospeed = speed;
X! ioctl(f, TIOCSETP, &buf);
X }
X #endif
X return (c == 'A');
X--- 98,104 ----
X read(f, &c, 1);
X #ifdef TIOCMSET
X if (df03 && speed) {
X! acu_setspeed (speed);
X }
X #endif
X return (c == 'A');
Xdiff -r -c ./libacu/dn11.c libacu/dn11.c
X*** ./libacu/dn11.c Sun Mar 26 18:47:00 1995
X--- libacu/dn11.c Thu Mar 16 07:41:24 1995
X***************
X*** 38,43 ****
X--- 38,44 ----
X /*
X * Routines for dialing up on DN-11
X */
X+ #include "tipconf.h"
X #include "tip.h"
X
X int dn_abort();
X***************
X*** 95,101 ****
X--- 96,113 ----
X return (0);
X }
X alarm(0);
X+
X+ #if HAVE_TERMIOS
X+ {
X+ struct termios term;
X+ tcgetattr (dn, &term);
X+ term.c_cflag |= HUPCL;
X+ tcsetattr (dn, TCSANOW, &term);
X+ }
X+ #elif defined(TIOCHPCL)
X ioctl(dn, TIOCHPCL, 0);
X+ #endif
X+
X signal(SIGALRM, SIG_DFL);
X while ((nw = wait(<)) != child && nw != -1)
X ;
Xdiff -r -c ./libacu/hayes.c libacu/hayes.c
X*** ./libacu/hayes.c Sun Mar 26 18:47:00 1995
X--- libacu/hayes.c Thu Mar 23 18:50:44 1995
X***************
X*** 58,63 ****
X--- 58,64 ----
X * mode only. This would make it consistent with normal
X * interactive use thru the command 'tip dialer'.
X */
X+ #include "tipconf.h"
X #include "tip.h"
X
X #define min(a,b) ((a < b) ? a : b)
X***************
X*** 82,88 ****
X register char *cp;
X register int connected = 0;
X char dummy;
X! #ifdef ACULOG
X char line[80];
X #endif
X if (hay_sync() == 0) /* make sure we can talk to the modem */
X--- 83,89 ----
X register char *cp;
X register int connected = 0;
X char dummy;
X! #if ACULOG
X char line[80];
X #endif
X if (hay_sync() == 0) /* make sure we can talk to the modem */
X***************
X*** 90,97 ****
X if (boolean(value(VERBOSE)))
X printf("\ndialing...");
X fflush(stdout);
X! ioctl(FD, TIOCHPCL, 0);
X! ioctl(FD, TIOCFLUSH, 0); /* get rid of garbage */
X write(FD, "ATv0\r", 5); /* tell modem to use short status codes */
X gobble("\r");
X gobble("\r");
X--- 91,98 ----
X if (boolean(value(VERBOSE)))
X printf("\ndialing...");
X fflush(stdout);
X! acu_hupcl ();
X! acu_flush ();
X write(FD, "ATv0\r", 5); /* tell modem to use short status codes */
X gobble("\r");
X gobble("\r");
X***************
X*** 113,119 ****
X return (connected); /* lets get out of here.. */
X }
X ioctl(FD, TIOCFLUSH, 0);
X! #ifdef ACULOG
X if (timeout) {
X sprintf(line, "%d second dial timeout",
X number(value(DIALTIMEOUT)));
X--- 114,120 ----
X return (connected); /* lets get out of here.. */
X }
X ioctl(FD, TIOCFLUSH, 0);
X! #if ACULOG
X if (timeout) {
X sprintf(line, "%d second dial timeout",
X number(value(DIALTIMEOUT)));
Xdiff -r -c ./libacu/modems libacu/modems
X*** ./libacu/modems Sun Mar 26 18:47:09 1995
X--- libacu/modems Sun Mar 26 18:00:13 1995
X***************
X*** 0 ****
X--- 1,33 ----
X+ #
X+ # @(#)modems 3/24/95
X+ #
X+ # modems -- modem configuration data base file
X+ # see tip(1), modems(5)
X+ #
X+ # dial_command AT command to dial up remote
X+ # echo_off_command AT command to turn off command echo
X+ # escape_guard_time Shroud escape sequence with specified delay (ms)
X+ # escape_sequence Return to command escape sequence
X+ # hangup_command AT command to hangup modem
X+ # hw_flow_control Enable RTS/CTS flow control between DTE/DCE
X+ # intercharacter_delay Delay between characters sent to modem when issuing
X+ # commands
X+ # intercommand_delay Minimum delay between commands to modem
X+ # init_string AT command to initialize modem before dialing out
X+ # lock_baud Use fixed DTE / DCE bit rate
X+ # reset_delay Delay required by modem for reset
X+ #
X+
X+ sportster|st|US Robotics Sportster 14.4K:dial_command=ATDT%s\r:hangup_command=ATH\r:\
X+ :echo_off_command=ATE0\r:reset_command=AT&F1\r:\
X+ :init_string=AT&B1&H1&R2&C1&D2\r:\
X+ :escape_sequence=+++:hw_flow_control:lock_baud:intercharacter_delay#50:\
X+ :intercommand_delay#250:escape_guard_time#500:reset_delay#2000:
X+
X+ mt932|multitech|mt|Multitech 932:dial_command=ATDT%s\r:hangup_command=ATH\r:\
X+ :echo_off_command=ATE0\r:reset_command=ATZ\r:\
X+ :init_string=AT$BA0$SB38400&E1&E4&E13&E15Q0V1X4E0S0=0\r:\
X+ :escape_sequence=+++:hw_flow_control:lock_baud:intercharacter_delay#50:\
X+ :intercommand_delay#250:escape_guard_time#500:reset_delay#2000:
X+
X+ generic|Generic AT command modem (use defaults):
END_OF_FILE
if test 48717 -ne `wc -c <'patches.tip.1'`; then
echo shar: \"'patches.tip.1'\" unpacked with wrong size!
fi
# end of 'patches.tip.1'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
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?199503270833.AAA12435>
