chat for ppp, from ppp 2.1.2
This commit is contained in:
parent
0b06d15f3a
commit
9b1aec4804
5
usr.bin/chat/Example
Normal file
5
usr.bin/chat/Example
Normal file
@ -0,0 +1,5 @@
|
||||
#
|
||||
|
||||
../pppd/pppd -d connect 'chat "" ATDT5551212 CONNECT "" ogin: ppp' netmask 255.255.255.0 /dev/com1 38400
|
||||
|
||||
../pppd/pppd connect 'chat "" AATDT5551212 CONNECT "" ogin: ppp' netmask 255.255.255.0 /dev/com1 38400
|
8
usr.bin/chat/Makefile
Normal file
8
usr.bin/chat/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
# $Id: Makefile.bsd,v 1.2 1994/05/26 06:45:03 paulus Exp $
|
||||
|
||||
PROG= chat
|
||||
SRCS= chat.c
|
||||
MAN8= chat.8
|
||||
BINDIR= /usr/bin
|
||||
|
||||
.include <bsd.prog.mk>
|
169
usr.bin/chat/README
Normal file
169
usr.bin/chat/README
Normal file
@ -0,0 +1,169 @@
|
||||
I run PPP between crappie.morningstar.com (137.175.6.3, my home
|
||||
machine) and remora.morningstar.com (137.175.2.7, my workstation at
|
||||
the office). This document describes how I use it. The installation
|
||||
of PPP itself is covered in the PPP distribution.
|
||||
|
||||
I put a line like this in remora's /etc/passwd:
|
||||
|
||||
Pkarl:2y4613BDaQD3x:51:10:Karl's PPP login:/tmp:/usr/local/etc/pppstart
|
||||
|
||||
I created a login shell script on remora called
|
||||
/usr/local/etc/pppstart:
|
||||
|
||||
#!/bin/sh
|
||||
/usr/bin/mesg n
|
||||
stty -tostop
|
||||
exec /usr/local/etc/ppp 137.175.2.7:
|
||||
|
||||
I use the ppp-on command to bring up a connection, and ppp-off to shut
|
||||
it down. These shell scripts, plus the unlock and fix-cua scripts and
|
||||
the source to the chat program are included. You will need to heavily
|
||||
modify these to suit your own situation, including Internet addresses,
|
||||
machine names, telephone numbers, modem dialing commands, baud rates,
|
||||
login names and passwords. Make the "ppp..." command in the ppp-on
|
||||
script look something like this:
|
||||
|
||||
ppp 137.175.6.3: /dev/cua &
|
||||
|
||||
The "137.175.6.3:" is of the format "local-addr:remote-addr" with the
|
||||
remote address null (it will be negotiated by PPP). Look at the login
|
||||
shell script above; it can be common to all dial-in PPP users on your
|
||||
machine because it only specifies the address of the remora
|
||||
(receiving) end of the link.
|
||||
|
||||
If you use the enclosed chat and unlock programs, be sure they are
|
||||
suid uucp, and fix-cua should be suid root. The ppp-on script should
|
||||
be chmod 700, owner yourself, to keep the password (semi-) secure.
|
||||
|
||||
I use the following eeprom settings and /dev and /etc/ttytab entries
|
||||
in order to support dial-in and dial-out on a single phone line:
|
||||
|
||||
crappie 12% eeprom | grep ttya
|
||||
ttya-mode=19200,8,1,n,h
|
||||
ttya-rts-dtr-off=false
|
||||
ttya-ignore-cd=false
|
||||
crappie 13% ls -lg /dev/cua /dev/ttya
|
||||
crw-rw-rw- 1 root staff 12, 128 Nov 20 09:14 /dev/cua
|
||||
crw--w--w- 1 root wheel 12, 0 Nov 20 08:25 /dev/ttya
|
||||
crappie 14% grep ttya /etc/ttytab
|
||||
ttya "/usr/etc/getty std.19200" unknown on
|
||||
crappie 15%
|
||||
|
||||
On SunOS 4.1 and later, make sure that the /etc/ttytab line for ttya
|
||||
doesn't say "local":
|
||||
|
||||
ttya "/usr/etc/getty std.38400" unknown on
|
||||
|
||||
Make sure your modem passes data transparently; watch out especially
|
||||
for ^S, ^Q, ^P (UUCP spoofing) and parity problems. I have a Telebit
|
||||
Trailblazer+ attached to /dev/ttya with the following register
|
||||
settings:
|
||||
|
||||
aaatz
|
||||
OK
|
||||
aat&n
|
||||
E1 F1 M1 Q6 P V1 X0 Version BA4.00
|
||||
S00=001 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07=060 S08=002 S09=006
|
||||
S10=007 S11=070 S12=050
|
||||
S45=000 S47=004 S48=000 S49=000
|
||||
S50=000 S51=005 S52=002 S53=003 S54=001 S55=000 S56=017 S57=019 S58=002 S59=000
|
||||
S60=000 S61=000 S62=003 S63=001 S64=000 S65=000 S66=001 S67=000 S68=255
|
||||
S90=000 S91=000 S92=001 S95=000
|
||||
S100=000 S101=000 S102=000 S104=000
|
||||
S110=001 S111=030 S112=001
|
||||
S121=000
|
||||
N0:
|
||||
N1:
|
||||
N2:
|
||||
N3:
|
||||
N4:
|
||||
N5:
|
||||
N6:
|
||||
N7:
|
||||
N8:
|
||||
N9:
|
||||
OK
|
||||
|
||||
And, the following entry is in /etc/gettytab:
|
||||
|
||||
#
|
||||
# 19200/2400 dialin for Telebit Trailblazer+ modem
|
||||
#
|
||||
T|T19200:dial-19200:\
|
||||
:nx=T2400:sp#19200:
|
||||
T2400|dial-2400:\
|
||||
:nx=T19200:sp#2400:
|
||||
|
||||
My chat script dialing command looks like "ATs50=255s111=0DT4515678"
|
||||
instead of just "ATDT4515678" in order to force a PEP mode connection
|
||||
and to disable the UUCP spoofing (otherwise, the modem swallows or
|
||||
delays ^P characters).
|
||||
|
||||
I run /usr/etc/in.routed on crappie (the calling end) and have this in
|
||||
my /etc/gateways file:
|
||||
|
||||
net 0.0.0.0 gateway remora metric 1 passive
|
||||
host crappie gateway crappie metric 0 passive
|
||||
|
||||
Routed is started in /etc/rc.local. This way, I don't have to
|
||||
manually add or delete routes when links come up. I ifconfig the ppp0
|
||||
interface on crappie at boot time like this (in /etc/rc.local with the
|
||||
other ifconfig's):
|
||||
|
||||
ifconfig ppp0 crappie remora netmask 0xffffff00 down
|
||||
|
||||
I put "init ppp_attach" in my /sys/sun4c/conf/CRAPPIE file so that the
|
||||
above ifconfig down will work:
|
||||
|
||||
pseudo-device ppp1 init ppp_attach # Point-to-Point Protocol, 1 line
|
||||
|
||||
Routed now keeps my routes sane at the crappie.MorningStar.Com end.
|
||||
|
||||
My ethernet (le0) and PPP (ppp0) interfaces are configured with the
|
||||
same address and netmask. IP is smart enough to figure out (via the
|
||||
routes in /etc/gateways) that everything useful needs to go out ppp0.
|
||||
Also, the remora end of my PPP link is configured the same way -- the
|
||||
ppp0 interface there is configured with the same address and netmask
|
||||
as remora's le0 ethernet. This means that separate interface names
|
||||
like "remora-ppp" are not needed; point-to-point links (whether PPP,
|
||||
Xerox Synchronous Point-to-Point Protocol, SLIP, IGP or whatever) have
|
||||
(apparently) been used this (seemingly bizarre) way for some time.
|
||||
This works because when IP looks at a POINTOPOINT link it ignores the
|
||||
local address (unlike an ethernet interface) and only looks at the
|
||||
remote address.
|
||||
|
||||
Here's what netstat shows for me:
|
||||
|
||||
crappie 109% netstat -r
|
||||
Routing tables
|
||||
Destination Gateway Flags Refcnt Use Interface
|
||||
localhost localhost UH 0 0 lo0
|
||||
crappie crappie UH 1 11339 le0
|
||||
default remora UG 0 1266 ppp0
|
||||
mstar-net-ppp-remora crappie U 0 0 le0
|
||||
crappie 110% netstat -rn
|
||||
Routing tables
|
||||
Destination Gateway Flags Refcnt Use Interface
|
||||
127.0.0.1 127.0.0.1 UH 0 0 lo0
|
||||
137.175.6.3 137.175.6.3 UH 1 11339 le0
|
||||
default 137.175.2.7 UG 0 1266 ppp0
|
||||
137.175.6.0 137.175.6.3 U 0 0 le0
|
||||
crappie 111%
|
||||
|
||||
The default route to remora is a result of the first line in the
|
||||
/etc/gateways file ("default" can't be used there; you have to say
|
||||
"0.0.0.0").
|
||||
|
||||
On the network at work, I add a static route in our gateway machine's
|
||||
/etc/rc.local file:
|
||||
|
||||
/usr/etc/route add net 137.175.6 remora 1
|
||||
|
||||
All the other machines in the office have default routes pointing at
|
||||
the gateway machine, and all PPP-connected external machines are on the
|
||||
137.175.6 subnet.
|
||||
|
||||
Send me mail or post to the newsgroup comp.protocols.ppp if you have
|
||||
any questions.
|
||||
|
||||
Karl Fox <karl@MorningStar.Com>
|
251
usr.bin/chat/chat.8
Normal file
251
usr.bin/chat/chat.8
Normal file
@ -0,0 +1,251 @@
|
||||
.\" -*- nroff -*-
|
||||
.\" manual page [] for chat 1.8
|
||||
.\" $Id: chat.8,v 1.7 1994/03/04 20:19:30 callahan Exp $
|
||||
.\" SH section heading
|
||||
.\" SS subsection heading
|
||||
.\" LP paragraph
|
||||
.\" IP indented paragraph
|
||||
.\" TP hanging label
|
||||
.TH CHAT 8 "17 April 1994" "Chat Version 1.8"
|
||||
.SH NAME
|
||||
chat \- Automated conversational script with a modem
|
||||
.SH SYNOPSIS
|
||||
.B chat
|
||||
[
|
||||
.I options
|
||||
]
|
||||
.I script
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
The \fIchat\fR program defines a conversational exchange between the
|
||||
computer and the modem. Its primary purpose is to establish the
|
||||
connection between the Point-to-Point Protocol Daemon (\fIpppd\fR) and
|
||||
the remote's \fIpppd\fR process.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B -f \fI<chat file>
|
||||
Read the chat script from the chat \fIfile\fR. The use of this option
|
||||
is mutually exclusive with the chat script parameters. The user must
|
||||
have read access to the file. Multiple lines are permitted in the
|
||||
file. Space or horizontal tab characters should be used to separate
|
||||
the strings.
|
||||
.TP
|
||||
.B -l \fI<lock file>
|
||||
Perform the UUCP style locking using the indicated lock file.
|
||||
.IP
|
||||
If the file could not be created then the \fIchat\fR program will
|
||||
fail. The lock file will be deleted only if the \fIchat\fR program
|
||||
fails to perform the script for any reason. If the script is
|
||||
successful the lock file will be left on the disk. It is expected that
|
||||
the lock file will be deleted when the \fIpppd\fR process no longer
|
||||
wishes to use the serial device.
|
||||
.IP
|
||||
The use of a lock file with
|
||||
.I chat
|
||||
and
|
||||
\fIpppd\fR\'s
|
||||
.I lock
|
||||
option should not be used at the same time. They are mutually
|
||||
exclusive options and will cause one or the other program to fail to
|
||||
achieve the required lock if you use both.
|
||||
.TP
|
||||
.B -t \fI<timeout>
|
||||
Set the timeout for the expected string to be received. If the string
|
||||
is not received within the time limit then the reply string is not
|
||||
sent. An alternate reply may be sent or the script will fail if there
|
||||
is no alternate reply string. A failed script will cause the
|
||||
\fIchat\fR program to terminate with a non-zero error code.
|
||||
.TP
|
||||
.B -v
|
||||
Request that the \fIchat\fR script be executed in a verbose mode. The
|
||||
\fIchat\fR program will then log all text received from the modem and
|
||||
the output strings which it sends to the SYSLOG.
|
||||
.TP
|
||||
.B script
|
||||
If the script is not specified in a file with the \fI-f\fR option then
|
||||
the script is included as parameters to the \fIchat\fR program.
|
||||
.SH CHAT SCRIPT
|
||||
.LP
|
||||
The \fIchat\fR script defines the communications.
|
||||
.LP
|
||||
A script consists of one or more "expect-send" pairs of strings,
|
||||
separated by spaces, with an optional "subexpect-subsend" string pair,
|
||||
separated by a dash as in the following example:
|
||||
.IP
|
||||
ogin:-BREAK-ogin: ppp ssword: hello2u2
|
||||
.LP
|
||||
This line indicates that the \fIchat\fR program should expect the string
|
||||
"ogin:". If it fails to receive a login prompt within the time interval
|
||||
allotted, it is to send a break sequence to the remote and then expect the
|
||||
string "ogin:". If the first "ogin:" is received then the break sequence is
|
||||
not generated.
|
||||
.LP
|
||||
Once it received the login prompt the \fIchat\fR program will send the string ppp
|
||||
and then expect the prompt "ssword:". When it receives the prompt for the
|
||||
password, it will send the password hello2u2.
|
||||
.LP
|
||||
A carriage return is normally sent following the reply string. It is not
|
||||
expected in the "expect" string unless it is specifically requested by using
|
||||
the \\r character sequence.
|
||||
.LP
|
||||
The expect sequence should contain only what is needed to identify the
|
||||
string. Since it is normally stored on a disk file, it should not contain
|
||||
variable information. It is generally not acceptable to look for time
|
||||
strings, network identification strings, or other variable pieces of data as
|
||||
an expect string.
|
||||
.LP
|
||||
To help correct for characters which may be corrupted during the initial
|
||||
sequence, look for the string "ogin:" rather than "login:". It is possible
|
||||
that the leading "l" character may be received in error and you may never
|
||||
find the string even though it was sent by the system. For this reason,
|
||||
scripts look for "ogin:" rather than "login:" and "ssword:" rather than
|
||||
"password:".
|
||||
.LP
|
||||
A very simple script might look like this:
|
||||
.IP
|
||||
ogin: ppp ssword: hello2u2
|
||||
.LP
|
||||
In other words, expect ....ogin:, send ppp, expect ...ssword:, send hello2u2.
|
||||
.LP
|
||||
In actual practice, simple scripts are rare. At the vary least, you
|
||||
should include sub-expect sequences should the original string not be
|
||||
received. For example, consider the following script:
|
||||
.IP
|
||||
ogin:--ogin: ppp ssowrd: hello2u2
|
||||
.LP
|
||||
This would be a better script than the simple one used earlier. This would look
|
||||
for the same login: prompt, however, if one was not received, a single
|
||||
return sequence is sent and then it will look for login: again. Should line
|
||||
noise obscure the first login prompt then sending the empty line will
|
||||
usually generate a login prompt again.
|
||||
.SH ABORT STRINGS
|
||||
Many modems will report the status of the call as a string. These
|
||||
strings may be \fBCONNECTED\fR or \fBNO CARRIER\fR or \fBBUSY\fR. It
|
||||
is often desirable to terminate the script should the modem fail to
|
||||
connect to the remote. The difficulty is that a script would not know
|
||||
exactly which modem string it may receive. On one attempt, it may
|
||||
receive \fBBUSY\fR while the next time it may receive \fBNO CARRIER\fR.
|
||||
.LP
|
||||
These "abort" strings may be specified in the script using the \fIABORT\fR
|
||||
sequence. It is written in the script as in the following example:
|
||||
.IP
|
||||
ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATDT5551212 CONNECT
|
||||
.LP
|
||||
This sequence will expect nothing; and then send the string ATZ. The
|
||||
expected response to this is the string \fIOK\fR. When it receives \fIOK\fR,
|
||||
the string ATDT5551212 to dial the telephone. The expected string is
|
||||
\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder of the
|
||||
script is executed. However, should the modem find a busy telephone, it will
|
||||
send the string \fIBUSY\fR. This will cause the string to match the abort
|
||||
character sequence. The script will then fail because it found a match to
|
||||
the abort string. If it received the string \fINO CARRIER\fR, it will abort
|
||||
for the same reason. Either string may be received. Either string will
|
||||
terminate the \fIchat\fR script.
|
||||
.SH TIMEOUT
|
||||
The initial timeout value is 45 seconds. This may be changed using the \fB-t\fR
|
||||
parameter.
|
||||
.LP
|
||||
To change the timeout value for the next expect string, the following
|
||||
example may be used:
|
||||
.IP
|
||||
ATZ OK ATDT5551212 CONNECT TIMEOUT 10 ogin:--ogin: TIMEOUT 5 assowrd: hello2u2
|
||||
.LP
|
||||
This will change the timeout to 10 seconds when it expects the login:
|
||||
prompt. The timeout is then changed to 5 seconds when it looks for the
|
||||
password prompt.
|
||||
.LP
|
||||
The timeout, once changed, remains in effect until it is changed again.
|
||||
.SH SENDING EOT
|
||||
The special reply string of \fIEOT\fR indicates that the chat program
|
||||
should send an EOT character to the remote. This is normally the
|
||||
End-of-file character sequence. A return character is not sent
|
||||
following the EOT.
|
||||
.PR
|
||||
The EOT sequence may be embedded into the send string using the
|
||||
sequence \fI^D\fR.
|
||||
.SH GENERATING BREAK
|
||||
The special reply string of \fIBREAK\fR will cause a break condition
|
||||
to be sent. The break is a special signal on the transmitter. The
|
||||
normal processing on the receiver is to change the transmission rate.
|
||||
It may be used to cycle through the available transmission rates on
|
||||
the remote until you are able to receive a valid login prompt.
|
||||
.PR
|
||||
The break sequence may be embedded into the send string using the
|
||||
\fI\\K\fR sequence.
|
||||
.SH ESCAPE SEQUENCES
|
||||
The expect and reply strings may contain escape sequences. All of the
|
||||
sequences are legal in the reply string. Many are legal in the expect.
|
||||
Those which are not valid in the expect sequence are so indicated.
|
||||
.TP
|
||||
.B ''
|
||||
Expects or sends a null string. If you send a null string then it will still
|
||||
send the return character. This sequence may either be a pair of apostrophe
|
||||
or quote characters.
|
||||
.TP
|
||||
.B \\\\b
|
||||
represents a backspace character.
|
||||
.TP
|
||||
.B \\\\c
|
||||
Suppresses the newline at the end of the reply string. This is the only
|
||||
method to send a string without a trailing return character. It must
|
||||
be at the end of the send string. For example,
|
||||
the sequence hello\\c will simply send the characters h, e, l, l, o.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \\\\d
|
||||
Delay for one second. The program uses sleep(1) which will delay to a
|
||||
maximum of one second.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \\\\K
|
||||
Insert a BREAK
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \\\\n
|
||||
Send a newline or linefeed character.
|
||||
.TP
|
||||
.B \\\\N
|
||||
Send a null character. The same sequence may be represented by \\0.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \\\\p
|
||||
Pause for a fraction of a second. The delay is 1/10th of a second.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \\\\q
|
||||
Suppress writing the string to the SYSLOG file. The string ?????? is
|
||||
written to the log in its place.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \\\\r
|
||||
Send or expect a carriage return.
|
||||
.TP
|
||||
.B \\\\s
|
||||
Represents a space character in the string. This may be used when it
|
||||
is not desirable to quote the strings which contains spaces. The
|
||||
sequence 'HI TIM' and HI\\sTIM are the same.
|
||||
.TP
|
||||
.B \\\\t
|
||||
Send or expect a tab character.
|
||||
.TP
|
||||
.B \\\\\\\\
|
||||
Send or expect a backslash character.
|
||||
.TP
|
||||
.B \\\\ddd
|
||||
Collapse the octal digits (ddd) into a single ASCII character and send that
|
||||
character.
|
||||
.I (some characters are not valid in expect.)
|
||||
.TP
|
||||
.B \^^C
|
||||
Substitute the sequence with the control character represented by C.
|
||||
For example, the character DC1 (17) is shown as \^^Q.
|
||||
.I (some characters are not valid in expect.)
|
||||
.SH SEE ALSO
|
||||
Additional information about \fIchat\fR scripts may be found with UUCP
|
||||
documentation. The \fIchat\fR script was taken from the ideas proposed by the
|
||||
scripts used by the \fIuucico\fR program.
|
||||
.LP
|
||||
uucico(1), uucp(1)
|
||||
.SH COPYRIGHT
|
||||
The \fIchat\fR program is in public domain. This is not the GNU public
|
||||
license. If it breaks then you get to keep both pieces.
|
1166
usr.bin/chat/chat.c
Normal file
1166
usr.bin/chat/chat.c
Normal file
File diff suppressed because it is too large
Load Diff
129
usr.bin/chat/connect-ppp
Executable file
129
usr.bin/chat/connect-ppp
Executable file
@ -0,0 +1,129 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# USAGE: connect-ppp <host>
|
||||
#
|
||||
# Set up a PPP link to host.
|
||||
#
|
||||
# This script locks the tty so that faxd and uucp will not
|
||||
# interfere. If you are running with faxd as you "getty" then
|
||||
# faxd will remove the lock once it notices that pppd is gone.
|
||||
# This is the reason for pppd running in with the -detach flag,
|
||||
# and you probably would run this script in the background.
|
||||
#
|
||||
# I had to create the nodropdtr option to pppd in order to be
|
||||
# able to do what the script is doing here. Pathces has been
|
||||
# sent to the respective people, but I don't know if they like
|
||||
# them :-).
|
||||
#
|
||||
# Look for comments with <LOCAL> in the string. They identify
|
||||
# things that you want to set for your system
|
||||
|
||||
#<LOCAL> define whatever your config file is.
|
||||
CON_DB=/etc/ppp-connections
|
||||
|
||||
#<LOCAL> define whatever your device is.
|
||||
DEVICE=tty00
|
||||
|
||||
#<LOCAL> define whatever your device speed is.
|
||||
DEVICESPEED=57600
|
||||
|
||||
#<LOCAL> define whatever your lock directory is.
|
||||
LOCKDIR=/var/spool/lock
|
||||
LOCKFILE=$LOCKDIR/LCK..$DEVICE
|
||||
|
||||
#<LOCAL> define whatever debug level you want.
|
||||
DEBUG="-d -d -d -d"
|
||||
|
||||
# Check that we got a name to connect to. This need not be an actuall hostname
|
||||
# just the name you specified in the config file.
|
||||
if [ $# -ne 1 ] ; then
|
||||
echo "Usage: $0 <host> &"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the configuration that is in effect for <name>
|
||||
LINE=`grep "^$1" $CON_DB`
|
||||
if [ -z "$LINE" ] ; then
|
||||
echo "Unknow host $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# parse the CON_DB. The format is:
|
||||
#
|
||||
# <hostname>:<phone number>:<user id>:<password>:<local ip address>:\
|
||||
# <remove_ip_address><netmask>:<pppd options>
|
||||
#
|
||||
# The last three are optional. But I would recomend specifying a netmask also
|
||||
# when you specify a ip address.
|
||||
|
||||
IP_ADDR=""
|
||||
IFS=':'
|
||||
set $LINE
|
||||
IFS=' '
|
||||
HOST=$1
|
||||
PHONE=$2
|
||||
USER=$3
|
||||
PASSWORD=$4
|
||||
OUR_IP_ADDR=$5
|
||||
THEIR_IP_ADDR=$6
|
||||
NETMASK=$7
|
||||
shift 7
|
||||
OPTIONS=$*
|
||||
|
||||
if [ -f $LOCKFILE ] ; then
|
||||
echo "PPP device is locked"
|
||||
exit 1
|
||||
else
|
||||
|
||||
# Lock the device
|
||||
# faxd and UUCP wants 10 character lock id.
|
||||
echo "$$" | awk '{printf("%10s",$0)}' > $LOCKFILE
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#Do we know our local ip address? If so pppd needs a : at the end of it.
|
||||
if [ ! -z "$OUR_IP_ADDR" ] ; then
|
||||
IP_ADDR=${OUR_IP_ADDR}:${THEIR_IP_ADDR}
|
||||
fi
|
||||
|
||||
#Did we specify a netmask? If so convert to pppd format.
|
||||
if [ ! -z "$NETMASK" ] ; then
|
||||
NETMASK="netmask ${NETMASK}"
|
||||
fi
|
||||
|
||||
# Do the actual work in a subshell so that we can turn off tostop and set
|
||||
# the tty speed before chat dials. The second reason for doing in like
|
||||
# is that if you aren't running BIDIR, and you are running faxd, clocal
|
||||
# doesn't get turned on from pppd so chat will never work if you exec
|
||||
# it from within pppd. I found that I needed to run uucp with the
|
||||
# HAVE_CLOCAL_BUG flag set to 1 in order to get it to work in conjunction
|
||||
# with faxd. Anyway, this setup seem to work.
|
||||
(
|
||||
|
||||
stty $DEVICESPEED -tostop hupcl 2> /dev/null
|
||||
|
||||
# <LOCAL> Modify the Modem initialization strings to be whatever works for you
|
||||
if chat -v ABORT "NO CARRIER" ABORT BUSY "" ATZ0E1 OK ATS50=255DT$PHONE \
|
||||
CONNECT "" ogin: $USER ssword: \\q$PASSWORD
|
||||
then
|
||||
# We got connected.
|
||||
/usr/libexec/pppd $DEBUG $OPTIONS -detach modem defaultroute \
|
||||
crtscts $NETMASK $DEVICE $DEVICESPEED $IP_ADDR
|
||||
|
||||
else
|
||||
echo "PPP call failed" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
) < /dev/$DEVICE > /dev/$DEVICE
|
||||
# Get the return code from the subshell.
|
||||
RC=$?
|
||||
|
||||
# Clear the lock. Slight window here where someone could detect that
|
||||
# pppd is no longer running, remove its lock file and create its own.
|
||||
# How to fix??
|
||||
rm -f $LOCKFILE
|
||||
|
||||
#Pass on the exit code.
|
||||
exit $RC
|
16
usr.bin/chat/fix-cua
Normal file
16
usr.bin/chat/fix-cua
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOCKDIR=/var/spool/lock
|
||||
|
||||
case "$1" in
|
||||
"") echo "Usage: fix-cua device"; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -f $LOCKDIR/LCK..$1 ]
|
||||
then
|
||||
echo "/dev/$1 is locked" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chown root /dev/$1
|
||||
chmod 666 /dev/$1
|
5
usr.bin/chat/ppp-off
Executable file
5
usr.bin/chat/ppp-off
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
kill -INT `ps -ax | egrep " ppp " | egrep -v "egrep" | sed 's/^\([ 0-9]*\) .*/\1'/`
|
||||
|
||||
exit 0
|
37
usr.bin/chat/ppp-on
Executable file
37
usr.bin/chat/ppp-on
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# ppp-on
|
||||
#
|
||||
# Set up a PPP link
|
||||
#
|
||||
|
||||
LOCKDIR=/var/spool/lock
|
||||
DEVICE=com1
|
||||
|
||||
PHONE=4511234
|
||||
USER=Pkarl
|
||||
PASSWORD=password
|
||||
OUR_IP_ADDR=137.175.6.3
|
||||
|
||||
if [ -f $LOCKDIR/LCK..$DEVICE ]
|
||||
then
|
||||
echo "PPP device is locked"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fix-cua $DEVICE
|
||||
|
||||
(
|
||||
stty 19200 -tostop
|
||||
|
||||
if chat -l LCK..$DEVICE ABORT "NO CARRIER" ABORT BUSY "" ATZ OK ATs50=255s111=0DT$PHONE CONNECT "" ogin: $USER ssword: \\q$PASSWORD
|
||||
then
|
||||
ppp mru 1500 $OUR_IP_ADDR: /dev/$DEVICE &
|
||||
sleep 10
|
||||
exit 0
|
||||
else
|
||||
echo "PPP call failed" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
) < /dev/$DEVICE > /dev/$DEVICE
|
23
usr.bin/chat/unlock
Executable file
23
usr.bin/chat/unlock
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOCKDIR=/var/spool/lock
|
||||
|
||||
case "$1" in
|
||||
"") echo "Usage: unlock lockfile"; exit 1 ;;
|
||||
.*) echo "Usage: unlock lockfile"; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ -f $LOCKDIR/$1 ]
|
||||
then
|
||||
if [ `wc -c < $LOCKDIR/$1` -eq 4 ]
|
||||
then
|
||||
rm -f $LOCKDIR/$1
|
||||
exit 0
|
||||
else
|
||||
echo "Usage: unlock lockfile"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "lockfile" $LOCKDIR/$1 "does not exist"
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue
Block a user