#!/usr/sbin/dip

#I took the dynamic-ip.dip example and modifed it a bit
#so it would handle the case of dynamic IP allocation for
#BOTH ends of a CSLIP connection.
#
#It works OK for me running dip-3.3.7n on linux 1.3.56
#Hardware is 386 DX 33 MHz.
#
# Here is a dynamic script that I obtained from our ftp server (and slightly
# modified to work with my modem), along with a shell script I wrote to
# grab the assigned IP number for this call and place it into /etc/hosts.
# Hope this helps a few people out:)
# - Blair Sundberg
#
# Modified for ISP's who dynamically allocate IP Addresses at BOTH
# ends of the SLIP/CSLIP/PPP connection by Richard Henschel. i.e:
#
# CONNECT 38400
# Welcome to Sasknet
# Port 2-32
#
# login:YOURLOGINNAME
# Password:YOURPASSWORD
# SL/IP session from (XXX.XXX.X.XX) to YYY.YYY.YY.Y beginning....
#
	# Connection script for dynamic CSLIP
	# Jason Wessel
	# jwessel@uiuc.edu
	# modified for Intel modem and my machine

# I'd recommend, that the login negotiation is done not with
# 8,N,1 as this script suggests, but with 7,E,1 - and only
# after the login (i.e. ASCII) negotiations are over, and
# it's about time to start SLIP protocol, change the line
# parameters to 8,N,1.
# - Uri Blumenthal <uri@watson.ibm.com>

main:
  get $mtu 296
	# Used for the point to point type connection
  netmask 255.255.255.0
        # Set the desired serial port and speed.
	# Com2 is cua1
  port cua1
        # Works well with my 14400 Intel Fax Modem
  speed 38400
  parity N
  databits 8
  stopbits 1
        # Reset the modem and terminal line.
  flush
  send \r\n\r\n
	# Initialization for the Supra Fax Modem You will have to change
	# this to match what type of modem you have
  send ATZ\r
  wait OK 2
  send AT&c1\r
  wait OK 2
  if $errlvl != 0 goto error
	# Nifty redial when busy
redial:
	# Dial our slip server from local phone
  # Uncoment the sleep line if you are having problems with dial speed
  # sleep 3
  send atdtXXXXXXX\r
  wait BUSY 5
  if $errlvl == 0 goto redial
  	flush
  	wait CONNECT 45
  if $errlvl != 0 goto error

        # We are connected.  Login to the system.
login:
   sleep 3
   wait ogin: 10
   if $errlvl != 0 goto error

        # REPLACE YOURLOGINNAME with your login name.
        send YOURLOGINNAME\r
	wait ord: 5
   if $errlvl != 0 goto error

        # REPLACE YOURPASSWORD with your password.
        send YOURPASSWORD\r

	# Need all of this to pick server and client IP's out
	wait SL/IP 1
	wait session 1
	wait from 1
	wait ( 1
	get $rmtip remote
	wait to 1
	get $locip remote
	sleep 3
   if $errlvl != 0 goto error
done:
   default
   print CSLIP to $rmtip with address $locip
   mode CSLIP
   goto exit
error:
   print SLIP to connection failed.
exit:

