dip(8)

NAME
dip - dialup IP connection handler.

SYNOPSIS
dip [-t]
dip [-ktv] [-m mtu] scriptfile
dip [-iv] [user_name]

DESCRIPTION
Dip handles the connections needed for dialup IP links, like SLIP or PPP. It can handle both incoming and outgoing connections, using password security for incoming connections. The outgoing connections use the system's dial(3) library if available.

COMMAND MODE
The first possible use of dip is as a standalone program to set up an outgoing IP connection. This can be done by invoking dip with the -t option, which means enter TEST mode and, more precisely, dumps you in the COMMAND-MODE of the dip program. You are reminded of this by the DIP> prompt, or, if you also specified the -v debugging flag, the DIP [NNNN]> prompt. The latter prompt also displays the current value of the global errlvl variable, which is used mostly when dip runs in script mode. For the interactive mode, it can be used to determine if the result of the previous command was OK or not.
The following is a sample taken from a live session:

$ dip -t
DIP: Dialup IP Protocol Driver version 3.3.4 (08/24/93)
Written by Fred N. van Kempen, MicroWalt Corporation.
DIP> _

The most helpful command in this mode is, of course, the help command, which should produce an output similar to this:

DIP knows about the following commands:
	databits default  dial     echo     get
	goto     help     if       init     mode
	modem    parity   print    port     reset
	send     sleep    speed    stopbits term
	wait
DIP> _

All commands display how they should be used when invoking them with no or invalid arguments. Just experiment a little to get the feel of it, and have a look at the sample script files, which also use this command language.

DIALIN MODE
The second possible way of using dip is as a login shell for incoming IP connections, as in dialup SLIP and PPP connections. To make integration into the existing UNIX system as easy as possible, dip can be installed as simply as using it as a login shell in the system's password file. A sample entry looks like:

suunet:ij/SMxiTlGVCo:1004:10:UUNET:/tmp:/usr/bin/dip -i

When user suunet logs in, the login(1) program sets the home directory to /tmp , and executes the dip program with the -i option, which means that dip must run in input mode. Dip then tries to locate the name of the logged in user (i.e. the name corresponding to its current user id, as returned by the getuid(2) system call) in its database file. An optional single argument to the dip program in this mode can be the username that must be used in this lookup, regardless the current user id.
Dip now scans the /etc/net/diphosts file for an entry for the given user name. This file contains lines of text (much like the standard password file). The format looks like:

#
# diphosts      This file describes a number of name to
#               address mappings for the DIP program. It
#               is used to determine which IP address to
#               use for in incoming call of some user.
#
# Version:      @(#)diphosts    1.00  12/10/92   FvK
#
# Author:       Fred N. van Kempen,
#               <waltje@uwalt.nl.mugnet.org>
#
suunet::uunet.uu.net:UUNET SLIP:SLIP,296
# End of diphosts.

The first field of a line identifies the user name, which we must match. The second field can contain an encrypted password. If this field is non-null, the dip program asks for an External security password: , which must match the password in this field. The third field contains the name (or raw IP address) of the host that is connecting to the system with this link. If a host name is given, the usual address resolving process is started, using either a name server or a local hosts file.
The fourth field may contain any text, it is not (yet) used by the dip program. In future releases, this info may be used in the system log files. Finally, the fifth field of a line contains a mixture of comma-separated flags. Possible flags are:

SLIP to indicate we must use the SLIP protocol.
PPP to indicate we must use the PPP protocol.
number which gives the MTU parameter of this connection.

After finding the correct line, dip puts the terminal line into RAW mode, and asks the system networking layer to allocate a channel of the desired protocol. Finally, if the channel is activated, it adds an entry to the system's routing table to make the connection work.
Dip now goes into an endless loop of sleeping, which continues until the conenction is physically aborted (i.e. the line is dropped). At that time, dip removes the entry it made in the system's routing table, and releases the protocol channel for re-use. It then exists, making room for another session.

DIALOUT MODE
The last way of using dip is as a program that initiates outgoing connections. To make life easier for the people who have to manage links of this type, dip uses a chat script to set up a link to a remote system. This gives the user an enourmous amount of flexibility when making the connection, which otherwise could require many command-line options. The path name of the script to be run is then given as the single argument to dip ; the program will automatically check if the file has a file name ending in a .dip part. This is not mandatory, just a tool to group scripts together in a single directory. A script should look something like this:

#
# sample.dip	Dialup IP connection support program.
#		This file (should show) shows how to use the DIP
#		scripting commands to establish a link to a host.
#		This host runs the 386bsd operating system, and
#		thus can only be used for the "static" addresses.
#
# NOTE:		We also need an examnple of a script used to
#		connect to a "dynamic" SLIP server, like an Annex
#		terminal server...
#
# Version:	@(#)sample.dip	1.30	07/05/93
#
# Author:	Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
#
main:
  # First of all, set up our name for this connection.
  # I am called "uwalt.hacktic.nl"  (== 193.78.33.238)
  get $local uwalt.hacktic.nl
  # Next, set up the other side's name and address.
  # My dialin machine is called 'xs4all.hacktic.nl' (== 193.78.33.42)
  get $remote xs4all.hacktic.nl
  # Set the desired serial port and speed.
  port cua0
  speed 38400
  # Reset the modem and terminal line.
  # This seems to cause trouble for some people!
  reset
  # Prepare for dialing.
  send ATQ0V1E1X1
  wait OK 2
  if $errlvl != 0 goto error
  dial 555-1234567
  if $errlvl != 0 goto error
  wait CONNECT 60
  if $errlvl != 0 goto error
  # We are connected.  Login to the system.
login:
  sleep 3
  send \r\n\r\n
  wait ogin: 10
  if $errlvl != 0 goto error
  send NO-WAY\n
  wait ord: 5
  if $errlvl != 0 goto error
  send HA-HA\n
  wait $ 30
  if $errlvl != 0 goto error
loggedin:
  # We are now logged in.  Start the 'sliplogin' program,
  # as this is not automatically done for me.
  send sliplogin\n
  wait SOME-STRING 15
  # Set up the SLIP operating parameters.
  get $mtu 1500
  # Set Destination net/address as type 'default' (vice an address).
  # This is used by the 'route' command to set the kernel routing table.
  # Some machines seem to require this be done for SLIP to work properly.
  default
  # Say hello and fire up!
done:
  print CONNECTED to $remote with address $rmtip
  mode SLIP
  goto exit
error:
  print SLIP to $remote failed.
exit:

This script causes dip to dial up a host, log in, and get a SLIP interface channel going (in the same manner as with incoming connections). When all is set up, it simply goes into the background and waits for a hangup (or just a lethal signal), at which it hangs up and exists.

FILES
/etc/passwd, /etc/diphosts

AUTHORS
Fred N. van Kempen, waltje@uwalt.nl.mugnet.org,
Paul Mossip, <mossip@vizlab.rutgers.edu>,
Jeff Uphoff, <juphoff@aoc.nrao.edu>,
Jim Seagrave, <jes@grendel.demon.co.uk>