* Copyright (c) 1983 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)ventel.c 5.4 (Berkeley) 3/2/91";
* Routines for calling up on a Ventel Modem
* The Ventel is expected to be strapped for local echo (just like uucp)
static jmp_buf timeoutbuf
;
* some sleep calls have been replaced by this macro
* because some ventel modems require two <cr>s in less than
* a second in order to 'wake up'... yes, it is dirty...
#define delay(num,denom) busyloop(CPUSPEED*num/denom)
#define CPUSPEED 1000000 /* VAX 780 is 1MIPS */
#define DELAY(n) { register long N = (n); while (--N > 0); }
busyloop(n
) { DELAY(n
); }
register int connected
= 0;
char *msg
, *index(), line
[80];
static int gobble(), vensync();
* Get in synch with a couple of carriage returns
printf("can't synchronize with ventel\n");
logent(value(HOST
), num
, "ventel", "can't synch up");
if (boolean(value(VERBOSE
)))
echo("#k$\r$\n$D$I$A$L$:$ ");
for (cp
= num
; *cp
; cp
++) {
connected
= gobble('!', line
);
sprintf(line
, "%d second dial timeout",
number(value(DIALTIMEOUT
)));
logent(value(HOST
), num
, "ventel", line
);
ven_disconnect(); /* insurance */
if (connected
|| timeout
|| !boolean(value(VERBOSE
)))
/* call failed, parse response for user */
for (cp
= line
; cp
= index(cp
, ' '); cp
++)
while (c
= *s
++) switch (c
) {
printf("\07timeout waiting for reply\n");
register char *cp
= response
;
f
= signal(SIGALRM
, sigALRM
);
if (setjmp(timeoutbuf
)) {
alarm(number(value(DIALTIMEOUT
)));
if (boolean(value(VERBOSE
)))
} while (c
!= '\n' && c
!= match
);
signal(SIGALRM
, SIG_DFL
);
#define min(a,b) ((a)>(b)?(b):(a))
* This convoluted piece of code attempts to get
* the ventel in sync. If you don't have FIONREAD
* there are gory ways to simulate this.
* Toggle DTR to force anyone off that might have left
* the modem connected, and insure a consistent state
* If you don't have the ioctl calls to diddle directly
* with DTR, you can always try setting the baud rate to 0.
while (already
< MAXRETRY
) {
* After reseting the modem, send it two \r's to
* autobaud on. Make sure to delay between them
* so the modem can frame the incoming characters.
if (ioctl(fd
, FIONREAD
, (caddr_t
)&nread
) < 0) {
read(fd
, buf
, min(nread
, 60));
if ((buf
[nread
- 1] & 0177) == '$')