Friday, October 28, 2011

The better, easier way to install wanpipe

In this post from march 2011, I described my successful installation of Sangoma software for my Sangoma S518 PCI DSL Modem.

Well, for unknown reasons a couple weeks ago the software failed completely upon a reboot.

So it's time to reinstall. And this time, to do it the right way. (Instructions)

In this case, PPPoE, two interfaces are created, dsl0 and ppp0. Wanrouter creates the physical dsl0 interface, and the pon/poff creates the virtual ppp0 interface that actually shows up in the routing table and enables real network activity.

To install wanrouter, do the following as root:
#Create the build environment
apt-get install gcc g++ automake autoconf libtool make libncurses5-dev flex bison patch libtool linux-headers-$(uname -r)

# Get the latest driver tarball
cd /usr/src
wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-3.5.23.tgz
tar xvfz wanpipe-<version>.tgz

# Create a deb package from the tarball
cd wanpipe-<version>
./Setup builddeb    # no make, no prepare. Setup does it all for you.
dpkg -i wanpipe_<version> 
And that's all for the install.

It seems last time I made a few mistakes. Live and learn:
1) I missed a couple build dependencies like automake and autoconf
2) I used obsolete information to prepare for the installation
3) I completely missed the builddeb option!

Next, configure the dsl0 interface. The DSL line does not need to be connected:
wanrouter hwprobe  # Test if the card is detected
wancfg             # Ncurses tool to configure the wanpipe and interface
                   # Name the interface (foe example dsl0)
                   # Enable the startup and shutdown scripts
                   # Note the name of the configuration file (wanpipe1)

Let's test to make sure wanrouter works:
wanrouter start wanpipe1   # Test - should bring up interface
ifconfig                   # The interface should be on the list
ifconfig dsl0 down         # Test - should bring down interface
ifconfig                   # The interface should *not* be on the list
ifconfig dsl0 up           # Test - should bring up interface
ifconfig                   # The interface should be on the list
wanrouter stop wanpipe1    # Test - should being down interface
ifconfig                   # The interface should *not* be on the list

Next, create and configure the ppp0 connection. The DSL line must be connected for this step to work.
wanrouter start   # Activate wanrouter so pppoeconf can detect it
ppoeconf          # Configure ppp0
                  # The pppoeconf program will ask two important questions:
                  # 1) Do you want to start PPPoE at each startup? 
                  #  NO, because it will fail - dsl0 will not be ready yet.
                  # 2) Do you want to start PPPoE now? 
                  #  You can, but if there are any problems, the process will be 
                  #  orphaned. Kill it with the command 'poff -a'
                  # You can see the PPPoE configuration (link to the dsl0 interface) 
                  # in /etc/ppp/peers/dsl-provider. You can see your dsl username 
                  # and password in /etc/ppp/pap-secrets.

Configuration is complete. DSL connectivity should work now.

Let's test it:

To manually open/close the dsl connection:

wanrouter start     # To bring up the dsl0 interface. Wanrouter does this at boot already.
pon dsl-provider    # To bring up the ppp0 interface, which is the real PPPoE connection 
                    # (with an IP address).
plog                # A handy debugging tool. Take a quick look at the log
ifconfig            # The dsl0 interface does not have an IP. 
                    # The ppp0 interface does have an IP
route               # The upstream DSL server should be showing as a gateway,
                    # and a 'default' route should exist
ping <example>      # Test network connectivity
poff -a             # To close the PPPoE connection, and bring down the ppp0 interface
wanrouter stop      # To bring down the dsl0 interface. Wanrouter does this at shutdown already,


To automatically open/close the dsl connection: Insert a start script and a stop script as follows. Automatically starting takes about 45 seconds:

echo "pon dsl-provider" >> etc/wanpipe/scripts/wanpipe1-dsl0-start
echo "poff -a" >> etc/wanpipe/scripts/wanpipe1-dsl0-stop
# If these don't work, then you may need to use 'wancfg' to enable the start/stop scripts.



For my own reference, here's the Setup output:
me@mysystem:/usr/src/wanpipe-3.5.23# ./Setup builddeb
Enabling the FR Protocol
Enabling the CHDLC Protocol
Enabling the PPP Protocol
Enabling the X25 API Protocol
Enabling the ADSL Protocol
Enabling the Multi Protocol Driver
Enabling the AFT TE1 Support
Enabling the AFT TE3 Support

WARNING: Module installation dir mismatch!
         Linux source name  = 2.6.
         Current image name = 2.6.32-5-686

  If you are building wanpipe modules for the
  currently running image, use the 2.6.32-5-686
  directory (i.e. select 'y') 

Install modules for current image: 2.6.32-5-686 ? (y/n) y

Installing modules for kernel: 2.6.32-5-686 !


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------


  
 WANPIPE DEB BUILD

Wanpipe DEB will be build based on the 
following Environment variables.
 
 1. Linux Source Dir  : /lib/modules/2.6.32-5-686/build

 2. Linux Source Name : 2.6.32-5-686

 3. Current Image Name: 2.6.32-5-686
 
 4. CPU Type          : i686
 
 5. Wan Protocols     : FR-CHDLC-PPP-MFR-MPROT-X25-AFT_TE1-AFT_TE3-ADSL-ATM
 
 6. Build Directory   : /usr/src/wanpipe-3.5.23/debbuild 



Would you like to build WANPIPE DEB ? (y/n) y
Enabling the FR Protocol
Enabling the CHDLC Protocol
Enabling the PPP Protocol
Enabling the X25 API Protocol
Enabling the ADSL Protocol
Enabling the Multi Protocol Driver
Enabling the AFT TE1 Support
Enabling the AFT TE3 Support

 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

WANPIPE INSTALLATION

You are about to install WANPIPE Multi-Protocol
TDM Voice & WAN Router into your system.

This script will examine your system, then install, create
and/or modify necessary files and directories.

You must have Linux Kernel Headers along with
full development tools (i.e. GNU C compiler and utilities)
installed in order to be able to install this product.

This script will automatically compile all WANPIPE kernel
drivers and install them in their appropriate directory.

If you are installing Wanpipe for ASTERISK/ZAPTEL this
script will will prompt you for zaptel source location.

If you have previoulsy installed WANPIPE, this release
will overrite/upgrade full release without the need to
uninstall first!

IMPORTANT:
It is always recommended to say YES to all options
prompted during the install!

Please visit: http://wiki.sangoma.com for more info.


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

Fixing file permissions...

Verifying files and fixing permissions ...Done
Checking for C developement tools ...(gcc) OK
Checking for C++ developement tools ...OK
Checking for Make utility ...OK
Checking for ncurses library ... OK
Checking for Perl developement tools ...OK
Checking for AWK ...OK
Checking for FLEX ...OK
Checking for Patch ...OK
Checking for libtermcap-devel...OK
Checking for bison...OK
Checking for libtool...OK


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------


Installing WANPIPE Device Drivers: Linux KERNEL

To integrate WANPIPE Multi-Protocol Voice & WAN Router 
modules into the Linux kernel, the kernel has to be 
updated with latest wanpipe sources.  Install will only
modify existing wanpipe source that is already in the
Kernel. 

IMPORTANT:
It is always recommended to say YES to all options 
prompted during the install!


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

Setting linux directory to /lib/modules/2.6.32-5-686/build



Upgrading WANPIPE kernel documentation ...Done.


Installing WANPIPE include headers ...Done.

WANPIPE device drivers upgraded successfully!


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

WANPIPE KERNEL DRIVER COMPILATION
 
The next step in WANPIPE installation involves compiling 
WANPIPE kernel modules.  

This script will compile and install WANPIPE modules
into the currently running linux kernel.

For greater customization you will be prompted to
select which Protocol/Drivers you would like to
build into the WANPIPE kernel modules.

Wanpipe for Asterisk/Dahdi/Zaptel
 Default for Asterisk/Dahdi/Zaptel
Wanpipe for Wan Routing/API 
 Default for Wan/IP Routing and Data API
Wanpipe for Asterisk SMG/SS7
 Default for Asterisk SS7
Wanpipe for TDM API
 Default for FreeSwitch and Voice API  

Custom Compilation:
------------------
  Customise WANPIPE driver compilation to add only the
  protocols that you need.  This way one can reduce
  the size of the WANPIPE kernel drivers.

Refer to http://wiki.sangoma.com for more info


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------


Checking for SMP support ...Enabled.

Checking current processor type ...i686

Wan Update Flags:  -DWANPIPE_MOD_266_FORCE_UPDATE


--------------------------------------------------
CFLAGS: gcc -Wp,-MD,.wanpipe.o.d -nostdinc -iwithprefix include -D__LINUX__ -Dlinux -D__KERNEL__ -I/usr/src/wanpipe-3.5.23/debbuild/usr/include/wanpipe -I/lib/modules/2.6.32-5-686/build/include  -DMODULE   -DWANPIPE_MOD_266_FORCE_UPDATE  make: Entering directory `/usr/src/linux-headers-2.6.32-5-686'
make: Leaving directory `/usr/src/linux-headers-2.6.32-5-686'
--------------------------------------------------

Checking for REGPARM kernel option ...
Warning: Failed to determine regparm from Makefile defaulting to YES!

Enabled.

Compiling General WANPIPE Driver for 2.6.X Kernel .....Done.


WAN HWEC module enabled and compiled!

FR compiled for GCC Ver=3 Arch=i686 File:wanpipe_fr.gcc3.i686.regparm.o

PPP/CHDLC compiled for GCC Ver=3 Arch=i686 File:wanpipe_sppp.gcc3.i686.regparm.o

ATM compiled for GCC Ver=3 Arch=i686 File:wanpipe_lip_atm.gcc3.i686.regparm.o

ADSL binary compiled for GCC Ver=3 Arch=i686 File:wanpipe_adsl.gcc3.i686.regparm.o

ATM binary compiled for GCC Ver=3 Arch=i686 File:wanpipe_atm.gcc3.i686.regparm.o

Linking Wanpipe Driver and protocols ...Done.

Updating Kernel Modules ...Done.

Compilation Successful.

 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

WANPIPE META CONFIGURATION

There are two configuration files associated with WANPIPE.  

1) /usr/src/wanpipe-3.5.23/wanrouter.rc: 
 - defines locations of important files such as lock
   and configuration files as well as start/stop 
   order of multiple WANPIPE devices.
2) /usr/src/wanpipe-3.5.23/wanpipe1.conf:
 - main configuration file for each WANPIPE device.
 - defines interfaces, hardware and protocol information.
 - this file can be created using the 'wancfg' GUI
   utility or manually based on sample files located
   in /etc/wanpipe/samples.
   
Please read the WanpipeInstallation.(pdf/txt) manual for further
information.


 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

WANPIPE UTILITIES SETUP

WANPIPE utilities are used to:
 1) create configuration files: for Zaptel and Asterisk
  /usr/sbin/wancfg_zaptel #Zaptel and Asterisk
  /usr/sbin/wancfg_dahdi #Dahdi and Asterisk
  /usr/sbin/wancfg_smg #BRI/SS7, Zaptel and Asterisk
  /usr/sbin/wancfg_tdmapi #TDM API
 2) create WANPIPE WAN/IP configuration files.
  (/usr/sbin/wancfg)
 3) start,stop,restart individual/all devices and interfaces.
  (/usr/sbin/wanrouter)
 4) debug line, protocol and driver problems.
  (/usr/sbin/wanpipemon)
 5) aid in WANPIPE API development
  (/etc/wanpipe/api)

Refer to the WanpipeInstallation.(pdf/txt) for more information.

Compiling WANPIPE LibSangoma API library ...Done.



Compiling WANPIPE Utilities ...Done.


Compiling WANPIPE WanCfg Utility ...Done.


Compiling WANPIPE API Development Utilities ...Skipped, no makefile

Compiling WANPIPE HWEC Utilities ...Done.


 WANPIPE Environment Setup Complete !!!

Installing WANPIPE Files ... !
Installing  WANPIPE Utilities in /usr/src/wanpipe-3.5.23/debbuild/usr/sbin
Installing wanrouter.rc in /usr/src/wanpipe-3.5.23/debbuild/etc/wanpipe
Installing wanpipe libraries in /usr/src/wanpipe-3.5.23/debbuild/etc/wanpipe
Installing firmware in /usr/src/wanpipe-3.5.23/debbuild/etc/wanpipe/firmware
Installing documentation in /usr/src/wanpipe-3.5.23/debbuild/usr/share/doc/wanpipe
Installing sample api code in /usr/src/wanpipe-3.5.23/debbuild/etc/wanpipe/api
Installing AFT Firmware update utility in /usr/src/wanpipe-3.5.23/debbuild/etc/wanpipe/util
Installing driver headers in /usr/src/wanpipe-3.5.23/debbuild/etc/wanpipe/api/include/linux
Installing Hardware Echo Cancel Utilites

 ----------------------------------------------------------
           WANPIPE v3.5.23 Installation Script
     Copyright (c) 1995-2011, Sangoma Technologies Inc.
 ----------------------------------------------------------

WANPIPE INSTALLATON: COMPLETE
 
WANPIPE installation is now complete. WANPIPE kernel drivers 
and configuration/debug utilities have been compiled and installed.

 1) Proceed to configure the WANPIPE drivers:
  Asterisk/Zaptel  : /usr/sbin/wancfg_zaptel
  Asterisk/Dahdi   : /usr/sbin/wancfg_dahdi
  TDM API          : /usr/sbin/wancfg_tdmapi
  SMG SS7/BRI/PRI  : /usr/sbin/wancfg_smg
  WAN Routing/API  : /usr/sbin/wancfg
 2) Use the /usr/sbin/wanrouter startup script to start and stop
    the router. (eg: wanrouter start)
 3) To uninstall WANPIPE package run ./Setup remove
  
Please read http://wiki.sangoma.com for further instructions.


WANPIPE DEB BUILD SUCCESSFUL

The new rpm is located in /usr/src/wanpipe-3.5.23:  wanpipe_3523-k266_i686.deb

To install run:
 dpkg -i 

No comments: