ppp\iproute: Direct Serial/Modem IP Routing Example


This application uses both ports for PPP, with a direct PPP serial
connection on serial port /com/1 running at 38400 bps and a modem
connection on serial port /com/0 running at 115200 bps.  Printfs 
are directed to the debug window.

The /com/1 direct serial line (200.92.187.195) is connected to a Linux
PC with the peer side assigned address 200.92.187.196.  The Linux
PC must have the PPP daemon up and running for the NET+ARM to connect
successfully.  The /com/0 modem connection provides dial up remote
access services and will assign the connecting client address
202.92.186.10.  The IP addresses for the PPP link are specified in
appconf.h.


The following #defines should be updated in ppp_test.h to the user
specific values:

REMOTE_PEER_CHAP_NAME      Linux CHAP name stored in the PPP user
                           table
REMOTE_PEER_CHAP_SECRET    Linux CHAP secret stored in the PPP user
                           table
REMOTE_PEER_PAP_NAME       Linux PAP username stored in the PPP user
                           table
REMOTE_PEER_PAP_PASSWORD   Linux PAP password stored in the PPP user
                           table
LOCAL_PEER_PAP_NAME        PAP user name used by PPP to authenticate
                           with Linux
LOCAL_PEER_PAP_PASSWORD    PAP password used by PPP to authenticate
                           with Linux
LOCAL_PEER_CHAP_NAME       CHAP name used by PPP to authenticate with
                           Linux
LOCAL_PEER_CHAP_SECRET     CHAP secret used by PPP to authenticate
                           with Linux
DIALUP_CLIENT_PAP_NAME     The dial up client's PAP name stored in
                           the PPP user table.
DIALUP_CLIENT_PASSWORD     The dial up client's PAP password stored
                           in the PPP user table.
DIALUP_CLIENT_CHAP_NAME    The dial up client's CHAP name stored in
                           the PPP user table.
DIALUP_CLIENT_SECRET       The dial up client's CHAP secret stored in 
                           the PPP user table.


This application requires and allows PPP PAP authentication on the PPP
direct serial link.  Thus, the direct serial link allows the PPP peers
to perform bidirectional authentication.  If you wish to change the
default authentication settings, change the values of

#define LCP_SERIAL_WANT_AUTH_PROTOCOL
#define LCP_SERIAL_ALLOW_AUTH_PROTOCOL

in ppp_test.h to either 0 or PPP_CHAP_PROTOCOL.

Likewise, this application requires PPP PAP authentication on the PPP
dialup link.  If you wish to change the default authentication settings,
change the values of

#define LCP_DIALUP_WANT_AUTH_PROTOCOL

in ppp_test.h to either 0 or PPP_CHAP_PROTOCOL.


Most the Digi International development boards have a /com/0 serial port
that supports all the modem control signals and a second serial port
(i.e. /com/1 or /com/2 or /com/3) that supports at least the TX and RX
signals.  If the board's second serial port doesn't support RTS/CTS
handshaking, set #define PPP_SERIAL_RTSCTS_FLOWCONTROL in ppp_test.h
to 0 to use Xon/Xoff software handshaking.


The PPP daemon on the Linux machine can be run by the command
"pppd" on the Linux host via command:

    pppd cua0 38400 crtscts -vj ipcp-accept-local
        ipcp-accept-remote require-chap name linuxc

or

    pppd cua0 38400 crtscts -vj ipcp-accept-local
        ipcp-accept-remote require-pap name linuxp

or

    pppd cua0 38400 xonxoff -vj ipcp-accept-local
        ipcp-accept-remote require-chap name linuxc

or

    pppd cua0 38400 xonxoff -vj ipcp-accept-local
        ipcp-accept-remote require-pap name linuxp

Note 1:  On some Linux versions, serial port devices are referenced
by "ttyS0" instead of "cua0".

Note 2: There is a pppd "silent" option if you want the Linux PPP to
behave as a server and not initiate LCP config-request packets.
Since the direct serial PPP interface in this application is a PPP
server, we do not need the "silent" option for the Linux PPP.


IP Routing can be demonstrated using PING (using Xterm) on the Linux
machine.  The following routes MUST be added to the remote hosts:

1) On the Linux machine (200.92.187.196), add a route for 202.92.186.0
   to gateway 200.92.187.195 on the PPP Interface, for example:

   route add -net 202.0.0.0 netmask 255.0.0.0 gw 200.92.187.195 ppp0

2) On the NT machine (202.92.186.10), add a route for 200.92.187.196
   to gateway 202.92.186.151 on the PPP Interface, for example:

   route add 200.92.187.196 mask 255.255.255.255 202.92.186.10

The route command for the Linux PC must be executed after the direct
serial PPP link is established.  Likewise, the route command for the 
Windows NT/2000/XP PC must be executed after the dial-up PPP connection
is established.

Now on the Linux machine, in an Xterm session type ping 202.92.186.10.
The Linux PC routes the PING request to the target board, the target
board forwards the packet to the Windows PC (via modem), the Windows
PC replies to the target board, and the target baord forwards the
response to the Linux PC.


There are two files to be edited in the Linux machine directory:

1) /etc/ppp/pap-secrets
2) /etc/ppp/chap-secrets


The edited pap-secrets file must be:

# client      server         secret       IP addresses

  linuxp      netarmp        machine       *

  netarmp     linuxp         board         *


The edited chap-secrets file must be:

# client      server         secret       IP addresses

  netarmc     linuxc         rhl52         *

  linuxc      netarmc        rhl52         *



The following diagram shows the connections required for this
application:

  +-------+                 +---------+
  |       |200.92.187.196   |         |
  | Linux |-----------------|/com/0   |                  +-------+
  |       |   200.92.187.195|         |202.92.186.151    |       |
  +-------+                 |   /com/1|------------------| Modem |
                            |         |                  |       |
                            | NET+ARM |                  +---+---+
                            |         | 7.92.187.138         |
                            | Ethernet|--+                   |
  +--------+                +---------+  |         phone line|
  |        | 7.92.187.218                |                   |
  |        |-----------------------------+->Local Subnet     |
  | Router |                                                 |
  |        |------->Internet                                 |
  |        |                +---------+                      |
  +--------+                |         |                  +---+---+
                            |         |202.92.186.10     |       |
                            | Windows |------------------| Modem |
                            | Dial-up |                  |       |
                            | client  |                  +-------+
                            +---------+


Note:

User should refer to BSP configuration header files to check the features enabled 
for the specific board and modify them as needed.
If BSP is modified, the BSP for the specific platform must be rebuilt.

To enable using PPP, you must set the following #define in bsp_net.h to the
following:

#define BSP_WANT_PPP                        TRUE

For each specific platform, you need to set the following #defines in
bsp_serial.h and gpio.h to the appropriate values:

#define BSP_SERIAL_PORT_1
#define BSP_SERIAL_PORT_x (if applicable)
#define BSP_GPIO_MUX_SERIAL_A
#define BSP_GPIO_MUX_SERIAL_x (if applicable)                       

Make sure the serial port is available on the platform. If different
serial port is used, root.c must be updated to use the correct serial port.

Since this application uses both two serial ports, if no other serial
ports are available for CLI (Command Line Interface) traces, you must
set the following #defines in bsp_cli.h to the following:

#define BSP_CLI_TELNET_ENABLE   TRUE
#define BSP_CLI_SERIAL_ENABLE   FALSE

The above settings enable the CLI trace feature through telnet instead
of through a serial port.

Likewise, if no other serial ports are available for STDIO or the
dialog, you must set the following #defines in bsp_sys.h to the following:

#define BSP_STDIO_PORT NULL
#define BSP_ENABLE_DIALOG FALSE

If no serial ports are available for the dialog, you must set APP_USE_NVRAM
in appconf.h to APP_DO_NOT_USE_NVRAM to use the hardcoded IP parameters in
appconf.h.  Under these circumstances, if you want to use the telnet version
of the CLI, you need to change APP_IP_ADDRESS, APP_IP_SUBNET_MASK and
APP_IP_GATEWAY in appconf.h to valid values.
 

End note


One GNU make file is provided.  Build the target 'image' to
generate an image that can be debugged with gdb, and the file 
image.bin which can be written to flash if the bootloader is used.
Build the target 'rom.bin' to create the file rom.bin which 
can be written to ROM if the bootloader is not used.

The following files are provided with this application.

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file
root.c            contains applicationStart() function


In addition, the following files in the BSP directory are built
as part of this application:

reset.s         contains the reset code
appconf_api.c   contains code used to read settings in appconf.h


The application build file links in the following libraries.  

libbsp.a           contains the BSP code
libtcpip.a         contains the Net+Works TCP/IP stack
libtx.a            contains the ThreadX kernel
libfilesys.a       contains the file system libraries
libftpsvr.a        contains the FTP server library
libposix.a         contains the POSIX layer libraries
libflash.a         contains the Flash driver API library
libtelnsvr.a       contains the Telnet server library
libdnsclnt.a       contains the DNS client library
libaddp.a		   contains the ADDP Library
libssh.a		   contains the SSH Library
libpppintf.a       contains the PPP API library

The application uses the following files located in the
netos\src\linkerScripts directory.  These files are generated
when the BSP is built.

bootldr.dat     bootloader configuration file used to generate the
                file image.bin.  It controls the information placed
                in the bootloader header of the image.

image.ldr       GNU linker script used to build an image that can
                be debugged and used with the bootloader.
                
customize.ldr   Customizable GNU linker script
