How to configure a PPP server with Minix.
=========================================

This paper tries to explain how to configure ppp as a server.

The Makefile produces ppp.drv as a client protocol driver, and ppp.srv with
server only code. You can edit config.h to control the inactivity timer, default
in 180 seconds. After this time, the connection is dropped if you have no 
link usage (packets received from peer).

You can use ppp.srv as a driver running from the /etc/ttytab 

In this configuration, I explain how to use ppp in other network than the
default, so you can use your default network for LAN.

1. check your default network like eth0 or psip2. Use netdefault to configure
   it.

2. configure your interfaces and default routes in /etc/rc.net
(the IP assigned are for reference only).

# default network and ppp pseudo interface
ifconfig -h 10.1.1.1 -n 255.255.255.0
ifconfig -I /dev/ip3 -h 20.1.1.1 -n 255.255.255.0 
# default routes
add_route -g 10.1.1.1 
add_route -g 20.1.1.1 -I /dev/ip3
add_route -i -g 0.0.0.0 -d 10.1.1.0 -m 1 -n 255.255.255.0 
add_route -i -g 0.0.0.0 -d 20.1.1.0 -m 10 -n 255.255.255.0 -I /dev/ip3

3. add an entry to /etc/ttytab

tty01  dialup "/usr/local/bin/ppp.srv -l -b 19200 -j 20.1.1.2 -N 10.1.1.1 -f /ppp1.log -I /dev/psip3 /dev/tty01"

here we assume that peer will have an assigned address of 20.1.1.2, we are
runing nonamed in our server to be DNS (10.1.1.1), we create a log file named
/ppp1.log with the driver activity, and force authentication with -l flag.

4. restart the system or kill the init process with 

kill -1 1

to restart and check /etc/ttytab file


5. you can log from any system. You can connect from other Minix system like

ppp.drv -a -b 19200 -u user -p passw -N  /dev/tty00 &

here we need to supply -a switch to began negotiation. Driver will login
using PAP (using an existing user account) and get info from DNS.

6. the driver detects the modem hangup, but check the last comments in this
paper about a modification in rs232.c


Login using a script.
=====================
This also can be possible, when one also likes to login like telnet or ppp.
You need to create routes like steps 1 and 2.

3. create an account to be used by PPP, add a record to /etc/passwd like

ppp::201:10:PPP Account:/usr/ppp:

the "ppp" entry is the account or login, no password is set now, 201 is
the user id, 10 is the group id, "PPP Account" is an explanation, and 
"/usr/ppp" is the default login directory.

4. create the login directory

# cd /usr
# mkdir ppp
# chown ppp ppp

5. change the password to the PPP account

# passwd ppp
Changing the password of ppp
New password: <not display>
Retype password: <not display>

6. create a .profile file to execute ppp at login, in /usr/ppp, the file 
can have the following

umask 022
PATH=/usr/local/bin:/usr/xbin:/bin:/usr/bin
export PATH

stty erase '^H' kill '^U' intr '^?'

exec ppp.srv -b 38400 -a -j 20.1.1.2 -N 10.1.1.1 /dev/tty01

I assume that you login via the COM2 serial line, here is tty01, and use a
speed of 38400 baud.

Here we are authenticated before, you do not need the -l flag.


5. modified the /etc/ttytab to have an entry like

tty01		dialup          getty           "stty 38400"

this entry indicates that tty01 is dialup, need to start getty at boot, 
and run an "stty 38400" command to have 38400 bauds ready.

6. You can login to your machine using kermit/term/chat, and when you see
the login prompt, you can log with ppp as user and the password you set.
This will fire the ppp driver as active, if you have no start the client
ppp, the system ends.

7. you can log using chat and special script like the following

#!/bin/sh
# this script allows you to log to a minix system using chat.
#set -x
#trap date 2
# load the SPEED and TTY variables.
. /etc/modem.line
f=""
n=0
echo `date +%T` - Dialing to Minix ...
chat -v -b $SPEED -f mx.scr < /dev/$TTY > /dev/$TTY 2> /tmp/chat.log
echo `date +%T` - Checking log file ...
n=`grep -c ailed /tmp/chat.log`
if [ $n = 0 ]
then
   echo `date +%T` - Login to ISP succesfull, starting PPP driver ...
   ppp.drv  -b $SPEED  /dev/$TTY &
   echo `date +%T` - Login ended.
else
   f=`grep ailed /tmp/chat.log`
   echo `date +%T` - Failed to login to ISP [ $f ].
fi


8. the mx.scr have the commands to chat, these are for direct connection

TIMEOUT 60 ABORT BUSY ABORT 'NO CARRIER' ABORT 'NO DIAL TONE' '' 
AT OK AT&D0 OK ATM3&N10 OK
'ATDT 0610-123-4567' ogin:
ppp assword:
ppp ''
'\r\r'

here the user and password are set to "ppp". You should check your connection
with term or kermit to know how the peer system responds.



Modem HangUp
============

*******************************************************************************
NOTE: at the time of this writting (April 2001) there is a patch in progress
to tty.c and rs232.c to solve this hangup issue. First check urls to know if 
the patchs are ready. It is for Minix 2.0.2.
*******************************************************************************

The driver should detect hangup signal. But it is not generated if you do not
modify the rs232.c file and recompile and reboot the new kernel

You must modify

from:

#define devhup(rs)	\
	(in_byte(rs->modem_status_port) & (MS_RLSD|MS_DRLSD) == MS_DRLSD)

to: 
#define devhup(rs)	\
	((in_byte(rs->modem_status_port) & (MS_RLSD|MS_DRLSD)) == MS_DRLSD)



This is a simple add of () in the define. This is valid for Minix 2.0.2.




